mx3d 0.0.39 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/core/mx3d.kernel.min.js +1 -2
- package/core/mx3d.loaders.min.js +1 -2
- package/index.d.ts +579 -4
- package/mx3d.min.js +2 -2
- package/package.json +2 -2
package/mx3d.min.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
varying vec3 localNrm ;`),n.Vertex_Before_PositionUpdated(`
|
|
11
11
|
localPos = position.xyz;
|
|
12
12
|
localNrm = normal;
|
|
13
|
-
`);let e=this.GetTexture(t,i);".png"==t.extension&&(e.hasAlpha=!0,n.alpha=.9),t.length=3.1,
|
|
13
|
+
`);let e=this.GetTexture(t,i);".png"==t.extension&&(e.hasAlpha=!0,n.alpha=.9),t.length||(t.length=3.1),t.width||(t.width=1.6),n.onBindObservable.add(()=>n.getEffect().setTexture("textureData",e)),n.Fragment_Custom_Diffuse(`
|
|
14
14
|
vec3 newUV = vec3(abs(localPos.x)/`+t.width+",abs(localPos.y)/"+t.length+",abs(localPos.z)/"+t.width+`);
|
|
15
15
|
if(abs(localNrm.z)>abs(localNrm.x)){
|
|
16
16
|
vec4 res = texture2D(textureData,newUV.xy);
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
diffuseColor = res.rgb;
|
|
23
23
|
alpha = res.a;
|
|
24
24
|
}
|
|
25
|
-
`),n.freeze()}return n}delete(e=!1){if(this.BOX&&this.BOX.dispose(),this.transparentBox&&this.transparentBox.dispose(!0,!0),this.BOX=null,this.transparentBox=null,e){for(const t in this.resources.map)this.resources.find(t).removeAllFromScene(),this.resources.remove(t);this.resources.clear()}}async GetWalls(e,t){let i=await BABYLON.SceneLoader.LoadAssetContainerAsync(e,t+".gltf",this.app.scene);if(i.meshes){var n=i.meshes[0].getChildMeshes();for(let e=0;e<n.length;e++)this.walls.add(n[e].id,n[e])}}}t=i(14);const y=i.n(t).a.create();y.defaults.headers.post["Content-Type"]="application/json",y.interceptors.request.use(e=>{var t=localStorage.getItem("mx3d-token");return t&&(e.headers.Authorization="Bearer "+t),e},e=>Promise.reject(e)),y.interceptors.response.use(e=>e,e=>{if(e.response)switch(e.response.status){case 401:console.error("开发者授权码异常");break;case 403:console.error("当前用户没有权限");break;case 400:console.error(e.response.data.message)}return Promise.reject(e)});var B,v,w=y;class x{static init(){let e=new p.a.Tween(this.colors[1]).to({r:1,g:0,b:0},500),t=new p.a.Tween(this.colors[1]).to({r:1,g:.5,b:.5},500);t.chain(e),e.chain(t),e.start();let i=new p.a.Tween(this.colors[2]).to({r:1,g:.55,b:0},500),n=new p.a.Tween(this.colors[2]).to({r:0,g:0,b:0},500);i.chain(n),n.chain(i),i.start();let s=new p.a.Tween(this.colors[3]).to({r:1,g:.84,b:0},500),r=new p.a.Tween(this.colors[3]).to({r:0,g:0,b:0},500);s.chain(r),r.chain(s),s.start();let o=new p.a.Tween(this.colors[4]).to({r:0,g:.75,b:1},500),a=new p.a.Tween(this.colors[4]).to({r:0,g:0,b:0},500);o.chain(a),a.chain(o),o.start();let h=new p.a.Tween(this.colors[5]).to({r:.53,g:.8,b:0},500),c=new p.a.Tween(this.colors[5]).to({r:0,g:0,b:0},500);h.chain(c),c.chain(h),h.start();let l=new p.a.Tween(this.colors[6]).to({r:.8,g:.8,b:.8},500),u=new p.a.Tween(this.colors[6]).to({r:0,g:0,b:0},500);l.chain(u),u.chain(l),l.start()}}x.colors={1:BABYLON.Color3.Red(),2:new BABYLON.Color3(1,.5,0),3:BABYLON.Color3.Yellow(),4:new BABYLON.Color3(0,1,1),5:BABYLON.Color3.Green(),6:BABYLON.Color3.Gray()},(t=B=B||{})[t.Opaque=0]="Opaque",t[t.Flash=1]="Flash",t[t.Transparent=2]="Transparent",(t=v=v||{}).leftClick="leftClick",t.rightClick="rightClick",t.doubleClick="doubleClick",t.eover="eover",t.longPress="longPress",t.out="out";class E{constructor(e){this.executes=new f,this.clickEvents=new f,this.touchtime=(new Date).getTime(),this.effectType=B.Opaque,this.app=e}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(v.eover)||this.executes.find(v.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set showBoundingBox(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.showBoundingBox=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}get showBoundingBox(){return this.instance.showBoundingBox}bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.animation=e.animation,this.isAutoPlay=e.isAutoPlay,this.isloop=e.isloop,this.objectType=e.objectType;let t=new BABYLON.Mesh(this.id,this.app.scene),i=this.app.Resources.resources.find(this.modelId);i.meshes[0].getChildMeshes().forEach(e=>{e=e.createInstance(this.id);e.isPickable=!1,e.enablePointerMoveEvents=!1,e.parent=t}),t.rotation=m.ToVector3(e.rotation),t.position=m.ToVector3(e.position),t.scaling=m.ToVector3(e.scaling);e=m.computeBounds(t);t.setBoundingInfo(e),this.instance=this.app.Resources.BOX.clone(this.id),this.instance.id=this.id,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.scaling=new BABYLON.Vector3((e.maximum.x-e.minimum.x)*t.scaling.x,(e.maximum.y-e.minimum.y)*t.scaling.y,(e.maximum.z-e.minimum.z)*t.scaling.z),0==this.instance.scaling.y&&(this.instance.scaling.y=.01),this.instance.position=t.position.clone(),this.instance.position.y=(e.maximum.y-e.minimum.y)/2+t.position.y,this.instance.rotation=t.rotation.clone(),t.setParent(this.instance),this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}computeView(){this.Sight=new d;var e=this.instance.getBoundingInfo(),t=m.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=this.instance.getAbsolutePosition(),this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}optimization(t){this.instance.getChildMeshes().forEach(e=>{t?e.freezeWorldMatrix():e.unfreezeWorldMatrix()}),t?this.instance.freezeWorldMatrix():this.instance.unfreezeWorldMatrix(),this.instance.material&&(t?this.instance.material.freeze():this.instance.material.unfreeze())}alwaysActive(){this.instance.getChildMeshes().forEach(e=>{e.alwaysSelectAsActiveMesh=!0,e.doNotSyncBoundingInfo=!1,e.ignoreNonUniformScaling=!0}),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.doNotSyncBoundingInfo=!1}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var n;e==v.leftClick||e==v.rightClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>{let t=this.clickEvents.find(v.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(v.rightClick);i&&2==e.sourceEvent.button&&i(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==v.doubleClick?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger,e=>t(this,e)):e==v.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==v.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==v.out&&(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0),i&&(this.action||(this.action=new BABYLON.ActionManager(this.app.scene),this.instance.actionManager=this.action),(n=this.executes.find(e))&&this.action.unregisterAction(n),this.executes.remove(e),this.executes.add(e,i),this.action.registerAction(i)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==v.leftClick||e==v.rightClick||e==v.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;var t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),0==this.executes.count()&&(this.action=null,this.instance.actionManager=this.action),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setFlash(t){this.effectType==B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.instancedBuffers&&(e.instancedBuffers.color=x.colors[t])}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Flash)}setOpaque(){this.effectType!=B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.setEnabled(!0),e.instancedBuffers&&(e.instancedBuffers.color=new BABYLON.Color4(1,1,1,1))}),this.instance.disableEdgesRendering(),this.instance.visibility=0,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Opaque)}setTransparent(e=.3){this.effectType==B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>e.setEnabled(!1)),this.instance.visibility=e,this.instance.enableEdgesRendering(),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Transparent)}play(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(t=>{let i;t.animations.forEach(e=>{-1!=e.name.indexOf("open")&&(i=e)}),i?this.app.scene.beginDirectAnimation(t,[i],0,10*i.getKeys().length,this.isloop):t.animations.forEach(e=>this.app.scene.beginDirectAnimation(t,[e],0,10*e.getKeys().length,this.isloop))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}stop(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(t=>{let i;t.animations.forEach(e=>{-1!=e.name.indexOf("close")&&(i=e)}),i?this.app.scene.beginDirectAnimation(t,[i],0,10*i.getKeys().length,!1):t.animations.forEach(e=>this.app.scene.beginDirectAnimation(t,[e],10*e.getKeys().length,0,!1))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}flyTo(){this.app.Camera.translation(this.Sight,500)}focus(){}}class M extends E{constructor(){super(...arguments),this.baseModel=null}bind(e){this.id=r.getGUID(12),this.objectType="Wall",this.name="墙体",this.instance=_.Tools.MergeMeshes(e.walls,this.app),this.instance.setEnabled(!1),this.instance.receiveShadows=!0,e.t&&""!=e.t?(this.modelId=e.t.modelId,this.baseModel=e.t,this.baseModel.length||(this.baseModel.length=3.1),this.nativeMaterial=this.app.Resources.GetMergeMaterial(e.t,this.app.scene)):this.nativeMaterial=null,this.instance.material=this.nativeMaterial,this.instance.id=this.id,this.instance.name=this.id,this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height,this.alwaysActive(),this.optimization(!0)}}class T extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.height=e.baseModel.height,this.objectType=e.objectType,this.instance=new BABYLON.Mesh(this.id,this.app.scene);let t=this.app.Resources.resources.find(this.modelId);t.meshes[0].getChildMeshes().forEach(e=>{e.createInstance(this.id).parent=this.instance});var i=_.Tools.computeBounds(this.instance);this.instance.rotation=_.Tools.ToVector3(e.rotation),this.instance.position=_.Tools.ToVector3(e.position),this.Sight=_.Tools.getVisualAngle(i,this.app);let n=this.app.Resources.BOX.createInstance(this.id);n.setBoundingInfo(i),n.enablePointerMoveEvents=!1,n.isPickable=!1,n.scaling=new BABYLON.Vector3((i.maximum.x-i.minimum.x)*this.instance.scaling.x,(i.maximum.y-i.minimum.y)*this.instance.scaling.y,(i.maximum.z-i.minimum.z)*this.instance.scaling.z),n.position=this.instance.position.clone(),n.position.y=(i.maximum.y-i.minimum.y)/2+this.instance.position.y,n.rotation=this.instance.rotation.clone(),this.instance.getChildMeshes().forEach(e=>e.setParent(n)),this.instance.dispose(),this.instance=n,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}}class O extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.height=e.baseModel.height,this.objectType=e.objectType,this.instance=new BABYLON.Mesh(this.id,this.app.scene);let t=this.app.Resources.resources.find(this.modelId);t.meshes[0].getChildMeshes().forEach(e=>{e.createInstance(this.id).parent=this.instance});var i=m.computeBounds(this.instance);this.instance.rotation=m.ToVector3(e.rotation),this.instance.position=m.ToVector3(e.position);let n=this.app.Resources.BOX.createInstance(this.id);n.setBoundingInfo(i),n.enablePointerMoveEvents=!1,n.isPickable=!1,n.scaling=new BABYLON.Vector3((i.maximum.x-i.minimum.x)*this.instance.scaling.x,(i.maximum.y-i.minimum.y)*this.instance.scaling.y,(i.maximum.z-i.minimum.z)*this.instance.scaling.z),n.position=this.instance.position.clone(),n.position.y=(i.maximum.y-i.minimum.y)/2+this.instance.position.y,n.rotation=this.instance.rotation.clone(),this.instance.getChildMeshes().forEach(e=>e.setParent(n)),this.instance.dispose(),this.instance=n,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}}class L extends E{}class R extends E{bind(e){this.Sight=new d;let t=m.ToARRVector3(e.lines);this.Sight.focus=t[0].clone(),this.instance=m.createTube(e.id,t,.02,this.app),this.instance.setEnabled(!1),this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.objectType=e.objectType;e=this.app.Resources.GetMaterial(e.baseModel,this.app.scene).clone(this.id);BABYLON.Animation.CreateAndStartAnimation("u",e.diffuseTexture,"vOffset",15,30,0,1,1),e.diffuseTexture.vScale=this.instance.getTotalVertices()/50,this.instance.material=e,this.alwaysActive(),this.computeView()}computeView(){var e=this.instance.getBoundingInfo(),t=m.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var n;e==v.leftClick||e==v.rightClick||e==v.doubleClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>{let t=this.clickEvents.find(v.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(v.rightClick);i&&2==e.sourceEvent.button&&i(this,e);let n=this.clickEvents.find(v.doubleClick);n&&0==e.sourceEvent.button&&(new Date).getTime()-this.touchtime<500&&n(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==v.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==v.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==v.out&&(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0),i&&(this.action||(this.action=new BABYLON.ActionManager(this.app.scene),this.instance.actionManager=this.action),(n=this.executes.find(e))&&this.action.unregisterAction(n),this.executes.remove(e),this.executes.add(e,i),this.action.registerAction(i)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==v.leftClick||e==v.rightClick||e==v.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;var t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),0==this.executes.count()&&(this.action=null,this.instance.actionManager=this.action,this.instance.getChildMeshes().forEach(e=>e.actionManager=this.action)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class C extends E{async bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.objectType=e.objectType,"Cylinder"==e.virtualType?this.instance=BABYLON.MeshBuilder.CreateCylinder(this.id,{height:1,diameterTop:1,diameterBottom:1},this.app.scene):this.instance=BABYLON.MeshBuilder.CreateBox(this.id,{size:1},this.app.scene),this.instance.setEnabled(!1),this.instance.id=this.id;let t=new BABYLON.StandardMaterial(this.id,this.app.scene);t.diffuseColor=BABYLON.Color3.FromHexString(e.color),e.alpha<.98&&(t.alpha=e.alpha,t.alphaMode=2,t.useAlphaFromDiffuseTexture=!0),this.instance.material=t,e.isEdges&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=1,this.instance.edgesColor=new BABYLON.Color4(0,1,1,1)),e.edgesWidth&&0<e.edgesWidth&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=e.edgesWidth,this.instance.edgesColor=BABYLON.Color3.FromHexString(e.edgesColor).toColor4(1)),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.rotation=_.Tools.ToVector3(e.rotation),this.instance.position=_.Tools.ToVector3(e.position),this.instance.scaling=_.Tools.ToVector3(e.scaling),this.alwaysActive(),this.optimization(!0),this.computeView()}}class N extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.objectType=e.objectType;let t={};t.color=e.color,e.size?(t.clearColor=null,t.position=_.Tools.ToVector3(e.position),s=_.Tools.ToVector3(e.rotation),t.rotation=new BABYLON.Vector3(s.x+Math.PI,s.y,s.z),i=Number.parseInt(e.size.replace("px",""))/40,s=e.scaling?_.Tools.ToVector3(e.scaling):BABYLON.Vector3.One(),t.scaling=new BABYLON.Vector3(14*i/50*s.x,1,14*i/50*s.z)):(t.clearColor=e.clearColor,t.position=_.Tools.ToVector3(e.position),t.rotation=_.Tools.ToVector3(e.rotation),t.scaling=_.Tools.ToVector3(e.scaling));var i="bold 100px Arial";let n=new BABYLON.DynamicTexture(this.id,64,this.app.scene,!1);var s=n.getContext();s.font=i;e=s.measureText(this.name).width+8,s=.02*e;n=new BABYLON.DynamicTexture(this.id,{width:e,height:150},this.app.scene,!1);e=new BABYLON.StandardMaterial(this.id,this.app.scene);e.backFaceCulling=!1,e.diffuseTexture=n,t.clearColor||(n.hasAlpha=!0),n.drawText(this.name,null,null,i,t.color,t.clearColor,!1),this.instance=BABYLON.Mesh.CreateGround(this.id,s,3,1,this.app.scene),this.instance.setEnabled(!1),this.instance.scaling=t.scaling,this.instance.position=t.position,this.instance.rotation=t.rotation,this.instance.material=e,this.alwaysActive(),this.optimization(!0),this.computeView()}}class P extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.objectType=e.objectType,this.color=e.color,this.instance=new BABYLON.Mesh(this.id);var t=m.ToARRVector3(e.pints);let i=m.createTube(e.id,t,e.radius,this.app);this.instance.position=i.getBoundingInfo().boundingBox.center.clone(),this.instance.addChild(i),e.rotation&&(this.instance.rotation=m.ToVector3(e.rotation)),e.position&&(this.instance.position=m.ToVector3(e.position)),i.setParent(this.instance.parent),this.instance.dispose(),this.instance=i;let n=new BABYLON.StandardMaterial(e.id,this.app.scene);n.diffuseColor=BABYLON.Color3.FromHexString(e.color),n.alpha=e.alpha,this.alpha=e.alpha,this.instance.material=n,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.setEnabled(!1),this.alwaysActive(),this.optimization(!0),this.computeView()}setColor(e,t,i){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=new BABYLON.Color3(e/255,i/255,t/255),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}reColor(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(this.color),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}computeView(){this.Sight=new d;var e=this.instance.getBoundingInfo(),e=m.getVisualAngle(e,this.app);this.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=e.focus,this.Sight.radius=e.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}setFlash(e=1){this.effectType==B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.emissiveColor=x.colors[e],this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Flash)}setOpaque(){this.effectType!=B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!0),this.instance.material.alpha=this.alpha,this.instance.material.emissiveColor=null,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Opaque)}setTransparent(e=.3){this.effectType==B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.alpha=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Transparent)}}class S extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.objectType=e.objectType,this.instance=BABYLON.MeshBuilder.CreatePolygon("地板",{shape:m.Expand(e.vectors,-.01),holes:e.buckles,sideOrientation:BABYLON.Mesh.DOUBLESIDE},this.app.scene),this.alwaysActive(),this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height,this.instance.id=e.id,this.instance.name="地板";var t=this.app.Resources.GetMaterial(e.baseModel,this.app.scene).clone(e.id),i=this.instance.getBoundingInfo();this.Sight=m.getVisualAngle(i,this.app),e.baseModel.isTiling&&(t.diffuseTexture.uScale=(i.maximum.x-i.minimum.x)/e.baseModel.width,t.diffuseTexture.vScale=(i.maximum.z-i.minimum.z)/e.baseModel.length),this.instance.material=t,this.optimization(!0),this.computeView()}}class k extends E{bind(e){this.id=e.id,this.parentId=e.parentId,this.objectType="Wall",this.instance=this.app.Resources.walls.find(e.id),this.instance&&(this.app.scene.addMesh(this.instance),this.app.Resources.walls.remove(e.id),e.baseModel?(this.modelId=e.baseModel.modelId,this.nativeMaterial=this.app.Resources.GetMergeMaterial(e.baseModel,this.app.scene)):this.nativeMaterial=null,this.instance.material=this.nativeMaterial,this.instance.id=this.id,this.instance.name=this.id,this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView())}}class I extends E{bind(i){let e=!1;this.id=r.getGUID(12),this.name="墙角",this.objectType="Corner";let n=new Array;for(let t=0;t<i.length;t++)if(2<i[t].pints.length){let e=BABYLON.MeshBuilder.CreatePolygon(this.id,{shape:i[t].pints,sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);e.setEnabled(!1),e.position.y=i[t].height,e.isPickable=!0,e.enablePointerMoveEvents=!1,n.push(e)}return n.length<1||(1<n.length?this.instance=m.MergeMeshes(n,this.app):this.instance=n[0],this.instance.id=this.id,this.instance.name=this.id,this.instance.position.y=this.height,this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.alwaysActive(),this.optimization(!0),e=!0),e}}class Y extends E{constructor(e,t){super(e),this.height=0,this.id=t.id,console.log(t),this.objectType=t.objectType,this.name=t.name,this.parentId=t.parentId,this.height=t.height,this.index=t.index}bind(s,e=0){let t=!1;for(let e=0;e<s.length;e++){var i=s[e];if(i.objectType==g.optimizedWall){t=!0;let e=new k(this.app);e.bind(i),e.instance&&this.app.Project.objectDatas.add(e.id,e)}}let o=new Array;for(let t=0;t<s.length;t++){let e=s[t];e.objectType==g.Wall&&(e.height||(e.height=3.1),e.ply||(e.ply=.09),o.push(e))}let r=new f;for(let e=0;e<s.length;e++){let i=s[e];i.objectType==g.Corner&&(r.add(i.id,i.corner),2<i.pints.length&&(i.height=3.1,i.walls.forEach(t=>{o.forEach(e=>{t==e.id&&parseFloat(e.height)<i.height&&(i.height=parseFloat(e.height))})})))}if(!t){let t=new Array;for(let e=0;e<s.length;e++){var n=s[e];n.objectType==g.Corner&&t.push(n)}let e=new I(this.app);e.height=this.height,e.bind(t)?(e.parentId=this.id,this.app.Project.objectDatas.add(e.id,e)):e=null}for(let i=0;i<s.length;i++){let n=s[i];if(n.objectType==g.Floor){n.vectors=new Array;let e=s[i];e.pints.forEach(e=>{r.find(e)||console.log(e),n.vectors.push(r.find(e))}),n.buckles=new Array,e.holes&&e.holes.forEach(e=>{let t=new Array;e.forEach(e=>t.push(r.find(e))),n.buckles.push(t)}),e.middles&&e.middles.forEach(t=>{let i=Array();for(let e=0;e<s.length;e++)s[e].id==t&&s[e].pints.forEach(e=>{e=r.find(e);i.push(new BABYLON.Vector3(e.x,0,e.z))});n.buckles.push(i)});let t=new S(this.app);t.height=this.height,t.bind(n),this.app.Project.objectDatas.add(t.id,t)}}r=null;for(let t=0;t<s.length;t++){var a=s[t];let e;if(a.objectType==g.Window)e=new T(this.app);else if(a.objectType==g.Door)e=new O(this.app);else if(a.objectType==g.Cabinet)e=new L(this.app);else if(a.objectType==g.LeakWater)e=new R(this.app);else if(a.objectType==g.VirtualBox)e=new C(this.app);else if(a.objectType==g.UI3D)e=new N(this.app);else if(a.objectType==g.Conduit)e=new P(this.app);else{if(a.objectType==g.Wall||a.objectType==g.optimizedWall)continue;if(a.objectType==g.Corner)continue;if(a.objectType==g.Floor)continue;e=new E(this.app)}e.bind(a),this.app.Project.objectDatas.add(e.id,e)}if(!t){let r=new f;r.add("body",{t:"",walls:new Array});for(let s=0;s<o.length;s++){let n=BABYLON.MeshBuilder.ExtrudePolygon(o[s].id,{shape:[m.ToVector3(o[s].wtop),m.ToVector3(o[s].wleft),m.ToVector3(o[s].wbottom),m.ToVector3(o[s].wright)],depth:parseFloat(o[s].height),sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);n.setEnabled(!1),n.position.y=parseFloat(o[s].height),n.subMeshes=[];var h=n.getTotalVertices();n.subMeshes.push(new BABYLON.SubMesh(0,0,h,0,6,n)),n.subMeshes.push(new BABYLON.SubMesh(0,1,h,18,6,n)),n.subMeshes.push(new BABYLON.SubMesh(0,2,h,30,6,n));for(let i=0;i<o[s].wallwindows.length;i++){const p=BABYLON.CSG.FromMesh(n);let e=this.app.Project.objectDatas.find(o[s].wallwindows[i]);var c=e.instance.getBoundingInfo(),l=BABYLON.MeshBuilder.CreateBox((new Date).getTime().toString(),{height:c.maximum.y-c.minimum.y,width:c.maximum.x-c.minimum.x,depth:2*parseFloat(o[s].ply)+.1},this.app.scene);l.position=e.instance.position.clone(),l.position.y=(c.maximum.y-c.minimum.y)/2+e.height,l.rotation=e.instance.rotation.clone();c=BABYLON.CSG.FromMesh(l);let t=p.subtract(c);l.dispose(),n.dispose(),n=t.toMesh(o[s].id,null,this.app.scene,!0),n.setEnabled(!1)}let t=r.find(o[s].leftMap.modelId);t||(t={t:o[s].leftMap,walls:new Array},r.add(o[s].leftMap.modelId,t));let i=r.find(o[s].rightMap.modelId);i||(i={t:o[s].rightMap,walls:new Array},r.add(o[s].rightMap.modelId,i));var u=m.DeconsTructMesh(n,parseFloat(o[s].height),this.app);for(let e=0;e<u.length;e++)(2==e||3==e?t:4==e||5==e?i:r.find("body")).walls.push(u[e])}for(const d in r.map)if(0<r.find(d).walls.length){let e=new M(this.app);e.parentId=this.id,e.height=this.height,e.bind(r.find(d)),this.app.Project.objectDatas.add(e.id,e)}}o=null,this.computeView()}computeView(){this.Sight=new d;var e=this.getBounding(),e=m.getVisualAngle(e,this.app);this.Sight.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=e.focus,this.Sight.radius=e.radius,this.Sight.focus.y=this.height}flyTo(){this.app.Camera.flyTo(this.Sight,500)}focus(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(const t in this.app.Project.objectDatas.map){let e=this.app.Project.objectDatas.find(t);e.setEnabled(!0)}(this.app.Project.current=this).app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setEnabled(e){}getBounding(){var i,n;for(const e in this.app.Project.objectDatas.map){let t=this.app.Project.objectDatas.find(e);if(t.objectType!=g.Region){let e=t.instance.getBoundingInfo();i&&n||(i=n=e.boundingBox.center.clone()),i=BABYLON.Vector3.Minimize(i,e.minimum.add(t.instance.position)),n=BABYLON.Vector3.Maximize(n,e.maximum.add(t.instance.position))}}return i&&n||(i=BABYLON.Vector3.Zero(),n=new BABYLON.Vector3(12,this.height,8)),new BABYLON.BoundingInfo(i,n)}dispose(){}}class _{}_.sl="https://www.wodashijie.com/",_.rl="https://models.wodashijie.com/",_.App=class{constructor(e){e.sl&&(_.sl=e.sl),e.rl&&(_.rl=e.rl),w.defaults.baseURL=_.sl,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;",e.container.appendChild(this.canvas),this.engine=new BABYLON.Engine(this.canvas,!0,{premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!0}),this.engine.setHardwareScalingLevel(.5),this.engine.enableOfflineSupport=!1,this.scene=new BABYLON.Scene(this.engine,{useGeometryUniqueIdsMap:!0,useClonedMeshMap:!0,useMaterialMeshMap:!0}),this.scene.useRightHandedSystem=!0,this.scene.getBoundingBoxRenderer().frontColor=BABYLON.Color3.Green(),this.scene.getBoundingBoxRenderer().showBackLines=!1,this.Camera=new n(this),this.HighlightLayer=new BABYLON.HighlightLayer("highlightLayer",this.scene),this.container=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("screenUI"),this.Environment=new u(this),this.Environment.defaultLights(),this.Environment.openAllLight(),this.Resources=new A(this),this.Project=new b(this),_.EffectMgr.init(),this.engine.runRenderLoop(()=>{this.fps&&(this.fps.innerText=this.engine.getFps().toFixed()+" fps"),this.scene.render(),p.a.update()}),window.addEventListener("resize",()=>{this.engine.resize()}),this.scene.onPointerObservable.add(e=>{switch(e.type){case BABYLON.PointerEventTypes.POINTERMOVE:if(!this.ToolTips)return;e.pickInfo&&e.pickInfo.pickedPoint?this.ToolTips.update(e):this.ToolTips.close();break;case BABYLON.PointerEventTypes.POINTERWHEEL:var t;this.Camera.isOverLook?this.Camera._wheel(e.event):(t=1e3/(this.Camera.camera.radius/20),this.Camera.camera.panningSensibility=2e3<t?2e3:t<10?10:t)}}),this.scene.onKeyboardObservable.add(e=>{e.type===BABYLON.KeyboardEventTypes.KEYDOWN&&70===e.event.keyCode&&prompt("请复制输入框内的视角参数",JSON.stringify({alpha:this.Camera.camera.alpha,focus:m.vector3ToJson(this.Camera.camera.target),radius:this.Camera.camera.radius,beta:this.Camera.camera.beta}))})}async load(u){_.pk=u.pk;var e=await w.get(`api/Account/Developer?accessToken=${encodeURIComponent(_.accessToken)}`);if(200==e.status){localStorage.setItem("mx3d-token",e.data);e=await w.get(`api/WorkFiles/GetProject?pk=${_.pk}`);if(200==e.status){let l=e.data;return new Promise(async(n,t)=>{try{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let t=new f;for(let e=0;e<l.length;e++){const a=l[e];!a.baseModel||".gltf"!=a.baseModel.extension||t.find(a.baseModel.modelId)||this.Resources.resources.find(a.baseModel.modelId)||(a.baseModel.objectType=a.objectType,t.add(a.baseModel.modelId,a.baseModel))}let e=0;for(const h in t.map)await this.Resources.loadModelMesh(t.find(h)),e++,u&&u.progress&&u.progress(e/t.count()*.8);e=0,t=null;let i=new f;for(let e=0;e<l.length;e++){var s,r=l[e];r.objectType==g.Region&&(s=new Y(this,r),this.Project.objectDatas.add(s.id,s),i.add(s.id,new Array))}for(let e=0;e<l.length;e++){var o=l[e];if(o.objectType!=g.Region){let e=i.find(o.parentId);e.push(o)}}for(const c in i.map)await this.Project.objectDatas.find(c).bind(i.find(c)),e++,u&&u.progress&&u.progress(.8+e/l.scenes.length*.2);i=null,this.Project.show(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1,n(null),this.engine.resize(),u&&u.complete&&u.complete()}catch(e){t(e)}})}}}},_.Tools=m,_.EffectMgr=x,_.IconFromMesh=class{constructor(e,t,i,n,s,r){this.id=e,this.scene=r,this.url=i,this.scaling=n,this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance=BABYLON.Mesh.CreatePlane(this.id,n,this.scene,!0,BABYLON.Mesh.DOUBLESIDE),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.position=t.clone(),this.instance.position.y+=s,this.instance.billboardMode=BABYLON.Mesh.BILLBOARDMODE_Y;let o=new BABYLON.StandardMaterial("Mat_"+this.id,this.scene);o.diffuseColor=BABYLON.Color3.White(),o.emissiveColor=BABYLON.Color3.White(),this.instance.material=o,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setBackground(){let i=new Image;i.src=this.url,i.onload=()=>{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.scaling.y=this.scaling/(i.width/i.height)/this.scaling;let e=new BABYLON.DynamicTexture(this.id,{width:i.width,height:i.height},this.scene,!1);e.hasAlpha=!0,this.instance.material.diffuseTexture=e;let t=e.getContext();t.drawImage(i,0,0),e.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}addEventListener(t){if(this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setColor(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(e),this.instance.material.emissiveColor=BABYLON.Color3.FromHexString(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setContents(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let n=new Image;n.src=this.url,n.onload=()=>{this.instance.scaling.y=this.scaling/(n.width/n.height)/this.scaling;let t=new BABYLON.DynamicTexture(this.id,{width:n.width,height:n.height},this.scene,!1);t.hasAlpha=!0,this.instance.material.diffuseTexture=t;let e=t.getContext();e.drawImage(n,0,0),i.forEach(e=>t.drawText(e.text,e.left,e.top,"bold "+e.fontSize+" monospace",e.color||"#fffffb","",!0,!0)),t.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}},_.Icon=class{constructor(e,t){this.textDics=new Array,this.id=e,this.scene=t}set background(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._background&&this._background.dispose(),this._background=new BABYLON.GUI.Image(r.getGUID(12)+"_Image",e),this._background.width=this.size.width+"px",this._background.height=this.size.height+"px",this.rect.addControl(this._background),this.onPointerClick&&(this._background.isPointerBlocker=!1,this._background.onPointerClickObservable.add(()=>{this.onPointerClick()})),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setTexts(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.textDics.forEach(e=>e.dispose());for(let t=this.textDics.length=0;t<i.length;t++){let e=new BABYLON.GUI.TextBlock;e.text=i[t].text,e.fontSize=i[t].fontSize||"20px",e.color=i[t].color||"white",e.top=i[t].top||0,e.left=i[t].left||0,this.rect.addControl(e),this.textDics.push(e)}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}line(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._line&&this._line.dispose(),this._line=new BABYLON.GUI.Line,this._line.lineWidth=e.width||1.5,this._line.color=e.color||"green",this._line.y2=this.size.height/2,this.container.addControl(this._line),this._line.linkWithMesh(this.pint),this._line.connectedControl=this.rect,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&this.rect.dispose(),this._line&&this._line.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&(this.rect.isVisible=e),this._line&&(this._line.isVisible=e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}}],l={},h.m=c,h.c=l,h.d=function(e,t,i){h.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},h.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.t=function(t,e){if(1&e&&(t=h(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(h.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)h.d(i,n,function(e){return t[e]}.bind(null,n));return i},h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,"a",t),t},h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},h.p="",h(h.s=44).default;function h(e){if(l[e])return l[e].exports;var t=l[e]={i:e,l:!1,exports:{}};return c[e].call(t.exports,t,t.exports,h),t.l=!0,t.exports}var c,l});
|
|
25
|
+
`),n.freeze()}return n}delete(e=!1){if(this.BOX&&this.BOX.dispose(),this.transparentBox&&this.transparentBox.dispose(!0,!0),this.BOX=null,this.transparentBox=null,e){for(const t in this.resources.map)this.resources.find(t).removeAllFromScene(),this.resources.remove(t);this.resources.clear()}}async GetWalls(e,t){let i=await BABYLON.SceneLoader.LoadAssetContainerAsync(e,t+".gltf",this.app.scene);if(i.meshes){var n=i.meshes[0].getChildMeshes();for(let e=0;e<n.length;e++)this.walls.add(n[e].id,n[e])}}}t=i(14);const y=i.n(t).a.create();y.defaults.headers.post["Content-Type"]="application/json",y.interceptors.request.use(e=>{var t=localStorage.getItem("mx3d-token");return t&&(e.headers.Authorization="Bearer "+t),e},e=>Promise.reject(e)),y.interceptors.response.use(e=>e,e=>{if(e.response)switch(e.response.status){case 401:console.error("开发者授权码异常");break;case 403:console.error("当前用户没有权限");break;case 400:console.error(e.response.data.message)}return Promise.reject(e)});var B,v,w=y;class x{static init(){let e=new p.a.Tween(this.colors[1]).to({r:1,g:0,b:0},500),t=new p.a.Tween(this.colors[1]).to({r:1,g:.5,b:.5},500);t.chain(e),e.chain(t),e.start();let i=new p.a.Tween(this.colors[2]).to({r:1,g:.55,b:0},500),n=new p.a.Tween(this.colors[2]).to({r:0,g:0,b:0},500);i.chain(n),n.chain(i),i.start();let s=new p.a.Tween(this.colors[3]).to({r:1,g:.84,b:0},500),r=new p.a.Tween(this.colors[3]).to({r:0,g:0,b:0},500);s.chain(r),r.chain(s),s.start();let o=new p.a.Tween(this.colors[4]).to({r:0,g:.75,b:1},500),a=new p.a.Tween(this.colors[4]).to({r:0,g:0,b:0},500);o.chain(a),a.chain(o),o.start();let h=new p.a.Tween(this.colors[5]).to({r:.53,g:.8,b:0},500),c=new p.a.Tween(this.colors[5]).to({r:0,g:0,b:0},500);h.chain(c),c.chain(h),h.start();let l=new p.a.Tween(this.colors[6]).to({r:.8,g:.8,b:.8},500),u=new p.a.Tween(this.colors[6]).to({r:0,g:0,b:0},500);l.chain(u),u.chain(l),l.start()}}x.colors={1:BABYLON.Color3.Red(),2:new BABYLON.Color3(1,.5,0),3:BABYLON.Color3.Yellow(),4:new BABYLON.Color3(0,1,1),5:BABYLON.Color3.Green(),6:BABYLON.Color3.Gray()},(t=B=B||{})[t.Opaque=0]="Opaque",t[t.Flash=1]="Flash",t[t.Transparent=2]="Transparent",(t=v=v||{}).leftClick="leftClick",t.rightClick="rightClick",t.doubleClick="doubleClick",t.eover="eover",t.longPress="longPress",t.out="out";class E{constructor(e){this.executes=new f,this.clickEvents=new f,this.touchtime=(new Date).getTime(),this.effectType=B.Opaque,this.app=e}setEnabled(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),e?(this.instance.isPickable=0<this.executes.count(),this.executes.find(v.eover)||this.executes.find(v.out)?this.instance.enablePointerMoveEvents=!0:this.instance.enablePointerMoveEvents=!1):(this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}set showBoundingBox(e){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.showBoundingBox=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}get showBoundingBox(){return this.instance.showBoundingBox}bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.animation=e.animation,this.isAutoPlay=e.isAutoPlay,this.isloop=e.isloop,this.objectType=e.objectType;let t=new BABYLON.Mesh(this.id,this.app.scene),i=this.app.Resources.resources.find(this.modelId);i.meshes[0].getChildMeshes().forEach(e=>{e=e.createInstance(this.id);e.isPickable=!1,e.enablePointerMoveEvents=!1,e.parent=t}),t.rotation=m.ToVector3(e.rotation),t.position=m.ToVector3(e.position),t.scaling=m.ToVector3(e.scaling);e=m.computeBounds(t);t.setBoundingInfo(e),this.instance=this.app.Resources.BOX.clone(this.id),this.instance.id=this.id,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.scaling=new BABYLON.Vector3((e.maximum.x-e.minimum.x)*t.scaling.x,(e.maximum.y-e.minimum.y)*t.scaling.y,(e.maximum.z-e.minimum.z)*t.scaling.z),0==this.instance.scaling.y&&(this.instance.scaling.y=.01),this.instance.position=t.position.clone(),this.instance.position.y=(e.maximum.y-e.minimum.y)/2+t.position.y,this.instance.rotation=t.rotation.clone(),t.setParent(this.instance),this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}computeView(){this.Sight=new d;var e=this.instance.getBoundingInfo(),t=m.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.focus=this.instance.getAbsolutePosition(),this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}optimization(t){this.instance.getChildMeshes().forEach(e=>{t?e.freezeWorldMatrix():e.unfreezeWorldMatrix()}),t?this.instance.freezeWorldMatrix():this.instance.unfreezeWorldMatrix(),this.instance.material&&(t?this.instance.material.freeze():this.instance.material.unfreeze())}alwaysActive(){this.instance.getChildMeshes().forEach(e=>{e.alwaysSelectAsActiveMesh=!0,e.doNotSyncBoundingInfo=!1,e.ignoreNonUniformScaling=!0}),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.doNotSyncBoundingInfo=!1}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var n;e==v.leftClick||e==v.rightClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>{let t=this.clickEvents.find(v.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(v.rightClick);i&&2==e.sourceEvent.button&&i(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==v.doubleClick?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger,e=>t(this,e)):e==v.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==v.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==v.out&&(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0),i&&(this.action||(this.action=new BABYLON.ActionManager(this.app.scene),this.instance.actionManager=this.action),(n=this.executes.find(e))&&this.action.unregisterAction(n),this.executes.remove(e),this.executes.add(e,i),this.action.registerAction(i)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==v.leftClick||e==v.rightClick||e==v.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;var t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),0==this.executes.count()&&(this.action=null,this.instance.actionManager=this.action),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setFlash(t){this.effectType==B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.instancedBuffers&&(e.instancedBuffers.color=x.colors[t])}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Flash)}setOpaque(){this.effectType!=B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>{e.setEnabled(!0),e.instancedBuffers&&(e.instancedBuffers.color=new BABYLON.Color4(1,1,1,1))}),this.instance.disableEdgesRendering(),this.instance.visibility=0,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Opaque)}setTransparent(e=.3){this.effectType==B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(e=>e.setEnabled(!1)),this.instance.visibility=e,this.instance.enableEdgesRendering(),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Transparent)}play(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(t=>{let i;t.animations.forEach(e=>{-1!=e.name.indexOf("open")&&(i=e)}),i?this.app.scene.beginDirectAnimation(t,[i],0,10*i.getKeys().length,this.isloop):t.animations.forEach(e=>this.app.scene.beginDirectAnimation(t,[e],0,10*e.getKeys().length,this.isloop))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}stop(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.getChildMeshes().forEach(t=>{let i;t.animations.forEach(e=>{-1!=e.name.indexOf("close")&&(i=e)}),i?this.app.scene.beginDirectAnimation(t,[i],0,10*i.getKeys().length,!1):t.animations.forEach(e=>this.app.scene.beginDirectAnimation(t,[e],10*e.getKeys().length,0,!1))}),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}flyTo(){this.app.Camera.translation(this.Sight,500)}focus(){}}class M extends E{constructor(){super(...arguments),this.baseModel=null}bind(e){this.id=r.getGUID(12),this.objectType="Wall",this.name="墙体",this.instance=_.Tools.MergeMeshes(e.walls,this.app),this.instance.setEnabled(!1),this.instance.receiveShadows=!0,e.t&&""!=e.t?(this.modelId=e.t.modelId,this.baseModel=e.t,this.baseModel.length||(this.baseModel.length=3.1),this.nativeMaterial=this.app.Resources.GetMergeMaterial(e.t,this.app.scene)):this.nativeMaterial=null,this.instance.material=this.nativeMaterial,this.instance.id=this.id,this.instance.name=this.id,this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height,this.alwaysActive(),this.optimization(!0)}}class T extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.height=e.baseModel.height,this.objectType=e.objectType,this.instance=new BABYLON.Mesh(this.id,this.app.scene);let t=this.app.Resources.resources.find(this.modelId);t.meshes[0].getChildMeshes().forEach(e=>{e.createInstance(this.id).parent=this.instance});var i=_.Tools.computeBounds(this.instance);this.instance.rotation=_.Tools.ToVector3(e.rotation),this.instance.position=_.Tools.ToVector3(e.position),this.Sight=_.Tools.getVisualAngle(i,this.app);let n=this.app.Resources.BOX.createInstance(this.id);n.setBoundingInfo(i),n.enablePointerMoveEvents=!1,n.isPickable=!1,n.scaling=new BABYLON.Vector3((i.maximum.x-i.minimum.x)*this.instance.scaling.x,(i.maximum.y-i.minimum.y)*this.instance.scaling.y,(i.maximum.z-i.minimum.z)*this.instance.scaling.z),n.position=this.instance.position.clone(),n.position.y=(i.maximum.y-i.minimum.y)/2+this.instance.position.y,n.rotation=this.instance.rotation.clone(),this.instance.getChildMeshes().forEach(e=>e.setParent(n)),this.instance.dispose(),this.instance=n,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}}class O extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.height=e.baseModel.height,this.objectType=e.objectType,this.instance=new BABYLON.Mesh(this.id,this.app.scene);let t=this.app.Resources.resources.find(this.modelId);t.meshes[0].getChildMeshes().forEach(e=>{e.createInstance(this.id).parent=this.instance});var i=m.computeBounds(this.instance);this.instance.rotation=m.ToVector3(e.rotation),this.instance.position=m.ToVector3(e.position);let n=this.app.Resources.BOX.createInstance(this.id);n.setBoundingInfo(i),n.enablePointerMoveEvents=!1,n.isPickable=!1,n.scaling=new BABYLON.Vector3((i.maximum.x-i.minimum.x)*this.instance.scaling.x,(i.maximum.y-i.minimum.y)*this.instance.scaling.y,(i.maximum.z-i.minimum.z)*this.instance.scaling.z),n.position=this.instance.position.clone(),n.position.y=(i.maximum.y-i.minimum.y)/2+this.instance.position.y,n.rotation=this.instance.rotation.clone(),this.instance.getChildMeshes().forEach(e=>e.setParent(n)),this.instance.dispose(),this.instance=n,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView()}}class L extends E{}class R extends E{bind(e){this.Sight=new d;let t=m.ToARRVector3(e.lines);this.Sight.focus=t[0].clone(),this.instance=m.createTube(e.id,t,.02,this.app),this.instance.setEnabled(!1),this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.objectType=e.objectType;e=this.app.Resources.GetMaterial(e.baseModel,this.app.scene).clone(this.id);BABYLON.Animation.CreateAndStartAnimation("u",e.diffuseTexture,"vOffset",15,30,0,1,1),e.diffuseTexture.vScale=this.instance.getTotalVertices()/50,this.instance.material=e,this.alwaysActive(),this.computeView()}computeView(){var e=this.instance.getBoundingInfo(),t=m.getVisualAngle(e,this.app);this.Sight.alpha=t.alpha,this.Sight.beta=t.beta,this.Sight.radius=e.boundingSphere.radiusWorld+3,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}addEventListener(e,t){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let i=null;var n;e==v.leftClick||e==v.rightClick||e==v.doubleClick?(this.clickEvents.remove(e),this.clickEvents.add(e,t),this.instance.isPickable=!0,i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>{let t=this.clickEvents.find(v.leftClick);t&&0==e.sourceEvent.button&&t(this,e);let i=this.clickEvents.find(v.rightClick);i&&2==e.sourceEvent.button&&i(this,e);let n=this.clickEvents.find(v.doubleClick);n&&0==e.sourceEvent.button&&(new Date).getTime()-this.touchtime<500&&n(this,e),this.touchtime=(new Date).getTime()}),e="click"):e==v.eover?(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0):e==v.longPress?i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger,e=>t(this,e)):e==v.out&&(i=new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger,e=>t(this,e)),this.instance.enablePointerMoveEvents=!0),i&&(this.action||(this.action=new BABYLON.ActionManager(this.app.scene),this.instance.actionManager=this.action),(n=this.executes.find(e))&&this.action.unregisterAction(n),this.executes.remove(e),this.executes.add(e,i),this.action.registerAction(i)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}removeEventListener(e){if(e==v.leftClick||e==v.rightClick||e==v.doubleClick){if(this.clickEvents.remove(e),0<this.clickEvents.count())return;e="click"}this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;var t=this.executes.find(e);t&&this.action.unregisterAction(t),this.executes.remove(e),0==this.executes.count()&&(this.action=null,this.instance.actionManager=this.action,this.instance.getChildMeshes().forEach(e=>e.actionManager=this.action)),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class C extends E{async bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.objectType=e.objectType,"Cylinder"==e.virtualType?this.instance=BABYLON.MeshBuilder.CreateCylinder(this.id,{height:1,diameterTop:1,diameterBottom:1},this.app.scene):this.instance=BABYLON.MeshBuilder.CreateBox(this.id,{size:1},this.app.scene),this.instance.setEnabled(!1),this.instance.id=this.id;let t=new BABYLON.StandardMaterial(this.id,this.app.scene);t.diffuseColor=BABYLON.Color3.FromHexString(e.color),e.alpha<.98&&(t.alpha=e.alpha,t.alphaMode=2,t.useAlphaFromDiffuseTexture=!0),this.instance.material=t,e.isEdges&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=1,this.instance.edgesColor=new BABYLON.Color4(0,1,1,1)),e.edgesWidth&&0<e.edgesWidth&&(this.instance.enableEdgesRendering(),this.instance.edgesWidth=e.edgesWidth,this.instance.edgesColor=BABYLON.Color3.FromHexString(e.edgesColor).toColor4(1)),this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.rotation=_.Tools.ToVector3(e.rotation),this.instance.position=_.Tools.ToVector3(e.position),this.instance.scaling=_.Tools.ToVector3(e.scaling),this.alwaysActive(),this.optimization(!0),this.computeView()}}class N extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.objectType=e.objectType;let t={};t.color=e.color,e.size?(t.clearColor=null,t.position=_.Tools.ToVector3(e.position),s=_.Tools.ToVector3(e.rotation),t.rotation=new BABYLON.Vector3(s.x+Math.PI,s.y,s.z),i=Number.parseInt(e.size.replace("px",""))/40,s=e.scaling?_.Tools.ToVector3(e.scaling):BABYLON.Vector3.One(),t.scaling=new BABYLON.Vector3(14*i/50*s.x,1,14*i/50*s.z)):(t.clearColor=e.clearColor,t.position=_.Tools.ToVector3(e.position),t.rotation=_.Tools.ToVector3(e.rotation),t.scaling=_.Tools.ToVector3(e.scaling));var i="bold 100px Arial";let n=new BABYLON.DynamicTexture(this.id,64,this.app.scene,!1);var s=n.getContext();s.font=i;e=s.measureText(this.name).width+8,s=.02*e;n=new BABYLON.DynamicTexture(this.id,{width:e,height:150},this.app.scene,!1);e=new BABYLON.StandardMaterial(this.id,this.app.scene);e.backFaceCulling=!1,e.diffuseTexture=n,t.clearColor||(n.hasAlpha=!0),n.drawText(this.name,null,null,i,t.color,t.clearColor,!1),this.instance=BABYLON.Mesh.CreateGround(this.id,s,3,1,this.app.scene),this.instance.setEnabled(!1),this.instance.scaling=t.scaling,this.instance.position=t.position,this.instance.rotation=t.rotation,this.instance.material=e,this.alwaysActive(),this.optimization(!0),this.computeView()}}class P extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.objectType=e.objectType,this.color=e.color,this.instance=new BABYLON.Mesh(this.id);var t=m.ToARRVector3(e.pints);let i=m.createTube(e.id,t,e.radius,this.app);this.instance.position=i.getBoundingInfo().boundingBox.center.clone(),this.instance.addChild(i),e.rotation&&(this.instance.rotation=m.ToVector3(e.rotation)),e.position&&(this.instance.position=m.ToVector3(e.position)),i.setParent(this.instance.parent),this.instance.dispose(),this.instance=i;let n=new BABYLON.StandardMaterial(e.id,this.app.scene);n.diffuseColor=BABYLON.Color3.FromHexString(e.color),n.alpha=e.alpha,this.alpha=e.alpha,this.instance.material=n,this.instance.enablePointerMoveEvents=!1,this.instance.isPickable=!1,this.instance.setEnabled(!1),this.alwaysActive(),this.optimization(!0),this.computeView()}setColor(e,t,i){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=new BABYLON.Color3(e/255,i/255,t/255),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}reColor(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(this.color),this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}computeView(){this.Sight=new d;var e=this.instance.getBoundingInfo(),e=m.getVisualAngle(e,this.app);this.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=e.focus,this.Sight.radius=e.radius,this.Sight.minimumLimit=.3,this.Sight.maximumLimit=2*this.Sight.radius,this.Sight.minBeta=.01,this.Sight.maxBeta=Math.PI/2*.98}setFlash(e=1){this.effectType==B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.emissiveColor=x.colors[e],this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Flash)}setOpaque(){this.effectType!=B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!0),this.instance.material.alpha=this.alpha,this.instance.material.emissiveColor=null,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Opaque)}setTransparent(e=.3){this.effectType==B.Opaque&&(this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.optimization(!1),this.instance.material.alpha=e,this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,this.effectType=B.Transparent)}}class S extends E{bind(e){this.id=e.id,this.name=e.name,this.parentId=e.parentId,this.modelId=e.baseModel.modelId,this.objectType=e.objectType,this.instance=BABYLON.MeshBuilder.CreatePolygon("地板",{shape:m.Expand(e.vectors,-.01),holes:e.buckles,sideOrientation:BABYLON.Mesh.DOUBLESIDE},this.app.scene),this.alwaysActive(),this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.instance.position.y=this.height,this.instance.id=e.id,this.instance.name="地板";var t=this.app.Resources.GetMaterial(e.baseModel,this.app.scene).clone(e.id),i=this.instance.getBoundingInfo();this.Sight=m.getVisualAngle(i,this.app),e.baseModel.isTiling&&(t.diffuseTexture.uScale=(i.maximum.x-i.minimum.x)/e.baseModel.width,t.diffuseTexture.vScale=(i.maximum.z-i.minimum.z)/e.baseModel.length),this.instance.material=t,this.optimization(!0),this.computeView()}}class k extends E{bind(e){this.id=e.id,this.parentId=e.parentId,this.objectType="Wall",this.instance=this.app.Resources.walls.find(e.id),this.instance&&(this.app.scene.addMesh(this.instance),this.app.Resources.walls.remove(e.id),e.baseModel?(this.modelId=e.baseModel.modelId,this.nativeMaterial=this.app.Resources.GetMergeMaterial(e.baseModel,this.app.scene)):this.nativeMaterial=null,this.instance.material=this.nativeMaterial,this.instance.id=this.id,this.instance.name=this.id,this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.alwaysActive(),this.optimization(!0),this.instance.setEnabled(!1),this.computeView())}}class I extends E{bind(i){let e=!1;this.id=r.getGUID(12),this.name="墙角",this.objectType="Corner";let n=new Array;for(let t=0;t<i.length;t++)if(2<i[t].pints.length){let e=BABYLON.MeshBuilder.CreatePolygon(this.id,{shape:i[t].pints,sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);e.setEnabled(!1),e.position.y=i[t].height,e.isPickable=!0,e.enablePointerMoveEvents=!1,n.push(e)}return n.length<1||(1<n.length?this.instance=m.MergeMeshes(n,this.app):this.instance=n[0],this.instance.id=this.id,this.instance.name=this.id,this.instance.position.y=this.height,this.instance.setEnabled(!1),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,this.alwaysActive(),this.optimization(!0),e=!0),e}}class Y extends E{constructor(e,t){super(e),this.height=0,this.id=t.id,this.objectType=t.objectType,this.name=t.name,this.parentId=t.parentId,this.height=t.height,this.index=t.index}bind(s,e=0){let t=!1;for(let e=0;e<s.length;e++){var i=s[e];if(i.objectType==g.optimizedWall){t=!0;let e=new k(this.app);e.bind(i),e.instance&&this.app.Project.objectDatas.add(e.id,e)}}let o=new Array;for(let t=0;t<s.length;t++){let e=s[t];e.objectType==g.Wall&&(e.height||(e.height=3.1),e.ply||(e.ply=.09),o.push(e))}let r=new f;for(let e=0;e<s.length;e++){let i=s[e];i.objectType==g.Corner&&(r.add(i.id,i.corner),2<i.pints.length&&(i.height=3.1,i.walls.forEach(t=>{o.forEach(e=>{t==e.id&&parseFloat(e.height)<i.height&&(i.height=parseFloat(e.height))})})))}if(!t){let t=new Array;for(let e=0;e<s.length;e++){var n=s[e];n.objectType==g.Corner&&t.push(n)}let e=new I(this.app);e.height=this.height,e.bind(t)?(e.parentId=this.id,this.app.Project.objectDatas.add(e.id,e)):e=null}for(let i=0;i<s.length;i++){let n=s[i];if(n.objectType==g.Floor){n.vectors=new Array;let e=s[i];e.pints.forEach(e=>{r.find(e)||console.log(e),n.vectors.push(r.find(e))}),n.buckles=new Array,e.holes&&e.holes.forEach(e=>{let t=new Array;e.forEach(e=>t.push(r.find(e))),n.buckles.push(t)}),e.middles&&e.middles.forEach(t=>{let i=Array();for(let e=0;e<s.length;e++)s[e].id==t&&s[e].pints.forEach(e=>{e=r.find(e);i.push(new BABYLON.Vector3(e.x,0,e.z))});n.buckles.push(i)});let t=new S(this.app);t.height=this.height,t.bind(n),this.app.Project.objectDatas.add(t.id,t)}}r=null;for(let t=0;t<s.length;t++){var a=s[t];let e;if(a.objectType==g.Window)e=new T(this.app);else if(a.objectType==g.Door)e=new O(this.app);else if(a.objectType==g.Cabinet)e=new L(this.app);else if(a.objectType==g.LeakWater)e=new R(this.app);else if(a.objectType==g.VirtualBox)e=new C(this.app);else if(a.objectType==g.UI3D)e=new N(this.app);else if(a.objectType==g.Conduit)e=new P(this.app);else{if(a.objectType==g.Wall||a.objectType==g.optimizedWall)continue;if(a.objectType==g.Corner)continue;if(a.objectType==g.Floor)continue;e=new E(this.app)}e.bind(a),this.app.Project.objectDatas.add(e.id,e)}if(!t){let r=new f;r.add("body",{t:"",walls:new Array});for(let s=0;s<o.length;s++){let n=BABYLON.MeshBuilder.ExtrudePolygon(o[s].id,{shape:[m.ToVector3(o[s].wtop),m.ToVector3(o[s].wleft),m.ToVector3(o[s].wbottom),m.ToVector3(o[s].wright)],depth:parseFloat(o[s].height),sideOrientation:BABYLON.Mesh.FRONTSIDE},this.app.scene);n.setEnabled(!1),n.position.y=parseFloat(o[s].height),n.subMeshes=[];var h=n.getTotalVertices();n.subMeshes.push(new BABYLON.SubMesh(0,0,h,0,6,n)),n.subMeshes.push(new BABYLON.SubMesh(0,1,h,18,6,n)),n.subMeshes.push(new BABYLON.SubMesh(0,2,h,30,6,n));for(let i=0;i<o[s].wallwindows.length;i++){const p=BABYLON.CSG.FromMesh(n);let e=this.app.Project.objectDatas.find(o[s].wallwindows[i]);var c=e.instance.getBoundingInfo(),l=BABYLON.MeshBuilder.CreateBox((new Date).getTime().toString(),{height:c.maximum.y-c.minimum.y,width:c.maximum.x-c.minimum.x,depth:2*parseFloat(o[s].ply)+.1},this.app.scene);l.position=e.instance.position.clone(),l.position.y=(c.maximum.y-c.minimum.y)/2+e.height,l.rotation=e.instance.rotation.clone();c=BABYLON.CSG.FromMesh(l);let t=p.subtract(c);l.dispose(),n.dispose(),n=t.toMesh(o[s].id,null,this.app.scene,!0),n.setEnabled(!1)}let t=r.find(o[s].leftMap.modelId);t||(t={t:o[s].leftMap,walls:new Array},r.add(o[s].leftMap.modelId,t));let i=r.find(o[s].rightMap.modelId);i||(i={t:o[s].rightMap,walls:new Array},r.add(o[s].rightMap.modelId,i));var u=m.DeconsTructMesh(n,parseFloat(o[s].height),this.app);for(let e=0;e<u.length;e++)(2==e||3==e?t:4==e||5==e?i:r.find("body")).walls.push(u[e])}for(const d in r.map)if(0<r.find(d).walls.length){let e=new M(this.app);e.parentId=this.id,e.height=this.height,e.bind(r.find(d)),this.app.Project.objectDatas.add(e.id,e)}}o=null,this.computeView()}computeView(){this.Sight=new d;var e=this.getBounding(),e=m.getVisualAngle(e,this.app);this.Sight.alpha=e.alpha,this.Sight.beta=e.beta,this.Sight.focus=e.focus,this.Sight.radius=e.radius,this.Sight.focus.y=this.height}flyTo(){this.app.Camera.flyTo(this.Sight,500)}focus(){this.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;for(const t in this.app.Project.objectDatas.map){let e=this.app.Project.objectDatas.find(t);e.setEnabled(!0)}(this.app.Project.current=this).app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setEnabled(e){}getBounding(){var i,n;for(const e in this.app.Project.objectDatas.map){let t=this.app.Project.objectDatas.find(e);if(t.objectType!=g.Region){let e=t.instance.getBoundingInfo();i&&n||(i=n=e.boundingBox.center.clone()),i=BABYLON.Vector3.Minimize(i,e.minimum.add(t.instance.position)),n=BABYLON.Vector3.Maximize(n,e.maximum.add(t.instance.position))}}return i&&n||(i=BABYLON.Vector3.Zero(),n=new BABYLON.Vector3(12,this.height,8)),new BABYLON.BoundingInfo(i,n)}dispose(){}}class _{}_.sl="https://www.wodashijie.com/",_.rl="https://models.wodashijie.com/",_.App=class{constructor(e){e.sl&&(_.sl=e.sl),e.rl&&(_.rl=e.rl),w.defaults.baseURL=_.sl,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;",e.container.appendChild(this.canvas),this.engine=new BABYLON.Engine(this.canvas,!0,{premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!0}),this.engine.setHardwareScalingLevel(.5),this.engine.enableOfflineSupport=!1,this.scene=new BABYLON.Scene(this.engine,{useGeometryUniqueIdsMap:!0,useClonedMeshMap:!0,useMaterialMeshMap:!0}),this.scene.useRightHandedSystem=!0,this.scene.getBoundingBoxRenderer().frontColor=BABYLON.Color3.Green(),this.scene.getBoundingBoxRenderer().showBackLines=!1,this.Camera=new n(this),this.HighlightLayer=new BABYLON.HighlightLayer("highlightLayer",this.scene),this.container=BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("screenUI"),this.Environment=new u(this),this.Environment.defaultLights(),this.Environment.openAllLight(),this.Resources=new A(this),this.Project=new b(this),_.EffectMgr.init(),this.engine.runRenderLoop(()=>{this.fps&&(this.fps.innerText=this.engine.getFps().toFixed()+" fps"),this.scene.render(),p.a.update()}),window.addEventListener("resize",()=>{this.engine.resize()}),this.scene.onPointerObservable.add(e=>{switch(e.type){case BABYLON.PointerEventTypes.POINTERMOVE:if(!this.ToolTips)return;e.pickInfo&&e.pickInfo.pickedPoint?this.ToolTips.update(e):this.ToolTips.close();break;case BABYLON.PointerEventTypes.POINTERWHEEL:var t;this.Camera.isOverLook?this.Camera._wheel(e.event):(t=1e3/(this.Camera.camera.radius/20),this.Camera.camera.panningSensibility=2e3<t?2e3:t<10?10:t)}}),this.scene.onKeyboardObservable.add(e=>{e.type===BABYLON.KeyboardEventTypes.KEYDOWN&&70===e.event.keyCode&&prompt("请复制输入框内的视角参数",JSON.stringify({alpha:this.Camera.camera.alpha,focus:m.vector3ToJson(this.Camera.camera.target),radius:this.Camera.camera.radius,beta:this.Camera.camera.beta}))})}async load(u){_.pk=u.pk;var e=await w.get(`api/Account/Developer?accessToken=${encodeURIComponent(_.accessToken)}`);if(200==e.status){localStorage.setItem("mx3d-token",e.data);e=await w.get(`api/WorkFiles/GetProject?pk=${_.pk}`);if(200==e.status){let l=e.data;return new Promise(async(n,t)=>{try{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let t=new f;for(let e=0;e<l.length;e++){const a=l[e];!a.baseModel||".gltf"!=a.baseModel.extension||t.find(a.baseModel.modelId)||this.Resources.resources.find(a.baseModel.modelId)||(a.baseModel.objectType=a.objectType,t.add(a.baseModel.modelId,a.baseModel))}let e=0;for(const h in t.map)await this.Resources.loadModelMesh(t.find(h)),e++,u&&u.progress&&u.progress(e/t.count()*.3);e=0,t=null;let i=new f;for(let e=0;e<l.length;e++){var s,r=l[e];r.objectType==g.Region&&(s=new Y(this,r),this.Project.objectDatas.add(s.id,s),i.add(s.id,new Array))}for(let e=0;e<l.length;e++){var o=l[e];if(o.objectType!=g.Region){let e=i.find(o.parentId);e.push(o)}}for(const c in i.map)await this.Project.objectDatas.find(c).bind(i.find(c)),e++,u&&u.progress&&u.progress(.3+e/i.count()*.7);i=null,this.Project.show(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1,n(null),this.engine.resize(),u&&u.complete&&u.complete()}catch(e){t(e)}})}}}},_.Tools=m,_.EffectMgr=x,_.IconFromMesh=class{constructor(e,t,i,n,s,r){this.id=e,this.scene=r,this.url=i,this.scaling=n,this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance=BABYLON.Mesh.CreatePlane(this.id,n,this.scene,!0,BABYLON.Mesh.DOUBLESIDE),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.position=t.clone(),this.instance.position.y+=s,this.instance.billboardMode=BABYLON.Mesh.BILLBOARDMODE_Y;let o=new BABYLON.StandardMaterial("Mat_"+this.id,this.scene);o.diffuseColor=BABYLON.Color3.White(),o.emissiveColor=BABYLON.Color3.White(),this.instance.material=o,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setBackground(){let i=new Image;i.src=this.url,i.onload=()=>{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.scaling.y=this.scaling/(i.width/i.height)/this.scaling;let e=new BABYLON.DynamicTexture(this.id,{width:i.width,height:i.height},this.scene,!1);e.hasAlpha=!0,this.instance.material.diffuseTexture=e;let t=e.getContext();t.drawImage(i,0,0),e.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}addEventListener(t){if(this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.actionManager&&this.instance.actionManager.dispose(),this.instance.isPickable=!1,this.instance.enablePointerMoveEvents=!1,t){this.instance.isPickable=!0,this.instance.enablePointerMoveEvents=!0;let e=new BABYLON.ActionManager(this.scene);e.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger,e=>t(this.id))),this.instance.actionManager=e}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setColor(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(e),this.instance.material.emissiveColor=BABYLON.Color3.FromHexString(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setContents(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let n=new Image;n.src=this.url,n.onload=()=>{this.instance.scaling.y=this.scaling/(n.width/n.height)/this.scaling;let t=new BABYLON.DynamicTexture(this.id,{width:n.width,height:n.height},this.scene,!1);t.hasAlpha=!0,this.instance.material.diffuseTexture=t;let e=t.getContext();e.drawImage(n,0,0),i.forEach(e=>t.drawText(e.text,e.left,e.top,"bold "+e.fontSize+" monospace",e.color||"#fffffb","",!0,!0)),t.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}},_.Icon=class{constructor(e,t){this.textDics=new Array,this.id=e,this.scene=t}set background(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._background&&this._background.dispose(),this._background=new BABYLON.GUI.Image(r.getGUID(12)+"_Image",e),this._background.width=this.size.width+"px",this._background.height=this.size.height+"px",this.rect.addControl(this._background),this.onPointerClick&&(this._background.isPointerBlocker=!1,this._background.onPointerClickObservable.add(()=>{this.onPointerClick()})),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setTexts(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.textDics.forEach(e=>e.dispose());for(let t=this.textDics.length=0;t<i.length;t++){let e=new BABYLON.GUI.TextBlock;e.text=i[t].text,e.fontSize=i[t].fontSize||"20px",e.color=i[t].color||"white",e.top=i[t].top||0,e.left=i[t].left||0,this.rect.addControl(e),this.textDics.push(e)}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}line(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._line&&this._line.dispose(),this._line=new BABYLON.GUI.Line,this._line.lineWidth=e.width||1.5,this._line.color=e.color||"green",this._line.y2=this.size.height/2,this.container.addControl(this._line),this._line.linkWithMesh(this.pint),this._line.connectedControl=this.rect,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&this.rect.dispose(),this._line&&this._line.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&(this.rect.isVisible=e),this._line&&(this._line.isVisible=e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}}],l={},h.m=c,h.c=l,h.d=function(e,t,i){h.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},h.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.t=function(t,e){if(1&e&&(t=h(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(h.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)h.d(i,n,function(e){return t[e]}.bind(null,n));return i},h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,"a",t),t},h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},h.p="",h(h.s=44).default;function h(e){if(l[e])return l[e].exports;var t=l[e]={i:e,l:!1,exports:{}};return c[e].call(t.exports,t,t.exports,h),t.l=!0,t.exports}var c,l});
|