|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import { Button, Card, Classes, Intent } from '@blueprintjs/core';
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import { Vector3 } from 'three';
|
|
|
|
|
import { MathUtils, Vector3 } from 'three';
|
|
|
|
|
import { OBJExporter } from 'three/examples/jsm/exporters/OBJExporter';
|
|
|
|
|
import { begin } from 'xaop';
|
|
|
|
|
import { app } from "../ApplicationServices/Application";
|
|
|
|
@ -23,6 +23,11 @@ import { Polyline } from "../DatabaseServices/Entity/Polyline";
|
|
|
|
|
import { Region } from "../DatabaseServices/Entity/Region";
|
|
|
|
|
import { HardwareCompositeEntity } from '../DatabaseServices/Hardware/HardwareCompositeEntity';
|
|
|
|
|
import { HardwareTopline } from '../DatabaseServices/Hardware/HardwareTopline';
|
|
|
|
|
import { DirectionalLight } from "../DatabaseServices/Lights/DirectionalLight";
|
|
|
|
|
import { HemisphereLight } from '../DatabaseServices/Lights/HemisphereLight';
|
|
|
|
|
import { PointLight } from '../DatabaseServices/Lights/PointLight';
|
|
|
|
|
import { RectAreaLight } from '../DatabaseServices/Lights/RectAreaLight';
|
|
|
|
|
import { SpotLight } from '../DatabaseServices/Lights/SpotLight';
|
|
|
|
|
import { PhysicalMaterialRecord } from "../DatabaseServices/PhysicalMaterialRecord";
|
|
|
|
|
import { Shape } from "../DatabaseServices/Shape";
|
|
|
|
|
import { TextureTableRecord } from "../DatabaseServices/Texture";
|
|
|
|
@ -35,6 +40,7 @@ import { ModalPosition } from '../UI/Components/Modal/ModalInterface';
|
|
|
|
|
import { TopPanelStore } from '../UI/Store/TopPanelStore';
|
|
|
|
|
import { Hole } from './../DatabaseServices/3DSolid/Hole';
|
|
|
|
|
import { CompositeEntity } from './../DatabaseServices/Entity/CompositeEntity';
|
|
|
|
|
|
|
|
|
|
export class ExportDataModal extends React.Component<{ msg: string; }, {}>{
|
|
|
|
|
private removeFuncs: Function[] = []; //移除注入
|
|
|
|
|
private Close()
|
|
|
|
@ -131,6 +137,16 @@ export function Entitys2Data(ents: Entity[]): Data
|
|
|
|
|
d.Entitys.push(ConvertRevolve2Data(e));
|
|
|
|
|
else if (e instanceof EntityRef)
|
|
|
|
|
d.Entitys.push(ConveEntityRef2Data(e));
|
|
|
|
|
else if (e instanceof DirectionalLight)
|
|
|
|
|
d.Entitys.push(ConverDirectionalLight2Data(e));
|
|
|
|
|
else if (e instanceof PointLight)
|
|
|
|
|
d.Entitys.push(ConverPointLight2Data(e));
|
|
|
|
|
else if (e instanceof SpotLight)
|
|
|
|
|
d.Entitys.push(ConverSpotLight2Data(e));
|
|
|
|
|
else if (e instanceof RectAreaLight)
|
|
|
|
|
d.Entitys.push(ConverRectAreaLight2Data(e));
|
|
|
|
|
else if (e instanceof HemisphereLight)
|
|
|
|
|
d.Entitys.push(ConverHemisphereLight2Data(e));
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
@ -161,7 +177,7 @@ export function Entitys2Data(ents: Entity[]): Data
|
|
|
|
|
|
|
|
|
|
function Curve2Data(cu: Curve, AligenToWCS = true): Object
|
|
|
|
|
{
|
|
|
|
|
let cud: any = { };
|
|
|
|
|
let cud: any = {};
|
|
|
|
|
if (cu instanceof Polyline)
|
|
|
|
|
{
|
|
|
|
|
cud.Type = "Polyline";
|
|
|
|
@ -185,7 +201,7 @@ function Curve2Data(cu: Curve, AligenToWCS = true): Object
|
|
|
|
|
|
|
|
|
|
function ConvertBoard2Data(br: ExtrudeSolid): Object
|
|
|
|
|
{
|
|
|
|
|
let ed: any = { };
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = br.Id?.Index ?? 0;
|
|
|
|
|
ed.OCS = br.OCSNoClone.toArray();
|
|
|
|
|
ed.Thickness = br.Thickness;
|
|
|
|
@ -211,7 +227,7 @@ function ConvertBoard2Data(br: ExtrudeSolid): Object
|
|
|
|
|
|
|
|
|
|
function ConverSweep2Data(e: SweepSolid)
|
|
|
|
|
{
|
|
|
|
|
let ed: any = { };
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = e.Id?.Index ?? 0;
|
|
|
|
|
ed.Type = "Sweep";
|
|
|
|
|
ed.OCS = e.OCS.toArray();
|
|
|
|
@ -231,7 +247,7 @@ function ConveRegion2Data(e: Region)
|
|
|
|
|
{
|
|
|
|
|
e = e.Clone();
|
|
|
|
|
|
|
|
|
|
let reg: any = { };
|
|
|
|
|
let reg: any = {};
|
|
|
|
|
reg.Type = "Region";
|
|
|
|
|
|
|
|
|
|
let ocsInv = e.OCSInv;
|
|
|
|
@ -244,7 +260,7 @@ function ConveRegion2Data(e: Region)
|
|
|
|
|
|
|
|
|
|
function ConveEntityRef2Data(e: EntityRef)
|
|
|
|
|
{
|
|
|
|
|
let ref: any = { };
|
|
|
|
|
let ref: any = {};
|
|
|
|
|
ref.Id = e.Id?.Index ?? 0;
|
|
|
|
|
ref.Type = "Ref";
|
|
|
|
|
ref.Url = e.Url;
|
|
|
|
@ -258,7 +274,7 @@ function ConveEntityRef2Data(e: EntityRef)
|
|
|
|
|
|
|
|
|
|
function ConverShape2Data(e: Shape)
|
|
|
|
|
{
|
|
|
|
|
let d = { } as any;
|
|
|
|
|
let d = {} as any;
|
|
|
|
|
d.Contour = Curve2Data(e.Outline.Curve);
|
|
|
|
|
d.Holes = e.Holes.map(c => Curve2Data(c.Curve));
|
|
|
|
|
return d;
|
|
|
|
@ -266,7 +282,7 @@ function ConverShape2Data(e: Shape)
|
|
|
|
|
|
|
|
|
|
export function ConverMaterialData(material: PhysicalMaterialRecord)
|
|
|
|
|
{
|
|
|
|
|
let d: any = { };
|
|
|
|
|
let d: any = {};
|
|
|
|
|
d.Id = material.Id?.Index ?? 0;
|
|
|
|
|
d.color = material.color;
|
|
|
|
|
d.transparent = material.transparent;
|
|
|
|
@ -287,7 +303,7 @@ export function ConverMaterialData(material: PhysicalMaterialRecord)
|
|
|
|
|
|
|
|
|
|
function ConvertHole2Data(h: Hole)
|
|
|
|
|
{
|
|
|
|
|
let ed: any = { };
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = h.Id?.Index ?? 0;
|
|
|
|
|
ed.OCS = h.OCS.toArray();
|
|
|
|
|
ed.Thickness = h.Height;
|
|
|
|
@ -308,7 +324,7 @@ function ConvertHole2Data(h: Hole)
|
|
|
|
|
|
|
|
|
|
function ConvertRevolve2Data(h: RevolveSolid)
|
|
|
|
|
{
|
|
|
|
|
let ed: any = { };
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = h.Id?.Index ?? 0;
|
|
|
|
|
ed.OCS = h.OCS.toArray();
|
|
|
|
|
ed.Type = "Revolve";
|
|
|
|
@ -334,6 +350,126 @@ function CompositeEntity2Data(comp: CompositeEntity)
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ConverDirectionalLight2Data(light: DirectionalLight)
|
|
|
|
|
{
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = light.Id?.Index ?? 0;
|
|
|
|
|
ed.Type = "DirectionalLight";
|
|
|
|
|
ed.LightSourceAngle = light.LightSourceAngle;
|
|
|
|
|
ed.LightSourceSoftAngle = light.LightSourceSoftAngle;
|
|
|
|
|
|
|
|
|
|
ed.Color = light.Color.toArray();
|
|
|
|
|
ed.Intensity = light.Intensity;
|
|
|
|
|
ed.Temperature = light.Temperature;
|
|
|
|
|
ed.IndirectLightingIntensity = light.IndirectLightingIntensity;
|
|
|
|
|
ed.CaseShadow = light.CaseShadow;
|
|
|
|
|
|
|
|
|
|
// ed.SpecularScale = light.SpecularScale; 默认为0
|
|
|
|
|
|
|
|
|
|
//阳光照射方向
|
|
|
|
|
let rotateV = light.Position.sub(light.Target).normalize();
|
|
|
|
|
ed.theta = Math.atan2(rotateV.y, rotateV.x) * MathUtils.RAD2DEG;
|
|
|
|
|
ed.phi = Math.asin(rotateV.z) * MathUtils.RAD2DEG;
|
|
|
|
|
|
|
|
|
|
return ed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ConverPointLight2Data(light: PointLight)
|
|
|
|
|
{
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = light.Id?.Index ?? 0;
|
|
|
|
|
ed.Type = "PointLight";
|
|
|
|
|
|
|
|
|
|
ed.Color = light.Color.toArray();
|
|
|
|
|
ed.Intensity = light.Intensity;
|
|
|
|
|
ed.Temperature = light.Temperature;
|
|
|
|
|
|
|
|
|
|
ed.SourceRadius = light.SourceRadius;
|
|
|
|
|
ed.SoftSourceRadius = light.SoftSourceRadius;
|
|
|
|
|
ed.SourceLength = light.SourceLength;
|
|
|
|
|
|
|
|
|
|
ed.AttenuationRadius = light.AttenuationRadius;
|
|
|
|
|
|
|
|
|
|
ed.IndirectLightingIntensity = light.IndirectLightingIntensity;
|
|
|
|
|
ed.CaseShadow = light.CaseShadow;
|
|
|
|
|
|
|
|
|
|
ed.SpecularScale = light.SpecularScale;
|
|
|
|
|
return ed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ConverSpotLight2Data(light: SpotLight)
|
|
|
|
|
{
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = light.Id?.Index ?? 0;
|
|
|
|
|
ed.Type = "SpotLight";
|
|
|
|
|
|
|
|
|
|
ed.Color = light.Color.toArray();
|
|
|
|
|
ed.Intensity = light.Intensity;
|
|
|
|
|
ed.Temperature = light.Temperature;
|
|
|
|
|
|
|
|
|
|
ed.SourceRadius = light.SourceRadius;
|
|
|
|
|
ed.SoftSourceRadius = light.SoftSourceRadius;
|
|
|
|
|
ed.SourceLength = light.SourceLength;
|
|
|
|
|
|
|
|
|
|
ed.AttenuationRadius = light.AttenuationRadius;
|
|
|
|
|
|
|
|
|
|
ed.InnerConeAngle = light.InnerConeAngle;
|
|
|
|
|
ed.OuterConeAngle = light.OuterConeAngle;
|
|
|
|
|
|
|
|
|
|
ed.IndirectLightingIntensity = light.IndirectLightingIntensity;
|
|
|
|
|
ed.CaseShadow = light.CaseShadow;
|
|
|
|
|
|
|
|
|
|
ed.SpecularScale = light.SpecularScale;
|
|
|
|
|
return ed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ConverRectAreaLight2Data(light: RectAreaLight)
|
|
|
|
|
{
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = light.Id?.Index ?? 0;
|
|
|
|
|
ed.Type = "RectAreaLight";
|
|
|
|
|
|
|
|
|
|
ed.Color = light.Color.toArray();
|
|
|
|
|
ed.Intensity = light.Intensity;
|
|
|
|
|
ed.Temperature = light.Temperature;
|
|
|
|
|
|
|
|
|
|
ed.AttenuationRadius = light.AttenuationRadius;
|
|
|
|
|
|
|
|
|
|
ed.BarnDoorAngle = light.BarnDoorAngle;
|
|
|
|
|
ed.BarnDoorLength = light.BarnDoorLength;
|
|
|
|
|
ed.SourceTexture = light.SourceTexture;
|
|
|
|
|
|
|
|
|
|
ed.IndirectLightingIntensity = light.IndirectLightingIntensity;
|
|
|
|
|
ed.CaseShadow = light.CaseShadow;
|
|
|
|
|
|
|
|
|
|
ed.SpecularScale = light.SpecularScale;
|
|
|
|
|
return ed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ConverHemisphereLight2Data(light: HemisphereLight)
|
|
|
|
|
{
|
|
|
|
|
let ed: any = {};
|
|
|
|
|
ed.Id = light.Id?.Index ?? 0;
|
|
|
|
|
ed.Type = "HemisphereLight";
|
|
|
|
|
|
|
|
|
|
//立方体贴图 默认 不变
|
|
|
|
|
|
|
|
|
|
ed.Color = light.Color.toArray();
|
|
|
|
|
ed.Intensity = light.Intensity;
|
|
|
|
|
|
|
|
|
|
// light.GroundColor 底色(默认黑色)
|
|
|
|
|
|
|
|
|
|
// ed.Temperature = light.Temperature;
|
|
|
|
|
|
|
|
|
|
// ed.IndirectLightingIntensity = light.IndirectLightingIntensity;
|
|
|
|
|
// ed.CaseShadow = light.CaseShadow;
|
|
|
|
|
|
|
|
|
|
// ed.SpecularScale = light.SpecularScale;
|
|
|
|
|
return ed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//OBJ文件
|
|
|
|
|
const objExport = new OBJExporter;
|
|
|
|
|
function GetOBJFileData(en: Entity): string
|
|
|
|
|