@2112-lab/central-plant 0.1.3 → 0.1.4
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/dist/bundle/index.js +1 -1
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1
- package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -1
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -1
- package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
- package/dist/cjs/src/analysis/analysis.js +1 -0
- package/dist/cjs/src/analysis/testing.js +1 -0
- package/dist/cjs/src/core/centralPlant.js +1 -0
- package/dist/cjs/src/core/debugLogger.js +1 -0
- package/dist/cjs/src/core/mathUtils.js +1 -0
- package/dist/cjs/src/core/nameUtils.js +1 -0
- package/dist/cjs/src/data/export.js +1 -0
- package/dist/cjs/src/data/import.js +1 -0
- package/dist/cjs/src/data/numerics.js +1 -0
- package/dist/cjs/src/helpers/sceneHelper.js +1 -0
- package/dist/cjs/src/index.js +1 -1
- package/dist/cjs/src/managers/components/animationManager.js +1 -0
- package/dist/cjs/src/managers/components/componentManager.js +1 -0
- package/dist/cjs/src/managers/components/pathfindingManager.js +1 -0
- package/dist/cjs/src/managers/controls/TransformControls.js +1 -0
- package/dist/cjs/src/managers/controls/cameraControlsManager.js +1 -0
- package/dist/cjs/src/managers/controls/dragDropManager.js +1 -0
- package/dist/cjs/src/managers/controls/keyboardControlsManager.js +1 -0
- package/dist/cjs/src/managers/controls/transformControlsManager.js +1 -0
- package/dist/cjs/src/managers/environment/environmentManager.js +1 -0
- package/dist/cjs/src/managers/environment/textureConfig.js +1 -0
- package/dist/cjs/src/managers/scene/sceneExportManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneInitializationManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +1 -0
- package/dist/cjs/src/managers/system/disposalManager.js +1 -0
- package/dist/cjs/src/managers/system/hotReloadManager.js +1 -0
- package/dist/cjs/src/managers/system/performanceMonitor.js +1 -0
- package/dist/cjs/src/rendering/modelPreloader.js +1 -0
- package/dist/cjs/src/rendering/rendering2D.js +1 -0
- package/dist/cjs/src/rendering/rendering3D.js +1 -0
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1
- package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -1
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -1
- package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
- package/dist/esm/src/analysis/analysis.js +1 -0
- package/dist/esm/src/analysis/testing.js +1 -0
- package/dist/esm/src/core/centralPlant.js +1 -0
- package/dist/esm/src/core/debugLogger.js +1 -0
- package/dist/esm/src/core/mathUtils.js +1 -0
- package/dist/esm/src/core/nameUtils.js +1 -0
- package/dist/esm/src/data/export.js +1 -0
- package/dist/esm/src/data/import.js +1 -0
- package/dist/esm/src/data/numerics.js +1 -0
- package/dist/esm/src/helpers/sceneHelper.js +1 -0
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/managers/components/animationManager.js +1 -0
- package/dist/esm/src/managers/components/componentManager.js +1 -0
- package/dist/esm/src/managers/components/pathfindingManager.js +1 -0
- package/dist/esm/src/managers/controls/TransformControls.js +1 -0
- package/dist/esm/src/managers/controls/cameraControlsManager.js +1 -0
- package/dist/esm/src/managers/controls/dragDropManager.js +1 -0
- package/dist/esm/src/managers/controls/keyboardControlsManager.js +1 -0
- package/dist/esm/src/managers/controls/transformControlsManager.js +1 -0
- package/dist/esm/src/managers/environment/environmentManager.js +1 -0
- package/dist/esm/src/managers/environment/textureConfig.js +1 -0
- package/dist/esm/src/managers/scene/sceneExportManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneInitializationManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneTooltipsManager.js +1 -0
- package/dist/esm/src/managers/system/disposalManager.js +1 -0
- package/dist/esm/src/managers/system/hotReloadManager.js +1 -0
- package/dist/esm/src/managers/system/performanceMonitor.js +1 -0
- package/dist/esm/src/rendering/modelPreloader.js +1 -0
- package/dist/esm/src/rendering/rendering2D.js +1 -0
- package/dist/esm/src/rendering/rendering3D.js +1 -0
- package/dist/index.d.ts +52 -255
- package/package.json +3 -6
- package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1
- package/dist/cjs/src/animationManager.js +0 -1
- package/dist/cjs/src/componentManager.js +0 -1
- package/dist/cjs/src/debugLogger.js +0 -1
- package/dist/cjs/src/disposalManager.js +0 -1
- package/dist/cjs/src/environmentManager.js +0 -1
- package/dist/cjs/src/hotReloadManager.js +0 -1
- package/dist/cjs/src/keyboardControlsManager.js +0 -1
- package/dist/cjs/src/nameUtils.js +0 -1
- package/dist/cjs/src/pathfindingManager.js +0 -1
- package/dist/cjs/src/performanceMonitor.js +0 -1
- package/dist/cjs/src/sceneExportManager.js +0 -1
- package/dist/cjs/src/sceneInitializationManager.js +0 -1
- package/dist/cjs/src/textureConfig.js +0 -1
- package/dist/cjs/src/transformControlsManager.js +0 -1
- package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1
- package/dist/esm/src/animationManager.js +0 -1
- package/dist/esm/src/componentManager.js +0 -1
- package/dist/esm/src/debugLogger.js +0 -1
- package/dist/esm/src/disposalManager.js +0 -1
- package/dist/esm/src/environmentManager.js +0 -1
- package/dist/esm/src/hotReloadManager.js +0 -1
- package/dist/esm/src/keyboardControlsManager.js +0 -1
- package/dist/esm/src/nameUtils.js +0 -1
- package/dist/esm/src/pathfindingManager.js +0 -1
- package/dist/esm/src/performanceMonitor.js +0 -1
- package/dist/esm/src/sceneExportManager.js +0 -1
- package/dist/esm/src/sceneInitializationManager.js +0 -1
- package/dist/esm/src/textureConfig.js +0 -1
- package/dist/esm/src/transformControlsManager.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{inherits as t,createClass as e,superPropGet as i,classCallCheck as h,callSuper as n}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{Raycaster as s,Vector3 as a,Quaternion as r,Euler as w,Matrix4 as o,Object3D as l,Mesh as u,MeshBasicMaterial as c,LineBasicMaterial as M,CylinderGeometry as v,BoxGeometry as p,BufferGeometry as f,Float32BufferAttribute as X,OctahedronGeometry as Y,Line as Z,SphereGeometry as d,TorusGeometry as y,PlaneGeometry as k,DoubleSide as m}from"three";var E=new s,S=new a,b=new a,g=new r,T={X:new a(1,0,0),Y:new a(0,1,0),Z:new a(0,0,1)},x={type:"change"},D={type:"mouseDown"},A={type:"mouseUp",mode:null},W={type:"objectChange"},C=function(){function s(t,e){var i;h(this,s),i=n(this,s),void 0===e&&(e=document),i.isTransformControls=!0,i.visible=!1,i.domElement=e,i.domElement.style.touchAction="none";var w=new tt;i.t=w,i.add(w);var o=new et;i.i=o,i.add(o);var l=i;function u(t,e){var i=e;Object.defineProperty(l,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,o[t]=e,w[t]=e,l.dispatchEvent({type:t+"-changed",value:e}),l.dispatchEvent(x))}}),l[t]=e,o[t]=e,w[t]=e}u("camera",t),u("object",void 0),u("enabled",!0),u("axis",null),u("mode","translate"),u("translationSnap",null),u("rotationSnap",null),u("scaleSnap",null),u("space","world"),u("size",1),u("dragging",!1),u("showX",!0),u("showY",!0),u("showZ",!0),u("showXY",!0),u("showYZ",!0),u("showXZ",!0),i.clickDelay=null,i.lastInteractionTime=0;var c=new a,M=new a,v=new r,p=new r,f=new a,X=new r,Y=new a,Z=new a,d=new a,y=new a;return u("worldPosition",c),u("worldPositionStart",M),u("worldQuaternion",v),u("worldQuaternionStart",p),u("cameraPosition",f),u("cameraQuaternion",X),u("pointStart",Y),u("pointEnd",Z),u("rotationAxis",d),u("rotationAngle",0),u("eye",y),i.h=new a,i.o=new a,i.l=new a,i.u=new a,i.M=new a,i.v=new r,i.p=new r,i.k=new a,i.m=new a,i.S=new r,i.T=new a,i.D=new a,i.A=new r,i.W=new a,i.C=P.bind(i),i.P=R.bind(i),i.j=j.bind(i),i.R=z.bind(i),i.I=I.bind(i),i.domElement.addEventListener("pointerdown",i.P),i.domElement.addEventListener("pointermove",i.j),i.domElement.addEventListener("pointerup",i.I),i}return t(s,l),e(s,[{key:"updateMatrixWorld",value:function(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent||this.object.parent.matrixWorld.decompose(this.M,this.v,this.k),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.T),this.p.copy(this.v).invert(),this.S.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.u),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),i(s,"updateMatrixWorld",this,3)([this])}},{key:"pointerHover",value:function(t){if(void 0!==this.object&&!0!==this.dragging){if(this.clickDelay&&this.clickDelay.doubleClickDelay)if(Date.now()-this.lastInteractionTime<this.clickDelay.doubleClickDelay)return;E.setFromCamera(t,this.camera);var e=Q(this.t.picker[this.mode],E);this.axis=e?e.object.name:null}}},{key:"pointerDown",value:function(t){if(void 0!==this.object&&!0!==this.dragging&&0===t.button){if(this.clickDelay&&this.clickDelay.doubleClickDelay){var e=Date.now();if(e-this.lastInteractionTime<this.clickDelay.doubleClickDelay)return;this.lastInteractionTime=e}if(null!==this.axis){E.setFromCamera(t,this.camera);var i=Q(this.i,E,!0);i&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this.D.copy(this.object.position),this.A.copy(this.object.quaternion),this.W.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.m),this.pointStart.copy(i.point).sub(this.worldPositionStart)),this.dragging=!0,D.mode=this.mode,this.dispatchEvent(D)}}}},{key:"pointerMove",value:function(t){var e=this.axis,i=this.mode,h=this.object,n=this.space;if("scale"===i?n="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(n="world"),void 0!==h&&null!==e&&!1!==this.dragging&&-1===t.button){E.setFromCamera(t,this.camera);var s=Q(this.i,E,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this.h.copy(this.pointEnd).sub(this.pointStart),"local"===n&&"XYZ"!==e&&this.h.applyQuaternion(this.S),-1===e.indexOf("X")&&(this.h.x=0),-1===e.indexOf("Y")&&(this.h.y=0),-1===e.indexOf("Z")&&(this.h.z=0),"local"===n&&"XYZ"!==e?this.h.applyQuaternion(this.A).divide(this.k):this.h.applyQuaternion(this.p).divide(this.k),h.position.copy(this.h).add(this.D),this.translationSnap&&("local"===n&&(h.position.applyQuaternion(g.copy(this.A).invert()),-1!==e.search("X")&&(h.position.x=Math.round(h.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(h.position.y=Math.round(h.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(h.position.z=Math.round(h.position.z/this.translationSnap)*this.translationSnap),h.position.applyQuaternion(this.A)),"world"===n&&(h.parent&&h.position.add(S.setFromMatrixPosition(h.parent.matrixWorld)),-1!==e.search("X")&&(h.position.x=Math.round(h.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(h.position.y=Math.round(h.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(h.position.z=Math.round(h.position.z/this.translationSnap)*this.translationSnap),h.parent&&h.position.sub(S.setFromMatrixPosition(h.parent.matrixWorld))));else if("scale"===i){if(-1!==e.search("XYZ")){var a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),b.set(a,a,a)}else S.copy(this.pointStart),b.copy(this.pointEnd),S.applyQuaternion(this.S),b.applyQuaternion(this.S),b.divide(S),-1===e.search("X")&&(b.x=1),-1===e.search("Y")&&(b.y=1),-1===e.search("Z")&&(b.z=1);h.scale.copy(this.W).multiply(b),this.scaleSnap&&(-1!==e.search("X")&&(h.scale.x=Math.round(h.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(h.scale.y=Math.round(h.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(h.scale.z=Math.round(h.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this.h.copy(this.pointEnd).sub(this.pointStart);var r=20/this.worldPosition.distanceTo(S.setFromMatrixPosition(this.camera.matrixWorld));"E"===e?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.o.copy(this.pointStart).normalize(),this.l.copy(this.pointEnd).normalize(),this.rotationAngle*=this.l.cross(this.o).dot(this.eye)<0?1:-1):"XYZE"===e?(this.rotationAxis.copy(this.h).cross(this.eye).normalize(),this.rotationAngle=this.h.dot(S.copy(this.rotationAxis).cross(this.eye))*r):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(T[e]),S.copy(T[e]),"local"===n&&S.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.h.dot(S.cross(this.eye).normalize())*r),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===n&&"E"!==e&&"XYZE"!==e?(h.quaternion.copy(this.A),h.quaternion.multiply(g.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.p),h.quaternion.copy(g.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),h.quaternion.multiply(this.A).normalize())}this.dispatchEvent(x),this.dispatchEvent(W)}}}},{key:"pointerUp",value:function(t){0===t.button&&(this.dragging&&null!==this.axis&&(A.mode=this.mode,this.dispatchEvent(A)),this.dragging=!1,this.axis=null)}},{key:"dispose",value:function(){this.domElement.removeEventListener("pointerdown",this.P),this.domElement.removeEventListener("pointermove",this.j),this.domElement.removeEventListener("pointermove",this.R),this.domElement.removeEventListener("pointerup",this.I),this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}},{key:"attach",value:function(t){return this.object=t,this.visible=!0,this}},{key:"detach",value:function(){return this.object=void 0,this.visible=!1,this.axis=null,this}},{key:"reset",value:function(){this.enabled&&this.dragging&&(this.object.position.copy(this.D),this.object.quaternion.copy(this.A),this.object.scale.copy(this.W),this.dispatchEvent(x),this.dispatchEvent(W),this.pointStart.copy(this.pointEnd))}},{key:"getRaycaster",value:function(){return E}},{key:"getMode",value:function(){return this.mode}},{key:"setMode",value:function(t){this.mode=t}},{key:"setTranslationSnap",value:function(t){this.translationSnap=t}},{key:"setRotationSnap",value:function(t){this.rotationSnap=t}},{key:"setScaleSnap",value:function(t){this.scaleSnap=t}},{key:"setSize",value:function(t){this.size=t}},{key:"setSpace",value:function(t){this.space=t}},{key:"setDelay",value:function(t){this.clickDelay=t}},{key:"updateInteractionTime",value:function(){this.lastInteractionTime=Date.now()}}])}();function P(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};var e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}function j(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this.C(t))}}function R(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this.R),this.pointerHover(this.C(t)),this.pointerDown(this.C(t)))}function z(t){this.enabled&&this.pointerMove(this.C(t))}function I(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this.R),this.pointerUp(this.C(t)))}function Q(t,e,i){for(var h=e.intersectObject(t,!0),n=0;n<h.length;n++)if(h[n].object.visible||i)return h[n];return!1}var G=new w,H=new a(0,1,0),L=new a(0,0,0),N=new o,U=new r,_=new r,B=new a,O=new o,q=new a(1,0,0),F=new a(0,1,0),J=new a(0,0,1),K=new a,V=new a,$=new a,tt=function(){function s(){var t;h(this,s),(t=n(this,s)).isTransformControlsGizmo=!0,t.type="TransformControlsGizmo";var e=new c({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=new M({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),a=e.clone();a.opacity=.15;var r=i.clone();r.opacity=.5;var w=e.clone();w.color.setHex(16711680);var o=e.clone();o.color.setHex(65280);var k=e.clone();k.color.setHex(255);var m=e.clone();m.color.setHex(16711680),m.opacity=.5;var E=e.clone();E.color.setHex(65280),E.opacity=.5;var S=e.clone();S.color.setHex(255),S.opacity=.5;var b=e.clone();b.opacity=.25;var g=e.clone();g.color.setHex(16776960),g.opacity=.25,e.clone().color.setHex(16776960);var T=e.clone();T.color.setHex(7895160);var x=new v(0,.04,.1,12);x.translate(0,.05,0);var D=new p(.08,.08,.08);D.translate(0,.04,0);var A=new f;A.setAttribute("position",new X([0,0,0,1,0,0],3));var W=new v(.0075,.0075,.5,3);function C(t,e){var i=new y(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}W.translate(0,.25,0);var P,j={X:[[new u(x,w),[.5,0,0],[0,0,-Math.PI/2]],[new u(x,w),[-.5,0,0],[0,0,Math.PI/2]],[new u(W,w),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new u(x,o),[0,.5,0]],[new u(x,o),[0,-.5,0],[Math.PI,0,0]],[new u(W,o)]],Z:[[new u(x,k),[0,0,.5],[Math.PI/2,0,0]],[new u(x,k),[0,0,-.5],[-Math.PI/2,0,0]],[new u(W,k),null,[Math.PI/2,0,0]]],XYZ:[[new u(new Y(.1,0),b.clone()),[0,0,0]]],XY:[[new u(new p(.15,.15,.01),S.clone()),[.15,.15,0]]],YZ:[[new u(new p(.15,.15,.01),m.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new u(new p(.15,.15,.01),E.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},R={X:[[new u(new v(.2,0,.6,4),a),[.3,0,0],[0,0,-Math.PI/2]],[new u(new v(.2,0,.6,4),a),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new u(new v(.2,0,.6,4),a),[0,.3,0]],[new u(new v(.2,0,.6,4),a),[0,-.3,0],[0,0,Math.PI]]],Z:[[new u(new v(.2,0,.6,4),a),[0,0,.3],[Math.PI/2,0,0]],[new u(new v(.2,0,.6,4),a),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new u(new Y(.2,0),a)]],XY:[[new u(new p(.2,.2,.01),a),[.15,.15,0]]],YZ:[[new u(new p(.2,.2,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new u(new p(.2,.2,.01),a),[.15,0,.15],[-Math.PI/2,0,0]]]},z={START:[[new u(new Y(.01,2),r),null,null,null,"helper"]],END:[[new u(new Y(.01,2),r),null,null,null,"helper"]],DELTA:[[new Z((P=new f,P.setAttribute("position",new X([0,0,0,1,1,1],3)),P),r),null,null,null,"helper"]],X:[[new Z(A,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Z(A,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Z(A,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},I={XYZE:[[new u(C(.5,1),T),null,[0,Math.PI/2,0]]],X:[[new u(C(.5,.5),w)]],Y:[[new u(C(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new u(C(.5,.5),k),null,[0,Math.PI/2,0]]],E:[[new u(C(.75,1),g),null,[0,Math.PI/2,0]]]},Q={AXIS:[[new Z(A,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},G={XYZE:[[new u(new d(.25,10,8),a)]],X:[[new u(new y(.5,.1,4,24),a),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new u(new y(.5,.1,4,24),a),[0,0,0],[Math.PI/2,0,0]]],Z:[[new u(new y(.5,.1,4,24),a),[0,0,0],[0,0,-Math.PI/2]]],E:[[new u(new y(.75,.1,2,24),a)]]},H={X:[[new u(D,w),[.5,0,0],[0,0,-Math.PI/2]],[new u(W,w),[0,0,0],[0,0,-Math.PI/2]],[new u(D,w),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new u(D,o),[0,.5,0]],[new u(W,o)],[new u(D,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new u(D,k),[0,0,.5],[Math.PI/2,0,0]],[new u(W,k),[0,0,0],[Math.PI/2,0,0]],[new u(D,k),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new u(new p(.15,.15,.01),S),[.15,.15,0]]],YZ:[[new u(new p(.15,.15,.01),m),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new u(new p(.15,.15,.01),E),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new u(new p(.1,.1,.1),b.clone())]]},L={X:[[new u(new v(.2,0,.6,4),a),[.3,0,0],[0,0,-Math.PI/2]],[new u(new v(.2,0,.6,4),a),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new u(new v(.2,0,.6,4),a),[0,.3,0]],[new u(new v(.2,0,.6,4),a),[0,-.3,0],[0,0,Math.PI]]],Z:[[new u(new v(.2,0,.6,4),a),[0,0,.3],[Math.PI/2,0,0]],[new u(new v(.2,0,.6,4),a),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new u(new p(.2,.2,.01),a),[.15,.15,0]]],YZ:[[new u(new p(.2,.2,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new u(new p(.2,.2,.01),a),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new u(new p(.2,.2,.2),a),[0,0,0]]]},N={X:[[new Z(A,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new Z(A,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new Z(A,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function U(t){var e=new l;for(var i in t)for(var h=t[i].length;h--;){var n=t[i][h][0].clone(),s=t[i][h][1],a=t[i][h][2],r=t[i][h][3],w=t[i][h][4];n.name=i,n.tag=w,s&&n.position.set(s[0],s[1],s[2]),a&&n.rotation.set(a[0],a[1],a[2]),r&&n.scale.set(r[0],r[1],r[2]),n.updateMatrix();var o=n.geometry.clone();o.applyMatrix4(n.matrix),n.geometry=o,n.renderOrder=1/0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),e.add(n)}return e}return t.gizmo={},t.picker={},t.helper={},t.add(t.gizmo.translate=U(j)),t.add(t.gizmo.rotate=U(I)),t.add(t.gizmo.scale=U(H)),t.add(t.picker.translate=U(R)),t.add(t.picker.rotate=U(G)),t.add(t.picker.scale=U(L)),t.add(t.helper.translate=U(z)),t.add(t.helper.rotate=U(Q)),t.add(t.helper.scale=U(N)),t.picker.translate.visible=!1,t.picker.rotate.visible=!1,t.picker.scale.visible=!1,t}return t(s,l),e(s,[{key:"updateMatrixWorld",value:function(t){var e=this,h="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:_;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;var n=[];n=(n=(n=n.concat(this.picker[this.mode].children)).concat(this.gizmo[this.mode].children)).concat(this.helper[this.mode].children);for(var a=function(){var t,i=n[r];if(i.visible=!0,i.rotation.set(0,0,0),i.position.copy(e.worldPosition),t=e.camera.isOrthographicCamera?(e.camera.top-e.camera.bottom)/e.camera.zoom:e.worldPosition.distanceTo(e.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*e.camera.fov/360)/e.camera.zoom,7),i.scale.set(1,1,1).multiplyScalar(t*e.size/4),"helper"===i.tag)return i.visible=!1,"AXIS"===i.name?(i.visible=!!e.axis,"X"===e.axis&&(g.setFromEuler(G.set(0,0,0)),i.quaternion.copy(h).multiply(g),Math.abs(H.copy(q).applyQuaternion(h).dot(e.eye))>.9&&(i.visible=!1)),"Y"===e.axis&&(g.setFromEuler(G.set(0,0,Math.PI/2)),i.quaternion.copy(h).multiply(g),Math.abs(H.copy(F).applyQuaternion(h).dot(e.eye))>.9&&(i.visible=!1)),"Z"===e.axis&&(g.setFromEuler(G.set(0,Math.PI/2,0)),i.quaternion.copy(h).multiply(g),Math.abs(H.copy(J).applyQuaternion(h).dot(e.eye))>.9&&(i.visible=!1)),"XYZE"===e.axis&&(g.setFromEuler(G.set(0,Math.PI/2,0)),H.copy(e.rotationAxis),i.quaternion.setFromRotationMatrix(N.lookAt(L,H,F)),i.quaternion.multiply(g),i.visible=e.dragging),"E"===e.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(e.worldPositionStart),i.visible=e.dragging):"END"===i.name?(i.position.copy(e.worldPosition),i.visible=e.dragging):"DELTA"===i.name?(i.position.copy(e.worldPositionStart),i.quaternion.copy(e.worldQuaternionStart),S.set(1e-10,1e-10,1e-10).add(e.worldPositionStart).sub(e.worldPosition).multiplyScalar(-1),S.applyQuaternion(e.worldQuaternionStart.clone().invert()),i.scale.copy(S),i.visible=e.dragging):(i.quaternion.copy(h),e.dragging?i.position.copy(e.worldPositionStart):i.position.copy(e.worldPosition),e.axis&&(i.visible=-1!==e.axis.search(i.name))),1;if(i.quaternion.copy(h),"translate"===e.mode||"scale"===e.mode){var s=.99;"X"===i.name&&Math.abs(H.copy(q).applyQuaternion(h).dot(e.eye))>s&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(H.copy(F).applyQuaternion(h).dot(e.eye))>s&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(H.copy(J).applyQuaternion(h).dot(e.eye))>s&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(H.copy(J).applyQuaternion(h).dot(e.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"YZ"===i.name&&Math.abs(H.copy(q).applyQuaternion(h).dot(e.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XZ"===i.name&&Math.abs(H.copy(F).applyQuaternion(h).dot(e.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)}else"rotate"===e.mode&&(U.copy(h),H.copy(e.eye).applyQuaternion(g.copy(h).invert()),-1!==i.name.search("E")&&i.quaternion.setFromRotationMatrix(N.lookAt(e.eye,L,F)),"X"===i.name&&(g.setFromAxisAngle(q,Math.atan2(-H.y,H.z)),g.multiplyQuaternions(U,g),i.quaternion.copy(g)),"Y"===i.name&&(g.setFromAxisAngle(F,Math.atan2(H.x,H.z)),g.multiplyQuaternions(U,g),i.quaternion.copy(g)),"Z"===i.name&&(g.setFromAxisAngle(J,Math.atan2(H.y,H.x)),g.multiplyQuaternions(U,g),i.quaternion.copy(g)));i.visible=i.visible&&(-1===i.name.indexOf("X")||e.showX),i.visible=i.visible&&(-1===i.name.indexOf("Y")||e.showY),i.visible=i.visible&&(-1===i.name.indexOf("Z")||e.showZ),i.visible=i.visible&&(-1===i.name.indexOf("E")||e.showX&&e.showY&&e.showZ),i.visible=i.visible&&("XY"!==i.name||e.showXY),i.visible=i.visible&&("YZ"!==i.name||e.showYZ),i.visible=i.visible&&("XZ"!==i.name||e.showXZ),i.material.G=i.material.G||i.material.color.clone(),i.material.H=i.material.H||i.material.opacity,i.material.color.copy(i.material.G),i.material.opacity=i.material.H,e.enabled&&e.axis&&(i.name===e.axis||e.axis.split("").some(function(t){return i.name===t}))&&(i.material.color.setHex(16776960),i.material.opacity=1)},r=0;r<n.length;r++)a();i(s,"updateMatrixWorld",this,3)([t])}}])}(),et=function(){function s(){var t;return h(this,s),(t=n(this,s,[new k(1e5,1e5,2,2),new c({visible:!1,wireframe:!0,side:m,transparent:!0,opacity:.1,toneMapped:!1})])).isTransformControlsPlane=!0,t.type="TransformControlsPlane",t}return t(s,u),e(s,[{key:"updateMatrixWorld",value:function(t){var e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),K.copy(q).applyQuaternion("local"===e?this.worldQuaternion:_),V.copy(F).applyQuaternion("local"===e?this.worldQuaternion:_),$.copy(J).applyQuaternion("local"===e?this.worldQuaternion:_),H.copy(V),this.mode){case"translate":case"scale":switch(this.axis){case"X":H.copy(this.eye).cross(K),B.copy(K).cross(H);break;case"Y":H.copy(this.eye).cross(V),B.copy(V).cross(H);break;case"Z":H.copy(this.eye).cross($),B.copy($).cross(H);break;case"XY":B.copy($);break;case"YZ":B.copy(K);break;case"XZ":H.copy($),B.copy(V);break;case"XYZ":case"E":B.set(0,0,0)}break;default:B.set(0,0,0)}0===B.length()?this.quaternion.copy(this.cameraQuaternion):(O.lookAt(S.set(0,0,0),B,H),this.quaternion.setFromRotationMatrix(O)),i(s,"updateMatrixWorld",this,3)([t])}}])}();export{C as TransformControls,tt as TransformControlsGizmo,et as TransformControlsPlane};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,classCallCheck as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import"../../core/debugLogger.js";var r=function(){return t(function t(r){i(this,t),this.sceneViewer=r,this.autoRotateSpeed=1,this.t=!1},[{key:"toggleCameraRotation",value:function(){var t=this.sceneViewer;if(!t.controls||!t.sceneInitializationManager)return!1;var i=t.sceneInitializationManager.toggleAutoRotation();return this.t=i,i&&t.controls.autoRotateSpeed!==this.autoRotateSpeed&&(t.controls.autoRotateSpeed=this.autoRotateSpeed),i}},{key:"isAutoRotating",value:function(){return this.sceneViewer.controls&&(this.t=this.sceneViewer.controls.autoRotate),this.t}},{key:"setAutoRotation",value:function(t){var i=this.sceneViewer;if(i.sceneInitializationManager){var r=i.sceneInitializationManager.toggleAutoRotation(t);return this.t=r,r}return!1}}])}();export{r as CameraControlsManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,classCallCheck as e,asyncToGenerator as i,regenerator as r}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as n from"three";var s=function(){return t(function t(i){e(this,t),this.scene=i.scene,this.camera=i.camera,this.transformManager=i.transformManager,this.modelPreloader=i.modelPreloader,this.componentManager=i.componentManager,this.currentDragComponentData=null,this.dragPreviewSize=null,this.isCreatingDragPreview=!1,this.dragPreviewMesh=null,this.dragPreviewBoundingBox=null,this.dragTargetPosition=null,this.isDragOverScene=!1,this.onComponentDragStart=this.onComponentDragStart.bind(this),this.onComponentDragEnd=this.onComponentDragEnd.bind(this),this.onDragEnter=this.onDragEnter.bind(this),this.onDragLeave=this.onDragLeave.bind(this),this.onDragOver=this.onDragOver.bind(this),this.onDrop=this.onDrop.bind(this)},[{key:"onComponentDragStart",value:(f=i(r().m(function t(e,i){return r().w(function(t){for(;;)switch(t.n){case 0:return this.currentDragComponentData=e,t.n=1,this.calculateDragPreviewSize(e);case 1:return t.a(2,!0)}},t,this)})),function(t,e){return f.apply(this,arguments)})},{key:"onComponentDragEnd",value:function(){return this.currentDragComponentData=null,this.dragPreviewSize=null,this.isCreatingDragPreview=!1,this.clearDragPreview(),this.cleanupDragPreview(),this.dragTargetPosition=null,this.isDragOverScene=!1,!0}},{key:"onDragEnter",value:(l=i(r().m(function t(e,i){var n;return r().w(function(t){for(;;)switch(t.n){case 0:if(e.preventDefault(),this.isDragOverScene=!0,!this.currentDragComponentData)try{(n=e.dataTransfer.getData("application/json"))&&(this.currentDragComponentData=JSON.parse(n))}catch(t){}if(this.dragPreviewSize||!this.currentDragComponentData){t.n=1;break}return t.n=1,this.calculateDragPreviewSize(this.currentDragComponentData);case 1:if(this.dragPreviewMesh||!this.currentDragComponentData||this.isCreatingDragPreview){t.n=4;break}return this.isCreatingDragPreview=!0,t.p=2,t.n=3,this.createDragPreview();case 3:return t.p=3,this.isCreatingDragPreview=!1,t.f(3);case 4:case 5:return t.a(2)}},t,this,[[2,,3,4]])})),function(t,e){return l.apply(this,arguments)})},{key:"onDragLeave",value:function(t,e){e.contains(t.relatedTarget)||(this.isDragOverScene=!1,this.clearDragPreview())}},{key:"onDragOver",value:(c=i(r().m(function t(e,i){var n,s,a,h;return r().w(function(t){for(;;)switch(t.n){case 0:if(e.preventDefault(),e.dataTransfer.dropEffect="copy",this.currentDragComponentData){t.n=4;break}if(t.p=1,!(n=e.dataTransfer.getData("application/json"))){t.n=2;break}if(this.currentDragComponentData=JSON.parse(n),this.dragPreviewSize){t.n=2;break}return t.n=2,this.calculateDragPreviewSize(this.currentDragComponentData);case 2:t.n=4;break;case 3:t.p=3,t.v;case 4:if(!(s=this.calculateDropPosition(e,i))){t.n=6;break}return this.dragTargetPosition=s,t.n=5,this.updateDragPreview(s);case 5:this.dragPreviewMesh&&this.dragPreviewMesh.userData.isFallback&&(a=this.checkBoundingBoxOverlap(),h=a?16711680:65280,this.dragPreviewMesh.material.color.set(h));case 6:return t.a(2)}},t,this,[[1,3]])})),function(t,e){return c.apply(this,arguments)})},{key:"onDrop",value:(o=i(r().m(function t(e,i){var n,s,a,h,u,o,c=arguments;return r().w(function(t){for(;;)switch(t.n){case 0:if(n=c.length>2&&void 0!==c[2]?c[2]:{},e.preventDefault(),this.isDragOverScene=!1,t.p=1,s=e.dataTransfer.getData("application/json")){t.n=2;break}return n.onPlacementCanceled&&n.onPlacementCanceled({reason:"invalid-data",message:"No component data found in drop event"}),t.a(2,!1);case 2:t.p=2,a=JSON.parse(s),t.n=4;break;case 3:return t.p=3,t.v,n.onPlacementCanceled&&n.onPlacementCanceled({reason:"parse-error",message:"Could not parse component data"}),t.a(2,!1);case 4:if(a&&a.libraryId&&a.modelKey){t.n=5;break}return n.onPlacementCanceled&&n.onPlacementCanceled({reason:"invalid-data",message:"Component data missing required fields"}),t.a(2,!1);case 5:if(h=this.calculateDropPosition(e,i)){t.n=6;break}return n.onPlacementCanceled&&n.onPlacementCanceled({reason:"position-error",message:"Could not calculate drop position",componentData:a}),t.a(2,!1);case 6:if(a.position={x:h.x,y:h.y,z:h.z},u=this.checkBoundingBoxOverlap(),o=!1,!u){t.n=7;break}return n.onPlacementCanceled&&n.onPlacementCanceled({reason:"overlap",componentData:a}),t.a(2,!1);case 7:if(!n.onAddComponent){t.n=9;break}return t.n=8,n.onAddComponent(a);case 8:o=t.v,t.n=11;break;case 9:if(!this.componentManager){t.n=11;break}return t.n=10,this.componentManager.addComponentToScene(a);case 10:o=t.v;case 11:return o&&n.onComponentAdded&&n.onComponentAdded({componentData:a,position:h}),t.a(2,o);case 12:return t.p=12,t.v,t.a(2,!1);case 13:return t.p=13,this.clearDragPreview(),this.cleanupDragPreview(),this.currentDragComponentData=null,this.dragPreviewSize=null,this.dragTargetPosition=null,this.isDragOverScene=!1,t.f(13);case 14:return t.a(2)}},t,this,[[2,3],[1,12,13,14]])})),function(t,e){return o.apply(this,arguments)})},{key:"calculateDropPosition",value:function(t,e){if(!this.camera||!e)return null;try{var i,r=e.getBoundingClientRect(),s=(t.clientX-r.left)/r.width*2-1,a=-(t.clientY-r.top)/r.height*2+1,h=new n.Raycaster;h.setFromCamera({x:s,y:a},this.camera);var u=1/((null===(i=this.transformManager)||void 0===i||null===(i=i.snapValues)||void 0===i?void 0:i.translation)||.5),o=null;if(this.scene.traverse(function(t){var e;t.isMesh&&null!==(e=t.userData)&&void 0!==e&&e.isBaseGround&&(o=t)}),o){var c=h.intersectObject(o,!1);if(c.length>0){var l=c[0];return{x:Math.round(l.point.x*u)/u,y:Math.max(0,l.point.y),z:Math.round(l.point.z*u)/u}}}var f=new n.Plane(new n.Vector3(0,1,0),0),v=new n.Vector3;return h.ray.intersectPlane(f,v)&&v?{x:Math.round(v.x*u)/u,y:0,z:Math.round(v.z*u)/u}:{x:0,y:0,z:0}}catch(t){}return null}},{key:"calculateDragPreviewSize",value:(u=i(r().m(function t(e){var i,n,s,a,h,u;return r().w(function(t){for(;;)switch(t.n){case 0:return i=1,n=1,s=1,t.p=1,t.p=2,t.n=3,this.getModelBoundingBox(e);case 3:if(!(a=t.v)){t.n=4;break}i=a.width,n=a.height,s=a.depth,t.n=5;break;case 4:throw new Error("Could not get model bounding box");case 5:t.n=7;break;case 6:t.p=6,t.v,e.dimensions?(i=e.dimensions.width||e.dimensions.x||1,n=e.dimensions.height||e.dimensions.y||1,s=e.dimensions.depth||e.dimensions.z||1):e.boundingBox?(h=e.boundingBox).max&&h.min?(i=Math.abs(h.max.x-h.min.x)||1,n=Math.abs(h.max.y-h.min.y)||1,s=Math.abs(h.max.z-h.min.z)||1):void 0!==h.width&&void 0!==h.height&&void 0!==h.depth?(i=h.width||1,n=h.height||1,s=h.depth||1):"number"==typeof h.x&&"number"==typeof h.y&&"number"==typeof h.z&&(i=h.x||1,n=h.y||1,s=h.z||1):(u=e.type||"").toLowerCase().includes("chiller")?(i=2,n=2,s=2):u.toLowerCase().includes("pump")?(i=1,n=1,s=1):u.toLowerCase().includes("tower")?(i=3,n=4,s=3):(i=1,n=1,s=1);case 7:i=Math.max(i,.5),n=Math.max(n,.5),s=Math.max(s,.5),this.dragPreviewSize={width:i,height:n,depth:s},t.n=9;break;case 8:t.p=8,t.v,this.dragPreviewSize={width:1,height:1,depth:1};case 9:return t.a(2)}},t,this,[[2,6],[1,8]])})),function(t){return u.apply(this,arguments)})},{key:"getModelBoundingBox",value:(h=i(r().m(function t(e){var i,s,a,h,u,o,c;return r().w(function(t){for(;;)switch(t.n){case 0:if(e.libraryId){t.n=1;break}return t.a(2,null);case 1:return t.p=1,s={},t.p=2,t.n=3,fetch("./library/component-dictionary.json");case 3:return a=t.v,t.n=4,a.json();case 4:s=t.v,t.n=6;break;case 5:return t.p=5,t.v,t.a(2,null);case 6:if((h=s[e.libraryId])&&h.modelKey){t.n=7;break}return t.a(2,null);case 7:if(u=null===(i=this.modelPreloader)||void 0===i?void 0:i.getCachedModel(h.modelKey)){t.n=8;break}return t.a(2,null);case 8:return o=(new n.Box3).setFromObject(u),c=o.getSize(new n.Vector3),t.a(2,{width:c.x,height:c.y,depth:c.z});case 9:return t.p=9,t.v,t.a(2,null)}},t,this,[[2,5],[1,9]])})),function(t){return h.apply(this,arguments)})},{key:"updateDragPreview",value:(a=i(r().m(function t(e){return r().w(function(t){for(;;)switch(t.n){case 0:if(this.dragPreviewMesh||this.isCreatingDragPreview){t.n=3;break}return this.isCreatingDragPreview=!0,t.p=1,t.n=2,this.createDragPreview();case 2:return t.p=2,this.isCreatingDragPreview=!1,t.f(2);case 3:this.dragPreviewMesh&&e&&(this.dragPreviewMesh.position.set(e.x,e.y,e.z),this.dragPreviewMesh.visible=!0,this.dragPreviewBoundingBox&&(this.dragPreviewBoundingBox.position.set(e.x,e.y,e.z),this.dragPreviewBoundingBox.visible=!0));case 4:return t.a(2)}},t,this,[[1,,2,3]])})),function(t){return a.apply(this,arguments)})},{key:"createDragPreview",value:(s=i(r().m(function t(){var e,i,s,a,h,u,o,c,l;return r().w(function(t){for(;;)switch(t.n){case 0:if(this.clearDragPreview(),this.scene&&this.currentDragComponentData){t.n=1;break}return t.a(2);case 1:return t.p=1,e={},t.p=2,t.n=3,fetch("./library/component-dictionary.json");case 3:return i=t.v,t.n=4,i.json();case 4:e=t.v,t.n=6;break;case 5:t.p=5,t.v;case 6:if(s=this.currentDragComponentData.libraryId,a=e[s],h=null,a&&a.modelKey&&this.modelPreloader)try{(u=this.modelPreloader.getCachedModel(a.modelKey))&&((h=u.clone()).traverse(function(t){t.isMesh&&(t.material=t.material.clone(),t.material.transparent=!0,t.material.opacity=.4,t.material.depthTest=!0,t.material.depthWrite=!0,t.material.needsUpdate=!0)}),h.userData.isPreview=!0)}catch(t){h=null}return h||(o=this.dragPreviewSize||{width:1,height:1,depth:1},c=new n.BoxGeometry(o.width,o.height,o.depth),l=new n.MeshBasicMaterial({color:65280,wireframe:!0,transparent:!0,opacity:.6}),(h=new n.Mesh(c,l)).userData.isFallback=!0,h.userData.isPreview=!0),this.scene.add(h),this.dragPreviewMesh=h,this.dragPreviewMesh.visible=!1,this.createBoundingBoxHelper(),t.a(2,!0);case 7:return t.p=7,t.v,t.a(2,!1)}},t,this,[[2,5],[1,7]])})),function(){return s.apply(this,arguments)})},{key:"createBoundingBoxHelper",value:function(){if(this.dragPreviewMesh){var t=(new n.Box3).setFromObject(this.dragPreviewMesh),e=t.getSize(new n.Vector3);t.getCenter(new n.Vector3);var i=new n.BoxGeometry(e.x,e.y,e.z),r=new n.LineBasicMaterial({color:16776960,transparent:!0,opacity:.3}),s=new n.EdgesGeometry(i),a=new n.LineSegments(s,r);a.position.copy(this.dragPreviewMesh.position),this.scene.add(a),this.dragPreviewBoundingBox=a,this.dragPreviewBoundingBox.visible=!1}}},{key:"checkBoundingBoxOverlap",value:function(){var t=this;if(!this.dragPreviewMesh||!this.scene)return!1;var e=(new n.Box3).setFromObject(this.dragPreviewMesh),i=[];this.scene.traverse(function(e){!e.isMesh||e===t.dragPreviewMesh||e===t.dragPreviewBoundingBox||e.userData.isBaseGround||e.userData.isBrickWall||e.userData.isBaseGrid||e.userData&&("component"===e.userData.componentType||"connector"===e.userData.componentType||"gateway"===e.userData.componentType)&&i.push(e)});for(var r=0,s=i;r<s.length;r++){var a=s[r],h=(new n.Box3).setFromObject(a);if(e.intersectsBox(h))return!0}return!1}},{key:"clearDragPreview",value:function(){this.dragPreviewMesh&&(this.dragPreviewMesh.visible=!1),this.dragPreviewBoundingBox&&(this.dragPreviewBoundingBox.visible=!1)}},{key:"cleanupDragPreview",value:function(){this.dragPreviewMesh&&(this.scene.remove(this.dragPreviewMesh),this.dragPreviewMesh.geometry&&this.dragPreviewMesh.geometry.dispose(),this.dragPreviewMesh.material&&(Array.isArray(this.dragPreviewMesh.material)?this.dragPreviewMesh.material.forEach(function(t){return t.dispose()}):this.dragPreviewMesh.material.dispose()),this.dragPreviewMesh=null),this.dragPreviewBoundingBox&&(this.scene.remove(this.dragPreviewBoundingBox),this.dragPreviewBoundingBox.geometry&&this.dragPreviewBoundingBox.geometry.dispose(),this.dragPreviewBoundingBox.material&&this.dragPreviewBoundingBox.material.dispose(),this.dragPreviewBoundingBox=null)}},{key:"dispose",value:function(){this.cleanupDragPreview(),this.currentDragComponentData=null,this.dragPreviewSize=null,this.isDragOverScene=!1,this.dragTargetPosition=null}},{key:"getDragState",value:function(){return{isDragging:!!this.currentDragComponentData,isDragOverScene:this.isDragOverScene,dragComponentData:this.currentDragComponentData,dragTargetPosition:this.dragTargetPosition}}}]);var s,a,h,u,o,c,l,f}();export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as e,classCallCheck as n}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as i from"three";import{logger as t}from"../../core/debugLogger.js";var a=function(){return e(function e(i){n(this,e),this.sceneViewer=i,this.handleKeyDown=null},[{key:"setupKeyboardControls",value:function(){var e=this;this.handleKeyDown=function(n){if(n.ctrlKey&&("z"===n.key.toLowerCase()||"KeyZ"===n.code))return n.preventDefault(),n.stopPropagation(),void e.undoTransform();if(n.altKey&&("r"===n.key.toLowerCase()||"KeyR"===n.code))return n.preventDefault(),n.stopPropagation(),void e.toggleShouldUpdatePaths();switch(n.key.toLowerCase()){case"p":e.togglePerformanceUI();break;case"l":e.logPerformanceSummary();break;case"r":e.resetPerformanceStats();break;case"a":e.toggleAutoRotation();break;case"e":e.cycleToneMapping();break;case"=":case"+":e.increaseExposure();break;case"-":e.decreaseExposure();break;case"h":e.showHelpInfo()}},window.addEventListener("keydown",this.handleKeyDown,!0),window._performanceKeyHandler=this.handleKeyDown,this.overrideTransformControlsKeyboard(),t.info("Keyboard controls initialized with Ctrl+Z undo override")}},{key:"togglePerformanceUI",value:function(){var e=this.sceneViewer;e.performanceUI&&(e.performanceUI.isVisible?e.performanceUI.hide():e.performanceUI.show())}},{key:"logPerformanceSummary",value:function(){var e=this.sceneViewer;e.performanceMonitor&&e.performanceMonitor.logSummary()}},{key:"resetPerformanceStats",value:function(){var e=this.sceneViewer;e.performanceMonitor&&e.performanceMonitor.reset()}},{key:"cycleToneMapping",value:function(){var e=this.sceneViewer;if(e.renderer){var n=[{type:i.NoToneMapping,name:"None"},{type:i.LinearToneMapping,name:"Linear"},{type:i.ReinhardToneMapping,name:"Reinhard"},{type:i.CineonToneMapping,name:"Cineon"},{type:i.ACESFilmicToneMapping,name:"ACES Filmic"}],t=n.findIndex(function(n){return n.type===e.renderer.toneMapping}),a=(t+1)%n.length,o=(n[t],n[a]);e.renderer.toneMapping=o.type}}},{key:"increaseExposure",value:function(){var e=this.sceneViewer;e.renderer&&(e.renderer.toneMappingExposure=Math.min(e.renderer.toneMappingExposure+.1,3))}},{key:"decreaseExposure",value:function(){var e=this.sceneViewer;e.renderer&&(e.renderer.toneMappingExposure=Math.max(e.renderer.toneMappingExposure-.1,.1))}},{key:"showHelpInfo",value:function(){}},{key:"toggleShouldUpdatePaths",value:function(){var e=this.sceneViewer;e&&"function"==typeof e.toggleShouldUpdatePaths&&e.toggleShouldUpdatePaths()}},{key:"toggleAutoRotation",value:function(){var e=this.sceneViewer;if(e.sceneInitializationManager){var n=e.sceneInitializationManager.toggleAutoRotation();void 0!==e.isAutoRotating&&(e.isAutoRotating=n)}}},{key:"setupResizeHandler",value:function(){var e=this.sceneViewer;e.handleResize=function(){if(e.$refs.container&&e.camera&&e.renderer){var n=e.$refs.container.getBoundingClientRect(),i=n.width,t=n.height;e.camera.aspect=i/t,e.camera.updateProjectionMatrix(),e.renderer.setSize(i,t),e.composer&&(e.composer.setSize(i,t),e.ssaoPass&&e.ssaoPass.setSize(i,t),e.bloomPass&&e.bloomPass.resolution.set(i,t)),e.tooltipsManager&&e.tooltipsManager.resize()}},e.resizeObserver=new ResizeObserver(e.handleResize),e.resizeObserver.observe(e.$refs.container),window.addEventListener("resize",e.handleResize),t.info("Resize handler initialized")}},{key:"cleanup",value:function(){this.handleKeyDown&&(window.removeEventListener("keydown",this.handleKeyDown,!0),this.handleKeyDown=null),window._performanceKeyHandler&&(window.removeEventListener("keydown",window._performanceKeyHandler,!0),delete window._performanceKeyHandler);var e=this.sceneViewer;e.handleResize&&(window.removeEventListener("resize",e.handleResize),e.handleResize=null),e.resizeObserver&&(e.resizeObserver.disconnect(),e.resizeObserver=null),t.info("Keyboard controls cleanup completed")}},{key:"undoTransform",value:function(){var e=this.sceneViewer;e.centralPlant&&("function"==typeof e.centralPlant.undoTransform&&e.centralPlant.undoTransform()&&(e.sceneHelper&&"function"==typeof e.sceneHelper.requestRender&&e.sceneHelper.requestRender(),e.renderer&&e.renderer.render(e.scene,e.camera),e.updateComponentPositions&&"function"==typeof e.updateComponentPositions&&e.updateComponentPositions()))}},{key:"overrideTransformControlsKeyboard",value:function(){var e=this.sceneViewer;if(e.transformManager&&e.transformManager.eventHandlers&&e.transformManager.eventHandlers.keydown){var n=e.transformManager.eventHandlers.keydown;e.transformManager.eventHandlers.keydown=function(e){(!e.ctrlKey||"z"!==e.key.toLowerCase()&&"KeyZ"!==e.code)&&n(e)}}}}])}();export{a as KeyboardControlsManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,createForOfIteratorHelper as i,objectSpread2 as s,classCallCheck as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as n from"three";import{TransformControls as h}from"./TransformControls.js";var o=function(){return t(function t(i,s,n){var h=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;e(this,t),this.scene=i,this.camera=s,this.renderer=n,this.orbitControls=h,this.transformControls=null,this.boundingBoxHelper=null,this.boundingBoxCache=new WeakMap,this.selectedObject=null,this.currentMode="translate",this.currentSpace="world",this.forceInvisible=!1,this.eventHandlers={keydown:null,click:null,transformStart:null,transformEnd:null,transforming:null},this.clickTiming={lastClickTime:0,lastClickedObject:null,doubleClickDelay:300},this.transformState={isTransforming:!1,initialTransform:null,currentTransform:null},this.config={size:1,enabled:!0,showX:!0,showY:!0,showZ:!0,snap:null,translationSnap:null,rotationSnap:null,scaleSnap:null,showBoundingBox:!0,boundingBoxColor:65280,useBoundingBoxSelection:!0},this.callbacks={onObjectSelect:null,onTransformStart:null,onTransform:null,onTransformEnd:null,onModeChange:null,onObjectRemoved:null},this.init()},[{key:"init",value:function(){this.createTransformControls(),this.setupEventListeners(),this.setupKeyboardControls()}},{key:"on",value:function(t){t.onObjectSelect&&(this.callbacks.onObjectSelect=t.onObjectSelect),t.onTransformStart&&(this.callbacks.onTransformStart=t.onTransformStart),t.onTransform&&(this.callbacks.onTransform=t.onTransform),t.onTransformEnd&&(this.callbacks.onTransformEnd=t.onTransformEnd),t.onModeChange&&(this.callbacks.onModeChange=t.onModeChange),t.onObjectRemoved&&(this.callbacks.onObjectRemoved=t.onObjectRemoved)}},{key:"createTransformControls",value:function(){this.transformControls=new h(this.camera,this.renderer.domElement),this.transformControls.setMode(this.currentMode),this.transformControls.setSpace(this.currentSpace),this.transformControls.setSize(this.config.size),this.transformControls.setDelay(this.clickTiming),this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ,this.transformControls.showXY=!1,this.transformControls.showYZ=!1,this.transformControls.showXZ=!1,this.transformControls.isTransformControls=!0,this.transformControls.userData={isTransformControls:!0},this.scene.add(this.transformControls),this.transformControls.enabled=!1,this.t()}},{key:"setupEventListeners",value:function(){var t=this;this.eventHandlers.transformStart=function(){t.transformState.isTransforming=!0,t.selectedObject&&(t.transformState.initialTransform={position:t.selectedObject.position.clone(),rotation:t.selectedObject.rotation.clone(),scale:t.selectedObject.scale.clone()}),t.orbitControls&&(t.orbitControls.enabled=!1),t.callbacks.onTransformStart&&t.callbacks.onTransformStart(t.selectedObject,t.currentMode)},this.eventHandlers.transformEnd=function(){if(t.transformState.isTransforming=!1,t.orbitControls&&(t.orbitControls.enabled=!0),t.selectedObject&&(t.transformState.currentTransform={position:t.selectedObject.position.clone(),rotation:t.selectedObject.rotation.clone(),scale:t.selectedObject.scale.clone()},t.boundingBoxCache.has(t.selectedObject)&&t.boundingBoxCache.delete(t.selectedObject)),t.callbacks.onTransformEnd&&t.callbacks.onTransformEnd(t.selectedObject,t.transformState.initialTransform,t.transformState.currentTransform,t.currentMode),"undefined"!=typeof window){var i,s=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),transformType:t.currentMode,objectName:(null===(i=t.selectedObject)||void 0===i?void 0:i.name)||"unknown"}});window.dispatchEvent(s)}},this.eventHandlers.transforming=function(){if(t.selectedObject&&t.boundingBoxCache.has(t.selectedObject)&&t.boundingBoxCache.delete(t.selectedObject),t.updateBoundingBox(),t.callbacks.onTransform&&t.callbacks.onTransform(t.selectedObject,t.currentMode),"undefined"!=typeof window){var i,s=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),transformType:t.currentMode,objectName:(null===(i=t.selectedObject)||void 0===i?void 0:i.name)||"unknown",isTransforming:!0}});window.dispatchEvent(s)}},this.transformControls&&(this.eventHandlers.transformStart&&this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.eventHandlers.transformEnd&&this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd),this.eventHandlers.transforming&&this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.addEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.addEventListener("mouseUp",this.eventHandlers.transformEnd),this.transformControls.addEventListener("objectChange",this.eventHandlers.transforming))}},{key:"setupKeyboardControls",value:function(){var t=this;this.eventHandlers.keydown=function(i){if(t.transformControls.enabled&&!t.transformState.isTransforming&&(!i.ctrlKey||"KeyZ"!==i.code))switch(i.code){case"KeyG":t.setMode("translate");break;case"KeyR":t.setMode("rotate");break;case"KeyS":t.setMode("scale");break;case"KeyW":t.setSpace("world");break;case"KeyL":t.setSpace("local");break;case"Escape":t.deselectObject();break;case"KeyX":t.setAxisConstraint("X");break;case"KeyY":t.setAxisConstraint("Y");break;case"KeyZ":i.ctrlKey||t.setAxisConstraint("Z");break;case"ShiftLeft":case"ShiftRight":t.clearAxisConstraint();break;case"Backspace":t.handleObjectRemoval()}},window.addEventListener("keydown",this.eventHandlers.keydown)}},{key:"setupObjectSelection",value:function(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,s=new n.Raycaster,e=new n.Vector2;this.eventHandlers.click=function(n){if(!t.transformState.isTransforming){var h=Date.now(),o=h-t.clickTiming.lastClickTime;t.i(n,e),s.setFromCamera(e,t.camera);var a=t.h(s,i),l=a===t.clickTiming.lastClickedObject,r=o<t.clickTiming.doubleClickDelay;l&&r&&null!==a?(t.selectObject(a),t.clickTiming.lastClickTime=0,t.clickTiming.lastClickedObject=null):(t.deselectObject(),a&&t.selectObjectForTransformOnly(a),t.clickTiming.lastClickTime=h,t.clickTiming.lastClickedObject=a)}},this.renderer.domElement.addEventListener("click",this.eventHandlers.click)}},{key:"_calculateMousePosition",value:function(t,i){var s=this.renderer.domElement.getBoundingClientRect();i.x=(t.clientX-s.left)/s.width*2-1,i.y=-(t.clientY-s.top)/s.height*2+1}},{key:"_findTargetObject",value:function(t,i){if(this.config.useBoundingBoxSelection){var s=this.o(t,i);if(s)return s}return this.l(t,i)}},{key:"_findTargetViaBoundingBox",value:function(t,i){var s=this.intersectObjectsBoundingBoxes(t,i);if(s.length>0){var e=s[0].object;if(this.u(e))return e}return null}},{key:"_findTargetViaMesh",value:function(t,i){var s=t.intersectObjects(this.scene.children,!0);if(s.length>0){var e=s[0].object;if(e=this.v(e),(i?i(e):this.isSelectableObject(e))&&this.u(e)){this.config.useBoundingBoxSelection;return e}}return null}},{key:"_resolveHierarchyTarget",value:function(t){var i,s,e;return this.isConnectorOrb(t)?t:null!==(i=t.parent)&&void 0!==i&&null!==(i=i.name)&&void 0!==i&&i.includes(" Component")?t.parent:null!==(s=t.parent)&&void 0!==s&&null!==(s=s.parent)&&void 0!==s&&null!==(s=s.name)&&void 0!==s&&s.includes(" Component")?t.parent.parent:(null!==(e=t.userData)&&void 0!==e&&e.isPipeSegment,t)}},{key:"_isValidSelectableObject",value:function(t){return!(!t||!t.parent)&&!!(t.position&&t.rotation&&t.scale&&t.updateMatrixWorld)}},{key:"isConnectorOrb",value:function(t){if(!t||!t.isObject3D)return!1;if(!t.isMesh||!t.geometry)return!1;var i="CONNECTOR-GEO"===t.geometry.uuid,s="SphereGeometry"===t.geometry.type&&t.geometry.parameters&&.2===t.geometry.parameters.radius,e=t.name&&t.name.toLowerCase().includes("connector");return(i||s)&&e}},{key:"isSelectableObject",value:function(t){var i,s,e,n,h,o,a,l;if(!t||!t.isObject3D)return!1;if(t.userData&&t.userData.isPipeSegment,t.isTransformControls||t.isTransformControlsPlane||t.isTransformControlsGizmo)return!1;var r=t.isHelper||(null===(i=t.userData)||void 0===i?void 0:i.isHelper)||(null===(s=t.userData)||void 0===s?void 0:s.isBoundingBox),u=null===(e=t.userData)||void 0===e?void 0:e.isBaseGround,c=null===(n=t.userData)||void 0===n?void 0:n.isBrickWall;if(r||u||c||!t.visible)return!1;if(t.name&&t.name.toLowerCase().includes("polyline")&&(null===(h=t.userData)||void 0===h||!h.isPipeSegment)&&(null===(o=t.userData)||void 0===o||!o.isPipeJunction))return!1;var v=!0===(null===(a=t.userData)||void 0===a?void 0:a.isPipeSegment),f=!0===(null===(l=t.userData)||void 0===l?void 0:l.isPipeJunction),d=t.name&&t.name.includes(" Component"),y=this.isConnectorOrb(t);return d||y||v||f}},{key:"selectObject",value:function(t){if(!t||!t.isObject3D)return!1;this.selectedObject=t,t.updateMatrixWorld(!0);var i=(new n.Box3).setFromObject(t);return this.boundingBoxCache.set(t,i),this.transformControls.attach(t),this.transformControls.updateInteractionTime&&this.transformControls.updateInteractionTime(),this.createBoundingBox(t),this.forceInvisible?(this.transformControls.enabled=!1,this.t()):(this.transformControls.enabled=this.config.enabled,this.k()),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(t),!0}},{key:"selectObjectForTransformOnly",value:function(t){if(!t||!t.isObject3D)return!1;this.selectedObject=t,t.updateMatrixWorld(!0);var i=(new n.Box3).setFromObject(t);return this.boundingBoxCache.set(t,i),this.transformControls.attach(t),this.transformControls.updateInteractionTime&&this.transformControls.updateInteractionTime(),this.createBoundingBox(t),this.forceInvisible?(this.transformControls.enabled=!1,this.t()):(this.transformControls.enabled=!0,this.k()),!0}},{key:"deselectObject",value:function(){this.selectedObject,this.removeBoundingBox(),this.selectedObject=null,this.transformControls&&(this.transformControls.detach(),this.transformControls.enabled=!1,this.t()),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(null)}},{key:"createBoundingBox",value:function(t){if(this.config.showBoundingBox&&(this.removeBoundingBox(),t))try{this.boundingBoxHelper=new n.BoxHelper(t,this.config.boundingBoxColor),this.boundingBoxHelper.isHelper=!0,this.boundingBoxHelper.userData={isBoundingBox:!0},this.scene.add(this.boundingBoxHelper)}catch(t){}}},{key:"removeBoundingBox",value:function(){if(this.boundingBoxHelper)try{this.boundingBoxHelper.parent&&this.boundingBoxHelper.parent.remove(this.boundingBoxHelper),this.boundingBoxHelper.geometry&&this.boundingBoxHelper.geometry.dispose(),this.boundingBoxHelper.material&&this.boundingBoxHelper.material.dispose()}catch(t){}finally{this.boundingBoxHelper=null}}},{key:"updateBoundingBox",value:function(){if(this.boundingBoxHelper&&this.selectedObject)try{if(this.selectedObject.updateMatrixWorld(!0),this.boundingBoxHelper.update(),this.boundingBoxCache.has(this.selectedObject)){var t=(new n.Box3).setFromObject(this.selectedObject);this.boundingBoxCache.set(this.selectedObject,t)}}catch(t){this.createBoundingBox(this.selectedObject)}}},{key:"setBoundingBoxVisibility",value:function(t){this.config.showBoundingBox=t,t&&this.selectedObject&&!this.boundingBoxHelper?this.createBoundingBox(this.selectedObject):!t&&this.boundingBoxHelper&&this.removeBoundingBox()}},{key:"setBoundingBoxColor",value:function(t){this.config.boundingBoxColor=t,this.boundingBoxHelper&&this.boundingBoxHelper.material&&this.boundingBoxHelper.material.color.setHex(t)}},{key:"setMode",value:function(t){if(["translate","rotate","scale"].includes(t)){var i=this.currentMode;this.currentMode=t,this.transformControls.setMode(t),this.callbacks.onModeChange&&this.callbacks.onModeChange(t,i)}}},{key:"setSpace",value:function(t){if(["world","local"].includes(t)){this.currentSpace;this.currentSpace=t,this.transformControls.setSpace(t)}}},{key:"setAxisConstraint",value:function(t){["X","Y","Z"].includes(t)&&(this.transformControls.showX=!1,this.transformControls.showY=!1,this.transformControls.showZ=!1,this.transformControls["show".concat(t)]=!0)}},{key:"clearAxisConstraint",value:function(){this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ}},{key:"setSnap",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==t.translation&&(this.config.translationSnap=t.translation,this.transformControls.setTranslationSnap(t.translation)),void 0!==t.rotation&&(this.config.rotationSnap=t.rotation,this.transformControls.setRotationSnap(t.rotation)),void 0!==t.scale&&(this.config.scaleSnap=t.scale,this.transformControls.setScaleSnap(t.scale))}},{key:"snapValues",get:function(){return{translation:this.config.translationSnap||.5,rotation:this.config.rotationSnap||Math.PI/2,scale:this.config.scaleSnap||.1}}},{key:"setSize",value:function(t){this.config.size=t,this.transformControls.setSize(t)}},{key:"setEnabled",value:function(t){this.config.enabled=t,this.selectedObject&&(this.transformControls.enabled=t)}},{key:"setShowPlanes",value:function(t){return!!this.transformControls&&(this.transformControls.showXY=t,this.transformControls.showYZ=t,this.transformControls.showXZ=t,!0)}},{key:"ensureSceneAttachment",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return!this.transformControls&&this.scene&&this.camera&&this.renderer?(this.createTransformControls(),this.setupEventListeners(),t||(this.transformControls.visible=!1),!0):!(!this.transformControls||!this.scene)&&(this.scene.children.includes(this.transformControls)?!this.transformControls.visible&&t?(this.transformControls.visible=!0,!0):this.transformControls.visible&&!t?(this.transformControls.visible=!1,!0):!(!this.transformControls.parent||this.transformControls.parent===this.scene)&&(this.transformControls.parent.remove(this.transformControls),this.scene.add(this.transformControls),!0):(this.scene.add(this.transformControls),this.transformControls.enabled=!1,this.selectedObject&&(this.transformControls.attach(this.selectedObject),this.transformControls.enabled=this.config.enabled),t||(this.transformControls.visible=!1),!0))}},{key:"getTransformData",value:function(){if(!this.selectedObject)return null;var t={position:this.selectedObject.position.clone(),rotation:this.selectedObject.rotation.clone(),scale:this.selectedObject.scale.clone()},i=this.getWorldTransformData();return{object:this.selectedObject,position:t.position,rotation:t.rotation,scale:t.scale,worldPosition:i.position,worldRotation:i.rotation,worldScale:i.scale,mode:this.currentMode,space:this.currentSpace,isTransforming:this.transformState.isTransforming}}},{key:"getWorldTransformData",value:function(){if(!this.selectedObject)return null;this.selectedObject.updateMatrixWorld(!0);var t=new n.Vector3;this.selectedObject.getWorldPosition(t);var i=new n.Quaternion;this.selectedObject.getWorldQuaternion(i);var s=new n.Euler;s.setFromQuaternion(i);var e=new n.Vector3;return this.selectedObject.getWorldScale(e),{position:t,rotation:s,scale:e}}},{key:"updateObjectTransform",value:function(t,i,s){var e=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(this.selectedObject){var n=this.selectedObject,h=parseFloat(s);if(!isNaN(h)){if(e)this.updateWorldTransform(n,t,i,h);else switch(t){case"position":n.position[i]=h;break;case"rotation":n.rotation[i]=h*(Math.PI/180);break;case"scale":n.scale[i]=h;break;default:return}this.transformControls&&this.transformControls.updateMatrixWorld(),this.updateBoundingBox()}}}},{key:"updateWorldTransform",value:function(t,i,s,e){switch(t.updateMatrixWorld(!0),i){case"position":this.setWorldPosition(t,s,e);break;case"rotation":this.setWorldRotation(t,s,e);break;case"scale":this.setWorldScale(t,s,e)}}},{key:"setWorldPosition",value:function(t,i,s){var e=new n.Vector3;if(t.getWorldPosition(e),e[i]=s,t.parent){var h=new n.Matrix4;h.copy(t.parent.matrixWorld).invert(),e.applyMatrix4(h)}t.position.copy(e)}},{key:"setWorldRotation",value:function(t,i,s){var e=new n.Quaternion;t.getWorldQuaternion(e);var h=new n.Euler;h.setFromQuaternion(e),h[i]=s*(Math.PI/180);var o=new n.Quaternion;if(o.setFromEuler(h),t.parent){var a=new n.Quaternion;t.parent.getWorldQuaternion(a),a.invert(),o.premultiply(a)}t.quaternion.copy(o)}},{key:"setWorldScale",value:function(t,i,s){var e=new n.Vector3;t.getWorldScale(e);var h=s/e[i];t.scale[i]*=h}},{key:"getSelectableObjectsWithBounds",value:function(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,s=[];return this.scene.traverse(function(e){var h,o;if(e&&e.isObject3D&&!(e.isTransformControls||e.isTransformControlsPlane||e.isTransformControlsGizmo||e.isHelper||null!==(h=e.userData)&&void 0!==h&&h.isHelper||null!==(o=e.userData)&&void 0!==o&&o.isBoundingBox))try{if(i?i(e):t.isSelectableObject(e)){e.updateMatrixWorld(!0);var a=t.boundingBoxCache.get(e);a&&e!==t.selectedObject||(a=(new n.Box3).setFromObject(e),t.boundingBoxCache.set(e,a)),s.push({object:e,boundingBox:a})}}catch(t){}}),s}},{key:"intersectObjectsBoundingBoxes",value:function(t){var s,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,h=this.getSelectableObjectsWithBounds(e),o=[],a=i(h);try{for(a.s();!(s=a.n()).done;){var l=s.value,r=l.object,u=l.boundingBox,c=t.ray.intersectBox(u,new n.Vector3);if(c){var v=t.ray.origin.distanceTo(c);o.push({object:r,point:c,distance:v,boundingBox:u})}}}catch(t){a.e(t)}finally{a.f()}return o.sort(function(t,i){return t.distance-i.distance}),o}},{key:"setBoundingBoxSelection",value:function(t){this.config.useBoundingBoxSelection=t}},{key:"handleObjectRemoval",value:function(){var t;this.selectedObject&&"gateway"===(null===(t=this.selectedObject.userData)||void 0===t?void 0:t.componentType)&&this.handleGatewayRemoval()}},{key:"handleGatewayRemoval",value:function(){var t,i=this.selectedObject,e={uuid:i.uuid,userData:s({},i.userData),position:i.position.clone(),connections:(null===(t=i.userData)||void 0===t?void 0:t.connections)||null};i.userData.origin="computed",this.deselectObject(),this.callbacks.onObjectRemoved&&this.callbacks.onObjectRemoved(e)}},{key:"dispose",value:function(){this.eventHandlers.keydown&&window.removeEventListener("keydown",this.eventHandlers.keydown),this.eventHandlers.click&&this.renderer.domElement.removeEventListener("click",this.eventHandlers.click),this.removeBoundingBox(),this.selectedObject&&this.deselectObject(),this.transformControls&&(this.eventHandlers.transformStart&&this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.eventHandlers.transformEnd&&this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd),this.eventHandlers.transforming&&this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.detach(),this.scene&&this.transformControls.parent===this.scene&&this.scene.remove(this.transformControls),this.transformControls.dispose(),this.transformControls=null),this.selectedObject=null,this.orbitControls=null}},{key:"forceHide",value:function(){this.transformControls&&(this.t(),this.transformControls.enabled=!1)}},{key:"_hideTransformControls",value:function(){this.transformControls&&(this.transformControls.visible=!1,this.transformControls.m&&(this.transformControls.m.visible=!1),this.transformControls.p&&(this.transformControls.p.visible=!1))}},{key:"_showTransformControls",value:function(){this.transformControls&&(this.transformControls.visible=!0,this.transformControls.m&&(this.transformControls.m.visible=!0),this.transformControls.p&&(this.transformControls.p.visible=!0))}},{key:"getVisibilityState",value:function(){var t;return this.transformControls?{exists:!0,visible:this.transformControls.visible,enabled:this.transformControls.enabled,gizmoVisible:this.transformControls.m?this.transformControls.m.visible:"N/A",planeVisible:this.transformControls.p?this.transformControls.p.visible:"N/A",hasSelectedObject:!!this.selectedObject,selectedObjectName:(null===(t=this.selectedObject)||void 0===t?void 0:t.name)||"none"}:{exists:!1}}},{key:"_forceHideAllGizmoComponents",value:function(){if(this.transformControls&&this.transformControls.m){var t=this.transformControls.m;t.visible=!1,t.gizmo&&Object.keys(t.gizmo).forEach(function(i){t.gizmo[i]&&(t.gizmo[i].visible=!1)}),t.helper&&Object.keys(t.helper).forEach(function(i){t.helper[i]&&(t.helper[i].visible=!1)}),this.transformControls.p&&(this.transformControls.p.visible=!1)}}},{key:"_hidePlaneHelpers",value:function(){if(this.transformControls&&this.transformControls.m){var t=this.transformControls.m;if(t.gizmo&&t.gizmo.translate)t.gizmo.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!1)});if(t.picker&&t.picker.translate)t.picker.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!1)})}}},{key:"_showPlaneHelpers",value:function(){if(this.transformControls&&this.transformControls.m){var t=this.transformControls.m;if(t.gizmo&&t.gizmo.translate)t.gizmo.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!0)});if(t.picker&&t.picker.translate)t.picker.translate.traverse(function(t){"XY"!==t.name&&"YZ"!==t.name&&"XZ"!==t.name||(t.visible=!0)})}}}])}();function a(t,i,s){return new o(t,i,s,arguments.length>3&&void 0!==arguments[3]?arguments[3]:null)}export{o as TransformControlsManager,a as createTransformControls};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as e,classCallCheck as r,asyncToGenerator as n,regenerator as t,regeneratorValues as a,createForOfIteratorHelper as o}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as i from"three";import{RGBELoader as s}from"../../../node_modules/three/examples/jsm/loaders/RGBELoader.js";import{loadTextureSetAndCreateMaterial as u}from"./textureConfig.js";import{logger as c}from"../../core/debugLogger.js";var l=function(){return e(function e(n){r(this,e),this.sceneViewer=n},[{key:"createSkybox",value:(y=n(t().m(function e(){var r,n,u,c,l,f,d,v,h,k;return t().w(function(e){for(;;)switch(e.n){case 0:r=this.sceneViewer,(n=new i.PMREMGenerator(r.renderer)).compileEquirectangularShader(),u=[{type:"hdr",loader:new s,paths:["/skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr","/skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr"]},{type:"jpeg",loader:r.textureLoader,paths:["/skyboxes/sky_fallback.jpg"]}],c=function(e,t){try{var a,o;e.mapping=i.EquirectangularReflectionMapping;var s=n.fromEquirectangular(e).texture;return null!==(a=r.scene.environment)&&void 0!==a&&a.dispose&&r.scene.environment.dispose(),null!==(o=r.scene.background)&&void 0!==o&&o.dispose&&r.scene.background.dispose(),r.scene.environment=s,r.scene.background=s,e.dispose(),!0}catch(e){return!1}},l=t().m(function e(){var r,i,s,u,l,f,h,k;return t().w(function(e){for(;;)switch(e.n){case 0:(r=v[d]).type,i=r.loader,s=r.paths,u=o(s),e.p=1,f=t().m(function e(){var r,a;return t().w(function(e){for(;;)switch(e.n){case 0:return r=l.value,e.p=1,e.n=2,new Promise(function(e,n){var t=setTimeout(function(){return n(new Error("Timeout"))},1e4);i.load(r,function(r){clearTimeout(t),e(r)},void 0,function(e){clearTimeout(t),n(e)})});case 2:if(a=e.v,!c(a)){e.n=3;break}return n.dispose(),e.a(2,{v:{v:void 0}});case 3:e.n=5;break;case 4:e.p=4,e.v;case 5:return e.a(2)}},e,null,[[1,4]])}),u.s();case 2:if((l=u.n()).done){e.n=5;break}return e.d(a(f()),3);case 3:if(!(h=e.v)){e.n=4;break}return e.a(2,h.v);case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,k=e.v,u.e(k);case 7:return e.p=7,u.f(),e.f(7);case 8:return e.a(2)}},e,null,[[1,6,7,8]])}),d=0,v=u;case 1:if(!(d<v.length)){e.n=4;break}return e.d(a(l()),2);case 2:if(!(f=e.v)){e.n=3;break}return e.a(2,f.v);case 3:d++,e.n=1;break;case 4:h=new i.AmbientLight(16777215,.6),r.scene.add(h),(k=new i.Scene).add(new i.HemisphereLight(8900331,4473975,1)),r.scene.environment=n.fromScene(k).texture,r.scene.background=new i.Color(8900331),n.dispose();case 5:return e.a(2)}},e,this)})),function(){return y.apply(this,arguments)})},{key:"setupLighting",value:function(){var e=this.sceneViewer;e.scene.children=e.scene.children.filter(function(e){return!(e instanceof i.Light)});var r=new i.DirectionalLight(16777195,5);r.position.set(15,30,-10),r.castShadow=!0,r.shadow.camera.near=.1,r.shadow.camera.far=100,r.shadow.camera.left=-50,r.shadow.camera.right=50,r.shadow.camera.top=50,r.shadow.camera.bottom=-50,r.shadow.mapSize.width=2048,r.shadow.mapSize.height=2048,e.scene.add(r);var n=new i.DirectionalLight(16777164,.4);n.position.set(-10,10,-10),e.scene.add(n),c.info("Scene lighting setup completed")}},{key:"addTexturedGround",value:(k=n(t().m(function e(){var r,n,a,o,s,l;return t().w(function(e){for(;;)switch(e.n){case 0:return r=this.sceneViewer,c.debug("Starting addTexturedGround..."),n=new i.PlaneGeometry(30,30),a=new i.MeshStandardMaterial({color:7829367,metalness:.2,roughness:.9}),(o=new i.Mesh(n,a)).rotation.x=-Math.PI/2,o.position.y=0,o.receiveShadow=!0,o.name="Ground",o.userData.isBaseGround=!0,r.scene.add(o),e.p=1,c.debug("Loading concrete texture set..."),e.n=2,u("gravel_embedded_concrete",r.textureLoader);case 2:s=e.v,o.material=s,o.material.needsUpdate=!0,c.success("Ground material updated with textures"),e.n=4;break;case 3:e.p=3,l=e.v,c.warn("Error loading ground textures:",l);case 4:return e.a(2)}},e,this,[[1,3]])})),function(){return k.apply(this,arguments)})},{key:"addBrickWalls",value:(h=n(t().m(function e(){var r,n,a,o,s,l,f;return t().w(function(e){for(;;)switch(e.n){case 0:return r=this.sceneViewer,c.debug("Starting addBrickWalls..."),n=2.5,a=.5,o=new i.MeshPhysicalMaterial({color:7824226,roughness:.9,metalness:.1,clearcoat:.05,clearcoatRoughness:.4}),s=function(e){var t=function(n,t,a,o,s,u){var c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:1,f=new i.BoxGeometry(n,t,a);if(1!==l){for(var d=f.attributes.uv,v=d.array,h=0;h<v.length;h+=2)v[h+1]*=l;d.needsUpdate=!0}var k=new i.Mesh(f,e);return k.position.set(o,s-.56,u),0!==c&&k.rotateY(c),k.userData.isBrickWall=!0,k.castShadow=!0,k.receiveShadow=!0,k.name="Wall",r.scene.add(k),k};t(30,n,a,0,1.25,14.75,0,1),t(30,n,a,0,1.25,-14.75,0,1),t(a,8.5,29,14.75,4.25,0,0,3.4),t(a,n,29,-14.75,1.25,0,0,1)},s(o),c.debug("Basic brick walls created"),e.p=1,c.debug("Loading brick texture set..."),e.n=2,u("brick",r.textureLoader);case 2:l=e.v,r.scene.traverse(function(e){e.isMesh&&e.userData.isBrickWall&&(e.material=l,e.material.needsUpdate=!0)}),c.success("Brick walls updated with textures"),e.n=4;break;case 3:e.p=3,f=e.v,c.warn("Error loading brick textures:",f);case 4:return e.a(2)}},e,this,[[1,3]])})),function(){return h.apply(this,arguments)})},{key:"addHorizonFog",value:function(){var e=this.sceneViewer,r=new i.ShaderMaterial({transparent:!0,uniforms:{fogColor:{value:new i.Color(5533306)},fogDensity:{value:1}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform vec3 fogColor;\n uniform float fogDensity;\n varying vec2 vUv;\n \n void main() {\n vec2 center = vec2(0.5, 0.5);\n float dist = distance(vUv, center);\n float opacity = (1.0 - smoothstep(0.0, 0.5, dist)) * fogDensity;\n gl_FragColor = vec4(fogColor, opacity);\n }\n ",side:i.DoubleSide}),n=new i.PlaneGeometry(300,300),t=new i.Mesh(n,r);return t.rotation.x=-Math.PI/2,t.position.y=-3,t.name="fogPlane",e.scene.add(t),t}},{key:"initializeEnvironment",value:(v=n(t().m(function e(){return t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.createSkybox();case 1:return this.setupLighting(),e.n=2,this.addTexturedGround();case 2:return e.n=3,this.addBrickWalls();case 3:this.addHorizonFog(),c.info("Environment initialization completed");case 4:return e.a(2)}},e,this)})),function(){return v.apply(this,arguments)})},{key:"removeSkybox",value:function(){var e=this.sceneViewer;try{var r,n;return null!==(r=e.scene.environment)&&void 0!==r&&r.dispose&&e.scene.environment.dispose(),null!==(n=e.scene.background)&&void 0!==n&&n.dispose&&e.scene.background.dispose(),e.scene.environment=null,e.scene.background=new i.Color(16777215),c.info("Skybox removed successfully"),!0}catch(e){return!1}}},{key:"setSkyboxType",value:(d=n(t().m(function e(r){var n,a,o,s,u;return t().w(function(e){for(;;)switch(e.n){case 0:n=this.sceneViewer,e.p=1,null!==(a=n.scene.environment)&&void 0!==a&&a.dispose&&n.scene.environment.dispose(),null!==(o=n.scene.background)&&void 0!==o&&o.dispose&&n.scene.background.dispose(),(s=new i.PMREMGenerator(n.renderer)).compileEquirectangularShader(),u=r,e.n="HDR"===u?2:"Fallback"===u?4:"Color"===u?6:7;break;case 2:return e.n=3,this.loadHDRSkybox(s);case 3:case 5:return e.a(3,8);case 4:return e.n=5,this.loadFallbackSkybox(s);case 6:return this.setColorBackground(),e.a(3,8);case 7:return e.n=8,this.loadHDRSkybox(s);case 8:return s.dispose(),c.info("Skybox type changed to: ".concat(r)),e.a(2,!0);case 9:return e.p=9,e.v,e.a(2,!1)}},e,this,[[1,9]])})),function(e){return d.apply(this,arguments)})},{key:"loadHDRSkybox",value:(f=n(t().m(function e(r){var n,o,u,c,l,f,d;return t().w(function(e){for(;;)switch(e.n){case 0:n=this.sceneViewer,o=new s,u=["/skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr","/skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr"],c=t().m(function e(){var a,s,u;return t().w(function(e){for(;;)switch(e.n){case 0:return a=d[f],e.p=1,e.n=2,new Promise(function(e,r){var n=setTimeout(function(){return r(new Error("Timeout"))},1e4);o.load(a,function(r){clearTimeout(n),e(r)},void 0,function(e){clearTimeout(n),r(e)})});case 2:return(s=e.v).mapping=i.EquirectangularReflectionMapping,u=r.fromEquirectangular(s).texture,n.scene.environment=u,n.scene.background=u,s.dispose(),e.a(2,{v:void 0});case 3:e.p=3,e.v;case 4:return e.a(2)}},e,null,[[1,3]])}),f=0,d=u;case 1:if(!(f<d.length)){e.n=4;break}return e.d(a(c()),2);case 2:if(!(l=e.v)){e.n=3;break}return e.a(2,l.v);case 3:f++,e.n=1;break;case 4:throw new Error("Failed to load any HDR skybox");case 5:return e.a(2)}},e,this)})),function(e){return f.apply(this,arguments)})},{key:"loadFallbackSkybox",value:(l=n(t().m(function e(r){var n,a,o;return t().w(function(e){for(;;)switch(e.n){case 0:return n=this.sceneViewer,e.p=1,e.n=2,new Promise(function(e,r){var t=setTimeout(function(){return r(new Error("Timeout"))},1e4);n.textureLoader.load("/skyboxes/sky_fallback.jpg",function(r){clearTimeout(t),e(r)},void 0,function(e){clearTimeout(t),r(e)})});case 2:(a=e.v).mapping=i.EquirectangularReflectionMapping,o=r.fromEquirectangular(a).texture,n.scene.environment=o,n.scene.background=o,a.dispose(),e.n=4;break;case 3:throw e.p=3,e.v;case 4:return e.a(2)}},e,this,[[1,3]])})),function(e){return l.apply(this,arguments)})},{key:"setColorBackground",value:function(){var e=this.sceneViewer;e.scene.environment=null,e.scene.background=new i.Color(16777215);var r=new i.AmbientLight(16777215,.6);e.scene.add(r)}}]);var l,f,d,v,h,k,y}();export{l as EnvironmentManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{asyncToGenerator as e,regenerator as r,objectSpread2 as t,construct as n,toConsumableArray as o,slicedToArray as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as s from"three";var u={light_metal:{path:"/textures/gravel_embedded_concrete_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:2,y:2},materialProps:{color:12105912,metalness:.3,roughness:.3,normalScale:[.4,.4],clearcoat:.3,clearcoatRoughness:.2,envMapIntensity:1.6,reflectivity:.5}},brick:{path:"/textures/pavement_03_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:7.5,y:.75},materialProps:{color:10061960,roughness:.9,metalness:.1,normalScale:[1.5,1.5],bumpScale:.05,clearcoat:.05,clearcoatRoughness:.4}},gravel_embedded_concrete:{path:"/textures/gravel_embedded_concrete_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:7,y:7},materialProps:{color:6710886,metalness:0,roughness:1,normalScale:[1,1]}}};function c(e,r){return i.apply(this,arguments)}function i(){return i=e(r().m(function t(n,o){var c,i,l,f,m;return r().w(function(t){for(;;)switch(t.n){case 0:if(c=u[n]){t.n=1;break}throw new Error('Texture set "'.concat(n,'" not found'));case 1:return i=function(e){return new Promise(function(r,t){o.load(e,function(e){r(e)},void 0,function(e){t(e)})})},l=Object.entries(c.files).map(function(){var t=e(r().m(function e(t){var n,o,s,u,l;return r().w(function(e){for(;;)switch(e.n){case 0:return n=a(t,2),o=n[0],s=n[1],u="".concat(c.path,"/").concat(s),e.n=1,i(u);case 1:return l=e.v,e.a(2,[o,l])}},e)}));return function(e){return t.apply(this,arguments)}}()),t.n=2,Promise.all(l);case 2:return f=t.v,m=Object.fromEntries(f),Object.values(m).forEach(function(e){e.wrapS=e.wrapT=s.RepeatWrapping,e.repeat.set(c.repeat.x,c.repeat.y)}),t.a(2,{textures:m,config:c})}},t)})),i.apply(this,arguments)}function l(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=e.textures,u=e.config,c=t(t({map:a.diffuse,normalMap:a.normal,roughnessMap:a.roughness},u.materialProps),r);return c.normalScale&&Array.isArray(c.normalScale)&&(c.normalScale=n(s.Vector2,o(c.normalScale))),new s.MeshPhysicalMaterial(c)}function f(e,r){return m.apply(this,arguments)}function m(){return m=e(r().m(function e(t,n){var o,a,s=arguments;return r().w(function(e){for(;;)switch(e.n){case 0:return o=s.length>2&&void 0!==s[2]?s[2]:{},e.n=1,c(t,n);case 1:return a=e.v,e.a(2,l(a,o))}},e)})),m.apply(this,arguments)}export{u as TEXTURE_SETS,l as createMaterialFromTextureSet,c as loadTextureSet,f as loadTextureSetAndCreateMaterial};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as n,classCallCheck as e,toConsumableArray as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{getHardcodedUuid as r}from"../../core/nameUtils.js";var o=function(){return n(function n(t){e(this,n),this.sceneViewer=t},[{key:"exportSceneData",value:function(){var n=this;if(!this.sceneViewer.scene)return null;var e=function(n){var t,o,l,a,i,u,s,c,v=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!n||null!==(t=n.name)&&void 0!==t&&t.includes("Polyline")||null!==(o=n.userData)&&void 0!==o&&o.isBrickWall||null!==(l=n.userData)&&void 0!==l&&l.isBaseGround||null!==(a=n.userData)&&void 0!==a&&a.isBaseGrid||n.isLight||null!==(i=n.userData)&&void 0!==i&&i.isTransformControls||n.isTransformControls||n.type&&n.type.includes("TransformControls"))return null;if(!(v||null!==(u=n.userData)&&void 0!==u&&u.componentType))return null;if(v&&(null===(s=n.userData)||void 0===s||!s.forExport))return null;if(v&&null!==(c=n.userData)&&void 0!==c&&c.forExport);var d,p,f,h={uuid:r(n),name:n.name||"Unnamed Object",type:n.type||"Object3D"};(n.userData&&Object.keys(n.userData).length>0&&(h.userData={},Object.keys(n.userData).forEach(function(e){"worldBoundingBox"!==e&&"isBaseGround"!==e&&"isBrickWall"!==e&&"isBaseGrid"!==e&&"isTransformControls"!==e&&(h.userData[e]=n.userData[e])}),n.userData.dimensions&&(h.userData.dimensions=n.userData.dimensions),0===Object.keys(h.userData).length&&delete h.userData),h.position={x:parseFloat(n.position.x.toFixed(6)),y:parseFloat(n.position.y.toFixed(6)),z:parseFloat(n.position.z.toFixed(6))},h.rotation={x:parseFloat((n.rotation.x*(180/Math.PI)).toFixed(6)),y:parseFloat((n.rotation.y*(180/Math.PI)).toFixed(6)),z:parseFloat((n.rotation.z*(180/Math.PI)).toFixed(6))},h.scale={x:parseFloat(n.scale.x.toFixed(6)),y:parseFloat(n.scale.y.toFixed(6)),z:parseFloat(n.scale.z.toFixed(6))},n.geometry)&&(null!==(d=n.name)&&void 0!==d&&d.toLowerCase().includes("connector")?h.geometry="CONNECTOR-GEO":null!==(p=n.name)&&void 0!==p&&p.toLowerCase().includes("gateway")?h.geometry="GATEWAY-GEO":null!==(f=n.userData)&&void 0!==f&&f.libraryId&&(h.geometry="".concat(n.userData.libraryId,"-GEO")));if(n.children&&n.children.length>0){var m=[];n.children.forEach(function(n){var t=e(n,!0);t&&m.push(t)}),m.length>0&&(h.children=m)}return h},o=[];this.sceneViewer.scene.children.forEach(function(n){var t=e(n);t&&o.push(t)});var l,a,i={connections:(a=[],null!==(l=n.sceneViewer.currentSceneData)&&void 0!==l&&l.connections&&a.push.apply(a,t(n.sceneViewer.currentSceneData.connections)),a),scene:{object:{uuid:"PLANT-SCENE",name:"Scene",type:"Scene",children:o}}};return i.t={exportedAt:(new Date).toISOString(),exportedFrom:"SceneViewerEnhanced",version:"1.0.0",objectCount:o.length},i}},{key:"downloadSceneExport",value:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.exportSceneData();if(!e)return!1;n||(n="cp-export.json");try{var t=JSON.stringify(e,null,2),r=new Blob([t],{type:"application/json"}),o=URL.createObjectURL(r),l=document.createElement("a");return l.href=o,l.download=n,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(o),!0}catch(n){return!1}}},{key:"exportSceneDataAsString",value:function(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.exportSceneData();return e?n?JSON.stringify(e,null,2):JSON.stringify(e):null}},{key:"getExportMetadata",value:function(){var n;if(!this.sceneViewer.scene)return null;var e=0;return this.sceneViewer.scene.traverse(function(){return e++}),{totalObjects:e,hasCurrentSceneData:!!this.sceneViewer.currentSceneData,connectionsCount:(null===(n=this.sceneViewer.currentSceneData)||void 0===n||null===(n=n.connections)||void 0===n?void 0:n.length)||0,exportTimestamp:(new Date).toISOString()}}}])}();export{o as SceneExportManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,classCallCheck as e,asyncToGenerator as n,regenerator as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as o from"three";import{OrbitControls as r}from"../../../node_modules/three/examples/jsm/controls/OrbitControls.js";import{GLTFLoader as s}from"../../../node_modules/three/examples/jsm/loaders/GLTFLoader.js";import{PerformanceMonitor as a,PerformanceUI as u}from"../system/performanceMonitor.js";import{logger as c}from"../../core/debugLogger.js";var l=function(){return t(function t(n){e(this,t),this.sceneViewer=n,this.textureLoader=null,this.gltfLoader=null},[{key:"initializeScene",value:(h=n(i().m(function t(){var e,n,r,s;return i().w(function(t){for(;;)switch(t.n){case 0:(e=this.sceneViewer).scene=new o.Scene,n=e.$refs.container.getBoundingClientRect(),r=n.width,s=n.height,e.camera=new o.PerspectiveCamera(50,r/s,.01,1e3),e.camera.position.set(-8,4,9),e.renderer=new o.WebGLRenderer({antialias:!0}),e.renderer.setSize(r,s),e.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.renderer.shadowMap.enabled=!0,e.renderer.shadowMap.type=o.PCFSoftShadowMap,e.renderer.physicallyCorrectLights=!0,e.renderer.outputColorSpace=o.SRGBColorSpace,e.renderer.toneMapping=o.LinearToneMapping,e.renderer.toneMappingExposure=1.5,e.$refs.container.appendChild(e.renderer.domElement),c.info("Scene, camera, and renderer initialized");case 1:return t.a(2)}},t,this)})),function(){return h.apply(this,arguments)})},{key:"initializePerformanceMonitoring",value:function(){var t=this.sceneViewer;if("development"===process.env.NODE_ENV)try{var e=document.querySelectorAll("#performance-monitor-ui");e.length>0&&e.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}catch(t){}t.performanceMonitor=new a(t.renderer),t.performanceUI=new u(t.performanceMonitor,t.$refs.container,"light"),t.performanceMonitor.on("warning",function(t){}),t.performanceMonitor.start(),t.performanceUI.show(),this.exposePerformanceMonitoringGlobally(),c.info("Performance monitoring initialized")}},{key:"exposePerformanceMonitoringGlobally",value:function(){var t=this,e=this.sceneViewer;"undefined"!=typeof window&&(window._performanceMonitor=e.performanceMonitor,window._performanceUI=e.performanceUI,window.performance3D={show:function(){return e.performanceUI.show()},hide:function(){return e.performanceUI.hide()},toggle:function(){return e.performanceUI.isVisible?e.performanceUI.hide():e.performanceUI.show()},setTheme:function(t){return e.performanceUI.setTheme(t)},log:function(){return e.performanceMonitor.logSummary()},reset:function(){return e.performanceMonitor.reset()},export:function(){return e.performanceMonitor.exportData()},cleanup:function(){return e.cleanupDuplicatePerformanceMonitors?e.cleanupDuplicatePerformanceMonitors():0},help:function(){}},window.cameraControls={autoRotate:{enable:function(){return t.toggleAutoRotation(!0)},disable:function(){return t.toggleAutoRotation(!1)},toggle:function(){return t.toggleAutoRotation()},setSpeed:function(t){if(e.controls)return e.controls.autoRotateSpeed=t,t}},help:function(){}})}},{key:"initializeLoaders",value:function(){var t=this.sceneViewer;this.textureLoader=new o.TextureLoader,t.textureLoader=this.textureLoader,this.gltfLoader=new s,t.gltfLoader=this.gltfLoader,c.info("Texture and GLTF loaders initialized")}},{key:"setupControls",value:function(){this.sceneViewer.controls=new r(this.sceneViewer.camera,this.sceneViewer.renderer.domElement),this.sceneViewer.controls.enableDamping=!0,this.sceneViewer.controls.dampingFactor=.05,this.sceneViewer.controls.minDistance=1,this.sceneViewer.controls.maxDistance=20,this.sceneViewer.controls.maxPolarAngle=Math.PI/1.5,this.sceneViewer.controls.autoRotate=!0,this.sceneViewer.controls.autoRotateSpeed=.5,c.info("Orbit controls initialized with auto-rotation")}},{key:"setDefaultBackground",value:function(){this.sceneViewer.scene.background=new o.Color(8965358),c.info("Default scene background set")}},{key:"initialize",value:(l=n(i().m(function t(){return i().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.initializeScene();case 1:this.initializePerformanceMonitoring(),this.initializeLoaders(),this.setupControls(),this.setDefaultBackground(),c.info("Scene initialization completed");case 2:return t.a(2)}},t,this)})),function(){return l.apply(this,arguments)})},{key:"toggleAutoRotation",value:function(t){var e=this.sceneViewer;return!!e.controls&&(e.controls.autoRotate=void 0!==t?t:!e.controls.autoRotate,e.controls.autoRotate&&(e.controls.dampingFactor=1,setTimeout(function(){e.controls.dampingFactor=.05},100)),c.info("Camera auto-rotation is now ".concat(e.controls.autoRotate?"ENABLED":"DISABLED")),e.controls.autoRotate)}}]);var l,h}();export{l as SceneInitializationManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as e,objectSpread2 as n,classCallCheck as r,createForOfIteratorHelper as t,asyncToGenerator as a,regenerator as i,toConsumableArray as o,slicedToArray as u}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as c from"three";import{loadTextureSet as s}from"../environment/textureConfig.js";import l from"../../rendering/modelPreloader.js";import{modelLogger as v}from"../../core/debugLogger.js";var f=function(){return e(function e(n){r(this,e),this.sceneViewer=n},[{key:"clearSceneObjects",value:function(){var e=this.sceneViewer;this.deselectObject();var n=null;e.transformManager&&e.transformManager.transformControls&&(e.transformManager.setEnabled(!1),e.transformManager.transformControls.visible=!1,n=e.transformManager.transformControls);var r=[];e.scene.traverse(function(t){var a,i,o,u,c;0;var s=t===n||(null===(a=t.userData)||void 0===a?void 0:a.isTransformControls)||t.isTransformControls||t.type&&t.type.includes("TransformControls");s&&0,t===e.scene||null!==(i=t.userData)&&void 0!==i&&i.isBrickWall||null!==(o=t.userData)&&void 0!==o&&o.isBaseGround||null!==(u=t.userData)&&void 0!==u&&u.isBaseGrid||s||t.isLight||"PlaneGeometry"===(null===(c=t.geometry)||void 0===c?void 0:c.type)||r.push(t)}),r.forEach(function(n){e.scene.remove(n),n.geometry&&n.geometry.dispose(),n.material&&(Array.isArray(n.material)?n.material.forEach(function(e){return e.dispose()}):n.material.dispose())}),e.selectedObjectForTransform=null,e.transformHistory&&(e.transformHistory=[]),e.transformManager&&e.transformManager.transformControls||e.initTransformControls(),this.ensureTransformControlsAttached(!1)}},{key:"ensureTransformControlsAttached",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=this.sceneViewer;if(n.transformManager){if(!n.transformManager.transformControls)return n.transformManager.createTransformControls(),void n.transformManager.setupEventListeners();n.transformManager.ensureSceneAttachment(e);!e&&n.transformManager.transformControls&&(n.transformManager.transformControls.visible=!1)}else n.initTransformControls()}},{key:"loadLibraryModel",value:(k=a(i().m(function e(n,r,t){var a,s,f,d,h,m,y,w,k,b,p,g,M,x,S,B;return i().w(function(e){for(;;)switch(e.n){case 0:if(a=this.sceneViewer,e.p=1,v.info("Loading library GLB model for ".concat(null===(s=r.userData)||void 0===s?void 0:s.libraryId,"...")),v.debug("Starting to load GLB model from /library/models/".concat(t.modelKey)),h=n.parent,m=n.position.clone(),y=n.quaternion.clone(),w=n.scale.clone(),k=n.name,b=n.uuid,p=[],n.children.forEach(function(e){var n=e.geometry&&("CONNECTOR-GEO"===e.geometry.uuid||"SphereGeometry"===e.geometry.type&&e.geometry.parameters),r=e.name&&e.name.toLowerCase().includes("connector");if(n&&r){if(e.userData||(e.userData={}),!e.userData.worldBoundingBox){var t=(new c.Box3).setFromObject(e);e.userData.worldBoundingBox={min:t.min.toArray(),max:t.max.toArray()}}var a=e.clone();if(e.userData){a.userData={},e.userData.worldBoundingBox&&(a.userData.worldBoundingBox={min:o(e.userData.worldBoundingBox.min),max:o(e.userData.worldBoundingBox.max)}),e.userData.direction&&(a.userData.direction=o(e.userData.direction));for(var i=0,s=Object.entries(e.userData);i<s.length;i++){var l=u(s[i],2),v=l[0],f=l[1];"worldBoundingBox"!==v&&"direction"!==v&&(a.userData[v]=f)}a.userData.originalUuid=e.uuid,void 0===a.userData.forExport&&(a.userData.forExport=!0),a.userData.componentType||(e.name&&e.name.toLowerCase().includes("connector")?a.userData.componentType="connector":e.name&&e.name.toLowerCase().includes("gateway")&&(a.userData.componentType="gateway"))}p.push(a)}}),!(g=l.getCachedModelWithDimensions(t.modelKey,null===(f=r.userData)||void 0===f?void 0:f.libraryId))){e.n=2;break}e.n=8;break;case 2:if(!l.getStatus().isPreloading){e.n=6;break}return e.p=3,e.n=4,l.preloadingPromise;case 4:g=l.getCachedModelWithDimensions(t.modelKey,null===(M=r.userData)||void 0===M?void 0:M.libraryId),e.n=6;break;case 5:e.p=5,e.v;case 6:if(g){e.n=8;break}return e.n=7,new Promise(function(e,n){a.gltfLoader.load("/library/models/".concat(t.modelKey),function(n){e(n)},function(e){},function(e){n(e)})});case 7:S=e.v,g=S.scene,null!==(x=r.userData)&&void 0!==x&&x.libraryId&&(g=l.addDimensionsToModel(g,r.userData.libraryId));case 8:return(B=g.isCachedClone?g:g.clone()).uuid=b,B.name=k,B.quaternion.copy(y),B.scale.copy(w),B.userData||(B.userData={}),B.userData.originalUuid=b,B.userData.componentType="component",B.userData.libraryId=null===(d=r.userData)||void 0===d?void 0:d.libraryId,t.boundingBox&&(B.userData.dimensions={x:t.boundingBox.x,y:t.boundingBox.y,z:t.boundingBox.z}),t.adaptedBoundingBox&&(B.userData.adaptedBoundingBox={x:t.adaptedBoundingBox.x,y:t.adaptedBoundingBox.y,z:t.adaptedBoundingBox.z}),r.position&&r.rotation?(B.position.set(r.position.x,r.position.y,r.position.z),B.rotation.set(c.MathUtils.degToRad(r.rotation.x),c.MathUtils.degToRad(r.rotation.y),c.MathUtils.degToRad(r.rotation.z))):B.position.copy(m),B.traverse(function(e){e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0,e.material&&(e.material.envMapIntensity=1))}),p.forEach(function(e){B.add(e)}),B.children.forEach(function(e,n){e.name&&e.name.toLowerCase().includes("connector")}),B.children.length>0&&B.children.forEach(function(e,n){}),h&&h.add&&"function"==typeof h.add?(h.remove(n),h.add(B)):(a.scene.remove(n),a.scene.add(B)),e.a(2,B);case 9:return e.p=9,e.v,e.a(2,n)}},e,this,[[3,5],[1,9]])})),function(e,n,r){return k.apply(this,arguments)})},{key:"verifyModelPreloaderCache",value:(w=a(i().m(function e(){var n;return i().w(function(e){for(;;)switch(e.n){case 0:if(!(n=l.getStatus()).isPreloading){e.n=4;break}return e.p=1,e.n=2,l.preloadingPromise;case 2:e.n=4;break;case 3:e.p=3,e.v;case 4:return e.a(2,n)}},e,null,[[1,3]])})),function(){return w.apply(this,arguments)})},{key:"preloadMissingModels",value:(y=a(i().m(function e(n,r){var a,o,u,c,s,v,f,d;return i().w(function(e){for(;;)switch(e.n){case 0:return a=new Set,n.scene.object.children.forEach(function(e){var n,t;if(null!==(n=e.userData)&&void 0!==n&&n.libraryId&&r[null===(t=e.userData)||void 0===t?void 0:t.libraryId]){var i,o=r[null===(i=e.userData)||void 0===i?void 0:i.libraryId].modelKey;o&&a.add(o)}}),e.n=1,this.verifyModelPreloaderCache();case 1:if(o=e.v,u=o.cachedModels,!((c=Array.from(a).filter(function(e){return!u.includes(e)})).length>0)){e.n=11;break}s=t(c),e.p=2,s.s();case 3:if((v=s.n()).done){e.n=8;break}return f=v.value,e.p=4,e.n=5,l.preloadSingleModel(f);case 5:e.n=7;break;case 6:e.p=6,e.v;case 7:e.n=3;break;case 8:e.n=10;break;case 9:e.p=9,d=e.v,s.e(d);case 10:return e.p=10,s.f(),e.f(10);case 11:return e.a(2)}},e,this,[[4,6],[2,9,10,11]])})),function(e,n){return y.apply(this,arguments)})},{key:"createSceneMaterials",value:(m=a(i().m(function e(n){var r,t,a;return i().w(function(e){for(;;)switch(e.n){case 0:return r=this.sceneViewer,t={},a=null,e.p=1,e.n=2,s("light_metal",r.textureLoader);case 2:a=e.v,e.n=7;break;case 3:return e.p=3,e.v,e.p=4,e.n=5,s("gravel_embedded_concrete",r.textureLoader);case 5:a=e.v,e.n=7;break;case 6:e.p=6,e.v;case 7:return e.a(2,{materials:t,crosscubeTextureSet:a})}},e,this,[[4,6],[1,3]])})),function(e){return m.apply(this,arguments)})},{key:"createSceneGeometries",value:function(e,n){var r={};return e.scene.object.children.forEach(function(e){var t;if(null!==(t=e.userData)&&void 0!==t&&t.libraryId&&n[e.userData.libraryId]){var a=n[e.userData.libraryId].boundingBox,i=new c.BoxGeometry(a.x||1,a.y||1,a.z||1);r[e.geometry]=i}else{var o=e.uuid&&(e.uuid.toLowerCase().includes("connector")||e.uuid.toLowerCase().includes("gateway"));r[e.geometry]=o?new c.SphereGeometry(.1,16,16):new c.BoxGeometry(1,1,1)}}),r}},{key:"createSceneObject",value:function(e,r,t){var a=this,i=r[e.geometry],o=t[e.material];o||(o=new c.MeshPhysicalMaterial({color:12632256,roughness:.15,metalness:.9,emissive:0,envMapIntensity:1.5,transparent:!0,opacity:.8}));var u=new c.Mesh(i,o);if(u.uuid=e.uuid,u.name=e.name||e.uuid,u.userData||(u.userData={}),u.userData.originalUuid=e.uuid,e.userData&&(u.userData=n({},e.userData),u.userData.componentType||(u.userData.libraryId?u.userData.componentType="component":e.uuid&&e.uuid.toLowerCase().includes("connector")?u.userData.componentType="connector":e.uuid&&e.uuid.toLowerCase().includes("gateway")&&(u.userData.componentType="gateway"))),u.isMesh&&(u.castShadow=!0,u.receiveShadow=!0),e.position&&u.position.set(e.position.x||0,e.position.y||0,e.position.z||0),e.rotation){var s=e.rotation.x*(Math.PI/180),l=e.rotation.y*(Math.PI/180),v=e.rotation.z*(Math.PI/180);u.rotation.set(s,l,v)}return e.scale&&u.scale.set(e.scale.x||1,e.scale.y||1,e.scale.z||1),e.children&&e.children.forEach(function(e){u.add(a.createSceneObject(e,r,t))}),u}},{key:"computeWorldBoundingBoxes",value:function(e){this.sceneViewer.scene.traverse(function(n){if(n.isMesh){var r=null,a=function(e){var r,i=t(e);try{for(i.s();!(r=i.n()).done;){var o,u,c=r.value;if(c.uuid===n.uuid||c.uuid===(null===(o=n.userData)||void 0===o?void 0:o.originalUuid)||n.uuid===(null===(u=c.userData)||void 0===u?void 0:u.originalUuid))return c;if(c.children){var s=a(c.children);if(s)return s}}}catch(e){i.e(e)}finally{i.f()}return null};if(r=a(e.scene.object.children)){var i=(new c.Box3).setFromObject(n);r.userData||(r.userData={}),r.userData.worldBoundingBox={min:i.min.toArray(),max:i.max.toArray()}}}})}},{key:"loadSceneData",value:(h=a(i().m(function e(n){var r,t,a,o,u,s,l,v,f,d,h,m,y=this,w=arguments;return i().w(function(e){for(;;)switch(e.n){case 0:return r=!(w.length>1&&void 0!==w[1])||w[1],t=this.sceneViewer,e.p=1,a=function(e){e.traverse(function(e){if(e.userData&&e.userData.direction){var n=new c.Matrix4;n.copy(e.matrixWorld),e.userData.worldMatrixOriginal=n.elements}})},r&&(t.transformManager&&t.transformManager.transformControls,this.clearSceneObjects()),t.currentSceneData=n,o={},e.p=2,e.n=3,fetch("./library/component-dictionary.json");case 3:return u=e.v,e.n=4,u.json();case 4:o=e.v,e.n=6;break;case 5:e.p=5,e.v;case 6:return e.n=7,this.preloadMissingModels(n,o);case 7:return e.n=8,this.createSceneMaterials(n);case 8:if(s=e.v,l=s.materials,v=s.crosscubeTextureSet,f=this.createSceneGeometries(n,o),d=[],n.scene.object.children.forEach(function(e,n){var r,a,i,u=y.createSceneObject(e,f,l);t.scene.add(u),null!==(r=e.userData)&&void 0!==r&&r.libraryId&&o[null===(a=e.userData)||void 0===a?void 0:a.libraryId]&&d.push({basicObject:u,jsonData:e,componentData:o[null===(i=e.userData)||void 0===i?void 0:i.libraryId]})}),this.computeWorldBoundingBoxes(n),a(t.scene),h=[],d.forEach(function(e,n){var r=e.basicObject,t=e.jsonData,a=e.componentData,i=y.loadLibraryModel(r,t,a).then(function(e){return d[n].glbModel=e,e}).catch(function(e){return r});h.push(i)}),!(h.length>0)){e.n=10;break}return e.n=9,Promise.all(h);case 9:"undefined"!=typeof window&&(m=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now()}}),window.dispatchEvent(m));case 10:if(d.forEach(function(e,n){e.basicObject;var r=e.jsonData,t=(e.componentData,e.glbModel);t.userData.associatedJsonObject=r;var a=(new c.Box3).setFromObject(t);r.type="Mesh",r.userData.worldBoundingBox.min=a.min.toArray(),r.userData.worldBoundingBox.max=a.max.toArray()}),n.scene.object.children.push({uuid:"GROUND",type:"Mesh",name:"Ground",layers:1,matrix:[1,0,0,0,0,0,-1,0,0,1,0,0,0,-.01,0,1],up:[0,1,0],userData:{worldBoundingBox:{min:[-30,-.01,-30],max:[30,-.01,30]}}}),!t.pathfindingManager){e.n=11;break}return e.n=11,t.pathfindingManager.initializePathfinder(n,v);case 11:t.currentSceneData=n,t.crosscubeTextureSet=v,r&&(t.transformManager&&t.transformManager.transformControls?t.transformManager.transformControls&&(t.transformManager.transformControls.visible=!1):t.initTransformControls(),t.ensureTransformControlsAttached(!1),t.transformManager&&t.transformManager.transformControls&&(t.keepTransformControlsInactive(),t.transformManager.transformControls.visible=!1)),e.n=13;break;case 12:e.p=12,e.v;case 13:return e.a(2)}},e,this,[[2,5],[1,12]])})),function(e){return h.apply(this,arguments)})},{key:"loadScene",value:(d=a(i().m(function e(){var n,r,t,a;return i().w(function(e){for(;;)switch(e.n){case 0:return n=this.sceneViewer,e.p=1,r=n.$config.defaultCentralPlantUrl,e.n=2,fetch(r);case 2:return t=e.v,e.n=3,t.json();case 3:return a=e.v,n.currentSceneData=a,e.n=4,this.loadSceneData(a,!1);case 4:e.n=6;break;case 5:e.p=5,e.v;case 6:return e.a(2)}},e,this,[[1,5]])})),function(){return d.apply(this,arguments)})},{key:"loadSceneFromData",value:(f=a(i().m(function e(n){return i().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.loadSceneData(n,!0);case 1:return e.a(2)}},e,this)})),function(e){return f.apply(this,arguments)})},{key:"createEmptyScene",value:function(){var e=this.sceneViewer;e.transformManager&&e.transformManager.transformControls&&e.disableTransformControls(),this.clearSceneObjects(),e.transformManager&&e.transformManager.transformControls&&(e.transformManager.setEnabled(!1),e.transformManager.transformControls.visible=!1,e.transformManager.selectedObject&&e.transformManager.deselectObject())}},{key:"clearModelCache",value:function(){var e=this.sceneViewer;e.modelCache&&e.modelCache.clear(),e.loadingPromises&&e.loadingPromises.clear()}},{key:"deselectObject",value:function(){var e=this.sceneViewer;e.transformManager&&e.transformManager.deselectObject(),e.selectedObjectForTransform=null}},{key:"setupEventListeners",value:function(){var e,n,r,t,o=this;this.sceneViewer;var u=this.loadSceneFromData.bind(this);null===(e=window.$nuxt)||void 0===e||null===(n=e.$on)||void 0===n||n.call(e,"loadNewScene",function(){var e=a(i().m(function e(n){return i().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,u(n);case 1:return e.a(2)}},e)}));return function(n){return e.apply(this,arguments)}}()),null===(r=window.$nuxt)||void 0===r||null===(t=r.$on)||void 0===t||t.call(r,"createNewScene",function(){o.createEmptyScene()})}},{key:"updateSceneDataAfterTransform",value:function(e,r){var t,a,i=!1;if(this.sceneViewer.pathfindingManager.recomputeWorldBoundingBoxes(r),"gateway"===(null===(t=e.userData)||void 0===t?void 0:t.componentType)&&"computed"===(null===(a=e.userData)||void 0===a?void 0:a.origin)){var o;e.userData.origin="declared";for(var u=0;u<r.scene.object.children.length;u++){var s,l,v=r.scene.object.children[u];if(v.uuid===e.uuid||v.uuid===(null===(s=e.userData)||void 0===s?void 0:s.originalUuid)||e.uuid===(null===(l=v.userData)||void 0===l?void 0:l.originalUuid)){v.userData||(v.userData={}),v.userData.origin="declared";break}}if(null!==(o=e.userData)&&void 0!==o&&o.connections&&r.connections){var f=e.userData.connections,d=r.connections;f.removed&&Array.isArray(f.removed)&&(r.connections=d.filter(function(e){var n=f.removed.some(function(n){return n.from===e.from&&n.to===e.to||n.from===e.to&&n.to===e.from});return!n})),f.added&&Array.isArray(f.added)&&f.added.forEach(function(e){r.connections.some(function(n){return n.from===e.from&&n.to===e.to||n.from===e.to&&n.to===e.from})||r.connections.push(e)})}}for(var h=function(){var t,a,o,u,s=r.scene.object.children[m],l=!1;if(s.uuid!==e.uuid&&s.uuid!==(null===(t=e.userData)||void 0===t?void 0:t.originalUuid)&&e.uuid!==(null===(a=s.userData)||void 0===a?void 0:a.originalUuid)||(l=!0),!l&&null!==(o=e.userData)&&void 0!==o&&o.libraryId&&null!==(u=s.userData)&&void 0!==u&&u.libraryId&&e.userData.libraryId===s.userData.libraryId){if(s.position&&e.position){var v=Math.abs(e.position.x-s.position.x),f=Math.abs(e.position.y-s.position.y),d=Math.abs(e.position.z-s.position.z);v<1&&f<1&&d<1&&(l=!0)}}if(l){var h=(new c.Box3).setFromObject(e),y=function(e,r){return e&&r?e.map(function(e){var t=r.find(function(n){var r,t,a,i;if(n.uuid===e.uuid||n.uuid===(null===(r=e.userData)||void 0===r?void 0:r.originalUuid)||(null===(t=n.userData)||void 0===t?void 0:t.originalUuid)===e.uuid)return!0;if(null!==(a=n.userData)&&void 0!==a&&a.componentType&&null!==(i=e.userData)&&void 0!==i&&i.componentType&&n.userData.componentType===e.userData.componentType&&"connector"===n.userData.componentType){if(e.position&&n.position){var o=Math.abs(n.position.x-e.position.x),u=Math.abs(n.position.y-e.position.y),c=Math.abs(n.position.z-e.position.z);if(o<.1&&u<.1&&c<.1)return!0}}return!1});if(t&&t.isMesh){var a=(new c.Box3).setFromObject(t);return n(n({},e),{},{userData:n(n(n({},e.userData),t.userData),{},{worldBoundingBox:{min:a.min.toArray(),max:a.max.toArray()}}),children:e.children?y(e.children,t.children):e.children})}return n(n({},e),{},{children:e.children?y(e.children,r):e.children})}):e};return e.traverse(function(e){if(e.userData&&e.userData.direction&&e.userData.worldMatrixOriginal){e.updateMatrixWorld(!0);var n=new c.Matrix4;n.copy(e.matrixWorld);var r=new c.Matrix4;r.elements=e.userData.worldMatrixOriginal;var t=new c.Matrix4,a=new c.Matrix4;t.extractRotation(n),a.extractRotation(r);var i=new c.Matrix4;i.copy(t),i.multiply(a.invert());var o=(new c.Vector3).fromArray(e.userData.direction);o.applyMatrix4(i),o.normalize();o.x=Math.abs(o.x)>.5?Math.sign(o.x):0,o.y=Math.abs(o.y)>.5?Math.sign(o.y):0,o.z=Math.abs(o.z)>.5?Math.sign(o.z):0,e.userData.direction=o.toArray(),e.userData.worldMatrixOriginal=n.elements}}),r.scene.object.children[m]=n(n({},s),{},{matrix:e.matrix.elements,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z},userData:n(n({},s.userData),{},{worldBoundingBox:{min:h.min.toArray(),max:h.max.toArray()}}),children:s.children?y(s.children,e.children):s.children}),i=!0,1}},m=0;m<r.scene.object.children.length&&!h();m++);return!!i}}]);var f,d,h,m,y,w,k}();export{f as SceneOperationsManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,classCallCheck as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{CSS2DRenderer as n,CSS2DObject as e}from"../../../node_modules/three/examples/jsm/renderers/CSS2DRenderer.js";import*as o from"three";var s=function(t){for(var i,n=arguments.length,e=new Array(n>1?n-1:0),o=1;o<n;o++)e[o-1]=arguments[o];return(i=console).log.apply(i,["🔍 [Tooltips] ".concat(t)].concat(e))},r=function(t){for(var i,n=arguments.length,e=new Array(n>1?n-1:0),o=1;o<n;o++)e[o-1]=arguments[o];return(i=console).log.apply(i,["ℹ️ [Tooltips] ".concat(t)].concat(e))},a=function(t){for(var i,n=arguments.length,e=new Array(n>1?n-1:0),o=1;o<n;o++)e[o-1]=arguments[o];return(i=console).warn.apply(i,["⚠️ [Tooltips] ".concat(t)].concat(e))},l=function(t){for(var i,n=arguments.length,e=new Array(n>1?n-1:0),o=1;o<n;o++)e[o-1]=arguments[o];return(i=console).error.apply(i,["❌ [Tooltips] ".concat(t)].concat(e))},h=function(){return t(function t(n,e,o){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;i(this,t),this.container=n,this.camera=e,this.scene=o,this.transformControlsManager=s,this.tooltipTemplate='\n<div class="component-tooltip" style="\n background-color: rgba(255, 255, 255, 0.95); \n color: #333333; \n border-radius: 8px; \n padding: 12px; \n width: 250px; \n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, sans-serif;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);\n border: 1px solid rgba(0, 0, 0, 0.1);\n user-select: none;\n pointer-events: auto;\n font-size: 13px;\n line-height: 1.4;\n transform: translate(-50%, -100%);\n margin-top: 0px;\n margin-left: 0px;\n position: relative;\n z-index: 1000;\n">\n <div class="tooltip-header" style="\n font-weight: 600; \n padding-bottom: 8px; \n border-bottom: 1px solid rgba(0, 0, 0, 0.1); \n margin-bottom: 8px;\n font-size: 14px;\n color: #2c3e50;\n ">Component Name</div>\n <div class="tooltip-body">\n <div class="tooltip-type" style="\n font-size: 12px;\n color: #666;\n margin-bottom: 8px;\n font-style: italic;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n "></div>\n <div class="tooltip-attributes">\n \x3c!-- Dynamic attributes will be inserted here --\x3e\n </div>\n <div class="tooltip-row tooltip-actions" style="display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 8px; border-top: 1px solid rgba(0, 0, 0, 0.1);">\n <div class="tooltip-key" style="flex: 1; color: #555555; font-size: 12px;">Add:</div>\n <div class="tooltip-dropdown-container" style="flex: 1; text-align: center;">\n <select class="tooltip-dropdown" style="\n background-color: #f8f9fa;\n color: #333333;\n border: 1px solid #ddd;\n padding: 4px 8px;\n border-radius: 4px;\n width: 100%;\n cursor: pointer;\n pointer-events: auto;\n font-size: 12px;\n ">\n <option value="" disabled selected>Select...</option>\n <option value="gateway">Gateway</option>\n <option value="connector">Connector</option>\n </select>\n </div>\n </div>\n </div>\n</div>\n',this.tooltipRenderer=null,this.selectedMesh=null,this.tooltipParent=null,this.tooltipObject=null,this.init()},[{key:"init",value:function(){this.tooltipRenderer=new n,this.tooltipRenderer.setSize(this.container.clientWidth,this.container.clientHeight),this.tooltipRenderer.domElement.style.position="absolute",this.tooltipRenderer.domElement.style.top="0",this.tooltipRenderer.domElement.style.left="0",this.tooltipRenderer.domElement.style.overflow="visible",this.tooltipRenderer.domElement.style.pointerEvents="none",this.tooltipRenderer.domElement.style.zIndex="100",this.container.appendChild(this.tooltipRenderer.domElement)}},{key:"resize",value:function(){this.tooltipRenderer&&this.tooltipRenderer.setSize(this.container.clientWidth,this.container.clientHeight)}},{key:"setTransformControlsManager",value:function(t){this.transformControlsManager=t,r("Transform controls manager set for tooltips"),this.transformControlsManager&&this.setupTransformControlsEvents(),this.tooltipObject&&this.updateTooltipForTransform()}},{key:"setupTransformControlsEvents",value:function(){var t=this;this.transformControlsManager&&this.transformControlsManager.on({onTransform:function(i){i===t.selectedMesh&&t.tooltipObject&&t.updateTooltipForTransform()},onTransformEnd:function(i){i===t.selectedMesh&&t.tooltipObject&&t.updateTooltipForTransform()}})}},{key:"setSelectedMesh",value:function(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.selectedMesh!==i&&(r("Setting selected mesh:",i?i.uuid:"none"),this.clearTooltip(),this.selectedMesh=i,i&&null!==(t=i.userData)&&void 0!==t&&null!==(t=t.component)&&void 0!==t&&t.attributes?(r("Mesh has component attributes, showing tooltip"),this.showTooltip()):i&&(a("Mesh does not have required component data for tooltip:",i),i.userData&&s("Available userData:",i.userData)))}},{key:"render",value:function(){if(this.tooltipRenderer&&this.camera&&this.scene)try{this.tooltipRenderer.render(this.scene,this.camera)}catch(t){l("Error rendering tooltips:",t)}}},{key:"dispose",value:function(){this.clearTooltip(),this.transformControlsManager&&(this.transformControlsManager=null),this.tooltipRenderer&&this.tooltipRenderer.domElement&&this.tooltipRenderer.domElement.parentNode&&this.tooltipRenderer.domElement.parentNode.removeChild(this.tooltipRenderer.domElement),this.tooltipRenderer=null,this.selectedMesh=null,this.container=null,this.camera=null,this.scene=null}},{key:"showTooltip",value:function(){try{if(!this.selectedMesh||!this.selectedMesh.userData||!this.selectedMesh.userData.component)return void a("Cannot show tooltip, missing data in selectedMesh");r("Showing tooltip for:",this.selectedMesh.uuid);var t=this.selectedMesh.userData.component;if(!t.attributes)return void a("Component has no attributes:",t);var i=t.attributes,n=document.createElement("div");n.innerHTML=this.tooltipTemplate.trim();var o=n.firstElementChild||n.firstChild;s("showTooltip this.selectedMesh:",this.selectedMesh),s("showTooltip meshComponentData:",t);var h=o.querySelector(".tooltip-header");h&&(this.selectedMesh.name&&""!==this.selectedMesh.name?h.textContent=this.selectedMesh.name:h.textContent=this.selectedMesh.userData.originalUuid||this.selectedMesh.userData.uuid||"Unknown Component");var c=o.querySelector(".tooltip-type");c&&t.type&&(c.textContent=t.type);var u=o.querySelector(".tooltip-attributes");if(u&&i&&Object.keys(i).length>0){u.innerHTML="",Object.keys(i).forEach(function(t){var n=i[t],e=document.createElement("div");e.className="tooltip-row",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="space-between",e.style.marginBottom="5px";var o=document.createElement("div");o.className="tooltip-key",o.style.flex="1",o.style.color="#555555",o.textContent="".concat(n.key||t,":");var s=document.createElement("div");s.className="tooltip-value",s.style.flex="1",s.style.textAlign="center",s.style.color="#000000";var r=n.value||"0";n.unit&&(r+=" ".concat(n.unit)),s.textContent=r,e.appendChild(o),e.appendChild(s),u.appendChild(e)});var p=o.querySelector(".tooltip-dropdown");p&&p.addEventListener("change",function(t){t.stopPropagation();var i=t.target.value;r("Add option selected: ".concat(i)),"gateway"===i?r("Adding Gateway"):"connector"===i&&r("Adding Connector"),t.target.selectedIndex=0})}var d=new e(o);this.tooltipParent=this.selectedMesh,this.tooltipObject=d;var v=this.calculateTooltipPosition();d.position.set(v.x,v.y,v.z),d.userData={isTooltip:!0},this.selectedMesh.add(d),r("Tooltip positioned at:",v)}catch(t){l("Error showing tooltip:",t)}}},{key:"updateTooltip",value:function(){if(this.tooltipParent&&this.tooltipObject){var t=this.calculateTooltipPosition();this.tooltipObject.position.set(t.x,t.y,t.z)}}},{key:"updateTooltipForTransform",value:function(){if(this.tooltipObject&&this.selectedMesh){var t=this.calculateTooltipPosition();this.tooltipObject.position.set(t.x,t.y,t.z),s("Tooltip position updated for transform")}}},{key:"getObjectBoundingBox",value:function(t){return(new o.Box3).setFromObject(t)}},{key:"calculateOptimalTooltipOffset",value:function(){if(!this.camera||!this.selectedMesh)return 1.5;var t=new o.Vector3;this.selectedMesh.getWorldPosition(t);var i=new o.Vector3;this.camera.getWorldPosition(i);return 1}},{key:"calculateTooltipPosition",value:function(){var t=this.getObjectBoundingBox(this.selectedMesh),i=this.findClosestBoundingBoxCorner(t),n=new o.Vector3;this.selectedMesh.getWorldPosition(n);var e=i.clone().sub(n),s=this.calculatePixelBasedOffset(e,n),l={x:e.x+s.x,y:e.y+s.y,z:e.z+s.z};if(this.transformControlsManager&&this.transformControlsManager.selectedObject===this.selectedMesh)try{var h=this.transformControlsManager.getWorldTransformData();if(h&&h.position)return r("Using transform controls position for tooltip at closest corner"),{x:e.x+s.x,y:e.y+s.y,z:e.z+s.z}}catch(t){a("Error getting transform controls position:",t)}return r("Positioning tooltip at closest corner to origin:",l),l}},{key:"calculatePixelBasedOffset",value:function(t,i){if(!this.camera)return{x:0,y:0,z:0};var n=250;if(this.tooltipObject&&this.tooltipObject.element){var e=this.tooltipObject.element;if(e.offsetWidth>0)n=e.offsetWidth;else{var r=document.createElement("div");r.style.position="absolute",r.style.visibility="hidden",r.style.top="-9999px",document.body.appendChild(r),r.appendChild(e),n=e.offsetWidth||250,document.body.removeChild(r)}}var a=n/2,l=i.clone().add(t),h=new o.Vector3;this.camera.getWorldPosition(h);var c=new o.Vector3;this.camera.getWorldDirection(c);var u=this.isPositionOnRightSideOfCameraMidline(l,h,c),p=l.distanceTo(h),d=0;if(this.camera.isPerspectiveCamera){var v=this.camera.fov*Math.PI/180,f=Math.tan(v/2)*p*this.camera.aspect;d=a/this.container.clientWidth*(2*f)}else if(this.camera.isOrthographicCamera){var m=(this.camera.right-this.camera.left)/2;d=a/this.container.clientWidth*(2*m)}var y=new o.Vector3;this.camera.getWorldDirection(y),y.cross(this.camera.up).normalize();var w=u?-1:1,g=y.multiplyScalar(d*w);return s("Tooltip pixel offset calculated:",{tooltipWidth:n,halfTooltipWidth:a,distanceToCamera:p,screenSpaceOffset:d,isOnRightSide:u,offsetDirection:w,worldOffset:g}),{x:g.x,y:0,z:g.z}}},{key:"findClosestBoundingBoxCorner",value:function(t){var i=t.min,n=t.max,e=[new o.Vector3(i.x,i.y,i.z),new o.Vector3(n.x,i.y,i.z),new o.Vector3(i.x,n.y,i.z),new o.Vector3(n.x,n.y,i.z),new o.Vector3(i.x,i.y,n.z),new o.Vector3(n.x,i.y,n.z),new o.Vector3(i.x,n.y,n.z),new o.Vector3(n.x,n.y,n.z)];return this.findCornerClosestToCameraVerticalMidline(e)}},{key:"findCornerClosestToCameraVerticalMidline",value:function(t){if(!this.camera)return a("No camera available, using first corner"),t[0];var i=new o.Vector3;this.camera.getWorldPosition(i);var n=new o.Vector3;this.camera.getWorldDirection(n);for(var e=t[0],r=this.getDistanceToVerticalMidline(t[0],i,n),l=1;l<t.length;l++){var h=this.getDistanceToVerticalMidline(t[l],i,n);h<r&&(r=h,e=t[l])}return s("Closest corner to camera vertical midline:",e,"Distance:",r),e}},{key:"getDistanceToVerticalMidline",value:function(t,i,n){var e=t.clone().sub(i),o=e.dot(n),s=n.clone().multiplyScalar(o);return e.clone().sub(s).length()}},{key:"clearTooltip",value:function(){this.tooltipParent&&this.tooltipObject&&(this.tooltipParent.remove(this.tooltipObject),this.tooltipParent=null,this.tooltipObject=null)}},{key:"handleSceneClick",value:function(t,i){this.clearTooltip(),this.selectedMesh=null}},{key:"isSelectableComponent",value:function(t){var i,n;return!!(t&&t.userData&&t.userData.component)||!(!t||!(null!==(i=t.userData)&&void 0!==i&&i.isPipeSegment||null!==(n=t.userData)&&void 0!==n&&n.isPipeJunction))}},{key:"isPositionOnRightSideOfCameraMidline",value:function(t,i,n){var e=new o.Vector3;return this.camera.getWorldDirection(e),e.cross(this.camera.up).normalize(),t.clone().sub(i).dot(e)>0}}])}();export{h as SceneTooltipsManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,slicedToArray as n,typeof as i,classCallCheck as e,asyncToGenerator as s,regenerator as l}from"../../../_virtual/_rollupPluginBabelHelpers.js";var a=function(){return t(function t(n){e(this,t),this.sceneViewer=n,this.isDev="development"===process.env.NODE_ENV},[{key:"enhancedDisposal",value:(u=s(l().m(function t(){return l().w(function(t){for(;;)switch(t.n){case 0:return this.isDev,this.forceStopOperations(),t.n=1,this.enhancedSceneCleanup();case 1:this.enhancedRendererCleanup(),this.sceneViewer.hotReloadManager&&this.sceneViewer.hotReloadManager.clearPendingOperations(),this.isDev&&this.sceneViewer.hotReloadManager&&this.sceneViewer.hotReloadManager.forceGarbageCollectionHint();case 2:return t.a(2)}},t,this)})),function(){return u.apply(this,arguments)})},{key:"forceStopOperations",value:function(){this.sceneViewer.isDestroyed=!0,this.sceneViewer.isLoading=!1,this.sceneViewer.currentTransition=null,this.sceneViewer.animationId&&(cancelAnimationFrame(this.sceneViewer.animationId),this.sceneViewer.animationId=null),this.isDev}},{key:"enhancedSceneCleanup",value:(a=s(l().m(function t(){var n,i=this;return l().w(function(t){for(;;)switch(t.n){case 0:if(n={textures:0,materials:0,geometries:0,objects:0},this.sceneViewer.scene){for(this.sceneViewer.scene.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){n.textures+=i.disposeMaterialTextures(t),t.dispose(),n.materials++}):(n.textures+=i.disposeMaterialTextures(t.material),t.material.dispose(),n.materials++)),t.geometry&&(t.geometry.dispose(),n.geometries++),n.objects++});this.sceneViewer.scene.children.length>0;)this.sceneViewer.scene.remove(this.sceneViewer.scene.children[0]);this.isDev}case 1:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"disposeMaterialTextures",value:function(t){var n=0;return["map","normalMap","roughnessMap","metalnessMap","envMap","lightMap","bumpMap","specularMap"].forEach(function(i){t[i]&&(t[i].dispose(),n++)}),n}},{key:"enhancedRendererCleanup",value:function(){if(this.sceneViewer.renderer){var t=this.sceneViewer.renderer.getContext();if(t&&"function"==typeof t.getExtension){var n=t.getExtension("WEBGL_lose_context");n&&n.loseContext()}this.sceneViewer.renderer.dispose(),this.sceneViewer.renderer.forceContextLoss(),this.sceneViewer.renderer=null,this.isDev}}},{key:"cleanupScene",value:function(){var t=this;if(this.sceneViewer.scene){var n=[];this.sceneViewer.scene.traverse(function(t){n.push(t)});for(var i=function(){var i=n[e];i.geometry&&i.geometry.dispose(),i.material&&(Array.isArray(i.material)?i.material.forEach(function(n){return t.disposeMaterial(n)}):t.disposeMaterial(i.material));["map","lightMap","bumpMap","normalMap","specularMap","envMap"].forEach(function(t){i[t]&&i[t].dispose()}),i.parent&&i.parent.remove(i)},e=n.length-1;e>=0;e--)i();this.sceneViewer.scene.environment&&(this.sceneViewer.scene.environment.dispose(),this.sceneViewer.scene.environment=null),this.sceneViewer.scene.background&&this.sceneViewer.scene.background.dispose&&(this.sceneViewer.scene.background.dispose(),this.sceneViewer.scene.background=null),this.sceneViewer.scene.clear(),this.sceneViewer.scene=null}}},{key:"disposeMaterial",value:function(t){for(var e=0,s=Object.entries(t);e<s.length;e++){var l=n(s[e],2);l[0];var a=l[1];a&&"object"===i(a)&&"function"==typeof a.dispose&&a.dispose()}t.dispose()}},{key:"cleanupRenderer",value:function(){this.sceneViewer.renderer&&(this.sceneViewer.renderer.domElement&&this.sceneViewer.renderer.domElement.parentNode&&this.sceneViewer.renderer.domElement.parentNode.removeChild(this.sceneViewer.renderer.domElement),this.sceneViewer.renderer.dispose(),this.sceneViewer.renderer.forceContextLoss(),this.sceneViewer.renderer=null)}},{key:"cleanupControls",value:function(){this.sceneViewer.controls&&(this.sceneViewer.controls.dispose(),this.sceneViewer.controls=null)}},{key:"cleanupEventListeners",value:function(){this.sceneViewer.handleResize&&(window.removeEventListener("resize",this.sceneViewer.handleResize),this.sceneViewer.handleResize=null),this.sceneViewer.resizeObserver&&(this.sceneViewer.resizeObserver.disconnect(),this.sceneViewer.resizeObserver=null),this.sceneViewer.handleKeyDown&&(window.removeEventListener("keydown",this.sceneViewer.handleKeyDown),this.sceneViewer.handleKeyDown=null),window._performanceKeyHandler&&(window.removeEventListener("keydown",window._performanceKeyHandler),delete window._performanceKeyHandler)}},{key:"cleanupPerformanceMonitoring",value:function(){if(this.sceneViewer.performanceMonitor){try{this.sceneViewer.performanceMonitor.stop()}catch(t){}this.sceneViewer.performanceMonitor=null}if(this.sceneViewer.performanceUI){try{"function"==typeof this.sceneViewer.performanceUI.dispose?this.sceneViewer.performanceUI.dispose():this.sceneViewer.performanceUI.hide()}catch(t){}this.sceneViewer.performanceUI=null}try{var t=document.querySelectorAll("#performance-monitor-ui");t.length>0&&t.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}catch(t){}}},{key:"cleanupGlobalReferences",value:function(){var t=this.parent;if(t){if(t.tooltipsManager)try{t.tooltipsManager.dispose()}catch(t){}finally{t.tooltipsManager=null}t.hotReloadManager=null,t.sceneExportManager=null,t.componentManager=null,t.sceneInitializationManager=null,t.environmentManager=null,t.keyboardControlsManager=null,t.pathfindingManager=null,t.sceneOperationsManager=null,t.animationManager=null,t.cameraControlsManager=null,t.disposalManager=null}}},{key:"cleanupNuxtEventListeners",value:function(){window.$nuxt&&window.$nuxt.$off&&(window.$nuxt.$off("loadNewScene"),window.$nuxt.$off("createNewScene"))}}]);var a,u}();export{a as DisposalManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,classCallCheck as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";var n=function(){return t(function t(n){i(this,t),this.sceneViewer=n||null,this.isDev="development"===process.env.NODE_ENV,this.instanceId=Date.now()+Math.random(),this.hotReloadCleanupHandler=null,this.visibilityChangeHandler=null,this.nuxtHotReloadHandler=null,this.memoryCheckInterval=null,this.timeoutIds=new Set,this.intervalIds=new Set},[{key:"setupHotReloadHandling",value:function(){var t=this;if(this.sceneViewer&&this.isDev){window._sceneViewerInstances||(window._sceneViewerInstances=new Set);try{window._sceneViewerInstances.add(this.sceneViewer)}catch(t){}this.hotReloadCleanupHandler=function(){if(t.sceneViewer){if(t.sceneViewer&&t.sceneViewer.tooltipsManager)try{t.sceneViewer.tooltipsManager.dispose(),t.sceneViewer.tooltipsManager=null}catch(t){}try{"function"==typeof t.sceneViewer.enhancedDisposal&&t.sceneViewer.enhancedDisposal()}catch(t){}try{import("./performanceMonitor.js").then(function(t){var i=t.PerformanceUI;i&&"function"==typeof i.cleanupAllInstances&&i.cleanupAllInstances()}).catch(function(t){})}catch(t){}if(window._sceneViewerInstances)try{window._sceneViewerInstances.delete(t.sceneViewer)}catch(t){}}};try{window.addEventListener("beforeunload",this.hotReloadCleanupHandler),window.addEventListener("pagehide",this.hotReloadCleanupHandler)}catch(t){}}}},{key:"cleanupHotReloadHandlers",value:function(){if(this.isDev)try{this.hotReloadCleanupHandler&&(window.removeEventListener("beforeunload",this.hotReloadCleanupHandler),window.removeEventListener("pagehide",this.hotReloadCleanupHandler),this.hotReloadCleanupHandler=null),this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.nuxtHotReloadHandler&&window.$nuxt&&window.$nuxt.$off&&(window.$nuxt.$off("routeChanged",this.nuxtHotReloadHandler),window.$nuxt.$off("$nuxtReady",this.nuxtHotReloadHandler),this.nuxtHotReloadHandler=null),this.memoryCheckInterval&&(clearInterval(this.memoryCheckInterval),this.memoryCheckInterval=null);this.sceneViewer;if(window._sceneViewerInstances&&this.sceneViewer)try{window._sceneViewerInstances.delete(this.sceneViewer)}catch(t){}this.sceneViewer=null,window._sceneViewerInstances&&0===window._sceneViewerInstances.size&&delete window._sceneViewerInstances}catch(t){}}},{key:"clearPendingOperations",value:function(){this.timeoutIds&&(this.timeoutIds.forEach(function(t){return clearTimeout(t)}),this.timeoutIds.clear()),this.intervalIds&&(this.intervalIds.forEach(function(t){return clearInterval(t)}),this.intervalIds.clear()),this.isDev}},{key:"forceGarbageCollectionHint",value:function(){this.isDev&&setTimeout(function(){window.gc?window.gc():new Array(1e6).fill(0).length=0},100)}},{key:"addTimeout",value:function(t){this.timeoutIds.add(t)}},{key:"addInterval",value:function(t){this.intervalIds.add(t)}},{key:"removeTimeout",value:function(t){this.timeoutIds.delete(t)}},{key:"removeInterval",value:function(t){this.intervalIds.delete(t)}}])}();export{n as HotReloadManager};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,createForOfIteratorHelper as e,classCallCheck as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";var s=function(){return t(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;i(this,t),this.renderer=e,this.stats={fps:{current:0,average:0,min:1/0,max:0,history:[]},frameTime:{current:0,average:0,min:1/0,max:0,history:[]},memory:{geometries:0,textures:0,programs:0,heapUsed:0,heapTotal:0},drawCalls:{current:0,average:0,triangles:0,points:0,lines:0},gpu:{memoryUsage:0,extensions:[]},scene:{objects:0,lights:0,meshes:0,materials:0,visible:0}},this.frameCount=0,this.lastTime=performance.now(),this.updateInterval=100,this.maxHistoryLength=300,this.thresholds={fps:{good:55,warning:45,critical:30},frameTime:{good:16.67,warning:22.22,critical:33.33},memory:{warning:200,critical:300},drawCalls:{warning:500,critical:1e3}},this.callbacks=new Map,this.isMonitoring=!1,this.update=this.update.bind(this),this.getGPUInfo=this.getGPUInfo.bind(this)},[{key:"start",value:function(){this.isMonitoring=!0,this.lastTime=performance.now(),this.getGPUInfo()}},{key:"stop",value:function(){this.isMonitoring=!1}},{key:"update",value:function(){if(this.isMonitoring){var t=performance.now(),e=t-this.lastTime;this.frameCount++;var i=1e3/e,s=e;this.stats.fps.current=i,this.stats.frameTime.current=s,this.addToHistory(this.stats.fps,i),this.addToHistory(this.stats.frameTime,s),this.frameCount%this.updateInterval===0&&(this.updateAverages(),this.updateMemoryStats(),this.updateDrawCallStats(),this.updateSceneStats(),this.checkThresholds()),this.lastTime=t}}},{key:"addToHistory",value:function(t,e){t.history.push(e),t.history.length>this.maxHistoryLength&&t.history.shift(),t.min=Math.min(t.min,e),t.max=Math.max(t.max,e)}},{key:"updateAverages",value:function(){this.stats.fps.history.length>0&&(this.stats.fps.average=this.stats.fps.history.reduce(function(t,e){return t+e},0)/this.stats.fps.history.length),this.stats.frameTime.history.length>0&&(this.stats.frameTime.average=this.stats.frameTime.history.reduce(function(t,e){return t+e},0)/this.stats.frameTime.history.length)}},{key:"updateMemoryStats",value:function(){var t;if(this.renderer){var e=this.renderer.info;this.stats.memory.geometries=e.memory.geometries,this.stats.memory.textures=e.memory.textures,this.stats.memory.programs=(null===(t=e.programs)||void 0===t?void 0:t.length)||0,performance.memory&&(this.stats.memory.heapUsed=Math.round(performance.memory.usedJSHeapSize/1024/1024),this.stats.memory.heapTotal=Math.round(performance.memory.totalJSHeapSize/1024/1024))}}},{key:"updateDrawCallStats",value:function(){if(this.renderer){var t=this.renderer.info.render;this.stats.drawCalls.current=t.calls,this.stats.drawCalls.triangles=t.triangles,this.stats.drawCalls.points=t.points,this.stats.drawCalls.lines=t.lines,this.stats.drawCalls.history||(this.stats.drawCalls.history=[]),this.addToHistory(this.stats.drawCalls,t.calls),this.stats.drawCalls.history.length>0&&(this.stats.drawCalls.average=this.stats.drawCalls.history.reduce(function(t,e){return t+e},0)/this.stats.drawCalls.history.length)}}},{key:"updateSceneStats",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(t){var i,s=0,n=0,a=0,r=new Set,o=0,l=e(t.children);try{for(l.s();!(i=l.n()).done;){var h=i.value;s++,h.visible&&o++,h.isLight&&n++,h.isMesh&&(a++,h.material&&(Array.isArray(h.material)?h.material.forEach(function(t){return r.add(t.uuid)}):r.add(h.material.uuid)))}}catch(t){l.e(t)}finally{l.f()}this.stats.scene={objects:s,lights:n,meshes:a,materials:r.size,visible:o}}}},{key:"getGPUInfo",value:function(){if(this.renderer){var t=this.renderer.getContext();this.stats.gpu.extensions=t.getSupportedExtensions()||[];var e=t.getExtension("WEBGL_debug_renderer_info");e&&(this.stats.gpu.renderer=t.getParameter(e.UNMASKED_RENDERER_WEBGL),this.stats.gpu.vendor=t.getParameter(e.UNMASKED_VENDOR_WEBGL))}}},{key:"checkThresholds",value:function(){var t=[];this.stats.fps.average<this.thresholds.fps.critical?t.push({type:"critical",category:"FPS",value:this.stats.fps.average.toFixed(1),threshold:this.thresholds.fps.critical}):this.stats.fps.average<this.thresholds.fps.warning&&t.push({type:"warning",category:"FPS",value:this.stats.fps.average.toFixed(1),threshold:this.thresholds.fps.warning}),this.stats.frameTime.average>this.thresholds.frameTime.critical?t.push({type:"critical",category:"Frame Time",value:this.stats.frameTime.average.toFixed(2)+"ms",threshold:this.thresholds.frameTime.critical+"ms"}):this.stats.frameTime.average>this.thresholds.frameTime.warning&&t.push({type:"warning",category:"Frame Time",value:this.stats.frameTime.average.toFixed(2)+"ms",threshold:this.thresholds.frameTime.warning+"ms"}),this.stats.memory.heapUsed>this.thresholds.memory.critical?t.push({type:"critical",category:"Memory",value:this.stats.memory.heapUsed+"MB",threshold:this.thresholds.memory.critical+"MB"}):this.stats.memory.heapUsed>this.thresholds.memory.warning&&t.push({type:"warning",category:"Memory",value:this.stats.memory.heapUsed+"MB",threshold:this.thresholds.memory.warning+"MB"}),this.stats.drawCalls.average>this.thresholds.drawCalls.critical?t.push({type:"critical",category:"Draw Calls",value:Math.round(this.stats.drawCalls.average),threshold:this.thresholds.drawCalls.critical}):this.stats.drawCalls.average>this.thresholds.drawCalls.warning&&t.push({type:"warning",category:"Draw Calls",value:Math.round(this.stats.drawCalls.average),threshold:this.thresholds.drawCalls.warning}),t.length>0&&this.triggerCallback("warning",t)}},{key:"on",value:function(t,e){this.callbacks.has(t)||this.callbacks.set(t,[]),this.callbacks.get(t).push(e)}},{key:"off",value:function(t,e){if(this.callbacks.has(t)){var i=this.callbacks.get(t),s=i.indexOf(e);s>-1&&i.splice(s,1)}}},{key:"triggerCallback",value:function(t,e){this.callbacks.has(t)&&this.callbacks.get(t).forEach(function(t){return t(e)})}},{key:"getSummary",value:function(){return{fps:{current:Math.round(this.stats.fps.current),average:Math.round(this.stats.fps.average),min:Math.round(this.stats.fps.min),max:Math.round(this.stats.fps.max)},frameTime:{current:this.stats.frameTime.current.toFixed(2)+"ms",average:this.stats.frameTime.average.toFixed(2)+"ms"},memory:{geometries:this.stats.memory.geometries,textures:this.stats.memory.textures,heapUsed:this.stats.memory.heapUsed+"MB",heapTotal:this.stats.memory.heapTotal+"MB"},drawCalls:{current:this.stats.drawCalls.current,average:Math.round(this.stats.drawCalls.average),triangles:this.stats.drawCalls.triangles.toLocaleString()},scene:this.stats.scene}}},{key:"logSummary",value:function(){this.getSummary()}},{key:"reset",value:function(){var t=this;Object.keys(this.stats).forEach(function(e){t.stats[e].history&&(t.stats[e].history=[]),void 0!==t.stats[e].min&&(t.stats[e].min=1/0,t.stats[e].max=0,t.stats[e].average=0)}),this.frameCount=0}},{key:"exportData",value:function(){return{timestamp:(new Date).toISOString(),stats:JSON.parse(JSON.stringify(this.stats)),thresholds:this.thresholds,frameCount:this.frameCount}}}])}(),n=function(){return t(function t(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document.body,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"dark";i(this,t),this.monitor=e,this.container=s,this.element=null,this.isVisible=!1,this.updateInterval=null,this.theme=n},[{key:"show",value:function(){var t=this;this.cleanupExistingElements(),this.element&&this.hide(),this.element=document.createElement("div"),this.element.id="performance-monitor-ui",this.element.innerHTML=this.getHTML(),this.addStyles(),this.container.appendChild(this.element),this.isVisible=!0,this.startUpdating(),this.element.querySelector("#perf-toggle").addEventListener("click",function(){return t.toggleDetails()}),this.toggleDetails()}},{key:"cleanupExistingElements",value:function(){document.querySelectorAll("#performance-monitor-ui").forEach(function(t){try{t.parentNode&&t.parentNode.removeChild(t)}catch(t){}})}},{key:"hide",value:function(){this.stopUpdating(),this.removeDOMElement(),this.isVisible=!1}},{key:"dispose",value:function(){this.hide(),this.cleanupExistingElements(),this.monitor=null,this.container=null,this.element=null}},{key:"stopUpdating",value:function(){this.updateInterval&&(clearInterval(this.updateInterval),this.updateInterval=null)}},{key:"removeDOMElement",value:function(){if(this.element){try{this.element.parentNode&&this.container&&this.container.contains(this.element)?this.container.removeChild(this.element):this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch(t){try{this.element.remove&&this.element.remove()}catch(t){}}this.element=null}}},{key:"toggleDetails",value:function(){var t=this.element.querySelector("#perf-details"),e="none"===t.style.display;t.style.display=e?"block":"none",this.element.querySelector("#perf-toggle").textContent=e?"▼":"▲"}},{key:"startUpdating",value:function(){var t=this;this.updateInterval=setInterval(function(){t.isVisible&&t.element&&t.updateContent()},500)}},{key:"updateContent",value:function(){var t=this.monitor.getSummary();this.updateElement("#fps-value",t.fps.current),this.updateElement("#frametime-value",t.frameTime.current),this.updateElement("#memory-value",t.memory.heapUsed),this.updateElement("#drawcalls-value",t.drawCalls.current),this.updateElement("#fps-avg",t.fps.average),this.updateElement("#fps-min",t.fps.min),this.updateElement("#fps-max",t.fps.max),this.updateElement("#geometries-value",t.memory.geometries),this.updateElement("#textures-value",t.memory.textures),this.updateElement("#triangles-value",t.drawCalls.triangles),this.updateElement("#objects-value",t.scene.objects),this.updateElement("#meshes-value",t.scene.meshes),this.updatePerformanceIndicators(t)}},{key:"updateElement",value:function(t,e){var i=this.element.querySelector(t);i&&(i.textContent=e)}},{key:"updatePerformanceIndicators",value:function(t){var e=this.element.querySelector("#fps-value"),i=this.element.querySelector("#frametime-value");if(e){var s=t.fps.current;e.className=this.getPerformanceClass("fps",s)}if(i){var n=parseFloat(t.frameTime.current);i.className=this.getPerformanceClass("frameTime",n)}}},{key:"getPerformanceClass",value:function(t,e){var i=this.monitor.thresholds[t];return"fps"===t?e>=i.good?"perf-good":e>=i.warning?"perf-warning":"perf-critical":"frameTime"===t?e<=i.good?"perf-good":e<=i.warning?"perf-warning":"perf-critical":""}},{key:"getHTML",value:function(){return'\n <div class="perf-header">\n <span class="perf-title">Performance</span>\n <button id="perf-toggle">▼</button>\n </div>\n <div class="perf-main">\n <div class="perf-stat">\n <span class="perf-label">FPS:</span>\n <span id="fps-value" class="perf-value">0</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Frame:</span>\n <span id="frametime-value" class="perf-value">0ms</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Memory:</span>\n <span id="memory-value" class="perf-value">0MB</span>\n </div>\n <div class="perf-stat">\n <span class="perf-label">Calls:</span>\n <span id="drawcalls-value" class="perf-value">0</span>\n </div>\n </div>\n <div id="perf-details" class="perf-details">\n <div class="perf-section">\n <div class="perf-section-title">FPS Stats</div>\n <div class="perf-detail">Avg: <span id="fps-avg">0</span></div>\n <div class="perf-detail">Min: <span id="fps-min">0</span></div>\n <div class="perf-detail">Max: <span id="fps-max">0</span></div>\n </div>\n <div class="perf-section">\n <div class="perf-section-title">Memory</div>\n <div class="perf-detail">Geometries: <span id="geometries-value">0</span></div>\n <div class="perf-detail">Textures: <span id="textures-value">0</span></div>\n </div>\n <div class="perf-section">\n <div class="perf-section-title">Rendering</div>\n <div class="perf-detail">Triangles: <span id="triangles-value">0</span></div>\n <div class="perf-detail">Objects: <span id="objects-value">0</span></div>\n <div class="perf-detail">Meshes: <span id="meshes-value">0</span></div>\n </div>\n </div>\n '}},{key:"addStyles",value:function(){if(!document.getElementById("performance-monitor-styles")){var t=document.createElement("style");t.id="performance-monitor-styles";var e={dark:{background:"rgba(0, 0, 0, 0.8)",color:"white",borderColor:"rgba(255, 255, 255, 0.1)",separatorColor:"rgba(255, 255, 255, 0.2)",sectionTitleColor:"#FFC107",goodColor:"#4CAF50",warningColor:"#FF9800",criticalColor:"#F44336"},light:{background:"rgba(255, 255, 255, 0.95)",color:"#333333",borderColor:"rgba(0, 0, 0, 0.15)",separatorColor:"rgba(0, 0, 0, 0.1)",sectionTitleColor:"#1565C0",goodColor:"#2E7D32",warningColor:"#E65100",criticalColor:"#C62828"}},i=e[this.theme]||e.dark;t.textContent=" #performance-monitor-ui {\n position: fixed;\n bottom: 10px;\n right: 10px;\n background: ".concat(i.background,";\n color: ").concat(i.color,";\n font-family: 'Consolas', 'Monaco', 'Courier New', monospace;\n font-size: 12px;\n padding: 10px;\n border-radius: 5px;\n z-index: 10000;\n min-width: 150px;\n backdrop-filter: blur(5px);\n border: 1px solid ").concat(i.borderColor,";\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n }\n\n .perf-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 8px;\n border-bottom: 1px solid ").concat(i.separatorColor,";\n padding-bottom: 5px;\n }\n\n .perf-title {\n font-weight: bold;\n font-size: 14px;\n }\n\n #perf-toggle {\n background: none;\n border: none;\n color: ").concat(i.color,";\n cursor: pointer;\n font-size: 12px;\n padding: 0;\n width: 20px;\n height: 20px;\n }\n\n .perf-main {\n display: grid;\n grid-template-columns: 1fr;\n gap: 4px;\n }\n\n .perf-stat {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n\n .perf-label {\n opacity: 0.8;\n }\n\n .perf-value {\n font-weight: bold;\n text-align: right;\n min-width: 50px;\n } .perf-good {\n color: ").concat(i.goodColor,";\n }\n\n .perf-warning {\n color: ").concat(i.warningColor,";\n }\n\n .perf-critical {\n color: ").concat(i.criticalColor,";\n }\n\n .perf-details {\n margin-top: 10px;\n padding-top: 8px;\n border-top: 1px solid ").concat(i.separatorColor,";\n }\n\n .perf-section {\n margin-bottom: 8px;\n }\n\n .perf-section-title {\n font-weight: bold;\n font-size: 11px;\n margin-bottom: 3px;\n color: ").concat(i.sectionTitleColor,";\n }\n\n .perf-detail {\n font-size: 10px;\n display: flex;\n justify-content: space-between;\n margin-bottom: 2px;\n opacity: 0.9;\n }\n "),document.head.appendChild(t)}}},{key:"setTheme",value:function(t){if("light"===t||"dark"===t){this.theme=t;var e=document.getElementById("performance-monitor-styles");e&&e.remove(),this.addStyles()}}}],[{key:"cleanupAllInstances",value:function(){var t=document.querySelectorAll("#performance-monitor-ui"),e=0;if(t.forEach(function(t){try{t.parentNode&&(t.parentNode.removeChild(t),e++)}catch(t){}}),0===document.querySelectorAll("#performance-monitor-ui").length){var i=document.getElementById("performance-monitor-styles");i&&i.remove()}return e}}])}();export{s as PerformanceMonitor,n as PerformanceUI};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,classCallCheck as e,asyncToGenerator as i,regenerator as n,typeof as r}from"../../_virtual/_rollupPluginBabelHelpers.js";import"three";import{GLTFLoader as s}from"../../node_modules/three/examples/jsm/loaders/GLTFLoader.js";var o=function(){return t(function t(){e(this,t),this.modelCache=new Map,this.loadingPromises=new Map,this.gltfLoader=new s,this.isPreloading=!1,this.preloadingPromise=null,this.componentDictionary=null},[{key:"preloadAllModels",value:(a=i(n().m(function t(e){var i,s,o=this;return n().w(function(t){for(;;)switch(t.n){case 0:if(!this.isPreloading){t.n=1;break}return t.a(2,this.preloadingPromise);case 1:if(e&&"object"===r(e)){t.n=2;break}return t.a(2,Promise.reject(new Error("Invalid component dictionary")));case 2:return this.componentDictionary=e,this.isPreloading=!0,i=[],s=[],Object.keys(e).forEach(function(t){var n=e[t];n&&n.modelKey&&(i.includes(n.modelKey)||i.push(n.modelKey))}),i.forEach(function(t){s.push(o.preloadSingleModel(t))}),this.preloadingPromise=Promise.allSettled(s).then(function(t){var e=t.filter(function(t){return"fulfilled"===t.status}).length,n=t.filter(function(t){return"rejected"===t.status}).length;return o.isPreloading=!1,{successful:e,failed:n,total:i.length,cache:o.modelCache}}),t.a(2,this.preloadingPromise)}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"preloadSingleModel",value:(u=i(n().m(function t(e){var i,r=this;return n().w(function(t){for(;;)switch(t.n){case 0:if(!this.modelCache.has(e)){t.n=1;break}return t.a(2,this.modelCache.get(e));case 1:if(!this.loadingPromises.has(e)){t.n=2;break}return t.a(2,this.loadingPromises.get(e));case 2:return i=new Promise(function(t,i){r.gltfLoader.load("/library/models/".concat(e),function(i){r.modelCache.set(e,i.scene),r.loadingPromises.delete(e),t(i.scene)},function(t){t.loaded,t.total},function(t){r.loadingPromises.delete(e),i(t)})}),this.loadingPromises.set(e,i),t.a(2,i)}},t,this)})),function(t){return u.apply(this,arguments)})},{key:"getCachedModel",value:function(t){return this.modelCache.has(t)?this.modelCache.get(t).clone():null}},{key:"getCachedModelWithDimensions",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.modelCache.has(t)){var i=this.modelCache.get(t).clone();if(e&&this.componentDictionary){var n=this.componentDictionary[e];n&&n.boundingBox&&(i.userData||(i.userData={}),i.userData.dimensions={x:n.boundingBox.x,y:n.boundingBox.y,z:n.boundingBox.z})}return i}return null}},{key:"addDimensionsToModel",value:function(t,e){if(!t||!e)return t;if(this.componentDictionary){var i=this.componentDictionary[e];i&&i.boundingBox&&(t.userData||(t.userData={}),t.userData.dimensions={x:i.boundingBox.x,y:i.boundingBox.y,z:i.boundingBox.z})}return t}},{key:"getStatus",value:function(){return{isPreloading:this.isPreloading,cachedModels:Array.from(this.modelCache.keys()),totalCached:this.modelCache.size,currentlyLoading:Array.from(this.loadingPromises.keys())}}},{key:"reloadModel",value:(o=i(n().m(function t(e){return n().w(function(t){for(;;)if(0===t.n)return this.modelCache.delete(e),this.loadingPromises.delete(e),t.a(2,this.preloadSingleModel(e))},t,this)})),function(t){return o.apply(this,arguments)})},{key:"clearCache",value:function(){this.modelCache.forEach(function(t,e){t&&t.traverse&&t.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){return t.dispose()}):t.material.dispose())})}),this.modelCache.clear(),this.loadingPromises.clear(),this.isPreloading=!1,this.preloadingPromise=null}},{key:"getCacheStats",value:function(){var t={totalModels:this.modelCache.size,loadingModels:this.loadingPromises.size,isPreloading:this.isPreloading,memoryUsage:0};return this.modelCache.forEach(function(e){e&&e.traverse&&e.traverse(function(e){var i;e.geometry&&(t.memoryUsage+=12*((null===(i=e.geometry.attributes.position)||void 0===i?void 0:i.count)||0))})}),t}}]);var o,u,a}(),u=new o;export{o as ModelPreloader,u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as t,classCallCheck as i,defineProperty as n}from"../../_virtual/_rollupPluginBabelHelpers.js";var r=function(){return t(function t(r){var e=this;i(this,t),n(this,"draw",{line:function(t,i,n,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e.ctx&&(e.save(),e.setStyles(s),e.ctx.beginPath(),e.ctx.moveTo(t,i),e.ctx.lineTo(n,r),e.ctx.stroke(),e.restore())},rect:function(t,i,n,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e.ctx&&(e.save(),e.setStyles(s),s.fillStyle&&e.ctx.fillRect(t,i,n,r),s.strokeStyle&&e.ctx.strokeRect(t,i,n,r),e.restore())},circle:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e.ctx&&(e.save(),e.setStyles(r),e.ctx.beginPath(),e.ctx.arc(t,i,n,0,2*Math.PI),r.fillStyle&&e.ctx.fill(),r.strokeStyle&&e.ctx.stroke(),e.restore())},ellipse:function(t,i,n,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};e.ctx&&(e.save(),e.setStyles(o),e.ctx.beginPath(),e.ctx.ellipse(t,i,n,r,s,0,2*Math.PI),o.fillStyle&&e.ctx.fill(),o.strokeStyle&&e.ctx.stroke(),e.restore())},polygon:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.ctx&&!(t.length<3)){e.save(),e.setStyles(i),e.ctx.beginPath(),e.ctx.moveTo(t[0][0],t[0][1]);for(var n=1;n<t.length;n++)e.ctx.lineTo(t[n][0],t[n][1]);e.ctx.closePath(),i.fillStyle&&e.ctx.fill(),i.strokeStyle&&e.ctx.stroke(),e.restore()}},bezierCurve:function(t,i,n,r,s,o,u,a){var l=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{};e.ctx&&(e.save(),e.setStyles(l),e.ctx.beginPath(),e.ctx.moveTo(t,i),e.ctx.bezierCurveTo(n,r,s,o,u,a),e.ctx.stroke(),e.restore())},text:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e.ctx&&(e.save(),e.setStyles(r),r.fillStyle&&e.ctx.fillText(t,i,n),r.strokeStyle&&e.ctx.strokeText(t,i,n),e.restore())},image:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;e.ctx&&t&&(r&&s?e.ctx.drawImage(t,i,n,r,s):e.ctx.drawImage(t,i,n))}}),n(this,"transform",{translate:function(t,i){e.ctx&&e.ctx.translate(t,i)},rotate:function(t){e.ctx&&e.ctx.rotate(t)},scale:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;e.ctx&&e.ctx.scale(t,i)},transform:function(t,i,n,r,s,o){e.ctx&&e.ctx.transform(t,i,n,r,s,o)},setTransform:function(t,i,n,r,s,o){e.ctx&&e.ctx.setTransform(t,i,n,r,s,o)},resetTransform:function(){e.ctx&&e.ctx.resetTransform()}}),n(this,"gradient",{linear:function(t,i,n,r,s){if(!e.ctx)return null;var o=e.ctx.createLinearGradient(t,i,n,r);return s.forEach(function(t){o.addColorStop(t.offset,t.color)}),o},radial:function(t,i,n,r,s,o,u){if(!e.ctx)return null;var a=e.ctx.createRadialGradient(t,i,n,r,s,o);return u.forEach(function(t){a.addColorStop(t.offset,t.color)}),a}}),n(this,"pattern",{fromImage:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return e.ctx&&t?e.ctx.createPattern(t,i):null},fromCanvas:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return e.ctx&&t?e.ctx.createPattern(t,i):null}}),n(this,"path",{begin:function(){e.ctx&&e.ctx.beginPath()},close:function(){e.ctx&&e.ctx.closePath()},moveTo:function(t,i){e.ctx&&e.ctx.moveTo(t,i)},lineTo:function(t,i){e.ctx&&e.ctx.lineTo(t,i)},arc:function(t,i,n,r,s){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];e.ctx&&e.ctx.arc(t,i,n,r,s,o)},quadraticCurveTo:function(t,i,n,r){e.ctx&&e.ctx.quadraticCurveTo(t,i,n,r)},bezierCurveTo:function(t,i,n,r,s,o){e.ctx&&e.ctx.bezierCurveTo(t,i,n,r,s,o)},fill:function(){e.ctx&&e.ctx.fill()},stroke:function(){e.ctx&&e.ctx.stroke()},clip:function(){e.ctx&&e.ctx.clip()}}),n(this,"measure",{textWidth:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.ctx)return 0;if(i){var n=e.ctx.font;e.ctx.font=i;var r=e.ctx.measureText(t).width;return e.ctx.font=n,r}return e.ctx.measureText(t).width},textMetrics:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.ctx)return null;if(i){var n=e.ctx.font;e.ctx.font=i;var r=e.ctx.measureText(t);return e.ctx.font=n,r}return e.ctx.measureText(t)}}),n(this,"export",{toDataURL:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return e.canvas?e.canvas.toDataURL(t,i):""},toBlob:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return e.canvas?new Promise(function(n){e.canvas.toBlob(n,t,i)}):Promise.resolve(null)}}),this.canvas=r,this.ctx=null==r?void 0:r.getContext("2d"),this.width=(null==r?void 0:r.width)||800,this.height=(null==r?void 0:r.height)||600,this.pixelRatio=window.devicePixelRatio||1,this.state={transforms:[],styles:[]},this.setupCanvas()},[{key:"setupCanvas",value:function(){this.canvas&&this.ctx&&(this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio,this.ctx.scale(this.pixelRatio,this.pixelRatio),this.canvas.style.width=this.width+"px",this.canvas.style.height=this.height+"px")}},{key:"clear",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.ctx&&(t?(this.ctx.fillStyle=t,this.ctx.fillRect(0,0,this.width,this.height)):this.ctx.clearRect(0,0,this.width,this.height))}},{key:"save",value:function(){this.ctx&&(this.ctx.save(),this.state.transforms.push(this.ctx.getTransform()),this.state.styles.push({fillStyle:this.ctx.fillStyle,strokeStyle:this.ctx.strokeStyle,lineWidth:this.ctx.lineWidth,font:this.ctx.font,textAlign:this.ctx.textAlign,textBaseline:this.ctx.textBaseline}))}},{key:"restore",value:function(){this.ctx&&(this.ctx.restore(),this.state.transforms.pop(),this.state.styles.pop())}},{key:"setStyles",value:function(t){var i=this;this.ctx&&Object.keys(t).forEach(function(n){void 0!==i.ctx[n]&&(i.ctx[n]=t[n])})}},{key:"resize",value:function(t,i){this.width=t,this.height=i,this.setupCanvas()}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height,pixelRatio:this.pixelRatio}}},{key:"dispose",value:function(){this.state.transforms=[],this.state.styles=[],this.canvas=null,this.ctx=null}}])}();export{r as Rendering2D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createClass as i,toConsumableArray as t,objectSpread2 as e,classCallCheck as n,defineProperty as o}from"../../_virtual/_rollupPluginBabelHelpers.js";import*as r from"three";import{logger as s}from"../core/debugLogger.js";var a=function(){return i(function i(){var s=this,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,i),o(this,"lighting",{addAmbient:function(){var i,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4210752,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,n=new r.AmbientLight(t,e);return null===(i=s.scene)||void 0===i||i.add(n),n},addDirectional:function(){var i,e,n,o,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},d=a.color,v=void 0===d?16777215:d,h=a.intensity,l=void 0===h?1:h,u=a.position,c=void 0===u?[10,10,5]:u,f=a.target,p=void 0===f?[0,0,0]:f,m=a.castShadow,w=void 0===m||m,g=a.shadowMapSize,y=void 0===g?2048:g,S=a.shadowCameraNear,M=void 0===S?.5:S,x=a.shadowCameraFar,k=void 0===x?50:x,C=a.shadowCameraLeft,P=void 0===C?-10:C,D=a.shadowCameraRight,b=void 0===D?10:D,R=a.shadowCameraTop,_=void 0===R?10:R,B=a.shadowCameraBottom,j=void 0===B?-10:B,z=new r.DirectionalLight(v,l);return(i=z.position).set.apply(i,t(c)),(e=z.target.position).set.apply(e,t(p)),w&&(z.castShadow=!0,z.shadow.mapSize.width=y,z.shadow.mapSize.height=y,z.shadow.camera.near=M,z.shadow.camera.far=k,z.shadow.camera.left=P,z.shadow.camera.right=b,z.shadow.camera.top=_,z.shadow.camera.bottom=j),null===(n=s.scene)||void 0===n||n.add(z),null===(o=s.scene)||void 0===o||o.add(z.target),z},addPoint:function(){var i,e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=n.color,a=void 0===o?16777215:o,d=n.intensity,v=void 0===d?1:d,h=n.distance,l=void 0===h?0:h,u=n.decay,c=void 0===u?2:u,f=n.position,p=void 0===f?[0,10,0]:f,m=n.castShadow,w=void 0!==m&&m,g=n.shadowMapSize,y=void 0===g?1024:g,S=new r.PointLight(a,v,l,c);return(i=S.position).set.apply(i,t(p)),w&&(S.castShadow=!0,S.shadow.mapSize.width=y,S.shadow.mapSize.height=y,S.shadow.camera.near=.1,S.shadow.camera.far=25),null===(e=s.scene)||void 0===e||e.add(S),S},addSpot:function(){var i,e,n,o,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},d=a.color,v=void 0===d?16777215:d,h=a.intensity,l=void 0===h?1:h,u=a.distance,c=void 0===u?0:u,f=a.angle,p=void 0===f?Math.PI/3:f,m=a.penumbra,w=void 0===m?0:m,g=a.decay,y=void 0===g?2:g,S=a.position,M=void 0===S?[0,10,0]:S,x=a.target,k=void 0===x?[0,0,0]:x,C=a.castShadow,P=void 0===C||C,D=a.shadowMapSize,b=void 0===D?1024:D,R=new r.SpotLight(v,l,c,p,w,y);return(i=R.position).set.apply(i,t(M)),(e=R.target.position).set.apply(e,t(k)),P&&(R.castShadow=!0,R.shadow.mapSize.width=b,R.shadow.mapSize.height=b,R.shadow.camera.near=.5,R.shadow.camera.far=50),null===(n=s.scene)||void 0===n||n.add(R),null===(o=s.scene)||void 0===o||o.add(R.target),R}}),o(this,"materials",{createStandard:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.MeshStandardMaterial(e({color:16777215,metalness:0,roughness:.5},i))},createPhysical:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.MeshPhysicalMaterial(e({color:16777215,metalness:0,roughness:.5,clearcoat:0,clearcoatRoughness:0},i))},createBasic:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.MeshBasicMaterial(e({color:16777215},i))},createShader:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new r.ShaderMaterial({vertexShader:i.vertexShader||"\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:i.fragmentShader||"\n void main() {\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n }\n ",uniforms:i.uniforms||{}})}}),o(this,"geometry",{createBox:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new r.BoxGeometry(i,t,e)},createSphere:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16;return new r.SphereGeometry(i,t,e)},createCylinder:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;return new r.CylinderGeometry(i,t,e,n)},createPlane:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return new r.PlaneGeometry(i,t)}}),o(this,"renderTargets",{create:function(i,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=new r.WebGLRenderTarget(i,t,e({minFilter:r.LinearFilter,magFilter:r.LinearFilter,format:r.RGBAFormat,type:r.UnsignedByteType},n)),a="rt_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9));return s.renderTargets.set(a,o),{id:a,renderTarget:o}},get:function(i){return s.renderTargets.get(i)},remove:function(i){var t=s.renderTargets.get(i);t&&(t.dispose(),s.renderTargets.delete(i))}}),o(this,"animation",{createMixer:function(i){return s.animationMixer=new r.AnimationMixer(i),s.animationMixer},addClip:function(i){if(!s.animationMixer)throw new Error("Animation mixer not created");return s.animationMixer.clipAction(i)},update:function(i){s.animationMixer&&s.animationMixer.update(i)}}),o(this,"screenshot",{toDataURL:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return s.renderer?s.renderer.domElement.toDataURL(i,t):""},toBlob:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return s.renderer?new Promise(function(e){s.renderer.domElement.toBlob(e,i,t)}):Promise.resolve(null)}}),this.options=e({antialias:!0,alpha:!0,shadowMapEnabled:!0,shadowMapType:r.PCFSoftShadowMap,toneMapping:r.ACESFilmicToneMapping,toneMappingExposure:1,outputColorSpace:r.SRGBColorSpace},a),this.renderer=null,this.scene=null,this.camera=null,this.controls=null,this.renderTargets=new Map,this.postProcessing={composer:null,passes:[]},this.stats={triangles:0,geometries:0,textures:0,calls:0,frameTime:0},this.animationMixer=null,this.clock=new r.Clock},[{key:"initializeRenderer",value:function(i){this.renderer&&this.dispose();try{return this.renderer=new r.WebGLRenderer({antialias:this.options.antialias,alpha:this.options.alpha,preserveDrawingBuffer:!1,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(i.clientWidth,i.clientHeight),this.renderer.setClearColor(0,0),this.options.shadowMapEnabled&&(this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=this.options.shadowMapType),this.renderer.toneMapping=this.options.toneMapping,this.renderer.toneMappingExposure=this.options.toneMappingExposure,this.renderer.outputColorSpace=this.options.outputColorSpace,this.renderer.useLegacyLights=!1,i.appendChild(this.renderer.domElement),s.info("✅ 3D Renderer initialized"),this.renderer}catch(i){throw s.error("❌ Failed to initialize 3D renderer:",i),i}}},{key:"createScene",value:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=i.background,e=void 0===t?null:t,n=i.environment,o=void 0===n?null:n,a=i.fog,d=void 0===a?null:a;return this.scene=new r.Scene,e&&("string"==typeof e?this.scene.background=new r.Color(e):e.isTexture&&(this.scene.background=e)),o&&o.isTexture&&(this.scene.environment=o),d&&("linear"===d.type?this.scene.fog=new r.Fog(d.color,d.near,d.far):"exponential"===d.type&&(this.scene.fog=new r.FogExp2(d.color,d.density))),s.info("✅ 3D Scene created"),this.scene}},{key:"createCamera",value:function(){var i,e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"perspective",o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null===(i=this.renderer)||void 0===i||null===(i=i.domElement)||void 0===i?void 0:i.parentElement,d=a?a.clientWidth/a.clientHeight:1;if("perspective"===n){var v=o.fov,h=void 0===v?75:v,l=o.near,u=void 0===l?.1:l,c=o.far,f=void 0===c?1e3:c;o.position,this.camera=new r.PerspectiveCamera(h,d,u,f)}else if("orthographic"===n){var p=o.left,m=void 0===p?-10:p,w=o.right,g=void 0===w?10:w,y=o.top,S=void 0===y?10:y,M=o.bottom,x=void 0===M?-10:M,k=o.near,C=void 0===k?.1:k,P=o.far,D=void 0===P?1e3:P;o.position,this.camera=new r.OrthographicCamera(m,g,S,x,C,D)}this.camera&&((e=this.camera.position).set.apply(e,t(position)),s.info("✅ ".concat(n," camera created")));return this.camera}},{key:"render",value:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.renderer){var n=i||this.scene,o=t||this.camera;if(n&&o){var r=performance.now(),s=this.clock.getDelta();this.animation.update(s),this.renderer.render(n,o,e),this.stats.frameTime=performance.now()-r,this.updateRenderStats()}}}},{key:"updateRenderStats",value:function(){if(this.renderer){var i=this.renderer.info;this.stats.triangles=i.render.triangles,this.stats.geometries=i.memory.geometries,this.stats.textures=i.memory.textures,this.stats.calls=i.render.calls}}},{key:"getRenderStats",value:function(){return e({},this.stats)}},{key:"resize",value:function(i,t){if(this.renderer){if(this.renderer.setSize(i,t),this.camera){if(this.camera.isPerspectiveCamera)this.camera.aspect=i/t;else if(this.camera.isOrthographicCamera){var e=i/t;this.camera.left=-10*e,this.camera.right=10*e,this.camera.top=10,this.camera.bottom=-10}this.camera.updateProjectionMatrix()}this.renderTargets.forEach(function(e){e.setSize(i,t)})}}},{key:"dispose",value:function(){this.renderTargets.forEach(function(i){i.dispose()}),this.renderTargets.clear(),this.animationMixer&&(this.animationMixer.stopAllAction(),this.animationMixer=null),this.renderer&&(this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer=null),this.scene=null,this.camera=null,this.controls=null,s.info("✅ 3D Rendering disposed")}}])}();export{a as Rendering3D};
|