@shopware-ag/dive 2.3.0 → 2.3.1

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 (31) hide show
  1. package/build/chunks/{AssetCache-p0Zr71Yh.mjs → AssetCache-BN-AmXc9.mjs} +1 -1
  2. package/build/chunks/{AssetCache-BZhTsybC.cjs → AssetCache-CwK-0iP9.cjs} +1 -1
  3. package/build/chunks/{AssetLoader-Dcr75VNw.mjs → AssetLoader-C-PfRr8Z.mjs} +3 -3
  4. package/build/chunks/{AssetLoader-Drtmvqgs.cjs → AssetLoader-uFMzuJWt.cjs} +1 -1
  5. package/build/chunks/{ClipAnimator-BL9qzfWl.mjs → ClipAnimator-BJZ4_C4B.mjs} +1 -1
  6. package/build/chunks/{ClipAnimator-BcDOC3qJ.cjs → ClipAnimator-CNKeT7rW.cjs} +1 -1
  7. package/build/chunks/{FileTypes-BSG8CC2s.mjs → FileTypes-B8g1qxjR.mjs} +1 -1
  8. package/build/chunks/{FileTypes-35x8Ekp6.cjs → FileTypes-BHH0KUFf.cjs} +1 -1
  9. package/build/chunks/{isFileTypeSupported-BmjxgShb.cjs → isFileTypeSupported-CFN9V48s.cjs} +1 -1
  10. package/build/chunks/{isFileTypeSupported-DBPOEmTI.mjs → isFileTypeSupported-DA7cjOZa.mjs} +1 -1
  11. package/build/dive.cjs +1 -1
  12. package/build/dive.mjs +2 -2
  13. package/build/plugins/animation/index.cjs +1 -1
  14. package/build/plugins/animation/index.mjs +1 -1
  15. package/build/plugins/ar/index.cjs +1 -1
  16. package/build/plugins/ar/index.mjs +1 -1
  17. package/build/plugins/assetcache/index.cjs +1 -1
  18. package/build/plugins/assetcache/index.mjs +1 -1
  19. package/build/plugins/assetloader/index.cjs +1 -1
  20. package/build/plugins/assetloader/index.mjs +2 -2
  21. package/build/plugins/orbitcontroller/index.cjs +1 -1
  22. package/build/plugins/orbitcontroller/index.mjs +1 -1
  23. package/build/plugins/orientationdisplay/index.cjs +1 -1
  24. package/build/plugins/orientationdisplay/index.mjs +1 -1
  25. package/build/plugins/quickview/index.cjs +1 -1
  26. package/build/plugins/quickview/index.mjs +1 -1
  27. package/build/plugins/state/index.cjs +1 -1
  28. package/build/plugins/state/index.mjs +1 -1
  29. package/build/plugins/toolbox/index.cjs +1 -1
  30. package/build/plugins/toolbox/index.mjs +1 -1
  31. 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-BSG8CC2s.mjs";
