toposync-ext-models 0.2.2__tar.gz → 0.4.0__tar.gz
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.
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/PKG-INFO +1 -1
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/pyproject.toml +1 -1
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/__init__.py +1 -1
- toposync_ext_models-0.4.0/src/toposync_ext_models/static/703.js +2 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/main.js +1 -1
- toposync_ext_models-0.2.2/src/toposync_ext_models/static/703.js +0 -2
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/.gitignore +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/LICENSE +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/README.md +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/extension.json +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/plugin.py +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/326.js +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/326.js.LICENSE.txt +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/387.js +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/703.js.LICENSE.txt +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/753.js +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/753.js.LICENSE.txt +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/main.js.LICENSE.txt +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/remoteEntry.js +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/package.json +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/activate.tsx +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/api/filesApi.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/constants.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/debug.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/elements/ModelElementType.tsx +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/entry.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/parsing.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/preview/modelPreview.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/runtime/gltfModel.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/tools/importModelTool.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/translations.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/types.ts +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/tsconfig.json +0 -0
- {toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/webpack.config.js +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 703.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.webpackChunk_toposync_extension_models_ui=self.webpackChunk_toposync_extension_models_ui||[]).push([[703],{87(e,t,s){s.d(t,{Bf:()=>r,I6:()=>i,Td:()=>a,_l:()=>n,wD:()=>o});const n="com.toposync.models.gltf",r="com.toposync.models.tool.import",o=.001,i=1e3,a="toposync.debug.models"},94(e,t,s){var n=s(496),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,o={},c=null,u=null;for(n in void 0!==s&&(c=""+s),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)i.call(t,n)&&!l.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:r,type:e,key:c,ref:u,props:o,_owner:a.current}}t.Fragment=o,t.jsx=c,t.jsxs=c},95(e,t,s){s.d(t,{p:()=>i});var n=s(320),r=s(912),o=s(322);function i(e,t){const s=new e.Group,i=new e.BoxGeometry(1,1,1),a=new e.MeshBasicMaterial({color:3718648,wireframe:!0,transparent:!0,opacity:.22,depthWrite:!1}),l=new e.Mesh(i,a);l.visible=!1,s.add(l);const c=new n.B;let u=!1,d=0,h="",m=null,p=null,f=[],g=!1,x=Boolean(t?.autoplay);function A(e){const t=e,s=["map","alphaMap","aoMap","bumpMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","displacementMap","emissiveMap","envMap","iridescenceMap","iridescenceThicknessMap","lightMap","metalnessMap","normalMap","roughnessMap","sheenColorMap","sheenRoughnessMap","specularColorMap","specularIntensityMap","thicknessMap","transmissionMap"];for(const e of s){const s=t[e];s&&s.isTexture&&"function"==typeof s.dispose&&s.dispose()}e.dispose()}function T(e){e.traverse(e=>{const t=e;t.geometry?.dispose&&t.geometry.dispose();const s=t.material;Array.isArray(s)?s.forEach(e=>e&&A(e)):s&&A(s)})}function y(){if(p){try{p.stopAllAction()}catch{}if(m)try{p.uncacheRoot(m)}catch{}p=null,f=[],g=!1}}function v(){p&&(x?function(){if(p)for(const e of f)try{e.reset(),e.play()}catch{}}():function(){if(p){for(const e of f)try{e.stop()}catch{}try{p.setTime(0)}catch{}}}())}return{object:s,updateFromProps:function(n){const i=n&&"object"==typeof n&&!Array.isArray(n)?n:{},a=(0,o.E3)(i.dir,""),x=(0,o.E3)(i.model,""),A=(0,o.RS)(i.scale,1),R=(0,o.ZX)(i.size,{x:1,y:1,z:1}),M=(0,o.ZX)(i.center,{x:0,y:0,z:0}),w=(0,o.kz)(i.min_y,0);s.scale.setScalar(A),l.scale.set(Math.max(.05,Math.abs(R.x)),Math.max(.05,Math.abs(R.y)),Math.max(.05,Math.abs(R.z))),l.position.y=l.scale.y/2;const E=a&&x?(0,r.resolveToposyncUrl)(`/files/${encodeURIComponent(a)}/${encodeURIComponent(x)}`):"";if(!E)return h="",l.visible=!1,void(m&&(s.remove(m),y(),T(m),m=null));E&&E!==h&&(h=E,l.visible=!m,async function(n,r){const o=++d;try{const i=await c.loadAsync(n);if(u||o!==d)return;const a=i.scene||i.scenes?.[0];if(!a)throw new Error("Empty model");a.traverse(e=>{const t=e;t.isMesh&&(t.castShadow=!0,t.receiveShadow=!0)});const h=(new e.Box3).setFromObject(a),x=h.getCenter(new e.Vector3),A=h.min.y,R=r?.center??{x:x.x,y:x.y,z:x.z},M=r?.minY??A;a.position.sub(new e.Vector3(R.x,M,R.z)),m&&(s.remove(m),y(),T(m),m=null),m=a,s.add(a),l.visible=!1,Array.isArray(i.animations)&&i.animations.length>0?(p=new e.AnimationMixer(a),f=i.animations.map(e=>p.clipAction(e)),g=f.length>0,v()):y(),t?.onInvalidate?.()}catch(e){console.error("[models:gltfModel]",e),t?.onInvalidate?.()}}(E,{center:M,minY:w}))},setAnimated:function(e){e!==x&&(x=e,v())},tick:e=>!(!x||!p||(p?.update(e),0)),dispose:()=>{u=!0,y(),m&&T(m),i.dispose(),a.dispose()},getHasAnimations:()=>g}}},161(e,t,s){s.d(t,{M:()=>d});var n=s(870),r=s(496),o=s(912),i=s(87),a=s(322),l=s(95);function c(e,t){return"boolean"==typeof e?e:t}function u(e){const t=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),s=(0,a.RS)(e.props.scale,1),n=(0,a.kz)(e.rotation?.y,0),r=t.x*s/2,o=t.z*s/2,i=Math.cos(n),l=Math.sin(n),c=[],u=[];for(const t of[{x:-r,z:-o},{x:r,z:-o},{x:r,z:o},{x:-r,z:o}])c.push(e.position.x+t.x*i-t.z*l),u.push(e.position.z+t.x*l+t.z*i);return{minX:Math.min(...c),maxX:Math.max(...c),minZ:Math.min(...u),maxZ:Math.max(...u)}}function d(e){const t=new Map;function s(e){const t=(0,a.E3)(e.props.dir,""),s=(0,a.E3)(e.props.preview,"");return t&&s?(0,o.resolveToposyncUrl)(`/files/${encodeURIComponent(t)}/${encodeURIComponent(s)}`):null}return{type:i._l,layerGroup:"objects",placeable:!1,name:{key:"ext.models.element.name",fallback:"3D Model"},description:{key:"ext.models.element.desc",fallback:"GLB/GLTF model placed in the scene."},defaultProps:{dir:"",model:"",preview:"",size:{x:1,y:1,z:1},center:{x:0,y:0,z:0},min_y:0,scale:1,animation_enabled:!1},getMain2DBounds:u,renderMain2DVector:({element:e})=>{const t=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),r=(0,a.RS)(e.props.scale,1),o=s(e),i=-180*(0,a.kz)(e.rotation?.y,0)/Math.PI,l=Math.max(.2,t.x*r),u=Math.max(.2,t.z*r),d=c(e.props.animation_enabled,!1),h=d?"rgba(56,189,248,0.42)":"rgba(226,232,240,0.22)";return(0,n.jsxs)("g",{className:"mainVector2dModel",transform:`translate(${e.position.x} ${e.position.z}) rotate(${i})`,opacity:.96,filter:"url(#mainVector2dSoftShadow)",children:[(0,n.jsx)("rect",{x:-l/2,y:-u/2,width:l,height:u,rx:.05,fill:"rgba(2,6,23,0.12)"}),o?(0,n.jsx)("image",{href:o,x:-l/2,y:-u/2,width:l,height:u,preserveAspectRatio:"none"}):(0,n.jsx)("rect",{x:-l/2,y:-u/2,width:l,height:u,rx:.05,fill:"rgba(56,189,248,0.08)"}),(0,n.jsx)("rect",{x:-l/2,y:-u/2,width:l,height:u,rx:.05,fill:"none",stroke:h,strokeWidth:.018,vectorEffect:"non-scaling-stroke"}),d?(0,n.jsx)("circle",{cx:l/2-.07,cy:-u/2+.07,r:.025,fill:"rgba(56,189,248,0.72)"}):null]})},create3D:({THREE:e,requestRender:t},s)=>{const n=(0,l.p)(e,{autoplay:!1,onInvalidate:t});return n.updateFromProps(s.props),n.setAnimated(c(s.props.animation_enabled,!1)),{object:n.object,update:e=>{n.updateFromProps(e.props),n.setAnimated(c(e.props.animation_enabled,!1))},tick:n.tick,dispose:n.dispose}},render2D:({ctx:e,element:n,viewport:r})=>{const o=(0,a.ZX)(n.props.size,{x:1,y:1,z:1}),i=(0,a.RS)(n.props.scale,1),l=s(n),c=(0,a.kz)(n.rotation?.y,0),u=r.worldToScreen({x:n.position.x,z:n.position.z}),d=Math.max(20,o.x*i*r.scale),h=Math.max(20,o.z*i*r.scale);if(e.save(),e.translate(u.x,u.y),e.rotate(-c),l){let s=t.get(l)??null;s||(s=new Image,s.decoding="async",s.onload=()=>r.canvas.dispatchEvent(new Event("toposync:invalidate")),s.onerror=()=>r.canvas.dispatchEvent(new Event("toposync:invalidate")),s.src=l,t.set(l,s)),s.complete&&s.naturalWidth>0?(e.globalAlpha=.94,e.drawImage(s,-d/2,-h/2,d,h),e.globalAlpha=1):(e.fillStyle="rgba(56,189,248,0.10)",e.fillRect(-d/2,-h/2,d,h))}else e.fillStyle="rgba(56,189,248,0.10)",e.fillRect(-d/2,-h/2,d,h);e.strokeStyle="rgba(230,232,242,0.22)",e.lineWidth=2,e.strokeRect(-d/2,-h/2,d,h),e.restore()},hitTest2D:({element:e,world:t})=>{const s=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),n=(0,a.RS)(e.props.scale,1),r=(0,a.kz)(e.rotation?.y,0),o=t.x-e.position.x,i=t.z-e.position.z,l=Math.cos(r),c=Math.sin(r),u=o*l-i*c,d=o*c+i*l;return Math.abs(u)<=s.x*n/2&&Math.abs(d)<=s.z*n/2},renderEditorModal:({element:t,update:s,remove:r,close:o})=>(0,n.jsx)(h,{element:t,update:s,remove:r,close:o,i18n:e})}}function h({element:e,update:t,remove:s,close:l,i18n:u}){const{t:d,locale:h}=u.useI18n(),m=(0,r.useMemo)(()=>new Intl.NumberFormat(h,{minimumFractionDigits:2,maximumFractionDigits:2}),[h]),p=(0,a.E3)(e.props.dir,""),f=(0,a.E3)(e.props.model,""),g=(0,a.E3)(e.props.preview,""),x=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),A=(0,a.RS)(e.props.scale,1),T=c(e.props.animation_enabled,!1),y=(0,a.kz)(e.position.y,0),v=p&&g?(0,o.resolveToposyncUrl)(`/files/${encodeURIComponent(p)}/${encodeURIComponent(g)}`):"",R=(0,r.useMemo)(()=>({x:x.x*A,y:x.y*A,z:x.z*A}),[A,x.x,x.y,x.z]);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"field",children:[(0,n.jsx)("div",{className:"label",children:d("core.element_editor.name")}),(0,n.jsx)("input",{className:"input",value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,n.jsxs)("div",{className:"rowWrap",children:[(0,n.jsxs)("div",{className:"field",style:{flex:1,minWidth:180},children:[(0,n.jsx)("div",{className:"label",children:d("ext.models.editor.file")}),(0,n.jsx)("input",{className:"input",value:f||"-",readOnly:!0})]}),(0,n.jsxs)("div",{className:"field",style:{flex:1,minWidth:180},children:[(0,n.jsx)("div",{className:"label",children:d("ext.models.editor.size")}),(0,n.jsx)("input",{className:"input",value:`${m.format(R.x)} × ${m.format(R.y)} × ${m.format(R.z)} m`,readOnly:!0})]})]}),(0,n.jsx)("div",{className:"rowWrap",children:(0,n.jsxs)("div",{className:"field",style:{flex:1,minWidth:180},children:[(0,n.jsx)("div",{className:"label",children:d("ext.models.editor.scale")}),(0,n.jsx)("input",{className:"input",type:"number",inputMode:"decimal",min:i.wD,max:i.I6,step:.01,value:A,onChange:e=>{const s=Number.parseFloat(e.target.value);Number.isFinite(s)&&t({props:{scale:(0,a.qE)(s,i.wD,i.I6)}})}})]})}),(0,n.jsxs)("label",{className:"chipButton",style:{display:"inline-flex",alignItems:"center",gap:10},children:[(0,n.jsx)("input",{type:"checkbox",checked:T,onChange:e=>t({props:{animation_enabled:e.target.checked}})}),(0,n.jsx)("span",{children:d("ext.models.editor.play_animations")})]}),(0,n.jsxs)("div",{className:"field",children:[(0,n.jsxs)("div",{className:"label",children:[d("ext.models.editor.height"),": ",m.format(y)," m"]}),(0,n.jsx)("div",{className:"rowWrap",children:[{key:"floor",y:0},{key:"mid",y:1.35},{key:"ceiling",y:2.7}].map(e=>{const s=Math.abs(y-e.y)<.01;return(0,n.jsx)("button",{className:["chipButton",s?"isActive":""].join(" "),type:"button",onClick:()=>t({position:{y:e.y}}),children:d(`ext.models.editor.height.${e.key}`)},e.key)})}),(0,n.jsx)("input",{className:"input",type:"range",min:0,max:3,step:.01,value:y,onChange:e=>t({position:{y:Number(e.target.value)}})})]}),v?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"sectionDivider"}),(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"cardHeaderRow",children:[(0,n.jsx)("div",{className:"cardTitle",children:d("ext.models.editor.preview")}),(0,n.jsx)("div",{className:"cardMeta",children:p})]}),(0,n.jsx)("div",{className:"cardBody",children:(0,n.jsx)("img",{src:v,alt:d("ext.models.editor.preview"),style:{width:"100%",borderRadius:12,border:"1px solid rgba(255,255,255,0.10)"}})})]})]}):null,(0,n.jsx)("div",{className:"sectionDivider"}),(0,n.jsxs)("div",{className:"rowWrap",children:[(0,n.jsx)("button",{className:"dangerButton",type:"button",onClick:s,children:d("core.actions.delete")}),(0,n.jsx)("button",{className:"chipButton",type:"button",onClick:l,children:d("core.actions.close")})]})]})}},194(e,t,s){s.d(t,{A_:()=>c,Qj:()=>a,Rj:()=>l});var n=s(97),r=s(320),o=s(87),i=s(322);function a(e){const t=e.lastIndexOf(".");return t<=0?e:e.slice(0,t)}function l(e){const t=Math.max(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z));return!Number.isFinite(t)||t<=1e-6?1:t>3?(0,i.qE)(1/t,o.wD,o.I6):t<.25?(0,i.qE)(.25/t,o.wD,o.I6):1}async function c(e,t){const s=Math.max(128,Math.min(1024,t?.renderSize??640)),o=(0,i.qE)(t?.paddingRatio??.08,0,.5),a=new r.B,l=await a.loadAsync(e),c=l.scene||l.scenes?.[0];if(!c)throw new Error("Empty model");const u=c.clone(!0);u.updateMatrixWorld(!0);const d=(new n.Box3).setFromObject(u),h=d.getSize(new n.Vector3),m=d.getCenter(new n.Vector3),p=d.min.y;if(!Number.isFinite(h.x)||!Number.isFinite(h.y)||!Number.isFinite(h.z)||h.length()<1e-6)throw new Error("Could not compute model size");u.position.sub(new n.Vector3(m.x,p,m.z));const f=Math.max(h.x,1e-6),g=Math.max(h.z,1e-6),x=f*(1+2*o),A=g*(1+2*o),T=s/Math.max(x,A),y=Math.max(64,Math.round(x*T)),v=Math.max(64,Math.round(A*T)),R=function(e,t){const s=new n.OrthographicCamera(-e/2,e/2,t/2,-t/2,.01,8*Math.max(e,t));return s.position.set(0,Math.max(e,t),0),s.up.set(0,0,-1),s.lookAt(new n.Vector3(0,0,0)),s}(x||1,A||1),M=function(e,t){const s=new n.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});return s.setPixelRatio(1),s.setSize(e,t,!1),s.setClearColor(0,0),s.outputColorSpace=n.SRGBColorSpace,s}(y,v),w=new n.Scene;!function(e){const t=new n.HemisphereLight(16777215,2236979,.9);e.add(t);const s=new n.DirectionalLight(16777215,.8);s.position.set(3,6,3),s.castShadow=!1,e.add(s)}(w),w.add(u),M.render(w,R);const E=f/Math.max(x,1e-9),_=g/Math.max(A,1e-9),b=Math.max(1,Math.min(y,Math.round(y*E))),S=Math.max(1,Math.min(v,Math.round(v*_))),L=Math.max(0,Math.min(y-b,Math.round((y-b)/2))),I=Math.max(0,Math.min(v-S,Math.round((v-S)/2)));let C=y,N=v,P="";if(b!==y||S!==v){const e=document.createElement("canvas");e.width=b,e.height=S;const t=e.getContext("2d");t&&(t.drawImage(M.domElement,L,I,b,S,0,0,b,S),P=e.toDataURL("image/png"),C=b,N=S)}P||(P=M.domElement.toDataURL("image/png"));try{M.dispose()}catch{}return{dataUrl:P,widthPx:C,heightPx:N,size:{x:h.x,y:h.y,z:h.z},center:{x:m.x,y:m.y,z:m.z},minY:p}}},320(e,t,s){s.d(t,{B:()=>o});var n=s(97);function r(e,t){if(t===n.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===n.TriangleFanDrawMode||t===n.TriangleStripDrawMode){let s=e.getIndex();if(null===s){const t=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),s=e.getIndex()}const r=s.count-2,o=[];if(t===n.TriangleFanDrawMode)for(let e=1;e<=r;e++)o.push(s.getX(0)),o.push(s.getX(e)),o.push(s.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(o.push(s.getX(e)),o.push(s.getX(e+1)),o.push(s.getX(e+2))):(o.push(s.getX(e+2)),o.push(s.getX(e+1)),o.push(s.getX(e)));o.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=e.clone();return i.setIndex(o),i.clearGroups(),i}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class o extends n.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new d(e)}),this.register(function(e){return new h(e)}),this.register(function(e){return new v(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new M(e)}),this.register(function(e){return new p(e)}),this.register(function(e){return new f(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new u(e)}),this.register(function(e){return new A(e)}),this.register(function(e){return new m(e)}),this.register(function(e){return new y(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new l(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new E(e)})}load(e,t,s,r){const o=this;let i;if(""!==this.resourcePath)i=this.resourcePath;else if(""!==this.path){const t=n.LoaderUtils.extractUrlBase(e);i=n.LoaderUtils.resolveURL(t,this.path)}else i=n.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),o.manager.itemError(e),o.manager.itemEnd(e)},l=new n.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(s){try{o.parse(s,i,function(s){t(s),o.manager.itemEnd(e)},a)}catch(e){a(e)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let r;const o={},i={},l=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===_){try{o[a.KHR_BINARY_GLTF]=new b(e)}catch(e){return void(n&&n(e))}r=JSON.parse(o[a.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new $(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](u);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),i[t.name]=t,o[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],s=r.extensionsRequired||[];switch(t){case a.KHR_MATERIALS_UNLIT:o[t]=new c;break;case a.KHR_DRACO_MESH_COMPRESSION:o[t]=new S(r,this.dracoLoader);break;case a.KHR_TEXTURE_TRANSFORM:o[t]=new L;break;case a.KHR_MESH_QUANTIZATION:o[t]=new I;break;default:s.indexOf(t)>=0&&void 0===i[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}u.setExtensions(o),u.setPlugins(i),u.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,r){s.parse(e,t,n,r)})}}function i(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const a={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class l{constructor(e){this.parser=e,this.name=a.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let r=t.cache.get(s);if(r)return r;const o=t.json,i=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let a;const l=new n.Color(16777215);void 0!==i.color&&l.setRGB(i.color[0],i.color[1],i.color[2],n.LinearSRGBColorSpace);const c=void 0!==i.range?i.range:0;switch(i.type){case"directional":a=new n.DirectionalLight(l),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new n.PointLight(l),a.distance=c;break;case"spot":a=new n.SpotLight(l),a.distance=c,i.spot=i.spot||{},i.spot.innerConeAngle=void 0!==i.spot.innerConeAngle?i.spot.innerConeAngle:0,i.spot.outerConeAngle=void 0!==i.spot.outerConeAngle?i.spot.outerConeAngle:Math.PI/4,a.angle=i.spot.outerConeAngle,a.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return a.position.set(0,0,0),a.decay=2,K(a,i),void 0!==i.intensity&&(a.intensity=i.intensity),a.name=t.createUniqueName(i.name||"light_"+e),r=Promise.resolve(a),t.cache.add(s,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,n=s.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then(function(e){return s._getNodeRef(t.cache,r,e)})}}class c{constructor(){this.name=a.KHR_MATERIALS_UNLIT}getMaterialType(){return n.MeshBasicMaterial}extendParams(e,t,s){const r=[];e.color=new n.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const t=o.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],n.LinearSRGBColorSpace),e.opacity=t[3]}void 0!==o.baseColorTexture&&r.push(s.assignTexture(e,"map",o.baseColorTexture,n.SRGBColorSpace))}return Promise.all(r)}}class u{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class d{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&o.push(s.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&o.push(s.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(o.push(s.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new n.Vector2(e,e)}return Promise.all(o)}}class h{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class m{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&r.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(t.iridescenceIOR=o.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&r.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class p{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new n.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=r.extensions[this.name];if(void 0!==i.sheenColorFactor){const e=i.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],n.LinearSRGBColorSpace)}return void 0!==i.sheenRoughnessFactor&&(t.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&o.push(s.assignTexture(t,"sheenColorMap",i.sheenColorTexture,n.SRGBColorSpace)),void 0!==i.sheenRoughnessTexture&&o.push(s.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(o)}}class f{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&r.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class g{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&o.push(s.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=(new n.Color).setRGB(a[0],a[1],a[2],n.LinearSRGBColorSpace),Promise.all(o)}}class x{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class A{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&o.push(s.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=(new n.Color).setRGB(a[0],a[1],a[2],n.LinearSRGBColorSpace),void 0!==i.specularColorTexture&&o.push(s.assignTexture(t,"specularColorMap",i.specularColorTexture,n.SRGBColorSpace)),Promise.all(o)}}class T{constructor(e){this.parser=e,this.name=a.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return t.bumpScale=void 0!==o.bumpFactor?o.bumpFactor:1,void 0!==o.bumpTexture&&r.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}}class y{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.anisotropyStrength&&(t.anisotropy=o.anisotropyStrength),void 0!==o.anisotropyRotation&&(t.anisotropyRotation=o.anisotropyRotation),void 0!==o.anisotropyTexture&&r.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}}class v{constructor(e){this.parser=e,this.name=a.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class R{constructor(e){this.parser=e,this.name=a.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],i=n.images[o.source];let a=s.textureLoader;if(i.uri){const e=s.options.manager.getHandler(i.uri);null!==e&&(a=e)}return this.detectSupport().then(function(r){if(r)return s.loadTextureImage(e,o.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class M{constructor(e){this.parser=e,this.name=a.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],i=n.images[o.source];let a=s.textureLoader;if(i.uri){const e=s.options.manager.getHandler(i.uri);null!==e&&(a=e)}return this.detectSupport().then(function(r){if(r)return s.loadTextureImage(e,o.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class w{constructor(e){this.name=a.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(t){const s=e.byteOffset||0,n=e.byteLength||0,o=e.count,i=e.byteStride,a=new Uint8Array(t,s,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(o,i,a,e.mode,e.filter).then(function(e){return e.buffer}):r.ready.then(function(){const t=new ArrayBuffer(o*i);return r.decodeGltfBuffer(new Uint8Array(t),o,i,a,e.mode,e.filter),t})})}return null}}class E{constructor(e){this.name=a.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||void 0===s.mesh)return null;const r=t.meshes[s.mesh];for(const e of r.primitives)if(e.mode!==k.TRIANGLES&&e.mode!==k.TRIANGLE_STRIP&&e.mode!==k.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=s.extensions[this.name].attributes,i=[],a={};for(const e in o)i.push(this.parser.getDependency("accessor",o[e]).then(t=>(a[e]=t,a[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{const t=e.pop(),s=t.isGroup?t.children:[t],r=e[0].count,o=[];for(const e of s){const t=new n.Matrix4,s=new n.Vector3,i=new n.Quaternion,l=new n.Vector3(1,1,1),c=new n.InstancedMesh(e.geometry,e.material,r);for(let e=0;e<r;e++)a.TRANSLATION&&s.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&i.fromBufferAttribute(a.ROTATION,e),a.SCALE&&l.fromBufferAttribute(a.SCALE,e),c.setMatrixAt(e,t.compose(s,i,l));for(const t in a)if("_COLOR_0"===t){const e=a[t];c.instanceColor=new n.InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,a[t]);n.Object3D.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),o.push(c)}return t.isGroup?(t.clear(),t.add(...o),t):o[0]}))}}const _="glTF";class b{constructor(e){this.name=a.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==_)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let o=0;for(;o<n;){const t=r.getUint32(o,!0);o+=4;const n=r.getUint32(o,!0);if(o+=4,1313821514===n){const n=new Uint8Array(e,12+o,t);this.content=s.decode(n)}else if(5130562===n){const s=12+o;this.body=e.slice(s,s+t)}o+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class S{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=a.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},l={},c={};for(const e in i){const t=D[e]||e.toLowerCase();a[t]=i[e]}for(const t in e.attributes){const n=D[t]||t.toLowerCase();if(void 0!==i[t]){const r=s.accessors[e.attributes[t]],o=O[r.componentType];c[n]=o.name,l[n]=!0===r.normalized}}return t.getDependency("bufferView",o).then(function(e){return new Promise(function(t,s){r.decodeDracoFile(e,function(e){for(const t in e.attributes){const s=e.attributes[t],n=l[t];void 0!==n&&(s.normalized=n)}t(e)},a,c,n.LinearSRGBColorSpace,s)})})}}class L{constructor(){this.name=a.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class I{constructor(){this.name=a.KHR_MESH_QUANTIZATION}}class C extends n.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=s[r+e];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,o=this.sampleValues,i=this.valueSize,a=2*i,l=3*i,c=n-t,u=(s-t)/c,d=u*u,h=d*u,m=e*l,p=m-l,f=-2*h+3*d,g=h-d,x=1-f,A=g-d+u;for(let e=0;e!==i;e++){const t=o[p+e+i],s=o[p+e+a]*c,n=o[m+e+i],l=o[m+e]*c;r[e]=x*t+A*s+f*n+g*l}return r}}const N=new n.Quaternion;class P extends C{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return N.fromArray(r).normalize().toArray(r),r}}const k={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},O={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},F={9728:n.NearestFilter,9729:n.LinearFilter,9984:n.NearestMipmapNearestFilter,9985:n.LinearMipmapNearestFilter,9986:n.NearestMipmapLinearFilter,9987:n.LinearMipmapLinearFilter},B={33071:n.ClampToEdgeWrapping,33648:n.MirroredRepeatWrapping,10497:n.RepeatWrapping},j={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},D={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},U={CUBICSPLINE:void 0,LINEAR:n.InterpolateLinear,STEP:n.InterpolateDiscrete};function G(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new n.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:n.FrontSide})),e.DefaultMaterial}function z(e,t,s){for(const n in s.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=s.extensions[n])}function K(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function V(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,n=t.weights.length;s<n;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,n=s.length;t<n;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function X(e){let t;const s=e.extensions&&e.extensions[a.KHR_DRACO_MESH_COMPRESSION];if(t=s?"draco:"+s.bufferView+":"+s.indices+":"+q(s.attributes):e.indices+":"+q(e.attributes)+":"+e.mode,void 0!==e.targets)for(let s=0,n=e.targets.length;s<n;s++)t+=":"+q(e.targets[s]);return t}function q(e){let t="";const s=Object.keys(e).sort();for(let n=0,r=s.length;n<r;n++)t+=s[n]+":"+e[s[n]]+";";return t}function W(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Y=new n.Matrix4;class ${constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new i,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,r=-1,o=!1,a=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;s=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);r=s&&t?parseInt(t[1],10):-1,o=e.indexOf("Firefox")>-1,a=o?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||s&&r<17||o&&a<98?this.textureLoader=new n.TextureLoader(this.options.manager):this.textureLoader=new n.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new n.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(t){const o={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:s,userData:{}};return z(r,o,n),K(o,n),Promise.all(s._invokeAll(function(e){return e.afterRoot&&e.afterRoot(o)})).then(function(){for(const e of o.scenes)e.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s].joints;for(let t=0,s=n.length;t<s;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(s[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),r=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,n]of e.children.entries())r(n,t.children[s])};return r(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&s.push(r)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":n=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e)}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map(function(t,n){return s.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[a.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(e,o){s.load(n.LoaderUtils.resolveURL(t.uri,r.path),e,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const s=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+s)})}loadAccessor(e){const t=this,s=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=j[r.type],t=O[r.componentType],s=!0===r.normalized,o=new t(r.count*e);return Promise.resolve(new n.BufferAttribute(o,e,s))}const o=[];return void 0!==r.bufferView?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),void 0!==r.sparse&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(e){const o=e[0],i=j[r.type],a=O[r.componentType],l=a.BYTES_PER_ELEMENT,c=l*i,u=r.byteOffset||0,d=void 0!==r.bufferView?s.bufferViews[r.bufferView].byteStride:void 0,h=!0===r.normalized;let m,p;if(d&&d!==c){const e=Math.floor(u/d),s="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let c=t.cache.get(s);c||(m=new a(o,e*d,r.count*d/l),c=new n.InterleavedBuffer(m,d/l),t.cache.add(s,c)),p=new n.InterleavedBufferAttribute(c,i,u%d/l,h)}else m=null===o?new a(r.count*i):new a(o,u,r.count*i),p=new n.BufferAttribute(m,i,h);if(void 0!==r.sparse){const t=j.SCALAR,s=O[r.sparse.indices.componentType],l=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,u=new s(e[1],l,r.sparse.count*t),d=new a(e[2],c,r.sparse.count*i);null!==o&&(p=new n.BufferAttribute(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=u.length;e<t;e++){const t=u[e];if(p.setX(t,d[e*i]),i>=2&&p.setY(t,d[e*i+1]),i>=3&&p.setZ(t,d[e*i+2]),i>=4&&p.setW(t,d[e*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p})}loadTexture(e){const t=this.json,s=this.options,n=t.textures[e].source,r=t.images[n];let o=this.textureLoader;if(r.uri){const e=s.manager.getHandler(r.uri);null!==e&&(o=e)}return this.loadTextureImage(e,n,o)}loadTextureImage(e,t,s){const r=this,o=this.json,i=o.textures[e],a=o.images[t],l=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,s).then(function(t){t.flipY=!1,t.name=i.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const s=(o.samplers||{})[i.sampler]||{};return t.magFilter=F[s.magFilter]||n.LinearFilter,t.minFilter=F[s.minFilter]||n.LinearMipmapLinearFilter,t.wrapS=B[s.wrapS]||n.RepeatWrapping,t.wrapT=B[s.wrapT]||n.RepeatWrapping,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const s=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const o=s.images[e],i=self.URL||self.webkitURL;let a=o.uri||"",l=!1;if(void 0!==o.bufferView)a=this.getDependency("bufferView",o.bufferView).then(function(e){l=!0;const t=new Blob([e],{type:o.mimeType});return a=i.createObjectURL(t),a});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then(function(e){return new Promise(function(s,o){let i=s;!0===t.isImageBitmapLoader&&(i=function(e){const t=new n.Texture(e);t.needsUpdate=!0,s(t)}),t.load(n.LoaderUtils.resolveURL(e,r.path),i,void 0,o)})}).then(function(e){var t;return!0===l&&i.revokeObjectURL(a),K(e,o),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=c,c}assignTexture(e,t,s,n){const r=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((o=o.clone()).channel=s.texCoord),r.extensions[a.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[a.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(o);o=r.extensions[a.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),r.associations.set(o,t)}}return void 0!==n&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const r=void 0===t.attributes.tangent,o=void 0!==t.attributes.color,i=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new n.PointsMaterial,n.Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new n.LineBasicMaterial,n.Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,this.cache.add(e,t)),s=t}if(r||o||i){let e="ClonedMaterial:"+s.uuid+":";r&&(e+="derivative-tangents:"),o&&(e+="vertex-colors:"),i&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),o&&(t.vertexColors=!0),i&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}e.material=s}getMaterialType(){return n.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,r=this.extensions,o=s.materials[e];let i;const l={},c=[];if((o.extensions||{})[a.KHR_MATERIALS_UNLIT]){const e=r[a.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),c.push(e.extendParams(l,o,t))}else{const s=o.pbrMetallicRoughness||{};if(l.color=new n.Color(1,1,1),l.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;l.color.setRGB(e[0],e[1],e[2],n.LinearSRGBColorSpace),l.opacity=e[3]}void 0!==s.baseColorTexture&&c.push(t.assignTexture(l,"map",s.baseColorTexture,n.SRGBColorSpace)),l.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,l.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(c.push(t.assignTexture(l,"metalnessMap",s.metallicRoughnessTexture)),c.push(t.assignTexture(l,"roughnessMap",s.metallicRoughnessTexture))),i=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,l)})))}!0===o.doubleSided&&(l.side=n.DoubleSide);const u=o.alphaMode||"OPAQUE";if("BLEND"===u?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,"MASK"===u&&(l.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&i!==n.MeshBasicMaterial&&(c.push(t.assignTexture(l,"normalMap",o.normalTexture)),l.normalScale=new n.Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;l.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&i!==n.MeshBasicMaterial&&(c.push(t.assignTexture(l,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(l.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&i!==n.MeshBasicMaterial){const e=o.emissiveFactor;l.emissive=(new n.Color).setRGB(e[0],e[1],e[2],n.LinearSRGBColorSpace)}return void 0!==o.emissiveTexture&&i!==n.MeshBasicMaterial&&c.push(t.assignTexture(l,"emissiveMap",o.emissiveTexture,n.SRGBColorSpace)),Promise.all(c).then(function(){const s=new i(l);return o.name&&(s.name=o.name),K(s,o),t.associations.set(s,{materials:e}),o.extensions&&z(r,s,o),s})}createUniqueName(e){const t=n.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,r=this.primitiveCache;function o(e){return s[a.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(s){return Q(s,e,t)})}const i=[];for(let s=0,l=e.length;s<l;s++){const l=e[s],c=X(l),u=r[c];if(u)i.push(u.promise);else{let e;e=l.extensions&&l.extensions[a.KHR_DRACO_MESH_COMPRESSION]?o(l):Q(new n.BufferGeometry,l,t),r[c]={primitive:l,promise:e},i.push(e)}}return Promise.all(i)}loadMesh(e){const t=this,s=this.json,o=this.extensions,i=s.meshes[e],a=i.primitives,l=[];for(let e=0,t=a.length;e<t;e++){const t=void 0===a[e].material?G(this.cache):this.getDependency("material",a[e].material);l.push(t)}return l.push(t.loadGeometries(a)),Promise.all(l).then(function(s){const l=s.slice(0,s.length-1),c=s[s.length-1],u=[];for(let s=0,d=c.length;s<d;s++){const d=c[s],h=a[s];let m;const p=l[s];if(h.mode===k.TRIANGLES||h.mode===k.TRIANGLE_STRIP||h.mode===k.TRIANGLE_FAN||void 0===h.mode)m=!0===i.isSkinnedMesh?new n.SkinnedMesh(d,p):new n.Mesh(d,p),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),h.mode===k.TRIANGLE_STRIP?m.geometry=r(m.geometry,n.TriangleStripDrawMode):h.mode===k.TRIANGLE_FAN&&(m.geometry=r(m.geometry,n.TriangleFanDrawMode));else if(h.mode===k.LINES)m=new n.LineSegments(d,p);else if(h.mode===k.LINE_STRIP)m=new n.Line(d,p);else if(h.mode===k.LINE_LOOP)m=new n.LineLoop(d,p);else{if(h.mode!==k.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);m=new n.Points(d,p)}Object.keys(m.geometry.morphAttributes).length>0&&V(m,i),m.name=t.createUniqueName(i.name||"mesh_"+e),K(m,i),h.extensions&&z(o,m,h),t.assignFinalMaterial(m),u.push(m)}for(let s=0,n=u.length;s<n;s++)t.associations.set(u[s],{meshes:e,primitives:s});if(1===u.length)return i.extensions&&z(o,u[0],i),u[0];const d=new n.Group;i.extensions&&z(o,d,i),t.associations.set(d,{meshes:e});for(let e=0,t=u.length;e<t;e++)d.add(u[e]);return d})}loadCamera(e){let t;const s=this.json.cameras[e],r=s[s.type];if(r)return"perspective"===s.type?t=new n.PerspectiveCamera(n.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===s.type&&(t=new n.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),K(t,s),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],s=[];for(let e=0,n=t.joints.length;e<n;e++)s.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(e){const s=e.pop(),r=e,o=[],i=[];for(let e=0,a=r.length;e<a;e++){const a=r[e];if(a){o.push(a);const t=new n.Matrix4;null!==s&&t.fromArray(s.array,16*e),i.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new n.Skeleton(o,i)})}loadAnimation(e){const t=this.json,s=this,r=t.animations[e],o=r.name?r.name:"animation_"+e,i=[],a=[],l=[],c=[],u=[];for(let e=0,t=r.channels.length;e<t;e++){const t=r.channels[e],s=r.samplers[t.sampler],n=t.target,o=n.node,d=void 0!==r.parameters?r.parameters[s.input]:s.input,h=void 0!==r.parameters?r.parameters[s.output]:s.output;void 0!==n.node&&(i.push(this.getDependency("node",o)),a.push(this.getDependency("accessor",d)),l.push(this.getDependency("accessor",h)),c.push(s),u.push(n))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(u)]).then(function(e){const t=e[0],r=e[1],i=e[2],a=e[3],l=e[4],c=[];for(let e=0,n=t.length;e<n;e++){const n=t[e],o=r[e],u=i[e],d=a[e],h=l[e];if(void 0===n)continue;n.updateMatrix&&n.updateMatrix();const m=s._createAnimationTracks(n,o,u,d,h);if(m)for(let e=0;e<m.length;e++)c.push(m[e])}return new n.AnimationClip(o,void 0,c)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return void 0===n.mesh?null:s.getDependency("mesh",n.mesh).then(function(e){const t=s._getNodeRef(s.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,s=n.weights.length;t<s;t++)e.morphTargetInfluences[t]=n.weights[t]}),t})}loadNode(e){const t=this,s=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],o=s.children||[];for(let e=0,s=o.length;e<s;e++)r.push(t.getDependency("node",o[e]));const i=void 0===s.skin?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([n,Promise.all(r),i]).then(function(e){const t=e[0],s=e[1],n=e[2];null!==n&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(n,Y)});for(let e=0,n=s.length;e<n;e++)t.add(s[e]);return t})}_loadNodeShallow(e){const t=this.json,s=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const o=t.nodes[e],i=o.name?r.createUniqueName(o.name):"",a=[],l=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return l&&a.push(l),void 0!==o.camera&&a.push(r.getDependency("camera",o.camera).then(function(e){return r._getNodeRef(r.cameraCache,o.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){a.push(e)}),this.nodeCache[e]=Promise.all(a).then(function(t){let a;if(a=!0===o.isBone?new n.Bone:t.length>1?new n.Group:1===t.length?t[0]:new n.Object3D,a!==t[0])for(let e=0,s=t.length;e<s;e++)a.add(t[e]);if(o.name&&(a.userData.name=o.name,a.name=i),K(a,o),o.extensions&&z(s,a,o),void 0!==o.matrix){const e=new n.Matrix4;e.fromArray(o.matrix),a.applyMatrix4(e)}else void 0!==o.translation&&a.position.fromArray(o.translation),void 0!==o.rotation&&a.quaternion.fromArray(o.rotation),void 0!==o.scale&&a.scale.fromArray(o.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],r=this,o=new n.Group;s.name&&(o.name=r.createUniqueName(s.name)),K(o,s),s.extensions&&z(t,o,s);const i=s.nodes||[],a=[];for(let e=0,t=i.length;e<t;e++)a.push(r.getDependency("node",i[e]));return Promise.all(a).then(function(e){for(let t=0,s=e.length;t<s;t++)o.add(e[t]);return r.associations=(e=>{const t=new Map;for(const[e,s]of r.associations)(e instanceof n.Material||e instanceof n.Texture)&&t.set(e,s);return e.traverse(e=>{const s=r.associations.get(e);null!=s&&t.set(e,s)}),t})(o),o})}_createAnimationTracks(e,t,s,r,o){const i=[],a=e.name?e.name:e.uuid,l=[];let c;switch(H[o.path]===H.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(a),H[o.path]){case H.weights:c=n.NumberKeyframeTrack;break;case H.rotation:c=n.QuaternionKeyframeTrack;break;case H.position:case H.scale:c=n.VectorKeyframeTrack;break;default:c=1===s.itemSize?n.NumberKeyframeTrack:n.VectorKeyframeTrack}const u=void 0!==r.interpolation?U[r.interpolation]:n.InterpolateLinear,d=this._getArrayFromAccessor(s);for(let e=0,s=l.length;e<s;e++){const s=new c(l[e]+"."+H[o.path],t.array,d,u);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(s),i.push(s)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=W(t.constructor),s=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)s[n]=t[n]*e;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof n.QuaternionKeyframeTrack?P:C)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Q(e,t,s){const r=t.attributes,o=[];function i(t,n){return s.getDependency("accessor",t).then(function(t){e.setAttribute(n,t)})}for(const t in r){const s=D[t]||t.toLowerCase();s in e.attributes||o.push(i(r[t],s))}if(void 0!==t.indices&&!e.index){const n=s.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});o.push(n)}return n.ColorManagement.workingColorSpace!==n.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${n.ColorManagement.workingColorSpace}" not supported.`),K(e,t),function(e,t,s){const r=t.attributes,o=new n.Box3;if(void 0===r.POSITION)return;{const e=s.json.accessors[r.POSITION],t=e.min,i=e.max;if(void 0===t||void 0===i)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new n.Vector3(t[0],t[1],t[2]),new n.Vector3(i[0],i[1],i[2])),e.normalized){const t=W(O[e.componentType]);o.min.multiplyScalar(t),o.max.multiplyScalar(t)}}const i=t.targets;if(void 0!==i){const e=new n.Vector3,t=new n.Vector3;for(let n=0,r=i.length;n<r;n++){const r=i[n];if(void 0!==r.POSITION){const n=s.json.accessors[r.POSITION],o=n.min,i=n.max;if(void 0!==o&&void 0!==i){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(i[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(i[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(i[2]))),n.normalized){const e=W(O[n.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const a=new n.Sphere;o.getCenter(a.center),a.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=a}(e,t,s),Promise.all(o).then(function(){return void 0!==t.targets?function(e,t,s){let n=!1,r=!1,o=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(void 0!==s.POSITION&&(n=!0),void 0!==s.NORMAL&&(r=!0),void 0!==s.COLOR_0&&(o=!0),n&&r&&o)break}if(!n&&!r&&!o)return Promise.resolve(e);const i=[],a=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(n){const t=void 0!==u.POSITION?s.getDependency("accessor",u.POSITION):e.attributes.position;i.push(t)}if(r){const t=void 0!==u.NORMAL?s.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(o){const t=void 0!==u.COLOR_0?s.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(l)]).then(function(t){const s=t[0],i=t[1],a=t[2];return n&&(e.morphAttributes.position=s),r&&(e.morphAttributes.normal=i),o&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(e,t.targets,s):e})}},322(e,t,s){s.d(t,{E3:()=>o,RS:()=>l,ZX:()=>i,kz:()=>r,qE:()=>a});var n=s(87);function r(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function o(e,t){return"string"==typeof e?e:t}function i(e,t){if(!e||"object"!=typeof e||Array.isArray(e))return t;const s=e;return{x:r(s.x,t.x),y:r(s.y,t.y),z:r(s.z,t.z)}}function a(e,t,s){return Math.max(t,Math.min(s,e))}function l(e,t=1){return a(r(e,t),n.wD,n.I6)}},381(e,t,s){s.d(t,{c:()=>o});var n=s(87);const r=(()=>{try{return"1"===localStorage.getItem(n.Td)}catch{return!1}})();function o(...e){r&&console.log(...e)}},416(e,t,s){s.d(t,{P:()=>n});const n={en:{"ext.models.element.name":"3D Model","ext.models.element.desc":"GLB/GLTF model placed in the scene.","ext.models.tool.import":"3D model","ext.models.tool.hint":"Click to upload and place a model.","ext.models.editor.file":"File","ext.models.editor.size":"Size","ext.models.editor.preview":"Preview","ext.models.editor.scale":"Scale","ext.models.editor.play_animations":"Play model animations","ext.models.editor.height":"Height","ext.models.editor.height.floor":"Floor","ext.models.editor.height.mid":"Mid","ext.models.editor.height.ceiling":"Ceiling","ext.models.editor.uploading":"Uploading…","ext.models.editor.processing":"Processing preview…","ext.models.editor.failed":"Failed to import model","ext.models.error.pick_entry":"Pick at least one .glb or .gltf file"},"pt-BR":{"ext.models.element.name":"Modelo 3D","ext.models.element.desc":"Modelo GLB/GLTF posicionado na cena.","ext.models.tool.import":"Modelo 3D","ext.models.tool.hint":"Clique para enviar e posicionar um modelo.","ext.models.editor.file":"Arquivo","ext.models.editor.size":"Tamanho","ext.models.editor.preview":"Prévia","ext.models.editor.scale":"Escala","ext.models.editor.play_animations":"Reproduzir animações do modelo","ext.models.editor.height":"Altura","ext.models.editor.height.floor":"Chão","ext.models.editor.height.mid":"Meio","ext.models.editor.height.ceiling":"Teto","ext.models.editor.uploading":"Enviando...","ext.models.editor.processing":"Processando prévia...","ext.models.editor.failed":"Falha ao importar modelo","ext.models.error.pick_entry":"Selecione pelo menos um arquivo .glb ou .gltf"}}},650(e,t,s){s.d(t,{N:()=>c});var n=s(912),r=s(840),o=s(381),i=s(87),a=s(194);const l={id:"references",name:{key:"core.ui.tools.group.references",fallback:"References"},order:10};function c(e){return{id:i.Bf,name:{key:"ext.models.tool.import",fallback:"3D model"},description:{key:"ext.models.tool.hint",fallback:"Click to upload and place a model."},icon:"cube",group:l,order:30,createSession:t=>{const s=document.createElement("input");s.type="file",s.multiple=!0,s.accept=".glb,.gltf,.bin,.png,.jpg,.jpeg,.webp",s.style.position="fixed",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",document.body.appendChild(s);let l=null,c=!1,u=null,d="idle",h=null,m=null;const p=e.t;function f(){m?.dispatchEvent(new Event("toposync:invalidate"))}return(0,o.c)("[models:tool] session created"),s.addEventListener("change",()=>{const e=s.files?Array.from(s.files):[];if(s.value="",(0,o.c)("[models:tool] input change",{count:e.length,pendingPlacementPoint:l}),0===e.length)return d="idle",void(l=null);(async()=>{try{await async function(e){if(0===e.length)return;const s=e.find(e=>e.name.toLowerCase().endsWith(".glb"))??e.find(e=>e.name.toLowerCase().endsWith(".gltf"));if(!s)throw new Error(p("ext.models.error.pick_entry"));if(!l)throw new Error("No placement point selected");(0,o.c)("[models:tool] handleFiles",e.map(e=>({name:e.name,size:e.size,type:e.type}))),d="uploading",h=null,f(),(0,o.c)("[models:tool] uploading entry",{name:s.name});const c=await(0,r.B)(s,{filename:s.name}),u=c.dir,m=c.filename;for(const t of e)t!==s&&((0,o.c)("[models:tool] uploading asset",{dir:u,name:t.name}),await(0,r.B)(t,{dir:u,filename:t.name}));const g=(0,n.resolveToposyncUrl)(`/files/${encodeURIComponent(u)}/${encodeURIComponent(m)}`);d="processing",f(),(0,o.c)("[models:tool] generating preview",{modelUrl:g});const x=await(0,a.A_)(g),A=await(await fetch(x.dataUrl)).blob(),T=await(0,r.B)(A,{dir:u,filename:"preview.png"});(0,o.c)("[models:tool] preview uploaded",{url:T.url});const y=(0,a.Qj)(m),v=t.createElement(i._l,{name:y,position:{x:l.x,y:0,z:l.z},props:{dir:u,model:m,preview:T.filename,size:x.size,center:x.center,min_y:x.minY,scale:(0,a.Rj)(x.size),animation_enabled:!1}});v&&t.openEditor(v),(0,o.c)("[models:tool] element created",{id:v})}(e),d="idle",l=null,f()}catch(e){d="idle",h=e instanceof Error?e.message:String(e),console.error("[models:tool] import failed",e),f()}})()}),{onPointerEvent:e=>{if("cancel"===e.kind)return c=!1,u=null,void(0,o.c)("[models:tool] pointer cancel");if("down"===e.kind){if(0!==e.button)return;if("idle"!==d)return;return l=e.world,c=!0,u={x:e.screen.x,y:e.screen.y},void(0,o.c)("[models:tool] pointer down",{world:e.world,screen:e.screen})}if("move"===e.kind){if(!c||!u)return;const t=e.screen.x-u.x,s=e.screen.y-u.y;return void(t*t+s*s>16&&(c=!1,u=null))}if("up"===e.kind){if(!c)return;if(c=!1,u=null,0!==e.button)return;if("idle"!==d)return;if(!l)return;(0,o.c)("[models:tool] pointer up -> open picker",{pendingPlacementPoint:l}),s.click()}},onKeyDown:e=>{"Escape"===e.key&&(l=null,c=!1,u=null,d="idle",h=null)},renderOverlay2D:({ctx:e,viewport:t})=>{if(m=t.canvas,"idle"===d&&!h)return;const s="uploading"===d?p("ext.models.editor.uploading"):"processing"===d?p("ext.models.editor.processing"):h?`${p("ext.models.editor.failed")}: ${h}`:"";if(!s)return;e.save(),e.font="12px ui-sans-serif, system-ui",e.textBaseline="top";const n=t.width,r=e.measureText(s).width,o=Math.min(n-24,r+20),i=(n-o)/2;e.fillStyle="rgba(8,12,26,0.82)",e.strokeStyle="rgba(255,255,255,0.14)",e.lineWidth=1,function(e,t,s,n,r){const o=Math.min(999,Math.min(n,r)/2);e.beginPath(),e.moveTo(t+o,s),e.lineTo(t+n-o,s),e.quadraticCurveTo(t+n,s,t+n,s+o),e.lineTo(t+n,42-o),e.quadraticCurveTo(t+n,42,t+n-o,42),e.lineTo(t+o,42),e.quadraticCurveTo(t,42,t,42-o),e.lineTo(t,s+o),e.quadraticCurveTo(t,s,t+o,s),e.closePath()}(e,i,14,o,28),e.fill(),e.stroke(),e.fillStyle="rgba(230,232,242,0.92)",e.fillText(s,i+10,22),e.restore()},getCursor:()=>"idle"===d?"copy":"wait",dispose:()=>{(0,o.c)("[models:tool] session disposed"),s.remove()}}}}}},703(e,t,s){s.r(t),s.d(t,{activate:()=>i});var n=s(161),r=s(650),o=s(416);function i(e){e.i18n.registerTranslations(o.P),e.registerElementType((0,n.M)(e.i18n)),e.registerEditorTool((0,r.N)(e.i18n))}},840(e,t,s){s.d(t,{B:()=>o});var n=s(912),r=s(381);async function o(e,t){const s=new FormData;s.append("file",e,t.filename),t.dir&&s.append("dir",t.dir),s.append("filename",t.filename),(0,r.c)("[models:tool] POST /api/files/upload",{dir:t.dir??null,filename:t.filename,size:e.size});const o=await fetch("/api/files/upload",{method:"POST",body:s});if((0,r.c)("[models:tool] upload response",{status:o.status,ok:o.ok}),!o.ok)throw new Error(`Upload failed: ${o.status}`);const i=await o.json();return{...i,url:(0,n.resolveToposyncUrl)(i.url)}}},870(e,t,s){e.exports=s(94)}}]);
|
{toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/main.js
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see main.js.LICENSE.txt */
|
|
2
|
-
(()=>{"use strict";var e,r,t={94(e,r,t){var o=t(496);Symbol.for("react.element"),Symbol.for("react.fragment"),Object.prototype.hasOwnProperty,o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner},
|
|
2
|
+
(()=>{"use strict";var e,r,t={94(e,r,t){var o=t(496);Symbol.for("react.element"),Symbol.for("react.fragment"),Object.prototype.hasOwnProperty,o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner},433(e,r,t){t(870),t(496),t(912),(()=>{try{return"1"===localStorage.getItem("toposync.debug.models")}catch{return!1}})(),t(97)},870(e,r,t){t(94)}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.m=t,n.c=o,n.d=(e,r)=>{for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((r,t)=>(n.f[t](e,r),r),[])),n.u=e=>e+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r="@toposync/extension-models-ui:",n.l=(t,o,a,i)=>{if(e[t])e[t].push(o);else{var u,l;if(void 0!==a)for(var s=document.getElementsByTagName("script"),p=0;p<s.length;p++){var f=s[p];if(f.getAttribute("src")==t||f.getAttribute("data-webpack")==r+a){u=f;break}}u||(l=!0,(u=document.createElement("script")).charset="utf-8",n.nc&&u.setAttribute("nonce",n.nc),u.setAttribute("data-webpack",r+a),u.src=t),e[t]=[o];var c=(r,o)=>{u.onerror=u.onload=null,clearTimeout(d);var n=e[t];if(delete e[t],u.parentNode&&u.parentNode.removeChild(u),n&&n.forEach(e=>e(o)),r)return r(o)},d=setTimeout(c.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=c.bind(null,u.onerror),u.onload=c.bind(null,u.onload),l&&document.head.appendChild(u)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{n.S={};var e={},r={};n.I=(t,o)=>{o||(o=[]);var a=r[t];if(a||(a=r[t]={}),!(o.indexOf(a)>=0)){if(o.push(a),e[t])return e[t];n.o(n.S,t)||(n.S[t]={});var i=n.S[t],u="@toposync/extension-models-ui",l=(e,r,t,o)=>{var n=i[e]=i[e]||{},a=n[r];(!a||!a.loaded&&(!o!=!a.eager?o:u>a.from))&&(n[r]={get:t,from:u,eager:!!o})},s=[];return"default"===t&&(l("@toposync/plugin-api","0.3.0",()=>n.e(387).then(()=>()=>n(387))),l("react","18.3.1",()=>n.e(326).then(()=>()=>n(326))),l("three","0.167.1",()=>n.e(753).then(()=>()=>n(753)))),e[t]=s.length?Promise.all(s).then(()=>e[t]=1):1}}})(),(()=>{var e;n.g.importScripts&&(e=n.g.location+"");var r=n.g.document;if(!e&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var o=t.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=t[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),(()=>{var e=e=>{var r=e=>e.split(".").map(e=>+e==e?+e:e),t=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),o=t[1]?r(t[1]):[];return t[2]&&(o.length++,o.push.apply(o,r(t[2]))),t[3]&&(o.push([]),o.push.apply(o,r(t[3]))),o},r=e=>{var t=e[0],o="";if(1===e.length)return"*";if(t+.5){o+=0==t?">=":-1==t?"<":1==t?"^":2==t?"~":t>0?"=":"!=";for(var n=1,a=1;a<e.length;a++)n--,o+="u"==(typeof(u=e[a]))[0]?"-":(n>0?".":"")+(n=2,u);return o}var i=[];for(a=1;a<e.length;a++){var u=e[a];i.push(0===u?"not("+l()+")":1===u?"("+l()+" || "+l()+")":2===u?i.pop()+" "+i.pop():r(u))}return l();function l(){return i.pop().replace(/^\((.+)\)$/,"$1")}},t=(r,o)=>{if(0 in r){o=e(o);var n=r[0],a=n<0;a&&(n=-n-1);for(var i=0,u=1,l=!0;;u++,i++){var s,p,f=u<r.length?(typeof r[u])[0]:"";if(i>=o.length||"o"==(p=(typeof(s=o[i]))[0]))return!l||("u"==f?u>n&&!a:""==f!=a);if("u"==p){if(!l||"u"!=f)return!1}else if(l)if(f==p)if(u<=n){if(s!=r[u])return!1}else{if(a?s>r[u]:s<r[u])return!1;s!=r[u]&&(l=!1)}else if("s"!=f&&"n"!=f){if(a||u<=n)return!1;l=!1,u--}else{if(u<=n||p<f!=a)return!1;l=!1}else"s"!=f&&"n"!=f&&(l=!1,u--)}}var c=[],d=c.pop.bind(c);for(i=1;i<r.length;i++){var h=r[i];c.push(1==h?d()|d():2==h?d()&d():h?t(h,o):!d())}return!!d()},o=(e,r)=>e&&n.o(e,r),a=e=>(e.loaded=1,e.get()),i=(r,t,o)=>{var n=o?(e=>Object.keys(e).reduce((r,t)=>(e[t].eager&&(r[t]=e[t]),r),{}))(r[t]):r[t];return Object.keys(n).reduce((r,t)=>!r||!n[r].loaded&&((r,t)=>{r=e(r),t=e(t);for(var o=0;;){if(o>=r.length)return o<t.length&&"u"!=(typeof t[o])[0];var n=r[o],a=(typeof n)[0];if(o>=t.length)return"u"==a;var i=t[o],u=(typeof i)[0];if(a!=u)return"o"==a&&"n"==u||"s"==u||"u"==a;if("o"!=a&&"u"!=a&&n!=i)return n<i;o++}})(r,t)?t:r,0)},u=e=>function(r,t,o,a,i){var u=n.I(r);return u&&u.then&&!o?u.then(e.bind(e,r,n.S[r],t,!1,a,i)):e(r,n.S[r],t,o,a,i)},l=(e,r,t)=>t?t():((e,r)=>(e=>{throw new Error(e)})("Shared module "+r+" doesn't exist in shared scope "+e))(e,r),s=u((e,r,t,n,u)=>{if(!o(r,t))return l(e,t,u);var s=i(r,t,n);return a(r[t][s])}),p=u((e,n,u,s,p,f)=>{if(!o(n,u))return l(e,u,f);var c,d=i(n,u,s);return t(p,d)||(c=((e,t,o,n)=>"Unsatisfied version "+o+" from "+(o&&e[t][o].from)+" of shared singleton module "+t+" (required "+r(n)+")")(n,u,d,p),"undefined"!=typeof console&&console.warn&&console.warn(c)),a(n[u][d])}),f={},c={496:()=>s("default","react",!1,()=>n.e(326).then(()=>()=>n(326))),912:()=>p("default","@toposync/plugin-api",!1,[2,0,3,0],()=>n.e(387).then(()=>()=>n(387))),97:()=>s("default","three",!1,()=>n.e(753).then(()=>()=>n(753)))};[496,912,97].forEach(e=>{n.m[e]=r=>{f[e]=0,delete n.c[e];var t=c[e]();if("function"!=typeof t)throw new Error("Shared module is not available for eager consumption: "+e);r.exports=t()}});var d={792:[496,912,97]},h={};n.f.consumes=(e,r)=>{n.o(d,e)&&d[e].forEach(e=>{if(n.o(f,e))return r.push(f[e]);if(!h[e]){var t=r=>{f[e]=0,n.m[e]=t=>{delete n.c[e],t.exports=r()}};h[e]=!0;var o=r=>{delete f[e],n.m[e]=t=>{throw delete n.c[e],r}};try{var a=c[e]();a.then?r.push(f[e]=a.then(t).catch(o)):t(a)}catch(e){o(e)}}})}})(),(()=>{var e={792:0};n.f.j=(r,t)=>{var o=n.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var a=new Promise((t,n)=>o=e[r]=[t,n]);t.push(o[2]=a);var i=n.p+n.u(r),u=new Error;n.l(i,t=>{if(n.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var a=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;u.message="Loading chunk "+r+" failed.\n("+a+": "+i+")",u.name="ChunkLoadError",u.type=a,u.request=i,o[1](u)}},"chunk-"+r,r)}};var r=(r,t)=>{var o,a,[i,u,l]=t,s=0;if(i.some(r=>0!==e[r])){for(o in u)n.o(u,o)&&(n.m[o]=u[o]);l&&l(n)}for(r&&r(t);s<i.length;s++)a=i[s],n.o(e,a)&&e[a]&&e[a][0](),e[a]=0},t=self.webpackChunk_toposync_extension_models_ui=self.webpackChunk_toposync_extension_models_ui||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),n(433)})();
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 703.js.LICENSE.txt */
|
|
2
|
-
"use strict";(self.webpackChunk_toposync_extension_models_ui=self.webpackChunk_toposync_extension_models_ui||[]).push([[703],{94(e,t,s){var n=s(496),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,s){var n,o={},c=null,u=null;for(n in void 0!==s&&(c=""+s),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)i.call(t,n)&&!l.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:r,type:e,key:c,ref:u,props:o,_owner:a.current}}t.Fragment=o,t.jsx=c,t.jsxs=c},870(e,t,s){e.exports=s(94)},703(e,t,s){s.r(t),s.d(t,{activate:()=>i});var n=s(161),r=s(650),o=s(416);function i(e){e.i18n.registerTranslations(o.P),e.registerElementType((0,n.M)(e.i18n)),e.registerEditorTool((0,r.N)(e.i18n))}},840(e,t,s){s.d(t,{B:()=>o});var n=s(912),r=s(381);async function o(e,t){const s=new FormData;s.append("file",e,t.filename),t.dir&&s.append("dir",t.dir),s.append("filename",t.filename),(0,r.c)("[models:tool] POST /api/files/upload",{dir:t.dir??null,filename:t.filename,size:e.size});const o=await fetch("/api/files/upload",{method:"POST",body:s});if((0,r.c)("[models:tool] upload response",{status:o.status,ok:o.ok}),!o.ok)throw new Error(`Upload failed: ${o.status}`);const i=await o.json();return{...i,url:(0,n.resolveToposyncUrl)(i.url)}}},87(e,t,s){s.d(t,{Bf:()=>r,I6:()=>i,Td:()=>a,_l:()=>n,wD:()=>o});const n="com.toposync.models.gltf",r="com.toposync.models.tool.import",o=.001,i=1e3,a="toposync.debug.models"},381(e,t,s){s.d(t,{c:()=>o});var n=s(87);const r=(()=>{try{return"1"===localStorage.getItem(n.Td)}catch{return!1}})();function o(...e){r&&console.log(...e)}},161(e,t,s){s.d(t,{M:()=>d});var n=s(870),r=s(496),o=s(912),i=s(87),a=s(322),l=s(95);function c(e,t){return"boolean"==typeof e?e:t}function u(e){const t=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),s=(0,a.RS)(e.props.scale,1),n=(0,a.kz)(e.rotation?.y,0),r=t.x*s/2,o=t.z*s/2,i=Math.cos(n),l=Math.sin(n),c=[],u=[];for(const t of[{x:-r,z:-o},{x:r,z:-o},{x:r,z:o},{x:-r,z:o}])c.push(e.position.x+t.x*i-t.z*l),u.push(e.position.z+t.x*l+t.z*i);return{minX:Math.min(...c),maxX:Math.max(...c),minZ:Math.min(...u),maxZ:Math.max(...u)}}function d(e){const t=new Map;function s(e){const t=(0,a.E3)(e.props.dir,""),s=(0,a.E3)(e.props.preview,"");return t&&s?(0,o.resolveToposyncUrl)(`/files/${encodeURIComponent(t)}/${encodeURIComponent(s)}`):null}return{type:i._l,layerGroup:"objects",placeable:!1,name:{key:"ext.models.element.name",fallback:"3D Model"},description:{key:"ext.models.element.desc",fallback:"GLB/GLTF model placed in the scene."},defaultProps:{dir:"",model:"",preview:"",size:{x:1,y:1,z:1},center:{x:0,y:0,z:0},min_y:0,scale:1,animation_enabled:!1},getMain2DBounds:u,renderMain2DVector:({element:e})=>{const t=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),r=(0,a.RS)(e.props.scale,1),o=s(e),i=-180*(0,a.kz)(e.rotation?.y,0)/Math.PI,l=Math.max(.2,t.x*r),u=Math.max(.2,t.z*r),d=c(e.props.animation_enabled,!1),h=d?"rgba(56,189,248,0.42)":"rgba(226,232,240,0.22)";return(0,n.jsxs)("g",{className:"mainVector2dModel",transform:`translate(${e.position.x} ${e.position.z}) rotate(${i})`,opacity:.96,filter:"url(#mainVector2dSoftShadow)",children:[(0,n.jsx)("rect",{x:-l/2,y:-u/2,width:l,height:u,rx:.05,fill:"rgba(2,6,23,0.12)"}),o?(0,n.jsx)("image",{href:o,x:-l/2,y:-u/2,width:l,height:u,preserveAspectRatio:"none"}):(0,n.jsx)("rect",{x:-l/2,y:-u/2,width:l,height:u,rx:.05,fill:"rgba(56,189,248,0.08)"}),(0,n.jsx)("rect",{x:-l/2,y:-u/2,width:l,height:u,rx:.05,fill:"none",stroke:h,strokeWidth:.018,vectorEffect:"non-scaling-stroke"}),d?(0,n.jsx)("circle",{cx:l/2-.07,cy:-u/2+.07,r:.025,fill:"rgba(56,189,248,0.72)"}):null]})},create3D:({THREE:e,requestRender:t},s)=>{const n=(0,l.p)(e,{autoplay:!1,onInvalidate:t});return n.updateFromProps(s.props),n.setAnimated(c(s.props.animation_enabled,!1)),{object:n.object,update:e=>{n.updateFromProps(e.props),n.setAnimated(c(e.props.animation_enabled,!1))},tick:n.tick,dispose:n.dispose}},render2D:({ctx:e,element:n,viewport:r})=>{const o=(0,a.ZX)(n.props.size,{x:1,y:1,z:1}),i=(0,a.RS)(n.props.scale,1),l=s(n),c=(0,a.kz)(n.rotation?.y,0),u=r.worldToScreen({x:n.position.x,z:n.position.z}),d=Math.max(20,o.x*i*r.scale),h=Math.max(20,o.z*i*r.scale);if(e.save(),e.translate(u.x,u.y),e.rotate(-c),l){let s=t.get(l)??null;s||(s=new Image,s.decoding="async",s.onload=()=>r.canvas.dispatchEvent(new Event("toposync:invalidate")),s.onerror=()=>r.canvas.dispatchEvent(new Event("toposync:invalidate")),s.src=l,t.set(l,s)),s.complete&&s.naturalWidth>0?(e.globalAlpha=.94,e.drawImage(s,-d/2,-h/2,d,h),e.globalAlpha=1):(e.fillStyle="rgba(56,189,248,0.10)",e.fillRect(-d/2,-h/2,d,h))}else e.fillStyle="rgba(56,189,248,0.10)",e.fillRect(-d/2,-h/2,d,h);e.strokeStyle="rgba(230,232,242,0.22)",e.lineWidth=2,e.strokeRect(-d/2,-h/2,d,h),e.restore()},hitTest2D:({element:e,world:t})=>{const s=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),n=(0,a.RS)(e.props.scale,1),r=(0,a.kz)(e.rotation?.y,0),o=t.x-e.position.x,i=t.z-e.position.z,l=Math.cos(r),c=Math.sin(r),u=o*l-i*c,d=o*c+i*l;return Math.abs(u)<=s.x*n/2&&Math.abs(d)<=s.z*n/2},renderEditorModal:({element:t,update:s,remove:r,close:o})=>(0,n.jsx)(h,{element:t,update:s,remove:r,close:o,i18n:e})}}function h({element:e,update:t,remove:s,close:l,i18n:u}){const{t:d,locale:h}=u.useI18n(),m=(0,r.useMemo)(()=>new Intl.NumberFormat(h,{minimumFractionDigits:2,maximumFractionDigits:2}),[h]),p=(0,a.E3)(e.props.dir,""),f=(0,a.E3)(e.props.model,""),g=(0,a.E3)(e.props.preview,""),x=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),A=(0,a.RS)(e.props.scale,1),T=c(e.props.animation_enabled,!1),y=(0,a.kz)(e.position.y,0),v=p&&g?(0,o.resolveToposyncUrl)(`/files/${encodeURIComponent(p)}/${encodeURIComponent(g)}`):"",R=(0,r.useMemo)(()=>({x:x.x*A,y:x.y*A,z:x.z*A}),[A,x.x,x.y,x.z]);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"field",children:[(0,n.jsx)("div",{className:"label",children:d("core.element_editor.name")}),(0,n.jsx)("input",{className:"input",value:e.name,onChange:e=>t({name:e.target.value})})]}),(0,n.jsxs)("div",{className:"rowWrap",children:[(0,n.jsxs)("div",{className:"field",style:{flex:1,minWidth:180},children:[(0,n.jsx)("div",{className:"label",children:d("ext.models.editor.file")}),(0,n.jsx)("input",{className:"input",value:f||"-",readOnly:!0})]}),(0,n.jsxs)("div",{className:"field",style:{flex:1,minWidth:180},children:[(0,n.jsx)("div",{className:"label",children:d("ext.models.editor.size")}),(0,n.jsx)("input",{className:"input",value:`${m.format(R.x)} × ${m.format(R.y)} × ${m.format(R.z)} m`,readOnly:!0})]})]}),(0,n.jsx)("div",{className:"rowWrap",children:(0,n.jsxs)("div",{className:"field",style:{flex:1,minWidth:180},children:[(0,n.jsx)("div",{className:"label",children:d("ext.models.editor.scale")}),(0,n.jsx)("input",{className:"input",type:"number",inputMode:"decimal",min:i.wD,max:i.I6,step:.01,value:A,onChange:e=>{const s=Number.parseFloat(e.target.value);Number.isFinite(s)&&t({props:{scale:(0,a.qE)(s,i.wD,i.I6)}})}})]})}),(0,n.jsxs)("label",{className:"chipButton",style:{display:"inline-flex",alignItems:"center",gap:10},children:[(0,n.jsx)("input",{type:"checkbox",checked:T,onChange:e=>t({props:{animation_enabled:e.target.checked}})}),(0,n.jsx)("span",{children:d("ext.models.editor.play_animations")})]}),(0,n.jsxs)("div",{className:"field",children:[(0,n.jsxs)("div",{className:"label",children:[d("ext.models.editor.height"),": ",m.format(y)," m"]}),(0,n.jsx)("div",{className:"rowWrap",children:[{key:"floor",y:0},{key:"mid",y:1.35},{key:"ceiling",y:2.7}].map(e=>{const s=Math.abs(y-e.y)<.01;return(0,n.jsx)("button",{className:["chipButton",s?"isActive":""].join(" "),type:"button",onClick:()=>t({position:{y:e.y}}),children:d(`ext.models.editor.height.${e.key}`)},e.key)})}),(0,n.jsx)("input",{className:"input",type:"range",min:0,max:3,step:.01,value:y,onChange:e=>t({position:{y:Number(e.target.value)}})})]}),v?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"sectionDivider"}),(0,n.jsxs)("div",{className:"card",children:[(0,n.jsxs)("div",{className:"cardHeaderRow",children:[(0,n.jsx)("div",{className:"cardTitle",children:d("ext.models.editor.preview")}),(0,n.jsx)("div",{className:"cardMeta",children:p})]}),(0,n.jsx)("div",{className:"cardBody",children:(0,n.jsx)("img",{src:v,alt:d("ext.models.editor.preview"),style:{width:"100%",borderRadius:12,border:"1px solid rgba(255,255,255,0.10)"}})})]})]}):null,(0,n.jsx)("div",{className:"sectionDivider"}),(0,n.jsxs)("div",{className:"rowWrap",children:[(0,n.jsx)("button",{className:"dangerButton",type:"button",onClick:s,children:d("core.actions.delete")}),(0,n.jsx)("button",{className:"chipButton",type:"button",onClick:l,children:d("core.actions.close")})]})]})}},322(e,t,s){s.d(t,{E3:()=>o,RS:()=>l,ZX:()=>i,kz:()=>r,qE:()=>a});var n=s(87);function r(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function o(e,t){return"string"==typeof e?e:t}function i(e,t){if(!e||"object"!=typeof e||Array.isArray(e))return t;const s=e;return{x:r(s.x,t.x),y:r(s.y,t.y),z:r(s.z,t.z)}}function a(e,t,s){return Math.max(t,Math.min(s,e))}function l(e,t=1){return a(r(e,t),n.wD,n.I6)}},194(e,t,s){s.d(t,{A_:()=>c,Qj:()=>a,Rj:()=>l});var n=s(97),r=s(320),o=s(87),i=s(322);function a(e){const t=e.lastIndexOf(".");return t<=0?e:e.slice(0,t)}function l(e){const t=Math.max(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z));return!Number.isFinite(t)||t<=1e-6?1:t>3?(0,i.qE)(1/t,o.wD,o.I6):t<.25?(0,i.qE)(.25/t,o.wD,o.I6):1}async function c(e,t){const s=Math.max(128,Math.min(1024,t?.renderSize??640)),o=(0,i.qE)(t?.paddingRatio??.08,0,.5),a=new r.B,l=await a.loadAsync(e),c=l.scene||l.scenes?.[0];if(!c)throw new Error("Empty model");const u=c.clone(!0);u.updateMatrixWorld(!0);const d=(new n.Box3).setFromObject(u),h=d.getSize(new n.Vector3),m=d.getCenter(new n.Vector3),p=d.min.y;if(!Number.isFinite(h.x)||!Number.isFinite(h.y)||!Number.isFinite(h.z)||h.length()<1e-6)throw new Error("Could not compute model size");u.position.sub(new n.Vector3(m.x,p,m.z));const f=Math.max(h.x,1e-6),g=Math.max(h.z,1e-6),x=f*(1+2*o),A=g*(1+2*o),T=s/Math.max(x,A),y=Math.max(64,Math.round(x*T)),v=Math.max(64,Math.round(A*T)),R=function(e,t){const s=new n.OrthographicCamera(-e/2,e/2,t/2,-t/2,.01,8*Math.max(e,t));return s.position.set(0,Math.max(e,t),0),s.up.set(0,0,-1),s.lookAt(new n.Vector3(0,0,0)),s}(x||1,A||1),M=function(e,t){const s=new n.WebGLRenderer({antialias:!0,alpha:!0,preserveDrawingBuffer:!0});return s.setPixelRatio(1),s.setSize(e,t,!1),s.setClearColor(0,0),s.outputColorSpace=n.SRGBColorSpace,s}(y,v),w=new n.Scene;!function(e){const t=new n.HemisphereLight(16777215,2236979,.9);e.add(t);const s=new n.DirectionalLight(16777215,.8);s.position.set(3,6,3),s.castShadow=!1,e.add(s)}(w),w.add(u),M.render(w,R);const E=f/Math.max(x,1e-9),_=g/Math.max(A,1e-9),b=Math.max(1,Math.min(y,Math.round(y*E))),S=Math.max(1,Math.min(v,Math.round(v*_))),L=Math.max(0,Math.min(y-b,Math.round((y-b)/2))),I=Math.max(0,Math.min(v-S,Math.round((v-S)/2)));let C=y,N=v,P="";if(b!==y||S!==v){const e=document.createElement("canvas");e.width=b,e.height=S;const t=e.getContext("2d");t&&(t.drawImage(M.domElement,L,I,b,S,0,0,b,S),P=e.toDataURL("image/png"),C=b,N=S)}P||(P=M.domElement.toDataURL("image/png"));try{M.dispose()}catch{}return{dataUrl:P,widthPx:C,heightPx:N,size:{x:h.x,y:h.y,z:h.z},center:{x:m.x,y:m.y,z:m.z},minY:p}}},95(e,t,s){s.d(t,{p:()=>i});var n=s(320),r=s(912),o=s(322);function i(e,t){const s=new e.Group,i=new e.BoxGeometry(1,1,1),a=new e.MeshBasicMaterial({color:3718648,wireframe:!0,transparent:!0,opacity:.22,depthWrite:!1}),l=new e.Mesh(i,a);l.visible=!1,s.add(l);const c=new n.B;let u=!1,d=0,h="",m=null,p=null,f=[],g=!1,x=Boolean(t?.autoplay);function A(e){const t=e,s=["map","alphaMap","aoMap","bumpMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","displacementMap","emissiveMap","envMap","iridescenceMap","iridescenceThicknessMap","lightMap","metalnessMap","normalMap","roughnessMap","sheenColorMap","sheenRoughnessMap","specularColorMap","specularIntensityMap","thicknessMap","transmissionMap"];for(const e of s){const s=t[e];s&&s.isTexture&&"function"==typeof s.dispose&&s.dispose()}e.dispose()}function T(e){e.traverse(e=>{const t=e;t.geometry?.dispose&&t.geometry.dispose();const s=t.material;Array.isArray(s)?s.forEach(e=>e&&A(e)):s&&A(s)})}function y(){if(p){try{p.stopAllAction()}catch{}if(m)try{p.uncacheRoot(m)}catch{}p=null,f=[],g=!1}}function v(){p&&(x?function(){if(p)for(const e of f)try{e.reset(),e.play()}catch{}}():function(){if(p){for(const e of f)try{e.stop()}catch{}try{p.setTime(0)}catch{}}}())}return{object:s,updateFromProps:function(n){const i=n&&"object"==typeof n&&!Array.isArray(n)?n:{},a=(0,o.E3)(i.dir,""),x=(0,o.E3)(i.model,""),A=(0,o.RS)(i.scale,1),R=(0,o.ZX)(i.size,{x:1,y:1,z:1}),M=(0,o.ZX)(i.center,{x:0,y:0,z:0}),w=(0,o.kz)(i.min_y,0);s.scale.setScalar(A),l.scale.set(Math.max(.05,Math.abs(R.x)),Math.max(.05,Math.abs(R.y)),Math.max(.05,Math.abs(R.z))),l.position.y=l.scale.y/2;const E=a&&x?(0,r.resolveToposyncUrl)(`/files/${encodeURIComponent(a)}/${encodeURIComponent(x)}`):"";if(!E)return h="",l.visible=!1,void(m&&(s.remove(m),y(),T(m),m=null));E&&E!==h&&(h=E,l.visible=!m,async function(n,r){const o=++d;try{const i=await c.loadAsync(n);if(u||o!==d)return;const a=i.scene||i.scenes?.[0];if(!a)throw new Error("Empty model");a.traverse(e=>{const t=e;t.isMesh&&(t.castShadow=!0,t.receiveShadow=!0)});const h=(new e.Box3).setFromObject(a),x=h.getCenter(new e.Vector3),A=h.min.y,R=r?.center??{x:x.x,y:x.y,z:x.z},M=r?.minY??A;a.position.sub(new e.Vector3(R.x,M,R.z)),m&&(s.remove(m),y(),T(m),m=null),m=a,s.add(a),l.visible=!1,Array.isArray(i.animations)&&i.animations.length>0?(p=new e.AnimationMixer(a),f=i.animations.map(e=>p.clipAction(e)),g=f.length>0,v()):y(),t?.onInvalidate?.()}catch(e){console.error("[models:gltfModel]",e),t?.onInvalidate?.()}}(E,{center:M,minY:w}))},setAnimated:function(e){e!==x&&(x=e,v())},tick:e=>!(!x||!p||(p?.update(e),0)),dispose:()=>{u=!0,y(),m&&T(m),i.dispose(),a.dispose()},getHasAnimations:()=>g}}},650(e,t,s){s.d(t,{N:()=>c});var n=s(912),r=s(840),o=s(381),i=s(87),a=s(194);const l={id:"references",name:{key:"core.ui.tools.group.references",fallback:"References"},order:10};function c(e){return{id:i.Bf,name:{key:"ext.models.tool.import",fallback:"3D model"},description:{key:"ext.models.tool.hint",fallback:"Click to upload and place a model."},icon:"cube",group:l,order:30,createSession:t=>{const s=document.createElement("input");s.type="file",s.multiple=!0,s.accept=".glb,.gltf,.bin,.png,.jpg,.jpeg,.webp",s.style.position="fixed",s.style.left="-9999px",s.style.width="1px",s.style.height="1px",document.body.appendChild(s);let l=null,c=!1,u=null,d="idle",h=null,m=null;const p=e.t;function f(){m?.dispatchEvent(new Event("toposync:invalidate"))}return(0,o.c)("[models:tool] session created"),s.addEventListener("change",()=>{const e=s.files?Array.from(s.files):[];if(s.value="",(0,o.c)("[models:tool] input change",{count:e.length,pendingPlacementPoint:l}),0===e.length)return d="idle",void(l=null);(async()=>{try{await async function(e){if(0===e.length)return;const s=e.find(e=>e.name.toLowerCase().endsWith(".glb"))??e.find(e=>e.name.toLowerCase().endsWith(".gltf"));if(!s)throw new Error(p("ext.models.error.pick_entry"));if(!l)throw new Error("No placement point selected");(0,o.c)("[models:tool] handleFiles",e.map(e=>({name:e.name,size:e.size,type:e.type}))),d="uploading",h=null,f(),(0,o.c)("[models:tool] uploading entry",{name:s.name});const c=await(0,r.B)(s,{filename:s.name}),u=c.dir,m=c.filename;for(const t of e)t!==s&&((0,o.c)("[models:tool] uploading asset",{dir:u,name:t.name}),await(0,r.B)(t,{dir:u,filename:t.name}));const g=(0,n.resolveToposyncUrl)(`/files/${encodeURIComponent(u)}/${encodeURIComponent(m)}`);d="processing",f(),(0,o.c)("[models:tool] generating preview",{modelUrl:g});const x=await(0,a.A_)(g),A=await(await fetch(x.dataUrl)).blob(),T=await(0,r.B)(A,{dir:u,filename:"preview.png"});(0,o.c)("[models:tool] preview uploaded",{url:T.url});const y=(0,a.Qj)(m),v=t.createElement(i._l,{name:y,position:{x:l.x,y:0,z:l.z},props:{dir:u,model:m,preview:T.filename,size:x.size,center:x.center,min_y:x.minY,scale:(0,a.Rj)(x.size),animation_enabled:!1}});v&&t.openEditor(v),(0,o.c)("[models:tool] element created",{id:v})}(e),d="idle",l=null,f()}catch(e){d="idle",h=e instanceof Error?e.message:String(e),console.error("[models:tool] import failed",e),f()}})()}),{onPointerEvent:e=>{if("cancel"===e.kind)return c=!1,u=null,void(0,o.c)("[models:tool] pointer cancel");if("down"===e.kind){if(0!==e.button)return;if("idle"!==d)return;return l=e.world,c=!0,u={x:e.screen.x,y:e.screen.y},void(0,o.c)("[models:tool] pointer down",{world:e.world,screen:e.screen})}if("move"===e.kind){if(!c||!u)return;const t=e.screen.x-u.x,s=e.screen.y-u.y;return void(t*t+s*s>16&&(c=!1,u=null))}if("up"===e.kind){if(!c)return;if(c=!1,u=null,0!==e.button)return;if("idle"!==d)return;if(!l)return;(0,o.c)("[models:tool] pointer up -> open picker",{pendingPlacementPoint:l}),s.click()}},onKeyDown:e=>{"Escape"===e.key&&(l=null,c=!1,u=null,d="idle",h=null)},renderOverlay2D:({ctx:e,viewport:t})=>{if(m=t.canvas,"idle"===d&&!h)return;const s="uploading"===d?p("ext.models.editor.uploading"):"processing"===d?p("ext.models.editor.processing"):h?`${p("ext.models.editor.failed")}: ${h}`:"";if(!s)return;e.save(),e.font="12px ui-sans-serif, system-ui",e.textBaseline="top";const n=t.width,r=e.measureText(s).width,o=Math.min(n-24,r+20),i=(n-o)/2;e.fillStyle="rgba(8,12,26,0.82)",e.strokeStyle="rgba(255,255,255,0.14)",e.lineWidth=1,function(e,t,s,n,r){const o=Math.min(999,Math.min(n,r)/2);e.beginPath(),e.moveTo(t+o,s),e.lineTo(t+n-o,s),e.quadraticCurveTo(t+n,s,t+n,s+o),e.lineTo(t+n,42-o),e.quadraticCurveTo(t+n,42,t+n-o,42),e.lineTo(t+o,42),e.quadraticCurveTo(t,42,t,42-o),e.lineTo(t,s+o),e.quadraticCurveTo(t,s,t+o,s),e.closePath()}(e,i,14,o,28),e.fill(),e.stroke(),e.fillStyle="rgba(230,232,242,0.92)",e.fillText(s,i+10,22),e.restore()},getCursor:()=>"idle"===d?"copy":"wait",dispose:()=>{(0,o.c)("[models:tool] session disposed"),s.remove()}}}}}},416(e,t,s){s.d(t,{P:()=>n});const n={en:{"ext.models.element.name":"3D Model","ext.models.element.desc":"GLB/GLTF model placed in the scene.","ext.models.tool.import":"3D model","ext.models.tool.hint":"Click to upload and place a model.","ext.models.editor.file":"File","ext.models.editor.size":"Size","ext.models.editor.preview":"Preview","ext.models.editor.scale":"Scale","ext.models.editor.play_animations":"Play model animations","ext.models.editor.height":"Height","ext.models.editor.height.floor":"Floor","ext.models.editor.height.mid":"Mid","ext.models.editor.height.ceiling":"Ceiling","ext.models.editor.uploading":"Uploading…","ext.models.editor.processing":"Processing preview…","ext.models.editor.failed":"Failed to import model","ext.models.error.pick_entry":"Pick at least one .glb or .gltf file"},"pt-BR":{"ext.models.element.name":"Modelo 3D","ext.models.element.desc":"Modelo GLB/GLTF posicionado na cena.","ext.models.tool.import":"Modelo 3D","ext.models.tool.hint":"Clique para enviar e posicionar um modelo.","ext.models.editor.file":"Arquivo","ext.models.editor.size":"Tamanho","ext.models.editor.preview":"Prévia","ext.models.editor.scale":"Escala","ext.models.editor.play_animations":"Reproduzir animações do modelo","ext.models.editor.height":"Altura","ext.models.editor.height.floor":"Chão","ext.models.editor.height.mid":"Meio","ext.models.editor.height.ceiling":"Teto","ext.models.editor.uploading":"Enviando...","ext.models.editor.processing":"Processando prévia...","ext.models.editor.failed":"Falha ao importar modelo","ext.models.error.pick_entry":"Selecione pelo menos um arquivo .glb ou .gltf"}}},320(e,t,s){s.d(t,{B:()=>o});var n=s(97);function r(e,t){if(t===n.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===n.TriangleFanDrawMode||t===n.TriangleStripDrawMode){let s=e.getIndex();if(null===s){const t=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),s=e.getIndex()}const r=s.count-2,o=[];if(t===n.TriangleFanDrawMode)for(let e=1;e<=r;e++)o.push(s.getX(0)),o.push(s.getX(e)),o.push(s.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(o.push(s.getX(e)),o.push(s.getX(e+1)),o.push(s.getX(e+2))):(o.push(s.getX(e+2)),o.push(s.getX(e+1)),o.push(s.getX(e)));o.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=e.clone();return i.setIndex(o),i.clearGroups(),i}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class o extends n.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new d(e)}),this.register(function(e){return new h(e)}),this.register(function(e){return new v(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new M(e)}),this.register(function(e){return new p(e)}),this.register(function(e){return new f(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new u(e)}),this.register(function(e){return new A(e)}),this.register(function(e){return new m(e)}),this.register(function(e){return new y(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new l(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new E(e)})}load(e,t,s,r){const o=this;let i;if(""!==this.resourcePath)i=this.resourcePath;else if(""!==this.path){const t=n.LoaderUtils.extractUrlBase(e);i=n.LoaderUtils.resolveURL(t,this.path)}else i=n.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),o.manager.itemError(e),o.manager.itemEnd(e)},l=new n.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(s){try{o.parse(s,i,function(s){t(s),o.manager.itemEnd(e)},a)}catch(e){a(e)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let r;const o={},i={},l=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===_){try{o[a.KHR_BINARY_GLTF]=new b(e)}catch(e){return void(n&&n(e))}r=JSON.parse(o[a.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new $(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](u);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),i[t.name]=t,o[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],s=r.extensionsRequired||[];switch(t){case a.KHR_MATERIALS_UNLIT:o[t]=new c;break;case a.KHR_DRACO_MESH_COMPRESSION:o[t]=new S(r,this.dracoLoader);break;case a.KHR_TEXTURE_TRANSFORM:o[t]=new L;break;case a.KHR_MESH_QUANTIZATION:o[t]=new I;break;default:s.indexOf(t)>=0&&void 0===i[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}u.setExtensions(o),u.setPlugins(i),u.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,r){s.parse(e,t,n,r)})}}function i(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const a={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class l{constructor(e){this.parser=e,this.name=a.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let r=t.cache.get(s);if(r)return r;const o=t.json,i=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let a;const l=new n.Color(16777215);void 0!==i.color&&l.setRGB(i.color[0],i.color[1],i.color[2],n.LinearSRGBColorSpace);const c=void 0!==i.range?i.range:0;switch(i.type){case"directional":a=new n.DirectionalLight(l),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new n.PointLight(l),a.distance=c;break;case"spot":a=new n.SpotLight(l),a.distance=c,i.spot=i.spot||{},i.spot.innerConeAngle=void 0!==i.spot.innerConeAngle?i.spot.innerConeAngle:0,i.spot.outerConeAngle=void 0!==i.spot.outerConeAngle?i.spot.outerConeAngle:Math.PI/4,a.angle=i.spot.outerConeAngle,a.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return a.position.set(0,0,0),a.decay=2,K(a,i),void 0!==i.intensity&&(a.intensity=i.intensity),a.name=t.createUniqueName(i.name||"light_"+e),r=Promise.resolve(a),t.cache.add(s,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,n=s.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then(function(e){return s._getNodeRef(t.cache,r,e)})}}class c{constructor(){this.name=a.KHR_MATERIALS_UNLIT}getMaterialType(){return n.MeshBasicMaterial}extendParams(e,t,s){const r=[];e.color=new n.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const t=o.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],n.LinearSRGBColorSpace),e.opacity=t[3]}void 0!==o.baseColorTexture&&r.push(s.assignTexture(e,"map",o.baseColorTexture,n.SRGBColorSpace))}return Promise.all(r)}}class u{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class d{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&o.push(s.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&o.push(s.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(o.push(s.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new n.Vector2(e,e)}return Promise.all(o)}}class h{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class m{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&r.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(t.iridescenceIOR=o.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&r.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class p{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new n.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=r.extensions[this.name];if(void 0!==i.sheenColorFactor){const e=i.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],n.LinearSRGBColorSpace)}return void 0!==i.sheenRoughnessFactor&&(t.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&o.push(s.assignTexture(t,"sheenColorMap",i.sheenColorTexture,n.SRGBColorSpace)),void 0!==i.sheenRoughnessTexture&&o.push(s.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(o)}}class f{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&r.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class g{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&o.push(s.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=(new n.Color).setRGB(a[0],a[1],a[2],n.LinearSRGBColorSpace),Promise.all(o)}}class x{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class A{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&o.push(s.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=(new n.Color).setRGB(a[0],a[1],a[2],n.LinearSRGBColorSpace),void 0!==i.specularColorTexture&&o.push(s.assignTexture(t,"specularColorMap",i.specularColorTexture,n.SRGBColorSpace)),Promise.all(o)}}class T{constructor(e){this.parser=e,this.name=a.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return t.bumpScale=void 0!==o.bumpFactor?o.bumpFactor:1,void 0!==o.bumpTexture&&r.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}}class y{constructor(e){this.parser=e,this.name=a.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?n.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return void 0!==o.anisotropyStrength&&(t.anisotropy=o.anisotropyStrength),void 0!==o.anisotropyRotation&&(t.anisotropyRotation=o.anisotropyRotation),void 0!==o.anisotropyTexture&&r.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}}class v{constructor(e){this.parser=e,this.name=a.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class R{constructor(e){this.parser=e,this.name=a.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],i=n.images[o.source];let a=s.textureLoader;if(i.uri){const e=s.options.manager.getHandler(i.uri);null!==e&&(a=e)}return this.detectSupport().then(function(r){if(r)return s.loadTextureImage(e,o.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class M{constructor(e){this.parser=e,this.name=a.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],i=n.images[o.source];let a=s.textureLoader;if(i.uri){const e=s.options.manager.getHandler(i.uri);null!==e&&(a=e)}return this.detectSupport().then(function(r){if(r)return s.loadTextureImage(e,o.source,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class w{constructor(e){this.name=a.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(t){const s=e.byteOffset||0,n=e.byteLength||0,o=e.count,i=e.byteStride,a=new Uint8Array(t,s,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(o,i,a,e.mode,e.filter).then(function(e){return e.buffer}):r.ready.then(function(){const t=new ArrayBuffer(o*i);return r.decodeGltfBuffer(new Uint8Array(t),o,i,a,e.mode,e.filter),t})})}return null}}class E{constructor(e){this.name=a.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||void 0===s.mesh)return null;const r=t.meshes[s.mesh];for(const e of r.primitives)if(e.mode!==k.TRIANGLES&&e.mode!==k.TRIANGLE_STRIP&&e.mode!==k.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=s.extensions[this.name].attributes,i=[],a={};for(const e in o)i.push(this.parser.getDependency("accessor",o[e]).then(t=>(a[e]=t,a[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{const t=e.pop(),s=t.isGroup?t.children:[t],r=e[0].count,o=[];for(const e of s){const t=new n.Matrix4,s=new n.Vector3,i=new n.Quaternion,l=new n.Vector3(1,1,1),c=new n.InstancedMesh(e.geometry,e.material,r);for(let e=0;e<r;e++)a.TRANSLATION&&s.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&i.fromBufferAttribute(a.ROTATION,e),a.SCALE&&l.fromBufferAttribute(a.SCALE,e),c.setMatrixAt(e,t.compose(s,i,l));for(const t in a)if("_COLOR_0"===t){const e=a[t];c.instanceColor=new n.InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,a[t]);n.Object3D.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),o.push(c)}return t.isGroup?(t.clear(),t.add(...o),t):o[0]}))}}const _="glTF";class b{constructor(e){this.name=a.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==_)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let o=0;for(;o<n;){const t=r.getUint32(o,!0);o+=4;const n=r.getUint32(o,!0);if(o+=4,1313821514===n){const n=new Uint8Array(e,12+o,t);this.content=s.decode(n)}else if(5130562===n){const s=12+o;this.body=e.slice(s,s+t)}o+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class S{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=a.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},l={},c={};for(const e in i){const t=D[e]||e.toLowerCase();a[t]=i[e]}for(const t in e.attributes){const n=D[t]||t.toLowerCase();if(void 0!==i[t]){const r=s.accessors[e.attributes[t]],o=O[r.componentType];c[n]=o.name,l[n]=!0===r.normalized}}return t.getDependency("bufferView",o).then(function(e){return new Promise(function(t,s){r.decodeDracoFile(e,function(e){for(const t in e.attributes){const s=e.attributes[t],n=l[t];void 0!==n&&(s.normalized=n)}t(e)},a,c,n.LinearSRGBColorSpace,s)})})}}class L{constructor(){this.name=a.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class I{constructor(){this.name=a.KHR_MESH_QUANTIZATION}}class C extends n.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=s[r+e];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,o=this.sampleValues,i=this.valueSize,a=2*i,l=3*i,c=n-t,u=(s-t)/c,d=u*u,h=d*u,m=e*l,p=m-l,f=-2*h+3*d,g=h-d,x=1-f,A=g-d+u;for(let e=0;e!==i;e++){const t=o[p+e+i],s=o[p+e+a]*c,n=o[m+e+i],l=o[m+e]*c;r[e]=x*t+A*s+f*n+g*l}return r}}const N=new n.Quaternion;class P extends C{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return N.fromArray(r).normalize().toArray(r),r}}const k={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},O={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},F={9728:n.NearestFilter,9729:n.LinearFilter,9984:n.NearestMipmapNearestFilter,9985:n.LinearMipmapNearestFilter,9986:n.NearestMipmapLinearFilter,9987:n.LinearMipmapLinearFilter},B={33071:n.ClampToEdgeWrapping,33648:n.MirroredRepeatWrapping,10497:n.RepeatWrapping},j={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},D={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},U={CUBICSPLINE:void 0,LINEAR:n.InterpolateLinear,STEP:n.InterpolateDiscrete};function G(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new n.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:n.FrontSide})),e.DefaultMaterial}function z(e,t,s){for(const n in s.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=s.extensions[n])}function K(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function V(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,n=t.weights.length;s<n;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,n=s.length;t<n;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function X(e){let t;const s=e.extensions&&e.extensions[a.KHR_DRACO_MESH_COMPRESSION];if(t=s?"draco:"+s.bufferView+":"+s.indices+":"+q(s.attributes):e.indices+":"+q(e.attributes)+":"+e.mode,void 0!==e.targets)for(let s=0,n=e.targets.length;s<n;s++)t+=":"+q(e.targets[s]);return t}function q(e){let t="";const s=Object.keys(e).sort();for(let n=0,r=s.length;n<r;n++)t+=s[n]+":"+e[s[n]]+";";return t}function W(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const Y=new n.Matrix4;class ${constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new i,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,r=-1,o=!1,a=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;s=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);r=s&&t?parseInt(t[1],10):-1,o=e.indexOf("Firefox")>-1,a=o?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||s&&r<17||o&&a<98?this.textureLoader=new n.TextureLoader(this.options.manager):this.textureLoader=new n.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new n.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(t){const o={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:s,userData:{}};return z(r,o,n),K(o,n),Promise.all(s._invokeAll(function(e){return e.afterRoot&&e.afterRoot(o)})).then(function(){for(const e of o.scenes)e.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s].joints;for(let t=0,s=n.length;t<s;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(s[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),r=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,n]of e.children.entries())r(n,t.children[s])};return r(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&s.push(r)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":n=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e)}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map(function(t,n){return s.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[a.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(e,o){s.load(n.LoaderUtils.resolveURL(t.uri,r.path),e,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const s=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+s)})}loadAccessor(e){const t=this,s=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=j[r.type],t=O[r.componentType],s=!0===r.normalized,o=new t(r.count*e);return Promise.resolve(new n.BufferAttribute(o,e,s))}const o=[];return void 0!==r.bufferView?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),void 0!==r.sparse&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(e){const o=e[0],i=j[r.type],a=O[r.componentType],l=a.BYTES_PER_ELEMENT,c=l*i,u=r.byteOffset||0,d=void 0!==r.bufferView?s.bufferViews[r.bufferView].byteStride:void 0,h=!0===r.normalized;let m,p;if(d&&d!==c){const e=Math.floor(u/d),s="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let c=t.cache.get(s);c||(m=new a(o,e*d,r.count*d/l),c=new n.InterleavedBuffer(m,d/l),t.cache.add(s,c)),p=new n.InterleavedBufferAttribute(c,i,u%d/l,h)}else m=null===o?new a(r.count*i):new a(o,u,r.count*i),p=new n.BufferAttribute(m,i,h);if(void 0!==r.sparse){const t=j.SCALAR,s=O[r.sparse.indices.componentType],l=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,u=new s(e[1],l,r.sparse.count*t),d=new a(e[2],c,r.sparse.count*i);null!==o&&(p=new n.BufferAttribute(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=u.length;e<t;e++){const t=u[e];if(p.setX(t,d[e*i]),i>=2&&p.setY(t,d[e*i+1]),i>=3&&p.setZ(t,d[e*i+2]),i>=4&&p.setW(t,d[e*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p})}loadTexture(e){const t=this.json,s=this.options,n=t.textures[e].source,r=t.images[n];let o=this.textureLoader;if(r.uri){const e=s.manager.getHandler(r.uri);null!==e&&(o=e)}return this.loadTextureImage(e,n,o)}loadTextureImage(e,t,s){const r=this,o=this.json,i=o.textures[e],a=o.images[t],l=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,s).then(function(t){t.flipY=!1,t.name=i.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const s=(o.samplers||{})[i.sampler]||{};return t.magFilter=F[s.magFilter]||n.LinearFilter,t.minFilter=F[s.minFilter]||n.LinearMipmapLinearFilter,t.wrapS=B[s.wrapS]||n.RepeatWrapping,t.wrapT=B[s.wrapT]||n.RepeatWrapping,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const s=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const o=s.images[e],i=self.URL||self.webkitURL;let a=o.uri||"",l=!1;if(void 0!==o.bufferView)a=this.getDependency("bufferView",o.bufferView).then(function(e){l=!0;const t=new Blob([e],{type:o.mimeType});return a=i.createObjectURL(t),a});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then(function(e){return new Promise(function(s,o){let i=s;!0===t.isImageBitmapLoader&&(i=function(e){const t=new n.Texture(e);t.needsUpdate=!0,s(t)}),t.load(n.LoaderUtils.resolveURL(e,r.path),i,void 0,o)})}).then(function(e){var t;return!0===l&&i.revokeObjectURL(a),K(e,o),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=c,c}assignTexture(e,t,s,n){const r=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((o=o.clone()).channel=s.texCoord),r.extensions[a.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[a.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(o);o=r.extensions[a.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),r.associations.set(o,t)}}return void 0!==n&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const r=void 0===t.attributes.tangent,o=void 0!==t.attributes.color,i=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new n.PointsMaterial,n.Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new n.LineBasicMaterial,n.Material.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,this.cache.add(e,t)),s=t}if(r||o||i){let e="ClonedMaterial:"+s.uuid+":";r&&(e+="derivative-tangents:"),o&&(e+="vertex-colors:"),i&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),o&&(t.vertexColors=!0),i&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}e.material=s}getMaterialType(){return n.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,r=this.extensions,o=s.materials[e];let i;const l={},c=[];if((o.extensions||{})[a.KHR_MATERIALS_UNLIT]){const e=r[a.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),c.push(e.extendParams(l,o,t))}else{const s=o.pbrMetallicRoughness||{};if(l.color=new n.Color(1,1,1),l.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;l.color.setRGB(e[0],e[1],e[2],n.LinearSRGBColorSpace),l.opacity=e[3]}void 0!==s.baseColorTexture&&c.push(t.assignTexture(l,"map",s.baseColorTexture,n.SRGBColorSpace)),l.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,l.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(c.push(t.assignTexture(l,"metalnessMap",s.metallicRoughnessTexture)),c.push(t.assignTexture(l,"roughnessMap",s.metallicRoughnessTexture))),i=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,l)})))}!0===o.doubleSided&&(l.side=n.DoubleSide);const u=o.alphaMode||"OPAQUE";if("BLEND"===u?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,"MASK"===u&&(l.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&i!==n.MeshBasicMaterial&&(c.push(t.assignTexture(l,"normalMap",o.normalTexture)),l.normalScale=new n.Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;l.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&i!==n.MeshBasicMaterial&&(c.push(t.assignTexture(l,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(l.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&i!==n.MeshBasicMaterial){const e=o.emissiveFactor;l.emissive=(new n.Color).setRGB(e[0],e[1],e[2],n.LinearSRGBColorSpace)}return void 0!==o.emissiveTexture&&i!==n.MeshBasicMaterial&&c.push(t.assignTexture(l,"emissiveMap",o.emissiveTexture,n.SRGBColorSpace)),Promise.all(c).then(function(){const s=new i(l);return o.name&&(s.name=o.name),K(s,o),t.associations.set(s,{materials:e}),o.extensions&&z(r,s,o),s})}createUniqueName(e){const t=n.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,r=this.primitiveCache;function o(e){return s[a.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(s){return Q(s,e,t)})}const i=[];for(let s=0,l=e.length;s<l;s++){const l=e[s],c=X(l),u=r[c];if(u)i.push(u.promise);else{let e;e=l.extensions&&l.extensions[a.KHR_DRACO_MESH_COMPRESSION]?o(l):Q(new n.BufferGeometry,l,t),r[c]={primitive:l,promise:e},i.push(e)}}return Promise.all(i)}loadMesh(e){const t=this,s=this.json,o=this.extensions,i=s.meshes[e],a=i.primitives,l=[];for(let e=0,t=a.length;e<t;e++){const t=void 0===a[e].material?G(this.cache):this.getDependency("material",a[e].material);l.push(t)}return l.push(t.loadGeometries(a)),Promise.all(l).then(function(s){const l=s.slice(0,s.length-1),c=s[s.length-1],u=[];for(let s=0,d=c.length;s<d;s++){const d=c[s],h=a[s];let m;const p=l[s];if(h.mode===k.TRIANGLES||h.mode===k.TRIANGLE_STRIP||h.mode===k.TRIANGLE_FAN||void 0===h.mode)m=!0===i.isSkinnedMesh?new n.SkinnedMesh(d,p):new n.Mesh(d,p),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),h.mode===k.TRIANGLE_STRIP?m.geometry=r(m.geometry,n.TriangleStripDrawMode):h.mode===k.TRIANGLE_FAN&&(m.geometry=r(m.geometry,n.TriangleFanDrawMode));else if(h.mode===k.LINES)m=new n.LineSegments(d,p);else if(h.mode===k.LINE_STRIP)m=new n.Line(d,p);else if(h.mode===k.LINE_LOOP)m=new n.LineLoop(d,p);else{if(h.mode!==k.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);m=new n.Points(d,p)}Object.keys(m.geometry.morphAttributes).length>0&&V(m,i),m.name=t.createUniqueName(i.name||"mesh_"+e),K(m,i),h.extensions&&z(o,m,h),t.assignFinalMaterial(m),u.push(m)}for(let s=0,n=u.length;s<n;s++)t.associations.set(u[s],{meshes:e,primitives:s});if(1===u.length)return i.extensions&&z(o,u[0],i),u[0];const d=new n.Group;i.extensions&&z(o,d,i),t.associations.set(d,{meshes:e});for(let e=0,t=u.length;e<t;e++)d.add(u[e]);return d})}loadCamera(e){let t;const s=this.json.cameras[e],r=s[s.type];if(r)return"perspective"===s.type?t=new n.PerspectiveCamera(n.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===s.type&&(t=new n.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),K(t,s),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],s=[];for(let e=0,n=t.joints.length;e<n;e++)s.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(e){const s=e.pop(),r=e,o=[],i=[];for(let e=0,a=r.length;e<a;e++){const a=r[e];if(a){o.push(a);const t=new n.Matrix4;null!==s&&t.fromArray(s.array,16*e),i.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new n.Skeleton(o,i)})}loadAnimation(e){const t=this.json,s=this,r=t.animations[e],o=r.name?r.name:"animation_"+e,i=[],a=[],l=[],c=[],u=[];for(let e=0,t=r.channels.length;e<t;e++){const t=r.channels[e],s=r.samplers[t.sampler],n=t.target,o=n.node,d=void 0!==r.parameters?r.parameters[s.input]:s.input,h=void 0!==r.parameters?r.parameters[s.output]:s.output;void 0!==n.node&&(i.push(this.getDependency("node",o)),a.push(this.getDependency("accessor",d)),l.push(this.getDependency("accessor",h)),c.push(s),u.push(n))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(u)]).then(function(e){const t=e[0],r=e[1],i=e[2],a=e[3],l=e[4],c=[];for(let e=0,n=t.length;e<n;e++){const n=t[e],o=r[e],u=i[e],d=a[e],h=l[e];if(void 0===n)continue;n.updateMatrix&&n.updateMatrix();const m=s._createAnimationTracks(n,o,u,d,h);if(m)for(let e=0;e<m.length;e++)c.push(m[e])}return new n.AnimationClip(o,void 0,c)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return void 0===n.mesh?null:s.getDependency("mesh",n.mesh).then(function(e){const t=s._getNodeRef(s.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,s=n.weights.length;t<s;t++)e.morphTargetInfluences[t]=n.weights[t]}),t})}loadNode(e){const t=this,s=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],o=s.children||[];for(let e=0,s=o.length;e<s;e++)r.push(t.getDependency("node",o[e]));const i=void 0===s.skin?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([n,Promise.all(r),i]).then(function(e){const t=e[0],s=e[1],n=e[2];null!==n&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(n,Y)});for(let e=0,n=s.length;e<n;e++)t.add(s[e]);return t})}_loadNodeShallow(e){const t=this.json,s=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const o=t.nodes[e],i=o.name?r.createUniqueName(o.name):"",a=[],l=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return l&&a.push(l),void 0!==o.camera&&a.push(r.getDependency("camera",o.camera).then(function(e){return r._getNodeRef(r.cameraCache,o.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){a.push(e)}),this.nodeCache[e]=Promise.all(a).then(function(t){let a;if(a=!0===o.isBone?new n.Bone:t.length>1?new n.Group:1===t.length?t[0]:new n.Object3D,a!==t[0])for(let e=0,s=t.length;e<s;e++)a.add(t[e]);if(o.name&&(a.userData.name=o.name,a.name=i),K(a,o),o.extensions&&z(s,a,o),void 0!==o.matrix){const e=new n.Matrix4;e.fromArray(o.matrix),a.applyMatrix4(e)}else void 0!==o.translation&&a.position.fromArray(o.translation),void 0!==o.rotation&&a.quaternion.fromArray(o.rotation),void 0!==o.scale&&a.scale.fromArray(o.scale);return r.associations.has(a)||r.associations.set(a,{}),r.associations.get(a).nodes=e,a}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],r=this,o=new n.Group;s.name&&(o.name=r.createUniqueName(s.name)),K(o,s),s.extensions&&z(t,o,s);const i=s.nodes||[],a=[];for(let e=0,t=i.length;e<t;e++)a.push(r.getDependency("node",i[e]));return Promise.all(a).then(function(e){for(let t=0,s=e.length;t<s;t++)o.add(e[t]);return r.associations=(e=>{const t=new Map;for(const[e,s]of r.associations)(e instanceof n.Material||e instanceof n.Texture)&&t.set(e,s);return e.traverse(e=>{const s=r.associations.get(e);null!=s&&t.set(e,s)}),t})(o),o})}_createAnimationTracks(e,t,s,r,o){const i=[],a=e.name?e.name:e.uuid,l=[];let c;switch(H[o.path]===H.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(a),H[o.path]){case H.weights:c=n.NumberKeyframeTrack;break;case H.rotation:c=n.QuaternionKeyframeTrack;break;case H.position:case H.scale:c=n.VectorKeyframeTrack;break;default:c=1===s.itemSize?n.NumberKeyframeTrack:n.VectorKeyframeTrack}const u=void 0!==r.interpolation?U[r.interpolation]:n.InterpolateLinear,d=this._getArrayFromAccessor(s);for(let e=0,s=l.length;e<s;e++){const s=new c(l[e]+"."+H[o.path],t.array,d,u);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(s),i.push(s)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=W(t.constructor),s=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)s[n]=t[n]*e;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof n.QuaternionKeyframeTrack?P:C)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Q(e,t,s){const r=t.attributes,o=[];function i(t,n){return s.getDependency("accessor",t).then(function(t){e.setAttribute(n,t)})}for(const t in r){const s=D[t]||t.toLowerCase();s in e.attributes||o.push(i(r[t],s))}if(void 0!==t.indices&&!e.index){const n=s.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});o.push(n)}return n.ColorManagement.workingColorSpace!==n.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${n.ColorManagement.workingColorSpace}" not supported.`),K(e,t),function(e,t,s){const r=t.attributes,o=new n.Box3;if(void 0===r.POSITION)return;{const e=s.json.accessors[r.POSITION],t=e.min,i=e.max;if(void 0===t||void 0===i)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new n.Vector3(t[0],t[1],t[2]),new n.Vector3(i[0],i[1],i[2])),e.normalized){const t=W(O[e.componentType]);o.min.multiplyScalar(t),o.max.multiplyScalar(t)}}const i=t.targets;if(void 0!==i){const e=new n.Vector3,t=new n.Vector3;for(let n=0,r=i.length;n<r;n++){const r=i[n];if(void 0!==r.POSITION){const n=s.json.accessors[r.POSITION],o=n.min,i=n.max;if(void 0!==o&&void 0!==i){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(i[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(i[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(i[2]))),n.normalized){const e=W(O[n.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const a=new n.Sphere;o.getCenter(a.center),a.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=a}(e,t,s),Promise.all(o).then(function(){return void 0!==t.targets?function(e,t,s){let n=!1,r=!1,o=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(void 0!==s.POSITION&&(n=!0),void 0!==s.NORMAL&&(r=!0),void 0!==s.COLOR_0&&(o=!0),n&&r&&o)break}if(!n&&!r&&!o)return Promise.resolve(e);const i=[],a=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(n){const t=void 0!==u.POSITION?s.getDependency("accessor",u.POSITION):e.attributes.position;i.push(t)}if(r){const t=void 0!==u.NORMAL?s.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(o){const t=void 0!==u.COLOR_0?s.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(l)]).then(function(t){const s=t[0],i=t[1],a=t[2];return n&&(e.morphAttributes.position=s),r&&(e.morphAttributes.normal=i),o&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(e,t.targets,s):e})}}}]);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/extension.json
RENAMED
|
File without changes
|
|
File without changes
|
{toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/326.js
RENAMED
|
File without changes
|
|
File without changes
|
{toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/387.js
RENAMED
|
File without changes
|
|
File without changes
|
{toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/src/toposync_ext_models/static/753.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{toposync_ext_models-0.2.2 → toposync_ext_models-0.4.0}/ui/src/elements/ModelElementType.tsx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|