@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"t",{value:!0});var t,i,s=require("../_virtual/_rollupPluginBabelHelpers.js");function e(t){if(t&&t.t)return t;var i=Object.create(null);return t&&Object.keys(t).forEach(function(s){if("default"!==s){var e=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(i,s,e.get?e:{enumerable:!0,get:function(){return t[s]}})}}),i.default=t,Object.freeze(i)}function n(){return h.apply(this,arguments)}function h(){return(h=s.asyncToGenerator(s.regenerator().m(function n(){var h,r;return s.regenerator().w(function(s){for(;;)switch(s.n){case 0:if("undefined"==typeof window){s.n=9;break}return s.p=1,s.n=2,Promise.resolve().then(function(){return e(require("three"))});case 2:return t=s.v,s.p=3,s.n=4,Promise.resolve().then(function(){return require("../node_modules/three/examples/jsm/controls/TransformControls.js")});case 4:h=s.v,i=h.TransformControls,s.n=7;break;case 5:if(s.p=5,s.v,"string"!=typeof window.__transformControlsCustomPath){s.n=7;break}return s.n=6,function(t){return Promise.resolve().then(function(){return e(require(t))})}(window.__transformControlsCustomPath);case 6:r=s.v,i=r.TransformControls;case 7:s.n=9;break;case 8:throw s.p=8,s.v,new Error("TransformControlsManager: Required dependencies could not be loaded");case 9:return s.a(2)}},n,null,[[3,5],[1,8]])}))).apply(this,arguments)}var r=function(){return s.createClass(function t(i,e,h){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;s.classCallCheck(this,t),this.scene=i,this.camera=e,this.renderer=h,this.orbitControls=o,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,pointerdown:null,pointerup:null,transformStart:null,transformEnd:null,transforming:null},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},"undefined"!=typeof window&&n().then(function(){return r.init()})},[{key:"init",value:(e=s.asyncToGenerator(s.regenerator().m(function i(){return s.regenerator().w(function(i){for(;;)switch(i.n){case 0:if("undefined"==typeof window||t){i.n=1;break}return i.n=1,n();case 1:this.createTransformControls(),this.setupEventListeners(),this.setupKeyboardControls();case 2:return i.a(2)}},i,this)})),function(){return e.apply(this,arguments)})},{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)}},{key:"createTransformControls",value:function(){t&&i&&(this.transformControls||(this.transformControls=new i(this.camera,this.renderer.domElement),this.transformControls.size=this.config.size,this.transformControls.enabled=this.config.enabled,this.transformControls.visible=this.config.enabled&&!this.forceInvisible,this.transformControls.setMode(this.currentMode),this.transformControls.setSpace(this.currentSpace),this.transformControls.userData={isTransformControls:!0},this.scene.add(this.transformControls)))}},{key:"setupEventListeners",value:function(){var t=this;this.transformControls&&(this.removeEventListeners(),this.eventHandlers.transformStart=function(i){t.transformState.isTransforming=!0,t.selectedObject&&(t.transformState.initialTransform=t.captureObjectTransform(t.selectedObject),t.callbacks.onTransformStart&&t.callbacks.onTransformStart(t.selectedObject,t.transformState.initialTransform))},this.eventHandlers.transforming=function(i){t.selectedObject&&t.transformState.isTransforming&&(t.transformState.currentTransform=t.captureObjectTransform(t.selectedObject),t.callbacks.onTransform&&t.callbacks.onTransform(t.selectedObject,t.transformState.currentTransform,t.transformState.initialTransform),t.updateBoundingBox())},this.eventHandlers.transformEnd=function(i){if(t.selectedObject){var s=t.captureObjectTransform(t.selectedObject);t.callbacks.onTransformEnd&&t.callbacks.onTransformEnd(t.selectedObject,s,t.transformState.initialTransform)}t.transformState.isTransforming=!1},this.transformControls.addEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.addEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.addEventListener("mouseUp",this.eventHandlers.transformEnd),this.orbitControls&&this.transformControls.addEventListener("dragging-changed",function(i){t.orbitControls.enabled=!i.value}))}},{key:"setupKeyboardControls",value:function(){var t=this;"undefined"!=typeof window&&"undefined"!=typeof document&&(this.eventHandlers.keydown&&document.removeEventListener("keydown",this.eventHandlers.keydown),this.eventHandlers.keydown=function(i){if(t.config.enabled&&t.selectedObject)switch(i.key.toLowerCase()){case"g":t.setMode("translate");break;case"r":t.setMode("rotate");break;case"s":t.setMode("scale");break;case" ":t.toggleVisibility();break;case"escape":t.deselectObject();break;case"x":i.shiftKey?(t.config.showX=!t.config.showX,t.updateAxisVisibility()):(t.transformControls.showX=!0,t.transformControls.showY=!1,t.transformControls.showZ=!1);break;case"y":i.shiftKey?(t.config.showY=!t.config.showY,t.updateAxisVisibility()):(t.transformControls.showX=!1,t.transformControls.showY=!0,t.transformControls.showZ=!1);break;case"z":i.shiftKey?(t.config.showZ=!t.config.showZ,t.updateAxisVisibility()):(t.transformControls.showX=!1,t.transformControls.showY=!1,t.transformControls.showZ=!0);break;case"q":t.toggleSpace()}},document.addEventListener("keydown",this.eventHandlers.keydown))}},{key:"removeEventListeners",value:function(){this.transformControls&&(this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd)),"undefined"!=typeof document&&this.eventHandlers.keydown&&document.removeEventListener("keydown",this.eventHandlers.keydown)}},{key:"selectObject",value:function(t){if(this.config.enabled&&this.transformControls&&t)return this.deselectObject(),this.selectedObject=t,this.transformControls.attach(t),this.config.showBoundingBox&&this.showBoundingBox(t),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(t,!0),this.forceInvisible||(this.transformControls.visible=!0),t}},{key:"deselectObject",value:function(){if(this.selectedObject){this.transformControls&&this.transformControls.detach(),this.hideBoundingBox(),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(this.selectedObject,!1);var t=this.selectedObject;return this.selectedObject=null,this.ensureSceneAttachment(!1),t}return null}},{key:"setMode",value:function(t){if(this.transformControls&&["translate","rotate","scale"].includes(t)){switch(this.currentMode=t,this.transformControls.setMode(t),t){case"translate":this.transformControls.setTranslationSnap(this.config.translationSnap);break;case"rotate":this.transformControls.setRotationSnap(this.config.rotationSnap);break;case"scale":this.transformControls.setScaleSnap(this.config.scaleSnap)}this.callbacks.onModeChange&&this.callbacks.onModeChange(t)}}},{key:"toggleSpace",value:function(){this.transformControls&&(this.currentSpace="world"===this.currentSpace?"local":"world",this.transformControls.setSpace(this.currentSpace))}},{key:"toggleVisibility",value:function(){this.transformControls&&(this.forceInvisible||(this.transformControls.visible=!this.transformControls.visible))}},{key:"setEnabled",value:function(t){this.config.enabled=t,this.transformControls&&(this.transformControls.enabled=t,t?this.selectedObject&&!this.forceInvisible&&(this.transformControls.visible=!0):(this.deselectObject(),this.transformControls.visible=!1))}},{key:"updateAxisVisibility",value:function(){this.transformControls&&(this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ)}},{key:"showBoundingBox",value:function(i){if(i&&t){this.hideBoundingBox();var s=this.boundingBoxCache.get(i);s||(s=(new t.Box3).setFromObject(i),this.boundingBoxCache.set(i,s)),this.boundingBoxHelper?this.boundingBoxHelper.box=s:(this.boundingBoxHelper=new t.Box3Helper(s,this.config.boundingBoxColor),this.scene.add(this.boundingBoxHelper)),i.userData.worldBoundingBox=s}}},{key:"hideBoundingBox",value:function(){this.boundingBoxHelper&&(this.scene.remove(this.boundingBoxHelper),this.boundingBoxHelper=null)}},{key:"updateBoundingBox",value:function(){if(this.selectedObject&&this.config.showBoundingBox){var i=(new t.Box3).setFromObject(this.selectedObject);this.boundingBoxCache.set(this.selectedObject,i),this.boundingBoxHelper&&(this.boundingBoxHelper.box=i),this.selectedObject.userData.worldBoundingBox=i}}},{key:"captureObjectTransform",value:function(t){return t?{position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z}}:null}},{key:"setSnapValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.transformControls){if(void 0!==t.translation&&(this.config.translationSnap=t.translation,"translate"===this.currentMode&&this.transformControls.setTranslationSnap(t.translation)),void 0!==t.rotation){var i=t.rotation*(Math.PI/180);this.config.rotationSnap=i,"rotate"===this.currentMode&&this.transformControls.setRotationSnap(i)}void 0!==t.scale&&(this.config.scaleSnap=t.scale,"scale"===this.currentMode&&this.transformControls.setScaleSnap(t.scale))}}},{key:"setSize",value:function(t){this.config.size=t,this.transformControls&&(this.transformControls.size=t)}},{key:"dispose",value:function(){this.removeEventListeners(),this.hideBoundingBox(),this.transformControls&&(this.transformControls.detach(),this.scene.remove(this.transformControls),this.transformControls=null),this.selectedObject=null,this.boundingBoxCache=new WeakMap}},{key:"ensureSceneAttachment",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return!(!this.transformControls||!this.scene)&&(!this.scene.children.includes(this.transformControls)&&(this.scene.add(this.transformControls),this.transformControls.visible=t&&!this.forceInvisible&&this.config.enabled,!0))}},{key:"getTransformData",value:function(){if(!this.selectedObject)return null;var i=new t.Vector3;this.selectedObject.getWorldPosition(i);var s=new t.Quaternion;this.selectedObject.getWorldQuaternion(s);var e=(new t.Euler).setFromQuaternion(s),n=new t.Vector3;return this.selectedObject.getWorldScale(n),{uuid:this.selectedObject.uuid,position:{x:this.selectedObject.position.x,y:this.selectedObject.position.y,z:this.selectedObject.position.z},rotation:{x:this.selectedObject.rotation.x,y:this.selectedObject.rotation.y,z:this.selectedObject.rotation.z},scale:{x:this.selectedObject.scale.x,y:this.selectedObject.scale.y,z:this.selectedObject.scale.z},worldPosition:{x:i.x,y:i.y,z:i.z},worldRotation:{x:e.x,y:e.y,z:e.z},worldScale:{x:n.x,y:n.y,z:n.z}}}}]);var e}();exports.TransformControlsManager=r,exports.default=r,exports.getTransformControlsManager=function(t,i,s,e){return new r(t,i,s,e)};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Raycaster as t,Vector3 as s,Quaternion as h,Object3D as i,Euler as e,Matrix4 as n,MeshBasicMaterial as a,LineBasicMaterial as o,CylinderGeometry as w,BoxGeometry as l,BufferGeometry as r,Float32BufferAttribute as c,Mesh as u,OctahedronGeometry as M,Line as p,SphereGeometry as X,TorusGeometry as Y,PlaneGeometry as Z,DoubleSide as d}from"three";const f=new t,m=new s,E=new s,v=new h,S={X:new s(1,0,0),Y:new s(0,1,0),Z:new s(0,0,1)},b={type:"change"},g={type:"mouseDown"},x={type:"mouseUp",mode:null},T={type:"objectChange"};class y extends i{constructor(t,i){super(),void 0===i&&(i=document),this.isTransformControls=!0,this.visible=!1,this.domElement=i,this.domElement.style.touchAction="none";const e=new J;this.t=e,this.add(e);const n=new K;this.h=n,this.add(n);const a=this;function o(t,s){let h=s;Object.defineProperty(a,t,{get:function(){return void 0!==h?h:s},set:function(s){h!==s&&(h=s,n[t]=s,e[t]=s,a.dispatchEvent({type:t+"-changed",value:s}),a.dispatchEvent(b))}}),a[t]=s,n[t]=s,e[t]=s}o("camera",t),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0);const w=new s,l=new s,r=new h,c=new h,u=new s,M=new h,p=new s,X=new s,Y=new s,Z=new s;o("worldPosition",w),o("worldPositionStart",l),o("worldQuaternion",r),o("worldQuaternionStart",c),o("cameraPosition",u),o("cameraQuaternion",M),o("pointStart",p),o("pointEnd",X),o("rotationAxis",Y),o("rotationAngle",0),o("eye",Z),this.i=new s,this.o=new s,this.l=new s,this.u=new s,this.M=new s,this.p=new h,this.m=new h,this.v=new s,this.S=new s,this.T=new h,this.A=new s,this.k=new s,this.D=new h,this.W=new s,this.P=A.bind(this),this.R=D.bind(this),this.j=k.bind(this),this.C=W.bind(this),this.I=P.bind(this),this.domElement.addEventListener("pointerdown",this.R),this.domElement.addEventListener("pointermove",this.j),this.domElement.addEventListener("pointerup",this.I)}updateMatrixWorld(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent||this.object.parent.matrixWorld.decompose(this.M,this.p,this.v),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.A),this.m.copy(this.p).invert(),this.T.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(),super.updateMatrixWorld(this)}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;f.setFromCamera(t,this.camera);const s=R(this.t.picker[this.mode],f);this.axis=s?s.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&0===t.button&&null!==this.axis){f.setFromCamera(t,this.camera);const s=R(this.h,f,!0);s&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this.k.copy(this.object.position),this.D.copy(this.object.quaternion),this.W.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.S),this.pointStart.copy(s.point).sub(this.worldPositionStart)),this.dragging=!0,g.mode=this.mode,this.dispatchEvent(g)}}pointerMove(t){const s=this.axis,h=this.mode,i=this.object;let e=this.space;if("scale"===h?e="local":"E"!==s&&"XYZE"!==s&&"XYZ"!==s||(e="world"),void 0===i||null===s||!1===this.dragging||-1!==t.button)return;f.setFromCamera(t,this.camera);const n=R(this.h,f,!0);if(n){if(this.pointEnd.copy(n.point).sub(this.worldPositionStart),"translate"===h)this.i.copy(this.pointEnd).sub(this.pointStart),"local"===e&&"XYZ"!==s&&this.i.applyQuaternion(this.T),-1===s.indexOf("X")&&(this.i.x=0),-1===s.indexOf("Y")&&(this.i.y=0),-1===s.indexOf("Z")&&(this.i.z=0),"local"===e&&"XYZ"!==s?this.i.applyQuaternion(this.D).divide(this.v):this.i.applyQuaternion(this.m).divide(this.v),i.position.copy(this.i).add(this.k),this.translationSnap&&("local"===e&&(i.position.applyQuaternion(v.copy(this.D).invert()),-1!==s.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==s.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==s.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this.D)),"world"===e&&(i.parent&&i.position.add(m.setFromMatrixPosition(i.parent.matrixWorld)),-1!==s.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==s.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==s.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(m.setFromMatrixPosition(i.parent.matrixWorld))));else if("scale"===h){if(-1!==s.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),E.set(t,t,t)}else m.copy(this.pointStart),E.copy(this.pointEnd),m.applyQuaternion(this.T),E.applyQuaternion(this.T),E.divide(m),-1===s.search("X")&&(E.x=1),-1===s.search("Y")&&(E.y=1),-1===s.search("Z")&&(E.z=1);i.scale.copy(this.W).multiply(E),this.scaleSnap&&(-1!==s.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==s.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==s.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===h){this.i.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(m.setFromMatrixPosition(this.camera.matrixWorld));"E"===s?(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"===s?(this.rotationAxis.copy(this.i).cross(this.eye).normalize(),this.rotationAngle=this.i.dot(m.copy(this.rotationAxis).cross(this.eye))*t):"X"!==s&&"Y"!==s&&"Z"!==s||(this.rotationAxis.copy(S[s]),m.copy(S[s]),"local"===e&&m.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.i.dot(m.cross(this.eye).normalize())*t),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===e&&"E"!==s&&"XYZE"!==s?(i.quaternion.copy(this.D),i.quaternion.multiply(v.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.m),i.quaternion.copy(v.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this.D).normalize())}this.dispatchEvent(b),this.dispatchEvent(T)}}pointerUp(t){0===t.button&&(this.dragging&&null!==this.axis&&(x.mode=this.mode,this.dispatchEvent(x)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this.R),this.domElement.removeEventListener("pointermove",this.j),this.domElement.removeEventListener("pointermove",this.C),this.domElement.removeEventListener("pointerup",this.I),this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}attach(t){return this.object=t,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this.k),this.object.quaternion.copy(this.D),this.object.scale.copy(this.W),this.dispatchEvent(b),this.dispatchEvent(T),this.pointStart.copy(this.pointEnd))}getRaycaster(){return f}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function A(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const s=this.domElement.getBoundingClientRect();return{x:(t.clientX-s.left)/s.width*2-1,y:-(t.clientY-s.top)/s.height*2+1,button:t.button}}}function k(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this.P(t))}}function D(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this.C),this.pointerHover(this.P(t)),this.pointerDown(this.P(t)))}function W(t){this.enabled&&this.pointerMove(this.P(t))}function P(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this.C),this.pointerUp(this.P(t)))}function R(t,s,h){const i=s.intersectObject(t,!0);for(let t=0;t<i.length;t++)if(i[t].object.visible||h)return i[t];return!1}const j=new e,z=new s(0,1,0),C=new s(0,0,0),Q=new n,I=new h,L=new h,N=new s,U=new n,G=new s(1,0,0),H=new s(0,1,0),O=new s(0,0,1),q=new s,B=new s,F=new s;class J extends i{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new a({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=new o({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),h=t.clone();h.opacity=.15;const e=s.clone();e.opacity=.5;const n=t.clone();n.color.setHex(16711680);const Z=t.clone();Z.color.setHex(65280);const d=t.clone();d.color.setHex(255);const f=t.clone();f.color.setHex(16711680),f.opacity=.5;const m=t.clone();m.color.setHex(65280),m.opacity=.5;const E=t.clone();E.color.setHex(255),E.opacity=.5;const v=t.clone();v.opacity=.25;const S=t.clone();S.color.setHex(16776960),S.opacity=.25;t.clone().color.setHex(16776960);const b=t.clone();b.color.setHex(7895160);const g=new w(0,.04,.1,12);g.translate(0,.05,0);const x=new l(.08,.08,.08);x.translate(0,.04,0);const T=new r;T.setAttribute("position",new c([0,0,0,1,0,0],3));const y=new w(.0075,.0075,.5,3);function A(t,s){const h=new Y(t,.0075,3,64,s*Math.PI*2);return h.rotateY(Math.PI/2),h.rotateX(Math.PI/2),h}y.translate(0,.25,0);const k={X:[[new u(g,n),[.5,0,0],[0,0,-Math.PI/2]],[new u(g,n),[-.5,0,0],[0,0,Math.PI/2]],[new u(y,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new u(g,Z),[0,.5,0]],[new u(g,Z),[0,-.5,0],[Math.PI,0,0]],[new u(y,Z)]],Z:[[new u(g,d),[0,0,.5],[Math.PI/2,0,0]],[new u(g,d),[0,0,-.5],[-Math.PI/2,0,0]],[new u(y,d),null,[Math.PI/2,0,0]]],XYZ:[[new u(new M(.1,0),v.clone()),[0,0,0]]],XY:[[new u(new l(.15,.15,.01),E.clone()),[.15,.15,0]]],YZ:[[new u(new l(.15,.15,.01),f.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new u(new l(.15,.15,.01),m.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},D={X:[[new u(new w(.2,0,.6,4),h),[.3,0,0],[0,0,-Math.PI/2]],[new u(new w(.2,0,.6,4),h),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new u(new w(.2,0,.6,4),h),[0,.3,0]],[new u(new w(.2,0,.6,4),h),[0,-.3,0],[0,0,Math.PI]]],Z:[[new u(new w(.2,0,.6,4),h),[0,0,.3],[Math.PI/2,0,0]],[new u(new w(.2,0,.6,4),h),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new u(new M(.2,0),h)]],XY:[[new u(new l(.2,.2,.01),h),[.15,.15,0]]],YZ:[[new u(new l(.2,.2,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new u(new l(.2,.2,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},W={START:[[new u(new M(.01,2),e),null,null,null,"helper"]],END:[[new u(new M(.01,2),e),null,null,null,"helper"]],DELTA:[[new p(function(){const t=new r;return t.setAttribute("position",new c([0,0,0,1,1,1],3)),t}(),e),null,null,null,"helper"]],X:[[new p(T,e.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new p(T,e.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new p(T,e.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},P={XYZE:[[new u(A(.5,1),b),null,[0,Math.PI/2,0]]],X:[[new u(A(.5,.5),n)]],Y:[[new u(A(.5,.5),Z),null,[0,0,-Math.PI/2]]],Z:[[new u(A(.5,.5),d),null,[0,Math.PI/2,0]]],E:[[new u(A(.75,1),S),null,[0,Math.PI/2,0]]]},R={AXIS:[[new p(T,e.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},j={XYZE:[[new u(new X(.25,10,8),h)]],X:[[new u(new Y(.5,.1,4,24),h),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new u(new Y(.5,.1,4,24),h),[0,0,0],[Math.PI/2,0,0]]],Z:[[new u(new Y(.5,.1,4,24),h),[0,0,0],[0,0,-Math.PI/2]]],E:[[new u(new Y(.75,.1,2,24),h)]]},z={X:[[new u(x,n),[.5,0,0],[0,0,-Math.PI/2]],[new u(y,n),[0,0,0],[0,0,-Math.PI/2]],[new u(x,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new u(x,Z),[0,.5,0]],[new u(y,Z)],[new u(x,Z),[0,-.5,0],[0,0,Math.PI]]],Z:[[new u(x,d),[0,0,.5],[Math.PI/2,0,0]],[new u(y,d),[0,0,0],[Math.PI/2,0,0]],[new u(x,d),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new u(new l(.15,.15,.01),E),[.15,.15,0]]],YZ:[[new u(new l(.15,.15,.01),f),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new u(new l(.15,.15,.01),m),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new u(new l(.1,.1,.1),v.clone())]]},C={X:[[new u(new w(.2,0,.6,4),h),[.3,0,0],[0,0,-Math.PI/2]],[new u(new w(.2,0,.6,4),h),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new u(new w(.2,0,.6,4),h),[0,.3,0]],[new u(new w(.2,0,.6,4),h),[0,-.3,0],[0,0,Math.PI]]],Z:[[new u(new w(.2,0,.6,4),h),[0,0,.3],[Math.PI/2,0,0]],[new u(new w(.2,0,.6,4),h),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new u(new l(.2,.2,.01),h),[.15,.15,0]]],YZ:[[new u(new l(.2,.2,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new u(new l(.2,.2,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new u(new l(.2,.2,.2),h),[0,0,0]]]},Q={X:[[new p(T,e.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new p(T,e.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new p(T,e.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function I(t){const s=new i;for(const h in t)for(let i=t[h].length;i--;){const e=t[h][i][0].clone(),n=t[h][i][1],a=t[h][i][2],o=t[h][i][3],w=t[h][i][4];e.name=h,e.tag=w,n&&e.position.set(n[0],n[1],n[2]),a&&e.rotation.set(a[0],a[1],a[2]),o&&e.scale.set(o[0],o[1],o[2]),e.updateMatrix();const l=e.geometry.clone();l.applyMatrix4(e.matrix),e.geometry=l,e.renderOrder=1/0,e.position.set(0,0,0),e.rotation.set(0,0,0),e.scale.set(1,1,1),s.add(e)}return s}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=I(k)),this.add(this.gizmo.rotate=I(P)),this.add(this.gizmo.scale=I(z)),this.add(this.picker.translate=I(D)),this.add(this.picker.rotate=I(j)),this.add(this.picker.scale=I(C)),this.add(this.helper.translate=I(W)),this.add(this.helper.rotate=I(R)),this.add(this.helper.scale=I(Q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const s="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:L;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;let h=[];h=h.concat(this.picker[this.mode].children),h=h.concat(this.gizmo[this.mode].children),h=h.concat(this.helper[this.mode].children);for(let t=0;t<h.length;t++){const i=h[t];let e;if(i.visible=!0,i.rotation.set(0,0,0),i.position.copy(this.worldPosition),e=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),i.scale.set(1,1,1).multiplyScalar(e*this.size/4),"helper"!==i.tag){if(i.quaternion.copy(s),"translate"===this.mode||"scale"===this.mode){const t=.99,h=.2;"X"===i.name&&Math.abs(z.copy(G).applyQuaternion(s).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(z.copy(H).applyQuaternion(s).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(z.copy(O).applyQuaternion(s).dot(this.eye))>t&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(z.copy(O).applyQuaternion(s).dot(this.eye))<h&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"YZ"===i.name&&Math.abs(z.copy(G).applyQuaternion(s).dot(this.eye))<h&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XZ"===i.name&&Math.abs(z.copy(H).applyQuaternion(s).dot(this.eye))<h&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)}else"rotate"===this.mode&&(I.copy(s),z.copy(this.eye).applyQuaternion(v.copy(s).invert()),-1!==i.name.search("E")&&i.quaternion.setFromRotationMatrix(Q.lookAt(this.eye,C,H)),"X"===i.name&&(v.setFromAxisAngle(G,Math.atan2(-z.y,z.z)),v.multiplyQuaternions(I,v),i.quaternion.copy(v)),"Y"===i.name&&(v.setFromAxisAngle(H,Math.atan2(z.x,z.z)),v.multiplyQuaternions(I,v),i.quaternion.copy(v)),"Z"===i.name&&(v.setFromAxisAngle(O,Math.atan2(z.y,z.x)),v.multiplyQuaternions(I,v),i.quaternion.copy(v)));i.visible=i.visible&&(-1===i.name.indexOf("X")||this.showX),i.visible=i.visible&&(-1===i.name.indexOf("Y")||this.showY),i.visible=i.visible&&(-1===i.name.indexOf("Z")||this.showZ),i.visible=i.visible&&(-1===i.name.indexOf("E")||this.showX&&this.showY&&this.showZ),i.material.L=i.material.L||i.material.color.clone(),i.material.N=i.material.N||i.material.opacity,i.material.color.copy(i.material.L),i.material.opacity=i.material.N,this.enabled&&this.axis&&(i.name===this.axis||this.axis.split("").some(function(t){return i.name===t}))&&(i.material.color.setHex(16776960),i.material.opacity=1)}else i.visible=!1,"AXIS"===i.name?(i.visible=!!this.axis,"X"===this.axis&&(v.setFromEuler(j.set(0,0,0)),i.quaternion.copy(s).multiply(v),Math.abs(z.copy(G).applyQuaternion(s).dot(this.eye))>.9&&(i.visible=!1)),"Y"===this.axis&&(v.setFromEuler(j.set(0,0,Math.PI/2)),i.quaternion.copy(s).multiply(v),Math.abs(z.copy(H).applyQuaternion(s).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(v.setFromEuler(j.set(0,Math.PI/2,0)),i.quaternion.copy(s).multiply(v),Math.abs(z.copy(O).applyQuaternion(s).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(v.setFromEuler(j.set(0,Math.PI/2,0)),z.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(Q.lookAt(C,z,H)),i.quaternion.multiply(v),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),m.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),m.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(m),i.visible=this.dragging):(i.quaternion.copy(s),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(t)}}class K extends u{constructor(){super(new Z(1e5,1e5,2,2),new a({visible:!1,wireframe:!0,side:d,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let s=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(s="local"),q.copy(G).applyQuaternion("local"===s?this.worldQuaternion:L),B.copy(H).applyQuaternion("local"===s?this.worldQuaternion:L),F.copy(O).applyQuaternion("local"===s?this.worldQuaternion:L),z.copy(B),this.mode){case"translate":case"scale":switch(this.axis){case"X":z.copy(this.eye).cross(q),N.copy(q).cross(z);break;case"Y":z.copy(this.eye).cross(B),N.copy(B).cross(z);break;case"Z":z.copy(this.eye).cross(F),N.copy(F).cross(z);break;case"XY":N.copy(F);break;case"YZ":N.copy(q);break;case"XZ":z.copy(F),N.copy(B);break;case"XYZ":case"E":N.set(0,0,0)}break;default:N.set(0,0,0)}0===N.length()?this.quaternion.copy(this.cameraQuaternion):(U.lookAt(m.set(0,0,0),N,z),this.quaternion.setFromRotationMatrix(U)),super.updateMatrixWorld(t)}}export{y as TransformControls,J as TransformControlsGizmo,K as TransformControlsPlane};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{logger as n}from"./debugLogger.js";var i=null,a=!1,t=0,o=[];function r(r){if(!a){a=!0,t=performance.now();var e=function(c){if(a){var u=(c-t)/1e3;t=c,function(i,a){o.forEach(function(t){try{t(i,a)}catch(i){n.error("Error in animation callback:",i)}})}(c,u),r&&r.renderer&&r.scene&&r.camera&&r.renderer.render(r.scene,r.camera),r&&r.controls&&r.controls.update&&r.controls.update(),i=requestAnimationFrame(e)}};i=requestAnimationFrame(e),n.info("Animation loop started")}}function e(){a&&(null!==i&&(cancelAnimationFrame(i),i=null),a=!1,n.info("Animation loop stopped"))}function c(i){if("function"==typeof i)return o.push(i),i;n.warn("Invalid animation callback")}function u(n){var i=o.indexOf(n);return-1!==i&&(o.splice(i,1),!0)}function l(){return a}var m={startAnimation:r,stopAnimation:e,addAnimationCallback:c,removeAnimationCallback:u,isAnimationRunning:l};export{c as addAnimationCallback,m as default,l as isAnimationRunning,u as removeAnimationCallback,r as startAnimation,e as stopAnimation};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{asyncToGenerator as n,regenerator as o}from"../_virtual/_rollupPluginBabelHelpers.js";import*as e from"three";import{logger as t}from"./debugLogger.js";function r(n){return i.apply(this,arguments)}function i(){return(i=n(o().m(function n(r){var i;return o().w(function(n){for(;;)if(0===n.n)return t.info("Loading component: ".concat(r.id||"Unknown")),i={id:r.id||"unknown-component",type:r.type||"generic",data:r,object:new e.Group,position:r.position||{x:0,y:0,z:0},rotation:r.rotation||{x:0,y:0,z:0},scale:r.scale||{x:1,y:1,z:1}},n.a(2,i)},n)}))).apply(this,arguments)}function u(n,o,e,r){return n&&n.object?(o&&n.object.position.set(o.x||0,o.y||0,o.z||0),e&&n.object.rotation.set(e.x||0,e.y||0,e.z||0),r&&r.add&&r.add(n.object),n):(t.error("Cannot place component: invalid component object"),null)}function a(n,o){if(!o)return t.error("Cannot remove component: scene not provided"),!1;var e=null;return o.traverse(function(o){o.userData&&o.userData.id===n&&(e=o)}),e&&e.parent?(e.parent.remove(e),t.info("Component removed: ".concat(n)),!0):(t.warn("Component not found: ".concat(n)),!1)}function c(n,o){if(!o)return t.error("Cannot get component: scene not provided"),null;var e=null;return o.traverse(function(o){o.userData&&o.userData.id===n&&(e=o)}),e}var p={loadComponent:r,placeComponent:u,removeComponent:a,getComponentById:c};export{p as default,c as getComponentById,r as loadComponent,u as placeComponent,a as removeComponent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClass as e,toConsumableArray as r,classCallCheck as i}from"../_virtual/_rollupPluginBabelHelpers.js";var n=function(){return e(function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SceneViewer",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";i(this,e),this.namespace=r,this.debugLevel=n,this.isProduction="undefined"!=typeof process&&"production"===process.env.NODE_ENV,this.enabled=!this.isProduction,this.levels={error:0,warn:1,info:2,debug:3,verbose:4},this.currentLevel=this.levels[n]||this.levels.info},[{key:"setLevel",value:function(e){return this.currentLevel=this.levels[e]||this.levels.info,this}},{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"_shouldLog",value:function(e){return this.enabled&&this.levels[e]<=this.currentLevel}},{key:"_formatMessage",value:function(e,r){for(var i="[".concat(this.namespace,":").concat(e.toUpperCase(),"]"),n=arguments.length,s=new Array(n>2?n-2:0),t=2;t<n;t++)s[t-2]=arguments[t];return[i,r].concat(s)}},{key:"error",value:function(e){if(this.i("error")){for(var i,n=arguments.length,s=new Array(n>1?n-1:0),t=1;t<n;t++)s[t-1]=arguments[t];(i=console).error.apply(i,r(this.t.apply(this,["error",e].concat(s))))}}},{key:"warn",value:function(e){if(this.i("warn")){for(var i,n=arguments.length,s=new Array(n>1?n-1:0),t=1;t<n;t++)s[t-1]=arguments[t];(i=console).warn.apply(i,r(this.t.apply(this,["warn",e].concat(s))))}}},{key:"info",value:function(e){if(this.i("info")){for(var i,n=arguments.length,s=new Array(n>1?n-1:0),t=1;t<n;t++)s[t-1]=arguments[t];(i=console).log.apply(i,r(this.t.apply(this,["info",e].concat(s))))}}},{key:"debug",value:function(e){if(this.i("debug")){for(var i,n=arguments.length,s=new Array(n>1?n-1:0),t=1;t<n;t++)s[t-1]=arguments[t];(i=console).debug.apply(i,r(this.t.apply(this,["debug",e].concat(s))))}}},{key:"verbose",value:function(e){if(this.i("verbose")){for(var i,n=arguments.length,s=new Array(n>1?n-1:0),t=1;t<n;t++)s[t-1]=arguments[t];(i=console).debug.apply(i,r(this.t.apply(this,["verbose",e].concat(s))))}}},{key:"phase",value:function(e,r){for(var i=arguments.length,n=new Array(i>2?i-2:0),s=2;s<i;s++)n[s-2]=arguments[s];this.info.apply(this,["🔍 PHASE ".concat(e,": ").concat(r)].concat(n))}},{key:"success",value:function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.info.apply(this,["✅ ".concat(e)].concat(i))}},{key:"failure",value:function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.error.apply(this,["❌ ".concat(e)].concat(i))}},{key:"loading",value:function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.debug.apply(this,["🔄 ".concat(e)].concat(i))}},{key:"timing",value:function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.debug.apply(this,["⏱️ ".concat(e)].concat(i))}}])}(),s=new n("SceneViewer","info"),t=new n("Transform","warn"),o=new n("Pathfinder","info"),a=new n("Models","info"),h=new n("Materials","warn");export{n as DebugLogger,s as logger,h as materialLogger,a as modelLogger,o as pathfinderLogger,t as transformLogger};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{toConsumableArray as e}from"../_virtual/_rollupPluginBabelHelpers.js";import*as n from"three";import{logger as r}from"./debugLogger.js";function o(n){n&&(n.geometry&&n.geometry.dispose(),n.material&&(Array.isArray(n.material)?n.material.forEach(function(e){return u(e)}):u(n.material)),n.children&&n.children.length>0&&e(n.children).forEach(function(e){return o(e)}))}function u(e){e&&(Object.keys(e).forEach(function(r){var o=e[r];o&&o instanceof n.Texture&&o.dispose()}),e.dispose())}function l(e){if(e){for(;e.children.length>0;){var n=e.children[0];e.remove(n),o(n)}r.info("Scene cleared and disposed")}else r.warn("Cannot cleanup: scene not provided")}function t(e){if(e){e.dispose();var n=e.domElement;n&&n.parentNode&&n.parentNode.removeChild(n),r.info("Renderer disposed")}else r.warn("Cannot cleanup: renderer not provided")}function i(){"undefined"!=typeof window&&window.$nuxt&&window.$nuxt.$off&&r.info("Nuxt event listeners cleaned up")}function s(e){e&&(e.stopAnimation&&e.stopAnimation(),e.controls&&(e.controls.dispose&&e.controls.dispose(),e.controls=null),e.scene&&(l(e.scene),e.scene=null),e.renderer&&(t(e.renderer),e.renderer=null),e.camera=null,e.textureLoader=null,e.gltfLoader=null,r.info("All Three.js resources cleaned up"))}var a={disposeObject:o,disposeMaterial:u,cleanupScene:l,cleanupRenderer:t,cleanupNuxtEventListeners:i,cleanupThreeJsResources:s};export{i as cleanupNuxtEventListeners,t as cleanupRenderer,l as cleanupScene,s as cleanupThreeJsResources,a as default,u as disposeMaterial,o as disposeObject};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClass as e,toConsumableArray as n,asyncToGenerator as r,regenerator as t,classCallCheck as a,regeneratorValues as i,createForOfIteratorHelper as o,slicedToArray as s}from"../_virtual/_rollupPluginBabelHelpers.js";import*as u from"three";import{logger as c}from"./debugLogger.js";var l;function f(e){if(e.startsWith("/")&&(e=e.substring(1)),"undefined"!=typeof window){var n="undefined"!=typeof CentralPlantUtils;if("localhost"===window.location.hostname&&("3000"===window.location.port||"3001"===window.location.port))return"/".concat(e);if(n){var r=import.meta.url;return new URL("./assets/".concat(e),r).href}var t=import.meta.url;return new URL("../assets/".concat(e),t).href}return"assets/".concat(e)}function d(){return v.apply(this,arguments)}function v(){return(v=r(t().m(function e(){var n;return t().w(function(e){for(;;)switch(e.n){case 0:if("undefined"==typeof window){e.n=4;break}return e.p=1,e.n=2,import("../node_modules/three/examples/jsm/loaders/RGBELoader.js");case 2:return n=e.v,l=n.RGBELoader,e.a(2,!0);case 3:throw e.p=3,e.v,new Error("Failed to load Three.js loaders");case 4:return e.a(2,!1)}},e,null,[[1,3]])}))).apply(this,arguments)}var w={loadTextureSetAndCreateMaterial:null,checkThreeJSCompatibility:null,forceUpdateMaterials:null};function h(){return p.apply(this,arguments)}function p(){return(p=r(t().m(function e(){var n;return t().w(function(e){for(;;)switch(e.n){case 0:if("undefined"==typeof window){e.n=4;break}return e.p=1,e.n=2,import("./textureConfig.js");case 2:return n=e.v,w.loadTextureSetAndCreateMaterial=n.loadTextureSetAndCreateMaterial,w.checkThreeJSCompatibility=n.checkThreeJSCompatibility,w.forceUpdateMaterials=n.forceUpdateMaterials,Object.entries(w).filter(function(e){var n=s(e,2);return n[0],"function"==typeof n[1]}).map(function(e){return s(e,1)[0]}),"function"==typeof w.checkThreeJSCompatibility&&w.checkThreeJSCompatibility(),e.a(2,!0);case 3:return e.p=3,e.v,e.a(2,!1);case 4:return e.a(2,!1)}},e,null,[[1,3]])}))).apply(this,arguments)}var m=function(){return e(function e(n){a(this,e),this.component=n,this.loadersInitialized=!1,this.initLoaders()},[{key:"initLoaders",value:(b=r(t().m(function e(){return t().w(function(e){for(;;)switch(e.n){case 0:return e.p=1,e.n=2,Promise.all([d(),h()]);case 2:this.loadersInitialized=!0,e.n=4;break;case 3:e.p=3,e.v;case 4:return e.a(2)}},e,this,[[1,3]])})),function(){return b.apply(this,arguments)})},{key:"createSkybox",value:(k=r(t().m(function e(){var n,r,a,s,v,w,h,p,m,k,b,y,g,E,x=this;return t().w(function(e){for(;;)switch(e.n){case 0:if((n=this.component)&&n.renderer&&n.scene){e.n=1;break}return c.warn("Cannot create skybox: component, renderer or scene not available"),e.a(2);case 1:if(l){e.n=5;break}return e.p=2,e.n=3,d();case 3:e.n=5;break;case 4:return e.p=4,e.v,this.createFallbackEnvironment(),e.a(2);case 5:if(e.p=5,r=!(!n.renderer.context||"function"!=typeof n.renderer.context.isContextLost)&&n.renderer.context.isContextLost(),n.renderer.capabilities&&!r){e.n=6;break}return c.warn("WebGL context is lost or invalid, using fallback environment"),this.createFallbackEnvironment(),e.a(2);case 6:if(e.p=6,a=new u.PMREMGenerator(n.renderer)){e.n=7;break}throw new Error("PMREMGenerator could not be created");case 7:a.compileEquirectangularShader(),e.n=9;break;case 8:return e.p=8,g=e.v,c.warn("Failed to initialize PMREMGenerator:",g),this.createFallbackEnvironment(),e.a(2);case 9:s=f("skyboxes/kloofendal_48d_partly_cloudy_puresky_2k.hdr"),v=f("skyboxes/kloofendal_48d_partly_cloudy_puresky_1k.hdr"),w=f("skyboxes/sky_fallback.jpg"),(h=[{type:"hdr",loader:new l,paths:[s,v]},{type:"jpeg",loader:n.textureLoader||new u.TextureLoader,paths:[w]}]).forEach(function(e){var n=e.loader;n&&"function"==typeof n.setCrossOrigin&&n.setCrossOrigin("anonymous")}),p=function(e,r){try{var t,i;e.mapping=u.EquirectangularReflectionMapping,void 0!==e.colorSpace?e.colorSpace=n.renderer.outputColorSpace||u.SRGBColorSpace:void 0!==e.encoding&&(e.encoding=n.renderer.outputEncoding||u.sRGBEncoding);var o=a.fromEquirectangular(e).texture;return c.info("Generating environment map:\n - Type: ".concat(r,"\n - Texture valid: ").concat(null!==e,"\n - Processed map valid: ").concat(null!==o,"\n - Renderer encoding: ").concat(n.renderer.outputEncoding||n.renderer.outputColorSpace,"\n - Texture encoding: ").concat(e.encoding||e.colorSpace)),null!==(t=n.scene.environment)&&void 0!==t&&t.dispose&&n.scene.environment.dispose(),null!==(i=n.scene.background)&&void 0!==i&&i.dispose&&n.scene.background.dispose(),n.scene.environment=o,n.scene.background=o,e.dispose(),n.renderer&&(n.renderer.toneMappingExposure=1,n.renderer.render(n.scene,n.camera)),c.info("Environment map (".concat(r,") applied successfully")),!0}catch(e){return c.warn("Failed to apply ".concat(r," environment map:"),e),!1}},m=t().m(function e(){var n,r,s,u,l,f,d,v,w;return t().w(function(e){for(;;)switch(e.n){case 0:n=y[b],r=n.type,s=n.loader,u=n.paths,l=o(u),e.p=1,d=t().m(function e(){var n,i,o;return t().w(function(e){for(;;)switch(e.n){case 0:if(n=f.value,e.p=1,!n.startsWith("/")||n.includes("://")){e.n=3;break}return e.n=2,x.checkLocalTextureExists(n);case 2:if(e.v){e.n=3;break}return e.a(2,0);case 3:return c.info("Attempting to load ".concat(r," texture: ").concat(n)),e.n=4,new Promise(function(e,r){var t=setTimeout(function(){return r(new Error("Timeout loading ".concat(n)))},1e4);s.load(n,function(n){clearTimeout(t),e(n)},function(e){e.lengthComputable&&(e.loaded,e.total)},function(e){clearTimeout(t),r(e)})});case 4:if(i=e.v,!p(i,r)){e.n=5;break}return a.dispose(),e.a(2,{v:{v:void 0}});case 5:e.n=7;break;case 6:e.p=6,o=e.v,c.warn("Failed to load ".concat(n,":"),o.message);case 7:return e.a(2)}},e,null,[[1,6]])}),l.s();case 2:if((f=l.n()).done){e.n=6;break}return e.d(i(d()),3);case 3:if(0!==(v=e.v)){e.n=4;break}return e.a(3,5);case 4:if(!v){e.n=5;break}return e.a(2,v.v);case 5:e.n=2;break;case 6:e.n=8;break;case 7:e.p=7,w=e.v,l.e(w);case 8:return e.p=8,l.f(),e.f(8);case 9:return e.a(2)}},e,null,[[1,7,8,9]])}),b=0,y=h;case 10:if(!(b<y.length)){e.n=13;break}return e.d(i(m()),11);case 11:if(!(k=e.v)){e.n=12;break}return e.a(2,k.v);case 12:b++,e.n=10;break;case 13:this.createProceduralSky(a),e.n=15;break;case 14:e.p=14,E=e.v,c.error("Error creating skybox:",E),this.createFallbackEnvironment();case 15:return e.a(2)}},e,this,[[6,8],[5,14],[2,4]])})),function(){return k.apply(this,arguments)})},{key:"createFallbackEnvironment",value:function(){var e=this.component;if(e&&e.scene){c.info("Creating basic fallback environment");var n=new u.AmbientLight(16777215,.6);e.scene.add(n);var r=new u.DirectionalLight(16777215,.8);r.position.set(1,2,3),e.scene.add(r),e.scene.background=new u.Color(8900331)}}},{key:"createProceduralSky",value:function(e){var n=this.component;if(n&&n.scene){c.info("Using procedural sky fallback");var r=new u.AmbientLight(16777215,.6);n.scene.add(r);var t=new u.DirectionalLight(16777215,.8);t.position.set(1,1,1),n.scene.add(t);try{if(e&&"function"==typeof e.fromScene){var a=new u.Scene;a.add(new u.HemisphereLight(8900331,4473975,1));var i=e.fromScene(a);i&&i.texture&&(n.scene.environment=i.texture)}n.scene.background=new u.Color(8900331)}catch(e){c.warn("Failed to create procedural sky, using simple background",e),n.scene.background=new u.Color(8900331)}finally{e&&"function"==typeof e.dispose&&e.dispose()}}}},{key:"setupLighting",value:function(){var e=this.component;if(e&&e.scene){var n=[];e.scene.traverse(function(e){e instanceof u.Light&&n.push(e)}),n.forEach(function(n){e.scene.remove(n)});var r=new u.DirectionalLight(16777215,.8);r.position.set(5,10,7),r.castShadow=!0,r.shadow.mapSize.width=1024,r.shadow.mapSize.height=1024,r.shadow.camera.near=1,r.shadow.camera.far=30,r.shadow.camera.left=-10,r.shadow.camera.right=10,r.shadow.camera.top=10,r.shadow.camera.bottom=-10,r.shadow.bias=-.001,e.scene.add(r);var t=new u.AmbientLight(16777215,.3);e.scene.add(t);var a=new u.HemisphereLight(16777215,4473975,.3);e.scene.add(a),c.info("Scene lighting setup complete")}else c.warn("Cannot setup lighting: component or scene not available")}},{key:"createGround",value:function(){var e=this.component;if(!e||!e.scene)return c.warn("Cannot create ground: component or scene not available"),null;var n=new u.PlaneGeometry(100,100),r=new u.MeshStandardMaterial({color:13421772,roughness:.8,metalness:.2,side:u.DoubleSide}),t=new u.Mesh(n,r);return t.rotation.x=-Math.PI/2,t.position.y=-.01,t.receiveShadow=!0,t.userData={isEnvironmentObject:!0,type:"ground"},e.scene.add(t),c.info("Ground plane created"),t}},{key:"createWalls",value:function(){var e=this.component;if(!e||!e.scene)return c.warn("Cannot create walls: component or scene not available"),[];for(var r=[],t=20,a=50,i=new u.MeshStandardMaterial({color:14540253,roughness:.9,metalness:.1,side:u.DoubleSide}),o=[new u.BoxGeometry(a,t,1),new u.BoxGeometry(1,t,a),new u.BoxGeometry(a,t,1),new u.BoxGeometry(1,t,a)],s=[[0,10,-25],[25,10,0],[0,10,25],[-25,10,0]],l=["north-wall","east-wall","south-wall","west-wall"],f=0;f<4;f++){var d,v=new u.Mesh(o[f],i);(d=v.position).set.apply(d,n(s[f])),v.receiveShadow=!0,v.castShadow=!0,v.userData={isEnvironmentObject:!0,type:"wall",name:l[f]},e.scene.add(v),r.push(v)}return c.info("Environment walls created"),r}},{key:"setFog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:13421772,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01,r=this.component;r&&r.scene?(r.scene.fog=new u.FogExp2(e,n),c.info("Scene fog applied")):c.warn("Cannot set fog: component or scene not available")}},{key:"initializeEnvironment",value:(m=r(t().m(function e(){var n,r,a=this;return t().w(function(e){for(;;)switch(e.n){case 0:return n=this.component,e.p=1,e.n=2,d();case 2:return e.v,e.n=3,h();case 3:e.v,e.n=5;break;case 4:e.p=4,e.v;case 5:if(n){e.n=6;break}return c.error("❌ Cannot initialize environment: component is null"),e.a(2);case 6:if(n.renderer){e.n=7;break}return c.error("❌ Cannot initialize environment: renderer is null"),e.a(2);case 7:return n.renderer.toneMapping||(n.renderer.toneMapping=u.ACESFilmicToneMapping),n.renderer.toneMappingExposure=1,void 0!==n.renderer.outputColorSpace?n.renderer.outputColorSpace=u.SRGBColorSpace:void 0!==n.renderer.outputEncoding&&(n.renderer.outputEncoding=u.sRGBEncoding),c.info("Renderer configured for HDR:\n - Tone mapping: ".concat(n.renderer.toneMapping,"\n - Color space: ").concat(n.renderer.outputColorSpace||n.renderer.outputEncoding)),e.n=8,this.createSkybox();case 8:return this.setupLighting(),e.n=9,this.addTexturedGround();case 9:return e.v?c.info("✅ Ground created successfully"):c.error("❌ Failed to create textured ground"),e.n=10,this.addBrickWalls();case 10:(r=e.v)&&0!==r.length?c.info("✅ Created ".concat(r.length," walls")):c.warn("⚠️ No walls were created"),this.addHorizonFog(),c.info("Environment initialization complete"),this.forceRefreshMaterials(),n.renderer&&n.scene&&n.camera&&(n.renderer.render(n.scene,n.camera),setTimeout(function(){n.renderer&&!n.isDestroyed&&(a.forceRefreshMaterials(),n.renderer.render(n.scene,n.camera))},1e3));case 11:return e.a(2)}},e,this,[[1,4]])})),function(){return m.apply(this,arguments)})},{key:"addTexturedGround",value:(p=r(t().m(function e(){var n,r,a,i,o,s,l,f,d,v;return t().w(function(e){for(;;)switch(e.n){case 0:if(w.loadTextureSetAndCreateMaterial){e.n=2;break}return e.n=1,h();case 1:if(w.loadTextureSetAndCreateMaterial){e.n=2;break}return e.a(2,this.createGround());case 2:if((n=this.component)&&n.scene){e.n=3;break}return c.warn("Cannot create textured ground: component or scene not available"),e.a(2,null);case 3:return n.textureLoader||(n.textureLoader=new u.TextureLoader,n.textureLoader.setCrossOrigin("anonymous")),n.scene.traverse(function(e){e.userData&&"ground"===e.userData.type&&n.scene.remove(e)}),e.p=4,e.n=5,w.loadTextureSetAndCreateMaterial(n,"gravel_embedded_concrete");case 5:if(r=e.v){e.n=6;break}throw new Error("Failed to create ground material");case 6:return a=new u.MeshBasicMaterial({color:2293538,wireframe:!1,side:u.DoubleSide}),i=new u.PlaneGeometry(100,100),(o=new u.Mesh(i,r)).rotation.x=-Math.PI/2,o.position.y=-.01,o.receiveShadow=!0,(s=new u.Mesh(i,a)).rotation.x=-Math.PI/2,s.position.y=-.02,s.visible=!1,o.userData={isEnvironmentObject:!0,isBaseGround:!0,type:"ground"},s.userData={isEnvironmentObject:!0,type:"ground-debug"},n.scene.add(o),n.scene.add(s),c.info("Textured ground created"),e.a(2,o);case 7:return e.p=7,v=e.v,c.error("Error creating textured ground:",v),l=new u.PlaneGeometry(100,100),f=new u.MeshBasicMaterial({color:16711680,wireframe:!0,side:u.DoubleSide}),(d=new u.Mesh(l,f)).rotation.x=-Math.PI/2,d.position.y=-.01,d.userData={isEnvironmentObject:!0,isBaseGround:!0,type:"ground-error"},n.scene.add(d),e.a(2,d)}},e,this,[[4,7]])})),function(){return p.apply(this,arguments)})},{key:"addBrickWalls",value:(v=r(t().m(function e(){var r,a,i,o,s,l,f,d,v,p,m,k;return t().w(function(e){for(;;)switch(e.n){case 0:if(w.loadTextureSetAndCreateMaterial){e.n=2;break}return e.n=1,h();case 1:if(w.loadTextureSetAndCreateMaterial){e.n=2;break}return e.a(2,this.createWalls());case 2:if((r=this.component)&&r.scene){e.n=3;break}return c.warn("Cannot create brick walls: component or scene not available"),e.a(2,[]);case 3:return r.scene.traverse(function(e){e.userData&&"wall"===e.userData.type&&r.scene.remove(e)}),e.p=4,e.n=5,w.loadTextureSetAndCreateMaterial(r,"brick");case 5:for(a=e.v,i=[],o=20,s=50,l=[new u.BoxGeometry(s,o,1),new u.BoxGeometry(1,o,s),new u.BoxGeometry(s,o,1),new u.BoxGeometry(1,o,s)],f=[[0,10,-25],[25,10,0],[0,10,25],[-25,10,0]],d=["north-wall","east-wall","south-wall","west-wall"],v=0;v<4;v++)m=new u.Mesh(l[v],a),(p=m.position).set.apply(p,n(f[v])),m.receiveShadow=!0,m.castShadow=!0,m.userData={isEnvironmentObject:!0,type:"wall",name:d[v]},r.scene.add(m),i.push(m);return c.info("Textured environment walls created"),e.a(2,i);case 6:return e.p=6,k=e.v,c.error("Error creating brick walls:",k),e.a(2,this.createWalls())}},e,this,[[4,6]])})),function(){return v.apply(this,arguments)})},{key:"addHorizonFog",value:function(){var e=this.component;if(e&&e.scene){e.scene.fog=new u.FogExp2(14213375,.005),c.info("Horizon fog applied")}else c.warn("Cannot set horizon fog: component or scene not available")}},{key:"checkLocalTextureExists",value:(s=r(t().m(function e(n){return t().w(function(e){for(;;)switch(e.n){case 0:if(n.startsWith("/")&&(n=n.substring(1)),"undefined"==typeof window){e.n=1;break}return e.a(2,new Promise(function(e){var r=new Image;r.onload=function(){return e(!0)},r.onerror=function(){return e(!1)},r.src=n,setTimeout(function(){return e(!1)},2e3)}));case 1:return e.a(2,!1)}},e)})),function(e){return s.apply(this,arguments)})},{key:"forceRefreshMaterials",value:function(){var e=this.component;if(e&&e.scene){var n=w.hasValidImageData||function(e){return e&&e.image},r=w.createPlaceholderTexture||function(){return null};e.scene.traverse(function(e){e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(function(e){if(e){e.needsUpdate=!0,e.color&&"function"==typeof e.color.convertSRGBToLinear&&e.color.convertSRGBToLinear();["map","normalMap","roughnessMap","metalnessMap","aoMap","bumpMap"].forEach(function(t){var a=e[t];if(a)if(n(a))a.needsUpdate=!0,"map"===t&&void 0!==a.colorSpace?a.colorSpace=u.SRGBColorSpace:"map"===t&&void 0!==a.encoding&&(a.encoding=u.sRGBEncoding);else if(r){var i=r("normalMap"===t?8421631:13421772);i&&(e[t]=i)}})}})}),w.forceUpdateMaterials&&w.forceUpdateMaterials(e.scene),e.renderer&&e.camera&&e.renderer.render(e.scene,e.camera)}else c.warn("Cannot refresh materials: component or scene not available")}}]);var s,v,p,m,k,b}(),k=null;function b(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return(!k||e&&k.component!==e)&&(k=new m(e)),k}var y,g={EnvironmentManager:m,getEnvironmentManager:b,initializeEnvironment:(y=r(t().m(function e(n){var r;return t().w(function(e){for(;;)switch(e.n){case 0:return r=b(n),e.n=1,r.initializeEnvironment();case 1:return e.a(2,r)}},e)})),function(e){return y.apply(this,arguments)})};export{m as EnvironmentManager,g as default,b as getEnvironmentManager};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClass as i,classCallCheck as t}from"../_virtual/_rollupPluginBabelHelpers.js";var n="undefined"!=typeof window,e=n&&"development"===process.env.NODE_ENV,o=function(){return i(function i(n){t(this,i),this.component=n,this.isDev=e,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 i=this;n&&this.isDev&&(window._sceneViewerInstances||(window._sceneViewerInstances=new Set),window._sceneViewerInstances.add(this.component),this.hotReloadCleanupHandler=function(){i.component&&"function"==typeof i.component.enhancedDisposal&&i.component.enhancedDisposal(),window._sceneViewerInstances&&window._sceneViewerInstances.delete(i.component)},window.addEventListener("beforeunload",this.hotReloadCleanupHandler),window.addEventListener("pagehide",this.hotReloadCleanupHandler))}},{key:"cleanupHotReloadHandlers",value:function(){n&&this.isDev&&(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),window._sceneViewerInstances&&window._sceneViewerInstances.delete(this.component))}},{key:"trackTimeout",value:function(i){return i&&this.timeoutIds.add(i),i}},{key:"trackInterval",value:function(i){return i&&this.intervalIds.add(i),i}},{key:"clearTrackedTimeout",value:function(i){return!!this.timeoutIds.has(i)&&(clearTimeout(i),this.timeoutIds.delete(i),!0)}},{key:"clearTrackedInterval",value:function(i){return!!this.intervalIds.has(i)&&(clearInterval(i),this.intervalIds.delete(i),!0)}},{key:"clearAllTrackedTimers",value:function(){this.timeoutIds.forEach(function(i){clearTimeout(i)}),this.timeoutIds.clear(),this.intervalIds.forEach(function(i){clearInterval(i)}),this.intervalIds.clear()}}])}();function a(i,t){if(n&&e){window._hotReloadRegistry||(window._hotReloadRegistry=new Map);var o=window._hotReloadRegistry.get(i);o&&"function"==typeof o.cleanup&&o.cleanup(),window._hotReloadRegistry.set(i,{timestamp:Date.now(),cleanup:t})}}function l(){return e&&n&&window._hotReloadRegistry&&window._hotReloadRegistry.size>0}function s(i){if(n&&e&&window._hotReloadRegistry){var t=window._hotReloadRegistry.get(i);t&&"function"==typeof t.cleanup&&(t.cleanup(),window._hotReloadRegistry.delete(i))}}var u={HotReloadManager:o,handleHotReload:a,isHotReloading:l,cleanupForHotReload:s};export{o as HotReloadManager,s as cleanupForHotReload,u as default,a as handleHotReload,l as isHotReloading};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{logger as n}from"./debugLogger.js";var e=new Map,o=!1;function r(){"undefined"!=typeof window?o||(window.addEventListener("keydown",t),window.addEventListener("keyup",a),o=!0,n.info("Keyboard controls initialized")):n.warn("Cannot initialize keyboard controls: window is not defined")}function i(){"undefined"!=typeof window&&o&&(window.removeEventListener("keydown",t),window.removeEventListener("keyup",a),e.clear(),o=!1,n.info("Keyboard controls cleaned up"))}function t(n){var o=l(n),r=e.get(o);r&&(n.preventDefault(),r.callback(n))}function a(n){var o=l(n),r=e.get(o);r&&r.onKeyUp&&(n.preventDefault(),r.onKeyUp(n))}function d(n,i){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=f(n);return e.set(a,{callback:i,onKeyUp:t.onKeyUp||null,description:t.description||""}),o||r(),a}function u(n){var o=f(n);return e.delete(o)}function c(){var n=[];return e.forEach(function(e,o){n.push({key:o,description:e.description})}),n}function f(n){return n.toLowerCase()}function l(n){var e="";return n.ctrlKey&&(e+="ctrl+"),n.altKey&&(e+="alt+"),n.shiftKey&&(e+="shift+"),n.metaKey&&(e+="meta+"),e+=n.key.toLowerCase()}function s(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};d("r",function(){e.camera&&e.controls&&(e.camera.position.set(-10,10,10),e.controls.target.set(0,0,0),e.controls.update(),n.info("Camera reset"))},{description:"Reset camera view"}),d("w",function(){if(e.scene){var r=!o.wireframeEnabled;o.wireframeEnabled=r,e.scene.traverse(function(n){n.isMesh&&n.material&&(Array.isArray(n.material)?n.material.forEach(function(n){n.wireframe=r}):n.material.wireframe=r)}),n.info("Wireframe mode: ".concat(r?"enabled":"disabled"))}},{description:"Toggle wireframe mode"}),d("p",function(){e.performanceUI&&e.performanceUI.toggle()},{description:"Toggle performance monitor"}),n.info("Common keyboard controls setup")}var w={initKeyboardControls:r,cleanupKeyboardControls:i,registerKeyHandler:d,unregisterKeyHandler:u,getRegisteredKeyHandlers:c,setupCommonControls:s};export{i as cleanupKeyboardControls,w as default,c as getRegisteredKeyHandlers,r as initKeyboardControls,d as registerKeyHandler,s as setupCommonControls,u as unregisterKeyHandler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function n(n){if(!n)return null;var r=n.toUpperCase().replace(/\s+COMPONENT$/i,"").replace(/\s+/g,"-").replace(/[^A-Z0-9\-]/g,"");return r=r.replace(/-COMPONENT$/,"")}function r(r,u){var i=n(r),l=n(u);return i&&l&&i===l}function u(r,u){if(!r||!u)return null;var i=null;return r.traverse(function(r){var l;if(!i)if(r.uuid!==u)if((null===(l=r.userData)||void 0===l?void 0:l.originalUuid)!==u){if(r.name&&n(r.name)===u)return void(i=r)}else i=r;else i=r}),i}function i(r){var u;return r?null!==(u=r.userData)&&void 0!==u&&u.originalUuid?r.userData.originalUuid:r.uuid&&!r.uuid.includes("-")&&r.uuid.length>10?r.uuid:r.name?n(r.name):null:null}export{u as findObjectByHardcodedUuid,n as generateUuidFromName,i as getHardcodedUuid,r as namesGenerateSameUuid};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClass as t,objectSpread2 as e,construct as n,toConsumableArray as r,classCallCheck as i,createForOfIteratorHelper as a,asyncToGenerator as s,regenerator as o}from"../_virtual/_rollupPluginBabelHelpers.js";import*as u from"three";import{Pathfinder as h}from"../node_modules/@2112-lab/pathfinder/dist/index.esm.js";import{logger as c,pathfinderLogger as l}from"./debugLogger.js";import{generateUuidFromName as f}from"./nameUtils.js";var v=function(){return t(function t(e){i(this,t),this.component=e,this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null},[{key:"getPathfinderVersionInfo",value:(y=s(o().m(function t(){var e;return o().w(function(t){for(;;)switch(t.n){case 0:if(!this.pathfinderVersionInfo){t.n=1;break}return t.a(2,this.pathfinderVersionInfo);case 1:return e={version:"1.0.15",detectionMethod:"hardcoded-fallback",timestamp:(new Date).toISOString()},this.pathfinderVersionInfo=e,t.a(2,e)}},t,this)})),function(){return y.apply(this,arguments)})},{key:"logPathfinderVersion",value:(p=s(o().m(function t(){var e,n,r,i=arguments;return o().w(function(t){for(;;)switch(t.n){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:"Unknown Context",t.p=1,t.n=2,this.getPathfinderVersionInfo();case 2:n=t.v,l.info("[".concat(e,"] Pathfinder Module Information:"),{version:n.version,detectionMethod:n.detectionMethod,context:e,timestamp:n.timestamp,pathfinderInstance:!!this.pathfinder}),t.n=4;break;case 3:t.p=3,r=t.v,l.error("[".concat(e,"] Failed to get pathfinder version:"),r);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return p.apply(this,arguments)})},{key:"getPathColor",value:function(t){var e=["#468e49","#245e29","#2e80d2","#1d51a1"];return e[t%e.length]}},{key:"initializePathfinder",value:(m=s(o().m(function t(e,n){var r,i;return o().w(function(t){for(;;)switch(t.n){case 0:return r=this.component,this.crosscubeTextureSet=n,t.n=1,this.logPathfinderVersion("Scene Loading");case 1:this.pathfinder=new h(e),r.pathfinder=this.pathfinder,i=this.pathfinder.findPaths(),this.createPipePaths(i,n);case 2:return t.a(2)}},t,this)})),function(t,e){return m.apply(this,arguments)})},{key:"removeAllPaths",value:function(){var t=this.component,e=[];t.scene.traverse(function(t){t.name&&t.name.includes("Polyline")&&e.push(t)});for(var n=0,r=e;n<r.length;n++){var i=r[n];t.scene.remove(i),i.geometry&&i.geometry.dispose(),i.material&&(Array.isArray(i.material)?i.material.forEach(function(t){return t.dispose()}):i.material.dispose())}}},{key:"createPipeMaterial",value:function(t,i){if(t){var a=e(e({},t.config.materialProps),{},{color:this.getPathColor(i),map:t.textures.diffuse,normalMap:t.textures.normal,roughnessMap:t.textures.roughness,metalness:.2,roughness:.9,clearcoat:.2,clearcoatRoughness:.2,envMapIntensity:.6,reflectivity:.4});a.normalScale&&Array.isArray(a.normalScale)&&(a.normalScale=n(u.Vector2,r(a.normalScale)));var s=new u.MeshPhysicalMaterial(a);return[s.map,s.normalMap,s.roughnessMap].filter(Boolean).forEach(function(e){e.wrapS=e.wrapT=u.RepeatWrapping,e.repeat.set(2*t.config.repeat.x,2*t.config.repeat.y)}),s}return new u.MeshPhysicalMaterial({color:this.getPathColor(i),metalness:.9,roughness:.7,clearcoat:.1,clearcoatRoughness:.3,envMapIntensity:1.5,reflectivity:.3})}},{key:"createPipePaths",value:function(t,e){var n=this,r=this.component;t.forEach(function(t,i){if(t.path){var a=new u.Object3D;a.name="Polyline ".concat(t.from,"-").concat(t.to);for(var s=n.createPipeMaterial(e,i),o=0;o<t.path.length-1;o++){var h=t.path[o],c=t.path[o+1],l=(new u.Vector3).subVectors(c,h),f=l.length(),v=new u.CylinderGeometry(.1,.1,f,8,1,!1),d=new u.Mesh(v,s);d.position.copy(h).add(c).multiplyScalar(.5);var m=new u.Quaternion,p=new u.Vector3(0,1,0);if(m.setFromUnitVectors(p,l.normalize()),d.quaternion.copy(m),d.castShadow=!0,d.receiveShadow=!0,a.add(d),o<t.path.length-2){var y=t.path[o+1],w=t.path[o+2],g=l.normalize(),k=(new u.Vector3).subVectors(w,y).normalize(),P=Math.acos(g.dot(k));if(Math.abs(P-Math.PI/2)<.1){var M=new u.SphereGeometry(.1,16,16),b=new u.Mesh(M,s);b.position.copy(c),b.castShadow=!0,b.receiveShadow=!0,a.add(b)}}}a.name="Polyline",r.scene.add(a)}})}},{key:"recomputeWorldBoundingBoxes",value:function(t){this.component.scene.traverse(function(e){if(e.isMesh){var n=null,r=function(t){var n,i=a(t);try{for(i.s();!(n=i.n()).done;){var s,o,u=n.value;if(u.uuid===e.uuid||u.uuid===(null===(s=e.userData)||void 0===s?void 0:s.originalUuid)||e.uuid===(null===(o=u.userData)||void 0===o?void 0:o.originalUuid))return u;if(e.name&&u.name){var h=f(e.name),c=f(u.name);if(h===c||h===u.uuid||c===e.uuid)return u}if(e.name&&u.name&&e.name===u.name)return u;if(u.children){var l=r(u.children);if(l)return l}}}catch(t){i.e(t)}finally{i.f()}return null};if(n=r(t.scene.object.children)){var i=(new u.Box3).setFromObject(e);n.userData||(n.userData={}),n.userData.worldBoundingBox={min:i.min.toArray(),max:i.max.toArray()}}}})}},{key:"updatePathfindingWithConnections",value:(d=s(o().m(function t(e){var n,i,a;return o().w(function(t){for(;;)switch(t.n){case 0:if((n=this.component).currentSceneData){t.n=1;break}return t.a(2,!1);case 1:return this.removeAllPaths(),(i=JSON.parse(JSON.stringify(n.currentSceneData))).connections=r(e),t.n=2,this.logPathfinderVersion("Connections Update");case 2:return this.pathfinder=new h(i),n.pathfinder=this.pathfinder,a=this.pathfinder.findPaths(),this.createPipePaths(a,this.crosscubeTextureSet),n.currentSceneData=i,t.a(2,!0)}},t,this)})),function(t){return d.apply(this,arguments)})},{key:"updatePathfindingAfterTransform",value:(v=s(o().m(function t(e){var n;return o().w(function(t){for(;;)switch(t.n){case 0:return this.removeAllPaths(),t.n=1,this.logPathfinderVersion("Transform Update");case 1:this.pathfinder=new h(e),this.component.pathfinder=this.pathfinder,n=this.pathfinder.findPaths(),this.createPipePaths(n,this.crosscubeTextureSet);case 2:return t.a(2)}},t,this)})),function(t){return v.apply(this,arguments)})},{key:"dispose",value:function(){this.removeAllPaths(),this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null,c.info("PathfindingManager disposed")}}]);var v,d,m,p,y}();export{v as PathfindingManager};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClass as t,classCallCheck as i}from"../_virtual/_rollupPluginBabelHelpers.js";import"three";import{logger as s}from"./debugLogger.js";var e=function(){return t(function t(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;i(this,t),this.renderer=s,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.historySize=120,this.isRunning=!1,this.lastUpdateTime=0,this.warningThresholds={fps:30,frameTime:16,drawCalls:1e3,triangles:1e6,geometries:1e3,textures:100},this.callbacks={update:[],warning:[]},this.t=this.t.bind(this)},[{key:"start",value:function(){this.isRunning||(this.isRunning=!0,this.lastUpdateTime=performance.now(),this.i(),requestAnimationFrame(this.t),s.info("Performance monitoring started"))}},{key:"stop",value:function(){this.isRunning=!1,s.info("Performance monitoring stopped")}},{key:"reset",value:function(){this.stats.fps={current:0,average:0,min:1/0,max:0,history:[]},this.stats.frameTime={current:0,average:0,min:1/0,max:0,history:[]},this.frameCount=0,s.info("Performance statistics reset")}},{key:"_update",value:function(){if(this.isRunning){var t=performance.now(),i=t-this.lastUpdateTime;this.lastUpdateTime=t;var s=1e3/i;this.h("frameTime",i),this.h("fps",s),this.renderer&&this.o(),this.u(),this.frameCount++,this.l(),this.v("update",this.stats),requestAnimationFrame(this.t)}}},{key:"_updateStat",value:function(t,i){if(this.stats[t]){var s=this.stats[t];s.current=i,s.min=Math.min(s.min,i),s.max=Math.max(s.max,i),s.history.push(i),s.history.length>this.historySize&&s.history.shift(),s.average=s.history.reduce(function(t,i){return t+i},0)/s.history.length}}},{key:"_getWebGLInfo",value:function(){var t,i,s,e,h;if(this.renderer){var a=this.renderer.info;this.stats.drawCalls.current=(null===(t=a.render)||void 0===t?void 0:t.calls)||0,this.stats.drawCalls.triangles=(null===(i=a.render)||void 0===i?void 0:i.triangles)||0,this.stats.drawCalls.history||(this.stats.drawCalls.history=[]),this.stats.drawCalls.history.push(this.stats.drawCalls.current),this.stats.drawCalls.history.length>this.historySize&&this.stats.drawCalls.history.shift(),this.stats.drawCalls.average=this.stats.drawCalls.history.reduce(function(t,i){return t+i},0)/this.stats.drawCalls.history.length,this.stats.memory.geometries=(null===(s=a.memory)||void 0===s?void 0:s.geometries)||0,this.stats.memory.textures=(null===(e=a.memory)||void 0===e?void 0:e.textures)||0,this.stats.memory.programs=(null===(h=a.programs)||void 0===h?void 0:h.length)||0}}},{key:"_getMemoryInfo",value:function(){"undefined"!=typeof window&&window.performance&&window.performance.memory?(this.stats.memory.heapUsed=window.performance.memory.usedJSHeapSize,this.stats.memory.heapTotal=window.performance.memory.totalJSHeapSize):"undefined"!=typeof navigator&&navigator.deviceMemory&&(this.stats.memory.deviceMemory=navigator.deviceMemory)}},{key:"_getGPUInfo",value:function(){if(this.renderer){var t=this.renderer.getContext(),i=t.getExtension("WEBGL_debug_renderer_info");i?(this.stats.gpu.vendor=t.getParameter(i.UNMASKED_VENDOR_WEBGL),this.stats.gpu.renderer=t.getParameter(i.UNMASKED_RENDERER_WEBGL)):(this.stats.gpu.vendor=t.getParameter(t.VENDOR),this.stats.gpu.renderer=t.getParameter(t.RENDERER)),this.stats.gpu.extensions=t.getSupportedExtensions()}}},{key:"_checkWarnings",value:function(){var t=[];this.stats.fps.average<this.warningThresholds.fps&&t.push({type:"fps",message:"Low FPS: ".concat(this.stats.fps.average.toFixed(1)," (threshold: ").concat(this.warningThresholds.fps,")"),value:this.stats.fps.average,threshold:this.warningThresholds.fps}),this.stats.frameTime.average>this.warningThresholds.frameTime&&t.push({type:"frameTime",message:"High frame time: ".concat(this.stats.frameTime.average.toFixed(1),"ms (threshold: ").concat(this.warningThresholds.frameTime,"ms)"),value:this.stats.frameTime.average,threshold:this.warningThresholds.frameTime}),this.stats.drawCalls.average>this.warningThresholds.drawCalls&&t.push({type:"drawCalls",message:"High draw calls: ".concat(this.stats.drawCalls.average.toFixed(0)," (threshold: ").concat(this.warningThresholds.drawCalls,")"),value:this.stats.drawCalls.average,threshold:this.warningThresholds.drawCalls}),this.stats.drawCalls.triangles>this.warningThresholds.triangles&&t.push({type:"triangles",message:"High triangle count: ".concat(this.stats.drawCalls.triangles.toFixed(0)," (threshold: ").concat(this.warningThresholds.triangles,")"),value:this.stats.drawCalls.triangles,threshold:this.warningThresholds.triangles}),this.stats.memory.geometries>this.warningThresholds.geometries&&t.push({type:"geometries",message:"High geometry count: ".concat(this.stats.memory.geometries," (threshold: ").concat(this.warningThresholds.geometries,")"),value:this.stats.memory.geometries,threshold:this.warningThresholds.geometries}),this.stats.memory.textures>this.warningThresholds.textures&&t.push({type:"textures",message:"High texture count: ".concat(this.stats.memory.textures," (threshold: ").concat(this.warningThresholds.textures,")"),value:this.stats.memory.textures,threshold:this.warningThresholds.textures}),t.length>0&&this.v("warning",t)}},{key:"on",value:function(t,i){this.callbacks[t]&&this.callbacks[t].push(i)}},{key:"off",value:function(t,i){if(this.callbacks[t]){var s=this.callbacks[t].indexOf(i);-1!==s&&this.callbacks[t].splice(s,1)}}},{key:"_triggerCallbacks",value:function(t,i){this.callbacks[t]&&this.callbacks[t].forEach(function(t){try{t(i)}catch(t){}})}},{key:"logSummary",value:function(){return this.stats.gpu.renderer,this.stats}},{key:"exportData",value:function(){return{timestamp:(new Date).toISOString(),frameCount:this.frameCount,stats:JSON.parse(JSON.stringify(this.stats)),gpu:this.stats.gpu,warnings:this.m()}}},{key:"_getActiveWarnings",value:function(){var t=[];return this.stats.fps.average<this.warningThresholds.fps&&t.push({type:"fps",value:this.stats.fps.average}),this.stats.frameTime.average>this.warningThresholds.frameTime&&t.push({type:"frameTime",value:this.stats.frameTime.average}),this.stats.drawCalls.average>this.warningThresholds.drawCalls&&t.push({type:"drawCalls",value:this.stats.drawCalls.average}),this.stats.drawCalls.triangles>this.warningThresholds.triangles&&t.push({type:"triangles",value:this.stats.drawCalls.triangles}),this.stats.memory.geometries>this.warningThresholds.geometries&&t.push({type:"geometries",value:this.stats.memory.geometries}),this.stats.memory.textures>this.warningThresholds.textures&&t.push({type:"textures",value:this.stats.memory.textures}),t}},{key:"setWarningThresholds",value:function(t){Object.assign(this.warningThresholds,t)}}])}(),h=function(){return t(function t(s,e){var h=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"dark";i(this,t),this.monitor=s,this.container=e,this.theme=h,this.isVisible=!1,this.element=null,this.graphs={},this.p(),this.k()},[{key:"_createUI",value:function(){var t=this;this.element=document.createElement("div"),this.element.className="performance-monitor",this.element.style.position="absolute",this.element.style.top="10px",this.element.style.right="10px",this.element.style.zIndex="1000",this.element.style.padding="10px",this.element.style.borderRadius="5px",this.element.style.fontFamily="monospace",this.element.style.fontSize="12px",this.element.style.lineHeight="1.2",this.element.style.transition="opacity 0.3s ease",this.element.style.userSelect="none",this.setTheme(this.theme);var i=document.createElement("div");i.style.display="flex",i.style.justifyContent="space-between",i.style.marginBottom="5px";var s=document.createElement("div");s.textContent="Performance Monitor",s.style.fontWeight="bold";var e=document.createElement("div");e.textContent="×",e.style.cursor="pointer",e.style.paddingLeft="10px",e.onclick=function(){return t.hide()},i.appendChild(s),i.appendChild(e),this.element.appendChild(i);var h=document.createElement("div");this.statsElement=h,this.element.appendChild(h),this.element.style.opacity="0",this.element.style.pointerEvents="none"}},{key:"setTheme",value:function(t){this.theme=t,"dark"===t?(this.element.style.backgroundColor="rgba(0, 0, 0, 0.7)",this.element.style.color="white",this.element.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.5)"):(this.element.style.backgroundColor="rgba(255, 255, 255, 0.85)",this.element.style.color="black",this.element.style.boxShadow="0 0 10px rgba(0, 0, 0, 0.1)")}},{key:"_setupUpdateLoop",value:function(){var t=this;setInterval(function(){if(t.isVisible&&t.monitor){var i="",s=t._(t.monitor.stats.fps.current,60,30);i+='<div>FPS: <span style="color: '.concat(s,'">').concat(t.monitor.stats.fps.current.toFixed(1),"</span> "),i+="(avg: ".concat(t.monitor.stats.fps.average.toFixed(1),")</div>");var e=t._(16-t.monitor.stats.frameTime.current,0,16,!0);i+='<div>Frame: <span style="color: '.concat(e,'">').concat(t.monitor.stats.frameTime.current.toFixed(1),"ms</span></div>");var h=t._(1e3-t.monitor.stats.drawCalls.current,0,1e3,!0);i+='<div>Calls: <span style="color: '.concat(h,'">').concat(t.monitor.stats.drawCalls.current,"</span> "),i+="Tris: ".concat(t.C(t.monitor.stats.drawCalls.triangles),"</div>"),i+="<div>Geo: ".concat(t.monitor.stats.memory.geometries," "),i+="Tex: ".concat(t.monitor.stats.memory.textures,"</div>"),t.statsElement.innerHTML=i}},500)}},{key:"_getMetricColor",value:function(t,i,s){var e=arguments.length>3&&void 0!==arguments[3]&&arguments[3],h=(t-s)/(i-s);h=Math.max(0,Math.min(1,h)),e&&(h=1-h);var a=h<.5?255:Math.floor(255*(1-h)*2),r=h>.5?255:Math.floor(255*h*2);return"rgb(".concat(a,", ").concat(r,", ").concat(0,")")}},{key:"_formatNumber",value:function(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toString()}},{key:"show",value:function(){this.isVisible||(this.isVisible=!0,this.element.style.opacity="1",this.element.style.pointerEvents="auto",this.element.parentElement||this.container.appendChild(this.element))}},{key:"hide",value:function(){this.isVisible&&(this.isVisible=!1,this.element.style.opacity="0",this.element.style.pointerEvents="none")}},{key:"toggle",value:function(){this.isVisible?this.hide():this.show()}},{key:"dispose",value:function(){this.element.parentElement&&this.element.parentElement.removeChild(this.element)}}])}(),a={PerformanceMonitor:e,PerformanceUI:h};export{e as PerformanceMonitor,h as PerformanceUI,a as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClass as n,classCallCheck as e,toConsumableArray as t}from"../_virtual/_rollupPluginBabelHelpers.js";import{getHardcodedUuid as r}from"./nameUtils.js";var o=function(){return n(function n(t){e(this,n),this.component=t},[{key:"exportSceneData",value:function(){var n=this;if(!this.component.scene)return null;var e=function(n){var t,o,l,a,i,u,s,c,d=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(!(d||null!==(u=n.userData)&&void 0!==u&&u.componentType))return null;if(d&&(null===(s=n.userData)||void 0===s||!s.forExport))return null;if(d&&null!==(c=n.userData)&&void 0!==c&&c.forExport);var v,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])}),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!==(v=n.name)&&void 0!==v&&v.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.component.scene.children.forEach(function(n){var t=e(n);t&&o.push(t)});var l,a,i={connections:(a=[],null!==(l=n.component.currentSceneData)&&void 0!==l&&l.connections&&a.push.apply(a,t(n.component.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);if("undefined"!=typeof window&&"undefined"!=typeof document){var 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}return!1}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.component.scene)return null;var e=0;return this.component.scene.traverse(function(){return e++}),{totalObjects:e,hasCurrentSceneData:!!this.component.currentSceneData,connectionsCount:(null===(n=this.component.currentSceneData)||void 0===n||null===(n=n.connections)||void 0===n?void 0:n.length)||0,exportTimestamp:(new Date).toISOString()}}}])}();function l(n){return new o(n)}export{o as SceneExportManager,o as default,l as getSceneExportManager};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClass as e,asyncToGenerator as n,regenerator as i,classCallCheck as r}from"../_virtual/_rollupPluginBabelHelpers.js";import*as t from"three";import{logger as o}from"./debugLogger.js";var a,u,s,l;function c(){return f.apply(this,arguments)}function f(){return(f=n(i().m(function e(){var n,r,t,o;return i().w(function(e){for(;;)switch(e.n){case 0:if("undefined"==typeof window){e.n=15;break}return e.p=1,e.p=2,e.n=3,import("../node_modules/three/examples/jsm/controls/OrbitControls.js");case 3:n=e.v,a=n.OrbitControls,e.n=9;break;case 4:if(e.p=4,e.v,e.p=5,"string"!=typeof window.__orbitControlsCustomPath){e.n=7;break}return e.n=6,import(window.__orbitControlsCustomPath);case 6:r=e.v,a=r.OrbitControls;case 7:e.n=9;break;case 8:e.p=8,e.v;case 9:return e.p=9,e.n=10,import("../node_modules/three/examples/jsm/loaders/GLTFLoader.js");case 10:t=e.v,u=t.GLTFLoader,e.n=12;break;case 11:e.p=11,e.v;case 12:return e.n=13,import("./performanceMonitor.js");case 13:o=e.v,s=o.PerformanceMonitor,l=o.PerformanceUI,e.n=15;break;case 14:e.p=14,e.v;case 15:return e.a(2)}},e,null,[[9,11],[5,8],[2,4],[1,14]])}))).apply(this,arguments)}var d=function(){return e(function e(n){r(this,e),this.component=n,this.textureLoader=null,this.gltfLoader=null,c()},[{key:"initializeScene",value:(v=n(i().m(function e(){var n,r,a,u,s,l;return i().w(function(e){for(;;)switch(e.n){case 0:if(a=this.component){e.n=1;break}return o.error("Cannot initialize scene: component not available"),e.a(2);case 1:if(a.scene=new t.Scene,u=(null===(n=a.$refs)||void 0===n||null===(n=n.container)||void 0===n?void 0:n.getBoundingClientRect())||{width:800,height:600},s=u.width,l=u.height,a.camera=new t.PerspectiveCamera(50,s/l,.01,1e3),a.camera.position.set(-8,4,9),null===(r=a.$refs)||void 0===r||!r.container){e.n=2;break}return e.n=2,this.setupRenderer(a.$refs.container,s,l);case 2:return o.info("Scene and camera initialized"),e.a(2,{scene:a.scene,camera:a.camera})}},e,this)})),function(){return v.apply(this,arguments)})},{key:"setupRenderer",value:(d=n(i().m(function e(n,r,a){var s,l;return i().w(function(e){for(;;)switch(e.n){case 0:if(s=this.component){e.n=1;break}return o.error("Cannot setup renderer: component not available"),e.a(2,null);case 1:if(r&&a||(l=n.getBoundingClientRect(),r=l.width,a=l.height),s.renderer=new t.WebGLRenderer({antialias:!0}),s.renderer.setSize(r,a),s.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),s.renderer.shadowMap.enabled=!0,s.renderer.shadowMap.type=t.PCFSoftShadowMap,s.renderer.physicallyCorrectLights=!0,s.renderer.outputColorSpace=t.SRGBColorSpace,s.renderer.toneMapping=t.LinearToneMapping,s.renderer.toneMappingExposure=1.5,n.appendChild(s.renderer.domElement),this.setupResizeHandler(),s.textureLoader=new t.TextureLoader,this.textureLoader=s.textureLoader,!u){e.n=2;break}s.gltfLoader=new u,this.gltfLoader=s.gltfLoader,e.n=4;break;case 2:return e.n=3,c();case 3:u&&(s.gltfLoader=new u,this.gltfLoader=s.gltfLoader);case 4:return o.info("Renderer initialized"),e.a(2,s.renderer)}},e,this)})),function(e,n,i){return d.apply(this,arguments)})},{key:"setupControls",value:function(e){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.component;return r&&r.camera&&r.renderer?a?this.setupControlsInternal(e,i):(o.info("OrbitControls not available, will try to import"),c().then(function(){a&&n.setupControlsInternal(e,i)}),null):(o.error("Cannot setup controls: camera or renderer not available"),null)}},{key:"setupControlsInternal",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.component,r=e||i.renderer.domElement;return i.controls=new a(i.camera,r),i.controls.enableDamping=!1!==n.enableDamping,i.controls.dampingFactor=n.dampingFactor||.05,i.controls.screenSpacePanning=!1!==n.screenSpacePanning,i.controls.maxPolarAngle=n.maxPolarAngle||Math.PI/1.5,i.controls.minDistance=n.minDistance||2,i.controls.maxDistance=n.maxDistance||50,n.target&&i.controls.target.copy(n.target),n.autoRotate&&(i.controls.autoRotate=!0,i.controls.autoRotateSpeed=n.autoRotateSpeed||1),o.info("Orbit controls initialized"),i.controls}},{key:"initializePerformanceMonitoring",value:(f=n(i().m(function e(){var n,r;return i().w(function(e){for(;;)switch(e.n){case 0:if((r=this.component)&&r.renderer){e.n=1;break}return o.error("Cannot initialize performance monitoring: renderer not available"),e.a(2);case 1:if(s){e.n=3;break}return e.n=2,c();case 2:if(s){e.n=3;break}return o.error("Performance monitoring not available"),e.a(2);case 3:return r.performanceMonitor=new s(r.renderer),null!==(n=r.$refs)&&void 0!==n&&n.container&&(r.performanceUI=new l(r.performanceMonitor,r.$refs.container,"light")),r.performanceMonitor.on("warning",function(e){}),r.performanceMonitor.start(),r.performanceUI&&r.performanceUI.show(),this.exposePerformanceMonitoringGlobally(),o.info("Performance monitoring initialized"),e.a(2,{monitor:r.performanceMonitor,ui:r.performanceUI})}},e,this)})),function(){return f.apply(this,arguments)})},{key:"exposePerformanceMonitoringGlobally",value:function(){var e=this.component;e&&e.performanceMonitor&&"undefined"!=typeof window&&(window._performanceMonitor=e.performanceMonitor,window._performanceUI=e.performanceUI,window.performance3D={show:function(){var n;return null===(n=e.performanceUI)||void 0===n?void 0:n.show()},hide:function(){var n;return null===(n=e.performanceUI)||void 0===n?void 0:n.hide()},toggle:function(){var n,i,r;return null!==(n=e.performanceUI)&&void 0!==n&&n.isVisible?null===(i=e.performanceUI)||void 0===i?void 0:i.hide():null===(r=e.performanceUI)||void 0===r?void 0:r.show()},setTheme:function(n){var i;return null===(i=e.performanceUI)||void 0===i?void 0:i.setTheme(n)},log:function(){var n;return null===(n=e.performanceMonitor)||void 0===n?void 0:n.logSummary()},reset:function(){var n;return null===(n=e.performanceMonitor)||void 0===n?void 0:n.reset()},export:function(){var n;return null===(n=e.performanceMonitor)||void 0===n?void 0:n.exportData()},help:function(){}},o.info("Performance monitoring exposed to global scope"))}},{key:"setupResizeHandler",value:function(){var e,n=this.component;if(n&&null!==(e=n.$refs)&&void 0!==e&&e.container){var i=function(){if(n.renderer&&n.camera){var e=n.$refs.container,i=e.clientWidth,r=e.clientHeight;n.camera.aspect=i/r,n.camera.updateProjectionMatrix(),n.renderer.setSize(i,r),n.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}};i(),window.addEventListener("resize",i),this.i=i,o.info("Resize handler initialized")}}},{key:"cleanupResizeHandler",value:function(){this.i&&(window.removeEventListener("resize",this.i),this.i=null)}}]);var f,d,v}(),v=null;function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return(!v||e&&v.component!==e)&&(v=new d(e)),v}function w(e,n){return m.apply(this,arguments)}function m(){return(m=n(i().m(function e(n,r){var t;return i().w(function(e){for(;;)switch(e.n){case 0:return t=h(n),e.n=1,t.initializeScene();case 1:if(!r){e.n=3;break}return e.n=2,t.setupRenderer(r);case 2:t.setupControls(r);case 3:return e.a(2,t)}},e)}))).apply(this,arguments)}var p={SceneInitializationManager:d,getSceneInitializationManager:h,setupScene:w};export{d as SceneInitializationManager,p as default,h as getSceneInitializationManager,w as setupScene};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{asyncToGenerator as e,regenerator as n,slicedToArray as t,objectSpread2 as r}from"../_virtual/_rollupPluginBabelHelpers.js";import*as a from"three";function o(e){if(e.startsWith("/")&&(e=e.substring(1)),"undefined"!=typeof window){var n="undefined"!=typeof CentralPlantUtils;if("localhost"===window.location.hostname&&("3000"===window.location.port||"3001"===window.location.port))return"/".concat(e);if(n){var t=import.meta.url;return new URL("./assets/".concat(e),t).href}var r=import.meta.url;return new URL("../assets/".concat(e),r).href}return"assets/".concat(e)}var s={light_metal:{localPath:"textures/gravel_embedded_concrete_1k",path:"https://central-plant-assets.s3.us-east-1.amazonaws.com/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:{localPath:"textures/pavement_03_1k",path:"https://central-plant-assets.s3.us-east-1.amazonaws.com/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:{localPath:"textures/gravel_embedded_concrete_1k",path:"https://central-plant-assets.s3.us-east-1.amazonaws.com/textures/gravel_embedded_concrete_1k",files:{diffuse:"diffuse.jpg",normal:"normal.jpg",roughness:"rough.jpg"},repeat:{x:3,y:3},materialProps:{color:16777215,roughness:.9,metalness:.1,normalScale:[1,1],bumpScale:.1}}};function u(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{x:1,y:1};e||(e=new a.TextureLoader);try{var r=f(13421772),o=new Promise(function(r,o){e.load(n,function(e){!e.image||!(e.image instanceof HTMLImageElement&&e.image.complete)&&e.image instanceof HTMLImageElement?o(new Error("Texture loaded but image data not ready")):(void 0!==e.colorSpace?e.colorSpace=a.SRGBColorSpace:void 0!==e.encoding&&(e.encoding=a.sRGBEncoding),e.wrapS=a.RepeatWrapping,e.wrapT=a.RepeatWrapping,e.repeat.set(t.x,t.y),e.needsUpdate=!0,r(e))},function(e){if(e.lengthComputable)e.loaded,e.total},function(e){o(e)})});return r.wrapS=a.RepeatWrapping,r.wrapT=a.RepeatWrapping,r.repeat.set(t.x,t.y),r.loadPromise=o,r.url=n,o.then(function(e){Object.keys(e).forEach(function(n){["uuid","id","version","isTexture"].includes(n)||(r[n]=e[n])}),r.image=e.image,r.source=e.source,r.needsUpdate=!0}).catch(function(){}),r}catch(e){return f(14496563)}}function i(e,n){return c.apply(this,arguments)}function c(){return c=e(n().m(function i(c,f){var d,m,p,v,h,g,w,b,_,y,x,j,k,T,M,P,S,E;return n().w(function(i){for(;;)switch(i.n){case 0:if(c){i.n=1;break}return i.a(2,new a.MeshStandardMaterial({color:11184810}));case 1:if(m=s[f]){i.n=2;break}return i.a(2,new a.MeshStandardMaterial({color:11184810}));case 2:return"function"==typeof(p=c.textureLoader||new a.TextureLoader).setCrossOrigin&&p.setCrossOrigin("anonymous"),v=m.repeat||{x:1,y:1},h={},g=function(){var t=e(n().m(function e(t){return n().w(function(e){for(;;)switch(e.n){case 0:if("undefined"==typeof window){e.n=1;break}return e.a(2,new Promise(function(e){var n=new Image;n.onload=function(){return e(!0)},n.onerror=function(){return e(!1)},n.src=t,setTimeout(function(){return e(!1)},2e3)}));case 1:return e.a(2,!1)}},e)}));return function(e){return t.apply(this,arguments)}}(),w=function(){var t=e(n().m(function e(t){var r,a,s,i;return n().w(function(e){for(;;)switch(e.n){case 0:if(m.files[t]){e.n=1;break}return e.a(2,null);case 1:r=[],m.localPath&&r.push(o("".concat(m.localPath,"/").concat(m.files[t]))),r.push("/textures/".concat(f,"_1k/").concat(m.files[t])),m.path&&r.push("".concat(m.path,"/").concat(m.files[t])),a=0,s=r;case 2:if(!(a<s.length)){e.n=6;break}return i=s[a],e.n=3,g(i);case 3:if(!e.v){e.n=4;break}return e.a(2,u(p,i,v));case 4:case 5:a++,e.n=2;break;case 6:return e.a(2,null)}},e)}));return function(e){return t.apply(this,arguments)}}(),b=Object.keys(m.files).map(function(){var t=e(n().m(function e(t){return n().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,w(t);case 1:return h[t]=e.v,e.a(2,{type:t,texture:h[t]})}},e)}));return function(e){return t.apply(this,arguments)}}()),i.n=3,Promise.all(b);case 3:if(Object.entries(h).forEach(function(e){var n=t(e,2);n[0],n[1]}),_=Object.values(h).some(function(e){return null!==e}),_){i.n=4;break}return x=(null===(y=m.materialProps)||void 0===y?void 0:y.color)||11184810,i.a(2,new a.MeshStandardMaterial({color:x,roughness:.8,metalness:.2,side:a.DoubleSide}));case 4:for(j={},k=0,T=Object.entries(h);k<T.length;k++)M=t(T[k],2),P=M[0],((S=M[1])&&l(S)||S)&&(j[P]=S);return(E=new a.MeshStandardMaterial(r(r({map:j.diffuse,normalMap:j.normal,roughnessMap:j.roughness,metalnessMap:j.metalness,aoMap:j.ao,displacementMap:j.displacement},m.materialProps),{},{side:a.DoubleSide}))).map&&l(E.map)||null===(d=m.materialProps)||void 0===d||!d.color||(E.color=new a.Color(m.materialProps.color)),E.needsUpdate=!0,c.scene&&c.scene.environment&&(E.envMap=c.scene.environment),Object.entries(j).forEach(function(e){var n=t(e,2),r=(n[0],n[1]);r&&r.loadPromise&&r.loadPromise.then(function(){E.needsUpdate=!0}).catch(function(e){})}),i.a(2,E)}},i)})),c.apply(this,arguments)}function l(e){return!!e&&(!!e.image&&(e.image instanceof HTMLImageElement||e.image instanceof HTMLCanvasElement?e.image.width>0&&e.image.height>0:!(!e.image.data||!Array.isArray(e.image.data))&&e.image.data.length>0))}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:13421772,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64,t=document.createElement("canvas");t.width=n,t.height=n;var r=t.getContext("2d");if(r){var o="#"+e.toString(16).padStart(6,"0");r.fillStyle=o,r.fillRect(0,0,n,n),r.fillStyle="#"+(e+2236962&16777215).toString(16),r.fillRect(0,0,n/2,n/2),r.fillRect(n/2,n/2,n/2,n/2)}var s=new a.CanvasTexture(t);return s.needsUpdate=!0,void 0!==s.colorSpace?s.colorSpace=a.SRGBColorSpace:void 0!==s.encoding&&(s.encoding=a.sRGBEncoding),s}function d(){return{version:a.REVISION,hasNewColorSpace:void 0!==a.SRGBColorSpace,hasOldEncoding:void 0!==a.sRGBEncoding,hasTextureLoader:"function"==typeof a.TextureLoader}}function m(e){if(e){e.traverse(function(e){e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(function(e){e&&(e.needsUpdate=!0,e.map&&(e.map.needsUpdate=!0),e.normalMap&&(e.normalMap.needsUpdate=!0),e.roughnessMap&&(e.roughnessMap.needsUpdate=!0))})})}}var p={TEXTURE_SETS:s,createTexture:u,loadTextureSetAndCreateMaterial:i,checkThreeJSCompatibility:d,forceUpdateMaterials:m,hasValidImageData:l,createPlaceholderTexture:f};export{s as TEXTURE_SETS,d as checkThreeJSCompatibility,u as createTexture,p as default,m as forceUpdateMaterials,i as loadTextureSetAndCreateMaterial};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClass as t,classCallCheck as i,asyncToGenerator as s,regenerator as e}from"../_virtual/_rollupPluginBabelHelpers.js";var n,h;function o(){return a.apply(this,arguments)}function a(){return(a=s(e().m(function t(){var i,s;return e().w(function(t){for(;;)switch(t.n){case 0:if("undefined"==typeof window){t.n=9;break}return t.p=1,t.n=2,import("three");case 2:return n=t.v,t.p=3,t.n=4,import("../node_modules/three/examples/jsm/controls/TransformControls.js");case 4:i=t.v,h=i.TransformControls,t.n=7;break;case 5:if(t.p=5,t.v,"string"!=typeof window.__transformControlsCustomPath){t.n=7;break}return t.n=6,import(window.__transformControlsCustomPath);case 6:s=t.v,h=s.TransformControls;case 7:t.n=9;break;case 8:throw t.p=8,t.v,new Error("TransformControlsManager: Required dependencies could not be loaded");case 9:return t.a(2)}},t,null,[[3,5],[1,8]])}))).apply(this,arguments)}var r=function(){return t(function t(s,e,n){var h=this,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;i(this,t),this.scene=s,this.camera=e,this.renderer=n,this.orbitControls=a,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,pointerdown:null,pointerup:null,transformStart:null,transformEnd:null,transforming:null},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},"undefined"!=typeof window&&o().then(function(){return h.init()})},[{key:"init",value:(a=s(e().m(function t(){return e().w(function(t){for(;;)switch(t.n){case 0:if("undefined"==typeof window||n){t.n=1;break}return t.n=1,o();case 1:this.createTransformControls(),this.setupEventListeners(),this.setupKeyboardControls();case 2:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{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)}},{key:"createTransformControls",value:function(){n&&h&&(this.transformControls||(this.transformControls=new h(this.camera,this.renderer.domElement),this.transformControls.size=this.config.size,this.transformControls.enabled=this.config.enabled,this.transformControls.visible=this.config.enabled&&!this.forceInvisible,this.transformControls.setMode(this.currentMode),this.transformControls.setSpace(this.currentSpace),this.transformControls.userData={isTransformControls:!0},this.scene.add(this.transformControls)))}},{key:"setupEventListeners",value:function(){var t=this;this.transformControls&&(this.removeEventListeners(),this.eventHandlers.transformStart=function(i){t.transformState.isTransforming=!0,t.selectedObject&&(t.transformState.initialTransform=t.captureObjectTransform(t.selectedObject),t.callbacks.onTransformStart&&t.callbacks.onTransformStart(t.selectedObject,t.transformState.initialTransform))},this.eventHandlers.transforming=function(i){t.selectedObject&&t.transformState.isTransforming&&(t.transformState.currentTransform=t.captureObjectTransform(t.selectedObject),t.callbacks.onTransform&&t.callbacks.onTransform(t.selectedObject,t.transformState.currentTransform,t.transformState.initialTransform),t.updateBoundingBox())},this.eventHandlers.transformEnd=function(i){if(t.selectedObject){var s=t.captureObjectTransform(t.selectedObject);t.callbacks.onTransformEnd&&t.callbacks.onTransformEnd(t.selectedObject,s,t.transformState.initialTransform)}t.transformState.isTransforming=!1},this.transformControls.addEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.addEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.addEventListener("mouseUp",this.eventHandlers.transformEnd),this.orbitControls&&this.transformControls.addEventListener("dragging-changed",function(i){t.orbitControls.enabled=!i.value}))}},{key:"setupKeyboardControls",value:function(){var t=this;"undefined"!=typeof window&&"undefined"!=typeof document&&(this.eventHandlers.keydown&&document.removeEventListener("keydown",this.eventHandlers.keydown),this.eventHandlers.keydown=function(i){if(t.config.enabled&&t.selectedObject)switch(i.key.toLowerCase()){case"g":t.setMode("translate");break;case"r":t.setMode("rotate");break;case"s":t.setMode("scale");break;case" ":t.toggleVisibility();break;case"escape":t.deselectObject();break;case"x":i.shiftKey?(t.config.showX=!t.config.showX,t.updateAxisVisibility()):(t.transformControls.showX=!0,t.transformControls.showY=!1,t.transformControls.showZ=!1);break;case"y":i.shiftKey?(t.config.showY=!t.config.showY,t.updateAxisVisibility()):(t.transformControls.showX=!1,t.transformControls.showY=!0,t.transformControls.showZ=!1);break;case"z":i.shiftKey?(t.config.showZ=!t.config.showZ,t.updateAxisVisibility()):(t.transformControls.showX=!1,t.transformControls.showY=!1,t.transformControls.showZ=!0);break;case"q":t.toggleSpace()}},document.addEventListener("keydown",this.eventHandlers.keydown))}},{key:"removeEventListeners",value:function(){this.transformControls&&(this.transformControls.removeEventListener("mouseDown",this.eventHandlers.transformStart),this.transformControls.removeEventListener("objectChange",this.eventHandlers.transforming),this.transformControls.removeEventListener("mouseUp",this.eventHandlers.transformEnd)),"undefined"!=typeof document&&this.eventHandlers.keydown&&document.removeEventListener("keydown",this.eventHandlers.keydown)}},{key:"selectObject",value:function(t){if(this.config.enabled&&this.transformControls&&t)return this.deselectObject(),this.selectedObject=t,this.transformControls.attach(t),this.config.showBoundingBox&&this.showBoundingBox(t),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(t,!0),this.forceInvisible||(this.transformControls.visible=!0),t}},{key:"deselectObject",value:function(){if(this.selectedObject){this.transformControls&&this.transformControls.detach(),this.hideBoundingBox(),this.callbacks.onObjectSelect&&this.callbacks.onObjectSelect(this.selectedObject,!1);var t=this.selectedObject;return this.selectedObject=null,this.ensureSceneAttachment(!1),t}return null}},{key:"setMode",value:function(t){if(this.transformControls&&["translate","rotate","scale"].includes(t)){switch(this.currentMode=t,this.transformControls.setMode(t),t){case"translate":this.transformControls.setTranslationSnap(this.config.translationSnap);break;case"rotate":this.transformControls.setRotationSnap(this.config.rotationSnap);break;case"scale":this.transformControls.setScaleSnap(this.config.scaleSnap)}this.callbacks.onModeChange&&this.callbacks.onModeChange(t)}}},{key:"toggleSpace",value:function(){this.transformControls&&(this.currentSpace="world"===this.currentSpace?"local":"world",this.transformControls.setSpace(this.currentSpace))}},{key:"toggleVisibility",value:function(){this.transformControls&&(this.forceInvisible||(this.transformControls.visible=!this.transformControls.visible))}},{key:"setEnabled",value:function(t){this.config.enabled=t,this.transformControls&&(this.transformControls.enabled=t,t?this.selectedObject&&!this.forceInvisible&&(this.transformControls.visible=!0):(this.deselectObject(),this.transformControls.visible=!1))}},{key:"updateAxisVisibility",value:function(){this.transformControls&&(this.transformControls.showX=this.config.showX,this.transformControls.showY=this.config.showY,this.transformControls.showZ=this.config.showZ)}},{key:"showBoundingBox",value:function(t){if(t&&n){this.hideBoundingBox();var i=this.boundingBoxCache.get(t);i||(i=(new n.Box3).setFromObject(t),this.boundingBoxCache.set(t,i)),this.boundingBoxHelper?this.boundingBoxHelper.box=i:(this.boundingBoxHelper=new n.Box3Helper(i,this.config.boundingBoxColor),this.scene.add(this.boundingBoxHelper)),t.userData.worldBoundingBox=i}}},{key:"hideBoundingBox",value:function(){this.boundingBoxHelper&&(this.scene.remove(this.boundingBoxHelper),this.boundingBoxHelper=null)}},{key:"updateBoundingBox",value:function(){if(this.selectedObject&&this.config.showBoundingBox){var t=(new n.Box3).setFromObject(this.selectedObject);this.boundingBoxCache.set(this.selectedObject,t),this.boundingBoxHelper&&(this.boundingBoxHelper.box=t),this.selectedObject.userData.worldBoundingBox=t}}},{key:"captureObjectTransform",value:function(t){return t?{position:{x:t.position.x,y:t.position.y,z:t.position.z},rotation:{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z},scale:{x:t.scale.x,y:t.scale.y,z:t.scale.z}}:null}},{key:"setSnapValues",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.transformControls){if(void 0!==t.translation&&(this.config.translationSnap=t.translation,"translate"===this.currentMode&&this.transformControls.setTranslationSnap(t.translation)),void 0!==t.rotation){var i=t.rotation*(Math.PI/180);this.config.rotationSnap=i,"rotate"===this.currentMode&&this.transformControls.setRotationSnap(i)}void 0!==t.scale&&(this.config.scaleSnap=t.scale,"scale"===this.currentMode&&this.transformControls.setScaleSnap(t.scale))}}},{key:"setSize",value:function(t){this.config.size=t,this.transformControls&&(this.transformControls.size=t)}},{key:"dispose",value:function(){this.removeEventListeners(),this.hideBoundingBox(),this.transformControls&&(this.transformControls.detach(),this.scene.remove(this.transformControls),this.transformControls=null),this.selectedObject=null,this.boundingBoxCache=new WeakMap}},{key:"ensureSceneAttachment",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return!(!this.transformControls||!this.scene)&&(!this.scene.children.includes(this.transformControls)&&(this.scene.add(this.transformControls),this.transformControls.visible=t&&!this.forceInvisible&&this.config.enabled,!0))}},{key:"getTransformData",value:function(){if(!this.selectedObject)return null;var t=new n.Vector3;this.selectedObject.getWorldPosition(t);var i=new n.Quaternion;this.selectedObject.getWorldQuaternion(i);var s=(new n.Euler).setFromQuaternion(i),e=new n.Vector3;return this.selectedObject.getWorldScale(e),{uuid:this.selectedObject.uuid,position:{x:this.selectedObject.position.x,y:this.selectedObject.position.y,z:this.selectedObject.position.z},rotation:{x:this.selectedObject.rotation.x,y:this.selectedObject.rotation.y,z:this.selectedObject.rotation.z},scale:{x:this.selectedObject.scale.x,y:this.selectedObject.scale.y,z:this.selectedObject.scale.z},worldPosition:{x:t.x,y:t.y,z:t.z},worldRotation:{x:s.x,y:s.y,z:s.z},worldScale:{x:e.x,y:e.y,z:e.z}}}}]);var a}();function u(t,i,s,e){return new r(t,i,s,e)}export{r as TransformControlsManager,r as default,u as getTransformControlsManager};
|