4
+ import "./FileTypes-B8g1qxjR.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-35x8Ekp6.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-BHH0KUFf.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 je = (d, e, t) => e in d ? Be(d, e, { enumerable: !0, configurable: !0, writ
3
3
  var O = (d, e, t) => je(d, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { TrianglesDrawMode as Ke, TriangleFanDrawMode as ie, TriangleStripDrawMode as Ie, Loader as le, LoaderUtils as z, FileLoader as W, MeshPhysicalMaterial as P, Vector2 as Y, Color as G, LinearSRGBColorSpace as k, SRGBColorSpace as D, SpotLight as We, PointLight as Ve, DirectionalLight as Xe, Matrix4 as J, Vector3 as j, Quaternion as Ce, InstancedMesh as ze, InstancedBufferAttribute as qe, Object3D as ue, TextureLoader as Ne, ImageBitmapLoader as Ye, BufferAttribute as N, InterleavedBuffer as Je, InterleavedBufferAttribute as Qe, LinearMipmapLinearFilter as Oe, NearestMipmapLinearFilter as Ze, LinearMipmapNearestFilter as $e, NearestMipmapNearestFilter as et, LinearFilter as De, NearestFilter as tt, RepeatWrapping as Q, MirroredRepeatWrapping as ke, ClampToEdgeWrapping as Pe, PointsMaterial as nt, Material as ee, LineBasicMaterial as st, MeshStandardMaterial as fe, DoubleSide as rt, MeshBasicMaterial as X, PropertyBinding as ot, BufferGeometry as Z, SkinnedMesh as it, Mesh as de, LineSegments as at, Line as ct, LineLoop as lt, Points as ut, Group as B, PerspectiveCamera as ft, MathUtils as dt, OrthographicCamera as ht, Skeleton as pt, AnimationClip as mt, Bone as gt, InterpolateDiscrete as At, InterpolateLinear as Fe, Texture as me, VectorKeyframeTrack as ge, NumberKeyframeTrack as Ae, QuaternionKeyframeTrack as Te, ColorManagement as _e, FrontSide as Tt, Interpolant as _t, Box3 as yt, Sphere as wt, NoColorSpace as H } from "three";
5
5
  import { u as Rt, a as ye } from "./fflate.module-xyO_T3Zm.mjs";
6
- import { S as xt } from "./FileTypes-BSG8CC2s.mjs";
7
- import { g as Et, i as St } from "./isFileTypeSupported-DBPOEmTI.mjs";
6
+ import { S as xt } from "./FileTypes-B8g1qxjR.mjs";
7
+ import { g as Et, i as St } from "./isFileTypeSupported-DA7cjOZa.mjs";
8
8
  import { F as we, P as Re } from "./parse-error-DfOPyLWM.mjs";
9
- import { A as q } from "./AssetCache-p0Zr71Yh.mjs";
9
+ import { A as q } from "./AssetCache-BN-AmXc9.mjs";
10
10
  function xe(d, e) {
11
11
  if (e === Ke)
12
12
  return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), d;
@@ -1,4 +1,4 @@
1
- "use strict";var ue=Object.defineProperty;var fe=(h,e,t)=>e in h?ue(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var O=(h,e,t)=>fe(h,typeof e!="symbol"?e+"":e,t);const f=require("three"),H=require("./fflate.module-DHdJvhNh.cjs"),de=require("./FileTypes-35x8Ekp6.cjs"),Q=require("./isFileTypeSupported-BmjxgShb.cjs"),U=require("./parse-error-Dy_EE4rL.cjs"),B=require("./AssetCache-BZhTsybC.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 s=[],i=h.getAttribute("position");if(i!==void 0){for(let a=0;a<i.count;a++)s.push(a);h.setIndex(s),t=h.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),h}const r=t.count-2,n=[];if(e===f.TriangleFanDrawMode)for(let s=1;s<=r;s++)n.push(t.getX(0)),n.push(t.getX(s)),n.push(t.getX(s+1));else for(let s=0;s<r;s++)s%2===0?(n.push(t.getX(s)),n.push(t.getX(s+1)),n.push(t.getX(s+2))):(n.push(t.getX(s+2)),n.push(t.getX(s+1)),n.push(t.getX(s)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=h.clone();return o.setIndex(n),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),h}class he extends f.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Te(t)}),this.register(function(t){return new be(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new ye(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new Ae(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new _e(t)}),this.register(function(t){return new Le(t)}),this.register(function(t){return new Ee(t)}),this.register(function(t){return new me(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new Ne(t)})}load(e,t,r,n){const o=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const c=f.LoaderUtils.extractUrlBase(e);s=f.LoaderUtils.resolveURL(c,this.path)}else s=f.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const i=function(c){n?n(c):console.error(c),o.manager.itemError(e),o.manager.itemEnd(e)},a=new f.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{o.parse(c,s,function(l){t(l),o.manager.itemEnd(e)},i)}catch(l){i(l)}},r,i)}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,r,n){let o;const s={},i={},a=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===re){try{s[b.KHR_BINARY_GLTF]=new Oe(e)}catch(u){n&&n(u);return}o=JSON.parse(s[b.KHR_BINARY_GLTF].content)}else o=JSON.parse(a.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Ve(o,{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"),i[u.name]=u,s[u.name]=!0}if(o.extensionsUsed)for(let l=0;l<o.extensionsUsed.length;++l){const u=o.extensionsUsed[l],d=o.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:s[u]=new ge;break;case b.KHR_DRACO_MESH_COMPRESSION:s[u]=new De(o,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:s[u]=new Pe;break;case b.KHR_MESH_QUANTIZATION:s[u]=new ke;break;default:d.indexOf(u)>=0&&i[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(i),c.parse(r,n)}parseAsync(e,t){const r=this;return new Promise(function(n,o){r.parse(e,t,n,o)})}}function pe(){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 me{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 r=0,n=t.length;r<n;r++){const o=t[r];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let n=t.cache.get(r);if(n)return n;const o=t.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let c;const l=new f.Color(16777215);a.color!==void 0&&l.setRGB(a.color[0],a.color[1],a.color[2],f.LinearSRGBColorSpace);const u=a.range!==void 0?a.range:0;switch(a.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,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return c.position.set(0,0,0),c.decay=2,P(c,a),a.intensity!==void 0&&(c.intensity=a.intensity),c.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(c),t.cache.add(r,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,o=r.json.nodes[e],i=(o.extensions&&o.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(a){return r._getNodeRef(t.cache,i,a)})}}class ge{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return f.MeshBasicMaterial}extendParams(e,t,r){const n=[];e.color=new f.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const s=o.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],f.LinearSRGBColorSpace),e.opacity=s[3]}o.baseColorTexture!==void 0&&n.push(r.assignTexture(e,"map",o.baseColorTexture,f.SRGBColorSpace))}return Promise.all(n)}}class Ae{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class Te{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&o.push(r.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&o.push(r.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(o.push(r.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f.Vector2(i,i)}return Promise.all(o)}}class _e{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&o.push(r.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&o.push(r.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(o)}}class ye{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new f.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=n.extensions[this.name];if(s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],f.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&o.push(r.assignTexture(t,"sheenColorMap",s.sheenColorTexture,f.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&o.push(r.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(o)}}class Re{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&o.push(r.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(o)}}class we{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&o.push(r.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return t.attenuationColor=new f.Color().setRGB(i[0],i[1],i[2],f.LinearSRGBColorSpace),Promise.all(o)}}class Se{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&o.push(r.assignTexture(t,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return t.specularColor=new f.Color().setRGB(i[0],i[1],i[2],f.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&o.push(r.assignTexture(t,"specularColorMap",s.specularColorTexture,f.SRGBColorSpace)),Promise.all(o)}}class Ee{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&o.push(r.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(o)}}class Le{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&o.push(r.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(o)}}class be{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const o=n.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,s)}}class Me{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,n=r.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const s=o.extensions[t],i=n.images[s.source];let a=r.textureLoader;if(i.uri){const c=r.options.manager.getHandler(i.uri);c!==null&&(a=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.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 Ce{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,n=r.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const s=o.extensions[t],i=n.images[s.source];let a=r.textureLoader;if(i.uri){const c=r.options.manager.getHandler(i.uri);c!==null&&(a=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.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 Ie{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],o=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 o.then(function(i){const a=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,d=new Uint8Array(i,a,c);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(l,u,d,n.mode,n.filter).then(function(m){return m.buffer}):s.ready.then(function(){const m=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(m),l,u,d,n.mode,n.filter),m})})}else return null}}class Ne{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=t.meshes[r.mesh];for(const c of n.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const s=r.extensions[this.name].attributes,i=[],a={};for(const c in s)i.push(this.parser.getDependency("accessor",s[c]).then(l=>(a[c]=l,a[c])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,m=[];for(const _ of u){const w=new f.Matrix4,y=new f.Vector3,R=new f.Quaternion,E=new f.Vector3(1,1,1),L=new f.InstancedMesh(_.geometry,_.material,d);for(let S=0;S<d;S++)a.TRANSLATION&&y.fromBufferAttribute(a.TRANSLATION,S),a.ROTATION&&R.fromBufferAttribute(a.ROTATION,S),a.SCALE&&E.fromBufferAttribute(a.SCALE,S),L.setMatrixAt(S,w.compose(y,R,E));for(const S in a)if(S==="_COLOR_0"){const C=a[S];L.instanceColor=new f.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&_.geometry.setAttribute(S,a[S]);f.Object3D.prototype.copy.call(L,_),this.parser.assignFinalMaterial(L),m.push(L)}return l.isGroup?(l.clear(),l.add(...m),l):m[0]}))}}const re="glTF",G=12,$={JSON:1313821514,BIN:5130562};class Oe{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,G),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==re)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-G,o=new DataView(e,G);let s=0;for(;s<n;){const i=o.getUint32(s,!0);s+=4;const a=o.getUint32(s,!0);if(s+=4,a===$.JSON){const c=new Uint8Array(e,G+s,i);this.content=r.decode(c)}else if(a===$.BIN){const c=G+s;this.body=e.slice(c,c+i)}s+=i}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 r=this.json,n=this.dracoLoader,o=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,i={},a={},c={};for(const l in s){const u=q[l]||l.toLowerCase();i[u]=s[l]}for(const l in e.attributes){const u=q[l]||l.toLowerCase();if(s[l]!==void 0){const d=r.accessors[e.attributes[l]],m=F[d.componentType];c[u]=m.name,a[u]=d.normalized===!0}}return t.getDependency("bufferView",o).then(function(l){return new Promise(function(u,d){n.decodeDracoFile(l,function(m){for(const _ in m.attributes){const w=m.attributes[_],y=a[_];y!==void 0&&(w.normalized=y)}u(m)},i,c,f.LinearSRGBColorSpace,d)})})}}class Pe{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 ke{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class oe extends f.Interpolant{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,o=e*n*3+n;for(let s=0;s!==n;s++)t[s]=r[o+s];return t}interpolate_(e,t,r,n){const o=this.resultBuffer,s=this.sampleValues,i=this.valueSize,a=i*2,c=i*3,l=n-t,u=(r-t)/l,d=u*u,m=d*u,_=e*c,w=_-c,y=-2*m+3*d,R=m-d,E=1-y,L=R-d+u;for(let S=0;S!==i;S++){const C=s[w+S+i],I=s[w+S+a]*l,M=s[_+S+i],p=s[_+S]*l;o[S]=E*C+L*I+y*M+R*p}return o}}const Fe=new f.Quaternion;class Ge extends oe{interpolate_(e,t,r,n){const o=super.interpolate_(e,t,r,n);return Fe.fromArray(o).normalize().toArray(o),o}}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},j={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},q={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"},Ue={CUBICSPLINE:void 0,LINEAR:f.InterpolateLinear,STEP:f.InterpolateDiscrete},K={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Be(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 k(h,e,t){for(const r in t.extensions)h[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function P(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 ve(h,e,t){let r=!1,n=!1,o=!1;for(let c=0,l=e.length;c<l;c++){const u=e[c];if(u.POSITION!==void 0&&(r=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(o=!0),r&&n&&o)break}if(!r&&!n&&!o)return Promise.resolve(h);const s=[],i=[],a=[];for(let c=0,l=e.length;c<l;c++){const u=e[c];if(r){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):h.attributes.position;s.push(d)}if(n){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):h.attributes.normal;i.push(d)}if(o){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):h.attributes.color;a.push(d)}}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(a)]).then(function(c){const l=c[0],u=c[1],d=c[2];return r&&(h.morphAttributes.position=l),n&&(h.morphAttributes.normal=u),o&&(h.morphAttributes.color=d),h.morphTargetsRelative=!0,h})}function He(h,e){if(h.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;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 r=0,n=t.length;r<n;r++)h.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function je(h){let e;const t=h.extensions&&h.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+W(t.attributes):e=h.indices+":"+W(h.attributes)+":"+h.mode,h.targets!==void 0)for(let r=0,n=h.targets.length;r<n;r++)e+=":"+W(h.targets[r]);return e}function W(h){let e="";const t=Object.keys(h).sort();for(let r=0,n=t.length;r<n;r++)e+=t[r]+":"+h[t[r]]+";";return e}function z(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 Ke(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 We=new f.Matrix4;class Ve{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new pe,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 r=!1,n=!1,o=-1;typeof navigator<"u"&&(r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,o=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||r||n&&o<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 r=this,n=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(s){const i={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:r,userData:{}};return k(o,i,n),P(i,n),Promise.all(r._invokeAll(function(a){return a.afterRoot&&a.afterRoot(i)})).then(function(){for(const a of i.scenes)a.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let n=0,o=t.length;n<o;n++){const s=t[n].joints;for(let i=0,a=s.length;i<a;i++)e[s[i]].isBone=!0}for(let n=0,o=e.length;n<o;n++){const s=e[n];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(r[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.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,r){if(e.refs[t]<=1)return r;const n=r.clone(),o=(s,i)=>{const a=this.associations.get(s);a!=null&&this.associations.set(i,a);for(const[c,l]of s.children.entries())o(l,i.children[c])};return o(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const n=e(t[r]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let n=0;n<t.length;n++){const o=e(t[n]);o&&r.push(o)}return r}getDependency(e,t){const r=e+":"+t;let n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":n=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(o,s){return r.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=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 n=this.options;return new Promise(function(o,s){r.load(f.LoaderUtils.resolveURL(t.uri,n.path),o,void 0,function(){s(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(r){const n=t.byteLength||0,o=t.byteOffset||0;return r.slice(o,o+n)})}loadAccessor(e){const t=this,r=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const s=j[n.type],i=F[n.componentType],a=n.normalized===!0,c=new i(n.count*s);return Promise.resolve(new f.BufferAttribute(c,s,a))}const o=[];return n.bufferView!==void 0?o.push(this.getDependency("bufferView",n.bufferView)):o.push(null),n.sparse!==void 0&&(o.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(o).then(function(s){const i=s[0],a=j[n.type],c=F[n.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,d=n.byteOffset||0,m=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,_=n.normalized===!0;let w,y;if(m&&m!==u){const R=Math.floor(d/m),E="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+R+":"+n.count;let L=t.cache.get(E);L||(w=new c(i,R*m,n.count*m/l),L=new f.InterleavedBuffer(w,m/l),t.cache.add(E,L)),y=new f.InterleavedBufferAttribute(L,a,d%m/l,_)}else i===null?w=new c(n.count*a):w=new c(i,d,n.count*a),y=new f.BufferAttribute(w,a,_);if(n.sparse!==void 0){const R=j.SCALAR,E=F[n.sparse.indices.componentType],L=n.sparse.indices.byteOffset||0,S=n.sparse.values.byteOffset||0,C=new E(s[1],L,n.sparse.count*R),I=new c(s[2],S,n.sparse.count*a);i!==null&&(y=new f.BufferAttribute(y.array.slice(),y.itemSize,y.normalized));for(let M=0,p=C.length;M<p;M++){const g=C[M];if(y.setX(g,I[M*a]),a>=2&&y.setY(g,I[M*a+1]),a>=3&&y.setZ(g,I[M*a+2]),a>=4&&y.setW(g,I[M*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const t=this.json,r=this.options,o=t.textures[e].source,s=t.images[o];let i=this.textureLoader;if(s.uri){const a=r.manager.getHandler(s.uri);a!==null&&(i=a)}return this.loadTextureImage(e,o,i)}loadTextureImage(e,t,r){const n=this,o=this.json,s=o.textures[e],i=o.images[t],a=(i.uri||i.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,r).then(function(l){l.flipY=!1,l.name=s.name||i.name||"",l.name===""&&typeof i.uri=="string"&&i.uri.startsWith("data:image/")===!1&&(l.name=i.uri);const d=(o.samplers||{})[s.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,n.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const r=this,n=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const s=n.images[e],i=self.URL||self.webkitURL;let a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=r.getDependency("bufferView",s.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:s.mimeType});return a=i.createObjectURL(d),a});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then(function(u){return new Promise(function(d,m){let _=d;t.isImageBitmapLoader===!0&&(_=function(w){const y=new f.Texture(w);y.needsUpdate=!0,d(y)}),t.load(f.LoaderUtils.resolveURL(u,o.path),_,void 0,m)})}).then(function(u){return c===!0&&i.revokeObjectURL(a),u.userData.mimeType=s.mimeType||Ke(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,r,n){const o=this;return this.getDependency("texture",r.index).then(function(s){if(!s)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(s=s.clone(),s.channel=r.texCoord),o.extensions[b.KHR_TEXTURE_TRANSFORM]){const i=r.extensions!==void 0?r.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(i){const a=o.associations.get(s);s=o.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(s,i),o.associations.set(s,a)}}return n!==void 0&&(s.colorSpace=n),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const n=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const i="PointsMaterial:"+r.uuid;let a=this.cache.get(i);a||(a=new f.PointsMaterial,f.Material.prototype.copy.call(a,r),a.color.copy(r.color),a.map=r.map,a.sizeAttenuation=!1,this.cache.add(i,a)),r=a}else if(e.isLine){const i="LineBasicMaterial:"+r.uuid;let a=this.cache.get(i);a||(a=new f.LineBasicMaterial,f.Material.prototype.copy.call(a,r),a.color.copy(r.color),a.map=r.map,this.cache.add(i,a)),r=a}if(n||o||s){let i="ClonedMaterial:"+r.uuid+":";n&&(i+="derivative-tangents:"),o&&(i+="vertex-colors:"),s&&(i+="flat-shading:");let a=this.cache.get(i);a||(a=r.clone(),o&&(a.vertexColors=!0),s&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(i,a),this.associations.set(a,this.associations.get(r))),r=a}e.material=r}getMaterialType(){return f.MeshStandardMaterial}loadMaterial(e){const t=this,r=this.json,n=this.extensions,o=r.materials[e];let s;const i={},a=o.extensions||{},c=[];if(a[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(i,o,t))}else{const u=o.pbrMetallicRoughness||{};if(i.color=new f.Color(1,1,1),i.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;i.color.setRGB(d[0],d[1],d[2],f.LinearSRGBColorSpace),i.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(i,"map",u.baseColorTexture,f.SRGBColorSpace)),i.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,i.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(i,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(i,"roughnessMap",u.metallicRoughnessTexture))),s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,i)})))}o.doubleSided===!0&&(i.side=f.DoubleSide);const l=o.alphaMode||K.OPAQUE;if(l===K.BLEND?(i.transparent=!0,i.depthWrite=!1):(i.transparent=!1,l===K.MASK&&(i.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&s!==f.MeshBasicMaterial&&(c.push(t.assignTexture(i,"normalMap",o.normalTexture)),i.normalScale=new f.Vector2(1,1),o.normalTexture.scale!==void 0)){const u=o.normalTexture.scale;i.normalScale.set(u,u)}if(o.occlusionTexture!==void 0&&s!==f.MeshBasicMaterial&&(c.push(t.assignTexture(i,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(i.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&s!==f.MeshBasicMaterial){const u=o.emissiveFactor;i.emissive=new f.Color().setRGB(u[0],u[1],u[2],f.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&s!==f.MeshBasicMaterial&&c.push(t.assignTexture(i,"emissiveMap",o.emissiveTexture,f.SRGBColorSpace)),Promise.all(c).then(function(){const u=new s(i);return o.name&&(u.name=o.name),P(u,o),t.associations.set(u,{materials:e}),o.extensions&&k(n,u,o),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,r=this.extensions,n=this.primitiveCache;function o(i){return r[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(i,t).then(function(a){return ne(a,i,t)})}const s=[];for(let i=0,a=e.length;i<a;i++){const c=e[i],l=je(c),u=n[l];if(u)s.push(u.promise);else{let d;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?d=o(c):d=ne(new f.BufferGeometry,c,t),n[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){const t=this,r=this.json,n=this.extensions,o=r.meshes[e],s=o.primitives,i=[];for(let a=0,c=s.length;a<c;a++){const l=s[a].material===void 0?Be(this.cache):this.getDependency("material",s[a].material);i.push(l)}return i.push(t.loadGeometries(s)),Promise.all(i).then(function(a){const c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let m=0,_=l.length;m<_;m++){const w=l[m],y=s[m];let R;const E=c[m];if(y.mode===N.TRIANGLES||y.mode===N.TRIANGLE_STRIP||y.mode===N.TRIANGLE_FAN||y.mode===void 0)R=o.isSkinnedMesh===!0?new f.SkinnedMesh(w,E):new f.Mesh(w,E),R.isSkinnedMesh===!0&&R.normalizeSkinWeights(),y.mode===N.TRIANGLE_STRIP?R.geometry=Z(R.geometry,f.TriangleStripDrawMode):y.mode===N.TRIANGLE_FAN&&(R.geometry=Z(R.geometry,f.TriangleFanDrawMode));else if(y.mode===N.LINES)R=new f.LineSegments(w,E);else if(y.mode===N.LINE_STRIP)R=new f.Line(w,E);else if(y.mode===N.LINE_LOOP)R=new f.LineLoop(w,E);else if(y.mode===N.POINTS)R=new f.Points(w,E);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(R.geometry.morphAttributes).length>0&&He(R,o),R.name=t.createUniqueName(o.name||"mesh_"+e),P(R,o),y.extensions&&k(n,R,y),t.assignFinalMaterial(R),u.push(R)}for(let m=0,_=u.length;m<_;m++)t.associations.set(u[m],{meshes:e,primitives:m});if(u.length===1)return o.extensions&&k(n,u[0],o),u[0];const d=new f.Group;o.extensions&&k(n,d,o),t.associations.set(d,{meshes:e});for(let m=0,_=u.length;m<_;m++)d.add(u[m]);return d})}loadCamera(e){let t;const r=this.json.cameras[e],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new f.PerspectiveCamera(f.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(t=new f.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),P(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let n=0,o=t.joints.length;n<o;n++)r.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){const o=n.pop(),s=n,i=[],a=[];for(let c=0,l=s.length;c<l;c++){const u=s[c];if(u){i.push(u);const d=new f.Matrix4;o!==null&&d.fromArray(o.array,c*16),a.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new f.Skeleton(i,a)})}loadAnimation(e){const t=this.json,r=this,n=t.animations[e],o=n.name?n.name:"animation_"+e,s=[],i=[],a=[],c=[],l=[];for(let u=0,d=n.channels.length;u<d;u++){const m=n.channels[u],_=n.samplers[m.sampler],w=m.target,y=w.node,R=n.parameters!==void 0?n.parameters[_.input]:_.input,E=n.parameters!==void 0?n.parameters[_.output]:_.output;w.node!==void 0&&(s.push(this.getDependency("node",y)),i.push(this.getDependency("accessor",R)),a.push(this.getDependency("accessor",E)),c.push(_),l.push(w))}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){const d=u[0],m=u[1],_=u[2],w=u[3],y=u[4],R=[];for(let E=0,L=d.length;E<L;E++){const S=d[E],C=m[E],I=_[E],M=w[E],p=y[E];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const g=r._createAnimationTracks(S,C,I,M,p);if(g)for(let A=0;A<g.length;A++)R.push(g[A])}return new f.AnimationClip(o,void 0,R)})}createNodeMesh(e){const t=this.json,r=this,n=t.nodes[e];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(o){const s=r._getNodeRef(r.meshCache,n.mesh,o);return n.weights!==void 0&&s.traverse(function(i){if(i.isMesh)for(let a=0,c=n.weights.length;a<c;a++)i.morphTargetInfluences[a]=n.weights[a]}),s})}loadNode(e){const t=this.json,r=this,n=t.nodes[e],o=r._loadNodeShallow(e),s=[],i=n.children||[];for(let c=0,l=i.length;c<l;c++)s.push(r.getDependency("node",i[c]));const a=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([o,Promise.all(s),a]).then(function(c){const l=c[0],u=c[1],d=c[2];d!==null&&l.traverse(function(m){m.isSkinnedMesh&&m.bind(d,We)});for(let m=0,_=u.length;m<_;m++)l.add(u[m]);return l})}_loadNodeShallow(e){const t=this.json,r=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],s=o.name?n.createUniqueName(o.name):"",i=[],a=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return a&&i.push(a),o.camera!==void 0&&i.push(n.getDependency("camera",o.camera).then(function(c){return n._getNodeRef(n.cameraCache,o.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){i.push(c)}),this.nodeCache[e]=Promise.all(i).then(function(c){let l;if(o.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(o.name&&(l.userData.name=o.name,l.name=s),P(l,o),o.extensions&&k(r,l,o),o.matrix!==void 0){const u=new f.Matrix4;u.fromArray(o.matrix),l.applyMatrix4(u)}else o.translation!==void 0&&l.position.fromArray(o.translation),o.rotation!==void 0&&l.quaternion.fromArray(o.rotation),o.scale!==void 0&&l.scale.fromArray(o.scale);return n.associations.has(l)||n.associations.set(l,{}),n.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],n=this,o=new f.Group;r.name&&(o.name=n.createUniqueName(r.name)),P(o,r),r.extensions&&k(t,o,r);const s=r.nodes||[],i=[];for(let a=0,c=s.length;a<c;a++)i.push(n.getDependency("node",s[a]));return Promise.all(i).then(function(a){for(let l=0,u=a.length;l<u;l++)o.add(a[l]);const c=l=>{const u=new Map;for(const[d,m]of n.associations)(d instanceof f.Material||d instanceof f.Texture)&&u.set(d,m);return l.traverse(d=>{const m=n.associations.get(d);m!=null&&u.set(d,m)}),u};return n.associations=c(o),o})}_createAnimationTracks(e,t,r,n,o){const s=[],i=e.name?e.name:e.uuid,a=[];D[o.path]===D.weights?e.traverse(function(d){d.morphTargetInfluences&&a.push(d.name?d.name:d.uuid)}):a.push(i);let c;switch(D[o.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(r.itemSize){case 1:c=f.NumberKeyframeTrack;break;case 2:case 3:default:c=f.VectorKeyframeTrack;break}break}const l=n.interpolation!==void 0?Ue[n.interpolation]:f.InterpolateLinear,u=this._getArrayFromAccessor(r);for(let d=0,m=a.length;d<m;d++){const _=new c(a[d]+"."+D[o.path],t.array,u,l);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),s.push(_)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const r=z(t.constructor),n=new Float32Array(t.length);for(let o=0,s=t.length;o<s;o++)n[o]=t[o]*r;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const n=this instanceof f.QuaternionKeyframeTrack?Ge:oe;return new n(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Xe(h,e,t){const r=e.attributes,n=new f.Box3;if(r.POSITION!==void 0){const i=t.json.accessors[r.POSITION],a=i.min,c=i.max;if(a!==void 0&&c!==void 0){if(n.set(new f.Vector3(a[0],a[1],a[2]),new f.Vector3(c[0],c[1],c[2])),i.normalized){const l=z(F[i.componentType]);n.min.multiplyScalar(l),n.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const i=new f.Vector3,a=new f.Vector3;for(let c=0,l=o.length;c<l;c++){const u=o[c];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],m=d.min,_=d.max;if(m!==void 0&&_!==void 0){if(a.setX(Math.max(Math.abs(m[0]),Math.abs(_[0]))),a.setY(Math.max(Math.abs(m[1]),Math.abs(_[1]))),a.setZ(Math.max(Math.abs(m[2]),Math.abs(_[2]))),d.normalized){const w=z(F[d.componentType]);a.multiplyScalar(w)}i.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(i)}h.boundingBox=n;const s=new f.Sphere;n.getCenter(s.center),s.radius=n.min.distanceTo(n.max)/2,h.boundingSphere=s}function ne(h,e,t){const r=e.attributes,n=[];function o(s,i){return t.getDependency("accessor",s).then(function(a){h.setAttribute(i,a)})}for(const s in r){const i=q[s]||s.toLowerCase();i in h.attributes||n.push(o(r[s],i))}if(e.indices!==void 0&&!h.index){const s=t.getDependency("accessor",e.indices).then(function(i){h.setIndex(i)});n.push(s)}return f.ColorManagement.workingColorSpace!==f.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${f.ColorManagement.workingColorSpace}" not supported.`),P(h,e),Xe(h,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ve(h,e.targets,t):h})}class qe{parse(e){const t={},r=e.split(`
1
+ "use strict";var ue=Object.defineProperty;var fe=(h,e,t)=>e in h?ue(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var O=(h,e,t)=>fe(h,typeof e!="symbol"?e+"":e,t);const f=require("three"),H=require("./fflate.module-DHdJvhNh.cjs"),de=require("./FileTypes-BHH0KUFf.cjs"),Q=require("./isFileTypeSupported-CFN9V48s.cjs"),U=require("./parse-error-Dy_EE4rL.cjs"),B=require("./AssetCache-CwK-0iP9.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 s=[],i=h.getAttribute("position");if(i!==void 0){for(let a=0;a<i.count;a++)s.push(a);h.setIndex(s),t=h.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),h}const r=t.count-2,n=[];if(e===f.TriangleFanDrawMode)for(let s=1;s<=r;s++)n.push(t.getX(0)),n.push(t.getX(s)),n.push(t.getX(s+1));else for(let s=0;s<r;s++)s%2===0?(n.push(t.getX(s)),n.push(t.getX(s+1)),n.push(t.getX(s+2))):(n.push(t.getX(s+2)),n.push(t.getX(s+1)),n.push(t.getX(s)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=h.clone();return o.setIndex(n),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),h}class he extends f.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Te(t)}),this.register(function(t){return new be(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Ce(t)}),this.register(function(t){return new ye(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new Ae(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new _e(t)}),this.register(function(t){return new Le(t)}),this.register(function(t){return new Ee(t)}),this.register(function(t){return new me(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new Ne(t)})}load(e,t,r,n){const o=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const c=f.LoaderUtils.extractUrlBase(e);s=f.LoaderUtils.resolveURL(c,this.path)}else s=f.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const i=function(c){n?n(c):console.error(c),o.manager.itemError(e),o.manager.itemEnd(e)},a=new f.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{o.parse(c,s,function(l){t(l),o.manager.itemEnd(e)},i)}catch(l){i(l)}},r,i)}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,r,n){let o;const s={},i={},a=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===re){try{s[b.KHR_BINARY_GLTF]=new Oe(e)}catch(u){n&&n(u);return}o=JSON.parse(s[b.KHR_BINARY_GLTF].content)}else o=JSON.parse(a.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Ve(o,{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"),i[u.name]=u,s[u.name]=!0}if(o.extensionsUsed)for(let l=0;l<o.extensionsUsed.length;++l){const u=o.extensionsUsed[l],d=o.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:s[u]=new ge;break;case b.KHR_DRACO_MESH_COMPRESSION:s[u]=new De(o,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:s[u]=new Pe;break;case b.KHR_MESH_QUANTIZATION:s[u]=new ke;break;default:d.indexOf(u)>=0&&i[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(i),c.parse(r,n)}parseAsync(e,t){const r=this;return new Promise(function(n,o){r.parse(e,t,n,o)})}}function pe(){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 me{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 r=0,n=t.length;r<n;r++){const o=t[r];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let n=t.cache.get(r);if(n)return n;const o=t.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let c;const l=new f.Color(16777215);a.color!==void 0&&l.setRGB(a.color[0],a.color[1],a.color[2],f.LinearSRGBColorSpace);const u=a.range!==void 0?a.range:0;switch(a.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,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return c.position.set(0,0,0),c.decay=2,P(c,a),a.intensity!==void 0&&(c.intensity=a.intensity),c.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(c),t.cache.add(r,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,o=r.json.nodes[e],i=(o.extensions&&o.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(a){return r._getNodeRef(t.cache,i,a)})}}class ge{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return f.MeshBasicMaterial}extendParams(e,t,r){const n=[];e.color=new f.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const s=o.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],f.LinearSRGBColorSpace),e.opacity=s[3]}o.baseColorTexture!==void 0&&n.push(r.assignTexture(e,"map",o.baseColorTexture,f.SRGBColorSpace))}return Promise.all(n)}}class Ae{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class Te{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&o.push(r.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&o.push(r.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(o.push(r.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f.Vector2(i,i)}return Promise.all(o)}}class _e{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&o.push(r.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&o.push(r.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(o)}}class ye{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new f.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=n.extensions[this.name];if(s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],f.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&o.push(r.assignTexture(t,"sheenColorMap",s.sheenColorTexture,f.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&o.push(r.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(o)}}class Re{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&o.push(r.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(o)}}class we{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&o.push(r.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return t.attenuationColor=new f.Color().setRGB(i[0],i[1],i[2],f.LinearSRGBColorSpace),Promise.all(o)}}class Se{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&o.push(r.assignTexture(t,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return t.specularColor=new f.Color().setRGB(i[0],i[1],i[2],f.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&o.push(r.assignTexture(t,"specularColorMap",s.specularColorTexture,f.SRGBColorSpace)),Promise.all(o)}}class Ee{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&o.push(r.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(o)}}class Le{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],s=n.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&o.push(r.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(o)}}class be{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const o=n.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,s)}}class Me{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,n=r.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const s=o.extensions[t],i=n.images[s.source];let a=r.textureLoader;if(i.uri){const c=r.options.manager.getHandler(i.uri);c!==null&&(a=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.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 Ce{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,n=r.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const s=o.extensions[t],i=n.images[s.source];let a=r.textureLoader;if(i.uri){const c=r.options.manager.getHandler(i.uri);c!==null&&(a=c)}return this.detectSupport().then(function(c){if(c)return r.loadTextureImage(e,s.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.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 Ie{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],o=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 o.then(function(i){const a=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,d=new Uint8Array(i,a,c);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(l,u,d,n.mode,n.filter).then(function(m){return m.buffer}):s.ready.then(function(){const m=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(m),l,u,d,n.mode,n.filter),m})})}else return null}}class Ne{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=t.meshes[r.mesh];for(const c of n.primitives)if(c.mode!==N.TRIANGLES&&c.mode!==N.TRIANGLE_STRIP&&c.mode!==N.TRIANGLE_FAN&&c.mode!==void 0)return null;const s=r.extensions[this.name].attributes,i=[],a={};for(const c in s)i.push(this.parser.getDependency("accessor",s[c]).then(l=>(a[c]=l,a[c])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,m=[];for(const _ of u){const w=new f.Matrix4,y=new f.Vector3,R=new f.Quaternion,E=new f.Vector3(1,1,1),L=new f.InstancedMesh(_.geometry,_.material,d);for(let S=0;S<d;S++)a.TRANSLATION&&y.fromBufferAttribute(a.TRANSLATION,S),a.ROTATION&&R.fromBufferAttribute(a.ROTATION,S),a.SCALE&&E.fromBufferAttribute(a.SCALE,S),L.setMatrixAt(S,w.compose(y,R,E));for(const S in a)if(S==="_COLOR_0"){const C=a[S];L.instanceColor=new f.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&_.geometry.setAttribute(S,a[S]);f.Object3D.prototype.copy.call(L,_),this.parser.assignFinalMaterial(L),m.push(L)}return l.isGroup?(l.clear(),l.add(...m),l):m[0]}))}}const re="glTF",G=12,$={JSON:1313821514,BIN:5130562};class Oe{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,G),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==re)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-G,o=new DataView(e,G);let s=0;for(;s<n;){const i=o.getUint32(s,!0);s+=4;const a=o.getUint32(s,!0);if(s+=4,a===$.JSON){const c=new Uint8Array(e,G+s,i);this.content=r.decode(c)}else if(a===$.BIN){const c=G+s;this.body=e.slice(c,c+i)}s+=i}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 r=this.json,n=this.dracoLoader,o=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,i={},a={},c={};for(const l in s){const u=q[l]||l.toLowerCase();i[u]=s[l]}for(const l in e.attributes){const u=q[l]||l.toLowerCase();if(s[l]!==void 0){const d=r.accessors[e.attributes[l]],m=F[d.componentType];c[u]=m.name,a[u]=d.normalized===!0}}return t.getDependency("bufferView",o).then(function(l){return new Promise(function(u,d){n.decodeDracoFile(l,function(m){for(const _ in m.attributes){const w=m.attributes[_],y=a[_];y!==void 0&&(w.normalized=y)}u(m)},i,c,f.LinearSRGBColorSpace,d)})})}}class Pe{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 ke{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class oe extends f.Interpolant{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,o=e*n*3+n;for(let s=0;s!==n;s++)t[s]=r[o+s];return t}interpolate_(e,t,r,n){const o=this.resultBuffer,s=this.sampleValues,i=this.valueSize,a=i*2,c=i*3,l=n-t,u=(r-t)/l,d=u*u,m=d*u,_=e*c,w=_-c,y=-2*m+3*d,R=m-d,E=1-y,L=R-d+u;for(let S=0;S!==i;S++){const C=s[w+S+i],I=s[w+S+a]*l,M=s[_+S+i],p=s[_+S]*l;o[S]=E*C+L*I+y*M+R*p}return o}}const Fe=new f.Quaternion;class Ge extends oe{interpolate_(e,t,r,n){const o=super.interpolate_(e,t,r,n);return Fe.fromArray(o).normalize().toArray(o),o}}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},j={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},q={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"},Ue={CUBICSPLINE:void 0,LINEAR:f.InterpolateLinear,STEP:f.InterpolateDiscrete},K={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Be(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 k(h,e,t){for(const r in t.extensions)h[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function P(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 ve(h,e,t){let r=!1,n=!1,o=!1;for(let c=0,l=e.length;c<l;c++){const u=e[c];if(u.POSITION!==void 0&&(r=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(o=!0),r&&n&&o)break}if(!r&&!n&&!o)return Promise.resolve(h);const s=[],i=[],a=[];for(let c=0,l=e.length;c<l;c++){const u=e[c];if(r){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):h.attributes.position;s.push(d)}if(n){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):h.attributes.normal;i.push(d)}if(o){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):h.attributes.color;a.push(d)}}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(a)]).then(function(c){const l=c[0],u=c[1],d=c[2];return r&&(h.morphAttributes.position=l),n&&(h.morphAttributes.normal=u),o&&(h.morphAttributes.color=d),h.morphTargetsRelative=!0,h})}function He(h,e){if(h.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;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 r=0,n=t.length;r<n;r++)h.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function je(h){let e;const t=h.extensions&&h.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+W(t.attributes):e=h.indices+":"+W(h.attributes)+":"+h.mode,h.targets!==void 0)for(let r=0,n=h.targets.length;r<n;r++)e+=":"+W(h.targets[r]);return e}function W(h){let e="";const t=Object.keys(h).sort();for(let r=0,n=t.length;r<n;r++)e+=t[r]+":"+h[t[r]]+";";return e}function z(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 Ke(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 We=new f.Matrix4;class Ve{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new pe,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 r=!1,n=!1,o=-1;typeof navigator<"u"&&(r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,o=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||r||n&&o<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 r=this,n=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(s){const i={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:r,userData:{}};return k(o,i,n),P(i,n),Promise.all(r._invokeAll(function(a){return a.afterRoot&&a.afterRoot(i)})).then(function(){for(const a of i.scenes)a.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let n=0,o=t.length;n<o;n++){const s=t[n].joints;for(let i=0,a=s.length;i<a;i++)e[s[i]].isBone=!0}for(let n=0,o=e.length;n<o;n++){const s=e[n];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(r[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.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,r){if(e.refs[t]<=1)return r;const n=r.clone(),o=(s,i)=>{const a=this.associations.get(s);a!=null&&this.associations.set(i,a);for(const[c,l]of s.children.entries())o(l,i.children[c])};return o(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const n=e(t[r]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let n=0;n<t.length;n++){const o=e(t[n]);o&&r.push(o)}return r}getDependency(e,t){const r=e+":"+t;let n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":n=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(o,s){return r.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=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 n=this.options;return new Promise(function(o,s){r.load(f.LoaderUtils.resolveURL(t.uri,n.path),o,void 0,function(){s(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(r){const n=t.byteLength||0,o=t.byteOffset||0;return r.slice(o,o+n)})}loadAccessor(e){const t=this,r=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const s=j[n.type],i=F[n.componentType],a=n.normalized===!0,c=new i(n.count*s);return Promise.resolve(new f.BufferAttribute(c,s,a))}const o=[];return n.bufferView!==void 0?o.push(this.getDependency("bufferView",n.bufferView)):o.push(null),n.sparse!==void 0&&(o.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(o).then(function(s){const i=s[0],a=j[n.type],c=F[n.componentType],l=c.BYTES_PER_ELEMENT,u=l*a,d=n.byteOffset||0,m=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,_=n.normalized===!0;let w,y;if(m&&m!==u){const R=Math.floor(d/m),E="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+R+":"+n.count;let L=t.cache.get(E);L||(w=new c(i,R*m,n.count*m/l),L=new f.InterleavedBuffer(w,m/l),t.cache.add(E,L)),y=new f.InterleavedBufferAttribute(L,a,d%m/l,_)}else i===null?w=new c(n.count*a):w=new c(i,d,n.count*a),y=new f.BufferAttribute(w,a,_);if(n.sparse!==void 0){const R=j.SCALAR,E=F[n.sparse.indices.componentType],L=n.sparse.indices.byteOffset||0,S=n.sparse.values.byteOffset||0,C=new E(s[1],L,n.sparse.count*R),I=new c(s[2],S,n.sparse.count*a);i!==null&&(y=new f.BufferAttribute(y.array.slice(),y.itemSize,y.normalized));for(let M=0,p=C.length;M<p;M++){const g=C[M];if(y.setX(g,I[M*a]),a>=2&&y.setY(g,I[M*a+1]),a>=3&&y.setZ(g,I[M*a+2]),a>=4&&y.setW(g,I[M*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const t=this.json,r=this.options,o=t.textures[e].source,s=t.images[o];let i=this.textureLoader;if(s.uri){const a=r.manager.getHandler(s.uri);a!==null&&(i=a)}return this.loadTextureImage(e,o,i)}loadTextureImage(e,t,r){const n=this,o=this.json,s=o.textures[e],i=o.images[t],a=(i.uri||i.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,r).then(function(l){l.flipY=!1,l.name=s.name||i.name||"",l.name===""&&typeof i.uri=="string"&&i.uri.startsWith("data:image/")===!1&&(l.name=i.uri);const d=(o.samplers||{})[s.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,n.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const r=this,n=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const s=n.images[e],i=self.URL||self.webkitURL;let a=s.uri||"",c=!1;if(s.bufferView!==void 0)a=r.getDependency("bufferView",s.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:s.mimeType});return a=i.createObjectURL(d),a});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then(function(u){return new Promise(function(d,m){let _=d;t.isImageBitmapLoader===!0&&(_=function(w){const y=new f.Texture(w);y.needsUpdate=!0,d(y)}),t.load(f.LoaderUtils.resolveURL(u,o.path),_,void 0,m)})}).then(function(u){return c===!0&&i.revokeObjectURL(a),u.userData.mimeType=s.mimeType||Ke(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=l,l}assignTexture(e,t,r,n){const o=this;return this.getDependency("texture",r.index).then(function(s){if(!s)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(s=s.clone(),s.channel=r.texCoord),o.extensions[b.KHR_TEXTURE_TRANSFORM]){const i=r.extensions!==void 0?r.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(i){const a=o.associations.get(s);s=o.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(s,i),o.associations.set(s,a)}}return n!==void 0&&(s.colorSpace=n),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const n=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const i="PointsMaterial:"+r.uuid;let a=this.cache.get(i);a||(a=new f.PointsMaterial,f.Material.prototype.copy.call(a,r),a.color.copy(r.color),a.map=r.map,a.sizeAttenuation=!1,this.cache.add(i,a)),r=a}else if(e.isLine){const i="LineBasicMaterial:"+r.uuid;let a=this.cache.get(i);a||(a=new f.LineBasicMaterial,f.Material.prototype.copy.call(a,r),a.color.copy(r.color),a.map=r.map,this.cache.add(i,a)),r=a}if(n||o||s){let i="ClonedMaterial:"+r.uuid+":";n&&(i+="derivative-tangents:"),o&&(i+="vertex-colors:"),s&&(i+="flat-shading:");let a=this.cache.get(i);a||(a=r.clone(),o&&(a.vertexColors=!0),s&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(i,a),this.associations.set(a,this.associations.get(r))),r=a}e.material=r}getMaterialType(){return f.MeshStandardMaterial}loadMaterial(e){const t=this,r=this.json,n=this.extensions,o=r.materials[e];let s;const i={},a=o.extensions||{},c=[];if(a[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(i,o,t))}else{const u=o.pbrMetallicRoughness||{};if(i.color=new f.Color(1,1,1),i.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;i.color.setRGB(d[0],d[1],d[2],f.LinearSRGBColorSpace),i.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(i,"map",u.baseColorTexture,f.SRGBColorSpace)),i.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,i.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(i,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(i,"roughnessMap",u.metallicRoughnessTexture))),s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,i)})))}o.doubleSided===!0&&(i.side=f.DoubleSide);const l=o.alphaMode||K.OPAQUE;if(l===K.BLEND?(i.transparent=!0,i.depthWrite=!1):(i.transparent=!1,l===K.MASK&&(i.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&s!==f.MeshBasicMaterial&&(c.push(t.assignTexture(i,"normalMap",o.normalTexture)),i.normalScale=new f.Vector2(1,1),o.normalTexture.scale!==void 0)){const u=o.normalTexture.scale;i.normalScale.set(u,u)}if(o.occlusionTexture!==void 0&&s!==f.MeshBasicMaterial&&(c.push(t.assignTexture(i,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(i.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&s!==f.MeshBasicMaterial){const u=o.emissiveFactor;i.emissive=new f.Color().setRGB(u[0],u[1],u[2],f.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&s!==f.MeshBasicMaterial&&c.push(t.assignTexture(i,"emissiveMap",o.emissiveTexture,f.SRGBColorSpace)),Promise.all(c).then(function(){const u=new s(i);return o.name&&(u.name=o.name),P(u,o),t.associations.set(u,{materials:e}),o.extensions&&k(n,u,o),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,r=this.extensions,n=this.primitiveCache;function o(i){return r[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(i,t).then(function(a){return ne(a,i,t)})}const s=[];for(let i=0,a=e.length;i<a;i++){const c=e[i],l=je(c),u=n[l];if(u)s.push(u.promise);else{let d;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?d=o(c):d=ne(new f.BufferGeometry,c,t),n[l]={primitive:c,promise:d},s.push(d)}}return Promise.all(s)}loadMesh(e){const t=this,r=this.json,n=this.extensions,o=r.meshes[e],s=o.primitives,i=[];for(let a=0,c=s.length;a<c;a++){const l=s[a].material===void 0?Be(this.cache):this.getDependency("material",s[a].material);i.push(l)}return i.push(t.loadGeometries(s)),Promise.all(i).then(function(a){const c=a.slice(0,a.length-1),l=a[a.length-1],u=[];for(let m=0,_=l.length;m<_;m++){const w=l[m],y=s[m];let R;const E=c[m];if(y.mode===N.TRIANGLES||y.mode===N.TRIANGLE_STRIP||y.mode===N.TRIANGLE_FAN||y.mode===void 0)R=o.isSkinnedMesh===!0?new f.SkinnedMesh(w,E):new f.Mesh(w,E),R.isSkinnedMesh===!0&&R.normalizeSkinWeights(),y.mode===N.TRIANGLE_STRIP?R.geometry=Z(R.geometry,f.TriangleStripDrawMode):y.mode===N.TRIANGLE_FAN&&(R.geometry=Z(R.geometry,f.TriangleFanDrawMode));else if(y.mode===N.LINES)R=new f.LineSegments(w,E);else if(y.mode===N.LINE_STRIP)R=new f.Line(w,E);else if(y.mode===N.LINE_LOOP)R=new f.LineLoop(w,E);else if(y.mode===N.POINTS)R=new f.Points(w,E);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(R.geometry.morphAttributes).length>0&&He(R,o),R.name=t.createUniqueName(o.name||"mesh_"+e),P(R,o),y.extensions&&k(n,R,y),t.assignFinalMaterial(R),u.push(R)}for(let m=0,_=u.length;m<_;m++)t.associations.set(u[m],{meshes:e,primitives:m});if(u.length===1)return o.extensions&&k(n,u[0],o),u[0];const d=new f.Group;o.extensions&&k(n,d,o),t.associations.set(d,{meshes:e});for(let m=0,_=u.length;m<_;m++)d.add(u[m]);return d})}loadCamera(e){let t;const r=this.json.cameras[e],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new f.PerspectiveCamera(f.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(t=new f.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),P(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let n=0,o=t.joints.length;n<o;n++)r.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){const o=n.pop(),s=n,i=[],a=[];for(let c=0,l=s.length;c<l;c++){const u=s[c];if(u){i.push(u);const d=new f.Matrix4;o!==null&&d.fromArray(o.array,c*16),a.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new f.Skeleton(i,a)})}loadAnimation(e){const t=this.json,r=this,n=t.animations[e],o=n.name?n.name:"animation_"+e,s=[],i=[],a=[],c=[],l=[];for(let u=0,d=n.channels.length;u<d;u++){const m=n.channels[u],_=n.samplers[m.sampler],w=m.target,y=w.node,R=n.parameters!==void 0?n.parameters[_.input]:_.input,E=n.parameters!==void 0?n.parameters[_.output]:_.output;w.node!==void 0&&(s.push(this.getDependency("node",y)),i.push(this.getDependency("accessor",R)),a.push(this.getDependency("accessor",E)),c.push(_),l.push(w))}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(a),Promise.all(c),Promise.all(l)]).then(function(u){const d=u[0],m=u[1],_=u[2],w=u[3],y=u[4],R=[];for(let E=0,L=d.length;E<L;E++){const S=d[E],C=m[E],I=_[E],M=w[E],p=y[E];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const g=r._createAnimationTracks(S,C,I,M,p);if(g)for(let A=0;A<g.length;A++)R.push(g[A])}return new f.AnimationClip(o,void 0,R)})}createNodeMesh(e){const t=this.json,r=this,n=t.nodes[e];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(o){const s=r._getNodeRef(r.meshCache,n.mesh,o);return n.weights!==void 0&&s.traverse(function(i){if(i.isMesh)for(let a=0,c=n.weights.length;a<c;a++)i.morphTargetInfluences[a]=n.weights[a]}),s})}loadNode(e){const t=this.json,r=this,n=t.nodes[e],o=r._loadNodeShallow(e),s=[],i=n.children||[];for(let c=0,l=i.length;c<l;c++)s.push(r.getDependency("node",i[c]));const a=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([o,Promise.all(s),a]).then(function(c){const l=c[0],u=c[1],d=c[2];d!==null&&l.traverse(function(m){m.isSkinnedMesh&&m.bind(d,We)});for(let m=0,_=u.length;m<_;m++)l.add(u[m]);return l})}_loadNodeShallow(e){const t=this.json,r=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],s=o.name?n.createUniqueName(o.name):"",i=[],a=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return a&&i.push(a),o.camera!==void 0&&i.push(n.getDependency("camera",o.camera).then(function(c){return n._getNodeRef(n.cameraCache,o.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){i.push(c)}),this.nodeCache[e]=Promise.all(i).then(function(c){let l;if(o.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(o.name&&(l.userData.name=o.name,l.name=s),P(l,o),o.extensions&&k(r,l,o),o.matrix!==void 0){const u=new f.Matrix4;u.fromArray(o.matrix),l.applyMatrix4(u)}else o.translation!==void 0&&l.position.fromArray(o.translation),o.rotation!==void 0&&l.quaternion.fromArray(o.rotation),o.scale!==void 0&&l.scale.fromArray(o.scale);return n.associations.has(l)||n.associations.set(l,{}),n.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],n=this,o=new f.Group;r.name&&(o.name=n.createUniqueName(r.name)),P(o,r),r.extensions&&k(t,o,r);const s=r.nodes||[],i=[];for(let a=0,c=s.length;a<c;a++)i.push(n.getDependency("node",s[a]));return Promise.all(i).then(function(a){for(let l=0,u=a.length;l<u;l++)o.add(a[l]);const c=l=>{const u=new Map;for(const[d,m]of n.associations)(d instanceof f.Material||d instanceof f.Texture)&&u.set(d,m);return l.traverse(d=>{const m=n.associations.get(d);m!=null&&u.set(d,m)}),u};return n.associations=c(o),o})}_createAnimationTracks(e,t,r,n,o){const s=[],i=e.name?e.name:e.uuid,a=[];D[o.path]===D.weights?e.traverse(function(d){d.morphTargetInfluences&&a.push(d.name?d.name:d.uuid)}):a.push(i);let c;switch(D[o.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(r.itemSize){case 1:c=f.NumberKeyframeTrack;break;case 2:case 3:default:c=f.VectorKeyframeTrack;break}break}const l=n.interpolation!==void 0?Ue[n.interpolation]:f.InterpolateLinear,u=this._getArrayFromAccessor(r);for(let d=0,m=a.length;d<m;d++){const _=new c(a[d]+"."+D[o.path],t.array,u,l);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),s.push(_)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const r=z(t.constructor),n=new Float32Array(t.length);for(let o=0,s=t.length;o<s;o++)n[o]=t[o]*r;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const n=this instanceof f.QuaternionKeyframeTrack?Ge:oe;return new n(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Xe(h,e,t){const r=e.attributes,n=new f.Box3;if(r.POSITION!==void 0){const i=t.json.accessors[r.POSITION],a=i.min,c=i.max;if(a!==void 0&&c!==void 0){if(n.set(new f.Vector3(a[0],a[1],a[2]),new f.Vector3(c[0],c[1],c[2])),i.normalized){const l=z(F[i.componentType]);n.min.multiplyScalar(l),n.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const i=new f.Vector3,a=new f.Vector3;for(let c=0,l=o.length;c<l;c++){const u=o[c];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],m=d.min,_=d.max;if(m!==void 0&&_!==void 0){if(a.setX(Math.max(Math.abs(m[0]),Math.abs(_[0]))),a.setY(Math.max(Math.abs(m[1]),Math.abs(_[1]))),a.setZ(Math.max(Math.abs(m[2]),Math.abs(_[2]))),d.normalized){const w=z(F[d.componentType]);a.multiplyScalar(w)}i.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(i)}h.boundingBox=n;const s=new f.Sphere;n.getCenter(s.center),s.radius=n.min.distanceTo(n.max)/2,h.boundingSphere=s}function ne(h,e,t){const r=e.attributes,n=[];function o(s,i){return t.getDependency("accessor",s).then(function(a){h.setAttribute(i,a)})}for(const s in r){const i=q[s]||s.toLowerCase();i in h.attributes||n.push(o(r[s],i))}if(e.indices!==void 0&&!h.index){const s=t.getDependency("accessor",e.indices).then(function(i){h.setIndex(i)});n.push(s)}return f.ColorManagement.workingColorSpace!==f.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${f.ColorManagement.workingColorSpace}" not supported.`),P(h,e),Xe(h,e,t),Promise.all(n).then(function(){return e.targets!==void 0?ve(h,e.targets,t):h})}class qe{parse(e){const t={},r=e.split(`
2
2
  `);let n=null,o=t;const s=[t];for(const i of r)if(i.includes("=")){const a=i.split("="),c=a[0].trim(),l=a[1].trim();if(l.endsWith("{")){const u={};s.push(u),o[c]=u,o=u}else o[c]=l}else if(i.endsWith("{")){const a=o[n]||{};s.push(a),o[n]=a,o=a}else if(i.endsWith("}")){if(s.pop(),s.length===0)continue;o=s[s.length-1]}else if(i.endsWith("(")){const a={};s.push(a),n=i.split("(")[0].trim()||n,o[n]=a,o=a}else i.endsWith(")")?(s.pop(),o=s[s.length-1]):n=i.trim();return t}}class ze extends f.Loader{constructor(e){super(e)}load(e,t,r,n){const o=this,s=new f.FileLoader(o.manager);s.setPath(o.path),s.setResponseType("arraybuffer"),s.setRequestHeader(o.requestHeader),s.setWithCredentials(o.withCredentials),s.load(e,function(i){try{t(o.parse(i))}catch(a){n?n(a):console.error(a),o.manager.itemError(e)}},r,n)}parse(e){const t=new qe;function r(p){const g={};new f.FileLoader().setResponseType("arraybuffer");for(const T in p){if(T.endsWith("png")){const x=new Blob([p[T]],{type:{type:"image/png"}});g[T]=URL.createObjectURL(x)}if(T.endsWith("usd")||T.endsWith("usda")){if(n(p[T])){console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.");continue}const x=H.strFromU8(p[T]);g[T]=t.parse(x)}}return g}function n(p){const g=p.slice(0,7),A=new Uint8Array([80,88,82,45,85,83,68,67]);return g.every((T,x)=>T===A[x])}function o(p){if(p.length<1)return;const g=Object.keys(p)[0];let A=!1;if(g.endsWith("usda"))return p[g];if(g.endsWith("usdc"))A=!0;else if(g.endsWith("usd"))if(n(p[g]))A=!0;else return p[g];A&&console.warn("THREE.USDZLoader: Crate files (.usdc or binary .usd) are not supported.")}const s=H.unzipSync(new Uint8Array(e)),i=r(s),a=o(s);if(a===void 0)return console.warn("THREE.USDZLoader: No usda file found."),new f.Group;const c=H.strFromU8(a),l=t.parse(c);function u(p){if(p){if("prepend references"in p){const A=p["prepend references"].split("@"),T=A[1].replace(/^.\//,""),x=A[2].replace(/^<\//,"").replace(/>$/,"");return d(i[T],x)}return d(p)}}function d(p,g){if(p){if(g!==void 0){const A=`def Mesh "${g}"`;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 x=d(T);if(x)return x}}}}function m(p){if(!p)return;let g=new f.BufferGeometry;if("int[] faceVertexIndices"in p){const A=JSON.parse(p["int[] faceVertexIndices"]);g.setIndex(A)}if("point3f[] points"in p){const A=JSON.parse(p["point3f[] points"].replace(/[()]*/g,"")),T=new f.BufferAttribute(new Float32Array(A),3);g.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);g.setAttribute("normal",T)}else g.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){g=g.toNonIndexed();const x=JSON.parse(p["int[] primvars:st:indices"]);g.setAttribute("uv",_(T,x))}else g.setAttribute("uv",T)}return g}function _(p,g){const A=p.array,T=p.itemSize,x=new A.constructor(g.length*T);let Y=0,ce=0;for(let v=0,le=g.length;v<le;v++){Y=g[v]*T;for(let J=0;J<T;J++)x[ce++]=A[Y++]}return new f.BufferAttribute(x,T)}function w(p){if(p){if("rel material:binding"in p){const T=p["rel material:binding"].replace(/^<\//,"").replace(/>$/,"").split("/");return y(l,` "${T[1]}"`)}return y(p)}}function y(p,g=""){for(const A in p){const T=p[A];if(A.startsWith("def Material"+g))return T;if(typeof T=="object"){const x=y(T,g);if(x)return x}}}function R(p,g){g["float inputs:rotation"]&&(p.rotation=parseFloat(g["float inputs:rotation"])),g["float2 inputs:scale"]&&(p.repeat=new f.Vector2().fromArray(JSON.parse("["+g["float2 inputs:scale"].replace(/[()]*/g,"")+"]"))),g["float2 inputs:translation"]&&(p.offset=new f.Vector2().fromArray(JSON.parse("["+g["float2 inputs:translation"].replace(/[()]*/g,"")+"]")))}function E(p){const g=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"],x=L(l,/(\w+).output/.exec(T)[1]);g.map=S(x),g.map.colorSpace=f.SRGBColorSpace,'def Shader "Transform2d_diffuse"'in p&&R(g.map,p['def Shader "Transform2d_diffuse"'])}else if("color3f inputs:diffuseColor"in A){const T=A["color3f inputs:diffuseColor"].replace(/[()]*/g,"");g.color.fromArray(JSON.parse("["+T+"]"))}if("color3f inputs:emissiveColor.connect"in A){const T=A["color3f inputs:emissiveColor.connect"],x=L(l,/(\w+).output/.exec(T)[1]);g.emissiveMap=S(x),g.emissiveMap.colorSpace=f.SRGBColorSpace,g.emissive.set(16777215),'def Shader "Transform2d_emissive"'in p&&R(g.emissiveMap,p['def Shader "Transform2d_emissive"'])}else if("color3f inputs:emissiveColor"in A){const T=A["color3f inputs:emissiveColor"].replace(/[()]*/g,"");g.emissive.fromArray(JSON.parse("["+T+"]"))}if("normal3f inputs:normal.connect"in A){const T=A["normal3f inputs:normal.connect"],x=L(l,/(\w+).output/.exec(T)[1]);g.normalMap=S(x),g.normalMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_normal"'in p&&R(g.normalMap,p['def Shader "Transform2d_normal"'])}if("float inputs:roughness.connect"in A){const T=A["float inputs:roughness.connect"],x=L(l,/(\w+).output/.exec(T)[1]);g.roughness=1,g.roughnessMap=S(x),g.roughnessMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_roughness"'in p&&R(g.roughnessMap,p['def Shader "Transform2d_roughness"'])}else"float inputs:roughness"in A&&(g.roughness=parseFloat(A["float inputs:roughness"]));if("float inputs:metallic.connect"in A){const T=A["float inputs:metallic.connect"],x=L(l,/(\w+).output/.exec(T)[1]);g.metalness=1,g.metalnessMap=S(x),g.metalnessMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_metallic"'in p&&R(g.metalnessMap,p['def Shader "Transform2d_metallic"'])}else"float inputs:metallic"in A&&(g.metalness=parseFloat(A["float inputs:metallic"]));if("float inputs:clearcoat.connect"in A){const T=A["float inputs:clearcoat.connect"],x=L(l,/(\w+).output/.exec(T)[1]);g.clearcoat=1,g.clearcoatMap=S(x),g.clearcoatMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_clearcoat"'in p&&R(g.clearcoatMap,p['def Shader "Transform2d_clearcoat"'])}else"float inputs:clearcoat"in A&&(g.clearcoat=parseFloat(A["float inputs:clearcoat"]));if("float inputs:clearcoatRoughness.connect"in A){const T=A["float inputs:clearcoatRoughness.connect"],x=L(l,/(\w+).output/.exec(T)[1]);g.clearcoatRoughness=1,g.clearcoatRoughnessMap=S(x),g.clearcoatRoughnessMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_clearcoatRoughness"'in p&&R(g.clearcoatRoughnessMap,p['def Shader "Transform2d_clearcoatRoughness"'])}else"float inputs:clearcoatRoughness"in A&&(g.clearcoatRoughness=parseFloat(A["float inputs:clearcoatRoughness"]));if("float inputs:ior"in A&&(g.ior=parseFloat(A["float inputs:ior"])),"float inputs:occlusion.connect"in A){const T=A["float inputs:occlusion.connect"],x=L(l,/(\w+).output/.exec(T)[1]);g.aoMap=S(x),g.aoMap.colorSpace=f.NoColorSpace,'def Shader "Transform2d_occlusion"'in p&&R(g.aoMap,p['def Shader "Transform2d_occlusion"'])}}if('def Shader "diffuseColor_texture"'in p){const A=p['def Shader "diffuseColor_texture"'];g.map=S(A),g.map.colorSpace=f.SRGBColorSpace}if('def Shader "normal_texture"'in p){const A=p['def Shader "normal_texture"'];g.normalMap=S(A),g.normalMap.colorSpace=f.NoColorSpace}}return g}function L(p,g){for(const A in p){const T=p[A];if(A.startsWith(`def Shader "${g}"`))return T;if(typeof T=="object"){const x=L(T,g);if(x)return x}}}function S(p){if("asset inputs:file"in p){const g=p["asset inputs:file"].replace(/@*/g,""),T=new f.TextureLoader().load(i[g]),x={'"clamp"':f.ClampToEdgeWrapping,'"mirror"':f.MirroredRepeatWrapping,'"repeat"':f.RepeatWrapping};return"token inputs:wrapS"in p&&(T.wrapS=x[p["token inputs:wrapS"]]),"token inputs:wrapT"in p&&(T.wrapT=x[p["token inputs:wrapT"]]),T}return null}function C(p){const g=m(u(p)),A=E(w(p)),T=g?new f.Mesh(g,A):new f.Object3D;if("matrix4d xformOp:transform"in p){const x=JSON.parse("["+p["matrix4d xformOp:transform"].replace(/[()]*/g,"")+"]");T.matrix.fromArray(x),T.matrix.decompose(T.position,T.quaternion,T.scale)}return T}function I(p,g){for(const A in p)if(A.startsWith("def Scope"))I(p[A],g);else if(A.startsWith("def Xform")){const T=C(p[A]);/def Xform "(\w+)"/.test(A)&&(T.name=/def Xform "(\w+)"/.exec(A)[1]),g.add(T),I(p[A],T)}}const M=new f.Group;return I(l,M),M}}const V=new WeakMap;class Ye 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,r,n){const o=new f.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,s=>{this.parse(s,t,n)},r,n)}parse(e,t,r=()=>{}){this.decodeDracoFile(e,t,null,null,f.SRGBColorSpace).catch(r)}decodeDracoFile(e,t,r,n,o=f.LinearSRGBColorSpace,s=()=>{}){const i={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:o};return this.decodeGeometry(e,i).then(t).catch(s)}decodeGeometry(e,t){const r=JSON.stringify(t);if(V.has(e)){const a=V.get(e);if(a.key===r)return a.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 n;const o=this.workerNextTaskID++,s=e.byteLength,i=this._getWorker(o,s).then(a=>(n=a,new Promise((c,l)=>{n._callbacks[o]={resolve:c,reject:l},n.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return i.catch(()=>!0).then(()=>{n&&o&&this._releaseTask(n,o)}),V.set(e,{key:r,promise:i}),i}_createGeometry(e){const t=new f.BufferGeometry;e.index&&t.setIndex(new f.BufferAttribute(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const n=e.attributes[r],o=n.name,s=n.array,i=n.itemSize,a=new f.BufferAttribute(s,i);o==="color"&&(this._assignVertexColorSpace(a,n.vertexColorSpace),a.normalized=!(s instanceof Float32Array)),t.setAttribute(o,a)}return t}_assignVertexColorSpace(e,t){if(t!==f.SRGBColorSpace)return;const r=new f.Color;for(let n=0,o=e.count;n<o;n++)r.fromBufferAttribute(e,n).convertSRGBToLinear(),e.setXYZ(n,r.r,r.g,r.b)}_loadLibrary(e,t){const r=new f.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((n,o)=>{r.load(e,n,void 0,o)})}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(r=>{const n=r[0];e||(this.decoderConfig.wasmBinary=r[1]);const o=Je.toString(),s=["/* draco decoder */",n,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
3
3
  `);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(o){const s=o.data;switch(s.type){case"decode":n._callbacks[s.id].resolve(s);break;case"error":n._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,o){return n._taskLoad>o._taskLoad?-1:1});const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_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 Je(){let h,e;onmessage=function(s){const i=s.data;switch(i.type){case"init":h=i.decoderConfig,e=new Promise(function(l){h.onModuleLoaded=function(u){l({draco:u})},DracoDecoderModule(h)});break;case"decode":const a=i.buffer,c=i.taskConfig;e.then(l=>{const u=l.draco,d=new u.Decoder;try{const m=t(u,d,new Int8Array(a),c),_=m.attributes.map(w=>w.array.buffer);m.index&&_.push(m.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:m},_)}catch(m){console.error(m),self.postMessage({type:"error",id:i.id,error:m.message})}finally{u.destroy(d)}});break}};function t(s,i,a,c){const l=c.attributeIDs,u=c.attributeTypes;let d,m;const _=i.GetEncodedGeometryType(a);if(_===s.TRIANGULAR_MESH)d=new s.Mesh,m=i.DecodeArrayToMesh(a,a.byteLength,d);else if(_===s.POINT_CLOUD)d=new s.PointCloud,m=i.DecodeArrayToPointCloud(a,a.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!m.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+m.error_msg());const w={index:null,attributes:[]};for(const y in l){const R=self[u[y]];let E,L;if(c.useUniqueIDs)L=l[y],E=i.GetAttributeByUniqueId(d,L);else{if(L=i.GetAttributeId(d,s[l[y]]),L===-1)continue;E=i.GetAttribute(d,L)}const S=n(s,i,d,y,R,E);y==="color"&&(S.vertexColorSpace=c.vertexColorSpace),w.attributes.push(S)}return _===s.TRIANGULAR_MESH&&(w.index=r(s,i,d)),s.destroy(d),w}function r(s,i,a){const l=a.num_faces()*3,u=l*4,d=s._malloc(u);i.GetTrianglesUInt32Array(a,u,d);const m=new Uint32Array(s.HEAPF32.buffer,d,l).slice();return s._free(d),{array:m,itemSize:1}}function n(s,i,a,c,l,u){const d=u.num_components(),_=a.num_points()*d,w=_*l.BYTES_PER_ELEMENT,y=o(s,l),R=s._malloc(w);i.GetAttributeDataArrayForAllPoints(a,u,y,w,R);const E=new l(s.HEAPF32.buffer,R,_).slice();return s._free(R),{name:c,array:E,itemSize:d}}function o(s,i){switch(i){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}function ie(){let h,e;onmessage=function(s){const i=s.data;switch(i.type){case"init":h=i.decoderConfig,e=new Promise(function(l){h.onModuleLoaded=function(u){l({draco:u})},DracoDecoderModule(h)});break;case"decode":const a=i.buffer,c=i.taskConfig;e.then(l=>{const u=l.draco,d=new u.Decoder;try{const m=t(u,d,new Int8Array(a),c),_=m.attributes.map(w=>w.array.buffer);m.index&&_.push(m.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:m},_)}catch(m){console.error(m),self.postMessage({type:"error",id:i.id,error:m.message})}finally{u.destroy(d)}});break}};function t(s,i,a,c){const l=c.attributeIDs,u=c.attributeTypes;let d,m;const _=i.GetEncodedGeometryType(a);if(_===s.TRIANGULAR_MESH)d=new s.Mesh,m=i.DecodeArrayToMesh(a,a.byteLength,d);else if(_===s.POINT_CLOUD)d=new s.PointCloud,m=i.DecodeArrayToPointCloud(a,a.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!m.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+m.error_msg());const w={index:null,attributes:[]};for(const y in l){const R=self[u[y]];let E,L;if(c.useUniqueIDs)L=l[y],E=i.GetAttributeByUniqueId(d,L);else{if(L=i.GetAttributeId(d,s[l[y]]),L===-1)continue;E=i.GetAttribute(d,L)}const S=n(s,i,d,y,R,E);y==="color"&&(S.vertexColorSpace=c.vertexColorSpace),w.attributes.push(S)}return _===s.TRIANGULAR_MESH&&(w.index=r(s,i,d)),s.destroy(d),w}function r(s,i,a){const l=a.num_faces()*3,u=l*4,d=s._malloc(u);i.GetTrianglesUInt32Array(a,u,d);const m=new Uint32Array(s.HEAPF32.buffer,d,l).slice();return s._free(d),{array:m,itemSize:1}}function n(s,i,a,c,l,u){const d=u.num_components(),_=a.num_points()*d,w=_*l.BYTES_PER_ELEMENT,y=o(s,l),R=s._malloc(w);i.GetAttributeDataArrayForAllPoints(a,u,y,w,R);const E=new l(s.HEAPF32.buffer,R,_).slice();return s._free(R),{name:c,array:E,itemSize:d}}function o(s,i){switch(i){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}const X={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 ae extends Ye{constructor(){super(...arguments);O(this,"decoderPending",null);O(this,"decoderConfig",{type:"js",wasmBinary:null});O(this,"workerSourceURL","")}async _initDecoder(){if(this.decoderPending)return this.decoderPending;const t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",r=[];return t?r.push(X.LOAD_DRACO_JS_DECODER()):(r.push(X.LOAD_DRACO_WASM_WRAPPER()),r.push(X.LOAD_DRACO_WASM_DECODER())),this.decoderPending=Promise.all(r).then(n=>{const o=n[0];t||(this.decoderConfig.wasmBinary=n[1]);const s=ie.toString(),i=["/* draco decoder */",o,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
4
4
  `);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}}function Qe(){let h=null,e=null;const t=[[/'CONFIG_CONTROL_DESIGN'\s*\)/g,"'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF')"],[/'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF\.\s*\{[\s\S]*?\}\s*'/g,"'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF'"]];function r(){return h||(h=occtimportjs({locateFile:function(){return e}})),h}function n(s){for(var i=new TextDecoder("utf-8",{fatal:!1}),a=new TextEncoder,c=i.decode(s),l=0;l<t.length;l++){var u=t[l][0],d=t[l][1];c=c.replace(u,d)}return new Uint8Array(a.encode(c))}function o(s,i){var a=n(i);try{var c=s.ReadStepFile(a,null);if(c.success&&c.root)return c}catch{}try{return s.ReadStepFile(i,null)}catch{return{success:!1,root:{meshes:[],children:[]},meshes:[]}}}onmessage=async function(s){var i=s.data;switch(i.type){case"init":e=i.wasmUrl;break;case"parse":try{var a=await r(),c=new Uint8Array(i.buffer),l=i.fileType,u;if(l==="step"||l==="stp"?u=o(a,c):u=a.ReadIgesFile(c,null),!u.success||!u.root){self.postMessage({type:"error",id:i.id,error:"Failed to parse CAD file"});return}self.postMessage({type:"result",id:i.id,result:u})}catch(d){self.postMessage({type:"error",id:i.id,error:d instanceof Error?d.message:String(d)})}break}}}const se={LOAD_OCCT_JS:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-DdbbsFBH.cjs"))).default,LOAD_OCCT_WASM_URL:async()=>(await Promise.resolve().then(()=>require("./occt-import-js-BQ1yZHCj.cjs"))).default};class Ze{constructor(){O(this,"_workerPending",null);O(this,"_worker",null);O(this,"_nextId",0);O(this,"_pending",new Map)}_getWorker(){return this._workerPending?this._workerPending:(this._workerPending=(async()=>{const[e,t]=await Promise.all([se.LOAD_OCCT_JS(),se.LOAD_OCCT_WASM_URL()]),r=Qe.toString(),n=["/* occt-import-js */",e,"","/* step worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
@@ -60,7 +60,7 @@ class g extends l {
60
60
  const r = t ?? this._actions.keys().next().value ?? void 0;
61
61
  if (r === void 0) return this;
62
62
  const e = this._actions.get(r);
63
- return e ? (this._currentAction && this._currentAction !== e && (this._currentAction.fadeOut(0.3), e.reset().fadeIn(0.3)), e.loop = this._resolveLoopConstant(this._loop), e.play(), this._currentAction = e, this._state = "playing", this.dispatchEvent({ type: "play", target: this }), this) : this;
63
+ return e ? (this._currentAction && this._currentAction !== e ? (this._currentAction.fadeOut(0.3), e.reset().fadeIn(0.3)) : this._state === "idle" && e.reset(), e.loop = this._resolveLoopConstant(this._loop), e.play(), this._currentAction = e, this._state = "playing", this.dispatchEvent({ type: "play", target: this }), this) : this;
64
64
  }
65
65
  pause() {
66
66
  return this._state = "paused", this._currentAction && (this._currentAction.paused = !0), this.dispatchEvent({ type: "pause", target: this }), this;
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var h=(s,i,t)=>i in s?a(s,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[i]=t;var n=(s,i,t)=>h(s,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("three"),u=require("./Animator-Cu7NIkVg.cjs");class p extends u.Animator{constructor(t,o){super();n(this,"_mixer");n(this,"_actions",new Map);n(this,"_currentAction",null);n(this,"_state","idle");n(this,"_loop","once");this._mixer=new r.AnimationMixer(t);for(const e of o){const c=this._mixer.clipAction(e);c.clampWhenFinished=!0,c.loop=r.LoopOnce,this._actions.set(e.name,c)}this._mixer.addEventListener("finished",()=>{this._state="idle",this.dispatchEvent({type:"complete",target:this})})}get state(){return this._state}get duration(){var t;return((t=this._currentAction)==null?void 0:t.getClip().duration)??0}get loop(){return this._loop}set loop(t){this._loop=t,this._currentAction&&(this._currentAction.loop=this._resolveLoopConstant(t))}_resolveLoopConstant(t){switch(t){case"repeat":return r.LoopRepeat;case"pingpong":return r.LoopPingPong;default:return r.LoopOnce}}get time(){var t;return((t=this._currentAction)==null?void 0:t.time)??0}set time(t){this._currentAction&&(this._currentAction.time=t)}get clipNames(){return[...this._actions.keys()]}get currentClipName(){return this._currentAction?this._currentAction.getClip().name:null}play(t){const o=t??this._actions.keys().next().value??void 0;if(o===void 0)return this;const e=this._actions.get(o);return e?(this._currentAction&&this._currentAction!==e&&(this._currentAction.fadeOut(.3),e.reset().fadeIn(.3)),e.loop=this._resolveLoopConstant(this._loop),e.play(),this._currentAction=e,this._state="playing",this.dispatchEvent({type:"play",target:this}),this):this}pause(){return this._state="paused",this._currentAction&&(this._currentAction.paused=!0),this.dispatchEvent({type:"pause",target:this}),this}resume(){return this._state="playing",this._currentAction&&(this._currentAction.paused=!1),this.dispatchEvent({type:"resume",target:this}),this}stop(){return this._state="idle",this._mixer.stopAllAction(),this._currentAction=null,this.dispatchEvent({type:"stop",target:this}),this}update(t){this._mixer.update(t)}dispose(){this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._mixer.getRoot()),this._actions.clear(),this._currentAction=null,this._state="idle"}}exports.ClipAnimator=p;
1
+ "use strict";var a=Object.defineProperty;var h=(s,i,t)=>i in s?a(s,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[i]=t;var n=(s,i,t)=>h(s,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("three"),u=require("./Animator-Cu7NIkVg.cjs");class p extends u.Animator{constructor(t,o){super();n(this,"_mixer");n(this,"_actions",new Map);n(this,"_currentAction",null);n(this,"_state","idle");n(this,"_loop","once");this._mixer=new r.AnimationMixer(t);for(const e of o){const c=this._mixer.clipAction(e);c.clampWhenFinished=!0,c.loop=r.LoopOnce,this._actions.set(e.name,c)}this._mixer.addEventListener("finished",()=>{this._state="idle",this.dispatchEvent({type:"complete",target:this})})}get state(){return this._state}get duration(){var t;return((t=this._currentAction)==null?void 0:t.getClip().duration)??0}get loop(){return this._loop}set loop(t){this._loop=t,this._currentAction&&(this._currentAction.loop=this._resolveLoopConstant(t))}_resolveLoopConstant(t){switch(t){case"repeat":return r.LoopRepeat;case"pingpong":return r.LoopPingPong;default:return r.LoopOnce}}get time(){var t;return((t=this._currentAction)==null?void 0:t.time)??0}set time(t){this._currentAction&&(this._currentAction.time=t)}get clipNames(){return[...this._actions.keys()]}get currentClipName(){return this._currentAction?this._currentAction.getClip().name:null}play(t){const o=t??this._actions.keys().next().value??void 0;if(o===void 0)return this;const e=this._actions.get(o);return e?(this._currentAction&&this._currentAction!==e?(this._currentAction.fadeOut(.3),e.reset().fadeIn(.3)):this._state==="idle"&&e.reset(),e.loop=this._resolveLoopConstant(this._loop),e.play(),this._currentAction=e,this._state="playing",this.dispatchEvent({type:"play",target:this}),this):this}pause(){return this._state="paused",this._currentAction&&(this._currentAction.paused=!0),this.dispatchEvent({type:"pause",target:this}),this}resume(){return this._state="playing",this._currentAction&&(this._currentAction.paused=!1),this.dispatchEvent({type:"resume",target:this}),this}stop(){return this._state="idle",this._mixer.stopAllAction(),this._currentAction=null,this.dispatchEvent({type:"stop",target:this}),this}update(t){this._mixer.update(t)}dispose(){this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._mixer.getRoot()),this._actions.clear(),this._currentAction=null,this._state="idle"}}exports.ClipAnimator=p;
@@ -1975,7 +1975,7 @@ class mi {
1975
1975
  ), this._clock.addTicker(this._orientationDisplay);
1976
1976
  }
1977
1977
  ), this._settings.autoStart && this.start(), console.log(
1978
- "DIVE 2.3.0 initialized successfully!"
1978
+ "DIVE 2.3.1 initialized successfully!"
1979
1979
  ), console.log(Di), window.DIVE.instances.push(this);
1980
1980
  }
1981
1981
  /**
@@ -30,4 +30,4 @@
30
30
  @@%-::::::::::::-%@ @%-------------=%@@
31
31
  @@@@+:::::::#@@ @@*-------*@@@@
32
32
  @@@@@@@ @@@@@@
33
- `;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const O={autoStart:!0,displayAxes:!1,...M,...G.DIVEPerspectiveCameraDefaultSettings,...x,...zA};class CA{constructor(t){i(this,"_instanceId",g.MathUtils.generateUUID());i(this,"_settings");i(this,"_views");i(this,"_mainView");i(this,"_scene");i(this,"_clock");i(this,"_orientationDisplay",null);this._settings={...O,...t??{}},this._clock=new AA,this._scene=new IA({backgroundColor:(t==null?void 0:t.backgroundColor)??O.backgroundColor,displayGrid:(t==null?void 0:t.displayGrid)??O.displayGrid,displayFloor:(t==null?void 0:t.displayFloor)??O.displayFloor});const A=new k(this._scene,new G.DIVEPerspectiveCamera,this._settings);this._clock.addTicker(A),this._views=[A],this._mainView=A,this._settings.displayAxes&&Promise.resolve().then(()=>require("../plugins/orientationdisplay/index.cjs")).then(({OrientationDisplay:e})=>{this._orientationDisplay=new e(this.mainView.renderer,this.scene,this.mainView.camera),this._clock.addTicker(this._orientationDisplay)}),this._settings.autoStart&&this.start(),console.log("DIVE 2.3.0 initialized successfully!"),console.log(KA),window.DIVE.instances.push(this)}static async QuickView(t,A){return Promise.resolve().then(()=>require("../plugins/quickview/index.cjs")).then(({QuickView:e})=>e(t,A))}get engine(){return{scene:this.scene,camera:this.mainView.camera,renderer:this.mainView.renderer,setCanvas:t=>{this.mainView.setCanvas(t)},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(t=>{this._views.forEach(A=>{A.dispose()}),this._views=[],this._orientationDisplay&&(this._clock.removeTicker(this._orientationDisplay),this._orientationDisplay.dispose()),this.scene.dispose(),window.DIVE.instances=window.DIVE.instances.filter(A=>A._instanceId!==this._instanceId),t()})}createView(t){const A=new k(this._scene,t??new G.DIVEPerspectiveCamera,{...this._settings,canvas:void 0});return this._views.push(A),this._clock.addTicker(A),this._views.length===1&&(this._mainView=A),A}disposeView(t){this._views=this._views.filter(A=>A!==t),this._clock.removeTicker(t),this._mainView===t&&(this._mainView=this._views[0]),t.dispose()}}const lA=CA,wA={glb:{key:"glb",extension:"glb"},gltf:{key:"gltf",extension:"gltf"},usdz:{key:"usdz",extension:"usdz"},step:{key:"step",extension:"step"},stp:{key:"stp",extension:"stp"},iges:{key:"iges",extension:"iges"},igs:{key:"igs",extension:"igs"}},vA=Object.values(wA).map(r=>r.extension);exports.BoundingBox=E;exports.DIVE=CA;exports.DIVEAmbientLight=oA;exports.DIVEClock=AA;exports.DIVEDefaultSettings=O;exports.DIVEEngine=lA;exports.DIVEEnvironment=gA;exports.DIVEEnvironmentDefaultSettings=iA;exports.DIVEFloor=rA;exports.DIVEGrid=PA;exports.DIVEGroup=hA;exports.DIVEModel=_;exports.DIVENode=Z;exports.DIVEPointLight=sA;exports.DIVEPrimitive=fA;exports.DIVERenderPipeline=pA;exports.DIVERenderer=S;exports.DIVERendererDefaultSettings=x;exports.DIVEResizeManager=tA;exports.DIVERoot=aA;exports.DIVEScene=IA;exports.DIVESceneDefaultSettings=M;exports.DIVESceneLight=nA;exports.DIVEView=k;exports.FILE_TYPES=wA;exports.GRID_CENTER_LINE_COLOR=BA;exports.GRID_SIDE_LINE_COLOR=cA;exports.OrbitController=T;exports.OrbitControllerDefaultSettings=zA;exports.SUPPORTED_FILE_TYPES=vA;exports.findSceneRecursive=J;
33
+ `;window.DIVE={instances:[],get instance(){return window.DIVE.instances[0]}};const O={autoStart:!0,displayAxes:!1,...M,...G.DIVEPerspectiveCameraDefaultSettings,...x,...zA};class CA{constructor(t){i(this,"_instanceId",g.MathUtils.generateUUID());i(this,"_settings");i(this,"_views");i(this,"_mainView");i(this,"_scene");i(this,"_clock");i(this,"_orientationDisplay",null);this._settings={...O,...t??{}},this._clock=new AA,this._scene=new IA({backgroundColor:(t==null?void 0:t.backgroundColor)??O.backgroundColor,displayGrid:(t==null?void 0:t.displayGrid)??O.displayGrid,displayFloor:(t==null?void 0:t.displayFloor)??O.displayFloor});const A=new k(this._scene,new G.DIVEPerspectiveCamera,this._settings);this._clock.addTicker(A),this._views=[A],this._mainView=A,this._settings.displayAxes&&Promise.resolve().then(()=>require("../plugins/orientationdisplay/index.cjs")).then(({OrientationDisplay:e})=>{this._orientationDisplay=new e(this.mainView.renderer,this.scene,this.mainView.camera),this._clock.addTicker(this._orientationDisplay)}),this._settings.autoStart&&this.start(),console.log("DIVE 2.3.1 initialized successfully!"),console.log(KA),window.DIVE.instances.push(this)}static async QuickView(t,A){return Promise.resolve().then(()=>require("../plugins/quickview/index.cjs")).then(({QuickView:e})=>e(t,A))}get engine(){return{scene:this.scene,camera:this.mainView.camera,renderer:this.mainView.renderer,setCanvas:t=>{this.mainView.setCanvas(t)},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(t=>{this._views.forEach(A=>{A.dispose()}),this._views=[],this._orientationDisplay&&(this._clock.removeTicker(this._orientationDisplay),this._orientationDisplay.dispose()),this.scene.dispose(),window.DIVE.instances=window.DIVE.instances.filter(A=>A._instanceId!==this._instanceId),t()})}createView(t){const A=new k(this._scene,t??new G.DIVEPerspectiveCamera,{...this._settings,canvas:void 0});return this._views.push(A),this._clock.addTicker(A),this._views.length===1&&(this._mainView=A),A}disposeView(t){this._views=this._views.filter(A=>A!==t),this._clock.removeTicker(t),this._mainView===t&&(this._mainView=this._views[0]),t.dispose()}}const lA=CA,wA={glb:{key:"glb",extension:"glb"},gltf:{key:"gltf",extension:"gltf"},usdz:{key:"usdz",extension:"usdz"},step:{key:"step",extension:"step"},stp:{key:"stp",extension:"stp"},iges:{key:"iges",extension:"iges"},igs:{key:"igs",extension:"igs"}},vA=Object.values(wA).map(r=>r.extension);exports.BoundingBox=E;exports.DIVE=CA;exports.DIVEAmbientLight=oA;exports.DIVEClock=AA;exports.DIVEDefaultSettings=O;exports.DIVEEngine=lA;exports.DIVEEnvironment=gA;exports.DIVEEnvironmentDefaultSettings=iA;exports.DIVEFloor=rA;exports.DIVEGrid=PA;exports.DIVEGroup=hA;exports.DIVEModel=_;exports.DIVENode=Z;exports.DIVEPointLight=sA;exports.DIVEPrimitive=fA;exports.DIVERenderPipeline=pA;exports.DIVERenderer=S;exports.DIVERendererDefaultSettings=x;exports.DIVEResizeManager=tA;exports.DIVERoot=aA;exports.DIVEScene=IA;exports.DIVESceneDefaultSettings=M;exports.DIVESceneLight=nA;exports.DIVEView=k;exports.FILE_TYPES=wA;exports.GRID_CENTER_LINE_COLOR=BA;exports.GRID_SIDE_LINE_COLOR=cA;exports.OrbitController=T;exports.OrbitControllerDefaultSettings=zA;exports.SUPPORTED_FILE_TYPES=vA;exports.findSceneRecursive=J;
@@ -1 +1 @@
1
- "use strict";const n=require("./FileTypes-35x8Ekp6.cjs");function o(e){var t;const i=e.split("/").pop()||"";return!i.includes(".")||i.endsWith(".")?"":((t=i.split(".").pop())==null?void 0:t.toLowerCase().split("?")[0])||""}function r(e){return e.toLowerCase()in n.FILE_TYPES}exports.getFileTypeFromUri=o;exports.isFileTypeSupported=r;
1
+ "use strict";const n=require("./FileTypes-BHH0KUFf.cjs");function o(e){var t;const i=e.split("/").pop()||"";return!i.includes(".")||i.endsWith(".")?"":((t=i.split(".").pop())==null?void 0:t.toLowerCase().split("?")[0])||""}function r(e){return e.toLowerCase()in n.FILE_TYPES}exports.getFileTypeFromUri=o;exports.isFileTypeSupported=r;
@@ -1,4 +1,4 @@
1
- import { F as n } from "./FileTypes-BSG8CC2s.mjs";
1
+ import { F as n } from "./FileTypes-B8g1qxjR.mjs";
2
2
  function r(e) {
3
3
  var i;
4
4
  const t = e.split("/").pop() || "";
package/build/dive.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var R=(r,i,e)=>i in r?b(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>R(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-35x8Ekp6.cjs"),u=require("./chunks/PerspectiveCamera-iAsZqrnY.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three"),V=require("./chunks/findInterface-C6mrvf_t.cjs"),y=require("./chunks/isFileTypeSupported-BmjxgShb.cjs"),w=require("./chunks/network-error-CdDXil5g.cjs"),A=require("./chunks/parse-error-Dy_EE4rL.cjs"),P=require("./chunks/PovSchema-Co9FznEz.cjs");class m extends s.Object3D{constructor(e,t,o,h,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 l=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const g=new s.TorusGeometry(t,.1,3,48,o),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(h)}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 p(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function O(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function v(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function x(r,i=0){if(r<0)return-x(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function H(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function z(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function G(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function C(r){return(s.MathUtils.radToDeg(r)+360)%360}function L(r){return s.MathUtils.degToRad(r)}const S={ceilExp:O,floorExp:v,roundExp:x,toFixedExp:z,truncateExp:G,signedAngleTo:H,radToDeg:C,degToRad:L};class T 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 m("x",1,Math.PI/2,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new m("y",1,-Math.PI/2,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new m("z",1,Math.PI/2,new s.Vector3(0,0,1),_.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(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.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(),h=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=S.signedAngleTo(h,o,e.forwardVector),l=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,l)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,h){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(h),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:h,depthTest:!1,depthWrite:!1});const l=new s.Mesh(a,this._lineMaterial);l.layers.mask=u.UI_LAYER_MASK,l.renderOrder=1/0,l.rotateX(Math.PI/2),l.translateY(t/2),this.add(l);const d=new s.CylinderGeometry(.1,.1,t,3),g=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,g),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 Y 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 D("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),_.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(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.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 M extends s.Object3D{constructor(e,t,o,h,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(h),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const l=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,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 g=new s.CylinderGeometry(.1,.1,t+a/2,3),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),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 j 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 M("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new M("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new M("z",1,new s.Vector3(0,0,1),_.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(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.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 N 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 h=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(h,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(l,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 F 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 Y(e),this._rotateGizmo=new T(e),this._scaleGizmo=new j(e),this._gizmoPlane=new N,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 U{constructor(){n(this,"isMovable",!0)}}class K{constructor(){n(this,"isSelectable",!0)}}function X(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const h=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,h)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const h=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,h)})}),r}function f(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 l=0;l<r.length;l++)a[l]=f(r[l],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[l,d]of r)a.set(f(l,i),f(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const l of r)a.add(f(l,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 l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}const h=Object.getOwnPropertySymbols(r);for(const a of h){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}return t}const I=(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],h=i[t];if(o.length===0&&h.length===0){e={...e};return}if(o.length!==h.length){e={...e,[t]:i[t]};return}const a=[];if(h.forEach((l,d)=>{const g=I(o[d],h[d]);Object.keys(g).length&&a.push(h[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=I(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 q(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function Z(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEEngine=c.DIVEEngine;exports.DIVEEnvironment=c.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=c.DIVEEnvironmentDefaultSettings;exports.DIVEFloor=c.DIVEFloor;exports.DIVEGrid=c.DIVEGrid;exports.DIVEGroup=c.DIVEGroup;exports.DIVEModel=c.DIVEModel;exports.DIVENode=c.DIVENode;exports.DIVEPointLight=c.DIVEPointLight;exports.DIVEPrimitive=c.DIVEPrimitive;exports.DIVERenderPipeline=c.DIVERenderPipeline;exports.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;exports.DIVEResizeManager=c.DIVEResizeManager;exports.DIVERoot=c.DIVERoot;exports.DIVEScene=c.DIVEScene;exports.DIVESceneDefaultSettings=c.DIVESceneDefaultSettings;exports.DIVESceneLight=c.DIVESceneLight;exports.DIVEView=c.DIVEView;exports.FILE_TYPES=c.FILE_TYPES;exports.GRID_CENTER_LINE_COLOR=c.GRID_CENTER_LINE_COLOR;exports.GRID_SIDE_LINE_COLOR=c.GRID_SIDE_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.findSceneRecursive=c.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.AxesColorBlue=_.AxesColorBlue;exports.AxesColorBlueLetter=_.AxesColorBlueLetter;exports.AxesColorGreen=_.AxesColorGreen;exports.AxesColorGreenLetter=_.AxesColorGreenLetter;exports.AxesColorRed=_.AxesColorRed;exports.AxesColorRedLetter=_.AxesColorRedLetter;exports.findInterface=V.findInterface;exports.implementsInterface=V.implementsInterface;exports.getFileTypeFromUri=y.getFileTypeFromUri;exports.isFileTypeSupported=y.isFileTypeSupported;exports.FileContentError=w.FileContentError;exports.NetworkError=w.NetworkError;exports.FileTypeError=A.FileTypeError;exports.ParseError=A.ParseError;exports.isModelSchema=P.isModelSchema;exports.isPovSchema=P.isPovSchema;exports.DIVEGizmo=F;exports.DIVEMath=S;exports.DIVEMovable=U;exports.DIVESelectable=K;exports.applyMixins=X;exports.deepClone=f;exports.getObjectDelta=I;exports.isGroupSchema=q;exports.isLightSchema=B;exports.isPrimitiveSchema=Z;
1
+ "use strict";var b=Object.defineProperty;var R=(r,i,e)=>i in r?b(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var n=(r,i,e)=>R(r,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./chunks/FileTypes-BHH0KUFf.cjs"),u=require("./chunks/PerspectiveCamera-iAsZqrnY.cjs"),_=require("./chunks/AxisHelperColors-BrGqktN5.cjs"),s=require("three"),V=require("./chunks/findInterface-C6mrvf_t.cjs"),y=require("./chunks/isFileTypeSupported-CFN9V48s.cjs"),w=require("./chunks/network-error-CdDXil5g.cjs"),A=require("./chunks/parse-error-Dy_EE4rL.cjs"),P=require("./chunks/PovSchema-Co9FznEz.cjs");class m extends s.Object3D{constructor(e,t,o,h,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 l=new s.TorusGeometry(t,.01,13,48,o);this._lineMaterial=new s.MeshBasicMaterial({color:a,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,this._lineMaterial);d.layers.mask=u.UI_LAYER_MASK,d.renderOrder=1/0,this.add(d);const g=new s.TorusGeometry(t,.1,3,48,o),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),this._colliderMesh.visible=!1,this._colliderMesh.layers.mask=u.UI_LAYER_MASK,this._colliderMesh.renderOrder=1/0,this.add(this._colliderMesh),this.lookAt(h)}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 p(r,i){const e=(r+"e").split("e");return+(e[0]+"e"+(+e[1]+(i||0)))}function O(r,i=0){const e=p(r,+i);return p(Math.ceil(e),-i)}function v(r,i=0){const e=p(r,+i);return p(Math.floor(e),-i)}function x(r,i=0){if(r<0)return-x(-r,i);const e=p(r,+i);return p(Math.round(e),-i)}function H(r,i,e){return Math.atan2(r.clone().cross(i).dot(e),i.clone().dot(r))}function z(r,i=0){const e=p(r,+i);return p(Math.round(e),-i).toFixed(i)}function G(r,i=0){const e=p(r,+i);return p(Math.trunc(e),-i)}function C(r){return(s.MathUtils.radToDeg(r)+360)%360}function L(r){return s.MathUtils.degToRad(r)}const S={ceilExp:O,floorExp:v,roundExp:x,toFixedExp:z,truncateExp:G,signedAngleTo:H,radToDeg:C,degToRad:L};class T 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 m("x",1,Math.PI/2,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new m("y",1,-Math.PI/2,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new m("z",1,Math.PI/2,new s.Vector3(0,0,1),_.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(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.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(),h=t.dragStart.clone().sub(this.parent.parent.position).normalize(),a=S.signedAngleTo(h,o,e.forwardVector),l=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,l)}onHandleDragEnd(e){this._startRot=null,this.handleHighlight(e.axis,!1,!1)}}class D extends s.Object3D{constructor(e,t,o,h){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(h),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:h,depthTest:!1,depthWrite:!1});const l=new s.Mesh(a,this._lineMaterial);l.layers.mask=u.UI_LAYER_MASK,l.renderOrder=1/0,l.rotateX(Math.PI/2),l.translateY(t/2),this.add(l);const d=new s.CylinderGeometry(.1,.1,t,3),g=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(d,g),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 Y 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 D("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new D("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new D("z",1,new s.Vector3(0,0,1),_.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(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.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 M extends s.Object3D{constructor(e,t,o,h,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(h),this._colorHover=this._color.clone().multiplyScalar(2),this._hovered=!1,this._highlight=!1,this._boxSize=a;const l=new s.CylinderGeometry(.01,.01,t-a/2,13);this._lineMaterial=new s.MeshBasicMaterial({color:h,depthTest:!1,depthWrite:!1});const d=new s.Mesh(l,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 g=new s.CylinderGeometry(.1,.1,t+a/2,3),E=new s.MeshBasicMaterial({color:16711935,transparent:!0,opacity:.15,depthTest:!1,depthWrite:!1});this._colliderMesh=new s.Mesh(g,E),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 j 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 M("x",1,new s.Vector3(1,0,0),_.AxesColorRed)),this.add(new M("y",1,new s.Vector3(0,1,0),_.AxesColorGreen)),this.add(new M("z",1,new s.Vector3(0,0,1),_.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(h=>{o?h.highlight=h.axis===e&&o:h.highlight=h.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 N 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 h=new s.PlaneGeometry(100,100,2,2),a=e.clone();a.color.set(65280),this._meshY=new s.Mesh(h,a),this._meshY.layers.mask=u.UI_LAYER_MASK,this._meshY.rotateX(-Math.PI/2);const l=new s.PlaneGeometry(100,100,2,2),d=e.clone();d.color.set(255),this._meshZ=new s.Mesh(l,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 F 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 Y(e),this._rotateGizmo=new T(e),this._scaleGizmo=new j(e),this._gizmoPlane=new N,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 U{constructor(){n(this,"isMovable",!0)}}class K{constructor(){n(this,"isSelectable",!0)}}function X(r,i){return i.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(o=>{if(o==="constructor")return;const h=Object.getOwnPropertyDescriptor(e.prototype,o);Object.defineProperty(r.prototype,o,h)});const t=new e;Object.getOwnPropertyNames(t).forEach(o=>{const h=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r.prototype,o,h)})}),r}function f(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 l=0;l<r.length;l++)a[l]=f(r[l],i);return a}if(r instanceof Map){const a=new Map;i.set(r,a);for(const[l,d]of r)a.set(f(l,i),f(d,i));return a}if(r instanceof Set){const a=new Set;i.set(r,a);for(const l of r)a.add(f(l,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 l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}const h=Object.getOwnPropertySymbols(r);for(const a of h){const l=Object.getOwnPropertyDescriptor(r,a);if(l)if(l.value!==void 0){const d=f(l.value,i);Object.defineProperty(t,a,{...l,value:d})}else Object.defineProperty(t,a,l)}return t}const I=(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],h=i[t];if(o.length===0&&h.length===0){e={...e};return}if(o.length!==h.length){e={...e,[t]:i[t]};return}const a=[];if(h.forEach((l,d)=>{const g=I(o[d],h[d]);Object.keys(g).length&&a.push(h[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=I(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 q(r){return r.entityType==="group"}function B(r){return r.entityType==="light"}function Z(r){return r.entityType==="primitive"}exports.BoundingBox=c.BoundingBox;exports.DIVE=c.DIVE;exports.DIVEAmbientLight=c.DIVEAmbientLight;exports.DIVEClock=c.DIVEClock;exports.DIVEDefaultSettings=c.DIVEDefaultSettings;exports.DIVEEngine=c.DIVEEngine;exports.DIVEEnvironment=c.DIVEEnvironment;exports.DIVEEnvironmentDefaultSettings=c.DIVEEnvironmentDefaultSettings;exports.DIVEFloor=c.DIVEFloor;exports.DIVEGrid=c.DIVEGrid;exports.DIVEGroup=c.DIVEGroup;exports.DIVEModel=c.DIVEModel;exports.DIVENode=c.DIVENode;exports.DIVEPointLight=c.DIVEPointLight;exports.DIVEPrimitive=c.DIVEPrimitive;exports.DIVERenderPipeline=c.DIVERenderPipeline;exports.DIVERenderer=c.DIVERenderer;exports.DIVERendererDefaultSettings=c.DIVERendererDefaultSettings;exports.DIVEResizeManager=c.DIVEResizeManager;exports.DIVERoot=c.DIVERoot;exports.DIVEScene=c.DIVEScene;exports.DIVESceneDefaultSettings=c.DIVESceneDefaultSettings;exports.DIVESceneLight=c.DIVESceneLight;exports.DIVEView=c.DIVEView;exports.FILE_TYPES=c.FILE_TYPES;exports.GRID_CENTER_LINE_COLOR=c.GRID_CENTER_LINE_COLOR;exports.GRID_SIDE_LINE_COLOR=c.GRID_SIDE_LINE_COLOR;exports.SUPPORTED_FILE_TYPES=c.SUPPORTED_FILE_TYPES;exports.findSceneRecursive=c.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.AxesColorBlue=_.AxesColorBlue;exports.AxesColorBlueLetter=_.AxesColorBlueLetter;exports.AxesColorGreen=_.AxesColorGreen;exports.AxesColorGreenLetter=_.AxesColorGreenLetter;exports.AxesColorRed=_.AxesColorRed;exports.AxesColorRedLetter=_.AxesColorRedLetter;exports.findInterface=V.findInterface;exports.implementsInterface=V.implementsInterface;exports.getFileTypeFromUri=y.getFileTypeFromUri;exports.isFileTypeSupported=y.isFileTypeSupported;exports.FileContentError=w.FileContentError;exports.NetworkError=w.NetworkError;exports.FileTypeError=A.FileTypeError;exports.ParseError=A.ParseError;exports.isModelSchema=P.isModelSchema;exports.isPovSchema=P.isPovSchema;exports.DIVEGizmo=F;exports.DIVEMath=S;exports.DIVEMovable=U;exports.DIVESelectable=K;exports.applyMixins=X;exports.deepClone=f;exports.getObjectDelta=I;exports.isGroupSchema=q;exports.isLightSchema=B;exports.isPrimitiveSchema=Z;
package/build/dive.mjs CHANGED
@@ -1,14 +1,14 @@
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 { B as ot, b as ht, d as lt, e as ct, D as dt, f as pt, g as ut, h as ft, i as _t, j as gt, k as mt, c as Et, l as Dt, m as wt, n as yt, o as Mt, p as xt, q as It, r as Pt, s as Vt, t as bt, u as Ht, v as zt, w as vt, F as Ot, G as St, x as At, S as Gt, y as Rt } from "./chunks/FileTypes-BSG8CC2s.mjs";
4
+ import { B as ot, b as ht, d as lt, e as ct, D as dt, f as pt, g as ut, h as ft, i as _t, j as gt, k as mt, c as Et, l as Dt, m as wt, n as yt, o as Mt, p as xt, q as It, r as Pt, s as Vt, t as bt, u as Ht, v as zt, w as vt, F as Ot, G as St, x as At, S as Gt, y as Rt } from "./chunks/FileTypes-B8g1qxjR.mjs";
5
5
  import { U as d } from "./chunks/PerspectiveCamera-BFzE2TQU.mjs";
6
6
  import { C as Yt, b as jt, D as Ct, a as Lt, H as Nt, P as Xt } from "./chunks/PerspectiveCamera-BFzE2TQU.mjs";
7
7
  import { A as I, a as P, b as V } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
8
8
  import { e as Zt, d as qt, c as Qt } from "./chunks/AxisHelperColors-JLBHYQDi.mjs";
9
9
  import { Object3D as f, Color as b, Vector3 as c, TorusGeometry as H, MeshBasicMaterial as g, Mesh as p, MathUtils as v, Euler as G, CylinderGeometry as E, BoxGeometry as R, PlaneGeometry as w } from "three";
10
10
  import { f as kt, i as Ut } from "./chunks/findInterface-DbJ5qzbc.mjs";
11
- import { g as Kt, i as Jt } from "./chunks/isFileTypeSupported-DBPOEmTI.mjs";
11
+ import { g as Kt, i as Jt } from "./chunks/isFileTypeSupported-DA7cjOZa.mjs";
12
12
  import { F as te, N as ee } from "./chunks/network-error-BONfHWQq.mjs";
13
13
  import { F as se, P as ie } from "./chunks/parse-error-DfOPyLWM.mjs";
14
14
  import { i as ae, a as oe } from "./chunks/PovSchema-DWWvr_ED.mjs";
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var u=(s,t,e)=>t in s?m(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var n=(s,t,e)=>u(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@tweenjs/tween.js"),c=require("three");class l{constructor(){n(this,"uuid",c.MathUtils.generateUUID());n(this,"Easing",o.Easing);n(this,"_animators",new Map)}dispose(){for(const t of this._animators.values())t.dispose();this._animators.clear()}tick(t){for(const e of this._animators.values())e.update(t)}async animate(t,e,i){const a=await this.fromTargets(t,e,i);return a.play(),a}async fromTargets(t,e,i){const{TargetAnimator:a}=await Promise.resolve().then(()=>require("../../chunks/TargetAnimator-DuqPk2eq.cjs")),r=new a(t,e,i);return this._animators.set(r.uuid,r),r}async fromClips(t,e){const{ClipAnimator:i}=await Promise.resolve().then(()=>require("../../chunks/ClipAnimator-BcDOC3qJ.cjs")),a=new i(t,e);return this._animators.set(a.uuid,a),a}remove(t){const e=this._animators.get(t);if(!e){console.warn(`Animator with uuid ${t} not found`);return}e.dispose(),this._animators.delete(t)}}Object.defineProperty(exports,"Easing",{enumerable:!0,get:()=>o.Easing});exports.AnimationSystem=l;
1
+ "use strict";var m=Object.defineProperty;var u=(s,t,e)=>t in s?m(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var n=(s,t,e)=>u(s,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@tweenjs/tween.js"),c=require("three");class l{constructor(){n(this,"uuid",c.MathUtils.generateUUID());n(this,"Easing",o.Easing);n(this,"_animators",new Map)}dispose(){for(const t of this._animators.values())t.dispose();this._animators.clear()}tick(t){for(const e of this._animators.values())e.update(t)}async animate(t,e,i){const a=await this.fromTargets(t,e,i);return a.play(),a}async fromTargets(t,e,i){const{TargetAnimator:a}=await Promise.resolve().then(()=>require("../../chunks/TargetAnimator-DuqPk2eq.cjs")),r=new a(t,e,i);return this._animators.set(r.uuid,r),r}async fromClips(t,e){const{ClipAnimator:i}=await Promise.resolve().then(()=>require("../../chunks/ClipAnimator-CNKeT7rW.cjs")),a=new i(t,e);return this._animators.set(a.uuid,a),a}remove(t){const e=this._animators.get(t);if(!e){console.warn(`Animator with uuid ${t} not found`);return}e.dispose(),this._animators.delete(t)}}Object.defineProperty(exports,"Easing",{enumerable:!0,get:()=>o.Easing});exports.AnimationSystem=l;
@@ -78,7 +78,7 @@ class l {
78
78
  * @returns Promise<ClipAnimator>.
79
79
  */
80
80
  async fromClips(t, a) {
81
- const { ClipAnimator: s } = await import("../../chunks/ClipAnimator-BL9qzfWl.mjs"), o = new s(t, a);
81
+ const { ClipAnimator: s } = await import("../../chunks/ClipAnimator-BJZ4_C4B.mjs"), o = new s(t, a);
82
82
  return this._animators.set(o.uuid, o), o;
83
83
  }
84
84
  /**
@@ -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-Drtmvqgs.cjs"),w=require("../../chunks/AssetExporter-Bqv27MWV.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-uFMzuJWt.cjs"),w=require("../../chunks/AssetExporter-Bqv27MWV.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-Dcr75VNw.mjs";
6
+ import { A as _ } from "../../chunks/AssetLoader-C-PfRr8Z.mjs";
7
7
  import { A as f } from "../../chunks/AssetExporter-BBaDvZ8D.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-BZhTsybC.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../chunks/AssetCache-CwK-0iP9.cjs");exports.AssetCache=e.AssetCache;exports.Chunk=e.Chunk;
@@ -1,4 +1,4 @@
1
- import { A as e, C } from "../../chunks/AssetCache-p0Zr71Yh.mjs";
1
+ import { A as e, C } from "../../chunks/AssetCache-BN-AmXc9.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-Drtmvqgs.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-uFMzuJWt.cjs");exports.AssetLoader=e.AssetLoader;exports.DRACOWorker=e.DRACOWorker;exports.DracoLoader=e.DracoLoader;
@@ -1,5 +1,5 @@
1
- import { A as o } from "../../chunks/AssetLoader-Dcr75VNw.mjs";
2
- import { D as s, a as t } from "../../chunks/AssetLoader-Dcr75VNw.mjs";
1
+ import { A as o } from "../../chunks/AssetLoader-C-PfRr8Z.mjs";
2
+ import { D as s, a as t } from "../../chunks/AssetLoader-C-PfRr8Z.mjs";
3
3
  export {
4
4
  o as AssetLoader,
5
5
  s as DRACOWorker,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-35x8Ekp6.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../chunks/FileTypes-BHH0KUFf.cjs");exports.OrbitController=t.OrbitController;exports.OrbitControllerDefaultSettings=t.OrbitControllerDefaultSettings;
@@ -1,4 +1,4 @@
1
- import { O as o, a as e } from "../../chunks/FileTypes-BSG8CC2s.mjs";
1
+ import { O as o, a as e } from "../../chunks/FileTypes-B8g1qxjR.mjs";
2
2
  export {
3
3
  o as OrbitController,
4
4
  e as OrbitControllerDefaultSettings
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var p=(s,e,r)=>e in s?c(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var a=(s,e,r)=>p(s,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("three");require("../../chunks/FileTypes-35x8Ekp6.cjs");const n=require("../../chunks/PerspectiveCamera-iAsZqrnY.cjs"),i=require("../../chunks/AxisHelperColors-BrGqktN5.cjs"),l=require("three-spritetext");class _ extends t.Object3D{constructor(){super();a(this,"_axesHelper");this._axesHelper=new t.AxesHelper(.5),this._axesHelper.layers.mask=n.COORDINATE_LAYER_MASK,this._axesHelper.material.depthTest=!1,this._axesHelper.position.set(0,0,-1),this._axesHelper.setColors(new t.Color(i.AxesColorRed),new t.Color(i.AxesColorGreen),new t.Color(i.AxesColorBlue));const r=new l("X",.2,i.AxesColorRedLetter),o=new l("Y",.2,i.AxesColorGreenLetter),h=new l("Z",.2,i.AxesColorBlueLetter);r.layers.mask=n.COORDINATE_LAYER_MASK,o.layers.mask=n.COORDINATE_LAYER_MASK,h.layers.mask=n.COORDINATE_LAYER_MASK,r.position.set(.7,0,0),o.position.set(0,.7,0),h.position.set(0,0,.7),this._axesHelper.add(r),this._axesHelper.add(o),this._axesHelper.add(h),this.add(this._axesHelper)}setFromCameraMatrix(r){this._axesHelper.rotation.setFromRotationMatrix(new t.Matrix4().extractRotation(r).invert())}}class d{constructor(e,r,o){a(this,"uuid",t.MathUtils.generateUUID());a(this,"_axes");a(this,"_orthographicCamera");a(this,"_restoreViewport",new t.Vector4);this._renderer=e,this._scene=r,this._camera=o,this._orthographicCamera=new t.OrthographicCamera(-1,1,1,-1,.1,100),this._orthographicCamera.name="OrientationDisplayCamera",this._orthographicCamera.layers.mask=n.COORDINATE_LAYER_MASK,this._scene.add(this._orthographicCamera),this._axes=new _,this._axes.name="OrientationDisplayAxes",this._scene.add(this._axes)}tick(){const e=this._scene.background??null;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=e}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}exports.OrientationDisplay=d;exports.OrientationDisplayAxes=_;
1
+ "use strict";var c=Object.defineProperty;var p=(s,e,r)=>e in s?c(s,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[e]=r;var a=(s,e,r)=>p(s,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("three");require("../../chunks/FileTypes-BHH0KUFf.cjs");const n=require("../../chunks/PerspectiveCamera-iAsZqrnY.cjs"),i=require("../../chunks/AxisHelperColors-BrGqktN5.cjs"),l=require("three-spritetext");class _ extends t.Object3D{constructor(){super();a(this,"_axesHelper");this._axesHelper=new t.AxesHelper(.5),this._axesHelper.layers.mask=n.COORDINATE_LAYER_MASK,this._axesHelper.material.depthTest=!1,this._axesHelper.position.set(0,0,-1),this._axesHelper.setColors(new t.Color(i.AxesColorRed),new t.Color(i.AxesColorGreen),new t.Color(i.AxesColorBlue));const r=new l("X",.2,i.AxesColorRedLetter),o=new l("Y",.2,i.AxesColorGreenLetter),h=new l("Z",.2,i.AxesColorBlueLetter);r.layers.mask=n.COORDINATE_LAYER_MASK,o.layers.mask=n.COORDINATE_LAYER_MASK,h.layers.mask=n.COORDINATE_LAYER_MASK,r.position.set(.7,0,0),o.position.set(0,.7,0),h.position.set(0,0,.7),this._axesHelper.add(r),this._axesHelper.add(o),this._axesHelper.add(h),this.add(this._axesHelper)}setFromCameraMatrix(r){this._axesHelper.rotation.setFromRotationMatrix(new t.Matrix4().extractRotation(r).invert())}}class d{constructor(e,r,o){a(this,"uuid",t.MathUtils.generateUUID());a(this,"_axes");a(this,"_orthographicCamera");a(this,"_restoreViewport",new t.Vector4);this._renderer=e,this._scene=r,this._camera=o,this._orthographicCamera=new t.OrthographicCamera(-1,1,1,-1,.1,100),this._orthographicCamera.name="OrientationDisplayCamera",this._orthographicCamera.layers.mask=n.COORDINATE_LAYER_MASK,this._scene.add(this._orthographicCamera),this._axes=new _,this._axes.name="OrientationDisplayAxes",this._scene.add(this._axes)}tick(){const e=this._scene.background??null;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=e}dispose(){this._scene.remove(this._axes),this._scene.remove(this._orthographicCamera)}}exports.OrientationDisplay=d;exports.OrientationDisplayAxes=_;
@@ -2,7 +2,7 @@ var l = Object.defineProperty;
2
2
  var _ = (s, e, r) => e in s ? l(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
3
3
  var t = (s, e, r) => _(s, typeof e != "symbol" ? e + "" : e, r);
4
4
  import { Object3D as p, AxesHelper as c, Color as n, Matrix4 as d, OrthographicCamera as m, MathUtils as x, Vector4 as w } from "three";
5
- import "../../chunks/FileTypes-BSG8CC2s.mjs";
5
+ import "../../chunks/FileTypes-B8g1qxjR.mjs";
6
6
  import { C as i } from "../../chunks/PerspectiveCamera-BFzE2TQU.mjs";
7
7
  import { A as C, a as g, b as u, c as A, d as H, e as b } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
8
8
  import h from "three-spritetext";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../chunks/FileTypes-35x8Ekp6.cjs");require("three");const r={...o.DIVEDefaultSettings},l=async(n,c)=>{const e=new o.DIVE(c);e.mainView.camera.position.set(0,1,2);const i=await new o.DIVEModel().setFromURL(n);e.scene.root.add(i),i.placeOnFloor();const t=new o.OrbitController(e.mainView.camera,e.mainView.canvas);t.focusObject(i),e.clock.addTicker(t);const s=Object.assign(e,{orbitController:t,model:i}),a=e.dispose.bind(e);return s.dispose=async()=>{t.dispose(),await a()},s};exports.QuickView=l;exports.QuickViewDefaultSettings=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../chunks/FileTypes-BHH0KUFf.cjs");require("three");const r={...o.DIVEDefaultSettings},l=async(n,c)=>{const e=new o.DIVE(c);e.mainView.camera.position.set(0,1,2);const i=await new o.DIVEModel().setFromURL(n);e.scene.root.add(i),i.placeOnFloor();const t=new o.OrbitController(e.mainView.camera,e.mainView.canvas);t.focusObject(i),e.clock.addTicker(t);const s=Object.assign(e,{orbitController:t,model:i}),a=e.dispose.bind(e);return s.dispose=async()=>{t.dispose(),await a()},s};exports.QuickView=l;exports.QuickViewDefaultSettings=r;
@@ -1,4 +1,4 @@
1
- import { D as c, b as r, c as l, O as d } from "../../chunks/FileTypes-BSG8CC2s.mjs";
1
+ import { D as c, b as r, c as l, O as d } from "../../chunks/FileTypes-B8g1qxjR.mjs";
2
2
  import "three";
3
3
  const p = {
4
4
  ...c
@@ -1,4 +1,4 @@
1
- "use strict";var Nd=Object.defineProperty;var $d=(d,g,o)=>g in d?Nd(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var un=(d,g,o)=>$d(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Hd=require("three"),qd=require("../../chunks/FileTypes-35x8Ekp6.cjs"),Li=require("../../chunks/PovSchema-Co9FznEz.cjs"),po={};function G(d,g){po[d]=g}function vo(d){return po[d]}class F{constructor(g,o){un(this,"_payload");un(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends F{constructor(m,$){super(m,$);un(this,"_description",g);un(this,"_payload");this._payload=m}execute(){return o(this._payload,this._dependencies)}}}}const wo=F.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",wo);const Ao=F.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new qd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",Ao);const xo=F.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",xo);const mo=F.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:m})=>{let $={x:0,y:0,z:0},q={x:0,y:0,z:0};if("id"in d){const j=o.get(d.id);if(!j)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Li.isPovSchema(j))throw new Error(`Object with id ${d.id} is not a POV. Object: ${j}`);$=j.position,q=j.target}else $=d.position,q=d.target;const gn=await S().then(j=>(m.clock.hasTicker(j)||m.clock.addTicker(j),g.enabled=!0,j.animate([{object:g.object.position,to:$},{object:g.target,to:q}],d.duration,{easing:j.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}})));return{stop:()=>gn.stop()}}});G("MOVE_CAMERA",mo);const Eo=F.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",Eo);const So=F.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",So);const bo=F.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",bo);const Oo=F.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 m=g.get(d.id);if(!m)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Li.isPovSchema(m))throw new Error(`Object with id ${d.id} is not a POV. Object: ${m}`);const{resolution:$}=d,{position:q,target:gn}=m;return S.generateMedia({position:q,target:gn,resolution:$})}return S.generateMedia(d)}});G("GENERATE_MEDIA",Oo);const To=F.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",To);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lt={exports:{}};/**
1
+ "use strict";var Nd=Object.defineProperty;var $d=(d,g,o)=>g in d?Nd(d,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):d[g]=o;var un=(d,g,o)=>$d(d,typeof g!="symbol"?g+"":g,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Hd=require("three"),qd=require("../../chunks/FileTypes-BHH0KUFf.cjs"),Li=require("../../chunks/PovSchema-Co9FznEz.cjs"),po={};function G(d,g){po[d]=g}function vo(d){return po[d]}class F{constructor(g,o){un(this,"_payload");un(this,"_dependencies");this._payload=g,this._dependencies=o}static define({description:g,execute:o}){return class extends F{constructor(m,$){super(m,$);un(this,"_description",g);un(this,"_payload");this._payload=m}execute(){return o(this._payload,this._dependencies)}}}}const wo=F.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",wo);const Ao=F.define({description:"Calculates the camera position and target to view the whole scene. (experimental).",execute:(d,{engine:g,controller:o})=>{const S=new qd.BoundingBox(g.scene.root,!1,65280);return o.computeEncompassingView(S)}});G("COMPUTE_ENCOMPASSING_VIEW",Ao);const xo=F.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",xo);const mo=F.define({description:"Moves the camera to a new position and target.",execute:async(d,{controller:g,registered:o,getAnimationSystem:S,engine:m})=>{let $={x:0,y:0,z:0},q={x:0,y:0,z:0};if("id"in d){const j=o.get(d.id);if(!j)throw new Error(`POV with id ${d.id} not registered. Registered: ${o}`);if(!Li.isPovSchema(j))throw new Error(`Object with id ${d.id} is not a POV. Object: ${j}`);$=j.position,q=j.target}else $=d.position,q=d.target;const gn=await S().then(j=>(m.clock.hasTicker(j)||m.clock.addTicker(j),g.enabled=!0,j.animate([{object:g.object.position,to:$},{object:g.target,to:q}],d.duration,{easing:j.Easing.Quadratic.Out,onUpdate:()=>{g.object.lookAt(g.target)},onComplete:()=>{g.enabled=!d.locked}})));return{stop:()=>gn.stop()}}});G("MOVE_CAMERA",mo);const Eo=F.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",Eo);const So=F.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",So);const bo=F.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",bo);const Oo=F.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 m=g.get(d.id);if(!m)throw new Error(`Object with id ${d.id} not registered. Registered: ${g}`);if(!Li.isPovSchema(m))throw new Error(`Object with id ${d.id} is not a POV. Object: ${m}`);const{resolution:$}=d,{position:q,target:gn}=m;return S.generateMedia({position:q,target:gn,resolution:$})}return S.generateMedia(d)}});G("GENERATE_MEDIA",Oo);const To=F.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",To);var or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lt={exports:{}};/**
2
2
  * @license
3
3
  * Lodash <https://lodash.com/>
4
4
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -2,7 +2,7 @@ var gd = Object.defineProperty;
2
2
  var _d = (d, g, o) => g in d ? gd(d, g, { enumerable: !0, configurable: !0, writable: !0, value: o }) : d[g] = o;
3
3
  var un = (d, g, o) => _d(d, typeof g != "symbol" ? g + "" : g, o);
4
4
  import { MathUtils as dd } from "three";
5
- import { B as pd } from "../../chunks/FileTypes-BSG8CC2s.mjs";
5
+ import { B as pd } from "../../chunks/FileTypes-B8g1qxjR.mjs";
6
6
  import { a as go, i as vd } from "../../chunks/PovSchema-DWWvr_ED.mjs";
7
7
  const _o = {};
8
8
  function N(d, g) {
@@ -1 +1 @@
1
- "use strict";var vt=Object.defineProperty;var Mt=(h,e,t)=>e in h?vt(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var r=(h,e,t)=>Mt(h,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("three");require("../../chunks/FileTypes-35x8Ekp6.cjs");const M=require("../../chunks/PerspectiveCamera-iAsZqrnY.cjs"),S=require("../../chunks/findInterface-C6mrvf_t.cjs"),j=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class lt{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(e){var t,s,o;this._selected!==e&&(this._selected&&((s=(t=this._selected).onDeselect)==null||s.call(t)),this._selected=e,(o=e.onSelect)==null||o.call(e),this.notifyListeners())}deselect(){var e,t;this._selected&&((t=(e=this._selected).onDeselect)==null||t.call(e),this._selected=null,this.notifyListeners())}onChange(e){this._listeners.add(e)}offChange(e){this._listeners.delete(e)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const e of this._listeners)e(this._selected)}}class ct{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var e,t;this._hovered&&((t=(e=this._hovered).onPointerLeave)==null||t.call(e),this._hovered=null)}onPointerMove(e){var o,a,n,l,_,w,P;const t=e.modelIntersects[0],s=S.findInterface(t==null?void 0:t.object,"isHoverable");if(t&&s){if(!this._hovered){(o=s.onPointerEnter)==null||o.call(s,t),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(n=(a=this._hovered).onPointerLeave)==null||n.call(a),(l=s.onPointerEnter)==null||l.call(s,t),this._hovered=s;return}(_=s.onPointerOver)==null||_.call(s,t);return}this._hovered&&((P=(w=this._hovered).onPointerLeave)==null||P.call(w),this._hovered=null)}}const St=h=>h.name==="select";class ${constructor(e){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=e}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(e){const t=e.modelIntersects[0],s=S.findInterface(t==null?void 0:t.object,"isSelectable");if(!t||!s){this._selectionState.deselect();return}const o=this._selectionState.selected;o&&o.uuid===s.uuid||this._selectionState.select(s)}select(e){this._selectionState.select(e)}deselect(){this._selectionState.deselect()}}const A=new i.Raycaster,p=new i.Vector3,T=new i.Vector3,d=new i.Quaternion,it={X:new i.Vector3(1,0,0),Y:new i.Vector3(0,1,0),Z:new i.Vector3(0,0,1)},N={type:"change"},st={type:"mouseDown"},nt={type:"mouseUp",mode:null},ot={type:"objectChange"};class Pt extends i.Object3D{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const s=new At;this._gizmo=s,this.add(s);const o=new Ct;this._plane=o,this.add(o);const a=this;function n(u,f){let L=f;Object.defineProperty(a,u,{get:function(){return L!==void 0?L:f},set:function(I){L!==I&&(L=I,o[u]=I,s[u]=I,a.dispatchEvent({type:u+"-changed",value:I}),a.dispatchEvent(N))}}),a[u]=f,o[u]=f,s[u]=f}n("camera",e),n("object",void 0),n("enabled",!0),n("axis",null),n("mode","translate"),n("translationSnap",null),n("rotationSnap",null),n("scaleSnap",null),n("space","world"),n("size",1),n("dragging",!1),n("showX",!0),n("showY",!0),n("showZ",!0);const l=new i.Vector3,_=new i.Vector3,w=new i.Quaternion,P=new i.Quaternion,G=new i.Vector3,R=new i.Quaternion,tt=new i.Vector3,X=new i.Vector3,D=new i.Vector3,E=0,b=new i.Vector3;n("worldPosition",l),n("worldPositionStart",_),n("worldQuaternion",w),n("worldQuaternionStart",P),n("cameraPosition",G),n("cameraQuaternion",R),n("pointStart",tt),n("pointEnd",X),n("rotationAxis",D),n("rotationAngle",E),n("eye",b),this._offset=new i.Vector3,this._startNorm=new i.Vector3,this._endNorm=new i.Vector3,this._cameraScale=new i.Vector3,this._parentPosition=new i.Vector3,this._parentQuaternion=new i.Quaternion,this._parentQuaternionInv=new i.Quaternion,this._parentScale=new i.Vector3,this._worldScaleStart=new i.Vector3,this._worldQuaternionInv=new i.Quaternion,this._worldScale=new i.Vector3,this._positionStart=new i.Vector3,this._quaternionStart=new i.Quaternion,this._scaleStart=new i.Vector3,this._getPointer=Dt.bind(this),this._onPointerDown=xt.bind(this),this._onPointerHover=Et.bind(this),this._onPointerMove=Tt.bind(this),this._onPointerUp=It.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(e){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(e)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&A.setFromCamera(e,this.camera);const t=K(this._gizmo.picker[this.mode],A);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&A.setFromCamera(e,this.camera);const t=K(this._plane,A,!0);t&&(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(t.point).sub(this.worldPositionStart)),this.dragging=!0,st.mode=this.mode,this.dispatchEvent(st)}}pointerMove(e){const t=this.axis,s=this.mode,o=this.object;let a=this.space;if(s==="scale"?a="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(a="world"),o===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&A.setFromCamera(e,this.camera);const n=K(this._plane,A,!0);if(n){if(this.pointEnd.copy(n.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),o.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(o.position.applyQuaternion(d.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.position.applyQuaternion(this._quaternionStart)),a==="world"&&(o.parent&&o.position.add(p.setFromMatrixPosition(o.parent.matrixWorld)),t.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.parent&&o.position.sub(p.setFromMatrixPosition(o.parent.matrixWorld))));else if(s==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),T.set(l,l,l)}else p.copy(this.pointStart),T.copy(this.pointEnd),p.applyQuaternion(this._worldQuaternionInv),T.applyQuaternion(this._worldQuaternionInv),T.divide(p),t.search("X")===-1&&(T.x=1),t.search("Y")===-1&&(T.y=1),t.search("Z")===-1&&(T.z=1);o.scale.copy(this._scaleStart).multiply(T),this.scaleSnap&&(t.search("X")!==-1&&(o.scale.x=Math.round(o.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(o.scale.y=Math.round(o.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(o.scale.z=Math.round(o.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(p.setFromMatrixPosition(this.camera.matrixWorld));let _=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(p.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(it[t]),p.copy(it[t]),a==="local"&&p.applyQuaternion(this.worldQuaternion),p.cross(this.eye),p.length()===0?_=!0:this.rotationAngle=this._offset.dot(p.normalize())*l),(t==="E"||_)&&(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"&&t!=="E"&&t!=="XYZE"?(o.quaternion.copy(this._quaternionStart),o.quaternion.multiply(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),o.quaternion.copy(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),o.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(N),this.dispatchEvent(ot)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(nt.mode=this.mode,this.dispatchEvent(nt)),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(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,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(N),this.dispatchEvent(ot),this.pointStart.copy(this.pointEnd))}getRaycaster(){return A}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Dt(h){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:h.button};{const e=this.domElement.getBoundingClientRect();return{x:(h.clientX-e.left)/e.width*2-1,y:-(h.clientY-e.top)/e.height*2+1,button:h.button}}}function Et(h){if(this.enabled)switch(h.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(h));break}}function xt(h){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(h.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(h)),this.pointerDown(this._getPointer(h)))}function Tt(h){this.enabled&&this.pointerMove(this._getPointer(h))}function It(h){this.enabled&&(this.domElement.releasePointerCapture(h.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(h)))}function K(h,e,t){const s=e.intersectObject(h,!0);for(let o=0;o<s.length;o++)if(s[o].object.visible||t)return s[o];return!1}const B=new i.Euler,c=new i.Vector3(0,1,0),rt=new i.Vector3(0,0,0),at=new i.Matrix4,q=new i.Quaternion,F=new i.Quaternion,v=new i.Vector3,ht=new i.Matrix4,H=new i.Vector3(1,0,0),C=new i.Vector3(0,1,0),O=new i.Vector3(0,0,1),U=new i.Vector3,Y=new i.Vector3,Q=new i.Vector3;class At extends i.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new i.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new i.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const o=t.clone();o.opacity=.5;const a=e.clone();a.color.setHex(16711680);const n=e.clone();n.color.setHex(65280);const l=e.clone();l.color.setHex(255);const _=e.clone();_.color.setHex(16711680),_.opacity=.5;const w=e.clone();w.color.setHex(65280),w.opacity=.5;const P=e.clone();P.color.setHex(255),P.opacity=.5;const G=e.clone();G.opacity=.25;const R=e.clone();R.color.setHex(16776960),R.opacity=.25,e.clone().color.setHex(16776960);const X=e.clone();X.color.setHex(7895160);const D=new i.CylinderGeometry(0,.04,.1,12);D.translate(0,.05,0);const E=new i.BoxGeometry(.08,.08,.08);E.translate(0,.04,0);const b=new i.BufferGeometry;b.setAttribute("position",new i.Float32BufferAttribute([0,0,0,1,0,0],3));const u=new i.CylinderGeometry(.0075,.0075,.5,3);u.translate(0,.25,0);function f(m,k){const y=new i.TorusGeometry(m,.0075,3,64,k*Math.PI*2);return y.rotateY(Math.PI/2),y.rotateX(Math.PI/2),y}function L(){const m=new i.BufferGeometry;return m.setAttribute("position",new i.Float32BufferAttribute([0,0,0,1,1,1],3)),m}const I={X:[[new i.Mesh(D,a),[.5,0,0],[0,0,-Math.PI/2]],[new i.Mesh(D,a),[-.5,0,0],[0,0,Math.PI/2]],[new i.Mesh(u,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new i.Mesh(D,n),[0,.5,0]],[new i.Mesh(D,n),[0,-.5,0],[Math.PI,0,0]],[new i.Mesh(u,n)]],Z:[[new i.Mesh(D,l),[0,0,.5],[Math.PI/2,0,0]],[new i.Mesh(D,l),[0,0,-.5],[-Math.PI/2,0,0]],[new i.Mesh(u,l),null,[Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.OctahedronGeometry(.1,0),G.clone()),[0,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),P.clone()),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),_.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),w.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},pt={X:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.OctahedronGeometry(.2,0),s)]],XY:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},_t={START:[[new i.Mesh(new i.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new i.Mesh(new i.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new i.Line(L(),o),null,null,null,"helper"]],X:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new i.Line(b,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new i.Line(b,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ut={XYZE:[[new i.Mesh(f(.5,1),X),null,[0,Math.PI/2,0]]],X:[[new i.Mesh(f(.5,.5),a)]],Y:[[new i.Mesh(f(.5,.5),n),null,[0,0,-Math.PI/2]]],Z:[[new i.Mesh(f(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new i.Mesh(f(.75,1),R),null,[0,Math.PI/2,0]]]},gt={AXIS:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},mt={XYZE:[[new i.Mesh(new i.SphereGeometry(.25,10,8),s)]],X:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new i.Mesh(new i.TorusGeometry(.75,.1,2,24),s)]]},ft={X:[[new i.Mesh(E,a),[.5,0,0],[0,0,-Math.PI/2]],[new i.Mesh(u,a),[0,0,0],[0,0,-Math.PI/2]],[new i.Mesh(E,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(E,n),[0,.5,0]],[new i.Mesh(u,n)],[new i.Mesh(E,n),[0,-.5,0],[0,0,Math.PI]]],Z:[[new i.Mesh(E,l),[0,0,.5],[Math.PI/2,0,0]],[new i.Mesh(u,l),[0,0,0],[Math.PI/2,0,0]],[new i.Mesh(E,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),P),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),_),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),w),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.BoxGeometry(.1,.1,.1),G.clone())]]},yt={X:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},wt={X:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new i.Line(b,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new i.Line(b,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function x(m){const k=new i.Object3D;for(const y in m)for(let z=m[y].length;z--;){const g=m[y][z][0].clone(),V=m[y][z][1],Z=m[y][z][2],W=m[y][z][3],bt=m[y][z][4];g.name=y,g.tag=bt,V&&g.position.set(V[0],V[1],V[2]),Z&&g.rotation.set(Z[0],Z[1],Z[2]),W&&g.scale.set(W[0],W[1],W[2]),g.updateMatrix();const et=g.geometry.clone();et.applyMatrix4(g.matrix),g.geometry=et,g.renderOrder=1/0,g.position.set(0,0,0),g.rotation.set(0,0,0),g.scale.set(1,1,1),k.add(g)}return k}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=x(I)),this.add(this.gizmo.rotate=x(ut)),this.add(this.gizmo.scale=x(ft)),this.add(this.picker.translate=x(pt)),this.add(this.picker.rotate=x(mt)),this.add(this.picker.scale=x(yt)),this.add(this.helper.translate=x(_t)),this.add(this.helper.rotate=x(gt)),this.add(this.helper.scale=x(wt)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(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 o=[];o=o.concat(this.picker[this.mode].children),o=o.concat(this.gizmo[this.mode].children),o=o.concat(this.helper[this.mode].children);for(let a=0;a<o.length;a++){const n=o[a];n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(l*this.size/4),n.tag==="helper"){n.visible=!1,n.name==="AXIS"?(n.visible=!!this.axis,this.axis==="X"&&(d.setFromEuler(B.set(0,0,0)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Y"&&(d.setFromEuler(B.set(0,0,Math.PI/2)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Z"&&(d.setFromEuler(B.set(0,Math.PI/2,0)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="XYZE"&&(d.setFromEuler(B.set(0,Math.PI/2,0)),c.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(at.lookAt(rt,c,C)),n.quaternion.multiply(d),n.visible=this.dragging),this.axis==="E"&&(n.visible=!1)):n.name==="START"?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):n.name==="END"?(n.position.copy(this.worldPosition),n.visible=this.dragging):n.name==="DELTA"?(n.position.copy(this.worldPositionStart),n.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()),n.scale.copy(p),n.visible=this.dragging):(n.quaternion.copy(s),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=this.axis.search(n.name)!==-1));continue}n.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(n.name==="X"&&Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Y"&&Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Z"&&Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XY"&&Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="YZ"&&Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XZ"&&Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)):this.mode==="rotate"&&(q.copy(s),c.copy(this.eye).applyQuaternion(d.copy(s).invert()),n.name.search("E")!==-1&&n.quaternion.setFromRotationMatrix(at.lookAt(this.eye,rt,C)),n.name==="X"&&(d.setFromAxisAngle(H,Math.atan2(-c.y,c.z)),d.multiplyQuaternions(q,d),n.quaternion.copy(d)),n.name==="Y"&&(d.setFromAxisAngle(C,Math.atan2(c.x,c.z)),d.multiplyQuaternions(q,d),n.quaternion.copy(d)),n.name==="Z"&&(d.setFromAxisAngle(O,Math.atan2(c.y,c.x)),d.multiplyQuaternions(q,d),n.quaternion.copy(d))),n.visible=n.visible&&(n.name.indexOf("X")===-1||this.showX),n.visible=n.visible&&(n.name.indexOf("Y")===-1||this.showY),n.visible=n.visible&&(n.name.indexOf("Z")===-1||this.showZ),n.visible=n.visible&&(n.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(_){return n.name===_}))&&(n.material.color.setHex(16776960),n.material.opacity=1)}super.updateMatrixWorld(e)}}class Ct extends i.Mesh{constructor(){super(new i.PlaneGeometry(1e5,1e5,2,2),new i.MeshBasicMaterial({visible:!1,wireframe:!0,side:i.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),U.copy(H).applyQuaternion(t==="local"?this.worldQuaternion:F),Y.copy(C).applyQuaternion(t==="local"?this.worldQuaternion:F),Q.copy(O).applyQuaternion(t==="local"?this.worldQuaternion:F),c.copy(Y),this.mode){case"translate":case"scale":switch(this.axis){case"X":c.copy(this.eye).cross(U),v.copy(U).cross(c);break;case"Y":c.copy(this.eye).cross(Y),v.copy(Y).cross(c);break;case"Z":c.copy(this.eye).cross(Q),v.copy(Q).cross(c);break;case"XY":v.copy(Q);break;case"YZ":v.copy(U);break;case"XZ":c.copy(Q),v.copy(Y);break;case"XYZ":case"E":v.set(0,0,0);break}break;case"rotate":default:v.set(0,0,0)}v.length()===0?this.quaternion.copy(this.cameraQuaternion):(ht.lookAt(p.set(0,0,0),v,c),this.quaternion.setFromRotationMatrix(ht)),super.updateMatrixWorld(e)}}const Lt=h=>h.name==="transform";class J extends i.EventDispatcher{constructor(t,s,o){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=t,this._controller=s,this._selectionState=o,this._gizmo=this.initGizmo(),this._scene.add(this._gizmo),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const t=this._selectionState.selected;t&&this.attachGizmo(t)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(t){if(this._gizmo.dragging||t.uiIntersects.length>0&&t.uiIntersects.some(o=>this.isGizmoChild(o.object)))return!0}setGizmoMode(t){this._gizmo.mode=t}setGizmoVisible(t){this._gizmoVisible=t;const s=this._scene.children.includes(this._gizmo);t&&!s?(this._scene.add(this._gizmo),this._gizmo.getRaycaster().layers.enableAll()):!t&&s&&(this._scene.remove(this._gizmo),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(t){this._scaleLinked=t}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmo),this._gizmo.dispose()}onSelectionChange(t){t&&S.implementsInterface(t,"isMovable")?this.attachGizmo(t):this._gizmo.detach()}attachGizmo(t){S.implementsInterface(t,"isMovable")&&(this._gizmo.attach(t),this.setGizmoVisible(t.visible&&this._gizmoVisible))}isGizmoChild(t){let s=t;for(;s;){if(s===this._gizmo)return!0;s=s.parent}return!1}initGizmo(){const t=new Pt(this._controller.object,this._controller.domElement);return t.mode="translate",t.traverse(s=>{if(!("isMesh"in s))return;const o=s.material;s.name==="X"&&o.color.set(j.AxesColorRed),s.name==="Y"&&o.color.set(j.AxesColorGreen),s.name==="Z"&&o.color.set(j.AxesColorBlue),s.name==="XY"&&o.color.set(j.AxesColorBlue),s.name==="YZ"&&o.color.set(j.AxesColorRed),s.name==="XZ"&&o.color.set(j.AxesColorGreen)}),t.addEventListener("mouseDown",()=>{var s,o;this._controller.enabled=!1,S.implementsInterface(t.object,"isMovable")&&((o=(s=t.object).onMoveStart)==null||o.call(s))}),t.addEventListener("objectChange",()=>{var s,o;if(S.implementsInterface(t.object,"isMovable")){if((o=(s=t.object).onMove)==null||o.call(s),this._scaleLinked&&t.object){const a=t.object.scale,n=(a.x+a.y+a.z)/3;t.object.scale.set(n,n,n)}switch(this.dispatchEvent({type:"object-change",object:t.object}),t.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:t.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:t.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:t.object});break}}}),t.addEventListener("mouseUp",()=>{var s,o;this._controller.enabled=!0,S.implementsInterface(t.object,"isMovable")&&((o=(s=t.object).onMoveEnd)==null||o.call(s))}),t}}const zt=.001;class dt{constructor(e){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new i.Vector3);r(this,"_dragCurrent",new i.Vector3);r(this,"_dragEnd",new i.Vector3);r(this,"_dragDelta",new i.Vector3);r(this,"_dragRaycastTargets",null);this._controller=e,this._raycaster=new i.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(e){var t;e.pointerPrimaryDown&&(this._draggable=S.findInterface((t=e.intersects[0])==null?void 0:t.object,"isDraggable")||null)}onPointerMove(e){if(e.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(e.pointer,this._controller.object),this._dragging||e.lastPointerDown.distanceTo(e.pointer)>zt&&this.startDrag(e),this._dragging))return this.updateDrag(e),!0}onPointerUp(e){this._dragging&&(this._raycaster.setFromCamera(e.pointer,this._controller.object),this.endDrag()),this._draggable=null}setDragRaycastTargets(e){this._dragRaycastTargets=e}startDrag(e){var s,o;const t=this.getDragIntersect(e);t&&(this._dragStart.copy(t.point),this._dragCurrent.copy(t.point),this._dragEnd.copy(t.point),this._dragDelta.set(0,0,0),(o=(s=this._draggable)==null?void 0:s.onDragStart)==null||o.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(e){var s,o;const t=this.getDragIntersect(e);t&&(this._dragCurrent.copy(t.point),this._dragEnd.copy(t.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(o=(s=this._draggable)==null?void 0:s.onDrag)==null||o.call(s,this.createDragEvent()))}endDrag(){var t,s;const e=this.createDragEvent();(s=(t=this._draggable)==null?void 0:t.onDragEnd)==null||s.call(t,e),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(e){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:e.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const jt=.001;class Gt{constructor(e,t){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_productLayerMask");r(this,"_uiLayerMask");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=e,this._controller=t,this._canvas=t.domElement,this._selectionState=new lt,this._raycaster=new i.Raycaster,this._pointer=new i.Vector2,this._lastPointerDown=new i.Vector2,this._productLayerMask=new i.Layers,this._productLayerMask.set(Math.log2(M.PRODUCT_LAYER_MASK)),this._uiLayerMask=new i.Layers,this._uiLayerMask.set(Math.log2(M.UI_LAYER_MASK)),this._tools=new Map([["hover",new ct],["select",new $(this._selectionState)],["transform",new J(e,t,this._selectionState)],["drag",new dt(t)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(e){var s;const t=this._tools.get(e);t&&(this._activeTools.has(e)||(this._activeTools.set(e,t),this.updateSortedTools(),(s=t.onActivate)==null||s.call(t)))}disableTool(e){var s;const t=this._activeTools.get(e);t&&((s=t.onDeactivate)==null||s.call(t),this._activeTools.delete(e),this.updateSortedTools())}isToolEnabled(e){return this._activeTools.has(e)}getTool(e){return this._tools.get(e)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var e;for(const t of this._activeTools.values())(e=t.onDeactivate)==null||e.call(t);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(e){var s;this.updatePointer(e);const t=this.createPointerContext(e);for(const o of this._sortedActiveTools)if((s=o.onPointerMove)==null?void 0:s.call(o,t))break}onPointerDown(e){var s;this.updatePointerState(e,!0),this.updatePointer(e),this._lastPointerDown.copy(this._pointer);const t=this.createPointerContext(e);for(const o of this._sortedActiveTools)if((s=o.onPointerDown)==null?void 0:s.call(o,t))break}onPointerUp(e){var o,a;this.updatePointer(e);const t=this.createPointerContext(e),s=!this.pointerWasDragged();for(const n of this._sortedActiveTools)if((o=n.onPointerUp)==null?void 0:o.call(n,t))break;if(s){for(const n of this._sortedActiveTools)if((a=n.onClick)==null?void 0:a.call(n,t))break}this.updatePointerState(e,!1)}onWheel(e){var s;const t=this.createWheelContext(e);for(const o of this._sortedActiveTools)if((s=o.onWheel)==null?void 0:s.call(o,t))break}createPointerContext(e){const t=this.raycast();return{event:e,pointer:this._pointer.clone(),intersects:t,modelIntersects:this.filterIntersectsByLayer(t,M.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(t,M.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(e){const t=this.raycast();return{event:e,pointer:this._pointer.clone(),intersects:t,modelIntersects:this.filterIntersectsByLayer(t,M.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(t,M.UI_LAYER_MASK)}}updatePointer(e){this._pointer.x=e.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(e.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object)}updatePointerState(e,t){switch(e.button){case 0:this._pointerPrimaryDown=t;break;case 1:this._pointerMiddleDown=t;break;case 2:this._pointerSecondaryDown=t;break}}raycast(){this._raycaster.layers.mask=M.PRODUCT_LAYER_MASK|M.UI_LAYER_MASK;const e=this._scene.children.filter(t=>t.visible&&"isMesh"in t&&t.isMesh);return this._raycaster.intersectObjects(e,!0)}filterIntersectsByLayer(e,t){return e.filter(s=>(s.object.layers.mask&t)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((e,t)=>e.priority-t.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>jt}useTool(e){const t=["hover","select","transform","drag"];for(const s of t)(s===e||e==="select")&&this.enableTool(s)}getActiveTool(){return this._sortedActiveTools[0]||null}}class Rt{constructor(e,t){r(this,"POINTER_DRAG_THRESHOLD",.001);r(this,"name");r(this,"_canvas");r(this,"_scene");r(this,"_controller");r(this,"_pointer");r(this,"_pointerPrimaryDown");r(this,"_pointerMiddleDown");r(this,"_pointerSecondaryDown");r(this,"_lastPointerDown");r(this,"_lastPointerUp");r(this,"_raycaster");r(this,"_intersects");r(this,"_hovered");r(this,"_dragging");r(this,"_dragStart");r(this,"_dragCurrent");r(this,"_dragEnd");r(this,"_dragDelta");r(this,"_draggable");r(this,"_dragRaycastOnObjects");this.name="BaseTool",this._canvas=t.domElement,this._scene=e,this._controller=t,this._pointer=new i.Vector2,this._pointerPrimaryDown=!1,this._pointerMiddleDown=!1,this._pointerSecondaryDown=!1,this._lastPointerDown=new i.Vector2,this._lastPointerUp=new i.Vector2,this._raycaster=new i.Raycaster,this._raycaster.layers.mask=M.PRODUCT_LAYER_MASK|M.UI_LAYER_MASK,this._intersects=[],this._hovered=null,this._dragging=!1,this._dragStart=new i.Vector3,this._dragCurrent=new i.Vector3,this._dragEnd=new i.Vector3,this._dragDelta=new i.Vector3,this._draggable=null,this._dragRaycastOnObjects=null}get _pointerAnyDown(){return this._pointerPrimaryDown||this._pointerMiddleDown||this._pointerSecondaryDown}activate(){}deactivate(){}onPointerDown(e){var t;switch(e.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: "+e.button)}this._lastPointerDown.copy(this._pointer),this._draggable=S.findInterface((t=this._intersects[0])==null?void 0:t.object,"isDraggable")||null}onDragStart(e){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(e){var s;this._pointer.x=e.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(e.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object),this._intersects=this.raycast(this._scene.children);const t=S.findInterface((s=this._intersects[0])==null?void 0:s.object,"isHoverable");if(this._intersects[0]&&t){if(!this._hovered){t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}if(this._hovered.uuid!==t.uuid){this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}t.onPointerOver&&t.onPointerOver(this._intersects[0]),this._hovered=t}else this._hovered&&this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),this._hovered=null;this._pointerAnyDown&&(this._dragging||this.onDragStart(e),this.onDrag(e))}onDrag(e){this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0));const t=this._intersects[0];t&&(this._dragCurrent.copy(t.point.clone()),this._dragEnd.copy(t.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(e){switch(this.pointerWasDragged()||this._dragging?this._draggable&&this.onDragEnd(e):this.onClick(e),e.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(e){}onDragEnd(e){const t=this._intersects[0];t&&(this._dragEnd.copy(t.point.clone()),this._dragCurrent.copy(t.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(e){}raycast(e){const s=(e||this._scene.children).filter(o=>o.visible&&"isMesh"in o&&o.isMesh);return this._raycaster.intersectObjects(s,!0)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>this.POINTER_DRAG_THRESHOLD}}exports.DIVEBaseTool=Rt;exports.DIVESelectTool=$;exports.DIVETransformTool=J;exports.DragTool=dt;exports.HoverTool=ct;exports.SelectTool=$;exports.SelectionState=lt;exports.Toolbox=Gt;exports.TransformTool=J;exports.isSelectTool=St;exports.isTransformTool=Lt;
1
+ "use strict";var vt=Object.defineProperty;var Mt=(h,e,t)=>e in h?vt(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var r=(h,e,t)=>Mt(h,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("three");require("../../chunks/FileTypes-BHH0KUFf.cjs");const M=require("../../chunks/PerspectiveCamera-iAsZqrnY.cjs"),S=require("../../chunks/findInterface-C6mrvf_t.cjs"),j=require("../../chunks/AxisHelperColors-BrGqktN5.cjs");class lt{constructor(){r(this,"_selected",null);r(this,"_listeners",new Set)}get selected(){return this._selected}select(e){var t,s,o;this._selected!==e&&(this._selected&&((s=(t=this._selected).onDeselect)==null||s.call(t)),this._selected=e,(o=e.onSelect)==null||o.call(e),this.notifyListeners())}deselect(){var e,t;this._selected&&((t=(e=this._selected).onDeselect)==null||t.call(e),this._selected=null,this.notifyListeners())}onChange(e){this._listeners.add(e)}offChange(e){this._listeners.delete(e)}dispose(){this._selected=null,this._listeners.clear()}notifyListeners(){for(const e of this._listeners)e(this._selected)}}class ct{constructor(){r(this,"name","hover");r(this,"priority",20);r(this,"_hovered",null)}get hovered(){return this._hovered}onActivate(){this._hovered=null}onDeactivate(){var e,t;this._hovered&&((t=(e=this._hovered).onPointerLeave)==null||t.call(e),this._hovered=null)}onPointerMove(e){var o,a,n,l,_,w,P;const t=e.modelIntersects[0],s=S.findInterface(t==null?void 0:t.object,"isHoverable");if(t&&s){if(!this._hovered){(o=s.onPointerEnter)==null||o.call(s,t),this._hovered=s;return}if(this._hovered.uuid!==s.uuid){(n=(a=this._hovered).onPointerLeave)==null||n.call(a),(l=s.onPointerEnter)==null||l.call(s,t),this._hovered=s;return}(_=s.onPointerOver)==null||_.call(s,t);return}this._hovered&&((P=(w=this._hovered).onPointerLeave)==null||P.call(w),this._hovered=null)}}const St=h=>h.name==="select";class ${constructor(e){r(this,"name","select");r(this,"priority",30);r(this,"_selectionState");this._selectionState=e}get selected(){return this._selectionState.selected}onActivate(){}onDeactivate(){}onClick(e){const t=e.modelIntersects[0],s=S.findInterface(t==null?void 0:t.object,"isSelectable");if(!t||!s){this._selectionState.deselect();return}const o=this._selectionState.selected;o&&o.uuid===s.uuid||this._selectionState.select(s)}select(e){this._selectionState.select(e)}deselect(){this._selectionState.deselect()}}const A=new i.Raycaster,p=new i.Vector3,T=new i.Vector3,d=new i.Quaternion,it={X:new i.Vector3(1,0,0),Y:new i.Vector3(0,1,0),Z:new i.Vector3(0,0,1)},N={type:"change"},st={type:"mouseDown"},nt={type:"mouseUp",mode:null},ot={type:"objectChange"};class Pt extends i.Object3D{constructor(e,t){super(),t===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const s=new At;this._gizmo=s,this.add(s);const o=new Ct;this._plane=o,this.add(o);const a=this;function n(u,f){let L=f;Object.defineProperty(a,u,{get:function(){return L!==void 0?L:f},set:function(I){L!==I&&(L=I,o[u]=I,s[u]=I,a.dispatchEvent({type:u+"-changed",value:I}),a.dispatchEvent(N))}}),a[u]=f,o[u]=f,s[u]=f}n("camera",e),n("object",void 0),n("enabled",!0),n("axis",null),n("mode","translate"),n("translationSnap",null),n("rotationSnap",null),n("scaleSnap",null),n("space","world"),n("size",1),n("dragging",!1),n("showX",!0),n("showY",!0),n("showZ",!0);const l=new i.Vector3,_=new i.Vector3,w=new i.Quaternion,P=new i.Quaternion,G=new i.Vector3,R=new i.Quaternion,tt=new i.Vector3,X=new i.Vector3,D=new i.Vector3,E=0,b=new i.Vector3;n("worldPosition",l),n("worldPositionStart",_),n("worldQuaternion",w),n("worldQuaternionStart",P),n("cameraPosition",G),n("cameraQuaternion",R),n("pointStart",tt),n("pointEnd",X),n("rotationAxis",D),n("rotationAngle",E),n("eye",b),this._offset=new i.Vector3,this._startNorm=new i.Vector3,this._endNorm=new i.Vector3,this._cameraScale=new i.Vector3,this._parentPosition=new i.Vector3,this._parentQuaternion=new i.Quaternion,this._parentQuaternionInv=new i.Quaternion,this._parentScale=new i.Vector3,this._worldScaleStart=new i.Vector3,this._worldQuaternionInv=new i.Quaternion,this._worldScale=new i.Vector3,this._positionStart=new i.Vector3,this._quaternionStart=new i.Quaternion,this._scaleStart=new i.Vector3,this._getPointer=Dt.bind(this),this._onPointerDown=xt.bind(this),this._onPointerHover=Et.bind(this),this._onPointerMove=Tt.bind(this),this._onPointerUp=It.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(e){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(e)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&A.setFromCamera(e,this.camera);const t=K(this._gizmo.picker[this.mode],A);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&A.setFromCamera(e,this.camera);const t=K(this._plane,A,!0);t&&(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(t.point).sub(this.worldPositionStart)),this.dragging=!0,st.mode=this.mode,this.dispatchEvent(st)}}pointerMove(e){const t=this.axis,s=this.mode,o=this.object;let a=this.space;if(s==="scale"?a="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(a="world"),o===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&A.setFromCamera(e,this.camera);const n=K(this._plane,A,!0);if(n){if(this.pointEnd.copy(n.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),a==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),a==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),o.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(a==="local"&&(o.position.applyQuaternion(d.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.position.applyQuaternion(this._quaternionStart)),a==="world"&&(o.parent&&o.position.add(p.setFromMatrixPosition(o.parent.matrixWorld)),t.search("X")!==-1&&(o.position.x=Math.round(o.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(o.position.y=Math.round(o.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(o.position.z=Math.round(o.position.z/this.translationSnap)*this.translationSnap),o.parent&&o.position.sub(p.setFromMatrixPosition(o.parent.matrixWorld))));else if(s==="scale"){if(t.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),T.set(l,l,l)}else p.copy(this.pointStart),T.copy(this.pointEnd),p.applyQuaternion(this._worldQuaternionInv),T.applyQuaternion(this._worldQuaternionInv),T.divide(p),t.search("X")===-1&&(T.x=1),t.search("Y")===-1&&(T.y=1),t.search("Z")===-1&&(T.z=1);o.scale.copy(this._scaleStart).multiply(T),this.scaleSnap&&(t.search("X")!==-1&&(o.scale.x=Math.round(o.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(o.scale.y=Math.round(o.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(o.scale.z=Math.round(o.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(p.setFromMatrixPosition(this.camera.matrixWorld));let _=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(p.copy(this.rotationAxis).cross(this.eye))*l):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(it[t]),p.copy(it[t]),a==="local"&&p.applyQuaternion(this.worldQuaternion),p.cross(this.eye),p.length()===0?_=!0:this.rotationAngle=this._offset.dot(p.normalize())*l),(t==="E"||_)&&(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"&&t!=="E"&&t!=="XYZE"?(o.quaternion.copy(this._quaternionStart),o.quaternion.multiply(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),o.quaternion.copy(d.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),o.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(N),this.dispatchEvent(ot)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(nt.mode=this.mode,this.dispatchEvent(nt)),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(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,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(N),this.dispatchEvent(ot),this.pointStart.copy(this.pointEnd))}getRaycaster(){return A}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Dt(h){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:h.button};{const e=this.domElement.getBoundingClientRect();return{x:(h.clientX-e.left)/e.width*2-1,y:-(h.clientY-e.top)/e.height*2+1,button:h.button}}}function Et(h){if(this.enabled)switch(h.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(h));break}}function xt(h){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(h.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(h)),this.pointerDown(this._getPointer(h)))}function Tt(h){this.enabled&&this.pointerMove(this._getPointer(h))}function It(h){this.enabled&&(this.domElement.releasePointerCapture(h.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(h)))}function K(h,e,t){const s=e.intersectObject(h,!0);for(let o=0;o<s.length;o++)if(s[o].object.visible||t)return s[o];return!1}const B=new i.Euler,c=new i.Vector3(0,1,0),rt=new i.Vector3(0,0,0),at=new i.Matrix4,q=new i.Quaternion,F=new i.Quaternion,v=new i.Vector3,ht=new i.Matrix4,H=new i.Vector3(1,0,0),C=new i.Vector3(0,1,0),O=new i.Vector3(0,0,1),U=new i.Vector3,Y=new i.Vector3,Q=new i.Vector3;class At extends i.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new i.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new i.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const o=t.clone();o.opacity=.5;const a=e.clone();a.color.setHex(16711680);const n=e.clone();n.color.setHex(65280);const l=e.clone();l.color.setHex(255);const _=e.clone();_.color.setHex(16711680),_.opacity=.5;const w=e.clone();w.color.setHex(65280),w.opacity=.5;const P=e.clone();P.color.setHex(255),P.opacity=.5;const G=e.clone();G.opacity=.25;const R=e.clone();R.color.setHex(16776960),R.opacity=.25,e.clone().color.setHex(16776960);const X=e.clone();X.color.setHex(7895160);const D=new i.CylinderGeometry(0,.04,.1,12);D.translate(0,.05,0);const E=new i.BoxGeometry(.08,.08,.08);E.translate(0,.04,0);const b=new i.BufferGeometry;b.setAttribute("position",new i.Float32BufferAttribute([0,0,0,1,0,0],3));const u=new i.CylinderGeometry(.0075,.0075,.5,3);u.translate(0,.25,0);function f(m,k){const y=new i.TorusGeometry(m,.0075,3,64,k*Math.PI*2);return y.rotateY(Math.PI/2),y.rotateX(Math.PI/2),y}function L(){const m=new i.BufferGeometry;return m.setAttribute("position",new i.Float32BufferAttribute([0,0,0,1,1,1],3)),m}const I={X:[[new i.Mesh(D,a),[.5,0,0],[0,0,-Math.PI/2]],[new i.Mesh(D,a),[-.5,0,0],[0,0,Math.PI/2]],[new i.Mesh(u,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new i.Mesh(D,n),[0,.5,0]],[new i.Mesh(D,n),[0,-.5,0],[Math.PI,0,0]],[new i.Mesh(u,n)]],Z:[[new i.Mesh(D,l),[0,0,.5],[Math.PI/2,0,0]],[new i.Mesh(D,l),[0,0,-.5],[-Math.PI/2,0,0]],[new i.Mesh(u,l),null,[Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.OctahedronGeometry(.1,0),G.clone()),[0,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),P.clone()),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),_.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),w.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},pt={X:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.OctahedronGeometry(.2,0),s)]],XY:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},_t={START:[[new i.Mesh(new i.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new i.Mesh(new i.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new i.Line(L(),o),null,null,null,"helper"]],X:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new i.Line(b,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new i.Line(b,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ut={XYZE:[[new i.Mesh(f(.5,1),X),null,[0,Math.PI/2,0]]],X:[[new i.Mesh(f(.5,.5),a)]],Y:[[new i.Mesh(f(.5,.5),n),null,[0,0,-Math.PI/2]]],Z:[[new i.Mesh(f(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new i.Mesh(f(.75,1),R),null,[0,Math.PI/2,0]]]},gt={AXIS:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},mt={XYZE:[[new i.Mesh(new i.SphereGeometry(.25,10,8),s)]],X:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new i.Mesh(new i.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new i.Mesh(new i.TorusGeometry(.75,.1,2,24),s)]]},ft={X:[[new i.Mesh(E,a),[.5,0,0],[0,0,-Math.PI/2]],[new i.Mesh(u,a),[0,0,0],[0,0,-Math.PI/2]],[new i.Mesh(E,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(E,n),[0,.5,0]],[new i.Mesh(u,n)],[new i.Mesh(E,n),[0,-.5,0],[0,0,Math.PI]]],Z:[[new i.Mesh(E,l),[0,0,.5],[Math.PI/2,0,0]],[new i.Mesh(u,l),[0,0,0],[Math.PI/2,0,0]],[new i.Mesh(E,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),P),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),_),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.15,.15,.01),w),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.BoxGeometry(.1,.1,.1),G.clone())]]},yt={X:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new i.Mesh(new i.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new i.Mesh(new i.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},wt={X:[[new i.Line(b,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new i.Line(b,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new i.Line(b,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function x(m){const k=new i.Object3D;for(const y in m)for(let z=m[y].length;z--;){const g=m[y][z][0].clone(),V=m[y][z][1],Z=m[y][z][2],W=m[y][z][3],bt=m[y][z][4];g.name=y,g.tag=bt,V&&g.position.set(V[0],V[1],V[2]),Z&&g.rotation.set(Z[0],Z[1],Z[2]),W&&g.scale.set(W[0],W[1],W[2]),g.updateMatrix();const et=g.geometry.clone();et.applyMatrix4(g.matrix),g.geometry=et,g.renderOrder=1/0,g.position.set(0,0,0),g.rotation.set(0,0,0),g.scale.set(1,1,1),k.add(g)}return k}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=x(I)),this.add(this.gizmo.rotate=x(ut)),this.add(this.gizmo.scale=x(ft)),this.add(this.picker.translate=x(pt)),this.add(this.picker.rotate=x(mt)),this.add(this.picker.scale=x(yt)),this.add(this.helper.translate=x(_t)),this.add(this.helper.rotate=x(gt)),this.add(this.helper.scale=x(wt)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(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 o=[];o=o.concat(this.picker[this.mode].children),o=o.concat(this.gizmo[this.mode].children),o=o.concat(this.helper[this.mode].children);for(let a=0;a<o.length;a++){const n=o[a];n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition);let l;if(this.camera.isOrthographicCamera?l=(this.camera.top-this.camera.bottom)/this.camera.zoom:l=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(l*this.size/4),n.tag==="helper"){n.visible=!1,n.name==="AXIS"?(n.visible=!!this.axis,this.axis==="X"&&(d.setFromEuler(B.set(0,0,0)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Y"&&(d.setFromEuler(B.set(0,0,Math.PI/2)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="Z"&&(d.setFromEuler(B.set(0,Math.PI/2,0)),n.quaternion.copy(s).multiply(d),Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))>.9&&(n.visible=!1)),this.axis==="XYZE"&&(d.setFromEuler(B.set(0,Math.PI/2,0)),c.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(at.lookAt(rt,c,C)),n.quaternion.multiply(d),n.visible=this.dragging),this.axis==="E"&&(n.visible=!1)):n.name==="START"?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):n.name==="END"?(n.position.copy(this.worldPosition),n.visible=this.dragging):n.name==="DELTA"?(n.position.copy(this.worldPositionStart),n.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()),n.scale.copy(p),n.visible=this.dragging):(n.quaternion.copy(s),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=this.axis.search(n.name)!==-1));continue}n.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(n.name==="X"&&Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Y"&&Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="Z"&&Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))>.99&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XY"&&Math.abs(c.copy(O).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="YZ"&&Math.abs(c.copy(H).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),n.name==="XZ"&&Math.abs(c.copy(C).applyQuaternion(s).dot(this.eye))<.2&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)):this.mode==="rotate"&&(q.copy(s),c.copy(this.eye).applyQuaternion(d.copy(s).invert()),n.name.search("E")!==-1&&n.quaternion.setFromRotationMatrix(at.lookAt(this.eye,rt,C)),n.name==="X"&&(d.setFromAxisAngle(H,Math.atan2(-c.y,c.z)),d.multiplyQuaternions(q,d),n.quaternion.copy(d)),n.name==="Y"&&(d.setFromAxisAngle(C,Math.atan2(c.x,c.z)),d.multiplyQuaternions(q,d),n.quaternion.copy(d)),n.name==="Z"&&(d.setFromAxisAngle(O,Math.atan2(c.y,c.x)),d.multiplyQuaternions(q,d),n.quaternion.copy(d))),n.visible=n.visible&&(n.name.indexOf("X")===-1||this.showX),n.visible=n.visible&&(n.name.indexOf("Y")===-1||this.showY),n.visible=n.visible&&(n.name.indexOf("Z")===-1||this.showZ),n.visible=n.visible&&(n.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some(function(_){return n.name===_}))&&(n.material.color.setHex(16776960),n.material.opacity=1)}super.updateMatrixWorld(e)}}class Ct extends i.Mesh{constructor(){super(new i.PlaneGeometry(1e5,1e5,2,2),new i.MeshBasicMaterial({visible:!1,wireframe:!0,side:i.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),U.copy(H).applyQuaternion(t==="local"?this.worldQuaternion:F),Y.copy(C).applyQuaternion(t==="local"?this.worldQuaternion:F),Q.copy(O).applyQuaternion(t==="local"?this.worldQuaternion:F),c.copy(Y),this.mode){case"translate":case"scale":switch(this.axis){case"X":c.copy(this.eye).cross(U),v.copy(U).cross(c);break;case"Y":c.copy(this.eye).cross(Y),v.copy(Y).cross(c);break;case"Z":c.copy(this.eye).cross(Q),v.copy(Q).cross(c);break;case"XY":v.copy(Q);break;case"YZ":v.copy(U);break;case"XZ":c.copy(Q),v.copy(Y);break;case"XYZ":case"E":v.set(0,0,0);break}break;case"rotate":default:v.set(0,0,0)}v.length()===0?this.quaternion.copy(this.cameraQuaternion):(ht.lookAt(p.set(0,0,0),v,c),this.quaternion.setFromRotationMatrix(ht)),super.updateMatrixWorld(e)}}const Lt=h=>h.name==="transform";class J extends i.EventDispatcher{constructor(t,s,o){super();r(this,"name","transform");r(this,"priority",5);r(this,"_scene");r(this,"_controller");r(this,"_selectionState");r(this,"_gizmo");r(this,"_scaleLinked",!1);r(this,"_gizmoVisible",!0);r(this,"_selectionChangeHandler");this._scene=t,this._controller=s,this._selectionState=o,this._gizmo=this.initGizmo(),this._scene.add(this._gizmo),this._selectionChangeHandler=this.onSelectionChange.bind(this)}get gizmo(){return this._gizmo}get isDragging(){return this._gizmo.dragging}onActivate(){this._selectionState.onChange(this._selectionChangeHandler);const t=this._selectionState.selected;t&&this.attachGizmo(t)}onDeactivate(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach()}onPointerMove(t){if(this._gizmo.dragging||t.uiIntersects.length>0&&t.uiIntersects.some(o=>this.isGizmoChild(o.object)))return!0}setGizmoMode(t){this._gizmo.mode=t}setGizmoVisible(t){this._gizmoVisible=t;const s=this._scene.children.includes(this._gizmo);t&&!s?(this._scene.add(this._gizmo),this._gizmo.getRaycaster().layers.enableAll()):!t&&s&&(this._scene.remove(this._gizmo),this._gizmo.getRaycaster().layers.disableAll())}setGizmoScaleLinked(t){this._scaleLinked=t}dispose(){this._selectionState.offChange(this._selectionChangeHandler),this._gizmo.detach(),this._scene.remove(this._gizmo),this._gizmo.dispose()}onSelectionChange(t){t&&S.implementsInterface(t,"isMovable")?this.attachGizmo(t):this._gizmo.detach()}attachGizmo(t){S.implementsInterface(t,"isMovable")&&(this._gizmo.attach(t),this.setGizmoVisible(t.visible&&this._gizmoVisible))}isGizmoChild(t){let s=t;for(;s;){if(s===this._gizmo)return!0;s=s.parent}return!1}initGizmo(){const t=new Pt(this._controller.object,this._controller.domElement);return t.mode="translate",t.traverse(s=>{if(!("isMesh"in s))return;const o=s.material;s.name==="X"&&o.color.set(j.AxesColorRed),s.name==="Y"&&o.color.set(j.AxesColorGreen),s.name==="Z"&&o.color.set(j.AxesColorBlue),s.name==="XY"&&o.color.set(j.AxesColorBlue),s.name==="YZ"&&o.color.set(j.AxesColorRed),s.name==="XZ"&&o.color.set(j.AxesColorGreen)}),t.addEventListener("mouseDown",()=>{var s,o;this._controller.enabled=!1,S.implementsInterface(t.object,"isMovable")&&((o=(s=t.object).onMoveStart)==null||o.call(s))}),t.addEventListener("objectChange",()=>{var s,o;if(S.implementsInterface(t.object,"isMovable")){if((o=(s=t.object).onMove)==null||o.call(s),this._scaleLinked&&t.object){const a=t.object.scale,n=(a.x+a.y+a.z)/3;t.object.scale.set(n,n,n)}switch(this.dispatchEvent({type:"object-change",object:t.object}),t.mode){case"translate":this.dispatchEvent({type:"object-position-change",object:t.object});break;case"rotate":this.dispatchEvent({type:"object-rotation-change",object:t.object});break;case"scale":this.dispatchEvent({type:"object-scale-change",object:t.object});break}}}),t.addEventListener("mouseUp",()=>{var s,o;this._controller.enabled=!0,S.implementsInterface(t.object,"isMovable")&&((o=(s=t.object).onMoveEnd)==null||o.call(s))}),t}}const zt=.001;class dt{constructor(e){r(this,"name","drag");r(this,"priority",10);r(this,"_controller");r(this,"_raycaster");r(this,"_dragging",!1);r(this,"_draggable",null);r(this,"_dragStart",new i.Vector3);r(this,"_dragCurrent",new i.Vector3);r(this,"_dragEnd",new i.Vector3);r(this,"_dragDelta",new i.Vector3);r(this,"_dragRaycastTargets",null);this._controller=e,this._raycaster=new i.Raycaster}get isDragging(){return this._dragging}get draggable(){return this._draggable}onActivate(){this.resetDragState()}onDeactivate(){this._dragging&&this._draggable&&this.endDrag(),this.resetDragState()}onPointerDown(e){var t;e.pointerPrimaryDown&&(this._draggable=S.findInterface((t=e.intersects[0])==null?void 0:t.object,"isDraggable")||null)}onPointerMove(e){if(e.pointerPrimaryDown&&this._draggable&&(this._raycaster.setFromCamera(e.pointer,this._controller.object),this._dragging||e.lastPointerDown.distanceTo(e.pointer)>zt&&this.startDrag(e),this._dragging))return this.updateDrag(e),!0}onPointerUp(e){this._dragging&&(this._raycaster.setFromCamera(e.pointer,this._controller.object),this.endDrag()),this._draggable=null}setDragRaycastTargets(e){this._dragRaycastTargets=e}startDrag(e){var s,o;const t=this.getDragIntersect(e);t&&(this._dragStart.copy(t.point),this._dragCurrent.copy(t.point),this._dragEnd.copy(t.point),this._dragDelta.set(0,0,0),(o=(s=this._draggable)==null?void 0:s.onDragStart)==null||o.call(s,this.createDragEvent()),this._dragging=!0,this._controller.enabled=!1)}updateDrag(e){var s,o;const t=this.getDragIntersect(e);t&&(this._dragCurrent.copy(t.point),this._dragEnd.copy(t.point),this._dragDelta.subVectors(this._dragCurrent,this._dragStart),(o=(s=this._draggable)==null?void 0:s.onDrag)==null||o.call(s,this.createDragEvent()))}endDrag(){var t,s;const e=this.createDragEvent();(s=(t=this._draggable)==null?void 0:t.onDragEnd)==null||s.call(t,e),this._dragging=!1,this._controller.enabled=!0,this.resetDragState()}getDragIntersect(e){return this._dragRaycastTargets?this._raycaster.intersectObjects(this._dragRaycastTargets,!0)[0]||null:e.intersects[0]||null}createDragEvent(){return{dragStart:this._dragStart.clone(),dragCurrent:this._dragCurrent.clone(),dragEnd:this._dragEnd.clone(),dragDelta:this._dragDelta.clone()}}resetDragState(){this._dragStart.set(0,0,0),this._dragCurrent.set(0,0,0),this._dragEnd.set(0,0,0),this._dragDelta.set(0,0,0)}}const jt=.001;class Gt{constructor(e,t){r(this,"_scene");r(this,"_controller");r(this,"_canvas");r(this,"_tools");r(this,"_activeTools",new Map);r(this,"_sortedActiveTools",[]);r(this,"_selectionState");r(this,"_raycaster");r(this,"_pointer");r(this,"_productLayerMask");r(this,"_uiLayerMask");r(this,"_pointerPrimaryDown",!1);r(this,"_pointerMiddleDown",!1);r(this,"_pointerSecondaryDown",!1);r(this,"_lastPointerDown");r(this,"_boundPointerMove");r(this,"_boundPointerDown");r(this,"_boundPointerUp");r(this,"_boundWheel");this._scene=e,this._controller=t,this._canvas=t.domElement,this._selectionState=new lt,this._raycaster=new i.Raycaster,this._pointer=new i.Vector2,this._lastPointerDown=new i.Vector2,this._productLayerMask=new i.Layers,this._productLayerMask.set(Math.log2(M.PRODUCT_LAYER_MASK)),this._uiLayerMask=new i.Layers,this._uiLayerMask.set(Math.log2(M.UI_LAYER_MASK)),this._tools=new Map([["hover",new ct],["select",new $(this._selectionState)],["transform",new J(e,t,this._selectionState)],["drag",new dt(t)]]),this._boundPointerMove=this.onPointerMove.bind(this),this._boundPointerDown=this.onPointerDown.bind(this),this._boundPointerUp=this.onPointerUp.bind(this),this._boundWheel=this.onWheel.bind(this),this._canvas.addEventListener("pointermove",this._boundPointerMove),this._canvas.addEventListener("pointerdown",this._boundPointerDown),this._canvas.addEventListener("pointerup",this._boundPointerUp),this._canvas.addEventListener("wheel",this._boundWheel)}get selectionState(){return this._selectionState}enableTool(e){var s;const t=this._tools.get(e);t&&(this._activeTools.has(e)||(this._activeTools.set(e,t),this.updateSortedTools(),(s=t.onActivate)==null||s.call(t)))}disableTool(e){var s;const t=this._activeTools.get(e);t&&((s=t.onDeactivate)==null||s.call(t),this._activeTools.delete(e),this.updateSortedTools())}isToolEnabled(e){return this._activeTools.has(e)}getTool(e){return this._tools.get(e)}getActiveTools(){return[...this._sortedActiveTools]}dispose(){var e;for(const t of this._activeTools.values())(e=t.onDeactivate)==null||e.call(t);this._activeTools.clear(),this._tools.clear(),this._sortedActiveTools=[],this._canvas.removeEventListener("pointermove",this._boundPointerMove),this._canvas.removeEventListener("pointerdown",this._boundPointerDown),this._canvas.removeEventListener("pointerup",this._boundPointerUp),this._canvas.removeEventListener("wheel",this._boundWheel),this._selectionState.dispose()}onPointerMove(e){var s;this.updatePointer(e);const t=this.createPointerContext(e);for(const o of this._sortedActiveTools)if((s=o.onPointerMove)==null?void 0:s.call(o,t))break}onPointerDown(e){var s;this.updatePointerState(e,!0),this.updatePointer(e),this._lastPointerDown.copy(this._pointer);const t=this.createPointerContext(e);for(const o of this._sortedActiveTools)if((s=o.onPointerDown)==null?void 0:s.call(o,t))break}onPointerUp(e){var o,a;this.updatePointer(e);const t=this.createPointerContext(e),s=!this.pointerWasDragged();for(const n of this._sortedActiveTools)if((o=n.onPointerUp)==null?void 0:o.call(n,t))break;if(s){for(const n of this._sortedActiveTools)if((a=n.onClick)==null?void 0:a.call(n,t))break}this.updatePointerState(e,!1)}onWheel(e){var s;const t=this.createWheelContext(e);for(const o of this._sortedActiveTools)if((s=o.onWheel)==null?void 0:s.call(o,t))break}createPointerContext(e){const t=this.raycast();return{event:e,pointer:this._pointer.clone(),intersects:t,modelIntersects:this.filterIntersectsByLayer(t,M.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(t,M.UI_LAYER_MASK),pointerPrimaryDown:this._pointerPrimaryDown,pointerMiddleDown:this._pointerMiddleDown,pointerSecondaryDown:this._pointerSecondaryDown,lastPointerDown:this._lastPointerDown.clone()}}createWheelContext(e){const t=this.raycast();return{event:e,pointer:this._pointer.clone(),intersects:t,modelIntersects:this.filterIntersectsByLayer(t,M.PRODUCT_LAYER_MASK),uiIntersects:this.filterIntersectsByLayer(t,M.UI_LAYER_MASK)}}updatePointer(e){this._pointer.x=e.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(e.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object)}updatePointerState(e,t){switch(e.button){case 0:this._pointerPrimaryDown=t;break;case 1:this._pointerMiddleDown=t;break;case 2:this._pointerSecondaryDown=t;break}}raycast(){this._raycaster.layers.mask=M.PRODUCT_LAYER_MASK|M.UI_LAYER_MASK;const e=this._scene.children.filter(t=>t.visible&&"isMesh"in t&&t.isMesh);return this._raycaster.intersectObjects(e,!0)}filterIntersectsByLayer(e,t){return e.filter(s=>(s.object.layers.mask&t)!==0)}updateSortedTools(){this._sortedActiveTools=[...this._activeTools.values()].sort((e,t)=>e.priority-t.priority)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>jt}useTool(e){const t=["hover","select","transform","drag"];for(const s of t)(s===e||e==="select")&&this.enableTool(s)}getActiveTool(){return this._sortedActiveTools[0]||null}}class Rt{constructor(e,t){r(this,"POINTER_DRAG_THRESHOLD",.001);r(this,"name");r(this,"_canvas");r(this,"_scene");r(this,"_controller");r(this,"_pointer");r(this,"_pointerPrimaryDown");r(this,"_pointerMiddleDown");r(this,"_pointerSecondaryDown");r(this,"_lastPointerDown");r(this,"_lastPointerUp");r(this,"_raycaster");r(this,"_intersects");r(this,"_hovered");r(this,"_dragging");r(this,"_dragStart");r(this,"_dragCurrent");r(this,"_dragEnd");r(this,"_dragDelta");r(this,"_draggable");r(this,"_dragRaycastOnObjects");this.name="BaseTool",this._canvas=t.domElement,this._scene=e,this._controller=t,this._pointer=new i.Vector2,this._pointerPrimaryDown=!1,this._pointerMiddleDown=!1,this._pointerSecondaryDown=!1,this._lastPointerDown=new i.Vector2,this._lastPointerUp=new i.Vector2,this._raycaster=new i.Raycaster,this._raycaster.layers.mask=M.PRODUCT_LAYER_MASK|M.UI_LAYER_MASK,this._intersects=[],this._hovered=null,this._dragging=!1,this._dragStart=new i.Vector3,this._dragCurrent=new i.Vector3,this._dragEnd=new i.Vector3,this._dragDelta=new i.Vector3,this._draggable=null,this._dragRaycastOnObjects=null}get _pointerAnyDown(){return this._pointerPrimaryDown||this._pointerMiddleDown||this._pointerSecondaryDown}activate(){}deactivate(){}onPointerDown(e){var t;switch(e.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: "+e.button)}this._lastPointerDown.copy(this._pointer),this._draggable=S.findInterface((t=this._intersects[0])==null?void 0:t.object,"isDraggable")||null}onDragStart(e){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(e){var s;this._pointer.x=e.offsetX/this._canvas.clientWidth*2-1,this._pointer.y=-(e.offsetY/this._canvas.clientHeight)*2+1,this._raycaster.setFromCamera(this._pointer,this._controller.object),this._intersects=this.raycast(this._scene.children);const t=S.findInterface((s=this._intersects[0])==null?void 0:s.object,"isHoverable");if(this._intersects[0]&&t){if(!this._hovered){t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}if(this._hovered.uuid!==t.uuid){this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),t.onPointerEnter&&t.onPointerEnter(this._intersects[0]),this._hovered=t;return}t.onPointerOver&&t.onPointerOver(this._intersects[0]),this._hovered=t}else this._hovered&&this._hovered.onPointerLeave&&this._hovered.onPointerLeave(),this._hovered=null;this._pointerAnyDown&&(this._dragging||this.onDragStart(e),this.onDrag(e))}onDrag(e){this._dragRaycastOnObjects!==null&&(this._intersects=this._raycaster.intersectObjects(this._dragRaycastOnObjects,!0));const t=this._intersects[0];t&&(this._dragCurrent.copy(t.point.clone()),this._dragEnd.copy(t.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(e){switch(this.pointerWasDragged()||this._dragging?this._draggable&&this.onDragEnd(e):this.onClick(e),e.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(e){}onDragEnd(e){const t=this._intersects[0];t&&(this._dragEnd.copy(t.point.clone()),this._dragCurrent.copy(t.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(e){}raycast(e){const s=(e||this._scene.children).filter(o=>o.visible&&"isMesh"in o&&o.isMesh);return this._raycaster.intersectObjects(s,!0)}pointerWasDragged(){return this._lastPointerDown.distanceTo(this._pointer)>this.POINTER_DRAG_THRESHOLD}}exports.DIVEBaseTool=Rt;exports.DIVESelectTool=$;exports.DIVETransformTool=J;exports.DragTool=dt;exports.HoverTool=ct;exports.SelectTool=$;exports.SelectionState=lt;exports.Toolbox=Gt;exports.TransformTool=J;exports.isSelectTool=St;exports.isTransformTool=Lt;
@@ -2,7 +2,7 @@ var Ht = Object.defineProperty;
2
2
  var Xt = (l, e, t) => e in l ? Ht(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
3
  var o = (l, e, t) => Xt(l, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { Object3D as ht, Vector3 as h, Quaternion as E, Raycaster as ot, MeshBasicMaterial as Dt, LineBasicMaterial as kt, CylinderGeometry as w, BoxGeometry as f, BufferGeometry as dt, Float32BufferAttribute as pt, Mesh as r, OctahedronGeometry as tt, Line as A, TorusGeometry as Q, SphereGeometry as Yt, Euler as Qt, Matrix4 as Et, PlaneGeometry as Ot, DoubleSide as Rt, EventDispatcher as Zt, Vector2 as F, Layers as _t } from "three";
5
- import "../../chunks/FileTypes-BSG8CC2s.mjs";
5
+ import "../../chunks/FileTypes-B8g1qxjR.mjs";
6
6
  import { P as G, U as W } from "../../chunks/PerspectiveCamera-BFzE2TQU.mjs";
7
7
  import { f as B, i as O } from "../../chunks/findInterface-DbJ5qzbc.mjs";
8
8
  import { A as ut, a as gt, b as ft } from "../../chunks/AxisHelperColors-JLBHYQDi.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "build/dive.cjs",