@shopware-ag/dive 2.2.1 → 2.2.2

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.
Files changed (27) hide show
  1. package/build/chunks/{AssetCache-B-m6VZSR.mjs → AssetCache-CZF_bKOU.mjs} +1 -1
  2. package/build/chunks/{AssetCache-udwfFvkY.cjs → AssetCache-D1_YD57U.cjs} +1 -1
  3. package/build/chunks/{AssetLoader-DCLXUeFD.mjs → AssetLoader-BMBH74ql.mjs} +2 -2
  4. package/build/chunks/{AssetLoader-DL8Fd2Vp.cjs → AssetLoader-DtpL2Rvh.cjs} +1 -1
  5. package/build/chunks/{FileTypes-DWBc6D11.cjs → FileTypes-BQlqpkm2.cjs} +2 -2
  6. package/build/chunks/{FileTypes-CjmCMP7P.mjs → FileTypes-Bov2_HgT.mjs} +5 -3
  7. package/build/chunks/{SelectTool-204u2Sqa.cjs → SelectTool-BZVnTJYv.cjs} +1 -1
  8. package/build/chunks/{SelectTool-aH-q193I.mjs → SelectTool-DDFLa3rP.mjs} +1 -1
  9. package/build/dive.cjs +1 -1
  10. package/build/dive.mjs +2 -2
  11. package/build/plugins/ar/index.cjs +1 -1
  12. package/build/plugins/ar/index.mjs +1 -1
  13. package/build/plugins/assetcache/index.cjs +1 -1
  14. package/build/plugins/assetcache/index.mjs +1 -1
  15. package/build/plugins/assetloader/index.cjs +1 -1
  16. package/build/plugins/assetloader/index.mjs +1 -1
  17. package/build/plugins/orbitcontroller/index.cjs +1 -1
  18. package/build/plugins/orbitcontroller/index.mjs +1 -1
  19. package/build/plugins/orientationdisplay/index.cjs +1 -1
  20. package/build/plugins/orientationdisplay/index.mjs +1 -1
  21. package/build/plugins/quickview/index.cjs +1 -1
  22. package/build/plugins/quickview/index.mjs +6 -6
  23. package/build/plugins/state/index.cjs +1 -1
  24. package/build/plugins/state/index.mjs +2 -2
  25. package/build/plugins/toolbox/index.cjs +1 -1
  26. package/build/plugins/toolbox/index.mjs +2 -2
  27. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  var h = Object.defineProperty;
