toposync-ext-models 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,4 @@
1
+ __all__ = ["__version__"]
2
+
3
+ __version__ = "0.1.0"
4
+
@@ -0,0 +1,13 @@
1
+ {
2
+ "schema_version": 1,
3
+ "id": "com.toposync.models",
4
+ "name": "Models",
5
+ "version": "0.1.0",
6
+ "frontend": {
7
+ "kind": "module-federation",
8
+ "remote_entry": "remoteEntry.js",
9
+ "scope": "models",
10
+ "module": "./activate"
11
+ }
12
+ }
13
+
@@ -0,0 +1,16 @@
1
+ from __future__ import annotations
2
+
3
+ from fastapi import FastAPI
4
+
5
+ from toposync.extensions import BaseExtension
6
+ from toposync.runtime.event_bus import EventBus
7
+ from toposync.runtime.services import ServiceRegistry
8
+
9
+
10
+ class ModelsExtension(BaseExtension):
11
+ def __init__(self) -> None:
12
+ super().__init__(package="toposync_ext_models")
13
+
14
+ async def setup(self, app: FastAPI, *, bus: EventBus, services: ServiceRegistry) -> None: # noqa: ARG002
15
+ return None
16
+
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 326.js.LICENSE.txt */
2
+ "use strict";(self.webpackChunk_toposync_extension_models_ui=self.webpackChunk_toposync_extension_models_ui||[]).push([[326],{249(e,t){var r=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),i=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),y=Symbol.iterator,d={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,h={};function m(e,t,r){this.props=e,this.context=t,this.refs=h,this.updater=r||d}function b(){}function v(e,t,r){this.props=e,this.context=t,this.refs=h,this.updater=r||d}m.prototype.isReactComponent={},m.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},m.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=m.prototype;var S=v.prototype=new b;S.constructor=v,_(S,m.prototype),S.isPureReactComponent=!0;var k=Array.isArray,w=Object.prototype.hasOwnProperty,E={current:null},$={key:!0,ref:!0,__self:!0,__source:!0};function R(e,t,n){var o,u={},c=null,a=null;if(null!=t)for(o in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(c=""+t.key),t)w.call(t,o)&&!$.hasOwnProperty(o)&&(u[o]=t[o]);var i=arguments.length-2;if(1===i)u.children=n;else if(1<i){for(var f=Array(i),s=0;s<i;s++)f[s]=arguments[s+2];u.children=f}if(e&&e.defaultProps)for(o in i=e.defaultProps)void 0===u[o]&&(u[o]=i[o]);return{$$typeof:r,type:e,key:c,ref:a,props:u,_owner:E.current}}function C(e){return"object"==typeof e&&null!==e&&e.$$typeof===r}var g=/\/+/g;function j(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function x(e,t,o,u,c){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var i=!1;if(null===e)i=!0;else switch(a){case"string":case"number":i=!0;break;case"object":switch(e.$$typeof){case r:case n:i=!0}}if(i)return c=c(i=e),e=""===u?"."+j(i,0):u,k(c)?(o="",null!=e&&(o=e.replace(g,"$&/")+"/"),x(c,t,o,"",function(e){return e})):null!=c&&(C(c)&&(c=function(e,t){return{$$typeof:r,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(c,o+(!c.key||i&&i.key===c.key?"":(""+c.key).replace(g,"$&/")+"/")+e)),t.push(c)),1;if(i=0,u=""===u?".":u+":",k(e))for(var f=0;f<e.length;f++){var s=u+j(a=e[f],f);i+=x(a,t,o,s,c)}else if(s=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=y&&e[y]||e["@@iterator"])?e:null}(e),"function"==typeof s)for(e=s.call(e),f=0;!(a=e.next()).done;)i+=x(a=a.value,t,o,s=u+j(a,f++),c);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return i}function O(e,t,r){if(null==e)return e;var n=[],o=0;return x(e,n,"","",function(e){return t.call(r,e,o++)}),n}function P(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var I={current:null},T={transition:null},V={ReactCurrentDispatcher:I,ReactCurrentBatchConfig:T,ReactCurrentOwner:E};function A(){throw Error("act(...) is not supported in production builds of React.")}t.Children={map:O,forEach:function(e,t,r){O(e,function(){t.apply(this,arguments)},r)},count:function(e){var t=0;return O(e,function(){t++}),t},toArray:function(e){return O(e,function(e){return e})||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=m,t.Fragment=o,t.Profiler=c,t.PureComponent=v,t.StrictMode=u,t.Suspense=s,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,t.act=A,t.cloneElement=function(e,t,n){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var o=_({},e.props),u=e.key,c=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(c=t.ref,a=E.current),void 0!==t.key&&(u=""+t.key),e.type&&e.type.defaultProps)var i=e.type.defaultProps;for(f in t)w.call(t,f)&&!$.hasOwnProperty(f)&&(o[f]=void 0===t[f]&&void 0!==i?i[f]:t[f])}var f=arguments.length-2;if(1===f)o.children=n;else if(1<f){i=Array(f);for(var s=0;s<f;s++)i[s]=arguments[s+2];o.children=i}return{$$typeof:r,type:e.type,key:u,ref:c,props:o,_owner:a}},t.createContext=function(e){return(e={$$typeof:i,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=R,t.createFactory=function(e){var t=R.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:f,render:e}},t.isValidElement=C,t.lazy=function(e){return{$$typeof:p,_payload:{_status:-1,_result:e},_init:P}},t.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=T.transition;T.transition={};try{e()}finally{T.transition=t}},t.unstable_act=A,t.useCallback=function(e,t){return I.current.useCallback(e,t)},t.useContext=function(e){return I.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return I.current.useDeferredValue(e)},t.useEffect=function(e,t){return I.current.useEffect(e,t)},t.useId=function(){return I.current.useId()},t.useImperativeHandle=function(e,t,r){return I.current.useImperativeHandle(e,t,r)},t.useInsertionEffect=function(e,t){return I.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return I.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return I.current.useMemo(e,t)},t.useReducer=function(e,t,r){return I.current.useReducer(e,t,r)},t.useRef=function(e){return I.current.useRef(e)},t.useState=function(e){return I.current.useState(e)},t.useSyncExternalStore=function(e,t,r){return I.current.useSyncExternalStore(e,t,r)},t.useTransition=function(){return I.current.useTransition()},t.version="18.3.1"},326(e,t,r){e.exports=r(249)}}]);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_toposync_extension_models_ui=self.webpackChunk_toposync_extension_models_ui||[]).push([[387],{387(t){function n(){return"undefined"==typeof window?"/":function(t){const n=String(t||"").trim();return n&&(n.startsWith("/")?n:`/${n}`).replace(/\/+$/,"")||"/"}(window.__TOPOSYNC_PUBLIC_BASE_PATH__)}function e(t){const e=n();return t.startsWith("/")?"/"===e||t===e||t.startsWith(`${e}/`)?t:`${e}${t}`:t}t.exports={getToposyncBasePath:n,resolveToposyncUrl:function(t){const n=String(t||"");if(!n)return n;if("undefined"==typeof window)return n;if(/^(data:|blob:|mailto:|tel:|#)/i.test(n))return n;if(n.startsWith("//"))return n;if(/^[a-z][a-z0-9+.-]*:/i.test(n))try{const t=new URL(n,window.location.href);return t.origin!==window.location.origin?n:e(`${t.pathname}${t.search}${t.hash}`)}catch{return n}return n.startsWith("/")?e(n):n}}}}]);
@@ -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 n.B;let a=!1,l=0,c="",u=null,d=null,h=[],m=!1,p=Boolean(t?.autoplay);function f(e){e.traverse(e=>{const t=e;t.geometry?.dispose&&t.geometry.dispose();const s=t.material;Array.isArray(s)?s.forEach(e=>e?.dispose?.()):s?.dispose?.()})}function g(){if(d){try{d.stopAllAction()}catch{}if(u)try{d.uncacheRoot(u)}catch{}d=null,h=[],m=!1}}function x(){d&&(p?function(){if(d)for(const e of h)try{e.reset(),e.play()}catch{}}():function(){if(d){for(const e of h)try{e.stop()}catch{}try{d.setTime(0)}catch{}}}())}return{object:s,updateFromProps:function(t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:{},p=(0,o.E3)(n.dir,""),A=(0,o.E3)(n.model,""),T=(0,o.RS)(n.scale,1),y=(0,o.ZX)(n.center,{x:0,y:0,z:0}),v=(0,o.kz)(n.min_y,0);s.scale.setScalar(T);const R=p&&A?(0,r.resolveToposyncUrl)(`/files/${encodeURIComponent(p)}/${encodeURIComponent(A)}`):"";if(!R)return c="",void(u&&(s.remove(u),g(),f(u),u=null));R&&R!==c&&(c=R,async function(t,n){const r=++l;try{const o=await i.loadAsync(t);if(a||r!==l)return;const c=o.scene||o.scenes?.[0];if(!c)throw new Error("Empty model");c.traverse(e=>{const t=e;t.isMesh&&(t.castShadow=!0,t.receiveShadow=!0)});const p=(new e.Box3).setFromObject(c),A=p.getCenter(new e.Vector3),T=p.min.y,y=n?.center??{x:A.x,y:A.y,z:A.z},v=n?.minY??T;c.position.sub(new e.Vector3(y.x,v,y.z)),u&&(s.remove(u),g(),f(u),u=null),u=c,s.add(c),Array.isArray(o.animations)&&o.animations.length>0?(d=new e.AnimationMixer(c),h=o.animations.map(e=>d.clipAction(e)),m=h.length>0,x()):g()}catch(e){console.error("[models:gltfModel]",e)}}(R,{center:y,minY:v}))},setAnimated:function(e){e!==p&&(p=e,x())},tick:e=>{p&&d?.update(e)},dispose:()=>{a=!0,g(),u&&f(u)},getHasAnimations:()=>m}}},161(e,t,s){s.d(t,{M:()=>c});var n=s(870),r=s(496),o=s(912),i=s(87),a=s(322),l=s(95);function c(e){const t=new Map;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},create3D:({THREE:e},t)=>{const s=(0,l.p)(e,{autoplay:!0});return s.updateFromProps(t.props),s.setAnimated(!0),{object:s.object,update:e=>s.updateFromProps(e.props),tick:s.tick,dispose:s.dispose}},render2D:({ctx:e,element:s,viewport:n})=>{const r=(0,a.ZX)(s.props.size,{x:1,y:1,z:1}),i=(0,a.RS)(s.props.scale,1),l=function(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}(s),c=(0,a.kz)(s.rotation?.y,0),u=n.worldToScreen({x:s.position.x,z:s.position.z}),d=Math.max(20,r.x*i*n.scale),h=Math.max(20,r.z*i*n.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=()=>n.canvas.dispatchEvent(new Event("toposync:invalidate")),s.onerror=()=>n.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)(u,{element:t,update:s,remove:r,close:o,i18n:e})}}function u({element:e,update:t,remove:s,close:l,i18n:c}){const{t:u,locale:d}=c.useI18n(),h=(0,r.useMemo)(()=>new Intl.NumberFormat(d,{minimumFractionDigits:2,maximumFractionDigits:2}),[d]),m=(0,a.E3)(e.props.dir,""),p=(0,a.E3)(e.props.model,""),f=(0,a.E3)(e.props.preview,""),g=(0,a.ZX)(e.props.size,{x:1,y:1,z:1}),x=(0,a.RS)(e.props.scale,1),A=(0,a.kz)(e.position.y,0),T=m&&f?(0,o.resolveToposyncUrl)(`/files/${encodeURIComponent(m)}/${encodeURIComponent(f)}`):"",y=(0,r.useMemo)(()=>({x:g.x*x,y:g.y*x,z:g.z*x}),[x,g.x,g.y,g.z]);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"field",children:[(0,n.jsx)("div",{className:"label",children:u("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:u("ext.models.editor.file")}),(0,n.jsx)("input",{className:"input",value:p||"-",readOnly:!0})]}),(0,n.jsxs)("div",{className:"field",style:{flex:1,minWidth:180},children:[(0,n.jsx)("div",{className:"label",children:u("ext.models.editor.size")}),(0,n.jsx)("input",{className:"input",value:`${h.format(y.x)} × ${h.format(y.y)} × ${h.format(y.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:u("ext.models.editor.scale")}),(0,n.jsx)("input",{className:"input",type:"number",inputMode:"decimal",min:i.wD,max:i.I6,step:.01,value:x,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)("div",{className:"field",children:[(0,n.jsxs)("div",{className:"label",children:[u("ext.models.editor.height"),": ",h.format(A)," 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(A-e.y)<.01;return(0,n.jsx)("button",{className:["chipButton",s?"isActive":""].join(" "),type:"button",onClick:()=>t({position:{y:e.y}}),children:u(`ext.models.editor.height.${e.key}`)},e.key)})}),(0,n.jsx)("input",{className:"input",type:"range",min:0,max:3,step:.01,value:A,onChange:e=>t({position:{y:Number(e.target.value)}})})]}),T?(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:u("ext.models.editor.preview")}),(0,n.jsx)("div",{className:"cardMeta",children:m})]}),(0,n.jsx)("div",{className:"cardBody",children:(0,n.jsx)("img",{src:T,alt:u("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:u("core.actions.delete")}),(0,n.jsx)("button",{className:"chipButton",type:"button",onClick:l,children:u("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),w=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),E=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)}(E),E.add(u),w.render(E,R);const M=f/Math.max(x,1e-9),_=g/Math.max(A,1e-9),S=Math.max(1,Math.min(y,Math.round(y*M))),b=Math.max(1,Math.min(v,Math.round(v*_))),L=Math.max(0,Math.min(y-S,Math.round((y-S)/2))),I=Math.max(0,Math.min(v-b,Math.round((v-b)/2)));let C=y,N=v,P="";if(S!==y||b!==v){const e=document.createElement("canvas");e.width=S,e.height=b;const t=e.getContext("2d");t&&(t.drawImage(w.domElement,L,I,S,b,0,0,S,b),P=e.toDataURL("image/png"),C=S,N=b)}P||(P=w.domElement.toDataURL("image/png"));try{w.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 w(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 E(e)}),this.register(function(e){return new M(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 S(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 Q(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 b(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 w{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 E{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 M{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!==O.TRIANGLES&&e.mode!==O.TRIANGLE_STRIP&&e.mode!==O.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 S{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 b{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=H[e]||e.toLowerCase();a[t]=i[e]}for(const t in e.attributes){const n=H[t]||t.toLowerCase();if(void 0!==i[t]){const r=s.accessors[e.attributes[t]],o=k[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 O={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},k={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},D={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},H={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"},j={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 Q{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=D[r.type],t=k[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=D[r.type],a=k[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=D.SCALAR,s=k[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 $(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):$(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===O.TRIANGLES||h.mode===O.TRIANGLE_STRIP||h.mode===O.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===O.TRIANGLE_STRIP?m.geometry=r(m.geometry,n.TriangleStripDrawMode):h.mode===O.TRIANGLE_FAN&&(m.geometry=r(m.geometry,n.TriangleFanDrawMode));else if(h.mode===O.LINES)m=new n.LineSegments(d,p);else if(h.mode===O.LINE_STRIP)m=new n.Line(d,p);else if(h.mode===O.LINE_LOOP)m=new n.LineLoop(d,p);else{if(h.mode!==O.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(j[o.path]===j.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(a),j[o.path]){case j.weights:c=n.NumberKeyframeTrack;break;case j.rotation:c=n.QuaternionKeyframeTrack;break;case j.position:case j.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]+"."+j[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 $(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=H[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(k[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(k[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":"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.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":"Importar 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.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:()=>l});var n=s(912),r=s(840),o=s(381),i=s(87),a=s(194);function l(e){return{id:i.Bf,name:{key:"ext.models.tool.import",fallback:"Import 3D model"},description:{key:"ext.models.tool.hint",fallback:"Click to upload and place a model."},icon:"cube",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)}});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)}}]);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */