shop-components 0.4.25 → 0.4.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shop-components.cjs +15 -15
- package/dist/shop-components.mjs +2 -2
- package/package.json +1 -1
package/dist/shop-components.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var _n=Object.create;var Di=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var yn=Object.getOwnPropertyNames;var xn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty;var bn=(a,e,t)=>e in a?Di(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var An=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of yn(e))!wn.call(a,s)&&s!==t&&Di(a,s,{get:()=>e[s],enumerable:!(i=vn(e,s))||i.enumerable});return a};var Tn=(a,e,t)=>(t=a!=null?_n(xn(a)):{},An(e||!a||!a.__esModule?Di(t,"default",{value:a,enumerable:!0}):t,a));var E=(a,e,t)=>(bn(a,typeof e!="symbol"?e+"":e,t),t),Es=(a,e,t)=>{if(!e.has(a))throw TypeError("Cannot "+t)};var Q=(a,e,t)=>(Es(a,e,"read from private field"),t?t.call(a):e.get(a)),Pe=(a,e,t)=>{if(e.has(a))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(a):e.set(a,t)},ye=(a,e,t,i)=>(Es(a,e,"write to private field"),i?i.call(a,t):e.set(a,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three"),ks=require("three/examples/jsm/loaders/HDRLoader.js"),Sn=require("three/examples/jsm/controls/OrbitControls"),be=require("three/examples/jsm/renderers/CSS2DRenderer"),Mn=require("three/examples/jsm/loaders/FontLoader"),ws=require("three/examples/jsm/loaders/GLTFLoader.js");require("three/examples/jsm/libs/meshopt_decoder.module.js");require("three/examples/jsm/loaders/DRACOLoader.js");const Cn=require("three/examples/jsm/loaders/GLTFLoader"),Dn=require("three/examples/jsm/loaders/DRACOLoader"),Ln=require("three/examples/jsm/exporters/DRACOExporter"),Pn=require("three/examples/jsm/exporters/GLTFExporter"),In=require("three/examples/jsm/utils/SkeletonUtils.js"),Rr=require("three/examples/jsm/lines/Line2.js"),Er=require("three/examples/jsm/lines/LineMaterial.js"),$i=require("three/examples/jsm/lines/LineGeometry.js"),Rn=require("three/examples/jsm/renderers/CSS3DRenderer");require("three/examples/jsm/utils/BufferGeometryUtils");const jt=require("three/examples/jsm/postprocessing/Pass"),Be=require("three-mesh-bvh"),_t=require("three/examples/jsm/postprocessing/Pass.js");var vt=typeof document<"u"?document.currentScript:null;function kr(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const V=kr(f),Li=kr(In);function Fr(a,e,t=0){if(a.isInterleavedBufferAttribute){const i=a.itemSize;for(let s=0,r=a.count;s<r;s++){const o=s+t;e.setX(o,a.getX(s)),i>=2&&e.setY(o,a.getY(s)),i>=3&&e.setZ(o,a.getZ(s)),i>=4&&e.setW(o,a.getW(s))}}else{const i=e.array,s=i.constructor,r=i.BYTES_PER_ELEMENT*a.itemSize*t;new s(i.buffer,r,a.array.length).set(a.array)}}function Ft(a,e=null){const t=a.array.constructor,i=a.normalized,s=a.itemSize,r=e===null?a.count:e;return new f.BufferAttribute(new t(s*r),s,i)}function ht(a,e){if(!a&&!e)return!0;if(!!a!=!!e)return!1;const t=a.count===e.count,i=a.normalized===e.normalized,s=a.array.constructor===e.array.constructor,r=a.itemSize===e.itemSize;return!(!t||!i||!s||!r)}function En(a){const e=a[0].index!==null,t=new Set(Object.keys(a[0].attributes));if(!a[0].getAttribute("position"))throw new Error("StaticGeometryGenerator: position attribute is required.");for(let i=0;i<a.length;++i){const s=a[i];let r=0;if(e!==(s.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const o in s.attributes){if(!t.has(o))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+o+'" attribute exists among all geometries, or in none of them.');r++}if(r!==t.size)throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.")}}function kn(a){let e=0;for(let t=0,i=a.length;t<i;t++)e+=a[t].getIndex().count;return e}function Fn(a){let e=0;for(let t=0,i=a.length;t<i;t++)e+=a[t].getAttribute("position").count;return e}function Bn(a,e,t){a.index&&a.index.count!==e&&a.setIndex(null);const i=a.attributes;for(const s in i)i[s].count!==t&&a.deleteAttribute(s)}function On(a,e={},t=new f.BufferGeometry){const{useGroups:i=!1,forceUpdate:s=!1,skipAssigningAttributes:r=[],overwriteIndex:o=!0}=e;En(a);const c=a[0].index!==null,h=c?kn(a):-1,u=Fn(a);if(Bn(t,h,u),i){let n=0;for(let l=0,d=a.length;l<d;l++){const g=a[l];let v;c?v=g.getIndex().count:v=g.getAttribute("position").count,t.addGroup(n,v,l),n+=v}}if(c){let n=!1;if(t.index||(t.setIndex(new f.BufferAttribute(new Uint32Array(h),1,!1)),n=!0),n||o){let l=0,d=0;const g=t.getIndex();for(let v=0,m=a.length;v<m;v++){const _=a[v],y=_.getIndex();if(!(!s&&!n&&r[v]))for(let x=0;x<y.count;++x)g.setX(l+x,y.getX(x)+d);l+=y.count,d+=_.getAttribute("position").count}}}const p=Object.keys(a[0].attributes);for(let n=0,l=p.length;n<l;n++){let d=!1;const g=p[n];if(!t.getAttribute(g)){const _=a[0].getAttribute(g);t.setAttribute(g,Ft(_,u)),d=!0}let v=0;const m=t.getAttribute(g);for(let _=0,y=a.length;_<y;_++){const w=a[_],x=!s&&!d&&r[_],b=w.getAttribute(g);x||Fr(b,m,v),v+=b.count}}}function zn(a,e,t){const i=a.index,r=a.attributes.position.count,o=i?i.count:r;let c=a.groups;c.length===0&&(c=[{count:o,start:0,materialIndex:0}]);let h=a.getAttribute("materialIndex");if(!h||h.count!==r){let p;t.length<=255?p=new Uint8Array(r):p=new Uint16Array(r),h=new f.BufferAttribute(p,1,!1),a.deleteAttribute("materialIndex"),a.setAttribute("materialIndex",h)}const u=h.array;for(let p=0;p<c.length;p++){const n=c[p],l=n.start,d=n.count,g=Math.min(d,o-l),v=Array.isArray(e)?e[n.materialIndex]:e,m=t.indexOf(v);for(let _=0;_<g;_++){let y=l+_;i&&(y=i.getX(y)),u[y]=m}}}function Vn(a,e){if(!a.index){const t=a.attributes.position.count,i=new Array(t);for(let s=0;s<t;s++)i[s]=s;a.setIndex(i)}if(!a.attributes.normal&&e&&e.includes("normal")&&a.computeVertexNormals(),!a.attributes.uv&&e&&e.includes("uv")){const t=a.attributes.position.count;a.setAttribute("uv",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!a.attributes.uv2&&e&&e.includes("uv2")){const t=a.attributes.position.count;a.setAttribute("uv2",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!a.attributes.tangent&&e&&e.includes("tangent"))if(a.attributes.uv&&a.attributes.normal)a.computeTangents();else{const t=a.attributes.position.count;a.setAttribute("tangent",new f.BufferAttribute(new Float32Array(t*4),4,!1))}if(!a.attributes.color&&e&&e.includes("color")){const t=a.attributes.position.count,i=new Float32Array(t*4);i.fill(1),a.setAttribute("color",new f.BufferAttribute(i,4))}}function bs(a){let e=0;if(a.byteLength!==0){const t=new Uint8Array(a);for(let i=0;i<a.byteLength;i++){const s=t[i];e=(e<<5)-e+s,e|=0}}return e}function Fs(a){let e=a.uuid;const t=Object.values(a.attributes);a.index&&(t.push(a.index),e+=`index|${a.index.version}`);const i=Object.keys(t).sort();for(const s of i){const r=t[s];e+=`${s}_${r.version}|`}return e}function Bs(a){const e=a.skeleton;return e?(e.boneTexture||e.computeBoneTexture(),`${bs(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`):null}class Wn{constructor(e=null){this.matrixWorld=new f.Matrix4,this.geometryHash=null,this.skeletonHash=null,this.primitiveCount=-1,e!==null&&this.updateFrom(e)}updateFrom(e){const t=e.geometry,i=(t.index?t.index.count:t.attributes.position.count)/3;this.matrixWorld.copy(e.matrixWorld),this.geometryHash=Fs(t),this.primitiveCount=i,this.skeletonHash=Bs(e)}didChange(e){const t=e.geometry,i=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===Fs(t)&&this.skeletonHash===Bs(e)&&this.primitiveCount===i)}}const We=new f.Vector3,Ue=new f.Vector3,He=new f.Vector3,Os=new f.Vector4,qt=new f.Vector3,Pi=new f.Vector3,zs=new f.Vector4,Vs=new f.Vector4,Yt=new f.Matrix4,Ws=new f.Matrix4;function Us(a,e,t){const i=a.skeleton,s=a.geometry,r=i.bones,o=i.boneInverses;zs.fromBufferAttribute(s.attributes.skinIndex,e),Vs.fromBufferAttribute(s.attributes.skinWeight,e),Yt.elements.fill(0);for(let c=0;c<4;c++){const h=Vs.getComponent(c);if(h!==0){const u=zs.getComponent(c);Ws.multiplyMatrices(r[u].matrixWorld,o[u]),Un(Yt,Ws,h)}}return Yt.multiply(a.bindMatrix).premultiply(a.bindMatrixInverse),t.transformDirection(Yt),t}function Ii(a,e,t,i,s){qt.set(0,0,0);for(let r=0,o=a.length;r<o;r++){const c=e[r],h=a[r];c!==0&&(Pi.fromBufferAttribute(h,i),t?qt.addScaledVector(Pi,c):qt.addScaledVector(Pi.sub(s),c))}s.add(qt)}function Un(a,e,t){const i=a.elements,s=e.elements;for(let r=0,o=s.length;r<o;r++)i[r]+=s[r]*t}function Hn(a){const{index:e,attributes:t}=a;if(e)for(let i=0,s=e.count;i<s;i+=3){const r=e.getX(i),o=e.getX(i+2);e.setX(i,o),e.setX(i+2,r)}else for(const i in t){const s=t[i],r=s.itemSize;for(let o=0,c=s.count;o<c;o+=3)for(let h=0;h<r;h++){const u=s.getComponent(o,h),p=s.getComponent(o+2,h);s.setComponent(o,h,p),s.setComponent(o+2,h,u)}}return a}function Gn(a,e={},t=new f.BufferGeometry){e={applyWorldTransforms:!0,attributes:[],...e};const i=a.geometry,s=e.applyWorldTransforms,r=e.attributes.includes("normal"),o=e.attributes.includes("tangent"),c=i.attributes,h=t.attributes;for(const y in t.attributes)(!e.attributes.includes(y)||!(y in i.attributes))&&t.deleteAttribute(y);!t.index&&i.index&&(t.index=i.index.clone()),h.position||t.setAttribute("position",Ft(c.position)),r&&!h.normal&&c.normal&&t.setAttribute("normal",Ft(c.normal)),o&&!h.tangent&&c.tangent&&t.setAttribute("tangent",Ft(c.tangent)),ht(i.index,t.index),ht(c.position,h.position),r&&ht(c.normal,h.normal),o&&ht(c.tangent,h.tangent);const u=c.position,p=r?c.normal:null,n=o?c.tangent:null,l=i.morphAttributes.position,d=i.morphAttributes.normal,g=i.morphAttributes.tangent,v=i.morphTargetsRelative,m=a.morphTargetInfluences,_=new f.Matrix3;_.getNormalMatrix(a.matrixWorld),i.index&&t.index.array.set(i.index.array);for(let y=0,w=c.position.count;y<w;y++)We.fromBufferAttribute(u,y),p&&Ue.fromBufferAttribute(p,y),n&&(Os.fromBufferAttribute(n,y),He.fromBufferAttribute(n,y)),m&&(l&&Ii(l,m,v,y,We),d&&Ii(d,m,v,y,Ue),g&&Ii(g,m,v,y,He)),a.isSkinnedMesh&&(a.applyBoneTransform(y,We),p&&Us(a,y,Ue),n&&Us(a,y,He)),s&&We.applyMatrix4(a.matrixWorld),h.position.setXYZ(y,We.x,We.y,We.z),p&&(s&&Ue.applyNormalMatrix(_),h.normal.setXYZ(y,Ue.x,Ue.y,Ue.z)),n&&(s&&He.transformDirection(a.matrixWorld),h.tangent.setXYZW(y,He.x,He.y,He.z,Os.w));for(const y in e.attributes){const w=e.attributes[y];w==="position"||w==="tangent"||w==="normal"||!(w in c)||(h[w]||t.setAttribute(w,Ft(c[w])),ht(c[w],h[w]),Fr(c[w],h[w]))}return a.matrixWorld.determinant()<0&&Hn(t),t}class Nn extends f.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new Wn}isCompatible(e,t){const i=e.geometry;for(let s=0;s<t.length;s++){const r=t[s],o=i.attributes[r],c=this.attributes[r];if(o&&!ht(o,c))return!1}return!0}updateFrom(e,t){const i=this._diff;return i.didChange(e)?(Gn(e,t,this),i.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}}const es=0,Br=1,Or=2;function Qn(a,e){for(let t=0,i=a.length;t<i;t++)a[t].traverseVisible(r=>{r.isMesh&&e(r)})}function jn(a){const e=[];for(let t=0,i=a.length;t<i;t++){const s=a[t];Array.isArray(s.material)?e.push(...s.material):e.push(s.material)}return e}function qn(a,e,t){if(a.length===0){e.setIndex(null);const i=e.attributes;for(const s in i)e.deleteAttribute(s);for(const s in t.attributes)e.setAttribute(t.attributes[s],new f.BufferAttribute(new Float32Array(0),4,!1))}else On(a,t,e);for(const i in e.attributes)e.attributes[i].needsUpdate=!0}class Yn{constructor(e){this.objects=null,this.useGroups=!0,this.applyWorldTransforms=!0,this.generateMissingAttributes=!0,this.overwriteIndex=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Map,this._geometryMergeSets=new WeakMap,this._mergeOrder=[],this._dummyMesh=null,this.setObjects(e||[])}_getDummyMesh(){if(!this._dummyMesh){const e=new f.MeshBasicMaterial,t=new f.BufferGeometry;t.setAttribute("position",new f.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new f.Mesh(t,e)}return this._dummyMesh}_getMeshes(){const e=[];return Qn(this.objects,t=>{e.push(t)}),e.sort((t,i)=>t.uuid>i.uuid?1:t.uuid<i.uuid?-1:0),e.length===0&&e.push(this._getDummyMesh()),e}_updateIntermediateGeometries(){const{_intermediateGeometry:e}=this,t=this._getMeshes(),i=new Set(e.keys()),s={attributes:this.attributes,applyWorldTransforms:this.applyWorldTransforms};for(let r=0,o=t.length;r<o;r++){const c=t[r],h=c.uuid;i.delete(h);let u=e.get(h);(!u||!u.isCompatible(c,this.attributes))&&(u&&u.dispose(),u=new Nn,e.set(h,u)),u.updateFrom(c,s)&&this.generateMissingAttributes&&Vn(u,this.attributes)}i.forEach(r=>{e.delete(r)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new f.BufferGeometry){const{useGroups:t,overwriteIndex:i,_intermediateGeometry:s,_geometryMergeSets:r}=this,o=this._getMeshes(),c=[],h=[],u=r.get(e)||[];this._updateIntermediateGeometries();let p=!1;o.length!==u.length&&(p=!0);for(let l=0,d=o.length;l<d;l++){const g=o[l],v=s.get(g.uuid);h.push(v);const m=u[l];!m||m.uuid!==v.uuid?(c.push(!1),p=!0):m.version!==v.version?c.push(!1):c.push(!0)}qn(h,e,{useGroups:t,forceUpdate:p,skipAssigningAttributes:c,overwriteIndex:i}),p&&e.dispose(),r.set(e,h.map(l=>({version:l.version,uuid:l.uuid})));let n=es;return p?n=Or:c.includes(!1)&&(n=Br),{changeType:n,materials:jn(o),geometry:e}}}function Zn(a){const e=new Set;for(let t=0,i=a.length;t<i;t++){const s=a[t];for(const r in s){const o=s[r];o&&o.isTexture&&e.add(o)}}return Array.from(e)}function Kn(a){const e=[],t=new Set;for(let s=0,r=a.length;s<r;s++)a[s].traverse(o=>{o.visible&&(o.isRectAreaLight||o.isSpotLight||o.isPointLight||o.isDirectionalLight)&&(e.push(o),o.iesMap&&t.add(o.iesMap))});const i=Array.from(t).sort((s,r)=>s.uuid<r.uuid?1:s.uuid>r.uuid?-1:0);return{lights:e,iesTextures:i}}class Xn{get initialized(){return!!this.bvh}constructor(e){this.bvhOptions={},this.attributes=["position","normal","tangent","color","uv","uv2"],this.generateBVH=!0,this.bvh=null,this.geometry=new f.BufferGeometry,this.staticGeometryGenerator=new Yn(e),this._bvhWorker=null,this._pendingGenerate=null,this._buildAsync=!1}setObjects(e){this.staticGeometryGenerator.setObjects(e)}setBVHWorker(e){this._bvhWorker=e}async generateAsync(e=null){if(!this._bvhWorker)throw new Error('PathTracingSceneGenerator: "setBVHWorker" must be called before "generateAsync" can be called.');if(this.bvh instanceof Promise)return this._pendingGenerate||(this._pendingGenerate=new Promise(async()=>(await this.bvh,this._pendingGenerate=null,this.generateAsync(e)))),this._pendingGenerate;{this._buildAsync=!0;const t=this.generate(e);return this._buildAsync=!1,t.bvh=this.bvh=await t.bvh,t}}generate(e=null){const{staticGeometryGenerator:t,geometry:i,attributes:s}=this,r=t.objects;t.attributes=s,r.forEach(n=>{n.traverse(l=>{l.isSkinnedMesh&&l.skeleton&&l.skeleton.update()})});const o=t.generate(i),c=o.materials,h=Zn(c),{lights:u,iesTextures:p}=Kn(r);if(o.changeType!==es&&zn(i,c,c),this.generateBVH){if(this.bvh instanceof Promise)throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");if(o.changeType===Or){const n={strategy:Be.SAH,maxLeafTris:1,indirect:!0,onProgress:e,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(i,n):this.bvh=new Be.MeshBVH(i,n)}else o.changeType===Br&&this.bvh.refit()}return{bvhChanged:o.changeType!==es,bvh:this.bvh,lights:u,iesTextures:p,geometry:i,materials:c,textures:h,objects:r}}}class As extends f.ShaderMaterial{set needsUpdate(e){super.needsUpdate=!0,this.dispatchEvent({type:"recompilation"})}constructor(e){super(e);for(const t in this.uniforms)Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(i){this.uniforms[t].value=i}})}setDefine(e,t=void 0){if(t==null){if(e in this.defines)return delete this.defines[e],this.needsUpdate=!0,!0}else if(this.defines[e]!==t)return this.defines[e]=t,this.needsUpdate=!0,!0;return!1}}class Jn extends As{constructor(e){super({blending:f.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
|
|
1
|
+
"use strict";var _n=Object.create;var Di=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var yn=Object.getOwnPropertyNames;var xn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty;var bn=(a,e,t)=>e in a?Di(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var An=(a,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of yn(e))!wn.call(a,s)&&s!==t&&Di(a,s,{get:()=>e[s],enumerable:!(i=vn(e,s))||i.enumerable});return a};var Tn=(a,e,t)=>(t=a!=null?_n(xn(a)):{},An(e||!a||!a.__esModule?Di(t,"default",{value:a,enumerable:!0}):t,a));var E=(a,e,t)=>(bn(a,typeof e!="symbol"?e+"":e,t),t),Es=(a,e,t)=>{if(!e.has(a))throw TypeError("Cannot "+t)};var Q=(a,e,t)=>(Es(a,e,"read from private field"),t?t.call(a):e.get(a)),Le=(a,e,t)=>{if(e.has(a))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(a):e.set(a,t)},ye=(a,e,t,i)=>(Es(a,e,"write to private field"),i?i.call(a,t):e.set(a,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three"),ks=require("three/examples/jsm/loaders/HDRLoader.js"),Sn=require("three/examples/jsm/controls/OrbitControls"),be=require("three/examples/jsm/renderers/CSS2DRenderer"),Mn=require("three/examples/jsm/loaders/FontLoader"),ws=require("three/examples/jsm/loaders/GLTFLoader.js");require("three/examples/jsm/libs/meshopt_decoder.module.js");require("three/examples/jsm/loaders/DRACOLoader.js");const Cn=require("three/examples/jsm/loaders/GLTFLoader"),Dn=require("three/examples/jsm/loaders/DRACOLoader"),Pn=require("three/examples/jsm/exporters/DRACOExporter"),Ln=require("three/examples/jsm/exporters/GLTFExporter"),In=require("three/examples/jsm/utils/SkeletonUtils.js"),Rr=require("three/examples/jsm/lines/Line2.js"),Er=require("three/examples/jsm/lines/LineMaterial.js"),$i=require("three/examples/jsm/lines/LineGeometry.js"),Rn=require("three/examples/jsm/renderers/CSS3DRenderer");require("three/examples/jsm/utils/BufferGeometryUtils");const jt=require("three/examples/jsm/postprocessing/Pass"),Be=require("three-mesh-bvh"),_t=require("three/examples/jsm/postprocessing/Pass.js");var vt=typeof document<"u"?document.currentScript:null;function kr(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const V=kr(f),Pi=kr(In);function Fr(a,e,t=0){if(a.isInterleavedBufferAttribute){const i=a.itemSize;for(let s=0,r=a.count;s<r;s++){const o=s+t;e.setX(o,a.getX(s)),i>=2&&e.setY(o,a.getY(s)),i>=3&&e.setZ(o,a.getZ(s)),i>=4&&e.setW(o,a.getW(s))}}else{const i=e.array,s=i.constructor,r=i.BYTES_PER_ELEMENT*a.itemSize*t;new s(i.buffer,r,a.array.length).set(a.array)}}function Ft(a,e=null){const t=a.array.constructor,i=a.normalized,s=a.itemSize,r=e===null?a.count:e;return new f.BufferAttribute(new t(s*r),s,i)}function ht(a,e){if(!a&&!e)return!0;if(!!a!=!!e)return!1;const t=a.count===e.count,i=a.normalized===e.normalized,s=a.array.constructor===e.array.constructor,r=a.itemSize===e.itemSize;return!(!t||!i||!s||!r)}function En(a){const e=a[0].index!==null,t=new Set(Object.keys(a[0].attributes));if(!a[0].getAttribute("position"))throw new Error("StaticGeometryGenerator: position attribute is required.");for(let i=0;i<a.length;++i){const s=a[i];let r=0;if(e!==(s.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const o in s.attributes){if(!t.has(o))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+o+'" attribute exists among all geometries, or in none of them.');r++}if(r!==t.size)throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.")}}function kn(a){let e=0;for(let t=0,i=a.length;t<i;t++)e+=a[t].getIndex().count;return e}function Fn(a){let e=0;for(let t=0,i=a.length;t<i;t++)e+=a[t].getAttribute("position").count;return e}function Bn(a,e,t){a.index&&a.index.count!==e&&a.setIndex(null);const i=a.attributes;for(const s in i)i[s].count!==t&&a.deleteAttribute(s)}function On(a,e={},t=new f.BufferGeometry){const{useGroups:i=!1,forceUpdate:s=!1,skipAssigningAttributes:r=[],overwriteIndex:o=!0}=e;En(a);const c=a[0].index!==null,h=c?kn(a):-1,u=Fn(a);if(Bn(t,h,u),i){let n=0;for(let l=0,d=a.length;l<d;l++){const g=a[l];let v;c?v=g.getIndex().count:v=g.getAttribute("position").count,t.addGroup(n,v,l),n+=v}}if(c){let n=!1;if(t.index||(t.setIndex(new f.BufferAttribute(new Uint32Array(h),1,!1)),n=!0),n||o){let l=0,d=0;const g=t.getIndex();for(let v=0,m=a.length;v<m;v++){const _=a[v],y=_.getIndex();if(!(!s&&!n&&r[v]))for(let x=0;x<y.count;++x)g.setX(l+x,y.getX(x)+d);l+=y.count,d+=_.getAttribute("position").count}}}const p=Object.keys(a[0].attributes);for(let n=0,l=p.length;n<l;n++){let d=!1;const g=p[n];if(!t.getAttribute(g)){const _=a[0].getAttribute(g);t.setAttribute(g,Ft(_,u)),d=!0}let v=0;const m=t.getAttribute(g);for(let _=0,y=a.length;_<y;_++){const w=a[_],x=!s&&!d&&r[_],b=w.getAttribute(g);x||Fr(b,m,v),v+=b.count}}}function zn(a,e,t){const i=a.index,r=a.attributes.position.count,o=i?i.count:r;let c=a.groups;c.length===0&&(c=[{count:o,start:0,materialIndex:0}]);let h=a.getAttribute("materialIndex");if(!h||h.count!==r){let p;t.length<=255?p=new Uint8Array(r):p=new Uint16Array(r),h=new f.BufferAttribute(p,1,!1),a.deleteAttribute("materialIndex"),a.setAttribute("materialIndex",h)}const u=h.array;for(let p=0;p<c.length;p++){const n=c[p],l=n.start,d=n.count,g=Math.min(d,o-l),v=Array.isArray(e)?e[n.materialIndex]:e,m=t.indexOf(v);for(let _=0;_<g;_++){let y=l+_;i&&(y=i.getX(y)),u[y]=m}}}function Vn(a,e){if(!a.index){const t=a.attributes.position.count,i=new Array(t);for(let s=0;s<t;s++)i[s]=s;a.setIndex(i)}if(!a.attributes.normal&&e&&e.includes("normal")&&a.computeVertexNormals(),!a.attributes.uv&&e&&e.includes("uv")){const t=a.attributes.position.count;a.setAttribute("uv",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!a.attributes.uv2&&e&&e.includes("uv2")){const t=a.attributes.position.count;a.setAttribute("uv2",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!a.attributes.tangent&&e&&e.includes("tangent"))if(a.attributes.uv&&a.attributes.normal)a.computeTangents();else{const t=a.attributes.position.count;a.setAttribute("tangent",new f.BufferAttribute(new Float32Array(t*4),4,!1))}if(!a.attributes.color&&e&&e.includes("color")){const t=a.attributes.position.count,i=new Float32Array(t*4);i.fill(1),a.setAttribute("color",new f.BufferAttribute(i,4))}}function bs(a){let e=0;if(a.byteLength!==0){const t=new Uint8Array(a);for(let i=0;i<a.byteLength;i++){const s=t[i];e=(e<<5)-e+s,e|=0}}return e}function Fs(a){let e=a.uuid;const t=Object.values(a.attributes);a.index&&(t.push(a.index),e+=`index|${a.index.version}`);const i=Object.keys(t).sort();for(const s of i){const r=t[s];e+=`${s}_${r.version}|`}return e}function Bs(a){const e=a.skeleton;return e?(e.boneTexture||e.computeBoneTexture(),`${bs(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`):null}class Wn{constructor(e=null){this.matrixWorld=new f.Matrix4,this.geometryHash=null,this.skeletonHash=null,this.primitiveCount=-1,e!==null&&this.updateFrom(e)}updateFrom(e){const t=e.geometry,i=(t.index?t.index.count:t.attributes.position.count)/3;this.matrixWorld.copy(e.matrixWorld),this.geometryHash=Fs(t),this.primitiveCount=i,this.skeletonHash=Bs(e)}didChange(e){const t=e.geometry,i=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===Fs(t)&&this.skeletonHash===Bs(e)&&this.primitiveCount===i)}}const We=new f.Vector3,Ue=new f.Vector3,He=new f.Vector3,Os=new f.Vector4,qt=new f.Vector3,Li=new f.Vector3,zs=new f.Vector4,Vs=new f.Vector4,Yt=new f.Matrix4,Ws=new f.Matrix4;function Us(a,e,t){const i=a.skeleton,s=a.geometry,r=i.bones,o=i.boneInverses;zs.fromBufferAttribute(s.attributes.skinIndex,e),Vs.fromBufferAttribute(s.attributes.skinWeight,e),Yt.elements.fill(0);for(let c=0;c<4;c++){const h=Vs.getComponent(c);if(h!==0){const u=zs.getComponent(c);Ws.multiplyMatrices(r[u].matrixWorld,o[u]),Un(Yt,Ws,h)}}return Yt.multiply(a.bindMatrix).premultiply(a.bindMatrixInverse),t.transformDirection(Yt),t}function Ii(a,e,t,i,s){qt.set(0,0,0);for(let r=0,o=a.length;r<o;r++){const c=e[r],h=a[r];c!==0&&(Li.fromBufferAttribute(h,i),t?qt.addScaledVector(Li,c):qt.addScaledVector(Li.sub(s),c))}s.add(qt)}function Un(a,e,t){const i=a.elements,s=e.elements;for(let r=0,o=s.length;r<o;r++)i[r]+=s[r]*t}function Hn(a){const{index:e,attributes:t}=a;if(e)for(let i=0,s=e.count;i<s;i+=3){const r=e.getX(i),o=e.getX(i+2);e.setX(i,o),e.setX(i+2,r)}else for(const i in t){const s=t[i],r=s.itemSize;for(let o=0,c=s.count;o<c;o+=3)for(let h=0;h<r;h++){const u=s.getComponent(o,h),p=s.getComponent(o+2,h);s.setComponent(o,h,p),s.setComponent(o+2,h,u)}}return a}function Gn(a,e={},t=new f.BufferGeometry){e={applyWorldTransforms:!0,attributes:[],...e};const i=a.geometry,s=e.applyWorldTransforms,r=e.attributes.includes("normal"),o=e.attributes.includes("tangent"),c=i.attributes,h=t.attributes;for(const y in t.attributes)(!e.attributes.includes(y)||!(y in i.attributes))&&t.deleteAttribute(y);!t.index&&i.index&&(t.index=i.index.clone()),h.position||t.setAttribute("position",Ft(c.position)),r&&!h.normal&&c.normal&&t.setAttribute("normal",Ft(c.normal)),o&&!h.tangent&&c.tangent&&t.setAttribute("tangent",Ft(c.tangent)),ht(i.index,t.index),ht(c.position,h.position),r&&ht(c.normal,h.normal),o&&ht(c.tangent,h.tangent);const u=c.position,p=r?c.normal:null,n=o?c.tangent:null,l=i.morphAttributes.position,d=i.morphAttributes.normal,g=i.morphAttributes.tangent,v=i.morphTargetsRelative,m=a.morphTargetInfluences,_=new f.Matrix3;_.getNormalMatrix(a.matrixWorld),i.index&&t.index.array.set(i.index.array);for(let y=0,w=c.position.count;y<w;y++)We.fromBufferAttribute(u,y),p&&Ue.fromBufferAttribute(p,y),n&&(Os.fromBufferAttribute(n,y),He.fromBufferAttribute(n,y)),m&&(l&&Ii(l,m,v,y,We),d&&Ii(d,m,v,y,Ue),g&&Ii(g,m,v,y,He)),a.isSkinnedMesh&&(a.applyBoneTransform(y,We),p&&Us(a,y,Ue),n&&Us(a,y,He)),s&&We.applyMatrix4(a.matrixWorld),h.position.setXYZ(y,We.x,We.y,We.z),p&&(s&&Ue.applyNormalMatrix(_),h.normal.setXYZ(y,Ue.x,Ue.y,Ue.z)),n&&(s&&He.transformDirection(a.matrixWorld),h.tangent.setXYZW(y,He.x,He.y,He.z,Os.w));for(const y in e.attributes){const w=e.attributes[y];w==="position"||w==="tangent"||w==="normal"||!(w in c)||(h[w]||t.setAttribute(w,Ft(c[w])),ht(c[w],h[w]),Fr(c[w],h[w]))}return a.matrixWorld.determinant()<0&&Hn(t),t}class Nn extends f.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new Wn}isCompatible(e,t){const i=e.geometry;for(let s=0;s<t.length;s++){const r=t[s],o=i.attributes[r],c=this.attributes[r];if(o&&!ht(o,c))return!1}return!0}updateFrom(e,t){const i=this._diff;return i.didChange(e)?(Gn(e,t,this),i.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}}const es=0,Br=1,Or=2;function Qn(a,e){for(let t=0,i=a.length;t<i;t++)a[t].traverseVisible(r=>{r.isMesh&&e(r)})}function jn(a){const e=[];for(let t=0,i=a.length;t<i;t++){const s=a[t];Array.isArray(s.material)?e.push(...s.material):e.push(s.material)}return e}function qn(a,e,t){if(a.length===0){e.setIndex(null);const i=e.attributes;for(const s in i)e.deleteAttribute(s);for(const s in t.attributes)e.setAttribute(t.attributes[s],new f.BufferAttribute(new Float32Array(0),4,!1))}else On(a,t,e);for(const i in e.attributes)e.attributes[i].needsUpdate=!0}class Yn{constructor(e){this.objects=null,this.useGroups=!0,this.applyWorldTransforms=!0,this.generateMissingAttributes=!0,this.overwriteIndex=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Map,this._geometryMergeSets=new WeakMap,this._mergeOrder=[],this._dummyMesh=null,this.setObjects(e||[])}_getDummyMesh(){if(!this._dummyMesh){const e=new f.MeshBasicMaterial,t=new f.BufferGeometry;t.setAttribute("position",new f.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new f.Mesh(t,e)}return this._dummyMesh}_getMeshes(){const e=[];return Qn(this.objects,t=>{e.push(t)}),e.sort((t,i)=>t.uuid>i.uuid?1:t.uuid<i.uuid?-1:0),e.length===0&&e.push(this._getDummyMesh()),e}_updateIntermediateGeometries(){const{_intermediateGeometry:e}=this,t=this._getMeshes(),i=new Set(e.keys()),s={attributes:this.attributes,applyWorldTransforms:this.applyWorldTransforms};for(let r=0,o=t.length;r<o;r++){const c=t[r],h=c.uuid;i.delete(h);let u=e.get(h);(!u||!u.isCompatible(c,this.attributes))&&(u&&u.dispose(),u=new Nn,e.set(h,u)),u.updateFrom(c,s)&&this.generateMissingAttributes&&Vn(u,this.attributes)}i.forEach(r=>{e.delete(r)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new f.BufferGeometry){const{useGroups:t,overwriteIndex:i,_intermediateGeometry:s,_geometryMergeSets:r}=this,o=this._getMeshes(),c=[],h=[],u=r.get(e)||[];this._updateIntermediateGeometries();let p=!1;o.length!==u.length&&(p=!0);for(let l=0,d=o.length;l<d;l++){const g=o[l],v=s.get(g.uuid);h.push(v);const m=u[l];!m||m.uuid!==v.uuid?(c.push(!1),p=!0):m.version!==v.version?c.push(!1):c.push(!0)}qn(h,e,{useGroups:t,forceUpdate:p,skipAssigningAttributes:c,overwriteIndex:i}),p&&e.dispose(),r.set(e,h.map(l=>({version:l.version,uuid:l.uuid})));let n=es;return p?n=Or:c.includes(!1)&&(n=Br),{changeType:n,materials:jn(o),geometry:e}}}function Zn(a){const e=new Set;for(let t=0,i=a.length;t<i;t++){const s=a[t];for(const r in s){const o=s[r];o&&o.isTexture&&e.add(o)}}return Array.from(e)}function Kn(a){const e=[],t=new Set;for(let s=0,r=a.length;s<r;s++)a[s].traverse(o=>{o.visible&&(o.isRectAreaLight||o.isSpotLight||o.isPointLight||o.isDirectionalLight)&&(e.push(o),o.iesMap&&t.add(o.iesMap))});const i=Array.from(t).sort((s,r)=>s.uuid<r.uuid?1:s.uuid>r.uuid?-1:0);return{lights:e,iesTextures:i}}class Xn{get initialized(){return!!this.bvh}constructor(e){this.bvhOptions={},this.attributes=["position","normal","tangent","color","uv","uv2"],this.generateBVH=!0,this.bvh=null,this.geometry=new f.BufferGeometry,this.staticGeometryGenerator=new Yn(e),this._bvhWorker=null,this._pendingGenerate=null,this._buildAsync=!1}setObjects(e){this.staticGeometryGenerator.setObjects(e)}setBVHWorker(e){this._bvhWorker=e}async generateAsync(e=null){if(!this._bvhWorker)throw new Error('PathTracingSceneGenerator: "setBVHWorker" must be called before "generateAsync" can be called.');if(this.bvh instanceof Promise)return this._pendingGenerate||(this._pendingGenerate=new Promise(async()=>(await this.bvh,this._pendingGenerate=null,this.generateAsync(e)))),this._pendingGenerate;{this._buildAsync=!0;const t=this.generate(e);return this._buildAsync=!1,t.bvh=this.bvh=await t.bvh,t}}generate(e=null){const{staticGeometryGenerator:t,geometry:i,attributes:s}=this,r=t.objects;t.attributes=s,r.forEach(n=>{n.traverse(l=>{l.isSkinnedMesh&&l.skeleton&&l.skeleton.update()})});const o=t.generate(i),c=o.materials,h=Zn(c),{lights:u,iesTextures:p}=Kn(r);if(o.changeType!==es&&zn(i,c,c),this.generateBVH){if(this.bvh instanceof Promise)throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");if(o.changeType===Or){const n={strategy:Be.SAH,maxLeafTris:1,indirect:!0,onProgress:e,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(i,n):this.bvh=new Be.MeshBVH(i,n)}else o.changeType===Br&&this.bvh.refit()}return{bvhChanged:o.changeType!==es,bvh:this.bvh,lights:u,iesTextures:p,geometry:i,materials:c,textures:h,objects:r}}}class As extends f.ShaderMaterial{set needsUpdate(e){super.needsUpdate=!0,this.dispatchEvent({type:"recompilation"})}constructor(e){super(e);for(const t in this.uniforms)Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(i){this.uniforms[t].value=i}})}setDefine(e,t=void 0){if(t==null){if(e in this.defines)return delete this.defines[e],this.needsUpdate=!0,!0}else if(this.defines[e]!==t)return this.defines[e]=t,this.needsUpdate=!0,!0;return!1}}class Jn extends As{constructor(e){super({blending:f.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
|
|
2
2
|
|
|
3
3
|
varying vec2 vUv;
|
|
4
4
|
|
|
@@ -270,7 +270,7 @@
|
|
|
270
270
|
gl_FragColor = texture2D( map, vUv );
|
|
271
271
|
|
|
272
272
|
}
|
|
273
|
-
`})}}function Co(a,e=Math.random()){for(let t=a.length-1;t>0;t--){const i=Math.floor(e()*(t+1)),s=a[t];a[t]=a[i],a[i]=s}return a}class Do{constructor(e,t,i=Math.random){const s=e**t,r=new Uint16Array(s);let o=s;for(let c=0;c<s;c++)r[c]=c;this.samples=new Float32Array(t),this.strataCount=e,this.reset=function(){for(let c=0;c<s;c++)r[c]=c;o=0},this.reshuffle=function(){o=0},this.next=function(){const{samples:c}=this;o>=r.length&&(Co(r,i),this.reshuffle());let h=r[o++];for(let u=0;u<t;u++)c[u]=(h%e+i())/e,h=Math.floor(h/e);return c}}}class
|
|
273
|
+
`})}}function Co(a,e=Math.random()){for(let t=a.length-1;t>0;t--){const i=Math.floor(e()*(t+1)),s=a[t];a[t]=a[i],a[i]=s}return a}class Do{constructor(e,t,i=Math.random){const s=e**t,r=new Uint16Array(s);let o=s;for(let c=0;c<s;c++)r[c]=c;this.samples=new Float32Array(t),this.strataCount=e,this.reset=function(){for(let c=0;c<s;c++)r[c]=c;o=0},this.reshuffle=function(){o=0},this.next=function(){const{samples:c}=this;o>=r.length&&(Co(r,i),this.reshuffle());let h=r[o++];for(let u=0;u<t;u++)c[u]=(h%e+i())/e,h=Math.floor(h/e);return c}}}class Po{constructor(e,t,i=Math.random){let s=0;for(const h of t)s+=h;const r=new Float32Array(s),o=[];let c=0;for(const h of t){const u=new Do(e,h,i);u.samples=new Float32Array(r.buffer,c,u.samples.length),c+=u.samples.length*4,o.push(u)}this.samples=r,this.strataCount=e,this.next=function(){for(const h of o)h.next();return r},this.reshuffle=function(){for(const h of o)h.reshuffle()},this.reset=function(){for(const h of o)h.reset()}}}class Lo{constructor(e=0){this.m=2147483648,this.a=1103515245,this.c=12345,this.seed=e}nextInt(){return this.seed=(this.a*this.seed+this.c)%this.m,this.seed}nextFloat(){return this.nextInt()/(this.m-1)}}class Io extends f.DataTexture{constructor(e=1,t=1,i=8){super(new Float32Array(1),1,1,f.RGBAFormat,f.FloatType),this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.strata=i,this.sampler=null,this.generator=new Lo,this.stableNoise=!1,this.random=()=>this.stableNoise?this.generator.nextFloat():Math.random(),this.init(e,t,i)}init(e=this.image.height,t=this.image.width,i=this.strata){const{image:s}=this;if(s.width===t&&s.height===e&&this.sampler!==null)return;const r=new Array(e*t).fill(4),o=new Po(i,r,this.random);s.width=t,s.height=e,s.data=o.samples,this.sampler=o,this.dispose(),this.next()}next(){this.sampler.next(),this.needsUpdate=!0}reset(){this.sampler.reset(),this.generator.seed=0}}function Ro(a,e=Math.random){for(let t=a.length-1;t>0;t--){const i=~~((e()-1e-6)*t),s=a[t];a[t]=a[i],a[i]=s}}function Eo(a,e){a.fill(0);for(let t=0;t<e;t++)a[t]=1}class Zs{constructor(e){this.count=0,this.size=-1,this.sigma=-1,this.radius=-1,this.lookupTable=null,this.score=null,this.binaryPattern=null,this.resize(e),this.setSigma(1.5)}findVoid(){const{score:e,binaryPattern:t}=this;let i=1/0,s=-1;for(let r=0,o=t.length;r<o;r++){if(t[r]!==0)continue;const c=e[r];c<i&&(i=c,s=r)}return s}findCluster(){const{score:e,binaryPattern:t}=this;let i=-1/0,s=-1;for(let r=0,o=t.length;r<o;r++){if(t[r]!==1)continue;const c=e[r];c>i&&(i=c,s=r)}return s}setSigma(e){if(e===this.sigma)return;const t=~~(Math.sqrt(10*2*e**2)+1),i=2*t+1,s=new Float32Array(i*i),r=e*e;for(let o=-t;o<=t;o++)for(let c=-t;c<=t;c++){const h=(t+c)*i+o+t,u=o*o+c*c;s[h]=Math.E**(-u/(2*r))}this.lookupTable=s,this.sigma=e,this.radius=t}resize(e){this.size!==e&&(this.size=e,this.score=new Float32Array(e*e),this.binaryPattern=new Uint8Array(e*e))}invert(){const{binaryPattern:e,score:t,size:i}=this;t.fill(0);for(let s=0,r=e.length;s<r;s++)if(e[s]===0){const o=~~(s/i),c=s-o*i;this.updateScore(c,o,1),e[s]=1}else e[s]=0}updateScore(e,t,i){const{size:s,score:r,lookupTable:o}=this,c=this.radius,h=2*c+1;for(let u=-c;u<=c;u++)for(let p=-c;p<=c;p++){const n=(c+p)*h+u+c,l=o[n];let d=e+u;d=d<0?s+d:d%s;let g=t+p;g=g<0?s+g:g%s;const v=g*s+d;r[v]+=i*l}}addPointIndex(e){this.binaryPattern[e]=1;const t=this.size,i=~~(e/t),s=e-i*t;this.updateScore(s,i,1),this.count++}removePointIndex(e){this.binaryPattern[e]=0;const t=this.size,i=~~(e/t),s=e-i*t;this.updateScore(s,i,-1),this.count--}copy(e){this.resize(e.size),this.score.set(e.score),this.binaryPattern.set(e.binaryPattern),this.setSigma(e.sigma),this.count=e.count}}class ko{constructor(){this.random=Math.random,this.sigma=1.5,this.size=64,this.majorityPointsRatio=.1,this.samples=new Zs(1),this.savedSamples=new Zs(1)}generate(){const{samples:e,savedSamples:t,sigma:i,majorityPointsRatio:s,size:r}=this;e.resize(r),e.setSigma(i);const o=Math.floor(r*r*s),c=e.binaryPattern;Eo(c,o),Ro(c,this.random);for(let n=0,l=c.length;n<l;n++)c[n]===1&&e.addPointIndex(n);for(;;){const n=e.findCluster();e.removePointIndex(n);const l=e.findVoid();if(n===l){e.addPointIndex(n);break}e.addPointIndex(l)}const h=new Uint32Array(r*r);t.copy(e);let u;for(u=e.count-1;u>=0;){const n=e.findCluster();e.removePointIndex(n),h[n]=u,u--}const p=r*r;for(u=t.count;u<p/2;){const n=t.findVoid();t.addPointIndex(n),h[n]=u,u++}for(t.invert();u<p;){const n=t.findCluster();t.removePointIndex(n),h[n]=u,u++}return{data:h,maxValue:p}}}function Fo(a){return a>=3?4:a}function Bo(a){switch(a){case 1:return f.RedFormat;case 2:return f.RGFormat;default:return f.RGBAFormat}}class Oo extends f.DataTexture{constructor(e=64,t=1){super(new Float32Array(4),1,1,f.RGBAFormat,f.FloatType),this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.size=e,this.channels=t,this.update()}update(){const e=this.channels,t=this.size,i=new ko;i.channels=e,i.size=t;const s=Fo(e),r=Bo(s);(this.image.width!==t||r!==this.format)&&(this.image.width=t,this.image.height=t,this.image.data=new Float32Array(t**2*s),this.format=r,this.dispose());const o=this.image.data;for(let c=0,h=e;c<h;c++){const u=i.generate(),p=u.data,n=u.maxValue;for(let l=0,d=p.length;l<d;l++){const g=p[l]/n;o[l*s+c]=g}}this.needsUpdate=!0}}const zo=`
|
|
274
274
|
|
|
275
275
|
struct PhysicalCamera {
|
|
276
276
|
|
|
@@ -3596,7 +3596,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3596
3596
|
|
|
3597
3597
|
}
|
|
3598
3598
|
|
|
3599
|
-
`}),this.setValues(e)}}function*ha(){const{_renderer:a,_fsQuad:e,_blendQuad:t,_primaryTarget:i,_blendTargets:s,_sobolTarget:r,_subframe:o,alpha:c,material:h}=this,u=new f.Vector4,p=new f.Vector4,n=t.material;let[l,d]=s;for(;;){c?(n.opacity=this._opacityFactor/(this.samples+1),h.blending=f.NoBlending,h.opacity=1):(h.opacity=this._opacityFactor/(this.samples+1),h.blending=f.NormalBlending);const[g,v,m,_]=o,y=i.width,w=i.height;h.resolution.set(y*m,w*_),h.sobolTexture=r.texture,h.stratifiedTexture.init(20,h.bounces+h.transmissiveBounces+5),h.stratifiedTexture.next(),h.seed++;const x=this.tiles.x||1,b=this.tiles.y||1,T=x*b,M=Math.ceil(y*m),
|
|
3599
|
+
`}),this.setValues(e)}}function*ha(){const{_renderer:a,_fsQuad:e,_blendQuad:t,_primaryTarget:i,_blendTargets:s,_sobolTarget:r,_subframe:o,alpha:c,material:h}=this,u=new f.Vector4,p=new f.Vector4,n=t.material;let[l,d]=s;for(;;){c?(n.opacity=this._opacityFactor/(this.samples+1),h.blending=f.NoBlending,h.opacity=1):(h.opacity=this._opacityFactor/(this.samples+1),h.blending=f.NormalBlending);const[g,v,m,_]=o,y=i.width,w=i.height;h.resolution.set(y*m,w*_),h.sobolTexture=r.texture,h.stratifiedTexture.init(20,h.bounces+h.transmissiveBounces+5),h.stratifiedTexture.next(),h.seed++;const x=this.tiles.x||1,b=this.tiles.y||1,T=x*b,M=Math.ceil(y*m),P=Math.ceil(w*_),C=Math.floor(g*y),I=Math.floor(v*w),D=Math.ceil(M/x),A=Math.ceil(P/b);for(let S=0;S<b;S++)for(let L=0;L<x;L++){const R=a.getRenderTarget(),k=a.autoClear,F=a.getScissorTest();a.getScissor(u),a.getViewport(p);let z=L,B=S;if(!this.stableTiles){const W=this._currentTile%(x*b);z=W%x,B=~~(W/x),this._currentTile=W+1}const N=b-B-1;i.scissor.set(C+z*D,I+N*A,Math.min(D,M-z*D),Math.min(A,P-N*A)),i.viewport.set(C,I,M,P),a.setRenderTarget(i),a.setScissorTest(!0),a.autoClear=!1,e.render(a),a.setViewport(p),a.setScissor(u),a.setScissorTest(F),a.setRenderTarget(R),a.autoClear=k,c&&(n.target1=l.texture,n.target2=i.texture,a.setRenderTarget(d),t.render(a),a.setRenderTarget(R)),this.samples+=1/T,L===x-1&&S===b-1&&(this.samples=Math.round(this.samples)),yield}[l,d]=[d,l]}}const Xs=new f.Color;class Js{get material(){return this._fsQuad.material}set material(e){this._fsQuad.material.removeEventListener("recompilation",this._compileFunction),e.addEventListener("recompilation",this._compileFunction),this._fsQuad.material=e}get target(){return this._alpha?this._blendTargets[1]:this._primaryTarget}set alpha(e){this._alpha!==e&&(e||(this._blendTargets[0].dispose(),this._blendTargets[1].dispose()),this._alpha=e,this.reset())}get alpha(){return this._alpha}get isCompiling(){return!!this._compilePromise}constructor(e){this.camera=null,this.tiles=new f.Vector2(3,3),this.stableNoise=!1,this.stableTiles=!0,this.samples=0,this._subframe=new f.Vector4(0,0,1,1),this._opacityFactor=1,this._renderer=e,this._alpha=!1,this._fsQuad=new _t.FullScreenQuad(new ca),this._blendQuad=new _t.FullScreenQuad(new Jn),this._task=null,this._currentTile=0,this._compilePromise=null,this._sobolTarget=new io().generate(e),this._primaryTarget=new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter}),this._blendTargets=[new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter}),new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter})],this._compileFunction=()=>{const t=this.compileMaterial(this._fsQuad._mesh);t.then(()=>{this._compilePromise===t&&(this._compilePromise=null)}),this._compilePromise=t},this.material.addEventListener("recompilation",this._compileFunction)}compileMaterial(){return this._renderer.compileAsync(this._fsQuad._mesh)}setCamera(e){const{material:t}=this;t.cameraWorldMatrix.copy(e.matrixWorld),t.invProjectionMatrix.copy(e.projectionMatrixInverse),t.physicalCamera.updateFrom(e);let i=0;e.projectionMatrix.elements[15]>0&&(i=1),e.isEquirectCamera&&(i=2),t.setDefine("CAMERA_TYPE",i),this.camera=e}setSize(e,t){e=Math.ceil(e),t=Math.ceil(t),!(this._primaryTarget.width===e&&this._primaryTarget.height===t)&&(this._primaryTarget.setSize(e,t),this._blendTargets[0].setSize(e,t),this._blendTargets[1].setSize(e,t),this.reset())}getSize(e){e.x=this._primaryTarget.width,e.y=this._primaryTarget.height}dispose(){this._primaryTarget.dispose(),this._blendTargets[0].dispose(),this._blendTargets[1].dispose(),this._sobolTarget.dispose(),this._fsQuad.dispose(),this._blendQuad.dispose(),this._task=null}reset(){const{_renderer:e,_primaryTarget:t,_blendTargets:i}=this,s=e.getRenderTarget(),r=e.getClearAlpha();e.getClearColor(Xs),e.setRenderTarget(t),e.setClearColor(0,0),e.clearColor(),e.setRenderTarget(i[0]),e.setClearColor(0,0),e.clearColor(),e.setRenderTarget(i[1]),e.setClearColor(0,0),e.clearColor(),e.setClearColor(Xs,r),e.setRenderTarget(s),this.samples=0,this._task=null,this.material.stratifiedTexture.stableNoise=this.stableNoise,this.stableNoise&&(this.material.seed=0,this.material.stratifiedTexture.reset())}update(){this.material.onBeforeRender(),!this.isCompiling&&(this._task||(this._task=ha.call(this)),this._task.next())}}const Ge=new f.Vector2,$s=new f.Vector2,Xt=new f.Spherical,Jt=new f.Color;class ua extends f.DataTexture{constructor(e=512,t=512){super(new Float32Array(e*t*4),e,t,f.RGBAFormat,f.FloatType,f.EquirectangularReflectionMapping,f.RepeatWrapping,f.ClampToEdgeWrapping,f.LinearFilter,f.LinearFilter),this.generationCallback=null}update(){this.dispose(),this.needsUpdate=!0;const{data:e,width:t,height:i}=this.image;for(let s=0;s<t;s++)for(let r=0;r<i;r++){$s.set(t,i),Ge.set(s/t,r/i),Ge.x-=.5,Ge.y=1-Ge.y,Xt.theta=Ge.x*2*Math.PI,Xt.phi=Ge.y*Math.PI,Xt.radius=1,this.generationCallback(Xt,Ge,$s,Jt);const c=4*(r*t+s);e[c+0]=Jt.r,e[c+1]=Jt.g,e[c+2]=Jt.b,e[c+3]=1}}copy(e){return super.copy(e),this.generationCallback=e.generationCallback,this}}const er=new f.Vector3;class fa extends ua{constructor(e=512){super(e,e),this.topColor=new f.Color().set(16777215),this.bottomColor=new f.Color().set(0),this.exponent=2,this.generationCallback=(t,i,s,r)=>{er.setFromSpherical(t);const o=er.y*.5+.5;r.lerpColors(this.bottomColor,this.topColor,o**this.exponent)}}copy(e){return super.copy(e),this.topColor.copy(e.topColor),this.bottomColor.copy(e.bottomColor),this}}class da extends f.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}constructor(e){super({uniforms:{map:{value:null},opacity:{value:1}},vertexShader:`
|
|
3600
3600
|
varying vec2 vUv;
|
|
3601
3601
|
void main() {
|
|
3602
3602
|
|
|
@@ -3678,12 +3678,12 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3678
3678
|
rayDirection.x *= flipEnvMap;
|
|
3679
3679
|
gl_FragColor = textureCube( envMap, rayDirection );
|
|
3680
3680
|
|
|
3681
|
-
}`}),this.depthWrite=!1,this.depthTest=!1}}class tr{constructor(e){this._renderer=e,this._quad=new _t.FullScreenQuad(new pa)}generate(e,t=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],r=this._renderer,o=this._quad;t===null&&(t=4*s.height),i===null&&(i=2*s.height);const c=new f.WebGLRenderTarget(t,i,{type:f.FloatType,colorSpace:s.colorSpace}),h=s.height,u=Math.log2(h)-2,p=1/h,n=1/(3*Math.max(Math.pow(2,u),7*16));o.material.defines.CUBEUV_MAX_MIP=`${u}.0`,o.material.defines.CUBEUV_TEXEL_WIDTH=n,o.material.defines.CUBEUV_TEXEL_HEIGHT=p,o.material.uniforms.envMap.value=e,o.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,o.material.needsUpdate=!0;const l=r.getRenderTarget(),d=r.autoClear;r.autoClear=!0,r.setRenderTarget(c),o.render(r),r.setRenderTarget(l),r.autoClear=d;const g=new Uint16Array(t*i*4),v=new Float32Array(t*i*4);r.readRenderTargetPixels(c,0,0,t,i,v),c.dispose();for(let _=0,y=v.length;_<y;_++)g[_]=f.DataUtils.toHalfFloat(v[_]);const m=new f.DataTexture(g,t,i,f.RGBAFormat,f.HalfFloatType);return m.minFilter=f.LinearMipMapLinearFilter,m.magFilter=f.LinearFilter,m.wrapS=f.RepeatWrapping,m.wrapT=f.RepeatWrapping,m.mapping=f.EquirectangularReflectionMapping,m.needsUpdate=!0,m}dispose(){this._quad.dispose()}}function ma(a){return a.extensions.get("EXT_float_blend")}const Je=new f.Vector2;class ga{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine("FEATURE_MIS",e?1:0)}get transmissiveBounces(){return this._pathTracer.material.transmissiveBounces}set transmissiveBounces(e){this._pathTracer.material.transmissiveBounces=e}get bounces(){return this._pathTracer.material.bounces}set bounces(e){this._pathTracer.material.bounces=e}get filterGlossyFactor(){return this._pathTracer.material.filterGlossyFactor}set filterGlossyFactor(e){this._pathTracer.material.filterGlossyFactor=e}get samples(){return this._pathTracer.samples}get target(){return this._pathTracer.target}get tiles(){return this._pathTracer.tiles}get stableNoise(){return this._pathTracer.stableNoise}set stableNoise(e){this._pathTracer.stableNoise=e}get isCompiling(){return!!this._pathTracer.isCompiling}constructor(e){this._renderer=e,this._generator=new Xn,this._pathTracer=new Js(e),this._queueReset=!1,this._clock=new f.Clock,this._compilePromise=null,this._lowResPathTracer=new Js(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new _t.FullScreenQuad(new da({map:null,transparent:!0,blending:f.NoBlending,premultipliedAlpha:e.getContextAttributes().premultipliedAlpha})),this._materials=null,this._previousEnvironment=null,this._previousBackground=null,this._internalBackground=null,this.renderDelay=100,this.minSamples=5,this.fadeDuration=500,this.enablePathTracing=!0,this.pausePathTracing=!1,this.dynamicLowRes=!1,this.lowResScale=.25,this.renderScale=1,this.synchronizeRenderSize=!0,this.rasterizeScene=!0,this.renderToCanvas=!0,this.textureSize=new f.Vector2(1024,1024),this.rasterizeSceneCallback=(t,i)=>{this._renderer.render(t,i)},this.renderToCanvasCallback=(t,i,s)=>{const r=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=r},this.setScene(new f.Scene,new f.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,i={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();const s=this._generator;if(s.setObjects(e),this._buildAsync)return s.generateAsync(i.onProgress).then(r=>this._updateFromResults(e,t,r));{const r=s.generate();return this._updateFromResults(e,t,r)}}setSceneAsync(...e){this._buildAsync=!0;const t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){const e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){const e=this._pathTracer.material,t=this._renderer,i=this._materials,s=this.textureSize,r=xo(i);e.textures.setTextures(t,r,s.x,s.y),e.materials.updateFrom(i,r),this.reset()}updateLights(){const e=this.scene,t=this._renderer,i=this._pathTracer.material,s=wo(e),r=yo(s);i.lights.updateFrom(s,r),i.iesProfiles.setTextures(t,r),this.reset()}updateEnvironment(){const e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&(this._internalBackground.dispose(),this._internalBackground=null),t.backgroundBlur=e.backgroundBlurriness,t.backgroundIntensity=e.backgroundIntensity??1,t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(),e.background===null)t.backgroundMap=null,t.backgroundAlpha=0;else if(e.background.isColor){this._colorBackground=this._colorBackground||new fa(16);const i=this._colorBackground;i.topColor.equals(e.background)||(i.topColor.set(e.background),i.bottomColor.set(e.background),i.update()),t.backgroundMap=i,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){const i=new tr(this._renderer).generate(e.background);this._internalBackground=i,t.backgroundMap=i,t.backgroundAlpha=1}}else t.backgroundMap=e.background,t.backgroundAlpha=1;if(t.environmentIntensity=e.environmentIntensity??1,t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(),this._previousEnvironment!==e.environment)if(e.environment!==null)if(e.environment.isCubeTexture){const i=new tr(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(i)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,i){const{materials:s,geometry:r,bvh:o,bvhChanged:c}=i;this._materials=s;const u=this._pathTracer.material;return c&&(u.bvh.updateFrom(o),u.attributesArray.updateFrom(r.attributes.normal,r.attributes.tangent,r.attributes.uv,r.attributes.color),u.materialIndexAttribute.updateFrom(r.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),i}renderSample(){const e=this._lowResPathTracer,t=this._pathTracer,i=this._renderer,s=this._clock,r=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,r.material.opacity=0,s.start());const o=s.getDelta()*1e3,c=s.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=c&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!ma(i),e.alpha=t.alpha,this.renderToCanvas){const h=this._renderer,u=this.minSamples;if(c>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?r.material.opacity=Math.min(r.material.opacity+o/this.fadeDuration,1):r.material.opacity=1),!this.enablePathTracing||this.samples<u||r.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const p=r.material.opacity;r.material.opacity=1-r.material.opacity,r.material.map=e.target.texture,r.render(h),r.material.opacity=p}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&r.material.opacity>0&&(r.material.opacity<1&&(r.material.blending=this.dynamicLowRes?f.AdditiveBlending:f.NormalBlending),r.material.map=t.target.texture,this.renderToCanvasCallback(t.target,h,r),r.material.blending=f.NoBlending)}}reset(){this._queueReset=!0,this._pathTracer.samples=0}dispose(){this._renderQuad.dispose(),this._renderQuad.material.dispose(),this._pathTracer.dispose()}_updateScale(){if(this.synchronizeRenderSize){this._renderer.getDrawingBufferSize(Je);const e=Math.floor(this.renderScale*Je.x),t=Math.floor(this.renderScale*Je.y);if(this._pathTracer.getSize(Je),Je.x!==e||Je.y!==t){const i=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(t*i))}}}}const _a="";globalThis.GLTF_PROGRESSIVE_VERSION=_a;console.debug("[gltf-progressive] version -");let Ur="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",va="https://cdn.needle.tools/static/three/0.179.1/basis2/";const ya=new URL(Ur+"draco_decoder.js");ya.searchParams.append("range","true");const xa=()=>({dracoDecoderPath:Ur,ktx2TranscoderPath:va});function Hr(a){return{dracoLoader:Nr,meshoptDecoder:Qr}}function Gr(a){a.dracoLoader||a.setDRACOLoader(Nr),a.meshoptDecoder||a.setMeshoptDecoder(Qr)}let Nr,Qr;const is=new WeakMap;function jr(a,e){let t=is.get(a);t?t=Object.assign(t,e):t=e,is.set(a,t)}const ki=ws.GLTFLoader.prototype.load;function wa(...a){const e=is.get(this);let t=a[0];const i=new URL(t,window.location.href);if(i.hostname.endsWith("needle.tools")){const r=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,o=e!=null&&e.usecase?e.usecase:"default";r?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${o}`:this.requestHeader.Accept=`*/*;usecase=${o}`,t=i.toString()}return a[0]=t,ki==null?void 0:ki.call(this,...a)}ws.GLTFLoader.prototype.load=wa;qe("debugprogressive");function qe(a){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(a);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function ba(a,e){if(e===void 0||a===void 0||e.startsWith("./")||e.startsWith("http")||e.startsWith("data:")||e.startsWith("blob:"))return e;const t=a.lastIndexOf("/");if(t>=0){const i=a.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}function qr(){return wt!==void 0||(wt=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),qe("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",wt)),wt}let wt;function ir(){if(typeof window>"u")return!1;const a=new URL(window.location.href),e=a.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(a.hostname);return a.hostname==="127.0.0.1"||e}class Aa{constructor(e=100,t={}){E(this,"_running",new Map);E(this,"_queue",[]);E(this,"debug",!1);E(this,"tick",()=>{this.internalUpdate(),setTimeout(this.tick,10)});this.maxConcurrent=e,this.debug=t.debug??!1,window.requestAnimationFrame(this.tick)}slot(e){return this.debug&&console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`),new Promise(t=>{this._queue.push({key:e,resolve:t})})}add(e,t){this._running.has(e)||(this._running.set(e,t),t.finally(()=>{this._running.delete(e),this.debug&&console.debug(`[PromiseQueue]: Promise finished now running: ${this._running.size}, waiting: ${this._queue.length}. (finished ${e})`)}),this.debug&&console.debug(`[PromiseQueue]: Added new promise, now running: ${this._running.size}, waiting: ${this._queue.length}. (added ${e})`))}internalUpdate(){const e=this.maxConcurrent-this._running.size;for(let t=0;t<e&&this._queue.length>0;t++){this.debug&&console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);const{key:i,resolve:s}=this._queue.shift();s({use:r=>this.add(i,r)})}}}const Ta=typeof window>"u"&&typeof document>"u",ss=Symbol("needle:raycast-mesh");function Ht(a){return(a==null?void 0:a[ss])instanceof f.BufferGeometry?a[ss]:null}function Sa(a,e){if((a.type==="Mesh"||a.type==="SkinnedMesh")&&!Ht(a)){const i=Ca(e);i.userData={isRaycastMesh:!0},a[ss]=i}}function Ma(a=!0){if(a){if(bt)return;const e=bt=f.Mesh.prototype.raycast;f.Mesh.prototype.raycast=function(t,i){const s=this,r=Ht(s);let o;r&&s.isMesh&&(o=s.geometry,s.geometry=r),e.call(this,t,i),o&&(s.geometry=o)}}else{if(!bt)return;f.Mesh.prototype.raycast=bt,bt=null}}let bt=null;function Ca(a){const e=new f.BufferGeometry;for(const t in a.attributes)e.setAttribute(t,a.getAttribute(t));return e.setIndex(a.getIndex()),e}const ke=new Array,G=qe("debugprogressive");let Ot,Ne=-1;if(G){let a=function(){Ne+=1,Ne>=e&&(Ne=-1),console.log(`Toggle LOD level [${Ne}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&a(),t.key==="w"&&(Ot=!Ot,console.log(`Toggle wireframe [${Ot}]`));const i=parseInt(t.key);!isNaN(i)&&i>=0&&(Ne=i,console.log(`Set LOD level to [${Ne}]`))})}function Yr(a){if(G&&Ot!==void 0)if(Array.isArray(a))for(const e of a)Yr(e);else a&&"wireframe"in a&&(a.wireframe=Ot===!0)}const At=new Array;let Da=0;const La=qr()?2:10;function Pa(a){if(At.length<La){const i=At.length;G&&console.warn(`[Worker] Creating new worker #${i}`);const s=Ss.createWorker(a||{});return At.push(s),s}const e=Da++%At.length;return At[e]}class Ss{constructor(e,t){E(this,"_running",[]);E(this,"_webglRenderer",null);E(this,"_debug",!1);this.worker=e,this._debug=t.debug??!1,e.onmessage=i=>{const s=i.data;switch(this._debug&&console.log("[Worker] EVENT",s),s.type){case"loaded-gltf":for(const r of this._running)if(r.url===s.result.url){Ia(s.result),r.resolve(s.result);const o=r.url;o.startsWith("blob:")&&URL.revokeObjectURL(o)}}},e.onerror=i=>{console.error("[Worker] Error in gltf-progressive worker:",i)},e.postMessage({type:"init"})}static async createWorker(e){const t=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/loader.worker-46d0lFWx.js").href:new URL("assets/loader.worker-46d0lFWx.js",document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:vt&&vt.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});return new Ss(t,e)}async load(e,t){const i=xa();let s=t==null?void 0:t.renderer;s||(this._webglRenderer??(this._webglRenderer=(async()=>{const{WebGLRenderer:u}=await import("three");return new u})()),s=await this._webglRenderer);const c=Hr().ktx2Loader.workerConfig;e instanceof URL?e=e.toString():e.startsWith("file:")?e=URL.createObjectURL(new Blob([e])):!e.startsWith("blob:")&&!e.startsWith("http:")&&!e.startsWith("https:")&&(e=new URL(e,window.location.href).toString());const h={type:"load",url:e,dracoDecoderPath:i.dracoDecoderPath,ktx2TranscoderPath:i.ktx2TranscoderPath,ktx2LoaderConfig:c};return this._debug&&console.debug("[Worker] Sending load request",h),this.worker.postMessage(h),new Promise(u=>{this._running.push({url:e.toString(),resolve:u})})}}function Ia(a){var e,t,i,s,r,o,c,h,u,p,n,l,d,g,v,m;for(const _ of a.geometries){const y=_.geometry,w=new f.BufferGeometry;if(w.name=y.name||"",y.index){const x=y.index;w.setIndex(Fi(x))}for(const x in y.attributes){const b=y.attributes[x],T=Fi(b);w.setAttribute(x,T)}if(y.morphAttributes)for(const x in y.morphAttributes){const T=y.morphAttributes[x].map(M=>Fi(M));w.morphAttributes[x]=T}if(w.morphTargetsRelative=y.morphTargetsRelative??!1,w.boundingBox=new f.Box3,w.boundingBox.min=new f.Vector3((e=y.boundingBox)==null?void 0:e.min.x,(t=y.boundingBox)==null?void 0:t.min.y,(i=y.boundingBox)==null?void 0:i.min.z),w.boundingBox.max=new f.Vector3((s=y.boundingBox)==null?void 0:s.max.x,(r=y.boundingBox)==null?void 0:r.max.y,(o=y.boundingBox)==null?void 0:o.max.z),w.boundingSphere=new f.Sphere(new f.Vector3((c=y.boundingSphere)==null?void 0:c.center.x,(h=y.boundingSphere)==null?void 0:h.center.y,(u=y.boundingSphere)==null?void 0:u.center.z),(p=y.boundingSphere)==null?void 0:p.radius),y.groups)for(const x of y.groups)w.addGroup(x.start,x.count,x.materialIndex);y.userData&&(w.userData=y.userData),_.geometry=w}for(const _ of a.textures){const y=_.texture;let w=null;if(y.isCompressedTexture){const x=y.mipmaps,b=((n=y.image)==null?void 0:n.width)||((d=(l=y.source)==null?void 0:l.data)==null?void 0:d.width)||-1,T=((g=y.image)==null?void 0:g.height)||((m=(v=y.source)==null?void 0:v.data)==null?void 0:m.height)||-1;w=new f.CompressedTexture(x,b,T,y.format,y.type,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.anisotropy,y.colorSpace)}else w=new f.Texture(y.image,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.format,y.type,y.anisotropy,y.colorSpace),w.mipmaps=y.mipmaps,w.channel=y.channel,w.source.data=y.source.data,w.flipY=y.flipY,w.premultiplyAlpha=y.premultiplyAlpha,w.unpackAlignment=y.unpackAlignment,w.matrix=new f.Matrix3(...y.matrix.elements);if(!w){console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");continue}_.texture=w}return a}function Fi(a){let e=a;if("isInterleavedBufferAttribute"in a&&a.isInterleavedBufferAttribute){const t=a.data,i=t.array,s=new f.InterleavedBuffer(i,t.stride);e=new f.InterleavedBufferAttribute(s,a.itemSize,i.byteOffset,a.normalized),e.offset=a.offset}else"isBufferAttribute"in a&&a.isBufferAttribute&&(e=new f.BufferAttribute(a.array,a.itemSize,a.normalized),e.usage=a.usage,e.gpuType=a.gpuType,e.updateRanges=a.updateRanges);return e}const Ra=qe("gltf-progressive-worker"),Ea=qe("gltf-progressive-reduce-mipmaps"),Bi=Symbol("needle-progressive-texture"),Se="NEEDLE_progressive",H=class H{constructor(e){E(this,"parser");E(this,"url");E(this,"_isLoadingMesh");E(this,"loadMesh",e=>{var i,s;if(this._isLoadingMesh)return null;const t=(s=(i=this.parser.json.meshes[e])==null?void 0:i.extensions)==null?void 0:s[Se];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(r=>{var o;return this._isLoadingMesh=!1,r&&H.registerMesh(this.url,t.guid,r,(o=t.lods)==null?void 0:o.length,0,t),r})):null});const t=e.options.path;G&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return Se}static getMeshLODExtension(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getPrimitiveIndex(e){var i;const t=(i=this.getAssignedLODInformation(e))==null?void 0:i.index;return t??-1}static getMaterialMinMaxLODsCount(e,t){const i=this,s="LODS:minmax",r=e[s];if(r!=null)return r;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const c of e)this.getMaterialMinMaxLODsCount(c,t);return e[s]=t,t}if(G==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const c=e;for(const h of Object.keys(c.uniforms)){const u=c.uniforms[h].value;(u==null?void 0:u.isTexture)===!0&&o(u,t)}}else if(e.isMaterial)for(const c of Object.keys(e)){const h=e[c];(h==null?void 0:h.isTexture)===!0&&o(h,t)}else G&&console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);return e[s]=t,t;function o(c,h){const u=i.getAssignedLODInformation(c);if(u){const p=i.lodInfos.get(u.key);if(p&&p.lods){h.min_count=Math.min(h.min_count,p.lods.length),h.max_count=Math.max(h.max_count,p.lods.length);for(let n=0;n<p.lods.length;n++){const l=p.lods[n];l.width&&(h.lods[n]=h.lods[n]||{min_height:1/0,max_height:0},h.lods[n].min_height=Math.min(h.lods[n].min_height,l.height),h.lods[n].max_height=Math.max(h.lods[n].max_height,l.height))}}}}}static hasLODLevelAvailable(e,t){var r;if(Array.isArray(e)){for(const o of e)if(this.hasLODLevelAvailable(o,t))return!0;return!1}if(e.isMaterial===!0){for(const o of Object.keys(e)){const c=e[o];if(c&&c.isTexture&&this.hasLODLevelAvailable(c,t))return!0}return!1}else if(e.isGroup===!0){for(const o of e.children)if(o.isMesh===!0&&this.hasLODLevelAvailable(o,t))return!0}let i,s;if(e.isMesh?i=e.geometry:(e.isBufferGeometry||e.isTexture)&&(i=e),i&&(r=i==null?void 0:i.userData)!=null&&r.LODS){const o=i.userData.LODS;if(s=this.lodInfos.get(o.key),t===void 0)return s!=null;if(s)return Array.isArray(s.lods)?t<s.lods.length:t===0}return!1}static assignMeshLOD(e,t){var i;if(!e)return Promise.resolve(null);if(e instanceof f.Mesh||e.isMesh===!0){const s=e.geometry,r=this.getAssignedLODInformation(s);if(!r)return Promise.resolve(null);for(const o of ke)(i=o.onBeforeGetLODMesh)==null||i.call(o,e,t);return e["LOD:requested level"]=t,H.getOrLoadLOD(s,t).then(o=>{if(Array.isArray(o)){const c=r.index||0;o=o[c]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],o&&s!=o&&((o==null?void 0:o.isBufferGeometry)?e.geometry=o:G&&console.error("Invalid LOD geometry",o))),o}).catch(o=>(console.error("Error loading mesh LOD",e,o),null))}else G&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const i=e;if(Array.isArray(i.material)){const s=new Array;for(const r of i.material){const o=this.assignTextureLOD(r,t);s.push(o)}return Promise.all(s).then(r=>{const o=new Array;for(const c of r)Array.isArray(c)&&o.push(...c);return o})}else return this.assignTextureLOD(i.material,t)}if(e.isMaterial===!0){const i=e,s=[],r=new Array;if(i.uniforms&&(i.isRawShaderMaterial||i.isShaderMaterial===!0)){const o=i;for(const c of Object.keys(o.uniforms)){const h=o.uniforms[c].value;if((h==null?void 0:h.isTexture)===!0){const u=this.assignTextureLODForSlot(h,t,i,c).then(p=>(p&&o.uniforms[c].value!=p&&(o.uniforms[c].value=p,o.uniformsNeedUpdate=!0),p));s.push(u),r.push(c)}}}else for(const o of Object.keys(i)){const c=i[o];if((c==null?void 0:c.isTexture)===!0){const h=this.assignTextureLODForSlot(c,t,i,o);s.push(h),r.push(o)}}return Promise.all(s).then(o=>{const c=new Array;for(let h=0;h<o.length;h++){const u=o[h],p=r[h];u&&u.isTexture===!0?c.push({material:i,slot:p,texture:u,level:t}):c.push({material:i,slot:p,texture:null,level:t})}return c})}if(e instanceof f.Texture||e.isTexture===!0){const i=e;return this.assignTextureLODForSlot(i,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,s){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):s==="glyphMap"?Promise.resolve(e):H.getOrLoadLOD(e,t).then(r=>{var o,c;if(Array.isArray(r))return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."),null;if((r==null?void 0:r.isTexture)===!0){if(r!=e&&i&&s){const h=i[s];if(h&&!G){const u=this.getAssignedLODInformation(h);if(u&&(u==null?void 0:u.level)<t)return G==="verbose"&&console.warn("Assigned texture level is already higher: ",u.level,t,i,h,r),null}if(Ea&&r.mipmaps){const u=r.mipmaps.length;r.mipmaps.length=Math.min(r.mipmaps.length,3),u!==r.mipmaps.length&&G&&console.debug(`Reduced mipmap count from ${u} to ${r.mipmaps.length} for ${r.uuid}: ${(o=r.image)==null?void 0:o.width}x${(c=r.image)==null?void 0:c.height}.`)}i[s]=r}return r}else G=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(r=>(console.error("Error loading LOD",e,r),null))}afterRoot(e){var t,i;return G&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,r)=>{var o;if(s!=null&&s.extensions){const c=s==null?void 0:s.extensions[Se];if(c){if(!c.lods){G&&console.warn("Texture has no LODs",c);return}let h=!1;for(const u of this.parser.associations.keys())if(u.isTexture===!0){const p=this.parser.associations.get(u);(p==null?void 0:p.textures)===r&&(h=!0,H.registerTexture(this.url,u,(o=c.lods)==null?void 0:o.length,r,c))}h||this.parser.getDependency("texture",r).then(u=>{var p;u&&H.registerTexture(this.url,u,(p=c.lods)==null?void 0:p.length,r,c)})}}}),(i=this.parser.json.meshes)==null||i.forEach((s,r)=>{if(s!=null&&s.extensions){const o=s==null?void 0:s.extensions[Se];if(o&&o.lods){for(const c of this.parser.associations.keys())if(c.isMesh){const h=this.parser.associations.get(c);(h==null?void 0:h.meshes)===r&&H.registerMesh(this.url,o.guid,c,o.lods.length,h.primitives,o)}}}}),null}static async getOrLoadLOD(e,t){var h,u,p,n;const i=G=="verbose",s=this.getAssignedLODInformation(e);if(!s)return G&&console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`,e),null;const r=s==null?void 0:s.key;let o;if(e.isTexture===!0){const l=e;l.source&&l.source[Bi]&&(o=l.source[Bi])}if(o||(o=H.lodInfos.get(r)),!o)G&&console.warn(`Can not load LOD ${t}: no LOD info found for "${r}" ${e.name}`,e.type,H.lodInfos);else{if(t>0){let g=!1;const v=Array.isArray(o.lods);if(v&&t>=o.lods.length?g=!0:v||(g=!0),g)return this.lowresCache.get(r)}const l=Array.isArray(o.lods)?(h=o.lods[t])==null?void 0:h.path:o.lods;if(!l)return G&&!o["missing:uri"]&&(o["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,o)),null;const d=ba(s.url,l);if(d.endsWith(".glb")||d.endsWith(".gltf")){if(!o.guid)return console.warn("missing pointer for glb/gltf texture",o),null;const g=d+"_"+o.guid,v=await this.queue.slot(d),m=this.previouslyLoaded.get(g);if(m!==void 0){i&&console.log(`LOD ${t} was already loading/loaded: ${g}`);let x=await m.catch(T=>(console.error(`Error loading LOD ${t} from ${d}
|
|
3682
|
-
`,T),null)),b=!1;if(x==null||(x instanceof f.Texture&&e instanceof f.Texture?(u=x.image)!=null&&u.data||(p=x.source)!=null&&p.data?x=this.copySettings(e,x):(b=!0,this.previouslyLoaded.delete(g)):x instanceof f.BufferGeometry&&e instanceof f.BufferGeometry&&((n=x.attributes.position)!=null&&n.array||(b=!0,this.previouslyLoaded.delete(g)))),!b)return x}if(!v.use)return G&&console.log(`LOD ${t} was aborted: ${d}`),null;const _=o,y=new Promise(async(x,b)=>{if(Ra){const A=await(await
|
|
3683
|
-
`,D),x(null)));if(!
|
|
3681
|
+
}`}),this.depthWrite=!1,this.depthTest=!1}}class tr{constructor(e){this._renderer=e,this._quad=new _t.FullScreenQuad(new pa)}generate(e,t=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],r=this._renderer,o=this._quad;t===null&&(t=4*s.height),i===null&&(i=2*s.height);const c=new f.WebGLRenderTarget(t,i,{type:f.FloatType,colorSpace:s.colorSpace}),h=s.height,u=Math.log2(h)-2,p=1/h,n=1/(3*Math.max(Math.pow(2,u),7*16));o.material.defines.CUBEUV_MAX_MIP=`${u}.0`,o.material.defines.CUBEUV_TEXEL_WIDTH=n,o.material.defines.CUBEUV_TEXEL_HEIGHT=p,o.material.uniforms.envMap.value=e,o.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,o.material.needsUpdate=!0;const l=r.getRenderTarget(),d=r.autoClear;r.autoClear=!0,r.setRenderTarget(c),o.render(r),r.setRenderTarget(l),r.autoClear=d;const g=new Uint16Array(t*i*4),v=new Float32Array(t*i*4);r.readRenderTargetPixels(c,0,0,t,i,v),c.dispose();for(let _=0,y=v.length;_<y;_++)g[_]=f.DataUtils.toHalfFloat(v[_]);const m=new f.DataTexture(g,t,i,f.RGBAFormat,f.HalfFloatType);return m.minFilter=f.LinearMipMapLinearFilter,m.magFilter=f.LinearFilter,m.wrapS=f.RepeatWrapping,m.wrapT=f.RepeatWrapping,m.mapping=f.EquirectangularReflectionMapping,m.needsUpdate=!0,m}dispose(){this._quad.dispose()}}function ma(a){return a.extensions.get("EXT_float_blend")}const Je=new f.Vector2;class ga{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine("FEATURE_MIS",e?1:0)}get transmissiveBounces(){return this._pathTracer.material.transmissiveBounces}set transmissiveBounces(e){this._pathTracer.material.transmissiveBounces=e}get bounces(){return this._pathTracer.material.bounces}set bounces(e){this._pathTracer.material.bounces=e}get filterGlossyFactor(){return this._pathTracer.material.filterGlossyFactor}set filterGlossyFactor(e){this._pathTracer.material.filterGlossyFactor=e}get samples(){return this._pathTracer.samples}get target(){return this._pathTracer.target}get tiles(){return this._pathTracer.tiles}get stableNoise(){return this._pathTracer.stableNoise}set stableNoise(e){this._pathTracer.stableNoise=e}get isCompiling(){return!!this._pathTracer.isCompiling}constructor(e){this._renderer=e,this._generator=new Xn,this._pathTracer=new Js(e),this._queueReset=!1,this._clock=new f.Clock,this._compilePromise=null,this._lowResPathTracer=new Js(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new _t.FullScreenQuad(new da({map:null,transparent:!0,blending:f.NoBlending,premultipliedAlpha:e.getContextAttributes().premultipliedAlpha})),this._materials=null,this._previousEnvironment=null,this._previousBackground=null,this._internalBackground=null,this.renderDelay=100,this.minSamples=5,this.fadeDuration=500,this.enablePathTracing=!0,this.pausePathTracing=!1,this.dynamicLowRes=!1,this.lowResScale=.25,this.renderScale=1,this.synchronizeRenderSize=!0,this.rasterizeScene=!0,this.renderToCanvas=!0,this.textureSize=new f.Vector2(1024,1024),this.rasterizeSceneCallback=(t,i)=>{this._renderer.render(t,i)},this.renderToCanvasCallback=(t,i,s)=>{const r=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=r},this.setScene(new f.Scene,new f.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,i={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();const s=this._generator;if(s.setObjects(e),this._buildAsync)return s.generateAsync(i.onProgress).then(r=>this._updateFromResults(e,t,r));{const r=s.generate();return this._updateFromResults(e,t,r)}}setSceneAsync(...e){this._buildAsync=!0;const t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){const e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){const e=this._pathTracer.material,t=this._renderer,i=this._materials,s=this.textureSize,r=xo(i);e.textures.setTextures(t,r,s.x,s.y),e.materials.updateFrom(i,r),this.reset()}updateLights(){const e=this.scene,t=this._renderer,i=this._pathTracer.material,s=wo(e),r=yo(s);i.lights.updateFrom(s,r),i.iesProfiles.setTextures(t,r),this.reset()}updateEnvironment(){const e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&(this._internalBackground.dispose(),this._internalBackground=null),t.backgroundBlur=e.backgroundBlurriness,t.backgroundIntensity=e.backgroundIntensity??1,t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(),e.background===null)t.backgroundMap=null,t.backgroundAlpha=0;else if(e.background.isColor){this._colorBackground=this._colorBackground||new fa(16);const i=this._colorBackground;i.topColor.equals(e.background)||(i.topColor.set(e.background),i.bottomColor.set(e.background),i.update()),t.backgroundMap=i,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){const i=new tr(this._renderer).generate(e.background);this._internalBackground=i,t.backgroundMap=i,t.backgroundAlpha=1}}else t.backgroundMap=e.background,t.backgroundAlpha=1;if(t.environmentIntensity=e.environmentIntensity??1,t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(),this._previousEnvironment!==e.environment)if(e.environment!==null)if(e.environment.isCubeTexture){const i=new tr(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(i)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,i){const{materials:s,geometry:r,bvh:o,bvhChanged:c}=i;this._materials=s;const u=this._pathTracer.material;return c&&(u.bvh.updateFrom(o),u.attributesArray.updateFrom(r.attributes.normal,r.attributes.tangent,r.attributes.uv,r.attributes.color),u.materialIndexAttribute.updateFrom(r.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),i}renderSample(){const e=this._lowResPathTracer,t=this._pathTracer,i=this._renderer,s=this._clock,r=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,r.material.opacity=0,s.start());const o=s.getDelta()*1e3,c=s.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=c&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!ma(i),e.alpha=t.alpha,this.renderToCanvas){const h=this._renderer,u=this.minSamples;if(c>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?r.material.opacity=Math.min(r.material.opacity+o/this.fadeDuration,1):r.material.opacity=1),!this.enablePathTracing||this.samples<u||r.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const p=r.material.opacity;r.material.opacity=1-r.material.opacity,r.material.map=e.target.texture,r.render(h),r.material.opacity=p}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&r.material.opacity>0&&(r.material.opacity<1&&(r.material.blending=this.dynamicLowRes?f.AdditiveBlending:f.NormalBlending),r.material.map=t.target.texture,this.renderToCanvasCallback(t.target,h,r),r.material.blending=f.NoBlending)}}reset(){this._queueReset=!0,this._pathTracer.samples=0}dispose(){this._renderQuad.dispose(),this._renderQuad.material.dispose(),this._pathTracer.dispose()}_updateScale(){if(this.synchronizeRenderSize){this._renderer.getDrawingBufferSize(Je);const e=Math.floor(this.renderScale*Je.x),t=Math.floor(this.renderScale*Je.y);if(this._pathTracer.getSize(Je),Je.x!==e||Je.y!==t){const i=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(t*i))}}}}const _a="";globalThis.GLTF_PROGRESSIVE_VERSION=_a;console.debug("[gltf-progressive] version -");let Ur="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",va="https://cdn.needle.tools/static/three/0.179.1/basis2/";const ya=new URL(Ur+"draco_decoder.js");ya.searchParams.append("range","true");const xa=()=>({dracoDecoderPath:Ur,ktx2TranscoderPath:va});function Hr(a){return{dracoLoader:Nr,meshoptDecoder:Qr}}function Gr(a){a.dracoLoader||a.setDRACOLoader(Nr),a.meshoptDecoder||a.setMeshoptDecoder(Qr)}let Nr,Qr;const is=new WeakMap;function jr(a,e){let t=is.get(a);t?t=Object.assign(t,e):t=e,is.set(a,t)}const ki=ws.GLTFLoader.prototype.load;function wa(...a){const e=is.get(this);let t=a[0];const i=new URL(t,window.location.href);if(i.hostname.endsWith("needle.tools")){const r=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,o=e!=null&&e.usecase?e.usecase:"default";r?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${o}`:this.requestHeader.Accept=`*/*;usecase=${o}`,t=i.toString()}return a[0]=t,ki==null?void 0:ki.call(this,...a)}ws.GLTFLoader.prototype.load=wa;qe("debugprogressive");function qe(a){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(a);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function ba(a,e){if(e===void 0||a===void 0||e.startsWith("./")||e.startsWith("http")||e.startsWith("data:")||e.startsWith("blob:"))return e;const t=a.lastIndexOf("/");if(t>=0){const i=a.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}function qr(){return wt!==void 0||(wt=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),qe("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",wt)),wt}let wt;function ir(){if(typeof window>"u")return!1;const a=new URL(window.location.href),e=a.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(a.hostname);return a.hostname==="127.0.0.1"||e}class Aa{constructor(e=100,t={}){E(this,"_running",new Map);E(this,"_queue",[]);E(this,"debug",!1);E(this,"tick",()=>{this.internalUpdate(),setTimeout(this.tick,10)});this.maxConcurrent=e,this.debug=t.debug??!1,window.requestAnimationFrame(this.tick)}slot(e){return this.debug&&console.debug(`[PromiseQueue]: Requesting slot for key ${e}, running: ${this._running.size}, waiting: ${this._queue.length}`),new Promise(t=>{this._queue.push({key:e,resolve:t})})}add(e,t){this._running.has(e)||(this._running.set(e,t),t.finally(()=>{this._running.delete(e),this.debug&&console.debug(`[PromiseQueue]: Promise finished now running: ${this._running.size}, waiting: ${this._queue.length}. (finished ${e})`)}),this.debug&&console.debug(`[PromiseQueue]: Added new promise, now running: ${this._running.size}, waiting: ${this._queue.length}. (added ${e})`))}internalUpdate(){const e=this.maxConcurrent-this._running.size;for(let t=0;t<e&&this._queue.length>0;t++){this.debug&&console.debug(`[PromiseQueue]: Running ${this._running.size} promises, waiting for ${this._queue.length} more.`);const{key:i,resolve:s}=this._queue.shift();s({use:r=>this.add(i,r)})}}}const Ta=typeof window>"u"&&typeof document>"u",ss=Symbol("needle:raycast-mesh");function Ht(a){return(a==null?void 0:a[ss])instanceof f.BufferGeometry?a[ss]:null}function Sa(a,e){if((a.type==="Mesh"||a.type==="SkinnedMesh")&&!Ht(a)){const i=Ca(e);i.userData={isRaycastMesh:!0},a[ss]=i}}function Ma(a=!0){if(a){if(bt)return;const e=bt=f.Mesh.prototype.raycast;f.Mesh.prototype.raycast=function(t,i){const s=this,r=Ht(s);let o;r&&s.isMesh&&(o=s.geometry,s.geometry=r),e.call(this,t,i),o&&(s.geometry=o)}}else{if(!bt)return;f.Mesh.prototype.raycast=bt,bt=null}}let bt=null;function Ca(a){const e=new f.BufferGeometry;for(const t in a.attributes)e.setAttribute(t,a.getAttribute(t));return e.setIndex(a.getIndex()),e}const ke=new Array,G=qe("debugprogressive");let Ot,Ne=-1;if(G){let a=function(){Ne+=1,Ne>=e&&(Ne=-1),console.log(`Toggle LOD level [${Ne}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&a(),t.key==="w"&&(Ot=!Ot,console.log(`Toggle wireframe [${Ot}]`));const i=parseInt(t.key);!isNaN(i)&&i>=0&&(Ne=i,console.log(`Set LOD level to [${Ne}]`))})}function Yr(a){if(G&&Ot!==void 0)if(Array.isArray(a))for(const e of a)Yr(e);else a&&"wireframe"in a&&(a.wireframe=Ot===!0)}const At=new Array;let Da=0;const Pa=qr()?2:10;function La(a){if(At.length<Pa){const i=At.length;G&&console.warn(`[Worker] Creating new worker #${i}`);const s=Ss.createWorker(a||{});return At.push(s),s}const e=Da++%At.length;return At[e]}class Ss{constructor(e,t){E(this,"_running",[]);E(this,"_webglRenderer",null);E(this,"_debug",!1);this.worker=e,this._debug=t.debug??!1,e.onmessage=i=>{const s=i.data;switch(this._debug&&console.log("[Worker] EVENT",s),s.type){case"loaded-gltf":for(const r of this._running)if(r.url===s.result.url){Ia(s.result),r.resolve(s.result);const o=r.url;o.startsWith("blob:")&&URL.revokeObjectURL(o)}}},e.onerror=i=>{console.error("[Worker] Error in gltf-progressive worker:",i)},e.postMessage({type:"init"})}static async createWorker(e){const t=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/loader.worker-46d0lFWx.js").href:new URL("assets/loader.worker-46d0lFWx.js",document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:vt&&vt.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});return new Ss(t,e)}async load(e,t){const i=xa();let s=t==null?void 0:t.renderer;s||(this._webglRenderer??(this._webglRenderer=(async()=>{const{WebGLRenderer:u}=await import("three");return new u})()),s=await this._webglRenderer);const c=Hr().ktx2Loader.workerConfig;e instanceof URL?e=e.toString():e.startsWith("file:")?e=URL.createObjectURL(new Blob([e])):!e.startsWith("blob:")&&!e.startsWith("http:")&&!e.startsWith("https:")&&(e=new URL(e,window.location.href).toString());const h={type:"load",url:e,dracoDecoderPath:i.dracoDecoderPath,ktx2TranscoderPath:i.ktx2TranscoderPath,ktx2LoaderConfig:c};return this._debug&&console.debug("[Worker] Sending load request",h),this.worker.postMessage(h),new Promise(u=>{this._running.push({url:e.toString(),resolve:u})})}}function Ia(a){var e,t,i,s,r,o,c,h,u,p,n,l,d,g,v,m;for(const _ of a.geometries){const y=_.geometry,w=new f.BufferGeometry;if(w.name=y.name||"",y.index){const x=y.index;w.setIndex(Fi(x))}for(const x in y.attributes){const b=y.attributes[x],T=Fi(b);w.setAttribute(x,T)}if(y.morphAttributes)for(const x in y.morphAttributes){const T=y.morphAttributes[x].map(M=>Fi(M));w.morphAttributes[x]=T}if(w.morphTargetsRelative=y.morphTargetsRelative??!1,w.boundingBox=new f.Box3,w.boundingBox.min=new f.Vector3((e=y.boundingBox)==null?void 0:e.min.x,(t=y.boundingBox)==null?void 0:t.min.y,(i=y.boundingBox)==null?void 0:i.min.z),w.boundingBox.max=new f.Vector3((s=y.boundingBox)==null?void 0:s.max.x,(r=y.boundingBox)==null?void 0:r.max.y,(o=y.boundingBox)==null?void 0:o.max.z),w.boundingSphere=new f.Sphere(new f.Vector3((c=y.boundingSphere)==null?void 0:c.center.x,(h=y.boundingSphere)==null?void 0:h.center.y,(u=y.boundingSphere)==null?void 0:u.center.z),(p=y.boundingSphere)==null?void 0:p.radius),y.groups)for(const x of y.groups)w.addGroup(x.start,x.count,x.materialIndex);y.userData&&(w.userData=y.userData),_.geometry=w}for(const _ of a.textures){const y=_.texture;let w=null;if(y.isCompressedTexture){const x=y.mipmaps,b=((n=y.image)==null?void 0:n.width)||((d=(l=y.source)==null?void 0:l.data)==null?void 0:d.width)||-1,T=((g=y.image)==null?void 0:g.height)||((m=(v=y.source)==null?void 0:v.data)==null?void 0:m.height)||-1;w=new f.CompressedTexture(x,b,T,y.format,y.type,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.anisotropy,y.colorSpace)}else w=new f.Texture(y.image,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.format,y.type,y.anisotropy,y.colorSpace),w.mipmaps=y.mipmaps,w.channel=y.channel,w.source.data=y.source.data,w.flipY=y.flipY,w.premultiplyAlpha=y.premultiplyAlpha,w.unpackAlignment=y.unpackAlignment,w.matrix=new f.Matrix3(...y.matrix.elements);if(!w){console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");continue}_.texture=w}return a}function Fi(a){let e=a;if("isInterleavedBufferAttribute"in a&&a.isInterleavedBufferAttribute){const t=a.data,i=t.array,s=new f.InterleavedBuffer(i,t.stride);e=new f.InterleavedBufferAttribute(s,a.itemSize,i.byteOffset,a.normalized),e.offset=a.offset}else"isBufferAttribute"in a&&a.isBufferAttribute&&(e=new f.BufferAttribute(a.array,a.itemSize,a.normalized),e.usage=a.usage,e.gpuType=a.gpuType,e.updateRanges=a.updateRanges);return e}const Ra=qe("gltf-progressive-worker"),Ea=qe("gltf-progressive-reduce-mipmaps"),Bi=Symbol("needle-progressive-texture"),Se="NEEDLE_progressive",H=class H{constructor(e){E(this,"parser");E(this,"url");E(this,"_isLoadingMesh");E(this,"loadMesh",e=>{var i,s;if(this._isLoadingMesh)return null;const t=(s=(i=this.parser.json.meshes[e])==null?void 0:i.extensions)==null?void 0:s[Se];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(r=>{var o;return this._isLoadingMesh=!1,r&&H.registerMesh(this.url,t.guid,r,(o=t.lods)==null?void 0:o.length,0,t),r})):null});const t=e.options.path;G&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return Se}static getMeshLODExtension(e){const t=this.getAssignedLODInformation(e);return t!=null&&t.key?this.lodInfos.get(t.key):null}static getPrimitiveIndex(e){var i;const t=(i=this.getAssignedLODInformation(e))==null?void 0:i.index;return t??-1}static getMaterialMinMaxLODsCount(e,t){const i=this,s="LODS:minmax",r=e[s];if(r!=null)return r;if(t||(t={min_count:1/0,max_count:0,lods:[]}),Array.isArray(e)){for(const c of e)this.getMaterialMinMaxLODsCount(c,t);return e[s]=t,t}if(G==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const c=e;for(const h of Object.keys(c.uniforms)){const u=c.uniforms[h].value;(u==null?void 0:u.isTexture)===!0&&o(u,t)}}else if(e.isMaterial)for(const c of Object.keys(e)){const h=e[c];(h==null?void 0:h.isTexture)===!0&&o(h,t)}else G&&console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);return e[s]=t,t;function o(c,h){const u=i.getAssignedLODInformation(c);if(u){const p=i.lodInfos.get(u.key);if(p&&p.lods){h.min_count=Math.min(h.min_count,p.lods.length),h.max_count=Math.max(h.max_count,p.lods.length);for(let n=0;n<p.lods.length;n++){const l=p.lods[n];l.width&&(h.lods[n]=h.lods[n]||{min_height:1/0,max_height:0},h.lods[n].min_height=Math.min(h.lods[n].min_height,l.height),h.lods[n].max_height=Math.max(h.lods[n].max_height,l.height))}}}}}static hasLODLevelAvailable(e,t){var r;if(Array.isArray(e)){for(const o of e)if(this.hasLODLevelAvailable(o,t))return!0;return!1}if(e.isMaterial===!0){for(const o of Object.keys(e)){const c=e[o];if(c&&c.isTexture&&this.hasLODLevelAvailable(c,t))return!0}return!1}else if(e.isGroup===!0){for(const o of e.children)if(o.isMesh===!0&&this.hasLODLevelAvailable(o,t))return!0}let i,s;if(e.isMesh?i=e.geometry:(e.isBufferGeometry||e.isTexture)&&(i=e),i&&(r=i==null?void 0:i.userData)!=null&&r.LODS){const o=i.userData.LODS;if(s=this.lodInfos.get(o.key),t===void 0)return s!=null;if(s)return Array.isArray(s.lods)?t<s.lods.length:t===0}return!1}static assignMeshLOD(e,t){var i;if(!e)return Promise.resolve(null);if(e instanceof f.Mesh||e.isMesh===!0){const s=e.geometry,r=this.getAssignedLODInformation(s);if(!r)return Promise.resolve(null);for(const o of ke)(i=o.onBeforeGetLODMesh)==null||i.call(o,e,t);return e["LOD:requested level"]=t,H.getOrLoadLOD(s,t).then(o=>{if(Array.isArray(o)){const c=r.index||0;o=o[c]}return e["LOD:requested level"]===t&&(delete e["LOD:requested level"],o&&s!=o&&((o==null?void 0:o.isBufferGeometry)?e.geometry=o:G&&console.error("Invalid LOD geometry",o))),o}).catch(o=>(console.error("Error loading mesh LOD",e,o),null))}else G&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(e,t=0){if(!e)return Promise.resolve(null);if(e.isMesh===!0){const i=e;if(Array.isArray(i.material)){const s=new Array;for(const r of i.material){const o=this.assignTextureLOD(r,t);s.push(o)}return Promise.all(s).then(r=>{const o=new Array;for(const c of r)Array.isArray(c)&&o.push(...c);return o})}else return this.assignTextureLOD(i.material,t)}if(e.isMaterial===!0){const i=e,s=[],r=new Array;if(i.uniforms&&(i.isRawShaderMaterial||i.isShaderMaterial===!0)){const o=i;for(const c of Object.keys(o.uniforms)){const h=o.uniforms[c].value;if((h==null?void 0:h.isTexture)===!0){const u=this.assignTextureLODForSlot(h,t,i,c).then(p=>(p&&o.uniforms[c].value!=p&&(o.uniforms[c].value=p,o.uniformsNeedUpdate=!0),p));s.push(u),r.push(c)}}}else for(const o of Object.keys(i)){const c=i[o];if((c==null?void 0:c.isTexture)===!0){const h=this.assignTextureLODForSlot(c,t,i,o);s.push(h),r.push(o)}}return Promise.all(s).then(o=>{const c=new Array;for(let h=0;h<o.length;h++){const u=o[h],p=r[h];u&&u.isTexture===!0?c.push({material:i,slot:p,texture:u,level:t}):c.push({material:i,slot:p,texture:null,level:t})}return c})}if(e instanceof f.Texture||e.isTexture===!0){const i=e;return this.assignTextureLODForSlot(i,t,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(e,t,i,s){return(e==null?void 0:e.isTexture)!==!0?Promise.resolve(null):s==="glyphMap"?Promise.resolve(e):H.getOrLoadLOD(e,t).then(r=>{var o,c;if(Array.isArray(r))return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."),null;if((r==null?void 0:r.isTexture)===!0){if(r!=e&&i&&s){const h=i[s];if(h&&!G){const u=this.getAssignedLODInformation(h);if(u&&(u==null?void 0:u.level)<t)return G==="verbose"&&console.warn("Assigned texture level is already higher: ",u.level,t,i,h,r),null}if(Ea&&r.mipmaps){const u=r.mipmaps.length;r.mipmaps.length=Math.min(r.mipmaps.length,3),u!==r.mipmaps.length&&G&&console.debug(`Reduced mipmap count from ${u} to ${r.mipmaps.length} for ${r.uuid}: ${(o=r.image)==null?void 0:o.width}x${(c=r.image)==null?void 0:c.height}.`)}i[s]=r}return r}else G=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(r=>(console.error("Error loading LOD",e,r),null))}afterRoot(e){var t,i;return G&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,r)=>{var o;if(s!=null&&s.extensions){const c=s==null?void 0:s.extensions[Se];if(c){if(!c.lods){G&&console.warn("Texture has no LODs",c);return}let h=!1;for(const u of this.parser.associations.keys())if(u.isTexture===!0){const p=this.parser.associations.get(u);(p==null?void 0:p.textures)===r&&(h=!0,H.registerTexture(this.url,u,(o=c.lods)==null?void 0:o.length,r,c))}h||this.parser.getDependency("texture",r).then(u=>{var p;u&&H.registerTexture(this.url,u,(p=c.lods)==null?void 0:p.length,r,c)})}}}),(i=this.parser.json.meshes)==null||i.forEach((s,r)=>{if(s!=null&&s.extensions){const o=s==null?void 0:s.extensions[Se];if(o&&o.lods){for(const c of this.parser.associations.keys())if(c.isMesh){const h=this.parser.associations.get(c);(h==null?void 0:h.meshes)===r&&H.registerMesh(this.url,o.guid,c,o.lods.length,h.primitives,o)}}}}),null}static async getOrLoadLOD(e,t){var h,u,p,n;const i=G=="verbose",s=this.getAssignedLODInformation(e);if(!s)return G&&console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`,e),null;const r=s==null?void 0:s.key;let o;if(e.isTexture===!0){const l=e;l.source&&l.source[Bi]&&(o=l.source[Bi])}if(o||(o=H.lodInfos.get(r)),!o)G&&console.warn(`Can not load LOD ${t}: no LOD info found for "${r}" ${e.name}`,e.type,H.lodInfos);else{if(t>0){let g=!1;const v=Array.isArray(o.lods);if(v&&t>=o.lods.length?g=!0:v||(g=!0),g)return this.lowresCache.get(r)}const l=Array.isArray(o.lods)?(h=o.lods[t])==null?void 0:h.path:o.lods;if(!l)return G&&!o["missing:uri"]&&(o["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,o)),null;const d=ba(s.url,l);if(d.endsWith(".glb")||d.endsWith(".gltf")){if(!o.guid)return console.warn("missing pointer for glb/gltf texture",o),null;const g=d+"_"+o.guid,v=await this.queue.slot(d),m=this.previouslyLoaded.get(g);if(m!==void 0){i&&console.log(`LOD ${t} was already loading/loaded: ${g}`);let x=await m.catch(T=>(console.error(`Error loading LOD ${t} from ${d}
|
|
3682
|
+
`,T),null)),b=!1;if(x==null||(x instanceof f.Texture&&e instanceof f.Texture?(u=x.image)!=null&&u.data||(p=x.source)!=null&&p.data?x=this.copySettings(e,x):(b=!0,this.previouslyLoaded.delete(g)):x instanceof f.BufferGeometry&&e instanceof f.BufferGeometry&&((n=x.attributes.position)!=null&&n.array||(b=!0,this.previouslyLoaded.delete(g)))),!b)return x}if(!v.use)return G&&console.log(`LOD ${t} was aborted: ${d}`),null;const _=o,y=new Promise(async(x,b)=>{if(Ra){const A=await(await La({})).load(d);if(A.textures.length>0)for(const S of A.textures){let L=S.texture;return H.assignLODInformation(s.url,L,r,t,void 0),e instanceof f.Texture&&(L=this.copySettings(e,L)),L&&(L.guid=_.guid),x(L)}if(A.geometries.length>0){const S=new Array;for(const L of A.geometries){const R=L.geometry;H.assignLODInformation(s.url,R,r,t,L.primitiveIndex),S.push(R)}return x(S)}return x(null)}const T=new ws.GLTFLoader;Gr(T),G&&(await new Promise(D=>setTimeout(D,1e3)),i&&console.warn("Start loading (delayed) "+d,_.guid));let M=d;if(_&&Array.isArray(_.lods)){const D=_.lods[t];D.hash&&(M+="?v="+D.hash)}const P=await T.loadAsync(M).catch(D=>(console.error(`Error loading LOD ${t} from ${d}
|
|
3683
|
+
`,D),x(null)));if(!P)return x(null);const C=P.parser;i&&console.log("Loading finished "+d,_.guid);let I=0;if(P.parser.json.textures){let D=!1;for(const A of P.parser.json.textures){if(A!=null&&A.extensions){const S=A==null?void 0:A.extensions[Se];if(S!=null&&S.guid&&S.guid===_.guid){D=!0;break}}I++}if(D){let A=await C.getDependency("texture",I);return A&&H.assignLODInformation(s.url,A,r,t,void 0),i&&console.log('change "'+e.name+'" → "'+A.name+'"',d,I,A,g),e instanceof f.Texture&&(A=this.copySettings(e,A)),A&&(A.guid=_.guid),x(A)}else G&&console.warn("Could not find texture with guid",_.guid,P.parser.json)}if(I=0,P.parser.json.meshes){let D=!1;for(const A of P.parser.json.meshes){if(A!=null&&A.extensions){const S=A==null?void 0:A.extensions[Se];if(S!=null&&S.guid&&S.guid===_.guid){D=!0;break}}I++}if(D){const A=await C.getDependency("mesh",I);if(i&&console.log(`Loaded Mesh "${A.name}"`,d,I,A,g),A.isMesh===!0){const S=A.geometry;return H.assignLODInformation(s.url,S,r,t,0),x(S)}else{const S=new Array;for(let L=0;L<A.children.length;L++){const R=A.children[L];if(R.isMesh===!0){const k=R.geometry;H.assignLODInformation(s.url,k,r,t,L),S.push(k)}}return x(S)}}else G&&console.warn("Could not find mesh with guid",_.guid,P.parser.json)}return x(null)});return this.previouslyLoaded.set(g,y),v.use(y),await y}else if(e instanceof f.Texture){i&&console.log("Load texture from uri: "+d);const v=await new f.TextureLoader().loadAsync(d);return v?(v.guid=o.guid,v.flipY=!1,v.needsUpdate=!0,v.colorSpace=e.colorSpace,i&&console.log(o,v)):G&&console.warn("failed loading",d),v}}return null}static assignLODInformation(e,t,i,s,r){if(!t)return;t.userData||(t.userData={});const o=new ka(e,i,s,r);t.userData.LODS=o,"source"in t&&typeof t.source=="object"&&(t.source.LODS=o)}static getAssignedLODInformation(e){var t,i;return e?(t=e.userData)!=null&&t.LODS?e.userData.LODS:"source"in e&&((i=e.source)!=null&&i.LODS)?e.source.LODS:null:null}static copySettings(e,t){return t?(G==="verbose"&&console.debug(`Copy texture settings
|
|
3684
3684
|
`,e.uuid,`
|
|
3685
|
-
`,t.uuid),t=t.clone(),t.offset=e.offset,t.repeat=e.repeat,t.colorSpace=e.colorSpace,t.magFilter=e.magFilter,t.minFilter=e.minFilter,t.wrapS=e.wrapS,t.wrapT=e.wrapT,t.flipY=e.flipY,t.anisotropy=e.anisotropy,t.mipmaps||(t.generateMipmaps=e.generateMipmaps),t):e}};E(H,"registerTexture",(e,t,i,s,r)=>{var c,h,u,p,n,l,d,g;if(!t){G&&console.error("!! gltf-progressive: Called register texture without texture");return}if(G){const v=((c=t.image)==null?void 0:c.width)||((u=(h=t.source)==null?void 0:h.data)==null?void 0:u.width)||0,m=((p=t.image)==null?void 0:p.height)||((l=(n=t.source)==null?void 0:n.data)==null?void 0:l.height)||0;console.log(`> gltf-progressive: register texture[${s}] "${t.name||t.uuid}", Current: ${v}x${m}, Max: ${(d=r.lods[0])==null?void 0:d.width}x${(g=r.lods[0])==null?void 0:g.height}, uuid: ${t.uuid}`,r,t)}t.source&&(t.source[Bi]=r);const o=r.guid;H.assignLODInformation(e,t,o,i,s),H.lodInfos.set(o,r),H.lowresCache.set(o,t)}),E(H,"registerMesh",(e,t,i,s,r,o)=>{var u;const c=i.geometry;if(!c){G&&console.warn("gltf-progressive: Register mesh without geometry");return}c.userData||(c.userData={}),G&&console.log("> Progressive: register mesh "+i.name,{index:r,uuid:i.uuid},o,i),H.assignLODInformation(e,c,t,s,r),H.lodInfos.set(t,o);let h=H.lowresCache.get(t);h?h.push(i.geometry):h=[i.geometry],H.lowresCache.set(t,h),s>0&&!Ht(i)&&Sa(i,c);for(const p of ke)(u=p.onRegisteredNewMesh)==null||u.call(p,i,o)}),E(H,"lodInfos",new Map),E(H,"previouslyLoaded",new Map),E(H,"lowresCache",new Map),E(H,"workers",[]),E(H,"_workersIndex",0),E(H,"maxConcurrent",50),E(H,"queue",new Aa(H.maxConcurrent,{debug:G!=!1}));let we=H;class ka{constructor(e,t,i,s){E(this,"url");E(this,"key");E(this,"level");E(this,"index");this.url=e,this.key=t,this.level=i,s!=null&&(this.index=s)}}class _i{constructor(e,t){E(this,"ready");E(this,"_resolve");E(this,"_signal");E(this,"_frame_start");E(this,"_frames_to_capture");E(this,"_resolved",!1);E(this,"_addedCount",0);E(this,"_resolvedCount",0);E(this,"_awaiting",[]);E(this,"_maxPromisesPerObject",1);E(this,"_currentFrame",0);E(this,"_seen",new WeakMap);var r;const s=Math.max(t.frames??2,2);this._frame_start=t.waitForFirstCapture?void 0:e,this._frames_to_capture=s,this.ready=new Promise(o=>{this._resolve=o}),this.ready.finally(()=>{this._resolved=!0,this._awaiting.length=0}),this._signal=t.signal,(r=this._signal)==null||r.addEventListener("abort",()=>{this.resolveNow()}),this._maxPromisesPerObject=Math.max(1,t.maxPromisesPerObject??1)}get awaitedCount(){return this._addedCount}get resolvedCount(){return this._resolvedCount}get currentlyAwaiting(){return this._awaiting.length}update(e){var t;this._currentFrame=e,this._frame_start===void 0&&this._addedCount>0&&(this._frame_start=e),((t=this._signal)!=null&&t.aborted||this._awaiting.length===0&&this._frame_start!==void 0&&e>this._frame_start+this._frames_to_capture)&&this.resolveNow()}add(e,t,i){if(this._resolved){G&&console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");return}if(!(this._frame_start!==void 0&&this._currentFrame>this._frame_start+this._frames_to_capture)){if(this._maxPromisesPerObject>=1)if(this._seen.has(t)){let s=this._seen.get(t);if(s>=this._maxPromisesPerObject){G&&console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");return}this._seen.set(t,s+1)}else this._seen.set(t,1);this._awaiting.push(i),this._addedCount++,i.finally(()=>{this._resolvedCount++,this._awaiting.splice(this._awaiting.indexOf(i),1)})}}resolveNow(){var e,t;this._resolved||(t=this._resolve)==null||t.call(this,{awaited_count:this._addedCount,resolved_count:this._resolvedCount,cancelled:((e=this._signal)==null?void 0:e.aborted)??!1})}}E(_i,"addPromise",(e,t,i,s)=>{s.forEach(r=>{r.add(e,t,i)})});const pe=qe("debugprogressive"),Fa=qe("noprogressive"),Oi=Symbol("Needle:LODSManager"),zi=Symbol("Needle:LODState"),Ie=Symbol("Needle:CurrentLOD"),re={mesh_lod:-1,texture_lod:-1};var ae,Me,Ai,Oe,gt,Ti,Ce;const q=class q{constructor(e,t){E(this,"renderer");E(this,"context");E(this,"projectionScreenMatrix",new f.Matrix4);E(this,"overrideLodLevel");E(this,"targetTriangleDensity",2e5);E(this,"skinnedMeshAutoUpdateBoundsInterval",30);E(this,"updateInterval","auto");Pe(this,ae,1);E(this,"pause",!1);E(this,"manual",!1);E(this,"_newPromiseGroups",[]);E(this,"_promiseGroupIds",0);E(this,"_lodchangedlisteners",[]);Pe(this,Me,void 0);Pe(this,Ai,new f.Clock);Pe(this,Oe,0);Pe(this,gt,0);Pe(this,Ti,0);Pe(this,Ce,0);E(this,"_fpsBuffer",[60,60,60,60,60]);E(this,"_sphere",new f.Sphere);E(this,"_tempBox",new f.Box3);E(this,"_tempBox2",new f.Box3);E(this,"tempMatrix",new f.Matrix4);E(this,"_tempWorldPosition",new f.Vector3);E(this,"_tempBoxSize",new f.Vector3);E(this,"_tempBox2Size",new f.Vector3);this.renderer=e,this.context={...t}}static getObjectLODState(e){return e[zi]}static addPlugin(e){ke.push(e)}static removePlugin(e){const t=ke.indexOf(e);t>=0&&ke.splice(t,1)}static get(e,t){if(e[Oi])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),e[Oi];const i=new q(e,{engine:"unknown",...t});return e[Oi]=i,i}get plugins(){return ke}awaitLoading(e){const t=this._promiseGroupIds++,i=new _i(Q(this,Oe),{...e});this._newPromiseGroups.push(i);const s=performance.now();return i.ready.finally(()=>{const r=this._newPromiseGroups.indexOf(i);r>=0&&(this._newPromiseGroups.splice(r,1),ir()&&performance.measure("LODsManager:awaitLoading",{start:s,detail:{id:t,name:e==null?void 0:e.name,awaited:i.awaitedCount,resolved:i.resolvedCount}}))}),i.ready}_postprocessPromiseGroups(){if(this._newPromiseGroups.length!==0)for(let e=this._newPromiseGroups.length-1;e>=0;e--)this._newPromiseGroups[e].update(Q(this,Oe))}addEventListener(e,t){e==="changed"&&this._lodchangedlisteners.push(t)}removeEventListener(e,t){if(e==="changed"){const i=this._lodchangedlisteners.indexOf(t);i>=0&&this._lodchangedlisteners.splice(i,1)}}enable(){if(Q(this,Me))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let e=0;ye(this,Me,this.renderer.render);const t=this;Hr(this.renderer),this.renderer.render=function(i,s){const r=t.renderer.getRenderTarget();(r==null||"isXRRenderTarget"in r&&r.isXRRenderTarget)&&(e=0,ye(t,Oe,Q(t,Oe)+1),ye(t,gt,Q(t,Ai).getDelta()),ye(t,Ti,Q(t,Ti)+Q(t,gt)),t._fpsBuffer.shift(),t._fpsBuffer.push(1/Q(t,gt)),ye(t,Ce,t._fpsBuffer.reduce((c,h)=>c+h)/t._fpsBuffer.length),pe&&Q(t,Oe)%200===0&&console.log("FPS",Math.round(Q(t,Ce)),"Interval:",Q(t,ae)));const o=e++;Q(t,Me).call(this,i,s),t.onAfterRender(i,s,o)}}disable(){Q(this,Me)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=Q(this,Me),ye(this,Me,void 0))}update(e,t){this.internalUpdate(e,t)}onAfterRender(e,t,i){if(this.pause)return;const r=this.renderer.renderLists.get(e,0).opaque;let o=!0;if(r.length===1){const c=r[0].material;(c.name==="EffectMaterial"||c.name==="CopyShader")&&(o=!1)}if((t.parent&&t.parent.type==="CubeCamera"||i>=1&&t.type==="OrthographicCamera")&&(o=!1),o){if(Fa||(this.updateInterval==="auto"?Q(this,Ce)<40&&Q(this,ae)<10?(ye(this,ae,Q(this,ae)+1),pe&&console.warn("↓ Reducing LOD updates",Q(this,ae),Q(this,Ce).toFixed(0))):Q(this,Ce)>=60&&Q(this,ae)>1&&(ye(this,ae,Q(this,ae)-1),pe&&console.warn("↑ Increasing LOD updates",Q(this,ae),Q(this,Ce).toFixed(0))):ye(this,ae,this.updateInterval),Q(this,ae)>0&&Q(this,Oe)%Q(this,ae)!=0))return;this.internalUpdate(e,t),this._postprocessPromiseGroups()}}internalUpdate(e,t){var h,u;const i=this.renderer.renderLists.get(e,0),s=i.opaque;this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const r=this.targetTriangleDensity;for(const p of s){if(p.material&&(((h=p.geometry)==null?void 0:h.type)==="BoxGeometry"||((u=p.geometry)==null?void 0:u.type)==="BufferGeometry")&&(p.material.name==="SphericalGaussianBlur"||p.material.name=="BackgroundCubeMaterial"||p.material.name==="CubemapFromEquirect"||p.material.name==="EquirectangularToCubeUV")){pe&&(p.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]||(p.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]=!0,console.warn("Ignoring skybox or BLIT object",p,p.material.name,p.material.type)));continue}switch(p.material.type){case"LineBasicMaterial":case"LineDashedMaterial":case"PointsMaterial":case"ShadowMaterial":case"MeshDistanceMaterial":case"MeshDepthMaterial":continue}if(pe==="color"&&p.material&&!p.object.progressive_debug_color){p.object.progressive_debug_color=!0;const l=Math.random()*16777215,d=new f.MeshStandardMaterial({color:l});p.object.material=d}const n=p.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,r)}const o=i.transparent;for(const p of o){const n=p.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,r)}const c=i.transmissive;for(const p of c){const n=p.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,r)}}updateLODs(e,t,i,s){var c,h;i.userData||(i.userData={});let r=i[zi];if(r||(r=new Ba,i[zi]=r),r.frames++<2)return;for(const u of ke)(c=u.onBeforeUpdateLOD)==null||c.call(u,this.renderer,e,t,i);const o=this.overrideLodLevel!==void 0?this.overrideLodLevel:Ne;o>=0?(re.mesh_lod=o,re.texture_lod=o):(this.calculateLodLevel(t,i,r,s,re),re.mesh_lod=Math.round(re.mesh_lod),re.texture_lod=Math.round(re.texture_lod)),re.mesh_lod>=0&&this.loadProgressiveMeshes(i,re.mesh_lod),i.material&&re.texture_lod>=0&&this.loadProgressiveTextures(i.material,re.texture_lod,o),G&&i.material&&!i.isGizmo&&Yr(i.material);for(const u of ke)(h=u.onAfterUpdatedLOD)==null||h.call(u,this.renderer,e,t,i,re);r.lastLodLevel_Mesh=re.mesh_lod,r.lastLodLevel_Texture=re.texture_lod}loadProgressiveTextures(e,t,i){if(!e)return;if(Array.isArray(e)){for(const r of e)this.loadProgressiveTextures(r,t);return}let s=!1;if((e[Ie]===void 0||t<e[Ie])&&(s=!0),i!==void 0&&i>=0&&(s=e[Ie]!=i,t=i),s){e[Ie]=t;const r=we.assignTextureLOD(e,t).then(o=>{this._lodchangedlisteners.forEach(c=>c({type:"texture",level:t,object:e}))});_i.addPromise("texture",e,r,this._newPromiseGroups)}}loadProgressiveMeshes(e,t){if(!e)return Promise.resolve(null);let i=e[Ie]!==t;const s=e["DEBUG:LOD"];if(s!=null&&(i=e[Ie]!=s,t=s),i){e[Ie]=t;const r=e.geometry,o=we.assignMeshLOD(e,t).then(c=>(c&&e[Ie]==t&&r!=e.geometry&&this._lodchangedlisteners.forEach(h=>h({type:"mesh",level:t,object:e})),c));return _i.addPromise("mesh",e,o,this._newPromiseGroups),o}return Promise.resolve(null)}static isInside(e,t){const i=e.min,s=e.max,r=(i.x+s.x)*.5,o=(i.y+s.y)*.5;return this._tempPtInside.set(r,o,i.z).applyMatrix4(t).z<0}calculateLodLevel(e,t,i,s,r){var m,_,y,w;if(!t){r.mesh_lod=-1,r.texture_lod=-1;return}if(!e){r.mesh_lod=-1,r.texture_lod=-1;return}let c=10+1,h=!1;if(pe&&t["DEBUG:LOD"]!=null)return t["DEBUG:LOD"];const u=(m=we.getMeshLODExtension(t.geometry))==null?void 0:m.lods,p=we.getPrimitiveIndex(t.geometry),n=u&&u.length>0,l=we.getMaterialMinMaxLODsCount(t.material),d=l.min_count!==1/0&&l.min_count>=0&&l.max_count>=0;if(!n&&!d){r.mesh_lod=0,r.texture_lod=0;return}n||(h=!0,c=0);const g=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let v=t.geometry.boundingBox;if(t.type==="SkinnedMesh"){const x=t;if(!x.boundingBox)x.computeBoundingBox();else if(this.skinnedMeshAutoUpdateBoundsInterval>0){if(!x[q.$skinnedMeshBoundsOffset]){const T=q.skinnedMeshBoundsFrameOffsetCounter++;x[q.$skinnedMeshBoundsOffset]=T}const b=x[q.$skinnedMeshBoundsOffset];if((i.frames+b)%this.skinnedMeshAutoUpdateBoundsInterval===0){const T=Ht(x),M=x.geometry;T&&(x.geometry=T),x.computeBoundingBox(),x.geometry=M}}v=x.boundingBox}if(v){const x=e;if(t.geometry.attributes.color&&t.geometry.attributes.color.count<100&&t.geometry.boundingSphere){this._sphere.copy(t.geometry.boundingSphere),this._sphere.applyMatrix4(t.matrixWorld);const S=e.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(S)){r.mesh_lod=0,r.texture_lod=0;return}}if(this._tempBox.copy(v),this._tempBox.applyMatrix4(t.matrixWorld),x.isPerspectiveCamera&&q.isInside(this._tempBox,this.projectionScreenMatrix)){r.mesh_lod=0,r.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&x.isPerspectiveCamera&&x.fov>70){const S=this._tempBox.min,P=this._tempBox.max;let R=S.x,k=S.y,F=P.x,z=P.y;const B=2,N=1.5,W=(S.x+P.x)*.5,O=(S.y+P.y)*.5;R=(R-W)*B+W,k=(k-O)*B+O,F=(F-W)*B+W,z=(z-O)*B+O;const j=R<0&&F>0?0:Math.min(Math.abs(S.x),Math.abs(P.x)),U=k<0&&z>0?0:Math.min(Math.abs(S.y),Math.abs(P.y)),ie=Math.max(j,U);i.lastCentrality=(N-ie)*(N-ie)*(N-ie)}else i.lastCentrality=1;const b=this._tempBox.getSize(this._tempBoxSize);b.multiplyScalar(.5),screen.availHeight>0&&g>0&&b.multiplyScalar(g/screen.availHeight),e.isPerspectiveCamera?b.x*=e.aspect:e.isOrthographicCamera;const T=e.matrixWorldInverse,M=this._tempBox2;M.copy(v),M.applyMatrix4(t.matrixWorld),M.applyMatrix4(T);const L=M.getSize(this._tempBox2Size),C=Math.max(L.x,L.y);if(Math.max(b.x,b.y)!=0&&C!=0&&(b.z=L.z/Math.max(L.x,L.y)*Math.max(b.x,b.y)),i.lastScreenCoverage=Math.max(b.x,b.y,b.z),i.lastScreenspaceVolume.copy(b),i.lastScreenCoverage*=i.lastCentrality,pe&&q.debugDrawLine){const S=this.tempMatrix.copy(this.projectionScreenMatrix);S.invert();const P=q.corner0,R=q.corner1,k=q.corner2,F=q.corner3;P.copy(this._tempBox.min),R.copy(this._tempBox.max),R.x=P.x,k.copy(this._tempBox.max),k.y=P.y,F.copy(this._tempBox.max);const z=(P.z+F.z)*.5;P.z=R.z=k.z=F.z=z,P.applyMatrix4(S),R.applyMatrix4(S),k.applyMatrix4(S),F.applyMatrix4(S),q.debugDrawLine(P,R,255),q.debugDrawLine(P,k,255),q.debugDrawLine(R,F,255),q.debugDrawLine(k,F,255)}let D=999;if(u&&i.lastScreenCoverage>0)for(let S=0;S<u.length;S++){const P=u[S],k=(((_=P.densities)==null?void 0:_[p])||P.density||1e-5)/i.lastScreenCoverage;if(p>0&&ir()&&!P.densities&&!globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"]&&(window["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"]=!0,console.warn("[Needle Progressive] Detected usage of mesh without primitive densities. This might cause incorrect LOD level selection: Consider re-optimizing your model by updating your Needle Integration, Needle glTF Pipeline or running optimization again on Needle Cloud.")),k<s){D=S;break}}D<c&&(c=D,h=!0)}if(h?r.mesh_lod=c:r.mesh_lod=i.lastLodLevel_Mesh,pe&&r.mesh_lod!=i.lastLodLevel_Mesh){const b=u==null?void 0:u[r.mesh_lod];b&&console.log(`Mesh LOD changed: ${i.lastLodLevel_Mesh} → ${r.mesh_lod} (density: ${(y=b.densities)==null?void 0:y[p].toFixed(0)}) | ${t.name}`)}if(d){const x="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(i.lastLodLevel_Texture<0){if(r.texture_lod=l.max_count-1,pe){const b=l.lods[l.max_count-1];pe&&console.log(`First Texture LOD ${r.texture_lod} (${b.max_height}px) - ${t.name}`)}}else{const b=i.lastScreenspaceVolume.x+i.lastScreenspaceVolume.y+i.lastScreenspaceVolume.z;let T=i.lastScreenCoverage*4;((w=this.context)==null?void 0:w.engine)==="model-viewer"&&(T*=1.5);const L=g/window.devicePixelRatio*T;let C=!1;for(let I=l.lods.length-1;I>=0;I--){const D=l.lods[I];if(!(x&&D.max_height>=2048)&&!(qr()&&D.max_height>4096)&&(D.max_height>L||!C&&I===0)){if(C=!0,r.texture_lod=I,pe&&r.texture_lod<i.lastLodLevel_Texture){const A=D.max_height;console.log(`Texture LOD changed: ${i.lastLodLevel_Texture} → ${r.texture_lod} = ${A}px
|
|
3686
|
-
Screensize: ${
|
|
3685
|
+
`,t.uuid),t=t.clone(),t.offset=e.offset,t.repeat=e.repeat,t.colorSpace=e.colorSpace,t.magFilter=e.magFilter,t.minFilter=e.minFilter,t.wrapS=e.wrapS,t.wrapT=e.wrapT,t.flipY=e.flipY,t.anisotropy=e.anisotropy,t.mipmaps||(t.generateMipmaps=e.generateMipmaps),t):e}};E(H,"registerTexture",(e,t,i,s,r)=>{var c,h,u,p,n,l,d,g;if(!t){G&&console.error("!! gltf-progressive: Called register texture without texture");return}if(G){const v=((c=t.image)==null?void 0:c.width)||((u=(h=t.source)==null?void 0:h.data)==null?void 0:u.width)||0,m=((p=t.image)==null?void 0:p.height)||((l=(n=t.source)==null?void 0:n.data)==null?void 0:l.height)||0;console.log(`> gltf-progressive: register texture[${s}] "${t.name||t.uuid}", Current: ${v}x${m}, Max: ${(d=r.lods[0])==null?void 0:d.width}x${(g=r.lods[0])==null?void 0:g.height}, uuid: ${t.uuid}`,r,t)}t.source&&(t.source[Bi]=r);const o=r.guid;H.assignLODInformation(e,t,o,i,s),H.lodInfos.set(o,r),H.lowresCache.set(o,t)}),E(H,"registerMesh",(e,t,i,s,r,o)=>{var u;const c=i.geometry;if(!c){G&&console.warn("gltf-progressive: Register mesh without geometry");return}c.userData||(c.userData={}),G&&console.log("> Progressive: register mesh "+i.name,{index:r,uuid:i.uuid},o,i),H.assignLODInformation(e,c,t,s,r),H.lodInfos.set(t,o);let h=H.lowresCache.get(t);h?h.push(i.geometry):h=[i.geometry],H.lowresCache.set(t,h),s>0&&!Ht(i)&&Sa(i,c);for(const p of ke)(u=p.onRegisteredNewMesh)==null||u.call(p,i,o)}),E(H,"lodInfos",new Map),E(H,"previouslyLoaded",new Map),E(H,"lowresCache",new Map),E(H,"workers",[]),E(H,"_workersIndex",0),E(H,"maxConcurrent",50),E(H,"queue",new Aa(H.maxConcurrent,{debug:G!=!1}));let we=H;class ka{constructor(e,t,i,s){E(this,"url");E(this,"key");E(this,"level");E(this,"index");this.url=e,this.key=t,this.level=i,s!=null&&(this.index=s)}}class _i{constructor(e,t){E(this,"ready");E(this,"_resolve");E(this,"_signal");E(this,"_frame_start");E(this,"_frames_to_capture");E(this,"_resolved",!1);E(this,"_addedCount",0);E(this,"_resolvedCount",0);E(this,"_awaiting",[]);E(this,"_maxPromisesPerObject",1);E(this,"_currentFrame",0);E(this,"_seen",new WeakMap);var r;const s=Math.max(t.frames??2,2);this._frame_start=t.waitForFirstCapture?void 0:e,this._frames_to_capture=s,this.ready=new Promise(o=>{this._resolve=o}),this.ready.finally(()=>{this._resolved=!0,this._awaiting.length=0}),this._signal=t.signal,(r=this._signal)==null||r.addEventListener("abort",()=>{this.resolveNow()}),this._maxPromisesPerObject=Math.max(1,t.maxPromisesPerObject??1)}get awaitedCount(){return this._addedCount}get resolvedCount(){return this._resolvedCount}get currentlyAwaiting(){return this._awaiting.length}update(e){var t;this._currentFrame=e,this._frame_start===void 0&&this._addedCount>0&&(this._frame_start=e),((t=this._signal)!=null&&t.aborted||this._awaiting.length===0&&this._frame_start!==void 0&&e>this._frame_start+this._frames_to_capture)&&this.resolveNow()}add(e,t,i){if(this._resolved){G&&console.warn("PromiseGroup: Trying to add a promise to a resolved group, ignoring.");return}if(!(this._frame_start!==void 0&&this._currentFrame>this._frame_start+this._frames_to_capture)){if(this._maxPromisesPerObject>=1)if(this._seen.has(t)){let s=this._seen.get(t);if(s>=this._maxPromisesPerObject){G&&console.warn("PromiseGroup: Already awaiting object ignoring new promise for it.");return}this._seen.set(t,s+1)}else this._seen.set(t,1);this._awaiting.push(i),this._addedCount++,i.finally(()=>{this._resolvedCount++,this._awaiting.splice(this._awaiting.indexOf(i),1)})}}resolveNow(){var e,t;this._resolved||(t=this._resolve)==null||t.call(this,{awaited_count:this._addedCount,resolved_count:this._resolvedCount,cancelled:((e=this._signal)==null?void 0:e.aborted)??!1})}}E(_i,"addPromise",(e,t,i,s)=>{s.forEach(r=>{r.add(e,t,i)})});const pe=qe("debugprogressive"),Fa=qe("noprogressive"),Oi=Symbol("Needle:LODSManager"),zi=Symbol("Needle:LODState"),Ie=Symbol("Needle:CurrentLOD"),re={mesh_lod:-1,texture_lod:-1};var ae,Me,Ai,Oe,gt,Ti,Ce;const q=class q{constructor(e,t){E(this,"renderer");E(this,"context");E(this,"projectionScreenMatrix",new f.Matrix4);E(this,"overrideLodLevel");E(this,"targetTriangleDensity",2e5);E(this,"skinnedMeshAutoUpdateBoundsInterval",30);E(this,"updateInterval","auto");Le(this,ae,1);E(this,"pause",!1);E(this,"manual",!1);E(this,"_newPromiseGroups",[]);E(this,"_promiseGroupIds",0);E(this,"_lodchangedlisteners",[]);Le(this,Me,void 0);Le(this,Ai,new f.Clock);Le(this,Oe,0);Le(this,gt,0);Le(this,Ti,0);Le(this,Ce,0);E(this,"_fpsBuffer",[60,60,60,60,60]);E(this,"_sphere",new f.Sphere);E(this,"_tempBox",new f.Box3);E(this,"_tempBox2",new f.Box3);E(this,"tempMatrix",new f.Matrix4);E(this,"_tempWorldPosition",new f.Vector3);E(this,"_tempBoxSize",new f.Vector3);E(this,"_tempBox2Size",new f.Vector3);this.renderer=e,this.context={...t}}static getObjectLODState(e){return e[zi]}static addPlugin(e){ke.push(e)}static removePlugin(e){const t=ke.indexOf(e);t>=0&&ke.splice(t,1)}static get(e,t){if(e[Oi])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),e[Oi];const i=new q(e,{engine:"unknown",...t});return e[Oi]=i,i}get plugins(){return ke}awaitLoading(e){const t=this._promiseGroupIds++,i=new _i(Q(this,Oe),{...e});this._newPromiseGroups.push(i);const s=performance.now();return i.ready.finally(()=>{const r=this._newPromiseGroups.indexOf(i);r>=0&&(this._newPromiseGroups.splice(r,1),ir()&&performance.measure("LODsManager:awaitLoading",{start:s,detail:{id:t,name:e==null?void 0:e.name,awaited:i.awaitedCount,resolved:i.resolvedCount}}))}),i.ready}_postprocessPromiseGroups(){if(this._newPromiseGroups.length!==0)for(let e=this._newPromiseGroups.length-1;e>=0;e--)this._newPromiseGroups[e].update(Q(this,Oe))}addEventListener(e,t){e==="changed"&&this._lodchangedlisteners.push(t)}removeEventListener(e,t){if(e==="changed"){const i=this._lodchangedlisteners.indexOf(t);i>=0&&this._lodchangedlisteners.splice(i,1)}}enable(){if(Q(this,Me))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let e=0;ye(this,Me,this.renderer.render);const t=this;Hr(this.renderer),this.renderer.render=function(i,s){const r=t.renderer.getRenderTarget();(r==null||"isXRRenderTarget"in r&&r.isXRRenderTarget)&&(e=0,ye(t,Oe,Q(t,Oe)+1),ye(t,gt,Q(t,Ai).getDelta()),ye(t,Ti,Q(t,Ti)+Q(t,gt)),t._fpsBuffer.shift(),t._fpsBuffer.push(1/Q(t,gt)),ye(t,Ce,t._fpsBuffer.reduce((c,h)=>c+h)/t._fpsBuffer.length),pe&&Q(t,Oe)%200===0&&console.log("FPS",Math.round(Q(t,Ce)),"Interval:",Q(t,ae)));const o=e++;Q(t,Me).call(this,i,s),t.onAfterRender(i,s,o)}}disable(){Q(this,Me)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=Q(this,Me),ye(this,Me,void 0))}update(e,t){this.internalUpdate(e,t)}onAfterRender(e,t,i){if(this.pause)return;const r=this.renderer.renderLists.get(e,0).opaque;let o=!0;if(r.length===1){const c=r[0].material;(c.name==="EffectMaterial"||c.name==="CopyShader")&&(o=!1)}if((t.parent&&t.parent.type==="CubeCamera"||i>=1&&t.type==="OrthographicCamera")&&(o=!1),o){if(Fa||(this.updateInterval==="auto"?Q(this,Ce)<40&&Q(this,ae)<10?(ye(this,ae,Q(this,ae)+1),pe&&console.warn("↓ Reducing LOD updates",Q(this,ae),Q(this,Ce).toFixed(0))):Q(this,Ce)>=60&&Q(this,ae)>1&&(ye(this,ae,Q(this,ae)-1),pe&&console.warn("↑ Increasing LOD updates",Q(this,ae),Q(this,Ce).toFixed(0))):ye(this,ae,this.updateInterval),Q(this,ae)>0&&Q(this,Oe)%Q(this,ae)!=0))return;this.internalUpdate(e,t),this._postprocessPromiseGroups()}}internalUpdate(e,t){var h,u;const i=this.renderer.renderLists.get(e,0),s=i.opaque;this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const r=this.targetTriangleDensity;for(const p of s){if(p.material&&(((h=p.geometry)==null?void 0:h.type)==="BoxGeometry"||((u=p.geometry)==null?void 0:u.type)==="BufferGeometry")&&(p.material.name==="SphericalGaussianBlur"||p.material.name=="BackgroundCubeMaterial"||p.material.name==="CubemapFromEquirect"||p.material.name==="EquirectangularToCubeUV")){pe&&(p.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]||(p.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]=!0,console.warn("Ignoring skybox or BLIT object",p,p.material.name,p.material.type)));continue}switch(p.material.type){case"LineBasicMaterial":case"LineDashedMaterial":case"PointsMaterial":case"ShadowMaterial":case"MeshDistanceMaterial":case"MeshDepthMaterial":continue}if(pe==="color"&&p.material&&!p.object.progressive_debug_color){p.object.progressive_debug_color=!0;const l=Math.random()*16777215,d=new f.MeshStandardMaterial({color:l});p.object.material=d}const n=p.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,r)}const o=i.transparent;for(const p of o){const n=p.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,r)}const c=i.transmissive;for(const p of c){const n=p.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,r)}}updateLODs(e,t,i,s){var c,h;i.userData||(i.userData={});let r=i[zi];if(r||(r=new Ba,i[zi]=r),r.frames++<2)return;for(const u of ke)(c=u.onBeforeUpdateLOD)==null||c.call(u,this.renderer,e,t,i);const o=this.overrideLodLevel!==void 0?this.overrideLodLevel:Ne;o>=0?(re.mesh_lod=o,re.texture_lod=o):(this.calculateLodLevel(t,i,r,s,re),re.mesh_lod=Math.round(re.mesh_lod),re.texture_lod=Math.round(re.texture_lod)),re.mesh_lod>=0&&this.loadProgressiveMeshes(i,re.mesh_lod),i.material&&re.texture_lod>=0&&this.loadProgressiveTextures(i.material,re.texture_lod,o),G&&i.material&&!i.isGizmo&&Yr(i.material);for(const u of ke)(h=u.onAfterUpdatedLOD)==null||h.call(u,this.renderer,e,t,i,re);r.lastLodLevel_Mesh=re.mesh_lod,r.lastLodLevel_Texture=re.texture_lod}loadProgressiveTextures(e,t,i){if(!e)return;if(Array.isArray(e)){for(const r of e)this.loadProgressiveTextures(r,t);return}let s=!1;if((e[Ie]===void 0||t<e[Ie])&&(s=!0),i!==void 0&&i>=0&&(s=e[Ie]!=i,t=i),s){e[Ie]=t;const r=we.assignTextureLOD(e,t).then(o=>{this._lodchangedlisteners.forEach(c=>c({type:"texture",level:t,object:e}))});_i.addPromise("texture",e,r,this._newPromiseGroups)}}loadProgressiveMeshes(e,t){if(!e)return Promise.resolve(null);let i=e[Ie]!==t;const s=e["DEBUG:LOD"];if(s!=null&&(i=e[Ie]!=s,t=s),i){e[Ie]=t;const r=e.geometry,o=we.assignMeshLOD(e,t).then(c=>(c&&e[Ie]==t&&r!=e.geometry&&this._lodchangedlisteners.forEach(h=>h({type:"mesh",level:t,object:e})),c));return _i.addPromise("mesh",e,o,this._newPromiseGroups),o}return Promise.resolve(null)}static isInside(e,t){const i=e.min,s=e.max,r=(i.x+s.x)*.5,o=(i.y+s.y)*.5;return this._tempPtInside.set(r,o,i.z).applyMatrix4(t).z<0}calculateLodLevel(e,t,i,s,r){var m,_,y,w;if(!t){r.mesh_lod=-1,r.texture_lod=-1;return}if(!e){r.mesh_lod=-1,r.texture_lod=-1;return}let c=10+1,h=!1;if(pe&&t["DEBUG:LOD"]!=null)return t["DEBUG:LOD"];const u=(m=we.getMeshLODExtension(t.geometry))==null?void 0:m.lods,p=we.getPrimitiveIndex(t.geometry),n=u&&u.length>0,l=we.getMaterialMinMaxLODsCount(t.material),d=l.min_count!==1/0&&l.min_count>=0&&l.max_count>=0;if(!n&&!d){r.mesh_lod=0,r.texture_lod=0;return}n||(h=!0,c=0);const g=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let v=t.geometry.boundingBox;if(t.type==="SkinnedMesh"){const x=t;if(!x.boundingBox)x.computeBoundingBox();else if(this.skinnedMeshAutoUpdateBoundsInterval>0){if(!x[q.$skinnedMeshBoundsOffset]){const T=q.skinnedMeshBoundsFrameOffsetCounter++;x[q.$skinnedMeshBoundsOffset]=T}const b=x[q.$skinnedMeshBoundsOffset];if((i.frames+b)%this.skinnedMeshAutoUpdateBoundsInterval===0){const T=Ht(x),M=x.geometry;T&&(x.geometry=T),x.computeBoundingBox(),x.geometry=M}}v=x.boundingBox}if(v){const x=e;if(t.geometry.attributes.color&&t.geometry.attributes.color.count<100&&t.geometry.boundingSphere){this._sphere.copy(t.geometry.boundingSphere),this._sphere.applyMatrix4(t.matrixWorld);const S=e.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(S)){r.mesh_lod=0,r.texture_lod=0;return}}if(this._tempBox.copy(v),this._tempBox.applyMatrix4(t.matrixWorld),x.isPerspectiveCamera&&q.isInside(this._tempBox,this.projectionScreenMatrix)){r.mesh_lod=0,r.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&x.isPerspectiveCamera&&x.fov>70){const S=this._tempBox.min,L=this._tempBox.max;let R=S.x,k=S.y,F=L.x,z=L.y;const B=2,N=1.5,W=(S.x+L.x)*.5,O=(S.y+L.y)*.5;R=(R-W)*B+W,k=(k-O)*B+O,F=(F-W)*B+W,z=(z-O)*B+O;const j=R<0&&F>0?0:Math.min(Math.abs(S.x),Math.abs(L.x)),U=k<0&&z>0?0:Math.min(Math.abs(S.y),Math.abs(L.y)),ie=Math.max(j,U);i.lastCentrality=(N-ie)*(N-ie)*(N-ie)}else i.lastCentrality=1;const b=this._tempBox.getSize(this._tempBoxSize);b.multiplyScalar(.5),screen.availHeight>0&&g>0&&b.multiplyScalar(g/screen.availHeight),e.isPerspectiveCamera?b.x*=e.aspect:e.isOrthographicCamera;const T=e.matrixWorldInverse,M=this._tempBox2;M.copy(v),M.applyMatrix4(t.matrixWorld),M.applyMatrix4(T);const P=M.getSize(this._tempBox2Size),C=Math.max(P.x,P.y);if(Math.max(b.x,b.y)!=0&&C!=0&&(b.z=P.z/Math.max(P.x,P.y)*Math.max(b.x,b.y)),i.lastScreenCoverage=Math.max(b.x,b.y,b.z),i.lastScreenspaceVolume.copy(b),i.lastScreenCoverage*=i.lastCentrality,pe&&q.debugDrawLine){const S=this.tempMatrix.copy(this.projectionScreenMatrix);S.invert();const L=q.corner0,R=q.corner1,k=q.corner2,F=q.corner3;L.copy(this._tempBox.min),R.copy(this._tempBox.max),R.x=L.x,k.copy(this._tempBox.max),k.y=L.y,F.copy(this._tempBox.max);const z=(L.z+F.z)*.5;L.z=R.z=k.z=F.z=z,L.applyMatrix4(S),R.applyMatrix4(S),k.applyMatrix4(S),F.applyMatrix4(S),q.debugDrawLine(L,R,255),q.debugDrawLine(L,k,255),q.debugDrawLine(R,F,255),q.debugDrawLine(k,F,255)}let D=999;if(u&&i.lastScreenCoverage>0)for(let S=0;S<u.length;S++){const L=u[S],k=(((_=L.densities)==null?void 0:_[p])||L.density||1e-5)/i.lastScreenCoverage;if(p>0&&ir()&&!L.densities&&!globalThis["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"]&&(window["NEEDLE:MISSING_LOD_PRIMITIVE_DENSITIES"]=!0,console.warn("[Needle Progressive] Detected usage of mesh without primitive densities. This might cause incorrect LOD level selection: Consider re-optimizing your model by updating your Needle Integration, Needle glTF Pipeline or running optimization again on Needle Cloud.")),k<s){D=S;break}}D<c&&(c=D,h=!0)}if(h?r.mesh_lod=c:r.mesh_lod=i.lastLodLevel_Mesh,pe&&r.mesh_lod!=i.lastLodLevel_Mesh){const b=u==null?void 0:u[r.mesh_lod];b&&console.log(`Mesh LOD changed: ${i.lastLodLevel_Mesh} → ${r.mesh_lod} (density: ${(y=b.densities)==null?void 0:y[p].toFixed(0)}) | ${t.name}`)}if(d){const x="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(i.lastLodLevel_Texture<0){if(r.texture_lod=l.max_count-1,pe){const b=l.lods[l.max_count-1];pe&&console.log(`First Texture LOD ${r.texture_lod} (${b.max_height}px) - ${t.name}`)}}else{const b=i.lastScreenspaceVolume.x+i.lastScreenspaceVolume.y+i.lastScreenspaceVolume.z;let T=i.lastScreenCoverage*4;((w=this.context)==null?void 0:w.engine)==="model-viewer"&&(T*=1.5);const P=g/window.devicePixelRatio*T;let C=!1;for(let I=l.lods.length-1;I>=0;I--){const D=l.lods[I];if(!(x&&D.max_height>=2048)&&!(qr()&&D.max_height>4096)&&(D.max_height>P||!C&&I===0)){if(C=!0,r.texture_lod=I,pe&&r.texture_lod<i.lastLodLevel_Texture){const A=D.max_height;console.log(`Texture LOD changed: ${i.lastLodLevel_Texture} → ${r.texture_lod} = ${A}px
|
|
3686
|
+
Screensize: ${P.toFixed(0)}px, Coverage: ${(100*i.lastScreenCoverage).toFixed(2)}%, Volume ${b.toFixed(1)}
|
|
3687
3687
|
${t.name}`)}break}}}}else r.texture_lod=0}};ae=new WeakMap,Me=new WeakMap,Ai=new WeakMap,Oe=new WeakMap,gt=new WeakMap,Ti=new WeakMap,Ce=new WeakMap,E(q,"debugDrawLine"),E(q,"corner0",new f.Vector3),E(q,"corner1",new f.Vector3),E(q,"corner2",new f.Vector3),E(q,"corner3",new f.Vector3),E(q,"_tempPtInside",new f.Vector3),E(q,"skinnedMeshBoundsFrameOffsetCounter",0),E(q,"$skinnedMeshBoundsOffset",Symbol("gltf-progressive-skinnedMeshBoundsOffset"));let yt=q;class Ba{constructor(){E(this,"frames",0);E(this,"lastLodLevel_Mesh",-1);E(this,"lastLodLevel_Texture",-1);E(this,"lastScreenCoverage",0);E(this,"lastScreenspaceVolume",new f.Vector3);E(this,"lastCentrality",0)}}const sr=Symbol("NEEDLE_mesh_lod"),$t=Symbol("NEEDLE_texture_lod");let Tt=null;function Zr(){const a=Oa();a&&(a.mapURLs(function(e){return rr(),e}),rr(),Tt==null||Tt.disconnect(),Tt=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(i=>{i instanceof HTMLElement&&i.tagName.toLowerCase()==="model-viewer"&&Kr(i)})})}),Tt.observe(document,{childList:!0,subtree:!0}))}function Oa(){if(typeof customElements>"u")return null;const a=customElements.get("model-viewer");return a||(customElements.whenDefined("model-viewer").then(()=>{console.debug("[gltf-progressive] model-viewer defined"),Zr()}),null)}function rr(){if(typeof document>"u")return;document.querySelectorAll("model-viewer").forEach(e=>{Kr(e)})}const nr=new WeakSet;let za=0;function Kr(a){if(!a||nr.has(a))return null;nr.add(a),console.debug("[gltf-progressive] found new model-viewer..."+ ++za+`
|
|
3688
3688
|
`,a.getAttribute("src"));let e=null,t=null,i=null;for(let s=a;s!=null;s=Object.getPrototypeOf(s)){const r=Object.getOwnPropertySymbols(s),o=r.find(u=>u.toString()=="Symbol(renderer)"),c=r.find(u=>u.toString()=="Symbol(scene)"),h=r.find(u=>u.toString()=="Symbol(needsRender)");!e&&o!=null&&(e=a[o].threeRenderer),!t&&c!=null&&(t=a[c]),!i&&h!=null&&(i=a[h])}if(e&&t){let s=function(){if(i){let o=0,c=setInterval(()=>{if(o++>5){clearInterval(c);return}i==null||i.call(a)},300)}};console.debug("[gltf-progressive] setup model-viewer");const r=yt.get(e,{engine:"model-viewer"});return yt.addPlugin(new Va),r.enable(),r.addEventListener("changed",()=>{i==null||i.call(a)}),a.addEventListener("model-visibility",o=>{o.detail.visible&&(i==null||i.call(a))}),a.addEventListener("load",()=>{s()}),()=>{r.disable()}}return null}class Va{constructor(){E(this,"_didWarnAboutMissingUrl",!1)}onBeforeUpdateLOD(e,t,i,s){this.tryParseMeshLOD(t,s),this.tryParseTextureLOD(t,s)}getUrl(e){if(!e)return null;let t=e.getAttribute("src");return t||(t=e.src),t||(this._didWarnAboutMissingUrl||console.warn("No url found in modelviewer",e),this._didWarnAboutMissingUrl=!0),t}tryGetCurrentGLTF(e){return e._currentGLTF}tryGetCurrentModelViewer(e){return e.element}tryParseTextureLOD(e,t){if(t[$t]==!0)return;t[$t]=!0;const i=this.tryGetCurrentGLTF(e),s=this.tryGetCurrentModelViewer(e),r=this.getUrl(s);if(r&&i&&t.material){let o=function(h){var p,n,l;if(h[$t]==!0)return;h[$t]=!0,h.userData&&(h.userData.LOD=-1);const u=Object.keys(h);for(let d=0;d<u.length;d++){const g=u[d],v=h[g];if((v==null?void 0:v.isTexture)===!0){const m=(n=(p=v.userData)==null?void 0:p.associations)==null?void 0:n.textures;if(m==null)continue;const _=i.parser.json.textures[m];if(!_){console.warn("Texture data not found for texture index "+m);continue}if((l=_==null?void 0:_.extensions)!=null&&l[Se]){const y=_.extensions[Se];y&&r&&we.registerTexture(r,v,y.lods.length,m,y)}}}};const c=t.material;if(Array.isArray(c))for(const h of c)o(h);else o(c)}}tryParseMeshLOD(e,t){var o,c;if(t[sr]==!0)return;t[sr]=!0;const i=this.tryGetCurrentModelViewer(e),s=this.getUrl(i);if(!s)return;const r=(c=(o=t.userData)==null?void 0:o.gltfExtensions)==null?void 0:c[Se];if(r&&s){const h=t.uuid;we.registerMesh(s,h,t,0,r.lods.length,r)}}}function Xr(...a){let e,t,i,s;switch(a.length){case 2:[i,t]=a,s={};break;case 3:[i,t,s]=a;break;case 4:[e,t,i,s]=a;break;default:throw new Error("Invalid arguments")}Gr(i),jr(i,{progressive:!0,...s==null?void 0:s.hints}),i.register(o=>new we(o));const r=yt.get(t);return(s==null?void 0:s.enableLODsManager)!==!1&&r.enable(),r}Zr();if(!Ta){const a={gltfProgressive:{useNeedleProgressive:Xr,LODsManager:yt,configureLoader:jr,getRaycastMesh:Ht,useRaycastMeshes:Ma}};if(!globalThis.Needle)globalThis.Needle=a;else for(const e in a)globalThis.Needle[e]=a[e]}var pt=Object.freeze({Linear:Object.freeze({None:function(a){return a},In:function(a){return a},Out:function(a){return a},InOut:function(a){return a}}),Quadratic:Object.freeze({In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}}),Cubic:Object.freeze({In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}}),Quartic:Object.freeze({In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}}),Quintic:Object.freeze({In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}}),Sinusoidal:Object.freeze({In:function(a){return 1-Math.sin((1-a)*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return .5*(1-Math.sin(Math.PI*(.5-a)))}}),Exponential:Object.freeze({In:function(a){return a===0?0:Math.pow(1024,a-1)},Out:function(a){return a===1?1:1-Math.pow(2,-10*a)},InOut:function(a){return a===0?0:a===1?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}}),Circular:Object.freeze({In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}}),Elastic:Object.freeze({In:function(a){return a===0?0:a===1?1:-Math.pow(2,10*(a-1))*Math.sin((a-1.1)*5*Math.PI)},Out:function(a){return a===0?0:a===1?1:Math.pow(2,-10*a)*Math.sin((a-.1)*5*Math.PI)+1},InOut:function(a){return a===0?0:a===1?1:(a*=2,a<1?-.5*Math.pow(2,10*(a-1))*Math.sin((a-1.1)*5*Math.PI):.5*Math.pow(2,-10*(a-1))*Math.sin((a-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(a){var e=1.70158;return a===1?1:a*a*((e+1)*a-e)},Out:function(a){var e=1.70158;return a===0?0:--a*a*((e+1)*a+e)+1},InOut:function(a){var e=2.5949095;return(a*=2)<1?.5*(a*a*((e+1)*a-e)):.5*((a-=2)*a*((e+1)*a+e)+2)}}),Bounce:Object.freeze({In:function(a){return 1-pt.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return a<.5?pt.Bounce.In(a*2)*.5:pt.Bounce.Out(a*2-1)*.5+.5}}),generatePow:function(a){return a===void 0&&(a=4),a=a<Number.EPSILON?Number.EPSILON:a,a=a>1e4?1e4:a,{In:function(e){return Math.pow(e,a)},Out:function(e){return 1-Math.pow(1-e,a)},InOut:function(e){return e<.5?Math.pow(e*2,a)/2:(1-Math.pow(2-e*2,a))/2+.5}}}}),ft=function(){return performance.now()},Jr=function(){function a(){this._tweens={},this._tweensAddedDuringUpdate={}}return a.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},a.prototype.removeAll=function(){this._tweens={}},a.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},a.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},a.prototype.update=function(e,t){e===void 0&&(e=ft()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<i.length;s++){var r=this._tweens[i[s]],o=!t;r&&r.update(e,o)===!1&&!t&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},a}(),Qe={Linear:function(a,e){var t=a.length-1,i=t*e,s=Math.floor(i),r=Qe.Utils.Linear;return e<0?r(a[0],a[1],i):e>1?r(a[t],a[t-1],t-i):r(a[s],a[s+1>t?t:s+1],i-s)},Bezier:function(a,e){for(var t=0,i=a.length-1,s=Math.pow,r=Qe.Utils.Bernstein,o=0;o<=i;o++)t+=s(1-e,i-o)*s(e,o)*a[o]*r(i,o);return t},CatmullRom:function(a,e){var t=a.length-1,i=t*e,s=Math.floor(i),r=Qe.Utils.CatmullRom;return a[0]===a[t]?(e<0&&(s=Math.floor(i=t*(1+e))),r(a[(s-1+t)%t],a[s],a[(s+1)%t],a[(s+2)%t],i-s)):e<0?a[0]-(r(a[0],a[0],a[1],a[1],-i)-a[0]):e>1?a[t]-(r(a[t],a[t],a[t-1],a[t-1],i-t)-a[t]):r(a[s?s-1:0],a[s],a[t<s+1?t:s+1],a[t<s+2?t:s+2],i-s)},Utils:{Linear:function(a,e,t){return(e-a)*t+a},Bernstein:function(a,e){var t=Qe.Utils.Factorial;return t(a)/t(e)/t(a-e)},Factorial:function(){var a=[1];return function(e){var t=1;if(a[e])return a[e];for(var i=e;i>1;i--)t*=i;return a[e]=t,t}}(),CatmullRom:function(a,e,t,i,s){var r=(t-a)*.5,o=(i-e)*.5,c=s*s,h=s*c;return(2*e-2*t+r+o)*h+(-3*e+3*t-2*r-o)*c+r*s+e}}},Ms=function(){function a(){}return a.nextId=function(){return a._nextId++},a._nextId=0,a}(),rs=new Jr,wi=function(){function a(e,t){t===void 0&&(t=rs),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=pt.Linear.None,this._interpolationFunction=Qe.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Ms.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return a.prototype.getId=function(){return this._id},a.prototype.isPlaying=function(){return this._isPlaying},a.prototype.isPaused=function(){return this._isPaused},a.prototype.getDuration=function(){return this._duration},a.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},a.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},a.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},a.prototype.start=function(e,t){if(e===void 0&&(e=ft()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var r in this._valuesEnd)s[r]=this._valuesEnd[r];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},a.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},a.prototype._setupProperties=function(e,t,i,s,r){for(var o in i){var c=e[o],h=Array.isArray(c),u=h?"array":typeof c,p=!h&&Array.isArray(i[o]);if(!(u==="undefined"||u==="function")){if(p){var n=i[o];if(n.length===0)continue;for(var l=[c],d=0,g=n.length;d<g;d+=1){var v=this._handleRelativeValue(c,n[d]);if(isNaN(v)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}l.push(v)}p&&(i[o]=l)}if((u==="object"||h)&&c&&!p){t[o]=h?[]:{};var m=c;for(var _ in m)t[o][_]=m[_];s[o]=h?[]:{};var n=i[o];if(!this._isDynamic){var y={};for(var _ in n)y[_]=n[_];i[o]=n=y}this._setupProperties(m,t[o],n,s[o],r)}else(typeof t[o]>"u"||r)&&(t[o]=c),h||(t[o]*=1),p?s[o]=i[o].slice().reverse():s[o]=t[o]||0}}},a.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},a.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},a.prototype.pause=function(e){return e===void 0&&(e=ft()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},a.prototype.resume=function(e){return e===void 0&&(e=ft()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},a.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},a.prototype.group=function(e){return e===void 0&&(e=rs),this._group=e,this},a.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},a.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},a.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},a.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},a.prototype.easing=function(e){return e===void 0&&(e=pt.Linear.None),this._easingFunction=e,this},a.prototype.interpolation=function(e){return e===void 0&&(e=Qe.Linear),this._interpolationFunction=e,this},a.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},a.prototype.onStart=function(e){return this._onStartCallback=e,this},a.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},a.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},a.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},a.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},a.prototype.onStop=function(e){return this._onStopCallback=e,this},a.prototype.update=function(e,t){var i=this,s;if(e===void 0&&(e=ft()),t===void 0&&(t=!0),this._isPaused)return!0;var r,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var c=e-this._startTime,h=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),u=this._duration+this._repeat*h,p=function(){if(i._duration===0||c>u)return 1;var m=Math.trunc(c/h),_=c-m*h,y=Math.min(_/i._duration,1);return y===0&&c===i._duration?1:y},n=p(),l=this._easingFunction(n);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,n),this._duration===0||c>=this._duration)if(this._repeat>0){var d=Math.min(Math.trunc((c-this._duration)/h)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=d);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=h*d,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,v=this._chainedTweens.length;g<v;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},a.prototype._updateProperties=function(e,t,i,s){for(var r in i)if(t[r]!==void 0){var o=t[r]||0,c=i[r],h=Array.isArray(e[r]),u=Array.isArray(c),p=!h&&u;p?e[r]=this._interpolationFunction(c,s):typeof c=="object"&&c?this._updateProperties(e[r],o,c,s):(c=this._handleRelativeValue(o,c),typeof c=="number"&&(e[r]=o+(c-o)*s))}},a.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},a.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},a}(),Wa="23.1.3",Ua=Ms.nextId,Ae=rs,Ha=Ae.getAll.bind(Ae),Ga=Ae.removeAll.bind(Ae),Na=Ae.add.bind(Ae),Qa=Ae.remove.bind(Ae),ja=Ae.update.bind(Ae),ne={Easing:pt,Group:Jr,Interpolation:Qe,now:ft,Sequence:Ms,nextId:Ua,Tween:wi,VERSION:Wa,getAll:Ha,removeAll:Ga,add:Na,remove:Qa,update:ja},St=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qa(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var $r={exports:{}};(function(a){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(h,u,p){this.fn=h,this.context=u,this.once=p||!1}function r(h,u,p,n,l){if(typeof p!="function")throw new TypeError("The listener must be a function");var d=new s(p,n||h,l),g=t?t+u:u;return h._events[g]?h._events[g].fn?h._events[g]=[h._events[g],d]:h._events[g].push(d):(h._events[g]=d,h._eventsCount++),h}function o(h,u){--h._eventsCount===0?h._events=new i:delete h._events[u]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var u=[],p,n;if(this._eventsCount===0)return u;for(n in p=this._events)e.call(p,n)&&u.push(t?n.slice(1):n);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(p)):u},c.prototype.listeners=function(u){var p=t?t+u:u,n=this._events[p];if(!n)return[];if(n.fn)return[n.fn];for(var l=0,d=n.length,g=new Array(d);l<d;l++)g[l]=n[l].fn;return g},c.prototype.listenerCount=function(u){var p=t?t+u:u,n=this._events[p];return n?n.fn?1:n.length:0},c.prototype.emit=function(u,p,n,l,d,g){var v=t?t+u:u;if(!this._events[v])return!1;var m=this._events[v],_=arguments.length,y,w;if(m.fn){switch(m.once&&this.removeListener(u,m.fn,void 0,!0),_){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,p),!0;case 3:return m.fn.call(m.context,p,n),!0;case 4:return m.fn.call(m.context,p,n,l),!0;case 5:return m.fn.call(m.context,p,n,l,d),!0;case 6:return m.fn.call(m.context,p,n,l,d,g),!0}for(w=1,y=new Array(_-1);w<_;w++)y[w-1]=arguments[w];m.fn.apply(m.context,y)}else{var x=m.length,b;for(w=0;w<x;w++)switch(m[w].once&&this.removeListener(u,m[w].fn,void 0,!0),_){case 1:m[w].fn.call(m[w].context);break;case 2:m[w].fn.call(m[w].context,p);break;case 3:m[w].fn.call(m[w].context,p,n);break;case 4:m[w].fn.call(m[w].context,p,n,l);break;default:if(!y)for(b=1,y=new Array(_-1);b<_;b++)y[b-1]=arguments[b];m[w].fn.apply(m[w].context,y)}}return!0},c.prototype.on=function(u,p,n){return r(this,u,p,n,!1)},c.prototype.once=function(u,p,n){return r(this,u,p,n,!0)},c.prototype.removeListener=function(u,p,n,l){var d=t?t+u:u;if(!this._events[d])return this;if(!p)return o(this,d),this;var g=this._events[d];if(g.fn)g.fn===p&&(!l||g.once)&&(!n||g.context===n)&&o(this,d);else{for(var v=0,m=[],_=g.length;v<_;v++)(g[v].fn!==p||l&&!g[v].once||n&&g[v].context!==n)&&m.push(g[v]);m.length?this._events[d]=m.length===1?m[0]:m:o(this,d)}return this},c.prototype.removeAllListeners=function(u){var p;return u?(p=t?t+u:u,this._events[p]&&o(this,p)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=t,c.EventEmitter=c,a.exports=c})($r);var Ya=$r.exports;const Ye=qa(Ya);var zt=function(){var a=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(n){n.preventDefault(),i(++a%e.children.length)},!1);function t(n){return e.appendChild(n.dom),n}function i(n){for(var l=0;l<e.children.length;l++)e.children[l].style.display=l===n?"block":"none";a=n}var s=(performance||Date).now(),r=s,o=0,c=t(new zt.Panel("FPS","#0ff","#002")),h=t(new zt.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=t(new zt.Panel("MB","#f08","#201"));i(0);var p=0;return{REVISION:16,dom:e,fps:function(){return p&&parseInt(p.toFixed(0))},addPanel:t,showPanel:i,begin:function(){s=(performance||Date).now()},end:function(){o++;var n=(performance||Date).now();if(h.update(n-s,200),n>=r+1e3&&(p=o*1e3/(n-r),c.update(p,100),r=n,o=0,u)){var l=performance.memory;u.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return n},update:function(){s=this.end()},domElement:e,setMode:i}};zt.Panel=function(a,e,t){var i=1/0,s=0,r=Math.round,o=r(window.devicePixelRatio||1),c=80*o,h=48*o,u=3*o,p=2*o,n=3*o,l=15*o,d=74*o,g=30*o,v=document.createElement("canvas");v.width=c,v.height=h,v.style.cssText="width:80px;height:48px";var m=v.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=t,m.fillRect(0,0,c,h),m.fillStyle=e,m.fillText(a,u,p),m.fillRect(n,l,d,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(n,l,d,g),{dom:v,update:function(_,y){i=Math.min(i,_),s=Math.max(s,_),m.fillStyle=t,m.globalAlpha=1,m.fillRect(0,0,c,l),m.fillStyle=e,m.fillText(r(_)+" "+a+" ("+r(i)+"-"+r(s)+")",u,p),m.drawImage(v,n+o,l,d-o,g,n,l,d-o,g),m.fillRect(n+d-o,l,o,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(n+d-o,l,o,r((1-_/y)*g))}}};function Za(a,e){const t=URL.createObjectURL(a),i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}function en(a){return a.length===0?0:a.reduce((t,i)=>t+i,0)/a.length}function ns(a,e){const t=new Blob([a],{type:e});return URL.createObjectURL(t)}function tn(){return/Mac|iPod|iPhone|iPad/.test(navigator==null?void 0:navigator.platform)||/Mac OS|iOS/.test(navigator==null?void 0:navigator.userAgent)}function os(a){let e=document.createElement("canvas");const t=e.getContext("2d");return e.width=a.width,e.height=a.height,t?(t.drawImage(a,0,0),e.toDataURL("image/png",.75)):void 0}function Ka(a,e=43){const t=a*Math.PI/180;return e/(2*Math.tan(t/2))}var sn={};/*!
|
|
3689
3689
|
* howler.js v2.2.4
|
|
@@ -3693,7 +3693,7 @@ ${t.name}`)}break}}}}else r.texture_lod=0}};ae=new WeakMap,Me=new WeakMap,Ai=new
|
|
|
3693
3693
|
* goldfirestudios.com
|
|
3694
3694
|
*
|
|
3695
3695
|
* MIT License
|
|
3696
|
-
*/(function(a){(function(){var e=function(){this.init()};e.prototype={init:function(){var n=this||t;return n._counter=1e3,n._html5AudioPool=[],n.html5PoolSize=10,n._codecs={},n._howls=[],n._muted=!1,n._volume=1,n._canPlayEvent="canplaythrough",n._navigator=typeof window<"u"&&window.navigator?window.navigator:null,n.masterGain=null,n.noAudio=!1,n.usingWebAudio=!0,n.autoSuspend=!0,n.ctx=null,n.autoUnlock=!0,n._setup(),n},volume:function(n){var l=this||t;if(n=parseFloat(n),l.ctx||p(),typeof n<"u"&&n>=0&&n<=1){if(l._volume=n,l._muted)return l;l.usingWebAudio&&l.masterGain.gain.setValueAtTime(n,t.ctx.currentTime);for(var d=0;d<l._howls.length;d++)if(!l._howls[d]._webAudio)for(var g=l._howls[d]._getSoundIds(),v=0;v<g.length;v++){var m=l._howls[d]._soundById(g[v]);m&&m._node&&(m._node.volume=m._volume*n)}return l}return l._volume},mute:function(n){var l=this||t;l.ctx||p(),l._muted=n,l.usingWebAudio&&l.masterGain.gain.setValueAtTime(n?0:l._volume,t.ctx.currentTime);for(var d=0;d<l._howls.length;d++)if(!l._howls[d]._webAudio)for(var g=l._howls[d]._getSoundIds(),v=0;v<g.length;v++){var m=l._howls[d]._soundById(g[v]);m&&m._node&&(m._node.muted=n?!0:m._muted)}return l},stop:function(){for(var n=this||t,l=0;l<n._howls.length;l++)n._howls[l].stop();return n},unload:function(){for(var n=this||t,l=n._howls.length-1;l>=0;l--)n._howls[l].unload();return n.usingWebAudio&&n.ctx&&typeof n.ctx.close<"u"&&(n.ctx.close(),n.ctx=null,p()),n},codecs:function(n){return(this||t)._codecs[n.replace(/^x-/,"")]},_setup:function(){var n=this||t;if(n.state=n.ctx&&n.ctx.state||"suspended",n._autoSuspend(),!n.usingWebAudio)if(typeof Audio<"u")try{var l=new Audio;typeof l.oncanplaythrough>"u"&&(n._canPlayEvent="canplay")}catch{n.noAudio=!0}else n.noAudio=!0;try{var l=new Audio;l.muted&&(n.noAudio=!0)}catch{}return n.noAudio||n._setupCodecs(),n},_setupCodecs:function(){var n=this||t,l=null;try{l=typeof Audio<"u"?new Audio:null}catch{return n}if(!l||typeof l.canPlayType!="function")return n;var d=l.canPlayType("audio/mpeg;").replace(/^no$/,""),g=n._navigator?n._navigator.userAgent:"",v=g.match(/OPR\/(\d+)/g),m=v&&parseInt(v[0].split("/")[1],10)<33,_=g.indexOf("Safari")!==-1&&g.indexOf("Chrome")===-1,y=g.match(/Version\/(.*?) /),w=_&&y&&parseInt(y[1],10)<15;return n._codecs={mp3:!!(!m&&(d||l.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!d,opus:!!l.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(l.canPlayType('audio/wav; codecs="1"')||l.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!l.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!l.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(l.canPlayType("audio/x-m4a;")||l.canPlayType("audio/m4a;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(l.canPlayType("audio/x-m4b;")||l.canPlayType("audio/m4b;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(l.canPlayType("audio/x-mp4;")||l.canPlayType("audio/mp4;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!w&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!w&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!l.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(l.canPlayType("audio/x-flac;")||l.canPlayType("audio/flac;")).replace(/^no$/,"")},n},_unlockAudio:function(){var n=this||t;if(!(n._audioUnlocked||!n.ctx)){n._audioUnlocked=!1,n.autoUnlock=!1,!n._mobileUnloaded&&n.ctx.sampleRate!==44100&&(n._mobileUnloaded=!0,n.unload()),n._scratchBuffer=n.ctx.createBuffer(1,1,22050);var l=function(d){for(;n._html5AudioPool.length<n.html5PoolSize;)try{var g=new Audio;g._unlocked=!0,n._releaseHtml5Audio(g)}catch{n.noAudio=!0;break}for(var v=0;v<n._howls.length;v++)if(!n._howls[v]._webAudio)for(var m=n._howls[v]._getSoundIds(),_=0;_<m.length;_++){var y=n._howls[v]._soundById(m[_]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}n._autoResume();var w=n.ctx.createBufferSource();w.buffer=n._scratchBuffer,w.connect(n.ctx.destination),typeof w.start>"u"?w.noteOn(0):w.start(0),typeof n.ctx.resume=="function"&&n.ctx.resume(),w.onended=function(){w.disconnect(0),n._audioUnlocked=!0,document.removeEventListener("touchstart",l,!0),document.removeEventListener("touchend",l,!0),document.removeEventListener("click",l,!0),document.removeEventListener("keydown",l,!0);for(var x=0;x<n._howls.length;x++)n._howls[x]._emit("unlock")}};return document.addEventListener("touchstart",l,!0),document.addEventListener("touchend",l,!0),document.addEventListener("click",l,!0),document.addEventListener("keydown",l,!0),n}},_obtainHtml5Audio:function(){var n=this||t;if(n._html5AudioPool.length)return n._html5AudioPool.pop();var l=new Audio().play();return l&&typeof Promise<"u"&&(l instanceof Promise||typeof l.then=="function")&&l.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(n){var l=this||t;return n._unlocked&&l._html5AudioPool.push(n),l},_autoSuspend:function(){var n=this;if(!(!n.autoSuspend||!n.ctx||typeof n.ctx.suspend>"u"||!t.usingWebAudio)){for(var l=0;l<n._howls.length;l++)if(n._howls[l]._webAudio){for(var d=0;d<n._howls[l]._sounds.length;d++)if(!n._howls[l]._sounds[d]._paused)return n}return n._suspendTimer&&clearTimeout(n._suspendTimer),n._suspendTimer=setTimeout(function(){if(n.autoSuspend){n._suspendTimer=null,n.state="suspending";var g=function(){n.state="suspended",n._resumeAfterSuspend&&(delete n._resumeAfterSuspend,n._autoResume())};n.ctx.suspend().then(g,g)}},3e4),n}},_autoResume:function(){var n=this;if(!(!n.ctx||typeof n.ctx.resume>"u"||!t.usingWebAudio))return n.state==="running"&&n.ctx.state!=="interrupted"&&n._suspendTimer?(clearTimeout(n._suspendTimer),n._suspendTimer=null):n.state==="suspended"||n.state==="running"&&n.ctx.state==="interrupted"?(n.ctx.resume().then(function(){n.state="running";for(var l=0;l<n._howls.length;l++)n._howls[l]._emit("resume")}),n._suspendTimer&&(clearTimeout(n._suspendTimer),n._suspendTimer=null)):n.state==="suspending"&&(n._resumeAfterSuspend=!0),n}};var t=new e,i=function(n){var l=this;if(!n.src||n.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}l.init(n)};i.prototype={init:function(n){var l=this;return t.ctx||p(),l._autoplay=n.autoplay||!1,l._format=typeof n.format!="string"?n.format:[n.format],l._html5=n.html5||!1,l._muted=n.mute||!1,l._loop=n.loop||!1,l._pool=n.pool||5,l._preload=typeof n.preload=="boolean"||n.preload==="metadata"?n.preload:!0,l._rate=n.rate||1,l._sprite=n.sprite||{},l._src=typeof n.src!="string"?n.src:[n.src],l._volume=n.volume!==void 0?n.volume:1,l._xhr={method:n.xhr&&n.xhr.method?n.xhr.method:"GET",headers:n.xhr&&n.xhr.headers?n.xhr.headers:null,withCredentials:n.xhr&&n.xhr.withCredentials?n.xhr.withCredentials:!1},l._duration=0,l._state="unloaded",l._sounds=[],l._endTimers={},l._queue=[],l._playLock=!1,l._onend=n.onend?[{fn:n.onend}]:[],l._onfade=n.onfade?[{fn:n.onfade}]:[],l._onload=n.onload?[{fn:n.onload}]:[],l._onloaderror=n.onloaderror?[{fn:n.onloaderror}]:[],l._onplayerror=n.onplayerror?[{fn:n.onplayerror}]:[],l._onpause=n.onpause?[{fn:n.onpause}]:[],l._onplay=n.onplay?[{fn:n.onplay}]:[],l._onstop=n.onstop?[{fn:n.onstop}]:[],l._onmute=n.onmute?[{fn:n.onmute}]:[],l._onvolume=n.onvolume?[{fn:n.onvolume}]:[],l._onrate=n.onrate?[{fn:n.onrate}]:[],l._onseek=n.onseek?[{fn:n.onseek}]:[],l._onunlock=n.onunlock?[{fn:n.onunlock}]:[],l._onresume=[],l._webAudio=t.usingWebAudio&&!l._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(l),l._autoplay&&l._queue.push({event:"play",action:function(){l.play()}}),l._preload&&l._preload!=="none"&&l.load(),l},load:function(){var n=this,l=null;if(t.noAudio){n._emit("loaderror",null,"No audio support.");return}typeof n._src=="string"&&(n._src=[n._src]);for(var d=0;d<n._src.length;d++){var g,v;if(n._format&&n._format[d])g=n._format[d];else{if(v=n._src[d],typeof v!="string"){n._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}g=/^data:audio\/([^;,]+);/i.exec(v),g||(g=/\.([^.]+)$/.exec(v.split("?",1)[0])),g&&(g=g[1].toLowerCase())}if(g||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),g&&t.codecs(g)){l=n._src[d];break}}if(!l){n._emit("loaderror",null,"No codec support for selected audio sources.");return}return n._src=l,n._state="loading",window.location.protocol==="https:"&&l.slice(0,5)==="http:"&&(n._html5=!0,n._webAudio=!1),new s(n),n._webAudio&&o(n),n},play:function(n,l){var d=this,g=null;if(typeof n=="number")g=n,n=null;else{if(typeof n=="string"&&d._state==="loaded"&&!d._sprite[n])return null;if(typeof n>"u"&&(n="__default",!d._playLock)){for(var v=0,m=0;m<d._sounds.length;m++)d._sounds[m]._paused&&!d._sounds[m]._ended&&(v++,g=d._sounds[m]._id);v===1?n=null:g=null}}var _=g?d._soundById(g):d._inactiveSound();if(!_)return null;if(g&&!n&&(n=_._sprite||"__default"),d._state!=="loaded"){_._sprite=n,_._ended=!1;var y=_._id;return d._queue.push({event:"play",action:function(){d.play(y)}}),y}if(g&&!_._paused)return l||d._loadQueue("play"),_._id;d._webAudio&&t._autoResume();var w=Math.max(0,_._seek>0?_._seek:d._sprite[n][0]/1e3),x=Math.max(0,(d._sprite[n][0]+d._sprite[n][1])/1e3-w),b=x*1e3/Math.abs(_._rate),T=d._sprite[n][0]/1e3,M=(d._sprite[n][0]+d._sprite[n][1])/1e3;_._sprite=n,_._ended=!1;var L=function(){_._paused=!1,_._seek=w,_._start=T,_._stop=M,_._loop=!!(_._loop||d._sprite[n][2])};if(w>=M){d._ended(_);return}var C=_._node;if(d._webAudio){var I=function(){d._playLock=!1,L(),d._refreshBuffer(_);var P=_._muted||d._muted?0:_._volume;C.gain.setValueAtTime(P,t.ctx.currentTime),_._playStart=t.ctx.currentTime,typeof C.bufferSource.start>"u"?_._loop?C.bufferSource.noteGrainOn(0,w,86400):C.bufferSource.noteGrainOn(0,w,x):_._loop?C.bufferSource.start(0,w,86400):C.bufferSource.start(0,w,x),b!==1/0&&(d._endTimers[_._id]=setTimeout(d._ended.bind(d,_),b)),l||setTimeout(function(){d._emit("play",_._id),d._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?I():(d._playLock=!0,d.once("resume",I),d._clearTimer(_._id))}else{var D=function(){C.currentTime=w,C.muted=_._muted||d._muted||t._muted||C.muted,C.volume=_._volume*t.volume(),C.playbackRate=_._rate;try{var P=C.play();if(P&&typeof Promise<"u"&&(P instanceof Promise||typeof P.then=="function")?(d._playLock=!0,L(),P.then(function(){d._playLock=!1,C._unlocked=!0,l?d._loadQueue():d._emit("play",_._id)}).catch(function(){d._playLock=!1,d._emit("playerror",_._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),_._ended=!0,_._paused=!0})):l||(d._playLock=!1,L(),d._emit("play",_._id)),C.playbackRate=_._rate,C.paused){d._emit("playerror",_._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}n!=="__default"||_._loop?d._endTimers[_._id]=setTimeout(d._ended.bind(d,_),b):(d._endTimers[_._id]=function(){d._ended(_),C.removeEventListener("ended",d._endTimers[_._id],!1)},C.addEventListener("ended",d._endTimers[_._id],!1))}catch(R){d._emit("playerror",_._id,R)}};C.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(C.src=d._src,C.load());var A=window&&window.ejecta||!C.readyState&&t._navigator.isCocoonJS;if(C.readyState>=3||A)D();else{d._playLock=!0,d._state="loading";var S=function(){d._state="loaded",D(),C.removeEventListener(t._canPlayEvent,S,!1)};C.addEventListener(t._canPlayEvent,S,!1),d._clearTimer(_._id)}}return _._id},pause:function(n){var l=this;if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"pause",action:function(){l.pause(n)}}),l;for(var d=l._getSoundIds(n),g=0;g<d.length;g++){l._clearTimer(d[g]);var v=l._soundById(d[g]);if(v&&!v._paused&&(v._seek=l.seek(d[g]),v._rateSeek=0,v._paused=!0,l._stopFade(d[g]),v._node))if(l._webAudio){if(!v._node.bufferSource)continue;typeof v._node.bufferSource.stop>"u"?v._node.bufferSource.noteOff(0):v._node.bufferSource.stop(0),l._cleanBuffer(v._node)}else(!isNaN(v._node.duration)||v._node.duration===1/0)&&v._node.pause();arguments[1]||l._emit("pause",v?v._id:null)}return l},stop:function(n,l){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"stop",action:function(){d.stop(n)}}),d;for(var g=d._getSoundIds(n),v=0;v<g.length;v++){d._clearTimer(g[v]);var m=d._soundById(g[v]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,d._stopFade(g[v]),m._node&&(d._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&d._clearSound(m._node))),l||d._emit("stop",m._id))}return d},mute:function(n,l){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"mute",action:function(){d.mute(n,l)}}),d;if(typeof l>"u")if(typeof n=="boolean")d._muted=n;else return d._muted;for(var g=d._getSoundIds(l),v=0;v<g.length;v++){var m=d._soundById(g[v]);m&&(m._muted=n,m._interval&&d._stopFade(m._id),d._webAudio&&m._node?m._node.gain.setValueAtTime(n?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:n),d._emit("mute",m._id))}return d},volume:function(){var n=this,l=arguments,d,g;if(l.length===0)return n._volume;if(l.length===1||l.length===2&&typeof l[1]>"u"){var v=n._getSoundIds(),m=v.indexOf(l[0]);m>=0?g=parseInt(l[0],10):d=parseFloat(l[0])}else l.length>=2&&(d=parseFloat(l[0]),g=parseInt(l[1],10));var _;if(typeof d<"u"&&d>=0&&d<=1){if(n._state!=="loaded"||n._playLock)return n._queue.push({event:"volume",action:function(){n.volume.apply(n,l)}}),n;typeof g>"u"&&(n._volume=d),g=n._getSoundIds(g);for(var y=0;y<g.length;y++)_=n._soundById(g[y]),_&&(_._volume=d,l[2]||n._stopFade(g[y]),n._webAudio&&_._node&&!_._muted?_._node.gain.setValueAtTime(d,t.ctx.currentTime):_._node&&!_._muted&&(_._node.volume=d*t.volume()),n._emit("volume",_._id))}else return _=g?n._soundById(g):n._sounds[0],_?_._volume:0;return n},fade:function(n,l,d,g){var v=this;if(v._state!=="loaded"||v._playLock)return v._queue.push({event:"fade",action:function(){v.fade(n,l,d,g)}}),v;n=Math.min(Math.max(0,parseFloat(n)),1),l=Math.min(Math.max(0,parseFloat(l)),1),d=parseFloat(d),v.volume(n,g);for(var m=v._getSoundIds(g),_=0;_<m.length;_++){var y=v._soundById(m[_]);if(y){if(g||v._stopFade(m[_]),v._webAudio&&!y._muted){var w=t.ctx.currentTime,x=w+d/1e3;y._volume=n,y._node.gain.setValueAtTime(n,w),y._node.gain.linearRampToValueAtTime(l,x)}v._startFadeInterval(y,n,l,d,m[_],typeof g>"u")}}return v},_startFadeInterval:function(n,l,d,g,v,m){var _=this,y=l,w=d-l,x=Math.abs(w/.01),b=Math.max(4,x>0?g/x:g),T=Date.now();n._fadeTo=d,n._interval=setInterval(function(){var M=(Date.now()-T)/g;T=Date.now(),y+=w*M,y=Math.round(y*100)/100,w<0?y=Math.max(d,y):y=Math.min(d,y),_._webAudio?n._volume=y:_.volume(y,n._id,!0),m&&(_._volume=y),(d<l&&y<=d||d>l&&y>=d)&&(clearInterval(n._interval),n._interval=null,n._fadeTo=null,_.volume(d,n._id),_._emit("fade",n._id))},b)},_stopFade:function(n){var l=this,d=l._soundById(n);return d&&d._interval&&(l._webAudio&&d._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(d._interval),d._interval=null,l.volume(d._fadeTo,n),d._fadeTo=null,l._emit("fade",n)),l},loop:function(){var n=this,l=arguments,d,g,v;if(l.length===0)return n._loop;if(l.length===1)if(typeof l[0]=="boolean")d=l[0],n._loop=d;else return v=n._soundById(parseInt(l[0],10)),v?v._loop:!1;else l.length===2&&(d=l[0],g=parseInt(l[1],10));for(var m=n._getSoundIds(g),_=0;_<m.length;_++)v=n._soundById(m[_]),v&&(v._loop=d,n._webAudio&&v._node&&v._node.bufferSource&&(v._node.bufferSource.loop=d,d&&(v._node.bufferSource.loopStart=v._start||0,v._node.bufferSource.loopEnd=v._stop,n.playing(m[_])&&(n.pause(m[_],!0),n.play(m[_],!0)))));return n},rate:function(){var n=this,l=arguments,d,g;if(l.length===0)g=n._sounds[0]._id;else if(l.length===1){var v=n._getSoundIds(),m=v.indexOf(l[0]);m>=0?g=parseInt(l[0],10):d=parseFloat(l[0])}else l.length===2&&(d=parseFloat(l[0]),g=parseInt(l[1],10));var _;if(typeof d=="number"){if(n._state!=="loaded"||n._playLock)return n._queue.push({event:"rate",action:function(){n.rate.apply(n,l)}}),n;typeof g>"u"&&(n._rate=d),g=n._getSoundIds(g);for(var y=0;y<g.length;y++)if(_=n._soundById(g[y]),_){n.playing(g[y])&&(_._rateSeek=n.seek(g[y]),_._playStart=n._webAudio?t.ctx.currentTime:_._playStart),_._rate=d,n._webAudio&&_._node&&_._node.bufferSource?_._node.bufferSource.playbackRate.setValueAtTime(d,t.ctx.currentTime):_._node&&(_._node.playbackRate=d);var w=n.seek(g[y]),x=(n._sprite[_._sprite][0]+n._sprite[_._sprite][1])/1e3-w,b=x*1e3/Math.abs(_._rate);(n._endTimers[g[y]]||!_._paused)&&(n._clearTimer(g[y]),n._endTimers[g[y]]=setTimeout(n._ended.bind(n,_),b)),n._emit("rate",_._id)}}else return _=n._soundById(g),_?_._rate:n._rate;return n},seek:function(){var n=this,l=arguments,d,g;if(l.length===0)n._sounds.length&&(g=n._sounds[0]._id);else if(l.length===1){var v=n._getSoundIds(),m=v.indexOf(l[0]);m>=0?g=parseInt(l[0],10):n._sounds.length&&(g=n._sounds[0]._id,d=parseFloat(l[0]))}else l.length===2&&(d=parseFloat(l[0]),g=parseInt(l[1],10));if(typeof g>"u")return 0;if(typeof d=="number"&&(n._state!=="loaded"||n._playLock))return n._queue.push({event:"seek",action:function(){n.seek.apply(n,l)}}),n;var _=n._soundById(g);if(_)if(typeof d=="number"&&d>=0){var y=n.playing(g);y&&n.pause(g,!0),_._seek=d,_._ended=!1,n._clearTimer(g),!n._webAudio&&_._node&&!isNaN(_._node.duration)&&(_._node.currentTime=d);var w=function(){y&&n.play(g,!0),n._emit("seek",g)};if(y&&!n._webAudio){var x=function(){n._playLock?setTimeout(x,0):w()};setTimeout(x,0)}else w()}else if(n._webAudio){var b=n.playing(g)?t.ctx.currentTime-_._playStart:0,T=_._rateSeek?_._rateSeek-_._seek:0;return _._seek+(T+b*Math.abs(_._rate))}else return _._node.currentTime;return n},playing:function(n){var l=this;if(typeof n=="number"){var d=l._soundById(n);return d?!d._paused:!1}for(var g=0;g<l._sounds.length;g++)if(!l._sounds[g]._paused)return!0;return!1},duration:function(n){var l=this,d=l._duration,g=l._soundById(n);return g&&(d=l._sprite[g._sprite][1]/1e3),d},state:function(){return this._state},unload:function(){for(var n=this,l=n._sounds,d=0;d<l.length;d++)l[d]._paused||n.stop(l[d]._id),n._webAudio||(n._clearSound(l[d]._node),l[d]._node.removeEventListener("error",l[d]._errorFn,!1),l[d]._node.removeEventListener(t._canPlayEvent,l[d]._loadFn,!1),l[d]._node.removeEventListener("ended",l[d]._endFn,!1),t._releaseHtml5Audio(l[d]._node)),delete l[d]._node,n._clearTimer(l[d]._id);var g=t._howls.indexOf(n);g>=0&&t._howls.splice(g,1);var v=!0;for(d=0;d<t._howls.length;d++)if(t._howls[d]._src===n._src||n._src.indexOf(t._howls[d]._src)>=0){v=!1;break}return r&&v&&delete r[n._src],t.noAudio=!1,n._state="unloaded",n._sounds=[],n=null,null},on:function(n,l,d,g){var v=this,m=v["_on"+n];return typeof l=="function"&&m.push(g?{id:d,fn:l,once:g}:{id:d,fn:l}),v},off:function(n,l,d){var g=this,v=g["_on"+n],m=0;if(typeof l=="number"&&(d=l,l=null),l||d)for(m=0;m<v.length;m++){var _=d===v[m].id;if(l===v[m].fn&&_||!l&&_){v.splice(m,1);break}}else if(n)g["_on"+n]=[];else{var y=Object.keys(g);for(m=0;m<y.length;m++)y[m].indexOf("_on")===0&&Array.isArray(g[y[m]])&&(g[y[m]]=[])}return g},once:function(n,l,d){var g=this;return g.on(n,l,d,1),g},_emit:function(n,l,d){for(var g=this,v=g["_on"+n],m=v.length-1;m>=0;m--)(!v[m].id||v[m].id===l||n==="load")&&(setTimeout((function(_){_.call(this,l,d)}).bind(g,v[m].fn),0),v[m].once&&g.off(n,v[m].fn,v[m].id));return g._loadQueue(n),g},_loadQueue:function(n){var l=this;if(l._queue.length>0){var d=l._queue[0];d.event===n&&(l._queue.shift(),l._loadQueue()),n||d.action()}return l},_ended:function(n){var l=this,d=n._sprite;if(!l._webAudio&&n._node&&!n._node.paused&&!n._node.ended&&n._node.currentTime<n._stop)return setTimeout(l._ended.bind(l,n),100),l;var g=!!(n._loop||l._sprite[d][2]);if(l._emit("end",n._id),!l._webAudio&&g&&l.stop(n._id,!0).play(n._id),l._webAudio&&g){l._emit("play",n._id),n._seek=n._start||0,n._rateSeek=0,n._playStart=t.ctx.currentTime;var v=(n._stop-n._start)*1e3/Math.abs(n._rate);l._endTimers[n._id]=setTimeout(l._ended.bind(l,n),v)}return l._webAudio&&!g&&(n._paused=!0,n._ended=!0,n._seek=n._start||0,n._rateSeek=0,l._clearTimer(n._id),l._cleanBuffer(n._node),t._autoSuspend()),!l._webAudio&&!g&&l.stop(n._id,!0),l},_clearTimer:function(n){var l=this;if(l._endTimers[n]){if(typeof l._endTimers[n]!="function")clearTimeout(l._endTimers[n]);else{var d=l._soundById(n);d&&d._node&&d._node.removeEventListener("ended",l._endTimers[n],!1)}delete l._endTimers[n]}return l},_soundById:function(n){for(var l=this,d=0;d<l._sounds.length;d++)if(n===l._sounds[d]._id)return l._sounds[d];return null},_inactiveSound:function(){var n=this;n._drain();for(var l=0;l<n._sounds.length;l++)if(n._sounds[l]._ended)return n._sounds[l].reset();return new s(n)},_drain:function(){var n=this,l=n._pool,d=0,g=0;if(!(n._sounds.length<l)){for(g=0;g<n._sounds.length;g++)n._sounds[g]._ended&&d++;for(g=n._sounds.length-1;g>=0;g--){if(d<=l)return;n._sounds[g]._ended&&(n._webAudio&&n._sounds[g]._node&&n._sounds[g]._node.disconnect(0),n._sounds.splice(g,1),d--)}}},_getSoundIds:function(n){var l=this;if(typeof n>"u"){for(var d=[],g=0;g<l._sounds.length;g++)d.push(l._sounds[g]._id);return d}else return[n]},_refreshBuffer:function(n){var l=this;return n._node.bufferSource=t.ctx.createBufferSource(),n._node.bufferSource.buffer=r[l._src],n._panner?n._node.bufferSource.connect(n._panner):n._node.bufferSource.connect(n._node),n._node.bufferSource.loop=n._loop,n._loop&&(n._node.bufferSource.loopStart=n._start||0,n._node.bufferSource.loopEnd=n._stop||0),n._node.bufferSource.playbackRate.setValueAtTime(n._rate,t.ctx.currentTime),l},_cleanBuffer:function(n){var l=this,d=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(!n.bufferSource)return l;if(t._scratchBuffer&&n.bufferSource&&(n.bufferSource.onended=null,n.bufferSource.disconnect(0),d))try{n.bufferSource.buffer=t._scratchBuffer}catch{}return n.bufferSource=null,l},_clearSound:function(n){var l=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);l||(n.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var s=function(n){this._parent=n,this.init()};s.prototype={init:function(){var n=this,l=n._parent;return n._muted=l._muted,n._loop=l._loop,n._volume=l._volume,n._rate=l._rate,n._seek=0,n._paused=!0,n._ended=!0,n._sprite="__default",n._id=++t._counter,l._sounds.push(n),n.create(),n},create:function(){var n=this,l=n._parent,d=t._muted||n._muted||n._parent._muted?0:n._volume;return l._webAudio?(n._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),n._node.gain.setValueAtTime(d,t.ctx.currentTime),n._node.paused=!0,n._node.connect(t.masterGain)):t.noAudio||(n._node=t._obtainHtml5Audio(),n._errorFn=n._errorListener.bind(n),n._node.addEventListener("error",n._errorFn,!1),n._loadFn=n._loadListener.bind(n),n._node.addEventListener(t._canPlayEvent,n._loadFn,!1),n._endFn=n._endListener.bind(n),n._node.addEventListener("ended",n._endFn,!1),n._node.src=l._src,n._node.preload=l._preload===!0?"auto":l._preload,n._node.volume=d*t.volume(),n._node.load()),n},reset:function(){var n=this,l=n._parent;return n._muted=l._muted,n._loop=l._loop,n._volume=l._volume,n._rate=l._rate,n._seek=0,n._rateSeek=0,n._paused=!0,n._ended=!0,n._sprite="__default",n._id=++t._counter,n},_errorListener:function(){var n=this;n._parent._emit("loaderror",n._id,n._node.error?n._node.error.code:0),n._node.removeEventListener("error",n._errorFn,!1)},_loadListener:function(){var n=this,l=n._parent;l._duration=Math.ceil(n._node.duration*10)/10,Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue()),n._node.removeEventListener(t._canPlayEvent,n._loadFn,!1)},_endListener:function(){var n=this,l=n._parent;l._duration===1/0&&(l._duration=Math.ceil(n._node.duration*10)/10,l._sprite.__default[1]===1/0&&(l._sprite.__default[1]=l._duration*1e3),l._ended(n)),n._node.removeEventListener("ended",n._endFn,!1)}};var r={},o=function(n){var l=n._src;if(r[l]){n._duration=r[l].duration,u(n);return}if(/^data:[^;]+;base64,/.test(l)){for(var d=atob(l.split(",")[1]),g=new Uint8Array(d.length),v=0;v<d.length;++v)g[v]=d.charCodeAt(v);h(g.buffer,n)}else{var m=new XMLHttpRequest;m.open(n._xhr.method,l,!0),m.withCredentials=n._xhr.withCredentials,m.responseType="arraybuffer",n._xhr.headers&&Object.keys(n._xhr.headers).forEach(function(_){m.setRequestHeader(_,n._xhr.headers[_])}),m.onload=function(){var _=(m.status+"")[0];if(_!=="0"&&_!=="2"&&_!=="3"){n._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}h(m.response,n)},m.onerror=function(){n._webAudio&&(n._html5=!0,n._webAudio=!1,n._sounds=[],delete r[l],n.load())},c(m)}},c=function(n){try{n.send()}catch{n.onerror()}},h=function(n,l){var d=function(){l._emit("loaderror",null,"Decoding audio data failed.")},g=function(v){v&&l._sounds.length>0?(r[l._src]=v,u(l,v)):d()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(n).then(g).catch(d):t.ctx.decodeAudioData(n,g,d)},u=function(n,l){l&&!n._duration&&(n._duration=l.duration),Object.keys(n._sprite).length===0&&(n._sprite={__default:[0,n._duration*1e3]}),n._state!=="loaded"&&(n._state="loaded",n._emit("load"),n._loadQueue())},p=function(){if(t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var n=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),l=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),d=l?parseInt(l[1],10):null;if(n&&d&&d<9){var g=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!g&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};a.Howler=t,a.Howl=i,typeof St<"u"?(St.HowlerGlobal=e,St.Howler=t,St.Howl=i,St.Sound=s):typeof window<"u"&&(window.HowlerGlobal=e,window.Howler=t,window.Howl=i,window.Sound=s)})();/*!
|
|
3696
|
+
*/(function(a){(function(){var e=function(){this.init()};e.prototype={init:function(){var n=this||t;return n._counter=1e3,n._html5AudioPool=[],n.html5PoolSize=10,n._codecs={},n._howls=[],n._muted=!1,n._volume=1,n._canPlayEvent="canplaythrough",n._navigator=typeof window<"u"&&window.navigator?window.navigator:null,n.masterGain=null,n.noAudio=!1,n.usingWebAudio=!0,n.autoSuspend=!0,n.ctx=null,n.autoUnlock=!0,n._setup(),n},volume:function(n){var l=this||t;if(n=parseFloat(n),l.ctx||p(),typeof n<"u"&&n>=0&&n<=1){if(l._volume=n,l._muted)return l;l.usingWebAudio&&l.masterGain.gain.setValueAtTime(n,t.ctx.currentTime);for(var d=0;d<l._howls.length;d++)if(!l._howls[d]._webAudio)for(var g=l._howls[d]._getSoundIds(),v=0;v<g.length;v++){var m=l._howls[d]._soundById(g[v]);m&&m._node&&(m._node.volume=m._volume*n)}return l}return l._volume},mute:function(n){var l=this||t;l.ctx||p(),l._muted=n,l.usingWebAudio&&l.masterGain.gain.setValueAtTime(n?0:l._volume,t.ctx.currentTime);for(var d=0;d<l._howls.length;d++)if(!l._howls[d]._webAudio)for(var g=l._howls[d]._getSoundIds(),v=0;v<g.length;v++){var m=l._howls[d]._soundById(g[v]);m&&m._node&&(m._node.muted=n?!0:m._muted)}return l},stop:function(){for(var n=this||t,l=0;l<n._howls.length;l++)n._howls[l].stop();return n},unload:function(){for(var n=this||t,l=n._howls.length-1;l>=0;l--)n._howls[l].unload();return n.usingWebAudio&&n.ctx&&typeof n.ctx.close<"u"&&(n.ctx.close(),n.ctx=null,p()),n},codecs:function(n){return(this||t)._codecs[n.replace(/^x-/,"")]},_setup:function(){var n=this||t;if(n.state=n.ctx&&n.ctx.state||"suspended",n._autoSuspend(),!n.usingWebAudio)if(typeof Audio<"u")try{var l=new Audio;typeof l.oncanplaythrough>"u"&&(n._canPlayEvent="canplay")}catch{n.noAudio=!0}else n.noAudio=!0;try{var l=new Audio;l.muted&&(n.noAudio=!0)}catch{}return n.noAudio||n._setupCodecs(),n},_setupCodecs:function(){var n=this||t,l=null;try{l=typeof Audio<"u"?new Audio:null}catch{return n}if(!l||typeof l.canPlayType!="function")return n;var d=l.canPlayType("audio/mpeg;").replace(/^no$/,""),g=n._navigator?n._navigator.userAgent:"",v=g.match(/OPR\/(\d+)/g),m=v&&parseInt(v[0].split("/")[1],10)<33,_=g.indexOf("Safari")!==-1&&g.indexOf("Chrome")===-1,y=g.match(/Version\/(.*?) /),w=_&&y&&parseInt(y[1],10)<15;return n._codecs={mp3:!!(!m&&(d||l.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!d,opus:!!l.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!l.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(l.canPlayType('audio/wav; codecs="1"')||l.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!l.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!l.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(l.canPlayType("audio/x-m4a;")||l.canPlayType("audio/m4a;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(l.canPlayType("audio/x-m4b;")||l.canPlayType("audio/m4b;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(l.canPlayType("audio/x-mp4;")||l.canPlayType("audio/mp4;")||l.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!w&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!w&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!l.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(l.canPlayType("audio/x-flac;")||l.canPlayType("audio/flac;")).replace(/^no$/,"")},n},_unlockAudio:function(){var n=this||t;if(!(n._audioUnlocked||!n.ctx)){n._audioUnlocked=!1,n.autoUnlock=!1,!n._mobileUnloaded&&n.ctx.sampleRate!==44100&&(n._mobileUnloaded=!0,n.unload()),n._scratchBuffer=n.ctx.createBuffer(1,1,22050);var l=function(d){for(;n._html5AudioPool.length<n.html5PoolSize;)try{var g=new Audio;g._unlocked=!0,n._releaseHtml5Audio(g)}catch{n.noAudio=!0;break}for(var v=0;v<n._howls.length;v++)if(!n._howls[v]._webAudio)for(var m=n._howls[v]._getSoundIds(),_=0;_<m.length;_++){var y=n._howls[v]._soundById(m[_]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}n._autoResume();var w=n.ctx.createBufferSource();w.buffer=n._scratchBuffer,w.connect(n.ctx.destination),typeof w.start>"u"?w.noteOn(0):w.start(0),typeof n.ctx.resume=="function"&&n.ctx.resume(),w.onended=function(){w.disconnect(0),n._audioUnlocked=!0,document.removeEventListener("touchstart",l,!0),document.removeEventListener("touchend",l,!0),document.removeEventListener("click",l,!0),document.removeEventListener("keydown",l,!0);for(var x=0;x<n._howls.length;x++)n._howls[x]._emit("unlock")}};return document.addEventListener("touchstart",l,!0),document.addEventListener("touchend",l,!0),document.addEventListener("click",l,!0),document.addEventListener("keydown",l,!0),n}},_obtainHtml5Audio:function(){var n=this||t;if(n._html5AudioPool.length)return n._html5AudioPool.pop();var l=new Audio().play();return l&&typeof Promise<"u"&&(l instanceof Promise||typeof l.then=="function")&&l.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(n){var l=this||t;return n._unlocked&&l._html5AudioPool.push(n),l},_autoSuspend:function(){var n=this;if(!(!n.autoSuspend||!n.ctx||typeof n.ctx.suspend>"u"||!t.usingWebAudio)){for(var l=0;l<n._howls.length;l++)if(n._howls[l]._webAudio){for(var d=0;d<n._howls[l]._sounds.length;d++)if(!n._howls[l]._sounds[d]._paused)return n}return n._suspendTimer&&clearTimeout(n._suspendTimer),n._suspendTimer=setTimeout(function(){if(n.autoSuspend){n._suspendTimer=null,n.state="suspending";var g=function(){n.state="suspended",n._resumeAfterSuspend&&(delete n._resumeAfterSuspend,n._autoResume())};n.ctx.suspend().then(g,g)}},3e4),n}},_autoResume:function(){var n=this;if(!(!n.ctx||typeof n.ctx.resume>"u"||!t.usingWebAudio))return n.state==="running"&&n.ctx.state!=="interrupted"&&n._suspendTimer?(clearTimeout(n._suspendTimer),n._suspendTimer=null):n.state==="suspended"||n.state==="running"&&n.ctx.state==="interrupted"?(n.ctx.resume().then(function(){n.state="running";for(var l=0;l<n._howls.length;l++)n._howls[l]._emit("resume")}),n._suspendTimer&&(clearTimeout(n._suspendTimer),n._suspendTimer=null)):n.state==="suspending"&&(n._resumeAfterSuspend=!0),n}};var t=new e,i=function(n){var l=this;if(!n.src||n.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}l.init(n)};i.prototype={init:function(n){var l=this;return t.ctx||p(),l._autoplay=n.autoplay||!1,l._format=typeof n.format!="string"?n.format:[n.format],l._html5=n.html5||!1,l._muted=n.mute||!1,l._loop=n.loop||!1,l._pool=n.pool||5,l._preload=typeof n.preload=="boolean"||n.preload==="metadata"?n.preload:!0,l._rate=n.rate||1,l._sprite=n.sprite||{},l._src=typeof n.src!="string"?n.src:[n.src],l._volume=n.volume!==void 0?n.volume:1,l._xhr={method:n.xhr&&n.xhr.method?n.xhr.method:"GET",headers:n.xhr&&n.xhr.headers?n.xhr.headers:null,withCredentials:n.xhr&&n.xhr.withCredentials?n.xhr.withCredentials:!1},l._duration=0,l._state="unloaded",l._sounds=[],l._endTimers={},l._queue=[],l._playLock=!1,l._onend=n.onend?[{fn:n.onend}]:[],l._onfade=n.onfade?[{fn:n.onfade}]:[],l._onload=n.onload?[{fn:n.onload}]:[],l._onloaderror=n.onloaderror?[{fn:n.onloaderror}]:[],l._onplayerror=n.onplayerror?[{fn:n.onplayerror}]:[],l._onpause=n.onpause?[{fn:n.onpause}]:[],l._onplay=n.onplay?[{fn:n.onplay}]:[],l._onstop=n.onstop?[{fn:n.onstop}]:[],l._onmute=n.onmute?[{fn:n.onmute}]:[],l._onvolume=n.onvolume?[{fn:n.onvolume}]:[],l._onrate=n.onrate?[{fn:n.onrate}]:[],l._onseek=n.onseek?[{fn:n.onseek}]:[],l._onunlock=n.onunlock?[{fn:n.onunlock}]:[],l._onresume=[],l._webAudio=t.usingWebAudio&&!l._html5,typeof t.ctx<"u"&&t.ctx&&t.autoUnlock&&t._unlockAudio(),t._howls.push(l),l._autoplay&&l._queue.push({event:"play",action:function(){l.play()}}),l._preload&&l._preload!=="none"&&l.load(),l},load:function(){var n=this,l=null;if(t.noAudio){n._emit("loaderror",null,"No audio support.");return}typeof n._src=="string"&&(n._src=[n._src]);for(var d=0;d<n._src.length;d++){var g,v;if(n._format&&n._format[d])g=n._format[d];else{if(v=n._src[d],typeof v!="string"){n._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}g=/^data:audio\/([^;,]+);/i.exec(v),g||(g=/\.([^.]+)$/.exec(v.split("?",1)[0])),g&&(g=g[1].toLowerCase())}if(g||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),g&&t.codecs(g)){l=n._src[d];break}}if(!l){n._emit("loaderror",null,"No codec support for selected audio sources.");return}return n._src=l,n._state="loading",window.location.protocol==="https:"&&l.slice(0,5)==="http:"&&(n._html5=!0,n._webAudio=!1),new s(n),n._webAudio&&o(n),n},play:function(n,l){var d=this,g=null;if(typeof n=="number")g=n,n=null;else{if(typeof n=="string"&&d._state==="loaded"&&!d._sprite[n])return null;if(typeof n>"u"&&(n="__default",!d._playLock)){for(var v=0,m=0;m<d._sounds.length;m++)d._sounds[m]._paused&&!d._sounds[m]._ended&&(v++,g=d._sounds[m]._id);v===1?n=null:g=null}}var _=g?d._soundById(g):d._inactiveSound();if(!_)return null;if(g&&!n&&(n=_._sprite||"__default"),d._state!=="loaded"){_._sprite=n,_._ended=!1;var y=_._id;return d._queue.push({event:"play",action:function(){d.play(y)}}),y}if(g&&!_._paused)return l||d._loadQueue("play"),_._id;d._webAudio&&t._autoResume();var w=Math.max(0,_._seek>0?_._seek:d._sprite[n][0]/1e3),x=Math.max(0,(d._sprite[n][0]+d._sprite[n][1])/1e3-w),b=x*1e3/Math.abs(_._rate),T=d._sprite[n][0]/1e3,M=(d._sprite[n][0]+d._sprite[n][1])/1e3;_._sprite=n,_._ended=!1;var P=function(){_._paused=!1,_._seek=w,_._start=T,_._stop=M,_._loop=!!(_._loop||d._sprite[n][2])};if(w>=M){d._ended(_);return}var C=_._node;if(d._webAudio){var I=function(){d._playLock=!1,P(),d._refreshBuffer(_);var L=_._muted||d._muted?0:_._volume;C.gain.setValueAtTime(L,t.ctx.currentTime),_._playStart=t.ctx.currentTime,typeof C.bufferSource.start>"u"?_._loop?C.bufferSource.noteGrainOn(0,w,86400):C.bufferSource.noteGrainOn(0,w,x):_._loop?C.bufferSource.start(0,w,86400):C.bufferSource.start(0,w,x),b!==1/0&&(d._endTimers[_._id]=setTimeout(d._ended.bind(d,_),b)),l||setTimeout(function(){d._emit("play",_._id),d._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?I():(d._playLock=!0,d.once("resume",I),d._clearTimer(_._id))}else{var D=function(){C.currentTime=w,C.muted=_._muted||d._muted||t._muted||C.muted,C.volume=_._volume*t.volume(),C.playbackRate=_._rate;try{var L=C.play();if(L&&typeof Promise<"u"&&(L instanceof Promise||typeof L.then=="function")?(d._playLock=!0,P(),L.then(function(){d._playLock=!1,C._unlocked=!0,l?d._loadQueue():d._emit("play",_._id)}).catch(function(){d._playLock=!1,d._emit("playerror",_._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),_._ended=!0,_._paused=!0})):l||(d._playLock=!1,P(),d._emit("play",_._id)),C.playbackRate=_._rate,C.paused){d._emit("playerror",_._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}n!=="__default"||_._loop?d._endTimers[_._id]=setTimeout(d._ended.bind(d,_),b):(d._endTimers[_._id]=function(){d._ended(_),C.removeEventListener("ended",d._endTimers[_._id],!1)},C.addEventListener("ended",d._endTimers[_._id],!1))}catch(R){d._emit("playerror",_._id,R)}};C.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(C.src=d._src,C.load());var A=window&&window.ejecta||!C.readyState&&t._navigator.isCocoonJS;if(C.readyState>=3||A)D();else{d._playLock=!0,d._state="loading";var S=function(){d._state="loaded",D(),C.removeEventListener(t._canPlayEvent,S,!1)};C.addEventListener(t._canPlayEvent,S,!1),d._clearTimer(_._id)}}return _._id},pause:function(n){var l=this;if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"pause",action:function(){l.pause(n)}}),l;for(var d=l._getSoundIds(n),g=0;g<d.length;g++){l._clearTimer(d[g]);var v=l._soundById(d[g]);if(v&&!v._paused&&(v._seek=l.seek(d[g]),v._rateSeek=0,v._paused=!0,l._stopFade(d[g]),v._node))if(l._webAudio){if(!v._node.bufferSource)continue;typeof v._node.bufferSource.stop>"u"?v._node.bufferSource.noteOff(0):v._node.bufferSource.stop(0),l._cleanBuffer(v._node)}else(!isNaN(v._node.duration)||v._node.duration===1/0)&&v._node.pause();arguments[1]||l._emit("pause",v?v._id:null)}return l},stop:function(n,l){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"stop",action:function(){d.stop(n)}}),d;for(var g=d._getSoundIds(n),v=0;v<g.length;v++){d._clearTimer(g[v]);var m=d._soundById(g[v]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,d._stopFade(g[v]),m._node&&(d._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)):(!isNaN(m._node.duration)||m._node.duration===1/0)&&(m._node.currentTime=m._start||0,m._node.pause(),m._node.duration===1/0&&d._clearSound(m._node))),l||d._emit("stop",m._id))}return d},mute:function(n,l){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"mute",action:function(){d.mute(n,l)}}),d;if(typeof l>"u")if(typeof n=="boolean")d._muted=n;else return d._muted;for(var g=d._getSoundIds(l),v=0;v<g.length;v++){var m=d._soundById(g[v]);m&&(m._muted=n,m._interval&&d._stopFade(m._id),d._webAudio&&m._node?m._node.gain.setValueAtTime(n?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:n),d._emit("mute",m._id))}return d},volume:function(){var n=this,l=arguments,d,g;if(l.length===0)return n._volume;if(l.length===1||l.length===2&&typeof l[1]>"u"){var v=n._getSoundIds(),m=v.indexOf(l[0]);m>=0?g=parseInt(l[0],10):d=parseFloat(l[0])}else l.length>=2&&(d=parseFloat(l[0]),g=parseInt(l[1],10));var _;if(typeof d<"u"&&d>=0&&d<=1){if(n._state!=="loaded"||n._playLock)return n._queue.push({event:"volume",action:function(){n.volume.apply(n,l)}}),n;typeof g>"u"&&(n._volume=d),g=n._getSoundIds(g);for(var y=0;y<g.length;y++)_=n._soundById(g[y]),_&&(_._volume=d,l[2]||n._stopFade(g[y]),n._webAudio&&_._node&&!_._muted?_._node.gain.setValueAtTime(d,t.ctx.currentTime):_._node&&!_._muted&&(_._node.volume=d*t.volume()),n._emit("volume",_._id))}else return _=g?n._soundById(g):n._sounds[0],_?_._volume:0;return n},fade:function(n,l,d,g){var v=this;if(v._state!=="loaded"||v._playLock)return v._queue.push({event:"fade",action:function(){v.fade(n,l,d,g)}}),v;n=Math.min(Math.max(0,parseFloat(n)),1),l=Math.min(Math.max(0,parseFloat(l)),1),d=parseFloat(d),v.volume(n,g);for(var m=v._getSoundIds(g),_=0;_<m.length;_++){var y=v._soundById(m[_]);if(y){if(g||v._stopFade(m[_]),v._webAudio&&!y._muted){var w=t.ctx.currentTime,x=w+d/1e3;y._volume=n,y._node.gain.setValueAtTime(n,w),y._node.gain.linearRampToValueAtTime(l,x)}v._startFadeInterval(y,n,l,d,m[_],typeof g>"u")}}return v},_startFadeInterval:function(n,l,d,g,v,m){var _=this,y=l,w=d-l,x=Math.abs(w/.01),b=Math.max(4,x>0?g/x:g),T=Date.now();n._fadeTo=d,n._interval=setInterval(function(){var M=(Date.now()-T)/g;T=Date.now(),y+=w*M,y=Math.round(y*100)/100,w<0?y=Math.max(d,y):y=Math.min(d,y),_._webAudio?n._volume=y:_.volume(y,n._id,!0),m&&(_._volume=y),(d<l&&y<=d||d>l&&y>=d)&&(clearInterval(n._interval),n._interval=null,n._fadeTo=null,_.volume(d,n._id),_._emit("fade",n._id))},b)},_stopFade:function(n){var l=this,d=l._soundById(n);return d&&d._interval&&(l._webAudio&&d._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(d._interval),d._interval=null,l.volume(d._fadeTo,n),d._fadeTo=null,l._emit("fade",n)),l},loop:function(){var n=this,l=arguments,d,g,v;if(l.length===0)return n._loop;if(l.length===1)if(typeof l[0]=="boolean")d=l[0],n._loop=d;else return v=n._soundById(parseInt(l[0],10)),v?v._loop:!1;else l.length===2&&(d=l[0],g=parseInt(l[1],10));for(var m=n._getSoundIds(g),_=0;_<m.length;_++)v=n._soundById(m[_]),v&&(v._loop=d,n._webAudio&&v._node&&v._node.bufferSource&&(v._node.bufferSource.loop=d,d&&(v._node.bufferSource.loopStart=v._start||0,v._node.bufferSource.loopEnd=v._stop,n.playing(m[_])&&(n.pause(m[_],!0),n.play(m[_],!0)))));return n},rate:function(){var n=this,l=arguments,d,g;if(l.length===0)g=n._sounds[0]._id;else if(l.length===1){var v=n._getSoundIds(),m=v.indexOf(l[0]);m>=0?g=parseInt(l[0],10):d=parseFloat(l[0])}else l.length===2&&(d=parseFloat(l[0]),g=parseInt(l[1],10));var _;if(typeof d=="number"){if(n._state!=="loaded"||n._playLock)return n._queue.push({event:"rate",action:function(){n.rate.apply(n,l)}}),n;typeof g>"u"&&(n._rate=d),g=n._getSoundIds(g);for(var y=0;y<g.length;y++)if(_=n._soundById(g[y]),_){n.playing(g[y])&&(_._rateSeek=n.seek(g[y]),_._playStart=n._webAudio?t.ctx.currentTime:_._playStart),_._rate=d,n._webAudio&&_._node&&_._node.bufferSource?_._node.bufferSource.playbackRate.setValueAtTime(d,t.ctx.currentTime):_._node&&(_._node.playbackRate=d);var w=n.seek(g[y]),x=(n._sprite[_._sprite][0]+n._sprite[_._sprite][1])/1e3-w,b=x*1e3/Math.abs(_._rate);(n._endTimers[g[y]]||!_._paused)&&(n._clearTimer(g[y]),n._endTimers[g[y]]=setTimeout(n._ended.bind(n,_),b)),n._emit("rate",_._id)}}else return _=n._soundById(g),_?_._rate:n._rate;return n},seek:function(){var n=this,l=arguments,d,g;if(l.length===0)n._sounds.length&&(g=n._sounds[0]._id);else if(l.length===1){var v=n._getSoundIds(),m=v.indexOf(l[0]);m>=0?g=parseInt(l[0],10):n._sounds.length&&(g=n._sounds[0]._id,d=parseFloat(l[0]))}else l.length===2&&(d=parseFloat(l[0]),g=parseInt(l[1],10));if(typeof g>"u")return 0;if(typeof d=="number"&&(n._state!=="loaded"||n._playLock))return n._queue.push({event:"seek",action:function(){n.seek.apply(n,l)}}),n;var _=n._soundById(g);if(_)if(typeof d=="number"&&d>=0){var y=n.playing(g);y&&n.pause(g,!0),_._seek=d,_._ended=!1,n._clearTimer(g),!n._webAudio&&_._node&&!isNaN(_._node.duration)&&(_._node.currentTime=d);var w=function(){y&&n.play(g,!0),n._emit("seek",g)};if(y&&!n._webAudio){var x=function(){n._playLock?setTimeout(x,0):w()};setTimeout(x,0)}else w()}else if(n._webAudio){var b=n.playing(g)?t.ctx.currentTime-_._playStart:0,T=_._rateSeek?_._rateSeek-_._seek:0;return _._seek+(T+b*Math.abs(_._rate))}else return _._node.currentTime;return n},playing:function(n){var l=this;if(typeof n=="number"){var d=l._soundById(n);return d?!d._paused:!1}for(var g=0;g<l._sounds.length;g++)if(!l._sounds[g]._paused)return!0;return!1},duration:function(n){var l=this,d=l._duration,g=l._soundById(n);return g&&(d=l._sprite[g._sprite][1]/1e3),d},state:function(){return this._state},unload:function(){for(var n=this,l=n._sounds,d=0;d<l.length;d++)l[d]._paused||n.stop(l[d]._id),n._webAudio||(n._clearSound(l[d]._node),l[d]._node.removeEventListener("error",l[d]._errorFn,!1),l[d]._node.removeEventListener(t._canPlayEvent,l[d]._loadFn,!1),l[d]._node.removeEventListener("ended",l[d]._endFn,!1),t._releaseHtml5Audio(l[d]._node)),delete l[d]._node,n._clearTimer(l[d]._id);var g=t._howls.indexOf(n);g>=0&&t._howls.splice(g,1);var v=!0;for(d=0;d<t._howls.length;d++)if(t._howls[d]._src===n._src||n._src.indexOf(t._howls[d]._src)>=0){v=!1;break}return r&&v&&delete r[n._src],t.noAudio=!1,n._state="unloaded",n._sounds=[],n=null,null},on:function(n,l,d,g){var v=this,m=v["_on"+n];return typeof l=="function"&&m.push(g?{id:d,fn:l,once:g}:{id:d,fn:l}),v},off:function(n,l,d){var g=this,v=g["_on"+n],m=0;if(typeof l=="number"&&(d=l,l=null),l||d)for(m=0;m<v.length;m++){var _=d===v[m].id;if(l===v[m].fn&&_||!l&&_){v.splice(m,1);break}}else if(n)g["_on"+n]=[];else{var y=Object.keys(g);for(m=0;m<y.length;m++)y[m].indexOf("_on")===0&&Array.isArray(g[y[m]])&&(g[y[m]]=[])}return g},once:function(n,l,d){var g=this;return g.on(n,l,d,1),g},_emit:function(n,l,d){for(var g=this,v=g["_on"+n],m=v.length-1;m>=0;m--)(!v[m].id||v[m].id===l||n==="load")&&(setTimeout((function(_){_.call(this,l,d)}).bind(g,v[m].fn),0),v[m].once&&g.off(n,v[m].fn,v[m].id));return g._loadQueue(n),g},_loadQueue:function(n){var l=this;if(l._queue.length>0){var d=l._queue[0];d.event===n&&(l._queue.shift(),l._loadQueue()),n||d.action()}return l},_ended:function(n){var l=this,d=n._sprite;if(!l._webAudio&&n._node&&!n._node.paused&&!n._node.ended&&n._node.currentTime<n._stop)return setTimeout(l._ended.bind(l,n),100),l;var g=!!(n._loop||l._sprite[d][2]);if(l._emit("end",n._id),!l._webAudio&&g&&l.stop(n._id,!0).play(n._id),l._webAudio&&g){l._emit("play",n._id),n._seek=n._start||0,n._rateSeek=0,n._playStart=t.ctx.currentTime;var v=(n._stop-n._start)*1e3/Math.abs(n._rate);l._endTimers[n._id]=setTimeout(l._ended.bind(l,n),v)}return l._webAudio&&!g&&(n._paused=!0,n._ended=!0,n._seek=n._start||0,n._rateSeek=0,l._clearTimer(n._id),l._cleanBuffer(n._node),t._autoSuspend()),!l._webAudio&&!g&&l.stop(n._id,!0),l},_clearTimer:function(n){var l=this;if(l._endTimers[n]){if(typeof l._endTimers[n]!="function")clearTimeout(l._endTimers[n]);else{var d=l._soundById(n);d&&d._node&&d._node.removeEventListener("ended",l._endTimers[n],!1)}delete l._endTimers[n]}return l},_soundById:function(n){for(var l=this,d=0;d<l._sounds.length;d++)if(n===l._sounds[d]._id)return l._sounds[d];return null},_inactiveSound:function(){var n=this;n._drain();for(var l=0;l<n._sounds.length;l++)if(n._sounds[l]._ended)return n._sounds[l].reset();return new s(n)},_drain:function(){var n=this,l=n._pool,d=0,g=0;if(!(n._sounds.length<l)){for(g=0;g<n._sounds.length;g++)n._sounds[g]._ended&&d++;for(g=n._sounds.length-1;g>=0;g--){if(d<=l)return;n._sounds[g]._ended&&(n._webAudio&&n._sounds[g]._node&&n._sounds[g]._node.disconnect(0),n._sounds.splice(g,1),d--)}}},_getSoundIds:function(n){var l=this;if(typeof n>"u"){for(var d=[],g=0;g<l._sounds.length;g++)d.push(l._sounds[g]._id);return d}else return[n]},_refreshBuffer:function(n){var l=this;return n._node.bufferSource=t.ctx.createBufferSource(),n._node.bufferSource.buffer=r[l._src],n._panner?n._node.bufferSource.connect(n._panner):n._node.bufferSource.connect(n._node),n._node.bufferSource.loop=n._loop,n._loop&&(n._node.bufferSource.loopStart=n._start||0,n._node.bufferSource.loopEnd=n._stop||0),n._node.bufferSource.playbackRate.setValueAtTime(n._rate,t.ctx.currentTime),l},_cleanBuffer:function(n){var l=this,d=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(!n.bufferSource)return l;if(t._scratchBuffer&&n.bufferSource&&(n.bufferSource.onended=null,n.bufferSource.disconnect(0),d))try{n.bufferSource.buffer=t._scratchBuffer}catch{}return n.bufferSource=null,l},_clearSound:function(n){var l=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);l||(n.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var s=function(n){this._parent=n,this.init()};s.prototype={init:function(){var n=this,l=n._parent;return n._muted=l._muted,n._loop=l._loop,n._volume=l._volume,n._rate=l._rate,n._seek=0,n._paused=!0,n._ended=!0,n._sprite="__default",n._id=++t._counter,l._sounds.push(n),n.create(),n},create:function(){var n=this,l=n._parent,d=t._muted||n._muted||n._parent._muted?0:n._volume;return l._webAudio?(n._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),n._node.gain.setValueAtTime(d,t.ctx.currentTime),n._node.paused=!0,n._node.connect(t.masterGain)):t.noAudio||(n._node=t._obtainHtml5Audio(),n._errorFn=n._errorListener.bind(n),n._node.addEventListener("error",n._errorFn,!1),n._loadFn=n._loadListener.bind(n),n._node.addEventListener(t._canPlayEvent,n._loadFn,!1),n._endFn=n._endListener.bind(n),n._node.addEventListener("ended",n._endFn,!1),n._node.src=l._src,n._node.preload=l._preload===!0?"auto":l._preload,n._node.volume=d*t.volume(),n._node.load()),n},reset:function(){var n=this,l=n._parent;return n._muted=l._muted,n._loop=l._loop,n._volume=l._volume,n._rate=l._rate,n._seek=0,n._rateSeek=0,n._paused=!0,n._ended=!0,n._sprite="__default",n._id=++t._counter,n},_errorListener:function(){var n=this;n._parent._emit("loaderror",n._id,n._node.error?n._node.error.code:0),n._node.removeEventListener("error",n._errorFn,!1)},_loadListener:function(){var n=this,l=n._parent;l._duration=Math.ceil(n._node.duration*10)/10,Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue()),n._node.removeEventListener(t._canPlayEvent,n._loadFn,!1)},_endListener:function(){var n=this,l=n._parent;l._duration===1/0&&(l._duration=Math.ceil(n._node.duration*10)/10,l._sprite.__default[1]===1/0&&(l._sprite.__default[1]=l._duration*1e3),l._ended(n)),n._node.removeEventListener("ended",n._endFn,!1)}};var r={},o=function(n){var l=n._src;if(r[l]){n._duration=r[l].duration,u(n);return}if(/^data:[^;]+;base64,/.test(l)){for(var d=atob(l.split(",")[1]),g=new Uint8Array(d.length),v=0;v<d.length;++v)g[v]=d.charCodeAt(v);h(g.buffer,n)}else{var m=new XMLHttpRequest;m.open(n._xhr.method,l,!0),m.withCredentials=n._xhr.withCredentials,m.responseType="arraybuffer",n._xhr.headers&&Object.keys(n._xhr.headers).forEach(function(_){m.setRequestHeader(_,n._xhr.headers[_])}),m.onload=function(){var _=(m.status+"")[0];if(_!=="0"&&_!=="2"&&_!=="3"){n._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}h(m.response,n)},m.onerror=function(){n._webAudio&&(n._html5=!0,n._webAudio=!1,n._sounds=[],delete r[l],n.load())},c(m)}},c=function(n){try{n.send()}catch{n.onerror()}},h=function(n,l){var d=function(){l._emit("loaderror",null,"Decoding audio data failed.")},g=function(v){v&&l._sounds.length>0?(r[l._src]=v,u(l,v)):d()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(n).then(g).catch(d):t.ctx.decodeAudioData(n,g,d)},u=function(n,l){l&&!n._duration&&(n._duration=l.duration),Object.keys(n._sprite).length===0&&(n._sprite={__default:[0,n._duration*1e3]}),n._state!=="loaded"&&(n._state="loaded",n._emit("load"),n._loadQueue())},p=function(){if(t.usingWebAudio){try{typeof AudioContext<"u"?t.ctx=new AudioContext:typeof webkitAudioContext<"u"?t.ctx=new webkitAudioContext:t.usingWebAudio=!1}catch{t.usingWebAudio=!1}t.ctx||(t.usingWebAudio=!1);var n=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),l=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),d=l?parseInt(l[1],10):null;if(n&&d&&d<9){var g=/safari/.test(t._navigator&&t._navigator.userAgent.toLowerCase());t._navigator&&!g&&(t.usingWebAudio=!1)}t.usingWebAudio&&(t.masterGain=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),t.masterGain.gain.setValueAtTime(t._muted?0:t._volume,t.ctx.currentTime),t.masterGain.connect(t.ctx.destination)),t._setup()}};a.Howler=t,a.Howl=i,typeof St<"u"?(St.HowlerGlobal=e,St.Howler=t,St.Howl=i,St.Sound=s):typeof window<"u"&&(window.HowlerGlobal=e,window.Howler=t,window.Howl=i,window.Sound=s)})();/*!
|
|
3697
3697
|
* Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
|
|
3698
3698
|
*
|
|
3699
3699
|
* howler.js v2.2.4
|
|
@@ -3703,7 +3703,7 @@ ${t.name}`)}break}}}}else r.texture_lod=0}};ae=new WeakMap,Me=new WeakMap,Ai=new
|
|
|
3703
3703
|
* goldfirestudios.com
|
|
3704
3704
|
*
|
|
3705
3705
|
* MIT License
|
|
3706
|
-
*/(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var i=this;if(!i.ctx||!i.ctx.listener)return i;for(var s=i._howls.length-1;s>=0;s--)i._howls[s].stereo(t);return i},HowlerGlobal.prototype.pos=function(t,i,s){var r=this;if(!r.ctx||!r.ctx.listener)return r;if(i=typeof i!="number"?r._pos[1]:i,s=typeof s!="number"?r._pos[2]:s,typeof t=="number")r._pos=[t,i,s],typeof r.ctx.listener.positionX<"u"?(r.ctx.listener.positionX.setTargetAtTime(r._pos[0],Howler.ctx.currentTime,.1),r.ctx.listener.positionY.setTargetAtTime(r._pos[1],Howler.ctx.currentTime,.1),r.ctx.listener.positionZ.setTargetAtTime(r._pos[2],Howler.ctx.currentTime,.1)):r.ctx.listener.setPosition(r._pos[0],r._pos[1],r._pos[2]);else return r._pos;return r},HowlerGlobal.prototype.orientation=function(t,i,s,r,o,c){var h=this;if(!h.ctx||!h.ctx.listener)return h;var u=h._orientation;if(i=typeof i!="number"?u[1]:i,s=typeof s!="number"?u[2]:s,r=typeof r!="number"?u[3]:r,o=typeof o!="number"?u[4]:o,c=typeof c!="number"?u[5]:c,typeof t=="number")h._orientation=[t,i,s,r,o,c],typeof h.ctx.listener.forwardX<"u"?(h.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),h.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),h.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),h.ctx.listener.upX.setTargetAtTime(r,Howler.ctx.currentTime,.1),h.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),h.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):h.ctx.listener.setOrientation(t,i,s,r,o,c);else return u;return h},Howl.prototype.init=function(t){return function(i){var s=this;return s._orientation=i.orientation||[1,0,0],s._stereo=i.stereo||null,s._pos=i.pos||null,s._pannerAttr={coneInnerAngle:typeof i.coneInnerAngle<"u"?i.coneInnerAngle:360,coneOuterAngle:typeof i.coneOuterAngle<"u"?i.coneOuterAngle:360,coneOuterGain:typeof i.coneOuterGain<"u"?i.coneOuterGain:0,distanceModel:typeof i.distanceModel<"u"?i.distanceModel:"inverse",maxDistance:typeof i.maxDistance<"u"?i.maxDistance:1e4,panningModel:typeof i.panningModel<"u"?i.panningModel:"HRTF",refDistance:typeof i.refDistance<"u"?i.refDistance:1,rolloffFactor:typeof i.rolloffFactor<"u"?i.rolloffFactor:1},s._onstereo=i.onstereo?[{fn:i.onstereo}]:[],s._onpos=i.onpos?[{fn:i.onpos}]:[],s._onorientation=i.onorientation?[{fn:i.onorientation}]:[],t.call(this,i)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"stereo",action:function(){s.stereo(t,i)}}),s;var r=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof i>"u")if(typeof t=="number")s._stereo=t,s._pos=[t,0,0];else return s._stereo;for(var o=s._getSoundIds(i),c=0;c<o.length;c++){var h=s._soundById(o[c]);if(h)if(typeof t=="number")h._stereo=t,h._pos=[t,0,0],h._node&&(h._pannerAttr.panningModel="equalpower",(!h._panner||!h._panner.pan)&&e(h,r),r==="spatial"?typeof h._panner.positionX<"u"?(h._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),h._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),h._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):h._panner.setPosition(t,0,0):h._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",h._id);else return h._stereo}return s},Howl.prototype.pos=function(t,i,s,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"pos",action:function(){o.pos(t,i,s,r)}}),o;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof r>"u")if(typeof t=="number")o._pos=[t,i,s];else return o._pos;for(var c=o._getSoundIds(r),h=0;h<c.length;h++){var u=o._soundById(c[h]);if(u)if(typeof t=="number")u._pos=[t,i,s],u._node&&((!u._panner||u._panner.pan)&&e(u,"spatial"),typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):u._panner.setPosition(t,i,s)),o._emit("pos",u._id);else return u._pos}return o},Howl.prototype.orientation=function(t,i,s,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"orientation",action:function(){o.orientation(t,i,s,r)}}),o;if(i=typeof i!="number"?o._orientation[1]:i,s=typeof s!="number"?o._orientation[2]:s,typeof r>"u")if(typeof t=="number")o._orientation=[t,i,s];else return o._orientation;for(var c=o._getSoundIds(r),h=0;h<c.length;h++){var u=o._soundById(c[h]);if(u)if(typeof t=="number")u._orientation=[t,i,s],u._node&&(u._panner||(u._pos||(u._pos=o._pos||[0,0,-.5]),e(u,"spatial")),typeof u._panner.orientationX<"u"?(u._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),u._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):u._panner.setOrientation(t,i,s)),o._emit("orientation",u._id);else return u._orientation}return o},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,r,o;if(!t._webAudio)return t;if(i.length===0)return t._pannerAttr;if(i.length===1)if(typeof i[0]=="object")s=i[0],typeof r>"u"&&(s.pannerAttr||(s.pannerAttr={coneInnerAngle:s.coneInnerAngle,coneOuterAngle:s.coneOuterAngle,coneOuterGain:s.coneOuterGain,distanceModel:s.distanceModel,maxDistance:s.maxDistance,refDistance:s.refDistance,rolloffFactor:s.rolloffFactor,panningModel:s.panningModel}),t._pannerAttr={coneInnerAngle:typeof s.pannerAttr.coneInnerAngle<"u"?s.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof s.pannerAttr.coneOuterAngle<"u"?s.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof s.pannerAttr.coneOuterGain<"u"?s.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof s.pannerAttr.distanceModel<"u"?s.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof s.pannerAttr.maxDistance<"u"?s.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof s.pannerAttr.refDistance<"u"?s.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof s.pannerAttr.rolloffFactor<"u"?s.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof s.pannerAttr.panningModel<"u"?s.pannerAttr.panningModel:t._panningModel});else return o=t._soundById(parseInt(i[0],10)),o?o._pannerAttr:t._pannerAttr;else i.length===2&&(s=i[0],r=parseInt(i[1],10));for(var c=t._getSoundIds(r),h=0;h<c.length;h++)if(o=t._soundById(c[h]),o){var u=o._pannerAttr;u={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:u.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:u.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:u.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:u.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:u.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:u.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:u.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:u.panningModel};var p=o._panner;p||(o._pos||(o._pos=t._pos||[0,0,-.5]),e(o,"spatial"),p=o._panner),p.coneInnerAngle=u.coneInnerAngle,p.coneOuterAngle=u.coneOuterAngle,p.coneOuterGain=u.coneOuterGain,p.distanceModel=u.distanceModel,p.maxDistance=u.maxDistance,p.refDistance=u.refDistance,p.rolloffFactor=u.rolloffFactor,p.panningModel=u.panningModel}return t},Sound.prototype.init=function(t){return function(){var i=this,s=i._parent;i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,t.call(this),i._stereo?s.stereo(i._stereo):i._pos&&s.pos(i._pos[0],i._pos[1],i._pos[2],i._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var i=this,s=i._parent;return i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,i._stereo?s.stereo(i._stereo):i._pos?s.pos(i._pos[0],i._pos[1],i._pos[2],i._id):i._panner&&(i._panner.disconnect(0),i._panner=void 0,s._refreshBuffer(i)),t.call(this)}}(Sound.prototype.reset);var e=function(t,i){i=i||"spatial",i==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()})(sn);const Xa="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjQxLjEwMAAAAAAAAAAAAAAA//NwwAAAAAAAAAAAAEluZm8AAAAPAAAAFAAACOAAICAgICwsLCwsNzc3NzdDQ0NDQ09PT09PW1tbW1tmZmZmZnJycnJyfn5+fn6KioqKipWVlZWVoaGhoaGtra2trbm5ubm5xcXFxcXQ0NDQ0Nzc3Nzc6Ojo6Oj09PT09P//////AAAAAExhdmM1OC43NQAAAAAAAAAAAAAAACQCwAAAAAAAAAjgTZykiAAAAAAAAAAAAAAAAAD/80DEABJhFmQCwwYUIDsKrsHAWBMRyeJYliQJBg5RYsWU/W3z/8OLc/3AAAQiIAIjv+7vUCJXd4jucQABAE3lwffiDBD+JC58oCH8H/1h/WH//1HPwTUMFrULH9ELKxULyTodFKYbO//zQsQRFFkScKDSRhyGWpIFpG91I7Fi/F6D2RWwN6TN/t9CiVSG5wMw74ogYcHoEwTFyMmTf4KkxEwmRfjXIYv1tpIOZRv/3O9ibtjR6gYmbGCgQ+Fk0mfSmybOX1cf78g7D6nP6qxCgf/zQMQbF+EacktaSABfy+3JKszHdMgcwwcl/kNFIuAo0I0DD1fWVs/crTSTTRInof3cmIwyLBwGQqCSLq7hyvtRPBB4aFyyXHov9X///7UXKqoIIcgcHict89/0y+n+nf/C0DIjB/+P//NCxBYZU9q0AYpoAHNyXSLn/+EjEbJclC4eJT//8e5aMAWeE4////wvAyAvYjZLjAD0Lg9D0kCU/////zwwBdJcYAehKBIwtYyx6FyXC4XP//////x7l83NDpfqd6gAcA/+wu9A2FGg//NAxAwXCnsq/5M4AhQKAOwmRvQRhjhOe5S8UkAmVHpU8IVU3lwejjIcayXOOceGwjf+D05I8oAu2x382o1ZHHV//31NU4441lmqcv///+RNGrUJKImnTf//iVYK1UZquoZESSy3egH/80LEChchBtMfyzAAk191v20qimbuNqavb211BthJKSJAG2aucbdLeVFVmRjZEVvzOggIwuUFDgvEZA7UeuUqNMLOraDQ5CVCk5m9BsmT3kbNrBdolcFSsqXGwQTWyYUX2wEDEgKkvZb/80DECRYRUpWsikYY1HXLbDZksYxtCHBShdHt/DgYCOM6r8AmUSpfGZYzH7ARMBCj1JtmY/hmwoGio0XBUShoklC5GsNeDR38RQ6d01DyrENtqp6mCJ5GJUckmpUBaIgYK6C0fPjmUf/zQsQLFil+cajTBhydxPRO4mLMWWSGQF2qa1f3PPlHQDJdzCxnwgkzB1SQohrpNRYRgtobv07tBLUFc27jQdWoQY0JNpiMJy654enBVoqnQR571uq/i9rpL1oAqAupJATLLk5L+QT3Kf/zQMQOE9D2bWFaGACZyWQZdt1rd3OVY8s/y2dBlg0m12PFzdFSlYrboY6gMOE1hJp7iFqmDcopF8F2OKEPnktdThRLoy9iuyj//0vD4+qf///++38OsIIFFhpEFZMC4s+gZmilJz1X//NCxBkaW8allZI4AWPWKBoLFWrwfuYvukbk4Rt9tBuJYOBoWpfzfjQaNMp//+OGEzzzDIif3+n/4PBIEt5hjDc9zxv/////nseeNDHGg0MQwxBEFn//////4TpB9d/s9thcHddpssFg//NAxAsVCT8GX5BAAigUAPBBdOBaKEIpaajR1VyCNH/gAwAfjRX8G7B4zfx0HANA8BpjQ6FhfqKxRBQURleGbrufzJywVGVfRdOzp5///ERCxhb//8wqijBAwUYMBCjVWZsv26uwYU3/80LEERRTIuTLwxABmdQgEBGKFNo9amfRWcpnayOUsKJ/UpWo/qyL////sj1b+pc3oarStSWpf/VP+hlotDN/0MVjKMKDAZGL/Ar8QWpCR0msAoVgrMoeT3xHIZd3qARkQge7hzlejQD/80DEGxPQ5sryeYYUBCI58AEvohe5nAMDcPxAbUxN6VCB4xCid97iaTyonF0l4upInmIpD//V0f/OllFls0vEBipVlYYRWhuzlHgpEiJSRmYJQaiptezfqvKm1PBRJKiq7M3s1yoqKv/zQsQmFBEGuojBkAQdCzTSpHY0FSwdboEQKi7pZN986g7UVOkf5ZR6VdbbQwZ+79PW6VoWdwZqA4VT2QGoxuuO0VZgbATjSNkSqqresUZ4lDGM5tfbuZzGHYfri5YKg0eDjgQjhm0Wpf/zQMQxE1jyoqhoxFD16D4jzQUUULEB1QXZhRIdIbHFtSlSvX5anFh11QTHaABkiBXOXoXxGW9galRr4fRiew3yOag/4HjxOydOM9ZyyokPlRKdFBa0CjY1luBiKXXwLw6oeMWEhjoS//NCxD4TUNKKIJpMJNTRh7nf/3kekmjdSWypy9UZXQgZMDh3pnAWB4O2M6nAaelR4r1OmVPFSwoksiWRUE1zc+f1lPc0ZudtdFDr4LLpoSwwGkpVO+oD6Tlb3HsYL7d+R1//td2LQMNF//NAxEwTaP5xYqJMCFlqIwAbEoCJNDEp9/3itYVbV6Yx/v0nuLdzyy50qHQw3cafmKlb6zBo0yXeRMnQG5J4jE7j4PFAkTSpQ9pexojMMsL0PIqP/Z1Xp/TpnVZZ27eWtNWRSSSyWyz/80LEWRSo1nDhWhgAlsstlkskgADyNOHqG5rlhLnSyI0a5oClU7uw0JnJQq2kTMBUYADEskGQ9wdHohh2xMKnCubKTIdyRgT83NEIrcfJpJOL3fV7l9cyXXJwJRDGpJLTZJF1+3OPUX3/80DEYiVyorJfmlgDRVRdYm21rHJXTVH0+ajd35ouiSF1tVcmLGnFummxbrhsXfHNzcf/2qgd/7XhppiSaYkmmQGRpnCsAMAEB4tQrXVA0VOiINSMWfljtMTHsRdZ3iL/V1neW6zvLf/zQsQnDSAiMFXMGADWd4i6zvEX+W/yzud5ZUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==";let Ja=class{constructor(){this.sound=new sn.Howl({src:[Xa]})}play(){this.sound.play()}};function $a(a,e,t=new f.Box3){if(t.makeEmpty(),!a||!e)return t;a.updateWorldMatrix(!0,!0),e.updateWorldMatrix(!0,!0);const i=new f.Matrix4().copy(e.matrixWorld).invert(),s=new f.Matrix4,r=new f.Vector3;let o=!1;return a.traverseVisible(c=>{var l,d,g;if(!(c!=null&&c.geometry)||!(c!=null&&c.isMesh)||(l=c==null?void 0:c.userData)!=null&&l.ignoreSize)return;const h=c.material;if((d=h==null?void 0:h.userData)!=null&&d.isLOGO)return;const u=c.geometry,p=(g=u==null?void 0:u.getAttribute)==null?void 0:g.call(u,"position");if(!p||p.count<=0)return;s.multiplyMatrices(i,c.matrixWorld);const n=typeof c.getVertexPosition=="function"?c.getVertexPosition.bind(c):void 0;for(let v=0,m=p.count;v<m;v++)n?n(v,r):r.fromBufferAttribute(p,v),r.applyMatrix4(s),t.expandByPoint(r),o=!0}),(!o||t.isEmpty())&&(t.min.set(0,0,0),t.max.set(0,0,0)),t}function el(a,e,t=new f.Vector3){return $a(a,e).getSize(t)}const De=a=>{var e,t;if(typeof a.destroy=="function"){a.destroy();return}for(;a.children.length>0;)De(a.children[0]),(e=a.children[0])==null||e.removeFromParent();if(a instanceof f.Mesh)try{(t=a.geometry)==null||t.dispose()}catch{}};function tl(a){return new f.Vector3(a[0],a[1],a[2])}function il(){let a=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(a=4,e=1/window.devicePixelRatio),{tiles:a,renderScale:e}}function sl(a){let e=!1,t=!1,i=!1,s=1/0,r=1/0,o=1/0,c=-1/0,h=-1/0,u=-1/0,p=0,n=0;return a.traverse(d=>{var L,C,I;const g=d;if(!(g!=null&&g.isMesh)||!g.geometry||g.userData.ignoreSize)return;const v=g.material;if((L=v==null?void 0:v.userData)!=null&&L.isLOGO)return;const m=g.geometry,_=(C=m==null?void 0:m.attributes)==null?void 0:C.position;if(!_||_.count<=0)return;const y=g.morphTargetDictionary;y&&(y.width!==void 0&&(t=!0),y.length!==void 0&&(e=!0),y.height!==void 0&&(i=!0));const w=(I=m==null?void 0:m.morphAttributes)==null?void 0:I.position,x=g.morphTargetInfluences,b=[];if(w&&x&&w.length>0){const D=Math.min(w.length,x.length);for(let A=0;A<D;A++){const S=x[A]||0;if(S===0)continue;const P=w[A];b.push({attr:P,weight:S,array:P.array,itemSize:P.itemSize??3})}}const T=_.array,M=_.itemSize??3;if(T&&M>=3){const D=_.count,A=b.length>0;for(let S=0;S<D;S++){const P=S*M;let R=T[P],k=T[P+1],F=T[P+2];if(A)for(let B=0;B<b.length;B++){const N=b[B],W=N.weight;if(N.array&&N.itemSize>=3){const O=S*N.itemSize;R+=N.array[O]*W,k+=N.array[O+1]*W,F+=N.array[O+2]*W}else R+=N.attr.getX(S)*W,k+=N.attr.getY(S)*W,F+=N.attr.getZ(S)*W}R<s&&(s=R),k<r&&(r=k),F<o&&(o=F),R>c&&(c=R),k>h&&(h=k),F>u&&(u=F),k>n&&(n=k);const z=R*R+k*k;z>p&&(p=z)}return}for(let D=0;D<_.count;D++){let A=_.getX(D),S=_.getY(D),P=_.getZ(D);if(b.length>0)for(let k=0;k<b.length;k++){const F=b[k],z=F.weight;A+=F.attr.getX(D)*z,S+=F.attr.getY(D)*z,P+=F.attr.getZ(D)*z}A<s&&(s=A),S<r&&(r=S),P<o&&(o=P),A>c&&(c=A),S>h&&(h=S),P>u&&(u=P),S>n&&(n=S);const R=A*A+S*S;R>p&&(p=R)}}),s===1/0?{box:new f.Box3(new f.Vector3(0,0,0),new f.Vector3(0,0,0)),maxRadius:0,height:0,hasWidth:t,hasLength:e,hasHeight:i}:{box:new f.Box3(new f.Vector3(s,r,o),new f.Vector3(c,h,u)),maxRadius:Math.sqrt(p),height:n,hasWidth:t,hasLength:e,hasHeight:i}}function rl(a,e,t=null){let i=0;return function(){let s=t||this,r=arguments;clearTimeout(i),i=window.setTimeout(function(){a.apply(s,r)},e)}}class nl{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const or=a=>{var i;let e=0,t=0;if(a.geometry){a.geometry.computeBoundingBox();const s=new f.Vector3;(i=a.geometry.boundingBox)==null||i.getSize(s),s.y?(t=s.y,!s.x&&s.z?e=s.z:s.x&&!s.z?e=s.x:s.x&&s.z&&(e=s.z)):(e=s.z,t=s.x)}return{width:e,height:t}};function Cs(){var e;if(typeof navigator>"u")return!1;if(ol())return!0;const a=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(a)}function ol(){try{if(typeof wx<"u"&&wx.getSystemInfo||typeof my<"u"&&my.alert||typeof tt<"u"&&tt.getSystemInfo||typeof swan<"u"&&swan.getSystemInfo)return!0}catch{}return!1}const rn=new Pn.GLTFExporter,je=new Cn.GLTFLoader,Si=new Dn.DRACOLoader;let mt="./draco/";try{mt=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:vt&&vt.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{mt="./draco/"}typeof window<"u"&&window.dracoPath&&(mt=window.dracoPath);Si.setDecoderConfig({type:"wasm"});Si.setDecoderPath(mt.endsWith("/")?mt:`${mt}/`);Si.preload();je.setDRACOLoader(Si);const al=new Ln.DRACOExporter,ar=[115,103,108,98];function ll(a,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),r=new Uint8Array([115,103,108,98]),o=new Uint8Array(2);o[0]=t>>8,o[1]=t&255;const c=new Uint8Array(4);c[0]=s.length>>24,c[1]=s.length>>16&255,c[2]=s.length>>8&255,c[3]=s.length&255;const h=new Uint8Array(a),u=r.length+o.length+c.length+s.length+h.length,p=new Uint8Array(u);let n=0;return p.set(r,n),n+=r.length,p.set(o,n),n+=o.length,p.set(c,n),n+=c.length,p.set(s,n),n+=s.length,p.set(h,n),p.buffer}function cl(a){const e=new Uint8Array(a.slice(0,4));let t=!0;for(let n=0;n<ar.length;n++)if(e[n]!==ar[n]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(a,4,2).getUint16(0,!1),o=new DataView(a,6,4).getUint32(0,!1),c=new Uint8Array(a.slice(10,10+o)),h=new TextDecoder().decode(c),u=JSON.parse(h),p=a.slice(10+o);return{version:s,jsonDescription:u,glbContent:p}}class Ut{constructor(e){this.props=e,this.cache=new Map}load(e,t,i,s){if(this.props.useCache&&this.cache.has(e)){t(this.cache.get(e));return}const r=this;fetch(e).then(o=>{if(!o.ok){s==null||s(new ErrorEvent("NetworkError",{message:"NetworkError for "+e+": "+o.statusText}));return}return o.arrayBuffer()}).then(async o=>{o||s==null||s(new ErrorEvent("Error",{message:"Not a valid sglb file."}));try{const c=r.parse(o);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const h=ns(c.glbContent,"model/gltf-binary"),u=await je.loadAsync(h);URL.revokeObjectURL(h),c.glbContent=void 0,c.glb=u.scene,c.scene=u.scene,c.animations=u.animations,o=void 0,this.cache.set(e,c),t(c)}catch(c){s==null||s(new ErrorEvent("Error",{message:c==null?void 0:c.message}))}}).catch(o=>{s==null||s(new ErrorEvent("Error",{message:o.message}))})}async loadAsync(e){if(this.props.useCache&&this.cache.has(e))return this.cache.get(e);try{const t=await fetch(e);if(!t.ok)throw new Error(`NetworkError for ${e}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i)throw new Error("Not a valid sglb file.");const s=this.parse(i);if(!s.glbContent)throw new Error("No GLB content.");const r=ns(s.glbContent,"model/gltf-binary");console.log(r);const o=await je.loadAsync(r);return URL.revokeObjectURL(r),s.glbContent=void 0,s.glb=o.scene,s.scene=o.scene,s.animations=o.animations,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return cl(e)}clear(){[...this.cache.values()]}}const hl=`*{box-sizing:border-box}.slot-item-container.is-mobile .main{pointer-events:none;border-width:1px;opacity:.8}.slot-item-container.is-mobile .main.focus{width:18px!important;height:18px!important;border-width:2px;opacity:1}.slot-item-container.is-mobile .main.filled{opacity:1;border-width:1px;width:14px!important;height:14px!important;background-image:none;border-radius:50%}.slot-item-container.is-mobile .main.to-be-installed{opacity:1;pointer-events:auto;width:38px!important;height:38px!important;border-color:#000;border-width:1px;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cg%3e%3cg%3e%3cpath%20d='M20,10.75L0,10.75L0,9.25L20,9.25L20,10.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%20transform='matrix(0,1,1,0,10,-10)'%3e%3cpath%20d='M30,0.75L10,0.75L10,-0.75L30,-0.75L30,0.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:20px auto;background-repeat:no-repeat;background-position:center;background-color:#fff9}.slot-item-container.is-mobile .main.to-be-installed+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container.is-mobile .main.to-be-installed.filled{opacity:1;border-width:2px;width:18px!important;height:18px!important;background-image:none;border-radius:50%;border-color:#00ff95}.slot-item-container.is-mobile .main.to-be-installed.to-be-replaced{opacity:1;border-width:1px;pointer-events:auto;width:38px!important;height:38px!important;border-radius:50%;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_014299'%3e%3crect%20x='0'%20y='0'%20width='40'%20height='40'%20rx='20'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_014299)'%3e%3cg%3e%3cg%3e%3cpath%20d='M31.695414,17L26.009501,10.74549544L24.899591,11.75450456L28.304586,15.5L8.75,15.5L8.75,17L31.695414,17Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.3045862,23L13.9904997,29.2545042L15.10041,28.2454953L11.6954139,24.5L31.25,24.5L31.25,23L8.3045862,23Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:38px auto;border-color:#000}.slot-item-container.is-mobile .info{left:100%;margin-top:0;margin-left:4px}.slot-item-container.is-mobile .info .name-wrapper{margin-top:0;border-radius:0;background:#000;color:#fff}.slot-item-container.is-mobile .info>img{display:none}.slot-item-container .main{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:22px;height:22px;background:#fff0;border:1.5px solid #fff;border-radius:0;transition:background .2s,width .14s,height .14s,border .14s}.slot-item-container .main.disable{cursor:not-allowed}.slot-item-container .main.drag-over{border-color:red}.slot-item-container .main.can-install{position:relative;width:44px;height:44px;background:#0066ff1a;border-color:#06f}.slot-item-container .main.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.selected{border-width:4px}.slot-item-container .main.selected+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus{border-color:#000}.slot-item-container .main.focus+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.has-error{border-color:red}.slot-item-container .main.hidden{display:none}.slot-item-container .main.hidden+.info{display:none}.slot-item-container .main:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}.slot-item-container .main:hover{background:#ffffff80}.slot-item-container .main:hover+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .name{position:relative}.slot-item-container .name-wrapper{margin-top:-10px;white-space:nowrap;font-size:12px;color:#fff;padding:2px 8px;background:#000}.slot-item-container .functions-wrapper{z-index:20000;position:absolute;left:0;top:100%}.slot-item-container .functions-wrapper>.functions{display:inline-block;min-width:100px;padding:6px 0;border-left:1px solid #00ff95;border-radius:0 2px 2px 0;background:#0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.slot-item-container .functions-wrapper>.functions .btn-add{cursor:pointer;padding:2px 0;margin:0 8px;display:flex;justify-content:center;align-content:center;align-items:center;border:1px dashed #eee;font-size:12px;color:#eee;border-radius:2px;-webkit-backdrop-filter:none;backdrop-filter:none;background:#00050a80}.slot-item-container .functions-wrapper>.functions .btn-add.btn-not-allowed{cursor:not-allowed}.slot-item-container .functions-wrapper>.functions .function{display:flex;justify-content:space-between;white-space:nowrap;margin-bottom:6px;padding:0 8px;font-size:12px;color:#fff}.slot-item-container .functions-wrapper>.functions .function span{margin-right:4px}.slot-item-container .functions-wrapper>.functions .function .btn-remove{pointer-events:none;opacity:0;cursor:pointer;align-self:center;margin-right:0;height:14px;width:14px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAACnSURBVEiJxZaxFcMgDETPTuUtWCWTM4pZAq5RojRpnOfEyEKxSnh3HySeBEhNjZJJTRgUG89GyZWilbKOgJCaKmWtFG2UvFnwQr56jYAcengg3dozELPGIjh96x6hu26/DIa9vD0jq/nUA3nikQEkAOW9nACUGbf7skxlX2mIj1Ob0jK76QdxbYpGFNlk3rPnNndDQltFaLMLbdehAyd8ZP5l6Ed+W17xG7oN9QkytAAAAABJRU5ErkJggg==) center no-repeat;background-size:10px 10px}.slot-item-container .functions-wrapper>.functions .function:hover .btn-remove{pointer-events:auto;opacity:1;transform:scale(1.2)}.slot-item-container .device-name{position:relative;margin:2px 0;display:flex;min-width:120px;align-items:center;align-content:center;justify-content:space-between;white-space:nowrap;height:30px;padding:0 8px;font-size:14px;font-weight:700;color:#000;background:#fff}.slot-item-container .device-name .device-logo{margin-left:-8px;margin-right:4px;width:30px;height:30px;object-fit:contain}.slot-item-container .device-name span{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:250px}.slot-item-container .device-name .btn-close{margin-left:8px;cursor:pointer;height:20px;width:20px;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_017509'%3e%3crect%20x='0'%20y='0'%20width='20'%20height='20'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_017509)'%3e%3cg%3e%3cpath%20d='M4.375,16.875L4.375,4.375L15.625,4.375L15.625,16.875L4.375,16.875ZM14.375,5.625L5.625,5.625L5.625,15.625L14.375,15.625L14.375,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.125,12.1875L8.125,8.125L9.375,8.125L9.375,12.1875L8.125,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M10.625,12.1875L10.625,8.125L11.875,8.125L11.875,12.1875L10.625,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M16.875,5.625L3.125,5.625L3.125,4.375L16.875,4.375L16.875,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M6.4446528999999995,5.625L13.545177899999999,5.625L11.8665838,2.5L8.15767372,2.5L6.4446528999999995,5.625ZM11.4548223,4.3749999L8.5553472,4.3749999L8.8979512,3.75L11.1191032,3.75L11.4548223,4.3749999Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e") center no-repeat;background-size:100% auto}.slot-item-container .device-name.empty{color:#000c;font-weight:400}.slot-item-container .device-name.empty .btn-close{display:none}.slot-item-container .device-name.empty:before{height:0}.slot-item-container .all-functions{opacity:0;pointer-events:none;min-width:80px;position:absolute;left:-10px;margin-left:100%;bottom:0;padding:6px 0;background:#fff;transition:all .3s}.slot-item-container .all-functions.show{opacity:1;pointer-events:auto;left:16px}.slot-item-container .all-functions label{margin-left:8px;margin-bottom:20px;color:#444e69;font-size:14px}.slot-item-container .all-functions .btn-close{cursor:pointer;position:absolute;right:7px;top:7px;height:16px;width:16px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAB4SURBVDiNpZPLEYAgDAUXe6MuoK4UpwdBwQkQJDcyb9+QnxORCOC9jyxE4Y78DiWxAIcmISKnxaSrtZhMNSOB+ZeacAS7ngl3k1JOBSBpk1INPib0YHjH+Du2S1DhlSZOYbPJ1iLtrLKrG2a9yJopYzTD8Jx+ArgAylOzjm1WpDwAAAAASUVORK5CYII=) center no-repeat;background-size:10px 10px}.slot-item-container .all-functions .functions{display:inline-block;max-height:200px;overflow-x:hidden;overflow-y:auto}.slot-item-container .all-functions .functions::-webkit-scrollbar{width:4px}.slot-item-container .all-functions .functions::-webkit-scrollbar-track{background-color:#fff}.slot-item-container .all-functions .functions::-webkit-scrollbar-thumb{background:#787878;border-radius:25px}.slot-item-container .all-functions .function{display:flex;justify-content:space-between;white-space:nowrap;padding:5px 10px;font-size:12px;color:#787878}.slot-item-container .all-functions .function span{display:flex;align-content:center;align-items:center;margin-right:4px}.slot-item-container .all-functions .function:hover{background:#444e6933}.slot-item-container .all-functions .btn-add{cursor:pointer;width:16px;font-size:16px;text-align:center;font-style:normal}.slot-item-container .info{overflow:hidden;margin-left:-2px;margin-top:-19px;position:absolute;left:100%;top:50%;transform:translateY(-50%);width:0;display:flex;align-items:flex-start;transition:all .3s}.slot-item-container .info>img{flex:0 0 auto;width:53px;height:29px}`,ul="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",lr={name:"",isMobile:!1},fl={"&":"&","<":"<",">":">",'"':""","'":"'"};function Mt(a){return a==null?"":String(a).replace(/[&<>"']/g,e=>fl[e])}function cr(...a){return a.filter(Boolean).join(" ")}class nn extends HTMLElement{constructor(e){super(),this._size=12,this._showDialog=!1,this._selected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._hasError=!1,this._canInstall=!1,this._hide=!1,this._disable=!1,this._filled=!1,this._allFunctions=[],this._functions=[],this._deviceName="",this._deviceLogo="",this._renderQueued=!1,this._needsRender=!0,this.attachShadow({mode:"open"}),this._props={...lr,...e??{}},this.handleShadowClick=this.handleShadowClick.bind(this),this.shadowRoot.addEventListener("click",this.handleShadowClick),this.render()}connectedCallback(){this._needsRender&&(this._needsRender=!1,this.render())}get props(){return this._props}set props(e){this._props={...lr,...e},this.scheduleRender()}get slot(){return this._slot}set slot(e){this._slot=e,this.scheduleRender()}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.scheduleRender())}get focused(){return this._focused}set focused(e){const t=!!e;this._focused!==t&&(this._focused=t,this.scheduleRender())}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){const t=!!e;this._toBeInstalled!==t&&(this._toBeInstalled=t,this.scheduleRender())}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){const t=!!e;this._toBeReplaced!==t&&(this._toBeReplaced=t,this.scheduleRender())}get hasError(){return this._hasError}set hasError(e){const t=!!e;this._hasError!==t&&(this._hasError=t,this.scheduleRender())}get canInstall(){return this._canInstall}set canInstall(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("can-install"):i.classList.remove("can-install");return}this._canInstall!==t&&(this._canInstall=t,this.scheduleRender())}get hide(){return this._hide}set hide(e){const t=!!e;this._hide!==t&&(this._hide=t,this.scheduleRender())}get disable(){return this._disable}set disable(e){const t=!!e;this._disable!==t&&(this._disable=t,this.scheduleRender())}get filled(){return this._filled}set filled(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("filled"):i.classList.remove("filled");return}this._filled!==t&&(this._filled=t,this.scheduleRender())}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._allFunctions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get functions(){return[...this._functions]}set functions(e){this._functions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get deviceName(){return this._deviceName}set deviceName(e){this._deviceName=e??"",this.scheduleRender()}get deviceLogo(){return this._deviceLogo}set deviceLogo(e){this._deviceLogo=e??"",this.scheduleRender()}get hasMoreFunctions(){return this._allFunctions.some(e=>!this._functions.includes(e))}setSize(e=12){var s;const t=Number.isFinite(e)?Number(e):12,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){i.style.width=i.style.height=`${e}px`;return}this._size!==t&&(this._size=t,this.scheduleRender())}removeDevice(){var e,t;this._showDialog=!1,this.scheduleRender(),(t=(e=this._props).onRemove)==null||t.call(e)}addFunction(e){this.dispatchEvent(new CustomEvent("function-added",{detail:e}))}scheduleRender(){if(!this.isConnected){this._needsRender=!0;return}this._renderQueued||(this._renderQueued=!0,queueMicrotask(()=>{this._renderQueued=!1,this.render()}))}render(){var p;if(!this.shadowRoot)return;const e=cr("slot-item-container",this._props.isMobile&&"is-mobile"),t=cr("main",this._selected&&"selected",this._focused&&"focus",this._toBeInstalled&&"to-be-installed",this._toBeReplaced&&"to-be-replaced",this._hasError&&"has-error",this._canInstall&&"can-install",this._hide&&"hidden",this._disable&&"disable",this._filled&&"filled"),i=this._functions.map(n=>{const l=Mt(n);return`<div class="function" data-function="${l}"><span>${l}</span><i class="btn btn-remove" data-action="remove-function" data-function="${l}"></i></div>`}).join(""),s=this._allFunctions.filter(n=>!this._functions.includes(n)),r=this._allFunctions.length?`<div class="functions">${i}${`<div class="btn btn-add ${this.hasMoreFunctions?"":"btn-not-allowed"}" data-action="toggle-dialog">+添加</div>`}</div>`:"",o=s.length?`<div class="all-functions ${this._showDialog?"show":""}">
|
|
3706
|
+
*/(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var i=this;if(!i.ctx||!i.ctx.listener)return i;for(var s=i._howls.length-1;s>=0;s--)i._howls[s].stereo(t);return i},HowlerGlobal.prototype.pos=function(t,i,s){var r=this;if(!r.ctx||!r.ctx.listener)return r;if(i=typeof i!="number"?r._pos[1]:i,s=typeof s!="number"?r._pos[2]:s,typeof t=="number")r._pos=[t,i,s],typeof r.ctx.listener.positionX<"u"?(r.ctx.listener.positionX.setTargetAtTime(r._pos[0],Howler.ctx.currentTime,.1),r.ctx.listener.positionY.setTargetAtTime(r._pos[1],Howler.ctx.currentTime,.1),r.ctx.listener.positionZ.setTargetAtTime(r._pos[2],Howler.ctx.currentTime,.1)):r.ctx.listener.setPosition(r._pos[0],r._pos[1],r._pos[2]);else return r._pos;return r},HowlerGlobal.prototype.orientation=function(t,i,s,r,o,c){var h=this;if(!h.ctx||!h.ctx.listener)return h;var u=h._orientation;if(i=typeof i!="number"?u[1]:i,s=typeof s!="number"?u[2]:s,r=typeof r!="number"?u[3]:r,o=typeof o!="number"?u[4]:o,c=typeof c!="number"?u[5]:c,typeof t=="number")h._orientation=[t,i,s,r,o,c],typeof h.ctx.listener.forwardX<"u"?(h.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),h.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),h.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),h.ctx.listener.upX.setTargetAtTime(r,Howler.ctx.currentTime,.1),h.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),h.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):h.ctx.listener.setOrientation(t,i,s,r,o,c);else return u;return h},Howl.prototype.init=function(t){return function(i){var s=this;return s._orientation=i.orientation||[1,0,0],s._stereo=i.stereo||null,s._pos=i.pos||null,s._pannerAttr={coneInnerAngle:typeof i.coneInnerAngle<"u"?i.coneInnerAngle:360,coneOuterAngle:typeof i.coneOuterAngle<"u"?i.coneOuterAngle:360,coneOuterGain:typeof i.coneOuterGain<"u"?i.coneOuterGain:0,distanceModel:typeof i.distanceModel<"u"?i.distanceModel:"inverse",maxDistance:typeof i.maxDistance<"u"?i.maxDistance:1e4,panningModel:typeof i.panningModel<"u"?i.panningModel:"HRTF",refDistance:typeof i.refDistance<"u"?i.refDistance:1,rolloffFactor:typeof i.rolloffFactor<"u"?i.rolloffFactor:1},s._onstereo=i.onstereo?[{fn:i.onstereo}]:[],s._onpos=i.onpos?[{fn:i.onpos}]:[],s._onorientation=i.onorientation?[{fn:i.onorientation}]:[],t.call(this,i)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"stereo",action:function(){s.stereo(t,i)}}),s;var r=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof i>"u")if(typeof t=="number")s._stereo=t,s._pos=[t,0,0];else return s._stereo;for(var o=s._getSoundIds(i),c=0;c<o.length;c++){var h=s._soundById(o[c]);if(h)if(typeof t=="number")h._stereo=t,h._pos=[t,0,0],h._node&&(h._pannerAttr.panningModel="equalpower",(!h._panner||!h._panner.pan)&&e(h,r),r==="spatial"?typeof h._panner.positionX<"u"?(h._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),h._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),h._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):h._panner.setPosition(t,0,0):h._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",h._id);else return h._stereo}return s},Howl.prototype.pos=function(t,i,s,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"pos",action:function(){o.pos(t,i,s,r)}}),o;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof r>"u")if(typeof t=="number")o._pos=[t,i,s];else return o._pos;for(var c=o._getSoundIds(r),h=0;h<c.length;h++){var u=o._soundById(c[h]);if(u)if(typeof t=="number")u._pos=[t,i,s],u._node&&((!u._panner||u._panner.pan)&&e(u,"spatial"),typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):u._panner.setPosition(t,i,s)),o._emit("pos",u._id);else return u._pos}return o},Howl.prototype.orientation=function(t,i,s,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"orientation",action:function(){o.orientation(t,i,s,r)}}),o;if(i=typeof i!="number"?o._orientation[1]:i,s=typeof s!="number"?o._orientation[2]:s,typeof r>"u")if(typeof t=="number")o._orientation=[t,i,s];else return o._orientation;for(var c=o._getSoundIds(r),h=0;h<c.length;h++){var u=o._soundById(c[h]);if(u)if(typeof t=="number")u._orientation=[t,i,s],u._node&&(u._panner||(u._pos||(u._pos=o._pos||[0,0,-.5]),e(u,"spatial")),typeof u._panner.orientationX<"u"?(u._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),u._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):u._panner.setOrientation(t,i,s)),o._emit("orientation",u._id);else return u._orientation}return o},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,r,o;if(!t._webAudio)return t;if(i.length===0)return t._pannerAttr;if(i.length===1)if(typeof i[0]=="object")s=i[0],typeof r>"u"&&(s.pannerAttr||(s.pannerAttr={coneInnerAngle:s.coneInnerAngle,coneOuterAngle:s.coneOuterAngle,coneOuterGain:s.coneOuterGain,distanceModel:s.distanceModel,maxDistance:s.maxDistance,refDistance:s.refDistance,rolloffFactor:s.rolloffFactor,panningModel:s.panningModel}),t._pannerAttr={coneInnerAngle:typeof s.pannerAttr.coneInnerAngle<"u"?s.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof s.pannerAttr.coneOuterAngle<"u"?s.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof s.pannerAttr.coneOuterGain<"u"?s.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof s.pannerAttr.distanceModel<"u"?s.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof s.pannerAttr.maxDistance<"u"?s.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof s.pannerAttr.refDistance<"u"?s.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof s.pannerAttr.rolloffFactor<"u"?s.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof s.pannerAttr.panningModel<"u"?s.pannerAttr.panningModel:t._panningModel});else return o=t._soundById(parseInt(i[0],10)),o?o._pannerAttr:t._pannerAttr;else i.length===2&&(s=i[0],r=parseInt(i[1],10));for(var c=t._getSoundIds(r),h=0;h<c.length;h++)if(o=t._soundById(c[h]),o){var u=o._pannerAttr;u={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:u.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:u.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:u.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:u.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:u.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:u.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:u.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:u.panningModel};var p=o._panner;p||(o._pos||(o._pos=t._pos||[0,0,-.5]),e(o,"spatial"),p=o._panner),p.coneInnerAngle=u.coneInnerAngle,p.coneOuterAngle=u.coneOuterAngle,p.coneOuterGain=u.coneOuterGain,p.distanceModel=u.distanceModel,p.maxDistance=u.maxDistance,p.refDistance=u.refDistance,p.rolloffFactor=u.rolloffFactor,p.panningModel=u.panningModel}return t},Sound.prototype.init=function(t){return function(){var i=this,s=i._parent;i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,t.call(this),i._stereo?s.stereo(i._stereo):i._pos&&s.pos(i._pos[0],i._pos[1],i._pos[2],i._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var i=this,s=i._parent;return i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,i._stereo?s.stereo(i._stereo):i._pos?s.pos(i._pos[0],i._pos[1],i._pos[2],i._id):i._panner&&(i._panner.disconnect(0),i._panner=void 0,s._refreshBuffer(i)),t.call(this)}}(Sound.prototype.reset);var e=function(t,i){i=i||"spatial",i==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()})(sn);const Xa="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjQxLjEwMAAAAAAAAAAAAAAA//NwwAAAAAAAAAAAAEluZm8AAAAPAAAAFAAACOAAICAgICwsLCwsNzc3NzdDQ0NDQ09PT09PW1tbW1tmZmZmZnJycnJyfn5+fn6KioqKipWVlZWVoaGhoaGtra2trbm5ubm5xcXFxcXQ0NDQ0Nzc3Nzc6Ojo6Oj09PT09P//////AAAAAExhdmM1OC43NQAAAAAAAAAAAAAAACQCwAAAAAAAAAjgTZykiAAAAAAAAAAAAAAAAAD/80DEABJhFmQCwwYUIDsKrsHAWBMRyeJYliQJBg5RYsWU/W3z/8OLc/3AAAQiIAIjv+7vUCJXd4jucQABAE3lwffiDBD+JC58oCH8H/1h/WH//1HPwTUMFrULH9ELKxULyTodFKYbO//zQsQRFFkScKDSRhyGWpIFpG91I7Fi/F6D2RWwN6TN/t9CiVSG5wMw74ogYcHoEwTFyMmTf4KkxEwmRfjXIYv1tpIOZRv/3O9ibtjR6gYmbGCgQ+Fk0mfSmybOX1cf78g7D6nP6qxCgf/zQMQbF+EacktaSABfy+3JKszHdMgcwwcl/kNFIuAo0I0DD1fWVs/crTSTTRInof3cmIwyLBwGQqCSLq7hyvtRPBB4aFyyXHov9X///7UXKqoIIcgcHict89/0y+n+nf/C0DIjB/+P//NCxBYZU9q0AYpoAHNyXSLn/+EjEbJclC4eJT//8e5aMAWeE4////wvAyAvYjZLjAD0Lg9D0kCU/////zwwBdJcYAehKBIwtYyx6FyXC4XP//////x7l83NDpfqd6gAcA/+wu9A2FGg//NAxAwXCnsq/5M4AhQKAOwmRvQRhjhOe5S8UkAmVHpU8IVU3lwejjIcayXOOceGwjf+D05I8oAu2x382o1ZHHV//31NU4441lmqcv///+RNGrUJKImnTf//iVYK1UZquoZESSy3egH/80LEChchBtMfyzAAk191v20qimbuNqavb211BthJKSJAG2aucbdLeVFVmRjZEVvzOggIwuUFDgvEZA7UeuUqNMLOraDQ5CVCk5m9BsmT3kbNrBdolcFSsqXGwQTWyYUX2wEDEgKkvZb/80DECRYRUpWsikYY1HXLbDZksYxtCHBShdHt/DgYCOM6r8AmUSpfGZYzH7ARMBCj1JtmY/hmwoGio0XBUShoklC5GsNeDR38RQ6d01DyrENtqp6mCJ5GJUckmpUBaIgYK6C0fPjmUf/zQsQLFil+cajTBhydxPRO4mLMWWSGQF2qa1f3PPlHQDJdzCxnwgkzB1SQohrpNRYRgtobv07tBLUFc27jQdWoQY0JNpiMJy654enBVoqnQR571uq/i9rpL1oAqAupJATLLk5L+QT3Kf/zQMQOE9D2bWFaGACZyWQZdt1rd3OVY8s/y2dBlg0m12PFzdFSlYrboY6gMOE1hJp7iFqmDcopF8F2OKEPnktdThRLoy9iuyj//0vD4+qf///++38OsIIFFhpEFZMC4s+gZmilJz1X//NCxBkaW8allZI4AWPWKBoLFWrwfuYvukbk4Rt9tBuJYOBoWpfzfjQaNMp//+OGEzzzDIif3+n/4PBIEt5hjDc9zxv/////nseeNDHGg0MQwxBEFn//////4TpB9d/s9thcHddpssFg//NAxAsVCT8GX5BAAigUAPBBdOBaKEIpaajR1VyCNH/gAwAfjRX8G7B4zfx0HANA8BpjQ6FhfqKxRBQURleGbrufzJywVGVfRdOzp5///ERCxhb//8wqijBAwUYMBCjVWZsv26uwYU3/80LEERRTIuTLwxABmdQgEBGKFNo9amfRWcpnayOUsKJ/UpWo/qyL////sj1b+pc3oarStSWpf/VP+hlotDN/0MVjKMKDAZGL/Ar8QWpCR0msAoVgrMoeT3xHIZd3qARkQge7hzlejQD/80DEGxPQ5sryeYYUBCI58AEvohe5nAMDcPxAbUxN6VCB4xCid97iaTyonF0l4upInmIpD//V0f/OllFls0vEBipVlYYRWhuzlHgpEiJSRmYJQaiptezfqvKm1PBRJKiq7M3s1yoqKv/zQsQmFBEGuojBkAQdCzTSpHY0FSwdboEQKi7pZN986g7UVOkf5ZR6VdbbQwZ+79PW6VoWdwZqA4VT2QGoxuuO0VZgbATjSNkSqqresUZ4lDGM5tfbuZzGHYfri5YKg0eDjgQjhm0Wpf/zQMQxE1jyoqhoxFD16D4jzQUUULEB1QXZhRIdIbHFtSlSvX5anFh11QTHaABkiBXOXoXxGW9galRr4fRiew3yOag/4HjxOydOM9ZyyokPlRKdFBa0CjY1luBiKXXwLw6oeMWEhjoS//NCxD4TUNKKIJpMJNTRh7nf/3kekmjdSWypy9UZXQgZMDh3pnAWB4O2M6nAaelR4r1OmVPFSwoksiWRUE1zc+f1lPc0ZudtdFDr4LLpoSwwGkpVO+oD6Tlb3HsYL7d+R1//td2LQMNF//NAxEwTaP5xYqJMCFlqIwAbEoCJNDEp9/3itYVbV6Yx/v0nuLdzyy50qHQw3cafmKlb6zBo0yXeRMnQG5J4jE7j4PFAkTSpQ9pexojMMsL0PIqP/Z1Xp/TpnVZZ27eWtNWRSSSyWyz/80LEWRSo1nDhWhgAlsstlkskgADyNOHqG5rlhLnSyI0a5oClU7uw0JnJQq2kTMBUYADEskGQ9wdHohh2xMKnCubKTIdyRgT83NEIrcfJpJOL3fV7l9cyXXJwJRDGpJLTZJF1+3OPUX3/80DEYiVyorJfmlgDRVRdYm21rHJXTVH0+ajd35ouiSF1tVcmLGnFummxbrhsXfHNzcf/2qgd/7XhppiSaYkmmQGRpnCsAMAEB4tQrXVA0VOiINSMWfljtMTHsRdZ3iL/V1neW6zvLf/zQsQnDSAiMFXMGADWd4i6zvEX+W/yzud5ZUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==";let Ja=class{constructor(){this.sound=new sn.Howl({src:[Xa]})}play(){this.sound.play()}};function $a(a,e,t=new f.Box3){if(t.makeEmpty(),!a||!e)return t;a.updateWorldMatrix(!0,!0),e.updateWorldMatrix(!0,!0);const i=new f.Matrix4().copy(e.matrixWorld).invert(),s=new f.Matrix4,r=new f.Vector3;let o=!1;return a.traverseVisible(c=>{var l,d,g;if(!(c!=null&&c.geometry)||!(c!=null&&c.isMesh)||(l=c==null?void 0:c.userData)!=null&&l.ignoreSize)return;const h=c.material;if((d=h==null?void 0:h.userData)!=null&&d.isLOGO)return;const u=c.geometry,p=(g=u==null?void 0:u.getAttribute)==null?void 0:g.call(u,"position");if(!p||p.count<=0)return;s.multiplyMatrices(i,c.matrixWorld);const n=typeof c.getVertexPosition=="function"?c.getVertexPosition.bind(c):void 0;for(let v=0,m=p.count;v<m;v++)n?n(v,r):r.fromBufferAttribute(p,v),r.applyMatrix4(s),t.expandByPoint(r),o=!0}),(!o||t.isEmpty())&&(t.min.set(0,0,0),t.max.set(0,0,0)),t}function el(a,e,t=new f.Vector3){return $a(a,e).getSize(t)}const De=a=>{var e,t;if(typeof a.destroy=="function"){a.destroy();return}for(;a.children.length>0;)De(a.children[0]),(e=a.children[0])==null||e.removeFromParent();if(a instanceof f.Mesh)try{(t=a.geometry)==null||t.dispose()}catch{}};function tl(a){return new f.Vector3(a[0],a[1],a[2])}function il(){let a=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(a=4,e=1/window.devicePixelRatio),{tiles:a,renderScale:e}}function sl(a){let e=!1,t=!1,i=!1,s=1/0,r=1/0,o=1/0,c=-1/0,h=-1/0,u=-1/0,p=0,n=0;return a.traverse(d=>{var P,C,I;const g=d;if(!(g!=null&&g.isMesh)||!g.geometry||g.userData.ignoreSize)return;const v=g.material;if((P=v==null?void 0:v.userData)!=null&&P.isLOGO)return;const m=g.geometry,_=(C=m==null?void 0:m.attributes)==null?void 0:C.position;if(!_||_.count<=0)return;const y=g.morphTargetDictionary;y&&(y.width!==void 0&&(t=!0),y.length!==void 0&&(e=!0),y.height!==void 0&&(i=!0));const w=(I=m==null?void 0:m.morphAttributes)==null?void 0:I.position,x=g.morphTargetInfluences,b=[];if(w&&x&&w.length>0){const D=Math.min(w.length,x.length);for(let A=0;A<D;A++){const S=x[A]||0;if(S===0)continue;const L=w[A];b.push({attr:L,weight:S,array:L.array,itemSize:L.itemSize??3})}}const T=_.array,M=_.itemSize??3;if(T&&M>=3){const D=_.count,A=b.length>0;for(let S=0;S<D;S++){const L=S*M;let R=T[L],k=T[L+1],F=T[L+2];if(A)for(let B=0;B<b.length;B++){const N=b[B],W=N.weight;if(N.array&&N.itemSize>=3){const O=S*N.itemSize;R+=N.array[O]*W,k+=N.array[O+1]*W,F+=N.array[O+2]*W}else R+=N.attr.getX(S)*W,k+=N.attr.getY(S)*W,F+=N.attr.getZ(S)*W}R<s&&(s=R),k<r&&(r=k),F<o&&(o=F),R>c&&(c=R),k>h&&(h=k),F>u&&(u=F),k>n&&(n=k);const z=R*R+k*k;z>p&&(p=z)}return}for(let D=0;D<_.count;D++){let A=_.getX(D),S=_.getY(D),L=_.getZ(D);if(b.length>0)for(let k=0;k<b.length;k++){const F=b[k],z=F.weight;A+=F.attr.getX(D)*z,S+=F.attr.getY(D)*z,L+=F.attr.getZ(D)*z}A<s&&(s=A),S<r&&(r=S),L<o&&(o=L),A>c&&(c=A),S>h&&(h=S),L>u&&(u=L),S>n&&(n=S);const R=A*A+S*S;R>p&&(p=R)}}),s===1/0?{box:new f.Box3(new f.Vector3(0,0,0),new f.Vector3(0,0,0)),maxRadius:0,height:0,hasWidth:t,hasLength:e,hasHeight:i}:{box:new f.Box3(new f.Vector3(s,r,o),new f.Vector3(c,h,u)),maxRadius:Math.sqrt(p),height:n,hasWidth:t,hasLength:e,hasHeight:i}}function rl(a,e,t=null){let i=0;return function(){let s=t||this,r=arguments;clearTimeout(i),i=window.setTimeout(function(){a.apply(s,r)},e)}}class nl{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const or=a=>{var i;let e=0,t=0;if(a.geometry){a.geometry.computeBoundingBox();const s=new f.Vector3;(i=a.geometry.boundingBox)==null||i.getSize(s),s.y?(t=s.y,!s.x&&s.z?e=s.z:s.x&&!s.z?e=s.x:s.x&&s.z&&(e=s.z)):(e=s.z,t=s.x)}return{width:e,height:t}};function Cs(){var e;if(typeof navigator>"u")return!1;if(ol())return!0;const a=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(a)}function ol(){try{if(typeof wx<"u"&&wx.getSystemInfo||typeof my<"u"&&my.alert||typeof tt<"u"&&tt.getSystemInfo||typeof swan<"u"&&swan.getSystemInfo)return!0}catch{}return!1}const rn=new Ln.GLTFExporter,je=new Cn.GLTFLoader,Si=new Dn.DRACOLoader;let mt="./draco/";try{mt=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:vt&&vt.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{mt="./draco/"}typeof window<"u"&&window.dracoPath&&(mt=window.dracoPath);Si.setDecoderConfig({type:"wasm"});Si.setDecoderPath(mt.endsWith("/")?mt:`${mt}/`);Si.preload();je.setDRACOLoader(Si);const al=new Pn.DRACOExporter,ar=[115,103,108,98];function ll(a,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),r=new Uint8Array([115,103,108,98]),o=new Uint8Array(2);o[0]=t>>8,o[1]=t&255;const c=new Uint8Array(4);c[0]=s.length>>24,c[1]=s.length>>16&255,c[2]=s.length>>8&255,c[3]=s.length&255;const h=new Uint8Array(a),u=r.length+o.length+c.length+s.length+h.length,p=new Uint8Array(u);let n=0;return p.set(r,n),n+=r.length,p.set(o,n),n+=o.length,p.set(c,n),n+=c.length,p.set(s,n),n+=s.length,p.set(h,n),p.buffer}function cl(a){const e=new Uint8Array(a.slice(0,4));let t=!0;for(let n=0;n<ar.length;n++)if(e[n]!==ar[n]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(a,4,2).getUint16(0,!1),o=new DataView(a,6,4).getUint32(0,!1),c=new Uint8Array(a.slice(10,10+o)),h=new TextDecoder().decode(c),u=JSON.parse(h),p=a.slice(10+o);return{version:s,jsonDescription:u,glbContent:p}}class Ut{constructor(e){this.props=e,this.cache=new Map}load(e,t,i,s){if(this.props.useCache&&this.cache.has(e)){t(this.cache.get(e));return}const r=this;fetch(e).then(o=>{if(!o.ok){s==null||s(new ErrorEvent("NetworkError",{message:"NetworkError for "+e+": "+o.statusText}));return}return o.arrayBuffer()}).then(async o=>{o||s==null||s(new ErrorEvent("Error",{message:"Not a valid sglb file."}));try{const c=r.parse(o);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const h=ns(c.glbContent,"model/gltf-binary"),u=await je.loadAsync(h);URL.revokeObjectURL(h),c.glbContent=void 0,c.glb=u.scene,c.scene=u.scene,c.animations=u.animations,o=void 0,this.cache.set(e,c),t(c)}catch(c){s==null||s(new ErrorEvent("Error",{message:c==null?void 0:c.message}))}}).catch(o=>{s==null||s(new ErrorEvent("Error",{message:o.message}))})}async loadAsync(e){if(this.props.useCache&&this.cache.has(e))return this.cache.get(e);try{const t=await fetch(e);if(!t.ok)throw new Error(`NetworkError for ${e}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i)throw new Error("Not a valid sglb file.");const s=this.parse(i);if(!s.glbContent)throw new Error("No GLB content.");const r=ns(s.glbContent,"model/gltf-binary");console.log(r);const o=await je.loadAsync(r);return URL.revokeObjectURL(r),s.glbContent=void 0,s.glb=o.scene,s.scene=o.scene,s.animations=o.animations,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return cl(e)}clear(){[...this.cache.values()]}}const hl=`*{box-sizing:border-box}.slot-item-container.is-mobile .main{pointer-events:none;border-width:1px;opacity:.8}.slot-item-container.is-mobile .main.focus{width:18px!important;height:18px!important;border-width:2px;opacity:1}.slot-item-container.is-mobile .main.filled{opacity:1;border-width:1px;width:14px!important;height:14px!important;background-image:none;border-radius:50%}.slot-item-container.is-mobile .main.to-be-installed{opacity:1;pointer-events:auto;width:38px!important;height:38px!important;border-color:#000;border-width:1px;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cg%3e%3cg%3e%3cpath%20d='M20,10.75L0,10.75L0,9.25L20,9.25L20,10.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%20transform='matrix(0,1,1,0,10,-10)'%3e%3cpath%20d='M30,0.75L10,0.75L10,-0.75L30,-0.75L30,0.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:20px auto;background-repeat:no-repeat;background-position:center;background-color:#fff9}.slot-item-container.is-mobile .main.to-be-installed+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container.is-mobile .main.to-be-installed.filled{opacity:1;border-width:2px;width:18px!important;height:18px!important;background-image:none;border-radius:50%;border-color:#00ff95}.slot-item-container.is-mobile .main.to-be-installed.to-be-replaced{opacity:1;border-width:1px;pointer-events:auto;width:38px!important;height:38px!important;border-radius:50%;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_014299'%3e%3crect%20x='0'%20y='0'%20width='40'%20height='40'%20rx='20'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_014299)'%3e%3cg%3e%3cg%3e%3cpath%20d='M31.695414,17L26.009501,10.74549544L24.899591,11.75450456L28.304586,15.5L8.75,15.5L8.75,17L31.695414,17Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.3045862,23L13.9904997,29.2545042L15.10041,28.2454953L11.6954139,24.5L31.25,24.5L31.25,23L8.3045862,23Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:38px auto;border-color:#000}.slot-item-container.is-mobile .info{left:100%;margin-top:0;margin-left:4px}.slot-item-container.is-mobile .info .name-wrapper{margin-top:0;border-radius:0;background:#000;color:#fff}.slot-item-container.is-mobile .info>img{display:none}.slot-item-container .main{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:22px;height:22px;background:#fff0;border:1.5px solid #fff;border-radius:0;transition:background .2s,width .14s,height .14s,border .14s}.slot-item-container .main.disable{cursor:not-allowed}.slot-item-container .main.drag-over{border-color:red}.slot-item-container .main.can-install{position:relative;width:44px;height:44px;background:#0066ff1a;border-color:#06f}.slot-item-container .main.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.selected{border-width:4px}.slot-item-container .main.selected+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus{border-color:#000}.slot-item-container .main.focus+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.has-error{border-color:red}.slot-item-container .main.hidden{display:none}.slot-item-container .main.hidden+.info{display:none}.slot-item-container .main:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}.slot-item-container .main:hover{background:#ffffff80}.slot-item-container .main:hover+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .name{position:relative}.slot-item-container .name-wrapper{margin-top:-10px;white-space:nowrap;font-size:12px;color:#fff;padding:2px 8px;background:#000}.slot-item-container .functions-wrapper{z-index:20000;position:absolute;left:0;top:100%}.slot-item-container .functions-wrapper>.functions{display:inline-block;min-width:100px;padding:6px 0;border-left:1px solid #00ff95;border-radius:0 2px 2px 0;background:#0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.slot-item-container .functions-wrapper>.functions .btn-add{cursor:pointer;padding:2px 0;margin:0 8px;display:flex;justify-content:center;align-content:center;align-items:center;border:1px dashed #eee;font-size:12px;color:#eee;border-radius:2px;-webkit-backdrop-filter:none;backdrop-filter:none;background:#00050a80}.slot-item-container .functions-wrapper>.functions .btn-add.btn-not-allowed{cursor:not-allowed}.slot-item-container .functions-wrapper>.functions .function{display:flex;justify-content:space-between;white-space:nowrap;margin-bottom:6px;padding:0 8px;font-size:12px;color:#fff}.slot-item-container .functions-wrapper>.functions .function span{margin-right:4px}.slot-item-container .functions-wrapper>.functions .function .btn-remove{pointer-events:none;opacity:0;cursor:pointer;align-self:center;margin-right:0;height:14px;width:14px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAACnSURBVEiJxZaxFcMgDETPTuUtWCWTM4pZAq5RojRpnOfEyEKxSnh3HySeBEhNjZJJTRgUG89GyZWilbKOgJCaKmWtFG2UvFnwQr56jYAcengg3dozELPGIjh96x6hu26/DIa9vD0jq/nUA3nikQEkAOW9nACUGbf7skxlX2mIj1Ob0jK76QdxbYpGFNlk3rPnNndDQltFaLMLbdehAyd8ZP5l6Ed+W17xG7oN9QkytAAAAABJRU5ErkJggg==) center no-repeat;background-size:10px 10px}.slot-item-container .functions-wrapper>.functions .function:hover .btn-remove{pointer-events:auto;opacity:1;transform:scale(1.2)}.slot-item-container .device-name{position:relative;margin:2px 0;display:flex;min-width:120px;align-items:center;align-content:center;justify-content:space-between;white-space:nowrap;height:30px;padding:0 8px;font-size:14px;font-weight:700;color:#000;background:#fff}.slot-item-container .device-name .device-logo{margin-left:-8px;margin-right:4px;width:30px;height:30px;object-fit:contain}.slot-item-container .device-name span{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:250px}.slot-item-container .device-name .btn-close{margin-left:8px;cursor:pointer;height:20px;width:20px;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_017509'%3e%3crect%20x='0'%20y='0'%20width='20'%20height='20'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_017509)'%3e%3cg%3e%3cpath%20d='M4.375,16.875L4.375,4.375L15.625,4.375L15.625,16.875L4.375,16.875ZM14.375,5.625L5.625,5.625L5.625,15.625L14.375,15.625L14.375,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.125,12.1875L8.125,8.125L9.375,8.125L9.375,12.1875L8.125,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M10.625,12.1875L10.625,8.125L11.875,8.125L11.875,12.1875L10.625,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M16.875,5.625L3.125,5.625L3.125,4.375L16.875,4.375L16.875,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M6.4446528999999995,5.625L13.545177899999999,5.625L11.8665838,2.5L8.15767372,2.5L6.4446528999999995,5.625ZM11.4548223,4.3749999L8.5553472,4.3749999L8.8979512,3.75L11.1191032,3.75L11.4548223,4.3749999Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e") center no-repeat;background-size:100% auto}.slot-item-container .device-name.empty{color:#000c;font-weight:400}.slot-item-container .device-name.empty .btn-close{display:none}.slot-item-container .device-name.empty:before{height:0}.slot-item-container .all-functions{opacity:0;pointer-events:none;min-width:80px;position:absolute;left:-10px;margin-left:100%;bottom:0;padding:6px 0;background:#fff;transition:all .3s}.slot-item-container .all-functions.show{opacity:1;pointer-events:auto;left:16px}.slot-item-container .all-functions label{margin-left:8px;margin-bottom:20px;color:#444e69;font-size:14px}.slot-item-container .all-functions .btn-close{cursor:pointer;position:absolute;right:7px;top:7px;height:16px;width:16px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAB4SURBVDiNpZPLEYAgDAUXe6MuoK4UpwdBwQkQJDcyb9+QnxORCOC9jyxE4Y78DiWxAIcmISKnxaSrtZhMNSOB+ZeacAS7ngl3k1JOBSBpk1INPib0YHjH+Du2S1DhlSZOYbPJ1iLtrLKrG2a9yJopYzTD8Jx+ArgAylOzjm1WpDwAAAAASUVORK5CYII=) center no-repeat;background-size:10px 10px}.slot-item-container .all-functions .functions{display:inline-block;max-height:200px;overflow-x:hidden;overflow-y:auto}.slot-item-container .all-functions .functions::-webkit-scrollbar{width:4px}.slot-item-container .all-functions .functions::-webkit-scrollbar-track{background-color:#fff}.slot-item-container .all-functions .functions::-webkit-scrollbar-thumb{background:#787878;border-radius:25px}.slot-item-container .all-functions .function{display:flex;justify-content:space-between;white-space:nowrap;padding:5px 10px;font-size:12px;color:#787878}.slot-item-container .all-functions .function span{display:flex;align-content:center;align-items:center;margin-right:4px}.slot-item-container .all-functions .function:hover{background:#444e6933}.slot-item-container .all-functions .btn-add{cursor:pointer;width:16px;font-size:16px;text-align:center;font-style:normal}.slot-item-container .info{overflow:hidden;margin-left:-2px;margin-top:-19px;position:absolute;left:100%;top:50%;transform:translateY(-50%);width:0;display:flex;align-items:flex-start;transition:all .3s}.slot-item-container .info>img{flex:0 0 auto;width:53px;height:29px}`,ul="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",lr={name:"",isMobile:!1},fl={"&":"&","<":"<",">":">",'"':""","'":"'"};function Mt(a){return a==null?"":String(a).replace(/[&<>"']/g,e=>fl[e])}function cr(...a){return a.filter(Boolean).join(" ")}class nn extends HTMLElement{constructor(e){super(),this._size=12,this._showDialog=!1,this._selected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._hasError=!1,this._canInstall=!1,this._hide=!1,this._disable=!1,this._filled=!1,this._allFunctions=[],this._functions=[],this._deviceName="",this._deviceLogo="",this._renderQueued=!1,this._needsRender=!0,this.attachShadow({mode:"open"}),this._props={...lr,...e??{}},this.handleShadowClick=this.handleShadowClick.bind(this),this.shadowRoot.addEventListener("click",this.handleShadowClick),this.render()}connectedCallback(){this._needsRender&&(this._needsRender=!1,this.render())}get props(){return this._props}set props(e){this._props={...lr,...e},this.scheduleRender()}get slot(){return this._slot}set slot(e){this._slot=e,this.scheduleRender()}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.scheduleRender())}get focused(){return this._focused}set focused(e){const t=!!e;this._focused!==t&&(this._focused=t,this.scheduleRender())}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){const t=!!e;this._toBeInstalled!==t&&(this._toBeInstalled=t,this.scheduleRender())}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){const t=!!e;this._toBeReplaced!==t&&(this._toBeReplaced=t,this.scheduleRender())}get hasError(){return this._hasError}set hasError(e){const t=!!e;this._hasError!==t&&(this._hasError=t,this.scheduleRender())}get canInstall(){return this._canInstall}set canInstall(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("can-install"):i.classList.remove("can-install");return}this._canInstall!==t&&(this._canInstall=t,this.scheduleRender())}get hide(){return this._hide}set hide(e){const t=!!e;this._hide!==t&&(this._hide=t,this.scheduleRender())}get disable(){return this._disable}set disable(e){const t=!!e;this._disable!==t&&(this._disable=t,this.scheduleRender())}get filled(){return this._filled}set filled(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("filled"):i.classList.remove("filled");return}this._filled!==t&&(this._filled=t,this.scheduleRender())}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._allFunctions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get functions(){return[...this._functions]}set functions(e){this._functions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get deviceName(){return this._deviceName}set deviceName(e){this._deviceName=e??"",this.scheduleRender()}get deviceLogo(){return this._deviceLogo}set deviceLogo(e){this._deviceLogo=e??"",this.scheduleRender()}get hasMoreFunctions(){return this._allFunctions.some(e=>!this._functions.includes(e))}setSize(e=12){var s;const t=Number.isFinite(e)?Number(e):12,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){i.style.width=i.style.height=`${e}px`;return}this._size!==t&&(this._size=t,this.scheduleRender())}removeDevice(){var e,t;this._showDialog=!1,this.scheduleRender(),(t=(e=this._props).onRemove)==null||t.call(e)}addFunction(e){this.dispatchEvent(new CustomEvent("function-added",{detail:e}))}scheduleRender(){if(!this.isConnected){this._needsRender=!0;return}this._renderQueued||(this._renderQueued=!0,queueMicrotask(()=>{this._renderQueued=!1,this.render()}))}render(){var p;if(!this.shadowRoot)return;const e=cr("slot-item-container",this._props.isMobile&&"is-mobile"),t=cr("main",this._selected&&"selected",this._focused&&"focus",this._toBeInstalled&&"to-be-installed",this._toBeReplaced&&"to-be-replaced",this._hasError&&"has-error",this._canInstall&&"can-install",this._hide&&"hidden",this._disable&&"disable",this._filled&&"filled"),i=this._functions.map(n=>{const l=Mt(n);return`<div class="function" data-function="${l}"><span>${l}</span><i class="btn btn-remove" data-action="remove-function" data-function="${l}"></i></div>`}).join(""),s=this._allFunctions.filter(n=>!this._functions.includes(n)),r=this._allFunctions.length?`<div class="functions">${i}${`<div class="btn btn-add ${this.hasMoreFunctions?"":"btn-not-allowed"}" data-action="toggle-dialog">+添加</div>`}</div>`:"",o=s.length?`<div class="all-functions ${this._showDialog?"show":""}">
|
|
3707
3707
|
<label>添加功能<i class="btn btn-close" data-action="toggle-dialog"></i></label>
|
|
3708
3708
|
<div class="functions">
|
|
3709
3709
|
${s.map(n=>{const l=Mt(n);return`<div class="function"><span>${l}</span><i class="btn btn-add" data-action="add-function" data-function="${l}">+</i></div>`}).join("")}
|
|
@@ -3728,7 +3728,7 @@ ${t.name}`)}break}}}}else r.texture_lod=0}};ae=new WeakMap,Me=new WeakMap,Ai=new
|
|
|
3728
3728
|
</div>
|
|
3729
3729
|
</div>
|
|
3730
3730
|
</div>
|
|
3731
|
-
`,this._needsRender=!1}handleShadowClick(e){const t=e.target;if(!t)return;t.closest(".info")&&(e.preventDefault(),e.stopPropagation());const i=t.closest("[data-action]");if(!i)return;const s=i.getAttribute("data-action");if(s)switch(e.preventDefault(),e.stopPropagation(),s){case"remove-device":this.removeDevice();break;case"remove-function":{const r=i.getAttribute("data-function");r&&this.dispatchEvent(new CustomEvent("function-removed",{detail:r}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const r=i.getAttribute("data-function");r&&(this.dispatchEvent(new CustomEvent("function-added",{detail:r})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",nn);const J={ON_DROP:"slot-on-drop",ON_DEVICE_DELETED:"slot-on-device-deleted",ON_DEVICE_REPLACED:"slot-on-device-replaced",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_ADD_BUTTON_CLICKED:"slot-add-button-clicked",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class as extends be.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new Ye,this._slotContainer=new f.Group,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this._parentPos=new f.Vector3,this._wrapper=new f.Group,this._showSlot=!0,this._isMirror=!1,this.beforeInstall=void 0,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),t.setAttribute("data-ui-type","slot"),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new nn({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot()}}),this._slotUI.slot=this,this._slotUI.hide=!this._showSlot||this.isMirror,t.append(this._slotUI),this._parentPos.copy(this.props.slot.position),this._slotUI.addEventListener("function-removed",({detail:i})=>{this.removeFunction(i)}),this._slotUI.addEventListener("function-added",({detail:i})=>{this.addFunction(i)}),this.add(this._slotContainer),this.props.slot.add(this),setTimeout(()=>{var i;(i=this.props.slot.parent)==null||i.add(this._wrapper),this._wrapper.add(this.props.slot)},10),["dragenter","dragover","dragleave","drop"].forEach(i=>{t.addEventListener(i,this._preventDefaults,!1)}),t.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.toBeInstalled?this._emitter.emit(J.ON_ADD_BUTTON_CLICKED):this.selected=!this.selected}),t.addEventListener("dragover",i=>{if(i.preventDefault(),i.dataTransfer.dropEffect="copy",!this._canInstall){i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}}),t.addEventListener("drop",async i=>{var r;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(r=i.dataTransfer)==null?void 0:r.getData("application/json");if(s){const o=JSON.parse(s);try{await this.install(o),this._emitter.emit(J.ON_DROP,this)}catch(c){this._emitter.emit(J.ON_DROP_ERROR,c)}}else this._emitter.emit(J.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){if(this.props.follows.has(e)){const i=this.props.follows.get(e);if(i){let s="x";["height","mast"].includes(e)?s="z":["width","liftOuterWidth"].includes(e)&&(s="y");const r=i.initPos[s]>0?1:-1;this._wrapper.position[s]=(t-i.origin)*i.scale*r}}}async loadGlb(e){const i=await new Ut({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new Ut({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(r=>{r.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){var t;if(!this._loading){this._loading=!0,this.beforeInstall&&typeof this.beforeInstall=="function"&&await((t=this.beforeInstall)==null?void 0:t.call(this,e));try{const i=await this.loadGlb(e.url);if(!i)throw new Error(`Fail to load device from: ${e.url}`);if(i.traverse(s=>{s.userData.isDevice=!0}),this.isMirror&&i.scale.set(1,1,-1),e.bracketUrl){const s=await this.loadGlb(e.bracketUrl);if(s)this.clearSlot(),s.traverse(r=>{r.name.startsWith("Slot")&&this._bracketSlots.push(r),r.userData.isBracket=!0}),this._slotContainer.add(s);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(r=>{r.add(i)})}else this.clearSlot(),this._slotContainer.add(i);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._currentDeivceLoaded=i,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1),this._emitter.emit(J.ON_DEVICE_REPLACED,i)}catch(i){throw i}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._functions.forEach(t=>{e.includes(t)||this._functions.delete(t)}),this._allFunctions=new Set(e),this._slotUI.allFunctions=e}get functions(){return[...this._functions]}addFunction(e){this._allFunctions.has(e)&&(this._functions.add(e),this._slotUI.functions=[...this.functions],this._emitter.emit(J.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(J.ON_FUNCTION_REMOVED,e))}clearFunctions(){this._functions.forEach(e=>this.removeFunction(e))}addFunctions(e){e.forEach(t=>this.addFunction(t)),this._slotUI.functions=this.functions}changeName(e){var t;this.name=e,this.props.slot.userData.name=e,this.props.name=e,(t=this.element)==null||t.setAttribute("data-name",this.props.name)}clearSlot(){this._emitter.emit(J.ON_DEVICE_DELETED,this._currentDeivceLoaded),this._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),De(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._currentDeivceLoaded=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}get disabled(){return this._slotUI.disable}enable(){this.show(),this._slotUI.disable=!1}disable(){this._slotUI.disable=!0,this.hide()}hide(){this._slotUI.hide=!0}show(){this.isMirror||this.disabled||(this._slotUI.hide=!1)}get selected(){return this._selected}get focused(){return this._focused}set focused(e){this._focused=e,this._slotUI.focused=e}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){this._toBeInstalled=e,this._slotUI.toBeInstalled=e}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){this._toBeReplaced=e,this._slotUI.toBeReplaced=e}set selected(e){this.disabled||(e&&this._emitter.emit(J.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(J.ON_SELECTED,e),this.element.style.zIndex="100",this.selected?this.renderOrder=1/0:this.renderOrder=1)}get deviceSelected(){return this._deviceSelected}set deviceSelected(e){this._deviceSelected=e,this._emitter.emit(J.ON_DEVICE_SELECTED,e)}get error(){return this._hasError}set error(e){this._loading&&setTimeout(()=>{this.error=e},100),this._hasError=e,this._slotUI.hasError=e,this._emitter.emit(J.ON_ERROR_STATE_CHANGE,e)}getCanInstall(){return this._canInstall}canInstall(e){this._canInstall=e,this._slotUI.canInstall=e}dispose(){cancelAnimationFrame(this._timer),["dragenter","dragover","dragleave","drop"].forEach(e=>{this.element.addEventListener(e,this._preventDefaults,!1)}),this.props.follows.clear(),this.clearSlot(),this._emitter.removeAllListeners(),De(this._slotContainer),this.element.remove()}render(e){const t=this.element.style.transform,i=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);if(!i)return;const s=new f.Vector2(parseFloat(i[1]),parseFloat(i[2])),r=e.mousePos.distanceTo(s);let o=this.props.isMobile?12:18,c=38,h=30;if(this._canInstall&&(o=34,c=60,h=60),r<h){let u=(h-r)*1+o;r<20&&(u=c),u>c&&(u=c),this._slotUI.setSize(u)}else this._slotUI.setSize(o)}clone(e){return new f.Group}}class dl extends be.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=Cs(),s=i?"#ddd":"#eee";this.element.style.pointerEvents="auto",this.element.style.padding=i?"2px 6px":"3px 12px",this.element.style.borderTop=`1px solid ${s}`,this.element.style.borderBottom=this.element.style.borderTop;const r="6px",o=document.createElement("div");o.style.pointerEvents="none",Object.assign(o.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:r,width:"100%"}),this.element.append(o);const c=document.createElement("div");c.style.pointerEvents="none",Object.assign(c.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",bottom:"0",boxSizing:"border-box",height:r,width:"100%"}),this.element.append(c),this._text.style.fontSize=i?"10px":"14px",this._text.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif",this._text.style.color="#fff",this._text.style.fontWeight="500",this._text.style.transition="all .16s",this._text.innerText=e,this.element.append(this._text),this._text.addEventListener("pointermove",()=>{var h;o.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(h=this.onPointMove)==null||h.call(this)}),this._text.addEventListener("pointerleave",()=>{var h;o.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(h=this.onPointLeave)==null||h.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class vi extends f.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new dl(""),this._line.frustumCulled=!1,this.add(this._line,this._line2),this._showText&&(this.add(this._text),this._text.onPointMove=()=>{this._line.material.color.set("#000"),this._line2.material.color.set("#000")},this._text.onPointLeave=()=>{this._line.material.color.set("#666"),this._line2.material.color.set("#666")})}updateMaterial(e){this._line.material=e}reset(){var e,t;(e=this._line.geometry)==null||e.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line.computeLineDistances(),(t=this._line2.geometry)==null||t.dispose(),this._line2.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line2.computeLineDistances()}update(e,t,i=0){var d,g;(d=this._line.geometry)==null||d.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,r=new f.Vector3().subVectors(t,e).normalize();let o;Math.abs(r.z)>Math.abs(r.x)&&Math.abs(r.z)>Math.abs(r.y)?o=new f.Vector3(-r.y,r.x,0):Math.abs(r.y)>Math.abs(r.x)?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0),o.length()<.001&&(Math.abs(r.x)<.9?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0)),o.normalize();const c=new f.Vector3().addVectors(e,o.clone().multiplyScalar(s)),h=new f.Vector3().addVectors(e,o.clone().multiplyScalar(-s)),u=new f.Vector3().addVectors(t,o.clone().multiplyScalar(s)),p=new f.Vector3().addVectors(t,o.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new f.BufferGeometry,this._line2.geometry.setFromPoints([c,h,u,p]),this._line2.computeLineDistances();const n=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(n*1e3).toFixed(0)} mm`:this._text.text=`${(n*1e3).toFixed(0)} mm`;const l=new f.Vector3;l.addVectors(e,t).multiplyScalar(.5),this._text.position.copy(l),this.useStartEnd||(this._line2.visible=!1)}destroy(){this._text.dispose(),this.children.forEach(e=>De(e)),this.removeFromParent()}}class on extends f.Object3D{constructor(e,t){super(),this.radius=e,this._text=new pl(""),this._line=new vi(void 0,!1,!1),this._box=new f.Mesh,this._arc=new Rr.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new f.RingGeometry(e,e+.003,128),this._box.material=new f.MeshBasicMaterial({color:"#666",side:f.DoubleSide}),this._arc.geometry=new $i.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new Er.LineMaterial({color:"#eee",linewidth:2,resolution:new f.Vector2(window.innerWidth,window.innerHeight)}),this._arc.visible=!1,this._arc.rotateX(-Math.PI/2),this.position.y=t,this._arc.position.y=.001,this.add(this._box),this.add(this._arc),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1,this._arc.visible=!1}show(){this._text.show(),this._line.visible=!0}dispose(){this._updateTimer&&(clearTimeout(this._updateTimer),this._updateTimer=null),this._box.geometry&&this._box.geometry.dispose(),this._arc.geometry&&this._arc.geometry.dispose(),this._arc.visible=!1,this._previousPosition=null}update(e){var t;this.radius=e,(t=this._box.geometry)==null||t.dispose(),this._box.geometry=new f.RingGeometry(e,e+.003,128),this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06*e,gapSize:.06*e})),this._text.update((e*1e3).toFixed(0))}change(e){const t=e.clone();t.setZ(0),t.normalize().multiplyScalar(this.radius),this._text.position.set(t.x,t.y,t.z),this._text.updateColor("#eee"),this._line.update(t,new f.Vector3),this._previousPosition&&this._updateArc(this._previousPosition,t),this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._previousPosition=null,this._accumulatedAngle=0,this._lastAngle=null,this._clearArc(),this._updateTimer=null},this._updateDelay),this._previousPosition||(this._previousPosition=t.clone(),this._lastAngle=Math.atan2(t.y,t.x),this._accumulatedAngle=0)}_updateArc(e,t){const i=Math.atan2(t.y,t.x);if(this._lastAngle!==null){let h=i-this._lastAngle;h>Math.PI?h-=2*Math.PI:h<-Math.PI&&(h+=2*Math.PI),this._accumulatedAngle+=h}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),r=s+this._accumulatedAngle;let o=.006*this.radius;o<.003&&(o=.003),o>.006&&(o=.006);const c=this._createArcGeometry(s,r,this.radius+o);this._arc.geometry&&this._arc.geometry.dispose(),this._arc.geometry=c,this._arc.visible=!0}_clearArc(){this._text.updateColor(),this._arc.geometry&&(this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.computeLineDistances()),this._arc.visible=!1}_createArcGeometry(e,t,i){const s=[],r=t-e,o=Math.max(128,Math.floor(Math.abs(r)/(Math.PI/128))),c=r/o;for(let u=0;u<=o;u++){const p=e+u*c,n=Math.cos(p),l=Math.sin(p);s.push(i*n,0,i*l)}const h=new $i.LineGeometry;return h.setPositions(s),h.instanceCount=Math.max(0,s.length/3-1),h}}class pl extends be.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=Cs();this._wrapper.style.fontSize=i?"10px":"11px",this._wrapper.style.color="#fff",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.top="6px",this._wrapper.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif";const s=this._circle;s.style.position="relative",s.style.zIndex="10",s.style.width=s.style.height="5px",s.style.borderRadius="50%",s.style.background="#666",t.append(this._wrapper,s),this.update(e)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(e){this._wrapper.innerText="旋转半径:"+e+" mm",this.updateColor("#eee")}updateColor(e="#666"){this._circle.style.background=e}}const ml="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",gl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",hr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAYAAACPZlfNAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAdzSURBVHic7Z3hlZs6EIUvW4E7CB3EHcQdxB08OngugVTg8yrwSQVOKnBSwW4qsFOB3cF9PxhZQsYYjEAS1neOD7ssCwPXMxoNIGWIDJJLAAsASwCfAOTyey6bLOQDABf5qJ9P8vkry48sy05j2+ySzLcBjyC5QiXOV1kuWv+hPxcAvwD8BvCBSsRL6394JDjBSC4ArFEJtG7Y5ILqwp4A/JHlxfyoC04yN/4vh/bEz9Dim9uY+/8O4EfI4nmFZEFyz1veSe5Iri0BXB13Icfekjxaxz6TPMixXXt2fJDM5WLZF+og63MPNi1IbsQGW7zyJYUToXZyEUxP8iLSPUS80hLvdYQTobbWN3fHKvMLGpKrBq/bzla4htC3C8mbutIg3JnkxrddzhCvil4omwbhDqy6IPEisV5xJFn4tsk1rDJI8wtZ+rapN+JV73PzqnuwSk7MtvkQzflabdUxGsMdIGFSnfuZZFPHPxysELjnXDOoFsTbzAJA6dumRiyxSt/2+Ma6Hlvf9lyRb9QumjAwIZKQqOLAznvEEbFUcvFS7VVXWO/WvHsTLYnVnSBEM8JgEqsDlmi7qQ++TWL1xxKtnOqgKvs5J7H6I6KdJxFNsh5FygafxLqOxVgHme6b8QIYkWqcZoW6Mr13vvMXhboi8u56x+a34eXKTWMhXSO3SQirgqZi5WSniSvS1ChyFztUoTCcetjMoNGnHbqjTQqF42P1z4pnd7IwssKUwo8Mq/uIz2eN1NWMg3vzxoUWvu3pihEa+zU/4l3RJhoRC/ZcAkKdxkfnXUC8ggE1L+tWILbartW45o1D5IIpL+tWq43du4C4BQNqXlY82jB67wJmIdhSTG/vl1FXkaP1LiB+wQCA+m5+Ya5/s7b7V5a/J7Eq0cZ/svza+FcrHEZd1ZiJh5kp/q0e1D3tqMMhMA/BgFodt1DrzJD4jyx/TmpVoo3vsqyHxTmFQ2BWHpY3ngP1Pa9h5f1AmItgQC1bXAE6JKpXVn94sSrRxocsl4AW7Iss/0xuTuIRKqfQ7dic2i9gdiHxWlu0V8yi/QLmJRhQc6jlG3T7lYboCRfVji3eoMda+mjeNhEAJ1ku31ANYQekhCNklDafTA87eTEl0YWTLHNTsNSGhYvSZvEGPWDkyY8t1xt2ua/jd0Uyah/jYinBcvt+2OTIBTgAOHi6GJ3wbKeOfkaOn09sRNM4VGcXF8N1P0wiwNmyMx+63x7HV48dnuHqpJ40ZMNbBovmUrAGsRSTjuB2PRefgokhZcPFGCSaK8FaxCqf3ecAW66Cea8juhbNhWCBiaXridRtSD61IZZRzkQbKlhIYok9ut5rCOY9Q3Ml2hDBQhNLbKoJdpBfVr4MMnEh2rOChSiW2KWeCHg3X4wO5h2woaI9I1ioYolt6gHf/RuMOpU/k+pkWVYC+GatXmCkTit1p9hOvL6JLb7JZXky+0LTjn/UgWc9rY+HhexZCuqXIzZmfAzyAdJnROsqWAxiAbUnp9bmmxJn34bdo69oXQSLRSwAt10veqwndqVFtKJh21bBWD2WHotYuo5orDzIymAyxSbuiEZbtDbBqN8hCF4soGbv3lwZbOJh00W0e4LFJhZQG81hY67UHbMIeCRak2AxigXU2q+V/QdF7sWynrSJ1nFdDGJd2y/axXnqikfhx7z+tIjWhdK3/Y+gbqpuu1yM9IU+Nt8EfUQU00ex4YU+84/m6Df55NYNgPdDXhOFb3u7wLZwaGwUXVhUdBSt8G1nV9hlvBTjpKPIFm0eiFb4tq8P7No3ZkA3NJ/hjmiFb7v6QN3Nuh8OjY3VCQffib6HJVrh256+GN5Vdtk4ZwS1xUeIaIVvO/rSy7uMf9rF7mWx0su7jH9SD31E7WWxwfoI5v0eO6QuOiYvmwgOGcGcLkZ6TnSG+kGb7m1Xw05UtnVMoXE8WJ8hYljZjL4mKXsh6HIE85SAjAvHmCqFabKcUeAYk+UYO1ePWqXpqBxBXWx3f0vLyhpL5wd4MYyoNd7bnKzX6IJ+wipkOOXUlJN8M2YMfUxNaSUh+SQHnQFWszLtfGxME2/3whJr+j4t09T2nbHE8jO1vRiSRHtAMGIZBi2M8HhO2aNGskGVYOy8i2VCXQ+bLvsJGNYfci1929OIZeQ+qG/UREjE2QcvlsIKA0cGMjrBFFjt1ZGx3EcUww/Gt2w7Z2+T890Z5/seZQJmhcjjHBMSVuW6o3GepW+bBsHqfo/pbYc5hMkGrzpG6VX3YPWWyTl24e4IVfi2axRYZVBm+h+NcKxGHdhZtm9n5VX3EOHKBo8rGVByIt5UUFdzKDbvXkIomzvCKfE2PsQzRDpYNh1lfT61TcEhwq3lItniHSX0FGMIKAKtxWveecueAbVRmW8DbESUNaopHpe4HbDrhGqU6Q9UMyao309qgyzLTsa+7E8O4LMsm/YPVPOo/QTwI8uyoMbzD04wE7ngS/l8AbBC8wUeghL/J4CPLMt+Od6/U4IWrAlpQ5aoPOSTLHNoIRfGzxfoMd9P0J74F5VIlyzLopok6H/tVqA8kSYfTwAAAABJRU5ErkJggg==",_l="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYwAAACsCAYAAABo4pvIAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAzYSURBVHic7d3hcdtIEobhD05gmYGRgbkRLDKwMjiGoBCUgeoi0F0Evo1AdASiIxAcgbkR9P1Aj9mESIm2QMwAeJ8qlihKomeXwHzsHgCsBBTOzGpJK7+pd7/2r3+ceCw69Vh8nkvt/fbW4/H7vaR//H4bfqeNX6uqij8DilPlHgCWxcxW6ibvNFmn+x/DY/Fn0mHyPXVLE7F0ejKOf3/SpRO1B9c55wJNOg6rfrD1/5v7/31pbN97j7WS9lVVnf3vAoZGYGAwPqHW6ia+tbrJce0/Tj+Lk176+k/4/ui2tAnRA/VUaNbqQjXdr8PvtDoOku/xeyoXDIXAwMXMbK1DGHzUcTikiatVN1l9Uy8YmLiG1wuY2r9+0vHrUuvwOux0/PrseF1wKQIDR06EQvw+TTatunexrXgXOwmh+ku31AJc6xAoMUxaESboITAWyoOhVjdhfAr307vQnbpQ2KlrDe2yDBSj8EBJ20S/Qml12B7S/XZp7UIQGLMX3lk2Og6Gnbqd/1u4zySAI+EghRQmH9VtS7W6bWYrKpLFIDBmJFQNf6nbwdOCc6oYvqqrFrY5xof56AXJJ53e3r5J2hIi80FgTFRoIcRwaP32Vb7TUjFgTCdaW426thYhMgMExgT4u7m1Dm2lxn+UqoatCAcUyrffRodqpPEfbcWbm0khMAoUdrBUPTTyUFC3g7UsQmPKvBJpdNzOiq3TLQFSHgKjAKGM/6xDOb+T9Le6d17bXGMDxmJmjY73g1aHRfX/ESD5ERgZhBbTZx2OOCEggOCVAEn7CQEyMgJjJL2Nv9Hxhr/NNS5gKnr7UK0uQNiHMH1mtjKzGzN7MLNnvz34Rg/gHXz/aszs3vetH75/bbyCB8pmZrVvsI/WeTSzWz8/AsCV+L536/vcj7Dv1bnHBvxkZmt/l/MUqogb3uUAefSqjx++X95R3SOLEBK0moDCER4Y3YmQuKfVBEyLh8dd2I8JDwzD+6J3hAQwP2fCo849LkyI9z/TwnVqNxESwIyF8IgL5qxD4jTfYB786KYvZnaTe0wAxudzQTraivVJdE60nDaUpACkn92GuxAed1QdCxSqCY5wAvCm3pFWj8wZM2eHk+p+VhO5xwRgWrzqSCcIPrHWMTMeFGltgmoCwCB6ax33tLMnzM+biG2nOveYAMxPWAulXTU1vUNiuRAZgFGERfJngqNwrE8AKEVoVz0xHxWEoABQqhAczE85ERQApiIEB62qMREUAKaK4BiJH4nwRFAAmDqC40rCeRQEBYBZ8Y5JumZVnXs8k9U7RO0u93gA4Br6cx2nAvyisE5B6gJYBA+OB684uFr2W3rtpzr3eABgbL31jTr3eIoUTq2/yz0WAMjNugsbPpvZbe6xFMOrimfSFACO+fyYzhhvco8nq1BVkKAAcIZXGz/M7D73WEYXqgoWtQHgAr1qo849nlGEvtwm91gAYGoWsbbBEVAAMIxw5YvH2Z23EVpQy+u/AcAV+Hkb9z63rnOPZxBhsWa+5RMAZDKbFlVIvzr3WABgrsbq4ny4xpOm/pqklaQ/q6pqr/HvAAAkn2P/lLSa1FFUIenuco8FAJYmXMiwzj2WVxEWAJBfCI0yF8PN7MYXtze5xwIASxeu+t3kHsuRMLAy0wwAFsjM1kW9kQ9hUeceCwDgWFgq2OQeSPp4wTrrQAAAZ3lo5Ks0QljQhgKAwmVrT1n3iVCEBQBMSAiNcebuUNrwmbMAMDF+ROv11539Ylf5F08AAL8tXH+qvuY/8sgVZwFg+vzkvqdrPfm9mT1e5ckBAKPz604NWwSM1vMCAIxm8HM0wiI3R0QBwMz4kVPDFAS+bjHtD+YAAJzli+DvW3IY5EkAAMV715XGaUUBwHKEOb/+nT/+wudaAMBy+KG2D7/6R42XJ6srjQsAUCCf+y+/kocvdDfXGxIAoETpIysu/eWGhW4AWK6Lz83w6oILCwLAQl1UZaS1i5HGBAAo1JtrGV5dbMYbEgCgRF5lnF6e8EuX/xh5TACAQvUvGfIh/OxW0n/GHhAAoFhbSS/bUp4kzdijAQCU6eS6dvqM7kxjAgAUKhYTqSW1Fu0oAMBLW3UZ0eHMbgDAKUcnc6ejo7huFACgzzPCpK4lVUvaV1W1zzoqAEBxPBt2ZtZ8UNeb2uYdEgCgYK2k9QdJnyR9yzsWAEDBvkr6mFpSbdahAABKtpNXGGtJrF8AAF6zSudhtDlHAQAo2l4hMAAAOGcvaaV0fC0AAOeYmVFhAAAu8kHSPl7vHACAyDOi/aDUmwIA4BUEBgDgLbV0CAwAAM5ZSdp9kJ/Bl3kwAIBy1fI1jO+S/so7FgBAwT5J+pYqjDrvWAAABWvUZUV3QgYfoAQA6IsfspdO3NuKdQwAwEtrSbuqqvYpMP6W9K+MAwIAlOmzuozo+Id8P+cbDwCgRN6OavoPPr94EACwWP1iIl588N+iLQUAOPgs6b8vHjWzmrYUACBJR0el739WGFVVtZJaM9tkGBcAoCCeBbuqqk5fPsrMbqgyAAAXrWv7L21GGREAoDhePDxe8osbqgwAWC4ze7z4qFmqDABYJj+U9u3qIvwBaxkAsDB+3ahfPyfPzB7M7O4qowIAFMfM7szsy+/8Ye3H4NbDDwsAUBIzW79rzve0oTUFADPnC923+Z8EAFAsM7v9pYXuV56o9kUQPi8DAGbm3a2oE0+48dAY5gkBANmFguBm6Ce+N7OnQZ8UAJCNLzncX+vJnzjUFgCmz4uA969bvPIPpPKFRXAAmKiwzLB6+7ff9w9dp+cFALg6v5LHeOfYhVV1jpwCgIkIc3cz9j+8ITQAYBpCWGxyDWAzamkDAPhl4VJPm9wD4RwNAChUWHfe5B6LJNpTAFAib0OVExaJf+hGeQMDgAUKb+TLPKI1pNld7rEAwFKlK40Xv1QQ+mV3uccCAEszmbBIPDSe/FP7rnsmIQAgfbzqg8+9de7x/DK/Vsl0kg4AJih0dq5zIcGx+AdzcP0pALgCn2N/zGaODYvh97SoAGAYs+3ieH/tcbL9NQAoRGhBPcx6PqVFBQC/L1xdYxlzaDiK6nHW6QgAA/F582GWLahLeP9tPos1AHAFYWH7LvdYsvJLilBtAECPVxWPi60qzmFtAwAO/IxtqopzQpo+2tifCAUABVjMEVBDscNnznJpEQCL0FvU3uQez6T4eRvpIlp3BAeAuWKuG0hI3fwfLwgAAwrnVNB+GpIfTcX6BoDJC0HBlS+uieAAMFUhKFinGBPBAWAqCIpChBeC4ABQFIKiUP7CPBEcAHIjKCYitKo4RA3AaPxUgNjx2OQeEy4UguOHB0ede0wA5qd3wt2Dma1zjwm/yV/MdFVc2lUABuFvSh+sw3kUc+Ll4m1Y57ilXQXgV/XXJwiKmeu1q+6pOgC8JlQTqe3U5B4TRmaH61WldhWL5AAk/Wxnx2qCtVB0wjsI1jqABbPuatlfwtpEk3tMKFRY64hHWDW5xwXgesxsHVpOj15Z0G3A5bwkTZcdfiY8gPnwkLin5YTBecuK8AAm7ERI3HPeBK6qFx4caQUUrHeEEyGBfM6FB/1PIA9fh7wJIfFESKA4vuYRF8wf/fs699iAOfNWU9r3LCxc17nHBrzJDhciS4fqplKY6gMYwIlW04NXFuxfV1LlHsBS+BrHWtJnSbWkVtLfknZVVW1zjQuYit4+1Ejain1oVARGBv4OKG74taSd2PiBn3oBsVb3Jmurw36yzzW2pSIwCuABciPpkwgQLNSZgIj7QZtrbOgQGAXyAGkk/aVux1mr23F2kr5J2rLzYMr8iKVah228UVc97CR9VbeNU0EUhsCYgNDCWqvbwRr/0VZdgOzEDoZChe230SEgpMP2uxUtpkkgMCbKDxds1LWxUpjsddgJW1HGY2Qn3tzUOrRYU/XAdjlRBMaMnAkR6bidtZPU8m4O7+VrDisdt06l43Boq6raZRkgBkdgzJyHSOoXx0X1Vl018l2HxUWCBEe8Yqj9tla3DaX7O3XbTmortVQO80ZgLFCYBFKQfAz39+omgr1obS2GL0KndlLaHtJjMRjSGwuqhgUiMHDkREWyCt+3OoRJqkxa8c6yeP66xttH/5pe3/S67tS9tjtJe4IBEYGBi4UwWek4TFLF0uplhbIPj+9peQ0vhMEqfP0Uvq91/Lq0IhTwGwgMDKb3Lnalw7vY9H0tDw4dqhPpUK1IIVy0wIDxduGpWy3pD70MhpWO/1/uJP2jEA5UfxgKgYFRhQmx1vGk99F/JT6WbvverfXf3aubHJM23E+/27//wqUT6htXPk1jTeoz9//Q6UCIf9/q5X/zd/WqNXGQAkZGYKB4YaLuf43300QsvZy8+9+/9fhrzoVP+8pjMdjiY0eBRiWA0v0fPGR4m68wwtkAAAAASUVORK5CYII=";class ur extends be.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this.isController=!0,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new Ye,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeListener=this._emitter.removeListener.bind(this._emitter),this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let n=(Date.now()-this._startAt)/200;n>4&&(n=4);let l=this._initial+.005*n*this._direction;if(l>this.props.max||l<this.props.min){this.mechanism&&(l<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):l>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=l,!this.mechanism)return;this.mechanism.position.setZ(l),this._emitter.emit("change",l)}},i.setAttribute("data-ui-type","mechanism");const s=Cs();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(n=>{n.name===e.userData.target.name&&(this.mechanism=n)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const r=n=>{n.stopPropagation()},o=n=>{n.preventDefault(),n.stopPropagation()},c={capture:!1,passive:!0},h={capture:!1,passive:!1};["pointerdown","pointerup","pointermove","pointercancel","click","dblclick","contextmenu","mousemove"].forEach(n=>{i.addEventListener(n,r,c)}),["wheel","dragenter","dragover","dragleave","drop"].forEach(n=>{i.addEventListener(n,o,h)});const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.transform="translateX(-50%) rotate(-180deg)",u.style.marginBottom="5px",u.style.width=u.style.height=s?"34px":"44px",u.style.background=`url(${hr}) center no-repeat`,u.style.backgroundSize="100% auto",u.setAttribute("data-direction","up"),u.style.transition="all .2s";const p=document.createElement("div");if(p.style.position="absolute",p.style.left="0",p.style.transform="translateX(-50%)",u.style.bottom=p.style.top="8px",p.style.width=p.style.height=u.style.width,p.style.background=`url(${hr}) center no-repeat`,p.style.backgroundSize="100% auto",p.style.transition="all .2s",p.setAttribute("data-direction","down"),Array.from([u,p]).forEach(n=>{s||n.addEventListener("mousemove",()=>{n.style.filter="invert(100%)"}),n.addEventListener("mouseleave",()=>{n.style.filter=""}),n.addEventListener("pointerdown",()=>{this.mechanism&&(n.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=n.getAttribute("data-direction")==="up"?1:-1,this._update())}),n.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),n.style.filter=""}),n.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),n.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:n,rotateDuration:l,rotateStep:d,rotateMax:g,rotateMin:v}=e.userData;let m;if(n&&(t.traverse(_=>{_.name===n.name&&(m=_)}),m)){const _=document.createElement("div");_.style.background=`url(${_l}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.position="absolute",_.style.top="-50%",_.style.left="-50%",_.style.width=s?"140px":"160px",_.style.height=s?"70px":"80px",_.style.transform="translateX(-50%) translateY(-50%)",i.append(_);const y=document.createElement("div");y.style.background=`url(${gl}) center no-repeat`,y.style.backgroundSize="100% auto",y.style.width=y.style.height=s?"20px":"26px",y.style.position="absolute",y.style.top="0",y.style.transform="translateY(-50%)",y.style.marginBottom="5px",y.setAttribute("data-direction","left"),i.append(y);const w=document.createElement("div");w.style.background=`url(${ml}) center no-repeat`,w.style.backgroundSize="100% auto",w.style.width=w.style.height=s?"20px":"26px",w.style.position="absolute",y.style.left=w.style.right=s?"62px":"69px",w.style.top="0",w.style.transform="translateY(-50%)",w.style.marginBottom="5px",w.setAttribute("data-direction","right"),i.append(w),Array.from([y,w]).forEach(x=>{s||x.addEventListener("mousemove",()=>{x.style.filter="invert(100%)"}),x.addEventListener("mouseleave",()=>{x.style.filter=""}),x.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;x.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=x.getAttribute("data-direction")==="left"?1:-1;let b=d/180*Math.PI*this._direction+m.rotation.z;b>g/180*Math.PI?b=g/180*Math.PI:b<v/180*Math.PI&&(b=v/180*Math.PI),this._timer=new wi(m.rotation).to({z:b}).duration(l).start(),this._update()}),x.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),x.style.filter=""}),x.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),x.style.filter=""})})}}i.append(u,p),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix()}hide(){this.element.style.display="none",this.traverse(e=>{e.visible=!1,e instanceof be.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof be.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class vl extends Rn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new Ye,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new f.Vector2,this._targetSize=new f.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=h=>{const{pageX:u,pageY:p}=h;this.endNode.setPointerCapture(h.pointerId),this._mouseStart.set(u,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=h=>{if(!this._mouseStart.x)return;const{pageX:u,pageY:p}=h;let n=u-this._mouseStart.x,l=n+this._targetSize.x;this._sizeFlag==="height"&&(n=p-this._mouseStart.y,l=n*this._direction+this._targetSize.y);const d=l%10;l=l-d,n=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(n=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=h=>{this.endNode.releasePointerCapture(h.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,r=s.distanceTo(i);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const o=document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.bottom="0",t.append(o),this._textNode=document.createElement("div"),this._textNode.innerText=r.toFixed(2)+" m",o.append(this._textNode);const c=document.createElement("div");this.endNode=c,c.style.position="absolute",c.style.left="auto",c.style.right="0",c.style.width="4px",c.style.height="4px",c.style.background="#0066FF",c.style.borderRadius="50%",c.style.margin="-2px -2px 0 0",c.style.cursor="pointer",o.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",o.style[this._sizeFlag]=r*100+"px",o.style.textAlign="center",this._sizeFlag==="height"?(o.style.borderLeft="0.1px dashed #fff",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):o.style.borderBottom="0.1px dashed #fff",c.addEventListener("pointerdown",this._pointerdown),c.addEventListener("pointermove",this._pointermove),c.addEventListener("pointerup",this._pointercancel),s[this.props.axios]<i[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(e=>e.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(e=>e.clear()),this._caches=[]}}class yl extends f.Object3D{constructor(){super(),this._box3=new f.Box3,this._line11=new vi("长:"),this._line12=new vi("宽:"),this._line13=new vi("高:"),this._outline=new on(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this.head=0,this.tail=0,this._change=()=>{if(!this._app)return;const e=this._app.camera;e&&this._outline.change(e.position)},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(e){this._app=e,this._app.controls.addEventListener("change",this._change)}reset(){this.hide(),this._line11.reset()}generate(e,t=0){e&&(this._object=e),this.update(t)}show(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!0,this._outline.visible=!0,this._outline.show(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!0,s instanceof be.CSS2DObject&&(s.element.style.visibility="visible")})})}hide(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!1,this._outline.visible=!1,this._outline.hide(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!1,s instanceof be.CSS2DObject&&(s.element.style.visibility="hidden")})})}destroy(){var e;(e=this._app)==null||e.controls.removeEventListener("change",this._change),this._line11.destroy(),this._line12.destroy(),this._line13.destroy()}update(e=0){if(!this._object)return;const t=this._object,{box:i,maxRadius:s,hasLength:r,hasHeight:o,hasWidth:c}=sl(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=r,this._hasHeightConfig=o,this._box3.copy(i),this._radius=s,this.follow&&e&&(this.originOffset=(this.followOrigin-e)*this.followScale),this._outline.update(this._radius),this._change();const h=this._box3.min.x,u=this._box3.max.x,p=this._box3.min.z,n=this._box3.max.z,l=this._box3.min.y,d=this._box3.max.y;let g=.2;const v=new f.Vector3(h,d,0),m=new f.Vector3(u,d,0);this._line11.update(v.clone().sub(new f.Vector3(0,-g/1.8,0)),m.clone().sub(new f.Vector3(0,-g/1.8,0)),this._radius);const _=new f.Vector3(u,l,0);this._line12.update(m.clone().add(new f.Vector3(g,0,0)),_.clone().add(new f.Vector3(g,0,0)),this._radius);const y=new f.Vector3(h,d,p),w=new f.Vector3(h,d,n),x=y.clone();x.y-=g/6;const b=w.clone();b.y-=g/6,this._line13.update(x,b,this._radius)}}class xe extends f.Mesh{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._lineMaterial=new f.LineDashedMaterial({color:new f.Color("#000"),dashSize:.015,gapSize:.015}),this._currentLength=.6,this._currentWidth=.4,this._currentHeight=.2,this.material=new f.MeshBasicMaterial({color:new f.Color("#0f5fd5"),transparent:!0,opacity:.4}),this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}dispose(){var t,i,s,r,o;(t=this.lineSegments)==null||t.removeFromParent(),(s=(i=this.lineSegments)==null?void 0:i.geometry)==null||s.dispose(),this.lineSegments=void 0,(r=this.geometry)==null||r.dispose();const e=this.material;Array.isArray(e)?e.forEach(c=>{var h;return(h=c==null?void 0:c.dispose)==null?void 0:h.call(c)}):(o=e==null?void 0:e.dispose)==null||o.call(e),this._lineMaterial.dispose(),this.clear()}clearAll(){this.dispose()}clone(e){return new xe(this._currentLength,this._currentWidth,this._currentHeight)}_generate(e,t,i){De(this),this.clear(),this.geometry.dispose(),this.geometry=new f.BoxGeometry(e,t,i),this.geometry.translate(0,0,i/2);const s=new f.EdgesGeometry(this.geometry);this.lineSegments=new f.LineSegments(s,this._lineMaterial),this.add(this.lineSegments),this.lineSegments.geometry.dispose(),this.lineSegments.geometry=s,this.lineSegments.computeLineDistances()}}const xl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class ls{constructor(e){this._props=e,this.name="",this.transparentTexture=Ds.load(xl),this._offscreen=new OffscreenCanvas(0,0),this._defaults={...e},this.target=e.target,this.parent=this.target.parent,this.reset()}get imageSize(){return this._props.imageSize}get size(){return this._props.size}get defaultConfigs(){return{canvasWidth:200,canvasHeight:200,scaleX:1,scaleY:1,x:0,y:0,ox:0,oy:0,url:this._defaults.imageUrl}}clear(){this.change()}change(e,t=new f.Vector2(1,1),i=new f.Vector2){this.imageUrl=e;let s;if(e){const r=new Image;r.crossOrigin="anonymous",r.src=e,r.onload=async()=>{var u;let o=window.devicePixelRatio*2;this._offscreen.width=r.width+o,this._offscreen.height=r.height+o;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(r,o/2,o/2,r.width,r.height),s=new f.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=f.SRGBColorSpace,s.wrapS=s.wrapT=f.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const h=this._props.target;h.material&&((u=h.material.map)==null||u.dispose(),s?(h.material.map=s,h.material.opacity=1):(h.material.map=this.transparentTexture,h.material.opacity=0))}}else{const r=this._props.target;r.material&&(r.material.map=this.transparentTexture)}}reset(){this._props=this._defaults,this.name=this._props.name,this.imageUrl=this._props.imageUrl,this.target=this._props.target,this.change(this.imageUrl||"")}dispose(){this._offscreen=null}}function Vi(a){return a.type?a.type==="Mesh":a.isMesh}class fr{constructor(e,t){this.links=[],this.target=new f.Vector3,this.targetQuaternion=new f.Quaternion,this.iterations=15,this.minDistance=.001,this.maxStep=.35,this.damping=.35,this.maxAngleDelta=.8,this._restQuaternions=[],this._initialRestQuaternions=[],this._axesLocal=[],this._axisMins=[],this._axisMaxs=[],this._jointStates=[],this._frameAppliedAbsDelta=[],this._jointWeights=[],this._stableFrameCount=0,this._lastFramePosErrSq=1/0,this._lastFrameOriErr=1/0,this._tmpEffectorPos=new f.Vector3,this._tmpTargetPos=new f.Vector3,this._tmpLinkPos=new f.Vector3,this._tmpAxisWorld=new f.Vector3,this._tmpVToEff=new f.Vector3,this._tmpVToTar=new f.Vector3,this._tmpProjE=new f.Vector3,this._tmpProjT=new f.Vector3,this._tmpCross=new f.Vector3,this._tmpEffWorldQ=new f.Quaternion,this._tmpTarWorldQ=new f.Quaternion,this._tmpDirCurP=new f.Vector3,this._tmpDirTarP=new f.Vector3,this._tmpDirCurS=new f.Vector3,this._tmpDirTarS=new f.Vector3,this._tmpAxisQ=new f.Quaternion,this._tmpParentWorldQ=new f.Quaternion,this._tmpLocalBeforeQ=new f.Quaternion,this._tmpWorldBeforeQ=new f.Quaternion,t&&(typeof t.iterations=="number"&&(this.iterations=t.iterations),typeof t.minDistance=="number"&&(this.minDistance=t.minDistance),typeof t.maxStep=="number"&&(this.maxStep=t.maxStep),typeof t.damping=="number"&&(this.damping=t.damping),typeof t.maxAngleDelta=="number"&&(this.maxAngleDelta=t.maxAngleDelta),t.orientation&&(this.orientation=Object.assign({enabled:!1},t.orientation))),this.links=(Array.isArray(e)?e:[]).map(s=>{const r=Array.isArray(s.axes)&&s.axes.length>0?s.axes.map(o=>({axis:o.axis.clone(),min:o.min,max:o.max,value:o.value})):void 0;return{object:s.object,ikTcp:!!s.ikTcp,weight:typeof s.weight=="number"?s.weight:void 0,axes:r}});const i=this.links.map(s=>s.object);this._axesLocal=i.map((s,r)=>this._normalizeAxesForLink(r)),this._axisMins=i.map((s,r)=>this._getAxisMinsForLink(r)),this._axisMaxs=i.map((s,r)=>this._getAxisMaxsForLink(r)),this._restQuaternions=i.map((s,r)=>{var u;const o=s.quaternion.clone(),c=this._axesLocal[r],h=this.links[r];if(c&&c.length>0&&h.axes)for(let p=c.length-1;p>=0;p--){const n=c[p],l=((u=h.axes[p])==null?void 0:u.value)??0;Math.abs(l)>1e-6&&(this._tmpAxisQ.setFromAxisAngle(n,l).invert(),o.multiply(this._tmpAxisQ))}return o}),this._initialRestQuaternions=this._restQuaternions.map(s=>s.clone()),this._jointStates=i.map((s,r)=>{var u;const o=((u=this._axesLocal[r])==null?void 0:u.length)??0,c=this.links[r],h=new Array(o).fill(0);if(c.axes&&c.axes.length>0)for(let p=0;p<o;p++)h[p]=c.axes[p].value??0;return{currentAngle:h[0]??0,prevAngle:h[0]??0,currentAngles:h,prevAngles:[...h]}}),this._frameAppliedAbsDelta=i.map((s,r)=>{var o;return new Array(((o=this._axesLocal[r])==null?void 0:o.length)??0).fill(0)}),this._jointWeights=this._buildJointWeights(t==null?void 0:t.weightProfile)}_buildJointWeights(e){var u;const t=(e==null?void 0:e.root)??.3,i=(e==null?void 0:e.middle)??.68,s=(e==null?void 0:e.end)??1,r=Math.max(1,(e==null?void 0:e.curve)??1),o=this.links.length,c=this.links.some(p=>typeof p.weight=="number"),h=[];for(let p=0;p<o;p++){const n=(u=this.links[p])==null?void 0:u.weight;if(c&&typeof n=="number"&&Number.isFinite(n)){h[p]=Math.max(0,n);continue}if(o<=1){h[p]=Math.max(0,s);continue}const l=p/(o-1),d=l<=.5?Math.pow(l/.5,r):Math.pow((l-.5)/.5,r),g=l<=.5?t+(i-t)*d:i+(s-i)*d;h[p]=Math.max(0,g)}return h}_normalizeAxesForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>{const s=i.axis.clone();return s.lengthSq()>0&&s.normalize(),s}):[]:[]}_getAxisMinsForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>i.min):[]:[]}_getAxisMaxsForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>i.max):[]:[]}_applyLinkAngles(e){var o;const t=(o=this.links[e])==null?void 0:o.object;if(!t)return;const i=this._axesLocal[e],r=this._jointStates[e].currentAngles??[];t.quaternion.copy(this._restQuaternions[e]);for(let c=0;c<i.length;c++){const h=i[c],u=r[c]??0;!h||h.lengthSq()<1e-12||Math.abs(u)<1e-12||(this._tmpAxisQ.setFromAxisAngle(h,u),t.quaternion.multiply(this._tmpAxisQ))}}_getAxisWorld(e,t,i){var u;const s=(u=this.links[e])==null?void 0:u.object;if(!s)return i.set(0,0,0);const r=this._axesLocal[e],o=r==null?void 0:r[t];if(!o||o.lengthSq()<1e-12)return i.set(0,0,0);s.parent?s.parent.getWorldQuaternion(this._tmpParentWorldQ):this._tmpParentWorldQ.identity(),this._tmpLocalBeforeQ.copy(this._restQuaternions[e]);const h=this._jointStates[e].currentAngles??[];for(let p=0;p<t;p++){const n=r[p],l=h[p]??0;!n||n.lengthSq()<1e-12||Math.abs(l)<1e-12||(this._tmpAxisQ.setFromAxisAngle(n,l),this._tmpLocalBeforeQ.multiply(this._tmpAxisQ))}return this._tmpWorldBeforeQ.copy(this._tmpParentWorldQ).multiply(this._tmpLocalBeforeQ),i.copy(o).applyQuaternion(this._tmpWorldBeforeQ).normalize()}resetToInitialPose(){for(let e=0;e<this.links.length;e++){const t=this._initialRestQuaternions[e];t&&(this._restQuaternions[e].copy(t),this.links[e].object.quaternion.copy(t));const i=this._jointStates[e];i.currentAngles&&i.currentAngles.fill(0),i.prevAngles&&i.prevAngles.fill(0),this._frameAppliedAbsDelta[e]&&this._frameAppliedAbsDelta[e].fill(0)}this.links.length>0&&this.links[0].object.updateMatrixWorld(!0)}get restQuaternions(){return this._restQuaternions}_isOrientationEnabled(){var e;return!!((e=this.orientation)!=null&&e.enabled)}_getEndIndices(){var o,c;let e=-1;for(let h=0;h<this.links.length;h++)(o=this.links[h])!=null&&o.ikTcp&&(e=h);e<0&&(e=this.links.length-1);const t=!!((c=this.links[e])!=null&&c.ikTcp),i=t?e:this.links.length-1;let s=-1;for(let h=i;h>=0;h--){const u=this._axesLocal[h];if(u&&u.length>0){s=h;break}}return s<0&&(s=Math.max(0,Math.min(this.links.length-1,i))),{ikTcpIndex:e,effectorJointIndex:s,orientationEvalIndex:t?e:s}}_getOrientationDefaults(){var l,d,g,v,m,_,y;const{effectorJointIndex:e,orientationEvalIndex:t}=this._getEndIndices(),i=e,s=this._getOrientationChainStartIndex(i),r=(((l=this.orientation)==null?void 0:l.forwardAxis)??new f.Vector3(1,0,0)).clone().normalize(),o=(((d=this.orientation)==null?void 0:d.upAxis)??new f.Vector3(0,0,1)).clone().normalize(),c=(((g=this.orientation)==null?void 0:g.targetForwardAxis)??new f.Vector3(1,0,0)).clone().normalize(),h=(((v=this.orientation)==null?void 0:v.targetUpAxis)??new f.Vector3(0,0,1)).clone().normalize(),u=((m=this.orientation)==null?void 0:m.forwardWeight)??1,p=((_=this.orientation)==null?void 0:_.upWeight)??.15,n=((y=this.orientation)==null?void 0:y.minAngle)??Math.PI/180;return{effectorIndex:i,orientationEvalIndex:t,orientationStartIndex:s,effectorForwardAxis:r,effectorUpAxis:o,targetForwardAxis:c,targetUpAxis:h,forwardWeight:u,upWeight:p,minAngle:n}}_orientationErrorAngle(){if(!this._isOrientationEnabled()||this.links.length<1)return 0;const{orientationEvalIndex:e,effectorForwardAxis:t,effectorUpAxis:i,targetForwardAxis:s,targetUpAxis:r,forwardWeight:o,upWeight:c}=this._getOrientationDefaults();this.links[Math.max(0,Math.min(this.links.length-1,e))].object.getWorldQuaternion(this._tmpEffWorldQ),this._tmpTarWorldQ.copy(this.targetQuaternion),this._tmpDirCurP.copy(t).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarP.copy(s).applyQuaternion(this._tmpTarWorldQ).normalize();let u=o*this._angleBetweenNormalized(this._tmpDirCurP,this._tmpDirTarP);return c>0&&(this._tmpDirCurS.copy(i).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarS.copy(r).applyQuaternion(this._tmpTarWorldQ).normalize(),u+=c*this._angleBetweenNormalized(this._tmpDirCurS,this._tmpDirTarS)),u}_angleBetweenNormalized(e,t){const i=Math.max(-1,Math.min(1,e.dot(t)));this._tmpCross.crossVectors(e,t);const s=this._tmpCross.length();return Math.atan2(s,i)}_getOrientationChainStartIndex(e){let t=0;for(let i=e;i>=0;i--){const s=this._axesLocal[i];if(s&&s.length>0&&(t+=s.length),t>=3)return i}return 0}bindRestPose(){for(let e=0;e<this.links.length;e++){this._restQuaternions[e].copy(this.links[e].object.quaternion);const t=this._jointStates[e];t.currentAngle=0,t.prevAngle=0,t.currentAngles&&t.currentAngles.fill(0),t.prevAngles&&t.prevAngles.fill(0)}}updateJointStateFromCurrentPose(){var e;for(let t=0;t<this.links.length;t++){const i=(e=this.links[t])==null?void 0:e.object;if(!i)continue;const s=this._restQuaternions[t],r=i.quaternion;this._updateLinkAnglesFromQuaternion(t,r,s),this._frameAppliedAbsDelta[t]&&this._frameAppliedAbsDelta[t].fill(0)}}rebindRestPoseWithBase(e){var t;for(let i=0;i<this.links.length;i++){const s=(t=this.links[i])==null?void 0:t.object;if(!s)continue;const r=e[i]??s.quaternion,o=s.quaternion;this._restQuaternions[i].copy(r),this._initialRestQuaternions[i]&&this._initialRestQuaternions[i].copy(r),this._updateLinkAnglesFromQuaternion(i,o,r),this._frameAppliedAbsDelta[i]&&this._frameAppliedAbsDelta[i].fill(0)}}_updateLinkAnglesFromQuaternion(e,t,i){const s=this._axesLocal[e]??[],r=this._jointStates[e];r.currentAngles||(r.currentAngles=new Array(s.length).fill(0)),r.prevAngles||(r.prevAngles=new Array(s.length).fill(0));const o=this._tmpLocalBeforeQ.copy(i).invert().multiply(t),c=this._tmpWorldBeforeQ.copy(o);for(let h=0;h<s.length;h++){const u=s[h];if(!u||u.lengthSq()<1e-12){r.currentAngles[h]=0,r.prevAngles[h]=0;continue}const p=this._tmpVToEff.set(c.x,c.y,c.z).dot(u);this._tmpAxisQ.set(u.x*p,u.y*p,u.z*p,c.w).normalize();const n=2*Math.atan2(p,this._tmpAxisQ.w);r.currentAngles[h]=n,r.prevAngles[h]=n,this._tmpParentWorldQ.copy(this._tmpAxisQ).invert(),c.premultiply(this._tmpParentWorldQ)}r.currentAngle=r.currentAngles[0]??0,r.prevAngle=r.currentAngle}get jointStates(){return this._jointStates}_clamp(e,t,i){return t!==void 0&&e<t&&(e=t),i!==void 0&&e>i&&(e=i),e}_signedAngleAroundAxis(e,t,i){const s=e.dot(i),r=t.dot(i);this._tmpProjE.copy(e).addScaledVector(i,-s),this._tmpProjT.copy(t).addScaledVector(i,-r);const o=this._tmpProjE.lengthSq(),c=this._tmpProjT.lengthSq(),h=1e-10;if(o<h||c<h)return 0;const u=Math.sqrt(o),p=Math.sqrt(c);this._tmpProjE.multiplyScalar(1/u),this._tmpProjT.multiplyScalar(1/p);const n=this._tmpProjE.dot(this._tmpProjT);this._tmpCross.crossVectors(this._tmpProjE,this._tmpProjT);const l=i.dot(this._tmpCross),d=Math.max(-1,Math.min(1,n));let g=Math.atan2(l,d);const v=Math.min(u,p),m=Math.sin(Math.PI/180*4.6),_=Math.sin(Math.PI/180*30);if(v<=m)return 0;if(v<_){const y=(v-m)/(_-m);g*=Math.max(0,Math.min(1,y))}return g}update(){var C,I,D;if(this.links.length<2)return;const{ikTcpIndex:e,effectorJointIndex:t}=this._getEndIndices(),i=this.links[Math.max(0,Math.min(this.links.length-1,e))].object,s=this._tmpEffectorPos,r=this._tmpTargetPos.copy(this.target),o=this._tmpLinkPos,c=this._tmpAxisWorld,h=this._tmpVToEff,u=this._tmpVToTar;let p=this._isOrientationEnabled();const n=p?this._getOrientationDefaults():void 0;i.getWorldPosition(s);const l=this.minDistance*this.minDistance,d=(n==null?void 0:n.minAngle)??Math.PI/180,g=s.distanceToSquared(r),v=p?this._orientationErrorAngle():0,m=g<=l,_=!p||v<=d,y=this.minDistance*2,w=y*y,x=d*2,b=g<=this._lastFramePosErrSq*1.5&&(!p||v<=this._lastFrameOriErr*1.5);if(m&&_||g<=w&&(!p||v<=x))if(b){if(this._stableFrameCount++,this._stableFrameCount>=2){this._lastFramePosErrSq=g,this._lastFrameOriErr=v;return}}else this._stableFrameCount=0;else this._stableFrameCount=0;this._lastFramePosErrSq=g,this._lastFrameOriErr=v;for(let A=0;A<this._frameAppliedAbsDelta.length;A++)this._frameAppliedAbsDelta[A]&&this._frameAppliedAbsDelta[A].fill(0);for(let A=0;A<this._jointStates.length;A++){const S=this._jointStates[A];if(S.prevAngle=S.currentAngle,S.prevAngles&&S.currentAngles)for(let P=0;P<S.currentAngles.length;P++)S.prevAngles[P]=S.currentAngles[P]}let T=g,M=v,L=0;for(let A=0;A<this.iterations;A++){i.getWorldPosition(s);const S=s.distanceToSquared(r),P=S<l,R=p?this._orientationErrorAngle():0,k=!p||R<=d;if(P&&k)break;if(S>=T*.9&&(!p||R>=M*.5)){if(L++,L>=2)break}else L=0;T=S,M=R;let F=0,z=p?t:e===t?t-1:t;z=Math.max(0,Math.min(this.links.length-1,z));for(let B=z;B>=0;B--){const N=this.links[B].object,W=this._axesLocal[B];if(!(!W||W.length===0))for(let O=0;O<W.length;O++){const j=W[O];if(!j||j.lengthSq()<1e-12||(i.getWorldPosition(s),N.getWorldPosition(o),this._getAxisWorld(B,O,c),c.lengthSq()<1e-12))continue;let U=0;if(!(B===t&&e===t)){h.subVectors(s,o),u.subVectors(r,o);const X=h.lengthSq(),ee=u.lengthSq();X>=1e-12&&ee>=1e-12&&(h.multiplyScalar(1/Math.sqrt(X)),u.multiplyScalar(1/Math.sqrt(ee)),U+=this._signedAngleAroundAxis(h,u,c))}if(p&&B>=n.orientationStartIndex&&B<=n.effectorIndex){this.links[Math.max(0,Math.min(this.links.length-1,n.orientationEvalIndex))].object.getWorldQuaternion(this._tmpEffWorldQ),this._tmpTarWorldQ.copy(this.targetQuaternion),this._tmpDirCurP.copy(n.effectorForwardAxis).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarP.copy(n.targetForwardAxis).applyQuaternion(this._tmpTarWorldQ).normalize();const ee=this._signedAngleAroundAxis(this._tmpDirCurP,this._tmpDirTarP,c);let Rs=0;n.upWeight>0&&(this._tmpDirCurS.copy(n.effectorUpAxis).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarS.copy(n.targetUpAxis).applyQuaternion(this._tmpTarWorldQ).normalize(),Rs=this._signedAngleAroundAxis(this._tmpDirCurS,this._tmpDirTarS,c)),U+=n.forwardWeight*ee+n.upWeight*Rs}if(Math.abs(U)<1e-6)continue;const Ze=Math.max(0,this._jointWeights[B]??1);if(Ze<=0)continue;if(U*=Math.max(0,Math.min(1,this.damping))*Ze,this.maxStep>0){const X=this.maxStep*Ze;if(X<=0)continue;U>X?U=X:U<-X&&(U=-X)}if(this.maxAngleDelta>0){const X=((C=this._frameAppliedAbsDelta[B])==null?void 0:C[O])??0,ee=Math.max(0,this.maxAngleDelta-X);if(ee<=0)continue;U>ee?U=ee:U<-ee&&(U=-ee)}const _e=this._jointStates[B];_e.currentAngles||(_e.currentAngles=new Array(W.length).fill(0));const Gt=(_e.currentAngles[O]??0)+U,Nt=(I=this._axisMins[B])==null?void 0:I[O],ve=(D=this._axisMaxs[B])==null?void 0:D[O];U=this._clamp(Gt,Nt,ve)-(_e.currentAngles[O]??0),!(Math.abs(U)<1e-9)&&(_e.currentAngles[O]=(_e.currentAngles[O]??0)+U,_e.currentAngle=_e.currentAngles[0]??0,Math.abs(U)>F&&(F=Math.abs(U)),this._frameAppliedAbsDelta[B]&&(this._frameAppliedAbsDelta[B][O]=(this._frameAppliedAbsDelta[B][O]??0)+Math.abs(U)),this._applyLinkAngles(B),N.updateMatrixWorld(!0))}}if(F<1e-5&&S<=l*4&&(!p||R<=d*2))break}}}const Re=new f.Raycaster,Ct=new f.Vector3,wl=new f.Quaternion,dr=new f.Vector3,pr=new f.Vector3,Wi={type:"change"},mr={type:"mouseDown",mode:null},gr={type:"mouseUp",mode:null},bl={type:"objectChange"},ei=new WeakMap,ti=new WeakMap,Dt=new WeakMap;function Al(a){if(!this.domElement)return{x:0,y:0,button:a.button};if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-((a.clientY-e.top)/e.height)*2+1,button:a.button}}function ii(a,e,t){const i=e.intersectObject(a,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}function Ui(a){return a==="E"?"rotate":a==="XYZ"?"translate":null}class Tl extends f.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("FreeTransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(e=>{const t=e;t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}const $=class $ extends f.Object3D{constructor(e){super(),this.picker=new f.Object3D,this.gizmo=new f.Object3D,this.helper=new f.Object3D,this._matMove=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1}),this._matRing=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1}),this._matInvisible=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:0}),this._matHelper=new f.LineBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:.6}),this._arcSegments=96,this._arcStartAngleOffset=.05,this._moveColorDefault=new f.Color(16777215),this._moveColorActive=new f.Color(0),this._moveOpacityDefault=1,this._moveOpacityRingActive=.5,this._ringColorDefault=new f.Color(16777215),this._ringColorActive=new f.Color(0),this._ringOpacityDefault=1,this._ringOpacityActive=.6,this._ringScale=1,this._ringTargetScale=1.5,this._ringScaleTweening=!1,this._isMoveActive=!1,this._isRingActive=!1,this._isMoveHover=!1,this._isDragging=!1,this._isExpanded=!1,this.controls=e,this._moveMesh=new f.Mesh(new f.CircleGeometry($.MOVE_RADIUS,96),this._matMove),this._moveMesh.rotateX(-Math.PI/2),this._moveMesh.name="XYZ",this._moveMesh.renderOrder=1/0,this._ringMesh=new f.Mesh(new f.TorusGeometry($.RING_RADIUS,$.RING_TUBE,48,96),this._matRing),this._ringMesh.name="E",this._ringMesh.renderOrder=1e3,this._arcGeom=new $i.LineGeometry,this._arcPositions=new Float32Array((this._arcSegments+1)*3),this._arcGeom.setPositions(this._arcPositions),this._arcGeom.instanceCount=0;const t=new Er.LineMaterial({color:16777215,linewidth:2,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1});t.resolution.set(window.innerWidth,window.innerHeight),this._arcLine=new Rr.Line2(this._arcGeom,t),this._arcLine.renderOrder=1001,this._arcLine.visible=!1,this.gizmo.add(this._ringMesh),this.gizmo.add(this._moveMesh),this.gizmo.add(this._arcLine);const i=new f.Mesh(new f.CircleGeometry($.PICKER_MOVE_RADIUS,32),this._matInvisible);i.name="XYZ",i.renderOrder=1/0;const s=new f.Mesh(new f.TorusGeometry($.RING_RADIUS+.005,$.PICKER_RING_TUBE,8,48),this._matInvisible);s.name="E",s.renderOrder=1/0,this.picker.add(s),this.picker.add(i),this.picker.visible=!1;const r=new f.OctahedronGeometry(.01,2),o=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:.7});this._startMarker=new f.Mesh(r,o),this._startMarker.renderOrder=1/0,this._startMarker.visible=!1,this._endMarker=new f.Mesh(r,o),this._endMarker.renderOrder=1/0,this._endMarker.visible=!1,this._deltaGeom=new f.BufferGeometry,this._deltaGeom.setAttribute("position",new f.Float32BufferAttribute(new Float32Array(2*3),3)),this._deltaLine=new f.Line(this._deltaGeom,this._matHelper),this._deltaLine.renderOrder=1/0,this._deltaLine.visible=!1,this.helper.add(this._startMarker),this.helper.add(this._endMarker),this.helper.add(this._deltaLine),this.add(this.gizmo),this.add(this.picker),this.add(this.helper)}get isExpanded(){return this._isExpanded}set isExpanded(e){var s;if(this._isExpanded===e)return;this._isExpanded=e;const t=e?this._ringTargetScale:1;this._ringScaleTweening=!0,(s=this._ringScaleTween)==null||s.stop();const i={scale:this._ringScale};this._ringScaleTween=new ne.Tween(i).to({scale:t},200).easing(ne.Easing.Quadratic.Out).onUpdate(()=>{this._ringScale=i.scale}).onStop(()=>{this._ringScaleTweening=!1}).onComplete(()=>{this._ringScaleTweening=!1}).start()}get isRingScaleTweening(){return this._ringScaleTweening}updateMatrixWorld(e){var y,w;const t=this.controls,i=t.axis,s=t.mode,r=t.worldPosition,o=t.size;this._arcLine.material.resolution.set(window.innerWidth,window.innerHeight);const h=(x,b=1)=>{x.position.copy(r),x.scale.set(1,1,1).multiplyScalar(o*b),x.visible=!0};h(this._moveMesh),h(this._ringMesh,this._ringScale),h(this._arcLine,this._ringScale),this.picker.position.copy(r),this.picker.scale.set(1,1,1).multiplyScalar(o);for(const x of this.picker.children)x.quaternion.copy(t.cameraQuaternion),x.scale.set(1,1,1).multiplyScalar(this._ringScale);this._ringMesh.quaternion.copy(t.cameraQuaternion),this._arcLine.quaternion.copy(t.cameraQuaternion),this._moveMesh.lookAt(t.cameraPosition);const u=s==="default"||s==="translate",p=s==="default"||s==="rotate";this._moveMesh.visible=u,this._ringMesh.visible=p;for(const x of this.picker.children)x.name==="XYZ"&&(x.visible=u),x.name==="E"&&(x.visible=p);const n=t.dragging,l=!n&&i==="XYZ",d=!n&&i==="E",g=l||n&&i==="XYZ",v=d||n&&i==="E";if(g!==this._isMoveActive){this._isMoveActive=g;const x=g?this._moveColorActive:this._moveColorDefault;(y=this._moveColorTween)==null||y.stop();const b={r:this._matMove.color.r,g:this._matMove.color.g,b:this._matMove.color.b};this._moveColorTween=new ne.Tween(b).to({r:x.r,g:x.g,b:x.b},200).easing(ne.Easing.Quadratic.Out).onUpdate(()=>{this._matMove.color.setRGB(b.r,b.g,b.b)}).start()}if(v!==this._isRingActive){this._isRingActive=v;const x=v?this._ringColorActive:this._ringColorDefault,b=v?this._ringOpacityActive:this._ringOpacityDefault,T=v?this._moveOpacityRingActive:this._moveOpacityDefault;this._matMove.opacity=T,(w=this._ringColorTween)==null||w.stop();const M={r:this._matRing.color.r,g:this._matRing.color.g,b:this._matRing.color.b,opacity:this._matRing.opacity};this._ringColorTween=new ne.Tween(M).to({r:x.r,g:x.g,b:x.b,opacity:b},200).easing(ne.Easing.Quadratic.Out).onUpdate(()=>{this._matRing.color.setRGB(M.r,M.g,M.b),this._matRing.opacity=M.opacity}).start()}const m=n;if(this._startMarker.visible=m,this._endMarker.visible=m,this._deltaLine.visible=m,m){this._startMarker.position.copy(t.worldPositionStart),this._endMarker.position.copy(t.worldPosition),this._startMarker.scale.set(1,1,1).multiplyScalar(o),this._endMarker.scale.set(1,1,1).multiplyScalar(o);const x=this._deltaGeom.getAttribute("position");x.setXYZ(0,t.worldPositionStart.x,t.worldPositionStart.y,t.worldPositionStart.z),x.setXYZ(1,t.worldPosition.x,t.worldPosition.y,t.worldPosition.z),x.needsUpdate=!0,this._deltaGeom.computeBoundingSphere()}const _=m&&p&&i==="E";if(this._arcLine.visible=_,_){const x=t.pointStart,b=t.pointEnd;if(x.lengthSq()>1e-12&&b.lengthSq()>1e-12){dr.set(1,0,0).applyQuaternion(t.cameraQuaternion),pr.set(0,1,0).applyQuaternion(t.cameraQuaternion);const T=x.dot(dr),M=x.dot(pr),L=Math.atan2(M,T),C=t.rotationAngle;if(Math.abs(C)<1e-4)this._arcLine.visible=!1,this._arcGeom.instanceCount=0;else{const I=this._arcSegments,D=Math.max(2,Math.min(I,Math.ceil(Math.abs(C)/(Math.PI*2)*I))),A=C/D,S=$.RING_RADIUS,P=Math.sign(C)*this._arcStartAngleOffset;for(let F=0;F<=D;F++){const z=L+P+A*F,B=Math.cos(z)*S,N=Math.sin(z)*S,W=F*3;this._arcPositions[W]=B,this._arcPositions[W+1]=N,this._arcPositions[W+2]=0}for(let F=D+1;F<=I;F++){const z=F*3;this._arcPositions[z]=0,this._arcPositions[z+1]=0,this._arcPositions[z+2]=0}this._arcGeom.setPositions(this._arcPositions),this._arcGeom.instanceCount=D,this._arcLine.computeLineDistances(),this._arcGeom.computeBoundingSphere();const R=Math.cos(L)*$.RING_RADIUS*this._ringScale,k=Math.sin(L)*$.RING_RADIUS*this._ringScale;Ct.set(R,k,0),Ct.applyQuaternion(t.cameraQuaternion),Ct.multiplyScalar(o),Ct.add(r),this._startMarker.position.copy(Ct)}}else this._arcLine.visible=!1,this._arcGeom.instanceCount=0}else this._arcGeom.instanceCount=0;super.updateMatrixWorld(e)}};$.RING_RADIUS=.18,$.RING_TUBE=.003,$.PICKER_RING_TUBE=.025,$.MOVE_RADIUS=.04,$.PICKER_MOVE_RADIUS=.2;let cs=$;class Sl extends f.Mesh{constructor(){super(new f.PlaneGeometry(1e5,1e5,2,2),new f.MeshBasicMaterial({visible:!1,wireframe:!0,transparent:!0,opacity:.1,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),this.isTransformControlsPlane=!0}updateMatrixWorld(e){const t=this,i=t.dragging?t.worldPositionStart:t.worldPosition;this.position.copy(i),this.quaternion.copy(t.cameraQuaternion),super.updateMatrixWorld(e)}}class Ml extends f.EventDispatcher{constructor(e,t=null){super(),this.domElement=null,this._offset=new f.Vector3,this._startNorm=new f.Vector3,this._endNorm=new f.Vector3,this._cameraScale=new f.Vector3,this._parentPosition=new f.Vector3,this._parentQuaternion=new f.Quaternion,this._parentQuaternionInv=new f.Quaternion,this._parentScale=new f.Vector3,this._worldScaleStart=new f.Vector3,this._worldQuaternionInv=new f.Quaternion,this._worldScale=new f.Vector3,this._positionStart=new f.Vector3,this._quaternionStart=new f.Quaternion,this._scaleStart=new f.Vector3,this._capturePointerId=null,this._captureDocument=null,this._hoverShieldActive=!1;const i=new Tl(this);this._root=i;const s=new cs(this);this._gizmo=s,i.add(s);const r=new Sl;this._plane=r,i.add(r);const o=this;function c(h,u){let p=u;Object.defineProperty(o,h,{get(){return p!==void 0?p:u},set(n){p!==n&&(p=n,r[h]=n,s[h]=n,o.dispatchEvent({type:h+"-changed",value:n}),o.dispatchEvent(Wi))}}),o[h]=u,r[h]=u,s[h]=u}c("camera",e),c("object",void 0),c("enabled",!0),c("depthTest",!0),c("axis",null),c("mode","default"),c("space","world"),c("size",.25),c("dragging",!1),c("gizmoPriority",!0),c("worldPosition",new f.Vector3),c("worldPositionStart",new f.Vector3),c("worldQuaternion",new f.Quaternion),c("worldQuaternionStart",new f.Quaternion),c("cameraPosition",new f.Vector3),c("cameraQuaternion",new f.Quaternion),c("pointStart",new f.Vector3),c("pointEnd",new f.Vector3),c("rotationAxis",new f.Vector3),c("rotationAngle",0),c("eye",new f.Vector3),this._getPointer=Al.bind(this),this._onPointerDown=this._handlePointerDown.bind(this),this._onPointerHover=this._handlePointerHover.bind(this),this._onPointerMove=this._handlePointerMove.bind(this),this._onPointerUp=this._handlePointerUp.bind(this),this._onPointerDownCapture=this._handlePointerDownCapture.bind(this),this._onPointerMoveCapture=this._handlePointerMoveCapture.bind(this),this._onPointerUpCapture=this._handlePointerUpCapture.bind(this),this._onMouseMoveCapture=this._handleMouseMoveCapture.bind(this),t!==null&&this.connect(t)}connect(e){this.domElement=e,this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none";const t=this.domElement.ownerDocument;this._captureDocument=t,t.addEventListener("pointerdown",this._onPointerDownCapture,!0),t.addEventListener("pointermove",this._onPointerMoveCapture,!0),t.addEventListener("pointerup",this._onPointerUpCapture,!0),t.addEventListener("mousemove",this._onMouseMoveCapture,!0)}disconnect(){this.domElement&&(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.domElement.style.touchAction="auto",this._captureDocument&&(this._captureDocument.removeEventListener("pointerdown",this._onPointerDownCapture,!0),this._captureDocument.removeEventListener("pointermove",this._onPointerMoveCapture,!0),this._captureDocument.removeEventListener("pointerup",this._onPointerUpCapture,!0),this._captureDocument.removeEventListener("mousemove",this._onMouseMoveCapture,!0),this._captureDocument=null))}getHelper(){return this._root}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this.dragging=!1,this._setHoverShieldActive(!1),this._root.visible=!1,this}getMode(){return this.mode}setMode(e){this.mode=e,this.axis=null,this.dispatchEvent(Wi)}setSize(e){this.size=e}getRaycaster(){return Re}_handlePointerHover(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e));break}}_handlePointerDown(e){if(!this.enabled||!this.domElement)return;document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove);const t=this._getPointer(e);this.pointerHover(t),this.pointerDown(t)}_handlePointerMove(e){this.enabled&&this.pointerMove(this._getPointer(e))}_handlePointerUp(e){this.enabled&&this.domElement&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}_setHoverShieldActive(e){if(!this.domElement)return;const t=this.domElement.ownerDocument;if(e){if(this._hoverShieldActive)return;this._hoverShieldActive=!0;const r=Dt.get(t)??0;Dt.set(t,r+1);let o=ti.get(t);o||(o=t.createElement("div"),o.style.position="fixed",o.style.left="0",o.style.top="0",o.style.right="0",o.style.bottom="0",o.style.cursor="grab",o.style.pointerEvents="auto",o.style.background="transparent",o.style.zIndex="2147483647",ti.set(t,o)),o.parentElement||t.body.appendChild(o);return}if(!this._hoverShieldActive)return;this._hoverShieldActive=!1;const i=Dt.get(t)??0,s=Math.max(0,i-1);if(s===0){Dt.delete(t);const r=ti.get(t);r!=null&&r.parentElement&&r.parentElement.removeChild(r),ti.delete(t)}else Dt.set(t,s)}_handlePointerDownCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=e.target;if(t&&(t===this.domElement||this.domElement.contains(t)))return;const i=this._getPointer(e);this.pointerHover(i),!(!this.axis||!this._isAxisAllowed(this.axis))&&i.button===0&&(this._capturePointerId=e.pointerId,document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerDown(i))}_handlePointerMoveCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=this._getPointer(e);if(this._capturePointerId===e.pointerId&&this.dragging){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerMove(t);return}this.dragging||(this.pointerHover(t),this.axis&&this._isAxisAllowed(this.axis)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()))}_handleMouseMoveCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=this._getPointer(e);if(this.dragging){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}this.pointerHover(t),this.axis&&this._isAxisAllowed(this.axis)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())}_handlePointerUpCapture(e){!this.enabled||!this.domElement||!this.gizmoPriority||this._capturePointerId===e.pointerId&&(this._capturePointerId=null,this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerUp(this._getPointer(e)))}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Re.setFromCamera(e,this.camera);const t=this._gizmo.picker.children.find(h=>h.name==="XYZ"),i=this._gizmo.picker.children.find(h=>h.name==="E"),s=t?ii(t,Re):!1,r=i?ii(i,Re):!1;let o=this._gizmo.isExpanded,c=null;o?r&&!this._gizmo.isRingScaleTweening?c="E":s?c="XYZ":(o=!1,c=null):s&&(o=!0,c="XYZ"),this._gizmo.isExpanded!==o&&(this._gizmo.isExpanded=o),c&&this._isAxisAllowed(c)?this.axis=c:this.axis=null,this._setHoverShieldActive(!!this.axis||this.dragging),this._updateCursor()}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null&&this._isAxisAllowed(this.axis)){e!==null&&Re.setFromCamera(e,this.camera);const t=ii(this._plane,Re,!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,this._setHoverShieldActive(!0);const i=Ui(this.axis);mr.mode=i,this.dispatchEvent(mr),this._updateCursor()}}pointerMove(e){const t=this.axis,i=this.object;if(i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1||!this._isAxisAllowed(t))return;const s=Ui(t);if(!s)return;e!==null&&Re.setFromCamera(e,this.camera);const r=ii(this._plane,Re,!0);r&&(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate"?(this._offset.copy(this.pointEnd).sub(this.pointStart),this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart)):s==="rotate"&&(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.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(wl.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize()),this.dispatchEvent(Wi),this.dispatchEvent(bl))}pointerUp(e){if(!(e!==null&&e.button!==0)){if(this.dragging&&this.axis!==null){const t=Ui(this.axis);gr.mode=t,this.dispatchEvent(gr)}this.dragging=!1,this.axis=null,this._setHoverShieldActive(!1),this._updateCursor()}}_updateCursor(){if(!this.domElement)return;const e=ei.get(this.domElement);if(this.dragging){this.domElement.style.cursor="grabbing",ei.set(this.domElement,this);return}if(this.axis){this.domElement.style.cursor="grab",ei.set(this.domElement,this);return}e===this&&(this.domElement.style.cursor="",ei.delete(this.domElement))}_isAxisAllowed(e){return this.mode==="default"?e==="XYZ"||e==="E":this.mode==="translate"?e==="XYZ":this.mode==="rotate"?e==="E":!1}}class Cl{constructor(e,t){var n;this.isController=!0,this._enabled=!0,this._tmpQ=new f.Quaternion,this._tmpContainerQ=new f.Quaternion,this._tmpV=new f.Vector3,this._resetHierarchy=!1,this._defaultPoseQuats=new Map,this._zeroPoseQuats=new Map,this._emitter=new Ye,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._initialTargetPos=new f.Vector3,this._initialTargetQuat=new f.Quaternion,this._axesHelpers=[],this._showAxes=!1;const{joints:i,container:s,context:r,resetHierarchy:o}=e,c=(Array.isArray(i)?i:[]).map(l=>l.object);this._container=s,this._context=r,this._resetHierarchy=!!o;let h;if(Array.isArray(i))for(let l=0;l<i.length;l++)(n=i[l])!=null&&n.ikTcp&&(h=i[l].object);this._effector=h??c[c.length-1],this._resetHierarchy&&this.setupHierarchy(c),c.forEach(l=>{l&&(this._defaultPoseQuats.has(l.uuid)||this._defaultPoseQuats.set(l.uuid,l.quaternion.clone()))}),this.transformControls=new Ml(t.camera,t.domElement),this.transformControls.addEventListener("dragging-changed",({value:l})=>{this._emitter.emit("dragging-changed",l),l||this.syncTargetToEffector()}),this.transformControls.addEventListener("axis-changed",({value:l})=>{this.transformControls.dragging||(this.targetObject.visible=l==="E")}),this.targetObject=new f.Object3D,this.targetObject.name="ikTarget",this.targetObject.visible=!1,this.targetObject.userData.isIKTarget=!0,this.transformControls.attach(this.targetObject);const u=new f.AxesHelper(.0675);u.material.depthTest=!1,u.material.depthWrite=!1,u.renderOrder=1e3,this.targetObject.add(u),this.syncTargetToEffector(),this._initialTargetPos.copy(this.targetObject.position),this._initialTargetQuat.copy(this.targetObject.quaternion);const p=this.transformControls.getHelper();this._container.add(this.targetObject),this._container.add(p),this.solver=new fr(i,r),this.solver.links.forEach((l,d)=>{const g=l.object;if(g){const v=this.solver.restQuaternions[d];v&&this._zeroPoseQuats.set(g.uuid,v.clone())}}),c.forEach(l=>{const d=new f.AxesHelper(.2);d.visible=!1,l.add(d),this._axesHelpers.push(d)})}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.transformControls.enabled=e,this.transformControls.getHelper().visible=e}get showAxes(){return this._showAxes}set showAxes(e){this._showAxes=e,this._axesHelpers.forEach(t=>t.visible=e)}getEffectorLocalPos(){var t;const e=new f.Vector3;return this._effector&&(this._effector.getWorldPosition(e),(t=this._container)==null||t.worldToLocal(e)),e}getEffectorLocalQuat(){const e=new f.Quaternion;return this._effector&&(this._effector.getWorldQuaternion(e),this._container&&(this._container.getWorldQuaternion(this._tmpContainerQ),this._tmpContainerQ.invert(),e.premultiply(this._tmpContainerQ))),e}setupHierarchy(e){for(let t=0;t<e.length-1;t++){const i=e[t],s=e[t+1];s.parent!==i&&i.attach(s)}}syncTargetToEffector(){this.targetObject.position.copy(this.getEffectorLocalPos()),this.targetObject.quaternion.copy(this.getEffectorLocalQuat()),this.targetObject.updateMatrixWorld(!0)}syncTargetToSolver(){this.solver&&(this.targetObject.getWorldPosition(this._tmpV),this.solver.target.copy(this._tmpV),this.targetObject.getWorldQuaternion(this._tmpQ),this.solver.targetQuaternion.copy(this._tmpQ))}setControlMode(e){this.transformControls.setMode(e)}setOrientation(e){this.solver&&(this.solver.orientation.forwardAxis=e.forwardAxis,this.solver.orientation.upAxis=e.upAxis)}updateJointChain(e){var h;const t=(Array.isArray(e)?e:[]).filter(u=>!!(u!=null&&u.object));if(t.length<2||!this._container)return;const i=t.map(u=>u.object);i.forEach(u=>{u&&(this._defaultPoseQuats.has(u.uuid)||this._defaultPoseQuats.set(u.uuid,u.quaternion.clone()),this._zeroPoseQuats.has(u.uuid)||this._zeroPoseQuats.set(u.uuid,u.quaternion.clone()))});let s;for(let u=0;u<t.length;u++)(h=t[u])!=null&&h.ikTcp&&(s=t[u].object);this._effector=s??i[i.length-1],this._resetHierarchy&&this.setupHierarchy(i);const r=this.solver,o=new fr(t,this._context);r&&(o.iterations=r.iterations,o.minDistance=r.minDistance,o.maxStep=r.maxStep,o.damping=r.damping,o.maxAngleDelta=r.maxAngleDelta,r.orientation&&o.orientation&&Object.assign(o.orientation,r.orientation));const c=o.links.map(u=>this._zeroPoseQuats.get(u.object.uuid));o.rebindRestPoseWithBase(c),this.solver=o,this._axesHelpers.forEach(u=>u.removeFromParent()),this._axesHelpers=[],i.forEach(u=>{const p=new f.AxesHelper(.2);p.visible=this._showAxes,u.add(p),this._axesHelpers.push(p)}),this.syncTargetToEffector(),this.syncTargetToSolver()}update(){!this._enabled||!this.solver||(this.syncTargetToSolver(),this.solver.update())}toggleOrientation(e){this.solver&&(this.solver.orientation.enabled=e)}setSolverContext(e){this.solver&&(typeof e.iterations=="number"&&(this.solver.iterations=e.iterations),typeof e.damping=="number"&&(this.solver.damping=e.damping))}reset(){if(!(!this.solver||!this._container)){for(const e of this.solver.links){const t=e==null?void 0:e.object;if(!t)continue;const i=this._defaultPoseQuats.get(t.uuid);i&&t.quaternion.copy(i)}this._container.updateMatrixWorld(!0),this.solver.updateJointStateFromCurrentPose(),this.syncTargetToEffector(),this.syncTargetToSolver()}}dispose(){this.transformControls.detach(),this.transformControls.dispose(),this.targetObject.removeFromParent(),this._axesHelpers.forEach(e=>e.removeFromParent()),this._axesHelpers=[]}}const Dl=(a,e,t,i={})=>{const s=[],{resetHierarchy:r,onDraggingChanged:o}=i;return a.forEach(c=>{if(!(c!=null&&c.joints)||c.joints.length<2)return;const h=new Cl({joints:c.joints,container:e,context:{orientation:c.orientation},resetHierarchy:r},t);o&&h.addListener("dragging-changed",u=>{o(h,u)}),s.push(h)}),s},Ds=new f.TextureLoader;Ds.crossOrigin="anonymous";class an extends f.Object3D{constructor(e){super(),this._props=e,this._emitter=new Ye,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new f.Group,this.lines=new f.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new f.Clock,this.sizeBox=new yl,this._goodsSize=new nl(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],this._ikChains=[],this.ikControllers=[],this._ikDraggingControllers=new Set,this._shelfSyncCache=new WeakMap,this._rollerPools=new WeakMap,this._videoCache=new Map,this._rollerColumns=1,this._bodyOpacity=1,this._masts=new Map,this._liftMaxHeight=0,this._jackMaxHeight=0,this._forkMaxHeight=0,this.controllers=[],this.goods=[],this._breathLights=[],this._shelves=new Map,this._shelfMaxLevel=1,this._url="",this._showController=!0,this._showSlots=!0,this._shapeKeys=new Map,this._shapeKeyTargets=new Map,this._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],this._useCenterModel=!1,this._useLift=!1,this._columnCount=1,this._columnGap=.03,this._rowCount=1,this._rowGap=.01,this._levelCount=1,this._currentAction=null,this._pendingFinishedCallback=null,this._url=e.url||"",this._url&&this.load(this._url).then(),this.add(this._container,this.lines),this._props.showSizeBox&&this.add(this.sizeBox),this.showController=typeof e.showController=="boolean"?e.showController:!0,this._showSlots=typeof e.showSlots=="boolean"?e.showSlots:!0}get shapeKeys(){return this._shapeKeys}get size(){const e=this.sizeBox.size.getSize(new f.Vector3);return{width:e.z,length:e.x,height:e.y}}get goodsSize(){return this._goodsSize}get showController(){return this._showController}set showController(e){this._showController=e,this.controllers.forEach(t=>e?t.show():t.hide())}get slots(){return this._slots}get logos(){return this._logos}get skins(){return this._skins}get bodyOpacity(){return this._bodyOpacity}get fork(){return this._fork}get forkHeight(){var e;return((e=this._fork)==null?void 0:e.position.z)||0}get liftHeight(){var e;return this._lift?this._lift instanceof Map?((e=this._lift.get(0))==null?void 0:e.position.z)||0:this._lift.position.z||0:0}get jack(){return this._jack}get jackHeight(){var e;return((e=this._jack)==null?void 0:e.position.z)||0}get lift(){return this._lift}get useCenterModel(){return this._useCenterModel}set useCenterModel(e){this._useCenterModel=e,this._rollerLevel.forEach(t=>{t.traverse(i=>{i.userData.isCenterModel&&(i.visible=e)})})}set bodyOpacity(e){this._bodyOpacity=e,e<1?this._materialsCache.forEach(t=>{t.mat.transparent=!0,t.mat.opacity=e,t.mat.metalness=0,t.mat.roughness=1,t.mat.color=new f.Color("#3859be"),t.mat.needsUpdate=!0}):this._materialsCache.forEach(t=>{t.mat.transparent=t.transparent,t.mat.opacity=t.opacity,t.mat.metalness=t.metalness,t.mat.roughness=t.roughness,t.mat.color=t.color,t.mat.needsUpdate=!0})}init(e){this._app=e,this.sizeBox.init(e),this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=()=>{if(this._mixer){const t=this._animationClock.getDelta();this._mixer.update(t)}else this._animationClock.getDelta();this.ikControllers.forEach(t=>t.update())},this._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{if(this._slots.forEach(s=>s.shapeKeyChanged(t,i)),this.sizeBox.follow===t?(this.sizeBox.generate(this._container,i),this.sizeBox.originOffset&&(this._container.traverse(s=>{s instanceof f.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof as&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new f.Vector3(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0))}),this.sizeBox.translateCache=this.sizeBox.originOffset,this.sizeBox.generate(this._container))):this.sizeBox.generate(this._container),["width","length","height"].includes(t)&&this._emitter.emit("size-changed",t,i),t==="goodsLength"){const s=i;this._goodsSize.length=this._layoutLengthToItemLength(s),this._applyDerivedSizesFromLayoutGoodsLength(s),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize()}t==="goodsWidth"&&(this._goodsSize.width=i,this._applyDerivedSizesFromGoodsWidth(i),this._columnCount>1&&this.setColumns(this._columnCount,!1),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize())})}_syncRollerGoodsBoxesFromGoodsSize(){const e=h=>{var n;const u=[],p=[...h.children];for(;p.length;){const l=p.pop();if((n=l.userData)!=null&&n.isRollerLevelBox){u.push(l);continue}l.children&&l.children.length&&p.push(...l.children)}return u},t=Math.max(1,this._rowCount||1),i=t>1?this._rowGap:0,s=this._goodsSize.length||0,r=this._getLayoutGoodsLength(s),o=s+i,c=t>0?-r/2+s/2:0;this._rollerLevel.forEach(h=>{e(h).forEach(p=>{const n=p.children.filter(l=>l instanceof xe);for(n.forEach(l=>{l.userData.__amrRollerGoodsBox=!0,this.goods.includes(l)||this.goods.push(l)});n.length<t;){const l=new xe(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);l.userData.__amrRollerGoodsBox=!0,p.add(l),this.goods.push(l),n.push(l)}for(let l=t;l<n.length;l++){const d=n[l];this.goods=this.goods.filter(g=>g!==d),d.dispose(),d.removeFromParent()}for(let l=0;l<t;l++){const d=n[l];d.updateSize(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height),d.position.y=c+o*l}})})}_syncShelvesFromGoodsSize(){const e=this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"),t=this._getLayoutGoodsLength(this._goodsSize.length);this._shelves.forEach(i=>{let s=this._shelfSyncCache.get(i);s||(s={container:void 0,morphMeshes:[],goodsBoxes:[]},i.traverse(c=>{var h;if((h=c.userData)!=null&&h.isShelfContainer&&(s.container=c),c instanceof xe&&s.goodsBoxes.push(c),Vi(c)){const u=c,p=u.morphTargetDictionary||{};(Object.prototype.hasOwnProperty.call(p,"goodsWidth")||Object.prototype.hasOwnProperty.call(p,"goodsLength"))&&s.morphMeshes.push(u)}}),this._shelfSyncCache.set(i,s)),s.goodsBoxes.forEach(c=>{c.updateSize(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height)}),s.morphMeshes.forEach(c=>{this.setShapeKeyToMesh(c,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(c,"goodsLength",t)});const r=s.container;if(!r)return;typeof r.userData.__goodsBaseX!="number"&&(r.userData.__goodsBaseX=r.position.x);const o=r.userData.__goodsBaseX;r.position.x=e?o+t/2:o})}_findFirstSkinnedMesh(e){if(!e)return;let t;return e.traverse(i=>{!t&&i.isSkinnedMesh&&(t=i)}),t}async loadAnimation(e,t="sglb"){let i,s;if(t==="glb"||e.endsWith(".glb")){const h=await je.loadAsync(e);i=h.animations||[],s=h.scene}else if(t==="sglb"||e.endsWith(".sglb")){const u=await new Ut({useCache:!0}).loadAsync(e);i=u.animations||[],s=u.scene}else{console.warn("[Amr.loadAnimation] 目前仅支持 glb/sglb 动画文件",{url:e,type:t});return}if(!i||i.length===0){console.warn("[Amr.loadAnimation] 文件中未找到动画",e);return}if(!this._modelRoot){console.warn("[Amr.loadAnimation] 模型尚未加载,无法绑定动画",e);return}if(!s){console.warn("[Amr.loadAnimation] 动画文件中缺少 scene,无法执行重定向",e);return}const r=this._findFirstSkinnedMesh(s),o=this._findFirstSkinnedMesh(this._modelRoot);(!r||!o)&&console.warn("[Amr.loadAnimation] 在动画或目标模型中未找到 SkinnedMesh,使用原始动画 clip",e),this._mixer||(this._mixer=new f.AnimationMixer(this._modelRoot));const c=typeof Li.retargetClip=="function";i.forEach(h=>{let u=h;if(c&&r&&o)try{u=Li.retargetClip(o,r,h)}catch(n){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",h.name,n)}this._clips=this._clips.filter(n=>n.name!==u.name),this._clips.push(u);const p=this._mixer.clipAction(u);this._actionsMap.set(u.name,p)}),this.actions=Array.from(this._actionsMap.keys())}async load(e,t=""){this._url=e,this.name||(this.name=e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("."))),!e.startsWith("blob")&&e.endsWith(".sglb");let i,s;if(t==="glb"||e.endsWith(".glb")){let o=await je.loadAsync(e);i=o.scene,s=o.animations||[]}else{const c=await new Ut({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const r=Li.clone(i);this._generateAmr(r,s),i=null,this._emitter.emit("amr-loaded")}changeSkin(e,t){e&&(e.change(t),this._app&&this._app.usePathTracing&&(this._app.sampleCount=0,this._app.usePathTracing&&(this._app.pathTracer.pausePathTracing=!1,this._app.pathTracer.updateMaterials())))}changeLogo(e,t){e.change(t.url,new f.Vector2(t.scaleX,t.scaleY),new f.Vector2(t.ox,t.oy))}getShapeKeyTargets(e){return this._shapeKeyTargets.get(e)||[]}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this.getShapeKeyTargets(e).forEach(r=>{var h;performance.now();let o=t;r.userData[`origin_${e}`]&&(o-=r.userData[`origin_${e}`]);const c=(h=r.morphTargetDictionary)==null?void 0:h[e];c!==void 0&&r.morphTargetInfluences&&(r.morphTargetInfluences[c]=o),r instanceof f.Mesh&&r.geometry.translate(0,0,1e-9)}),i&&this._emitter.emit("shape-key-changed",e,t)},0)}_generateAmr(e,t){var i,s;this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new f.AnimationMixer(e),this._clips=t,t.forEach(r=>{const o=this._mixer.clipAction(r);this._actionsMap.set(r.name,o)}),this.actions=t.map(r=>r.name)),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),e.traverse(r=>{if(r.userData.isShelf&&(this._shelf=r),r.userData.isFork&&(this._fork=r),r.userData.isMast&&r.userData.mastLevel&&this._masts.set(r.userData.mastLevel,r),r.userData.isJack&&(this._jack=r),r.userData.isLift&&(this._lift=r),r.userData.isRollerLevel&&this._rollerLevel.set(r.userData.level||0,r),r.userData.isCenterModel&&(r.visible=this.useCenterModel),r.userData.isSwitch&&r.userData.switchName==="top"&&(this._rollerTop=r),r.userData.isLiftBracket&&(this._liftBrackets.push(r),r.visible=this._useLift),r.userData.isBaffle&&(this._rollerBaffle=r,r.visible=!this._useLift),r.userData.isRoller&&(this._roller=r,this._roller.visible=!1,this._generateRollers()),r.userData.isRollerLevelBox){this._rollerGoodsBox=r;const o=new xe(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);r.add(o),this.goods.push(o)}Object.keys(r.morphTargetDictionary||{}).forEach(o=>{let c=r.morphTargetInfluences[r.morphTargetDictionary[o]];r.userData[`origin_${o}`]&&(c+=r.userData[`origin_${o}`]),this._shapeKeys.has(o)||this._shapeKeys.set(o,c);const h=this._shapeKeyTargets.get(o);h?h.push(r):this._shapeKeyTargets.set(o,[r])})}),e.traverse(r=>{if(r instanceof f.Mesh){if(r.castShadow=!0,r.receiveShadow=!0,r.material)if(Array.isArray(r.material))r.material.forEach(c=>{c.userData.changeColor&&(this.skins.find(h=>h.name===c.userData.name)||this.skins.push(new ys({name:c.userData.name,target:c})))});else{if(r.material.userData.isVideo&&r.material.userData.video){const c=r.material.userData.video;let h=this._videoCache.get(c);h||(h=document.createElement("video"),h.src=c,h.crossOrigin="anonymous",h.loop=!0,h.muted=!0,h.playsInline=!0,h.autoplay=!0,h.preload="auto",this._videoCache.set(c,h)),h.play().catch(()=>{}),r.material.map&&r.material.map.dispose(),r.material.emissiveMap&&r.material.emissiveMap.dispose();const u=new f.VideoTexture(h);u.colorSpace=f.SRGBColorSpace,r.material.map=u,r.material.emissiveMap=u,r.material.emissive||(r.material.emissive=new f.Color(16777215)),r.material.emissiveIntensity=1,r.material.needsUpdate=!0}if(r.material.userData.isBreathLight&&r.material.emissiveIntensity){r.material.emissive||(r.material.emissive=new f.Color(16777215)),r.material.emissiveIntensity=2,r.material.toneMapped=!1;const c=1e3,h=new ne.Tween(r.material).to({emissiveIntensity:.2}).easing(ne.Easing.Quintic.InOut).duration(c),u=new ne.Tween(r.material).to({emissiveIntensity:2}).easing(ne.Easing.Quintic.InOut).duration(c);h.onComplete(()=>u.start()),u.onComplete(()=>h.start()),h.start(),this._breathLights.push(h,u)}r.material.userData.changeColor&&(this.skins.find(c=>c.name===r.material.userData.name)||this.skins.push(new ys({name:r.material.userData.name,target:r.material})))}if(r.material)if(Array.isArray(r.material))r.material.forEach(h=>{if(h.userData.isLOGO){r.material.transparent=!0;let u;const p={width:0,height:0};r.material.map&&r.material.map.image&&(p.width=r.material.map.image.width,p.height=r.material.map.image.height,u=os(r.material.map.image)),r.material.needsUpdate=!0;const n=new ls({name:h.userData.name,target:r,size:or(r),imageSize:p,imageUrl:u});this._logos.push(n)}h.userData.isTransparent&&(h.transparent=!0),this._materialsCache.set(h.uuid,{opacity:h.opacity,transparent:h.transparent,roughness:h.roughness,metalness:h.metalness,color:h.color,mat:h})});else{const c=r.material;if(c.userData.isLOGO){r.material.transparent=!0;let h;const u={width:0,height:0};r.material.map&&r.material.map.image&&(u.width=r.material.map.image.width,u.height=r.material.map.image.height,h=os(r.material.map.image));const p=new ls({name:c.userData.name,target:r,size:or(r),imageSize:u,imageUrl:h});this._logos.push(p)}c.userData.isTransparent&&(c.transparent=!0),this._materialsCache.set(c.uuid,{opacity:c.opacity,transparent:c.transparent,roughness:c.roughness,metalness:c.metalness,color:c.color,mat:c})}}this.generateController(r,e),this.generateDimension(r,e);const o=this.generateSlot(r,e);o&&this._slots.push(o),r.userData.isOrigin&&Object.keys(r.userData).forEach(h=>{if(h.startsWith("follow_")){const u=h.replace("follow_","");this.shapeKeys.has(u)&&(this.sizeBox.follow=u,this.sizeBox.followOrigin=this._shapeKeys.get(u)||0,this.sizeBox.followScale=r.userData[h])}})}),this.slots.forEach(r=>{r.props.mirrorTarget&&(r.mirrorTarget=this.slots.find(o=>o.props.slot.name===r.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this._buildJointChain(e),this._disposeIkControllers(),this._ikChains.length&&(this.ikControllers=Dl(this._ikChains,this,{camera:(i=this._app)==null?void 0:i.camera,domElement:(s=this._app)==null?void 0:s.renderer.domElement},{onDraggingChanged:(r,o)=>{this._onIkDraggingChanged(r,o)}}),this._ikChains.forEach((r,o)=>{r.controller=this.ikControllers[o]})),this.sizeBox.generate(e),this.sizeBox.show()}_syncIkDraggingState(){this._app&&(this._app.controls.enabled=this._ikDraggingControllers.size===0)}_onIkDraggingChanged(e,t){t?this._ikDraggingControllers.add(e):this._ikDraggingControllers.delete(e),this._syncIkDraggingState()}_disposeIkControllers(){this.ikControllers.forEach(e=>e.dispose()),this.ikControllers=[],this._ikChains.forEach(e=>{e.controller=void 0}),this._ikDraggingControllers.clear(),this._syncIkDraggingState()}_buildJointChain(e){if(this._ikChains=[],!this._ikChains.length){const t=[];e.traverse(i=>{i!=null&&i.name&&i.name.startsWith("ArmatureRoot")&&t.push(i)}),t.sort((i,s)=>i.name.localeCompare(s.name)),t.forEach(i=>{const{joints:s,orientation:r}=this._buildIKChainParams(i);if(s.length<2)return;const o={enabled:!0,...r};this._ikChains.push({name:i.name,joints:s,baseLinks:s.slice(),toolLinks:[],orientation:o})})}}_findIkChainByNode(e){var t;for(const i of this._ikChains){if(!((t=i.baseLinks)!=null&&t.length))continue;const s=new Set(i.baseLinks.map(o=>o.object.uuid));let r=e;for(;r;){if(s.has(r.uuid))return i;r=r.parent}}}updateIkJointChainByTool(e,t){if(!e)return;const i=this._findIkChainByNode(e);if(console.log("chain",i),!i||!i.controller||!i.baseLinks||i.baseLinks.length<2)return;const s=(u,p)=>{if(!p.length)return!1;const n=new Set;return u.traverse(l=>n.add(l.uuid)),p.some(l=>n.has(l.uuid))};if(t==="uninstall"){if(!(!!i.toolRootUuid&&e.uuid===i.toolRootUuid||i.toolLinks.length>0&&s(e,i.toolLinks.map(p=>p.object))))return;i.toolLinks=[],i.toolRootUuid=void 0,i.joints=i.baseLinks.slice(),i.controller.updateJointChain(i.joints);return}const{joints:r,orientation:o}=this._buildIKChainParams(e);if(!r.length)return;o&&i.controller.setOrientation(o);const c=!!i.toolRootUuid&&e.uuid===i.toolRootUuid,h=i.toolLinks.length>0;if(c&&h){i.joints=[...i.baseLinks,...i.toolLinks],i.controller.updateJointChain(i.joints);return}i.toolRootUuid=e.uuid,i.toolLinks=r,i.joints=[...i.baseLinks,...i.toolLinks],i.controller.updateJointChain(i.joints)}_buildIKChainParams(e){var o,c,h,u;if(!e)return{joints:[],orientation:void 0};const t=[];let i;const s=p=>{const n=p.children.find(l=>{var d,g;return((d=l.userData)==null?void 0:d.isJoint)||((g=l.userData)==null?void 0:g.isTcp)});if(n)return n;for(const l of p.children){const d=s(l);if(d)return d}};let r=(o=e.userData)!=null&&o.isJoint||(c=e.userData)!=null&&c.isTcp?e:s(e);for(;r;){if(console.log("cur",r),(h=r.userData)!=null&&h.isJoint){const p=this._parseIkAxes(r.userData.ikAxes);this._fillInitialRotationValues(r,p),t.push({object:r,axes:p})}else if((u=r.userData)!=null&&u.isTcp){const p=this._parseIkAxes(r.userData.ikAxes);this._fillInitialRotationValues(r,p),t.push({object:r,ikTcp:!0,axes:p}),i=this._parseIkOrientation(r.userData.ikOrientation)??i;break}r=s(r)}return{joints:t,orientation:i}}_fillInitialRotationValues(e,t){if(!t||!e)return;const i=e.rotation;t.forEach(s=>{const{axis:r}=s;Math.abs(r.x)>.9?s.value=i.x*Math.sign(r.x):Math.abs(r.y)>.9?s.value=i.y*Math.sign(r.y):Math.abs(r.z)>.9&&(s.value=i.z*Math.sign(r.z))})}_axisFromLetter(e){const t=String(e).trim().toUpperCase();if(t==="X")return new f.Vector3(1,0,0);if(t==="Y")return new f.Vector3(0,1,0);if(t==="Z")return new f.Vector3(0,0,1)}_parseIkAxes(e){if(!e||typeof e!="string")return;const t=JSON.parse(e);if(!(!Array.isArray(t)||t.length===0))return t.map(i=>{const s=this._axisFromLetter(i.axis)??new f.Vector3(0,0,0),r=typeof i.min=="number"?f.MathUtils.degToRad(i.min):void 0,o=typeof i.max=="number"?f.MathUtils.degToRad(i.max):void 0;return{axis:s,min:r,max:o}})}_parseIkOrientation(e){if(!e)return;const t=typeof e=="string"?JSON.parse(e):e,i=this._axisFromLetter(t.forwardAxis),s=this._axisFromLetter(t.upAxis);if(!(!i||!s))return{forwardAxis:i,upAxis:s}}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){this.name==="SFL-CDD14"&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CDD20","SFL-CDD20-Y"].includes(this.name)&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),this.name==="SFL-CDD15"&&(e>2.43?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CPD20-Y","SFL-CPD30-Y"].includes(this.name)&&(e>3.5?this.setShapeKey("mast",2):e>3?this.setShapeKey("mast",1):this.setShapeKey("mast",0))}setForkHeight(e){if(this._fork){if(e>this._forkMaxHeight&&(e=this._forkMaxHeight),this._fork.position.z=e,this._masts.size===1){const t=this._masts.get(2),i=(t==null?void 0:t.userData.startHeight)||.1;t&&(t.position.z=(e-i)*.5)}this._emitter.emit("fork-height-change",e)}}setForkMaxHeight(e){this._fork&&(this._forkMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("fork")&&(t.props.max=e)}),this._fork&&this.forkHeight>this._forkMaxHeight&&this.setForkHeight(e))}setLiftHeight(e){if(this._lift)if(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift instanceof Map){const t=this._lift.get(0);t&&(t.position.z=e)}else this._lift&&(this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(r=>{r.name.toLowerCase().includes("lift")&&(r.props.max=e)}),this.liftHeight>this._liftMaxHeight&&this.setLiftHeight(e);let t=.46;this.levelOffset&&(t=this.levelOffset+.1);let i=e+t;const s=this.getShelfMinHeight()+t||0;i<s&&(i=s),this.setHeight(i)}setJackMaxHeight(e){this._jack&&(this._jackMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("jack")&&(t.props.max=e)}),this.jackHeight>this._jackMaxHeight&&this.setJackHeight(e))}setJackHeight(e){this._jack&&(e>this._jackMaxHeight&&(e=this._jackMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("jackHeight",e,!1)}),this._jack.position.z=e)}setLevel(e){}setGoodsSize(e){this._goodsSize.length=e.length,this._goodsSize.width=e.width,this._goodsSize.height=e.height,this.setShelfLevel(this._shelfMaxLevel),this.setRoller(),this._rollerLevel.forEach(t=>{t.traverse(i=>{i instanceof xe&&i.updateSize(e.width,e.length,e.height)})})}setRoller(){}get isTopInvert(){if(this._rollerTop)return Math.abs(this._rollerTop.rotation.z)===Math.PI/2}setTopInvert(e=!0){this._rollerTop&&(this._rollerTop.rotation.z=e?Math.PI/2:0,this.setShapeKey("switch",e?1:0),this.setShapeKey("goodsWidth",this.goodsSize.width),this.setShapeKey("goodsLength",this._getLayoutGoodsLength(this.goodsSize.length)))}get useLift(){return this._useLift}set useLift(e){var t;this._lift&&(this._useLift=e,(t=this._rollerTop)==null||t.traverse(i=>{i.userData.isBaffle&&(i.visible=!e),i.userData.isLiftBracket&&(i.visible=e)}))}get columns(){return this._columnCount}get rows(){return this._rowCount}setRows(e){const t=Math.max(1,Math.floor(e||1));if(t===this._rowCount)return;this._rowCount=t;const i=this._getLayoutGoodsLength(this._goodsSize.length);this.setShapeKey("goodsLength",i,!1),this._applyDerivedSizesFromLayoutGoodsLength(i),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize()}_getLayoutGoodsLength(e=this._goodsSize.length){const t=Math.max(1,this._rowCount||1),i=e||0;return t<=1?i:i*t+this._rowGap*(t-1)}_layoutLengthToItemLength(e){const t=Math.max(1,this._rowCount||1);if(t<=1)return Math.max(0,e||0);const i=this._rowGap*(t-1);return Math.max(0,((e||0)-i)/t)}setGoodsItemLength(e){this._goodsSize.length=e;const t=this._getLayoutGoodsLength(e);this.setShapeKey("goodsLength",t)}_applyDerivedSizesFromLayoutGoodsLength(e){const t=e+.14-.54;this.setShapeKey("boxLength",t);const i=e+.14;if(this.setShapeKey("topWidth",i),this.isTopInvert){const s=e-.259;this.setShapeKey("length",s)}else this.setShapeKey("width",i)}_applyDerivedSizesFromGoodsLength(e){const t=this._getLayoutGoodsLength(e);this._applyDerivedSizesFromLayoutGoodsLength(t)}_applyDerivedSizesFromGoodsWidth(e){const t=Math.max(1,this._columnCount||1),i=.125,s=t===1?e+i:(e+i)*t+this._columnGap*(t-1),r=s+.06;this.setShapeKey("boxWidth",r);const o=s+.085;if(this.setShapeKey("topLength",o),this.isTopInvert){const c=s+.485;this.setShapeKey("width",c)}else this.setShapeKey("length",o)}setColumns(e,t=!0){const i=Math.max(1,Math.floor(e||1));this._columnCount=i,this._rollerLevel.forEach(s=>{const r=s.children.filter(d=>{var g;return(g=d.userData)==null?void 0:g.isRollerLevelBox}),o=r.length>0?(Math.min(...r.map(d=>d.position.x))+Math.max(...r.map(d=>d.position.x)))/2:0;s.children.filter(d=>{var g,v;return((g=d.userData)==null?void 0:g.isRollerLevelBox)&&((v=d.userData)==null?void 0:v.cloned)}).forEach(d=>s.remove(d));const c=s.children.find(d=>d.userData.isRollerLevelBox&&!d.userData.cloned)||s.children.find(d=>d.userData.isRollerLevelBox);if(!c)return;const h=el(c,s,new f.Vector3),u=this._columnGap,n=h.x+u,l=(i-1)*n/2;c.position.x=o-l;for(let d=1;d<i;d++){const g=c.clone(!0);g.userData.cloned=!0,this._stripRollerInstances(g),this.regenerateShapeKeyNode(g),g.position.x=o-l+d*n,s.add(g)}}),t&&this._applyDerivedSizesFromGoodsWidth(this.goodsSize.width),this._pruneShapeKeyTargets(),this.setShapeKey("goodsWidth",this._goodsSize.width,!1),this.setShapeKey("goodsLength",this._getLayoutGoodsLength(this._goodsSize.length),!1),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize()}get levels(){return this._levelCount}setLevels(e){var o;const t=Math.max(1,Math.floor(e||1));this._levelCount=t;const i=this._rollerLevel.size,s=t-i,r=this._rollerLevel.get(0);if(s>0&&r){for(let h=i;h<t;h++){const u=r.clone(!0);u.visible=!0,this._stripRollerInstances(u),u.position.z=r.position.z+.2*h,u.userData.level=h,this._rollerLevel.set(h,u),(o=r.parent)==null||o.add(u),this.regenerateShapeKeyNode(u),u.traverse(p=>{p instanceof xe&&(p.updateSize(this.goodsSize.width,this.goodsSize.length,this.goodsSize.height),this.goods.push(p))})}this._columnCount>1&&this.setColumns(this._columnCount,!1),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize()}else for(let c=0;c<i;c++){const h=this._rollerLevel.get(c);h&&(h.visible=c<t)}}regenerateShapeKeyNode(e){e&&e.traverse(t=>{Vi(t)&&Object.keys(t.morphTargetDictionary||{}).forEach(i=>{const s=this._shapeKeyTargets.get(i);s&&s.push(t)})})}_stripRollerInstances(e){const t=[];e.traverse(i=>{var s,r;((s=i==null?void 0:i.userData)!=null&&s.__amrRollerInstance||(r=i==null?void 0:i.userData)!=null&&r.isCloned)&&t.push(i)}),t.forEach(i=>{i.parent&&i.removeFromParent()})}_isInAmrContainer(e){let t=e;for(;t;){if(t===this._container||t===this)return!0;t=t.parent}return!1}_pruneShapeKeyTargets(){this._shapeKeyTargets.forEach((e,t)=>{const i=new Set,s=[];for(const r of e)r&&this._isInAmrContainer(r)&&(i.has(r.uuid)||(i.add(r.uuid),s.push(r)));this._shapeKeyTargets.set(t,s)})}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){if(!this._roller)return;let e=this._getLayoutGoodsLength(this._goodsSize.length);e=e||.5;const t=.05;let i=.02;const r=e-i,o=t+i;let c=Math.floor(r/o);const h=r%o,u=l=>{var v;const d=[],g=[...l.children];for(;g.length;){const m=g.pop();if((v=m.userData)!=null&&v.isRollerLevelBox){d.push(m);continue}m.children&&m.children.length&&g.push(...m.children)}return d},p=[];this._rollerLevel.forEach(l=>{p.push(...u(l))});let n=!1;if(p.forEach(l=>{const d=[];l.traverse(g=>{var v,m;g!==l&&((v=g==null?void 0:g.userData)!=null&&v.isCloned)&&!((m=g==null?void 0:g.userData)!=null&&m.__amrRollerInstance)&&d.push(g)}),d.forEach(g=>g.removeFromParent()),d.length&&(n=!0)}),n&&this._pruneShapeKeyTargets(),c>0){c>1&&(i+=h/(c+2));const l=t+i,d=-e/2+i+t/2;p.forEach(g=>{let v=this._rollerPools.get(g);for(v||(v=[],this._rollerPools.set(g,v));v.length<c;){const m=this._roller.clone(!0);m.visible=!1,m.userData.__amrRollerInstance=!0,m.userData.isCloned=!0,g.add(m),this.regenerateShapeKeyNode(m),v.push(m)}for(let m=0;m<c;m++){const _=v[m];_.parent!==g&&g.add(_),_.visible=!0,_.position.y=d+l*m}for(let m=c;m<v.length;m++)v[m].visible=!1})}else p.forEach(l=>{const d=this._rollerPools.get(l);d&&d.forEach(g=>g.visible=!1)})}getShelfMinHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);return i?i.position.z+e*t+.1:0}getShelfMaxShelfHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);if(i)return i.position.z+e*(t-1)}get levelOffset(){return this._goodsSize.height+.2}setShapeKeyToMesh(e,t,i){if(!Object.keys(e.morphTargetDictionary||{}).includes(t))return;const s=e.morphTargetDictionary[t];e.morphTargetInfluences&&(e.morphTargetInfluences[s]=i),e.geometry.translate(0,0,1e-9)}setShelfLevel(e=3){var r;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset,i=this._getLayoutGoodsLength(this._goodsSize.length);this._shelves.delete(0),this._shelves.forEach(o=>{De(o),o.parent&&o.removeFromParent()}),this.goods=this.goods.filter(o=>{var c;return(c=o==null?void 0:o.userData)==null?void 0:c.__amrRollerGoodsBox}),this._shelves.clear(),this._shelves.set(0,this._shelf);for(let o=1;o<e;o++){if(!this._shelf)return;this._shelf.traverse(u=>{Vi(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",i))});const c=this._shelf.clone(!0);c.position.z+=t*o,this._shelves.set(o,c),(r=this._shelf.parent)==null||r.add(c);let h;if(c.traverse(u=>{u.userData.isShelfContainer&&(h=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&h&&(typeof h.userData.__goodsBaseX!="number"&&(h.userData.__goodsBaseX=h.position.x),h.position.x=h.userData.__goodsBaseX+i/2),h){const u=new xe(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(u.userData.__amrShelfGoodsBox=!0,h.add(u),this.goods.push(u),o===1){const p=new xe(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);p.userData.__amrShelfGoodsBox=!0,p.position.z-=t,h.add(p),this.goods.push(p)}}}const s=this.getShelfMinHeight()||0;this._liftMaxHeight<s&&this.setLiftMaxHeight(s)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new on(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=e.userData.target.name,{min:s,max:r}=e.userData;let o;if(t.traverse(h=>{h.name===i&&(o=h)}),!o)return;const c=new ur({name:"",target:i,default:0,min:s,max:r},o);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:r}=e.userData;let o;if(t.traverse(h=>{h.name===i&&(o=h)}),!o)return;const c=new ur({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:r||1},o);e.add(c),this.controllers.push(c),c.addListener("change",()=>{this.ikControllers.forEach(h=>{h.enabled=!1}),clearTimeout(this._ikControllersTimer),this._ikControllersTimer=setTimeout(()=>{this.ikControllers.forEach(h=>{h.enabled=!0,h.syncTargetToEffector()})},100)}),(o.userData.isFork||o.userData.isLift||o.userData.isJack)&&(this._forkMaxHeight=r||1,this._liftMaxHeight=r||1,this._jackMaxHeight=r||1,c.addListener("change",h=>{this.setForkHeight(h),this.setLiftHeight(h),this.setJackHeight(h)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=tl(e.userData.startOrigin),r=e.userData.axios;let o,c;if(r==="x"?(o=new f.Vector3(e.userData.start-e.position.x,0,0),c=o.clone().setX(e.userData.end-e.position.x)):r==="z"?(o=new f.Vector3(0,e.userData.start-e.position.y,0),c=o.clone().setY(e.userData.end-e.position.y)):(o=new f.Vector3(0,0,e.userData.start-e.position.z),c=o.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(n=>n.startsWith("target")?e.userData[n].name:[]).length)return;const p=new vl({start:o,end:c,startOrigin:s,axios:r,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const r=e.userData.name,o=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(r){const h=e.userData.holeTarget&&e.userData.holeTarget.name;let u;h&&t.traverse(d=>{d.name===h&&(u=d)});const p=new Map;Object.keys(e.userData).forEach(d=>{if(d.startsWith("follow_")){const g=d.split("_")[1];if(g){let v=e.userData[d];p.set(g,{scale:v,initPos:e.position.clone(),origin:this.shapeKeys.get(g)||0})}}});const n=(s=this._app)==null?void 0:s.props.isMobile,l=new as({name:r,follows:p,slot:e,show:this._showSlots,isMirror:o,mirrorTarget:c,isMobile:n});return l.holeTarget=u,l.addEventListener(J.ON_DROP,d=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(J.ON_DEVICE_REPLACED,d=>{d&&this.updateIkJointChainByTool(d,"install")}),l.addEventListener(J.ON_DEVICE_DELETED,d=>{d&&this.updateIkJointChainByTool(d,"uninstall")}),l.addEventListener(J.ON_BEFORE_SELECTED,d=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(J.ON_ERROR_STATE_CHANGE,d=>{var v;if(!this._app)return;const g=(v=this._app)==null?void 0:v._outlinePassError;if(g)if(g.selectedObjects=g.selectedObjects.filter(m=>!!m.parent),d){if(l.device){if(g.selectedObjects.find(_=>{var y;return _.parent===((y=l.device)==null?void 0:y.parent)}))return;g.selectedObjects=[l.device,...g.selectedObjects]}}else l.device&&(g.selectedObjects=g.selectedObjects.filter(m=>{var _;return m.parent!==((_=l.device)==null?void 0:_.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._rollerLevel.clear(),De(this._container),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset(),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),this._shelfSyncCache=new WeakMap,this._rollerPools=new WeakMap,this._shapeKeyTimer&&(clearTimeout(this._shapeKeyTimer),this._shapeKeyTimer=0),this._currentAction=null,this._pendingFinishedCallback&&this._mixer&&(this._mixer.removeEventListener("finished",this._pendingFinishedCallback),this._pendingFinishedCallback=null),this._mixer&&(this._mixer.stopAllAction(),this._modelRoot&&this._mixer.uncacheRoot(this._modelRoot)),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],this._disposeIkControllers(),this._lift=void 0,this._fork=void 0,this._jack=void 0,this._roller=void 0,this._rollerBaffle=void 0,this._rollerTop=void 0,this._shelf=void 0,this._rollerGoodsBox=void 0,this._modelRoot=void 0,this.goods.forEach(e=>{e.dispose(),e.parent&&e.removeFromParent()}),this.goods=[],this._liftBrackets=[],this._videoCache.forEach(e=>{e.pause(),e.removeAttribute("src"),e.load(),e.remove()}),this._videoCache.clear(),this._masts.clear(),this._shelves.clear(),this._outline&&(this._outline.removeFromParent(),this._outline=void 0),this._app&&this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=void 0}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t){const i=Object.keys(t||{}).includes("reset")?t==null?void 0:t.reset:!0,s=this._actionsMap.get(e);if(!s||!this._mixer)return Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`));if(s.isRunning()&&s===this._currentAction)return Promise.resolve();const r=this._currentAction,o=r===s,c=o?0:t!=null&&t.fadeIn?t==null?void 0:t.fadeIn:.5,h=r&&!o&&r.isRunning();this._actionsMap.forEach(n=>{n!==s&&n!==r&&(n.stopFading(),n.setEffectiveWeight(0),n.stop())});const u=(t==null?void 0:t.loop)??!1;(i||!s.isRunning())&&s.reset(),s.enabled=!0,s.setEffectiveTimeScale((t==null?void 0:t.timeScale)??1),s.setEffectiveWeight(1),s.paused=!1,s.setLoop(u?f.LoopRepeat:f.LoopOnce,u?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!u,s.play();const p=(t==null?void 0:t.timeScale)??1;return h?(r.stopFading(),r.enabled=!0,r.setEffectiveWeight(1),r.crossFadeTo(s,c,!1)):c>0&&s.fadeIn(c),s.setEffectiveTimeScale(p),this._currentAction=s,new Promise(n=>{this._pendingFinishedCallback&&this._mixer&&this._mixer.removeEventListener("finished",this._pendingFinishedCallback);const l=d=>{var g;d.action===s&&((g=this._mixer)==null||g.removeEventListener("finished",l),this._pendingFinishedCallback=null,n())};this._pendingFinishedCallback=l,this._mixer.addEventListener("finished",l)})}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}stopAction(e,t=.3){const i=this._actionsMap.get(e);return!i||!i.isRunning()?Promise.resolve():(this._currentAction===i&&(this._currentAction=null),t>0?(i.fadeOut(t),new Promise(s=>{setTimeout(()=>{i.stop(),s()},t*1e3)})):(i.stop(),Promise.resolve()))}stopAllActions(e=.3){return this._mixer?(this._currentAction=null,e>0?(this._actionsMap.forEach(t=>{t.isRunning()&&t.fadeOut(e)}),new Promise(t=>{setTimeout(()=>{var i;(i=this._mixer)==null||i.stopAllAction(),t()},e*1e3)})):(this._mixer.stopAllAction(),Promise.resolve())):Promise.resolve()}}const ln=0,Ll=1,Pl=2,_r=2,Hi=1.25,vr=1,Vt=6*4+4+4,Mi=65535,Il=Math.pow(2,-24),Gi=Symbol("SKIP_GENERATION");function Rl(a){return a.index?a.index.count:a.attributes.position.count}function xt(a){return Rl(a)/3}function El(a,e=ArrayBuffer){return a>65535?new Uint32Array(new e(4*a)):new Uint16Array(new e(2*a))}function kl(a,e){if(!a.index){const t=a.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=El(t,i);a.setIndex(new f.BufferAttribute(s,1));for(let r=0;r<t;r++)s[r]=r}}function cn(a){const e=xt(a),t=a.drawRange,i=t.start/3,s=(t.start+t.count)/3,r=Math.max(0,i),o=Math.min(e,s)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function hn(a){if(!a.groups||!a.groups.length)return cn(a);const e=[],t=new Set,i=a.drawRange,s=i.start/3,r=(i.start+i.count)/3;for(const c of a.groups){const h=c.start/3,u=(c.start+c.count)/3;t.add(Math.max(s,h)),t.add(Math.min(r,u))}const o=Array.from(t.values()).sort((c,h)=>c-h);for(let c=0;c<o.length-1;c++){const h=o[c],u=o[c+1];e.push({offset:Math.floor(h),count:Math.floor(u-h)})}return e}function Fl(a){if(a.groups.length===0)return!1;const e=xt(a),t=hn(a).sort((r,o)=>r.offset-o.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:r})=>s+=r),e!==s}function Ni(a,e,t,i,s){let r=1/0,o=1/0,c=1/0,h=-1/0,u=-1/0,p=-1/0,n=1/0,l=1/0,d=1/0,g=-1/0,v=-1/0,m=-1/0;for(let _=e*6,y=(e+t)*6;_<y;_+=6){const w=a[_+0],x=a[_+1],b=w-x,T=w+x;b<r&&(r=b),T>h&&(h=T),w<n&&(n=w),w>g&&(g=w);const M=a[_+2],L=a[_+3],C=M-L,I=M+L;C<o&&(o=C),I>u&&(u=I),M<l&&(l=M),M>v&&(v=M);const D=a[_+4],A=a[_+5],S=D-A,P=D+A;S<c&&(c=S),P>p&&(p=P),D<d&&(d=D),D>m&&(m=D)}i[0]=r,i[1]=o,i[2]=c,i[3]=h,i[4]=u,i[5]=p,s[0]=n,s[1]=l,s[2]=d,s[3]=g,s[4]=v,s[5]=m}function Bl(a,e=null,t=null,i=null){const s=a.attributes.position,r=a.index?a.index.array:null,o=xt(a),c=s.normalized;let h;e===null?(h=new Float32Array(o*6*4),t=0,i=o):(h=e,t=t||0,i=i||o);const u=s.array,p=s.offset||0;let n=3;s.isInterleavedBufferAttribute&&(n=s.data.stride);const l=["getX","getY","getZ"];for(let d=t;d<t+i;d++){const g=d*3,v=d*6;let m=g+0,_=g+1,y=g+2;r&&(m=r[m],_=r[_],y=r[y]),c||(m=m*n+p,_=_*n+p,y=y*n+p);for(let w=0;w<3;w++){let x,b,T;c?(x=s[l[w]](m),b=s[l[w]](_),T=s[l[w]](y)):(x=u[m+w],b=u[_+w],T=u[y+w]);let M=x;b<M&&(M=b),T<M&&(M=T);let L=x;b>L&&(L=b),T>L&&(L=T);const C=(L-M)/2,I=w*2;h[v+I+0]=M+C,h[v+I+1]=C+(Math.abs(M)+C)*Il}}return h}function Z(a,e,t){return t.min.x=e[a],t.min.y=e[a+1],t.min.z=e[a+2],t.max.x=e[a+3],t.max.y=e[a+4],t.max.z=e[a+5],t}function yr(a){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=a[i+3]-a[i];s>t&&(t=s,e=i)}return e}function xr(a,e){e.set(a)}function wr(a,e,t){let i,s;for(let r=0;r<3;r++){const o=r+3;i=a[r],s=e[r],t[r]=i<s?i:s,i=a[o],s=e[o],t[o]=i>s?i:s}}function si(a,e,t){for(let i=0;i<3;i++){const s=e[a+2*i],r=e[a+2*i+1],o=s-r,c=s+r;o<t[i]&&(t[i]=o),c>t[i+3]&&(t[i+3]=c)}}function Lt(a){const e=a[3]-a[0],t=a[4]-a[1],i=a[5]-a[2];return 2*(e*t+t*i+i*e)}const Te=32,Ol=(a,e)=>a.candidate-e.candidate,Ee=new Array(Te).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ri=new Float32Array(6);function zl(a,e,t,i,s,r){let o=-1,c=0;if(r===ln)o=yr(e),o!==-1&&(c=(e[o]+e[o+3])/2);else if(r===Ll)o=yr(a),o!==-1&&(c=Vl(t,i,s,o));else if(r===Pl){const h=Lt(a);let u=Hi*s;const p=i*6,n=(i+s)*6;for(let l=0;l<3;l++){const d=e[l],m=(e[l+3]-d)/Te;if(s<Te/4){const _=[...Ee];_.length=s;let y=0;for(let x=p;x<n;x+=6,y++){const b=_[y];b.candidate=t[x+2*l],b.count=0;const{bounds:T,leftCacheBounds:M,rightCacheBounds:L}=b;for(let C=0;C<3;C++)L[C]=1/0,L[C+3]=-1/0,M[C]=1/0,M[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0;si(x,t,T)}_.sort(Ol);let w=s;for(let x=0;x<w;x++){const b=_[x];for(;x+1<w&&_[x+1].candidate===b.candidate;)_.splice(x+1,1),w--}for(let x=p;x<n;x+=6){const b=t[x+2*l];for(let T=0;T<w;T++){const M=_[T];b>=M.candidate?si(x,t,M.rightCacheBounds):(si(x,t,M.leftCacheBounds),M.count++)}}for(let x=0;x<w;x++){const b=_[x],T=b.count,M=s-b.count,L=b.leftCacheBounds,C=b.rightCacheBounds;let I=0;T!==0&&(I=Lt(L)/h);let D=0;M!==0&&(D=Lt(C)/h);const A=vr+Hi*(I*T+D*M);A<u&&(o=l,u=A,c=b.candidate)}}else{for(let w=0;w<Te;w++){const x=Ee[w];x.count=0,x.candidate=d+m+w*m;const b=x.bounds;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0}for(let w=p;w<n;w+=6){let T=~~((t[w+2*l]-d)/m);T>=Te&&(T=Te-1);const M=Ee[T];M.count++,si(w,t,M.bounds)}const _=Ee[Te-1];xr(_.bounds,_.rightCacheBounds);for(let w=Te-2;w>=0;w--){const x=Ee[w],b=Ee[w+1];wr(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let y=0;for(let w=0;w<Te-1;w++){const x=Ee[w],b=x.count,T=x.bounds,L=Ee[w+1].rightCacheBounds;b!==0&&(y===0?xr(T,ri):wr(T,ri,ri)),y+=b;let C=0,I=0;y!==0&&(C=Lt(ri)/h);const D=s-y;D!==0&&(I=Lt(L)/h);const A=vr+Hi*(C*y+I*D);A<u&&(o=l,u=A,c=x.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:c}}function Vl(a,e,t,i){let s=0;for(let r=e,o=e+t;r<o;r++)s+=a[r*6+i*2];return s/t}class Qi{constructor(){this.boundingData=new Float32Array(6)}}function Wl(a,e,t,i,s,r){let o=i,c=i+s-1;const h=r.pos,u=r.axis*2;for(;;){for(;o<=c&&t[o*6+u]<h;)o++;for(;o<=c&&t[c*6+u]>=h;)c--;if(o<c){for(let p=0;p<3;p++){let n=e[o*3+p];e[o*3+p]=e[c*3+p],e[c*3+p]=n}for(let p=0;p<6;p++){let n=t[o*6+p];t[o*6+p]=t[c*6+p],t[c*6+p]=n}o++,c--}else return o}}function Ul(a,e,t,i,s,r){let o=i,c=i+s-1;const h=r.pos,u=r.axis*2;for(;;){for(;o<=c&&t[o*6+u]<h;)o++;for(;o<=c&&t[c*6+u]>=h;)c--;if(o<c){let p=a[o];a[o]=a[c],a[c]=p;for(let n=0;n<6;n++){let l=t[o*6+n];t[o*6+n]=t[c*6+n],t[c*6+n]=l}o++,c--}else return o}}function oe(a,e){return e[a+15]===65535}function le(a,e){return e[a+6]}function ce(a,e){return e[a+14]}function he(a){return a+8}function ue(a,e){return e[a+6]}function un(a,e){return e[a+7]}let fn,Bt,yi,dn;const Hl=Math.pow(2,32);function hs(a){return"count"in a?1:1+hs(a.left)+hs(a.right)}function Gl(a,e,t){return fn=new Float32Array(t),Bt=new Uint32Array(t),yi=new Uint16Array(t),dn=new Uint8Array(t),us(a,e)}function us(a,e){const t=a/4,i=a/2,s="count"in e,r=e.boundingData;for(let o=0;o<6;o++)fn[t+o]=r[o];if(s)if(e.buffer){const o=e.buffer;dn.set(new Uint8Array(o),a);for(let c=a,h=a+o.byteLength;c<h;c+=Vt){const u=c/2;oe(u,yi)||(Bt[c/4+6]+=t)}return a+o.byteLength}else{const o=e.offset,c=e.count;return Bt[t+6]=o,yi[i+14]=c,yi[i+15]=Mi,a+Vt}else{const o=e.left,c=e.right,h=e.splitAxis;let u;if(u=us(a+Vt,o),u/4>Hl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Bt[t+6]=u/4,u=us(u,c),Bt[t+7]=h,u}}function Nl(a,e){const t=(a.index?a.index.count:a.attributes.position.count)/3,i=t>2**16,s=i?4:2,r=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),o=i?new Uint32Array(r):new Uint16Array(r);for(let c=0,h=o.length;c<h;c++)o[c]=c;return o}function Ql(a,e,t,i,s){const{maxDepth:r,verbose:o,maxLeafTris:c,strategy:h,onProgress:u,indirect:p}=s,n=a._indirectBuffer,l=a.geometry,d=l.index?l.index.array:null,g=p?Ul:Wl,v=xt(l),m=new Float32Array(6);let _=!1;const y=new Qi;return Ni(e,t,i,y.boundingData,m),x(y,t,i,m),y;function w(b){u&&u(b/v)}function x(b,T,M,L=null,C=0){if(!_&&C>=r&&(_=!0,o&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),M<=c||C>=r)return w(T+M),b.offset=T,b.count=M,b;const I=zl(b.boundingData,L,e,T,M,h);if(I.axis===-1)return w(T+M),b.offset=T,b.count=M,b;const D=g(n,d,e,T,M,I);if(D===T||D===T+M)w(T+M),b.offset=T,b.count=M;else{b.splitAxis=I.axis;const A=new Qi,S=T,P=D-T;b.left=A,Ni(e,S,P,A.boundingData,m),x(A,S,P,m,C+1);const R=new Qi,k=D,F=M-P;b.right=R,Ni(e,k,F,R.boundingData,m),x(R,k,F,m,C+1)}return b}}function jl(a,e){const t=a.geometry;e.indirect&&(a._indirectBuffer=Nl(t,e.useSharedArrayBuffer),Fl(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),a._indirectBuffer||kl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Bl(t),r=e.indirect?cn(t):hn(t);a._roots=r.map(o=>{const c=Ql(a,s,o.offset,o.count,e),h=hs(c),u=new i(Vt*h);return Gl(0,c,u),u})}class Le{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let r=0,o=e.length;r<o;r++){const h=e[r][t];i=h<i?h:i,s=h>s?h:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let r=0,o=t.length;r<o;r++){const c=t[r],h=e.dot(c);i=h<i?h:i,s=h>s?h:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Le.prototype.setFromBox=function(){const a=new f.Vector3;return function(t,i){const s=i.min,r=i.max;let o=1/0,c=-1/0;for(let h=0;h<=1;h++)for(let u=0;u<=1;u++)for(let p=0;p<=1;p++){a.x=s.x*h+r.x*(1-h),a.y=s.y*u+r.y*(1-u),a.z=s.z*p+r.z*(1-p);const n=t.dot(a);o=Math.min(n,o),c=Math.max(n,c)}this.min=o,this.max=c}}();const ql=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(s,r,o){const c=s.start,h=a,u=r.start,p=e;t.subVectors(c,u),a.subVectors(s.end,s.start),e.subVectors(r.end,r.start);const n=t.dot(p),l=p.dot(h),d=p.dot(p),g=t.dot(h),m=h.dot(h)*d-l*l;let _,y;m!==0?_=(n*l-g*d)/m:_=0,y=(n+_*l)/d,o.x=_,o.y=y}}(),Ls=function(){const a=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(s,r,o,c){ql(s,r,a);let h=a.x,u=a.y;if(h>=0&&h<=1&&u>=0&&u<=1){s.at(h,o),r.at(u,c);return}else if(h>=0&&h<=1){u<0?r.at(0,c):r.at(1,c),s.closestPointToPoint(c,!0,o);return}else if(u>=0&&u<=1){h<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,c);return}else{let p;h<0?p=s.start:p=s.end;let n;u<0?n=r.start:n=r.end;const l=e,d=t;if(s.closestPointToPoint(n,!0,e),r.closestPointToPoint(p,!0,t),l.distanceToSquared(n)<=d.distanceToSquared(p)){o.copy(l),c.copy(n);return}else{o.copy(p),c.copy(d);return}}}}(),Yl=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Plane,i=new f.Line3;return function(r,o){const{radius:c,center:h}=r,{a:u,b:p,c:n}=o;if(i.start=u,i.end=p,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c||(i.start=u,i.end=n,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c)||(i.start=p,i.end=n,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c))return!0;const v=o.getPlane(t);if(Math.abs(v.distanceToPoint(h))<=c){const _=v.projectPoint(h,e);if(o.containsPoint(_))return!0}return!1}}(),Zl=1e-15;function ji(a){return Math.abs(a)<Zl}class ge extends f.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new f.Vector3),this.satBounds=new Array(4).fill().map(()=>new Le),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return Yl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,r=this.satAxes,o=this.satBounds,c=r[0],h=o[0];this.getNormal(c),h.setFromPoints(c,s);const u=r[1],p=o[1];u.subVectors(e,t),p.setFromPoints(u,s);const n=r[2],l=o[2];n.subVectors(t,i),l.setFromPoints(n,s);const d=r[3],g=o[3];d.subVectors(i,e),g.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}ge.prototype.closestPointToSegment=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(s,r=null,o=null){const{start:c,end:h}=s,u=this.points;let p,n=1/0;for(let l=0;l<3;l++){const d=(l+1)%3;t.start.copy(u[l]),t.end.copy(u[d]),Ls(t,s,a,e),p=a.distanceToSquared(e),p<n&&(n=p,r&&r.copy(a),o&&o.copy(e))}return this.closestPointToPoint(c,a),p=c.distanceToSquared(a),p<n&&(n=p,r&&r.copy(a),o&&o.copy(c)),this.closestPointToPoint(h,a),p=h.distanceToSquared(a),p<n&&(n=p,r&&r.copy(a),o&&o.copy(h)),Math.sqrt(n)}}();ge.prototype.intersectsTriangle=function(){const a=new ge,e=new Array(3),t=new Array(3),i=new Le,s=new Le,r=new f.Vector3,o=new f.Vector3,c=new f.Vector3,h=new f.Vector3,u=new f.Vector3,p=new f.Line3,n=new f.Line3,l=new f.Line3,d=new f.Vector3;function g(v,m,_){const y=v.points;let w=0,x=-1;for(let b=0;b<3;b++){const{start:T,end:M}=p;T.copy(y[b]),M.copy(y[(b+1)%3]),p.delta(o);const L=ji(m.distanceToPoint(T));if(ji(m.normal.dot(o))&&L){_.copy(p),w=2;break}const C=m.intersectLine(p,d);if(!C&&L&&d.copy(T),(C||L)&&!ji(d.distanceTo(M))){if(w<=1)(w===1?_.start:_.end).copy(d),L&&(x=w);else if(w>=2){(x===1?_.start:_.end).copy(d),w=2;break}if(w++,w===2&&x===-1)break}}return w}return function(m,_=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(a.copy(m),a.update(),m=a);const w=this.plane,x=m.plane;if(Math.abs(w.normal.dot(x.normal))>1-1e-10){const b=this.satBounds,T=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let C=0;C<4;C++){const I=b[C],D=T[C];if(i.setFromPoints(D,t),I.isSeparated(i))return!1}const M=m.satBounds,L=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const I=M[C],D=L[C];if(i.setFromPoints(D,e),I.isSeparated(i))return!1}for(let C=0;C<4;C++){const I=T[C];for(let D=0;D<4;D++){const A=L[D];if(r.crossVectors(I,A),i.setFromPoints(r,e),s.setFromPoints(r,t),i.isSeparated(s))return!1}}return _&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}else{const b=g(this,x,n);if(b===1&&m.containsPoint(n.end))return _&&(_.start.copy(n.end),_.end.copy(n.end)),!0;if(b!==2)return!1;const T=g(m,w,l);if(T===1&&this.containsPoint(l.end))return _&&(_.start.copy(l.end),_.end.copy(l.end)),!0;if(T!==2)return!1;if(n.delta(c),l.delta(h),c.dot(h)<0){let S=l.start;l.start=l.end,l.end=S}const M=n.start.dot(c),L=n.end.dot(c),C=l.start.dot(c),I=l.end.dot(c),D=L<C,A=M<I;return M!==I&&C!==L&&D===A?!1:(_&&(u.subVectors(n.start,l.start),u.dot(c)>0?_.start.copy(n.start):_.start.copy(l.start),u.subVectors(n.end,l.end),u.dot(c)<0?_.end.copy(n.end):_.end.copy(l.end)),!0)}}}();ge.prototype.distanceToPoint=function(){const a=new f.Vector3;return function(t){return this.closestPointToPoint(t,a),t.distanceTo(a)}}();ge.prototype.distanceToTriangle=function(){const a=new f.Vector3,e=new f.Vector3,t=["a","b","c"],i=new f.Line3,s=new f.Line3;return function(o,c=null,h=null){const u=c||h?i:null;if(this.intersectsTriangle(o,u))return(c||h)&&(c&&u.getCenter(c),h&&u.getCenter(h)),0;let p=1/0;for(let n=0;n<3;n++){let l;const d=t[n],g=o[d];this.closestPointToPoint(g,a),l=g.distanceToSquared(a),l<p&&(p=l,c&&c.copy(a),h&&h.copy(g));const v=this[d];o.closestPointToPoint(v,a),l=v.distanceToSquared(a),l<p&&(p=l,c&&c.copy(v),h&&h.copy(a))}for(let n=0;n<3;n++){const l=t[n],d=t[(n+1)%3];i.set(this[l],this[d]);for(let g=0;g<3;g++){const v=t[g],m=t[(g+1)%3];s.set(o[v],o[m]),Ls(i,s,a,e);const _=a.distanceToSquared(e);_<p&&(p=_,c&&c.copy(a),h&&h.copy(e))}}return Math.sqrt(p)}}();class te{constructor(e,t,i){this.isOrientedBox=!0,this.min=new f.Vector3,this.max=new f.Vector3,this.matrix=new f.Matrix4,this.invMatrix=new f.Matrix4,this.points=new Array(8).fill().map(()=>new f.Vector3),this.satAxes=new Array(3).fill().map(()=>new f.Vector3),this.satBounds=new Array(3).fill().map(()=>new Le),this.alignedSatBounds=new Array(3).fill().map(()=>new Le),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}te.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let u=0;u<=1;u++)for(let p=0;p<=1;p++)for(let n=0;n<=1;n++){const l=1*u|2*p|4*n,d=s[l];d.x=u?i.x:t.x,d.y=p?i.y:t.y,d.z=n?i.z:t.z,d.applyMatrix4(e)}const r=this.satBounds,o=this.satAxes,c=s[0];for(let u=0;u<3;u++){const p=o[u],n=r[u],l=1<<u,d=s[l];p.subVectors(c,d),n.setFromPoints(p,s)}const h=this.alignedSatBounds;h[0].setFromPointsField(s,"x"),h[1].setFromPointsField(s,"y"),h[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();te.prototype.intersectsBox=function(){const a=new Le;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,r=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(a.min=i.x,a.max=s.x,c[0].isSeparated(a)||(a.min=i.y,a.max=s.y,c[1].isSeparated(a))||(a.min=i.z,a.max=s.z,c[2].isSeparated(a)))return!1;for(let h=0;h<3;h++){const u=o[h],p=r[h];if(a.setFromBox(u,t),p.isSeparated(a))return!1}return!0}}();te.prototype.intersectsTriangle=function(){const a=new ge,e=new Array(3),t=new Le,i=new Le,s=new f.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(a.copy(o),a.update(),o=a);const c=this.satBounds,h=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let l=0;l<3;l++){const d=c[l],g=h[l];if(t.setFromPoints(g,e),d.isSeparated(t))return!1}const u=o.satBounds,p=o.satAxes,n=this.points;for(let l=0;l<3;l++){const d=u[l],g=p[l];if(t.setFromPoints(g,n),d.isSeparated(t))return!1}for(let l=0;l<3;l++){const d=h[l];for(let g=0;g<4;g++){const v=p[g];if(s.crossVectors(d,v),t.setFromPoints(s,e),i.setFromPoints(s,n),t.isSeparated(i))return!1}}return!0}}();te.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();te.prototype.distanceToPoint=function(){const a=new f.Vector3;return function(t){return this.closestPointToPoint(t,a),t.distanceTo(a)}}();te.prototype.distanceToBox=function(){const a=["x","y","z"],e=new Array(12).fill().map(()=>new f.Line3),t=new Array(12).fill().map(()=>new f.Line3),i=new f.Vector3,s=new f.Vector3;return function(o,c=0,h=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(h||u)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),h&&h.copy(i),u&&u.copy(s)),0;const p=c*c,n=o.min,l=o.max,d=this.points;let g=1/0;for(let m=0;m<8;m++){const _=d[m];s.copy(_).clamp(n,l);const y=_.distanceToSquared(s);if(y<g&&(g=y,h&&h.copy(_),u&&u.copy(s),y<p))return Math.sqrt(y)}let v=0;for(let m=0;m<3;m++)for(let _=0;_<=1;_++)for(let y=0;y<=1;y++){const w=(m+1)%3,x=(m+2)%3,b=_<<w|y<<x,T=1<<m|_<<w|y<<x,M=d[b],L=d[T];e[v].set(M,L);const I=a[m],D=a[w],A=a[x],S=t[v],P=S.start,R=S.end;P[I]=n[I],P[D]=_?n[D]:l[D],P[A]=y?n[A]:l[D],R[I]=l[I],R[D]=_?n[D]:l[D],R[A]=y?n[A]:l[D],v++}for(let m=0;m<=1;m++)for(let _=0;_<=1;_++)for(let y=0;y<=1;y++){s.x=m?l.x:n.x,s.y=_?l.y:n.y,s.z=y?l.z:n.z,this.closestPointToPoint(s,i);const w=s.distanceToSquared(i);if(w<g&&(g=w,h&&h.copy(i),u&&u.copy(s),w<p))return Math.sqrt(w)}for(let m=0;m<12;m++){const _=e[m];for(let y=0;y<12;y++){const w=t[y];Ls(_,w,i,s);const x=i.distanceToSquared(s);if(x<g&&(g=x,h&&h.copy(i),u&&u.copy(s),x<p))return Math.sqrt(x)}}return Math.sqrt(g)}}();class Ps{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Kl extends Ps{constructor(){super(()=>new ge)}}const fe=new Kl;class Xl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Y=new Xl;let ze,dt;const $e=[],ni=new Ps(()=>new f.Box3);function Jl(a,e,t,i,s,r){ze=ni.getPrimitive(),dt=ni.getPrimitive(),$e.push(ze,dt),Y.setBuffer(a._roots[e]);const o=fs(0,a.geometry,t,i,s,r);Y.clearBuffer(),ni.releasePrimitive(ze),ni.releasePrimitive(dt),$e.pop(),$e.pop();const c=$e.length;return c>0&&(dt=$e[c-1],ze=$e[c-2]),o}function fs(a,e,t,i,s=null,r=0,o=0){const{float32Array:c,uint16Array:h,uint32Array:u}=Y;let p=a*2;if(oe(p,h)){const l=le(a,u),d=ce(p,h);return Z(a,c,ze),i(l,d,!1,o,r+a,ze)}else{let I=function(A){const{uint16Array:S,uint32Array:P}=Y;let R=A*2;for(;!oe(R,S);)A=he(A),R=A*2;return le(A,P)},D=function(A){const{uint16Array:S,uint32Array:P}=Y;let R=A*2;for(;!oe(R,S);)A=ue(A,P),R=A*2;return le(A,P)+ce(R,S)};const l=he(a),d=ue(a,u);let g=l,v=d,m,_,y,w;if(s&&(y=ze,w=dt,Z(g,c,y),Z(v,c,w),m=s(y),_=s(w),_<m)){g=d,v=l;const A=m;m=_,_=A,y=w}y||(y=ze,Z(g,c,y));const x=oe(g*2,h),b=t(y,x,m,o+1,r+g);let T;if(b===_r){const A=I(g),P=D(g)-A;T=i(A,P,!0,o+1,r+g,y)}else T=b&&fs(g,e,t,i,s,r,o+1);if(T)return!0;w=dt,Z(v,c,w);const M=oe(v*2,h),L=t(w,M,_,o+1,r+v);let C;if(L===_r){const A=I(v),P=D(v)-A;C=i(A,P,!0,o+1,r+v,w)}else C=L&&fs(v,e,t,i,s,r,o+1);return!!C}}const Pt=new f.Vector3,qi=new f.Vector3;function $l(a,e,t={},i=0,s=1/0){const r=i*i,o=s*s;let c=1/0,h=null;if(a.shapecast({boundsTraverseOrder:p=>(Pt.copy(e).clamp(p.min,p.max),Pt.distanceToSquared(e)),intersectsBounds:(p,n,l)=>l<c&&l<o,intersectsTriangle:(p,n)=>{p.closestPointToPoint(e,Pt);const l=e.distanceToSquared(Pt);return l<c&&(qi.copy(Pt),c=l,h=n),l<r}}),c===1/0)return null;const u=Math.sqrt(c);return t.point?t.point.copy(qi):t.point=qi.clone(),t.distance=u,t.faceIndex=h,t}const et=new f.Vector3,it=new f.Vector3,st=new f.Vector3,oi=new f.Vector2,ai=new f.Vector2,li=new f.Vector2,br=new f.Vector3,Ar=new f.Vector3,Tr=new f.Vector3,ci=new f.Vector3;function ec(a,e,t,i,s,r,o,c){let h;if(r===f.BackSide?h=a.intersectTriangle(i,t,e,!0,s):h=a.intersectTriangle(e,t,i,r!==f.DoubleSide,s),h===null)return null;const u=a.origin.distanceTo(s);return u<o||u>c?null:{distance:u,point:s.clone()}}function tc(a,e,t,i,s,r,o,c,h,u,p){et.fromBufferAttribute(e,r),it.fromBufferAttribute(e,o),st.fromBufferAttribute(e,c);const n=ec(a,et,it,st,ci,h,u,p);if(n){i&&(oi.fromBufferAttribute(i,r),ai.fromBufferAttribute(i,o),li.fromBufferAttribute(i,c),n.uv=f.Triangle.getInterpolation(ci,et,it,st,oi,ai,li,new f.Vector2)),s&&(oi.fromBufferAttribute(s,r),ai.fromBufferAttribute(s,o),li.fromBufferAttribute(s,c),n.uv1=f.Triangle.getInterpolation(ci,et,it,st,oi,ai,li,new f.Vector2)),t&&(br.fromBufferAttribute(t,r),Ar.fromBufferAttribute(t,o),Tr.fromBufferAttribute(t,c),n.normal=f.Triangle.getInterpolation(ci,et,it,st,br,Ar,Tr,new f.Vector3),n.normal.dot(a.direction)>0&&n.normal.multiplyScalar(-1));const l={a:r,b:o,c,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(et,it,st,l.normal),n.face=l,n.faceIndex=r}return n}function Ci(a,e,t,i,s,r,o){const c=i*3;let h=c+0,u=c+1,p=c+2;const n=a.index;a.index&&(h=n.getX(h),u=n.getX(u),p=n.getX(p));const{position:l,normal:d,uv:g,uv1:v}=a.attributes,m=tc(t,l,d,g,v,h,u,p,e,r,o);return m?(m.faceIndex=i,s&&s.push(m),m):null}function K(a,e,t,i){const s=a.a,r=a.b,o=a.c;let c=e,h=e+1,u=e+2;t&&(c=t.getX(c),h=t.getX(h),u=t.getX(u)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),r.x=i.getX(h),r.y=i.getY(h),r.z=i.getZ(h),o.x=i.getX(u),o.y=i.getY(u),o.z=i.getZ(u)}function ic(a,e,t,i,s,r,o,c){const{geometry:h,_indirectBuffer:u}=a;for(let p=i,n=i+s;p<n;p++)Ci(h,e,t,p,r,o,c)}function sc(a,e,t,i,s,r,o){const{geometry:c,_indirectBuffer:h}=a;let u=1/0,p=null;for(let n=i,l=i+s;n<l;n++){let d;d=Ci(c,e,t,n,null,r,o),d&&d.distance<u&&(p=d,u=d.distance)}return p}function rc(a,e,t,i,s,r,o){const{geometry:c}=t,{index:h}=c,u=c.attributes.position;for(let p=a,n=e+a;p<n;p++){let l;if(l=p,K(o,l*3,h,u),o.needsUpdate=!0,i(o,l,s,r))return!0}return!1}function nc(a,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=a.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,c,h,u=0;const p=a._roots;for(let l=0,d=p.length;l<d;l++)r=p[l],o=new Uint32Array(r),c=new Uint16Array(r),h=new Float32Array(r),n(0,u),u+=r.byteLength;function n(l,d,g=!1){const v=l*2;if(c[v+15]===Mi){const _=o[l+6],y=c[v+14];let w=1/0,x=1/0,b=1/0,T=-1/0,M=-1/0,L=-1/0;for(let C=3*_,I=3*(_+y);C<I;C++){let D=i[C];const A=s.getX(D),S=s.getY(D),P=s.getZ(D);A<w&&(w=A),A>T&&(T=A),S<x&&(x=S),S>M&&(M=S),P<b&&(b=P),P>L&&(L=P)}return h[l+0]!==w||h[l+1]!==x||h[l+2]!==b||h[l+3]!==T||h[l+4]!==M||h[l+5]!==L?(h[l+0]=w,h[l+1]=x,h[l+2]=b,h[l+3]=T,h[l+4]=M,h[l+5]=L,!0):!1}else{const _=l+8,y=o[l+6],w=_+d,x=y+d;let b=g,T=!1,M=!1;e?b||(T=e.has(w),M=e.has(x),b=!T&&!M):(T=!0,M=!0);const L=b||T,C=b||M;let I=!1;L&&(I=n(_,d,b));let D=!1;C&&(D=n(y,d,b));const A=I||D;if(A)for(let S=0;S<3;S++){const P=_+S,R=y+S,k=h[P],F=h[P+3],z=h[R],B=h[R+3];h[l+S]=k<z?k:z,h[l+S+3]=F>B?F:B}return A}}}function Ve(a,e,t,i,s){let r,o,c,h,u,p;const n=1/t.direction.x,l=1/t.direction.y,d=1/t.direction.z,g=t.origin.x,v=t.origin.y,m=t.origin.z;let _=e[a],y=e[a+3],w=e[a+1],x=e[a+3+1],b=e[a+2],T=e[a+3+2];return n>=0?(r=(_-g)*n,o=(y-g)*n):(r=(y-g)*n,o=(_-g)*n),l>=0?(c=(w-v)*l,h=(x-v)*l):(c=(x-v)*l,h=(w-v)*l),r>h||c>o||((c>r||isNaN(r))&&(r=c),(h<o||isNaN(o))&&(o=h),d>=0?(u=(b-m)*d,p=(T-m)*d):(u=(T-m)*d,p=(b-m)*d),r>p||u>o)?!1:((u>r||r!==r)&&(r=u),(p<o||o!==o)&&(o=p),r<=s&&o>=i)}function oc(a,e,t,i,s,r,o,c){const{geometry:h,_indirectBuffer:u}=a;for(let p=i,n=i+s;p<n;p++){let l=u?u[p]:p;Ci(h,e,t,l,r,o,c)}}function ac(a,e,t,i,s,r,o){const{geometry:c,_indirectBuffer:h}=a;let u=1/0,p=null;for(let n=i,l=i+s;n<l;n++){let d;d=Ci(c,e,t,h?h[n]:n,null,r,o),d&&d.distance<u&&(p=d,u=d.distance)}return p}function lc(a,e,t,i,s,r,o){const{geometry:c}=t,{index:h}=c,u=c.attributes.position;for(let p=a,n=e+a;p<n;p++){let l;if(l=t.resolveTriangleIndex(p),K(o,l*3,h,u),o.needsUpdate=!0,i(o,l,s,r))return!0}return!1}function cc(a,e,t,i,s,r,o){Y.setBuffer(a._roots[e]),ds(0,a,t,i,s,r,o),Y.clearBuffer()}function ds(a,e,t,i,s,r,o){const{float32Array:c,uint16Array:h,uint32Array:u}=Y,p=a*2;if(oe(p,h)){const l=le(a,u),d=ce(p,h);ic(e,t,i,l,d,s,r,o)}else{const l=he(a);Ve(l,c,i,r,o)&&ds(l,e,t,i,s,r,o);const d=ue(a,u);Ve(d,c,i,r,o)&&ds(d,e,t,i,s,r,o)}}const hc=["x","y","z"];function uc(a,e,t,i,s,r){Y.setBuffer(a._roots[e]);const o=ps(0,a,t,i,s,r);return Y.clearBuffer(),o}function ps(a,e,t,i,s,r){const{float32Array:o,uint16Array:c,uint32Array:h}=Y;let u=a*2;if(oe(u,c)){const n=le(a,h),l=ce(u,c);return sc(e,t,i,n,l,s,r)}else{const n=un(a,h),l=hc[n],g=i.direction[l]>=0;let v,m;g?(v=he(a),m=ue(a,h)):(v=ue(a,h),m=he(a));const y=Ve(v,o,i,s,r)?ps(v,e,t,i,s,r):null;if(y){const b=y.point[l];if(g?b<=o[m+n]:b>=o[m+n+3])return y}const x=Ve(m,o,i,s,r)?ps(m,e,t,i,s,r):null;return y&&x?y.distance<=x.distance?y:x:y||x||null}}const hi=new f.Box3,rt=new ge,nt=new ge,It=new f.Matrix4,Sr=new te,ui=new te;function fc(a,e,t,i){Y.setBuffer(a._roots[e]);const s=ms(0,a,t,i);return Y.clearBuffer(),s}function ms(a,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:c}=Y;let h=a*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Sr.set(t.boundingBox.min,t.boundingBox.max,i),s=Sr),oe(h,o)){const p=e.geometry,n=p.index,l=p.attributes.position,d=t.index,g=t.attributes.position,v=le(a,c),m=ce(h,o);if(It.copy(i).invert(),t.boundsTree)return Z(a,r,ui),ui.matrix.copy(It),ui.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>ui.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let w=v*3,x=(m+v)*3;w<x;w+=3)if(K(nt,w,n,l),nt.needsUpdate=!0,y.intersectsTriangle(nt))return!0;return!1}});for(let _=v*3,y=(m+v)*3;_<y;_+=3){K(rt,_,n,l),rt.a.applyMatrix4(It),rt.b.applyMatrix4(It),rt.c.applyMatrix4(It),rt.needsUpdate=!0;for(let w=0,x=d.count;w<x;w+=3)if(K(nt,w,d,g),nt.needsUpdate=!0,rt.intersectsTriangle(nt))return!0}}else{const p=a+8,n=c[a+6];return Z(p,r,hi),!!(s.intersectsBox(hi)&&ms(p,e,t,i,s)||(Z(n,r,hi),s.intersectsBox(hi)&&ms(n,e,t,i,s)))}}const fi=new f.Matrix4,Yi=new te,Rt=new te,dc=new f.Vector3,pc=new f.Vector3,mc=new f.Vector3,gc=new f.Vector3;function _c(a,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Yi.set(e.boundingBox.min,e.boundingBox.max,t),Yi.needsUpdate=!0;const c=a.geometry,h=c.attributes.position,u=c.index,p=e.attributes.position,n=e.index,l=fe.getPrimitive(),d=fe.getPrimitive();let g=dc,v=pc,m=null,_=null;s&&(m=mc,_=gc);let y=1/0,w=null,x=null;return fi.copy(t).invert(),Rt.matrix.copy(fi),a.shapecast({boundsTraverseOrder:b=>Yi.distanceToBox(b),intersectsBounds:(b,T,M)=>M<y&&M<o?(T&&(Rt.min.copy(b.min),Rt.max.copy(b.max),Rt.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:L=>Rt.distanceToBox(L),intersectsBounds:(L,C,I)=>I<y&&I<o,intersectsRange:(L,C)=>{for(let I=L,D=L+C;I<D;I++){K(d,3*I,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let A=b,S=b+T;A<S;A++){K(l,3*A,u,h),l.needsUpdate=!0;const P=l.distanceToTriangle(d,g,m);if(P<y&&(v.copy(g),_&&_.copy(m),y=P,w=A,x=I),P<r)return!0}}}});{const M=xt(e);for(let L=0,C=M;L<C;L++){K(d,3*L,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let I=b,D=b+T;I<D;I++){K(l,3*I,u,h),l.needsUpdate=!0;const A=l.distanceToTriangle(d,g,m);if(A<y&&(v.copy(g),_&&_.copy(m),y=A,w=I,x=L),A<r)return!0}}}}}),fe.releasePrimitive(l),fe.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=y,i.faceIndex=w,s&&(s.point?s.point.copy(_):s.point=_.clone(),s.point.applyMatrix4(fi),v.applyMatrix4(fi),s.distance=v.sub(s.point).length(),s.faceIndex=x),i)}function vc(a,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=a.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,c,h,u=0;const p=a._roots;for(let l=0,d=p.length;l<d;l++)r=p[l],o=new Uint32Array(r),c=new Uint16Array(r),h=new Float32Array(r),n(0,u),u+=r.byteLength;function n(l,d,g=!1){const v=l*2;if(c[v+15]===Mi){const _=o[l+6],y=c[v+14];let w=1/0,x=1/0,b=1/0,T=-1/0,M=-1/0,L=-1/0;for(let C=_,I=_+y;C<I;C++){const D=3*a.resolveTriangleIndex(C);for(let A=0;A<3;A++){let S=D+A;S=i?i[S]:S;const P=s.getX(S),R=s.getY(S),k=s.getZ(S);P<w&&(w=P),P>T&&(T=P),R<x&&(x=R),R>M&&(M=R),k<b&&(b=k),k>L&&(L=k)}}return h[l+0]!==w||h[l+1]!==x||h[l+2]!==b||h[l+3]!==T||h[l+4]!==M||h[l+5]!==L?(h[l+0]=w,h[l+1]=x,h[l+2]=b,h[l+3]=T,h[l+4]=M,h[l+5]=L,!0):!1}else{const _=l+8,y=o[l+6],w=_+d,x=y+d;let b=g,T=!1,M=!1;e?b||(T=e.has(w),M=e.has(x),b=!T&&!M):(T=!0,M=!0);const L=b||T,C=b||M;let I=!1;L&&(I=n(_,d,b));let D=!1;C&&(D=n(y,d,b));const A=I||D;if(A)for(let S=0;S<3;S++){const P=_+S,R=y+S,k=h[P],F=h[P+3],z=h[R],B=h[R+3];h[l+S]=k<z?k:z,h[l+S+3]=F>B?F:B}return A}}}function yc(a,e,t,i,s,r,o){Y.setBuffer(a._roots[e]),gs(0,a,t,i,s,r,o),Y.clearBuffer()}function gs(a,e,t,i,s,r,o){const{float32Array:c,uint16Array:h,uint32Array:u}=Y,p=a*2;if(oe(p,h)){const l=le(a,u),d=ce(p,h);oc(e,t,i,l,d,s,r,o)}else{const l=he(a);Ve(l,c,i,r,o)&&gs(l,e,t,i,s,r,o);const d=ue(a,u);Ve(d,c,i,r,o)&&gs(d,e,t,i,s,r,o)}}const xc=["x","y","z"];function wc(a,e,t,i,s,r){Y.setBuffer(a._roots[e]);const o=_s(0,a,t,i,s,r);return Y.clearBuffer(),o}function _s(a,e,t,i,s,r){const{float32Array:o,uint16Array:c,uint32Array:h}=Y;let u=a*2;if(oe(u,c)){const n=le(a,h),l=ce(u,c);return ac(e,t,i,n,l,s,r)}else{const n=un(a,h),l=xc[n],g=i.direction[l]>=0;let v,m;g?(v=he(a),m=ue(a,h)):(v=ue(a,h),m=he(a));const y=Ve(v,o,i,s,r)?_s(v,e,t,i,s,r):null;if(y){const b=y.point[l];if(g?b<=o[m+n]:b>=o[m+n+3])return y}const x=Ve(m,o,i,s,r)?_s(m,e,t,i,s,r):null;return y&&x?y.distance<=x.distance?y:x:y||x||null}}const di=new f.Box3,ot=new ge,at=new ge,Et=new f.Matrix4,Mr=new te,pi=new te;function bc(a,e,t,i){Y.setBuffer(a._roots[e]);const s=vs(0,a,t,i);return Y.clearBuffer(),s}function vs(a,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:c}=Y;let h=a*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Mr.set(t.boundingBox.min,t.boundingBox.max,i),s=Mr),oe(h,o)){const p=e.geometry,n=p.index,l=p.attributes.position,d=t.index,g=t.attributes.position,v=le(a,c),m=ce(h,o);if(Et.copy(i).invert(),t.boundsTree)return Z(a,r,pi),pi.matrix.copy(Et),pi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>pi.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let w=v,x=m+v;w<x;w++)if(K(at,3*e.resolveTriangleIndex(w),n,l),at.needsUpdate=!0,y.intersectsTriangle(at))return!0;return!1}});for(let _=v,y=m+v;_<y;_++){const w=e.resolveTriangleIndex(_);K(ot,3*w,n,l),ot.a.applyMatrix4(Et),ot.b.applyMatrix4(Et),ot.c.applyMatrix4(Et),ot.needsUpdate=!0;for(let x=0,b=d.count;x<b;x+=3)if(K(at,x,d,g),at.needsUpdate=!0,ot.intersectsTriangle(at))return!0}}else{const p=a+8,n=c[a+6];return Z(p,r,di),!!(s.intersectsBox(di)&&vs(p,e,t,i,s)||(Z(n,r,di),s.intersectsBox(di)&&vs(n,e,t,i,s)))}}const mi=new f.Matrix4,Zi=new te,kt=new te,Ac=new f.Vector3,Tc=new f.Vector3,Sc=new f.Vector3,Mc=new f.Vector3;function Cc(a,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Zi.set(e.boundingBox.min,e.boundingBox.max,t),Zi.needsUpdate=!0;const c=a.geometry,h=c.attributes.position,u=c.index,p=e.attributes.position,n=e.index,l=fe.getPrimitive(),d=fe.getPrimitive();let g=Ac,v=Tc,m=null,_=null;s&&(m=Sc,_=Mc);let y=1/0,w=null,x=null;return mi.copy(t).invert(),kt.matrix.copy(mi),a.shapecast({boundsTraverseOrder:b=>Zi.distanceToBox(b),intersectsBounds:(b,T,M)=>M<y&&M<o?(T&&(kt.min.copy(b.min),kt.max.copy(b.max),kt.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree){const M=e.boundsTree;return M.shapecast({boundsTraverseOrder:L=>kt.distanceToBox(L),intersectsBounds:(L,C,I)=>I<y&&I<o,intersectsRange:(L,C)=>{for(let I=L,D=L+C;I<D;I++){const A=M.resolveTriangleIndex(I);K(d,3*A,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=b,P=b+T;S<P;S++){const R=a.resolveTriangleIndex(S);K(l,3*R,u,h),l.needsUpdate=!0;const k=l.distanceToTriangle(d,g,m);if(k<y&&(v.copy(g),_&&_.copy(m),y=k,w=S,x=I),k<r)return!0}}}})}else{const M=xt(e);for(let L=0,C=M;L<C;L++){K(d,3*L,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let I=b,D=b+T;I<D;I++){const A=a.resolveTriangleIndex(I);K(l,3*A,u,h),l.needsUpdate=!0;const S=l.distanceToTriangle(d,g,m);if(S<y&&(v.copy(g),_&&_.copy(m),y=S,w=I,x=L),S<r)return!0}}}}}),fe.releasePrimitive(l),fe.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=y,i.faceIndex=w,s&&(s.point?s.point.copy(_):s.point=_.clone(),s.point.applyMatrix4(mi),v.applyMatrix4(mi),s.distance=v.sub(s.point).length(),s.faceIndex=x),i)}function Dc(){return typeof SharedArrayBuffer<"u"}const Wt=new Y.constructor,bi=new Y.constructor,Fe=new Ps(()=>new f.Box3),lt=new f.Box3,ct=new f.Box3,Ki=new f.Box3,Xi=new f.Box3;let Ji=!1;function Lc(a,e,t,i){if(Ji)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Ji=!0;const s=a._roots,r=e._roots;let o,c=0,h=0;const u=new f.Matrix4().copy(t).invert();for(let p=0,n=s.length;p<n;p++){Wt.setBuffer(s[p]),h=0;const l=Fe.getPrimitive();Z(0,Wt.float32Array,l),l.applyMatrix4(u);for(let d=0,g=r.length;d<g&&(bi.setBuffer(r[p]),o=me(0,0,t,u,i,c,h,0,0,l),bi.clearBuffer(),h+=r[d].length,!o);d++);if(Fe.releasePrimitive(l),Wt.clearBuffer(),c+=s[p].length,o)break}return Ji=!1,o}function me(a,e,t,i,s,r=0,o=0,c=0,h=0,u=null,p=!1){let n,l;p?(n=bi,l=Wt):(n=Wt,l=bi);const d=n.float32Array,g=n.uint32Array,v=n.uint16Array,m=l.float32Array,_=l.uint32Array,y=l.uint16Array,w=a*2,x=e*2,b=oe(w,v),T=oe(x,y);let M=!1;if(T&&b)p?M=s(le(e,_),ce(e*2,y),le(a,g),ce(a*2,v),h,o+e,c,r+a):M=s(le(a,g),ce(a*2,v),le(e,_),ce(e*2,y),c,r+a,h,o+e);else if(T){const L=Fe.getPrimitive();Z(e,m,L),L.applyMatrix4(t);const C=he(a),I=ue(a,g);Z(C,d,lt),Z(I,d,ct);const D=L.intersectsBox(lt),A=L.intersectsBox(ct);M=D&&me(e,C,i,t,s,o,r,h,c+1,L,!p)||A&&me(e,I,i,t,s,o,r,h,c+1,L,!p),Fe.releasePrimitive(L)}else{const L=he(e),C=ue(e,_);Z(L,m,Ki),Z(C,m,Xi);const I=u.intersectsBox(Ki),D=u.intersectsBox(Xi);if(I&&D)M=me(a,L,t,i,s,r,o,c,h+1,u,p)||me(a,C,t,i,s,r,o,c,h+1,u,p);else if(I)if(b)M=me(a,L,t,i,s,r,o,c,h+1,u,p);else{const A=Fe.getPrimitive();A.copy(Ki).applyMatrix4(t);const S=he(a),P=ue(a,g);Z(S,d,lt),Z(P,d,ct);const R=A.intersectsBox(lt),k=A.intersectsBox(ct);M=R&&me(L,S,i,t,s,o,r,h,c+1,A,!p)||k&&me(L,P,i,t,s,o,r,h,c+1,A,!p),Fe.releasePrimitive(A)}else if(D)if(b)M=me(a,C,t,i,s,r,o,c,h+1,u,p);else{const A=Fe.getPrimitive();A.copy(Xi).applyMatrix4(t);const S=he(a),P=ue(a,g);Z(S,d,lt),Z(P,d,ct);const R=A.intersectsBox(lt),k=A.intersectsBox(ct);M=R&&me(C,S,i,t,s,o,r,h,c+1,A,!p)||k&&me(C,P,i,t,s,o,r,h,c+1,A,!p),Fe.releasePrimitive(A)}}return M}const gi=new te,Cr=new f.Box3,Pc={strategy:ln,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class Is{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,r=e._indirectBuffer,o=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(h=>h.slice()),index:o?o.array.slice():null,indirectBuffer:r?r.slice():null}:c={roots:s,index:o?o.array:null,indirectBuffer:r},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:r,indirectBuffer:o}=e,c=new Is(t,{...i,[Gi]:!0});if(c._roots=r,c._indirectBuffer=o||null,i.setIndex){const h=t.getIndex();if(h===null){const u=new f.BufferAttribute(e.index,1,!1);t.setIndex(u)}else h.array!==s&&(h.array.set(s),h.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Pc,[Gi]:!1},t),t.useSharedArrayBuffer&&!Dc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Gi]||(jl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new f.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?vc:nc)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),r=new Uint16Array(i);o(0);function o(c,h=0){const u=c*2,p=r[u+15]===Mi;if(p){const n=s[c+6],l=r[u+14];e(h,p,new Float32Array(i,c*4,6),n,l)}else{const n=c+Vt/4,l=s[c+6],d=s[c+7];e(h,p,new Float32Array(i,c*4,6),d)||(o(n,h+1),o(l,h+1))}}}raycast(e,t=f.FrontSide,i=0,s=1/0){const r=this._roots,o=this.geometry,c=[],h=t.isMaterial,u=Array.isArray(t),p=o.groups,n=h?t.side:t,l=this.indirect?yc:cc;for(let d=0,g=r.length;d<g;d++){const v=u?t[p[d].materialIndex].side:n,m=c.length;if(l(this,d,v,e,c,i,s),u){const _=p[d].materialIndex;for(let y=m,w=c.length;y<w;y++)c[y].face.materialIndex=_}}return c}raycastFirst(e,t=f.FrontSide,i=0,s=1/0){const r=this._roots,o=this.geometry,c=t.isMaterial,h=Array.isArray(t);let u=null;const p=o.groups,n=c?t.side:t,l=this.indirect?wc:uc;for(let d=0,g=r.length;d<g;d++){const v=h?t[p[d].materialIndex].side:n,m=l(this,d,v,e,i,s);m!=null&&(u==null||m.distance<u.distance)&&(u=m,h&&(m.face.materialIndex=p[d].materialIndex))}return u}intersectsGeometry(e,t){let i=!1;const s=this._roots,r=this.indirect?bc:fc;for(let o=0,c=s.length;o<c&&(i=r(this,o,e,t),!i);o++);return i}shapecast(e){const t=fe.getPrimitive(),i=this.indirect?lc:rc;let{boundsTraverseOrder:s,intersectsBounds:r,intersectsRange:o,intersectsTriangle:c}=e;if(o&&c){const n=o;o=(l,d,g,v,m)=>n(l,d,g,v,m)?!0:i(l,d,this,c,g,v,t)}else o||(c?o=(n,l,d,g)=>i(n,l,this,c,d,g,t):o=(n,l,d)=>d);let h=!1,u=0;const p=this._roots;for(let n=0,l=p.length;n<l;n++){const d=p[n];if(h=Jl(this,n,r,o,s,u),h)break;u+=d.byteLength}return fe.releasePrimitive(t),h}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:r}=i;const o=fe.getPrimitive(),c=this.geometry.index,h=this.geometry.attributes.position,u=this.indirect?g=>{const v=this.resolveTriangleIndex(g);K(o,v*3,c,h)}:g=>{K(o,g*3,c,h)},p=fe.getPrimitive(),n=e.geometry.index,l=e.geometry.attributes.position,d=e.indirect?g=>{const v=e.resolveTriangleIndex(g);K(p,v*3,n,l)}:g=>{K(p,g*3,n,l)};if(r){const g=(v,m,_,y,w,x,b,T)=>{for(let M=_,L=_+y;M<L;M++){d(M),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let C=v,I=v+m;C<I;C++)if(u(C),o.needsUpdate=!0,r(o,p,C,M,w,x,b,T))return!0}return!1};if(s){const v=s;s=function(m,_,y,w,x,b,T,M){return v(m,_,y,w,x,b,T,M)?!0:g(m,_,y,w,x,b,T,M)}}else s=g}return Lc(this,e,t,s)}intersectsBox(e,t){return gi.set(e.min,e.max,t),gi.needsUpdate=!0,this.shapecast({intersectsBounds:i=>gi.intersectsBox(i),intersectsTriangle:i=>gi.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},r=0,o=1/0){return(this.indirect?Cc:_c)(this,e,t,i,s,r,o)}closestPointToPoint(e,t={},i=0,s=1/0){return $l(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Z(0,new Float32Array(i),Cr),e.union(Cr)}),e}}class Ic{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}class Rc extends Ic{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:vt&&vt.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,r)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=u=>{r(new Error(`GenerateMeshBVHWorker: ${u.message}`))},e.onmessage=u=>{const{data:p}=u;if(p.error)r(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:n,position:l}=p,d=Is.deserialize(n,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,n.index)if(t.index)t.index.array=n.index;else{const v=new f.BufferAttribute(n.index,1,!1);t.setIndex(v)}g.setBoundingBox&&(t.boundingBox=d.getBoundingBox(new f.Box3)),i.onProgress&&i.onProgress(p.progress),s(d),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const o=t.index?t.index.array:null,c=t.attributes.position.array,h=[c];o&&h.push(o),e.postMessage({index:o,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},h.map(u=>u.buffer).filter(u=>typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer)))})}}class Ec{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new f.Matrix4,this.mouse=new f.Vector3,this.rotateStart=new f.Vector2,this.rotateEnd=new f.Vector2,this.rotateDelta=new f.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new Ye,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._text=document.createElement("div"),this._textTimer=0,this._update=()=>{this.lock||(this._textTimer&&(window.clearTimeout(this._textTimer),this._textTimer=0),this._textTimer=window.setTimeout(()=>{this._text.style.opacity="0"},800),this.camera.updateMatrix(),this.invRotMat.extractRotation(this.camera.matrix).invert(),this.axes.forEach(s=>{this.setAxisPosition(s)}),this.axes.sort((s,r)=>s.position.z>r.position.z?1:-1),this.drawLayers(!0),this._text.style.opacity="1",this._text.innerText=this.camera.position.distanceTo(this.orbit.target).toFixed(2)+" m")},this.updateMouseFromEvent=s=>{this.rect=this.domElement.getBoundingClientRect();const r=this.domElement.width/this.domElement.clientWidth,o=this.domElement.height/this.domElement.clientHeight,{left:c,top:h}=this.rect;this.mouse.set((s.clientX-c)*r,(s.clientY-h)*o,0)},this.updateSelectedAxisUnderMouse=()=>{this.selectedAxis=null,this.axes.forEach(s=>{this.mouse.distanceTo(s.position)<s.size&&(this.selectedAxis=s)})},this.onPointerDown=s=>{this.rotateStart.set(s.clientX,s.clientY),this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.orbitState=this.orbit.enabled,this.orbit.enabled=!1,window.addEventListener("pointermove",this.onDrag,!1),window.addEventListener("pointerup",this.onPointerUp,!1)},this.onPointerUp=()=>{this.domElement.style.backgroundColor="#FFF0",setTimeout(()=>this.isDragging=!1,0),this.domElement.classList.remove("dragging"),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1)},this.onPointerEnter=()=>{this.domElement.style.backgroundColor="#FFF3",this.rect=this.domElement.getBoundingClientRect()},this.onPointerMove=s=>{if(this.lock||this.isDragging)return;const r=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),r!==this.selectedAxis&&this.drawLayers()},this.onDrag=s=>{this.lock||(this.isDragging||this.domElement.classList.add("dragging"),this.isDragging=!0,this.selectedAxis=null,this.rotateEnd.set(s.clientX,s.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(.5),this.rotateStart.copy(this.rotateEnd),this.orbit.update())},this.onMouseClick=s=>{if(this.lock||(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.isDragging||!this.selectedAxis))return;this._animator&&cancelAnimationFrame(this._animator);const r=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const o=this.camera.position.distanceTo(this.orbit.target);r.multiplyScalar(o),this.selectedAxis.axis==="z"?r.setZ(this.orbit.target.z+o):this.selectedAxis.axis==="-z"?r.setZ(this.orbit.target.z-o):r.setZ(this.orbit.target.z);const c=500,h=performance.now(),u=1,p=this.selectedAxis.axis,n=()=>{const d=performance.now()-h,g=Math.min(d/c,u);if(this.camera.position.lerp(r,g),this.orbit.update(),g!==u){this._animator=window.requestAnimationFrame(n);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",p);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",p),n()},this.drawCircle=(s,r=10,o="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-r,s.y-r,r*2,r*2),this.context.fillStyle=o,this.context.fill(),this.context.closePath())},this.drawLine=(s,r,o=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(r.x,r.y),this.context.lineWidth=o,this.context.strokeStyle=c,this.context.stroke(),this.context.closePath())},this.drawLayers=(s=!1)=>{this.context&&(s&&this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.axes.forEach(r=>{const o=this.selectedAxis===r,c=r.position.z>=-.01?r.color[0]:r.color[1];if(r.line&&this.drawLine(this.center,r.position,r.line,c),this.drawCircle(r.position,r.size,o?"#0066ff":c),r.label){const h=r.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,h+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(r.label,r.position.x,r.position.y)}}))},this.setAxisPosition=s=>{const r=s.direction.clone().applyMatrix4(this.invRotMat),o=s.size;s.position.set(r.x*(this.center.x-o/2-this.options.padding)+this.center.x,this.center.y-r.y*(this.center.y-o/2-this.options.padding),r.z)};const i={offset:new f.Vector2,size:90,padding:8,bubbleSizePrimary:8,bubbleSizeSecondary:6,lineWidth:2,fontSize:11,fontFamily:"arial",fontWeight:"normal",fontColor:"#fff",className:"orbit-controls-gizmo",colors:{x:["#f35f5f","#902525"],y:["#78da2f","#71ae45"],z:["#1d92fa","#d0d1d1"]}};this.options={...i,...t},this.orbit=e,this.camera=e.object,this.center=new f.Vector3(this.options.size/2,this.options.size/2,0),this.axes=this.createAxes(),this.domElement=this.createCanvas(this.options),this.orbit.addEventListener("change",this._update),this._text.style.cssText=`
|
|
3731
|
+
`,this._needsRender=!1}handleShadowClick(e){const t=e.target;if(!t)return;t.closest(".info")&&(e.preventDefault(),e.stopPropagation());const i=t.closest("[data-action]");if(!i)return;const s=i.getAttribute("data-action");if(s)switch(e.preventDefault(),e.stopPropagation(),s){case"remove-device":this.removeDevice();break;case"remove-function":{const r=i.getAttribute("data-function");r&&this.dispatchEvent(new CustomEvent("function-removed",{detail:r}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const r=i.getAttribute("data-function");r&&(this.dispatchEvent(new CustomEvent("function-added",{detail:r})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",nn);const J={ON_DROP:"slot-on-drop",ON_DEVICE_DELETED:"slot-on-device-deleted",ON_DEVICE_REPLACED:"slot-on-device-replaced",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_ADD_BUTTON_CLICKED:"slot-add-button-clicked",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class as extends be.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new Ye,this._slotContainer=new f.Group,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this._parentPos=new f.Vector3,this._wrapper=new f.Group,this._showSlot=!0,this._isMirror=!1,this.beforeInstall=void 0,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),t.setAttribute("data-ui-type","slot"),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new nn({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot()}}),this._slotUI.slot=this,this._slotUI.hide=!this._showSlot||this.isMirror,t.append(this._slotUI),this._parentPos.copy(this.props.slot.position),this._slotUI.addEventListener("function-removed",({detail:i})=>{this.removeFunction(i)}),this._slotUI.addEventListener("function-added",({detail:i})=>{this.addFunction(i)}),this.add(this._slotContainer),this.props.slot.add(this),setTimeout(()=>{var i;(i=this.props.slot.parent)==null||i.add(this._wrapper),this._wrapper.add(this.props.slot)},10),["dragenter","dragover","dragleave","drop"].forEach(i=>{t.addEventListener(i,this._preventDefaults,!1)}),t.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.toBeInstalled?this._emitter.emit(J.ON_ADD_BUTTON_CLICKED):this.selected=!this.selected}),t.addEventListener("dragover",i=>{if(i.preventDefault(),i.dataTransfer.dropEffect="copy",!this._canInstall){i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}}),t.addEventListener("drop",async i=>{var r;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(r=i.dataTransfer)==null?void 0:r.getData("application/json");if(s){const o=JSON.parse(s);try{await this.install(o),this._emitter.emit(J.ON_DROP,this)}catch(c){this._emitter.emit(J.ON_DROP_ERROR,c)}}else this._emitter.emit(J.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){if(this.props.follows.has(e)){const i=this.props.follows.get(e);if(i){let s="x";["height","mast"].includes(e)?s="z":["width","liftOuterWidth"].includes(e)&&(s="y");const r=i.initPos[s]>0?1:-1;this._wrapper.position[s]=(t-i.origin)*i.scale*r}}}async loadGlb(e){const i=await new Ut({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new Ut({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(r=>{r.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){var t;if(!this._loading){this._loading=!0,this.beforeInstall&&typeof this.beforeInstall=="function"&&await((t=this.beforeInstall)==null?void 0:t.call(this,e));try{const i=await this.loadGlb(e.url);if(!i)throw new Error(`Fail to load device from: ${e.url}`);if(i.traverse(s=>{s.userData.isDevice=!0}),this.isMirror&&i.scale.set(1,1,-1),e.bracketUrl){const s=await this.loadGlb(e.bracketUrl);if(s)this.clearSlot(),s.traverse(r=>{r.name.startsWith("Slot")&&this._bracketSlots.push(r),r.userData.isBracket=!0}),this._slotContainer.add(s);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(r=>{r.add(i)})}else this.clearSlot(),this._slotContainer.add(i);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._currentDeivceLoaded=i,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1),this._emitter.emit(J.ON_DEVICE_REPLACED,i)}catch(i){throw i}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._functions.forEach(t=>{e.includes(t)||this._functions.delete(t)}),this._allFunctions=new Set(e),this._slotUI.allFunctions=e}get functions(){return[...this._functions]}addFunction(e){this._allFunctions.has(e)&&(this._functions.add(e),this._slotUI.functions=[...this.functions],this._emitter.emit(J.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(J.ON_FUNCTION_REMOVED,e))}clearFunctions(){this._functions.forEach(e=>this.removeFunction(e))}addFunctions(e){e.forEach(t=>this.addFunction(t)),this._slotUI.functions=this.functions}changeName(e){var t;this.name=e,this.props.slot.userData.name=e,this.props.name=e,(t=this.element)==null||t.setAttribute("data-name",this.props.name)}clearSlot(){this._emitter.emit(J.ON_DEVICE_DELETED,this._currentDeivceLoaded),this._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),De(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._currentDeivceLoaded=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}get disabled(){return this._slotUI.disable}enable(){this.show(),this._slotUI.disable=!1}disable(){this._slotUI.disable=!0,this.hide()}hide(){this._slotUI.hide=!0}show(){this.isMirror||this.disabled||(this._slotUI.hide=!1)}get selected(){return this._selected}get focused(){return this._focused}set focused(e){this._focused=e,this._slotUI.focused=e}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){this._toBeInstalled=e,this._slotUI.toBeInstalled=e}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){this._toBeReplaced=e,this._slotUI.toBeReplaced=e}set selected(e){this.disabled||(e&&this._emitter.emit(J.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(J.ON_SELECTED,e),this.element.style.zIndex="100",this.selected?this.renderOrder=1/0:this.renderOrder=1)}get deviceSelected(){return this._deviceSelected}set deviceSelected(e){this._deviceSelected=e,this._emitter.emit(J.ON_DEVICE_SELECTED,e)}get error(){return this._hasError}set error(e){this._loading&&setTimeout(()=>{this.error=e},100),this._hasError=e,this._slotUI.hasError=e,this._emitter.emit(J.ON_ERROR_STATE_CHANGE,e)}getCanInstall(){return this._canInstall}canInstall(e){this._canInstall=e,this._slotUI.canInstall=e}dispose(){cancelAnimationFrame(this._timer),["dragenter","dragover","dragleave","drop"].forEach(e=>{this.element.addEventListener(e,this._preventDefaults,!1)}),this.props.follows.clear(),this.clearSlot(),this._emitter.removeAllListeners(),De(this._slotContainer),this.element.remove()}render(e){const t=this.element.style.transform,i=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);if(!i)return;const s=new f.Vector2(parseFloat(i[1]),parseFloat(i[2])),r=e.mousePos.distanceTo(s);let o=this.props.isMobile?12:18,c=38,h=30;if(this._canInstall&&(o=34,c=60,h=60),r<h){let u=(h-r)*1+o;r<20&&(u=c),u>c&&(u=c),this._slotUI.setSize(u)}else this._slotUI.setSize(o)}clone(e){return new f.Group}}class dl extends be.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=Cs(),s=i?"#ddd":"#eee";this.element.style.pointerEvents="auto",this.element.style.padding=i?"2px 6px":"3px 12px",this.element.style.borderTop=`1px solid ${s}`,this.element.style.borderBottom=this.element.style.borderTop;const r="6px",o=document.createElement("div");o.style.pointerEvents="none",Object.assign(o.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:r,width:"100%"}),this.element.append(o);const c=document.createElement("div");c.style.pointerEvents="none",Object.assign(c.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",bottom:"0",boxSizing:"border-box",height:r,width:"100%"}),this.element.append(c),this._text.style.fontSize=i?"10px":"14px",this._text.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif",this._text.style.color="#fff",this._text.style.fontWeight="500",this._text.style.transition="all .16s",this._text.innerText=e,this.element.append(this._text),this._text.addEventListener("pointermove",()=>{var h;o.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(h=this.onPointMove)==null||h.call(this)}),this._text.addEventListener("pointerleave",()=>{var h;o.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(h=this.onPointLeave)==null||h.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class vi extends f.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new dl(""),this._line.frustumCulled=!1,this.add(this._line,this._line2),this._showText&&(this.add(this._text),this._text.onPointMove=()=>{this._line.material.color.set("#000"),this._line2.material.color.set("#000")},this._text.onPointLeave=()=>{this._line.material.color.set("#666"),this._line2.material.color.set("#666")})}updateMaterial(e){this._line.material=e}reset(){var e,t;(e=this._line.geometry)==null||e.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line.computeLineDistances(),(t=this._line2.geometry)==null||t.dispose(),this._line2.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line2.computeLineDistances()}update(e,t,i=0){var d,g;(d=this._line.geometry)==null||d.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,r=new f.Vector3().subVectors(t,e).normalize();let o;Math.abs(r.z)>Math.abs(r.x)&&Math.abs(r.z)>Math.abs(r.y)?o=new f.Vector3(-r.y,r.x,0):Math.abs(r.y)>Math.abs(r.x)?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0),o.length()<.001&&(Math.abs(r.x)<.9?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0)),o.normalize();const c=new f.Vector3().addVectors(e,o.clone().multiplyScalar(s)),h=new f.Vector3().addVectors(e,o.clone().multiplyScalar(-s)),u=new f.Vector3().addVectors(t,o.clone().multiplyScalar(s)),p=new f.Vector3().addVectors(t,o.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new f.BufferGeometry,this._line2.geometry.setFromPoints([c,h,u,p]),this._line2.computeLineDistances();const n=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(n*1e3).toFixed(0)} mm`:this._text.text=`${(n*1e3).toFixed(0)} mm`;const l=new f.Vector3;l.addVectors(e,t).multiplyScalar(.5),this._text.position.copy(l),this.useStartEnd||(this._line2.visible=!1)}destroy(){this._text.dispose(),this.children.forEach(e=>De(e)),this.removeFromParent()}}class on extends f.Object3D{constructor(e,t){super(),this.radius=e,this._text=new pl(""),this._line=new vi(void 0,!1,!1),this._box=new f.Mesh,this._arc=new Rr.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new f.RingGeometry(e,e+.003,128),this._box.material=new f.MeshBasicMaterial({color:"#666",side:f.DoubleSide}),this._arc.geometry=new $i.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new Er.LineMaterial({color:"#eee",linewidth:2,resolution:new f.Vector2(window.innerWidth,window.innerHeight)}),this._arc.visible=!1,this._arc.rotateX(-Math.PI/2),this.position.y=t,this._arc.position.y=.001,this.add(this._box),this.add(this._arc),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1,this._arc.visible=!1}show(){this._text.show(),this._line.visible=!0}dispose(){this._updateTimer&&(clearTimeout(this._updateTimer),this._updateTimer=null),this._box.geometry&&this._box.geometry.dispose(),this._arc.geometry&&this._arc.geometry.dispose(),this._arc.visible=!1,this._previousPosition=null}update(e){var t;this.radius=e,(t=this._box.geometry)==null||t.dispose(),this._box.geometry=new f.RingGeometry(e,e+.003,128),this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06*e,gapSize:.06*e})),this._text.update((e*1e3).toFixed(0))}change(e){const t=e.clone();t.setZ(0),t.normalize().multiplyScalar(this.radius),this._text.position.set(t.x,t.y,t.z),this._text.updateColor("#eee"),this._line.update(t,new f.Vector3),this._previousPosition&&this._updateArc(this._previousPosition,t),this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._previousPosition=null,this._accumulatedAngle=0,this._lastAngle=null,this._clearArc(),this._updateTimer=null},this._updateDelay),this._previousPosition||(this._previousPosition=t.clone(),this._lastAngle=Math.atan2(t.y,t.x),this._accumulatedAngle=0)}_updateArc(e,t){const i=Math.atan2(t.y,t.x);if(this._lastAngle!==null){let h=i-this._lastAngle;h>Math.PI?h-=2*Math.PI:h<-Math.PI&&(h+=2*Math.PI),this._accumulatedAngle+=h}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),r=s+this._accumulatedAngle;let o=.006*this.radius;o<.003&&(o=.003),o>.006&&(o=.006);const c=this._createArcGeometry(s,r,this.radius+o);this._arc.geometry&&this._arc.geometry.dispose(),this._arc.geometry=c,this._arc.visible=!0}_clearArc(){this._text.updateColor(),this._arc.geometry&&(this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.computeLineDistances()),this._arc.visible=!1}_createArcGeometry(e,t,i){const s=[],r=t-e,o=Math.max(128,Math.floor(Math.abs(r)/(Math.PI/128))),c=r/o;for(let u=0;u<=o;u++){const p=e+u*c,n=Math.cos(p),l=Math.sin(p);s.push(i*n,0,i*l)}const h=new $i.LineGeometry;return h.setPositions(s),h.instanceCount=Math.max(0,s.length/3-1),h}}class pl extends be.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=Cs();this._wrapper.style.fontSize=i?"10px":"11px",this._wrapper.style.color="#fff",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.top="6px",this._wrapper.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif";const s=this._circle;s.style.position="relative",s.style.zIndex="10",s.style.width=s.style.height="5px",s.style.borderRadius="50%",s.style.background="#666",t.append(this._wrapper,s),this.update(e)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(e){this._wrapper.innerText="旋转半径:"+e+" mm",this.updateColor("#eee")}updateColor(e="#666"){this._circle.style.background=e}}const ml="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",gl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",hr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAYAAACPZlfNAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAdzSURBVHic7Z3hlZs6EIUvW4E7CB3EHcQdxB08OngugVTg8yrwSQVOKnBSwW4qsFOB3cF9PxhZQsYYjEAS1neOD7ssCwPXMxoNIGWIDJJLAAsASwCfAOTyey6bLOQDABf5qJ9P8vkry48sy05j2+ySzLcBjyC5QiXOV1kuWv+hPxcAvwD8BvCBSsRL6394JDjBSC4ArFEJtG7Y5ILqwp4A/JHlxfyoC04yN/4vh/bEz9Dim9uY+/8O4EfI4nmFZEFyz1veSe5Iri0BXB13Icfekjxaxz6TPMixXXt2fJDM5WLZF+og63MPNi1IbsQGW7zyJYUToXZyEUxP8iLSPUS80hLvdYQTobbWN3fHKvMLGpKrBq/bzla4htC3C8mbutIg3JnkxrddzhCvil4omwbhDqy6IPEisV5xJFn4tsk1rDJI8wtZ+rapN+JV73PzqnuwSk7MtvkQzflabdUxGsMdIGFSnfuZZFPHPxysELjnXDOoFsTbzAJA6dumRiyxSt/2+Ma6Hlvf9lyRb9QumjAwIZKQqOLAznvEEbFUcvFS7VVXWO/WvHsTLYnVnSBEM8JgEqsDlmi7qQ++TWL1xxKtnOqgKvs5J7H6I6KdJxFNsh5FygafxLqOxVgHme6b8QIYkWqcZoW6Mr13vvMXhboi8u56x+a34eXKTWMhXSO3SQirgqZi5WSniSvS1ChyFztUoTCcetjMoNGnHbqjTQqF42P1z4pnd7IwssKUwo8Mq/uIz2eN1NWMg3vzxoUWvu3pihEa+zU/4l3RJhoRC/ZcAkKdxkfnXUC8ggE1L+tWILbartW45o1D5IIpL+tWq43du4C4BQNqXlY82jB67wJmIdhSTG/vl1FXkaP1LiB+wQCA+m5+Ya5/s7b7V5a/J7Eq0cZ/svza+FcrHEZd1ZiJh5kp/q0e1D3tqMMhMA/BgFodt1DrzJD4jyx/TmpVoo3vsqyHxTmFQ2BWHpY3ngP1Pa9h5f1AmItgQC1bXAE6JKpXVn94sSrRxocsl4AW7Iss/0xuTuIRKqfQ7dic2i9gdiHxWlu0V8yi/QLmJRhQc6jlG3T7lYboCRfVji3eoMda+mjeNhEAJ1ku31ANYQekhCNklDafTA87eTEl0YWTLHNTsNSGhYvSZvEGPWDkyY8t1xt2ua/jd0Uyah/jYinBcvt+2OTIBTgAOHi6GJ3wbKeOfkaOn09sRNM4VGcXF8N1P0wiwNmyMx+63x7HV48dnuHqpJ40ZMNbBovmUrAGsRSTjuB2PRefgokhZcPFGCSaK8FaxCqf3ecAW66Cea8juhbNhWCBiaXridRtSD61IZZRzkQbKlhIYok9ut5rCOY9Q3Ml2hDBQhNLbKoJdpBfVr4MMnEh2rOChSiW2KWeCHg3X4wO5h2woaI9I1ioYolt6gHf/RuMOpU/k+pkWVYC+GatXmCkTit1p9hOvL6JLb7JZXky+0LTjn/UgWc9rY+HhexZCuqXIzZmfAzyAdJnROsqWAxiAbUnp9bmmxJn34bdo69oXQSLRSwAt10veqwndqVFtKJh21bBWD2WHotYuo5orDzIymAyxSbuiEZbtDbBqN8hCF4soGbv3lwZbOJh00W0e4LFJhZQG81hY67UHbMIeCRak2AxigXU2q+V/QdF7sWynrSJ1nFdDGJd2y/axXnqikfhx7z+tIjWhdK3/Y+gbqpuu1yM9IU+Nt8EfUQU00ex4YU+84/m6Df55NYNgPdDXhOFb3u7wLZwaGwUXVhUdBSt8G1nV9hlvBTjpKPIFm0eiFb4tq8P7No3ZkA3NJ/hjmiFb7v6QN3Nuh8OjY3VCQffib6HJVrh256+GN5Vdtk4ZwS1xUeIaIVvO/rSy7uMf9rF7mWx0su7jH9SD31E7WWxwfoI5v0eO6QuOiYvmwgOGcGcLkZ6TnSG+kGb7m1Xw05UtnVMoXE8WJ8hYljZjL4mKXsh6HIE85SAjAvHmCqFabKcUeAYk+UYO1ePWqXpqBxBXWx3f0vLyhpL5wd4MYyoNd7bnKzX6IJ+wipkOOXUlJN8M2YMfUxNaSUh+SQHnQFWszLtfGxME2/3whJr+j4t09T2nbHE8jO1vRiSRHtAMGIZBi2M8HhO2aNGskGVYOy8i2VCXQ+bLvsJGNYfci1929OIZeQ+qG/UREjE2QcvlsIKA0cGMjrBFFjt1ZGx3EcUww/Gt2w7Z2+T890Z5/seZQJmhcjjHBMSVuW6o3GepW+bBsHqfo/pbYc5hMkGrzpG6VX3YPWWyTl24e4IVfi2axRYZVBm+h+NcKxGHdhZtm9n5VX3EOHKBo8rGVByIt5UUFdzKDbvXkIomzvCKfE2PsQzRDpYNh1lfT61TcEhwq3lItniHSX0FGMIKAKtxWveecueAbVRmW8DbESUNaopHpe4HbDrhGqU6Q9UMyao309qgyzLTsa+7E8O4LMsm/YPVPOo/QTwI8uyoMbzD04wE7ngS/l8AbBC8wUeghL/J4CPLMt+Od6/U4IWrAlpQ5aoPOSTLHNoIRfGzxfoMd9P0J74F5VIlyzLopok6H/tVqA8kSYfTwAAAABJRU5ErkJggg==",_l="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYwAAACsCAYAAABo4pvIAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAzYSURBVHic7d3hcdtIEobhD05gmYGRgbkRLDKwMjiGoBCUgeoi0F0Evo1AdASiIxAcgbkR9P1Aj9mESIm2QMwAeJ8qlihKomeXwHzsHgCsBBTOzGpJK7+pd7/2r3+ceCw69Vh8nkvt/fbW4/H7vaR//H4bfqeNX6uqij8DilPlHgCWxcxW6ibvNFmn+x/DY/Fn0mHyPXVLE7F0ejKOf3/SpRO1B9c55wJNOg6rfrD1/5v7/31pbN97j7WS9lVVnf3vAoZGYGAwPqHW6ia+tbrJce0/Tj+Lk176+k/4/ui2tAnRA/VUaNbqQjXdr8PvtDoOku/xeyoXDIXAwMXMbK1DGHzUcTikiatVN1l9Uy8YmLiG1wuY2r9+0vHrUuvwOux0/PrseF1wKQIDR06EQvw+TTatunexrXgXOwmh+ku31AJc6xAoMUxaESboITAWyoOhVjdhfAr307vQnbpQ2KlrDe2yDBSj8EBJ20S/Qml12B7S/XZp7UIQGLMX3lk2Og6Gnbqd/1u4zySAI+EghRQmH9VtS7W6bWYrKpLFIDBmJFQNf6nbwdOCc6oYvqqrFrY5xof56AXJJ53e3r5J2hIi80FgTFRoIcRwaP32Vb7TUjFgTCdaW426thYhMgMExgT4u7m1Dm2lxn+UqoatCAcUyrffRodqpPEfbcWbm0khMAoUdrBUPTTyUFC3g7UsQmPKvBJpdNzOiq3TLQFSHgKjAKGM/6xDOb+T9Le6d17bXGMDxmJmjY73g1aHRfX/ESD5ERgZhBbTZx2OOCEggOCVAEn7CQEyMgJjJL2Nv9Hxhr/NNS5gKnr7UK0uQNiHMH1mtjKzGzN7MLNnvz34Rg/gHXz/aszs3vetH75/bbyCB8pmZrVvsI/WeTSzWz8/AsCV+L536/vcj7Dv1bnHBvxkZmt/l/MUqogb3uUAefSqjx++X95R3SOLEBK0moDCER4Y3YmQuKfVBEyLh8dd2I8JDwzD+6J3hAQwP2fCo849LkyI9z/TwnVqNxESwIyF8IgL5qxD4jTfYB786KYvZnaTe0wAxudzQTraivVJdE60nDaUpACkn92GuxAed1QdCxSqCY5wAvCm3pFWj8wZM2eHk+p+VhO5xwRgWrzqSCcIPrHWMTMeFGltgmoCwCB6ax33tLMnzM+biG2nOveYAMxPWAulXTU1vUNiuRAZgFGERfJngqNwrE8AKEVoVz0xHxWEoABQqhAczE85ERQApiIEB62qMREUAKaK4BiJH4nwRFAAmDqC40rCeRQEBYBZ8Y5JumZVnXs8k9U7RO0u93gA4Br6cx2nAvyisE5B6gJYBA+OB684uFr2W3rtpzr3eABgbL31jTr3eIoUTq2/yz0WAMjNugsbPpvZbe6xFMOrimfSFACO+fyYzhhvco8nq1BVkKAAcIZXGz/M7D73WEYXqgoWtQHgAr1qo849nlGEvtwm91gAYGoWsbbBEVAAMIxw5YvH2Z23EVpQy+u/AcAV+Hkb9z63rnOPZxBhsWa+5RMAZDKbFlVIvzr3WABgrsbq4ny4xpOm/pqklaQ/q6pqr/HvAAAkn2P/lLSa1FFUIenuco8FAJYmXMiwzj2WVxEWAJBfCI0yF8PN7MYXtze5xwIASxeu+t3kHsuRMLAy0wwAFsjM1kW9kQ9hUeceCwDgWFgq2OQeSPp4wTrrQAAAZ3lo5Ks0QljQhgKAwmVrT1n3iVCEBQBMSAiNcebuUNrwmbMAMDF+ROv11539Ylf5F08AAL8tXH+qvuY/8sgVZwFg+vzkvqdrPfm9mT1e5ckBAKPz604NWwSM1vMCAIxm8HM0wiI3R0QBwMz4kVPDFAS+bjHtD+YAAJzli+DvW3IY5EkAAMV715XGaUUBwHKEOb/+nT/+wudaAMBy+KG2D7/6R42XJ6srjQsAUCCf+y+/kocvdDfXGxIAoETpIysu/eWGhW4AWK6Lz83w6oILCwLAQl1UZaS1i5HGBAAo1JtrGV5dbMYbEgCgRF5lnF6e8EuX/xh5TACAQvUvGfIh/OxW0n/GHhAAoFhbSS/bUp4kzdijAQCU6eS6dvqM7kxjAgAUKhYTqSW1Fu0oAMBLW3UZ0eHMbgDAKUcnc6ejo7huFACgzzPCpK4lVUvaV1W1zzoqAEBxPBt2ZtZ8UNeb2uYdEgCgYK2k9QdJnyR9yzsWAEDBvkr6mFpSbdahAABKtpNXGGtJrF8AAF6zSudhtDlHAQAo2l4hMAAAOGcvaaV0fC0AAOeYmVFhAAAu8kHSPl7vHACAyDOi/aDUmwIA4BUEBgDgLbV0CAwAAM5ZSdp9kJ/Bl3kwAIBy1fI1jO+S/so7FgBAwT5J+pYqjDrvWAAABWvUZUV3QgYfoAQA6IsfspdO3NuKdQwAwEtrSbuqqvYpMP6W9K+MAwIAlOmzuozo+Id8P+cbDwCgRN6OavoPPr94EACwWP1iIl588N+iLQUAOPgs6b8vHjWzmrYUACBJR0el739WGFVVtZJaM9tkGBcAoCCeBbuqqk5fPsrMbqgyAAAXrWv7L21GGREAoDhePDxe8osbqgwAWC4ze7z4qFmqDABYJj+U9u3qIvwBaxkAsDB+3ahfPyfPzB7M7O4qowIAFMfM7szsy+/8Ye3H4NbDDwsAUBIzW79rzve0oTUFADPnC923+Z8EAFAsM7v9pYXuV56o9kUQPi8DAGbm3a2oE0+48dAY5gkBANmFguBm6Ce+N7OnQZ8UAJCNLzncX+vJnzjUFgCmz4uA969bvPIPpPKFRXAAmKiwzLB6+7ff9w9dp+cFALg6v5LHeOfYhVV1jpwCgIkIc3cz9j+8ITQAYBpCWGxyDWAzamkDAPhl4VJPm9wD4RwNAChUWHfe5B6LJNpTAFAib0OVExaJf+hGeQMDgAUKb+TLPKI1pNld7rEAwFKlK40Xv1QQ+mV3uccCAEszmbBIPDSe/FP7rnsmIQAgfbzqg8+9de7x/DK/Vsl0kg4AJih0dq5zIcGx+AdzcP0pALgCn2N/zGaODYvh97SoAGAYs+3ieH/tcbL9NQAoRGhBPcx6PqVFBQC/L1xdYxlzaDiK6nHW6QgAA/F582GWLahLeP9tPos1AHAFYWH7LvdYsvJLilBtAECPVxWPi60qzmFtAwAO/IxtqopzQpo+2tifCAUABVjMEVBDscNnznJpEQCL0FvU3uQez6T4eRvpIlp3BAeAuWKuG0hI3fwfLwgAAwrnVNB+GpIfTcX6BoDJC0HBlS+uieAAMFUhKFinGBPBAWAqCIpChBeC4ABQFIKiUP7CPBEcAHIjKCYitKo4RA3AaPxUgNjx2OQeEy4UguOHB0ede0wA5qd3wt2Dma1zjwm/yV/MdFVc2lUABuFvSh+sw3kUc+Ll4m1Y57ilXQXgV/XXJwiKmeu1q+6pOgC8JlQTqe3U5B4TRmaH61WldhWL5AAk/Wxnx2qCtVB0wjsI1jqABbPuatlfwtpEk3tMKFRY64hHWDW5xwXgesxsHVpOj15Z0G3A5bwkTZcdfiY8gPnwkLin5YTBecuK8AAm7ERI3HPeBK6qFx4caQUUrHeEEyGBfM6FB/1PIA9fh7wJIfFESKA4vuYRF8wf/fs699iAOfNWU9r3LCxc17nHBrzJDhciS4fqplKY6gMYwIlW04NXFuxfV1LlHsBS+BrHWtJnSbWkVtLfknZVVW1zjQuYit4+1Ejain1oVARGBv4OKG74taSd2PiBn3oBsVb3Jmurw36yzzW2pSIwCuABciPpkwgQLNSZgIj7QZtrbOgQGAXyAGkk/aVux1mr23F2kr5J2rLzYMr8iKVah228UVc97CR9VbeNU0EUhsCYgNDCWqvbwRr/0VZdgOzEDoZChe230SEgpMP2uxUtpkkgMCbKDxds1LWxUpjsddgJW1HGY2Qn3tzUOrRYU/XAdjlRBMaMnAkR6bidtZPU8m4O7+VrDisdt06l43Boq6raZRkgBkdgzJyHSOoXx0X1Vl018l2HxUWCBEe8Yqj9tla3DaX7O3XbTmortVQO80ZgLFCYBFKQfAz39+omgr1obS2GL0KndlLaHtJjMRjSGwuqhgUiMHDkREWyCt+3OoRJqkxa8c6yeP66xttH/5pe3/S67tS9tjtJe4IBEYGBi4UwWek4TFLF0uplhbIPj+9peQ0vhMEqfP0Uvq91/Lq0IhTwGwgMDKb3Lnalw7vY9H0tDw4dqhPpUK1IIVy0wIDxduGpWy3pD70MhpWO/1/uJP2jEA5UfxgKgYFRhQmx1vGk99F/JT6WbvverfXf3aubHJM23E+/27//wqUT6htXPk1jTeoz9//Q6UCIf9/q5X/zd/WqNXGQAkZGYKB4YaLuf43300QsvZy8+9+/9fhrzoVP+8pjMdjiY0eBRiWA0v0fPGR4m68wwtkAAAAASUVORK5CYII=";class ur extends be.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this.isController=!0,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new Ye,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeListener=this._emitter.removeListener.bind(this._emitter),this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let n=(Date.now()-this._startAt)/200;n>4&&(n=4);let l=this._initial+.005*n*this._direction;if(l>this.props.max||l<this.props.min){this.mechanism&&(l<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):l>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=l,!this.mechanism)return;this.mechanism.position.setZ(l),this._emitter.emit("change",l)}},i.setAttribute("data-ui-type","mechanism");const s=Cs();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(n=>{n.name===e.userData.target.name&&(this.mechanism=n)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const r=n=>{n.stopPropagation()},o=n=>{n.preventDefault(),n.stopPropagation()},c={capture:!1,passive:!0},h={capture:!1,passive:!1};["pointerdown","pointerup","pointermove","pointercancel","click","dblclick","contextmenu","mousemove"].forEach(n=>{i.addEventListener(n,r,c)}),["wheel","dragenter","dragover","dragleave","drop"].forEach(n=>{i.addEventListener(n,o,h)});const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.transform="translateX(-50%) rotate(-180deg)",u.style.marginBottom="5px",u.style.width=u.style.height=s?"34px":"44px",u.style.background=`url(${hr}) center no-repeat`,u.style.backgroundSize="100% auto",u.setAttribute("data-direction","up"),u.style.transition="all .2s";const p=document.createElement("div");if(p.style.position="absolute",p.style.left="0",p.style.transform="translateX(-50%)",u.style.bottom=p.style.top="8px",p.style.width=p.style.height=u.style.width,p.style.background=`url(${hr}) center no-repeat`,p.style.backgroundSize="100% auto",p.style.transition="all .2s",p.setAttribute("data-direction","down"),Array.from([u,p]).forEach(n=>{s||n.addEventListener("mousemove",()=>{n.style.filter="invert(100%)"}),n.addEventListener("mouseleave",()=>{n.style.filter=""}),n.addEventListener("pointerdown",()=>{this.mechanism&&(n.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=n.getAttribute("data-direction")==="up"?1:-1,this._update())}),n.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),n.style.filter=""}),n.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),n.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:n,rotateDuration:l,rotateStep:d,rotateMax:g,rotateMin:v}=e.userData;let m;if(n&&(t.traverse(_=>{_.name===n.name&&(m=_)}),m)){const _=document.createElement("div");_.style.background=`url(${_l}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.position="absolute",_.style.top="-50%",_.style.left="-50%",_.style.width=s?"140px":"160px",_.style.height=s?"70px":"80px",_.style.transform="translateX(-50%) translateY(-50%)",i.append(_);const y=document.createElement("div");y.style.background=`url(${gl}) center no-repeat`,y.style.backgroundSize="100% auto",y.style.width=y.style.height=s?"20px":"26px",y.style.position="absolute",y.style.top="0",y.style.transform="translateY(-50%)",y.style.marginBottom="5px",y.setAttribute("data-direction","left"),i.append(y);const w=document.createElement("div");w.style.background=`url(${ml}) center no-repeat`,w.style.backgroundSize="100% auto",w.style.width=w.style.height=s?"20px":"26px",w.style.position="absolute",y.style.left=w.style.right=s?"62px":"69px",w.style.top="0",w.style.transform="translateY(-50%)",w.style.marginBottom="5px",w.setAttribute("data-direction","right"),i.append(w),Array.from([y,w]).forEach(x=>{s||x.addEventListener("mousemove",()=>{x.style.filter="invert(100%)"}),x.addEventListener("mouseleave",()=>{x.style.filter=""}),x.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;x.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=x.getAttribute("data-direction")==="left"?1:-1;let b=d/180*Math.PI*this._direction+m.rotation.z;b>g/180*Math.PI?b=g/180*Math.PI:b<v/180*Math.PI&&(b=v/180*Math.PI),this._timer=new wi(m.rotation).to({z:b}).duration(l).start(),this._update()}),x.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),x.style.filter=""}),x.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),x.style.filter=""})})}}i.append(u,p),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix()}hide(){this.element.style.display="none",this.traverse(e=>{e.visible=!1,e instanceof be.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof be.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class vl extends Rn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new Ye,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new f.Vector2,this._targetSize=new f.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=h=>{const{pageX:u,pageY:p}=h;this.endNode.setPointerCapture(h.pointerId),this._mouseStart.set(u,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=h=>{if(!this._mouseStart.x)return;const{pageX:u,pageY:p}=h;let n=u-this._mouseStart.x,l=n+this._targetSize.x;this._sizeFlag==="height"&&(n=p-this._mouseStart.y,l=n*this._direction+this._targetSize.y);const d=l%10;l=l-d,n=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(n=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=h=>{this.endNode.releasePointerCapture(h.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,r=s.distanceTo(i);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const o=document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.bottom="0",t.append(o),this._textNode=document.createElement("div"),this._textNode.innerText=r.toFixed(2)+" m",o.append(this._textNode);const c=document.createElement("div");this.endNode=c,c.style.position="absolute",c.style.left="auto",c.style.right="0",c.style.width="4px",c.style.height="4px",c.style.background="#0066FF",c.style.borderRadius="50%",c.style.margin="-2px -2px 0 0",c.style.cursor="pointer",o.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",o.style[this._sizeFlag]=r*100+"px",o.style.textAlign="center",this._sizeFlag==="height"?(o.style.borderLeft="0.1px dashed #fff",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):o.style.borderBottom="0.1px dashed #fff",c.addEventListener("pointerdown",this._pointerdown),c.addEventListener("pointermove",this._pointermove),c.addEventListener("pointerup",this._pointercancel),s[this.props.axios]<i[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(e=>e.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(e=>e.clear()),this._caches=[]}}class yl extends f.Object3D{constructor(){super(),this._box3=new f.Box3,this._line11=new vi("长:"),this._line12=new vi("宽:"),this._line13=new vi("高:"),this._outline=new on(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this.head=0,this.tail=0,this._change=()=>{if(!this._app)return;const e=this._app.camera;e&&this._outline.change(e.position)},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(e){this._app=e,this._app.controls.addEventListener("change",this._change)}reset(){this.hide(),this._line11.reset()}generate(e,t=0){e&&(this._object=e),this.update(t)}show(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!0,this._outline.visible=!0,this._outline.show(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!0,s instanceof be.CSS2DObject&&(s.element.style.visibility="visible")})})}hide(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!1,this._outline.visible=!1,this._outline.hide(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!1,s instanceof be.CSS2DObject&&(s.element.style.visibility="hidden")})})}destroy(){var e;(e=this._app)==null||e.controls.removeEventListener("change",this._change),this._line11.destroy(),this._line12.destroy(),this._line13.destroy()}update(e=0){if(!this._object)return;const t=this._object,{box:i,maxRadius:s,hasLength:r,hasHeight:o,hasWidth:c}=sl(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=r,this._hasHeightConfig=o,this._box3.copy(i),this._radius=s,this.follow&&e&&(this.originOffset=(this.followOrigin-e)*this.followScale),this._outline.update(this._radius),this._change();const h=this._box3.min.x,u=this._box3.max.x,p=this._box3.min.z,n=this._box3.max.z,l=this._box3.min.y,d=this._box3.max.y;let g=.2;const v=new f.Vector3(h,d,0),m=new f.Vector3(u,d,0);this._line11.update(v.clone().sub(new f.Vector3(0,-g/1.8,0)),m.clone().sub(new f.Vector3(0,-g/1.8,0)),this._radius);const _=new f.Vector3(u,l,0);this._line12.update(m.clone().add(new f.Vector3(g,0,0)),_.clone().add(new f.Vector3(g,0,0)),this._radius);const y=new f.Vector3(h,d,p),w=new f.Vector3(h,d,n),x=y.clone();x.y-=g/6;const b=w.clone();b.y-=g/6,this._line13.update(x,b,this._radius)}}class xe extends f.Mesh{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._lineMaterial=new f.LineDashedMaterial({color:new f.Color("#000"),dashSize:.015,gapSize:.015}),this._currentLength=.6,this._currentWidth=.4,this._currentHeight=.2,this.material=new f.MeshBasicMaterial({color:new f.Color("#0f5fd5"),transparent:!0,opacity:.4}),this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}dispose(){var t,i,s,r,o;(t=this.lineSegments)==null||t.removeFromParent(),(s=(i=this.lineSegments)==null?void 0:i.geometry)==null||s.dispose(),this.lineSegments=void 0,(r=this.geometry)==null||r.dispose();const e=this.material;Array.isArray(e)?e.forEach(c=>{var h;return(h=c==null?void 0:c.dispose)==null?void 0:h.call(c)}):(o=e==null?void 0:e.dispose)==null||o.call(e),this._lineMaterial.dispose(),this.clear()}clearAll(){this.dispose()}clone(e){return new xe(this._currentLength,this._currentWidth,this._currentHeight)}_generate(e,t,i){De(this),this.clear(),this.geometry.dispose(),this.geometry=new f.BoxGeometry(e,t,i),this.geometry.translate(0,0,i/2);const s=new f.EdgesGeometry(this.geometry);this.lineSegments=new f.LineSegments(s,this._lineMaterial),this.add(this.lineSegments),this.lineSegments.geometry.dispose(),this.lineSegments.geometry=s,this.lineSegments.computeLineDistances()}}const xl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class ls{constructor(e){this._props=e,this.name="",this.transparentTexture=Ds.load(xl),this._offscreen=new OffscreenCanvas(0,0),this._defaults={...e},this.target=e.target,this.parent=this.target.parent,this.reset()}get imageSize(){return this._props.imageSize}get size(){return this._props.size}get defaultConfigs(){return{canvasWidth:200,canvasHeight:200,scaleX:1,scaleY:1,x:0,y:0,ox:0,oy:0,url:this._defaults.imageUrl}}clear(){this.change()}change(e,t=new f.Vector2(1,1),i=new f.Vector2){this.imageUrl=e;let s;if(e){const r=new Image;r.crossOrigin="anonymous",r.src=e,r.onload=async()=>{var u;let o=window.devicePixelRatio*2;this._offscreen.width=r.width+o,this._offscreen.height=r.height+o;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(r,o/2,o/2,r.width,r.height),s=new f.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=f.SRGBColorSpace,s.wrapS=s.wrapT=f.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const h=this._props.target;h.material&&((u=h.material.map)==null||u.dispose(),s?(h.material.map=s,h.material.opacity=1):(h.material.map=this.transparentTexture,h.material.opacity=0))}}else{const r=this._props.target;r.material&&(r.material.map=this.transparentTexture)}}reset(){this._props=this._defaults,this.name=this._props.name,this.imageUrl=this._props.imageUrl,this.target=this._props.target,this.change(this.imageUrl||"")}dispose(){this._offscreen=null}}function Vi(a){return a.type?a.type==="Mesh":a.isMesh}class fr{constructor(e,t){this.links=[],this.target=new f.Vector3,this.targetQuaternion=new f.Quaternion,this.iterations=15,this.minDistance=.001,this.maxStep=.35,this.damping=.35,this.maxAngleDelta=.8,this._restQuaternions=[],this._initialRestQuaternions=[],this._axesLocal=[],this._axisMins=[],this._axisMaxs=[],this._jointStates=[],this._frameAppliedAbsDelta=[],this._jointWeights=[],this._stableFrameCount=0,this._lastFramePosErrSq=1/0,this._lastFrameOriErr=1/0,this._tmpEffectorPos=new f.Vector3,this._tmpTargetPos=new f.Vector3,this._tmpLinkPos=new f.Vector3,this._tmpAxisWorld=new f.Vector3,this._tmpVToEff=new f.Vector3,this._tmpVToTar=new f.Vector3,this._tmpProjE=new f.Vector3,this._tmpProjT=new f.Vector3,this._tmpCross=new f.Vector3,this._tmpEffWorldQ=new f.Quaternion,this._tmpTarWorldQ=new f.Quaternion,this._tmpDirCurP=new f.Vector3,this._tmpDirTarP=new f.Vector3,this._tmpDirCurS=new f.Vector3,this._tmpDirTarS=new f.Vector3,this._tmpAxisQ=new f.Quaternion,this._tmpParentWorldQ=new f.Quaternion,this._tmpLocalBeforeQ=new f.Quaternion,this._tmpWorldBeforeQ=new f.Quaternion,t&&(typeof t.iterations=="number"&&(this.iterations=t.iterations),typeof t.minDistance=="number"&&(this.minDistance=t.minDistance),typeof t.maxStep=="number"&&(this.maxStep=t.maxStep),typeof t.damping=="number"&&(this.damping=t.damping),typeof t.maxAngleDelta=="number"&&(this.maxAngleDelta=t.maxAngleDelta),t.orientation&&(this.orientation=Object.assign({enabled:!1},t.orientation))),this.links=(Array.isArray(e)?e:[]).map(s=>{const r=Array.isArray(s.axes)&&s.axes.length>0?s.axes.map(o=>({axis:o.axis.clone(),min:o.min,max:o.max,value:o.value})):void 0;return{object:s.object,ikTcp:!!s.ikTcp,weight:typeof s.weight=="number"?s.weight:void 0,axes:r}});const i=this.links.map(s=>s.object);this._axesLocal=i.map((s,r)=>this._normalizeAxesForLink(r)),this._axisMins=i.map((s,r)=>this._getAxisMinsForLink(r)),this._axisMaxs=i.map((s,r)=>this._getAxisMaxsForLink(r)),this._restQuaternions=i.map((s,r)=>{var u;const o=s.quaternion.clone(),c=this._axesLocal[r],h=this.links[r];if(c&&c.length>0&&h.axes)for(let p=c.length-1;p>=0;p--){const n=c[p],l=((u=h.axes[p])==null?void 0:u.value)??0;Math.abs(l)>1e-6&&(this._tmpAxisQ.setFromAxisAngle(n,l).invert(),o.multiply(this._tmpAxisQ))}return o}),this._initialRestQuaternions=this._restQuaternions.map(s=>s.clone()),this._jointStates=i.map((s,r)=>{var u;const o=((u=this._axesLocal[r])==null?void 0:u.length)??0,c=this.links[r],h=new Array(o).fill(0);if(c.axes&&c.axes.length>0)for(let p=0;p<o;p++)h[p]=c.axes[p].value??0;return{currentAngle:h[0]??0,prevAngle:h[0]??0,currentAngles:h,prevAngles:[...h]}}),this._frameAppliedAbsDelta=i.map((s,r)=>{var o;return new Array(((o=this._axesLocal[r])==null?void 0:o.length)??0).fill(0)}),this._jointWeights=this._buildJointWeights(t==null?void 0:t.weightProfile)}_buildJointWeights(e){var u;const t=(e==null?void 0:e.root)??.3,i=(e==null?void 0:e.middle)??.68,s=(e==null?void 0:e.end)??1,r=Math.max(1,(e==null?void 0:e.curve)??1),o=this.links.length,c=this.links.some(p=>typeof p.weight=="number"),h=[];for(let p=0;p<o;p++){const n=(u=this.links[p])==null?void 0:u.weight;if(c&&typeof n=="number"&&Number.isFinite(n)){h[p]=Math.max(0,n);continue}if(o<=1){h[p]=Math.max(0,s);continue}const l=p/(o-1),d=l<=.5?Math.pow(l/.5,r):Math.pow((l-.5)/.5,r),g=l<=.5?t+(i-t)*d:i+(s-i)*d;h[p]=Math.max(0,g)}return h}_normalizeAxesForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>{const s=i.axis.clone();return s.lengthSq()>0&&s.normalize(),s}):[]:[]}_getAxisMinsForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>i.min):[]:[]}_getAxisMaxsForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>i.max):[]:[]}_applyLinkAngles(e){var o;const t=(o=this.links[e])==null?void 0:o.object;if(!t)return;const i=this._axesLocal[e],r=this._jointStates[e].currentAngles??[];t.quaternion.copy(this._restQuaternions[e]);for(let c=0;c<i.length;c++){const h=i[c],u=r[c]??0;!h||h.lengthSq()<1e-12||Math.abs(u)<1e-12||(this._tmpAxisQ.setFromAxisAngle(h,u),t.quaternion.multiply(this._tmpAxisQ))}}_getAxisWorld(e,t,i){var u;const s=(u=this.links[e])==null?void 0:u.object;if(!s)return i.set(0,0,0);const r=this._axesLocal[e],o=r==null?void 0:r[t];if(!o||o.lengthSq()<1e-12)return i.set(0,0,0);s.parent?s.parent.getWorldQuaternion(this._tmpParentWorldQ):this._tmpParentWorldQ.identity(),this._tmpLocalBeforeQ.copy(this._restQuaternions[e]);const h=this._jointStates[e].currentAngles??[];for(let p=0;p<t;p++){const n=r[p],l=h[p]??0;!n||n.lengthSq()<1e-12||Math.abs(l)<1e-12||(this._tmpAxisQ.setFromAxisAngle(n,l),this._tmpLocalBeforeQ.multiply(this._tmpAxisQ))}return this._tmpWorldBeforeQ.copy(this._tmpParentWorldQ).multiply(this._tmpLocalBeforeQ),i.copy(o).applyQuaternion(this._tmpWorldBeforeQ).normalize()}resetToInitialPose(){for(let e=0;e<this.links.length;e++){const t=this._initialRestQuaternions[e];t&&(this._restQuaternions[e].copy(t),this.links[e].object.quaternion.copy(t));const i=this._jointStates[e];i.currentAngles&&i.currentAngles.fill(0),i.prevAngles&&i.prevAngles.fill(0),this._frameAppliedAbsDelta[e]&&this._frameAppliedAbsDelta[e].fill(0)}this.links.length>0&&this.links[0].object.updateMatrixWorld(!0)}get restQuaternions(){return this._restQuaternions}_isOrientationEnabled(){var e;return!!((e=this.orientation)!=null&&e.enabled)}_getEndIndices(){var o,c;let e=-1;for(let h=0;h<this.links.length;h++)(o=this.links[h])!=null&&o.ikTcp&&(e=h);e<0&&(e=this.links.length-1);const t=!!((c=this.links[e])!=null&&c.ikTcp),i=t?e:this.links.length-1;let s=-1;for(let h=i;h>=0;h--){const u=this._axesLocal[h];if(u&&u.length>0){s=h;break}}return s<0&&(s=Math.max(0,Math.min(this.links.length-1,i))),{ikTcpIndex:e,effectorJointIndex:s,orientationEvalIndex:t?e:s}}_getOrientationDefaults(){var l,d,g,v,m,_,y;const{effectorJointIndex:e,orientationEvalIndex:t}=this._getEndIndices(),i=e,s=this._getOrientationChainStartIndex(i),r=(((l=this.orientation)==null?void 0:l.forwardAxis)??new f.Vector3(1,0,0)).clone().normalize(),o=(((d=this.orientation)==null?void 0:d.upAxis)??new f.Vector3(0,0,1)).clone().normalize(),c=(((g=this.orientation)==null?void 0:g.targetForwardAxis)??new f.Vector3(1,0,0)).clone().normalize(),h=(((v=this.orientation)==null?void 0:v.targetUpAxis)??new f.Vector3(0,0,1)).clone().normalize(),u=((m=this.orientation)==null?void 0:m.forwardWeight)??1,p=((_=this.orientation)==null?void 0:_.upWeight)??.15,n=((y=this.orientation)==null?void 0:y.minAngle)??Math.PI/180;return{effectorIndex:i,orientationEvalIndex:t,orientationStartIndex:s,effectorForwardAxis:r,effectorUpAxis:o,targetForwardAxis:c,targetUpAxis:h,forwardWeight:u,upWeight:p,minAngle:n}}_orientationErrorAngle(){if(!this._isOrientationEnabled()||this.links.length<1)return 0;const{orientationEvalIndex:e,effectorForwardAxis:t,effectorUpAxis:i,targetForwardAxis:s,targetUpAxis:r,forwardWeight:o,upWeight:c}=this._getOrientationDefaults();this.links[Math.max(0,Math.min(this.links.length-1,e))].object.getWorldQuaternion(this._tmpEffWorldQ),this._tmpTarWorldQ.copy(this.targetQuaternion),this._tmpDirCurP.copy(t).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarP.copy(s).applyQuaternion(this._tmpTarWorldQ).normalize();let u=o*this._angleBetweenNormalized(this._tmpDirCurP,this._tmpDirTarP);return c>0&&(this._tmpDirCurS.copy(i).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarS.copy(r).applyQuaternion(this._tmpTarWorldQ).normalize(),u+=c*this._angleBetweenNormalized(this._tmpDirCurS,this._tmpDirTarS)),u}_angleBetweenNormalized(e,t){const i=Math.max(-1,Math.min(1,e.dot(t)));this._tmpCross.crossVectors(e,t);const s=this._tmpCross.length();return Math.atan2(s,i)}_getOrientationChainStartIndex(e){let t=0;for(let i=e;i>=0;i--){const s=this._axesLocal[i];if(s&&s.length>0&&(t+=s.length),t>=3)return i}return 0}bindRestPose(){for(let e=0;e<this.links.length;e++){this._restQuaternions[e].copy(this.links[e].object.quaternion);const t=this._jointStates[e];t.currentAngle=0,t.prevAngle=0,t.currentAngles&&t.currentAngles.fill(0),t.prevAngles&&t.prevAngles.fill(0)}}updateJointStateFromCurrentPose(){var e;for(let t=0;t<this.links.length;t++){const i=(e=this.links[t])==null?void 0:e.object;if(!i)continue;const s=this._restQuaternions[t],r=i.quaternion;this._updateLinkAnglesFromQuaternion(t,r,s),this._frameAppliedAbsDelta[t]&&this._frameAppliedAbsDelta[t].fill(0)}}rebindRestPoseWithBase(e){var t;for(let i=0;i<this.links.length;i++){const s=(t=this.links[i])==null?void 0:t.object;if(!s)continue;const r=e[i]??s.quaternion,o=s.quaternion;this._restQuaternions[i].copy(r),this._initialRestQuaternions[i]&&this._initialRestQuaternions[i].copy(r),this._updateLinkAnglesFromQuaternion(i,o,r),this._frameAppliedAbsDelta[i]&&this._frameAppliedAbsDelta[i].fill(0)}}_updateLinkAnglesFromQuaternion(e,t,i){const s=this._axesLocal[e]??[],r=this._jointStates[e];r.currentAngles||(r.currentAngles=new Array(s.length).fill(0)),r.prevAngles||(r.prevAngles=new Array(s.length).fill(0));const o=this._tmpLocalBeforeQ.copy(i).invert().multiply(t),c=this._tmpWorldBeforeQ.copy(o);for(let h=0;h<s.length;h++){const u=s[h];if(!u||u.lengthSq()<1e-12){r.currentAngles[h]=0,r.prevAngles[h]=0;continue}const p=this._tmpVToEff.set(c.x,c.y,c.z).dot(u);this._tmpAxisQ.set(u.x*p,u.y*p,u.z*p,c.w).normalize();const n=2*Math.atan2(p,this._tmpAxisQ.w);r.currentAngles[h]=n,r.prevAngles[h]=n,this._tmpParentWorldQ.copy(this._tmpAxisQ).invert(),c.premultiply(this._tmpParentWorldQ)}r.currentAngle=r.currentAngles[0]??0,r.prevAngle=r.currentAngle}get jointStates(){return this._jointStates}_clamp(e,t,i){return t!==void 0&&e<t&&(e=t),i!==void 0&&e>i&&(e=i),e}_signedAngleAroundAxis(e,t,i){const s=e.dot(i),r=t.dot(i);this._tmpProjE.copy(e).addScaledVector(i,-s),this._tmpProjT.copy(t).addScaledVector(i,-r);const o=this._tmpProjE.lengthSq(),c=this._tmpProjT.lengthSq(),h=1e-10;if(o<h||c<h)return 0;const u=Math.sqrt(o),p=Math.sqrt(c);this._tmpProjE.multiplyScalar(1/u),this._tmpProjT.multiplyScalar(1/p);const n=this._tmpProjE.dot(this._tmpProjT);this._tmpCross.crossVectors(this._tmpProjE,this._tmpProjT);const l=i.dot(this._tmpCross),d=Math.max(-1,Math.min(1,n));let g=Math.atan2(l,d);const v=Math.min(u,p),m=Math.sin(Math.PI/180*4.6),_=Math.sin(Math.PI/180*30);if(v<=m)return 0;if(v<_){const y=(v-m)/(_-m);g*=Math.max(0,Math.min(1,y))}return g}update(){var C,I,D;if(this.links.length<2)return;const{ikTcpIndex:e,effectorJointIndex:t}=this._getEndIndices(),i=this.links[Math.max(0,Math.min(this.links.length-1,e))].object,s=this._tmpEffectorPos,r=this._tmpTargetPos.copy(this.target),o=this._tmpLinkPos,c=this._tmpAxisWorld,h=this._tmpVToEff,u=this._tmpVToTar;let p=this._isOrientationEnabled();const n=p?this._getOrientationDefaults():void 0;i.getWorldPosition(s);const l=this.minDistance*this.minDistance,d=(n==null?void 0:n.minAngle)??Math.PI/180,g=s.distanceToSquared(r),v=p?this._orientationErrorAngle():0,m=g<=l,_=!p||v<=d,y=this.minDistance*2,w=y*y,x=d*2,b=g<=this._lastFramePosErrSq*1.5&&(!p||v<=this._lastFrameOriErr*1.5);if(m&&_||g<=w&&(!p||v<=x))if(b){if(this._stableFrameCount++,this._stableFrameCount>=2){this._lastFramePosErrSq=g,this._lastFrameOriErr=v;return}}else this._stableFrameCount=0;else this._stableFrameCount=0;this._lastFramePosErrSq=g,this._lastFrameOriErr=v;for(let A=0;A<this._frameAppliedAbsDelta.length;A++)this._frameAppliedAbsDelta[A]&&this._frameAppliedAbsDelta[A].fill(0);for(let A=0;A<this._jointStates.length;A++){const S=this._jointStates[A];if(S.prevAngle=S.currentAngle,S.prevAngles&&S.currentAngles)for(let L=0;L<S.currentAngles.length;L++)S.prevAngles[L]=S.currentAngles[L]}let T=g,M=v,P=0;for(let A=0;A<this.iterations;A++){i.getWorldPosition(s);const S=s.distanceToSquared(r),L=S<l,R=p?this._orientationErrorAngle():0,k=!p||R<=d;if(L&&k)break;if(S>=T*.9&&(!p||R>=M*.5)){if(P++,P>=2)break}else P=0;T=S,M=R;let F=0,z=p?t:e===t?t-1:t;z=Math.max(0,Math.min(this.links.length-1,z));for(let B=z;B>=0;B--){const N=this.links[B].object,W=this._axesLocal[B];if(!(!W||W.length===0))for(let O=0;O<W.length;O++){const j=W[O];if(!j||j.lengthSq()<1e-12||(i.getWorldPosition(s),N.getWorldPosition(o),this._getAxisWorld(B,O,c),c.lengthSq()<1e-12))continue;let U=0;if(!(B===t&&e===t)){h.subVectors(s,o),u.subVectors(r,o);const X=h.lengthSq(),ee=u.lengthSq();X>=1e-12&&ee>=1e-12&&(h.multiplyScalar(1/Math.sqrt(X)),u.multiplyScalar(1/Math.sqrt(ee)),U+=this._signedAngleAroundAxis(h,u,c))}if(p&&B>=n.orientationStartIndex&&B<=n.effectorIndex){this.links[Math.max(0,Math.min(this.links.length-1,n.orientationEvalIndex))].object.getWorldQuaternion(this._tmpEffWorldQ),this._tmpTarWorldQ.copy(this.targetQuaternion),this._tmpDirCurP.copy(n.effectorForwardAxis).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarP.copy(n.targetForwardAxis).applyQuaternion(this._tmpTarWorldQ).normalize();const ee=this._signedAngleAroundAxis(this._tmpDirCurP,this._tmpDirTarP,c);let Rs=0;n.upWeight>0&&(this._tmpDirCurS.copy(n.effectorUpAxis).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarS.copy(n.targetUpAxis).applyQuaternion(this._tmpTarWorldQ).normalize(),Rs=this._signedAngleAroundAxis(this._tmpDirCurS,this._tmpDirTarS,c)),U+=n.forwardWeight*ee+n.upWeight*Rs}if(Math.abs(U)<1e-6)continue;const Ze=Math.max(0,this._jointWeights[B]??1);if(Ze<=0)continue;if(U*=Math.max(0,Math.min(1,this.damping))*Ze,this.maxStep>0){const X=this.maxStep*Ze;if(X<=0)continue;U>X?U=X:U<-X&&(U=-X)}if(this.maxAngleDelta>0){const X=((C=this._frameAppliedAbsDelta[B])==null?void 0:C[O])??0,ee=Math.max(0,this.maxAngleDelta-X);if(ee<=0)continue;U>ee?U=ee:U<-ee&&(U=-ee)}const _e=this._jointStates[B];_e.currentAngles||(_e.currentAngles=new Array(W.length).fill(0));const Gt=(_e.currentAngles[O]??0)+U,Nt=(I=this._axisMins[B])==null?void 0:I[O],ve=(D=this._axisMaxs[B])==null?void 0:D[O];U=this._clamp(Gt,Nt,ve)-(_e.currentAngles[O]??0),!(Math.abs(U)<1e-9)&&(_e.currentAngles[O]=(_e.currentAngles[O]??0)+U,_e.currentAngle=_e.currentAngles[0]??0,Math.abs(U)>F&&(F=Math.abs(U)),this._frameAppliedAbsDelta[B]&&(this._frameAppliedAbsDelta[B][O]=(this._frameAppliedAbsDelta[B][O]??0)+Math.abs(U)),this._applyLinkAngles(B),N.updateMatrixWorld(!0))}}if(F<1e-5&&S<=l*4&&(!p||R<=d*2))break}}}const Re=new f.Raycaster,Ct=new f.Vector3,wl=new f.Quaternion,dr=new f.Vector3,pr=new f.Vector3,Wi={type:"change"},mr={type:"mouseDown",mode:null},gr={type:"mouseUp",mode:null},bl={type:"objectChange"},ei=new WeakMap,ti=new WeakMap,Dt=new WeakMap;function Al(a){if(!this.domElement)return{x:0,y:0,button:a.button};if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-((a.clientY-e.top)/e.height)*2+1,button:a.button}}function ii(a,e,t){const i=e.intersectObject(a,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}function Ui(a){return a==="E"?"rotate":a==="XYZ"?"translate":null}class Tl extends f.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("FreeTransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(e=>{const t=e;t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}const $=class $ extends f.Object3D{constructor(e){super(),this.picker=new f.Object3D,this.gizmo=new f.Object3D,this.helper=new f.Object3D,this._matMove=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1}),this._matRing=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1}),this._matInvisible=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:0}),this._matHelper=new f.LineBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:.6}),this._arcSegments=96,this._arcStartAngleOffset=.05,this._moveColorDefault=new f.Color(16777215),this._moveColorActive=new f.Color(0),this._moveOpacityDefault=1,this._moveOpacityRingActive=.5,this._ringColorDefault=new f.Color(16777215),this._ringColorActive=new f.Color(0),this._ringOpacityDefault=1,this._ringOpacityActive=.6,this._ringScale=1,this._ringTargetScale=1.5,this._ringScaleTweening=!1,this._isMoveActive=!1,this._isRingActive=!1,this._isMoveHover=!1,this._isDragging=!1,this._isExpanded=!1,this.controls=e,this._moveMesh=new f.Mesh(new f.CircleGeometry($.MOVE_RADIUS,96),this._matMove),this._moveMesh.rotateX(-Math.PI/2),this._moveMesh.name="XYZ",this._moveMesh.renderOrder=1/0,this._ringMesh=new f.Mesh(new f.TorusGeometry($.RING_RADIUS,$.RING_TUBE,48,96),this._matRing),this._ringMesh.name="E",this._ringMesh.renderOrder=1e3,this._arcGeom=new $i.LineGeometry,this._arcPositions=new Float32Array((this._arcSegments+1)*3),this._arcGeom.setPositions(this._arcPositions),this._arcGeom.instanceCount=0;const t=new Er.LineMaterial({color:16777215,linewidth:2,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1});t.resolution.set(window.innerWidth,window.innerHeight),this._arcLine=new Rr.Line2(this._arcGeom,t),this._arcLine.renderOrder=1001,this._arcLine.visible=!1,this.gizmo.add(this._ringMesh),this.gizmo.add(this._moveMesh),this.gizmo.add(this._arcLine);const i=new f.Mesh(new f.CircleGeometry($.PICKER_MOVE_RADIUS,32),this._matInvisible);i.name="XYZ",i.renderOrder=1/0;const s=new f.Mesh(new f.TorusGeometry($.RING_RADIUS+.005,$.PICKER_RING_TUBE,8,48),this._matInvisible);s.name="E",s.renderOrder=1/0,this.picker.add(s),this.picker.add(i),this.picker.visible=!1;const r=new f.OctahedronGeometry(.01,2),o=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:.7});this._startMarker=new f.Mesh(r,o),this._startMarker.renderOrder=1/0,this._startMarker.visible=!1,this._endMarker=new f.Mesh(r,o),this._endMarker.renderOrder=1/0,this._endMarker.visible=!1,this._deltaGeom=new f.BufferGeometry,this._deltaGeom.setAttribute("position",new f.Float32BufferAttribute(new Float32Array(2*3),3)),this._deltaLine=new f.Line(this._deltaGeom,this._matHelper),this._deltaLine.renderOrder=1/0,this._deltaLine.visible=!1,this.helper.add(this._startMarker),this.helper.add(this._endMarker),this.helper.add(this._deltaLine),this.add(this.gizmo),this.add(this.picker),this.add(this.helper)}get isExpanded(){return this._isExpanded}set isExpanded(e){var s;if(this._isExpanded===e)return;this._isExpanded=e;const t=e?this._ringTargetScale:1;this._ringScaleTweening=!0,(s=this._ringScaleTween)==null||s.stop();const i={scale:this._ringScale};this._ringScaleTween=new ne.Tween(i).to({scale:t},200).easing(ne.Easing.Quadratic.Out).onUpdate(()=>{this._ringScale=i.scale}).onStop(()=>{this._ringScaleTweening=!1}).onComplete(()=>{this._ringScaleTweening=!1}).start()}get isRingScaleTweening(){return this._ringScaleTweening}updateMatrixWorld(e){var y,w;const t=this.controls,i=t.axis,s=t.mode,r=t.worldPosition,o=t.size;this._arcLine.material.resolution.set(window.innerWidth,window.innerHeight);const h=(x,b=1)=>{x.position.copy(r),x.scale.set(1,1,1).multiplyScalar(o*b),x.visible=!0};h(this._moveMesh),h(this._ringMesh,this._ringScale),h(this._arcLine,this._ringScale),this.picker.position.copy(r),this.picker.scale.set(1,1,1).multiplyScalar(o);for(const x of this.picker.children)x.quaternion.copy(t.cameraQuaternion),x.scale.set(1,1,1).multiplyScalar(this._ringScale);this._ringMesh.quaternion.copy(t.cameraQuaternion),this._arcLine.quaternion.copy(t.cameraQuaternion),this._moveMesh.lookAt(t.cameraPosition);const u=s==="default"||s==="translate",p=s==="default"||s==="rotate";this._moveMesh.visible=u,this._ringMesh.visible=p;for(const x of this.picker.children)x.name==="XYZ"&&(x.visible=u),x.name==="E"&&(x.visible=p);const n=t.dragging,l=!n&&i==="XYZ",d=!n&&i==="E",g=l||n&&i==="XYZ",v=d||n&&i==="E";if(g!==this._isMoveActive){this._isMoveActive=g;const x=g?this._moveColorActive:this._moveColorDefault;(y=this._moveColorTween)==null||y.stop();const b={r:this._matMove.color.r,g:this._matMove.color.g,b:this._matMove.color.b};this._moveColorTween=new ne.Tween(b).to({r:x.r,g:x.g,b:x.b},200).easing(ne.Easing.Quadratic.Out).onUpdate(()=>{this._matMove.color.setRGB(b.r,b.g,b.b)}).start()}if(v!==this._isRingActive){this._isRingActive=v;const x=v?this._ringColorActive:this._ringColorDefault,b=v?this._ringOpacityActive:this._ringOpacityDefault,T=v?this._moveOpacityRingActive:this._moveOpacityDefault;this._matMove.opacity=T,(w=this._ringColorTween)==null||w.stop();const M={r:this._matRing.color.r,g:this._matRing.color.g,b:this._matRing.color.b,opacity:this._matRing.opacity};this._ringColorTween=new ne.Tween(M).to({r:x.r,g:x.g,b:x.b,opacity:b},200).easing(ne.Easing.Quadratic.Out).onUpdate(()=>{this._matRing.color.setRGB(M.r,M.g,M.b),this._matRing.opacity=M.opacity}).start()}const m=n;if(this._startMarker.visible=m,this._endMarker.visible=m,this._deltaLine.visible=m,m){this._startMarker.position.copy(t.worldPositionStart),this._endMarker.position.copy(t.worldPosition),this._startMarker.scale.set(1,1,1).multiplyScalar(o),this._endMarker.scale.set(1,1,1).multiplyScalar(o);const x=this._deltaGeom.getAttribute("position");x.setXYZ(0,t.worldPositionStart.x,t.worldPositionStart.y,t.worldPositionStart.z),x.setXYZ(1,t.worldPosition.x,t.worldPosition.y,t.worldPosition.z),x.needsUpdate=!0,this._deltaGeom.computeBoundingSphere()}const _=m&&p&&i==="E";if(this._arcLine.visible=_,_){const x=t.pointStart,b=t.pointEnd;if(x.lengthSq()>1e-12&&b.lengthSq()>1e-12){dr.set(1,0,0).applyQuaternion(t.cameraQuaternion),pr.set(0,1,0).applyQuaternion(t.cameraQuaternion);const T=x.dot(dr),M=x.dot(pr),P=Math.atan2(M,T),C=t.rotationAngle;if(Math.abs(C)<1e-4)this._arcLine.visible=!1,this._arcGeom.instanceCount=0;else{const I=this._arcSegments,D=Math.max(2,Math.min(I,Math.ceil(Math.abs(C)/(Math.PI*2)*I))),A=C/D,S=$.RING_RADIUS,L=Math.sign(C)*this._arcStartAngleOffset;for(let F=0;F<=D;F++){const z=P+L+A*F,B=Math.cos(z)*S,N=Math.sin(z)*S,W=F*3;this._arcPositions[W]=B,this._arcPositions[W+1]=N,this._arcPositions[W+2]=0}for(let F=D+1;F<=I;F++){const z=F*3;this._arcPositions[z]=0,this._arcPositions[z+1]=0,this._arcPositions[z+2]=0}this._arcGeom.setPositions(this._arcPositions),this._arcGeom.instanceCount=D,this._arcLine.computeLineDistances(),this._arcGeom.computeBoundingSphere();const R=Math.cos(P)*$.RING_RADIUS*this._ringScale,k=Math.sin(P)*$.RING_RADIUS*this._ringScale;Ct.set(R,k,0),Ct.applyQuaternion(t.cameraQuaternion),Ct.multiplyScalar(o),Ct.add(r),this._startMarker.position.copy(Ct)}}else this._arcLine.visible=!1,this._arcGeom.instanceCount=0}else this._arcGeom.instanceCount=0;super.updateMatrixWorld(e)}};$.RING_RADIUS=.18,$.RING_TUBE=.003,$.PICKER_RING_TUBE=.025,$.MOVE_RADIUS=.04,$.PICKER_MOVE_RADIUS=.2;let cs=$;class Sl extends f.Mesh{constructor(){super(new f.PlaneGeometry(1e5,1e5,2,2),new f.MeshBasicMaterial({visible:!1,wireframe:!0,transparent:!0,opacity:.1,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),this.isTransformControlsPlane=!0}updateMatrixWorld(e){const t=this,i=t.dragging?t.worldPositionStart:t.worldPosition;this.position.copy(i),this.quaternion.copy(t.cameraQuaternion),super.updateMatrixWorld(e)}}class Ml extends f.EventDispatcher{constructor(e,t=null){super(),this.domElement=null,this._offset=new f.Vector3,this._startNorm=new f.Vector3,this._endNorm=new f.Vector3,this._cameraScale=new f.Vector3,this._parentPosition=new f.Vector3,this._parentQuaternion=new f.Quaternion,this._parentQuaternionInv=new f.Quaternion,this._parentScale=new f.Vector3,this._worldScaleStart=new f.Vector3,this._worldQuaternionInv=new f.Quaternion,this._worldScale=new f.Vector3,this._positionStart=new f.Vector3,this._quaternionStart=new f.Quaternion,this._scaleStart=new f.Vector3,this._capturePointerId=null,this._captureDocument=null,this._hoverShieldActive=!1;const i=new Tl(this);this._root=i;const s=new cs(this);this._gizmo=s,i.add(s);const r=new Sl;this._plane=r,i.add(r);const o=this;function c(h,u){let p=u;Object.defineProperty(o,h,{get(){return p!==void 0?p:u},set(n){p!==n&&(p=n,r[h]=n,s[h]=n,o.dispatchEvent({type:h+"-changed",value:n}),o.dispatchEvent(Wi))}}),o[h]=u,r[h]=u,s[h]=u}c("camera",e),c("object",void 0),c("enabled",!0),c("depthTest",!0),c("axis",null),c("mode","default"),c("space","world"),c("size",.25),c("dragging",!1),c("gizmoPriority",!0),c("worldPosition",new f.Vector3),c("worldPositionStart",new f.Vector3),c("worldQuaternion",new f.Quaternion),c("worldQuaternionStart",new f.Quaternion),c("cameraPosition",new f.Vector3),c("cameraQuaternion",new f.Quaternion),c("pointStart",new f.Vector3),c("pointEnd",new f.Vector3),c("rotationAxis",new f.Vector3),c("rotationAngle",0),c("eye",new f.Vector3),this._getPointer=Al.bind(this),this._onPointerDown=this._handlePointerDown.bind(this),this._onPointerHover=this._handlePointerHover.bind(this),this._onPointerMove=this._handlePointerMove.bind(this),this._onPointerUp=this._handlePointerUp.bind(this),this._onPointerDownCapture=this._handlePointerDownCapture.bind(this),this._onPointerMoveCapture=this._handlePointerMoveCapture.bind(this),this._onPointerUpCapture=this._handlePointerUpCapture.bind(this),this._onMouseMoveCapture=this._handleMouseMoveCapture.bind(this),t!==null&&this.connect(t)}connect(e){this.domElement=e,this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none";const t=this.domElement.ownerDocument;this._captureDocument=t,t.addEventListener("pointerdown",this._onPointerDownCapture,!0),t.addEventListener("pointermove",this._onPointerMoveCapture,!0),t.addEventListener("pointerup",this._onPointerUpCapture,!0),t.addEventListener("mousemove",this._onMouseMoveCapture,!0)}disconnect(){this.domElement&&(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.domElement.style.touchAction="auto",this._captureDocument&&(this._captureDocument.removeEventListener("pointerdown",this._onPointerDownCapture,!0),this._captureDocument.removeEventListener("pointermove",this._onPointerMoveCapture,!0),this._captureDocument.removeEventListener("pointerup",this._onPointerUpCapture,!0),this._captureDocument.removeEventListener("mousemove",this._onMouseMoveCapture,!0),this._captureDocument=null))}getHelper(){return this._root}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this.dragging=!1,this._setHoverShieldActive(!1),this._root.visible=!1,this}getMode(){return this.mode}setMode(e){this.mode=e,this.axis=null,this.dispatchEvent(Wi)}setSize(e){this.size=e}getRaycaster(){return Re}_handlePointerHover(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e));break}}_handlePointerDown(e){if(!this.enabled||!this.domElement)return;document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove);const t=this._getPointer(e);this.pointerHover(t),this.pointerDown(t)}_handlePointerMove(e){this.enabled&&this.pointerMove(this._getPointer(e))}_handlePointerUp(e){this.enabled&&this.domElement&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}_setHoverShieldActive(e){if(!this.domElement)return;const t=this.domElement.ownerDocument;if(e){if(this._hoverShieldActive)return;this._hoverShieldActive=!0;const r=Dt.get(t)??0;Dt.set(t,r+1);let o=ti.get(t);o||(o=t.createElement("div"),o.style.position="fixed",o.style.left="0",o.style.top="0",o.style.right="0",o.style.bottom="0",o.style.cursor="grab",o.style.pointerEvents="auto",o.style.background="transparent",o.style.zIndex="2147483647",ti.set(t,o)),o.parentElement||t.body.appendChild(o);return}if(!this._hoverShieldActive)return;this._hoverShieldActive=!1;const i=Dt.get(t)??0,s=Math.max(0,i-1);if(s===0){Dt.delete(t);const r=ti.get(t);r!=null&&r.parentElement&&r.parentElement.removeChild(r),ti.delete(t)}else Dt.set(t,s)}_handlePointerDownCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=e.target;if(t&&(t===this.domElement||this.domElement.contains(t)))return;const i=this._getPointer(e);this.pointerHover(i),!(!this.axis||!this._isAxisAllowed(this.axis))&&i.button===0&&(this._capturePointerId=e.pointerId,document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerDown(i))}_handlePointerMoveCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=this._getPointer(e);if(this._capturePointerId===e.pointerId&&this.dragging){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerMove(t);return}this.dragging||(this.pointerHover(t),this.axis&&this._isAxisAllowed(this.axis)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()))}_handleMouseMoveCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=this._getPointer(e);if(this.dragging){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}this.pointerHover(t),this.axis&&this._isAxisAllowed(this.axis)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())}_handlePointerUpCapture(e){!this.enabled||!this.domElement||!this.gizmoPriority||this._capturePointerId===e.pointerId&&(this._capturePointerId=null,this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerUp(this._getPointer(e)))}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Re.setFromCamera(e,this.camera);const t=this._gizmo.picker.children.find(h=>h.name==="XYZ"),i=this._gizmo.picker.children.find(h=>h.name==="E"),s=t?ii(t,Re):!1,r=i?ii(i,Re):!1;let o=this._gizmo.isExpanded,c=null;o?r&&!this._gizmo.isRingScaleTweening?c="E":s?c="XYZ":(o=!1,c=null):s&&(o=!0,c="XYZ"),this._gizmo.isExpanded!==o&&(this._gizmo.isExpanded=o),c&&this._isAxisAllowed(c)?this.axis=c:this.axis=null,this._setHoverShieldActive(!!this.axis||this.dragging),this._updateCursor()}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null&&this._isAxisAllowed(this.axis)){e!==null&&Re.setFromCamera(e,this.camera);const t=ii(this._plane,Re,!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,this._setHoverShieldActive(!0);const i=Ui(this.axis);mr.mode=i,this.dispatchEvent(mr),this._updateCursor()}}pointerMove(e){const t=this.axis,i=this.object;if(i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1||!this._isAxisAllowed(t))return;const s=Ui(t);if(!s)return;e!==null&&Re.setFromCamera(e,this.camera);const r=ii(this._plane,Re,!0);r&&(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate"?(this._offset.copy(this.pointEnd).sub(this.pointStart),this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart)):s==="rotate"&&(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.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(wl.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize()),this.dispatchEvent(Wi),this.dispatchEvent(bl))}pointerUp(e){if(!(e!==null&&e.button!==0)){if(this.dragging&&this.axis!==null){const t=Ui(this.axis);gr.mode=t,this.dispatchEvent(gr)}this.dragging=!1,this.axis=null,this._setHoverShieldActive(!1),this._updateCursor()}}_updateCursor(){if(!this.domElement)return;const e=ei.get(this.domElement);if(this.dragging){this.domElement.style.cursor="grabbing",ei.set(this.domElement,this);return}if(this.axis){this.domElement.style.cursor="grab",ei.set(this.domElement,this);return}e===this&&(this.domElement.style.cursor="",ei.delete(this.domElement))}_isAxisAllowed(e){return this.mode==="default"?e==="XYZ"||e==="E":this.mode==="translate"?e==="XYZ":this.mode==="rotate"?e==="E":!1}}class Cl{constructor(e,t){var n;this.isController=!0,this._enabled=!0,this._tmpQ=new f.Quaternion,this._tmpContainerQ=new f.Quaternion,this._tmpV=new f.Vector3,this._resetHierarchy=!1,this._defaultPoseQuats=new Map,this._zeroPoseQuats=new Map,this._emitter=new Ye,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._initialTargetPos=new f.Vector3,this._initialTargetQuat=new f.Quaternion,this._axesHelpers=[],this._showAxes=!1;const{joints:i,container:s,context:r,resetHierarchy:o}=e,c=(Array.isArray(i)?i:[]).map(l=>l.object);this._container=s,this._context=r,this._resetHierarchy=!!o;let h;if(Array.isArray(i))for(let l=0;l<i.length;l++)(n=i[l])!=null&&n.ikTcp&&(h=i[l].object);this._effector=h??c[c.length-1],this._resetHierarchy&&this.setupHierarchy(c),c.forEach(l=>{l&&(this._defaultPoseQuats.has(l.uuid)||this._defaultPoseQuats.set(l.uuid,l.quaternion.clone()))}),this.transformControls=new Ml(t.camera,t.domElement),this.transformControls.addEventListener("dragging-changed",({value:l})=>{this._emitter.emit("dragging-changed",l),l||this.syncTargetToEffector()}),this.transformControls.addEventListener("axis-changed",({value:l})=>{this.transformControls.dragging||(this.targetObject.visible=l==="E")}),this.targetObject=new f.Object3D,this.targetObject.name="ikTarget",this.targetObject.visible=!1,this.targetObject.userData.isIKTarget=!0,this.transformControls.attach(this.targetObject);const u=new f.AxesHelper(.0675);u.material.depthTest=!1,u.material.depthWrite=!1,u.renderOrder=1e3,this.targetObject.add(u),this.syncTargetToEffector(),this._initialTargetPos.copy(this.targetObject.position),this._initialTargetQuat.copy(this.targetObject.quaternion);const p=this.transformControls.getHelper();this._container.add(this.targetObject),this._container.add(p),this.solver=new fr(i,r),this.solver.links.forEach((l,d)=>{const g=l.object;if(g){const v=this.solver.restQuaternions[d];v&&this._zeroPoseQuats.set(g.uuid,v.clone())}}),c.forEach(l=>{const d=new f.AxesHelper(.2);d.visible=!1,l.add(d),this._axesHelpers.push(d)})}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.transformControls.enabled=e,this.transformControls.getHelper().visible=e}get showAxes(){return this._showAxes}set showAxes(e){this._showAxes=e,this._axesHelpers.forEach(t=>t.visible=e)}getEffectorLocalPos(){var t;const e=new f.Vector3;return this._effector&&(this._effector.getWorldPosition(e),(t=this._container)==null||t.worldToLocal(e)),e}getEffectorLocalQuat(){const e=new f.Quaternion;return this._effector&&(this._effector.getWorldQuaternion(e),this._container&&(this._container.getWorldQuaternion(this._tmpContainerQ),this._tmpContainerQ.invert(),e.premultiply(this._tmpContainerQ))),e}setupHierarchy(e){for(let t=0;t<e.length-1;t++){const i=e[t],s=e[t+1];s.parent!==i&&i.attach(s)}}syncTargetToEffector(){this.targetObject.position.copy(this.getEffectorLocalPos()),this.targetObject.quaternion.copy(this.getEffectorLocalQuat()),this.targetObject.updateMatrixWorld(!0)}syncTargetToSolver(){this.solver&&(this.targetObject.getWorldPosition(this._tmpV),this.solver.target.copy(this._tmpV),this.targetObject.getWorldQuaternion(this._tmpQ),this.solver.targetQuaternion.copy(this._tmpQ))}setControlMode(e){this.transformControls.setMode(e)}setOrientation(e){this.solver&&(this.solver.orientation.forwardAxis=e.forwardAxis,this.solver.orientation.upAxis=e.upAxis)}updateJointChain(e){var h;const t=(Array.isArray(e)?e:[]).filter(u=>!!(u!=null&&u.object));if(t.length<2||!this._container)return;const i=t.map(u=>u.object);i.forEach(u=>{u&&(this._defaultPoseQuats.has(u.uuid)||this._defaultPoseQuats.set(u.uuid,u.quaternion.clone()),this._zeroPoseQuats.has(u.uuid)||this._zeroPoseQuats.set(u.uuid,u.quaternion.clone()))});let s;for(let u=0;u<t.length;u++)(h=t[u])!=null&&h.ikTcp&&(s=t[u].object);this._effector=s??i[i.length-1],this._resetHierarchy&&this.setupHierarchy(i);const r=this.solver,o=new fr(t,this._context);r&&(o.iterations=r.iterations,o.minDistance=r.minDistance,o.maxStep=r.maxStep,o.damping=r.damping,o.maxAngleDelta=r.maxAngleDelta,r.orientation&&o.orientation&&Object.assign(o.orientation,r.orientation));const c=o.links.map(u=>this._zeroPoseQuats.get(u.object.uuid));o.rebindRestPoseWithBase(c),this.solver=o,this._axesHelpers.forEach(u=>u.removeFromParent()),this._axesHelpers=[],i.forEach(u=>{const p=new f.AxesHelper(.2);p.visible=this._showAxes,u.add(p),this._axesHelpers.push(p)}),this.syncTargetToEffector(),this.syncTargetToSolver()}update(){!this._enabled||!this.solver||(this.syncTargetToSolver(),this.solver.update())}toggleOrientation(e){this.solver&&(this.solver.orientation.enabled=e)}setSolverContext(e){this.solver&&(typeof e.iterations=="number"&&(this.solver.iterations=e.iterations),typeof e.damping=="number"&&(this.solver.damping=e.damping))}reset(){if(!(!this.solver||!this._container)){for(const e of this.solver.links){const t=e==null?void 0:e.object;if(!t)continue;const i=this._defaultPoseQuats.get(t.uuid);i&&t.quaternion.copy(i)}this._container.updateMatrixWorld(!0),this.solver.updateJointStateFromCurrentPose(),this.syncTargetToEffector(),this.syncTargetToSolver()}}dispose(){this.transformControls.detach(),this.transformControls.dispose(),this.targetObject.removeFromParent(),this._axesHelpers.forEach(e=>e.removeFromParent()),this._axesHelpers=[]}}const Dl=(a,e,t,i={})=>{const s=[],{resetHierarchy:r,onDraggingChanged:o}=i;return a.forEach(c=>{if(!(c!=null&&c.joints)||c.joints.length<2)return;const h=new Cl({joints:c.joints,container:e,context:{orientation:c.orientation},resetHierarchy:r},t);o&&h.addListener("dragging-changed",u=>{o(h,u)}),s.push(h)}),s},Ds=new f.TextureLoader;Ds.crossOrigin="anonymous";class an extends f.Object3D{constructor(e){super(),this._props=e,this._emitter=new Ye,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new f.Group,this.lines=new f.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new f.Clock,this.sizeBox=new yl,this._goodsSize=new nl(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],this._ikChains=[],this.ikControllers=[],this._ikDraggingControllers=new Set,this._shelfSyncCache=new WeakMap,this._rollerPools=new WeakMap,this._videoCache=new Map,this._rollerColumns=1,this._bodyOpacity=1,this._masts=new Map,this._liftMaxHeight=0,this._jackMaxHeight=0,this._forkMaxHeight=0,this.controllers=[],this.goods=[],this._breathLights=[],this._shelves=new Map,this._shelfMaxLevel=1,this._url="",this._showController=!0,this._showSlots=!0,this._shapeKeys=new Map,this._shapeKeyTargets=new Map,this._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],this._useCenterModel=!1,this._useLift=!1,this._columnCount=1,this._columnGap=.03,this._rowCount=1,this._rowGap=.01,this._levelCount=1,this._currentAction=null,this._pendingFinishedCallback=null,this._url=e.url||"",this._url&&this.load(this._url).then(),this.add(this._container,this.lines),this._props.showSizeBox&&this.add(this.sizeBox),this.showController=typeof e.showController=="boolean"?e.showController:!0,this._showSlots=typeof e.showSlots=="boolean"?e.showSlots:!0}get shapeKeys(){return this._shapeKeys}get size(){const e=this.sizeBox.size.getSize(new f.Vector3);return{width:e.z,length:e.x,height:e.y}}get goodsSize(){return this._goodsSize}get showController(){return this._showController}set showController(e){this._showController=e,this.controllers.forEach(t=>e?t.show():t.hide())}get slots(){return this._slots}get logos(){return this._logos}get skins(){return this._skins}get bodyOpacity(){return this._bodyOpacity}get fork(){return this._fork}get forkHeight(){var e;return((e=this._fork)==null?void 0:e.position.z)||0}get liftHeight(){var e;return this._lift?this._lift instanceof Map?((e=this._lift.get(0))==null?void 0:e.position.z)||0:this._lift.position.z||0:0}get jack(){return this._jack}get jackHeight(){var e;return((e=this._jack)==null?void 0:e.position.z)||0}get lift(){return this._lift}get useCenterModel(){return this._useCenterModel}set useCenterModel(e){this._useCenterModel=e,this._rollerLevel.forEach(t=>{t.traverse(i=>{i.userData.isCenterModel&&(i.visible=e)})})}set bodyOpacity(e){this._bodyOpacity=e,e<1?this._materialsCache.forEach(t=>{t.mat.transparent=!0,t.mat.opacity=e,t.mat.metalness=0,t.mat.roughness=1,t.mat.color=new f.Color("#3859be"),t.mat.needsUpdate=!0}):this._materialsCache.forEach(t=>{t.mat.transparent=t.transparent,t.mat.opacity=t.opacity,t.mat.metalness=t.metalness,t.mat.roughness=t.roughness,t.mat.color=t.color,t.mat.needsUpdate=!0})}init(e){this._app=e,this.sizeBox.init(e),this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=()=>{if(this._mixer){const t=this._animationClock.getDelta();this._mixer.update(t)}else this._animationClock.getDelta();this.ikControllers.forEach(t=>t.update())},this._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{if(this._slots.forEach(s=>s.shapeKeyChanged(t,i)),this.sizeBox.follow===t?(this.sizeBox.generate(this._container,i),this.sizeBox.originOffset&&(this._container.traverse(s=>{s instanceof f.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof as&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new f.Vector3(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0))}),this.sizeBox.translateCache=this.sizeBox.originOffset,this.sizeBox.generate(this._container))):this.sizeBox.generate(this._container),["width","length","height"].includes(t)&&this._emitter.emit("size-changed",t,i),t==="goodsLength"){const s=i;this._goodsSize.length=this._layoutLengthToItemLength(s),this._applyDerivedSizesFromLayoutGoodsLength(s),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize()}t==="goodsWidth"&&(this._goodsSize.width=i,this._applyDerivedSizesFromGoodsWidth(i),this._columnCount>1&&this.setColumns(this._columnCount,!1),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize())})}_syncRollerGoodsBoxesFromGoodsSize(){const e=h=>{var n;const u=[],p=[...h.children];for(;p.length;){const l=p.pop();if((n=l.userData)!=null&&n.isRollerLevelBox){u.push(l);continue}l.children&&l.children.length&&p.push(...l.children)}return u},t=Math.max(1,this._rowCount||1),i=t>1?this._rowGap:0,s=this._goodsSize.length||0,r=this._getLayoutGoodsLength(s),o=s+i,c=t>0?-r/2+s/2:0;this._rollerLevel.forEach(h=>{e(h).forEach(p=>{const n=p.children.filter(l=>l instanceof xe);for(n.forEach(l=>{l.userData.__amrRollerGoodsBox=!0,this.goods.includes(l)||this.goods.push(l)});n.length<t;){const l=new xe(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);l.userData.__amrRollerGoodsBox=!0,p.add(l),this.goods.push(l),n.push(l)}for(let l=t;l<n.length;l++){const d=n[l];this.goods=this.goods.filter(g=>g!==d),d.dispose(),d.removeFromParent()}for(let l=0;l<t;l++){const d=n[l];d.updateSize(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height),d.position.y=c+o*l}})})}_syncShelvesFromGoodsSize(){const e=this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"),t=this._getLayoutGoodsLength(this._goodsSize.length);this._shelves.forEach(i=>{let s=this._shelfSyncCache.get(i);s||(s={container:void 0,morphMeshes:[],goodsBoxes:[]},i.traverse(c=>{var h;if((h=c.userData)!=null&&h.isShelfContainer&&(s.container=c),c instanceof xe&&s.goodsBoxes.push(c),Vi(c)){const u=c,p=u.morphTargetDictionary||{};(Object.prototype.hasOwnProperty.call(p,"goodsWidth")||Object.prototype.hasOwnProperty.call(p,"goodsLength"))&&s.morphMeshes.push(u)}}),this._shelfSyncCache.set(i,s)),s.goodsBoxes.forEach(c=>{c.updateSize(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height)}),s.morphMeshes.forEach(c=>{this.setShapeKeyToMesh(c,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(c,"goodsLength",t)});const r=s.container;if(!r)return;typeof r.userData.__goodsBaseX!="number"&&(r.userData.__goodsBaseX=r.position.x);const o=r.userData.__goodsBaseX;r.position.x=e?o+t/2:o})}_findFirstSkinnedMesh(e){if(!e)return;let t;return e.traverse(i=>{!t&&i.isSkinnedMesh&&(t=i)}),t}async loadAnimation(e,t="sglb"){let i,s;if(t==="glb"||e.endsWith(".glb")){const h=await je.loadAsync(e);i=h.animations||[],s=h.scene}else if(t==="sglb"||e.endsWith(".sglb")){const u=await new Ut({useCache:!0}).loadAsync(e);i=u.animations||[],s=u.scene}else{console.warn("[Amr.loadAnimation] 目前仅支持 glb/sglb 动画文件",{url:e,type:t});return}if(!i||i.length===0){console.warn("[Amr.loadAnimation] 文件中未找到动画",e);return}if(!this._modelRoot){console.warn("[Amr.loadAnimation] 模型尚未加载,无法绑定动画",e);return}if(!s){console.warn("[Amr.loadAnimation] 动画文件中缺少 scene,无法执行重定向",e);return}const r=this._findFirstSkinnedMesh(s),o=this._findFirstSkinnedMesh(this._modelRoot);(!r||!o)&&console.warn("[Amr.loadAnimation] 在动画或目标模型中未找到 SkinnedMesh,使用原始动画 clip",e),this._mixer||(this._mixer=new f.AnimationMixer(this._modelRoot));const c=typeof Pi.retargetClip=="function";i.forEach(h=>{let u=h;if(c&&r&&o)try{u=Pi.retargetClip(o,r,h)}catch(n){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",h.name,n)}this._clips=this._clips.filter(n=>n.name!==u.name),this._clips.push(u);const p=this._mixer.clipAction(u);this._actionsMap.set(u.name,p)}),this.actions=Array.from(this._actionsMap.keys())}async load(e,t=""){this._url=e,this.name||(this.name=e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("."))),!e.startsWith("blob")&&e.endsWith(".sglb");let i,s;if(t==="glb"||e.endsWith(".glb")){let o=await je.loadAsync(e);i=o.scene,s=o.animations||[]}else{const c=await new Ut({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const r=Pi.clone(i);this._generateAmr(r,s),i=null,this._emitter.emit("amr-loaded")}changeSkin(e,t){e&&(e.change(t),this._app&&this._app.usePathTracing&&(this._app.sampleCount=0,this._app.usePathTracing&&(this._app.pathTracer.pausePathTracing=!1,this._app.pathTracer.updateMaterials())))}changeLogo(e,t){e.change(t.url,new f.Vector2(t.scaleX,t.scaleY),new f.Vector2(t.ox,t.oy))}getShapeKeyTargets(e){return this._shapeKeyTargets.get(e)||[]}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this.getShapeKeyTargets(e).forEach(r=>{var h;performance.now();let o=t;r.userData[`origin_${e}`]&&(o-=r.userData[`origin_${e}`]);const c=(h=r.morphTargetDictionary)==null?void 0:h[e];c!==void 0&&r.morphTargetInfluences&&(r.morphTargetInfluences[c]=o),r instanceof f.Mesh&&r.geometry.translate(0,0,1e-9)}),i&&this._emitter.emit("shape-key-changed",e,t)},0)}_generateAmr(e,t){var i,s;this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new f.AnimationMixer(e),this._clips=t,t.forEach(r=>{const o=this._mixer.clipAction(r);this._actionsMap.set(r.name,o)}),this.actions=t.map(r=>r.name)),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),e.traverse(r=>{if(r.userData.isShelf&&(this._shelf=r),r.userData.isFork&&(this._fork=r),r.userData.isMast&&r.userData.mastLevel&&this._masts.set(r.userData.mastLevel,r),r.userData.isJack&&(this._jack=r),r.userData.isLift&&(this._lift=r),r.userData.isRollerLevel&&this._rollerLevel.set(r.userData.level||0,r),r.userData.isCenterModel&&(r.visible=this.useCenterModel),r.userData.isSwitch&&r.userData.switchName==="top"&&(this._rollerTop=r),r.userData.isLiftBracket&&(this._liftBrackets.push(r),r.visible=this._useLift),r.userData.isBaffle&&(this._rollerBaffle=r,r.visible=!this._useLift),r.userData.isRoller&&(this._roller=r,this._roller.visible=!1,this._generateRollers()),r.userData.isRollerLevelBox){this._rollerGoodsBox=r;const o=new xe(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);r.add(o),this.goods.push(o)}Object.keys(r.morphTargetDictionary||{}).forEach(o=>{let c=r.morphTargetInfluences[r.morphTargetDictionary[o]];r.userData[`origin_${o}`]&&(c+=r.userData[`origin_${o}`]),this._shapeKeys.has(o)||this._shapeKeys.set(o,c);const h=this._shapeKeyTargets.get(o);h?h.push(r):this._shapeKeyTargets.set(o,[r])})}),e.traverse(r=>{if(r instanceof f.Mesh){if(r.castShadow=!0,r.receiveShadow=!0,r.material)if(Array.isArray(r.material))r.material.forEach(c=>{c.userData.changeColor&&(this.skins.find(h=>h.name===c.userData.name)||this.skins.push(new ys({name:c.userData.name,target:c})))});else{if(r.material.userData.isVideo&&r.material.userData.video){const c=r.material.userData.video;let h=this._videoCache.get(c);h||(h=document.createElement("video"),h.src=c,h.crossOrigin="anonymous",h.loop=!0,h.muted=!0,h.playsInline=!0,h.autoplay=!0,h.preload="auto",this._videoCache.set(c,h)),h.play().catch(()=>{}),r.material.map&&r.material.map.dispose(),r.material.emissiveMap&&r.material.emissiveMap.dispose();const u=new f.VideoTexture(h);u.colorSpace=f.SRGBColorSpace,r.material.map=u,r.material.emissiveMap=u,r.material.emissive||(r.material.emissive=new f.Color(16777215)),r.material.emissiveIntensity=1,r.material.needsUpdate=!0}if(r.material.userData.isBreathLight&&r.material.emissiveIntensity){r.material.emissive||(r.material.emissive=new f.Color(16777215)),r.material.emissiveIntensity=2,r.material.toneMapped=!1;const c=1e3,h=new ne.Tween(r.material).to({emissiveIntensity:.2}).easing(ne.Easing.Quintic.InOut).duration(c),u=new ne.Tween(r.material).to({emissiveIntensity:2}).easing(ne.Easing.Quintic.InOut).duration(c);h.onComplete(()=>u.start()),u.onComplete(()=>h.start()),h.start(),this._breathLights.push(h,u)}r.material.userData.changeColor&&(this.skins.find(c=>c.name===r.material.userData.name)||this.skins.push(new ys({name:r.material.userData.name,target:r.material})))}if(r.material)if(Array.isArray(r.material))r.material.forEach(h=>{if(h.userData.isLOGO){r.material.transparent=!0;let u;const p={width:0,height:0};r.material.map&&r.material.map.image&&(p.width=r.material.map.image.width,p.height=r.material.map.image.height,u=os(r.material.map.image)),r.material.needsUpdate=!0;const n=new ls({name:h.userData.name,target:r,size:or(r),imageSize:p,imageUrl:u});this._logos.push(n)}h.userData.isTransparent&&(h.transparent=!0),this._materialsCache.set(h.uuid,{opacity:h.opacity,transparent:h.transparent,roughness:h.roughness,metalness:h.metalness,color:h.color,mat:h})});else{const c=r.material;if(c.userData.isLOGO){r.material.transparent=!0;let h;const u={width:0,height:0};r.material.map&&r.material.map.image&&(u.width=r.material.map.image.width,u.height=r.material.map.image.height,h=os(r.material.map.image));const p=new ls({name:c.userData.name,target:r,size:or(r),imageSize:u,imageUrl:h});this._logos.push(p)}c.userData.isTransparent&&(c.transparent=!0),this._materialsCache.set(c.uuid,{opacity:c.opacity,transparent:c.transparent,roughness:c.roughness,metalness:c.metalness,color:c.color,mat:c})}}this.generateController(r,e),this.generateDimension(r,e);const o=this.generateSlot(r,e);o&&this._slots.push(o),r.userData.isOrigin&&Object.keys(r.userData).forEach(h=>{if(h.startsWith("follow_")){const u=h.replace("follow_","");this.shapeKeys.has(u)&&(this.sizeBox.follow=u,this.sizeBox.followOrigin=this._shapeKeys.get(u)||0,this.sizeBox.followScale=r.userData[h])}})}),this.slots.forEach(r=>{r.props.mirrorTarget&&(r.mirrorTarget=this.slots.find(o=>o.props.slot.name===r.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this._buildJointChain(e),this._disposeIkControllers(),this._ikChains.length&&(this.ikControllers=Dl(this._ikChains,this,{camera:(i=this._app)==null?void 0:i.camera,domElement:(s=this._app)==null?void 0:s.renderer.domElement},{onDraggingChanged:(r,o)=>{this._onIkDraggingChanged(r,o)}}),this._ikChains.forEach((r,o)=>{r.controller=this.ikControllers[o]})),this.sizeBox.generate(e),this.sizeBox.show()}_syncIkDraggingState(){this._app&&(this._app.controls.enabled=this._ikDraggingControllers.size===0)}_onIkDraggingChanged(e,t){t?this._ikDraggingControllers.add(e):this._ikDraggingControllers.delete(e),this._syncIkDraggingState()}_disposeIkControllers(){this.ikControllers.forEach(e=>e.dispose()),this.ikControllers=[],this._ikChains.forEach(e=>{e.controller=void 0}),this._ikDraggingControllers.clear(),this._syncIkDraggingState()}_buildJointChain(e){if(this._ikChains=[],!this._ikChains.length){const t=[];e.traverse(i=>{i!=null&&i.name&&i.name.startsWith("ArmatureRoot")&&t.push(i)}),t.sort((i,s)=>i.name.localeCompare(s.name)),t.forEach(i=>{const{joints:s,orientation:r}=this._buildIKChainParams(i);if(s.length<2)return;const o={enabled:!0,...r};this._ikChains.push({name:i.name,joints:s,baseLinks:s.slice(),toolLinks:[],orientation:o})})}}_findIkChainByNode(e){var t;for(const i of this._ikChains){if(!((t=i.baseLinks)!=null&&t.length))continue;const s=new Set(i.baseLinks.map(o=>o.object.uuid));let r=e;for(;r;){if(s.has(r.uuid))return i;r=r.parent}}}updateIkJointChainByTool(e,t){if(!e)return;const i=this._findIkChainByNode(e);if(console.log("chain",i),!i||!i.controller||!i.baseLinks||i.baseLinks.length<2)return;const s=(u,p)=>{if(!p.length)return!1;const n=new Set;return u.traverse(l=>n.add(l.uuid)),p.some(l=>n.has(l.uuid))};if(t==="uninstall"){if(!(!!i.toolRootUuid&&e.uuid===i.toolRootUuid||i.toolLinks.length>0&&s(e,i.toolLinks.map(p=>p.object))))return;i.toolLinks=[],i.toolRootUuid=void 0,i.joints=i.baseLinks.slice(),i.controller.updateJointChain(i.joints);return}const{joints:r,orientation:o}=this._buildIKChainParams(e);if(!r.length)return;o&&i.controller.setOrientation(o);const c=!!i.toolRootUuid&&e.uuid===i.toolRootUuid,h=i.toolLinks.length>0;if(c&&h){i.joints=[...i.baseLinks,...i.toolLinks],i.controller.updateJointChain(i.joints);return}i.toolRootUuid=e.uuid,i.toolLinks=r,i.joints=[...i.baseLinks,...i.toolLinks],i.controller.updateJointChain(i.joints)}_buildIKChainParams(e){var o,c,h,u;if(!e)return{joints:[],orientation:void 0};const t=[];let i;const s=p=>{const n=p.children.find(l=>{var d,g;return((d=l.userData)==null?void 0:d.isJoint)||((g=l.userData)==null?void 0:g.isTcp)});if(n)return n;for(const l of p.children){const d=s(l);if(d)return d}};let r=(o=e.userData)!=null&&o.isJoint||(c=e.userData)!=null&&c.isTcp?e:s(e);for(;r;){if(console.log("cur",r),(h=r.userData)!=null&&h.isJoint){const p=this._parseIkAxes(r.userData.ikAxes);this._fillInitialRotationValues(r,p),t.push({object:r,axes:p})}else if((u=r.userData)!=null&&u.isTcp){const p=this._parseIkAxes(r.userData.ikAxes);this._fillInitialRotationValues(r,p),t.push({object:r,ikTcp:!0,axes:p}),i=this._parseIkOrientation(r.userData.ikOrientation)??i;break}r=s(r)}return{joints:t,orientation:i}}_fillInitialRotationValues(e,t){if(!t||!e)return;const i=e.rotation;t.forEach(s=>{const{axis:r}=s;Math.abs(r.x)>.9?s.value=i.x*Math.sign(r.x):Math.abs(r.y)>.9?s.value=i.y*Math.sign(r.y):Math.abs(r.z)>.9&&(s.value=i.z*Math.sign(r.z))})}_axisFromLetter(e){const t=String(e).trim().toUpperCase();if(t==="X")return new f.Vector3(1,0,0);if(t==="Y")return new f.Vector3(0,1,0);if(t==="Z")return new f.Vector3(0,0,1)}_parseIkAxes(e){if(!e||typeof e!="string")return;const t=JSON.parse(e);if(!(!Array.isArray(t)||t.length===0))return t.map(i=>{const s=this._axisFromLetter(i.axis)??new f.Vector3(0,0,0),r=typeof i.min=="number"?f.MathUtils.degToRad(i.min):void 0,o=typeof i.max=="number"?f.MathUtils.degToRad(i.max):void 0;return{axis:s,min:r,max:o}})}_parseIkOrientation(e){if(!e)return;const t=typeof e=="string"?JSON.parse(e):e,i=this._axisFromLetter(t.forwardAxis),s=this._axisFromLetter(t.upAxis);if(!(!i||!s))return{forwardAxis:i,upAxis:s}}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){this.name==="SFL-CDD14"&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CDD20","SFL-CDD20-Y"].includes(this.name)&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),this.name==="SFL-CDD15"&&(e>2.43?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CPD20-Y","SFL-CPD30-Y"].includes(this.name)&&(e>3.5?this.setShapeKey("mast",2):e>3?this.setShapeKey("mast",1):this.setShapeKey("mast",0))}setForkHeight(e){if(this._fork){if(e>this._forkMaxHeight&&(e=this._forkMaxHeight),this._fork.position.z=e,this._masts.size===1){const t=this._masts.get(2),i=(t==null?void 0:t.userData.startHeight)||.1;t&&(t.position.z=(e-i)*.5)}this._emitter.emit("fork-height-change",e)}}setForkMaxHeight(e){this._fork&&(this._forkMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("fork")&&(t.props.max=e)}),this._fork&&this.forkHeight>this._forkMaxHeight&&this.setForkHeight(e))}setLiftHeight(e){if(this._lift)if(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift instanceof Map){const t=this._lift.get(0);t&&(t.position.z=e)}else this._lift&&(this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(r=>{r.name.toLowerCase().includes("lift")&&(r.props.max=e)}),this.liftHeight>this._liftMaxHeight&&this.setLiftHeight(e);let t=.46;this.levelOffset&&(t=this.levelOffset+.1);let i=e+t;const s=this.getShelfMinHeight()+t||0;i<s&&(i=s),this.setHeight(i)}setJackMaxHeight(e){this._jack&&(this._jackMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("jack")&&(t.props.max=e)}),this.jackHeight>this._jackMaxHeight&&this.setJackHeight(e))}setJackHeight(e){this._jack&&(e>this._jackMaxHeight&&(e=this._jackMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("jackHeight",e,!1)}),this._jack.position.z=e)}setLevel(e){}setGoodsSize(e){this._goodsSize.length=e.length,this._goodsSize.width=e.width,this._goodsSize.height=e.height,this.setShelfLevel(this._shelfMaxLevel),this.setRoller(),this._rollerLevel.forEach(t=>{t.traverse(i=>{i instanceof xe&&i.updateSize(e.width,e.length,e.height)})})}setRoller(){}get isTopInvert(){if(this._rollerTop)return Math.abs(this._rollerTop.rotation.z)===Math.PI/2}setTopInvert(e=!0){this._rollerTop&&(this._rollerTop.rotation.z=e?Math.PI/2:0,this.setShapeKey("switch",e?1:0),this.setShapeKey("goodsWidth",this.goodsSize.width),this.setShapeKey("goodsLength",this._getLayoutGoodsLength(this.goodsSize.length)))}get useLift(){return this._useLift}set useLift(e){var t;this._lift&&(this._useLift=e,(t=this._rollerTop)==null||t.traverse(i=>{i.userData.isBaffle&&(i.visible=!e),i.userData.isLiftBracket&&(i.visible=e)}))}get columns(){return this._columnCount}get rows(){return this._rowCount}setRows(e){const t=Math.max(1,Math.floor(e||1));if(t===this._rowCount)return;this._rowCount=t;const i=this._getLayoutGoodsLength(this._goodsSize.length);this.setShapeKey("goodsLength",i,!1),this._applyDerivedSizesFromLayoutGoodsLength(i),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize()}_getLayoutGoodsLength(e=this._goodsSize.length){const t=Math.max(1,this._rowCount||1),i=e||0;return t<=1?i:i*t+this._rowGap*(t-1)}_layoutLengthToItemLength(e){const t=Math.max(1,this._rowCount||1);if(t<=1)return Math.max(0,e||0);const i=this._rowGap*(t-1);return Math.max(0,((e||0)-i)/t)}setGoodsItemLength(e){this._goodsSize.length=e;const t=this._getLayoutGoodsLength(e);this.setShapeKey("goodsLength",t)}_applyDerivedSizesFromLayoutGoodsLength(e){const t=e+.14-.54;this.setShapeKey("boxLength",t);const i=e+.14;if(this.setShapeKey("topWidth",i),this.isTopInvert){const s=e-.259;this.setShapeKey("length",s)}else this.setShapeKey("width",i)}_applyDerivedSizesFromGoodsLength(e){const t=this._getLayoutGoodsLength(e);this._applyDerivedSizesFromLayoutGoodsLength(t)}_applyDerivedSizesFromGoodsWidth(e){const t=Math.max(1,this._columnCount||1),i=.125,s=t===1?e+i:(e+i)*t+this._columnGap*(t-1),r=s+.06;this.setShapeKey("boxWidth",r);const o=s+.085;if(this.setShapeKey("topLength",o),this.isTopInvert){const c=s+.485;this.setShapeKey("width",c)}else this.setShapeKey("length",o)}setColumns(e,t=!0){const i=Math.max(1,Math.floor(e||1));this._columnCount=i,this._rollerLevel.forEach(s=>{const r=s.children.filter(d=>{var g;return(g=d.userData)==null?void 0:g.isRollerLevelBox}),o=r.length>0?(Math.min(...r.map(d=>d.position.x))+Math.max(...r.map(d=>d.position.x)))/2:0;s.children.filter(d=>{var g,v;return((g=d.userData)==null?void 0:g.isRollerLevelBox)&&((v=d.userData)==null?void 0:v.cloned)}).forEach(d=>s.remove(d));const c=s.children.find(d=>d.userData.isRollerLevelBox&&!d.userData.cloned)||s.children.find(d=>d.userData.isRollerLevelBox);if(!c)return;const h=el(c,s,new f.Vector3),u=this._columnGap,n=h.x+u,l=(i-1)*n/2;c.position.x=o-l;for(let d=1;d<i;d++){const g=c.clone(!0);g.userData.cloned=!0,this._stripRollerInstances(g),this.regenerateShapeKeyNode(g),g.position.x=o-l+d*n,s.add(g)}}),t&&this._applyDerivedSizesFromGoodsWidth(this.goodsSize.width),this._pruneShapeKeyTargets(),this.setShapeKey("goodsWidth",this._goodsSize.width,!1),this.setShapeKey("goodsLength",this._getLayoutGoodsLength(this._goodsSize.length),!1),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize()}get levels(){return this._levelCount}setLevels(e){var o;const t=Math.max(1,Math.floor(e||1));this._levelCount=t;const i=this._rollerLevel.size,s=t-i,r=this._rollerLevel.get(0);if(s>0&&r){for(let h=i;h<t;h++){const u=r.clone(!0);u.visible=!0,this._stripRollerInstances(u),u.position.z=r.position.z+.2*h,u.userData.level=h,this._rollerLevel.set(h,u),(o=r.parent)==null||o.add(u),this.regenerateShapeKeyNode(u),u.traverse(p=>{p instanceof xe&&(p.updateSize(this.goodsSize.width,this.goodsSize.length,this.goodsSize.height),this.goods.push(p))})}this._columnCount>1&&this.setColumns(this._columnCount,!1),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize()}else for(let c=0;c<i;c++){const h=this._rollerLevel.get(c);h&&(h.visible=c<t)}}regenerateShapeKeyNode(e){e&&e.traverse(t=>{Vi(t)&&Object.keys(t.morphTargetDictionary||{}).forEach(i=>{const s=this._shapeKeyTargets.get(i);s&&s.push(t)})})}_stripRollerInstances(e){const t=[];e.traverse(i=>{var s,r;((s=i==null?void 0:i.userData)!=null&&s.__amrRollerInstance||(r=i==null?void 0:i.userData)!=null&&r.isCloned)&&t.push(i)}),t.forEach(i=>{i.parent&&i.removeFromParent()})}_isInAmrContainer(e){let t=e;for(;t;){if(t===this._container||t===this)return!0;t=t.parent}return!1}_pruneShapeKeyTargets(){this._shapeKeyTargets.forEach((e,t)=>{const i=new Set,s=[];for(const r of e)r&&this._isInAmrContainer(r)&&(i.has(r.uuid)||(i.add(r.uuid),s.push(r)));this._shapeKeyTargets.set(t,s)})}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){if(!this._roller)return;let e=this._getLayoutGoodsLength(this._goodsSize.length);e=e||.5;const t=.05;let i=.02;const r=e-i,o=t+i;let c=Math.floor(r/o);const h=r%o,u=l=>{var v;const d=[],g=[...l.children];for(;g.length;){const m=g.pop();if((v=m.userData)!=null&&v.isRollerLevelBox){d.push(m);continue}m.children&&m.children.length&&g.push(...m.children)}return d},p=[];this._rollerLevel.forEach(l=>{p.push(...u(l))});let n=!1;if(p.forEach(l=>{const d=[];l.traverse(g=>{var v,m;g!==l&&((v=g==null?void 0:g.userData)!=null&&v.isCloned)&&!((m=g==null?void 0:g.userData)!=null&&m.__amrRollerInstance)&&d.push(g)}),d.forEach(g=>g.removeFromParent()),d.length&&(n=!0)}),n&&this._pruneShapeKeyTargets(),c>0){c>1&&(i+=h/(c+2));const l=t+i,d=-e/2+i+t/2;p.forEach(g=>{let v=this._rollerPools.get(g);for(v||(v=[],this._rollerPools.set(g,v));v.length<c;){const m=this._roller.clone(!0);m.visible=!1,m.userData.__amrRollerInstance=!0,m.userData.isCloned=!0,g.add(m),this.regenerateShapeKeyNode(m),v.push(m)}for(let m=0;m<c;m++){const _=v[m];_.parent!==g&&g.add(_),_.visible=!0,_.position.y=d+l*m}for(let m=c;m<v.length;m++)v[m].visible=!1})}else p.forEach(l=>{const d=this._rollerPools.get(l);d&&d.forEach(g=>g.visible=!1)})}getShelfMinHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);return i?i.position.z+e*t+.1:0}getShelfMaxShelfHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);if(i)return i.position.z+e*(t-1)}get levelOffset(){return this._goodsSize.height+.2}setShapeKeyToMesh(e,t,i){if(!Object.keys(e.morphTargetDictionary||{}).includes(t))return;const s=e.morphTargetDictionary[t];e.morphTargetInfluences&&(e.morphTargetInfluences[s]=i),e.geometry.translate(0,0,1e-9)}setShelfLevel(e=3){var r;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset,i=this._getLayoutGoodsLength(this._goodsSize.length);this._shelves.delete(0),this._shelves.forEach(o=>{De(o),o.parent&&o.removeFromParent()}),this.goods=this.goods.filter(o=>{var c;return(c=o==null?void 0:o.userData)==null?void 0:c.__amrRollerGoodsBox}),this._shelves.clear(),this._shelves.set(0,this._shelf);for(let o=1;o<e;o++){if(!this._shelf)return;this._shelf.traverse(u=>{Vi(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",i))});const c=this._shelf.clone(!0);c.position.z+=t*o,this._shelves.set(o,c),(r=this._shelf.parent)==null||r.add(c);let h;if(c.traverse(u=>{u.userData.isShelfContainer&&(h=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&h&&(typeof h.userData.__goodsBaseX!="number"&&(h.userData.__goodsBaseX=h.position.x),h.position.x=h.userData.__goodsBaseX+i/2),h){const u=new xe(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(u.userData.__amrShelfGoodsBox=!0,h.add(u),this.goods.push(u),o===1){const p=new xe(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);p.userData.__amrShelfGoodsBox=!0,p.position.z-=t,h.add(p),this.goods.push(p)}}}const s=this.getShelfMinHeight()||0;this._liftMaxHeight<s&&this.setLiftMaxHeight(s)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new on(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=e.userData.target.name,{min:s,max:r}=e.userData;let o;if(t.traverse(h=>{h.name===i&&(o=h)}),!o)return;const c=new ur({name:"",target:i,default:0,min:s,max:r},o);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:r}=e.userData;let o;if(t.traverse(h=>{h.name===i&&(o=h)}),!o)return;const c=new ur({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:r||1},o);e.add(c),this.controllers.push(c),c.addListener("change",()=>{this.ikControllers.forEach(h=>{h.enabled=!1}),clearTimeout(this._ikControllersTimer),this._ikControllersTimer=setTimeout(()=>{this.ikControllers.forEach(h=>{h.enabled=!0,h.syncTargetToEffector()})},100)}),(o.userData.isFork||o.userData.isLift||o.userData.isJack)&&(this._forkMaxHeight=r||1,this._liftMaxHeight=r||1,this._jackMaxHeight=r||1,c.addListener("change",h=>{this.setForkHeight(h),this.setLiftHeight(h),this.setJackHeight(h)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=tl(e.userData.startOrigin),r=e.userData.axios;let o,c;if(r==="x"?(o=new f.Vector3(e.userData.start-e.position.x,0,0),c=o.clone().setX(e.userData.end-e.position.x)):r==="z"?(o=new f.Vector3(0,e.userData.start-e.position.y,0),c=o.clone().setY(e.userData.end-e.position.y)):(o=new f.Vector3(0,0,e.userData.start-e.position.z),c=o.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(n=>n.startsWith("target")?e.userData[n].name:[]).length)return;const p=new vl({start:o,end:c,startOrigin:s,axios:r,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const r=e.userData.name,o=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(r){const h=e.userData.holeTarget&&e.userData.holeTarget.name;let u;h&&t.traverse(d=>{d.name===h&&(u=d)});const p=new Map;Object.keys(e.userData).forEach(d=>{if(d.startsWith("follow_")){const g=d.split("_")[1];if(g){let v=e.userData[d];p.set(g,{scale:v,initPos:e.position.clone(),origin:this.shapeKeys.get(g)||0})}}});const n=(s=this._app)==null?void 0:s.props.isMobile,l=new as({name:r,follows:p,slot:e,show:this._showSlots,isMirror:o,mirrorTarget:c,isMobile:n});return l.holeTarget=u,l.addEventListener(J.ON_DROP,d=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(J.ON_DEVICE_REPLACED,d=>{d&&this.updateIkJointChainByTool(d,"install")}),l.addEventListener(J.ON_DEVICE_DELETED,d=>{d&&this.updateIkJointChainByTool(d,"uninstall")}),l.addEventListener(J.ON_BEFORE_SELECTED,d=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(J.ON_ERROR_STATE_CHANGE,d=>{var v;if(!this._app)return;const g=(v=this._app)==null?void 0:v._outlinePassError;if(g)if(g.selectedObjects=g.selectedObjects.filter(m=>!!m.parent),d){if(l.device){if(g.selectedObjects.find(_=>{var y;return _.parent===((y=l.device)==null?void 0:y.parent)}))return;g.selectedObjects=[l.device,...g.selectedObjects]}}else l.device&&(g.selectedObjects=g.selectedObjects.filter(m=>{var _;return m.parent!==((_=l.device)==null?void 0:_.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._rollerLevel.clear(),De(this._container),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset(),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),this._shelfSyncCache=new WeakMap,this._rollerPools=new WeakMap,this._shapeKeyTimer&&(clearTimeout(this._shapeKeyTimer),this._shapeKeyTimer=0),this._currentAction=null,this._pendingFinishedCallback&&this._mixer&&(this._mixer.removeEventListener("finished",this._pendingFinishedCallback),this._pendingFinishedCallback=null),this._mixer&&(this._mixer.stopAllAction(),this._modelRoot&&this._mixer.uncacheRoot(this._modelRoot)),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],this._disposeIkControllers(),this._lift=void 0,this._fork=void 0,this._jack=void 0,this._roller=void 0,this._rollerBaffle=void 0,this._rollerTop=void 0,this._shelf=void 0,this._rollerGoodsBox=void 0,this._modelRoot=void 0,this.goods.forEach(e=>{e.dispose(),e.parent&&e.removeFromParent()}),this.goods=[],this._liftBrackets=[],this._videoCache.forEach(e=>{e.pause(),e.removeAttribute("src"),e.load(),e.remove()}),this._videoCache.clear(),this._masts.clear(),this._shelves.clear(),this._outline&&(this._outline.removeFromParent(),this._outline=void 0),this._app&&this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=void 0}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t){const i=Object.keys(t||{}).includes("reset")?t==null?void 0:t.reset:!0,s=this._actionsMap.get(e);if(!s||!this._mixer)return Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`));if(s.isRunning()&&s===this._currentAction)return Promise.resolve();const r=this._currentAction,o=r===s,c=o?0:t!=null&&t.fadeIn?t==null?void 0:t.fadeIn:.5,h=r&&!o&&r.isRunning();this._actionsMap.forEach(n=>{n!==s&&n!==r&&(n.stopFading(),n.setEffectiveWeight(0),n.stop())});const u=(t==null?void 0:t.loop)??!1;(i||!s.isRunning())&&s.reset(),s.enabled=!0,s.setEffectiveTimeScale((t==null?void 0:t.timeScale)??1),s.setEffectiveWeight(1),s.paused=!1,s.setLoop(u?f.LoopRepeat:f.LoopOnce,u?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!u,s.play();const p=(t==null?void 0:t.timeScale)??1;return h?(r.stopFading(),r.enabled=!0,r.setEffectiveWeight(1),r.crossFadeTo(s,c,!1)):c>0&&s.fadeIn(c),s.setEffectiveTimeScale(p),this._currentAction=s,new Promise(n=>{this._pendingFinishedCallback&&this._mixer&&this._mixer.removeEventListener("finished",this._pendingFinishedCallback);const l=d=>{var g;d.action===s&&((g=this._mixer)==null||g.removeEventListener("finished",l),this._pendingFinishedCallback=null,n())};this._pendingFinishedCallback=l,this._mixer.addEventListener("finished",l)})}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}stopAction(e,t=.3){const i=this._actionsMap.get(e);return!i||!i.isRunning()?Promise.resolve():(this._currentAction===i&&(this._currentAction=null),t>0?(i.fadeOut(t),new Promise(s=>{setTimeout(()=>{i.stop(),s()},t*1e3)})):(i.stop(),Promise.resolve()))}stopAllActions(e=.3){return this._mixer?(this._currentAction=null,e>0?(this._actionsMap.forEach(t=>{t.isRunning()&&t.fadeOut(e)}),new Promise(t=>{setTimeout(()=>{var i;(i=this._mixer)==null||i.stopAllAction(),t()},e*1e3)})):(this._mixer.stopAllAction(),Promise.resolve())):Promise.resolve()}}const ln=0,Pl=1,Ll=2,_r=2,Hi=1.25,vr=1,Vt=6*4+4+4,Mi=65535,Il=Math.pow(2,-24),Gi=Symbol("SKIP_GENERATION");function Rl(a){return a.index?a.index.count:a.attributes.position.count}function xt(a){return Rl(a)/3}function El(a,e=ArrayBuffer){return a>65535?new Uint32Array(new e(4*a)):new Uint16Array(new e(2*a))}function kl(a,e){if(!a.index){const t=a.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=El(t,i);a.setIndex(new f.BufferAttribute(s,1));for(let r=0;r<t;r++)s[r]=r}}function cn(a){const e=xt(a),t=a.drawRange,i=t.start/3,s=(t.start+t.count)/3,r=Math.max(0,i),o=Math.min(e,s)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function hn(a){if(!a.groups||!a.groups.length)return cn(a);const e=[],t=new Set,i=a.drawRange,s=i.start/3,r=(i.start+i.count)/3;for(const c of a.groups){const h=c.start/3,u=(c.start+c.count)/3;t.add(Math.max(s,h)),t.add(Math.min(r,u))}const o=Array.from(t.values()).sort((c,h)=>c-h);for(let c=0;c<o.length-1;c++){const h=o[c],u=o[c+1];e.push({offset:Math.floor(h),count:Math.floor(u-h)})}return e}function Fl(a){if(a.groups.length===0)return!1;const e=xt(a),t=hn(a).sort((r,o)=>r.offset-o.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:r})=>s+=r),e!==s}function Ni(a,e,t,i,s){let r=1/0,o=1/0,c=1/0,h=-1/0,u=-1/0,p=-1/0,n=1/0,l=1/0,d=1/0,g=-1/0,v=-1/0,m=-1/0;for(let _=e*6,y=(e+t)*6;_<y;_+=6){const w=a[_+0],x=a[_+1],b=w-x,T=w+x;b<r&&(r=b),T>h&&(h=T),w<n&&(n=w),w>g&&(g=w);const M=a[_+2],P=a[_+3],C=M-P,I=M+P;C<o&&(o=C),I>u&&(u=I),M<l&&(l=M),M>v&&(v=M);const D=a[_+4],A=a[_+5],S=D-A,L=D+A;S<c&&(c=S),L>p&&(p=L),D<d&&(d=D),D>m&&(m=D)}i[0]=r,i[1]=o,i[2]=c,i[3]=h,i[4]=u,i[5]=p,s[0]=n,s[1]=l,s[2]=d,s[3]=g,s[4]=v,s[5]=m}function Bl(a,e=null,t=null,i=null){const s=a.attributes.position,r=a.index?a.index.array:null,o=xt(a),c=s.normalized;let h;e===null?(h=new Float32Array(o*6*4),t=0,i=o):(h=e,t=t||0,i=i||o);const u=s.array,p=s.offset||0;let n=3;s.isInterleavedBufferAttribute&&(n=s.data.stride);const l=["getX","getY","getZ"];for(let d=t;d<t+i;d++){const g=d*3,v=d*6;let m=g+0,_=g+1,y=g+2;r&&(m=r[m],_=r[_],y=r[y]),c||(m=m*n+p,_=_*n+p,y=y*n+p);for(let w=0;w<3;w++){let x,b,T;c?(x=s[l[w]](m),b=s[l[w]](_),T=s[l[w]](y)):(x=u[m+w],b=u[_+w],T=u[y+w]);let M=x;b<M&&(M=b),T<M&&(M=T);let P=x;b>P&&(P=b),T>P&&(P=T);const C=(P-M)/2,I=w*2;h[v+I+0]=M+C,h[v+I+1]=C+(Math.abs(M)+C)*Il}}return h}function Z(a,e,t){return t.min.x=e[a],t.min.y=e[a+1],t.min.z=e[a+2],t.max.x=e[a+3],t.max.y=e[a+4],t.max.z=e[a+5],t}function yr(a){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=a[i+3]-a[i];s>t&&(t=s,e=i)}return e}function xr(a,e){e.set(a)}function wr(a,e,t){let i,s;for(let r=0;r<3;r++){const o=r+3;i=a[r],s=e[r],t[r]=i<s?i:s,i=a[o],s=e[o],t[o]=i>s?i:s}}function si(a,e,t){for(let i=0;i<3;i++){const s=e[a+2*i],r=e[a+2*i+1],o=s-r,c=s+r;o<t[i]&&(t[i]=o),c>t[i+3]&&(t[i+3]=c)}}function Pt(a){const e=a[3]-a[0],t=a[4]-a[1],i=a[5]-a[2];return 2*(e*t+t*i+i*e)}const Te=32,Ol=(a,e)=>a.candidate-e.candidate,Ee=new Array(Te).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ri=new Float32Array(6);function zl(a,e,t,i,s,r){let o=-1,c=0;if(r===ln)o=yr(e),o!==-1&&(c=(e[o]+e[o+3])/2);else if(r===Pl)o=yr(a),o!==-1&&(c=Vl(t,i,s,o));else if(r===Ll){const h=Pt(a);let u=Hi*s;const p=i*6,n=(i+s)*6;for(let l=0;l<3;l++){const d=e[l],m=(e[l+3]-d)/Te;if(s<Te/4){const _=[...Ee];_.length=s;let y=0;for(let x=p;x<n;x+=6,y++){const b=_[y];b.candidate=t[x+2*l],b.count=0;const{bounds:T,leftCacheBounds:M,rightCacheBounds:P}=b;for(let C=0;C<3;C++)P[C]=1/0,P[C+3]=-1/0,M[C]=1/0,M[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0;si(x,t,T)}_.sort(Ol);let w=s;for(let x=0;x<w;x++){const b=_[x];for(;x+1<w&&_[x+1].candidate===b.candidate;)_.splice(x+1,1),w--}for(let x=p;x<n;x+=6){const b=t[x+2*l];for(let T=0;T<w;T++){const M=_[T];b>=M.candidate?si(x,t,M.rightCacheBounds):(si(x,t,M.leftCacheBounds),M.count++)}}for(let x=0;x<w;x++){const b=_[x],T=b.count,M=s-b.count,P=b.leftCacheBounds,C=b.rightCacheBounds;let I=0;T!==0&&(I=Pt(P)/h);let D=0;M!==0&&(D=Pt(C)/h);const A=vr+Hi*(I*T+D*M);A<u&&(o=l,u=A,c=b.candidate)}}else{for(let w=0;w<Te;w++){const x=Ee[w];x.count=0,x.candidate=d+m+w*m;const b=x.bounds;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0}for(let w=p;w<n;w+=6){let T=~~((t[w+2*l]-d)/m);T>=Te&&(T=Te-1);const M=Ee[T];M.count++,si(w,t,M.bounds)}const _=Ee[Te-1];xr(_.bounds,_.rightCacheBounds);for(let w=Te-2;w>=0;w--){const x=Ee[w],b=Ee[w+1];wr(x.bounds,b.rightCacheBounds,x.rightCacheBounds)}let y=0;for(let w=0;w<Te-1;w++){const x=Ee[w],b=x.count,T=x.bounds,P=Ee[w+1].rightCacheBounds;b!==0&&(y===0?xr(T,ri):wr(T,ri,ri)),y+=b;let C=0,I=0;y!==0&&(C=Pt(ri)/h);const D=s-y;D!==0&&(I=Pt(P)/h);const A=vr+Hi*(C*y+I*D);A<u&&(o=l,u=A,c=x.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:c}}function Vl(a,e,t,i){let s=0;for(let r=e,o=e+t;r<o;r++)s+=a[r*6+i*2];return s/t}class Qi{constructor(){this.boundingData=new Float32Array(6)}}function Wl(a,e,t,i,s,r){let o=i,c=i+s-1;const h=r.pos,u=r.axis*2;for(;;){for(;o<=c&&t[o*6+u]<h;)o++;for(;o<=c&&t[c*6+u]>=h;)c--;if(o<c){for(let p=0;p<3;p++){let n=e[o*3+p];e[o*3+p]=e[c*3+p],e[c*3+p]=n}for(let p=0;p<6;p++){let n=t[o*6+p];t[o*6+p]=t[c*6+p],t[c*6+p]=n}o++,c--}else return o}}function Ul(a,e,t,i,s,r){let o=i,c=i+s-1;const h=r.pos,u=r.axis*2;for(;;){for(;o<=c&&t[o*6+u]<h;)o++;for(;o<=c&&t[c*6+u]>=h;)c--;if(o<c){let p=a[o];a[o]=a[c],a[c]=p;for(let n=0;n<6;n++){let l=t[o*6+n];t[o*6+n]=t[c*6+n],t[c*6+n]=l}o++,c--}else return o}}function oe(a,e){return e[a+15]===65535}function le(a,e){return e[a+6]}function ce(a,e){return e[a+14]}function he(a){return a+8}function ue(a,e){return e[a+6]}function un(a,e){return e[a+7]}let fn,Bt,yi,dn;const Hl=Math.pow(2,32);function hs(a){return"count"in a?1:1+hs(a.left)+hs(a.right)}function Gl(a,e,t){return fn=new Float32Array(t),Bt=new Uint32Array(t),yi=new Uint16Array(t),dn=new Uint8Array(t),us(a,e)}function us(a,e){const t=a/4,i=a/2,s="count"in e,r=e.boundingData;for(let o=0;o<6;o++)fn[t+o]=r[o];if(s)if(e.buffer){const o=e.buffer;dn.set(new Uint8Array(o),a);for(let c=a,h=a+o.byteLength;c<h;c+=Vt){const u=c/2;oe(u,yi)||(Bt[c/4+6]+=t)}return a+o.byteLength}else{const o=e.offset,c=e.count;return Bt[t+6]=o,yi[i+14]=c,yi[i+15]=Mi,a+Vt}else{const o=e.left,c=e.right,h=e.splitAxis;let u;if(u=us(a+Vt,o),u/4>Hl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Bt[t+6]=u/4,u=us(u,c),Bt[t+7]=h,u}}function Nl(a,e){const t=(a.index?a.index.count:a.attributes.position.count)/3,i=t>2**16,s=i?4:2,r=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),o=i?new Uint32Array(r):new Uint16Array(r);for(let c=0,h=o.length;c<h;c++)o[c]=c;return o}function Ql(a,e,t,i,s){const{maxDepth:r,verbose:o,maxLeafTris:c,strategy:h,onProgress:u,indirect:p}=s,n=a._indirectBuffer,l=a.geometry,d=l.index?l.index.array:null,g=p?Ul:Wl,v=xt(l),m=new Float32Array(6);let _=!1;const y=new Qi;return Ni(e,t,i,y.boundingData,m),x(y,t,i,m),y;function w(b){u&&u(b/v)}function x(b,T,M,P=null,C=0){if(!_&&C>=r&&(_=!0,o&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),M<=c||C>=r)return w(T+M),b.offset=T,b.count=M,b;const I=zl(b.boundingData,P,e,T,M,h);if(I.axis===-1)return w(T+M),b.offset=T,b.count=M,b;const D=g(n,d,e,T,M,I);if(D===T||D===T+M)w(T+M),b.offset=T,b.count=M;else{b.splitAxis=I.axis;const A=new Qi,S=T,L=D-T;b.left=A,Ni(e,S,L,A.boundingData,m),x(A,S,L,m,C+1);const R=new Qi,k=D,F=M-L;b.right=R,Ni(e,k,F,R.boundingData,m),x(R,k,F,m,C+1)}return b}}function jl(a,e){const t=a.geometry;e.indirect&&(a._indirectBuffer=Nl(t,e.useSharedArrayBuffer),Fl(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),a._indirectBuffer||kl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Bl(t),r=e.indirect?cn(t):hn(t);a._roots=r.map(o=>{const c=Ql(a,s,o.offset,o.count,e),h=hs(c),u=new i(Vt*h);return Gl(0,c,u),u})}class Pe{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let r=0,o=e.length;r<o;r++){const h=e[r][t];i=h<i?h:i,s=h>s?h:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let r=0,o=t.length;r<o;r++){const c=t[r],h=e.dot(c);i=h<i?h:i,s=h>s?h:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Pe.prototype.setFromBox=function(){const a=new f.Vector3;return function(t,i){const s=i.min,r=i.max;let o=1/0,c=-1/0;for(let h=0;h<=1;h++)for(let u=0;u<=1;u++)for(let p=0;p<=1;p++){a.x=s.x*h+r.x*(1-h),a.y=s.y*u+r.y*(1-u),a.z=s.z*p+r.z*(1-p);const n=t.dot(a);o=Math.min(n,o),c=Math.max(n,c)}this.min=o,this.max=c}}();const ql=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(s,r,o){const c=s.start,h=a,u=r.start,p=e;t.subVectors(c,u),a.subVectors(s.end,s.start),e.subVectors(r.end,r.start);const n=t.dot(p),l=p.dot(h),d=p.dot(p),g=t.dot(h),m=h.dot(h)*d-l*l;let _,y;m!==0?_=(n*l-g*d)/m:_=0,y=(n+_*l)/d,o.x=_,o.y=y}}(),Ps=function(){const a=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(s,r,o,c){ql(s,r,a);let h=a.x,u=a.y;if(h>=0&&h<=1&&u>=0&&u<=1){s.at(h,o),r.at(u,c);return}else if(h>=0&&h<=1){u<0?r.at(0,c):r.at(1,c),s.closestPointToPoint(c,!0,o);return}else if(u>=0&&u<=1){h<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,c);return}else{let p;h<0?p=s.start:p=s.end;let n;u<0?n=r.start:n=r.end;const l=e,d=t;if(s.closestPointToPoint(n,!0,e),r.closestPointToPoint(p,!0,t),l.distanceToSquared(n)<=d.distanceToSquared(p)){o.copy(l),c.copy(n);return}else{o.copy(p),c.copy(d);return}}}}(),Yl=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Plane,i=new f.Line3;return function(r,o){const{radius:c,center:h}=r,{a:u,b:p,c:n}=o;if(i.start=u,i.end=p,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c||(i.start=u,i.end=n,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c)||(i.start=p,i.end=n,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c))return!0;const v=o.getPlane(t);if(Math.abs(v.distanceToPoint(h))<=c){const _=v.projectPoint(h,e);if(o.containsPoint(_))return!0}return!1}}(),Zl=1e-15;function ji(a){return Math.abs(a)<Zl}class ge extends f.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new f.Vector3),this.satBounds=new Array(4).fill().map(()=>new Pe),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return Yl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,r=this.satAxes,o=this.satBounds,c=r[0],h=o[0];this.getNormal(c),h.setFromPoints(c,s);const u=r[1],p=o[1];u.subVectors(e,t),p.setFromPoints(u,s);const n=r[2],l=o[2];n.subVectors(t,i),l.setFromPoints(n,s);const d=r[3],g=o[3];d.subVectors(i,e),g.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}ge.prototype.closestPointToSegment=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(s,r=null,o=null){const{start:c,end:h}=s,u=this.points;let p,n=1/0;for(let l=0;l<3;l++){const d=(l+1)%3;t.start.copy(u[l]),t.end.copy(u[d]),Ps(t,s,a,e),p=a.distanceToSquared(e),p<n&&(n=p,r&&r.copy(a),o&&o.copy(e))}return this.closestPointToPoint(c,a),p=c.distanceToSquared(a),p<n&&(n=p,r&&r.copy(a),o&&o.copy(c)),this.closestPointToPoint(h,a),p=h.distanceToSquared(a),p<n&&(n=p,r&&r.copy(a),o&&o.copy(h)),Math.sqrt(n)}}();ge.prototype.intersectsTriangle=function(){const a=new ge,e=new Array(3),t=new Array(3),i=new Pe,s=new Pe,r=new f.Vector3,o=new f.Vector3,c=new f.Vector3,h=new f.Vector3,u=new f.Vector3,p=new f.Line3,n=new f.Line3,l=new f.Line3,d=new f.Vector3;function g(v,m,_){const y=v.points;let w=0,x=-1;for(let b=0;b<3;b++){const{start:T,end:M}=p;T.copy(y[b]),M.copy(y[(b+1)%3]),p.delta(o);const P=ji(m.distanceToPoint(T));if(ji(m.normal.dot(o))&&P){_.copy(p),w=2;break}const C=m.intersectLine(p,d);if(!C&&P&&d.copy(T),(C||P)&&!ji(d.distanceTo(M))){if(w<=1)(w===1?_.start:_.end).copy(d),P&&(x=w);else if(w>=2){(x===1?_.start:_.end).copy(d),w=2;break}if(w++,w===2&&x===-1)break}}return w}return function(m,_=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(a.copy(m),a.update(),m=a);const w=this.plane,x=m.plane;if(Math.abs(w.normal.dot(x.normal))>1-1e-10){const b=this.satBounds,T=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let C=0;C<4;C++){const I=b[C],D=T[C];if(i.setFromPoints(D,t),I.isSeparated(i))return!1}const M=m.satBounds,P=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const I=M[C],D=P[C];if(i.setFromPoints(D,e),I.isSeparated(i))return!1}for(let C=0;C<4;C++){const I=T[C];for(let D=0;D<4;D++){const A=P[D];if(r.crossVectors(I,A),i.setFromPoints(r,e),s.setFromPoints(r,t),i.isSeparated(s))return!1}}return _&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}else{const b=g(this,x,n);if(b===1&&m.containsPoint(n.end))return _&&(_.start.copy(n.end),_.end.copy(n.end)),!0;if(b!==2)return!1;const T=g(m,w,l);if(T===1&&this.containsPoint(l.end))return _&&(_.start.copy(l.end),_.end.copy(l.end)),!0;if(T!==2)return!1;if(n.delta(c),l.delta(h),c.dot(h)<0){let S=l.start;l.start=l.end,l.end=S}const M=n.start.dot(c),P=n.end.dot(c),C=l.start.dot(c),I=l.end.dot(c),D=P<C,A=M<I;return M!==I&&C!==P&&D===A?!1:(_&&(u.subVectors(n.start,l.start),u.dot(c)>0?_.start.copy(n.start):_.start.copy(l.start),u.subVectors(n.end,l.end),u.dot(c)<0?_.end.copy(n.end):_.end.copy(l.end)),!0)}}}();ge.prototype.distanceToPoint=function(){const a=new f.Vector3;return function(t){return this.closestPointToPoint(t,a),t.distanceTo(a)}}();ge.prototype.distanceToTriangle=function(){const a=new f.Vector3,e=new f.Vector3,t=["a","b","c"],i=new f.Line3,s=new f.Line3;return function(o,c=null,h=null){const u=c||h?i:null;if(this.intersectsTriangle(o,u))return(c||h)&&(c&&u.getCenter(c),h&&u.getCenter(h)),0;let p=1/0;for(let n=0;n<3;n++){let l;const d=t[n],g=o[d];this.closestPointToPoint(g,a),l=g.distanceToSquared(a),l<p&&(p=l,c&&c.copy(a),h&&h.copy(g));const v=this[d];o.closestPointToPoint(v,a),l=v.distanceToSquared(a),l<p&&(p=l,c&&c.copy(v),h&&h.copy(a))}for(let n=0;n<3;n++){const l=t[n],d=t[(n+1)%3];i.set(this[l],this[d]);for(let g=0;g<3;g++){const v=t[g],m=t[(g+1)%3];s.set(o[v],o[m]),Ps(i,s,a,e);const _=a.distanceToSquared(e);_<p&&(p=_,c&&c.copy(a),h&&h.copy(e))}}return Math.sqrt(p)}}();class te{constructor(e,t,i){this.isOrientedBox=!0,this.min=new f.Vector3,this.max=new f.Vector3,this.matrix=new f.Matrix4,this.invMatrix=new f.Matrix4,this.points=new Array(8).fill().map(()=>new f.Vector3),this.satAxes=new Array(3).fill().map(()=>new f.Vector3),this.satBounds=new Array(3).fill().map(()=>new Pe),this.alignedSatBounds=new Array(3).fill().map(()=>new Pe),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}te.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let u=0;u<=1;u++)for(let p=0;p<=1;p++)for(let n=0;n<=1;n++){const l=1*u|2*p|4*n,d=s[l];d.x=u?i.x:t.x,d.y=p?i.y:t.y,d.z=n?i.z:t.z,d.applyMatrix4(e)}const r=this.satBounds,o=this.satAxes,c=s[0];for(let u=0;u<3;u++){const p=o[u],n=r[u],l=1<<u,d=s[l];p.subVectors(c,d),n.setFromPoints(p,s)}const h=this.alignedSatBounds;h[0].setFromPointsField(s,"x"),h[1].setFromPointsField(s,"y"),h[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();te.prototype.intersectsBox=function(){const a=new Pe;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,r=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(a.min=i.x,a.max=s.x,c[0].isSeparated(a)||(a.min=i.y,a.max=s.y,c[1].isSeparated(a))||(a.min=i.z,a.max=s.z,c[2].isSeparated(a)))return!1;for(let h=0;h<3;h++){const u=o[h],p=r[h];if(a.setFromBox(u,t),p.isSeparated(a))return!1}return!0}}();te.prototype.intersectsTriangle=function(){const a=new ge,e=new Array(3),t=new Pe,i=new Pe,s=new f.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(a.copy(o),a.update(),o=a);const c=this.satBounds,h=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let l=0;l<3;l++){const d=c[l],g=h[l];if(t.setFromPoints(g,e),d.isSeparated(t))return!1}const u=o.satBounds,p=o.satAxes,n=this.points;for(let l=0;l<3;l++){const d=u[l],g=p[l];if(t.setFromPoints(g,n),d.isSeparated(t))return!1}for(let l=0;l<3;l++){const d=h[l];for(let g=0;g<4;g++){const v=p[g];if(s.crossVectors(d,v),t.setFromPoints(s,e),i.setFromPoints(s,n),t.isSeparated(i))return!1}}return!0}}();te.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();te.prototype.distanceToPoint=function(){const a=new f.Vector3;return function(t){return this.closestPointToPoint(t,a),t.distanceTo(a)}}();te.prototype.distanceToBox=function(){const a=["x","y","z"],e=new Array(12).fill().map(()=>new f.Line3),t=new Array(12).fill().map(()=>new f.Line3),i=new f.Vector3,s=new f.Vector3;return function(o,c=0,h=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(h||u)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),h&&h.copy(i),u&&u.copy(s)),0;const p=c*c,n=o.min,l=o.max,d=this.points;let g=1/0;for(let m=0;m<8;m++){const _=d[m];s.copy(_).clamp(n,l);const y=_.distanceToSquared(s);if(y<g&&(g=y,h&&h.copy(_),u&&u.copy(s),y<p))return Math.sqrt(y)}let v=0;for(let m=0;m<3;m++)for(let _=0;_<=1;_++)for(let y=0;y<=1;y++){const w=(m+1)%3,x=(m+2)%3,b=_<<w|y<<x,T=1<<m|_<<w|y<<x,M=d[b],P=d[T];e[v].set(M,P);const I=a[m],D=a[w],A=a[x],S=t[v],L=S.start,R=S.end;L[I]=n[I],L[D]=_?n[D]:l[D],L[A]=y?n[A]:l[D],R[I]=l[I],R[D]=_?n[D]:l[D],R[A]=y?n[A]:l[D],v++}for(let m=0;m<=1;m++)for(let _=0;_<=1;_++)for(let y=0;y<=1;y++){s.x=m?l.x:n.x,s.y=_?l.y:n.y,s.z=y?l.z:n.z,this.closestPointToPoint(s,i);const w=s.distanceToSquared(i);if(w<g&&(g=w,h&&h.copy(i),u&&u.copy(s),w<p))return Math.sqrt(w)}for(let m=0;m<12;m++){const _=e[m];for(let y=0;y<12;y++){const w=t[y];Ps(_,w,i,s);const x=i.distanceToSquared(s);if(x<g&&(g=x,h&&h.copy(i),u&&u.copy(s),x<p))return Math.sqrt(x)}}return Math.sqrt(g)}}();class Ls{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Kl extends Ls{constructor(){super(()=>new ge)}}const fe=new Kl;class Xl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Y=new Xl;let ze,dt;const $e=[],ni=new Ls(()=>new f.Box3);function Jl(a,e,t,i,s,r){ze=ni.getPrimitive(),dt=ni.getPrimitive(),$e.push(ze,dt),Y.setBuffer(a._roots[e]);const o=fs(0,a.geometry,t,i,s,r);Y.clearBuffer(),ni.releasePrimitive(ze),ni.releasePrimitive(dt),$e.pop(),$e.pop();const c=$e.length;return c>0&&(dt=$e[c-1],ze=$e[c-2]),o}function fs(a,e,t,i,s=null,r=0,o=0){const{float32Array:c,uint16Array:h,uint32Array:u}=Y;let p=a*2;if(oe(p,h)){const l=le(a,u),d=ce(p,h);return Z(a,c,ze),i(l,d,!1,o,r+a,ze)}else{let I=function(A){const{uint16Array:S,uint32Array:L}=Y;let R=A*2;for(;!oe(R,S);)A=he(A),R=A*2;return le(A,L)},D=function(A){const{uint16Array:S,uint32Array:L}=Y;let R=A*2;for(;!oe(R,S);)A=ue(A,L),R=A*2;return le(A,L)+ce(R,S)};const l=he(a),d=ue(a,u);let g=l,v=d,m,_,y,w;if(s&&(y=ze,w=dt,Z(g,c,y),Z(v,c,w),m=s(y),_=s(w),_<m)){g=d,v=l;const A=m;m=_,_=A,y=w}y||(y=ze,Z(g,c,y));const x=oe(g*2,h),b=t(y,x,m,o+1,r+g);let T;if(b===_r){const A=I(g),L=D(g)-A;T=i(A,L,!0,o+1,r+g,y)}else T=b&&fs(g,e,t,i,s,r,o+1);if(T)return!0;w=dt,Z(v,c,w);const M=oe(v*2,h),P=t(w,M,_,o+1,r+v);let C;if(P===_r){const A=I(v),L=D(v)-A;C=i(A,L,!0,o+1,r+v,w)}else C=P&&fs(v,e,t,i,s,r,o+1);return!!C}}const Lt=new f.Vector3,qi=new f.Vector3;function $l(a,e,t={},i=0,s=1/0){const r=i*i,o=s*s;let c=1/0,h=null;if(a.shapecast({boundsTraverseOrder:p=>(Lt.copy(e).clamp(p.min,p.max),Lt.distanceToSquared(e)),intersectsBounds:(p,n,l)=>l<c&&l<o,intersectsTriangle:(p,n)=>{p.closestPointToPoint(e,Lt);const l=e.distanceToSquared(Lt);return l<c&&(qi.copy(Lt),c=l,h=n),l<r}}),c===1/0)return null;const u=Math.sqrt(c);return t.point?t.point.copy(qi):t.point=qi.clone(),t.distance=u,t.faceIndex=h,t}const et=new f.Vector3,it=new f.Vector3,st=new f.Vector3,oi=new f.Vector2,ai=new f.Vector2,li=new f.Vector2,br=new f.Vector3,Ar=new f.Vector3,Tr=new f.Vector3,ci=new f.Vector3;function ec(a,e,t,i,s,r,o,c){let h;if(r===f.BackSide?h=a.intersectTriangle(i,t,e,!0,s):h=a.intersectTriangle(e,t,i,r!==f.DoubleSide,s),h===null)return null;const u=a.origin.distanceTo(s);return u<o||u>c?null:{distance:u,point:s.clone()}}function tc(a,e,t,i,s,r,o,c,h,u,p){et.fromBufferAttribute(e,r),it.fromBufferAttribute(e,o),st.fromBufferAttribute(e,c);const n=ec(a,et,it,st,ci,h,u,p);if(n){i&&(oi.fromBufferAttribute(i,r),ai.fromBufferAttribute(i,o),li.fromBufferAttribute(i,c),n.uv=f.Triangle.getInterpolation(ci,et,it,st,oi,ai,li,new f.Vector2)),s&&(oi.fromBufferAttribute(s,r),ai.fromBufferAttribute(s,o),li.fromBufferAttribute(s,c),n.uv1=f.Triangle.getInterpolation(ci,et,it,st,oi,ai,li,new f.Vector2)),t&&(br.fromBufferAttribute(t,r),Ar.fromBufferAttribute(t,o),Tr.fromBufferAttribute(t,c),n.normal=f.Triangle.getInterpolation(ci,et,it,st,br,Ar,Tr,new f.Vector3),n.normal.dot(a.direction)>0&&n.normal.multiplyScalar(-1));const l={a:r,b:o,c,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(et,it,st,l.normal),n.face=l,n.faceIndex=r}return n}function Ci(a,e,t,i,s,r,o){const c=i*3;let h=c+0,u=c+1,p=c+2;const n=a.index;a.index&&(h=n.getX(h),u=n.getX(u),p=n.getX(p));const{position:l,normal:d,uv:g,uv1:v}=a.attributes,m=tc(t,l,d,g,v,h,u,p,e,r,o);return m?(m.faceIndex=i,s&&s.push(m),m):null}function K(a,e,t,i){const s=a.a,r=a.b,o=a.c;let c=e,h=e+1,u=e+2;t&&(c=t.getX(c),h=t.getX(h),u=t.getX(u)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),r.x=i.getX(h),r.y=i.getY(h),r.z=i.getZ(h),o.x=i.getX(u),o.y=i.getY(u),o.z=i.getZ(u)}function ic(a,e,t,i,s,r,o,c){const{geometry:h,_indirectBuffer:u}=a;for(let p=i,n=i+s;p<n;p++)Ci(h,e,t,p,r,o,c)}function sc(a,e,t,i,s,r,o){const{geometry:c,_indirectBuffer:h}=a;let u=1/0,p=null;for(let n=i,l=i+s;n<l;n++){let d;d=Ci(c,e,t,n,null,r,o),d&&d.distance<u&&(p=d,u=d.distance)}return p}function rc(a,e,t,i,s,r,o){const{geometry:c}=t,{index:h}=c,u=c.attributes.position;for(let p=a,n=e+a;p<n;p++){let l;if(l=p,K(o,l*3,h,u),o.needsUpdate=!0,i(o,l,s,r))return!0}return!1}function nc(a,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=a.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,c,h,u=0;const p=a._roots;for(let l=0,d=p.length;l<d;l++)r=p[l],o=new Uint32Array(r),c=new Uint16Array(r),h=new Float32Array(r),n(0,u),u+=r.byteLength;function n(l,d,g=!1){const v=l*2;if(c[v+15]===Mi){const _=o[l+6],y=c[v+14];let w=1/0,x=1/0,b=1/0,T=-1/0,M=-1/0,P=-1/0;for(let C=3*_,I=3*(_+y);C<I;C++){let D=i[C];const A=s.getX(D),S=s.getY(D),L=s.getZ(D);A<w&&(w=A),A>T&&(T=A),S<x&&(x=S),S>M&&(M=S),L<b&&(b=L),L>P&&(P=L)}return h[l+0]!==w||h[l+1]!==x||h[l+2]!==b||h[l+3]!==T||h[l+4]!==M||h[l+5]!==P?(h[l+0]=w,h[l+1]=x,h[l+2]=b,h[l+3]=T,h[l+4]=M,h[l+5]=P,!0):!1}else{const _=l+8,y=o[l+6],w=_+d,x=y+d;let b=g,T=!1,M=!1;e?b||(T=e.has(w),M=e.has(x),b=!T&&!M):(T=!0,M=!0);const P=b||T,C=b||M;let I=!1;P&&(I=n(_,d,b));let D=!1;C&&(D=n(y,d,b));const A=I||D;if(A)for(let S=0;S<3;S++){const L=_+S,R=y+S,k=h[L],F=h[L+3],z=h[R],B=h[R+3];h[l+S]=k<z?k:z,h[l+S+3]=F>B?F:B}return A}}}function Ve(a,e,t,i,s){let r,o,c,h,u,p;const n=1/t.direction.x,l=1/t.direction.y,d=1/t.direction.z,g=t.origin.x,v=t.origin.y,m=t.origin.z;let _=e[a],y=e[a+3],w=e[a+1],x=e[a+3+1],b=e[a+2],T=e[a+3+2];return n>=0?(r=(_-g)*n,o=(y-g)*n):(r=(y-g)*n,o=(_-g)*n),l>=0?(c=(w-v)*l,h=(x-v)*l):(c=(x-v)*l,h=(w-v)*l),r>h||c>o||((c>r||isNaN(r))&&(r=c),(h<o||isNaN(o))&&(o=h),d>=0?(u=(b-m)*d,p=(T-m)*d):(u=(T-m)*d,p=(b-m)*d),r>p||u>o)?!1:((u>r||r!==r)&&(r=u),(p<o||o!==o)&&(o=p),r<=s&&o>=i)}function oc(a,e,t,i,s,r,o,c){const{geometry:h,_indirectBuffer:u}=a;for(let p=i,n=i+s;p<n;p++){let l=u?u[p]:p;Ci(h,e,t,l,r,o,c)}}function ac(a,e,t,i,s,r,o){const{geometry:c,_indirectBuffer:h}=a;let u=1/0,p=null;for(let n=i,l=i+s;n<l;n++){let d;d=Ci(c,e,t,h?h[n]:n,null,r,o),d&&d.distance<u&&(p=d,u=d.distance)}return p}function lc(a,e,t,i,s,r,o){const{geometry:c}=t,{index:h}=c,u=c.attributes.position;for(let p=a,n=e+a;p<n;p++){let l;if(l=t.resolveTriangleIndex(p),K(o,l*3,h,u),o.needsUpdate=!0,i(o,l,s,r))return!0}return!1}function cc(a,e,t,i,s,r,o){Y.setBuffer(a._roots[e]),ds(0,a,t,i,s,r,o),Y.clearBuffer()}function ds(a,e,t,i,s,r,o){const{float32Array:c,uint16Array:h,uint32Array:u}=Y,p=a*2;if(oe(p,h)){const l=le(a,u),d=ce(p,h);ic(e,t,i,l,d,s,r,o)}else{const l=he(a);Ve(l,c,i,r,o)&&ds(l,e,t,i,s,r,o);const d=ue(a,u);Ve(d,c,i,r,o)&&ds(d,e,t,i,s,r,o)}}const hc=["x","y","z"];function uc(a,e,t,i,s,r){Y.setBuffer(a._roots[e]);const o=ps(0,a,t,i,s,r);return Y.clearBuffer(),o}function ps(a,e,t,i,s,r){const{float32Array:o,uint16Array:c,uint32Array:h}=Y;let u=a*2;if(oe(u,c)){const n=le(a,h),l=ce(u,c);return sc(e,t,i,n,l,s,r)}else{const n=un(a,h),l=hc[n],g=i.direction[l]>=0;let v,m;g?(v=he(a),m=ue(a,h)):(v=ue(a,h),m=he(a));const y=Ve(v,o,i,s,r)?ps(v,e,t,i,s,r):null;if(y){const b=y.point[l];if(g?b<=o[m+n]:b>=o[m+n+3])return y}const x=Ve(m,o,i,s,r)?ps(m,e,t,i,s,r):null;return y&&x?y.distance<=x.distance?y:x:y||x||null}}const hi=new f.Box3,rt=new ge,nt=new ge,It=new f.Matrix4,Sr=new te,ui=new te;function fc(a,e,t,i){Y.setBuffer(a._roots[e]);const s=ms(0,a,t,i);return Y.clearBuffer(),s}function ms(a,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:c}=Y;let h=a*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Sr.set(t.boundingBox.min,t.boundingBox.max,i),s=Sr),oe(h,o)){const p=e.geometry,n=p.index,l=p.attributes.position,d=t.index,g=t.attributes.position,v=le(a,c),m=ce(h,o);if(It.copy(i).invert(),t.boundsTree)return Z(a,r,ui),ui.matrix.copy(It),ui.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>ui.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let w=v*3,x=(m+v)*3;w<x;w+=3)if(K(nt,w,n,l),nt.needsUpdate=!0,y.intersectsTriangle(nt))return!0;return!1}});for(let _=v*3,y=(m+v)*3;_<y;_+=3){K(rt,_,n,l),rt.a.applyMatrix4(It),rt.b.applyMatrix4(It),rt.c.applyMatrix4(It),rt.needsUpdate=!0;for(let w=0,x=d.count;w<x;w+=3)if(K(nt,w,d,g),nt.needsUpdate=!0,rt.intersectsTriangle(nt))return!0}}else{const p=a+8,n=c[a+6];return Z(p,r,hi),!!(s.intersectsBox(hi)&&ms(p,e,t,i,s)||(Z(n,r,hi),s.intersectsBox(hi)&&ms(n,e,t,i,s)))}}const fi=new f.Matrix4,Yi=new te,Rt=new te,dc=new f.Vector3,pc=new f.Vector3,mc=new f.Vector3,gc=new f.Vector3;function _c(a,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Yi.set(e.boundingBox.min,e.boundingBox.max,t),Yi.needsUpdate=!0;const c=a.geometry,h=c.attributes.position,u=c.index,p=e.attributes.position,n=e.index,l=fe.getPrimitive(),d=fe.getPrimitive();let g=dc,v=pc,m=null,_=null;s&&(m=mc,_=gc);let y=1/0,w=null,x=null;return fi.copy(t).invert(),Rt.matrix.copy(fi),a.shapecast({boundsTraverseOrder:b=>Yi.distanceToBox(b),intersectsBounds:(b,T,M)=>M<y&&M<o?(T&&(Rt.min.copy(b.min),Rt.max.copy(b.max),Rt.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:P=>Rt.distanceToBox(P),intersectsBounds:(P,C,I)=>I<y&&I<o,intersectsRange:(P,C)=>{for(let I=P,D=P+C;I<D;I++){K(d,3*I,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let A=b,S=b+T;A<S;A++){K(l,3*A,u,h),l.needsUpdate=!0;const L=l.distanceToTriangle(d,g,m);if(L<y&&(v.copy(g),_&&_.copy(m),y=L,w=A,x=I),L<r)return!0}}}});{const M=xt(e);for(let P=0,C=M;P<C;P++){K(d,3*P,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let I=b,D=b+T;I<D;I++){K(l,3*I,u,h),l.needsUpdate=!0;const A=l.distanceToTriangle(d,g,m);if(A<y&&(v.copy(g),_&&_.copy(m),y=A,w=I,x=P),A<r)return!0}}}}}),fe.releasePrimitive(l),fe.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=y,i.faceIndex=w,s&&(s.point?s.point.copy(_):s.point=_.clone(),s.point.applyMatrix4(fi),v.applyMatrix4(fi),s.distance=v.sub(s.point).length(),s.faceIndex=x),i)}function vc(a,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=a.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,c,h,u=0;const p=a._roots;for(let l=0,d=p.length;l<d;l++)r=p[l],o=new Uint32Array(r),c=new Uint16Array(r),h=new Float32Array(r),n(0,u),u+=r.byteLength;function n(l,d,g=!1){const v=l*2;if(c[v+15]===Mi){const _=o[l+6],y=c[v+14];let w=1/0,x=1/0,b=1/0,T=-1/0,M=-1/0,P=-1/0;for(let C=_,I=_+y;C<I;C++){const D=3*a.resolveTriangleIndex(C);for(let A=0;A<3;A++){let S=D+A;S=i?i[S]:S;const L=s.getX(S),R=s.getY(S),k=s.getZ(S);L<w&&(w=L),L>T&&(T=L),R<x&&(x=R),R>M&&(M=R),k<b&&(b=k),k>P&&(P=k)}}return h[l+0]!==w||h[l+1]!==x||h[l+2]!==b||h[l+3]!==T||h[l+4]!==M||h[l+5]!==P?(h[l+0]=w,h[l+1]=x,h[l+2]=b,h[l+3]=T,h[l+4]=M,h[l+5]=P,!0):!1}else{const _=l+8,y=o[l+6],w=_+d,x=y+d;let b=g,T=!1,M=!1;e?b||(T=e.has(w),M=e.has(x),b=!T&&!M):(T=!0,M=!0);const P=b||T,C=b||M;let I=!1;P&&(I=n(_,d,b));let D=!1;C&&(D=n(y,d,b));const A=I||D;if(A)for(let S=0;S<3;S++){const L=_+S,R=y+S,k=h[L],F=h[L+3],z=h[R],B=h[R+3];h[l+S]=k<z?k:z,h[l+S+3]=F>B?F:B}return A}}}function yc(a,e,t,i,s,r,o){Y.setBuffer(a._roots[e]),gs(0,a,t,i,s,r,o),Y.clearBuffer()}function gs(a,e,t,i,s,r,o){const{float32Array:c,uint16Array:h,uint32Array:u}=Y,p=a*2;if(oe(p,h)){const l=le(a,u),d=ce(p,h);oc(e,t,i,l,d,s,r,o)}else{const l=he(a);Ve(l,c,i,r,o)&&gs(l,e,t,i,s,r,o);const d=ue(a,u);Ve(d,c,i,r,o)&&gs(d,e,t,i,s,r,o)}}const xc=["x","y","z"];function wc(a,e,t,i,s,r){Y.setBuffer(a._roots[e]);const o=_s(0,a,t,i,s,r);return Y.clearBuffer(),o}function _s(a,e,t,i,s,r){const{float32Array:o,uint16Array:c,uint32Array:h}=Y;let u=a*2;if(oe(u,c)){const n=le(a,h),l=ce(u,c);return ac(e,t,i,n,l,s,r)}else{const n=un(a,h),l=xc[n],g=i.direction[l]>=0;let v,m;g?(v=he(a),m=ue(a,h)):(v=ue(a,h),m=he(a));const y=Ve(v,o,i,s,r)?_s(v,e,t,i,s,r):null;if(y){const b=y.point[l];if(g?b<=o[m+n]:b>=o[m+n+3])return y}const x=Ve(m,o,i,s,r)?_s(m,e,t,i,s,r):null;return y&&x?y.distance<=x.distance?y:x:y||x||null}}const di=new f.Box3,ot=new ge,at=new ge,Et=new f.Matrix4,Mr=new te,pi=new te;function bc(a,e,t,i){Y.setBuffer(a._roots[e]);const s=vs(0,a,t,i);return Y.clearBuffer(),s}function vs(a,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:c}=Y;let h=a*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Mr.set(t.boundingBox.min,t.boundingBox.max,i),s=Mr),oe(h,o)){const p=e.geometry,n=p.index,l=p.attributes.position,d=t.index,g=t.attributes.position,v=le(a,c),m=ce(h,o);if(Et.copy(i).invert(),t.boundsTree)return Z(a,r,pi),pi.matrix.copy(Et),pi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>pi.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let w=v,x=m+v;w<x;w++)if(K(at,3*e.resolveTriangleIndex(w),n,l),at.needsUpdate=!0,y.intersectsTriangle(at))return!0;return!1}});for(let _=v,y=m+v;_<y;_++){const w=e.resolveTriangleIndex(_);K(ot,3*w,n,l),ot.a.applyMatrix4(Et),ot.b.applyMatrix4(Et),ot.c.applyMatrix4(Et),ot.needsUpdate=!0;for(let x=0,b=d.count;x<b;x+=3)if(K(at,x,d,g),at.needsUpdate=!0,ot.intersectsTriangle(at))return!0}}else{const p=a+8,n=c[a+6];return Z(p,r,di),!!(s.intersectsBox(di)&&vs(p,e,t,i,s)||(Z(n,r,di),s.intersectsBox(di)&&vs(n,e,t,i,s)))}}const mi=new f.Matrix4,Zi=new te,kt=new te,Ac=new f.Vector3,Tc=new f.Vector3,Sc=new f.Vector3,Mc=new f.Vector3;function Cc(a,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Zi.set(e.boundingBox.min,e.boundingBox.max,t),Zi.needsUpdate=!0;const c=a.geometry,h=c.attributes.position,u=c.index,p=e.attributes.position,n=e.index,l=fe.getPrimitive(),d=fe.getPrimitive();let g=Ac,v=Tc,m=null,_=null;s&&(m=Sc,_=Mc);let y=1/0,w=null,x=null;return mi.copy(t).invert(),kt.matrix.copy(mi),a.shapecast({boundsTraverseOrder:b=>Zi.distanceToBox(b),intersectsBounds:(b,T,M)=>M<y&&M<o?(T&&(kt.min.copy(b.min),kt.max.copy(b.max),kt.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree){const M=e.boundsTree;return M.shapecast({boundsTraverseOrder:P=>kt.distanceToBox(P),intersectsBounds:(P,C,I)=>I<y&&I<o,intersectsRange:(P,C)=>{for(let I=P,D=P+C;I<D;I++){const A=M.resolveTriangleIndex(I);K(d,3*A,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=b,L=b+T;S<L;S++){const R=a.resolveTriangleIndex(S);K(l,3*R,u,h),l.needsUpdate=!0;const k=l.distanceToTriangle(d,g,m);if(k<y&&(v.copy(g),_&&_.copy(m),y=k,w=S,x=I),k<r)return!0}}}})}else{const M=xt(e);for(let P=0,C=M;P<C;P++){K(d,3*P,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let I=b,D=b+T;I<D;I++){const A=a.resolveTriangleIndex(I);K(l,3*A,u,h),l.needsUpdate=!0;const S=l.distanceToTriangle(d,g,m);if(S<y&&(v.copy(g),_&&_.copy(m),y=S,w=I,x=P),S<r)return!0}}}}}),fe.releasePrimitive(l),fe.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=y,i.faceIndex=w,s&&(s.point?s.point.copy(_):s.point=_.clone(),s.point.applyMatrix4(mi),v.applyMatrix4(mi),s.distance=v.sub(s.point).length(),s.faceIndex=x),i)}function Dc(){return typeof SharedArrayBuffer<"u"}const Wt=new Y.constructor,bi=new Y.constructor,Fe=new Ls(()=>new f.Box3),lt=new f.Box3,ct=new f.Box3,Ki=new f.Box3,Xi=new f.Box3;let Ji=!1;function Pc(a,e,t,i){if(Ji)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Ji=!0;const s=a._roots,r=e._roots;let o,c=0,h=0;const u=new f.Matrix4().copy(t).invert();for(let p=0,n=s.length;p<n;p++){Wt.setBuffer(s[p]),h=0;const l=Fe.getPrimitive();Z(0,Wt.float32Array,l),l.applyMatrix4(u);for(let d=0,g=r.length;d<g&&(bi.setBuffer(r[p]),o=me(0,0,t,u,i,c,h,0,0,l),bi.clearBuffer(),h+=r[d].length,!o);d++);if(Fe.releasePrimitive(l),Wt.clearBuffer(),c+=s[p].length,o)break}return Ji=!1,o}function me(a,e,t,i,s,r=0,o=0,c=0,h=0,u=null,p=!1){let n,l;p?(n=bi,l=Wt):(n=Wt,l=bi);const d=n.float32Array,g=n.uint32Array,v=n.uint16Array,m=l.float32Array,_=l.uint32Array,y=l.uint16Array,w=a*2,x=e*2,b=oe(w,v),T=oe(x,y);let M=!1;if(T&&b)p?M=s(le(e,_),ce(e*2,y),le(a,g),ce(a*2,v),h,o+e,c,r+a):M=s(le(a,g),ce(a*2,v),le(e,_),ce(e*2,y),c,r+a,h,o+e);else if(T){const P=Fe.getPrimitive();Z(e,m,P),P.applyMatrix4(t);const C=he(a),I=ue(a,g);Z(C,d,lt),Z(I,d,ct);const D=P.intersectsBox(lt),A=P.intersectsBox(ct);M=D&&me(e,C,i,t,s,o,r,h,c+1,P,!p)||A&&me(e,I,i,t,s,o,r,h,c+1,P,!p),Fe.releasePrimitive(P)}else{const P=he(e),C=ue(e,_);Z(P,m,Ki),Z(C,m,Xi);const I=u.intersectsBox(Ki),D=u.intersectsBox(Xi);if(I&&D)M=me(a,P,t,i,s,r,o,c,h+1,u,p)||me(a,C,t,i,s,r,o,c,h+1,u,p);else if(I)if(b)M=me(a,P,t,i,s,r,o,c,h+1,u,p);else{const A=Fe.getPrimitive();A.copy(Ki).applyMatrix4(t);const S=he(a),L=ue(a,g);Z(S,d,lt),Z(L,d,ct);const R=A.intersectsBox(lt),k=A.intersectsBox(ct);M=R&&me(P,S,i,t,s,o,r,h,c+1,A,!p)||k&&me(P,L,i,t,s,o,r,h,c+1,A,!p),Fe.releasePrimitive(A)}else if(D)if(b)M=me(a,C,t,i,s,r,o,c,h+1,u,p);else{const A=Fe.getPrimitive();A.copy(Xi).applyMatrix4(t);const S=he(a),L=ue(a,g);Z(S,d,lt),Z(L,d,ct);const R=A.intersectsBox(lt),k=A.intersectsBox(ct);M=R&&me(C,S,i,t,s,o,r,h,c+1,A,!p)||k&&me(C,L,i,t,s,o,r,h,c+1,A,!p),Fe.releasePrimitive(A)}}return M}const gi=new te,Cr=new f.Box3,Lc={strategy:ln,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class Is{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,r=e._indirectBuffer,o=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(h=>h.slice()),index:o?o.array.slice():null,indirectBuffer:r?r.slice():null}:c={roots:s,index:o?o.array:null,indirectBuffer:r},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:r,indirectBuffer:o}=e,c=new Is(t,{...i,[Gi]:!0});if(c._roots=r,c._indirectBuffer=o||null,i.setIndex){const h=t.getIndex();if(h===null){const u=new f.BufferAttribute(e.index,1,!1);t.setIndex(u)}else h.array!==s&&(h.array.set(s),h.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Lc,[Gi]:!1},t),t.useSharedArrayBuffer&&!Dc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Gi]||(jl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new f.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?vc:nc)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),r=new Uint16Array(i);o(0);function o(c,h=0){const u=c*2,p=r[u+15]===Mi;if(p){const n=s[c+6],l=r[u+14];e(h,p,new Float32Array(i,c*4,6),n,l)}else{const n=c+Vt/4,l=s[c+6],d=s[c+7];e(h,p,new Float32Array(i,c*4,6),d)||(o(n,h+1),o(l,h+1))}}}raycast(e,t=f.FrontSide,i=0,s=1/0){const r=this._roots,o=this.geometry,c=[],h=t.isMaterial,u=Array.isArray(t),p=o.groups,n=h?t.side:t,l=this.indirect?yc:cc;for(let d=0,g=r.length;d<g;d++){const v=u?t[p[d].materialIndex].side:n,m=c.length;if(l(this,d,v,e,c,i,s),u){const _=p[d].materialIndex;for(let y=m,w=c.length;y<w;y++)c[y].face.materialIndex=_}}return c}raycastFirst(e,t=f.FrontSide,i=0,s=1/0){const r=this._roots,o=this.geometry,c=t.isMaterial,h=Array.isArray(t);let u=null;const p=o.groups,n=c?t.side:t,l=this.indirect?wc:uc;for(let d=0,g=r.length;d<g;d++){const v=h?t[p[d].materialIndex].side:n,m=l(this,d,v,e,i,s);m!=null&&(u==null||m.distance<u.distance)&&(u=m,h&&(m.face.materialIndex=p[d].materialIndex))}return u}intersectsGeometry(e,t){let i=!1;const s=this._roots,r=this.indirect?bc:fc;for(let o=0,c=s.length;o<c&&(i=r(this,o,e,t),!i);o++);return i}shapecast(e){const t=fe.getPrimitive(),i=this.indirect?lc:rc;let{boundsTraverseOrder:s,intersectsBounds:r,intersectsRange:o,intersectsTriangle:c}=e;if(o&&c){const n=o;o=(l,d,g,v,m)=>n(l,d,g,v,m)?!0:i(l,d,this,c,g,v,t)}else o||(c?o=(n,l,d,g)=>i(n,l,this,c,d,g,t):o=(n,l,d)=>d);let h=!1,u=0;const p=this._roots;for(let n=0,l=p.length;n<l;n++){const d=p[n];if(h=Jl(this,n,r,o,s,u),h)break;u+=d.byteLength}return fe.releasePrimitive(t),h}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:r}=i;const o=fe.getPrimitive(),c=this.geometry.index,h=this.geometry.attributes.position,u=this.indirect?g=>{const v=this.resolveTriangleIndex(g);K(o,v*3,c,h)}:g=>{K(o,g*3,c,h)},p=fe.getPrimitive(),n=e.geometry.index,l=e.geometry.attributes.position,d=e.indirect?g=>{const v=e.resolveTriangleIndex(g);K(p,v*3,n,l)}:g=>{K(p,g*3,n,l)};if(r){const g=(v,m,_,y,w,x,b,T)=>{for(let M=_,P=_+y;M<P;M++){d(M),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let C=v,I=v+m;C<I;C++)if(u(C),o.needsUpdate=!0,r(o,p,C,M,w,x,b,T))return!0}return!1};if(s){const v=s;s=function(m,_,y,w,x,b,T,M){return v(m,_,y,w,x,b,T,M)?!0:g(m,_,y,w,x,b,T,M)}}else s=g}return Pc(this,e,t,s)}intersectsBox(e,t){return gi.set(e.min,e.max,t),gi.needsUpdate=!0,this.shapecast({intersectsBounds:i=>gi.intersectsBox(i),intersectsTriangle:i=>gi.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},r=0,o=1/0){return(this.indirect?Cc:_c)(this,e,t,i,s,r,o)}closestPointToPoint(e,t={},i=0,s=1/0){return $l(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Z(0,new Float32Array(i),Cr),e.union(Cr)}),e}}class Ic{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}class Rc extends Ic{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:vt&&vt.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,r)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=u=>{r(new Error(`GenerateMeshBVHWorker: ${u.message}`))},e.onmessage=u=>{const{data:p}=u;if(p.error)r(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:n,position:l}=p,d=Is.deserialize(n,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,n.index)if(t.index)t.index.array=n.index;else{const v=new f.BufferAttribute(n.index,1,!1);t.setIndex(v)}g.setBoundingBox&&(t.boundingBox=d.getBoundingBox(new f.Box3)),i.onProgress&&i.onProgress(p.progress),s(d),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const o=t.index?t.index.array:null,c=t.attributes.position.array,h=[c];o&&h.push(o),e.postMessage({index:o,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},h.map(u=>u.buffer).filter(u=>typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer)))})}}class Ec{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new f.Matrix4,this.mouse=new f.Vector3,this.rotateStart=new f.Vector2,this.rotateEnd=new f.Vector2,this.rotateDelta=new f.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new Ye,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._text=document.createElement("div"),this._textTimer=0,this._update=()=>{this.lock||(this._textTimer&&(window.clearTimeout(this._textTimer),this._textTimer=0),this._textTimer=window.setTimeout(()=>{this._text.style.opacity="0"},800),this.camera.updateMatrix(),this.invRotMat.extractRotation(this.camera.matrix).invert(),this.axes.forEach(s=>{this.setAxisPosition(s)}),this.axes.sort((s,r)=>s.position.z>r.position.z?1:-1),this.drawLayers(!0),this._text.style.opacity="1",this._text.innerText=this.camera.position.distanceTo(this.orbit.target).toFixed(2)+" m")},this.updateMouseFromEvent=s=>{this.rect=this.domElement.getBoundingClientRect();const r=this.domElement.width/this.domElement.clientWidth,o=this.domElement.height/this.domElement.clientHeight,{left:c,top:h}=this.rect;this.mouse.set((s.clientX-c)*r,(s.clientY-h)*o,0)},this.updateSelectedAxisUnderMouse=()=>{this.selectedAxis=null,this.axes.forEach(s=>{this.mouse.distanceTo(s.position)<s.size&&(this.selectedAxis=s)})},this.onPointerDown=s=>{this.rotateStart.set(s.clientX,s.clientY),this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.orbitState=this.orbit.enabled,this.orbit.enabled=!1,window.addEventListener("pointermove",this.onDrag,!1),window.addEventListener("pointerup",this.onPointerUp,!1)},this.onPointerUp=()=>{this.domElement.style.backgroundColor="#FFF0",setTimeout(()=>this.isDragging=!1,0),this.domElement.classList.remove("dragging"),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1)},this.onPointerEnter=()=>{this.domElement.style.backgroundColor="#FFF3",this.rect=this.domElement.getBoundingClientRect()},this.onPointerMove=s=>{if(this.lock||this.isDragging)return;const r=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),r!==this.selectedAxis&&this.drawLayers()},this.onDrag=s=>{this.lock||(this.isDragging||this.domElement.classList.add("dragging"),this.isDragging=!0,this.selectedAxis=null,this.rotateEnd.set(s.clientX,s.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(.5),this.rotateStart.copy(this.rotateEnd),this.orbit.update())},this.onMouseClick=s=>{if(this.lock||(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.isDragging||!this.selectedAxis))return;this._animator&&cancelAnimationFrame(this._animator);const r=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const o=this.camera.position.distanceTo(this.orbit.target);r.multiplyScalar(o),this.selectedAxis.axis==="z"?r.setZ(this.orbit.target.z+o):this.selectedAxis.axis==="-z"?r.setZ(this.orbit.target.z-o):r.setZ(this.orbit.target.z);const c=500,h=performance.now(),u=1,p=this.selectedAxis.axis,n=()=>{const d=performance.now()-h,g=Math.min(d/c,u);if(this.camera.position.lerp(r,g),this.orbit.update(),g!==u){this._animator=window.requestAnimationFrame(n);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",p);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",p),n()},this.drawCircle=(s,r=10,o="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-r,s.y-r,r*2,r*2),this.context.fillStyle=o,this.context.fill(),this.context.closePath())},this.drawLine=(s,r,o=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(r.x,r.y),this.context.lineWidth=o,this.context.strokeStyle=c,this.context.stroke(),this.context.closePath())},this.drawLayers=(s=!1)=>{this.context&&(s&&this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.axes.forEach(r=>{const o=this.selectedAxis===r,c=r.position.z>=-.01?r.color[0]:r.color[1];if(r.line&&this.drawLine(this.center,r.position,r.line,c),this.drawCircle(r.position,r.size,o?"#0066ff":c),r.label){const h=r.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,h+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(r.label,r.position.x,r.position.y)}}))},this.setAxisPosition=s=>{const r=s.direction.clone().applyMatrix4(this.invRotMat),o=s.size;s.position.set(r.x*(this.center.x-o/2-this.options.padding)+this.center.x,this.center.y-r.y*(this.center.y-o/2-this.options.padding),r.z)};const i={offset:new f.Vector2,size:90,padding:8,bubbleSizePrimary:8,bubbleSizeSecondary:6,lineWidth:2,fontSize:11,fontFamily:"arial",fontWeight:"normal",fontColor:"#fff",className:"orbit-controls-gizmo",colors:{x:["#f35f5f","#902525"],y:["#78da2f","#71ae45"],z:["#1d92fa","#d0d1d1"]}};this.options={...i,...t},this.orbit=e,this.camera=e.object,this.center=new f.Vector3(this.options.size/2,this.options.size/2,0),this.axes=this.createAxes(),this.domElement=this.createCanvas(this.options),this.orbit.addEventListener("change",this._update),this._text.style.cssText=`
|
|
3732
3732
|
transition: all 0.8s ease-in-out;
|
|
3733
3733
|
color: rgb(68, 78, 105);
|
|
3734
3734
|
position: absolute;
|
|
@@ -3758,7 +3758,7 @@ ${t.name}`)}break}}}}else r.texture_lod=0}};ae=new WeakMap,Me=new WeakMap,Ai=new
|
|
|
3758
3758
|
`+_.fragmentShader.slice(y-1,-1)+`
|
|
3759
3759
|
vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
3760
3760
|
gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);
|
|
3761
|
-
}`,_.uniforms.previousShadowMap=this.previousShadowMap,_.uniforms.averagingWindow=this.averagingWindow},this._pushShadowHistory("init")}_now(){try{if(typeof performance<"u"&&typeof performance.now=="function")return performance.now()}catch{}return Date.now()}_getMeshMaterialLabel(){var t;const e=(t=this.shadowCatcherMesh)==null?void 0:t.material;return e?e===this.shadowCatcherMaterial?"shadowCatcherMaterial":e===this.targetMat?"targetMat":e.type||"unknown":"none"}_getTextureLabel(e){var t,i;return e?(t=this.progressiveLightMap1)!=null&&t.texture&&e===this.progressiveLightMap1.texture?"progressiveLightMap1":(i=this.progressiveLightMap2)!=null&&i.texture&&e===this.progressiveLightMap2.texture?"progressiveLightMap2":e.uuid?`external:${e.uuid}`:"external":"none"}_pushShadowHistory(e,t={}){const i=this.shadowCatcherMaterial,s={time:this._now(),reason:e,framesDone:this.framesDone,buffer1Active:this.buffer1Active,isRendering:this.isRendering,displaySuppressed:this._displaySuppressed,displayDelayRemaining:this._displayDelayRemaining,displayMap:this._getTextureLabel(i==null?void 0:i.map),alphaTest:typeof(i==null?void 0:i.alphaTest)=="number"?i.alphaTest:0,opacity:typeof(i==null?void 0:i.opacity)=="number"?i.opacity:0,meshMaterial:this._getMeshMaterialLabel(),...t};this.shadowMapHistory.push(s);const r=180;this.shadowMapHistory.length>r&&this.shadowMapHistory.splice(0,this.shadowMapHistory.length-r)}_suppressDisplay(e,t){const i=this.shadowCatcherMaterial;if(!i)return;this._displaySuppressed||(this._displayRestoreOpacity=typeof i.opacity=="number"?i.opacity:1),this._displaySuppressed=!0;const s=t===void 0?this.params.displayDelayFrames:Math.max(0,Math.floor(t));this._displayDelayRemaining=Math.max(this._displayDelayRemaining,s),typeof i.opacity=="number"&&(i.opacity=0),this._pushShadowHistory(`display_suppress:${e}`)}_tickDisplaySuppression(){if(!this._displaySuppressed||(this._displayDelayRemaining>0&&(this._displayDelayRemaining-=1),this._displayDelayRemaining>0))return;const e=this.shadowCatcherMaterial;e&&typeof e.opacity=="number"&&(e.opacity=this._displayRestoreOpacity),this._displaySuppressed=!1,this._pushShadowHistory("display_restore")}renderOnRenderTargets(e){this.prepare(),this.averagingWindow.value=Math.max(this.framesDone+1,1);const t=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,i=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1;this.renderer.setRenderTarget(t),this.previousShadowMap.value=i.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,e),this.finish(),this.shadowCatcherMaterial.map=t.texture,this._pushShadowHistory("renderOnRenderTargets",{writeMap:this._getTextureLabel(t.texture),readMap:this._getTextureLabel(i.texture)}),this.renderer.setRenderTarget(null)}showDebugHelpers(e){if(!this.debugHelpersGroup.children.length){const t=new f.Mesh(new f.PlaneGeometry(2,2),new f.MeshBasicMaterial({map:this.progressiveLightMap1.texture,side:f.DoubleSide}));this.isZUp?t.position.z=this.params.size/2:t.position.y=this.params.size/2;for(const r of this.dirLights){const o=new f.DirectionalLightHelper(r);this.dirLightsHelpers.push(o)}const i=this.isZUp?new f.Vector3(0,0,1):new f.Vector3(0,1,0),s=new f.PlaneHelper(new f.Plane(i,.001),this.params.size,16776960);this.debugHelpersGroup.add(t,s,...this.dirLightsHelpers)}e?(this.progShadowGrp.add(this.debugHelpersGroup),this.dirLightsHelpers.forEach(t=>{t.update()})):this.progShadowGrp.remove(this.debugHelpersGroup)}randomiseLights(){const e=this.lightOrigin.position.length();for(let t=0;t<this.dirLights.length;t++){if(Math.random()>this.params.ambientWeight)this.dirLights[t].position.set(this.lightOrigin.position.x,this.lightOrigin.position.y+f.MathUtils.randFloatSpread(this.params.lightRadius),this.lightOrigin.position.z+f.MathUtils.randFloatSpread(this.params.lightRadius));else{const i=Math.acos(2*Math.random()-1)-1.570795,s=2*3.14159*Math.random();this.isZUp?this.dirLights[t].position.set(Math.cos(i)*Math.cos(s)*e,Math.cos(i)*Math.sin(s)*e,Math.abs(Math.sin(i)*e)):this.dirLights[t].position.set(Math.cos(i)*Math.cos(s)*e,Math.abs(Math.cos(i)*Math.sin(s)*e),Math.sin(i)*e)}this.params.debugHelpers&&this.dirLightsHelpers[t].update()}}async recalculate(){this.params.enabled&&(this._suppressDisplay("recalculate"),this._pushShadowHistory("recalculate"),this.clear())}prepare(){this.lights.forEach(t=>{t.object.intensity=0}),this.meshes.forEach(t=>{t.object.material=this.discardMaterial}),this.autoHiddenObjects.length=0;const e=t=>this.objectsToShowAncestors.has(t);this.scene.traverse(t=>{t!==this.scene&&(this.isExcludedObject(t)||e(t)||t.isLight||t.isCamera||t.visible&&(this.autoHiddenObjects.push({object:t,visible:t.visible}),t.visible=!1))}),this.lightGroup.visible=!0,this.shadowCatcherMesh.material=this.targetMat,this.params.debugHelpers&&this.showDebugHelpers(!1)}finish(){this.lights.forEach(e=>{e.object.intensity=e.intensity}),this.meshes.forEach(e=>{e.object.material=e.material}),this.autoHiddenObjects.forEach(e=>{e.object.visible=e.visible}),this.autoHiddenObjects.length=0,this.lightGroup.visible=!1,this.shadowCatcherMesh.material=this.shadowCatcherMaterial,this.params.debugHelpers&&this.showDebugHelpers(!0)}clear(){this._suppressDisplay("clear"),this._pushShadowHistory("clear_begin"),this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.buffer1Active=!1,this.shadowCatcherMaterial.alphaTest=0;try{this.shadowCatcherMesh.material.alphaTest=0}catch{}this.framesDone=0,this.fixedCamera=null,this.isRendering=!1,this.updateShadowObjectsList(),this._pushShadowHistory("clear_end")}updateShadowObjectsList(){this.lights.length=0,this.meshes.length=0,this.objectsToShow.length=0,this.objectsToShowSet.clear(),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.scene.traverse(e=>{if(e!==this.scene){if(this.isExcludedObject(e)){this.addObjectToShow(e);return}if(e===this.progShadowGrp||e===this.lightGroup||e===this.lightOrigin){this.addObjectToShow(e);return}if(e===this.shadowCatcherMesh){this.addObjectToShow(e);return}if(e.isLight&&e.parent!==this.lightGroup){this.lights.push({object:e,intensity:e.intensity});return}e.isGoods||e.isTransformControls||e.geometry&&e!==this.shadowCatcherMesh&&e.castShadow&&(this.meshes.push({object:e,material:e.material}),this.addObjectToShow(e))}}),this.rebuildObjectsToShowAncestors()}addObjectToShow(e){e&&(this.objectsToShowSet.has(e)||(this.objectsToShow.push({object:e,visible:e.visible}),this.objectsToShowSet.add(e)))}rebuildObjectsToShowAncestors(){this.objectsToShowAncestors.clear();const e=t=>{let i=t;for(;i&&!this.objectsToShowAncestors.has(i);)this.objectsToShowAncestors.add(i),i=i.parent};this.objectsToShow.forEach(({object:t})=>{e(t)})}isExcludedObject(e){const t=e;return!!(t.isCSS2DObject||t.isCSS3DObject||t.isHelper||typeof e.type=="string"&&e.type.endsWith("Helper")||typeof e.name=="string"&&e.name.toLowerCase().includes("helper"))}update(e){!this.params||!this.shadowCatcherMesh||!this.progressiveLightMap1||!this.progressiveLightMap2||!this.params.enabled||this.framesDone>=this.params.frames||this.params.paused||!this.shadowCatcherMesh.visible||!this.progShadowGrp.visible||(this.framesDone===0&&(this.fixedCamera=e.clone(),this.isRendering=!0),this.shadowCatcherMaterial.alphaTest=f.MathUtils.clamp(f.MathUtils.mapLinear(this.framesDone,2,this.params.frames-1,0,this.params.alphaTest),0,1),this.renderOnRenderTargets(this.fixedCamera||e),this.randomiseLights(),this.progress=f.MathUtils.mapLinear(this.framesDone,0,this.params.frames-1,0,100),this.framesDone++,this._tickDisplaySuppression(),this.framesDone>=this.params.frames&&(this._displaySuppressed&&(this._displayDelayRemaining=0,this._tickDisplaySuppression()),this.fixedCamera=null,this.isRendering=!1))}destroy(){this.scene&&this.progShadowGrp&&this.scene.remove(this.progShadowGrp),this.progressiveLightMap1&&(this.progressiveLightMap1.dispose(),this.progressiveLightMap1=null),this.progressiveLightMap2&&(this.progressiveLightMap2.dispose(),this.progressiveLightMap2=null),this.shadowCatcherMaterial&&(this.shadowCatcherMaterial.dispose(),this.shadowCatcherMaterial=null),this.targetMat&&(this.targetMat.dispose(),this.targetMat=null),this.discardMaterial&&(this.discardMaterial.dispose(),this.discardMaterial=null),this.shadowCatcherMesh&&(this.shadowCatcherMesh.geometry&&this.shadowCatcherMesh.geometry.dispose(),this.shadowCatcherMesh=null),this.dirLights.forEach(e=>{e.parent&&e.parent.remove(e);const t=e;t.dispose&&typeof t.dispose=="function"&&t.dispose()}),this.dirLights=[],this.dirLightsHelpers.forEach(e=>{e.parent&&e.parent.remove(e);const t=e;t.dispose&&typeof t.dispose=="function"&&t.dispose()}),this.dirLightsHelpers=[],this.debugHelpersGroup&&(this.debugHelpersGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this.debugHelpersGroup.clear(),this.debugHelpersGroup=null),this.progShadowGrp&&(this.progShadowGrp.clear(),this.progShadowGrp=null),this.lightGroup&&(this.lightGroup.clear(),this.lightGroup=null),this.lightOrigin&&(this.lightOrigin.clear(),this.lightOrigin=null),this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.shadowMapHistory.length=0,this._displaySuppressed=!1,this._displayDelayRemaining=0,this._displayRestoreOpacity=1,this.scene=null,this.renderer=null,this.fixedCamera=null,this.clearColor=null,this.previousShadowMap=null,this.averagingWindow=null,this.params=null}}function pn(a={},e,t,i=s=>{}){const s=class extends f.ShaderMaterial{constructor(r={}){const o=Object.entries(a);super({uniforms:o.reduce((c,[h,u])=>{const p=f.UniformsUtils.clone({[h]:{value:u}});return{...c,...p}},{}),vertexShader:e,fragmentShader:t}),o.forEach(([c])=>Object.defineProperty(this,c,{get:()=>this.uniforms[c].value,set:h=>this.uniforms[c].value=h})),Object.assign(this,r),i&&i(this)}};return s.key=f.MathUtils.generateUUID(),s}const Fc=pn({transparent:!0,color:new f.Color(0,0,0),alphaTest:0,opacity:1,map:null,depthWrite:!1,toneMapped:!1,blend:2},`varying vec2 vUv;
|
|
3761
|
+
}`,_.uniforms.previousShadowMap=this.previousShadowMap,_.uniforms.averagingWindow=this.averagingWindow},this._pushShadowHistory("init")}_now(){try{if(typeof performance<"u"&&typeof performance.now=="function")return performance.now()}catch{}return Date.now()}_getMeshMaterialLabel(){var t;const e=(t=this.shadowCatcherMesh)==null?void 0:t.material;return e?e===this.shadowCatcherMaterial?"shadowCatcherMaterial":e===this.targetMat?"targetMat":e.type||"unknown":"none"}_getTextureLabel(e){var t,i;return e?(t=this.progressiveLightMap1)!=null&&t.texture&&e===this.progressiveLightMap1.texture?"progressiveLightMap1":(i=this.progressiveLightMap2)!=null&&i.texture&&e===this.progressiveLightMap2.texture?"progressiveLightMap2":e.uuid?`external:${e.uuid}`:"external":"none"}_pushShadowHistory(e,t={}){const i=this.shadowCatcherMaterial,s={time:this._now(),reason:e,framesDone:this.framesDone,buffer1Active:this.buffer1Active,isRendering:this.isRendering,displaySuppressed:this._displaySuppressed,displayDelayRemaining:this._displayDelayRemaining,displayMap:this._getTextureLabel(i==null?void 0:i.map),alphaTest:typeof(i==null?void 0:i.alphaTest)=="number"?i.alphaTest:0,opacity:typeof(i==null?void 0:i.opacity)=="number"?i.opacity:0,meshMaterial:this._getMeshMaterialLabel(),...t};this.shadowMapHistory.push(s);const r=180;this.shadowMapHistory.length>r&&this.shadowMapHistory.splice(0,this.shadowMapHistory.length-r)}_suppressDisplay(e,t){const i=this.shadowCatcherMaterial;if(!i)return;this._displaySuppressed||(this._displayRestoreOpacity=typeof i.opacity=="number"?i.opacity:1),this._displaySuppressed=!0;const s=t===void 0?this.params.displayDelayFrames:Math.max(0,Math.floor(t));this._displayDelayRemaining=Math.max(this._displayDelayRemaining,s),typeof i.opacity=="number"&&(i.opacity=0),this._pushShadowHistory(`display_suppress:${e}`)}_tickDisplaySuppression(){if(!this._displaySuppressed||(this._displayDelayRemaining>0&&(this._displayDelayRemaining-=1),this._displayDelayRemaining>0))return;const e=this.shadowCatcherMaterial;e&&typeof e.opacity=="number"&&(e.opacity=this._displayRestoreOpacity),this._displaySuppressed=!1,this._pushShadowHistory("display_restore")}renderOnRenderTargets(e){this.prepare(),this.averagingWindow.value=Math.max(this.framesDone+1,1);const t=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,i=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1;this.renderer.setRenderTarget(t),this.previousShadowMap.value=i.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,e),this.finish(),this.shadowCatcherMaterial.map=t.texture,this._pushShadowHistory("renderOnRenderTargets",{writeMap:this._getTextureLabel(t.texture),readMap:this._getTextureLabel(i.texture)}),this.renderer.setRenderTarget(null)}showDebugHelpers(e){if(!this.debugHelpersGroup.children.length){const t=new f.Mesh(new f.PlaneGeometry(2,2),new f.MeshBasicMaterial({map:this.progressiveLightMap1.texture,side:f.DoubleSide}));this.isZUp?t.position.z=this.params.size/2:t.position.y=this.params.size/2;for(const r of this.dirLights){const o=new f.DirectionalLightHelper(r);this.dirLightsHelpers.push(o)}const i=this.isZUp?new f.Vector3(0,0,1):new f.Vector3(0,1,0),s=new f.PlaneHelper(new f.Plane(i,.001),this.params.size,16776960);this.debugHelpersGroup.add(t,s,...this.dirLightsHelpers)}e?(this.progShadowGrp.add(this.debugHelpersGroup),this.dirLightsHelpers.forEach(t=>{t.update()})):this.progShadowGrp.remove(this.debugHelpersGroup)}randomiseLights(){const e=this.lightOrigin.position.length();for(let t=0;t<this.dirLights.length;t++){if(Math.random()>this.params.ambientWeight)this.dirLights[t].position.set(this.lightOrigin.position.x,this.lightOrigin.position.y+f.MathUtils.randFloatSpread(this.params.lightRadius),this.lightOrigin.position.z+f.MathUtils.randFloatSpread(this.params.lightRadius));else{const i=Math.acos(2*Math.random()-1)-1.570795,s=2*3.14159*Math.random();this.isZUp?this.dirLights[t].position.set(Math.cos(i)*Math.cos(s)*e,Math.cos(i)*Math.sin(s)*e,Math.abs(Math.sin(i)*e)):this.dirLights[t].position.set(Math.cos(i)*Math.cos(s)*e,Math.abs(Math.cos(i)*Math.sin(s)*e),Math.sin(i)*e)}this.params.debugHelpers&&this.dirLightsHelpers[t].update()}}async recalculate(){this.params.enabled&&(this._suppressDisplay("recalculate"),this._pushShadowHistory("recalculate"),this.clear())}prepare(){this.lights.forEach(t=>{t.object.intensity=0}),this.meshes.forEach(t=>{t.object.material=this.discardMaterial}),this.autoHiddenObjects.length=0;const e=t=>this.objectsToShowAncestors.has(t);this.scene.traverse(t=>{t!==this.scene&&(this.isExcludedObject(t)||e(t)||t.isLight||t.isCamera||t.visible&&(this.autoHiddenObjects.push({object:t,visible:t.visible}),t.visible=!1))}),this.lightGroup.visible=!0,this.shadowCatcherMesh.material=this.targetMat,this.params.debugHelpers&&this.showDebugHelpers(!1)}finish(){this.lights.forEach(e=>{e.object.intensity=e.intensity}),this.meshes.forEach(e=>{e.object.material=e.material}),this.autoHiddenObjects.forEach(e=>{e.object.visible=e.visible}),this.autoHiddenObjects.length=0,this.lightGroup.visible=!1,this.shadowCatcherMesh.material=this.shadowCatcherMaterial,this.params.debugHelpers&&this.showDebugHelpers(!0)}clear(){this._suppressDisplay("clear"),this._pushShadowHistory("clear_begin"),this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.buffer1Active=!1,this.shadowCatcherMaterial.alphaTest=0;try{this.shadowCatcherMesh.material.alphaTest=0}catch{}this.framesDone=0,this.fixedCamera=null,this.isRendering=!1,this.updateShadowObjectsList(),this._pushShadowHistory("clear_end")}updateShadowObjectsList(){this.lights.length=0,this.meshes.length=0,this.objectsToShow.length=0,this.objectsToShowSet.clear(),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.scene.traverse(e=>{if(e!==this.scene){if(this.isExcludedObject(e)){this.addObjectToShow(e);return}if(e===this.progShadowGrp||e===this.lightGroup||e===this.lightOrigin){this.addObjectToShow(e);return}if(e===this.shadowCatcherMesh){this.addObjectToShow(e);return}if(e.isLight&&e.parent!==this.lightGroup){this.lights.push({object:e,intensity:e.intensity});return}e.isGoods||e.isTransformControls||e.geometry&&e!==this.shadowCatcherMesh&&e.castShadow&&(this.meshes.push({object:e,material:e.material}),this.addObjectToShow(e))}}),this.rebuildObjectsToShowAncestors()}addObjectToShow(e){e&&(this.objectsToShowSet.has(e)||(this.objectsToShow.push({object:e,visible:e.visible}),this.objectsToShowSet.add(e)))}rebuildObjectsToShowAncestors(){this.objectsToShowAncestors.clear();const e=t=>{let i=t;for(;i&&!this.objectsToShowAncestors.has(i);)this.objectsToShowAncestors.add(i),i=i.parent};this.objectsToShow.forEach(({object:t})=>{e(t)})}isExcludedObject(e){const t=e;return!!(t.isCSS2DObject||t.isCSS3DObject)}update(e){!this.params||!this.shadowCatcherMesh||!this.progressiveLightMap1||!this.progressiveLightMap2||!this.params.enabled||this.framesDone>=this.params.frames||this.params.paused||!this.shadowCatcherMesh.visible||!this.progShadowGrp.visible||(this.framesDone===0&&(this.fixedCamera=e.clone(),this.isRendering=!0),this.shadowCatcherMaterial.alphaTest=f.MathUtils.clamp(f.MathUtils.mapLinear(this.framesDone,2,this.params.frames-1,0,this.params.alphaTest),0,1),this.renderOnRenderTargets(this.fixedCamera||e),this.randomiseLights(),this.progress=f.MathUtils.mapLinear(this.framesDone,0,this.params.frames-1,0,100),this.framesDone++,this._tickDisplaySuppression(),this.framesDone>=this.params.frames&&(this._displaySuppressed&&(this._displayDelayRemaining=0,this._tickDisplaySuppression()),this.fixedCamera=null,this.isRendering=!1))}destroy(){this.scene&&this.progShadowGrp&&this.scene.remove(this.progShadowGrp),this.progressiveLightMap1&&(this.progressiveLightMap1.dispose(),this.progressiveLightMap1=null),this.progressiveLightMap2&&(this.progressiveLightMap2.dispose(),this.progressiveLightMap2=null),this.shadowCatcherMaterial&&(this.shadowCatcherMaterial.dispose(),this.shadowCatcherMaterial=null),this.targetMat&&(this.targetMat.dispose(),this.targetMat=null),this.discardMaterial&&(this.discardMaterial.dispose(),this.discardMaterial=null),this.shadowCatcherMesh&&(this.shadowCatcherMesh.geometry&&this.shadowCatcherMesh.geometry.dispose(),this.shadowCatcherMesh=null),this.dirLights.forEach(e=>{e.parent&&e.parent.remove(e);const t=e;t.dispose&&typeof t.dispose=="function"&&t.dispose()}),this.dirLights=[],this.dirLightsHelpers.forEach(e=>{e.parent&&e.parent.remove(e);const t=e;t.dispose&&typeof t.dispose=="function"&&t.dispose()}),this.dirLightsHelpers=[],this.debugHelpersGroup&&(this.debugHelpersGroup.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this.debugHelpersGroup.clear(),this.debugHelpersGroup=null),this.progShadowGrp&&(this.progShadowGrp.clear(),this.progShadowGrp=null),this.lightGroup&&(this.lightGroup.clear(),this.lightGroup=null),this.lightOrigin&&(this.lightOrigin.clear(),this.lightOrigin=null),this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.shadowMapHistory.length=0,this._displaySuppressed=!1,this._displayDelayRemaining=0,this._displayRestoreOpacity=1,this.scene=null,this.renderer=null,this.fixedCamera=null,this.clearColor=null,this.previousShadowMap=null,this.averagingWindow=null,this.params=null}}function pn(a={},e,t,i=s=>{}){const s=class extends f.ShaderMaterial{constructor(r={}){const o=Object.entries(a);super({uniforms:o.reduce((c,[h,u])=>{const p=f.UniformsUtils.clone({[h]:{value:u}});return{...c,...p}},{}),vertexShader:e,fragmentShader:t}),o.forEach(([c])=>Object.defineProperty(this,c,{get:()=>this.uniforms[c].value,set:h=>this.uniforms[c].value=h})),Object.assign(this,r),i&&i(this)}};return s.key=f.MathUtils.generateUUID(),s}const Fc=pn({transparent:!0,color:new f.Color(0,0,0),alphaTest:0,opacity:1,map:null,depthWrite:!1,toneMapped:!1,blend:2},`varying vec2 vUv;
|
|
3762
3762
|
void main() {
|
|
3763
3763
|
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);
|
|
3764
3764
|
vUv = uv;
|
|
@@ -3901,7 +3901,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3901
3901
|
`}).join("")}
|
|
3902
3902
|
gl_FragColor = vec4( result, 1.0 );
|
|
3903
3903
|
}
|
|
3904
|
-
`})}}class Uc{constructor(e,t,i,s){this.params={inside:!1,thickness:30,color:new V.Color("#e91e63")},this._selectionLayer=31,this._box=new V.Box3,this._sphere=new V.Sphere,this.renderer=e,this.scene=t,this.camera=i,(s==null?void 0:s.inside)!==void 0&&(this.params.inside=s.inside),(s==null?void 0:s.thickness)!==void 0&&(this.params.thickness=s.thickness),(s==null?void 0:s.color)!==void 0&&(this.params.color=new V.Color(s.color)),this.seedMaterial=new Dr,this.seedMaterial.side=V.DoubleSide,this.seedModelMaterial=new Dr,this.seedModelMaterial.side=V.DoubleSide,this.maskMaterial=new V.MeshBasicMaterial({color:16777215,side:V.DoubleSide}),this.maskMaterial.morphTargets=!0,this.targets=[new V.WebGLRenderTarget(1,1,{format:V.RGBAFormat,type:V.FloatType,minFilter:V.NearestFilter,magFilter:V.NearestFilter}),new V.WebGLRenderTarget(1,1,{format:V.RGBAFormat,type:V.FloatType,minFilter:V.NearestFilter,magFilter:V.NearestFilter})],this.masks=[new V.WebGLRenderTarget(1,1,{format:V.RedFormat,type:V.UnsignedByteType,minFilter:V.LinearFilter,magFilter:V.LinearFilter,wrapS:V.ClampToEdgeWrapping,wrapT:V.ClampToEdgeWrapping}),new V.WebGLRenderTarget(1,1,{format:V.RedFormat,type:V.UnsignedByteType,minFilter:V.LinearFilter,magFilter:V.LinearFilter,wrapS:V.ClampToEdgeWrapping,wrapT:V.ClampToEdgeWrapping})],this.effectQuad=new jt.FullScreenQuad(new Vc),this.jfaQuad=new jt.FullScreenQuad(new Wc),this.seedQuad=new jt.FullScreenQuad(this.seedMaterial),this.expandQuad=new jt.FullScreenQuad(new zc),this.setSize(window.innerWidth,window.innerHeight)}setSize(e,t){const i=this.renderer.getPixelRatio(),s=Math.floor(e*i),r=Math.floor(t*i);this.targets[0].setSize(s,r),this.targets[1].setSize(s,r)}render(e){const t=this.renderer,i=this.scene,s=this.camera,r=this.params;let o=!1;const c=s.layers.mask;if(e){const
|
|
3904
|
+
`})}}class Uc{constructor(e,t,i,s){this.params={inside:!1,thickness:30,color:new V.Color("#e91e63")},this._selectionLayer=31,this._box=new V.Box3,this._sphere=new V.Sphere,this.renderer=e,this.scene=t,this.camera=i,(s==null?void 0:s.inside)!==void 0&&(this.params.inside=s.inside),(s==null?void 0:s.thickness)!==void 0&&(this.params.thickness=s.thickness),(s==null?void 0:s.color)!==void 0&&(this.params.color=new V.Color(s.color)),this.seedMaterial=new Dr,this.seedMaterial.side=V.DoubleSide,this.seedModelMaterial=new Dr,this.seedModelMaterial.side=V.DoubleSide,this.maskMaterial=new V.MeshBasicMaterial({color:16777215,side:V.DoubleSide}),this.maskMaterial.morphTargets=!0,this.targets=[new V.WebGLRenderTarget(1,1,{format:V.RGBAFormat,type:V.FloatType,minFilter:V.NearestFilter,magFilter:V.NearestFilter}),new V.WebGLRenderTarget(1,1,{format:V.RGBAFormat,type:V.FloatType,minFilter:V.NearestFilter,magFilter:V.NearestFilter})],this.masks=[new V.WebGLRenderTarget(1,1,{format:V.RedFormat,type:V.UnsignedByteType,minFilter:V.LinearFilter,magFilter:V.LinearFilter,wrapS:V.ClampToEdgeWrapping,wrapT:V.ClampToEdgeWrapping}),new V.WebGLRenderTarget(1,1,{format:V.RedFormat,type:V.UnsignedByteType,minFilter:V.LinearFilter,magFilter:V.LinearFilter,wrapS:V.ClampToEdgeWrapping,wrapT:V.ClampToEdgeWrapping})],this.effectQuad=new jt.FullScreenQuad(new Vc),this.jfaQuad=new jt.FullScreenQuad(new Wc),this.seedQuad=new jt.FullScreenQuad(this.seedMaterial),this.expandQuad=new jt.FullScreenQuad(new zc),this.setSize(window.innerWidth,window.innerHeight)}setSize(e,t){const i=this.renderer.getPixelRatio(),s=Math.floor(e*i),r=Math.floor(t*i);this.targets[0].setSize(s,r),this.targets[1].setSize(s,r)}render(e){const t=this.renderer,i=this.scene,s=this.camera,r=this.params;let o=!1;const c=s.layers.mask;if(e){const P=Array.isArray(e)?e:[e];P.length>0&&(o=!0,this._box.makeEmpty(),P.forEach(C=>{if(C)try{this._box.expandByObject(C),C.traverse(I=>{I.layers.enable(this._selectionLayer)})}catch(I){console.log("eee",I)}}),this._box.getBoundingSphere(this._sphere),s.layers.set(this._selectionLayer))}else this._box.setFromObject(i).getBoundingSphere(this._sphere);this.masks[0].setSize(this.targets[0].width,this.targets[0].height),this.masks[1].setSize(this.masks[0].width,this.masks[0].height),i.overrideMaterial=this.maskMaterial,t.setClearColor(0,0),t.setRenderTarget(this.masks[0]),t.clear(),t.render(i,s),i.overrideMaterial=null,t.setRenderTarget(null);for(let P=0;P<4;P++)this.expandQuad.material.source=this.masks[0].texture,t.setRenderTarget(this.masks[1]),this.expandQuad.render(t),t.setRenderTarget(null),this.masks.reverse();this.masks.reverse(),s.updateMatrixWorld();const h=this._sphere.center.clone();h.applyMatrix4(s.matrixWorldInverse);const u=h.z>-this._sphere.radius-s.near;h.x+=this._sphere.radius,h.y+=this._sphere.radius,h.applyMatrix4(s.projectionMatrix);const p=this._sphere.center.clone();p.project(s).multiplyScalar(.5),p.x+=.5,p.y+=.5,p.z=0,h.multiplyScalar(.5),h.x+=.5,h.y+=.5,h.z=0;let{width:n,height:l}=this.targets[0];n/=t.getPixelRatio(),l/=t.getPixelRatio();const d=r.thickness+20,g=Math.max(Math.abs(p.x-h.x)*n,Math.abs(p.y-h.y)*l)*1.5+d;p.x*=n,p.y*=l;const v=p.x-g,m=p.y-g,_=g*2,y=g*2;u||_>=n||y>=l?t.setScissorTest(!1):(t.setScissorTest(!0),t.setScissor(v,m,_,y)),t.setRenderTarget(this.targets[0]),this.seedQuad.material.depthWrite=!1,this.seedQuad.render(t),i.overrideMaterial=this.seedModelMaterial,this.seedModelMaterial.negative=!0,t.autoClear=!1,t.render(i,s),t.autoClear=!0,i.overrideMaterial=null,t.setRenderTarget(null);let w=Math.min(Math.max(this.targets[0].width,this.targets[0].height),r.thickness);for(;this.jfaQuad.material.step=w,this.jfaQuad.material.source=this.targets[0].texture,this.jfaQuad.material.mask=this.masks[1].texture,t.setRenderTarget(this.targets[1]),this.jfaQuad.render(t),t.setRenderTarget(null),this.targets.reverse(),!(w<=1);)w=Math.ceil(w*.5);const x=t.autoClear;t.autoClear=!1;const b=this.effectQuad.material;b.map=this.targets[0].texture;const T=this.targets[0].texture.minFilter,M=this.targets[0].texture.magFilter;this.targets[0].texture.minFilter=V.LinearFilter,this.targets[0].texture.magFilter=V.LinearFilter,this.targets[0].texture.needsUpdate=!0,b.mask=this.masks[1].texture,b.thickness=r.thickness,b.inside=r.inside,b.color.set(r.color),b.transparent=!0,b.blending=V.NormalBlending,b.depthTest=!1,b.depthWrite=!1,this.effectQuad.render(t),this.targets[0].texture.minFilter=T,this.targets[0].texture.magFilter=M,this.targets[0].texture.needsUpdate=!0,t.autoClear=x,t.setScissorTest(!1),o&&e&&((Array.isArray(e)?e:[e]).forEach(C=>{C&&C.traverse(I=>{I.layers.disable(this._selectionLayer)})}),s.layers.mask=c)}}class Hc extends f.Mesh{constructor(e=200,t=20,i=.8){const s=new f.PlaneGeometry(e,e),r=new f.ShaderMaterial({side:f.DoubleSide,transparent:!0,depthWrite:!1,uniforms:{uColor:{value:new f.Color(13619165)},uSize:{value:1},uDistance:{value:e/2},uOpacity:{value:i}},vertexShader:`
|
|
3905
3905
|
varying vec3 vPos;
|
|
3906
3906
|
void main() {
|
|
3907
3907
|
vPos = position;
|
|
@@ -3935,7 +3935,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3935
3935
|
// Combine
|
|
3936
3936
|
gl_FragColor = vec4(uColor, alpha * fade * uOpacity);
|
|
3937
3937
|
}
|
|
3938
|
-
`});super(s,r),this.position.z=-.02}}const Gc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",Nc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",Qc="https://cdn2.seer-group.com/libs/fonts.type.json",jc=new Mn.Font(Qc);class ys{constructor(e){var i;this._props=e,this.name="",this._defaults={color:"",metalness:0,roughness:0,envMapIntensity:1},this.color="",this.metalness=0,this.roughness=0,this.envMapIntensity=1,this.name=this._props.name;const t=this.material;t&&(this.color=this._defaults.color="#"+((i=t.color)==null?void 0:i.getHexString()),this.metalness=this._defaults.metalness=t.metalness??0,this.roughness=this._defaults.roughness=t.roughness??1,this.envMapIntensity=this._defaults.envMapIntensity=t.envMapIntensity??1)}get material(){if(this._props.target instanceof f.MeshStandardMaterial)return this._props.target;if(this._props.target instanceof f.Mesh){if(Array.isArray(this._props.target.material))return this._props.target.material.find(e=>e instanceof f.MeshStandardMaterial);if(this._props.target.material instanceof f.MeshStandardMaterial)return this._props.target.material}}change(e){var i;this.color=e;const t=this.material;(i=t==null?void 0:t.color)==null||i.set(e)}reset(){this.change(this._defaults.color);const e=this.material;e&&(e.metalness=this._defaults.metalness,e.roughness=this._defaults.roughness,e.envMapIntensity=this._defaults.envMapIntensity,e.needsUpdate=!0)}}var mn=(a=>(a[a.DEFAULT=0]="DEFAULT",a[a.CAN_INSTALL=1]="CAN_INSTALL",a))(mn||{});const Lr=.15;f.Object3D.DEFAULT_UP.set(0,0,1);let ut,xi=0,xs=0;const qc=()=>{ut=void 0,xi=0,xs=0},Yc=new f.MeshBasicMaterial({colorWrite:!1});class Zc{constructor(e){this.props=e,this.stats=new zt,this.scene=new f.Scene,this.overlayScene=new f.Scene,this.renderer=new f.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new be.CSS2DRenderer,this.mousePos=new f.Vector2,this.mouseCoord=new f.Vector2,this.offset=new f.Vector2,this.size=new f.Vector2,this.amr=new an({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new f.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new f.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new f.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new f.Group,this._raycaster=new f.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new Ye,this.sound=new Ja,this._rafId=null,this._destroyed=!1,this._css2dUiStyleInjected=!1,this._ground=new f.Mesh(new f.PlaneGeometry(100,100),new f.MeshPhysicalMaterial({color:new f.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new Hc(18,40),this._amrRender=new f.WebGLRenderTarget(1024,1024,{format:f.RGBAFormat,type:f.UnsignedByteType,colorSpace:f.SRGBColorSpace,samples:8}),this._lastTarget=new f.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:h,left:u}=this.renderer.domElement.getBoundingClientRect();this.offset.set(u,h),this.mousePos.set(c.clientX-u,c.clientY-h),this.mouseCoord.set((c.clientX-u)/this.size.x*2-1,-((c.clientY-h)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const h=()=>{this.amr.slots.forEach(n=>n.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(n=>{n.traverse(l=>{l==p.object||(n.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(h,200)},this._detectTrackpad=()=>{ut||typeof ut<"u"||(xi===0&&(xs=performance.now()),xi++,performance.now()-xs>66&&(xi>5?ut=!0:ut=!1,ut?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(qc,2e3)))},this.debounceForkHeightChange=rl(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,h)=>{var W;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(W=this._fitAnimation)==null||W.stop();const u=new f.Box3,p=new f.Box3,n=new f.Vector3,l=new f.Vector3,d=new f.Vector3,g=new f.Vector3,v=O=>{O.geometry&&(O.geometry.boundingBox||O.geometry.computeBoundingBox(),p.copy(O.geometry.boundingBox).applyMatrix4(O.matrixWorld),p.isEmpty()||u.union(p))},m=O=>{var Gt,Nt;const j=O.geometry,U=(Gt=j==null?void 0:j.attributes)==null?void 0:Gt.position;if(!U){v(O);return}const ie=((Nt=j.morphAttributes)==null?void 0:Nt.position)||[],Ze=O.morphTargetInfluences||[],_e=ie.length>0&&Ze.length>0;for(let ve=0;ve<U.count;ve++){if(n.set(U.getX(ve),U.getY(ve),U.getZ(ve)),_e){l.set(0,0,0);let Qt=0;for(let X=0;X<ie.length;X++){const ee=Ze[X]||0;ee&&(Qt+=ee,d.set(ie[X].getX(ve),ie[X].getY(ve),ie[X].getZ(ve)),j.morphTargetsRelative,l.addScaledVector(d,ee))}j.morphTargetsRelative?n.add(l):Qt>0&&(n.multiplyScalar(1-Qt),n.add(l))}g.copy(n).applyMatrix4(O.matrixWorld),u.expandByPoint(g)}};if(c.forEach(O=>{O.traverse(j=>{if(j.visible){if(j instanceof f.Mesh){m(j);return}(j.isPoint||j.isLine)&&v(j)}})}),u.isEmpty())return;const _=new f.Vector3;u.getCenter(_);const y=new f.Vector3;u.getSize(y);const w=_.clone();this._lastTarget.copy(w);let x;h?x=h.clone().normalize().negate():x=this.camera.position.clone().sub(this.controls.target).normalize();const b=y.clone().multiplyScalar(.5),T=[new f.Vector3(b.x,b.y,b.z),new f.Vector3(b.x,b.y,-b.z),new f.Vector3(b.x,-b.y,b.z),new f.Vector3(b.x,-b.y,-b.z),new f.Vector3(-b.x,b.y,b.z),new f.Vector3(-b.x,b.y,-b.z),new f.Vector3(-b.x,-b.y,b.z),new f.Vector3(-b.x,-b.y,-b.z)],M=new f.Vector3(0,1,0);Math.abs(x.dot(M))>.99&&M.set(0,0,1);const L=new f.Vector3().crossVectors(x,M).normalize(),C=new f.Vector3().crossVectors(L,x).normalize();let I=0;T.forEach(O=>{const j=O.dot(L),U=O.dot(C),ie=Math.sqrt(j*j+U*U);I=Math.max(I,ie)}),I=I/2+.4;const D=this.camera.fov*Math.PI/180,A=2*Math.atan(Math.tan(D/2)*this.camera.aspect),S=I/Math.tan(A/2),P=I/Math.tan(D/2),R=Math.max(S,P),k=_.clone().add(x.multiplyScalar(R)),F=this.camera.position.clone(),z=this.controls.target.clone();let B=500;const N=F.distanceTo(k)+z.distanceTo(w);N>.001&&(B=Math.min(1e3,Math.max(450,N*45))),this._animateCamera(F,k,z,w,B)},this.focusSlots=c=>{var C,I;if(this.amr.slots.forEach(D=>{D.focused=!1,D.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(D=>{D.show()}),this.shadowMode=!1,this._focusRestoreView){const D=this._focusRestoreView;this._focusRestoreView=void 0;const A=this.camera.position.clone(),S=this.controls.target.clone(),P=D.position.clone(),R=D.target.clone();let k=500;const F=A.distanceTo(P)+S.distanceTo(R);F>.001&&(k=Math.min(1e3,Math.max(450,F*45))),this._animateCamera(A,P,S,R,k,()=>{this.camera.up.copy(D.up)});return}else{this.fit();return}(C=this._fitAnimation)!=null&&C.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new f.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(I=this._fitAnimation)==null||I.stop(),this.shadowMode=!0;const h=c.flatMap(D=>{if(D.show(),D.focused=!0,!D.parent)return[];const A=new f.Vector3;return D.parent.getWorldPosition(A),[A]});if(!h.length)return;const u=h.reduce((D,A)=>D.add(A),new f.Vector3).multiplyScalar(1/h.length),p=this.controls.target.clone(),n=this.camera.position.clone().sub(p).normalize();let l=0;for(const D of h){const A=D.clone().sub(u),S=A.dot(n),P=Math.sqrt(Math.max(0,A.lengthSq()-S*S));P>l&&(l=P)}l=l+.4;const d=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(d/2)*this.camera.aspect),v=l/Math.tan(g/2),m=l/Math.tan(d/2),_=Math.max(v,m),y=u.clone(),w=u.clone().add(n.clone().multiplyScalar(_<1?1:_)),x=this.camera.position.clone(),b=p.clone(),T={t:0};let M=500;const L=x.distanceTo(w)+b.distanceTo(y);L>.001&&(M=Math.min(1e3,Math.max(450,L*45))),this._lastTarget=y.clone(),this._fitAnimation=new wi(T).to({t:1},M).easing(ne.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const D=T.t;this.camera.position.lerpVectors(x,w,D),this.controls.target.lerpVectors(b,y,D)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new f.Box3().setFromObject(this._container);const h=this.amr.sizeBox.size.getSize(new f.Vector3),u=h.clone().multiplyScalar(.5),p=new f.Vector3(0,0,u.z);this._lastTarget.copy(p);let n=u.clone().sub(p);n.lengthSq()<1e-6&&(n=new f.Vector3(1,0,0));const l=n.clone().normalize(),d=h.clone().multiplyScalar(.5),g=[new f.Vector3(d.x,d.y,d.z),new f.Vector3(d.x,d.y,-d.z),new f.Vector3(d.x,-d.y,d.z),new f.Vector3(d.x,-d.y,-d.z),new f.Vector3(-d.x,d.y,d.z),new f.Vector3(-d.x,d.y,-d.z),new f.Vector3(-d.x,-d.y,d.z),new f.Vector3(-d.x,-d.y,-d.z)];let v=0;for(const A of g){const S=A.dot(l),P=Math.sqrt(Math.max(0,A.lengthSq()-S*S));P>v&&(v=P)}v=v*1.05;const m=this.camera.fov*Math.PI/180,_=2*Math.atan(Math.tan(m/2)*this.camera.aspect),y=v/Math.tan(_/2),w=v/Math.tan(m/2),x=Math.max(y,w),b=u.clone();let T=h.z/3;h.z<h.x&&h.z<h.y&&(T=h.x*.8),h.z>h.x&&h.z>h.y&&(T=0),b.z+=T;const M=n.clone().normalize().multiplyScalar(x<1?1:x).add(b);Math.max(h.x*2,5);const L=this.camera.position.clone(),C=this.controls.target.clone();let I=600;const D=L.distanceTo(M)+C.distanceTo(p);D>.001&&(I=Math.min(800,Math.max(650,D*45))),this._animateCamera(L,M,C,p,I,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(x*.25,x-.1)),this.controls.maxDistance=x*4},this.resize=()=>{var p,n;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const h=c.clientWidth,u=c.clientHeight;this.size.set(h,u),this.camera.aspect=h/u,this.camera.updateProjectionMatrix(),this._amrRender.setSize(h,u),this._updateCamera(),this.css2dRenderer.setSize(h,u),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(h,u),(n=this._jumpFlood)==null||n.setSize(h,u)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const h=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Yc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=h}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const u=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(u)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),ne.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Xr(je,this.renderer),this._ground.visible=!1,this.controls=new Sn.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=Lr,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:tn()?.2:1,this._cameraPositionUI=new Oc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=f.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=f.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.css2dRenderer.domElement.setAttribute("data-css2d-root","1"),this._ensureCss2dUiStyle(),this.camera.position.set(10,-10,5),this.camera.lookAt(new f.Vector3);const{tiles:t}=il();this.pathTracer=new ga(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new Rc(e.workerUrl),r=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=r,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const o=()=>{let c=this._lastTarget.x,h=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=h};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,o(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new kc(this.renderer,this.scene,{size:8,lightCount:6,frames:e.isMobile?20:60,lightRadius:2,ambientWeight:.75}),this._progressShadow.lightOrigin.position.set(3,2.5,.6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new Uc(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new Ec(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new f.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new f.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new ks.HDRLoader().load(Nc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.add(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:Lr,this.sampleCount=0}get fpsAverage(){return en(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof f.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),this.amr.ikControllers.forEach(i=>i.enabled=!1),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&(this.amr.controllers.forEach(t=>t.show()),this.amr.ikControllers.forEach(t=>t.enabled=!0)),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide()),this.amr.ikControllers.forEach(t=>e?t.enabled=!0:t.enabled=!1)}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new ks.HDRLoader().load(Gc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new f.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{const t=new f.Group;e.target.updateMatrixWorld(!0),t.applyMatrix4(e.target.matrixWorld),t.add(e.target),this.overlayScene.add(t)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const r=document.createElement("canvas");r.width=t,r.height=i;const o=r.getContext("2d"),c=new ImageData(t,i);for(let h=0;h<i;h++)for(let u=0;u<t;u++){const p=((i-h-1)*t+u)*4,n=(h*t+u)*4;c.data[n]=s[p],c.data[n+1]=s[p+1],c.data[n+2]=s[p+2],c.data[n+3]=s[p+3]}return o.putImageData(c,0,0),r.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const r=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(r)},this.fpsAverage)})}async captureTriViews(e){var o;const t=(e==null?void 0:e.subject)??this._container;(o=this._progressShadow)==null||o.visible;const i=this.scene.background,s=this.showSize;return new gn({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){De(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await rn.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(r=>{if(!Object.keys(r.morphTargetDictionary||{}).includes(i))return;let o=s;r.userData[`origin_${i}`]&&(o-=r.userData[`origin_${i}`]);const c=r.morphTargetDictionary[i];r.morphTargetInfluences&&(r.morphTargetInfluences[c]=o),r instanceof f.Mesh&&r.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,r,o){var h;const c={t:0};(h=this._fitAnimation)==null||h.stop(),this._fitAnimation=new wi(c).to({t:1},r).easing(ne.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const u=c.t;this.controls.target.lerpVectors(i,s,u);const p=s.clone(),n=e.clone().sub(p),l=t.clone().sub(p),d=n.length(),g=l.length(),v=d+(g-d)*u;let m;if(d>.001&&g>.001){const _=n.clone().normalize(),y=l.clone().normalize(),w=_.angleTo(y);if(w>.001){const x=new f.Vector3().crossVectors(_,y);if(x.lengthSq()>.001){x.normalize();const b=new f.Quaternion().setFromAxisAngle(x,w*u),T=_.clone().applyQuaternion(b);m=p.clone().add(T.multiplyScalar(v))}else m=p.clone().add(_.multiplyScalar(v))}else m=p.clone().add(_.multiplyScalar(v))}else m=e.clone().lerp(t,u);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,o==null||o()}).start()}select(e,t=4){if(this._jumpFlood&&(this._jumpFlood.params.thickness=t),!e){this._selectedForOutline=[];return}typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
|
|
3938
|
+
`});super(s,r),this.position.z=-.02}}const Gc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",Nc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",Qc="https://cdn2.seer-group.com/libs/fonts.type.json",jc=new Mn.Font(Qc);class ys{constructor(e){var i;this._props=e,this.name="",this._defaults={color:"",metalness:0,roughness:0,envMapIntensity:1},this.color="",this.metalness=0,this.roughness=0,this.envMapIntensity=1,this.name=this._props.name;const t=this.material;t&&(this.color=this._defaults.color="#"+((i=t.color)==null?void 0:i.getHexString()),this.metalness=this._defaults.metalness=t.metalness??0,this.roughness=this._defaults.roughness=t.roughness??1,this.envMapIntensity=this._defaults.envMapIntensity=t.envMapIntensity??1)}get material(){if(this._props.target instanceof f.MeshStandardMaterial)return this._props.target;if(this._props.target instanceof f.Mesh){if(Array.isArray(this._props.target.material))return this._props.target.material.find(e=>e instanceof f.MeshStandardMaterial);if(this._props.target.material instanceof f.MeshStandardMaterial)return this._props.target.material}}change(e){var i;this.color=e;const t=this.material;(i=t==null?void 0:t.color)==null||i.set(e)}reset(){this.change(this._defaults.color);const e=this.material;e&&(e.metalness=this._defaults.metalness,e.roughness=this._defaults.roughness,e.envMapIntensity=this._defaults.envMapIntensity,e.needsUpdate=!0)}}var mn=(a=>(a[a.DEFAULT=0]="DEFAULT",a[a.CAN_INSTALL=1]="CAN_INSTALL",a))(mn||{});const Pr=.15;f.Object3D.DEFAULT_UP.set(0,0,1);let ut,xi=0,xs=0;const qc=()=>{ut=void 0,xi=0,xs=0},Yc=new f.MeshBasicMaterial({colorWrite:!1});class Zc{constructor(e){this.props=e,this.stats=new zt,this.scene=new f.Scene,this.overlayScene=new f.Scene,this.renderer=new f.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new be.CSS2DRenderer,this.mousePos=new f.Vector2,this.mouseCoord=new f.Vector2,this.offset=new f.Vector2,this.size=new f.Vector2,this.amr=new an({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new f.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new f.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new f.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new f.Group,this._raycaster=new f.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new Ye,this.sound=new Ja,this._rafId=null,this._destroyed=!1,this._css2dUiStyleInjected=!1,this._ground=new f.Mesh(new f.PlaneGeometry(100,100),new f.MeshPhysicalMaterial({color:new f.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new Hc(18,40),this._amrRender=new f.WebGLRenderTarget(1024,1024,{format:f.RGBAFormat,type:f.UnsignedByteType,colorSpace:f.SRGBColorSpace,samples:8}),this._lastTarget=new f.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:h,left:u}=this.renderer.domElement.getBoundingClientRect();this.offset.set(u,h),this.mousePos.set(c.clientX-u,c.clientY-h),this.mouseCoord.set((c.clientX-u)/this.size.x*2-1,-((c.clientY-h)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const h=()=>{this.amr.slots.forEach(n=>n.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(n=>{n.traverse(l=>{l==p.object||(n.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(h,200)},this._detectTrackpad=()=>{ut||typeof ut<"u"||(xi===0&&(xs=performance.now()),xi++,performance.now()-xs>66&&(xi>5?ut=!0:ut=!1,ut?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(qc,2e3)))},this.debounceForkHeightChange=rl(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,h)=>{var W;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(W=this._fitAnimation)==null||W.stop();const u=new f.Box3,p=new f.Box3,n=new f.Vector3,l=new f.Vector3,d=new f.Vector3,g=new f.Vector3,v=O=>{O.geometry&&(O.geometry.boundingBox||O.geometry.computeBoundingBox(),p.copy(O.geometry.boundingBox).applyMatrix4(O.matrixWorld),p.isEmpty()||u.union(p))},m=O=>{var Gt,Nt;const j=O.geometry,U=(Gt=j==null?void 0:j.attributes)==null?void 0:Gt.position;if(!U){v(O);return}const ie=((Nt=j.morphAttributes)==null?void 0:Nt.position)||[],Ze=O.morphTargetInfluences||[],_e=ie.length>0&&Ze.length>0;for(let ve=0;ve<U.count;ve++){if(n.set(U.getX(ve),U.getY(ve),U.getZ(ve)),_e){l.set(0,0,0);let Qt=0;for(let X=0;X<ie.length;X++){const ee=Ze[X]||0;ee&&(Qt+=ee,d.set(ie[X].getX(ve),ie[X].getY(ve),ie[X].getZ(ve)),j.morphTargetsRelative,l.addScaledVector(d,ee))}j.morphTargetsRelative?n.add(l):Qt>0&&(n.multiplyScalar(1-Qt),n.add(l))}g.copy(n).applyMatrix4(O.matrixWorld),u.expandByPoint(g)}};if(c.forEach(O=>{O.traverse(j=>{if(j.visible){if(j instanceof f.Mesh){m(j);return}(j.isPoint||j.isLine)&&v(j)}})}),u.isEmpty())return;const _=new f.Vector3;u.getCenter(_);const y=new f.Vector3;u.getSize(y);const w=_.clone();this._lastTarget.copy(w);let x;h?x=h.clone().normalize().negate():x=this.camera.position.clone().sub(this.controls.target).normalize();const b=y.clone().multiplyScalar(.5),T=[new f.Vector3(b.x,b.y,b.z),new f.Vector3(b.x,b.y,-b.z),new f.Vector3(b.x,-b.y,b.z),new f.Vector3(b.x,-b.y,-b.z),new f.Vector3(-b.x,b.y,b.z),new f.Vector3(-b.x,b.y,-b.z),new f.Vector3(-b.x,-b.y,b.z),new f.Vector3(-b.x,-b.y,-b.z)],M=new f.Vector3(0,1,0);Math.abs(x.dot(M))>.99&&M.set(0,0,1);const P=new f.Vector3().crossVectors(x,M).normalize(),C=new f.Vector3().crossVectors(P,x).normalize();let I=0;T.forEach(O=>{const j=O.dot(P),U=O.dot(C),ie=Math.sqrt(j*j+U*U);I=Math.max(I,ie)}),I=I/2+.4;const D=this.camera.fov*Math.PI/180,A=2*Math.atan(Math.tan(D/2)*this.camera.aspect),S=I/Math.tan(A/2),L=I/Math.tan(D/2),R=Math.max(S,L),k=_.clone().add(x.multiplyScalar(R)),F=this.camera.position.clone(),z=this.controls.target.clone();let B=500;const N=F.distanceTo(k)+z.distanceTo(w);N>.001&&(B=Math.min(1e3,Math.max(450,N*45))),this._animateCamera(F,k,z,w,B)},this.focusSlots=c=>{var C,I;if(this.amr.slots.forEach(D=>{D.focused=!1,D.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(D=>{D.show()}),this.shadowMode=!1,this._focusRestoreView){const D=this._focusRestoreView;this._focusRestoreView=void 0;const A=this.camera.position.clone(),S=this.controls.target.clone(),L=D.position.clone(),R=D.target.clone();let k=500;const F=A.distanceTo(L)+S.distanceTo(R);F>.001&&(k=Math.min(1e3,Math.max(450,F*45))),this._animateCamera(A,L,S,R,k,()=>{this.camera.up.copy(D.up)});return}else{this.fit();return}(C=this._fitAnimation)!=null&&C.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new f.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(I=this._fitAnimation)==null||I.stop(),this.shadowMode=!0;const h=c.flatMap(D=>{if(D.show(),D.focused=!0,!D.parent)return[];const A=new f.Vector3;return D.parent.getWorldPosition(A),[A]});if(!h.length)return;const u=h.reduce((D,A)=>D.add(A),new f.Vector3).multiplyScalar(1/h.length),p=this.controls.target.clone(),n=this.camera.position.clone().sub(p).normalize();let l=0;for(const D of h){const A=D.clone().sub(u),S=A.dot(n),L=Math.sqrt(Math.max(0,A.lengthSq()-S*S));L>l&&(l=L)}l=l+.4;const d=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(d/2)*this.camera.aspect),v=l/Math.tan(g/2),m=l/Math.tan(d/2),_=Math.max(v,m),y=u.clone(),w=u.clone().add(n.clone().multiplyScalar(_<1?1:_)),x=this.camera.position.clone(),b=p.clone(),T={t:0};let M=500;const P=x.distanceTo(w)+b.distanceTo(y);P>.001&&(M=Math.min(1e3,Math.max(450,P*45))),this._lastTarget=y.clone(),this._fitAnimation=new wi(T).to({t:1},M).easing(ne.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const D=T.t;this.camera.position.lerpVectors(x,w,D),this.controls.target.lerpVectors(b,y,D)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new f.Box3().setFromObject(this._container);const h=this.amr.sizeBox.size.getSize(new f.Vector3),u=h.clone().multiplyScalar(.5),p=new f.Vector3(0,0,u.z);this._lastTarget.copy(p);let n=u.clone().sub(p);n.lengthSq()<1e-6&&(n=new f.Vector3(1,0,0));const l=n.clone().normalize(),d=h.clone().multiplyScalar(.5),g=[new f.Vector3(d.x,d.y,d.z),new f.Vector3(d.x,d.y,-d.z),new f.Vector3(d.x,-d.y,d.z),new f.Vector3(d.x,-d.y,-d.z),new f.Vector3(-d.x,d.y,d.z),new f.Vector3(-d.x,d.y,-d.z),new f.Vector3(-d.x,-d.y,d.z),new f.Vector3(-d.x,-d.y,-d.z)];let v=0;for(const A of g){const S=A.dot(l),L=Math.sqrt(Math.max(0,A.lengthSq()-S*S));L>v&&(v=L)}v=v*1.05;const m=this.camera.fov*Math.PI/180,_=2*Math.atan(Math.tan(m/2)*this.camera.aspect),y=v/Math.tan(_/2),w=v/Math.tan(m/2),x=Math.max(y,w),b=u.clone();let T=h.z/3;h.z<h.x&&h.z<h.y&&(T=h.x*.8),h.z>h.x&&h.z>h.y&&(T=0),b.z+=T;const M=n.clone().normalize().multiplyScalar(x<1?1:x).add(b);Math.max(h.x*2,5);const P=this.camera.position.clone(),C=this.controls.target.clone();let I=600;const D=P.distanceTo(M)+C.distanceTo(p);D>.001&&(I=Math.min(800,Math.max(650,D*45))),this._animateCamera(P,M,C,p,I,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(x*.25,x-.1)),this.controls.maxDistance=x*4},this.resize=()=>{var p,n;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const h=c.clientWidth,u=c.clientHeight;this.size.set(h,u),this.camera.aspect=h/u,this.camera.updateProjectionMatrix(),this._amrRender.setSize(h,u),this._updateCamera(),this.css2dRenderer.setSize(h,u),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(h,u),(n=this._jumpFlood)==null||n.setSize(h,u)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const h=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Yc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=h}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const u=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(u)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),ne.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Xr(je,this.renderer),this._ground.visible=!1,this.controls=new Sn.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=Pr,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:tn()?.2:1,this._cameraPositionUI=new Oc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=f.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=f.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.css2dRenderer.domElement.setAttribute("data-css2d-root","1"),this._ensureCss2dUiStyle(),this.camera.position.set(10,-10,5),this.camera.lookAt(new f.Vector3);const{tiles:t}=il();this.pathTracer=new ga(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new Rc(e.workerUrl),r=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=r,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const o=()=>{let c=this._lastTarget.x,h=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=h};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,o(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new kc(this.renderer,this.scene,{size:8,lightCount:6,frames:e.isMobile?20:60,lightRadius:2,ambientWeight:.75}),this._progressShadow.lightOrigin.position.set(3,2.5,.6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new Uc(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new Ec(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new f.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new f.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new ks.HDRLoader().load(Nc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.add(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:Pr,this.sampleCount=0}get fpsAverage(){return en(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof f.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),this.amr.ikControllers.forEach(i=>i.enabled=!1),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&(this.amr.controllers.forEach(t=>t.show()),this.amr.ikControllers.forEach(t=>t.enabled=!0)),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide()),this.amr.ikControllers.forEach(t=>e?t.enabled=!0:t.enabled=!1)}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new ks.HDRLoader().load(Gc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new f.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{const t=new f.Group;e.target.updateMatrixWorld(!0),t.applyMatrix4(e.target.matrixWorld),t.add(e.target),this.overlayScene.add(t)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const r=document.createElement("canvas");r.width=t,r.height=i;const o=r.getContext("2d"),c=new ImageData(t,i);for(let h=0;h<i;h++)for(let u=0;u<t;u++){const p=((i-h-1)*t+u)*4,n=(h*t+u)*4;c.data[n]=s[p],c.data[n+1]=s[p+1],c.data[n+2]=s[p+2],c.data[n+3]=s[p+3]}return o.putImageData(c,0,0),r.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const r=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(r)},this.fpsAverage)})}async captureTriViews(e){var o;const t=(e==null?void 0:e.subject)??this._container;(o=this._progressShadow)==null||o.visible;const i=this.scene.background,s=this.showSize;return new gn({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){De(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await rn.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(r=>{if(!Object.keys(r.morphTargetDictionary||{}).includes(i))return;let o=s;r.userData[`origin_${i}`]&&(o-=r.userData[`origin_${i}`]);const c=r.morphTargetDictionary[i];r.morphTargetInfluences&&(r.morphTargetInfluences[c]=o),r instanceof f.Mesh&&r.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,r,o){var h;const c={t:0};(h=this._fitAnimation)==null||h.stop(),this._fitAnimation=new wi(c).to({t:1},r).easing(ne.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const u=c.t;this.controls.target.lerpVectors(i,s,u);const p=s.clone(),n=e.clone().sub(p),l=t.clone().sub(p),d=n.length(),g=l.length(),v=d+(g-d)*u;let m;if(d>.001&&g>.001){const _=n.clone().normalize(),y=l.clone().normalize(),w=_.angleTo(y);if(w>.001){const x=new f.Vector3().crossVectors(_,y);if(x.lengthSq()>.001){x.normalize();const b=new f.Quaternion().setFromAxisAngle(x,w*u),T=_.clone().applyQuaternion(b);m=p.clone().add(T.multiplyScalar(v))}else m=p.clone().add(_.multiplyScalar(v))}else m=p.clone().add(_.multiplyScalar(v))}else m=e.clone().lerp(t,u);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,o==null||o()}).start()}select(e,t=4){if(this._jumpFlood&&(this._jumpFlood.params.thickness=t),!e){this._selectedForOutline=[];return}typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
|
|
3939
3939
|
-webkit-user-select: none;
|
|
3940
3940
|
user-select: none;
|
|
3941
3941
|
touch-action: none;
|
|
@@ -3944,4 +3944,4 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3944
3944
|
[data-css2d-root="1"] [data-ui-type="mechanism"] {
|
|
3945
3945
|
z-index: 2147483647 !important;
|
|
3946
3946
|
}
|
|
3947
|
-
`,document.head.append(t),this._css2dUiStyleInjected=!0}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s,r,o,c;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),(i=this._sciFiGrid)==null||i.removeFromParent(),(s=this._sciFiGrid)==null||s.geometry.dispose(),(r=this._sciFiGrid.material)==null||r.dispose(),ne.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(o=this._fitAnimation)==null||o.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((c=this._resizeObserver)==null||c.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),De(this.scene),this.scene.clear()}}class gn{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new f.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new f.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,v,m,_,y,w;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new f.Vector2;t.getSize(s);const r=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),o=((v=e==null?void 0:e.size)==null?void 0:v.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,h=(e==null?void 0:e.includeOverlay)??!1,u=r/o||1,p=this.resolveViews(e==null?void 0:e.views),n=new f.WebGLRenderTarget(r,o,{format:f.RGBAFormat,type:f.UnsignedByteType});n.texture.colorSpace=f.SRGBColorSpace,n.texture.generateMipmaps=!1,n.depthBuffer=!0;const l=this.storeRendererState(t),d={};try{(_=(m=this.deps).onBeforeCapture)==null||_.call(m);const x=this.computeBounds(i);this.applyRendererState(t,r,o,e==null?void 0:e.backgroundColor);for(const b of p){const T=this.configureCamera(x,b,u,c,r,o);t.setRenderTarget(n),t.clear(!0,!0,!0),t.render(this.deps.scene,T),h&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const M=this.readPixels(t,n,r,o);d[b.key]=M}}finally{n.dispose(),this.restoreRendererState(t,l),(w=(y=this.deps).onAfterCapture)==null||w.call(y)}return d}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new f.Vector3(0,0,1),up:new f.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new f.Vector3(0,-1,0),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new f.Vector3(1,0,0),up:new f.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new f.Vector3(1,1,1),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new f.Box3,i=new f.Box3,s=new f.Vector3,r=new f.Vector3,o=new f.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const u=c.geometry;if(!u)return;u.boundingBox||u.computeBoundingBox();const p=u.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new f.Vector3(.001,.001,.001)),r.set(.001,.001,.001),o.center.copy(s),o.radius=.001):(t.getCenter(s),t.getSize(r),t.getBoundingSphere(o)),(!Number.isFinite(o.radius)||o.radius<=0)&&(o.radius=Math.max(r.length()*.5,.001)),{box:t,center:s,size:r,sphere:o}}configureCamera(e,t,i,s,r,o){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const h=t.up.clone().normalize();if(Math.abs(h.dot(c))>.999&&(h.set(0,0,1),Math.abs(h.dot(c))>.999&&h.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const x=this.perspectiveCamera,b=t.fov??45,T=f.MathUtils.degToRad(b),M=Math.max(Math.tan(T/2),1e-4),
|
|
3947
|
+
`,document.head.append(t),this._css2dUiStyleInjected=!0}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s,r,o,c;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),(i=this._sciFiGrid)==null||i.removeFromParent(),(s=this._sciFiGrid)==null||s.geometry.dispose(),(r=this._sciFiGrid.material)==null||r.dispose(),ne.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(o=this._fitAnimation)==null||o.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((c=this._resizeObserver)==null||c.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),De(this.scene),this.scene.clear()}}class gn{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new f.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new f.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,v,m,_,y,w;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new f.Vector2;t.getSize(s);const r=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),o=((v=e==null?void 0:e.size)==null?void 0:v.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,h=(e==null?void 0:e.includeOverlay)??!1,u=r/o||1,p=this.resolveViews(e==null?void 0:e.views),n=new f.WebGLRenderTarget(r,o,{format:f.RGBAFormat,type:f.UnsignedByteType});n.texture.colorSpace=f.SRGBColorSpace,n.texture.generateMipmaps=!1,n.depthBuffer=!0;const l=this.storeRendererState(t),d={};try{(_=(m=this.deps).onBeforeCapture)==null||_.call(m);const x=this.computeBounds(i);this.applyRendererState(t,r,o,e==null?void 0:e.backgroundColor);for(const b of p){const T=this.configureCamera(x,b,u,c,r,o);t.setRenderTarget(n),t.clear(!0,!0,!0),t.render(this.deps.scene,T),h&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const M=this.readPixels(t,n,r,o);d[b.key]=M}}finally{n.dispose(),this.restoreRendererState(t,l),(w=(y=this.deps).onAfterCapture)==null||w.call(y)}return d}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new f.Vector3(0,0,1),up:new f.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new f.Vector3(0,-1,0),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new f.Vector3(1,0,0),up:new f.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new f.Vector3(1,1,1),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new f.Box3,i=new f.Box3,s=new f.Vector3,r=new f.Vector3,o=new f.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const u=c.geometry;if(!u)return;u.boundingBox||u.computeBoundingBox();const p=u.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new f.Vector3(.001,.001,.001)),r.set(.001,.001,.001),o.center.copy(s),o.radius=.001):(t.getCenter(s),t.getSize(r),t.getBoundingSphere(o)),(!Number.isFinite(o.radius)||o.radius<=0)&&(o.radius=Math.max(r.length()*.5,.001)),{box:t,center:s,size:r,sphere:o}}configureCamera(e,t,i,s,r,o){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const h=t.up.clone().normalize();if(Math.abs(h.dot(c))>.999&&(h.set(0,0,1),Math.abs(h.dot(c))>.999&&h.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const x=this.perspectiveCamera,b=t.fov??45,T=f.MathUtils.degToRad(b),M=Math.max(Math.tan(T/2),1e-4),P=Math.max(M*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),I=new f.Vector3().crossVectors(C,h).normalize();I.lengthSq()<1e-6&&I.set(1,0,0);const D=new f.Vector3().crossVectors(I,C).normalize(),A=Math.max(e.size.x*.5,1e-4),S=Math.max(e.size.y*.5,1e-4),L=Math.max(e.size.z*.5,1e-4),R=[new f.Vector3(-A,-S,-L),new f.Vector3(-A,-S,L),new f.Vector3(-A,S,-L),new f.Vector3(-A,S,L),new f.Vector3(A,-S,-L),new f.Vector3(A,-S,L),new f.Vector3(A,S,-L),new f.Vector3(A,S,L)];let k=0,F=-1/0;for(const N of R){const W=I.dot(N),O=D.dot(N),j=C.dot(N);F=Math.max(F,j);const U=j+Math.abs(W)/P,ie=j+Math.abs(O)/M;k=Math.max(k,U,ie)}k=Math.max(k,F+.1);const z=k*(1+s);let B=1/0;for(const N of R){const W=C.dot(N),O=z-W;O>.001&&(B=Math.min(B,O))}return x.fov=b,x.aspect=i||r/Math.max(o,1),x.near=Math.max(.1,Number.isFinite(B)?B*.5:z*.1),x.far=Math.max(x.near+1,z+e.sphere.radius*3),x.position.copy(e.center).add(C.clone().multiplyScalar(z)),x.up.copy(D),x.lookAt(e.center),x.updateProjectionMatrix(),x.updateMatrixWorld(!0),x}const p=this.orthoCamera,n=e.size,l=e.center,d=Math.max(n[t.plane.width]*.5,.01),g=Math.max(n[t.plane.height]*.5,.01),v=Math.max(n[t.plane.depth]*.5,.01);let m=d*(1+s),_=g*(1+s);m/i>_?_=m/i:m=_*i;const y=v*(1+s)+Math.max(m,_),w=l.clone().add(c.multiplyScalar(y));return p.left=-m,p.right=m,p.top=_,p.bottom=-_,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(w),p.up.copy(h),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new f.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),r=new f.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),o=.25,c=new f.Vector3(Math.max(o,s.x)*Math.max(t.x,.001),Math.max(o,s.y)*Math.max(t.y,.001),0),h=Math.max((t.x+t.y)*.5,.001),u=Math.max(t.z,.001),p=Math.max(o,s.z),n=u*.5+h*.5;return c.z=p*n,c.multiply(r),c}storeRendererState(e){const t=new f.Vector2;e.getSize(t);const i=new f.Vector4;e.getViewport(i);const s=new f.Vector4;e.getScissor(s);const r=e.getClearColor(new f.Color),o=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:r,clearAlpha:o}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const r=e.getClearColor(new f.Color);e.setClearColor(r,0)}else s instanceof f.Color?e.setClearColor(s,1):e.setClearColor(new f.Color(s),1);else{const r=e.getClearColor(new f.Color);e.setClearColor(r,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const r=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==r)&&(this.pixelBuffer=new Uint8Array(r)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const o=this.ensureCanvas(i,s),c=o.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const h=c.createImageData(i,s),u=h.data,p=this.pixelBuffer;for(let n=0;n<s;n+=1){const d=(s-n-1)*i*4,g=n*i*4;u.set(p.subarray(d,d+i*4),g)}return c.putImageData(h,0,0),o.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const Kc="shop-components",Xc="0.4.26",Jc="Shop components",$c="dist/shop-components.umd.js",eh="dist/shop-components.mjs",th="dist/main.d.ts",ih={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build","build:web":"BUILD_WEB=1 vite build --outDir dist/web --emptyOutDir",v:"auto-changelog -p && git add CHANGELOG.md"},sh=["dist","package.json"],rh=[],nh="machengda<machengda@seer-group.com>",oh="ISC",ah={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3",tweakpane:"^4.0.3","@tweakpane/core":"^2.0.3",stylus:"^0.63.0"},lh={"string-width":"4.2.3"},ch={three:"0.182.0"},hh={"@tweenjs/tween.js":"^23.1.2","@types/howler":"^2.2.11","@types/three":"0.182.0",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1"},uh={name:Kc,version:Xc,description:Jc,main:$c,module:eh,types:th,scripts:ih,files:sh,keywords:rh,author:nh,license:oh,devDependencies:ah,resolutions:lh,peerDependencies:ch,dependencies:hh};function Lr(){const a="Nebula Engin",e=uh.version,t=`%c ${a} %c v${e} `;console.log(t,"background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;","background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;")}const Ir="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const a=globalThis;a[Ir]||(a[Ir]=!0,Lr())}catch{Lr()}exports.Amr=an;exports.Logo=ls;exports.SGLBLoader=Ut;exports.SLOT_EVENTS=J;exports.Scene3D=Zc;exports.Skin=ys;exports.Slot=as;exports.SlotState=mn;exports.TriViewCapture=gn;exports.arrayBufferToUrl=ns;exports.calculateArrayAverage=en;exports.calculateFocalLength=Ka;exports.createSGLBFile=ll;exports.downloadBlob=Za;exports.dracoExporter=al;exports.font=jc;exports.gltfExporter=rn;exports.gltfLoader=je;exports.imageBitmapToUrl=os;exports.isAppleDevice=tn;exports.textureLoader=Ds;
|