shop-components 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/dev/libs/gltf-progressive/src/extension.d.ts +50 -0
  2. package/dist/dev/libs/gltf-progressive/src/extension.model.d.ts +24 -0
  3. package/dist/dev/libs/gltf-progressive/src/index.d.ts +15 -0
  4. package/dist/dev/libs/gltf-progressive/src/loaders.d.ts +28 -0
  5. package/dist/dev/libs/gltf-progressive/src/lods.debug.d.ts +4 -0
  6. package/dist/dev/libs/gltf-progressive/src/lods.manager.d.ts +79 -0
  7. package/dist/dev/libs/gltf-progressive/src/lods.promise.d.ts +36 -0
  8. package/dist/dev/libs/gltf-progressive/src/plugins/index.d.ts +2 -0
  9. package/dist/dev/libs/gltf-progressive/src/plugins/modelviewer.d.ts +1 -0
  10. package/dist/dev/libs/gltf-progressive/src/plugins/plugin.d.ts +12 -0
  11. package/dist/dev/libs/gltf-progressive/src/utils.d.ts +5 -0
  12. package/dist/dev/libs/gltf-progressive/src/utils.internal.d.ts +21 -0
  13. package/dist/dev/libs/gltf-progressive/src/version.d.ts +1 -0
  14. package/dist/dev/libs/gltf-progressive/src/worker/index.d.ts +1 -0
  15. package/dist/dev/libs/gltf-progressive/src/worker/loader.mainthread.d.ts +44 -0
  16. package/dist/dev/libs/gltf-progressive/vite.config.d.ts +2 -0
  17. package/dist/dev/main.d.ts +3 -0
  18. package/dist/{stories/device-viewer → dev/src}/amr.d.ts +22 -2
  19. package/dist/{stories/device-viewer → dev/src}/index.stories.d.ts +1 -2
  20. package/dist/{stories/device-viewer → dev/src}/scene.d.ts +3 -5
  21. package/dist/{stories/device-viewer → dev/src}/slot.d.ts +1 -0
  22. package/dist/shop-components.cjs +103 -193
  23. package/dist/shop-components.mjs +3234 -3705
  24. package/package.json +6 -9
  25. package/dist/stories/cropper/index.d.ts +0 -67
  26. package/dist/stories/cropper/index.stories.d.ts +0 -11
  27. package/dist/stories/device-viewer/index.d.ts +0 -84
  28. package/dist/stories/device-viewer/lines.d.ts +0 -36
  29. package/dist/stories/devices/index.d.ts +0 -5
  30. package/dist/stories/devices/index.stories.d.ts +0 -13
  31. package/dist/stories/devices/src/connector.d.ts +0 -8
  32. package/dist/stories/devices/src/constraints/constraint.d.ts +0 -16
  33. package/dist/stories/devices/src/constraints/same-device-constraint.d.ts +0 -9
  34. package/dist/stories/devices/src/constraints/single-connection-constraint.d.ts +0 -9
  35. package/dist/stories/devices/src/device.d.ts +0 -11
  36. package/dist/stories/devices/src/pin.d.ts +0 -43
  37. package/dist/stories/main.d.ts +0 -3
  38. package/dist/stories/plugin.d.ts +0 -5
  39. package/dist/stories/plugins/change-slot/index.d.ts +0 -0
  40. package/dist/stories/step-viewer/index.d.ts +0 -17
  41. package/dist/stories/step-viewer/index.stories.d.ts +0 -19
  42. /package/dist/{stories/main → dev}/index.d.ts +0 -0
  43. /package/dist/{stories → dev/libs}/sglb/index.d.ts +0 -0
  44. /package/dist/{stories → dev/libs}/utils/index.d.ts +0 -0
  45. /package/dist/{stories/device-viewer → dev/src}/assembly.d.ts +0 -0
  46. /package/dist/{stories/device-viewer → dev/src}/belt.d.ts +0 -0
  47. /package/dist/{stories/device-viewer → dev/src}/dimension/index.d.ts +0 -0
  48. /package/dist/{stories/device-viewer → dev/src}/dimension/line3.d.ts +0 -0
  49. /package/dist/{stories/device-viewer → dev/src}/dimension/size-box.d.ts +0 -0
  50. /package/dist/{stories/device-viewer → dev/src}/dimension/size-line.d.ts +0 -0
  51. /package/dist/{stories/device-viewer → dev/src}/goods-box.d.ts +0 -0
  52. /package/dist/{stories/device-viewer → dev/src}/group-roller.d.ts +0 -0
  53. /package/dist/{stories/device-viewer → dev/src}/libs/BVH/index.d.ts +0 -0
  54. /package/dist/{stories/device-viewer → dev/src}/libs/gizmo/gizmo.d.ts +0 -0
  55. /package/dist/{stories/device-viewer → dev/src}/libs/progress-shadow/ProgressiveShadows.d.ts +0 -0
  56. /package/dist/{stories/device-viewer → dev/src}/logo.d.ts +0 -0
  57. /package/dist/{stories/device-viewer → dev/src}/main.d.ts +0 -0
  58. /package/dist/{stories/device-viewer → dev/src}/mechanism/mechanism.d.ts +0 -0
  59. /package/dist/{stories/device-viewer → dev/src}/outerline.d.ts +0 -0
  60. /package/dist/{stories/device-viewer → dev/src}/pin/pin.d.ts +0 -0
  61. /package/dist/{stories/device-viewer → dev/src}/roller.d.ts +0 -0
  62. /package/dist/{stories/device-viewer → dev/src}/row.d.ts +0 -0
  63. /package/dist/{stories/device-viewer → dev/src}/slot/slot-item.d.ts +0 -0
  64. /package/dist/{stories/device-viewer → dev/src}/sound.d.ts +0 -0
  65. /package/dist/{stories/device-viewer → dev/src}/text2.d.ts +0 -0
  66. /package/dist/{stories/device-viewer → dev/src}/text3.d.ts +0 -0
  67. /package/dist/{stories/device-viewer → dev/src}/ui/camera-position.d.ts +0 -0
  68. /package/dist/{stories/device-viewer → dev/src}/ui/right-menu.d.ts +0 -0
  69. /package/dist/{stories/device-viewer → dev/src}/utils/geometory.d.ts +0 -0
  70. /package/dist/{stories/device-viewer → dev/src}/utils/index.d.ts +0 -0
  71. /package/dist/{stories/device-viewer → dev/src}/worker/generate-mesh-bvh-worker.d.ts +0 -0
  72. /package/dist/{stories/device-viewer → dev/src}/worker/generateAsync.worker.d.ts +0 -0
  73. /package/dist/{stories/device-viewer → dev/src}/worker/path-tracing-scene-worker.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";var on=Object.create;var xi=Object.defineProperty;var an=Object.getOwnPropertyDescriptor;var ln=Object.getOwnPropertyNames;var cn=Object.getPrototypeOf,un=Object.prototype.hasOwnProperty;var hn=(r,e,t)=>e in r?xi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fn=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ln(e))!un.call(r,s)&&s!==t&&xi(r,s,{get:()=>e[s],enumerable:!(i=an(e,s))||i.enumerable});return r};var dn=(r,e,t)=>(t=r!=null?on(cn(r)):{},fn(e||!r||!r.__esModule?xi(t,"default",{value:r,enumerable:!0}):t,r));var D=(r,e,t)=>(hn(r,typeof e!="symbol"?e+"":e,t),t),Ts=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var z=(r,e,t)=>(Ts(r,e,"read from private field"),t?t.call(r):e.get(r)),we=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},ue=(r,e,t,i)=>(Ts(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("three"),pn=require("three/examples/jsm/loaders/HDRLoader.js"),Ss=require("three/examples/jsm/postprocessing/RenderPass"),Cs=require("three/examples/jsm/postprocessing/OutlinePass"),mn=require("three/examples/jsm/postprocessing/ShaderPass"),gn=require("three/examples/jsm/shaders/FXAAShader"),vn=require("three/examples/jsm/postprocessing/UnrealBloomPass"),_n=require("three/examples/jsm/controls/OrbitControls"),yn=require("three/examples/jsm/postprocessing/OutputPass"),xn=require("three/examples/jsm/postprocessing/EffectComposer"),fe=require("three/examples/jsm/renderers/CSS2DRenderer"),wn=require("three/examples/jsm/loaders/FontLoader"),cs=require("three/examples/jsm/loaders/GLTFLoader.js"),bn=require("three/examples/jsm/libs/meshopt_decoder.module.js"),An=require("three/examples/jsm/loaders/DRACOLoader.js"),Tn=require("three/examples/jsm/loaders/GLTFLoader"),Sn=require("three/examples/jsm/loaders/DRACOLoader"),Cn=require("three/examples/jsm/exporters/DRACOExporter"),Mn=require("three/examples/jsm/exporters/GLTFExporter"),ii=require("lit"),Pn=require("three/examples/jsm/lines/Line2.js"),Rn=require("three/examples/jsm/lines/LineMaterial.js"),Ms=require("three/examples/jsm/lines/LineGeometry.js"),In=require("three/examples/jsm/renderers/CSS3DRenderer");require("three/examples/jsm/utils/BufferGeometryUtils");const Ce=require("three-mesh-bvh"),ot=require("three/examples/jsm/postprocessing/Pass.js");var at=typeof document<"u"?document.currentScript:null;function Sr(r,e,t=0){if(r.isInterleavedBufferAttribute){const i=r.itemSize;for(let s=0,a=r.count;s<a;s++){const o=s+t;e.setX(o,r.getX(s)),i>=2&&e.setY(o,r.getY(s)),i>=3&&e.setZ(o,r.getZ(s)),i>=4&&e.setW(o,r.getW(s))}}else{const i=e.array,s=i.constructor,a=i.BYTES_PER_ELEMENT*r.itemSize*t;new s(i.buffer,a,r.array.length).set(r.array)}}function Mt(r,e=null){const t=r.array.constructor,i=r.normalized,s=r.itemSize,a=e===null?r.count:e;return new f.BufferAttribute(new t(s*a),s,i)}function Ke(r,e){if(!r&&!e)return!0;if(!!r!=!!e)return!1;const t=r.count===e.count,i=r.normalized===e.normalized,s=r.array.constructor===e.array.constructor,a=r.itemSize===e.itemSize;return!(!t||!i||!s||!a)}function En(r){const e=r[0].index!==null,t=new Set(Object.keys(r[0].attributes));if(!r[0].getAttribute("position"))throw new Error("StaticGeometryGenerator: position attribute is required.");for(let i=0;i<r.length;++i){const s=r[i];let a=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.');a++}if(a!==t.size)throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.")}}function Dn(r){let e=0;for(let t=0,i=r.length;t<i;t++)e+=r[t].getIndex().count;return e}function Ln(r){let e=0;for(let t=0,i=r.length;t<i;t++)e+=r[t].getAttribute("position").count;return e}function Fn(r,e,t){r.index&&r.index.count!==e&&r.setIndex(null);const i=r.attributes;for(const s in i)i[s].count!==t&&r.deleteAttribute(s)}function Bn(r,e={},t=new f.BufferGeometry){const{useGroups:i=!1,forceUpdate:s=!1,skipAssigningAttributes:a=[],overwriteIndex:o=!0}=e;En(r);const c=r[0].index!==null,u=c?Dn(r):-1,p=Ln(r);if(Fn(t,u,p),i){let n=0;for(let l=0,h=r.length;l<h;l++){const g=r[l];let _;c?_=g.getIndex().count:_=g.getAttribute("position").count,t.addGroup(n,_,l),n+=_}}if(c){let n=!1;if(t.index||(t.setIndex(new f.BufferAttribute(new Uint32Array(u),1,!1)),n=!0),n||o){let l=0,h=0;const g=t.getIndex();for(let _=0,d=r.length;_<d;_++){const v=r[_],y=v.getIndex();if(!(!s&&!n&&a[_]))for(let w=0;w<y.count;++w)g.setX(l+w,y.getX(w)+h);l+=y.count,h+=v.getAttribute("position").count}}}const m=Object.keys(r[0].attributes);for(let n=0,l=m.length;n<l;n++){let h=!1;const g=m[n];if(!t.getAttribute(g)){const v=r[0].getAttribute(g);t.setAttribute(g,Mt(v,p)),h=!0}let _=0;const d=t.getAttribute(g);for(let v=0,y=r.length;v<y;v++){const x=r[v],w=!s&&!h&&a[v],b=x.getAttribute(g);w||Sr(b,d,_),_+=b.count}}}function kn(r,e,t){const i=r.index,a=r.attributes.position.count,o=i?i.count:a;let c=r.groups;c.length===0&&(c=[{count:o,start:0,materialIndex:0}]);let u=r.getAttribute("materialIndex");if(!u||u.count!==a){let m;t.length<=255?m=new Uint8Array(a):m=new Uint16Array(a),u=new f.BufferAttribute(m,1,!1),r.deleteAttribute("materialIndex"),r.setAttribute("materialIndex",u)}const p=u.array;for(let m=0;m<c.length;m++){const n=c[m],l=n.start,h=n.count,g=Math.min(h,o-l),_=Array.isArray(e)?e[n.materialIndex]:e,d=t.indexOf(_);for(let v=0;v<g;v++){let y=l+v;i&&(y=i.getX(y)),p[y]=d}}}function On(r,e){if(!r.index){const t=r.attributes.position.count,i=new Array(t);for(let s=0;s<t;s++)i[s]=s;r.setIndex(i)}if(!r.attributes.normal&&e&&e.includes("normal")&&r.computeVertexNormals(),!r.attributes.uv&&e&&e.includes("uv")){const t=r.attributes.position.count;r.setAttribute("uv",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!r.attributes.uv2&&e&&e.includes("uv2")){const t=r.attributes.position.count;r.setAttribute("uv2",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!r.attributes.tangent&&e&&e.includes("tangent"))if(r.attributes.uv&&r.attributes.normal)r.computeTangents();else{const t=r.attributes.position.count;r.setAttribute("tangent",new f.BufferAttribute(new Float32Array(t*4),4,!1))}if(!r.attributes.color&&e&&e.includes("color")){const t=r.attributes.position.count,i=new Float32Array(t*4);i.fill(1),r.setAttribute("color",new f.BufferAttribute(i,4))}}function us(r){let e=0;if(r.byteLength!==0){const t=new Uint8Array(r);for(let i=0;i<r.byteLength;i++){const s=t[i];e=(e<<5)-e+s,e|=0}}return e}function Ps(r){let e=r.uuid;const t=Object.values(r.attributes);r.index&&(t.push(r.index),e+=`index|${r.index.version}`);const i=Object.keys(t).sort();for(const s of i){const a=t[s];e+=`${s}_${a.version}|`}return e}function Rs(r){const e=r.skeleton;return e?(e.boneTexture||e.computeBoneTexture(),`${us(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`):null}class zn{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=Ps(t),this.primitiveCount=i,this.skeletonHash=Rs(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===Ps(t)&&this.skeletonHash===Rs(e)&&this.primitiveCount===i)}}const De=new f.Vector3,Le=new f.Vector3,Fe=new f.Vector3,Is=new f.Vector4,Bt=new f.Vector3,wi=new f.Vector3,Es=new f.Vector4,Ds=new f.Vector4,kt=new f.Matrix4,Ls=new f.Matrix4;function Fs(r,e,t){const i=r.skeleton,s=r.geometry,a=i.bones,o=i.boneInverses;Es.fromBufferAttribute(s.attributes.skinIndex,e),Ds.fromBufferAttribute(s.attributes.skinWeight,e),kt.elements.fill(0);for(let c=0;c<4;c++){const u=Ds.getComponent(c);if(u!==0){const p=Es.getComponent(c);Ls.multiplyMatrices(a[p].matrixWorld,o[p]),Vn(kt,Ls,u)}}return kt.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(kt),t}function bi(r,e,t,i,s){Bt.set(0,0,0);for(let a=0,o=r.length;a<o;a++){const c=e[a],u=r[a];c!==0&&(wi.fromBufferAttribute(u,i),t?Bt.addScaledVector(wi,c):Bt.addScaledVector(wi.sub(s),c))}s.add(Bt)}function Vn(r,e,t){const i=r.elements,s=e.elements;for(let a=0,o=s.length;a<o;a++)i[a]+=s[a]*t}function Un(r){const{index:e,attributes:t}=r;if(e)for(let i=0,s=e.count;i<s;i+=3){const a=e.getX(i),o=e.getX(i+2);e.setX(i,o),e.setX(i+2,a)}else for(const i in t){const s=t[i],a=s.itemSize;for(let o=0,c=s.count;o<c;o+=3)for(let u=0;u<a;u++){const p=s.getComponent(o,u),m=s.getComponent(o+2,u);s.setComponent(o,u,m),s.setComponent(o+2,u,p)}}return r}function Hn(r,e={},t=new f.BufferGeometry){e={applyWorldTransforms:!0,attributes:[],...e};const i=r.geometry,s=e.applyWorldTransforms,a=e.attributes.includes("normal"),o=e.attributes.includes("tangent"),c=i.attributes,u=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()),u.position||t.setAttribute("position",Mt(c.position)),a&&!u.normal&&c.normal&&t.setAttribute("normal",Mt(c.normal)),o&&!u.tangent&&c.tangent&&t.setAttribute("tangent",Mt(c.tangent)),Ke(i.index,t.index),Ke(c.position,u.position),a&&Ke(c.normal,u.normal),o&&Ke(c.tangent,u.tangent);const p=c.position,m=a?c.normal:null,n=o?c.tangent:null,l=i.morphAttributes.position,h=i.morphAttributes.normal,g=i.morphAttributes.tangent,_=i.morphTargetsRelative,d=r.morphTargetInfluences,v=new f.Matrix3;v.getNormalMatrix(r.matrixWorld),i.index&&t.index.array.set(i.index.array);for(let y=0,x=c.position.count;y<x;y++)De.fromBufferAttribute(p,y),m&&Le.fromBufferAttribute(m,y),n&&(Is.fromBufferAttribute(n,y),Fe.fromBufferAttribute(n,y)),d&&(l&&bi(l,d,_,y,De),h&&bi(h,d,_,y,Le),g&&bi(g,d,_,y,Fe)),r.isSkinnedMesh&&(r.applyBoneTransform(y,De),m&&Fs(r,y,Le),n&&Fs(r,y,Fe)),s&&De.applyMatrix4(r.matrixWorld),u.position.setXYZ(y,De.x,De.y,De.z),m&&(s&&Le.applyNormalMatrix(v),u.normal.setXYZ(y,Le.x,Le.y,Le.z)),n&&(s&&Fe.transformDirection(r.matrixWorld),u.tangent.setXYZW(y,Fe.x,Fe.y,Fe.z,Is.w));for(const y in e.attributes){const x=e.attributes[y];x==="position"||x==="tangent"||x==="normal"||!(x in c)||(u[x]||t.setAttribute(x,Mt(c[x])),Ke(c[x],u[x]),Sr(c[x],u[x]))}return r.matrixWorld.determinant()<0&&Un(t),t}class Nn extends f.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new zn}isCompatible(e,t){const i=e.geometry;for(let s=0;s<t.length;s++){const a=t[s],o=i.attributes[a],c=this.attributes[a];if(o&&!Ke(o,c))return!1}return!0}updateFrom(e,t){const i=this._diff;return i.didChange(e)?(Hn(e,t,this),i.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}}const Ni=0,Cr=1,Mr=2;function Wn(r,e){for(let t=0,i=r.length;t<i;t++)r[t].traverseVisible(a=>{a.isMesh&&e(a)})}function Gn(r){const e=[];for(let t=0,i=r.length;t<i;t++){const s=r[t];Array.isArray(s.material)?e.push(...s.material):e.push(s.material)}return e}function qn(r,e,t){if(r.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 Bn(r,t,e);for(const i in e.attributes)e.attributes[i].needsUpdate=!0}class jn{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 Wn(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 a=0,o=t.length;a<o;a++){const c=t[a],u=c.uuid;i.delete(u);let p=e.get(u);(!p||!p.isCompatible(c,this.attributes))&&(p&&p.dispose(),p=new Nn,e.set(u,p)),p.updateFrom(c,s)&&this.generateMissingAttributes&&On(p,this.attributes)}i.forEach(a=>{e.delete(a)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new f.BufferGeometry){const{useGroups:t,overwriteIndex:i,_intermediateGeometry:s,_geometryMergeSets:a}=this,o=this._getMeshes(),c=[],u=[],p=a.get(e)||[];this._updateIntermediateGeometries();let m=!1;o.length!==p.length&&(m=!0);for(let l=0,h=o.length;l<h;l++){const g=o[l],_=s.get(g.uuid);u.push(_);const d=p[l];!d||d.uuid!==_.uuid?(c.push(!1),m=!0):d.version!==_.version?c.push(!1):c.push(!0)}qn(u,e,{useGroups:t,forceUpdate:m,skipAssigningAttributes:c,overwriteIndex:i}),m&&e.dispose(),a.set(e,u.map(l=>({version:l.version,uuid:l.uuid})));let n=Ni;return m?n=Mr:c.includes(!1)&&(n=Cr),{changeType:n,materials:Gn(o),geometry:e}}}function Yn(r){const e=new Set;for(let t=0,i=r.length;t<i;t++){const s=r[t];for(const a in s){const o=s[a];o&&o.isTexture&&e.add(o)}}return Array.from(e)}function $n(r){const e=[],t=new Set;for(let s=0,a=r.length;s<a;s++)r[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,a)=>s.uuid<a.uuid?1:s.uuid>a.uuid?-1:0);return{lights:e,iesTextures:i}}class Qn{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 jn(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,a=t.objects;t.attributes=s,a.forEach(n=>{n.traverse(l=>{l.isSkinnedMesh&&l.skeleton&&l.skeleton.update()})});const o=t.generate(i),c=o.materials,u=Yn(c),{lights:p,iesTextures:m}=$n(a);if(o.changeType!==Ni&&kn(i,c,c),this.generateBVH){if(this.bvh instanceof Promise)throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");if(o.changeType===Mr){const n={strategy:Ce.SAH,maxLeafTris:1,indirect:!0,onProgress:e,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(i,n):this.bvh=new Ce.MeshBVH(i,n)}else o.changeType===Cr&&this.bvh.refit()}return{bvhChanged:o.changeType!==Ni,bvh:this.bvh,lights:p,iesTextures:m,geometry:i,materials:c,textures:u,objects:a}}}class hs 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 Zn extends hs{constructor(e){super({blending:f.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
1
+ "use strict";var Wr=Object.create;var pi=Object.defineProperty;var Gr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Yr=Object.prototype.hasOwnProperty;var Qr=(n,e,t)=>e in n?pi(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Zr=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qr(e))!Yr.call(n,s)&&s!==t&&pi(n,s,{get:()=>e[s],enumerable:!(i=Gr(e,s))||i.enumerable});return n};var Xr=(n,e,t)=>(t=n!=null?Wr(jr(n)):{},Zr(e||!n||!n.__esModule?pi(t,"default",{value:n,enumerable:!0}):t,n));var L=(n,e,t)=>(Qr(n,typeof e!="symbol"?e+"":e,t),t),ps=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var z=(n,e,t)=>(ps(n,e,"read from private field"),t?t.call(n):e.get(n)),be=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},ue=(n,e,t,i)=>(ps(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("three"),Kr=require("three/examples/jsm/loaders/HDRLoader.js"),ms=require("three/examples/jsm/postprocessing/RenderPass"),gs=require("three/examples/jsm/postprocessing/OutlinePass"),Jr=require("three/examples/jsm/postprocessing/ShaderPass"),$r=require("three/examples/jsm/shaders/FXAAShader"),en=require("three/examples/jsm/postprocessing/UnrealBloomPass"),tn=require("three/examples/jsm/controls/OrbitControls"),sn=require("three/examples/jsm/postprocessing/OutputPass"),rn=require("three/examples/jsm/postprocessing/EffectComposer"),fe=require("three/examples/jsm/renderers/CSS2DRenderer"),nn=require("three/examples/jsm/loaders/FontLoader"),is=require("three/examples/jsm/loaders/GLTFLoader.js"),on=require("three/examples/jsm/libs/meshopt_decoder.module.js"),an=require("three/examples/jsm/loaders/DRACOLoader.js"),ln=require("three/examples/jsm/loaders/GLTFLoader"),cn=require("three/examples/jsm/loaders/DRACOLoader"),un=require("three/examples/jsm/exporters/DRACOExporter"),hn=require("three/examples/jsm/exporters/GLTFExporter"),fn=require("three/examples/jsm/utils/SkeletonUtils.js"),dn=require("three/examples/jsm/lines/Line2.js"),pn=require("three/examples/jsm/lines/LineMaterial.js"),vs=require("three/examples/jsm/lines/LineGeometry.js"),mn=require("three/examples/jsm/renderers/CSS3DRenderer");require("three/examples/jsm/utils/BufferGeometryUtils");const Ce=require("three-mesh-bvh"),nt=require("three/examples/jsm/postprocessing/Pass.js");var ot=typeof document<"u"?document.currentScript:null;function gn(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const vn=gn(fn);function ur(n,e,t=0){if(n.isInterleavedBufferAttribute){const i=n.itemSize;for(let s=0,a=n.count;s<a;s++){const o=s+t;e.setX(o,n.getX(s)),i>=2&&e.setY(o,n.getY(s)),i>=3&&e.setZ(o,n.getZ(s)),i>=4&&e.setW(o,n.getW(s))}}else{const i=e.array,s=i.constructor,a=i.BYTES_PER_ELEMENT*n.itemSize*t;new s(i.buffer,a,n.array.length).set(n.array)}}function St(n,e=null){const t=n.array.constructor,i=n.normalized,s=n.itemSize,a=e===null?n.count:e;return new d.BufferAttribute(new t(s*a),s,i)}function Ke(n,e){if(!n&&!e)return!0;if(!!n!=!!e)return!1;const t=n.count===e.count,i=n.normalized===e.normalized,s=n.array.constructor===e.array.constructor,a=n.itemSize===e.itemSize;return!(!t||!i||!s||!a)}function _n(n){const e=n[0].index!==null,t=new Set(Object.keys(n[0].attributes));if(!n[0].getAttribute("position"))throw new Error("StaticGeometryGenerator: position attribute is required.");for(let i=0;i<n.length;++i){const s=n[i];let a=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.');a++}if(a!==t.size)throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.")}}function yn(n){let e=0;for(let t=0,i=n.length;t<i;t++)e+=n[t].getIndex().count;return e}function xn(n){let e=0;for(let t=0,i=n.length;t<i;t++)e+=n[t].getAttribute("position").count;return e}function wn(n,e,t){n.index&&n.index.count!==e&&n.setIndex(null);const i=n.attributes;for(const s in i)i[s].count!==t&&n.deleteAttribute(s)}function bn(n,e={},t=new d.BufferGeometry){const{useGroups:i=!1,forceUpdate:s=!1,skipAssigningAttributes:a=[],overwriteIndex:o=!0}=e;_n(n);const c=n[0].index!==null,u=c?yn(n):-1,f=xn(n);if(wn(t,u,f),i){let r=0;for(let l=0,h=n.length;l<h;l++){const g=n[l];let _;c?_=g.getIndex().count:_=g.getAttribute("position").count,t.addGroup(r,_,l),r+=_}}if(c){let r=!1;if(t.index||(t.setIndex(new d.BufferAttribute(new Uint32Array(u),1,!1)),r=!0),r||o){let l=0,h=0;const g=t.getIndex();for(let _=0,m=n.length;_<m;_++){const v=n[_],y=v.getIndex();if(!(!s&&!r&&a[_]))for(let w=0;w<y.count;++w)g.setX(l+w,y.getX(w)+h);l+=y.count,h+=v.getAttribute("position").count}}}const p=Object.keys(n[0].attributes);for(let r=0,l=p.length;r<l;r++){let h=!1;const g=p[r];if(!t.getAttribute(g)){const v=n[0].getAttribute(g);t.setAttribute(g,St(v,f)),h=!0}let _=0;const m=t.getAttribute(g);for(let v=0,y=n.length;v<y;v++){const x=n[v],w=!s&&!h&&a[v],b=x.getAttribute(g);w||ur(b,m,_),_+=b.count}}}function An(n,e,t){const i=n.index,a=n.attributes.position.count,o=i?i.count:a;let c=n.groups;c.length===0&&(c=[{count:o,start:0,materialIndex:0}]);let u=n.getAttribute("materialIndex");if(!u||u.count!==a){let p;t.length<=255?p=new Uint8Array(a):p=new Uint16Array(a),u=new d.BufferAttribute(p,1,!1),n.deleteAttribute("materialIndex"),n.setAttribute("materialIndex",u)}const f=u.array;for(let p=0;p<c.length;p++){const r=c[p],l=r.start,h=r.count,g=Math.min(h,o-l),_=Array.isArray(e)?e[r.materialIndex]:e,m=t.indexOf(_);for(let v=0;v<g;v++){let y=l+v;i&&(y=i.getX(y)),f[y]=m}}}function Tn(n,e){if(!n.index){const t=n.attributes.position.count,i=new Array(t);for(let s=0;s<t;s++)i[s]=s;n.setIndex(i)}if(!n.attributes.normal&&e&&e.includes("normal")&&n.computeVertexNormals(),!n.attributes.uv&&e&&e.includes("uv")){const t=n.attributes.position.count;n.setAttribute("uv",new d.BufferAttribute(new Float32Array(t*2),2,!1))}if(!n.attributes.uv2&&e&&e.includes("uv2")){const t=n.attributes.position.count;n.setAttribute("uv2",new d.BufferAttribute(new Float32Array(t*2),2,!1))}if(!n.attributes.tangent&&e&&e.includes("tangent"))if(n.attributes.uv&&n.attributes.normal)n.computeTangents();else{const t=n.attributes.position.count;n.setAttribute("tangent",new d.BufferAttribute(new Float32Array(t*4),4,!1))}if(!n.attributes.color&&e&&e.includes("color")){const t=n.attributes.position.count,i=new Float32Array(t*4);i.fill(1),n.setAttribute("color",new d.BufferAttribute(i,4))}}function ss(n){let e=0;if(n.byteLength!==0){const t=new Uint8Array(n);for(let i=0;i<n.byteLength;i++){const s=t[i];e=(e<<5)-e+s,e|=0}}return e}function _s(n){let e=n.uuid;const t=Object.values(n.attributes);n.index&&(t.push(n.index),e+=`index|${n.index.version}`);const i=Object.keys(t).sort();for(const s of i){const a=t[s];e+=`${s}_${a.version}|`}return e}function ys(n){const e=n.skeleton;return e?(e.boneTexture||e.computeBoneTexture(),`${ss(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`):null}class Sn{constructor(e=null){this.matrixWorld=new d.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=_s(t),this.primitiveCount=i,this.skeletonHash=ys(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===_s(t)&&this.skeletonHash===ys(e)&&this.primitiveCount===i)}}const De=new d.Vector3,Le=new d.Vector3,Ee=new d.Vector3,xs=new d.Vector4,Et=new d.Vector3,mi=new d.Vector3,ws=new d.Vector4,bs=new d.Vector4,Ft=new d.Matrix4,As=new d.Matrix4;function Ts(n,e,t){const i=n.skeleton,s=n.geometry,a=i.bones,o=i.boneInverses;ws.fromBufferAttribute(s.attributes.skinIndex,e),bs.fromBufferAttribute(s.attributes.skinWeight,e),Ft.elements.fill(0);for(let c=0;c<4;c++){const u=bs.getComponent(c);if(u!==0){const f=ws.getComponent(c);As.multiplyMatrices(a[f].matrixWorld,o[f]),Mn(Ft,As,u)}}return Ft.multiply(n.bindMatrix).premultiply(n.bindMatrixInverse),t.transformDirection(Ft),t}function gi(n,e,t,i,s){Et.set(0,0,0);for(let a=0,o=n.length;a<o;a++){const c=e[a],u=n[a];c!==0&&(mi.fromBufferAttribute(u,i),t?Et.addScaledVector(mi,c):Et.addScaledVector(mi.sub(s),c))}s.add(Et)}function Mn(n,e,t){const i=n.elements,s=e.elements;for(let a=0,o=s.length;a<o;a++)i[a]+=s[a]*t}function Cn(n){const{index:e,attributes:t}=n;if(e)for(let i=0,s=e.count;i<s;i+=3){const a=e.getX(i),o=e.getX(i+2);e.setX(i,o),e.setX(i+2,a)}else for(const i in t){const s=t[i],a=s.itemSize;for(let o=0,c=s.count;o<c;o+=3)for(let u=0;u<a;u++){const f=s.getComponent(o,u),p=s.getComponent(o+2,u);s.setComponent(o,u,p),s.setComponent(o+2,u,f)}}return n}function In(n,e={},t=new d.BufferGeometry){e={applyWorldTransforms:!0,attributes:[],...e};const i=n.geometry,s=e.applyWorldTransforms,a=e.attributes.includes("normal"),o=e.attributes.includes("tangent"),c=i.attributes,u=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()),u.position||t.setAttribute("position",St(c.position)),a&&!u.normal&&c.normal&&t.setAttribute("normal",St(c.normal)),o&&!u.tangent&&c.tangent&&t.setAttribute("tangent",St(c.tangent)),Ke(i.index,t.index),Ke(c.position,u.position),a&&Ke(c.normal,u.normal),o&&Ke(c.tangent,u.tangent);const f=c.position,p=a?c.normal:null,r=o?c.tangent:null,l=i.morphAttributes.position,h=i.morphAttributes.normal,g=i.morphAttributes.tangent,_=i.morphTargetsRelative,m=n.morphTargetInfluences,v=new d.Matrix3;v.getNormalMatrix(n.matrixWorld),i.index&&t.index.array.set(i.index.array);for(let y=0,x=c.position.count;y<x;y++)De.fromBufferAttribute(f,y),p&&Le.fromBufferAttribute(p,y),r&&(xs.fromBufferAttribute(r,y),Ee.fromBufferAttribute(r,y)),m&&(l&&gi(l,m,_,y,De),h&&gi(h,m,_,y,Le),g&&gi(g,m,_,y,Ee)),n.isSkinnedMesh&&(n.applyBoneTransform(y,De),p&&Ts(n,y,Le),r&&Ts(n,y,Ee)),s&&De.applyMatrix4(n.matrixWorld),u.position.setXYZ(y,De.x,De.y,De.z),p&&(s&&Le.applyNormalMatrix(v),u.normal.setXYZ(y,Le.x,Le.y,Le.z)),r&&(s&&Ee.transformDirection(n.matrixWorld),u.tangent.setXYZW(y,Ee.x,Ee.y,Ee.z,xs.w));for(const y in e.attributes){const x=e.attributes[y];x==="position"||x==="tangent"||x==="normal"||!(x in c)||(u[x]||t.setAttribute(x,St(c[x])),Ke(c[x],u[x]),ur(c[x],u[x]))}return n.matrixWorld.determinant()<0&&Cn(t),t}class Rn extends d.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new Sn}isCompatible(e,t){const i=e.geometry;for(let s=0;s<t.length;s++){const a=t[s],o=i.attributes[a],c=this.attributes[a];if(o&&!Ke(o,c))return!1}return!0}updateFrom(e,t){const i=this._diff;return i.didChange(e)?(In(e,t,this),i.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}}const Bi=0,hr=1,fr=2;function Pn(n,e){for(let t=0,i=n.length;t<i;t++)n[t].traverseVisible(a=>{a.isMesh&&e(a)})}function Dn(n){const e=[];for(let t=0,i=n.length;t<i;t++){const s=n[t];Array.isArray(s.material)?e.push(...s.material):e.push(s.material)}return e}function Ln(n,e,t){if(n.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 d.BufferAttribute(new Float32Array(0),4,!1))}else bn(n,t,e);for(const i in e.attributes)e.attributes[i].needsUpdate=!0}class En{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 d.MeshBasicMaterial,t=new d.BufferGeometry;t.setAttribute("position",new d.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new d.Mesh(t,e)}return this._dummyMesh}_getMeshes(){const e=[];return Pn(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 a=0,o=t.length;a<o;a++){const c=t[a],u=c.uuid;i.delete(u);let f=e.get(u);(!f||!f.isCompatible(c,this.attributes))&&(f&&f.dispose(),f=new Rn,e.set(u,f)),f.updateFrom(c,s)&&this.generateMissingAttributes&&Tn(f,this.attributes)}i.forEach(a=>{e.delete(a)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new d.BufferGeometry){const{useGroups:t,overwriteIndex:i,_intermediateGeometry:s,_geometryMergeSets:a}=this,o=this._getMeshes(),c=[],u=[],f=a.get(e)||[];this._updateIntermediateGeometries();let p=!1;o.length!==f.length&&(p=!0);for(let l=0,h=o.length;l<h;l++){const g=o[l],_=s.get(g.uuid);u.push(_);const m=f[l];!m||m.uuid!==_.uuid?(c.push(!1),p=!0):m.version!==_.version?c.push(!1):c.push(!0)}Ln(u,e,{useGroups:t,forceUpdate:p,skipAssigningAttributes:c,overwriteIndex:i}),p&&e.dispose(),a.set(e,u.map(l=>({version:l.version,uuid:l.uuid})));let r=Bi;return p?r=fr:c.includes(!1)&&(r=hr),{changeType:r,materials:Dn(o),geometry:e}}}function Fn(n){const e=new Set;for(let t=0,i=n.length;t<i;t++){const s=n[t];for(const a in s){const o=s[a];o&&o.isTexture&&e.add(o)}}return Array.from(e)}function Bn(n){const e=[],t=new Set;for(let s=0,a=n.length;s<a;s++)n[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,a)=>s.uuid<a.uuid?1:s.uuid>a.uuid?-1:0);return{lights:e,iesTextures:i}}class kn{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 d.BufferGeometry,this.staticGeometryGenerator=new En(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,a=t.objects;t.attributes=s,a.forEach(r=>{r.traverse(l=>{l.isSkinnedMesh&&l.skeleton&&l.skeleton.update()})});const o=t.generate(i),c=o.materials,u=Fn(c),{lights:f,iesTextures:p}=Bn(a);if(o.changeType!==Bi&&An(i,c,c),this.generateBVH){if(this.bvh instanceof Promise)throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");if(o.changeType===fr){const r={strategy:Ce.SAH,maxLeafTris:1,indirect:!0,onProgress:e,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(i,r):this.bvh=new Ce.MeshBVH(i,r)}else o.changeType===hr&&this.bvh.refit()}return{bvhChanged:o.changeType!==Bi,bvh:this.bvh,lights:f,iesTextures:p,geometry:i,materials:c,textures:u,objects:a}}}class rs extends d.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 On extends rs{constructor(e){super({blending:d.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
2
2
 
3
3
  varying vec2 vUv;
4
4
 
@@ -35,7 +35,7 @@
35
35
 
36
36
  }
37
37
 
38
- }`}),this.setValues(e)}}function Ot(r=1){let e="uint";return r>1&&(e="uvec"+r),`
38
+ }`}),this.setValues(e)}}function Bt(n=1){let e="uint";return n>1&&(e="uvec"+n),`
39
39
  ${e} sobolReverseBits( ${e} x ) {
40
40
 
41
41
  x = ( ( ( x & 0xaaaaaaaau ) >> 1 ) | ( ( x & 0x55555555u ) << 1 ) );
@@ -70,7 +70,7 @@
70
70
  return x;
71
71
 
72
72
  }
73
- `}function zt(r=1){let e="uint",t="float",i="",s=".r",a="1u";return r>1&&(e="uvec"+r,t="vec"+r,i=r+"",r===2?(s=".rg",a="uvec2( 1u, 2u )"):r===3?(s=".rgb",a="uvec3( 1u, 2u, 3u )"):(s="",a="uvec4( 1u, 2u, 3u, 4u )")),`
73
+ `}function kt(n=1){let e="uint",t="float",i="",s=".r",a="1u";return n>1&&(e="uvec"+n,t="vec"+n,i=n+"",n===2?(s=".rg",a="uvec2( 1u, 2u )"):n===3?(s=".rgb",a="uvec3( 1u, 2u, 3u )"):(s="",a="uvec4( 1u, 2u, 3u, 4u )")),`
74
74
 
75
75
  ${t} sobol${i}( int effect ) {
76
76
 
@@ -88,16 +88,16 @@
88
88
  return SOBOL_FACTOR * ${t}( result >> 8 );
89
89
 
90
90
  }
91
- `}const Pr=`
91
+ `}const dr=`
92
92
 
93
93
  // Utils
94
94
  const float SOBOL_FACTOR = 1.0 / 16777216.0;
95
95
  const uint SOBOL_MAX_POINTS = 256u * 256u;
96
96
 
97
- ${Ot(1)}
98
- ${Ot(2)}
99
- ${Ot(3)}
100
- ${Ot(4)}
97
+ ${Bt(1)}
98
+ ${Bt(2)}
99
+ ${Bt(3)}
100
+ ${Bt(4)}
101
101
 
102
102
  uint sobolHash( uint x ) {
103
103
 
@@ -111,7 +111,7 @@
111
111
 
112
112
  }
113
113
 
114
- `,Xn=`
114
+ `,zn=`
115
115
 
116
116
  const uint SOBOL_DIRECTIONS_1[ 32 ] = uint[ 32 ](
117
117
  0x80000000u, 0xc0000000u, 0xa0000000u, 0xf0000000u,
@@ -189,7 +189,7 @@
189
189
 
190
190
  }
191
191
 
192
- `,Kn=`
192
+ `,Vn=`
193
193
 
194
194
  // Seeds
195
195
  uniform sampler2D sobolTexture;
@@ -227,12 +227,12 @@
227
227
 
228
228
  }
229
229
 
230
- ${zt(1)}
231
- ${zt(2)}
232
- ${zt(3)}
233
- ${zt(4)}
230
+ ${kt(1)}
231
+ ${kt(2)}
232
+ ${kt(3)}
233
+ ${kt(4)}
234
234
 
235
- `;class Jn extends hs{constructor(){super({blending:f.NoBlending,uniforms:{resolution:{value:new f.Vector2}},vertexShader:`
235
+ `;class Un extends rs{constructor(){super({blending:d.NoBlending,uniforms:{resolution:{value:new d.Vector2}},vertexShader:`
236
236
 
237
237
  varying vec2 vUv;
238
238
  void main() {
@@ -243,8 +243,8 @@
243
243
  }
244
244
  `,fragmentShader:`
245
245
 
246
- ${Pr}
247
- ${Xn}
246
+ ${dr}
247
+ ${zn}
248
248
 
249
249
  varying vec2 vUv;
250
250
  uniform vec2 resolution;
@@ -254,7 +254,7 @@
254
254
  gl_FragColor = generateSobolPoint( index );
255
255
 
256
256
  }
257
- `})}}class eo{generate(e,t=256){const i=new f.WebGLRenderTarget(t,t,{type:f.FloatType,format:f.RGBAFormat,minFilter:f.NearestFilter,magFilter:f.NearestFilter,generateMipmaps:!1}),s=e.getRenderTarget();e.setRenderTarget(i);const a=new ot.FullScreenQuad(new Jn);return a.material.resolution.set(t,t),a.render(e),e.setRenderTarget(s),a.dispose(),i}}class to extends f.PerspectiveCamera{set bokehSize(e){this.fStop=this.getFocalLength()/e}get bokehSize(){return this.getFocalLength()/this.fStop}constructor(...e){super(...e),this.fStop=1.4,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=25,this.anamorphicRatio=1}copy(e,t){return super.copy(e,t),this.fStop=e.fStop,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio,this}}class io{constructor(){this.bokehSize=0,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=10,this.anamorphicRatio=1}updateFrom(e){e instanceof to?(this.bokehSize=e.bokehSize,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio):(this.bokehSize=0,this.apertureRotation=0,this.apertureBlades=0,this.focusDistance=10,this.anamorphicRatio=1)}}function Ai(r){const e=new Uint16Array(r.length);for(let t=0,i=r.length;t<i;++t)e[t]=f.DataUtils.toHalfFloat(r[t]);return e}function Bs(r,e,t=0,i=r.length){let s=t,a=t+i-1;for(;s<a;){const o=s+a>>1;r[o]<e?s=o+1:a=o}return s-t}function so(r,e,t){return .2126*r+.7152*e+.0722*t}function ro(r,e=f.HalfFloatType){const t=r.clone();t.source=new f.Source({...t.image});const{width:i,height:s,data:a}=t.image;let o=a;if(t.type!==e){e===f.HalfFloatType?o=new Uint16Array(a.length):o=new Float32Array(a.length);let c;a instanceof Int8Array||a instanceof Int16Array||a instanceof Int32Array?c=2**(8*a.BYTES_PER_ELEMENT-1)-1:c=2**(8*a.BYTES_PER_ELEMENT)-1;for(let u=0,p=a.length;u<p;u++){let m=a[u];t.type===f.HalfFloatType&&(m=f.DataUtils.fromHalfFloat(a[u])),t.type!==f.FloatType&&t.type!==f.HalfFloatType&&(m/=c),e===f.HalfFloatType&&(o[u]=f.DataUtils.toHalfFloat(m))}t.image.data=o,t.type=e}if(t.flipY){const c=o;o=o.slice();for(let u=0;u<s;u++)for(let p=0;p<i;p++){const m=s-u-1,n=4*(u*i+p),l=4*(m*i+p);o[l+0]=c[n+0],o[l+1]=c[n+1],o[l+2]=c[n+2],o[l+3]=c[n+3]}t.flipY=!1,t.image.data=o}return t}class no{constructor(){const e=new f.DataTexture(Ai(new Float32Array([0,0,0,0])),1,1);e.type=f.HalfFloatType,e.format=f.RGBAFormat,e.minFilter=f.LinearFilter,e.magFilter=f.LinearFilter,e.wrapS=f.RepeatWrapping,e.wrapT=f.RepeatWrapping,e.generateMipmaps=!1,e.needsUpdate=!0;const t=new f.DataTexture(Ai(new Float32Array([0,1])),1,2);t.type=f.HalfFloatType,t.format=f.RedFormat,t.minFilter=f.LinearFilter,t.magFilter=f.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0;const i=new f.DataTexture(Ai(new Float32Array([0,0,1,1])),2,2);i.type=f.HalfFloatType,i.format=f.RedFormat,i.minFilter=f.LinearFilter,i.magFilter=f.LinearFilter,i.generateMipmaps=!1,i.needsUpdate=!0,this.map=e,this.marginalWeights=t,this.conditionalWeights=i,this.totalSum=0}dispose(){this.marginalWeights.dispose(),this.conditionalWeights.dispose(),this.map.dispose()}updateFrom(e){const t=ro(e);t.wrapS=f.RepeatWrapping,t.wrapT=f.ClampToEdgeWrapping;const{width:i,height:s,data:a}=t.image,o=new Float32Array(i*s),c=new Float32Array(i*s),u=new Float32Array(s),p=new Float32Array(s);let m=0,n=0;for(let d=0;d<s;d++){let v=0;for(let y=0;y<i;y++){const x=d*i+y,w=f.DataUtils.fromHalfFloat(a[4*x+0]),b=f.DataUtils.fromHalfFloat(a[4*x+1]),T=f.DataUtils.fromHalfFloat(a[4*x+2]),S=so(w,b,T);v+=S,m+=S,o[x]=S,c[x]=v}if(v!==0)for(let y=d*i,x=d*i+i;y<x;y++)o[y]/=v,c[y]/=v;n+=v,u[d]=v,p[d]=n}if(n!==0)for(let d=0,v=u.length;d<v;d++)u[d]/=n,p[d]/=n;const l=new Uint16Array(s),h=new Uint16Array(i*s);for(let d=0;d<s;d++){const v=(d+1)/s,y=Bs(p,v);l[d]=f.DataUtils.toHalfFloat((y+.5)/s)}for(let d=0;d<s;d++)for(let v=0;v<i;v++){const y=d*i+v,x=(v+1)/i,w=Bs(c,x,d*i,i);h[y]=f.DataUtils.toHalfFloat((w+.5)/i)}this.dispose();const{marginalWeights:g,conditionalWeights:_}=this;g.image={width:s,height:1,data:l},g.needsUpdate=!0,_.image={width:i,height:s,data:h},_.needsUpdate=!0,this.totalSum=m,this.map=t}}const Ti=6,oo=0,ao=1,lo=2,co=3,uo=4,ne=new f.Vector3,Y=new f.Vector3,ks=new f.Matrix4,Ve=new f.Quaternion,Os=new f.Vector3,Ue=new f.Vector3,ho=new f.Vector3(0,1,0);class fo{constructor(){const e=new f.DataTexture(new Float32Array(4),1,1);e.format=f.RGBAFormat,e.type=f.FloatType,e.wrapS=f.ClampToEdgeWrapping,e.wrapT=f.ClampToEdgeWrapping,e.generateMipmaps=!1,e.minFilter=f.NearestFilter,e.magFilter=f.NearestFilter,this.tex=e,this.count=0}updateFrom(e,t=[]){const i=this.tex,s=Math.max(e.length*Ti,1),a=Math.ceil(Math.sqrt(s));i.image.width!==a&&(i.dispose(),i.image.data=new Float32Array(a*a*4),i.image.width=a,i.image.height=a);const o=i.image.data;for(let u=0,p=e.length;u<p;u++){const m=e[u],n=u*Ti*4;let l=0;for(let g=0;g<Ti*4;g++)o[n+g]=0;m.getWorldPosition(Y),o[n+l++]=Y.x,o[n+l++]=Y.y,o[n+l++]=Y.z;let h=oo;if(m.isRectAreaLight&&m.isCircular?h=ao:m.isSpotLight?h=lo:m.isDirectionalLight?h=co:m.isPointLight&&(h=uo),o[n+l++]=h,o[n+l++]=m.color.r,o[n+l++]=m.color.g,o[n+l++]=m.color.b,o[n+l++]=m.intensity,m.getWorldQuaternion(Ve),m.isRectAreaLight)ne.set(m.width,0,0).applyQuaternion(Ve),o[n+l++]=ne.x,o[n+l++]=ne.y,o[n+l++]=ne.z,l++,Y.set(0,m.height,0).applyQuaternion(Ve),o[n+l++]=Y.x,o[n+l++]=Y.y,o[n+l++]=Y.z,o[n+l++]=ne.cross(Y).length()*(m.isCircular?Math.PI/4:1);else if(m.isSpotLight){const g=m.radius||0;Os.setFromMatrixPosition(m.matrixWorld),Ue.setFromMatrixPosition(m.target.matrixWorld),ks.lookAt(Os,Ue,ho),Ve.setFromRotationMatrix(ks),ne.set(1,0,0).applyQuaternion(Ve),o[n+l++]=ne.x,o[n+l++]=ne.y,o[n+l++]=ne.z,l++,Y.set(0,1,0).applyQuaternion(Ve),o[n+l++]=Y.x,o[n+l++]=Y.y,o[n+l++]=Y.z,o[n+l++]=Math.PI*g*g,o[n+l++]=g,o[n+l++]=m.decay,o[n+l++]=m.distance,o[n+l++]=Math.cos(m.angle),o[n+l++]=Math.cos(m.angle*(1-m.penumbra)),o[n+l++]=m.iesMap?t.indexOf(m.iesMap):-1}else if(m.isPointLight){const g=ne.setFromMatrixPosition(m.matrixWorld);o[n+l++]=g.x,o[n+l++]=g.y,o[n+l++]=g.z,l++,l+=4,l+=1,o[n+l++]=m.decay,o[n+l++]=m.distance}else if(m.isDirectionalLight){const g=ne.setFromMatrixPosition(m.matrixWorld),_=Y.setFromMatrixPosition(m.target.matrixWorld);Ue.subVectors(g,_).normalize(),o[n+l++]=Ue.x,o[n+l++]=Ue.y,o[n+l++]=Ue.z}}this.count=e.length;const c=us(o.buffer);return this.hash!==c?(this.hash=c,i.needsUpdate=!0,!0):!1}}function zs(r,e,t,i,s){if(e>i)throw new Error;const a=r.length/e,o=r.constructor.BYTES_PER_ELEMENT*8;let c=1;switch(r.constructor){case Uint8Array:case Uint16Array:case Uint32Array:c=2**o-1;break;case Int8Array:case Int16Array:case Int32Array:c=2**(o-1)-1;break}for(let u=0;u<a;u++){const p=4*u,m=e*u;for(let n=0;n<i;n++)t[s+p+n]=e>=n+1?r[m+n]/c:0}}class po extends f.DataArrayTexture{constructor(){super(),this._textures=[],this.type=f.FloatType,this.format=f.RGBAFormat,this.internalFormat="RGBA32F"}updateAttribute(e,t){const i=this._textures[e];i.updateFrom(t);const s=i.image,a=this.image;if(s.width!==a.width||s.height!==a.height)throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");const{width:o,height:c,data:u}=a,m=o*c*4*e;let n=t.itemSize;n===3&&(n=4),zs(i.image.data,n,u,4,m),this.dispose(),this.needsUpdate=!0}setAttributes(e){const t=e[0].count,i=e.length;for(let n=0,l=i;n<l;n++)if(e[n].count!==t)throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");const s=this._textures;for(;s.length<i;){const n=new Ce.FloatVertexAttributeTexture;s.push(n)}for(;s.length>i;)s.pop();for(let n=0,l=i;n<l;n++)s[n].updateFrom(e[n]);const o=s[0].image,c=this.image;(o.width!==c.width||o.height!==c.height||o.depth!==i)&&(c.width=o.width,c.height=o.height,c.depth=i,c.data=new Float32Array(c.width*c.height*c.depth*4));const{data:u,width:p,height:m}=c;for(let n=0,l=i;n<l;n++){const h=s[n],_=p*m*4*n;let d=e[n].itemSize;d===3&&(d=4),zs(h.image.data,d,u,4,_)}this.dispose(),this.needsUpdate=!0}}class mo extends po{updateNormalAttribute(e){this.updateAttribute(0,e)}updateTangentAttribute(e){this.updateAttribute(1,e)}updateUvAttribute(e){this.updateAttribute(2,e)}updateColorAttribute(e){this.updateAttribute(3,e)}updateFrom(e,t,i,s){this.setAttributes([e,t,i,s])}}function fs(r,e){return r.uuid<e.uuid?1:r.uuid>e.uuid?-1:0}function Wi(r){return`${r.source.uuid}:${r.colorSpace}`}function go(r){const e=new Set,t=[];for(let i=0,s=r.length;i<s;i++){const a=r[i],o=Wi(a);e.has(o)||(e.add(o),t.push(a))}return t}function vo(r){const e=r.map(i=>i.iesMap||null).filter(i=>i),t=new Set(e);return Array.from(t).sort(fs)}function _o(r){const e=new Set;for(let i=0,s=r.length;i<s;i++){const a=r[i];for(const o in a){const c=a[o];c&&c.isTexture&&e.add(c)}}const t=Array.from(e);return go(t).sort(fs)}function yo(r){const e=[];return r.traverse(t=>{t.visible&&(t.isRectAreaLight||t.isSpotLight||t.isPointLight||t.isDirectionalLight)&&e.push(t)}),e.sort(fs)}const Rr=45,Vs=Rr*4;class xo{constructor(){this._features={}}isUsed(e){return e in this._features}setUsed(e,t=!0){t===!1?delete this._features[e]:this._features[e]=!0}reset(){this._features={}}}class wo extends f.DataTexture{constructor(){super(new Float32Array(4),1,1),this.format=f.RGBAFormat,this.type=f.FloatType,this.wrapS=f.ClampToEdgeWrapping,this.wrapT=f.ClampToEdgeWrapping,this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.generateMipmaps=!1,this.features=new xo}updateFrom(e,t){function i(g,_,d=-1){if(_ in g&&g[_]){const v=Wi(g[_]);return n[v]}else return d}function s(g,_,d){return _ in g?g[_]:d}function a(g,_,d,v){const y=g[_]&&g[_].isTexture?g[_]:null;if(y){y.matrixAutoUpdate&&y.updateMatrix();const x=y.matrix.elements;let w=0;d[v+w++]=x[0],d[v+w++]=x[3],d[v+w++]=x[6],w++,d[v+w++]=x[1],d[v+w++]=x[4],d[v+w++]=x[7],w++}return 8}let o=0;const c=e.length*Rr,u=Math.ceil(Math.sqrt(c))||1,{image:p,features:m}=this,n={};for(let g=0,_=t.length;g<_;g++)n[Wi(t[g])]=g;p.width!==u&&(this.dispose(),p.data=new Float32Array(u*u*4),p.width=u,p.height=u);const l=p.data;m.reset();for(let g=0,_=e.length;g<_;g++){const d=e[g];if(d.isFogVolumeMaterial){m.setUsed("FOG");for(let x=0;x<Vs;x++)l[o+x]=0;l[o+0*4+0]=d.color.r,l[o+0*4+1]=d.color.g,l[o+0*4+2]=d.color.b,l[o+2*4+3]=s(d,"emissiveIntensity",0),l[o+3*4+0]=d.emissive.r,l[o+3*4+1]=d.emissive.g,l[o+3*4+2]=d.emissive.b,l[o+13*4+1]=d.density,l[o+13*4+3]=0,l[o+14*4+2]=4,o+=Vs;continue}l[o++]=d.color.r,l[o++]=d.color.g,l[o++]=d.color.b,l[o++]=i(d,"map"),l[o++]=s(d,"metalness",0),l[o++]=i(d,"metalnessMap"),l[o++]=s(d,"roughness",0),l[o++]=i(d,"roughnessMap"),l[o++]=s(d,"ior",1.5),l[o++]=s(d,"transmission",0),l[o++]=i(d,"transmissionMap"),l[o++]=s(d,"emissiveIntensity",0),"emissive"in d?(l[o++]=d.emissive.r,l[o++]=d.emissive.g,l[o++]=d.emissive.b):(l[o++]=0,l[o++]=0,l[o++]=0),l[o++]=i(d,"emissiveMap"),l[o++]=i(d,"normalMap"),"normalScale"in d?(l[o++]=d.normalScale.x,l[o++]=d.normalScale.y):(l[o++]=1,l[o++]=1),l[o++]=s(d,"clearcoat",0),l[o++]=i(d,"clearcoatMap"),l[o++]=s(d,"clearcoatRoughness",0),l[o++]=i(d,"clearcoatRoughnessMap"),l[o++]=i(d,"clearcoatNormalMap"),"clearcoatNormalScale"in d?(l[o++]=d.clearcoatNormalScale.x,l[o++]=d.clearcoatNormalScale.y):(l[o++]=1,l[o++]=1),o++,l[o++]=s(d,"sheen",0),"sheenColor"in d?(l[o++]=d.sheenColor.r,l[o++]=d.sheenColor.g,l[o++]=d.sheenColor.b):(l[o++]=0,l[o++]=0,l[o++]=0),l[o++]=i(d,"sheenColorMap"),l[o++]=s(d,"sheenRoughness",0),l[o++]=i(d,"sheenRoughnessMap"),l[o++]=i(d,"iridescenceMap"),l[o++]=i(d,"iridescenceThicknessMap"),l[o++]=s(d,"iridescence",0),l[o++]=s(d,"iridescenceIOR",1.3);const v=s(d,"iridescenceThicknessRange",[100,400]);l[o++]=v[0],l[o++]=v[1],"specularColor"in d?(l[o++]=d.specularColor.r,l[o++]=d.specularColor.g,l[o++]=d.specularColor.b):(l[o++]=1,l[o++]=1,l[o++]=1),l[o++]=i(d,"specularColorMap"),l[o++]=s(d,"specularIntensity",1),l[o++]=i(d,"specularIntensityMap");const y=s(d,"thickness",0)===0&&s(d,"attenuationDistance",1/0)===1/0;if(l[o++]=Number(y),o++,"attenuationColor"in d?(l[o++]=d.attenuationColor.r,l[o++]=d.attenuationColor.g,l[o++]=d.attenuationColor.b):(l[o++]=1,l[o++]=1,l[o++]=1),l[o++]=s(d,"attenuationDistance",1/0),l[o++]=i(d,"alphaMap"),l[o++]=d.opacity,l[o++]=d.alphaTest,!y&&d.transmission>0)l[o++]=0;else switch(d.side){case f.FrontSide:l[o++]=1;break;case f.BackSide:l[o++]=-1;break;case f.DoubleSide:l[o++]=0;break}l[o++]=Number(s(d,"matte",!1)),l[o++]=Number(s(d,"castShadow",!0)),l[o++]=Number(d.vertexColors)|Number(d.flatShading)<<1,l[o++]=Number(d.transparent),o+=a(d,"map",l,o),o+=a(d,"metalnessMap",l,o),o+=a(d,"roughnessMap",l,o),o+=a(d,"transmissionMap",l,o),o+=a(d,"emissiveMap",l,o),o+=a(d,"normalMap",l,o),o+=a(d,"clearcoatMap",l,o),o+=a(d,"clearcoatNormalMap",l,o),o+=a(d,"clearcoatRoughnessMap",l,o),o+=a(d,"sheenColorMap",l,o),o+=a(d,"sheenRoughnessMap",l,o),o+=a(d,"iridescenceMap",l,o),o+=a(d,"iridescenceThicknessMap",l,o),o+=a(d,"specularColorMap",l,o),o+=a(d,"specularIntensityMap",l,o)}const h=us(l.buffer);return this.hash!==h?(this.hash=h,this.needsUpdate=!0,!0):!1}}const Us=new f.Color;function bo(r){return r?`${r.uuid}:${r.version}`:null}function Ao(r,e){for(const t in e)t in r&&(r[t]=e[t])}class Hs extends f.WebGLArrayRenderTarget{constructor(e,t,i){const s={format:f.RGBAFormat,type:f.UnsignedByteType,minFilter:f.LinearFilter,magFilter:f.LinearFilter,wrapS:f.RepeatWrapping,wrapT:f.RepeatWrapping,generateMipmaps:!1,...i};super(e,t,1,s),Ao(this.texture,s),this.texture.setTextures=(...o)=>{this.setTextures(...o)},this.hashes=[null];const a=new ot.FullScreenQuad(new To);this.fsQuad=a}setTextures(e,t,i=this.width,s=this.height){const a=e.getRenderTarget(),o=e.toneMapping,c=e.getClearAlpha();e.getClearColor(Us);const u=t.length||1;(i!==this.width||s!==this.height||this.depth!==u)&&(this.setSize(i,s,u),this.hashes=new Array(u).fill(null)),e.setClearColor(0,0),e.toneMapping=f.NoToneMapping;const p=this.fsQuad,m=this.hashes;let n=!1;for(let l=0,h=u;l<h;l++){const g=t[l],_=bo(g);g&&(m[l]!==_||g.isWebGLRenderTarget)&&(g.matrixAutoUpdate=!1,g.matrix.identity(),p.material.map=g,e.setRenderTarget(this,l),p.render(e),g.updateMatrix(),g.matrixAutoUpdate=!0,m[l]=_,n=!0)}return p.material.map=null,e.setClearColor(Us,c),e.setRenderTarget(a),e.toneMapping=o,n}dispose(){super.dispose(),this.fsQuad.dispose()}}class To extends f.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}constructor(){super({uniforms:{map:{value:null}},vertexShader:`
257
+ `})}}class Hn{generate(e,t=256){const i=new d.WebGLRenderTarget(t,t,{type:d.FloatType,format:d.RGBAFormat,minFilter:d.NearestFilter,magFilter:d.NearestFilter,generateMipmaps:!1}),s=e.getRenderTarget();e.setRenderTarget(i);const a=new nt.FullScreenQuad(new Un);return a.material.resolution.set(t,t),a.render(e),e.setRenderTarget(s),a.dispose(),i}}class Nn extends d.PerspectiveCamera{set bokehSize(e){this.fStop=this.getFocalLength()/e}get bokehSize(){return this.getFocalLength()/this.fStop}constructor(...e){super(...e),this.fStop=1.4,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=25,this.anamorphicRatio=1}copy(e,t){return super.copy(e,t),this.fStop=e.fStop,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio,this}}class Wn{constructor(){this.bokehSize=0,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=10,this.anamorphicRatio=1}updateFrom(e){e instanceof Nn?(this.bokehSize=e.bokehSize,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio):(this.bokehSize=0,this.apertureRotation=0,this.apertureBlades=0,this.focusDistance=10,this.anamorphicRatio=1)}}function vi(n){const e=new Uint16Array(n.length);for(let t=0,i=n.length;t<i;++t)e[t]=d.DataUtils.toHalfFloat(n[t]);return e}function Ss(n,e,t=0,i=n.length){let s=t,a=t+i-1;for(;s<a;){const o=s+a>>1;n[o]<e?s=o+1:a=o}return s-t}function Gn(n,e,t){return .2126*n+.7152*e+.0722*t}function qn(n,e=d.HalfFloatType){const t=n.clone();t.source=new d.Source({...t.image});const{width:i,height:s,data:a}=t.image;let o=a;if(t.type!==e){e===d.HalfFloatType?o=new Uint16Array(a.length):o=new Float32Array(a.length);let c;a instanceof Int8Array||a instanceof Int16Array||a instanceof Int32Array?c=2**(8*a.BYTES_PER_ELEMENT-1)-1:c=2**(8*a.BYTES_PER_ELEMENT)-1;for(let u=0,f=a.length;u<f;u++){let p=a[u];t.type===d.HalfFloatType&&(p=d.DataUtils.fromHalfFloat(a[u])),t.type!==d.FloatType&&t.type!==d.HalfFloatType&&(p/=c),e===d.HalfFloatType&&(o[u]=d.DataUtils.toHalfFloat(p))}t.image.data=o,t.type=e}if(t.flipY){const c=o;o=o.slice();for(let u=0;u<s;u++)for(let f=0;f<i;f++){const p=s-u-1,r=4*(u*i+f),l=4*(p*i+f);o[l+0]=c[r+0],o[l+1]=c[r+1],o[l+2]=c[r+2],o[l+3]=c[r+3]}t.flipY=!1,t.image.data=o}return t}class jn{constructor(){const e=new d.DataTexture(vi(new Float32Array([0,0,0,0])),1,1);e.type=d.HalfFloatType,e.format=d.RGBAFormat,e.minFilter=d.LinearFilter,e.magFilter=d.LinearFilter,e.wrapS=d.RepeatWrapping,e.wrapT=d.RepeatWrapping,e.generateMipmaps=!1,e.needsUpdate=!0;const t=new d.DataTexture(vi(new Float32Array([0,1])),1,2);t.type=d.HalfFloatType,t.format=d.RedFormat,t.minFilter=d.LinearFilter,t.magFilter=d.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0;const i=new d.DataTexture(vi(new Float32Array([0,0,1,1])),2,2);i.type=d.HalfFloatType,i.format=d.RedFormat,i.minFilter=d.LinearFilter,i.magFilter=d.LinearFilter,i.generateMipmaps=!1,i.needsUpdate=!0,this.map=e,this.marginalWeights=t,this.conditionalWeights=i,this.totalSum=0}dispose(){this.marginalWeights.dispose(),this.conditionalWeights.dispose(),this.map.dispose()}updateFrom(e){const t=qn(e);t.wrapS=d.RepeatWrapping,t.wrapT=d.ClampToEdgeWrapping;const{width:i,height:s,data:a}=t.image,o=new Float32Array(i*s),c=new Float32Array(i*s),u=new Float32Array(s),f=new Float32Array(s);let p=0,r=0;for(let m=0;m<s;m++){let v=0;for(let y=0;y<i;y++){const x=m*i+y,w=d.DataUtils.fromHalfFloat(a[4*x+0]),b=d.DataUtils.fromHalfFloat(a[4*x+1]),A=d.DataUtils.fromHalfFloat(a[4*x+2]),S=Gn(w,b,A);v+=S,p+=S,o[x]=S,c[x]=v}if(v!==0)for(let y=m*i,x=m*i+i;y<x;y++)o[y]/=v,c[y]/=v;r+=v,u[m]=v,f[m]=r}if(r!==0)for(let m=0,v=u.length;m<v;m++)u[m]/=r,f[m]/=r;const l=new Uint16Array(s),h=new Uint16Array(i*s);for(let m=0;m<s;m++){const v=(m+1)/s,y=Ss(f,v);l[m]=d.DataUtils.toHalfFloat((y+.5)/s)}for(let m=0;m<s;m++)for(let v=0;v<i;v++){const y=m*i+v,x=(v+1)/i,w=Ss(c,x,m*i,i);h[y]=d.DataUtils.toHalfFloat((w+.5)/i)}this.dispose();const{marginalWeights:g,conditionalWeights:_}=this;g.image={width:s,height:1,data:l},g.needsUpdate=!0,_.image={width:i,height:s,data:h},_.needsUpdate=!0,this.totalSum=p,this.map=t}}const _i=6,Yn=0,Qn=1,Zn=2,Xn=3,Kn=4,ne=new d.Vector3,Y=new d.Vector3,Ms=new d.Matrix4,ze=new d.Quaternion,Cs=new d.Vector3,Ve=new d.Vector3,Jn=new d.Vector3(0,1,0);class $n{constructor(){const e=new d.DataTexture(new Float32Array(4),1,1);e.format=d.RGBAFormat,e.type=d.FloatType,e.wrapS=d.ClampToEdgeWrapping,e.wrapT=d.ClampToEdgeWrapping,e.generateMipmaps=!1,e.minFilter=d.NearestFilter,e.magFilter=d.NearestFilter,this.tex=e,this.count=0}updateFrom(e,t=[]){const i=this.tex,s=Math.max(e.length*_i,1),a=Math.ceil(Math.sqrt(s));i.image.width!==a&&(i.dispose(),i.image.data=new Float32Array(a*a*4),i.image.width=a,i.image.height=a);const o=i.image.data;for(let u=0,f=e.length;u<f;u++){const p=e[u],r=u*_i*4;let l=0;for(let g=0;g<_i*4;g++)o[r+g]=0;p.getWorldPosition(Y),o[r+l++]=Y.x,o[r+l++]=Y.y,o[r+l++]=Y.z;let h=Yn;if(p.isRectAreaLight&&p.isCircular?h=Qn:p.isSpotLight?h=Zn:p.isDirectionalLight?h=Xn:p.isPointLight&&(h=Kn),o[r+l++]=h,o[r+l++]=p.color.r,o[r+l++]=p.color.g,o[r+l++]=p.color.b,o[r+l++]=p.intensity,p.getWorldQuaternion(ze),p.isRectAreaLight)ne.set(p.width,0,0).applyQuaternion(ze),o[r+l++]=ne.x,o[r+l++]=ne.y,o[r+l++]=ne.z,l++,Y.set(0,p.height,0).applyQuaternion(ze),o[r+l++]=Y.x,o[r+l++]=Y.y,o[r+l++]=Y.z,o[r+l++]=ne.cross(Y).length()*(p.isCircular?Math.PI/4:1);else if(p.isSpotLight){const g=p.radius||0;Cs.setFromMatrixPosition(p.matrixWorld),Ve.setFromMatrixPosition(p.target.matrixWorld),Ms.lookAt(Cs,Ve,Jn),ze.setFromRotationMatrix(Ms),ne.set(1,0,0).applyQuaternion(ze),o[r+l++]=ne.x,o[r+l++]=ne.y,o[r+l++]=ne.z,l++,Y.set(0,1,0).applyQuaternion(ze),o[r+l++]=Y.x,o[r+l++]=Y.y,o[r+l++]=Y.z,o[r+l++]=Math.PI*g*g,o[r+l++]=g,o[r+l++]=p.decay,o[r+l++]=p.distance,o[r+l++]=Math.cos(p.angle),o[r+l++]=Math.cos(p.angle*(1-p.penumbra)),o[r+l++]=p.iesMap?t.indexOf(p.iesMap):-1}else if(p.isPointLight){const g=ne.setFromMatrixPosition(p.matrixWorld);o[r+l++]=g.x,o[r+l++]=g.y,o[r+l++]=g.z,l++,l+=4,l+=1,o[r+l++]=p.decay,o[r+l++]=p.distance}else if(p.isDirectionalLight){const g=ne.setFromMatrixPosition(p.matrixWorld),_=Y.setFromMatrixPosition(p.target.matrixWorld);Ve.subVectors(g,_).normalize(),o[r+l++]=Ve.x,o[r+l++]=Ve.y,o[r+l++]=Ve.z}}this.count=e.length;const c=ss(o.buffer);return this.hash!==c?(this.hash=c,i.needsUpdate=!0,!0):!1}}function Is(n,e,t,i,s){if(e>i)throw new Error;const a=n.length/e,o=n.constructor.BYTES_PER_ELEMENT*8;let c=1;switch(n.constructor){case Uint8Array:case Uint16Array:case Uint32Array:c=2**o-1;break;case Int8Array:case Int16Array:case Int32Array:c=2**(o-1)-1;break}for(let u=0;u<a;u++){const f=4*u,p=e*u;for(let r=0;r<i;r++)t[s+f+r]=e>=r+1?n[p+r]/c:0}}class eo extends d.DataArrayTexture{constructor(){super(),this._textures=[],this.type=d.FloatType,this.format=d.RGBAFormat,this.internalFormat="RGBA32F"}updateAttribute(e,t){const i=this._textures[e];i.updateFrom(t);const s=i.image,a=this.image;if(s.width!==a.width||s.height!==a.height)throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");const{width:o,height:c,data:u}=a,p=o*c*4*e;let r=t.itemSize;r===3&&(r=4),Is(i.image.data,r,u,4,p),this.dispose(),this.needsUpdate=!0}setAttributes(e){const t=e[0].count,i=e.length;for(let r=0,l=i;r<l;r++)if(e[r].count!==t)throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");const s=this._textures;for(;s.length<i;){const r=new Ce.FloatVertexAttributeTexture;s.push(r)}for(;s.length>i;)s.pop();for(let r=0,l=i;r<l;r++)s[r].updateFrom(e[r]);const o=s[0].image,c=this.image;(o.width!==c.width||o.height!==c.height||o.depth!==i)&&(c.width=o.width,c.height=o.height,c.depth=i,c.data=new Float32Array(c.width*c.height*c.depth*4));const{data:u,width:f,height:p}=c;for(let r=0,l=i;r<l;r++){const h=s[r],_=f*p*4*r;let m=e[r].itemSize;m===3&&(m=4),Is(h.image.data,m,u,4,_)}this.dispose(),this.needsUpdate=!0}}class to extends eo{updateNormalAttribute(e){this.updateAttribute(0,e)}updateTangentAttribute(e){this.updateAttribute(1,e)}updateUvAttribute(e){this.updateAttribute(2,e)}updateColorAttribute(e){this.updateAttribute(3,e)}updateFrom(e,t,i,s){this.setAttributes([e,t,i,s])}}function ns(n,e){return n.uuid<e.uuid?1:n.uuid>e.uuid?-1:0}function ki(n){return`${n.source.uuid}:${n.colorSpace}`}function io(n){const e=new Set,t=[];for(let i=0,s=n.length;i<s;i++){const a=n[i],o=ki(a);e.has(o)||(e.add(o),t.push(a))}return t}function so(n){const e=n.map(i=>i.iesMap||null).filter(i=>i),t=new Set(e);return Array.from(t).sort(ns)}function ro(n){const e=new Set;for(let i=0,s=n.length;i<s;i++){const a=n[i];for(const o in a){const c=a[o];c&&c.isTexture&&e.add(c)}}const t=Array.from(e);return io(t).sort(ns)}function no(n){const e=[];return n.traverse(t=>{t.visible&&(t.isRectAreaLight||t.isSpotLight||t.isPointLight||t.isDirectionalLight)&&e.push(t)}),e.sort(ns)}const pr=45,Rs=pr*4;class oo{constructor(){this._features={}}isUsed(e){return e in this._features}setUsed(e,t=!0){t===!1?delete this._features[e]:this._features[e]=!0}reset(){this._features={}}}class ao extends d.DataTexture{constructor(){super(new Float32Array(4),1,1),this.format=d.RGBAFormat,this.type=d.FloatType,this.wrapS=d.ClampToEdgeWrapping,this.wrapT=d.ClampToEdgeWrapping,this.minFilter=d.NearestFilter,this.magFilter=d.NearestFilter,this.generateMipmaps=!1,this.features=new oo}updateFrom(e,t){function i(g,_,m=-1){if(_ in g&&g[_]){const v=ki(g[_]);return r[v]}else return m}function s(g,_,m){return _ in g?g[_]:m}function a(g,_,m,v){const y=g[_]&&g[_].isTexture?g[_]:null;if(y){y.matrixAutoUpdate&&y.updateMatrix();const x=y.matrix.elements;let w=0;m[v+w++]=x[0],m[v+w++]=x[3],m[v+w++]=x[6],w++,m[v+w++]=x[1],m[v+w++]=x[4],m[v+w++]=x[7],w++}return 8}let o=0;const c=e.length*pr,u=Math.ceil(Math.sqrt(c))||1,{image:f,features:p}=this,r={};for(let g=0,_=t.length;g<_;g++)r[ki(t[g])]=g;f.width!==u&&(this.dispose(),f.data=new Float32Array(u*u*4),f.width=u,f.height=u);const l=f.data;p.reset();for(let g=0,_=e.length;g<_;g++){const m=e[g];if(m.isFogVolumeMaterial){p.setUsed("FOG");for(let x=0;x<Rs;x++)l[o+x]=0;l[o+0*4+0]=m.color.r,l[o+0*4+1]=m.color.g,l[o+0*4+2]=m.color.b,l[o+2*4+3]=s(m,"emissiveIntensity",0),l[o+3*4+0]=m.emissive.r,l[o+3*4+1]=m.emissive.g,l[o+3*4+2]=m.emissive.b,l[o+13*4+1]=m.density,l[o+13*4+3]=0,l[o+14*4+2]=4,o+=Rs;continue}l[o++]=m.color.r,l[o++]=m.color.g,l[o++]=m.color.b,l[o++]=i(m,"map"),l[o++]=s(m,"metalness",0),l[o++]=i(m,"metalnessMap"),l[o++]=s(m,"roughness",0),l[o++]=i(m,"roughnessMap"),l[o++]=s(m,"ior",1.5),l[o++]=s(m,"transmission",0),l[o++]=i(m,"transmissionMap"),l[o++]=s(m,"emissiveIntensity",0),"emissive"in m?(l[o++]=m.emissive.r,l[o++]=m.emissive.g,l[o++]=m.emissive.b):(l[o++]=0,l[o++]=0,l[o++]=0),l[o++]=i(m,"emissiveMap"),l[o++]=i(m,"normalMap"),"normalScale"in m?(l[o++]=m.normalScale.x,l[o++]=m.normalScale.y):(l[o++]=1,l[o++]=1),l[o++]=s(m,"clearcoat",0),l[o++]=i(m,"clearcoatMap"),l[o++]=s(m,"clearcoatRoughness",0),l[o++]=i(m,"clearcoatRoughnessMap"),l[o++]=i(m,"clearcoatNormalMap"),"clearcoatNormalScale"in m?(l[o++]=m.clearcoatNormalScale.x,l[o++]=m.clearcoatNormalScale.y):(l[o++]=1,l[o++]=1),o++,l[o++]=s(m,"sheen",0),"sheenColor"in m?(l[o++]=m.sheenColor.r,l[o++]=m.sheenColor.g,l[o++]=m.sheenColor.b):(l[o++]=0,l[o++]=0,l[o++]=0),l[o++]=i(m,"sheenColorMap"),l[o++]=s(m,"sheenRoughness",0),l[o++]=i(m,"sheenRoughnessMap"),l[o++]=i(m,"iridescenceMap"),l[o++]=i(m,"iridescenceThicknessMap"),l[o++]=s(m,"iridescence",0),l[o++]=s(m,"iridescenceIOR",1.3);const v=s(m,"iridescenceThicknessRange",[100,400]);l[o++]=v[0],l[o++]=v[1],"specularColor"in m?(l[o++]=m.specularColor.r,l[o++]=m.specularColor.g,l[o++]=m.specularColor.b):(l[o++]=1,l[o++]=1,l[o++]=1),l[o++]=i(m,"specularColorMap"),l[o++]=s(m,"specularIntensity",1),l[o++]=i(m,"specularIntensityMap");const y=s(m,"thickness",0)===0&&s(m,"attenuationDistance",1/0)===1/0;if(l[o++]=Number(y),o++,"attenuationColor"in m?(l[o++]=m.attenuationColor.r,l[o++]=m.attenuationColor.g,l[o++]=m.attenuationColor.b):(l[o++]=1,l[o++]=1,l[o++]=1),l[o++]=s(m,"attenuationDistance",1/0),l[o++]=i(m,"alphaMap"),l[o++]=m.opacity,l[o++]=m.alphaTest,!y&&m.transmission>0)l[o++]=0;else switch(m.side){case d.FrontSide:l[o++]=1;break;case d.BackSide:l[o++]=-1;break;case d.DoubleSide:l[o++]=0;break}l[o++]=Number(s(m,"matte",!1)),l[o++]=Number(s(m,"castShadow",!0)),l[o++]=Number(m.vertexColors)|Number(m.flatShading)<<1,l[o++]=Number(m.transparent),o+=a(m,"map",l,o),o+=a(m,"metalnessMap",l,o),o+=a(m,"roughnessMap",l,o),o+=a(m,"transmissionMap",l,o),o+=a(m,"emissiveMap",l,o),o+=a(m,"normalMap",l,o),o+=a(m,"clearcoatMap",l,o),o+=a(m,"clearcoatNormalMap",l,o),o+=a(m,"clearcoatRoughnessMap",l,o),o+=a(m,"sheenColorMap",l,o),o+=a(m,"sheenRoughnessMap",l,o),o+=a(m,"iridescenceMap",l,o),o+=a(m,"iridescenceThicknessMap",l,o),o+=a(m,"specularColorMap",l,o),o+=a(m,"specularIntensityMap",l,o)}const h=ss(l.buffer);return this.hash!==h?(this.hash=h,this.needsUpdate=!0,!0):!1}}const Ps=new d.Color;function lo(n){return n?`${n.uuid}:${n.version}`:null}function co(n,e){for(const t in e)t in n&&(n[t]=e[t])}class Ds extends d.WebGLArrayRenderTarget{constructor(e,t,i){const s={format:d.RGBAFormat,type:d.UnsignedByteType,minFilter:d.LinearFilter,magFilter:d.LinearFilter,wrapS:d.RepeatWrapping,wrapT:d.RepeatWrapping,generateMipmaps:!1,...i};super(e,t,1,s),co(this.texture,s),this.texture.setTextures=(...o)=>{this.setTextures(...o)},this.hashes=[null];const a=new nt.FullScreenQuad(new uo);this.fsQuad=a}setTextures(e,t,i=this.width,s=this.height){const a=e.getRenderTarget(),o=e.toneMapping,c=e.getClearAlpha();e.getClearColor(Ps);const u=t.length||1;(i!==this.width||s!==this.height||this.depth!==u)&&(this.setSize(i,s,u),this.hashes=new Array(u).fill(null)),e.setClearColor(0,0),e.toneMapping=d.NoToneMapping;const f=this.fsQuad,p=this.hashes;let r=!1;for(let l=0,h=u;l<h;l++){const g=t[l],_=lo(g);g&&(p[l]!==_||g.isWebGLRenderTarget)&&(g.matrixAutoUpdate=!1,g.matrix.identity(),f.material.map=g,e.setRenderTarget(this,l),f.render(e),g.updateMatrix(),g.matrixAutoUpdate=!0,p[l]=_,r=!0)}return f.material.map=null,e.setClearColor(Ps,c),e.setRenderTarget(a),e.toneMapping=o,r}dispose(){super.dispose(),this.fsQuad.dispose()}}class uo extends d.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}constructor(){super({uniforms:{map:{value:null}},vertexShader:`
258
258
  varying vec2 vUv;
259
259
  void main() {
260
260
 
@@ -270,7 +270,7 @@
270
270
  gl_FragColor = texture2D( map, vUv );
271
271
 
272
272
  }
273
- `})}}function So(r,e=Math.random()){for(let t=r.length-1;t>0;t--){const i=Math.floor(e()*(t+1)),s=r[t];r[t]=r[i],r[i]=s}return r}class Co{constructor(e,t,i=Math.random){const s=e**t,a=new Uint16Array(s);let o=s;for(let c=0;c<s;c++)a[c]=c;this.samples=new Float32Array(t),this.strataCount=e,this.reset=function(){for(let c=0;c<s;c++)a[c]=c;o=0},this.reshuffle=function(){o=0},this.next=function(){const{samples:c}=this;o>=a.length&&(So(a,i),this.reshuffle());let u=a[o++];for(let p=0;p<t;p++)c[p]=(u%e+i())/e,u=Math.floor(u/e);return c}}}class Mo{constructor(e,t,i=Math.random){let s=0;for(const u of t)s+=u;const a=new Float32Array(s),o=[];let c=0;for(const u of t){const p=new Co(e,u,i);p.samples=new Float32Array(a.buffer,c,p.samples.length),c+=p.samples.length*4,o.push(p)}this.samples=a,this.strataCount=e,this.next=function(){for(const u of o)u.next();return a},this.reshuffle=function(){for(const u of o)u.reshuffle()},this.reset=function(){for(const u of o)u.reset()}}}class Po{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 Ro 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 Po,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 a=new Array(e*t).fill(4),o=new Mo(i,a,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 Io(r,e=Math.random){for(let t=r.length-1;t>0;t--){const i=~~((e()-1e-6)*t),s=r[t];r[t]=r[i],r[i]=s}}function Eo(r,e){r.fill(0);for(let t=0;t<e;t++)r[t]=1}class Ns{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 a=0,o=t.length;a<o;a++){if(t[a]!==0)continue;const c=e[a];c<i&&(i=c,s=a)}return s}findCluster(){const{score:e,binaryPattern:t}=this;let i=-1/0,s=-1;for(let a=0,o=t.length;a<o;a++){if(t[a]!==1)continue;const c=e[a];c>i&&(i=c,s=a)}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),a=e*e;for(let o=-t;o<=t;o++)for(let c=-t;c<=t;c++){const u=(t+c)*i+o+t,p=o*o+c*c;s[u]=Math.E**(-p/(2*a))}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,a=e.length;s<a;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:a,lookupTable:o}=this,c=this.radius,u=2*c+1;for(let p=-c;p<=c;p++)for(let m=-c;m<=c;m++){const n=(c+m)*u+p+c,l=o[n];let h=e+p;h=h<0?s+h:h%s;let g=t+m;g=g<0?s+g:g%s;const _=g*s+h;a[_]+=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 Do{constructor(){this.random=Math.random,this.sigma=1.5,this.size=64,this.majorityPointsRatio=.1,this.samples=new Ns(1),this.savedSamples=new Ns(1)}generate(){const{samples:e,savedSamples:t,sigma:i,majorityPointsRatio:s,size:a}=this;e.resize(a),e.setSigma(i);const o=Math.floor(a*a*s),c=e.binaryPattern;Eo(c,o),Io(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 u=new Uint32Array(a*a);t.copy(e);let p;for(p=e.count-1;p>=0;){const n=e.findCluster();e.removePointIndex(n),u[n]=p,p--}const m=a*a;for(p=t.count;p<m/2;){const n=t.findVoid();t.addPointIndex(n),u[n]=p,p++}for(t.invert();p<m;){const n=t.findCluster();t.removePointIndex(n),u[n]=p,p++}return{data:u,maxValue:m}}}function Lo(r){return r>=3?4:r}function Fo(r){switch(r){case 1:return f.RedFormat;case 2:return f.RGFormat;default:return f.RGBAFormat}}class Bo 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 Do;i.channels=e,i.size=t;const s=Lo(e),a=Fo(s);(this.image.width!==t||a!==this.format)&&(this.image.width=t,this.image.height=t,this.image.data=new Float32Array(t**2*s),this.format=a,this.dispose());const o=this.image.data;for(let c=0,u=e;c<u;c++){const p=i.generate(),m=p.data,n=p.maxValue;for(let l=0,h=m.length;l<h;l++){const g=m[l]/n;o[l*s+c]=g}}this.needsUpdate=!0}}const ko=`
273
+ `})}}function ho(n,e=Math.random()){for(let t=n.length-1;t>0;t--){const i=Math.floor(e()*(t+1)),s=n[t];n[t]=n[i],n[i]=s}return n}class fo{constructor(e,t,i=Math.random){const s=e**t,a=new Uint16Array(s);let o=s;for(let c=0;c<s;c++)a[c]=c;this.samples=new Float32Array(t),this.strataCount=e,this.reset=function(){for(let c=0;c<s;c++)a[c]=c;o=0},this.reshuffle=function(){o=0},this.next=function(){const{samples:c}=this;o>=a.length&&(ho(a,i),this.reshuffle());let u=a[o++];for(let f=0;f<t;f++)c[f]=(u%e+i())/e,u=Math.floor(u/e);return c}}}class po{constructor(e,t,i=Math.random){let s=0;for(const u of t)s+=u;const a=new Float32Array(s),o=[];let c=0;for(const u of t){const f=new fo(e,u,i);f.samples=new Float32Array(a.buffer,c,f.samples.length),c+=f.samples.length*4,o.push(f)}this.samples=a,this.strataCount=e,this.next=function(){for(const u of o)u.next();return a},this.reshuffle=function(){for(const u of o)u.reshuffle()},this.reset=function(){for(const u of o)u.reset()}}}class mo{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 go extends d.DataTexture{constructor(e=1,t=1,i=8){super(new Float32Array(1),1,1,d.RGBAFormat,d.FloatType),this.minFilter=d.NearestFilter,this.magFilter=d.NearestFilter,this.strata=i,this.sampler=null,this.generator=new mo,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 a=new Array(e*t).fill(4),o=new po(i,a,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 vo(n,e=Math.random){for(let t=n.length-1;t>0;t--){const i=~~((e()-1e-6)*t),s=n[t];n[t]=n[i],n[i]=s}}function _o(n,e){n.fill(0);for(let t=0;t<e;t++)n[t]=1}class Ls{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 a=0,o=t.length;a<o;a++){if(t[a]!==0)continue;const c=e[a];c<i&&(i=c,s=a)}return s}findCluster(){const{score:e,binaryPattern:t}=this;let i=-1/0,s=-1;for(let a=0,o=t.length;a<o;a++){if(t[a]!==1)continue;const c=e[a];c>i&&(i=c,s=a)}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),a=e*e;for(let o=-t;o<=t;o++)for(let c=-t;c<=t;c++){const u=(t+c)*i+o+t,f=o*o+c*c;s[u]=Math.E**(-f/(2*a))}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,a=e.length;s<a;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:a,lookupTable:o}=this,c=this.radius,u=2*c+1;for(let f=-c;f<=c;f++)for(let p=-c;p<=c;p++){const r=(c+p)*u+f+c,l=o[r];let h=e+f;h=h<0?s+h:h%s;let g=t+p;g=g<0?s+g:g%s;const _=g*s+h;a[_]+=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 yo{constructor(){this.random=Math.random,this.sigma=1.5,this.size=64,this.majorityPointsRatio=.1,this.samples=new Ls(1),this.savedSamples=new Ls(1)}generate(){const{samples:e,savedSamples:t,sigma:i,majorityPointsRatio:s,size:a}=this;e.resize(a),e.setSigma(i);const o=Math.floor(a*a*s),c=e.binaryPattern;_o(c,o),vo(c,this.random);for(let r=0,l=c.length;r<l;r++)c[r]===1&&e.addPointIndex(r);for(;;){const r=e.findCluster();e.removePointIndex(r);const l=e.findVoid();if(r===l){e.addPointIndex(r);break}e.addPointIndex(l)}const u=new Uint32Array(a*a);t.copy(e);let f;for(f=e.count-1;f>=0;){const r=e.findCluster();e.removePointIndex(r),u[r]=f,f--}const p=a*a;for(f=t.count;f<p/2;){const r=t.findVoid();t.addPointIndex(r),u[r]=f,f++}for(t.invert();f<p;){const r=t.findCluster();t.removePointIndex(r),u[r]=f,f++}return{data:u,maxValue:p}}}function xo(n){return n>=3?4:n}function wo(n){switch(n){case 1:return d.RedFormat;case 2:return d.RGFormat;default:return d.RGBAFormat}}class bo extends d.DataTexture{constructor(e=64,t=1){super(new Float32Array(4),1,1,d.RGBAFormat,d.FloatType),this.minFilter=d.NearestFilter,this.magFilter=d.NearestFilter,this.size=e,this.channels=t,this.update()}update(){const e=this.channels,t=this.size,i=new yo;i.channels=e,i.size=t;const s=xo(e),a=wo(s);(this.image.width!==t||a!==this.format)&&(this.image.width=t,this.image.height=t,this.image.data=new Float32Array(t**2*s),this.format=a,this.dispose());const o=this.image.data;for(let c=0,u=e;c<u;c++){const f=i.generate(),p=f.data,r=f.maxValue;for(let l=0,h=p.length;l<h;l++){const g=p[l]/r;o[l*s+c]=g}}this.needsUpdate=!0}}const Ao=`
274
274
 
275
275
  struct PhysicalCamera {
276
276
 
@@ -282,7 +282,7 @@
282
282
 
283
283
  };
284
284
 
285
- `,Oo=`
285
+ `,To=`
286
286
 
287
287
  struct EquirectHdrInfo {
288
288
 
@@ -294,7 +294,7 @@
294
294
 
295
295
  };
296
296
 
297
- `,zo=`
297
+ `,So=`
298
298
 
299
299
  #define RECT_AREA_LIGHT_TYPE 0
300
300
  #define CIRC_AREA_LIGHT_TYPE 1
@@ -380,7 +380,7 @@
380
380
 
381
381
  }
382
382
 
383
- `,Vo=`
383
+ `,Mo=`
384
384
 
385
385
  struct Material {
386
386
 
@@ -587,7 +587,7 @@
587
587
 
588
588
  }
589
589
 
590
- `,Uo=`
590
+ `,Co=`
591
591
 
592
592
  struct SurfaceRecord {
593
593
 
@@ -649,7 +649,7 @@
649
649
  vec3 color;
650
650
  };
651
651
 
652
- `,Ho=`
652
+ `,Io=`
653
653
 
654
654
  // samples the the given environment map in the given direction
655
655
  vec3 sampleEquirectColor( sampler2D envMap, vec3 direction ) {
@@ -716,7 +716,7 @@
716
716
  return float( resolution.x * resolution.y ) * pdf * equirectDirectionPdf( direction );
717
717
 
718
718
  }
719
- `,No=`
719
+ `,Ro=`
720
720
 
721
721
  float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
722
722
 
@@ -931,7 +931,7 @@
931
931
 
932
932
  }
933
933
 
934
- `,Wo=`
934
+ `,Po=`
935
935
 
936
936
  vec3 sampleHemisphere( vec3 n, vec2 uv ) {
937
937
 
@@ -1016,7 +1016,7 @@
1016
1016
  }
1017
1017
 
1018
1018
 
1019
- `,Go=`
1019
+ `,Do=`
1020
1020
 
1021
1021
  bool totalInternalReflection( float cosTheta, float eta ) {
1022
1022
 
@@ -1119,7 +1119,7 @@
1119
1119
 
1120
1120
  }
1121
1121
 
1122
- `,qo=`
1122
+ `,Lo=`
1123
1123
 
1124
1124
  // Fast arccos approximation used to remove banding artifacts caused by numerical errors in acos.
1125
1125
  // This is a cubic Lagrange interpolating polynomial for x = [-1, -1/2, 0, 1/2, 1].
@@ -1199,7 +1199,7 @@
1199
1199
 
1200
1200
  }
1201
1201
 
1202
- `,jo=`
1202
+ `,Eo=`
1203
1203
 
1204
1204
  // Finds the point where the ray intersects the plane defined by u and v and checks if this point
1205
1205
  // falls in the bounds of the rectangle on that same plane.
@@ -1260,7 +1260,7 @@
1260
1260
 
1261
1261
  }
1262
1262
 
1263
- `,Yo=`
1263
+ `,Fo=`
1264
1264
 
1265
1265
  // add texel fetch functions for texture arrays
1266
1266
  vec4 texelFetch1D( sampler2DArray tex, int layer, uint index ) {
@@ -1283,7 +1283,7 @@
1283
1283
 
1284
1284
  }
1285
1285
 
1286
- `,Ir=`
1286
+ `,mr=`
1287
1287
 
1288
1288
  // TODO: possibly this should be renamed something related to material or path tracing logic
1289
1289
 
@@ -1398,7 +1398,7 @@
1398
1398
  return x < 0.5 ? sqrt( 2.0 * x ) - 1.0 : 1.0 - sqrt( 2.0 - ( 2.0 * x ) );
1399
1399
 
1400
1400
  }
1401
- `,Ws=`
1401
+ `,Es=`
1402
1402
 
1403
1403
  // https://www.shadertoy.com/view/wltcRS
1404
1404
  uvec4 WHITE_NOISE_SEED;
@@ -1454,7 +1454,7 @@
1454
1454
  return vec4( WHITE_NOISE_SEED ) / float( 0xffffffffu );
1455
1455
 
1456
1456
  }
1457
- `,$o=`
1457
+ `,Bo=`
1458
1458
 
1459
1459
  uniform sampler2D stratifiedTexture;
1460
1460
  uniform sampler2D stratifiedOffsetTexture;
@@ -1503,7 +1503,7 @@
1503
1503
 
1504
1504
  }
1505
1505
 
1506
- `,Qo=`
1506
+ `,ko=`
1507
1507
 
1508
1508
  // diffuse
1509
1509
  float diffuseEval( vec3 wo, vec3 wi, vec3 wh, SurfaceRecord surf, inout vec3 color ) {
@@ -1941,7 +1941,7 @@
1941
1941
 
1942
1942
  }
1943
1943
 
1944
- `,Zo=`
1944
+ `,Oo=`
1945
1945
 
1946
1946
  // returns the hit distance given the material density
1947
1947
  float intersectFogVolume( Material material, float u ) {
@@ -1962,7 +1962,7 @@
1962
1962
 
1963
1963
  }
1964
1964
 
1965
- `,Xo=`
1965
+ `,zo=`
1966
1966
 
1967
1967
  // The GGX functions provide sampling and distribution information for normals as output so
1968
1968
  // in order to get probability of scatter direction the half vector must be computed and provided.
@@ -2063,7 +2063,7 @@
2063
2063
 
2064
2064
  }
2065
2065
 
2066
- `,Ko=`
2066
+ `,Vo=`
2067
2067
 
2068
2068
  // XYZ to sRGB color space
2069
2069
  const mat3 XYZ_TO_REC709 = mat3(
@@ -2197,7 +2197,7 @@
2197
2197
 
2198
2198
  }
2199
2199
 
2200
- `,Jo=`
2200
+ `,Uo=`
2201
2201
 
2202
2202
  // See equation (2) in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
2203
2203
  float velvetD( float cosThetaH, float roughness ) {
@@ -2294,7 +2294,7 @@
2294
2294
 
2295
2295
  }
2296
2296
 
2297
- `,ea=`
2297
+ `,Ho=`
2298
2298
 
2299
2299
  #ifndef FOG_CHECK_ITERATIONS
2300
2300
  #define FOG_CHECK_ITERATIONS 30
@@ -2355,7 +2355,7 @@ bool bvhIntersectFogVolumeHit(
2355
2355
 
2356
2356
  }
2357
2357
 
2358
- `,ta=`
2358
+ `,No=`
2359
2359
 
2360
2360
  // step through multiple surface hits and accumulate color attenuation based on transmissive surfaces
2361
2361
  // returns true if a solid surface was hit
@@ -2532,7 +2532,7 @@ bool bvhIntersectFogVolumeHit(
2532
2532
 
2533
2533
  }
2534
2534
 
2535
- `,ia=`
2535
+ `,Wo=`
2536
2536
 
2537
2537
  vec3 ndcToRayOrigin( vec2 coord ) {
2538
2538
 
@@ -2615,7 +2615,7 @@ bool bvhIntersectFogVolumeHit(
2615
2615
 
2616
2616
  }
2617
2617
 
2618
- `,sa=`
2618
+ `,Go=`
2619
2619
 
2620
2620
  vec3 directLightContribution( vec3 worldWo, SurfaceRecord surf, RenderState state, vec3 rayOrigin ) {
2621
2621
 
@@ -2711,7 +2711,7 @@ bool bvhIntersectFogVolumeHit(
2711
2711
 
2712
2712
  }
2713
2713
 
2714
- `,ra=`
2714
+ `,qo=`
2715
2715
 
2716
2716
  #define SKIP_SURFACE 0
2717
2717
  #define HIT_SURFACE 1
@@ -3033,7 +3033,7 @@ bool bvhIntersectFogVolumeHit(
3033
3033
  return HIT_SURFACE;
3034
3034
 
3035
3035
  }
3036
- `,na=`
3036
+ `,jo=`
3037
3037
 
3038
3038
  struct Ray {
3039
3039
 
@@ -3082,7 +3082,7 @@ bool bvhIntersectFogVolumeHit(
3082
3082
 
3083
3083
  }
3084
3084
 
3085
- `,oa=`
3085
+ `,Yo=`
3086
3086
 
3087
3087
  #define NO_HIT 0
3088
3088
  #define SURFACE_HIT 1
@@ -3129,7 +3129,7 @@ bool bvhIntersectFogVolumeHit(
3129
3129
 
3130
3130
  }
3131
3131
 
3132
- `;class aa extends hs{onBeforeRender(){this.setDefine("FEATURE_DOF",this.physicalCamera.bokehSize===0?0:1),this.setDefine("FEATURE_BACKGROUND_MAP",this.backgroundMap?1:0),this.setDefine("FEATURE_FOG",this.materials.features.isUsed("FOG")?1:0)}constructor(e){super({transparent:!0,depthWrite:!1,defines:{FEATURE_MIS:1,FEATURE_RUSSIAN_ROULETTE:1,FEATURE_DOF:1,FEATURE_BACKGROUND_MAP:0,FEATURE_FOG:1,RANDOM_TYPE:2,CAMERA_TYPE:0,DEBUG_MODE:0,ATTR_NORMAL:0,ATTR_TANGENT:1,ATTR_UV:2,ATTR_COLOR:3},uniforms:{resolution:{value:new f.Vector2},opacity:{value:1},bounces:{value:10},transmissiveBounces:{value:10},filterGlossyFactor:{value:0},physicalCamera:{value:new io},cameraWorldMatrix:{value:new f.Matrix4},invProjectionMatrix:{value:new f.Matrix4},bvh:{value:new Ce.MeshBVHUniformStruct},attributesArray:{value:new mo},materialIndexAttribute:{value:new Ce.UIntVertexAttributeTexture},materials:{value:new wo},textures:{value:new Hs().texture},lights:{value:new fo},iesProfiles:{value:new Hs(360,180,{type:f.HalfFloatType,wrapS:f.ClampToEdgeWrapping,wrapT:f.ClampToEdgeWrapping}).texture},environmentIntensity:{value:1},environmentRotation:{value:new f.Matrix4},envMapInfo:{value:new no},backgroundBlur:{value:0},backgroundMap:{value:null},backgroundAlpha:{value:1},backgroundIntensity:{value:1},backgroundRotation:{value:new f.Matrix4},seed:{value:0},sobolTexture:{value:null},stratifiedTexture:{value:new Ro},stratifiedOffsetTexture:{value:new Bo(64,1)}},vertexShader:`
3132
+ `;class Qo extends rs{onBeforeRender(){this.setDefine("FEATURE_DOF",this.physicalCamera.bokehSize===0?0:1),this.setDefine("FEATURE_BACKGROUND_MAP",this.backgroundMap?1:0),this.setDefine("FEATURE_FOG",this.materials.features.isUsed("FOG")?1:0)}constructor(e){super({transparent:!0,depthWrite:!1,defines:{FEATURE_MIS:1,FEATURE_RUSSIAN_ROULETTE:1,FEATURE_DOF:1,FEATURE_BACKGROUND_MAP:0,FEATURE_FOG:1,RANDOM_TYPE:2,CAMERA_TYPE:0,DEBUG_MODE:0,ATTR_NORMAL:0,ATTR_TANGENT:1,ATTR_UV:2,ATTR_COLOR:3},uniforms:{resolution:{value:new d.Vector2},opacity:{value:1},bounces:{value:10},transmissiveBounces:{value:10},filterGlossyFactor:{value:0},physicalCamera:{value:new Wn},cameraWorldMatrix:{value:new d.Matrix4},invProjectionMatrix:{value:new d.Matrix4},bvh:{value:new Ce.MeshBVHUniformStruct},attributesArray:{value:new to},materialIndexAttribute:{value:new Ce.UIntVertexAttributeTexture},materials:{value:new ao},textures:{value:new Ds().texture},lights:{value:new $n},iesProfiles:{value:new Ds(360,180,{type:d.HalfFloatType,wrapS:d.ClampToEdgeWrapping,wrapT:d.ClampToEdgeWrapping}).texture},environmentIntensity:{value:1},environmentRotation:{value:new d.Matrix4},envMapInfo:{value:new jn},backgroundBlur:{value:0},backgroundMap:{value:null},backgroundAlpha:{value:1},backgroundIntensity:{value:1},backgroundRotation:{value:new d.Matrix4},seed:{value:0},sobolTexture:{value:null},stratifiedTexture:{value:new go},stratifiedOffsetTexture:{value:new bo(64,1)}},vertexShader:`
3133
3133
 
3134
3134
  varying vec2 vUv;
3135
3135
  void main() {
@@ -3158,22 +3158,22 @@ bool bvhIntersectFogVolumeHit(
3158
3158
  ${Ce.BVHShaderGLSL.bvh_ray_functions}
3159
3159
 
3160
3160
  // uniform structs
3161
- ${ko}
3162
- ${zo}
3163
- ${Oo}
3164
- ${Vo}
3165
- ${Uo}
3161
+ ${Ao}
3162
+ ${So}
3163
+ ${To}
3164
+ ${Mo}
3165
+ ${Co}
3166
3166
 
3167
3167
  // random
3168
3168
  #if RANDOM_TYPE == 2 // Stratified List
3169
3169
 
3170
- ${$o}
3170
+ ${Bo}
3171
3171
 
3172
3172
  #elif RANDOM_TYPE == 1 // Sobol
3173
3173
 
3174
- ${Ws}
3175
- ${Pr}
3176
- ${Kn}
3174
+ ${Es}
3175
+ ${dr}
3176
+ ${Vn}
3177
3177
 
3178
3178
  #define rand(v) sobol(v)
3179
3179
  #define rand2(v) sobol2(v)
@@ -3182,7 +3182,7 @@ bool bvhIntersectFogVolumeHit(
3182
3182
 
3183
3183
  #else // PCG
3184
3184
 
3185
- ${Ws}
3185
+ ${Es}
3186
3186
 
3187
3187
  // Using the sobol functions seems to break the the compiler on MacOS
3188
3188
  // - specifically the "sobolReverseBits" function.
@@ -3198,11 +3198,11 @@ bool bvhIntersectFogVolumeHit(
3198
3198
  #endif
3199
3199
 
3200
3200
  // common
3201
- ${Yo}
3202
- ${Go}
3203
- ${Ir}
3204
- ${qo}
3205
- ${jo}
3201
+ ${Fo}
3202
+ ${Do}
3203
+ ${mr}
3204
+ ${Lo}
3205
+ ${Eo}
3206
3206
 
3207
3207
  // environment
3208
3208
  uniform EquirectHdrInfo envMapInfo;
@@ -3258,16 +3258,16 @@ bool bvhIntersectFogVolumeHit(
3258
3258
  float lightsDenom;
3259
3259
 
3260
3260
  // sampling
3261
- ${Wo}
3262
- ${Ho}
3263
- ${No}
3261
+ ${Po}
3262
+ ${Io}
3263
+ ${Ro}
3264
3264
 
3265
- ${ea}
3266
- ${Xo}
3267
- ${Jo}
3268
- ${Ko}
3269
- ${Zo}
3270
- ${Qo}
3265
+ ${Ho}
3266
+ ${zo}
3267
+ ${Uo}
3268
+ ${Vo}
3269
+ ${Oo}
3270
+ ${ko}
3271
3271
 
3272
3272
  float applyFilteredGlossy( float roughness, float accumulatedRoughness ) {
3273
3273
 
@@ -3299,12 +3299,12 @@ bool bvhIntersectFogVolumeHit(
3299
3299
 
3300
3300
  }
3301
3301
 
3302
- ${na}
3303
- ${ia}
3304
- ${oa}
3305
- ${ta}
3306
- ${sa}
3307
- ${ra}
3302
+ ${jo}
3303
+ ${Wo}
3304
+ ${Yo}
3305
+ ${No}
3306
+ ${Go}
3307
+ ${qo}
3308
3308
 
3309
3309
  void main() {
3310
3310
 
@@ -3596,7 +3596,7 @@ bool bvhIntersectFogVolumeHit(
3596
3596
 
3597
3597
  }
3598
3598
 
3599
- `}),this.setValues(e)}}function*la(){const{_renderer:r,_fsQuad:e,_blendQuad:t,_primaryTarget:i,_blendTargets:s,_sobolTarget:a,_subframe:o,alpha:c,material:u}=this,p=new f.Vector4,m=new f.Vector4,n=t.material;let[l,h]=s;for(;;){c?(n.opacity=this._opacityFactor/(this.samples+1),u.blending=f.NoBlending,u.opacity=1):(u.opacity=this._opacityFactor/(this.samples+1),u.blending=f.NormalBlending);const[g,_,d,v]=o,y=i.width,x=i.height;u.resolution.set(y*d,x*v),u.sobolTexture=a.texture,u.stratifiedTexture.init(20,u.bounces+u.transmissiveBounces+5),u.stratifiedTexture.next(),u.seed++;const w=this.tiles.x||1,b=this.tiles.y||1,T=w*b,S=Math.ceil(y*d),P=Math.ceil(x*v),C=Math.floor(g*y),R=Math.floor(_*x),E=Math.ceil(S/w),A=Math.ceil(P/b);for(let M=0;M<b;M++)for(let I=0;I<w;I++){const L=r.getRenderTarget(),F=r.autoClear,O=r.getScissorTest();r.getScissor(p),r.getViewport(m);let H=I,W=M;if(!this.stableTiles){const ee=this._currentTile%(w*b);H=ee%w,W=~~(ee/w),this._currentTile=ee+1}const J=b-W-1;i.scissor.set(C+H*E,R+J*A,Math.min(E,S-H*E),Math.min(A,P-J*A)),i.viewport.set(C,R,S,P),r.setRenderTarget(i),r.setScissorTest(!0),r.autoClear=!1,e.render(r),r.setViewport(m),r.setScissor(p),r.setScissorTest(O),r.setRenderTarget(L),r.autoClear=F,c&&(n.target1=l.texture,n.target2=i.texture,r.setRenderTarget(h),t.render(r),r.setRenderTarget(L)),this.samples+=1/T,I===w-1&&M===b-1&&(this.samples=Math.round(this.samples)),yield}[l,h]=[h,l]}}const Gs=new f.Color;class qs{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 ot.FullScreenQuad(new aa),this._blendQuad=new ot.FullScreenQuad(new Zn),this._task=null,this._currentTile=0,this._compilePromise=null,this._sobolTarget=new eo().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(),a=e.getClearAlpha();e.getClearColor(Gs),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(Gs,a),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=la.call(this)),this._task.next())}}const Be=new f.Vector2,js=new f.Vector2,Vt=new f.Spherical,Ut=new f.Color;class ca 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 a=0;a<i;a++){js.set(t,i),Be.set(s/t,a/i),Be.x-=.5,Be.y=1-Be.y,Vt.theta=Be.x*2*Math.PI,Vt.phi=Be.y*Math.PI,Vt.radius=1,this.generationCallback(Vt,Be,js,Ut);const c=4*(a*t+s);e[c+0]=Ut.r,e[c+1]=Ut.g,e[c+2]=Ut.b,e[c+3]=1}}copy(e){return super.copy(e),this.generationCallback=e.generationCallback,this}}const Ys=new f.Vector3;class ua extends ca{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,a)=>{Ys.setFromSpherical(t);const o=Ys.y*.5+.5;a.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 ha 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:`
3599
+ `}),this.setValues(e)}}function*Zo(){const{_renderer:n,_fsQuad:e,_blendQuad:t,_primaryTarget:i,_blendTargets:s,_sobolTarget:a,_subframe:o,alpha:c,material:u}=this,f=new d.Vector4,p=new d.Vector4,r=t.material;let[l,h]=s;for(;;){c?(r.opacity=this._opacityFactor/(this.samples+1),u.blending=d.NoBlending,u.opacity=1):(u.opacity=this._opacityFactor/(this.samples+1),u.blending=d.NormalBlending);const[g,_,m,v]=o,y=i.width,x=i.height;u.resolution.set(y*m,x*v),u.sobolTexture=a.texture,u.stratifiedTexture.init(20,u.bounces+u.transmissiveBounces+5),u.stratifiedTexture.next(),u.seed++;const w=this.tiles.x||1,b=this.tiles.y||1,A=w*b,S=Math.ceil(y*m),I=Math.ceil(x*v),M=Math.floor(g*y),P=Math.floor(_*x),R=Math.ceil(S/w),T=Math.ceil(I/b);for(let C=0;C<b;C++)for(let D=0;D<w;D++){const E=n.getRenderTarget(),F=n.autoClear,O=n.getScissorTest();n.getScissor(f),n.getViewport(p);let H=D,W=C;if(!this.stableTiles){const ee=this._currentTile%(w*b);H=ee%w,W=~~(ee/w),this._currentTile=ee+1}const $=b-W-1;i.scissor.set(M+H*R,P+$*T,Math.min(R,S-H*R),Math.min(T,I-$*T)),i.viewport.set(M,P,S,I),n.setRenderTarget(i),n.setScissorTest(!0),n.autoClear=!1,e.render(n),n.setViewport(p),n.setScissor(f),n.setScissorTest(O),n.setRenderTarget(E),n.autoClear=F,c&&(r.target1=l.texture,r.target2=i.texture,n.setRenderTarget(h),t.render(n),n.setRenderTarget(E)),this.samples+=1/A,D===w-1&&C===b-1&&(this.samples=Math.round(this.samples)),yield}[l,h]=[h,l]}}const Fs=new d.Color;class Bs{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 d.Vector2(3,3),this.stableNoise=!1,this.stableTiles=!0,this.samples=0,this._subframe=new d.Vector4(0,0,1,1),this._opacityFactor=1,this._renderer=e,this._alpha=!1,this._fsQuad=new nt.FullScreenQuad(new Qo),this._blendQuad=new nt.FullScreenQuad(new On),this._task=null,this._currentTile=0,this._compilePromise=null,this._sobolTarget=new Hn().generate(e),this._primaryTarget=new d.WebGLRenderTarget(1,1,{format:d.RGBAFormat,type:d.FloatType,magFilter:d.NearestFilter,minFilter:d.NearestFilter}),this._blendTargets=[new d.WebGLRenderTarget(1,1,{format:d.RGBAFormat,type:d.FloatType,magFilter:d.NearestFilter,minFilter:d.NearestFilter}),new d.WebGLRenderTarget(1,1,{format:d.RGBAFormat,type:d.FloatType,magFilter:d.NearestFilter,minFilter:d.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(),a=e.getClearAlpha();e.getClearColor(Fs),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(Fs,a),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=Zo.call(this)),this._task.next())}}const Fe=new d.Vector2,ks=new d.Vector2,Ot=new d.Spherical,zt=new d.Color;class Xo extends d.DataTexture{constructor(e=512,t=512){super(new Float32Array(e*t*4),e,t,d.RGBAFormat,d.FloatType,d.EquirectangularReflectionMapping,d.RepeatWrapping,d.ClampToEdgeWrapping,d.LinearFilter,d.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 a=0;a<i;a++){ks.set(t,i),Fe.set(s/t,a/i),Fe.x-=.5,Fe.y=1-Fe.y,Ot.theta=Fe.x*2*Math.PI,Ot.phi=Fe.y*Math.PI,Ot.radius=1,this.generationCallback(Ot,Fe,ks,zt);const c=4*(a*t+s);e[c+0]=zt.r,e[c+1]=zt.g,e[c+2]=zt.b,e[c+3]=1}}copy(e){return super.copy(e),this.generationCallback=e.generationCallback,this}}const Os=new d.Vector3;class Ko extends Xo{constructor(e=512){super(e,e),this.topColor=new d.Color().set(16777215),this.bottomColor=new d.Color().set(0),this.exponent=2,this.generationCallback=(t,i,s,a)=>{Os.setFromSpherical(t);const o=Os.y*.5+.5;a.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 Jo extends d.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
 
@@ -3653,7 +3653,7 @@ bool bvhIntersectFogVolumeHit(
3653
3653
  #include <premultiplied_alpha_fragment>
3654
3654
 
3655
3655
  }
3656
- `}),this.setValues(e)}}class fa extends f.ShaderMaterial{constructor(){super({uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:`
3656
+ `}),this.setValues(e)}}class $o extends d.ShaderMaterial{constructor(){super({uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:`
3657
3657
  varying vec2 vUv;
3658
3658
  void main() {
3659
3659
 
@@ -3670,7 +3670,7 @@ bool bvhIntersectFogVolumeHit(
3670
3670
  #include <common>
3671
3671
  #include <cube_uv_reflection_fragment>
3672
3672
 
3673
- ${Ir}
3673
+ ${mr}
3674
3674
 
3675
3675
  void main() {
3676
3676
 
@@ -3678,14 +3678,14 @@ bool bvhIntersectFogVolumeHit(
3678
3678
  rayDirection.x *= flipEnvMap;
3679
3679
  gl_FragColor = textureCube( envMap, rayDirection );
3680
3680
 
3681
- }`}),this.depthWrite=!1,this.depthTest=!1}}class $s{constructor(e){this._renderer=e,this._quad=new ot.FullScreenQuad(new fa)}generate(e,t=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],a=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}),u=s.height,p=Math.log2(u)-2,m=1/u,n=1/(3*Math.max(Math.pow(2,p),7*16));o.material.defines.CUBEUV_MAX_MIP=`${p}.0`,o.material.defines.CUBEUV_TEXEL_WIDTH=n,o.material.defines.CUBEUV_TEXEL_HEIGHT=m,o.material.uniforms.envMap.value=e,o.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,o.material.needsUpdate=!0;const l=a.getRenderTarget(),h=a.autoClear;a.autoClear=!0,a.setRenderTarget(c),o.render(a),a.setRenderTarget(l),a.autoClear=h;const g=new Uint16Array(t*i*4),_=new Float32Array(t*i*4);a.readRenderTargetPixels(c,0,0,t,i,_),c.dispose();for(let v=0,y=_.length;v<y;v++)g[v]=f.DataUtils.toHalfFloat(_[v]);const d=new f.DataTexture(g,t,i,f.RGBAFormat,f.HalfFloatType);return d.minFilter=f.LinearMipMapLinearFilter,d.magFilter=f.LinearFilter,d.wrapS=f.RepeatWrapping,d.wrapT=f.RepeatWrapping,d.mapping=f.EquirectangularReflectionMapping,d.needsUpdate=!0,d}dispose(){this._quad.dispose()}}function da(r){return r.extensions.get("EXT_float_blend")}const He=new f.Vector2;class pa{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 Qn,this._pathTracer=new qs(e),this._queueReset=!1,this._clock=new f.Clock,this._compilePromise=null,this._lowResPathTracer=new qs(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new ot.FullScreenQuad(new ha({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 a=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=a},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(a=>this._updateFromResults(e,t,a));{const a=s.generate();return this._updateFromResults(e,t,a)}}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,a=_o(i);e.textures.setTextures(t,a,s.x,s.y),e.materials.updateFrom(i,a),this.reset()}updateLights(){const e=this.scene,t=this._renderer,i=this._pathTracer.material,s=yo(e),a=vo(s);i.lights.updateFrom(s,a),i.iesProfiles.setTextures(t,a),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 ua(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 $s(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 $s(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:a,bvh:o,bvhChanged:c}=i;this._materials=s;const p=this._pathTracer.material;return c&&(p.bvh.updateFrom(o),p.attributesArray.updateFrom(a.attributes.normal,a.attributes.tangent,a.attributes.uv,a.attributes.color),p.materialIndexAttribute.updateFrom(a.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,a=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,a.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||!da(i),e.alpha=t.alpha,this.renderToCanvas){const u=this._renderer,p=this.minSamples;if(c>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?a.material.opacity=Math.min(a.material.opacity+o/this.fadeDuration,1):a.material.opacity=1),!this.enablePathTracing||this.samples<p||a.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const m=a.material.opacity;a.material.opacity=1-a.material.opacity,a.material.map=e.target.texture,a.render(u),a.material.opacity=m}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&a.material.opacity>0&&(a.material.opacity<1&&(a.material.blending=this.dynamicLowRes?f.AdditiveBlending:f.NormalBlending),a.material.map=t.target.texture,this.renderToCanvasCallback(t.target,u,a),a.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(He);const e=Math.floor(this.renderScale*He.x),t=Math.floor(this.renderScale*He.y);if(this._pathTracer.getSize(He),He.x!==e||He.y!==t){const i=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(t*i))}}}}const ma="";globalThis.GLTF_PROGRESSIVE_VERSION=ma;console.debug("[gltf-progressive] version -");let le="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",mi="https://cdn.needle.tools/static/three/0.179.1/basis2/";const ga=le,va=mi,Er=new URL(le+"draco_decoder.js");Er.searchParams.append("range","true");fetch(Er,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(r=>{console.debug(`Failed to fetch remote Draco decoder from ${le} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),le===ga&&ya("./include/draco/"),mi===va&&xa("./include/ktx2/")}).finally(()=>{Lr()});const _a=()=>({dracoDecoderPath:le,ktx2TranscoderPath:mi});function ya(r){le=r,X&&X[Gi]!=le?(console.debug("Updating Draco decoder path to "+r),X[Gi]=le,X.setDecoderPath(le),X.preload()):console.debug("Setting Draco decoder path to "+r)}function xa(r){mi=r}function ds(r){return Lr(),{dracoLoader:X,meshoptDecoder:li}}function Dr(r){r.dracoLoader||r.setDRACOLoader(X),r.meshoptDecoder||r.setMeshoptDecoder(li)}const Gi=Symbol("dracoDecoderPath");let X,li;function Lr(){X||(X=new An.DRACOLoader,X[Gi]=le,X.setDecoderPath(le),X.setDecoderConfig({type:"js"}),X.preload()),li||(li=bn.MeshoptDecoder)}const qi=new WeakMap;function Fr(r,e){let t=qi.get(r);t?t=Object.assign(t,e):t=e,qi.set(r,t)}const Si=cs.GLTFLoader.prototype.load;function wa(...r){const e=qi.get(this);let t=r[0];const i=new URL(t,window.location.href);if(i.hostname.endsWith("needle.tools")){const a=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,o=e!=null&&e.usecase?e.usecase:"default";a?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${o}`:this.requestHeader.Accept=`*/*;usecase=${o}`,t=i.toString()}return r[0]=t,Si==null?void 0:Si.call(this,...r)}cs.GLTFLoader.prototype.load=wa;ze("debugprogressive");function ze(r){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(r);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function ba(r,e){if(e===void 0||r===void 0||e.startsWith("./")||e.startsWith("http")||e.startsWith("data:")||e.startsWith("blob:"))return e;const t=r.lastIndexOf("/");if(t>=0){const i=r.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}function Br(){return pt!==void 0||(pt=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),ze("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",pt)),pt}let pt;function Qs(){if(typeof window>"u")return!1;const r=new URL(window.location.href),e=r.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(r.hostname);return r.hostname==="127.0.0.1"||e}class Aa{constructor(e=100,t={}){D(this,"_running",new Map);D(this,"_queue",[]);D(this,"debug",!1);D(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:a=>this.add(i,a)})}}}const Ta=typeof window>"u"&&typeof document>"u",ji=Symbol("needle:raycast-mesh");function Ft(r){return(r==null?void 0:r[ji])instanceof f.BufferGeometry?r[ji]:null}function Sa(r,e){if((r.type==="Mesh"||r.type==="SkinnedMesh")&&!Ft(r)){const i=Ma(e);i.userData={isRaycastMesh:!0},r[ji]=i}}function Ca(r=!0){if(r){if(mt)return;const e=mt=f.Mesh.prototype.raycast;f.Mesh.prototype.raycast=function(t,i){const s=this,a=Ft(s);let o;a&&s.isMesh&&(o=s.geometry,s.geometry=a),e.call(this,t,i),o&&(s.geometry=o)}}else{if(!mt)return;f.Mesh.prototype.raycast=mt,mt=null}}let mt=null;function Ma(r){const e=new f.BufferGeometry;for(const t in r.attributes)e.setAttribute(t,r.getAttribute(t));return e.setIndex(r.getIndex()),e}const Te=new Array,k=ze("debugprogressive");let Rt,ke=-1;if(k){let r=function(){ke+=1,ke>=e&&(ke=-1),console.log(`Toggle LOD level [${ke}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&r(),t.key==="w"&&(Rt=!Rt,console.log(`Toggle wireframe [${Rt}]`));const i=parseInt(t.key);!isNaN(i)&&i>=0&&(ke=i,console.log(`Set LOD level to [${ke}]`))})}function kr(r){if(k&&Rt!==void 0)if(Array.isArray(r))for(const e of r)kr(e);else r&&"wireframe"in r&&(r.wireframe=Rt===!0)}const gt=new Array;let Pa=0;const Ra=Br()?2:10;function Ia(r){if(gt.length<Ra){const i=gt.length;k&&console.warn(`[Worker] Creating new worker #${i}`);const s=ps.createWorker(r||{});return gt.push(s),s}const e=Pa++%gt.length;return gt[e]}class ps{constructor(e,t){D(this,"_running",[]);D(this,"_webglRenderer",null);D(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 a of this._running)if(a.url===s.result.url){Ea(s.result),a.resolve(s.result);const o=a.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-fysOIq2s.js").href:new URL("assets/loader.worker-fysOIq2s.js",document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:at&&at.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});return new ps(t,e)}async load(e,t){const i=_a();let s=t==null?void 0:t.renderer;s||(this._webglRenderer??(this._webglRenderer=(async()=>{const{WebGLRenderer:p}=await import("three");return new p})()),s=await this._webglRenderer);const c=ds().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 u={type:"load",url:e,dracoDecoderPath:i.dracoDecoderPath,ktx2TranscoderPath:i.ktx2TranscoderPath,ktx2LoaderConfig:c};return this._debug&&console.debug("[Worker] Sending load request",u),this.worker.postMessage(u),new Promise(p=>{this._running.push({url:e.toString(),resolve:p})})}}function Ea(r){var e,t,i,s,a,o,c,u,p,m,n,l,h,g,_,d;for(const v of r.geometries){const y=v.geometry,x=new f.BufferGeometry;if(x.name=y.name||"",y.index){const w=y.index;x.setIndex(Ci(w))}for(const w in y.attributes){const b=y.attributes[w],T=Ci(b);x.setAttribute(w,T)}if(y.morphAttributes)for(const w in y.morphAttributes){const T=y.morphAttributes[w].map(S=>Ci(S));x.morphAttributes[w]=T}if(x.morphTargetsRelative=y.morphTargetsRelative??!1,x.boundingBox=new f.Box3,x.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),x.boundingBox.max=new f.Vector3((s=y.boundingBox)==null?void 0:s.max.x,(a=y.boundingBox)==null?void 0:a.max.y,(o=y.boundingBox)==null?void 0:o.max.z),x.boundingSphere=new f.Sphere(new f.Vector3((c=y.boundingSphere)==null?void 0:c.center.x,(u=y.boundingSphere)==null?void 0:u.center.y,(p=y.boundingSphere)==null?void 0:p.center.z),(m=y.boundingSphere)==null?void 0:m.radius),y.groups)for(const w of y.groups)x.addGroup(w.start,w.count,w.materialIndex);y.userData&&(x.userData=y.userData),v.geometry=x}for(const v of r.textures){const y=v.texture;let x=null;if(y.isCompressedTexture){const w=y.mipmaps,b=((n=y.image)==null?void 0:n.width)||((h=(l=y.source)==null?void 0:l.data)==null?void 0:h.width)||-1,T=((g=y.image)==null?void 0:g.height)||((d=(_=y.source)==null?void 0:_.data)==null?void 0:d.height)||-1;x=new f.CompressedTexture(w,b,T,y.format,y.type,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.anisotropy,y.colorSpace)}else x=new f.Texture(y.image,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.format,y.type,y.anisotropy,y.colorSpace),x.mipmaps=y.mipmaps,x.channel=y.channel,x.source.data=y.source.data,x.flipY=y.flipY,x.premultiplyAlpha=y.premultiplyAlpha,x.unpackAlignment=y.unpackAlignment,x.matrix=new f.Matrix3(...y.matrix.elements);if(!x){console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");continue}v.texture=x}return r}function Ci(r){let e=r;if("isInterleavedBufferAttribute"in r&&r.isInterleavedBufferAttribute){const t=r.data,i=t.array,s=new f.InterleavedBuffer(i,t.stride);e=new f.InterleavedBufferAttribute(s,r.itemSize,i.byteOffset,r.normalized),e.offset=r.offset}else"isBufferAttribute"in r&&r.isBufferAttribute&&(e=new f.BufferAttribute(r.array,r.itemSize,r.normalized),e.usage=r.usage,e.gpuType=r.gpuType,e.updateRanges=r.updateRanges);return e}const Da=ze("gltf-progressive-worker"),La=ze("gltf-progressive-reduce-mipmaps"),Mi=Symbol("needle-progressive-texture"),ge="NEEDLE_progressive",B=class B{constructor(e){D(this,"parser");D(this,"url");D(this,"_isLoadingMesh");D(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[ge];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(a=>{var o;return this._isLoadingMesh=!1,a&&B.registerMesh(this.url,t.guid,a,(o=t.lods)==null?void 0:o.length,0,t),a})):null});const t=e.options.path;k&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return ge}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",a=e[s];if(a!=null)return a;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(k==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const c=e;for(const u of Object.keys(c.uniforms)){const p=c.uniforms[u].value;(p==null?void 0:p.isTexture)===!0&&o(p,t)}}else if(e.isMaterial)for(const c of Object.keys(e)){const u=e[c];(u==null?void 0:u.isTexture)===!0&&o(u,t)}else k&&console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);return e[s]=t,t;function o(c,u){const p=i.getAssignedLODInformation(c);if(p){const m=i.lodInfos.get(p.key);if(m&&m.lods){u.min_count=Math.min(u.min_count,m.lods.length),u.max_count=Math.max(u.max_count,m.lods.length);for(let n=0;n<m.lods.length;n++){const l=m.lods[n];l.width&&(u.lods[n]=u.lods[n]||{min_height:1/0,max_height:0},u.lods[n].min_height=Math.min(u.lods[n].min_height,l.height),u.lods[n].max_height=Math.max(u.lods[n].max_height,l.height))}}}}}static hasLODLevelAvailable(e,t){var a;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&&(a=i==null?void 0:i.userData)!=null&&a.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,a=this.getAssignedLODInformation(s);if(!a)return Promise.resolve(null);for(const o of Te)(i=o.onBeforeGetLODMesh)==null||i.call(o,e,t);return e["LOD:requested level"]=t,B.getOrLoadLOD(s,t).then(o=>{if(Array.isArray(o)){const c=a.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:k&&console.error("Invalid LOD geometry",o))),o}).catch(o=>(console.error("Error loading mesh LOD",e,o),null))}else k&&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 a of i.material){const o=this.assignTextureLOD(a,t);s.push(o)}return Promise.all(s).then(a=>{const o=new Array;for(const c of a)Array.isArray(c)&&o.push(...c);return o})}else return this.assignTextureLOD(i.material,t)}if(e.isMaterial===!0){const i=e,s=[],a=new Array;if(i.uniforms&&(i.isRawShaderMaterial||i.isShaderMaterial===!0)){const o=i;for(const c of Object.keys(o.uniforms)){const u=o.uniforms[c].value;if((u==null?void 0:u.isTexture)===!0){const p=this.assignTextureLODForSlot(u,t,i,c).then(m=>(m&&o.uniforms[c].value!=m&&(o.uniforms[c].value=m,o.uniformsNeedUpdate=!0),m));s.push(p),a.push(c)}}}else for(const o of Object.keys(i)){const c=i[o];if((c==null?void 0:c.isTexture)===!0){const u=this.assignTextureLODForSlot(c,t,i,o);s.push(u),a.push(o)}}return Promise.all(s).then(o=>{const c=new Array;for(let u=0;u<o.length;u++){const p=o[u],m=a[u];p&&p.isTexture===!0?c.push({material:i,slot:m,texture:p,level:t}):c.push({material:i,slot:m,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):B.getOrLoadLOD(e,t).then(a=>{var o,c;if(Array.isArray(a))return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."),null;if((a==null?void 0:a.isTexture)===!0){if(a!=e&&i&&s){const u=i[s];if(u&&!k){const p=this.getAssignedLODInformation(u);if(p&&(p==null?void 0:p.level)<t)return k==="verbose"&&console.warn("Assigned texture level is already higher: ",p.level,t,i,u,a),null}if(La&&a.mipmaps){const p=a.mipmaps.length;a.mipmaps.length=Math.min(a.mipmaps.length,3),p!==a.mipmaps.length&&k&&console.debug(`Reduced mipmap count from ${p} to ${a.mipmaps.length} for ${a.uuid}: ${(o=a.image)==null?void 0:o.width}x${(c=a.image)==null?void 0:c.height}.`)}i[s]=a}return a}else k=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(a=>(console.error("Error loading LOD",e,a),null))}afterRoot(e){var t,i;return k&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,a)=>{var o;if(s!=null&&s.extensions){const c=s==null?void 0:s.extensions[ge];if(c){if(!c.lods){k&&console.warn("Texture has no LODs",c);return}let u=!1;for(const p of this.parser.associations.keys())if(p.isTexture===!0){const m=this.parser.associations.get(p);(m==null?void 0:m.textures)===a&&(u=!0,B.registerTexture(this.url,p,(o=c.lods)==null?void 0:o.length,a,c))}u||this.parser.getDependency("texture",a).then(p=>{var m;p&&B.registerTexture(this.url,p,(m=c.lods)==null?void 0:m.length,a,c)})}}}),(i=this.parser.json.meshes)==null||i.forEach((s,a)=>{if(s!=null&&s.extensions){const o=s==null?void 0:s.extensions[ge];if(o&&o.lods){for(const c of this.parser.associations.keys())if(c.isMesh){const u=this.parser.associations.get(c);(u==null?void 0:u.meshes)===a&&B.registerMesh(this.url,o.guid,c,o.lods.length,u.primitives,o)}}}}),null}static async getOrLoadLOD(e,t){var u,p,m,n;const i=k=="verbose",s=this.getAssignedLODInformation(e);if(!s)return k&&console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`,e),null;const a=s==null?void 0:s.key;let o;if(e.isTexture===!0){const l=e;l.source&&l.source[Mi]&&(o=l.source[Mi])}if(o||(o=B.lodInfos.get(a)),!o)k&&console.warn(`Can not load LOD ${t}: no LOD info found for "${a}" ${e.name}`,e.type,B.lodInfos);else{if(t>0){let g=!1;const _=Array.isArray(o.lods);if(_&&t>=o.lods.length?g=!0:_||(g=!0),g)return this.lowresCache.get(a)}const l=Array.isArray(o.lods)?(u=o.lods[t])==null?void 0:u.path:o.lods;if(!l)return k&&!o["missing:uri"]&&(o["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,o)),null;const h=ba(s.url,l);if(h.endsWith(".glb")||h.endsWith(".gltf")){if(!o.guid)return console.warn("missing pointer for glb/gltf texture",o),null;const g=h+"_"+o.guid,_=await this.queue.slot(h),d=this.previouslyLoaded.get(g);if(d!==void 0){i&&console.log(`LOD ${t} was already loading/loaded: ${g}`);let w=await d.catch(T=>(console.error(`Error loading LOD ${t} from ${h}
3682
- `,T),null)),b=!1;if(w==null||(w instanceof f.Texture&&e instanceof f.Texture?(p=w.image)!=null&&p.data||(m=w.source)!=null&&m.data?w=this.copySettings(e,w):(b=!0,this.previouslyLoaded.delete(g)):w instanceof f.BufferGeometry&&e instanceof f.BufferGeometry&&((n=w.attributes.position)!=null&&n.array||(b=!0,this.previouslyLoaded.delete(g)))),!b)return w}if(!_.use)return k&&console.log(`LOD ${t} was aborted: ${h}`),null;const v=o,y=new Promise(async(w,b)=>{if(Da){const A=await(await Ia({})).load(h);if(A.textures.length>0)for(const M of A.textures){let I=M.texture;return B.assignLODInformation(s.url,I,a,t,void 0),e instanceof f.Texture&&(I=this.copySettings(e,I)),I&&(I.guid=v.guid),w(I)}if(A.geometries.length>0){const M=new Array;for(const I of A.geometries){const L=I.geometry;B.assignLODInformation(s.url,L,a,t,I.primitiveIndex),M.push(L)}return w(M)}return w(null)}const T=new cs.GLTFLoader;Dr(T),k&&(await new Promise(E=>setTimeout(E,1e3)),i&&console.warn("Start loading (delayed) "+h,v.guid));let S=h;if(v&&Array.isArray(v.lods)){const E=v.lods[t];E.hash&&(S+="?v="+E.hash)}const P=await T.loadAsync(S).catch(E=>(console.error(`Error loading LOD ${t} from ${h}
3683
- `,E),w(null)));if(!P)return w(null);const C=P.parser;i&&console.log("Loading finished "+h,v.guid);let R=0;if(P.parser.json.textures){let E=!1;for(const A of P.parser.json.textures){if(A!=null&&A.extensions){const M=A==null?void 0:A.extensions[ge];if(M!=null&&M.guid&&M.guid===v.guid){E=!0;break}}R++}if(E){let A=await C.getDependency("texture",R);return A&&B.assignLODInformation(s.url,A,a,t,void 0),i&&console.log('change "'+e.name+'" → "'+A.name+'"',h,R,A,g),e instanceof f.Texture&&(A=this.copySettings(e,A)),A&&(A.guid=v.guid),w(A)}else k&&console.warn("Could not find texture with guid",v.guid,P.parser.json)}if(R=0,P.parser.json.meshes){let E=!1;for(const A of P.parser.json.meshes){if(A!=null&&A.extensions){const M=A==null?void 0:A.extensions[ge];if(M!=null&&M.guid&&M.guid===v.guid){E=!0;break}}R++}if(E){const A=await C.getDependency("mesh",R);if(i&&console.log(`Loaded Mesh "${A.name}"`,h,R,A,g),A.isMesh===!0){const M=A.geometry;return B.assignLODInformation(s.url,M,a,t,0),w(M)}else{const M=new Array;for(let I=0;I<A.children.length;I++){const L=A.children[I];if(L.isMesh===!0){const F=L.geometry;B.assignLODInformation(s.url,F,a,t,I),M.push(F)}}return w(M)}}else k&&console.warn("Could not find mesh with guid",v.guid,P.parser.json)}return w(null)});return this.previouslyLoaded.set(g,y),_.use(y),await y}else if(e instanceof f.Texture){i&&console.log("Load texture from uri: "+h);const _=await new f.TextureLoader().loadAsync(h);return _?(_.guid=o.guid,_.flipY=!1,_.needsUpdate=!0,_.colorSpace=e.colorSpace,i&&console.log(o,_)):k&&console.warn("failed loading",h),_}}return null}static assignLODInformation(e,t,i,s,a){if(!t)return;t.userData||(t.userData={});const o=new Fa(e,i,s,a);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?(k==="verbose"&&console.debug(`Copy texture settings
3681
+ }`}),this.depthWrite=!1,this.depthTest=!1}}class zs{constructor(e){this._renderer=e,this._quad=new nt.FullScreenQuad(new $o)}generate(e,t=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],a=this._renderer,o=this._quad;t===null&&(t=4*s.height),i===null&&(i=2*s.height);const c=new d.WebGLRenderTarget(t,i,{type:d.FloatType,colorSpace:s.colorSpace}),u=s.height,f=Math.log2(u)-2,p=1/u,r=1/(3*Math.max(Math.pow(2,f),7*16));o.material.defines.CUBEUV_MAX_MIP=`${f}.0`,o.material.defines.CUBEUV_TEXEL_WIDTH=r,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=a.getRenderTarget(),h=a.autoClear;a.autoClear=!0,a.setRenderTarget(c),o.render(a),a.setRenderTarget(l),a.autoClear=h;const g=new Uint16Array(t*i*4),_=new Float32Array(t*i*4);a.readRenderTargetPixels(c,0,0,t,i,_),c.dispose();for(let v=0,y=_.length;v<y;v++)g[v]=d.DataUtils.toHalfFloat(_[v]);const m=new d.DataTexture(g,t,i,d.RGBAFormat,d.HalfFloatType);return m.minFilter=d.LinearMipMapLinearFilter,m.magFilter=d.LinearFilter,m.wrapS=d.RepeatWrapping,m.wrapT=d.RepeatWrapping,m.mapping=d.EquirectangularReflectionMapping,m.needsUpdate=!0,m}dispose(){this._quad.dispose()}}function ea(n){return n.extensions.get("EXT_float_blend")}const Ue=new d.Vector2;class ta{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 kn,this._pathTracer=new Bs(e),this._queueReset=!1,this._clock=new d.Clock,this._compilePromise=null,this._lowResPathTracer=new Bs(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new nt.FullScreenQuad(new Jo({map:null,transparent:!0,blending:d.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 d.Vector2(1024,1024),this.rasterizeSceneCallback=(t,i)=>{this._renderer.render(t,i)},this.renderToCanvasCallback=(t,i,s)=>{const a=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=a},this.setScene(new d.Scene,new d.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(a=>this._updateFromResults(e,t,a));{const a=s.generate();return this._updateFromResults(e,t,a)}}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,a=ro(i);e.textures.setTextures(t,a,s.x,s.y),e.materials.updateFrom(i,a),this.reset()}updateLights(){const e=this.scene,t=this._renderer,i=this._pathTracer.material,s=no(e),a=so(s);i.lights.updateFrom(s,a),i.iesProfiles.setTextures(t,a),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 Ko(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 zs(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 zs(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:a,bvh:o,bvhChanged:c}=i;this._materials=s;const f=this._pathTracer.material;return c&&(f.bvh.updateFrom(o),f.attributesArray.updateFrom(a.attributes.normal,a.attributes.tangent,a.attributes.uv,a.attributes.color),f.materialIndexAttribute.updateFrom(a.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,a=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,a.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||!ea(i),e.alpha=t.alpha,this.renderToCanvas){const u=this._renderer,f=this.minSamples;if(c>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?a.material.opacity=Math.min(a.material.opacity+o/this.fadeDuration,1):a.material.opacity=1),!this.enablePathTracing||this.samples<f||a.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const p=a.material.opacity;a.material.opacity=1-a.material.opacity,a.material.map=e.target.texture,a.render(u),a.material.opacity=p}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&a.material.opacity>0&&(a.material.opacity<1&&(a.material.blending=this.dynamicLowRes?d.AdditiveBlending:d.NormalBlending),a.material.map=t.target.texture,this.renderToCanvasCallback(t.target,u,a),a.material.blending=d.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(Ue);const e=Math.floor(this.renderScale*Ue.x),t=Math.floor(this.renderScale*Ue.y);if(this._pathTracer.getSize(Ue),Ue.x!==e||Ue.y!==t){const i=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(t*i))}}}}const ia="";globalThis.GLTF_PROGRESSIVE_VERSION=ia;console.debug("[gltf-progressive] version -");let le="https://www.gstatic.com/draco/versioned/decoders/1.5.7/",ci="https://cdn.needle.tools/static/three/0.179.1/basis2/";const sa=le,ra=ci,gr=new URL(le+"draco_decoder.js");gr.searchParams.append("range","true");fetch(gr,{method:"GET",headers:{Range:"bytes=0-1"}}).catch(n=>{console.debug(`Failed to fetch remote Draco decoder from ${le} (offline: ${typeof navigator<"u"?navigator.onLine:"unknown"})`),le===sa&&oa("./include/draco/"),ci===ra&&aa("./include/ktx2/")}).finally(()=>{_r()});const na=()=>({dracoDecoderPath:le,ktx2TranscoderPath:ci});function oa(n){le=n,K&&K[Oi]!=le?(console.debug("Updating Draco decoder path to "+n),K[Oi]=le,K.setDecoderPath(le),K.preload()):console.debug("Setting Draco decoder path to "+n)}function aa(n){ci=n}function os(n){return _r(),{dracoLoader:K,meshoptDecoder:ri}}function vr(n){n.dracoLoader||n.setDRACOLoader(K),n.meshoptDecoder||n.setMeshoptDecoder(ri)}const Oi=Symbol("dracoDecoderPath");let K,ri;function _r(){K||(K=new an.DRACOLoader,K[Oi]=le,K.setDecoderPath(le),K.setDecoderConfig({type:"js"}),K.preload()),ri||(ri=on.MeshoptDecoder)}const zi=new WeakMap;function yr(n,e){let t=zi.get(n);t?t=Object.assign(t,e):t=e,zi.set(n,t)}const yi=is.GLTFLoader.prototype.load;function la(...n){const e=zi.get(this);let t=n[0];const i=new URL(t,window.location.href);if(i.hostname.endsWith("needle.tools")){const a=(e==null?void 0:e.progressive)!==void 0?e.progressive:!0,o=e!=null&&e.usecase?e.usecase:"default";a?this.requestHeader.Accept=`*/*;progressive=allowed;usecase=${o}`:this.requestHeader.Accept=`*/*;usecase=${o}`,t=i.toString()}return n[0]=t,yi==null?void 0:yi.call(this,...n)}is.GLTFLoader.prototype.load=la;Oe("debugprogressive");function Oe(n){if(typeof window>"u")return!1;const t=new URL(window.location.href).searchParams.get(n);return t==null||t==="0"||t==="false"?!1:t===""?!0:t}function ca(n,e){if(e===void 0||n===void 0||e.startsWith("./")||e.startsWith("http")||e.startsWith("data:")||e.startsWith("blob:"))return e;const t=n.lastIndexOf("/");if(t>=0){const i=n.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);return i+e}return e}function xr(){return dt!==void 0||(dt=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent),Oe("debugprogressive")&&console.log("[glTF Progressive]: isMobileDevice",dt)),dt}let dt;function Vs(){if(typeof window>"u")return!1;const n=new URL(window.location.href),e=n.hostname==="localhost"||/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(n.hostname);return n.hostname==="127.0.0.1"||e}class ua{constructor(e=100,t={}){L(this,"_running",new Map);L(this,"_queue",[]);L(this,"debug",!1);L(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:a=>this.add(i,a)})}}}const ha=typeof window>"u"&&typeof document>"u",Vi=Symbol("needle:raycast-mesh");function Lt(n){return(n==null?void 0:n[Vi])instanceof d.BufferGeometry?n[Vi]:null}function fa(n,e){if((n.type==="Mesh"||n.type==="SkinnedMesh")&&!Lt(n)){const i=pa(e);i.userData={isRaycastMesh:!0},n[Vi]=i}}function da(n=!0){if(n){if(pt)return;const e=pt=d.Mesh.prototype.raycast;d.Mesh.prototype.raycast=function(t,i){const s=this,a=Lt(s);let o;a&&s.isMesh&&(o=s.geometry,s.geometry=a),e.call(this,t,i),o&&(s.geometry=o)}}else{if(!pt)return;d.Mesh.prototype.raycast=pt,pt=null}}let pt=null;function pa(n){const e=new d.BufferGeometry;for(const t in n.attributes)e.setAttribute(t,n.getAttribute(t));return e.setIndex(n.getIndex()),e}const Se=new Array,k=Oe("debugprogressive");let Ct,Be=-1;if(k){let n=function(){Be+=1,Be>=e&&(Be=-1),console.log(`Toggle LOD level [${Be}]`)},e=6;window.addEventListener("keyup",t=>{t.key==="p"&&n(),t.key==="w"&&(Ct=!Ct,console.log(`Toggle wireframe [${Ct}]`));const i=parseInt(t.key);!isNaN(i)&&i>=0&&(Be=i,console.log(`Set LOD level to [${Be}]`))})}function wr(n){if(k&&Ct!==void 0)if(Array.isArray(n))for(const e of n)wr(e);else n&&"wireframe"in n&&(n.wireframe=Ct===!0)}const mt=new Array;let ma=0;const ga=xr()?2:10;function va(n){if(mt.length<ga){const i=mt.length;k&&console.warn(`[Worker] Creating new worker #${i}`);const s=as.createWorker(n||{});return mt.push(s),s}const e=ma++%mt.length;return mt[e]}class as{constructor(e,t){L(this,"_running",[]);L(this,"_webglRenderer",null);L(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 a of this._running)if(a.url===s.result.url){_a(s.result),a.resolve(s.result);const o=a.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-fysOIq2s.js").href:new URL("assets/loader.worker-fysOIq2s.js",document.currentScript&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:ot&&ot.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});return new as(t,e)}async load(e,t){const i=na();let s=t==null?void 0:t.renderer;s||(this._webglRenderer??(this._webglRenderer=(async()=>{const{WebGLRenderer:f}=await import("three");return new f})()),s=await this._webglRenderer);const c=os().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 u={type:"load",url:e,dracoDecoderPath:i.dracoDecoderPath,ktx2TranscoderPath:i.ktx2TranscoderPath,ktx2LoaderConfig:c};return this._debug&&console.debug("[Worker] Sending load request",u),this.worker.postMessage(u),new Promise(f=>{this._running.push({url:e.toString(),resolve:f})})}}function _a(n){var e,t,i,s,a,o,c,u,f,p,r,l,h,g,_,m;for(const v of n.geometries){const y=v.geometry,x=new d.BufferGeometry;if(x.name=y.name||"",y.index){const w=y.index;x.setIndex(xi(w))}for(const w in y.attributes){const b=y.attributes[w],A=xi(b);x.setAttribute(w,A)}if(y.morphAttributes)for(const w in y.morphAttributes){const A=y.morphAttributes[w].map(S=>xi(S));x.morphAttributes[w]=A}if(x.morphTargetsRelative=y.morphTargetsRelative??!1,x.boundingBox=new d.Box3,x.boundingBox.min=new d.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),x.boundingBox.max=new d.Vector3((s=y.boundingBox)==null?void 0:s.max.x,(a=y.boundingBox)==null?void 0:a.max.y,(o=y.boundingBox)==null?void 0:o.max.z),x.boundingSphere=new d.Sphere(new d.Vector3((c=y.boundingSphere)==null?void 0:c.center.x,(u=y.boundingSphere)==null?void 0:u.center.y,(f=y.boundingSphere)==null?void 0:f.center.z),(p=y.boundingSphere)==null?void 0:p.radius),y.groups)for(const w of y.groups)x.addGroup(w.start,w.count,w.materialIndex);y.userData&&(x.userData=y.userData),v.geometry=x}for(const v of n.textures){const y=v.texture;let x=null;if(y.isCompressedTexture){const w=y.mipmaps,b=((r=y.image)==null?void 0:r.width)||((h=(l=y.source)==null?void 0:l.data)==null?void 0:h.width)||-1,A=((g=y.image)==null?void 0:g.height)||((m=(_=y.source)==null?void 0:_.data)==null?void 0:m.height)||-1;x=new d.CompressedTexture(w,b,A,y.format,y.type,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.anisotropy,y.colorSpace)}else x=new d.Texture(y.image,y.mapping,y.wrapS,y.wrapT,y.magFilter,y.minFilter,y.format,y.type,y.anisotropy,y.colorSpace),x.mipmaps=y.mipmaps,x.channel=y.channel,x.source.data=y.source.data,x.flipY=y.flipY,x.premultiplyAlpha=y.premultiplyAlpha,x.unpackAlignment=y.unpackAlignment,x.matrix=new d.Matrix3(...y.matrix.elements);if(!x){console.error("[Worker] Failed to create new texture from received data. Texture is not a CompressedTexture or Texture.");continue}v.texture=x}return n}function xi(n){let e=n;if("isInterleavedBufferAttribute"in n&&n.isInterleavedBufferAttribute){const t=n.data,i=t.array,s=new d.InterleavedBuffer(i,t.stride);e=new d.InterleavedBufferAttribute(s,n.itemSize,i.byteOffset,n.normalized),e.offset=n.offset}else"isBufferAttribute"in n&&n.isBufferAttribute&&(e=new d.BufferAttribute(n.array,n.itemSize,n.normalized),e.usage=n.usage,e.gpuType=n.gpuType,e.updateRanges=n.updateRanges);return e}const ya=Oe("gltf-progressive-worker"),xa=Oe("gltf-progressive-reduce-mipmaps"),wi=Symbol("needle-progressive-texture"),ge="NEEDLE_progressive",B=class B{constructor(e){L(this,"parser");L(this,"url");L(this,"_isLoadingMesh");L(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[ge];return t?(this._isLoadingMesh=!0,this.parser.getDependency("mesh",e).then(a=>{var o;return this._isLoadingMesh=!1,a&&B.registerMesh(this.url,t.guid,a,(o=t.lods)==null?void 0:o.length,0,t),a})):null});const t=e.options.path;k&&console.log("Progressive extension registered for",t),this.parser=e,this.url=t}get name(){return ge}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",a=e[s];if(a!=null)return a;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(k==="verbose"&&console.log("getMaterialMinMaxLODsCount",e),e.type==="ShaderMaterial"||e.type==="RawShaderMaterial"){const c=e;for(const u of Object.keys(c.uniforms)){const f=c.uniforms[u].value;(f==null?void 0:f.isTexture)===!0&&o(f,t)}}else if(e.isMaterial)for(const c of Object.keys(e)){const u=e[c];(u==null?void 0:u.isTexture)===!0&&o(u,t)}else k&&console.warn(`[getMaterialMinMaxLODsCount] Unsupported material type: ${e.type}`);return e[s]=t,t;function o(c,u){const f=i.getAssignedLODInformation(c);if(f){const p=i.lodInfos.get(f.key);if(p&&p.lods){u.min_count=Math.min(u.min_count,p.lods.length),u.max_count=Math.max(u.max_count,p.lods.length);for(let r=0;r<p.lods.length;r++){const l=p.lods[r];l.width&&(u.lods[r]=u.lods[r]||{min_height:1/0,max_height:0},u.lods[r].min_height=Math.min(u.lods[r].min_height,l.height),u.lods[r].max_height=Math.max(u.lods[r].max_height,l.height))}}}}}static hasLODLevelAvailable(e,t){var a;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&&(a=i==null?void 0:i.userData)!=null&&a.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 d.Mesh||e.isMesh===!0){const s=e.geometry,a=this.getAssignedLODInformation(s);if(!a)return Promise.resolve(null);for(const o of Se)(i=o.onBeforeGetLODMesh)==null||i.call(o,e,t);return e["LOD:requested level"]=t,B.getOrLoadLOD(s,t).then(o=>{if(Array.isArray(o)){const c=a.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:k&&console.error("Invalid LOD geometry",o))),o}).catch(o=>(console.error("Error loading mesh LOD",e,o),null))}else k&&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 a of i.material){const o=this.assignTextureLOD(a,t);s.push(o)}return Promise.all(s).then(a=>{const o=new Array;for(const c of a)Array.isArray(c)&&o.push(...c);return o})}else return this.assignTextureLOD(i.material,t)}if(e.isMaterial===!0){const i=e,s=[],a=new Array;if(i.uniforms&&(i.isRawShaderMaterial||i.isShaderMaterial===!0)){const o=i;for(const c of Object.keys(o.uniforms)){const u=o.uniforms[c].value;if((u==null?void 0:u.isTexture)===!0){const f=this.assignTextureLODForSlot(u,t,i,c).then(p=>(p&&o.uniforms[c].value!=p&&(o.uniforms[c].value=p,o.uniformsNeedUpdate=!0),p));s.push(f),a.push(c)}}}else for(const o of Object.keys(i)){const c=i[o];if((c==null?void 0:c.isTexture)===!0){const u=this.assignTextureLODForSlot(c,t,i,o);s.push(u),a.push(o)}}return Promise.all(s).then(o=>{const c=new Array;for(let u=0;u<o.length;u++){const f=o[u],p=a[u];f&&f.isTexture===!0?c.push({material:i,slot:p,texture:f,level:t}):c.push({material:i,slot:p,texture:null,level:t})}return c})}if(e instanceof d.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):B.getOrLoadLOD(e,t).then(a=>{var o,c;if(Array.isArray(a))return console.warn("Progressive: Got an array of textures for a texture slot, this should not happen..."),null;if((a==null?void 0:a.isTexture)===!0){if(a!=e&&i&&s){const u=i[s];if(u&&!k){const f=this.getAssignedLODInformation(u);if(f&&(f==null?void 0:f.level)<t)return k==="verbose"&&console.warn("Assigned texture level is already higher: ",f.level,t,i,u,a),null}if(xa&&a.mipmaps){const f=a.mipmaps.length;a.mipmaps.length=Math.min(a.mipmaps.length,3),f!==a.mipmaps.length&&k&&console.debug(`Reduced mipmap count from ${f} to ${a.mipmaps.length} for ${a.uuid}: ${(o=a.image)==null?void 0:o.width}x${(c=a.image)==null?void 0:c.height}.`)}i[s]=a}return a}else k=="verbose"&&console.warn("No LOD found for",e,t);return null}).catch(a=>(console.error("Error loading LOD",e,a),null))}afterRoot(e){var t,i;return k&&console.log("AFTER",this.url,e),(t=this.parser.json.textures)==null||t.forEach((s,a)=>{var o;if(s!=null&&s.extensions){const c=s==null?void 0:s.extensions[ge];if(c){if(!c.lods){k&&console.warn("Texture has no LODs",c);return}let u=!1;for(const f of this.parser.associations.keys())if(f.isTexture===!0){const p=this.parser.associations.get(f);(p==null?void 0:p.textures)===a&&(u=!0,B.registerTexture(this.url,f,(o=c.lods)==null?void 0:o.length,a,c))}u||this.parser.getDependency("texture",a).then(f=>{var p;f&&B.registerTexture(this.url,f,(p=c.lods)==null?void 0:p.length,a,c)})}}}),(i=this.parser.json.meshes)==null||i.forEach((s,a)=>{if(s!=null&&s.extensions){const o=s==null?void 0:s.extensions[ge];if(o&&o.lods){for(const c of this.parser.associations.keys())if(c.isMesh){const u=this.parser.associations.get(c);(u==null?void 0:u.meshes)===a&&B.registerMesh(this.url,o.guid,c,o.lods.length,u.primitives,o)}}}}),null}static async getOrLoadLOD(e,t){var u,f,p,r;const i=k=="verbose",s=this.getAssignedLODInformation(e);if(!s)return k&&console.warn(`[gltf-progressive] No LOD information found: ${e.name}, uuid: ${e.uuid}, type: ${e.type}`,e),null;const a=s==null?void 0:s.key;let o;if(e.isTexture===!0){const l=e;l.source&&l.source[wi]&&(o=l.source[wi])}if(o||(o=B.lodInfos.get(a)),!o)k&&console.warn(`Can not load LOD ${t}: no LOD info found for "${a}" ${e.name}`,e.type,B.lodInfos);else{if(t>0){let g=!1;const _=Array.isArray(o.lods);if(_&&t>=o.lods.length?g=!0:_||(g=!0),g)return this.lowresCache.get(a)}const l=Array.isArray(o.lods)?(u=o.lods[t])==null?void 0:u.path:o.lods;if(!l)return k&&!o["missing:uri"]&&(o["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+t,o)),null;const h=ca(s.url,l);if(h.endsWith(".glb")||h.endsWith(".gltf")){if(!o.guid)return console.warn("missing pointer for glb/gltf texture",o),null;const g=h+"_"+o.guid,_=await this.queue.slot(h),m=this.previouslyLoaded.get(g);if(m!==void 0){i&&console.log(`LOD ${t} was already loading/loaded: ${g}`);let w=await m.catch(A=>(console.error(`Error loading LOD ${t} from ${h}
3682
+ `,A),null)),b=!1;if(w==null||(w instanceof d.Texture&&e instanceof d.Texture?(f=w.image)!=null&&f.data||(p=w.source)!=null&&p.data?w=this.copySettings(e,w):(b=!0,this.previouslyLoaded.delete(g)):w instanceof d.BufferGeometry&&e instanceof d.BufferGeometry&&((r=w.attributes.position)!=null&&r.array||(b=!0,this.previouslyLoaded.delete(g)))),!b)return w}if(!_.use)return k&&console.log(`LOD ${t} was aborted: ${h}`),null;const v=o,y=new Promise(async(w,b)=>{if(ya){const T=await(await va({})).load(h);if(T.textures.length>0)for(const C of T.textures){let D=C.texture;return B.assignLODInformation(s.url,D,a,t,void 0),e instanceof d.Texture&&(D=this.copySettings(e,D)),D&&(D.guid=v.guid),w(D)}if(T.geometries.length>0){const C=new Array;for(const D of T.geometries){const E=D.geometry;B.assignLODInformation(s.url,E,a,t,D.primitiveIndex),C.push(E)}return w(C)}return w(null)}const A=new is.GLTFLoader;vr(A),k&&(await new Promise(R=>setTimeout(R,1e3)),i&&console.warn("Start loading (delayed) "+h,v.guid));let S=h;if(v&&Array.isArray(v.lods)){const R=v.lods[t];R.hash&&(S+="?v="+R.hash)}const I=await A.loadAsync(S).catch(R=>(console.error(`Error loading LOD ${t} from ${h}
3683
+ `,R),w(null)));if(!I)return w(null);const M=I.parser;i&&console.log("Loading finished "+h,v.guid);let P=0;if(I.parser.json.textures){let R=!1;for(const T of I.parser.json.textures){if(T!=null&&T.extensions){const C=T==null?void 0:T.extensions[ge];if(C!=null&&C.guid&&C.guid===v.guid){R=!0;break}}P++}if(R){let T=await M.getDependency("texture",P);return T&&B.assignLODInformation(s.url,T,a,t,void 0),i&&console.log('change "'+e.name+'" → "'+T.name+'"',h,P,T,g),e instanceof d.Texture&&(T=this.copySettings(e,T)),T&&(T.guid=v.guid),w(T)}else k&&console.warn("Could not find texture with guid",v.guid,I.parser.json)}if(P=0,I.parser.json.meshes){let R=!1;for(const T of I.parser.json.meshes){if(T!=null&&T.extensions){const C=T==null?void 0:T.extensions[ge];if(C!=null&&C.guid&&C.guid===v.guid){R=!0;break}}P++}if(R){const T=await M.getDependency("mesh",P);if(i&&console.log(`Loaded Mesh "${T.name}"`,h,P,T,g),T.isMesh===!0){const C=T.geometry;return B.assignLODInformation(s.url,C,a,t,0),w(C)}else{const C=new Array;for(let D=0;D<T.children.length;D++){const E=T.children[D];if(E.isMesh===!0){const F=E.geometry;B.assignLODInformation(s.url,F,a,t,D),C.push(F)}}return w(C)}}else k&&console.warn("Could not find mesh with guid",v.guid,I.parser.json)}return w(null)});return this.previouslyLoaded.set(g,y),_.use(y),await y}else if(e instanceof d.Texture){i&&console.log("Load texture from uri: "+h);const _=await new d.TextureLoader().loadAsync(h);return _?(_.guid=o.guid,_.flipY=!1,_.needsUpdate=!0,_.colorSpace=e.colorSpace,i&&console.log(o,_)):k&&console.warn("failed loading",h),_}}return null}static assignLODInformation(e,t,i,s,a){if(!t)return;t.userData||(t.userData={});const o=new wa(e,i,s,a);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?(k==="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}};D(B,"registerTexture",(e,t,i,s,a)=>{var c,u,p,m,n,l,h,g;if(!t){k&&console.error("!! gltf-progressive: Called register texture without texture");return}if(k){const _=((c=t.image)==null?void 0:c.width)||((p=(u=t.source)==null?void 0:u.data)==null?void 0:p.width)||0,d=((m=t.image)==null?void 0:m.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: ${_}x${d}, Max: ${(h=a.lods[0])==null?void 0:h.width}x${(g=a.lods[0])==null?void 0:g.height}, uuid: ${t.uuid}`,a,t)}t.source&&(t.source[Mi]=a);const o=a.guid;B.assignLODInformation(e,t,o,i,s),B.lodInfos.set(o,a),B.lowresCache.set(o,t)}),D(B,"registerMesh",(e,t,i,s,a,o)=>{var p;const c=i.geometry;if(!c){k&&console.warn("gltf-progressive: Register mesh without geometry");return}c.userData||(c.userData={}),k&&console.log("> Progressive: register mesh "+i.name,{index:a,uuid:i.uuid},o,i),B.assignLODInformation(e,c,t,s,a),B.lodInfos.set(t,o);let u=B.lowresCache.get(t);u?u.push(i.geometry):u=[i.geometry],B.lowresCache.set(t,u),s>0&&!Ft(i)&&Sa(i,c);for(const m of Te)(p=m.onRegisteredNewMesh)==null||p.call(m,i,o)}),D(B,"lodInfos",new Map),D(B,"previouslyLoaded",new Map),D(B,"lowresCache",new Map),D(B,"workers",[]),D(B,"_workersIndex",0),D(B,"maxConcurrent",50),D(B,"queue",new Aa(B.maxConcurrent,{debug:k!=!1}));let he=B;class Fa{constructor(e,t,i,s){D(this,"url");D(this,"key");D(this,"level");D(this,"index");this.url=e,this.key=t,this.level=i,s!=null&&(this.index=s)}}class si{constructor(e,t){D(this,"ready");D(this,"_resolve");D(this,"_signal");D(this,"_frame_start");D(this,"_frames_to_capture");D(this,"_resolved",!1);D(this,"_addedCount",0);D(this,"_resolvedCount",0);D(this,"_awaiting",[]);D(this,"_maxPromisesPerObject",1);D(this,"_currentFrame",0);D(this,"_seen",new WeakMap);var a;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,(a=this._signal)==null||a.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){k&&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){k&&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})}}D(si,"addPromise",(e,t,i,s)=>{s.forEach(a=>{a.add(e,t,i)})});const oe=ze("debugprogressive"),Ba=ze("noprogressive"),Pi=Symbol("Needle:LODSManager"),Ri=Symbol("Needle:LODState"),be=Symbol("Needle:CurrentLOD"),$={mesh_lod:-1,texture_lod:-1};var Z,ve,di,Me,nt,pi,_e;const V=class V{constructor(e,t){D(this,"renderer");D(this,"context");D(this,"projectionScreenMatrix",new f.Matrix4);D(this,"overrideLodLevel");D(this,"targetTriangleDensity",2e5);D(this,"skinnedMeshAutoUpdateBoundsInterval",30);D(this,"updateInterval","auto");we(this,Z,1);D(this,"pause",!1);D(this,"manual",!1);D(this,"_newPromiseGroups",[]);D(this,"_promiseGroupIds",0);D(this,"_lodchangedlisteners",[]);we(this,ve,void 0);we(this,di,new f.Clock);we(this,Me,0);we(this,nt,0);we(this,pi,0);we(this,_e,0);D(this,"_fpsBuffer",[60,60,60,60,60]);D(this,"_sphere",new f.Sphere);D(this,"_tempBox",new f.Box3);D(this,"_tempBox2",new f.Box3);D(this,"tempMatrix",new f.Matrix4);D(this,"_tempWorldPosition",new f.Vector3);D(this,"_tempBoxSize",new f.Vector3);D(this,"_tempBox2Size",new f.Vector3);this.renderer=e,this.context={...t}}static getObjectLODState(e){return e[Ri]}static addPlugin(e){Te.push(e)}static removePlugin(e){const t=Te.indexOf(e);t>=0&&Te.splice(t,1)}static get(e,t){if(e[Pi])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),e[Pi];const i=new V(e,{engine:"unknown",...t});return e[Pi]=i,i}get plugins(){return Te}awaitLoading(e){const t=this._promiseGroupIds++,i=new si(z(this,Me),{...e});this._newPromiseGroups.push(i);const s=performance.now();return i.ready.finally(()=>{const a=this._newPromiseGroups.indexOf(i);a>=0&&(this._newPromiseGroups.splice(a,1),Qs()&&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(z(this,Me))}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(z(this,ve))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let e=0;ue(this,ve,this.renderer.render);const t=this;ds(this.renderer),this.renderer.render=function(i,s){const a=t.renderer.getRenderTarget();(a==null||"isXRRenderTarget"in a&&a.isXRRenderTarget)&&(e=0,ue(t,Me,z(t,Me)+1),ue(t,nt,z(t,di).getDelta()),ue(t,pi,z(t,pi)+z(t,nt)),t._fpsBuffer.shift(),t._fpsBuffer.push(1/z(t,nt)),ue(t,_e,t._fpsBuffer.reduce((c,u)=>c+u)/t._fpsBuffer.length),oe&&z(t,Me)%200===0&&console.log("FPS",Math.round(z(t,_e)),"Interval:",z(t,Z)));const o=e++;z(t,ve).call(this,i,s),t.onAfterRender(i,s,o)}}disable(){z(this,ve)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=z(this,ve),ue(this,ve,void 0))}update(e,t){this.internalUpdate(e,t)}onAfterRender(e,t,i){if(this.pause)return;const a=this.renderer.renderLists.get(e,0).opaque;let o=!0;if(a.length===1){const c=a[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(Ba||(this.updateInterval==="auto"?z(this,_e)<40&&z(this,Z)<10?(ue(this,Z,z(this,Z)+1),oe&&console.warn("↓ Reducing LOD updates",z(this,Z),z(this,_e).toFixed(0))):z(this,_e)>=60&&z(this,Z)>1&&(ue(this,Z,z(this,Z)-1),oe&&console.warn("↑ Increasing LOD updates",z(this,Z),z(this,_e).toFixed(0))):ue(this,Z,this.updateInterval),z(this,Z)>0&&z(this,Me)%z(this,Z)!=0))return;this.internalUpdate(e,t),this._postprocessPromiseGroups()}}internalUpdate(e,t){var u,p;const i=this.renderer.renderLists.get(e,0),s=i.opaque;this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const a=this.targetTriangleDensity;for(const m of s){if(m.material&&(((u=m.geometry)==null?void 0:u.type)==="BoxGeometry"||((p=m.geometry)==null?void 0:p.type)==="BufferGeometry")&&(m.material.name==="SphericalGaussianBlur"||m.material.name=="BackgroundCubeMaterial"||m.material.name==="CubemapFromEquirect"||m.material.name==="EquirectangularToCubeUV")){oe&&(m.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]||(m.material["NEEDLE_PROGRESSIVE:IGNORE-WARNING"]=!0,console.warn("Ignoring skybox or BLIT object",m,m.material.name,m.material.type)));continue}switch(m.material.type){case"LineBasicMaterial":case"LineDashedMaterial":case"PointsMaterial":case"ShadowMaterial":case"MeshDistanceMaterial":case"MeshDepthMaterial":continue}if(oe==="color"&&m.material&&!m.object.progressive_debug_color){m.object.progressive_debug_color=!0;const l=Math.random()*16777215,h=new f.MeshStandardMaterial({color:l});m.object.material=h}const n=m.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,a)}const o=i.transparent;for(const m of o){const n=m.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,a)}const c=i.transmissive;for(const m of c){const n=m.object;(n instanceof f.Mesh||n.isMesh)&&this.updateLODs(e,t,n,a)}}updateLODs(e,t,i,s){var c,u;i.userData||(i.userData={});let a=i[Ri];if(a||(a=new ka,i[Ri]=a),a.frames++<2)return;for(const p of Te)(c=p.onBeforeUpdateLOD)==null||c.call(p,this.renderer,e,t,i);const o=this.overrideLodLevel!==void 0?this.overrideLodLevel:ke;o>=0?($.mesh_lod=o,$.texture_lod=o):(this.calculateLodLevel(t,i,a,s,$),$.mesh_lod=Math.round($.mesh_lod),$.texture_lod=Math.round($.texture_lod)),$.mesh_lod>=0&&this.loadProgressiveMeshes(i,$.mesh_lod),i.material&&$.texture_lod>=0&&this.loadProgressiveTextures(i.material,$.texture_lod,o),k&&i.material&&!i.isGizmo&&kr(i.material);for(const p of Te)(u=p.onAfterUpdatedLOD)==null||u.call(p,this.renderer,e,t,i,$);a.lastLodLevel_Mesh=$.mesh_lod,a.lastLodLevel_Texture=$.texture_lod}loadProgressiveTextures(e,t,i){if(!e)return;if(Array.isArray(e)){for(const a of e)this.loadProgressiveTextures(a,t);return}let s=!1;if((e[be]===void 0||t<e[be])&&(s=!0),i!==void 0&&i>=0&&(s=e[be]!=i,t=i),s){e[be]=t;const a=he.assignTextureLOD(e,t).then(o=>{this._lodchangedlisteners.forEach(c=>c({type:"texture",level:t,object:e}))});si.addPromise("texture",e,a,this._newPromiseGroups)}}loadProgressiveMeshes(e,t){if(!e)return Promise.resolve(null);let i=e[be]!==t;const s=e["DEBUG:LOD"];if(s!=null&&(i=e[be]!=s,t=s),i){e[be]=t;const a=e.geometry,o=he.assignMeshLOD(e,t).then(c=>(c&&e[be]==t&&a!=e.geometry&&this._lodchangedlisteners.forEach(u=>u({type:"mesh",level:t,object:e})),c));return si.addPromise("mesh",e,o,this._newPromiseGroups),o}return Promise.resolve(null)}static isInside(e,t){const i=e.min,s=e.max,a=(i.x+s.x)*.5,o=(i.y+s.y)*.5;return this._tempPtInside.set(a,o,i.z).applyMatrix4(t).z<0}calculateLodLevel(e,t,i,s,a){var d,v,y,x;if(!t){a.mesh_lod=-1,a.texture_lod=-1;return}if(!e){a.mesh_lod=-1,a.texture_lod=-1;return}let c=10+1,u=!1;if(oe&&t["DEBUG:LOD"]!=null)return t["DEBUG:LOD"];const p=(d=he.getMeshLODExtension(t.geometry))==null?void 0:d.lods,m=he.getPrimitiveIndex(t.geometry),n=p&&p.length>0,l=he.getMaterialMinMaxLODsCount(t.material),h=l.min_count!==1/0&&l.min_count>=0&&l.max_count>=0;if(!n&&!h){a.mesh_lod=0,a.texture_lod=0;return}n||(u=!0,c=0);const g=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let _=t.geometry.boundingBox;if(t.type==="SkinnedMesh"){const w=t;if(!w.boundingBox)w.computeBoundingBox();else if(this.skinnedMeshAutoUpdateBoundsInterval>0){if(!w[V.$skinnedMeshBoundsOffset]){const T=V.skinnedMeshBoundsFrameOffsetCounter++;w[V.$skinnedMeshBoundsOffset]=T}const b=w[V.$skinnedMeshBoundsOffset];if((i.frames+b)%this.skinnedMeshAutoUpdateBoundsInterval===0){const T=Ft(w),S=w.geometry;T&&(w.geometry=T),w.computeBoundingBox(),w.geometry=S}}_=w.boundingBox}if(_){const w=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 M=e.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(M)){a.mesh_lod=0,a.texture_lod=0;return}}if(this._tempBox.copy(_),this._tempBox.applyMatrix4(t.matrixWorld),w.isPerspectiveCamera&&V.isInside(this._tempBox,this.projectionScreenMatrix)){a.mesh_lod=0,a.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&w.isPerspectiveCamera&&w.fov>70){const M=this._tempBox.min,I=this._tempBox.max;let L=M.x,F=M.y,O=I.x,H=I.y;const W=2,J=1.5,ee=(M.x+I.x)*.5,pe=(M.y+I.y)*.5;L=(L-ee)*W+ee,F=(F-pe)*W+pe,O=(O-ee)*W+ee,H=(H-pe)*W+pe;const ft=L<0&&O>0?0:Math.min(Math.abs(M.x),Math.abs(I.x)),yi=F<0&&H>0?0:Math.min(Math.abs(M.y),Math.abs(I.y)),dt=Math.max(ft,yi);i.lastCentrality=(J-dt)*(J-dt)*(J-dt)}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,S=this._tempBox2;S.copy(_),S.applyMatrix4(t.matrixWorld),S.applyMatrix4(T);const P=S.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,oe&&V.debugDrawLine){const M=this.tempMatrix.copy(this.projectionScreenMatrix);M.invert();const I=V.corner0,L=V.corner1,F=V.corner2,O=V.corner3;I.copy(this._tempBox.min),L.copy(this._tempBox.max),L.x=I.x,F.copy(this._tempBox.max),F.y=I.y,O.copy(this._tempBox.max);const H=(I.z+O.z)*.5;I.z=L.z=F.z=O.z=H,I.applyMatrix4(M),L.applyMatrix4(M),F.applyMatrix4(M),O.applyMatrix4(M),V.debugDrawLine(I,L,255),V.debugDrawLine(I,F,255),V.debugDrawLine(L,O,255),V.debugDrawLine(F,O,255)}let E=999;if(p&&i.lastScreenCoverage>0)for(let M=0;M<p.length;M++){const I=p[M],F=(((v=I.densities)==null?void 0:v[m])||I.density||1e-5)/i.lastScreenCoverage;if(m>0&&Qs()&&!I.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.")),F<s){E=M;break}}E<c&&(c=E,u=!0)}if(u?a.mesh_lod=c:a.mesh_lod=i.lastLodLevel_Mesh,oe&&a.mesh_lod!=i.lastLodLevel_Mesh){const b=p==null?void 0:p[a.mesh_lod];b&&console.log(`Mesh LOD changed: ${i.lastLodLevel_Mesh} → ${a.mesh_lod} (density: ${(y=b.densities)==null?void 0:y[m].toFixed(0)}) | ${t.name}`)}if(h){const w="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(i.lastLodLevel_Texture<0){if(a.texture_lod=l.max_count-1,oe){const b=l.lods[l.max_count-1];oe&&console.log(`First Texture LOD ${a.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;((x=this.context)==null?void 0:x.engine)==="model-viewer"&&(T*=1.5);const P=g/window.devicePixelRatio*T;let C=!1;for(let R=l.lods.length-1;R>=0;R--){const E=l.lods[R];if(!(w&&E.max_height>=2048)&&!(Br()&&E.max_height>4096)&&(E.max_height>P||!C&&R===0)){if(C=!0,a.texture_lod=R,oe&&a.texture_lod<i.lastLodLevel_Texture){const A=E.max_height;console.log(`Texture LOD changed: ${i.lastLodLevel_Texture} → ${a.texture_lod} = ${A}px
3686
- Screensize: ${P.toFixed(0)}px, Coverage: ${(100*i.lastScreenCoverage).toFixed(2)}%, Volume ${b.toFixed(1)}
3687
- ${t.name}`)}break}}}}else a.texture_lod=0}};Z=new WeakMap,ve=new WeakMap,di=new WeakMap,Me=new WeakMap,nt=new WeakMap,pi=new WeakMap,_e=new WeakMap,D(V,"debugDrawLine"),D(V,"corner0",new f.Vector3),D(V,"corner1",new f.Vector3),D(V,"corner2",new f.Vector3),D(V,"corner3",new f.Vector3),D(V,"_tempPtInside",new f.Vector3),D(V,"skinnedMeshBoundsFrameOffsetCounter",0),D(V,"$skinnedMeshBoundsOffset",Symbol("gltf-progressive-skinnedMeshBoundsOffset"));let lt=V;class ka{constructor(){D(this,"frames",0);D(this,"lastLodLevel_Mesh",-1);D(this,"lastLodLevel_Texture",-1);D(this,"lastScreenCoverage",0);D(this,"lastScreenspaceVolume",new f.Vector3);D(this,"lastCentrality",0)}}const Zs=Symbol("NEEDLE_mesh_lod"),Ht=Symbol("NEEDLE_texture_lod");let vt=null;function Or(){const r=Oa();r&&(r.mapURLs(function(e){return Xs(),e}),Xs(),vt==null||vt.disconnect(),vt=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(i=>{i instanceof HTMLElement&&i.tagName.toLowerCase()==="model-viewer"&&zr(i)})})}),vt.observe(document,{childList:!0,subtree:!0}))}function Oa(){if(typeof customElements>"u")return null;const r=customElements.get("model-viewer");return r||(customElements.whenDefined("model-viewer").then(()=>{console.debug("[gltf-progressive] model-viewer defined"),Or()}),null)}function Xs(){if(typeof document>"u")return;document.querySelectorAll("model-viewer").forEach(e=>{zr(e)})}const Ks=new WeakSet;let za=0;function zr(r){if(!r||Ks.has(r))return null;Ks.add(r),console.debug("[gltf-progressive] found new model-viewer..."+ ++za+`
3688
- `,r.getAttribute("src"));let e=null,t=null,i=null;for(let s=r;s!=null;s=Object.getPrototypeOf(s)){const a=Object.getOwnPropertySymbols(s),o=a.find(p=>p.toString()=="Symbol(renderer)"),c=a.find(p=>p.toString()=="Symbol(scene)"),u=a.find(p=>p.toString()=="Symbol(needsRender)");!e&&o!=null&&(e=r[o].threeRenderer),!t&&c!=null&&(t=r[c]),!i&&u!=null&&(i=r[u])}if(e&&t){let s=function(){if(i){let o=0,c=setInterval(()=>{if(o++>5){clearInterval(c);return}i==null||i.call(r)},300)}};console.debug("[gltf-progressive] setup model-viewer");const a=lt.get(e,{engine:"model-viewer"});return lt.addPlugin(new Va),a.enable(),a.addEventListener("changed",()=>{i==null||i.call(r)}),r.addEventListener("model-visibility",o=>{o.detail.visible&&(i==null||i.call(r))}),r.addEventListener("load",()=>{s()}),()=>{a.disable()}}return null}class Va{constructor(){D(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[Ht]==!0)return;t[Ht]=!0;const i=this.tryGetCurrentGLTF(e),s=this.tryGetCurrentModelViewer(e),a=this.getUrl(s);if(a&&i&&t.material){let o=function(u){var m,n,l;if(u[Ht]==!0)return;u[Ht]=!0,u.userData&&(u.userData.LOD=-1);const p=Object.keys(u);for(let h=0;h<p.length;h++){const g=p[h],_=u[g];if((_==null?void 0:_.isTexture)===!0){const d=(n=(m=_.userData)==null?void 0:m.associations)==null?void 0:n.textures;if(d==null)continue;const v=i.parser.json.textures[d];if(!v){console.warn("Texture data not found for texture index "+d);continue}if((l=v==null?void 0:v.extensions)!=null&&l[ge]){const y=v.extensions[ge];y&&a&&he.registerTexture(a,_,y.lods.length,d,y)}}}};const c=t.material;if(Array.isArray(c))for(const u of c)o(u);else o(c)}}tryParseMeshLOD(e,t){var o,c;if(t[Zs]==!0)return;t[Zs]=!0;const i=this.tryGetCurrentModelViewer(e),s=this.getUrl(i);if(!s)return;const a=(c=(o=t.userData)==null?void 0:o.gltfExtensions)==null?void 0:c[ge];if(a&&s){const u=t.uuid;he.registerMesh(s,u,t,0,a.lods.length,a)}}}function Vr(...r){let e,t,i,s;switch(r.length){case 2:[i,t]=r,s={};break;case 3:[i,t,s]=r;break;case 4:[e,t,i,s]=r;break;default:throw new Error("Invalid arguments")}ds(),Dr(i),Fr(i,{progressive:!0,...s==null?void 0:s.hints}),i.register(o=>new he(o));const a=lt.get(t);return(s==null?void 0:s.enableLODsManager)!==!1&&a.enable(),a}Or();if(!Ta){const r={gltfProgressive:{useNeedleProgressive:Vr,LODsManager:lt,configureLoader:Fr,getRaycastMesh:Ft,useRaycastMeshes:Ca}};if(!globalThis.Needle)globalThis.Needle=r;else for(const e in r)globalThis.Needle[e]=r[e]}var st=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return r},Out:function(r){return r},InOut:function(r){return r}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-st.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?st.Bounce.In(r*2)*.5:st.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),et=function(){return performance.now()},Ur=function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},r.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},r.prototype.update=function(e,t){e===void 0&&(e=et()),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 a=this._tweens[i[s]],o=!t;a&&a.update(e,o)===!1&&!t&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},r}(),Oe={Linear:function(r,e){var t=r.length-1,i=t*e,s=Math.floor(i),a=Oe.Utils.Linear;return e<0?a(r[0],r[1],i):e>1?a(r[t],r[t-1],t-i):a(r[s],r[s+1>t?t:s+1],i-s)},Bezier:function(r,e){for(var t=0,i=r.length-1,s=Math.pow,a=Oe.Utils.Bernstein,o=0;o<=i;o++)t+=s(1-e,i-o)*s(e,o)*r[o]*a(i,o);return t},CatmullRom:function(r,e){var t=r.length-1,i=t*e,s=Math.floor(i),a=Oe.Utils.CatmullRom;return r[0]===r[t]?(e<0&&(s=Math.floor(i=t*(1+e))),a(r[(s-1+t)%t],r[s],r[(s+1)%t],r[(s+2)%t],i-s)):e<0?r[0]-(a(r[0],r[0],r[1],r[1],-i)-r[0]):e>1?r[t]-(a(r[t],r[t],r[t-1],r[t-1],i-t)-r[t]):a(r[s?s-1:0],r[s],r[t<s+1?t:s+1],r[t<s+2?t:s+2],i-s)},Utils:{Linear:function(r,e,t){return(e-r)*t+r},Bernstein:function(r,e){var t=Oe.Utils.Factorial;return t(r)/t(e)/t(r-e)},Factorial:function(){var r=[1];return function(e){var t=1;if(r[e])return r[e];for(var i=e;i>1;i--)t*=i;return r[e]=t,t}}(),CatmullRom:function(r,e,t,i,s){var a=(t-r)*.5,o=(i-e)*.5,c=s*s,u=s*c;return(2*e-2*t+a+o)*u+(-3*e+3*t-2*a-o)*c+a*s+e}}},ms=function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r}(),Yi=new Ur,ci=function(){function r(e,t){t===void 0&&(t=Yi),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=st.Linear.None,this._interpolationFunction=Oe.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=ms.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.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},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=et()),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 a in this._valuesEnd)s[a]=this._valuesEnd[a];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,i,s,a){for(var o in i){var c=e[o],u=Array.isArray(c),p=u?"array":typeof c,m=!u&&Array.isArray(i[o]);if(!(p==="undefined"||p==="function")){if(m){var n=i[o];if(n.length===0)continue;for(var l=[c],h=0,g=n.length;h<g;h+=1){var _=this._handleRelativeValue(c,n[h]);if(isNaN(_)){m=!1,console.warn("Found invalid interpolation list. Skipping.");break}l.push(_)}m&&(i[o]=l)}if((p==="object"||u)&&c&&!m){t[o]=u?[]:{};var d=c;for(var v in d)t[o][v]=d[v];s[o]=u?[]:{};var n=i[o];if(!this._isDynamic){var y={};for(var v in n)y[v]=n[v];i[o]=n=y}this._setupProperties(d,t[o],n,s[o],a)}else(typeof t[o]>"u"||a)&&(t[o]=c),u||(t[o]*=1),m?s[o]=i[o].slice().reverse():s[o]=t[o]||0}}},r.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},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(e){return e===void 0&&(e=et()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},r.prototype.resume=function(e){return e===void 0&&(e=et()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.prototype.group=function(e){return e===void 0&&(e=Yi),this._group=e,this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=st.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=Oe.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var i=this,s;if(e===void 0&&(e=et()),t===void 0&&(t=!0),this._isPaused)return!0;var a,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,u=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),p=this._duration+this._repeat*u,m=function(){if(i._duration===0||c>p)return 1;var d=Math.trunc(c/u),v=c-d*u,y=Math.min(v/i._duration,1);return y===0&&c===i._duration?1:y},n=m(),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 h=Math.min(Math.trunc((c-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=h);for(a in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[a]=="string"&&(this._valuesStartRepeat[a]=this._valuesStartRepeat[a]+parseFloat(this._valuesEnd[a])),this._yoyo&&this._swapEndStartRepeatValues(a),this._valuesStart[a]=this._valuesStartRepeat[a];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*h,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,_=this._chainedTweens.length;g<_;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(e,t,i,s){for(var a in i)if(t[a]!==void 0){var o=t[a]||0,c=i[a],u=Array.isArray(e[a]),p=Array.isArray(c),m=!u&&p;m?e[a]=this._interpolationFunction(c,s):typeof c=="object"&&c?this._updateProperties(e[a],o,c,s):(c=this._handleRelativeValue(o,c),typeof c=="number"&&(e[a]=o+(c-o)*s))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.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},r}(),Ua="23.1.3",Ha=ms.nextId,de=Yi,Na=de.getAll.bind(de),Wa=de.removeAll.bind(de),Ga=de.add.bind(de),qa=de.remove.bind(de),ja=de.update.bind(de),Pe={Easing:st,Group:Ur,Interpolation:Oe,now:et,Sequence:ms,nextId:Ha,Tween:ci,VERSION:Ua,getAll:Na,removeAll:Wa,add:Ga,remove:qa,update:ja},_t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ya(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Hr={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(u,p,m){this.fn=u,this.context=p,this.once=m||!1}function a(u,p,m,n,l){if(typeof m!="function")throw new TypeError("The listener must be a function");var h=new s(m,n||u,l),g=t?t+p:p;return u._events[g]?u._events[g].fn?u._events[g]=[u._events[g],h]:u._events[g].push(h):(u._events[g]=h,u._eventsCount++),u}function o(u,p){--u._eventsCount===0?u._events=new i:delete u._events[p]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var p=[],m,n;if(this._eventsCount===0)return p;for(n in m=this._events)e.call(m,n)&&p.push(t?n.slice(1):n);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(m)):p},c.prototype.listeners=function(p){var m=t?t+p:p,n=this._events[m];if(!n)return[];if(n.fn)return[n.fn];for(var l=0,h=n.length,g=new Array(h);l<h;l++)g[l]=n[l].fn;return g},c.prototype.listenerCount=function(p){var m=t?t+p:p,n=this._events[m];return n?n.fn?1:n.length:0},c.prototype.emit=function(p,m,n,l,h,g){var _=t?t+p:p;if(!this._events[_])return!1;var d=this._events[_],v=arguments.length,y,x;if(d.fn){switch(d.once&&this.removeListener(p,d.fn,void 0,!0),v){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,m),!0;case 3:return d.fn.call(d.context,m,n),!0;case 4:return d.fn.call(d.context,m,n,l),!0;case 5:return d.fn.call(d.context,m,n,l,h),!0;case 6:return d.fn.call(d.context,m,n,l,h,g),!0}for(x=1,y=new Array(v-1);x<v;x++)y[x-1]=arguments[x];d.fn.apply(d.context,y)}else{var w=d.length,b;for(x=0;x<w;x++)switch(d[x].once&&this.removeListener(p,d[x].fn,void 0,!0),v){case 1:d[x].fn.call(d[x].context);break;case 2:d[x].fn.call(d[x].context,m);break;case 3:d[x].fn.call(d[x].context,m,n);break;case 4:d[x].fn.call(d[x].context,m,n,l);break;default:if(!y)for(b=1,y=new Array(v-1);b<v;b++)y[b-1]=arguments[b];d[x].fn.apply(d[x].context,y)}}return!0},c.prototype.on=function(p,m,n){return a(this,p,m,n,!1)},c.prototype.once=function(p,m,n){return a(this,p,m,n,!0)},c.prototype.removeListener=function(p,m,n,l){var h=t?t+p:p;if(!this._events[h])return this;if(!m)return o(this,h),this;var g=this._events[h];if(g.fn)g.fn===m&&(!l||g.once)&&(!n||g.context===n)&&o(this,h);else{for(var _=0,d=[],v=g.length;_<v;_++)(g[_].fn!==m||l&&!g[_].once||n&&g[_].context!==n)&&d.push(g[_]);d.length?this._events[h]=d.length===1?d[0]:d:o(this,h)}return this},c.prototype.removeAllListeners=function(p){var m;return p?(m=t?t+p:p,this._events[m]&&o(this,m)):(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,r.exports=c})(Hr);var $a=Hr.exports;const ut=Ya($a);var It=function(){var r=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(++r%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";r=n}var s=(performance||Date).now(),a=s,o=0,c=t(new It.Panel("FPS","#0ff","#002")),u=t(new It.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=t(new It.Panel("MB","#f08","#201"));i(0);var m=0;return{REVISION:16,dom:e,fps:function(){return m&&parseInt(m.toFixed(0))},addPanel:t,showPanel:i,begin:function(){s=(performance||Date).now()},end:function(){o++;var n=(performance||Date).now();if(u.update(n-s,200),n>=a+1e3&&(m=o*1e3/(n-a),c.update(m,100),a=n,o=0,p)){var l=performance.memory;p.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return n},update:function(){s=this.end()},domElement:e,setMode:i}};It.Panel=function(r,e,t){var i=1/0,s=0,a=Math.round,o=a(window.devicePixelRatio||1),c=80*o,u=48*o,p=3*o,m=2*o,n=3*o,l=15*o,h=74*o,g=30*o,_=document.createElement("canvas");_.width=c,_.height=u,_.style.cssText="width:80px;height:48px";var d=_.getContext("2d");return d.font="bold "+9*o+"px Helvetica,Arial,sans-serif",d.textBaseline="top",d.fillStyle=t,d.fillRect(0,0,c,u),d.fillStyle=e,d.fillText(r,p,m),d.fillRect(n,l,h,g),d.fillStyle=t,d.globalAlpha=.9,d.fillRect(n,l,h,g),{dom:_,update:function(v,y){i=Math.min(i,v),s=Math.max(s,v),d.fillStyle=t,d.globalAlpha=1,d.fillRect(0,0,c,l),d.fillStyle=e,d.fillText(a(v)+" "+r+" ("+a(i)+"-"+a(s)+")",p,m),d.drawImage(_,n+o,l,h-o,g,n,l,h-o,g),d.fillRect(n+h-o,l,o,g),d.fillStyle=t,d.globalAlpha=.9,d.fillRect(n+h-o,l,o,a((1-v/y)*g))}}};function Qa(r,e){const t=URL.createObjectURL(r),i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}function Nr(r){return r.length===0?0:r.reduce((t,i)=>t+i,0)/r.length}function $i(r,e){const t=new Blob([r],{type:e});return URL.createObjectURL(t)}function Wr(){return/Mac|iPod|iPhone|iPad/.test(navigator==null?void 0:navigator.platform)||/Mac OS|iOS/.test(navigator==null?void 0:navigator.userAgent)}function Qi(r){let e=document.createElement("canvas");const t=e.getContext("2d");return e.width=r.width,e.height=r.height,t?(t.drawImage(r,0,0),e.toDataURL("image/png",.75)):void 0}function Za(r,e=43){const t=r*Math.PI/180;return e/(2*Math.tan(t/2))}var Gr={};/*!
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}};L(B,"registerTexture",(e,t,i,s,a)=>{var c,u,f,p,r,l,h,g;if(!t){k&&console.error("!! gltf-progressive: Called register texture without texture");return}if(k){const _=((c=t.image)==null?void 0:c.width)||((f=(u=t.source)==null?void 0:u.data)==null?void 0:f.width)||0,m=((p=t.image)==null?void 0:p.height)||((l=(r=t.source)==null?void 0:r.data)==null?void 0:l.height)||0;console.log(`> gltf-progressive: register texture[${s}] "${t.name||t.uuid}", Current: ${_}x${m}, Max: ${(h=a.lods[0])==null?void 0:h.width}x${(g=a.lods[0])==null?void 0:g.height}, uuid: ${t.uuid}`,a,t)}t.source&&(t.source[wi]=a);const o=a.guid;B.assignLODInformation(e,t,o,i,s),B.lodInfos.set(o,a),B.lowresCache.set(o,t)}),L(B,"registerMesh",(e,t,i,s,a,o)=>{var f;const c=i.geometry;if(!c){k&&console.warn("gltf-progressive: Register mesh without geometry");return}c.userData||(c.userData={}),k&&console.log("> Progressive: register mesh "+i.name,{index:a,uuid:i.uuid},o,i),B.assignLODInformation(e,c,t,s,a),B.lodInfos.set(t,o);let u=B.lowresCache.get(t);u?u.push(i.geometry):u=[i.geometry],B.lowresCache.set(t,u),s>0&&!Lt(i)&&fa(i,c);for(const p of Se)(f=p.onRegisteredNewMesh)==null||f.call(p,i,o)}),L(B,"lodInfos",new Map),L(B,"previouslyLoaded",new Map),L(B,"lowresCache",new Map),L(B,"workers",[]),L(B,"_workersIndex",0),L(B,"maxConcurrent",50),L(B,"queue",new ua(B.maxConcurrent,{debug:k!=!1}));let he=B;class wa{constructor(e,t,i,s){L(this,"url");L(this,"key");L(this,"level");L(this,"index");this.url=e,this.key=t,this.level=i,s!=null&&(this.index=s)}}class ei{constructor(e,t){L(this,"ready");L(this,"_resolve");L(this,"_signal");L(this,"_frame_start");L(this,"_frames_to_capture");L(this,"_resolved",!1);L(this,"_addedCount",0);L(this,"_resolvedCount",0);L(this,"_awaiting",[]);L(this,"_maxPromisesPerObject",1);L(this,"_currentFrame",0);L(this,"_seen",new WeakMap);var a;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,(a=this._signal)==null||a.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){k&&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){k&&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})}}L(ei,"addPromise",(e,t,i,s)=>{s.forEach(a=>{a.add(e,t,i)})});const oe=Oe("debugprogressive"),ba=Oe("noprogressive"),bi=Symbol("Needle:LODSManager"),Ai=Symbol("Needle:LODState"),Ae=Symbol("Needle:CurrentLOD"),Q={mesh_lod:-1,texture_lod:-1};var X,ve,ai,Ie,rt,li,_e;const V=class V{constructor(e,t){L(this,"renderer");L(this,"context");L(this,"projectionScreenMatrix",new d.Matrix4);L(this,"overrideLodLevel");L(this,"targetTriangleDensity",2e5);L(this,"skinnedMeshAutoUpdateBoundsInterval",30);L(this,"updateInterval","auto");be(this,X,1);L(this,"pause",!1);L(this,"manual",!1);L(this,"_newPromiseGroups",[]);L(this,"_promiseGroupIds",0);L(this,"_lodchangedlisteners",[]);be(this,ve,void 0);be(this,ai,new d.Clock);be(this,Ie,0);be(this,rt,0);be(this,li,0);be(this,_e,0);L(this,"_fpsBuffer",[60,60,60,60,60]);L(this,"_sphere",new d.Sphere);L(this,"_tempBox",new d.Box3);L(this,"_tempBox2",new d.Box3);L(this,"tempMatrix",new d.Matrix4);L(this,"_tempWorldPosition",new d.Vector3);L(this,"_tempBoxSize",new d.Vector3);L(this,"_tempBox2Size",new d.Vector3);this.renderer=e,this.context={...t}}static getObjectLODState(e){return e[Ai]}static addPlugin(e){Se.push(e)}static removePlugin(e){const t=Se.indexOf(e);t>=0&&Se.splice(t,1)}static get(e,t){if(e[bi])return console.debug("[gltf-progressive] LODsManager already exists for this renderer"),e[bi];const i=new V(e,{engine:"unknown",...t});return e[bi]=i,i}get plugins(){return Se}awaitLoading(e){const t=this._promiseGroupIds++,i=new ei(z(this,Ie),{...e});this._newPromiseGroups.push(i);const s=performance.now();return i.ready.finally(()=>{const a=this._newPromiseGroups.indexOf(i);a>=0&&(this._newPromiseGroups.splice(a,1),Vs()&&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(z(this,Ie))}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(z(this,ve))return;console.debug("[gltf-progressive] Enabling LODsManager for renderer");let e=0;ue(this,ve,this.renderer.render);const t=this;os(this.renderer),this.renderer.render=function(i,s){const a=t.renderer.getRenderTarget();(a==null||"isXRRenderTarget"in a&&a.isXRRenderTarget)&&(e=0,ue(t,Ie,z(t,Ie)+1),ue(t,rt,z(t,ai).getDelta()),ue(t,li,z(t,li)+z(t,rt)),t._fpsBuffer.shift(),t._fpsBuffer.push(1/z(t,rt)),ue(t,_e,t._fpsBuffer.reduce((c,u)=>c+u)/t._fpsBuffer.length),oe&&z(t,Ie)%200===0&&console.log("FPS",Math.round(z(t,_e)),"Interval:",z(t,X)));const o=e++;z(t,ve).call(this,i,s),t.onAfterRender(i,s,o)}}disable(){z(this,ve)&&(console.debug("[gltf-progressive] Disabling LODsManager for renderer"),this.renderer.render=z(this,ve),ue(this,ve,void 0))}update(e,t){this.internalUpdate(e,t)}onAfterRender(e,t,i){if(this.pause)return;const a=this.renderer.renderLists.get(e,0).opaque;let o=!0;if(a.length===1){const c=a[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(ba||(this.updateInterval==="auto"?z(this,_e)<40&&z(this,X)<10?(ue(this,X,z(this,X)+1),oe&&console.warn("↓ Reducing LOD updates",z(this,X),z(this,_e).toFixed(0))):z(this,_e)>=60&&z(this,X)>1&&(ue(this,X,z(this,X)-1),oe&&console.warn("↑ Increasing LOD updates",z(this,X),z(this,_e).toFixed(0))):ue(this,X,this.updateInterval),z(this,X)>0&&z(this,Ie)%z(this,X)!=0))return;this.internalUpdate(e,t),this._postprocessPromiseGroups()}}internalUpdate(e,t){var u,f;const i=this.renderer.renderLists.get(e,0),s=i.opaque;this.projectionScreenMatrix.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const a=this.targetTriangleDensity;for(const p of s){if(p.material&&(((u=p.geometry)==null?void 0:u.type)==="BoxGeometry"||((f=p.geometry)==null?void 0:f.type)==="BufferGeometry")&&(p.material.name==="SphericalGaussianBlur"||p.material.name=="BackgroundCubeMaterial"||p.material.name==="CubemapFromEquirect"||p.material.name==="EquirectangularToCubeUV")){oe&&(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(oe==="color"&&p.material&&!p.object.progressive_debug_color){p.object.progressive_debug_color=!0;const l=Math.random()*16777215,h=new d.MeshStandardMaterial({color:l});p.object.material=h}const r=p.object;(r instanceof d.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}const o=i.transparent;for(const p of o){const r=p.object;(r instanceof d.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}const c=i.transmissive;for(const p of c){const r=p.object;(r instanceof d.Mesh||r.isMesh)&&this.updateLODs(e,t,r,a)}}updateLODs(e,t,i,s){var c,u;i.userData||(i.userData={});let a=i[Ai];if(a||(a=new Aa,i[Ai]=a),a.frames++<2)return;for(const f of Se)(c=f.onBeforeUpdateLOD)==null||c.call(f,this.renderer,e,t,i);const o=this.overrideLodLevel!==void 0?this.overrideLodLevel:Be;o>=0?(Q.mesh_lod=o,Q.texture_lod=o):(this.calculateLodLevel(t,i,a,s,Q),Q.mesh_lod=Math.round(Q.mesh_lod),Q.texture_lod=Math.round(Q.texture_lod)),Q.mesh_lod>=0&&this.loadProgressiveMeshes(i,Q.mesh_lod),i.material&&Q.texture_lod>=0&&this.loadProgressiveTextures(i.material,Q.texture_lod,o),k&&i.material&&!i.isGizmo&&wr(i.material);for(const f of Se)(u=f.onAfterUpdatedLOD)==null||u.call(f,this.renderer,e,t,i,Q);a.lastLodLevel_Mesh=Q.mesh_lod,a.lastLodLevel_Texture=Q.texture_lod}loadProgressiveTextures(e,t,i){if(!e)return;if(Array.isArray(e)){for(const a of e)this.loadProgressiveTextures(a,t);return}let s=!1;if((e[Ae]===void 0||t<e[Ae])&&(s=!0),i!==void 0&&i>=0&&(s=e[Ae]!=i,t=i),s){e[Ae]=t;const a=he.assignTextureLOD(e,t).then(o=>{this._lodchangedlisteners.forEach(c=>c({type:"texture",level:t,object:e}))});ei.addPromise("texture",e,a,this._newPromiseGroups)}}loadProgressiveMeshes(e,t){if(!e)return Promise.resolve(null);let i=e[Ae]!==t;const s=e["DEBUG:LOD"];if(s!=null&&(i=e[Ae]!=s,t=s),i){e[Ae]=t;const a=e.geometry,o=he.assignMeshLOD(e,t).then(c=>(c&&e[Ae]==t&&a!=e.geometry&&this._lodchangedlisteners.forEach(u=>u({type:"mesh",level:t,object:e})),c));return ei.addPromise("mesh",e,o,this._newPromiseGroups),o}return Promise.resolve(null)}static isInside(e,t){const i=e.min,s=e.max,a=(i.x+s.x)*.5,o=(i.y+s.y)*.5;return this._tempPtInside.set(a,o,i.z).applyMatrix4(t).z<0}calculateLodLevel(e,t,i,s,a){var m,v,y,x;if(!t){a.mesh_lod=-1,a.texture_lod=-1;return}if(!e){a.mesh_lod=-1,a.texture_lod=-1;return}let c=10+1,u=!1;if(oe&&t["DEBUG:LOD"]!=null)return t["DEBUG:LOD"];const f=(m=he.getMeshLODExtension(t.geometry))==null?void 0:m.lods,p=he.getPrimitiveIndex(t.geometry),r=f&&f.length>0,l=he.getMaterialMinMaxLODsCount(t.material),h=l.min_count!==1/0&&l.min_count>=0&&l.max_count>=0;if(!r&&!h){a.mesh_lod=0,a.texture_lod=0;return}r||(u=!0,c=0);const g=this.renderer.domElement.clientHeight||this.renderer.domElement.height;let _=t.geometry.boundingBox;if(t.type==="SkinnedMesh"){const w=t;if(!w.boundingBox)w.computeBoundingBox();else if(this.skinnedMeshAutoUpdateBoundsInterval>0){if(!w[V.$skinnedMeshBoundsOffset]){const A=V.skinnedMeshBoundsFrameOffsetCounter++;w[V.$skinnedMeshBoundsOffset]=A}const b=w[V.$skinnedMeshBoundsOffset];if((i.frames+b)%this.skinnedMeshAutoUpdateBoundsInterval===0){const A=Lt(w),S=w.geometry;A&&(w.geometry=A),w.computeBoundingBox(),w.geometry=S}}_=w.boundingBox}if(_){const w=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 C=e.getWorldPosition(this._tempWorldPosition);if(this._sphere.containsPoint(C)){a.mesh_lod=0,a.texture_lod=0;return}}if(this._tempBox.copy(_),this._tempBox.applyMatrix4(t.matrixWorld),w.isPerspectiveCamera&&V.isInside(this._tempBox,this.projectionScreenMatrix)){a.mesh_lod=0,a.texture_lod=0;return}if(this._tempBox.applyMatrix4(this.projectionScreenMatrix),this.renderer.xr.enabled&&w.isPerspectiveCamera&&w.fov>70){const C=this._tempBox.min,D=this._tempBox.max;let E=C.x,F=C.y,O=D.x,H=D.y;const W=2,$=1.5,ee=(C.x+D.x)*.5,pe=(C.y+D.y)*.5;E=(E-ee)*W+ee,F=(F-pe)*W+pe,O=(O-ee)*W+ee,H=(H-pe)*W+pe;const ht=E<0&&O>0?0:Math.min(Math.abs(C.x),Math.abs(D.x)),di=F<0&&H>0?0:Math.min(Math.abs(C.y),Math.abs(D.y)),ft=Math.max(ht,di);i.lastCentrality=($-ft)*($-ft)*($-ft)}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 A=e.matrixWorldInverse,S=this._tempBox2;S.copy(_),S.applyMatrix4(t.matrixWorld),S.applyMatrix4(A);const I=S.getSize(this._tempBox2Size),M=Math.max(I.x,I.y);if(Math.max(b.x,b.y)!=0&&M!=0&&(b.z=I.z/Math.max(I.x,I.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,oe&&V.debugDrawLine){const C=this.tempMatrix.copy(this.projectionScreenMatrix);C.invert();const D=V.corner0,E=V.corner1,F=V.corner2,O=V.corner3;D.copy(this._tempBox.min),E.copy(this._tempBox.max),E.x=D.x,F.copy(this._tempBox.max),F.y=D.y,O.copy(this._tempBox.max);const H=(D.z+O.z)*.5;D.z=E.z=F.z=O.z=H,D.applyMatrix4(C),E.applyMatrix4(C),F.applyMatrix4(C),O.applyMatrix4(C),V.debugDrawLine(D,E,255),V.debugDrawLine(D,F,255),V.debugDrawLine(E,O,255),V.debugDrawLine(F,O,255)}let R=999;if(f&&i.lastScreenCoverage>0)for(let C=0;C<f.length;C++){const D=f[C],F=(((v=D.densities)==null?void 0:v[p])||D.density||1e-5)/i.lastScreenCoverage;if(p>0&&Vs()&&!D.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.")),F<s){R=C;break}}R<c&&(c=R,u=!0)}if(u?a.mesh_lod=c:a.mesh_lod=i.lastLodLevel_Mesh,oe&&a.mesh_lod!=i.lastLodLevel_Mesh){const b=f==null?void 0:f[a.mesh_lod];b&&console.log(`Mesh LOD changed: ${i.lastLodLevel_Mesh} → ${a.mesh_lod} (density: ${(y=b.densities)==null?void 0:y[p].toFixed(0)}) | ${t.name}`)}if(h){const w="saveData"in globalThis.navigator&&globalThis.navigator.saveData===!0;if(i.lastLodLevel_Texture<0){if(a.texture_lod=l.max_count-1,oe){const b=l.lods[l.max_count-1];oe&&console.log(`First Texture LOD ${a.texture_lod} (${b.max_height}px) - ${t.name}`)}}else{const b=i.lastScreenspaceVolume.x+i.lastScreenspaceVolume.y+i.lastScreenspaceVolume.z;let A=i.lastScreenCoverage*4;((x=this.context)==null?void 0:x.engine)==="model-viewer"&&(A*=1.5);const I=g/window.devicePixelRatio*A;let M=!1;for(let P=l.lods.length-1;P>=0;P--){const R=l.lods[P];if(!(w&&R.max_height>=2048)&&!(xr()&&R.max_height>4096)&&(R.max_height>I||!M&&P===0)){if(M=!0,a.texture_lod=P,oe&&a.texture_lod<i.lastLodLevel_Texture){const T=R.max_height;console.log(`Texture LOD changed: ${i.lastLodLevel_Texture} → ${a.texture_lod} = ${T}px
3686
+ Screensize: ${I.toFixed(0)}px, Coverage: ${(100*i.lastScreenCoverage).toFixed(2)}%, Volume ${b.toFixed(1)}
3687
+ ${t.name}`)}break}}}}else a.texture_lod=0}};X=new WeakMap,ve=new WeakMap,ai=new WeakMap,Ie=new WeakMap,rt=new WeakMap,li=new WeakMap,_e=new WeakMap,L(V,"debugDrawLine"),L(V,"corner0",new d.Vector3),L(V,"corner1",new d.Vector3),L(V,"corner2",new d.Vector3),L(V,"corner3",new d.Vector3),L(V,"_tempPtInside",new d.Vector3),L(V,"skinnedMeshBoundsFrameOffsetCounter",0),L(V,"$skinnedMeshBoundsOffset",Symbol("gltf-progressive-skinnedMeshBoundsOffset"));let at=V;class Aa{constructor(){L(this,"frames",0);L(this,"lastLodLevel_Mesh",-1);L(this,"lastLodLevel_Texture",-1);L(this,"lastScreenCoverage",0);L(this,"lastScreenspaceVolume",new d.Vector3);L(this,"lastCentrality",0)}}const Us=Symbol("NEEDLE_mesh_lod"),Vt=Symbol("NEEDLE_texture_lod");let gt=null;function br(){const n=Ta();n&&(n.mapURLs(function(e){return Hs(),e}),Hs(),gt==null||gt.disconnect(),gt=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(i=>{i instanceof HTMLElement&&i.tagName.toLowerCase()==="model-viewer"&&Ar(i)})})}),gt.observe(document,{childList:!0,subtree:!0}))}function Ta(){if(typeof customElements>"u")return null;const n=customElements.get("model-viewer");return n||(customElements.whenDefined("model-viewer").then(()=>{console.debug("[gltf-progressive] model-viewer defined"),br()}),null)}function Hs(){if(typeof document>"u")return;document.querySelectorAll("model-viewer").forEach(e=>{Ar(e)})}const Ns=new WeakSet;let Sa=0;function Ar(n){if(!n||Ns.has(n))return null;Ns.add(n),console.debug("[gltf-progressive] found new model-viewer..."+ ++Sa+`
3688
+ `,n.getAttribute("src"));let e=null,t=null,i=null;for(let s=n;s!=null;s=Object.getPrototypeOf(s)){const a=Object.getOwnPropertySymbols(s),o=a.find(f=>f.toString()=="Symbol(renderer)"),c=a.find(f=>f.toString()=="Symbol(scene)"),u=a.find(f=>f.toString()=="Symbol(needsRender)");!e&&o!=null&&(e=n[o].threeRenderer),!t&&c!=null&&(t=n[c]),!i&&u!=null&&(i=n[u])}if(e&&t){let s=function(){if(i){let o=0,c=setInterval(()=>{if(o++>5){clearInterval(c);return}i==null||i.call(n)},300)}};console.debug("[gltf-progressive] setup model-viewer");const a=at.get(e,{engine:"model-viewer"});return at.addPlugin(new Ma),a.enable(),a.addEventListener("changed",()=>{i==null||i.call(n)}),n.addEventListener("model-visibility",o=>{o.detail.visible&&(i==null||i.call(n))}),n.addEventListener("load",()=>{s()}),()=>{a.disable()}}return null}class Ma{constructor(){L(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[Vt]==!0)return;t[Vt]=!0;const i=this.tryGetCurrentGLTF(e),s=this.tryGetCurrentModelViewer(e),a=this.getUrl(s);if(a&&i&&t.material){let o=function(u){var p,r,l;if(u[Vt]==!0)return;u[Vt]=!0,u.userData&&(u.userData.LOD=-1);const f=Object.keys(u);for(let h=0;h<f.length;h++){const g=f[h],_=u[g];if((_==null?void 0:_.isTexture)===!0){const m=(r=(p=_.userData)==null?void 0:p.associations)==null?void 0:r.textures;if(m==null)continue;const v=i.parser.json.textures[m];if(!v){console.warn("Texture data not found for texture index "+m);continue}if((l=v==null?void 0:v.extensions)!=null&&l[ge]){const y=v.extensions[ge];y&&a&&he.registerTexture(a,_,y.lods.length,m,y)}}}};const c=t.material;if(Array.isArray(c))for(const u of c)o(u);else o(c)}}tryParseMeshLOD(e,t){var o,c;if(t[Us]==!0)return;t[Us]=!0;const i=this.tryGetCurrentModelViewer(e),s=this.getUrl(i);if(!s)return;const a=(c=(o=t.userData)==null?void 0:o.gltfExtensions)==null?void 0:c[ge];if(a&&s){const u=t.uuid;he.registerMesh(s,u,t,0,a.lods.length,a)}}}function Tr(...n){let e,t,i,s;switch(n.length){case 2:[i,t]=n,s={};break;case 3:[i,t,s]=n;break;case 4:[e,t,i,s]=n;break;default:throw new Error("Invalid arguments")}os(),vr(i),yr(i,{progressive:!0,...s==null?void 0:s.hints}),i.register(o=>new he(o));const a=at.get(t);return(s==null?void 0:s.enableLODsManager)!==!1&&a.enable(),a}br();if(!ha){const n={gltfProgressive:{useNeedleProgressive:Tr,LODsManager:at,configureLoader:yr,getRaycastMesh:Lt,useRaycastMeshes:da}};if(!globalThis.Needle)globalThis.Needle=n;else for(const e in n)globalThis.Needle[e]=n[e]}var it=Object.freeze({Linear:Object.freeze({None:function(n){return n},In:function(n){return n},Out:function(n){return n},InOut:function(n){return n}}),Quadratic:Object.freeze({In:function(n){return n*n},Out:function(n){return n*(2-n)},InOut:function(n){return(n*=2)<1?.5*n*n:-.5*(--n*(n-2)-1)}}),Cubic:Object.freeze({In:function(n){return n*n*n},Out:function(n){return--n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n:.5*((n-=2)*n*n+2)}}),Quartic:Object.freeze({In:function(n){return n*n*n*n},Out:function(n){return 1- --n*n*n*n},InOut:function(n){return(n*=2)<1?.5*n*n*n*n:-.5*((n-=2)*n*n*n-2)}}),Quintic:Object.freeze({In:function(n){return n*n*n*n*n},Out:function(n){return--n*n*n*n*n+1},InOut:function(n){return(n*=2)<1?.5*n*n*n*n*n:.5*((n-=2)*n*n*n*n+2)}}),Sinusoidal:Object.freeze({In:function(n){return 1-Math.sin((1-n)*Math.PI/2)},Out:function(n){return Math.sin(n*Math.PI/2)},InOut:function(n){return .5*(1-Math.sin(Math.PI*(.5-n)))}}),Exponential:Object.freeze({In:function(n){return n===0?0:Math.pow(1024,n-1)},Out:function(n){return n===1?1:1-Math.pow(2,-10*n)},InOut:function(n){return n===0?0:n===1?1:(n*=2)<1?.5*Math.pow(1024,n-1):.5*(-Math.pow(2,-10*(n-1))+2)}}),Circular:Object.freeze({In:function(n){return 1-Math.sqrt(1-n*n)},Out:function(n){return Math.sqrt(1- --n*n)},InOut:function(n){return(n*=2)<1?-.5*(Math.sqrt(1-n*n)-1):.5*(Math.sqrt(1-(n-=2)*n)+1)}}),Elastic:Object.freeze({In:function(n){return n===0?0:n===1?1:-Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI)},Out:function(n){return n===0?0:n===1?1:Math.pow(2,-10*n)*Math.sin((n-.1)*5*Math.PI)+1},InOut:function(n){return n===0?0:n===1?1:(n*=2,n<1?-.5*Math.pow(2,10*(n-1))*Math.sin((n-1.1)*5*Math.PI):.5*Math.pow(2,-10*(n-1))*Math.sin((n-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(n){var e=1.70158;return n===1?1:n*n*((e+1)*n-e)},Out:function(n){var e=1.70158;return n===0?0:--n*n*((e+1)*n+e)+1},InOut:function(n){var e=2.5949095;return(n*=2)<1?.5*(n*n*((e+1)*n-e)):.5*((n-=2)*n*((e+1)*n+e)+2)}}),Bounce:Object.freeze({In:function(n){return 1-it.Bounce.Out(1-n)},Out:function(n){return n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375},InOut:function(n){return n<.5?it.Bounce.In(n*2)*.5:it.Bounce.Out(n*2-1)*.5+.5}}),generatePow:function(n){return n===void 0&&(n=4),n=n<Number.EPSILON?Number.EPSILON:n,n=n>1e4?1e4:n,{In:function(e){return Math.pow(e,n)},Out:function(e){return 1-Math.pow(1-e,n)},InOut:function(e){return e<.5?Math.pow(e*2,n)/2:(1-Math.pow(2-e*2,n))/2+.5}}}}),$e=function(){return performance.now()},Sr=function(){function n(){this._tweens={},this._tweensAddedDuringUpdate={}}return n.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},n.prototype.removeAll=function(){this._tweens={}},n.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},n.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},n.prototype.update=function(e,t){e===void 0&&(e=$e()),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 a=this._tweens[i[s]],o=!t;a&&a.update(e,o)===!1&&!t&&delete this._tweens[i[s]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},n}(),ke={Linear:function(n,e){var t=n.length-1,i=t*e,s=Math.floor(i),a=ke.Utils.Linear;return e<0?a(n[0],n[1],i):e>1?a(n[t],n[t-1],t-i):a(n[s],n[s+1>t?t:s+1],i-s)},Bezier:function(n,e){for(var t=0,i=n.length-1,s=Math.pow,a=ke.Utils.Bernstein,o=0;o<=i;o++)t+=s(1-e,i-o)*s(e,o)*n[o]*a(i,o);return t},CatmullRom:function(n,e){var t=n.length-1,i=t*e,s=Math.floor(i),a=ke.Utils.CatmullRom;return n[0]===n[t]?(e<0&&(s=Math.floor(i=t*(1+e))),a(n[(s-1+t)%t],n[s],n[(s+1)%t],n[(s+2)%t],i-s)):e<0?n[0]-(a(n[0],n[0],n[1],n[1],-i)-n[0]):e>1?n[t]-(a(n[t],n[t],n[t-1],n[t-1],i-t)-n[t]):a(n[s?s-1:0],n[s],n[t<s+1?t:s+1],n[t<s+2?t:s+2],i-s)},Utils:{Linear:function(n,e,t){return(e-n)*t+n},Bernstein:function(n,e){var t=ke.Utils.Factorial;return t(n)/t(e)/t(n-e)},Factorial:function(){var n=[1];return function(e){var t=1;if(n[e])return n[e];for(var i=e;i>1;i--)t*=i;return n[e]=t,t}}(),CatmullRom:function(n,e,t,i,s){var a=(t-n)*.5,o=(i-e)*.5,c=s*s,u=s*c;return(2*e-2*t+a+o)*u+(-3*e+3*t-2*a-o)*c+a*s+e}}},ls=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),Ui=new Sr,It=function(){function n(e,t){t===void 0&&(t=Ui),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=it.Linear.None,this._interpolationFunction=ke.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=ls.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.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},n.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},n.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},n.prototype.start=function(e,t){if(e===void 0&&(e=$e()),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 a in this._valuesEnd)s[a]=this._valuesEnd[a];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},n.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},n.prototype._setupProperties=function(e,t,i,s,a){for(var o in i){var c=e[o],u=Array.isArray(c),f=u?"array":typeof c,p=!u&&Array.isArray(i[o]);if(!(f==="undefined"||f==="function")){if(p){var r=i[o];if(r.length===0)continue;for(var l=[c],h=0,g=r.length;h<g;h+=1){var _=this._handleRelativeValue(c,r[h]);if(isNaN(_)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}l.push(_)}p&&(i[o]=l)}if((f==="object"||u)&&c&&!p){t[o]=u?[]:{};var m=c;for(var v in m)t[o][v]=m[v];s[o]=u?[]:{};var r=i[o];if(!this._isDynamic){var y={};for(var v in r)y[v]=r[v];i[o]=r=y}this._setupProperties(m,t[o],r,s[o],a)}else(typeof t[o]>"u"||a)&&(t[o]=c),u||(t[o]*=1),p?s[o]=i[o].slice().reverse():s[o]=t[o]||0}}},n.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},n.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},n.prototype.pause=function(e){return e===void 0&&(e=$e()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},n.prototype.resume=function(e){return e===void 0&&(e=$e()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},n.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},n.prototype.group=function(e){return e===void 0&&(e=Ui),this._group=e,this},n.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},n.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},n.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},n.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},n.prototype.easing=function(e){return e===void 0&&(e=it.Linear.None),this._easingFunction=e,this},n.prototype.interpolation=function(e){return e===void 0&&(e=ke.Linear),this._interpolationFunction=e,this},n.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},n.prototype.onStart=function(e){return this._onStartCallback=e,this},n.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},n.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},n.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},n.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},n.prototype.onStop=function(e){return this._onStopCallback=e,this},n.prototype.update=function(e,t){var i=this,s;if(e===void 0&&(e=$e()),t===void 0&&(t=!0),this._isPaused)return!0;var a,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,u=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),f=this._duration+this._repeat*u,p=function(){if(i._duration===0||c>f)return 1;var m=Math.trunc(c/u),v=c-m*u,y=Math.min(v/i._duration,1);return y===0&&c===i._duration?1:y},r=p(),l=this._easingFunction(r);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,l),this._onUpdateCallback&&this._onUpdateCallback(this._object,r),this._duration===0||c>=this._duration)if(this._repeat>0){var h=Math.min(Math.trunc((c-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=h);for(a in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[a]=="string"&&(this._valuesStartRepeat[a]=this._valuesStartRepeat[a]+parseFloat(this._valuesEnd[a])),this._yoyo&&this._swapEndStartRepeatValues(a),this._valuesStart[a]=this._valuesStartRepeat[a];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*h,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,_=this._chainedTweens.length;g<_;g++)this._chainedTweens[g].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},n.prototype._updateProperties=function(e,t,i,s){for(var a in i)if(t[a]!==void 0){var o=t[a]||0,c=i[a],u=Array.isArray(e[a]),f=Array.isArray(c),p=!u&&f;p?e[a]=this._interpolationFunction(c,s):typeof c=="object"&&c?this._updateProperties(e[a],o,c,s):(c=this._handleRelativeValue(o,c),typeof c=="number"&&(e[a]=o+(c-o)*s))}},n.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},n.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},n}(),Ca="23.1.3",Ia=ls.nextId,de=Ui,Ra=de.getAll.bind(de),Pa=de.removeAll.bind(de),Da=de.add.bind(de),La=de.remove.bind(de),Ea=de.update.bind(de),ye={Easing:it,Group:Sr,Interpolation:ke,now:$e,Sequence:ls,nextId:Ia,Tween:It,VERSION:Ca,getAll:Ra,removeAll:Pa,add:Da,remove:La,update:Ea},vt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fa(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Mr={exports:{}};(function(n){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(u,f,p){this.fn=u,this.context=f,this.once=p||!1}function a(u,f,p,r,l){if(typeof p!="function")throw new TypeError("The listener must be a function");var h=new s(p,r||u,l),g=t?t+f:f;return u._events[g]?u._events[g].fn?u._events[g]=[u._events[g],h]:u._events[g].push(h):(u._events[g]=h,u._eventsCount++),u}function o(u,f){--u._eventsCount===0?u._events=new i:delete u._events[f]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],p,r;if(this._eventsCount===0)return f;for(r in p=this._events)e.call(p,r)&&f.push(t?r.slice(1):r);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},c.prototype.listeners=function(f){var p=t?t+f:f,r=this._events[p];if(!r)return[];if(r.fn)return[r.fn];for(var l=0,h=r.length,g=new Array(h);l<h;l++)g[l]=r[l].fn;return g},c.prototype.listenerCount=function(f){var p=t?t+f:f,r=this._events[p];return r?r.fn?1:r.length:0},c.prototype.emit=function(f,p,r,l,h,g){var _=t?t+f:f;if(!this._events[_])return!1;var m=this._events[_],v=arguments.length,y,x;if(m.fn){switch(m.once&&this.removeListener(f,m.fn,void 0,!0),v){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,r),!0;case 4:return m.fn.call(m.context,p,r,l),!0;case 5:return m.fn.call(m.context,p,r,l,h),!0;case 6:return m.fn.call(m.context,p,r,l,h,g),!0}for(x=1,y=new Array(v-1);x<v;x++)y[x-1]=arguments[x];m.fn.apply(m.context,y)}else{var w=m.length,b;for(x=0;x<w;x++)switch(m[x].once&&this.removeListener(f,m[x].fn,void 0,!0),v){case 1:m[x].fn.call(m[x].context);break;case 2:m[x].fn.call(m[x].context,p);break;case 3:m[x].fn.call(m[x].context,p,r);break;case 4:m[x].fn.call(m[x].context,p,r,l);break;default:if(!y)for(b=1,y=new Array(v-1);b<v;b++)y[b-1]=arguments[b];m[x].fn.apply(m[x].context,y)}}return!0},c.prototype.on=function(f,p,r){return a(this,f,p,r,!1)},c.prototype.once=function(f,p,r){return a(this,f,p,r,!0)},c.prototype.removeListener=function(f,p,r,l){var h=t?t+f:f;if(!this._events[h])return this;if(!p)return o(this,h),this;var g=this._events[h];if(g.fn)g.fn===p&&(!l||g.once)&&(!r||g.context===r)&&o(this,h);else{for(var _=0,m=[],v=g.length;_<v;_++)(g[_].fn!==p||l&&!g[_].once||r&&g[_].context!==r)&&m.push(g[_]);m.length?this._events[h]=m.length===1?m[0]:m:o(this,h)}return this},c.prototype.removeAllListeners=function(f){var p;return f?(p=t?t+f:f,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,n.exports=c})(Mr);var Ba=Mr.exports;const ct=Fa(Ba);var Rt=function(){var n=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(r){r.preventDefault(),i(++n%e.children.length)},!1);function t(r){return e.appendChild(r.dom),r}function i(r){for(var l=0;l<e.children.length;l++)e.children[l].style.display=l===r?"block":"none";n=r}var s=(performance||Date).now(),a=s,o=0,c=t(new Rt.Panel("FPS","#0ff","#002")),u=t(new Rt.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var f=t(new Rt.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 r=(performance||Date).now();if(u.update(r-s,200),r>=a+1e3&&(p=o*1e3/(r-a),c.update(p,100),a=r,o=0,f)){var l=performance.memory;f.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return r},update:function(){s=this.end()},domElement:e,setMode:i}};Rt.Panel=function(n,e,t){var i=1/0,s=0,a=Math.round,o=a(window.devicePixelRatio||1),c=80*o,u=48*o,f=3*o,p=2*o,r=3*o,l=15*o,h=74*o,g=30*o,_=document.createElement("canvas");_.width=c,_.height=u,_.style.cssText="width:80px;height:48px";var m=_.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=t,m.fillRect(0,0,c,u),m.fillStyle=e,m.fillText(n,f,p),m.fillRect(r,l,h,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(r,l,h,g),{dom:_,update:function(v,y){i=Math.min(i,v),s=Math.max(s,v),m.fillStyle=t,m.globalAlpha=1,m.fillRect(0,0,c,l),m.fillStyle=e,m.fillText(a(v)+" "+n+" ("+a(i)+"-"+a(s)+")",f,p),m.drawImage(_,r+o,l,h-o,g,r,l,h-o,g),m.fillRect(r+h-o,l,o,g),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(r+h-o,l,o,a((1-v/y)*g))}}};function ka(n,e){const t=URL.createObjectURL(n),i=document.createElement("a");i.href=t,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}function Cr(n){return n.length===0?0:n.reduce((t,i)=>t+i,0)/n.length}function Hi(n,e){const t=new Blob([n],{type:e});return URL.createObjectURL(t)}function Ir(){return/Mac|iPod|iPhone|iPad/.test(navigator==null?void 0:navigator.platform)||/Mac OS|iOS/.test(navigator==null?void 0:navigator.userAgent)}function Ni(n){let e=document.createElement("canvas");const t=e.getContext("2d");return e.width=n.width,e.height=n.height,t?(t.drawImage(n,0,0),e.toDataURL("image/png",.75)):void 0}function Oa(n,e=43){const t=n*Math.PI/180;return e/(2*Math.tan(t/2))}var Rr={};/*!
3689
3689
  * howler.js v2.2.4
3690
3690
  * howlerjs.com
3691
3691
  *
@@ -3693,7 +3693,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};Z=new WeakMap,ve=new WeakMap,di=new
3693
3693
  * goldfirestudios.com
3694
3694
  *
3695
3695
  * MIT License
3696
- */(function(r){(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||m(),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 h=0;h<l._howls.length;h++)if(!l._howls[h]._webAudio)for(var g=l._howls[h]._getSoundIds(),_=0;_<g.length;_++){var d=l._howls[h]._soundById(g[_]);d&&d._node&&(d._node.volume=d._volume*n)}return l}return l._volume},mute:function(n){var l=this||t;l.ctx||m(),l._muted=n,l.usingWebAudio&&l.masterGain.gain.setValueAtTime(n?0:l._volume,t.ctx.currentTime);for(var h=0;h<l._howls.length;h++)if(!l._howls[h]._webAudio)for(var g=l._howls[h]._getSoundIds(),_=0;_<g.length;_++){var d=l._howls[h]._soundById(g[_]);d&&d._node&&(d._node.muted=n?!0:d._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,m()),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 h=l.canPlayType("audio/mpeg;").replace(/^no$/,""),g=n._navigator?n._navigator.userAgent:"",_=g.match(/OPR\/(\d+)/g),d=_&&parseInt(_[0].split("/")[1],10)<33,v=g.indexOf("Safari")!==-1&&g.indexOf("Chrome")===-1,y=g.match(/Version\/(.*?) /),x=v&&y&&parseInt(y[1],10)<15;return n._codecs={mp3:!!(!d&&(h||l.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!h,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:!!(!x&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&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(h){for(;n._html5AudioPool.length<n.html5PoolSize;)try{var g=new Audio;g._unlocked=!0,n._releaseHtml5Audio(g)}catch{n.noAudio=!0;break}for(var _=0;_<n._howls.length;_++)if(!n._howls[_]._webAudio)for(var d=n._howls[_]._getSoundIds(),v=0;v<d.length;v++){var y=n._howls[_]._soundById(d[v]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}n._autoResume();var x=n.ctx.createBufferSource();x.buffer=n._scratchBuffer,x.connect(n.ctx.destination),typeof x.start>"u"?x.noteOn(0):x.start(0),typeof n.ctx.resume=="function"&&n.ctx.resume(),x.onended=function(){x.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 w=0;w<n._howls.length;w++)n._howls[w]._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 h=0;h<n._howls[l]._sounds.length;h++)if(!n._howls[l]._sounds[h]._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||m(),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 h=0;h<n._src.length;h++){var g,_;if(n._format&&n._format[h])g=n._format[h];else{if(_=n._src[h],typeof _!="string"){n._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}g=/^data:audio\/([^;,]+);/i.exec(_),g||(g=/\.([^.]+)$/.exec(_.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[h];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 h=this,g=null;if(typeof n=="number")g=n,n=null;else{if(typeof n=="string"&&h._state==="loaded"&&!h._sprite[n])return null;if(typeof n>"u"&&(n="__default",!h._playLock)){for(var _=0,d=0;d<h._sounds.length;d++)h._sounds[d]._paused&&!h._sounds[d]._ended&&(_++,g=h._sounds[d]._id);_===1?n=null:g=null}}var v=g?h._soundById(g):h._inactiveSound();if(!v)return null;if(g&&!n&&(n=v._sprite||"__default"),h._state!=="loaded"){v._sprite=n,v._ended=!1;var y=v._id;return h._queue.push({event:"play",action:function(){h.play(y)}}),y}if(g&&!v._paused)return l||h._loadQueue("play"),v._id;h._webAudio&&t._autoResume();var x=Math.max(0,v._seek>0?v._seek:h._sprite[n][0]/1e3),w=Math.max(0,(h._sprite[n][0]+h._sprite[n][1])/1e3-x),b=w*1e3/Math.abs(v._rate),T=h._sprite[n][0]/1e3,S=(h._sprite[n][0]+h._sprite[n][1])/1e3;v._sprite=n,v._ended=!1;var P=function(){v._paused=!1,v._seek=x,v._start=T,v._stop=S,v._loop=!!(v._loop||h._sprite[n][2])};if(x>=S){h._ended(v);return}var C=v._node;if(h._webAudio){var R=function(){h._playLock=!1,P(),h._refreshBuffer(v);var I=v._muted||h._muted?0:v._volume;C.gain.setValueAtTime(I,t.ctx.currentTime),v._playStart=t.ctx.currentTime,typeof C.bufferSource.start>"u"?v._loop?C.bufferSource.noteGrainOn(0,x,86400):C.bufferSource.noteGrainOn(0,x,w):v._loop?C.bufferSource.start(0,x,86400):C.bufferSource.start(0,x,w),b!==1/0&&(h._endTimers[v._id]=setTimeout(h._ended.bind(h,v),b)),l||setTimeout(function(){h._emit("play",v._id),h._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?R():(h._playLock=!0,h.once("resume",R),h._clearTimer(v._id))}else{var E=function(){C.currentTime=x,C.muted=v._muted||h._muted||t._muted||C.muted,C.volume=v._volume*t.volume(),C.playbackRate=v._rate;try{var I=C.play();if(I&&typeof Promise<"u"&&(I instanceof Promise||typeof I.then=="function")?(h._playLock=!0,P(),I.then(function(){h._playLock=!1,C._unlocked=!0,l?h._loadQueue():h._emit("play",v._id)}).catch(function(){h._playLock=!1,h._emit("playerror",v._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."),v._ended=!0,v._paused=!0})):l||(h._playLock=!1,P(),h._emit("play",v._id)),C.playbackRate=v._rate,C.paused){h._emit("playerror",v._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"||v._loop?h._endTimers[v._id]=setTimeout(h._ended.bind(h,v),b):(h._endTimers[v._id]=function(){h._ended(v),C.removeEventListener("ended",h._endTimers[v._id],!1)},C.addEventListener("ended",h._endTimers[v._id],!1))}catch(L){h._emit("playerror",v._id,L)}};C.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(C.src=h._src,C.load());var A=window&&window.ejecta||!C.readyState&&t._navigator.isCocoonJS;if(C.readyState>=3||A)E();else{h._playLock=!0,h._state="loading";var M=function(){h._state="loaded",E(),C.removeEventListener(t._canPlayEvent,M,!1)};C.addEventListener(t._canPlayEvent,M,!1),h._clearTimer(v._id)}}return v._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 h=l._getSoundIds(n),g=0;g<h.length;g++){l._clearTimer(h[g]);var _=l._soundById(h[g]);if(_&&!_._paused&&(_._seek=l.seek(h[g]),_._rateSeek=0,_._paused=!0,l._stopFade(h[g]),_._node))if(l._webAudio){if(!_._node.bufferSource)continue;typeof _._node.bufferSource.stop>"u"?_._node.bufferSource.noteOff(0):_._node.bufferSource.stop(0),l._cleanBuffer(_._node)}else(!isNaN(_._node.duration)||_._node.duration===1/0)&&_._node.pause();arguments[1]||l._emit("pause",_?_._id:null)}return l},stop:function(n,l){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"stop",action:function(){h.stop(n)}}),h;for(var g=h._getSoundIds(n),_=0;_<g.length;_++){h._clearTimer(g[_]);var d=h._soundById(g[_]);d&&(d._seek=d._start||0,d._rateSeek=0,d._paused=!0,d._ended=!0,h._stopFade(g[_]),d._node&&(h._webAudio?d._node.bufferSource&&(typeof d._node.bufferSource.stop>"u"?d._node.bufferSource.noteOff(0):d._node.bufferSource.stop(0),h._cleanBuffer(d._node)):(!isNaN(d._node.duration)||d._node.duration===1/0)&&(d._node.currentTime=d._start||0,d._node.pause(),d._node.duration===1/0&&h._clearSound(d._node))),l||h._emit("stop",d._id))}return h},mute:function(n,l){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"mute",action:function(){h.mute(n,l)}}),h;if(typeof l>"u")if(typeof n=="boolean")h._muted=n;else return h._muted;for(var g=h._getSoundIds(l),_=0;_<g.length;_++){var d=h._soundById(g[_]);d&&(d._muted=n,d._interval&&h._stopFade(d._id),h._webAudio&&d._node?d._node.gain.setValueAtTime(n?0:d._volume,t.ctx.currentTime):d._node&&(d._node.muted=t._muted?!0:n),h._emit("mute",d._id))}return h},volume:function(){var n=this,l=arguments,h,g;if(l.length===0)return n._volume;if(l.length===1||l.length===2&&typeof l[1]>"u"){var _=n._getSoundIds(),d=_.indexOf(l[0]);d>=0?g=parseInt(l[0],10):h=parseFloat(l[0])}else l.length>=2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));var v;if(typeof h<"u"&&h>=0&&h<=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=h),g=n._getSoundIds(g);for(var y=0;y<g.length;y++)v=n._soundById(g[y]),v&&(v._volume=h,l[2]||n._stopFade(g[y]),n._webAudio&&v._node&&!v._muted?v._node.gain.setValueAtTime(h,t.ctx.currentTime):v._node&&!v._muted&&(v._node.volume=h*t.volume()),n._emit("volume",v._id))}else return v=g?n._soundById(g):n._sounds[0],v?v._volume:0;return n},fade:function(n,l,h,g){var _=this;if(_._state!=="loaded"||_._playLock)return _._queue.push({event:"fade",action:function(){_.fade(n,l,h,g)}}),_;n=Math.min(Math.max(0,parseFloat(n)),1),l=Math.min(Math.max(0,parseFloat(l)),1),h=parseFloat(h),_.volume(n,g);for(var d=_._getSoundIds(g),v=0;v<d.length;v++){var y=_._soundById(d[v]);if(y){if(g||_._stopFade(d[v]),_._webAudio&&!y._muted){var x=t.ctx.currentTime,w=x+h/1e3;y._volume=n,y._node.gain.setValueAtTime(n,x),y._node.gain.linearRampToValueAtTime(l,w)}_._startFadeInterval(y,n,l,h,d[v],typeof g>"u")}}return _},_startFadeInterval:function(n,l,h,g,_,d){var v=this,y=l,x=h-l,w=Math.abs(x/.01),b=Math.max(4,w>0?g/w:g),T=Date.now();n._fadeTo=h,n._interval=setInterval(function(){var S=(Date.now()-T)/g;T=Date.now(),y+=x*S,y=Math.round(y*100)/100,x<0?y=Math.max(h,y):y=Math.min(h,y),v._webAudio?n._volume=y:v.volume(y,n._id,!0),d&&(v._volume=y),(h<l&&y<=h||h>l&&y>=h)&&(clearInterval(n._interval),n._interval=null,n._fadeTo=null,v.volume(h,n._id),v._emit("fade",n._id))},b)},_stopFade:function(n){var l=this,h=l._soundById(n);return h&&h._interval&&(l._webAudio&&h._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(h._interval),h._interval=null,l.volume(h._fadeTo,n),h._fadeTo=null,l._emit("fade",n)),l},loop:function(){var n=this,l=arguments,h,g,_;if(l.length===0)return n._loop;if(l.length===1)if(typeof l[0]=="boolean")h=l[0],n._loop=h;else return _=n._soundById(parseInt(l[0],10)),_?_._loop:!1;else l.length===2&&(h=l[0],g=parseInt(l[1],10));for(var d=n._getSoundIds(g),v=0;v<d.length;v++)_=n._soundById(d[v]),_&&(_._loop=h,n._webAudio&&_._node&&_._node.bufferSource&&(_._node.bufferSource.loop=h,h&&(_._node.bufferSource.loopStart=_._start||0,_._node.bufferSource.loopEnd=_._stop,n.playing(d[v])&&(n.pause(d[v],!0),n.play(d[v],!0)))));return n},rate:function(){var n=this,l=arguments,h,g;if(l.length===0)g=n._sounds[0]._id;else if(l.length===1){var _=n._getSoundIds(),d=_.indexOf(l[0]);d>=0?g=parseInt(l[0],10):h=parseFloat(l[0])}else l.length===2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));var v;if(typeof h=="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=h),g=n._getSoundIds(g);for(var y=0;y<g.length;y++)if(v=n._soundById(g[y]),v){n.playing(g[y])&&(v._rateSeek=n.seek(g[y]),v._playStart=n._webAudio?t.ctx.currentTime:v._playStart),v._rate=h,n._webAudio&&v._node&&v._node.bufferSource?v._node.bufferSource.playbackRate.setValueAtTime(h,t.ctx.currentTime):v._node&&(v._node.playbackRate=h);var x=n.seek(g[y]),w=(n._sprite[v._sprite][0]+n._sprite[v._sprite][1])/1e3-x,b=w*1e3/Math.abs(v._rate);(n._endTimers[g[y]]||!v._paused)&&(n._clearTimer(g[y]),n._endTimers[g[y]]=setTimeout(n._ended.bind(n,v),b)),n._emit("rate",v._id)}}else return v=n._soundById(g),v?v._rate:n._rate;return n},seek:function(){var n=this,l=arguments,h,g;if(l.length===0)n._sounds.length&&(g=n._sounds[0]._id);else if(l.length===1){var _=n._getSoundIds(),d=_.indexOf(l[0]);d>=0?g=parseInt(l[0],10):n._sounds.length&&(g=n._sounds[0]._id,h=parseFloat(l[0]))}else l.length===2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));if(typeof g>"u")return 0;if(typeof h=="number"&&(n._state!=="loaded"||n._playLock))return n._queue.push({event:"seek",action:function(){n.seek.apply(n,l)}}),n;var v=n._soundById(g);if(v)if(typeof h=="number"&&h>=0){var y=n.playing(g);y&&n.pause(g,!0),v._seek=h,v._ended=!1,n._clearTimer(g),!n._webAudio&&v._node&&!isNaN(v._node.duration)&&(v._node.currentTime=h);var x=function(){y&&n.play(g,!0),n._emit("seek",g)};if(y&&!n._webAudio){var w=function(){n._playLock?setTimeout(w,0):x()};setTimeout(w,0)}else x()}else if(n._webAudio){var b=n.playing(g)?t.ctx.currentTime-v._playStart:0,T=v._rateSeek?v._rateSeek-v._seek:0;return v._seek+(T+b*Math.abs(v._rate))}else return v._node.currentTime;return n},playing:function(n){var l=this;if(typeof n=="number"){var h=l._soundById(n);return h?!h._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,h=l._duration,g=l._soundById(n);return g&&(h=l._sprite[g._sprite][1]/1e3),h},state:function(){return this._state},unload:function(){for(var n=this,l=n._sounds,h=0;h<l.length;h++)l[h]._paused||n.stop(l[h]._id),n._webAudio||(n._clearSound(l[h]._node),l[h]._node.removeEventListener("error",l[h]._errorFn,!1),l[h]._node.removeEventListener(t._canPlayEvent,l[h]._loadFn,!1),l[h]._node.removeEventListener("ended",l[h]._endFn,!1),t._releaseHtml5Audio(l[h]._node)),delete l[h]._node,n._clearTimer(l[h]._id);var g=t._howls.indexOf(n);g>=0&&t._howls.splice(g,1);var _=!0;for(h=0;h<t._howls.length;h++)if(t._howls[h]._src===n._src||n._src.indexOf(t._howls[h]._src)>=0){_=!1;break}return a&&_&&delete a[n._src],t.noAudio=!1,n._state="unloaded",n._sounds=[],n=null,null},on:function(n,l,h,g){var _=this,d=_["_on"+n];return typeof l=="function"&&d.push(g?{id:h,fn:l,once:g}:{id:h,fn:l}),_},off:function(n,l,h){var g=this,_=g["_on"+n],d=0;if(typeof l=="number"&&(h=l,l=null),l||h)for(d=0;d<_.length;d++){var v=h===_[d].id;if(l===_[d].fn&&v||!l&&v){_.splice(d,1);break}}else if(n)g["_on"+n]=[];else{var y=Object.keys(g);for(d=0;d<y.length;d++)y[d].indexOf("_on")===0&&Array.isArray(g[y[d]])&&(g[y[d]]=[])}return g},once:function(n,l,h){var g=this;return g.on(n,l,h,1),g},_emit:function(n,l,h){for(var g=this,_=g["_on"+n],d=_.length-1;d>=0;d--)(!_[d].id||_[d].id===l||n==="load")&&(setTimeout((function(v){v.call(this,l,h)}).bind(g,_[d].fn),0),_[d].once&&g.off(n,_[d].fn,_[d].id));return g._loadQueue(n),g},_loadQueue:function(n){var l=this;if(l._queue.length>0){var h=l._queue[0];h.event===n&&(l._queue.shift(),l._loadQueue()),n||h.action()}return l},_ended:function(n){var l=this,h=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[h][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 _=(n._stop-n._start)*1e3/Math.abs(n._rate);l._endTimers[n._id]=setTimeout(l._ended.bind(l,n),_)}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 h=l._soundById(n);h&&h._node&&h._node.removeEventListener("ended",l._endTimers[n],!1)}delete l._endTimers[n]}return l},_soundById:function(n){for(var l=this,h=0;h<l._sounds.length;h++)if(n===l._sounds[h]._id)return l._sounds[h];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,h=0,g=0;if(!(n._sounds.length<l)){for(g=0;g<n._sounds.length;g++)n._sounds[g]._ended&&h++;for(g=n._sounds.length-1;g>=0;g--){if(h<=l)return;n._sounds[g]._ended&&(n._webAudio&&n._sounds[g]._node&&n._sounds[g]._node.disconnect(0),n._sounds.splice(g,1),h--)}}},_getSoundIds:function(n){var l=this;if(typeof n>"u"){for(var h=[],g=0;g<l._sounds.length;g++)h.push(l._sounds[g]._id);return h}else return[n]},_refreshBuffer:function(n){var l=this;return n._node.bufferSource=t.ctx.createBufferSource(),n._node.bufferSource.buffer=a[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,h=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),h))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,h=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(h,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=h*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 a={},o=function(n){var l=n._src;if(a[l]){n._duration=a[l].duration,p(n);return}if(/^data:[^;]+;base64,/.test(l)){for(var h=atob(l.split(",")[1]),g=new Uint8Array(h.length),_=0;_<h.length;++_)g[_]=h.charCodeAt(_);u(g.buffer,n)}else{var d=new XMLHttpRequest;d.open(n._xhr.method,l,!0),d.withCredentials=n._xhr.withCredentials,d.responseType="arraybuffer",n._xhr.headers&&Object.keys(n._xhr.headers).forEach(function(v){d.setRequestHeader(v,n._xhr.headers[v])}),d.onload=function(){var v=(d.status+"")[0];if(v!=="0"&&v!=="2"&&v!=="3"){n._emit("loaderror",null,"Failed loading audio file with status: "+d.status+".");return}u(d.response,n)},d.onerror=function(){n._webAudio&&(n._html5=!0,n._webAudio=!1,n._sounds=[],delete a[l],n.load())},c(d)}},c=function(n){try{n.send()}catch{n.onerror()}},u=function(n,l){var h=function(){l._emit("loaderror",null,"Decoding audio data failed.")},g=function(_){_&&l._sounds.length>0?(a[l._src]=_,p(l,_)):h()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(n).then(g).catch(h):t.ctx.decodeAudioData(n,g,h)},p=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())},m=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+)?/),h=l?parseInt(l[1],10):null;if(n&&h&&h<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()}};r.Howler=t,r.Howl=i,typeof _t<"u"?(_t.HowlerGlobal=e,_t.Howler=t,_t.Howl=i,_t.Sound=s):typeof window<"u"&&(window.HowlerGlobal=e,window.Howler=t,window.Howl=i,window.Sound=s)})();/*!
3696
+ */(function(n){(function(){var e=function(){this.init()};e.prototype={init:function(){var r=this||t;return r._counter=1e3,r._html5AudioPool=[],r.html5PoolSize=10,r._codecs={},r._howls=[],r._muted=!1,r._volume=1,r._canPlayEvent="canplaythrough",r._navigator=typeof window<"u"&&window.navigator?window.navigator:null,r.masterGain=null,r.noAudio=!1,r.usingWebAudio=!0,r.autoSuspend=!0,r.ctx=null,r.autoUnlock=!0,r._setup(),r},volume:function(r){var l=this||t;if(r=parseFloat(r),l.ctx||p(),typeof r<"u"&&r>=0&&r<=1){if(l._volume=r,l._muted)return l;l.usingWebAudio&&l.masterGain.gain.setValueAtTime(r,t.ctx.currentTime);for(var h=0;h<l._howls.length;h++)if(!l._howls[h]._webAudio)for(var g=l._howls[h]._getSoundIds(),_=0;_<g.length;_++){var m=l._howls[h]._soundById(g[_]);m&&m._node&&(m._node.volume=m._volume*r)}return l}return l._volume},mute:function(r){var l=this||t;l.ctx||p(),l._muted=r,l.usingWebAudio&&l.masterGain.gain.setValueAtTime(r?0:l._volume,t.ctx.currentTime);for(var h=0;h<l._howls.length;h++)if(!l._howls[h]._webAudio)for(var g=l._howls[h]._getSoundIds(),_=0;_<g.length;_++){var m=l._howls[h]._soundById(g[_]);m&&m._node&&(m._node.muted=r?!0:m._muted)}return l},stop:function(){for(var r=this||t,l=0;l<r._howls.length;l++)r._howls[l].stop();return r},unload:function(){for(var r=this||t,l=r._howls.length-1;l>=0;l--)r._howls[l].unload();return r.usingWebAudio&&r.ctx&&typeof r.ctx.close<"u"&&(r.ctx.close(),r.ctx=null,p()),r},codecs:function(r){return(this||t)._codecs[r.replace(/^x-/,"")]},_setup:function(){var r=this||t;if(r.state=r.ctx&&r.ctx.state||"suspended",r._autoSuspend(),!r.usingWebAudio)if(typeof Audio<"u")try{var l=new Audio;typeof l.oncanplaythrough>"u"&&(r._canPlayEvent="canplay")}catch{r.noAudio=!0}else r.noAudio=!0;try{var l=new Audio;l.muted&&(r.noAudio=!0)}catch{}return r.noAudio||r._setupCodecs(),r},_setupCodecs:function(){var r=this||t,l=null;try{l=typeof Audio<"u"?new Audio:null}catch{return r}if(!l||typeof l.canPlayType!="function")return r;var h=l.canPlayType("audio/mpeg;").replace(/^no$/,""),g=r._navigator?r._navigator.userAgent:"",_=g.match(/OPR\/(\d+)/g),m=_&&parseInt(_[0].split("/")[1],10)<33,v=g.indexOf("Safari")!==-1&&g.indexOf("Chrome")===-1,y=g.match(/Version\/(.*?) /),x=v&&y&&parseInt(y[1],10)<15;return r._codecs={mp3:!!(!m&&(h||l.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!h,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:!!(!x&&l.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&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$/,"")},r},_unlockAudio:function(){var r=this||t;if(!(r._audioUnlocked||!r.ctx)){r._audioUnlocked=!1,r.autoUnlock=!1,!r._mobileUnloaded&&r.ctx.sampleRate!==44100&&(r._mobileUnloaded=!0,r.unload()),r._scratchBuffer=r.ctx.createBuffer(1,1,22050);var l=function(h){for(;r._html5AudioPool.length<r.html5PoolSize;)try{var g=new Audio;g._unlocked=!0,r._releaseHtml5Audio(g)}catch{r.noAudio=!0;break}for(var _=0;_<r._howls.length;_++)if(!r._howls[_]._webAudio)for(var m=r._howls[_]._getSoundIds(),v=0;v<m.length;v++){var y=r._howls[_]._soundById(m[v]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}r._autoResume();var x=r.ctx.createBufferSource();x.buffer=r._scratchBuffer,x.connect(r.ctx.destination),typeof x.start>"u"?x.noteOn(0):x.start(0),typeof r.ctx.resume=="function"&&r.ctx.resume(),x.onended=function(){x.disconnect(0),r._audioUnlocked=!0,document.removeEventListener("touchstart",l,!0),document.removeEventListener("touchend",l,!0),document.removeEventListener("click",l,!0),document.removeEventListener("keydown",l,!0);for(var w=0;w<r._howls.length;w++)r._howls[w]._emit("unlock")}};return document.addEventListener("touchstart",l,!0),document.addEventListener("touchend",l,!0),document.addEventListener("click",l,!0),document.addEventListener("keydown",l,!0),r}},_obtainHtml5Audio:function(){var r=this||t;if(r._html5AudioPool.length)return r._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(r){var l=this||t;return r._unlocked&&l._html5AudioPool.push(r),l},_autoSuspend:function(){var r=this;if(!(!r.autoSuspend||!r.ctx||typeof r.ctx.suspend>"u"||!t.usingWebAudio)){for(var l=0;l<r._howls.length;l++)if(r._howls[l]._webAudio){for(var h=0;h<r._howls[l]._sounds.length;h++)if(!r._howls[l]._sounds[h]._paused)return r}return r._suspendTimer&&clearTimeout(r._suspendTimer),r._suspendTimer=setTimeout(function(){if(r.autoSuspend){r._suspendTimer=null,r.state="suspending";var g=function(){r.state="suspended",r._resumeAfterSuspend&&(delete r._resumeAfterSuspend,r._autoResume())};r.ctx.suspend().then(g,g)}},3e4),r}},_autoResume:function(){var r=this;if(!(!r.ctx||typeof r.ctx.resume>"u"||!t.usingWebAudio))return r.state==="running"&&r.ctx.state!=="interrupted"&&r._suspendTimer?(clearTimeout(r._suspendTimer),r._suspendTimer=null):r.state==="suspended"||r.state==="running"&&r.ctx.state==="interrupted"?(r.ctx.resume().then(function(){r.state="running";for(var l=0;l<r._howls.length;l++)r._howls[l]._emit("resume")}),r._suspendTimer&&(clearTimeout(r._suspendTimer),r._suspendTimer=null)):r.state==="suspending"&&(r._resumeAfterSuspend=!0),r}};var t=new e,i=function(r){var l=this;if(!r.src||r.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}l.init(r)};i.prototype={init:function(r){var l=this;return t.ctx||p(),l._autoplay=r.autoplay||!1,l._format=typeof r.format!="string"?r.format:[r.format],l._html5=r.html5||!1,l._muted=r.mute||!1,l._loop=r.loop||!1,l._pool=r.pool||5,l._preload=typeof r.preload=="boolean"||r.preload==="metadata"?r.preload:!0,l._rate=r.rate||1,l._sprite=r.sprite||{},l._src=typeof r.src!="string"?r.src:[r.src],l._volume=r.volume!==void 0?r.volume:1,l._xhr={method:r.xhr&&r.xhr.method?r.xhr.method:"GET",headers:r.xhr&&r.xhr.headers?r.xhr.headers:null,withCredentials:r.xhr&&r.xhr.withCredentials?r.xhr.withCredentials:!1},l._duration=0,l._state="unloaded",l._sounds=[],l._endTimers={},l._queue=[],l._playLock=!1,l._onend=r.onend?[{fn:r.onend}]:[],l._onfade=r.onfade?[{fn:r.onfade}]:[],l._onload=r.onload?[{fn:r.onload}]:[],l._onloaderror=r.onloaderror?[{fn:r.onloaderror}]:[],l._onplayerror=r.onplayerror?[{fn:r.onplayerror}]:[],l._onpause=r.onpause?[{fn:r.onpause}]:[],l._onplay=r.onplay?[{fn:r.onplay}]:[],l._onstop=r.onstop?[{fn:r.onstop}]:[],l._onmute=r.onmute?[{fn:r.onmute}]:[],l._onvolume=r.onvolume?[{fn:r.onvolume}]:[],l._onrate=r.onrate?[{fn:r.onrate}]:[],l._onseek=r.onseek?[{fn:r.onseek}]:[],l._onunlock=r.onunlock?[{fn:r.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 r=this,l=null;if(t.noAudio){r._emit("loaderror",null,"No audio support.");return}typeof r._src=="string"&&(r._src=[r._src]);for(var h=0;h<r._src.length;h++){var g,_;if(r._format&&r._format[h])g=r._format[h];else{if(_=r._src[h],typeof _!="string"){r._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}g=/^data:audio\/([^;,]+);/i.exec(_),g||(g=/\.([^.]+)$/.exec(_.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=r._src[h];break}}if(!l){r._emit("loaderror",null,"No codec support for selected audio sources.");return}return r._src=l,r._state="loading",window.location.protocol==="https:"&&l.slice(0,5)==="http:"&&(r._html5=!0,r._webAudio=!1),new s(r),r._webAudio&&o(r),r},play:function(r,l){var h=this,g=null;if(typeof r=="number")g=r,r=null;else{if(typeof r=="string"&&h._state==="loaded"&&!h._sprite[r])return null;if(typeof r>"u"&&(r="__default",!h._playLock)){for(var _=0,m=0;m<h._sounds.length;m++)h._sounds[m]._paused&&!h._sounds[m]._ended&&(_++,g=h._sounds[m]._id);_===1?r=null:g=null}}var v=g?h._soundById(g):h._inactiveSound();if(!v)return null;if(g&&!r&&(r=v._sprite||"__default"),h._state!=="loaded"){v._sprite=r,v._ended=!1;var y=v._id;return h._queue.push({event:"play",action:function(){h.play(y)}}),y}if(g&&!v._paused)return l||h._loadQueue("play"),v._id;h._webAudio&&t._autoResume();var x=Math.max(0,v._seek>0?v._seek:h._sprite[r][0]/1e3),w=Math.max(0,(h._sprite[r][0]+h._sprite[r][1])/1e3-x),b=w*1e3/Math.abs(v._rate),A=h._sprite[r][0]/1e3,S=(h._sprite[r][0]+h._sprite[r][1])/1e3;v._sprite=r,v._ended=!1;var I=function(){v._paused=!1,v._seek=x,v._start=A,v._stop=S,v._loop=!!(v._loop||h._sprite[r][2])};if(x>=S){h._ended(v);return}var M=v._node;if(h._webAudio){var P=function(){h._playLock=!1,I(),h._refreshBuffer(v);var D=v._muted||h._muted?0:v._volume;M.gain.setValueAtTime(D,t.ctx.currentTime),v._playStart=t.ctx.currentTime,typeof M.bufferSource.start>"u"?v._loop?M.bufferSource.noteGrainOn(0,x,86400):M.bufferSource.noteGrainOn(0,x,w):v._loop?M.bufferSource.start(0,x,86400):M.bufferSource.start(0,x,w),b!==1/0&&(h._endTimers[v._id]=setTimeout(h._ended.bind(h,v),b)),l||setTimeout(function(){h._emit("play",v._id),h._loadQueue()},0)};t.state==="running"&&t.ctx.state!=="interrupted"?P():(h._playLock=!0,h.once("resume",P),h._clearTimer(v._id))}else{var R=function(){M.currentTime=x,M.muted=v._muted||h._muted||t._muted||M.muted,M.volume=v._volume*t.volume(),M.playbackRate=v._rate;try{var D=M.play();if(D&&typeof Promise<"u"&&(D instanceof Promise||typeof D.then=="function")?(h._playLock=!0,I(),D.then(function(){h._playLock=!1,M._unlocked=!0,l?h._loadQueue():h._emit("play",v._id)}).catch(function(){h._playLock=!1,h._emit("playerror",v._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."),v._ended=!0,v._paused=!0})):l||(h._playLock=!1,I(),h._emit("play",v._id)),M.playbackRate=v._rate,M.paused){h._emit("playerror",v._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}r!=="__default"||v._loop?h._endTimers[v._id]=setTimeout(h._ended.bind(h,v),b):(h._endTimers[v._id]=function(){h._ended(v),M.removeEventListener("ended",h._endTimers[v._id],!1)},M.addEventListener("ended",h._endTimers[v._id],!1))}catch(E){h._emit("playerror",v._id,E)}};M.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(M.src=h._src,M.load());var T=window&&window.ejecta||!M.readyState&&t._navigator.isCocoonJS;if(M.readyState>=3||T)R();else{h._playLock=!0,h._state="loading";var C=function(){h._state="loaded",R(),M.removeEventListener(t._canPlayEvent,C,!1)};M.addEventListener(t._canPlayEvent,C,!1),h._clearTimer(v._id)}}return v._id},pause:function(r){var l=this;if(l._state!=="loaded"||l._playLock)return l._queue.push({event:"pause",action:function(){l.pause(r)}}),l;for(var h=l._getSoundIds(r),g=0;g<h.length;g++){l._clearTimer(h[g]);var _=l._soundById(h[g]);if(_&&!_._paused&&(_._seek=l.seek(h[g]),_._rateSeek=0,_._paused=!0,l._stopFade(h[g]),_._node))if(l._webAudio){if(!_._node.bufferSource)continue;typeof _._node.bufferSource.stop>"u"?_._node.bufferSource.noteOff(0):_._node.bufferSource.stop(0),l._cleanBuffer(_._node)}else(!isNaN(_._node.duration)||_._node.duration===1/0)&&_._node.pause();arguments[1]||l._emit("pause",_?_._id:null)}return l},stop:function(r,l){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"stop",action:function(){h.stop(r)}}),h;for(var g=h._getSoundIds(r),_=0;_<g.length;_++){h._clearTimer(g[_]);var m=h._soundById(g[_]);m&&(m._seek=m._start||0,m._rateSeek=0,m._paused=!0,m._ended=!0,h._stopFade(g[_]),m._node&&(h._webAudio?m._node.bufferSource&&(typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),h._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&&h._clearSound(m._node))),l||h._emit("stop",m._id))}return h},mute:function(r,l){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"mute",action:function(){h.mute(r,l)}}),h;if(typeof l>"u")if(typeof r=="boolean")h._muted=r;else return h._muted;for(var g=h._getSoundIds(l),_=0;_<g.length;_++){var m=h._soundById(g[_]);m&&(m._muted=r,m._interval&&h._stopFade(m._id),h._webAudio&&m._node?m._node.gain.setValueAtTime(r?0:m._volume,t.ctx.currentTime):m._node&&(m._node.muted=t._muted?!0:r),h._emit("mute",m._id))}return h},volume:function(){var r=this,l=arguments,h,g;if(l.length===0)return r._volume;if(l.length===1||l.length===2&&typeof l[1]>"u"){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):h=parseFloat(l[0])}else l.length>=2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));var v;if(typeof h<"u"&&h>=0&&h<=1){if(r._state!=="loaded"||r._playLock)return r._queue.push({event:"volume",action:function(){r.volume.apply(r,l)}}),r;typeof g>"u"&&(r._volume=h),g=r._getSoundIds(g);for(var y=0;y<g.length;y++)v=r._soundById(g[y]),v&&(v._volume=h,l[2]||r._stopFade(g[y]),r._webAudio&&v._node&&!v._muted?v._node.gain.setValueAtTime(h,t.ctx.currentTime):v._node&&!v._muted&&(v._node.volume=h*t.volume()),r._emit("volume",v._id))}else return v=g?r._soundById(g):r._sounds[0],v?v._volume:0;return r},fade:function(r,l,h,g){var _=this;if(_._state!=="loaded"||_._playLock)return _._queue.push({event:"fade",action:function(){_.fade(r,l,h,g)}}),_;r=Math.min(Math.max(0,parseFloat(r)),1),l=Math.min(Math.max(0,parseFloat(l)),1),h=parseFloat(h),_.volume(r,g);for(var m=_._getSoundIds(g),v=0;v<m.length;v++){var y=_._soundById(m[v]);if(y){if(g||_._stopFade(m[v]),_._webAudio&&!y._muted){var x=t.ctx.currentTime,w=x+h/1e3;y._volume=r,y._node.gain.setValueAtTime(r,x),y._node.gain.linearRampToValueAtTime(l,w)}_._startFadeInterval(y,r,l,h,m[v],typeof g>"u")}}return _},_startFadeInterval:function(r,l,h,g,_,m){var v=this,y=l,x=h-l,w=Math.abs(x/.01),b=Math.max(4,w>0?g/w:g),A=Date.now();r._fadeTo=h,r._interval=setInterval(function(){var S=(Date.now()-A)/g;A=Date.now(),y+=x*S,y=Math.round(y*100)/100,x<0?y=Math.max(h,y):y=Math.min(h,y),v._webAudio?r._volume=y:v.volume(y,r._id,!0),m&&(v._volume=y),(h<l&&y<=h||h>l&&y>=h)&&(clearInterval(r._interval),r._interval=null,r._fadeTo=null,v.volume(h,r._id),v._emit("fade",r._id))},b)},_stopFade:function(r){var l=this,h=l._soundById(r);return h&&h._interval&&(l._webAudio&&h._node.gain.cancelScheduledValues(t.ctx.currentTime),clearInterval(h._interval),h._interval=null,l.volume(h._fadeTo,r),h._fadeTo=null,l._emit("fade",r)),l},loop:function(){var r=this,l=arguments,h,g,_;if(l.length===0)return r._loop;if(l.length===1)if(typeof l[0]=="boolean")h=l[0],r._loop=h;else return _=r._soundById(parseInt(l[0],10)),_?_._loop:!1;else l.length===2&&(h=l[0],g=parseInt(l[1],10));for(var m=r._getSoundIds(g),v=0;v<m.length;v++)_=r._soundById(m[v]),_&&(_._loop=h,r._webAudio&&_._node&&_._node.bufferSource&&(_._node.bufferSource.loop=h,h&&(_._node.bufferSource.loopStart=_._start||0,_._node.bufferSource.loopEnd=_._stop,r.playing(m[v])&&(r.pause(m[v],!0),r.play(m[v],!0)))));return r},rate:function(){var r=this,l=arguments,h,g;if(l.length===0)g=r._sounds[0]._id;else if(l.length===1){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):h=parseFloat(l[0])}else l.length===2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));var v;if(typeof h=="number"){if(r._state!=="loaded"||r._playLock)return r._queue.push({event:"rate",action:function(){r.rate.apply(r,l)}}),r;typeof g>"u"&&(r._rate=h),g=r._getSoundIds(g);for(var y=0;y<g.length;y++)if(v=r._soundById(g[y]),v){r.playing(g[y])&&(v._rateSeek=r.seek(g[y]),v._playStart=r._webAudio?t.ctx.currentTime:v._playStart),v._rate=h,r._webAudio&&v._node&&v._node.bufferSource?v._node.bufferSource.playbackRate.setValueAtTime(h,t.ctx.currentTime):v._node&&(v._node.playbackRate=h);var x=r.seek(g[y]),w=(r._sprite[v._sprite][0]+r._sprite[v._sprite][1])/1e3-x,b=w*1e3/Math.abs(v._rate);(r._endTimers[g[y]]||!v._paused)&&(r._clearTimer(g[y]),r._endTimers[g[y]]=setTimeout(r._ended.bind(r,v),b)),r._emit("rate",v._id)}}else return v=r._soundById(g),v?v._rate:r._rate;return r},seek:function(){var r=this,l=arguments,h,g;if(l.length===0)r._sounds.length&&(g=r._sounds[0]._id);else if(l.length===1){var _=r._getSoundIds(),m=_.indexOf(l[0]);m>=0?g=parseInt(l[0],10):r._sounds.length&&(g=r._sounds[0]._id,h=parseFloat(l[0]))}else l.length===2&&(h=parseFloat(l[0]),g=parseInt(l[1],10));if(typeof g>"u")return 0;if(typeof h=="number"&&(r._state!=="loaded"||r._playLock))return r._queue.push({event:"seek",action:function(){r.seek.apply(r,l)}}),r;var v=r._soundById(g);if(v)if(typeof h=="number"&&h>=0){var y=r.playing(g);y&&r.pause(g,!0),v._seek=h,v._ended=!1,r._clearTimer(g),!r._webAudio&&v._node&&!isNaN(v._node.duration)&&(v._node.currentTime=h);var x=function(){y&&r.play(g,!0),r._emit("seek",g)};if(y&&!r._webAudio){var w=function(){r._playLock?setTimeout(w,0):x()};setTimeout(w,0)}else x()}else if(r._webAudio){var b=r.playing(g)?t.ctx.currentTime-v._playStart:0,A=v._rateSeek?v._rateSeek-v._seek:0;return v._seek+(A+b*Math.abs(v._rate))}else return v._node.currentTime;return r},playing:function(r){var l=this;if(typeof r=="number"){var h=l._soundById(r);return h?!h._paused:!1}for(var g=0;g<l._sounds.length;g++)if(!l._sounds[g]._paused)return!0;return!1},duration:function(r){var l=this,h=l._duration,g=l._soundById(r);return g&&(h=l._sprite[g._sprite][1]/1e3),h},state:function(){return this._state},unload:function(){for(var r=this,l=r._sounds,h=0;h<l.length;h++)l[h]._paused||r.stop(l[h]._id),r._webAudio||(r._clearSound(l[h]._node),l[h]._node.removeEventListener("error",l[h]._errorFn,!1),l[h]._node.removeEventListener(t._canPlayEvent,l[h]._loadFn,!1),l[h]._node.removeEventListener("ended",l[h]._endFn,!1),t._releaseHtml5Audio(l[h]._node)),delete l[h]._node,r._clearTimer(l[h]._id);var g=t._howls.indexOf(r);g>=0&&t._howls.splice(g,1);var _=!0;for(h=0;h<t._howls.length;h++)if(t._howls[h]._src===r._src||r._src.indexOf(t._howls[h]._src)>=0){_=!1;break}return a&&_&&delete a[r._src],t.noAudio=!1,r._state="unloaded",r._sounds=[],r=null,null},on:function(r,l,h,g){var _=this,m=_["_on"+r];return typeof l=="function"&&m.push(g?{id:h,fn:l,once:g}:{id:h,fn:l}),_},off:function(r,l,h){var g=this,_=g["_on"+r],m=0;if(typeof l=="number"&&(h=l,l=null),l||h)for(m=0;m<_.length;m++){var v=h===_[m].id;if(l===_[m].fn&&v||!l&&v){_.splice(m,1);break}}else if(r)g["_on"+r]=[];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(r,l,h){var g=this;return g.on(r,l,h,1),g},_emit:function(r,l,h){for(var g=this,_=g["_on"+r],m=_.length-1;m>=0;m--)(!_[m].id||_[m].id===l||r==="load")&&(setTimeout((function(v){v.call(this,l,h)}).bind(g,_[m].fn),0),_[m].once&&g.off(r,_[m].fn,_[m].id));return g._loadQueue(r),g},_loadQueue:function(r){var l=this;if(l._queue.length>0){var h=l._queue[0];h.event===r&&(l._queue.shift(),l._loadQueue()),r||h.action()}return l},_ended:function(r){var l=this,h=r._sprite;if(!l._webAudio&&r._node&&!r._node.paused&&!r._node.ended&&r._node.currentTime<r._stop)return setTimeout(l._ended.bind(l,r),100),l;var g=!!(r._loop||l._sprite[h][2]);if(l._emit("end",r._id),!l._webAudio&&g&&l.stop(r._id,!0).play(r._id),l._webAudio&&g){l._emit("play",r._id),r._seek=r._start||0,r._rateSeek=0,r._playStart=t.ctx.currentTime;var _=(r._stop-r._start)*1e3/Math.abs(r._rate);l._endTimers[r._id]=setTimeout(l._ended.bind(l,r),_)}return l._webAudio&&!g&&(r._paused=!0,r._ended=!0,r._seek=r._start||0,r._rateSeek=0,l._clearTimer(r._id),l._cleanBuffer(r._node),t._autoSuspend()),!l._webAudio&&!g&&l.stop(r._id,!0),l},_clearTimer:function(r){var l=this;if(l._endTimers[r]){if(typeof l._endTimers[r]!="function")clearTimeout(l._endTimers[r]);else{var h=l._soundById(r);h&&h._node&&h._node.removeEventListener("ended",l._endTimers[r],!1)}delete l._endTimers[r]}return l},_soundById:function(r){for(var l=this,h=0;h<l._sounds.length;h++)if(r===l._sounds[h]._id)return l._sounds[h];return null},_inactiveSound:function(){var r=this;r._drain();for(var l=0;l<r._sounds.length;l++)if(r._sounds[l]._ended)return r._sounds[l].reset();return new s(r)},_drain:function(){var r=this,l=r._pool,h=0,g=0;if(!(r._sounds.length<l)){for(g=0;g<r._sounds.length;g++)r._sounds[g]._ended&&h++;for(g=r._sounds.length-1;g>=0;g--){if(h<=l)return;r._sounds[g]._ended&&(r._webAudio&&r._sounds[g]._node&&r._sounds[g]._node.disconnect(0),r._sounds.splice(g,1),h--)}}},_getSoundIds:function(r){var l=this;if(typeof r>"u"){for(var h=[],g=0;g<l._sounds.length;g++)h.push(l._sounds[g]._id);return h}else return[r]},_refreshBuffer:function(r){var l=this;return r._node.bufferSource=t.ctx.createBufferSource(),r._node.bufferSource.buffer=a[l._src],r._panner?r._node.bufferSource.connect(r._panner):r._node.bufferSource.connect(r._node),r._node.bufferSource.loop=r._loop,r._loop&&(r._node.bufferSource.loopStart=r._start||0,r._node.bufferSource.loopEnd=r._stop||0),r._node.bufferSource.playbackRate.setValueAtTime(r._rate,t.ctx.currentTime),l},_cleanBuffer:function(r){var l=this,h=t._navigator&&t._navigator.vendor.indexOf("Apple")>=0;if(!r.bufferSource)return l;if(t._scratchBuffer&&r.bufferSource&&(r.bufferSource.onended=null,r.bufferSource.disconnect(0),h))try{r.bufferSource.buffer=t._scratchBuffer}catch{}return r.bufferSource=null,l},_clearSound:function(r){var l=/MSIE |Trident\//.test(t._navigator&&t._navigator.userAgent);l||(r.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var s=function(r){this._parent=r,this.init()};s.prototype={init:function(){var r=this,l=r._parent;return r._muted=l._muted,r._loop=l._loop,r._volume=l._volume,r._rate=l._rate,r._seek=0,r._paused=!0,r._ended=!0,r._sprite="__default",r._id=++t._counter,l._sounds.push(r),r.create(),r},create:function(){var r=this,l=r._parent,h=t._muted||r._muted||r._parent._muted?0:r._volume;return l._webAudio?(r._node=typeof t.ctx.createGain>"u"?t.ctx.createGainNode():t.ctx.createGain(),r._node.gain.setValueAtTime(h,t.ctx.currentTime),r._node.paused=!0,r._node.connect(t.masterGain)):t.noAudio||(r._node=t._obtainHtml5Audio(),r._errorFn=r._errorListener.bind(r),r._node.addEventListener("error",r._errorFn,!1),r._loadFn=r._loadListener.bind(r),r._node.addEventListener(t._canPlayEvent,r._loadFn,!1),r._endFn=r._endListener.bind(r),r._node.addEventListener("ended",r._endFn,!1),r._node.src=l._src,r._node.preload=l._preload===!0?"auto":l._preload,r._node.volume=h*t.volume(),r._node.load()),r},reset:function(){var r=this,l=r._parent;return r._muted=l._muted,r._loop=l._loop,r._volume=l._volume,r._rate=l._rate,r._seek=0,r._rateSeek=0,r._paused=!0,r._ended=!0,r._sprite="__default",r._id=++t._counter,r},_errorListener:function(){var r=this;r._parent._emit("loaderror",r._id,r._node.error?r._node.error.code:0),r._node.removeEventListener("error",r._errorFn,!1)},_loadListener:function(){var r=this,l=r._parent;l._duration=Math.ceil(r._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()),r._node.removeEventListener(t._canPlayEvent,r._loadFn,!1)},_endListener:function(){var r=this,l=r._parent;l._duration===1/0&&(l._duration=Math.ceil(r._node.duration*10)/10,l._sprite.__default[1]===1/0&&(l._sprite.__default[1]=l._duration*1e3),l._ended(r)),r._node.removeEventListener("ended",r._endFn,!1)}};var a={},o=function(r){var l=r._src;if(a[l]){r._duration=a[l].duration,f(r);return}if(/^data:[^;]+;base64,/.test(l)){for(var h=atob(l.split(",")[1]),g=new Uint8Array(h.length),_=0;_<h.length;++_)g[_]=h.charCodeAt(_);u(g.buffer,r)}else{var m=new XMLHttpRequest;m.open(r._xhr.method,l,!0),m.withCredentials=r._xhr.withCredentials,m.responseType="arraybuffer",r._xhr.headers&&Object.keys(r._xhr.headers).forEach(function(v){m.setRequestHeader(v,r._xhr.headers[v])}),m.onload=function(){var v=(m.status+"")[0];if(v!=="0"&&v!=="2"&&v!=="3"){r._emit("loaderror",null,"Failed loading audio file with status: "+m.status+".");return}u(m.response,r)},m.onerror=function(){r._webAudio&&(r._html5=!0,r._webAudio=!1,r._sounds=[],delete a[l],r.load())},c(m)}},c=function(r){try{r.send()}catch{r.onerror()}},u=function(r,l){var h=function(){l._emit("loaderror",null,"Decoding audio data failed.")},g=function(_){_&&l._sounds.length>0?(a[l._src]=_,f(l,_)):h()};typeof Promise<"u"&&t.ctx.decodeAudioData.length===1?t.ctx.decodeAudioData(r).then(g).catch(h):t.ctx.decodeAudioData(r,g,h)},f=function(r,l){l&&!r._duration&&(r._duration=l.duration),Object.keys(r._sprite).length===0&&(r._sprite={__default:[0,r._duration*1e3]}),r._state!=="loaded"&&(r._state="loaded",r._emit("load"),r._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 r=/iP(hone|od|ad)/.test(t._navigator&&t._navigator.platform),l=t._navigator&&t._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),h=l?parseInt(l[1],10):null;if(r&&h&&h<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()}};n.Howler=t,n.Howl=i,typeof vt<"u"?(vt.HowlerGlobal=e,vt.Howler=t,vt.Howl=i,vt.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,23 +3703,23 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};Z=new WeakMap,ve=new WeakMap,di=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 a=this;if(!a.ctx||!a.ctx.listener)return a;if(i=typeof i!="number"?a._pos[1]:i,s=typeof s!="number"?a._pos[2]:s,typeof t=="number")a._pos=[t,i,s],typeof a.ctx.listener.positionX<"u"?(a.ctx.listener.positionX.setTargetAtTime(a._pos[0],Howler.ctx.currentTime,.1),a.ctx.listener.positionY.setTargetAtTime(a._pos[1],Howler.ctx.currentTime,.1),a.ctx.listener.positionZ.setTargetAtTime(a._pos[2],Howler.ctx.currentTime,.1)):a.ctx.listener.setPosition(a._pos[0],a._pos[1],a._pos[2]);else return a._pos;return a},HowlerGlobal.prototype.orientation=function(t,i,s,a,o,c){var u=this;if(!u.ctx||!u.ctx.listener)return u;var p=u._orientation;if(i=typeof i!="number"?p[1]:i,s=typeof s!="number"?p[2]:s,a=typeof a!="number"?p[3]:a,o=typeof o!="number"?p[4]:o,c=typeof c!="number"?p[5]:c,typeof t=="number")u._orientation=[t,i,s,a,o,c],typeof u.ctx.listener.forwardX<"u"?(u.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),u.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),u.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),u.ctx.listener.upX.setTargetAtTime(a,Howler.ctx.currentTime,.1),u.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),u.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):u.ctx.listener.setOrientation(t,i,s,a,o,c);else return p;return u},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 a=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 u=s._soundById(o[c]);if(u)if(typeof t=="number")u._stereo=t,u._pos=[t,0,0],u._node&&(u._pannerAttr.panningModel="equalpower",(!u._panner||!u._panner.pan)&&e(u,a),a==="spatial"?typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):u._panner.setPosition(t,0,0):u._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",u._id);else return u._stereo}return s},Howl.prototype.pos=function(t,i,s,a){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,a)}}),o;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof a>"u")if(typeof t=="number")o._pos=[t,i,s];else return o._pos;for(var c=o._getSoundIds(a),u=0;u<c.length;u++){var p=o._soundById(c[u]);if(p)if(typeof t=="number")p._pos=[t,i,s],p._node&&((!p._panner||p._panner.pan)&&e(p,"spatial"),typeof p._panner.positionX<"u"?(p._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),p._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),p._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):p._panner.setPosition(t,i,s)),o._emit("pos",p._id);else return p._pos}return o},Howl.prototype.orientation=function(t,i,s,a){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,a)}}),o;if(i=typeof i!="number"?o._orientation[1]:i,s=typeof s!="number"?o._orientation[2]:s,typeof a>"u")if(typeof t=="number")o._orientation=[t,i,s];else return o._orientation;for(var c=o._getSoundIds(a),u=0;u<c.length;u++){var p=o._soundById(c[u]);if(p)if(typeof t=="number")p._orientation=[t,i,s],p._node&&(p._panner||(p._pos||(p._pos=o._pos||[0,0,-.5]),e(p,"spatial")),typeof p._panner.orientationX<"u"?(p._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),p._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),p._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):p._panner.setOrientation(t,i,s)),o._emit("orientation",p._id);else return p._orientation}return o},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,a,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 a>"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],a=parseInt(i[1],10));for(var c=t._getSoundIds(a),u=0;u<c.length;u++)if(o=t._soundById(c[u]),o){var p=o._pannerAttr;p={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:p.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:p.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:p.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:p.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:p.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:p.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:p.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:p.panningModel};var m=o._panner;m||(o._pos||(o._pos=t._pos||[0,0,-.5]),e(o,"spatial"),m=o._panner),m.coneInnerAngle=p.coneInnerAngle,m.coneOuterAngle=p.coneOuterAngle,m.coneOuterGain=p.coneOuterGain,m.distanceModel=p.distanceModel,m.maxDistance=p.maxDistance,m.refDistance=p.refDistance,m.rolloffFactor=p.rolloffFactor,m.panningModel=p.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)}})()})(Gr);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 Ka=class{constructor(){this.sound=new Gr.Howl({src:[Xa]})}play(){this.sound.play()}};const ye=r=>{var e,t;if(typeof r.destroy=="function"){r.destroy();return}for(;r.children.length>0;)ye(r.children[0]),(e=r.children[0])==null||e.removeFromParent();if(r instanceof f.Mesh)try{(t=r.geometry)==null||t.dispose()}catch{}};function Ja(r){return new f.Vector3(r[0],r[1],r[2])}function el(){let r=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(r=4,e=1/window.devicePixelRatio),{tiles:r,renderScale:e}}function tl(r){let e=!1,t=!1,i=!1,s=1/0,a=1/0,o=1/0,c=-1/0,u=-1/0,p=-1/0,m=0,n=0;return r.traverse(h=>{if(h.isMesh&&h.geometry){const g=h;if(g.userData.ignoreSize||g.material.userData.isLOGO)return;g.geometry.computeBoundingBox();let _=g.geometry.attributes.position;const d=g.geometry.morphAttributes.position;let v=g.morphTargetInfluences;const y=Object.keys(g.morphTargetDictionary||{});y.includes("width")&&(t=!0),y.includes("length")&&(e=!0),y.includes("height")&&(i=!0);for(let x=0;x<_.count;x++){let w=_.getX(x),b=_.getY(x),T=_.getZ(x);n=Math.max(b,n),d&&v&&d.forEach((P,C)=>{const R=v&&v[C]||0;w+=P.getX(x)*R,b+=P.getY(x)*R,T+=P.getZ(x)*R}),w<s&&(s=w),b<a&&(a=b),T<o&&(o=T),w>c&&(c=w),b>u&&(u=b),T>p&&(p=T);const S=Math.sqrt(w*w+b*b);S>m&&(m=S)}}}),{box:new f.Box3(new f.Vector3(s,a,o),new f.Vector3(c,u,p)),maxRadius:m,height:n,hasWidth:t,hasLength:e,hasHeight:i}}function il(r,e,t=null){let i=0;return function(){let s=t||this,a=arguments;clearTimeout(i),i=window.setTimeout(function(){r.apply(s,a)},e)}}class sl{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const Js=r=>{var i;let e=0,t=0;if(r.geometry){r.geometry.computeBoundingBox();const s=new f.Vector3;(i=r.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 gs(){var e;if(typeof navigator>"u")return!1;if(rl())return!0;const r=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(r)}function rl(){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 qr=new Mn.GLTFExporter,ct=new Tn.GLTFLoader,gi=new Sn.DRACOLoader;let rt="./draco/";try{rt=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:at&&at.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{rt="./draco/"}typeof window<"u"&&window.dracoPath&&(rt=window.dracoPath);gi.setDecoderConfig({type:"wasm"});gi.setDecoderPath(rt.endsWith("/")?rt:`${rt}/`);gi.preload();ct.setDRACOLoader(gi);const nl=new Cn.DRACOExporter,er=[115,103,108,98];function ol(r,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),a=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 u=new Uint8Array(r),p=a.length+o.length+c.length+s.length+u.length,m=new Uint8Array(p);let n=0;return m.set(a,n),n+=a.length,m.set(o,n),n+=o.length,m.set(c,n),n+=c.length,m.set(s,n),n+=s.length,m.set(u,n),m.buffer}function al(r){const e=new Uint8Array(r.slice(0,4));let t=!0;for(let n=0;n<er.length;n++)if(e[n]!==er[n]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(r,4,2).getUint16(0,!1),o=new DataView(r,6,4).getUint32(0,!1),c=new Uint8Array(r.slice(10,10+o)),u=new TextDecoder().decode(c),p=JSON.parse(u),m=r.slice(10+o);return{version:s,jsonDescription:p,glbContent:m}}class ui{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 a=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=a.parse(o);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const u=$i(c.glbContent,"model/gltf-binary"),p=await ct.loadAsync(u);URL.revokeObjectURL(u),c.glbContent=void 0,c.glb=p.scene,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 a=$i(s.glbContent,"model/gltf-binary");console.log(a);const o=await ct.loadAsync(a);return URL.revokeObjectURL(a),s.glbContent=void 0,s.glb=o.scene,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return al(e)}clear(){[...this.cache.values()]}}const ll=`*{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:2px 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}`,cl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",tr={name:"",isMobile:!1},ul={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function yt(r){return r==null?"":String(r).replace(/[&<>"']/g,e=>ul[e])}function ir(...r){return r.filter(Boolean).join(" ")}class jr 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={...tr,...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={...tr,...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){const t=!!e;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){const t=!!e;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){const t=Number.isFinite(e)?Number(e):12;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 m;if(!this.shadowRoot)return;const e=ir("slot-item-container",this._props.isMobile&&"is-mobile"),t=ir("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=yt(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)),a=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 a=this;if(!a.ctx||!a.ctx.listener)return a;if(i=typeof i!="number"?a._pos[1]:i,s=typeof s!="number"?a._pos[2]:s,typeof t=="number")a._pos=[t,i,s],typeof a.ctx.listener.positionX<"u"?(a.ctx.listener.positionX.setTargetAtTime(a._pos[0],Howler.ctx.currentTime,.1),a.ctx.listener.positionY.setTargetAtTime(a._pos[1],Howler.ctx.currentTime,.1),a.ctx.listener.positionZ.setTargetAtTime(a._pos[2],Howler.ctx.currentTime,.1)):a.ctx.listener.setPosition(a._pos[0],a._pos[1],a._pos[2]);else return a._pos;return a},HowlerGlobal.prototype.orientation=function(t,i,s,a,o,c){var u=this;if(!u.ctx||!u.ctx.listener)return u;var f=u._orientation;if(i=typeof i!="number"?f[1]:i,s=typeof s!="number"?f[2]:s,a=typeof a!="number"?f[3]:a,o=typeof o!="number"?f[4]:o,c=typeof c!="number"?f[5]:c,typeof t=="number")u._orientation=[t,i,s,a,o,c],typeof u.ctx.listener.forwardX<"u"?(u.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),u.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),u.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),u.ctx.listener.upX.setTargetAtTime(a,Howler.ctx.currentTime,.1),u.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),u.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):u.ctx.listener.setOrientation(t,i,s,a,o,c);else return f;return u},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 a=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 u=s._soundById(o[c]);if(u)if(typeof t=="number")u._stereo=t,u._pos=[t,0,0],u._node&&(u._pannerAttr.panningModel="equalpower",(!u._panner||!u._panner.pan)&&e(u,a),a==="spatial"?typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):u._panner.setPosition(t,0,0):u._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",u._id);else return u._stereo}return s},Howl.prototype.pos=function(t,i,s,a){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,a)}}),o;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof a>"u")if(typeof t=="number")o._pos=[t,i,s];else return o._pos;for(var c=o._getSoundIds(a),u=0;u<c.length;u++){var f=o._soundById(c[u]);if(f)if(typeof t=="number")f._pos=[t,i,s],f._node&&((!f._panner||f._panner.pan)&&e(f,"spatial"),typeof f._panner.positionX<"u"?(f._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),f._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),f._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):f._panner.setPosition(t,i,s)),o._emit("pos",f._id);else return f._pos}return o},Howl.prototype.orientation=function(t,i,s,a){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,a)}}),o;if(i=typeof i!="number"?o._orientation[1]:i,s=typeof s!="number"?o._orientation[2]:s,typeof a>"u")if(typeof t=="number")o._orientation=[t,i,s];else return o._orientation;for(var c=o._getSoundIds(a),u=0;u<c.length;u++){var f=o._soundById(c[u]);if(f)if(typeof t=="number")f._orientation=[t,i,s],f._node&&(f._panner||(f._pos||(f._pos=o._pos||[0,0,-.5]),e(f,"spatial")),typeof f._panner.orientationX<"u"?(f._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),f._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),f._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):f._panner.setOrientation(t,i,s)),o._emit("orientation",f._id);else return f._orientation}return o},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,a,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 a>"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],a=parseInt(i[1],10));for(var c=t._getSoundIds(a),u=0;u<c.length;u++)if(o=t._soundById(c[u]),o){var f=o._pannerAttr;f={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:f.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:f.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:f.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:f.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:f.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:f.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:f.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:f.panningModel};var p=o._panner;p||(o._pos||(o._pos=t._pos||[0,0,-.5]),e(o,"spatial"),p=o._panner),p.coneInnerAngle=f.coneInnerAngle,p.coneOuterAngle=f.coneOuterAngle,p.coneOuterGain=f.coneOuterGain,p.distanceModel=f.distanceModel,p.maxDistance=f.maxDistance,p.refDistance=f.refDistance,p.rolloffFactor=f.rolloffFactor,p.panningModel=f.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)}})()})(Rr);const za="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 Va=class{constructor(){this.sound=new Rr.Howl({src:[za]})}play(){this.sound.play()}};const xe=n=>{var e,t;if(typeof n.destroy=="function"){n.destroy();return}for(;n.children.length>0;)xe(n.children[0]),(e=n.children[0])==null||e.removeFromParent();if(n instanceof d.Mesh)try{(t=n.geometry)==null||t.dispose()}catch{}};function Ua(n){return new d.Vector3(n[0],n[1],n[2])}function Ha(){let n=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(n=4,e=1/window.devicePixelRatio),{tiles:n,renderScale:e}}function Na(n){let e=!1,t=!1,i=!1,s=1/0,a=1/0,o=1/0,c=-1/0,u=-1/0,f=-1/0,p=0,r=0;return n.traverse(h=>{if(h.isMesh&&h.geometry){const g=h;if(g.userData.ignoreSize||g.material.userData.isLOGO)return;g.geometry.computeBoundingBox();let _=g.geometry.attributes.position;const m=g.geometry.morphAttributes.position;let v=g.morphTargetInfluences;const y=Object.keys(g.morphTargetDictionary||{});y.includes("width")&&(t=!0),y.includes("length")&&(e=!0),y.includes("height")&&(i=!0);for(let x=0;x<_.count;x++){let w=_.getX(x),b=_.getY(x),A=_.getZ(x);r=Math.max(b,r),m&&v&&m.forEach((I,M)=>{const P=v&&v[M]||0;w+=I.getX(x)*P,b+=I.getY(x)*P,A+=I.getZ(x)*P}),w<s&&(s=w),b<a&&(a=b),A<o&&(o=A),w>c&&(c=w),b>u&&(u=b),A>f&&(f=A);const S=Math.sqrt(w*w+b*b);S>p&&(p=S)}}}),{box:new d.Box3(new d.Vector3(s,a,o),new d.Vector3(c,u,f)),maxRadius:p,height:r,hasWidth:t,hasLength:e,hasHeight:i}}function Wa(n,e,t=null){let i=0;return function(){let s=t||this,a=arguments;clearTimeout(i),i=window.setTimeout(function(){n.apply(s,a)},e)}}class Ga{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const Ws=n=>{var i;let e=0,t=0;if(n.geometry){n.geometry.computeBoundingBox();const s=new d.Vector3;(i=n.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(qa())return!0;const n=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(n)}function qa(){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 Pr=new hn.GLTFExporter,lt=new ln.GLTFLoader,ui=new cn.DRACOLoader;let st="./draco/";try{st=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:ot&&ot.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{st="./draco/"}typeof window<"u"&&window.dracoPath&&(st=window.dracoPath);ui.setDecoderConfig({type:"wasm"});ui.setDecoderPath(st.endsWith("/")?st:`${st}/`);ui.preload();lt.setDRACOLoader(ui);const ja=new un.DRACOExporter,Gs=[115,103,108,98];function Ya(n,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),a=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 u=new Uint8Array(n),f=a.length+o.length+c.length+s.length+u.length,p=new Uint8Array(f);let r=0;return p.set(a,r),r+=a.length,p.set(o,r),r+=o.length,p.set(c,r),r+=c.length,p.set(s,r),r+=s.length,p.set(u,r),p.buffer}function Qa(n){const e=new Uint8Array(n.slice(0,4));let t=!0;for(let r=0;r<Gs.length;r++)if(e[r]!==Gs[r]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(n,4,2).getUint16(0,!1),o=new DataView(n,6,4).getUint32(0,!1),c=new Uint8Array(n.slice(10,10+o)),u=new TextDecoder().decode(c),f=JSON.parse(u),p=n.slice(10+o);return{version:s,jsonDescription:f,glbContent:p}}class ni{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 a=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=a.parse(o);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const u=Hi(c.glbContent,"model/gltf-binary"),f=await lt.loadAsync(u);URL.revokeObjectURL(u),c.glbContent=void 0,c.glb=f.scene,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 a=Hi(s.glbContent,"model/gltf-binary");console.log(a);const o=await lt.loadAsync(a);return URL.revokeObjectURL(a),s.glbContent=void 0,s.glb=o.scene,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return Qa(e)}clear(){[...this.cache.values()]}}const Za=`*{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:2px 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}`,Xa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",qs={name:"",isMobile:!1},Ka={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function _t(n){return n==null?"":String(n).replace(/[&<>"']/g,e=>Ka[e])}function js(...n){return n.filter(Boolean).join(" ")}class Dr 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={...qs,...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={...qs,...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){const t=!!e;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){const t=!!e;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){const t=Number.isFinite(e)?Number(e):12;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=js("slot-item-container",this._props.isMobile&&"is-mobile"),t=js("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(r=>{const l=_t(r);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(r=>!this._functions.includes(r)),a=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
- ${s.map(n=>{const l=yt(n);return`<div class="function"><span>${l}</span><i class="btn btn-add" data-action="add-function" data-function="${l}">+</i></div>`}).join("")}
3709
+ ${s.map(r=>{const l=_t(r);return`<div class="function"><span>${l}</span><i class="btn btn-add" data-action="add-function" data-function="${l}">+</i></div>`}).join("")}
3710
3710
  </div>
3711
- </div>`:"",c=this._deviceLogo?`<img class="device-logo" src="${yt(this._deviceLogo)}" alt="device logo">`:"",u=yt(((m=this._slot)==null?void 0:m.name)??this._props.name??""),p=yt(this._deviceName||"待安装");this.shadowRoot.innerHTML=`
3712
- <style>${ll}</style>
3711
+ </div>`:"",c=this._deviceLogo?`<img class="device-logo" src="${_t(this._deviceLogo)}" alt="device logo">`:"",u=_t(((p=this._slot)==null?void 0:p.name)??this._props.name??""),f=_t(this._deviceName||"待安装");this.shadowRoot.innerHTML=`
3712
+ <style>${Za}</style>
3713
3713
  <div class="${e}">
3714
3714
  <div class="${t}" style="width:${this._size}px;height:${this._size}px"></div>
3715
3715
  <div class="info">
3716
- <img alt="" src="${cl}">
3716
+ <img alt="" src="${Xa}">
3717
3717
  <div class="name">
3718
3718
  <div class="name-wrapper">${u}</div>
3719
3719
  <div class="functions-wrapper">
3720
3720
  <div class="device-name ${this._deviceName?"":"empty"}">
3721
3721
  ${c}
3722
- <span>${p}</span>
3722
+ <span>${f}</span>
3723
3723
  <i class="btn btn-close" data-action="remove-device"></i>
3724
3724
  </div>
3725
3725
  ${a}
@@ -3728,97 +3728,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};Z=new WeakMap,ve=new WeakMap,di=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 a=i.getAttribute("data-function");a&&this.dispatchEvent(new CustomEvent("function-removed",{detail:a}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const a=i.getAttribute("data-function");a&&(this.dispatchEvent(new CustomEvent("function-added",{detail:a})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",jr);const q={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 Zi extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new ut,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._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new jr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(q.ON_DEVICE_DELETED)}}),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(q.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 a;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(a=i.dataTransfer)==null?void 0:a.getData("application/json");if(s){const o=JSON.parse(s);try{await this.install(o),this._emitter.emit(q.ON_DROP,this)}catch(c){this._emitter.emit(q.ON_DROP_ERROR,c)}}else this._emitter.emit(q.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){var i;if(this.props.follows.has(e)){const s=this.props.follows.get(e);if(s){let a="x";["height","mast"].includes(e)?a="y":["width","liftOuterWidth"].includes(e)&&(a="z");const o=((i=this.props.slot)==null?void 0:i.position[a])>0?1:-1;this._wrapper.position[a]=(t-s.origin)*s.scale*o}}}async loadGlb(e){const i=await new ui({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new ui({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(a=>{a.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){if(!this._loading){this._loading=!0;try{const t=await this.loadGlb(e.url);if(!t)throw new Error(`Fail to load device from: ${e.url}`);if(t.traverse(i=>{i.userData.isDevice=!0}),this.isMirror&&t.scale.set(1,1,-1),e.bracketUrl){const i=await this.loadGlb(e.bracketUrl);if(i)this.clearSlot(),this._emitter.emit(q.ON_DEVICE_REPLACED),i.traverse(s=>{s.name.startsWith("Slot")&&this._bracketSlots.push(s),s.userData.isBracket=!0}),this._slotContainer.add(i);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(s=>{s.add(t)})}else this.clearSlot(),this._emitter.emit(q.ON_DEVICE_REPLACED),this._slotContainer.add(t);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1)}catch(t){throw t}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(q.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(q.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._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),ye(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}enable(){this._slotUI.disable=!1}disable(){this._slotUI.disable=!0}hide(){this._slotUI.hide=!0}show(){this.isMirror||(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){e&&this._emitter.emit(q.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(q.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(q.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(q.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.clearSlot(),this._emitter.removeAllListeners(),ye(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])),a=e.mousePos.distanceTo(s);let o=this.props.isMobile?12:18,c=38,u=30;if(this._canInstall&&(o=34,c=60,u=60),a<u){let p=(u-a)*1+o;a<20&&(p=c),p>c&&(p=c),this._slotUI.setSize(p)}else this._slotUI.setSize(o)}clone(e){return new f.Group}}/**
3732
- * @license
3733
- * Copyright 2017 Google LLC
3734
- * SPDX-License-Identifier: BSD-3-Clause
3735
- */const hl=r=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(r,e)}):customElements.define(r,e)};/**
3736
- * @license
3737
- * Copyright 2019 Google LLC
3738
- * SPDX-License-Identifier: BSD-3-Clause
3739
- */const ri=globalThis,vs=ri.ShadowRoot&&(ri.ShadyCSS===void 0||ri.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Yr=Symbol(),sr=new WeakMap;let fl=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Yr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(vs&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=sr.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&sr.set(t,e))}return e}toString(){return this.cssText}};const dl=r=>new fl(typeof r=="string"?r:r+"",void 0,Yr),pl=(r,e)=>{if(vs)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),s=ri.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,r.appendChild(i)}},rr=vs?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return dl(t)})(r):r;/**
3740
- * @license
3741
- * Copyright 2017 Google LLC
3742
- * SPDX-License-Identifier: BSD-3-Clause
3743
- */const{is:ml,defineProperty:gl,getOwnPropertyDescriptor:vl,getOwnPropertyNames:_l,getOwnPropertySymbols:yl,getPrototypeOf:xl}=Object,Ie=globalThis,nr=Ie.trustedTypes,wl=nr?nr.emptyScript:"",Ii=Ie.reactiveElementPolyfillSupport,Et=(r,e)=>r,hi={toAttribute(r,e){switch(e){case Boolean:r=r?wl:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},_s=(r,e)=>!ml(r,e),or={attribute:!0,type:String,converter:hi,reflect:!1,hasChanged:_s};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ie.litPropertyMetadata??(Ie.litPropertyMetadata=new WeakMap);class xt extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=or){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&gl(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){const{get:s,set:a}=vl(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get(){return s==null?void 0:s.call(this)},set(o){const c=s==null?void 0:s.call(this);a.call(this,o),this.requestUpdate(e,c,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??or}static _$Ei(){if(this.hasOwnProperty(Et("elementProperties")))return;const e=xl(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Et("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Et("properties"))){const t=this.properties,i=[..._l(t),...yl(t)];for(const s of i)this.createProperty(s,t[s])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const s of i)t.unshift(rr(s))}else e!==void 0&&t.push(rr(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$Eg=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$ES(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$E_??(this._$E_=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$E_)==null||t.delete(e)}_$ES(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return pl(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t){var a;const i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){const o=(((a=i.converter)==null?void 0:a.toAttribute)!==void 0?i.converter:hi).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){var a;const i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const o=i.getPropertyOptions(s),c=typeof o.converter=="function"?{fromAttribute:o.converter}:((a=o.converter)==null?void 0:a.fromAttribute)!==void 0?o.converter:hi;this._$Em=s,this[s]=c.fromAttribute(t,o.type),this._$Em=null}}requestUpdate(e,t,i){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??_s)(this[e],t))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$ET??(this._$ET=new Set)).add(e)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[a,o]of this._$Ep)this[a]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[a,o]of s)o.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.C(a,this[a],o)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$E_)==null||i.forEach(s=>{var a;return(a=s.hostUpdate)==null?void 0:a.call(s)}),this.update(t)):this._$Ej()}catch(s){throw e=!1,this._$Ej(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$E_)==null||t.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(e){return!0}update(e){this._$ET&&(this._$ET=this._$ET.forEach(t=>this._$EO(t,this[t]))),this._$Ej()}updated(e){}firstUpdated(e){}}xt.elementStyles=[],xt.shadowRootOptions={mode:"open"},xt[Et("elementProperties")]=new Map,xt[Et("finalized")]=new Map,Ii==null||Ii({ReactiveElement:xt}),(Ie.reactiveElementVersions??(Ie.reactiveElementVersions=[])).push("2.0.3");/**
3744
- * @license
3745
- * Copyright 2017 Google LLC
3746
- * SPDX-License-Identifier: BSD-3-Clause
3747
- */const bl={attribute:!0,type:String,converter:hi,reflect:!1,hasChanged:_s},Al=(r=bl,e,t)=>{const{kind:i,metadata:s}=t;let a=globalThis.litPropertyMetadata.get(s);if(a===void 0&&globalThis.litPropertyMetadata.set(s,a=new Map),a.set(t.name,r),i==="accessor"){const{name:o}=t;return{set(c){const u=e.get.call(this);e.set.call(this,c),this.requestUpdate(o,u,r)},init(c){return c!==void 0&&this.C(o,void 0,r),c}}}if(i==="setter"){const{name:o}=t;return function(c){const u=this[o];e.call(this,c),this.requestUpdate(o,u,r)}}throw Error("Unsupported decorator location: "+i)};function Tl(r){return(e,t)=>typeof t=="object"?Al(r,e,t):((i,s,a)=>{const o=s.hasOwnProperty(a);return s.constructor.createProperty(a,o?{...i,wrapped:!0}:i),o?Object.getOwnPropertyDescriptor(s,a):void 0})(r,e,t)}/**
3748
- * @license
3749
- * Copyright 2017 Google LLC
3750
- * SPDX-License-Identifier: BSD-3-Clause
3751
- */function Sl(r){return Tl({...r,state:!0,attribute:!1})}/**
3752
- * @license
3753
- * Copyright 2017 Google LLC
3754
- * SPDX-License-Identifier: BSD-3-Clause
3755
- */const ar=(r,e,t)=>(t.configurable=!0,t.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(r,e,t),t);/**
3756
- * @license
3757
- * Copyright 2017 Google LLC
3758
- * SPDX-License-Identifier: BSD-3-Clause
3759
- */function Cl(r,e){return(t,i,s)=>{const a=o=>{var c;return((c=o.renderRoot)==null?void 0:c.querySelector(r))??null};if(e){const{get:o,set:c}=typeof i=="object"?t:s??(()=>{const u=Symbol();return{get(){return this[u]},set(p){this[u]=p}}})();return ar(t,i,{get(){let u=o.call(this);return u===void 0&&(u=a(this),(u!==null||this.hasUpdated)&&c.call(this,u)),u}})}return ar(t,i,{get(){return a(this)}})}}var Ml=Object.defineProperty,Pl=Object.getOwnPropertyDescriptor,ys=(r,e,t,i)=>{for(var s=i>1?void 0:i?Pl(e,t):e,a=r.length-1,o;a>=0;a--)(o=r[a])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ml(e,t,s),s};class Rl{constructor(e,t,i,s){this.name=e,this.slot=t,this.start=i,this.end=s,this.split="--",this.uuid="",this.valid=!1,this.editable=!1,this.highlight=!1,this.uuid=e+this.split+t}update(e,t){this.start=e.clone(),this.end=t.clone()}}exports.DeviceLines=class extends ii.LitElement{constructor(e,t=0){super(),this.offset=e,this.heightOffset=t,this.lines=new Map,this.setOffset(this.offset.x,this.offset.y)}setOffset(e,t){this.offset.set(e,t),this.style.setProperty("--left",this.offset.x+"px"),this.style.setProperty("--top",this.offset.y+"px")}setHeightOffset(e){this.heightOffset=e,this.style.setProperty("--heightOffset",this.heightOffset+"px")}hide(){var e;(e=this.container)==null||e.classList.add("hidden")}show(){var e;(e=this.container)==null||e.classList.remove("hidden")}addLine(e){this.lines.has(e.uuid)||this.lines.set(e.uuid,e)}clear(){this.lines.clear()}removeLine(e){this.lines.delete(e.uuid)}getLineByName(e){const t=[];return this.lines.forEach((i,s)=>{i.name===e&&t.push(i)}),t}getLineBySlot(e){const t=[];return this.lines.forEach((i,s)=>{i.slot===e&&t.push(i)}),t}getPath(e){const t=e.end.clone();t.set(t.x-this.offset.x,t.y-this.offset.y);const i=e.start.clone().add(t).multiplyScalar(.5),s=e.start.clone().add(t).multiplyScalar(.7);return`M${e.start.x} ${e.start.y}
3760
- C${i.x} ${e.start.y}
3761
- ${s.x} ${e.end.y}
3762
- ${t.x} ${t.y}
3763
- `}updateLine(e){this.lines.set(e.uuid,e)}forceUpdate(){this.requestUpdate()}render(){return ii.svg`
3764
- <svg class="container">
3765
- <g>
3766
- ${[...this.lines.values()].map(e=>ii.svg`<path
3767
- class="${e.valid?"valid":""} ${e.editable?"editable":""} ${e.highlight?"highlight":""}"
3768
- d="${this.getPath(e)}"></path>`)}
3769
- </g>
3770
- </svg>`}};exports.DeviceLines.styles=ii.css`
3771
- :host {
3772
- --left: 0px;
3773
- --top: 0px;
3774
- position: absolute;
3775
- left: var(--left);
3776
- top: var(--top);
3777
- pointer-events: none;
3778
- width: calc(100% - var(--left));
3779
- height: calc(100% - var(--top));
3780
- }
3781
-
3782
- svg {
3783
- width: 100%;
3784
- height: calc(100% + var(--heightOffset));
3785
- &.hidden {
3786
- display: none;
3787
- }
3788
- }
3789
-
3790
- path {
3791
- stroke: #787878;
3792
- fill: transparent;
3793
- stroke-width: 0.5px;
3794
- stroke-dasharray: 4 4;
3795
-
3796
- &.valid {
3797
- stroke-width: 1px;
3798
- stroke: #00FF95;
3799
- stroke-dasharray: none;
3800
- &:hover {
3801
- cursor: pointer;
3802
- }
3803
- }
3804
-
3805
- &.highlight {
3806
- stroke: #0066FF;
3807
- cursor: pointer;
3808
- stroke-width: 2px;
3809
- }
3810
-
3811
- &.editable {
3812
- pointer-events: auto;
3813
- &:hover {
3814
- cursor: pointer;
3815
- stroke: #0066FF;
3816
- stroke-width: 2px;
3817
- stroke-dasharray: none;
3818
- }
3819
- }
3820
- }
3821
- `;ys([Sl()],exports.DeviceLines.prototype,"lines",2);ys([Cl(".container")],exports.DeviceLines.prototype,"container",2);exports.DeviceLines=ys([hl("device-lines")],exports.DeviceLines);class Il extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=gs(),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 a="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:a,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:a,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 u;o.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(u=this.onPointMove)==null||u.call(this)}),this._text.addEventListener("pointerleave",()=>{var u;o.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(u=this.onPointLeave)==null||u.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class ni 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 Il(""),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;(e=this._line.geometry)==null||e.dispose(),this._line.computeLineDistances()}update(e,t,i=0){var h,g;(h=this._line.geometry)==null||h.dispose(),this._line.geometry.setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new f.Vector3().subVectors(t,e).normalize();let o;Math.abs(a.z)>Math.abs(a.x)&&Math.abs(a.z)>Math.abs(a.y)?o=new f.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0),o.length()<.001&&(Math.abs(a.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)),u=new f.Vector3().addVectors(e,o.clone().multiplyScalar(-s)),p=new f.Vector3().addVectors(t,o.clone().multiplyScalar(s)),m=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,u,p,m]),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=>ye(e)),this.removeFromParent()}}class $r extends f.Object3D{constructor(e,t){super(),this.radius=e,this._text=new El(""),this._line=new ni(void 0,!1,!1),this._box=new f.Mesh,this._arc=new Pn.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 Ms.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new Rn.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 u=i-this._lastAngle;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI),this._accumulatedAngle+=u}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),a=s+this._accumulatedAngle;let o=.006*this.radius;o<.003&&(o=.003),o>.006&&(o=.006);const c=this._createArcGeometry(s,a,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=[],a=t-e,o=Math.max(128,Math.floor(Math.abs(a)/(Math.PI/128))),c=a/o;for(let p=0;p<=o;p++){const m=e+p*c,n=Math.cos(m),l=Math.sin(m);s.push(i*n,0,i*l)}const u=new Ms.LineGeometry;return u.setPositions(s),u.instanceCount=Math.max(0,s.length/3-1),u}}class El extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=gs();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 Dl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",Ll="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",lr="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==",Fl="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 cr extends fe.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new ut,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 c=(Date.now()-this._startAt)/200;c>4&&(c=4);let u=this._initial+.005*c*this._direction;if(u>this.props.max||u<this.props.min){this.mechanism&&(u<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):u>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=u,!this.mechanism)return;this.mechanism.position.setZ(u),this._emitter.emit("change",u)}};const s=gs();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(c=>{c.name===e.userData.target.name&&(this.mechanism=c)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const a=document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.transform="translateX(-50%) rotate(-180deg)",a.style.marginBottom="5px",a.style.width=a.style.height=s?"34px":"44px",a.style.background=`url(${lr}) center no-repeat`,a.style.backgroundSize="100% auto",a.setAttribute("data-direction","up"),a.style.transition="all .2s";const o=document.createElement("div");if(o.style.position="absolute",o.style.left="0",o.style.transform="translateX(-50%)",a.style.bottom=o.style.top="8px",o.style.width=o.style.height=a.style.width,o.style.background=`url(${lr}) center no-repeat`,o.style.backgroundSize="100% auto",o.style.transition="all .2s",o.setAttribute("data-direction","down"),Array.from([a,o]).forEach(c=>{s||c.addEventListener("mousemove",()=>{c.style.filter="invert(100%)"}),c.addEventListener("mouseleave",()=>{c.style.filter=""}),c.addEventListener("pointerdown",()=>{this.mechanism&&(c.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=c.getAttribute("data-direction")==="up"?1:-1,this._update())}),c.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""}),c.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:c,rotateDuration:u,rotateStep:p,rotateMax:m,rotateMin:n}=e.userData;let l;if(c&&(t.traverse(h=>{h.name===c.name&&(l=h)}),l)){const h=document.createElement("div");h.style.background=`url(${Fl}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.position="absolute",h.style.top="-50%",h.style.left="-50%",h.style.width=s?"140px":"160px",h.style.height=s?"70px":"80px",h.style.transform="translateX(-50%) translateY(-50%)",i.append(h);const g=document.createElement("div");g.style.background=`url(${Ll}) center no-repeat`,g.style.backgroundSize="100% auto",g.style.width=g.style.height=s?"20px":"26px",g.style.position="absolute",g.style.top="0",g.style.transform="translateY(-50%)",g.style.marginBottom="5px",g.setAttribute("data-direction","left"),i.append(g);const _=document.createElement("div");_.style.background=`url(${Dl}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.width=_.style.height=s?"20px":"26px",_.style.position="absolute",g.style.left=_.style.right=s?"62px":"69px",_.style.top="0",_.style.transform="translateY(-50%)",_.style.marginBottom="5px",_.setAttribute("data-direction","right"),i.append(_),Array.from([g,_]).forEach(d=>{s||d.addEventListener("mousemove",()=>{d.style.filter="invert(100%)"}),d.addEventListener("mouseleave",()=>{d.style.filter=""}),d.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;d.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=d.getAttribute("data-direction")==="left"?1:-1;let v=p/180*Math.PI*this._direction+l.rotation.z;v>m/180*Math.PI?v=m/180*Math.PI:v<n/180*Math.PI&&(v=n/180*Math.PI),this._timer=new ci(l.rotation).to({z:v}).duration(u).start(),this._update()}),d.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),d.style.filter=""}),d.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),d.style.filter=""})})}}i.append(a,o),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 fe.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof fe.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class Bl extends In.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new ut,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=u=>{const{pageX:p,pageY:m}=u;this.endNode.setPointerCapture(u.pointerId),this._mouseStart.set(p,m),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=u=>{if(!this._mouseStart.x)return;const{pageX:p,pageY:m}=u;let n=p-this._mouseStart.x,l=n+this._targetSize.x;this._sizeFlag==="height"&&(n=m-this._mouseStart.y,l=n*this._direction+this._targetSize.y);const h=l%10;l=l-h,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=u=>{this.endNode.releasePointerCapture(u.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,a=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=a.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]=a*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 kl extends f.Object3D{constructor(){super(),this._box3=new f.Box3,this._line11=new ni("长:"),this._line12=new ni("宽:"),this._line13=new ni("高:"),this._outline=new $r(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 fe.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 fe.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:a,hasHeight:o,hasWidth:c}=tl(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=a,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 u=this._box3.min.x,p=this._box3.max.x,m=this._box3.min.z,n=this._box3.max.z,l=this._box3.min.y,h=this._box3.max.y;let g=.2;const _=new f.Vector3(u,h,0),d=new f.Vector3(p,h,0);this._line11.update(_.clone().sub(new f.Vector3(0,-g/1.8,0)),d.clone().sub(new f.Vector3(0,-g/1.8,0)),this._radius);const v=new f.Vector3(p,l,0);this._line12.update(d.clone().add(new f.Vector3(g,0,0)),v.clone().add(new f.Vector3(g,0,0)),this._radius);const y=new f.Vector3(u,h,m),x=new f.Vector3(u,h,n),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class ur extends f.Object3D{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._generate(e,t,i)}clearAll(){ye(this)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}_generate(e,t,i){this.clearAll();const s=new f.Mesh(new f.BoxGeometry(e,t,i),new f.MeshBasicMaterial({color:new f.Color("#0f5fd5"),transparent:!0,opacity:.4}));s.geometry.translate(0,0,i/2);const a=new f.EdgesGeometry(s.geometry),o=new f.LineDashedMaterial({color:new f.Color("#000"),dashSize:.015,gapSize:.015}),c=new f.LineSegments(a,o);c.computeLineDistances(),this.add(s,c)}}const Ol="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Xi{constructor(e){this._props=e,this.name="",this.transparentTexture=xs.load(Ol),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 a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var p;let o=window.devicePixelRatio*2;this._offscreen.width=a.width+o,this._offscreen.height=a.height+o;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(a,o/2,o/2,a.width,a.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 u=this._props.target;u.material&&((p=u.material.map)==null||p.dispose(),s?(u.material.map=s,u.material.opacity=1):(u.material.map=this.transparentTexture,u.material.opacity=0))}}else{const a=this._props.target;a.material&&(a.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 zl(r){return r.type?r.type==="Mesh":r.isMesh}const xs=new f.TextureLoader;xs.crossOrigin="anonymous";class Qr extends f.Object3D{constructor(e){super(),this._props=e,this._emitter=new ut,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new f.Group,this.lines=new f.Group,this.sizeBox=new kl,this._goodsSize=new sl(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,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._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],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((e=this._lift)==null?void 0:e.position.z)||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}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.addEventListener("shape-key-changed",(t,i)=>{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 Zi&&!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)})}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;if(t==="glb"||e.endsWith(".glb"))i=(await ct.loadAsync(e)).scene;else{const a=await new ui({useCache:!0}).loadAsync(e);if(!a.glb)return;i=a.glb}this._generateAmr(i.clone(!0)),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))}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this._container.traverse(s=>{if(!Object.keys(s.morphTargetDictionary||{}).includes(e))return;let a=t;s.userData[`origin_${e}`]&&(a-=s.userData[`origin_${e}`]);const o=s.morphTargetDictionary[e];s.morphTargetInfluences&&(s.morphTargetInfluences[o]=a),s instanceof f.Mesh&&s.geometry.translate(0,0,1e-5)}),i&&this._emitter.emit("shape-key-changed",e,t)},100)}_generateAmr(e){e.traverse(t=>{t.userData.isShelf&&(this._shelf=t),t.userData.isFork&&(this._fork=t),t.userData.isMast&&t.userData.mastLevel&&this._masts.set(t.userData.mastLevel,t),t.userData.isJack&&(this._jack=t),t.userData.isLift&&(this._lift=t),Object.keys(t.morphTargetDictionary||{}).forEach(i=>{let s=t.morphTargetInfluences[t.morphTargetDictionary[i]];t.userData[`origin_${i}`]&&(s+=t.userData[`origin_${i}`]),this._shapeKeys.has(i)||this._shapeKeys.set(i,s)})}),e.traverse(t=>{if(t instanceof f.Mesh){if(t.castShadow=!0,t.receiveShadow=!0,t.material)if(Array.isArray(t.material))t.material.forEach(s=>{s.userData.changeColor&&(this.skins.find(a=>a.name===s.userData.name)||this.skins.push(new as({name:s.userData.name,target:s})))});else{if(t.material.userData.isBreathLight&&t.material.emissiveIntensity){t.material.emissive||(t.material.emissive=new f.Color(16777215)),t.material.emissiveIntensity=2,t.material.toneMapped=!1;const s=1e3,a=new Pe.Tween(t.material).to({emissiveIntensity:.2}).easing(Pe.Easing.Quintic.InOut).duration(s),o=new Pe.Tween(t.material).to({emissiveIntensity:2}).easing(Pe.Easing.Quintic.InOut).duration(s);a.onComplete(()=>o.start()),o.onComplete(()=>a.start()),a.start(),this._breathLights.push(a,o)}t.material.userData.changeColor&&(this.skins.find(s=>s.name===t.material.userData.name)||this.skins.push(new as({name:t.material.userData.name,target:t.material})))}if(t.material)if(Array.isArray(t.material))t.material.forEach(a=>{if(a.userData.isLOGO){t.material.transparent=!0;let o;const c={width:0,height:0};t.material.map&&t.material.map.image&&(c.width=t.material.map.image.width,c.height=t.material.map.image.height,o=Qi(t.material.map.image));const u=new Xi({name:a.userData.name,target:t,size:Js(t),imageSize:c,imageUrl:o});this._logos.push(u)}a.userData.isTransparent&&(a.transparent=!0),this._materialsCache.set(a.uuid,{opacity:a.opacity,transparent:a.transparent,roughness:a.roughness,metalness:a.metalness,color:a.color,mat:a})});else{const s=t.material;if(s.userData.isLOGO){t.material.transparent=!0;let a;const o={width:0,height:0};t.material.map&&t.material.map.image&&(o.width=t.material.map.image.width,o.height=t.material.map.image.height,a=Qi(t.material.map.image));const c=new Xi({name:s.userData.name,target:t,size:Js(t),imageSize:o,imageUrl:a});this._logos.push(c)}s.userData.isTransparent&&(s.transparent=!0),this._materialsCache.set(s.uuid,{opacity:s.opacity,transparent:s.transparent,roughness:s.roughness,metalness:s.metalness,color:s.color,mat:s})}}this.generateController(t,e),this.generateDimension(t,e);const i=this.generateSlot(t,e);i&&this._slots.push(i),t.userData.isOrigin&&Object.keys(t.userData).forEach(a=>{if(a.startsWith("follow_")){const o=a.replace("follow_","");this.shapeKeys.has(o)&&(this.sizeBox.follow=o,this.sizeBox.followOrigin=this._shapeKeys.get(o)||0,this.sizeBox.followScale=t.userData[a])}})}),this.slots.forEach(t=>{t.props.mirrorTarget&&(t.mirrorTarget=this.slots.find(i=>i.props.slot.name===t.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this.sizeBox.generate(e),this.sizeBox.show()}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){this._lift&&(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(a=>{a.name.toLowerCase().includes("lift")&&(a.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)}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-5)}setShelfLevel(e=3){var s;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset;this._shelves.delete(0),this._shelves.forEach(a=>{ye(a),a.parent&&a.removeFromParent()}),this.goods=[],this._shelves.clear(),this._shelves.set(0,this._shelf);for(let a=1;a<e;a++){if(!this._shelf)return;this._shelf.traverse(u=>{zl(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",this._goodsSize.length))});const o=this._shelf.clone(!0);o.position.z+=t*a,this._shelves.set(a,o),(s=this._shelf.parent)==null||s.add(o);let c;if(o.traverse(u=>{u.userData.isShelfContainer&&(c=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&(c==null||c.position.setX((c==null?void 0:c.position.x)-this._goodsSize.length/2)),c){const u=new ur(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(u),this.goods.push(u),a===1){const p=new ur(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);p.position.z-=t,c.add(p),this.goods.push(p)}}}const i=this.getShelfMinHeight()||0;this._liftMaxHeight<i&&this.setLiftMaxHeight(i)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new $r(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:a}=e.userData;let o;if(t.traverse(u=>{u.name===i&&(o=u)}),!o)return;const c=new cr({name:"",target:i,default:0,min:s,max:a},o);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let o;if(t.traverse(u=>{u.name===i&&(o=u)}),!o)return;const c=new cr({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:a||1},o);e.add(c),this.controllers.push(c),(o.userData.isFork||o.userData.isLift||o.userData.isJack)&&(this._forkMaxHeight=a||1,this._liftMaxHeight=a||1,this._jackMaxHeight=a||1,c.addListener("change",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=Ja(e.userData.startOrigin),a=e.userData.axios;let o,c;if(a==="x"?(o=new f.Vector3(e.userData.start-e.position.x,0,0),c=o.clone().setX(e.userData.end-e.position.x)):a==="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 m=new Bl({start:o,end:c,startOrigin:s,axios:a,divider:i});e.add(m)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const a=e.userData.name,o=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(a){const u=e.userData.holeTarget&&e.userData.holeTarget.name;let p;u&&t.traverse(h=>{h.name===u&&(p=h)});const m=new Map;Object.keys(e.userData).forEach(h=>{if(h.startsWith("follow_")){const g=h.split("_")[1];if(g){let _=e.userData[h];m.set(g,{scale:_,origin:this.shapeKeys.get(g)||0})}}});const n=(s=this._app)==null?void 0:s.props.isMobile,l=new Zi({name:a,follows:m,slot:e,show:this._showSlots,isMirror:o,mirrorTarget:c,isMobile:n});return l.holeTarget=p,l.addEventListener(q.ON_DROP,h=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(q.ON_BEFORE_SELECTED,h=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(q.ON_ERROR_STATE_CHANGE,h=>{if(this._app)if(this._app._outlinePassError.selectedObjects=this._app._outlinePassError.selectedObjects.filter(g=>!!g.parent),h){if(l.device){if(this._app._outlinePassError.selectedObjects.find(_=>{var d;return _.parent==((d=l.device)==null?void 0:d.parent)}))return;this._app._outlinePassError.selectedObjects=[l.device,...this._app._outlinePassError.selectedObjects]}}else l.device&&(this._app._outlinePassError.selectedObjects=this._app._outlinePassError.selectedObjects.filter(g=>{var _;return g.parent!=((_=l.device)==null?void 0:_.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],ye(this._container),this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset()}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t=!0){}pauseAction(e){console.log(`Pausing action: ${e}`)}}const Zr=0,Vl=1,Ul=2,hr=2,Ei=1.25,fr=1,Dt=6*4+4+4,vi=65535,Hl=Math.pow(2,-24),Di=Symbol("SKIP_GENERATION");function Nl(r){return r.index?r.index.count:r.attributes.position.count}function ht(r){return Nl(r)/3}function Wl(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Gl(r,e){if(!r.index){const t=r.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Wl(t,i);r.setIndex(new f.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Xr(r){const e=ht(r),t=r.drawRange,i=t.start/3,s=(t.start+t.count)/3,a=Math.max(0,i),o=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function Kr(r){if(!r.groups||!r.groups.length)return Xr(r);const e=[],t=new Set,i=r.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of r.groups){const u=c.start/3,p=(c.start+c.count)/3;t.add(Math.max(s,u)),t.add(Math.min(a,p))}const o=Array.from(t.values()).sort((c,u)=>c-u);for(let c=0;c<o.length-1;c++){const u=o[c],p=o[c+1];e.push({offset:Math.floor(u),count:Math.floor(p-u)})}return e}function ql(r){if(r.groups.length===0)return!1;const e=ht(r),t=Kr(r).sort((a,o)=>a.offset-o.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:a})=>s+=a),e!==s}function Li(r,e,t,i,s){let a=1/0,o=1/0,c=1/0,u=-1/0,p=-1/0,m=-1/0,n=1/0,l=1/0,h=1/0,g=-1/0,_=-1/0,d=-1/0;for(let v=e*6,y=(e+t)*6;v<y;v+=6){const x=r[v+0],w=r[v+1],b=x-w,T=x+w;b<a&&(a=b),T>u&&(u=T),x<n&&(n=x),x>g&&(g=x);const S=r[v+2],P=r[v+3],C=S-P,R=S+P;C<o&&(o=C),R>p&&(p=R),S<l&&(l=S),S>_&&(_=S);const E=r[v+4],A=r[v+5],M=E-A,I=E+A;M<c&&(c=M),I>m&&(m=I),E<h&&(h=E),E>d&&(d=E)}i[0]=a,i[1]=o,i[2]=c,i[3]=u,i[4]=p,i[5]=m,s[0]=n,s[1]=l,s[2]=h,s[3]=g,s[4]=_,s[5]=d}function jl(r,e=null,t=null,i=null){const s=r.attributes.position,a=r.index?r.index.array:null,o=ht(r),c=s.normalized;let u;e===null?(u=new Float32Array(o*6*4),t=0,i=o):(u=e,t=t||0,i=i||o);const p=s.array,m=s.offset||0;let n=3;s.isInterleavedBufferAttribute&&(n=s.data.stride);const l=["getX","getY","getZ"];for(let h=t;h<t+i;h++){const g=h*3,_=h*6;let d=g+0,v=g+1,y=g+2;a&&(d=a[d],v=a[v],y=a[y]),c||(d=d*n+m,v=v*n+m,y=y*n+m);for(let x=0;x<3;x++){let w,b,T;c?(w=s[l[x]](d),b=s[l[x]](v),T=s[l[x]](y)):(w=p[d+x],b=p[v+x],T=p[y+x]);let S=w;b<S&&(S=b),T<S&&(S=T);let P=w;b>P&&(P=b),T>P&&(P=T);const C=(P-S)/2,R=x*2;u[_+R+0]=S+C,u[_+R+1]=C+(Math.abs(S)+C)*Hl}}return u}function N(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function dr(r){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=r[i+3]-r[i];s>t&&(t=s,e=i)}return e}function pr(r,e){e.set(r)}function mr(r,e,t){let i,s;for(let a=0;a<3;a++){const o=a+3;i=r[a],s=e[a],t[a]=i<s?i:s,i=r[o],s=e[o],t[o]=i>s?i:s}}function Nt(r,e,t){for(let i=0;i<3;i++){const s=e[r+2*i],a=e[r+2*i+1],o=s-a,c=s+a;o<t[i]&&(t[i]=o),c>t[i+3]&&(t[i+3]=c)}}function wt(r){const e=r[3]-r[0],t=r[4]-r[1],i=r[5]-r[2];return 2*(e*t+t*i+i*e)}const me=32,Yl=(r,e)=>r.candidate-e.candidate,Ae=new Array(me).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Wt=new Float32Array(6);function $l(r,e,t,i,s,a){let o=-1,c=0;if(a===Zr)o=dr(e),o!==-1&&(c=(e[o]+e[o+3])/2);else if(a===Vl)o=dr(r),o!==-1&&(c=Ql(t,i,s,o));else if(a===Ul){const u=wt(r);let p=Ei*s;const m=i*6,n=(i+s)*6;for(let l=0;l<3;l++){const h=e[l],d=(e[l+3]-h)/me;if(s<me/4){const v=[...Ae];v.length=s;let y=0;for(let w=m;w<n;w+=6,y++){const b=v[y];b.candidate=t[w+2*l],b.count=0;const{bounds:T,leftCacheBounds:S,rightCacheBounds:P}=b;for(let C=0;C<3;C++)P[C]=1/0,P[C+3]=-1/0,S[C]=1/0,S[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0;Nt(w,t,T)}v.sort(Yl);let x=s;for(let w=0;w<x;w++){const b=v[w];for(;w+1<x&&v[w+1].candidate===b.candidate;)v.splice(w+1,1),x--}for(let w=m;w<n;w+=6){const b=t[w+2*l];for(let T=0;T<x;T++){const S=v[T];b>=S.candidate?Nt(w,t,S.rightCacheBounds):(Nt(w,t,S.leftCacheBounds),S.count++)}}for(let w=0;w<x;w++){const b=v[w],T=b.count,S=s-b.count,P=b.leftCacheBounds,C=b.rightCacheBounds;let R=0;T!==0&&(R=wt(P)/u);let E=0;S!==0&&(E=wt(C)/u);const A=fr+Ei*(R*T+E*S);A<p&&(o=l,p=A,c=b.candidate)}}else{for(let x=0;x<me;x++){const w=Ae[x];w.count=0,w.candidate=h+d+x*d;const b=w.bounds;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0}for(let x=m;x<n;x+=6){let T=~~((t[x+2*l]-h)/d);T>=me&&(T=me-1);const S=Ae[T];S.count++,Nt(x,t,S.bounds)}const v=Ae[me-1];pr(v.bounds,v.rightCacheBounds);for(let x=me-2;x>=0;x--){const w=Ae[x],b=Ae[x+1];mr(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<me-1;x++){const w=Ae[x],b=w.count,T=w.bounds,P=Ae[x+1].rightCacheBounds;b!==0&&(y===0?pr(T,Wt):mr(T,Wt,Wt)),y+=b;let C=0,R=0;y!==0&&(C=wt(Wt)/u);const E=s-y;E!==0&&(R=wt(P)/u);const A=fr+Ei*(C*y+R*E);A<p&&(o=l,p=A,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:o,pos:c}}function Ql(r,e,t,i){let s=0;for(let a=e,o=e+t;a<o;a++)s+=r[a*6+i*2];return s/t}class Fi{constructor(){this.boundingData=new Float32Array(6)}}function Zl(r,e,t,i,s,a){let o=i,c=i+s-1;const u=a.pos,p=a.axis*2;for(;;){for(;o<=c&&t[o*6+p]<u;)o++;for(;o<=c&&t[c*6+p]>=u;)c--;if(o<c){for(let m=0;m<3;m++){let n=e[o*3+m];e[o*3+m]=e[c*3+m],e[c*3+m]=n}for(let m=0;m<6;m++){let n=t[o*6+m];t[o*6+m]=t[c*6+m],t[c*6+m]=n}o++,c--}else return o}}function Xl(r,e,t,i,s,a){let o=i,c=i+s-1;const u=a.pos,p=a.axis*2;for(;;){for(;o<=c&&t[o*6+p]<u;)o++;for(;o<=c&&t[c*6+p]>=u;)c--;if(o<c){let m=r[o];r[o]=r[c],r[c]=m;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 Q(r,e){return e[r+15]===65535}function K(r,e){return e[r+6]}function te(r,e){return e[r+14]}function ie(r){return r+8}function se(r,e){return e[r+6]}function Jr(r,e){return e[r+7]}let en,Pt,oi,tn;const Kl=Math.pow(2,32);function Ki(r){return"count"in r?1:1+Ki(r.left)+Ki(r.right)}function Jl(r,e,t){return en=new Float32Array(t),Pt=new Uint32Array(t),oi=new Uint16Array(t),tn=new Uint8Array(t),Ji(r,e)}function Ji(r,e){const t=r/4,i=r/2,s="count"in e,a=e.boundingData;for(let o=0;o<6;o++)en[t+o]=a[o];if(s)if(e.buffer){const o=e.buffer;tn.set(new Uint8Array(o),r);for(let c=r,u=r+o.byteLength;c<u;c+=Dt){const p=c/2;Q(p,oi)||(Pt[c/4+6]+=t)}return r+o.byteLength}else{const o=e.offset,c=e.count;return Pt[t+6]=o,oi[i+14]=c,oi[i+15]=vi,r+Dt}else{const o=e.left,c=e.right,u=e.splitAxis;let p;if(p=Ji(r+Dt,o),p/4>Kl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Pt[t+6]=p/4,p=Ji(p,c),Pt[t+7]=u,p}}function ec(r,e){const t=(r.index?r.index.count:r.attributes.position.count)/3,i=t>2**16,s=i?4:2,a=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),o=i?new Uint32Array(a):new Uint16Array(a);for(let c=0,u=o.length;c<u;c++)o[c]=c;return o}function tc(r,e,t,i,s){const{maxDepth:a,verbose:o,maxLeafTris:c,strategy:u,onProgress:p,indirect:m}=s,n=r._indirectBuffer,l=r.geometry,h=l.index?l.index.array:null,g=m?Xl:Zl,_=ht(l),d=new Float32Array(6);let v=!1;const y=new Fi;return Li(e,t,i,y.boundingData,d),w(y,t,i,d),y;function x(b){p&&p(b/_)}function w(b,T,S,P=null,C=0){if(!v&&C>=a&&(v=!0,o&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),S<=c||C>=a)return x(T+S),b.offset=T,b.count=S,b;const R=$l(b.boundingData,P,e,T,S,u);if(R.axis===-1)return x(T+S),b.offset=T,b.count=S,b;const E=g(n,h,e,T,S,R);if(E===T||E===T+S)x(T+S),b.offset=T,b.count=S;else{b.splitAxis=R.axis;const A=new Fi,M=T,I=E-T;b.left=A,Li(e,M,I,A.boundingData,d),w(A,M,I,d,C+1);const L=new Fi,F=E,O=S-I;b.right=L,Li(e,F,O,L.boundingData,d),w(L,F,O,d,C+1)}return b}}function ic(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=ec(t,e.useSharedArrayBuffer),ql(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.')),r._indirectBuffer||Gl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=jl(t),a=e.indirect?Xr(t):Kr(t);r._roots=a.map(o=>{const c=tc(r,s,o.offset,o.count,e),u=Ki(c),p=new i(Dt*u);return Jl(0,c,p),p})}class xe{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,o=e.length;a<o;a++){const u=e[a][t];i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let a=0,o=t.length;a<o;a++){const c=t[a],u=e.dot(c);i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}xe.prototype.setFromBox=function(){const r=new f.Vector3;return function(t,i){const s=i.min,a=i.max;let o=1/0,c=-1/0;for(let u=0;u<=1;u++)for(let p=0;p<=1;p++)for(let m=0;m<=1;m++){r.x=s.x*u+a.x*(1-u),r.y=s.y*p+a.y*(1-p),r.z=s.z*m+a.z*(1-m);const n=t.dot(r);o=Math.min(n,o),c=Math.max(n,c)}this.min=o,this.max=c}}();const sc=function(){const r=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(s,a,o){const c=s.start,u=r,p=a.start,m=e;t.subVectors(c,p),r.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const n=t.dot(m),l=m.dot(u),h=m.dot(m),g=t.dot(u),d=u.dot(u)*h-l*l;let v,y;d!==0?v=(n*l-g*h)/d:v=0,y=(n+v*l)/h,o.x=v,o.y=y}}(),ws=function(){const r=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(s,a,o,c){sc(s,a,r);let u=r.x,p=r.y;if(u>=0&&u<=1&&p>=0&&p<=1){s.at(u,o),a.at(p,c);return}else if(u>=0&&u<=1){p<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,o);return}else if(p>=0&&p<=1){u<0?s.at(0,o):s.at(1,o),a.closestPointToPoint(o,!0,c);return}else{let m;u<0?m=s.start:m=s.end;let n;p<0?n=a.start:n=a.end;const l=e,h=t;if(s.closestPointToPoint(n,!0,e),a.closestPointToPoint(m,!0,t),l.distanceToSquared(n)<=h.distanceToSquared(m)){o.copy(l),c.copy(n);return}else{o.copy(m),c.copy(h);return}}}}(),rc=function(){const r=new f.Vector3,e=new f.Vector3,t=new f.Plane,i=new f.Line3;return function(a,o){const{radius:c,center:u}=a,{a:p,b:m,c:n}=o;if(i.start=p,i.end=m,i.closestPointToPoint(u,!0,r).distanceTo(u)<=c||(i.start=p,i.end=n,i.closestPointToPoint(u,!0,r).distanceTo(u)<=c)||(i.start=m,i.end=n,i.closestPointToPoint(u,!0,r).distanceTo(u)<=c))return!0;const _=o.getPlane(t);if(Math.abs(_.distanceToPoint(u))<=c){const v=_.projectPoint(u,e);if(o.containsPoint(v))return!0}return!1}}(),nc=1e-15;function Bi(r){return Math.abs(r)<nc}class ce 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 xe),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return rc(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,o=this.satBounds,c=a[0],u=o[0];this.getNormal(c),u.setFromPoints(c,s);const p=a[1],m=o[1];p.subVectors(e,t),m.setFromPoints(p,s);const n=a[2],l=o[2];n.subVectors(t,i),l.setFromPoints(n,s);const h=a[3],g=o[3];h.subVectors(i,e),g.setFromPoints(h,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}ce.prototype.closestPointToSegment=function(){const r=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(s,a=null,o=null){const{start:c,end:u}=s,p=this.points;let m,n=1/0;for(let l=0;l<3;l++){const h=(l+1)%3;t.start.copy(p[l]),t.end.copy(p[h]),ws(t,s,r,e),m=r.distanceToSquared(e),m<n&&(n=m,a&&a.copy(r),o&&o.copy(e))}return this.closestPointToPoint(c,r),m=c.distanceToSquared(r),m<n&&(n=m,a&&a.copy(r),o&&o.copy(c)),this.closestPointToPoint(u,r),m=u.distanceToSquared(r),m<n&&(n=m,a&&a.copy(r),o&&o.copy(u)),Math.sqrt(n)}}();ce.prototype.intersectsTriangle=function(){const r=new ce,e=new Array(3),t=new Array(3),i=new xe,s=new xe,a=new f.Vector3,o=new f.Vector3,c=new f.Vector3,u=new f.Vector3,p=new f.Vector3,m=new f.Line3,n=new f.Line3,l=new f.Line3,h=new f.Vector3;function g(_,d,v){const y=_.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:T,end:S}=m;T.copy(y[b]),S.copy(y[(b+1)%3]),m.delta(o);const P=Bi(d.distanceToPoint(T));if(Bi(d.normal.dot(o))&&P){v.copy(m),x=2;break}const C=d.intersectLine(m,h);if(!C&&P&&h.copy(T),(C||P)&&!Bi(h.distanceTo(S))){if(x<=1)(x===1?v.start:v.end).copy(h),P&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(h),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(d,v=null,y=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(r.copy(d),r.update(),d=r);const x=this.plane,w=d.plane;if(Math.abs(x.normal.dot(w.normal))>1-1e-10){const b=this.satBounds,T=this.satAxes;t[0]=d.a,t[1]=d.b,t[2]=d.c;for(let C=0;C<4;C++){const R=b[C],E=T[C];if(i.setFromPoints(E,t),R.isSeparated(i))return!1}const S=d.satBounds,P=d.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const R=S[C],E=P[C];if(i.setFromPoints(E,e),R.isSeparated(i))return!1}for(let C=0;C<4;C++){const R=T[C];for(let E=0;E<4;E++){const A=P[E];if(a.crossVectors(R,A),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const b=g(this,w,n);if(b===1&&d.containsPoint(n.end))return v&&(v.start.copy(n.end),v.end.copy(n.end)),!0;if(b!==2)return!1;const T=g(d,x,l);if(T===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(T!==2)return!1;if(n.delta(c),l.delta(u),c.dot(u)<0){let M=l.start;l.start=l.end,l.end=M}const S=n.start.dot(c),P=n.end.dot(c),C=l.start.dot(c),R=l.end.dot(c),E=P<C,A=S<R;return S!==R&&C!==P&&E===A?!1:(v&&(p.subVectors(n.start,l.start),p.dot(c)>0?v.start.copy(n.start):v.start.copy(l.start),p.subVectors(n.end,l.end),p.dot(c)<0?v.end.copy(n.end):v.end.copy(l.end)),!0)}}}();ce.prototype.distanceToPoint=function(){const r=new f.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();ce.prototype.distanceToTriangle=function(){const r=new f.Vector3,e=new f.Vector3,t=["a","b","c"],i=new f.Line3,s=new f.Line3;return function(o,c=null,u=null){const p=c||u?i:null;if(this.intersectsTriangle(o,p))return(c||u)&&(c&&p.getCenter(c),u&&p.getCenter(u)),0;let m=1/0;for(let n=0;n<3;n++){let l;const h=t[n],g=o[h];this.closestPointToPoint(g,r),l=g.distanceToSquared(r),l<m&&(m=l,c&&c.copy(r),u&&u.copy(g));const _=this[h];o.closestPointToPoint(_,r),l=_.distanceToSquared(r),l<m&&(m=l,c&&c.copy(_),u&&u.copy(r))}for(let n=0;n<3;n++){const l=t[n],h=t[(n+1)%3];i.set(this[l],this[h]);for(let g=0;g<3;g++){const _=t[g],d=t[(g+1)%3];s.set(o[_],o[d]),ws(i,s,r,e);const v=r.distanceToSquared(e);v<m&&(m=v,c&&c.copy(r),u&&u.copy(e))}}return Math.sqrt(m)}}();class j{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 xe),this.alignedSatBounds=new Array(3).fill().map(()=>new xe),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}}j.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let p=0;p<=1;p++)for(let m=0;m<=1;m++)for(let n=0;n<=1;n++){const l=1*p|2*m|4*n,h=s[l];h.x=p?i.x:t.x,h.y=m?i.y:t.y,h.z=n?i.z:t.z,h.applyMatrix4(e)}const a=this.satBounds,o=this.satAxes,c=s[0];for(let p=0;p<3;p++){const m=o[p],n=a[p],l=1<<p,h=s[l];m.subVectors(c,h),n.setFromPoints(m,s)}const u=this.alignedSatBounds;u[0].setFromPointsField(s,"x"),u[1].setFromPointsField(s,"y"),u[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();j.prototype.intersectsBox=function(){const r=new xe;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(r.min=i.x,r.max=s.x,c[0].isSeparated(r)||(r.min=i.y,r.max=s.y,c[1].isSeparated(r))||(r.min=i.z,r.max=s.z,c[2].isSeparated(r)))return!1;for(let u=0;u<3;u++){const p=o[u],m=a[u];if(r.setFromBox(p,t),m.isSeparated(r))return!1}return!0}}();j.prototype.intersectsTriangle=function(){const r=new ce,e=new Array(3),t=new xe,i=new xe,s=new f.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);const c=this.satBounds,u=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let l=0;l<3;l++){const h=c[l],g=u[l];if(t.setFromPoints(g,e),h.isSeparated(t))return!1}const p=o.satBounds,m=o.satAxes,n=this.points;for(let l=0;l<3;l++){const h=p[l],g=m[l];if(t.setFromPoints(g,n),h.isSeparated(t))return!1}for(let l=0;l<3;l++){const h=u[l];for(let g=0;g<4;g++){const _=m[g];if(s.crossVectors(h,_),t.setFromPoints(s,e),i.setFromPoints(s,n),t.isSeparated(i))return!1}}return!0}}();j.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}}();j.prototype.distanceToPoint=function(){const r=new f.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();j.prototype.distanceToBox=function(){const r=["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,u=null,p=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(u||p)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),u&&u.copy(i),p&&p.copy(s)),0;const m=c*c,n=o.min,l=o.max,h=this.points;let g=1/0;for(let d=0;d<8;d++){const v=h[d];s.copy(v).clamp(n,l);const y=v.distanceToSquared(s);if(y<g&&(g=y,u&&u.copy(v),p&&p.copy(s),y<m))return Math.sqrt(y)}let _=0;for(let d=0;d<3;d++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){const x=(d+1)%3,w=(d+2)%3,b=v<<x|y<<w,T=1<<d|v<<x|y<<w,S=h[b],P=h[T];e[_].set(S,P);const R=r[d],E=r[x],A=r[w],M=t[_],I=M.start,L=M.end;I[R]=n[R],I[E]=v?n[E]:l[E],I[A]=y?n[A]:l[E],L[R]=l[R],L[E]=v?n[E]:l[E],L[A]=y?n[A]:l[E],_++}for(let d=0;d<=1;d++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=d?l.x:n.x,s.y=v?l.y:n.y,s.z=y?l.z:n.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,u&&u.copy(i),p&&p.copy(s),x<m))return Math.sqrt(x)}for(let d=0;d<12;d++){const v=e[d];for(let y=0;y<12;y++){const x=t[y];ws(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,u&&u.copy(i),p&&p.copy(s),w<m))return Math.sqrt(w)}}return Math.sqrt(g)}}();class bs{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 oc extends bs{constructor(){super(()=>new ce)}}const re=new oc;class ac{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 U=new ac;let Re,it;const Ne=[],Gt=new bs(()=>new f.Box3);function lc(r,e,t,i,s,a){Re=Gt.getPrimitive(),it=Gt.getPrimitive(),Ne.push(Re,it),U.setBuffer(r._roots[e]);const o=es(0,r.geometry,t,i,s,a);U.clearBuffer(),Gt.releasePrimitive(Re),Gt.releasePrimitive(it),Ne.pop(),Ne.pop();const c=Ne.length;return c>0&&(it=Ne[c-1],Re=Ne[c-2]),o}function es(r,e,t,i,s=null,a=0,o=0){const{float32Array:c,uint16Array:u,uint32Array:p}=U;let m=r*2;if(Q(m,u)){const l=K(r,p),h=te(m,u);return N(r,c,Re),i(l,h,!1,o,a+r,Re)}else{let R=function(A){const{uint16Array:M,uint32Array:I}=U;let L=A*2;for(;!Q(L,M);)A=ie(A),L=A*2;return K(A,I)},E=function(A){const{uint16Array:M,uint32Array:I}=U;let L=A*2;for(;!Q(L,M);)A=se(A,I),L=A*2;return K(A,I)+te(L,M)};const l=ie(r),h=se(r,p);let g=l,_=h,d,v,y,x;if(s&&(y=Re,x=it,N(g,c,y),N(_,c,x),d=s(y),v=s(x),v<d)){g=h,_=l;const A=d;d=v,v=A,y=x}y||(y=Re,N(g,c,y));const w=Q(g*2,u),b=t(y,w,d,o+1,a+g);let T;if(b===hr){const A=R(g),I=E(g)-A;T=i(A,I,!0,o+1,a+g,y)}else T=b&&es(g,e,t,i,s,a,o+1);if(T)return!0;x=it,N(_,c,x);const S=Q(_*2,u),P=t(x,S,v,o+1,a+_);let C;if(P===hr){const A=R(_),I=E(_)-A;C=i(A,I,!0,o+1,a+_,x)}else C=P&&es(_,e,t,i,s,a,o+1);return!!C}}const bt=new f.Vector3,ki=new f.Vector3;function cc(r,e,t={},i=0,s=1/0){const a=i*i,o=s*s;let c=1/0,u=null;if(r.shapecast({boundsTraverseOrder:m=>(bt.copy(e).clamp(m.min,m.max),bt.distanceToSquared(e)),intersectsBounds:(m,n,l)=>l<c&&l<o,intersectsTriangle:(m,n)=>{m.closestPointToPoint(e,bt);const l=e.distanceToSquared(bt);return l<c&&(ki.copy(bt),c=l,u=n),l<a}}),c===1/0)return null;const p=Math.sqrt(c);return t.point?t.point.copy(ki):t.point=ki.clone(),t.distance=p,t.faceIndex=u,t}const We=new f.Vector3,Ge=new f.Vector3,qe=new f.Vector3,qt=new f.Vector2,jt=new f.Vector2,Yt=new f.Vector2,gr=new f.Vector3,vr=new f.Vector3,_r=new f.Vector3,$t=new f.Vector3;function uc(r,e,t,i,s,a,o,c){let u;if(a===f.BackSide?u=r.intersectTriangle(i,t,e,!0,s):u=r.intersectTriangle(e,t,i,a!==f.DoubleSide,s),u===null)return null;const p=r.origin.distanceTo(s);return p<o||p>c?null:{distance:p,point:s.clone()}}function hc(r,e,t,i,s,a,o,c,u,p,m){We.fromBufferAttribute(e,a),Ge.fromBufferAttribute(e,o),qe.fromBufferAttribute(e,c);const n=uc(r,We,Ge,qe,$t,u,p,m);if(n){i&&(qt.fromBufferAttribute(i,a),jt.fromBufferAttribute(i,o),Yt.fromBufferAttribute(i,c),n.uv=f.Triangle.getInterpolation($t,We,Ge,qe,qt,jt,Yt,new f.Vector2)),s&&(qt.fromBufferAttribute(s,a),jt.fromBufferAttribute(s,o),Yt.fromBufferAttribute(s,c),n.uv1=f.Triangle.getInterpolation($t,We,Ge,qe,qt,jt,Yt,new f.Vector2)),t&&(gr.fromBufferAttribute(t,a),vr.fromBufferAttribute(t,o),_r.fromBufferAttribute(t,c),n.normal=f.Triangle.getInterpolation($t,We,Ge,qe,gr,vr,_r,new f.Vector3),n.normal.dot(r.direction)>0&&n.normal.multiplyScalar(-1));const l={a,b:o,c,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(We,Ge,qe,l.normal),n.face=l,n.faceIndex=a}return n}function _i(r,e,t,i,s,a,o){const c=i*3;let u=c+0,p=c+1,m=c+2;const n=r.index;r.index&&(u=n.getX(u),p=n.getX(p),m=n.getX(m));const{position:l,normal:h,uv:g,uv1:_}=r.attributes,d=hc(t,l,h,g,_,u,p,m,e,a,o);return d?(d.faceIndex=i,s&&s.push(d),d):null}function G(r,e,t,i){const s=r.a,a=r.b,o=r.c;let c=e,u=e+1,p=e+2;t&&(c=t.getX(c),u=t.getX(u),p=t.getX(p)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(u),a.y=i.getY(u),a.z=i.getZ(u),o.x=i.getX(p),o.y=i.getY(p),o.z=i.getZ(p)}function fc(r,e,t,i,s,a,o,c){const{geometry:u,_indirectBuffer:p}=r;for(let m=i,n=i+s;m<n;m++)_i(u,e,t,m,a,o,c)}function dc(r,e,t,i,s,a,o){const{geometry:c,_indirectBuffer:u}=r;let p=1/0,m=null;for(let n=i,l=i+s;n<l;n++){let h;h=_i(c,e,t,n,null,a,o),h&&h.distance<p&&(m=h,p=h.distance)}return m}function pc(r,e,t,i,s,a,o){const{geometry:c}=t,{index:u}=c,p=c.attributes.position;for(let m=r,n=e+r;m<n;m++){let l;if(l=m,G(o,l*3,u,p),o.needsUpdate=!0,i(o,l,s,a))return!0}return!1}function mc(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,o,c,u,p=0;const m=r._roots;for(let l=0,h=m.length;l<h;l++)a=m[l],o=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),n(0,p),p+=a.byteLength;function n(l,h,g=!1){const _=l*2;if(c[_+15]===vi){const v=o[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,T=-1/0,S=-1/0,P=-1/0;for(let C=3*v,R=3*(v+y);C<R;C++){let E=i[C];const A=s.getX(E),M=s.getY(E),I=s.getZ(E);A<x&&(x=A),A>T&&(T=A),M<w&&(w=M),M>S&&(S=M),I<b&&(b=I),I>P&&(P=I)}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==T||u[l+4]!==S||u[l+5]!==P?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=T,u[l+4]=S,u[l+5]=P,!0):!1}else{const v=l+8,y=o[l+6],x=v+h,w=y+h;let b=g,T=!1,S=!1;e?b||(T=e.has(x),S=e.has(w),b=!T&&!S):(T=!0,S=!0);const P=b||T,C=b||S;let R=!1;P&&(R=n(v,h,b));let E=!1;C&&(E=n(y,h,b));const A=R||E;if(A)for(let M=0;M<3;M++){const I=v+M,L=y+M,F=u[I],O=u[I+3],H=u[L],W=u[L+3];u[l+M]=F<H?F:H,u[l+M+3]=O>W?O:W}return A}}}function Ee(r,e,t,i,s){let a,o,c,u,p,m;const n=1/t.direction.x,l=1/t.direction.y,h=1/t.direction.z,g=t.origin.x,_=t.origin.y,d=t.origin.z;let v=e[r],y=e[r+3],x=e[r+1],w=e[r+3+1],b=e[r+2],T=e[r+3+2];return n>=0?(a=(v-g)*n,o=(y-g)*n):(a=(y-g)*n,o=(v-g)*n),l>=0?(c=(x-_)*l,u=(w-_)*l):(c=(w-_)*l,u=(x-_)*l),a>u||c>o||((c>a||isNaN(a))&&(a=c),(u<o||isNaN(o))&&(o=u),h>=0?(p=(b-d)*h,m=(T-d)*h):(p=(T-d)*h,m=(b-d)*h),a>m||p>o)?!1:((p>a||a!==a)&&(a=p),(m<o||o!==o)&&(o=m),a<=s&&o>=i)}function gc(r,e,t,i,s,a,o,c){const{geometry:u,_indirectBuffer:p}=r;for(let m=i,n=i+s;m<n;m++){let l=p?p[m]:m;_i(u,e,t,l,a,o,c)}}function vc(r,e,t,i,s,a,o){const{geometry:c,_indirectBuffer:u}=r;let p=1/0,m=null;for(let n=i,l=i+s;n<l;n++){let h;h=_i(c,e,t,u?u[n]:n,null,a,o),h&&h.distance<p&&(m=h,p=h.distance)}return m}function _c(r,e,t,i,s,a,o){const{geometry:c}=t,{index:u}=c,p=c.attributes.position;for(let m=r,n=e+r;m<n;m++){let l;if(l=t.resolveTriangleIndex(m),G(o,l*3,u,p),o.needsUpdate=!0,i(o,l,s,a))return!0}return!1}function yc(r,e,t,i,s,a,o){U.setBuffer(r._roots[e]),ts(0,r,t,i,s,a,o),U.clearBuffer()}function ts(r,e,t,i,s,a,o){const{float32Array:c,uint16Array:u,uint32Array:p}=U,m=r*2;if(Q(m,u)){const l=K(r,p),h=te(m,u);fc(e,t,i,l,h,s,a,o)}else{const l=ie(r);Ee(l,c,i,a,o)&&ts(l,e,t,i,s,a,o);const h=se(r,p);Ee(h,c,i,a,o)&&ts(h,e,t,i,s,a,o)}}const xc=["x","y","z"];function wc(r,e,t,i,s,a){U.setBuffer(r._roots[e]);const o=is(0,r,t,i,s,a);return U.clearBuffer(),o}function is(r,e,t,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:u}=U;let p=r*2;if(Q(p,c)){const n=K(r,u),l=te(p,c);return dc(e,t,i,n,l,s,a)}else{const n=Jr(r,u),l=xc[n],g=i.direction[l]>=0;let _,d;g?(_=ie(r),d=se(r,u)):(_=se(r,u),d=ie(r));const y=Ee(_,o,i,s,a)?is(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=o[d+n]:b>=o[d+n+3])return y}const w=Ee(d,o,i,s,a)?is(d,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Qt=new f.Box3,je=new ce,Ye=new ce,At=new f.Matrix4,yr=new j,Zt=new j;function bc(r,e,t,i){U.setBuffer(r._roots[e]);const s=ss(0,r,t,i);return U.clearBuffer(),s}function ss(r,e,t,i,s=null){const{float32Array:a,uint16Array:o,uint32Array:c}=U;let u=r*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),yr.set(t.boundingBox.min,t.boundingBox.max,i),s=yr),Q(u,o)){const m=e.geometry,n=m.index,l=m.attributes.position,h=t.index,g=t.attributes.position,_=K(r,c),d=te(u,o);if(At.copy(i).invert(),t.boundsTree)return N(r,a,Zt),Zt.matrix.copy(At),Zt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Zt.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_*3,w=(d+_)*3;x<w;x+=3)if(G(Ye,x,n,l),Ye.needsUpdate=!0,y.intersectsTriangle(Ye))return!0;return!1}});for(let v=_*3,y=(d+_)*3;v<y;v+=3){G(je,v,n,l),je.a.applyMatrix4(At),je.b.applyMatrix4(At),je.c.applyMatrix4(At),je.needsUpdate=!0;for(let x=0,w=h.count;x<w;x+=3)if(G(Ye,x,h,g),Ye.needsUpdate=!0,je.intersectsTriangle(Ye))return!0}}else{const m=r+8,n=c[r+6];return N(m,a,Qt),!!(s.intersectsBox(Qt)&&ss(m,e,t,i,s)||(N(n,a,Qt),s.intersectsBox(Qt)&&ss(n,e,t,i,s)))}}const Xt=new f.Matrix4,Oi=new j,Tt=new j,Ac=new f.Vector3,Tc=new f.Vector3,Sc=new f.Vector3,Cc=new f.Vector3;function Mc(r,e,t,i={},s={},a=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Oi.set(e.boundingBox.min,e.boundingBox.max,t),Oi.needsUpdate=!0;const c=r.geometry,u=c.attributes.position,p=c.index,m=e.attributes.position,n=e.index,l=re.getPrimitive(),h=re.getPrimitive();let g=Ac,_=Tc,d=null,v=null;s&&(d=Sc,v=Cc);let y=1/0,x=null,w=null;return Xt.copy(t).invert(),Tt.matrix.copy(Xt),r.shapecast({boundsTraverseOrder:b=>Oi.distanceToBox(b),intersectsBounds:(b,T,S)=>S<y&&S<o?(T&&(Tt.min.copy(b.min),Tt.max.copy(b.max),Tt.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:P=>Tt.distanceToBox(P),intersectsBounds:(P,C,R)=>R<y&&R<o,intersectsRange:(P,C)=>{for(let R=P,E=P+C;R<E;R++){G(h,3*R,n,m),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let A=b,M=b+T;A<M;A++){G(l,3*A,p,u),l.needsUpdate=!0;const I=l.distanceToTriangle(h,g,d);if(I<y&&(_.copy(g),v&&v.copy(d),y=I,x=A,w=R),I<a)return!0}}}});{const S=ht(e);for(let P=0,C=S;P<C;P++){G(h,3*P,n,m),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let R=b,E=b+T;R<E;R++){G(l,3*R,p,u),l.needsUpdate=!0;const A=l.distanceToTriangle(h,g,d);if(A<y&&(_.copy(g),v&&v.copy(d),y=A,x=R,w=P),A<a)return!0}}}}}),re.releasePrimitive(l),re.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(Xt),_.applyMatrix4(Xt),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function Pc(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,o,c,u,p=0;const m=r._roots;for(let l=0,h=m.length;l<h;l++)a=m[l],o=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),n(0,p),p+=a.byteLength;function n(l,h,g=!1){const _=l*2;if(c[_+15]===vi){const v=o[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,T=-1/0,S=-1/0,P=-1/0;for(let C=v,R=v+y;C<R;C++){const E=3*r.resolveTriangleIndex(C);for(let A=0;A<3;A++){let M=E+A;M=i?i[M]:M;const I=s.getX(M),L=s.getY(M),F=s.getZ(M);I<x&&(x=I),I>T&&(T=I),L<w&&(w=L),L>S&&(S=L),F<b&&(b=F),F>P&&(P=F)}}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==T||u[l+4]!==S||u[l+5]!==P?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=T,u[l+4]=S,u[l+5]=P,!0):!1}else{const v=l+8,y=o[l+6],x=v+h,w=y+h;let b=g,T=!1,S=!1;e?b||(T=e.has(x),S=e.has(w),b=!T&&!S):(T=!0,S=!0);const P=b||T,C=b||S;let R=!1;P&&(R=n(v,h,b));let E=!1;C&&(E=n(y,h,b));const A=R||E;if(A)for(let M=0;M<3;M++){const I=v+M,L=y+M,F=u[I],O=u[I+3],H=u[L],W=u[L+3];u[l+M]=F<H?F:H,u[l+M+3]=O>W?O:W}return A}}}function Rc(r,e,t,i,s,a,o){U.setBuffer(r._roots[e]),rs(0,r,t,i,s,a,o),U.clearBuffer()}function rs(r,e,t,i,s,a,o){const{float32Array:c,uint16Array:u,uint32Array:p}=U,m=r*2;if(Q(m,u)){const l=K(r,p),h=te(m,u);gc(e,t,i,l,h,s,a,o)}else{const l=ie(r);Ee(l,c,i,a,o)&&rs(l,e,t,i,s,a,o);const h=se(r,p);Ee(h,c,i,a,o)&&rs(h,e,t,i,s,a,o)}}const Ic=["x","y","z"];function Ec(r,e,t,i,s,a){U.setBuffer(r._roots[e]);const o=ns(0,r,t,i,s,a);return U.clearBuffer(),o}function ns(r,e,t,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:u}=U;let p=r*2;if(Q(p,c)){const n=K(r,u),l=te(p,c);return vc(e,t,i,n,l,s,a)}else{const n=Jr(r,u),l=Ic[n],g=i.direction[l]>=0;let _,d;g?(_=ie(r),d=se(r,u)):(_=se(r,u),d=ie(r));const y=Ee(_,o,i,s,a)?ns(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=o[d+n]:b>=o[d+n+3])return y}const w=Ee(d,o,i,s,a)?ns(d,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Kt=new f.Box3,$e=new ce,Qe=new ce,St=new f.Matrix4,xr=new j,Jt=new j;function Dc(r,e,t,i){U.setBuffer(r._roots[e]);const s=os(0,r,t,i);return U.clearBuffer(),s}function os(r,e,t,i,s=null){const{float32Array:a,uint16Array:o,uint32Array:c}=U;let u=r*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),xr.set(t.boundingBox.min,t.boundingBox.max,i),s=xr),Q(u,o)){const m=e.geometry,n=m.index,l=m.attributes.position,h=t.index,g=t.attributes.position,_=K(r,c),d=te(u,o);if(St.copy(i).invert(),t.boundsTree)return N(r,a,Jt),Jt.matrix.copy(St),Jt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Jt.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_,w=d+_;x<w;x++)if(G(Qe,3*e.resolveTriangleIndex(x),n,l),Qe.needsUpdate=!0,y.intersectsTriangle(Qe))return!0;return!1}});for(let v=_,y=d+_;v<y;v++){const x=e.resolveTriangleIndex(v);G($e,3*x,n,l),$e.a.applyMatrix4(St),$e.b.applyMatrix4(St),$e.c.applyMatrix4(St),$e.needsUpdate=!0;for(let w=0,b=h.count;w<b;w+=3)if(G(Qe,w,h,g),Qe.needsUpdate=!0,$e.intersectsTriangle(Qe))return!0}}else{const m=r+8,n=c[r+6];return N(m,a,Kt),!!(s.intersectsBox(Kt)&&os(m,e,t,i,s)||(N(n,a,Kt),s.intersectsBox(Kt)&&os(n,e,t,i,s)))}}const ei=new f.Matrix4,zi=new j,Ct=new j,Lc=new f.Vector3,Fc=new f.Vector3,Bc=new f.Vector3,kc=new f.Vector3;function Oc(r,e,t,i={},s={},a=0,o=1/0){e.boundingBox||e.computeBoundingBox(),zi.set(e.boundingBox.min,e.boundingBox.max,t),zi.needsUpdate=!0;const c=r.geometry,u=c.attributes.position,p=c.index,m=e.attributes.position,n=e.index,l=re.getPrimitive(),h=re.getPrimitive();let g=Lc,_=Fc,d=null,v=null;s&&(d=Bc,v=kc);let y=1/0,x=null,w=null;return ei.copy(t).invert(),Ct.matrix.copy(ei),r.shapecast({boundsTraverseOrder:b=>zi.distanceToBox(b),intersectsBounds:(b,T,S)=>S<y&&S<o?(T&&(Ct.min.copy(b.min),Ct.max.copy(b.max),Ct.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:P=>Ct.distanceToBox(P),intersectsBounds:(P,C,R)=>R<y&&R<o,intersectsRange:(P,C)=>{for(let R=P,E=P+C;R<E;R++){const A=S.resolveTriangleIndex(R);G(h,3*A,n,m),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let M=b,I=b+T;M<I;M++){const L=r.resolveTriangleIndex(M);G(l,3*L,p,u),l.needsUpdate=!0;const F=l.distanceToTriangle(h,g,d);if(F<y&&(_.copy(g),v&&v.copy(d),y=F,x=M,w=R),F<a)return!0}}}})}else{const S=ht(e);for(let P=0,C=S;P<C;P++){G(h,3*P,n,m),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let R=b,E=b+T;R<E;R++){const A=r.resolveTriangleIndex(R);G(l,3*A,p,u),l.needsUpdate=!0;const M=l.distanceToTriangle(h,g,d);if(M<y&&(_.copy(g),v&&v.copy(d),y=M,x=R,w=P),M<a)return!0}}}}}),re.releasePrimitive(l),re.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ei),_.applyMatrix4(ei),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function zc(){return typeof SharedArrayBuffer<"u"}const Lt=new U.constructor,fi=new U.constructor,Se=new bs(()=>new f.Box3),Ze=new f.Box3,Xe=new f.Box3,Vi=new f.Box3,Ui=new f.Box3;let Hi=!1;function Vc(r,e,t,i){if(Hi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Hi=!0;const s=r._roots,a=e._roots;let o,c=0,u=0;const p=new f.Matrix4().copy(t).invert();for(let m=0,n=s.length;m<n;m++){Lt.setBuffer(s[m]),u=0;const l=Se.getPrimitive();N(0,Lt.float32Array,l),l.applyMatrix4(p);for(let h=0,g=a.length;h<g&&(fi.setBuffer(a[m]),o=ae(0,0,t,p,i,c,u,0,0,l),fi.clearBuffer(),u+=a[h].length,!o);h++);if(Se.releasePrimitive(l),Lt.clearBuffer(),c+=s[m].length,o)break}return Hi=!1,o}function ae(r,e,t,i,s,a=0,o=0,c=0,u=0,p=null,m=!1){let n,l;m?(n=fi,l=Lt):(n=Lt,l=fi);const h=n.float32Array,g=n.uint32Array,_=n.uint16Array,d=l.float32Array,v=l.uint32Array,y=l.uint16Array,x=r*2,w=e*2,b=Q(x,_),T=Q(w,y);let S=!1;if(T&&b)m?S=s(K(e,v),te(e*2,y),K(r,g),te(r*2,_),u,o+e,c,a+r):S=s(K(r,g),te(r*2,_),K(e,v),te(e*2,y),c,a+r,u,o+e);else if(T){const P=Se.getPrimitive();N(e,d,P),P.applyMatrix4(t);const C=ie(r),R=se(r,g);N(C,h,Ze),N(R,h,Xe);const E=P.intersectsBox(Ze),A=P.intersectsBox(Xe);S=E&&ae(e,C,i,t,s,o,a,u,c+1,P,!m)||A&&ae(e,R,i,t,s,o,a,u,c+1,P,!m),Se.releasePrimitive(P)}else{const P=ie(e),C=se(e,v);N(P,d,Vi),N(C,d,Ui);const R=p.intersectsBox(Vi),E=p.intersectsBox(Ui);if(R&&E)S=ae(r,P,t,i,s,a,o,c,u+1,p,m)||ae(r,C,t,i,s,a,o,c,u+1,p,m);else if(R)if(b)S=ae(r,P,t,i,s,a,o,c,u+1,p,m);else{const A=Se.getPrimitive();A.copy(Vi).applyMatrix4(t);const M=ie(r),I=se(r,g);N(M,h,Ze),N(I,h,Xe);const L=A.intersectsBox(Ze),F=A.intersectsBox(Xe);S=L&&ae(P,M,i,t,s,o,a,u,c+1,A,!m)||F&&ae(P,I,i,t,s,o,a,u,c+1,A,!m),Se.releasePrimitive(A)}else if(E)if(b)S=ae(r,C,t,i,s,a,o,c,u+1,p,m);else{const A=Se.getPrimitive();A.copy(Ui).applyMatrix4(t);const M=ie(r),I=se(r,g);N(M,h,Ze),N(I,h,Xe);const L=A.intersectsBox(Ze),F=A.intersectsBox(Xe);S=L&&ae(C,M,i,t,s,o,a,u,c+1,A,!m)||F&&ae(C,I,i,t,s,o,a,u,c+1,A,!m),Se.releasePrimitive(A)}}return S}const ti=new j,wr=new f.Box3,Uc={strategy:Zr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class As{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,o=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(u=>u.slice()),index:o?o.array.slice():null,indirectBuffer:a?a.slice():null}:c={roots:s,index:o?o.array:null,indirectBuffer:a},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:o}=e,c=new As(t,{...i,[Di]:!0});if(c._roots=a,c._indirectBuffer=o||null,i.setIndex){const u=t.getIndex();if(u===null){const p=new f.BufferAttribute(e.index,1,!1);t.setIndex(p)}else u.array!==s&&(u.array.set(s),u.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({...Uc,[Di]:!1},t),t.useSharedArrayBuffer&&!zc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Di]||(ic(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?Pc:mc)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);o(0);function o(c,u=0){const p=c*2,m=a[p+15]===vi;if(m){const n=s[c+6],l=a[p+14];e(u,m,new Float32Array(i,c*4,6),n,l)}else{const n=c+Dt/4,l=s[c+6],h=s[c+7];e(u,m,new Float32Array(i,c*4,6),h)||(o(n,u+1),o(l,u+1))}}}raycast(e,t=f.FrontSide,i=0,s=1/0){const a=this._roots,o=this.geometry,c=[],u=t.isMaterial,p=Array.isArray(t),m=o.groups,n=u?t.side:t,l=this.indirect?Rc:yc;for(let h=0,g=a.length;h<g;h++){const _=p?t[m[h].materialIndex].side:n,d=c.length;if(l(this,h,_,e,c,i,s),p){const v=m[h].materialIndex;for(let y=d,x=c.length;y<x;y++)c[y].face.materialIndex=v}}return c}raycastFirst(e,t=f.FrontSide,i=0,s=1/0){const a=this._roots,o=this.geometry,c=t.isMaterial,u=Array.isArray(t);let p=null;const m=o.groups,n=c?t.side:t,l=this.indirect?Ec:wc;for(let h=0,g=a.length;h<g;h++){const _=u?t[m[h].materialIndex].side:n,d=l(this,h,_,e,i,s);d!=null&&(p==null||d.distance<p.distance)&&(p=d,u&&(d.face.materialIndex=m[h].materialIndex))}return p}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?Dc:bc;for(let o=0,c=s.length;o<c&&(i=a(this,o,e,t),!i);o++);return i}shapecast(e){const t=re.getPrimitive(),i=this.indirect?_c:pc;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:o,intersectsTriangle:c}=e;if(o&&c){const n=o;o=(l,h,g,_,d)=>n(l,h,g,_,d)?!0:i(l,h,this,c,g,_,t)}else o||(c?o=(n,l,h,g)=>i(n,l,this,c,h,g,t):o=(n,l,h)=>h);let u=!1,p=0;const m=this._roots;for(let n=0,l=m.length;n<l;n++){const h=m[n];if(u=lc(this,n,a,o,s,p),u)break;p+=h.byteLength}return re.releasePrimitive(t),u}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const o=re.getPrimitive(),c=this.geometry.index,u=this.geometry.attributes.position,p=this.indirect?g=>{const _=this.resolveTriangleIndex(g);G(o,_*3,c,u)}:g=>{G(o,g*3,c,u)},m=re.getPrimitive(),n=e.geometry.index,l=e.geometry.attributes.position,h=e.indirect?g=>{const _=e.resolveTriangleIndex(g);G(m,_*3,n,l)}:g=>{G(m,g*3,n,l)};if(a){const g=(_,d,v,y,x,w,b,T)=>{for(let S=v,P=v+y;S<P;S++){h(S),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let C=_,R=_+d;C<R;C++)if(p(C),o.needsUpdate=!0,a(o,m,C,S,x,w,b,T))return!0}return!1};if(s){const _=s;s=function(d,v,y,x,w,b,T,S){return _(d,v,y,x,w,b,T,S)?!0:g(d,v,y,x,w,b,T,S)}}else s=g}return Vc(this,e,t,s)}intersectsBox(e,t){return ti.set(e.min,e.max,t),ti.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ti.intersectsBox(i),intersectsTriangle:i=>ti.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,o=1/0){return(this.indirect?Oc:Mc)(this,e,t,i,s,a,o)}closestPointToPoint(e,t={},i=0,s=1/0){return cc(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{N(0,new Float32Array(i),wr),e.union(wr)}),e}}class Hc{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 Nc extends Hc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:at&&at.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,a)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=p=>{a(new Error(`GenerateMeshBVHWorker: ${p.message}`))},e.onmessage=p=>{const{data:m}=p;if(m.error)a(new Error(m.error)),e.onmessage=null;else if(m.serialized){const{serialized:n,position:l}=m,h=As.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 _=new f.BufferAttribute(n.index,1,!1);t.setIndex(_)}g.setBoundingBox&&(t.boundingBox=h.getBoundingBox(new f.Box3)),i.onProgress&&i.onProgress(m.progress),s(h),e.onmessage=null}else i.onProgress&&i.onProgress(m.progress)};const o=t.index?t.index.array:null,c=t.attributes.position.array,u=[c];o&&u.push(o),e.postMessage({index:o,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},u.map(p=>p.buffer).filter(p=>typeof SharedArrayBuffer>"u"||!(p instanceof SharedArrayBuffer)))})}}class Wc{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 ut,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,a)=>s.position.z>a.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 a=this.domElement.width/this.domElement.clientWidth,o=this.domElement.height/this.domElement.clientHeight,{left:c,top:u}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-u)*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 a=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),a!==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 a=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const o=this.camera.position.distanceTo(this.orbit.target);a.multiplyScalar(o),this.selectedAxis.axis==="z"?a.setZ(this.orbit.target.z+o):this.selectedAxis.axis==="-z"?a.setZ(this.orbit.target.z-o):a.setZ(this.orbit.target.z);const c=500,u=performance.now(),p=1,m=this.selectedAxis.axis,n=()=>{const h=performance.now()-u,g=Math.min(h/c,p);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==p){this._animator=window.requestAnimationFrame(n);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",m);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",m),n()},this.drawCircle=(s,a=10,o="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-a,s.y-a,a*2,a*2),this.context.fillStyle=o,this.context.fill(),this.context.closePath())},this.drawLine=(s,a,o=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(a.x,a.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(a=>{const o=this.selectedAxis===a,c=a.position.z>=-.01?a.color[0]:a.color[1];if(a.line&&this.drawLine(this.center,a.position,a.line,c),this.drawCircle(a.position,a.size,o?"#0066ff":c),a.label){const u=a.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,u+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(a.label,a.position.x,a.position.y)}}))},this.setAxisPosition=s=>{const a=s.direction.clone().applyMatrix4(this.invRotMat),o=s.size;s.position.set(a.x*(this.center.x-o/2-this.options.padding)+this.center.x,this.center.y-a.y*(this.center.y-o/2-this.options.padding),a.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 a=i.getAttribute("data-function");a&&this.dispatchEvent(new CustomEvent("function-removed",{detail:a}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const a=i.getAttribute("data-function");a&&(this.dispatchEvent(new CustomEvent("function-added",{detail:a})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",Dr);const q={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 Wi extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new ct,this._slotContainer=new d.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 d.Vector3,this._wrapper=new d.Group,this._showSlot=!0,this._isMirror=!1,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new Dr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(q.ON_DEVICE_DELETED)}}),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(q.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 a;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(a=i.dataTransfer)==null?void 0:a.getData("application/json");if(s){const o=JSON.parse(s);try{await this.install(o),this._emitter.emit(q.ON_DROP,this)}catch(c){this._emitter.emit(q.ON_DROP_ERROR,c)}}else this._emitter.emit(q.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){var i;if(this.props.follows.has(e)){const s=this.props.follows.get(e);if(s){let a="x";["height","mast"].includes(e)?a="y":["width","liftOuterWidth"].includes(e)&&(a="z");const o=((i=this.props.slot)==null?void 0:i.position[a])>0?1:-1;this._wrapper.position[a]=(t-s.origin)*s.scale*o}}}async loadGlb(e){const i=await new ni({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new ni({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(a=>{a.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){if(!this._loading){this._loading=!0;try{const t=await this.loadGlb(e.url);if(!t)throw new Error(`Fail to load device from: ${e.url}`);if(t.traverse(i=>{i.userData.isDevice=!0}),this.isMirror&&t.scale.set(1,1,-1),e.bracketUrl){const i=await this.loadGlb(e.bracketUrl);if(i)this.clearSlot(),this._emitter.emit(q.ON_DEVICE_REPLACED),i.traverse(s=>{s.name.startsWith("Slot")&&this._bracketSlots.push(s),s.userData.isBracket=!0}),this._slotContainer.add(i);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(s=>{s.add(t)})}else this.clearSlot(),this._emitter.emit(q.ON_DEVICE_REPLACED),this._slotContainer.add(t);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1)}catch(t){throw t}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(q.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(q.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._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),xe(e)}),this._slotUI.filled=!1,this.deviceInfo=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(q.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(q.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(q.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(q.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.clearSlot(),this._emitter.removeAllListeners(),xe(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 d.Vector2(parseFloat(i[1]),parseFloat(i[2])),a=e.mousePos.distanceTo(s);let o=this.props.isMobile?12:18,c=38,u=30;if(this._canInstall&&(o=34,c=60,u=60),a<u){let f=(u-a)*1+o;a<20&&(f=c),f>c&&(f=c),this._slotUI.setSize(f)}else this._slotUI.setSize(o)}clone(e){return new d.Group}}class Ja extends fe.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 a="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:a,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:a,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 u;o.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(u=this.onPointMove)==null||u.call(this)}),this._text.addEventListener("pointerleave",()=>{var u;o.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(u=this.onPointLeave)==null||u.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class ti extends d.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new Ja(""),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;(e=this._line.geometry)==null||e.dispose(),this._line.computeLineDistances()}update(e,t,i=0){var h,g;(h=this._line.geometry)==null||h.dispose(),this._line.geometry.setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new d.Vector3().subVectors(t,e).normalize();let o;Math.abs(a.z)>Math.abs(a.x)&&Math.abs(a.z)>Math.abs(a.y)?o=new d.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?o=new d.Vector3(1,0,0):o=new d.Vector3(0,1,0),o.length()<.001&&(Math.abs(a.x)<.9?o=new d.Vector3(1,0,0):o=new d.Vector3(0,1,0)),o.normalize();const c=new d.Vector3().addVectors(e,o.clone().multiplyScalar(s)),u=new d.Vector3().addVectors(e,o.clone().multiplyScalar(-s)),f=new d.Vector3().addVectors(t,o.clone().multiplyScalar(s)),p=new d.Vector3().addVectors(t,o.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new d.BufferGeometry,this._line2.geometry.setFromPoints([c,u,f,p]),this._line2.computeLineDistances();const r=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(r*1e3).toFixed(0)} mm`:this._text.text=`${(r*1e3).toFixed(0)} mm`;const l=new d.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=>xe(e)),this.removeFromParent()}}class Lr extends d.Object3D{constructor(e,t){super(),this.radius=e,this._text=new $a(""),this._line=new ti(void 0,!1,!1),this._box=new d.Mesh,this._arc=new dn.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new d.RingGeometry(e,e+.003,128),this._box.material=new d.MeshBasicMaterial({color:"#666",side:d.DoubleSide}),this._arc.geometry=new vs.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new pn.LineMaterial({color:"#eee",linewidth:2,resolution:new d.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 d.RingGeometry(e,e+.003,128),this._line.updateMaterial(new d.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 d.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 u=i-this._lastAngle;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI),this._accumulatedAngle+=u}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),a=s+this._accumulatedAngle;let o=.006*this.radius;o<.003&&(o=.003),o>.006&&(o=.006);const c=this._createArcGeometry(s,a,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=[],a=t-e,o=Math.max(128,Math.floor(Math.abs(a)/(Math.PI/128))),c=a/o;for(let f=0;f<=o;f++){const p=e+f*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const u=new vs.LineGeometry;return u.setPositions(s),u.instanceCount=Math.max(0,s.length/3-1),u}}class $a extends fe.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 el="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",tl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",Ys="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==",il="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 Qs extends fe.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new ct,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 c=(Date.now()-this._startAt)/200;c>4&&(c=4);let u=this._initial+.005*c*this._direction;if(u>this.props.max||u<this.props.min){this.mechanism&&(u<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):u>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=u,!this.mechanism)return;this.mechanism.position.setZ(u),this._emitter.emit("change",u)}};const s=cs();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(c=>{c.name===e.userData.target.name&&(this.mechanism=c)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const a=document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.transform="translateX(-50%) rotate(-180deg)",a.style.marginBottom="5px",a.style.width=a.style.height=s?"34px":"44px",a.style.background=`url(${Ys}) center no-repeat`,a.style.backgroundSize="100% auto",a.setAttribute("data-direction","up"),a.style.transition="all .2s";const o=document.createElement("div");if(o.style.position="absolute",o.style.left="0",o.style.transform="translateX(-50%)",a.style.bottom=o.style.top="8px",o.style.width=o.style.height=a.style.width,o.style.background=`url(${Ys}) center no-repeat`,o.style.backgroundSize="100% auto",o.style.transition="all .2s",o.setAttribute("data-direction","down"),Array.from([a,o]).forEach(c=>{s||c.addEventListener("mousemove",()=>{c.style.filter="invert(100%)"}),c.addEventListener("mouseleave",()=>{c.style.filter=""}),c.addEventListener("pointerdown",()=>{this.mechanism&&(c.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=c.getAttribute("data-direction")==="up"?1:-1,this._update())}),c.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""}),c.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:c,rotateDuration:u,rotateStep:f,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(h=>{h.name===c.name&&(l=h)}),l)){const h=document.createElement("div");h.style.background=`url(${il}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.position="absolute",h.style.top="-50%",h.style.left="-50%",h.style.width=s?"140px":"160px",h.style.height=s?"70px":"80px",h.style.transform="translateX(-50%) translateY(-50%)",i.append(h);const g=document.createElement("div");g.style.background=`url(${tl}) center no-repeat`,g.style.backgroundSize="100% auto",g.style.width=g.style.height=s?"20px":"26px",g.style.position="absolute",g.style.top="0",g.style.transform="translateY(-50%)",g.style.marginBottom="5px",g.setAttribute("data-direction","left"),i.append(g);const _=document.createElement("div");_.style.background=`url(${el}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.width=_.style.height=s?"20px":"26px",_.style.position="absolute",g.style.left=_.style.right=s?"62px":"69px",_.style.top="0",_.style.transform="translateY(-50%)",_.style.marginBottom="5px",_.setAttribute("data-direction","right"),i.append(_),Array.from([g,_]).forEach(m=>{s||m.addEventListener("mousemove",()=>{m.style.filter="invert(100%)"}),m.addEventListener("mouseleave",()=>{m.style.filter=""}),m.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;m.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=m.getAttribute("data-direction")==="left"?1:-1;let v=f/180*Math.PI*this._direction+l.rotation.z;v>p/180*Math.PI?v=p/180*Math.PI:v<r/180*Math.PI&&(v=r/180*Math.PI),this._timer=new It(l.rotation).to({z:v}).duration(u).start(),this._update()}),m.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""}),m.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""})})}}i.append(a,o),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 fe.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof fe.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class sl extends mn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new ct,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new d.Vector2,this._targetSize=new d.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=u=>{const{pageX:f,pageY:p}=u;this.endNode.setPointerCapture(u.pointerId),this._mouseStart.set(f,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=u=>{if(!this._mouseStart.x)return;const{pageX:f,pageY:p}=u;let r=f-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const h=l%10;l=l-h,r=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(r=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=u=>{this.endNode.releasePointerCapture(u.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,a=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=a.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]=a*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 rl extends d.Object3D{constructor(){super(),this._box3=new d.Box3,this._line11=new ti("长:"),this._line12=new ti("宽:"),this._line13=new ti("高:"),this._outline=new Lr(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 fe.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 fe.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:a,hasHeight:o,hasWidth:c}=Na(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=a,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 u=this._box3.min.x,f=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,h=this._box3.max.y;let g=.2;const _=new d.Vector3(u,h,0),m=new d.Vector3(f,h,0);this._line11.update(_.clone().sub(new d.Vector3(0,-g/1.8,0)),m.clone().sub(new d.Vector3(0,-g/1.8,0)),this._radius);const v=new d.Vector3(f,l,0);this._line12.update(m.clone().add(new d.Vector3(g,0,0)),v.clone().add(new d.Vector3(g,0,0)),this._radius);const y=new d.Vector3(u,h,p),x=new d.Vector3(u,h,r),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class Zs extends d.Object3D{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._generate(e,t,i)}clearAll(){xe(this)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}_generate(e,t,i){this.clearAll();const s=new d.Mesh(new d.BoxGeometry(e,t,i),new d.MeshBasicMaterial({color:new d.Color("#0f5fd5"),transparent:!0,opacity:.4}));s.geometry.translate(0,0,i/2);const a=new d.EdgesGeometry(s.geometry),o=new d.LineDashedMaterial({color:new d.Color("#000"),dashSize:.015,gapSize:.015}),c=new d.LineSegments(a,o);c.computeLineDistances(),this.add(s,c)}}const nl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Gi{constructor(e){this._props=e,this.name="",this.transparentTexture=us.load(nl),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 d.Vector2(1,1),i=new d.Vector2){this.imageUrl=e;let s;if(e){const a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var f;let o=window.devicePixelRatio*2;this._offscreen.width=a.width+o,this._offscreen.height=a.height+o;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(a,o/2,o/2,a.width,a.height),s=new d.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=d.SRGBColorSpace,s.wrapS=s.wrapT=d.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const u=this._props.target;u.material&&((f=u.material.map)==null||f.dispose(),s?(u.material.map=s,u.material.opacity=1):(u.material.map=this.transparentTexture,u.material.opacity=0))}}else{const a=this._props.target;a.material&&(a.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 ol(n){return n.type?n.type==="Mesh":n.isMesh}const us=new d.TextureLoader;us.crossOrigin="anonymous";class Er extends d.Object3D{constructor(e){super(),this._props=e,this._emitter=new ct,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new d.Group,this.lines=new d.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new d.Clock,this.sizeBox=new rl,this._goodsSize=new Ga(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,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._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],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 d.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((e=this._lift)==null?void 0:e.position.z)||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}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 d.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._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{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 d.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof Wi&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new d.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)})}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 lt.loadAsync(e);i=o.scene,s=o.animations||[]}else{const c=await new ni({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=vn.clone(i);this._generateAmr(a,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 d.Vector2(t.scaleX,t.scaleY),new d.Vector2(t.ox,t.oy))}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this._container.traverse(s=>{if(!Object.keys(s.morphTargetDictionary||{}).includes(e))return;let a=t;s.userData[`origin_${e}`]&&(a-=s.userData[`origin_${e}`]);const o=s.morphTargetDictionary[e];s.morphTargetInfluences&&(s.morphTargetInfluences[o]=a),s instanceof d.Mesh&&s.geometry.translate(0,0,1e-5)}),i&&this._emitter.emit("shape-key-changed",e,t)},100)}_generateAmr(e,t){this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new d.AnimationMixer(e),this._clips=t,t.forEach(i=>{const s=this._mixer.clipAction(i);this._actionsMap.set(i.name,s)}),this.actions=t.map(i=>i.name)),e.traverse(i=>{i.userData.isShelf&&(this._shelf=i),i.userData.isFork&&(this._fork=i),i.userData.isMast&&i.userData.mastLevel&&this._masts.set(i.userData.mastLevel,i),i.userData.isJack&&(this._jack=i),i.userData.isLift&&(this._lift=i),Object.keys(i.morphTargetDictionary||{}).forEach(s=>{let a=i.morphTargetInfluences[i.morphTargetDictionary[s]];i.userData[`origin_${s}`]&&(a+=i.userData[`origin_${s}`]),this._shapeKeys.has(s)||this._shapeKeys.set(s,a)})}),e.traverse(i=>{if(i instanceof d.Mesh){if(i.castShadow=!0,i.receiveShadow=!0,i.material)if(Array.isArray(i.material))i.material.forEach(a=>{a.userData.changeColor&&(this.skins.find(o=>o.name===a.userData.name)||this.skins.push(new es({name:a.userData.name,target:a})))});else{if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new d.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,o=new ye.Tween(i.material).to({emissiveIntensity:.2}).easing(ye.Easing.Quintic.InOut).duration(a),c=new ye.Tween(i.material).to({emissiveIntensity:2}).easing(ye.Easing.Quintic.InOut).duration(a);o.onComplete(()=>c.start()),c.onComplete(()=>o.start()),o.start(),this._breathLights.push(o,c)}i.material.userData.changeColor&&(this.skins.find(a=>a.name===i.material.userData.name)||this.skins.push(new es({name:i.material.userData.name,target:i.material})))}if(i.material)if(Array.isArray(i.material))i.material.forEach(o=>{if(o.userData.isLOGO){i.material.transparent=!0;let c;const u={width:0,height:0};i.material.map&&i.material.map.image&&(u.width=i.material.map.image.width,u.height=i.material.map.image.height,c=Ni(i.material.map.image));const f=new Gi({name:o.userData.name,target:i,size:Ws(i),imageSize:u,imageUrl:c});this._logos.push(f)}o.userData.isTransparent&&(o.transparent=!0),this._materialsCache.set(o.uuid,{opacity:o.opacity,transparent:o.transparent,roughness:o.roughness,metalness:o.metalness,color:o.color,mat:o})});else{const a=i.material;if(a.userData.isLOGO){i.material.transparent=!0;let o;const c={width:0,height:0};i.material.map&&i.material.map.image&&(c.width=i.material.map.image.width,c.height=i.material.map.image.height,o=Ni(i.material.map.image));const u=new Gi({name:a.userData.name,target:i,size:Ws(i),imageSize:c,imageUrl:o});this._logos.push(u)}a.userData.isTransparent&&(a.transparent=!0),this._materialsCache.set(a.uuid,{opacity:a.opacity,transparent:a.transparent,roughness:a.roughness,metalness:a.metalness,color:a.color,mat:a})}}this.generateController(i,e),this.generateDimension(i,e);const s=this.generateSlot(i,e);s&&this._slots.push(s),i.userData.isOrigin&&Object.keys(i.userData).forEach(o=>{if(o.startsWith("follow_")){const c=o.replace("follow_","");this.shapeKeys.has(c)&&(this.sizeBox.follow=c,this.sizeBox.followOrigin=this._shapeKeys.get(c)||0,this.sizeBox.followScale=i.userData[o])}})}),this.slots.forEach(i=>{i.props.mirrorTarget&&(i.mirrorTarget=this.slots.find(s=>s.props.slot.name===i.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this.sizeBox.generate(e),this.sizeBox.show()}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){this._lift&&(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(a=>{a.name.toLowerCase().includes("lift")&&(a.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)}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-5)}setShelfLevel(e=3){var s;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset;this._shelves.delete(0),this._shelves.forEach(a=>{xe(a),a.parent&&a.removeFromParent()}),this.goods=[],this._shelves.clear(),this._shelves.set(0,this._shelf);for(let a=1;a<e;a++){if(!this._shelf)return;this._shelf.traverse(u=>{ol(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",this._goodsSize.length))});const o=this._shelf.clone(!0);o.position.z+=t*a,this._shelves.set(a,o),(s=this._shelf.parent)==null||s.add(o);let c;if(o.traverse(u=>{u.userData.isShelfContainer&&(c=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&(c==null||c.position.setX((c==null?void 0:c.position.x)-this._goodsSize.length/2)),c){const u=new Zs(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(u),this.goods.push(u),a===1){const f=new Zs(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);f.position.z-=t,c.add(f),this.goods.push(f)}}}const i=this.getShelfMinHeight()||0;this._liftMaxHeight<i&&this.setLiftMaxHeight(i)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new Lr(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:a}=e.userData;let o;if(t.traverse(u=>{u.name===i&&(o=u)}),!o)return;const c=new Qs({name:"",target:i,default:0,min:s,max:a},o);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let o;if(t.traverse(u=>{u.name===i&&(o=u)}),!o)return;const c=new Qs({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:a||1},o);e.add(c),this.controllers.push(c),(o.userData.isFork||o.userData.isLift||o.userData.isJack)&&(this._forkMaxHeight=a||1,this._liftMaxHeight=a||1,this._jackMaxHeight=a||1,c.addListener("change",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=Ua(e.userData.startOrigin),a=e.userData.axios;let o,c;if(a==="x"?(o=new d.Vector3(e.userData.start-e.position.x,0,0),c=o.clone().setX(e.userData.end-e.position.x)):a==="z"?(o=new d.Vector3(0,e.userData.start-e.position.y,0),c=o.clone().setY(e.userData.end-e.position.y)):(o=new d.Vector3(0,0,e.userData.start-e.position.z),c=o.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(r=>r.startsWith("target")?e.userData[r].name:[]).length)return;const p=new sl({start:o,end:c,startOrigin:s,axios:a,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const a=e.userData.name,o=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(a){const u=e.userData.holeTarget&&e.userData.holeTarget.name;let f;u&&t.traverse(h=>{h.name===u&&(f=h)});const p=new Map;Object.keys(e.userData).forEach(h=>{if(h.startsWith("follow_")){const g=h.split("_")[1];if(g){let _=e.userData[h];p.set(g,{scale:_,origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new Wi({name:a,follows:p,slot:e,show:this._showSlots,isMirror:o,mirrorTarget:c,isMobile:r});return l.holeTarget=f,l.addEventListener(q.ON_DROP,h=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(q.ON_BEFORE_SELECTED,h=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(q.ON_ERROR_STATE_CHANGE,h=>{if(this._app)if(this._app._outlinePassError.selectedObjects=this._app._outlinePassError.selectedObjects.filter(g=>!!g.parent),h){if(l.device){if(this._app._outlinePassError.selectedObjects.find(_=>{var m;return _.parent==((m=l.device)==null?void 0:m.parent)}))return;this._app._outlinePassError.selectedObjects=[l.device,...this._app._outlinePassError.selectedObjects]}}else l.device&&(this._app._outlinePassError.selectedObjects=this._app._outlinePassError.selectedObjects.filter(g=>{var _;return g.parent!=((_=l.device)==null?void 0:_.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],xe(this._container),this._levels.forEach(e=>e.destroy()),this._levels.clear(),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._mixer&&this._mixer.stopAllAction(),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],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=!0,i){const s=this._actionsMap.get(e);return!s||!this._mixer?Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`)):(t&&s.reset(),this._actionsMap.forEach((a,o)=>{o!==e&&a.stop()}),s.enabled=!0,s.paused=!1,s.setLoop(d.LoopOnce,0),s.setEffectiveTimeScale((i==null?void 0:i.timeScale)??1),s.setEffectiveWeight(1),s.clampWhenFinished=(i==null?void 0:i.clampWhenFinished)??!0,i!=null&&i.fadeIn&&i.fadeIn>0&&s.fadeIn(i.fadeIn),new Promise(a=>{const o=c=>{var u;c.action===s&&((u=this._mixer)==null||u.removeEventListener("finished",o),a())};this._mixer.addEventListener("finished",o),s.play()}))}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}}const Fr=0,al=1,ll=2,Xs=2,Ti=1.25,Ks=1,Pt=6*4+4+4,hi=65535,cl=Math.pow(2,-24),Si=Symbol("SKIP_GENERATION");function ul(n){return n.index?n.index.count:n.attributes.position.count}function ut(n){return ul(n)/3}function hl(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function fl(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=hl(t,i);n.setIndex(new d.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Br(n){const e=ut(n),t=n.drawRange,i=t.start/3,s=(t.start+t.count)/3,a=Math.max(0,i),o=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function kr(n){if(!n.groups||!n.groups.length)return Br(n);const e=[],t=new Set,i=n.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of n.groups){const u=c.start/3,f=(c.start+c.count)/3;t.add(Math.max(s,u)),t.add(Math.min(a,f))}const o=Array.from(t.values()).sort((c,u)=>c-u);for(let c=0;c<o.length-1;c++){const u=o[c],f=o[c+1];e.push({offset:Math.floor(u),count:Math.floor(f-u)})}return e}function dl(n){if(n.groups.length===0)return!1;const e=ut(n),t=kr(n).sort((a,o)=>a.offset-o.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:a})=>s+=a),e!==s}function Mi(n,e,t,i,s){let a=1/0,o=1/0,c=1/0,u=-1/0,f=-1/0,p=-1/0,r=1/0,l=1/0,h=1/0,g=-1/0,_=-1/0,m=-1/0;for(let v=e*6,y=(e+t)*6;v<y;v+=6){const x=n[v+0],w=n[v+1],b=x-w,A=x+w;b<a&&(a=b),A>u&&(u=A),x<r&&(r=x),x>g&&(g=x);const S=n[v+2],I=n[v+3],M=S-I,P=S+I;M<o&&(o=M),P>f&&(f=P),S<l&&(l=S),S>_&&(_=S);const R=n[v+4],T=n[v+5],C=R-T,D=R+T;C<c&&(c=C),D>p&&(p=D),R<h&&(h=R),R>m&&(m=R)}i[0]=a,i[1]=o,i[2]=c,i[3]=u,i[4]=f,i[5]=p,s[0]=r,s[1]=l,s[2]=h,s[3]=g,s[4]=_,s[5]=m}function pl(n,e=null,t=null,i=null){const s=n.attributes.position,a=n.index?n.index.array:null,o=ut(n),c=s.normalized;let u;e===null?(u=new Float32Array(o*6*4),t=0,i=o):(u=e,t=t||0,i=i||o);const f=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let h=t;h<t+i;h++){const g=h*3,_=h*6;let m=g+0,v=g+1,y=g+2;a&&(m=a[m],v=a[v],y=a[y]),c||(m=m*r+p,v=v*r+p,y=y*r+p);for(let x=0;x<3;x++){let w,b,A;c?(w=s[l[x]](m),b=s[l[x]](v),A=s[l[x]](y)):(w=f[m+x],b=f[v+x],A=f[y+x]);let S=w;b<S&&(S=b),A<S&&(S=A);let I=w;b>I&&(I=b),A>I&&(I=A);const M=(I-S)/2,P=x*2;u[_+P+0]=S+M,u[_+P+1]=M+(Math.abs(S)+M)*cl}}return u}function N(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function Js(n){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=n[i+3]-n[i];s>t&&(t=s,e=i)}return e}function $s(n,e){e.set(n)}function er(n,e,t){let i,s;for(let a=0;a<3;a++){const o=a+3;i=n[a],s=e[a],t[a]=i<s?i:s,i=n[o],s=e[o],t[o]=i>s?i:s}}function Ut(n,e,t){for(let i=0;i<3;i++){const s=e[n+2*i],a=e[n+2*i+1],o=s-a,c=s+a;o<t[i]&&(t[i]=o),c>t[i+3]&&(t[i+3]=c)}}function yt(n){const e=n[3]-n[0],t=n[4]-n[1],i=n[5]-n[2];return 2*(e*t+t*i+i*e)}const me=32,ml=(n,e)=>n.candidate-e.candidate,Te=new Array(me).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ht=new Float32Array(6);function gl(n,e,t,i,s,a){let o=-1,c=0;if(a===Fr)o=Js(e),o!==-1&&(c=(e[o]+e[o+3])/2);else if(a===al)o=Js(n),o!==-1&&(c=vl(t,i,s,o));else if(a===ll){const u=yt(n);let f=Ti*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const h=e[l],m=(e[l+3]-h)/me;if(s<me/4){const v=[...Te];v.length=s;let y=0;for(let w=p;w<r;w+=6,y++){const b=v[y];b.candidate=t[w+2*l],b.count=0;const{bounds:A,leftCacheBounds:S,rightCacheBounds:I}=b;for(let M=0;M<3;M++)I[M]=1/0,I[M+3]=-1/0,S[M]=1/0,S[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;Ut(w,t,A)}v.sort(ml);let x=s;for(let w=0;w<x;w++){const b=v[w];for(;w+1<x&&v[w+1].candidate===b.candidate;)v.splice(w+1,1),x--}for(let w=p;w<r;w+=6){const b=t[w+2*l];for(let A=0;A<x;A++){const S=v[A];b>=S.candidate?Ut(w,t,S.rightCacheBounds):(Ut(w,t,S.leftCacheBounds),S.count++)}}for(let w=0;w<x;w++){const b=v[w],A=b.count,S=s-b.count,I=b.leftCacheBounds,M=b.rightCacheBounds;let P=0;A!==0&&(P=yt(I)/u);let R=0;S!==0&&(R=yt(M)/u);const T=Ks+Ti*(P*A+R*S);T<f&&(o=l,f=T,c=b.candidate)}}else{for(let x=0;x<me;x++){const w=Te[x];w.count=0,w.candidate=h+m+x*m;const b=w.bounds;for(let A=0;A<3;A++)b[A]=1/0,b[A+3]=-1/0}for(let x=p;x<r;x+=6){let A=~~((t[x+2*l]-h)/m);A>=me&&(A=me-1);const S=Te[A];S.count++,Ut(x,t,S.bounds)}const v=Te[me-1];$s(v.bounds,v.rightCacheBounds);for(let x=me-2;x>=0;x--){const w=Te[x],b=Te[x+1];er(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<me-1;x++){const w=Te[x],b=w.count,A=w.bounds,I=Te[x+1].rightCacheBounds;b!==0&&(y===0?$s(A,Ht):er(A,Ht,Ht)),y+=b;let M=0,P=0;y!==0&&(M=yt(Ht)/u);const R=s-y;R!==0&&(P=yt(I)/u);const T=Ks+Ti*(M*y+P*R);T<f&&(o=l,f=T,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:o,pos:c}}function vl(n,e,t,i){let s=0;for(let a=e,o=e+t;a<o;a++)s+=n[a*6+i*2];return s/t}class Ci{constructor(){this.boundingData=new Float32Array(6)}}function _l(n,e,t,i,s,a){let o=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;o<=c&&t[o*6+f]<u;)o++;for(;o<=c&&t[c*6+f]>=u;)c--;if(o<c){for(let p=0;p<3;p++){let r=e[o*3+p];e[o*3+p]=e[c*3+p],e[c*3+p]=r}for(let p=0;p<6;p++){let r=t[o*6+p];t[o*6+p]=t[c*6+p],t[c*6+p]=r}o++,c--}else return o}}function yl(n,e,t,i,s,a){let o=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;o<=c&&t[o*6+f]<u;)o++;for(;o<=c&&t[c*6+f]>=u;)c--;if(o<c){let p=n[o];n[o]=n[c],n[c]=p;for(let r=0;r<6;r++){let l=t[o*6+r];t[o*6+r]=t[c*6+r],t[c*6+r]=l}o++,c--}else return o}}function Z(n,e){return e[n+15]===65535}function J(n,e){return e[n+6]}function te(n,e){return e[n+14]}function ie(n){return n+8}function se(n,e){return e[n+6]}function Or(n,e){return e[n+7]}let zr,Mt,ii,Vr;const xl=Math.pow(2,32);function qi(n){return"count"in n?1:1+qi(n.left)+qi(n.right)}function wl(n,e,t){return zr=new Float32Array(t),Mt=new Uint32Array(t),ii=new Uint16Array(t),Vr=new Uint8Array(t),ji(n,e)}function ji(n,e){const t=n/4,i=n/2,s="count"in e,a=e.boundingData;for(let o=0;o<6;o++)zr[t+o]=a[o];if(s)if(e.buffer){const o=e.buffer;Vr.set(new Uint8Array(o),n);for(let c=n,u=n+o.byteLength;c<u;c+=Pt){const f=c/2;Z(f,ii)||(Mt[c/4+6]+=t)}return n+o.byteLength}else{const o=e.offset,c=e.count;return Mt[t+6]=o,ii[i+14]=c,ii[i+15]=hi,n+Pt}else{const o=e.left,c=e.right,u=e.splitAxis;let f;if(f=ji(n+Pt,o),f/4>xl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Mt[t+6]=f/4,f=ji(f,c),Mt[t+7]=u,f}}function bl(n,e){const t=(n.index?n.index.count:n.attributes.position.count)/3,i=t>2**16,s=i?4:2,a=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),o=i?new Uint32Array(a):new Uint16Array(a);for(let c=0,u=o.length;c<u;c++)o[c]=c;return o}function Al(n,e,t,i,s){const{maxDepth:a,verbose:o,maxLeafTris:c,strategy:u,onProgress:f,indirect:p}=s,r=n._indirectBuffer,l=n.geometry,h=l.index?l.index.array:null,g=p?yl:_l,_=ut(l),m=new Float32Array(6);let v=!1;const y=new Ci;return Mi(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){f&&f(b/_)}function w(b,A,S,I=null,M=0){if(!v&&M>=a&&(v=!0,o&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),S<=c||M>=a)return x(A+S),b.offset=A,b.count=S,b;const P=gl(b.boundingData,I,e,A,S,u);if(P.axis===-1)return x(A+S),b.offset=A,b.count=S,b;const R=g(r,h,e,A,S,P);if(R===A||R===A+S)x(A+S),b.offset=A,b.count=S;else{b.splitAxis=P.axis;const T=new Ci,C=A,D=R-A;b.left=T,Mi(e,C,D,T.boundingData,m),w(T,C,D,m,M+1);const E=new Ci,F=R,O=S-D;b.right=E,Mi(e,F,O,E.boundingData,m),w(E,F,O,m,M+1)}return b}}function Tl(n,e){const t=n.geometry;e.indirect&&(n._indirectBuffer=bl(t,e.useSharedArrayBuffer),dl(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.')),n._indirectBuffer||fl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=pl(t),a=e.indirect?Br(t):kr(t);n._roots=a.map(o=>{const c=Al(n,s,o.offset,o.count,e),u=qi(c),f=new i(Pt*u);return wl(0,c,f),f})}class we{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,o=e.length;a<o;a++){const u=e[a][t];i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let a=0,o=t.length;a<o;a++){const c=t[a],u=e.dot(c);i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}we.prototype.setFromBox=function(){const n=new d.Vector3;return function(t,i){const s=i.min,a=i.max;let o=1/0,c=-1/0;for(let u=0;u<=1;u++)for(let f=0;f<=1;f++)for(let p=0;p<=1;p++){n.x=s.x*u+a.x*(1-u),n.y=s.y*f+a.y*(1-f),n.z=s.z*p+a.z*(1-p);const r=t.dot(n);o=Math.min(r,o),c=Math.max(r,c)}this.min=o,this.max=c}}();const Sl=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Vector3;return function(s,a,o){const c=s.start,u=n,f=a.start,p=e;t.subVectors(c,f),n.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(u),h=p.dot(p),g=t.dot(u),m=u.dot(u)*h-l*l;let v,y;m!==0?v=(r*l-g*h)/m:v=0,y=(r+v*l)/h,o.x=v,o.y=y}}(),hs=function(){const n=new d.Vector2,e=new d.Vector3,t=new d.Vector3;return function(s,a,o,c){Sl(s,a,n);let u=n.x,f=n.y;if(u>=0&&u<=1&&f>=0&&f<=1){s.at(u,o),a.at(f,c);return}else if(u>=0&&u<=1){f<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,o);return}else if(f>=0&&f<=1){u<0?s.at(0,o):s.at(1,o),a.closestPointToPoint(o,!0,c);return}else{let p;u<0?p=s.start:p=s.end;let r;f<0?r=a.start:r=a.end;const l=e,h=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=h.distanceToSquared(p)){o.copy(l),c.copy(r);return}else{o.copy(p),c.copy(h);return}}}}(),Ml=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Plane,i=new d.Line3;return function(a,o){const{radius:c,center:u}=a,{a:f,b:p,c:r}=o;if(i.start=f,i.end=p,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c||(i.start=f,i.end=r,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c))return!0;const _=o.getPlane(t);if(Math.abs(_.distanceToPoint(u))<=c){const v=_.projectPoint(u,e);if(o.containsPoint(v))return!0}return!1}}(),Cl=1e-15;function Ii(n){return Math.abs(n)<Cl}class ce extends d.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new d.Vector3),this.satBounds=new Array(4).fill().map(()=>new we),this.points=[this.a,this.b,this.c],this.sphere=new d.Sphere,this.plane=new d.Plane,this.needsUpdate=!0}intersectsSphere(e){return Ml(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,o=this.satBounds,c=a[0],u=o[0];this.getNormal(c),u.setFromPoints(c,s);const f=a[1],p=o[1];f.subVectors(e,t),p.setFromPoints(f,s);const r=a[2],l=o[2];r.subVectors(t,i),l.setFromPoints(r,s);const h=a[3],g=o[3];h.subVectors(i,e),g.setFromPoints(h,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}ce.prototype.closestPointToSegment=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Line3;return function(s,a=null,o=null){const{start:c,end:u}=s,f=this.points;let p,r=1/0;for(let l=0;l<3;l++){const h=(l+1)%3;t.start.copy(f[l]),t.end.copy(f[h]),hs(t,s,n,e),p=n.distanceToSquared(e),p<r&&(r=p,a&&a.copy(n),o&&o.copy(e))}return this.closestPointToPoint(c,n),p=c.distanceToSquared(n),p<r&&(r=p,a&&a.copy(n),o&&o.copy(c)),this.closestPointToPoint(u,n),p=u.distanceToSquared(n),p<r&&(r=p,a&&a.copy(n),o&&o.copy(u)),Math.sqrt(r)}}();ce.prototype.intersectsTriangle=function(){const n=new ce,e=new Array(3),t=new Array(3),i=new we,s=new we,a=new d.Vector3,o=new d.Vector3,c=new d.Vector3,u=new d.Vector3,f=new d.Vector3,p=new d.Line3,r=new d.Line3,l=new d.Line3,h=new d.Vector3;function g(_,m,v){const y=_.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:A,end:S}=p;A.copy(y[b]),S.copy(y[(b+1)%3]),p.delta(o);const I=Ii(m.distanceToPoint(A));if(Ii(m.normal.dot(o))&&I){v.copy(p),x=2;break}const M=m.intersectLine(p,h);if(!M&&I&&h.copy(A),(M||I)&&!Ii(h.distanceTo(S))){if(x<=1)(x===1?v.start:v.end).copy(h),I&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(h),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(n.copy(m),n.update(),m=n);const x=this.plane,w=m.plane;if(Math.abs(x.normal.dot(w.normal))>1-1e-10){const b=this.satBounds,A=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let M=0;M<4;M++){const P=b[M],R=A[M];if(i.setFromPoints(R,t),P.isSeparated(i))return!1}const S=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let M=0;M<4;M++){const P=S[M],R=I[M];if(i.setFromPoints(R,e),P.isSeparated(i))return!1}for(let M=0;M<4;M++){const P=A[M];for(let R=0;R<4;R++){const T=I[R];if(a.crossVectors(P,T),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const b=g(this,w,r);if(b===1&&m.containsPoint(r.end))return v&&(v.start.copy(r.end),v.end.copy(r.end)),!0;if(b!==2)return!1;const A=g(m,x,l);if(A===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(A!==2)return!1;if(r.delta(c),l.delta(u),c.dot(u)<0){let C=l.start;l.start=l.end,l.end=C}const S=r.start.dot(c),I=r.end.dot(c),M=l.start.dot(c),P=l.end.dot(c),R=I<M,T=S<P;return S!==P&&M!==I&&R===T?!1:(v&&(f.subVectors(r.start,l.start),f.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),f.subVectors(r.end,l.end),f.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();ce.prototype.distanceToPoint=function(){const n=new d.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}}();ce.prototype.distanceToTriangle=function(){const n=new d.Vector3,e=new d.Vector3,t=["a","b","c"],i=new d.Line3,s=new d.Line3;return function(o,c=null,u=null){const f=c||u?i:null;if(this.intersectsTriangle(o,f))return(c||u)&&(c&&f.getCenter(c),u&&f.getCenter(u)),0;let p=1/0;for(let r=0;r<3;r++){let l;const h=t[r],g=o[h];this.closestPointToPoint(g,n),l=g.distanceToSquared(n),l<p&&(p=l,c&&c.copy(n),u&&u.copy(g));const _=this[h];o.closestPointToPoint(_,n),l=_.distanceToSquared(n),l<p&&(p=l,c&&c.copy(_),u&&u.copy(n))}for(let r=0;r<3;r++){const l=t[r],h=t[(r+1)%3];i.set(this[l],this[h]);for(let g=0;g<3;g++){const _=t[g],m=t[(g+1)%3];s.set(o[_],o[m]),hs(i,s,n,e);const v=n.distanceToSquared(e);v<p&&(p=v,c&&c.copy(n),u&&u.copy(e))}}return Math.sqrt(p)}}();class j{constructor(e,t,i){this.isOrientedBox=!0,this.min=new d.Vector3,this.max=new d.Vector3,this.matrix=new d.Matrix4,this.invMatrix=new d.Matrix4,this.points=new Array(8).fill().map(()=>new d.Vector3),this.satAxes=new Array(3).fill().map(()=>new d.Vector3),this.satBounds=new Array(3).fill().map(()=>new we),this.alignedSatBounds=new Array(3).fill().map(()=>new we),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}}j.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let f=0;f<=1;f++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*f|2*p|4*r,h=s[l];h.x=f?i.x:t.x,h.y=p?i.y:t.y,h.z=r?i.z:t.z,h.applyMatrix4(e)}const a=this.satBounds,o=this.satAxes,c=s[0];for(let f=0;f<3;f++){const p=o[f],r=a[f],l=1<<f,h=s[l];p.subVectors(c,h),r.setFromPoints(p,s)}const u=this.alignedSatBounds;u[0].setFromPointsField(s,"x"),u[1].setFromPointsField(s,"y"),u[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();j.prototype.intersectsBox=function(){const n=new we;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(n.min=i.x,n.max=s.x,c[0].isSeparated(n)||(n.min=i.y,n.max=s.y,c[1].isSeparated(n))||(n.min=i.z,n.max=s.z,c[2].isSeparated(n)))return!1;for(let u=0;u<3;u++){const f=o[u],p=a[u];if(n.setFromBox(f,t),p.isSeparated(n))return!1}return!0}}();j.prototype.intersectsTriangle=function(){const n=new ce,e=new Array(3),t=new we,i=new we,s=new d.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(n.copy(o),n.update(),o=n);const c=this.satBounds,u=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let l=0;l<3;l++){const h=c[l],g=u[l];if(t.setFromPoints(g,e),h.isSeparated(t))return!1}const f=o.satBounds,p=o.satAxes,r=this.points;for(let l=0;l<3;l++){const h=f[l],g=p[l];if(t.setFromPoints(g,r),h.isSeparated(t))return!1}for(let l=0;l<3;l++){const h=u[l];for(let g=0;g<4;g++){const _=p[g];if(s.crossVectors(h,_),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();j.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}}();j.prototype.distanceToPoint=function(){const n=new d.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}}();j.prototype.distanceToBox=function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new d.Line3),t=new Array(12).fill().map(()=>new d.Line3),i=new d.Vector3,s=new d.Vector3;return function(o,c=0,u=null,f=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(u||f)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),u&&u.copy(i),f&&f.copy(s)),0;const p=c*c,r=o.min,l=o.max,h=this.points;let g=1/0;for(let m=0;m<8;m++){const v=h[m];s.copy(v).clamp(r,l);const y=v.distanceToSquared(s);if(y<g&&(g=y,u&&u.copy(v),f&&f.copy(s),y<p))return Math.sqrt(y)}let _=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|y<<w,A=1<<m|v<<x|y<<w,S=h[b],I=h[A];e[_].set(S,I);const P=n[m],R=n[x],T=n[w],C=t[_],D=C.start,E=C.end;D[P]=r[P],D[R]=v?r[R]:l[R],D[T]=y?r[T]:l[R],E[P]=l[P],E[R]=v?r[R]:l[R],E[T]=y?r[T]:l[R],_++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=y?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,u&&u.copy(i),f&&f.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let y=0;y<12;y++){const x=t[y];hs(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,u&&u.copy(i),f&&f.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class fs{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 Il extends fs{constructor(){super(()=>new ce)}}const re=new Il;class Rl{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 U=new Rl;let Re,et;const He=[],Nt=new fs(()=>new d.Box3);function Pl(n,e,t,i,s,a){Re=Nt.getPrimitive(),et=Nt.getPrimitive(),He.push(Re,et),U.setBuffer(n._roots[e]);const o=Yi(0,n.geometry,t,i,s,a);U.clearBuffer(),Nt.releasePrimitive(Re),Nt.releasePrimitive(et),He.pop(),He.pop();const c=He.length;return c>0&&(et=He[c-1],Re=He[c-2]),o}function Yi(n,e,t,i,s=null,a=0,o=0){const{float32Array:c,uint16Array:u,uint32Array:f}=U;let p=n*2;if(Z(p,u)){const l=J(n,f),h=te(p,u);return N(n,c,Re),i(l,h,!1,o,a+n,Re)}else{let P=function(T){const{uint16Array:C,uint32Array:D}=U;let E=T*2;for(;!Z(E,C);)T=ie(T),E=T*2;return J(T,D)},R=function(T){const{uint16Array:C,uint32Array:D}=U;let E=T*2;for(;!Z(E,C);)T=se(T,D),E=T*2;return J(T,D)+te(E,C)};const l=ie(n),h=se(n,f);let g=l,_=h,m,v,y,x;if(s&&(y=Re,x=et,N(g,c,y),N(_,c,x),m=s(y),v=s(x),v<m)){g=h,_=l;const T=m;m=v,v=T,y=x}y||(y=Re,N(g,c,y));const w=Z(g*2,u),b=t(y,w,m,o+1,a+g);let A;if(b===Xs){const T=P(g),D=R(g)-T;A=i(T,D,!0,o+1,a+g,y)}else A=b&&Yi(g,e,t,i,s,a,o+1);if(A)return!0;x=et,N(_,c,x);const S=Z(_*2,u),I=t(x,S,v,o+1,a+_);let M;if(I===Xs){const T=P(_),D=R(_)-T;M=i(T,D,!0,o+1,a+_,x)}else M=I&&Yi(_,e,t,i,s,a,o+1);return!!M}}const xt=new d.Vector3,Ri=new d.Vector3;function Dl(n,e,t={},i=0,s=1/0){const a=i*i,o=s*s;let c=1/0,u=null;if(n.shapecast({boundsTraverseOrder:p=>(xt.copy(e).clamp(p.min,p.max),xt.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<o,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,xt);const l=e.distanceToSquared(xt);return l<c&&(Ri.copy(xt),c=l,u=r),l<a}}),c===1/0)return null;const f=Math.sqrt(c);return t.point?t.point.copy(Ri):t.point=Ri.clone(),t.distance=f,t.faceIndex=u,t}const Ne=new d.Vector3,We=new d.Vector3,Ge=new d.Vector3,Wt=new d.Vector2,Gt=new d.Vector2,qt=new d.Vector2,tr=new d.Vector3,ir=new d.Vector3,sr=new d.Vector3,jt=new d.Vector3;function Ll(n,e,t,i,s,a,o,c){let u;if(a===d.BackSide?u=n.intersectTriangle(i,t,e,!0,s):u=n.intersectTriangle(e,t,i,a!==d.DoubleSide,s),u===null)return null;const f=n.origin.distanceTo(s);return f<o||f>c?null:{distance:f,point:s.clone()}}function El(n,e,t,i,s,a,o,c,u,f,p){Ne.fromBufferAttribute(e,a),We.fromBufferAttribute(e,o),Ge.fromBufferAttribute(e,c);const r=Ll(n,Ne,We,Ge,jt,u,f,p);if(r){i&&(Wt.fromBufferAttribute(i,a),Gt.fromBufferAttribute(i,o),qt.fromBufferAttribute(i,c),r.uv=d.Triangle.getInterpolation(jt,Ne,We,Ge,Wt,Gt,qt,new d.Vector2)),s&&(Wt.fromBufferAttribute(s,a),Gt.fromBufferAttribute(s,o),qt.fromBufferAttribute(s,c),r.uv1=d.Triangle.getInterpolation(jt,Ne,We,Ge,Wt,Gt,qt,new d.Vector2)),t&&(tr.fromBufferAttribute(t,a),ir.fromBufferAttribute(t,o),sr.fromBufferAttribute(t,c),r.normal=d.Triangle.getInterpolation(jt,Ne,We,Ge,tr,ir,sr,new d.Vector3),r.normal.dot(n.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:o,c,normal:new d.Vector3,materialIndex:0};d.Triangle.getNormal(Ne,We,Ge,l.normal),r.face=l,r.faceIndex=a}return r}function fi(n,e,t,i,s,a,o){const c=i*3;let u=c+0,f=c+1,p=c+2;const r=n.index;n.index&&(u=r.getX(u),f=r.getX(f),p=r.getX(p));const{position:l,normal:h,uv:g,uv1:_}=n.attributes,m=El(t,l,h,g,_,u,f,p,e,a,o);return m?(m.faceIndex=i,s&&s.push(m),m):null}function G(n,e,t,i){const s=n.a,a=n.b,o=n.c;let c=e,u=e+1,f=e+2;t&&(c=t.getX(c),u=t.getX(u),f=t.getX(f)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(u),a.y=i.getY(u),a.z=i.getZ(u),o.x=i.getX(f),o.y=i.getY(f),o.z=i.getZ(f)}function Fl(n,e,t,i,s,a,o,c){const{geometry:u,_indirectBuffer:f}=n;for(let p=i,r=i+s;p<r;p++)fi(u,e,t,p,a,o,c)}function Bl(n,e,t,i,s,a,o){const{geometry:c,_indirectBuffer:u}=n;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=fi(c,e,t,r,null,a,o),h&&h.distance<f&&(p=h,f=h.distance)}return p}function kl(n,e,t,i,s,a,o){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=n,r=e+n;p<r;p++){let l;if(l=p,G(o,l*3,u,f),o.needsUpdate=!0,i(o,l,s,a))return!0}return!1}function Ol(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,o,c,u,f=0;const p=n._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],o=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===hi){const v=o[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,I=-1/0;for(let M=3*v,P=3*(v+y);M<P;M++){let R=i[M];const T=s.getX(R),C=s.getY(R),D=s.getZ(R);T<x&&(x=T),T>A&&(A=T),C<w&&(w=C),C>S&&(S=C),D<b&&(b=D),D>I&&(I=D)}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==I?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=I,!0):!1}else{const v=l+8,y=o[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const I=b||A,M=b||S;let P=!1;I&&(P=r(v,h,b));let R=!1;M&&(R=r(y,h,b));const T=P||R;if(T)for(let C=0;C<3;C++){const D=v+C,E=y+C,F=u[D],O=u[D+3],H=u[E],W=u[E+3];u[l+C]=F<H?F:H,u[l+C+3]=O>W?O:W}return T}}}function Pe(n,e,t,i,s){let a,o,c,u,f,p;const r=1/t.direction.x,l=1/t.direction.y,h=1/t.direction.z,g=t.origin.x,_=t.origin.y,m=t.origin.z;let v=e[n],y=e[n+3],x=e[n+1],w=e[n+3+1],b=e[n+2],A=e[n+3+2];return r>=0?(a=(v-g)*r,o=(y-g)*r):(a=(y-g)*r,o=(v-g)*r),l>=0?(c=(x-_)*l,u=(w-_)*l):(c=(w-_)*l,u=(x-_)*l),a>u||c>o||((c>a||isNaN(a))&&(a=c),(u<o||isNaN(o))&&(o=u),h>=0?(f=(b-m)*h,p=(A-m)*h):(f=(A-m)*h,p=(b-m)*h),a>p||f>o)?!1:((f>a||a!==a)&&(a=f),(p<o||o!==o)&&(o=p),a<=s&&o>=i)}function zl(n,e,t,i,s,a,o,c){const{geometry:u,_indirectBuffer:f}=n;for(let p=i,r=i+s;p<r;p++){let l=f?f[p]:p;fi(u,e,t,l,a,o,c)}}function Vl(n,e,t,i,s,a,o){const{geometry:c,_indirectBuffer:u}=n;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=fi(c,e,t,u?u[r]:r,null,a,o),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Ul(n,e,t,i,s,a,o){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=n,r=e+n;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),G(o,l*3,u,f),o.needsUpdate=!0,i(o,l,s,a))return!0}return!1}function Hl(n,e,t,i,s,a,o){U.setBuffer(n._roots[e]),Qi(0,n,t,i,s,a,o),U.clearBuffer()}function Qi(n,e,t,i,s,a,o){const{float32Array:c,uint16Array:u,uint32Array:f}=U,p=n*2;if(Z(p,u)){const l=J(n,f),h=te(p,u);Fl(e,t,i,l,h,s,a,o)}else{const l=ie(n);Pe(l,c,i,a,o)&&Qi(l,e,t,i,s,a,o);const h=se(n,f);Pe(h,c,i,a,o)&&Qi(h,e,t,i,s,a,o)}}const Nl=["x","y","z"];function Wl(n,e,t,i,s,a){U.setBuffer(n._roots[e]);const o=Zi(0,n,t,i,s,a);return U.clearBuffer(),o}function Zi(n,e,t,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:u}=U;let f=n*2;if(Z(f,c)){const r=J(n,u),l=te(f,c);return Bl(e,t,i,r,l,s,a)}else{const r=Or(n,u),l=Nl[r],g=i.direction[l]>=0;let _,m;g?(_=ie(n),m=se(n,u)):(_=se(n,u),m=ie(n));const y=Pe(_,o,i,s,a)?Zi(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=o[m+r]:b>=o[m+r+3])return y}const w=Pe(m,o,i,s,a)?Zi(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Yt=new d.Box3,qe=new ce,je=new ce,wt=new d.Matrix4,rr=new j,Qt=new j;function Gl(n,e,t,i){U.setBuffer(n._roots[e]);const s=Xi(0,n,t,i);return U.clearBuffer(),s}function Xi(n,e,t,i,s=null){const{float32Array:a,uint16Array:o,uint32Array:c}=U;let u=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),rr.set(t.boundingBox.min,t.boundingBox.max,i),s=rr),Z(u,o)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=J(n,c),m=te(u,o);if(wt.copy(i).invert(),t.boundsTree)return N(n,a,Qt),Qt.matrix.copy(wt),Qt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Qt.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_*3,w=(m+_)*3;x<w;x+=3)if(G(je,x,r,l),je.needsUpdate=!0,y.intersectsTriangle(je))return!0;return!1}});for(let v=_*3,y=(m+_)*3;v<y;v+=3){G(qe,v,r,l),qe.a.applyMatrix4(wt),qe.b.applyMatrix4(wt),qe.c.applyMatrix4(wt),qe.needsUpdate=!0;for(let x=0,w=h.count;x<w;x+=3)if(G(je,x,h,g),je.needsUpdate=!0,qe.intersectsTriangle(je))return!0}}else{const p=n+8,r=c[n+6];return N(p,a,Yt),!!(s.intersectsBox(Yt)&&Xi(p,e,t,i,s)||(N(r,a,Yt),s.intersectsBox(Yt)&&Xi(r,e,t,i,s)))}}const Zt=new d.Matrix4,Pi=new j,bt=new j,ql=new d.Vector3,jl=new d.Vector3,Yl=new d.Vector3,Ql=new d.Vector3;function Zl(n,e,t,i={},s={},a=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Pi.set(e.boundingBox.min,e.boundingBox.max,t),Pi.needsUpdate=!0;const c=n.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=re.getPrimitive(),h=re.getPrimitive();let g=ql,_=jl,m=null,v=null;s&&(m=Yl,v=Ql);let y=1/0,x=null,w=null;return Zt.copy(t).invert(),bt.matrix.copy(Zt),n.shapecast({boundsTraverseOrder:b=>Pi.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<o?(A&&(bt.min.copy(b.min),bt.max.copy(b.max),bt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>bt.distanceToBox(I),intersectsBounds:(I,M,P)=>P<y&&P<o,intersectsRange:(I,M)=>{for(let P=I,R=I+M;P<R;P++){G(h,3*P,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let T=b,C=b+A;T<C;T++){G(l,3*T,f,u),l.needsUpdate=!0;const D=l.distanceToTriangle(h,g,m);if(D<y&&(_.copy(g),v&&v.copy(m),y=D,x=T,w=P),D<a)return!0}}}});{const S=ut(e);for(let I=0,M=S;I<M;I++){G(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let P=b,R=b+A;P<R;P++){G(l,3*P,f,u),l.needsUpdate=!0;const T=l.distanceToTriangle(h,g,m);if(T<y&&(_.copy(g),v&&v.copy(m),y=T,x=P,w=I),T<a)return!0}}}}}),re.releasePrimitive(l),re.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(Zt),_.applyMatrix4(Zt),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function Xl(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,o,c,u,f=0;const p=n._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],o=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===hi){const v=o[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,I=-1/0;for(let M=v,P=v+y;M<P;M++){const R=3*n.resolveTriangleIndex(M);for(let T=0;T<3;T++){let C=R+T;C=i?i[C]:C;const D=s.getX(C),E=s.getY(C),F=s.getZ(C);D<x&&(x=D),D>A&&(A=D),E<w&&(w=E),E>S&&(S=E),F<b&&(b=F),F>I&&(I=F)}}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==I?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=I,!0):!1}else{const v=l+8,y=o[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const I=b||A,M=b||S;let P=!1;I&&(P=r(v,h,b));let R=!1;M&&(R=r(y,h,b));const T=P||R;if(T)for(let C=0;C<3;C++){const D=v+C,E=y+C,F=u[D],O=u[D+3],H=u[E],W=u[E+3];u[l+C]=F<H?F:H,u[l+C+3]=O>W?O:W}return T}}}function Kl(n,e,t,i,s,a,o){U.setBuffer(n._roots[e]),Ki(0,n,t,i,s,a,o),U.clearBuffer()}function Ki(n,e,t,i,s,a,o){const{float32Array:c,uint16Array:u,uint32Array:f}=U,p=n*2;if(Z(p,u)){const l=J(n,f),h=te(p,u);zl(e,t,i,l,h,s,a,o)}else{const l=ie(n);Pe(l,c,i,a,o)&&Ki(l,e,t,i,s,a,o);const h=se(n,f);Pe(h,c,i,a,o)&&Ki(h,e,t,i,s,a,o)}}const Jl=["x","y","z"];function $l(n,e,t,i,s,a){U.setBuffer(n._roots[e]);const o=Ji(0,n,t,i,s,a);return U.clearBuffer(),o}function Ji(n,e,t,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:u}=U;let f=n*2;if(Z(f,c)){const r=J(n,u),l=te(f,c);return Vl(e,t,i,r,l,s,a)}else{const r=Or(n,u),l=Jl[r],g=i.direction[l]>=0;let _,m;g?(_=ie(n),m=se(n,u)):(_=se(n,u),m=ie(n));const y=Pe(_,o,i,s,a)?Ji(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=o[m+r]:b>=o[m+r+3])return y}const w=Pe(m,o,i,s,a)?Ji(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Xt=new d.Box3,Ye=new ce,Qe=new ce,At=new d.Matrix4,nr=new j,Kt=new j;function ec(n,e,t,i){U.setBuffer(n._roots[e]);const s=$i(0,n,t,i);return U.clearBuffer(),s}function $i(n,e,t,i,s=null){const{float32Array:a,uint16Array:o,uint32Array:c}=U;let u=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),nr.set(t.boundingBox.min,t.boundingBox.max,i),s=nr),Z(u,o)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=J(n,c),m=te(u,o);if(At.copy(i).invert(),t.boundsTree)return N(n,a,Kt),Kt.matrix.copy(At),Kt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Kt.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_,w=m+_;x<w;x++)if(G(Qe,3*e.resolveTriangleIndex(x),r,l),Qe.needsUpdate=!0,y.intersectsTriangle(Qe))return!0;return!1}});for(let v=_,y=m+_;v<y;v++){const x=e.resolveTriangleIndex(v);G(Ye,3*x,r,l),Ye.a.applyMatrix4(At),Ye.b.applyMatrix4(At),Ye.c.applyMatrix4(At),Ye.needsUpdate=!0;for(let w=0,b=h.count;w<b;w+=3)if(G(Qe,w,h,g),Qe.needsUpdate=!0,Ye.intersectsTriangle(Qe))return!0}}else{const p=n+8,r=c[n+6];return N(p,a,Xt),!!(s.intersectsBox(Xt)&&$i(p,e,t,i,s)||(N(r,a,Xt),s.intersectsBox(Xt)&&$i(r,e,t,i,s)))}}const Jt=new d.Matrix4,Di=new j,Tt=new j,tc=new d.Vector3,ic=new d.Vector3,sc=new d.Vector3,rc=new d.Vector3;function nc(n,e,t,i={},s={},a=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Di.set(e.boundingBox.min,e.boundingBox.max,t),Di.needsUpdate=!0;const c=n.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=re.getPrimitive(),h=re.getPrimitive();let g=tc,_=ic,m=null,v=null;s&&(m=sc,v=rc);let y=1/0,x=null,w=null;return Jt.copy(t).invert(),Tt.matrix.copy(Jt),n.shapecast({boundsTraverseOrder:b=>Di.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<o?(A&&(Tt.min.copy(b.min),Tt.max.copy(b.max),Tt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:I=>Tt.distanceToBox(I),intersectsBounds:(I,M,P)=>P<y&&P<o,intersectsRange:(I,M)=>{for(let P=I,R=I+M;P<R;P++){const T=S.resolveTriangleIndex(P);G(h,3*T,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let C=b,D=b+A;C<D;C++){const E=n.resolveTriangleIndex(C);G(l,3*E,f,u),l.needsUpdate=!0;const F=l.distanceToTriangle(h,g,m);if(F<y&&(_.copy(g),v&&v.copy(m),y=F,x=C,w=P),F<a)return!0}}}})}else{const S=ut(e);for(let I=0,M=S;I<M;I++){G(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let P=b,R=b+A;P<R;P++){const T=n.resolveTriangleIndex(P);G(l,3*T,f,u),l.needsUpdate=!0;const C=l.distanceToTriangle(h,g,m);if(C<y&&(_.copy(g),v&&v.copy(m),y=C,x=P,w=I),C<a)return!0}}}}}),re.releasePrimitive(l),re.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(Jt),_.applyMatrix4(Jt),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function oc(){return typeof SharedArrayBuffer<"u"}const Dt=new U.constructor,oi=new U.constructor,Me=new fs(()=>new d.Box3),Ze=new d.Box3,Xe=new d.Box3,Li=new d.Box3,Ei=new d.Box3;let Fi=!1;function ac(n,e,t,i){if(Fi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Fi=!0;const s=n._roots,a=e._roots;let o,c=0,u=0;const f=new d.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){Dt.setBuffer(s[p]),u=0;const l=Me.getPrimitive();N(0,Dt.float32Array,l),l.applyMatrix4(f);for(let h=0,g=a.length;h<g&&(oi.setBuffer(a[p]),o=ae(0,0,t,f,i,c,u,0,0,l),oi.clearBuffer(),u+=a[h].length,!o);h++);if(Me.releasePrimitive(l),Dt.clearBuffer(),c+=s[p].length,o)break}return Fi=!1,o}function ae(n,e,t,i,s,a=0,o=0,c=0,u=0,f=null,p=!1){let r,l;p?(r=oi,l=Dt):(r=Dt,l=oi);const h=r.float32Array,g=r.uint32Array,_=r.uint16Array,m=l.float32Array,v=l.uint32Array,y=l.uint16Array,x=n*2,w=e*2,b=Z(x,_),A=Z(w,y);let S=!1;if(A&&b)p?S=s(J(e,v),te(e*2,y),J(n,g),te(n*2,_),u,o+e,c,a+n):S=s(J(n,g),te(n*2,_),J(e,v),te(e*2,y),c,a+n,u,o+e);else if(A){const I=Me.getPrimitive();N(e,m,I),I.applyMatrix4(t);const M=ie(n),P=se(n,g);N(M,h,Ze),N(P,h,Xe);const R=I.intersectsBox(Ze),T=I.intersectsBox(Xe);S=R&&ae(e,M,i,t,s,o,a,u,c+1,I,!p)||T&&ae(e,P,i,t,s,o,a,u,c+1,I,!p),Me.releasePrimitive(I)}else{const I=ie(e),M=se(e,v);N(I,m,Li),N(M,m,Ei);const P=f.intersectsBox(Li),R=f.intersectsBox(Ei);if(P&&R)S=ae(n,I,t,i,s,a,o,c,u+1,f,p)||ae(n,M,t,i,s,a,o,c,u+1,f,p);else if(P)if(b)S=ae(n,I,t,i,s,a,o,c,u+1,f,p);else{const T=Me.getPrimitive();T.copy(Li).applyMatrix4(t);const C=ie(n),D=se(n,g);N(C,h,Ze),N(D,h,Xe);const E=T.intersectsBox(Ze),F=T.intersectsBox(Xe);S=E&&ae(I,C,i,t,s,o,a,u,c+1,T,!p)||F&&ae(I,D,i,t,s,o,a,u,c+1,T,!p),Me.releasePrimitive(T)}else if(R)if(b)S=ae(n,M,t,i,s,a,o,c,u+1,f,p);else{const T=Me.getPrimitive();T.copy(Ei).applyMatrix4(t);const C=ie(n),D=se(n,g);N(C,h,Ze),N(D,h,Xe);const E=T.intersectsBox(Ze),F=T.intersectsBox(Xe);S=E&&ae(M,C,i,t,s,o,a,u,c+1,T,!p)||F&&ae(M,D,i,t,s,o,a,u,c+1,T,!p),Me.releasePrimitive(T)}}return S}const $t=new j,or=new d.Box3,lc={strategy:Fr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class ds{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,o=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(u=>u.slice()),index:o?o.array.slice():null,indirectBuffer:a?a.slice():null}:c={roots:s,index:o?o.array:null,indirectBuffer:a},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:o}=e,c=new ds(t,{...i,[Si]:!0});if(c._roots=a,c._indirectBuffer=o||null,i.setIndex){const u=t.getIndex();if(u===null){const f=new d.BufferAttribute(e.index,1,!1);t.setIndex(f)}else u.array!==s&&(u.array.set(s),u.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,[Si]:!1},t),t.useSharedArrayBuffer&&!oc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Si]||(Tl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new d.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?Xl:Ol)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);o(0);function o(c,u=0){const f=c*2,p=a[f+15]===hi;if(p){const r=s[c+6],l=a[f+14];e(u,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Pt/4,l=s[c+6],h=s[c+7];e(u,p,new Float32Array(i,c*4,6),h)||(o(r,u+1),o(l,u+1))}}}raycast(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,o=this.geometry,c=[],u=t.isMaterial,f=Array.isArray(t),p=o.groups,r=u?t.side:t,l=this.indirect?Kl:Hl;for(let h=0,g=a.length;h<g;h++){const _=f?t[p[h].materialIndex].side:r,m=c.length;if(l(this,h,_,e,c,i,s),f){const v=p[h].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=v}}return c}raycastFirst(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,o=this.geometry,c=t.isMaterial,u=Array.isArray(t);let f=null;const p=o.groups,r=c?t.side:t,l=this.indirect?$l:Wl;for(let h=0,g=a.length;h<g;h++){const _=u?t[p[h].materialIndex].side:r,m=l(this,h,_,e,i,s);m!=null&&(f==null||m.distance<f.distance)&&(f=m,u&&(m.face.materialIndex=p[h].materialIndex))}return f}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?ec:Gl;for(let o=0,c=s.length;o<c&&(i=a(this,o,e,t),!i);o++);return i}shapecast(e){const t=re.getPrimitive(),i=this.indirect?Ul:kl;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:o,intersectsTriangle:c}=e;if(o&&c){const r=o;o=(l,h,g,_,m)=>r(l,h,g,_,m)?!0:i(l,h,this,c,g,_,t)}else o||(c?o=(r,l,h,g)=>i(r,l,this,c,h,g,t):o=(r,l,h)=>h);let u=!1,f=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const h=p[r];if(u=Pl(this,r,a,o,s,f),u)break;f+=h.byteLength}return re.releasePrimitive(t),u}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const o=re.getPrimitive(),c=this.geometry.index,u=this.geometry.attributes.position,f=this.indirect?g=>{const _=this.resolveTriangleIndex(g);G(o,_*3,c,u)}:g=>{G(o,g*3,c,u)},p=re.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,h=e.indirect?g=>{const _=e.resolveTriangleIndex(g);G(p,_*3,r,l)}:g=>{G(p,g*3,r,l)};if(a){const g=(_,m,v,y,x,w,b,A)=>{for(let S=v,I=v+y;S<I;S++){h(S),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let M=_,P=_+m;M<P;M++)if(f(M),o.needsUpdate=!0,a(o,p,M,S,x,w,b,A))return!0}return!1};if(s){const _=s;s=function(m,v,y,x,w,b,A,S){return _(m,v,y,x,w,b,A,S)?!0:g(m,v,y,x,w,b,A,S)}}else s=g}return ac(this,e,t,s)}intersectsBox(e,t){return $t.set(e.min,e.max,t),$t.needsUpdate=!0,this.shapecast({intersectsBounds:i=>$t.intersectsBox(i),intersectsTriangle:i=>$t.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,o=1/0){return(this.indirect?nc:Zl)(this,e,t,i,s,a,o)}closestPointToPoint(e,t={},i=0,s=1/0){return Dl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{N(0,new Float32Array(i),or),e.union(or)}),e}}class cc{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 uc extends cc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:ot&&ot.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,a)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=f=>{a(new Error(`GenerateMeshBVHWorker: ${f.message}`))},e.onmessage=f=>{const{data:p}=f;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,h=ds.deserialize(r,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,r.index)if(t.index)t.index.array=r.index;else{const _=new d.BufferAttribute(r.index,1,!1);t.setIndex(_)}g.setBoundingBox&&(t.boundingBox=h.getBoundingBox(new d.Box3)),i.onProgress&&i.onProgress(p.progress),s(h),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const o=t.index?t.index.array:null,c=t.attributes.position.array,u=[c];o&&u.push(o),e.postMessage({index:o,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},u.map(f=>f.buffer).filter(f=>typeof SharedArrayBuffer>"u"||!(f instanceof SharedArrayBuffer)))})}}class hc{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new d.Matrix4,this.mouse=new d.Vector3,this.rotateStart=new d.Vector2,this.rotateEnd=new d.Vector2,this.rotateDelta=new d.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new ct,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,a)=>s.position.z>a.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 a=this.domElement.width/this.domElement.clientWidth,o=this.domElement.height/this.domElement.clientHeight,{left:c,top:u}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-u)*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 a=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),a!==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 a=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const o=this.camera.position.distanceTo(this.orbit.target);a.multiplyScalar(o),this.selectedAxis.axis==="z"?a.setZ(this.orbit.target.z+o):this.selectedAxis.axis==="-z"?a.setZ(this.orbit.target.z-o):a.setZ(this.orbit.target.z);const c=500,u=performance.now(),f=1,p=this.selectedAxis.axis,r=()=>{const h=performance.now()-u,g=Math.min(h/c,f);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==f){this._animator=window.requestAnimationFrame(r);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),r()},this.drawCircle=(s,a=10,o="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-a,s.y-a,a*2,a*2),this.context.fillStyle=o,this.context.fill(),this.context.closePath())},this.drawLine=(s,a,o=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(a.x,a.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(a=>{const o=this.selectedAxis===a,c=a.position.z>=-.01?a.color[0]:a.color[1];if(a.line&&this.drawLine(this.center,a.position,a.line,c),this.drawCircle(a.position,a.size,o?"#0066ff":c),a.label){const u=a.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,u+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(a.label,a.position.x,a.position.y)}}))},this.setAxisPosition=s=>{const a=s.direction.clone().applyMatrix4(this.invRotMat),o=s.size;s.position.set(a.x*(this.center.x-o/2-this.options.padding)+this.center.x,this.center.y-a.y*(this.center.y-o/2-this.options.padding),a.z)};const i={offset:new d.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 d.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=`
3822
3732
  transition: all 0.8s ease-in-out;
3823
3733
  color: rgb(68, 78, 105);
3824
3734
  position: absolute;
@@ -3829,7 +3739,7 @@ d="${this.getPath(e)}"></path>`)}
3829
3739
  margin-right: ${-this.options.size/4}px;
3830
3740
  font-size: 12px;
3831
3741
  text-align:center;
3832
- `}appendTo(e){e.append(this.domElement),e.append(this._text)}createAxes(){const{colors:e,lineWidth:t,bubbleSizePrimary:i,bubbleSizeSecondary:s}=this.options;return[{axis:"x",direction:new f.Vector3(1,0,0),size:i,color:e.x,line:t,label:"前",position:new f.Vector3},{axis:"y",direction:new f.Vector3(0,1,0),size:i,color:e.y,line:t,label:"左",position:new f.Vector3},{axis:"z",direction:new f.Vector3(0,0,1),size:i,color:e.z,line:t,label:"上",position:new f.Vector3},{axis:"-x",direction:new f.Vector3(-1,0,0),size:s,color:e.x,label:"后",position:new f.Vector3},{axis:"-y",direction:new f.Vector3(0,-1,0),size:s,color:e.y,position:new f.Vector3,label:"右"},{axis:"-z",direction:new f.Vector3(0,0,-1),size:i,color:e.z,label:"下",position:new f.Vector3}]}createCanvas(e){const t=document.createElement("canvas");return t.width=e.size,t.height=e.size,t.classList.add(e.className),t.style.cssText=`
3742
+ `}appendTo(e){e.append(this.domElement),e.append(this._text)}createAxes(){const{colors:e,lineWidth:t,bubbleSizePrimary:i,bubbleSizeSecondary:s}=this.options;return[{axis:"x",direction:new d.Vector3(1,0,0),size:i,color:e.x,line:t,label:"前",position:new d.Vector3},{axis:"y",direction:new d.Vector3(0,1,0),size:i,color:e.y,line:t,label:"左",position:new d.Vector3},{axis:"z",direction:new d.Vector3(0,0,1),size:i,color:e.z,line:t,label:"上",position:new d.Vector3},{axis:"-x",direction:new d.Vector3(-1,0,0),size:s,color:e.x,label:"后",position:new d.Vector3},{axis:"-y",direction:new d.Vector3(0,-1,0),size:s,color:e.y,position:new d.Vector3,label:"右"},{axis:"-z",direction:new d.Vector3(0,0,-1),size:i,color:e.z,label:"下",position:new d.Vector3}]}createCanvas(e){const t=document.createElement("canvas");return t.width=e.size,t.height=e.size,t.classList.add(e.className),t.style.cssText=`
3833
3743
  position: absolute;
3834
3744
  left: auto;
3835
3745
  top: ${this.options.offset.y}px;
@@ -3841,14 +3751,14 @@ d="${this.getPath(e)}"></path>`)}
3841
3751
  border-radius: 100%;
3842
3752
  transition: background-color .15s linear;
3843
3753
  cursor: pointer;
3844
- `,t.addEventListener("pointerdown",this.onPointerDown,!1),t.addEventListener("pointerenter",this.onPointerEnter,!1),t.addEventListener("pointermove",this.onPointerMove,!1),t.addEventListener("click",this.onMouseClick,!1),this.context=t.getContext("2d"),t}destroy(){cancelAnimationFrame(this._animator),this.orbit.removeEventListener("change",this._update),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1),this._emitter.removeAllListeners(),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!1),this.domElement.removeEventListener("pointerenter",this.onPointerEnter,!1),this.domElement.removeEventListener("pointermove",this.onPointerMove,!1),this.domElement.removeEventListener("click",this.onMouseClick,!1),this.domElement.remove(),window.clearTimeout(this._textTimer),this._text.remove()}}class Gc{get isFinished(){return this.params?this.framesDone>=this.params.frames:!0}set visible(e){this.shadowCatcherMesh.visible=e,this.progShadowGrp.visible=e,e||(this.isRendering=!1)}get paused(){return this.params?this.params.paused:!0}set paused(e){this.params&&(this.params.paused=e,e&&(this.isRendering=!1))}constructor(e,t,{resolution:i=1024,shadowMapRes:s=512,shadowBias:a=.001,lightCount:o=8,size:c=4,frames:u=40,lightRadius:p=2,ambientWeight:m=.5,alphaTest:n=.98,paused:l=!1}={}){this.params={enabled:!0,frames:u,lightRadius:p,ambientWeight:m,alphaTest:n,debugHelpers:!1,size:c,paused:l},this.scene=t,this.renderer=e,this.buffer1Active=!1,this.dirLights=[],this.dirLightsHelpers=[],this.clearColor=new f.Color,this.clearAlpha=0,this.progress=0,this.discardMaterial=new jc,this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.framesDone=0,this.fixedCamera=null,this.isRendering=!1,this.isZUp=f.Object3D.DEFAULT_UP.z===1,this.progShadowGrp=new f.Group,this.progShadowGrp.name="progressive_shadow_assets",this.scene.add(this.progShadowGrp),this.lightOrigin=new f.Group,this.lightOrigin.name="light_origin",this.isZUp?this.lightOrigin.position.set(c,c,c*1.5):this.lightOrigin.position.set(c,c,c),this.progShadowGrp.add(this.lightOrigin),this.lightGroup=new f.Group,this.lightGroup.name="all_dir_lights",this.progShadowGrp.add(this.lightGroup);const h=Math.PI;for(let d=0;d<o;d++){const v=new f.DirectionalLight(16777215,h/o);v.name="dir_light_"+d,v.castShadow=!0,v.shadow.bias=a,v.shadow.camera.near=.1,v.shadow.camera.far=50,v.shadow.camera.right=c/2,v.shadow.camera.left=-c/2,v.shadow.camera.top=c/2,v.shadow.camera.bottom=-c/2,v.shadow.mapSize.width=s,v.shadow.mapSize.height=s,this.dirLights.push(v),this.lightGroup.add(v)}const g=/(Android|iPad|iPhone|iPod)/g.test(navigator==null?void 0:navigator.userAgent)?f.HalfFloatType:f.FloatType;this.progressiveLightMap1=new f.WebGLRenderTarget(i,i,{type:g}),this.progressiveLightMap2=new f.WebGLRenderTarget(i,i,{type:g}),this.progressiveLightMap1.texture.colorSpace=f.NoColorSpace,this.progressiveLightMap2.texture.colorSpace=f.NoColorSpace,this.shadowCatcherMaterial=new qc({map:this.progressiveLightMap2.texture,transparent:!0,opacity:1});const _=new f.PlaneGeometry(c,c);this.isZUp||_.rotateX(-Math.PI/2),this.shadowCatcherMesh=new f.Mesh(_,this.shadowCatcherMaterial),this.isZUp?this.shadowCatcherMesh.position.z=.001:this.shadowCatcherMesh.position.y=.001,this.shadowCatcherMesh.name="shadowCatcherMesh",this.shadowCatcherMesh.receiveShadow=!0,this.progShadowGrp.add(this.shadowCatcherMesh),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.rebuildObjectsToShowAncestors(),this.debugHelpersGroup=new f.Group,this.targetMat=new f.MeshLambertMaterial({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:u},this.targetMat.onBeforeCompile=d=>{d.vertexShader=`varying vec2 vUv;
3845
- `+d.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const v=d.fragmentShader.indexOf("void main() {");d.fragmentShader=`varying vec2 vUv;
3846
- `+d.fragmentShader.slice(0,v)+`uniform sampler2D previousShadowMap;
3754
+ `,t.addEventListener("pointerdown",this.onPointerDown,!1),t.addEventListener("pointerenter",this.onPointerEnter,!1),t.addEventListener("pointermove",this.onPointerMove,!1),t.addEventListener("click",this.onMouseClick,!1),this.context=t.getContext("2d"),t}destroy(){cancelAnimationFrame(this._animator),this.orbit.removeEventListener("change",this._update),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1),this._emitter.removeAllListeners(),this.domElement.removeEventListener("pointerdown",this.onPointerDown,!1),this.domElement.removeEventListener("pointerenter",this.onPointerEnter,!1),this.domElement.removeEventListener("pointermove",this.onPointerMove,!1),this.domElement.removeEventListener("click",this.onMouseClick,!1),this.domElement.remove(),window.clearTimeout(this._textTimer),this._text.remove()}}class fc{get isFinished(){return this.params?this.framesDone>=this.params.frames:!0}set visible(e){this.shadowCatcherMesh.visible=e,this.progShadowGrp.visible=e,e||(this.isRendering=!1)}get paused(){return this.params?this.params.paused:!0}set paused(e){this.params&&(this.params.paused=e,e&&(this.isRendering=!1))}constructor(e,t,{resolution:i=1024,shadowMapRes:s=512,shadowBias:a=.001,lightCount:o=8,size:c=4,frames:u=40,lightRadius:f=2,ambientWeight:p=.5,alphaTest:r=.98,paused:l=!1}={}){this.params={enabled:!0,frames:u,lightRadius:f,ambientWeight:p,alphaTest:r,debugHelpers:!1,size:c,paused:l},this.scene=t,this.renderer=e,this.buffer1Active=!1,this.dirLights=[],this.dirLightsHelpers=[],this.clearColor=new d.Color,this.clearAlpha=0,this.progress=0,this.discardMaterial=new pc,this.lights=[],this.meshes=[],this.objectsToShow=[],this.autoHiddenObjects=[],this.objectsToShowSet=new Set,this.objectsToShowAncestors=new Set,this.framesDone=0,this.fixedCamera=null,this.isRendering=!1,this.isZUp=d.Object3D.DEFAULT_UP.z===1,this.progShadowGrp=new d.Group,this.progShadowGrp.name="progressive_shadow_assets",this.scene.add(this.progShadowGrp),this.lightOrigin=new d.Group,this.lightOrigin.name="light_origin",this.isZUp?this.lightOrigin.position.set(c,c,c*1.5):this.lightOrigin.position.set(c,c,c),this.progShadowGrp.add(this.lightOrigin),this.lightGroup=new d.Group,this.lightGroup.name="all_dir_lights",this.progShadowGrp.add(this.lightGroup);const h=Math.PI;for(let m=0;m<o;m++){const v=new d.DirectionalLight(16777215,h/o);v.name="dir_light_"+m,v.castShadow=!0,v.shadow.bias=a,v.shadow.camera.near=.1,v.shadow.camera.far=50,v.shadow.camera.right=c/2,v.shadow.camera.left=-c/2,v.shadow.camera.top=c/2,v.shadow.camera.bottom=-c/2,v.shadow.mapSize.width=s,v.shadow.mapSize.height=s,this.dirLights.push(v),this.lightGroup.add(v)}const g=/(Android|iPad|iPhone|iPod)/g.test(navigator==null?void 0:navigator.userAgent)?d.HalfFloatType:d.FloatType;this.progressiveLightMap1=new d.WebGLRenderTarget(i,i,{type:g}),this.progressiveLightMap2=new d.WebGLRenderTarget(i,i,{type:g}),this.progressiveLightMap1.texture.colorSpace=d.NoColorSpace,this.progressiveLightMap2.texture.colorSpace=d.NoColorSpace,this.shadowCatcherMaterial=new dc({map:this.progressiveLightMap2.texture,transparent:!0,opacity:1});const _=new d.PlaneGeometry(c,c);this.isZUp||_.rotateX(-Math.PI/2),this.shadowCatcherMesh=new d.Mesh(_,this.shadowCatcherMaterial),this.isZUp?this.shadowCatcherMesh.position.z=.001:this.shadowCatcherMesh.position.y=.001,this.shadowCatcherMesh.name="shadowCatcherMesh",this.shadowCatcherMesh.receiveShadow=!0,this.progShadowGrp.add(this.shadowCatcherMesh),this.addObjectToShow(this.progShadowGrp),this.addObjectToShow(this.lightGroup),this.addObjectToShow(this.lightOrigin),this.addObjectToShow(this.shadowCatcherMesh),this.rebuildObjectsToShowAncestors(),this.debugHelpersGroup=new d.Group,this.targetMat=new d.MeshLambertMaterial({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:u},this.targetMat.onBeforeCompile=m=>{m.vertexShader=`varying vec2 vUv;
3755
+ `+m.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const v=m.fragmentShader.indexOf("void main() {");m.fragmentShader=`varying vec2 vUv;
3756
+ `+m.fragmentShader.slice(0,v)+`uniform sampler2D previousShadowMap;
3847
3757
  uniform float averagingWindow;
3848
- `+d.fragmentShader.slice(v-1,-1)+`
3758
+ `+m.fragmentShader.slice(v-1,-1)+`
3849
3759
  vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3850
3760
  gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);
3851
- }`,d.uniforms.previousShadowMap=this.previousShadowMap,d.uniforms.averagingWindow=this.averagingWindow}}renderOnRenderTargets(e){this.prepare(),this.averagingWindow.value=this.params.frames;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.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 a of this.dirLights){const o=new f.DirectionalLightHelper(a);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+f.MathUtils.randFloatSpread(this.params.lightRadius),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.clear(),this.framesDone=0,this.fixedCamera=null,this.isRendering=!1)}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.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.shadowCatcherMesh.material.alphaTest=0,this.updateShadowObjectsList()}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.shadowCatcherMesh.material.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.framesDone>=this.params.frames&&(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.scene=null,this.renderer=null,this.fixedCamera=null,this.clearColor=null,this.previousShadowMap=null,this.averagingWindow=null,this.params=null}}function sn(r={},e,t,i=s=>{}){const s=class extends f.ShaderMaterial{constructor(a={}){const o=Object.entries(r);super({uniforms:o.reduce((c,[u,p])=>{const m=f.UniformsUtils.clone({[u]:{value:p}});return{...c,...m}},{}),vertexShader:e,fragmentShader:t}),o.forEach(([c])=>Object.defineProperty(this,c,{get:()=>this.uniforms[c].value,set:u=>this.uniforms[c].value=u})),Object.assign(this,a),i&&i(this)}};return s.key=f.MathUtils.generateUUID(),s}const qc=sn({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
+ }`,m.uniforms.previousShadowMap=this.previousShadowMap,m.uniforms.averagingWindow=this.averagingWindow}}renderOnRenderTargets(e){this.prepare(),this.averagingWindow.value=this.params.frames;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.renderer.setRenderTarget(null)}showDebugHelpers(e){if(!this.debugHelpersGroup.children.length){const t=new d.Mesh(new d.PlaneGeometry(2,2),new d.MeshBasicMaterial({map:this.progressiveLightMap1.texture,side:d.DoubleSide}));this.isZUp?t.position.z=this.params.size/2:t.position.y=this.params.size/2;for(const a of this.dirLights){const o=new d.DirectionalLightHelper(a);this.dirLightsHelpers.push(o)}const i=this.isZUp?new d.Vector3(0,0,1):new d.Vector3(0,1,0),s=new d.PlaneHelper(new d.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+d.MathUtils.randFloatSpread(this.params.lightRadius),this.lightOrigin.position.y+d.MathUtils.randFloatSpread(this.params.lightRadius),this.lightOrigin.position.z+d.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.clear(),this.framesDone=0,this.fixedCamera=null,this.isRendering=!1)}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.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.shadowCatcherMesh.material.alphaTest=0,this.updateShadowObjectsList()}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.shadowCatcherMesh.material.alphaTest=d.MathUtils.clamp(d.MathUtils.mapLinear(this.framesDone,2,this.params.frames-1,0,this.params.alphaTest),0,1),this.renderOnRenderTargets(this.fixedCamera||e),this.randomiseLights(),this.progress=d.MathUtils.mapLinear(this.framesDone,0,this.params.frames-1,0,100),this.framesDone++,this.framesDone>=this.params.frames&&(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.scene=null,this.renderer=null,this.fixedCamera=null,this.clearColor=null,this.previousShadowMap=null,this.averagingWindow=null,this.params=null}}function Ur(n={},e,t,i=s=>{}){const s=class extends d.ShaderMaterial{constructor(a={}){const o=Object.entries(n);super({uniforms:o.reduce((c,[u,f])=>{const p=d.UniformsUtils.clone({[u]:{value:f}});return{...c,...p}},{}),vertexShader:e,fragmentShader:t}),o.forEach(([c])=>Object.defineProperty(this,c,{get:()=>this.uniforms[c].value,set:u=>this.uniforms[c].value=u})),Object.assign(this,a),i&&i(this)}};return s.key=d.MathUtils.generateUUID(),s}const dc=Ur({transparent:!0,color:new d.Color(0,0,0),alphaTest:0,opacity:1,map:null,depthWrite:!1,toneMapped:!1,blend:2},`varying vec2 vUv;
3852
3762
  void main() {
3853
3763
  gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);
3854
3764
  vUv = uv;
@@ -3863,7 +3773,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3863
3773
  gl_FragColor = vec4(color * sampledDiffuseColor.r * blend, max(0.0, (1.0 - (sampledDiffuseColor.r + sampledDiffuseColor.g + sampledDiffuseColor.b) / alphaTest)) * opacity);
3864
3774
  #include <tonemapping_fragment>
3865
3775
  #include <colorspace_fragment>
3866
- }`),jc=sn({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class Yc extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._controls=e}}const $c="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",Qc="https://cdn2.seer-group.com/libs/fonts.type.json",Zc=new wn.Font(Qc);class as{constructor(e){var t;this._props=e,this.name="",this._defaults={color:""},this.color="",this.name=this._props.name,this.color=this._defaults.color="#"+((t=e.target.color)==null?void 0:t.getHexString())}change(e){var t;this.color=e,(t=this._props.target.color)==null||t.set(e)}reset(){this.change(this._defaults.color)}}var rn=(r=>(r[r.DEFAULT=0]="DEFAULT",r[r.CAN_INSTALL=1]="CAN_INSTALL",r))(rn||{});const br=.15;f.Object3D.DEFAULT_UP.set(0,0,1);let Je,ai=0,ls=0;const Xc=()=>{Je=void 0,ai=0,ls=0},Kc=new f.MeshBasicMaterial({colorWrite:!1});class Jc{constructor(e){this.props=e,this.stats=new It,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 fe.CSS2DRenderer,this.mousePos=new f.Vector2,this.mouseCoord=new f.Vector2,this.offset=new f.Vector2,this.size=new f.Vector2,this.amr=new Qr({showSizeBox:!0,showController:!0}),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 ut,this.sound=new Ka,this._rafId=null,this._destroyed=!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.light=new f.PointLight(16777215,10,30),this._amrRender=new f.WebGLRenderTarget(1024,1024,{format:f.RGBAFormat,type:f.UnsignedByteType,colorSpace:f.SRGBColorSpace,samples:8}),this._pointCloudMode=!1,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=m=>{this._dragging=!0,this._pointermove(m)},this._dragend=m=>{this._dragging=!1},this._pointermove=m=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:n,left:l}=this.renderer.domElement.getBoundingClientRect();this.offset.set(l,n),this.mousePos.set(m.clientX-l,m.clientY-n),this.mouseCoord.set((m.clientX-l)/this.size.x*2-1,-((m.clientY-n)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=m=>{const n=()=>{let l=[...this._outlinePass.selectedObjects];this._outlinePass.selectedObjects=[],this.amr.slots.forEach(_=>_.selected=!1);const g=this._raycaster.intersectObjects(this.amr.slots,!1)[0];g&&this.amr.slots.forEach(_=>{_.traverse(d=>{d==g.object?l!=null&&l.includes(_)?(l=void 0,_.deviceSelected=!1):(this._outlinePass.selectedObjects=[_],_.deviceSelected=!0):_.deviceSelected=!1})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(n,200)},this._detectTrackpad=()=>{Je||typeof Je<"u"||(ai===0&&(ls=performance.now()),ai++,performance.now()-ls>66&&(ai>5?Je=!0:Je=!1,Je?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(Xc,2e3)))},this.debounceForkHeightChange=il(()=>{var m;(m=this._progressShadow)==null||m.recalculate()},300),this.focusSlots=m=>{if(this.amr.slots.forEach(A=>A.focused=!1),!m.length){this.fit();return}const n=m.flatMap(A=>{if(A.focused=!0,!A.parent)return[];const M=new f.Vector3;return A.parent.getWorldPosition(M),[M]});if(!n.length)return;const l=n.reduce((A,M)=>A.add(M),new f.Vector3).multiplyScalar(1/n.length),h=this.controls.target.clone(),g=this.camera.position.clone().sub(h).normalize();let _=0;for(const A of n){const M=A.clone().sub(l),I=M.dot(g),L=Math.sqrt(Math.max(0,M.lengthSq()-I*I));L>_&&(_=L)}_=_*1.2+.45;const d=this.camera.fov*Math.PI/180,v=2*Math.atan(Math.tan(d/2)*this.camera.aspect),y=_/Math.tan(v/2),x=_/Math.tan(d/2),w=Math.max(y,x),b=new f.Vector3(0,0,l.z),T=l.clone().sub(b).normalize().multiplyScalar(w<1?1:w).add(l),S=this.camera.position.clone(),P=h.clone(),C={t:0};let R=500;const E=S.distanceTo(T)+P.distanceTo(b);E>.001&&(R=Math.min(1e3,Math.max(450,E*45))),this._fitAnimation=new ci(C).to({t:1},R).easing(Pe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const A=C.t;this.camera.position.lerpVectors(S,T,A),this.controls.target.lerpVectors(P,b,A)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{new f.Box3().setFromObject(this._container);const n=this.amr.sizeBox.size.getSize(new f.Vector3),l=n.clone().multiplyScalar(.5),h=new f.Vector3(0,0,l.z);let g=l.clone().sub(h);g.lengthSq()<1e-6&&(g=new f.Vector3(1,0,0));const _=g.clone().normalize(),d=n.clone().multiplyScalar(.5),v=[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 y=0;for(const O of v){const H=O.dot(_),W=Math.sqrt(Math.max(0,O.lengthSq()-H*H));W>y&&(y=W)}y=y*1.05;const x=this.camera.fov*Math.PI/180,w=2*Math.atan(Math.tan(x/2)*this.camera.aspect),b=y/Math.tan(w/2),T=y/Math.tan(x/2),S=Math.max(b,T),P=l.clone();let C=n.z/3;n.z<n.x&&n.z<n.y&&(C=n.x*.8),n.z>n.x&&n.z>n.y&&(C=0),P.z+=C;const R=g.clone().normalize().multiplyScalar(S<1?1:S).add(P),E=Math.max(n.x*2,5);this.light.position.set(E,0,n.z*2);const A=this.camera.position.clone(),M=this.controls.target.clone(),I={t:0};let L=600;const F=A.distanceTo(R)+M.distanceTo(h);F>.001&&(L=Math.min(800,Math.max(650,F*45))),this._fitAnimation=new ci(I).to({t:1},L).easing(Pe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const O=I.t;this.camera.position.lerpVectors(A,R,O),this.controls.target.lerpVectors(M,h,O)}).onComplete(()=>{this.controls.enabled=!0,!this.shadowMode&&(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}).start(),this.controls.minDistance=Math.max(.2,Math.min(S*.25,S-.1)),this.controls.maxDistance=S*4},this.resize=()=>{var _;const m=this.renderer.domElement.parentElement;if(!m)return;m.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const n=m.clientWidth,l=m.clientHeight;this.size.set(n,l),this.camera.aspect=n/l,this.camera.updateProjectionMatrix(),this._amrRender.setSize(n,l),this._updateCamera(),this.css2dRenderer.setSize(n,l);const h=this.renderer.getPixelRatio();(_=this.pathTracer)==null||_.updateCamera(),this.sampleCount=0,this.renderer.setSize(n,l),this._composer.setSize(n,l),this._composer.passes.forEach(d=>d.setSize(n,l));const g=this._fxaaPass.material.uniforms;g.resolution.value.x=1/(n*h),g.resolution.value.y=1/(l*h),this._bloomPass&&this._bloomPass.setSize(n,l)},this.ticker=()=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker")),this._rafId=requestAnimationFrame(this.ticker),this.renderer.autoClear=!1,this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const m=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Kc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=m}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showAmrUI(!0):this.hideAmrUI(!1,!1);const n=this.stats.fps();this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(n)),this.amr.slots.forEach(l=>{this._dragging?l.getCanInstall()&&l.render(this):l.render(this)}),Pe.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.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Vr(ct,this.renderer),this._ground.visible=!1,this.controls=new _n.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=br,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:Wr()?.2:1,this._cameraPositionUI=new Yc(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",f.ShaderChunk.tonemapping_pars_fragment=f.ShaderChunk.tonemapping_pars_fragment.replace("vec3 CustomToneMapping( vec3 color ) { return color; }",`
3776
+ }`),pc=Ur({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class mc extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._controls=e}}const gc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",vc="https://cdn2.seer-group.com/libs/fonts.type.json",_c=new nn.Font(vc);class es{constructor(e){var t;this._props=e,this.name="",this._defaults={color:""},this.color="",this.name=this._props.name,this.color=this._defaults.color="#"+((t=e.target.color)==null?void 0:t.getHexString())}change(e){var t;this.color=e,(t=this._props.target.color)==null||t.set(e)}reset(){this.change(this._defaults.color)}}var Hr=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.CAN_INSTALL=1]="CAN_INSTALL",n))(Hr||{});const ar=.15;d.Object3D.DEFAULT_UP.set(0,0,1);let Je,si=0,ts=0;const yc=()=>{Je=void 0,si=0,ts=0},xc=new d.MeshBasicMaterial({colorWrite:!1});class wc{constructor(e){this.props=e,this.stats=new Rt,this.scene=new d.Scene,this.overlayScene=new d.Scene,this.renderer=new d.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new fe.CSS2DRenderer,this.mousePos=new d.Vector2,this.mouseCoord=new d.Vector2,this.offset=new d.Vector2,this.size=new d.Vector2,this.amr=new Er({showSizeBox:!0,showController:!0}),this._clock=new d.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new d.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new d.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 d.Group,this._raycaster=new d.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 ct,this.sound=new Va,this._rafId=null,this._destroyed=!1,this._ground=new d.Mesh(new d.PlaneGeometry(100,100),new d.MeshPhysicalMaterial({color:new d.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this.light=new d.PointLight(16777215,10,30),this._amrRender=new d.WebGLRenderTarget(1024,1024,{format:d.RGBAFormat,type:d.UnsignedByteType,colorSpace:d.SRGBColorSpace,samples:8}),this._lastTarget=new d.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=u=>{this._dragging=!0,this._pointermove(u)},this._dragend=u=>{this._dragging=!1},this._pointermove=u=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:f,left:p}=this.renderer.domElement.getBoundingClientRect();this.offset.set(p,f),this.mousePos.set(u.clientX-p,u.clientY-f),this.mouseCoord.set((u.clientX-p)/this.size.x*2-1,-((u.clientY-f)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=u=>{const f=()=>{let p=[...this._outlinePass.selectedObjects];this._outlinePass.selectedObjects=[],this.amr.slots.forEach(h=>h.selected=!1);const l=this._raycaster.intersectObjects(this.amr.slots,!1)[0];l&&this.amr.slots.forEach(h=>{h.traverse(g=>{g==l.object?p!=null&&p.includes(h)?(p=void 0,h.deviceSelected=!1):(this._outlinePass.selectedObjects=[h],h.deviceSelected=!0):h.deviceSelected=!1})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(f,200)},this._detectTrackpad=()=>{Je||typeof Je<"u"||(si===0&&(ts=performance.now()),si++,performance.now()-ts>66&&(si>5?Je=!0:Je=!1,Je?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(yc,2e3)))},this.debounceForkHeightChange=Wa(()=>{var u;(u=this._progressShadow)==null||u.recalculate()},300),this.focusSlots=u=>{var P;if(this.amr.slots.forEach(R=>{R.focused=!1,R.hide()}),!u.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(R=>{R.show()}),this._focusRestoreView){const R=this._focusRestoreView;this._focusRestoreView=void 0;const T=this.camera.position.clone(),C=this.controls.target.clone(),D=R.position.clone(),E=R.target.clone(),F={t:0};let O=500;const H=T.distanceTo(D)+C.distanceTo(E);H>.001&&(O=Math.min(1e3,Math.max(450,H*45))),(P=this._fitAnimation)==null||P.stop(),this._fitAnimation=new It(F).to({t:1},O).easing(ye.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const W=F.t;this.camera.position.lerpVectors(T,D,W),this.controls.target.lerpVectors(C,E,W)}).onComplete(()=>{this.controls.enabled=!0,this.camera.up.copy(R.up)}).start();return}else{this.fit();return}this._focusRestoreView={position:this.camera.position.clone(),target:new d.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()};const f=u.flatMap(R=>{if(R.show(),R.focused=!0,!R.parent)return[];const T=new d.Vector3;return R.parent.getWorldPosition(T),[T]});if(!f.length)return;const p=f.reduce((R,T)=>R.add(T),new d.Vector3).multiplyScalar(1/f.length),r=this.controls.target.clone(),l=this.camera.position.clone().sub(r).normalize();let h=0;for(const R of f){const T=R.clone().sub(p),C=T.dot(l),D=Math.sqrt(Math.max(0,T.lengthSq()-C*C));D>h&&(h=D)}h=h+.4;const g=this.camera.fov*Math.PI/180,_=2*Math.atan(Math.tan(g/2)*this.camera.aspect),m=h/Math.tan(_/2),v=h/Math.tan(g/2),y=Math.max(m,v),x=p.clone(),w=p.clone().add(l.clone().multiplyScalar(y<1?1:y)),b=this.camera.position.clone(),A=r.clone(),S={t:0};let I=500;const M=b.distanceTo(w)+A.distanceTo(x);M>.001&&(I=Math.min(1e3,Math.max(450,M*45))),this._lastTarget=x.clone(),this._fitAnimation=new It(S).to({t:1},I).easing(ye.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const R=S.t;this.camera.position.lerpVectors(b,w,R),this.controls.target.lerpVectors(A,x,R)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{new d.Box3().setFromObject(this._container);const f=this.amr.sizeBox.size.getSize(new d.Vector3),p=f.clone().multiplyScalar(.5),r=new d.Vector3(0,0,p.z);let l=p.clone().sub(r);l.lengthSq()<1e-6&&(l=new d.Vector3(1,0,0));const h=l.clone().normalize(),g=f.clone().multiplyScalar(.5),_=[new d.Vector3(g.x,g.y,g.z),new d.Vector3(g.x,g.y,-g.z),new d.Vector3(g.x,-g.y,g.z),new d.Vector3(g.x,-g.y,-g.z),new d.Vector3(-g.x,g.y,g.z),new d.Vector3(-g.x,g.y,-g.z),new d.Vector3(-g.x,-g.y,g.z),new d.Vector3(-g.x,-g.y,-g.z)];let m=0;for(const E of _){const F=E.dot(h),O=Math.sqrt(Math.max(0,E.lengthSq()-F*F));O>m&&(m=O)}m=m*1.05;const v=this.camera.fov*Math.PI/180,y=2*Math.atan(Math.tan(v/2)*this.camera.aspect),x=m/Math.tan(y/2),w=m/Math.tan(v/2),b=Math.max(x,w),A=p.clone();let S=f.z/3;f.z<f.x&&f.z<f.y&&(S=f.x*.8),f.z>f.x&&f.z>f.y&&(S=0),A.z+=S;const I=l.clone().normalize().multiplyScalar(b<1?1:b).add(A),M=Math.max(f.x*2,5);this.light.position.set(M,0,f.z*2);const P=this.camera.position.clone(),R=this.controls.target.clone(),T={t:0};let C=600;const D=P.distanceTo(I)+R.distanceTo(r);D>.001&&(C=Math.min(800,Math.max(650,D*45))),this._fitAnimation=new It(T).to({t:1},C).easing(ye.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const E=T.t;this.camera.position.lerpVectors(P,I,E),this.controls.target.lerpVectors(R,r,E)}).onComplete(()=>{this.controls.enabled=!0,!this.shadowMode&&(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}).start(),this.controls.minDistance=Math.max(.2,Math.min(b*.25,b-.1)),this.controls.maxDistance=b*4},this.resize=()=>{var h;const u=this.renderer.domElement.parentElement;if(!u)return;u.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const f=u.clientWidth,p=u.clientHeight;this.size.set(f,p),this.camera.aspect=f/p,this.camera.updateProjectionMatrix(),this._amrRender.setSize(f,p),this._updateCamera(),this.css2dRenderer.setSize(f,p);const r=this.renderer.getPixelRatio();(h=this.pathTracer)==null||h.updateCamera(),this.sampleCount=0,this.renderer.setSize(f,p),this._composer.setSize(f,p),this._composer.passes.forEach(g=>g.setSize(f,p));const l=this._fxaaPass.material.uniforms;l.resolution.value.x=1/(f*r),l.resolution.value.y=1/(p*r),this._bloomPass&&this._bloomPass.setSize(f,p)},this.ticker=()=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker")),this._rafId=requestAnimationFrame(this.ticker),this.renderer.autoClear=!1,this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const u=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=xc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=u}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const f=this.stats.fps();this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(f)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),ye.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.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Tr(lt,this.renderer),this._ground.visible=!1,this.controls=new tn.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=ar,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:Ir()?.2:1,this._cameraPositionUI=new mc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=d.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=d.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",d.ShaderChunk.tonemapping_pars_fragment=d.ShaderChunk.tonemapping_pars_fragment.replace("vec3 CustomToneMapping( vec3 color ) { return color; }",`
3867
3777
  float startCompression = 0.8;
3868
3778
  float desaturation = 0.5;
3869
3779
  vec3 CustomToneMapping( vec3 color ) {
@@ -3882,9 +3792,9 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3882
3792
  color *= newPeak * invPeak;
3883
3793
  float g = 1. - 3. / (desaturation * extraBrightness + 3.);
3884
3794
  return mix(color, vec3(1, 1, 1), g);
3885
- }`),this.camera.position.set(10,-10,5),this.camera.lookAt(new f.Vector3);const{tiles:t}=el();this.pathTracer=new pa(this.renderer),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.fadeDuration=0;const s=new Nc(e.workerUrl),a=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=a,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20;let o=this.controls.target.x,c=this.controls.target.y;const u=()=>{this.controls.target.x=o,this.controls.target.y=c};this.controls.addEventListener("change",()=>{var m;this.sampleCount=0,u(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(m=this.pathTracer)==null||m.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._composer=new xn.EffectComposer(this.renderer),this._composer.setPixelRatio(window.devicePixelRatio);const p=new Ss.RenderPass(this.scene,this.camera);this._composer.addPass(p),this._composer.addPass(new yn.OutputPass),this._outlinePass=new Cs.OutlinePass(new f.Vector2(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePass.visibleEdgeColor.set(26367),this._outlinePass.edgeThickness=.5,this._outlinePass.hiddenEdgeColor.set(26367),this._outlinePass.edgeStrength=3,this._outlinePass.edgeGlow=0,this._composer.addPass(this._outlinePass),this._outlinePassError=new Cs.OutlinePass(new f.Vector2(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePassError.visibleEdgeColor.set(16711680),this._outlinePassError.edgeThickness=.5,this._outlinePassError.hiddenEdgeColor.set(16711680),this._outlinePassError.edgeStrength=3,this._outlinePassError.edgeGlow=0,this._composer.addPass(this._outlinePassError),this._bloomPass=new vn.UnrealBloomPass(new f.Vector2(window.innerWidth,window.innerHeight),.1,.1,.2),this._bloomPass.enabled=!1,this._bloomPass.renderToScreen=!1,this._composer.addPass(this._bloomPass),this._composer.renderTarget1.texture.colorSpace=f.SRGBColorSpace,this._composer.renderTarget2.texture.colorSpace=f.SRGBColorSpace,this._fxaaPass=new mn.ShaderPass(gn.FXAAShader),this._composer.addPass(this._fxaaPass),this._progressShadow=new Gc(this.renderer,this.scene,{size:8,lightCount:e.isMobile?6:12,frames:e.isMobile?80:120,lightRadius:8,ambientWeight:.8}),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(),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new Wc(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})),this.test=new f.Mesh(new f.PlaneGeometry(2,2),new f.MeshBasicMaterial({map:this._amrRender.texture,opacity:.5,transparent:!0,side:f.DoubleSide})),this.test.position.set(0,1,0),this.test.visible=!1,this.scene.add(this.test)}get pointCloudMode(){return this._pointCloudMode}set pointCloudMode(e){this._pointCloudMode=e,this.amr.setPointCloudMode(e),e?setTimeout(()=>{console.log(this.amr.lines.children)},3e3):this._outlinePass.selectedObjects=[],this._bloomPass,e?this.scene.fog=null:this.scene.background=null}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.add(this.light),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.light.removeFromParent(),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.scene.background=this.scene.environment),this._usePathTracing=e,this.controls.dampingFactor=e?1:br,this.sampleCount=0}get fpsAverage(){return Nr(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,this._composer.passes.forEach(t=>{t instanceof Ss.RenderPass&&(t.camera=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()),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.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())}_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 pn.HDRLoader().load($c,t=>{t.mapping=f.EquirectangularReflectionMapping,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)}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 a=document.createElement("canvas");a.width=t,a.height=i;const o=a.getContext("2d"),c=new ImageData(t,i);for(let u=0;u<i;u++)for(let p=0;p<t;p++){const m=((i-u-1)*t+p)*4,n=(u*t+p)*4;c.data[n]=s[m],c.data[n+1]=s[m+1],c.data[n+2]=s[m+2],c.data[n+3]=s[m+3]}return o.putImageData(c,0,0),a.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 a=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(a)},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 nn({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(){ye(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 qr.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this._progressShadow.clear(),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(a=>{if(!Object.keys(a.morphTargetDictionary||{}).includes(i))return;let o=s;a.userData[`origin_${i}`]&&(o-=a.userData[`origin_${i}`]);const c=a.morphTargetDictionary[i];a.morphTargetInfluences&&(a.morphTargetInfluences[c]=o),a instanceof f.Mesh&&a.geometry.translate(0,0,1e-5)}),this._progressShadow.clear(),this._progressShadow.recalculate()})}select(e){typeof e=="string"||(Array.isArray(e)?this._outlinePass.selectedObjects=[...e]:this._outlinePass.selectedObjects=[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=`
3795
+ }`),this.camera.position.set(10,-10,5),this.camera.lookAt(new d.Vector3);const{tiles:t}=Ha();this.pathTracer=new ta(this.renderer),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.fadeDuration=0;const s=new uc(e.workerUrl),a=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=a,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 u=this._lastTarget.x,f=this._lastTarget.y;this.controls.target.x=u,this.controls.target.y=f};this.controls.addEventListener("change",()=>{var u;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,(u=this.pathTracer)==null||u.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._composer=new rn.EffectComposer(this.renderer),this._composer.setPixelRatio(window.devicePixelRatio);const c=new ms.RenderPass(this.scene,this.camera);this._composer.addPass(c),this._composer.addPass(new sn.OutputPass),this._outlinePass=new gs.OutlinePass(new d.Vector2(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePass.visibleEdgeColor.set(26367),this._outlinePass.edgeThickness=.5,this._outlinePass.hiddenEdgeColor.set(26367),this._outlinePass.edgeStrength=3,this._outlinePass.edgeGlow=0,this._composer.addPass(this._outlinePass),this._outlinePassError=new gs.OutlinePass(new d.Vector2(window.innerWidth,window.innerHeight),this.scene,this.camera),this._outlinePassError.visibleEdgeColor.set(16711680),this._outlinePassError.edgeThickness=.5,this._outlinePassError.hiddenEdgeColor.set(16711680),this._outlinePassError.edgeStrength=3,this._outlinePassError.edgeGlow=0,this._composer.addPass(this._outlinePassError),this._bloomPass=new en.UnrealBloomPass(new d.Vector2(window.innerWidth,window.innerHeight),.1,.1,.2),this._bloomPass.enabled=!1,this._bloomPass.renderToScreen=!1,this._composer.addPass(this._bloomPass),this._composer.renderTarget1.texture.colorSpace=d.SRGBColorSpace,this._composer.renderTarget2.texture.colorSpace=d.SRGBColorSpace,this._fxaaPass=new Jr.ShaderPass($r.FXAAShader),this._composer.addPass(this._fxaaPass),this._progressShadow=new fc(this.renderer,this.scene,{size:8,lightCount:e.isMobile?6:12,frames:e.isMobile?80:120,lightRadius:8,ambientWeight:.8}),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(),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new hc(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new d.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._lastTarget=this.controls.target.clone(),this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1})),this.test=new d.Mesh(new d.PlaneGeometry(2,2),new d.MeshBasicMaterial({map:this._amrRender.texture,opacity:.5,transparent:!0,side:d.DoubleSide})),this.test.position.set(0,1,0),this.test.visible=!1,this.scene.add(this.test)}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.add(this.light),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.light.removeFromParent(),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.scene.background=this.scene.environment),this._usePathTracing=e,this.controls.dampingFactor=e?1:ar,this.sampleCount=0}get fpsAverage(){return Cr(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,this._composer.passes.forEach(t=>{t instanceof ms.RenderPass&&(t.camera=e)}),e instanceof d.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()),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.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())}_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 Kr.HDRLoader().load(gc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new d.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)}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 d.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.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 d.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 a=document.createElement("canvas");a.width=t,a.height=i;const o=a.getContext("2d"),c=new ImageData(t,i);for(let u=0;u<i;u++)for(let f=0;f<t;f++){const p=((i-u-1)*t+f)*4,r=(u*t+f)*4;c.data[r]=s[p],c.data[r+1]=s[p+1],c.data[r+2]=s[p+2],c.data[r+3]=s[p+3]}return o.putImageData(c,0,0),a.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 a=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(a)},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 Nr({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(){xe(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 Pr.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this._progressShadow.clear(),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(a=>{if(!Object.keys(a.morphTargetDictionary||{}).includes(i))return;let o=s;a.userData[`origin_${i}`]&&(o-=a.userData[`origin_${i}`]);const c=a.morphTargetDictionary[i];a.morphTargetInfluences&&(a.morphTargetInfluences[c]=o),a instanceof d.Mesh&&a.geometry.translate(0,0,1e-5)}),this._progressShadow.clear(),this._progressShadow.recalculate()})}select(e){typeof e=="string"||(Array.isArray(e)?this._outlinePass.selectedObjects=[...e]:this._outlinePass.selectedObjects=[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=`
3886
3796
  -webkit-user-select: none;
3887
3797
  user-select: none;
3888
3798
  touch-action: none;
3889
3799
  -webkit-touch-callout: none;
3890
- `),this._controlsGizmo&&this._controlsGizmo.appendTo(e),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(e)}add(e){this._container.add(e)}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;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(),Pe.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(i=this._fitAnimation)==null||i.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&&((s=this._resizeObserver)==null||s.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),this._composer.dispose(),ye(this.scene),this.scene.clear()}}class nn{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,_,d,v,y,x;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 a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),o=((_=e==null?void 0:e.size)==null?void 0:_.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,u=(e==null?void 0:e.includeOverlay)??!1,p=a/o||1,m=this.resolveViews(e==null?void 0:e.views),n=new f.WebGLRenderTarget(a,o,{format:f.RGBAFormat,type:f.UnsignedByteType});n.texture.colorSpace=f.SRGBColorSpace,n.texture.generateMipmaps=!1,n.depthBuffer=!0;const l=this.storeRendererState(t),h={};try{(v=(d=this.deps).onBeforeCapture)==null||v.call(d);const w=this.computeBounds(i);this.applyRendererState(t,a,o,e==null?void 0:e.backgroundColor);for(const b of m){const T=this.configureCamera(w,b,p,c,a,o);t.setRenderTarget(n),t.clear(!0,!0,!0),t.render(this.deps.scene,T),u&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const S=this.readPixels(t,n,a,o);h[b.key]=S}}finally{n.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return h}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,a=new f.Vector3,o=new f.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const p=c.geometry;if(!p)return;p.boundingBox||p.computeBoundingBox();const m=p.boundingBox;m&&(i.copy(m).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new f.Vector3(.001,.001,.001)),a.set(.001,.001,.001),o.center.copy(s),o.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(o)),(!Number.isFinite(o.radius)||o.radius<=0)&&(o.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:o}}configureCamera(e,t,i,s,a,o){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const u=t.up.clone().normalize();if(Math.abs(u.dot(c))>.999&&(u.set(0,0,1),Math.abs(u.dot(c))>.999&&u.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,T=f.MathUtils.degToRad(b),S=Math.max(Math.tan(T/2),1e-4),P=Math.max(S*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),R=new f.Vector3().crossVectors(C,u).normalize();R.lengthSq()<1e-6&&R.set(1,0,0);const E=new f.Vector3().crossVectors(R,C).normalize(),A=Math.max(e.size.x*.5,1e-4),M=Math.max(e.size.y*.5,1e-4),I=Math.max(e.size.z*.5,1e-4),L=[new f.Vector3(-A,-M,-I),new f.Vector3(-A,-M,I),new f.Vector3(-A,M,-I),new f.Vector3(-A,M,I),new f.Vector3(A,-M,-I),new f.Vector3(A,-M,I),new f.Vector3(A,M,-I),new f.Vector3(A,M,I)];let F=0,O=-1/0;for(const J of L){const ee=R.dot(J),pe=E.dot(J),ft=C.dot(J);O=Math.max(O,ft);const yi=ft+Math.abs(ee)/P,dt=ft+Math.abs(pe)/S;F=Math.max(F,yi,dt)}F=Math.max(F,O+.1);const H=F*(1+s);let W=1/0;for(const J of L){const ee=C.dot(J),pe=H-ee;pe>.001&&(W=Math.min(W,pe))}return w.fov=b,w.aspect=i||a/Math.max(o,1),w.near=Math.max(.1,Number.isFinite(W)?W*.5:H*.1),w.far=Math.max(w.near+1,H+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(H)),w.up.copy(E),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const m=this.orthoCamera,n=e.size,l=e.center,h=Math.max(n[t.plane.width]*.5,.01),g=Math.max(n[t.plane.height]*.5,.01),_=Math.max(n[t.plane.depth]*.5,.01);let d=h*(1+s),v=g*(1+s);d/i>v?v=d/i:d=v*i;const y=_*(1+s)+Math.max(d,v),x=l.clone().add(c.multiplyScalar(y));return m.left=-d,m.right=d,m.top=v,m.bottom=-v,m.near=.1,m.far=y*4,m.zoom=1,m.position.copy(x),m.up.copy(u),m.lookAt(l),m.updateProjectionMatrix(),m.updateMatrixWorld(!0),m}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),a=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),u=Math.max((t.x+t.y)*.5,.001),p=Math.max(t.z,.001),m=Math.max(o,s.z),n=p*.5+u*.5;return c.z=m*n,c.multiply(a),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 a=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:a,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 a=e.getClearColor(new f.Color);e.setClearColor(a,0)}else s instanceof f.Color?e.setClearColor(s,1):e.setClearColor(new f.Color(s),1);else{const a=e.getClearColor(new f.Color);e.setClearColor(a,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 a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),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 u=c.createImageData(i,s),p=u.data,m=this.pixelBuffer;for(let n=0;n<s;n+=1){const h=(s-n-1)*i*4,g=n*i*4;p.set(m.subarray(h,h+i*4),g)}return c.putImageData(u,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 eu="shop-components",tu="0.3.0",iu="Shop components",su="dist/shop-components.umd.js",ru="dist/shop-components.mjs",nu="dist/main.d.ts",ou={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",test:'echo "Error: no test specified" && exit 1',dev:"vite dev --open",storybook:"storybook dev -p 6006",build:"storybook build -o dist",vite:"vite build",version:"auto-changelog -p && git add CHANGELOG.md"},au=["dist","package.json"],lu=[],cu="machengda<machengda@seer-group.com>",uu="ISC",hu={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},fu={"string-width":"4.2.3"},du={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.180.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"0.180.0","three-gpu-pathtracer":"0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},pu={name:eu,version:tu,description:iu,main:su,module:ru,types:nu,scripts:ou,files:au,keywords:lu,author:cu,license:uu,devDependencies:hu,resolutions:fu,dependencies:du};function Ar(){const r="Nebular Engin",e=pu.version,t=`%c ${r} %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 Tr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const r=globalThis;r[Tr]||(r[Tr]=!0,Ar())}catch{Ar()}exports.Amr=Qr;exports.Line=Rl;exports.Logo=Xi;exports.SGLBLoader=ui;exports.SLOT_EVENTS=q;exports.Scene3D=Jc;exports.Skin=as;exports.Slot=Zi;exports.SlotState=rn;exports.TriViewCapture=nn;exports.arrayBufferToUrl=$i;exports.calculateArrayAverage=Nr;exports.calculateFocalLength=Za;exports.createSGLBFile=ol;exports.downloadBlob=Qa;exports.dracoExporter=nl;exports.font=Zc;exports.gltfExporter=qr;exports.gltfLoader=ct;exports.imageBitmapToUrl=Qi;exports.isAppleDevice=Wr;exports.textureLoader=xs;
3800
+ `),this._controlsGizmo&&this._controlsGizmo.appendTo(e),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(e)}add(e){this._container.add(e)}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;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(),ye.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(i=this._fitAnimation)==null||i.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&&((s=this._resizeObserver)==null||s.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),this._composer.dispose(),xe(this.scene),this.scene.clear()}}class Nr{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new d.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new d.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,_,m,v,y,x;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 d.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),o=((_=e==null?void 0:e.size)==null?void 0:_.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,u=(e==null?void 0:e.includeOverlay)??!1,f=a/o||1,p=this.resolveViews(e==null?void 0:e.views),r=new d.WebGLRenderTarget(a,o,{format:d.RGBAFormat,type:d.UnsignedByteType});r.texture.colorSpace=d.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),h={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,o,e==null?void 0:e.backgroundColor);for(const b of p){const A=this.configureCamera(w,b,f,c,a,o);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,A),u&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,A));const S=this.readPixels(t,r,a,o);h[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return h}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 d.Vector3(0,0,1),up:new d.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new d.Vector3(0,-1,0),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new d.Vector3(1,0,0),up:new d.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new d.Vector3(1,1,1),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new d.Box3,i=new d.Box3,s=new d.Vector3,a=new d.Vector3,o=new d.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const f=c.geometry;if(!f)return;f.boundingBox||f.computeBoundingBox();const p=f.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new d.Vector3(.001,.001,.001)),a.set(.001,.001,.001),o.center.copy(s),o.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(o)),(!Number.isFinite(o.radius)||o.radius<=0)&&(o.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:o}}configureCamera(e,t,i,s,a,o){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const u=t.up.clone().normalize();if(Math.abs(u.dot(c))>.999&&(u.set(0,0,1),Math.abs(u.dot(c))>.999&&u.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,A=d.MathUtils.degToRad(b),S=Math.max(Math.tan(A/2),1e-4),I=Math.max(S*(i||1),1e-4),M=this.getPerspectiveDirection(t,e.size).normalize(),P=new d.Vector3().crossVectors(M,u).normalize();P.lengthSq()<1e-6&&P.set(1,0,0);const R=new d.Vector3().crossVectors(P,M).normalize(),T=Math.max(e.size.x*.5,1e-4),C=Math.max(e.size.y*.5,1e-4),D=Math.max(e.size.z*.5,1e-4),E=[new d.Vector3(-T,-C,-D),new d.Vector3(-T,-C,D),new d.Vector3(-T,C,-D),new d.Vector3(-T,C,D),new d.Vector3(T,-C,-D),new d.Vector3(T,-C,D),new d.Vector3(T,C,-D),new d.Vector3(T,C,D)];let F=0,O=-1/0;for(const $ of E){const ee=P.dot($),pe=R.dot($),ht=M.dot($);O=Math.max(O,ht);const di=ht+Math.abs(ee)/I,ft=ht+Math.abs(pe)/S;F=Math.max(F,di,ft)}F=Math.max(F,O+.1);const H=F*(1+s);let W=1/0;for(const $ of E){const ee=M.dot($),pe=H-ee;pe>.001&&(W=Math.min(W,pe))}return w.fov=b,w.aspect=i||a/Math.max(o,1),w.near=Math.max(.1,Number.isFinite(W)?W*.5:H*.1),w.far=Math.max(w.near+1,H+e.sphere.radius*3),w.position.copy(e.center).add(M.clone().multiplyScalar(H)),w.up.copy(R),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,h=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),_=Math.max(r[t.plane.depth]*.5,.01);let m=h*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const y=_*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(y));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(u),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 d.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new d.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),o=.25,c=new d.Vector3(Math.max(o,s.x)*Math.max(t.x,.001),Math.max(o,s.y)*Math.max(t.y,.001),0),u=Math.max((t.x+t.y)*.5,.001),f=Math.max(t.z,.001),p=Math.max(o,s.z),r=f*.5+u*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new d.Vector2;e.getSize(t);const i=new d.Vector4;e.getViewport(i);const s=new d.Vector4;e.getScissor(s);const a=e.getClearColor(new d.Color),o=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,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 a=e.getClearColor(new d.Color);e.setClearColor(a,0)}else s instanceof d.Color?e.setClearColor(s,1):e.setClearColor(new d.Color(s),1);else{const a=e.getClearColor(new d.Color);e.setClearColor(a,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 a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),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 u=c.createImageData(i,s),f=u.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const h=(s-r-1)*i*4,g=r*i*4;f.set(p.subarray(h,h+i*4),g)}return c.putImageData(u,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 bc="shop-components",Ac="0.3.2",Tc="Shop components",Sc="dist/shop-components.umd.js",Mc="dist/shop-components.mjs",Cc="dist/main.d.ts",Ic={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",test:'echo "Error: no test specified" && exit 1',dev:"vite dev",storybook:"storybook dev -p 6006",build:"storybook build -o dist",vite:"vite build",version:"auto-changelog -p && git add CHANGELOG.md"},Rc=["dist","package.json"],Pc=[],Dc="machengda<machengda@seer-group.com>",Lc="ISC",Ec={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},Fc={"string-width":"4.2.3"},Bc={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.180.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"^0.180.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},kc={name:bc,version:Ac,description:Tc,main:Sc,module:Mc,types:Cc,scripts:Ic,files:Rc,keywords:Pc,author:Dc,license:Lc,devDependencies:Ec,resolutions:Fc,dependencies:Bc};function lr(){const n="Nebular Engin",e=kc.version,t=`%c ${n} %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 cr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const n=globalThis;n[cr]||(n[cr]=!0,lr())}catch{lr()}exports.Amr=Er;exports.Logo=Gi;exports.SGLBLoader=ni;exports.SLOT_EVENTS=q;exports.Scene3D=wc;exports.Skin=es;exports.Slot=Wi;exports.SlotState=Hr;exports.TriViewCapture=Nr;exports.arrayBufferToUrl=Hi;exports.calculateArrayAverage=Cr;exports.calculateFocalLength=Oa;exports.createSGLBFile=Ya;exports.downloadBlob=ka;exports.dracoExporter=ja;exports.font=_c;exports.gltfExporter=Pr;exports.gltfLoader=lt;exports.imageBitmapToUrl=Ni;exports.isAppleDevice=Ir;exports.textureLoader=us;