2
2
  var c = (s, e, t) => e in s ? h(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
3
  var r = (s, e, t) => c(s, typeof e != "symbol" ? e + "" : e, t);
4
- import "./FileTypes-CjmCMP7P.mjs";
4
+ import "./FileTypes-Bov2_HgT.mjs";
5
5
  import "three";
6
6
  import { N as o, F as _ } from "./network-error-BONfHWQq.mjs";
7
7
  class n {
@@ -1 +1 @@
1
- "use strict";var n=Object.defineProperty;var u=(s,e,t)=>e in s?n(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var r=(s,e,t)=>u(s,typeof e!="symbol"?e+"":e,t);require("./FileTypes-DWBc6D11.cjs");require("three");const h=require("./network-error-CdDXil5g.cjs");class c{constructor(e){r(this,"_promise");r(this,"_resolve");r(this,"_arrayBuffer",null);r(this,"_size",0);r(this,"_createdAt");r(this,"_updatedAt");this._uri=e,this._promise=new Promise(t=>{this._resolve=t}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}async load(){const e=await fetch(this._uri);if(!e.ok)throw new h.NetworkError(this._uri);try{this._arrayBuffer=await e.arrayBuffer(),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date}catch{throw new h.FileContentError(this._uri)}return this._resolve(this._arrayBuffer),this._arrayBuffer}}class o{constructor(){r(this,"_cache",new Map)}get(){return this._cache}create(e){const t=new c(e);return this._cache.set(e,t),t}write(e,t){this._cache.set(e,t)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(t=>{this._cache.delete(t)})}clear(){this._cache.clear()}}const a=Symbol.for("@shopware-ag/dive/assetcache"),i=globalThis;i[a]||(i[a]=new o);const _=i[a];exports.AssetCache=_;exports.Chunk=c;
1
+ "use strict";var n=Object.defineProperty;var u=(s,e,t)=>e in s?n(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var r=(s,e,t)=>u(s,typeof e!="symbol"?e+"":e,t);require("./FileTypes-BQlqpkm2.cjs");require("three");const h=require("./network-error-CdDXil5g.cjs");class c{constructor(e){r(this,"_promise");r(this,"_resolve");r(this,"_arrayBuffer",null);r(this,"_size",0);r(this,"_createdAt");r(this,"_updatedAt");this._uri=e,this._promise=new Promise(t=>{this._resolve=t}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}async load(){const e=await fetch(this._uri);if(!e.ok)throw new h.NetworkError(this._uri);try{this._arrayBuffer=await e.arrayBuffer(),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date}catch{throw new h.FileContentError(this._uri)}return this._resolve(this._arrayBuffer),this._arrayBuffer}}class o{constructor(){r(this,"_cache",new Map)}get(){return this._cache}create(e){const t=new c(e);return this._cache.set(e,t),t}write(e,t){this._cache.set(e,t)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(t=>{this._cache.delete(t)})}clear(){this._cache.clear()}}const a=Symbol.for("@shopware-ag/dive/assetcache"),i=globalThis;i[a]||(i[a]=new o);const _=i[a];exports.AssetCache=_;exports.Chunk=c;
@@ -3,10 +3,10 @@ var Be = (d, e, t) => e in d ? ve(d, e, { enumerable: !0, configurable: !0, writ
3
3
  var v = (d, e, t) => Be(d, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { TrianglesDrawMode as je, TriangleFanDrawMode as re, TriangleStripDrawMode as be, Loader as ae, LoaderUtils as X, FileLoader as K, MeshPhysicalMaterial as O, Vector2 as q, Color as U, LinearSRGBColorSpace as D, SRGBColorSpace as N, SpotLight as Ke, PointLight as Ve, DirectionalLight as We, Matrix4 as Y, Vector3 as B, Quaternion as Le, InstancedMesh as Xe, InstancedBufferAttribute as ze, Object3D as ce, TextureLoader as Me, ImageBitmapLoader as qe, BufferAttribute as P, InterleavedBuffer as Ye, InterleavedBufferAttribute as Je, LinearMipmapLinearFilter as Ie, NearestMipmapLinearFilter as Qe, LinearMipmapNearestFilter as Ze, NearestMipmapNearestFilter as $e, LinearFilter as Ce, NearestFilter as et, RepeatWrapping as J, MirroredRepeatWrapping as Ne, ClampToEdgeWrapping as De, PointsMaterial as tt, Material as Z, LineBasicMaterial as nt, MeshStandardMaterial as Oe, DoubleSide as st, MeshBasicMaterial as W, PropertyBinding as rt, BufferGeometry as ue, SkinnedMesh as ot, Mesh as Pe, LineSegments as it, Line as at, LineLoop as ct, Points as ut, Group as z, PerspectiveCamera as lt, MathUtils as ft, OrthographicCamera as dt, Skeleton as ht, AnimationClip as pt, Bone as mt, InterpolateDiscrete as gt, InterpolateLinear as ke, Texture as de, VectorKeyframeTrack as he, NumberKeyframeTrack as pe, QuaternionKeyframeTrack as me, ColorManagement as ge, FrontSide as At, Interpolant as Tt, Box3 as yt, Sphere as xt, NoColorSpace as H } from "three";
5
5
  import { u as Rt, a as Ae } from "./fflate.module-xyO_T3Zm.mjs";
6
- import { S as _t } from "./FileTypes-CjmCMP7P.mjs";
6
+ import { S as _t } from "./FileTypes-Bov2_HgT.mjs";
7
7
  import { g as wt, i as Et } from "./isFileTypeSupported-BSpswPHU.mjs";
8
8
  import { F as Te, P as ye } from "./parse-error-DfOPyLWM.mjs";
9
- import { A as xe } from "./AssetCache-B-m6VZSR.mjs";
9
+ import { A as xe } from "./AssetCache-CZF_bKOU.mjs";
10
10
  function Re(d, e) {
11
11
  if (e === je)
12
12
  return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), d;
@@ -1,4 +1,4 @@
1
- "use strict";var le=Object.defineProperty;var ue=(h,e,t)=>e in h?le(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var k=(h,e,t)=>ue(h,typeof e!="symbol"?e+"":e,t);const f=require("three"),H=require("./fflate.module-DHdJvhNh.cjs"),fe=require("./FileTypes-DWBc6D11.cjs"),J=require("./isFileTypeSupported-CrEqYiv9.cjs"),U=require("./parse-error-Dy_EE4rL.cjs"),Q=require("./AssetCache-udwfFvkY.cjs");function Z(h,e){if(e===f.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),h;if(e===f.TriangleFanDrawMode||e===f.TriangleStripDrawMode){let t=h.getIndex();if(t===null){const n=[],a=h.getAttribute("position");if(a!==void 0){for(let i=0;i<a.count;i++)n.push(i);h.setIndex(n),t=h.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),h}const o=t.count-2,s=[];if(e===f.TriangleFanDrawMode)for(let n=1;n<=o;n++)s.push(t.getX(0)),s.push(t.getX(n)),s.push(t.getX(n+1));else for(let n=0;n<o;n++)n%2===0?(s.push(t.getX(n)),s.push(t.getX(n+1)),s.push(t.getX(n+2))):(s.push(t.getX(n+2)),s.push(t.getX(n+1)),s.push(t.getX(n)));s.length/3!==o&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=h.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),h}class de extends f.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ae(t)}),this.register(function(t){return new Ee(t)}),this.register(function(t){return new be(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new ye(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new ge(t)}),this.register(function(t){return new _e(t)}),this.register(function(t){return new Te(t)}),this.register(function(t){return new Le(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new pe(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new Ie(t)})}load(e,t,o,s){const r=this;let n;if(this.resourcePath!=="")n=this.resourcePath;else if(this.path!==""){const c=f.LoaderUtils.extractUrlBase(e);n=f.LoaderUtils.resolveURL(c,this.path)}else n=f.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){s?s(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},i=new f.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{r.parse(c,n,function(l){t(l),r.manager.itemEnd(e)},a)}catch(l){a(l)}},o,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,o,s){let r;const n={},a={},i=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(i.decode(new Uint8Array(e,0,4))===se){try{n[b.KHR_BINARY_GLTF]=new Ne(e)}catch(u){s&&s(u);return}r=JSON.parse(n[b.KHR_BINARY_GLTF].content)}else r=JSON.parse(i.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Ve(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const u=this.pluginCallbacks[l](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,n[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){const u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:n[u]=new me;break;case b.KHR_DRACO_MESH_COMPRESSION:n[u]=new De(r,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:n[u]=new Oe;break;case b.KHR_MESH_QUANTIZATION:n[u]=new Pe;break;default:d.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(n),c.setPlugins(a),c.parse(o,s)}parseAsync(e,t){const o=this;return new Promise(function(s,r){o.parse(e,t,s,r)})}}function he(){let h={};return{get:function(e){return h[e]},add:function(e,t){h[e]=t},remove:function(e){delete h[e]},removeAll:function(){h={}}}}const b={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class pe{constructor(e){this.parser=e,this.name=b.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let o=0,s=t.length;o<s;o++){const r=t[o];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,o="light:"+e;let s=t.cache.get(o);if(s)return s;const r=t.json,i=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const l=new f.Color(16777215);i.color!==void 0&&l.setRGB(i.color[0],i.color[1],i.color[2],f.LinearSRGBColorSpace);const u=i.range!==void 0?i.range:0;switch(i.type){case"directional":c=new f.DirectionalLight(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new f.PointLight(l),c.distance=u;break;case"spot":c=new f.SpotLight(l),c.distance=u,i.spot=i.spot||{},i.spot.innerConeAngle=i.spot.innerConeAngle!==void 0?i.spot.innerConeAngle:0,i.spot.outerConeAngle=i.spot.outerConeAngle!==void 0?i.spot.outerConeAngle:Math.PI/4,c.angle=i.spot.outerConeAngle,c.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return c.position.set(0,0,0),c.decay=2,O(c,i),i.intensity!==void 0&&(c.intensity=i.intensity),c.name=t.createUniqueName(i.name||"light_"+e),s=Promise.resolve(c),t.cache.add(o,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,o=this.parser,r=o.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(i){return o._getNodeRef(t.cache,a,i)})}}class me{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return f.MeshBasicMaterial}extendParams(e,t,o){const s=[];e.color=new f.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const n=r.baseColorFactor;e.color.setRGB(n[0],n[1],n[2],f.LinearSRGBColorSpace),e.opacity=n[3]}r.baseColorTexture!==void 0&&s.push(o.assignTexture(e,"map",r.baseColorTexture,f.SRGBColorSpace))}return Promise.all(s)}}class ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Ae{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(o.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(o.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(o.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const a=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f.Vector2(a,a)}return Promise.all(r)}}class Te{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(o.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(o.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(r)}}class ye{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new f.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const n=s.extensions[this.name];if(n.sheenColorFactor!==void 0){const a=n.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(o.assignTexture(t,"sheenColorMap",n.sheenColorTexture,f.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&r.push(o.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(r)}}class Re{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(o.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(r)}}class xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&r.push(o.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const a=n.attenuationColor||[1,1,1];return t.attenuationColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),Promise.all(r)}}class Se{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class _e{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&r.push(o.assignTexture(t,"specularIntensityMap",n.specularTexture));const a=n.specularColorFactor||[1,1,1];return t.specularColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&r.push(o.assignTexture(t,"specularColorMap",n.specularColorTexture,f.SRGBColorSpace)),Promise.all(r)}}class we{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&r.push(o.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(r)}}class Le{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(o.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(r)}}class Ee{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,o=t.json,s=o.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],n=t.options.ktx2Loader;if(!n){if(o.extensionsRequired&&o.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,n)}}class be{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,o=this.parser,s=o.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const n=r.extensions[t],a=s.images[n.source];let i=o.textureLoader;if(a.uri){const c=o.options.manager.getHandler(a.uri);c!==null&&(i=c)}return this.detectSupport().then(function(c){if(c)return o.loadTextureImage(e,n.source,i);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return o.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Me{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,o=this.parser,s=o.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const n=r.extensions[t],a=s.images[n.source];let i=o.textureLoader;if(a.uri){const c=o.options.manager.getHandler(a.uri);c!==null&&(i=c)}return this.detectSupport().then(function(c){if(c)return o.loadTextureImage(e,n.source,i);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return o.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ce{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,o=t.bufferViews[e];if(o.extensions&&o.extensions[this.name]){const s=o.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const i=s.byteOffset||0,c=s.byteLength||0,l=s.count,u=s.byteStride,d=new Uint8Array(a,i,c);return n.decodeGltfBufferAsync?n.decodeGltfBufferAsync(l,u,d,s.mode,s.filter).then(function(g){return g.buffer}):n.ready.then(function(){const g=new ArrayBuffer(l*u);return n.decodeGltfBuffer(new Uint8Array(g),l,u,d,s.mode,s.filter),g})})}else return null}}class Ie{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,o=t.nodes[e];if(!o.extensions||!o.extensions[this.name]||o.mesh===void 0)return null;const s=t.meshes[o.mesh];for(const c of s.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const n=o.extensions[this.name].attributes,a=[],i={};for(const c in n)a.push(this.parser.getDependency("accessor",n[c]).then(l=>(i[c]=l,i[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,g=[];for(const y of u){const S=new f.Matrix4,R=new f.Vector3,x=new f.Quaternion,L=new f.Vector3(1,1,1),E=new f.InstancedMesh(y.geometry,y.material,d);for(let _=0;_<d;_++)i.TRANSLATION&&R.fromBufferAttribute(i.TRANSLATION,_),i.ROTATION&&x.fromBufferAttribute(i.ROTATION,_),i.SCALE&&L.fromBufferAttribute(i.SCALE,_),E.setMatrixAt(_,S.compose(R,x,L));for(const _ in i)if(_==="_COLOR_0"){const C=i[_];E.instanceColor=new f.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&y.geometry.setAttribute(_,i[_]);f.Object3D.prototype.copy.call(E,y),this.parser.assignFinalMaterial(E),g.push(E)}return l.isGroup?(l.clear(),l.add(...g),l):g[0]}))}}const se="glTF",G=12,$={JSON:1313821514,BIN:5130562};class Ne{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,G),o=new TextDecoder;if(this.header={magic:o.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==se)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-G,r=new DataView(e,G);let n=0;for(;n<s;){const a=r.getUint32(n,!0);n+=4;const i=r.getUint32(n,!0);if(n+=4,i===$.JSON){const c=new Uint8Array(e,G+n,a);this.content=o.decode(c)}else if(i===$.BIN){const c=G+n;this.body=e.slice(c,c+a)}n+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class De{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const o=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,n=e.extensions[this.name].attributes,a={},i={},c={};for(const l in n){const u=X[l]||l.toLowerCase();a[u]=n[l]}for(const l in e.attributes){const u=X[l]||l.toLowerCase();if(n[l]!==void 0){const d=o.accessors[e.attributes[l]],g=F[d.componentType];c[u]=g.name,i[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){s.decodeDracoFile(l,function(g){for(const y in g.attributes){const S=g.attributes[y],R=i[y];R!==void 0&&(S.normalized=R)}u(g)},a,c,f.LinearSRGBColorSpace,d)})})}}class Oe{constructor(){this.name=b.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Pe{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class re extends f.Interpolant{constructor(e,t,o,s){super(e,t,o,s)}copySampleValue_(e){const t=this.resultBuffer,o=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let n=0;n!==s;n++)t[n]=o[r+n];return t}interpolate_(e,t,o,s){const r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,i=a*2,c=a*3,l=s-t,u=(o-t)/l,d=u*u,g=d*u,y=e*c,S=y-c,R=-2*g+3*d,x=g-d,L=1-R,E=x-d+u;for(let _=0;_!==a;_++){const C=n[S+_+a],I=n[S+_+i]*l,M=n[y+_+a],p=n[y+_]*l;r[_]=L*C+E*I+R*M+x*p}return r}}const ke=new f.Quaternion;class Fe extends re{interpolate_(e,t,o,s){const r=super.interpolate_(e,t,o,s);return ke.fromArray(r).normalize().toArray(r),r}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},F={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ee={9728:f.NearestFilter,9729:f.LinearFilter,9984:f.NearestMipmapNearestFilter,9985:f.LinearMipmapNearestFilter,9986:f.NearestMipmapLinearFilter,9987:f.LinearMipmapLinearFilter},te={33071:f.ClampToEdgeWrapping,33648:f.MirroredRepeatWrapping,10497:f.RepeatWrapping},v={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},D={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ge={CUBICSPLINE:void 0,LINEAR:f.InterpolateLinear,STEP:f.InterpolateDiscrete},j={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ue(h){return h.DefaultMaterial===void 0&&(h.DefaultMaterial=new f.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:f.FrontSide})),h.DefaultMaterial}function P(h,e,t){for(const o in t.extensions)h[o]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[o]=t.extensions[o])}function O(h,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(h.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Be(h,e,t){let o=!1,s=!1,r=!1;for(let c=0,l=e.length;c<l;c++){const u=e[c];if(u.POSITION!==void 0&&(o=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),o&&s&&r)break}if(!o&&!s&&!r)return Promise.resolve(h);const n=[],a=[],i=[];for(let c=0,l=e.length;c<l;c++){const u=e[c];if(o){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):h.attributes.position;n.push(d)}if(s){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):h.attributes.normal;a.push(d)}if(r){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):h.attributes.color;i.push(d)}}return Promise.all([Promise.all(n),Promise.all(a),Promise.all(i)]).then(function(c){const l=c[0],u=c[1],d=c[2];return o&&(h.morphAttributes.position=l),s&&(h.morphAttributes.normal=u),r&&(h.morphAttributes.color=d),h.morphTargetsRelative=!0,h})}function He(h,e){if(h.updateMorphTargets(),e.weights!==void 0)for(let t=0,o=e.weights.length;t<o;t++)h.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(h.morphTargetInfluences.length===t.length){h.morphTargetDictionary={};for(let o=0,s=t.length;o<s;o++)h.morphTargetDictionary[t[o]]=o}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ve(h){let e;const t=h.extensions&&h.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+K(t.attributes):e=h.indices+":"+K(h.attributes)+":"+h.mode,h.targets!==void 0)for(let o=0,s=h.targets.length;o<s;o++)e+=":"+K(h.targets[o]);return e}function K(h){let e="";const t=Object.keys(h).sort();for(let o=0,s=t.length;o<s;o++)e+=t[o]+":"+h[t[o]]+";";return e}function q(h){switch(h){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function je(h){return h.search(/\.jpe?g($|\?)/i)>0||h.search(/^data\:image\/jpeg/)===0?"image/jpeg":h.search(/\.webp($|\?)/i)>0||h.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Ke=new f.Matrix4;class Ve{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new he,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let o=!1,s=!1,r=-1;typeof navigator<"u"&&(o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,r=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||o||s&&r<98?this.textureLoader=new f.TextureLoader(this.options.manager):this.textureLoader=new f.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new f.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const o=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(n){return n._markDefs&&n._markDefs()}),Promise.all(this._invokeAll(function(n){return n.beforeRoot&&n.beforeRoot()})).then(function(){return Promise.all([o.getDependencies("scene"),o.getDependencies("animation"),o.getDependencies("camera")])}).then(function(n){const a={scene:n[0][s.scene||0],scenes:n[0],animations:n[1],cameras:n[2],asset:s.asset,parser:o,userData:{}};return P(r,a,s),O(a,s),Promise.all(o._invokeAll(function(i){return i.afterRoot&&i.afterRoot(a)})).then(function(){for(const i of a.scenes)i.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],o=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const n=t[s].joints;for(let a=0,i=n.length;a<i;a++)e[n[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const n=e[s];n.mesh!==void 0&&(this._addNodeRef(this.meshCache,n.mesh),n.skin!==void 0&&(o[n.mesh].isSkinnedMesh=!0)),n.camera!==void 0&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,o){if(e.refs[t]<=1)return o;const s=o.clone(),r=(n,a)=>{const i=this.associations.get(n);i!=null&&this.associations.set(a,i);for(const[c,l]of n.children.entries())r(l,a.children[c])};return r(o,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let o=0;o<t.length;o++){const s=e(t[o]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const o=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&o.push(r)}return o}getDependency(e,t){const o=e+":"+t;let s=this.cache.get(o);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(o,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const o=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,n){return o.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],o=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,n){o.load(f.LoaderUtils.resolveURL(t.uri,s.path),r,void 0,function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(o){const s=t.byteLength||0,r=t.byteOffset||0;return o.slice(r,r+s)})}loadAccessor(e){const t=this,o=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const n=v[s.type],a=F[s.componentType],i=s.normalized===!0,c=new a(s.count*n);return Promise.resolve(new f.BufferAttribute(c,n,i))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(n){const a=n[0],i=v[s.type],c=F[s.componentType],l=c.BYTES_PER_ELEMENT,u=l*i,d=s.byteOffset||0,g=s.bufferView!==void 0?o.bufferViews[s.bufferView].byteStride:void 0,y=s.normalized===!0;let S,R;if(g&&g!==u){const x=Math.floor(d/g),L="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+x+":"+s.count;let E=t.cache.get(L);E||(S=new c(a,x*g,s.count*g/l),E=new f.InterleavedBuffer(S,g/l),t.cache.add(L,E)),R=new f.InterleavedBufferAttribute(E,i,d%g/l,y)}else a===null?S=new c(s.count*i):S=new c(a,d,s.count*i),R=new f.BufferAttribute(S,i,y);if(s.sparse!==void 0){const x=v.SCALAR,L=F[s.sparse.indices.componentType],E=s.sparse.indices.byteOffset||0,_=s.sparse.values.byteOffset||0,C=new L(n[1],E,s.sparse.count*x),I=new c(n[2],_,s.sparse.count*i);a!==null&&(R=new f.BufferAttribute(R.array.slice(),R.itemSize,R.normalized));for(let M=0,p=C.length;M<p;M++){const m=C[M];if(R.setX(m,I[M*i]),i>=2&&R.setY(m,I[M*i+1]),i>=3&&R.setZ(m,I[M*i+2]),i>=4&&R.setW(m,I[M*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return R})}loadTexture(e){const t=this.json,o=this.options,r=t.textures[e].source,n=t.images[r];let a=this.textureLoader;if(n.uri){const i=o.manager.getHandler(n.uri);i!==null&&(a=i)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,o){const s=this,r=this.json,n=r.textures[e],a=r.images[t],i=(a.uri||a.bufferView)+":"+n.sampler;if(this.textureCache[i])return this.textureCache[i];const c=this.loadImageSource(t,o).then(function(l){l.flipY=!1,l.name=n.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);const d=(r.samplers||{})[n.sampler]||{};return l.magFilter=ee[d.magFilter]||f.LinearFilter,l.minFilter=ee[d.minFilter]||f.LinearMipmapLinearFilter,l.wrapS=te[d.wrapS]||f.RepeatWrapping,l.wrapT=te[d.wrapT]||f.RepeatWrapping,s.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[i]=c,c}loadImageSource(e,t){const o=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const n=s.images[e],a=self.URL||self.webkitURL;let i=n.uri||"",c=!1;if(n.bufferView!==void 0)i=o.getDependency("bufferView",n.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:n.mimeType});return i=a.createObjectURL(d),i});else if(n.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(i).then(function(u){return new Promise(function(d,g){let y=d;t.isImageBitmapLoader===!0&&(y=function(S){const R=new f.Texture(S);R.needsUpdate=!0,d(R)}),t.load(f.LoaderUtils.resolveURL(u,r.path),y,void 0,g)})}).then(function(u){return c===!0&&a.revokeObjectURL(i),u.userData.mimeType=n.mimeType||je(n.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),u});return this.sourceCache[e]=l,l}assignTexture(e,t,o,s){const r=this;return this.getDependency("texture",o.index).then(function(n){if(!n)return null;if(o.texCoord!==void 0&&o.texCoord>0&&(n=n.clone(),n.channel=o.texCoord),r.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=o.extensions!==void 0?o.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const i=r.associations.get(n);n=r.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(n,a),r.associations.set(n,i)}}return s!==void 0&&(n.colorSpace=s),e[t]=n,n})}assignFinalMaterial(e){const t=e.geometry;let o=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,n=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+o.uuid;let i=this.cache.get(a);i||(i=new f.PointsMaterial,f.Material.prototype.copy.call(i,o),i.color.copy(o.color),i.map=o.map,i.sizeAttenuation=!1,this.cache.add(a,i)),o=i}else if(e.isLine){const a="LineBasicMaterial:"+o.uuid;let i=this.cache.get(a);i||(i=new f.LineBasicMaterial,f.Material.prototype.copy.call(i,o),i.color.copy(o.color),i.map=o.map,this.cache.add(a,i)),o=i}if(s||r||n){let a="ClonedMaterial:"+o.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),n&&(a+="flat-shading:");let i=this.cache.get(a);i||(i=o.clone(),r&&(i.vertexColors=!0),n&&(i.flatShading=!0),s&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(a,i),this.associations.set(i,this.associations.get(o))),o=i}e.material=o}getMaterialType(){return f.MeshStandardMaterial}loadMaterial(e){const t=this,o=this.json,s=this.extensions,r=o.materials[e];let n;const a={},i=r.extensions||{},c=[];if(i[b.KHR_MATERIALS_UNLIT]){const u=s[b.KHR_MATERIALS_UNLIT];n=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new f.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],f.LinearSRGBColorSpace),a.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,f.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),n=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=f.DoubleSide);const l=r.alphaMode||j.OPAQUE;if(l===j.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===j.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&n!==f.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new f.Vector2(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&n!==f.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&n!==f.MeshBasicMaterial){const u=r.emissiveFactor;a.emissive=new f.Color().setRGB(u[0],u[1],u[2],f.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&n!==f.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,f.SRGBColorSpace)),Promise.all(c).then(function(){const u=new n(a);return r.name&&(u.name=r.name),O(u,r),t.associations.set(u,{materials:e}),r.extensions&&P(s,u,r),u})}createUniqueName(e){const t=f.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,o=this.extensions,s=this.primitiveCache;function r(a){return o[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(i){return ne(i,a,t)})}const n=[];for(let a=0,i=e.length;a<i;a++){const c=e[a],l=ve(c),u=s[l];if(u)n.push(u.promise);else{let d;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=ne(new f.BufferGeometry,c,t),s[l]={primitive:c,promise:d},n.push(d)}}return Promise.all(n)}loadMesh(e){const t=this,o=this.json,s=this.extensions,r=o.meshes[e],n=r.primitives,a=[];for(let i=0,c=n.length;i<c;i++){const l=n[i].material===void 0?Ue(this.cache):this.getDependency("material",n[i].material);a.push(l)}return a.push(t.loadGeometries(n)),Promise.all(a).then(function(i){const c=i.slice(0,i.length-1),l=i[i.length-1],u=[];for(let g=0,y=l.length;g<y;g++){const S=l[g],R=n[g];let x;const L=c[g];if(R.mode===N.TRIANGLES||R.mode===N.TRIANGLE_STRIP||R.mode===N.TRIANGLE_FAN||R.mode===void 0)x=r.isSkinnedMesh===!0?new f.SkinnedMesh(S,L):new f.Mesh(S,L),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),R.mode===N.TRIANGLE_STRIP?x.geometry=Z(x.geometry,f.TriangleStripDrawMode):R.mode===N.TRIANGLE_FAN&&(x.geometry=Z(x.geometry,f.TriangleFanDrawMode));else if(R.mode===N.LINES)x=new f.LineSegments(S,L);else if(R.mode===N.LINE_STRIP)x=new f.Line(S,L);else if(R.mode===N.LINE_LOOP)x=new f.LineLoop(S,L);else if(R.mode===N.POINTS)x=new f.Points(S,L);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+R.mode);Object.keys(x.geometry.morphAttributes).length>0&&He(x,r),x.name=t.createUniqueName(r.name||"mesh_"+e),O(x,r),R.extensions&&P(s,x,R),t.assignFinalMaterial(x),u.push(x)}for(let g=0,y=u.length;g<y;g++)t.associations.set(u[g],{meshes:e,primitives:g});if(u.length===1)return r.extensions&&P(s,u[0],r),u[0];const d=new f.Group;r.extensions&&P(s,d,r),t.associations.set(d,{meshes:e});for(let g=0,y=u.length;g<y;g++)d.add(u[g]);return d})}loadCamera(e){let t;const o=this.json.cameras[e],s=o[o.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return o.type==="perspective"?t=new f.PerspectiveCamera(f.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):o.type==="orthographic"&&(t=new f.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),o.name&&(t.name=this.createUniqueName(o.name)),O(t,o),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],o=[];for(let s=0,r=t.joints.length;s<r;s++)o.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?o.push(this.getDependency("accessor",t.inverseBindMatrices)):o.push(null),Promise.all(o).then(function(s){const r=s.pop(),n=s,a=[],i=[];for(let c=0,l=n.length;c<l;c++){const u=n[c];if(u){a.push(u);const d=new f.Matrix4;r!==null&&d.fromArray(r.array,c*16),i.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new f.Skeleton(a,i)})}loadAnimation(e){const t=this.json,o=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,n=[],a=[],i=[],c=[],l=[];for(let u=0,d=s.channels.length;u<d;u++){const g=s.channels[u],y=s.samplers[g.sampler],S=g.target,R=S.node,x=s.parameters!==void 0?s.parameters[y.input]:y.input,L=s.parameters!==void 0?s.parameters[y.output]:y.output;S.node!==void 0&&(n.push(this.getDependency("node",R)),a.push(this.getDependency("accessor",x)),i.push(this.getDependency("accessor",L)),c.push(y),l.push(S))}return Promise.all([Promise.all(n),Promise.all(a),Promise.all(i),Promise.all(c),Promise.all(l)]).then(function(u){const d=u[0],g=u[1],y=u[2],S=u[3],R=u[4],x=[];for(let L=0,E=d.length;L<E;L++){const _=d[L],C=g[L],I=y[L],M=S[L],p=R[L];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const m=o._createAnimationTracks(_,C,I,M,p);if(m)for(let A=0;A<m.length;A++)x.push(m[A])}return new f.AnimationClip(r,void 0,x)})}createNodeMesh(e){const t=this.json,o=this,s=t.nodes[e];return s.mesh===void 0?null:o.getDependency("mesh",s.mesh).then(function(r){const n=o._getNodeRef(o.meshCache,s.mesh,r);return s.weights!==void 0&&n.traverse(function(a){if(a.isMesh)for(let i=0,c=s.weights.length;i<c;i++)a.morphTargetInfluences[i]=s.weights[i]}),n})}loadNode(e){const t=this.json,o=this,s=t.nodes[e],r=o._loadNodeShallow(e),n=[],a=s.children||[];for(let c=0,l=a.length;c<l;c++)n.push(o.getDependency("node",a[c]));const i=s.skin===void 0?Promise.resolve(null):o.getDependency("skin",s.skin);return Promise.all([r,Promise.all(n),i]).then(function(c){const l=c[0],u=c[1],d=c[2];d!==null&&l.traverse(function(g){g.isSkinnedMesh&&g.bind(d,Ke)});for(let g=0,y=u.length;g<y;g++)l.add(u[g]);return l})}_loadNodeShallow(e){const t=this.json,o=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],n=r.name?s.createUniqueName(r.name):"",a=[],i=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return i&&a.push(i),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(r.isBone===!0?l=new f.Bone:c.length>1?l=new f.Group:c.length===1?l=c[0]:l=new f.Object3D,l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name&&(l.userData.name=r.name,l.name=n),O(l,r),r.extensions&&P(o,l,r),r.matrix!==void 0){const u=new f.Matrix4;u.fromArray(r.matrix),l.applyMatrix4(u)}else r.translation!==void 0&&l.position.fromArray(r.translation),r.rotation!==void 0&&l.quaternion.fromArray(r.rotation),r.scale!==void 0&&l.scale.fromArray(r.scale);return s.associations.has(l)||s.associations.set(l,{}),s.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){const t=this.extensions,o=this.json.scenes[e],s=this,r=new f.Group;o.name&&(r.name=s.createUniqueName(o.name)),O(r,o),o.extensions&&P(t,r,o);const n=o.nodes||[],a=[];for(let i=0,c=n.length;i<c;i++)a.push(s.getDependency("node",n[i]));return Promise.all(a).then(function(i){for(let l=0,u=i.length;l<u;l++)r.add(i[l]);const c=l=>{const u=new Map;for(const[d,g]of s.associations)(d instanceof f.Material||d instanceof f.Texture)&&u.set(d,g);return l.traverse(d=>{const g=s.associations.get(d);g!=null&&u.set(d,g)}),u};return s.associations=c(r),r})}_createAnimationTracks(e,t,o,s,r){const n=[],a=e.name?e.name:e.uuid,i=[];D[r.path]===D.weights?e.traverse(function(d){d.morphTargetInfluences&&i.push(d.name?d.name:d.uuid)}):i.push(a);let c;switch(D[r.path]){case D.weights:c=f.NumberKeyframeTrack;break;case D.rotation:c=f.QuaternionKeyframeTrack;break;case D.position:case D.scale:c=f.VectorKeyframeTrack;break;default:switch(o.itemSize){case 1:c=f.NumberKeyframeTrack;break;case 2:case 3:default:c=f.VectorKeyframeTrack;break}break}const l=s.interpolation!==void 0?Ge[s.interpolation]:f.InterpolateLinear,u=this._getArrayFromAccessor(o);for(let d=0,g=i.length;d<g;d++){const y=new c(i[d]+"."+D[r.path],t.array,u,l);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),n.push(y)}return n}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const o=q(t.constructor),s=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r++)s[r]=t[r]*o;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(o){const s=this instanceof f.QuaternionKeyframeTrack?Fe:re;return new s(this.times,this.values,this.getValueSize()/3,o)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function We(h,e,t){const o=e.attributes,s=new f.Box3;if(o.POSITION!==void 0){const a=t.json.accessors[o.POSITION],i=a.min,c=a.max;if(i!==void 0&&c!==void 0){if(s.set(new f.Vector3(i[0],i[1],i[2]),new f.Vector3(c[0],c[1],c[2])),a.normalized){const l=q(F[a.componentType]);s.min.multiplyScalar(l),s.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new f.Vector3,i=new f.Vector3;for(let c=0,l=r.length;c<l;c++){const u=r[c];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],g=d.min,y=d.max;if(g!==void 0&&y!==void 0){if(i.setX(Math.max(Math.abs(g[0]),Math.abs(y[0]))),i.setY(Math.max(Math.abs(g[1]),Math.abs(y[1]))),i.setZ(Math.max(Math.abs(g[2]),Math.abs(y[2]))),d.normalized){const S=q(F[d.componentType]);i.multiplyScalar(S)}a.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}h.boundingBox=s;const n=new f.Sphere;s.getCenter(n.center),n.radius=s.min.distanceTo(s.max)/2,h.boundingSphere=n}function ne(h,e,t){const o=e.attributes,s=[];function r(n,a){return t.getDependency("accessor",n).then(function(i){h.setAttribute(a,i)})}for(const n in o){const a=X[n]||n.toLowerCase();a in h.attributes||s.push(r(o[n],a))}if(e.indices!==void 0&&!h.index){const n=t.getDependency("accessor",e.indices).then(function(a){h.setIndex(a)});s.push(n)}return f.ColorManagement.workingColorSpace!==f.LinearSRGBColorSpace&&"COLOR_0"in o&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${f.ColorManagement.workingColorSpace}" not supported.`),O(h,e),We(h,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Be(h,e.targets,t):h})}class Xe{parse(e){const t={},o=e.split(`
1
+ "use strict";var le=Object.defineProperty;var ue=(h,e,t)=>e in h?le(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var k=(h,e,t)=>ue(h,typeof e!="symbol"?e+"":e,t);const f=require("three"),H=require("./fflate.module-DHdJvhNh.cjs"),fe=require("./FileTypes-BQlqpkm2.cjs"),J=require("./isFileTypeSupported-CrEqYiv9.cjs"),U=require("./parse-error-Dy_EE4rL.cjs"),Q=require("./AssetCache-D1_YD57U.cjs");function Z(h,e){if(e===f.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),h;if(e===f.TriangleFanDrawMode||e===f.TriangleStripDrawMode){let t=h.getIndex();if(t===null){const n=[],a=h.getAttribute("position");if(a!==void 0){for(let i=0;i<a.count;i++)n.push(i);h.setIndex(n),t=h.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),h}const o=t.count-2,s=[];if(e===f.TriangleFanDrawMode)for(let n=1;n<=o;n++)s.push(t.getX(0)),s.push(t.getX(n)),s.push(t.getX(n+1));else for(let n=0;n<o;n++)n%2===0?(s.push(t.getX(n)),s.push(t.getX(n+1)),s.push(t.getX(n+2))):(s.push(t.getX(n+2)),s.push(t.getX(n+1)),s.push(t.getX(n)));s.length/3!==o&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=h.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),h}class de extends f.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ae(t)}),this.register(function(t){return new Ee(t)}),this.register(function(t){return new be(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new ye(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new ge(t)}),this.register(function(t){return new _e(t)}),this.register(function(t){return new Te(t)}),this.register(function(t){return new Le(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new pe(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new Ie(t)})}load(e,t,o,s){const r=this;let n;if(this.resourcePath!=="")n=this.resourcePath;else if(this.path!==""){const c=f.LoaderUtils.extractUrlBase(e);n=f.LoaderUtils.resolveURL(c,this.path)}else n=f.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){s?s(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},i=new f.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{r.parse(c,n,function(l){t(l),r.manager.itemEnd(e)},a)}catch(l){a(l)}},o,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,o,s){let r;const n={},a={},i=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(i.decode(new Uint8Array(e,0,4))===se){try{n[b.KHR_BINARY_GLTF]=new Ne(e)}catch(u){s&&s(u);return}r=JSON.parse(n[b.KHR_BINARY_GLTF].content)}else r=JSON.parse(i.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Ve(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const u=this.pluginCallbacks[l](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,n[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){const u=r.extensionsUsed[l],d=r.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:n[u]=new me;break;case b.KHR_DRACO_MESH_COMPRESSION:n[u]=new De(r,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:n[u]=new Oe;break;case b.KHR_MESH_QUANTIZATION:n[u]=new Pe;break;default:d.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(n),c.setPlugins(a),c.parse(o,s)}parseAsync(e,t){const o=this;return new Promise(function(s,r){o.parse(e,t,s,r)})}}function he(){let h={};return{get:function(e){return h[e]},add:function(e,t){h[e]=t},remove:function(e){delete h[e]},removeAll:function(){h={}}}}const b={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class pe{constructor(e){this.parser=e,this.name=b.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let o=0,s=t.length;o<s;o++){const r=t[o];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,o="light:"+e;let s=t.cache.get(o);if(s)return s;const r=t.json,i=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const l=new f.Color(16777215);i.color!==void 0&&l.setRGB(i.color[0],i.color[1],i.color[2],f.LinearSRGBColorSpace);const u=i.range!==void 0?i.range:0;switch(i.type){case"directional":c=new f.DirectionalLight(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new f.PointLight(l),c.distance=u;break;case"spot":c=new f.SpotLight(l),c.distance=u,i.spot=i.spot||{},i.spot.innerConeAngle=i.spot.innerConeAngle!==void 0?i.spot.innerConeAngle:0,i.spot.outerConeAngle=i.spot.outerConeAngle!==void 0?i.spot.outerConeAngle:Math.PI/4,c.angle=i.spot.outerConeAngle,c.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return c.position.set(0,0,0),c.decay=2,O(c,i),i.intensity!==void 0&&(c.intensity=i.intensity),c.name=t.createUniqueName(i.name||"light_"+e),s=Promise.resolve(c),t.cache.add(o,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,o=this.parser,r=o.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(i){return o._getNodeRef(t.cache,a,i)})}}class me{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return f.MeshBasicMaterial}extendParams(e,t,o){const s=[];e.color=new f.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const n=r.baseColorFactor;e.color.setRGB(n[0],n[1],n[2],f.LinearSRGBColorSpace),e.opacity=n[3]}r.baseColorTexture!==void 0&&s.push(o.assignTexture(e,"map",r.baseColorTexture,f.SRGBColorSpace))}return Promise.all(s)}}class ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Ae{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(o.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(o.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(o.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const a=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f.Vector2(a,a)}return Promise.all(r)}}class Te{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(o.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(o.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(r)}}class ye{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new f.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const n=s.extensions[this.name];if(n.sheenColorFactor!==void 0){const a=n.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(o.assignTexture(t,"sheenColorMap",n.sheenColorTexture,f.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&r.push(o.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(r)}}class Re{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(o.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(r)}}class xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&r.push(o.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const a=n.attenuationColor||[1,1,1];return t.attenuationColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),Promise.all(r)}}class Se{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class _e{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&r.push(o.assignTexture(t,"specularIntensityMap",n.specularTexture));const a=n.specularColorFactor||[1,1,1];return t.specularColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&r.push(o.assignTexture(t,"specularColorMap",n.specularColorTexture,f.SRGBColorSpace)),Promise.all(r)}}class we{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&r.push(o.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(r)}}class Le{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const o=this.parser.json.materials[e];return!o.extensions||!o.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser,s=o.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(o.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(r)}}class Ee{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,o=t.json,s=o.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],n=t.options.ktx2Loader;if(!n){if(o.extensionsRequired&&o.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,n)}}class be{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,o=this.parser,s=o.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const n=r.extensions[t],a=s.images[n.source];let i=o.textureLoader;if(a.uri){const c=o.options.manager.getHandler(a.uri);c!==null&&(i=c)}return this.detectSupport().then(function(c){if(c)return o.loadTextureImage(e,n.source,i);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return o.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Me{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,o=this.parser,s=o.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const n=r.extensions[t],a=s.images[n.source];let i=o.textureLoader;if(a.uri){const c=o.options.manager.getHandler(a.uri);c!==null&&(i=c)}return this.detectSupport().then(function(c){if(c)return o.loadTextureImage(e,n.source,i);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return o.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ce{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,o=t.bufferViews[e];if(o.extensions&&o.extensions[this.name]){const s=o.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const i=s.byteOffset||0,c=s.byteLength||0,l=s.count,u=s.byteStride,d=new Uint8Array(a,i,c);return n.decodeGltfBufferAsync?n.decodeGltfBufferAsync(l,u,d,s.mode,s.filter).then(function(g){return g.buffer}):n.ready.then(function(){const g=new ArrayBuffer(l*u);return n.decodeGltfBuffer(new Uint8Array(g),l,u,d,s.mode,s.filter),g})})}else return null}}class Ie{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,o=t.nodes[e];if(!o.extensions||!o.extensions[this.name]||o.mesh===void 0)return null;const s=t.meshes[o.mesh];for(const c of s.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const n=o.extensions[this.name].attributes,a=[],i={};for(const c in n)a.push(this.parser.getDependency("accessor",n[c]).then(l=>(i[c]=l,i[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,g=[];for(const y of u){const S=new f.Matrix4,R=new f.Vector3,x=new f.Quaternion,L=new f.Vector3(1,1,1),E=new f.InstancedMesh(y.geometry,y.material,d);for(let _=0;_<d;_++)i.TRANSLATION&&R.fromBufferAttribute(i.TRANSLATION,_),i.ROTATION&&x.fromBufferAttribute(i.ROTATION,_),i.SCALE&&L.fromBufferAttribute(i.SCALE,_),E.setMatrixAt(_,S.compose(R,x,L));for(const _ in i)if(_==="_COLOR_0"){const C=i[_];E.instanceColor=new f.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&y.geometry.setAttribute(_,i[_]);f.Object3D.prototype.copy.call(E,y),this.parser.assignFinalMaterial(E),g.push(E)}return l.isGroup?(l.clear(),l.add(...g),l):g[0]}))}}const se="glTF",G=12,$={JSON:1313821514,BIN:5130562};class Ne{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,G),o=new TextDecoder;if(this.header={magic:o.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==se)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-G,r=new DataView(e,G);let n=0;for(;n<s;){const a=r.getUint32(n,!0);n+=4;const i=r.getUint32(n,!0);if(n+=4,i===$.JSON){const c=new Uint8Array(e,G+n,a);this.content=o.decode(c)}else if(i===$.BIN){const c=G+n;this.body=e.slice(c,c+a)}n+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class De{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const o=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,n=e.extensions[this.name].attributes,a={},i={},c={};for(const l in n){const u=X[l]||l.toLowerCase();a[u]=n[l]}for(const l in e.attributes){const u=X[l]||l.toLowerCase();if(n[l]!==void 0){const d=o.accessors[e.attributes[l]],g=F[d.componentType];c[u]=g.name,i[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,d){s.decodeDracoFile(l,function(g){for(const y in g.attributes){const S=g.attributes[y],R=i[y];R!==void 0&&(S.normalized=R)}u(g)},a,c,f.LinearSRGBColorSpace,d)})})}}class Oe{constructor(){this.name=b.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Pe{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class re extends f.Interpolant{constructor(e,t,o,s){super(e,t,o,s)}copySampleValue_(e){const t=this.resultBuffer,o=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let n=0;n!==s;n++)t[n]=o[r+n];return t}interpolate_(e,t,o,s){const r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,i=a*2,c=a*3,l=s-t,u=(o-t)/l,d=u*u,g=d*u,y=e*c,S=y-c,R=-2*g+3*d,x=g-d,L=1-R,E=x-d+u;for(let _=0;_!==a;_++){const C=n[S+_+a],I=n[S+_+i]*l,M=n[y+_+a],p=n[y+_]*l;r[_]=L*C+E*I+R*M+x*p}return r}}const ke=new f.Quaternion;class Fe extends re{interpolate_(e,t,o,s){const r=super.interpolate_(e,t,o,s);return ke.fromArray(r).normalize().toArray(r),r}}const N={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},F={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ee={9728:f.NearestFilter,9729:f.LinearFilter,9984:f.NearestMipmapNearestFilter,9985:f.LinearMipmapNearestFilter,9986:f.NearestMipmapLinearFilter,9987:f.LinearMipmapLinearFilter},te={33071:f.ClampToEdgeWrapping,33648:f.MirroredRepeatWrapping,10497:f.RepeatWrapping},v={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},D={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ge={CUBICSPLINE:void 0,LINEAR:f.InterpolateLinear,STEP:f.InterpolateDiscrete},j={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ue(h){return h.DefaultMaterial===void 0&&(h.DefaultMaterial=new f.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:f.FrontSide})),h.DefaultMaterial}function P(h,e,t){for(const o in t.extensions)h[o]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[o]=t.extensions[o])}function O(h,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(h.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Be(h,e,t){let o=!1,s=!1,r=!1;for(let c=0,l=e.length;c<l;c++){const u=e[c];if(u.POSITION!==void 0&&(o=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),o&&s&&r)break}if(!o&&!s&&!r)return Promise.resolve(h);const n=[],a=[],i=[];for(let c=0,l=e.length;c<l;c++){const u=e[c];if(o){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):h.attributes.position;n.push(d)}if(s){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):h.attributes.normal;a.push(d)}if(r){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):h.attributes.color;i.push(d)}}return Promise.all([Promise.all(n),Promise.all(a),Promise.all(i)]).then(function(c){const l=c[0],u=c[1],d=c[2];return o&&(h.morphAttributes.position=l),s&&(h.morphAttributes.normal=u),r&&(h.morphAttributes.color=d),h.morphTargetsRelative=!0,h})}function He(h,e){if(h.updateMorphTargets(),e.weights!==void 0)for(let t=0,o=e.weights.length;t<o;t++)h.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(h.morphTargetInfluences.length===t.length){h.morphTargetDictionary={};for(let o=0,s=t.length;o<s;o++)h.morphTargetDictionary[t[o]]=o}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ve(h){let e;const t=h.extensions&&h.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+K(t.attributes):e=h.indices+":"+K(h.attributes)+":"+h.mode,h.targets!==void 0)for(let o=0,s=h.targets.length;o<s;o++)e+=":"+K(h.targets[o]);return e}function K(h){let e="";const t=Object.keys(h).sort();for(let o=0,s=t.length;o<s;o++)e+=t[o]+":"+h[t[o]]+";";return e}function q(h){switch(h){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function je(h){return h.search(/\.jpe?g($|\?)/i)>0||h.search(/^data\:image\/jpeg/)===0?"image/jpeg":h.search(/\.webp($|\?)/i)>0||h.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Ke=new f.Matrix4;class Ve{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new he,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let o=!1,s=!1,r=-1;typeof navigator<"u"&&(o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,r=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||o||s&&r<98?this.textureLoader=new f.TextureLoader(this.options.manager):this.textureLoader=new f.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new f.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const o=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(n){return n._markDefs&&n._markDefs()}),Promise.all(this._invokeAll(function(n){return n.beforeRoot&&n.beforeRoot()})).then(function(){return Promise.all([o.getDependencies("scene"),o.getDependencies("animation"),o.getDependencies("camera")])}).then(function(n){const a={scene:n[0][s.scene||0],scenes:n[0],animations:n[1],cameras:n[2],asset:s.asset,parser:o,userData:{}};return P(r,a,s),O(a,s),Promise.all(o._invokeAll(function(i){return i.afterRoot&&i.afterRoot(a)})).then(function(){for(const i of a.scenes)i.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],o=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const n=t[s].joints;for(let a=0,i=n.length;a<i;a++)e[n[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const n=e[s];n.mesh!==void 0&&(this._addNodeRef(this.meshCache,n.mesh),n.skin!==void 0&&(o[n.mesh].isSkinnedMesh=!0)),n.camera!==void 0&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,o){if(e.refs[t]<=1)return o;const s=o.clone(),r=(n,a)=>{const i=this.associations.get(n);i!=null&&this.associations.set(a,i);for(const[c,l]of n.children.entries())r(l,a.children[c])};return r(o,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let o=0;o<t.length;o++){const s=e(t[o]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const o=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&o.push(r)}return o}getDependency(e,t){const o=e+":"+t;let s=this.cache.get(o);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(o,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const o=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,n){return o.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],o=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,n){o.load(f.LoaderUtils.resolveURL(t.uri,s.path),r,void 0,function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(o){const s=t.byteLength||0,r=t.byteOffset||0;return o.slice(r,r+s)})}loadAccessor(e){const t=this,o=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const n=v[s.type],a=F[s.componentType],i=s.normalized===!0,c=new a(s.count*n);return Promise.resolve(new f.BufferAttribute(c,n,i))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(n){const a=n[0],i=v[s.type],c=F[s.componentType],l=c.BYTES_PER_ELEMENT,u=l*i,d=s.byteOffset||0,g=s.bufferView!==void 0?o.bufferViews[s.bufferView].byteStride:void 0,y=s.normalized===!0;let S,R;if(g&&g!==u){const x=Math.floor(d/g),L="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+x+":"+s.count;let E=t.cache.get(L);E||(S=new c(a,x*g,s.count*g/l),E=new f.InterleavedBuffer(S,g/l),t.cache.add(L,E)),R=new f.InterleavedBufferAttribute(E,i,d%g/l,y)}else a===null?S=new c(s.count*i):S=new c(a,d,s.count*i),R=new f.BufferAttribute(S,i,y);if(s.sparse!==void 0){const x=v.SCALAR,L=F[s.sparse.indices.componentType],E=s.sparse.indices.byteOffset||0,_=s.sparse.values.byteOffset||0,C=new L(n[1],E,s.sparse.count*x),I=new c(n[2],_,s.sparse.count*i);a!==null&&(R=new f.BufferAttribute(R.array.slice(),R.itemSize,R.normalized));for(let M=0,p=C.length;M<p;M++){const m=C[M];if(R.setX(m,I[M*i]),i>=2&&R.setY(m,I[M*i+1]),i>=3&&R.setZ(m,I[M*i+2]),i>=4&&R.setW(m,I[M*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return R})}loadTexture(e){const t=this.json,o=this.options,r=t.textures[e].source,n=t.images[r];let a=this.textureLoader;if(n.uri){const i=o.manager.getHandler(n.uri);i!==null&&(a=i)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,o){const s=this,r=this.json,n=r.textures[e],a=r.images[t],i=(a.uri||a.bufferView)+":"+n.sampler;if(this.textureCache[i])return this.textureCache[i];const c=this.loadImageSource(t,o).then(function(l){l.flipY=!1,l.name=n.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);const d=(r.samplers||{})[n.sampler]||{};return l.magFilter=ee[d.magFilter]||f.LinearFilter,l.minFilter=ee[d.minFilter]||f.LinearMipmapLinearFilter,l.wrapS=te[d.wrapS]||f.RepeatWrapping,l.wrapT=te[d.wrapT]||f.RepeatWrapping,s.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[i]=c,c}loadImageSource(e,t){const o=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const n=s.images[e],a=self.URL||self.webkitURL;let i=n.uri||"",c=!1;if(n.bufferView!==void 0)i=o.getDependency("bufferView",n.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:n.mimeType});return i=a.createObjectURL(d),i});else if(n.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(i).then(function(u){return new Promise(function(d,g){let y=d;t.isImageBitmapLoader===!0&&(y=function(S){const R=new f.Texture(S);R.needsUpdate=!0,d(R)}),t.load(f.LoaderUtils.resolveURL(u,r.path),y,void 0,g)})}).then(function(u){return c===!0&&a.revokeObjectURL(i),u.userData.mimeType=n.mimeType||je(n.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),u});return this.sourceCache[e]=l,l}assignTexture(e,t,o,s){const r=this;return this.getDependency("texture",o.index).then(function(n){if(!n)return null;if(o.texCoord!==void 0&&o.texCoord>0&&(n=n.clone(),n.channel=o.texCoord),r.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=o.extensions!==void 0?o.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const i=r.associations.get(n);n=r.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(n,a),r.associations.set(n,i)}}return s!==void 0&&(n.colorSpace=s),e[t]=n,n})}assignFinalMaterial(e){const t=e.geometry;let o=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,n=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+o.uuid;let i=this.cache.get(a);i||(i=new f.PointsMaterial,f.Material.prototype.copy.call(i,o),i.color.copy(o.color),i.map=o.map,i.sizeAttenuation=!1,this.cache.add(a,i)),o=i}else if(e.isLine){const a="LineBasicMaterial:"+o.uuid;let i=this.cache.get(a);i||(i=new f.LineBasicMaterial,f.Material.prototype.copy.call(i,o),i.color.copy(o.color),i.map=o.map,this.cache.add(a,i)),o=i}if(s||r||n){let a="ClonedMaterial:"+o.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),n&&(a+="flat-shading:");let i=this.cache.get(a);i||(i=o.clone(),r&&(i.vertexColors=!0),n&&(i.flatShading=!0),s&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(a,i),this.associations.set(i,this.associations.get(o))),o=i}e.material=o}getMaterialType(){return f.MeshStandardMaterial}loadMaterial(e){const t=this,o=this.json,s=this.extensions,r=o.materials[e];let n;const a={},i=r.extensions||{},c=[];if(i[b.KHR_MATERIALS_UNLIT]){const u=s[b.KHR_MATERIALS_UNLIT];n=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new f.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],f.LinearSRGBColorSpace),a.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,f.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),n=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=f.DoubleSide);const l=r.alphaMode||j.OPAQUE;if(l===j.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===j.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&n!==f.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new f.Vector2(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&n!==f.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&n!==f.MeshBasicMaterial){const u=r.emissiveFactor;a.emissive=new f.Color().setRGB(u[0],u[1],u[2],f.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&n!==f.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,f.SRGBColorSpace)),Promise.all(c).then(function(){const u=new n(a);return r.name&&(u.name=r.name),O(u,r),t.associations.set(u,{materials:e}),r.extensions&&P(s,u,r),u})}createUniqueName(e){const t=f.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,o=this.extensions,s=this.primitiveCache;function r(a){return o[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(i){return ne(i,a,t)})}const n=[];for(let a=0,i=e.length;a<i;a++){const c=e[a],l=ve(c),u=s[l];if(u)n.push(u.promise);else{let d;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=ne(new f.BufferGeometry,c,t),s[l]={primitive:c,promise:d},n.push(d)}}return Promise.all(n)}loadMesh(e){const t=this,o=this.json,s=this.extensions,r=o.meshes[e],n=r.primitives,a=[];for(let i=0,c=n.length;i<c;i++){const l=n[i].material===void 0?Ue(this.cache):this.getDependency("material",n[i].material);a.push(l)}return a.push(t.loadGeometries(n)),Promise.all(a).then(function(i){const c=i.slice(0,i.length-1),l=i[i.length-1],u=[];for(let g=0,y=l.length;g<y;g++){const S=l[g],R=n[g];let x;const L=c[g];if(R.mode===N.TRIANGLES||R.mode===N.TRIANGLE_STRIP||R.mode===N.TRIANGLE_FAN||R.mode===void 0)x=r.isSkinnedMesh===!0?new f.SkinnedMesh(S,L):new f.Mesh(S,L),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),R.mode===N.TRIANGLE_STRIP?x.geometry=Z(x.geometry,f.TriangleStripDrawMode):R.mode===N.TRIANGLE_FAN&&(x.geometry=Z(x.geometry,f.TriangleFanDrawMode));else if(R.mode===N.LINES)x=new f.LineSegments(S,L);else if(R.mode===N.LINE_STRIP)x=new f.Line(S,L);else if(R.mode===N.LINE_LOOP)x=new f.LineLoop(S,L);else if(R.mode===N.POINTS)x=new f.Points(S,L);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+R.mode);Object.keys(x.geometry.morphAttributes).length>0&&He(x,r),x.name=t.createUniqueName(r.name||"mesh_"+e),O(x,r),R.extensions&&P(s,x,R),t.assignFinalMaterial(x),u.push(x)}for(let g=0,y=u.length;g<y;g++)t.associations.set(u[g],{meshes:e,primitives:g});if(u.length===1)return r.extensions&&P(s,u[0],r),u[0];const d=new f.Group;r.extensions&&P(s,d,r),t.associations.set(d,{meshes:e});for(let g=0,y=u.length;g<y;g++)d.add(u[g]);return d})}loadCamera(e){let t;const o=this.json.cameras[e],s=o[o.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return o.type==="perspective"?t=new f.PerspectiveCamera(f.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):o.type==="orthographic"&&(t=new f.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),o.name&&(t.name=this.createUniqueName(o.name)),O(t,o),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],o=[];for(let s=0,r=t.joints.length;s<r;s++)o.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?o.push(this.getDependency("accessor",t.inverseBindMatrices)):o.push(null),Promise.all(o).then(function(s){const r=s.pop(),n=s,a=[],i=[];for(let c=0,l=n.length;c<l;c++){const u=n[c];if(u){a.push(u);const d=new f.Matrix4;r!==null&&d.fromArray(r.array,c*16),i.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new f.Skeleton(a,i)})}loadAnimation(e){const t=this.json,o=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,n=[],a=[],i=[],c=[],l=[];for(let u=0,d=s.channels.length;u<d;u++){const g=s.channels[u],y=s.samplers[g.sampler],S=g.target,R=S.node,x=s.parameters!==void 0?s.parameters[y.input]:y.input,L=s.parameters!==void 0?s.parameters[y.output]:y.output;S.node!==void 0&&(n.push(this.getDependency("node",R)),a.push(this.getDependency("accessor",x)),i.push(this.getDependency("accessor",L)),c.push(y),l.push(S))}return Promise.all([Promise.all(n),Promise.all(a),Promise.all(i),Promise.all(c),Promise.all(l)]).then(function(u){const d=u[0],g=u[1],y=u[2],S=u[3],R=u[4],x=[];for(let L=0,E=d.length;L<E;L++){const _=d[L],C=g[L],I=y[L],M=S[L],p=R[L];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const m=o._createAnimationTracks(_,C,I,M,p);if(m)for(let A=0;A<m.length;A++)x.push(m[A])}return new f.AnimationClip(r,void 0,x)})}createNodeMesh(e){const t=this.json,o=this,s=t.nodes[e];return s.mesh===void 0?null:o.getDependency("mesh",s.mesh).then(function(r){const n=o._getNodeRef(o.meshCache,s.mesh,r);return s.weights!==void 0&&n.traverse(function(a){if(a.isMesh)for(let i=0,c=s.weights.length;i<c;i++)a.morphTargetInfluences[i]=s.weights[i]}),n})}loadNode(e){const t=this.json,o=this,s=t.nodes[e],r=o._loadNodeShallow(e),n=[],a=s.children||[];for(let c=0,l=a.length;c<l;c++)n.push(o.getDependency("node",a[c]));const i=s.skin===void 0?Promise.resolve(null):o.getDependency("skin",s.skin);return Promise.all([r,Promise.all(n),i]).then(function(c){const l=c[0],u=c[1],d=c[2];d!==null&&l.traverse(function(g){g.isSkinnedMesh&&g.bind(d,Ke)});for(let g=0,y=u.length;g<y;g++)l.add(u[g]);return l})}_loadNodeShallow(e){const t=this.json,o=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],n=r.name?s.createUniqueName(r.name):"",a=[],i=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return i&&a.push(i),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(r.isBone===!0?l=new f.Bone:c.length>1?l=new f.Group:c.length===1?l=c[0]:l=new f.Object3D,l!==c[0])for(let u=0,d=c.length;u<d;u++)l.add(c[u]);if(r.name&&(l.userData.name=r.name,l.name=n),O(l,r),r.extensions&&P(o,l,r),r.matrix!==void 0){const u=new f.Matrix4;u.fromArray(r.matrix),l.applyMatrix4(u)}else r.translation!==void 0&&l.position.fromArray(r.translation),r.rotation!==void 0&&l.quaternion.fromArray(r.rotation),r.scale!==void 0&&l.scale.fromArray(r.scale);return s.associations.has(l)||s.associations.set(l,{}),s.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){const t=this.extensions,o=this.json.scenes[e],s=this,r=new f.Group;o.name&&(r.name=s.createUniqueName(o.name)),O(r,o),o.extensions&&P(t,r,o);const n=o.nodes||[],a=[];for(let i=0,c=n.length;i<c;i++)a.push(s.getDependency("node",n[i]));return Promise.all(a).then(function(i){for(let l=0,u=i.length;l<u;l++)r.add(i[l]);const c=l=>{const u=new Map;for(const[d,g]of s.associations)(d instanceof f.Material||d instanceof f.Texture)&&u.set(d,g);return l.traverse(d=>{const g=s.associations.get(d);g!=null&&u.set(d,g)}),u};return s.associations=c(r),r})}_createAnimationTracks(e,t,o,s,r){const n=[],a=e.name?e.name:e.uuid,i=[];D[r.path]===D.weights?e.traverse(function(d){d.morphTargetInfluences&&i.push(d.name?d.name:d.uuid)}):i.push(a);let c;switch(D[r.path]){case D.weights:c=f.NumberKeyframeTrack;break;case D.rotation:c=f.QuaternionKeyframeTrack;break;case D.position:case D.scale:c=f.VectorKeyframeTrack;break;default:switch(o.itemSize){case 1:c=f.NumberKeyframeTrack;break;case 2:case 3:default:c=f.VectorKeyframeTrack;break}break}const l=s.interpolation!==void 0?Ge[s.interpolation]:f.InterpolateLinear,u=this._getArrayFromAccessor(o);for(let d=0,g=i.length;d<g;d++){const y=new c(i[d]+"."+D[r.path],t.array,u,l);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),n.push(y)}return n}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const o=q(t.constructor),s=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r++)s[r]=t[r]*o;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(o){const s=this instanceof f.QuaternionKeyframeTrack?Fe:re;return new s(this.times,this.values,this.getValueSize()/3,o)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function We(h,e,t){const o=e.attributes,s=new f.Box3;if(o.POSITION!==void 0){const a=t.json.accessors[o.POSITION],i=a.min,c=a.max;if(i!==void 0&&c!==void 0){if(s.set(new f.Vector3(i[0],i[1],i[2]),new f.Vector3(c[0],c[1],c[2])),a.normalized){const l=q(F[a.componentType]);s.min.multiplyScalar(l),s.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new f.Vector3,i=new f.Vector3;for(let c=0,l=r.length;c<l;c++){const u=r[c];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],g=d.min,y=d.max;if(g!==void 0&&y!==void 0){if(i.setX(Math.max(Math.abs(g[0]),Math.abs(y[0]))),i.setY(Math.max(Math.abs(g[1]),Math.abs(y[1]))),i.setZ(Math.max(Math.abs(g[2]),Math.abs(y[2]))),d.normalized){const S=q(F[d.componentType]);i.multiplyScalar(S)}a.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}h.boundingBox=s;const n=new f.Sphere;s.getCenter(n.center),n.radius=s.min.distanceTo(s.max)/2,h.boundingSphere=n}function ne(h,e,t){const o=e.attributes,s=[];function r(n,a){return t.getDependency("accessor",n).then(function(i){h.setAttribute(a,i)})}for(const n in o){const a=X[n]||n.toLowerCase();a in h.attributes||s.push(r(o[n],a))}if(e.indices!==void 0&&!h.index){const n=t.getDependency("accessor",e.indices).then(function(a){h.setIndex(a)});s.push(n)}return f.ColorManagement.workingColorSpace!==f.LinearSRGBColorSpace&&"COLOR_0"in o&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${f.ColorManagement.workingColorSpace}" not supported.`),O(h,e),We(h,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Be(h,e.targets,t):h})}class Xe{parse(e){const t={},o=e.split(`
2
2
  `);let s=null,r=t;const n=[t];for(const a of o)if(a.includes("=")){const i=a.split("="),c=i[0].trim(),l=i[1].trim();if(l.endsWith("{")){const u={};n.push(u),r[c]=u,r=u}else r[c]=l}else if(a.endsWith("{")){const i=r[s]||{};n.push(i),r[s]=i,r=i}else if(a.endsWith("}")){if(n.pop(),n.length===0)continue;r=n[n.length-1]}else if(a.endsWith("(")){const i={};n.push(i),s=a.split("(")[0].trim()||s,r[s]=i,r=i}else a.endsWith(")")?(n.pop(),r=n[n.length-1]):s=a.trim();return t}}class qe extends f.Loader{constructor(e){super(e)}load(e,t,o,s){const r=this,n=new f.FileLoader(r.manager);n.setPath(r.path),n.setResponseType("arraybuffer"),n.setRequestHeader(r.requestHeader),n.setWithCredentials(r.withCredentials),n.load(e,function(a){try{t(r.parse(a))}catch(i){s?s(i):console.error(i),r.manager.itemError(e)}},o,s)}parse(e){const t=new Xe;function o(p){const m={};new f.FileLoader().setResponseType("arraybuffer");for(const T in p){if(T.endsWith("png")){const w=new Blob([p[T]],{type:{type:"image/png"}});m[T]=URL.createObjectURL(w)}if(T.endsWith("usd")||T.endsWith("usda")){if(s(p[T])){console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.");continue}const w=H.strFromU8(p[T]);m[T]=t.parse(w)}}return m}function s(p){const m=p.slice(0,7),A=new Uint8Array([80,88,82,45,85,83,68,67]);return m.every((T,w)=>T===A[w])}function r(p){if(p.length<1)return;const m=Object.keys(p)[0];let A=!1;if(m.endsWith("usda"))return p[m];if(m.endsWith("usdc"))A=!0;else if(m.endsWith("usd"))if(s(p[m]))A=!0;else return p[m];A&&console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.")}const n=H.unzipSync(new Uint8Array(e)),a=o(n),i=r(n);if(i===void 0)return console.warn("THREE.USDZLoader: No usda file found."),new f.Group;const c=H.strFromU8(i),l=t.parse(c);function u(p){if(p){if("prepend references"in p){const A=p["prepend references"].split("@"),T=A[1].replace(/^.\//,""),w=A[2].replace(/^<\//,"").replace(/>$/,"");return d(a[T],w)}return d(p)}}function d(p,m){if(p){if(m!==void 0){const A=`def Mesh "${m}"`;if(A in p)return p[A]}for(const A in p){const T=p[A];if(A.startsWith("def Mesh"))return"point3f[] points"in p&&(T["point3f[] points"]=p["point3f[] points"]),"texCoord2f[] primvars:st"in p&&(T["texCoord2f[] primvars:st"]=p["texCoord2f[] primvars:st"]),"int[] primvars:st:indices"in p&&(T["int[] primvars:st:indices"]=p["int[] primvars:st:indices"]),T;if(typeof T=="object"){const w=d(T);if(w)return w}}}}function g(p){if(!p)return;let m=new f.BufferGeometry;if("int[] faceVertexIndices"in p){const A=JSON.parse(p["int[] faceVertexIndices"]);m.setIndex(A)}if("point3f[] points"in p){const A=JSON.parse(p["point3f[] points"].replace(/[()]*/g,"")),T=new f.BufferAttribute(new Float32Array(A),3);m.setAttribute("position",T)}if("normal3f[] normals"in p){const A=JSON.parse(p["normal3f[] normals"].replace(/[()]*/g,"")),T=new f.BufferAttribute(new Float32Array(A),3);m.setAttribute("normal",T)}else m.computeVertexNormals();if("float2[] primvars:st"in p&&(p["texCoord2f[] primvars:st"]=p["float2[] primvars:st"]),"texCoord2f[] primvars:st"in p){const A=JSON.parse(p["texCoord2f[] primvars:st"].replace(/[()]*/g,"")),T=new f.BufferAttribute(new Float32Array(A),2);if("int[] primvars:st:indices"in p){m=m.toNonIndexed();const w=JSON.parse(p["int[] primvars:st:indices"]);m.setAttribute("uv",y(T,w))}else m.setAttribute("uv",T)}return m}function y(p,m){const A=p.array,T=p.itemSize,w=new A.constructor(m.length*T);let z=0,ae=0;for(let B=0,ce=m.length;B<ce;B++){z=m[B]*T;for(let Y=0;Y<T;Y++)w[ae++]=A[z++]}return new f.BufferAttribute(w,T)}function S(p){if(p){if("rel material:binding"in p){const T=p["rel material:binding"].replace(/^<\//,"").replace(/>$/,"").split("/");return R(l,` "${T[1]}"`)}return R(p)}}function R(p,m=""){for(const A in p){const T=p[A];if(A.startsWith("def Material"+m))return T;if(typeof T=="object"){const w=R(T,m);if(w)return w}}}function x(p,m){m["float inputs:rotation"]&&(p.rotation=parseFloat(m["float inputs:rotation"])),m["float2 inputs:scale"]&&(p.repeat=new f.Vector2().fromArray(JSON.parse("["+m["float2 inputs:scale"].replace(/[()]*/g,"")+"]"))),m["float2 inputs:translation"]&&(p.offset=new f.Vector2().fromArray(JSON.parse("["+m["float2 inputs:translation"].replace(/[()]*/g,"")+"]")))}function L(p){const m=new f.MeshPhysicalMaterial;if(p!==void 0){if('def Shader "PreviewSurface"'in p){const A=p['def Shader "PreviewSurface"'];if("color3f inputs:diffuseColor.connect"in A){const T=A["color3f inputs:diffuseColor.connect"],w=E(l,/(\w+).output/.exec(T)[1]);m.map=_(w),m.map.colorSpace=f.SRGBColorSpace,'def Shader "Transform2d_diffuse"'in p&&x(m.map,p['def Shader "Transform2d_diffuse"'])}else if("color3f inputs:diffuseColor"in A){const T=A["color3f inputs:diffuseColor"].replace(/[()]*/g,"");m.color.fromArray(JSON.parse("["+T+"]"))}if("color3f inputs:emissiveColor.connect"in A){const T=A["color3f inputs:emissiveColor.connect"],w=E(l,/(\w+).output/.exec(T)[1]);m.emissiveMap=_(w),m.emissiveMap.colorSpace=f.SRGBColorSpace,m.emissive.set(16777215),'def Shader "Transform2d_emissive"'in p&&x(m.emissiveMap,p['def Shader "Transform2d_emissive"'])}else if("color3f inputs:emissiveColor"in A){const T=A["color3f inputs:emissiveColor"].replace(/[()]*/g,"");m.emissive.fromArray(JSON.parse("["+T+"]"))}if("normal3f inputs:normal.connect"in A){const T=A["normal3f inputs:normal.connect"],w=E(l,/(\w+).output/.exec(T)[1]);m.normalMap=_(w),m.normalMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_normal"'in p&&x(m.normalMap,p['def Shader "Transform2d_normal"'])}if("float inputs:roughness.connect"in A){const T=A["float inputs:roughness.connect"],w=E(l,/(\w+).output/.exec(T)[1]);m.roughness=1,m.roughnessMap=_(w),m.roughnessMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_roughness"'in p&&x(m.roughnessMap,p['def Shader "Transform2d_roughness"'])}else"float inputs:roughness"in A&&(m.roughness=parseFloat(A["float inputs:roughness"]));if("float inputs:metallic.connect"in A){const T=A["float inputs:metallic.connect"],w=E(l,/(\w+).output/.exec(T)[1]);m.metalness=1,m.metalnessMap=_(w),m.metalnessMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_metallic"'in p&&x(m.metalnessMap,p['def Shader "Transform2d_metallic"'])}else"float inputs:metallic"in A&&(m.metalness=parseFloat(A["float inputs:metallic"]));if("float inputs:clearcoat.connect"in A){const T=A["float inputs:clearcoat.connect"],w=E(l,/(\w+).output/.exec(T)[1]);m.clearcoat=1,m.clearcoatMap=_(w),m.clearcoatMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_clearcoat"'in p&&x(m.clearcoatMap,p['def Shader "Transform2d_clearcoat"'])}else"float inputs:clearcoat"in A&&(m.clearcoat=parseFloat(A["float inputs:clearcoat"]));if("float inputs:clearcoatRoughness.connect"in A){const T=A["float inputs:clearcoatRoughness.connect"],w=E(l,/(\w+).output/.exec(T)[1]);m.clearcoatRoughness=1,m.clearcoatRoughnessMap=_(w),m.clearcoatRoughnessMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_clearcoatRoughness"'in p&&x(m.clearcoatRoughnessMap,p['def Shader "Transform2d_clearcoatRoughness"'])}else"float inputs:clearcoatRoughness"in A&&(m.clearcoatRoughness=parseFloat(A["float inputs:clearcoatRoughness"]));if("float inputs:ior"in A&&(m.ior=parseFloat(A["float inputs:ior"])),"float inputs:occlusion.connect"in A){const T=A["float inputs:occlusion.connect"],w=E(l,/(\w+).output/.exec(T)[1]);m.aoMap=_(w),m.aoMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_occlusion"'in p&&x(m.aoMap,p['def Shader "Transform2d_occlusion"'])}}if('def Shader "diffuseColor_texture"'in p){const A=p['def Shader "diffuseColor_texture"'];m.map=_(A),m.map.colorSpace=f.SRGBColorSpace}if('def Shader "normal_texture"'in p){const A=p['def Shader "normal_texture"'];m.normalMap=_(A),m.normalMap.colorSpace=f.NoColorSpace}}return m}function E(p,m){for(const A in p){const T=p[A];if(A.startsWith(`def Shader "${m}"`))return T;if(typeof T=="object"){const w=E(T,m);if(w)return w}}}function _(p){if("asset inputs:file"in p){const m=p["asset inputs:file"].replace(/@*/g,""),T=new f.TextureLoader().load(a[m]),w={'"clamp"':f.ClampToEdgeWrapping,'"mirror"':f.MirroredRepeatWrapping,'"repeat"':f.RepeatWrapping};return"token inputs:wrapS"in p&&(T.wrapS=w[p["token inputs:wrapS"]]),"token inputs:wrapT"in p&&(T.wrapT=w[p["token inputs:wrapT"]]),T}return null}function C(p){const m=g(u(p)),A=L(S(p)),T=m?new f.Mesh(m,A):new f.Object3D;if("matrix4d xformOp:transform"in p){const w=JSON.parse("["+p["matrix4d xformOp:transform"].replace(/[()]*/g,"")+"]");T.matrix.fromArray(w),T.matrix.decompose(T.position,T.quaternion,T.scale)}return T}function I(p,m){for(const A in p)if(A.startsWith("def Scope"))I(p[A],m);else if(A.startsWith("def Xform")){const T=C(p[A]);/def Xform "(\w+)"/.test(A)&&(T.name=/def Xform "(\w+)"/.exec(A)[1]),m.add(T),I(p[A],T)}}const M=new f.Group;return I(l,M),M}}const V=new WeakMap;class ze extends f.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,o,s){const r=new f.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,n=>{this.parse(n,t,s)},o,s)}parse(e,t,o=()=>{}){this.decodeDracoFile(e,t,null,null,f.SRGBColorSpace).catch(o)}decodeDracoFile(e,t,o,s,r=f.LinearSRGBColorSpace,n=()=>{}){const a={attributeIDs:o||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!o,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t).catch(n)}decodeGeometry(e,t){const o=JSON.stringify(t);if(V.has(e)){const i=V.get(e);if(i.key===o)return i.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const r=this.workerNextTaskID++,n=e.byteLength,a=this._getWorker(r,n).then(i=>(s=i,new Promise((c,l)=>{s._callbacks[r]={resolve:c,reject:l},s.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(i=>this._createGeometry(i.geometry));return a.catch(()=>!0).then(()=>{s&&r&&this._releaseTask(s,r)}),V.set(e,{key:o,promise:a}),a}_createGeometry(e){const t=new f.BufferGeometry;e.index&&t.setIndex(new f.BufferAttribute(e.index.array,1));for(let o=0;o<e.attributes.length;o++){const s=e.attributes[o],r=s.name,n=s.array,a=s.itemSize,i=new f.BufferAttribute(n,a);r==="color"&&(this._assignVertexColorSpace(i,s.vertexColorSpace),i.normalized=!(n instanceof Float32Array)),t.setAttribute(r,i)}return t}_assignVertexColorSpace(e,t){if(t!==f.SRGBColorSpace)return;const o=new f.Color;for(let s=0,r=e.count;s<r;s++)o.fromBufferAttribute(e,s).convertSRGBToLinear(),e.setXYZ(s,o.r,o.g,o.b)}_loadLibrary(e,t){const o=new f.FileLoader(this.manager);return o.setPath(this.decoderPath),o.setResponseType(t),o.setWithCredentials(this.withCredentials),new Promise((s,r)=>{o.load(e,s,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(o=>{const s=o[0];e||(this.decoderConfig.wasmBinary=o[1]);const r=Ye.toString(),n=["/* draco decoder */",s,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
3
3
  `);this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const s=new Worker(this.workerSourceURL);s._callbacks={},s._taskCosts={},s._taskLoad=0,s.postMessage({type:"init",decoderConfig:this.decoderConfig}),s.onmessage=function(r){const n=r.data;switch(n.type){case"decode":s._callbacks[n.id].resolve(n);break;case"error":s._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(s)}else this.workerPool.sort(function(s,r){return s._taskLoad>r._taskLoad?-1:1});const o=this.workerPool[this.workerPool.length-1];return o._taskCosts[e]=t,o._taskLoad+=t,o})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Ye(){let h,e;onmessage=function(n){const a=n.data;switch(a.type){case"init":h=a.decoderConfig,e=new Promise(function(l){h.onModuleLoaded=function(u){l({draco:u})},DracoDecoderModule(h)});break;case"decode":const i=a.buffer,c=a.taskConfig;e.then(l=>{const u=l.draco,d=new u.Decoder;try{const g=t(u,d,new Int8Array(i),c),y=g.attributes.map(S=>S.array.buffer);g.index&&y.push(g.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:g},y)}catch(g){console.error(g),self.postMessage({type:"error",id:a.id,error:g.message})}finally{u.destroy(d)}});break}};function t(n,a,i,c){const l=c.attributeIDs,u=c.attributeTypes;let d,g;const y=a.GetEncodedGeometryType(i);if(y===n.TRIANGULAR_MESH)d=new n.Mesh,g=a.DecodeArrayToMesh(i,i.byteLength,d);else if(y===n.POINT_CLOUD)d=new n.PointCloud,g=a.DecodeArrayToPointCloud(i,i.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!g.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());const S={index:null,attributes:[]};for(const R in l){const x=self[u[R]];let L,E;if(c.useUniqueIDs)E=l[R],L=a.GetAttributeByUniqueId(d,E);else{if(E=a.GetAttributeId(d,n[l[R]]),E===-1)continue;L=a.GetAttribute(d,E)}const _=s(n,a,d,R,x,L);R==="color"&&(_.vertexColorSpace=c.vertexColorSpace),S.attributes.push(_)}return y===n.TRIANGULAR_MESH&&(S.index=o(n,a,d)),n.destroy(d),S}function o(n,a,i){const l=i.num_faces()*3,u=l*4,d=n._malloc(u);a.GetTrianglesUInt32Array(i,u,d);const g=new Uint32Array(n.HEAPF32.buffer,d,l).slice();return n._free(d),{array:g,itemSize:1}}function s(n,a,i,c,l,u){const d=u.num_components(),y=i.num_points()*d,S=y*l.BYTES_PER_ELEMENT,R=r(n,l),x=n._malloc(S);a.GetAttributeDataArrayForAllPoints(i,u,R,S,x);const L=new l(n.HEAPF32.buffer,x,y).slice();return n._free(x),{name:c,array:L,itemSize:d}}function r(n,a){switch(a){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}function oe(){let h,e;onmessage=function(n){const a=n.data;switch(a.type){case"init":h=a.decoderConfig,e=new Promise(function(l){h.onModuleLoaded=function(u){l({draco:u})},DracoDecoderModule(h)});break;case"decode":const i=a.buffer,c=a.taskConfig;e.then(l=>{const u=l.draco,d=new u.Decoder;try{const g=t(u,d,new Int8Array(i),c),y=g.attributes.map(S=>S.array.buffer);g.index&&y.push(g.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:g},y)}catch(g){console.error(g),self.postMessage({type:"error",id:a.id,error:g.message})}finally{u.destroy(d)}});break}};function t(n,a,i,c){const l=c.attributeIDs,u=c.attributeTypes;let d,g;const y=a.GetEncodedGeometryType(i);if(y===n.TRIANGULAR_MESH)d=new n.Mesh,g=a.DecodeArrayToMesh(i,i.byteLength,d);else if(y===n.POINT_CLOUD)d=new n.PointCloud,g=a.DecodeArrayToPointCloud(i,i.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!g.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());const S={index:null,attributes:[]};for(const R in l){const x=self[u[R]];let L,E;if(c.useUniqueIDs)E=l[R],L=a.GetAttributeByUniqueId(d,E);else{if(E=a.GetAttributeId(d,n[l[R]]),E===-1)continue;L=a.GetAttribute(d,E)}const _=s(n,a,d,R,x,L);R==="color"&&(_.vertexColorSpace=c.vertexColorSpace),S.attributes.push(_)}return y===n.TRIANGULAR_MESH&&(S.index=o(n,a,d)),n.destroy(d),S}function o(n,a,i){const l=i.num_faces()*3,u=l*4,d=n._malloc(u);a.GetTrianglesUInt32Array(i,u,d);const g=new Uint32Array(n.HEAPF32.buffer,d,l).slice();return n._free(d),{array:g,itemSize:1}}function s(n,a,i,c,l,u){const d=u.num_components(),y=i.num_points()*d,S=y*l.BYTES_PER_ELEMENT,R=r(n,l),x=n._malloc(S);a.GetAttributeDataArrayForAllPoints(i,u,R,S,x);const L=new l(n.HEAPF32.buffer,x,y).slice();return n._free(x),{name:c,array:L,itemSize:d}}function r(n,a){switch(a){case Float32Array:return n.DT_FLOAT32;case Int8Array:return n.DT_INT8;case Int16Array:return n.DT_INT16;case Int32Array:return n.DT_INT32;case Uint8Array:return n.DT_UINT8;case Uint16Array:return n.DT_UINT16;case Uint32Array:return n.DT_UINT32}}}const W={LOAD_DRACO_JS_DECODER:async()=>(await Promise.resolve().then(()=>require("./draco_decoder-DvYjcLz_.cjs"))).default,LOAD_DRACO_WASM_WRAPPER:async()=>(await Promise.resolve().then(()=>require("./draco_wasm_wrapper-FoEVV9af.cjs"))).default,LOAD_DRACO_WASM_DECODER:async()=>{const h=(await Promise.resolve().then(()=>require("./draco_decoder-Bh9flJPu.cjs"))).default;return await(await fetch(h)).arrayBuffer()}};class ie extends ze{constructor(){super(...arguments);k(this,"decoderPending",null);k(this,"decoderConfig",{type:"js",wasmBinary:null});k(this,"workerSourceURL","")}async _initDecoder(){if(this.decoderPending)return this.decoderPending;const t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",o=[];return t?o.push(W.LOAD_DRACO_JS_DECODER()):(o.push(W.LOAD_DRACO_WASM_WRAPPER()),o.push(W.LOAD_DRACO_WASM_DECODER())),this.decoderPending=Promise.all(o).then(s=>{const r=s[0];t||(this.decoderConfig.wasmBinary=s[1]);const n=oe.toString(),a=["/* draco decoder */",r,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(`
4
4
  `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}}class Je{constructor(){k(this,"_gltfLoader");k(this,"_usdzLoader");const e=new ie;e.setDecoderConfig({type:"wasm"}),this._gltfLoader=new de,this._gltfLoader.setDRACOLoader(e),this._usdzLoader=new qe}async load(e){const t=J.getFileTypeFromUri(e);if(t.length===0)throw new U.FileTypeError("No file extension found in URI","");if(!J.isFileTypeSupported(t))throw new U.FileTypeError(`Unsupported file type: ${t}. Supported types: ${fe.SUPPORTED_FILE_TYPES.join(", ")}`,t);const o=Q.AssetCache.read(e);if(o)return o.arrayBuffer?this._parse(o.arrayBuffer,t):o.promise.then(n=>this._parse(n,t));const r=await Q.AssetCache.create(e).load();return this._parse(r,t)}async _parse(e,t){try{switch(t){case"glb":case"gltf":return(await this._gltfLoader.parseAsync(e,"")).scene;case"usdz":return await this._usdzLoader.parse(e)}}catch(o){throw o instanceof Error?new U.ParseError(`Failed to parse ${t} file: ${o.message}`,o):new U.ParseError(`Failed to parse ${t} file`)}}}exports.AssetLoader=Je;exports.DRACOWorker=oe;exports.DracoLoader=ie;
@@ -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-Dp8ElZGj.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-Dp8ElZGj.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=`
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,this.scene.setBackground((r==null?void 0:r.backgroundColor)??p.backgroundColor),this.scene.grid.setVisibility((r==null?void 0:r.displayGrid)??p.displayGrid),this.scene.root.floor.setVisibility((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.1 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 Object.assign(this,{camera:this.mainView.camera,renderer:this.mainView.renderer,setCanvas:r=>{this.mainView.setCanvas(r)},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;
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,this.scene.setBackground((r==null?void 0:r.backgroundColor)??p.backgroundColor),this.scene.grid.setVisibility((r==null?void 0:r.displayGrid)??p.displayGrid),this.scene.root.floor.setVisibility((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.2 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;
@@ -1717,7 +1717,7 @@ class Wt {
1717
1717
  this.mainView.renderer,
1718
1718
  this.scene,
1719
1719
  this.mainView.camera
1720
- ), this.clock.addTicker(this.orientationDisplay)) : this.orientationDisplay = null, console.log("DIVE 2.2.1 initialized successfully!"), console.log(Yt), window.DIVE.instances.push(this);
1720
+ ), this.clock.addTicker(this.orientationDisplay)) : this.orientationDisplay = null, console.log("DIVE 2.2.2 initialized successfully!"), console.log(Yt), window.DIVE.instances.push(this);
1721
1721
  }
1722
1722
  /**
1723
1723
  * @deprecated This static method will be removed in a future version. Please use `import { QuickView, QuickViewSettings, QuickViewDefaultSettings } from '@shopware-ag/dive/quickview'` instead.
@@ -1731,12 +1731,14 @@ class Wt {
1731
1731
  * @deprecated This property will be removed in a future version. Please use properties on the DIVE instance and mainView directly.
1732
1732
  */
1733
1733
  get engine() {
1734
- return Object.assign(this, {
1734
+ return {
1735
+ scene: this.scene,
1735
1736
  camera: this.mainView.camera,
1736
1737
  renderer: this.mainView.renderer,
1737
1738
  setCanvas: (s) => {
1738
1739
  this.mainView.setCanvas(s);
1739
1740
  },
1741
+ clock: this.clock,
1740
1742
  start: () => {
1741
1743
  this.start();
1742
1744
  },
@@ -1746,7 +1748,7 @@ class Wt {
1746
1748
  dispose: () => {
1747
1749
  this.dispose();
1748
1750
  }
1749
- });
1751
+ };
1750
1752
  }
1751
1753
  get views() {
1752
1754
  return this._views;
@@ -1 +1 @@
1
- "use strict";var wt=Object.defineProperty;var gt=(r,n,e)=>n in r?wt(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var h=(r,n,e)=>gt(r,typeof n!="symbol"?n+"":n,e);const Q=require("./FileTypes-DWBc6D11.cjs"),t=require("three"),j=require("./findInterface-C6mrvf_t.cjs"),$=require("./PerspectiveCamera-Dp8ElZGj.cjs"),D=new t.Raycaster,p=new t.Vector3,P=new t.Vector3,c=new t.Quaternion,tt={X:new t.Vector3(1,0,0),Y:new t.Vector3(0,1,0),Z:new t.Vector3(0,0,1)},U={type:"change"},et={type:"mouseDown"},it={type:"mouseUp",mode:null},nt={type:"objectChange"};class bt extends t.Object3D{constructor(n,e){super(),e===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),e=document),this.isTransformControls=!0,this.visible=!1,this.domElement=e,this.domElement.style.touchAction="none";const o=new xt;this._gizmo=o,this.add(o);const s=new Dt;this._plane=s,this.add(s);const a=this;function i(m,y){let A=y;Object.defineProperty(a,m,{get:function(){return A!==void 0?A:y},set:function(x){A!==x&&(A=x,s[m]=x,o[m]=x,a.dispatchEvent({type:m+"-changed",value:x}),a.dispatchEvent(U))}}),a[m]=y,s[m]=y,o[m]=y}i("camera",n),i("object",void 0),i("enabled",!0),i("axis",null),i("mode","translate"),i("translationSnap",null),i("rotationSnap",null),i("scaleSnap",null),i("space","world"),i("size",1),i("dragging",!1),i("showX",!0),i("showY",!0),i("showZ",!0);const d=new t.Vector3,f=new t.Vector3,E=new t.Quaternion,T=new t.Quaternion,z=new t.Vector3,C=new t.Quaternion,K=new t.Vector3,H=new t.Vector3,M=new t.Vector3,S=0,g=new t.Vector3;i("worldPosition",d),i("worldPositionStart",f),i("worldQuaternion",E),i("worldQuaternionStart",T),i("cameraPosition",z),i("cameraQuaternion",C),i("pointStart",K),i("pointEnd",H),i("rotationAxis",M),i("rotationAngle",S),i("eye",g),this._offset=new t.Vector3,this._startNorm=new t.Vector3,this._endNorm=new t.Vector3,this._cameraScale=new t.Vector3,this._parentPosition=new t.Vector3,this._parentQuaternion=new t.Quaternion,this._parentQuaternionInv=new t.Quaternion,this._parentScale=new t.Vector3,this._worldScaleStart=new t.Vector3,this._worldQuaternionInv=new t.Quaternion,this._worldScale=new t.Vector3,this._positionStart=new t.Vector3,this._quaternionStart=new t.Quaternion,this._scaleStart=new t.Vector3,this._getPointer=Mt.bind(this),this._onPointerDown=vt.bind(this),this._onPointerHover=St.bind(this),this._onPointerMove=Pt.bind(this),this._onPointerUp=Et.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(n){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(n)}pointerHover(n){if(this.object===void 0||this.dragging===!0)return;n!==null&&D.setFromCamera(n,this.camera);const e=N(this._gizmo.picker[this.mode],D);e?this.axis=e.object.name:this.axis=null}pointerDown(n){if(!(this.object===void 0||this.dragging===!0||n!=null&&n.button!==0)&&this.axis!==null){n!==null&&D.setFromCamera(n,this.camera);const e=N(this._plane,D,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,et.mode=this.mode,this.dispatchEvent(et)}}pointerMove(n){const e=this.axis,o=this.mode,s=this.object;let a=this.space;if(o==="scale"?a="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(a="world"),s===void 0||e===null||this.dragging===!1||n!==null&&n.button!==-1)return;n!==null&&D.setFromCamera(n,this.camera);const i=N(this._plane,D,!0);if(i){if(this.pointEnd.copy(i.point).sub(this.worldPositionStart),o==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&e!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),e.indexOf("X")===-1&&(this._offset.x=0),e.indexOf("Y")===-1&&(this._offset.y=0),e.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&e!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(s.position.applyQuaternion(c.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),a==="world"&&(s.parent&&s.position.add(p.setFromMatrixPosition(s.parent.matrixWorld)),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(p.setFromMatrixPosition(s.parent.matrixWorld))));else if(o==="scale"){if(e.search("XYZ")!==-1){let d=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(d*=-1),P.set(d,d,d)}else p.copy(this.pointStart),P.copy(this.pointEnd),p.applyQuaternion(this._worldQuaternionInv),P.applyQuaternion(this._worldQuaternionInv),P.divide(p),e.search("X")===-1&&(P.x=1),e.search("Y")===-1&&(P.y=1),e.search("Z")===-1&&(P.z=1);s.scale.copy(this._scaleStart).multiply(P),this.scaleSnap&&(e.search("X")!==-1&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(o==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const d=20/this.worldPosition.distanceTo(p.setFromMatrixPosition(this.camera.matrixWorld));let f=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(p.copy(this.rotationAxis).cross(this.eye))*d):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(tt[e]),p.copy(tt[e]),a==="local"&&p.applyQuaternion(this.worldQuaternion),p.cross(this.eye),p.length()===0?f=!0:this.rotationAngle=this._offset.dot(p.normalize())*d),(e==="E"||f)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&e!=="E"&&e!=="XYZE"?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(c.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(c.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(U),this.dispatchEvent(nt)}}pointerUp(n){n!==null&&n.button!==0||(this.dragging&&this.axis!==null&&(it.mode=this.mode,this.dispatchEvent(it)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(n){n.geometry&&n.geometry.dispose(),n.material&&n.material.dispose()})}attach(n){return this.object=n,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(U),this.dispatchEvent(nt),this.pointStart.copy(this.pointEnd))}getRaycaster(){return D}getMode(){return this.mode}setMode(n){this.mode=n}setTranslationSnap(n){this.translationSnap=n}setRotationSnap(n){this.rotationSnap=n}setScaleSnap(n){this.scaleSnap=n}setSize(n){this.size=n}setSpace(n){this.space=n}}function Mt(r){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:r.button};{const n=this.domElement.getBoundingClientRect();return{x:(r.clientX-n.left)/n.width*2-1,y:-(r.clientY-n.top)/n.height*2+1,button:r.button}}}function St(r){if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(r));break}}function vt(r){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(r)),this.pointerDown(this._getPointer(r)))}function Pt(r){this.enabled&&this.pointerMove(this._getPointer(r))}function Et(r){this.enabled&&(this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(r)))}function N(r,n,e){const o=n.intersectObject(r,!0);for(let s=0;s<o.length;s++)if(o[s].object.visible||e)return o[s];return!1}const q=new t.Euler,l=new t.Vector3(0,1,0),ot=new t.Vector3(0,0,0),st=new t.Matrix4,B=new t.Quaternion,F=new t.Quaternion,b=new t.Vector3,rt=new t.Matrix4,O=new t.Vector3(1,0,0),I=new t.Vector3(0,1,0),Z=new t.Vector3(0,0,1),W=new t.Vector3,X=new t.Vector3,Y=new t.Vector3;class xt extends t.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const n=new t.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new t.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),o=n.clone();o.opacity=.15;const s=e.clone();s.opacity=.5;const a=n.clone();a.color.setHex(16711680);const i=n.clone();i.color.setHex(65280);const d=n.clone();d.color.setHex(255);const f=n.clone();f.color.setHex(16711680),f.opacity=.5;const E=n.clone();E.color.setHex(65280),E.opacity=.5;const T=n.clone();T.color.setHex(255),T.opacity=.5;const z=n.clone();z.opacity=.25;const C=n.clone();C.color.setHex(16776960),C.opacity=.25,n.clone().color.setHex(16776960);const H=n.clone();H.color.setHex(7895160);const M=new t.CylinderGeometry(0,.04,.1,12);M.translate(0,.05,0);const S=new t.BoxGeometry(.08,.08,.08);S.translate(0,.04,0);const g=new t.BufferGeometry;g.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,0,0],3));const m=new t.CylinderGeometry(.0075,.0075,.5,3);m.translate(0,.25,0);function y(_,V){const w=new t.TorusGeometry(_,.0075,3,64,V*Math.PI*2);return w.rotateY(Math.PI/2),w.rotateX(Math.PI/2),w}function A(){const _=new t.BufferGeometry;return _.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,1,1],3)),_}const x={X:[[new t.Mesh(M,a),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(M,a),[-.5,0,0],[0,0,Math.PI/2]],[new t.Mesh(m,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new t.Mesh(M,i),[0,.5,0]],[new t.Mesh(M,i),[0,-.5,0],[Math.PI,0,0]],[new t.Mesh(m,i)]],Z:[[new t.Mesh(M,d),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(M,d),[0,0,-.5],[-Math.PI/2,0,0]],[new t.Mesh(m,d),null,[Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.OctahedronGeometry(.1,0),z.clone()),[0,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),T.clone()),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),f.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),E.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},ht={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.OctahedronGeometry(.2,0),o)]],XY:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[.15,0,.15],[-Math.PI/2,0,0]]]},ct={START:[[new t.Mesh(new t.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new t.Mesh(new t.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new t.Line(A(),s),null,null,null,"helper"]],X:[[new t.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new t.Line(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new t.Line(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},dt={XYZE:[[new t.Mesh(y(.5,1),H),null,[0,Math.PI/2,0]]],X:[[new t.Mesh(y(.5,.5),a)]],Y:[[new t.Mesh(y(.5,.5),i),null,[0,0,-Math.PI/2]]],Z:[[new t.Mesh(y(.5,.5),d),null,[0,Math.PI/2,0]]],E:[[new t.Mesh(y(.75,1),C),null,[0,Math.PI/2,0]]]},pt={AXIS:[[new t.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},mt={XYZE:[[new t.Mesh(new t.SphereGeometry(.25,10,8),o)]],X:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),o),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),o),[0,0,0],[Math.PI/2,0,0]]],Z:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),o),[0,0,0],[0,0,-Math.PI/2]]],E:[[new t.Mesh(new t.TorusGeometry(.75,.1,2,24),o)]]},ut={X:[[new t.Mesh(S,a),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(m,a),[0,0,0],[0,0,-Math.PI/2]],[new t.Mesh(S,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(S,i),[0,.5,0]],[new t.Mesh(m,i)],[new t.Mesh(S,i),[0,-.5,0],[0,0,Math.PI]]],Z:[[new t.Mesh(S,d),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(m,d),[0,0,0],[Math.PI/2,0,0]],[new t.Mesh(S,d),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),T),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),f),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),E),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.BoxGeometry(.1,.1,.1),z.clone())]]},ft={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.2),o),[0,0,0]]]},_t={X:[[new t.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new t.Line(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new t.Line(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function v(_){const V=new t.Object3D;for(const w in _)for(let G=_[w].length;G--;){const u=_[w][G][0].clone(),L=_[w][G][1],R=_[w][G][2],k=_[w][G][3],yt=_[w][G][4];u.name=w,u.tag=yt,L&&u.position.set(L[0],L[1],L[2]),R&&u.rotation.set(R[0],R[1],R[2]),k&&u.scale.set(k[0],k[1],k[2]),u.updateMatrix();const J=u.geometry.clone();J.applyMatrix4(u.matrix),u.geometry=J,u.renderOrder=1/0,u.position.set(0,0,0),u.rotation.set(0,0,0),u.scale.set(1,1,1),V.add(u)}return V}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=v(x)),this.add(this.gizmo.rotate=v(dt)),this.add(this.gizmo.scale=v(ut)),this.add(this.picker.translate=v(ht)),this.add(this.picker.rotate=v(mt)),this.add(this.picker.scale=v(ft)),this.add(this.helper.translate=v(ct)),this.add(this.helper.rotate=v(pt)),this.add(this.helper.scale=v(_t)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(n){const o=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:F;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let a=0;a<s.length;a++){const i=s[a];i.visible=!0,i.rotation.set(0,0,0),i.position.copy(this.worldPosition);let d;if(this.camera.isOrthographicCamera?d=(this.camera.top-this.camera.bottom)/this.camera.zoom:d=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),i.scale.set(1,1,1).multiplyScalar(d*this.size/4),i.tag==="helper"){i.visible=!1,i.name==="AXIS"?(i.visible=!!this.axis,this.axis==="X"&&(c.setFromEuler(q.set(0,0,0)),i.quaternion.copy(o).multiply(c),Math.abs(l.copy(O).applyQuaternion(o).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="Y"&&(c.setFromEuler(q.set(0,0,Math.PI/2)),i.quaternion.copy(o).multiply(c),Math.abs(l.copy(I).applyQuaternion(o).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="Z"&&(c.setFromEuler(q.set(0,Math.PI/2,0)),i.quaternion.copy(o).multiply(c),Math.abs(l.copy(Z).applyQuaternion(o).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="XYZE"&&(c.setFromEuler(q.set(0,Math.PI/2,0)),l.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(st.lookAt(ot,l,I)),i.quaternion.multiply(c),i.visible=this.dragging),this.axis==="E"&&(i.visible=!1)):i.name==="START"?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):i.name==="END"?(i.position.copy(this.worldPosition),i.visible=this.dragging):i.name==="DELTA"?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),p.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),p.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(p),i.visible=this.dragging):(i.quaternion.copy(o),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=this.axis.search(i.name)!==-1));continue}i.quaternion.copy(o),this.mode==="translate"||this.mode==="scale"?(i.name==="X"&&Math.abs(l.copy(O).applyQuaternion(o).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="Y"&&Math.abs(l.copy(I).applyQuaternion(o).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="Z"&&Math.abs(l.copy(Z).applyQuaternion(o).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="XY"&&Math.abs(l.copy(Z).applyQuaternion(o).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="YZ"&&Math.abs(l.copy(O).applyQuaternion(o).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="XZ"&&Math.abs(l.copy(I).applyQuaternion(o).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)):this.mode==="rotate"&&(B.copy(o),l.copy(this.eye).applyQuaternion(c.copy(o).invert()),i.name.search("E")!==-1&&i.quaternion.setFromRotationMatrix(st.lookAt(this.eye,ot,I)),i.name==="X"&&(c.setFromAxisAngle(O,Math.atan2(-l.y,l.z)),c.multiplyQuaternions(B,c),i.quaternion.copy(c)),i.name==="Y"&&(c.setFromAxisAngle(I,Math.atan2(l.x,l.z)),c.multiplyQuaternions(B,c),i.quaternion.copy(c)),i.name==="Z"&&(c.setFromAxisAngle(Z,Math.atan2(l.y,l.x)),c.multiplyQuaternions(B,c),i.quaternion.copy(c))),i.visible=i.visible&&(i.name.indexOf("X")===-1||this.showX),i.visible=i.visible&&(i.name.indexOf("Y")===-1||this.showY),i.visible=i.visible&&(i.name.indexOf("Z")===-1||this.showZ),i.visible=i.visible&&(i.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),i.material._color=i.material._color||i.material.color.clone(),i.material._opacity=i.material._opacity||i.material.opacity,i.material.color.copy(i.material._color),i.material.opacity=i.material._opacity,this.enabled&&this.axis&&(i.name===this.axis||this.axis.split("").some(function(f){return i.name===f}))&&(i.material.color.setHex(16776960),i.material.opacity=1)}super.updateMatrixWorld(n)}}class Dt extends t.Mesh{constructor(){super(new t.PlaneGeometry(1e5,1e5,2,2),new t.MeshBasicMaterial({visible:!1,wireframe:!0,side:t.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(n){let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),W.copy(O).applyQuaternion(e==="local"?this.worldQuaternion:F),X.copy(I).applyQuaternion(e==="local"?this.worldQuaternion:F),Y.copy(Z).applyQuaternion(e==="local"?this.worldQuaternion:F),l.copy(X),this.mode){case"translate":case"scale":switch(this.axis){case"X":l.copy(this.eye).cross(W),b.copy(W).cross(l);break;case"Y":l.copy(this.eye).cross(X),b.copy(X).cross(l);break;case"Z":l.copy(this.eye).cross(Y),b.copy(Y).cross(l);break;case"XY":b.copy(Y);break;case"YZ":b.copy(W);break;case"XZ":l.copy(Y),b.copy(X);break;case"XYZ":case"E":b.set(0,0,0);break}break;case"rotate":default:b.set(0,0,0)}b.length()===0?this.quaternion.copy(this.cameraQuaternion):(rt.lookAt(p.set(0,0,0),b,l),this.quaternion.setFromRotationMatrix(rt)),super.updateMatrixWorld(n)}}class at{constructor(n,e){h(this,"POINTER_DRAG_THRESHOLD",.001);h(this,"name");h(this,"_canvas");h(this,"_scene");h(this,"_controller");h(this,"_pointer");h(this,"_pointerPrimaryDown");h(this,"_pointerMiddleDown");h(this,"_pointerSecondaryDown");h(this,"_lastPointerDown");h(this,"_lastPointerUp");h(this,"_raycaster");h(this,"_intersects");h(this,"_hovered");h(this,"_dragging");h(this,"_dragStart");h(this,"_dragCurrent");h(this,"_dragEnd");h(this,"_dragDelta");h(this,"_draggable");h(this,"_dragRaycastOnObjects");this.name="BaseTool",this._canvas=e.domElement,this._scene=n,this._controller=e,this._pointer=new t.Vector2,this._pointerPrimaryDown=!1,this._pointerMiddleDown=!1,this._pointerSecondaryDown=!1,this._lastPointerDown=new t.Vector2,this._lastPointerUp=new t.Vector2,this._raycaster=new t.Raycaster,this._raycaster.layers.mask=$.PRODUCT_LAYER_MASK|$.UI_LAYER_MASK,this._intersects=[],this._hovered=null,this._dragging=!1,this._dragStart=new t.Vector3,this._dragCurrent=new t.Vector3,this._dragEnd=new t.Vector3,this._dragDelta=new t.Vector3,this._draggable=null,this._dragRaycastOnObjects=null}get _pointerAnyDown(){return this._pointerPrimaryDown||this._pointerMiddleDown||this._pointerSecondaryDown}activate(){}deactivate(){}onPointerDown(n){var e;switch(n.button){case 0:{this._pointerPrimaryDown=!0;break}case 1:{this._pointerMiddleDown=!0;break}case 2:{this._pointerSecondaryDown=!0;break}default:console.warn("DIVEBaseTool.onPointerDown: Unknown button: "+n.button)}this._lastPointerDown.copy(this._pointer),this._draggable=j.findInterface((e=this._intersects[0])==null?void 0:e.object,"isDraggable")||null}onDragStart(n){this._draggable&&(this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0)),this._intersects.length!==0&&(this._dragStart.copy(this._intersects[0].point.clone()),this._dragCurrent.copy(this._intersects[0].point.clone()),this._dragEnd.copy(this._dragStart.clone()),this._dragDelta.set(0,0,0),this._draggable&&this._draggable.onDragStart&&(this._draggable.onDragStart({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._dragging=!0,this._controller.enabled=!1)))}onPointerMove(n){var o;this._pointer.x=n.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(n.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object),this._intersects=this.raycast(this._scene.children);const e=j.findInterface((o=this._intersects[0])==null?void 0:o.object,"isHoverable");if(this._intersects[0]&&e){if(!this._hovered){e.onPointerEnter&&e.onPointerEnter(this._intersects[0]),this._hovered=e;return}if(this._hovered.uuid!==e.uuid){this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),e.onPointerEnter&&e.onPointerEnter(this._intersects[0]),this._hovered=e;return}e.onPointerOver&&e.onPointerOver(this._intersects[0]),this._hovered=e}else this._hovered&&this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),this._hovered=null;this._pointerAnyDown&&(this._dragging||this.onDragStart(n),this.onDrag(n))}onDrag(n){this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0));const e=this._intersects[0];e&&(this._dragCurrent.copy(e.point.clone()),this._dragEnd.copy(e.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone()),this._draggable&&this._draggable.onDrag&&this._draggable.onDrag({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}))}onPointerUp(n){switch(this.pointerWasDragged()||this._dragging?this._draggable&&this.onDragEnd(n):this.onClick(n),n.button){case 0:this._pointerPrimaryDown=!1;break;case 1:this._pointerMiddleDown=!1;break;case 2:this._pointerSecondaryDown=!1;break}this._lastPointerUp.copy(this._pointer)}onClick(n){}onDragEnd(n){const e=this._intersects[0];e&&(this._dragEnd.copy(e.point.clone()),this._dragCurrent.copy(e.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone())),this._draggable&&this._draggable.onDragEnd&&this._draggable.onDragEnd({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._draggable=null,this._dragging=!1,this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0),this._controller.enabled=!0}onWheel(n){}raycast(n){return n!==void 0?this._raycaster.intersectObjects(n,!0).filter(e=>e.object.visible):this._raycaster.intersectObjects(this._scene.children,!0).filter(e=>e.object.visible)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>this.POINTER_DRAG_THRESHOLD}}const It=r=>r.isTransformTool!==void 0;class lt extends at{constructor(e,o){super(e,o);h(this,"isTransformTool",!0);h(this,"_scaleLinked");h(this,"_gizmo");this.name="DIVETransformTool",this._scaleLinked=!1,this._gizmo=this.initGizmo(),this._scene.add(this._gizmo)}activate(){}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){const o=this._scene.children.includes(this._gizmo);e&&!o?(this._scene.add(this._gizmo),"isTransformControls"in this._gizmo&&this._gizmo.getRaycaster().layers.enableAll()):!e&&o&&(this._scene.remove(this._gizmo),"isTransformControls"in this._gizmo&&this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}initGizmo(){const e=new bt(this._controller.object,this._controller.domElement);return e.mode="translate",e.traverse(o=>{if(!("isMesh"in o))return;const s=o.material;o.name==="X"&&s.color.set(Q.AxesColorRed),o.name==="Y"&&s.color.set(Q.AxesColorGreen),o.name==="Z"&&s.color.set(Q.AxesColorBlue),o.name==="XY"&&s.color.set(Q.AxesColorBlue),o.name==="YZ"&&s.color.set(Q.AxesColorRed),o.name==="XZ"&&s.color.set(Q.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{this._controller.enabled=!1,j.implementsInterface(e.object,"isMovable")&&e.object.onMoveStart&&e.object.onMoveStart()}),e.addEventListener("objectChange",()=>{if(j.implementsInterface(e.object,"isMovable")&&e.object.onMove&&(e.object.onMove(),this._scaleLinked)){const o=e.object.scale,s=(o.x+o.y+o.z)/3;e.object.scale.set(s,s,s)}}),e.addEventListener("mouseUp",()=>{this._controller.enabled=!0,j.implementsInterface(e.object,"isMovable")&&e.object.onMoveEnd&&e.object.onMoveEnd()}),e}}const Tt=r=>r.isSelectTool!==void 0;class At extends lt{constructor(e,o){super(e,o);h(this,"isSelectTool",!0);this.name="SelectTool"}activate(){}select(e){this.attachGizmo(e),e.onSelect&&e.onSelect()}deselect(e){this.detachGizmo(),e.onDeselect&&e.onDeselect()}attachGizmo(e){if("isMovable"in e){const o=e;this._gizmo.attach(o),this.setGizmoVisible(o.visible)}}detachGizmo(){this._gizmo.detach()}onClick(e){super.onClick(e);const o=this._raycaster.intersectObjects(this._scene.root.children,!0).filter(a=>a.object.visible)[0],s=j.findInterface(o==null?void 0:o.object,"isSelectable");if(!o||!s){this._gizmo.object&&this.deselect(this._gizmo.object);return}if(this._gizmo.object){if(this._gizmo.object.uuid===s.uuid)return;this.deselect(this._gizmo.object)}this.select(s)}}exports.DIVEBaseTool=at;exports.DIVESelectTool=At;exports.DIVETransformTool=lt;exports.isSelectTool=Tt;exports.isTransformTool=It;
1
+ "use strict";var wt=Object.defineProperty;var gt=(r,n,e)=>n in r?wt(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var h=(r,n,e)=>gt(r,typeof n!="symbol"?n+"":n,e);const Q=require("./FileTypes-BQlqpkm2.cjs"),t=require("three"),j=require("./findInterface-C6mrvf_t.cjs"),$=require("./PerspectiveCamera-Dp8ElZGj.cjs"),D=new t.Raycaster,p=new t.Vector3,P=new t.Vector3,c=new t.Quaternion,tt={X:new t.Vector3(1,0,0),Y:new t.Vector3(0,1,0),Z:new t.Vector3(0,0,1)},U={type:"change"},et={type:"mouseDown"},it={type:"mouseUp",mode:null},nt={type:"objectChange"};class bt extends t.Object3D{constructor(n,e){super(),e===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),e=document),this.isTransformControls=!0,this.visible=!1,this.domElement=e,this.domElement.style.touchAction="none";const o=new xt;this._gizmo=o,this.add(o);const s=new Dt;this._plane=s,this.add(s);const a=this;function i(m,y){let A=y;Object.defineProperty(a,m,{get:function(){return A!==void 0?A:y},set:function(x){A!==x&&(A=x,s[m]=x,o[m]=x,a.dispatchEvent({type:m+"-changed",value:x}),a.dispatchEvent(U))}}),a[m]=y,s[m]=y,o[m]=y}i("camera",n),i("object",void 0),i("enabled",!0),i("axis",null),i("mode","translate"),i("translationSnap",null),i("rotationSnap",null),i("scaleSnap",null),i("space","world"),i("size",1),i("dragging",!1),i("showX",!0),i("showY",!0),i("showZ",!0);const d=new t.Vector3,f=new t.Vector3,E=new t.Quaternion,T=new t.Quaternion,z=new t.Vector3,C=new t.Quaternion,K=new t.Vector3,H=new t.Vector3,M=new t.Vector3,S=0,g=new t.Vector3;i("worldPosition",d),i("worldPositionStart",f),i("worldQuaternion",E),i("worldQuaternionStart",T),i("cameraPosition",z),i("cameraQuaternion",C),i("pointStart",K),i("pointEnd",H),i("rotationAxis",M),i("rotationAngle",S),i("eye",g),this._offset=new t.Vector3,this._startNorm=new t.Vector3,this._endNorm=new t.Vector3,this._cameraScale=new t.Vector3,this._parentPosition=new t.Vector3,this._parentQuaternion=new t.Quaternion,this._parentQuaternionInv=new t.Quaternion,this._parentScale=new t.Vector3,this._worldScaleStart=new t.Vector3,this._worldQuaternionInv=new t.Quaternion,this._worldScale=new t.Vector3,this._positionStart=new t.Vector3,this._quaternionStart=new t.Quaternion,this._scaleStart=new t.Vector3,this._getPointer=Mt.bind(this),this._onPointerDown=vt.bind(this),this._onPointerHover=St.bind(this),this._onPointerMove=Pt.bind(this),this._onPointerUp=Et.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(n){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(n)}pointerHover(n){if(this.object===void 0||this.dragging===!0)return;n!==null&&D.setFromCamera(n,this.camera);const e=N(this._gizmo.picker[this.mode],D);e?this.axis=e.object.name:this.axis=null}pointerDown(n){if(!(this.object===void 0||this.dragging===!0||n!=null&&n.button!==0)&&this.axis!==null){n!==null&&D.setFromCamera(n,this.camera);const e=N(this._plane,D,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,et.mode=this.mode,this.dispatchEvent(et)}}pointerMove(n){const e=this.axis,o=this.mode,s=this.object;let a=this.space;if(o==="scale"?a="local":(e==="E"||e==="XYZE"||e==="XYZ")&&(a="world"),s===void 0||e===null||this.dragging===!1||n!==null&&n.button!==-1)return;n!==null&&D.setFromCamera(n,this.camera);const i=N(this._plane,D,!0);if(i){if(this.pointEnd.copy(i.point).sub(this.worldPositionStart),o==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&e!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),e.indexOf("X")===-1&&(this._offset.x=0),e.indexOf("Y")===-1&&(this._offset.y=0),e.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&e!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(s.position.applyQuaternion(c.copy(this._quaternionStart).invert()),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),a==="world"&&(s.parent&&s.position.add(p.setFromMatrixPosition(s.parent.matrixWorld)),e.search("X")!==-1&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),e.search("Y")!==-1&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),e.search("Z")!==-1&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(p.setFromMatrixPosition(s.parent.matrixWorld))));else if(o==="scale"){if(e.search("XYZ")!==-1){let d=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(d*=-1),P.set(d,d,d)}else p.copy(this.pointStart),P.copy(this.pointEnd),p.applyQuaternion(this._worldQuaternionInv),P.applyQuaternion(this._worldQuaternionInv),P.divide(p),e.search("X")===-1&&(P.x=1),e.search("Y")===-1&&(P.y=1),e.search("Z")===-1&&(P.z=1);s.scale.copy(this._scaleStart).multiply(P),this.scaleSnap&&(e.search("X")!==-1&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Y")!==-1&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),e.search("Z")!==-1&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(o==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const d=20/this.worldPosition.distanceTo(p.setFromMatrixPosition(this.camera.matrixWorld));let f=!1;e==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(p.copy(this.rotationAxis).cross(this.eye))*d):(e==="X"||e==="Y"||e==="Z")&&(this.rotationAxis.copy(tt[e]),p.copy(tt[e]),a==="local"&&p.applyQuaternion(this.worldQuaternion),p.cross(this.eye),p.length()===0?f=!0:this.rotationAngle=this._offset.dot(p.normalize())*d),(e==="E"||f)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),a==="local"&&e!=="E"&&e!=="XYZE"?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(c.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(c.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(U),this.dispatchEvent(nt)}}pointerUp(n){n!==null&&n.button!==0||(this.dragging&&this.axis!==null&&(it.mode=this.mode,this.dispatchEvent(it)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(n){n.geometry&&n.geometry.dispose(),n.material&&n.material.dispose()})}attach(n){return this.object=n,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(U),this.dispatchEvent(nt),this.pointStart.copy(this.pointEnd))}getRaycaster(){return D}getMode(){return this.mode}setMode(n){this.mode=n}setTranslationSnap(n){this.translationSnap=n}setRotationSnap(n){this.rotationSnap=n}setScaleSnap(n){this.scaleSnap=n}setSize(n){this.size=n}setSpace(n){this.space=n}}function Mt(r){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:r.button};{const n=this.domElement.getBoundingClientRect();return{x:(r.clientX-n.left)/n.width*2-1,y:-(r.clientY-n.top)/n.height*2+1,button:r.button}}}function St(r){if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(r));break}}function vt(r){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(r)),this.pointerDown(this._getPointer(r)))}function Pt(r){this.enabled&&this.pointerMove(this._getPointer(r))}function Et(r){this.enabled&&(this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(r)))}function N(r,n,e){const o=n.intersectObject(r,!0);for(let s=0;s<o.length;s++)if(o[s].object.visible||e)return o[s];return!1}const q=new t.Euler,l=new t.Vector3(0,1,0),ot=new t.Vector3(0,0,0),st=new t.Matrix4,B=new t.Quaternion,F=new t.Quaternion,b=new t.Vector3,rt=new t.Matrix4,O=new t.Vector3(1,0,0),I=new t.Vector3(0,1,0),Z=new t.Vector3(0,0,1),W=new t.Vector3,X=new t.Vector3,Y=new t.Vector3;class xt extends t.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const n=new t.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new t.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),o=n.clone();o.opacity=.15;const s=e.clone();s.opacity=.5;const a=n.clone();a.color.setHex(16711680);const i=n.clone();i.color.setHex(65280);const d=n.clone();d.color.setHex(255);const f=n.clone();f.color.setHex(16711680),f.opacity=.5;const E=n.clone();E.color.setHex(65280),E.opacity=.5;const T=n.clone();T.color.setHex(255),T.opacity=.5;const z=n.clone();z.opacity=.25;const C=n.clone();C.color.setHex(16776960),C.opacity=.25,n.clone().color.setHex(16776960);const H=n.clone();H.color.setHex(7895160);const M=new t.CylinderGeometry(0,.04,.1,12);M.translate(0,.05,0);const S=new t.BoxGeometry(.08,.08,.08);S.translate(0,.04,0);const g=new t.BufferGeometry;g.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,0,0],3));const m=new t.CylinderGeometry(.0075,.0075,.5,3);m.translate(0,.25,0);function y(_,V){const w=new t.TorusGeometry(_,.0075,3,64,V*Math.PI*2);return w.rotateY(Math.PI/2),w.rotateX(Math.PI/2),w}function A(){const _=new t.BufferGeometry;return _.setAttribute("position",new t.Float32BufferAttribute([0,0,0,1,1,1],3)),_}const x={X:[[new t.Mesh(M,a),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(M,a),[-.5,0,0],[0,0,Math.PI/2]],[new t.Mesh(m,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new t.Mesh(M,i),[0,.5,0]],[new t.Mesh(M,i),[0,-.5,0],[Math.PI,0,0]],[new t.Mesh(m,i)]],Z:[[new t.Mesh(M,d),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(M,d),[0,0,-.5],[-Math.PI/2,0,0]],[new t.Mesh(m,d),null,[Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.OctahedronGeometry(.1,0),z.clone()),[0,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),T.clone()),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),f.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),E.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},ht={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.OctahedronGeometry(.2,0),o)]],XY:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[.15,0,.15],[-Math.PI/2,0,0]]]},ct={START:[[new t.Mesh(new t.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new t.Mesh(new t.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new t.Line(A(),s),null,null,null,"helper"]],X:[[new t.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new t.Line(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new t.Line(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},dt={XYZE:[[new t.Mesh(y(.5,1),H),null,[0,Math.PI/2,0]]],X:[[new t.Mesh(y(.5,.5),a)]],Y:[[new t.Mesh(y(.5,.5),i),null,[0,0,-Math.PI/2]]],Z:[[new t.Mesh(y(.5,.5),d),null,[0,Math.PI/2,0]]],E:[[new t.Mesh(y(.75,1),C),null,[0,Math.PI/2,0]]]},pt={AXIS:[[new t.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},mt={XYZE:[[new t.Mesh(new t.SphereGeometry(.25,10,8),o)]],X:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),o),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),o),[0,0,0],[Math.PI/2,0,0]]],Z:[[new t.Mesh(new t.TorusGeometry(.5,.1,4,24),o),[0,0,0],[0,0,-Math.PI/2]]],E:[[new t.Mesh(new t.TorusGeometry(.75,.1,2,24),o)]]},ut={X:[[new t.Mesh(S,a),[.5,0,0],[0,0,-Math.PI/2]],[new t.Mesh(m,a),[0,0,0],[0,0,-Math.PI/2]],[new t.Mesh(S,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(S,i),[0,.5,0]],[new t.Mesh(m,i)],[new t.Mesh(S,i),[0,-.5,0],[0,0,Math.PI]]],Z:[[new t.Mesh(S,d),[0,0,.5],[Math.PI/2,0,0]],[new t.Mesh(m,d),[0,0,0],[Math.PI/2,0,0]],[new t.Mesh(S,d),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),T),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),f),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.15,.15,.01),E),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.BoxGeometry(.1,.1,.1),z.clone())]]},ft={X:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[.3,0,0],[0,0,-Math.PI/2]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,.3,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,-.3,0],[0,0,Math.PI]]],Z:[[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,0,.3],[Math.PI/2,0,0]],[new t.Mesh(new t.CylinderGeometry(.2,0,.6,4),o),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[.15,.15,0]]],YZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.01),o),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new t.Mesh(new t.BoxGeometry(.2,.2,.2),o),[0,0,0]]]},_t={X:[[new t.Line(g,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new t.Line(g,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new t.Line(g,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function v(_){const V=new t.Object3D;for(const w in _)for(let G=_[w].length;G--;){const u=_[w][G][0].clone(),L=_[w][G][1],R=_[w][G][2],k=_[w][G][3],yt=_[w][G][4];u.name=w,u.tag=yt,L&&u.position.set(L[0],L[1],L[2]),R&&u.rotation.set(R[0],R[1],R[2]),k&&u.scale.set(k[0],k[1],k[2]),u.updateMatrix();const J=u.geometry.clone();J.applyMatrix4(u.matrix),u.geometry=J,u.renderOrder=1/0,u.position.set(0,0,0),u.rotation.set(0,0,0),u.scale.set(1,1,1),V.add(u)}return V}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=v(x)),this.add(this.gizmo.rotate=v(dt)),this.add(this.gizmo.scale=v(ut)),this.add(this.picker.translate=v(ht)),this.add(this.picker.rotate=v(mt)),this.add(this.picker.scale=v(ft)),this.add(this.helper.translate=v(ct)),this.add(this.helper.rotate=v(pt)),this.add(this.helper.scale=v(_t)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(n){const o=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:F;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let a=0;a<s.length;a++){const i=s[a];i.visible=!0,i.rotation.set(0,0,0),i.position.copy(this.worldPosition);let d;if(this.camera.isOrthographicCamera?d=(this.camera.top-this.camera.bottom)/this.camera.zoom:d=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),i.scale.set(1,1,1).multiplyScalar(d*this.size/4),i.tag==="helper"){i.visible=!1,i.name==="AXIS"?(i.visible=!!this.axis,this.axis==="X"&&(c.setFromEuler(q.set(0,0,0)),i.quaternion.copy(o).multiply(c),Math.abs(l.copy(O).applyQuaternion(o).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="Y"&&(c.setFromEuler(q.set(0,0,Math.PI/2)),i.quaternion.copy(o).multiply(c),Math.abs(l.copy(I).applyQuaternion(o).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="Z"&&(c.setFromEuler(q.set(0,Math.PI/2,0)),i.quaternion.copy(o).multiply(c),Math.abs(l.copy(Z).applyQuaternion(o).dot(this.eye))>.9&&(i.visible=!1)),this.axis==="XYZE"&&(c.setFromEuler(q.set(0,Math.PI/2,0)),l.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(st.lookAt(ot,l,I)),i.quaternion.multiply(c),i.visible=this.dragging),this.axis==="E"&&(i.visible=!1)):i.name==="START"?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):i.name==="END"?(i.position.copy(this.worldPosition),i.visible=this.dragging):i.name==="DELTA"?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),p.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),p.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(p),i.visible=this.dragging):(i.quaternion.copy(o),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=this.axis.search(i.name)!==-1));continue}i.quaternion.copy(o),this.mode==="translate"||this.mode==="scale"?(i.name==="X"&&Math.abs(l.copy(O).applyQuaternion(o).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="Y"&&Math.abs(l.copy(I).applyQuaternion(o).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="Z"&&Math.abs(l.copy(Z).applyQuaternion(o).dot(this.eye))>.99&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="XY"&&Math.abs(l.copy(Z).applyQuaternion(o).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="YZ"&&Math.abs(l.copy(O).applyQuaternion(o).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),i.name==="XZ"&&Math.abs(l.copy(I).applyQuaternion(o).dot(this.eye))<.2&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1)):this.mode==="rotate"&&(B.copy(o),l.copy(this.eye).applyQuaternion(c.copy(o).invert()),i.name.search("E")!==-1&&i.quaternion.setFromRotationMatrix(st.lookAt(this.eye,ot,I)),i.name==="X"&&(c.setFromAxisAngle(O,Math.atan2(-l.y,l.z)),c.multiplyQuaternions(B,c),i.quaternion.copy(c)),i.name==="Y"&&(c.setFromAxisAngle(I,Math.atan2(l.x,l.z)),c.multiplyQuaternions(B,c),i.quaternion.copy(c)),i.name==="Z"&&(c.setFromAxisAngle(Z,Math.atan2(l.y,l.x)),c.multiplyQuaternions(B,c),i.quaternion.copy(c))),i.visible=i.visible&&(i.name.indexOf("X")===-1||this.showX),i.visible=i.visible&&(i.name.indexOf("Y")===-1||this.showY),i.visible=i.visible&&(i.name.indexOf("Z")===-1||this.showZ),i.visible=i.visible&&(i.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),i.material._color=i.material._color||i.material.color.clone(),i.material._opacity=i.material._opacity||i.material.opacity,i.material.color.copy(i.material._color),i.material.opacity=i.material._opacity,this.enabled&&this.axis&&(i.name===this.axis||this.axis.split("").some(function(f){return i.name===f}))&&(i.material.color.setHex(16776960),i.material.opacity=1)}super.updateMatrixWorld(n)}}class Dt extends t.Mesh{constructor(){super(new t.PlaneGeometry(1e5,1e5,2,2),new t.MeshBasicMaterial({visible:!1,wireframe:!0,side:t.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(n){let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),W.copy(O).applyQuaternion(e==="local"?this.worldQuaternion:F),X.copy(I).applyQuaternion(e==="local"?this.worldQuaternion:F),Y.copy(Z).applyQuaternion(e==="local"?this.worldQuaternion:F),l.copy(X),this.mode){case"translate":case"scale":switch(this.axis){case"X":l.copy(this.eye).cross(W),b.copy(W).cross(l);break;case"Y":l.copy(this.eye).cross(X),b.copy(X).cross(l);break;case"Z":l.copy(this.eye).cross(Y),b.copy(Y).cross(l);break;case"XY":b.copy(Y);break;case"YZ":b.copy(W);break;case"XZ":l.copy(Y),b.copy(X);break;case"XYZ":case"E":b.set(0,0,0);break}break;case"rotate":default:b.set(0,0,0)}b.length()===0?this.quaternion.copy(this.cameraQuaternion):(rt.lookAt(p.set(0,0,0),b,l),this.quaternion.setFromRotationMatrix(rt)),super.updateMatrixWorld(n)}}class at{constructor(n,e){h(this,"POINTER_DRAG_THRESHOLD",.001);h(this,"name");h(this,"_canvas");h(this,"_scene");h(this,"_controller");h(this,"_pointer");h(this,"_pointerPrimaryDown");h(this,"_pointerMiddleDown");h(this,"_pointerSecondaryDown");h(this,"_lastPointerDown");h(this,"_lastPointerUp");h(this,"_raycaster");h(this,"_intersects");h(this,"_hovered");h(this,"_dragging");h(this,"_dragStart");h(this,"_dragCurrent");h(this,"_dragEnd");h(this,"_dragDelta");h(this,"_draggable");h(this,"_dragRaycastOnObjects");this.name="BaseTool",this._canvas=e.domElement,this._scene=n,this._controller=e,this._pointer=new t.Vector2,this._pointerPrimaryDown=!1,this._pointerMiddleDown=!1,this._pointerSecondaryDown=!1,this._lastPointerDown=new t.Vector2,this._lastPointerUp=new t.Vector2,this._raycaster=new t.Raycaster,this._raycaster.layers.mask=$.PRODUCT_LAYER_MASK|$.UI_LAYER_MASK,this._intersects=[],this._hovered=null,this._dragging=!1,this._dragStart=new t.Vector3,this._dragCurrent=new t.Vector3,this._dragEnd=new t.Vector3,this._dragDelta=new t.Vector3,this._draggable=null,this._dragRaycastOnObjects=null}get _pointerAnyDown(){return this._pointerPrimaryDown||this._pointerMiddleDown||this._pointerSecondaryDown}activate(){}deactivate(){}onPointerDown(n){var e;switch(n.button){case 0:{this._pointerPrimaryDown=!0;break}case 1:{this._pointerMiddleDown=!0;break}case 2:{this._pointerSecondaryDown=!0;break}default:console.warn("DIVEBaseTool.onPointerDown: Unknown button: "+n.button)}this._lastPointerDown.copy(this._pointer),this._draggable=j.findInterface((e=this._intersects[0])==null?void 0:e.object,"isDraggable")||null}onDragStart(n){this._draggable&&(this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0)),this._intersects.length!==0&&(this._dragStart.copy(this._intersects[0].point.clone()),this._dragCurrent.copy(this._intersects[0].point.clone()),this._dragEnd.copy(this._dragStart.clone()),this._dragDelta.set(0,0,0),this._draggable&&this._draggable.onDragStart&&(this._draggable.onDragStart({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._dragging=!0,this._controller.enabled=!1)))}onPointerMove(n){var o;this._pointer.x=n.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(n.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object),this._intersects=this.raycast(this._scene.children);const e=j.findInterface((o=this._intersects[0])==null?void 0:o.object,"isHoverable");if(this._intersects[0]&&e){if(!this._hovered){e.onPointerEnter&&e.onPointerEnter(this._intersects[0]),this._hovered=e;return}if(this._hovered.uuid!==e.uuid){this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),e.onPointerEnter&&e.onPointerEnter(this._intersects[0]),this._hovered=e;return}e.onPointerOver&&e.onPointerOver(this._intersects[0]),this._hovered=e}else this._hovered&&this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),this._hovered=null;this._pointerAnyDown&&(this._dragging||this.onDragStart(n),this.onDrag(n))}onDrag(n){this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0));const e=this._intersects[0];e&&(this._dragCurrent.copy(e.point.clone()),this._dragEnd.copy(e.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone()),this._draggable&&this._draggable.onDrag&&this._draggable.onDrag({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}))}onPointerUp(n){switch(this.pointerWasDragged()||this._dragging?this._draggable&&this.onDragEnd(n):this.onClick(n),n.button){case 0:this._pointerPrimaryDown=!1;break;case 1:this._pointerMiddleDown=!1;break;case 2:this._pointerSecondaryDown=!1;break}this._lastPointerUp.copy(this._pointer)}onClick(n){}onDragEnd(n){const e=this._intersects[0];e&&(this._dragEnd.copy(e.point.clone()),this._dragCurrent.copy(e.point.clone()),this._dragDelta.subVectors(this._dragCurrent.clone(),this._dragStart.clone())),this._draggable&&this._draggable.onDragEnd&&this._draggable.onDragEnd({dragStart:this._dragStart,dragCurrent:this._dragCurrent,dragEnd:this._dragEnd,dragDelta:this._dragDelta}),this._draggable=null,this._dragging=!1,this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0),this._controller.enabled=!0}onWheel(n){}raycast(n){return n!==void 0?this._raycaster.intersectObjects(n,!0).filter(e=>e.object.visible):this._raycaster.intersectObjects(this._scene.children,!0).filter(e=>e.object.visible)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>this.POINTER_DRAG_THRESHOLD}}const It=r=>r.isTransformTool!==void 0;class lt extends at{constructor(e,o){super(e,o);h(this,"isTransformTool",!0);h(this,"_scaleLinked");h(this,"_gizmo");this.name="DIVETransformTool",this._scaleLinked=!1,this._gizmo=this.initGizmo(),this._scene.add(this._gizmo)}activate(){}setGizmoMode(e){this._gizmo.mode=e}setGizmoVisible(e){const o=this._scene.children.includes(this._gizmo);e&&!o?(this._scene.add(this._gizmo),"isTransformControls"in this._gizmo&&this._gizmo.getRaycaster().layers.enableAll()):!e&&o&&(this._scene.remove(this._gizmo),"isTransformControls"in this._gizmo&&this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(e){this._scaleLinked=e}initGizmo(){const e=new bt(this._controller.object,this._controller.domElement);return e.mode="translate",e.traverse(o=>{if(!("isMesh"in o))return;const s=o.material;o.name==="X"&&s.color.set(Q.AxesColorRed),o.name==="Y"&&s.color.set(Q.AxesColorGreen),o.name==="Z"&&s.color.set(Q.AxesColorBlue),o.name==="XY"&&s.color.set(Q.AxesColorBlue),o.name==="YZ"&&s.color.set(Q.AxesColorRed),o.name==="XZ"&&s.color.set(Q.AxesColorGreen)}),e.addEventListener("mouseDown",()=>{this._controller.enabled=!1,j.implementsInterface(e.object,"isMovable")&&e.object.onMoveStart&&e.object.onMoveStart()}),e.addEventListener("objectChange",()=>{if(j.implementsInterface(e.object,"isMovable")&&e.object.onMove&&(e.object.onMove(),this._scaleLinked)){const o=e.object.scale,s=(o.x+o.y+o.z)/3;e.object.scale.set(s,s,s)}}),e.addEventListener("mouseUp",()=>{this._controller.enabled=!0,j.implementsInterface(e.object,"isMovable")&&e.object.onMoveEnd&&e.object.onMoveEnd()}),e}}const Tt=r=>r.isSelectTool!==void 0;class At extends lt{constructor(e,o){super(e,o);h(this,"isSelectTool",!0);this.name="SelectTool"}activate(){}select(e){this.attachGizmo(e),e.onSelect&&e.onSelect()}deselect(e){this.detachGizmo(),e.onDeselect&&e.onDeselect()}attachGizmo(e){if("isMovable"in e){const o=e;this._gizmo.attach(o),this.setGizmoVisible(o.visible)}}detachGizmo(){this._gizmo.detach()}onClick(e){super.onClick(e);const o=this._raycaster.intersectObjects(this._scene.root.children,!0).filter(a=>a.object.visible)[0],s=j.findInterface(o==null?void 0:o.object,"isSelectable");if(!o||!s){this._gizmo.object&&this.deselect(this._gizmo.object);return}if(this._gizmo.object){if(this._gizmo.object.uuid===s.uuid)return;this.deselect(this._gizmo.object)}this.select(s)}}exports.DIVEBaseTool=at;exports.DIVESelectTool=At;exports.DIVETransformTool=lt;exports.isSelectTool=Tt;exports.isTransformTool=It;
@@ -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-CjmCMP7P.mjs";
4
+ import { A as lt, g as ht, h as ct } from "./FileTypes-Bov2_HgT.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-8tnOn5YS.mjs";
package/build/dive.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var S=Object.defineProperty;var b=(r,i,e)=>i in r?S(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>b(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./chunks/FileTypes-DWBc6D11.cjs"),u=require("./chunks/PerspectiveCamera-Dp8ElZGj.cjs"),s=require("three"),I=require("./chunks/findInterface-C6mrvf_t.cjs"),V=require("./chunks/isFileTypeSupported-CrEqYiv9.cjs"),y=require("./chunks/network-error-CdDXil5g.cjs"),w=require("./chunks/parse-error-Dy_EE4rL.cjs"),A=require("./chunks/PovSchema-Co9FznEz.cjs");class E extends s.Object3D{constructor(e,t,o,l,a){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVERadialHandle",this.axis=e,this._color.set(a),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1;const c=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(c,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const p=new s.TorusGeometry(t,.1,3,48,o),f=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(p,f),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(l)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}function _(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function R(r,i=0){const e=_(r,+i);return _(Math.ceil(e),-i)}function O(r,i=0){const e=_(r,+i);return _(Math.floor(e),-i)}function P(r,i=0){if(r<0)return-P(-r,i);const e=_(r,+i);return _(Math.round(e),-i)}function v(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function H(r,i=0){const e=_(r,+i);return _(Math.round(e),-i).toFixed(i)}function z(r,i=0){const e=_(r,+i);return _(Math.trunc(e),-i)}function G(r){return(s.MathUtils.radToDeg(r)+360)%360}function C(r){return s.MathUtils.degToRad(r)}const x={ceilExp:R,floorExp:O,roundExp:P,toFixedExp:H,truncateExp:z,signedAngleTo:v,radToDeg:G,degToRad:C};class L extends s.Object3D{constructor(e){super();n(this,"children");n(this,"_controller");n(this,"_startRot");this.name="DIVERotateGizmo",this.children=[],this._startRot=null,this._controller=e,this.add(new E("x",1,Math.PI/2,new s.Vector3(1,0,0),h.AxesColorRed)),this.add(new E("y",1,-Math.PI/2,new s.Vector3(0,1,0),h.AxesColorGreen)),this.add(new E("z",1,Math.PI/2,new s.Vector3(0,0,1),h.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(l=>{o?l.highlight=l.axis===e&&o:l.highlight=l.axis===e&&t})}onHandleHover(e,t){this._startRot||this.parent&&this.parent.parent&&(this.parent.parent.onHover("rotate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startRot=t.rotation.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startRot||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragCurrent.clone().sub(this.parent.parent.position).normalize(),l=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=x.signedAngleTo(l,o,e.forwardVector),c=new s.Euler(this._startRot.x+e.forwardVector.x*a,this._startRot.y+e.forwardVector.y*a,this._startRot.z+e.forwardVector.z*a);this.parent.parent.onChange(void 0,c)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class m extends s.Object3D{constructor(e,t,o,l){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVEAxisHandle",this.axis=e,this._color.set(l),this._colorHover=this._color.clone().multiplyScalar(2),this._highlight=!1,this._hovered=!1;const a=new s.CylinderGeometry(.01,.01,t,13);this._lineMaterial=new s.MeshBasicMaterial({color:l,depthTest:!1,depthWrite:!1});const c=new s.Mesh(a,this._lineMaterial);c.layers.mask=u.UI_LAYER_MASK,c.renderOrder=1/0,c.rotateX(Math.PI/2),c.translateY(t/2),this.add(c);const d=new s.CylinderGeometry(.1,.1,t,3),p=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,p),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}class T extends s.Object3D{constructor(e){super();n(this,"_controller");n(this,"children");n(this,"_startPos");this.name="DIVETranslateGizmo",this.children=[],this._startPos=null,this._controller=e,this.add(new m("x",1,new s.Vector3(1,0,0),h.AxesColorRed)),this.add(new m("y",1,new s.Vector3(0,1,0),h.AxesColorGreen)),this.add(new m("z",1,new s.Vector3(0,0,1),h.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(l=>{o?l.highlight=l.axis===e&&o:l.highlight=l.axis===e&&t})}onHandleHover(e,t){this._startPos||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startPos=t.position.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startPos||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(this._startPos.clone().add(o))}onHandleDragEnd(e){this._startPos=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,l,a=.05){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");n(this,"_box");n(this,"_boxSize");this.name="DIVEScaleHandle",this.axis=e,this._color.set(l),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const c=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:l,depthTest:!1,depthWrite:!1});const d=new s.Mesh(c,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,d.rotateX(Math.PI/2),d.translateY(t/2-a/4),this.add(d),this._box=new s.Mesh(new s.BoxGeometry(a,a,a),this._lineMaterial),this._box.layers.mask=u.UI_LAYER_MASK,this._box.renderOrder=1/0,this._box.rotateX(Math.PI/2),this._box.translateY(t-a/2),this._box.rotateZ(o.x*Math.PI/2),this._box.rotateX(o.z*Math.PI/2),this.add(this._box);const p=new s.CylinderGeometry(.1,.1,t+a/2,3),f=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(p,f),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}update(e){this._box.scale.copy(new s.Vector3(1,1,1).sub(this.forwardVector).add(e.clone().multiply(this.forwardVector)))}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHoverAxis(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHoverAxis(this,!1)}onDragStart(){this.parent&&this.parent.onAxisDragStart(this)}onDrag(e){this.parent&&this.parent.onAxisDrag(this,e)}onDragEnd(){this.parent&&this.parent.onAxisDragEnd(this)}}class Y extends s.Object3D{constructor(e){super();n(this,"isHoverable",!0);n(this,"children");n(this,"_controller");n(this,"_startScale");this.name="DIVEScaleGizmo",this.children=[],this._startScale=null,this._controller=e,this.add(new D("x",1,new s.Vector3(1,0,0),h.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),h.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),h.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}update(e){this.children.forEach(t=>{t.update(e)})}handleHighlight(e,t,o){this.children.forEach(l=>{o?l.highlight=l.axis===e&&o:l.highlight=l.axis===e&&t})}onHoverAxis(e,t){this._startScale||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onAxisDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startScale=t.scale.clone(),this.handleHighlight(e.axis,!0,!0))}onAxisDrag(e,t){if(!this._startScale||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(void 0,void 0,this._startScale.clone().add(o))}onAxisDragEnd(e){this._startScale=null,this.handleHighlight(e.axis,!1,!1)}}class j extends s.Object3D{constructor(){super();n(this,"_meshX");n(this,"_meshY");n(this,"_meshZ");this.name="DIVEGizmoPlane";const e=new s.MeshBasicMaterial({transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1,side:2}),t=new s.PlaneGeometry(100,100,2,2),o=e.clone();o.color.set(16711680),this._meshX=new s.Mesh(t,o),this._meshX.layers.mask=u.UI_LAYER_MASK,this._meshX.rotateY(Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(l,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const c=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(c,d),this._meshZ.layers.mask=u.UI_LAYER_MASK}get XPlane(){return this._meshX}get YPlane(){return this._meshY}get ZPlane(){return this._meshZ}assemble(e,t){if(this.clear(),e==="translate"||e==="scale")switch(t){case"x":this.add(this._meshY),this.add(this._meshZ);break;case"y":this.add(this._meshX),this.add(this._meshZ);break;case"z":this.add(this._meshX),this.add(this._meshY);break}else if(e==="rotate")switch(t){case"x":this.add(this._meshX);break;case"y":this.add(this._meshY);break;case"z":this.add(this._meshZ);break}}}class N extends s.Object3D{constructor(e){super();n(this,"_mode");n(this,"_gizmoNode");n(this,"_translateGizmo");n(this,"_rotateGizmo");n(this,"_scaleGizmo");n(this,"_gizmoPlane");n(this,"_object");this.name="DIVEGizmo",e.addEventListener("change",()=>{const t=e.getDistance()/2.5;this.scale.set(t,t,t)}),this._mode="translate",this._gizmoNode=new s.Object3D,this.add(this._gizmoNode),this._translateGizmo=new T(e),this._rotateGizmo=new L(e),this._scaleGizmo=new Y(e),this._gizmoPlane=new j,this._gizmoPlane.visible=!1,this._object=null}get mode(){return this._mode}set mode(e){this._mode=e,this.assemble()}set debug(e){this._translateGizmo.debug=e,this._rotateGizmo.debug=e,this._scaleGizmo.debug=e}get gizmoNode(){return this._gizmoNode}get gizmoPlane(){return this._gizmoPlane}get object(){return this._object}attach(e){return this._object=e,this.assemble(),this}detach(){return this._object=null,this.assemble(),this}onHover(e,t,o){o&&this._gizmoPlane.assemble(e,t)}onChange(e,t,o){this.object!==null&&(e&&(this.position.copy(e),this.object.position.copy(e)),t&&this.object.rotation.copy(t),o&&(this.object.scale.copy(o),this._scaleGizmo.update(o)))}assemble(){this._gizmoNode.clear(),this._gizmoPlane.clear(),this._translateGizmo.reset(),this._rotateGizmo.reset(),this._scaleGizmo.reset(),this.object!==null&&(this._mode==="translate"&&this._gizmoNode.add(this._translateGizmo),this._mode==="rotate"&&this._gizmoNode.add(this._rotateGizmo),this._mode==="scale"&&this._gizmoNode.add(this._scaleGizmo),this.add(this._gizmoPlane))}}class F{constructor(){n(this,"isMovable",!0)}}class U{constructor(){n(this,"isSelectable",!0)}}function K(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const l=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,l)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,l)})}),r}function g(r,i=new WeakMap){if(r===null||typeof r!="object")return r;if(i.has(r))return i.get(r);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const a=[];i.set(r,a);for(let c=0;c<r.length;c++)a[c]=g(r[c],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[c,d]of r)a.set(g(c,i),g(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const c of r)a.add(g(c,i));return a}const e=r;if(typeof e.clone=="function"){const a=e.clone();return i.set(r,a),a}const t=Object.create(Object.getPrototypeOf(r));i.set(r,t);const o=Object.getOwnPropertyNames(r);for(const a of o){const c=Object.getOwnPropertyDescriptor(r,a);if(c)if(c.value!==void 0){const d=g(c.value,i);Object.defineProperty(t,a,{...c,value:d})}else Object.defineProperty(t,a,c)}const l=Object.getOwnPropertySymbols(r);for(const a of l){const c=Object.getOwnPropertyDescriptor(r,a);if(c)if(c.value!==void 0){const d=g(c.value,i);Object.defineProperty(t,a,{...c,value:d})}else Object.defineProperty(t,a,c)}return t}const M=(r,i)=>{if(Object.keys(r).length===0&&Object.keys(i).length===0)return{};if(typeof r!="object"||typeof i!="object")return i;let e={};return Object.keys(i).forEach(t=>{if(!Object.keys(r).includes(t)){e={...e,[t]:i[t]};return}if(Array.isArray(i[t])){if(!Array.isArray(r[t])){e={...e,[t]:i[t]};return}const o=r[t],l=i[t];if(o.length===0&&l.length===0){e={...e};return}if(o.length!==l.length){e={...e,[t]:i[t]};return}const a=[];if(l.forEach((c,d)=>{const p=M(o[d],l[d]);Object.keys(p).length&&a.push(l[d])}),Object.keys(a).length){e={...e,[t]:a};return}return}if(typeof i[t]=="object"){if(typeof r[t]!="object"){e={...e,[t]:i[t]};return}const o=M(r[t],i[t]);if(Object.keys(o).length){e={...e,[t]:o};return}}r[t]!==i[t]&&(e={...e,[t]:i[t]})}),e};function X(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function q(r){return r.entityType==="primitive"}exports.AxesColorBlue=h.AxesColorBlue;exports.AxesColorBlueLetter=h.AxesColorBlueLetter;exports.AxesColorGreen=h.AxesColorGreen;exports.AxesColorGreenLetter=h.AxesColorGreenLetter;exports.AxesColorRed=h.AxesColorRed;exports.AxesColorRedLetter=h.AxesColorRedLetter;exports.BoundingBox=h.BoundingBox;exports.DIVE=h.DIVE;exports.DIVEAmbientLight=h.DIVEAmbientLight;exports.DIVEClock=h.DIVEClock;exports.DIVEDefaultSettings=h.DIVEDefaultSettings;exports.DIVEEngine=h.DIVEEngine;exports.DIVEFloor=h.DIVEFloor;exports.DIVEGrid=h.DIVEGrid;exports.DIVEGroup=h.DIVEGroup;exports.DIVEModel=h.DIVEModel;exports.DIVENode=h.DIVENode;exports.DIVEPointLight=h.DIVEPointLight;exports.DIVEPrimitive=h.DIVEPrimitive;exports.DIVERenderPipeline=h.DIVERenderPipeline;exports.DIVERenderer=h.DIVERenderer;exports.DIVERendererDefaultSettings=h.DIVERendererDefaultSettings;exports.DIVEResizeManager=h.DIVEResizeManager;exports.DIVERoot=h.DIVERoot;exports.DIVEScene=h.DIVEScene;exports.DIVESceneDefaultSettings=h.DIVESceneDefaultSettings;exports.DIVESceneLight=h.DIVESceneLight;exports.DIVEView=h.DIVEView;exports.FILE_TYPES=h.FILE_TYPES;exports.GRID_CENTER_LINE_COLOR=h.GRID_CENTER_LINE_COLOR;exports.GRID_SIDE_LINE_COLOR=h.GRID_SIDE_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=h.SUPPORTED_FILE_TYPES;exports.findSceneRecursive=h.findSceneRecursive;exports.COORDINATE_LAYER_MASK=u.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=u.DEFAULT_LAYER_MASK;exports.DIVEPerspectiveCamera=u.DIVEPerspectiveCamera;exports.DIVEPerspectiveCameraDefaultSettings=u.DIVEPerspectiveCameraDefaultSettings;exports.HELPER_LAYER_MASK=u.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=u.PRODUCT_LAYER_MASK;exports.UI_LAYER_MASK=u.UI_LAYER_MASK;exports.findInterface=I.findInterface;exports.implementsInterface=I.implementsInterface;exports.getFileTypeFromUri=V.getFileTypeFromUri;exports.isFileTypeSupported=V.isFileTypeSupported;exports.FileContentError=y.FileContentError;exports.NetworkError=y.NetworkError;exports.FileTypeError=w.FileTypeError;exports.ParseError=w.ParseError;exports.isModelSchema=A.isModelSchema;exports.isPovSchema=A.isPovSchema;exports.DIVEGizmo=N;exports.DIVEMath=x;exports.DIVEMovable=F;exports.DIVESelectable=U;exports.applyMixins=K;exports.deepClone=g;exports.getObjectDelta=M;exports.isGroupSchema=X;exports.isLightSchema=B;exports.isPrimitiveSchema=q;
1
+ "use strict";var S=Object.defineProperty;var b=(r,i,e)=>i in r?S(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>b(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./chunks/FileTypes-BQlqpkm2.cjs"),u=require("./chunks/PerspectiveCamera-Dp8ElZGj.cjs"),s=require("three"),I=require("./chunks/findInterface-C6mrvf_t.cjs"),V=require("./chunks/isFileTypeSupported-CrEqYiv9.cjs"),y=require("./chunks/network-error-CdDXil5g.cjs"),w=require("./chunks/parse-error-Dy_EE4rL.cjs"),A=require("./chunks/PovSchema-Co9FznEz.cjs");class E extends s.Object3D{constructor(e,t,o,l,a){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVERadialHandle",this.axis=e,this._color.set(a),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1;const c=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(c,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const p=new s.TorusGeometry(t,.1,3,48,o),f=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(p,f),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(l)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}function _(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function R(r,i=0){const e=_(r,+i);return _(Math.ceil(e),-i)}function O(r,i=0){const e=_(r,+i);return _(Math.floor(e),-i)}function P(r,i=0){if(r<0)return-P(-r,i);const e=_(r,+i);return _(Math.round(e),-i)}function v(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function H(r,i=0){const e=_(r,+i);return _(Math.round(e),-i).toFixed(i)}function z(r,i=0){const e=_(r,+i);return _(Math.trunc(e),-i)}function G(r){return(s.MathUtils.radToDeg(r)+360)%360}function C(r){return s.MathUtils.degToRad(r)}const x={ceilExp:R,floorExp:O,roundExp:P,toFixedExp:H,truncateExp:z,signedAngleTo:v,radToDeg:G,degToRad:C};class L extends s.Object3D{constructor(e){super();n(this,"children");n(this,"_controller");n(this,"_startRot");this.name="DIVERotateGizmo",this.children=[],this._startRot=null,this._controller=e,this.add(new E("x",1,Math.PI/2,new s.Vector3(1,0,0),h.AxesColorRed)),this.add(new E("y",1,-Math.PI/2,new s.Vector3(0,1,0),h.AxesColorGreen)),this.add(new E("z",1,Math.PI/2,new s.Vector3(0,0,1),h.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(l=>{o?l.highlight=l.axis===e&&o:l.highlight=l.axis===e&&t})}onHandleHover(e,t){this._startRot||this.parent&&this.parent.parent&&(this.parent.parent.onHover("rotate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startRot=t.rotation.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startRot||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragCurrent.clone().sub(this.parent.parent.position).normalize(),l=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=x.signedAngleTo(l,o,e.forwardVector),c=new s.Euler(this._startRot.x+e.forwardVector.x*a,this._startRot.y+e.forwardVector.y*a,this._startRot.z+e.forwardVector.z*a);this.parent.parent.onChange(void 0,c)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class m extends s.Object3D{constructor(e,t,o,l){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");this.name="DIVEAxisHandle",this.axis=e,this._color.set(l),this._colorHover=this._color.clone().multiplyScalar(2),this._highlight=!1,this._hovered=!1;const a=new s.CylinderGeometry(.01,.01,t,13);this._lineMaterial=new s.MeshBasicMaterial({color:l,depthTest:!1,depthWrite:!1});const c=new s.Mesh(a,this._lineMaterial);c.layers.mask=u.UI_LAYER_MASK,c.renderOrder=1/0,c.rotateX(Math.PI/2),c.translateY(t/2),this.add(c);const d=new s.CylinderGeometry(.1,.1,t,3),p=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,p),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHandleHover(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHandleHover(this,!1)}onDragStart(){this.parent&&this.parent.onHandleDragStart(this)}onDrag(e){this.parent&&this.parent.onHandleDrag(this,e)}onDragEnd(){this.parent&&this.parent.onHandleDragEnd(this)}}class T extends s.Object3D{constructor(e){super();n(this,"_controller");n(this,"children");n(this,"_startPos");this.name="DIVETranslateGizmo",this.children=[],this._startPos=null,this._controller=e,this.add(new m("x",1,new s.Vector3(1,0,0),h.AxesColorRed)),this.add(new m("y",1,new s.Vector3(0,1,0),h.AxesColorGreen)),this.add(new m("z",1,new s.Vector3(0,0,1),h.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}handleHighlight(e,t,o){this.children.forEach(l=>{o?l.highlight=l.axis===e&&o:l.highlight=l.axis===e&&t})}onHandleHover(e,t){this._startPos||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onHandleDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startPos=t.position.clone(),this.handleHighlight(e.axis,!0,!0))}onHandleDrag(e,t){if(!this._startPos||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(this._startPos.clone().add(o))}onHandleDragEnd(e){this._startPos=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,l,a=.05){super();n(this,"isHoverable",!0);n(this,"isDraggable",!0);n(this,"parent",null);n(this,"axis");n(this,"_color",new s.Color(16711935));n(this,"_colorHover");n(this,"_hovered");n(this,"_highlight");n(this,"_lineMaterial");n(this,"_colliderMesh");n(this,"_box");n(this,"_boxSize");this.name="DIVEScaleHandle",this.axis=e,this._color.set(l),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const c=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:l,depthTest:!1,depthWrite:!1});const d=new s.Mesh(c,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,d.rotateX(Math.PI/2),d.translateY(t/2-a/4),this.add(d),this._box=new s.Mesh(new s.BoxGeometry(a,a,a),this._lineMaterial),this._box.layers.mask=u.UI_LAYER_MASK,this._box.renderOrder=1/0,this._box.rotateX(Math.PI/2),this._box.translateY(t-a/2),this._box.rotateZ(o.x*Math.PI/2),this._box.rotateX(o.z*Math.PI/2),this.add(this._box);const p=new s.CylinderGeometry(.1,.1,t+a/2,3),f=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(p,f),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this._colliderMesh.rotateX(Math.PI/2),this._colliderMesh.translateY(t/2),this.add(this._colliderMesh),this.rotateX(o.y*-Math.PI/2),this.rotateY(o.x*Math.PI/2)}set debug(e){this._colliderMesh.visible=e}get highlight(){return this._highlight}set highlight(e){this._highlight=e,this._lineMaterial.color=this._highlight||this._hovered?this._colorHover:this._color}get forwardVector(){return new s.Vector3(0,0,1).applyQuaternion(this.quaternion).normalize()}get rightVector(){return new s.Vector3(1,0,0).applyQuaternion(this.quaternion).normalize()}get upVector(){return new s.Vector3(0,1,0).applyQuaternion(this.quaternion).normalize()}reset(){this._lineMaterial.color=this._color}update(e){this._box.scale.copy(new s.Vector3(1,1,1).sub(this.forwardVector).add(e.clone().multiply(this.forwardVector)))}onPointerEnter(){this._hovered=!0,this.parent&&this.parent.onHoverAxis(this,!0)}onPointerLeave(){this._hovered=!1,this.parent&&this.parent.onHoverAxis(this,!1)}onDragStart(){this.parent&&this.parent.onAxisDragStart(this)}onDrag(e){this.parent&&this.parent.onAxisDrag(this,e)}onDragEnd(){this.parent&&this.parent.onAxisDragEnd(this)}}class Y extends s.Object3D{constructor(e){super();n(this,"isHoverable",!0);n(this,"children");n(this,"_controller");n(this,"_startScale");this.name="DIVEScaleGizmo",this.children=[],this._startScale=null,this._controller=e,this.add(new D("x",1,new s.Vector3(1,0,0),h.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),h.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),h.AxesColorBlue))}set debug(e){this.children.forEach(t=>{t.debug=e})}reset(){this.children.forEach(e=>{e.reset()})}update(e){this.children.forEach(t=>{t.update(e)})}handleHighlight(e,t,o){this.children.forEach(l=>{o?l.highlight=l.axis===e&&o:l.highlight=l.axis===e&&t})}onHoverAxis(e,t){this._startScale||this.parent&&this.parent.parent&&(this.parent.parent.onHover("translate",e.axis,t),this.handleHighlight(e.axis,t,!1))}onAxisDragStart(e){if(!this.parent||!this.parent.parent)return;const t=this.parent.parent.object;t&&(this._startScale=t.scale.clone(),this.handleHighlight(e.axis,!0,!0))}onAxisDrag(e,t){if(!this._startScale||!this.parent||!this.parent.parent||!("onChange"in this.parent.parent))return;const o=t.dragDelta.clone().projectOnVector(e.forwardVector);this.parent.parent.onChange(void 0,void 0,this._startScale.clone().add(o))}onAxisDragEnd(e){this._startScale=null,this.handleHighlight(e.axis,!1,!1)}}class j extends s.Object3D{constructor(){super();n(this,"_meshX");n(this,"_meshY");n(this,"_meshZ");this.name="DIVEGizmoPlane";const e=new s.MeshBasicMaterial({transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1,side:2}),t=new s.PlaneGeometry(100,100,2,2),o=e.clone();o.color.set(16711680),this._meshX=new s.Mesh(t,o),this._meshX.layers.mask=u.UI_LAYER_MASK,this._meshX.rotateY(Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(l,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const c=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(c,d),this._meshZ.layers.mask=u.UI_LAYER_MASK}get XPlane(){return this._meshX}get YPlane(){return this._meshY}get ZPlane(){return this._meshZ}assemble(e,t){if(this.clear(),e==="translate"||e==="scale")switch(t){case"x":this.add(this._meshY),this.add(this._meshZ);break;case"y":this.add(this._meshX),this.add(this._meshZ);break;case"z":this.add(this._meshX),this.add(this._meshY);break}else if(e==="rotate")switch(t){case"x":this.add(this._meshX);break;case"y":this.add(this._meshY);break;case"z":this.add(this._meshZ);break}}}class N extends s.Object3D{constructor(e){super();n(this,"_mode");n(this,"_gizmoNode");n(this,"_translateGizmo");n(this,"_rotateGizmo");n(this,"_scaleGizmo");n(this,"_gizmoPlane");n(this,"_object");this.name="DIVEGizmo",e.addEventListener("change",()=>{const t=e.getDistance()/2.5;this.scale.set(t,t,t)}),this._mode="translate",this._gizmoNode=new s.Object3D,this.add(this._gizmoNode),this._translateGizmo=new T(e),this._rotateGizmo=new L(e),this._scaleGizmo=new Y(e),this._gizmoPlane=new j,this._gizmoPlane.visible=!1,this._object=null}get mode(){return this._mode}set mode(e){this._mode=e,this.assemble()}set debug(e){this._translateGizmo.debug=e,this._rotateGizmo.debug=e,this._scaleGizmo.debug=e}get gizmoNode(){return this._gizmoNode}get gizmoPlane(){return this._gizmoPlane}get object(){return this._object}attach(e){return this._object=e,this.assemble(),this}detach(){return this._object=null,this.assemble(),this}onHover(e,t,o){o&&this._gizmoPlane.assemble(e,t)}onChange(e,t,o){this.object!==null&&(e&&(this.position.copy(e),this.object.position.copy(e)),t&&this.object.rotation.copy(t),o&&(this.object.scale.copy(o),this._scaleGizmo.update(o)))}assemble(){this._gizmoNode.clear(),this._gizmoPlane.clear(),this._translateGizmo.reset(),this._rotateGizmo.reset(),this._scaleGizmo.reset(),this.object!==null&&(this._mode==="translate"&&this._gizmoNode.add(this._translateGizmo),this._mode==="rotate"&&this._gizmoNode.add(this._rotateGizmo),this._mode==="scale"&&this._gizmoNode.add(this._scaleGizmo),this.add(this._gizmoPlane))}}class F{constructor(){n(this,"isMovable",!0)}}class U{constructor(){n(this,"isSelectable",!0)}}function K(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const l=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,l)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,l)})}),r}function g(r,i=new WeakMap){if(r===null||typeof r!="object")return r;if(i.has(r))return i.get(r);if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r)){const a=[];i.set(r,a);for(let c=0;c<r.length;c++)a[c]=g(r[c],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[c,d]of r)a.set(g(c,i),g(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const c of r)a.add(g(c,i));return a}const e=r;if(typeof e.clone=="function"){const a=e.clone();return i.set(r,a),a}const t=Object.create(Object.getPrototypeOf(r));i.set(r,t);const o=Object.getOwnPropertyNames(r);for(const a of o){const c=Object.getOwnPropertyDescriptor(r,a);if(c)if(c.value!==void 0){const d=g(c.value,i);Object.defineProperty(t,a,{...c,value:d})}else Object.defineProperty(t,a,c)}const l=Object.getOwnPropertySymbols(r);for(const a of l){const c=Object.getOwnPropertyDescriptor(r,a);if(c)if(c.value!==void 0){const d=g(c.value,i);Object.defineProperty(t,a,{...c,value:d})}else Object.defineProperty(t,a,c)}return t}const M=(r,i)=>{if(Object.keys(r).length===0&&Object.keys(i).length===0)return{};if(typeof r!="object"||typeof i!="object")return i;let e={};return Object.keys(i).forEach(t=>{if(!Object.keys(r).includes(t)){e={...e,[t]:i[t]};return}if(Array.isArray(i[t])){if(!Array.isArray(r[t])){e={...e,[t]:i[t]};return}const o=r[t],l=i[t];if(o.length===0&&l.length===0){e={...e};return}if(o.length!==l.length){e={...e,[t]:i[t]};return}const a=[];if(l.forEach((c,d)=>{const p=M(o[d],l[d]);Object.keys(p).length&&a.push(l[d])}),Object.keys(a).length){e={...e,[t]:a};return}return}if(typeof i[t]=="object"){if(typeof r[t]!="object"){e={...e,[t]:i[t]};return}const o=M(r[t],i[t]);if(Object.keys(o).length){e={...e,[t]:o};return}}r[t]!==i[t]&&(e={...e,[t]:i[t]})}),e};function X(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function q(r){return r.entityType==="primitive"}exports.AxesColorBlue=h.AxesColorBlue;exports.AxesColorBlueLetter=h.AxesColorBlueLetter;exports.AxesColorGreen=h.AxesColorGreen;exports.AxesColorGreenLetter=h.AxesColorGreenLetter;exports.AxesColorRed=h.AxesColorRed;exports.AxesColorRedLetter=h.AxesColorRedLetter;exports.BoundingBox=h.BoundingBox;exports.DIVE=h.DIVE;exports.DIVEAmbientLight=h.DIVEAmbientLight;exports.DIVEClock=h.DIVEClock;exports.DIVEDefaultSettings=h.DIVEDefaultSettings;exports.DIVEEngine=h.DIVEEngine;exports.DIVEFloor=h.DIVEFloor;exports.DIVEGrid=h.DIVEGrid;exports.DIVEGroup=h.DIVEGroup;exports.DIVEModel=h.DIVEModel;exports.DIVENode=h.DIVENode;exports.DIVEPointLight=h.DIVEPointLight;exports.DIVEPrimitive=h.DIVEPrimitive;exports.DIVERenderPipeline=h.DIVERenderPipeline;exports.DIVERenderer=h.DIVERenderer;exports.DIVERendererDefaultSettings=h.DIVERendererDefaultSettings;exports.DIVEResizeManager=h.DIVEResizeManager;exports.DIVERoot=h.DIVERoot;exports.DIVEScene=h.DIVEScene;exports.DIVESceneDefaultSettings=h.DIVESceneDefaultSettings;exports.DIVESceneLight=h.DIVESceneLight;exports.DIVEView=h.DIVEView;exports.FILE_TYPES=h.FILE_TYPES;exports.GRID_CENTER_LINE_COLOR=h.GRID_CENTER_LINE_COLOR;exports.GRID_SIDE_LINE_COLOR=h.GRID_SIDE_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=h.SUPPORTED_FILE_TYPES;exports.findSceneRecursive=h.findSceneRecursive;exports.COORDINATE_LAYER_MASK=u.COORDINATE_LAYER_MASK;exports.DEFAULT_LAYER_MASK=u.DEFAULT_LAYER_MASK;exports.DIVEPerspectiveCamera=u.DIVEPerspectiveCamera;exports.DIVEPerspectiveCameraDefaultSettings=u.DIVEPerspectiveCameraDefaultSettings;exports.HELPER_LAYER_MASK=u.HELPER_LAYER_MASK;exports.PRODUCT_LAYER_MASK=u.PRODUCT_LAYER_MASK;exports.UI_LAYER_MASK=u.UI_LAYER_MASK;exports.findInterface=I.findInterface;exports.implementsInterface=I.implementsInterface;exports.getFileTypeFromUri=V.getFileTypeFromUri;exports.isFileTypeSupported=V.isFileTypeSupported;exports.FileContentError=y.FileContentError;exports.NetworkError=y.NetworkError;exports.FileTypeError=w.FileTypeError;exports.ParseError=w.ParseError;exports.isModelSchema=A.isModelSchema;exports.isPovSchema=A.isPovSchema;exports.DIVEGizmo=N;exports.DIVEMath=x;exports.DIVEMovable=F;exports.DIVESelectable=U;exports.applyMixins=K;exports.deepClone=g;exports.getObjectDelta=M;exports.isGroupSchema=X;exports.isLightSchema=B;exports.isPrimitiveSchema=q;
package/build/dive.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  var S = Object.defineProperty;
2
2
  var A = (r, s, t) => s in r ? S(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
3
3
  var i = (r, s, t) => A(r, typeof s != "symbol" ? s + "" : s, t);
4
- import { A as I, g as P, h as V } from "./chunks/FileTypes-CjmCMP7P.mjs";
5
- import { t as ot, s as ht, r as lt, F as ct, d as dt, y as pt, j as ut, D as ft, i as _t, v as gt, w as mt, x as Et, f as Dt, B as wt, z as yt, C as Mt, m as xt, l as It, k as Pt, n as Vt, E as Ht, p as bt, o as zt, e as vt, q as Ot, I as St, G as At, u as Gt, S as Rt, H as Tt } from "./chunks/FileTypes-CjmCMP7P.mjs";
4
+ import { A as I, g as P, h as V } from "./chunks/FileTypes-Bov2_HgT.mjs";
5
+ import { t as ot, s as ht, r as lt, F as ct, d as dt, y as pt, j as ut, D as ft, i as _t, v as gt, w as mt, x as Et, f as Dt, B as wt, z as yt, C as Mt, m as xt, l as It, k as Pt, n as Vt, E as Ht, p as bt, o as zt, e as vt, q as Ot, I as St, G as At, u as Gt, S as Rt, H as Tt } from "./chunks/FileTypes-Bov2_HgT.mjs";
6
6
  import { U as d } from "./chunks/PerspectiveCamera-8tnOn5YS.mjs";
7
7
  import { C as jt, b as Ct, D as Lt, a as Nt, H as Xt, P as Ft } from "./chunks/PerspectiveCamera-8tnOn5YS.mjs";
8
8
  import { Object3D as f, Color as H, Vector3 as c, TorusGeometry as b, MeshBasicMaterial as g, Mesh as p, MathUtils as v, Euler as G, CylinderGeometry as E, BoxGeometry as R, PlaneGeometry as w } from "three";
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-DL8Fd2Vp.cjs"),w=require("../../chunks/AssetExporter-DsbC2rqv.cjs");var m=(o=>(o.AR_DESKTOP_PLATFORM_ERROR="ar-desktop-platform-error",o.AR_QUICK_LOOK_NOT_SAFARI_ERROR="ar-quicklook-not-safari-error",o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR="ar-quicklook-version-mismatch-error",o.AR_QUICK_LOOK_UNKNOWN_ERROR="ar-quicklook-unknown-error",o))(m||{});class a extends Error{constructor(r,t){super(r);l(this,"type");this.name=this.constructor.name,this.type=t,Object.setPrototypeOf(this,new.target.prototype)}}class R extends a{constructor(){super("AR features are not supported on desktop platforms.","ar-desktop-platform-error")}}class p extends a{constructor(){super("ARQuickLook on iOS is only available in Safari.","ar-quicklook-not-safari-error")}}class d extends a{constructor(e,r){super(`ARQuickLook requires iOS version ${r} or later. Current version: ${e}.`,"ar-quicklook-version-mismatch-error"),this.currentVersion=e,this.requiredVersion=r}}class u extends a{constructor(){super("An unknown ARQuickLook compatibility error occurred.","ar-quicklook-unknown-error")}}const k=12;class S{constructor(){l(this,"converter",new A.AssetConverter(new O.AssetLoader,new w.AssetExporter))}async launch(e,r){if(c.SystemInfo.getBrowser()!==c.EBrowser.SAFARI)return Promise.reject(new p);const t=c.SystemInfo.getIOSVersion();if(t&&t.major<k)return Promise.reject(new d(t.full,k));if(!t)return Promise.reject(new u);if(!c.SystemInfo.getSupportsARQuickLook())return Promise.reject(new u);const n=await this.convertToUSDZ(e,r);return this.launchARQuickLook(n,r)}async convertToUSDZ(e,r){const t=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob([t],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,r){return new Promise(t=>{(r==null?void 0:r.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",t(),n.click()})}}class _{launch(e,r){const t=self.location.toString(),n=document.createElement("a"),s=this._createParams(t,e,r),i=this._createIntent(t,e,s);n.setAttribute("href",i),n.click()}_createParams(e,r,t){const n=new URL(r,e),s=new URLSearchParams(n.search);return s.set("mode","ar_preferred"),this._applyScaleOption(s,t),this._applyPlacementOption(s,t),this._applySoundOption(s,e),this._applyLinkOption(s,e),s}_applyScaleOption(e,r){(r==null?void 0:r.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,r){(r==null?void 0:r.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,r){if(e.has("sound")){const t=new URL(e.get("sound"),r);e.set("sound",t.toString())}}_applyLinkOption(e,r){if(e.has("link")){const t=new URL(e.get("link"),r);e.set("link",t.toString())}}_createIntent(e,r,t){const n=new URL(e),s=new URL(r,e),i="#model-viewer-no-ar-fallback";return n.hash=i,`intent://arvr.google.com/scene-viewer/1.2?${t.toString()+"&file="+s.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class L{async launch(e,r){const t=c.SystemInfo.getSystem();return t===c.ESystem.IOS?new S().launch(e,r):t===c.ESystem.ANDROID?new _().launch(e,r):Promise.reject(new R)}}exports.ARDesktopPlatformError=R;exports.ARError=a;exports.ARQuickLook=S;exports.ARQuickLookNotSafariError=p;exports.ARQuickLookUnknownError=u;exports.ARQuickLookVersionMismatchError=d;exports.ARSystem=L;exports.EARErrorType=m;exports.SceneViewer=_;
1
+ "use strict";var f=Object.defineProperty;var h=(o,e,r)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r;var l=(o,e,r)=>h(o,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../systeminfo/index.cjs"),A=require("../assetconverter/index.cjs"),O=require("../../chunks/AssetLoader-DtpL2Rvh.cjs"),w=require("../../chunks/AssetExporter-DsbC2rqv.cjs");var m=(o=>(o.AR_DESKTOP_PLATFORM_ERROR="ar-desktop-platform-error",o.AR_QUICK_LOOK_NOT_SAFARI_ERROR="ar-quicklook-not-safari-error",o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR="ar-quicklook-version-mismatch-error",o.AR_QUICK_LOOK_UNKNOWN_ERROR="ar-quicklook-unknown-error",o))(m||{});class a extends Error{constructor(r,t){super(r);l(this,"type");this.name=this.constructor.name,this.type=t,Object.setPrototypeOf(this,new.target.prototype)}}class R extends a{constructor(){super("AR features are not supported on desktop platforms.","ar-desktop-platform-error")}}class p extends a{constructor(){super("ARQuickLook on iOS is only available in Safari.","ar-quicklook-not-safari-error")}}class d extends a{constructor(e,r){super(`ARQuickLook requires iOS version ${r} or later. Current version: ${e}.`,"ar-quicklook-version-mismatch-error"),this.currentVersion=e,this.requiredVersion=r}}class u extends a{constructor(){super("An unknown ARQuickLook compatibility error occurred.","ar-quicklook-unknown-error")}}const k=12;class S{constructor(){l(this,"converter",new A.AssetConverter(new O.AssetLoader,new w.AssetExporter))}async launch(e,r){if(c.SystemInfo.getBrowser()!==c.EBrowser.SAFARI)return Promise.reject(new p);const t=c.SystemInfo.getIOSVersion();if(t&&t.major<k)return Promise.reject(new d(t.full,k));if(!t)return Promise.reject(new u);if(!c.SystemInfo.getSupportsARQuickLook())return Promise.reject(new u);const n=await this.convertToUSDZ(e,r);return this.launchARQuickLook(n,r)}async convertToUSDZ(e,r){const t=await this.converter.convert(e).to("usdz",{quickLookCompatible:!0,ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}}}),n=new Blob([t],{type:"model/vnd.usdz+zip"});return URL.createObjectURL(n)}launchARQuickLook(e,r){return new Promise(t=>{(r==null?void 0:r.arScale)==="fixed"&&(e=e.concat("#allowsContentScaling=0"));const n=document.createElement("a");n.innerHTML="<picture></picture>",n.rel="ar",n.href=e,n.download="scene.usdz",t(),n.click()})}}class _{launch(e,r){const t=self.location.toString(),n=document.createElement("a"),s=this._createParams(t,e,r),i=this._createIntent(t,e,s);n.setAttribute("href",i),n.click()}_createParams(e,r,t){const n=new URL(r,e),s=new URLSearchParams(n.search);return s.set("mode","ar_preferred"),this._applyScaleOption(s,t),this._applyPlacementOption(s,t),this._applySoundOption(s,e),this._applyLinkOption(s,e),s}_applyScaleOption(e,r){(r==null?void 0:r.arScale)==="fixed"&&e.set("resizable","false")}_applyPlacementOption(e,r){(r==null?void 0:r.arPlacement)==="vertical"&&e.set("enable_vertical_placement","true")}_applySoundOption(e,r){if(e.has("sound")){const t=new URL(e.get("sound"),r);e.set("sound",t.toString())}}_applyLinkOption(e,r){if(e.has("link")){const t=new URL(e.get("link"),r);e.set("link",t.toString())}}_createIntent(e,r,t){const n=new URL(e),s=new URL(r,e),i="#model-viewer-no-ar-fallback";return n.hash=i,`intent://arvr.google.com/scene-viewer/1.2?${t.toString()+"&file="+s.toString()}#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(n.toString())};end;`}}class L{async launch(e,r){const t=c.SystemInfo.getSystem();return t===c.ESystem.IOS?new S().launch(e,r):t===c.ESystem.ANDROID?new _().launch(e,r):Promise.reject(new R)}}exports.ARDesktopPlatformError=R;exports.ARError=a;exports.ARQuickLook=S;exports.ARQuickLookNotSafariError=p;exports.ARQuickLookUnknownError=u;exports.ARQuickLookVersionMismatchError=d;exports.ARSystem=L;exports.EARErrorType=m;exports.SceneViewer=_;
@@ -3,7 +3,7 @@ var R = (o, e, r) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writab
3
3
  var l = (o, e, r) => R(o, typeof e != "symbol" ? e + "" : e, r);
4
4
  import { SystemInfo as c, EBrowser as d, ESystem as u } from "../systeminfo/index.mjs";
5
5
  import { AssetConverter as h } from "../assetconverter/index.mjs";
6
- import { A as _ } from "../../chunks/AssetLoader-DCLXUeFD.mjs";
6
+ import { A as _ } from "../../chunks/AssetLoader-BMBH74ql.mjs";
7
7
  import { A as f } from "../../chunks/AssetExporter-brT7ogoM.mjs";
8
8
  var S = /* @__PURE__ */ ((o) => (o.AR_DESKTOP_PLATFORM_ERROR = "ar-desktop-platform-error", o.AR_QUICK_LOOK_NOT_SAFARI_ERROR = "ar-quicklook-not-safari-error", o.AR_QUICK_LOOK_VERSION_MISMATCH_ERROR = "ar-quicklook-version-mismatch-error", o.AR_QUICK_LOOK_UNKNOWN_ERROR = "ar-quicklook-unknown-error", o))(S || {});
9
9
  class a extends Error {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-udwfFvkY.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-D1_YD57U.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
@@ -1,4 +1,4 @@
1
- import { A as e, C } from "../../chunks/AssetCache-B-m6VZSR.mjs";
1
+ import { A as e, C } from "../../chunks/AssetCache-CZF_bKOU.mjs";
2
2
  export {
3
3
  e as AssetCache,
4
4
  C as Chunk
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-DL8Fd2Vp.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetLoader-DtpL2Rvh.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
@@ -1,4 +1,4 @@
1
- import { A as o, a as e, D as s } from "../../chunks/AssetLoader-DCLXUeFD.mjs";
1
+ import { A as o, a as e, D as s } from "../../chunks/AssetLoader-BMBH74ql.mjs";
2
2
  export {
3
3
  o as AssetLoader,
4
4
  e as DRACOWorker,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-DWBc6D11.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-BQlqpkm2.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
@@ -1,4 +1,4 @@
1
- import { a as o, O as e } from "../../chunks/FileTypes-CjmCMP7P.mjs";
1
+ import { a as o, O as e } from "../../chunks/FileTypes-Bov2_HgT.mjs";
2
2
  export {
3
3
  o as OrbitController,
4
4
  e as OrbitControllerDefaultSettings
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/FileTypes-DWBc6D11.cjs");exports.OrientationDisplay=e.OrientationDisplay;exports.OrientationDisplayAxes=e.OrientationDisplayAxes;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/FileTypes-BQlqpkm2.cjs");exports.OrientationDisplay=e.OrientationDisplay;exports.OrientationDisplayAxes=e.OrientationDisplayAxes;
@@ -1,4 +1,4 @@
1
- import { b as s, c as t } from "../../chunks/FileTypes-CjmCMP7P.mjs";
1
+ import { b as s, c as t } from "../../chunks/FileTypes-Bov2_HgT.mjs";
2
2
  export {
3
3
  s as OrientationDisplay,
4
4
  t as OrientationDisplayAxes
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-DWBc6D11.cjs");require("three");const a={...t.DIVEDefaultSettings,lightIntensity:1},l=async(r,i)=>{const e=new t.DIVE(i);e.mainView.camera.position.set(0,1,2);const o=new t.DIVESceneLight;o.setIntensity((i==null?void 0:i.lightIntensity)??1),e.scene.root.add(o);const c=await new t.DIVEModel().setFromURL(r);e.scene.root.add(c);const n=new t.OrbitController(e.mainView.camera,e.mainView.canvas);return n.focusObject(c),e.clock.addTicker(n),Object.assign(e,{orbitController:n})};exports.QuickView=l;exports.QuickViewDefaultSettings=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-BQlqpkm2.cjs");require("three");const a={...t.DIVEDefaultSettings,lightIntensity:1},l=async(r,i)=>{const e=new t.DIVE(i);e.mainView.camera.position.set(0,1,2);const c=new t.DIVESceneLight;c.setIntensity((i==null?void 0:i.lightIntensity)??1),e.scene.root.add(c);const n=await new t.DIVEModel().setFromURL(r);e.scene.root.add(n),n.placeOnFloor();const o=new t.OrbitController(e.mainView.camera,e.mainView.canvas);return o.focusObject(n),e.clock.addTicker(o),Object.assign(e,{orbitController:o})};exports.QuickView=l;exports.QuickViewDefaultSettings=a;
@@ -1,4 +1,4 @@
1
- import { D as c, d as r, e as s, f as l, a as d } from "../../chunks/FileTypes-CjmCMP7P.mjs";
1
+ import { D as c, d as r, e as s, f as l, a as d } from "../../chunks/FileTypes-Bov2_HgT.mjs";
2
2
  import "three";
3
3
  const V = {
4
4
  ...c,
@@ -6,15 +6,15 @@ const V = {
6
6
  }, D = async (i, t) => {
7
7
  const e = new r(t);
8
8
  e.mainView.camera.position.set(0, 1, 2);
9
- const o = new s();
10
- o.setIntensity((t == null ? void 0 : t.lightIntensity) ?? 1), e.scene.root.add(o);
11
- const a = await new l().setFromURL(i);
12
- e.scene.root.add(a);
9
+ const a = new s();
10
+ a.setIntensity((t == null ? void 0 : t.lightIntensity) ?? 1), e.scene.root.add(a);
11
+ const o = await new l().setFromURL(i);
12
+ e.scene.root.add(o), o.placeOnFloor();
13
13
  const n = new d(
14
14
  e.mainView.camera,
15
15
  e.mainView.canvas
16
16
  );
17
- return n.focusObject(a), e.clock.addTicker(n), Object.assign(e, { orbitController: n });
17
+ return n.focusObject(o), e.clock.addTicker(n), Object.assign(e, { orbitController: n });
18
18
  };
19
19
  export {
20
20
  D as QuickView,
@@ -1,4 +1,4 @@
1
- "use strict";var $d=Object.defineProperty;var Hd=(d,g,o)=>g in d?$d(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var fn=(d,g,o)=>Hd(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qd=require("three"),zd=require("../../chunks/FileTypes-DWBc6D11.cjs"),Mi=require("../../chunks/PovSchema-Co9FznEz.cjs"),vo=require("../../chunks/SelectTool-204u2Sqa.cjs"),wo={};function G(d,g){wo[d]=g}function Ao(d){return wo[d]}class W{constructor(g,o){fn(this,"_payload");fn(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends W{constructor(E,$){super(E,$);fn(this,"_description",g);fn(this,"_payload");this._payload=E}execute(){return o(this._payload,this._dependencies)}}}}const xo=W.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(d,{getARSystem:g})=>g().then(o=>{o.launch(d.uri,d.options)})});G("LAUNCH_AR",xo);const Eo=W.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new zd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",Eo);const mo=W.define({description:"Gets the current camera position and target.",execute:(d,{controller:g})=>({position:g.object.position.clone(),target:g.target.clone()})});G("GET_CAMERA_TRANSFORM",mo);const So=W.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:E})=>{let $={x:0,y:0,z:0},q={x:0,y:0,z:0};if("id"in d){const Y=o.get(d.id);if(!Y)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Mi.isPovSchema(Y))throw new Error(`Object with id ${d.id} is not a POV. Object: ${Y}`);$=Y.position,q=Y.target}else $=d.position,q=d.target;const X=await S().then(Y=>{E.clock.hasTicker(Y)||E.clock.addTicker(Y),g.enabled=!0;const sr=Y.animate(g.object.position,$,d.duration,{easing:Y.TWEEN.Easing.Quadratic.Out}).play(),ve=Y.animate(g.target,q,d.duration,{easing:Y.TWEEN.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}}).play();return[sr,ve]});return{stop:()=>X.forEach(Y=>Y.stop())}}});G("MOVE_CAMERA",So);const bo=W.define({description:"Sets the camera layer to a certain layer.",execute:(d,{controller:g})=>{"setCameraLayer"in g.object&&g.object.setCameraLayer(d.layer)}});G("SET_CAMERA_LAYER",bo);const Oo=W.define({description:"Sets the camera position and target.",execute:(d,{controller:g})=>{g.object.position.copy(d.position),g.target.copy(d.target),g.update()}});G("SET_CAMERA_TRANSFORM",Oo);const To=W.define({description:"Zooms the camera in or out by a certain amount.",execute:(d,{controller:g})=>{d.direction==="IN"&&g.zoomIn(d.by),d.direction==="OUT"&&g.zoomOut(d.by)}});G("ZOOM_CAMERA",To);const Co=W.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(d,{registered:g,getMediaCreator:o})=>{const S=await o();if("id"in d){const E=g.get(d.id);if(!E)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Mi.isPovSchema(E))throw new Error(`Object with id ${d.id} is not a POV. Object: ${E}`);const{resolution:$}=d,{position:q,target:X}=E;return S.generateMedia({position:q,target:X,resolution:$})}return S.generateMedia(d)}});G("GENERATE_MEDIA",Co);const Io=W.define({description:"Adds an object to the scene.",execute:(d,{engine:g,registered:o})=>{o.get(d.id)||(d.parentId===void 0&&(d.parentId=null),o.set(d.id,d),g.scene.root.addSceneObject(d))}});G("ADD_OBJECT",Io);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},at={exports:{}};/**
1
+ "use strict";var $d=Object.defineProperty;var Hd=(d,g,o)=>g in d?$d(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var fn=(d,g,o)=>Hd(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qd=require("three"),zd=require("../../chunks/FileTypes-BQlqpkm2.cjs"),Mi=require("../../chunks/PovSchema-Co9FznEz.cjs"),vo=require("../../chunks/SelectTool-BZVnTJYv.cjs"),wo={};function G(d,g){wo[d]=g}function Ao(d){return wo[d]}class W{constructor(g,o){fn(this,"_payload");fn(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends W{constructor(E,$){super(E,$);fn(this,"_description",g);fn(this,"_payload");this._payload=E}execute(){return o(this._payload,this._dependencies)}}}}const xo=W.define({description:"Launches AR mode in native capabilities. (iOS: AR Quick Look, Android: Google Scene Viewer)",execute:async(d,{getARSystem:g})=>g().then(o=>{o.launch(d.uri,d.options)})});G("LAUNCH_AR",xo);const Eo=W.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new zd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",Eo);const mo=W.define({description:"Gets the current camera position and target.",execute:(d,{controller:g})=>({position:g.object.position.clone(),target:g.target.clone()})});G("GET_CAMERA_TRANSFORM",mo);const So=W.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:E})=>{let $={x:0,y:0,z:0},q={x:0,y:0,z:0};if("id"in d){const Y=o.get(d.id);if(!Y)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Mi.isPovSchema(Y))throw new Error(`Object with id ${d.id} is not a POV. Object: ${Y}`);$=Y.position,q=Y.target}else $=d.position,q=d.target;const X=await S().then(Y=>{E.clock.hasTicker(Y)||E.clock.addTicker(Y),g.enabled=!0;const sr=Y.animate(g.object.position,$,d.duration,{easing:Y.TWEEN.Easing.Quadratic.Out}).play(),ve=Y.animate(g.target,q,d.duration,{easing:Y.TWEEN.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}}).play();return[sr,ve]});return{stop:()=>X.forEach(Y=>Y.stop())}}});G("MOVE_CAMERA",So);const bo=W.define({description:"Sets the camera layer to a certain layer.",execute:(d,{controller:g})=>{"setCameraLayer"in g.object&&g.object.setCameraLayer(d.layer)}});G("SET_CAMERA_LAYER",bo);const Oo=W.define({description:"Sets the camera position and target.",execute:(d,{controller:g})=>{g.object.position.copy(d.position),g.target.copy(d.target),g.update()}});G("SET_CAMERA_TRANSFORM",Oo);const To=W.define({description:"Zooms the camera in or out by a certain amount.",execute:(d,{controller:g})=>{d.direction==="IN"&&g.zoomIn(d.by),d.direction==="OUT"&&g.zoomOut(d.by)}});G("ZOOM_CAMERA",To);const Co=W.define({description:"Generates a screenshot, stores it in a Blob and returns a Promise of a valid URI.",execute:async(d,{registered:g,getMediaCreator:o})=>{const S=await o();if("id"in d){const E=g.get(d.id);if(!E)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Mi.isPovSchema(E))throw new Error(`Object with id ${d.id} is not a POV. Object: ${E}`);const{resolution:$}=d,{position:q,target:X}=E;return S.generateMedia({position:q,target:X,resolution:$})}return S.generateMedia(d)}});G("GENERATE_MEDIA",Co);const Io=W.define({description:"Adds an object to the scene.",execute:(d,{engine:g,registered:o})=>{o.get(d.id)||(d.parentId===void 0&&(d.parentId=null),o.set(d.id,d),g.scene.root.addSceneObject(d))}});G("ADD_OBJECT",Io);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},at={exports:{}};/**
2
2
  * @license
3
3
  * Lodash <https://lodash.com/>
4
4
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -2,9 +2,9 @@ var _d = Object.defineProperty;
2
2
  var dd = (d, g, o) => g in d ? _d(d, g, { enumerable: !0, configurable: !0, writable: !0, value: o }) : d[g] = o;
3
3
  var fn = (d, g, o) => dd(d, typeof g != "symbol" ? g + "" : g, o);
4
4
  import { MathUtils as pd } from "three";
5
- import { F as vd } from "../../chunks/FileTypes-CjmCMP7P.mjs";
5
+ import { F as vd } from "../../chunks/FileTypes-Bov2_HgT.mjs";
6
6
  import { a as _o, i as wd } from "../../chunks/PovSchema-DWWvr_ED.mjs";
7
- import { i as po } from "../../chunks/SelectTool-aH-q193I.mjs";
7
+ import { i as po } from "../../chunks/SelectTool-DDFLa3rP.mjs";
8
8
  const vo = {};
9
9
  function N(d, g) {
10
10
  vo[d] = g;
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var r=(t,e,o)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var l=(t,e,o)=>r(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../chunks/SelectTool-204u2Sqa.cjs");class i{constructor(e,o){l(this,"_scene");l(this,"_controller");l(this,"_activeTool");l(this,"_selectTool");this._scene=e,this._controller=o,this._selectTool=null,this._activeTool=null}get selectTool(){return this._selectTool||(this._selectTool=new n.DIVESelectTool(this._scene,this._controller)),this._selectTool}dispose(){this.removeEventListeners()}getActiveTool(){return this._activeTool}useTool(e){var o;switch((o=this._activeTool)==null||o.deactivate(),e){case"select":{this.addEventListeners(),this.selectTool.activate(),this._activeTool=this.selectTool;break}case"none":{this.removeEventListeners(),this._activeTool=null;break}default:console.warn(`DIVEToolBox.useTool: Unknown tool: ${e}`)}}setGizmoMode(e){this.selectTool.setGizmoMode(e)}setGizmoVisible(e){this.selectTool.setGizmoVisible(e)}setGizmoScaleLinked(e){this.selectTool.setGizmoScaleLinked(e)}onPointerMove(e){var o;(o=this._activeTool)==null||o.onPointerMove(e)}onPointerDown(e){var o;(o=this._activeTool)==null||o.onPointerDown(e)}onPointerUp(e){var o;(o=this._activeTool)==null||o.onPointerUp(e)}onWheel(e){var o;(o=this._activeTool)==null||o.onWheel(e)}addEventListeners(){this._controller.domElement.addEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.addEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.addEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.addEventListener("wheel",e=>this.onWheel(e))}removeEventListeners(){this._controller.domElement.removeEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.removeEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.removeEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.removeEventListener("wheel",e=>this.onWheel(e))}}l(i,"DefaultTool","select");exports.DIVEBaseTool=n.DIVEBaseTool;exports.DIVESelectTool=n.DIVESelectTool;exports.DIVETransformTool=n.DIVETransformTool;exports.isSelectTool=n.isSelectTool;exports.isTransformTool=n.isTransformTool;exports.Toolbox=i;
1
+ "use strict";var s=Object.defineProperty;var r=(t,e,o)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var l=(t,e,o)=>r(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../chunks/SelectTool-BZVnTJYv.cjs");class i{constructor(e,o){l(this,"_scene");l(this,"_controller");l(this,"_activeTool");l(this,"_selectTool");this._scene=e,this._controller=o,this._selectTool=null,this._activeTool=null}get selectTool(){return this._selectTool||(this._selectTool=new n.DIVESelectTool(this._scene,this._controller)),this._selectTool}dispose(){this.removeEventListeners()}getActiveTool(){return this._activeTool}useTool(e){var o;switch((o=this._activeTool)==null||o.deactivate(),e){case"select":{this.addEventListeners(),this.selectTool.activate(),this._activeTool=this.selectTool;break}case"none":{this.removeEventListeners(),this._activeTool=null;break}default:console.warn(`DIVEToolBox.useTool: Unknown tool: ${e}`)}}setGizmoMode(e){this.selectTool.setGizmoMode(e)}setGizmoVisible(e){this.selectTool.setGizmoVisible(e)}setGizmoScaleLinked(e){this.selectTool.setGizmoScaleLinked(e)}onPointerMove(e){var o;(o=this._activeTool)==null||o.onPointerMove(e)}onPointerDown(e){var o;(o=this._activeTool)==null||o.onPointerDown(e)}onPointerUp(e){var o;(o=this._activeTool)==null||o.onPointerUp(e)}onWheel(e){var o;(o=this._activeTool)==null||o.onWheel(e)}addEventListeners(){this._controller.domElement.addEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.addEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.addEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.addEventListener("wheel",e=>this.onWheel(e))}removeEventListeners(){this._controller.domElement.removeEventListener("pointermove",e=>this.onPointerMove(e)),this._controller.domElement.removeEventListener("pointerdown",e=>this.onPointerDown(e)),this._controller.domElement.removeEventListener("pointerup",e=>this.onPointerUp(e)),this._controller.domElement.removeEventListener("wheel",e=>this.onWheel(e))}}l(i,"DefaultTool","select");exports.DIVEBaseTool=n.DIVEBaseTool;exports.DIVESelectTool=n.DIVESelectTool;exports.DIVETransformTool=n.DIVETransformTool;exports.isSelectTool=n.isSelectTool;exports.isTransformTool=n.isTransformTool;exports.Toolbox=i;
@@ -1,8 +1,8 @@
1
1
  var i = Object.defineProperty;
2
2
  var s = (t, e, o) => e in t ? i(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
3
  var n = (t, e, o) => s(t, typeof e != "symbol" ? e + "" : e, o);
4
- import { D as l } from "../../chunks/SelectTool-aH-q193I.mjs";
5
- import { a as m, c as T, i as d, b as _ } from "../../chunks/SelectTool-aH-q193I.mjs";
4
+ import { D as l } from "../../chunks/SelectTool-DDFLa3rP.mjs";
5
+ import { a as m, c as T, i as d, b as _ } from "../../chunks/SelectTool-DDFLa3rP.mjs";
6
6
  class r {
7
7
  constructor(e, o) {
8
8
  n(this, "_scene");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "build/dive.cjs",