@shopware-ag/dive 2.2.3 → 2.2.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/build/chunks/{AssetCache-C1x_3etl.cjs → AssetCache-BNppFVgO.cjs} +1 -1
- package/build/chunks/{AssetCache-kFHaTt4q.mjs → AssetCache-BQFuZyej.mjs} +1 -1
- package/build/chunks/{AssetLoader-CChuNBTq.mjs → AssetLoader-E2Xdqd44.mjs} +2 -2
- package/build/chunks/{AssetLoader-D4IN0yOZ.cjs → AssetLoader-rt-Pr_wb.cjs} +1 -1
- package/build/chunks/{FileTypes-HNcEuUhi.mjs → FileTypes-C6ZTNzXM.mjs} +37 -39
- package/build/chunks/{FileTypes-Fd6DeJyo.cjs → FileTypes-CXhRE6Gs.cjs} +2 -2
- package/build/chunks/HDREnvorinment-D9NfhUuA.mjs +255 -0
- package/build/chunks/HDREnvorinment-DBz-m4DU.cjs +5 -0
- package/build/chunks/{SelectTool-DAZe_dB4.mjs → SelectTool-B6qvhxVy.mjs} +1 -1
- package/build/chunks/{SelectTool-gpfuLJfp.cjs → SelectTool-L7SsQpDR.cjs} +1 -1
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +2 -2
- package/build/engine/scene/Scene.d.ts +2 -2
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +1 -1
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +1 -1
- package/build/plugins/hdr/index.cjs +1 -0
- package/build/plugins/hdr/index.d.ts +2 -0
- package/build/plugins/hdr/index.mjs +5 -0
- package/build/plugins/hdr/src/HDREnvorinment.d.ts +33 -0
- package/build/plugins/hdr/src/index.d.ts +1 -0
- package/build/plugins/hdr/types/HDREnvironmentSettings.d.ts +44 -0
- package/build/plugins/hdr/types/index.d.ts +1 -0
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -1
- package/build/plugins/orientationdisplay/index.mjs +1 -1
- package/build/plugins/quickview/index.cjs +1 -1
- package/build/plugins/quickview/index.mjs +18 -10
- package/build/plugins/quickview/src/QuickView.d.ts +3 -1
- package/build/plugins/quickview/types/QuickViewSettings.d.ts +5 -0
- package/build/plugins/state/index.cjs +1 -1
- package/build/plugins/state/index.mjs +2 -2
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +2 -2
- package/package.json +6 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var te=Object.defineProperty;var ie=(h,r,e)=>r in h?te(h,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[r]=e;var i=(h,r,e)=>ie(h,typeof r!="symbol"?r+"":r,e);const s=require("three"),l=require("./PerspectiveCamera-iAsZqrnY.cjs"),b=require("three-spritetext");class A{constructor(){i(this,"isDIVEClock",!0);i(this,"_lastTime",0);i(this,"_isRunning",!1);i(this,"_tickers",[])}start(){this._isRunning||(this._isRunning=!0,this._lastTime=performance.now(),requestAnimationFrame(this._tick.bind(this)))}stop(){this._isRunning=!1}addTicker(r){this._tickers.find(e=>e.uuid===r.uuid)||this._tickers.push(r)}hasTicker(r){return this._tickers.find(e=>e.uuid===r.uuid)!==void 0}removeTicker(r){const e=this._tickers.findIndex(t=>t.uuid===r.uuid);e!==-1&&this._tickers.splice(e,1)}dispose(){this.stop(),this._tickers=[],this._isRunning=!1,this._lastTime=0}_tick(r){if(!this._isRunning)return;const e=(r-this._lastTime)/1e3;this._lastTime=r,this._tickers.forEach(t=>t.tick(e)),requestAnimationFrame(this._tick.bind(this))}}const M={canvas:void 0,antialias:!0,alpha:!0,powerPreference:"high-performance",precision:"highp",stencil:!1,depth:!0,logarithmicDepthBuffer:!1,shadows:!0,shadowQuality:"high"};class I{constructor(r,e,t){i(this,"isDIVERenderer",!0);i(this,"_webglrenderer");i(this,"_settings");this._scene=r,this._camera=e,this._settings={...M,...t??{}},this._webglrenderer=this._createWebGLRenderer()}get webglrenderer(){return this._webglrenderer}get canvas(){return this._webglrenderer.domElement}render(){this._webglrenderer.render(this._scene,this._camera)}onResize(r,e){this._webglrenderer.setSize(r,e,!1)}dispose(){this._webglrenderer.dispose()}setCanvas(r){this._webglrenderer.dispose(),this._settings.canvas=r,this._webglrenderer=this._createWebGLRenderer()}_createWebGLRenderer(){const r=new s.WebGLRenderer(this._settings);return r.shadowMap.enabled=this._settings.shadows,r.shadowMap.type=this._settings.shadowQuality==="high"?s.PCFSoftShadowMap:this._settings.shadowQuality==="medium"?s.PCFShadowMap:s.BasicShadowMap,r.setPixelRatio(window.devicePixelRatio),r}}const se=I;class C{constructor(r,e){i(this,"isDIVEResizeManager",!0);i(this,"_resizeObserver");i(this,"_width",0);i(this,"_height",0);this._renderer=r,this._camera=e,this._resizeObserver=new ResizeObserver(t=>{const a=t[0],{width:n,height:o}=a.contentRect;n===this._width&&o===this._height||(this._renderer.onResize(n,o),this._camera.onResize(n,o),this._width=n,this._height=o)}),this._observeCanvas(this._renderer.canvas)}setCanvas(r){this._resizeObserver.disconnect(),this._observeCanvas(r);const{width:e,height:t}=r.getBoundingClientRect();this._renderer.onResize(e,t),this._camera.onResize(e,t),this._width=e,this._height=t}dispose(){this._resizeObserver.disconnect()}_observeCanvas(r){if(r.parentElement)this._resizeObserver.observe(r.parentElement);else{const e=setInterval(()=>{r.parentElement&&(this._resizeObserver.observe(r.parentElement),clearInterval(e))},16)}}}class S{constructor(r,e,t){i(this,"isDIVEView",!0);i(this,"uuid",s.MathUtils.generateUUID());i(this,"_paused",!1);i(this,"_renderer");i(this,"_resizeManager");this._scene=r,this._camera=e,this._settings=t,this._renderer=new I(this._scene,this._camera,this._settings),this._resizeManager=new C(this._renderer,this._camera)}get renderer(){return this._renderer}get camera(){return this._camera}get canvas(){return this._renderer.canvas}tick(){this._paused||this._renderer.render()}dispose(){this._resizeManager.dispose(),this._renderer.dispose()}onResize(r,e){this._renderer.onResize(r,e),this._camera.onResize(r,e)}setCanvas(r){this._renderer.setCanvas(r),this._resizeManager.setCanvas(r),this.onResize(this._renderer.canvas.clientWidth,this._renderer.canvas.clientHeight)}pause(){this._paused=!0}resume(){this._paused=!1}}class k extends s.Object3D{constructor(){super();i(this,"isDIVELight",!0);i(this,"isDIVEAmbientLight",!0);i(this,"isSelectable",!0);i(this,"_light");this.name="DIVEAmbientLight",this._light=new s.AmbientLight(16777215,1),this._light.layers.mask=l.PRODUCT_LAYER_MASK,this.add(this._light)}setColor(e){this._light.color=e}setIntensity(e){this._light.intensity=e}setEnabled(e){this._light.visible=e}}class O extends s.Object3D{constructor(){super();i(this,"isDIVELight",!0);i(this,"isDIVEPointLight",!0);i(this,"isMovable",!0);i(this,"isSelectable",!0);i(this,"gizmo",null);i(this,"light");i(this,"mesh");this.name="DIVEPointLight",this.light=new s.PointLight(16777215,1),this.light.layers.mask=l.PRODUCT_LAYER_MASK,this.light.castShadow=!0,this.light.shadow.mapSize.width=512,this.light.shadow.mapSize.height=512,this.add(this.light);const e=.1,t=new s.SphereGeometry(e,e*320,e*320),a=new s.MeshBasicMaterial({color:this.light.color,transparent:!0,opacity:.8,side:s.FrontSide});this.mesh=new s.Mesh(t,a),this.mesh.layers.mask=l.UI_LAYER_MASK,this.add(this.mesh)}setColor(e){this.light.color=e,this.mesh.material.color=e}setIntensity(e){this.light.intensity=e,this.mesh.material.opacity=e>.8?.8:e*.8}setEnabled(e){this.light.visible=e}onMove(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.position})})}onSelect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("SELECT_OBJECT",{id:this.userData.id})})}onDeselect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("DESELECT_OBJECT",{id:this.userData.id})})}}class B extends s.Object3D{constructor(){super();i(this,"isDIVELight",!0);i(this,"isDIVESceneLight",!0);i(this,"isSelectable",!0);i(this,"_hemiLight");i(this,"_dirLight");this.name="DIVESceneLight",this._hemiLight=new s.HemisphereLight(16777215,16777215,2),this._hemiLight.layers.mask=l.PRODUCT_LAYER_MASK,this._hemiLight.position.set(0,50,0),this._hemiLight.visible=!0,this.add(this._hemiLight),this._dirLight=new s.DirectionalLight(16777215,3),this._dirLight.layers.mask=l.PRODUCT_LAYER_MASK,this._dirLight.position.set(1,1.75,1),this._dirLight.position.multiplyScalar(30),this._dirLight.castShadow=!0,this._dirLight.visible=!0,this._dirLight.shadow.mapSize.width=2048,this._dirLight.shadow.mapSize.height=2048;const e=5;this._dirLight.shadow.camera.left=-5,this._dirLight.shadow.camera.right=e,this._dirLight.shadow.camera.top=e,this._dirLight.shadow.camera.bottom=-5,this._dirLight.shadow.camera.far=3500,this.add(this._dirLight)}setColor(e){this._hemiLight.color=e,this._dirLight.color=e}setIntensity(e){this._hemiLight.intensity=e*2,this._dirLight.intensity=e*3}setEnabled(e){this._hemiLight.visible=e,this._dirLight.visible=e}}const v=h=>h.parent?v(h.parent):h;class D extends s.Object3D{constructor(){super();i(this,"isSelectable",!0);i(this,"isMovable",!0);i(this,"isDIVENode",!0);i(this,"gizmo",null);i(this,"_positionWorldBuffer");i(this,"_boundingBox");this.layers.mask=l.PRODUCT_LAYER_MASK,this._positionWorldBuffer=new s.Vector3,this._boundingBox=new s.Box3}setPosition(e){if(!this.parent){this.position.set(e.x,e.y,e.z);return}const t=new s.Vector3(e.x,e.y,e.z);this.position.copy(this.parent.worldToLocal(t)),"isDIVEGroup"in this.parent&&this.parent.updateLineTo(this)}setRotation(e){this.rotation.set(e.x,e.y,e.z)}setScale(e){this.scale.set(e.x,e.y,e.z)}setVisibility(e){this.visible=e}setToWorldOrigin(){this.position.set(0,0,0),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})})}onMove(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})})}onSelect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("SELECT_OBJECT",{id:this.userData.id})})}onDeselect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("DESELECT_OBJECT",{id:this.userData.id})})}}class y extends D{constructor(e,t=!1,a=65280){super();i(this,"_box");i(this,"_sphere");i(this,"_center");i(this,"_radius");i(this,"_boxHelper");i(this,"_sphereHelper");i(this,"_size");const n=new s.Box3;t?n.setFromObject(e):(e.updateWorldMatrix(!0,!0),e.traverse(c=>{if(c.isMesh){const d=c,u=d.geometry.clone();u.applyMatrix4(d.matrixWorld);const g=d.getWorldQuaternion(new s.Quaternion).invert();u.applyQuaternion(g),u.computeBoundingBox(),u.boundingBox&&n.union(u.boundingBox)}})),this.rotation.copy(e.rotation),this._box=n,this._size=n.getSize(new s.Vector3),this._center=n.getCenter(new s.Vector3),this._boxHelper=new s.Box3Helper(this._box,a),this._boxHelper.visible=!1,this.add(this._boxHelper),this._sphere=n.getBoundingSphere(new s.Sphere),this._radius=this._sphere.radius;const o=new s.SphereGeometry(this._radius,32,32);o.translate(this._center.x,this._center.y,this._center.z),this._sphereHelper=new s.Mesh(o,new s.MeshBasicMaterial({color:a,wireframe:!0})),this._sphereHelper.visible=!1,this.add(this._sphereHelper)}get box(){return this._box}get sphere(){return this._sphere}get center(){return this._center}get radius(){return this._radius}get size(){return this._size}setBoxHelperVisible(e){this._boxHelper.visible=e}setSphereHelperVisible(e){this._sphereHelper.visible=e}}class L extends D{constructor(){super();i(this,"isDIVEModel",!0);i(this,"_gltf",null);i(this,"_mesh",null);i(this,"_material",null);i(this,"_assetLoader",null);this.name="DIVEModel"}async _getAssetLoader(){return this._assetLoader||(this._assetLoader=new(await Promise.resolve().then(()=>require("../plugins/assetloader/index.cjs"))).AssetLoader),this._assetLoader}async setFromURL(e){const a=await(await this._getAssetLoader()).load(e);return this.setFromGLTF(a),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:n})=>{var o;(o=n.get(this.userData.id))==null||o.performAction("MODEL_LOADED",{id:this.userData.id})}),this}setFromGLTF(e){return this.clear(),this._boundingBox.makeEmpty(),this._gltf=e,this._gltf.name="GLTF",this._gltf.traverse(t=>{t.castShadow=!0,t.receiveShadow=!0,t.layers.mask=this.layers.mask,this._boundingBox.expandByObject(t),!this._mesh&&"isMesh"in t&&(this._mesh=t,this._material?this._mesh.material=this._material:this._material=t.material)}),this.add(this._gltf),this}setMaterial(e){this._material||(this._material=new s.MeshStandardMaterial),e.vertexColors!==void 0&&(this._material.vertexColors=e.vertexColors),e.color!==void 0&&this._material.color.set(e.color),e.map!==void 0&&(this._material.map=e.map),e.normalMap!==void 0&&(this._material.normalMap=e.normalMap),e.roughness!==void 0&&(this._material.roughness=e.roughness),e.roughnessMap!==void 0&&(this._material.roughnessMap=e.roughnessMap,this._material.roughnessMap&&(this._material.roughness=1)),e.metalness!==void 0&&(this._material.metalness=e.metalness),e.metalnessMap!==void 0&&(this._material.metalnessMap=e.metalnessMap,this._material.metalnessMap&&(this._material.metalness=1)),this._mesh&&(this._mesh.material=this._material)}placeOnFloor(){this.updateWorldMatrix(!0,!0);const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone(),a=new s.Box3;this.children.forEach(o=>{o instanceof y||a.expandByObject(o,!0)});const n=-a.min.y;Math.abs(n)<1e-9||(e.y+=n,e.y!==t.y&&(this.setPosition(e),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:o})=>{var c;(c=o.get(this.userData.id))==null||c.performAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale})}),this.onMove()))}dropIt(){if(!this.parent){console.warn("DIVEModel: dropIt() called on a model that is not in the scene.",this);return}const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone(),a=new s.Box3;this.children.forEach(d=>{d instanceof y||a.expandByObject(d,!0)});const n=a.getCenter(new s.Vector3);n.y=a.min.y;const o=new s.Raycaster(n,new s.Vector3(0,-1,0));o.layers.mask=l.PRODUCT_LAYER_MASK;const c=o.intersectObjects(v(this).root.children,!0);if(c.length>0){const d=c[0].object,f=new s.Box3().setFromObject(d).max.y-a.min.y;if(Math.abs(f)<1e-9||(e.y+=f,e.y===t.y))return;this.setPosition(e),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:E})=>{var w;(w=E.get(this.userData.id))==null||w.performAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale})}),this.onMove()}else this.placeOnFloor()}}class z extends L{constructor(){super();i(this,"isDIVEPrimitive",!0);i(this,"_mesh");i(this,"_material");this._mesh=new s.Mesh,this._mesh.name="PrimitiveMesh",this._mesh.layers.mask=l.PRODUCT_LAYER_MASK,this._mesh.castShadow=!0,this._mesh.receiveShadow=!0,this.add(this._mesh),this._material=new s.MeshStandardMaterial,this._mesh.material=this._material}setGeometry(e){const t=this.assembleGeometry(e);t&&(t.computeVertexNormals(),t.computeBoundingBox(),t.computeBoundingSphere(),this._mesh.geometry=t,this._boundingBox.setFromObject(this._mesh))}assembleGeometry(e){switch(this._material.flatShading=!1,e.name.toLowerCase()){case"cylinder":return this.createCylinderGeometry(e);case"sphere":return this.createSphereGeometry(e);case"pyramid":return this._material.flatShading=!0,this.createPyramidGeometry(e);case"cube":case"box":return this.createBoxGeometry(e);case"cone":return this.createConeGeometry(e);case"wall":return this.createWallGeometry(e);case"plane":return this.createPlaneGeometry(e);default:return console.warn("DIVEPrimitive.assembleGeometry: Invalid geometry type:",e.name.toLowerCase()),null}}createCylinderGeometry(e){const t=new s.CylinderGeometry(e.width/2,e.width/2,e.height,64);return t.translate(0,e.height/2,0),t}createSphereGeometry(e){return new s.SphereGeometry(e.width/2,256,256)}createPyramidGeometry(e){const t=new Float32Array([-e.width/2,0,-e.depth/2,e.width/2,0,-e.depth/2,e.width/2,0,e.depth/2,-e.width/2,0,e.depth/2,0,e.height,0]),a=new Uint16Array([0,1,2,0,2,3,0,4,1,1,4,2,2,4,3,3,4,0]),n=new s.BufferGeometry;return n.setAttribute("position",new s.BufferAttribute(t,3)),n.setIndex(new s.BufferAttribute(a,1)),n}createBoxGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}createConeGeometry(e){const t=new s.ConeGeometry(e.width/2,e.height,256);return t.translate(0,e.height/2,0),t}createWallGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth||.05,16);return t.translate(0,e.height/2,0),t}createPlaneGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}}class G extends D{constructor(){super();i(this,"isDIVEGroup",!0);i(this,"_members");i(this,"_lines");this.name="DIVEGroup",this._members=[],this._lines=[]}get members(){return this._members}setPosition(e){super.setPosition(e),this._members.forEach(t=>{"isDIVENode"in t&&t.onMove()})}setLinesVisibility(e,t){if(!t){this._lines.forEach(n=>{n.visible=e});return}const a=this._members.indexOf(t);a!==-1&&(this._lines[a].visible=e)}attach(e){if(this._members.includes(e))return this;const t=this.createLine();return this.add(t),this._lines.push(t),super.attach(e),this._members.push(e),this._updateLineTo(t,e),this.setLinesVisibility(!0,e),this}remove(e){const t=this._members.indexOf(e);if(t===-1)return this;const a=this._lines[t];return super.remove(a),this._lines.splice(t,1),super.remove(e),this._members.splice(t,1),this}updateLineTo(e){const t=this._members.indexOf(e);t!==-1&&this._updateLineTo(this._lines[t],e)}createLine(){const e=new s.BufferGeometry,t=new s.LineDashedMaterial({color:6710886,dashSize:.05,gapSize:.025}),a=new s.Line(e,t);return a.visible=!1,a}_updateLineTo(e,t){const a=[new s.Vector3(0,0,0),t.position.clone()];e.geometry.setFromPoints(a),e.computeLineDistances()}}class U extends s.Mesh{constructor(){const e=new s.PlaneGeometry(1,1);e.scale(1e3,1e3,1),e.rotateX(-Math.PI/2);const t=new s.MeshStandardMaterial({color:new s.Color(16777215),side:s.FrontSide});super(e,t);i(this,"isDIVEFloor",!0);this.name="Floor",this.layers.mask=l.PRODUCT_LAYER_MASK,this.receiveShadow=!0}setVisibility(e){this.visible=e}setColor(e){this.material.color=new s.Color(e)}}class F extends s.Object3D{constructor(){super();i(this,"isDIVERoot",!0);i(this,"_floor");this.name="Root",this._floor=new U,this.add(this._floor)}get floor(){return this._floor}computeSceneBB(){const e=new s.Box3;return this.children.forEach(t=>{"isDIVEFloor"in t||t.traverse(a=>{"isObject3D"in a&&e.expandByObject(a)})}),e}getSceneObject(e){let t;return this.traverse(a=>{t||a.userData.id===e.id&&(t=a)}),t}addSceneObject(e){let t=this.getSceneObject(e);if(t)return console.warn(`DIVERoot.addSceneObject: Scene object with id ${e.id} already exists`),t;switch(e.entityType){case"pov":break;case"light":{switch(e.type){case"scene":{t=new B;break}case"ambient":{t=new k;break}case"point":{t=new O;break}default:throw new Error(`DIVERoot.addSceneObject: Unknown light type: ${e.type}`)}t.name=e.name,t.userData.id=e.id,this.add(t),this._updateLight(t,e);break}case"model":{t=new L,t.name=e.name,t.userData.id=e.id,t.userData.uri=e.uri,this.add(t),this._updateModel(t,e);break}case"primitive":{t=new z,t.name=e.name,t.userData.id=e.id,this.add(t),this._updatePrimitive(t,e);break}case"group":{t=new G,t.name=e.name,t.userData.id=e.id,this.add(t),this._updateGroup(t,e);break}default:throw new Error(`DIVERoot.addSceneObject: Unknown entity type: ${e.entityType}`)}return t}updateSceneObject(e){const t=this.getSceneObject(e);if(!t){console.warn(`DIVERoot.updateSceneObject: Scene object with id ${e.id} does not exist`);return}switch(e.entityType){case"pov":break;case"light":{this._updateLight(t,e);break}case"model":{this._updateModel(t,e);break}case"primitive":{this._updatePrimitive(t,e);break}case"group":{this._updateGroup(t,e);break}default:throw new Error(`DIVERoot.updateSceneObject: Unknown entity type: ${e.entityType}`)}}deleteSceneObject(e){const t=this.getSceneObject(e);if(!t){console.warn(`DIVERoot.deleteSceneObject: Object with id ${e.id} not found`);return}switch(e.entityType){case"pov":break;case"light":{this._deleteLight(t);break}case"model":{this._deleteModel(t);break}case"primitive":{this._deletePrimitive(t);break}case"group":{this._deleteGroup(t);break}default:throw new Error(`DIVERoot.deleteSceneObject: Unknown entity type: ${e.entityType}`)}}_updateLight(e,t){t.name!==void 0&&t.name!==null&&(e.name=t.name),t.position!==void 0&&t.position!==null&&e.position.set(t.position.x,t.position.y,t.position.z),t.intensity!==void 0&&t.intensity!==null&&e.setIntensity(t.intensity),t.enabled!==void 0&&t.enabled!==null&&e.setEnabled(t.enabled),t.color!==void 0&&t.color!==null&&e.setColor(new s.Color(t.color)),t.visible!==void 0&&t.visible!==null&&(e.visible=t.visible),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updateModel(e,t){t.uri!==void 0&&e.setFromURL(t.uri),t.name!==void 0&&(e.name=t.name),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.material!==void 0&&e.setMaterial(t.material),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updatePrimitive(e,t){t.name!==void 0&&(e.name=t.name),t.geometry!==void 0&&e.setGeometry(t.geometry),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.material!==void 0&&e.setMaterial(t.material),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updateGroup(e,t){t.name!==void 0&&(e.name=t.name),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.bbVisible!==void 0&&e.setLinesVisibility(t.bbVisible),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_deleteLight(e){this._detachTransformControls(e),e.parent.remove(e)}_deleteModel(e){this._detachTransformControls(e),e.parent.remove(e)}_deletePrimitive(e){this._detachTransformControls(e),e.parent.remove(e)}_deleteGroup(e){this._detachTransformControls(e);for(let t=e.members.length-1;t>=0;t--)this.attach(e.members[t]);e.parent.remove(e)}_setParent(e){const t=this.getSceneObject(e);if(e.parentId!==null){const a=this.getSceneObject({id:e.parentId,entityType:e.entityType});if(!a)return;a.attach(t)}else this.attach(t)}_detachTransformControls(e){this._findScene(e).children.find(t=>{"isTransformControls"in t&&t.detach()})}_findScene(e){return e.parent!==null?this._findScene(e.parent):e}}const Y="#888888",H="#dddddd";class W extends s.Object3D{constructor(){super(),this.name="Grid";const r=new s.GridHelper(100,100,Y,H);r.material.depthTest=!1,r.layers.mask=l.HELPER_LAYER_MASK,this.add(r)}setVisibility(r){this.visible=r}}const m={displayFloor:!1,displayGrid:!1,backgroundColor:"#ffffff"};class q extends s.Scene{constructor(e){super();i(this,"isDIVEScene",!0);i(this,"_root");i(this,"_grid");this.background=new s.Color((e==null?void 0:e.backgroundColor)??m.backgroundColor),this._root=new F,this._root.floor.setVisibility((e==null?void 0:e.displayFloor)??m.displayFloor),this.add(this._root),this._grid=new W,this._grid.setVisibility((e==null?void 0:e.displayGrid)??m.displayGrid),this.add(this._grid)}get root(){return this._root}get grid(){return this._grid}setBackground(e){this.background=new s.Color(e)}computeSceneBB(){return this._root.computeSceneBB()}}const N={enableDamping:!0,dampingFactor:.05,enabled:!0,target:new s.Vector3,minDistance:0,maxDistance:1/0,minZoom:0,maxZoom:1/0,minPolarAngle:0,maxPolarAngle:Math.PI,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,enableZoom:!0,zoomSpeed:1,enableRotate:!0,rotateSpeed:1,enablePan:!0,panSpeed:1,screenSpacePanning:!0,keyPanSpeed:7,autoRotate:!1,autoRotateSpeed:2,keys:{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},mouseButtons:{LEFT:s.MOUSE.ROTATE,MIDDLE:s.MOUSE.DOLLY,RIGHT:s.MOUSE.PAN},touches:{ONE:s.TOUCH.ROTATE,TWO:s.TOUCH.DOLLY_PAN}},_=class _ extends s.EventDispatcher{constructor(e,t,a){super();i(this,"object");i(this,"domElements");i(this,"enabled",!0);i(this,"target",new s.Vector3);i(this,"minDistance",0);i(this,"maxDistance",1/0);i(this,"minZoom",0);i(this,"maxZoom",1/0);i(this,"minPolarAngle",0);i(this,"maxPolarAngle",Math.PI);i(this,"minAzimuthAngle",-1/0);i(this,"maxAzimuthAngle",1/0);i(this,"enableDamping",!0);i(this,"dampingFactor",.05);i(this,"enableZoom",!0);i(this,"zoomSpeed",1);i(this,"enableRotate",!0);i(this,"rotateSpeed",1);i(this,"enablePan",!0);i(this,"panSpeed",1);i(this,"screenSpacePanning",!0);i(this,"keyPanSpeed",7);i(this,"autoRotate",!1);i(this,"autoRotateSpeed",2);i(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"});i(this,"mouseButtons",{LEFT:s.MOUSE.ROTATE,MIDDLE:s.MOUSE.DOLLY,RIGHT:s.MOUSE.PAN});i(this,"touches",{ONE:s.TOUCH.ROTATE,TWO:s.TOUCH.DOLLY_PAN});i(this,"target0");i(this,"position0");i(this,"zoom0");i(this,"uuid",s.MathUtils.generateUUID());i(this,"state",-1);i(this,"EPS",1e-6);i(this,"spherical",new s.Spherical);i(this,"sphericalDelta",new s.Spherical);i(this,"scale",1);i(this,"panOffset",new s.Vector3);i(this,"zoomChanged",!1);i(this,"rotateStart",new s.Vector2);i(this,"rotateEnd",new s.Vector2);i(this,"rotateDelta",new s.Vector2);i(this,"panStart",new s.Vector2);i(this,"panEnd",new s.Vector2);i(this,"panDelta",new s.Vector2);i(this,"dollyStart",new s.Vector2);i(this,"dollyEnd",new s.Vector2);i(this,"dollyDelta",new s.Vector2);i(this,"pointers",[]);i(this,"pointerPositions",{});i(this,"offset",new s.Vector3);i(this,"quat");i(this,"quatInverse");i(this,"lastPosition",new s.Vector3);i(this,"lastQuaternion",new s.Quaternion);i(this,"lastTarget",new s.Vector3);i(this,"panLeft",(()=>{const e=new s.Vector3;return(t,a)=>{e.setFromMatrixColumn(a,0),e.multiplyScalar(-t),this.panOffset.add(e)}})());i(this,"panUp",(()=>{const e=new s.Vector3;return(t,a)=>{this.screenSpacePanning===!0?e.setFromMatrixColumn(a,1):(e.setFromMatrixColumn(a,0),e.crossVectors(this.object.up,e)),e.multiplyScalar(t),this.panOffset.add(e)}})());i(this,"onMouseDown",e=>{let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case s.MOUSE.DOLLY:if(this.enableZoom===!1)return;this.handleMouseDownDolly(e),this.state=1;break;case s.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}break;case s.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});i(this,"onMouseMove",e=>{if(this.enabled!==!1)switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(e);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(e);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(e);break}});i(this,"onMouseWheel",e=>{this.enabled===!1||this.enableZoom===!1||this.state!==-1||(e.preventDefault(),this.dispatchEvent({type:"start"}),this.handleMouseWheel(e),this.dispatchEvent({type:"end"}))});i(this,"onKeyDown",e=>{this.enabled===!1||this.enablePan===!1||this.handleKeyDown(e)});i(this,"onTouchStart",e=>{switch(this.trackPointer(e),this.pointers.length){case 1:switch(this.touches.ONE){case s.TOUCH.ROTATE:if(this.enableRotate===!1)return;this.handleTouchStartRotate(e),this.state=3;break;case s.TOUCH.PAN:if(this.enablePan===!1)return;this.handleTouchStartPan(e),this.state=4;break;default:this.state=-1}break;case 2:switch(this.touches.TWO){case s.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(e),this.state=5;break;case s.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(e),this.state=6;break;default:this.state=-1}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});i(this,"onTouchMove",e=>{switch(this.trackPointer(e),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(e),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(e),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(e),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(e),this.update();break;default:this.state=-1}});i(this,"onPointerDown",e=>{if(this.enabled!==!1){if(this.pointers.length===0){const t=e.currentTarget;t.setPointerCapture(e.pointerId),t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp)}this.isTrackingPointer(e)||(this.addPointer(e),e.pointerType==="touch"?this.onTouchStart(e):this.onMouseDown(e))}});i(this,"onPointerMove",e=>{this.enabled!==!1&&(e.pointerType==="touch"?this.onTouchMove(e):this.onMouseMove(e))});i(this,"onPointerUp",e=>{if(this.removePointer(e),this.pointers.length===0){const t=e.currentTarget;t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),this.dispatchEvent({type:"end"}),this.state=-1}});i(this,"onPointerCancel",e=>{this.removePointer(e)});i(this,"onContextMenu",e=>{this.enabled!==!1&&e.preventDefault()});this.object=e,this.domElements=Array.isArray(t)?t:[t],Object.assign(this,a),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat=new s.Quaternion().setFromUnitVectors(e.up,new s.Vector3(0,1,0)),this.quatInverse=this.quat.clone().invert(),this.domElements.forEach(n=>this.addEventListeners(n)),this.update()}get domElement(){return this.domElements[0]}tick(){this.enabled&&this.update()}getPolarAngle(){return this.spherical.phi}getAzimuthalAngle(){return this.spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent({type:"change"}),this.update(),this.state=-1}update(){return this.offset.copy(this.object.position).sub(this.target),this.offset.applyQuaternion(this.quat),this.spherical.setFromVector3(this.offset),this.autoRotate&&this.state===-1&&this.rotateLeft(this.getAutoRotationAngle()),this.enableDamping?(this.spherical.theta+=this.sphericalDelta.theta*this.dampingFactor,this.spherical.phi+=this.sphericalDelta.phi*this.dampingFactor):(this.spherical.theta+=this.sphericalDelta.theta,this.spherical.phi+=this.sphericalDelta.phi),this.spherical.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this.spherical.theta)),this.spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.spherical.phi)),this.spherical.makeSafe(),this.spherical.radius*=this.scale,this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius)),this.enableDamping===!0?this.target.addScaledVector(this.panOffset,this.dampingFactor):this.target.add(this.panOffset),this.offset.setFromSpherical(this.spherical),this.offset.applyQuaternion(this.quatInverse),this.object.position.copy(this.target).add(this.offset),this.object.lookAt(this.target),this.enableDamping===!0?(this.sphericalDelta.theta*=1-this.dampingFactor,this.sphericalDelta.phi*=1-this.dampingFactor,this.panOffset.multiplyScalar(1-this.dampingFactor)):(this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0)),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>this.EPS||8*(1-this.lastQuaternion.dot(this.object.quaternion))>this.EPS||this.lastTarget.distanceToSquared(this.target)>this.EPS?(this.dispatchEvent({type:"change"}),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.lastTarget.copy(this.target),this.zoomChanged=!1,!0):!1}dispose(){this.domElements.forEach(e=>this.removeEventListeners(e)),this.dispatchEvent({type:"dispose"})}addDomElements(...e){e.forEach(t=>{this.domElements.includes(t)||(this.domElements.push(t),this.addEventListeners(t))})}removeDomElements(...e){e.forEach(t=>{const a=this.domElements.indexOf(t);a>-1&&(this.removeEventListeners(t),this.domElements.splice(a,1))})}setDomElements(...e){this.removeDomElements(...this.domElements),this.domElements=[],this.addDomElements(...e)}computeEncompassingView(e,t=0){const a=e.center,o=e.sphere.radius,c=this.object.fov*(Math.PI/180),d=this.object.aspect,u=c/2,g=Math.atan(Math.tan(u)*d),f=o/Math.sin(u),E=o/Math.sin(g),w=Math.max(f,E)*(1+t),R=this.object.position.clone().sub(this.target).normalize(),ee=R.length()>.001?R:new s.Vector3(0,0,1);return{position:a.clone().add(ee.multiplyScalar(w)),target:a}}focusObject(e,t=0){const a=new y(e),n=this.computeEncompassingView(a,t);this.object.position.copy(n.position),this.target.copy(n.target),this.update()}zoomIn(e){this.dollyIn(Math.pow(.95,e??_.DEFAULT_ZOOM_FACTOR)),this.update()}zoomOut(e){this.dollyOut(Math.pow(.95,e??_.DEFAULT_ZOOM_FACTOR)),this.update()}getState(){return{target:this.target.clone(),azimuthalAngle:this.getAzimuthalAngle(),polarAngle:this.getPolarAngle(),distance:this.getDistance(),position:this.object.position.clone(),quaternion:this.object.quaternion.clone()}}setState(e){this.target.copy(e.target),this.object.position.copy(e.position),this.object.quaternion.copy(e.quaternion),this.update()}addEventListeners(e){e.style.touchAction="none",e.addEventListener("contextmenu",this.onContextMenu),e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointercancel",this.onPointerCancel),e.addEventListener("wheel",this.onMouseWheel,{passive:!1}),e.addEventListener("keydown",this.onKeyDown)}removeEventListeners(e){e.removeEventListener("contextmenu",this.onContextMenu),e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointercancel",this.onPointerCancel),e.removeEventListener("wheel",this.onMouseWheel),e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(e){this.sphericalDelta.theta-=e}rotateUp(e){this.sphericalDelta.phi-=e}pan(e,t,a){const n=new s.Vector3;if("isPerspectiveCamera"in this.object){const o=this.object.position;n.copy(o).sub(this.target);let c=n.length();c*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*c/a.clientHeight,this.object.matrix),this.panUp(2*t*c/a.clientHeight,this.object.matrix)}else"isOrthographicCamera"in this.object?(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/a.clientWidth,this.object.matrix),this.panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/a.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitController encountered an unknown camera type - pan disabled."),this.enablePan=!1)}dollyIn(e){"isPerspectiveCamera"in this.object||"isOrthographicCamera"in this.object?this.scale*=e:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyOut(e){"isPerspectiveCamera"in this.object||"isOrthographicCamera"in this.object?this.scale/=e:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleMouseMoveRotate(e){this.rotateEnd.set(e.clientX,e.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);const t=e.currentTarget;this.rotateLeft(2*Math.PI*this.rotateDelta.x/t.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/t.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyIn(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyOut(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(e){const t=e.currentTarget;this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,t),this.panStart.copy(this.panEnd),this.update()}handleMouseWheel(e){e.deltaY<0?this.dollyIn(this.getZoomScale()):e.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update()}handleKeyDown(e){let t=!1;const a=e.currentTarget;switch(e.code){case this.keys.UP:this.pan(0,this.keyPanSpeed,a),t=!0;break;case this.keys.BOTTOM:this.pan(0,-this.keyPanSpeed,a),t=!0;break;case this.keys.LEFT:this.pan(this.keyPanSpeed,0,a),t=!0;break;case this.keys.RIGHT:this.pan(-this.keyPanSpeed,0,a),t=!0;break}t&&(e.preventDefault(),this.update())}handleTouchStartRotate(e){if(this.pointers.length===1)this.rotateStart.set(e.pageX,e.pageY);else{const t=this.getSecondPointer(e),a=.5*(e.pageX+t.pageX),n=.5*(e.pageY+t.pageY);this.rotateStart.set(a,n)}}handleTouchStartPan(e){if(this.pointers.length===1)this.panStart.set(e.pageX,e.pageY);else{const t=this.getSecondPointer(e),a=.5*(e.pageX+t.pageX),n=.5*(e.pageY+t.pageY);this.panStart.set(a,n)}}handleTouchStartDolly(e){const t=this.getSecondPointer(e),a=e.pageX-t.pageX,n=e.pageY-t.pageY,o=Math.sqrt(a*a+n*n);this.dollyStart.set(0,o)}handleTouchStartDollyPan(e){this.enableZoom&&this.handleTouchStartDolly(e),this.enablePan&&this.handleTouchStartPan(e)}handleTouchStartDollyRotate(e){this.enableZoom&&this.handleTouchStartDolly(e),this.enableRotate&&this.handleTouchStartRotate(e)}handleTouchMoveRotate(e){if(this.pointers.length===1)this.rotateEnd.set(e.pageX,e.pageY);else{const a=this.getSecondPointer(e),n=.5*(e.pageX+a.pageX),o=.5*(e.pageY+a.pageY);this.rotateEnd.set(n,o)}const t=e.currentTarget;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed),this.rotateLeft(2*Math.PI*this.rotateDelta.x/t.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/t.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(e){if(this.pointers.length===1)this.panEnd.set(e.pageX,e.pageY);else{const a=this.getSecondPointer(e),n=.5*(e.pageX+a.pageX),o=.5*(e.pageY+a.pageY);this.panEnd.set(n,o)}const t=e.currentTarget;this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,t),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(e){const t=this.getSecondPointer(e),a=e.pageX-t.pageX,n=e.pageY-t.pageY,o=Math.sqrt(a*a+n*n);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(e){this.enableZoom&&this.handleTouchMoveDolly(e),this.enablePan&&this.handleTouchMovePan(e)}handleTouchMoveDollyRotate(e){this.enableZoom&&this.handleTouchMoveDolly(e),this.enableRotate&&this.handleTouchMoveRotate(e)}addPointer(e){this.pointers.push(e)}removePointer(e){delete this.pointerPositions[e.pointerId];for(let t=0;t<this.pointers.length;t++)if(this.pointers[t].pointerId==e.pointerId){this.pointers.splice(t,1);return}}trackPointer(e){let t=this.pointerPositions[e.pointerId];t===void 0&&(t=new s.Vector2,this.pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}getSecondPointer(e){return this.pointers[0].pointerId===e.pointerId?this.pointers[1]:this.pointers[0]}isTrackingPointer(e){return this.pointers.some(t=>t.pointerId===e.pointerId)}};i(_,"DEFAULT_ZOOM_FACTOR",1);let P=_;class Z extends s.Object3D{constructor(){super();i(this,"_axesHelper");this._axesHelper=new s.AxesHelper(.5),this._axesHelper.layers.mask=l.COORDINATE_LAYER_MASK,this._axesHelper.material.depthTest=!1,this._axesHelper.position.set(0,0,-1),this._axesHelper.setColors(new s.Color(Q),new s.Color(J),new s.Color(j));const e=new b("X",.2,T),t=new b("Y",.2,x),a=new b("Z",.2,V);e.layers.mask=l.COORDINATE_LAYER_MASK,t.layers.mask=l.COORDINATE_LAYER_MASK,a.layers.mask=l.COORDINATE_LAYER_MASK,e.position.set(.7,0,0),t.position.set(0,.7,0),a.position.set(0,0,.7),this._axesHelper.add(e),this._axesHelper.add(t),this._axesHelper.add(a)}setFromCameraMatrix(e){this._axesHelper.rotation.setFromRotationMatrix(new s.Matrix4().extractRotation(e).invert())}}class K{constructor(r,e,t){i(this,"uuid",s.MathUtils.generateUUID());i(this,"_axes");i(this,"_orthographicCamera");i(this,"_restoreViewport",new s.Vector4);this._renderer=r,this._scene=e,this._camera=t,this._orthographicCamera=new s.OrthographicCamera(-1,1,1,-1,.1,100),this._orthographicCamera.layers.mask=l.COORDINATE_LAYER_MASK,this._scene.add(this._orthographicCamera),this._axes=new Z,this._scene.add(this._axes)}tick(){const r=this._scene.background;this._scene.background=null,this._renderer.webglrenderer.getViewport(this._restoreViewport),this._renderer.webglrenderer.setViewport(0,0,150,150),this._renderer.webglrenderer.autoClear=!1,this._axes.setFromCameraMatrix(this._camera.matrix),this._renderer.webglrenderer.render(this._scene,this._orthographicCamera),this._renderer.webglrenderer.setViewport(this._restoreViewport),this._renderer.webglrenderer.autoClear=!0,this._scene.background=r}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}const re=`
|
|
1
|
+
"use strict";var te=Object.defineProperty;var ie=(h,r,e)=>r in h?te(h,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[r]=e;var i=(h,r,e)=>ie(h,typeof r!="symbol"?r+"":r,e);const s=require("three"),l=require("./PerspectiveCamera-iAsZqrnY.cjs"),b=require("three-spritetext");class A{constructor(){i(this,"isDIVEClock",!0);i(this,"_lastTime",0);i(this,"_isRunning",!1);i(this,"_tickers",[])}start(){this._isRunning||(this._isRunning=!0,this._lastTime=performance.now(),requestAnimationFrame(this._tick.bind(this)))}stop(){this._isRunning=!1}addTicker(r){this._tickers.find(e=>e.uuid===r.uuid)||this._tickers.push(r)}hasTicker(r){return this._tickers.find(e=>e.uuid===r.uuid)!==void 0}removeTicker(r){const e=this._tickers.findIndex(t=>t.uuid===r.uuid);e!==-1&&this._tickers.splice(e,1)}dispose(){this.stop(),this._tickers=[],this._isRunning=!1,this._lastTime=0}_tick(r){if(!this._isRunning)return;const e=(r-this._lastTime)/1e3;this._lastTime=r,this._tickers.forEach(t=>t.tick(e)),requestAnimationFrame(this._tick.bind(this))}}const M={canvas:void 0,antialias:!0,alpha:!0,powerPreference:"high-performance",precision:"highp",stencil:!1,depth:!0,logarithmicDepthBuffer:!1,shadows:!0,shadowQuality:"high"};class I{constructor(r,e,t){i(this,"isDIVERenderer",!0);i(this,"_webglrenderer");i(this,"_settings");this._scene=r,this._camera=e,this._settings={...M,...t??{}},this._webglrenderer=this._createWebGLRenderer()}get webglrenderer(){return this._webglrenderer}get canvas(){return this._webglrenderer.domElement}render(){this._webglrenderer.render(this._scene,this._camera)}onResize(r,e){this._webglrenderer.setSize(r,e,!1)}dispose(){this._webglrenderer.dispose()}setCanvas(r){this._webglrenderer.dispose(),this._settings.canvas=r,this._webglrenderer=this._createWebGLRenderer()}_createWebGLRenderer(){const r=new s.WebGLRenderer(this._settings);return r.shadowMap.enabled=this._settings.shadows,r.shadowMap.type=this._settings.shadowQuality==="high"?s.PCFSoftShadowMap:this._settings.shadowQuality==="medium"?s.PCFShadowMap:s.BasicShadowMap,r.setPixelRatio(window.devicePixelRatio),r}}const se=I;class C{constructor(r,e){i(this,"isDIVEResizeManager",!0);i(this,"_resizeObserver");i(this,"_width",0);i(this,"_height",0);this._renderer=r,this._camera=e,this._resizeObserver=new ResizeObserver(t=>{const a=t[0],{width:n,height:o}=a.contentRect;n===this._width&&o===this._height||(this._renderer.onResize(n,o),this._camera.onResize(n,o),this._width=n,this._height=o)}),this._observeCanvas(this._renderer.canvas)}setCanvas(r){this._resizeObserver.disconnect(),this._observeCanvas(r);const{width:e,height:t}=r.getBoundingClientRect();this._renderer.onResize(e,t),this._camera.onResize(e,t),this._width=e,this._height=t}dispose(){this._resizeObserver.disconnect()}_observeCanvas(r){if(r.parentElement)this._resizeObserver.observe(r.parentElement);else{const e=setInterval(()=>{r.parentElement&&(this._resizeObserver.observe(r.parentElement),clearInterval(e))},16)}}}class S{constructor(r,e,t){i(this,"isDIVEView",!0);i(this,"uuid",s.MathUtils.generateUUID());i(this,"_paused",!1);i(this,"_renderer");i(this,"_resizeManager");this._scene=r,this._camera=e,this._settings=t,this._renderer=new I(this._scene,this._camera,this._settings),this._resizeManager=new C(this._renderer,this._camera)}get renderer(){return this._renderer}get camera(){return this._camera}get canvas(){return this._renderer.canvas}tick(){this._paused||this._renderer.render()}dispose(){this._resizeManager.dispose(),this._renderer.dispose()}onResize(r,e){this._renderer.onResize(r,e),this._camera.onResize(r,e)}setCanvas(r){this._renderer.setCanvas(r),this._resizeManager.setCanvas(r),this.onResize(this._renderer.canvas.clientWidth,this._renderer.canvas.clientHeight)}pause(){this._paused=!0}resume(){this._paused=!1}}class k extends s.Object3D{constructor(){super();i(this,"isDIVELight",!0);i(this,"isDIVEAmbientLight",!0);i(this,"isSelectable",!0);i(this,"_light");this.name="DIVEAmbientLight",this._light=new s.AmbientLight(16777215,1),this._light.layers.mask=l.PRODUCT_LAYER_MASK,this.add(this._light)}setColor(e){this._light.color=e}setIntensity(e){this._light.intensity=e}setEnabled(e){this._light.visible=e}}class O extends s.Object3D{constructor(){super();i(this,"isDIVELight",!0);i(this,"isDIVEPointLight",!0);i(this,"isMovable",!0);i(this,"isSelectable",!0);i(this,"gizmo",null);i(this,"light");i(this,"mesh");this.name="DIVEPointLight",this.light=new s.PointLight(16777215,1),this.light.layers.mask=l.PRODUCT_LAYER_MASK,this.light.castShadow=!0,this.light.shadow.mapSize.width=512,this.light.shadow.mapSize.height=512,this.add(this.light);const e=.1,t=new s.SphereGeometry(e,e*320,e*320),a=new s.MeshBasicMaterial({color:this.light.color,transparent:!0,opacity:.8,side:s.FrontSide});this.mesh=new s.Mesh(t,a),this.mesh.layers.mask=l.UI_LAYER_MASK,this.add(this.mesh)}setColor(e){this.light.color=e,this.mesh.material.color=e}setIntensity(e){this.light.intensity=e,this.mesh.material.opacity=e>.8?.8:e*.8}setEnabled(e){this.light.visible=e}onMove(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.position})})}onSelect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("SELECT_OBJECT",{id:this.userData.id})})}onDeselect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("DESELECT_OBJECT",{id:this.userData.id})})}}class B extends s.Object3D{constructor(){super();i(this,"isDIVELight",!0);i(this,"isDIVESceneLight",!0);i(this,"isSelectable",!0);i(this,"_hemiLight");i(this,"_dirLight");this.name="DIVESceneLight",this._hemiLight=new s.HemisphereLight(16777215,16777215,2),this._hemiLight.layers.mask=l.PRODUCT_LAYER_MASK,this._hemiLight.position.set(0,50,0),this._hemiLight.visible=!0,this.add(this._hemiLight),this._dirLight=new s.DirectionalLight(16777215,3),this._dirLight.layers.mask=l.PRODUCT_LAYER_MASK,this._dirLight.position.set(1,1.75,1),this._dirLight.position.multiplyScalar(30),this._dirLight.castShadow=!0,this._dirLight.visible=!0,this._dirLight.shadow.mapSize.width=2048,this._dirLight.shadow.mapSize.height=2048;const e=5;this._dirLight.shadow.camera.left=-5,this._dirLight.shadow.camera.right=e,this._dirLight.shadow.camera.top=e,this._dirLight.shadow.camera.bottom=-5,this._dirLight.shadow.camera.far=3500,this.add(this._dirLight)}setColor(e){this._hemiLight.color=e,this._dirLight.color=e}setIntensity(e){this._hemiLight.intensity=e*2,this._dirLight.intensity=e*3}setEnabled(e){this._hemiLight.visible=e,this._dirLight.visible=e}}const v=h=>h.parent?v(h.parent):h;class D extends s.Object3D{constructor(){super();i(this,"isSelectable",!0);i(this,"isMovable",!0);i(this,"isDIVENode",!0);i(this,"gizmo",null);i(this,"_positionWorldBuffer");i(this,"_boundingBox");this.layers.mask=l.PRODUCT_LAYER_MASK,this._positionWorldBuffer=new s.Vector3,this._boundingBox=new s.Box3}setPosition(e){if(!this.parent){this.position.set(e.x,e.y,e.z);return}const t=new s.Vector3(e.x,e.y,e.z);this.position.copy(this.parent.worldToLocal(t)),"isDIVEGroup"in this.parent&&this.parent.updateLineTo(this)}setRotation(e){this.rotation.set(e.x,e.y,e.z)}setScale(e){this.scale.set(e.x,e.y,e.z)}setVisibility(e){this.visible=e}setToWorldOrigin(){this.position.set(0,0,0),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})})}onMove(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("UPDATE_OBJECT",{id:this.userData.id,position:this.getWorldPosition(this._positionWorldBuffer),rotation:this.rotation,scale:this.scale})})}onSelect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("SELECT_OBJECT",{id:this.userData.id})})}onDeselect(){Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:e})=>{var t;(t=e.get(this.userData.id))==null||t.performAction("DESELECT_OBJECT",{id:this.userData.id})})}}class y extends D{constructor(e,t=!1,a=65280){super();i(this,"_box");i(this,"_sphere");i(this,"_center");i(this,"_radius");i(this,"_boxHelper");i(this,"_sphereHelper");i(this,"_size");const n=new s.Box3;t?n.setFromObject(e):(e.updateWorldMatrix(!0,!0),e.traverse(c=>{if(c.isMesh){const d=c,u=d.geometry.clone();u.applyMatrix4(d.matrixWorld);const g=d.getWorldQuaternion(new s.Quaternion).invert();u.applyQuaternion(g),u.computeBoundingBox(),u.boundingBox&&n.union(u.boundingBox)}})),this.rotation.copy(e.rotation),this._box=n,this._size=n.getSize(new s.Vector3),this._center=n.getCenter(new s.Vector3),this._boxHelper=new s.Box3Helper(this._box,a),this._boxHelper.visible=!1,this.add(this._boxHelper),this._sphere=n.getBoundingSphere(new s.Sphere),this._radius=this._sphere.radius;const o=new s.SphereGeometry(this._radius,32,32);o.translate(this._center.x,this._center.y,this._center.z),this._sphereHelper=new s.Mesh(o,new s.MeshBasicMaterial({color:a,wireframe:!0})),this._sphereHelper.visible=!1,this.add(this._sphereHelper)}get box(){return this._box}get sphere(){return this._sphere}get center(){return this._center}get radius(){return this._radius}get size(){return this._size}setBoxHelperVisible(e){this._boxHelper.visible=e}setSphereHelperVisible(e){this._sphereHelper.visible=e}}class L extends D{constructor(){super();i(this,"isDIVEModel",!0);i(this,"_gltf",null);i(this,"_mesh",null);i(this,"_material",null);i(this,"_assetLoader",null);this.name="DIVEModel"}async _getAssetLoader(){return this._assetLoader||(this._assetLoader=new(await Promise.resolve().then(()=>require("../plugins/assetloader/index.cjs"))).AssetLoader),this._assetLoader}async setFromURL(e){const a=await(await this._getAssetLoader()).load(e);return this.setFromGLTF(a),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:n})=>{var o;(o=n.get(this.userData.id))==null||o.performAction("MODEL_LOADED",{id:this.userData.id})}),this}setFromGLTF(e){return this.clear(),this._boundingBox.makeEmpty(),this._gltf=e,this._gltf.name="GLTF",this._gltf.traverse(t=>{t.castShadow=!0,t.receiveShadow=!0,t.layers.mask=this.layers.mask,this._boundingBox.expandByObject(t),!this._mesh&&"isMesh"in t&&(this._mesh=t,this._material?this._mesh.material=this._material:this._material=t.material)}),this.add(this._gltf),this}setMaterial(e){this._material||(this._material=new s.MeshStandardMaterial),e.vertexColors!==void 0&&(this._material.vertexColors=e.vertexColors),e.color!==void 0&&this._material.color.set(e.color),e.map!==void 0&&(this._material.map=e.map),e.normalMap!==void 0&&(this._material.normalMap=e.normalMap),e.roughness!==void 0&&(this._material.roughness=e.roughness),e.roughnessMap!==void 0&&(this._material.roughnessMap=e.roughnessMap,this._material.roughnessMap&&(this._material.roughness=1)),e.metalness!==void 0&&(this._material.metalness=e.metalness),e.metalnessMap!==void 0&&(this._material.metalnessMap=e.metalnessMap,this._material.metalnessMap&&(this._material.metalness=1)),this._mesh&&(this._mesh.material=this._material)}placeOnFloor(){this.updateWorldMatrix(!0,!0);const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone(),a=new s.Box3;this.children.forEach(o=>{o instanceof y||a.expandByObject(o,!0)});const n=-a.min.y;Math.abs(n)<1e-9||(e.y+=n,e.y!==t.y&&(this.setPosition(e),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:o})=>{var c;(c=o.get(this.userData.id))==null||c.performAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale})}),this.onMove()))}dropIt(){if(!this.parent){console.warn("DIVEModel: dropIt() called on a model that is not in the scene.",this);return}const e=this.getWorldPosition(this._positionWorldBuffer),t=e.clone(),a=new s.Box3;this.children.forEach(d=>{d instanceof y||a.expandByObject(d,!0)});const n=a.getCenter(new s.Vector3);n.y=a.min.y;const o=new s.Raycaster(n,new s.Vector3(0,-1,0));o.layers.mask=l.PRODUCT_LAYER_MASK;const c=o.intersectObjects(v(this).root.children,!0);if(c.length>0){const d=c[0].object,f=new s.Box3().setFromObject(d).max.y-a.min.y;if(Math.abs(f)<1e-9||(e.y+=f,e.y===t.y))return;this.setPosition(e),Promise.resolve().then(()=>require("../plugins/state/index.cjs")).then(({State:E})=>{var w;(w=E.get(this.userData.id))==null||w.performAction("UPDATE_OBJECT",{id:this.userData.id,position:e,rotation:this.rotation,scale:this.scale})}),this.onMove()}else this.placeOnFloor()}}class z extends L{constructor(){super();i(this,"isDIVEPrimitive",!0);i(this,"_mesh");i(this,"_material");this._mesh=new s.Mesh,this._mesh.name="PrimitiveMesh",this._mesh.layers.mask=l.PRODUCT_LAYER_MASK,this._mesh.castShadow=!0,this._mesh.receiveShadow=!0,this.add(this._mesh),this._material=new s.MeshStandardMaterial,this._mesh.material=this._material}setGeometry(e){const t=this.assembleGeometry(e);t&&(t.computeVertexNormals(),t.computeBoundingBox(),t.computeBoundingSphere(),this._mesh.geometry=t,this._boundingBox.setFromObject(this._mesh))}assembleGeometry(e){switch(this._material.flatShading=!1,e.name.toLowerCase()){case"cylinder":return this.createCylinderGeometry(e);case"sphere":return this.createSphereGeometry(e);case"pyramid":return this._material.flatShading=!0,this.createPyramidGeometry(e);case"cube":case"box":return this.createBoxGeometry(e);case"cone":return this.createConeGeometry(e);case"wall":return this.createWallGeometry(e);case"plane":return this.createPlaneGeometry(e);default:return console.warn("DIVEPrimitive.assembleGeometry: Invalid geometry type:",e.name.toLowerCase()),null}}createCylinderGeometry(e){const t=new s.CylinderGeometry(e.width/2,e.width/2,e.height,64);return t.translate(0,e.height/2,0),t}createSphereGeometry(e){return new s.SphereGeometry(e.width/2,256,256)}createPyramidGeometry(e){const t=new Float32Array([-e.width/2,0,-e.depth/2,e.width/2,0,-e.depth/2,e.width/2,0,e.depth/2,-e.width/2,0,e.depth/2,0,e.height,0]),a=new Uint16Array([0,1,2,0,2,3,0,4,1,1,4,2,2,4,3,3,4,0]),n=new s.BufferGeometry;return n.setAttribute("position",new s.BufferAttribute(t,3)),n.setIndex(new s.BufferAttribute(a,1)),n}createBoxGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}createConeGeometry(e){const t=new s.ConeGeometry(e.width/2,e.height,256);return t.translate(0,e.height/2,0),t}createWallGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth||.05,16);return t.translate(0,e.height/2,0),t}createPlaneGeometry(e){const t=new s.BoxGeometry(e.width,e.height,e.depth);return t.translate(0,e.height/2,0),t}}class G extends D{constructor(){super();i(this,"isDIVEGroup",!0);i(this,"_members");i(this,"_lines");this.name="DIVEGroup",this._members=[],this._lines=[]}get members(){return this._members}setPosition(e){super.setPosition(e),this._members.forEach(t=>{"isDIVENode"in t&&t.onMove()})}setLinesVisibility(e,t){if(!t){this._lines.forEach(n=>{n.visible=e});return}const a=this._members.indexOf(t);a!==-1&&(this._lines[a].visible=e)}attach(e){if(this._members.includes(e))return this;const t=this.createLine();return this.add(t),this._lines.push(t),super.attach(e),this._members.push(e),this._updateLineTo(t,e),this.setLinesVisibility(!0,e),this}remove(e){const t=this._members.indexOf(e);if(t===-1)return this;const a=this._lines[t];return super.remove(a),this._lines.splice(t,1),super.remove(e),this._members.splice(t,1),this}updateLineTo(e){const t=this._members.indexOf(e);t!==-1&&this._updateLineTo(this._lines[t],e)}createLine(){const e=new s.BufferGeometry,t=new s.LineDashedMaterial({color:6710886,dashSize:.05,gapSize:.025}),a=new s.Line(e,t);return a.visible=!1,a}_updateLineTo(e,t){const a=[new s.Vector3(0,0,0),t.position.clone()];e.geometry.setFromPoints(a),e.computeLineDistances()}}class U extends s.Mesh{constructor(){const e=new s.PlaneGeometry(1,1);e.scale(1e3,1e3,1),e.rotateX(-Math.PI/2);const t=new s.MeshStandardMaterial({color:new s.Color(16777215),side:s.FrontSide});super(e,t);i(this,"isDIVEFloor",!0);this.name="Floor",this.layers.mask=l.PRODUCT_LAYER_MASK,this.receiveShadow=!0}setVisibility(e){this.visible=e}setColor(e){this.material.color=new s.Color(e)}}class F extends s.Object3D{constructor(){super();i(this,"isDIVERoot",!0);i(this,"_floor");this.name="Root",this._floor=new U,this.add(this._floor)}get floor(){return this._floor}computeSceneBB(){const e=new s.Box3;return this.children.forEach(t=>{"isDIVEFloor"in t||t.traverse(a=>{"isObject3D"in a&&e.expandByObject(a)})}),e}getSceneObject(e){let t;return this.traverse(a=>{t||a.userData.id===e.id&&(t=a)}),t}addSceneObject(e){let t=this.getSceneObject(e);if(t)return console.warn(`DIVERoot.addSceneObject: Scene object with id ${e.id} already exists`),t;switch(e.entityType){case"pov":break;case"light":{switch(e.type){case"scene":{t=new B;break}case"ambient":{t=new k;break}case"point":{t=new O;break}default:throw new Error(`DIVERoot.addSceneObject: Unknown light type: ${e.type}`)}t.name=e.name,t.userData.id=e.id,this.add(t),this._updateLight(t,e);break}case"model":{t=new L,t.name=e.name,t.userData.id=e.id,t.userData.uri=e.uri,this.add(t),this._updateModel(t,e);break}case"primitive":{t=new z,t.name=e.name,t.userData.id=e.id,this.add(t),this._updatePrimitive(t,e);break}case"group":{t=new G,t.name=e.name,t.userData.id=e.id,this.add(t),this._updateGroup(t,e);break}default:throw new Error(`DIVERoot.addSceneObject: Unknown entity type: ${e.entityType}`)}return t}updateSceneObject(e){const t=this.getSceneObject(e);if(!t){console.warn(`DIVERoot.updateSceneObject: Scene object with id ${e.id} does not exist`);return}switch(e.entityType){case"pov":break;case"light":{this._updateLight(t,e);break}case"model":{this._updateModel(t,e);break}case"primitive":{this._updatePrimitive(t,e);break}case"group":{this._updateGroup(t,e);break}default:throw new Error(`DIVERoot.updateSceneObject: Unknown entity type: ${e.entityType}`)}}deleteSceneObject(e){const t=this.getSceneObject(e);if(!t){console.warn(`DIVERoot.deleteSceneObject: Object with id ${e.id} not found`);return}switch(e.entityType){case"pov":break;case"light":{this._deleteLight(t);break}case"model":{this._deleteModel(t);break}case"primitive":{this._deletePrimitive(t);break}case"group":{this._deleteGroup(t);break}default:throw new Error(`DIVERoot.deleteSceneObject: Unknown entity type: ${e.entityType}`)}}_updateLight(e,t){t.name!==void 0&&t.name!==null&&(e.name=t.name),t.position!==void 0&&t.position!==null&&e.position.set(t.position.x,t.position.y,t.position.z),t.intensity!==void 0&&t.intensity!==null&&e.setIntensity(t.intensity),t.enabled!==void 0&&t.enabled!==null&&e.setEnabled(t.enabled),t.color!==void 0&&t.color!==null&&e.setColor(new s.Color(t.color)),t.visible!==void 0&&t.visible!==null&&(e.visible=t.visible),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updateModel(e,t){t.uri!==void 0&&e.setFromURL(t.uri),t.name!==void 0&&(e.name=t.name),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.material!==void 0&&e.setMaterial(t.material),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updatePrimitive(e,t){t.name!==void 0&&(e.name=t.name),t.geometry!==void 0&&e.setGeometry(t.geometry),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.material!==void 0&&e.setMaterial(t.material),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_updateGroup(e,t){t.name!==void 0&&(e.name=t.name),t.position!==void 0&&e.setPosition(t.position),t.rotation!==void 0&&e.setRotation(t.rotation),t.scale!==void 0&&e.setScale(t.scale),t.visible!==void 0&&e.setVisibility(t.visible),t.bbVisible!==void 0&&e.setLinesVisibility(t.bbVisible),t.parentId!==void 0&&this._setParent({...t,parentId:t.parentId})}_deleteLight(e){this._detachTransformControls(e),e.parent.remove(e)}_deleteModel(e){this._detachTransformControls(e),e.parent.remove(e)}_deletePrimitive(e){this._detachTransformControls(e),e.parent.remove(e)}_deleteGroup(e){this._detachTransformControls(e);for(let t=e.members.length-1;t>=0;t--)this.attach(e.members[t]);e.parent.remove(e)}_setParent(e){const t=this.getSceneObject(e);if(e.parentId!==null){const a=this.getSceneObject({id:e.parentId,entityType:e.entityType});if(!a)return;a.attach(t)}else this.attach(t)}_detachTransformControls(e){this._findScene(e).children.find(t=>{"isTransformControls"in t&&t.detach()})}_findScene(e){return e.parent!==null?this._findScene(e.parent):e}}const Y="#888888",H="#dddddd";class W extends s.Object3D{constructor(){super(),this.name="Grid";const r=new s.GridHelper(100,100,Y,H);r.material.depthTest=!1,r.layers.mask=l.HELPER_LAYER_MASK,this.add(r)}setVisibility(r){this.visible=r}}const m={displayFloor:!1,displayGrid:!1,backgroundColor:"#ffffff"};class q extends s.Scene{constructor(e){super();i(this,"isDIVEScene",!0);i(this,"_root");i(this,"_grid");this.setBackground((e==null?void 0:e.backgroundColor)??m.backgroundColor),this._root=new F,this._root.floor.setVisibility((e==null?void 0:e.displayFloor)??m.displayFloor),this.add(this._root),this._grid=new W,this._grid.setVisibility((e==null?void 0:e.displayGrid)??m.displayGrid),this.add(this._grid)}get root(){return this._root}get grid(){return this._grid}setBackground(e){this.background=new s.Color(e)}computeSceneBB(){return this._root.computeSceneBB()}}const N={enableDamping:!0,dampingFactor:.05,enabled:!0,target:new s.Vector3,minDistance:0,maxDistance:1/0,minZoom:0,maxZoom:1/0,minPolarAngle:0,maxPolarAngle:Math.PI,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,enableZoom:!0,zoomSpeed:1,enableRotate:!0,rotateSpeed:1,enablePan:!0,panSpeed:1,screenSpacePanning:!0,keyPanSpeed:7,autoRotate:!1,autoRotateSpeed:2,keys:{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},mouseButtons:{LEFT:s.MOUSE.ROTATE,MIDDLE:s.MOUSE.DOLLY,RIGHT:s.MOUSE.PAN},touches:{ONE:s.TOUCH.ROTATE,TWO:s.TOUCH.DOLLY_PAN}},_=class _ extends s.EventDispatcher{constructor(e,t,a){super();i(this,"object");i(this,"domElements");i(this,"enabled",!0);i(this,"target",new s.Vector3);i(this,"minDistance",0);i(this,"maxDistance",1/0);i(this,"minZoom",0);i(this,"maxZoom",1/0);i(this,"minPolarAngle",0);i(this,"maxPolarAngle",Math.PI);i(this,"minAzimuthAngle",-1/0);i(this,"maxAzimuthAngle",1/0);i(this,"enableDamping",!0);i(this,"dampingFactor",.05);i(this,"enableZoom",!0);i(this,"zoomSpeed",1);i(this,"enableRotate",!0);i(this,"rotateSpeed",1);i(this,"enablePan",!0);i(this,"panSpeed",1);i(this,"screenSpacePanning",!0);i(this,"keyPanSpeed",7);i(this,"autoRotate",!1);i(this,"autoRotateSpeed",2);i(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"});i(this,"mouseButtons",{LEFT:s.MOUSE.ROTATE,MIDDLE:s.MOUSE.DOLLY,RIGHT:s.MOUSE.PAN});i(this,"touches",{ONE:s.TOUCH.ROTATE,TWO:s.TOUCH.DOLLY_PAN});i(this,"target0");i(this,"position0");i(this,"zoom0");i(this,"uuid",s.MathUtils.generateUUID());i(this,"state",-1);i(this,"EPS",1e-6);i(this,"spherical",new s.Spherical);i(this,"sphericalDelta",new s.Spherical);i(this,"scale",1);i(this,"panOffset",new s.Vector3);i(this,"zoomChanged",!1);i(this,"rotateStart",new s.Vector2);i(this,"rotateEnd",new s.Vector2);i(this,"rotateDelta",new s.Vector2);i(this,"panStart",new s.Vector2);i(this,"panEnd",new s.Vector2);i(this,"panDelta",new s.Vector2);i(this,"dollyStart",new s.Vector2);i(this,"dollyEnd",new s.Vector2);i(this,"dollyDelta",new s.Vector2);i(this,"pointers",[]);i(this,"pointerPositions",{});i(this,"offset",new s.Vector3);i(this,"quat");i(this,"quatInverse");i(this,"lastPosition",new s.Vector3);i(this,"lastQuaternion",new s.Quaternion);i(this,"lastTarget",new s.Vector3);i(this,"panLeft",(()=>{const e=new s.Vector3;return(t,a)=>{e.setFromMatrixColumn(a,0),e.multiplyScalar(-t),this.panOffset.add(e)}})());i(this,"panUp",(()=>{const e=new s.Vector3;return(t,a)=>{this.screenSpacePanning===!0?e.setFromMatrixColumn(a,1):(e.setFromMatrixColumn(a,0),e.crossVectors(this.object.up,e)),e.multiplyScalar(t),this.panOffset.add(e)}})());i(this,"onMouseDown",e=>{let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case s.MOUSE.DOLLY:if(this.enableZoom===!1)return;this.handleMouseDownDolly(e),this.state=1;break;case s.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}break;case s.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(e),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(e),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});i(this,"onMouseMove",e=>{if(this.enabled!==!1)switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(e);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(e);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(e);break}});i(this,"onMouseWheel",e=>{this.enabled===!1||this.enableZoom===!1||this.state!==-1||(e.preventDefault(),this.dispatchEvent({type:"start"}),this.handleMouseWheel(e),this.dispatchEvent({type:"end"}))});i(this,"onKeyDown",e=>{this.enabled===!1||this.enablePan===!1||this.handleKeyDown(e)});i(this,"onTouchStart",e=>{switch(this.trackPointer(e),this.pointers.length){case 1:switch(this.touches.ONE){case s.TOUCH.ROTATE:if(this.enableRotate===!1)return;this.handleTouchStartRotate(e),this.state=3;break;case s.TOUCH.PAN:if(this.enablePan===!1)return;this.handleTouchStartPan(e),this.state=4;break;default:this.state=-1}break;case 2:switch(this.touches.TWO){case s.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(e),this.state=5;break;case s.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(e),this.state=6;break;default:this.state=-1}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent({type:"start"})});i(this,"onTouchMove",e=>{switch(this.trackPointer(e),this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(e),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(e),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(e),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(e),this.update();break;default:this.state=-1}});i(this,"onPointerDown",e=>{if(this.enabled!==!1){if(this.pointers.length===0){const t=e.currentTarget;t.setPointerCapture(e.pointerId),t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp)}this.isTrackingPointer(e)||(this.addPointer(e),e.pointerType==="touch"?this.onTouchStart(e):this.onMouseDown(e))}});i(this,"onPointerMove",e=>{this.enabled!==!1&&(e.pointerType==="touch"?this.onTouchMove(e):this.onMouseMove(e))});i(this,"onPointerUp",e=>{if(this.removePointer(e),this.pointers.length===0){const t=e.currentTarget;t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),this.dispatchEvent({type:"end"}),this.state=-1}});i(this,"onPointerCancel",e=>{this.removePointer(e)});i(this,"onContextMenu",e=>{this.enabled!==!1&&e.preventDefault()});this.object=e,this.domElements=Array.isArray(t)?t:[t],Object.assign(this,a),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat=new s.Quaternion().setFromUnitVectors(e.up,new s.Vector3(0,1,0)),this.quatInverse=this.quat.clone().invert(),this.domElements.forEach(n=>this.addEventListeners(n)),this.update()}get domElement(){return this.domElements[0]}tick(){this.enabled&&this.update()}getPolarAngle(){return this.spherical.phi}getAzimuthalAngle(){return this.spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent({type:"change"}),this.update(),this.state=-1}update(){return this.offset.copy(this.object.position).sub(this.target),this.offset.applyQuaternion(this.quat),this.spherical.setFromVector3(this.offset),this.autoRotate&&this.state===-1&&this.rotateLeft(this.getAutoRotationAngle()),this.enableDamping?(this.spherical.theta+=this.sphericalDelta.theta*this.dampingFactor,this.spherical.phi+=this.sphericalDelta.phi*this.dampingFactor):(this.spherical.theta+=this.sphericalDelta.theta,this.spherical.phi+=this.sphericalDelta.phi),this.spherical.theta=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this.spherical.theta)),this.spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this.spherical.phi)),this.spherical.makeSafe(),this.spherical.radius*=this.scale,this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius)),this.enableDamping===!0?this.target.addScaledVector(this.panOffset,this.dampingFactor):this.target.add(this.panOffset),this.offset.setFromSpherical(this.spherical),this.offset.applyQuaternion(this.quatInverse),this.object.position.copy(this.target).add(this.offset),this.object.lookAt(this.target),this.enableDamping===!0?(this.sphericalDelta.theta*=1-this.dampingFactor,this.sphericalDelta.phi*=1-this.dampingFactor,this.panOffset.multiplyScalar(1-this.dampingFactor)):(this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0)),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>this.EPS||8*(1-this.lastQuaternion.dot(this.object.quaternion))>this.EPS||this.lastTarget.distanceToSquared(this.target)>this.EPS?(this.dispatchEvent({type:"change"}),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.lastTarget.copy(this.target),this.zoomChanged=!1,!0):!1}dispose(){this.domElements.forEach(e=>this.removeEventListeners(e)),this.dispatchEvent({type:"dispose"})}addDomElements(...e){e.forEach(t=>{this.domElements.includes(t)||(this.domElements.push(t),this.addEventListeners(t))})}removeDomElements(...e){e.forEach(t=>{const a=this.domElements.indexOf(t);a>-1&&(this.removeEventListeners(t),this.domElements.splice(a,1))})}setDomElements(...e){this.removeDomElements(...this.domElements),this.domElements=[],this.addDomElements(...e)}computeEncompassingView(e,t=0){const a=e.center,o=e.sphere.radius,c=this.object.fov*(Math.PI/180),d=this.object.aspect,u=c/2,g=Math.atan(Math.tan(u)*d),f=o/Math.sin(u),E=o/Math.sin(g),w=Math.max(f,E)*(1+t),R=this.object.position.clone().sub(this.target).normalize(),ee=R.length()>.001?R:new s.Vector3(0,0,1);return{position:a.clone().add(ee.multiplyScalar(w)),target:a}}focusObject(e,t=0){const a=new y(e),n=this.computeEncompassingView(a,t);this.object.position.copy(n.position),this.target.copy(n.target),this.update()}zoomIn(e){this.dollyIn(Math.pow(.95,e??_.DEFAULT_ZOOM_FACTOR)),this.update()}zoomOut(e){this.dollyOut(Math.pow(.95,e??_.DEFAULT_ZOOM_FACTOR)),this.update()}getState(){return{target:this.target.clone(),azimuthalAngle:this.getAzimuthalAngle(),polarAngle:this.getPolarAngle(),distance:this.getDistance(),position:this.object.position.clone(),quaternion:this.object.quaternion.clone()}}setState(e){this.target.copy(e.target),this.object.position.copy(e.position),this.object.quaternion.copy(e.quaternion),this.update()}addEventListeners(e){e.style.touchAction="none",e.addEventListener("contextmenu",this.onContextMenu),e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointercancel",this.onPointerCancel),e.addEventListener("wheel",this.onMouseWheel,{passive:!1}),e.addEventListener("keydown",this.onKeyDown)}removeEventListeners(e){e.removeEventListener("contextmenu",this.onContextMenu),e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointercancel",this.onPointerCancel),e.removeEventListener("wheel",this.onMouseWheel),e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(e){this.sphericalDelta.theta-=e}rotateUp(e){this.sphericalDelta.phi-=e}pan(e,t,a){const n=new s.Vector3;if("isPerspectiveCamera"in this.object){const o=this.object.position;n.copy(o).sub(this.target);let c=n.length();c*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*e*c/a.clientHeight,this.object.matrix),this.panUp(2*t*c/a.clientHeight,this.object.matrix)}else"isOrthographicCamera"in this.object?(this.panLeft(e*(this.object.right-this.object.left)/this.object.zoom/a.clientWidth,this.object.matrix),this.panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/a.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitController encountered an unknown camera type - pan disabled."),this.enablePan=!1)}dollyIn(e){"isPerspectiveCamera"in this.object||"isOrthographicCamera"in this.object?this.scale*=e:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyOut(e){"isPerspectiveCamera"in this.object||"isOrthographicCamera"in this.object?this.scale/=e:(console.warn("WARNING: OrbitController encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleMouseMoveRotate(e){this.rotateEnd.set(e.clientX,e.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);const t=e.currentTarget;this.rotateLeft(2*Math.PI*this.rotateDelta.x/t.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/t.clientHeight),this.rotateStart.copy(this.rotateEnd),this.update()}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyIn(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyOut(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(e){const t=e.currentTarget;this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,t),this.panStart.copy(this.panEnd),this.update()}handleMouseWheel(e){e.deltaY<0?this.dollyIn(this.getZoomScale()):e.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update()}handleKeyDown(e){let t=!1;const a=e.currentTarget;switch(e.code){case this.keys.UP:this.pan(0,this.keyPanSpeed,a),t=!0;break;case this.keys.BOTTOM:this.pan(0,-this.keyPanSpeed,a),t=!0;break;case this.keys.LEFT:this.pan(this.keyPanSpeed,0,a),t=!0;break;case this.keys.RIGHT:this.pan(-this.keyPanSpeed,0,a),t=!0;break}t&&(e.preventDefault(),this.update())}handleTouchStartRotate(e){if(this.pointers.length===1)this.rotateStart.set(e.pageX,e.pageY);else{const t=this.getSecondPointer(e),a=.5*(e.pageX+t.pageX),n=.5*(e.pageY+t.pageY);this.rotateStart.set(a,n)}}handleTouchStartPan(e){if(this.pointers.length===1)this.panStart.set(e.pageX,e.pageY);else{const t=this.getSecondPointer(e),a=.5*(e.pageX+t.pageX),n=.5*(e.pageY+t.pageY);this.panStart.set(a,n)}}handleTouchStartDolly(e){const t=this.getSecondPointer(e),a=e.pageX-t.pageX,n=e.pageY-t.pageY,o=Math.sqrt(a*a+n*n);this.dollyStart.set(0,o)}handleTouchStartDollyPan(e){this.enableZoom&&this.handleTouchStartDolly(e),this.enablePan&&this.handleTouchStartPan(e)}handleTouchStartDollyRotate(e){this.enableZoom&&this.handleTouchStartDolly(e),this.enableRotate&&this.handleTouchStartRotate(e)}handleTouchMoveRotate(e){if(this.pointers.length===1)this.rotateEnd.set(e.pageX,e.pageY);else{const a=this.getSecondPointer(e),n=.5*(e.pageX+a.pageX),o=.5*(e.pageY+a.pageY);this.rotateEnd.set(n,o)}const t=e.currentTarget;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed),this.rotateLeft(2*Math.PI*this.rotateDelta.x/t.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/t.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(e){if(this.pointers.length===1)this.panEnd.set(e.pageX,e.pageY);else{const a=this.getSecondPointer(e),n=.5*(e.pageX+a.pageX),o=.5*(e.pageY+a.pageY);this.panEnd.set(n,o)}const t=e.currentTarget;this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y,t),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(e){const t=this.getSecondPointer(e),a=e.pageX-t.pageX,n=e.pageY-t.pageY,o=Math.sqrt(a*a+n*n);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(e){this.enableZoom&&this.handleTouchMoveDolly(e),this.enablePan&&this.handleTouchMovePan(e)}handleTouchMoveDollyRotate(e){this.enableZoom&&this.handleTouchMoveDolly(e),this.enableRotate&&this.handleTouchMoveRotate(e)}addPointer(e){this.pointers.push(e)}removePointer(e){delete this.pointerPositions[e.pointerId];for(let t=0;t<this.pointers.length;t++)if(this.pointers[t].pointerId==e.pointerId){this.pointers.splice(t,1);return}}trackPointer(e){let t=this.pointerPositions[e.pointerId];t===void 0&&(t=new s.Vector2,this.pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}getSecondPointer(e){return this.pointers[0].pointerId===e.pointerId?this.pointers[1]:this.pointers[0]}isTrackingPointer(e){return this.pointers.some(t=>t.pointerId===e.pointerId)}};i(_,"DEFAULT_ZOOM_FACTOR",1);let P=_;class Z extends s.Object3D{constructor(){super();i(this,"_axesHelper");this._axesHelper=new s.AxesHelper(.5),this._axesHelper.layers.mask=l.COORDINATE_LAYER_MASK,this._axesHelper.material.depthTest=!1,this._axesHelper.position.set(0,0,-1),this._axesHelper.setColors(new s.Color(Q),new s.Color(J),new s.Color(j));const e=new b("X",.2,T),t=new b("Y",.2,x),a=new b("Z",.2,V);e.layers.mask=l.COORDINATE_LAYER_MASK,t.layers.mask=l.COORDINATE_LAYER_MASK,a.layers.mask=l.COORDINATE_LAYER_MASK,e.position.set(.7,0,0),t.position.set(0,.7,0),a.position.set(0,0,.7),this._axesHelper.add(e),this._axesHelper.add(t),this._axesHelper.add(a)}setFromCameraMatrix(e){this._axesHelper.rotation.setFromRotationMatrix(new s.Matrix4().extractRotation(e).invert())}}class K{constructor(r,e,t){i(this,"uuid",s.MathUtils.generateUUID());i(this,"_axes");i(this,"_orthographicCamera");i(this,"_restoreViewport",new s.Vector4);this._renderer=r,this._scene=e,this._camera=t,this._orthographicCamera=new s.OrthographicCamera(-1,1,1,-1,.1,100),this._orthographicCamera.layers.mask=l.COORDINATE_LAYER_MASK,this._scene.add(this._orthographicCamera),this._axes=new Z,this._scene.add(this._axes)}tick(){const r=this._scene.background;this._scene.background=null,this._renderer.webglrenderer.getViewport(this._restoreViewport),this._renderer.webglrenderer.setViewport(0,0,150,150),this._renderer.webglrenderer.autoClear=!1,this._axes.setFromCameraMatrix(this._camera.matrix),this._renderer.webglrenderer.render(this._scene,this._orthographicCamera),this._renderer.webglrenderer.setViewport(this._restoreViewport),this._renderer.webglrenderer.autoClear=!0,this._scene.background=r}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}const re=`
|
|
2
2
|
@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@
|
|
3
3
|
@@@@+-:::::::---------------------==------------------------------=#@@@@
|
|
4
4
|
@@%=::::.......::---------------------------------------------------------+@@
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
@@%-::::::::::::-%@ @%-------------=%@@
|
|
27
27
|
@@@@+:::::::#@@ @@*-------*@@@@
|
|
28
28
|
@@@@@@@ @@@@@@
|
|
29
|
-
`;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const p={autoStart:!0,displayAxes:!1,...m,...l.DIVEPerspectiveCameraDefaultSettings,...M,...N};class X{constructor(r){i(this,"_instanceId",s.MathUtils.generateUUID());i(this,"_settings");i(this,"_views");i(this,"_mainView");i(this,"_scene");i(this,"_clock");i(this,"orientationDisplay");this._settings={...p,...r??{}},this._clock=new A,this._scene=new q
|
|
29
|
+
`;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const p={autoStart:!0,displayAxes:!1,...m,...l.DIVEPerspectiveCameraDefaultSettings,...M,...N};class X{constructor(r){i(this,"_instanceId",s.MathUtils.generateUUID());i(this,"_settings");i(this,"_views");i(this,"_mainView");i(this,"_scene");i(this,"_clock");i(this,"orientationDisplay");this._settings={...p,...r??{}},this._clock=new A,this._scene=new q({backgroundColor:(r==null?void 0:r.backgroundColor)??p.backgroundColor,displayGrid:(r==null?void 0:r.displayGrid)??p.displayGrid,displayFloor:(r==null?void 0:r.displayFloor)??p.displayFloor});const e=new S(this._scene,new l.DIVEPerspectiveCamera,this._settings);this._clock.addTicker(e),this._views=[e],this._mainView=e,this._settings.autoStart&&this.start(),this._settings.displayAxes?(console.log("displayAxes",this._settings.displayAxes),this.orientationDisplay=new K(this.mainView.renderer,this.scene,this.mainView.camera),this.clock.addTicker(this.orientationDisplay)):this.orientationDisplay=null,console.log("DIVE 2.2.4 initialized successfully!"),console.log(re),window.DIVE.instances.push(this)}static async QuickView(r,e){return Promise.resolve().then(()=>require("../plugins/quickview/index.cjs")).then(({QuickView:t})=>t(r,e))}get engine(){return{scene:this.scene,camera:this.mainView.camera,renderer:this.mainView.renderer,setCanvas:r=>{this.mainView.setCanvas(r)},clock:this.clock,start:()=>{this.start()},stop:()=>{this.stop()},dispose:()=>{this.dispose()}}}get views(){return this._views}get mainView(){return this._mainView}get canvas(){return this.mainView.canvas}get scene(){return this._scene}get clock(){return this._clock}start(){this._clock.start()}stop(){this._clock.stop()}async dispose(){return new Promise(r=>{this._views.forEach(e=>{e.dispose()}),this._views=[],this.orientationDisplay&&(this._clock.removeTicker(this.orientationDisplay),this.orientationDisplay.dispose()),window.DIVE.instances=window.DIVE.instances.filter(e=>e._instanceId!==this._instanceId),r()})}createView(r){const e=new S(this._scene,r??new l.DIVEPerspectiveCamera,{...this._settings,canvas:void 0});return this._views.push(e),this._clock.addTicker(e),this._views.length===1&&(this._mainView=e),e}disposeView(r){this._views=this._views.filter(e=>e!==r),this._clock.removeTicker(r),this._mainView===r&&(this._mainView=this._views[0]),r.dispose()}}const ae=X,T="#c20017",x="#00ab26",V="#0081d4",Q=T,J=x,j=V,$={glb:{key:"glb",extension:"glb"},gltf:{key:"gltf",extension:"gltf"},usdz:{key:"usdz",extension:"usdz"}},ne=Object.values($).map(h=>h.extension);exports.AxesColorBlue=j;exports.AxesColorBlueLetter=V;exports.AxesColorGreen=J;exports.AxesColorGreenLetter=x;exports.AxesColorRed=Q;exports.AxesColorRedLetter=T;exports.BoundingBox=y;exports.DIVE=X;exports.DIVEAmbientLight=k;exports.DIVEClock=A;exports.DIVEDefaultSettings=p;exports.DIVEEngine=ae;exports.DIVEFloor=U;exports.DIVEGrid=W;exports.DIVEGroup=G;exports.DIVEModel=L;exports.DIVENode=D;exports.DIVEPointLight=O;exports.DIVEPrimitive=z;exports.DIVERenderPipeline=se;exports.DIVERenderer=I;exports.DIVERendererDefaultSettings=M;exports.DIVEResizeManager=C;exports.DIVERoot=F;exports.DIVEScene=q;exports.DIVESceneDefaultSettings=m;exports.DIVESceneLight=B;exports.DIVEView=S;exports.FILE_TYPES=$;exports.GRID_CENTER_LINE_COLOR=Y;exports.GRID_SIDE_LINE_COLOR=H;exports.OrbitController=P;exports.OrbitControllerDefaultSettings=N;exports.OrientationDisplay=K;exports.OrientationDisplayAxes=Z;exports.SUPPORTED_FILE_TYPES=ne;exports.findSceneRecursive=v;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
|
+
var K = (b, t, c) => t in b ? J(b, t, { enumerable: !0, configurable: !0, writable: !0, value: c }) : b[t] = c;
|
|
3
|
+
var y = (b, t, c) => K(b, typeof t != "symbol" ? t + "" : t, c);
|
|
4
|
+
import { DataTextureLoader as Q, HalfFloatType as L, FloatType as x, DataUtils as G, LinearSRGBColorSpace as z, LinearFilter as V, PMREMGenerator as Z, SRGBColorSpace as Y, ACESFilmicToneMapping as ee, EquirectangularReflectionMapping as P, Scene as te, SphereGeometry as ne, MeshBasicMaterial as re, BackSide as ie, Mesh as se, NoToneMapping as oe, WebGLCubeRenderTarget as ae, CubeCamera as ce } from "three";
|
|
5
|
+
class j extends Q {
|
|
6
|
+
constructor(t) {
|
|
7
|
+
super(t), this.type = L;
|
|
8
|
+
}
|
|
9
|
+
// adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
|
|
10
|
+
parse(t) {
|
|
11
|
+
const o = function(e, r) {
|
|
12
|
+
switch (e) {
|
|
13
|
+
case 1:
|
|
14
|
+
throw new Error("THREE.RGBELoader: Read Error: " + (r || ""));
|
|
15
|
+
case 2:
|
|
16
|
+
throw new Error("THREE.RGBELoader: Write Error: " + (r || ""));
|
|
17
|
+
case 3:
|
|
18
|
+
throw new Error("THREE.RGBELoader: Bad File Format: " + (r || ""));
|
|
19
|
+
default:
|
|
20
|
+
case 4:
|
|
21
|
+
throw new Error("THREE.RGBELoader: Memory Error: " + (r || ""));
|
|
22
|
+
}
|
|
23
|
+
}, F = `
|
|
24
|
+
`, f = function(e, r, s) {
|
|
25
|
+
r = r || 1024;
|
|
26
|
+
let h = e.pos, l = -1, n = 0, p = "", i = String.fromCharCode.apply(null, new Uint16Array(e.subarray(h, h + 128)));
|
|
27
|
+
for (; 0 > (l = i.indexOf(F)) && n < r && h < e.byteLength; )
|
|
28
|
+
p += i, n += i.length, h += 128, i += String.fromCharCode.apply(null, new Uint16Array(e.subarray(h, h + 128)));
|
|
29
|
+
return -1 < l ? (e.pos += n + l + 1, p + i.slice(0, l)) : !1;
|
|
30
|
+
}, O = function(e) {
|
|
31
|
+
const r = /^#\?(\S+)/, s = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, a = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, h = /^\s*FORMAT=(\S+)\s*$/, l = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, n = {
|
|
32
|
+
valid: 0,
|
|
33
|
+
/* indicate which fields are valid */
|
|
34
|
+
string: "",
|
|
35
|
+
/* the actual header string */
|
|
36
|
+
comments: "",
|
|
37
|
+
/* comments found in header */
|
|
38
|
+
programtype: "RGBE",
|
|
39
|
+
/* listed at beginning of file to identify it after "#?". defaults to "RGBE" */
|
|
40
|
+
format: "",
|
|
41
|
+
/* RGBE format, default 32-bit_rle_rgbe */
|
|
42
|
+
gamma: 1,
|
|
43
|
+
/* image has already been gamma corrected with given gamma. defaults to 1.0 (no correction) */
|
|
44
|
+
exposure: 1,
|
|
45
|
+
/* a value of 1.0 in an image corresponds to <exposure> watts/steradian/m^2. defaults to 1.0 */
|
|
46
|
+
width: 0,
|
|
47
|
+
height: 0
|
|
48
|
+
/* image dimensions, width/height */
|
|
49
|
+
};
|
|
50
|
+
let p, i;
|
|
51
|
+
for ((e.pos >= e.byteLength || !(p = f(e))) && o(1, "no header found"), (i = p.match(r)) || o(3, "bad initial token"), n.valid |= 1, n.programtype = i[1], n.string += p + `
|
|
52
|
+
`; p = f(e), p !== !1; ) {
|
|
53
|
+
if (n.string += p + `
|
|
54
|
+
`, p.charAt(0) === "#") {
|
|
55
|
+
n.comments += p + `
|
|
56
|
+
`;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if ((i = p.match(s)) && (n.gamma = parseFloat(i[1])), (i = p.match(a)) && (n.exposure = parseFloat(i[1])), (i = p.match(h)) && (n.valid |= 2, n.format = i[1]), (i = p.match(l)) && (n.valid |= 4, n.height = parseInt(i[1], 10), n.width = parseInt(i[2], 10)), n.valid & 2 && n.valid & 4) break;
|
|
60
|
+
}
|
|
61
|
+
return n.valid & 2 || o(3, "missing format specifier"), n.valid & 4 || o(3, "missing image size specifier"), n;
|
|
62
|
+
}, $ = function(e, r, s) {
|
|
63
|
+
const a = r;
|
|
64
|
+
if (
|
|
65
|
+
// run length encoding is not allowed so read flat
|
|
66
|
+
a < 8 || a > 32767 || // this file is not run length encoded
|
|
67
|
+
e[0] !== 2 || e[1] !== 2 || e[2] & 128
|
|
68
|
+
)
|
|
69
|
+
return new Uint8Array(e);
|
|
70
|
+
a !== (e[2] << 8 | e[3]) && o(3, "wrong scanline width");
|
|
71
|
+
const h = new Uint8Array(4 * r * s);
|
|
72
|
+
h.length || o(4, "unable to allocate buffer space");
|
|
73
|
+
let l = 0, n = 0;
|
|
74
|
+
const p = 4 * a, i = new Uint8Array(4), v = new Uint8Array(p);
|
|
75
|
+
let H = s;
|
|
76
|
+
for (; H > 0 && n < e.byteLength; ) {
|
|
77
|
+
n + 4 > e.byteLength && o(1), i[0] = e[n++], i[1] = e[n++], i[2] = e[n++], i[3] = e[n++], (i[0] != 2 || i[1] != 2 || (i[2] << 8 | i[3]) != a) && o(3, "bad rgbe scanline format");
|
|
78
|
+
let S = 0, d;
|
|
79
|
+
for (; S < p && n < e.byteLength; ) {
|
|
80
|
+
d = e[n++];
|
|
81
|
+
const E = d > 128;
|
|
82
|
+
if (E && (d -= 128), (d === 0 || S + d > p) && o(3, "bad scanline data"), E) {
|
|
83
|
+
const _ = e[n++];
|
|
84
|
+
for (let N = 0; N < d; N++)
|
|
85
|
+
v[S++] = _;
|
|
86
|
+
} else
|
|
87
|
+
v.set(e.subarray(n, n + d), S), S += d, n += d;
|
|
88
|
+
}
|
|
89
|
+
const X = a;
|
|
90
|
+
for (let E = 0; E < X; E++) {
|
|
91
|
+
let _ = 0;
|
|
92
|
+
h[l] = v[E + _], _ += a, h[l + 1] = v[E + _], _ += a, h[l + 2] = v[E + _], _ += a, h[l + 3] = v[E + _], l += 4;
|
|
93
|
+
}
|
|
94
|
+
H--;
|
|
95
|
+
}
|
|
96
|
+
return h;
|
|
97
|
+
}, W = function(e, r, s, a) {
|
|
98
|
+
const h = e[r + 3], l = Math.pow(2, h - 128) / 255;
|
|
99
|
+
s[a + 0] = e[r + 0] * l, s[a + 1] = e[r + 1] * l, s[a + 2] = e[r + 2] * l, s[a + 3] = 1;
|
|
100
|
+
}, q = function(e, r, s, a) {
|
|
101
|
+
const h = e[r + 3], l = Math.pow(2, h - 128) / 255;
|
|
102
|
+
s[a + 0] = G.toHalfFloat(Math.min(e[r + 0] * l, 65504)), s[a + 1] = G.toHalfFloat(Math.min(e[r + 1] * l, 65504)), s[a + 2] = G.toHalfFloat(Math.min(e[r + 2] * l, 65504)), s[a + 3] = G.toHalfFloat(1);
|
|
103
|
+
}, k = new Uint8Array(t);
|
|
104
|
+
k.pos = 0;
|
|
105
|
+
const M = O(k), D = M.width, U = M.height, A = $(k.subarray(k.pos), D, U);
|
|
106
|
+
let T, C, I;
|
|
107
|
+
switch (this.type) {
|
|
108
|
+
case x:
|
|
109
|
+
I = A.length / 4;
|
|
110
|
+
const e = new Float32Array(I * 4);
|
|
111
|
+
for (let s = 0; s < I; s++)
|
|
112
|
+
W(A, s * 4, e, s * 4);
|
|
113
|
+
T = e, C = x;
|
|
114
|
+
break;
|
|
115
|
+
case L:
|
|
116
|
+
I = A.length / 4;
|
|
117
|
+
const r = new Uint16Array(I * 4);
|
|
118
|
+
for (let s = 0; s < I; s++)
|
|
119
|
+
q(A, s * 4, r, s * 4);
|
|
120
|
+
T = r, C = L;
|
|
121
|
+
break;
|
|
122
|
+
default:
|
|
123
|
+
throw new Error("THREE.RGBELoader: Unsupported type: " + this.type);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
width: D,
|
|
127
|
+
height: U,
|
|
128
|
+
data: T,
|
|
129
|
+
header: M.string,
|
|
130
|
+
gamma: M.gamma,
|
|
131
|
+
exposure: M.exposure,
|
|
132
|
+
type: C
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
setDataType(t) {
|
|
136
|
+
return this.type = t, this;
|
|
137
|
+
}
|
|
138
|
+
load(t, c, g, B) {
|
|
139
|
+
function m(o, w) {
|
|
140
|
+
switch (o.type) {
|
|
141
|
+
case x:
|
|
142
|
+
case L:
|
|
143
|
+
o.colorSpace = z, o.minFilter = V, o.magFilter = V, o.generateMipmaps = !1, o.flipY = !0;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
c && c(o, w);
|
|
147
|
+
}
|
|
148
|
+
return super.load(t, m, g, B);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const pe = {
|
|
152
|
+
enabled: !0,
|
|
153
|
+
imageUrl: void 0,
|
|
154
|
+
useAsBackground: !0,
|
|
155
|
+
globalEnvIntensity: 1,
|
|
156
|
+
exposure: 1,
|
|
157
|
+
rotateY: 0,
|
|
158
|
+
replaceLights: !0
|
|
159
|
+
};
|
|
160
|
+
class ge {
|
|
161
|
+
constructor(t, c, g = {}) {
|
|
162
|
+
y(this, "renderer");
|
|
163
|
+
y(this, "scene");
|
|
164
|
+
y(this, "pmrem");
|
|
165
|
+
y(this, "currentEnvRT", null);
|
|
166
|
+
y(this, "currentBackgroundCube", null);
|
|
167
|
+
y(this, "sourceImage", null);
|
|
168
|
+
y(this, "originalLights", []);
|
|
169
|
+
y(this, "options");
|
|
170
|
+
this.renderer = t, this.scene = c, this.pmrem = new Z(t), this.options = g, this.options.imageUrl && (this.sourceImage = new j().loadAsync(
|
|
171
|
+
this.options.imageUrl
|
|
172
|
+
)), this.options.enabled && this.enable();
|
|
173
|
+
}
|
|
174
|
+
async enable(t) {
|
|
175
|
+
if (this.options = { ...this.options, enabled: !0, ...t }, !this.options.imageUrl) return;
|
|
176
|
+
this.renderer.outputColorSpace = Y, this.renderer.toneMapping = ee, this.options.exposure != null && (this.renderer.toneMappingExposure = this.options.exposure), this.sourceImage || (this.sourceImage = new j().loadAsync(
|
|
177
|
+
this.options.imageUrl
|
|
178
|
+
));
|
|
179
|
+
const c = await this.sourceImage;
|
|
180
|
+
if (c.mapping = P, this.options.useAsBackground && (this.scene.background = c), this.options.rotateY)
|
|
181
|
+
await this.applyRotationAndSetEnvironment(this.options.rotateY);
|
|
182
|
+
else {
|
|
183
|
+
const g = this.pmrem.fromEquirectangular(c);
|
|
184
|
+
this.cleanupEnv(), this.currentEnvRT = g, this.scene.environment = g.texture;
|
|
185
|
+
}
|
|
186
|
+
this.applyEnvIntensity(
|
|
187
|
+
this.scene,
|
|
188
|
+
this.options.globalEnvIntensity ?? 1
|
|
189
|
+
), this.options.replaceLights && this.disableExistingLights();
|
|
190
|
+
}
|
|
191
|
+
async setImageUrl(t) {
|
|
192
|
+
this.options.imageUrl = t, this.sourceImage = null, this.options.enabled && await this.enable();
|
|
193
|
+
}
|
|
194
|
+
async setRotationY(t) {
|
|
195
|
+
this.options.rotateY = t, this.sourceImage && await this.applyRotationAndSetEnvironment(t);
|
|
196
|
+
}
|
|
197
|
+
setExposure(t) {
|
|
198
|
+
this.options.exposure = t, this.renderer.toneMappingExposure = t;
|
|
199
|
+
}
|
|
200
|
+
setGlobalEnvIntensity(t) {
|
|
201
|
+
this.options.globalEnvIntensity = t, this.applyEnvIntensity(this.scene, t);
|
|
202
|
+
}
|
|
203
|
+
disable() {
|
|
204
|
+
this.options.enabled = !1, this.scene.environment = null, this.restoreLights(), this.cleanupEnv();
|
|
205
|
+
}
|
|
206
|
+
async dispose() {
|
|
207
|
+
this.disable(), this.pmrem.dispose(), this.sourceImage && ((await this.sourceImage).dispose(), this.sourceImage = null);
|
|
208
|
+
}
|
|
209
|
+
async applyRotationAndSetEnvironment(t) {
|
|
210
|
+
if (!this.sourceImage) return;
|
|
211
|
+
const c = await this.sourceImage, g = new te(), B = new ne(10, 60, 40);
|
|
212
|
+
c.mapping = P;
|
|
213
|
+
const m = new re({ map: c, side: ie }), o = new se(B, m);
|
|
214
|
+
o.scale.set(1, 1, -1), o.rotation.y = t, g.add(o);
|
|
215
|
+
const w = this.renderer.toneMapping, u = this.renderer.outputColorSpace;
|
|
216
|
+
this.renderer.toneMapping = oe, this.renderer.outputColorSpace = z;
|
|
217
|
+
const R = new ae(1024, { type: L });
|
|
218
|
+
new ce(0.1, 1e3, R).update(this.renderer, g), this.renderer.toneMapping = w, this.renderer.outputColorSpace = u;
|
|
219
|
+
const f = this.pmrem.fromCubemap(R.texture);
|
|
220
|
+
this.cleanupEnv(), this.currentEnvRT = f, this.scene.environment = f.texture, this.options.useAsBackground && (this.scene.background = R.texture, this.currentBackgroundCube && (this.currentBackgroundCube.texture.dispose(), this.currentBackgroundCube.dispose()), this.currentBackgroundCube = R), this.applyEnvIntensity(
|
|
221
|
+
this.scene,
|
|
222
|
+
this.options.globalEnvIntensity ?? 1
|
|
223
|
+
), this.options.useAsBackground || (R.texture.dispose(), R.dispose());
|
|
224
|
+
}
|
|
225
|
+
applyEnvIntensity(t, c) {
|
|
226
|
+
t.traverse((g) => {
|
|
227
|
+
const m = g.material;
|
|
228
|
+
if (!m) return;
|
|
229
|
+
const o = Array.isArray(m) ? m : [m];
|
|
230
|
+
for (const w of o) {
|
|
231
|
+
const u = w;
|
|
232
|
+
u && "envMapIntensity" in u && (u.envMapIntensity = c, u.needsUpdate = !0), u && u.map && "colorSpace" in u.map && (u.map.colorSpace = Y);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
disableExistingLights() {
|
|
237
|
+
const t = [];
|
|
238
|
+
this.scene.traverse((c) => {
|
|
239
|
+
const g = c;
|
|
240
|
+
g.isLight && (g.visible = !1, t.push(g));
|
|
241
|
+
}), this.originalLights = t;
|
|
242
|
+
}
|
|
243
|
+
restoreLights() {
|
|
244
|
+
for (const t of this.originalLights)
|
|
245
|
+
t.visible = !0;
|
|
246
|
+
this.originalLights = [];
|
|
247
|
+
}
|
|
248
|
+
cleanupEnv() {
|
|
249
|
+
this.currentEnvRT && (this.currentEnvRT.texture.dispose(), this.currentEnvRT.dispose(), this.currentEnvRT = null), this.currentBackgroundCube && (this.currentBackgroundCube.texture.dispose(), this.currentBackgroundCube.dispose(), this.currentBackgroundCube = null);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
export {
|
|
253
|
+
pe as H,
|
|
254
|
+
ge as a
|
|
255
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var z=Object.defineProperty;var O=(b,t,c)=>t in b?z(b,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[t]=c;var R=(b,t,c)=>O(b,typeof t!="symbol"?t+"":t,c);const r=require("three");class H extends r.DataTextureLoader{constructor(t){super(t),this.type=r.HalfFloatType}parse(t){const o=function(e,i){switch(e){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(i||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(i||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(i||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(i||""))}},C=`
|
|
2
|
+
`,S=function(e,i,s){i=i||1024;let h=e.pos,p=-1,n=0,u="",a=String.fromCharCode.apply(null,new Uint16Array(e.subarray(h,h+128)));for(;0>(p=a.indexOf(C))&&n<i&&h<e.byteLength;)u+=a,n+=a.length,h+=128,a+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(h,h+128)));return-1<p?(e.pos+=n+p+1,u+a.slice(0,p)):!1},N=function(e){const i=/^#\?(\S+)/,s=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,l=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,h=/^\s*FORMAT=(\S+)\s*$/,p=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,n={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let u,a;for((e.pos>=e.byteLength||!(u=S(e)))&&o(1,"no header found"),(a=u.match(i))||o(3,"bad initial token"),n.valid|=1,n.programtype=a[1],n.string+=u+`
|
|
3
|
+
`;u=S(e),u!==!1;){if(n.string+=u+`
|
|
4
|
+
`,u.charAt(0)==="#"){n.comments+=u+`
|
|
5
|
+
`;continue}if((a=u.match(s))&&(n.gamma=parseFloat(a[1])),(a=u.match(l))&&(n.exposure=parseFloat(a[1])),(a=u.match(h))&&(n.valid|=2,n.format=a[1]),(a=u.match(p))&&(n.valid|=4,n.height=parseInt(a[1],10),n.width=parseInt(a[2],10)),n.valid&2&&n.valid&4)break}return n.valid&2||o(3,"missing format specifier"),n.valid&4||o(3,"missing image size specifier"),n},V=function(e,i,s){const l=i;if(l<8||l>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);l!==(e[2]<<8|e[3])&&o(3,"wrong scanline width");const h=new Uint8Array(4*i*s);h.length||o(4,"unable to allocate buffer space");let p=0,n=0;const u=4*l,a=new Uint8Array(4),B=new Uint8Array(u);let U=s;for(;U>0&&n<e.byteLength;){n+4>e.byteLength&&o(1),a[0]=e[n++],a[1]=e[n++],a[2]=e[n++],a[3]=e[n++],(a[0]!=2||a[1]!=2||(a[2]<<8|a[3])!=l)&&o(3,"bad rgbe scanline format");let T=0,E;for(;T<u&&n<e.byteLength;){E=e[n++];const y=E>128;if(y&&(E-=128),(E===0||T+E>u)&&o(3,"bad scanline data"),y){const _=e[n++];for(let x=0;x<E;x++)B[T++]=_}else B.set(e.subarray(n,n+E),T),T+=E,n+=E}const j=l;for(let y=0;y<j;y++){let _=0;h[p]=B[y+_],_+=l,h[p+1]=B[y+_],_+=l,h[p+2]=B[y+_],_+=l,h[p+3]=B[y+_],p+=4}U--}return h},Y=function(e,i,s,l){const h=e[i+3],p=Math.pow(2,h-128)/255;s[l+0]=e[i+0]*p,s[l+1]=e[i+1]*p,s[l+2]=e[i+2]*p,s[l+3]=1},P=function(e,i,s,l){const h=e[i+3],p=Math.pow(2,h-128)/255;s[l+0]=r.DataUtils.toHalfFloat(Math.min(e[i+0]*p,65504)),s[l+1]=r.DataUtils.toHalfFloat(Math.min(e[i+1]*p,65504)),s[l+2]=r.DataUtils.toHalfFloat(Math.min(e[i+2]*p,65504)),s[l+3]=r.DataUtils.toHalfFloat(1)},L=new Uint8Array(t);L.pos=0;const M=N(L),F=M.width,D=M.height,G=V(L.subarray(L.pos),F,D);let k,A,v;switch(this.type){case r.FloatType:v=G.length/4;const e=new Float32Array(v*4);for(let s=0;s<v;s++)Y(G,s*4,e,s*4);k=e,A=r.FloatType;break;case r.HalfFloatType:v=G.length/4;const i=new Uint16Array(v*4);for(let s=0;s<v;s++)P(G,s*4,i,s*4);k=i,A=r.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:F,height:D,data:k,header:M.string,gamma:M.gamma,exposure:M.exposure,type:A}}setDataType(t){return this.type=t,this}load(t,c,g,I){function d(o,f){switch(o.type){case r.FloatType:case r.HalfFloatType:o.colorSpace=r.LinearSRGBColorSpace,o.minFilter=r.LinearFilter,o.magFilter=r.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}c&&c(o,f)}return super.load(t,d,g,I)}}const q={enabled:!0,imageUrl:void 0,useAsBackground:!0,globalEnvIntensity:1,exposure:1,rotateY:0,replaceLights:!0};class ${constructor(t,c,g={}){R(this,"renderer");R(this,"scene");R(this,"pmrem");R(this,"currentEnvRT",null);R(this,"currentBackgroundCube",null);R(this,"sourceImage",null);R(this,"originalLights",[]);R(this,"options");this.renderer=t,this.scene=c,this.pmrem=new r.PMREMGenerator(t),this.options=g,this.options.imageUrl&&(this.sourceImage=new H().loadAsync(this.options.imageUrl)),this.options.enabled&&this.enable()}async enable(t){if(this.options={...this.options,enabled:!0,...t},!this.options.imageUrl)return;this.renderer.outputColorSpace=r.SRGBColorSpace,this.renderer.toneMapping=r.ACESFilmicToneMapping,this.options.exposure!=null&&(this.renderer.toneMappingExposure=this.options.exposure),this.sourceImage||(this.sourceImage=new H().loadAsync(this.options.imageUrl));const c=await this.sourceImage;if(c.mapping=r.EquirectangularReflectionMapping,this.options.useAsBackground&&(this.scene.background=c),this.options.rotateY)await this.applyRotationAndSetEnvironment(this.options.rotateY);else{const g=this.pmrem.fromEquirectangular(c);this.cleanupEnv(),this.currentEnvRT=g,this.scene.environment=g.texture}this.applyEnvIntensity(this.scene,this.options.globalEnvIntensity??1),this.options.replaceLights&&this.disableExistingLights()}async setImageUrl(t){this.options.imageUrl=t,this.sourceImage=null,this.options.enabled&&await this.enable()}async setRotationY(t){this.options.rotateY=t,this.sourceImage&&await this.applyRotationAndSetEnvironment(t)}setExposure(t){this.options.exposure=t,this.renderer.toneMappingExposure=t}setGlobalEnvIntensity(t){this.options.globalEnvIntensity=t,this.applyEnvIntensity(this.scene,t)}disable(){this.options.enabled=!1,this.scene.environment=null,this.restoreLights(),this.cleanupEnv()}async dispose(){this.disable(),this.pmrem.dispose(),this.sourceImage&&((await this.sourceImage).dispose(),this.sourceImage=null)}async applyRotationAndSetEnvironment(t){if(!this.sourceImage)return;const c=await this.sourceImage,g=new r.Scene,I=new r.SphereGeometry(10,60,40);c.mapping=r.EquirectangularReflectionMapping;const d=new r.MeshBasicMaterial({map:c,side:r.BackSide}),o=new r.Mesh(I,d);o.scale.set(1,1,-1),o.rotation.y=t,g.add(o);const f=this.renderer.toneMapping,m=this.renderer.outputColorSpace;this.renderer.toneMapping=r.NoToneMapping,this.renderer.outputColorSpace=r.LinearSRGBColorSpace;const w=new r.WebGLCubeRenderTarget(1024,{type:r.HalfFloatType});new r.CubeCamera(.1,1e3,w).update(this.renderer,g),this.renderer.toneMapping=f,this.renderer.outputColorSpace=m;const S=this.pmrem.fromCubemap(w.texture);this.cleanupEnv(),this.currentEnvRT=S,this.scene.environment=S.texture,this.options.useAsBackground&&(this.scene.background=w.texture,this.currentBackgroundCube&&(this.currentBackgroundCube.texture.dispose(),this.currentBackgroundCube.dispose()),this.currentBackgroundCube=w),this.applyEnvIntensity(this.scene,this.options.globalEnvIntensity??1),this.options.useAsBackground||(w.texture.dispose(),w.dispose())}applyEnvIntensity(t,c){t.traverse(g=>{const d=g.material;if(!d)return;const o=Array.isArray(d)?d:[d];for(const f of o){const m=f;m&&"envMapIntensity"in m&&(m.envMapIntensity=c,m.needsUpdate=!0),m&&m.map&&"colorSpace"in m.map&&(m.map.colorSpace=r.SRGBColorSpace)}})}disableExistingLights(){const t=[];this.scene.traverse(c=>{const g=c;g.isLight&&(g.visible=!1,t.push(g))}),this.originalLights=t}restoreLights(){for(const t of this.originalLights)t.visible=!0;this.originalLights=[]}cleanupEnv(){this.currentEnvRT&&(this.currentEnvRT.texture.dispose(),this.currentEnvRT.dispose(),this.currentEnvRT=null),this.currentBackgroundCube&&(this.currentBackgroundCube.texture.dispose(),this.currentBackgroundCube.dispose(),this.currentBackgroundCube=null)}}exports.HDREnvironment=$;exports.HDREnvironmentDefaultSettings=q;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var jt = Object.defineProperty;
|
|
2
2
|
var Xt = (r, i, t) => i in r ? jt(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
|
|
3
3
|
var c = (r, i, t) => Xt(r, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
-
import { A as lt, g as ht, h as ct } from "./FileTypes-
|
|
4
|
+
import { A as lt, g as ht, h as ct } from "./FileTypes-C6ZTNzXM.mjs";
|
|
5
5
|
import { Object3D as st, Vector3 as a, Quaternion as E, Raycaster as bt, MeshBasicMaterial as St, LineBasicMaterial as Yt, CylinderGeometry as w, BoxGeometry as f, BufferGeometry as dt, Float32BufferAttribute as pt, Mesh as o, OctahedronGeometry as B, Line as I, TorusGeometry as C, SphereGeometry as Qt, Euler as Zt, Matrix4 as vt, PlaneGeometry as Ht, DoubleSide as Ot, Vector2 as tt } from "three";
|
|
6
6
|
import { f as ot, i as et } from "./findInterface-DbJ5qzbc.mjs";
|
|
7
7
|
import { P as Ct, U as kt } from "./PerspectiveCamera-BFzE2TQU.mjs";
|