@volter/editor 0.5.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BUNDLED_NOTICES +6196 -0
- package/LICENSE +686 -0
- package/LICENSE-BLENDER +1409 -0
- package/LICENSE-MCP +21 -0
- package/NOTICE +20 -0
- package/dist/.vite/manifest.json +1744 -0
- package/dist/assets/AudioViewer-DILwc7Pt.js +1 -0
- package/dist/assets/BVHLoader--2mLoe3e.js +1 -0
- package/dist/assets/BufferGeometryUtils-oP8-Ve4I.js +1 -0
- package/dist/assets/ColladaLoader-CyOCKXko.js +3 -0
- package/dist/assets/EntityModelDocument-DVlDQ_IJ.js +1 -0
- package/dist/assets/EnvironmentAssetDocument-BVGDJjW4.js +5 -0
- package/dist/assets/FBXLoader-DzWtiWYm.js +1 -0
- package/dist/assets/GameplaySessionTimeline-X_nMT8Sa.js +142 -0
- package/dist/assets/ImageViewer-D-aZoyr1.js +1 -0
- package/dist/assets/InspectorCanvasPreview-CLDhscy0.js +1 -0
- package/dist/assets/InspectorObjectPreview-CpHEw6QH.js +1 -0
- package/dist/assets/JsonAssetDocument-CLVN1V9Z.js +3 -0
- package/dist/assets/LineSegments2-vfeDUBfs.js +370 -0
- package/dist/assets/MTLLoader-D8SKGOsv.js +2 -0
- package/dist/assets/ModelAssetDocument-C60lQ11c.js +1 -0
- package/dist/assets/NonThreeAuthoringBootstrap-D8oHDftw.js +2 -0
- package/dist/assets/OBJLoader-8SrBLZ7J.js +5 -0
- package/dist/assets/Object3DPreview-CSmLPKkk.js +2 -0
- package/dist/assets/OnlineAssetDetail-D8wVVoay.js +2 -0
- package/dist/assets/OrbitControls-BHxt84w6.js +1 -0
- package/dist/assets/PLYLoader-BXUWXVtV.js +2 -0
- package/dist/assets/RectAreaLightUniformsLib-BGT7Bu4n.js +1 -0
- package/dist/assets/STLLoader-U-3fQm8v.js +1 -0
- package/dist/assets/SourceAssetViewer-BcOCJ2ye.js +13 -0
- package/dist/assets/StageHost-B_YrFNiC.js +1126 -0
- package/dist/assets/TDSLoader-BtiaQ4S3.js +1 -0
- package/dist/assets/ToolObject3DPreview-Crowr7IN.js +1 -0
- package/dist/assets/TransientHint-GNwuzA4c.js +1 -0
- package/dist/assets/VideoViewer-CjQ4P9AJ.js +1 -0
- package/dist/assets/_commonjsHelpers-D6-XlEtG.js +1 -0
- package/dist/assets/agx-base-srgb-BjWZJgrZ.lut +0 -0
- package/dist/assets/agx-look-medium-high-contrast-D5F_ob1L.lut +0 -0
- package/dist/assets/agx-look-punchy-dxsnycNs.lut +0 -0
- package/dist/assets/asset-editor-persistence-D3Yy77wZ.js +1 -0
- package/dist/assets/blender-emscripten-engine-C_uFxIuO.js +2 -0
- package/dist/assets/blender-node-editor.document-BfvoBocD.js +1 -0
- package/dist/assets/blender-outliner-model-B8b00oxr.js +1 -0
- package/dist/assets/blender-properties-tab-0M780SHF.js +3 -0
- package/dist/assets/blender-runtime-host-D8NHsAfD.js +4 -0
- package/dist/assets/blender-runtime-skin-DcwXD-m8.js +61 -0
- package/dist/assets/blender-runtime.document-BixTvrw8.js +7 -0
- package/dist/assets/blender-timeline.document-RtHIpbT1.js +1 -0
- package/dist/assets/blender-uv-editor.document-ChwaS3BG.js +1 -0
- package/dist/assets/blender-version.status-Bnhf8h1I.js +1 -0
- package/dist/assets/blender-wali-engine-C7bet0ss.js +2 -0
- package/dist/assets/blender.command-BCCEp0kb.js +1 -0
- package/dist/assets/blender.keymap-GAQgeklK.js +1 -0
- package/dist/assets/blender.status-ujwGU6dU.js +1 -0
- package/dist/assets/blender.style-Dcem5f_T.js +1 -0
- package/dist/assets/browserAll-Do0ehj3Q.js +14 -0
- package/dist/assets/client-DNXj_opT.js +25 -0
- package/dist/assets/clip-planes-CnAI6DZn.js +1 -0
- package/dist/assets/edit-mode-authoring-BX4IRQq9.js +1 -0
- package/dist/assets/editor-presentation-activity-C7SNSmTd.js +1 -0
- package/dist/assets/events-156d8d12.esm-Dy_KXdhT.js +36 -0
- package/dist/assets/fflate.module-DPuTF8aG.js +6 -0
- package/dist/assets/filmic-srgb-Ct35FIH6.lut +0 -0
- package/dist/assets/hosted-asset-materialization-BK7DHisS.js +2 -0
- package/dist/assets/index-5av5LJja.js +1691 -0
- package/dist/assets/index-BP6wv2A0.js +5 -0
- package/dist/assets/index-Bge9JUr6.js +1 -0
- package/dist/assets/index-BncK9THk.js +1 -0
- package/dist/assets/index-C5UECeSr.js +952 -0
- package/dist/assets/index-CJbYy-CF.js +3 -0
- package/dist/assets/index-CanA16PU.js +2 -0
- package/dist/assets/index-CinJrH5C.js +9 -0
- package/dist/assets/index-Cl83EGRl.js +2 -0
- package/dist/assets/index-CtzuWnCS.js +1 -0
- package/dist/assets/index-D2LwEE0L.js +562 -0
- package/dist/assets/index-D2fNXpHa.css +1 -0
- package/dist/assets/index-DUqP1RMl.js +1 -0
- package/dist/assets/index-D_NuPfjr.js +9 -0
- package/dist/assets/index-DaQZGF7d.js +1 -0
- package/dist/assets/index-DgapqSPi.js +7 -0
- package/dist/assets/index-IEjydI9d.js +1 -0
- package/dist/assets/index-gHZae-lw.js +13 -0
- package/dist/assets/jsx-runtime-DPjLkJKQ.js +9 -0
- package/dist/assets/model.layout-BJUEQYUI.js +1 -0
- package/dist/assets/models.finder-Bm1YfG95.js +1 -0
- package/dist/assets/product-Ywxte8eQ.js +1 -0
- package/dist/assets/properties-bone-constraints.inspector-Ck0Hzlvr.js +1 -0
- package/dist/assets/properties-bone.inspector-B8M42o0V.js +1 -0
- package/dist/assets/properties-collection.inspector-D-RSO5zy.js +1 -0
- package/dist/assets/properties-constraints.inspector-DbJa57oa.js +1 -0
- package/dist/assets/properties-data.inspector-DLgjbRW6.js +1 -0
- package/dist/assets/properties-material.inspector-B11LZYDW.js +1 -0
- package/dist/assets/properties-modifiers.inspector-BCWwuA26.js +1 -0
- package/dist/assets/properties-object.inspector-UZVJG49S.js +1 -0
- package/dist/assets/properties-output.inspector-XOwcBits.js +1 -0
- package/dist/assets/properties-particles.inspector-By04vT7R.js +1 -0
- package/dist/assets/properties-physics.inspector-D3T7FLdg.js +1 -0
- package/dist/assets/properties-render.inspector-Y0Rjr9gZ.js +1 -0
- package/dist/assets/properties-scene.inspector-CfyDWB4W.js +1 -0
- package/dist/assets/properties-texture.inspector-AFRsJx6-.js +1 -0
- package/dist/assets/properties-view-layer.inspector-Co07LAmQ.js +1 -0
- package/dist/assets/properties-world.inspector-C7T4JocI.js +1 -0
- package/dist/assets/react-18-DyywM-Z2.js +1 -0
- package/dist/assets/react-story-board-vrmj74Ng.js +1 -0
- package/dist/assets/react-three-rapier.esm-D874pLFD.js +1 -0
- package/dist/assets/sculpt.layout-zJF55yCR.js +1 -0
- package/dist/assets/session-1bPxsLdy.js +4167 -0
- package/dist/assets/shading.layout-DULYZV6M.js +1 -0
- package/dist/assets/sky-precompute-worker-ChN7J87v.js +1 -0
- package/dist/assets/spark.module-D1CUMLYS.js +12120 -0
- package/dist/assets/stage-keyboard-Cx90EYIT.js +1 -0
- package/dist/assets/stage-overlay-set-duu3P0mZ.js +1 -0
- package/dist/assets/stage-presence-markers-DKH3p_ao.js +1 -0
- package/dist/assets/story-capture-Dqurwlhr.js +1 -0
- package/dist/assets/story-mount-turn-2IYGgHob.js +1 -0
- package/dist/assets/story-pixi-preview-c78Aygdi.js +1 -0
- package/dist/assets/story-three-preview-CbZo5B3D.js +2 -0
- package/dist/assets/texture.layout-DASpHVht.js +1 -0
- package/dist/assets/three.module-BynznMJN.js +3840 -0
- package/dist/assets/uv-editing.layout-BEKHxmHw.js +1 -0
- package/dist/assets/vgai-shared-fontawesome-CFSkqz69.js +1 -0
- package/dist/assets/vgai-shared-jsx-dev-runtime-VfxIYu0y.js +9 -0
- package/dist/assets/vgai-shared-jsx-runtime-DIqBpTut.js +1 -0
- package/dist/assets/vgai-shared-react-DL5U9FnC.js +1 -0
- package/dist/assets/vgai-shared-react-dom-DFajMqMT.js +1 -0
- package/dist/assets/vgai-shared-react-dom-client-S0ozfl6_.js +1 -0
- package/dist/assets/vgai-shared-three-BWkbSQ3V.js +1 -0
- package/dist/assets/viewport-pick-context-DkawXbEi.js +1 -0
- package/dist/assets/webworkerAll-iMzrvNir.js +101 -0
- package/dist/assets/worker-DTgfRRas.js +1 -0
- package/dist/assets/world-documents-CGbrcsYk.js +3 -0
- package/dist/vgai-shared-react.json +10 -0
- package/dist/vgai-shared-three.json +3 -0
- package/dist-node/cli.js +17823 -0
- package/dist-node/create.js +14084 -0
- package/package.json +56 -0
- package/presets.mjs +2 -0
- package/src/contributions.d.ts +4 -0
- package/src/index.ts +9 -0
- package/starter/cube.blend +0 -0
- package/starter/cube.py +81 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./jsx-runtime-DPjLkJKQ.js";import{r as l}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import{t as r,B as k,C as w,R as z,S as C}from"./index-5av5LJja.js";import"./index-D2LwEE0L.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";const m={fontSize:11,color:r.content.dim,marginBottom:2};function M({assetPath:s}){const i=l.useRef(null),[a,p]=l.useState(!1),[n,f]=l.useState(null),[c,x]=l.useState(0),[h,g]=l.useState(!1),[v,y]=l.useState(1),j=s.split("/").pop()??s,b=s.split(".").pop()?.toUpperCase()??"";l.useEffect(()=>()=>{i.current?.pause()},[]);const S=()=>{const t=i.current;t&&(a?t.pause():t.play(),p(!a))},d=t=>{const o=Math.floor(t/60),u=Math.floor(t%60);return`${o}:${u.toString().padStart(2,"0")}`};return e.jsxs("div",{style:{padding:8,display:"flex",flexDirection:"column",gap:8},children:[e.jsx("div",{style:{fontWeight:600,fontSize:12,color:r.content.primary,wordBreak:"break-all"},children:j}),e.jsxs("div",{className:"vgai-content-frost",style:{width:"100%",border:`1px solid ${r.boundary.default}`,borderRadius:r.shape.small,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:8,padding:16},children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:48,height:48,children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",fill:"var(--vgai-asset-icon-audio)"}),e.jsx("path",{d:"M9 8l4-2v12l-4-2H7V10h2zm6 1v6m2-5v4",stroke:"var(--vgai-text-1)",strokeWidth:"1.5",fill:"none",strokeLinecap:"round"})]}),n!=null&&e.jsxs("div",{style:{width:"100%",fontSize:10,color:r.content.muted,textAlign:"center"},children:[d(c)," / ",d(n)]}),n!=null&&n>0&&e.jsx("div",{style:{width:"100%",height:4,background:r.surface.raised,borderRadius:r.shape.small,cursor:"pointer",position:"relative"},onClick:t=>{const o=t.currentTarget.getBoundingClientRect(),u=(t.clientX-o.left)/o.width;i.current&&(i.current.currentTime=u*n)},children:e.jsx("div",{style:{width:`${c/n*100}%`,height:"100%",background:"var(--vgai-asset-icon-audio)",borderRadius:r.shape.small}})}),e.jsx(k,{type:"button",variant:"secondary",size:"comfortable",onClick:S,children:a?"Pause":"Play"}),e.jsx("div",{role:"img","aria-label":"Audio waveform",style:{width:"100%",height:36,display:"flex",alignItems:"center",gap:2},children:Array.from({length:48},(t,o)=>e.jsx("i",{style:{flex:1,height:`${20+o*37%75}%`,background:"var(--vgai-asset-icon-audio)",opacity:o/48<=c/(n||1)?1:.3}},o))}),e.jsxs("label",{style:{fontSize:11,color:r.content.muted},children:[e.jsx(w,{checked:h,onChange:t=>g(t.target.checked)})," Loop"]}),e.jsxs("label",{style:{fontSize:11,color:r.content.muted},children:["Volume"," ",e.jsx(z,{"aria-label":"Audio volume",min:"0",max:"1",step:"0.05",value:v,onChange:t=>{const o=Number(t.target.value);y(o),i.current&&(i.current.volume=o)}})]})]}),e.jsx("audio",{ref:i,src:s,loop:h,onLoadedMetadata:()=>{i.current&&f(i.current.duration)},onTimeUpdate:()=>{i.current&&x(i.current.currentTime)},onEnded:()=>p(!1)}),e.jsx(C,{label:"Info",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsxs("div",{children:[e.jsx("div",{style:m,children:"Path"}),e.jsx("div",{style:{fontSize:11,color:r.content.primary,wordBreak:"break-all"},children:s})]}),n!=null&&e.jsxs("div",{children:[e.jsx("div",{style:m,children:"Duration"}),e.jsx("div",{style:{fontSize:11,color:r.content.primary},children:d(n)})]}),e.jsxs("div",{children:[e.jsx("div",{style:m,children:"Format"}),e.jsx("div",{style:{fontSize:11,color:r.content.primary},children:b})]})]})})]})}export{M as AudioViewer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as w,I as B,aM as R,V as u,Q as N,aN as x,aO as L,aP as g,aQ as k}from"./three.module-BynznMJN.js";class A extends w{constructor(c){super(c),this.animateBonePositions=!0,this.animateBoneRotations=!0}load(c,H,d,f){const l=this,h=new B(l.manager);h.setPath(l.path),h.setRequestHeader(l.requestHeader),h.setWithCredentials(l.withCredentials),h.load(c,function(p){try{H(l.parse(p))}catch(m){f?f(m):console.error(m),l.manager.itemError(c)}},d,f)}parse(c){function H(t){p(t)!=="HIERARCHY"&&console.error("THREE.BVHLoader: HIERARCHY expected.");const s=[],n=f(t,p(t),s);p(t)!=="MOTION"&&console.error("THREE.BVHLoader: MOTION expected.");let e=p(t).split(/[\s]+/);const o=parseInt(e[1]);isNaN(o)&&console.error("THREE.BVHLoader: Failed to read number of frames."),e=p(t).split(/[\s]+/);const i=parseFloat(e[2]);isNaN(i)&&console.error("THREE.BVHLoader: Failed to read frame time.");for(let r=0;r<o;r++)e=p(t).split(/[\s]+/),d(e,r*i,n);return s}function d(t,s,n){if(n.type==="ENDSITE")return;const e={time:s,position:new u,rotation:new N};n.frames.push(e);const o=new N,i=new u(1,0,0),r=new u(0,1,0),E=new u(0,0,1);for(let a=0;a<n.channels.length;a++)switch(n.channels[a]){case"Xposition":e.position.x=parseFloat(t.shift().trim());break;case"Yposition":e.position.y=parseFloat(t.shift().trim());break;case"Zposition":e.position.z=parseFloat(t.shift().trim());break;case"Xrotation":o.setFromAxisAngle(i,parseFloat(t.shift().trim())*Math.PI/180),e.rotation.multiply(o);break;case"Yrotation":o.setFromAxisAngle(r,parseFloat(t.shift().trim())*Math.PI/180),e.rotation.multiply(o);break;case"Zrotation":o.setFromAxisAngle(E,parseFloat(t.shift().trim())*Math.PI/180),e.rotation.multiply(o);break;default:console.warn("THREE.BVHLoader: Invalid channel type.")}for(let a=0;a<n.children.length;a++)d(t,s,n.children[a])}function f(t,s,n){const e={name:"",type:"",frames:[]};n.push(e);let o=s.split(/[\s]+/);o[0].toUpperCase()==="END"&&o[1].toUpperCase()==="SITE"?(e.type="ENDSITE",e.name="ENDSITE"):(e.name=o[1],e.type=o[0].toUpperCase()),p(t)!=="{"&&console.error("THREE.BVHLoader: Expected opening { after type & name"),o=p(t).split(/[\s]+/),o[0]!=="OFFSET"&&console.error("THREE.BVHLoader: Expected OFFSET but got: "+o[0]),o.length!==4&&console.error("THREE.BVHLoader: Invalid number of values for OFFSET.");const i=new u(parseFloat(o[1]),parseFloat(o[2]),parseFloat(o[3]));if((isNaN(i.x)||isNaN(i.y)||isNaN(i.z))&&console.error("THREE.BVHLoader: Invalid values of OFFSET."),e.offset=i,e.type!=="ENDSITE"){o=p(t).split(/[\s]+/),o[0]!=="CHANNELS"&&console.error("THREE.BVHLoader: Expected CHANNELS definition.");const r=parseInt(o[1]);e.channels=o.splice(2,r),e.children=[]}for(;;){const r=p(t);if(r==="}")return e;e.children.push(f(t,r,n))}}function l(t,s){const n=new x;if(s.push(n),n.position.add(t.offset),n.name=t.name,t.type!=="ENDSITE")for(let e=0;e<t.children.length;e++)n.add(l(t.children[e],s));return n}function h(t){const s=[];for(let n=0;n<t.length;n++){const e=t[n];if(e.type==="ENDSITE")continue;const o=[],i=[],r=[];for(let E=0;E<e.frames.length;E++){const a=e.frames[E];o.push(a.time),i.push(a.position.x+e.offset.x),i.push(a.position.y+e.offset.y),i.push(a.position.z+e.offset.z),r.push(a.rotation.x),r.push(a.rotation.y),r.push(a.rotation.z),r.push(a.rotation.w)}m.animateBonePositions&&s.push(new L(e.name+".position",o,i)),m.animateBoneRotations&&s.push(new g(e.name+".quaternion",o,r))}return new k("animation",-1,s)}function p(t){let s;for(;(s=t.shift().trim()).length===0;);return s}const m=this,y=c.split(/[\r\n]+/g),T=H(y),F=[];l(T[0],F);const I=h(T);return{skeleton:new R(F),clip:I}}}export{A as BVHLoader};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{aS as j,aT as E,aU as k,ab as z}from"./three.module-BynznMJN.js";function R(e,c=1e-4){c=Math.max(c,Number.EPSILON);const n={},f=e.getIndex(),o=e.getAttribute("position"),d=f?f.count:o.count;let t=0;const l=Object.keys(e.attributes),p={},m={},x=[],M=["getX","getY","getZ","getW"];for(let i=0,g=l.length;i<g;i++){const s=l[i];p[s]=[];const r=e.morphAttributes[s];r&&(m[s]=new Array(r.length).fill(0).map(()=>[]))}const D=Math.log10(1/c),U=Math.pow(10,D);for(let i=0;i<d;i++){const g=f?f.getX(i):i;let s="";for(let r=0,A=l.length;r<A;r++){const h=l[r],a=e.getAttribute(h),u=a.itemSize;for(let b=0;b<u;b++)s+=`${~~(a[M[b]](g)*U)},`}if(s in n)x.push(n[s]);else{for(let r=0,A=l.length;r<A;r++){const h=l[r],a=e.getAttribute(h),u=e.morphAttributes[h],b=a.itemSize,I=p[h],G=m[h];for(let X=0;X<b;X++){const S=M[X];if(I.push(a[S](g)),u)for(let T=0,B=u.length;T<B;T++)G[T].push(u[T][S](g))}}n[s]=t,x.push(t),t++}}const w=e.clone();for(let i=0,g=l.length;i<g;i++){const s=l[i],r=e.getAttribute(s),A=new r.array.constructor(p[s]),h=new z(A,r.itemSize,r.normalized);if(w.setAttribute(s,h),s in m)for(let a=0;a<m[s].length;a++){const u=e.morphAttributes[s][a],b=new u.array.constructor(m[s][a]),I=new z(b,u.itemSize,u.normalized);w.morphAttributes[s][a]=I}}return w.setIndex(x),w}function N(e,c){if(c===j)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(c===E||c===k){let n=e.getIndex();if(n===null){const t=[],l=e.getAttribute("position");if(l!==void 0){for(let p=0;p<l.count;p++)t.push(p);e.setIndex(t),n=e.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e}const f=n.count-2,o=[];if(n)if(c===E)for(let t=1;t<=f;t++)o.push(n.getX(0)),o.push(n.getX(t)),o.push(n.getX(t+1));else for(let t=0;t<f;t++)t%2===0?(o.push(n.getX(t)),o.push(n.getX(t+1)),o.push(n.getX(t+2))):(o.push(n.getX(t+2)),o.push(n.getX(t+1)),o.push(n.getX(t)));o.length/3!==f&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const d=e.clone();return d.setIndex(o),d.clearGroups(),d}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",c),e}export{R as m,N as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{b0 as kn,a4 as wn,z as it,aI as Nn,I as An,V as $,x as X,b1 as at,w as Tn,aL as En,d as rt,b as pe,aQ as ot,b2 as _n,aF as ct,aJ as Ee,i as ee,a as xn,Z as Cn,_ as vn,k as lt,$ as In,b3 as Ln,b4 as Rn,b5 as Mn,aY as Sn,aB as dt,Q as Gn,aO as ut,aP as On,aa as jn,aC as ne,aN as qn,aD as ft,b6 as Pn,a0 as Hn,b7 as Un,aG as Bn,aM as zn,f as _e,J as ht}from"./three.module-BynznMJN.js";class pt extends kn{constructor(K){super(K)}parse(K){function se(h){switch(h.image_type){case me:case z:if(h.colormap_length>256||h.colormap_size!==24||h.colormap_type!==1)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case B:case V:case ue:case be:if(h.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case Ce:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+h.image_type)}if(h.width<=0||h.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(h.pixel_size!==8&&h.pixel_size!==16&&h.pixel_size!==24&&h.pixel_size!==32)throw new Error("THREE.TGALoader: Invalid pixel size "+h.pixel_size)}function U(h,q,R,C,P){let _,v;const A=R.pixel_size>>3,N=R.width*R.height*A;if(q&&(v=P.subarray(C,C+=R.colormap_length*(R.colormap_size>>3))),h){_=new Uint8Array(N);let y,u,k,M=0;const J=new Uint8Array(A);for(;M<N;)if(y=P[C++],u=(y&127)+1,y&128){for(k=0;k<A;++k)J[k]=P[C++];for(k=0;k<u;++k)_.set(J,M+k*A);M+=A*u}else{for(u*=A,k=0;k<u;++k)_[M+k]=P[C++];M+=u}}else _=P.subarray(C,C+=q?R.width*R.height:N);return{pixel_data:_,palettes:v}}function te(h,q,R,C,P,_,v,A,N){const y=N;let u,k=0,M,J;const re=j.width;for(J=q;J!==C;J+=R)for(M=P;M!==v;M+=_,k++)u=A[k],h[(M+re*J)*4+3]=255,h[(M+re*J)*4+2]=y[u*3+0],h[(M+re*J)*4+1]=y[u*3+1],h[(M+re*J)*4+0]=y[u*3+2];return h}function I(h,q,R,C,P,_,v,A){let N,y=0,u,k;const M=j.width;for(k=q;k!==C;k+=R)for(u=P;u!==v;u+=_,y+=2)N=A[y+0]+(A[y+1]<<8),h[(u+M*k)*4+0]=(N&31744)>>7,h[(u+M*k)*4+1]=(N&992)>>2,h[(u+M*k)*4+2]=(N&31)<<3,h[(u+M*k)*4+3]=N&32768?0:255;return h}function Z(h,q,R,C,P,_,v,A){let N=0,y,u;const k=j.width;for(u=q;u!==C;u+=R)for(y=P;y!==v;y+=_,N+=3)h[(y+k*u)*4+3]=255,h[(y+k*u)*4+2]=A[N+0],h[(y+k*u)*4+1]=A[N+1],h[(y+k*u)*4+0]=A[N+2];return h}function S(h,q,R,C,P,_,v,A){let N=0,y,u;const k=j.width;for(u=q;u!==C;u+=R)for(y=P;y!==v;y+=_,N+=4)h[(y+k*u)*4+2]=A[N+0],h[(y+k*u)*4+1]=A[N+1],h[(y+k*u)*4+0]=A[N+2],h[(y+k*u)*4+3]=A[N+3];return h}function de(h,q,R,C,P,_,v,A){let N,y=0,u,k;const M=j.width;for(k=q;k!==C;k+=R)for(u=P;u!==v;u+=_,y++)N=A[y],h[(u+M*k)*4+0]=N,h[(u+M*k)*4+1]=N,h[(u+M*k)*4+2]=N,h[(u+M*k)*4+3]=255;return h}function Q(h,q,R,C,P,_,v,A){let N=0,y,u;const k=j.width;for(u=q;u!==C;u+=R)for(y=P;y!==v;y+=_,N+=2)h[(y+k*u)*4+0]=A[N+0],h[(y+k*u)*4+1]=A[N+0],h[(y+k*u)*4+2]=A[N+0],h[(y+k*u)*4+3]=A[N+1];return h}function xe(h,q,R,C,P){let _,v,A,N,y,u;switch((j.flags&ve)>>ge){default:case Le:_=0,A=1,y=q,v=0,N=1,u=R;break;case ye:_=0,A=1,y=q,v=R-1,N=-1,u=-1;break;case ie:_=q-1,A=-1,y=-1,v=0,N=1,u=R;break;case Ie:_=q-1,A=-1,y=-1,v=R-1,N=-1,u=-1;break}if(he)switch(j.pixel_size){case 8:de(h,v,N,u,_,A,y,C);break;case 16:Q(h,v,N,u,_,A,y,C);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(j.pixel_size){case 8:te(h,v,N,u,_,A,y,C,P);break;case 16:I(h,v,N,u,_,A,y,C);break;case 24:Z(h,v,N,u,_,A,y,C);break;case 32:S(h,v,N,u,_,A,y,C);break;default:throw new Error("THREE.TGALoader: Format not supported.")}return h}const Ce=0,me=1,B=2,V=3,z=9,ue=10,be=11,ve=48,ge=4,ye=0,Ie=1,Le=2,ie=3;if(K.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let L=0;const G=new Uint8Array(K),j={id_length:G[L++],colormap_type:G[L++],image_type:G[L++],colormap_index:G[L++]|G[L++]<<8,colormap_length:G[L++]|G[L++]<<8,colormap_size:G[L++],origin:[G[L++]|G[L++]<<8,G[L++]|G[L++]<<8],width:G[L++]|G[L++]<<8,height:G[L++]|G[L++]<<8,pixel_size:G[L++],flags:G[L++]};if(se(j),j.id_length+L>K.length)throw new Error("THREE.TGALoader: No data.");L+=j.id_length;let ae=!1,fe=!1,he=!1;switch(j.image_type){case z:ae=!0,fe=!0;break;case me:fe=!0;break;case ue:ae=!0;break;case B:break;case be:ae=!0,he=!0;break;case V:he=!0;break}const ke=new Uint8Array(j.width*j.height*4),we=U(ae,fe,j,L,G);return xe(ke,j.width,j.height,we.pixel_data,we.palettes),{data:ke,width:j.width,height:j.height,flipY:!0,generateMipmaps:!0,minFilter:wn}}}class Vn extends it{load(K,se,U,te){const I=this,Z=I.path===""?Nn.extractUrlBase(K):I.path,S=new An(I.manager);S.setPath(I.path),S.setRequestHeader(I.requestHeader),S.setWithCredentials(I.withCredentials),S.load(K,function(de){try{se(I.parse(de,Z))}catch(Q){te?te(Q):console.error(Q),I.manager.itemError(K)}},U,te)}parse(K,se){function U(t,e){const s=[],n=t.childNodes;for(let i=0,a=n.length;i<a;i++){const r=n[i];r.nodeName===e&&s.push(r)}return s}function te(t){if(t.length===0)return[];const e=t.trim().split(/\s+/),s=new Array(e.length);for(let n=0,i=e.length;n<i;n++)s[n]=e[n];return s}function I(t){if(t.length===0)return[];const e=t.trim().split(/\s+/),s=new Array(e.length);for(let n=0,i=e.length;n<i;n++)s[n]=parseFloat(e[n]);return s}function Z(t){if(t.length===0)return[];const e=t.trim().split(/\s+/),s=new Array(e.length);for(let n=0,i=e.length;n<i;n++)s[n]=parseInt(e[n]);return s}function S(t){return t.substring(1)}function de(){return"three_default_"+gn++}function Q(t){return Object.keys(t).length===0}function xe(t){return{unit:Ce(U(t,"unit")[0]),upAxis:me(U(t,"up_axis")[0])}}function Ce(t){return t!==void 0&&t.hasAttribute("meter")===!0?parseFloat(t.getAttribute("meter")):1}function me(t){return t!==void 0?t.textContent:"Y_UP"}function B(t,e,s,n){const i=U(t,e)[0];if(i!==void 0){const a=U(i,s);for(let r=0;r<a.length;r++)n(a[r])}}function V(t,e){for(const s in t){const n=t[s];n.build=e(t[s])}}function z(t,e){return t.build!==void 0||(t.build=e(t)),t.build}function ue(t){const e={sources:{},samplers:{},channels:{}};let s=!1;for(let n=0,i=t.childNodes.length;n<i;n++){const a=t.childNodes[n];if(a.nodeType!==1)continue;let r;switch(a.nodeName){case"source":r=a.getAttribute("id"),e.sources[r]=Re(a);break;case"sampler":r=a.getAttribute("id"),e.samplers[r]=be(a);break;case"channel":r=a.getAttribute("target"),e.channels[r]=ve(a);break;case"animation":ue(a),s=!0;break;default:console.log(a)}}s===!1&&(w.animations[t.getAttribute("id")||pe.generateUUID()]=e)}function be(t){const e={inputs:{}};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"input":const a=S(i.getAttribute("source")),r=i.getAttribute("semantic");e.inputs[r]=a;break}}return e}function ve(t){const e={};let n=t.getAttribute("target").split("/");const i=n.shift();let a=n.shift();const r=a.indexOf("(")!==-1,d=a.indexOf(".")!==-1;if(d)n=a.split("."),a=n.shift(),e.member=n.shift();else if(r){const c=a.split("(");a=c.shift();for(let l=0;l<c.length;l++)c[l]=parseInt(c[l].replace(/\)/,""));e.indices=c}return e.id=i,e.sid=a,e.arraySyntax=r,e.memberSyntax=d,e.sampler=S(t.getAttribute("source")),e}function ge(t){const e=[],s=t.channels,n=t.samplers,i=t.sources;for(const a in s)if(s.hasOwnProperty(a)){const r=s[a],d=n[r.sampler],c=d.inputs.INPUT,l=d.inputs.OUTPUT,m=i[c],o=i[l],p=Ie(r,m,o);j(p,e)}return e}function ye(t){return z(w.animations[t],ge)}function Ie(t,e,s){const n=w.nodes[t.id],i=ce(n.id),a=n.transforms[t.sid],r=n.matrix.clone().transpose();let d,c,l,m,o,p;const f={};switch(a){case"matrix":for(l=0,m=e.array.length;l<m;l++)if(d=e.array[l],c=l*s.stride,f[d]===void 0&&(f[d]={}),t.arraySyntax===!0){const O=s.array[c],x=t.indices[0]+4*t.indices[1];f[d][x]=O}else for(o=0,p=s.stride;o<p;o++)f[d][o]=s.array[c+o];break;case"translate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',a);break;case"rotate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',a);break;case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',a);break}const g=Le(f,r);return{name:i.uuid,keyframes:g}}function Le(t,e){const s=[];for(const i in t)s.push({time:parseFloat(i),value:t[i]});s.sort(n);for(let i=0;i<16;i++)ae(s,i,e.elements[i]);return s;function n(i,a){return i.time-a.time}}const ie=new $,L=new $,G=new Gn;function j(t,e){const s=t.keyframes,n=t.name,i=[],a=[],r=[],d=[];for(let c=0,l=s.length;c<l;c++){const m=s[c],o=m.time,p=m.value;D.fromArray(p).transpose(),D.decompose(ie,G,L),i.push(o),a.push(ie.x,ie.y,ie.z),r.push(G.x,G.y,G.z,G.w),d.push(L.x,L.y,L.z)}return a.length>0&&e.push(new ut(n+".position",i,a)),r.length>0&&e.push(new On(n+".quaternion",i,r)),d.length>0&&e.push(new ut(n+".scale",i,d)),e}function ae(t,e,s){let n,i=!0,a,r;for(a=0,r=t.length;a<r;a++)n=t[a],n.value[e]===void 0?n.value[e]=null:i=!1;if(i===!0)for(a=0,r=t.length;a<r;a++)n=t[a],n.value[e]=s;else fe(t,e)}function fe(t,e){let s,n;for(let i=0,a=t.length;i<a;i++){const r=t[i];if(r.value[e]===null){if(s=he(t,i,e),n=ke(t,i,e),s===null){r.value[e]=n.value[e];continue}if(n===null){r.value[e]=s.value[e];continue}we(r,s,n,e)}}}function he(t,e,s){for(;e>=0;){const n=t[e];if(n.value[s]!==null)return n;e--}return null}function ke(t,e,s){for(;e<t.length;){const n=t[e];if(n.value[s]!==null)return n;e++}return null}function we(t,e,s,n){if(s.time-e.time===0){t.value[n]=e.value[n];return}t.value[n]=(t.time-e.time)*(s.value[n]-e.value[n])/(s.time-e.time)+e.value[n]}function h(t){const e={name:t.getAttribute("id")||"default",start:parseFloat(t.getAttribute("start")||0),end:parseFloat(t.getAttribute("end")||0),animations:[]};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"instance_animation":e.animations.push(S(i.getAttribute("url")));break}}w.clips[t.getAttribute("id")]=e}function q(t){const e=[],s=t.name,n=t.end-t.start||-1,i=t.animations;for(let a=0,r=i.length;a<r;a++){const d=ye(i[a]);for(let c=0,l=d.length;c<l;c++)e.push(d[c])}return new ot(s,n,e)}function R(t){return z(w.clips[t],q)}function C(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"skin":e.id=S(i.getAttribute("source")),e.skin=P(i);break;case"morph":e.id=S(i.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");break}}w.controllers[t.getAttribute("id")]=e}function P(t){const e={sources:{}};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"bind_shape_matrix":e.bindShapeMatrix=I(i.textContent);break;case"source":const a=i.getAttribute("id");e.sources[a]=Re(i);break;case"joints":e.joints=_(i);break;case"vertex_weights":e.vertexWeights=v(i);break}}return e}function _(t){const e={inputs:{}};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"input":const a=i.getAttribute("semantic"),r=S(i.getAttribute("source"));e.inputs[a]=r;break}}return e}function v(t){const e={inputs:{}};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"input":const a=i.getAttribute("semantic"),r=S(i.getAttribute("source")),d=parseInt(i.getAttribute("offset"));e.inputs[a]={id:r,offset:d};break;case"vcount":e.vcount=Z(i.textContent);break;case"v":e.v=Z(i.textContent);break}}return e}function A(t){const e={id:t.id},s=w.geometries[e.id];return t.skin!==void 0&&(e.skin=N(t.skin),s.sources.skinIndices=e.skin.indices,s.sources.skinWeights=e.skin.weights),e}function N(t){const s={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},n=t.sources,i=t.vertexWeights,a=i.vcount,r=i.v,d=i.inputs.JOINT.offset,c=i.inputs.WEIGHT.offset,l=t.sources[t.joints.inputs.JOINT],m=t.sources[t.joints.inputs.INV_BIND_MATRIX],o=n[i.inputs.WEIGHT.id].array;let p=0,f,g,b;for(f=0,b=a.length;f<b;f++){const x=a[f],T=[];for(g=0;g<x;g++){const E=r[p+d],Y=r[p+c],F=o[Y];T.push({index:E,weight:F}),p+=2}for(T.sort(O),g=0;g<4;g++){const E=T[g];E!==void 0?(s.indices.array.push(E.index),s.weights.array.push(E.weight)):(s.indices.array.push(0),s.weights.array.push(0))}}for(t.bindShapeMatrix?s.bindMatrix=new X().fromArray(t.bindShapeMatrix).transpose():s.bindMatrix=new X().identity(),f=0,b=l.array.length;f<b;f++){const x=l.array[f],T=new X().fromArray(m.array,f*m.stride).transpose();s.joints.push({name:x,boneInverse:T})}return s;function O(x,T){return T.weight-x.weight}}function y(t){return z(w.controllers[t],A)}function u(t){const e={init_from:U(t,"init_from")[0].textContent};w.images[t.getAttribute("id")]=e}function k(t){return t.build!==void 0?t.build:t.init_from}function M(t){const e=w.images[t];return e!==void 0?z(e,k):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",t),null)}function J(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"profile_COMMON":e.profile=re(i);break}}w.effects[t.getAttribute("id")]=e}function re(t){const e={surfaces:{},samplers:{}};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"newparam":bt(i,e);break;case"technique":e.technique=kt(i);break;case"extra":e.extra=qe(i);break}}return e}function bt(t,e){const s=t.getAttribute("sid");for(let n=0,i=t.childNodes.length;n<i;n++){const a=t.childNodes[n];if(a.nodeType===1)switch(a.nodeName){case"surface":e.surfaces[s]=gt(a);break;case"sampler2D":e.samplers[s]=yt(a);break}}}function gt(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"init_from":e.init_from=i.textContent;break}}return e}function yt(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"source":e.source=i.textContent;break}}return e}function kt(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"constant":case"lambert":case"blinn":case"phong":e.type=i.nodeName,e.parameters=wt(i);break;case"extra":e.extra=qe(i);break}}return e}function wt(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":e[i.nodeName]=Oe(i);break;case"transparent":e[i.nodeName]={opaque:i.hasAttribute("opaque")?i.getAttribute("opaque"):"A_ONE",data:Oe(i)};break}}return e}function Oe(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"color":e[i.nodeName]=I(i.textContent);break;case"float":e[i.nodeName]=parseFloat(i.textContent);break;case"texture":e[i.nodeName]={id:i.getAttribute("texture"),extra:je(i)};break}}return e}function je(t){const e={technique:{}};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"extra":Nt(i,e);break}}return e}function Nt(t,e){for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"technique":At(i,e);break}}}function At(t,e){for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":e.technique[i.nodeName]=parseFloat(i.textContent);break;case"wrapU":case"wrapV":i.textContent.toUpperCase()==="TRUE"?e.technique[i.nodeName]=1:i.textContent.toUpperCase()==="FALSE"?e.technique[i.nodeName]=0:e.technique[i.nodeName]=parseInt(i.textContent);break;case"bump":e[i.nodeName]=Pe(i);break}}}function qe(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"technique":e.technique=Tt(i);break}}return e}function Tt(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"double_sided":e[i.nodeName]=parseInt(i.textContent);break;case"bump":e[i.nodeName]=Pe(i);break}}return e}function Pe(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"texture":e[i.nodeName]={id:i.getAttribute("texture"),texcoord:i.getAttribute("texcoord"),extra:je(i)};break}}return e}function He(t){return t}function Et(t){return z(w.effects[t],He)}function _t(t){const e={name:t.getAttribute("name")};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"instance_effect":e.url=S(i.getAttribute("url"));break}}w.materials[t.getAttribute("id")]=e}function xt(t){let e,s=t.slice((t.lastIndexOf(".")-1>>>0)+2);switch(s=s.toLowerCase(),s){case"tga":e=Ge;break;default:e=tt}return e}function Ue(t){const e=Et(t.url),s=e.profile.technique;let n;switch(s.type){case"phong":case"blinn":n=new ct;break;case"lambert":n=new _n;break;default:n=new at;break}n.name=t.name||"";function i(c,l=null){const m=e.profile.samplers[c.id];let o=null;if(m!==void 0){const p=e.profile.surfaces[m.source];o=M(p.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),o=M(c.id);if(o!==null){const p=xt(o);if(p!==void 0){const f=p.load(o),g=c.extra;if(g!==void 0&&g.technique!==void 0&&Q(g.technique)===!1){const b=g.technique;f.wrapS=b.wrapU?_e:ht,f.wrapT=b.wrapV?_e:ht,f.offset.set(b.offsetU||0,b.offsetV||0),f.repeat.set(b.repeatU||1,b.repeatV||1)}else f.wrapS=_e,f.wrapT=_e;return l!==null&&(f.colorSpace=l),f}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",o),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",c.id),null}const a=s.parameters;for(const c in a){const l=a[c];switch(c){case"diffuse":l.color&&n.color.fromArray(l.color),l.texture&&(n.map=i(l.texture,ee));break;case"specular":l.color&&n.specular&&n.specular.fromArray(l.color),l.texture&&(n.specularMap=i(l.texture));break;case"bump":l.texture&&(n.normalMap=i(l.texture));break;case"ambient":l.texture&&(n.lightMap=i(l.texture,ee));break;case"shininess":l.float&&n.shininess&&(n.shininess=l.float);break;case"emission":l.color&&n.emissive&&n.emissive.fromArray(l.color),l.texture&&(n.emissiveMap=i(l.texture,ee));break}}Ee.colorSpaceToWorking(n.color,ee),n.specular&&Ee.colorSpaceToWorking(n.specular,ee),n.emissive&&Ee.colorSpaceToWorking(n.emissive,ee);let r=a.transparent,d=a.transparency;if(d===void 0&&r&&(d={float:1}),r===void 0&&d&&(r={opaque:"A_ONE",data:{color:[1,1,1,1]}}),r&&d)if(r.data.texture)n.transparent=!0;else{const c=r.data.color;switch(r.opaque){case"A_ONE":n.opacity=c[3]*d.float;break;case"RGB_ZERO":n.opacity=1-c[0]*d.float;break;case"A_ZERO":n.opacity=1-c[3]*d.float;break;case"RGB_ONE":n.opacity=c[0]*d.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',r.opaque)}n.opacity<1&&(n.transparent=!0)}if(s.extra!==void 0&&s.extra.technique!==void 0){const c=s.extra.technique;for(const l in c){const m=c[l];switch(l){case"double_sided":n.side=m===1?Cn:vn;break;case"bump":n.normalMap=i(m.texture),n.normalScale=new xn(1,1);break}}}return n}function Ct(t){return z(w.materials[t],Ue)}function vt(t){const e={name:t.getAttribute("name")};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"optics":e.optics=It(i);break}}w.cameras[t.getAttribute("id")]=e}function It(t){for(let e=0;e<t.childNodes.length;e++){const s=t.childNodes[e];switch(s.nodeName){case"technique_common":return Lt(s)}}return{}}function Lt(t){const e={};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];switch(n.nodeName){case"perspective":case"orthographic":e.technique=n.nodeName,e.parameters=Rt(n);break}}return e}function Rt(t){const e={};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];switch(n.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":e[n.nodeName]=parseFloat(n.textContent);break}}return e}function Be(t){let e;switch(t.optics.technique){case"perspective":e=new lt(t.optics.parameters.yfov,t.optics.parameters.aspect_ratio,t.optics.parameters.znear,t.optics.parameters.zfar);break;case"orthographic":let s=t.optics.parameters.ymag,n=t.optics.parameters.xmag;const i=t.optics.parameters.aspect_ratio;n=n===void 0?s*i:n,s=s===void 0?n/i:s,n*=.5,s*=.5,e=new In(-n,n,s,-s,t.optics.parameters.znear,t.optics.parameters.zfar);break;default:e=new lt;break}return e.name=t.name||"",e}function Mt(t){const e=w.cameras[t];return e!==void 0?z(e,Be):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",t),null)}function St(t){let e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"technique_common":e=Gt(i);break}}w.lights[t.getAttribute("id")]=e}function Gt(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"directional":case"point":case"spot":case"ambient":e.technique=i.nodeName,e.parameters=Ot(i)}}return e}function Ot(t){const e={};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"color":const a=I(i.textContent);e.color=new rt().fromArray(a),Ee.colorSpaceToWorking(e.color,ee);break;case"falloff_angle":e.falloffAngle=parseFloat(i.textContent);break;case"quadratic_attenuation":const r=parseFloat(i.textContent);e.distance=r?Math.sqrt(1/r):0;break}}return e}function ze(t){let e;switch(t.technique){case"directional":e=new Sn;break;case"point":e=new Mn;break;case"spot":e=new Rn;break;case"ambient":e=new Ln;break}return t.parameters.color&&e.color.copy(t.parameters.color),t.parameters.distance&&(e.distance=t.parameters.distance),e}function jt(t){const e=w.lights[t];return e!==void 0?z(e,ze):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",t),null)}function qt(t){const e={name:t.getAttribute("name"),sources:{},vertices:{},primitives:[]},s=U(t,"mesh")[0];if(s!==void 0){for(let n=0;n<s.childNodes.length;n++){const i=s.childNodes[n];if(i.nodeType!==1)continue;const a=i.getAttribute("id");switch(i.nodeName){case"source":e.sources[a]=Re(i);break;case"vertices":e.vertices=Pt(i);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",i.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":e.primitives.push(Ht(i));break;default:console.log(i)}}w.geometries[t.getAttribute("id")]=e}}function Re(t){const e={array:[],stride:3};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"float_array":e.array=I(n.textContent);break;case"Name_array":e.array=te(n.textContent);break;case"technique_common":const i=U(n,"accessor")[0];i!==void 0&&(e.stride=parseInt(i.getAttribute("stride")));break}}return e}function Pt(t){const e={};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];n.nodeType===1&&(e[n.getAttribute("semantic")]=S(n.getAttribute("source")))}return e}function Ht(t){const e={type:t.nodeName,material:t.getAttribute("material"),count:parseInt(t.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let s=0,n=t.childNodes.length;s<n;s++){const i=t.childNodes[s];if(i.nodeType===1)switch(i.nodeName){case"input":const a=S(i.getAttribute("source")),r=i.getAttribute("semantic"),d=parseInt(i.getAttribute("offset")),c=parseInt(i.getAttribute("set")),l=c>0?r+c:r;e.inputs[l]={id:a,offset:d},e.stride=Math.max(e.stride,d+1),r==="TEXCOORD"&&(e.hasUV=!0);break;case"vcount":e.vcount=Z(i.textContent);break;case"p":e.p=Z(i.textContent);break}}return e}function Ut(t){const e={};for(let s=0;s<t.length;s++){const n=t[s];e[n.type]===void 0&&(e[n.type]=[]),e[n.type].push(n)}return e}function Bt(t){let e=0;for(let s=0,n=t.length;s<n;s++)t[s].hasUV===!0&&e++;e>0&&e<t.length&&(t.uvsNeedsFix=!0)}function Fe(t){const e={},s=t.sources,n=t.vertices,i=t.primitives;if(i.length===0)return{};const a=Ut(i);for(const r in a){const d=a[r];Bt(d),e[r]=zt(d,s,n)}return e}function zt(t,e,s){const n={},i={array:[],stride:0},a={array:[],stride:0},r={array:[],stride:0},d={array:[],stride:0},c={array:[],stride:0},l={array:[],stride:4},m={array:[],stride:4},o=new jn,p=[];let f=0;for(let g=0;g<t.length;g++){const b=t[g],O=b.inputs;let x=0;switch(b.type){case"lines":case"linestrips":x=b.count*2;break;case"triangles":x=b.count*3;break;case"polylist":for(let T=0;T<b.count;T++){const E=b.vcount[T];switch(E){case 3:x+=3;break;case 4:x+=6;break;default:x+=(E-2)*3;break}}break;default:console.warn("THREE.ColladaLoader: Unknown primitive type:",b.type)}o.addGroup(f,x,g),f+=x,b.material&&p.push(b.material);for(const T in O){const E=O[T];switch(T){case"VERTEX":for(const Y in s){const F=s[Y];switch(Y){case"POSITION":const le=i.array.length;if(W(b,e[F],E.offset,i.array),i.stride=e[F].stride,e.skinWeights&&e.skinIndices&&(W(b,e.skinIndices,E.offset,l.array),W(b,e.skinWeights,E.offset,m.array)),b.hasUV===!1&&t.uvsNeedsFix===!0){const yn=(i.array.length-le)/i.stride;for(let st=0;st<yn;st++)r.array.push(0,0)}break;case"NORMAL":W(b,e[F],E.offset,a.array),a.stride=e[F].stride;break;case"COLOR":W(b,e[F],E.offset,c.array),c.stride=e[F].stride;break;case"TEXCOORD":W(b,e[F],E.offset,r.array),r.stride=e[F].stride;break;case"TEXCOORD1":W(b,e[F],E.offset,d.array),r.stride=e[F].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',Y)}}break;case"NORMAL":W(b,e[E.id],E.offset,a.array),a.stride=e[E.id].stride;break;case"COLOR":W(b,e[E.id],E.offset,c.array,!0),c.stride=e[E.id].stride;break;case"TEXCOORD":W(b,e[E.id],E.offset,r.array),r.stride=e[E.id].stride;break;case"TEXCOORD1":W(b,e[E.id],E.offset,d.array),d.stride=e[E.id].stride;break}}}return i.array.length>0&&o.setAttribute("position",new ne(i.array,i.stride)),a.array.length>0&&o.setAttribute("normal",new ne(a.array,a.stride)),c.array.length>0&&o.setAttribute("color",new ne(c.array,c.stride)),r.array.length>0&&o.setAttribute("uv",new ne(r.array,r.stride)),d.array.length>0&&o.setAttribute("uv1",new ne(d.array,d.stride)),l.array.length>0&&o.setAttribute("skinIndex",new ne(l.array,l.stride)),m.array.length>0&&o.setAttribute("skinWeight",new ne(m.array,m.stride)),n.data=o,n.type=t[0].type,n.materialKeys=p,n}function W(t,e,s,n,i=!1){const a=t.p,r=t.stride,d=t.vcount;function c(o){let p=a[o+s]*m;const f=p+m;for(;p<f;p++)n.push(l[p]);if(i){const g=n.length-m-1;Ne.setRGB(n[g+0],n[g+1],n[g+2],ee),n[g+0]=Ne.r,n[g+1]=Ne.g,n[g+2]=Ne.b}}const l=e.array,m=e.stride;if(t.vcount!==void 0){let o=0;for(let p=0,f=d.length;p<f;p++){const g=d[p];if(g===4){const b=o+r*0,O=o+r*1,x=o+r*2,T=o+r*3;c(b),c(O),c(T),c(O),c(x),c(T)}else if(g===3){const b=o+r*0,O=o+r*1,x=o+r*2;c(b),c(O),c(x)}else if(g>4)for(let b=1,O=g-2;b<=O;b++){const x=o+r*0,T=o+r*b,E=o+r*(b+1);c(x),c(T),c(E)}o+=r*g}}else for(let o=0,p=a.length;o<p;o+=r)c(o)}function Ve(t){return z(w.geometries[t],Fe)}function Ft(t){const e={name:t.getAttribute("name")||"",joints:{},links:[]};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"technique_common":Kt(n,e);break}}w.kinematicsModels[t.getAttribute("id")]=e}function Vt(t){return t.build!==void 0?t.build:t}function Dt(t){return z(w.kinematicsModels[t],Vt)}function Kt(t,e){for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"joint":e.joints[n.getAttribute("sid")]=Jt(n);break;case"link":e.links.push(De(n));break}}}function Jt(t){let e;for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"prismatic":case"revolute":e=Wt(n);break}}return e}function Wt(t){const e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",axis:new $,limits:{min:0,max:0},type:t.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"axis":const i=I(n.textContent);e.axis.fromArray(i);break;case"limits":const a=n.getElementsByTagName("max")[0],r=n.getElementsByTagName("min")[0];e.limits.max=parseFloat(a.textContent),e.limits.min=parseFloat(r.textContent);break}}return e.limits.min>=e.limits.max&&(e.static=!0),e.middlePosition=(e.limits.min+e.limits.max)/2,e}function De(t){const e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",attachments:[],transforms:[]};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"attachment_full":e.attachments.push(Yt(n));break;case"matrix":case"translate":case"rotate":e.transforms.push(Ke(n));break}}return e}function Yt(t){const e={joint:t.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"link":e.links.push(De(n));break;case"matrix":case"translate":case"rotate":e.transforms.push(Ke(n));break}}return e}function Ke(t){const e={type:t.nodeName},s=I(t.textContent);switch(e.type){case"matrix":e.obj=new X,e.obj.fromArray(s).transpose();break;case"translate":e.obj=new $,e.obj.fromArray(s);break;case"rotate":e.obj=new $,e.obj.fromArray(s),e.angle=pe.degToRad(s[3]);break}return e}function Xt(t){const e={name:t.getAttribute("name")||"",rigidBodies:{}};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"rigid_body":e.rigidBodies[n.getAttribute("name")]={},Zt(n,e.rigidBodies[n.getAttribute("name")]);break}}w.physicsModels[t.getAttribute("id")]=e}function Zt(t,e){for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"technique_common":Qt(n,e);break}}}function Qt(t,e){for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"inertia":e.inertia=I(n.textContent);break;case"mass":e.mass=I(n.textContent)[0];break}}}function $t(t){const e={bindJointAxis:[]};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"bind_joint_axis":e.bindJointAxis.push(en(n));break}}w.kinematicsScenes[S(t.getAttribute("url"))]=e}function en(t){const e={target:t.getAttribute("target").split("/").pop()};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType===1)switch(n.nodeName){case"axis":const i=n.getElementsByTagName("param")[0];e.axis=i.textContent;const a=e.axis.split("inst_").pop().split("axis")[0];e.jointIndex=a.substring(0,a.length-1);break}}return e}function tn(t){return t.build!==void 0?t.build:t}function nn(t){return z(w.kinematicsScenes[t],tn)}function sn(){const t=Object.keys(w.kinematicsModels)[0],e=Object.keys(w.kinematicsScenes)[0],s=Object.keys(w.visualScenes)[0];if(t===void 0||e===void 0)return;const n=Dt(t),i=nn(e),a=Qe(s),r=i.bindJointAxis,d={};for(let m=0,o=r.length;m<o;m++){const p=r[m],f=H.querySelector('[sid="'+p.target+'"]');if(f){const g=f.parentElement;c(p.jointIndex,g)}}function c(m,o){const p=o.getAttribute("name"),f=n.joints[m];a.traverse(function(g){g.name===p&&(d[m]={object:g,transforms:an(o),joint:f,position:f.zeroPosition})})}const l=new X;nt={joints:n&&n.joints,getJointValue:function(m){const o=d[m];if(o)return o.position;console.warn("THREE.ColladaLoader: Joint "+m+" doesn't exist.")},setJointValue:function(m,o){const p=d[m];if(p){const f=p.joint;if(o>f.limits.max||o<f.limits.min)console.warn("THREE.ColladaLoader: Joint "+m+" value "+o+" outside of limits (min: "+f.limits.min+", max: "+f.limits.max+").");else if(f.static)console.warn("THREE.ColladaLoader: Joint "+m+" is static.");else{const g=p.object,b=f.axis,O=p.transforms;D.identity();for(let x=0;x<O.length;x++){const T=O[x];if(T.sid&&T.sid.indexOf(m)!==-1)switch(f.type){case"revolute":D.multiply(l.makeRotationAxis(b,pe.degToRad(o)));break;case"prismatic":D.multiply(l.makeTranslation(b.x*o,b.y*o,b.z*o));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+f.type);break}else switch(T.type){case"matrix":D.multiply(T.obj);break;case"translate":D.multiply(l.makeTranslation(T.obj.x,T.obj.y,T.obj.z));break;case"scale":D.scale(T.obj);break;case"rotate":D.multiply(l.makeRotationAxis(T.obj,T.angle));break}}g.matrix.copy(D),g.matrix.decompose(g.position,g.quaternion,g.scale),d[m].position=o}}else console.log("THREE.ColladaLoader: "+m+" does not exist.")}}}function an(t){const e=[],s=H.querySelector('[id="'+t.id+'"]');for(let n=0;n<s.childNodes.length;n++){const i=s.childNodes[n];if(i.nodeType!==1)continue;let a,r;switch(i.nodeName){case"matrix":a=I(i.textContent);const d=new X().fromArray(a).transpose();e.push({sid:i.getAttribute("sid"),type:i.nodeName,obj:d});break;case"translate":case"scale":a=I(i.textContent),r=new $().fromArray(a),e.push({sid:i.getAttribute("sid"),type:i.nodeName,obj:r});break;case"rotate":a=I(i.textContent),r=new $().fromArray(a);const c=pe.degToRad(a[3]);e.push({sid:i.getAttribute("sid"),type:i.nodeName,obj:r,angle:c});break}}return e}function rn(t){const e=t.getElementsByTagName("node");for(let s=0;s<e.length;s++){const n=e[s];n.hasAttribute("id")===!1&&n.setAttribute("id",de())}}const D=new X,oe=new $;function Me(t){const e={name:t.getAttribute("name")||"",type:t.getAttribute("type"),id:t.getAttribute("id"),sid:t.getAttribute("sid"),matrix:new X,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];if(n.nodeType!==1)continue;let i;switch(n.nodeName){case"node":e.nodes.push(n.getAttribute("id")),Me(n);break;case"instance_camera":e.instanceCameras.push(S(n.getAttribute("url")));break;case"instance_controller":e.instanceControllers.push(Je(n));break;case"instance_light":e.instanceLights.push(S(n.getAttribute("url")));break;case"instance_geometry":e.instanceGeometries.push(Je(n));break;case"instance_node":e.instanceNodes.push(S(n.getAttribute("url")));break;case"matrix":i=I(n.textContent),e.matrix.multiply(D.fromArray(i).transpose()),e.transforms[n.getAttribute("sid")]=n.nodeName;break;case"translate":i=I(n.textContent),oe.fromArray(i),e.matrix.multiply(D.makeTranslation(oe.x,oe.y,oe.z)),e.transforms[n.getAttribute("sid")]=n.nodeName;break;case"rotate":i=I(n.textContent);const a=pe.degToRad(i[3]);e.matrix.multiply(D.makeRotationAxis(oe.fromArray(i),a)),e.transforms[n.getAttribute("sid")]=n.nodeName;break;case"scale":i=I(n.textContent),e.matrix.scale(oe.fromArray(i)),e.transforms[n.getAttribute("sid")]=n.nodeName;break;case"extra":break;default:console.log(n)}}return Xe(e.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",e.id):w.nodes[e.id]=e,e}function Je(t){const e={id:S(t.getAttribute("url")),materials:{},skeletons:[]};for(let s=0;s<t.childNodes.length;s++){const n=t.childNodes[s];switch(n.nodeName){case"bind_material":const i=n.getElementsByTagName("instance_material");for(let a=0;a<i.length;a++){const r=i[a],d=r.getAttribute("symbol"),c=r.getAttribute("target");e.materials[d]=S(c)}break;case"skeleton":e.skeletons.push(S(n.textContent));break}}return e}function on(t,e){const s=[],n=[];let i,a,r;for(i=0;i<t.length;i++){const l=t[i];let m;if(Xe(l))m=ce(l),We(m,e,s);else if(fn(l)){const p=w.visualScenes[l].children;for(let f=0;f<p.length;f++){const g=p[f];if(g.type==="JOINT"){const b=ce(g.id);We(b,e,s)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",l)}for(i=0;i<e.length;i++)for(a=0;a<s.length;a++)if(r=s[a],r.bone.name===e[i].name){n[i]=r,r.processed=!0;break}for(i=0;i<s.length;i++)r=s[i],r.processed===!1&&(n.push(r),r.processed=!0);const d=[],c=[];for(i=0;i<n.length;i++)r=n[i],d.push(r.bone),c.push(r.boneInverse);return new zn(d,c)}function We(t,e,s){t.traverse(function(n){if(n.isBone===!0){let i;for(let a=0;a<e.length;a++){const r=e[a];if(r.name===n.name){i=r.boneInverse;break}}i===void 0&&(i=new X),s.push({bone:n,boneInverse:i,processed:!1})}})}function cn(t){const e=[],s=t.matrix,n=t.nodes,i=t.type,a=t.instanceCameras,r=t.instanceControllers,d=t.instanceLights,c=t.instanceGeometries,l=t.instanceNodes;for(let o=0,p=n.length;o<p;o++)e.push(ce(n[o]));for(let o=0,p=a.length;o<p;o++){const f=Mt(a[o]);f!==null&&e.push(f.clone())}for(let o=0,p=r.length;o<p;o++){const f=r[o],g=y(f.id),b=Ve(g.id),O=Ye(b,f.materials),x=f.skeletons,T=g.skin.joints,E=on(x,T);for(let Y=0,F=O.length;Y<F;Y++){const le=O[Y];le.isSkinnedMesh&&(le.bind(E,g.skin.bindMatrix),le.normalizeSkinWeights()),e.push(le)}}for(let o=0,p=d.length;o<p;o++){const f=jt(d[o]);f!==null&&e.push(f.clone())}for(let o=0,p=c.length;o<p;o++){const f=c[o],g=Ve(f.id),b=Ye(g,f.materials);for(let O=0,x=b.length;O<x;O++)e.push(b[O])}for(let o=0,p=l.length;o<p;o++)e.push(ce(l[o]).clone());let m;if(n.length===0&&e.length===1)m=e[0];else{m=i==="JOINT"?new qn:new dt;for(let o=0;o<e.length;o++)m.add(e[o])}return m.name=i==="JOINT"?t.sid:t.name,m.matrix.copy(s),m.matrix.decompose(m.position,m.quaternion,m.scale),m}const ln=new at({name:it.DEFAULT_MATERIAL_NAME,color:16711935});function dn(t,e){const s=[];for(let n=0,i=t.length;n<i;n++){const a=e[t[n]];a===void 0?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",t[n]),s.push(ln)):s.push(Ct(a))}return s}function Ye(t,e){const s=[];for(const n in t){const i=t[n],a=dn(i.materialKeys,e);if(a.length===0&&(n==="lines"||n==="linestrips"?a.push(new ft):a.push(new ct)),n==="lines"||n==="linestrips")for(let l=0,m=a.length;l<m;l++){const o=a[l];if(o.isMeshPhongMaterial===!0||o.isMeshLambertMaterial===!0){const p=new ft;p.color.copy(o.color),p.opacity=o.opacity,p.transparent=o.transparent,a[l]=p}}const r=i.data.attributes.skinIndex!==void 0,d=a.length===1?a[0]:a;let c;switch(n){case"lines":c=new Bn(i.data,d);break;case"linestrips":c=new Un(i.data,d);break;case"triangles":case"polylist":r?c=new Pn(i.data,d):c=new Hn(i.data,d);break}s.push(c)}return s}function Xe(t){return w.nodes[t]!==void 0}function ce(t){return z(w.nodes[t],cn)}function un(t){const e={name:t.getAttribute("name"),children:[]};rn(t);const s=U(t,"node");for(let n=0;n<s.length;n++)e.children.push(Me(s[n]));w.visualScenes[t.getAttribute("id")]=e}function Ze(t){const e=new dt;e.name=t.name;const s=t.children;for(let n=0;n<s.length;n++){const i=s[n];e.add(ce(i.id))}return e}function fn(t){return w.visualScenes[t]!==void 0}function Qe(t){return z(w.visualScenes[t],Ze)}function hn(t){const e=U(t,"instance_visual_scene")[0];return Qe(S(e.getAttribute("url")))}function pn(){const t=w.clips;if(Q(t)===!0){if(Q(w.animations)===!1){const e=[];for(const s in w.animations){const n=ye(s);for(let i=0,a=n.length;i<a;i++)e.push(n[i])}Ae.push(new ot("default",-1,e))}}else for(const e in t)Ae.push(R(e))}function mn(t){let e="";const s=[t];for(;s.length;){const n=s.shift();n.nodeType===Node.TEXT_NODE?e+=n.textContent:(e+=`
|
|
2
|
+
`,s.push(...n.childNodes))}return e.trim()}if(K.length===0)return{scene:new Tn};const $e=new DOMParser().parseFromString(K,"application/xml"),H=U($e,"COLLADA")[0],Se=$e.getElementsByTagName("parsererror")[0];if(Se!==void 0){const t=U(Se,"div")[0];let e;return t?e=t.textContent:e=mn(Se),console.error(`THREE.ColladaLoader: Failed to parse collada file.
|
|
3
|
+
`,e),null}const bn=H.getAttribute("version");console.debug("THREE.ColladaLoader: File version",bn);const et=xe(U(H,"asset")[0]),tt=new En(this.manager);tt.setPath(this.resourcePath||se).setCrossOrigin(this.crossOrigin);let Ge;pt&&(Ge=new pt(this.manager),Ge.setPath(this.resourcePath||se));const Ne=new rt,Ae=[];let nt={},gn=0;const w={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};B(H,"library_animations","animation",ue),B(H,"library_animation_clips","animation_clip",h),B(H,"library_controllers","controller",C),B(H,"library_images","image",u),B(H,"library_effects","effect",J),B(H,"library_materials","material",_t),B(H,"library_cameras","camera",vt),B(H,"library_lights","light",St),B(H,"library_geometries","geometry",qt),B(H,"library_nodes","node",Me),B(H,"library_visual_scenes","visual_scene",un),B(H,"library_kinematics_models","kinematics_model",Ft),B(H,"library_physics_models","physics_model",Xt),B(H,"scene","instance_kinematics_scene",$t),V(w.animations,ge),V(w.clips,q),V(w.controllers,A),V(w.images,k),V(w.effects,He),V(w.materials,Ue),V(w.cameras,Be),V(w.lights,ze),V(w.geometries,Fe),V(w.visualScenes,Ze),pn(),sn();const Te=hn(U(H,"scene")[0]);return Te.animations=Ae,et.upAxis==="Z_UP"&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),Te.rotation.set(-Math.PI/2,0,0)),Te.scale.multiplyScalar(et.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Ae},kinematics:nt,library:w,scene:Te}}}export{Vn as ColladaLoader};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"./jsx-runtime-DPjLkJKQ.js";import{r as l}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import{u as f,t as v,c as S,b,d as x,g as u}from"./index-5av5LJja.js";import"./index-D2LwEE0L.js";import{O as g}from"./StageHost-B_YrFNiC.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";import"./clip-planes-CnAI6DZn.js";import"./OrbitControls-BHxt84w6.js";import"./LineSegments2-vfeDUBfs.js";import"./viewport-pick-context-DkawXbEi.js";import"./editor-presentation-activity-C7SNSmTd.js";function h(i){const t=new Set;return i.traverse(r=>{const s=u(r,"_animationRuntime");if(s)for(const o of s.clips.values())t.add(o);const e=u(r,"_animClips");if(e)for(const o of e.values())t.add(o);for(const o of r.animations)t.add(o)}),[...t]}function w({documentId:i,source:t,sourcePath:r,displayName:s,active:e,chromeless:o=!1,revision:n=0,modelSource:p}){const d=l.useCallback(()=>{const a=S(b(t)),m=h(t);return a.animations=[...m],{root:a,animations:m,dispose(){x(a)}}},[t,n]);return c.jsx(g,{documentId:i,sourcePath:r??s,displayName:s,build:d,active:e,chromeless:o,rendererLane:o?"inspector-preview":"own",assetType:"entity",...p?{modelSource:p}:{}})}function $({documentId:i,entityId:t,displayName:r,active:s}){const e=f(),o=l.useSyncExternalStore(e.subscribe,e.getSnapshot),n=e.objectMap.get(t);return n?c.jsx(w,{documentId:i,source:n,sourcePath:`Entity ${t}`,displayName:r,active:s,revision:o,modelSource:{kind:"entity",entityId:t}}):c.jsxs("div",{role:"alert",style:{padding:20,color:v.semantic.danger},children:["Scene entity ",t," is no longer available."]})}export{$ as EntityModelDocument,w as Object3DSnapshotDocument};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as T}from"./jsx-runtime-DPjLkJKQ.js";import{aD as Xn,aE as jn,aF as $n,aG as Kn,t as Ce,aH as Ke,aI as Pe}from"./index-5av5LJja.js";import{r as ue}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{b0 as mn,H as Ee,v as Re,ac as ke,p as we,O as Ze,F as Ae,L as Ye,b9 as xe,bn as qn,aV as Vn,i as Jn,aW as Qn,w as et,k as nt,d as tt,bo as ot,b1 as rt,a0 as qe,am as ze,bp as Ve,bq as st,b as it}from"./three.module-BynznMJN.js";import{O as lt}from"./OrbitControls-BHxt84w6.js";import{u as Ge}from"./fflate.module-DPuTF8aG.js";import{s as ct}from"./asset-editor-persistence-D3Yy77wZ.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./client-DNXj_opT.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";class at extends mn{constructor(g){super(g),this.type=Ee,this.outputFormat=Re}parse(g){const N=Math.pow(2.7182818,2.2);function k(e,n){let t=0;for(let s=0;s<65536;++s)(s==0||e[s>>3]&1<<(s&7))&&(n[t++]=s);const r=t-1;for(;t<65536;)n[t++]=0;return r}function P(e){for(let n=0;n<16384;n++)e[n]={},e[n].len=0,e[n].lit=0,e[n].p=null}const U={l:0,c:0,lc:0};function z(e,n,t,r,s){for(;t<e;)n=n<<8|an(r,s),t+=8;t-=e,U.l=n>>t&(1<<e)-1,U.c=n,U.lc=t}const I=new Array(59);function W(e){for(let t=0;t<=58;++t)I[t]=0;for(let t=0;t<65537;++t)I[e[t]]+=1;let n=0;for(let t=58;t>0;--t){const r=n+I[t]>>1;I[t]=n,n=r}for(let t=0;t<65537;++t){const r=e[t];r>0&&(e[t]=r|I[r]++<<6)}}function O(e,n,t,r,s,a){const o=n;let u=0,l=0;for(;r<=s;r++){if(o.value-n.value>t)return!1;z(6,u,l,e,o);const i=U.l;if(u=U.c,l=U.lc,a[r]=i,i==63){if(o.value-n.value>t)throw new Error("Something wrong with hufUnpackEncTable");z(8,u,l,e,o);let c=U.l+6;if(u=U.c,l=U.lc,r+c>s+1)throw new Error("Something wrong with hufUnpackEncTable");for(;c--;)a[r++]=0;r--}else if(i>=59){let c=i-59+2;if(r+c>s+1)throw new Error("Something wrong with hufUnpackEncTable");for(;c--;)a[r++]=0;r--}}W(a)}function pe(e){return e&63}function Ue(e){return e>>6}function ye(e,n,t,r){for(;n<=t;n++){const s=Ue(e[n]),a=pe(e[n]);if(s>>a)throw new Error("Invalid table entry");if(a>14){const o=r[s>>a-14];if(o.len)throw new Error("Invalid table entry");if(o.lit++,o.p){const u=o.p;o.p=new Array(o.lit);for(let l=0;l<o.lit-1;++l)o.p[l]=u[l]}else o.p=new Array(1);o.p[o.lit-1]=n}else if(a){let o=0;for(let u=1<<14-a;u>0;u--){const l=r[(s<<14-a)+o];if(l.len||l.p)throw new Error("Invalid table entry");l.len=a,l.lit=n,o++}}}return!0}const K={c:0,lc:0};function Te(e,n,t,r){e=e<<8|an(t,r),n+=8,K.c=e,K.lc=n}const q={c:0,lc:0};function oe(e,n,t,r,s,a,o,u,l){if(e==n){r<8&&(Te(t,r,s,a),t=K.c,r=K.lc),r-=8;let i=t>>r;if(i=new Uint8Array([i])[0],u.value+i>l)return!1;const c=o[u.value-1];for(;i-- >0;)o[u.value++]=c}else if(u.value<l)o[u.value++]=e;else return!1;q.c=t,q.lc=r}function ve(e){return e&65535}function Je(e){const n=ve(e);return n>32767?n-65536:n}const Z={a:0,b:0};function Ie(e,n){const t=Je(e),s=Je(n),a=t+(s&1)+(s>>1),o=a,u=a-s;Z.a=o,Z.b=u}function be(e,n){const t=ve(e),r=ve(n),s=t-(r>>1)&65535,a=r+s-32768&65535;Z.a=a,Z.b=s}function dn(e,n,t,r,s,a,o){const u=o<16384,l=t>s?s:t;let i=1,c,p;for(;i<=l;)i<<=1;for(i>>=1,c=i,i>>=1;i>=1;){p=0;const h=p+a*(s-c),d=a*i,E=a*c,m=r*i,w=r*c;let y,A,L,$;for(;p<=h;p+=E){let D=p;const v=p+r*(t-c);for(;D<=v;D+=w){const G=D+m,V=D+d,B=V+m;u?(Ie(e[D+n],e[V+n]),y=Z.a,L=Z.b,Ie(e[G+n],e[B+n]),A=Z.a,$=Z.b,Ie(y,A),e[D+n]=Z.a,e[G+n]=Z.b,Ie(L,$),e[V+n]=Z.a,e[B+n]=Z.b):(be(e[D+n],e[V+n]),y=Z.a,L=Z.b,be(e[G+n],e[B+n]),A=Z.a,$=Z.b,be(y,A),e[D+n]=Z.a,e[G+n]=Z.b,be(L,$),e[V+n]=Z.a,e[B+n]=Z.b)}if(t&i){const G=D+d;u?Ie(e[D+n],e[G+n]):be(e[D+n],e[G+n]),y=Z.a,e[G+n]=Z.b,e[D+n]=y}}if(s&i){let D=p;const v=p+r*(t-c);for(;D<=v;D+=w){const G=D+m;u?Ie(e[D+n],e[G+n]):be(e[D+n],e[G+n]),y=Z.a,e[G+n]=Z.b,e[D+n]=y}}c=i,i>>=1}return p}function fn(e,n,t,r,s,a,o,u,l){let i=0,c=0;const p=o,h=Math.trunc(r.value+(s+7)/8);for(;r.value<h;)for(Te(i,c,t,r),i=K.c,c=K.lc;c>=14;){const E=i>>c-14&16383,m=n[E];if(m.len)c-=m.len,oe(m.lit,a,i,c,t,r,u,l,p),i=q.c,c=q.lc;else{if(!m.p)throw new Error("hufDecode issues");let w;for(w=0;w<m.lit;w++){const y=pe(e[m.p[w]]);for(;c<y&&r.value<h;)Te(i,c,t,r),i=K.c,c=K.lc;if(c>=y&&Ue(e[m.p[w]])==(i>>c-y&(1<<y)-1)){c-=y,oe(m.p[w],a,i,c,t,r,u,l,p),i=q.c,c=q.lc;break}}if(w==m.lit)throw new Error("hufDecode issues")}}const d=8-s&7;for(i>>=d,c-=d;c>0;){const E=n[i<<14-c&16383];if(E.len)c-=E.len,oe(E.lit,a,i,c,t,r,u,l,p),i=q.c,c=q.lc;else throw new Error("hufDecode issues")}return!0}function Qe(e,n,t,r,s,a){const o={value:0},u=t.value,l=ie(n,t),i=ie(n,t);t.value+=4;const c=ie(n,t);if(t.value+=4,l<0||l>=65537||i<0||i>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const p=new Array(65537),h=new Array(16384);P(h);const d=r-(t.value-u);if(O(e,t,d,l,i,p),c>8*(r-(t.value-u)))throw new Error("Something wrong with hufUncompress");ye(p,l,i,h),fn(p,h,e,t,c,i,a,s,o)}function wn(e,n,t){for(let r=0;r<t;++r)n[r]=e[n[r]]}function en(e){for(let n=1;n<e.length;n++){const t=e[n-1]+e[n]-128;e[n]=t}}function nn(e,n){let t=0,r=Math.floor((e.length+1)/2),s=0;const a=e.length-1;for(;!(s>a||(n[s++]=e[t++],s>a));)n[s++]=e[r++]}function tn(e){let n=e.byteLength;const t=new Array;let r=0;const s=new DataView(e);for(;n>0;){const a=s.getInt8(r++);if(a<0){const o=-a;n-=o+1;for(let u=0;u<o;u++)t.push(s.getUint8(r++))}else{const o=a;n-=2;const u=s.getUint8(r++);for(let l=0;l<o+1;l++)t.push(u)}}return t}function En(e,n,t,r,s,a){let o=new DataView(a.buffer);const u=t[e.idx[0]].width,l=t[e.idx[0]].height,i=3,c=Math.floor(u/8),p=Math.ceil(u/8),h=Math.ceil(l/8),d=u-(p-1)*8,E=l-(h-1)*8,m={value:0},w=new Array(i),y=new Array(i),A=new Array(i),L=new Array(i),$=new Array(i);for(let v=0;v<i;++v)$[v]=n[e.idx[v]],w[v]=v<1?0:w[v-1]+p*h,y[v]=new Float32Array(64),A[v]=new Uint16Array(64),L[v]=new Uint16Array(p*64);for(let v=0;v<h;++v){let G=8;v==h-1&&(G=E);let V=8;for(let C=0;C<p;++C){C==p-1&&(V=d);for(let F=0;F<i;++F)A[F].fill(0),A[F][0]=s[w[F]++],on(m,r,A[F]),rn(A[F],y[F]),sn(y[F]);yn(y);for(let F=0;F<i;++F)ln(y[F],L[F],C*64)}let B=0;for(let C=0;C<i;++C){const F=t[e.idx[C]].type;for(let me=8*v;me<8*v+G;++me){B=$[C][me];for(let De=0;De<c;++De){const ae=De*64+(me&7)*8;o.setUint16(B+0*F,L[C][ae+0],!0),o.setUint16(B+2*F,L[C][ae+1],!0),o.setUint16(B+4*F,L[C][ae+2],!0),o.setUint16(B+6*F,L[C][ae+3],!0),o.setUint16(B+8*F,L[C][ae+4],!0),o.setUint16(B+10*F,L[C][ae+5],!0),o.setUint16(B+12*F,L[C][ae+6],!0),o.setUint16(B+14*F,L[C][ae+7],!0),B+=16*F}}if(c!=p)for(let me=8*v;me<8*v+G;++me){const De=$[C][me]+8*c*2*F,ae=c*64+(me&7)*8;for(let He=0;He<V;++He)o.setUint16(De+He*2*F,L[C][ae+He],!0)}}}const D=new Uint16Array(u);o=new DataView(a.buffer);for(let v=0;v<i;++v){t[e.idx[v]].decoded=!0;const G=t[e.idx[v]].type;if(t[v].type==2)for(let V=0;V<l;++V){const B=$[v][V];for(let C=0;C<u;++C)D[C]=o.getUint16(B+C*2*G,!0);for(let C=0;C<u;++C)o.setFloat32(B+C*2*G,f(D[C]),!0)}}}function gn(e,n,t,r,s,a){const o=new DataView(a.buffer),u=t[e],l=u.width,i=u.height,c=Math.ceil(l/8),p=Math.ceil(i/8),h=Math.floor(l/8),d=l-(c-1)*8,E=i-(p-1)*8,m={value:0};let w=0;const y=new Float32Array(64),A=new Uint16Array(64),L=new Uint16Array(c*64);for(let $=0;$<p;++$){let D=8;$==p-1&&(D=E);for(let v=0;v<c;++v)A.fill(0),A[0]=s[w++],on(m,r,A),rn(A,y),sn(y),ln(y,L,v*64);for(let v=8*$;v<8*$+D;++v){let G=n[e][v];for(let V=0;V<h;++V){const B=V*64+(v&7)*8;for(let C=0;C<8;++C)o.setUint16(G+C*2*u.type,L[B+C],!0);G+=16*u.type}if(c!=h){const V=h*64+(v&7)*8;for(let B=0;B<d;++B)o.setUint16(G+B*2*u.type,L[V+B],!0)}}}u.decoded=!0}function on(e,n,t){let r,s=1;for(;s<64;)r=n[e.value],r==65280?s=64:r>>8==255?s+=r&255:(t[s]=r,s++),e.value++}function rn(e,n){n[0]=f(e[0]),n[1]=f(e[1]),n[2]=f(e[5]),n[3]=f(e[6]),n[4]=f(e[14]),n[5]=f(e[15]),n[6]=f(e[27]),n[7]=f(e[28]),n[8]=f(e[2]),n[9]=f(e[4]),n[10]=f(e[7]),n[11]=f(e[13]),n[12]=f(e[16]),n[13]=f(e[26]),n[14]=f(e[29]),n[15]=f(e[42]),n[16]=f(e[3]),n[17]=f(e[8]),n[18]=f(e[12]),n[19]=f(e[17]),n[20]=f(e[25]),n[21]=f(e[30]),n[22]=f(e[41]),n[23]=f(e[43]),n[24]=f(e[9]),n[25]=f(e[11]),n[26]=f(e[18]),n[27]=f(e[24]),n[28]=f(e[31]),n[29]=f(e[40]),n[30]=f(e[44]),n[31]=f(e[53]),n[32]=f(e[10]),n[33]=f(e[19]),n[34]=f(e[23]),n[35]=f(e[32]),n[36]=f(e[39]),n[37]=f(e[45]),n[38]=f(e[52]),n[39]=f(e[54]),n[40]=f(e[20]),n[41]=f(e[22]),n[42]=f(e[33]),n[43]=f(e[38]),n[44]=f(e[46]),n[45]=f(e[51]),n[46]=f(e[55]),n[47]=f(e[60]),n[48]=f(e[21]),n[49]=f(e[34]),n[50]=f(e[37]),n[51]=f(e[47]),n[52]=f(e[50]),n[53]=f(e[56]),n[54]=f(e[59]),n[55]=f(e[61]),n[56]=f(e[35]),n[57]=f(e[36]),n[58]=f(e[48]),n[59]=f(e[49]),n[60]=f(e[57]),n[61]=f(e[58]),n[62]=f(e[62]),n[63]=f(e[63])}function sn(e){const n=.5*Math.cos(.7853975),t=.5*Math.cos(3.14159/16),r=.5*Math.cos(3.14159/8),s=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(5*3.14159/16),o=.5*Math.cos(3*3.14159/8),u=.5*Math.cos(7*3.14159/16),l=new Array(4),i=new Array(4),c=new Array(4),p=new Array(4);for(let h=0;h<8;++h){const d=h*8;l[0]=r*e[d+2],l[1]=o*e[d+2],l[2]=r*e[d+6],l[3]=o*e[d+6],i[0]=t*e[d+1]+s*e[d+3]+a*e[d+5]+u*e[d+7],i[1]=s*e[d+1]-u*e[d+3]-t*e[d+5]-a*e[d+7],i[2]=a*e[d+1]-t*e[d+3]+u*e[d+5]+s*e[d+7],i[3]=u*e[d+1]-a*e[d+3]+s*e[d+5]-t*e[d+7],c[0]=n*(e[d+0]+e[d+4]),c[3]=n*(e[d+0]-e[d+4]),c[1]=l[0]+l[3],c[2]=l[1]-l[2],p[0]=c[0]+c[1],p[1]=c[3]+c[2],p[2]=c[3]-c[2],p[3]=c[0]-c[1],e[d+0]=p[0]+i[0],e[d+1]=p[1]+i[1],e[d+2]=p[2]+i[2],e[d+3]=p[3]+i[3],e[d+4]=p[3]-i[3],e[d+5]=p[2]-i[2],e[d+6]=p[1]-i[1],e[d+7]=p[0]-i[0]}for(let h=0;h<8;++h)l[0]=r*e[16+h],l[1]=o*e[16+h],l[2]=r*e[48+h],l[3]=o*e[48+h],i[0]=t*e[8+h]+s*e[24+h]+a*e[40+h]+u*e[56+h],i[1]=s*e[8+h]-u*e[24+h]-t*e[40+h]-a*e[56+h],i[2]=a*e[8+h]-t*e[24+h]+u*e[40+h]+s*e[56+h],i[3]=u*e[8+h]-a*e[24+h]+s*e[40+h]-t*e[56+h],c[0]=n*(e[h]+e[32+h]),c[3]=n*(e[h]-e[32+h]),c[1]=l[0]+l[3],c[2]=l[1]-l[2],p[0]=c[0]+c[1],p[1]=c[3]+c[2],p[2]=c[3]-c[2],p[3]=c[0]-c[1],e[0+h]=p[0]+i[0],e[8+h]=p[1]+i[1],e[16+h]=p[2]+i[2],e[24+h]=p[3]+i[3],e[32+h]=p[3]-i[3],e[40+h]=p[2]-i[2],e[48+h]=p[1]-i[1],e[56+h]=p[0]-i[0]}function yn(e){for(let n=0;n<64;++n){const t=e[0][n],r=e[1][n],s=e[2][n];e[0][n]=t+1.5747*s,e[1][n]=t-.1873*r-.4682*s,e[2][n]=t+1.8556*r}}function ln(e,n,t){for(let r=0;r<64;++r)n[t+r]=xe.toHalfFloat(Sn(e[r]))}function Sn(e){return e<=1?Math.sign(e)*Math.pow(Math.abs(e),2.2):Math.sign(e)*Math.pow(N,Math.abs(e)-1)}function je(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function _n(e){const n=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),t=new Uint8Array(tn(n)),r=new Uint8Array(t.length);return en(t),nn(t,r),new DataView(r.buffer)}function $e(e){const n=e.array.slice(e.offset.value,e.offset.value+e.size),t=Ge(n),r=new Uint8Array(t.length);return en(t),nn(t,r),new DataView(r.buffer)}function vn(e){const n=e.viewer,t={value:e.offset.value},r=new Uint16Array(e.columns*e.lines*(e.inputChannels.length*e.type)),s=new Uint8Array(8192);let a=0;const o=new Array(e.inputChannels.length);for(let E=0,m=e.inputChannels.length;E<m;E++)o[E]={},o[E].start=a,o[E].end=o[E].start,o[E].nx=e.columns,o[E].ny=e.lines,o[E].size=e.type,a+=o[E].nx*o[E].ny*o[E].size;const u=Oe(n,t),l=Oe(n,t);if(l>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(u<=l)for(let E=0;E<l-u+1;E++)s[E+u]=de(n,t);const i=new Uint16Array(65536),c=k(s,i),p=ie(n,t);Qe(e.array,n,t,p,r,a);for(let E=0;E<e.inputChannels.length;++E){const m=o[E];for(let w=0;w<o[E].size;++w)dn(r,m.start+w,m.nx,m.size,m.ny,m.nx*m.size,c)}wn(i,r,a);let h=0;const d=new Uint8Array(r.buffer.byteLength);for(let E=0;E<e.lines;E++)for(let m=0;m<e.inputChannels.length;m++){const w=o[m],y=w.nx*w.size,A=new Uint8Array(r.buffer,w.end*2,y*2);d.set(A,h),h+=y*2,w.end+=y}return new DataView(d.buffer)}function In(e){const n=e.array.slice(e.offset.value,e.offset.value+e.size),t=Ge(n),r=e.inputChannels.length*e.lines*e.columns*e.totalBytes,s=new ArrayBuffer(r),a=new DataView(s);let o=0,u=0;const l=new Array(4);for(let i=0;i<e.lines;i++)for(let c=0;c<e.inputChannels.length;c++){let p=0;switch(e.inputChannels[c].pixelType){case 1:l[0]=o,l[1]=l[0]+e.columns,o=l[1]+e.columns;for(let d=0;d<e.columns;++d){const E=t[l[0]++]<<8|t[l[1]++];p+=E,a.setUint16(u,p,!0),u+=2}break;case 2:l[0]=o,l[1]=l[0]+e.columns,l[2]=l[1]+e.columns,o=l[2]+e.columns;for(let d=0;d<e.columns;++d){const E=t[l[0]++]<<24|t[l[1]++]<<16|t[l[2]++]<<8;p+=E,a.setUint32(u,p,!0),u+=4}break}}return a}function cn(e){const n=e.viewer,t={value:e.offset.value},r=new Uint8Array(e.columns*e.lines*(e.inputChannels.length*e.type*2)),s={version:re(n,t),unknownUncompressedSize:re(n,t),unknownCompressedSize:re(n,t),acCompressedSize:re(n,t),dcCompressedSize:re(n,t),rleCompressedSize:re(n,t),rleUncompressedSize:re(n,t),rleRawSize:re(n,t),totalAcUncompressedCount:re(n,t),totalDcUncompressedCount:re(n,t),acCompression:re(n,t)};if(s.version<2)throw new Error("EXRLoader.parse: "+Se.compression+" version "+s.version+" is unsupported");const a=new Array;let o=Oe(n,t)-2;for(;o>0;){const m=Be(n.buffer,t),w=de(n,t),y=w>>2&3,A=(w>>4)-1,L=new Int8Array([A])[0],$=de(n,t);a.push({name:m,index:L,type:$,compression:y}),o-=m.length+3}const u=Se.channels,l=new Array(e.inputChannels.length);for(let m=0;m<e.inputChannels.length;++m){const w=l[m]={},y=u[m];w.name=y.name,w.compression=0,w.decoded=!1,w.type=y.pixelType,w.pLinear=y.pLinear,w.width=e.columns,w.height=e.lines}const i={idx:new Array(3)};for(let m=0;m<e.inputChannels.length;++m){const w=l[m];for(let y=0;y<a.length;++y){const A=a[y];w.name==A.name&&(w.compression=A.compression,A.index>=0&&(i.idx[A.index]=m),w.offset=m)}}let c,p,h;if(s.acCompressedSize>0)switch(s.acCompression){case 0:c=new Uint16Array(s.totalAcUncompressedCount),Qe(e.array,n,t,s.acCompressedSize,c,s.totalAcUncompressedCount);break;case 1:const m=e.array.slice(t.value,t.value+s.totalAcUncompressedCount),w=Ge(m);c=new Uint16Array(w.buffer),t.value+=s.totalAcUncompressedCount;break}if(s.dcCompressedSize>0){const m={array:e.array,offset:t,size:s.dcCompressedSize};p=new Uint16Array($e(m).buffer),t.value+=s.dcCompressedSize}if(s.rleRawSize>0){const m=e.array.slice(t.value,t.value+s.rleCompressedSize),w=Ge(m);h=tn(w.buffer),t.value+=s.rleCompressedSize}let d=0;const E=new Array(l.length);for(let m=0;m<E.length;++m)E[m]=new Array;for(let m=0;m<e.lines;++m)for(let w=0;w<l.length;++w)E[w].push(d),d+=l[w].width*e.type*2;i.idx[0]!==void 0&&l[i.idx[0]]&&En(i,E,l,c,p,r);for(let m=0;m<l.length;++m){const w=l[m];if(!w.decoded)switch(w.compression){case 2:let y=0,A=0;for(let L=0;L<e.lines;++L){let $=E[m][y];for(let D=0;D<w.width;++D){for(let v=0;v<2*w.type;++v)r[$++]=h[A+v*w.width*w.height];A++}y++}break;case 1:gn(m,E,l,c,p,r);break;default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(r.buffer)}function Be(e,n){const t=new Uint8Array(e);let r=0;for(;t[n.value+r]!=0;)r+=1;const s=new TextDecoder().decode(t.slice(n.value,n.value+r));return n.value=n.value+r+1,s}function bn(e,n,t){const r=new TextDecoder().decode(new Uint8Array(e).slice(n.value,n.value+t));return n.value=n.value+t,r}function Rn(e,n){const t=se(e,n),r=ie(e,n);return[t,r]}function Cn(e,n){const t=ie(e,n),r=ie(e,n);return[t,r]}function se(e,n){const t=e.getInt32(n.value,!0);return n.value=n.value+4,t}function ie(e,n){const t=e.getUint32(n.value,!0);return n.value=n.value+4,t}function an(e,n){const t=e[n.value];return n.value=n.value+1,t}function de(e,n){const t=e.getUint8(n.value);return n.value=n.value+1,t}const re=function(e,n){let t;return"getBigInt64"in DataView.prototype?t=Number(e.getBigInt64(n.value,!0)):t=e.getUint32(n.value+4,!0)+Number(e.getUint32(n.value,!0)<<32),n.value+=8,t};function ne(e,n){const t=e.getFloat32(n.value,!0);return n.value+=4,t}function xn(e,n){return xe.toHalfFloat(ne(e,n))}function f(e){const n=(e&31744)>>10,t=e&1023;return(e>>15?-1:1)*(n?n===31?t?NaN:1/0:Math.pow(2,n-15)*(1+t/1024):6103515625e-14*(t/1024))}function Oe(e,n){const t=e.getUint16(n.value,!0);return n.value+=2,t}function An(e,n){return f(Oe(e,n))}function Mn(e,n,t,r){const s=t.value,a=[];for(;t.value<s+r-1;){const o=Be(n,t),u=se(e,t),l=de(e,t);t.value+=3;const i=se(e,t),c=se(e,t);a.push({name:o,pixelType:u,pLinear:l,xSampling:i,ySampling:c})}return t.value+=1,a}function Nn(e,n){const t=ne(e,n),r=ne(e,n),s=ne(e,n),a=ne(e,n),o=ne(e,n),u=ne(e,n),l=ne(e,n),i=ne(e,n);return{redX:t,redY:r,greenX:s,greenY:a,blueX:o,blueY:u,whiteX:l,whiteY:i}}function Un(e,n){const t=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],r=de(e,n);return t[r]}function Tn(e,n){const t=se(e,n),r=se(e,n),s=se(e,n),a=se(e,n);return{xMin:t,yMin:r,xMax:s,yMax:a}}function On(e,n){const t=["INCREASING_Y","DECREASING_Y","RANDOM_Y"],r=de(e,n);return t[r]}function Dn(e,n){const t=["ENVMAP_LATLONG","ENVMAP_CUBE"],r=de(e,n);return t[r]}function kn(e,n){const t=["ONE_LEVEL","MIPMAP_LEVELS","RIPMAP_LEVELS"],r=["ROUND_DOWN","ROUND_UP"],s=ie(e,n),a=ie(e,n),o=de(e,n);return{xSize:s,ySize:a,levelMode:t[o&15],roundingMode:r[o>>4]}}function Ln(e,n){const t=ne(e,n),r=ne(e,n);return[t,r]}function Fn(e,n){const t=ne(e,n),r=ne(e,n),s=ne(e,n);return[t,r,s]}function Bn(e,n,t,r,s){if(r==="string"||r==="stringvector"||r==="iccProfile")return bn(n,t,s);if(r==="chlist")return Mn(e,n,t,s);if(r==="chromaticities")return Nn(e,t);if(r==="compression")return Un(e,t);if(r==="box2i")return Tn(e,t);if(r==="envmap")return Dn(e,t);if(r==="tiledesc")return kn(e,t);if(r==="lineOrder")return On(e,t);if(r==="float")return ne(e,t);if(r==="v2f")return Ln(e,t);if(r==="v3f")return Fn(e,t);if(r==="int")return se(e,t);if(r==="rational")return Rn(e,t);if(r==="timecode")return Cn(e,t);if(r==="preview")return t.value+=s,"skipped";t.value+=s}function Hn(e,n){const t=Math.log2(e);return n=="ROUND_DOWN"?Math.floor(t):Math.ceil(t)}function Pn(e,n,t){let r=0;switch(e.levelMode){case"ONE_LEVEL":r=1;break;case"MIPMAP_LEVELS":r=Hn(Math.max(n,t),e.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return r}function un(e,n,t,r){const s=new Array(e);for(let a=0;a<e;a++){const o=1<<a;let u=n/o|0;r=="ROUND_UP"&&u*o<n&&(u+=1);const l=Math.max(u,1);s[a]=(l+t-1)/t|0}return s}function Zn(){const e=this,n=e.offset,t={value:0};for(let r=0;r<e.tileCount;r++){const s=se(e.viewer,n),a=se(e.viewer,n);n.value+=8,e.size=ie(e.viewer,n);const o=s*e.blockWidth,u=a*e.blockHeight;e.columns=o+e.blockWidth>e.width?e.width-o:e.blockWidth,e.lines=u+e.blockHeight>e.height?e.height-u:e.blockHeight;const l=e.columns*e.totalBytes,c=e.size<e.lines*l?e.uncompress(e):je(e);n.value+=e.size;for(let p=0;p<e.lines;p++){const h=p*e.columns*e.totalBytes;for(let d=0;d<e.inputChannels.length;d++){const E=Se.channels[d].name,m=e.channelByteOffsets[E]*e.columns,w=e.decodeChannels[E];if(w===void 0)continue;t.value=h+m;const y=(e.height-(1+u+p))*e.outLineWidth;for(let A=0;A<e.columns;A++){const L=y+(A+o)*e.outputChannels+w;e.byteArray[L]=e.getter(c,t)}}}}}function zn(){const e=this,n=e.offset,t={value:0};for(let r=0;r<e.height/e.blockHeight;r++){const s=se(e.viewer,n)-Se.dataWindow.yMin;e.size=ie(e.viewer,n),e.lines=s+e.blockHeight>e.height?e.height-s:e.blockHeight;const a=e.columns*e.totalBytes,u=e.size<e.lines*a?e.uncompress(e):je(e);n.value+=e.size;for(let l=0;l<e.blockHeight;l++){const i=r*e.blockHeight,c=l+e.scanOrder(i);if(c>=e.height)continue;const p=l*a,h=(e.height-1-c)*e.outLineWidth;for(let d=0;d<e.inputChannels.length;d++){const E=Se.channels[d].name,m=e.channelByteOffsets[E]*e.columns,w=e.decodeChannels[E];if(w!==void 0){t.value=p+m;for(let y=0;y<e.columns;y++){const A=h+y*e.outputChannels+w;e.byteArray[A]=e.getter(u,t)}}}}}}function Gn(e,n,t){const r={};if(e.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");r.version=e.getUint8(4);const s=e.getUint8(5);r.spec={singleTile:!!(s&2),longName:!!(s&4),deepFormat:!!(s&8),multiPart:!!(s&16)},t.value=8;let a=!0;for(;a;){const o=Be(n,t);if(o==="")a=!1;else{const u=Be(n,t),l=ie(e,t),i=Bn(e,n,t,u,l);i===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${u}'.`):r[o]=i}}if((s&-7)!=0)throw console.error("THREE.EXRHeader:",r),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return r}function Yn(e,n,t,r,s,a){const o={size:0,viewer:n,array:t,offset:r,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,inputChannels:e.channels,channelByteOffsets:{},shouldExpand:!1,scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:we};switch(e.compression){case"NO_COMPRESSION":o.blockHeight=1,o.uncompress=je;break;case"RLE_COMPRESSION":o.blockHeight=1,o.uncompress=_n;break;case"ZIPS_COMPRESSION":o.blockHeight=1,o.uncompress=$e;break;case"ZIP_COMPRESSION":o.blockHeight=16,o.uncompress=$e;break;case"PIZ_COMPRESSION":o.blockHeight=32,o.uncompress=vn;break;case"PXR24_COMPRESSION":o.blockHeight=16,o.uncompress=In;break;case"DWAA_COMPRESSION":o.blockHeight=32,o.uncompress=cn;break;case"DWAB_COMPRESSION":o.blockHeight=256,o.uncompress=cn;break;default:throw new Error("EXRLoader.parse: "+e.compression+" is unsupported")}const u={};for(const h of e.channels)switch(h.name){case"Y":case"R":case"G":case"B":case"A":u[h.name]=!0,o.type=h.pixelType}let l=!1,i=!1;if(u.R&&u.G&&u.B)o.outputChannels=4;else if(u.Y)o.outputChannels=1;else throw new Error("EXRLoader.parse: file contains unsupported data channels.");switch(o.outputChannels){case 4:a==Re?(l=!u.A,o.format=Re,o.colorSpace=we,o.outputChannels=4,o.decodeChannels={R:0,G:1,B:2,A:3}):a==ke?(o.format=ke,o.colorSpace=we,o.outputChannels=2,o.decodeChannels={R:0,G:1}):a==Ze?(o.format=Ze,o.colorSpace=we,o.outputChannels=1,o.decodeChannels={R:0}):i=!0;break;case 1:a==Re?(l=!0,o.format=Re,o.colorSpace=we,o.outputChannels=4,o.shouldExpand=!0,o.decodeChannels={Y:0}):a==ke?(o.format=ke,o.colorSpace=we,o.outputChannels=2,o.shouldExpand=!0,o.decodeChannels={Y:0}):a==Ze?(o.format=Ze,o.colorSpace=we,o.outputChannels=1,o.decodeChannels={Y:0}):i=!0;break;default:i=!0}if(i)throw new Error("EXRLoader.parse: invalid output format for specified file.");if(o.type==1)switch(s){case Ae:o.getter=An;break;case Ee:o.getter=Oe;break}else if(o.type==2)switch(s){case Ae:o.getter=ne;break;case Ee:o.getter=xn}else throw new Error("EXRLoader.parse: unsupported pixelType "+o.type+" for "+e.compression+".");o.columns=o.width;const c=o.width*o.height*o.outputChannels;switch(s){case Ae:o.byteArray=new Float32Array(c),l&&o.byteArray.fill(1,0,c);break;case Ee:o.byteArray=new Uint16Array(c),l&&o.byteArray.fill(15360,0,c);break;default:console.error("THREE.EXRLoader: unsupported type: ",s);break}let p=0;for(const h of e.channels)o.decodeChannels[h.name]!==void 0&&(o.channelByteOffsets[h.name]=p),p+=h.pixelType*2;if(o.totalBytes=p,o.outLineWidth=o.width*o.outputChannels,e.lineOrder==="INCREASING_Y"?o.scanOrder=h=>h:o.scanOrder=h=>o.height-1-h,e.spec.singleTile){o.blockHeight=e.tiles.ySize,o.blockWidth=e.tiles.xSize;const h=Pn(e.tiles,o.width,o.height),d=un(h,o.width,e.tiles.xSize,e.tiles.roundingMode),E=un(h,o.height,e.tiles.ySize,e.tiles.roundingMode);o.tileCount=d[0]*E[0];for(let m=0;m<h;m++)for(let w=0;w<E[m];w++)for(let y=0;y<d[m];y++)re(n,r);o.decode=Zn.bind(o)}else{o.blockWidth=o.width;const h=Math.ceil(o.height/o.blockHeight);for(let d=0;d<h;d++)re(n,r);o.decode=zn.bind(o)}return o}const hn={value:0},pn=new DataView(g),Wn=new Uint8Array(g),Se=Gn(pn,g,hn),fe=Yn(Se,pn,Wn,hn,this.type,this.outputFormat);if(fe.decode(),fe.shouldExpand){const e=fe.byteArray;if(this.outputFormat==Re)for(let n=0;n<e.length;n+=4)e[n+2]=e[n+1]=e[n];else if(this.outputFormat==ke)for(let n=0;n<e.length;n+=2)e[n+1]=e[n]}return{header:Se,width:fe.width,height:fe.height,data:fe.byteArray,format:fe.format,colorSpace:fe.colorSpace,type:this.type}}setDataType(g){return this.type=g,this}setOutputFormat(g){return this.outputFormat=g,this}load(g,x,M,j){function b(S,Y){S.colorSpace=Y.colorSpace,S.minFilter=Ye,S.magFilter=Ye,S.generateMipmaps=!1,S.flipY=!1,x&&x(S,Y)}return super.load(g,b,M,j)}}class ut extends mn{constructor(g){super(g),this.type=Ee}parse(g){const S=function(_,N){switch(_){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(N||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(N||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(N||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(N||""))}},te=function(_,N,k){N=N||1024;let U=_.pos,z=-1,I=0,W="",O=String.fromCharCode.apply(null,new Uint16Array(_.subarray(U,U+128)));for(;0>(z=O.indexOf(`
|
|
2
|
+
`))&&I<N&&U<_.byteLength;)W+=O,I+=O.length,U+=128,O+=String.fromCharCode.apply(null,new Uint16Array(_.subarray(U,U+128)));return-1<z?(_.pos+=I+z+1,W+O.slice(0,z)):!1},ce=function(_){const N=/^#\?(\S+)/,k=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,P=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,U=/^\s*FORMAT=(\S+)\s*$/,z=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,I={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let W,O;for((_.pos>=_.byteLength||!(W=te(_)))&&S(1,"no header found"),(O=W.match(N))||S(3,"bad initial token"),I.valid|=1,I.programtype=O[1],I.string+=W+`
|
|
3
|
+
`;W=te(_),W!==!1;){if(I.string+=W+`
|
|
4
|
+
`,W.charAt(0)==="#"){I.comments+=W+`
|
|
5
|
+
`;continue}if((O=W.match(k))&&(I.gamma=parseFloat(O[1])),(O=W.match(P))&&(I.exposure=parseFloat(O[1])),(O=W.match(U))&&(I.valid|=2,I.format=O[1]),(O=W.match(z))&&(I.valid|=4,I.height=parseInt(O[1],10),I.width=parseInt(O[2],10)),I.valid&2&&I.valid&4)break}return I.valid&2||S(3,"missing format specifier"),I.valid&4||S(3,"missing image size specifier"),I},he=function(_,N,k){const P=N;if(P<8||P>32767||_[0]!==2||_[1]!==2||_[2]&128)return new Uint8Array(_);P!==(_[2]<<8|_[3])&&S(3,"wrong scanline width");const U=new Uint8Array(4*N*k);U.length||S(4,"unable to allocate buffer space");let z=0,I=0;const W=4*P,O=new Uint8Array(4),pe=new Uint8Array(W);let Ue=k;for(;Ue>0&&I<_.byteLength;){I+4>_.byteLength&&S(1),O[0]=_[I++],O[1]=_[I++],O[2]=_[I++],O[3]=_[I++],(O[0]!=2||O[1]!=2||(O[2]<<8|O[3])!=P)&&S(3,"bad rgbe scanline format");let ye=0,K;for(;ye<W&&I<_.byteLength;){K=_[I++];const q=K>128;if(q&&(K-=128),(K===0||ye+K>W)&&S(3,"bad scanline data"),q){const oe=_[I++];for(let ve=0;ve<K;ve++)pe[ye++]=oe}else pe.set(_.subarray(I,I+K),ye),ye+=K,I+=K}const Te=P;for(let q=0;q<Te;q++){let oe=0;U[z]=pe[q+oe],oe+=P,U[z+1]=pe[q+oe],oe+=P,U[z+2]=pe[q+oe],oe+=P,U[z+3]=pe[q+oe],z+=4}Ue--}return U},le=function(_,N,k,P){const U=_[N+3],z=Math.pow(2,U-128)/255;k[P+0]=_[N+0]*z,k[P+1]=_[N+1]*z,k[P+2]=_[N+2]*z,k[P+3]=1},J=function(_,N,k,P){const U=_[N+3],z=Math.pow(2,U-128)/255;k[P+0]=xe.toHalfFloat(Math.min(_[N+0]*z,65504)),k[P+1]=xe.toHalfFloat(Math.min(_[N+1]*z,65504)),k[P+2]=xe.toHalfFloat(Math.min(_[N+2]*z,65504)),k[P+3]=xe.toHalfFloat(1)},ee=new Uint8Array(g);ee.pos=0;const _e=ce(ee),We=_e.width,Xe=_e.height,Ne=he(ee.subarray(ee.pos),We,Xe);let Le,Fe,ge;switch(this.type){case Ae:ge=Ne.length/4;const _=new Float32Array(ge*4);for(let k=0;k<ge;k++)le(Ne,k*4,_,k*4);Le=_,Fe=Ae;break;case Ee:ge=Ne.length/4;const N=new Uint16Array(ge*4);for(let k=0;k<ge;k++)J(Ne,k*4,N,k*4);Le=N,Fe=Ee;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:We,height:Xe,data:Le,header:_e.string,gamma:_e.gamma,exposure:_e.exposure,type:Fe}}setDataType(g){return this.type=g,this}load(g,x,M,j){function b(S,Y){switch(S.type){case Ae:case Ee:S.colorSpace=we,S.minFilter=Ye,S.magFilter=Ye,S.generateMipmaps=!1,S.flipY=!0;break}x&&x(S,Y)}return super.load(g,b,M,j)}}function ht(R){return R.split("/").pop()??R}function Me(R,g,x){return Math.min(x,Math.max(g,R))}function pt(R){return R.split(/[?#]/,1)[0].toLowerCase().endsWith(".exr")}async function mt(R){const g=pt(R)?"EXR":"HDR",M=await(g==="EXR"?new at:new ut).loadAsync(R),j=M.image,b=j.width??0,S=j.height??0,Y=b>0&&S>0&&Math.abs(b/S-2)<=.04;return M.mapping=qn,M.needsUpdate=!0,{texture:M,width:b,height:S,format:g,panorama:Y}}function dt(R){const g=new et,x=new nt(38,1,.05,100);x.position.set(6.2,3.4,7.8),x.lookAt(0,.7,0);const M=[],j=[];if(!R.panorama){g.background=new tt("#11141b");const H=R.width>0&&R.height>0?R.width/R.height:1,Q=new ot(H>=1?4.8:4.8*H,H>=1?4.8/H:4.8),te=new rt({map:R.texture,toneMapped:!0});return M.push(Q),j.push(te),g.add(new qe(Q,te)),x.position.set(0,0,6.5),x.lookAt(0,0,0),{scene:g,camera:x,geometries:M,materials:j}}g.background=R.texture,g.environment=R.texture;const b=(H,Q,te)=>{M.push(H),j.push(Q);const ce=new qe(H,Q);ce.position.set(...te),g.add(ce)};b(new Ve(1,64,40),new ze({color:"#d8dde5",roughness:.08,metalness:1}),[-2.3,1.15,0]),b(new Ve(1,64,40),new ze({color:"#c97341",roughness:.32,metalness:.25}),[0,1.15,0]),b(new Ve(1,64,40),new ze({color:"#d7d5cf",roughness:.82,metalness:0}),[2.3,1.15,0]);const S=new st(5.7,96),Y=new ze({color:"#737881",roughness:.58,metalness:0});M.push(S),j.push(Y);const X=new qe(S,Y);return X.rotation.x=-Math.PI/2,X.position.y=.08,g.add(X),{scene:g,camera:x,geometries:M,materials:j}}function ft({image:R,settingsRef:g}){const x=ue.useRef(null);return ue.useEffect(()=>{const M=x.current;if(!M)return;let j=!1,b=0;const S=document.createElement("canvas");S.setAttribute("aria-label",`${R.format} environment preview`),S.style.width="100%",S.style.height="100%",S.style.display="block",M.replaceChildren(S);const Y=new Vn({canvas:S,antialias:!0});Y.outputColorSpace=Jn,Y.toneMapping=Qn;const X=dt(R),H=new lt(X.camera,S);H.target.set(0,R.panorama?.8:0,0),H.enableDamping=!0,H.enablePan=!1,H.minDistance=R.panorama?3.8:4,H.maxDistance=R.panorama?14:10,H.update();const Q={width:1,height:1},te=()=>{const J=g.current;if(Y.toneMappingExposure=Me(J.exposure,.05,8),R.panorama){const ee=it.degToRad(J.rotation);X.scene.backgroundRotation.y=ee,X.scene.environmentRotation.y=ee,X.scene.backgroundBlurriness=Me(J.blur,0,1),X.scene.environmentIntensity=Me(J.intensity,0,8)}H.update(),Y.render(X.scene,X.camera)},ce=()=>{const J=M.getBoundingClientRect();Q.width=Math.max(1,Math.floor(J.width)),Q.height=Math.max(1,Math.floor(J.height)),Y.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),Y.setSize(Q.width,Q.height,!1),X.camera.aspect=Q.width/Q.height,X.camera.updateProjectionMatrix(),te()};ce();const he=new ResizeObserver(ce);he.observe(M);const le=()=>{j||(te(),b=requestAnimationFrame(le))};return b=requestAnimationFrame(le),()=>{j=!0,cancelAnimationFrame(b),he.disconnect(),H.dispose();for(const J of X.geometries)J.dispose();for(const J of X.materials)J.dispose();Y.dispose(),S.remove()}},[R,g]),T.jsx("div",{ref:x,"data-testid":"environment-preview",style:{width:"100%",height:"100%",minHeight:260,background:"#11141b"}})}function wt({panorama:R,settings:g,onChange:x}){return T.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:4},children:[T.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:5,fontSize:11},children:["Exposure",T.jsx(Pe,{value:g.exposure,onChange:M=>x({...g,exposure:Me(M,.05,8)}),step:.05,precision:2})]}),R&&T.jsxs(T.Fragment,{children:[T.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:5,fontSize:11},children:["Lighting intensity",T.jsx(Pe,{value:g.intensity,onChange:M=>x({...g,intensity:Me(M,0,8)}),step:.05,precision:2})]}),T.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:5,fontSize:11},children:["Rotation",T.jsx(Pe,{value:g.rotation,onChange:M=>x({...g,rotation:M%360}),step:1,precision:0})]}),T.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:5,fontSize:11},children:["Background blur",T.jsx(Pe,{value:g.blur,onChange:M=>x({...g,blur:Me(M,0,1)}),step:.05,precision:2})]})]}),T.jsx("div",{style:{color:Ce.content.muted,fontSize:10,lineHeight:1.45},children:"Preview controls are session-only. Bind the image, orientation, and accepted intensity in the owning scene source."})]})}function Nt({documentId:R,assetPath:g,active:x=!0}){const[M,j]=ue.useState(0),[b,S]=ue.useState(null),[Y,X]=ue.useState(null),[H,Q]=ue.useState({exposure:1,intensity:1,rotation:0,blur:0}),te=ue.useRef(H);te.current=H,ue.useEffect(()=>{if(x)return ct(g,()=>j(le=>le+1))},[x,g]),ue.useEffect(()=>{if(!x)return;let le=!1,J=null;return S(null),X(null),mt(g).then(ee=>{if(J=ee,le){ee.texture.dispose();return}S(ee)},ee=>{le||X(ee instanceof Error?ee.message:String(ee))}),()=>{le=!0,J?.texture.dispose()}},[x,g,M]);const ce=ue.useMemo(()=>[{id:"environment-image",title:"Environment Image",icon:jn,order:Xn,body:{kind:"custom",...b?{data:{format:b.format,width:b.width,height:b.height,panorama:b.panorama}}:{},render:()=>T.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"6px 10px"},children:[T.jsx("span",{style:{color:Ce.content.muted},children:"Format"}),T.jsx("span",{children:b?.format??"—"}),T.jsx("span",{style:{color:Ce.content.muted},children:"Resolution"}),T.jsx("span",{children:b?`${b.width} × ${b.height}`:"—"}),T.jsx("span",{style:{color:Ce.content.muted},children:"Projection"}),T.jsx("span",{children:b?.panorama?"2:1 equirectangular":"Flat image"})]})}},{id:"environment-preview-settings",title:"Preview",icon:Kn,order:$n,body:{kind:"custom",data:{...H},render:()=>T.jsx(wt,{panorama:b?.panorama??!1,settings:H,onChange:Q})}}],[b,H]),he=ht(g);return Y?T.jsx(Ke,{documentId:R,active:x,type:"environment image",title:he,status:"HDR image unavailable",children:T.jsx("div",{role:"alert",style:{padding:20,color:Ce.semantic.danger},children:Y})}):b?T.jsx(Ke,{documentId:R,active:x,type:"environment image",title:he,sections:ce,status:`${b.format} · ${b.width} × ${b.height}`,fill:!0,children:T.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",minHeight:0},children:[T.jsx(ft,{image:b,settingsRef:te}),T.jsx("div",{style:{position:"absolute",left:12,bottom:12,padding:"4px 7px",borderRadius:4,background:"rgba(12,14,20,0.72)",color:"#f2f4f8",fontSize:10,pointerEvents:"none"},children:b.panorama?"Drag to orbit · wheel to frame":"Non-2:1 image · flat preview"})]})}):T.jsx(Ke,{documentId:R,active:x,type:"environment image",title:he,status:"Loading HDR image",children:T.jsx("div",{style:{padding:20,color:Ce.content.muted},children:"Loading environment…"})})}export{Nt as EnvironmentAssetDocument};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as z,V as M,bs as ue,z as Z,aI as fe,I as he,aL as me,f as $,J,a1 as de,aF as _,b2 as ge,aJ as B,d as b,i as D,bn as ye,x as I,aB as ee,aN as te,bt as W,av as K,k as ve,b5 as ne,b as S,b4 as we,aY as Te,b6 as Ie,a0 as Fe,aD as xe,b7 as Pe,aM as Ae,b3 as Se,aa as Q,aC as V,bu as Ee,af as De,a as Le,bv as Me,as as O,aQ as ke,Q as R,aO as Ce,aP as re,bw as be}from"./three.module-BynznMJN.js";import{u as Re}from"./fflate.module-DPuTF8aG.js";function ae(f,e,t){const n=t.length-f-1;if(e>=t[n])return n-1;if(e<=t[f])return f;let r=f,s=n,i=Math.floor((r+s)/2);for(;e<t[i]||e>=t[i+1];)e<t[i]?s=i:r=i,i=Math.floor((r+s)/2);return i}function Be(f,e,t,n){const r=[],s=[],i=[];r[0]=1;for(let a=1;a<=t;++a){s[a]=e-n[f+1-a],i[a]=n[f+a]-e;let o=0;for(let l=0;l<a;++l){const p=i[l+1],c=s[a-l],u=r[l]/(p+c);r[l]=o+p*u,o=c*u}r[a]=o}return r}function Oe(f,e,t,n){const r=ae(f,n,e),s=Be(r,n,f,e),i=new z(0,0,0,0);for(let a=0;a<=f;++a){const o=t[r-f+a],l=s[a],p=o.w*l;i.x+=o.x*p,i.y+=o.y*p,i.z+=o.z*p,i.w+=o.w*l}return i}function Ve(f,e,t,n,r){const s=[];for(let c=0;c<=t;++c)s[c]=0;const i=[];for(let c=0;c<=n;++c)i[c]=s.slice(0);const a=[];for(let c=0;c<=t;++c)a[c]=s.slice(0);a[0][0]=1;const o=s.slice(0),l=s.slice(0);for(let c=1;c<=t;++c){o[c]=e-r[f+1-c],l[c]=r[f+c]-e;let u=0;for(let h=0;h<c;++h){const m=l[h+1],g=o[c-h];a[c][h]=m+g;const d=a[h][c-1]/a[c][h];a[h][c]=u+m*d,u=g*d}a[c][c]=u}for(let c=0;c<=t;++c)i[0][c]=a[c][t];for(let c=0;c<=t;++c){let u=0,h=1;const m=[];for(let g=0;g<=t;++g)m[g]=s.slice(0);m[0][0]=1;for(let g=1;g<=n;++g){let d=0;const w=c-g,T=t-g;c>=g&&(m[h][0]=m[u][0]/a[T+1][w],d=m[h][0]*a[w][T]);const v=w>=-1?1:-w,x=c-1<=T?g-1:t-c;for(let P=v;P<=x;++P)m[h][P]=(m[u][P]-m[u][P-1])/a[T+1][w+P],d+=m[h][P]*a[w+P][T];c<=T&&(m[h][g]=-m[u][g-1]/a[T+1][c],d+=m[h][g]*a[c][T]),i[g][c]=d;const E=u;u=h,h=E}}let p=t;for(let c=1;c<=n;++c){for(let u=0;u<=t;++u)i[c][u]*=p;p*=t-c}return i}function Ue(f,e,t,n,r){const s=r<f?r:f,i=[],a=ae(f,n,e),o=Ve(a,n,f,s,e),l=[];for(let p=0;p<t.length;++p){const c=t[p].clone(),u=c.w;c.x*=u,c.y*=u,c.z*=u,l[p]=c}for(let p=0;p<=s;++p){const c=l[a-f].clone().multiplyScalar(o[p][0]);for(let u=1;u<=f;++u)c.add(l[a-f+u].clone().multiplyScalar(o[p][u]));i[p]=c}for(let p=s+1;p<=r+1;++p)i[p]=new z(0,0,0);return i}function Xe(f,e){let t=1;for(let r=2;r<=f;++r)t*=r;let n=1;for(let r=2;r<=e;++r)n*=r;for(let r=2;r<=f-e;++r)n*=r;return t/n}function ze(f){const e=f.length,t=[],n=[];for(let s=0;s<e;++s){const i=f[s];t[s]=new M(i.x,i.y,i.z),n[s]=i.w}const r=[];for(let s=0;s<e;++s){const i=t[s].clone();for(let a=1;a<=s;++a)i.sub(r[s-a].clone().multiplyScalar(Xe(s,a)*n[a]));r[s]=i.divideScalar(n[0])}return r}function Ge(f,e,t,n,r){const s=Ue(f,e,t,n,r);return ze(s)}class je extends ue{constructor(e,t,n,r,s){super();const i=t?t.length-1:0,a=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=s||i;for(let o=0;o<a;++o){const l=n[o];this.controlPoints[o]=new z(l.x,l.y,l.z,l.w)}}getPoint(e,t=new M){const n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=Oe(this.degree,this.knots,this.controlPoints,r);return s.w!==1&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t=new M){const n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=Ge(this.degree,this.knots,this.controlPoints,r,1);return n.copy(s[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new z(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}let y,F,A;class nt extends Z{constructor(e){super(e)}load(e,t,n,r){const s=this,i=s.path===""?fe.extractUrlBase(e):s.path,a=new he(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(o){try{t(s.parse(o,i))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e,t){if(Qe(e))y=new Ne().parse(e);else{const r=ce(e);if(!Ye(r))throw new Error("THREE.FBXLoader: Unknown format.");if(ie(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+ie(r));y=new We().parse(r)}const n=new me(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new _e(n,this.manager).parse(y)}}class _e{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){F=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),s=new Ke().parse(r);return this.parseScene(r,s,n),A}parseConnections(){const e=new Map;return"Connections"in y&&y.Connections.connections.forEach(function(n){const r=n[0],s=n[1],i=n[2];e.has(r)||e.set(r,{parents:[],children:[]});const a={ID:s,relationship:i};e.get(r).parents.push(a),e.has(s)||e.set(s,{parents:[],children:[]});const o={ID:r,relationship:i};e.get(s).children.push(o)}),e}parseImages(){const e={},t={};if("Video"in y.Objects){const n=y.Objects.Video;for(const r in n){const s=n[r],i=parseInt(r);if(e[i]=s.RelativeFilename||s.Filename,"Content"in s){const a=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,o=typeof s.Content=="string"&&s.Content!=="";if(a||o){const l=this.parseImage(n[r]);t[s.RelativeFilename||s.Filename]=l}}}}for(const n in e){const r=e[n];t[r]!==void 0?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(r){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;case"webp":s="image/webp";break;default:console.warn('FBXLoader: Image type "'+r+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const i=new Uint8Array(t);return window.URL.createObjectURL(new Blob([i],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in y.Objects){const n=y.Objects.Texture;for(const r in n){const s=this.parseTexture(n[r],e);t.set(parseInt(r),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const r=e.WrapModeU,s=e.WrapModeV,i=r!==void 0?r.value:0,a=s!==void 0?s.value:0;if(n.wrapS=i===0?$:J,n.wrapT=a===0?$:J,"Scaling"in e){const o=e.Scaling.value;n.repeat.x=o[0],n.repeat.y=o[1]}if("Translation"in e){const o=e.Translation.value;n.offset.x=o[0],n.offset.y=o[1]}return n}loadTexture(e,t){const n=e.FileName.split(".").pop().toLowerCase();let r=this.manager.getHandler(`.${n}`);r===null&&(r=this.textureLoader);const s=r.path;s||r.setPath(this.textureLoader.path);const i=F.get(e.id).children;let a;if(i!==void 0&&i.length>0&&t[i[0].ID]!==void 0&&(a=t[i[0].ID],(a.indexOf("blob:")===0||a.indexOf("data:")===0)&&r.setPath(void 0)),a===void 0)return console.warn("FBXLoader: Undefined filename, creating placeholder texture."),new de;const o=r.load(a);return r.setPath(s),o}parseMaterials(e){const t=new Map;if("Material"in y.Objects){const n=y.Objects.Material;for(const r in n){const s=this.parseMaterial(n[r],e);s!==null&&t.set(parseInt(r),s)}}return t}parseMaterial(e,t){const n=e.id,r=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!F.has(n))return null;const i=this.parseParameters(e,t,n);let a;switch(s.toLowerCase()){case"phong":a=new _;break;case"lambert":a=new ge;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new _;break}return a.setValues(i),a.name=r,a}parseParameters(e,t,n){const r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=B.colorSpaceToWorking(new b().fromArray(e.Diffuse.value),D):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(r.color=B.colorSpaceToWorking(new b().fromArray(e.DiffuseColor.value),D)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=B.colorSpaceToWorking(new b().fromArray(e.Emissive.value),D):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(r.emissive=B.colorSpaceToWorking(new b().fromArray(e.EmissiveColor.value),D)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),r.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),(r.opacity===1||r.opacity===0)&&(r.opacity=e.Opacity?parseFloat(e.Opacity.value):null,r.opacity===null&&(r.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=B.colorSpaceToWorking(new b().fromArray(e.Specular.value),D):e.SpecularColor&&e.SpecularColor.type==="Color"&&(r.specular=B.colorSpaceToWorking(new b().fromArray(e.SpecularColor.value),D));const s=this;return F.get(n).children.forEach(function(i){const a=i.relationship;switch(a){case"Bump":r.bumpMap=s.getTexture(t,i.ID);break;case"Maya|TEX_ao_map":r.aoMap=s.getTexture(t,i.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=s.getTexture(t,i.ID),r.map!==void 0&&(r.map.colorSpace=D);break;case"DisplacementColor":r.displacementMap=s.getTexture(t,i.ID);break;case"EmissiveColor":r.emissiveMap=s.getTexture(t,i.ID),r.emissiveMap!==void 0&&(r.emissiveMap.colorSpace=D);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=s.getTexture(t,i.ID);break;case"ReflectionColor":r.envMap=s.getTexture(t,i.ID),r.envMap!==void 0&&(r.envMap.mapping=ye,r.envMap.colorSpace=D);break;case"SpecularColor":r.specularMap=s.getTexture(t,i.ID),r.specularMap!==void 0&&(r.specularMap.colorSpace=D);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=s.getTexture(t,i.ID),r.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",a);break}}),r}getTexture(e,t){return"LayeredTexture"in y.Objects&&t in y.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=F.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in y.Objects){const n=y.Objects.Deformer;for(const r in n){const s=n[r],i=F.get(parseInt(r));if(s.attrType==="Skin"){const a=this.parseSkeleton(i,n);a.ID=r,i.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=i.parents[0].ID,e[r]=a}else if(s.attrType==="BlendShape"){const a={id:r};a.rawTargets=this.parseMorphTargets(i,n),a.id=r,i.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=a}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(r){const s=t[r.ID];if(s.attrType!=="Cluster")return;const i={ID:r.ID,indices:[],weights:[],transformLink:new I().fromArray(s.TransformLink.a)};"Indexes"in s&&(i.indices=s.Indexes.a,i.weights=s.Weights.a),n.push(i)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const s=e.children[r],i=t[s.ID],a={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if(i.attrType!=="BlendShapeChannel")return;a.geoID=F.get(parseInt(s.ID)).children.filter(function(o){return o.relationship===void 0})[0].ID,n.push(a)}return n}parseScene(e,t,n){A=new ee;const r=this.parseModels(e.skeletons,t,n),s=y.Objects.Model,i=this;r.forEach(function(o){const l=s[o.ID];i.setLookAtProperties(o,l),F.get(o.ID).parents.forEach(function(c){const u=r.get(c.ID);u!==void 0&&u.add(o)}),o.parent===null&&A.add(o)}),this.bindSkeleton(e.skeletons,t,r),this.addGlobalSceneSettings(),A.traverse(function(o){if(o.userData.transformData){o.parent&&(o.userData.transformData.parentMatrix=o.parent.matrix,o.userData.transformData.parentMatrixWorld=o.parent.matrixWorld);const l=le(o.userData.transformData);o.applyMatrix4(l),o.updateWorldMatrix()}});const a=new He().parse();A.children.length===1&&A.children[0].isGroup&&(A.children[0].animations=a,A=A.children[0]),A.animations=a}parseModels(e,t,n){const r=new Map,s=y.Objects.Model;for(const i in s){const a=parseInt(i),o=s[i],l=F.get(a);let p=this.buildSkeleton(l,e,a,o.attrName);if(!p){switch(o.attrType){case"Camera":p=this.createCamera(l);break;case"Light":p=this.createLight(l);break;case"Mesh":p=this.createMesh(l,t,n);break;case"NurbsCurve":p=this.createCurve(l,t);break;case"LimbNode":case"Root":p=new te;break;case"Null":default:p=new ee;break}p.name=o.attrName?W.sanitizeNodeName(o.attrName):"",p.userData.originalName=o.attrName,p.ID=a}this.getTransformData(p,o),r.set(a,p)}return r}buildSkeleton(e,t,n,r){let s=null;return e.parents.forEach(function(i){for(const a in t){const o=t[a];o.rawBones.forEach(function(l,p){if(l.ID===i.ID){const c=s;s=new te,s.matrixWorld.copy(l.transformLink),s.name=r?W.sanitizeNodeName(r):"",s.userData.originalName=r,s.ID=n,o.bones[p]=s,c!==null&&s.add(c)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(r){const s=y.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)t=new K;else{let r=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(r=1);let s=1;n.NearPlane!==void 0&&(s=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let a=window.innerWidth,o=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,o=n.AspectHeight.value);const l=a/o;let p=45;n.FieldOfView!==void 0&&(p=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(r){case 0:t=new ve(p,l,s,i),c!==null&&t.setFocalLength(c);break;case 1:console.warn("THREE.FBXLoader: Orthographic cameras not supported yet."),t=new K;break;default:console.warn("THREE.FBXLoader: Unknown camera type "+r+"."),t=new K;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(r){const s=y.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)t=new K;else{let r;n.LightType===void 0?r=0:r=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=B.colorSpaceToWorking(new b().fromArray(n.Color.value),D));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let a=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?a=0:a=n.FarAttenuationEnd.value);const o=1;switch(r){case 0:t=new ne(s,i,a,o);break;case 1:t=new Te(s,i);break;case 2:let l=Math.PI/3;n.InnerAngle!==void 0&&(l=S.degToRad(n.InnerAngle.value));let p=0;n.OuterAngle!==void 0&&(p=S.degToRad(n.OuterAngle.value),p=Math.max(p,1)),t=new we(s,i,a,l,p,o);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new ne(s,i);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,s=null,i=null;const a=[];if(e.children.forEach(function(o){t.has(o.ID)&&(s=t.get(o.ID)),n.has(o.ID)&&a.push(n.get(o.ID))}),a.length>1?i=a:a.length>0?i=a[0]:(i=new _({name:Z.DEFAULT_MATERIAL_NAME,color:13421772}),a.push(i)),"color"in s.attributes&&a.forEach(function(o){o.vertexColors=!0}),s.groups.length>0){let o=!1;for(let l=0,p=s.groups.length;l<p;l++){const c=s.groups[l];(c.materialIndex<0||c.materialIndex>=a.length)&&(c.materialIndex=a.length,o=!0)}if(o){const l=new _;a.push(l)}}return s.FBX_Deformer?(r=new Ie(s,i),r.normalizeSkinWeights()):r=new Fe(s,i),r}createCurve(e,t){const n=e.children.reduce(function(s,i){return t.has(i.ID)&&(s=t.get(i.ID)),s},null),r=new xe({name:Z.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Pe(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=G(t.RotationOrder.value):n.eulerOrder=G(0),"Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&F.get(e.ID).children.forEach(function(r){if(r.relationship==="LookAtProperty"){const s=y.Objects.Model[r.ID];if("Lcl_Translation"in s){const i=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),A.add(e.target)):e.lookAt(new M().fromArray(i))}}})}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const s in e){const i=e[s];F.get(parseInt(i.ID)).parents.forEach(function(o){if(t.has(o.ID)){const l=o.ID;F.get(l).parents.forEach(function(c){n.has(c.ID)&&n.get(c.ID).bind(new Ae(i.bones),r[c.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in y.Objects){const t=y.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const r=t[n].PoseNode;Array.isArray(r)?r.forEach(function(s){e[s.Node]=new I().fromArray(s.Matrix.a)}):e[r.Node]=new I().fromArray(r.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in y){if("AmbientColor"in y.GlobalSettings){const e=y.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(t!==0||n!==0||r!==0){const s=new b().setRGB(t,n,r,D);A.add(new Se(s,1))}}"UnitScaleFactor"in y.GlobalSettings&&(A.userData.unitScaleFactor=y.GlobalSettings.UnitScaleFactor.value)}}}class Ke{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in y.Objects){const n=y.Objects.Geometry;for(const r in n){const s=F.get(parseInt(r)),i=this.parseGeometry(s,n[r],e);t.set(parseInt(r),i)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,s=[],i=e.parents.map(function(c){return y.Objects.Model[c.ID]});if(i.length===0)return;const a=e.children.reduce(function(c,u){return r[u.ID]!==void 0&&(c=r[u.ID]),c},null);e.children.forEach(function(c){n.morphTargets[c.ID]!==void 0&&s.push(n.morphTargets[c.ID])});const o=i[0],l={};"RotationOrder"in o&&(l.eulerOrder=G(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);const p=le(l);return this.genGeometry(t,a,s,p)}genGeometry(e,t,n,r){const s=new Q;e.attrName&&(s.name=e.attrName);const i=this.parseGeoNode(e,t),a=this.genBuffers(i),o=new V(a.vertex,3);if(o.applyMatrix4(r),s.setAttribute("position",o),a.colors.length>0&&s.setAttribute("color",new V(a.colors,3)),t&&(s.setAttribute("skinIndex",new Ee(a.weightsIndices,4)),s.setAttribute("skinWeight",new V(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const l=new De().getNormalMatrix(r),p=new V(a.normal,3);p.applyNormalMatrix(l),s.setAttribute("normal",p)}if(a.uvs.forEach(function(l,p){const c=p===0?"uv":`uv${p}`;s.setAttribute(c,new V(a.uvs[p],2))}),i.material&&i.material.mappingType!=="AllSame"){let l=a.materialIndex[0],p=0;if(a.materialIndex.forEach(function(c,u){c!==l&&(s.addGroup(p,u-p,l),l=c,p=u)}),s.groups.length>0){const c=s.groups[s.groups.length-1],u=c.start+c.count;u!==a.materialIndex.length&&s.addGroup(u,a.materialIndex.length-u,l)}s.groups.length===0&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,n,r),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&e.LayerElementColor[0].Colors&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let r=0;for(;e.LayerElementUV[r];)e.LayerElementUV[r].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[r])),r++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(r,s){r.indices.forEach(function(i,a){n.weightTable[i]===void 0&&(n.weightTable[i]=[]),n.weightTable[i].push({id:s,weight:r.weights[a]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,s=!1,i=[],a=[],o=[],l=[],p=[],c=[];const u=this;return e.vertexIndices.forEach(function(h,m){let g,d=!1;h<0&&(h=h^-1,d=!0);let w=[],T=[];if(i.push(h*3,h*3+1,h*3+2),e.color){const v=H(m,n,h,e.color);o.push(v[0],v[1],v[2])}if(e.skeleton){if(e.weightTable[h]!==void 0&&e.weightTable[h].forEach(function(v){T.push(v.weight),w.push(v.id)}),T.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const v=[0,0,0,0],x=[0,0,0,0];T.forEach(function(E,P){let C=E,L=w[P];x.forEach(function(j,X,k){if(C>j){k[X]=C,C=j;const N=v[X];v[X]=L,L=N}})}),w=v,T=x}for(;T.length<4;)T.push(0),w.push(0);for(let v=0;v<4;++v)p.push(T[v]),c.push(w[v])}if(e.normal){const v=H(m,n,h,e.normal);a.push(v[0],v[1],v[2])}e.material&&e.material.mappingType!=="AllSame"&&(g=H(m,n,h,e.material)[0],g<0&&(u.negativeMaterialIndices=!0,g=0)),e.uv&&e.uv.forEach(function(v,x){const E=H(m,n,h,v);l[x]===void 0&&(l[x]=[]),l[x].push(E[0]),l[x].push(E[1])}),r++,d&&(u.genFace(t,e,i,g,a,o,l,p,c,r),n++,r=0,i=[],a=[],o=[],l=[],p=[],c=[])}),t}getNormalNewell(e){const t=new M(0,0,0);for(let n=0;n<e.length;n++){const r=e[n],s=e[(n+1)%e.length];t.x+=(r.y-s.y)*(r.z+s.z),t.y+=(r.z-s.z)*(r.x+s.x),t.z+=(r.x-s.x)*(r.y+s.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){const t=this.getNormalNewell(e),r=(Math.abs(t.z)>.5?new M(0,1,0):new M(0,0,1)).cross(t).normalize(),s=t.clone().cross(r).normalize();return{normal:t,tangent:r,bitangent:s}}flattenVertex(e,t,n){return new Le(e.dot(t),e.dot(n))}genFace(e,t,n,r,s,i,a,o,l,p){let c;if(p>3){const u=[],h=t.baseVertexPositions||t.vertexPositions;for(let w=0;w<n.length;w+=3)u.push(new M(h[n[w]],h[n[w+1]],h[n[w+2]]));const{tangent:m,bitangent:g}=this.getNormalTangentAndBitangent(u),d=[];for(const w of u)d.push(this.flattenVertex(w,m,g));c=Me.triangulateShape(d,[])}else c=[[0,1,2]];for(const[u,h,m]of c)e.vertex.push(t.vertexPositions[n[u*3]]),e.vertex.push(t.vertexPositions[n[u*3+1]]),e.vertex.push(t.vertexPositions[n[u*3+2]]),e.vertex.push(t.vertexPositions[n[h*3]]),e.vertex.push(t.vertexPositions[n[h*3+1]]),e.vertex.push(t.vertexPositions[n[h*3+2]]),e.vertex.push(t.vertexPositions[n[m*3]]),e.vertex.push(t.vertexPositions[n[m*3+1]]),e.vertex.push(t.vertexPositions[n[m*3+2]]),t.skeleton&&(e.vertexWeights.push(o[u*4]),e.vertexWeights.push(o[u*4+1]),e.vertexWeights.push(o[u*4+2]),e.vertexWeights.push(o[u*4+3]),e.vertexWeights.push(o[h*4]),e.vertexWeights.push(o[h*4+1]),e.vertexWeights.push(o[h*4+2]),e.vertexWeights.push(o[h*4+3]),e.vertexWeights.push(o[m*4]),e.vertexWeights.push(o[m*4+1]),e.vertexWeights.push(o[m*4+2]),e.vertexWeights.push(o[m*4+3]),e.weightsIndices.push(l[u*4]),e.weightsIndices.push(l[u*4+1]),e.weightsIndices.push(l[u*4+2]),e.weightsIndices.push(l[u*4+3]),e.weightsIndices.push(l[h*4]),e.weightsIndices.push(l[h*4+1]),e.weightsIndices.push(l[h*4+2]),e.weightsIndices.push(l[h*4+3]),e.weightsIndices.push(l[m*4]),e.weightsIndices.push(l[m*4+1]),e.weightsIndices.push(l[m*4+2]),e.weightsIndices.push(l[m*4+3])),t.color&&(e.colors.push(i[u*3]),e.colors.push(i[u*3+1]),e.colors.push(i[u*3+2]),e.colors.push(i[h*3]),e.colors.push(i[h*3+1]),e.colors.push(i[h*3+2]),e.colors.push(i[m*3]),e.colors.push(i[m*3+1]),e.colors.push(i[m*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(s[u*3]),e.normal.push(s[u*3+1]),e.normal.push(s[u*3+2]),e.normal.push(s[h*3]),e.normal.push(s[h*3+1]),e.normal.push(s[h*3+2]),e.normal.push(s[m*3]),e.normal.push(s[m*3+1]),e.normal.push(s[m*3+2])),t.uv&&t.uv.forEach(function(g,d){e.uvs[d]===void 0&&(e.uvs[d]=[]),e.uvs[d].push(a[d][u*2]),e.uvs[d].push(a[d][u*2+1]),e.uvs[d].push(a[d][h*2]),e.uvs[d].push(a[d][h*2+1]),e.uvs[d].push(a[d][m*2]),e.uvs[d].push(a[d][m*2+1])})}addMorphTargets(e,t,n,r){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;n.forEach(function(i){i.rawTargets.forEach(function(a){const o=y.Objects.Geometry[a.geoID];o!==void 0&&s.genMorphGeometry(e,t,o,r,a.name)})})}genMorphGeometry(e,t,n,r,s){const i=t.Vertices!==void 0?t.Vertices.a:[],a=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],o=n.Vertices!==void 0?n.Vertices.a:[],l=n.Indexes!==void 0?n.Indexes.a:[],p=e.attributes.position.count*3,c=new Float32Array(p);for(let g=0;g<l.length;g++){const d=l[g]*3;c[d]=o[g*3],c[d+1]=o[g*3+1],c[d+2]=o[g*3+2]}const u={vertexIndices:a,vertexPositions:c,baseVertexPositions:i},h=this.genBuffers(u),m=new V(h.vertex,3);m.name=s||n.attrName,m.applyMatrix4(r),e.morphAttributes.position.push(m)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let s=[];return n==="IndexToDirect"&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:s,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let s=[];return n==="IndexToDirect"&&(s=e.UVIndex.a),{dataSize:2,buffer:r,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a;let s=[];n==="IndexToDirect"&&(s=e.ColorIndex.a);for(let i=0,a=new b;i<r.length;i+=4)a.fromArray(r,i),B.colorSpaceToWorking(a,D),a.toArray(r,i);return{dataSize:4,buffer:r,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,s=[];for(let i=0;i<r.length;++i)s.push(i);return{dataSize:1,buffer:r,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Q;const n=t-1,r=e.KnotVector.a,s=[],i=e.Points.a;for(let c=0,u=i.length;c<u;c+=4)s.push(new z().fromArray(i,c));let a,o;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){a=n,o=r.length-1-a;for(let c=0;c<n;++c)s.push(s[c])}const p=new je(n,r,s,a,o).getPoints(s.length*12);return new Q().setFromPoints(p)}}class He{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const r=t[n],s=this.addClip(r);e.push(s)}return e}parseClips(){if(y.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=y.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(r.attrName.match(/S|R|T|DeformPercent/)!==null){const s={id:r.id,attr:r.attrName,curves:{}};t.set(s.id,s)}}return t}parseAnimationCurves(e){const t=y.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(qe),values:t[n].KeyValueFloat.a},s=F.get(r.id);if(s!==void 0){const i=s.parents[0].ID,a=s.parents[0].relationship;a.match(/X/)?e.get(i).curves.x=r:a.match(/Y/)?e.get(i).curves.y=r:a.match(/Z/)?e.get(i).curves.z=r:a.match(/DeformPercent/)&&e.has(i)&&(e.get(i).curves.morph=r)}}}parseAnimationLayers(e){const t=y.Objects.AnimationLayer,n=new Map;for(const r in t){const s=[],i=F.get(parseInt(r));i!==void 0&&(i.children.forEach(function(o,l){if(e.has(o.ID)){const p=e.get(o.ID);if(p.curves.x!==void 0||p.curves.y!==void 0||p.curves.z!==void 0){if(s[l]===void 0){const c=F.get(o.ID).parents.filter(function(u){return u.relationship!==void 0})[0].ID;if(c!==void 0){const u=y.Objects.Model[c.toString()];if(u===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",o);return}const h={modelName:u.attrName?W.sanitizeNodeName(u.attrName):"",ID:u.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};A.traverse(function(m){m.ID===u.id&&(h.transform=m.matrix,m.userData.transformData&&(h.eulerOrder=m.userData.transformData.eulerOrder))}),h.transform||(h.transform=new I),"PreRotation"in u&&(h.preRotation=u.PreRotation.value),"PostRotation"in u&&(h.postRotation=u.PostRotation.value),s[l]=h}}s[l]&&(s[l][p.attr]=p)}else if(p.curves.morph!==void 0){if(s[l]===void 0){const c=F.get(o.ID).parents.filter(function(w){return w.relationship!==void 0})[0].ID,u=F.get(c).parents[0].ID,h=F.get(u).parents[0].ID,m=F.get(h).parents[0].ID,g=y.Objects.Model[m],d={modelName:g.attrName?W.sanitizeNodeName(g.attrName):"",morphName:y.Objects.Deformer[c].attrName};s[l]=d}s[l][p.attr]=p}}}),n.set(parseInt(r),s))}return n}parseAnimStacks(e){const t=y.Objects.AnimationStack,n={};for(const r in t){const s=F.get(parseInt(r)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const i=e.get(s[0].ID);n[r]={name:t[r].attrName,layer:i}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(r){t=t.concat(n.generateTracks(r))}),new ke(e.name,-1,t)}generateTracks(e){const t=[];let n=new M,r=new M;if(e.transform&&e.transform.decompose(n,new R,r),n=n.toArray(),r=r.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");s!==void 0&&t.push(s)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const s=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);s!==void 0&&t.push(s)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");s!==void 0&&t.push(s)}if(e.DeformPercent!==void 0){const s=this.generateMorphTrack(e);s!==void 0&&t.push(s)}return t}generateVectorTrack(e,t,n,r){const s=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(s,t,n);return new Ce(e+"."+r,s,i)}generateRotationTrack(e,t,n,r,s){let i,a;if(t.x!==void 0&&t.y!==void 0&&t.z!==void 0){const u=this.interpolateRotations(t.x,t.y,t.z,s);i=u[0],a=u[1]}const o=G(0);n!==void 0&&(n=n.map(S.degToRad),n.push(o),n=new O().fromArray(n),n=new R().setFromEuler(n)),r!==void 0&&(r=r.map(S.degToRad),r.push(o),r=new O().fromArray(r),r=new R().setFromEuler(r).invert());const l=new R,p=new O,c=[];if(!a||!i)return new re(e+".quaternion",[0],[0]);for(let u=0;u<a.length;u+=3)p.set(a[u],a[u+1],a[u+2],s),l.setFromEuler(p),n!==void 0&&l.premultiply(n),r!==void 0&&l.multiply(r),u>2&&new R().fromArray(c,(u-3)/3*4).dot(l)<0&&l.set(-l.x,-l.y,-l.z,-l.w),l.toArray(c,u/3*4);return new re(e+".quaternion",i,c)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),r=A.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new be(e.modelName+".morphTargetInfluences["+r+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,r){return n-r}),t.length>1){let n=1,r=t[0];for(let s=1;s<t.length;s++){const i=t[s];i!==r&&(t[n]=i,r=i,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const r=n,s=[];let i=-1,a=-1,o=-1;return e.forEach(function(l){if(t.x&&(i=t.x.times.indexOf(l)),t.y&&(a=t.y.times.indexOf(l)),t.z&&(o=t.z.times.indexOf(l)),i!==-1){const p=t.x.values[i];s.push(p),r[0]=p}else s.push(r[0]);if(a!==-1){const p=t.y.values[a];s.push(p),r[1]=p}else s.push(r[1]);if(o!==-1){const p=t.z.values[o];s.push(p),r[2]=p}else s.push(r[2])}),s}interpolateRotations(e,t,n,r){const s=[],i=[];s.push(e.times[0]),i.push(S.degToRad(e.values[0])),i.push(S.degToRad(t.values[0])),i.push(S.degToRad(n.values[0]));for(let a=1;a<e.values.length;a++){const o=[e.values[a-1],t.values[a-1],n.values[a-1]];if(isNaN(o[0])||isNaN(o[1])||isNaN(o[2]))continue;const l=o.map(S.degToRad),p=[e.values[a],t.values[a],n.values[a]];if(isNaN(p[0])||isNaN(p[1])||isNaN(p[2]))continue;const c=p.map(S.degToRad),u=[p[0]-o[0],p[1]-o[1],p[2]-o[2]],h=[Math.abs(u[0]),Math.abs(u[1]),Math.abs(u[2])];if(h[0]>=180||h[1]>=180||h[2]>=180){const g=Math.max(...h)/180,d=new O(...l,r),w=new O(...c,r),T=new R().setFromEuler(d),v=new R().setFromEuler(w);T.dot(v)&&v.set(-v.x,-v.y,-v.z,-v.w);const x=e.times[a-1],E=e.times[a]-x,P=new R,C=new O;for(let L=0;L<1;L+=1/g)P.copy(T.clone().slerp(v.clone(),L)),s.push(x+L*E),C.setFromQuaternion(P,r),i.push(C.x),i.push(C.y),i.push(C.z)}else s.push(e.times[a]),i.push(S.degToRad(e.values[a])),i.push(S.degToRad(t.values[a])),i.push(S.degToRad(n.values[a]))}return[s,i]}}class We{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new oe,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(r,s){const i=r.match(/^[\s\t]*;/),a=r.match(/^[\s\t]*$/);if(i||a)return;const o=r.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),l=r.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),p=r.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(r,o):l?t.parseNodeProperty(r,l,n[++s]):p?t.popStack():r.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(r)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map(function(o){return o.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},i=this.parseNodeAttr(r),a=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,s):n in a?(n==="PoseNode"?a.PoseNode.push(s):a[n].id!==void 0&&(a[n]={},a[n][a[n].id]=a[n]),i.id!==""&&(a[n][i.id]=s)):typeof i.id=="number"?(a[n]={},a[n][i.id]=s):n!=="Properties70"&&(n==="PoseNode"?a[n]=[s]:a[n]=s),typeof i.id=="number"&&(s.id=i.id),i.name!==""&&(s.attrName=i.name),i.type!==""&&(s.attrType=i.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();r==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if(i.name==="Properties70"){this.parseNodeSpecialProperty(e,r,s);return}if(r==="C"){const o=s.split(",").slice(1),l=parseInt(o[0]),p=parseInt(o[1]);let c=s.split(",").slice(3);c=c.map(function(u){return u.trim().replace(/^"/,"")}),r="connections",s=[l,p],$e(s,c),i[r]===void 0&&(i[r]=[])}r==="Node"&&(i.id=s),r in i&&Array.isArray(i[r])?i[r].push(s):r!=="a"?i[r]=s:i.a=s,this.setCurrentProp(i,r),r==="a"&&s.slice(-1)!==","&&(i.a=q(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=q(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map(function(p){return p.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=r[0],i=r[1],a=r[2],o=r[3];let l=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=q(l);break}this.getPrevNode()[s]={type:i,type2:a,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),s)}}class Ne{parse(e){const t=new se(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new oe;for(;!this.endOfContent(t);){const s=this.parseNode(t,n);s!==null&&r.add(s.name,s)}return r}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),a=e.getString(i);if(r===0)return null;const o=[];for(let u=0;u<s;u++)o.push(this.parseProperty(e));const l=o.length>0?o[0]:"",p=o.length>1?o[1]:"",c=o.length>2?o[2]:"";for(n.singleProperty=s===1&&e.getOffset()===r;r>e.getOffset();){const u=this.parseNode(e,t);u!==null&&this.parseSubNode(a,n,u)}return n.propertyList=o,typeof l=="number"&&(n.id=l),p!==""&&(n.attrName=p),c!==""&&(n.attrType=c),a!==""&&(n.name=a),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const r=n.propertyList[0];Array.isArray(r)?(t[n.name]=n,n.a=r):t[n.name]=r}else if(e==="Connections"&&n.name==="C"){const r=[];n.propertyList.forEach(function(s,i){i!==0&&r.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(r)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let r=n.propertyList[0],s=n.propertyList[1];const i=n.propertyList[2],a=n.propertyList[3];let o;r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?o=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:o=n.propertyList[4],t[r]={type:s,type2:i,flag:a,value:o}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),s=e.getUint32(),i=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}const a=Re(new Uint8Array(e.getArrayBuffer(i))),o=new se(a.buffer);switch(t){case"b":case"c":return o.getBooleanArray(r);case"d":return o.getFloat64Array(r);case"f":return o.getFloat32Array(r);case"i":return o.getInt32Array(r);case"l":return o.getInt64Array(r)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class se{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}}class oe{add(e,t){this[e]=t}}function Qe(f){const e="Kaydara FBX Binary \0";return f.byteLength>=e.length&&e===ce(f,0,e.length)}function Ye(f){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(r){const s=f[r-1];return f=f.slice(t+r),t++,s}for(let r=0;r<e.length;++r)if(n(1)===e[r])return!1;return!0}function ie(f){const e=/FBXVersion: (\d+)/,t=f.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function qe(f){return f/46186158e3}const Ze=[];function H(f,e,t,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=f;break;case"ByPolygon":r=e;break;case"ByVertice":r=t;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(r=n.indices[r]);const s=r*n.dataSize,i=s+n.dataSize;return Je(Ze,n.buffer,s,i)}const Y=new O,U=new M;function le(f){const e=new I,t=new I,n=new I,r=new I,s=new I,i=new I,a=new I,o=new I,l=new I,p=new I,c=new I,u=new I,h=f.inheritType?f.inheritType:0;f.translation&&e.setPosition(U.fromArray(f.translation));const m=G(0);if(f.preRotation){const k=f.preRotation.map(S.degToRad);k.push(m),t.makeRotationFromEuler(Y.fromArray(k))}if(f.rotation){const k=f.rotation.map(S.degToRad);k.push(f.eulerOrder||m),n.makeRotationFromEuler(Y.fromArray(k))}if(f.postRotation){const k=f.postRotation.map(S.degToRad);k.push(m),r.makeRotationFromEuler(Y.fromArray(k)),r.invert()}f.scale&&s.scale(U.fromArray(f.scale)),f.scalingOffset&&a.setPosition(U.fromArray(f.scalingOffset)),f.scalingPivot&&i.setPosition(U.fromArray(f.scalingPivot)),f.rotationOffset&&o.setPosition(U.fromArray(f.rotationOffset)),f.rotationPivot&&l.setPosition(U.fromArray(f.rotationPivot)),f.parentMatrixWorld&&(c.copy(f.parentMatrix),p.copy(f.parentMatrixWorld));const g=t.clone().multiply(n).multiply(r),d=new I;d.extractRotation(p);const w=new I;w.copyPosition(p);const T=w.clone().invert().multiply(p),v=d.clone().invert().multiply(T),x=s,E=new I;if(h===0)E.copy(d).multiply(g).multiply(v).multiply(x);else if(h===1)E.copy(d).multiply(v).multiply(g).multiply(x);else{const N=new I().scale(new M().setFromMatrixScale(c)).clone().invert(),pe=v.clone().multiply(N);E.copy(d).multiply(g).multiply(pe).multiply(x)}const P=l.clone().invert(),C=i.clone().invert();let L=e.clone().multiply(o).multiply(l).multiply(t).multiply(n).multiply(r).multiply(P).multiply(a).multiply(i).multiply(s).multiply(C);const j=new I().copyPosition(L),X=p.clone().multiply(j);return u.copyPosition(X),L=u.clone().multiply(E),L.premultiply(p.invert()),L}function G(f){f=f||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return f===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[f]}function q(f){return f.split(",").map(function(t){return parseFloat(t)})}function ce(f,e,t){return e===void 0&&(e=0),t===void 0&&(t=f.byteLength),new TextDecoder().decode(new Uint8Array(f,e,t))}function $e(f,e){for(let t=0,n=f.length,r=e.length;t<r;t++,n++)f[n]=e[t]}function Je(f,e,t,n){for(let r=t,s=0;r<n;r++,s++)f[s]=e[r];return f}export{nt as FBXLoader};
|