threedviewer 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -4
- package/dist/SimpleViewerWrapper.d.ts +24 -0
- package/dist/core/ViewerCore.d.ts +114 -0
- package/dist/core/entities/ViewerState.d.ts +44 -0
- package/dist/core/events/ViewerEvents.d.ts +49 -0
- package/dist/core/interfaces/ICamera.d.ts +27 -0
- package/dist/core/interfaces/IControls.d.ts +38 -0
- package/dist/core/interfaces/IModelLoader.d.ts +46 -0
- package/dist/core/interfaces/IObject3D.d.ts +36 -0
- package/dist/core/interfaces/IRenderer.d.ts +44 -0
- package/dist/core/interfaces/IRendererExtension.d.ts +15 -0
- package/dist/core/interfaces/IScene.d.ts +36 -0
- package/dist/core/interfaces/index.d.ts +7 -0
- package/dist/core/services/IEnvironmentService.d.ts +34 -0
- package/dist/core/services/IFloorAlignmentService.d.ts +11 -0
- package/dist/core/services/IPathTracingService.d.ts +81 -0
- package/dist/core/services/ISceneSetupService.d.ts +79 -0
- package/dist/core/utils/MemoryMonitor.d.ts +31 -0
- package/dist/core/utils/RenderLoopManager.d.ts +65 -0
- package/dist/core/utils/SceneSerializer.d.ts +41 -0
- package/dist/defaultOptions.d.ts +4 -1
- package/dist/errors/ErrorCode.d.ts +9 -0
- package/dist/errors/ThreeViewerError.d.ts +1 -1
- package/dist/events/EventEmitter.d.ts +9 -1
- package/dist/events/ViewerEvents.d.ts +11 -4
- package/dist/index.d.ts +1 -1
- package/dist/infrastructure/converters/RendererOptionsConverter.d.ts +6 -0
- package/dist/infrastructure/factories/ViewerFactory.d.ts +20 -0
- package/dist/{ThreeSceneSetup/HexGrid → infrastructure/three}/HexTile.d.ts +1 -1
- package/dist/infrastructure/three/HexTileConfig.d.ts +41 -0
- package/dist/infrastructure/three/ThreeCamera.d.ts +57 -0
- package/dist/infrastructure/three/ThreeControls.d.ts +75 -0
- package/dist/infrastructure/three/ThreeEnvironmentService.d.ts +17 -0
- package/dist/infrastructure/three/ThreeFloorAlignmentService.d.ts +6 -0
- package/dist/infrastructure/three/ThreeModelLoader.d.ts +20 -0
- package/dist/infrastructure/three/ThreeObject3D.d.ts +29 -0
- package/dist/infrastructure/three/ThreePathTracingService.d.ts +68 -0
- package/dist/infrastructure/three/ThreeRenderer.d.ts +29 -0
- package/dist/infrastructure/three/ThreeScene.d.ts +30 -0
- package/dist/infrastructure/three/ThreeSceneSetupService.d.ts +13 -0
- package/dist/infrastructure/three/ThreeVector3.d.ts +24 -0
- package/dist/infrastructure/three/index.d.ts +11 -0
- package/dist/infrastructure/three/types/PathTracerTypes.d.ts +42 -0
- package/dist/infrastructure/types/ExtendedTypes.d.ts +77 -0
- package/dist/presentation/adapters/EventAdapter.d.ts +41 -0
- package/dist/presentation/components/PerformanceMonitor.d.ts +5 -0
- package/dist/presentation/components/SimpleViewer.d.ts +7 -0
- package/dist/presentation/components/ViewerCanvas.d.ts +4 -0
- package/dist/presentation/components/ViewerContext.d.ts +20 -0
- package/dist/presentation/components/ViewerErrorBoundary.d.ts +19 -0
- package/dist/presentation/components/ViewerGizmo.d.ts +12 -0
- package/dist/presentation/hooks/index.d.ts +5 -0
- package/dist/presentation/hooks/useDebounce.d.ts +7 -0
- package/dist/presentation/hooks/useStableOptions.d.ts +6 -0
- package/dist/presentation/hooks/useViewerCore.d.ts +11 -0
- package/dist/presentation/hooks/useViewerEvents.d.ts +12 -0
- package/dist/presentation/hooks/useViewerState.d.ts +18 -0
- package/dist/simple-viewer.es.js +14248 -15250
- package/dist/simple-viewer.umd.js +135 -178
- package/dist/testUtils/testDefaultOptions.d.ts +7 -0
- package/dist/types/CommonTypes.d.ts +59 -0
- package/dist/types/SimpleViewerOptions.d.ts +2 -36
- package/dist/types/options/HelperOptions.d.ts +0 -5
- package/dist/types/options/RenderingOptions.d.ts +25 -0
- package/dist/types/options/index.d.ts +1 -0
- package/dist/types.d.ts +6 -120
- package/dist/validation/OptionsValidator.d.ts +2 -2
- package/package.json +9 -2
- package/dist/Resizer.d.ts +0 -5
- package/dist/SimpleViewer.d.ts +0 -20
- package/dist/ThreeSceneSetup/SceneInitializer.d.ts +0 -18
- package/dist/ThreeSceneSetup/addHelpers.d.ts +0 -3
- package/dist/ThreeSceneSetup/addLighting.d.ts +0 -3
- package/dist/ThreeSceneSetup/cleanupScene.d.ts +0 -3
- package/dist/ThreeSceneSetup/constants.d.ts +0 -1
- package/dist/ThreeSceneSetup/createGradientBackground.d.ts +0 -2
- package/dist/ThreeSceneSetup/fitCameraToObject.d.ts +0 -2
- package/dist/ThreeSceneSetup/get2DContext.d.ts +0 -1
- package/dist/ThreeSceneSetup/importRaytracer.d.ts +0 -7
- package/dist/ThreeSceneSetup/initializeScene.d.ts +0 -3
- package/dist/ThreeSceneSetup/setupScene/AnimationManager.d.ts +0 -24
- package/dist/ThreeSceneSetup/setupScene/CameraManager.d.ts +0 -9
- package/dist/ThreeSceneSetup/setupScene/ControlsManager.d.ts +0 -14
- package/dist/ThreeSceneSetup/setupScene/EnvironmentMapManager.d.ts +0 -32
- package/dist/ThreeSceneSetup/setupScene/PathTracingManager.d.ts +0 -25
- package/dist/ThreeSceneSetup/setupScene/RendererManager.d.ts +0 -11
- package/dist/ThreeSceneSetup/setupScene/SceneManager.d.ts +0 -28
- package/dist/ThreeSceneSetup/setupScene/initializeCamera.d.ts +0 -3
- package/dist/ThreeSceneSetup/setupScene/initializeRenderer.d.ts +0 -3
- package/dist/ThreeSceneSetup/types.d.ts +0 -8
- package/dist/ThreeSceneSetup/updateSize.d.ts +0 -3
- package/dist/loadModel.d.ts +0 -3
- package/dist/utils/deprecation.d.ts +0 -15
- package/dist/utils/optionsMapper.d.ts +0 -11
- package/dist/utils.d.ts +0 -1
- /package/dist/{FloorAligner.d.ts → infrastructure/three/FloorAligner.d.ts} +0 -0
- /package/dist/{ThreeSceneSetup/HexGrid → infrastructure/three}/HexGrid.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(wt,ae){typeof exports=="object"&&typeof module<"u"?ae(exports,require("react"),require("three")):typeof define=="function"&&define.amd?define(["exports","react","three"],ae):(wt=typeof globalThis<"u"?globalThis:wt||self,ae(wt.SimpleViewer={},wt.React,wt.THREE))})(this,function(wt,ae,f){"use strict";function Ao(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const C=Ao(f);var hn={exports:{}},Nr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Vi;function Mo(){if(Vi)return Nr;Vi=1;var s=ae,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,n=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(a,c,u){var d,h={},l=null,v=null;u!==void 0&&(l=""+u),c.key!==void 0&&(l=""+c.key),c.ref!==void 0&&(v=c.ref);for(d in c)r.call(c,d)&&!o.hasOwnProperty(d)&&(h[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)h[d]===void 0&&(h[d]=c[d]);return{$$typeof:e,type:a,key:l,ref:v,props:h,_owner:n.current}}return Nr.Fragment=t,Nr.jsx=i,Nr.jsxs=i,Nr}var kr={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,49 +14,20 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
|
|
17
|
+
*/var Gi;function Io(){return Gi||(Gi=1,process.env.NODE_ENV!=="production"&&function(){var s=ae,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),b=Symbol.iterator,T="@@iterator";function g(m){if(m===null||typeof m!="object")return null;var I=b&&m[b]||m[T];return typeof I=="function"?I:null}var x=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(m){{for(var I=arguments.length,N=new Array(I>1?I-1:0),Z=1;Z<I;Z++)N[Z-1]=arguments[Z];S("error",m,N)}}function S(m,I,N){{var Z=x.ReactDebugCurrentFrame,ie=Z.getStackAddendum();ie!==""&&(I+="%s",N=N.concat([ie]));var oe=N.map(function(Q){return String(Q)});oe.unshift("Warning: "+I),Function.prototype.apply.call(console[m],console,oe)}}var A=!1,P=!1,D=!1,F=!1,O=!1,L;L=Symbol.for("react.module.reference");function E(m){return!!(typeof m=="string"||typeof m=="function"||m===r||m===o||O||m===n||m===u||m===d||F||m===v||A||P||D||typeof m=="object"&&m!==null&&(m.$$typeof===l||m.$$typeof===h||m.$$typeof===i||m.$$typeof===a||m.$$typeof===c||m.$$typeof===L||m.getModuleId!==void 0))}function V(m,I,N){var Z=m.displayName;if(Z)return Z;var ie=I.displayName||I.name||"";return ie!==""?N+"("+ie+")":N}function z(m){return m.displayName||"Context"}function G(m){if(m==null)return null;if(typeof m.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof m=="function")return m.displayName||m.name||null;if(typeof m=="string")return m;switch(m){case r:return"Fragment";case t:return"Portal";case o:return"Profiler";case n:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof m=="object")switch(m.$$typeof){case a:var I=m;return z(I)+".Consumer";case i:var N=m;return z(N._context)+".Provider";case c:return V(m,m.render,"ForwardRef");case h:var Z=m.displayName||null;return Z!==null?Z:G(m.type)||"Memo";case l:{var ie=m,oe=ie._payload,Q=ie._init;try{return G(Q(oe))}catch{return null}}}return null}var U=Object.assign,H=0,ne,ge,Pe,ve,ye,Ue,_e;function Se(){}Se.__reactDisabledLog=!0;function et(){{if(H===0){ne=console.log,ge=console.info,Pe=console.warn,ve=console.error,ye=console.group,Ue=console.groupCollapsed,_e=console.groupEnd;var m={configurable:!0,enumerable:!0,value:Se,writable:!0};Object.defineProperties(console,{info:m,log:m,warn:m,error:m,group:m,groupCollapsed:m,groupEnd:m})}H++}}function ut(){{if(H--,H===0){var m={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:U({},m,{value:ne}),info:U({},m,{value:ge}),warn:U({},m,{value:Pe}),error:U({},m,{value:ve}),group:U({},m,{value:ye}),groupCollapsed:U({},m,{value:Ue}),groupEnd:U({},m,{value:_e})})}H<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=x.ReactCurrentDispatcher,ze;function ke(m,I,N){{if(ze===void 0)try{throw Error()}catch(ie){var Z=ie.stack.trim().match(/\n( *(at )?)/);ze=Z&&Z[1]||""}return`
|
|
18
|
+
`+ze+m}}var ht=!1,tt;{var Pt=typeof WeakMap=="function"?WeakMap:Map;tt=new Pt}function _t(m,I){if(!m||ht)return"";{var N=tt.get(m);if(N!==void 0)return N}var Z;ht=!0;var ie=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var oe;oe=de.current,de.current=null,et();try{if(I){var Q=function(){throw Error()};if(Object.defineProperty(Q.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Q,[])}catch(B){Z=B}Reflect.construct(m,[],Q)}else{try{Q.call()}catch(B){Z=B}m.call(Q.prototype)}}else{try{throw Error()}catch(B){Z=B}m()}}catch(B){if(B&&Z&&typeof B.stack=="string"){for(var $=B.stack.split(`
|
|
19
|
+
`),p=Z.stack.split(`
|
|
20
|
+
`),y=$.length-1,_=p.length-1;y>=1&&_>=0&&$[y]!==p[_];)_--;for(;y>=1&&_>=0;y--,_--)if($[y]!==p[_]){if(y!==1||_!==1)do if(y--,_--,_<0||$[y]!==p[_]){var M=`
|
|
21
|
+
`+$[y].replace(" at new "," at ");return m.displayName&&M.includes("<anonymous>")&&(M=M.replace("<anonymous>",m.displayName)),typeof m=="function"&&tt.set(m,M),M}while(y>=1&&_>=0);break}}}finally{ht=!1,de.current=oe,ut(),Error.prepareStackTrace=ie}var k=m?m.displayName||m.name:"",R=k?ke(k):"";return typeof m=="function"&&tt.set(m,R),R}function Dt(m,I,N){return _t(m,!1)}function Rr(m){var I=m.prototype;return!!(I&&I.isReactComponent)}function ft(m,I,N){if(m==null)return"";if(typeof m=="function")return _t(m,Rr(m));if(typeof m=="string")return ke(m);switch(m){case u:return ke("Suspense");case d:return ke("SuspenseList")}if(typeof m=="object")switch(m.$$typeof){case c:return Dt(m.render);case h:return ft(m.type,I,N);case l:{var Z=m,ie=Z._payload,oe=Z._init;try{return ft(oe(ie),I,N)}catch{}}}return""}var rt=Object.prototype.hasOwnProperty,Qt={},Jt=x.ReactDebugCurrentFrame;function xt(m){if(m){var I=m._owner,N=ft(m.type,m._source,I?I.type:null);Jt.setExtraStackFrame(N)}else Jt.setExtraStackFrame(null)}function Qr(m,I,N,Z,ie){{var oe=Function.call.bind(rt);for(var Q in m)if(oe(m,Q)){var $=void 0;try{if(typeof m[Q]!="function"){var p=Error((Z||"React class")+": "+N+" type `"+Q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof m[Q]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw p.name="Invariant Violation",p}$=m[Q](I,Q,Z,N,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(y){$=y}$&&!($ instanceof Error)&&(xt(ie),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Z||"React class",N,Q,typeof $),xt(null)),$ instanceof Error&&!($.message in Qt)&&(Qt[$.message]=!0,xt(ie),w("Failed %s type: %s",N,$.message),xt(null))}}}var Jr=Array.isArray;function Rt(m){return Jr(m)}function Ht(m){{var I=typeof Symbol=="function"&&Symbol.toStringTag,N=I&&m[Symbol.toStringTag]||m.constructor.name||"Object";return N}}function Hr(m){try{return Ft(m),!1}catch{return!0}}function Ft(m){return""+m}function er(m){if(Hr(m))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ht(m)),Ft(m)}var tr=x.ReactCurrentOwner,Fr={key:!0,ref:!0,__self:!0,__source:!0},Tt,rr;function en(m){if(rt.call(m,"ref")){var I=Object.getOwnPropertyDescriptor(m,"ref").get;if(I&&I.isReactWarning)return!1}return m.ref!==void 0}function tn(m){if(rt.call(m,"key")){var I=Object.getOwnPropertyDescriptor(m,"key").get;if(I&&I.isReactWarning)return!1}return m.key!==void 0}function Ge(m,I){typeof m.ref=="string"&&tr.current}function je(m,I){{var N=function(){Tt||(Tt=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",I))};N.isReactWarning=!0,Object.defineProperty(m,"key",{get:N,configurable:!0})}}function Or(m,I){{var N=function(){rr||(rr=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",I))};N.isReactWarning=!0,Object.defineProperty(m,"ref",{get:N,configurable:!0})}}var dt=function(m,I,N,Z,ie,oe,Q){var $={$$typeof:e,type:m,key:I,ref:N,props:Q,_owner:oe};return $._store={},Object.defineProperty($._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty($,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Z}),Object.defineProperty($,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ie}),Object.freeze&&(Object.freeze($.props),Object.freeze($)),$};function Ve(m,I,N,Z,ie){{var oe,Q={},$=null,p=null;N!==void 0&&(er(N),$=""+N),tn(I)&&(er(I.key),$=""+I.key),en(I)&&(p=I.ref,Ge(I,ie));for(oe in I)rt.call(I,oe)&&!Fr.hasOwnProperty(oe)&&(Q[oe]=I[oe]);if(m&&m.defaultProps){var y=m.defaultProps;for(oe in y)Q[oe]===void 0&&(Q[oe]=y[oe])}if($||p){var _=typeof m=="function"?m.displayName||m.name||"Unknown":m;$&&je(Q,_),p&&Or(Q,_)}return dt(m,$,p,ie,Z,tr.current,Q)}}var De=x.ReactCurrentOwner,nr=x.ReactDebugCurrentFrame;function K(m){if(m){var I=m._owner,N=ft(m.type,m._source,I?I.type:null);nr.setExtraStackFrame(N)}else nr.setExtraStackFrame(null)}var nt;nt=!1;function Ot(m){return typeof m=="object"&&m!==null&&m.$$typeof===e}function ir(){{if(De.current){var m=G(De.current.type);if(m)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+
|
|
23
|
+
Check the render method of \``+m+"`."}return""}}function rn(m){return""}var sr={};function nn(m){{var I=ir();if(!I){var N=typeof m=="string"?m:m.displayName||m.name;N&&(I=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+N+">.")}return I}}function or(m,I){{if(!m._store||m._store.validated||m.key!=null)return;m._store.validated=!0;var N=nn(I);if(sr[N])return;sr[N]=!0;var Z="";m&&m._owner&&m._owner!==De.current&&(Z=" It was passed a child from "+G(m._owner.type)+"."),K(m),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',N,Z),K(null)}}function ar(m,I){{if(typeof m!="object")return;if(Rt(m))for(var N=0;N<m.length;N++){var Z=m[N];Ot(Z)&&or(Z,I)}else if(Ot(m))m._store&&(m._store.validated=!0);else if(m){var ie=g(m);if(typeof ie=="function"&&ie!==m.entries)for(var oe=ie.call(m),Q;!(Q=oe.next()).done;)Ot(Q.value)&&or(Q.value,I)}}}function sn(m){{var I=m.type;if(I==null||typeof I=="string")return;var N;if(typeof I=="function")N=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===c||I.$$typeof===h))N=I.propTypes;else return;if(N){var Z=G(I);Qr(N,m.props,"prop",Z,m)}else if(I.PropTypes!==void 0&&!nt){nt=!0;var ie=G(I);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function on(m){{for(var I=Object.keys(m.props),N=0;N<I.length;N++){var Z=I[N];if(Z!=="children"&&Z!=="key"){K(m),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Z),K(null);break}}m.ref!==null&&(K(m),w("Invalid attribute `ref` supplied to `React.Fragment`."),K(null))}}var cr={};function lr(m,I,N,Z,ie,oe){{var Q=E(m);if(!Q){var $="";(m===void 0||typeof m=="object"&&m!==null&&Object.keys(m).length===0)&&($+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var p=rn();p?$+=p:$+=ir();var y;m===null?y="null":Rt(m)?y="array":m!==void 0&&m.$$typeof===e?(y="<"+(G(m.type)||"Unknown")+" />",$=" Did you accidentally export a JSX literal instead of a component?"):y=typeof m,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",y,$)}var _=Ve(m,I,N,ie,oe);if(_==null)return _;if(Q){var M=I.children;if(M!==void 0)if(Z)if(Rt(M)){for(var k=0;k<M.length;k++)ar(M[k],m);Object.freeze&&Object.freeze(M)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ar(M,m)}if(rt.call(I,"key")){var R=G(m),B=Object.keys(I).filter(function(j){return j!=="key"}),q=B.length>0?"{key: someKey, "+B.join(": ..., ")+": ...}":"{key: someKey}";if(!cr[R+q]){var Y=B.length>0?"{"+B.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,Pn,ut,Ni,ut),In[ut+Pn]=!0}}return y===i?Di(ge):Pi(ge),ge}}function Sr(y,D,z){return Er(y,D,z,!0)}function Fi(y,D,z){return Er(y,D,z,!1)}var Oi=Fi,Li=Sr;mi.Fragment=i,mi.jsx=Oi,mi.jsxs=Li}()),mi}var wc;function xh(){return wc||(wc=1,process.env.NODE_ENV==="production"?es.exports=yh():es.exports=_h()),es.exports}var Vt=xh();function Rc(o,e){if(e===m.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===m.TriangleFanDrawMode||e===m.TriangleStripDrawMode){let n=o.getIndex();if(n===null){const a=[],u=o.getAttribute("position");if(u!==void 0){for(let f=0;f<u.count;f++)a.push(f);o.setIndex(a),n=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const i=n.count-2,s=[];if(e===m.TriangleFanDrawMode)for(let a=1;a<=i;a++)s.push(n.getX(0)),s.push(n.getX(a)),s.push(n.getX(a+1));else for(let a=0;a<i;a++)a%2===0?(s.push(n.getX(a)),s.push(n.getX(a+1)),s.push(n.getX(a+2))):(s.push(n.getX(a+2)),s.push(n.getX(a+1)),s.push(n.getX(a)));s.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const c=o.clone();return c.setIndex(s),c.clearGroups(),c}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Ac extends m.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new Ah(n)}),this.register(function(n){return new Eh(n)}),this.register(function(n){return new Lh(n)}),this.register(function(n){return new Nh(n)}),this.register(function(n){return new Bh(n)}),this.register(function(n){return new Mh(n)}),this.register(function(n){return new Ch(n)}),this.register(function(n){return new Ih(n)}),this.register(function(n){return new Ph(n)}),this.register(function(n){return new Rh(n)}),this.register(function(n){return new Dh(n)}),this.register(function(n){return new Sh(n)}),this.register(function(n){return new Oh(n)}),this.register(function(n){return new Fh(n)}),this.register(function(n){return new Th(n)}),this.register(function(n){return new kh(n)}),this.register(function(n){return new Uh(n)})}load(e,n,i,s){const c=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const p=m.LoaderUtils.extractUrlBase(e);a=m.LoaderUtils.resolveURL(p,this.path)}else a=m.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const u=function(p){s?s(p):console.error(p),c.manager.itemError(e),c.manager.itemEnd(e)},f=new m.FileLoader(this.manager);f.setPath(this.path),f.setResponseType("arraybuffer"),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(p){try{c.parse(p,a,function(v){n(v),c.manager.itemEnd(e)},u)}catch(v){u(v)}},i,u)}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 this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,i,s){let c;const a={},u={},f=new TextDecoder;if(typeof e=="string")c=JSON.parse(e);else if(e instanceof ArrayBuffer)if(f.decode(new Uint8Array(e,0,4))===Ec){try{a[be.KHR_BINARY_GLTF]=new zh(e)}catch(g){s&&s(g);return}c=JSON.parse(a[be.KHR_BINARY_GLTF].content)}else c=JSON.parse(f.decode(e));else c=e;if(c.asset===void 0||c.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const p=new Jh(c,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});p.fileLoader.setRequestHeader(this.requestHeader);for(let v=0;v<this.pluginCallbacks.length;v++){const g=this.pluginCallbacks[v](p);g.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),u[g.name]=g,a[g.name]=!0}if(c.extensionsUsed)for(let v=0;v<c.extensionsUsed.length;++v){const g=c.extensionsUsed[v],h=c.extensionsRequired||[];switch(g){case be.KHR_MATERIALS_UNLIT:a[g]=new wh;break;case be.KHR_DRACO_MESH_COMPRESSION:a[g]=new Hh(c,this.dracoLoader);break;case be.KHR_TEXTURE_TRANSFORM:a[g]=new Gh;break;case be.KHR_MESH_QUANTIZATION:a[g]=new Wh;break;default:h.indexOf(g)>=0&&u[g]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+g+'".')}}p.setExtensions(a),p.setPlugins(u),p.parse(i,s)}parseAsync(e,n){const i=this;return new Promise(function(s,c){i.parse(e,n,s,c)})}}function bh(){let o={};return{get:function(e){return o[e]},add:function(e,n){o[e]=n},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const be={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 Th{constructor(e){this.parser=e,this.name=be.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let i=0,s=n.length;i<s;i++){const c=n[i];c.extensions&&c.extensions[this.name]&&c.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,c.extensions[this.name].light)}}_loadLight(e){const n=this.parser,i="light:"+e;let s=n.cache.get(i);if(s)return s;const c=n.json,f=((c.extensions&&c.extensions[this.name]||{}).lights||[])[e];let p;const v=new m.Color(16777215);f.color!==void 0&&v.setRGB(f.color[0],f.color[1],f.color[2],m.LinearSRGBColorSpace);const g=f.range!==void 0?f.range:0;switch(f.type){case"directional":p=new m.DirectionalLight(v),p.target.position.set(0,0,-1),p.add(p.target);break;case"point":p=new m.PointLight(v),p.distance=g;break;case"spot":p=new m.SpotLight(v),p.distance=g,f.spot=f.spot||{},f.spot.innerConeAngle=f.spot.innerConeAngle!==void 0?f.spot.innerConeAngle:0,f.spot.outerConeAngle=f.spot.outerConeAngle!==void 0?f.spot.outerConeAngle:Math.PI/4,p.angle=f.spot.outerConeAngle,p.penumbra=1-f.spot.innerConeAngle/f.spot.outerConeAngle,p.target.position.set(0,0,-1),p.add(p.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+f.type)}return p.position.set(0,0,0),p.decay=2,wn(p,f),f.intensity!==void 0&&(p.intensity=f.intensity),p.name=n.createUniqueName(f.name||"light_"+e),s=Promise.resolve(p),n.cache.add(i,s),s}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,i=this.parser,c=i.json.nodes[e],u=(c.extensions&&c.extensions[this.name]||{}).light;return u===void 0?null:this._loadLight(u).then(function(f){return i._getNodeRef(n.cache,u,f)})}}class wh{constructor(){this.name=be.KHR_MATERIALS_UNLIT}getMaterialType(){return m.MeshBasicMaterial}extendParams(e,n,i){const s=[];e.color=new m.Color(1,1,1),e.opacity=1;const c=n.pbrMetallicRoughness;if(c){if(Array.isArray(c.baseColorFactor)){const a=c.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],m.LinearSRGBColorSpace),e.opacity=a[3]}c.baseColorTexture!==void 0&&s.push(i.assignTexture(e,"map",c.baseColorTexture,m.SRGBColorSpace))}return Promise.all(s)}}class Rh{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=s.extensions[this.name].emissiveStrength;return c!==void 0&&(n.emissiveIntensity=c),Promise.resolve()}}class Ah{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=[],a=s.extensions[this.name];if(a.clearcoatFactor!==void 0&&(n.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&c.push(i.assignTexture(n,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&c.push(i.assignTexture(n,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(c.push(i.assignTexture(n,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const u=a.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new m.Vector2(u,u)}return Promise.all(c)}}class Eh{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_DISPERSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=s.extensions[this.name];return n.dispersion=c.dispersion!==void 0?c.dispersion:0,Promise.resolve()}}class Sh{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=[],a=s.extensions[this.name];return a.iridescenceFactor!==void 0&&(n.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&c.push(i.assignTexture(n,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(n.iridescenceIOR=a.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&c.push(i.assignTexture(n,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(c)}}class Mh{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_SHEEN}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=[];n.sheenColor=new m.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const a=s.extensions[this.name];if(a.sheenColorFactor!==void 0){const u=a.sheenColorFactor;n.sheenColor.setRGB(u[0],u[1],u[2],m.LinearSRGBColorSpace)}return a.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&c.push(i.assignTexture(n,"sheenColorMap",a.sheenColorTexture,m.SRGBColorSpace)),a.sheenRoughnessTexture!==void 0&&c.push(i.assignTexture(n,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(c)}}class Ch{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=[],a=s.extensions[this.name];return a.transmissionFactor!==void 0&&(n.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&c.push(i.assignTexture(n,"transmissionMap",a.transmissionTexture)),Promise.all(c)}}class Ih{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_VOLUME}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=[],a=s.extensions[this.name];n.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&c.push(i.assignTexture(n,"thicknessMap",a.thicknessTexture)),n.attenuationDistance=a.attenuationDistance||1/0;const u=a.attenuationColor||[1,1,1];return n.attenuationColor=new m.Color().setRGB(u[0],u[1],u[2],m.LinearSRGBColorSpace),Promise.all(c)}}class Ph{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_IOR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=s.extensions[this.name];return n.ior=c.ior!==void 0?c.ior:1.5,Promise.resolve()}}class Dh{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_SPECULAR}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=[],a=s.extensions[this.name];n.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&c.push(i.assignTexture(n,"specularIntensityMap",a.specularTexture));const u=a.specularColorFactor||[1,1,1];return n.specularColor=new m.Color().setRGB(u[0],u[1],u[2],m.LinearSRGBColorSpace),a.specularColorTexture!==void 0&&c.push(i.assignTexture(n,"specularColorMap",a.specularColorTexture,m.SRGBColorSpace)),Promise.all(c)}}class Fh{constructor(e){this.parser=e,this.name=be.EXT_MATERIALS_BUMP}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=[],a=s.extensions[this.name];return n.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&c.push(i.assignTexture(n,"bumpMap",a.bumpTexture)),Promise.all(c)}}class Oh{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const i=this.parser.json.materials[e];return!i.extensions||!i.extensions[this.name]?null:m.MeshPhysicalMaterial}extendMaterialParams(e,n){const i=this.parser,s=i.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const c=[],a=s.extensions[this.name];return a.anisotropyStrength!==void 0&&(n.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(n.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&c.push(i.assignTexture(n,"anisotropyMap",a.anisotropyTexture)),Promise.all(c)}}class Lh{constructor(e){this.parser=e,this.name=be.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const c=s.extensions[this.name],a=n.options.ktx2Loader;if(!a){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,c.source,a)}}class Nh{constructor(e){this.parser=e,this.name=be.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,i=this.parser,s=i.json,c=s.textures[e];if(!c.extensions||!c.extensions[n])return null;const a=c.extensions[n],u=s.images[a.source];let f=i.textureLoader;if(u.uri){const p=i.options.manager.getHandler(u.uri);p!==null&&(f=p)}return this.detectSupport().then(function(p){if(p)return i.loadTextureImage(e,a.source,f);if(s.extensionsRequired&&s.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class Bh{constructor(e){this.parser=e,this.name=be.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,i=this.parser,s=i.json,c=s.textures[e];if(!c.extensions||!c.extensions[n])return null;const a=c.extensions[n],u=s.images[a.source];let f=i.textureLoader;if(u.uri){const p=i.options.manager.getHandler(u.uri);p!==null&&(f=p)}return this.detectSupport().then(function(p){if(p)return i.loadTextureImage(e,a.source,f);if(s.extensionsRequired&&s.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class kh{constructor(e){this.name=be.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,i=n.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const s=i.extensions[this.name],c=this.parser.getDependency("buffer",s.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return c.then(function(u){const f=s.byteOffset||0,p=s.byteLength||0,v=s.count,g=s.byteStride,h=new Uint8Array(u,f,p);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(v,g,h,s.mode,s.filter).then(function(b){return b.buffer}):a.ready.then(function(){const b=new ArrayBuffer(v*g);return a.decodeGltfBuffer(new Uint8Array(b),v,g,h,s.mode,s.filter),b})})}else return null}}class Uh{constructor(e){this.name=be.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,i=n.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const s=n.meshes[i.mesh];for(const p of s.primitives)if(p.mode!==jt.TRIANGLES&&p.mode!==jt.TRIANGLE_STRIP&&p.mode!==jt.TRIANGLE_FAN&&p.mode!==void 0)return null;const a=i.extensions[this.name].attributes,u=[],f={};for(const p in a)u.push(this.parser.getDependency("accessor",a[p]).then(v=>(f[p]=v,f[p])));return u.length<1?null:(u.push(this.parser.createNodeMesh(e)),Promise.all(u).then(p=>{const v=p.pop(),g=v.isGroup?v.children:[v],h=p[0].count,b=[];for(const R of g){const M=new m.Matrix4,x=new m.Vector3,A=new m.Quaternion,E=new m.Vector3(1,1,1),C=new m.InstancedMesh(R.geometry,R.material,h);for(let P=0;P<h;P++)f.TRANSLATION&&x.fromBufferAttribute(f.TRANSLATION,P),f.ROTATION&&A.fromBufferAttribute(f.ROTATION,P),f.SCALE&&E.fromBufferAttribute(f.SCALE,P),C.setMatrixAt(P,M.compose(x,A,E));for(const P in f)if(P==="_COLOR_0"){const O=f[P];C.instanceColor=new m.InstancedBufferAttribute(O.array,O.itemSize,O.normalized)}else P!=="TRANSLATION"&&P!=="ROTATION"&&P!=="SCALE"&&R.geometry.setAttribute(P,f[P]);m.Object3D.prototype.copy.call(C,R),this.parser.assignFinalMaterial(C),b.push(C)}return v.isGroup?(v.clear(),v.add(...b),v):b[0]}))}}const Ec="glTF",gi=12,Sc={JSON:1313821514,BIN:5130562};class zh{constructor(e){this.name=be.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,gi),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==Ec)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-gi,c=new DataView(e,gi);let a=0;for(;a<s;){const u=c.getUint32(a,!0);a+=4;const f=c.getUint32(a,!0);if(a+=4,f===Sc.JSON){const p=new Uint8Array(e,gi+a,u);this.content=i.decode(p)}else if(f===Sc.BIN){const p=gi+a;this.body=e.slice(p,p+u)}a+=u}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Hh{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=be.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const i=this.json,s=this.dracoLoader,c=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,u={},f={},p={};for(const v in a){const g=xa[v]||v.toLowerCase();u[g]=a[v]}for(const v in e.attributes){const g=xa[v]||v.toLowerCase();if(a[v]!==void 0){const h=i.accessors[e.attributes[v]],b=Br[h.componentType];p[g]=b.name,f[g]=h.normalized===!0}}return n.getDependency("bufferView",c).then(function(v){return new Promise(function(g,h){s.decodeDracoFile(v,function(b){for(const R in b.attributes){const M=b.attributes[R],x=f[R];x!==void 0&&(M.normalized=x)}g(b)},u,p,m.LinearSRGBColorSpace,h)})})}}class Gh{constructor(){this.name=be.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class Wh{constructor(){this.name=be.KHR_MESH_QUANTIZATION}}class Mc extends m.Interpolant{constructor(e,n,i,s){super(e,n,i,s)}copySampleValue_(e){const n=this.resultBuffer,i=this.sampleValues,s=this.valueSize,c=e*s*3+s;for(let a=0;a!==s;a++)n[a]=i[c+a];return n}interpolate_(e,n,i,s){const c=this.resultBuffer,a=this.sampleValues,u=this.valueSize,f=u*2,p=u*3,v=s-n,g=(i-n)/v,h=g*g,b=h*g,R=e*p,M=R-p,x=-2*b+3*h,A=b-h,E=1-x,C=A-h+g;for(let P=0;P!==u;P++){const O=a[M+P+u],B=a[M+P+f]*v,k=a[R+P+u],q=a[R+P]*v;c[P]=E*O+C*B+x*k+A*q}return c}}const Vh=new m.Quaternion;class jh extends Mc{interpolate_(e,n,i,s){const c=super.interpolate_(e,n,i,s);return Vh.fromArray(c).normalize().toArray(c),c}}const jt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Br={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Cc={9728:m.NearestFilter,9729:m.LinearFilter,9984:m.NearestMipmapNearestFilter,9985:m.LinearMipmapNearestFilter,9986:m.NearestMipmapLinearFilter,9987:m.LinearMipmapLinearFilter},Ic={33071:m.ClampToEdgeWrapping,33648:m.MirroredRepeatWrapping,10497:m.RepeatWrapping},_a={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xa={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"},Hn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},qh={CUBICSPLINE:void 0,LINEAR:m.InterpolateLinear,STEP:m.InterpolateDiscrete},ba={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Yh(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new m.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:m.FrontSide})),o.DefaultMaterial}function or(o,e,n){for(const i in n.extensions)o[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=n.extensions[i])}function wn(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Kh(o,e,n){let i=!1,s=!1,c=!1;for(let p=0,v=e.length;p<v;p++){const g=e[p];if(g.POSITION!==void 0&&(i=!0),g.NORMAL!==void 0&&(s=!0),g.COLOR_0!==void 0&&(c=!0),i&&s&&c)break}if(!i&&!s&&!c)return Promise.resolve(o);const a=[],u=[],f=[];for(let p=0,v=e.length;p<v;p++){const g=e[p];if(i){const h=g.POSITION!==void 0?n.getDependency("accessor",g.POSITION):o.attributes.position;a.push(h)}if(s){const h=g.NORMAL!==void 0?n.getDependency("accessor",g.NORMAL):o.attributes.normal;u.push(h)}if(c){const h=g.COLOR_0!==void 0?n.getDependency("accessor",g.COLOR_0):o.attributes.color;f.push(h)}}return Promise.all([Promise.all(a),Promise.all(u),Promise.all(f)]).then(function(p){const v=p[0],g=p[1],h=p[2];return i&&(o.morphAttributes.position=v),s&&(o.morphAttributes.normal=g),c&&(o.morphAttributes.color=h),o.morphTargetsRelative=!0,o})}function Xh(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let n=0,i=e.weights.length;n<i;n++)o.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(o.morphTargetInfluences.length===n.length){o.morphTargetDictionary={};for(let i=0,s=n.length;i<s;i++)o.morphTargetDictionary[n[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Zh(o){let e;const n=o.extensions&&o.extensions[be.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+Ta(n.attributes):e=o.indices+":"+Ta(o.attributes)+":"+o.mode,o.targets!==void 0)for(let i=0,s=o.targets.length;i<s;i++)e+=":"+Ta(o.targets[i]);return e}function Ta(o){let e="";const n=Object.keys(o).sort();for(let i=0,s=n.length;i<s;i++)e+=n[i]+":"+o[n[i]]+";";return e}function wa(o){switch(o){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.")}}function $h(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Qh=new m.Matrix4;class Jh{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new bh,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 i=!1,s=-1,c=!1,a=-1;if(typeof navigator<"u"){const u=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(u)===!0;const f=u.match(/Version\/(\d+)/);s=i&&f?parseInt(f[1],10):-1,c=u.indexOf("Firefox")>-1,a=c?u.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&s<17||c&&a<98?this.textureLoader=new m.TextureLoader(this.options.manager):this.textureLoader=new m.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new m.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const i=this,s=this.json,c=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(a){const u={scene:a[0][s.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:s.asset,parser:i,userData:{}};return or(c,u,s),wn(u,s),Promise.all(i._invokeAll(function(f){return f.afterRoot&&f.afterRoot(u)})).then(function(){for(const f of u.scenes)f.updateMatrixWorld();e(u)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],i=this.json.meshes||[];for(let s=0,c=n.length;s<c;s++){const a=n[s].joints;for(let u=0,f=a.length;u<f;u++)e[a[u]].isBone=!0}for(let s=0,c=e.length;s<c;s++){const a=e[s];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(i[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,i){if(e.refs[n]<=1)return i;const s=i.clone(),c=(a,u)=>{const f=this.associations.get(a);f!=null&&this.associations.set(u,f);for(const[p,v]of a.children.entries())c(v,u.children[p])};return c(i,s),s.name+="_instance_"+e.uses[n]++,s}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let i=0;i<n.length;i++){const s=e(n[i]);if(s)return s}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const i=[];for(let s=0;s<n.length;s++){const c=e(n[s]);c&&i.push(c)}return i}getDependency(e,n){const i=e+":"+n;let s=this.cache.get(i);if(!s){switch(e){case"scene":s=this.loadScene(n);break;case"node":s=this._invokeOne(function(c){return c.loadNode&&c.loadNode(n)});break;case"mesh":s=this._invokeOne(function(c){return c.loadMesh&&c.loadMesh(n)});break;case"accessor":s=this.loadAccessor(n);break;case"bufferView":s=this._invokeOne(function(c){return c.loadBufferView&&c.loadBufferView(n)});break;case"buffer":s=this.loadBuffer(n);break;case"material":s=this._invokeOne(function(c){return c.loadMaterial&&c.loadMaterial(n)});break;case"texture":s=this._invokeOne(function(c){return c.loadTexture&&c.loadTexture(n)});break;case"skin":s=this.loadSkin(n);break;case"animation":s=this._invokeOne(function(c){return c.loadAnimation&&c.loadAnimation(n)});break;case"camera":s=this.loadCamera(n);break;default:if(s=this._invokeOne(function(c){return c!=this&&c.getDependency&&c.getDependency(e,n)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(i,s)}return s}getDependencies(e){let n=this.cache.get(e);if(!n){const i=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(s.map(function(c,a){return i.getDependency(e,a)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],i=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[be.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(c,a){i.load(m.LoaderUtils.resolveURL(n.uri,s.path),c,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(i){const s=n.byteLength||0,c=n.byteOffset||0;return i.slice(c,c+s)})}loadAccessor(e){const n=this,i=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const a=_a[s.type],u=Br[s.componentType],f=s.normalized===!0,p=new u(s.count*a);return Promise.resolve(new m.BufferAttribute(p,a,f))}const c=[];return s.bufferView!==void 0?c.push(this.getDependency("bufferView",s.bufferView)):c.push(null),s.sparse!==void 0&&(c.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),c.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(c).then(function(a){const u=a[0],f=_a[s.type],p=Br[s.componentType],v=p.BYTES_PER_ELEMENT,g=v*f,h=s.byteOffset||0,b=s.bufferView!==void 0?i.bufferViews[s.bufferView].byteStride:void 0,R=s.normalized===!0;let M,x;if(b&&b!==g){const A=Math.floor(h/b),E="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+A+":"+s.count;let C=n.cache.get(E);C||(M=new p(u,A*b,s.count*b/v),C=new m.InterleavedBuffer(M,b/v),n.cache.add(E,C)),x=new m.InterleavedBufferAttribute(C,f,h%b/v,R)}else u===null?M=new p(s.count*f):M=new p(u,h,s.count*f),x=new m.BufferAttribute(M,f,R);if(s.sparse!==void 0){const A=_a.SCALAR,E=Br[s.sparse.indices.componentType],C=s.sparse.indices.byteOffset||0,P=s.sparse.values.byteOffset||0,O=new E(a[1],C,s.sparse.count*A),B=new p(a[2],P,s.sparse.count*f);u!==null&&(x=new m.BufferAttribute(x.array.slice(),x.itemSize,x.normalized));for(let k=0,q=O.length;k<q;k++){const j=O[k];if(x.setX(j,B[k*f]),f>=2&&x.setY(j,B[k*f+1]),f>=3&&x.setZ(j,B[k*f+2]),f>=4&&x.setW(j,B[k*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return x})}loadTexture(e){const n=this.json,i=this.options,c=n.textures[e].source,a=n.images[c];let u=this.textureLoader;if(a.uri){const f=i.manager.getHandler(a.uri);f!==null&&(u=f)}return this.loadTextureImage(e,c,u)}loadTextureImage(e,n,i){const s=this,c=this.json,a=c.textures[e],u=c.images[n],f=(u.uri||u.bufferView)+":"+a.sampler;if(this.textureCache[f])return this.textureCache[f];const p=this.loadImageSource(n,i).then(function(v){v.flipY=!1,v.name=a.name||u.name||"",v.name===""&&typeof u.uri=="string"&&u.uri.startsWith("data:image/")===!1&&(v.name=u.uri);const h=(c.samplers||{})[a.sampler]||{};return v.magFilter=Cc[h.magFilter]||m.LinearFilter,v.minFilter=Cc[h.minFilter]||m.LinearMipmapLinearFilter,v.wrapS=Ic[h.wrapS]||m.RepeatWrapping,v.wrapT=Ic[h.wrapT]||m.RepeatWrapping,s.associations.set(v,{textures:e}),v}).catch(function(){return null});return this.textureCache[f]=p,p}loadImageSource(e,n){const i=this,s=this.json,c=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(g=>g.clone());const a=s.images[e],u=self.URL||self.webkitURL;let f=a.uri||"",p=!1;if(a.bufferView!==void 0)f=i.getDependency("bufferView",a.bufferView).then(function(g){p=!0;const h=new Blob([g],{type:a.mimeType});return f=u.createObjectURL(h),f});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const v=Promise.resolve(f).then(function(g){return new Promise(function(h,b){let R=h;n.isImageBitmapLoader===!0&&(R=function(M){const x=new m.Texture(M);x.needsUpdate=!0,h(x)}),n.load(m.LoaderUtils.resolveURL(g,c.path),R,void 0,b)})}).then(function(g){return p===!0&&u.revokeObjectURL(f),wn(g,a),g.userData.mimeType=a.mimeType||$h(a.uri),g}).catch(function(g){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),g});return this.sourceCache[e]=v,v}assignTexture(e,n,i,s){const c=this;return this.getDependency("texture",i.index).then(function(a){if(!a)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(a=a.clone(),a.channel=i.texCoord),c.extensions[be.KHR_TEXTURE_TRANSFORM]){const u=i.extensions!==void 0?i.extensions[be.KHR_TEXTURE_TRANSFORM]:void 0;if(u){const f=c.associations.get(a);a=c.extensions[be.KHR_TEXTURE_TRANSFORM].extendTexture(a,u),c.associations.set(a,f)}}return s!==void 0&&(a.colorSpace=s),e[n]=a,a})}assignFinalMaterial(e){const n=e.geometry;let i=e.material;const s=n.attributes.tangent===void 0,c=n.attributes.color!==void 0,a=n.attributes.normal===void 0;if(e.isPoints){const u="PointsMaterial:"+i.uuid;let f=this.cache.get(u);f||(f=new m.PointsMaterial,m.Material.prototype.copy.call(f,i),f.color.copy(i.color),f.map=i.map,f.sizeAttenuation=!1,this.cache.add(u,f)),i=f}else if(e.isLine){const u="LineBasicMaterial:"+i.uuid;let f=this.cache.get(u);f||(f=new m.LineBasicMaterial,m.Material.prototype.copy.call(f,i),f.color.copy(i.color),f.map=i.map,this.cache.add(u,f)),i=f}if(s||c||a){let u="ClonedMaterial:"+i.uuid+":";s&&(u+="derivative-tangents:"),c&&(u+="vertex-colors:"),a&&(u+="flat-shading:");let f=this.cache.get(u);f||(f=i.clone(),c&&(f.vertexColors=!0),a&&(f.flatShading=!0),s&&(f.normalScale&&(f.normalScale.y*=-1),f.clearcoatNormalScale&&(f.clearcoatNormalScale.y*=-1)),this.cache.add(u,f),this.associations.set(f,this.associations.get(i))),i=f}e.material=i}getMaterialType(){return m.MeshStandardMaterial}loadMaterial(e){const n=this,i=this.json,s=this.extensions,c=i.materials[e];let a;const u={},f=c.extensions||{},p=[];if(f[be.KHR_MATERIALS_UNLIT]){const g=s[be.KHR_MATERIALS_UNLIT];a=g.getMaterialType(),p.push(g.extendParams(u,c,n))}else{const g=c.pbrMetallicRoughness||{};if(u.color=new m.Color(1,1,1),u.opacity=1,Array.isArray(g.baseColorFactor)){const h=g.baseColorFactor;u.color.setRGB(h[0],h[1],h[2],m.LinearSRGBColorSpace),u.opacity=h[3]}g.baseColorTexture!==void 0&&p.push(n.assignTexture(u,"map",g.baseColorTexture,m.SRGBColorSpace)),u.metalness=g.metallicFactor!==void 0?g.metallicFactor:1,u.roughness=g.roughnessFactor!==void 0?g.roughnessFactor:1,g.metallicRoughnessTexture!==void 0&&(p.push(n.assignTexture(u,"metalnessMap",g.metallicRoughnessTexture)),p.push(n.assignTexture(u,"roughnessMap",g.metallicRoughnessTexture))),a=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),p.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,u)})))}c.doubleSided===!0&&(u.side=m.DoubleSide);const v=c.alphaMode||ba.OPAQUE;if(v===ba.BLEND?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,v===ba.MASK&&(u.alphaTest=c.alphaCutoff!==void 0?c.alphaCutoff:.5)),c.normalTexture!==void 0&&a!==m.MeshBasicMaterial&&(p.push(n.assignTexture(u,"normalMap",c.normalTexture)),u.normalScale=new m.Vector2(1,1),c.normalTexture.scale!==void 0)){const g=c.normalTexture.scale;u.normalScale.set(g,g)}if(c.occlusionTexture!==void 0&&a!==m.MeshBasicMaterial&&(p.push(n.assignTexture(u,"aoMap",c.occlusionTexture)),c.occlusionTexture.strength!==void 0&&(u.aoMapIntensity=c.occlusionTexture.strength)),c.emissiveFactor!==void 0&&a!==m.MeshBasicMaterial){const g=c.emissiveFactor;u.emissive=new m.Color().setRGB(g[0],g[1],g[2],m.LinearSRGBColorSpace)}return c.emissiveTexture!==void 0&&a!==m.MeshBasicMaterial&&p.push(n.assignTexture(u,"emissiveMap",c.emissiveTexture,m.SRGBColorSpace)),Promise.all(p).then(function(){const g=new a(u);return c.name&&(g.name=c.name),wn(g,c),n.associations.set(g,{materials:e}),c.extensions&&or(s,g,c),g})}createUniqueName(e){const n=m.PropertyBinding.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,i=this.extensions,s=this.primitiveCache;function c(u){return i[be.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(u,n).then(function(f){return Pc(f,u,n)})}const a=[];for(let u=0,f=e.length;u<f;u++){const p=e[u],v=Zh(p),g=s[v];if(g)a.push(g.promise);else{let h;p.extensions&&p.extensions[be.KHR_DRACO_MESH_COMPRESSION]?h=c(p):h=Pc(new m.BufferGeometry,p,n),s[v]={primitive:p,promise:h},a.push(h)}}return Promise.all(a)}loadMesh(e){const n=this,i=this.json,s=this.extensions,c=i.meshes[e],a=c.primitives,u=[];for(let f=0,p=a.length;f<p;f++){const v=a[f].material===void 0?Yh(this.cache):this.getDependency("material",a[f].material);u.push(v)}return u.push(n.loadGeometries(a)),Promise.all(u).then(function(f){const p=f.slice(0,f.length-1),v=f[f.length-1],g=[];for(let b=0,R=v.length;b<R;b++){const M=v[b],x=a[b];let A;const E=p[b];if(x.mode===jt.TRIANGLES||x.mode===jt.TRIANGLE_STRIP||x.mode===jt.TRIANGLE_FAN||x.mode===void 0)A=c.isSkinnedMesh===!0?new m.SkinnedMesh(M,E):new m.Mesh(M,E),A.isSkinnedMesh===!0&&A.normalizeSkinWeights(),x.mode===jt.TRIANGLE_STRIP?A.geometry=Rc(A.geometry,m.TriangleStripDrawMode):x.mode===jt.TRIANGLE_FAN&&(A.geometry=Rc(A.geometry,m.TriangleFanDrawMode));else if(x.mode===jt.LINES)A=new m.LineSegments(M,E);else if(x.mode===jt.LINE_STRIP)A=new m.Line(M,E);else if(x.mode===jt.LINE_LOOP)A=new m.LineLoop(M,E);else if(x.mode===jt.POINTS)A=new m.Points(M,E);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(A.geometry.morphAttributes).length>0&&Xh(A,c),A.name=n.createUniqueName(c.name||"mesh_"+e),wn(A,c),x.extensions&&or(s,A,x),n.assignFinalMaterial(A),g.push(A)}for(let b=0,R=g.length;b<R;b++)n.associations.set(g[b],{meshes:e,primitives:b});if(g.length===1)return c.extensions&&or(s,g[0],c),g[0];const h=new m.Group;c.extensions&&or(s,h,c),n.associations.set(h,{meshes:e});for(let b=0,R=g.length;b<R;b++)h.add(g[b]);return h})}loadCamera(e){let n;const i=this.json.cameras[e],s=i[i.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?n=new m.PerspectiveCamera(m.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):i.type==="orthographic"&&(n=new m.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),i.name&&(n.name=this.createUniqueName(i.name)),wn(n,i),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],i=[];for(let s=0,c=n.joints.length;s<c;s++)i.push(this._loadNodeShallow(n.joints[s]));return n.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",n.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(s){const c=s.pop(),a=s,u=[],f=[];for(let p=0,v=a.length;p<v;p++){const g=a[p];if(g){u.push(g);const h=new m.Matrix4;c!==null&&h.fromArray(c.array,p*16),f.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[p])}return new m.Skeleton(u,f)})}loadAnimation(e){const n=this.json,i=this,s=n.animations[e],c=s.name?s.name:"animation_"+e,a=[],u=[],f=[],p=[],v=[];for(let g=0,h=s.channels.length;g<h;g++){const b=s.channels[g],R=s.samplers[b.sampler],M=b.target,x=M.node,A=s.parameters!==void 0?s.parameters[R.input]:R.input,E=s.parameters!==void 0?s.parameters[R.output]:R.output;M.node!==void 0&&(a.push(this.getDependency("node",x)),u.push(this.getDependency("accessor",A)),f.push(this.getDependency("accessor",E)),p.push(R),v.push(M))}return Promise.all([Promise.all(a),Promise.all(u),Promise.all(f),Promise.all(p),Promise.all(v)]).then(function(g){const h=g[0],b=g[1],R=g[2],M=g[3],x=g[4],A=[];for(let E=0,C=h.length;E<C;E++){const P=h[E],O=b[E],B=R[E],k=M[E],q=x[E];if(P===void 0)continue;P.updateMatrix&&P.updateMatrix();const j=i._createAnimationTracks(P,O,B,k,q);if(j)for(let K=0;K<j.length;K++)A.push(j[K])}return new m.AnimationClip(c,void 0,A)})}createNodeMesh(e){const n=this.json,i=this,s=n.nodes[e];return s.mesh===void 0?null:i.getDependency("mesh",s.mesh).then(function(c){const a=i._getNodeRef(i.meshCache,s.mesh,c);return s.weights!==void 0&&a.traverse(function(u){if(u.isMesh)for(let f=0,p=s.weights.length;f<p;f++)u.morphTargetInfluences[f]=s.weights[f]}),a})}loadNode(e){const n=this.json,i=this,s=n.nodes[e],c=i._loadNodeShallow(e),a=[],u=s.children||[];for(let p=0,v=u.length;p<v;p++)a.push(i.getDependency("node",u[p]));const f=s.skin===void 0?Promise.resolve(null):i.getDependency("skin",s.skin);return Promise.all([c,Promise.all(a),f]).then(function(p){const v=p[0],g=p[1],h=p[2];h!==null&&v.traverse(function(b){b.isSkinnedMesh&&b.bind(h,Qh)});for(let b=0,R=g.length;b<R;b++)v.add(g[b]);return v})}_loadNodeShallow(e){const n=this.json,i=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const c=n.nodes[e],a=c.name?s.createUniqueName(c.name):"",u=[],f=s._invokeOne(function(p){return p.createNodeMesh&&p.createNodeMesh(e)});return f&&u.push(f),c.camera!==void 0&&u.push(s.getDependency("camera",c.camera).then(function(p){return s._getNodeRef(s.cameraCache,c.camera,p)})),s._invokeAll(function(p){return p.createNodeAttachment&&p.createNodeAttachment(e)}).forEach(function(p){u.push(p)}),this.nodeCache[e]=Promise.all(u).then(function(p){let v;if(c.isBone===!0?v=new m.Bone:p.length>1?v=new m.Group:p.length===1?v=p[0]:v=new m.Object3D,v!==p[0])for(let g=0,h=p.length;g<h;g++)v.add(p[g]);if(c.name&&(v.userData.name=c.name,v.name=a),wn(v,c),c.extensions&&or(i,v,c),c.matrix!==void 0){const g=new m.Matrix4;g.fromArray(c.matrix),v.applyMatrix4(g)}else c.translation!==void 0&&v.position.fromArray(c.translation),c.rotation!==void 0&&v.quaternion.fromArray(c.rotation),c.scale!==void 0&&v.scale.fromArray(c.scale);return s.associations.has(v)||s.associations.set(v,{}),s.associations.get(v).nodes=e,v}),this.nodeCache[e]}loadScene(e){const n=this.extensions,i=this.json.scenes[e],s=this,c=new m.Group;i.name&&(c.name=s.createUniqueName(i.name)),wn(c,i),i.extensions&&or(n,c,i);const a=i.nodes||[],u=[];for(let f=0,p=a.length;f<p;f++)u.push(s.getDependency("node",a[f]));return Promise.all(u).then(function(f){for(let v=0,g=f.length;v<g;v++)c.add(f[v]);const p=v=>{const g=new Map;for(const[h,b]of s.associations)(h instanceof m.Material||h instanceof m.Texture)&&g.set(h,b);return v.traverse(h=>{const b=s.associations.get(h);b!=null&&g.set(h,b)}),g};return s.associations=p(c),c})}_createAnimationTracks(e,n,i,s,c){const a=[],u=e.name?e.name:e.uuid,f=[];Hn[c.path]===Hn.weights?e.traverse(function(h){h.morphTargetInfluences&&f.push(h.name?h.name:h.uuid)}):f.push(u);let p;switch(Hn[c.path]){case Hn.weights:p=m.NumberKeyframeTrack;break;case Hn.rotation:p=m.QuaternionKeyframeTrack;break;case Hn.position:case Hn.scale:p=m.VectorKeyframeTrack;break;default:switch(i.itemSize){case 1:p=m.NumberKeyframeTrack;break;case 2:case 3:default:p=m.VectorKeyframeTrack;break}break}const v=s.interpolation!==void 0?qh[s.interpolation]:m.InterpolateLinear,g=this._getArrayFromAccessor(i);for(let h=0,b=f.length;h<b;h++){const R=new p(f[h]+"."+Hn[c.path],n.array,g,v);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(R),a.push(R)}return a}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const i=wa(n.constructor),s=new Float32Array(n.length);for(let c=0,a=n.length;c<a;c++)s[c]=n[c]*i;n=s}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const s=this instanceof m.QuaternionKeyframeTrack?jh:Mc;return new s(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ed(o,e,n){const i=e.attributes,s=new m.Box3;if(i.POSITION!==void 0){const u=n.json.accessors[i.POSITION],f=u.min,p=u.max;if(f!==void 0&&p!==void 0){if(s.set(new m.Vector3(f[0],f[1],f[2]),new m.Vector3(p[0],p[1],p[2])),u.normalized){const v=wa(Br[u.componentType]);s.min.multiplyScalar(v),s.max.multiplyScalar(v)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const c=e.targets;if(c!==void 0){const u=new m.Vector3,f=new m.Vector3;for(let p=0,v=c.length;p<v;p++){const g=c[p];if(g.POSITION!==void 0){const h=n.json.accessors[g.POSITION],b=h.min,R=h.max;if(b!==void 0&&R!==void 0){if(f.setX(Math.max(Math.abs(b[0]),Math.abs(R[0]))),f.setY(Math.max(Math.abs(b[1]),Math.abs(R[1]))),f.setZ(Math.max(Math.abs(b[2]),Math.abs(R[2]))),h.normalized){const M=wa(Br[h.componentType]);f.multiplyScalar(M)}u.max(f)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(u)}o.boundingBox=s;const a=new m.Sphere;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,o.boundingSphere=a}function Pc(o,e,n){const i=e.attributes,s=[];function c(a,u){return n.getDependency("accessor",a).then(function(f){o.setAttribute(u,f)})}for(const a in i){const u=xa[a]||a.toLowerCase();u in o.attributes||s.push(c(i[a],u))}if(e.indices!==void 0&&!o.index){const a=n.getDependency("accessor",e.indices).then(function(u){o.setIndex(u)});s.push(a)}return m.ColorManagement.workingColorSpace!==m.LinearSRGBColorSpace&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${m.ColorManagement.workingColorSpace}" not supported.`),wn(o,e),ed(o,e,n),Promise.all(s).then(function(){return e.targets!==void 0?Kh(o,e.targets,n):o})}(function(){try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode(".gizmo-default{width:100px;height:100px;position:absolute;top:0;right:0;z-index:2;cursor:pointer}")),document.head.appendChild(o)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var Ra={exports:{}},vi={};/**
|
|
31
|
-
* @license React
|
|
32
|
-
* react-jsx-runtime.production.min.js
|
|
33
|
-
*
|
|
34
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
35
|
-
*
|
|
36
|
-
* This source code is licensed under the MIT license found in the
|
|
37
|
-
* LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/var Dc;function td(){if(Dc)return vi;Dc=1;var o=le,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function a(u,f,p){var v,g={},h=null,b=null;p!==void 0&&(h=""+p),f.key!==void 0&&(h=""+f.key),f.ref!==void 0&&(b=f.ref);for(v in f)i.call(f,v)&&!c.hasOwnProperty(v)&&(g[v]=f[v]);if(u&&u.defaultProps)for(v in f=u.defaultProps,f)g[v]===void 0&&(g[v]=f[v]);return{$$typeof:e,type:u,key:h,ref:b,props:g,_owner:s.current}}return vi.Fragment=n,vi.jsx=a,vi.jsxs=a,vi}var ts={};/**
|
|
39
|
-
* @license React
|
|
40
|
-
* react-jsx-runtime.development.js
|
|
41
|
-
*
|
|
42
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the MIT license found in the
|
|
45
|
-
* LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/var Fc;function nd(){return Fc||(Fc=1,process.env.NODE_ENV!=="production"&&function(){var o=le,e=Symbol.for("react.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),R=Symbol.iterator,M="@@iterator";function x(y){if(y===null||typeof y!="object")return null;var D=R&&y[R]||y[M];return typeof D=="function"?D:null}var A=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(y){{for(var D=arguments.length,z=new Array(D>1?D-1:0),X=1;X<D;X++)z[X-1]=arguments[X];C("error",y,z)}}function C(y,D,z){{var X=A.ReactDebugCurrentFrame,re=X.getStackAddendum();re!==""&&(D+="%s",z=z.concat([re]));var ae=z.map(function(te){return String(te)});ae.unshift("Warning: "+D),Function.prototype.apply.call(console[y],console,ae)}}var P=!1,O=!1,B=!1,k=!1,q=!1,j;j=Symbol.for("react.module.reference");function K(y){return!!(typeof y=="string"||typeof y=="function"||y===i||y===c||q||y===s||y===p||y===v||k||y===b||P||O||B||typeof y=="object"&&y!==null&&(y.$$typeof===h||y.$$typeof===g||y.$$typeof===a||y.$$typeof===u||y.$$typeof===f||y.$$typeof===j||y.getModuleId!==void 0))}function $(y,D,z){var X=y.displayName;if(X)return X;var re=D.displayName||D.name||"";return re!==""?z+"("+re+")":z}function H(y){return y.displayName||"Context"}function Z(y){if(y==null)return null;if(typeof y.tag=="number"&&E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof y=="function")return y.displayName||y.name||null;if(typeof y=="string")return y;switch(y){case i:return"Fragment";case n:return"Portal";case c:return"Profiler";case s:return"StrictMode";case p:return"Suspense";case v:return"SuspenseList"}if(typeof y=="object")switch(y.$$typeof){case u:var D=y;return H(D)+".Consumer";case a:var z=y;return H(z._context)+".Provider";case f:return $(y,y.render,"ForwardRef");case g:var X=y.displayName||null;return X!==null?X:Z(y.type)||"Memo";case h:{var re=y,ae=re._payload,te=re._init;try{return Z(te(ae))}catch{return null}}}return null}var Q=Object.assign,ce=0,Re,ke,Ie,et,vt,je,mn;function gn(){}gn.__reactDisabledLog=!0;function Kn(){{if(ce===0){Re=console.log,ke=console.info,Ie=console.warn,et=console.error,vt=console.group,je=console.groupCollapsed,mn=console.groupEnd;var y={configurable:!0,enumerable:!0,value:gn,writable:!0};Object.defineProperties(console,{info:y,log:y,warn:y,error:y,group:y,groupCollapsed:y,groupEnd:y})}ce++}}function Lt(){{if(ce--,ce===0){var y={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Q({},y,{value:Re}),info:Q({},y,{value:ke}),warn:Q({},y,{value:Ie}),error:Q({},y,{value:et}),group:Q({},y,{value:vt}),groupCollapsed:Q({},y,{value:je}),groupEnd:Q({},y,{value:mn})})}ce<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Se=A.ReactCurrentDispatcher,Ke;function De(y,D,z){{if(Ke===void 0)try{throw Error()}catch(re){var X=re.stack.trim().match(/\n( *(at )?)/);Ke=X&&X[1]||""}return`
|
|
47
|
-
`+Ke+y}}var Te=!1,Ze;{var an=typeof WeakMap=="function"?WeakMap:Map;Ze=new an}function yt(y,D){if(!y||Te)return"";{var z=Ze.get(y);if(z!==void 0)return z}var X;Te=!0;var re=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ae;ae=Se.current,Se.current=null,Kn();try{if(D){var te=function(){throw Error()};if(Object.defineProperty(te.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(te,[])}catch(Ce){X=Ce}Reflect.construct(y,[],te)}else{try{te.call()}catch(Ce){X=Ce}y.call(te.prototype)}}else{try{throw Error()}catch(Ce){X=Ce}y()}}catch(Ce){if(Ce&&X&&typeof Ce.stack=="string"){for(var ee=Ce.stack.split(`
|
|
48
|
-
`),Pe=X.stack.split(`
|
|
49
|
-
`),pe=ee.length-1,ge=Pe.length-1;pe>=1&&ge>=0&&ee[pe]!==Pe[ge];)ge--;for(;pe>=1&&ge>=0;pe--,ge--)if(ee[pe]!==Pe[ge]){if(pe!==1||ge!==1)do if(pe--,ge--,ge<0||ee[pe]!==Pe[ge]){var Ue=`
|
|
50
|
-
`+ee[pe].replace(" at new "," at ");return y.displayName&&Ue.includes("<anonymous>")&&(Ue=Ue.replace("<anonymous>",y.displayName)),typeof y=="function"&&Ze.set(y,Ue),Ue}while(pe>=1&&ge>=0);break}}}finally{Te=!1,Se.current=ae,Lt(),Error.prepareStackTrace=re}var at=y?y.displayName||y.name:"",ut=at?De(at):"";return typeof y=="function"&&Ze.set(y,ut),ut}function Nt(y,D,z){return yt(y,!1)}function ct(y){var D=y.prototype;return!!(D&&D.isReactComponent)}function lt(y,D,z){if(y==null)return"";if(typeof y=="function")return yt(y,ct(y));if(typeof y=="string")return De(y);switch(y){case p:return De("Suspense");case v:return De("SuspenseList")}if(typeof y=="object")switch(y.$$typeof){case f:return Nt(y.render);case g:return lt(y.type,D,z);case h:{var X=y,re=X._payload,ae=X._init;try{return lt(ae(re),D,z)}catch{}}}return""}var _t=Object.prototype.hasOwnProperty,st={},Xn=A.ReactDebugCurrentFrame;function on(y){if(y){var D=y._owner,z=lt(y.type,y._source,D?D.type:null);Xn.setExtraStackFrame(z)}else Xn.setExtraStackFrame(null)}function En(y,D,z,X,re){{var ae=Function.call.bind(_t);for(var te in y)if(ae(y,te)){var ee=void 0;try{if(typeof y[te]!="function"){var Pe=Error((X||"React class")+": "+z+" type `"+te+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof y[te]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Pe.name="Invariant Violation",Pe}ee=y[te](D,te,X,z,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){ee=pe}ee&&!(ee instanceof Error)&&(on(re),E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",X||"React class",z,te,typeof ee),on(null)),ee instanceof Error&&!(ee.message in st)&&(st[ee.message]=!0,on(re),E("Failed %s type: %s",z,ee.message),on(null))}}}var xt=Array.isArray;function Bt(y){return xt(y)}function Zn(y){{var D=typeof Symbol=="function"&&Symbol.toStringTag,z=D&&y[Symbol.toStringTag]||y.constructor.name||"Object";return z}}function Mi(y){try{return cn(y),!1}catch{return!0}}function cn(y){return""+y}function pr(y){if(Mi(y))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Zn(y)),cn(y)}var ln=A.ReactCurrentOwner,vn={key:!0,ref:!0,__self:!0,__source:!0},Sn,Mn;function mr(y){if(_t.call(y,"ref")){var D=Object.getOwnPropertyDescriptor(y,"ref").get;if(D&&D.isReactWarning)return!1}return y.ref!==void 0}function gr(y){if(_t.call(y,"key")){var D=Object.getOwnPropertyDescriptor(y,"key").get;if(D&&D.isReactWarning)return!1}return y.key!==void 0}function vr(y,D){typeof y.ref=="string"&&ln.current}function yr(y,D){{var z=function(){Sn||(Sn=!0,E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",D))};z.isReactWarning=!0,Object.defineProperty(y,"key",{get:z,configurable:!0})}}function _r(y,D){{var z=function(){Mn||(Mn=!0,E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",D))};z.isReactWarning=!0,Object.defineProperty(y,"ref",{get:z,configurable:!0})}}var xr=function(y,D,z,X,re,ae,te){var ee={$$typeof:e,type:y,key:D,ref:z,props:te,_owner:ae};return ee._store={},Object.defineProperty(ee._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ee,"_self",{configurable:!1,enumerable:!1,writable:!1,value:X}),Object.defineProperty(ee,"_source",{configurable:!1,enumerable:!1,writable:!1,value:re}),Object.freeze&&(Object.freeze(ee.props),Object.freeze(ee)),ee};function br(y,D,z,X,re){{var ae,te={},ee=null,Pe=null;z!==void 0&&(pr(z),ee=""+z),gr(D)&&(pr(D.key),ee=""+D.key),mr(D)&&(Pe=D.ref,vr(D,re));for(ae in D)_t.call(D,ae)&&!vn.hasOwnProperty(ae)&&(te[ae]=D[ae]);if(y&&y.defaultProps){var pe=y.defaultProps;for(ae in pe)te[ae]===void 0&&(te[ae]=pe[ae])}if(ee||Pe){var ge=typeof y=="function"?y.displayName||y.name||"Unknown":y;ee&&yr(te,ge),Pe&&_r(te,ge)}return xr(y,ee,Pe,re,X,ln.current,te)}}var Cn=A.ReactCurrentOwner,Tr=A.ReactDebugCurrentFrame;function bt(y){if(y){var D=y._owner,z=lt(y.type,y._source,D?D.type:null);Tr.setExtraStackFrame(z)}else Tr.setExtraStackFrame(null)}var yn;yn=!1;function _n(y){return typeof y=="object"&&y!==null&&y.$$typeof===e}function wr(){{if(Cn.current){var y=Z(Cn.current.type);if(y)return`
|
|
51
|
-
|
|
52
|
-
Check the render method of \``+y+"`."}return""}}function Ci(y){return""}var Rr={};function Ii(y){{var D=wr();if(!D){var z=typeof y=="string"?y:y.displayName||y.name;z&&(D=`
|
|
53
|
-
|
|
54
|
-
Check the top-level render call using <`+z+">.")}return D}}function $n(y,D){{if(!y._store||y._store.validated||y.key!=null)return;y._store.validated=!0;var z=Ii(D);if(Rr[z])return;Rr[z]=!0;var X="";y&&y._owner&&y._owner!==Cn.current&&(X=" It was passed a child from "+Z(y._owner.type)+"."),bt(y),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',z,X),bt(null)}}function Ar(y,D){{if(typeof y!="object")return;if(Bt(y))for(var z=0;z<y.length;z++){var X=y[z];_n(X)&&$n(X,D)}else if(_n(y))y._store&&(y._store.validated=!0);else if(y){var re=x(y);if(typeof re=="function"&&re!==y.entries)for(var ae=re.call(y),te;!(te=ae.next()).done;)_n(te.value)&&$n(te.value,D)}}}function Pi(y){{var D=y.type;if(D==null||typeof D=="string")return;var z;if(typeof D=="function")z=D.propTypes;else if(typeof D=="object"&&(D.$$typeof===f||D.$$typeof===g))z=D.propTypes;else return;if(z){var X=Z(D);En(z,y.props,"prop",X,y)}else if(D.PropTypes!==void 0&&!yn){yn=!0;var re=Z(D);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",re||"Unknown")}typeof D.getDefaultProps=="function"&&!D.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Di(y){{for(var D=Object.keys(y.props),z=0;z<D.length;z++){var X=D[z];if(X!=="children"&&X!=="key"){bt(y),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",X),bt(null);break}}y.ref!==null&&(bt(y),E("Invalid attribute `ref` supplied to `React.Fragment`."),bt(null))}}var In={};function Er(y,D,z,X,re,ae){{var te=K(y);if(!te){var ee="";(y===void 0||typeof y=="object"&&y!==null&&Object.keys(y).length===0)&&(ee+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Pe=Ci();Pe?ee+=Pe:ee+=wr();var pe;y===null?pe="null":Bt(y)?pe="array":y!==void 0&&y.$$typeof===e?(pe="<"+(Z(y.type)||"Unknown")+" />",ee=" Did you accidentally export a JSX literal instead of a component?"):pe=typeof y,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",pe,ee)}var ge=br(y,D,z,re,ae);if(ge==null)return ge;if(te){var Ue=D.children;if(Ue!==void 0)if(X)if(Bt(Ue)){for(var at=0;at<Ue.length;at++)Ar(Ue[at],y);Object.freeze&&Object.freeze(Ue)}else E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ar(Ue,y)}if(_t.call(D,"key")){var ut=Z(y),Ce=Object.keys(D).filter(function(Bi){return Bi!=="key"}),Pn=Ce.length>0?"{key: someKey, "+Ce.join(": ..., ")+": ...}":"{key: someKey}";if(!In[ut+Pn]){var Ni=Ce.length>0?"{"+Ce.join(": ..., ")+": ...}":"{}";E(`A props object containing a "key" prop is being spread into JSX:
|
|
55
|
-
let props = %s;
|
|
56
|
-
<%s {...props} />
|
|
57
|
-
React keys must be passed directly to JSX without using spread:
|
|
58
|
-
let props = %s;
|
|
59
|
-
<%s key={someKey} {...props} />`,Pn,ut,Ni,ut),In[ut+Pn]=!0}}return y===i?Di(ge):Pi(ge),ge}}function Sr(y,D,z){return Er(y,D,z,!0)}function Fi(y,D,z){return Er(y,D,z,!1)}var Oi=Fi,Li=Sr;ts.Fragment=i,ts.jsx=Oi,ts.jsxs=Li}()),ts}process.env.NODE_ENV==="production"?Ra.exports=td():Ra.exports=nd();var rd=Ra.exports;const id=(o,e,n,i,s,c)=>{const a=performance.now(),u=()=>{const f=performance.now()-a,p=Math.min(f/s,1);o.position.lerpVectors(n,i,p),e==null||e.update(),c(),p<1&&requestAnimationFrame(u)};requestAnimationFrame(u)},Oc=(o,e)=>{o.quaternion.copy(e.quaternion);const n=new N.Vector3(0,0,-1).applyQuaternion(o.quaternion).normalize();o.position.copy(n.multiplyScalar(-8)),o.lookAt(new N.Vector3(0,0,0)),o.updateMatrixWorld(!0)},sd=(o,e,n)=>{const i=n.target.clone(),s=o.position.clone().sub(i).length(),c=new N.Vector3(0,0,-1).applyQuaternion(e.quaternion).normalize().multiplyScalar(-s);o.position.copy(i).add(c),o.quaternion.copy(e.quaternion),o.updateMatrixWorld(!0),n.update()},ad=()=>{try{const o=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(o.getContext("webgl")||o.getContext("experimental-webgl")))}catch{return!1}},od=()=>ad()?new N.WebGLRenderer({alpha:!0,antialias:!1}):(console.error("WebGL is not supported in this environment."),null),Lc={type:"change"},Aa={type:"start"},Nc={type:"end"},ns=new m.Ray,Bc=new m.Plane,cd=Math.cos(70*m.MathUtils.DEG2RAD),tt=new m.Vector3,At=2*Math.PI,Ne={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ea=1e-6;class ld extends m.Controls{constructor(e,n=null){super(e,n),this.state=Ne.NONE,this.enabled=!0,this.target=new m.Vector3,this.cursor=new m.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:m.MOUSE.ROTATE,MIDDLE:m.MOUSE.DOLLY,RIGHT:m.MOUSE.PAN},this.touches={ONE:m.TOUCH.ROTATE,TWO:m.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new m.Vector3,this._lastQuaternion=new m.Quaternion,this._lastTargetPosition=new m.Vector3,this._quat=new m.Quaternion().setFromUnitVectors(e.up,new m.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new m.Spherical,this._sphericalDelta=new m.Spherical,this._scale=1,this._panOffset=new m.Vector3,this._rotateStart=new m.Vector2,this._rotateEnd=new m.Vector2,this._rotateDelta=new m.Vector2,this._panStart=new m.Vector2,this._panEnd=new m.Vector2,this._panDelta=new m.Vector2,this._dollyStart=new m.Vector2,this._dollyEnd=new m.Vector2,this._dollyDelta=new m.Vector2,this._dollyDirection=new m.Vector3,this._mouse=new m.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=fd.bind(this),this._onPointerDown=ud.bind(this),this._onPointerUp=hd.bind(this),this._onContextMenu=_d.bind(this),this._onMouseWheel=md.bind(this),this._onKeyDown=gd.bind(this),this._onTouchStart=vd.bind(this),this._onTouchMove=yd.bind(this),this._onMouseDown=dd.bind(this),this._onMouseMove=pd.bind(this),this._interceptControlDown=xd.bind(this),this._interceptControlUp=bd.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Lc),this.update(),this.state=Ne.NONE}update(e=null){const n=this.object.position;tt.copy(n).sub(this.target),tt.applyQuaternion(this._quat),this._spherical.setFromVector3(tt),this.autoRotate&&this.state===Ne.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=At:i>Math.PI&&(i-=At),s<-Math.PI?s+=At:s>Math.PI&&(s-=At),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let c=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),c=a!=this._spherical.radius}if(tt.setFromSpherical(this._spherical),tt.applyQuaternion(this._quatInverse),n.copy(this.target).add(tt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const u=tt.length();a=this._clampDistance(u*this._scale);const f=u-a;this.object.position.addScaledVector(this._dollyDirection,f),this.object.updateMatrixWorld(),c=!!f}else if(this.object.isOrthographicCamera){const u=new m.Vector3(this._mouse.x,this._mouse.y,0);u.unproject(this.object);const f=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),c=f!==this.object.zoom;const p=new m.Vector3(this._mouse.x,this._mouse.y,0);p.unproject(this.object),this.object.position.sub(p).add(u),this.object.updateMatrixWorld(),a=tt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(ns.origin.copy(this.object.position),ns.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ns.direction))<cd?this.object.lookAt(this.target):(Bc.setFromNormalAndCoplanarPoint(this.object.up,this.target),ns.intersectPlane(Bc,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),c=!0)}return this._scale=1,this._performCursorZoom=!1,c||this._lastPosition.distanceToSquared(this.object.position)>Ea||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ea||this._lastTargetPosition.distanceToSquared(this.target)>Ea?(this.dispatchEvent(Lc),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?At/60*this.autoRotateSpeed*e:At/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){tt.setFromMatrixColumn(n,0),tt.multiplyScalar(-e),this._panOffset.add(tt)}_panUp(e,n){this.screenSpacePanning===!0?tt.setFromMatrixColumn(n,1):(tt.setFromMatrixColumn(n,0),tt.crossVectors(this.object.up,tt)),tt.multiplyScalar(e),this._panOffset.add(tt)}_pan(e,n){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;tt.copy(s).sub(this.target);let c=tt.length();c*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*c/i.clientHeight,this.object.matrix),this._panUp(2*n*c/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,c=n-i.top,a=i.width,u=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(c/u)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(At*this._rotateDelta.x/n.clientHeight),this._rotateUp(At*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(At*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-At*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(At*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-At*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),i=e.pageX-n.x,s=e.pageY-n.y,c=Math.sqrt(i*i+s*s);this._dollyStart.set(0,c)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),c=.5*(e.pageY+i.y);this._rotateEnd.set(s,c)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(At*this._rotateDelta.x/n.clientHeight),this._rotateUp(At*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),i=e.pageX-n.x,s=e.pageY-n.y,c=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,c),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+n.x)*.5,u=(e.pageY+n.y)*.5;this._updateZoomParameters(a,u)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new m.Vector2,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function ud(o){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(o)&&(this._addPointer(o),o.pointerType==="touch"?this._onTouchStart(o):this._onMouseDown(o)))}function fd(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function hd(o){switch(this._removePointer(o),this._pointers.length){case 0:this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Nc),this.state=Ne.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function dd(o){let e;switch(o.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case m.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=Ne.DOLLY;break;case m.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=Ne.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=Ne.ROTATE}break;case m.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=Ne.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=Ne.PAN}break;default:this.state=Ne.NONE}this.state!==Ne.NONE&&this.dispatchEvent(Aa)}function pd(o){switch(this.state){case Ne.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case Ne.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case Ne.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function md(o){this.enabled===!1||this.enableZoom===!1||this.state!==Ne.NONE||(o.preventDefault(),this.dispatchEvent(Aa),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(Nc))}function gd(o){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(o)}function vd(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case m.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=Ne.TOUCH_ROTATE;break;case m.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=Ne.TOUCH_PAN;break;default:this.state=Ne.NONE}break;case 2:switch(this.touches.TWO){case m.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=Ne.TOUCH_DOLLY_PAN;break;case m.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=Ne.TOUCH_DOLLY_ROTATE;break;default:this.state=Ne.NONE}break;default:this.state=Ne.NONE}this.state!==Ne.NONE&&this.dispatchEvent(Aa)}function yd(o){switch(this._trackPointer(o),this.state){case Ne.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case Ne.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case Ne.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case Ne.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=Ne.NONE}}function _d(o){this.enabled!==!1&&o.preventDefault()}function xd(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function bd(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Td=o=>{const e=new N.AmbientLight(16777215,1);o.add(e);const n=new N.DirectionalLight(16777215,1);n.position.set(5,10,5),o.add(n);const i=new N.DirectionalLight(16777215,1);i.position.set(-5,-10,5),o.add(i);const s=new N.PointLight(16777215,1,100);s.position.set(0,0,5),o.add(s),n.castShadow=!1,i.castShadow=!1,s.castShadow=!1},Ee={CUBE_SIZE:1.8,EDGE_SECTION_SIZE:.35,FACE_THICKNESS:.35,CANVAS_SIZE:256,FONT_SIZE:"62px",TEXT_COLOR:"#000000",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",FACE_COLOR:"#EFF3F2",EDGE_COLOR:"#EFF3F2",CORNER_COLOR:"#EFF3F2",LINE_COLOR:0};var Gn=(o=>(o.FRONT="FRONT",o.BACK="BACK",o.RIGHT="RIGHT",o.LEFT="LEFT",o.TOP="TOP",o.BOTTOM="BOTTOM",o))(Gn||{});new N.Vector3(0,1,0);class wd{static createTextTexture(e){const n=document.createElement("canvas"),i=n.getContext("2d");n.width=Ee.CANVAS_SIZE,n.height=Ee.CANVAS_SIZE,i&&(i.clearRect(0,0,n.width,n.height),i.font=`${Ee.FONT_SIZE} Arial`,i.fillStyle=Ee.TEXT_COLOR,i.textAlign=Ee.TEXT_ALIGN,i.textBaseline=Ee.TEXT_BASELINE,i.fillText(e,n.width/2,n.height/2));const s=new N.CanvasTexture(n);return s.needsUpdate=!0,s}}class rs{static createWireframe([e,n,i]){const s=new N.BoxGeometry(e,n,i),c=new N.EdgesGeometry(s),a=new N.LineBasicMaterial({color:Ee.LINE_COLOR}),u=new N.LineSegments(c,a);return u.name="Wireframe",u}static createEdgeBox(e,n,i){const s=Ee.CUBE_SIZE-Ee.EDGE_SECTION_SIZE,c={x:Ee.EDGE_SECTION_SIZE,y:Ee.EDGE_SECTION_SIZE,z:Ee.EDGE_SECTION_SIZE};c[n]=s;const a=new N.BoxGeometry(c.x,c.y,c.z),u=new N.MeshStandardMaterial({color:Ee.EDGE_COLOR}),f=new N.Mesh(a,u);return f.position.copy(e),f.name=`Edge Box ${i}`,f}static createCornerCube(e,n){const i=new N.BoxGeometry(Ee.EDGE_SECTION_SIZE,Ee.EDGE_SECTION_SIZE,Ee.EDGE_SECTION_SIZE),s=new N.MeshStandardMaterial({color:Ee.CORNER_COLOR}),c=new N.Mesh(i,s);return c.position.copy(e),c.name=`Corner Cube ${n}`,c}static createFace(e,n,i){const s=new N.Group,c=new N.BoxGeometry(Ee.CUBE_SIZE-Ee.EDGE_SECTION_SIZE,Ee.CUBE_SIZE-Ee.EDGE_SECTION_SIZE,Ee.FACE_THICKNESS),a=new N.MeshStandardMaterial({color:Ee.FACE_COLOR}),u=new N.Mesh(c,a);u.name=`Face Box ${i}`,s.add(u);const f=new N.PlaneGeometry(Ee.CUBE_SIZE-Ee.EDGE_SECTION_SIZE,Ee.CUBE_SIZE-Ee.EDGE_SECTION_SIZE),p=new N.MeshStandardMaterial({map:wd.createTextTexture(i),transparent:!0,depthWrite:!1}),v=new N.Mesh(f,p);return v.position.set(0,0,Ee.FACE_THICKNESS/2+.01),s.add(v),s.position.copy(e),s.rotation.copy(n),s}}const Rd=(o,e)=>{const n=document.createElement("canvas");n.width=64,n.height=64;const i=n.getContext("2d");i.fillStyle="rgba(0, 0, 0, 0)",i.fillRect(0,0,n.width,n.height),i.font="Bold 48px Arial",i.fillStyle=`#${e.toString(16).padStart(6,"0")}`,i.textAlign="center",i.textBaseline="middle",i.fillText(o,n.width/2,n.height/2);const s=new N.CanvasTexture(n),c=new N.SpriteMaterial({map:s}),a=new N.Sprite(c);return a.scale.set(.5,.5,.5),a};class Ad{constructor(e){this.hoveredObject=null,this.originalColor=null,this.config=e}get vectorToCube(){var e;return(e=this.hoveredObject)==null?void 0:e.userData.vectorToCube}getInitialRotation(){switch(this.config.initialFace){case Gn.BACK:return new N.Euler(0,Math.PI,0);case Gn.RIGHT:return new N.Euler(0,-Math.PI/2,0);case Gn.LEFT:return new N.Euler(0,Math.PI/2,0);case Gn.TOP:return new N.Euler(Math.PI/2,0,0);case Gn.BOTTOM:return new N.Euler(-Math.PI/2,0,0);case Gn.FRONT:default:return new N.Euler(0,0,0)}}createWireframe(){const e=Ee.CUBE_SIZE+Ee.EDGE_SECTION_SIZE,n=rs.createWireframe([e,e,e]);return n.userData.gizmoCube=this,n}createEdgeBox(e,n,i){const s=rs.createEdgeBox(e,n,i);return s.userData.gizmoCube=this,s}createCornerCube(e,n){const i=rs.createCornerCube(e,n);return i.userData.gizmoCube=this,i}createFace(e,n,i){const s=rs.createFace(e,n,i),c=s.getObjectByName(`Face Box ${i}`);return c.userData.gizmoCube=this,s}createEdges(e){const n=Ee.CUBE_SIZE/2;[{axis:"x",pos:new N.Vector3(0,n,-n)},{axis:"x",pos:new N.Vector3(0,n,n)},{axis:"x",pos:new N.Vector3(0,-n,-n)},{axis:"x",pos:new N.Vector3(0,-n,n)},{axis:"y",pos:new N.Vector3(n,0,-n)},{axis:"y",pos:new N.Vector3(n,0,n)},{axis:"y",pos:new N.Vector3(-n,0,-n)},{axis:"y",pos:new N.Vector3(-n,0,n)},{axis:"z",pos:new N.Vector3(n,n,0)},{axis:"z",pos:new N.Vector3(n,-n,0)},{axis:"z",pos:new N.Vector3(-n,n,0)},{axis:"z",pos:new N.Vector3(-n,-n,0)}].forEach(({axis:i,pos:s},c)=>{const a=this.createEdgeBox(s,i,c+1);e.add(a)})}createCorners(e){const n=Ee.CUBE_SIZE/2;[new N.Vector3(-n,-n,-n),new N.Vector3(-n,-n,n),new N.Vector3(-n,n,-n),new N.Vector3(-n,n,n),new N.Vector3(n,-n,-n),new N.Vector3(n,-n,n),new N.Vector3(n,n,-n),new N.Vector3(n,n,n)].forEach((i,s)=>{const c=this.createCornerCube(i,s+1);e.add(c)})}createFaces(e){const n=Ee.CUBE_SIZE/2;[{pos:new N.Vector3(0,0,n),rotation:new N.Euler(0,0,0),label:"FRONT"},{pos:new N.Vector3(0,0,-n),rotation:new N.Euler(0,Math.PI,0),label:"BACK"},{pos:new N.Vector3(n,0,0),rotation:new N.Euler(0,Math.PI/2,0),label:"RIGHT"},{pos:new N.Vector3(-n,0,0),rotation:new N.Euler(0,-Math.PI/2,0),label:"LEFT"},{pos:new N.Vector3(0,n,0),rotation:new N.Euler(-Math.PI/2,0,0),label:"TOP"},{pos:new N.Vector3(0,-n,0),rotation:new N.Euler(Math.PI/2,0,0),label:"BOTTOM"}].forEach(({pos:i,rotation:s,label:c})=>{const a=this.createFace(i,s,c);e.add(a)})}createAxis(e){const{color:n,direction:i,length:s,origin:c,lineWidth:a,label:u}=e,f=new N.Group,p=a/2,v=new N.CylinderGeometry(p,p,s,32),g=new N.MeshBasicMaterial({color:n}),h=new N.Mesh(v,g);if(h.position.copy(c).add(i.clone().multiplyScalar(s/2)),!i.equals(new N.Vector3(0,1,0))){const R=new N.Vector3(0,1,0).cross(i).normalize(),M=Math.acos(new N.Vector3(0,1,0).dot(i));h.setRotationFromAxisAngle(R,M)}f.add(h);const b=Rd(u,n);return b.position.copy(c).add(i.clone().multiplyScalar(s+.1)),f.add(b),f}createCoordinateAxes(){const e=new N.Group,n=Ee.CUBE_SIZE,i=Ee.EDGE_SECTION_SIZE,s=-1.075,c=u=>{const f=new N.Vector3(1,1,1);return new N.Vector3(u,u,u).add(f.clone().normalize().negate().multiplyScalar(.04))},a=n+1.25*i;return[{color:16711680,direction:new N.Vector3(1,0,0),length:a,origin:c(s),lineWidth:.04,label:"X"},{color:65280,direction:new N.Vector3(0,1,0),length:a,origin:c(s),lineWidth:.04,label:"Y"},{color:255,direction:new N.Vector3(0,0,1),length:a,origin:c(s),lineWidth:.04,label:"Z"}].forEach(u=>{const f=this.createAxis(u);e.add(f)}),e}create(){const e=new N.Group;e.name="Gizmo Group";const n=this.createWireframe();e.add(n),this.createEdges(e),this.createCorners(e),this.createFaces(e);const i=this.createCoordinateAxes();e.add(i);const s=this.getInitialRotation();return e.setRotationFromEuler(s),e}highlightObject(e){if(this.hoveredObject!==e)if(this.hoveredObject&&this.originalColor&&this.hoveredObject.material.color.set(this.originalColor),e&&e instanceof N.Mesh){const n=e.material;this.hoveredObject=e,this.originalColor=n.color.clone(),n.color.set(11519973)}else this.hoveredObject=null,this.originalColor=null}handleClick(){if(this.hoveredObject){let e=new N.Vector3;e=this.hoveredObject.getWorldPosition(e).clone();const n=new N.Vector3(0,0,0),i=e.sub(n).normalize();this.hoveredObject.userData.vectorToCube=i}}}class Ed{constructor(e){this.onChangeMainControlsListener=()=>{},this.onChangeGizmoControlsListener=()=>{},this.animationId=0;const{gizmoParams:n,mainParams:i,syncFunctions:s,options:c}=e;this.gizmoDiv=n.gizmoDiv,this.gizmoScene=n.gizmoScene,this.gizmoRenderer=n.gizmoRenderer,this.gizmoCamera=n.gizmoCamera,this.mainCamera=i.mainCamera,this.mainControls=i.mainControls,this.renderGizmo=i.renderGizmo,this.syncFunctions=s,this.options=c,this.gizmoControls=new ld(this.gizmoCamera,this.gizmoRenderer.domElement),this.initializeRenderer(),this.initializeScene(),this.initializeControls(),this.startAnimationLoop()}initializeRenderer(){this.gizmoRenderer.setPixelRatio(window.devicePixelRatio),this.gizmoRenderer.setSize(this.gizmoDiv.clientWidth,this.gizmoDiv.clientHeight),this.gizmoDiv.appendChild(this.gizmoRenderer.domElement)}initializeScene(){var e;const n=new Ad({initialFace:((e=this.options)==null?void 0:e.initialFace)??Gn.FRONT}).create();n&&this.gizmoScene.add(n),Td(this.gizmoScene)}initializeControls(){this.onChangeMainControlsListener=()=>this.syncFunctions.syncGizmoCameraWithMain(this.gizmoCamera,this.mainCamera),this.mainControls.addEventListener("change",this.onChangeMainControlsListener),this.gizmoControls.enableZoom=!1,this.gizmoControls.enablePan=!1,this.gizmoControls.rotateSpeed=.5,this.gizmoControls.update(),this.onChangeGizmoControlsListener=()=>{this.syncFunctions.syncMainCameraWithGizmo(this.mainCamera,this.gizmoCamera,this.mainControls),this.renderGizmo()},this.gizmoControls.addEventListener("change",this.onChangeGizmoControlsListener)}startAnimationLoop(){const e=()=>{this.gizmoRenderer.render(this.gizmoScene,this.gizmoCamera)},n=()=>{this.animationId=requestAnimationFrame(n),e()};n()}dispose(){this.mainControls.removeEventListener("change",this.onChangeMainControlsListener),this.gizmoControls.removeEventListener("change",this.onChangeGizmoControlsListener),this.gizmoScene.clear(),cancelAnimationFrame(this.animationId)}}const Sd=(o,e)=>{let n;return function(...i){n||(o.apply(this,i),n=!0,setTimeout(()=>n=!1,e))}};function kc(o,e,n){if(!e)return;const i=e.domElement.getBoundingClientRect();n.x=(o.clientX-i.left)/i.width*2-1,n.y=-((o.clientY-i.top)/i.height)*2+1}function Uc(o,e,n,i){var s;if(!e||!n)return null;i.setFromCamera(o,e);const c=i.intersectObjects(n.children,!0),a=["Wireframe",""];return((s=c.find(u=>!a.includes(u.object.name)))==null?void 0:s.object)||null}function Md(o,e){const n=o==null?void 0:o.userData.gizmoCube;if(o&&n){n.handleClick();const i=n.vectorToCube;i&&e(i)}}const Cd=25,Id=200;function Pd({gizmoRenderer:o,gizmoScene:e,gizmoCamera:n,alignCameraWithVector:i,gizmoControlRef:s}){const c=le.useRef(null),a=le.useRef(null),u=le.useRef(new N.Raycaster).current,f=le.useRef(new N.Vector2).current,p=le.useCallback(Sd(h=>{if(!s.current||!o)return;kc(h,o,f);const b=Uc(f,n,e,u);b!=null&&b.userData.gizmoCube?b.userData.gizmoCube.highlightObject(b):e.traverse(R=>{R.userData.gizmoCube&&R.userData.gizmoCube.highlightObject(null)})},1e3/Cd),[s,o,n,e,u,f]),v=le.useCallback(h=>{c.current=Date.now(),a.current={x:h.clientX,y:h.clientY}},[]),g=le.useCallback(h=>{if((c.current?Date.now()-c.current:0)<Id){kc(h,o,f);const b=Uc(f,n,e,u);Md(b,i)}c.current=null,a.current=null},[i,o,n,e,u,f]);return{onMouseDown:v,onMouseMove:p,onMouseUp:g}}const Dd=({camera:o,controls:e,className:n,render:i,options:s})=>{const c=le.useRef(null),a=le.useRef(new N.Scene).current,[u]=le.useState(()=>od()),f=30,p=1,v=.1,g=10,h=new N.PerspectiveCamera(f,p,v,g),b=le.useRef(h).current,R=le.useRef(null),M=le.useCallback(()=>{u&&(i(),u.render(a,b))},[i,u,a,b]),x=le.useCallback(P=>{if(!o||!e)return;const O=o.position.length(),B=P.clone().multiplyScalar(O);id(o,e,o.position.clone(),B,400,M),o.lookAt(new N.Vector3(0,0,0)),o.up.set(0,1,0),e.target.set(0,0,0)},[o,e,M]),{onMouseDown:A,onMouseMove:E,onMouseUp:C}=Pd({gizmoRenderer:u,gizmoScene:a,gizmoCamera:b,alignCameraWithVector:x,gizmoControlRef:R});return le.useEffect(()=>{const P=c.current;if(!P||!o||!e||!u)return;R.current&&R.current.dispose();const O={gizmoDiv:P,gizmoScene:a,gizmoRenderer:u,gizmoCamera:b},B={mainCamera:o,mainControls:e,renderGizmo:M},k={syncGizmoCameraWithMain:Oc,syncMainCameraWithGizmo:sd};return R.current=new Ed({gizmoParams:O,mainParams:B,syncFunctions:k,options:s}),P.addEventListener("mousedown",A),P.addEventListener("mousemove",E),P.addEventListener("mouseup",C),()=>{R.current&&(R.current.dispose(),R.current=null),P.removeEventListener("mousedown",A),P.removeEventListener("mousemove",E),P.removeEventListener("mouseup",C)}},[o,e,M,E,A,C]),le.useEffect(()=>{o&&(Oc(b,o),M())},[o,M]),rd.jsx("div",{className:n?`${n}`:"gizmo-default",ref:c})},zc=(o,e,n)=>new Promise((i,s)=>{e.load(o,c=>{const a=c.scene;i(a)},void 0,c=>{console.error("An error occurred while loading the model:",c),s(c)})}),Fd=(o,e,n)=>{window.removeEventListener("resize",n),o.current&&e&&o.current.removeChild(e.domElement)},Od=1e3/50;class oe extends Error{constructor(e,n,i){super(e),this.code=n,this.context=i,this.name="ThreeViewerError",this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,oe)}static fromError(e,n,i){if(e instanceof oe)return e;const s=e instanceof Error?e.message:String(e),c={...i,originalError:e instanceof Error?{name:e.name,message:e.message,stack:e.stack}:e};return new oe(s,n,c)}}var ue=(o=>(o.SCENE_INIT_FAILED="SCENE_INIT_FAILED",o.RENDERER_INIT_FAILED="RENDERER_INIT_FAILED",o.CAMERA_INIT_FAILED="CAMERA_INIT_FAILED",o.WEBGL_NOT_SUPPORTED="WEBGL_NOT_SUPPORTED",o.MODEL_LOAD_FAILED="MODEL_LOAD_FAILED",o.TEXTURE_LOAD_FAILED="TEXTURE_LOAD_FAILED",o.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",o.INVALID_CONFIGURATION="INVALID_CONFIGURATION",o.RENDER_ERROR="RENDER_ERROR",o.COMPONENT_NOT_MOUNTED="COMPONENT_NOT_MOUNTED",o.UNKNOWN="UNKNOWN",o))(ue||{});const Hc=0,Ld=1,Gc=2,Wc=2,Sa=1.25,Vc=1,Wn=6*4+4+4,is=65535,Nd=Math.pow(2,-24),Ma=Symbol("SKIP_GENERATION");function jc(o){return o.index?o.index.count:o.attributes.position.count}function kr(o){return jc(o)/3}function qc(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function Bd(o,e){if(!o.index){const n=o.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=qc(n,i);o.setIndex(new m.BufferAttribute(s,1));for(let c=0;c<n;c++)s[c]=c}}function Yc(o,e){const n=kr(o),i=e||o.drawRange,s=i.start/3,c=(i.start+i.count)/3,a=Math.max(0,s),u=Math.min(n,c)-a;return[{offset:Math.floor(a),count:Math.floor(u)}]}function Kc(o,e){if(!o.groups||!o.groups.length)return Yc(o,e);const n=[],i=new Set,s=e||o.drawRange,c=s.start/3,a=(s.start+s.count)/3;for(const f of o.groups){const p=f.start/3,v=(f.start+f.count)/3;i.add(Math.max(c,p)),i.add(Math.min(a,v))}const u=Array.from(i.values()).sort((f,p)=>f-p);for(let f=0;f<u.length-1;f++){const p=u[f],v=u[f+1];n.push({offset:Math.floor(p),count:Math.floor(v-p)})}return n}function kd(o,e){const n=kr(o),i=Kc(o,e).sort((a,u)=>a.offset-u.offset),s=i[i.length-1];s.count=Math.min(n-s.offset,s.count);let c=0;return i.forEach(({count:a})=>c+=a),n!==c}function Ca(o,e,n,i,s){let c=1/0,a=1/0,u=1/0,f=-1/0,p=-1/0,v=-1/0,g=1/0,h=1/0,b=1/0,R=-1/0,M=-1/0,x=-1/0;for(let A=e*6,E=(e+n)*6;A<E;A+=6){const C=o[A+0],P=o[A+1],O=C-P,B=C+P;O<c&&(c=O),B>f&&(f=B),C<g&&(g=C),C>R&&(R=C);const k=o[A+2],q=o[A+3],j=k-q,K=k+q;j<a&&(a=j),K>p&&(p=K),k<h&&(h=k),k>M&&(M=k);const $=o[A+4],H=o[A+5],Z=$-H,Q=$+H;Z<u&&(u=Z),Q>v&&(v=Q),$<b&&(b=$),$>x&&(x=$)}i[0]=c,i[1]=a,i[2]=u,i[3]=f,i[4]=p,i[5]=v,s[0]=g,s[1]=h,s[2]=b,s[3]=R,s[4]=M,s[5]=x}function Ud(o,e=null,n=null,i=null){const s=o.attributes.position,c=o.index?o.index.array:null,a=kr(o),u=s.normalized;let f;e===null?(f=new Float32Array(a*6*4),n=0,i=a):(f=e,n=n||0,i=i||a);const p=s.array,v=s.offset||0;let g=3;s.isInterleavedBufferAttribute&&(g=s.data.stride);const h=["getX","getY","getZ"];for(let b=n;b<n+i;b++){const R=b*3,M=b*6;let x=R+0,A=R+1,E=R+2;c&&(x=c[x],A=c[A],E=c[E]),u||(x=x*g+v,A=A*g+v,E=E*g+v);for(let C=0;C<3;C++){let P,O,B;u?(P=s[h[C]](x),O=s[h[C]](A),B=s[h[C]](E)):(P=p[x+C],O=p[A+C],B=p[E+C]);let k=P;O<k&&(k=O),B<k&&(k=B);let q=P;O>q&&(q=O),B>q&&(q=B);const j=(q-k)/2,K=C*2;f[M+K+0]=k+j,f[M+K+1]=j+(Math.abs(k)+j)*Nd}}return f}function Ye(o,e,n){return n.min.x=e[o],n.min.y=e[o+1],n.min.z=e[o+2],n.max.x=e[o+3],n.max.y=e[o+4],n.max.z=e[o+5],n}function Xc(o){let e=-1,n=-1/0;for(let i=0;i<3;i++){const s=o[i+3]-o[i];s>n&&(n=s,e=i)}return e}function Zc(o,e){e.set(o)}function $c(o,e,n){let i,s;for(let c=0;c<3;c++){const a=c+3;i=o[c],s=e[c],n[c]=i<s?i:s,i=o[a],s=e[a],n[a]=i>s?i:s}}function ss(o,e,n){for(let i=0;i<3;i++){const s=e[o+2*i],c=e[o+2*i+1],a=s-c,u=s+c;a<n[i]&&(n[i]=a),u>n[i+3]&&(n[i+3]=u)}}function yi(o){const e=o[3]-o[0],n=o[4]-o[1],i=o[5]-o[2];return 2*(e*n+n*i+i*e)}const Rn=32,zd=(o,e)=>o.candidate-e.candidate,Vn=new Array(Rn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),as=new Float32Array(6);function Hd(o,e,n,i,s,c){let a=-1,u=0;if(c===Hc)a=Xc(e),a!==-1&&(u=(e[a]+e[a+3])/2);else if(c===Ld)a=Xc(o),a!==-1&&(u=Gd(n,i,s,a));else if(c===Gc){const f=yi(o);let p=Sa*s;const v=i*6,g=(i+s)*6;for(let h=0;h<3;h++){const b=e[h],x=(e[h+3]-b)/Rn;if(s<Rn/4){const A=[...Vn];A.length=s;let E=0;for(let P=v;P<g;P+=6,E++){const O=A[E];O.candidate=n[P+2*h],O.count=0;const{bounds:B,leftCacheBounds:k,rightCacheBounds:q}=O;for(let j=0;j<3;j++)q[j]=1/0,q[j+3]=-1/0,k[j]=1/0,k[j+3]=-1/0,B[j]=1/0,B[j+3]=-1/0;ss(P,n,B)}A.sort(zd);let C=s;for(let P=0;P<C;P++){const O=A[P];for(;P+1<C&&A[P+1].candidate===O.candidate;)A.splice(P+1,1),C--}for(let P=v;P<g;P+=6){const O=n[P+2*h];for(let B=0;B<C;B++){const k=A[B];O>=k.candidate?ss(P,n,k.rightCacheBounds):(ss(P,n,k.leftCacheBounds),k.count++)}}for(let P=0;P<C;P++){const O=A[P],B=O.count,k=s-O.count,q=O.leftCacheBounds,j=O.rightCacheBounds;let K=0;B!==0&&(K=yi(q)/f);let $=0;k!==0&&($=yi(j)/f);const H=Vc+Sa*(K*B+$*k);H<p&&(a=h,p=H,u=O.candidate)}}else{for(let C=0;C<Rn;C++){const P=Vn[C];P.count=0,P.candidate=b+x+C*x;const O=P.bounds;for(let B=0;B<3;B++)O[B]=1/0,O[B+3]=-1/0}for(let C=v;C<g;C+=6){let B=~~((n[C+2*h]-b)/x);B>=Rn&&(B=Rn-1);const k=Vn[B];k.count++,ss(C,n,k.bounds)}const A=Vn[Rn-1];Zc(A.bounds,A.rightCacheBounds);for(let C=Rn-2;C>=0;C--){const P=Vn[C],O=Vn[C+1];$c(P.bounds,O.rightCacheBounds,P.rightCacheBounds)}let E=0;for(let C=0;C<Rn-1;C++){const P=Vn[C],O=P.count,B=P.bounds,q=Vn[C+1].rightCacheBounds;O!==0&&(E===0?Zc(B,as):$c(B,as,as)),E+=O;let j=0,K=0;E!==0&&(j=yi(as)/f);const $=s-E;$!==0&&(K=yi(q)/f);const H=Vc+Sa*(j*E+K*$);H<p&&(a=h,p=H,u=P.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${c} used.`);return{axis:a,pos:u}}function Gd(o,e,n,i){let s=0;for(let c=e,a=e+n;c<a;c++)s+=o[c*6+i*2];return s/n}class Ia{constructor(){this.boundingData=new Float32Array(6)}}function Wd(o,e,n,i,s,c){let a=i,u=i+s-1;const f=c.pos,p=c.axis*2;for(;;){for(;a<=u&&n[a*6+p]<f;)a++;for(;a<=u&&n[u*6+p]>=f;)u--;if(a<u){for(let v=0;v<3;v++){let g=e[a*3+v];e[a*3+v]=e[u*3+v],e[u*3+v]=g}for(let v=0;v<6;v++){let g=n[a*6+v];n[a*6+v]=n[u*6+v],n[u*6+v]=g}a++,u--}else return a}}function Vd(o,e,n,i,s,c){let a=i,u=i+s-1;const f=c.pos,p=c.axis*2;for(;;){for(;a<=u&&n[a*6+p]<f;)a++;for(;a<=u&&n[u*6+p]>=f;)u--;if(a<u){let v=o[a];o[a]=o[u],o[u]=v;for(let g=0;g<6;g++){let h=n[a*6+g];n[a*6+g]=n[u*6+g],n[u*6+g]=h}a++,u--}else return a}}function mt(o,e){return e[o+15]===65535}function Et(o,e){return e[o+6]}function Ft(o,e){return e[o+14]}function qt(o){return o+8}function Ot(o,e){return e[o+6]}function Pa(o,e){return e[o+7]}function Dw(o){return o}let Qc,_i,os,Jc;const jd=Math.pow(2,32);function Da(o){return"count"in o?1:1+Da(o.left)+Da(o.right)}function qd(o,e,n){return Qc=new Float32Array(n),_i=new Uint32Array(n),os=new Uint16Array(n),Jc=new Uint8Array(n),Fa(o,e)}function Fa(o,e){const n=o/4,i=o/2,s="count"in e,c=e.boundingData;for(let a=0;a<6;a++)Qc[n+a]=c[a];if(s)if(e.buffer){const a=e.buffer;Jc.set(new Uint8Array(a),o);for(let u=o,f=o+a.byteLength;u<f;u+=Wn){const p=u/2;mt(p,os)||(_i[u/4+6]+=n)}return o+a.byteLength}else{const a=e.offset,u=e.count;return _i[n+6]=a,os[i+14]=u,os[i+15]=is,o+Wn}else{const a=e.left,u=e.right,f=e.splitAxis;let p;if(p=Fa(o+Wn,a),p/4>jd)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return _i[n+6]=p/4,p=Fa(p,u),_i[n+7]=f,p}}function Yd(o,e){const n=(o.index?o.index.count:o.attributes.position.count)/3,i=n>2**16,s=i?4:2,c=e?new SharedArrayBuffer(n*s):new ArrayBuffer(n*s),a=i?new Uint32Array(c):new Uint16Array(c);for(let u=0,f=a.length;u<f;u++)a[u]=u;return a}function Kd(o,e,n,i,s){const{maxDepth:c,verbose:a,maxLeafTris:u,strategy:f,onProgress:p,indirect:v}=s,g=o._indirectBuffer,h=o.geometry,b=h.index?h.index.array:null,R=v?Vd:Wd,M=kr(h),x=new Float32Array(6);let A=!1;const E=new Ia;return Ca(e,n,i,E.boundingData,x),P(E,n,i,x),E;function C(O){p&&p(O/M)}function P(O,B,k,q=null,j=0){if(!A&&j>=c&&(A=!0,a&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(h))),k<=u||j>=c)return C(B+k),O.offset=B,O.count=k,O;const K=Hd(O.boundingData,q,e,B,k,f);if(K.axis===-1)return C(B+k),O.offset=B,O.count=k,O;const $=R(g,b,e,B,k,K);if($===B||$===B+k)C(B+k),O.offset=B,O.count=k;else{O.splitAxis=K.axis;const H=new Ia,Z=B,Q=$-B;O.left=H,Ca(e,Z,Q,H.boundingData,x),P(H,Z,Q,x,j+1);const ce=new Ia,Re=$,ke=k-Q;O.right=ce,Ca(e,Re,ke,ce.boundingData,x),P(ce,Re,ke,x,j+1)}return O}}function Xd(o,e){const n=o.geometry;e.indirect&&(o._indirectBuffer=Yd(n,e.useSharedArrayBuffer),kd(n,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),o._indirectBuffer||Bd(n,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Ud(n),c=e.indirect?Yc(n,e.range):Kc(n,e.range);o._roots=c.map(a=>{const u=Kd(o,s,a.offset,a.count,e),f=Da(u),p=new i(Wn*f);return qd(0,u,p),p})}class An{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,n){let i=1/0,s=-1/0;for(let c=0,a=e.length;c<a;c++){const f=e[c][n];i=f<i?f:i,s=f>s?f:s}this.min=i,this.max=s}setFromPoints(e,n){let i=1/0,s=-1/0;for(let c=0,a=n.length;c<a;c++){const u=n[c],f=e.dot(u);i=f<i?f:i,s=f>s?f:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}An.prototype.setFromBox=function(){const o=new m.Vector3;return function(n,i){const s=i.min,c=i.max;let a=1/0,u=-1/0;for(let f=0;f<=1;f++)for(let p=0;p<=1;p++)for(let v=0;v<=1;v++){o.x=s.x*f+c.x*(1-f),o.y=s.y*p+c.y*(1-p),o.z=s.z*v+c.z*(1-v);const g=n.dot(o);a=Math.min(g,a),u=Math.max(g,u)}this.min=a,this.max=u}}();const Zd=function(){const o=new m.Vector3,e=new m.Vector3,n=new m.Vector3;return function(s,c,a){const u=s.start,f=o,p=c.start,v=e;n.subVectors(u,p),o.subVectors(s.end,s.start),e.subVectors(c.end,c.start);const g=n.dot(v),h=v.dot(f),b=v.dot(v),R=n.dot(f),x=f.dot(f)*b-h*h;let A,E;x!==0?A=(g*h-R*b)/x:A=0,E=(g+A*h)/b,a.x=A,a.y=E}}(),Oa=function(){const o=new m.Vector2,e=new m.Vector3,n=new m.Vector3;return function(s,c,a,u){Zd(s,c,o);let f=o.x,p=o.y;if(f>=0&&f<=1&&p>=0&&p<=1){s.at(f,a),c.at(p,u);return}else if(f>=0&&f<=1){p<0?c.at(0,u):c.at(1,u),s.closestPointToPoint(u,!0,a);return}else if(p>=0&&p<=1){f<0?s.at(0,a):s.at(1,a),c.closestPointToPoint(a,!0,u);return}else{let v;f<0?v=s.start:v=s.end;let g;p<0?g=c.start:g=c.end;const h=e,b=n;if(s.closestPointToPoint(g,!0,e),c.closestPointToPoint(v,!0,n),h.distanceToSquared(g)<=b.distanceToSquared(v)){a.copy(h),u.copy(g);return}else{a.copy(v),u.copy(b);return}}}}(),$d=function(){const o=new m.Vector3,e=new m.Vector3,n=new m.Plane,i=new m.Line3;return function(c,a){const{radius:u,center:f}=c,{a:p,b:v,c:g}=a;if(i.start=p,i.end=v,i.closestPointToPoint(f,!0,o).distanceTo(f)<=u||(i.start=p,i.end=g,i.closestPointToPoint(f,!0,o).distanceTo(f)<=u)||(i.start=v,i.end=g,i.closestPointToPoint(f,!0,o).distanceTo(f)<=u))return!0;const M=a.getPlane(n);if(Math.abs(M.distanceToPoint(f))<=u){const A=M.projectPoint(f,e);if(a.containsPoint(A))return!0}return!1}}(),Qd=1e-15;function La(o){return Math.abs(o)<Qd}class nn extends m.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new m.Vector3),this.satBounds=new Array(4).fill().map(()=>new An),this.points=[this.a,this.b,this.c],this.sphere=new m.Sphere,this.plane=new m.Plane,this.needsUpdate=!0}intersectsSphere(e){return $d(e,this)}update(){const e=this.a,n=this.b,i=this.c,s=this.points,c=this.satAxes,a=this.satBounds,u=c[0],f=a[0];this.getNormal(u),f.setFromPoints(u,s);const p=c[1],v=a[1];p.subVectors(e,n),v.setFromPoints(p,s);const g=c[2],h=a[2];g.subVectors(n,i),h.setFromPoints(g,s);const b=c[3],R=a[3];b.subVectors(i,e),R.setFromPoints(b,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(u,e),this.needsUpdate=!1}}nn.prototype.closestPointToSegment=function(){const o=new m.Vector3,e=new m.Vector3,n=new m.Line3;return function(s,c=null,a=null){const{start:u,end:f}=s,p=this.points;let v,g=1/0;for(let h=0;h<3;h++){const b=(h+1)%3;n.start.copy(p[h]),n.end.copy(p[b]),Oa(n,s,o,e),v=o.distanceToSquared(e),v<g&&(g=v,c&&c.copy(o),a&&a.copy(e))}return this.closestPointToPoint(u,o),v=u.distanceToSquared(o),v<g&&(g=v,c&&c.copy(o),a&&a.copy(u)),this.closestPointToPoint(f,o),v=f.distanceToSquared(o),v<g&&(g=v,c&&c.copy(o),a&&a.copy(f)),Math.sqrt(g)}}(),nn.prototype.intersectsTriangle=function(){const o=new nn,e=new Array(3),n=new Array(3),i=new An,s=new An,c=new m.Vector3,a=new m.Vector3,u=new m.Vector3,f=new m.Vector3,p=new m.Vector3,v=new m.Line3,g=new m.Line3,h=new m.Line3,b=new m.Vector3;function R(M,x,A){const E=M.points;let C=0,P=-1;for(let O=0;O<3;O++){const{start:B,end:k}=v;B.copy(E[O]),k.copy(E[(O+1)%3]),v.delta(a);const q=La(x.distanceToPoint(B));if(La(x.normal.dot(a))&&q){A.copy(v),C=2;break}const j=x.intersectLine(v,b);if(!j&&q&&b.copy(B),(j||q)&&!La(b.distanceTo(k))){if(C<=1)(C===1?A.start:A.end).copy(b),q&&(P=C);else if(C>=2){(P===1?A.start:A.end).copy(b),C=2;break}if(C++,C===2&&P===-1)break}}return C}return function(x,A=null,E=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(o.copy(x),o.update(),x=o);const C=this.plane,P=x.plane;if(Math.abs(C.normal.dot(P.normal))>1-1e-10){const O=this.satBounds,B=this.satAxes;n[0]=x.a,n[1]=x.b,n[2]=x.c;for(let j=0;j<4;j++){const K=O[j],$=B[j];if(i.setFromPoints($,n),K.isSeparated(i))return!1}const k=x.satBounds,q=x.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let j=0;j<4;j++){const K=k[j],$=q[j];if(i.setFromPoints($,e),K.isSeparated(i))return!1}for(let j=0;j<4;j++){const K=B[j];for(let $=0;$<4;$++){const H=q[$];if(c.crossVectors(K,H),i.setFromPoints(c,e),s.setFromPoints(c,n),i.isSeparated(s))return!1}}return A&&(E||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),A.start.set(0,0,0),A.end.set(0,0,0)),!0}else{const O=R(this,P,g);if(O===1&&x.containsPoint(g.end))return A&&(A.start.copy(g.end),A.end.copy(g.end)),!0;if(O!==2)return!1;const B=R(x,C,h);if(B===1&&this.containsPoint(h.end))return A&&(A.start.copy(h.end),A.end.copy(h.end)),!0;if(B!==2)return!1;if(g.delta(u),h.delta(f),u.dot(f)<0){let Z=h.start;h.start=h.end,h.end=Z}const k=g.start.dot(u),q=g.end.dot(u),j=h.start.dot(u),K=h.end.dot(u),$=q<j,H=k<K;return k!==K&&j!==q&&$===H?!1:(A&&(p.subVectors(g.start,h.start),p.dot(u)>0?A.start.copy(g.start):A.start.copy(h.start),p.subVectors(g.end,h.end),p.dot(u)<0?A.end.copy(g.end):A.end.copy(h.end)),!0)}}}(),nn.prototype.distanceToPoint=function(){const o=new m.Vector3;return function(n){return this.closestPointToPoint(n,o),n.distanceTo(o)}}(),nn.prototype.distanceToTriangle=function(){const o=new m.Vector3,e=new m.Vector3,n=["a","b","c"],i=new m.Line3,s=new m.Line3;return function(a,u=null,f=null){const p=u||f?i:null;if(this.intersectsTriangle(a,p))return(u||f)&&(u&&p.getCenter(u),f&&p.getCenter(f)),0;let v=1/0;for(let g=0;g<3;g++){let h;const b=n[g],R=a[b];this.closestPointToPoint(R,o),h=R.distanceToSquared(o),h<v&&(v=h,u&&u.copy(o),f&&f.copy(R));const M=this[b];a.closestPointToPoint(M,o),h=M.distanceToSquared(o),h<v&&(v=h,u&&u.copy(M),f&&f.copy(o))}for(let g=0;g<3;g++){const h=n[g],b=n[(g+1)%3];i.set(this[h],this[b]);for(let R=0;R<3;R++){const M=n[R],x=n[(R+1)%3];s.set(a[M],a[x]),Oa(i,s,o,e);const A=o.distanceToSquared(e);A<v&&(v=A,u&&u.copy(o),f&&f.copy(e))}}return Math.sqrt(v)}}();class gt{constructor(e,n,i){this.isOrientedBox=!0,this.min=new m.Vector3,this.max=new m.Vector3,this.matrix=new m.Matrix4,this.invMatrix=new m.Matrix4,this.points=new Array(8).fill().map(()=>new m.Vector3),this.satAxes=new Array(3).fill().map(()=>new m.Vector3),this.satBounds=new Array(3).fill().map(()=>new An),this.alignedSatBounds=new Array(3).fill().map(()=>new An),this.needsUpdate=!1,e&&this.min.copy(e),n&&this.max.copy(n),i&&this.matrix.copy(i)}set(e,n,i){this.min.copy(e),this.max.copy(n),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}gt.prototype.update=function(){return function(){const e=this.matrix,n=this.min,i=this.max,s=this.points;for(let p=0;p<=1;p++)for(let v=0;v<=1;v++)for(let g=0;g<=1;g++){const h=1*p|2*v|4*g,b=s[h];b.x=p?i.x:n.x,b.y=v?i.y:n.y,b.z=g?i.z:n.z,b.applyMatrix4(e)}const c=this.satBounds,a=this.satAxes,u=s[0];for(let p=0;p<3;p++){const v=a[p],g=c[p],h=1<<p,b=s[h];v.subVectors(u,b),g.setFromPoints(v,s)}const f=this.alignedSatBounds;f[0].setFromPointsField(s,"x"),f[1].setFromPointsField(s,"y"),f[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),gt.prototype.intersectsBox=function(){const o=new An;return function(n){this.needsUpdate&&this.update();const i=n.min,s=n.max,c=this.satBounds,a=this.satAxes,u=this.alignedSatBounds;if(o.min=i.x,o.max=s.x,u[0].isSeparated(o)||(o.min=i.y,o.max=s.y,u[1].isSeparated(o))||(o.min=i.z,o.max=s.z,u[2].isSeparated(o)))return!1;for(let f=0;f<3;f++){const p=a[f],v=c[f];if(o.setFromBox(p,n),v.isSeparated(o))return!1}return!0}}(),gt.prototype.intersectsTriangle=function(){const o=new nn,e=new Array(3),n=new An,i=new An,s=new m.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(o.copy(a),o.update(),a=o);const u=this.satBounds,f=this.satAxes;e[0]=a.a,e[1]=a.b,e[2]=a.c;for(let h=0;h<3;h++){const b=u[h],R=f[h];if(n.setFromPoints(R,e),b.isSeparated(n))return!1}const p=a.satBounds,v=a.satAxes,g=this.points;for(let h=0;h<3;h++){const b=p[h],R=v[h];if(n.setFromPoints(R,g),b.isSeparated(n))return!1}for(let h=0;h<3;h++){const b=f[h];for(let R=0;R<4;R++){const M=v[R];if(s.crossVectors(b,M),n.setFromPoints(s,e),i.setFromPoints(s,g),n.isSeparated(i))return!1}}return!0}}(),gt.prototype.closestPointToPoint=function(){return function(e,n){return this.needsUpdate&&this.update(),n.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),n}}(),gt.prototype.distanceToPoint=function(){const o=new m.Vector3;return function(n){return this.closestPointToPoint(n,o),n.distanceTo(o)}}(),gt.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new m.Line3),n=new Array(12).fill().map(()=>new m.Line3),i=new m.Vector3,s=new m.Vector3;return function(a,u=0,f=null,p=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(f||p)&&(a.getCenter(s),this.closestPointToPoint(s,i),a.closestPointToPoint(i,s),f&&f.copy(i),p&&p.copy(s)),0;const v=u*u,g=a.min,h=a.max,b=this.points;let R=1/0;for(let x=0;x<8;x++){const A=b[x];s.copy(A).clamp(g,h);const E=A.distanceToSquared(s);if(E<R&&(R=E,f&&f.copy(A),p&&p.copy(s),E<v))return Math.sqrt(E)}let M=0;for(let x=0;x<3;x++)for(let A=0;A<=1;A++)for(let E=0;E<=1;E++){const C=(x+1)%3,P=(x+2)%3,O=A<<C|E<<P,B=1<<x|A<<C|E<<P,k=b[O],q=b[B];e[M].set(k,q);const K=o[x],$=o[C],H=o[P],Z=n[M],Q=Z.start,ce=Z.end;Q[K]=g[K],Q[$]=A?g[$]:h[$],Q[H]=E?g[H]:h[$],ce[K]=h[K],ce[$]=A?g[$]:h[$],ce[H]=E?g[H]:h[$],M++}for(let x=0;x<=1;x++)for(let A=0;A<=1;A++)for(let E=0;E<=1;E++){s.x=x?h.x:g.x,s.y=A?h.y:g.y,s.z=E?h.z:g.z,this.closestPointToPoint(s,i);const C=s.distanceToSquared(i);if(C<R&&(R=C,f&&f.copy(i),p&&p.copy(s),C<v))return Math.sqrt(C)}for(let x=0;x<12;x++){const A=e[x];for(let E=0;E<12;E++){const C=n[E];Oa(A,C,i,s);const P=i.distanceToSquared(s);if(P<R&&(R=P,f&&f.copy(i),p&&p.copy(s),P<v))return Math.sqrt(P)}}return Math.sqrt(R)}}();class Na{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Jd extends Na{constructor(){super(()=>new nn)}}const Yt=new Jd;class ep{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let n=null;this.setBuffer=i=>{n&&e.push(n),n=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{n=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Ge=new ep;let jn,Ur;const zr=[],cs=new Na(()=>new m.Box3);function tp(o,e,n,i,s,c){jn=cs.getPrimitive(),Ur=cs.getPrimitive(),zr.push(jn,Ur),Ge.setBuffer(o._roots[e]);const a=Ba(0,o.geometry,n,i,s,c);Ge.clearBuffer(),cs.releasePrimitive(jn),cs.releasePrimitive(Ur),zr.pop(),zr.pop();const u=zr.length;return u>0&&(Ur=zr[u-1],jn=zr[u-2]),a}function Ba(o,e,n,i,s=null,c=0,a=0){const{float32Array:u,uint16Array:f,uint32Array:p}=Ge;let v=o*2;if(mt(v,f)){const h=Et(o,p),b=Ft(v,f);return Ye(o,u,jn),i(h,b,!1,a,c+o,jn)}else{let K=function(H){const{uint16Array:Z,uint32Array:Q}=Ge;let ce=H*2;for(;!mt(ce,Z);)H=qt(H),ce=H*2;return Et(H,Q)},$=function(H){const{uint16Array:Z,uint32Array:Q}=Ge;let ce=H*2;for(;!mt(ce,Z);)H=Ot(H,Q),ce=H*2;return Et(H,Q)+Ft(ce,Z)};const h=qt(o),b=Ot(o,p);let R=h,M=b,x,A,E,C;if(s&&(E=jn,C=Ur,Ye(R,u,E),Ye(M,u,C),x=s(E),A=s(C),A<x)){R=b,M=h;const H=x;x=A,A=H,E=C}E||(E=jn,Ye(R,u,E));const P=mt(R*2,f),O=n(E,P,x,a+1,c+R);let B;if(O===Wc){const H=K(R),Q=$(R)-H;B=i(H,Q,!0,a+1,c+R,E)}else B=O&&Ba(R,e,n,i,s,c,a+1);if(B)return!0;C=Ur,Ye(M,u,C);const k=mt(M*2,f),q=n(C,k,A,a+1,c+M);let j;if(q===Wc){const H=K(M),Q=$(M)-H;j=i(H,Q,!0,a+1,c+M,C)}else j=q&&Ba(M,e,n,i,s,c,a+1);return!!j}}const xi=new m.Vector3,ka=new m.Vector3;function np(o,e,n={},i=0,s=1/0){const c=i*i,a=s*s;let u=1/0,f=null;if(o.shapecast({boundsTraverseOrder:v=>(xi.copy(e).clamp(v.min,v.max),xi.distanceToSquared(e)),intersectsBounds:(v,g,h)=>h<u&&h<a,intersectsTriangle:(v,g)=>{v.closestPointToPoint(e,xi);const h=e.distanceToSquared(xi);return h<u&&(ka.copy(xi),u=h,f=g),h<c}}),u===1/0)return null;const p=Math.sqrt(u);return n.point?n.point.copy(ka):n.point=ka.clone(),n.distance=p,n.faceIndex=f,n}const Hr=new m.Vector3,Gr=new m.Vector3,Wr=new m.Vector3,ls=new m.Vector2,us=new m.Vector2,fs=new m.Vector2,el=new m.Vector3,tl=new m.Vector3,nl=new m.Vector3,hs=new m.Vector3;function rp(o,e,n,i,s,c,a,u){let f;if(c===m.BackSide?f=o.intersectTriangle(i,n,e,!0,s):f=o.intersectTriangle(e,n,i,c!==m.DoubleSide,s),f===null)return null;const p=o.origin.distanceTo(s);return p<a||p>u?null:{distance:p,point:s.clone()}}function ip(o,e,n,i,s,c,a,u,f,p,v){Hr.fromBufferAttribute(e,c),Gr.fromBufferAttribute(e,a),Wr.fromBufferAttribute(e,u);const g=rp(o,Hr,Gr,Wr,hs,f,p,v);if(g){i&&(ls.fromBufferAttribute(i,c),us.fromBufferAttribute(i,a),fs.fromBufferAttribute(i,u),g.uv=m.Triangle.getInterpolation(hs,Hr,Gr,Wr,ls,us,fs,new m.Vector2)),s&&(ls.fromBufferAttribute(s,c),us.fromBufferAttribute(s,a),fs.fromBufferAttribute(s,u),g.uv1=m.Triangle.getInterpolation(hs,Hr,Gr,Wr,ls,us,fs,new m.Vector2)),n&&(el.fromBufferAttribute(n,c),tl.fromBufferAttribute(n,a),nl.fromBufferAttribute(n,u),g.normal=m.Triangle.getInterpolation(hs,Hr,Gr,Wr,el,tl,nl,new m.Vector3),g.normal.dot(o.direction)>0&&g.normal.multiplyScalar(-1));const h={a:c,b:a,c:u,normal:new m.Vector3,materialIndex:0};m.Triangle.getNormal(Hr,Gr,Wr,h.normal),g.face=h,g.faceIndex=c}return g}function ds(o,e,n,i,s,c,a){const u=i*3;let f=u+0,p=u+1,v=u+2;const g=o.index;o.index&&(f=g.getX(f),p=g.getX(p),v=g.getX(v));const{position:h,normal:b,uv:R,uv1:M}=o.attributes,x=ip(n,h,b,R,M,f,p,v,e,c,a);return x?(x.faceIndex=i,s&&s.push(x),x):null}function Je(o,e,n,i){const s=o.a,c=o.b,a=o.c;let u=e,f=e+1,p=e+2;n&&(u=n.getX(u),f=n.getX(f),p=n.getX(p)),s.x=i.getX(u),s.y=i.getY(u),s.z=i.getZ(u),c.x=i.getX(f),c.y=i.getY(f),c.z=i.getZ(f),a.x=i.getX(p),a.y=i.getY(p),a.z=i.getZ(p)}function sp(o,e,n,i,s,c,a,u){const{geometry:f,_indirectBuffer:p}=o;for(let v=i,g=i+s;v<g;v++)ds(f,e,n,v,c,a,u)}function ap(o,e,n,i,s,c,a){const{geometry:u,_indirectBuffer:f}=o;let p=1/0,v=null;for(let g=i,h=i+s;g<h;g++){let b;b=ds(u,e,n,g,null,c,a),b&&b.distance<p&&(v=b,p=b.distance)}return v}function op(o,e,n,i,s,c,a){const{geometry:u}=n,{index:f}=u,p=u.attributes.position;for(let v=o,g=e+o;v<g;v++){let h;if(h=v,Je(a,h*3,f,p),a.needsUpdate=!0,i(a,h,s,c))return!0}return!1}function cp(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const n=o.geometry,i=n.index?n.index.array:null,s=n.attributes.position;let c,a,u,f,p=0;const v=o._roots;for(let h=0,b=v.length;h<b;h++)c=v[h],a=new Uint32Array(c),u=new Uint16Array(c),f=new Float32Array(c),g(0,p),p+=c.byteLength;function g(h,b,R=!1){const M=h*2;if(u[M+15]===is){const A=a[h+6],E=u[M+14];let C=1/0,P=1/0,O=1/0,B=-1/0,k=-1/0,q=-1/0;for(let j=3*A,K=3*(A+E);j<K;j++){let $=i[j];const H=s.getX($),Z=s.getY($),Q=s.getZ($);H<C&&(C=H),H>B&&(B=H),Z<P&&(P=Z),Z>k&&(k=Z),Q<O&&(O=Q),Q>q&&(q=Q)}return f[h+0]!==C||f[h+1]!==P||f[h+2]!==O||f[h+3]!==B||f[h+4]!==k||f[h+5]!==q?(f[h+0]=C,f[h+1]=P,f[h+2]=O,f[h+3]=B,f[h+4]=k,f[h+5]=q,!0):!1}else{const A=h+8,E=a[h+6],C=A+b,P=E+b;let O=R,B=!1,k=!1;e?O||(B=e.has(C),k=e.has(P),O=!B&&!k):(B=!0,k=!0);const q=O||B,j=O||k;let K=!1;q&&(K=g(A,b,O));let $=!1;j&&($=g(E,b,O));const H=K||$;if(H)for(let Z=0;Z<3;Z++){const Q=A+Z,ce=E+Z,Re=f[Q],ke=f[Q+3],Ie=f[ce],et=f[ce+3];f[h+Z]=Re<Ie?Re:Ie,f[h+Z+3]=ke>et?ke:et}return H}}}function qn(o,e,n,i,s){let c,a,u,f,p,v;const g=1/n.direction.x,h=1/n.direction.y,b=1/n.direction.z,R=n.origin.x,M=n.origin.y,x=n.origin.z;let A=e[o],E=e[o+3],C=e[o+1],P=e[o+3+1],O=e[o+2],B=e[o+3+2];return g>=0?(c=(A-R)*g,a=(E-R)*g):(c=(E-R)*g,a=(A-R)*g),h>=0?(u=(C-M)*h,f=(P-M)*h):(u=(P-M)*h,f=(C-M)*h),c>f||u>a||((u>c||isNaN(c))&&(c=u),(f<a||isNaN(a))&&(a=f),b>=0?(p=(O-x)*b,v=(B-x)*b):(p=(B-x)*b,v=(O-x)*b),c>v||p>a)?!1:((p>c||c!==c)&&(c=p),(v<a||a!==a)&&(a=v),c<=s&&a>=i)}function lp(o,e,n,i,s,c,a,u){const{geometry:f,_indirectBuffer:p}=o;for(let v=i,g=i+s;v<g;v++){let h=p?p[v]:v;ds(f,e,n,h,c,a,u)}}function up(o,e,n,i,s,c,a){const{geometry:u,_indirectBuffer:f}=o;let p=1/0,v=null;for(let g=i,h=i+s;g<h;g++){let b;b=ds(u,e,n,f?f[g]:g,null,c,a),b&&b.distance<p&&(v=b,p=b.distance)}return v}function fp(o,e,n,i,s,c,a){const{geometry:u}=n,{index:f}=u,p=u.attributes.position;for(let v=o,g=e+o;v<g;v++){let h;if(h=n.resolveTriangleIndex(v),Je(a,h*3,f,p),a.needsUpdate=!0,i(a,h,s,c))return!0}return!1}function hp(o,e,n,i,s,c,a){Ge.setBuffer(o._roots[e]),Ua(0,o,n,i,s,c,a),Ge.clearBuffer()}function Ua(o,e,n,i,s,c,a){const{float32Array:u,uint16Array:f,uint32Array:p}=Ge,v=o*2;if(mt(v,f)){const h=Et(o,p),b=Ft(v,f);sp(e,n,i,h,b,s,c,a)}else{const h=qt(o);qn(h,u,i,c,a)&&Ua(h,e,n,i,s,c,a);const b=Ot(o,p);qn(b,u,i,c,a)&&Ua(b,e,n,i,s,c,a)}}const dp=["x","y","z"];function pp(o,e,n,i,s,c){Ge.setBuffer(o._roots[e]);const a=za(0,o,n,i,s,c);return Ge.clearBuffer(),a}function za(o,e,n,i,s,c){const{float32Array:a,uint16Array:u,uint32Array:f}=Ge;let p=o*2;if(mt(p,u)){const g=Et(o,f),h=Ft(p,u);return ap(e,n,i,g,h,s,c)}else{const g=Pa(o,f),h=dp[g],R=i.direction[h]>=0;let M,x;R?(M=qt(o),x=Ot(o,f)):(M=Ot(o,f),x=qt(o));const E=qn(M,a,i,s,c)?za(M,e,n,i,s,c):null;if(E){const O=E.point[h];if(R?O<=a[x+g]:O>=a[x+g+3])return E}const P=qn(x,a,i,s,c)?za(x,e,n,i,s,c):null;return E&&P?E.distance<=P.distance?E:P:E||P||null}}const ps=new m.Box3,Vr=new nn,jr=new nn,bi=new m.Matrix4,rl=new gt,ms=new gt;function mp(o,e,n,i){Ge.setBuffer(o._roots[e]);const s=Ha(0,o,n,i);return Ge.clearBuffer(),s}function Ha(o,e,n,i,s=null){const{float32Array:c,uint16Array:a,uint32Array:u}=Ge;let f=o*2;if(s===null&&(n.boundingBox||n.computeBoundingBox(),rl.set(n.boundingBox.min,n.boundingBox.max,i),s=rl),mt(f,a)){const v=e.geometry,g=v.index,h=v.attributes.position,b=n.index,R=n.attributes.position,M=Et(o,u),x=Ft(f,a);if(bi.copy(i).invert(),n.boundsTree)return Ye(o,c,ms),ms.matrix.copy(bi),ms.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:E=>ms.intersectsBox(E),intersectsTriangle:E=>{E.a.applyMatrix4(i),E.b.applyMatrix4(i),E.c.applyMatrix4(i),E.needsUpdate=!0;for(let C=M*3,P=(x+M)*3;C<P;C+=3)if(Je(jr,C,g,h),jr.needsUpdate=!0,E.intersectsTriangle(jr))return!0;return!1}});for(let A=M*3,E=(x+M)*3;A<E;A+=3){Je(Vr,A,g,h),Vr.a.applyMatrix4(bi),Vr.b.applyMatrix4(bi),Vr.c.applyMatrix4(bi),Vr.needsUpdate=!0;for(let C=0,P=b.count;C<P;C+=3)if(Je(jr,C,b,R),jr.needsUpdate=!0,Vr.intersectsTriangle(jr))return!0}}else{const v=o+8,g=u[o+6];return Ye(v,c,ps),!!(s.intersectsBox(ps)&&Ha(v,e,n,i,s)||(Ye(g,c,ps),s.intersectsBox(ps)&&Ha(g,e,n,i,s)))}}const gs=new m.Matrix4,Ga=new gt,Ti=new gt,gp=new m.Vector3,vp=new m.Vector3,yp=new m.Vector3,_p=new m.Vector3;function xp(o,e,n,i={},s={},c=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Ga.set(e.boundingBox.min,e.boundingBox.max,n),Ga.needsUpdate=!0;const u=o.geometry,f=u.attributes.position,p=u.index,v=e.attributes.position,g=e.index,h=Yt.getPrimitive(),b=Yt.getPrimitive();let R=gp,M=vp,x=null,A=null;s&&(x=yp,A=_p);let E=1/0,C=null,P=null;return gs.copy(n).invert(),Ti.matrix.copy(gs),o.shapecast({boundsTraverseOrder:O=>Ga.distanceToBox(O),intersectsBounds:(O,B,k)=>k<E&&k<a?(B&&(Ti.min.copy(O.min),Ti.max.copy(O.max),Ti.needsUpdate=!0),!0):!1,intersectsRange:(O,B)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:q=>Ti.distanceToBox(q),intersectsBounds:(q,j,K)=>K<E&&K<a,intersectsRange:(q,j)=>{for(let K=q,$=q+j;K<$;K++){Je(b,3*K,g,v),b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let H=O,Z=O+B;H<Z;H++){Je(h,3*H,p,f),h.needsUpdate=!0;const Q=h.distanceToTriangle(b,R,x);if(Q<E&&(M.copy(R),A&&A.copy(x),E=Q,C=H,P=K),Q<c)return!0}}}});{const k=kr(e);for(let q=0,j=k;q<j;q++){Je(b,3*q,g,v),b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let K=O,$=O+B;K<$;K++){Je(h,3*K,p,f),h.needsUpdate=!0;const H=h.distanceToTriangle(b,R,x);if(H<E&&(M.copy(R),A&&A.copy(x),E=H,C=K,P=q),H<c)return!0}}}}}),Yt.releasePrimitive(h),Yt.releasePrimitive(b),E===1/0?null:(i.point?i.point.copy(M):i.point=M.clone(),i.distance=E,i.faceIndex=C,s&&(s.point?s.point.copy(A):s.point=A.clone(),s.point.applyMatrix4(gs),M.applyMatrix4(gs),s.distance=M.sub(s.point).length(),s.faceIndex=P),i)}function bp(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const n=o.geometry,i=n.index?n.index.array:null,s=n.attributes.position;let c,a,u,f,p=0;const v=o._roots;for(let h=0,b=v.length;h<b;h++)c=v[h],a=new Uint32Array(c),u=new Uint16Array(c),f=new Float32Array(c),g(0,p),p+=c.byteLength;function g(h,b,R=!1){const M=h*2;if(u[M+15]===is){const A=a[h+6],E=u[M+14];let C=1/0,P=1/0,O=1/0,B=-1/0,k=-1/0,q=-1/0;for(let j=A,K=A+E;j<K;j++){const $=3*o.resolveTriangleIndex(j);for(let H=0;H<3;H++){let Z=$+H;Z=i?i[Z]:Z;const Q=s.getX(Z),ce=s.getY(Z),Re=s.getZ(Z);Q<C&&(C=Q),Q>B&&(B=Q),ce<P&&(P=ce),ce>k&&(k=ce),Re<O&&(O=Re),Re>q&&(q=Re)}}return f[h+0]!==C||f[h+1]!==P||f[h+2]!==O||f[h+3]!==B||f[h+4]!==k||f[h+5]!==q?(f[h+0]=C,f[h+1]=P,f[h+2]=O,f[h+3]=B,f[h+4]=k,f[h+5]=q,!0):!1}else{const A=h+8,E=a[h+6],C=A+b,P=E+b;let O=R,B=!1,k=!1;e?O||(B=e.has(C),k=e.has(P),O=!B&&!k):(B=!0,k=!0);const q=O||B,j=O||k;let K=!1;q&&(K=g(A,b,O));let $=!1;j&&($=g(E,b,O));const H=K||$;if(H)for(let Z=0;Z<3;Z++){const Q=A+Z,ce=E+Z,Re=f[Q],ke=f[Q+3],Ie=f[ce],et=f[ce+3];f[h+Z]=Re<Ie?Re:Ie,f[h+Z+3]=ke>et?ke:et}return H}}}function Tp(o,e,n,i,s,c,a){Ge.setBuffer(o._roots[e]),Wa(0,o,n,i,s,c,a),Ge.clearBuffer()}function Wa(o,e,n,i,s,c,a){const{float32Array:u,uint16Array:f,uint32Array:p}=Ge,v=o*2;if(mt(v,f)){const h=Et(o,p),b=Ft(v,f);lp(e,n,i,h,b,s,c,a)}else{const h=qt(o);qn(h,u,i,c,a)&&Wa(h,e,n,i,s,c,a);const b=Ot(o,p);qn(b,u,i,c,a)&&Wa(b,e,n,i,s,c,a)}}const wp=["x","y","z"];function Rp(o,e,n,i,s,c){Ge.setBuffer(o._roots[e]);const a=Va(0,o,n,i,s,c);return Ge.clearBuffer(),a}function Va(o,e,n,i,s,c){const{float32Array:a,uint16Array:u,uint32Array:f}=Ge;let p=o*2;if(mt(p,u)){const g=Et(o,f),h=Ft(p,u);return up(e,n,i,g,h,s,c)}else{const g=Pa(o,f),h=wp[g],R=i.direction[h]>=0;let M,x;R?(M=qt(o),x=Ot(o,f)):(M=Ot(o,f),x=qt(o));const E=qn(M,a,i,s,c)?Va(M,e,n,i,s,c):null;if(E){const O=E.point[h];if(R?O<=a[x+g]:O>=a[x+g+3])return E}const P=qn(x,a,i,s,c)?Va(x,e,n,i,s,c):null;return E&&P?E.distance<=P.distance?E:P:E||P||null}}const vs=new m.Box3,qr=new nn,Yr=new nn,wi=new m.Matrix4,il=new gt,ys=new gt;function Ap(o,e,n,i){Ge.setBuffer(o._roots[e]);const s=ja(0,o,n,i);return Ge.clearBuffer(),s}function ja(o,e,n,i,s=null){const{float32Array:c,uint16Array:a,uint32Array:u}=Ge;let f=o*2;if(s===null&&(n.boundingBox||n.computeBoundingBox(),il.set(n.boundingBox.min,n.boundingBox.max,i),s=il),mt(f,a)){const v=e.geometry,g=v.index,h=v.attributes.position,b=n.index,R=n.attributes.position,M=Et(o,u),x=Ft(f,a);if(wi.copy(i).invert(),n.boundsTree)return Ye(o,c,ys),ys.matrix.copy(wi),ys.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:E=>ys.intersectsBox(E),intersectsTriangle:E=>{E.a.applyMatrix4(i),E.b.applyMatrix4(i),E.c.applyMatrix4(i),E.needsUpdate=!0;for(let C=M,P=x+M;C<P;C++)if(Je(Yr,3*e.resolveTriangleIndex(C),g,h),Yr.needsUpdate=!0,E.intersectsTriangle(Yr))return!0;return!1}});for(let A=M,E=x+M;A<E;A++){const C=e.resolveTriangleIndex(A);Je(qr,3*C,g,h),qr.a.applyMatrix4(wi),qr.b.applyMatrix4(wi),qr.c.applyMatrix4(wi),qr.needsUpdate=!0;for(let P=0,O=b.count;P<O;P+=3)if(Je(Yr,P,b,R),Yr.needsUpdate=!0,qr.intersectsTriangle(Yr))return!0}}else{const v=o+8,g=u[o+6];return Ye(v,c,vs),!!(s.intersectsBox(vs)&&ja(v,e,n,i,s)||(Ye(g,c,vs),s.intersectsBox(vs)&&ja(g,e,n,i,s)))}}const _s=new m.Matrix4,qa=new gt,Ri=new gt,Ep=new m.Vector3,Sp=new m.Vector3,Mp=new m.Vector3,Cp=new m.Vector3;function Ip(o,e,n,i={},s={},c=0,a=1/0){e.boundingBox||e.computeBoundingBox(),qa.set(e.boundingBox.min,e.boundingBox.max,n),qa.needsUpdate=!0;const u=o.geometry,f=u.attributes.position,p=u.index,v=e.attributes.position,g=e.index,h=Yt.getPrimitive(),b=Yt.getPrimitive();let R=Ep,M=Sp,x=null,A=null;s&&(x=Mp,A=Cp);let E=1/0,C=null,P=null;return _s.copy(n).invert(),Ri.matrix.copy(_s),o.shapecast({boundsTraverseOrder:O=>qa.distanceToBox(O),intersectsBounds:(O,B,k)=>k<E&&k<a?(B&&(Ri.min.copy(O.min),Ri.max.copy(O.max),Ri.needsUpdate=!0),!0):!1,intersectsRange:(O,B)=>{if(e.boundsTree){const k=e.boundsTree;return k.shapecast({boundsTraverseOrder:q=>Ri.distanceToBox(q),intersectsBounds:(q,j,K)=>K<E&&K<a,intersectsRange:(q,j)=>{for(let K=q,$=q+j;K<$;K++){const H=k.resolveTriangleIndex(K);Je(b,3*H,g,v),b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let Z=O,Q=O+B;Z<Q;Z++){const ce=o.resolveTriangleIndex(Z);Je(h,3*ce,p,f),h.needsUpdate=!0;const Re=h.distanceToTriangle(b,R,x);if(Re<E&&(M.copy(R),A&&A.copy(x),E=Re,C=Z,P=K),Re<c)return!0}}}})}else{const k=kr(e);for(let q=0,j=k;q<j;q++){Je(b,3*q,g,v),b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let K=O,$=O+B;K<$;K++){const H=o.resolveTriangleIndex(K);Je(h,3*H,p,f),h.needsUpdate=!0;const Z=h.distanceToTriangle(b,R,x);if(Z<E&&(M.copy(R),A&&A.copy(x),E=Z,C=K,P=q),Z<c)return!0}}}}}),Yt.releasePrimitive(h),Yt.releasePrimitive(b),E===1/0?null:(i.point?i.point.copy(M):i.point=M.clone(),i.distance=E,i.faceIndex=C,s&&(s.point?s.point.copy(A):s.point=A.clone(),s.point.applyMatrix4(_s),M.applyMatrix4(_s),s.distance=M.sub(s.point).length(),s.faceIndex=P),i)}function Pp(){return typeof SharedArrayBuffer<"u"}const Ai=new Ge.constructor,xs=new Ge.constructor,Yn=new Na(()=>new m.Box3),Kr=new m.Box3,Xr=new m.Box3,Ya=new m.Box3,Ka=new m.Box3;let Xa=!1;function Dp(o,e,n,i){if(Xa)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Xa=!0;const s=o._roots,c=e._roots;let a,u=0,f=0;const p=new m.Matrix4().copy(n).invert();for(let v=0,g=s.length;v<g;v++){Ai.setBuffer(s[v]),f=0;const h=Yn.getPrimitive();Ye(0,Ai.float32Array,h),h.applyMatrix4(p);for(let b=0,R=c.length;b<R&&(xs.setBuffer(c[b]),a=rn(0,0,n,p,i,u,f,0,0,h),xs.clearBuffer(),f+=c[b].length,!a);b++);if(Yn.releasePrimitive(h),Ai.clearBuffer(),u+=s[v].length,a)break}return Xa=!1,a}function rn(o,e,n,i,s,c=0,a=0,u=0,f=0,p=null,v=!1){let g,h;v?(g=xs,h=Ai):(g=Ai,h=xs);const b=g.float32Array,R=g.uint32Array,M=g.uint16Array,x=h.float32Array,A=h.uint32Array,E=h.uint16Array,C=o*2,P=e*2,O=mt(C,M),B=mt(P,E);let k=!1;if(B&&O)v?k=s(Et(e,A),Ft(e*2,E),Et(o,R),Ft(o*2,M),f,a+e,u,c+o):k=s(Et(o,R),Ft(o*2,M),Et(e,A),Ft(e*2,E),u,c+o,f,a+e);else if(B){const q=Yn.getPrimitive();Ye(e,x,q),q.applyMatrix4(n);const j=qt(o),K=Ot(o,R);Ye(j,b,Kr),Ye(K,b,Xr);const $=q.intersectsBox(Kr),H=q.intersectsBox(Xr);k=$&&rn(e,j,i,n,s,a,c,f,u+1,q,!v)||H&&rn(e,K,i,n,s,a,c,f,u+1,q,!v),Yn.releasePrimitive(q)}else{const q=qt(e),j=Ot(e,A);Ye(q,x,Ya),Ye(j,x,Ka);const K=p.intersectsBox(Ya),$=p.intersectsBox(Ka);if(K&&$)k=rn(o,q,n,i,s,c,a,u,f+1,p,v)||rn(o,j,n,i,s,c,a,u,f+1,p,v);else if(K)if(O)k=rn(o,q,n,i,s,c,a,u,f+1,p,v);else{const H=Yn.getPrimitive();H.copy(Ya).applyMatrix4(n);const Z=qt(o),Q=Ot(o,R);Ye(Z,b,Kr),Ye(Q,b,Xr);const ce=H.intersectsBox(Kr),Re=H.intersectsBox(Xr);k=ce&&rn(q,Z,i,n,s,a,c,f,u+1,H,!v)||Re&&rn(q,Q,i,n,s,a,c,f,u+1,H,!v),Yn.releasePrimitive(H)}else if($)if(O)k=rn(o,j,n,i,s,c,a,u,f+1,p,v);else{const H=Yn.getPrimitive();H.copy(Ka).applyMatrix4(n);const Z=qt(o),Q=Ot(o,R);Ye(Z,b,Kr),Ye(Q,b,Xr);const ce=H.intersectsBox(Kr),Re=H.intersectsBox(Xr);k=ce&&rn(j,Z,i,n,s,a,c,f,u+1,H,!v)||Re&&rn(j,Q,i,n,s,a,c,f,u+1,H,!v),Yn.releasePrimitive(H)}}return k}const bs=new gt,sl=new m.Box3,Fp={strategy:Hc,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Za{static serialize(e,n={}){n={cloneBuffers:!0,...n};const i=e.geometry,s=e._roots,c=e._indirectBuffer,a=i.getIndex();let u;return n.cloneBuffers?u={roots:s.map(f=>f.slice()),index:a?a.array.slice():null,indirectBuffer:c?c.slice():null}:u={roots:s,index:a?a.array:null,indirectBuffer:c},u}static deserialize(e,n,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:c,indirectBuffer:a}=e,u=new Za(n,{...i,[Ma]:!0});if(u._roots=c,u._indirectBuffer=a||null,i.setIndex){const f=n.getIndex();if(f===null){const p=new m.BufferAttribute(e.index,1,!1);n.setIndex(p)}else f.array!==s&&(f.array.set(s),f.needsUpdate=!0)}return u}get indirect(){return!!this._indirectBuffer}constructor(e,n={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(n=Object.assign({...Fp,[Ma]:!1},n),n.useSharedArrayBuffer&&!Pp())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,n[Ma]||(Xd(this,n),!e.boundingBox&&n.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new m.Box3))),this.resolveTriangleIndex=n.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?bp:cp)(this,e)}traverse(e,n=0){const i=this._roots[n],s=new Uint32Array(i),c=new Uint16Array(i);a(0);function a(u,f=0){const p=u*2,v=c[p+15]===is;if(v){const g=s[u+6],h=c[p+14];e(f,v,new Float32Array(i,u*4,6),g,h)}else{const g=u+Wn/4,h=s[u+6],b=s[u+7];e(f,v,new Float32Array(i,u*4,6),b)||(a(g,f+1),a(h,f+1))}}}raycast(e,n=m.FrontSide,i=0,s=1/0){const c=this._roots,a=this.geometry,u=[],f=n.isMaterial,p=Array.isArray(n),v=a.groups,g=f?n.side:n,h=this.indirect?Tp:hp;for(let b=0,R=c.length;b<R;b++){const M=p?n[v[b].materialIndex].side:g,x=u.length;if(h(this,b,M,e,u,i,s),p){const A=v[b].materialIndex;for(let E=x,C=u.length;E<C;E++)u[E].face.materialIndex=A}}return u}raycastFirst(e,n=m.FrontSide,i=0,s=1/0){const c=this._roots,a=this.geometry,u=n.isMaterial,f=Array.isArray(n);let p=null;const v=a.groups,g=u?n.side:n,h=this.indirect?Rp:pp;for(let b=0,R=c.length;b<R;b++){const M=f?n[v[b].materialIndex].side:g,x=h(this,b,M,e,i,s);x!=null&&(p==null||x.distance<p.distance)&&(p=x,f&&(x.face.materialIndex=v[b].materialIndex))}return p}intersectsGeometry(e,n){let i=!1;const s=this._roots,c=this.indirect?Ap:mp;for(let a=0,u=s.length;a<u&&(i=c(this,a,e,n),!i);a++);return i}shapecast(e){const n=Yt.getPrimitive(),i=this.indirect?fp:op;let{boundsTraverseOrder:s,intersectsBounds:c,intersectsRange:a,intersectsTriangle:u}=e;if(a&&u){const g=a;a=(h,b,R,M,x)=>g(h,b,R,M,x)?!0:i(h,b,this,u,R,M,n)}else a||(u?a=(g,h,b,R)=>i(g,h,this,u,b,R,n):a=(g,h,b)=>b);let f=!1,p=0;const v=this._roots;for(let g=0,h=v.length;g<h;g++){const b=v[g];if(f=tp(this,g,c,a,s,p),f)break;p+=b.byteLength}return Yt.releasePrimitive(n),f}bvhcast(e,n,i){let{intersectsRanges:s,intersectsTriangles:c}=i;const a=Yt.getPrimitive(),u=this.geometry.index,f=this.geometry.attributes.position,p=this.indirect?R=>{const M=this.resolveTriangleIndex(R);Je(a,M*3,u,f)}:R=>{Je(a,R*3,u,f)},v=Yt.getPrimitive(),g=e.geometry.index,h=e.geometry.attributes.position,b=e.indirect?R=>{const M=e.resolveTriangleIndex(R);Je(v,M*3,g,h)}:R=>{Je(v,R*3,g,h)};if(c){const R=(M,x,A,E,C,P,O,B)=>{for(let k=A,q=A+E;k<q;k++){b(k),v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let j=M,K=M+x;j<K;j++)if(p(j),a.needsUpdate=!0,c(a,v,j,k,C,P,O,B))return!0}return!1};if(s){const M=s;s=function(x,A,E,C,P,O,B,k){return M(x,A,E,C,P,O,B,k)?!0:R(x,A,E,C,P,O,B,k)}}else s=R}return Dp(this,e,n,s)}intersectsBox(e,n){return bs.set(e.min,e.max,n),bs.needsUpdate=!0,this.shapecast({intersectsBounds:i=>bs.intersectsBox(i),intersectsTriangle:i=>bs.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:n=>e.intersectsBox(n),intersectsTriangle:n=>n.intersectsSphere(e)})}closestPointToGeometry(e,n,i={},s={},c=0,a=1/0){return(this.indirect?Ip:xp)(this,e,n,i,s,c,a)}closestPointToPoint(e,n={},i=0,s=1/0){return np(this,e,n,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Ye(0,new Float32Array(i),sl),e.union(sl)}),e}}function Op(o){switch(o){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function Lp(o){switch(o){case 1:return m.RedFormat;case 2:return m.RGFormat;case 3:return m.RGBAFormat;case 4:return m.RGBAFormat}}function al(o){switch(o){case 1:return m.RedIntegerFormat;case 2:return m.RGIntegerFormat;case 3:return m.RGBAIntegerFormat;case 4:return m.RGBAIntegerFormat}}class ol extends m.DataTexture{constructor(){super(),this.minFilter=m.NearestFilter,this.magFilter=m.NearestFilter,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const n=this.overrideItemSize,i=e.itemSize,s=e.count;if(n!==null){if(i*s%n!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=n,e.count=s*i/n}const c=e.itemSize,a=e.count,u=e.normalized,f=e.array.constructor,p=f.BYTES_PER_ELEMENT;let v=this._forcedType,g=c;if(v===null)switch(f){case Float32Array:v=m.FloatType;break;case Uint8Array:case Uint16Array:case Uint32Array:v=m.UnsignedIntType;break;case Int8Array:case Int16Array:case Int32Array:v=m.IntType;break}let h,b,R,M,x=Op(c);switch(v){case m.FloatType:R=1,b=Lp(c),u&&p===1?(M=f,x+="8",f===Uint8Array?h=m.UnsignedByteType:(h=m.ByteType,x+="_SNORM")):(M=Float32Array,x+="32F",h=m.FloatType);break;case m.IntType:x+=p*8+"I",R=u?Math.pow(2,f.BYTES_PER_ELEMENT*8-1):1,b=al(c),p===1?(M=Int8Array,h=m.ByteType):p===2?(M=Int16Array,h=m.ShortType):(M=Int32Array,h=m.IntType);break;case m.UnsignedIntType:x+=p*8+"UI",R=u?Math.pow(2,f.BYTES_PER_ELEMENT*8-1):1,b=al(c),p===1?(M=Uint8Array,h=m.UnsignedByteType):p===2?(M=Uint16Array,h=m.UnsignedShortType):(M=Uint32Array,h=m.UnsignedIntType);break}g===3&&(b===m.RGBAFormat||b===m.RGBAIntegerFormat)&&(g=4);const A=Math.ceil(Math.sqrt(a))||1,E=g*A*A,C=new M(E),P=e.normalized;e.normalized=!1;for(let O=0;O<a;O++){const B=g*O;C[B]=e.getX(O)/R,c>=2&&(C[B+1]=e.getY(O)/R),c>=3&&(C[B+2]=e.getZ(O)/R,g===4&&(C[B+3]=1)),c>=4&&(C[B+3]=e.getW(O)/R)}e.normalized=P,this.internalFormat=x,this.format=b,this.type=h,this.image.width=A,this.image.height=A,this.image.data=C,this.needsUpdate=!0,this.dispose(),e.itemSize=i,e.count=s}}class cl extends ol{constructor(){super(),this._forcedType=m.UnsignedIntType}}class ll extends ol{constructor(){super(),this._forcedType=m.FloatType}}class Np{constructor(){this.index=new cl,this.position=new ll,this.bvhBounds=new m.DataTexture,this.bvhContents=new m.DataTexture,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:n}=e;if(kp(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(n.attributes.position),e.indirect){const i=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==i.length)if(n.index)this._cachedIndexAttr=n.index.clone();else{const s=qc(jc(n));this._cachedIndexAttr=new m.BufferAttribute(s,1,!1)}Bp(n,i,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(n.index)}dispose(){const{index:e,position:n,bvhBounds:i,bvhContents:s}=this;e&&e.dispose(),n&&n.dispose(),i&&i.dispose(),s&&s.dispose()}}function Bp(o,e,n){const i=n.array,s=o.index?o.index.array:null;for(let c=0,a=e.length;c<a;c++){const u=3*c,f=3*e[c];for(let p=0;p<3;p++)i[u+p]=s?s[f+p]:f+p}}function kp(o,e,n){const i=o._roots;if(i.length!==1)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const s=i[0],c=new Uint16Array(s),a=new Uint32Array(s),u=new Float32Array(s),f=s.byteLength/Wn,p=2*Math.ceil(Math.sqrt(f/2)),v=new Float32Array(4*p*p),g=Math.ceil(Math.sqrt(f)),h=new Uint32Array(2*g*g);for(let b=0;b<f;b++){const R=b*Wn/4,M=R*2,x=R;for(let A=0;A<3;A++)v[8*b+0+A]=u[x+0+A],v[8*b+4+A]=u[x+3+A];if(mt(M,c)){const A=Ft(M,c),E=Et(R,a),C=4294901760|A;h[b*2+0]=C,h[b*2+1]=E}else{const A=4*Ot(R,a)/Wn,E=Pa(R,a);h[b*2+0]=E,h[b*2+1]=A}}e.image.data=v,e.image.width=p,e.image.height=p,e.format=m.RGBAFormat,e.type=m.FloatType,e.internalFormat="RGBA32F",e.minFilter=m.NearestFilter,e.magFilter=m.NearestFilter,e.generateMipmaps=!1,e.needsUpdate=!0,e.dispose(),n.image.data=h,n.image.width=g,n.image.height=g,n.format=m.RGIntegerFormat,n.type=m.UnsignedIntType,n.internalFormat="RG32UI",n.minFilter=m.NearestFilter,n.magFilter=m.NearestFilter,n.generateMipmaps=!1,n.needsUpdate=!0,n.dispose()}const Up=`
|
|
30
|
+
<%s key={someKey} {...props} />`,q,R,Y,R),cr[R+q]=!0}}return m===r?on(_):sn(_),_}}function an(m,I,N){return lr(m,I,N,!0)}function cn(m,I,N){return lr(m,I,N,!1)}var Lr=cn,ln=an;kr.Fragment=r,kr.jsx=Lr,kr.jsxs=ln}()),kr}var ji;function Co(){return ji||(ji=1,process.env.NODE_ENV==="production"?hn.exports=Mo():hn.exports=Io()),hn.exports}var qe=Co();class ce extends Error{constructor(e,t,r){super(e),this.code=t,this.context=r,this.name="ThreeViewerError",this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,ce)}static fromError(e,t,r){if(e instanceof ce)return e;const n=e instanceof Error?e.message:String(e),o={...r,originalError:e instanceof Error?{name:e.name,message:e.message,stack:e.stack}:e};return new ce(n,t,o)}}var ue=(s=>(s.SCENE_INIT_FAILED="SCENE_INIT_FAILED",s.RENDERER_INIT_FAILED="RENDERER_INIT_FAILED",s.RENDERER_NOT_INITIALIZED="RENDERER_NOT_INITIALIZED",s.CAMERA_INIT_FAILED="CAMERA_INIT_FAILED",s.WEBGL_NOT_SUPPORTED="WEBGL_NOT_SUPPORTED",s.INITIALIZATION_FAILED="INITIALIZATION_FAILED",s.PATH_TRACING_INIT_FAILED="PATH_TRACING_INIT_FAILED",s.MODEL_LOAD_FAILED="MODEL_LOAD_FAILED",s.TEXTURE_LOAD_FAILED="TEXTURE_LOAD_FAILED",s.RESOURCE_NOT_FOUND="RESOURCE_NOT_FOUND",s.UNSUPPORTED_FORMAT="UNSUPPORTED_FORMAT",s.INVALID_CONFIGURATION="INVALID_CONFIGURATION",s.RENDER_ERROR="RENDER_ERROR",s.RENDER_FAILED="RENDER_FAILED",s.SCENE_OPERATION_FAILED="SCENE_OPERATION_FAILED",s.COMPONENT_NOT_MOUNTED="COMPONENT_NOT_MOUNTED",s.INVALID_STATE="INVALID_STATE",s.INVALID_PARAMETER="INVALID_PARAMETER",s.OPERATION_FAILED="OPERATION_FAILED",s.UNKNOWN="UNKNOWN",s))(ue||{});const X={ok(s){return{ok:!0,value:s}},err(s){return{ok:!1,error:s}},wrap(s){try{return X.ok(s())}catch(e){return X.err(e instanceof ce?e:new ce(String(e),ue.UNKNOWN,{originalError:e}))}}};class st{constructor(e={}){this.data=Object.freeze({status:"idle",currentModel:null,error:null,isInitialized:!1,loadProgress:0,renderInfo:{frameCount:0,fps:0,lastRenderTime:0,averageRenderTime:0},...e})}get status(){return this.data.status}get currentModel(){return this.data.currentModel}get error(){return this.data.error}get isInitialized(){return this.data.isInitialized}get loadProgress(){return this.data.loadProgress}get renderInfo(){return this.data.renderInfo}setInitialized(){return new st({...this.data,isInitialized:!0,status:"idle"})}startLoading(){return new st({...this.data,status:"loading",loadProgress:0,error:null})}updateLoadProgress(e){return new st({...this.data,loadProgress:Math.min(Math.max(0,e),1)})}setLoaded(e){return new st({...this.data,status:"loaded",currentModel:e,loadProgress:1,error:null})}setError(e){return new st({...this.data,status:"error",error:e,loadProgress:0})}startRendering(){return new st({...this.data,status:"rendering"})}updateRenderInfo(e){return new st({...this.data,renderInfo:{...this.data.renderInfo,...e}})}dispose(){return new st({...this.data,status:"disposed",currentModel:null})}canLoad(){return this.data.isInitialized&&(this.data.status==="idle"||this.data.status==="loaded"||this.data.status==="error"||this.data.status==="rendering")}canRender(){return this.data.isInitialized&&this.data.status==="loaded"&&this.data.currentModel!==null}isLoading(){return this.data.status==="loading"}hasError(){return this.data.status==="error"&&this.data.error!==null}toJSON(){return{...this.data}}}class fn{constructor(){this.listeners=new Map}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set);const r=this.listeners.get(e);return r&&r.add(t),()=>{var n;(n=this.listeners.get(e))==null||n.delete(t)}}emit(e,t){var r;(r=this.listeners.get(e))==null||r.forEach(n=>{try{n(t)}catch(o){console.error(`Error in event listener for ${String(e)}:`,o)}})}once(e,t){const r=this.on(e,n=>{r(),t(n)});return r}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}listenerCount(e){var t;return((t=this.listeners.get(e))==null?void 0:t.size)||0}off(e,t){var r;(r=this.listeners.get(e))==null||r.delete(t)}removeListener(e,t){this.off(e,t)}}class Po{constructor(e={}){this.animationFrameId=null,this.lastRenderTime=0,this.idleTimeout=null,this.isIdle=!1,this.needsRender=!0,this.continuousRenderingEnabled=!1,this.alwaysRender=!1,this.enableIdleDetection=e.enableIdleDetection??!0,this.idleDelay=e.idleDelay??1e3,this.targetFPS=e.targetFPS??60,this.frameInterval=1e3/this.targetFPS,this.enableFrameRateLimiting=e.enableFrameRateLimiting??!0,this.alwaysRender=e.alwaysRender??!1,this.lastRenderTime=performance.now()}requestRender(){this.needsRender=!0,this.wakeUp()}enableContinuousRendering(){this.continuousRenderingEnabled=!0,this.wakeUp()}disableContinuousRendering(){this.continuousRenderingEnabled=!1}setAlwaysRender(e){this.alwaysRender=e,e&&this.wakeUp()}wakeUp(){this.idleTimeout!==null&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.isIdle=!1}start(e){if(this.animationFrameId!==null)return;const t=r=>{if(this.animationFrameId===null)return;const n=r-this.lastRenderTime;if(this.enableFrameRateLimiting&&n<this.frameInterval){this.animationFrameId=requestAnimationFrame(t);return}(this.alwaysRender||this.needsRender||this.continuousRenderingEnabled)&&(e(n),this.lastRenderTime=r,this.needsRender=!1,this.enableIdleDetection&&!this.alwaysRender&&(this.wakeUp(),this.continuousRenderingEnabled||(this.idleTimeout=window.setTimeout(()=>{this.isIdle=!0,console.log("[RenderLoopManager] Entering idle state")},this.idleDelay)))),this.alwaysRender||!this.enableIdleDetection||!this.isIdle||this.continuousRenderingEnabled||this.needsRender?this.animationFrameId=requestAnimationFrame(t):(console.log("[RenderLoopManager] Stopping render loop (idle)"),this.animationFrameId=null)};this.animationFrameId=requestAnimationFrame(t)}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.idleTimeout!==null&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.isIdle=!1,this.needsRender=!1,this.continuousRenderingEnabled=!1,this.alwaysRender=!1}isRunning(){return this.animationFrameId!==null}getIsIdle(){return this.isIdle}getNeedsRender(){return this.needsRender||this.continuousRenderingEnabled||this.alwaysRender}}class Wi{static serialize(e,t,r,n){const o=t.position,i=r.target||{x:0,y:0,z:0};return{modelUrl:e,cameraPosition:{x:o.x,y:o.y,z:o.z},cameraTarget:{x:i.x,y:i.y,z:i.z},controlsTarget:{x:i.x,y:i.y,z:i.z},rendererSize:{width:n.clientWidth,height:n.clientHeight}}}static async restore(e,t,r,n){t.position.set(e.cameraPosition.x,e.cameraPosition.y,e.cameraPosition.z),t.lookAt({x:e.cameraTarget.x,y:e.cameraTarget.y,z:e.cameraTarget.z,set:()=>{},copy:()=>{},add:()=>{},multiply:()=>{},normalize:()=>{},length:()=>0}),r.target&&r.target.set(e.controlsTarget.x,e.controlsTarget.y,e.controlsTarget.z),r.update&&r.update(),e.modelUrl&&n&&await n(e.modelUrl)}}class Yn{static getMemoryInfo(){const e=performance;return e.memory?{jsHeapUsed:Math.round(e.memory.usedJSHeapSize/1048576),jsHeapTotal:Math.round(e.memory.totalJSHeapSize/1048576),jsHeapLimit:Math.round(e.memory.jsHeapSizeLimit/1048576)}:null}static formatBytes(e){return e<1024?e+" B":e<1048576?(e/1024).toFixed(1)+" KB":e<1073741824?(e/1048576).toFixed(1)+" MB":(e/1073741824).toFixed(1)+" GB"}static logMemoryUsage(e="Memory"){const t=this.getMemoryInfo();t?(console.log(`[${e}] JS Heap: ${t.jsHeapUsed}MB / ${t.jsHeapTotal}MB (Limit: ${t.jsHeapLimit}MB)`),t.webglMemory&&console.log(`[${e}] WebGL - Programs: ${t.webglMemory.programs}, Geometries: ${t.webglMemory.geometries}, Textures: ${t.webglMemory.textures}`)):console.log(`[${e}] Memory info not available (use Chrome with --enable-precise-memory-info)`)}static startMonitoring(e=5e3,t="MemoryMonitor"){const r=setInterval(()=>{this.logMemoryUsage(t)},e);return()=>clearInterval(r)}}function At(s){return s!==null&&typeof s=="object"&&"getInternalRenderer"in s&&typeof s.getInternalRenderer=="function"}class Do{constructor(e){this.lastFrameTime=0,this.frameCount=0,this.screenshotElement=null,this.isShowingScreenshot=!1,this.pathTracingCompleteHandled=!1,this.disposed=!1,this.renderer=e.renderer,this.scene=e.scene,this.camera=e.camera,this.controls=e.controls,this.modelLoader=e.modelLoader,this.options=e.options,this.rendererOptions=e.rendererOptions,this.sceneSetupService=e.sceneSetupService,this.environmentService=e.environmentService,this.pathTracingService=e.pathTracingService,this.floorAlignmentService=e.floorAlignmentService,this.state=new st,this.events=new fn;const t=this.options.rendering||{},r=this.options.staticScene!==!1;this.renderLoopManager=new Po({enableIdleDetection:t.enableIdleDetection??r,idleDelay:t.idleDelay,targetFPS:t.targetFPS,enableFrameRateLimiting:t.enableFrameRateLimiting,alwaysRender:!1})}async initialize(){var e,t,r,n,o;try{const i=this.rendererOptions||{},a=this.renderer.initialize(i);if(!a.ok)return a;if(this.sceneSetupService){if(this.options.helpers){const h={grid:typeof this.options.helpers.grid=="boolean"?this.options.helpers.grid:!!this.options.helpers.grid,axes:typeof this.options.helpers.axes=="boolean"?this.options.helpers.axes:!!this.options.helpers.axes,gridColor:"#AAAAAA"},l=this.sceneSetupService.addHelpers(this.scene,h);l.ok||console.warn("Failed to add helpers:",l.error)}const u=this.options.lighting;if(u){const h={ambient:u.ambientLight?{color:String(u.ambientLight.color),intensity:u.ambientLight.intensity}:void 0,hemisphere:u.hemisphereLight?{skyColor:String(u.hemisphereLight.skyColor),groundColor:String(u.hemisphereLight.groundColor),intensity:u.hemisphereLight.intensity}:void 0,directional:u.directionalLight?{color:String(u.directionalLight.color),intensity:u.directionalLight.intensity,position:Array.isArray(u.directionalLight.position)?u.directionalLight.position:void 0,castShadow:u.directionalLight.castShadow,shadow:u.directionalLight.shadow}:void 0},l=this.sceneSetupService.addLighting(this.scene,h);l.ok||console.warn("Failed to add lighting:",l.error)}const d=(e=this.options.environment)==null?void 0:e.url;if(this.options.backgroundColor&&!d&&this.sceneSetupService){const h=this.sceneSetupService.createGradientBackground(this.scene,{topColor:String(this.options.backgroundColor),bottomColor:String(this.options.backgroundColor)});h.ok||console.warn("Failed to set background:",h.error)}}if(this.environmentService){const u=await this.environmentService.initialize({renderer:this.renderer,autoDispose:!0});u.ok||console.warn("Failed to initialize environment service:",u.error);const d=(t=this.options.environment)==null?void 0:t.url;if(d){const h=await this.environmentService.loadEnvironmentMap(d);h.ok?this.environmentService.applyToScene(this.scene,h.value):console.warn("Failed to load environment map:",h.error)}else if((r=this.options.helpers)!=null&&r.studioEnvironment){const h=this.environmentService.createStudioEnvironment();h.ok?this.environmentService.applyToScene(this.scene,h.value):console.warn("Failed to create studio environment:",h.error)}}const c=((n=this.options.pathTracing)==null?void 0:n.enabled)??!1;if(this.pathTracingService&&c){const u=await this.pathTracingService.initialize({enabled:!0,renderer:this.renderer});u.ok?(this.options.pathTracing&&this.pathTracingService.updateSettings({samples:this.options.pathTracing.maxSamples??300,bounces:this.options.pathTracing.bounces,transmissiveBounces:this.options.pathTracing.transmissiveBounces,renderScale:this.options.pathTracing.renderScale,lowResScale:this.options.pathTracing.lowResScale,dynamicLowRes:this.options.pathTracing.dynamicLowRes,enablePathTracing:this.options.pathTracing.enabled??c}),this.pathTracingService.events.on("pathtracing:paused",d=>{this.renderLoopManager.disableContinuousRendering(),this.options.staticScene||this.renderLoopManager.setAlwaysRender(!1),setTimeout(()=>{this.renderLoopManager.stop()},100)})):console.warn("Failed to initialize path tracing:",u.error)}if(this.state=this.state.setInitialized(),this.startRenderLoop(),!this.options.staticScene)this.renderLoopManager.setAlwaysRender(!0);else{const u=((o=this.options.pathTracing)==null?void 0:o.enabled)??!1;this.pathTracingService&&u&&this.renderLoopManager.enableContinuousRendering()}return this.renderLoopManager.requestRender(),X.ok(void 0)}catch(i){const a=new ce("Failed to initialize viewer",ue.INITIALIZATION_FAILED,{originalError:i});return this.state=this.state.setError(a),this.events.emit("error",{error:a}),X.err(a)}}async loadModel(e){var t,r;if(!this.state.canLoad())return X.err(new ce("Cannot load model in current state",ue.INVALID_STATE,{currentState:this.state.status,isInitialized:this.state.isInitialized}));try{this.state=this.state.startLoading();const n=performance.now();let o;if(typeof e=="string"){this.lastModelUrl=e;const u=await this.modelLoader.load(e);if(!u.ok)throw u.error;o=u.value.scene}else o=e;this.state.currentModel&&(this.scene.remove(this.state.currentModel),this.state.currentModel.dispose());const i=this.scene.add(o);if(!i.ok)throw i.error;if(this.floorAlignmentService){const u=this.floorAlignmentService.alignToFloor(o);u.ok||console.warn("Failed to align model to floor:",u.error)}if(o.traverse(u=>{"castShadow"in u&&"receiveShadow"in u&&(u.castShadow=!0,u.receiveShadow=!0)}),this.state=this.state.setLoaded(o),this.sceneSetupService){const u=this.sceneSetupService.addDynamicGrid(this.scene,o,2);u.ok||console.warn("Failed to add dynamic grid:",u.error)}if((t=this.options.camera)!=null&&t.autoFitToObject&&this.sceneSetupService){const u=this.sceneSetupService.fitCameraToObject(o,this.camera,this.controls);u.ok||console.warn("Failed to fit camera to object:",u.error)}const a=performance.now()-n;this.events.emit("model:loaded",{model:o,loadTime:a}),this.renderLoopManager.requestRender();const c=((r=this.options.pathTracing)==null?void 0:r.enabled)??!1;return this.pathTracingService&&c&&(this.pathTracingService.reset(),this.pathTracingCompleteHandled=!1),X.ok(void 0)}catch(n){const o=n instanceof ce?n:new ce("Failed to load model",ue.MODEL_LOAD_FAILED,{originalError:n,source:e});return this.state=this.state.setError(o),this.events.emit("model:error",{error:o,url:typeof e=="string"?e:void 0}),X.err(o)}}startRenderLoop(){this.renderLoopManager.start(e=>{var u,d,h,l,v;if(this.disposed){this.renderLoopManager.stop();return}if(!this.state.isInitialized||this.state.status==="error")return;if(!this.renderer||this.renderer.renderer===null){this.renderLoopManager.stop();return}this.frameCount%60;const t=performance.now(),r=e>0?1e3/e:0;if(this.controls.update()){this.events.emit("controls:change",{controls:this.controls});const b=((u=this.options.pathTracing)==null?void 0:u.enabled)??!1;this.pathTracingService&&b&&(this.pathTracingService.reset(),this.pathTracingCompleteHandled=!1),this.renderLoopManager.requestRender()}const o=((d=this.pathTracingService)==null?void 0:d.isEnabled())||!1,i=((h=this.pathTracingService)==null?void 0:h.getSampleCount())||0,a=((l=this.options.pathTracing)==null?void 0:l.maxSamples)??300;if(this.renderFrame().catch(b=>{console.error("[ViewerCore] Render frame error:",b)}),(((v=this.pathTracingService)==null?void 0:v.getSampleCount())||0)>=a&&!this.pathTracingCompleteHandled&&o){if(this.pathTracingCompleteHandled=!0,this.renderLoopManager.disableContinuousRendering(),this.options.staticScene||this.renderLoopManager.setAlwaysRender(!1),this.events.emit("pathtracing:complete",{samples:i,totalTime:t-(this.pathTracingStartTime||0)}),this.options.replaceWithScreenshotOnComplete)setTimeout(()=>{this.replaceWithScreenshot(),setTimeout(()=>{this.renderLoopManager.stop()},200)},100);else if(this.renderLoopManager.requestRender(),setTimeout(()=>{this.renderLoopManager.stop()},100),At(this.renderer)){const b=this.renderer.getInternalRenderer();b&&(b.autoClear=!1)}}this.frameCount++,this.state=this.state.updateRenderInfo({frameCount:this.frameCount,fps:Math.round(r),lastRenderTime:performance.now()-t}),this.lastFrameTime=t})}stopRenderLoop(){this.renderLoopManager.stop()}async renderFrame(){var u,d,h,l;const e=performance.now();if(!this.renderer||!this.scene||!this.camera){console.warn("[ViewerCore] Cannot render - components not initialized");return}if(this.isShowingScreenshot)return;this.state=this.state.startRendering();let t;const r=((u=this.pathTracingService)==null?void 0:u.isEnabled())||!1,n=((d=this.pathTracingService)==null?void 0:d.getSampleCount())||0,o=((h=this.options.pathTracing)==null?void 0:h.maxSamples)??300;if(this.pathTracingService&&!this.pathTracingService.isPathTracerDisposed()&&(r||n>=o&&n>0)&&this.pathTracingService?(this.pathTracingService.getSampleCount()===0&&(this.pathTracingStartTime=performance.now()),t=await this.pathTracingService.render(this.scene,this.camera)):t=this.renderer.render(this.scene,this.camera),!t.ok){console.error("[ViewerCore] Render failed:",t.error),this.events.emit("error",{error:t.error});return}const a=performance.now()-e,c=((l=this.pathTracingService)==null?void 0:l.getSampleCount())||0;this.events.emit("render:complete",{frame:this.frameCount,renderTime:a,samples:c})}resize(e,t){var o;const r=this.renderer.getDomElement();if(r.width===e&&r.height===t)return;const n=(o=this.pathTracingService)==null?void 0:o.isEnabled();this.pathTracingService&&this.pathTracingService.hasImageOverlay()&&(this.pathTracingService.removeImageOverlay(),this.pathTracingService.reset()),this.camera.type==="perspective"&&"aspect"in this.camera&&(this.camera.aspect=e/t),this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t);try{this.renderer.render(this.scene,this.camera)}catch{}n&&this.pathTracingService&&this.pathTracingService.setEnabled(!0),this.renderLoopManager.requestRender()}getState(){return this.state}onStateChange(e){const t=r=>{this.state=r,e(r)};return this.stateChangeCallback=t,()=>{this.stateChangeCallback=void 0}}getEvents(){return this.events}getDomElement(){return this.renderer.getDomElement()}replaceWithScreenshot(){if(this.isShowingScreenshot)return;const e=this.renderer.getDomElement(),t=e.toDataURL("image/png"),r=document.createElement("img");r.src=t,r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.width="100%",r.style.height="100%",r.style.pointerEvents="auto",r.style.cursor="grab";const n=e.parentElement;if(n){e.style.display="none",n.appendChild(r),this.screenshotElement=r,this.isShowingScreenshot=!0;const o=()=>{this.restoreFromScreenshot()};r.addEventListener("mousedown",o),r.addEventListener("touchstart",o);const i=()=>{this.isShowingScreenshot&&this.restoreFromScreenshot()};window.addEventListener("resize",i),this.screenshotResizeHandler=i,this.screenshotElement&&this.screenshotElement.src?this.disposeSceneResources():console.warn("[ViewerCore] Screenshot capture failed, keeping scene resources")}}async restoreFromScreenshot(){var r;if(!this.isShowingScreenshot||!this.screenshotElement)return;const e=this.renderer.getDomElement(),t=this.screenshotElement.parentElement;t&&(this.screenshotResizeHandler&&(window.removeEventListener("resize",this.screenshotResizeHandler),this.screenshotResizeHandler=void 0),t.removeChild(this.screenshotElement),e.style.display="",this.screenshotElement=null,this.isShowingScreenshot=!1,!this.pathTracingService&&((r=this.options.pathTracing)!=null&&r.enabled)&&console.warn("[ViewerCore] Cannot recreate path tracing service - feature disabled"),this.serializedSceneState&&await Wi.restore(this.serializedSceneState,this.camera,this.controls,async n=>{const o=await this.loadModel(n);o.ok||console.error("[ViewerCore] Failed to reload model:",o.error)}),this.renderLoopManager.isRunning()||this.startRenderLoop(),this.renderLoopManager.requestRender())}disposeSceneResources(){var e;Yn.logMemoryUsage("Before disposal"),this.renderLoopManager.stop(),this.serializedSceneState=Wi.serialize(this.lastModelUrl,this.camera,this.controls,this.renderer.getDomElement()),this.pathTracingService,this.environmentService&&this.environmentService.dispose(),this.state.currentModel&&(this.scene.remove(this.state.currentModel),this.disposeObject(this.state.currentModel),this.state=new st().setInitialized()),this.scene.traverse(t=>{var r,n,o,i;"geometry"in t&&t.geometry&&((n=(r=t.geometry).dispose)==null||n.call(r)),"material"in t&&t.material&&(Array.isArray(t.material)?t.material.forEach(a=>{var c;(c=a.dispose)==null||c.call(a)}):(i=(o=t.material).dispose)==null||i.call(o))}),this.scene.clear(),globalThis.gc&&((e=globalThis.gc)==null||e.call(globalThis)),Yn.logMemoryUsage("After disposal"),setTimeout(()=>{Yn.logMemoryUsage("After GC delay")},2e3)}disposeObject(e){e.traverse(t=>{var r,n,o;if("geometry"in t&&((r=t.geometry)!=null&&r.dispose)&&((o=(n=t.geometry)==null?void 0:n.dispose)==null||o.call(n)),"material"in t&&t.material){const i=t.material;Array.isArray(i)?i.forEach(a=>{var c;(c=a.dispose)==null||c.call(a)}):i!=null&&i.dispose&&i.dispose()}}),e.dispose()}dispose(){this.disposed=!0,this.stopRenderLoop(),this.state.currentModel&&(this.scene.remove(this.state.currentModel),this.state.currentModel.dispose()),this.pathTracingService&&this.pathTracingService.dispose(),this.environmentService&&this.environmentService.dispose(),this.scene.clear(),this.controls.dispose(),this.renderer.dispose(),this.state=this.state.dispose(),this.events.removeAllListeners()}}class Nt{constructor(e){this.vector=e}get x(){return this.vector.x}set x(e){this.vector.x=e}get y(){return this.vector.y}set y(e){this.vector.y=e}get z(){return this.vector.z}set z(e){this.vector.z=e}set(e,t,r){this.vector.set(e,t,r)}copy(e){this.vector.set(e.x,e.y,e.z)}add(e){this.vector.x+=e.x,this.vector.y+=e.y,this.vector.z+=e.z}multiply(e){this.vector.x*=e.x,this.vector.y*=e.y,this.vector.z*=e.z}normalize(){this.vector.normalize()}length(){return this.vector.length()}getThreeVector(){return this.vector}static fromThreeVector(e){return new Nt(e)}static create(e=0,t=0,r=0){return new Nt(new C.Vector3(e,t,r))}}class We{constructor(e){this.object=e,this.positionAdapter=Nt.fromThreeVector(e.position),this.rotationAdapter=Nt.fromThreeVector(e.rotation),this.scaleAdapter=Nt.fromThreeVector(e.scale)}get id(){return this.object.uuid}get name(){return this.object.name}set name(e){this.object.name=e}get visible(){return this.object.visible}set visible(e){this.object.visible=e}get position(){return this.positionAdapter}get rotation(){return this.rotationAdapter}get scale(){return this.scaleAdapter}add(e){try{return e instanceof We?(this.object.add(e.getThreeObject()),X.ok(void 0)):X.err(new ce("Child must be a ThreeObject3DAdapter",ue.INVALID_PARAMETER))}catch(t){return X.err(new ce("Failed to add child object",ue.SCENE_OPERATION_FAILED,{originalError:t}))}}remove(e){try{return e instanceof We?(this.object.remove(e.getThreeObject()),X.ok(void 0)):X.err(new ce("Child must be a ThreeObject3DAdapter",ue.INVALID_PARAMETER))}catch(t){return X.err(new ce("Failed to remove child object",ue.SCENE_OPERATION_FAILED,{originalError:t}))}}traverse(e){this.object.traverse(t=>{e(new We(t))})}clone(){return new We(this.object.clone())}dispose(){this.object.traverse(e=>{var t;e instanceof C.Mesh&&((t=e.geometry)==null||t.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(r=>r.dispose()):e.material.dispose()))})}getThreeObject(){return this.object}static fromThreeObject(e){return new We(e)}static create(){return new We(new C.Object3D)}}class Wt{constructor(e){this.scene=e||new C.Scene}get id(){return this.scene.uuid}get name(){return this.scene.name}set name(e){this.scene.name=e}add(e){try{return e instanceof We?(this.scene.add(e.getThreeObject()),X.ok(void 0)):X.err(new ce("Object must be a ThreeObject3DAdapter",ue.INVALID_PARAMETER))}catch(t){return X.err(new ce("Failed to add object to scene",ue.SCENE_OPERATION_FAILED,{originalError:t}))}}remove(e){try{return e instanceof We?(this.scene.remove(e.getThreeObject()),X.ok(void 0)):X.err(new ce("Object must be a ThreeObject3DAdapter",ue.INVALID_PARAMETER))}catch(t){return X.err(new ce("Failed to remove object from scene",ue.SCENE_OPERATION_FAILED,{originalError:t}))}}clear(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0])}traverse(e){this.scene.traverse(t=>{e(new We(t))})}get background(){return this.scene.background instanceof C.Color?new Zn(this.scene.background):this.scene.background instanceof C.Texture?new dn(this.scene.background):null}set background(e){e instanceof Zn?this.scene.background=e.getThreeColor():e instanceof dn?this.scene.background=e.getThreeTexture():this.scene.background=null}get fog(){return this.scene.fog?new Yi(this.scene.fog):null}set fog(e){e instanceof Yi?this.scene.fog=e.getThreeFog():this.scene.fog=null}get environment(){return this.scene.environment?new dn(this.scene.environment):null}set environment(e){e instanceof dn?this.scene.environment=e.getThreeTexture():this.scene.environment=null}getInternalRenderer(){return this.scene}getThreeScene(){return this.scene}}class Zn{constructor(e){this.color=e}get r(){return this.color.r}set r(e){this.color.r=e}get g(){return this.color.g}set g(e){this.color.g=e}get b(){return this.color.b}set b(e){this.color.b=e}setHex(e){this.color.setHex(e)}setRGB(e,t,r){this.color.setRGB(e,t,r)}getHex(){return this.color.getHex()}getThreeColor(){return this.color}}let dn=class{constructor(e){this.texture=e}get id(){return this.texture.uuid}get image(){return this.texture.image||null}get needsUpdate(){return this.texture.needsUpdate}set needsUpdate(e){this.texture.needsUpdate=e}dispose(){this.texture.dispose()}getThreeTexture(){return this.texture}};class Yi{constructor(e){this.fog=e}get color(){return new Zn(this.fog.color)}get near(){return this.fog.near||0}get far(){return this.fog.far||1e3}getThreeFog(){return this.fog}}class qn extends We{constructor(e){super(e),this.camera=e}get near(){return this.camera instanceof C.PerspectiveCamera||this.camera instanceof C.OrthographicCamera?this.camera.near:.1}set near(e){(this.camera instanceof C.PerspectiveCamera||this.camera instanceof C.OrthographicCamera)&&(this.camera.near=e)}get far(){return this.camera instanceof C.PerspectiveCamera||this.camera instanceof C.OrthographicCamera?this.camera.far:1e3}set far(e){(this.camera instanceof C.PerspectiveCamera||this.camera instanceof C.OrthographicCamera)&&(this.camera.far=e)}lookAt(e){e instanceof Nt?this.camera.lookAt(e.getThreeVector()):this.camera.lookAt(e.x,e.y,e.z)}updateProjectionMatrix(){(this.camera instanceof C.PerspectiveCamera||this.camera instanceof C.OrthographicCamera)&&this.camera.updateProjectionMatrix()}getWorldDirection(e){const t=new C.Vector3;this.camera.getWorldDirection(t),e.set(t.x,t.y,t.z)}getInternalRenderer(){return this.camera}getThreeCamera(){return this.camera}}class Kn extends qn{constructor(e){const t=e||new C.PerspectiveCamera;super(t),this.perspectiveCamera=t}get type(){return"perspective"}get fov(){return this.perspectiveCamera.fov}set fov(e){this.perspectiveCamera.fov=e}get aspect(){return this.perspectiveCamera.aspect}set aspect(e){this.perspectiveCamera.aspect=e}static create(e=75,t=1,r=.1,n=1e3){return new Kn(new C.PerspectiveCamera(e,t,r,n))}}class Ro{constructor(e){this.renderer=null,this._id=crypto.randomUUID(),this.canvas=e}get id(){return this._id}initialize(e){console.log("[ThreeRendererAdapter] initialize() called");try{if(this.renderer=new C.WebGLRenderer({canvas:this.canvas,antialias:e.antialias??!0,alpha:e.alpha??!1,premultipliedAlpha:e.premultipliedAlpha??!0,preserveDrawingBuffer:e.preserveDrawingBuffer??!1,powerPreference:e.powerPreference??"default"}),console.log("[ThreeRendererAdapter] WebGLRenderer created successfully"),e.shadowMap&&(this.renderer.shadowMap.enabled=e.shadowMap.enabled,this.renderer.shadowMap.autoUpdate=!0,e.shadowMap.type)){const t={basic:C.BasicShadowMap,pcf:C.PCFShadowMap,pcfsoft:C.PCFSoftShadowMap,vsm:C.VSMShadowMap};this.renderer.shadowMap.type=t[e.shadowMap.type]}if(e.toneMapping){const t={none:C.NoToneMapping,linear:C.LinearToneMapping,reinhard:C.ReinhardToneMapping,cineon:C.CineonToneMapping,aces:C.ACESFilmicToneMapping};this.renderer.toneMapping=t[e.toneMapping.type],this.renderer.toneMappingExposure=e.toneMapping.exposure}if(e.pixelRatio!==void 0?this.renderer.setPixelRatio(e.pixelRatio):this.renderer.setPixelRatio(window.devicePixelRatio),this.canvas){const{clientWidth:t,clientHeight:r}=this.canvas.parentElement||this.canvas;t&&r&&this.renderer.setSize(t,r)}return this.renderer.outputColorSpace=C.SRGBColorSpace,X.ok(void 0)}catch(t){return X.err(new ce("Failed to initialize renderer",ue.RENDERER_INIT_FAILED,{originalError:t,options:e}))}}render(e,t){if(!this.renderer)return X.err(new ce("Renderer not initialized",ue.RENDERER_NOT_INITIALIZED));try{if(!(e instanceof Wt))return X.err(new ce("Scene must be a ThreeSceneAdapter",ue.INVALID_PARAMETER));if(!(t instanceof qn))return X.err(new ce("Camera must be a ThreeCameraAdapter",ue.INVALID_PARAMETER));const r=e.getThreeScene(),n=t.getThreeCamera();return this.renderer.__pathTracingActive?(console.log("[ThreeRenderer] Skipping standard render - path tracing is active"),X.ok(void 0)):(this.renderer.render(r,n),X.ok(void 0))}catch(r){return X.err(new ce("Failed to render frame",ue.RENDER_FAILED,{originalError:r}))}}setSize(e,t){if(this.renderer){this.renderer.setSize(e,t,!1);const r=this.renderer.domElement;r.style.width="100%",r.style.height="100%"}}setPixelRatio(e){this.renderer&&this.renderer.setPixelRatio(e)}getDomElement(){if(!this.renderer)throw new Error("Renderer not initialized");return this.renderer.domElement}getContext(){if(!this.renderer)throw new Error("Renderer not initialized");return this.renderer.getContext()}get capabilities(){if(!this.renderer)return{maxTextureSize:0,maxCubemapSize:0,maxAttributes:0,maxVertexUniforms:0,maxFragmentUniforms:0,maxSamples:0,isWebGL2:!1};const e=this.renderer.capabilities;return{maxTextureSize:e.maxTextureSize,maxCubemapSize:e.maxCubemapSize,maxAttributes:e.maxAttributes,maxVertexUniforms:e.maxVertexUniforms,maxFragmentUniforms:e.maxFragmentUniforms,maxSamples:e.maxSamples||0,isWebGL2:e.isWebGL2}}dispose(){this.renderer&&(this.renderer.dispose(),this.renderer=null)}getInternalRenderer(){return console.log("[ThreeRendererAdapter] getInternalRenderer called, renderer exists:",!!this.renderer),this.renderer}getThreeRenderer(){return this.getInternalRenderer()}}function Zi(s,e){if(e===f.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===f.TriangleFanDrawMode||e===f.TriangleStripDrawMode){let t=s.getIndex();if(t===null){const i=[],a=s.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)i.push(c);s.setIndex(i),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const r=t.count-2,n=[];if(e===f.TriangleFanDrawMode)for(let i=1;i<=r;i++)n.push(t.getX(0)),n.push(t.getX(i)),n.push(t.getX(i+1));else for(let i=0;i<r;i++)i%2===0?(n.push(t.getX(i)),n.push(t.getX(i+1)),n.push(t.getX(i+2))):(n.push(t.getX(i+2)),n.push(t.getX(i+1)),n.push(t.getX(i)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=s.clone();return o.setIndex(n),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}class Fo extends f.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Bo(t)}),this.register(function(t){return new zo(t)}),this.register(function(t){return new qo(t)}),this.register(function(t){return new Ko(t)}),this.register(function(t){return new Xo(t)}),this.register(function(t){return new Uo(t)}),this.register(function(t){return new Vo(t)}),this.register(function(t){return new Go(t)}),this.register(function(t){return new jo(t)}),this.register(function(t){return new ko(t)}),this.register(function(t){return new Wo(t)}),this.register(function(t){return new Eo(t)}),this.register(function(t){return new Zo(t)}),this.register(function(t){return new Yo(t)}),this.register(function(t){return new Lo(t)}),this.register(function(t){return new $o(t)}),this.register(function(t){return new Qo(t)})}load(e,t,r,n){const o=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const u=f.LoaderUtils.extractUrlBase(e);i=f.LoaderUtils.resolveURL(u,this.path)}else i=f.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(u){n?n(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},c=new f.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(u){try{o.parse(u,i,function(d){t(d),o.manager.itemEnd(e)},a)}catch(d){a(d)}},r,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 this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,n){let o;const i={},a={},c=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===qi){try{i[fe.KHR_BINARY_GLTF]=new Jo(e)}catch(h){n&&n(h);return}o=JSON.parse(i[fe.KHR_BINARY_GLTF].content)}else o=JSON.parse(c.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new ha(o,{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 d=0;d<this.pluginCallbacks.length;d++){const h=this.pluginCallbacks[d](u);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,i[h.name]=!0}if(o.extensionsUsed)for(let d=0;d<o.extensionsUsed.length;++d){const h=o.extensionsUsed[d],l=o.extensionsRequired||[];switch(h){case fe.KHR_MATERIALS_UNLIT:i[h]=new No;break;case fe.KHR_DRACO_MESH_COMPRESSION:i[h]=new Ho(o,this.dracoLoader);break;case fe.KHR_TEXTURE_TRANSFORM:i[h]=new ea;break;case fe.KHR_MESH_QUANTIZATION:i[h]=new ta;break;default:l.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}u.setExtensions(i),u.setPlugins(a),u.parse(r,n)}parseAsync(e,t){const r=this;return new Promise(function(n,o){r.parse(e,t,n,o)})}}function Oo(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const fe={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 Lo{constructor(e){this.parser=e,this.name=fe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r<n;r++){const o=t[r];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let n=t.cache.get(r);if(n)return n;const o=t.json,c=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const d=new f.Color(16777215);c.color!==void 0&&d.setRGB(c.color[0],c.color[1],c.color[2],f.LinearSRGBColorSpace);const h=c.range!==void 0?c.range:0;switch(c.type){case"directional":u=new f.DirectionalLight(d),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new f.PointLight(d),u.distance=h;break;case"spot":u=new f.SpotLight(d),u.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,u.angle=c.spot.outerConeAngle,u.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return u.position.set(0,0,0),u.decay=2,Mt(u,c),c.intensity!==void 0&&(u.intensity=c.intensity),u.name=t.createUniqueName(c.name||"light_"+e),n=Promise.resolve(u),t.cache.add(r,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,o=r.json.nodes[e],a=(o.extensions&&o.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return r._getNodeRef(t.cache,a,c)})}}class No{constructor(){this.name=fe.KHR_MATERIALS_UNLIT}getMaterialType(){return f.MeshBasicMaterial}extendParams(e,t,r){const n=[];e.color=new f.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const i=o.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],f.LinearSRGBColorSpace),e.opacity=i[3]}o.baseColorTexture!==void 0&&n.push(r.assignTexture(e,"map",o.baseColorTexture,f.SRGBColorSpace))}return Promise.all(n)}}class ko{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class Bo{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],i=n.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&o.push(r.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&o.push(r.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(o.push(r.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f.Vector2(a,a)}return Promise.all(o)}}class zo{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_DISPERSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class Eo{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],i=n.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&o.push(r.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&o.push(r.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(o)}}class Uo{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_SHEEN}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new f.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=n.extensions[this.name];if(i.sheenColorFactor!==void 0){const a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&o.push(r.assignTexture(t,"sheenColorMap",i.sheenColorTexture,f.SRGBColorSpace)),i.sheenRoughnessTexture!==void 0&&o.push(r.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(o)}}class Vo{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],i=n.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&o.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(o)}}class Go{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],i=n.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&o.push(r.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),Promise.all(o)}}class jo{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=n.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class Wo{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],i=n.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&o.push(r.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=new f.Color().setRGB(a[0],a[1],a[2],f.LinearSRGBColorSpace),i.specularColorTexture!==void 0&&o.push(r.assignTexture(t,"specularColorMap",i.specularColorTexture,f.SRGBColorSpace)),Promise.all(o)}}class Yo{constructor(e){this.parser=e,this.name=fe.EXT_MATERIALS_BUMP}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],i=n.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&o.push(r.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(o)}}class Zo{constructor(e){this.parser=e,this.name=fe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:f.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const o=[],i=n.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&o.push(r.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(o)}}class qo{constructor(e){this.parser=e,this.name=fe.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const o=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,i)}}class Ko{constructor(e){this.parser=e,this.name=fe.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,n=r.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],a=n.images[i.source];let c=r.textureLoader;if(a.uri){const u=r.options.manager.getHandler(a.uri);u!==null&&(c=u)}return this.detectSupport().then(function(u){if(u)return r.loadTextureImage(e,i.source,c);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.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(t.height===1)}})),this.isSupported}}class Xo{constructor(e){this.parser=e,this.name=fe.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,n=r.json,o=n.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],a=n.images[i.source];let c=r.textureLoader;if(a.uri){const u=r.options.manager.getHandler(a.uri);u!==null&&(c=u)}return this.detectSupport().then(function(u){if(u)return r.loadTextureImage(e,i.source,c);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.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(t.height===1)}})),this.isSupported}}class $o{constructor(e){this.name=fe.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const n=r.extensions[this.name],o=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.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 o.then(function(a){const c=n.byteOffset||0,u=n.byteLength||0,d=n.count,h=n.byteStride,l=new Uint8Array(a,c,u);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(d,h,l,n.mode,n.filter).then(function(v){return v.buffer}):i.ready.then(function(){const v=new ArrayBuffer(d*h);return i.decodeGltfBuffer(new Uint8Array(v),d,h,l,n.mode,n.filter),v})})}else return null}}class Qo{constructor(e){this.name=fe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const n=t.meshes[r.mesh];for(const u of n.primitives)if(u.mode!==ot.TRIANGLES&&u.mode!==ot.TRIANGLE_STRIP&&u.mode!==ot.TRIANGLE_FAN&&u.mode!==void 0)return null;const i=r.extensions[this.name].attributes,a=[],c={};for(const u in i)a.push(this.parser.getDependency("accessor",i[u]).then(d=>(c[u]=d,c[u])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(u=>{const d=u.pop(),h=d.isGroup?d.children:[d],l=u[0].count,v=[];for(const b of h){const T=new f.Matrix4,g=new f.Vector3,x=new f.Quaternion,w=new f.Vector3(1,1,1),S=new f.InstancedMesh(b.geometry,b.material,l);for(let A=0;A<l;A++)c.TRANSLATION&&g.fromBufferAttribute(c.TRANSLATION,A),c.ROTATION&&x.fromBufferAttribute(c.ROTATION,A),c.SCALE&&w.fromBufferAttribute(c.SCALE,A),S.setMatrixAt(A,T.compose(g,x,w));for(const A in c)if(A==="_COLOR_0"){const P=c[A];S.instanceColor=new f.InstancedBufferAttribute(P.array,P.itemSize,P.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&b.geometry.setAttribute(A,c[A]);f.Object3D.prototype.copy.call(S,b),this.parser.assignFinalMaterial(S),v.push(S)}return d.isGroup?(d.clear(),d.add(...v),d):v[0]}))}}const qi="glTF",Br=12,Ki={JSON:1313821514,BIN:5130562};class Jo{constructor(e){this.name=fe.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Br),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==qi)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-Br,o=new DataView(e,Br);let i=0;for(;i<n;){const a=o.getUint32(i,!0);i+=4;const c=o.getUint32(i,!0);if(i+=4,c===Ki.JSON){const u=new Uint8Array(e,Br+i,a);this.content=r.decode(u)}else if(c===Ki.BIN){const u=Br+i;this.body=e.slice(u,u+a)}i+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ho{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=fe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,n=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},c={},u={};for(const d in i){const h=$n[d]||d.toLowerCase();a[h]=i[d]}for(const d in e.attributes){const h=$n[d]||d.toLowerCase();if(i[d]!==void 0){const l=r.accessors[e.attributes[d]],v=ur[l.componentType];u[h]=v.name,c[h]=l.normalized===!0}}return t.getDependency("bufferView",o).then(function(d){return new Promise(function(h,l){n.decodeDracoFile(d,function(v){for(const b in v.attributes){const T=v.attributes[b],g=c[b];g!==void 0&&(T.normalized=g)}h(v)},a,u,f.LinearSRGBColorSpace,l)})})}}class ea{constructor(){this.name=fe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class ta{constructor(){this.name=fe.KHR_MESH_QUANTIZATION}}class Xi extends f.Interpolant{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,o=e*n*3+n;for(let i=0;i!==n;i++)t[i]=r[o+i];return t}interpolate_(e,t,r,n){const o=this.resultBuffer,i=this.sampleValues,a=this.valueSize,c=a*2,u=a*3,d=n-t,h=(r-t)/d,l=h*h,v=l*h,b=e*u,T=b-u,g=-2*v+3*l,x=v-l,w=1-g,S=x-l+h;for(let A=0;A!==a;A++){const P=i[T+A+a],D=i[T+A+c]*d,F=i[b+A+a],O=i[b+A]*d;o[A]=w*P+S*D+g*F+x*O}return o}}const ra=new f.Quaternion;class na extends Xi{interpolate_(e,t,r,n){const o=super.interpolate_(e,t,r,n);return ra.fromArray(o).normalize().toArray(o),o}}const ot={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ur={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},$i={9728:f.NearestFilter,9729:f.LinearFilter,9984:f.NearestMipmapNearestFilter,9985:f.LinearMipmapNearestFilter,9986:f.NearestMipmapLinearFilter,9987:f.LinearMipmapLinearFilter},Qi={33071:f.ClampToEdgeWrapping,33648:f.MirroredRepeatWrapping,10497:f.RepeatWrapping},Xn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$n={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"},kt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ia={CUBICSPLINE:void 0,LINEAR:f.InterpolateLinear,STEP:f.InterpolateDiscrete},Qn={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function sa(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new f.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:f.FrontSide})),s.DefaultMaterial}function Yt(s,e,t){for(const r in t.extensions)s[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function Mt(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function oa(s,e,t){let r=!1,n=!1,o=!1;for(let u=0,d=e.length;u<d;u++){const h=e[u];if(h.POSITION!==void 0&&(r=!0),h.NORMAL!==void 0&&(n=!0),h.COLOR_0!==void 0&&(o=!0),r&&n&&o)break}if(!r&&!n&&!o)return Promise.resolve(s);const i=[],a=[],c=[];for(let u=0,d=e.length;u<d;u++){const h=e[u];if(r){const l=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):s.attributes.position;i.push(l)}if(n){const l=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):s.attributes.normal;a.push(l)}if(o){const l=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):s.attributes.color;c.push(l)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c)]).then(function(u){const d=u[0],h=u[1],l=u[2];return r&&(s.morphAttributes.position=d),n&&(s.morphAttributes.normal=h),o&&(s.morphAttributes.color=l),s.morphTargetsRelative=!0,s})}function aa(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let r=0,n=t.length;r<n;r++)s.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ca(s){let e;const t=s.extensions&&s.extensions[fe.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Jn(t.attributes):e=s.indices+":"+Jn(s.attributes)+":"+s.mode,s.targets!==void 0)for(let r=0,n=s.targets.length;r<n;r++)e+=":"+Jn(s.targets[r]);return e}function Jn(s){let e="";const t=Object.keys(s).sort();for(let r=0,n=t.length;r<n;r++)e+=t[r]+":"+s[t[r]]+";";return e}function Hn(s){switch(s){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.")}}function la(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const ua=new f.Matrix4;class ha{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Oo,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 r=!1,n=-1,o=!1,i=-1;if(typeof navigator<"u"){const a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);n=r&&c?parseInt(c[1],10):-1,o=a.indexOf("Firefox")>-1,i=o?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||o&&i<98?this.textureLoader=new f.TextureLoader(this.options.manager):this.textureLoader=new f.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new f.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,n=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(i){const a={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:r,userData:{}};return Yt(o,a,n),Mt(a,n),Promise.all(r._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let n=0,o=t.length;n<o;n++){const i=t[n].joints;for(let a=0,c=i.length;a<c;a++)e[i[a]].isBone=!0}for(let n=0,o=e.length;n<o;n++){const i=e[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(r[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const n=r.clone(),o=(i,a)=>{const c=this.associations.get(i);c!=null&&this.associations.set(a,c);for(const[u,d]of i.children.entries())o(d,a.children[u])};return o(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const n=e(t[r]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let n=0;n<t.length;n++){const o=e(t[n]);o&&r.push(o)}return r}getDependency(e,t){const r=e+":"+t;let n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":n=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(o,i){return r.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[fe.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(o,i){r.load(f.LoaderUtils.resolveURL(t.uri,n.path),o,void 0,function(){i(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(r){const n=t.byteLength||0,o=t.byteOffset||0;return r.slice(o,o+n)})}loadAccessor(e){const t=this,r=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const i=Xn[n.type],a=ur[n.componentType],c=n.normalized===!0,u=new a(n.count*i);return Promise.resolve(new f.BufferAttribute(u,i,c))}const o=[];return n.bufferView!==void 0?o.push(this.getDependency("bufferView",n.bufferView)):o.push(null),n.sparse!==void 0&&(o.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(o).then(function(i){const a=i[0],c=Xn[n.type],u=ur[n.componentType],d=u.BYTES_PER_ELEMENT,h=d*c,l=n.byteOffset||0,v=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,b=n.normalized===!0;let T,g;if(v&&v!==h){const x=Math.floor(l/v),w="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+x+":"+n.count;let S=t.cache.get(w);S||(T=new u(a,x*v,n.count*v/d),S=new f.InterleavedBuffer(T,v/d),t.cache.add(w,S)),g=new f.InterleavedBufferAttribute(S,c,l%v/d,b)}else a===null?T=new u(n.count*c):T=new u(a,l,n.count*c),g=new f.BufferAttribute(T,c,b);if(n.sparse!==void 0){const x=Xn.SCALAR,w=ur[n.sparse.indices.componentType],S=n.sparse.indices.byteOffset||0,A=n.sparse.values.byteOffset||0,P=new w(i[1],S,n.sparse.count*x),D=new u(i[2],A,n.sparse.count*c);a!==null&&(g=new f.BufferAttribute(g.array.slice(),g.itemSize,g.normalized));for(let F=0,O=P.length;F<O;F++){const L=P[F];if(g.setX(L,D[F*c]),c>=2&&g.setY(L,D[F*c+1]),c>=3&&g.setZ(L,D[F*c+2]),c>=4&&g.setW(L,D[F*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){const t=this.json,r=this.options,o=t.textures[e].source,i=t.images[o];let a=this.textureLoader;if(i.uri){const c=r.manager.getHandler(i.uri);c!==null&&(a=c)}return this.loadTextureImage(e,o,a)}loadTextureImage(e,t,r){const n=this,o=this.json,i=o.textures[e],a=o.images[t],c=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[c])return this.textureCache[c];const u=this.loadImageSource(t,r).then(function(d){d.flipY=!1,d.name=i.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const l=(o.samplers||{})[i.sampler]||{};return d.magFilter=$i[l.magFilter]||f.LinearFilter,d.minFilter=$i[l.minFilter]||f.LinearMipmapLinearFilter,d.wrapS=Qi[l.wrapS]||f.RepeatWrapping,d.wrapT=Qi[l.wrapT]||f.RepeatWrapping,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[c]=u,u}loadImageSource(e,t){const r=this,n=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const i=n.images[e],a=self.URL||self.webkitURL;let c=i.uri||"",u=!1;if(i.bufferView!==void 0)c=r.getDependency("bufferView",i.bufferView).then(function(h){u=!0;const l=new Blob([h],{type:i.mimeType});return c=a.createObjectURL(l),c});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(c).then(function(h){return new Promise(function(l,v){let b=l;t.isImageBitmapLoader===!0&&(b=function(T){const g=new f.Texture(T);g.needsUpdate=!0,l(g)}),t.load(f.LoaderUtils.resolveURL(h,o.path),b,void 0,v)})}).then(function(h){return u===!0&&a.revokeObjectURL(c),Mt(h,i),h.userData.mimeType=i.mimeType||la(i.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=d,d}assignTexture(e,t,r,n){const o=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(i=i.clone(),i.channel=r.texCoord),o.extensions[fe.KHR_TEXTURE_TRANSFORM]){const a=r.extensions!==void 0?r.extensions[fe.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=o.associations.get(i);i=o.extensions[fe.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),o.associations.set(i,c)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const n=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+r.uuid;let c=this.cache.get(a);c||(c=new f.PointsMaterial,f.Material.prototype.copy.call(c,r),c.color.copy(r.color),c.map=r.map,c.sizeAttenuation=!1,this.cache.add(a,c)),r=c}else if(e.isLine){const a="LineBasicMaterial:"+r.uuid;let c=this.cache.get(a);c||(c=new f.LineBasicMaterial,f.Material.prototype.copy.call(c,r),c.color.copy(r.color),c.map=r.map,this.cache.add(a,c)),r=c}if(n||o||i){let a="ClonedMaterial:"+r.uuid+":";n&&(a+="derivative-tangents:"),o&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=r.clone(),o&&(c.vertexColors=!0),i&&(c.flatShading=!0),n&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(r))),r=c}e.material=r}getMaterialType(){return f.MeshStandardMaterial}loadMaterial(e){const t=this,r=this.json,n=this.extensions,o=r.materials[e];let i;const a={},c=o.extensions||{},u=[];if(c[fe.KHR_MATERIALS_UNLIT]){const h=n[fe.KHR_MATERIALS_UNLIT];i=h.getMaterialType(),u.push(h.extendParams(a,o,t))}else{const h=o.pbrMetallicRoughness||{};if(a.color=new f.Color(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){const l=h.baseColorFactor;a.color.setRGB(l[0],l[1],l[2],f.LinearSRGBColorSpace),a.opacity=l[3]}h.baseColorTexture!==void 0&&u.push(t.assignTexture(a,"map",h.baseColorTexture,f.SRGBColorSpace)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),u.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),i=this._invokeOne(function(l){return l.getMaterialType&&l.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(l){return l.extendMaterialParams&&l.extendMaterialParams(e,a)})))}o.doubleSided===!0&&(a.side=f.DoubleSide);const d=o.alphaMode||Qn.OPAQUE;if(d===Qn.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===Qn.MASK&&(a.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&i!==f.MeshBasicMaterial&&(u.push(t.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new f.Vector2(1,1),o.normalTexture.scale!==void 0)){const h=o.normalTexture.scale;a.normalScale.set(h,h)}if(o.occlusionTexture!==void 0&&i!==f.MeshBasicMaterial&&(u.push(t.assignTexture(a,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&i!==f.MeshBasicMaterial){const h=o.emissiveFactor;a.emissive=new f.Color().setRGB(h[0],h[1],h[2],f.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&i!==f.MeshBasicMaterial&&u.push(t.assignTexture(a,"emissiveMap",o.emissiveTexture,f.SRGBColorSpace)),Promise.all(u).then(function(){const h=new i(a);return o.name&&(h.name=o.name),Mt(h,o),t.associations.set(h,{materials:e}),o.extensions&&Yt(n,h,o),h})}createUniqueName(e){const t=f.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,r=this.extensions,n=this.primitiveCache;function o(a){return r[fe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Ji(c,a,t)})}const i=[];for(let a=0,c=e.length;a<c;a++){const u=e[a],d=ca(u),h=n[d];if(h)i.push(h.promise);else{let l;u.extensions&&u.extensions[fe.KHR_DRACO_MESH_COMPRESSION]?l=o(u):l=Ji(new f.BufferGeometry,u,t),n[d]={primitive:u,promise:l},i.push(l)}}return Promise.all(i)}loadMesh(e){const t=this,r=this.json,n=this.extensions,o=r.meshes[e],i=o.primitives,a=[];for(let c=0,u=i.length;c<u;c++){const d=i[c].material===void 0?sa(this.cache):this.getDependency("material",i[c].material);a.push(d)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(c){const u=c.slice(0,c.length-1),d=c[c.length-1],h=[];for(let v=0,b=d.length;v<b;v++){const T=d[v],g=i[v];let x;const w=u[v];if(g.mode===ot.TRIANGLES||g.mode===ot.TRIANGLE_STRIP||g.mode===ot.TRIANGLE_FAN||g.mode===void 0)x=o.isSkinnedMesh===!0?new f.SkinnedMesh(T,w):new f.Mesh(T,w),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),g.mode===ot.TRIANGLE_STRIP?x.geometry=Zi(x.geometry,f.TriangleStripDrawMode):g.mode===ot.TRIANGLE_FAN&&(x.geometry=Zi(x.geometry,f.TriangleFanDrawMode));else if(g.mode===ot.LINES)x=new f.LineSegments(T,w);else if(g.mode===ot.LINE_STRIP)x=new f.Line(T,w);else if(g.mode===ot.LINE_LOOP)x=new f.LineLoop(T,w);else if(g.mode===ot.POINTS)x=new f.Points(T,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(x.geometry.morphAttributes).length>0&&aa(x,o),x.name=t.createUniqueName(o.name||"mesh_"+e),Mt(x,o),g.extensions&&Yt(n,x,g),t.assignFinalMaterial(x),h.push(x)}for(let v=0,b=h.length;v<b;v++)t.associations.set(h[v],{meshes:e,primitives:v});if(h.length===1)return o.extensions&&Yt(n,h[0],o),h[0];const l=new f.Group;o.extensions&&Yt(n,l,o),t.associations.set(l,{meshes:e});for(let v=0,b=h.length;v<b;v++)l.add(h[v]);return l})}loadCamera(e){let t;const r=this.json.cameras[e],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new f.PerspectiveCamera(f.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(t=new f.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),Mt(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let n=0,o=t.joints.length;n<o;n++)r.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){const o=n.pop(),i=n,a=[],c=[];for(let u=0,d=i.length;u<d;u++){const h=i[u];if(h){a.push(h);const l=new f.Matrix4;o!==null&&l.fromArray(o.array,u*16),c.push(l)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new f.Skeleton(a,c)})}loadAnimation(e){const t=this.json,r=this,n=t.animations[e],o=n.name?n.name:"animation_"+e,i=[],a=[],c=[],u=[],d=[];for(let h=0,l=n.channels.length;h<l;h++){const v=n.channels[h],b=n.samplers[v.sampler],T=v.target,g=T.node,x=n.parameters!==void 0?n.parameters[b.input]:b.input,w=n.parameters!==void 0?n.parameters[b.output]:b.output;T.node!==void 0&&(i.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",x)),c.push(this.getDependency("accessor",w)),u.push(b),d.push(T))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c),Promise.all(u),Promise.all(d)]).then(function(h){const l=h[0],v=h[1],b=h[2],T=h[3],g=h[4],x=[];for(let w=0,S=l.length;w<S;w++){const A=l[w],P=v[w],D=b[w],F=T[w],O=g[w];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();const L=r._createAnimationTracks(A,P,D,F,O);if(L)for(let E=0;E<L.length;E++)x.push(L[E])}return new f.AnimationClip(o,void 0,x)})}createNodeMesh(e){const t=this.json,r=this,n=t.nodes[e];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(o){const i=r._getNodeRef(r.meshCache,n.mesh,o);return n.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let c=0,u=n.weights.length;c<u;c++)a.morphTargetInfluences[c]=n.weights[c]}),i})}loadNode(e){const t=this.json,r=this,n=t.nodes[e],o=r._loadNodeShallow(e),i=[],a=n.children||[];for(let u=0,d=a.length;u<d;u++)i.push(r.getDependency("node",a[u]));const c=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([o,Promise.all(i),c]).then(function(u){const d=u[0],h=u[1],l=u[2];l!==null&&d.traverse(function(v){v.isSkinnedMesh&&v.bind(l,ua)});for(let v=0,b=h.length;v<b;v++)d.add(h[v]);return d})}_loadNodeShallow(e){const t=this.json,r=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],i=o.name?n.createUniqueName(o.name):"",a=[],c=n._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return c&&a.push(c),o.camera!==void 0&&a.push(n.getDependency("camera",o.camera).then(function(u){return n._getNodeRef(n.cameraCache,o.camera,u)})),n._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){a.push(u)}),this.nodeCache[e]=Promise.all(a).then(function(u){let d;if(o.isBone===!0?d=new f.Bone:u.length>1?d=new f.Group:u.length===1?d=u[0]:d=new f.Object3D,d!==u[0])for(let h=0,l=u.length;h<l;h++)d.add(u[h]);if(o.name&&(d.userData.name=o.name,d.name=i),Mt(d,o),o.extensions&&Yt(r,d,o),o.matrix!==void 0){const h=new f.Matrix4;h.fromArray(o.matrix),d.applyMatrix4(h)}else o.translation!==void 0&&d.position.fromArray(o.translation),o.rotation!==void 0&&d.quaternion.fromArray(o.rotation),o.scale!==void 0&&d.scale.fromArray(o.scale);return n.associations.has(d)||n.associations.set(d,{}),n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],n=this,o=new f.Group;r.name&&(o.name=n.createUniqueName(r.name)),Mt(o,r),r.extensions&&Yt(t,o,r);const i=r.nodes||[],a=[];for(let c=0,u=i.length;c<u;c++)a.push(n.getDependency("node",i[c]));return Promise.all(a).then(function(c){for(let d=0,h=c.length;d<h;d++)o.add(c[d]);const u=d=>{const h=new Map;for(const[l,v]of n.associations)(l instanceof f.Material||l instanceof f.Texture)&&h.set(l,v);return d.traverse(l=>{const v=n.associations.get(l);v!=null&&h.set(l,v)}),h};return n.associations=u(o),o})}_createAnimationTracks(e,t,r,n,o){const i=[],a=e.name?e.name:e.uuid,c=[];kt[o.path]===kt.weights?e.traverse(function(l){l.morphTargetInfluences&&c.push(l.name?l.name:l.uuid)}):c.push(a);let u;switch(kt[o.path]){case kt.weights:u=f.NumberKeyframeTrack;break;case kt.rotation:u=f.QuaternionKeyframeTrack;break;case kt.position:case kt.scale:u=f.VectorKeyframeTrack;break;default:switch(r.itemSize){case 1:u=f.NumberKeyframeTrack;break;case 2:case 3:default:u=f.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?ia[n.interpolation]:f.InterpolateLinear,h=this._getArrayFromAccessor(r);for(let l=0,v=c.length;l<v;l++){const b=new u(c[l]+"."+kt[o.path],t.array,h,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(b),i.push(b)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const r=Hn(t.constructor),n=new Float32Array(t.length);for(let o=0,i=t.length;o<i;o++)n[o]=t[o]*r;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){const n=this instanceof f.QuaternionKeyframeTrack?na:Xi;return new n(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function fa(s,e,t){const r=e.attributes,n=new f.Box3;if(r.POSITION!==void 0){const a=t.json.accessors[r.POSITION],c=a.min,u=a.max;if(c!==void 0&&u!==void 0){if(n.set(new f.Vector3(c[0],c[1],c[2]),new f.Vector3(u[0],u[1],u[2])),a.normalized){const d=Hn(ur[a.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const a=new f.Vector3,c=new f.Vector3;for(let u=0,d=o.length;u<d;u++){const h=o[u];if(h.POSITION!==void 0){const l=t.json.accessors[h.POSITION],v=l.min,b=l.max;if(v!==void 0&&b!==void 0){if(c.setX(Math.max(Math.abs(v[0]),Math.abs(b[0]))),c.setY(Math.max(Math.abs(v[1]),Math.abs(b[1]))),c.setZ(Math.max(Math.abs(v[2]),Math.abs(b[2]))),l.normalized){const T=Hn(ur[l.componentType]);c.multiplyScalar(T)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}s.boundingBox=n;const i=new f.Sphere;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,s.boundingSphere=i}function Ji(s,e,t){const r=e.attributes,n=[];function o(i,a){return t.getDependency("accessor",i).then(function(c){s.setAttribute(a,c)})}for(const i in r){const a=$n[i]||i.toLowerCase();a in s.attributes||n.push(o(r[i],a))}if(e.indices!==void 0&&!s.index){const i=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});n.push(i)}return f.ColorManagement.workingColorSpace!==f.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${f.ColorManagement.workingColorSpace}" not supported.`),Mt(s,e),fa(s,e,t),Promise.all(n).then(function(){return e.targets!==void 0?oa(s,e.targets,t):s})}class da{constructor(){this.loadingManager=new C.LoadingManager,this.loader=new Fo(this.loadingManager)}async load(e){try{return new Promise(t=>{this.loader.load(e,r=>{var o;const n={scene:new We(r.scene),animations:this.convertAnimations(r.animations),cameras:(o=r.cameras)==null?void 0:o.map(i=>{const a=i instanceof C.PerspectiveCamera,c=i instanceof C.OrthographicCamera;return{name:i.name,type:i.type,fov:a?i.fov:void 0,aspect:a?i.aspect:void 0,near:a||c?i.near:.1,far:a||c?i.far:1e3}}),userData:r.userData};t(X.ok(n))},r=>{if(r.total>0){const n=r.loaded/r.total*100;console.log(`Loading: ${n.toFixed(0)}%`)}},r=>{t(X.err(new ce("Failed to load GLTF model",ue.MODEL_LOAD_FAILED,{url:e,originalError:r})))})})}catch(t){return X.err(new ce("Failed to initiate model loading",ue.MODEL_LOAD_FAILED,{url:e,originalError:t}))}}supports(e){var r;const t=(r=e.split(".").pop())==null?void 0:r.toLowerCase();return t==="gltf"||t==="glb"}convertAnimations(e){return e.map(t=>({name:t.name,duration:t.duration,tracks:t.tracks.map(r=>({name:r.name,type:this.getTrackType(r),times:r.times,values:r.values}))}))}getTrackType(e){return e instanceof C.VectorKeyframeTrack?"vector":e instanceof C.QuaternionKeyframeTrack?"quaternion":e instanceof C.NumberKeyframeTrack?"number":e instanceof C.BooleanKeyframeTrack?"boolean":"number"}}class Hi{static createLoader(e){var r;const t=(r=e.split(".").pop())==null?void 0:r.toLowerCase();switch(t){case"gltf":case"glb":return new da;default:throw new ce(`Unsupported file format: ${t}`,ue.UNSUPPORTED_FORMAT,{url:e,extension:t})}}}const es={type:"change"},ei={type:"start"},ts={type:"end"},pn=new f.Ray,rs=new f.Plane,pa=Math.cos(70*f.MathUtils.DEG2RAD),Le=new f.Vector3,Ke=2*Math.PI,xe={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ti=1e-6;class ns extends f.Controls{constructor(e,t=null){super(e,t),this.state=xe.NONE,this.enabled=!0,this.target=new f.Vector3,this.cursor=new f.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:f.MOUSE.ROTATE,MIDDLE:f.MOUSE.DOLLY,RIGHT:f.MOUSE.PAN},this.touches={ONE:f.TOUCH.ROTATE,TWO:f.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new f.Vector3,this._lastQuaternion=new f.Quaternion,this._lastTargetPosition=new f.Vector3,this._quat=new f.Quaternion().setFromUnitVectors(e.up,new f.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new f.Spherical,this._sphericalDelta=new f.Spherical,this._scale=1,this._panOffset=new f.Vector3,this._rotateStart=new f.Vector2,this._rotateEnd=new f.Vector2,this._rotateDelta=new f.Vector2,this._panStart=new f.Vector2,this._panEnd=new f.Vector2,this._panDelta=new f.Vector2,this._dollyStart=new f.Vector2,this._dollyEnd=new f.Vector2,this._dollyDelta=new f.Vector2,this._dollyDirection=new f.Vector3,this._mouse=new f.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ga.bind(this),this._onPointerDown=ma.bind(this),this._onPointerUp=va.bind(this),this._onContextMenu=Sa.bind(this),this._onMouseWheel=xa.bind(this),this._onKeyDown=wa.bind(this),this._onTouchStart=_a.bind(this),this._onTouchMove=Ta.bind(this),this._onMouseDown=ya.bind(this),this._onMouseMove=ba.bind(this),this._interceptControlDown=Aa.bind(this),this._interceptControlUp=Ma.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(es),this.update(),this.state=xe.NONE}update(e=null){const t=this.object.position;Le.copy(t).sub(this.target),Le.applyQuaternion(this._quat),this._spherical.setFromVector3(Le),this.autoRotate&&this.state===xe.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(r)&&isFinite(n)&&(r<-Math.PI?r+=Ke:r>Math.PI&&(r-=Ke),n<-Math.PI?n+=Ke:n>Math.PI&&(n-=Ke),r<=n?this._spherical.theta=Math.max(r,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+n)/2?Math.max(r,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const i=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=i!=this._spherical.radius}if(Le.setFromSpherical(this._spherical),Le.applyQuaternion(this._quatInverse),t.copy(this.target).add(Le),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let i=null;if(this.object.isPerspectiveCamera){const a=Le.length();i=this._clampDistance(a*this._scale);const c=a-i;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),o=!!c}else if(this.object.isOrthographicCamera){const a=new f.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=c!==this.object.zoom;const u=new f.Vector3(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(a),this.object.updateMatrixWorld(),i=Le.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;i!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(i).add(this.object.position):(pn.origin.copy(this.object.position),pn.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(pn.direction))<pa?this.object.lookAt(this.target):(rs.setFromNormalAndCoplanarPoint(this.object.up,this.target),pn.intersectPlane(rs,this.target))))}else if(this.object.isOrthographicCamera){const i=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),i!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>ti||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ti||this._lastTargetPosition.distanceToSquared(this.target)>ti?(this.dispatchEvent(es),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ke/60*this.autoRotateSpeed*e:Ke/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Le.setFromMatrixColumn(t,0),Le.multiplyScalar(-e),this._panOffset.add(Le)}_panUp(e,t){this.screenSpacePanning===!0?Le.setFromMatrixColumn(t,1):(Le.setFromMatrixColumn(t,0),Le.crossVectors(this.object.up,Le)),Le.multiplyScalar(e),this._panOffset.add(Le)}_pan(e,t){const r=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;Le.copy(n).sub(this.target);let o=Le.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/r.clientHeight,this.object.matrix),this._panUp(2*t*o/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),n=e-r.left,o=t-r.top,i=r.width,a=r.height;this._mouse.x=n/i*2-1,this._mouse.y=-(o/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ke*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ke*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(Ke*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-Ke*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(Ke*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-Ke*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(r,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(r,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,n=e.pageY-t.y,o=Math.sqrt(r*r+n*n);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),n=.5*(e.pageX+r.x),o=.5*(e.pageY+r.y);this._rotateEnd.set(n,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ke*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ke*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(r,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,n=e.pageY-t.y,o=Math.sqrt(r*r+n*n);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const i=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(i,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new f.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function ma(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s)))}function ga(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function va(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ts),this.state=xe.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function ya(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case f.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=xe.DOLLY;break;case f.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=xe.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=xe.ROTATE}break;case f.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=xe.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=xe.PAN}break;default:this.state=xe.NONE}this.state!==xe.NONE&&this.dispatchEvent(ei)}function ba(s){switch(this.state){case xe.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case xe.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case xe.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function xa(s){this.enabled===!1||this.enableZoom===!1||this.state!==xe.NONE||(s.preventDefault(),this.dispatchEvent(ei),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(ts))}function wa(s){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(s)}function _a(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case f.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=xe.TOUCH_ROTATE;break;case f.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=xe.TOUCH_PAN;break;default:this.state=xe.NONE}break;case 2:switch(this.touches.TWO){case f.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=xe.TOUCH_DOLLY_PAN;break;case f.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=xe.TOUCH_DOLLY_ROTATE;break;default:this.state=xe.NONE}break;default:this.state=xe.NONE}this.state!==xe.NONE&&this.dispatchEvent(ei)}function Ta(s){switch(this._trackPointer(s),this.state){case xe.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case xe.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case xe.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case xe.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=xe.NONE}}function Sa(s){this.enabled!==!1&&s.preventDefault()}function Aa(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Ma(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Ia extends ns{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons={LEFT:f.MOUSE.PAN,MIDDLE:f.MOUSE.DOLLY,RIGHT:f.MOUSE.ROTATE},this.touches={ONE:f.TOUCH.PAN,TWO:f.TOUCH.DOLLY_ROTATE}}}class is{constructor(e){this.controls=e,this.targetAdapter=Nt.fromThreeVector(e.target)}get enabled(){return this.controls.enabled}set enabled(e){this.controls.enabled=e}get enableDamping(){return this.controls.enableDamping}set enableDamping(e){this.controls.enableDamping=e}get dampingFactor(){return this.controls.dampingFactor}set dampingFactor(e){this.controls.dampingFactor=e}get enableZoom(){return this.controls.enableZoom}set enableZoom(e){this.controls.enableZoom=e}get enableRotate(){return this.controls.enableRotate}set enableRotate(e){this.controls.enableRotate=e}get enablePan(){return this.controls.enablePan}set enablePan(e){this.controls.enablePan=e}get zoomSpeed(){return this.controls.zoomSpeed}set zoomSpeed(e){this.controls.zoomSpeed=e}get minDistance(){return this.controls.minDistance}set minDistance(e){this.controls.minDistance=e}get maxDistance(){return this.controls.maxDistance}set maxDistance(e){this.controls.maxDistance=e}get rotateSpeed(){return this.controls.rotateSpeed}set rotateSpeed(e){this.controls.rotateSpeed=e}get minPolarAngle(){return this.controls.minPolarAngle}set minPolarAngle(e){this.controls.minPolarAngle=e}get maxPolarAngle(){return this.controls.maxPolarAngle}set maxPolarAngle(e){this.controls.maxPolarAngle=e}get minAzimuthAngle(){return this.controls.minAzimuthAngle}set minAzimuthAngle(e){this.controls.minAzimuthAngle=e}get maxAzimuthAngle(){return this.controls.maxAzimuthAngle}set maxAzimuthAngle(e){this.controls.maxAzimuthAngle=e}get panSpeed(){return this.controls.panSpeed}set panSpeed(e){this.controls.panSpeed=e}get screenSpacePanning(){return this.controls.screenSpacePanning}set screenSpacePanning(e){this.controls.screenSpacePanning=e}get target(){return this.targetAdapter}update(){return this.controls.update()}reset(){this.controls.reset()}dispose(){this.controls.dispose()}connect(e){}disconnect(){this.controls.dispose()}getThreeControls(){return this.controls}}class ss extends is{constructor(e,t){const r=new ns(e,t);super(r),this.orbitControls=r}get type(){return"orbit"}get autoRotate(){return this.orbitControls.autoRotate}set autoRotate(e){this.orbitControls.autoRotate=e}get autoRotateSpeed(){return this.orbitControls.autoRotateSpeed}set autoRotateSpeed(e){this.orbitControls.autoRotateSpeed=e}}class os extends is{constructor(e,t){const r=new Ia(e,t);super(r),r.screenSpacePanning=!0}get type(){return"map"}get screenSpacePanning(){return!0}set screenSpacePanning(e){}}const $r=class $r{static getHeight(e){return e*this.HEIGHT_RATIO}static getBevelSize(e){return e*this.BEVEL_RATIO}static getBevelThickness(e){return this.getBevelSize(e)}static getBaseSize(e){return e+this.getBevelSize(e)+this.getBevelThickness(e)}static getGapFactor(){return this.GAP_FACTOR}static getGridSpacing(e){const t=this.getBaseSize(e),r=this.getGapFactor();return{width:Math.sqrt(3)*t*r,height:2*t*r}}static getYPosition(e){return-(this.getHeight(e)+this.getBevelSize(e))}};$r.HEIGHT_RATIO=.075,$r.BEVEL_RATIO=.25,$r.GAP_FACTOR=1.05;let Zt=$r;class Ca{constructor(e,t,r){this.position=e,this.size=t,this.color=r,this.height=Zt.getHeight(this.size),this.bevel=Zt.getBevelSize(this.size)}createMesh(){const e=new C.Shape,t=this.size+this.bevel,r=Math.PI*2/6;for(let u=0;u<6;u++){const d=t*Math.cos(u*r),h=t*Math.sin(u*r);u===0?e.moveTo(d,h):e.lineTo(d,h)}e.closePath();const n={depth:this.height,bevelEnabled:!0,bevelSize:this.bevel,bevelThickness:this.bevel,bevelSegments:128},o=new C.ExtrudeGeometry(e,n),i=new C.MeshPhysicalMaterial({color:new C.Color(16777215),metalness:0,roughness:.15,transparent:!0,transmission:1,thickness:.4,ior:1.5,opacity:1,clearcoat:1,clearcoatRoughness:.05,sheen:1,sheenColor:new C.Color(16777215),envMapIntensity:1}),a=new C.Mesh(o,i);a.receiveShadow=!0;const c=new C.Group;return c.add(a),c.position.set(this.position.x,this.position.y,this.position.z),c.rotation.x=Math.PI/2,c.rotation.z=Math.PI/6,c}}class Pa{constructor(e,t,r){this.radius=e,this.tileSize=t,this.color=r}generateGrid(){const e=[],t=Zt.getGridSpacing(this.tileSize),r=t.width,n=t.height;for(let o=-this.radius;o<=this.radius;o++){const i=Math.max(-this.radius,-o-this.radius),a=Math.min(this.radius,-o+this.radius);for(let c=i;c<=a;c++){const u=r*(o+c/2),d=n*.75*c,h=Zt.getYPosition(this.tileSize),l=new Ca(new C.Vector3(u,h,d),this.tileSize,this.color);e.push(l)}}return e}addToScene(e){this.generateGrid().forEach(r=>{const n=r.createMesh();e.add(n)})}}class Da{addHelpers(e,t){try{if(!(e instanceof Wt))return X.err(new ce("Scene must be ThreeSceneAdapter",ue.INVALID_PARAMETER));const r=e.getThreeScene();if(t.grid){const n=r.userData;r.userData={...n,gridOptions:{enabled:!0,color:t.gridColor||"#AAAAAA"}}}if(t.axes){const n=t.axesSize||5,o=new C.AxesHelper(n);r.add(o)}return X.ok(void 0)}catch(r){return X.err(new ce("Failed to add helpers to scene",ue.SCENE_OPERATION_FAILED,{originalError:r,options:t}))}}addDynamicGrid(e,t,r=1.2){try{if(!(e instanceof Wt))return X.err(new ce("Scene must be ThreeSceneAdapter",ue.INVALID_PARAMETER));const n=e.getThreeScene(),o=n.userData,i=o==null?void 0:o.gridOptions;if(!(i!=null&&i.enabled))return X.ok(void 0);const a=[];n.traverse(A=>{var P;(P=A.userData)!=null&&P.isHexGrid&&a.push(A)}),a.forEach(A=>n.remove(A));let c;t instanceof We||"getThreeObject"in t&&typeof t.getThreeObject=="function"?c=t.getThreeObject():c=t;const d=new C.Box3().setFromObject(c).getSize(new C.Vector3);console.log("Object size:",d);const l=1,b=Zt.getGridSpacing(l).width,T=Math.max(d.x,d.z)*r;let g=0,x=b;for(;x<T&&g<20;)g++,x+=2*b;T<b*.8?g=0:g<3&&T>b*2&&(g=3),console.log("Grid parameters:",{tileSize:l,gridRadius:g,requiredWidth:T,hexWidth:b,actualCoverage:(2*g+1)*b});const w=new Pa(g,l,i.color),S=new C.Group;return S.userData.isHexGrid=!0,w.generateGrid().forEach(A=>{const P=A.createMesh();S.add(P)}),n.add(S),X.ok(void 0)}catch(n){return X.err(new ce("Failed to add dynamic grid",ue.SCENE_OPERATION_FAILED,{originalError:n}))}}addLighting(e,t){try{if(!(e instanceof Wt))return X.err(new ce("Scene must be ThreeSceneAdapter",ue.INVALID_PARAMETER));const r=e.getThreeScene();if(t.ambient){const n=new C.Color(t.ambient.color||"#404040"),o=t.ambient.intensity??Math.PI,i=new C.AmbientLight(n,o);r.add(i)}if(t.hemisphere){const n=new C.Color(t.hemisphere.skyColor||"#ffffbb"),o=new C.Color(t.hemisphere.groundColor||"#080820"),i=t.hemisphere.intensity??1,a=new C.HemisphereLight(n,o,i);r.add(a)}if(t.directional){const n=new C.Color(t.directional.color||"#ffffff"),o=t.directional.intensity??Math.PI,i=new C.DirectionalLight(n,o);if(t.directional.position){const a=t.directional.position;if(a instanceof C.Vector3)i.position.copy(a);else if(Array.isArray(a))i.position.set(a[0],a[1],a[2]);else if(typeof a=="object"&&"x"in a&&"y"in a&&"z"in a){const c=a;i.position.set(c.x,c.y,c.z)}}else i.position.set(6,6,6);if(t.directional.castShadow&&(i.castShadow=!0,t.directional.shadow)){const a=t.directional.shadow;if(a.mapSize&&(i.shadow.mapSize.width=a.mapSize.width,i.shadow.mapSize.height=a.mapSize.height),a.camera){const c=i.shadow.camera;a.camera.near!==void 0&&(c.near=a.camera.near),a.camera.far!==void 0&&(c.far=a.camera.far),a.camera.left!==void 0&&(c.left=a.camera.left),a.camera.right!==void 0&&(c.right=a.camera.right),a.camera.top!==void 0&&(c.top=a.camera.top),a.camera.bottom!==void 0&&(c.bottom=a.camera.bottom)}a.bias!==void 0&&(i.shadow.bias=a.bias),a.radius!==void 0&&(i.shadow.radius=a.radius)}i.target.position.set(0,0,0),r.add(i),r.add(i.target),i.shadow&&i.shadow.camera.updateProjectionMatrix()}return X.ok(void 0)}catch(r){return X.err(new ce("Failed to add lighting to scene",ue.SCENE_OPERATION_FAILED,{originalError:r,options:t}))}}createGradientBackground(e,t){try{if(!(e instanceof Wt))return X.err(new ce("Scene must be ThreeSceneAdapter",ue.INVALID_PARAMETER));const r=e.getThreeScene(),n=document.createElement("canvas");n.width=2,n.height=512;const o=n.getContext("2d");if(!o)return X.err(new ce("Failed to create canvas context",ue.SCENE_OPERATION_FAILED));const i=o.createLinearGradient(0,0,0,n.height);i.addColorStop(0,t.topColor),i.addColorStop(1,t.bottomColor),o.fillStyle=i,o.fillRect(0,0,n.width,n.height);const a=new C.CanvasTexture(n);return a.needsUpdate=!0,r.background=a,X.ok(void 0)}catch(r){return X.err(new ce("Failed to create gradient background",ue.SCENE_OPERATION_FAILED,{originalError:r,options:t}))}}fitCameraToObject(e,t,r){try{let n;e instanceof We||"getThreeObject"in e&&typeof e.getThreeObject=="function"?n=e.getThreeObject():n=e;let o;t instanceof qn||"getThreeCamera"in t&&typeof t.getThreeCamera=="function"?o=t.getThreeCamera():o=t;let i;r instanceof ss||r instanceof os||"getThreeControls"in r&&typeof r.getThreeControls=="function"?i=r.getThreeControls():i=r;const a=new C.Box3().setFromObject(n),c=a.getCenter(new C.Vector3),u=a.getSize(new C.Vector3);console.log("Fitting camera to object:",{center:c,size:u,maxDimension:Math.max(u.x,u.y,u.z)});const d=Math.max(u.x,u.y,u.z);let h;"fov"in o?h=o.fov*(Math.PI/180):h=50*(Math.PI/180);let l=Math.abs(d/2/Math.tan(h/2));l*=2;const v=-Math.PI/4,b=Math.PI/8,T=c.x+l*Math.sin(v)*Math.cos(b),g=c.y+l*Math.sin(b),x=c.z+l*Math.cos(v)*Math.cos(b);return o.position.set(T,g,x),o.lookAt(c),o.updateProjectionMatrix(),i&&i.target&&(i.target.copy(c),i.update()),console.log("Camera positioned at:",{x:T,y:g,z:x}),console.log("Looking at:",c),X.ok(void 0)}catch(n){return X.err(new ce("Failed to fit camera to object",ue.CAMERA_INIT_FAILED,{originalError:n}))}}}const as=0,Ra=1,cs=2,ls=2,ri=1.25,us=1,Bt=6*4+4+4,mn=65535,Fa=Math.pow(2,-24),ni=Symbol("SKIP_GENERATION");function hs(s){return s.index?s.index.count:s.attributes.position.count}function hr(s){return hs(s)/3}function fs(s,e=ArrayBuffer){return s>65535?new Uint32Array(new e(4*s)):new Uint16Array(new e(2*s))}function Oa(s,e){if(!s.index){const t=s.attributes.position.count,r=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=fs(t,r);s.setIndex(new f.BufferAttribute(n,1));for(let o=0;o<t;o++)n[o]=o}}function ds(s,e){const t=hr(s),r=e||s.drawRange,n=r.start/3,o=(r.start+r.count)/3,i=Math.max(0,n),a=Math.min(t,o)-i;return[{offset:Math.floor(i),count:Math.floor(a)}]}function ps(s,e){if(!s.groups||!s.groups.length)return ds(s,e);const t=[],r=new Set,n=e||s.drawRange,o=n.start/3,i=(n.start+n.count)/3;for(const c of s.groups){const u=c.start/3,d=(c.start+c.count)/3;r.add(Math.max(o,u)),r.add(Math.min(i,d))}const a=Array.from(r.values()).sort((c,u)=>c-u);for(let c=0;c<a.length-1;c++){const u=a[c],d=a[c+1];t.push({offset:Math.floor(u),count:Math.floor(d-u)})}return t}function La(s,e){const t=hr(s),r=ps(s,e).sort((i,a)=>i.offset-a.offset),n=r[r.length-1];n.count=Math.min(t-n.offset,n.count);let o=0;return r.forEach(({count:i})=>o+=i),t!==o}function ii(s,e,t,r,n){let o=1/0,i=1/0,a=1/0,c=-1/0,u=-1/0,d=-1/0,h=1/0,l=1/0,v=1/0,b=-1/0,T=-1/0,g=-1/0;for(let x=e*6,w=(e+t)*6;x<w;x+=6){const S=s[x+0],A=s[x+1],P=S-A,D=S+A;P<o&&(o=P),D>c&&(c=D),S<h&&(h=S),S>b&&(b=S);const F=s[x+2],O=s[x+3],L=F-O,E=F+O;L<i&&(i=L),E>u&&(u=E),F<l&&(l=F),F>T&&(T=F);const V=s[x+4],z=s[x+5],G=V-z,U=V+z;G<a&&(a=G),U>d&&(d=U),V<v&&(v=V),V>g&&(g=V)}r[0]=o,r[1]=i,r[2]=a,r[3]=c,r[4]=u,r[5]=d,n[0]=h,n[1]=l,n[2]=v,n[3]=b,n[4]=T,n[5]=g}function Na(s,e=null,t=null,r=null){const n=s.attributes.position,o=s.index?s.index.array:null,i=hr(s),a=n.normalized;let c;e===null?(c=new Float32Array(i*6*4),t=0,r=i):(c=e,t=t||0,r=r||i);const u=n.array,d=n.offset||0;let h=3;n.isInterleavedBufferAttribute&&(h=n.data.stride);const l=["getX","getY","getZ"];for(let v=t;v<t+r;v++){const b=v*3,T=v*6;let g=b+0,x=b+1,w=b+2;o&&(g=o[g],x=o[x],w=o[w]),a||(g=g*h+d,x=x*h+d,w=w*h+d);for(let S=0;S<3;S++){let A,P,D;a?(A=n[l[S]](g),P=n[l[S]](x),D=n[l[S]](w)):(A=u[g+S],P=u[x+S],D=u[w+S]);let F=A;P<F&&(F=P),D<F&&(F=D);let O=A;P>O&&(O=P),D>O&&(O=D);const L=(O-F)/2,E=S*2;c[T+E+0]=F+L,c[T+E+1]=L+(Math.abs(F)+L)*Fa}}return c}function Fe(s,e,t){return t.min.x=e[s],t.min.y=e[s+1],t.min.z=e[s+2],t.max.x=e[s+3],t.max.y=e[s+4],t.max.z=e[s+5],t}function ms(s){let e=-1,t=-1/0;for(let r=0;r<3;r++){const n=s[r+3]-s[r];n>t&&(t=n,e=r)}return e}function gs(s,e){e.set(s)}function vs(s,e,t){let r,n;for(let o=0;o<3;o++){const i=o+3;r=s[o],n=e[o],t[o]=r<n?r:n,r=s[i],n=e[i],t[i]=r>n?r:n}}function gn(s,e,t){for(let r=0;r<3;r++){const n=e[s+2*r],o=e[s+2*r+1],i=n-o,a=n+o;i<t[r]&&(t[r]=i),a>t[r+3]&&(t[r+3]=a)}}function zr(s){const e=s[3]-s[0],t=s[4]-s[1],r=s[5]-s[2];return 2*(e*t+t*r+r*e)}const It=32,ka=(s,e)=>s.candidate-e.candidate,zt=new Array(It).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),vn=new Float32Array(6);function Ba(s,e,t,r,n,o){let i=-1,a=0;if(o===as)i=ms(e),i!==-1&&(a=(e[i]+e[i+3])/2);else if(o===Ra)i=ms(s),i!==-1&&(a=za(t,r,n,i));else if(o===cs){const c=zr(s);let u=ri*n;const d=r*6,h=(r+n)*6;for(let l=0;l<3;l++){const v=e[l],g=(e[l+3]-v)/It;if(n<It/4){const x=[...zt];x.length=n;let w=0;for(let A=d;A<h;A+=6,w++){const P=x[w];P.candidate=t[A+2*l],P.count=0;const{bounds:D,leftCacheBounds:F,rightCacheBounds:O}=P;for(let L=0;L<3;L++)O[L]=1/0,O[L+3]=-1/0,F[L]=1/0,F[L+3]=-1/0,D[L]=1/0,D[L+3]=-1/0;gn(A,t,D)}x.sort(ka);let S=n;for(let A=0;A<S;A++){const P=x[A];for(;A+1<S&&x[A+1].candidate===P.candidate;)x.splice(A+1,1),S--}for(let A=d;A<h;A+=6){const P=t[A+2*l];for(let D=0;D<S;D++){const F=x[D];P>=F.candidate?gn(A,t,F.rightCacheBounds):(gn(A,t,F.leftCacheBounds),F.count++)}}for(let A=0;A<S;A++){const P=x[A],D=P.count,F=n-P.count,O=P.leftCacheBounds,L=P.rightCacheBounds;let E=0;D!==0&&(E=zr(O)/c);let V=0;F!==0&&(V=zr(L)/c);const z=us+ri*(E*D+V*F);z<u&&(i=l,u=z,a=P.candidate)}}else{for(let S=0;S<It;S++){const A=zt[S];A.count=0,A.candidate=v+g+S*g;const P=A.bounds;for(let D=0;D<3;D++)P[D]=1/0,P[D+3]=-1/0}for(let S=d;S<h;S+=6){let D=~~((t[S+2*l]-v)/g);D>=It&&(D=It-1);const F=zt[D];F.count++,gn(S,t,F.bounds)}const x=zt[It-1];gs(x.bounds,x.rightCacheBounds);for(let S=It-2;S>=0;S--){const A=zt[S],P=zt[S+1];vs(A.bounds,P.rightCacheBounds,A.rightCacheBounds)}let w=0;for(let S=0;S<It-1;S++){const A=zt[S],P=A.count,D=A.bounds,O=zt[S+1].rightCacheBounds;P!==0&&(w===0?gs(D,vn):vs(D,vn,vn)),w+=P;let L=0,E=0;w!==0&&(L=zr(vn)/c);const V=n-w;V!==0&&(E=zr(O)/c);const z=us+ri*(L*w+E*V);z<u&&(i=l,u=z,a=A.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${o} used.`);return{axis:i,pos:a}}function za(s,e,t,r){let n=0;for(let o=e,i=e+t;o<i;o++)n+=s[o*6+r*2];return n/t}class si{constructor(){this.boundingData=new Float32Array(6)}}function Ea(s,e,t,r,n,o){let i=r,a=r+n-1;const c=o.pos,u=o.axis*2;for(;;){for(;i<=a&&t[i*6+u]<c;)i++;for(;i<=a&&t[a*6+u]>=c;)a--;if(i<a){for(let d=0;d<3;d++){let h=e[i*3+d];e[i*3+d]=e[a*3+d],e[a*3+d]=h}for(let d=0;d<6;d++){let h=t[i*6+d];t[i*6+d]=t[a*6+d],t[a*6+d]=h}i++,a--}else return i}}function Ua(s,e,t,r,n,o){let i=r,a=r+n-1;const c=o.pos,u=o.axis*2;for(;;){for(;i<=a&&t[i*6+u]<c;)i++;for(;i<=a&&t[a*6+u]>=c;)a--;if(i<a){let d=s[i];s[i]=s[a],s[a]=d;for(let h=0;h<6;h++){let l=t[i*6+h];t[i*6+h]=t[a*6+h],t[a*6+h]=l}i++,a--}else return i}}function Ye(s,e){return e[s+15]===65535}function Xe(s,e){return e[s+6]}function Je(s,e){return e[s+14]}function at(s){return s+8}function He(s,e){return e[s+6]}function oi(s,e){return e[s+7]}function kh(s){return s}let ys,Er,yn,bs;const Va=Math.pow(2,32);function ai(s){return"count"in s?1:1+ai(s.left)+ai(s.right)}function Ga(s,e,t){return ys=new Float32Array(t),Er=new Uint32Array(t),yn=new Uint16Array(t),bs=new Uint8Array(t),ci(s,e)}function ci(s,e){const t=s/4,r=s/2,n="count"in e,o=e.boundingData;for(let i=0;i<6;i++)ys[t+i]=o[i];if(n)if(e.buffer){const i=e.buffer;bs.set(new Uint8Array(i),s);for(let a=s,c=s+i.byteLength;a<c;a+=Bt){const u=a/2;Ye(u,yn)||(Er[a/4+6]+=t)}return s+i.byteLength}else{const i=e.offset,a=e.count;return Er[t+6]=i,yn[r+14]=a,yn[r+15]=mn,s+Bt}else{const i=e.left,a=e.right,c=e.splitAxis;let u;if(u=ci(s+Bt,i),u/4>Va)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Er[t+6]=u/4,u=ci(u,a),Er[t+7]=c,u}}function ja(s,e){const t=(s.index?s.index.count:s.attributes.position.count)/3,r=t>2**16,n=r?4:2,o=e?new SharedArrayBuffer(t*n):new ArrayBuffer(t*n),i=r?new Uint32Array(o):new Uint16Array(o);for(let a=0,c=i.length;a<c;a++)i[a]=a;return i}function Wa(s,e,t,r,n){const{maxDepth:o,verbose:i,maxLeafTris:a,strategy:c,onProgress:u,indirect:d}=n,h=s._indirectBuffer,l=s.geometry,v=l.index?l.index.array:null,b=d?Ua:Ea,T=hr(l),g=new Float32Array(6);let x=!1;const w=new si;return ii(e,t,r,w.boundingData,g),A(w,t,r,g),w;function S(P){u&&u(P/T)}function A(P,D,F,O=null,L=0){if(!x&&L>=o&&(x=!0,i&&(console.warn(`MeshBVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),F<=a||L>=o)return S(D+F),P.offset=D,P.count=F,P;const E=Ba(P.boundingData,O,e,D,F,c);if(E.axis===-1)return S(D+F),P.offset=D,P.count=F,P;const V=b(h,v,e,D,F,E);if(V===D||V===D+F)S(D+F),P.offset=D,P.count=F;else{P.splitAxis=E.axis;const z=new si,G=D,U=V-D;P.left=z,ii(e,G,U,z.boundingData,g),A(z,G,U,g,L+1);const H=new si,ne=V,ge=F-U;P.right=H,ii(e,ne,ge,H.boundingData,g),A(H,ne,ge,g,L+1)}return P}}function Ya(s,e){const t=s.geometry;e.indirect&&(s._indirectBuffer=ja(t,e.useSharedArrayBuffer),La(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),s._indirectBuffer||Oa(t,e);const r=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=Na(t),o=e.indirect?ds(t,e.range):ps(t,e.range);s._roots=o.map(i=>{const a=Wa(s,n,i.offset,i.count,e),c=ai(a),u=new r(Bt*c);return Ga(0,a,u),u})}class Ct{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let r=1/0,n=-1/0;for(let o=0,i=e.length;o<i;o++){const c=e[o][t];r=c<r?c:r,n=c>n?c:n}this.min=r,this.max=n}setFromPoints(e,t){let r=1/0,n=-1/0;for(let o=0,i=t.length;o<i;o++){const a=t[o],c=e.dot(a);r=c<r?c:r,n=c>n?c:n}this.min=r,this.max=n}isSeparated(e){return this.min>e.max||e.min>this.max}}Ct.prototype.setFromBox=function(){const s=new f.Vector3;return function(t,r){const n=r.min,o=r.max;let i=1/0,a=-1/0;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let d=0;d<=1;d++){s.x=n.x*c+o.x*(1-c),s.y=n.y*u+o.y*(1-u),s.z=n.z*d+o.z*(1-d);const h=t.dot(s);i=Math.min(h,i),a=Math.max(h,a)}this.min=i,this.max=a}}();const Za=function(){const s=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(n,o,i){const a=n.start,c=s,u=o.start,d=e;t.subVectors(a,u),s.subVectors(n.end,n.start),e.subVectors(o.end,o.start);const h=t.dot(d),l=d.dot(c),v=d.dot(d),b=t.dot(c),g=c.dot(c)*v-l*l;let x,w;g!==0?x=(h*l-b*v)/g:x=0,w=(h+x*l)/v,i.x=x,i.y=w}}(),li=function(){const s=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(n,o,i,a){Za(n,o,s);let c=s.x,u=s.y;if(c>=0&&c<=1&&u>=0&&u<=1){n.at(c,i),o.at(u,a);return}else if(c>=0&&c<=1){u<0?o.at(0,a):o.at(1,a),n.closestPointToPoint(a,!0,i);return}else if(u>=0&&u<=1){c<0?n.at(0,i):n.at(1,i),o.closestPointToPoint(i,!0,a);return}else{let d;c<0?d=n.start:d=n.end;let h;u<0?h=o.start:h=o.end;const l=e,v=t;if(n.closestPointToPoint(h,!0,e),o.closestPointToPoint(d,!0,t),l.distanceToSquared(h)<=v.distanceToSquared(d)){i.copy(l),a.copy(h);return}else{i.copy(d),a.copy(v);return}}}}(),qa=function(){const s=new f.Vector3,e=new f.Vector3,t=new f.Plane,r=new f.Line3;return function(o,i){const{radius:a,center:c}=o,{a:u,b:d,c:h}=i;if(r.start=u,r.end=d,r.closestPointToPoint(c,!0,s).distanceTo(c)<=a||(r.start=u,r.end=h,r.closestPointToPoint(c,!0,s).distanceTo(c)<=a)||(r.start=d,r.end=h,r.closestPointToPoint(c,!0,s).distanceTo(c)<=a))return!0;const T=i.getPlane(t);if(Math.abs(T.distanceToPoint(c))<=a){const x=T.projectPoint(c,e);if(i.containsPoint(x))return!0}return!1}}(),Ka=1e-15;function ui(s){return Math.abs(s)<Ka}class mt extends f.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new f.Vector3),this.satBounds=new Array(4).fill().map(()=>new Ct),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return qa(e,this)}update(){const e=this.a,t=this.b,r=this.c,n=this.points,o=this.satAxes,i=this.satBounds,a=o[0],c=i[0];this.getNormal(a),c.setFromPoints(a,n);const u=o[1],d=i[1];u.subVectors(e,t),d.setFromPoints(u,n);const h=o[2],l=i[2];h.subVectors(t,r),l.setFromPoints(h,n);const v=o[3],b=i[3];v.subVectors(r,e),b.setFromPoints(v,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}mt.prototype.closestPointToSegment=function(){const s=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(n,o=null,i=null){const{start:a,end:c}=n,u=this.points;let d,h=1/0;for(let l=0;l<3;l++){const v=(l+1)%3;t.start.copy(u[l]),t.end.copy(u[v]),li(t,n,s,e),d=s.distanceToSquared(e),d<h&&(h=d,o&&o.copy(s),i&&i.copy(e))}return this.closestPointToPoint(a,s),d=a.distanceToSquared(s),d<h&&(h=d,o&&o.copy(s),i&&i.copy(a)),this.closestPointToPoint(c,s),d=c.distanceToSquared(s),d<h&&(h=d,o&&o.copy(s),i&&i.copy(c)),Math.sqrt(h)}}(),mt.prototype.intersectsTriangle=function(){const s=new mt,e=new Array(3),t=new Array(3),r=new Ct,n=new Ct,o=new f.Vector3,i=new f.Vector3,a=new f.Vector3,c=new f.Vector3,u=new f.Vector3,d=new f.Line3,h=new f.Line3,l=new f.Line3,v=new f.Vector3;function b(T,g,x){const w=T.points;let S=0,A=-1;for(let P=0;P<3;P++){const{start:D,end:F}=d;D.copy(w[P]),F.copy(w[(P+1)%3]),d.delta(i);const O=ui(g.distanceToPoint(D));if(ui(g.normal.dot(i))&&O){x.copy(d),S=2;break}const L=g.intersectLine(d,v);if(!L&&O&&v.copy(D),(L||O)&&!ui(v.distanceTo(F))){if(S<=1)(S===1?x.start:x.end).copy(v),O&&(A=S);else if(S>=2){(A===1?x.start:x.end).copy(v),S=2;break}if(S++,S===2&&A===-1)break}}return S}return function(g,x=null,w=!1){this.needsUpdate&&this.update(),g.isExtendedTriangle?g.needsUpdate&&g.update():(s.copy(g),s.update(),g=s);const S=this.plane,A=g.plane;if(Math.abs(S.normal.dot(A.normal))>1-1e-10){const P=this.satBounds,D=this.satAxes;t[0]=g.a,t[1]=g.b,t[2]=g.c;for(let L=0;L<4;L++){const E=P[L],V=D[L];if(r.setFromPoints(V,t),E.isSeparated(r))return!1}const F=g.satBounds,O=g.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let L=0;L<4;L++){const E=F[L],V=O[L];if(r.setFromPoints(V,e),E.isSeparated(r))return!1}for(let L=0;L<4;L++){const E=D[L];for(let V=0;V<4;V++){const z=O[V];if(o.crossVectors(E,z),r.setFromPoints(o,e),n.setFromPoints(o,t),r.isSeparated(n))return!1}}return x&&(w||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),x.start.set(0,0,0),x.end.set(0,0,0)),!0}else{const P=b(this,A,h);if(P===1&&g.containsPoint(h.end))return x&&(x.start.copy(h.end),x.end.copy(h.end)),!0;if(P!==2)return!1;const D=b(g,S,l);if(D===1&&this.containsPoint(l.end))return x&&(x.start.copy(l.end),x.end.copy(l.end)),!0;if(D!==2)return!1;if(h.delta(a),l.delta(c),a.dot(c)<0){let G=l.start;l.start=l.end,l.end=G}const F=h.start.dot(a),O=h.end.dot(a),L=l.start.dot(a),E=l.end.dot(a),V=O<L,z=F<E;return F!==E&&L!==O&&V===z?!1:(x&&(u.subVectors(h.start,l.start),u.dot(a)>0?x.start.copy(h.start):x.start.copy(l.start),u.subVectors(h.end,l.end),u.dot(a)<0?x.end.copy(h.end):x.end.copy(l.end)),!0)}}}(),mt.prototype.distanceToPoint=function(){const s=new f.Vector3;return function(t){return this.closestPointToPoint(t,s),t.distanceTo(s)}}(),mt.prototype.distanceToTriangle=function(){const s=new f.Vector3,e=new f.Vector3,t=["a","b","c"],r=new f.Line3,n=new f.Line3;return function(i,a=null,c=null){const u=a||c?r:null;if(this.intersectsTriangle(i,u))return(a||c)&&(a&&u.getCenter(a),c&&u.getCenter(c)),0;let d=1/0;for(let h=0;h<3;h++){let l;const v=t[h],b=i[v];this.closestPointToPoint(b,s),l=b.distanceToSquared(s),l<d&&(d=l,a&&a.copy(s),c&&c.copy(b));const T=this[v];i.closestPointToPoint(T,s),l=T.distanceToSquared(s),l<d&&(d=l,a&&a.copy(T),c&&c.copy(s))}for(let h=0;h<3;h++){const l=t[h],v=t[(h+1)%3];r.set(this[l],this[v]);for(let b=0;b<3;b++){const T=t[b],g=t[(b+1)%3];n.set(i[T],i[g]),li(r,n,s,e);const x=s.distanceToSquared(e);x<d&&(d=x,a&&a.copy(s),c&&c.copy(e))}}return Math.sqrt(d)}}();class Ze{constructor(e,t,r){this.isOrientedBox=!0,this.min=new f.Vector3,this.max=new f.Vector3,this.matrix=new f.Matrix4,this.invMatrix=new f.Matrix4,this.points=new Array(8).fill().map(()=>new f.Vector3),this.satAxes=new Array(3).fill().map(()=>new f.Vector3),this.satBounds=new Array(3).fill().map(()=>new Ct),this.alignedSatBounds=new Array(3).fill().map(()=>new Ct),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),r&&this.matrix.copy(r)}set(e,t,r){this.min.copy(e),this.max.copy(t),this.matrix.copy(r),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ze.prototype.update=function(){return function(){const e=this.matrix,t=this.min,r=this.max,n=this.points;for(let u=0;u<=1;u++)for(let d=0;d<=1;d++)for(let h=0;h<=1;h++){const l=1*u|2*d|4*h,v=n[l];v.x=u?r.x:t.x,v.y=d?r.y:t.y,v.z=h?r.z:t.z,v.applyMatrix4(e)}const o=this.satBounds,i=this.satAxes,a=n[0];for(let u=0;u<3;u++){const d=i[u],h=o[u],l=1<<u,v=n[l];d.subVectors(a,v),h.setFromPoints(d,n)}const c=this.alignedSatBounds;c[0].setFromPointsField(n,"x"),c[1].setFromPointsField(n,"y"),c[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Ze.prototype.intersectsBox=function(){const s=new Ct;return function(t){this.needsUpdate&&this.update();const r=t.min,n=t.max,o=this.satBounds,i=this.satAxes,a=this.alignedSatBounds;if(s.min=r.x,s.max=n.x,a[0].isSeparated(s)||(s.min=r.y,s.max=n.y,a[1].isSeparated(s))||(s.min=r.z,s.max=n.z,a[2].isSeparated(s)))return!1;for(let c=0;c<3;c++){const u=i[c],d=o[c];if(s.setFromBox(u,t),d.isSeparated(s))return!1}return!0}}(),Ze.prototype.intersectsTriangle=function(){const s=new mt,e=new Array(3),t=new Ct,r=new Ct,n=new f.Vector3;return function(i){this.needsUpdate&&this.update(),i.isExtendedTriangle?i.needsUpdate&&i.update():(s.copy(i),s.update(),i=s);const a=this.satBounds,c=this.satAxes;e[0]=i.a,e[1]=i.b,e[2]=i.c;for(let l=0;l<3;l++){const v=a[l],b=c[l];if(t.setFromPoints(b,e),v.isSeparated(t))return!1}const u=i.satBounds,d=i.satAxes,h=this.points;for(let l=0;l<3;l++){const v=u[l],b=d[l];if(t.setFromPoints(b,h),v.isSeparated(t))return!1}for(let l=0;l<3;l++){const v=c[l];for(let b=0;b<4;b++){const T=d[b];if(n.crossVectors(v,T),t.setFromPoints(n,e),r.setFromPoints(n,h),t.isSeparated(r))return!1}}return!0}}(),Ze.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}(),Ze.prototype.distanceToPoint=function(){const s=new f.Vector3;return function(t){return this.closestPointToPoint(t,s),t.distanceTo(s)}}(),Ze.prototype.distanceToBox=function(){const s=["x","y","z"],e=new Array(12).fill().map(()=>new f.Line3),t=new Array(12).fill().map(()=>new f.Line3),r=new f.Vector3,n=new f.Vector3;return function(i,a=0,c=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(i))return(c||u)&&(i.getCenter(n),this.closestPointToPoint(n,r),i.closestPointToPoint(r,n),c&&c.copy(r),u&&u.copy(n)),0;const d=a*a,h=i.min,l=i.max,v=this.points;let b=1/0;for(let g=0;g<8;g++){const x=v[g];n.copy(x).clamp(h,l);const w=x.distanceToSquared(n);if(w<b&&(b=w,c&&c.copy(x),u&&u.copy(n),w<d))return Math.sqrt(w)}let T=0;for(let g=0;g<3;g++)for(let x=0;x<=1;x++)for(let w=0;w<=1;w++){const S=(g+1)%3,A=(g+2)%3,P=x<<S|w<<A,D=1<<g|x<<S|w<<A,F=v[P],O=v[D];e[T].set(F,O);const E=s[g],V=s[S],z=s[A],G=t[T],U=G.start,H=G.end;U[E]=h[E],U[V]=x?h[V]:l[V],U[z]=w?h[z]:l[V],H[E]=l[E],H[V]=x?h[V]:l[V],H[z]=w?h[z]:l[V],T++}for(let g=0;g<=1;g++)for(let x=0;x<=1;x++)for(let w=0;w<=1;w++){n.x=g?l.x:h.x,n.y=x?l.y:h.y,n.z=w?l.z:h.z,this.closestPointToPoint(n,r);const S=n.distanceToSquared(r);if(S<b&&(b=S,c&&c.copy(r),u&&u.copy(n),S<d))return Math.sqrt(S)}for(let g=0;g<12;g++){const x=e[g];for(let w=0;w<12;w++){const S=t[w];li(x,S,r,n);const A=r.distanceToSquared(n);if(A<b&&(b=A,c&&c.copy(r),u&&u.copy(n),A<d))return Math.sqrt(A)}}return Math.sqrt(b)}}();class hi{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Xa extends hi{constructor(){super(()=>new mt)}}const ct=new Xa;class $a{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=r=>{t&&e.push(t),t=r,this.float32Array=new Float32Array(r),this.uint16Array=new Uint16Array(r),this.uint32Array=new Uint32Array(r)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Me=new $a;let Et,fr;const dr=[],bn=new hi(()=>new f.Box3);function Qa(s,e,t,r,n,o){Et=bn.getPrimitive(),fr=bn.getPrimitive(),dr.push(Et,fr),Me.setBuffer(s._roots[e]);const i=fi(0,s.geometry,t,r,n,o);Me.clearBuffer(),bn.releasePrimitive(Et),bn.releasePrimitive(fr),dr.pop(),dr.pop();const a=dr.length;return a>0&&(fr=dr[a-1],Et=dr[a-2]),i}function fi(s,e,t,r,n=null,o=0,i=0){const{float32Array:a,uint16Array:c,uint32Array:u}=Me;let d=s*2;if(Ye(d,c)){const l=Xe(s,u),v=Je(d,c);return Fe(s,a,Et),r(l,v,!1,i,o+s,Et)}else{let E=function(z){const{uint16Array:G,uint32Array:U}=Me;let H=z*2;for(;!Ye(H,G);)z=at(z),H=z*2;return Xe(z,U)},V=function(z){const{uint16Array:G,uint32Array:U}=Me;let H=z*2;for(;!Ye(H,G);)z=He(z,U),H=z*2;return Xe(z,U)+Je(H,G)};const l=at(s),v=He(s,u);let b=l,T=v,g,x,w,S;if(n&&(w=Et,S=fr,Fe(b,a,w),Fe(T,a,S),g=n(w),x=n(S),x<g)){b=v,T=l;const z=g;g=x,x=z,w=S}w||(w=Et,Fe(b,a,w));const A=Ye(b*2,c),P=t(w,A,g,i+1,o+b);let D;if(P===ls){const z=E(b),U=V(b)-z;D=r(z,U,!0,i+1,o+b,w)}else D=P&&fi(b,e,t,r,n,o,i+1);if(D)return!0;S=fr,Fe(T,a,S);const F=Ye(T*2,c),O=t(S,F,x,i+1,o+T);let L;if(O===ls){const z=E(T),U=V(T)-z;L=r(z,U,!0,i+1,o+T,S)}else L=O&&fi(T,e,t,r,n,o,i+1);return!!L}}const Ur=new f.Vector3,di=new f.Vector3;function Ja(s,e,t={},r=0,n=1/0){const o=r*r,i=n*n;let a=1/0,c=null;if(s.shapecast({boundsTraverseOrder:d=>(Ur.copy(e).clamp(d.min,d.max),Ur.distanceToSquared(e)),intersectsBounds:(d,h,l)=>l<a&&l<i,intersectsTriangle:(d,h)=>{d.closestPointToPoint(e,Ur);const l=e.distanceToSquared(Ur);return l<a&&(di.copy(Ur),a=l,c=h),l<o}}),a===1/0)return null;const u=Math.sqrt(a);return t.point?t.point.copy(di):t.point=di.clone(),t.distance=u,t.faceIndex=c,t}const pr=new f.Vector3,mr=new f.Vector3,gr=new f.Vector3,xn=new f.Vector2,wn=new f.Vector2,_n=new f.Vector2,xs=new f.Vector3,ws=new f.Vector3,_s=new f.Vector3,Tn=new f.Vector3;function Ha(s,e,t,r,n,o,i,a){let c;if(o===f.BackSide?c=s.intersectTriangle(r,t,e,!0,n):c=s.intersectTriangle(e,t,r,o!==f.DoubleSide,n),c===null)return null;const u=s.origin.distanceTo(n);return u<i||u>a?null:{distance:u,point:n.clone()}}function ec(s,e,t,r,n,o,i,a,c,u,d){pr.fromBufferAttribute(e,o),mr.fromBufferAttribute(e,i),gr.fromBufferAttribute(e,a);const h=Ha(s,pr,mr,gr,Tn,c,u,d);if(h){r&&(xn.fromBufferAttribute(r,o),wn.fromBufferAttribute(r,i),_n.fromBufferAttribute(r,a),h.uv=f.Triangle.getInterpolation(Tn,pr,mr,gr,xn,wn,_n,new f.Vector2)),n&&(xn.fromBufferAttribute(n,o),wn.fromBufferAttribute(n,i),_n.fromBufferAttribute(n,a),h.uv1=f.Triangle.getInterpolation(Tn,pr,mr,gr,xn,wn,_n,new f.Vector2)),t&&(xs.fromBufferAttribute(t,o),ws.fromBufferAttribute(t,i),_s.fromBufferAttribute(t,a),h.normal=f.Triangle.getInterpolation(Tn,pr,mr,gr,xs,ws,_s,new f.Vector3),h.normal.dot(s.direction)>0&&h.normal.multiplyScalar(-1));const l={a:o,b:i,c:a,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(pr,mr,gr,l.normal),h.face=l,h.faceIndex=o}return h}function Sn(s,e,t,r,n,o,i){const a=r*3;let c=a+0,u=a+1,d=a+2;const h=s.index;s.index&&(c=h.getX(c),u=h.getX(u),d=h.getX(d));const{position:l,normal:v,uv:b,uv1:T}=s.attributes,g=ec(t,l,v,b,T,c,u,d,e,o,i);return g?(g.faceIndex=r,n&&n.push(g),g):null}function Oe(s,e,t,r){const n=s.a,o=s.b,i=s.c;let a=e,c=e+1,u=e+2;t&&(a=t.getX(a),c=t.getX(c),u=t.getX(u)),n.x=r.getX(a),n.y=r.getY(a),n.z=r.getZ(a),o.x=r.getX(c),o.y=r.getY(c),o.z=r.getZ(c),i.x=r.getX(u),i.y=r.getY(u),i.z=r.getZ(u)}function tc(s,e,t,r,n,o,i,a){const{geometry:c,_indirectBuffer:u}=s;for(let d=r,h=r+n;d<h;d++)Sn(c,e,t,d,o,i,a)}function rc(s,e,t,r,n,o,i){const{geometry:a,_indirectBuffer:c}=s;let u=1/0,d=null;for(let h=r,l=r+n;h<l;h++){let v;v=Sn(a,e,t,h,null,o,i),v&&v.distance<u&&(d=v,u=v.distance)}return d}function nc(s,e,t,r,n,o,i){const{geometry:a}=t,{index:c}=a,u=a.attributes.position;for(let d=s,h=e+s;d<h;d++){let l;if(l=d,Oe(i,l*3,c,u),i.needsUpdate=!0,r(i,l,n,o))return!0}return!1}function ic(s,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=s.geometry,r=t.index?t.index.array:null,n=t.attributes.position;let o,i,a,c,u=0;const d=s._roots;for(let l=0,v=d.length;l<v;l++)o=d[l],i=new Uint32Array(o),a=new Uint16Array(o),c=new Float32Array(o),h(0,u),u+=o.byteLength;function h(l,v,b=!1){const T=l*2;if(a[T+15]===mn){const x=i[l+6],w=a[T+14];let S=1/0,A=1/0,P=1/0,D=-1/0,F=-1/0,O=-1/0;for(let L=3*x,E=3*(x+w);L<E;L++){let V=r[L];const z=n.getX(V),G=n.getY(V),U=n.getZ(V);z<S&&(S=z),z>D&&(D=z),G<A&&(A=G),G>F&&(F=G),U<P&&(P=U),U>O&&(O=U)}return c[l+0]!==S||c[l+1]!==A||c[l+2]!==P||c[l+3]!==D||c[l+4]!==F||c[l+5]!==O?(c[l+0]=S,c[l+1]=A,c[l+2]=P,c[l+3]=D,c[l+4]=F,c[l+5]=O,!0):!1}else{const x=l+8,w=i[l+6],S=x+v,A=w+v;let P=b,D=!1,F=!1;e?P||(D=e.has(S),F=e.has(A),P=!D&&!F):(D=!0,F=!0);const O=P||D,L=P||F;let E=!1;O&&(E=h(x,v,P));let V=!1;L&&(V=h(w,v,P));const z=E||V;if(z)for(let G=0;G<3;G++){const U=x+G,H=w+G,ne=c[U],ge=c[U+3],Pe=c[H],ve=c[H+3];c[l+G]=ne<Pe?ne:Pe,c[l+G+3]=ge>ve?ge:ve}return z}}}function Ut(s,e,t,r,n){let o,i,a,c,u,d;const h=1/t.direction.x,l=1/t.direction.y,v=1/t.direction.z,b=t.origin.x,T=t.origin.y,g=t.origin.z;let x=e[s],w=e[s+3],S=e[s+1],A=e[s+3+1],P=e[s+2],D=e[s+3+2];return h>=0?(o=(x-b)*h,i=(w-b)*h):(o=(w-b)*h,i=(x-b)*h),l>=0?(a=(S-T)*l,c=(A-T)*l):(a=(A-T)*l,c=(S-T)*l),o>c||a>i||((a>o||isNaN(o))&&(o=a),(c<i||isNaN(i))&&(i=c),v>=0?(u=(P-g)*v,d=(D-g)*v):(u=(D-g)*v,d=(P-g)*v),o>d||u>i)?!1:((u>o||o!==o)&&(o=u),(d<i||i!==i)&&(i=d),o<=n&&i>=r)}function sc(s,e,t,r,n,o,i,a){const{geometry:c,_indirectBuffer:u}=s;for(let d=r,h=r+n;d<h;d++){let l=u?u[d]:d;Sn(c,e,t,l,o,i,a)}}function oc(s,e,t,r,n,o,i){const{geometry:a,_indirectBuffer:c}=s;let u=1/0,d=null;for(let h=r,l=r+n;h<l;h++){let v;v=Sn(a,e,t,c?c[h]:h,null,o,i),v&&v.distance<u&&(d=v,u=v.distance)}return d}function ac(s,e,t,r,n,o,i){const{geometry:a}=t,{index:c}=a,u=a.attributes.position;for(let d=s,h=e+s;d<h;d++){let l;if(l=t.resolveTriangleIndex(d),Oe(i,l*3,c,u),i.needsUpdate=!0,r(i,l,n,o))return!0}return!1}function cc(s,e,t,r,n,o,i){Me.setBuffer(s._roots[e]),pi(0,s,t,r,n,o,i),Me.clearBuffer()}function pi(s,e,t,r,n,o,i){const{float32Array:a,uint16Array:c,uint32Array:u}=Me,d=s*2;if(Ye(d,c)){const l=Xe(s,u),v=Je(d,c);tc(e,t,r,l,v,n,o,i)}else{const l=at(s);Ut(l,a,r,o,i)&&pi(l,e,t,r,n,o,i);const v=He(s,u);Ut(v,a,r,o,i)&&pi(v,e,t,r,n,o,i)}}const lc=["x","y","z"];function uc(s,e,t,r,n,o){Me.setBuffer(s._roots[e]);const i=mi(0,s,t,r,n,o);return Me.clearBuffer(),i}function mi(s,e,t,r,n,o){const{float32Array:i,uint16Array:a,uint32Array:c}=Me;let u=s*2;if(Ye(u,a)){const h=Xe(s,c),l=Je(u,a);return rc(e,t,r,h,l,n,o)}else{const h=oi(s,c),l=lc[h],b=r.direction[l]>=0;let T,g;b?(T=at(s),g=He(s,c)):(T=He(s,c),g=at(s));const w=Ut(T,i,r,n,o)?mi(T,e,t,r,n,o):null;if(w){const P=w.point[l];if(b?P<=i[g+h]:P>=i[g+h+3])return w}const A=Ut(g,i,r,n,o)?mi(g,e,t,r,n,o):null;return w&&A?w.distance<=A.distance?w:A:w||A||null}}const An=new f.Box3,vr=new mt,yr=new mt,Vr=new f.Matrix4,Ts=new Ze,Mn=new Ze;function hc(s,e,t,r){Me.setBuffer(s._roots[e]);const n=gi(0,s,t,r);return Me.clearBuffer(),n}function gi(s,e,t,r,n=null){const{float32Array:o,uint16Array:i,uint32Array:a}=Me;let c=s*2;if(n===null&&(t.boundingBox||t.computeBoundingBox(),Ts.set(t.boundingBox.min,t.boundingBox.max,r),n=Ts),Ye(c,i)){const d=e.geometry,h=d.index,l=d.attributes.position,v=t.index,b=t.attributes.position,T=Xe(s,a),g=Je(c,i);if(Vr.copy(r).invert(),t.boundsTree)return Fe(s,o,Mn),Mn.matrix.copy(Vr),Mn.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>Mn.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(r),w.b.applyMatrix4(r),w.c.applyMatrix4(r),w.needsUpdate=!0;for(let S=T*3,A=(g+T)*3;S<A;S+=3)if(Oe(yr,S,h,l),yr.needsUpdate=!0,w.intersectsTriangle(yr))return!0;return!1}});for(let x=T*3,w=(g+T)*3;x<w;x+=3){Oe(vr,x,h,l),vr.a.applyMatrix4(Vr),vr.b.applyMatrix4(Vr),vr.c.applyMatrix4(Vr),vr.needsUpdate=!0;for(let S=0,A=v.count;S<A;S+=3)if(Oe(yr,S,v,b),yr.needsUpdate=!0,vr.intersectsTriangle(yr))return!0}}else{const d=s+8,h=a[s+6];return Fe(d,o,An),!!(n.intersectsBox(An)&&gi(d,e,t,r,n)||(Fe(h,o,An),n.intersectsBox(An)&&gi(h,e,t,r,n)))}}const In=new f.Matrix4,vi=new Ze,Gr=new Ze,fc=new f.Vector3,dc=new f.Vector3,pc=new f.Vector3,mc=new f.Vector3;function gc(s,e,t,r={},n={},o=0,i=1/0){e.boundingBox||e.computeBoundingBox(),vi.set(e.boundingBox.min,e.boundingBox.max,t),vi.needsUpdate=!0;const a=s.geometry,c=a.attributes.position,u=a.index,d=e.attributes.position,h=e.index,l=ct.getPrimitive(),v=ct.getPrimitive();let b=fc,T=dc,g=null,x=null;n&&(g=pc,x=mc);let w=1/0,S=null,A=null;return In.copy(t).invert(),Gr.matrix.copy(In),s.shapecast({boundsTraverseOrder:P=>vi.distanceToBox(P),intersectsBounds:(P,D,F)=>F<w&&F<i?(D&&(Gr.min.copy(P.min),Gr.max.copy(P.max),Gr.needsUpdate=!0),!0):!1,intersectsRange:(P,D)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:O=>Gr.distanceToBox(O),intersectsBounds:(O,L,E)=>E<w&&E<i,intersectsRange:(O,L)=>{for(let E=O,V=O+L;E<V;E++){Oe(v,3*E,h,d),v.a.applyMatrix4(t),v.b.applyMatrix4(t),v.c.applyMatrix4(t),v.needsUpdate=!0;for(let z=P,G=P+D;z<G;z++){Oe(l,3*z,u,c),l.needsUpdate=!0;const U=l.distanceToTriangle(v,b,g);if(U<w&&(T.copy(b),x&&x.copy(g),w=U,S=z,A=E),U<o)return!0}}}});{const F=hr(e);for(let O=0,L=F;O<L;O++){Oe(v,3*O,h,d),v.a.applyMatrix4(t),v.b.applyMatrix4(t),v.c.applyMatrix4(t),v.needsUpdate=!0;for(let E=P,V=P+D;E<V;E++){Oe(l,3*E,u,c),l.needsUpdate=!0;const z=l.distanceToTriangle(v,b,g);if(z<w&&(T.copy(b),x&&x.copy(g),w=z,S=E,A=O),z<o)return!0}}}}}),ct.releasePrimitive(l),ct.releasePrimitive(v),w===1/0?null:(r.point?r.point.copy(T):r.point=T.clone(),r.distance=w,r.faceIndex=S,n&&(n.point?n.point.copy(x):n.point=x.clone(),n.point.applyMatrix4(In),T.applyMatrix4(In),n.distance=T.sub(n.point).length(),n.faceIndex=A),r)}function vc(s,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=s.geometry,r=t.index?t.index.array:null,n=t.attributes.position;let o,i,a,c,u=0;const d=s._roots;for(let l=0,v=d.length;l<v;l++)o=d[l],i=new Uint32Array(o),a=new Uint16Array(o),c=new Float32Array(o),h(0,u),u+=o.byteLength;function h(l,v,b=!1){const T=l*2;if(a[T+15]===mn){const x=i[l+6],w=a[T+14];let S=1/0,A=1/0,P=1/0,D=-1/0,F=-1/0,O=-1/0;for(let L=x,E=x+w;L<E;L++){const V=3*s.resolveTriangleIndex(L);for(let z=0;z<3;z++){let G=V+z;G=r?r[G]:G;const U=n.getX(G),H=n.getY(G),ne=n.getZ(G);U<S&&(S=U),U>D&&(D=U),H<A&&(A=H),H>F&&(F=H),ne<P&&(P=ne),ne>O&&(O=ne)}}return c[l+0]!==S||c[l+1]!==A||c[l+2]!==P||c[l+3]!==D||c[l+4]!==F||c[l+5]!==O?(c[l+0]=S,c[l+1]=A,c[l+2]=P,c[l+3]=D,c[l+4]=F,c[l+5]=O,!0):!1}else{const x=l+8,w=i[l+6],S=x+v,A=w+v;let P=b,D=!1,F=!1;e?P||(D=e.has(S),F=e.has(A),P=!D&&!F):(D=!0,F=!0);const O=P||D,L=P||F;let E=!1;O&&(E=h(x,v,P));let V=!1;L&&(V=h(w,v,P));const z=E||V;if(z)for(let G=0;G<3;G++){const U=x+G,H=w+G,ne=c[U],ge=c[U+3],Pe=c[H],ve=c[H+3];c[l+G]=ne<Pe?ne:Pe,c[l+G+3]=ge>ve?ge:ve}return z}}}function yc(s,e,t,r,n,o,i){Me.setBuffer(s._roots[e]),yi(0,s,t,r,n,o,i),Me.clearBuffer()}function yi(s,e,t,r,n,o,i){const{float32Array:a,uint16Array:c,uint32Array:u}=Me,d=s*2;if(Ye(d,c)){const l=Xe(s,u),v=Je(d,c);sc(e,t,r,l,v,n,o,i)}else{const l=at(s);Ut(l,a,r,o,i)&&yi(l,e,t,r,n,o,i);const v=He(s,u);Ut(v,a,r,o,i)&&yi(v,e,t,r,n,o,i)}}const bc=["x","y","z"];function xc(s,e,t,r,n,o){Me.setBuffer(s._roots[e]);const i=bi(0,s,t,r,n,o);return Me.clearBuffer(),i}function bi(s,e,t,r,n,o){const{float32Array:i,uint16Array:a,uint32Array:c}=Me;let u=s*2;if(Ye(u,a)){const h=Xe(s,c),l=Je(u,a);return oc(e,t,r,h,l,n,o)}else{const h=oi(s,c),l=bc[h],b=r.direction[l]>=0;let T,g;b?(T=at(s),g=He(s,c)):(T=He(s,c),g=at(s));const w=Ut(T,i,r,n,o)?bi(T,e,t,r,n,o):null;if(w){const P=w.point[l];if(b?P<=i[g+h]:P>=i[g+h+3])return w}const A=Ut(g,i,r,n,o)?bi(g,e,t,r,n,o):null;return w&&A?w.distance<=A.distance?w:A:w||A||null}}const Cn=new f.Box3,br=new mt,xr=new mt,jr=new f.Matrix4,Ss=new Ze,Pn=new Ze;function wc(s,e,t,r){Me.setBuffer(s._roots[e]);const n=xi(0,s,t,r);return Me.clearBuffer(),n}function xi(s,e,t,r,n=null){const{float32Array:o,uint16Array:i,uint32Array:a}=Me;let c=s*2;if(n===null&&(t.boundingBox||t.computeBoundingBox(),Ss.set(t.boundingBox.min,t.boundingBox.max,r),n=Ss),Ye(c,i)){const d=e.geometry,h=d.index,l=d.attributes.position,v=t.index,b=t.attributes.position,T=Xe(s,a),g=Je(c,i);if(jr.copy(r).invert(),t.boundsTree)return Fe(s,o,Pn),Pn.matrix.copy(jr),Pn.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>Pn.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(r),w.b.applyMatrix4(r),w.c.applyMatrix4(r),w.needsUpdate=!0;for(let S=T,A=g+T;S<A;S++)if(Oe(xr,3*e.resolveTriangleIndex(S),h,l),xr.needsUpdate=!0,w.intersectsTriangle(xr))return!0;return!1}});for(let x=T,w=g+T;x<w;x++){const S=e.resolveTriangleIndex(x);Oe(br,3*S,h,l),br.a.applyMatrix4(jr),br.b.applyMatrix4(jr),br.c.applyMatrix4(jr),br.needsUpdate=!0;for(let A=0,P=v.count;A<P;A+=3)if(Oe(xr,A,v,b),xr.needsUpdate=!0,br.intersectsTriangle(xr))return!0}}else{const d=s+8,h=a[s+6];return Fe(d,o,Cn),!!(n.intersectsBox(Cn)&&xi(d,e,t,r,n)||(Fe(h,o,Cn),n.intersectsBox(Cn)&&xi(h,e,t,r,n)))}}const Dn=new f.Matrix4,wi=new Ze,Wr=new Ze,_c=new f.Vector3,Tc=new f.Vector3,Sc=new f.Vector3,Ac=new f.Vector3;function Mc(s,e,t,r={},n={},o=0,i=1/0){e.boundingBox||e.computeBoundingBox(),wi.set(e.boundingBox.min,e.boundingBox.max,t),wi.needsUpdate=!0;const a=s.geometry,c=a.attributes.position,u=a.index,d=e.attributes.position,h=e.index,l=ct.getPrimitive(),v=ct.getPrimitive();let b=_c,T=Tc,g=null,x=null;n&&(g=Sc,x=Ac);let w=1/0,S=null,A=null;return Dn.copy(t).invert(),Wr.matrix.copy(Dn),s.shapecast({boundsTraverseOrder:P=>wi.distanceToBox(P),intersectsBounds:(P,D,F)=>F<w&&F<i?(D&&(Wr.min.copy(P.min),Wr.max.copy(P.max),Wr.needsUpdate=!0),!0):!1,intersectsRange:(P,D)=>{if(e.boundsTree){const F=e.boundsTree;return F.shapecast({boundsTraverseOrder:O=>Wr.distanceToBox(O),intersectsBounds:(O,L,E)=>E<w&&E<i,intersectsRange:(O,L)=>{for(let E=O,V=O+L;E<V;E++){const z=F.resolveTriangleIndex(E);Oe(v,3*z,h,d),v.a.applyMatrix4(t),v.b.applyMatrix4(t),v.c.applyMatrix4(t),v.needsUpdate=!0;for(let G=P,U=P+D;G<U;G++){const H=s.resolveTriangleIndex(G);Oe(l,3*H,u,c),l.needsUpdate=!0;const ne=l.distanceToTriangle(v,b,g);if(ne<w&&(T.copy(b),x&&x.copy(g),w=ne,S=G,A=E),ne<o)return!0}}}})}else{const F=hr(e);for(let O=0,L=F;O<L;O++){Oe(v,3*O,h,d),v.a.applyMatrix4(t),v.b.applyMatrix4(t),v.c.applyMatrix4(t),v.needsUpdate=!0;for(let E=P,V=P+D;E<V;E++){const z=s.resolveTriangleIndex(E);Oe(l,3*z,u,c),l.needsUpdate=!0;const G=l.distanceToTriangle(v,b,g);if(G<w&&(T.copy(b),x&&x.copy(g),w=G,S=E,A=O),G<o)return!0}}}}}),ct.releasePrimitive(l),ct.releasePrimitive(v),w===1/0?null:(r.point?r.point.copy(T):r.point=T.clone(),r.distance=w,r.faceIndex=S,n&&(n.point?n.point.copy(x):n.point=x.clone(),n.point.applyMatrix4(Dn),T.applyMatrix4(Dn),n.distance=T.sub(n.point).length(),n.faceIndex=A),r)}function Ic(){return typeof SharedArrayBuffer<"u"}const Yr=new Me.constructor,Rn=new Me.constructor,Vt=new hi(()=>new f.Box3),wr=new f.Box3,_r=new f.Box3,_i=new f.Box3,Ti=new f.Box3;let Si=!1;function Cc(s,e,t,r){if(Si)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Si=!0;const n=s._roots,o=e._roots;let i,a=0,c=0;const u=new f.Matrix4().copy(t).invert();for(let d=0,h=n.length;d<h;d++){Yr.setBuffer(n[d]),c=0;const l=Vt.getPrimitive();Fe(0,Yr.float32Array,l),l.applyMatrix4(u);for(let v=0,b=o.length;v<b&&(Rn.setBuffer(o[v]),i=gt(0,0,t,u,r,a,c,0,0,l),Rn.clearBuffer(),c+=o[v].length,!i);v++);if(Vt.releasePrimitive(l),Yr.clearBuffer(),a+=n[d].length,i)break}return Si=!1,i}function gt(s,e,t,r,n,o=0,i=0,a=0,c=0,u=null,d=!1){let h,l;d?(h=Rn,l=Yr):(h=Yr,l=Rn);const v=h.float32Array,b=h.uint32Array,T=h.uint16Array,g=l.float32Array,x=l.uint32Array,w=l.uint16Array,S=s*2,A=e*2,P=Ye(S,T),D=Ye(A,w);let F=!1;if(D&&P)d?F=n(Xe(e,x),Je(e*2,w),Xe(s,b),Je(s*2,T),c,i+e,a,o+s):F=n(Xe(s,b),Je(s*2,T),Xe(e,x),Je(e*2,w),a,o+s,c,i+e);else if(D){const O=Vt.getPrimitive();Fe(e,g,O),O.applyMatrix4(t);const L=at(s),E=He(s,b);Fe(L,v,wr),Fe(E,v,_r);const V=O.intersectsBox(wr),z=O.intersectsBox(_r);F=V&>(e,L,r,t,n,i,o,c,a+1,O,!d)||z&>(e,E,r,t,n,i,o,c,a+1,O,!d),Vt.releasePrimitive(O)}else{const O=at(e),L=He(e,x);Fe(O,g,_i),Fe(L,g,Ti);const E=u.intersectsBox(_i),V=u.intersectsBox(Ti);if(E&&V)F=gt(s,O,t,r,n,o,i,a,c+1,u,d)||gt(s,L,t,r,n,o,i,a,c+1,u,d);else if(E)if(P)F=gt(s,O,t,r,n,o,i,a,c+1,u,d);else{const z=Vt.getPrimitive();z.copy(_i).applyMatrix4(t);const G=at(s),U=He(s,b);Fe(G,v,wr),Fe(U,v,_r);const H=z.intersectsBox(wr),ne=z.intersectsBox(_r);F=H&>(O,G,r,t,n,i,o,c,a+1,z,!d)||ne&>(O,U,r,t,n,i,o,c,a+1,z,!d),Vt.releasePrimitive(z)}else if(V)if(P)F=gt(s,L,t,r,n,o,i,a,c+1,u,d);else{const z=Vt.getPrimitive();z.copy(Ti).applyMatrix4(t);const G=at(s),U=He(s,b);Fe(G,v,wr),Fe(U,v,_r);const H=z.intersectsBox(wr),ne=z.intersectsBox(_r);F=H&>(L,G,r,t,n,i,o,c,a+1,z,!d)||ne&>(L,U,r,t,n,i,o,c,a+1,z,!d),Vt.releasePrimitive(z)}}return F}const Fn=new Ze,As=new f.Box3,Pc={strategy:as,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Ai{static serialize(e,t={}){t={cloneBuffers:!0,...t};const r=e.geometry,n=e._roots,o=e._indirectBuffer,i=r.getIndex();let a;return t.cloneBuffers?a={roots:n.map(c=>c.slice()),index:i?i.array.slice():null,indirectBuffer:o?o.slice():null}:a={roots:n,index:i?i.array:null,indirectBuffer:o},a}static deserialize(e,t,r={}){r={setIndex:!0,indirect:!!e.indirectBuffer,...r};const{index:n,roots:o,indirectBuffer:i}=e,a=new Ai(t,{...r,[ni]:!0});if(a._roots=o,a._indirectBuffer=i||null,r.setIndex){const c=t.getIndex();if(c===null){const u=new f.BufferAttribute(e.index,1,!1);t.setIndex(u)}else c.array!==n&&(c.array.set(n),c.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Pc,[ni]:!1},t),t.useSharedArrayBuffer&&!Ic())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[ni]||(Ya(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new f.Box3))),this.resolveTriangleIndex=t.indirect?r=>this._indirectBuffer[r]:r=>r}refit(e=null){return(this.indirect?vc:ic)(this,e)}traverse(e,t=0){const r=this._roots[t],n=new Uint32Array(r),o=new Uint16Array(r);i(0);function i(a,c=0){const u=a*2,d=o[u+15]===mn;if(d){const h=n[a+6],l=o[u+14];e(c,d,new Float32Array(r,a*4,6),h,l)}else{const h=a+Bt/4,l=n[a+6],v=n[a+7];e(c,d,new Float32Array(r,a*4,6),v)||(i(h,c+1),i(l,c+1))}}}raycast(e,t=f.FrontSide,r=0,n=1/0){const o=this._roots,i=this.geometry,a=[],c=t.isMaterial,u=Array.isArray(t),d=i.groups,h=c?t.side:t,l=this.indirect?yc:cc;for(let v=0,b=o.length;v<b;v++){const T=u?t[d[v].materialIndex].side:h,g=a.length;if(l(this,v,T,e,a,r,n),u){const x=d[v].materialIndex;for(let w=g,S=a.length;w<S;w++)a[w].face.materialIndex=x}}return a}raycastFirst(e,t=f.FrontSide,r=0,n=1/0){const o=this._roots,i=this.geometry,a=t.isMaterial,c=Array.isArray(t);let u=null;const d=i.groups,h=a?t.side:t,l=this.indirect?xc:uc;for(let v=0,b=o.length;v<b;v++){const T=c?t[d[v].materialIndex].side:h,g=l(this,v,T,e,r,n);g!=null&&(u==null||g.distance<u.distance)&&(u=g,c&&(g.face.materialIndex=d[v].materialIndex))}return u}intersectsGeometry(e,t){let r=!1;const n=this._roots,o=this.indirect?wc:hc;for(let i=0,a=n.length;i<a&&(r=o(this,i,e,t),!r);i++);return r}shapecast(e){const t=ct.getPrimitive(),r=this.indirect?ac:nc;let{boundsTraverseOrder:n,intersectsBounds:o,intersectsRange:i,intersectsTriangle:a}=e;if(i&&a){const h=i;i=(l,v,b,T,g)=>h(l,v,b,T,g)?!0:r(l,v,this,a,b,T,t)}else i||(a?i=(h,l,v,b)=>r(h,l,this,a,v,b,t):i=(h,l,v)=>v);let c=!1,u=0;const d=this._roots;for(let h=0,l=d.length;h<l;h++){const v=d[h];if(c=Qa(this,h,o,i,n,u),c)break;u+=v.byteLength}return ct.releasePrimitive(t),c}bvhcast(e,t,r){let{intersectsRanges:n,intersectsTriangles:o}=r;const i=ct.getPrimitive(),a=this.geometry.index,c=this.geometry.attributes.position,u=this.indirect?b=>{const T=this.resolveTriangleIndex(b);Oe(i,T*3,a,c)}:b=>{Oe(i,b*3,a,c)},d=ct.getPrimitive(),h=e.geometry.index,l=e.geometry.attributes.position,v=e.indirect?b=>{const T=e.resolveTriangleIndex(b);Oe(d,T*3,h,l)}:b=>{Oe(d,b*3,h,l)};if(o){const b=(T,g,x,w,S,A,P,D)=>{for(let F=x,O=x+w;F<O;F++){v(F),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let L=T,E=T+g;L<E;L++)if(u(L),i.needsUpdate=!0,o(i,d,L,F,S,A,P,D))return!0}return!1};if(n){const T=n;n=function(g,x,w,S,A,P,D,F){return T(g,x,w,S,A,P,D,F)?!0:b(g,x,w,S,A,P,D,F)}}else n=b}return Cc(this,e,t,n)}intersectsBox(e,t){return Fn.set(e.min,e.max,t),Fn.needsUpdate=!0,this.shapecast({intersectsBounds:r=>Fn.intersectsBox(r),intersectsTriangle:r=>Fn.intersectsTriangle(r)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,r={},n={},o=0,i=1/0){return(this.indirect?Mc:gc)(this,e,t,r,n,o,i)}closestPointToPoint(e,t={},r=0,n=1/0){return Ja(this,e,t,r,n)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(r=>{Fe(0,new Float32Array(r),As),e.union(As)}),e}}function Dc(s){switch(s){case 1:return"R";case 2:return"RG";case 3:return"RGBA";case 4:return"RGBA"}throw new Error}function Rc(s){switch(s){case 1:return f.RedFormat;case 2:return f.RGFormat;case 3:return f.RGBAFormat;case 4:return f.RGBAFormat}}function Ms(s){switch(s){case 1:return f.RedIntegerFormat;case 2:return f.RGIntegerFormat;case 3:return f.RGBAIntegerFormat;case 4:return f.RGBAIntegerFormat}}class Is extends f.DataTexture{constructor(){super(),this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.generateMipmaps=!1,this.overrideItemSize=null,this._forcedType=null}updateFrom(e){const t=this.overrideItemSize,r=e.itemSize,n=e.count;if(t!==null){if(r*n%t!==0)throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");e.itemSize=t,e.count=n*r/t}const o=e.itemSize,i=e.count,a=e.normalized,c=e.array.constructor,u=c.BYTES_PER_ELEMENT;let d=this._forcedType,h=o;if(d===null)switch(c){case Float32Array:d=f.FloatType;break;case Uint8Array:case Uint16Array:case Uint32Array:d=f.UnsignedIntType;break;case Int8Array:case Int16Array:case Int32Array:d=f.IntType;break}let l,v,b,T,g=Dc(o);switch(d){case f.FloatType:b=1,v=Rc(o),a&&u===1?(T=c,g+="8",c===Uint8Array?l=f.UnsignedByteType:(l=f.ByteType,g+="_SNORM")):(T=Float32Array,g+="32F",l=f.FloatType);break;case f.IntType:g+=u*8+"I",b=a?Math.pow(2,c.BYTES_PER_ELEMENT*8-1):1,v=Ms(o),u===1?(T=Int8Array,l=f.ByteType):u===2?(T=Int16Array,l=f.ShortType):(T=Int32Array,l=f.IntType);break;case f.UnsignedIntType:g+=u*8+"UI",b=a?Math.pow(2,c.BYTES_PER_ELEMENT*8-1):1,v=Ms(o),u===1?(T=Uint8Array,l=f.UnsignedByteType):u===2?(T=Uint16Array,l=f.UnsignedShortType):(T=Uint32Array,l=f.UnsignedIntType);break}h===3&&(v===f.RGBAFormat||v===f.RGBAIntegerFormat)&&(h=4);const x=Math.ceil(Math.sqrt(i))||1,w=h*x*x,S=new T(w),A=e.normalized;e.normalized=!1;for(let P=0;P<i;P++){const D=h*P;S[D]=e.getX(P)/b,o>=2&&(S[D+1]=e.getY(P)/b),o>=3&&(S[D+2]=e.getZ(P)/b,h===4&&(S[D+3]=1)),o>=4&&(S[D+3]=e.getW(P)/b)}e.normalized=A,this.internalFormat=g,this.format=v,this.type=l,this.image.width=x,this.image.height=x,this.image.data=S,this.needsUpdate=!0,this.dispose(),e.itemSize=r,e.count=n}}class Cs extends Is{constructor(){super(),this._forcedType=f.UnsignedIntType}}class Ps extends Is{constructor(){super(),this._forcedType=f.FloatType}}class Fc{constructor(){this.index=new Cs,this.position=new Ps,this.bvhBounds=new f.DataTexture,this.bvhContents=new f.DataTexture,this._cachedIndexAttr=null,this.index.overrideItemSize=3}updateFrom(e){const{geometry:t}=e;if(Lc(e,this.bvhBounds,this.bvhContents),this.position.updateFrom(t.attributes.position),e.indirect){const r=e._indirectBuffer;if(this._cachedIndexAttr===null||this._cachedIndexAttr.count!==r.length)if(t.index)this._cachedIndexAttr=t.index.clone();else{const n=fs(hs(t));this._cachedIndexAttr=new f.BufferAttribute(n,1,!1)}Oc(t,r,this._cachedIndexAttr),this.index.updateFrom(this._cachedIndexAttr)}else this.index.updateFrom(t.index)}dispose(){const{index:e,position:t,bvhBounds:r,bvhContents:n}=this;e&&e.dispose(),t&&t.dispose(),r&&r.dispose(),n&&n.dispose()}}function Oc(s,e,t){const r=t.array,n=s.index?s.index.array:null;for(let o=0,i=e.length;o<i;o++){const a=3*o,c=3*e[o];for(let u=0;u<3;u++)r[a+u]=n?n[c+u]:c+u}}function Lc(s,e,t){const r=s._roots;if(r.length!==1)throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");const n=r[0],o=new Uint16Array(n),i=new Uint32Array(n),a=new Float32Array(n),c=n.byteLength/Bt,u=2*Math.ceil(Math.sqrt(c/2)),d=new Float32Array(4*u*u),h=Math.ceil(Math.sqrt(c)),l=new Uint32Array(2*h*h);for(let v=0;v<c;v++){const b=v*Bt/4,T=b*2,g=b;for(let x=0;x<3;x++)d[8*v+0+x]=a[g+0+x],d[8*v+4+x]=a[g+3+x];if(Ye(T,o)){const x=Je(T,o),w=Xe(b,i),S=4294901760|x;l[v*2+0]=S,l[v*2+1]=w}else{const x=4*He(b,i)/Bt,w=oi(b,i);l[v*2+0]=w,l[v*2+1]=x}}e.image.data=d,e.image.width=u,e.image.height=u,e.format=f.RGBAFormat,e.type=f.FloatType,e.internalFormat="RGBA32F",e.minFilter=f.NearestFilter,e.magFilter=f.NearestFilter,e.generateMipmaps=!1,e.needsUpdate=!0,e.dispose(),t.image.data=l,t.image.width=h,t.image.height=h,t.format=f.RGIntegerFormat,t.type=f.UnsignedIntType,t.internalFormat="RG32UI",t.minFilter=f.NearestFilter,t.magFilter=f.NearestFilter,t.generateMipmaps=!1,t.needsUpdate=!0,t.dispose()}const Nc=`
|
|
60
31
|
|
|
61
32
|
// A stack of uint32 indices can can store the indices for
|
|
62
33
|
// a perfectly balanced tree with a depth up to 31. Lower stack
|
|
@@ -138,7 +109,7 @@ void ndcToCameraRay(
|
|
|
138
109
|
rayDirection = direction.xyz;
|
|
139
110
|
|
|
140
111
|
}
|
|
141
|
-
`,
|
|
112
|
+
`,kc=`
|
|
142
113
|
|
|
143
114
|
#ifndef TRI_INTERSECT_EPSILON
|
|
144
115
|
#define TRI_INTERSECT_EPSILON 1e-5
|
|
@@ -342,7 +313,7 @@ bool _bvhIntersectFirstHit(
|
|
|
342
313
|
return found;
|
|
343
314
|
|
|
344
315
|
}
|
|
345
|
-
`,
|
|
316
|
+
`,Bc=`
|
|
346
317
|
struct BVH {
|
|
347
318
|
|
|
348
319
|
usampler2D index;
|
|
@@ -352,7 +323,7 @@ struct BVH {
|
|
|
352
323
|
usampler2D bvhContents;
|
|
353
324
|
|
|
354
325
|
};
|
|
355
|
-
`;function ul(o,e,n=0){if(o.isInterleavedBufferAttribute){const i=o.itemSize;for(let s=0,c=o.count;s<c;s++){const a=s+n;e.setX(a,o.getX(s)),i>=2&&e.setY(a,o.getY(s)),i>=3&&e.setZ(a,o.getZ(s)),i>=4&&e.setW(a,o.getW(s))}}else{const i=e.array,s=i.constructor,c=i.BYTES_PER_ELEMENT*o.itemSize*n;new s(i.buffer,c,o.array.length).set(o.array)}}function Ei(o,e=null){const n=o.array.constructor,i=o.normalized,s=o.itemSize,c=e===null?o.count:e;return new m.BufferAttribute(new n(s*c),s,i)}function Zr(o,e){if(!o&&!e)return!0;if(!!o!=!!e)return!1;const n=o.count===e.count,i=o.normalized===e.normalized,s=o.array.constructor===e.array.constructor,c=o.itemSize===e.itemSize;return!(!n||!i||!s||!c)}function Gp(o){const e=o[0].index!==null,n=new Set(Object.keys(o[0].attributes));if(!o[0].getAttribute("position"))throw new Error("StaticGeometryGenerator: position attribute is required.");for(let i=0;i<o.length;++i){const s=o[i];let c=0;if(e!==(s.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const a in s.attributes){if(!n.has(a))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+a+'" attribute exists among all geometries, or in none of them.');c++}if(c!==n.size)throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.")}}function Wp(o){let e=0;for(let n=0,i=o.length;n<i;n++)e+=o[n].getIndex().count;return e}function Vp(o){let e=0;for(let n=0,i=o.length;n<i;n++)e+=o[n].getAttribute("position").count;return e}function jp(o,e,n){o.index&&o.index.count!==e&&o.setIndex(null);const i=o.attributes;for(const s in i)i[s].count!==n&&o.deleteAttribute(s)}function qp(o,e={},n=new m.BufferGeometry){const{useGroups:i=!1,forceUpdate:s=!1,skipAssigningAttributes:c=[],overwriteIndex:a=!0}=e;Gp(o);const u=o[0].index!==null,f=u?Wp(o):-1,p=Vp(o);if(jp(n,f,p),i){let g=0;for(let h=0,b=o.length;h<b;h++){const R=o[h];let M;u?M=R.getIndex().count:M=R.getAttribute("position").count,n.addGroup(g,M,h),g+=M}}if(u){let g=!1;if(n.index||(n.setIndex(new m.BufferAttribute(new Uint32Array(f),1,!1)),g=!0),g||a){let h=0,b=0;const R=n.getIndex();for(let M=0,x=o.length;M<x;M++){const A=o[M],E=A.getIndex();if(!(!s&&!g&&c[M]))for(let P=0;P<E.count;++P)R.setX(h+P,E.getX(P)+b);h+=E.count,b+=A.getAttribute("position").count}}}const v=Object.keys(o[0].attributes);for(let g=0,h=v.length;g<h;g++){let b=!1;const R=v[g];if(!n.getAttribute(R)){const A=o[0].getAttribute(R);n.setAttribute(R,Ei(A,p)),b=!0}let M=0;const x=n.getAttribute(R);for(let A=0,E=o.length;A<E;A++){const C=o[A],P=!s&&!b&&c[A],O=C.getAttribute(R);P||ul(O,x,M),M+=O.count}}}function Yp(o,e,n){const i=o.index,c=o.attributes.position.count,a=i?i.count:c;let u=o.groups;u.length===0&&(u=[{count:a,start:0,materialIndex:0}]);let f=o.getAttribute("materialIndex");if(!f||f.count!==c){let v;n.length<=255?v=new Uint8Array(c):v=new Uint16Array(c),f=new m.BufferAttribute(v,1,!1),o.deleteAttribute("materialIndex"),o.setAttribute("materialIndex",f)}const p=f.array;for(let v=0;v<u.length;v++){const g=u[v],h=g.start,b=g.count,R=Math.min(b,a-h),M=Array.isArray(e)?e[g.materialIndex]:e,x=n.indexOf(M);for(let A=0;A<R;A++){let E=h+A;i&&(E=i.getX(E)),p[E]=x}}}function Kp(o,e){if(!o.index){const n=o.attributes.position.count,i=new Array(n);for(let s=0;s<n;s++)i[s]=s;o.setIndex(i)}if(!o.attributes.normal&&e&&e.includes("normal")&&o.computeVertexNormals(),!o.attributes.uv&&e&&e.includes("uv")){const n=o.attributes.position.count;o.setAttribute("uv",new m.BufferAttribute(new Float32Array(n*2),2,!1))}if(!o.attributes.uv2&&e&&e.includes("uv2")){const n=o.attributes.position.count;o.setAttribute("uv2",new m.BufferAttribute(new Float32Array(n*2),2,!1))}if(!o.attributes.tangent&&e&&e.includes("tangent"))if(o.attributes.uv&&o.attributes.normal)o.computeTangents();else{const n=o.attributes.position.count;o.setAttribute("tangent",new m.BufferAttribute(new Float32Array(n*4),4,!1))}if(!o.attributes.color&&e&&e.includes("color")){const n=o.attributes.position.count,i=new Float32Array(n*4);i.fill(1),o.setAttribute("color",new m.BufferAttribute(i,4))}}function $a(o){let e=0;if(o.byteLength!==0){const n=new Uint8Array(o);for(let i=0;i<o.byteLength;i++){const s=n[i];e=(e<<5)-e+s,e|=0}}return e}function fl(o){let e=o.uuid;const n=Object.values(o.attributes);o.index&&(n.push(o.index),e+=`index|${o.index.version}`);const i=Object.keys(n).sort();for(const s of i){const c=n[s];e+=`${s}_${c.version}|`}return e}function hl(o){const e=o.skeleton;return e?(e.boneTexture||e.computeBoneTexture(),`${$a(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`):null}class Xp{constructor(e=null){this.matrixWorld=new m.Matrix4,this.geometryHash=null,this.skeletonHash=null,this.primitiveCount=-1,e!==null&&this.updateFrom(e)}updateFrom(e){const n=e.geometry,i=(n.index?n.index.count:n.attributes.position.count)/3;this.matrixWorld.copy(e.matrixWorld),this.geometryHash=fl(n),this.primitiveCount=i,this.skeletonHash=hl(e)}didChange(e){const n=e.geometry,i=(n.index?n.index.count:n.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===fl(n)&&this.skeletonHash===hl(e)&&this.primitiveCount===i)}}const cr=new m.Vector3,lr=new m.Vector3,ur=new m.Vector3,dl=new m.Vector4,Ts=new m.Vector3,Qa=new m.Vector3,pl=new m.Vector4,ml=new m.Vector4,ws=new m.Matrix4,gl=new m.Matrix4;function vl(o,e,n){const i=o.skeleton,s=o.geometry,c=i.bones,a=i.boneInverses;pl.fromBufferAttribute(s.attributes.skinIndex,e),ml.fromBufferAttribute(s.attributes.skinWeight,e),ws.elements.fill(0);for(let u=0;u<4;u++){const f=ml.getComponent(u);if(f!==0){const p=pl.getComponent(u);gl.multiplyMatrices(c[p].matrixWorld,a[p]),Zp(ws,gl,f)}}return ws.multiply(o.bindMatrix).premultiply(o.bindMatrixInverse),n.transformDirection(ws),n}function Ja(o,e,n,i,s){Ts.set(0,0,0);for(let c=0,a=o.length;c<a;c++){const u=e[c],f=o[c];u!==0&&(Qa.fromBufferAttribute(f,i),n?Ts.addScaledVector(Qa,u):Ts.addScaledVector(Qa.sub(s),u))}s.add(Ts)}function Zp(o,e,n){const i=o.elements,s=e.elements;for(let c=0,a=s.length;c<a;c++)i[c]+=s[c]*n}function $p(o){const{index:e,attributes:n}=o;if(e)for(let i=0,s=e.count;i<s;i+=3){const c=e.getX(i),a=e.getX(i+2);e.setX(i,a),e.setX(i+2,c)}else for(const i in n){const s=n[i],c=s.itemSize;for(let a=0,u=s.count;a<u;a+=3)for(let f=0;f<c;f++){const p=s.getComponent(a,f),v=s.getComponent(a+2,f);s.setComponent(a,f,v),s.setComponent(a+2,f,p)}}return o}function Qp(o,e={},n=new m.BufferGeometry){e={applyWorldTransforms:!0,attributes:[],...e};const i=o.geometry,s=e.applyWorldTransforms,c=e.attributes.includes("normal"),a=e.attributes.includes("tangent"),u=i.attributes,f=n.attributes;for(const E in n.attributes)(!e.attributes.includes(E)||!(E in i.attributes))&&n.deleteAttribute(E);!n.index&&i.index&&(n.index=i.index.clone()),f.position||n.setAttribute("position",Ei(u.position)),c&&!f.normal&&u.normal&&n.setAttribute("normal",Ei(u.normal)),a&&!f.tangent&&u.tangent&&n.setAttribute("tangent",Ei(u.tangent)),Zr(i.index,n.index),Zr(u.position,f.position),c&&Zr(u.normal,f.normal),a&&Zr(u.tangent,f.tangent);const p=u.position,v=c?u.normal:null,g=a?u.tangent:null,h=i.morphAttributes.position,b=i.morphAttributes.normal,R=i.morphAttributes.tangent,M=i.morphTargetsRelative,x=o.morphTargetInfluences,A=new m.Matrix3;A.getNormalMatrix(o.matrixWorld),i.index&&n.index.array.set(i.index.array);for(let E=0,C=u.position.count;E<C;E++)cr.fromBufferAttribute(p,E),v&&lr.fromBufferAttribute(v,E),g&&(dl.fromBufferAttribute(g,E),ur.fromBufferAttribute(g,E)),x&&(h&&Ja(h,x,M,E,cr),b&&Ja(b,x,M,E,lr),R&&Ja(R,x,M,E,ur)),o.isSkinnedMesh&&(o.applyBoneTransform(E,cr),v&&vl(o,E,lr),g&&vl(o,E,ur)),s&&cr.applyMatrix4(o.matrixWorld),f.position.setXYZ(E,cr.x,cr.y,cr.z),v&&(s&&lr.applyNormalMatrix(A),f.normal.setXYZ(E,lr.x,lr.y,lr.z)),g&&(s&&ur.transformDirection(o.matrixWorld),f.tangent.setXYZW(E,ur.x,ur.y,ur.z,dl.w));for(const E in e.attributes){const C=e.attributes[E];C==="position"||C==="tangent"||C==="normal"||!(C in u)||(f[C]||n.setAttribute(C,Ei(u[C])),Zr(u[C],f[C]),ul(u[C],f[C]))}return o.matrixWorld.determinant()<0&&$p(n),n}class Jp extends m.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new Xp}isCompatible(e,n){const i=e.geometry;for(let s=0;s<n.length;s++){const c=n[s],a=i.attributes[c],u=this.attributes[c];if(a&&!Zr(a,u))return!1}return!0}updateFrom(e,n){const i=this._diff;return i.didChange(e)?(Qp(e,n,this),i.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}}const eo=0,yl=1,_l=2;function em(o,e){for(let n=0,i=o.length;n<i;n++)o[n].traverseVisible(c=>{c.isMesh&&e(c)})}function tm(o){const e=[];for(let n=0,i=o.length;n<i;n++){const s=o[n];Array.isArray(s.material)?e.push(...s.material):e.push(s.material)}return e}function nm(o,e,n){if(o.length===0){e.setIndex(null);const i=e.attributes;for(const s in i)e.deleteAttribute(s);for(const s in n.attributes)e.setAttribute(n.attributes[s],new m.BufferAttribute(new Float32Array(0),4,!1))}else qp(o,n,e);for(const i in e.attributes)e.attributes[i].needsUpdate=!0}class rm{constructor(e){this.objects=null,this.useGroups=!0,this.applyWorldTransforms=!0,this.generateMissingAttributes=!0,this.overwriteIndex=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Map,this._geometryMergeSets=new WeakMap,this._mergeOrder=[],this._dummyMesh=null,this.setObjects(e||[])}_getDummyMesh(){if(!this._dummyMesh){const e=new m.MeshBasicMaterial,n=new m.BufferGeometry;n.setAttribute("position",new m.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new m.Mesh(n,e)}return this._dummyMesh}_getMeshes(){const e=[];return em(this.objects,n=>{e.push(n)}),e.sort((n,i)=>n.uuid>i.uuid?1:n.uuid<i.uuid?-1:0),e.length===0&&e.push(this._getDummyMesh()),e}_updateIntermediateGeometries(){const{_intermediateGeometry:e}=this,n=this._getMeshes(),i=new Set(e.keys()),s={attributes:this.attributes,applyWorldTransforms:this.applyWorldTransforms};for(let c=0,a=n.length;c<a;c++){const u=n[c],f=u.uuid;i.delete(f);let p=e.get(f);(!p||!p.isCompatible(u,this.attributes))&&(p&&p.dispose(),p=new Jp,e.set(f,p)),p.updateFrom(u,s)&&this.generateMissingAttributes&&Kp(p,this.attributes)}i.forEach(c=>{e.delete(c)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new m.BufferGeometry){const{useGroups:n,overwriteIndex:i,_intermediateGeometry:s,_geometryMergeSets:c}=this,a=this._getMeshes(),u=[],f=[],p=c.get(e)||[];this._updateIntermediateGeometries();let v=!1;a.length!==p.length&&(v=!0);for(let h=0,b=a.length;h<b;h++){const R=a[h],M=s.get(R.uuid);f.push(M);const x=p[h];!x||x.uuid!==M.uuid?(u.push(!1),v=!0):x.version!==M.version?u.push(!1):u.push(!0)}nm(f,e,{useGroups:n,forceUpdate:v,skipAssigningAttributes:u,overwriteIndex:i}),v&&e.dispose(),c.set(e,f.map(h=>({version:h.version,uuid:h.uuid})));let g=eo;return v?g=_l:u.includes(!1)&&(g=yl),{changeType:g,materials:tm(a),geometry:e}}}function im(o){const e=new Set;for(let n=0,i=o.length;n<i;n++){const s=o[n];for(const c in s){const a=s[c];a&&a.isTexture&&e.add(a)}}return Array.from(e)}function sm(o){const e=[],n=new Set;for(let s=0,c=o.length;s<c;s++)o[s].traverse(a=>{a.visible&&(a.isRectAreaLight||a.isSpotLight||a.isPointLight||a.isDirectionalLight)&&(e.push(a),a.iesMap&&n.add(a.iesMap))});const i=Array.from(n).sort((s,c)=>s.uuid<c.uuid?1:s.uuid>c.uuid?-1:0);return{lights:e,iesTextures:i}}class am{get initialized(){return!!this.bvh}constructor(e){this.bvhOptions={},this.attributes=["position","normal","tangent","color","uv","uv2"],this.generateBVH=!0,this.bvh=null,this.geometry=new m.BufferGeometry,this.staticGeometryGenerator=new rm(e),this._bvhWorker=null,this._pendingGenerate=null,this._buildAsync=!1}setObjects(e){this.staticGeometryGenerator.setObjects(e)}setBVHWorker(e){this._bvhWorker=e}async generateAsync(e=null){if(!this._bvhWorker)throw new Error('PathTracingSceneGenerator: "setBVHWorker" must be called before "generateAsync" can be called.');if(this.bvh instanceof Promise)return this._pendingGenerate||(this._pendingGenerate=new Promise(async()=>(await this.bvh,this._pendingGenerate=null,this.generateAsync(e)))),this._pendingGenerate;{this._buildAsync=!0;const n=this.generate(e);return this._buildAsync=!1,n.bvh=this.bvh=await n.bvh,n}}generate(e=null){const{staticGeometryGenerator:n,geometry:i,attributes:s}=this,c=n.objects;n.attributes=s,c.forEach(g=>{g.traverse(h=>{h.isSkinnedMesh&&h.skeleton&&h.skeleton.update()})});const a=n.generate(i),u=a.materials,f=im(u),{lights:p,iesTextures:v}=sm(c);if(a.changeType!==eo&&Yp(i,u,u),this.generateBVH){if(this.bvh instanceof Promise)throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");if(a.changeType===_l){const g={strategy:Gc,maxLeafTris:1,indirect:!0,onProgress:e,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(i,g):this.bvh=new Za(i,g)}else a.changeType===yl&&this.bvh.refit()}return{bvhChanged:a.changeType!==eo,bvh:this.bvh,lights:p,iesTextures:v,geometry:i,materials:u,textures:f,objects:c}}}const om=new m.OrthographicCamera(-1,1,1,-1,0,1);class cm extends m.BufferGeometry{constructor(){super(),this.setAttribute("position",new m.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new m.Float32BufferAttribute([0,2,0,0,2,0],2))}}const lm=new cm;class fr{constructor(e){this._mesh=new m.Mesh(lm,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,om)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Rs extends m.ShaderMaterial{set needsUpdate(e){super.needsUpdate=!0,this.dispatchEvent({type:"recompilation"})}constructor(e){super(e);for(const n in this.uniforms)Object.defineProperty(this,n,{get(){return this.uniforms[n].value},set(i){this.uniforms[n].value=i}})}setDefine(e,n=void 0){if(n==null){if(e in this.defines)return delete this.defines[e],this.needsUpdate=!0,!0}else if(this.defines[e]!==n)return this.defines[e]=n,this.needsUpdate=!0,!0;return!1}}class um extends Rs{constructor(e){super({blending:m.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
|
|
326
|
+
`;function Ds(s,e,t=0){if(s.isInterleavedBufferAttribute){const r=s.itemSize;for(let n=0,o=s.count;n<o;n++){const i=n+t;e.setX(i,s.getX(n)),r>=2&&e.setY(i,s.getY(n)),r>=3&&e.setZ(i,s.getZ(n)),r>=4&&e.setW(i,s.getW(n))}}else{const r=e.array,n=r.constructor,o=r.BYTES_PER_ELEMENT*s.itemSize*t;new n(r.buffer,o,s.array.length).set(s.array)}}function Zr(s,e=null){const t=s.array.constructor,r=s.normalized,n=s.itemSize,o=e===null?s.count:e;return new f.BufferAttribute(new t(n*o),n,r)}function Tr(s,e){if(!s&&!e)return!0;if(!!s!=!!e)return!1;const t=s.count===e.count,r=s.normalized===e.normalized,n=s.array.constructor===e.array.constructor,o=s.itemSize===e.itemSize;return!(!t||!r||!n||!o)}function zc(s){const e=s[0].index!==null,t=new Set(Object.keys(s[0].attributes));if(!s[0].getAttribute("position"))throw new Error("StaticGeometryGenerator: position attribute is required.");for(let r=0;r<s.length;++r){const n=s[r];let o=0;if(e!==(n.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const i in n.attributes){if(!t.has(i))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+i+'" attribute exists among all geometries, or in none of them.');o++}if(o!==t.size)throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.")}}function Ec(s){let e=0;for(let t=0,r=s.length;t<r;t++)e+=s[t].getIndex().count;return e}function Uc(s){let e=0;for(let t=0,r=s.length;t<r;t++)e+=s[t].getAttribute("position").count;return e}function Vc(s,e,t){s.index&&s.index.count!==e&&s.setIndex(null);const r=s.attributes;for(const n in r)r[n].count!==t&&s.deleteAttribute(n)}function Gc(s,e={},t=new f.BufferGeometry){const{useGroups:r=!1,forceUpdate:n=!1,skipAssigningAttributes:o=[],overwriteIndex:i=!0}=e;zc(s);const a=s[0].index!==null,c=a?Ec(s):-1,u=Uc(s);if(Vc(t,c,u),r){let h=0;for(let l=0,v=s.length;l<v;l++){const b=s[l];let T;a?T=b.getIndex().count:T=b.getAttribute("position").count,t.addGroup(h,T,l),h+=T}}if(a){let h=!1;if(t.index||(t.setIndex(new f.BufferAttribute(new Uint32Array(c),1,!1)),h=!0),h||i){let l=0,v=0;const b=t.getIndex();for(let T=0,g=s.length;T<g;T++){const x=s[T],w=x.getIndex();if(!(!n&&!h&&o[T]))for(let A=0;A<w.count;++A)b.setX(l+A,w.getX(A)+v);l+=w.count,v+=x.getAttribute("position").count}}}const d=Object.keys(s[0].attributes);for(let h=0,l=d.length;h<l;h++){let v=!1;const b=d[h];if(!t.getAttribute(b)){const x=s[0].getAttribute(b);t.setAttribute(b,Zr(x,u)),v=!0}let T=0;const g=t.getAttribute(b);for(let x=0,w=s.length;x<w;x++){const S=s[x],A=!n&&!v&&o[x],P=S.getAttribute(b);A||Ds(P,g,T),T+=P.count}}}function jc(s,e,t){const r=s.index,o=s.attributes.position.count,i=r?r.count:o;let a=s.groups;a.length===0&&(a=[{count:i,start:0,materialIndex:0}]);let c=s.getAttribute("materialIndex");if(!c||c.count!==o){let d;t.length<=255?d=new Uint8Array(o):d=new Uint16Array(o),c=new f.BufferAttribute(d,1,!1),s.deleteAttribute("materialIndex"),s.setAttribute("materialIndex",c)}const u=c.array;for(let d=0;d<a.length;d++){const h=a[d],l=h.start,v=h.count,b=Math.min(v,i-l),T=Array.isArray(e)?e[h.materialIndex]:e,g=t.indexOf(T);for(let x=0;x<b;x++){let w=l+x;r&&(w=r.getX(w)),u[w]=g}}}function Wc(s,e){if(!s.index){const t=s.attributes.position.count,r=new Array(t);for(let n=0;n<t;n++)r[n]=n;s.setIndex(r)}if(!s.attributes.normal&&e&&e.includes("normal")&&s.computeVertexNormals(),!s.attributes.uv&&e&&e.includes("uv")){const t=s.attributes.position.count;s.setAttribute("uv",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!s.attributes.uv2&&e&&e.includes("uv2")){const t=s.attributes.position.count;s.setAttribute("uv2",new f.BufferAttribute(new Float32Array(t*2),2,!1))}if(!s.attributes.tangent&&e&&e.includes("tangent"))if(s.attributes.uv&&s.attributes.normal)s.computeTangents();else{const t=s.attributes.position.count;s.setAttribute("tangent",new f.BufferAttribute(new Float32Array(t*4),4,!1))}if(!s.attributes.color&&e&&e.includes("color")){const t=s.attributes.position.count,r=new Float32Array(t*4);r.fill(1),s.setAttribute("color",new f.BufferAttribute(r,4))}}function Mi(s){let e=0;if(s.byteLength!==0){const t=new Uint8Array(s);for(let r=0;r<s.byteLength;r++){const n=t[r];e=(e<<5)-e+n,e|=0}}return e}function Rs(s){let e=s.uuid;const t=Object.values(s.attributes);s.index&&(t.push(s.index),e+=`index|${s.index.version}`);const r=Object.keys(t).sort();for(const n of r){const o=t[n];e+=`${n}_${o.version}|`}return e}function Fs(s){const e=s.skeleton;return e?(e.boneTexture||e.computeBoneTexture(),`${Mi(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`):null}class Yc{constructor(e=null){this.matrixWorld=new f.Matrix4,this.geometryHash=null,this.skeletonHash=null,this.primitiveCount=-1,e!==null&&this.updateFrom(e)}updateFrom(e){const t=e.geometry,r=(t.index?t.index.count:t.attributes.position.count)/3;this.matrixWorld.copy(e.matrixWorld),this.geometryHash=Rs(t),this.primitiveCount=r,this.skeletonHash=Fs(e)}didChange(e){const t=e.geometry,r=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===Rs(t)&&this.skeletonHash===Fs(e)&&this.primitiveCount===r)}}const qt=new f.Vector3,Kt=new f.Vector3,Xt=new f.Vector3,Os=new f.Vector4,On=new f.Vector3,Ii=new f.Vector3,Ls=new f.Vector4,Ns=new f.Vector4,Ln=new f.Matrix4,ks=new f.Matrix4;function Bs(s,e,t){const r=s.skeleton,n=s.geometry,o=r.bones,i=r.boneInverses;Ls.fromBufferAttribute(n.attributes.skinIndex,e),Ns.fromBufferAttribute(n.attributes.skinWeight,e),Ln.elements.fill(0);for(let a=0;a<4;a++){const c=Ns.getComponent(a);if(c!==0){const u=Ls.getComponent(a);ks.multiplyMatrices(o[u].matrixWorld,i[u]),Zc(Ln,ks,c)}}return Ln.multiply(s.bindMatrix).premultiply(s.bindMatrixInverse),t.transformDirection(Ln),t}function Ci(s,e,t,r,n){On.set(0,0,0);for(let o=0,i=s.length;o<i;o++){const a=e[o],c=s[o];a!==0&&(Ii.fromBufferAttribute(c,r),t?On.addScaledVector(Ii,a):On.addScaledVector(Ii.sub(n),a))}n.add(On)}function Zc(s,e,t){const r=s.elements,n=e.elements;for(let o=0,i=n.length;o<i;o++)r[o]+=n[o]*t}function qc(s){const{index:e,attributes:t}=s;if(e)for(let r=0,n=e.count;r<n;r+=3){const o=e.getX(r),i=e.getX(r+2);e.setX(r,i),e.setX(r+2,o)}else for(const r in t){const n=t[r],o=n.itemSize;for(let i=0,a=n.count;i<a;i+=3)for(let c=0;c<o;c++){const u=n.getComponent(i,c),d=n.getComponent(i+2,c);n.setComponent(i,c,d),n.setComponent(i+2,c,u)}}return s}function Kc(s,e={},t=new f.BufferGeometry){e={applyWorldTransforms:!0,attributes:[],...e};const r=s.geometry,n=e.applyWorldTransforms,o=e.attributes.includes("normal"),i=e.attributes.includes("tangent"),a=r.attributes,c=t.attributes;for(const w in t.attributes)(!e.attributes.includes(w)||!(w in r.attributes))&&t.deleteAttribute(w);!t.index&&r.index&&(t.index=r.index.clone()),c.position||t.setAttribute("position",Zr(a.position)),o&&!c.normal&&a.normal&&t.setAttribute("normal",Zr(a.normal)),i&&!c.tangent&&a.tangent&&t.setAttribute("tangent",Zr(a.tangent)),Tr(r.index,t.index),Tr(a.position,c.position),o&&Tr(a.normal,c.normal),i&&Tr(a.tangent,c.tangent);const u=a.position,d=o?a.normal:null,h=i?a.tangent:null,l=r.morphAttributes.position,v=r.morphAttributes.normal,b=r.morphAttributes.tangent,T=r.morphTargetsRelative,g=s.morphTargetInfluences,x=new f.Matrix3;x.getNormalMatrix(s.matrixWorld),r.index&&t.index.array.set(r.index.array);for(let w=0,S=a.position.count;w<S;w++)qt.fromBufferAttribute(u,w),d&&Kt.fromBufferAttribute(d,w),h&&(Os.fromBufferAttribute(h,w),Xt.fromBufferAttribute(h,w)),g&&(l&&Ci(l,g,T,w,qt),v&&Ci(v,g,T,w,Kt),b&&Ci(b,g,T,w,Xt)),s.isSkinnedMesh&&(s.applyBoneTransform(w,qt),d&&Bs(s,w,Kt),h&&Bs(s,w,Xt)),n&&qt.applyMatrix4(s.matrixWorld),c.position.setXYZ(w,qt.x,qt.y,qt.z),d&&(n&&Kt.applyNormalMatrix(x),c.normal.setXYZ(w,Kt.x,Kt.y,Kt.z)),h&&(n&&Xt.transformDirection(s.matrixWorld),c.tangent.setXYZW(w,Xt.x,Xt.y,Xt.z,Os.w));for(const w in e.attributes){const S=e.attributes[w];S==="position"||S==="tangent"||S==="normal"||!(S in a)||(c[S]||t.setAttribute(S,Zr(a[S])),Tr(a[S],c[S]),Ds(a[S],c[S]))}return s.matrixWorld.determinant()<0&&qc(t),t}class Xc extends f.BufferGeometry{constructor(){super(),this.version=0,this.hash=null,this._diff=new Yc}isCompatible(e,t){const r=e.geometry;for(let n=0;n<t.length;n++){const o=t[n],i=r.attributes[o],a=this.attributes[o];if(i&&!Tr(i,a))return!1}return!0}updateFrom(e,t){const r=this._diff;return r.didChange(e)?(Kc(e,t,this),r.updateFrom(e),this.version++,this.hash=`${this.uuid}_${this.version}`,!0):!1}}const Pi=0,zs=1,Es=2;function $c(s,e){for(let t=0,r=s.length;t<r;t++)s[t].traverseVisible(o=>{o.isMesh&&e(o)})}function Qc(s){const e=[];for(let t=0,r=s.length;t<r;t++){const n=s[t];Array.isArray(n.material)?e.push(...n.material):e.push(n.material)}return e}function Jc(s,e,t){if(s.length===0){e.setIndex(null);const r=e.attributes;for(const n in r)e.deleteAttribute(n);for(const n in t.attributes)e.setAttribute(t.attributes[n],new f.BufferAttribute(new Float32Array(0),4,!1))}else Gc(s,t,e);for(const r in e.attributes)e.attributes[r].needsUpdate=!0}class Hc{constructor(e){this.objects=null,this.useGroups=!0,this.applyWorldTransforms=!0,this.generateMissingAttributes=!0,this.overwriteIndex=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Map,this._geometryMergeSets=new WeakMap,this._mergeOrder=[],this._dummyMesh=null,this.setObjects(e||[])}_getDummyMesh(){if(!this._dummyMesh){const e=new f.MeshBasicMaterial,t=new f.BufferGeometry;t.setAttribute("position",new f.BufferAttribute(new Float32Array(9),3)),this._dummyMesh=new f.Mesh(t,e)}return this._dummyMesh}_getMeshes(){const e=[];return $c(this.objects,t=>{e.push(t)}),e.sort((t,r)=>t.uuid>r.uuid?1:t.uuid<r.uuid?-1:0),e.length===0&&e.push(this._getDummyMesh()),e}_updateIntermediateGeometries(){const{_intermediateGeometry:e}=this,t=this._getMeshes(),r=new Set(e.keys()),n={attributes:this.attributes,applyWorldTransforms:this.applyWorldTransforms};for(let o=0,i=t.length;o<i;o++){const a=t[o],c=a.uuid;r.delete(c);let u=e.get(c);(!u||!u.isCompatible(a,this.attributes))&&(u&&u.dispose(),u=new Xc,e.set(c,u)),u.updateFrom(a,n)&&this.generateMissingAttributes&&Wc(u,this.attributes)}r.forEach(o=>{e.delete(o)})}setObjects(e){Array.isArray(e)?this.objects=[...e]:this.objects=[e]}generate(e=new f.BufferGeometry){const{useGroups:t,overwriteIndex:r,_intermediateGeometry:n,_geometryMergeSets:o}=this,i=this._getMeshes(),a=[],c=[],u=o.get(e)||[];this._updateIntermediateGeometries();let d=!1;i.length!==u.length&&(d=!0);for(let l=0,v=i.length;l<v;l++){const b=i[l],T=n.get(b.uuid);c.push(T);const g=u[l];!g||g.uuid!==T.uuid?(a.push(!1),d=!0):g.version!==T.version?a.push(!1):a.push(!0)}Jc(c,e,{useGroups:t,forceUpdate:d,skipAssigningAttributes:a,overwriteIndex:r}),d&&e.dispose(),o.set(e,c.map(l=>({version:l.version,uuid:l.uuid})));let h=Pi;return d?h=Es:a.includes(!1)&&(h=zs),{changeType:h,materials:Qc(i),geometry:e}}}function el(s){const e=new Set;for(let t=0,r=s.length;t<r;t++){const n=s[t];for(const o in n){const i=n[o];i&&i.isTexture&&e.add(i)}}return Array.from(e)}function tl(s){const e=[],t=new Set;for(let n=0,o=s.length;n<o;n++)s[n].traverse(i=>{i.visible&&(i.isRectAreaLight||i.isSpotLight||i.isPointLight||i.isDirectionalLight)&&(e.push(i),i.iesMap&&t.add(i.iesMap))});const r=Array.from(t).sort((n,o)=>n.uuid<o.uuid?1:n.uuid>o.uuid?-1:0);return{lights:e,iesTextures:r}}class rl{get initialized(){return!!this.bvh}constructor(e){this.bvhOptions={},this.attributes=["position","normal","tangent","color","uv","uv2"],this.generateBVH=!0,this.bvh=null,this.geometry=new f.BufferGeometry,this.staticGeometryGenerator=new Hc(e),this._bvhWorker=null,this._pendingGenerate=null,this._buildAsync=!1}setObjects(e){this.staticGeometryGenerator.setObjects(e)}setBVHWorker(e){this._bvhWorker=e}async generateAsync(e=null){if(!this._bvhWorker)throw new Error('PathTracingSceneGenerator: "setBVHWorker" must be called before "generateAsync" can be called.');if(this.bvh instanceof Promise)return this._pendingGenerate||(this._pendingGenerate=new Promise(async()=>(await this.bvh,this._pendingGenerate=null,this.generateAsync(e)))),this._pendingGenerate;{this._buildAsync=!0;const t=this.generate(e);return this._buildAsync=!1,t.bvh=this.bvh=await t.bvh,t}}generate(e=null){const{staticGeometryGenerator:t,geometry:r,attributes:n}=this,o=t.objects;t.attributes=n,o.forEach(h=>{h.traverse(l=>{l.isSkinnedMesh&&l.skeleton&&l.skeleton.update()})});const i=t.generate(r),a=i.materials,c=el(a),{lights:u,iesTextures:d}=tl(o);if(i.changeType!==Pi&&jc(r,a,a),this.generateBVH){if(this.bvh instanceof Promise)throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");if(i.changeType===Es){const h={strategy:cs,maxLeafTris:1,indirect:!0,onProgress:e,...this.bvhOptions};this._buildAsync?this.bvh=this._bvhWorker.generate(r,h):this.bvh=new Ai(r,h)}else i.changeType===zs&&this.bvh.refit()}return{bvhChanged:i.changeType!==Pi,bvh:this.bvh,lights:u,iesTextures:d,geometry:r,materials:a,textures:c,objects:o}}}const nl=new f.OrthographicCamera(-1,1,1,-1,0,1);class il extends f.BufferGeometry{constructor(){super(),this.setAttribute("position",new f.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new f.Float32BufferAttribute([0,2,0,0,2,0],2))}}const sl=new il;class Sr{constructor(e){this._mesh=new f.Mesh(sl,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,nl)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Di extends f.ShaderMaterial{set needsUpdate(e){super.needsUpdate=!0,this.dispatchEvent({type:"recompilation"})}constructor(e){super(e);for(const t in this.uniforms)Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(r){this.uniforms[t].value=r}})}setDefine(e,t=void 0){if(t==null){if(e in this.defines)return delete this.defines[e],this.needsUpdate=!0,!0}else if(this.defines[e]!==t)return this.defines[e]=t,this.needsUpdate=!0,!0;return!1}}class ol extends Di{constructor(e){super({blending:f.NoBlending,uniforms:{target1:{value:null},target2:{value:null},opacity:{value:1}},vertexShader:`
|
|
356
327
|
|
|
357
328
|
varying vec2 vUv;
|
|
358
329
|
|
|
@@ -389,7 +360,7 @@ struct BVH {
|
|
|
389
360
|
|
|
390
361
|
}
|
|
391
362
|
|
|
392
|
-
}`}),this.setValues(e)}}function
|
|
363
|
+
}`}),this.setValues(e)}}function Nn(s=1){let e="uint";return s>1&&(e="uvec"+s),`
|
|
393
364
|
${e} sobolReverseBits( ${e} x ) {
|
|
394
365
|
|
|
395
366
|
x = ( ( ( x & 0xaaaaaaaau ) >> 1 ) | ( ( x & 0x55555555u ) << 1 ) );
|
|
@@ -424,34 +395,34 @@ struct BVH {
|
|
|
424
395
|
return x;
|
|
425
396
|
|
|
426
397
|
}
|
|
427
|
-
`}function
|
|
398
|
+
`}function kn(s=1){let e="uint",t="float",r="",n=".r",o="1u";return s>1&&(e="uvec"+s,t="vec"+s,r=s+"",s===2?(n=".rg",o="uvec2( 1u, 2u )"):s===3?(n=".rgb",o="uvec3( 1u, 2u, 3u )"):(n="",o="uvec4( 1u, 2u, 3u, 4u )")),`
|
|
428
399
|
|
|
429
|
-
${
|
|
400
|
+
${t} sobol${r}( int effect ) {
|
|
430
401
|
|
|
431
402
|
uint seed = sobolGetSeed( sobolBounceIndex, uint( effect ) );
|
|
432
403
|
uint index = sobolPathIndex;
|
|
433
404
|
|
|
434
405
|
uint shuffle_seed = sobolHashCombine( seed, 0u );
|
|
435
406
|
uint shuffled_index = nestedUniformScrambleBase2( sobolReverseBits( index ), shuffle_seed );
|
|
436
|
-
${
|
|
407
|
+
${t} sobol_pt = sobolGetTexturePoint( shuffled_index )${n};
|
|
437
408
|
${e} result = ${e}( sobol_pt * 16777216.0 );
|
|
438
409
|
|
|
439
|
-
${e} seed2 = sobolHashCombine( seed, ${
|
|
410
|
+
${e} seed2 = sobolHashCombine( seed, ${o} );
|
|
440
411
|
result = nestedUniformScrambleBase2( result, seed2 );
|
|
441
412
|
|
|
442
|
-
return SOBOL_FACTOR * ${
|
|
413
|
+
return SOBOL_FACTOR * ${t}( result >> 8 );
|
|
443
414
|
|
|
444
415
|
}
|
|
445
|
-
`}const
|
|
416
|
+
`}const Us=`
|
|
446
417
|
|
|
447
418
|
// Utils
|
|
448
419
|
const float SOBOL_FACTOR = 1.0 / 16777216.0;
|
|
449
420
|
const uint SOBOL_MAX_POINTS = 256u * 256u;
|
|
450
421
|
|
|
451
|
-
${
|
|
452
|
-
${
|
|
453
|
-
${
|
|
454
|
-
${
|
|
422
|
+
${Nn(1)}
|
|
423
|
+
${Nn(2)}
|
|
424
|
+
${Nn(3)}
|
|
425
|
+
${Nn(4)}
|
|
455
426
|
|
|
456
427
|
uint sobolHash( uint x ) {
|
|
457
428
|
|
|
@@ -465,7 +436,7 @@ struct BVH {
|
|
|
465
436
|
|
|
466
437
|
}
|
|
467
438
|
|
|
468
|
-
`,
|
|
439
|
+
`,al=`
|
|
469
440
|
|
|
470
441
|
const uint SOBOL_DIRECTIONS_1[ 32 ] = uint[ 32 ](
|
|
471
442
|
0x80000000u, 0xc0000000u, 0xa0000000u, 0xf0000000u,
|
|
@@ -543,7 +514,7 @@ struct BVH {
|
|
|
543
514
|
|
|
544
515
|
}
|
|
545
516
|
|
|
546
|
-
`,
|
|
517
|
+
`,cl=`
|
|
547
518
|
|
|
548
519
|
// Seeds
|
|
549
520
|
uniform sampler2D sobolTexture;
|
|
@@ -581,12 +552,12 @@ struct BVH {
|
|
|
581
552
|
|
|
582
553
|
}
|
|
583
554
|
|
|
584
|
-
${
|
|
585
|
-
${
|
|
586
|
-
${
|
|
587
|
-
${
|
|
555
|
+
${kn(1)}
|
|
556
|
+
${kn(2)}
|
|
557
|
+
${kn(3)}
|
|
558
|
+
${kn(4)}
|
|
588
559
|
|
|
589
|
-
`;class
|
|
560
|
+
`;class ll extends Di{constructor(){super({blending:f.NoBlending,uniforms:{resolution:{value:new f.Vector2}},vertexShader:`
|
|
590
561
|
|
|
591
562
|
varying vec2 vUv;
|
|
592
563
|
void main() {
|
|
@@ -597,8 +568,8 @@ struct BVH {
|
|
|
597
568
|
}
|
|
598
569
|
`,fragmentShader:`
|
|
599
570
|
|
|
600
|
-
${
|
|
601
|
-
${
|
|
571
|
+
${Us}
|
|
572
|
+
${al}
|
|
602
573
|
|
|
603
574
|
varying vec2 vUv;
|
|
604
575
|
uniform vec2 resolution;
|
|
@@ -608,7 +579,7 @@ struct BVH {
|
|
|
608
579
|
gl_FragColor = generateSobolPoint( index );
|
|
609
580
|
|
|
610
581
|
}
|
|
611
|
-
`})}}class pm{generate(e,n=256){const i=new m.WebGLRenderTarget(n,n,{type:m.FloatType,format:m.RGBAFormat,minFilter:m.NearestFilter,magFilter:m.NearestFilter,generateMipmaps:!1}),s=e.getRenderTarget();e.setRenderTarget(i);const c=new fr(new dm);return c.material.resolution.set(n,n),c.render(e),e.setRenderTarget(s),c.dispose(),i}}let bl=class extends m.PerspectiveCamera{set bokehSize(e){this.fStop=this.getFocalLength()/e}get bokehSize(){return this.getFocalLength()/this.fStop}constructor(...e){super(...e),this.fStop=1.4,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=25,this.anamorphicRatio=1}copy(e,n){return super.copy(e,n),this.fStop=e.fStop,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio,this}};class mm{constructor(){this.bokehSize=0,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=10,this.anamorphicRatio=1}updateFrom(e){e instanceof bl?(this.bokehSize=e.bokehSize,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio):(this.bokehSize=0,this.apertureRotation=0,this.apertureBlades=0,this.focusDistance=10,this.anamorphicRatio=1)}}function to(o){const e=new Uint16Array(o.length);for(let n=0,i=o.length;n<i;++n)e[n]=m.DataUtils.toHalfFloat(o[n]);return e}function Tl(o,e,n=0,i=o.length){let s=n,c=n+i-1;for(;s<c;){const a=s+c>>1;o[a]<e?s=a+1:c=a}return s-n}function gm(o,e,n){return .2126*o+.7152*e+.0722*n}function vm(o,e=m.HalfFloatType){const n=o.clone();n.source=new m.Source({...n.image});const{width:i,height:s,data:c}=n.image;let a=c;if(n.type!==e){e===m.HalfFloatType?a=new Uint16Array(c.length):a=new Float32Array(c.length);let u;c instanceof Int8Array||c instanceof Int16Array||c instanceof Int32Array?u=2**(8*c.BYTES_PER_ELEMENT-1)-1:u=2**(8*c.BYTES_PER_ELEMENT)-1;for(let f=0,p=c.length;f<p;f++){let v=c[f];n.type===m.HalfFloatType&&(v=m.DataUtils.fromHalfFloat(c[f])),n.type!==m.FloatType&&n.type!==m.HalfFloatType&&(v/=u),e===m.HalfFloatType&&(a[f]=m.DataUtils.toHalfFloat(v))}n.image.data=a,n.type=e}if(n.flipY){const u=a;a=a.slice();for(let f=0;f<s;f++)for(let p=0;p<i;p++){const v=s-f-1,g=4*(f*i+p),h=4*(v*i+p);a[h+0]=u[g+0],a[h+1]=u[g+1],a[h+2]=u[g+2],a[h+3]=u[g+3]}n.flipY=!1,n.image.data=a}return n}class ym{constructor(){const e=new m.DataTexture(to(new Float32Array([0,0,0,0])),1,1);e.type=m.HalfFloatType,e.format=m.RGBAFormat,e.minFilter=m.LinearFilter,e.magFilter=m.LinearFilter,e.wrapS=m.RepeatWrapping,e.wrapT=m.RepeatWrapping,e.generateMipmaps=!1,e.needsUpdate=!0;const n=new m.DataTexture(to(new Float32Array([0,1])),1,2);n.type=m.HalfFloatType,n.format=m.RedFormat,n.minFilter=m.LinearFilter,n.magFilter=m.LinearFilter,n.generateMipmaps=!1,n.needsUpdate=!0;const i=new m.DataTexture(to(new Float32Array([0,0,1,1])),2,2);i.type=m.HalfFloatType,i.format=m.RedFormat,i.minFilter=m.LinearFilter,i.magFilter=m.LinearFilter,i.generateMipmaps=!1,i.needsUpdate=!0,this.map=e,this.marginalWeights=n,this.conditionalWeights=i,this.totalSum=0}dispose(){this.marginalWeights.dispose(),this.conditionalWeights.dispose(),this.map.dispose()}updateFrom(e){const n=vm(e);n.wrapS=m.RepeatWrapping,n.wrapT=m.ClampToEdgeWrapping;const{width:i,height:s,data:c}=n.image,a=new Float32Array(i*s),u=new Float32Array(i*s),f=new Float32Array(s),p=new Float32Array(s);let v=0,g=0;for(let x=0;x<s;x++){let A=0;for(let E=0;E<i;E++){const C=x*i+E,P=m.DataUtils.fromHalfFloat(c[4*C+0]),O=m.DataUtils.fromHalfFloat(c[4*C+1]),B=m.DataUtils.fromHalfFloat(c[4*C+2]),k=gm(P,O,B);A+=k,v+=k,a[C]=k,u[C]=A}if(A!==0)for(let E=x*i,C=x*i+i;E<C;E++)a[E]/=A,u[E]/=A;g+=A,f[x]=A,p[x]=g}if(g!==0)for(let x=0,A=f.length;x<A;x++)f[x]/=g,p[x]/=g;const h=new Uint16Array(s),b=new Uint16Array(i*s);for(let x=0;x<s;x++){const A=(x+1)/s,E=Tl(p,A);h[x]=m.DataUtils.toHalfFloat((E+.5)/s)}for(let x=0;x<s;x++)for(let A=0;A<i;A++){const E=x*i+A,C=(A+1)/i,P=Tl(u,C,x*i,i);b[E]=m.DataUtils.toHalfFloat((P+.5)/i)}this.dispose();const{marginalWeights:R,conditionalWeights:M}=this;R.image={width:s,height:1,data:h},R.needsUpdate=!0,M.image={width:i,height:s,data:b},M.needsUpdate=!0,this.totalSum=v,this.map=n}}const no=6,_m=0,xm=1,bm=2,Tm=3,wm=4,sn=new m.Vector3,St=new m.Vector3,wl=new m.Matrix4,$r=new m.Quaternion,Rl=new m.Vector3,Qr=new m.Vector3,Rm=new m.Vector3(0,1,0);class Am{constructor(){const e=new m.DataTexture(new Float32Array(4),1,1);e.format=m.RGBAFormat,e.type=m.FloatType,e.wrapS=m.ClampToEdgeWrapping,e.wrapT=m.ClampToEdgeWrapping,e.generateMipmaps=!1,e.minFilter=m.NearestFilter,e.magFilter=m.NearestFilter,this.tex=e,this.count=0}updateFrom(e,n=[]){const i=this.tex,s=Math.max(e.length*no,1),c=Math.ceil(Math.sqrt(s));i.image.width!==c&&(i.dispose(),i.image.data=new Float32Array(c*c*4),i.image.width=c,i.image.height=c);const a=i.image.data;for(let f=0,p=e.length;f<p;f++){const v=e[f],g=f*no*4;let h=0;for(let R=0;R<no*4;R++)a[g+R]=0;v.getWorldPosition(St),a[g+h++]=St.x,a[g+h++]=St.y,a[g+h++]=St.z;let b=_m;if(v.isRectAreaLight&&v.isCircular?b=xm:v.isSpotLight?b=bm:v.isDirectionalLight?b=Tm:v.isPointLight&&(b=wm),a[g+h++]=b,a[g+h++]=v.color.r,a[g+h++]=v.color.g,a[g+h++]=v.color.b,a[g+h++]=v.intensity,v.getWorldQuaternion($r),v.isRectAreaLight)sn.set(v.width,0,0).applyQuaternion($r),a[g+h++]=sn.x,a[g+h++]=sn.y,a[g+h++]=sn.z,h++,St.set(0,v.height,0).applyQuaternion($r),a[g+h++]=St.x,a[g+h++]=St.y,a[g+h++]=St.z,a[g+h++]=sn.cross(St).length()*(v.isCircular?Math.PI/4:1);else if(v.isSpotLight){const R=v.radius||0;Rl.setFromMatrixPosition(v.matrixWorld),Qr.setFromMatrixPosition(v.target.matrixWorld),wl.lookAt(Rl,Qr,Rm),$r.setFromRotationMatrix(wl),sn.set(1,0,0).applyQuaternion($r),a[g+h++]=sn.x,a[g+h++]=sn.y,a[g+h++]=sn.z,h++,St.set(0,1,0).applyQuaternion($r),a[g+h++]=St.x,a[g+h++]=St.y,a[g+h++]=St.z,a[g+h++]=Math.PI*R*R,a[g+h++]=R,a[g+h++]=v.decay,a[g+h++]=v.distance,a[g+h++]=Math.cos(v.angle),a[g+h++]=Math.cos(v.angle*(1-v.penumbra)),a[g+h++]=v.iesMap?n.indexOf(v.iesMap):-1}else if(v.isPointLight){const R=sn.setFromMatrixPosition(v.matrixWorld);a[g+h++]=R.x,a[g+h++]=R.y,a[g+h++]=R.z,h++,h+=4,h+=1,a[g+h++]=v.decay,a[g+h++]=v.distance}else if(v.isDirectionalLight){const R=sn.setFromMatrixPosition(v.matrixWorld),M=St.setFromMatrixPosition(v.target.matrixWorld);Qr.subVectors(R,M).normalize(),a[g+h++]=Qr.x,a[g+h++]=Qr.y,a[g+h++]=Qr.z}}this.count=e.length;const u=$a(a.buffer);return this.hash!==u?(this.hash=u,i.needsUpdate=!0,!0):!1}}function Al(o,e,n,i,s){if(e>i)throw new Error;const c=o.length/e,a=o.constructor.BYTES_PER_ELEMENT*8;let u=1;switch(o.constructor){case Uint8Array:case Uint16Array:case Uint32Array:u=2**a-1;break;case Int8Array:case Int16Array:case Int32Array:u=2**(a-1)-1;break}for(let f=0;f<c;f++){const p=4*f,v=e*f;for(let g=0;g<i;g++)n[s+p+g]=e>=g+1?o[v+g]/u:0}}class Em extends m.DataArrayTexture{constructor(){super(),this._textures=[],this.type=m.FloatType,this.format=m.RGBAFormat,this.internalFormat="RGBA32F"}updateAttribute(e,n){const i=this._textures[e];i.updateFrom(n);const s=i.image,c=this.image;if(s.width!==c.width||s.height!==c.height)throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");const{width:a,height:u,data:f}=c,v=a*u*4*e;let g=n.itemSize;g===3&&(g=4),Al(i.image.data,g,f,4,v),this.dispose(),this.needsUpdate=!0}setAttributes(e){const n=e[0].count,i=e.length;for(let g=0,h=i;g<h;g++)if(e[g].count!==n)throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");const s=this._textures;for(;s.length<i;){const g=new ll;s.push(g)}for(;s.length>i;)s.pop();for(let g=0,h=i;g<h;g++)s[g].updateFrom(e[g]);const a=s[0].image,u=this.image;(a.width!==u.width||a.height!==u.height||a.depth!==i)&&(u.width=a.width,u.height=a.height,u.depth=i,u.data=new Float32Array(u.width*u.height*u.depth*4));const{data:f,width:p,height:v}=u;for(let g=0,h=i;g<h;g++){const b=s[g],M=p*v*4*g;let x=e[g].itemSize;x===3&&(x=4),Al(b.image.data,x,f,4,M)}this.dispose(),this.needsUpdate=!0}}class Sm extends Em{updateNormalAttribute(e){this.updateAttribute(0,e)}updateTangentAttribute(e){this.updateAttribute(1,e)}updateUvAttribute(e){this.updateAttribute(2,e)}updateColorAttribute(e){this.updateAttribute(3,e)}updateFrom(e,n,i,s){this.setAttributes([e,n,i,s])}}function ro(o,e){return o.uuid<e.uuid?1:o.uuid>e.uuid?-1:0}function io(o){return`${o.source.uuid}:${o.colorSpace}`}function Mm(o){const e=new Set,n=[];for(let i=0,s=o.length;i<s;i++){const c=o[i],a=io(c);e.has(a)||(e.add(a),n.push(c))}return n}function Cm(o){const e=o.map(i=>i.iesMap||null).filter(i=>i),n=new Set(e);return Array.from(n).sort(ro)}function Im(o){const e=new Set;for(let i=0,s=o.length;i<s;i++){const c=o[i];for(const a in c){const u=c[a];u&&u.isTexture&&e.add(u)}}const n=Array.from(e);return Mm(n).sort(ro)}function Pm(o){const e=[];return o.traverse(n=>{n.visible&&(n.isRectAreaLight||n.isSpotLight||n.isPointLight||n.isDirectionalLight)&&e.push(n)}),e.sort(ro)}const El=45,Sl=El*4;class Dm{constructor(){this._features={}}isUsed(e){return e in this._features}setUsed(e,n=!0){n===!1?delete this._features[e]:this._features[e]=!0}reset(){this._features={}}}class Fm extends m.DataTexture{constructor(){super(new Float32Array(4),1,1),this.format=m.RGBAFormat,this.type=m.FloatType,this.wrapS=m.ClampToEdgeWrapping,this.wrapT=m.ClampToEdgeWrapping,this.minFilter=m.NearestFilter,this.magFilter=m.NearestFilter,this.generateMipmaps=!1,this.features=new Dm}updateFrom(e,n){function i(R,M,x=-1){if(M in R&&R[M]){const A=io(R[M]);return g[A]}else return x}function s(R,M,x){return M in R?R[M]:x}function c(R,M,x,A){const E=R[M]&&R[M].isTexture?R[M]:null;if(E){E.matrixAutoUpdate&&E.updateMatrix();const C=E.matrix.elements;let P=0;x[A+P++]=C[0],x[A+P++]=C[3],x[A+P++]=C[6],P++,x[A+P++]=C[1],x[A+P++]=C[4],x[A+P++]=C[7],P++}return 8}let a=0;const u=e.length*El,f=Math.ceil(Math.sqrt(u))||1,{image:p,features:v}=this,g={};for(let R=0,M=n.length;R<M;R++)g[io(n[R])]=R;p.width!==f&&(this.dispose(),p.data=new Float32Array(f*f*4),p.width=f,p.height=f);const h=p.data;v.reset();for(let R=0,M=e.length;R<M;R++){const x=e[R];if(x.isFogVolumeMaterial){v.setUsed("FOG");for(let C=0;C<Sl;C++)h[a+C]=0;h[a+0*4+0]=x.color.r,h[a+0*4+1]=x.color.g,h[a+0*4+2]=x.color.b,h[a+2*4+3]=s(x,"emissiveIntensity",0),h[a+3*4+0]=x.emissive.r,h[a+3*4+1]=x.emissive.g,h[a+3*4+2]=x.emissive.b,h[a+13*4+1]=x.density,h[a+13*4+3]=0,h[a+14*4+2]=4,a+=Sl;continue}h[a++]=x.color.r,h[a++]=x.color.g,h[a++]=x.color.b,h[a++]=i(x,"map"),h[a++]=s(x,"metalness",0),h[a++]=i(x,"metalnessMap"),h[a++]=s(x,"roughness",0),h[a++]=i(x,"roughnessMap"),h[a++]=s(x,"ior",1.5),h[a++]=s(x,"transmission",0),h[a++]=i(x,"transmissionMap"),h[a++]=s(x,"emissiveIntensity",0),"emissive"in x?(h[a++]=x.emissive.r,h[a++]=x.emissive.g,h[a++]=x.emissive.b):(h[a++]=0,h[a++]=0,h[a++]=0),h[a++]=i(x,"emissiveMap"),h[a++]=i(x,"normalMap"),"normalScale"in x?(h[a++]=x.normalScale.x,h[a++]=x.normalScale.y):(h[a++]=1,h[a++]=1),h[a++]=s(x,"clearcoat",0),h[a++]=i(x,"clearcoatMap"),h[a++]=s(x,"clearcoatRoughness",0),h[a++]=i(x,"clearcoatRoughnessMap"),h[a++]=i(x,"clearcoatNormalMap"),"clearcoatNormalScale"in x?(h[a++]=x.clearcoatNormalScale.x,h[a++]=x.clearcoatNormalScale.y):(h[a++]=1,h[a++]=1),a++,h[a++]=s(x,"sheen",0),"sheenColor"in x?(h[a++]=x.sheenColor.r,h[a++]=x.sheenColor.g,h[a++]=x.sheenColor.b):(h[a++]=0,h[a++]=0,h[a++]=0),h[a++]=i(x,"sheenColorMap"),h[a++]=s(x,"sheenRoughness",0),h[a++]=i(x,"sheenRoughnessMap"),h[a++]=i(x,"iridescenceMap"),h[a++]=i(x,"iridescenceThicknessMap"),h[a++]=s(x,"iridescence",0),h[a++]=s(x,"iridescenceIOR",1.3);const A=s(x,"iridescenceThicknessRange",[100,400]);h[a++]=A[0],h[a++]=A[1],"specularColor"in x?(h[a++]=x.specularColor.r,h[a++]=x.specularColor.g,h[a++]=x.specularColor.b):(h[a++]=1,h[a++]=1,h[a++]=1),h[a++]=i(x,"specularColorMap"),h[a++]=s(x,"specularIntensity",1),h[a++]=i(x,"specularIntensityMap");const E=s(x,"thickness",0)===0&&s(x,"attenuationDistance",1/0)===1/0;if(h[a++]=Number(E),a++,"attenuationColor"in x?(h[a++]=x.attenuationColor.r,h[a++]=x.attenuationColor.g,h[a++]=x.attenuationColor.b):(h[a++]=1,h[a++]=1,h[a++]=1),h[a++]=s(x,"attenuationDistance",1/0),h[a++]=i(x,"alphaMap"),h[a++]=x.opacity,h[a++]=x.alphaTest,!E&&x.transmission>0)h[a++]=0;else switch(x.side){case m.FrontSide:h[a++]=1;break;case m.BackSide:h[a++]=-1;break;case m.DoubleSide:h[a++]=0;break}h[a++]=Number(s(x,"matte",!1)),h[a++]=Number(s(x,"castShadow",!0)),h[a++]=Number(x.vertexColors)|Number(x.flatShading)<<1,h[a++]=Number(x.transparent),a+=c(x,"map",h,a),a+=c(x,"metalnessMap",h,a),a+=c(x,"roughnessMap",h,a),a+=c(x,"transmissionMap",h,a),a+=c(x,"emissiveMap",h,a),a+=c(x,"normalMap",h,a),a+=c(x,"clearcoatMap",h,a),a+=c(x,"clearcoatNormalMap",h,a),a+=c(x,"clearcoatRoughnessMap",h,a),a+=c(x,"sheenColorMap",h,a),a+=c(x,"sheenRoughnessMap",h,a),a+=c(x,"iridescenceMap",h,a),a+=c(x,"iridescenceThicknessMap",h,a),a+=c(x,"specularColorMap",h,a),a+=c(x,"specularIntensityMap",h,a)}const b=$a(h.buffer);return this.hash!==b?(this.hash=b,this.needsUpdate=!0,!0):!1}}const Ml=new m.Color;function Om(o){return o?`${o.uuid}:${o.version}`:null}function Lm(o,e){for(const n in e)n in o&&(o[n]=e[n])}class Cl extends m.WebGLArrayRenderTarget{constructor(e,n,i){const s={format:m.RGBAFormat,type:m.UnsignedByteType,minFilter:m.LinearFilter,magFilter:m.LinearFilter,wrapS:m.RepeatWrapping,wrapT:m.RepeatWrapping,generateMipmaps:!1,...i};super(e,n,1,s),Lm(this.texture,s),this.texture.setTextures=(...a)=>{this.setTextures(...a)},this.hashes=[null];const c=new fr(new Nm);this.fsQuad=c}setTextures(e,n,i=this.width,s=this.height){const c=e.getRenderTarget(),a=e.toneMapping,u=e.getClearAlpha();e.getClearColor(Ml);const f=n.length||1;(i!==this.width||s!==this.height||this.depth!==f)&&(this.setSize(i,s,f),this.hashes=new Array(f).fill(null)),e.setClearColor(0,0),e.toneMapping=m.NoToneMapping;const p=this.fsQuad,v=this.hashes;let g=!1;for(let h=0,b=f;h<b;h++){const R=n[h],M=Om(R);R&&(v[h]!==M||R.isWebGLRenderTarget)&&(R.matrixAutoUpdate=!1,R.matrix.identity(),p.material.map=R,e.setRenderTarget(this,h),p.render(e),R.updateMatrix(),R.matrixAutoUpdate=!0,v[h]=M,g=!0)}return p.material.map=null,e.setClearColor(Ml,u),e.setRenderTarget(c),e.toneMapping=a,g}dispose(){super.dispose(),this.fsQuad.dispose()}}class Nm extends m.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}constructor(){super({uniforms:{map:{value:null}},vertexShader:`
|
|
582
|
+
`})}}class ul{generate(e,t=256){const r=new f.WebGLRenderTarget(t,t,{type:f.FloatType,format:f.RGBAFormat,minFilter:f.NearestFilter,magFilter:f.NearestFilter,generateMipmaps:!1}),n=e.getRenderTarget();e.setRenderTarget(r);const o=new Sr(new ll);return o.material.resolution.set(t,t),o.render(e),e.setRenderTarget(n),o.dispose(),r}}class hl extends f.PerspectiveCamera{set bokehSize(e){this.fStop=this.getFocalLength()/e}get bokehSize(){return this.getFocalLength()/this.fStop}constructor(...e){super(...e),this.fStop=1.4,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=25,this.anamorphicRatio=1}copy(e,t){return super.copy(e,t),this.fStop=e.fStop,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio,this}}class fl{constructor(){this.bokehSize=0,this.apertureBlades=0,this.apertureRotation=0,this.focusDistance=10,this.anamorphicRatio=1}updateFrom(e){e instanceof hl?(this.bokehSize=e.bokehSize,this.apertureBlades=e.apertureBlades,this.apertureRotation=e.apertureRotation,this.focusDistance=e.focusDistance,this.anamorphicRatio=e.anamorphicRatio):(this.bokehSize=0,this.apertureRotation=0,this.apertureBlades=0,this.focusDistance=10,this.anamorphicRatio=1)}}function Ri(s){const e=new Uint16Array(s.length);for(let t=0,r=s.length;t<r;++t)e[t]=f.DataUtils.toHalfFloat(s[t]);return e}function Vs(s,e,t=0,r=s.length){let n=t,o=t+r-1;for(;n<o;){const i=n+o>>1;s[i]<e?n=i+1:o=i}return n-t}function dl(s,e,t){return .2126*s+.7152*e+.0722*t}function pl(s,e=f.HalfFloatType){const t=s.clone();t.source=new f.Source({...t.image});const{width:r,height:n,data:o}=t.image;let i=o;if(t.type!==e){e===f.HalfFloatType?i=new Uint16Array(o.length):i=new Float32Array(o.length);let a;o instanceof Int8Array||o instanceof Int16Array||o instanceof Int32Array?a=2**(8*o.BYTES_PER_ELEMENT-1)-1:a=2**(8*o.BYTES_PER_ELEMENT)-1;for(let c=0,u=o.length;c<u;c++){let d=o[c];t.type===f.HalfFloatType&&(d=f.DataUtils.fromHalfFloat(o[c])),t.type!==f.FloatType&&t.type!==f.HalfFloatType&&(d/=a),e===f.HalfFloatType&&(i[c]=f.DataUtils.toHalfFloat(d))}t.image.data=i,t.type=e}if(t.flipY){const a=i;i=i.slice();for(let c=0;c<n;c++)for(let u=0;u<r;u++){const d=n-c-1,h=4*(c*r+u),l=4*(d*r+u);i[l+0]=a[h+0],i[l+1]=a[h+1],i[l+2]=a[h+2],i[l+3]=a[h+3]}t.flipY=!1,t.image.data=i}return t}class ml{constructor(){const e=new f.DataTexture(Ri(new Float32Array([0,0,0,0])),1,1);e.type=f.HalfFloatType,e.format=f.RGBAFormat,e.minFilter=f.LinearFilter,e.magFilter=f.LinearFilter,e.wrapS=f.RepeatWrapping,e.wrapT=f.RepeatWrapping,e.generateMipmaps=!1,e.needsUpdate=!0;const t=new f.DataTexture(Ri(new Float32Array([0,1])),1,2);t.type=f.HalfFloatType,t.format=f.RedFormat,t.minFilter=f.LinearFilter,t.magFilter=f.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0;const r=new f.DataTexture(Ri(new Float32Array([0,0,1,1])),2,2);r.type=f.HalfFloatType,r.format=f.RedFormat,r.minFilter=f.LinearFilter,r.magFilter=f.LinearFilter,r.generateMipmaps=!1,r.needsUpdate=!0,this.map=e,this.marginalWeights=t,this.conditionalWeights=r,this.totalSum=0}dispose(){this.marginalWeights.dispose(),this.conditionalWeights.dispose(),this.map.dispose()}updateFrom(e){const t=pl(e);t.wrapS=f.RepeatWrapping,t.wrapT=f.ClampToEdgeWrapping;const{width:r,height:n,data:o}=t.image,i=new Float32Array(r*n),a=new Float32Array(r*n),c=new Float32Array(n),u=new Float32Array(n);let d=0,h=0;for(let g=0;g<n;g++){let x=0;for(let w=0;w<r;w++){const S=g*r+w,A=f.DataUtils.fromHalfFloat(o[4*S+0]),P=f.DataUtils.fromHalfFloat(o[4*S+1]),D=f.DataUtils.fromHalfFloat(o[4*S+2]),F=dl(A,P,D);x+=F,d+=F,i[S]=F,a[S]=x}if(x!==0)for(let w=g*r,S=g*r+r;w<S;w++)i[w]/=x,a[w]/=x;h+=x,c[g]=x,u[g]=h}if(h!==0)for(let g=0,x=c.length;g<x;g++)c[g]/=h,u[g]/=h;const l=new Uint16Array(n),v=new Uint16Array(r*n);for(let g=0;g<n;g++){const x=(g+1)/n,w=Vs(u,x);l[g]=f.DataUtils.toHalfFloat((w+.5)/n)}for(let g=0;g<n;g++)for(let x=0;x<r;x++){const w=g*r+x,S=(x+1)/r,A=Vs(a,S,g*r,r);v[w]=f.DataUtils.toHalfFloat((A+.5)/r)}this.dispose();const{marginalWeights:b,conditionalWeights:T}=this;b.image={width:n,height:1,data:l},b.needsUpdate=!0,T.image={width:r,height:n,data:v},T.needsUpdate=!0,this.totalSum=d,this.map=t}}const Fi=6,gl=0,vl=1,yl=2,bl=3,xl=4,vt=new f.Vector3,$e=new f.Vector3,Gs=new f.Matrix4,Ar=new f.Quaternion,js=new f.Vector3,Mr=new f.Vector3,wl=new f.Vector3(0,1,0);class _l{constructor(){const e=new f.DataTexture(new Float32Array(4),1,1);e.format=f.RGBAFormat,e.type=f.FloatType,e.wrapS=f.ClampToEdgeWrapping,e.wrapT=f.ClampToEdgeWrapping,e.generateMipmaps=!1,e.minFilter=f.NearestFilter,e.magFilter=f.NearestFilter,this.tex=e,this.count=0}updateFrom(e,t=[]){const r=this.tex,n=Math.max(e.length*Fi,1),o=Math.ceil(Math.sqrt(n));r.image.width!==o&&(r.dispose(),r.image.data=new Float32Array(o*o*4),r.image.width=o,r.image.height=o);const i=r.image.data;for(let c=0,u=e.length;c<u;c++){const d=e[c],h=c*Fi*4;let l=0;for(let b=0;b<Fi*4;b++)i[h+b]=0;d.getWorldPosition($e),i[h+l++]=$e.x,i[h+l++]=$e.y,i[h+l++]=$e.z;let v=gl;if(d.isRectAreaLight&&d.isCircular?v=vl:d.isSpotLight?v=yl:d.isDirectionalLight?v=bl:d.isPointLight&&(v=xl),i[h+l++]=v,i[h+l++]=d.color.r,i[h+l++]=d.color.g,i[h+l++]=d.color.b,i[h+l++]=d.intensity,d.getWorldQuaternion(Ar),d.isRectAreaLight)vt.set(d.width,0,0).applyQuaternion(Ar),i[h+l++]=vt.x,i[h+l++]=vt.y,i[h+l++]=vt.z,l++,$e.set(0,d.height,0).applyQuaternion(Ar),i[h+l++]=$e.x,i[h+l++]=$e.y,i[h+l++]=$e.z,i[h+l++]=vt.cross($e).length()*(d.isCircular?Math.PI/4:1);else if(d.isSpotLight){const b=d.radius||0;js.setFromMatrixPosition(d.matrixWorld),Mr.setFromMatrixPosition(d.target.matrixWorld),Gs.lookAt(js,Mr,wl),Ar.setFromRotationMatrix(Gs),vt.set(1,0,0).applyQuaternion(Ar),i[h+l++]=vt.x,i[h+l++]=vt.y,i[h+l++]=vt.z,l++,$e.set(0,1,0).applyQuaternion(Ar),i[h+l++]=$e.x,i[h+l++]=$e.y,i[h+l++]=$e.z,i[h+l++]=Math.PI*b*b,i[h+l++]=b,i[h+l++]=d.decay,i[h+l++]=d.distance,i[h+l++]=Math.cos(d.angle),i[h+l++]=Math.cos(d.angle*(1-d.penumbra)),i[h+l++]=d.iesMap?t.indexOf(d.iesMap):-1}else if(d.isPointLight){const b=vt.setFromMatrixPosition(d.matrixWorld);i[h+l++]=b.x,i[h+l++]=b.y,i[h+l++]=b.z,l++,l+=4,l+=1,i[h+l++]=d.decay,i[h+l++]=d.distance}else if(d.isDirectionalLight){const b=vt.setFromMatrixPosition(d.matrixWorld),T=$e.setFromMatrixPosition(d.target.matrixWorld);Mr.subVectors(b,T).normalize(),i[h+l++]=Mr.x,i[h+l++]=Mr.y,i[h+l++]=Mr.z}}this.count=e.length;const a=Mi(i.buffer);return this.hash!==a?(this.hash=a,r.needsUpdate=!0,!0):!1}}function Ws(s,e,t,r,n){if(e>r)throw new Error;const o=s.length/e,i=s.constructor.BYTES_PER_ELEMENT*8;let a=1;switch(s.constructor){case Uint8Array:case Uint16Array:case Uint32Array:a=2**i-1;break;case Int8Array:case Int16Array:case Int32Array:a=2**(i-1)-1;break}for(let c=0;c<o;c++){const u=4*c,d=e*c;for(let h=0;h<r;h++)t[n+u+h]=e>=h+1?s[d+h]/a:0}}class Tl extends f.DataArrayTexture{constructor(){super(),this._textures=[],this.type=f.FloatType,this.format=f.RGBAFormat,this.internalFormat="RGBA32F"}updateAttribute(e,t){const r=this._textures[e];r.updateFrom(t);const n=r.image,o=this.image;if(n.width!==o.width||n.height!==o.height)throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");const{width:i,height:a,data:c}=o,d=i*a*4*e;let h=t.itemSize;h===3&&(h=4),Ws(r.image.data,h,c,4,d),this.dispose(),this.needsUpdate=!0}setAttributes(e){const t=e[0].count,r=e.length;for(let h=0,l=r;h<l;h++)if(e[h].count!==t)throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");const n=this._textures;for(;n.length<r;){const h=new Ps;n.push(h)}for(;n.length>r;)n.pop();for(let h=0,l=r;h<l;h++)n[h].updateFrom(e[h]);const i=n[0].image,a=this.image;(i.width!==a.width||i.height!==a.height||i.depth!==r)&&(a.width=i.width,a.height=i.height,a.depth=r,a.data=new Float32Array(a.width*a.height*a.depth*4));const{data:c,width:u,height:d}=a;for(let h=0,l=r;h<l;h++){const v=n[h],T=u*d*4*h;let g=e[h].itemSize;g===3&&(g=4),Ws(v.image.data,g,c,4,T)}this.dispose(),this.needsUpdate=!0}}class Sl extends Tl{updateNormalAttribute(e){this.updateAttribute(0,e)}updateTangentAttribute(e){this.updateAttribute(1,e)}updateUvAttribute(e){this.updateAttribute(2,e)}updateColorAttribute(e){this.updateAttribute(3,e)}updateFrom(e,t,r,n){this.setAttributes([e,t,r,n])}}function Oi(s,e){return s.uuid<e.uuid?1:s.uuid>e.uuid?-1:0}function Li(s){return`${s.source.uuid}:${s.colorSpace}`}function Al(s){const e=new Set,t=[];for(let r=0,n=s.length;r<n;r++){const o=s[r],i=Li(o);e.has(i)||(e.add(i),t.push(o))}return t}function Ml(s){const e=s.map(r=>r.iesMap||null).filter(r=>r),t=new Set(e);return Array.from(t).sort(Oi)}function Il(s){const e=new Set;for(let r=0,n=s.length;r<n;r++){const o=s[r];for(const i in o){const a=o[i];a&&a.isTexture&&e.add(a)}}const t=Array.from(e);return Al(t).sort(Oi)}function Cl(s){const e=[];return s.traverse(t=>{t.visible&&(t.isRectAreaLight||t.isSpotLight||t.isPointLight||t.isDirectionalLight)&&e.push(t)}),e.sort(Oi)}const Ys=45,Zs=Ys*4;class Pl{constructor(){this._features={}}isUsed(e){return e in this._features}setUsed(e,t=!0){t===!1?delete this._features[e]:this._features[e]=!0}reset(){this._features={}}}class Dl extends f.DataTexture{constructor(){super(new Float32Array(4),1,1),this.format=f.RGBAFormat,this.type=f.FloatType,this.wrapS=f.ClampToEdgeWrapping,this.wrapT=f.ClampToEdgeWrapping,this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.generateMipmaps=!1,this.features=new Pl}updateFrom(e,t){function r(b,T,g=-1){if(T in b&&b[T]){const x=Li(b[T]);return h[x]}else return g}function n(b,T,g){return T in b?b[T]:g}function o(b,T,g,x){const w=b[T]&&b[T].isTexture?b[T]:null;if(w){w.matrixAutoUpdate&&w.updateMatrix();const S=w.matrix.elements;let A=0;g[x+A++]=S[0],g[x+A++]=S[3],g[x+A++]=S[6],A++,g[x+A++]=S[1],g[x+A++]=S[4],g[x+A++]=S[7],A++}return 8}let i=0;const a=e.length*Ys,c=Math.ceil(Math.sqrt(a))||1,{image:u,features:d}=this,h={};for(let b=0,T=t.length;b<T;b++)h[Li(t[b])]=b;u.width!==c&&(this.dispose(),u.data=new Float32Array(c*c*4),u.width=c,u.height=c);const l=u.data;d.reset();for(let b=0,T=e.length;b<T;b++){const g=e[b];if(g.isFogVolumeMaterial){d.setUsed("FOG");for(let S=0;S<Zs;S++)l[i+S]=0;l[i+0*4+0]=g.color.r,l[i+0*4+1]=g.color.g,l[i+0*4+2]=g.color.b,l[i+2*4+3]=n(g,"emissiveIntensity",0),l[i+3*4+0]=g.emissive.r,l[i+3*4+1]=g.emissive.g,l[i+3*4+2]=g.emissive.b,l[i+13*4+1]=g.density,l[i+13*4+3]=0,l[i+14*4+2]=4,i+=Zs;continue}l[i++]=g.color.r,l[i++]=g.color.g,l[i++]=g.color.b,l[i++]=r(g,"map"),l[i++]=n(g,"metalness",0),l[i++]=r(g,"metalnessMap"),l[i++]=n(g,"roughness",0),l[i++]=r(g,"roughnessMap"),l[i++]=n(g,"ior",1.5),l[i++]=n(g,"transmission",0),l[i++]=r(g,"transmissionMap"),l[i++]=n(g,"emissiveIntensity",0),"emissive"in g?(l[i++]=g.emissive.r,l[i++]=g.emissive.g,l[i++]=g.emissive.b):(l[i++]=0,l[i++]=0,l[i++]=0),l[i++]=r(g,"emissiveMap"),l[i++]=r(g,"normalMap"),"normalScale"in g?(l[i++]=g.normalScale.x,l[i++]=g.normalScale.y):(l[i++]=1,l[i++]=1),l[i++]=n(g,"clearcoat",0),l[i++]=r(g,"clearcoatMap"),l[i++]=n(g,"clearcoatRoughness",0),l[i++]=r(g,"clearcoatRoughnessMap"),l[i++]=r(g,"clearcoatNormalMap"),"clearcoatNormalScale"in g?(l[i++]=g.clearcoatNormalScale.x,l[i++]=g.clearcoatNormalScale.y):(l[i++]=1,l[i++]=1),i++,l[i++]=n(g,"sheen",0),"sheenColor"in g?(l[i++]=g.sheenColor.r,l[i++]=g.sheenColor.g,l[i++]=g.sheenColor.b):(l[i++]=0,l[i++]=0,l[i++]=0),l[i++]=r(g,"sheenColorMap"),l[i++]=n(g,"sheenRoughness",0),l[i++]=r(g,"sheenRoughnessMap"),l[i++]=r(g,"iridescenceMap"),l[i++]=r(g,"iridescenceThicknessMap"),l[i++]=n(g,"iridescence",0),l[i++]=n(g,"iridescenceIOR",1.3);const x=n(g,"iridescenceThicknessRange",[100,400]);l[i++]=x[0],l[i++]=x[1],"specularColor"in g?(l[i++]=g.specularColor.r,l[i++]=g.specularColor.g,l[i++]=g.specularColor.b):(l[i++]=1,l[i++]=1,l[i++]=1),l[i++]=r(g,"specularColorMap"),l[i++]=n(g,"specularIntensity",1),l[i++]=r(g,"specularIntensityMap");const w=n(g,"thickness",0)===0&&n(g,"attenuationDistance",1/0)===1/0;if(l[i++]=Number(w),i++,"attenuationColor"in g?(l[i++]=g.attenuationColor.r,l[i++]=g.attenuationColor.g,l[i++]=g.attenuationColor.b):(l[i++]=1,l[i++]=1,l[i++]=1),l[i++]=n(g,"attenuationDistance",1/0),l[i++]=r(g,"alphaMap"),l[i++]=g.opacity,l[i++]=g.alphaTest,!w&&g.transmission>0)l[i++]=0;else switch(g.side){case f.FrontSide:l[i++]=1;break;case f.BackSide:l[i++]=-1;break;case f.DoubleSide:l[i++]=0;break}l[i++]=Number(n(g,"matte",!1)),l[i++]=Number(n(g,"castShadow",!0)),l[i++]=Number(g.vertexColors)|Number(g.flatShading)<<1,l[i++]=Number(g.transparent),i+=o(g,"map",l,i),i+=o(g,"metalnessMap",l,i),i+=o(g,"roughnessMap",l,i),i+=o(g,"transmissionMap",l,i),i+=o(g,"emissiveMap",l,i),i+=o(g,"normalMap",l,i),i+=o(g,"clearcoatMap",l,i),i+=o(g,"clearcoatNormalMap",l,i),i+=o(g,"clearcoatRoughnessMap",l,i),i+=o(g,"sheenColorMap",l,i),i+=o(g,"sheenRoughnessMap",l,i),i+=o(g,"iridescenceMap",l,i),i+=o(g,"iridescenceThicknessMap",l,i),i+=o(g,"specularColorMap",l,i),i+=o(g,"specularIntensityMap",l,i)}const v=Mi(l.buffer);return this.hash!==v?(this.hash=v,this.needsUpdate=!0,!0):!1}}const qs=new f.Color;function Rl(s){return s?`${s.uuid}:${s.version}`:null}function Fl(s,e){for(const t in e)t in s&&(s[t]=e[t])}class Ks extends f.WebGLArrayRenderTarget{constructor(e,t,r){const n={format:f.RGBAFormat,type:f.UnsignedByteType,minFilter:f.LinearFilter,magFilter:f.LinearFilter,wrapS:f.RepeatWrapping,wrapT:f.RepeatWrapping,generateMipmaps:!1,...r};super(e,t,1,n),Fl(this.texture,n),this.texture.setTextures=(...i)=>{this.setTextures(...i)},this.hashes=[null];const o=new Sr(new Ol);this.fsQuad=o}setTextures(e,t,r=this.width,n=this.height){const o=e.getRenderTarget(),i=e.toneMapping,a=e.getClearAlpha();e.getClearColor(qs);const c=t.length||1;(r!==this.width||n!==this.height||this.depth!==c)&&(this.setSize(r,n,c),this.hashes=new Array(c).fill(null)),e.setClearColor(0,0),e.toneMapping=f.NoToneMapping;const u=this.fsQuad,d=this.hashes;let h=!1;for(let l=0,v=c;l<v;l++){const b=t[l],T=Rl(b);b&&(d[l]!==T||b.isWebGLRenderTarget)&&(b.matrixAutoUpdate=!1,b.matrix.identity(),u.material.map=b,e.setRenderTarget(this,l),u.render(e),b.updateMatrix(),b.matrixAutoUpdate=!0,d[l]=T,h=!0)}return u.material.map=null,e.setClearColor(qs,a),e.setRenderTarget(o),e.toneMapping=i,h}dispose(){super.dispose(),this.fsQuad.dispose()}}class Ol extends f.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}constructor(){super({uniforms:{map:{value:null}},vertexShader:`
|
|
612
583
|
varying vec2 vUv;
|
|
613
584
|
void main() {
|
|
614
585
|
|
|
@@ -624,7 +595,7 @@ struct BVH {
|
|
|
624
595
|
gl_FragColor = texture2D( map, vUv );
|
|
625
596
|
|
|
626
597
|
}
|
|
627
|
-
`})}}function
|
|
598
|
+
`})}}function Ll(s,e=Math.random()){for(let t=s.length-1;t>0;t--){const r=Math.floor(e()*(t+1)),n=s[t];s[t]=s[r],s[r]=n}return s}class Nl{constructor(e,t,r=Math.random){const n=e**t,o=new Uint16Array(n);let i=n;for(let a=0;a<n;a++)o[a]=a;this.samples=new Float32Array(t),this.strataCount=e,this.reset=function(){for(let a=0;a<n;a++)o[a]=a;i=0},this.reshuffle=function(){i=0},this.next=function(){const{samples:a}=this;i>=o.length&&(Ll(o,r),this.reshuffle());let c=o[i++];for(let u=0;u<t;u++)a[u]=(c%e+r())/e,c=Math.floor(c/e);return a}}}class kl{constructor(e,t,r=Math.random){let n=0;for(const c of t)n+=c;const o=new Float32Array(n),i=[];let a=0;for(const c of t){const u=new Nl(e,c,r);u.samples=new Float32Array(o.buffer,a,u.samples.length),a+=u.samples.length*4,i.push(u)}this.samples=o,this.strataCount=e,this.next=function(){for(const c of i)c.next();return o},this.reshuffle=function(){for(const c of i)c.reshuffle()},this.reset=function(){for(const c of i)c.reset()}}}class Bl{constructor(e=0){this.m=2147483648,this.a=1103515245,this.c=12345,this.seed=e}nextInt(){return this.seed=(this.a*this.seed+this.c)%this.m,this.seed}nextFloat(){return this.nextInt()/(this.m-1)}}class zl extends f.DataTexture{constructor(e=1,t=1,r=8){super(new Float32Array(1),1,1,f.RGBAFormat,f.FloatType),this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.strata=r,this.sampler=null,this.generator=new Bl,this.stableNoise=!1,this.random=()=>this.stableNoise?this.generator.nextFloat():Math.random(),this.init(e,t,r)}init(e=this.image.height,t=this.image.width,r=this.strata){const{image:n}=this;if(n.width===t&&n.height===e&&this.sampler!==null)return;const o=new Array(e*t).fill(4),i=new kl(r,o,this.random);n.width=t,n.height=e,n.data=i.samples,this.sampler=i,this.dispose(),this.next()}next(){this.sampler.next(),this.needsUpdate=!0}reset(){this.sampler.reset(),this.generator.seed=0}}function El(s,e=Math.random){for(let t=s.length-1;t>0;t--){const r=~~((e()-1e-6)*t),n=s[t];s[t]=s[r],s[r]=n}}function Ul(s,e){s.fill(0);for(let t=0;t<e;t++)s[t]=1}class Xs{constructor(e){this.count=0,this.size=-1,this.sigma=-1,this.radius=-1,this.lookupTable=null,this.score=null,this.binaryPattern=null,this.resize(e),this.setSigma(1.5)}findVoid(){const{score:e,binaryPattern:t}=this;let r=1/0,n=-1;for(let o=0,i=t.length;o<i;o++){if(t[o]!==0)continue;const a=e[o];a<r&&(r=a,n=o)}return n}findCluster(){const{score:e,binaryPattern:t}=this;let r=-1/0,n=-1;for(let o=0,i=t.length;o<i;o++){if(t[o]!==1)continue;const a=e[o];a>r&&(r=a,n=o)}return n}setSigma(e){if(e===this.sigma)return;const t=~~(Math.sqrt(10*2*e**2)+1),r=2*t+1,n=new Float32Array(r*r),o=e*e;for(let i=-t;i<=t;i++)for(let a=-t;a<=t;a++){const c=(t+a)*r+i+t,u=i*i+a*a;n[c]=Math.E**(-u/(2*o))}this.lookupTable=n,this.sigma=e,this.radius=t}resize(e){this.size!==e&&(this.size=e,this.score=new Float32Array(e*e),this.binaryPattern=new Uint8Array(e*e))}invert(){const{binaryPattern:e,score:t,size:r}=this;t.fill(0);for(let n=0,o=e.length;n<o;n++)if(e[n]===0){const i=~~(n/r),a=n-i*r;this.updateScore(a,i,1),e[n]=1}else e[n]=0}updateScore(e,t,r){const{size:n,score:o,lookupTable:i}=this,a=this.radius,c=2*a+1;for(let u=-a;u<=a;u++)for(let d=-a;d<=a;d++){const h=(a+d)*c+u+a,l=i[h];let v=e+u;v=v<0?n+v:v%n;let b=t+d;b=b<0?n+b:b%n;const T=b*n+v;o[T]+=r*l}}addPointIndex(e){this.binaryPattern[e]=1;const t=this.size,r=~~(e/t),n=e-r*t;this.updateScore(n,r,1),this.count++}removePointIndex(e){this.binaryPattern[e]=0;const t=this.size,r=~~(e/t),n=e-r*t;this.updateScore(n,r,-1),this.count--}copy(e){this.resize(e.size),this.score.set(e.score),this.binaryPattern.set(e.binaryPattern),this.setSigma(e.sigma),this.count=e.count}}class Vl{constructor(){this.random=Math.random,this.sigma=1.5,this.size=64,this.majorityPointsRatio=.1,this.samples=new Xs(1),this.savedSamples=new Xs(1)}generate(){const{samples:e,savedSamples:t,sigma:r,majorityPointsRatio:n,size:o}=this;e.resize(o),e.setSigma(r);const i=Math.floor(o*o*n),a=e.binaryPattern;Ul(a,i),El(a,this.random);for(let h=0,l=a.length;h<l;h++)a[h]===1&&e.addPointIndex(h);for(;;){const h=e.findCluster();e.removePointIndex(h);const l=e.findVoid();if(h===l){e.addPointIndex(h);break}e.addPointIndex(l)}const c=new Uint32Array(o*o);t.copy(e);let u;for(u=e.count-1;u>=0;){const h=e.findCluster();e.removePointIndex(h),c[h]=u,u--}const d=o*o;for(u=t.count;u<d/2;){const h=t.findVoid();t.addPointIndex(h),c[h]=u,u++}for(t.invert();u<d;){const h=t.findCluster();t.removePointIndex(h),c[h]=u,u++}return{data:c,maxValue:d}}}function Gl(s){return s>=3?4:s}function jl(s){switch(s){case 1:return f.RedFormat;case 2:return f.RGFormat;default:return f.RGBAFormat}}class Wl extends f.DataTexture{constructor(e=64,t=1){super(new Float32Array(4),1,1,f.RGBAFormat,f.FloatType),this.minFilter=f.NearestFilter,this.magFilter=f.NearestFilter,this.size=e,this.channels=t,this.update()}update(){const e=this.channels,t=this.size,r=new Vl;r.channels=e,r.size=t;const n=Gl(e),o=jl(n);(this.image.width!==t||o!==this.format)&&(this.image.width=t,this.image.height=t,this.image.data=new Float32Array(t**2*n),this.format=o,this.dispose());const i=this.image.data;for(let a=0,c=e;a<c;a++){const u=r.generate(),d=u.data,h=u.maxValue;for(let l=0,v=d.length;l<v;l++){const b=d[l]/h;i[l*n+a]=b}}this.needsUpdate=!0}}const Yl=`
|
|
628
599
|
|
|
629
600
|
struct PhysicalCamera {
|
|
630
601
|
|
|
@@ -636,7 +607,7 @@ struct BVH {
|
|
|
636
607
|
|
|
637
608
|
};
|
|
638
609
|
|
|
639
|
-
`,
|
|
610
|
+
`,Zl=`
|
|
640
611
|
|
|
641
612
|
struct EquirectHdrInfo {
|
|
642
613
|
|
|
@@ -648,7 +619,7 @@ struct BVH {
|
|
|
648
619
|
|
|
649
620
|
};
|
|
650
621
|
|
|
651
|
-
`,
|
|
622
|
+
`,ql=`
|
|
652
623
|
|
|
653
624
|
#define RECT_AREA_LIGHT_TYPE 0
|
|
654
625
|
#define CIRC_AREA_LIGHT_TYPE 1
|
|
@@ -734,7 +705,7 @@ struct BVH {
|
|
|
734
705
|
|
|
735
706
|
}
|
|
736
707
|
|
|
737
|
-
|
|
708
|
+
`,Kl=`
|
|
738
709
|
|
|
739
710
|
struct Material {
|
|
740
711
|
|
|
@@ -941,7 +912,7 @@ struct BVH {
|
|
|
941
912
|
|
|
942
913
|
}
|
|
943
914
|
|
|
944
|
-
`,
|
|
915
|
+
`,Xl=`
|
|
945
916
|
|
|
946
917
|
struct SurfaceRecord {
|
|
947
918
|
|
|
@@ -1003,7 +974,7 @@ struct BVH {
|
|
|
1003
974
|
vec3 color;
|
|
1004
975
|
};
|
|
1005
976
|
|
|
1006
|
-
|
|
977
|
+
`,$l=`
|
|
1007
978
|
|
|
1008
979
|
// samples the the given environment map in the given direction
|
|
1009
980
|
vec3 sampleEquirectColor( sampler2D envMap, vec3 direction ) {
|
|
@@ -1070,7 +1041,7 @@ struct BVH {
|
|
|
1070
1041
|
return float( resolution.x * resolution.y ) * pdf * equirectDirectionPdf( direction );
|
|
1071
1042
|
|
|
1072
1043
|
}
|
|
1073
|
-
`,
|
|
1044
|
+
`,Ql=`
|
|
1074
1045
|
|
|
1075
1046
|
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
1076
1047
|
|
|
@@ -1285,7 +1256,7 @@ struct BVH {
|
|
|
1285
1256
|
|
|
1286
1257
|
}
|
|
1287
1258
|
|
|
1288
|
-
`,
|
|
1259
|
+
`,Jl=`
|
|
1289
1260
|
|
|
1290
1261
|
vec3 sampleHemisphere( vec3 n, vec2 uv ) {
|
|
1291
1262
|
|
|
@@ -1370,7 +1341,7 @@ struct BVH {
|
|
|
1370
1341
|
}
|
|
1371
1342
|
|
|
1372
1343
|
|
|
1373
|
-
`,
|
|
1344
|
+
`,Hl=`
|
|
1374
1345
|
|
|
1375
1346
|
bool totalInternalReflection( float cosTheta, float eta ) {
|
|
1376
1347
|
|
|
@@ -1473,7 +1444,7 @@ struct BVH {
|
|
|
1473
1444
|
|
|
1474
1445
|
}
|
|
1475
1446
|
|
|
1476
|
-
`,
|
|
1447
|
+
`,eu=`
|
|
1477
1448
|
|
|
1478
1449
|
// Fast arccos approximation used to remove banding artifacts caused by numerical errors in acos.
|
|
1479
1450
|
// This is a cubic Lagrange interpolating polynomial for x = [-1, -1/2, 0, 1/2, 1].
|
|
@@ -1553,7 +1524,7 @@ struct BVH {
|
|
|
1553
1524
|
|
|
1554
1525
|
}
|
|
1555
1526
|
|
|
1556
|
-
`,
|
|
1527
|
+
`,tu=`
|
|
1557
1528
|
|
|
1558
1529
|
// Finds the point where the ray intersects the plane defined by u and v and checks if this point
|
|
1559
1530
|
// falls in the bounds of the rectangle on that same plane.
|
|
@@ -1614,7 +1585,7 @@ struct BVH {
|
|
|
1614
1585
|
|
|
1615
1586
|
}
|
|
1616
1587
|
|
|
1617
|
-
`,
|
|
1588
|
+
`,ru=`
|
|
1618
1589
|
|
|
1619
1590
|
// add texel fetch functions for texture arrays
|
|
1620
1591
|
vec4 texelFetch1D( sampler2DArray tex, int layer, uint index ) {
|
|
@@ -1637,7 +1608,7 @@ struct BVH {
|
|
|
1637
1608
|
|
|
1638
1609
|
}
|
|
1639
1610
|
|
|
1640
|
-
|
|
1611
|
+
`,$s=`
|
|
1641
1612
|
|
|
1642
1613
|
// TODO: possibly this should be renamed something related to material or path tracing logic
|
|
1643
1614
|
|
|
@@ -1752,7 +1723,7 @@ struct BVH {
|
|
|
1752
1723
|
return x < 0.5 ? sqrt( 2.0 * x ) - 1.0 : 1.0 - sqrt( 2.0 - ( 2.0 * x ) );
|
|
1753
1724
|
|
|
1754
1725
|
}
|
|
1755
|
-
`,
|
|
1726
|
+
`,Qs=`
|
|
1756
1727
|
|
|
1757
1728
|
// https://www.shadertoy.com/view/wltcRS
|
|
1758
1729
|
uvec4 WHITE_NOISE_SEED;
|
|
@@ -1808,7 +1779,7 @@ struct BVH {
|
|
|
1808
1779
|
return vec4( WHITE_NOISE_SEED ) / float( 0xffffffffu );
|
|
1809
1780
|
|
|
1810
1781
|
}
|
|
1811
|
-
`,
|
|
1782
|
+
`,nu=`
|
|
1812
1783
|
|
|
1813
1784
|
uniform sampler2D stratifiedTexture;
|
|
1814
1785
|
uniform sampler2D stratifiedOffsetTexture;
|
|
@@ -1857,7 +1828,7 @@ struct BVH {
|
|
|
1857
1828
|
|
|
1858
1829
|
}
|
|
1859
1830
|
|
|
1860
|
-
`,
|
|
1831
|
+
`,iu=`
|
|
1861
1832
|
|
|
1862
1833
|
// diffuse
|
|
1863
1834
|
float diffuseEval( vec3 wo, vec3 wi, vec3 wh, SurfaceRecord surf, inout vec3 color ) {
|
|
@@ -2295,7 +2266,7 @@ struct BVH {
|
|
|
2295
2266
|
|
|
2296
2267
|
}
|
|
2297
2268
|
|
|
2298
|
-
`,
|
|
2269
|
+
`,su=`
|
|
2299
2270
|
|
|
2300
2271
|
// returns the hit distance given the material density
|
|
2301
2272
|
float intersectFogVolume( Material material, float u ) {
|
|
@@ -2316,7 +2287,7 @@ struct BVH {
|
|
|
2316
2287
|
|
|
2317
2288
|
}
|
|
2318
2289
|
|
|
2319
|
-
`,
|
|
2290
|
+
`,ou=`
|
|
2320
2291
|
|
|
2321
2292
|
// The GGX functions provide sampling and distribution information for normals as output so
|
|
2322
2293
|
// in order to get probability of scatter direction the half vector must be computed and provided.
|
|
@@ -2417,7 +2388,7 @@ struct BVH {
|
|
|
2417
2388
|
|
|
2418
2389
|
}
|
|
2419
2390
|
|
|
2420
|
-
`,
|
|
2391
|
+
`,au=`
|
|
2421
2392
|
|
|
2422
2393
|
// XYZ to sRGB color space
|
|
2423
2394
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
@@ -2551,7 +2522,7 @@ struct BVH {
|
|
|
2551
2522
|
|
|
2552
2523
|
}
|
|
2553
2524
|
|
|
2554
|
-
`,
|
|
2525
|
+
`,cu=`
|
|
2555
2526
|
|
|
2556
2527
|
// See equation (2) in http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
|
|
2557
2528
|
float velvetD( float cosThetaH, float roughness ) {
|
|
@@ -2648,7 +2619,7 @@ struct BVH {
|
|
|
2648
2619
|
|
|
2649
2620
|
}
|
|
2650
2621
|
|
|
2651
|
-
`,
|
|
2622
|
+
`,lu=`
|
|
2652
2623
|
|
|
2653
2624
|
#ifndef FOG_CHECK_ITERATIONS
|
|
2654
2625
|
#define FOG_CHECK_ITERATIONS 30
|
|
@@ -2709,7 +2680,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
2709
2680
|
|
|
2710
2681
|
}
|
|
2711
2682
|
|
|
2712
|
-
`,
|
|
2683
|
+
`,uu=`
|
|
2713
2684
|
|
|
2714
2685
|
// step through multiple surface hits and accumulate color attenuation based on transmissive surfaces
|
|
2715
2686
|
// returns true if a solid surface was hit
|
|
@@ -2886,7 +2857,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
2886
2857
|
|
|
2887
2858
|
}
|
|
2888
2859
|
|
|
2889
|
-
`,
|
|
2860
|
+
`,hu=`
|
|
2890
2861
|
|
|
2891
2862
|
vec3 ndcToRayOrigin( vec2 coord ) {
|
|
2892
2863
|
|
|
@@ -2969,7 +2940,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
2969
2940
|
|
|
2970
2941
|
}
|
|
2971
2942
|
|
|
2972
|
-
`,
|
|
2943
|
+
`,fu=`
|
|
2973
2944
|
|
|
2974
2945
|
vec3 directLightContribution( vec3 worldWo, SurfaceRecord surf, RenderState state, vec3 rayOrigin ) {
|
|
2975
2946
|
|
|
@@ -3065,7 +3036,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3065
3036
|
|
|
3066
3037
|
}
|
|
3067
3038
|
|
|
3068
|
-
`,
|
|
3039
|
+
`,du=`
|
|
3069
3040
|
|
|
3070
3041
|
#define SKIP_SURFACE 0
|
|
3071
3042
|
#define HIT_SURFACE 1
|
|
@@ -3387,7 +3358,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3387
3358
|
return HIT_SURFACE;
|
|
3388
3359
|
|
|
3389
3360
|
}
|
|
3390
|
-
`,
|
|
3361
|
+
`,pu=`
|
|
3391
3362
|
|
|
3392
3363
|
struct Ray {
|
|
3393
3364
|
|
|
@@ -3436,7 +3407,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3436
3407
|
|
|
3437
3408
|
}
|
|
3438
3409
|
|
|
3439
|
-
`,
|
|
3410
|
+
`,mu=`
|
|
3440
3411
|
|
|
3441
3412
|
#define NO_HIT 0
|
|
3442
3413
|
#define SURFACE_HIT 1
|
|
@@ -3483,7 +3454,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3483
3454
|
|
|
3484
3455
|
}
|
|
3485
3456
|
|
|
3486
|
-
`;class
|
|
3457
|
+
`;class gu extends Di{onBeforeRender(){this.setDefine("FEATURE_DOF",this.physicalCamera.bokehSize===0?0:1),this.setDefine("FEATURE_BACKGROUND_MAP",this.backgroundMap?1:0),this.setDefine("FEATURE_FOG",this.materials.features.isUsed("FOG")?1:0)}constructor(e){super({transparent:!0,depthWrite:!1,defines:{FEATURE_MIS:1,FEATURE_RUSSIAN_ROULETTE:1,FEATURE_DOF:1,FEATURE_BACKGROUND_MAP:0,FEATURE_FOG:1,RANDOM_TYPE:2,CAMERA_TYPE:0,DEBUG_MODE:0,ATTR_NORMAL:0,ATTR_TANGENT:1,ATTR_UV:2,ATTR_COLOR:3},uniforms:{resolution:{value:new f.Vector2},opacity:{value:1},bounces:{value:10},transmissiveBounces:{value:10},filterGlossyFactor:{value:0},physicalCamera:{value:new fl},cameraWorldMatrix:{value:new f.Matrix4},invProjectionMatrix:{value:new f.Matrix4},bvh:{value:new Fc},attributesArray:{value:new Sl},materialIndexAttribute:{value:new Cs},materials:{value:new Dl},textures:{value:new Ks().texture},lights:{value:new _l},iesProfiles:{value:new Ks(360,180,{type:f.HalfFloatType,wrapS:f.ClampToEdgeWrapping,wrapT:f.ClampToEdgeWrapping}).texture},environmentIntensity:{value:1},environmentRotation:{value:new f.Matrix4},envMapInfo:{value:new ml},backgroundBlur:{value:0},backgroundMap:{value:null},backgroundAlpha:{value:1},backgroundIntensity:{value:1},backgroundRotation:{value:new f.Matrix4},seed:{value:0},sobolTexture:{value:null},stratifiedTexture:{value:new zl},stratifiedOffsetTexture:{value:new Wl(64,1)}},vertexShader:`
|
|
3487
3458
|
|
|
3488
3459
|
varying vec2 vUv;
|
|
3489
3460
|
void main() {
|
|
@@ -3507,27 +3478,27 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3507
3478
|
#include <common>
|
|
3508
3479
|
|
|
3509
3480
|
// bvh intersection
|
|
3510
|
-
${
|
|
3511
|
-
${
|
|
3512
|
-
${
|
|
3481
|
+
${Nc}
|
|
3482
|
+
${Bc}
|
|
3483
|
+
${kc}
|
|
3513
3484
|
|
|
3514
3485
|
// uniform structs
|
|
3515
|
-
${
|
|
3516
|
-
${
|
|
3517
|
-
${
|
|
3518
|
-
${
|
|
3519
|
-
${
|
|
3486
|
+
${Yl}
|
|
3487
|
+
${ql}
|
|
3488
|
+
${Zl}
|
|
3489
|
+
${Kl}
|
|
3490
|
+
${Xl}
|
|
3520
3491
|
|
|
3521
3492
|
// random
|
|
3522
3493
|
#if RANDOM_TYPE == 2 // Stratified List
|
|
3523
3494
|
|
|
3524
|
-
${
|
|
3495
|
+
${nu}
|
|
3525
3496
|
|
|
3526
3497
|
#elif RANDOM_TYPE == 1 // Sobol
|
|
3527
3498
|
|
|
3528
|
-
${
|
|
3529
|
-
${
|
|
3530
|
-
${
|
|
3499
|
+
${Qs}
|
|
3500
|
+
${Us}
|
|
3501
|
+
${cl}
|
|
3531
3502
|
|
|
3532
3503
|
#define rand(v) sobol(v)
|
|
3533
3504
|
#define rand2(v) sobol2(v)
|
|
@@ -3536,7 +3507,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3536
3507
|
|
|
3537
3508
|
#else // PCG
|
|
3538
3509
|
|
|
3539
|
-
${
|
|
3510
|
+
${Qs}
|
|
3540
3511
|
|
|
3541
3512
|
// Using the sobol functions seems to break the the compiler on MacOS
|
|
3542
3513
|
// - specifically the "sobolReverseBits" function.
|
|
@@ -3552,11 +3523,11 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3552
3523
|
#endif
|
|
3553
3524
|
|
|
3554
3525
|
// common
|
|
3555
|
-
${
|
|
3556
|
-
${
|
|
3557
|
-
${
|
|
3558
|
-
${
|
|
3559
|
-
${
|
|
3526
|
+
${ru}
|
|
3527
|
+
${Hl}
|
|
3528
|
+
${$s}
|
|
3529
|
+
${eu}
|
|
3530
|
+
${tu}
|
|
3560
3531
|
|
|
3561
3532
|
// environment
|
|
3562
3533
|
uniform EquirectHdrInfo envMapInfo;
|
|
@@ -3612,16 +3583,16 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3612
3583
|
float lightsDenom;
|
|
3613
3584
|
|
|
3614
3585
|
// sampling
|
|
3615
|
-
${
|
|
3616
|
-
${
|
|
3617
|
-
${
|
|
3586
|
+
${Jl}
|
|
3587
|
+
${$l}
|
|
3588
|
+
${Ql}
|
|
3618
3589
|
|
|
3619
|
-
${
|
|
3620
|
-
${
|
|
3621
|
-
${
|
|
3622
|
-
${
|
|
3623
|
-
${
|
|
3624
|
-
${
|
|
3590
|
+
${lu}
|
|
3591
|
+
${ou}
|
|
3592
|
+
${cu}
|
|
3593
|
+
${au}
|
|
3594
|
+
${su}
|
|
3595
|
+
${iu}
|
|
3625
3596
|
|
|
3626
3597
|
float applyFilteredGlossy( float roughness, float accumulatedRoughness ) {
|
|
3627
3598
|
|
|
@@ -3653,12 +3624,12 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3653
3624
|
|
|
3654
3625
|
}
|
|
3655
3626
|
|
|
3656
|
-
${
|
|
3657
|
-
${
|
|
3658
|
-
${
|
|
3659
|
-
${
|
|
3660
|
-
${
|
|
3661
|
-
${
|
|
3627
|
+
${pu}
|
|
3628
|
+
${hu}
|
|
3629
|
+
${mu}
|
|
3630
|
+
${uu}
|
|
3631
|
+
${fu}
|
|
3632
|
+
${du}
|
|
3662
3633
|
|
|
3663
3634
|
void main() {
|
|
3664
3635
|
|
|
@@ -3950,7 +3921,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
3950
3921
|
|
|
3951
3922
|
}
|
|
3952
3923
|
|
|
3953
|
-
`}),this.setValues(e)}}function*
|
|
3924
|
+
`}),this.setValues(e)}}function*vu(){const{_renderer:s,_fsQuad:e,_blendQuad:t,_primaryTarget:r,_blendTargets:n,_sobolTarget:o,_subframe:i,alpha:a,material:c}=this,u=new f.Vector4,d=new f.Vector4,h=t.material;let[l,v]=n;for(;;){a?(h.opacity=this._opacityFactor/(this.samples+1),c.blending=f.NoBlending,c.opacity=1):(c.opacity=this._opacityFactor/(this.samples+1),c.blending=f.NormalBlending);const[b,T,g,x]=i,w=r.width,S=r.height;c.resolution.set(w*g,S*x),c.sobolTexture=o.texture,c.stratifiedTexture.init(20,c.bounces+c.transmissiveBounces+5),c.stratifiedTexture.next(),c.seed++;const A=this.tiles.x||1,P=this.tiles.y||1,D=A*P,F=Math.ceil(w*g),O=Math.ceil(S*x),L=Math.floor(b*w),E=Math.floor(T*S),V=Math.ceil(F/A),z=Math.ceil(O/P);for(let G=0;G<P;G++)for(let U=0;U<A;U++){const H=s.getRenderTarget(),ne=s.autoClear,ge=s.getScissorTest();s.getScissor(u),s.getViewport(d);let Pe=U,ve=G;if(!this.stableTiles){const Ue=this._currentTile%(A*P);Pe=Ue%A,ve=~~(Ue/A),this._currentTile=Ue+1}const ye=P-ve-1;r.scissor.set(L+Pe*V,E+ye*z,Math.min(V,F-Pe*V),Math.min(z,O-ye*z)),r.viewport.set(L,E,F,O),s.setRenderTarget(r),s.setScissorTest(!0),s.autoClear=!1,e.render(s),s.setViewport(d),s.setScissor(u),s.setScissorTest(ge),s.setRenderTarget(H),s.autoClear=ne,a&&(h.target1=l.texture,h.target2=r.texture,s.setRenderTarget(v),t.render(s),s.setRenderTarget(H)),this.samples+=1/D,U===A-1&&G===P-1&&(this.samples=Math.round(this.samples)),yield}[l,v]=[v,l]}}const Js=new f.Color;class Hs{get material(){return this._fsQuad.material}set material(e){this._fsQuad.material.removeEventListener("recompilation",this._compileFunction),e.addEventListener("recompilation",this._compileFunction),this._fsQuad.material=e}get target(){return this._alpha?this._blendTargets[1]:this._primaryTarget}set alpha(e){this._alpha!==e&&(e||(this._blendTargets[0].dispose(),this._blendTargets[1].dispose()),this._alpha=e,this.reset())}get alpha(){return this._alpha}get isCompiling(){return!!this._compilePromise}constructor(e){this.camera=null,this.tiles=new f.Vector2(3,3),this.stableNoise=!1,this.stableTiles=!0,this.samples=0,this._subframe=new f.Vector4(0,0,1,1),this._opacityFactor=1,this._renderer=e,this._alpha=!1,this._fsQuad=new Sr(new gu),this._blendQuad=new Sr(new ol),this._task=null,this._currentTile=0,this._compilePromise=null,this._sobolTarget=new ul().generate(e),this._primaryTarget=new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter}),this._blendTargets=[new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter}),new f.WebGLRenderTarget(1,1,{format:f.RGBAFormat,type:f.FloatType,magFilter:f.NearestFilter,minFilter:f.NearestFilter})],this._compileFunction=()=>{const t=this.compileMaterial(this._fsQuad._mesh);t.then(()=>{this._compilePromise===t&&(this._compilePromise=null)}),this._compilePromise=t},this.material.addEventListener("recompilation",this._compileFunction)}compileMaterial(){return this._renderer.compileAsync(this._fsQuad._mesh)}setCamera(e){const{material:t}=this;t.cameraWorldMatrix.copy(e.matrixWorld),t.invProjectionMatrix.copy(e.projectionMatrixInverse),t.physicalCamera.updateFrom(e);let r=0;e.projectionMatrix.elements[15]>0&&(r=1),e.isEquirectCamera&&(r=2),t.setDefine("CAMERA_TYPE",r),this.camera=e}setSize(e,t){e=Math.ceil(e),t=Math.ceil(t),!(this._primaryTarget.width===e&&this._primaryTarget.height===t)&&(this._primaryTarget.setSize(e,t),this._blendTargets[0].setSize(e,t),this._blendTargets[1].setSize(e,t),this.reset())}getSize(e){e.x=this._primaryTarget.width,e.y=this._primaryTarget.height}dispose(){this._primaryTarget.dispose(),this._blendTargets[0].dispose(),this._blendTargets[1].dispose(),this._sobolTarget.dispose(),this._fsQuad.dispose(),this._blendQuad.dispose(),this._task=null}reset(){const{_renderer:e,_primaryTarget:t,_blendTargets:r}=this,n=e.getRenderTarget(),o=e.getClearAlpha();e.getClearColor(Js),e.setRenderTarget(t),e.setClearColor(0,0),e.clearColor(),e.setRenderTarget(r[0]),e.setClearColor(0,0),e.clearColor(),e.setRenderTarget(r[1]),e.setClearColor(0,0),e.clearColor(),e.setClearColor(Js,o),e.setRenderTarget(n),this.samples=0,this._task=null,this.material.stratifiedTexture.stableNoise=this.stableNoise,this.stableNoise&&(this.material.seed=0,this.material.stratifiedTexture.reset())}update(){this.material.onBeforeRender(),!this.isCompiling&&(this._task||(this._task=vu.call(this)),this._task.next())}}const $t=new f.Vector2,eo=new f.Vector2,Bn=new f.Spherical,zn=new f.Color;class yu extends f.DataTexture{constructor(e=512,t=512){super(new Float32Array(e*t*4),e,t,f.RGBAFormat,f.FloatType,f.EquirectangularReflectionMapping,f.RepeatWrapping,f.ClampToEdgeWrapping,f.LinearFilter,f.LinearFilter),this.generationCallback=null}update(){this.dispose(),this.needsUpdate=!0;const{data:e,width:t,height:r}=this.image;for(let n=0;n<t;n++)for(let o=0;o<r;o++){eo.set(t,r),$t.set(n/t,o/r),$t.x-=.5,$t.y=1-$t.y,Bn.theta=$t.x*2*Math.PI,Bn.phi=$t.y*Math.PI,Bn.radius=1,this.generationCallback(Bn,$t,eo,zn);const a=4*(o*t+n);e[a+0]=zn.r,e[a+1]=zn.g,e[a+2]=zn.b,e[a+3]=1}}copy(e){return super.copy(e),this.generationCallback=e.generationCallback,this}}const to=new f.Vector3;class bu extends yu{constructor(e=512){super(e,e),this.topColor=new f.Color().set(16777215),this.bottomColor=new f.Color().set(0),this.exponent=2,this.generationCallback=(t,r,n,o)=>{to.setFromSpherical(t);const i=to.y*.5+.5;o.lerpColors(this.bottomColor,this.topColor,i**this.exponent)}}copy(e){return super.copy(e),this.topColor.copy(e.topColor),this.bottomColor.copy(e.bottomColor),this}}class xu extends f.ShaderMaterial{get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}constructor(e){super({uniforms:{map:{value:null},opacity:{value:1}},vertexShader:`
|
|
3954
3925
|
varying vec2 vUv;
|
|
3955
3926
|
void main() {
|
|
3956
3927
|
|
|
@@ -4007,7 +3978,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4007
3978
|
#include <premultiplied_alpha_fragment>
|
|
4008
3979
|
|
|
4009
3980
|
}
|
|
4010
|
-
`}),this.setValues(e)}}class
|
|
3981
|
+
`}),this.setValues(e)}}class wu extends f.ShaderMaterial{constructor(){super({uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:`
|
|
4011
3982
|
varying vec2 vUv;
|
|
4012
3983
|
void main() {
|
|
4013
3984
|
|
|
@@ -4024,7 +3995,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4024
3995
|
#include <common>
|
|
4025
3996
|
#include <cube_uv_reflection_fragment>
|
|
4026
3997
|
|
|
4027
|
-
${
|
|
3998
|
+
${$s}
|
|
4028
3999
|
|
|
4029
4000
|
void main() {
|
|
4030
4001
|
|
|
@@ -4032,56 +4003,42 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4032
4003
|
rayDirection.x *= flipEnvMap;
|
|
4033
4004
|
gl_FragColor = textureCube( envMap, rayDirection );
|
|
4034
4005
|
|
|
4035
|
-
}`}),this.depthWrite=!1,this.depthTest=!1}}class Nl{constructor(e){this._renderer=e,this._quad=new fr(new Rg)}generate(e,n=null,i=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const s=e.images[0],c=this._renderer,a=this._quad;n===null&&(n=4*s.height),i===null&&(i=2*s.height);const u=new m.WebGLRenderTarget(n,i,{type:m.FloatType,colorSpace:s.colorSpace}),f=s.height,p=Math.log2(f)-2,v=1/f,g=1/(3*Math.max(Math.pow(2,p),7*16));a.material.defines.CUBEUV_MAX_MIP=`${p}.0`,a.material.defines.CUBEUV_TEXEL_WIDTH=g,a.material.defines.CUBEUV_TEXEL_HEIGHT=v,a.material.uniforms.envMap.value=e,a.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,a.material.needsUpdate=!0;const h=c.getRenderTarget(),b=c.autoClear;c.autoClear=!0,c.setRenderTarget(u),a.render(c),c.setRenderTarget(h),c.autoClear=b;const R=new Uint16Array(n*i*4),M=new Float32Array(n*i*4);c.readRenderTargetPixels(u,0,0,n,i,M),u.dispose();for(let A=0,E=M.length;A<E;A++)R[A]=m.DataUtils.toHalfFloat(M[A]);const x=new m.DataTexture(R,n,i,m.RGBAFormat,m.HalfFloatType);return x.minFilter=m.LinearMipMapLinearFilter,x.magFilter=m.LinearFilter,x.wrapS=m.RepeatWrapping,x.wrapT=m.RepeatWrapping,x.mapping=m.EquirectangularReflectionMapping,x.needsUpdate=!0,x}dispose(){this._quad.dispose()}}function Ag(o){return o.extensions.get("EXT_float_blend")}const Jr=new m.Vector2;class Eg{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine("FEATURE_MIS",e?1:0)}get transmissiveBounces(){return this._pathTracer.material.transmissiveBounces}set transmissiveBounces(e){this._pathTracer.material.transmissiveBounces=e}get bounces(){return this._pathTracer.material.bounces}set bounces(e){this._pathTracer.material.bounces=e}get filterGlossyFactor(){return this._pathTracer.material.filterGlossyFactor}set filterGlossyFactor(e){this._pathTracer.material.filterGlossyFactor=e}get samples(){return this._pathTracer.samples}get target(){return this._pathTracer.target}get tiles(){return this._pathTracer.tiles}get stableNoise(){return this._pathTracer.stableNoise}set stableNoise(e){this._pathTracer.stableNoise=e}get isCompiling(){return!!this._pathTracer.isCompiling}constructor(e){this._renderer=e,this._generator=new am,this._pathTracer=new Fl(e),this._queueReset=!1,this._clock=new m.Clock,this._compilePromise=null,this._lowResPathTracer=new Fl(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new fr(new wg({map:null,transparent:!0,blending:m.NoBlending,premultipliedAlpha:e.getContextAttributes().premultipliedAlpha})),this._materials=null,this._previousEnvironment=null,this._previousBackground=null,this._internalBackground=null,this.renderDelay=100,this.minSamples=5,this.fadeDuration=500,this.enablePathTracing=!0,this.pausePathTracing=!1,this.dynamicLowRes=!1,this.lowResScale=.25,this.renderScale=1,this.synchronizeRenderSize=!0,this.rasterizeScene=!0,this.renderToCanvas=!0,this.textureSize=new m.Vector2(1024,1024),this.rasterizeSceneCallback=(n,i)=>{this._renderer.render(n,i)},this.renderToCanvasCallback=(n,i,s)=>{const c=i.autoClear;i.autoClear=!1,s.render(i),i.autoClear=c},this.setScene(new m.Scene,new m.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,n,i={}){e.updateMatrixWorld(!0),n.updateMatrixWorld();const s=this._generator;if(s.setObjects(e),this._buildAsync)return s.generateAsync(i.onProgress).then(c=>this._updateFromResults(e,n,c));{const c=s.generate();return this._updateFromResults(e,n,c)}}setSceneAsync(...e){this._buildAsync=!0;const n=this.setScene(...e);return this._buildAsync=!1,n}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){const e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){const e=this._pathTracer.material,n=this._renderer,i=this._materials,s=this.textureSize,c=Im(i);e.textures.setTextures(n,c,s.x,s.y),e.materials.updateFrom(i,c),this.reset()}updateLights(){const e=this.scene,n=this._renderer,i=this._pathTracer.material,s=Pm(e),c=Cm(s);i.lights.updateFrom(s,c),i.iesProfiles.setTextures(n,c),this.reset()}updateEnvironment(){const e=this.scene,n=this._pathTracer.material;if(this._internalBackground&&(this._internalBackground.dispose(),this._internalBackground=null),n.backgroundBlur=e.backgroundBlurriness,n.backgroundIntensity=e.backgroundIntensity??1,n.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(),e.background===null)n.backgroundMap=null,n.backgroundAlpha=0;else if(e.background.isColor){this._colorBackground=this._colorBackground||new Tg(16);const i=this._colorBackground;i.topColor.equals(e.background)||(i.topColor.set(e.background),i.bottomColor.set(e.background),i.update()),n.backgroundMap=i,n.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){const i=new Nl(this._renderer).generate(e.background);this._internalBackground=i,n.backgroundMap=i,n.backgroundAlpha=1}}else n.backgroundMap=e.background,n.backgroundAlpha=1;if(n.environmentIntensity=e.environmentIntensity??1,n.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(),this._previousEnvironment!==e.environment)if(e.environment!==null)if(e.environment.isCubeTexture){const i=new Nl(this._renderer).generate(e.environment);n.envMapInfo.updateFrom(i)}else n.envMapInfo.updateFrom(e.environment);else n.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,n,i){const{materials:s,geometry:c,bvh:a,bvhChanged:u}=i;this._materials=s;const p=this._pathTracer.material;return u&&(p.bvh.updateFrom(a),p.attributesArray.updateFrom(c.attributes.normal,c.attributes.tangent,c.attributes.uv,c.attributes.color),p.materialIndexAttribute.updateFrom(c.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=n,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),i}renderSample(){const e=this._lowResPathTracer,n=this._pathTracer,i=this._renderer,s=this._clock,c=this._quad;this._updateScale(),this._queueReset&&(n.reset(),e.reset(),this._queueReset=!1,c.material.opacity=0,s.start());const a=s.getDelta()*1e3,u=s.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=u&&!this.isCompiling&&n.update(),n.alpha=n.material.backgroundAlpha!==1||!Ag(i),e.alpha=n.alpha,this.renderToCanvas){const f=this._renderer,p=this.minSamples;if(u>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?c.material.opacity=Math.min(c.material.opacity+a/this.fadeDuration,1):c.material.opacity=1),!this.enablePathTracing||this.samples<p||c.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=n.material,e.update());const v=c.material.opacity;c.material.opacity=1-c.material.opacity,c.material.map=e.target.texture,c.render(f),c.material.opacity=v}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&c.material.opacity>0&&(c.material.opacity<1&&(c.material.blending=this.dynamicLowRes?m.AdditiveBlending:m.NormalBlending),c.material.map=n.target.texture,this.renderToCanvasCallback(n.target,f,c),c.material.blending=m.NoBlending)}}reset(){this._queueReset=!0,this._pathTracer.samples=0}dispose(){this._renderQuad.dispose(),this._renderQuad.material.dispose(),this._pathTracer.dispose()}_updateScale(){if(this.synchronizeRenderSize){this._renderer.getDrawingBufferSize(Jr);const e=Math.floor(this.renderScale*Jr.x),n=Math.floor(this.renderScale*Jr.y);if(this._pathTracer.getSize(Jr),Jr.x!==e||Jr.y!==n){const i=this.lowResScale;this._pathTracer.setSize(e,n),this._lowResPathTracer.setSize(Math.floor(e*i),Math.floor(n*i))}}}}class Sg extends Rs{constructor(){super({uniforms:{envMap:{value:null},blur:{value:0}},vertexShader:`
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4006
|
+
}`}),this.depthWrite=!1,this.depthTest=!1}}class ro{constructor(e){this._renderer=e,this._quad=new Sr(new wu)}generate(e,t=null,r=null){if(!e.isCubeTexture)throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");const n=e.images[0],o=this._renderer,i=this._quad;t===null&&(t=4*n.height),r===null&&(r=2*n.height);const a=new f.WebGLRenderTarget(t,r,{type:f.FloatType,colorSpace:n.colorSpace}),c=n.height,u=Math.log2(c)-2,d=1/c,h=1/(3*Math.max(Math.pow(2,u),7*16));i.material.defines.CUBEUV_MAX_MIP=`${u}.0`,i.material.defines.CUBEUV_TEXEL_WIDTH=h,i.material.defines.CUBEUV_TEXEL_HEIGHT=d,i.material.uniforms.envMap.value=e,i.material.uniforms.flipEnvMap.value=e.isRenderTargetTexture?1:-1,i.material.needsUpdate=!0;const l=o.getRenderTarget(),v=o.autoClear;o.autoClear=!0,o.setRenderTarget(a),i.render(o),o.setRenderTarget(l),o.autoClear=v;const b=new Uint16Array(t*r*4),T=new Float32Array(t*r*4);o.readRenderTargetPixels(a,0,0,t,r,T),a.dispose();for(let x=0,w=T.length;x<w;x++)b[x]=f.DataUtils.toHalfFloat(T[x]);const g=new f.DataTexture(b,t,r,f.RGBAFormat,f.HalfFloatType);return g.minFilter=f.LinearMipMapLinearFilter,g.magFilter=f.LinearFilter,g.wrapS=f.RepeatWrapping,g.wrapT=f.RepeatWrapping,g.mapping=f.EquirectangularReflectionMapping,g.needsUpdate=!0,g}dispose(){this._quad.dispose()}}function _u(s){return s.extensions.get("EXT_float_blend")}const Ir=new f.Vector2;class Tu{get multipleImportanceSampling(){return!!this._pathTracer.material.defines.FEATURE_MIS}set multipleImportanceSampling(e){this._pathTracer.material.setDefine("FEATURE_MIS",e?1:0)}get transmissiveBounces(){return this._pathTracer.material.transmissiveBounces}set transmissiveBounces(e){this._pathTracer.material.transmissiveBounces=e}get bounces(){return this._pathTracer.material.bounces}set bounces(e){this._pathTracer.material.bounces=e}get filterGlossyFactor(){return this._pathTracer.material.filterGlossyFactor}set filterGlossyFactor(e){this._pathTracer.material.filterGlossyFactor=e}get samples(){return this._pathTracer.samples}get target(){return this._pathTracer.target}get tiles(){return this._pathTracer.tiles}get stableNoise(){return this._pathTracer.stableNoise}set stableNoise(e){this._pathTracer.stableNoise=e}get isCompiling(){return!!this._pathTracer.isCompiling}constructor(e){this._renderer=e,this._generator=new rl,this._pathTracer=new Hs(e),this._queueReset=!1,this._clock=new f.Clock,this._compilePromise=null,this._lowResPathTracer=new Hs(e),this._lowResPathTracer.tiles.set(1,1),this._quad=new Sr(new xu({map:null,transparent:!0,blending:f.NoBlending,premultipliedAlpha:e.getContextAttributes().premultipliedAlpha})),this._materials=null,this._previousEnvironment=null,this._previousBackground=null,this._internalBackground=null,this.renderDelay=100,this.minSamples=5,this.fadeDuration=500,this.enablePathTracing=!0,this.pausePathTracing=!1,this.dynamicLowRes=!1,this.lowResScale=.25,this.renderScale=1,this.synchronizeRenderSize=!0,this.rasterizeScene=!0,this.renderToCanvas=!0,this.textureSize=new f.Vector2(1024,1024),this.rasterizeSceneCallback=(t,r)=>{this._renderer.render(t,r)},this.renderToCanvasCallback=(t,r,n)=>{const o=r.autoClear;r.autoClear=!1,n.render(r),r.autoClear=o},this.setScene(new f.Scene,new f.PerspectiveCamera)}setBVHWorker(e){this._generator.setBVHWorker(e)}setScene(e,t,r={}){e.updateMatrixWorld(!0),t.updateMatrixWorld();const n=this._generator;if(n.setObjects(e),this._buildAsync)return n.generateAsync(r.onProgress).then(o=>this._updateFromResults(e,t,o));{const o=n.generate();return this._updateFromResults(e,t,o)}}setSceneAsync(...e){this._buildAsync=!0;const t=this.setScene(...e);return this._buildAsync=!1,t}setCamera(e){this.camera=e,this.updateCamera()}updateCamera(){const e=this.camera;e.updateMatrixWorld(),this._pathTracer.setCamera(e),this._lowResPathTracer.setCamera(e),this.reset()}updateMaterials(){const e=this._pathTracer.material,t=this._renderer,r=this._materials,n=this.textureSize,o=Il(r);e.textures.setTextures(t,o,n.x,n.y),e.materials.updateFrom(r,o),this.reset()}updateLights(){const e=this.scene,t=this._renderer,r=this._pathTracer.material,n=Cl(e),o=Ml(n);r.lights.updateFrom(n,o),r.iesProfiles.setTextures(t,o),this.reset()}updateEnvironment(){const e=this.scene,t=this._pathTracer.material;if(this._internalBackground&&(this._internalBackground.dispose(),this._internalBackground=null),t.backgroundBlur=e.backgroundBlurriness,t.backgroundIntensity=e.backgroundIntensity??1,t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(),e.background===null)t.backgroundMap=null,t.backgroundAlpha=0;else if(e.background.isColor){this._colorBackground=this._colorBackground||new bu(16);const r=this._colorBackground;r.topColor.equals(e.background)||(r.topColor.set(e.background),r.bottomColor.set(e.background),r.update()),t.backgroundMap=r,t.backgroundAlpha=1}else if(e.background.isCubeTexture){if(e.background!==this._previousBackground){const r=new ro(this._renderer).generate(e.background);this._internalBackground=r,t.backgroundMap=r,t.backgroundAlpha=1}}else t.backgroundMap=e.background,t.backgroundAlpha=1;if(t.environmentIntensity=e.environmentIntensity??1,t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(),this._previousEnvironment!==e.environment)if(e.environment!==null)if(e.environment.isCubeTexture){const r=new ro(this._renderer).generate(e.environment);t.envMapInfo.updateFrom(r)}else t.envMapInfo.updateFrom(e.environment);else t.environmentIntensity=0;this._previousEnvironment=e.environment,this._previousBackground=e.background,this.reset()}_updateFromResults(e,t,r){const{materials:n,geometry:o,bvh:i,bvhChanged:a}=r;this._materials=n;const u=this._pathTracer.material;return a&&(u.bvh.updateFrom(i),u.attributesArray.updateFrom(o.attributes.normal,o.attributes.tangent,o.attributes.uv,o.attributes.color),u.materialIndexAttribute.updateFrom(o.attributes.materialIndex)),this._previousScene=e,this.scene=e,this.camera=t,this.updateCamera(),this.updateMaterials(),this.updateEnvironment(),this.updateLights(),r}renderSample(){const e=this._lowResPathTracer,t=this._pathTracer,r=this._renderer,n=this._clock,o=this._quad;this._updateScale(),this._queueReset&&(t.reset(),e.reset(),this._queueReset=!1,o.material.opacity=0,n.start());const i=n.getDelta()*1e3,a=n.getElapsedTime()*1e3;if(!this.pausePathTracing&&this.enablePathTracing&&this.renderDelay<=a&&!this.isCompiling&&t.update(),t.alpha=t.material.backgroundAlpha!==1||!_u(r),e.alpha=t.alpha,this.renderToCanvas){const c=this._renderer,u=this.minSamples;if(a>=this.renderDelay&&this.samples>=this.minSamples&&(this.fadeDuration!==0?o.material.opacity=Math.min(o.material.opacity+i/this.fadeDuration,1):o.material.opacity=1),!this.enablePathTracing||this.samples<u||o.material.opacity<1){if(this.dynamicLowRes&&!this.isCompiling){e.samples<1&&(e.material=t.material,e.update());const d=o.material.opacity;o.material.opacity=1-o.material.opacity,o.material.map=e.target.texture,o.render(c),o.material.opacity=d}(!this.dynamicLowRes&&this.rasterizeScene||this.dynamicLowRes&&this.isCompiling)&&this.rasterizeSceneCallback(this.scene,this.camera)}this.enablePathTracing&&o.material.opacity>0&&(o.material.opacity<1&&(o.material.blending=this.dynamicLowRes?f.AdditiveBlending:f.NormalBlending),o.material.map=t.target.texture,this.renderToCanvasCallback(t.target,c,o),o.material.blending=f.NoBlending)}}reset(){this._queueReset=!0,this._pathTracer.samples=0}dispose(){this._renderQuad.dispose(),this._renderQuad.material.dispose(),this._pathTracer.dispose()}_updateScale(){if(this.synchronizeRenderSize){this._renderer.getDrawingBufferSize(Ir);const e=Math.floor(this.renderScale*Ir.x),t=Math.floor(this.renderScale*Ir.y);if(this._pathTracer.getSize(Ir),Ir.x!==e||Ir.y!==t){const r=this.lowResScale;this._pathTracer.setSize(e,t),this._lowResPathTracer.setSize(Math.floor(e*r),Math.floor(t*r))}}}}function no(s){return typeof s=="object"&&s!==null&&"getInternalRenderer"in s&&typeof s.getInternalRenderer=="function"}let Su=0;const io=new Set;class Au{constructor(){this.pathTracer=null,this.enabled=!1,this.renderer=null,this.sampleCount=0,this.createAttempts=0,this.maxCreateAttempts=10,this.sceneInitialized=!1,this.environmentWaitFrames=0,this.maxEnvironmentWaitFrames=300,this.disposed=!1,this.convertedEnvTexture=null,this.lastResetTime=0,this.pausedFrameBase64=null,this.imageOverlay=null,this.events=new fn,this.instanceId=++Su,io.add(this),this.settings={samples:300,bounces:4,transmissiveBounces:2,renderScale:.5,lowResScale:.5,dynamicLowRes:!0,enablePathTracing:!0}}convertToDataTexture(e){if(!e.image||!(e.image instanceof HTMLImageElement))return null;const t=e.image,r=document.createElement("canvas");r.width=t.width,r.height=t.height;const n=r.getContext("2d");if(!n)return null;n.drawImage(t,0,0);const o=n.getImageData(0,0,r.width,r.height),i=new Float32Array(o.data.length);for(let c=0;c<o.data.length;c++)i[c]=o.data[c]/255;const a=new C.DataTexture(i,r.width,r.height,C.RGBAFormat,C.FloatType);return a.mapping=e.mapping,a.wrapS=e.wrapS,a.wrapT=e.wrapT,a.magFilter=e.magFilter,a.minFilter=e.minFilter,a.anisotropy=e.anisotropy,a.needsUpdate=!0,a}async initialize(e){try{return this.renderer=e.renderer,this.enabled=e.enabled,this.isSupported()?X.ok(void 0):X.err(new ce("Path tracing is not supported in this environment",ue.PATH_TRACING_INIT_FAILED,{reason:"WebGL2 or required extensions not available"}))}catch(t){return X.err(new ce("Failed to initialize path tracing",ue.PATH_TRACING_INIT_FAILED,{originalError:t}))}}createPathTracer(){if(this.disposed)return X.err(new ce("Instance is disposed",ue.INVALID_STATE));try{let e=null,t=0;for(;!e&&t<3;){if(At(this.renderer)&&(e=this.renderer.getInternalRenderer()),!e&&t<2)return X.err(new ce("Renderer not ready, will retry",ue.RENDERER_NOT_INITIALIZED));t++}return e?(this.pathTracer=new Tu(e),this.pathTracer.tiles&&"set"in this.pathTracer.tiles&&this.pathTracer.tiles.set(1,1),this.pathTracer.bounces=this.settings.bounces,this.settings.transmissiveBounces!==void 0&&(this.pathTracer.transmissiveBounces=this.settings.transmissiveBounces),this.pathTracer.renderScale=this.settings.renderScale,this.pathTracer.dynamicLowRes=this.settings.dynamicLowRes,this.pathTracer.lowResScale=this.settings.lowResScale,this.pathTracer.environmentIntensity!==void 0&&(this.pathTracer.environmentIntensity=2),e.toneMapping!==C.ACESFilmicToneMapping&&(e.toneMapping=C.ACESFilmicToneMapping,e.toneMappingExposure=1.5),e.autoClear=!1,e.setRenderTarget(null),X.ok(void 0)):X.err(new ce("Three.js renderer not available",ue.RENDERER_NOT_INITIALIZED))}catch(e){return X.err(new ce("Failed to create path tracer",ue.PATH_TRACING_INIT_FAILED,{originalError:e}))}}setEnabled(e){if(this.enabled!==e&&(this.enabled=e,!e)){this.reset(),this.sceneInitialized=!1;const t=At(this.renderer)?this.renderer.getInternalRenderer():null;t&&(t.__pathTracingActive=!1,t.autoClear=!0)}}updateSettings(e){this.settings={...this.settings,...e},e.enablePathTracing!==void 0&&this.setEnabled(e.enablePathTracing),this.pathTracer&&(e.bounces!==void 0&&(this.pathTracer.bounces=e.bounces),e.transmissiveBounces!==void 0&&(this.pathTracer.transmissiveBounces=e.transmissiveBounces),e.renderScale!==void 0&&(this.pathTracer.renderScale=e.renderScale),e.lowResScale!==void 0&&(this.pathTracer.lowResScale=e.lowResScale),e.dynamicLowRes!==void 0&&(this.pathTracer.dynamicLowRes=e.dynamicLowRes))}async render(e,t){var r,n;if(this.disposed||!this.renderer)return X.ok(void 0);if(!this.enabled){if(this.sampleCount>=this.settings.samples&&this.sampleCount>0)return this.pathTracer&&At(this.renderer)&&this.renderer.getInternalRenderer().setRenderTarget(null),X.ok(void 0);const o=this.renderer.render(e,t);return o.ok,o}if(!this.pathTracer){this.createAttempts++;const o=this.createPathTracer();if(!o.ok){if(this.createAttempts<this.maxCreateAttempts&&((r=o.error)==null?void 0:r.message)==="Renderer not ready, will retry")return this.renderer.render(e,t);{this.enabled=!1,this.createAttempts=0;const i=this.renderer.render(e,t);return i.ok,i}}this.createAttempts=0}try{let o=null,i=null;if(e&&no(e)&&(o=e.getInternalRenderer()),t&&no(t)&&(i=t.getInternalRenderer()),!o||!i)return X.err(new ce("Could not extract Three.js scene or camera",ue.INVALID_PARAMETER));if(!this.sceneInitialized)try{const a=o.__originalEnvironmentTexture;if(!o.environment&&!a)return this.environmentWaitFrames++,this.environmentWaitFrames>=this.maxEnvironmentWaitFrames&&(this.enabled=!1,this.environmentWaitFrames=0),this.renderer.render(e,t);this.environmentWaitFrames=0;let c=null;if(a&&a.mapping===C.EquirectangularReflectionMapping){if(c=a,a.image instanceof HTMLImageElement)if(this.convertedEnvTexture)c=this.convertedEnvTexture;else{const d=this.convertToDataTexture(a);if(d)this.convertedEnvTexture=d,c=d;else throw new Error("Failed to convert environment texture to DataTexture")}const u=o.environment;o.environment=c;try{a.image&&!a.image.data&&a.image instanceof HTMLImageElement&&!a.image.complete&&await new Promise(d=>{a.image.onload=()=>{a.needsUpdate=!0,d()},a.image.onerror=h=>{d()},a.image.complete&&d()}),this.pathTracer&&this.pathTracer.setScene(o,i),this.sceneInitialized=!0,o.environment=u}catch(d){throw o.environment=u,d}}else if(((n=o.environment)==null?void 0:n.mapping)===C.EquirectangularReflectionMapping)this.pathTracer&&this.pathTracer.setScene(o,i),this.sceneInitialized=!0;else return this.enabled=!1,this.renderer.render(e,t)}catch(a){return console.warn("Scene initialization error:",a),this.renderer.render(e,t)}if(this.sceneInitialized){if(this.sampleCount===0)try{this.pathTracer&&this.pathTracer.updateLights()}catch(u){console.warn("Failed to update lights for path tracing:",u)}const a=this.renderer.render(e,t);if(!a.ok)return a;const c=At(this.renderer)?this.renderer.getInternalRenderer():null;if(c){const u=c.autoClear,d=c.getRenderTarget();c.autoClear=!1,this.pathTracer&&this.pathTracer.renderSample(),c.autoClear=u,c.setRenderTarget(d)}else throw new Error("Three.js renderer not available");if(this.sampleCount++,this.sampleCount===this.settings.samples){const u=At(this.renderer)?this.renderer.getInternalRenderer():null;if(u&&this.pathTracer)try{const d=u.autoClear;u.autoClear=!0,u.setRenderTarget(null),u.clear(!0,!0,!0);const h=this.pathTracer.copyQuad;h&&typeof h.render=="function"?h.render(u):(u.autoClear=!1,this.pathTracer.renderSample());const l=u.domElement,v=l.toDataURL("image/png");this.pausedFrameBase64=v,this.createImageOverlay(l,v),u.autoClear=d}catch(d){console.warn("Failed to capture path traced result:",d)}return this.enabled=!1,this.events.emit("pathtracing:paused",{samples:this.sampleCount}),setTimeout(()=>{this.disposePathTracingResources()},100),X.ok(void 0)}}else return this.renderer.render(e,t);return X.ok(void 0)}catch(o){return X.err(new ce("Failed to render with path tracing",ue.RENDER_FAILED,{originalError:o}))}}getSampleCount(){return this.sampleCount}isEnabled(){return this.enabled}isPathTracerDisposed(){return this.disposed}reset(){const e=performance.now();e-this.lastResetTime<50||(this.lastResetTime=e,this.sampleCount=0,this.pathTracer&&(this.pathTracer.reset(),this.sceneInitialized=!1))}createImageOverlay(e,t){const r=document.createElement("img");r.src=t,r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.width="100%",r.style.height="100%",r.style.pointerEvents="none",r.style.zIndex="1000",this.imageOverlay=r;const n=e.parentElement;n?(window.getComputedStyle(n).position==="static"&&(n.style.position="relative"),r.onload=()=>{n.appendChild(r),e.style.visibility="hidden"},r.onerror=i=>{console.error("Failed to load path traced image overlay")}):console.warn("Cannot create image overlay: canvas has no parent element")}disposePathTracingResources(){if(this.pathTracer){try{this.pathTracer.dispose()}catch(e){console.warn("Failed to dispose path tracer:",e)}this.pathTracer=null}if(this.convertedEnvTexture&&(this.convertedEnvTexture.dispose(),this.convertedEnvTexture=null),this.renderer){const e=At(this.renderer)?this.renderer.getInternalRenderer():null;e&&(e.__pathTracingActive=!1,e.autoClear=!0)}this.sceneInitialized=!1,this.createAttempts=0}dispose(){if(this.disposed=!0,io.delete(this),this.imageOverlay&&this.imageOverlay.parentElement&&(this.imageOverlay.parentElement.removeChild(this.imageOverlay),this.imageOverlay=null),this.renderer){const e=At(this.renderer)?this.renderer.getInternalRenderer():null;e&&(e.__pathTracingActive=!1)}if(this.pathTracer){try{this.pathTracer.dispose()}catch(e){console.warn("Failed to dispose path tracer during service disposal:",e)}this.pathTracer=null}this.convertedEnvTexture&&(this.convertedEnvTexture.dispose(),this.convertedEnvTexture=null),this.sampleCount=0,this.sceneInitialized=!1,this.createAttempts=0,this.renderer=null}isSupported(){return document.createElement("canvas").getContext("webgl2")!==null}getPausedFrameBase64(){return this.pausedFrameBase64}hasImageOverlay(){return this.imageOverlay!==null}removeImageOverlay(){if(this.imageOverlay&&this.imageOverlay.parentElement){if(this.imageOverlay.parentElement.removeChild(this.imageOverlay),this.imageOverlay=null,this.renderer){const e=At(this.renderer)?this.renderer.getInternalRenderer():null;e&&e.domElement&&(e.domElement.style.visibility="visible")}this.pausedFrameBase64=null}}}/*!
|
|
4007
|
+
fflate - fast JavaScript compression/decompression
|
|
4008
|
+
<https://101arrowz.github.io/fflate>
|
|
4009
|
+
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
4010
|
+
version 0.8.2
|
|
4011
|
+
*/var lt=Uint8Array,Cr=Uint16Array,Mu=Int32Array,so=new lt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),oo=new lt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Iu=new lt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ao=function(s,e){for(var t=new Cr(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var n=new Mu(t[30]),r=1;r<30;++r)for(var o=t[r];o<t[r+1];++o)n[o]=o-t[r]<<5|r;return{b:t,r:n}},co=ao(so,2),lo=co.b,Cu=co.r;lo[28]=258,Cu[258]=28;for(var Pu=ao(oo,0),Du=Pu.b,Ni=new Cr(32768),Ie=0;Ie<32768;++Ie){var Gt=(Ie&43690)>>1|(Ie&21845)<<1;Gt=(Gt&52428)>>2|(Gt&13107)<<2,Gt=(Gt&61680)>>4|(Gt&3855)<<4,Ni[Ie]=((Gt&65280)>>8|(Gt&255)<<8)>>1}for(var qr=function(s,e,t){for(var r=s.length,n=0,o=new Cr(e);n<r;++n)s[n]&&++o[s[n]-1];var i=new Cr(e);for(n=1;n<e;++n)i[n]=i[n-1]+o[n-1]<<1;var a;if(t){a=new Cr(1<<e);var c=15-e;for(n=0;n<r;++n)if(s[n])for(var u=n<<4|s[n],d=e-s[n],h=i[s[n]-1]++<<d,l=h|(1<<d)-1;h<=l;++h)a[Ni[h]>>c]=u}else for(a=new Cr(r),n=0;n<r;++n)s[n]&&(a[n]=Ni[i[s[n]-1]++]>>15-s[n]);return a},Kr=new lt(288),Ie=0;Ie<144;++Ie)Kr[Ie]=8;for(var Ie=144;Ie<256;++Ie)Kr[Ie]=9;for(var Ie=256;Ie<280;++Ie)Kr[Ie]=7;for(var Ie=280;Ie<288;++Ie)Kr[Ie]=8;for(var uo=new lt(32),Ie=0;Ie<32;++Ie)uo[Ie]=5;var Ru=qr(Kr,9,1),Fu=qr(uo,5,1),ki=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},yt=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},Bi=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Ou=function(s){return(s+7)/8|0},Lu=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new lt(s.subarray(e,t))},Nu=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],bt=function(s,e,t){var r=new Error(e||Nu[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,bt),!t)throw r;return r},ku=function(s,e,t,r){var n=s.length,o=0;if(!n||e.f&&!e.l)return t||new lt(0);var i=!t,a=i||e.i!=2,c=e.i;i&&(t=new lt(n*3));var u=function(Pt){var _t=t.length;if(Pt>_t){var Dt=new lt(Math.max(_t*2,Pt));Dt.set(t),t=Dt}},d=e.f||0,h=e.p||0,l=e.b||0,v=e.l,b=e.d,T=e.m,g=e.n,x=n*8;do{if(!v){d=yt(s,h,1);var w=yt(s,h+1,3);if(h+=3,w)if(w==1)v=Ru,b=Fu,T=9,g=5;else if(w==2){var D=yt(s,h,31)+257,F=yt(s,h+10,15)+4,O=D+yt(s,h+5,31)+1;h+=14;for(var L=new lt(O),E=new lt(19),V=0;V<F;++V)E[Iu[V]]=yt(s,h+V*3,7);h+=F*3;for(var z=ki(E),G=(1<<z)-1,U=qr(E,z,1),V=0;V<O;){var H=U[yt(s,h,G)];h+=H&15;var S=H>>4;if(S<16)L[V++]=S;else{var ne=0,ge=0;for(S==16?(ge=3+yt(s,h,3),h+=2,ne=L[V-1]):S==17?(ge=3+yt(s,h,7),h+=3):S==18&&(ge=11+yt(s,h,127),h+=7);ge--;)L[V++]=ne}}var Pe=L.subarray(0,D),ve=L.subarray(D);T=ki(Pe),g=ki(ve),v=qr(Pe,T,1),b=qr(ve,g,1)}else bt(1);else{var S=Ou(h)+4,A=s[S-4]|s[S-3]<<8,P=S+A;if(P>n){c&&bt(0);break}a&&u(l+A),t.set(s.subarray(S,P),l),e.b=l+=A,e.p=h=P*8,e.f=d;continue}if(h>x){c&&bt(0);break}}a&&u(l+131072);for(var ye=(1<<T)-1,Ue=(1<<g)-1,_e=h;;_e=h){var ne=v[Bi(s,h)&ye],Se=ne>>4;if(h+=ne&15,h>x){c&&bt(0);break}if(ne||bt(2),Se<256)t[l++]=Se;else if(Se==256){_e=h,v=null;break}else{var et=Se-254;if(Se>264){var V=Se-257,ut=so[V];et=yt(s,h,(1<<ut)-1)+lo[V],h+=ut}var de=b[Bi(s,h)&Ue],ze=de>>4;de||bt(3),h+=de&15;var ve=Du[ze];if(ze>3){var ut=oo[ze];ve+=Bi(s,h)&(1<<ut)-1,h+=ut}if(h>x){c&&bt(0);break}a&&u(l+131072);var ke=l+et;if(l<ve){var ht=o-ve,tt=Math.min(ve,ke);for(ht+l<0&&bt(3);l<tt;++l)t[l]=r[ht+l]}for(;l<ke;++l)t[l]=t[l-ve]}}e.l=v,e.p=_e,e.b=l,e.f=d,v&&(d=1,e.m=T,e.d=b,e.n=g)}while(!d);return l!=t.length&&i?Lu(t,0,l):t.subarray(0,l)},Bu=new lt(0),zu=function(s,e){return((s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31)&&bt(6,"invalid zlib data"),(s[1]>>5&1)==1&&bt(6,"invalid zlib data: "+(s[1]&32?"need":"unexpected")+" dictionary"),(s[1]>>3&4)+2};function En(s,e){return ku(s.subarray(zu(s),-4),{i:2},e,e)}var Eu=typeof TextDecoder<"u"&&new TextDecoder,Uu=0;try{Eu.decode(Bu,{stream:!0}),Uu=1}catch{}class Vu extends f.DataTextureLoader{constructor(e){super(e),this.type=f.HalfFloatType}parse(e){const L=Math.pow(2.7182818,2.2);function E(p,y){let _=0;for(let k=0;k<65536;++k)(k==0||p[k>>3]&1<<(k&7))&&(y[_++]=k);const M=_-1;for(;_<65536;)y[_++]=0;return M}function V(p){for(let y=0;y<16384;y++)p[y]={},p[y].len=0,p[y].lit=0,p[y].p=null}const z={l:0,c:0,lc:0};function G(p,y,_,M,k){for(;_<p;)y=y<<8|Or(M,k),_+=8;_-=p,z.l=y>>_&(1<<p)-1,z.c=y,z.lc=_}const U=new Array(59);function H(p){for(let _=0;_<=58;++_)U[_]=0;for(let _=0;_<65537;++_)U[p[_]]+=1;let y=0;for(let _=58;_>0;--_){const M=y+U[_]>>1;U[_]=y,y=M}for(let _=0;_<65537;++_){const M=p[_];M>0&&(p[_]=M|U[M]++<<6)}}function ne(p,y,_,M,k,R){const B=y;let q=0,Y=0;for(;M<=k;M++){if(B.value-y.value>_)return!1;G(6,q,Y,p,B);const j=z.l;if(q=z.c,Y=z.lc,R[M]=j,j==63){if(B.value-y.value>_)throw new Error("Something wrong with hufUnpackEncTable");G(8,q,Y,p,B);let W=z.l+6;if(q=z.c,Y=z.lc,M+W>k+1)throw new Error("Something wrong with hufUnpackEncTable");for(;W--;)R[M++]=0;M--}else if(j>=59){let W=j-59+2;if(M+W>k+1)throw new Error("Something wrong with hufUnpackEncTable");for(;W--;)R[M++]=0;M--}}H(R)}function ge(p){return p&63}function Pe(p){return p>>6}function ve(p,y,_,M){for(;y<=_;y++){const k=Pe(p[y]),R=ge(p[y]);if(k>>R)throw new Error("Invalid table entry");if(R>14){const B=M[k>>R-14];if(B.len)throw new Error("Invalid table entry");if(B.lit++,B.p){const q=B.p;B.p=new Array(B.lit);for(let Y=0;Y<B.lit-1;++Y)B.p[Y]=q[Y]}else B.p=new Array(1);B.p[B.lit-1]=y}else if(R){let B=0;for(let q=1<<14-R;q>0;q--){const Y=M[(k<<14-R)+B];if(Y.len||Y.p)throw new Error("Invalid table entry");Y.len=R,Y.lit=y,B++}}}return!0}const ye={c:0,lc:0};function Ue(p,y,_,M){p=p<<8|Or(_,M),y+=8,ye.c=p,ye.lc=y}const _e={c:0,lc:0};function Se(p,y,_,M,k,R,B,q,Y){if(p==y){M<8&&(Ue(_,M,k,R),_=ye.c,M=ye.lc),M-=8;let j=_>>M;if(j=new Uint8Array([j])[0],q.value+j>Y)return!1;const W=B[q.value-1];for(;j-- >0;)B[q.value++]=W}else if(q.value<Y)B[q.value++]=p;else return!1;_e.c=_,_e.lc=M}function et(p){return p&65535}function ut(p){const y=et(p);return y>32767?y-65536:y}const de={a:0,b:0};function ze(p,y){const _=ut(p),k=ut(y),R=_+(k&1)+(k>>1),B=R,q=R-k;de.a=B,de.b=q}function ke(p,y){const _=et(p),M=et(y),k=_-(M>>1)&65535,R=M+k-32768&65535;de.a=R,de.b=k}function ht(p,y,_,M,k,R,B){const q=B<16384,Y=_>k?k:_;let j=1,W,J;for(;j<=Y;)j<<=1;for(j>>=1,W=j,j>>=1;j>=1;){J=0;const re=J+R*(k-W),ee=R*j,le=R*W,te=M*j,se=M*W;let he,Te,Re,it;for(;J<=re;J+=le){let Ce=J;const me=J+M*(_-W);for(;Ce<=me;Ce+=se){const Be=Ce+te,pt=Ce+ee,Ee=pt+te;q?(ze(p[Ce+y],p[pt+y]),he=de.a,Re=de.b,ze(p[Be+y],p[Ee+y]),Te=de.a,it=de.b,ze(he,Te),p[Ce+y]=de.a,p[Be+y]=de.b,ze(Re,it),p[pt+y]=de.a,p[Ee+y]=de.b):(ke(p[Ce+y],p[pt+y]),he=de.a,Re=de.b,ke(p[Be+y],p[Ee+y]),Te=de.a,it=de.b,ke(he,Te),p[Ce+y]=de.a,p[Be+y]=de.b,ke(Re,it),p[pt+y]=de.a,p[Ee+y]=de.b)}if(_&j){const Be=Ce+ee;q?ze(p[Ce+y],p[Be+y]):ke(p[Ce+y],p[Be+y]),he=de.a,p[Be+y]=de.b,p[Ce+y]=he}}if(k&j){let Ce=J;const me=J+M*(_-W);for(;Ce<=me;Ce+=se){const Be=Ce+te;q?ze(p[Ce+y],p[Be+y]):ke(p[Ce+y],p[Be+y]),he=de.a,p[Be+y]=de.b,p[Ce+y]=he}}W=j,j>>=1}return J}function tt(p,y,_,M,k,R,B,q,Y){let j=0,W=0;const J=B,re=Math.trunc(M.value+(k+7)/8);for(;M.value<re;)for(Ue(j,W,_,M),j=ye.c,W=ye.lc;W>=14;){const le=j>>W-14&16383,te=y[le];if(te.len)W-=te.len,Se(te.lit,R,j,W,_,M,q,Y,J),j=_e.c,W=_e.lc;else{if(!te.p)throw new Error("hufDecode issues");let se;for(se=0;se<te.lit;se++){const he=ge(p[te.p[se]]);for(;W<he&&M.value<re;)Ue(j,W,_,M),j=ye.c,W=ye.lc;if(W>=he&&Pe(p[te.p[se]])==(j>>W-he&(1<<he)-1)){W-=he,Se(te.p[se],R,j,W,_,M,q,Y,J),j=_e.c,W=_e.lc;break}}if(se==te.lit)throw new Error("hufDecode issues")}}const ee=8-k&7;for(j>>=ee,W-=ee;W>0;){const le=y[j<<14-W&16383];if(le.len)W-=le.len,Se(le.lit,R,j,W,_,M,q,Y,J),j=_e.c,W=_e.lc;else throw new Error("hufDecode issues")}return!0}function Pt(p,y,_,M,k,R){const B={value:0},q=_.value,Y=je(y,_),j=je(y,_);_.value+=4;const W=je(y,_);if(_.value+=4,Y<0||Y>=65537||j<0||j>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const J=new Array(65537),re=new Array(16384);V(re);const ee=M-(_.value-q);if(ne(p,_,ee,Y,j,J),W>8*(M-(_.value-q)))throw new Error("Something wrong with hufUncompress");ve(J,Y,j,re),tt(J,re,p,_,W,j,R,k,B)}function _t(p,y,_){for(let M=0;M<_;++M)y[M]=p[y[M]]}function Dt(p){for(let y=1;y<p.length;y++){const _=p[y-1]+p[y]-128;p[y]=_}}function Rr(p,y){let _=0,M=Math.floor((p.length+1)/2),k=0;const R=p.length-1;for(;!(k>R||(y[k++]=p[_++],k>R));)y[k++]=p[M++]}function ft(p){let y=p.byteLength;const _=new Array;let M=0;const k=new DataView(p);for(;y>0;){const R=k.getInt8(M++);if(R<0){const B=-R;y-=B+1;for(let q=0;q<B;q++)_.push(k.getUint8(M++))}else{const B=R;y-=2;const q=k.getUint8(M++);for(let Y=0;Y<B+1;Y++)_.push(q)}}return _}function rt(p,y,_,M,k,R){let B=new DataView(R.buffer);const q=_[p.idx[0]].width,Y=_[p.idx[0]].height,j=3,W=Math.floor(q/8),J=Math.ceil(q/8),re=Math.ceil(Y/8),ee=q-(J-1)*8,le=Y-(re-1)*8,te={value:0},se=new Array(j),he=new Array(j),Te=new Array(j),Re=new Array(j),it=new Array(j);for(let me=0;me<j;++me)it[me]=y[p.idx[me]],se[me]=me<1?0:se[me-1]+J*re,he[me]=new Float32Array(64),Te[me]=new Uint16Array(64),Re[me]=new Uint16Array(J*64);for(let me=0;me<re;++me){let Be=8;me==re-1&&(Be=le);let pt=8;for(let be=0;be<J;++be){be==J-1&&(pt=ee);for(let Ae=0;Ae<j;++Ae)Te[Ae].fill(0),Te[Ae][0]=k[se[Ae]++],Qt(te,M,Te[Ae]),Jt(Te[Ae],he[Ae]),xt(he[Ae]);Qr(he);for(let Ae=0;Ae<j;++Ae)Jr(he[Ae],Re[Ae],be*64)}let Ee=0;for(let be=0;be<j;++be){const Ae=_[p.idx[be]].type;for(let Lt=8*me;Lt<8*me+Be;++Lt){Ee=it[be][Lt];for(let un=0;un<W;++un){const St=un*64+(Lt&7)*8;B.setUint16(Ee+0*2*Ae,Re[be][St+0],!0),B.setUint16(Ee+1*2*Ae,Re[be][St+1],!0),B.setUint16(Ee+2*2*Ae,Re[be][St+2],!0),B.setUint16(Ee+3*2*Ae,Re[be][St+3],!0),B.setUint16(Ee+4*2*Ae,Re[be][St+4],!0),B.setUint16(Ee+5*2*Ae,Re[be][St+5],!0),B.setUint16(Ee+6*2*Ae,Re[be][St+6],!0),B.setUint16(Ee+7*2*Ae,Re[be][St+7],!0),Ee+=8*2*Ae}}if(W!=J)for(let Lt=8*me;Lt<8*me+Be;++Lt){const un=it[be][Lt]+8*W*2*Ae,St=W*64+(Lt&7)*8;for(let Wn=0;Wn<pt;++Wn)B.setUint16(un+Wn*2*Ae,Re[be][St+Wn],!0)}}}const Ce=new Uint16Array(q);B=new DataView(R.buffer);for(let me=0;me<j;++me){_[p.idx[me]].decoded=!0;const Be=_[p.idx[me]].type;if(_[me].type==2)for(let pt=0;pt<Y;++pt){const Ee=it[me][pt];for(let be=0;be<q;++be)Ce[be]=B.getUint16(Ee+be*2*Be,!0);for(let be=0;be<q;++be)B.setFloat32(Ee+be*2*Be,K(Ce[be]),!0)}}}function Qt(p,y,_){let M,k=1;for(;k<64;)M=y[p.value],M==65280?k=64:M>>8==255?k+=M&255:(_[k]=M,k++),p.value++}function Jt(p,y){y[0]=K(p[0]),y[1]=K(p[1]),y[2]=K(p[5]),y[3]=K(p[6]),y[4]=K(p[14]),y[5]=K(p[15]),y[6]=K(p[27]),y[7]=K(p[28]),y[8]=K(p[2]),y[9]=K(p[4]),y[10]=K(p[7]),y[11]=K(p[13]),y[12]=K(p[16]),y[13]=K(p[26]),y[14]=K(p[29]),y[15]=K(p[42]),y[16]=K(p[3]),y[17]=K(p[8]),y[18]=K(p[12]),y[19]=K(p[17]),y[20]=K(p[25]),y[21]=K(p[30]),y[22]=K(p[41]),y[23]=K(p[43]),y[24]=K(p[9]),y[25]=K(p[11]),y[26]=K(p[18]),y[27]=K(p[24]),y[28]=K(p[31]),y[29]=K(p[40]),y[30]=K(p[44]),y[31]=K(p[53]),y[32]=K(p[10]),y[33]=K(p[19]),y[34]=K(p[23]),y[35]=K(p[32]),y[36]=K(p[39]),y[37]=K(p[45]),y[38]=K(p[52]),y[39]=K(p[54]),y[40]=K(p[20]),y[41]=K(p[22]),y[42]=K(p[33]),y[43]=K(p[38]),y[44]=K(p[46]),y[45]=K(p[51]),y[46]=K(p[55]),y[47]=K(p[60]),y[48]=K(p[21]),y[49]=K(p[34]),y[50]=K(p[37]),y[51]=K(p[47]),y[52]=K(p[50]),y[53]=K(p[56]),y[54]=K(p[59]),y[55]=K(p[61]),y[56]=K(p[35]),y[57]=K(p[36]),y[58]=K(p[48]),y[59]=K(p[49]),y[60]=K(p[57]),y[61]=K(p[58]),y[62]=K(p[62]),y[63]=K(p[63])}function xt(p){const y=.5*Math.cos(.7853975),_=.5*Math.cos(3.14159/16),M=.5*Math.cos(3.14159/8),k=.5*Math.cos(3*3.14159/16),R=.5*Math.cos(5*3.14159/16),B=.5*Math.cos(3*3.14159/8),q=.5*Math.cos(7*3.14159/16),Y=new Array(4),j=new Array(4),W=new Array(4),J=new Array(4);for(let re=0;re<8;++re){const ee=re*8;Y[0]=M*p[ee+2],Y[1]=B*p[ee+2],Y[2]=M*p[ee+6],Y[3]=B*p[ee+6],j[0]=_*p[ee+1]+k*p[ee+3]+R*p[ee+5]+q*p[ee+7],j[1]=k*p[ee+1]-q*p[ee+3]-_*p[ee+5]-R*p[ee+7],j[2]=R*p[ee+1]-_*p[ee+3]+q*p[ee+5]+k*p[ee+7],j[3]=q*p[ee+1]-R*p[ee+3]+k*p[ee+5]-_*p[ee+7],W[0]=y*(p[ee+0]+p[ee+4]),W[3]=y*(p[ee+0]-p[ee+4]),W[1]=Y[0]+Y[3],W[2]=Y[1]-Y[2],J[0]=W[0]+W[1],J[1]=W[3]+W[2],J[2]=W[3]-W[2],J[3]=W[0]-W[1],p[ee+0]=J[0]+j[0],p[ee+1]=J[1]+j[1],p[ee+2]=J[2]+j[2],p[ee+3]=J[3]+j[3],p[ee+4]=J[3]-j[3],p[ee+5]=J[2]-j[2],p[ee+6]=J[1]-j[1],p[ee+7]=J[0]-j[0]}for(let re=0;re<8;++re)Y[0]=M*p[16+re],Y[1]=B*p[16+re],Y[2]=M*p[48+re],Y[3]=B*p[48+re],j[0]=_*p[8+re]+k*p[24+re]+R*p[40+re]+q*p[56+re],j[1]=k*p[8+re]-q*p[24+re]-_*p[40+re]-R*p[56+re],j[2]=R*p[8+re]-_*p[24+re]+q*p[40+re]+k*p[56+re],j[3]=q*p[8+re]-R*p[24+re]+k*p[40+re]-_*p[56+re],W[0]=y*(p[re]+p[32+re]),W[3]=y*(p[re]-p[32+re]),W[1]=Y[0]+Y[3],W[2]=Y[1]-Y[2],J[0]=W[0]+W[1],J[1]=W[3]+W[2],J[2]=W[3]-W[2],J[3]=W[0]-W[1],p[0+re]=J[0]+j[0],p[8+re]=J[1]+j[1],p[16+re]=J[2]+j[2],p[24+re]=J[3]+j[3],p[32+re]=J[3]-j[3],p[40+re]=J[2]-j[2],p[48+re]=J[1]-j[1],p[56+re]=J[0]-j[0]}function Qr(p){for(let y=0;y<64;++y){const _=p[0][y],M=p[1][y],k=p[2][y];p[0][y]=_+1.5747*k,p[1][y]=_-.1873*M-.4682*k,p[2][y]=_+1.8556*M}}function Jr(p,y,_){for(let M=0;M<64;++M)y[_+M]=f.DataUtils.toHalfFloat(Rt(p[M]))}function Rt(p){return p<=1?Math.sign(p)*Math.pow(Math.abs(p),2.2):Math.sign(p)*Math.pow(L,Math.abs(p)-1)}function Ht(p){return new DataView(p.array.buffer,p.offset.value,p.size)}function Hr(p){const y=p.viewer.buffer.slice(p.offset.value,p.offset.value+p.size),_=new Uint8Array(ft(y)),M=new Uint8Array(_.length);return Dt(_),Rr(_,M),new DataView(M.buffer)}function Ft(p){const y=p.array.slice(p.offset.value,p.offset.value+p.size),_=En(y),M=new Uint8Array(_.length);return Dt(_),Rr(_,M),new DataView(M.buffer)}function er(p){const y=p.viewer,_={value:p.offset.value},M=new Uint16Array(p.columns*p.lines*(p.inputChannels.length*p.type)),k=new Uint8Array(8192);let R=0;const B=new Array(p.inputChannels.length);for(let le=0,te=p.inputChannels.length;le<te;le++)B[le]={},B[le].start=R,B[le].end=B[le].start,B[le].nx=p.columns,B[le].ny=p.lines,B[le].size=p.type,R+=B[le].nx*B[le].ny*B[le].size;const q=nt(y,_),Y=nt(y,_);if(Y>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(q<=Y)for(let le=0;le<Y-q+1;le++)k[le+q]=dt(y,_);const j=new Uint16Array(65536),W=E(k,j),J=je(y,_);Pt(p.array,y,_,J,M,R);for(let le=0;le<p.inputChannels.length;++le){const te=B[le];for(let se=0;se<B[le].size;++se)ht(M,te.start+se,te.nx,te.size,te.ny,te.nx*te.size,W)}_t(j,M,R);let re=0;const ee=new Uint8Array(M.buffer.byteLength);for(let le=0;le<p.lines;le++)for(let te=0;te<p.inputChannels.length;te++){const se=B[te],he=se.nx*se.size,Te=new Uint8Array(M.buffer,se.end*2,he*2);ee.set(Te,re),re+=he*2,se.end+=he}return new DataView(ee.buffer)}function tr(p){const y=p.array.slice(p.offset.value,p.offset.value+p.size),_=En(y),M=p.inputChannels.length*p.lines*p.columns*p.totalBytes,k=new ArrayBuffer(M),R=new DataView(k);let B=0,q=0;const Y=new Array(4);for(let j=0;j<p.lines;j++)for(let W=0;W<p.inputChannels.length;W++){let J=0;switch(p.inputChannels[W].pixelType){case 1:Y[0]=B,Y[1]=Y[0]+p.columns,B=Y[1]+p.columns;for(let ee=0;ee<p.columns;++ee){const le=_[Y[0]++]<<8|_[Y[1]++];J+=le,R.setUint16(q,J,!0),q+=2}break;case 2:Y[0]=B,Y[1]=Y[0]+p.columns,Y[2]=Y[1]+p.columns,B=Y[2]+p.columns;for(let ee=0;ee<p.columns;++ee){const le=_[Y[0]++]<<24|_[Y[1]++]<<16|_[Y[2]++]<<8;J+=le,R.setUint32(q,J,!0),q+=4}break}}return R}function Fr(p){const y=p.viewer,_={value:p.offset.value},M=new Uint8Array(p.columns*p.lines*(p.inputChannels.length*p.type*2)),k={version:Ve(y,_),unknownUncompressedSize:Ve(y,_),unknownCompressedSize:Ve(y,_),acCompressedSize:Ve(y,_),dcCompressedSize:Ve(y,_),rleCompressedSize:Ve(y,_),rleUncompressedSize:Ve(y,_),rleRawSize:Ve(y,_),totalAcUncompressedCount:Ve(y,_),totalDcUncompressedCount:Ve(y,_),acCompression:Ve(y,_)};if(k.version<2)throw new Error("EXRLoader.parse: "+Q.compression+" version "+k.version+" is unsupported");const R=new Array;let B=nt(y,_)-2;for(;B>0;){const te=Tt(y.buffer,_),se=dt(y,_),he=se>>2&3,Te=(se>>4)-1,Re=new Int8Array([Te])[0],it=dt(y,_);R.push({name:te,index:Re,type:it,compression:he}),B-=te.length+3}const q=Q.channels,Y=new Array(p.inputChannels.length);for(let te=0;te<p.inputChannels.length;++te){const se=Y[te]={},he=q[te];se.name=he.name,se.compression=0,se.decoded=!1,se.type=he.pixelType,se.pLinear=he.pLinear,se.width=p.columns,se.height=p.lines}const j={idx:new Array(3)};for(let te=0;te<p.inputChannels.length;++te){const se=Y[te];for(let he=0;he<R.length;++he){const Te=R[he];se.name==Te.name&&(se.compression=Te.compression,Te.index>=0&&(j.idx[Te.index]=te),se.offset=te)}}let W,J,re;if(k.acCompressedSize>0)switch(k.acCompression){case 0:W=new Uint16Array(k.totalAcUncompressedCount),Pt(p.array,y,_,k.acCompressedSize,W,k.totalAcUncompressedCount);break;case 1:const te=p.array.slice(_.value,_.value+k.totalAcUncompressedCount),se=En(te);W=new Uint16Array(se.buffer),_.value+=k.totalAcUncompressedCount;break}if(k.dcCompressedSize>0){const te={array:p.array,offset:_,size:k.dcCompressedSize};J=new Uint16Array(Ft(te).buffer),_.value+=k.dcCompressedSize}if(k.rleRawSize>0){const te=p.array.slice(_.value,_.value+k.rleCompressedSize),se=En(te);re=ft(se.buffer),_.value+=k.rleCompressedSize}let ee=0;const le=new Array(Y.length);for(let te=0;te<le.length;++te)le[te]=new Array;for(let te=0;te<p.lines;++te)for(let se=0;se<Y.length;++se)le[se].push(ee),ee+=Y[se].width*p.type*2;rt(j,le,Y,W,J,M);for(let te=0;te<Y.length;++te){const se=Y[te];if(!se.decoded)switch(se.compression){case 2:let he=0,Te=0;for(let Re=0;Re<p.lines;++Re){let it=le[te][he];for(let Ce=0;Ce<se.width;++Ce){for(let me=0;me<2*se.type;++me)M[it++]=re[Te+me*se.width*se.height];Te++}he++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(M.buffer)}function Tt(p,y){const _=new Uint8Array(p);let M=0;for(;_[y.value+M]!=0;)M+=1;const k=new TextDecoder().decode(_.slice(y.value,y.value+M));return y.value=y.value+M+1,k}function rr(p,y,_){const M=new TextDecoder().decode(new Uint8Array(p).slice(y.value,y.value+_));return y.value=y.value+_,M}function en(p,y){const _=Ge(p,y),M=je(p,y);return[_,M]}function tn(p,y){const _=je(p,y),M=je(p,y);return[_,M]}function Ge(p,y){const _=p.getInt32(y.value,!0);return y.value=y.value+4,_}function je(p,y){const _=p.getUint32(y.value,!0);return y.value=y.value+4,_}function Or(p,y){const _=p[y.value];return y.value=y.value+1,_}function dt(p,y){const _=p.getUint8(y.value);return y.value=y.value+1,_}const Ve=function(p,y){let _;return"getBigInt64"in DataView.prototype?_=Number(p.getBigInt64(y.value,!0)):_=p.getUint32(y.value+4,!0)+Number(p.getUint32(y.value,!0)<<32),y.value+=8,_};function De(p,y){const _=p.getFloat32(y.value,!0);return y.value+=4,_}function nr(p,y){return f.DataUtils.toHalfFloat(De(p,y))}function K(p){const y=(p&31744)>>10,_=p&1023;return(p>>15?-1:1)*(y?y===31?_?NaN:1/0:Math.pow(2,y-15)*(1+_/1024):6103515625e-14*(_/1024))}function nt(p,y){const _=p.getUint16(y.value,!0);return y.value+=2,_}function Ot(p,y){return K(nt(p,y))}function ir(p,y,_,M){const k=_.value,R=[];for(;_.value<k+M-1;){const B=Tt(y,_),q=Ge(p,_),Y=dt(p,_);_.value+=3;const j=Ge(p,_),W=Ge(p,_);R.push({name:B,pixelType:q,pLinear:Y,xSampling:j,ySampling:W})}return _.value+=1,R}function rn(p,y){const _=De(p,y),M=De(p,y),k=De(p,y),R=De(p,y),B=De(p,y),q=De(p,y),Y=De(p,y),j=De(p,y);return{redX:_,redY:M,greenX:k,greenY:R,blueX:B,blueY:q,whiteX:Y,whiteY:j}}function sr(p,y){const _=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],M=dt(p,y);return _[M]}function nn(p,y){const _=Ge(p,y),M=Ge(p,y),k=Ge(p,y),R=Ge(p,y);return{xMin:_,yMin:M,xMax:k,yMax:R}}function or(p,y){const _=["INCREASING_Y","DECREASING_Y","RANDOM_Y"],M=dt(p,y);return _[M]}function ar(p,y){const _=["ENVMAP_LATLONG","ENVMAP_CUBE"],M=dt(p,y);return _[M]}function sn(p,y){const _=["ONE_LEVEL","MIPMAP_LEVELS","RIPMAP_LEVELS"],M=["ROUND_DOWN","ROUND_UP"],k=je(p,y),R=je(p,y),B=dt(p,y);return{xSize:k,ySize:R,levelMode:_[B&15],roundingMode:M[B>>4]}}function on(p,y){const _=De(p,y),M=De(p,y);return[_,M]}function cr(p,y){const _=De(p,y),M=De(p,y),k=De(p,y);return[_,M,k]}function lr(p,y,_,M,k){if(M==="string"||M==="stringvector"||M==="iccProfile")return rr(y,_,k);if(M==="chlist")return ir(p,y,_,k);if(M==="chromaticities")return rn(p,_);if(M==="compression")return sr(p,_);if(M==="box2i")return nn(p,_);if(M==="envmap")return ar(p,_);if(M==="tiledesc")return sn(p,_);if(M==="lineOrder")return or(p,_);if(M==="float")return De(p,_);if(M==="v2f")return on(p,_);if(M==="v3f")return cr(p,_);if(M==="int")return Ge(p,_);if(M==="rational")return en(p,_);if(M==="timecode")return tn(p,_);if(M==="preview")return _.value+=k,"skipped";_.value+=k}function an(p,y){const _=Math.log2(p);return y=="ROUND_DOWN"?Math.floor(_):Math.ceil(_)}function cn(p,y,_){let M=0;switch(p.levelMode){case"ONE_LEVEL":M=1;break;case"MIPMAP_LEVELS":M=an(Math.max(y,_),p.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return M}function Lr(p,y,_,M){const k=new Array(p);for(let R=0;R<p;R++){const B=1<<R;let q=y/B|0;M=="ROUND_UP"&&q*B<y&&(q+=1);const Y=Math.max(q,1);k[R]=(Y+_-1)/_|0}return k}function ln(){const p=this,y=p.offset,_={value:0};for(let M=0;M<p.tileCount;M++){const k=Ge(p.viewer,y),R=Ge(p.viewer,y);y.value+=8,p.size=je(p.viewer,y);const B=k*p.blockWidth,q=R*p.blockHeight;p.columns=B+p.blockWidth>p.width?p.width-B:p.blockWidth,p.lines=q+p.blockHeight>p.height?p.height-q:p.blockHeight;const Y=p.columns*p.totalBytes,W=p.size<p.lines*Y?p.uncompress(p):Ht(p);y.value+=p.size;for(let J=0;J<p.lines;J++){const re=J*p.columns*p.totalBytes;for(let ee=0;ee<p.inputChannels.length;ee++){const le=Q.channels[ee].name,te=p.channelByteOffsets[le]*p.columns,se=p.decodeChannels[le];if(se===void 0)continue;_.value=re+te;const he=(p.height-(1+q+J))*p.outLineWidth;for(let Te=0;Te<p.columns;Te++){const Re=he+(Te+B)*p.outputChannels+se;p.byteArray[Re]=p.getter(W,_)}}}}}function m(){const p=this,y=p.offset,_={value:0};for(let M=0;M<p.height/p.blockHeight;M++){const k=Ge(p.viewer,y)-Q.dataWindow.yMin;p.size=je(p.viewer,y),p.lines=k+p.blockHeight>p.height?p.height-k:p.blockHeight;const R=p.columns*p.totalBytes,q=p.size<p.lines*R?p.uncompress(p):Ht(p);y.value+=p.size;for(let Y=0;Y<p.blockHeight;Y++){const j=M*p.blockHeight,W=Y+p.scanOrder(j);if(W>=p.height)continue;const J=Y*R,re=(p.height-1-W)*p.outLineWidth;for(let ee=0;ee<p.inputChannels.length;ee++){const le=Q.channels[ee].name,te=p.channelByteOffsets[le]*p.columns,se=p.decodeChannels[le];if(se!==void 0){_.value=J+te;for(let he=0;he<p.columns;he++){const Te=re+he*p.outputChannels+se;p.byteArray[Te]=p.getter(q,_)}}}}}}function I(p,y,_){const M={};if(p.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");M.version=p.getUint8(4);const k=p.getUint8(5);M.spec={singleTile:!!(k&2),longName:!!(k&4),deepFormat:!!(k&8),multiPart:!!(k&16)},_.value=8;let R=!0;for(;R;){const B=Tt(y,_);if(B==0)R=!1;else{const q=Tt(y,_),Y=je(p,_),j=lr(p,y,_,q,Y);j===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${q}'.`):M[B]=j}}if((k&-7)!=0)throw console.error("THREE.EXRHeader:",M),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return M}function N(p,y,_,M,k){const R={size:0,viewer:y,array:_,offset:M,width:p.dataWindow.xMax-p.dataWindow.xMin+1,height:p.dataWindow.yMax-p.dataWindow.yMin+1,inputChannels:p.channels,channelByteOffsets:{},scanOrder:null,totalBytes:null,columns:null,lines:null,type:null,uncompress:null,getter:null,format:null,colorSpace:f.LinearSRGBColorSpace};switch(p.compression){case"NO_COMPRESSION":R.blockHeight=1,R.uncompress=Ht;break;case"RLE_COMPRESSION":R.blockHeight=1,R.uncompress=Hr;break;case"ZIPS_COMPRESSION":R.blockHeight=1,R.uncompress=Ft;break;case"ZIP_COMPRESSION":R.blockHeight=16,R.uncompress=Ft;break;case"PIZ_COMPRESSION":R.blockHeight=32,R.uncompress=er;break;case"PXR24_COMPRESSION":R.blockHeight=16,R.uncompress=tr;break;case"DWAA_COMPRESSION":R.blockHeight=32,R.uncompress=Fr;break;case"DWAB_COMPRESSION":R.blockHeight=256,R.uncompress=Fr;break;default:throw new Error("EXRLoader.parse: "+p.compression+" is unsupported")}const B={};for(const W of p.channels)switch(W.name){case"Y":case"R":case"G":case"B":case"A":B[W.name]=!0,R.type=W.pixelType}let q=!1;if(B.R&&B.G&&B.B)q=!B.A,R.outputChannels=4,R.decodeChannels={R:0,G:1,B:2,A:3};else if(B.Y)R.outputChannels=1,R.decodeChannels={Y:0};else throw new Error("EXRLoader.parse: file contains unsupported data channels.");if(R.type==1)switch(k){case f.FloatType:R.getter=Ot;break;case f.HalfFloatType:R.getter=nt;break}else if(R.type==2)switch(k){case f.FloatType:R.getter=De;break;case f.HalfFloatType:R.getter=nr}else throw new Error("EXRLoader.parse: unsupported pixelType "+R.type+" for "+p.compression+".");R.columns=R.width;const Y=R.width*R.height*R.outputChannels;switch(k){case f.FloatType:R.byteArray=new Float32Array(Y),q&&R.byteArray.fill(1,0,Y);break;case f.HalfFloatType:R.byteArray=new Uint16Array(Y),q&&R.byteArray.fill(15360,0,Y);break;default:console.error("THREE.EXRLoader: unsupported type: ",k);break}let j=0;for(const W of p.channels)R.decodeChannels[W.name]!==void 0&&(R.channelByteOffsets[W.name]=j),j+=W.pixelType*2;if(R.totalBytes=j,R.outLineWidth=R.width*R.outputChannels,p.lineOrder==="INCREASING_Y"?R.scanOrder=W=>W:R.scanOrder=W=>R.height-1-W,R.outputChannels==4?(R.format=f.RGBAFormat,R.colorSpace=f.LinearSRGBColorSpace):(R.format=f.RedFormat,R.colorSpace=f.NoColorSpace),p.spec.singleTile){R.blockHeight=p.tiles.ySize,R.blockWidth=p.tiles.xSize;const W=cn(p.tiles,R.width,R.height),J=Lr(W,R.width,p.tiles.xSize,p.tiles.roundingMode),re=Lr(W,R.height,p.tiles.ySize,p.tiles.roundingMode);R.tileCount=J[0]*re[0];for(let ee=0;ee<W;ee++)for(let le=0;le<re[ee];le++)for(let te=0;te<J[ee];te++)Ve(y,M);R.decode=ln.bind(R)}else{R.blockWidth=R.width;const W=Math.ceil(R.height/R.blockHeight);for(let J=0;J<W;J++)Ve(y,M);R.decode=m.bind(R)}return R}const Z={value:0},ie=new DataView(e),oe=new Uint8Array(e),Q=I(ie,e,Z),$=N(Q,ie,oe,Z,this.type);return $.decode(),{header:Q,width:$.width,height:$.height,data:$.byteArray,format:$.format,colorSpace:$.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,t,r,n){function o(i,a){i.colorSpace=a.colorSpace,i.minFilter=f.LinearFilter,i.magFilter=f.LinearFilter,i.generateMipmaps=!1,i.flipY=!1,t&&t(i,a)}return super.load(e,o,r,n)}}class Gu extends f.DataTextureLoader{constructor(e){super(e),this.type=f.HalfFloatType}parse(e){const i=function(O,L){switch(O){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(L||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(L||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(L||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(L||""))}},d=`
|
|
4012
|
+
`,h=function(O,L,E){L=L||1024;let z=O.pos,G=-1,U=0,H="",ne=String.fromCharCode.apply(null,new Uint16Array(O.subarray(z,z+128)));for(;0>(G=ne.indexOf(d))&&U<L&&z<O.byteLength;)H+=ne,U+=ne.length,z+=128,ne+=String.fromCharCode.apply(null,new Uint16Array(O.subarray(z,z+128)));return-1<G?(O.pos+=U+G+1,H+ne.slice(0,G)):!1},l=function(O){const L=/^#\?(\S+)/,E=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,V=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,z=/^\s*FORMAT=(\S+)\s*$/,G=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,U={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let H,ne;for((O.pos>=O.byteLength||!(H=h(O)))&&i(1,"no header found"),(ne=H.match(L))||i(3,"bad initial token"),U.valid|=1,U.programtype=ne[1],U.string+=H+`
|
|
4013
|
+
`;H=h(O),H!==!1;){if(U.string+=H+`
|
|
4014
|
+
`,H.charAt(0)==="#"){U.comments+=H+`
|
|
4015
|
+
`;continue}if((ne=H.match(E))&&(U.gamma=parseFloat(ne[1])),(ne=H.match(V))&&(U.exposure=parseFloat(ne[1])),(ne=H.match(z))&&(U.valid|=2,U.format=ne[1]),(ne=H.match(G))&&(U.valid|=4,U.height=parseInt(ne[1],10),U.width=parseInt(ne[2],10)),U.valid&2&&U.valid&4)break}return U.valid&2||i(3,"missing format specifier"),U.valid&4||i(3,"missing image size specifier"),U},v=function(O,L,E){const V=L;if(V<8||V>32767||O[0]!==2||O[1]!==2||O[2]&128)return new Uint8Array(O);V!==(O[2]<<8|O[3])&&i(3,"wrong scanline width");const z=new Uint8Array(4*L*E);z.length||i(4,"unable to allocate buffer space");let G=0,U=0;const H=4*V,ne=new Uint8Array(4),ge=new Uint8Array(H);let Pe=E;for(;Pe>0&&U<O.byteLength;){U+4>O.byteLength&&i(1),ne[0]=O[U++],ne[1]=O[U++],ne[2]=O[U++],ne[3]=O[U++],(ne[0]!=2||ne[1]!=2||(ne[2]<<8|ne[3])!=V)&&i(3,"bad rgbe scanline format");let ve=0,ye;for(;ve<H&&U<O.byteLength;){ye=O[U++];const _e=ye>128;if(_e&&(ye-=128),(ye===0||ve+ye>H)&&i(3,"bad scanline data"),_e){const Se=O[U++];for(let et=0;et<ye;et++)ge[ve++]=Se}else ge.set(O.subarray(U,U+ye),ve),ve+=ye,U+=ye}const Ue=V;for(let _e=0;_e<Ue;_e++){let Se=0;z[G]=ge[_e+Se],Se+=V,z[G+1]=ge[_e+Se],Se+=V,z[G+2]=ge[_e+Se],Se+=V,z[G+3]=ge[_e+Se],G+=4}Pe--}return z},b=function(O,L,E,V){const z=O[L+3],G=Math.pow(2,z-128)/255;E[V+0]=O[L+0]*G,E[V+1]=O[L+1]*G,E[V+2]=O[L+2]*G,E[V+3]=1},T=function(O,L,E,V){const z=O[L+3],G=Math.pow(2,z-128)/255;E[V+0]=f.DataUtils.toHalfFloat(Math.min(O[L+0]*G,65504)),E[V+1]=f.DataUtils.toHalfFloat(Math.min(O[L+1]*G,65504)),E[V+2]=f.DataUtils.toHalfFloat(Math.min(O[L+2]*G,65504)),E[V+3]=f.DataUtils.toHalfFloat(1)},g=new Uint8Array(e);g.pos=0;const x=l(g),w=x.width,S=x.height,A=v(g.subarray(g.pos),w,S);let P,D,F;switch(this.type){case f.FloatType:F=A.length/4;const O=new Float32Array(F*4);for(let E=0;E<F;E++)b(A,E*4,O,E*4);P=O,D=f.FloatType;break;case f.HalfFloatType:F=A.length/4;const L=new Uint16Array(F*4);for(let E=0;E<F;E++)T(A,E*4,L,E*4);P=L,D=f.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:w,height:S,data:P,header:x.string,gamma:x.gamma,exposure:x.exposure,type:D}}setDataType(e){return this.type=e,this}load(e,t,r,n){function o(i,a){switch(i.type){case f.FloatType:case f.HalfFloatType:i.colorSpace=f.LinearSRGBColorSpace,i.minFilter=f.LinearFilter,i.magFilter=f.LinearFilter,i.generateMipmaps=!1,i.flipY=!0;break}t&&t(i,a)}return super.load(e,o,r,n)}}class ju extends f.Scene{constructor(){super();const e=new f.BoxGeometry;e.deleteAttribute("uv");const t=new f.MeshStandardMaterial({side:f.BackSide}),r=new f.MeshStandardMaterial,n=new f.PointLight(16777215,900,28,2);n.position.set(.418,16.199,.3),this.add(n);const o=new f.Mesh(e,t);o.position.set(-.757,13.219,.717),o.scale.set(31.713,28.305,28.591),this.add(o);const i=new f.Mesh(e,r);i.position.set(-10.906,2.009,1.846),i.rotation.set(0,-.195,0),i.scale.set(2.328,7.905,4.651),this.add(i);const a=new f.Mesh(e,r);a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),this.add(a);const c=new f.Mesh(e,r);c.position.set(6.167,.857,7.803),c.rotation.set(0,.561,0),c.scale.set(3.927,6.285,3.687),this.add(c);const u=new f.Mesh(e,r);u.position.set(-2.017,.018,6.124),u.rotation.set(0,.333,0),u.scale.set(2.002,4.566,2.064),this.add(u);const d=new f.Mesh(e,r);d.position.set(2.291,-.756,-2.621),d.rotation.set(0,-.286,0),d.scale.set(1.546,1.552,1.496),this.add(d);const h=new f.Mesh(e,r);h.position.set(-2.193,-.369,-5.547),h.rotation.set(0,.516,0),h.scale.set(3.875,3.487,2.986),this.add(h);const l=new f.Mesh(e,Pr(50));l.position.set(-16.116,14.37,8.208),l.scale.set(.1,2.428,2.739),this.add(l);const v=new f.Mesh(e,Pr(50));v.position.set(-16.109,18.021,-8.207),v.scale.set(.1,2.425,2.751),this.add(v);const b=new f.Mesh(e,Pr(17));b.position.set(14.904,12.198,-1.832),b.scale.set(.15,4.265,6.331),this.add(b);const T=new f.Mesh(e,Pr(43));T.position.set(-.462,8.89,14.52),T.scale.set(4.38,5.441,.088),this.add(T);const g=new f.Mesh(e,Pr(20));g.position.set(3.235,11.486,-12.541),g.scale.set(2.5,2,.1),this.add(g);const x=new f.Mesh(e,Pr(100));x.position.set(0,20,0),x.scale.set(1,.1,1),this.add(x)}dispose(){const e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(const t of e)t.dispose()}}function Pr(s){const e=new f.MeshBasicMaterial;return e.color.setScalar(s),e}class Wu{constructor(){this.pmremGenerator=null,this.loadedTextures=new Map}async initialize(e){var t;try{const r=e.renderer;let n=r.renderer||((t=r.getThreeRenderer)==null?void 0:t.call(r));if(!n&&r.getDomElement){const o=r.getDomElement();if(o&&"parentElement"in o&&o.parentElement){const i=o.parentElement.renderer;i instanceof C.WebGLRenderer&&(n=i)}}return n?(this.pmremGenerator=new C.PMREMGenerator(n),this.pmremGenerator.compileEquirectangularShader(),X.ok(void 0)):X.err(new ce("Could not access Three.js renderer",ue.INITIALIZATION_FAILED))}catch(r){return X.err(new ce("Failed to initialize environment service",ue.INITIALIZATION_FAILED,{originalError:r}))}}async loadEnvironmentMap(e){var t,r,n,o;try{const i=this.loadedTextures.get(e);if(i)return X.ok(new Dr(i));const a=(t=e.split(".").pop())==null?void 0:t.toLowerCase();let c;switch(a){case"hdr":c=new Gu;break;case"exr":c=new Vu;break;case"jpg":case"jpeg":case"png":c=new C.TextureLoader;break;default:return X.err(new ce(`Unsupported environment map format: ${a}`,ue.UNSUPPORTED_FORMAT,{url:e,extension:a}))}const u=await new Promise((d,h)=>{c.load(e,l=>{var v,b,T,g,x;console.log("[ThreeEnvironmentService] Texture loaded:",{url:e,format:l.format,type:l.type,mapping:l.mapping,hasImage:!!l.image,imageType:(b=(v=l.image)==null?void 0:v.constructor)==null?void 0:b.name,imageData:(T=l.image)!=null&&T.data?"has data":"no data",imageWidth:(g=l.image)==null?void 0:g.width,imageHeight:(x=l.image)==null?void 0:x.height}),d(l)},void 0,l=>h(l))});if(this.pmremGenerator){u.mapping=C.EquirectangularReflectionMapping;const d=this.pmremGenerator.fromEquirectangular(u).texture;return this.loadedTextures.set(e,d),this.loadedTextures.set(e+"_original",u),console.log("[ThreeEnvironmentService] Stored original texture for path tracing:",{url:e+"_original",format:u.format,mapping:u.mapping,hasImage:!!u.image,imageComplete:(r=u.image)==null?void 0:r.complete,imageNaturalWidth:(n=u.image)==null?void 0:n.naturalWidth,imageNaturalHeight:(o=u.image)==null?void 0:o.naturalHeight}),X.ok(new Dr(d))}return this.loadedTextures.set(e,u),X.ok(new Dr(u))}catch(i){return X.err(new ce("Failed to load environment map",ue.TEXTURE_LOAD_FAILED,{url:e,originalError:i}))}}applyToScene(e,t){try{if(!(e instanceof Wt))return X.err(new ce("Scene must be ThreeSceneAdapter",ue.INVALID_PARAMETER));if(!(t instanceof Dr))return X.err(new ce("Texture must be ThreeTextureAdapter",ue.INVALID_PARAMETER));const r=e.getThreeScene(),n=t.getThreeTexture();if(r.environment=n,n.mapping===C.CubeUVReflectionMapping){const i=Array.from(this.loadedTextures.entries()).find(([a,c])=>a.endsWith("_original")&&c.mapping===C.EquirectangularReflectionMapping);i&&(r.__originalEnvironmentTexture=i[1])}else n.mapping===C.EquirectangularReflectionMapping&&(r.__originalEnvironmentTexture=n);if(n.mapping===C.EquirectangularReflectionMapping)r.background=n;else if(n.mapping===C.CubeUVReflectionMapping){const i=Array.from(this.loadedTextures.entries()).find(([a,c])=>a.endsWith("_original")&&c.mapping===C.EquirectangularReflectionMapping);i?r.background=i[1]:r.background=n}else r.background=n;return X.ok(void 0)}catch(r){return X.err(new ce("Failed to apply environment to scene",ue.SCENE_OPERATION_FAILED,{originalError:r}))}}getOriginalEnvironmentTexture(e){const t=this.loadedTextures.get(e+"_original");return t?new Dr(t):null}createStudioEnvironment(e={}){try{if(!this.pmremGenerator)return X.err(new ce("Environment service not initialized",ue.INITIALIZATION_FAILED));const t=new ju,r=this.pmremGenerator.fromScene(t).texture;return t.dispose(),X.ok(new Dr(r))}catch(t){return X.err(new ce("Failed to create studio environment",ue.TEXTURE_LOAD_FAILED,{originalError:t}))}}dispose(){this.loadedTextures.forEach(e=>e.dispose()),this.loadedTextures.clear(),this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=null)}}class Dr{constructor(e){this.texture=e}get id(){return this.texture.uuid}get image(){return this.texture.image}get needsUpdate(){return this.texture.needsUpdate}set needsUpdate(e){this.texture.needsUpdate=e}dispose(){this.texture.dispose()}getThreeTexture(){return this.texture}}class Yu{constructor(e){this.object=e,this.boundingBox=new C.Box3().setFromObject(this.object)}alignToFloor(){const e=this.calculateFloorOffset();this.applyOffset(e)}calculateFloorOffset(){const e=this.boundingBox.min.y,t=this.boundingBox.max.y-e,r=new C.Vector3;return t>0?r.y=-e:r.y=0,r}applyOffset(e){this.object.position.add(e)}}class Zu{alignToFloor(e){try{let t=null;return"getThreeObject"in e&&typeof e.getThreeObject=="function"?t=e.getThreeObject():e instanceof C.Object3D&&(t=e),t?(new Yu(t).alignToFloor(),X.ok(void 0)):X.err(new ce("Could not get Three.js object for floor alignment",ue.INVALID_PARAMETER))}catch(t){return X.err(new ce("Failed to align object to floor",ue.OPERATION_FAILED,{originalError:t}))}}}var Un=(s=>(s.MapControls="MapControls",s.OrbitControls="OrbitControls",s))(Un||{});class qu{static convertRendererOptions(e){const t={antialias:e.antialias,alpha:e.alpha,premultipliedAlpha:e.premultipliedAlpha,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference,pixelRatio:e.pixelRatio};return(e.shadowMapEnabled!==void 0||e.shadowMapType!==void 0)&&(t.shadowMap={enabled:e.shadowMapEnabled??!0,type:this.convertShadowMapType(e.shadowMapType)}),(e.toneMapping!==void 0||e.toneMappingExposure!==void 0)&&(t.toneMapping={type:this.convertToneMappingType(e.toneMapping),exposure:e.toneMappingExposure??1}),t}static convertShadowMapType(e){if(typeof e=="number"){if(e===C.BasicShadowMap)return"basic";if(e===C.PCFShadowMap)return"pcf";if(e===C.PCFSoftShadowMap)return"pcfsoft";if(e===C.VSMShadowMap)return"vsm"}return typeof e=="string"?e:void 0}static convertToneMappingType(e){if(typeof e=="number"){if(e===C.NoToneMapping)return"none";if(e===C.LinearToneMapping)return"linear";if(e===C.ReinhardToneMapping)return"reinhard";if(e===C.CineonToneMapping)return"cineon";if(e===C.ACESFilmicToneMapping)return"aces"}return typeof e=="string"?e:"aces"}}class Ku{static createViewer(e,t){var T;const r=new Ro(e),n=new Wt,o=this.createCamera(t),i=this.createControls(o.getThreeCamera(),e,t),a=new Xu().createDefaultLoader(),c=new Da,u=new Wu;let d;(((T=t.pathTracing)==null?void 0:T.enabled)??!1)&&(d=new Au);const l=new Zu,v=qu.convertRendererOptions(t.renderer||{}),b={renderer:r,scene:n,camera:o,controls:i,modelLoader:a,options:t,rendererOptions:v,sceneSetupService:c,environmentService:u,pathTracingService:d,floorAlignmentService:l};return new Do(b)}static createCamera(e){const r=e.camera||{},n=r.fov||r.cameraFov||75,o=r.near||r.cameraNear||.1,i=r.far||r.cameraFar||1e5,a=r.position||r.cameraPosition,c=r.target||r.cameraTarget,u=Kn.create(n,1,o,i);return a&&u.position.set(a[0],a[1],a[2]),c&&u.lookAt({x:c[0],y:c[1],z:c[2],set:()=>{},copy:()=>{},add:()=>{},multiply:()=>{},normalize:()=>{},length:()=>0}),u}static createControls(e,t,r){const n=r.controls||{},o=n.type||Un.OrbitControls;let i;o===Un.MapControls?i=new os(e,t):i=new ss(e,t),i.enabled=n.enabled??!0,i.enableDamping=n.enableDamping??!0,i.dampingFactor=n.dampingFactor??.25,i.enableZoom=n.enableZoom??!0,i.enableRotate=n.enableRotate??!0,i.enablePan=n.enablePan??!0,n.minDistance!==void 0&&(i.minDistance=n.minDistance),n.maxDistance!==void 0&&(i.maxDistance=n.maxDistance),n.minPolarAngle!==void 0&&(i.minPolarAngle=n.minPolarAngle),n.maxPolarAngle!==void 0&&(i.maxPolarAngle=n.maxPolarAngle);const c=r.camera||{},u=c.target||c.cameraTarget;return u&&i.target&&(i.target.set(u[0],u[1],u[2]),i.update()),i}}class Xu extends Hi{createDefaultLoader(){return Hi.createLoader("model.glb")}}const ho={staticScene:!1,backgroundColor:"#f0f0f7",replaceWithScreenshotOnComplete:!0,animationLoop:null,pathTracing:{enabled:!1,maxSamples:16,bounces:16,transmissiveBounces:4,renderScale:.8,lowResScale:.25,dynamicLowRes:!0},camera:{position:[60,60,60],target:[0,0,0],fov:75,near:.1,far:1e5,autoFitToObject:!0},environment:{url:"https://dl.polyhaven.org/file/ph-assets/HDRIs/extra/Tonemapped%20JPG/industrial_sunset_puresky.jpg"},lighting:{ambientLight:{color:"#404040",intensity:Math.PI},hemisphereLight:{skyColor:"#ffffbb",groundColor:"#080820",intensity:1},directionalLight:{color:"#ffffff",intensity:Math.PI,position:[72,72,72],castShadow:!0,shadow:{mapSize:{width:4096,height:4096},camera:{near:.5,far:200,left:-50,right:50,top:50,bottom:-50},bias:-1e-4,radius:1}}},renderer:{antialias:!0,alpha:!1,shadowMapEnabled:!0,pixelRatio:window.devicePixelRatio,shadowMapType:2,toneMapping:6,toneMappingExposure:1.5},controls:{type:Un.OrbitControls,enabled:!0,enableDamping:!0,dampingFactor:.25,enableZoom:!0,enableRotate:!0,enablePan:!0},helpers:{grid:!0,axes:!1,stats:!1,gizmo:!1,studioEnvironment:!0}};function $u(s){const e=ae.useRef(s),t=ae.useMemo(()=>JSON.stringify({pathTracing:s.pathTracing,staticScene:s.staticScene,renderer:s.renderer,camera:s.camera,controls:s.controls,backgroundColor:s.backgroundColor,environment:s.environment,lighting:s.lighting,helpers:s.helpers}),[s.pathTracing,s.staticScene,s.renderer,s.camera,s.controls,s.backgroundColor,s.environment,s.lighting,s.helpers]);return ae.useMemo(()=>{e.current=s},[t,s]),e.current}function Qu(s,e){const t=ae.useRef(null),[r,n]=ae.useState(new st),[o,i]=ae.useState(!1),a=$u(e);ae.useEffect(()=>{var l;if(!s.current||t.current)return;const u={...ho,...a};console.log("[useViewerCore] Creating viewer with options:",{pathTracingEnabled:(l=u.pathTracing)==null?void 0:l.enabled,staticScene:u.staticScene,pathTracing:u.pathTracing});const d=Ku.createViewer(s.current,u);t.current=d;const h=d.onStateChange(v=>{n(v)});return d.initialize().then(v=>{v.ok?i(!0):console.error("Failed to initialize viewer:",v.error)}),()=>{h(),d.dispose(),t.current=null,i(!1)}},[s,a]);const c=ae.useRef({width:0,height:0});return ae.useEffect(()=>{if(!t.current||!s.current)return;let u=null;const d=v=>{if(s.current&&t.current){const b=s.current.parentElement||s.current;let{clientWidth:T,clientHeight:g}=b;if(v&&v[0]){const{width:x,height:w}=v[0].contentRect;T=Math.floor(x),g=Math.floor(w)}if(c.current.width===T&&c.current.height===g)return;u!==null&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{t.current&&s.current&&(t.current.resize(T,g),c.current={width:T,height:g})})}};d();const h=()=>d();window.addEventListener("resize",h);let l=null;return typeof ResizeObserver<"u"&&s.current.parentElement&&(l=new ResizeObserver(d),l.observe(s.current.parentElement)),()=>{window.removeEventListener("resize",h),l==null||l.disconnect(),u!==null&&cancelAnimationFrame(u)}},[o,s]),{viewer:t.current,state:r,isInitialized:o}}function Ju(s,e){const t=ae.useRef(e);t.current=e,ae.useEffect(()=>{if(!s)return;const r=s.getEvents(),n=[];return Object.keys(e).forEach(o=>{if(e[o]){const a=c=>{const u=t.current[o];u&&u(c)};r.on(o,a),n.push(()=>r.off(o,a))}}),()=>{n.forEach(o=>o())}},[s])}const fo=ae.createContext(null);function Hu({viewer:s,canvasRef:e,children:t}){return qe.jsx(fo.Provider,{value:{viewer:s,canvasRef:e},children:t})}function eh(){const s=ae.useContext(fo);if(!s)throw new Error("useViewerContext must be used within ViewerProvider");return s}function th(){const{canvasRef:s}=eh();return qe.jsx("canvas",{ref:s,style:{width:"100%",height:"100%",display:"block",imageRendering:"auto",background:"transparent"}})}(function(){try{if(typeof document<"u"){var s=document.createElement("style");s.appendChild(document.createTextNode(".gizmo-default{width:100px;height:100px;position:absolute;top:0;right:0;z-index:2;cursor:pointer}")),document.head.appendChild(s)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();var zi={exports:{}},Xr={};/**
|
|
4016
|
+
* @license React
|
|
4017
|
+
* react-jsx-runtime.production.min.js
|
|
4018
|
+
*
|
|
4019
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4020
|
+
*
|
|
4021
|
+
* This source code is licensed under the MIT license found in the
|
|
4022
|
+
* LICENSE file in the root directory of this source tree.
|
|
4023
|
+
*/var po;function rh(){if(po)return Xr;po=1;var s=ae,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,n=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(a,c,u){var d,h={},l=null,v=null;u!==void 0&&(l=""+u),c.key!==void 0&&(l=""+c.key),c.ref!==void 0&&(v=c.ref);for(d in c)r.call(c,d)&&!o.hasOwnProperty(d)&&(h[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)h[d]===void 0&&(h[d]=c[d]);return{$$typeof:e,type:a,key:l,ref:v,props:h,_owner:n.current}}return Xr.Fragment=t,Xr.jsx=i,Xr.jsxs=i,Xr}var Vn={};/**
|
|
4024
|
+
* @license React
|
|
4025
|
+
* react-jsx-runtime.development.js
|
|
4026
|
+
*
|
|
4027
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4028
|
+
*
|
|
4029
|
+
* This source code is licensed under the MIT license found in the
|
|
4030
|
+
* LICENSE file in the root directory of this source tree.
|
|
4031
|
+
*/var mo;function nh(){return mo||(mo=1,process.env.NODE_ENV!=="production"&&function(){var s=ae,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),b=Symbol.iterator,T="@@iterator";function g(m){if(m===null||typeof m!="object")return null;var I=b&&m[b]||m[T];return typeof I=="function"?I:null}var x=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(m){{for(var I=arguments.length,N=new Array(I>1?I-1:0),Z=1;Z<I;Z++)N[Z-1]=arguments[Z];S("error",m,N)}}function S(m,I,N){{var Z=x.ReactDebugCurrentFrame,ie=Z.getStackAddendum();ie!==""&&(I+="%s",N=N.concat([ie]));var oe=N.map(function(Q){return String(Q)});oe.unshift("Warning: "+I),Function.prototype.apply.call(console[m],console,oe)}}var A=!1,P=!1,D=!1,F=!1,O=!1,L;L=Symbol.for("react.module.reference");function E(m){return!!(typeof m=="string"||typeof m=="function"||m===r||m===o||O||m===n||m===u||m===d||F||m===v||A||P||D||typeof m=="object"&&m!==null&&(m.$$typeof===l||m.$$typeof===h||m.$$typeof===i||m.$$typeof===a||m.$$typeof===c||m.$$typeof===L||m.getModuleId!==void 0))}function V(m,I,N){var Z=m.displayName;if(Z)return Z;var ie=I.displayName||I.name||"";return ie!==""?N+"("+ie+")":N}function z(m){return m.displayName||"Context"}function G(m){if(m==null)return null;if(typeof m.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof m=="function")return m.displayName||m.name||null;if(typeof m=="string")return m;switch(m){case r:return"Fragment";case t:return"Portal";case o:return"Profiler";case n:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof m=="object")switch(m.$$typeof){case a:var I=m;return z(I)+".Consumer";case i:var N=m;return z(N._context)+".Provider";case c:return V(m,m.render,"ForwardRef");case h:var Z=m.displayName||null;return Z!==null?Z:G(m.type)||"Memo";case l:{var ie=m,oe=ie._payload,Q=ie._init;try{return G(Q(oe))}catch{return null}}}return null}var U=Object.assign,H=0,ne,ge,Pe,ve,ye,Ue,_e;function Se(){}Se.__reactDisabledLog=!0;function et(){{if(H===0){ne=console.log,ge=console.info,Pe=console.warn,ve=console.error,ye=console.group,Ue=console.groupCollapsed,_e=console.groupEnd;var m={configurable:!0,enumerable:!0,value:Se,writable:!0};Object.defineProperties(console,{info:m,log:m,warn:m,error:m,group:m,groupCollapsed:m,groupEnd:m})}H++}}function ut(){{if(H--,H===0){var m={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:U({},m,{value:ne}),info:U({},m,{value:ge}),warn:U({},m,{value:Pe}),error:U({},m,{value:ve}),group:U({},m,{value:ye}),groupCollapsed:U({},m,{value:Ue}),groupEnd:U({},m,{value:_e})})}H<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=x.ReactCurrentDispatcher,ze;function ke(m,I,N){{if(ze===void 0)try{throw Error()}catch(ie){var Z=ie.stack.trim().match(/\n( *(at )?)/);ze=Z&&Z[1]||""}return`
|
|
4032
|
+
`+ze+m}}var ht=!1,tt;{var Pt=typeof WeakMap=="function"?WeakMap:Map;tt=new Pt}function _t(m,I){if(!m||ht)return"";{var N=tt.get(m);if(N!==void 0)return N}var Z;ht=!0;var ie=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var oe;oe=de.current,de.current=null,et();try{if(I){var Q=function(){throw Error()};if(Object.defineProperty(Q.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Q,[])}catch(B){Z=B}Reflect.construct(m,[],Q)}else{try{Q.call()}catch(B){Z=B}m.call(Q.prototype)}}else{try{throw Error()}catch(B){Z=B}m()}}catch(B){if(B&&Z&&typeof B.stack=="string"){for(var $=B.stack.split(`
|
|
4033
|
+
`),p=Z.stack.split(`
|
|
4034
|
+
`),y=$.length-1,_=p.length-1;y>=1&&_>=0&&$[y]!==p[_];)_--;for(;y>=1&&_>=0;y--,_--)if($[y]!==p[_]){if(y!==1||_!==1)do if(y--,_--,_<0||$[y]!==p[_]){var M=`
|
|
4035
|
+
`+$[y].replace(" at new "," at ");return m.displayName&&M.includes("<anonymous>")&&(M=M.replace("<anonymous>",m.displayName)),typeof m=="function"&&tt.set(m,M),M}while(y>=1&&_>=0);break}}}finally{ht=!1,de.current=oe,ut(),Error.prepareStackTrace=ie}var k=m?m.displayName||m.name:"",R=k?ke(k):"";return typeof m=="function"&&tt.set(m,R),R}function Dt(m,I,N){return _t(m,!1)}function Rr(m){var I=m.prototype;return!!(I&&I.isReactComponent)}function ft(m,I,N){if(m==null)return"";if(typeof m=="function")return _t(m,Rr(m));if(typeof m=="string")return ke(m);switch(m){case u:return ke("Suspense");case d:return ke("SuspenseList")}if(typeof m=="object")switch(m.$$typeof){case c:return Dt(m.render);case h:return ft(m.type,I,N);case l:{var Z=m,ie=Z._payload,oe=Z._init;try{return ft(oe(ie),I,N)}catch{}}}return""}var rt=Object.prototype.hasOwnProperty,Qt={},Jt=x.ReactDebugCurrentFrame;function xt(m){if(m){var I=m._owner,N=ft(m.type,m._source,I?I.type:null);Jt.setExtraStackFrame(N)}else Jt.setExtraStackFrame(null)}function Qr(m,I,N,Z,ie){{var oe=Function.call.bind(rt);for(var Q in m)if(oe(m,Q)){var $=void 0;try{if(typeof m[Q]!="function"){var p=Error((Z||"React class")+": "+N+" type `"+Q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof m[Q]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw p.name="Invariant Violation",p}$=m[Q](I,Q,Z,N,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(y){$=y}$&&!($ instanceof Error)&&(xt(ie),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Z||"React class",N,Q,typeof $),xt(null)),$ instanceof Error&&!($.message in Qt)&&(Qt[$.message]=!0,xt(ie),w("Failed %s type: %s",N,$.message),xt(null))}}}var Jr=Array.isArray;function Rt(m){return Jr(m)}function Ht(m){{var I=typeof Symbol=="function"&&Symbol.toStringTag,N=I&&m[Symbol.toStringTag]||m.constructor.name||"Object";return N}}function Hr(m){try{return Ft(m),!1}catch{return!0}}function Ft(m){return""+m}function er(m){if(Hr(m))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ht(m)),Ft(m)}var tr=x.ReactCurrentOwner,Fr={key:!0,ref:!0,__self:!0,__source:!0},Tt,rr;function en(m){if(rt.call(m,"ref")){var I=Object.getOwnPropertyDescriptor(m,"ref").get;if(I&&I.isReactWarning)return!1}return m.ref!==void 0}function tn(m){if(rt.call(m,"key")){var I=Object.getOwnPropertyDescriptor(m,"key").get;if(I&&I.isReactWarning)return!1}return m.key!==void 0}function Ge(m,I){typeof m.ref=="string"&&tr.current}function je(m,I){{var N=function(){Tt||(Tt=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",I))};N.isReactWarning=!0,Object.defineProperty(m,"key",{get:N,configurable:!0})}}function Or(m,I){{var N=function(){rr||(rr=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",I))};N.isReactWarning=!0,Object.defineProperty(m,"ref",{get:N,configurable:!0})}}var dt=function(m,I,N,Z,ie,oe,Q){var $={$$typeof:e,type:m,key:I,ref:N,props:Q,_owner:oe};return $._store={},Object.defineProperty($._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty($,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Z}),Object.defineProperty($,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ie}),Object.freeze&&(Object.freeze($.props),Object.freeze($)),$};function Ve(m,I,N,Z,ie){{var oe,Q={},$=null,p=null;N!==void 0&&(er(N),$=""+N),tn(I)&&(er(I.key),$=""+I.key),en(I)&&(p=I.ref,Ge(I,ie));for(oe in I)rt.call(I,oe)&&!Fr.hasOwnProperty(oe)&&(Q[oe]=I[oe]);if(m&&m.defaultProps){var y=m.defaultProps;for(oe in y)Q[oe]===void 0&&(Q[oe]=y[oe])}if($||p){var _=typeof m=="function"?m.displayName||m.name||"Unknown":m;$&&je(Q,_),p&&Or(Q,_)}return dt(m,$,p,ie,Z,tr.current,Q)}}var De=x.ReactCurrentOwner,nr=x.ReactDebugCurrentFrame;function K(m){if(m){var I=m._owner,N=ft(m.type,m._source,I?I.type:null);nr.setExtraStackFrame(N)}else nr.setExtraStackFrame(null)}var nt;nt=!1;function Ot(m){return typeof m=="object"&&m!==null&&m.$$typeof===e}function ir(){{if(De.current){var m=G(De.current.type);if(m)return`
|
|
4057
4036
|
|
|
4058
|
-
|
|
4037
|
+
Check the render method of \``+m+"`."}return""}}function rn(m){return""}var sr={};function nn(m){{var I=ir();if(!I){var N=typeof m=="string"?m:m.displayName||m.name;N&&(I=`
|
|
4059
4038
|
|
|
4060
|
-
`})}}class Mg{constructor(e){this.renderer=e,this.pmremGenerator=new m.PMREMGenerator(e),this.copyQuad=new fr(new Sg),this.renderTarget=new m.WebGLRenderTarget(1,1,{type:m.FloatType,format:m.RGBAFormat})}dispose(){this.pmremGenerator.dispose(),this.copyQuad.dispose(),this.renderTarget.dispose()}generate(e,n){const{pmremGenerator:i,renderTarget:s,copyQuad:c,renderer:a}=this,u=i.fromEquirectangular(e),{width:f,height:p}=e.image;s.setSize(f,p),c.material.envMap=u.texture,c.material.blur=n;const v=a.getRenderTarget(),g=a.autoClear;a.setRenderTarget(s),a.autoClear=!0,c.render(a),a.setRenderTarget(v),a.autoClear=g;const h=new Uint16Array(f*p*4),b=new Float32Array(f*p*4);a.readRenderTargetPixels(s,0,0,f,p,b);for(let M=0,x=b.length;M<x;M++)h[M]=m.DataUtils.toHalfFloat(b[M]);const R=new m.DataTexture(h,f,p,m.RGBAFormat,m.HalfFloatType);return R.minFilter=e.minFilter,R.magFilter=e.magFilter,R.wrapS=e.wrapS,R.wrapT=e.wrapT,R.mapping=m.EquirectangularReflectionMapping,R.needsUpdate=!0,u.dispose(),R}}const Cs=()=>({WebGLPathTracer:Eg,PhysicalCamera:bl,BlurredEnvMapGenerator:Mg}),Cg=(o,e)=>(e.cameraPosition&&o.position.copy(new N.Vector3().fromArray(e.cameraPosition)),e.cameraTarget&&o.lookAt(new N.Vector3().fromArray(e.cameraTarget)),o),Ig=1.4;class Pg{constructor(e,n){this.mountRef=e,this.options=n,this.camera=this.setupCamera()}setupCamera(){if(!this.mountRef.current)throw new oe("Cannot create camera: Mount element is not ready",ue.COMPONENT_NOT_MOUNTED,{manager:"CameraManager",method:"setupCamera"});const e=this.mountRef.current.clientWidth,n=this.mountRef.current.clientHeight;if(e<=0||n<=0)throw new oe("Invalid mount dimensions",ue.INVALID_CONFIGURATION,{width:e,height:n});const i=e/n;let s;try{if(this.options.usePathTracing){const{PhysicalCamera:c}=Cs();s=new c(this.options.camera.cameraFov,i,this.options.camera.cameraNear,this.options.camera.cameraFar),"fStop"in s&&(s.fStop=Ig)}else s=new N.PerspectiveCamera(this.options.camera.cameraFov,i,this.options.camera.cameraNear,this.options.camera.cameraFar);return Cg(s,this.options.camera),s}catch(c){throw oe.fromError(c,ue.CAMERA_INIT_FAILED,{usePathTracing:this.options.usePathTracing})}}}const Dg=o=>{const e=new N.WebGLRenderer({antialias:o.antialias,alpha:o.alpha});return e.setPixelRatio(o.pixelRatio),e.shadowMap.enabled=o.shadowMapEnabled,e.shadowMap.type=o.shadowMapType,o.toneMapping&&(e.toneMapping=o.toneMapping),o.toneMappingExposure!==void 0&&(e.toneMappingExposure=o.toneMappingExposure),e},se={ok(o){return{ok:!0,value:o}},err(o){return{ok:!1,error:o}},wrap(o){try{return se.ok(o())}catch(e){return se.err(e instanceof oe?e:new oe(String(e),ue.UNKNOWN,{originalError:e}))}}};class Fg{constructor(e){this.renderer=null,this.options=e}setup(){try{return this.isWebGLSupported()?(this.renderer=Dg(this.options.renderer),this.renderer?se.ok(this.renderer):se.err(new oe("Failed to initialize renderer",ue.RENDERER_INIT_FAILED,{options:this.options.renderer}))):se.err(new oe("WebGL is not supported in this browser",ue.WEBGL_NOT_SUPPORTED,{userAgent:navigator.userAgent}))}catch(e){return se.err(oe.fromError(e,ue.RENDERER_INIT_FAILED,{options:this.options.renderer}))}}isWebGLSupported(){try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}dispose(){this.renderer&&(this.renderer.dispose(),this.renderer=null)}}const Bl={type:"change"},ao={type:"start"},kl={type:"end"},Is=new m.Ray,Ul=new m.Plane,Og=Math.cos(70*m.MathUtils.DEG2RAD),nt=new m.Vector3,Mt=2*Math.PI,Be={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},oo=1e-6;class zl extends m.Controls{constructor(e,n=null){super(e,n),this.state=Be.NONE,this.enabled=!0,this.target=new m.Vector3,this.cursor=new m.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:m.MOUSE.ROTATE,MIDDLE:m.MOUSE.DOLLY,RIGHT:m.MOUSE.PAN},this.touches={ONE:m.TOUCH.ROTATE,TWO:m.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new m.Vector3,this._lastQuaternion=new m.Quaternion,this._lastTargetPosition=new m.Vector3,this._quat=new m.Quaternion().setFromUnitVectors(e.up,new m.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new m.Spherical,this._sphericalDelta=new m.Spherical,this._scale=1,this._panOffset=new m.Vector3,this._rotateStart=new m.Vector2,this._rotateEnd=new m.Vector2,this._rotateDelta=new m.Vector2,this._panStart=new m.Vector2,this._panEnd=new m.Vector2,this._panDelta=new m.Vector2,this._dollyStart=new m.Vector2,this._dollyEnd=new m.Vector2,this._dollyDelta=new m.Vector2,this._dollyDirection=new m.Vector3,this._mouse=new m.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Ng.bind(this),this._onPointerDown=Lg.bind(this),this._onPointerUp=Bg.bind(this),this._onContextMenu=Vg.bind(this),this._onMouseWheel=zg.bind(this),this._onKeyDown=Hg.bind(this),this._onTouchStart=Gg.bind(this),this._onTouchMove=Wg.bind(this),this._onMouseDown=kg.bind(this),this._onMouseMove=Ug.bind(this),this._interceptControlDown=jg.bind(this),this._interceptControlUp=qg.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Bl),this.update(),this.state=Be.NONE}update(e=null){const n=this.object.position;nt.copy(n).sub(this.target),nt.applyQuaternion(this._quat),this._spherical.setFromVector3(nt),this.autoRotate&&this.state===Be.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(i)&&isFinite(s)&&(i<-Math.PI?i+=Mt:i>Math.PI&&(i-=Mt),s<-Math.PI?s+=Mt:s>Math.PI&&(s-=Mt),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let c=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),c=a!=this._spherical.radius}if(nt.setFromSpherical(this._spherical),nt.applyQuaternion(this._quatInverse),n.copy(this.target).add(nt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const u=nt.length();a=this._clampDistance(u*this._scale);const f=u-a;this.object.position.addScaledVector(this._dollyDirection,f),this.object.updateMatrixWorld(),c=!!f}else if(this.object.isOrthographicCamera){const u=new m.Vector3(this._mouse.x,this._mouse.y,0);u.unproject(this.object);const f=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),c=f!==this.object.zoom;const p=new m.Vector3(this._mouse.x,this._mouse.y,0);p.unproject(this.object),this.object.position.sub(p).add(u),this.object.updateMatrixWorld(),a=nt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Is.origin.copy(this.object.position),Is.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Is.direction))<Og?this.object.lookAt(this.target):(Ul.setFromNormalAndCoplanarPoint(this.object.up,this.target),Is.intersectPlane(Ul,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),c=!0)}return this._scale=1,this._performCursorZoom=!1,c||this._lastPosition.distanceToSquared(this.object.position)>oo||8*(1-this._lastQuaternion.dot(this.object.quaternion))>oo||this._lastTargetPosition.distanceToSquared(this.target)>oo?(this.dispatchEvent(Bl),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Mt/60*this.autoRotateSpeed*e:Mt/60/60*this.autoRotateSpeed}_getZoomScale(e){const n=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*n)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,n){nt.setFromMatrixColumn(n,0),nt.multiplyScalar(-e),this._panOffset.add(nt)}_panUp(e,n){this.screenSpacePanning===!0?nt.setFromMatrixColumn(n,1):(nt.setFromMatrixColumn(n,0),nt.crossVectors(this.object.up,nt)),nt.multiplyScalar(e),this._panOffset.add(nt)}_pan(e,n){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;nt.copy(s).sub(this.target);let c=nt.length();c*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*c/i.clientHeight,this.object.matrix),this._panUp(2*n*c/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,c=n-i.top,a=i.width,u=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(c/u)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Mt*this._rotateDelta.x/n.clientHeight),this._rotateUp(Mt*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let n=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(Mt*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),n=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-Mt*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),n=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(Mt*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),n=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-Mt*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),i=e.pageX-n.x,s=e.pageY-n.y,c=Math.sqrt(i*i+s*s);this._dollyStart.set(0,c)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),c=.5*(e.pageY+i.y);this._rotateEnd.set(s,c)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Mt*this._rotateDelta.x/n.clientHeight),this._rotateUp(Mt*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),i=e.pageX-n.x,s=e.pageY-n.y,c=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,c),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+n.x)*.5,u=(e.pageY+n.y)*.5;this._updateZoomParameters(a,u)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId){this._pointers.splice(n,1);return}}_isTrackingPointer(e){for(let n=0;n<this._pointers.length;n++)if(this._pointers[n]==e.pointerId)return!0;return!1}_trackPointer(e){let n=this._pointerPositions[e.pointerId];n===void 0&&(n=new m.Vector2,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function Lg(o){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(o)&&(this._addPointer(o),o.pointerType==="touch"?this._onTouchStart(o):this._onMouseDown(o)))}function Ng(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function Bg(o){switch(this._removePointer(o),this._pointers.length){case 0:this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(kl),this.state=Be.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function kg(o){let e;switch(o.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case m.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=Be.DOLLY;break;case m.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=Be.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=Be.ROTATE}break;case m.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=Be.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=Be.PAN}break;default:this.state=Be.NONE}this.state!==Be.NONE&&this.dispatchEvent(ao)}function Ug(o){switch(this.state){case Be.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case Be.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case Be.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function zg(o){this.enabled===!1||this.enableZoom===!1||this.state!==Be.NONE||(o.preventDefault(),this.dispatchEvent(ao),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(kl))}function Hg(o){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(o)}function Gg(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case m.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=Be.TOUCH_ROTATE;break;case m.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=Be.TOUCH_PAN;break;default:this.state=Be.NONE}break;case 2:switch(this.touches.TWO){case m.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=Be.TOUCH_DOLLY_PAN;break;case m.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=Be.TOUCH_DOLLY_ROTATE;break;default:this.state=Be.NONE}break;default:this.state=Be.NONE}this.state!==Be.NONE&&this.dispatchEvent(ao)}function Wg(o){switch(this._trackPointer(o),this.state){case Be.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case Be.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case Be.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case Be.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=Be.NONE}}function Vg(o){this.enabled!==!1&&o.preventDefault()}function jg(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function qg(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Yg extends zl{constructor(e,n){super(e,n),this.screenSpacePanning=!1,this.mouseButtons={LEFT:m.MOUSE.PAN,MIDDLE:m.MOUSE.DOLLY,RIGHT:m.MOUSE.ROTATE},this.touches={ONE:m.TOUCH.PAN,TWO:m.TOUCH.DOLLY_ROTATE}}}var co=(o=>(o.MapControls="MapControls",o.OrbitControls="OrbitControls",o))(co||{});class Kg{constructor(e,n,i){this.controls=null,this.camera=e,this.rendererDomElement=n,this.options=i}setup(){try{if(!this.camera)return se.err(new oe("Cannot setup controls: Camera is not initialized",ue.CAMERA_INIT_FAILED,{manager:"ControlsManager"}));if(!this.rendererDomElement)return se.err(new oe("Cannot setup controls: Renderer DOM element is not available",ue.RENDERER_INIT_FAILED,{manager:"ControlsManager"}));const e=this.options.controls.type===co.MapControls?new Yg(this.camera,this.rendererDomElement):new zl(this.camera,this.rendererDomElement),n=this.options.controls;return n.enabled!==void 0&&(e.enabled=n.enabled),n.enableDamping!==void 0&&(e.enableDamping=n.enableDamping),n.dampingFactor!==void 0&&(e.dampingFactor=n.dampingFactor),n.enableZoom!==void 0&&(e.enableZoom=n.enableZoom),n.enableRotate!==void 0&&(e.enableRotate=n.enableRotate),n.enablePan!==void 0&&(e.enablePan=n.enablePan),e.update(),this.controls=e,se.ok(e)}catch(e){return se.err(oe.fromError(e,ue.INVALID_CONFIGURATION,{controlsType:this.options.controls.type,options:this.options.controls}))}}dispose(){this.controls&&(this.controls.dispose(),this.controls=null)}}class Xg{constructor(e,n,i){this.position=e,this.size=n,this.color=i,this.height=.25,this.bevel=.5}createMesh(){const e=new N.Shape,n=this.size-1,i=Math.PI*2/6;for(let p=0;p<6;p++){const v=n*Math.cos(p*i),g=n*Math.sin(p*i);p===0?e.moveTo(v,g):e.lineTo(v,g)}e.closePath();const s={depth:this.height,bevelEnabled:!0,bevelSize:this.bevel,bevelThickness:this.bevel,bevelSegments:64},c=new N.ExtrudeGeometry(e,s);new N.EdgesGeometry(c),new N.LineBasicMaterial({color:this.color});const a=new N.MeshPhysicalMaterial({color:new N.Color(16777215),metalness:0,roughness:.15,transparent:!0,transmission:1,thickness:.4,ior:1.5,opacity:1,clearcoat:1,clearcoatRoughness:.05,sheen:1,sheenColor:new N.Color(16777215)}),u=new N.Mesh(c,a);u.receiveShadow=!0;const f=new N.Group;return f.add(u),f.position.set(this.position.x,this.position.y,this.position.z),f.rotation.x=Math.PI/2,f.rotation.z=Math.PI/6,f}}class Zg{constructor(e,n,i){this.radius=e,this.tileSize=n,this.color=i}generateGrid(){const e=[],n=Math.sqrt(3)*this.tileSize,i=2*this.tileSize;for(let s=-this.radius;s<=this.radius;s++){const c=Math.max(-this.radius,-s-this.radius),a=Math.min(this.radius,-s+this.radius);for(let u=c;u<=a;u++){const f=n*(s+u/2),p=i*.75*u,v=-.25-.5,g=new Xg(new N.Vector3(f,v,p),this.tileSize,this.color);e.push(g)}}return e}addToScene(e){this.generateGrid().forEach(i=>{const s=i.createMesh();e.add(s)})}}const $g=(o,e,n)=>{if(o.children=o.children.filter(i=>!(i instanceof N.GridHelper||i instanceof N.AxesHelper||i instanceof N.BoxHelper)),n.gridHelper&&new Zg(3,12,n.color).addToScene(o),n.axesHelper){const i=new N.AxesHelper(5);o.add(i)}if(n.object3DHelper&&e){const i=new N.BoxHelper(e,new N.Color(n.color));o.add(i)}},Qg=(o,e)=>{if(e.ambientLight){const n=new N.AmbientLight(e.ambientLight.color,e.ambientLight.intensity);o.add(n)}if(e.hemisphereLight){const n=new N.HemisphereLight(e.hemisphereLight.skyColor,e.hemisphereLight.groundColor,e.hemisphereLight.intensity);o.add(n)}if(e.directionalLight){const n=new N.DirectionalLight(e.directionalLight.color,e.directionalLight.intensity);n.position.copy(e.directionalLight.position),n.castShadow=e.directionalLight.castShadow,n.castShadow&&(n.shadow.mapSize.width=e.directionalLight.shadow.mapSize.width,n.shadow.mapSize.height=e.directionalLight.shadow.mapSize.height,n.shadow.camera.near=e.directionalLight.shadow.camera.near,n.shadow.camera.far=e.directionalLight.shadow.camera.far,n.shadow.camera.left=e.directionalLight.shadow.camera.left,n.shadow.camera.right=e.directionalLight.shadow.camera.right,n.shadow.camera.top=e.directionalLight.shadow.camera.top,n.shadow.camera.bottom=e.directionalLight.shadow.camera.bottom,n.shadow.bias=e.directionalLight.shadow.bias,n.shadow.radius=e.directionalLight.shadow.radius),o.add(n)}},Jg=o=>{const e=o.getContext("2d");if(!e)throw new Error("Canvas 2d context is not supported");return e},e0=10,t0=.75,n0=300,r0=250,i0=1,s0="rgba(34, 34, 34, 0.95)",a0="rgba(0, 0, 0, 1)",o0="rgba(15, 15, 15, 1)",c0=(o,e)=>{const n=document.createElement("canvas");n.width=e.x,n.height=e.y;const i=Jg(n);i.fillStyle=o0,i.fillRect(0,0,e.x,e.y);const s=i.getImageData(0,0,e.x,e.y),c=s.data;for(let f=0;f<c.length;f+=4){const p=Math.random()*n0;c[f]+=p,c[f+1]+=p,c[f+2]+=p,c[f+3]=r0}i.putImageData(s,0,0),i.filter=`blur(${i0}px)`,i.drawImage(n,0,0),i.filter="none";const a=i.createRadialGradient(e.x/2,e.y/2,e0,e.x/2,e.y/2,e.y*t0);a.addColorStop(0,s0),a.addColorStop(1,a0),i.fillStyle=a,i.fillRect(0,0,e.x,e.y);const u=new N.CanvasTexture(n);u.minFilter=N.LinearFilter,u.magFilter=N.LinearFilter,u.wrapS=N.ClampToEdgeWrapping,u.wrapT=N.ClampToEdgeWrapping,o.background=u},{PhysicalCamera:l0}=Cs(),u0=(o,e)=>{const n=new N.Box3().setFromObject(o),i=n.getSize(new N.Vector3),s=n.getCenter(new N.Vector3),c=1.2;e instanceof N.PerspectiveCamera||e instanceof l0?f0(e,i,s,c):e instanceof N.OrthographicCamera?h0(e,i,s,c):console.warn("Camera type not supported in fitCameraToObject")},f0=(o,e,n,i)=>{const s=Math.max(e.x,e.y,e.z),c=o.fov*Math.PI/180;let a=Math.abs(s/2/Math.tan(c/2));a*=i,o.position.set(n.x,n.y,n.z+a),o.lookAt(n),o.updateProjectionMatrix()},h0=(o,e,n,i)=>{const s=e.x*i,c=e.y*i;o.left=-s/2,o.right=s/2,o.top=c/2,o.bottom=-c/2;const a=n.z+e.z*i;o.position.set(n.x,n.y,a),o.lookAt(n),o.near=.1,o.far=a+e.z*i,o.updateProjectionMatrix()},d0=o=>{const e=new N.Scene,n=o.backgroundColor;return e.background=new N.Color(n),e};class p0{constructor(e,n,i,s,c){this.scene=null,this.object=e,this.camera=n,this.controls=i,this.options=s,this.mountRef=c}setup(){try{if(!this.mountRef.current)return se.err(new oe("Cannot initialize scene: Mount element is not ready",ue.COMPONENT_NOT_MOUNTED,{manager:"SceneInitializer"}));if(!this.camera)return se.err(new oe("Cannot initialize scene: Camera is not provided",ue.CAMERA_INIT_FAILED,{manager:"SceneInitializer"}));if(!this.controls)return se.err(new oe("Cannot initialize scene: Controls are not provided",ue.INVALID_CONFIGURATION,{manager:"SceneInitializer"}));if(this.scene=d0(this.options),!this.scene)return se.err(new oe("Failed to initialize Three.js scene",ue.SCENE_INIT_FAILED,{options:this.options}));const e=this.setupScene();return e.ok?se.ok(this.scene):e}catch(e){return se.err(oe.fromError(e,ue.SCENE_INIT_FAILED,{options:this.options,hasObject:!!this.object}))}}setupScene(){try{if(!this.mountRef.current)return se.err(new oe("Mount element became unavailable during scene setup",ue.COMPONENT_NOT_MOUNTED));const e=this.mountRef.current.clientWidth,n=this.mountRef.current.clientHeight;if(e<=0||n<=0)return se.err(new oe("Invalid mount element dimensions",ue.INVALID_CONFIGURATION,{width:e,height:n}));const i=new N.Vector2(e*3,n*3);this.options.helpers.studioEnvironment&&c0(this.scene,i),this.setupObjectInScene(),Qg(this.scene,this.options.lightning),$g(this.scene,this.object,this.options.helpers),this.options.camera.autoFitToObject&&this.object&&u0(this.scene,this.camera);const s=new N.Vector3;return this.scene.position.copy(s),this.controls.target.copy(s),this.controls.update(),se.ok(void 0)}catch(e){return se.err(oe.fromError(e,ue.SCENE_INIT_FAILED,{phase:"setupScene"}))}}setupObjectInScene(){this.object&&this.scene&&(this.object.castShadow=!0,this.object.traverse(e=>{e instanceof N.Mesh&&(e.castShadow=!0,e.receiveShadow=!0)}),this.scene.add(this.object))}dispose(){var e;if(this.scene){for(;this.scene.children.length>0;){const n=this.scene.children[0];if(this.scene.remove(n),n instanceof N.Mesh||n instanceof N.Line||n instanceof N.Points){(e=n.geometry)==null||e.dispose();const i=n.material;Array.isArray(i)?i.forEach(s=>s==null?void 0:s.dispose()):i==null||i.dispose()}}this.scene=null}}}class m0{constructor(e,n,i,s,c){this.isPathTracing=!1,this.ptRenderer=null,this.renderCount=0,this.animatePathTracing=()=>{var a;if(!(!this.isPathTracing||!this.ptRenderer)){if(this.renderCount+=1,this.renderCount>=this.maxSamples){this.stopPathTracing(),console.log(`Path tracing completed after ${this.renderCount} samples.`),this.saveScreenshot();return}requestAnimationFrame(()=>this.animatePathTracing()),(a=this.ptRenderer)==null||a.renderSample()}},this.renderer=e,this.scene=n,this.camera=i,this.maxSamples=s.maxSamplesPathTracing??100,this._onComplete=c}setup(){try{if(!this.renderer)return se.err(new oe("Cannot setup path tracer: Renderer is not provided",ue.RENDERER_INIT_FAILED,{manager:"PathTracingManager"}));if(!this.scene)return se.err(new oe("Cannot setup path tracer: Scene is not provided",ue.SCENE_INIT_FAILED,{manager:"PathTracingManager"}));if(!this.camera)return se.err(new oe("Cannot setup path tracer: Camera is not provided",ue.CAMERA_INIT_FAILED,{manager:"PathTracingManager"}));const{WebGLPathTracer:e}=Cs();if(!e)return se.err(new oe("Failed to import WebGLPathTracer",ue.RESOURCE_NOT_FOUND,{manager:"PathTracingManager"}));if(this.ptRenderer=new e(this.renderer),!this.ptRenderer)return se.err(new oe("Failed to initialize WebGLPathTracer",ue.INVALID_CONFIGURATION,{manager:"PathTracingManager"}));const n=this.updatePathTracerRenderer();return n.ok?se.ok(this.ptRenderer):se.err(n.error)}catch(e){return se.err(oe.fromError(e,ue.INVALID_CONFIGURATION,{manager:"PathTracingManager",maxSamples:this.maxSamples}))}}updatePathTracerRenderer(){try{return this.ptRenderer?(this.ptRenderer.setScene(this.scene,this.camera),this.ptRenderer.renderToCanvas=!0,this.ptRenderer.updateMaterials(),this.ptRenderer.updateLights(),this.scene.environment&&this.ptRenderer.updateEnvironment(),se.ok(void 0)):se.err(new oe("Path tracer not initialized",ue.INVALID_CONFIGURATION,{manager:"PathTracingManager"}))}catch(e){return se.err(oe.fromError(e,ue.RENDER_ERROR,{phase:"updatePathTracerRenderer",hasEnvironment:!!this.scene.environment}))}}set onComplete(e){this._onComplete=e}get onComplete(){return this._onComplete}startPathTracing(){!this.isPathTracing&&this.ptRenderer&&(this.isPathTracing=!0,this.renderCount=0,this.ptRenderer.reset(),this.animatePathTracing())}stopPathTracing(){this.isPathTracing=!1}saveScreenshot(){const n=this.renderer.domElement.toDataURL("image/png");this.onComplete(n)}resetForStandardRender(){this.isPathTracing=!1,this.renderCount=0}dispose(){this.stopPathTracing(),this.ptRenderer&&("dispose"in this.ptRenderer&&typeof this.ptRenderer.dispose=="function"&&this.ptRenderer.dispose(),this.ptRenderer=null)}}var Si={exports:{}};/**
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
4066
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
4067
|
-
*/var g0=Si.exports,Hl;function v0(){return Hl||(Hl=1,function(o,e){(function(){var n,i="4.17.21",s=200,c="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",u="Invalid `variable` option passed into `_.template`",f="__lodash_hash_undefined__",p=500,v="__lodash_placeholder__",g=1,h=2,b=4,R=1,M=2,x=1,A=2,E=4,C=8,P=16,O=32,B=64,k=128,q=256,j=512,K=30,$="...",H=800,Z=16,Q=1,ce=2,Re=3,ke=1/0,Ie=9007199254740991,et=17976931348623157e292,vt=NaN,je=4294967295,mn=je-1,gn=je>>>1,Kn=[["ary",k],["bind",x],["bindKey",A],["curry",C],["curryRight",P],["flip",j],["partial",O],["partialRight",B],["rearg",q]],Lt="[object Arguments]",Se="[object Array]",Ke="[object AsyncFunction]",De="[object Boolean]",Te="[object Date]",Ze="[object DOMException]",an="[object Error]",yt="[object Function]",Nt="[object GeneratorFunction]",ct="[object Map]",lt="[object Number]",_t="[object Null]",st="[object Object]",Xn="[object Promise]",on="[object Proxy]",En="[object RegExp]",xt="[object Set]",Bt="[object String]",Zn="[object Symbol]",Mi="[object Undefined]",cn="[object WeakMap]",pr="[object WeakSet]",ln="[object ArrayBuffer]",vn="[object DataView]",Sn="[object Float32Array]",Mn="[object Float64Array]",mr="[object Int8Array]",gr="[object Int16Array]",vr="[object Int32Array]",yr="[object Uint8Array]",_r="[object Uint8ClampedArray]",xr="[object Uint16Array]",br="[object Uint32Array]",Cn=/\b__p \+= '';/g,Tr=/\b(__p \+=) '' \+/g,bt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,yn=/&(?:amp|lt|gt|quot|#39);/g,_n=/[&<>"']/g,wr=RegExp(yn.source),Ci=RegExp(_n.source),Rr=/<%-([\s\S]+?)%>/g,Ii=/<%([\s\S]+?)%>/g,$n=/<%=([\s\S]+?)%>/g,Ar=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pi=/^\w*$/,Di=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,In=/[\\^$.*+?()[\]{}|]/g,Er=RegExp(In.source),Sr=/^\s+/,Fi=/\s/,Oi=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Li=/\{\n\/\* \[wrapped with (.+)\] \*/,y=/,? & /,D=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,z=/[()=,{}\[\]\/\s]/,X=/\\(\\)?/g,re=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ae=/\w*$/,te=/^[-+]0x[0-9a-f]+$/i,ee=/^0b[01]+$/i,Pe=/^\[object .+?Constructor\]$/,pe=/^0o[0-7]+$/i,ge=/^(?:0|[1-9]\d*)$/,Ue=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,at=/($^)/,ut=/['\n\r\u2028\u2029\\]/g,Ce="\\ud800-\\udfff",Pn="\\u0300-\\u036f",Ni="\\ufe20-\\ufe2f",Bi="\\u20d0-\\u20ff",jl=Pn+Ni+Bi,ql="\\u2700-\\u27bf",Yl="a-z\\xdf-\\xf6\\xf8-\\xff",M0="\\xac\\xb1\\xd7\\xf7",C0="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",I0="\\u2000-\\u206f",P0=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Kl="A-Z\\xc0-\\xd6\\xd8-\\xde",Xl="\\ufe0e\\ufe0f",Zl=M0+C0+I0+P0,uo="['’]",D0="["+Ce+"]",$l="["+Zl+"]",Fs="["+jl+"]",Ql="\\d+",F0="["+ql+"]",Jl="["+Yl+"]",eu="[^"+Ce+Zl+Ql+ql+Yl+Kl+"]",fo="\\ud83c[\\udffb-\\udfff]",O0="(?:"+Fs+"|"+fo+")",tu="[^"+Ce+"]",ho="(?:\\ud83c[\\udde6-\\uddff]){2}",po="[\\ud800-\\udbff][\\udc00-\\udfff]",ei="["+Kl+"]",nu="\\u200d",ru="(?:"+Jl+"|"+eu+")",L0="(?:"+ei+"|"+eu+")",iu="(?:"+uo+"(?:d|ll|m|re|s|t|ve))?",su="(?:"+uo+"(?:D|LL|M|RE|S|T|VE))?",au=O0+"?",ou="["+Xl+"]?",N0="(?:"+nu+"(?:"+[tu,ho,po].join("|")+")"+ou+au+")*",B0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",k0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",cu=ou+au+N0,U0="(?:"+[F0,ho,po].join("|")+")"+cu,z0="(?:"+[tu+Fs+"?",Fs,ho,po,D0].join("|")+")",H0=RegExp(uo,"g"),G0=RegExp(Fs,"g"),mo=RegExp(fo+"(?="+fo+")|"+z0+cu,"g"),W0=RegExp([ei+"?"+Jl+"+"+iu+"(?="+[$l,ei,"$"].join("|")+")",L0+"+"+su+"(?="+[$l,ei+ru,"$"].join("|")+")",ei+"?"+ru+"+"+iu,ei+"+"+su,k0,B0,Ql,U0].join("|"),"g"),V0=RegExp("["+nu+Ce+jl+Xl+"]"),j0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,q0=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Y0=-1,We={};We[Sn]=We[Mn]=We[mr]=We[gr]=We[vr]=We[yr]=We[_r]=We[xr]=We[br]=!0,We[Lt]=We[Se]=We[ln]=We[De]=We[vn]=We[Te]=We[an]=We[yt]=We[ct]=We[lt]=We[st]=We[En]=We[xt]=We[Bt]=We[cn]=!1;var He={};He[Lt]=He[Se]=He[ln]=He[vn]=He[De]=He[Te]=He[Sn]=He[Mn]=He[mr]=He[gr]=He[vr]=He[ct]=He[lt]=He[st]=He[En]=He[xt]=He[Bt]=He[Zn]=He[yr]=He[_r]=He[xr]=He[br]=!0,He[an]=He[yt]=He[cn]=!1;var K0={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},X0={"&":"&","<":"<",">":">",'"':""","'":"'"},Z0={"&":"&","<":"<",">":">",""":'"',"'":"'"},$0={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Q0=parseFloat,J0=parseInt,lu=typeof Ji=="object"&&Ji&&Ji.Object===Object&&Ji,ev=typeof self=="object"&&self&&self.Object===Object&&self,ft=lu||ev||Function("return this")(),go=e&&!e.nodeType&&e,Mr=go&&!0&&o&&!o.nodeType&&o,uu=Mr&&Mr.exports===go,vo=uu&&lu.process,Kt=function(){try{var F=Mr&&Mr.require&&Mr.require("util").types;return F||vo&&vo.binding&&vo.binding("util")}catch{}}(),fu=Kt&&Kt.isArrayBuffer,hu=Kt&&Kt.isDate,du=Kt&&Kt.isMap,pu=Kt&&Kt.isRegExp,mu=Kt&&Kt.isSet,gu=Kt&&Kt.isTypedArray;function kt(F,G,U){switch(U.length){case 0:return F.call(G);case 1:return F.call(G,U[0]);case 2:return F.call(G,U[0],U[1]);case 3:return F.call(G,U[0],U[1],U[2])}return F.apply(G,U)}function tv(F,G,U,ne){for(var me=-1,Fe=F==null?0:F.length;++me<Fe;){var rt=F[me];G(ne,rt,U(rt),F)}return ne}function Xt(F,G){for(var U=-1,ne=F==null?0:F.length;++U<ne&&G(F[U],U,F)!==!1;);return F}function nv(F,G){for(var U=F==null?0:F.length;U--&&G(F[U],U,F)!==!1;);return F}function vu(F,G){for(var U=-1,ne=F==null?0:F.length;++U<ne;)if(!G(F[U],U,F))return!1;return!0}function Qn(F,G){for(var U=-1,ne=F==null?0:F.length,me=0,Fe=[];++U<ne;){var rt=F[U];G(rt,U,F)&&(Fe[me++]=rt)}return Fe}function Os(F,G){var U=F==null?0:F.length;return!!U&&ti(F,G,0)>-1}function yo(F,G,U){for(var ne=-1,me=F==null?0:F.length;++ne<me;)if(U(G,F[ne]))return!0;return!1}function Ve(F,G){for(var U=-1,ne=F==null?0:F.length,me=Array(ne);++U<ne;)me[U]=G(F[U],U,F);return me}function Jn(F,G){for(var U=-1,ne=G.length,me=F.length;++U<ne;)F[me+U]=G[U];return F}function _o(F,G,U,ne){var me=-1,Fe=F==null?0:F.length;for(ne&&Fe&&(U=F[++me]);++me<Fe;)U=G(U,F[me],me,F);return U}function rv(F,G,U,ne){var me=F==null?0:F.length;for(ne&&me&&(U=F[--me]);me--;)U=G(U,F[me],me,F);return U}function xo(F,G){for(var U=-1,ne=F==null?0:F.length;++U<ne;)if(G(F[U],U,F))return!0;return!1}var iv=bo("length");function sv(F){return F.split("")}function av(F){return F.match(D)||[]}function yu(F,G,U){var ne;return U(F,function(me,Fe,rt){if(G(me,Fe,rt))return ne=Fe,!1}),ne}function Ls(F,G,U,ne){for(var me=F.length,Fe=U+(ne?1:-1);ne?Fe--:++Fe<me;)if(G(F[Fe],Fe,F))return Fe;return-1}function ti(F,G,U){return G===G?yv(F,G,U):Ls(F,_u,U)}function ov(F,G,U,ne){for(var me=U-1,Fe=F.length;++me<Fe;)if(ne(F[me],G))return me;return-1}function _u(F){return F!==F}function xu(F,G){var U=F==null?0:F.length;return U?wo(F,G)/U:vt}function bo(F){return function(G){return G==null?n:G[F]}}function To(F){return function(G){return F==null?n:F[G]}}function bu(F,G,U,ne,me){return me(F,function(Fe,rt,ze){U=ne?(ne=!1,Fe):G(U,Fe,rt,ze)}),U}function cv(F,G){var U=F.length;for(F.sort(G);U--;)F[U]=F[U].value;return F}function wo(F,G){for(var U,ne=-1,me=F.length;++ne<me;){var Fe=G(F[ne]);Fe!==n&&(U=U===n?Fe:U+Fe)}return U}function Ro(F,G){for(var U=-1,ne=Array(F);++U<F;)ne[U]=G(U);return ne}function lv(F,G){return Ve(G,function(U){return[U,F[U]]})}function Tu(F){return F&&F.slice(0,Eu(F)+1).replace(Sr,"")}function Ut(F){return function(G){return F(G)}}function Ao(F,G){return Ve(G,function(U){return F[U]})}function ki(F,G){return F.has(G)}function wu(F,G){for(var U=-1,ne=F.length;++U<ne&&ti(G,F[U],0)>-1;);return U}function Ru(F,G){for(var U=F.length;U--&&ti(G,F[U],0)>-1;);return U}function uv(F,G){for(var U=F.length,ne=0;U--;)F[U]===G&&++ne;return ne}var fv=To(K0),hv=To(X0);function dv(F){return"\\"+$0[F]}function pv(F,G){return F==null?n:F[G]}function ni(F){return V0.test(F)}function mv(F){return j0.test(F)}function gv(F){for(var G,U=[];!(G=F.next()).done;)U.push(G.value);return U}function Eo(F){var G=-1,U=Array(F.size);return F.forEach(function(ne,me){U[++G]=[me,ne]}),U}function Au(F,G){return function(U){return F(G(U))}}function er(F,G){for(var U=-1,ne=F.length,me=0,Fe=[];++U<ne;){var rt=F[U];(rt===G||rt===v)&&(F[U]=v,Fe[me++]=U)}return Fe}function Ns(F){var G=-1,U=Array(F.size);return F.forEach(function(ne){U[++G]=ne}),U}function vv(F){var G=-1,U=Array(F.size);return F.forEach(function(ne){U[++G]=[ne,ne]}),U}function yv(F,G,U){for(var ne=U-1,me=F.length;++ne<me;)if(F[ne]===G)return ne;return-1}function _v(F,G,U){for(var ne=U+1;ne--;)if(F[ne]===G)return ne;return ne}function ri(F){return ni(F)?bv(F):iv(F)}function un(F){return ni(F)?Tv(F):sv(F)}function Eu(F){for(var G=F.length;G--&&Fi.test(F.charAt(G)););return G}var xv=To(Z0);function bv(F){for(var G=mo.lastIndex=0;mo.test(F);)++G;return G}function Tv(F){return F.match(mo)||[]}function wv(F){return F.match(W0)||[]}var Rv=function F(G){G=G==null?ft:ii.defaults(ft.Object(),G,ii.pick(ft,q0));var U=G.Array,ne=G.Date,me=G.Error,Fe=G.Function,rt=G.Math,ze=G.Object,So=G.RegExp,Av=G.String,Zt=G.TypeError,Bs=U.prototype,Ev=Fe.prototype,si=ze.prototype,ks=G["__core-js_shared__"],Us=Ev.toString,Le=si.hasOwnProperty,Sv=0,Su=function(){var t=/[^.]+$/.exec(ks&&ks.keys&&ks.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),zs=si.toString,Mv=Us.call(ze),Cv=ft._,Iv=So("^"+Us.call(Le).replace(In,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hs=uu?G.Buffer:n,tr=G.Symbol,Gs=G.Uint8Array,Mu=Hs?Hs.allocUnsafe:n,Ws=Au(ze.getPrototypeOf,ze),Cu=ze.create,Iu=si.propertyIsEnumerable,Vs=Bs.splice,Pu=tr?tr.isConcatSpreadable:n,Ui=tr?tr.iterator:n,Cr=tr?tr.toStringTag:n,js=function(){try{var t=Or(ze,"defineProperty");return t({},"",{}),t}catch{}}(),Pv=G.clearTimeout!==ft.clearTimeout&&G.clearTimeout,Dv=ne&&ne.now!==ft.Date.now&&ne.now,Fv=G.setTimeout!==ft.setTimeout&&G.setTimeout,qs=rt.ceil,Ys=rt.floor,Mo=ze.getOwnPropertySymbols,Ov=Hs?Hs.isBuffer:n,Du=G.isFinite,Lv=Bs.join,Nv=Au(ze.keys,ze),it=rt.max,dt=rt.min,Bv=ne.now,kv=G.parseInt,Fu=rt.random,Uv=Bs.reverse,Co=Or(G,"DataView"),zi=Or(G,"Map"),Io=Or(G,"Promise"),ai=Or(G,"Set"),Hi=Or(G,"WeakMap"),Gi=Or(ze,"create"),Ks=Hi&&new Hi,oi={},zv=Lr(Co),Hv=Lr(zi),Gv=Lr(Io),Wv=Lr(ai),Vv=Lr(Hi),Xs=tr?tr.prototype:n,Wi=Xs?Xs.valueOf:n,Ou=Xs?Xs.toString:n;function T(t){if(Xe(t)&&!ve(t)&&!(t instanceof Ae)){if(t instanceof $t)return t;if(Le.call(t,"__wrapped__"))return Nf(t)}return new $t(t)}var ci=function(){function t(){}return function(r){if(!qe(r))return{};if(Cu)return Cu(r);t.prototype=r;var l=new t;return t.prototype=n,l}}();function Zs(){}function $t(t,r){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!r,this.__index__=0,this.__values__=n}T.templateSettings={escape:Rr,evaluate:Ii,interpolate:$n,variable:"",imports:{_:T}},T.prototype=Zs.prototype,T.prototype.constructor=T,$t.prototype=ci(Zs.prototype),$t.prototype.constructor=$t;function Ae(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=je,this.__views__=[]}function jv(){var t=new Ae(this.__wrapped__);return t.__actions__=Ct(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ct(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ct(this.__views__),t}function qv(){if(this.__filtered__){var t=new Ae(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Yv(){var t=this.__wrapped__.value(),r=this.__dir__,l=ve(t),d=r<0,_=l?t.length:0,w=s_(0,_,this.__views__),S=w.start,I=w.end,L=I-S,W=d?I:S-1,V=this.__iteratees__,Y=V.length,J=0,ie=dt(L,this.__takeCount__);if(!l||!d&&_==L&&ie==L)return sf(t,this.__actions__);var he=[];e:for(;L--&&J<ie;){W+=r;for(var _e=-1,de=t[W];++_e<Y;){var we=V[_e],Me=we.iteratee,Gt=we.type,Rt=Me(de);if(Gt==ce)de=Rt;else if(!Rt){if(Gt==Q)continue e;break e}}he[J++]=de}return he}Ae.prototype=ci(Zs.prototype),Ae.prototype.constructor=Ae;function Ir(t){var r=-1,l=t==null?0:t.length;for(this.clear();++r<l;){var d=t[r];this.set(d[0],d[1])}}function Kv(){this.__data__=Gi?Gi(null):{},this.size=0}function Xv(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}function Zv(t){var r=this.__data__;if(Gi){var l=r[t];return l===f?n:l}return Le.call(r,t)?r[t]:n}function $v(t){var r=this.__data__;return Gi?r[t]!==n:Le.call(r,t)}function Qv(t,r){var l=this.__data__;return this.size+=this.has(t)?0:1,l[t]=Gi&&r===n?f:r,this}Ir.prototype.clear=Kv,Ir.prototype.delete=Xv,Ir.prototype.get=Zv,Ir.prototype.has=$v,Ir.prototype.set=Qv;function Dn(t){var r=-1,l=t==null?0:t.length;for(this.clear();++r<l;){var d=t[r];this.set(d[0],d[1])}}function Jv(){this.__data__=[],this.size=0}function ey(t){var r=this.__data__,l=$s(r,t);if(l<0)return!1;var d=r.length-1;return l==d?r.pop():Vs.call(r,l,1),--this.size,!0}function ty(t){var r=this.__data__,l=$s(r,t);return l<0?n:r[l][1]}function ny(t){return $s(this.__data__,t)>-1}function ry(t,r){var l=this.__data__,d=$s(l,t);return d<0?(++this.size,l.push([t,r])):l[d][1]=r,this}Dn.prototype.clear=Jv,Dn.prototype.delete=ey,Dn.prototype.get=ty,Dn.prototype.has=ny,Dn.prototype.set=ry;function Fn(t){var r=-1,l=t==null?0:t.length;for(this.clear();++r<l;){var d=t[r];this.set(d[0],d[1])}}function iy(){this.size=0,this.__data__={hash:new Ir,map:new(zi||Dn),string:new Ir}}function sy(t){var r=la(this,t).delete(t);return this.size-=r?1:0,r}function ay(t){return la(this,t).get(t)}function oy(t){return la(this,t).has(t)}function cy(t,r){var l=la(this,t),d=l.size;return l.set(t,r),this.size+=l.size==d?0:1,this}Fn.prototype.clear=iy,Fn.prototype.delete=sy,Fn.prototype.get=ay,Fn.prototype.has=oy,Fn.prototype.set=cy;function Pr(t){var r=-1,l=t==null?0:t.length;for(this.__data__=new Fn;++r<l;)this.add(t[r])}function ly(t){return this.__data__.set(t,f),this}function uy(t){return this.__data__.has(t)}Pr.prototype.add=Pr.prototype.push=ly,Pr.prototype.has=uy;function fn(t){var r=this.__data__=new Dn(t);this.size=r.size}function fy(){this.__data__=new Dn,this.size=0}function hy(t){var r=this.__data__,l=r.delete(t);return this.size=r.size,l}function dy(t){return this.__data__.get(t)}function py(t){return this.__data__.has(t)}function my(t,r){var l=this.__data__;if(l instanceof Dn){var d=l.__data__;if(!zi||d.length<s-1)return d.push([t,r]),this.size=++l.size,this;l=this.__data__=new Fn(d)}return l.set(t,r),this.size=l.size,this}fn.prototype.clear=fy,fn.prototype.delete=hy,fn.prototype.get=dy,fn.prototype.has=py,fn.prototype.set=my;function Lu(t,r){var l=ve(t),d=!l&&Nr(t),_=!l&&!d&&ar(t),w=!l&&!d&&!_&&hi(t),S=l||d||_||w,I=S?Ro(t.length,Av):[],L=I.length;for(var W in t)(r||Le.call(t,W))&&!(S&&(W=="length"||_&&(W=="offset"||W=="parent")||w&&(W=="buffer"||W=="byteLength"||W=="byteOffset")||Bn(W,L)))&&I.push(W);return I}function Nu(t){var r=t.length;return r?t[Ho(0,r-1)]:n}function gy(t,r){return ua(Ct(t),Dr(r,0,t.length))}function vy(t){return ua(Ct(t))}function Po(t,r,l){(l!==n&&!hn(t[r],l)||l===n&&!(r in t))&&On(t,r,l)}function Vi(t,r,l){var d=t[r];(!(Le.call(t,r)&&hn(d,l))||l===n&&!(r in t))&&On(t,r,l)}function $s(t,r){for(var l=t.length;l--;)if(hn(t[l][0],r))return l;return-1}function yy(t,r,l,d){return nr(t,function(_,w,S){r(d,_,l(_),S)}),d}function Bu(t,r){return t&&bn(r,ot(r),t)}function _y(t,r){return t&&bn(r,Pt(r),t)}function On(t,r,l){r=="__proto__"&&js?js(t,r,{configurable:!0,enumerable:!0,value:l,writable:!0}):t[r]=l}function Do(t,r){for(var l=-1,d=r.length,_=U(d),w=t==null;++l<d;)_[l]=w?n:hc(t,r[l]);return _}function Dr(t,r,l){return t===t&&(l!==n&&(t=t<=l?t:l),r!==n&&(t=t>=r?t:r)),t}function Qt(t,r,l,d,_,w){var S,I=r&g,L=r&h,W=r&b;if(l&&(S=_?l(t,d,_,w):l(t)),S!==n)return S;if(!qe(t))return t;var V=ve(t);if(V){if(S=o_(t),!I)return Ct(t,S)}else{var Y=pt(t),J=Y==yt||Y==Nt;if(ar(t))return cf(t,I);if(Y==st||Y==Lt||J&&!_){if(S=L||J?{}:Sf(t),!I)return L?Zy(t,_y(S,t)):Xy(t,Bu(S,t))}else{if(!He[Y])return _?t:{};S=c_(t,Y,I)}}w||(w=new fn);var ie=w.get(t);if(ie)return ie;w.set(t,S),nh(t)?t.forEach(function(de){S.add(Qt(de,r,l,de,t,w))}):eh(t)&&t.forEach(function(de,we){S.set(we,Qt(de,r,l,we,t,w))});var he=W?L?Qo:$o:L?Pt:ot,_e=V?n:he(t);return Xt(_e||t,function(de,we){_e&&(we=de,de=t[we]),Vi(S,we,Qt(de,r,l,we,t,w))}),S}function xy(t){var r=ot(t);return function(l){return ku(l,t,r)}}function ku(t,r,l){var d=l.length;if(t==null)return!d;for(t=ze(t);d--;){var _=l[d],w=r[_],S=t[_];if(S===n&&!(_ in t)||!w(S))return!1}return!0}function Uu(t,r,l){if(typeof t!="function")throw new Zt(a);return $i(function(){t.apply(n,l)},r)}function ji(t,r,l,d){var _=-1,w=Os,S=!0,I=t.length,L=[],W=r.length;if(!I)return L;l&&(r=Ve(r,Ut(l))),d?(w=yo,S=!1):r.length>=s&&(w=ki,S=!1,r=new Pr(r));e:for(;++_<I;){var V=t[_],Y=l==null?V:l(V);if(V=d||V!==0?V:0,S&&Y===Y){for(var J=W;J--;)if(r[J]===Y)continue e;L.push(V)}else w(r,Y,d)||L.push(V)}return L}var nr=df(xn),zu=df(Oo,!0);function by(t,r){var l=!0;return nr(t,function(d,_,w){return l=!!r(d,_,w),l}),l}function Qs(t,r,l){for(var d=-1,_=t.length;++d<_;){var w=t[d],S=r(w);if(S!=null&&(I===n?S===S&&!Ht(S):l(S,I)))var I=S,L=w}return L}function Ty(t,r,l,d){var _=t.length;for(l=ye(l),l<0&&(l=-l>_?0:_+l),d=d===n||d>_?_:ye(d),d<0&&(d+=_),d=l>d?0:ih(d);l<d;)t[l++]=r;return t}function Hu(t,r){var l=[];return nr(t,function(d,_,w){r(d,_,w)&&l.push(d)}),l}function ht(t,r,l,d,_){var w=-1,S=t.length;for(l||(l=u_),_||(_=[]);++w<S;){var I=t[w];r>0&&l(I)?r>1?ht(I,r-1,l,d,_):Jn(_,I):d||(_[_.length]=I)}return _}var Fo=pf(),Gu=pf(!0);function xn(t,r){return t&&Fo(t,r,ot)}function Oo(t,r){return t&&Gu(t,r,ot)}function Js(t,r){return Qn(r,function(l){return kn(t[l])})}function Fr(t,r){r=ir(r,t);for(var l=0,d=r.length;t!=null&&l<d;)t=t[Tn(r[l++])];return l&&l==d?t:n}function Wu(t,r,l){var d=r(t);return ve(t)?d:Jn(d,l(t))}function Tt(t){return t==null?t===n?Mi:_t:Cr&&Cr in ze(t)?i_(t):v_(t)}function Lo(t,r){return t>r}function wy(t,r){return t!=null&&Le.call(t,r)}function Ry(t,r){return t!=null&&r in ze(t)}function Ay(t,r,l){return t>=dt(r,l)&&t<it(r,l)}function No(t,r,l){for(var d=l?yo:Os,_=t[0].length,w=t.length,S=w,I=U(w),L=1/0,W=[];S--;){var V=t[S];S&&r&&(V=Ve(V,Ut(r))),L=dt(V.length,L),I[S]=!l&&(r||_>=120&&V.length>=120)?new Pr(S&&V):n}V=t[0];var Y=-1,J=I[0];e:for(;++Y<_&&W.length<L;){var ie=V[Y],he=r?r(ie):ie;if(ie=l||ie!==0?ie:0,!(J?ki(J,he):d(W,he,l))){for(S=w;--S;){var _e=I[S];if(!(_e?ki(_e,he):d(t[S],he,l)))continue e}J&&J.push(he),W.push(ie)}}return W}function Ey(t,r,l,d){return xn(t,function(_,w,S){r(d,l(_),w,S)}),d}function qi(t,r,l){r=ir(r,t),t=Pf(t,r);var d=t==null?t:t[Tn(en(r))];return d==null?n:kt(d,t,l)}function Vu(t){return Xe(t)&&Tt(t)==Lt}function Sy(t){return Xe(t)&&Tt(t)==ln}function My(t){return Xe(t)&&Tt(t)==Te}function Yi(t,r,l,d,_){return t===r?!0:t==null||r==null||!Xe(t)&&!Xe(r)?t!==t&&r!==r:Cy(t,r,l,d,Yi,_)}function Cy(t,r,l,d,_,w){var S=ve(t),I=ve(r),L=S?Se:pt(t),W=I?Se:pt(r);L=L==Lt?st:L,W=W==Lt?st:W;var V=L==st,Y=W==st,J=L==W;if(J&&ar(t)){if(!ar(r))return!1;S=!0,V=!1}if(J&&!V)return w||(w=new fn),S||hi(t)?Rf(t,r,l,d,_,w):n_(t,r,L,l,d,_,w);if(!(l&R)){var ie=V&&Le.call(t,"__wrapped__"),he=Y&&Le.call(r,"__wrapped__");if(ie||he){var _e=ie?t.value():t,de=he?r.value():r;return w||(w=new fn),_(_e,de,l,d,w)}}return J?(w||(w=new fn),r_(t,r,l,d,_,w)):!1}function Iy(t){return Xe(t)&&pt(t)==ct}function Bo(t,r,l,d){var _=l.length,w=_,S=!d;if(t==null)return!w;for(t=ze(t);_--;){var I=l[_];if(S&&I[2]?I[1]!==t[I[0]]:!(I[0]in t))return!1}for(;++_<w;){I=l[_];var L=I[0],W=t[L],V=I[1];if(S&&I[2]){if(W===n&&!(L in t))return!1}else{var Y=new fn;if(d)var J=d(W,V,L,t,r,Y);if(!(J===n?Yi(V,W,R|M,d,Y):J))return!1}}return!0}function ju(t){if(!qe(t)||h_(t))return!1;var r=kn(t)?Iv:Pe;return r.test(Lr(t))}function Py(t){return Xe(t)&&Tt(t)==En}function Dy(t){return Xe(t)&&pt(t)==xt}function Fy(t){return Xe(t)&&ga(t.length)&&!!We[Tt(t)]}function qu(t){return typeof t=="function"?t:t==null?Dt:typeof t=="object"?ve(t)?Xu(t[0],t[1]):Ku(t):mh(t)}function ko(t){if(!Zi(t))return Nv(t);var r=[];for(var l in ze(t))Le.call(t,l)&&l!="constructor"&&r.push(l);return r}function Oy(t){if(!qe(t))return g_(t);var r=Zi(t),l=[];for(var d in t)d=="constructor"&&(r||!Le.call(t,d))||l.push(d);return l}function Uo(t,r){return t<r}function Yu(t,r){var l=-1,d=It(t)?U(t.length):[];return nr(t,function(_,w,S){d[++l]=r(_,w,S)}),d}function Ku(t){var r=ec(t);return r.length==1&&r[0][2]?Cf(r[0][0],r[0][1]):function(l){return l===t||Bo(l,t,r)}}function Xu(t,r){return nc(t)&&Mf(r)?Cf(Tn(t),r):function(l){var d=hc(l,t);return d===n&&d===r?dc(l,t):Yi(r,d,R|M)}}function ea(t,r,l,d,_){t!==r&&Fo(r,function(w,S){if(_||(_=new fn),qe(w))Ly(t,r,S,l,ea,d,_);else{var I=d?d(ic(t,S),w,S+"",t,r,_):n;I===n&&(I=w),Po(t,S,I)}},Pt)}function Ly(t,r,l,d,_,w,S){var I=ic(t,l),L=ic(r,l),W=S.get(L);if(W){Po(t,l,W);return}var V=w?w(I,L,l+"",t,r,S):n,Y=V===n;if(Y){var J=ve(L),ie=!J&&ar(L),he=!J&&!ie&&hi(L);V=L,J||ie||he?ve(I)?V=I:$e(I)?V=Ct(I):ie?(Y=!1,V=cf(L,!0)):he?(Y=!1,V=lf(L,!0)):V=[]:Qi(L)||Nr(L)?(V=I,Nr(I)?V=sh(I):(!qe(I)||kn(I))&&(V=Sf(L))):Y=!1}Y&&(S.set(L,V),_(V,L,d,w,S),S.delete(L)),Po(t,l,V)}function Zu(t,r){var l=t.length;if(l)return r+=r<0?l:0,Bn(r,l)?t[r]:n}function $u(t,r,l){r.length?r=Ve(r,function(w){return ve(w)?function(S){return Fr(S,w.length===1?w[0]:w)}:w}):r=[Dt];var d=-1;r=Ve(r,Ut(fe()));var _=Yu(t,function(w,S,I){var L=Ve(r,function(W){return W(w)});return{criteria:L,index:++d,value:w}});return cv(_,function(w,S){return Ky(w,S,l)})}function Ny(t,r){return Qu(t,r,function(l,d){return dc(t,d)})}function Qu(t,r,l){for(var d=-1,_=r.length,w={};++d<_;){var S=r[d],I=Fr(t,S);l(I,S)&&Ki(w,ir(S,t),I)}return w}function By(t){return function(r){return Fr(r,t)}}function zo(t,r,l,d){var _=d?ov:ti,w=-1,S=r.length,I=t;for(t===r&&(r=Ct(r)),l&&(I=Ve(t,Ut(l)));++w<S;)for(var L=0,W=r[w],V=l?l(W):W;(L=_(I,V,L,d))>-1;)I!==t&&Vs.call(I,L,1),Vs.call(t,L,1);return t}function Ju(t,r){for(var l=t?r.length:0,d=l-1;l--;){var _=r[l];if(l==d||_!==w){var w=_;Bn(_)?Vs.call(t,_,1):Vo(t,_)}}return t}function Ho(t,r){return t+Ys(Fu()*(r-t+1))}function ky(t,r,l,d){for(var _=-1,w=it(qs((r-t)/(l||1)),0),S=U(w);w--;)S[d?w:++_]=t,t+=l;return S}function Go(t,r){var l="";if(!t||r<1||r>Ie)return l;do r%2&&(l+=t),r=Ys(r/2),r&&(t+=t);while(r);return l}function xe(t,r){return sc(If(t,r,Dt),t+"")}function Uy(t){return Nu(di(t))}function zy(t,r){var l=di(t);return ua(l,Dr(r,0,l.length))}function Ki(t,r,l,d){if(!qe(t))return t;r=ir(r,t);for(var _=-1,w=r.length,S=w-1,I=t;I!=null&&++_<w;){var L=Tn(r[_]),W=l;if(L==="__proto__"||L==="constructor"||L==="prototype")return t;if(_!=S){var V=I[L];W=d?d(V,L,I):n,W===n&&(W=qe(V)?V:Bn(r[_+1])?[]:{})}Vi(I,L,W),I=I[L]}return t}var ef=Ks?function(t,r){return Ks.set(t,r),t}:Dt,Hy=js?function(t,r){return js(t,"toString",{configurable:!0,enumerable:!1,value:mc(r),writable:!0})}:Dt;function Gy(t){return ua(di(t))}function Jt(t,r,l){var d=-1,_=t.length;r<0&&(r=-r>_?0:_+r),l=l>_?_:l,l<0&&(l+=_),_=r>l?0:l-r>>>0,r>>>=0;for(var w=U(_);++d<_;)w[d]=t[d+r];return w}function Wy(t,r){var l;return nr(t,function(d,_,w){return l=r(d,_,w),!l}),!!l}function ta(t,r,l){var d=0,_=t==null?d:t.length;if(typeof r=="number"&&r===r&&_<=gn){for(;d<_;){var w=d+_>>>1,S=t[w];S!==null&&!Ht(S)&&(l?S<=r:S<r)?d=w+1:_=w}return _}return Wo(t,r,Dt,l)}function Wo(t,r,l,d){var _=0,w=t==null?0:t.length;if(w===0)return 0;r=l(r);for(var S=r!==r,I=r===null,L=Ht(r),W=r===n;_<w;){var V=Ys((_+w)/2),Y=l(t[V]),J=Y!==n,ie=Y===null,he=Y===Y,_e=Ht(Y);if(S)var de=d||he;else W?de=he&&(d||J):I?de=he&&J&&(d||!ie):L?de=he&&J&&!ie&&(d||!_e):ie||_e?de=!1:de=d?Y<=r:Y<r;de?_=V+1:w=V}return dt(w,mn)}function tf(t,r){for(var l=-1,d=t.length,_=0,w=[];++l<d;){var S=t[l],I=r?r(S):S;if(!l||!hn(I,L)){var L=I;w[_++]=S===0?0:S}}return w}function nf(t){return typeof t=="number"?t:Ht(t)?vt:+t}function zt(t){if(typeof t=="string")return t;if(ve(t))return Ve(t,zt)+"";if(Ht(t))return Ou?Ou.call(t):"";var r=t+"";return r=="0"&&1/t==-ke?"-0":r}function rr(t,r,l){var d=-1,_=Os,w=t.length,S=!0,I=[],L=I;if(l)S=!1,_=yo;else if(w>=s){var W=r?null:e_(t);if(W)return Ns(W);S=!1,_=ki,L=new Pr}else L=r?[]:I;e:for(;++d<w;){var V=t[d],Y=r?r(V):V;if(V=l||V!==0?V:0,S&&Y===Y){for(var J=L.length;J--;)if(L[J]===Y)continue e;r&&L.push(Y),I.push(V)}else _(L,Y,l)||(L!==I&&L.push(Y),I.push(V))}return I}function Vo(t,r){return r=ir(r,t),t=Pf(t,r),t==null||delete t[Tn(en(r))]}function rf(t,r,l,d){return Ki(t,r,l(Fr(t,r)),d)}function na(t,r,l,d){for(var _=t.length,w=d?_:-1;(d?w--:++w<_)&&r(t[w],w,t););return l?Jt(t,d?0:w,d?w+1:_):Jt(t,d?w+1:0,d?_:w)}function sf(t,r){var l=t;return l instanceof Ae&&(l=l.value()),_o(r,function(d,_){return _.func.apply(_.thisArg,Jn([d],_.args))},l)}function jo(t,r,l){var d=t.length;if(d<2)return d?rr(t[0]):[];for(var _=-1,w=U(d);++_<d;)for(var S=t[_],I=-1;++I<d;)I!=_&&(w[_]=ji(w[_]||S,t[I],r,l));return rr(ht(w,1),r,l)}function af(t,r,l){for(var d=-1,_=t.length,w=r.length,S={};++d<_;){var I=d<w?r[d]:n;l(S,t[d],I)}return S}function qo(t){return $e(t)?t:[]}function Yo(t){return typeof t=="function"?t:Dt}function ir(t,r){return ve(t)?t:nc(t,r)?[t]:Lf(Oe(t))}var Vy=xe;function sr(t,r,l){var d=t.length;return l=l===n?d:l,!r&&l>=d?t:Jt(t,r,l)}var of=Pv||function(t){return ft.clearTimeout(t)};function cf(t,r){if(r)return t.slice();var l=t.length,d=Mu?Mu(l):new t.constructor(l);return t.copy(d),d}function Ko(t){var r=new t.constructor(t.byteLength);return new Gs(r).set(new Gs(t)),r}function jy(t,r){var l=r?Ko(t.buffer):t.buffer;return new t.constructor(l,t.byteOffset,t.byteLength)}function qy(t){var r=new t.constructor(t.source,ae.exec(t));return r.lastIndex=t.lastIndex,r}function Yy(t){return Wi?ze(Wi.call(t)):{}}function lf(t,r){var l=r?Ko(t.buffer):t.buffer;return new t.constructor(l,t.byteOffset,t.length)}function uf(t,r){if(t!==r){var l=t!==n,d=t===null,_=t===t,w=Ht(t),S=r!==n,I=r===null,L=r===r,W=Ht(r);if(!I&&!W&&!w&&t>r||w&&S&&L&&!I&&!W||d&&S&&L||!l&&L||!_)return 1;if(!d&&!w&&!W&&t<r||W&&l&&_&&!d&&!w||I&&l&&_||!S&&_||!L)return-1}return 0}function Ky(t,r,l){for(var d=-1,_=t.criteria,w=r.criteria,S=_.length,I=l.length;++d<S;){var L=uf(_[d],w[d]);if(L){if(d>=I)return L;var W=l[d];return L*(W=="desc"?-1:1)}}return t.index-r.index}function ff(t,r,l,d){for(var _=-1,w=t.length,S=l.length,I=-1,L=r.length,W=it(w-S,0),V=U(L+W),Y=!d;++I<L;)V[I]=r[I];for(;++_<S;)(Y||_<w)&&(V[l[_]]=t[_]);for(;W--;)V[I++]=t[_++];return V}function hf(t,r,l,d){for(var _=-1,w=t.length,S=-1,I=l.length,L=-1,W=r.length,V=it(w-I,0),Y=U(V+W),J=!d;++_<V;)Y[_]=t[_];for(var ie=_;++L<W;)Y[ie+L]=r[L];for(;++S<I;)(J||_<w)&&(Y[ie+l[S]]=t[_++]);return Y}function Ct(t,r){var l=-1,d=t.length;for(r||(r=U(d));++l<d;)r[l]=t[l];return r}function bn(t,r,l,d){var _=!l;l||(l={});for(var w=-1,S=r.length;++w<S;){var I=r[w],L=d?d(l[I],t[I],I,l,t):n;L===n&&(L=t[I]),_?On(l,I,L):Vi(l,I,L)}return l}function Xy(t,r){return bn(t,tc(t),r)}function Zy(t,r){return bn(t,Af(t),r)}function ra(t,r){return function(l,d){var _=ve(l)?tv:yy,w=r?r():{};return _(l,t,fe(d,2),w)}}function li(t){return xe(function(r,l){var d=-1,_=l.length,w=_>1?l[_-1]:n,S=_>2?l[2]:n;for(w=t.length>3&&typeof w=="function"?(_--,w):n,S&&wt(l[0],l[1],S)&&(w=_<3?n:w,_=1),r=ze(r);++d<_;){var I=l[d];I&&t(r,I,d,w)}return r})}function df(t,r){return function(l,d){if(l==null)return l;if(!It(l))return t(l,d);for(var _=l.length,w=r?_:-1,S=ze(l);(r?w--:++w<_)&&d(S[w],w,S)!==!1;);return l}}function pf(t){return function(r,l,d){for(var _=-1,w=ze(r),S=d(r),I=S.length;I--;){var L=S[t?I:++_];if(l(w[L],L,w)===!1)break}return r}}function $y(t,r,l){var d=r&x,_=Xi(t);function w(){var S=this&&this!==ft&&this instanceof w?_:t;return S.apply(d?l:this,arguments)}return w}function mf(t){return function(r){r=Oe(r);var l=ni(r)?un(r):n,d=l?l[0]:r.charAt(0),_=l?sr(l,1).join(""):r.slice(1);return d[t]()+_}}function ui(t){return function(r){return _o(dh(hh(r).replace(H0,"")),t,"")}}function Xi(t){return function(){var r=arguments;switch(r.length){case 0:return new t;case 1:return new t(r[0]);case 2:return new t(r[0],r[1]);case 3:return new t(r[0],r[1],r[2]);case 4:return new t(r[0],r[1],r[2],r[3]);case 5:return new t(r[0],r[1],r[2],r[3],r[4]);case 6:return new t(r[0],r[1],r[2],r[3],r[4],r[5]);case 7:return new t(r[0],r[1],r[2],r[3],r[4],r[5],r[6])}var l=ci(t.prototype),d=t.apply(l,r);return qe(d)?d:l}}function Qy(t,r,l){var d=Xi(t);function _(){for(var w=arguments.length,S=U(w),I=w,L=fi(_);I--;)S[I]=arguments[I];var W=w<3&&S[0]!==L&&S[w-1]!==L?[]:er(S,L);if(w-=W.length,w<l)return xf(t,r,ia,_.placeholder,n,S,W,n,n,l-w);var V=this&&this!==ft&&this instanceof _?d:t;return kt(V,this,S)}return _}function gf(t){return function(r,l,d){var _=ze(r);if(!It(r)){var w=fe(l,3);r=ot(r),l=function(I){return w(_[I],I,_)}}var S=t(r,l,d);return S>-1?_[w?r[S]:S]:n}}function vf(t){return Nn(function(r){var l=r.length,d=l,_=$t.prototype.thru;for(t&&r.reverse();d--;){var w=r[d];if(typeof w!="function")throw new Zt(a);if(_&&!S&&ca(w)=="wrapper")var S=new $t([],!0)}for(d=S?d:l;++d<l;){w=r[d];var I=ca(w),L=I=="wrapper"?Jo(w):n;L&&rc(L[0])&&L[1]==(k|C|O|q)&&!L[4].length&&L[9]==1?S=S[ca(L[0])].apply(S,L[3]):S=w.length==1&&rc(w)?S[I]():S.thru(w)}return function(){var W=arguments,V=W[0];if(S&&W.length==1&&ve(V))return S.plant(V).value();for(var Y=0,J=l?r[Y].apply(this,W):V;++Y<l;)J=r[Y].call(this,J);return J}})}function ia(t,r,l,d,_,w,S,I,L,W){var V=r&k,Y=r&x,J=r&A,ie=r&(C|P),he=r&j,_e=J?n:Xi(t);function de(){for(var we=arguments.length,Me=U(we),Gt=we;Gt--;)Me[Gt]=arguments[Gt];if(ie)var Rt=fi(de),Wt=uv(Me,Rt);if(d&&(Me=ff(Me,d,_,ie)),w&&(Me=hf(Me,w,S,ie)),we-=Wt,ie&&we<W){var Qe=er(Me,Rt);return xf(t,r,ia,de.placeholder,l,Me,Qe,I,L,W-we)}var dn=Y?l:this,zn=J?dn[t]:t;return we=Me.length,I?Me=y_(Me,I):he&&we>1&&Me.reverse(),V&&L<we&&(Me.length=L),this&&this!==ft&&this instanceof de&&(zn=_e||Xi(zn)),zn.apply(dn,Me)}return de}function yf(t,r){return function(l,d){return Ey(l,t,r(d),{})}}function sa(t,r){return function(l,d){var _;if(l===n&&d===n)return r;if(l!==n&&(_=l),d!==n){if(_===n)return d;typeof l=="string"||typeof d=="string"?(l=zt(l),d=zt(d)):(l=nf(l),d=nf(d)),_=t(l,d)}return _}}function Xo(t){return Nn(function(r){return r=Ve(r,Ut(fe())),xe(function(l){var d=this;return t(r,function(_){return kt(_,d,l)})})})}function aa(t,r){r=r===n?" ":zt(r);var l=r.length;if(l<2)return l?Go(r,t):r;var d=Go(r,qs(t/ri(r)));return ni(r)?sr(un(d),0,t).join(""):d.slice(0,t)}function Jy(t,r,l,d){var _=r&x,w=Xi(t);function S(){for(var I=-1,L=arguments.length,W=-1,V=d.length,Y=U(V+L),J=this&&this!==ft&&this instanceof S?w:t;++W<V;)Y[W]=d[W];for(;L--;)Y[W++]=arguments[++I];return kt(J,_?l:this,Y)}return S}function _f(t){return function(r,l,d){return d&&typeof d!="number"&&wt(r,l,d)&&(l=d=n),r=Un(r),l===n?(l=r,r=0):l=Un(l),d=d===n?r<l?1:-1:Un(d),ky(r,l,d,t)}}function oa(t){return function(r,l){return typeof r=="string"&&typeof l=="string"||(r=tn(r),l=tn(l)),t(r,l)}}function xf(t,r,l,d,_,w,S,I,L,W){var V=r&C,Y=V?S:n,J=V?n:S,ie=V?w:n,he=V?n:w;r|=V?O:B,r&=~(V?B:O),r&E||(r&=-4);var _e=[t,r,_,ie,Y,he,J,I,L,W],de=l.apply(n,_e);return rc(t)&&Df(de,_e),de.placeholder=d,Ff(de,t,r)}function Zo(t){var r=rt[t];return function(l,d){if(l=tn(l),d=d==null?0:dt(ye(d),292),d&&Du(l)){var _=(Oe(l)+"e").split("e"),w=r(_[0]+"e"+(+_[1]+d));return _=(Oe(w)+"e").split("e"),+(_[0]+"e"+(+_[1]-d))}return r(l)}}var e_=ai&&1/Ns(new ai([,-0]))[1]==ke?function(t){return new ai(t)}:yc;function bf(t){return function(r){var l=pt(r);return l==ct?Eo(r):l==xt?vv(r):lv(r,t(r))}}function Ln(t,r,l,d,_,w,S,I){var L=r&A;if(!L&&typeof t!="function")throw new Zt(a);var W=d?d.length:0;if(W||(r&=-97,d=_=n),S=S===n?S:it(ye(S),0),I=I===n?I:ye(I),W-=_?_.length:0,r&B){var V=d,Y=_;d=_=n}var J=L?n:Jo(t),ie=[t,r,l,d,_,V,Y,w,S,I];if(J&&m_(ie,J),t=ie[0],r=ie[1],l=ie[2],d=ie[3],_=ie[4],I=ie[9]=ie[9]===n?L?0:t.length:it(ie[9]-W,0),!I&&r&(C|P)&&(r&=-25),!r||r==x)var he=$y(t,r,l);else r==C||r==P?he=Qy(t,r,I):(r==O||r==(x|O))&&!_.length?he=Jy(t,r,l,d):he=ia.apply(n,ie);var _e=J?ef:Df;return Ff(_e(he,ie),t,r)}function Tf(t,r,l,d){return t===n||hn(t,si[l])&&!Le.call(d,l)?r:t}function wf(t,r,l,d,_,w){return qe(t)&&qe(r)&&(w.set(r,t),ea(t,r,n,wf,w),w.delete(r)),t}function t_(t){return Qi(t)?n:t}function Rf(t,r,l,d,_,w){var S=l&R,I=t.length,L=r.length;if(I!=L&&!(S&&L>I))return!1;var W=w.get(t),V=w.get(r);if(W&&V)return W==r&&V==t;var Y=-1,J=!0,ie=l&M?new Pr:n;for(w.set(t,r),w.set(r,t);++Y<I;){var he=t[Y],_e=r[Y];if(d)var de=S?d(_e,he,Y,r,t,w):d(he,_e,Y,t,r,w);if(de!==n){if(de)continue;J=!1;break}if(ie){if(!xo(r,function(we,Me){if(!ki(ie,Me)&&(he===we||_(he,we,l,d,w)))return ie.push(Me)})){J=!1;break}}else if(!(he===_e||_(he,_e,l,d,w))){J=!1;break}}return w.delete(t),w.delete(r),J}function n_(t,r,l,d,_,w,S){switch(l){case vn:if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case ln:return!(t.byteLength!=r.byteLength||!w(new Gs(t),new Gs(r)));case De:case Te:case lt:return hn(+t,+r);case an:return t.name==r.name&&t.message==r.message;case En:case Bt:return t==r+"";case ct:var I=Eo;case xt:var L=d&R;if(I||(I=Ns),t.size!=r.size&&!L)return!1;var W=S.get(t);if(W)return W==r;d|=M,S.set(t,r);var V=Rf(I(t),I(r),d,_,w,S);return S.delete(t),V;case Zn:if(Wi)return Wi.call(t)==Wi.call(r)}return!1}function r_(t,r,l,d,_,w){var S=l&R,I=$o(t),L=I.length,W=$o(r),V=W.length;if(L!=V&&!S)return!1;for(var Y=L;Y--;){var J=I[Y];if(!(S?J in r:Le.call(r,J)))return!1}var ie=w.get(t),he=w.get(r);if(ie&&he)return ie==r&&he==t;var _e=!0;w.set(t,r),w.set(r,t);for(var de=S;++Y<L;){J=I[Y];var we=t[J],Me=r[J];if(d)var Gt=S?d(Me,we,J,r,t,w):d(we,Me,J,t,r,w);if(!(Gt===n?we===Me||_(we,Me,l,d,w):Gt)){_e=!1;break}de||(de=J=="constructor")}if(_e&&!de){var Rt=t.constructor,Wt=r.constructor;Rt!=Wt&&"constructor"in t&&"constructor"in r&&!(typeof Rt=="function"&&Rt instanceof Rt&&typeof Wt=="function"&&Wt instanceof Wt)&&(_e=!1)}return w.delete(t),w.delete(r),_e}function Nn(t){return sc(If(t,n,Uf),t+"")}function $o(t){return Wu(t,ot,tc)}function Qo(t){return Wu(t,Pt,Af)}var Jo=Ks?function(t){return Ks.get(t)}:yc;function ca(t){for(var r=t.name+"",l=oi[r],d=Le.call(oi,r)?l.length:0;d--;){var _=l[d],w=_.func;if(w==null||w==t)return _.name}return r}function fi(t){var r=Le.call(T,"placeholder")?T:t;return r.placeholder}function fe(){var t=T.iteratee||gc;return t=t===gc?qu:t,arguments.length?t(arguments[0],arguments[1]):t}function la(t,r){var l=t.__data__;return f_(r)?l[typeof r=="string"?"string":"hash"]:l.map}function ec(t){for(var r=ot(t),l=r.length;l--;){var d=r[l],_=t[d];r[l]=[d,_,Mf(_)]}return r}function Or(t,r){var l=pv(t,r);return ju(l)?l:n}function i_(t){var r=Le.call(t,Cr),l=t[Cr];try{t[Cr]=n;var d=!0}catch{}var _=zs.call(t);return d&&(r?t[Cr]=l:delete t[Cr]),_}var tc=Mo?function(t){return t==null?[]:(t=ze(t),Qn(Mo(t),function(r){return Iu.call(t,r)}))}:_c,Af=Mo?function(t){for(var r=[];t;)Jn(r,tc(t)),t=Ws(t);return r}:_c,pt=Tt;(Co&&pt(new Co(new ArrayBuffer(1)))!=vn||zi&&pt(new zi)!=ct||Io&&pt(Io.resolve())!=Xn||ai&&pt(new ai)!=xt||Hi&&pt(new Hi)!=cn)&&(pt=function(t){var r=Tt(t),l=r==st?t.constructor:n,d=l?Lr(l):"";if(d)switch(d){case zv:return vn;case Hv:return ct;case Gv:return Xn;case Wv:return xt;case Vv:return cn}return r});function s_(t,r,l){for(var d=-1,_=l.length;++d<_;){var w=l[d],S=w.size;switch(w.type){case"drop":t+=S;break;case"dropRight":r-=S;break;case"take":r=dt(r,t+S);break;case"takeRight":t=it(t,r-S);break}}return{start:t,end:r}}function a_(t){var r=t.match(Li);return r?r[1].split(y):[]}function Ef(t,r,l){r=ir(r,t);for(var d=-1,_=r.length,w=!1;++d<_;){var S=Tn(r[d]);if(!(w=t!=null&&l(t,S)))break;t=t[S]}return w||++d!=_?w:(_=t==null?0:t.length,!!_&&ga(_)&&Bn(S,_)&&(ve(t)||Nr(t)))}function o_(t){var r=t.length,l=new t.constructor(r);return r&&typeof t[0]=="string"&&Le.call(t,"index")&&(l.index=t.index,l.input=t.input),l}function Sf(t){return typeof t.constructor=="function"&&!Zi(t)?ci(Ws(t)):{}}function c_(t,r,l){var d=t.constructor;switch(r){case ln:return Ko(t);case De:case Te:return new d(+t);case vn:return jy(t,l);case Sn:case Mn:case mr:case gr:case vr:case yr:case _r:case xr:case br:return lf(t,l);case ct:return new d;case lt:case Bt:return new d(t);case En:return qy(t);case xt:return new d;case Zn:return Yy(t)}}function l_(t,r){var l=r.length;if(!l)return t;var d=l-1;return r[d]=(l>1?"& ":"")+r[d],r=r.join(l>2?", ":" "),t.replace(Oi,`{
|
|
4068
|
-
/* [wrapped with `+r+`] */
|
|
4069
|
-
`)}function u_(t){return ve(t)||Nr(t)||!!(Pu&&t&&t[Pu])}function Bn(t,r){var l=typeof t;return r=r??Ie,!!r&&(l=="number"||l!="symbol"&&ge.test(t))&&t>-1&&t%1==0&&t<r}function wt(t,r,l){if(!qe(l))return!1;var d=typeof r;return(d=="number"?It(l)&&Bn(r,l.length):d=="string"&&r in l)?hn(l[r],t):!1}function nc(t,r){if(ve(t))return!1;var l=typeof t;return l=="number"||l=="symbol"||l=="boolean"||t==null||Ht(t)?!0:Pi.test(t)||!Ar.test(t)||r!=null&&t in ze(r)}function f_(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}function rc(t){var r=ca(t),l=T[r];if(typeof l!="function"||!(r in Ae.prototype))return!1;if(t===l)return!0;var d=Jo(l);return!!d&&t===d[0]}function h_(t){return!!Su&&Su in t}var d_=ks?kn:xc;function Zi(t){var r=t&&t.constructor,l=typeof r=="function"&&r.prototype||si;return t===l}function Mf(t){return t===t&&!qe(t)}function Cf(t,r){return function(l){return l==null?!1:l[t]===r&&(r!==n||t in ze(l))}}function p_(t){var r=pa(t,function(d){return l.size===p&&l.clear(),d}),l=r.cache;return r}function m_(t,r){var l=t[1],d=r[1],_=l|d,w=_<(x|A|k),S=d==k&&l==C||d==k&&l==q&&t[7].length<=r[8]||d==(k|q)&&r[7].length<=r[8]&&l==C;if(!(w||S))return t;d&x&&(t[2]=r[2],_|=l&x?0:E);var I=r[3];if(I){var L=t[3];t[3]=L?ff(L,I,r[4]):I,t[4]=L?er(t[3],v):r[4]}return I=r[5],I&&(L=t[5],t[5]=L?hf(L,I,r[6]):I,t[6]=L?er(t[5],v):r[6]),I=r[7],I&&(t[7]=I),d&k&&(t[8]=t[8]==null?r[8]:dt(t[8],r[8])),t[9]==null&&(t[9]=r[9]),t[0]=r[0],t[1]=_,t}function g_(t){var r=[];if(t!=null)for(var l in ze(t))r.push(l);return r}function v_(t){return zs.call(t)}function If(t,r,l){return r=it(r===n?t.length-1:r,0),function(){for(var d=arguments,_=-1,w=it(d.length-r,0),S=U(w);++_<w;)S[_]=d[r+_];_=-1;for(var I=U(r+1);++_<r;)I[_]=d[_];return I[r]=l(S),kt(t,this,I)}}function Pf(t,r){return r.length<2?t:Fr(t,Jt(r,0,-1))}function y_(t,r){for(var l=t.length,d=dt(r.length,l),_=Ct(t);d--;){var w=r[d];t[d]=Bn(w,l)?_[w]:n}return t}function ic(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}var Df=Of(ef),$i=Fv||function(t,r){return ft.setTimeout(t,r)},sc=Of(Hy);function Ff(t,r,l){var d=r+"";return sc(t,l_(d,__(a_(d),l)))}function Of(t){var r=0,l=0;return function(){var d=Bv(),_=Z-(d-l);if(l=d,_>0){if(++r>=H)return arguments[0]}else r=0;return t.apply(n,arguments)}}function ua(t,r){var l=-1,d=t.length,_=d-1;for(r=r===n?d:r;++l<r;){var w=Ho(l,_),S=t[w];t[w]=t[l],t[l]=S}return t.length=r,t}var Lf=p_(function(t){var r=[];return t.charCodeAt(0)===46&&r.push(""),t.replace(Di,function(l,d,_,w){r.push(_?w.replace(X,"$1"):d||l)}),r});function Tn(t){if(typeof t=="string"||Ht(t))return t;var r=t+"";return r=="0"&&1/t==-ke?"-0":r}function Lr(t){if(t!=null){try{return Us.call(t)}catch{}try{return t+""}catch{}}return""}function __(t,r){return Xt(Kn,function(l){var d="_."+l[0];r&l[1]&&!Os(t,d)&&t.push(d)}),t.sort()}function Nf(t){if(t instanceof Ae)return t.clone();var r=new $t(t.__wrapped__,t.__chain__);return r.__actions__=Ct(t.__actions__),r.__index__=t.__index__,r.__values__=t.__values__,r}function x_(t,r,l){(l?wt(t,r,l):r===n)?r=1:r=it(ye(r),0);var d=t==null?0:t.length;if(!d||r<1)return[];for(var _=0,w=0,S=U(qs(d/r));_<d;)S[w++]=Jt(t,_,_+=r);return S}function b_(t){for(var r=-1,l=t==null?0:t.length,d=0,_=[];++r<l;){var w=t[r];w&&(_[d++]=w)}return _}function T_(){var t=arguments.length;if(!t)return[];for(var r=U(t-1),l=arguments[0],d=t;d--;)r[d-1]=arguments[d];return Jn(ve(l)?Ct(l):[l],ht(r,1))}var w_=xe(function(t,r){return $e(t)?ji(t,ht(r,1,$e,!0)):[]}),R_=xe(function(t,r){var l=en(r);return $e(l)&&(l=n),$e(t)?ji(t,ht(r,1,$e,!0),fe(l,2)):[]}),A_=xe(function(t,r){var l=en(r);return $e(l)&&(l=n),$e(t)?ji(t,ht(r,1,$e,!0),n,l):[]});function E_(t,r,l){var d=t==null?0:t.length;return d?(r=l||r===n?1:ye(r),Jt(t,r<0?0:r,d)):[]}function S_(t,r,l){var d=t==null?0:t.length;return d?(r=l||r===n?1:ye(r),r=d-r,Jt(t,0,r<0?0:r)):[]}function M_(t,r){return t&&t.length?na(t,fe(r,3),!0,!0):[]}function C_(t,r){return t&&t.length?na(t,fe(r,3),!0):[]}function I_(t,r,l,d){var _=t==null?0:t.length;return _?(l&&typeof l!="number"&&wt(t,r,l)&&(l=0,d=_),Ty(t,r,l,d)):[]}function Bf(t,r,l){var d=t==null?0:t.length;if(!d)return-1;var _=l==null?0:ye(l);return _<0&&(_=it(d+_,0)),Ls(t,fe(r,3),_)}function kf(t,r,l){var d=t==null?0:t.length;if(!d)return-1;var _=d-1;return l!==n&&(_=ye(l),_=l<0?it(d+_,0):dt(_,d-1)),Ls(t,fe(r,3),_,!0)}function Uf(t){var r=t==null?0:t.length;return r?ht(t,1):[]}function P_(t){var r=t==null?0:t.length;return r?ht(t,ke):[]}function D_(t,r){var l=t==null?0:t.length;return l?(r=r===n?1:ye(r),ht(t,r)):[]}function F_(t){for(var r=-1,l=t==null?0:t.length,d={};++r<l;){var _=t[r];d[_[0]]=_[1]}return d}function zf(t){return t&&t.length?t[0]:n}function O_(t,r,l){var d=t==null?0:t.length;if(!d)return-1;var _=l==null?0:ye(l);return _<0&&(_=it(d+_,0)),ti(t,r,_)}function L_(t){var r=t==null?0:t.length;return r?Jt(t,0,-1):[]}var N_=xe(function(t){var r=Ve(t,qo);return r.length&&r[0]===t[0]?No(r):[]}),B_=xe(function(t){var r=en(t),l=Ve(t,qo);return r===en(l)?r=n:l.pop(),l.length&&l[0]===t[0]?No(l,fe(r,2)):[]}),k_=xe(function(t){var r=en(t),l=Ve(t,qo);return r=typeof r=="function"?r:n,r&&l.pop(),l.length&&l[0]===t[0]?No(l,n,r):[]});function U_(t,r){return t==null?"":Lv.call(t,r)}function en(t){var r=t==null?0:t.length;return r?t[r-1]:n}function z_(t,r,l){var d=t==null?0:t.length;if(!d)return-1;var _=d;return l!==n&&(_=ye(l),_=_<0?it(d+_,0):dt(_,d-1)),r===r?_v(t,r,_):Ls(t,_u,_,!0)}function H_(t,r){return t&&t.length?Zu(t,ye(r)):n}var G_=xe(Hf);function Hf(t,r){return t&&t.length&&r&&r.length?zo(t,r):t}function W_(t,r,l){return t&&t.length&&r&&r.length?zo(t,r,fe(l,2)):t}function V_(t,r,l){return t&&t.length&&r&&r.length?zo(t,r,n,l):t}var j_=Nn(function(t,r){var l=t==null?0:t.length,d=Do(t,r);return Ju(t,Ve(r,function(_){return Bn(_,l)?+_:_}).sort(uf)),d});function q_(t,r){var l=[];if(!(t&&t.length))return l;var d=-1,_=[],w=t.length;for(r=fe(r,3);++d<w;){var S=t[d];r(S,d,t)&&(l.push(S),_.push(d))}return Ju(t,_),l}function ac(t){return t==null?t:Uv.call(t)}function Y_(t,r,l){var d=t==null?0:t.length;return d?(l&&typeof l!="number"&&wt(t,r,l)?(r=0,l=d):(r=r==null?0:ye(r),l=l===n?d:ye(l)),Jt(t,r,l)):[]}function K_(t,r){return ta(t,r)}function X_(t,r,l){return Wo(t,r,fe(l,2))}function Z_(t,r){var l=t==null?0:t.length;if(l){var d=ta(t,r);if(d<l&&hn(t[d],r))return d}return-1}function $_(t,r){return ta(t,r,!0)}function Q_(t,r,l){return Wo(t,r,fe(l,2),!0)}function J_(t,r){var l=t==null?0:t.length;if(l){var d=ta(t,r,!0)-1;if(hn(t[d],r))return d}return-1}function ex(t){return t&&t.length?tf(t):[]}function tx(t,r){return t&&t.length?tf(t,fe(r,2)):[]}function nx(t){var r=t==null?0:t.length;return r?Jt(t,1,r):[]}function rx(t,r,l){return t&&t.length?(r=l||r===n?1:ye(r),Jt(t,0,r<0?0:r)):[]}function ix(t,r,l){var d=t==null?0:t.length;return d?(r=l||r===n?1:ye(r),r=d-r,Jt(t,r<0?0:r,d)):[]}function sx(t,r){return t&&t.length?na(t,fe(r,3),!1,!0):[]}function ax(t,r){return t&&t.length?na(t,fe(r,3)):[]}var ox=xe(function(t){return rr(ht(t,1,$e,!0))}),cx=xe(function(t){var r=en(t);return $e(r)&&(r=n),rr(ht(t,1,$e,!0),fe(r,2))}),lx=xe(function(t){var r=en(t);return r=typeof r=="function"?r:n,rr(ht(t,1,$e,!0),n,r)});function ux(t){return t&&t.length?rr(t):[]}function fx(t,r){return t&&t.length?rr(t,fe(r,2)):[]}function hx(t,r){return r=typeof r=="function"?r:n,t&&t.length?rr(t,n,r):[]}function oc(t){if(!(t&&t.length))return[];var r=0;return t=Qn(t,function(l){if($e(l))return r=it(l.length,r),!0}),Ro(r,function(l){return Ve(t,bo(l))})}function Gf(t,r){if(!(t&&t.length))return[];var l=oc(t);return r==null?l:Ve(l,function(d){return kt(r,n,d)})}var dx=xe(function(t,r){return $e(t)?ji(t,r):[]}),px=xe(function(t){return jo(Qn(t,$e))}),mx=xe(function(t){var r=en(t);return $e(r)&&(r=n),jo(Qn(t,$e),fe(r,2))}),gx=xe(function(t){var r=en(t);return r=typeof r=="function"?r:n,jo(Qn(t,$e),n,r)}),vx=xe(oc);function yx(t,r){return af(t||[],r||[],Vi)}function _x(t,r){return af(t||[],r||[],Ki)}var xx=xe(function(t){var r=t.length,l=r>1?t[r-1]:n;return l=typeof l=="function"?(t.pop(),l):n,Gf(t,l)});function Wf(t){var r=T(t);return r.__chain__=!0,r}function bx(t,r){return r(t),t}function fa(t,r){return r(t)}var Tx=Nn(function(t){var r=t.length,l=r?t[0]:0,d=this.__wrapped__,_=function(w){return Do(w,t)};return r>1||this.__actions__.length||!(d instanceof Ae)||!Bn(l)?this.thru(_):(d=d.slice(l,+l+(r?1:0)),d.__actions__.push({func:fa,args:[_],thisArg:n}),new $t(d,this.__chain__).thru(function(w){return r&&!w.length&&w.push(n),w}))});function wx(){return Wf(this)}function Rx(){return new $t(this.value(),this.__chain__)}function Ax(){this.__values__===n&&(this.__values__=rh(this.value()));var t=this.__index__>=this.__values__.length,r=t?n:this.__values__[this.__index__++];return{done:t,value:r}}function Ex(){return this}function Sx(t){for(var r,l=this;l instanceof Zs;){var d=Nf(l);d.__index__=0,d.__values__=n,r?_.__wrapped__=d:r=d;var _=d;l=l.__wrapped__}return _.__wrapped__=t,r}function Mx(){var t=this.__wrapped__;if(t instanceof Ae){var r=t;return this.__actions__.length&&(r=new Ae(this)),r=r.reverse(),r.__actions__.push({func:fa,args:[ac],thisArg:n}),new $t(r,this.__chain__)}return this.thru(ac)}function Cx(){return sf(this.__wrapped__,this.__actions__)}var Ix=ra(function(t,r,l){Le.call(t,l)?++t[l]:On(t,l,1)});function Px(t,r,l){var d=ve(t)?vu:by;return l&&wt(t,r,l)&&(r=n),d(t,fe(r,3))}function Dx(t,r){var l=ve(t)?Qn:Hu;return l(t,fe(r,3))}var Fx=gf(Bf),Ox=gf(kf);function Lx(t,r){return ht(ha(t,r),1)}function Nx(t,r){return ht(ha(t,r),ke)}function Bx(t,r,l){return l=l===n?1:ye(l),ht(ha(t,r),l)}function Vf(t,r){var l=ve(t)?Xt:nr;return l(t,fe(r,3))}function jf(t,r){var l=ve(t)?nv:zu;return l(t,fe(r,3))}var kx=ra(function(t,r,l){Le.call(t,l)?t[l].push(r):On(t,l,[r])});function Ux(t,r,l,d){t=It(t)?t:di(t),l=l&&!d?ye(l):0;var _=t.length;return l<0&&(l=it(_+l,0)),va(t)?l<=_&&t.indexOf(r,l)>-1:!!_&&ti(t,r,l)>-1}var zx=xe(function(t,r,l){var d=-1,_=typeof r=="function",w=It(t)?U(t.length):[];return nr(t,function(S){w[++d]=_?kt(r,S,l):qi(S,r,l)}),w}),Hx=ra(function(t,r,l){On(t,l,r)});function ha(t,r){var l=ve(t)?Ve:Yu;return l(t,fe(r,3))}function Gx(t,r,l,d){return t==null?[]:(ve(r)||(r=r==null?[]:[r]),l=d?n:l,ve(l)||(l=l==null?[]:[l]),$u(t,r,l))}var Wx=ra(function(t,r,l){t[l?0:1].push(r)},function(){return[[],[]]});function Vx(t,r,l){var d=ve(t)?_o:bu,_=arguments.length<3;return d(t,fe(r,4),l,_,nr)}function jx(t,r,l){var d=ve(t)?rv:bu,_=arguments.length<3;return d(t,fe(r,4),l,_,zu)}function qx(t,r){var l=ve(t)?Qn:Hu;return l(t,ma(fe(r,3)))}function Yx(t){var r=ve(t)?Nu:Uy;return r(t)}function Kx(t,r,l){(l?wt(t,r,l):r===n)?r=1:r=ye(r);var d=ve(t)?gy:zy;return d(t,r)}function Xx(t){var r=ve(t)?vy:Gy;return r(t)}function Zx(t){if(t==null)return 0;if(It(t))return va(t)?ri(t):t.length;var r=pt(t);return r==ct||r==xt?t.size:ko(t).length}function $x(t,r,l){var d=ve(t)?xo:Wy;return l&&wt(t,r,l)&&(r=n),d(t,fe(r,3))}var Qx=xe(function(t,r){if(t==null)return[];var l=r.length;return l>1&&wt(t,r[0],r[1])?r=[]:l>2&&wt(r[0],r[1],r[2])&&(r=[r[0]]),$u(t,ht(r,1),[])}),da=Dv||function(){return ft.Date.now()};function Jx(t,r){if(typeof r!="function")throw new Zt(a);return t=ye(t),function(){if(--t<1)return r.apply(this,arguments)}}function qf(t,r,l){return r=l?n:r,r=t&&r==null?t.length:r,Ln(t,k,n,n,n,n,r)}function Yf(t,r){var l;if(typeof r!="function")throw new Zt(a);return t=ye(t),function(){return--t>0&&(l=r.apply(this,arguments)),t<=1&&(r=n),l}}var cc=xe(function(t,r,l){var d=x;if(l.length){var _=er(l,fi(cc));d|=O}return Ln(t,d,r,l,_)}),Kf=xe(function(t,r,l){var d=x|A;if(l.length){var _=er(l,fi(Kf));d|=O}return Ln(r,d,t,l,_)});function Xf(t,r,l){r=l?n:r;var d=Ln(t,C,n,n,n,n,n,r);return d.placeholder=Xf.placeholder,d}function Zf(t,r,l){r=l?n:r;var d=Ln(t,P,n,n,n,n,n,r);return d.placeholder=Zf.placeholder,d}function $f(t,r,l){var d,_,w,S,I,L,W=0,V=!1,Y=!1,J=!0;if(typeof t!="function")throw new Zt(a);r=tn(r)||0,qe(l)&&(V=!!l.leading,Y="maxWait"in l,w=Y?it(tn(l.maxWait)||0,r):w,J="trailing"in l?!!l.trailing:J);function ie(Qe){var dn=d,zn=_;return d=_=n,W=Qe,S=t.apply(zn,dn),S}function he(Qe){return W=Qe,I=$i(we,r),V?ie(Qe):S}function _e(Qe){var dn=Qe-L,zn=Qe-W,gh=r-dn;return Y?dt(gh,w-zn):gh}function de(Qe){var dn=Qe-L,zn=Qe-W;return L===n||dn>=r||dn<0||Y&&zn>=w}function we(){var Qe=da();if(de(Qe))return Me(Qe);I=$i(we,_e(Qe))}function Me(Qe){return I=n,J&&d?ie(Qe):(d=_=n,S)}function Gt(){I!==n&&of(I),W=0,d=L=_=I=n}function Rt(){return I===n?S:Me(da())}function Wt(){var Qe=da(),dn=de(Qe);if(d=arguments,_=this,L=Qe,dn){if(I===n)return he(L);if(Y)return of(I),I=$i(we,r),ie(L)}return I===n&&(I=$i(we,r)),S}return Wt.cancel=Gt,Wt.flush=Rt,Wt}var eb=xe(function(t,r){return Uu(t,1,r)}),tb=xe(function(t,r,l){return Uu(t,tn(r)||0,l)});function nb(t){return Ln(t,j)}function pa(t,r){if(typeof t!="function"||r!=null&&typeof r!="function")throw new Zt(a);var l=function(){var d=arguments,_=r?r.apply(this,d):d[0],w=l.cache;if(w.has(_))return w.get(_);var S=t.apply(this,d);return l.cache=w.set(_,S)||w,S};return l.cache=new(pa.Cache||Fn),l}pa.Cache=Fn;function ma(t){if(typeof t!="function")throw new Zt(a);return function(){var r=arguments;switch(r.length){case 0:return!t.call(this);case 1:return!t.call(this,r[0]);case 2:return!t.call(this,r[0],r[1]);case 3:return!t.call(this,r[0],r[1],r[2])}return!t.apply(this,r)}}function rb(t){return Yf(2,t)}var ib=Vy(function(t,r){r=r.length==1&&ve(r[0])?Ve(r[0],Ut(fe())):Ve(ht(r,1),Ut(fe()));var l=r.length;return xe(function(d){for(var _=-1,w=dt(d.length,l);++_<w;)d[_]=r[_].call(this,d[_]);return kt(t,this,d)})}),lc=xe(function(t,r){var l=er(r,fi(lc));return Ln(t,O,n,r,l)}),Qf=xe(function(t,r){var l=er(r,fi(Qf));return Ln(t,B,n,r,l)}),sb=Nn(function(t,r){return Ln(t,q,n,n,n,r)});function ab(t,r){if(typeof t!="function")throw new Zt(a);return r=r===n?r:ye(r),xe(t,r)}function ob(t,r){if(typeof t!="function")throw new Zt(a);return r=r==null?0:it(ye(r),0),xe(function(l){var d=l[r],_=sr(l,0,r);return d&&Jn(_,d),kt(t,this,_)})}function cb(t,r,l){var d=!0,_=!0;if(typeof t!="function")throw new Zt(a);return qe(l)&&(d="leading"in l?!!l.leading:d,_="trailing"in l?!!l.trailing:_),$f(t,r,{leading:d,maxWait:r,trailing:_})}function lb(t){return qf(t,1)}function ub(t,r){return lc(Yo(r),t)}function fb(){if(!arguments.length)return[];var t=arguments[0];return ve(t)?t:[t]}function hb(t){return Qt(t,b)}function db(t,r){return r=typeof r=="function"?r:n,Qt(t,b,r)}function pb(t){return Qt(t,g|b)}function mb(t,r){return r=typeof r=="function"?r:n,Qt(t,g|b,r)}function gb(t,r){return r==null||ku(t,r,ot(r))}function hn(t,r){return t===r||t!==t&&r!==r}var vb=oa(Lo),yb=oa(function(t,r){return t>=r}),Nr=Vu(function(){return arguments}())?Vu:function(t){return Xe(t)&&Le.call(t,"callee")&&!Iu.call(t,"callee")},ve=U.isArray,_b=fu?Ut(fu):Sy;function It(t){return t!=null&&ga(t.length)&&!kn(t)}function $e(t){return Xe(t)&&It(t)}function xb(t){return t===!0||t===!1||Xe(t)&&Tt(t)==De}var ar=Ov||xc,bb=hu?Ut(hu):My;function Tb(t){return Xe(t)&&t.nodeType===1&&!Qi(t)}function wb(t){if(t==null)return!0;if(It(t)&&(ve(t)||typeof t=="string"||typeof t.splice=="function"||ar(t)||hi(t)||Nr(t)))return!t.length;var r=pt(t);if(r==ct||r==xt)return!t.size;if(Zi(t))return!ko(t).length;for(var l in t)if(Le.call(t,l))return!1;return!0}function Rb(t,r){return Yi(t,r)}function Ab(t,r,l){l=typeof l=="function"?l:n;var d=l?l(t,r):n;return d===n?Yi(t,r,n,l):!!d}function uc(t){if(!Xe(t))return!1;var r=Tt(t);return r==an||r==Ze||typeof t.message=="string"&&typeof t.name=="string"&&!Qi(t)}function Eb(t){return typeof t=="number"&&Du(t)}function kn(t){if(!qe(t))return!1;var r=Tt(t);return r==yt||r==Nt||r==Ke||r==on}function Jf(t){return typeof t=="number"&&t==ye(t)}function ga(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ie}function qe(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}function Xe(t){return t!=null&&typeof t=="object"}var eh=du?Ut(du):Iy;function Sb(t,r){return t===r||Bo(t,r,ec(r))}function Mb(t,r,l){return l=typeof l=="function"?l:n,Bo(t,r,ec(r),l)}function Cb(t){return th(t)&&t!=+t}function Ib(t){if(d_(t))throw new me(c);return ju(t)}function Pb(t){return t===null}function Db(t){return t==null}function th(t){return typeof t=="number"||Xe(t)&&Tt(t)==lt}function Qi(t){if(!Xe(t)||Tt(t)!=st)return!1;var r=Ws(t);if(r===null)return!0;var l=Le.call(r,"constructor")&&r.constructor;return typeof l=="function"&&l instanceof l&&Us.call(l)==Mv}var fc=pu?Ut(pu):Py;function Fb(t){return Jf(t)&&t>=-Ie&&t<=Ie}var nh=mu?Ut(mu):Dy;function va(t){return typeof t=="string"||!ve(t)&&Xe(t)&&Tt(t)==Bt}function Ht(t){return typeof t=="symbol"||Xe(t)&&Tt(t)==Zn}var hi=gu?Ut(gu):Fy;function Ob(t){return t===n}function Lb(t){return Xe(t)&&pt(t)==cn}function Nb(t){return Xe(t)&&Tt(t)==pr}var Bb=oa(Uo),kb=oa(function(t,r){return t<=r});function rh(t){if(!t)return[];if(It(t))return va(t)?un(t):Ct(t);if(Ui&&t[Ui])return gv(t[Ui]());var r=pt(t),l=r==ct?Eo:r==xt?Ns:di;return l(t)}function Un(t){if(!t)return t===0?t:0;if(t=tn(t),t===ke||t===-ke){var r=t<0?-1:1;return r*et}return t===t?t:0}function ye(t){var r=Un(t),l=r%1;return r===r?l?r-l:r:0}function ih(t){return t?Dr(ye(t),0,je):0}function tn(t){if(typeof t=="number")return t;if(Ht(t))return vt;if(qe(t)){var r=typeof t.valueOf=="function"?t.valueOf():t;t=qe(r)?r+"":r}if(typeof t!="string")return t===0?t:+t;t=Tu(t);var l=ee.test(t);return l||pe.test(t)?J0(t.slice(2),l?2:8):te.test(t)?vt:+t}function sh(t){return bn(t,Pt(t))}function Ub(t){return t?Dr(ye(t),-Ie,Ie):t===0?t:0}function Oe(t){return t==null?"":zt(t)}var zb=li(function(t,r){if(Zi(r)||It(r)){bn(r,ot(r),t);return}for(var l in r)Le.call(r,l)&&Vi(t,l,r[l])}),ah=li(function(t,r){bn(r,Pt(r),t)}),ya=li(function(t,r,l,d){bn(r,Pt(r),t,d)}),Hb=li(function(t,r,l,d){bn(r,ot(r),t,d)}),Gb=Nn(Do);function Wb(t,r){var l=ci(t);return r==null?l:Bu(l,r)}var Vb=xe(function(t,r){t=ze(t);var l=-1,d=r.length,_=d>2?r[2]:n;for(_&&wt(r[0],r[1],_)&&(d=1);++l<d;)for(var w=r[l],S=Pt(w),I=-1,L=S.length;++I<L;){var W=S[I],V=t[W];(V===n||hn(V,si[W])&&!Le.call(t,W))&&(t[W]=w[W])}return t}),jb=xe(function(t){return t.push(n,wf),kt(oh,n,t)});function qb(t,r){return yu(t,fe(r,3),xn)}function Yb(t,r){return yu(t,fe(r,3),Oo)}function Kb(t,r){return t==null?t:Fo(t,fe(r,3),Pt)}function Xb(t,r){return t==null?t:Gu(t,fe(r,3),Pt)}function Zb(t,r){return t&&xn(t,fe(r,3))}function $b(t,r){return t&&Oo(t,fe(r,3))}function Qb(t){return t==null?[]:Js(t,ot(t))}function Jb(t){return t==null?[]:Js(t,Pt(t))}function hc(t,r,l){var d=t==null?n:Fr(t,r);return d===n?l:d}function eT(t,r){return t!=null&&Ef(t,r,wy)}function dc(t,r){return t!=null&&Ef(t,r,Ry)}var tT=yf(function(t,r,l){r!=null&&typeof r.toString!="function"&&(r=zs.call(r)),t[r]=l},mc(Dt)),nT=yf(function(t,r,l){r!=null&&typeof r.toString!="function"&&(r=zs.call(r)),Le.call(t,r)?t[r].push(l):t[r]=[l]},fe),rT=xe(qi);function ot(t){return It(t)?Lu(t):ko(t)}function Pt(t){return It(t)?Lu(t,!0):Oy(t)}function iT(t,r){var l={};return r=fe(r,3),xn(t,function(d,_,w){On(l,r(d,_,w),d)}),l}function sT(t,r){var l={};return r=fe(r,3),xn(t,function(d,_,w){On(l,_,r(d,_,w))}),l}var aT=li(function(t,r,l){ea(t,r,l)}),oh=li(function(t,r,l,d){ea(t,r,l,d)}),oT=Nn(function(t,r){var l={};if(t==null)return l;var d=!1;r=Ve(r,function(w){return w=ir(w,t),d||(d=w.length>1),w}),bn(t,Qo(t),l),d&&(l=Qt(l,g|h|b,t_));for(var _=r.length;_--;)Vo(l,r[_]);return l});function cT(t,r){return ch(t,ma(fe(r)))}var lT=Nn(function(t,r){return t==null?{}:Ny(t,r)});function ch(t,r){if(t==null)return{};var l=Ve(Qo(t),function(d){return[d]});return r=fe(r),Qu(t,l,function(d,_){return r(d,_[0])})}function uT(t,r,l){r=ir(r,t);var d=-1,_=r.length;for(_||(_=1,t=n);++d<_;){var w=t==null?n:t[Tn(r[d])];w===n&&(d=_,w=l),t=kn(w)?w.call(t):w}return t}function fT(t,r,l){return t==null?t:Ki(t,r,l)}function hT(t,r,l,d){return d=typeof d=="function"?d:n,t==null?t:Ki(t,r,l,d)}var lh=bf(ot),uh=bf(Pt);function dT(t,r,l){var d=ve(t),_=d||ar(t)||hi(t);if(r=fe(r,4),l==null){var w=t&&t.constructor;_?l=d?new w:[]:qe(t)?l=kn(w)?ci(Ws(t)):{}:l={}}return(_?Xt:xn)(t,function(S,I,L){return r(l,S,I,L)}),l}function pT(t,r){return t==null?!0:Vo(t,r)}function mT(t,r,l){return t==null?t:rf(t,r,Yo(l))}function gT(t,r,l,d){return d=typeof d=="function"?d:n,t==null?t:rf(t,r,Yo(l),d)}function di(t){return t==null?[]:Ao(t,ot(t))}function vT(t){return t==null?[]:Ao(t,Pt(t))}function yT(t,r,l){return l===n&&(l=r,r=n),l!==n&&(l=tn(l),l=l===l?l:0),r!==n&&(r=tn(r),r=r===r?r:0),Dr(tn(t),r,l)}function _T(t,r,l){return r=Un(r),l===n?(l=r,r=0):l=Un(l),t=tn(t),Ay(t,r,l)}function xT(t,r,l){if(l&&typeof l!="boolean"&&wt(t,r,l)&&(r=l=n),l===n&&(typeof r=="boolean"?(l=r,r=n):typeof t=="boolean"&&(l=t,t=n)),t===n&&r===n?(t=0,r=1):(t=Un(t),r===n?(r=t,t=0):r=Un(r)),t>r){var d=t;t=r,r=d}if(l||t%1||r%1){var _=Fu();return dt(t+_*(r-t+Q0("1e-"+((_+"").length-1))),r)}return Ho(t,r)}var bT=ui(function(t,r,l){return r=r.toLowerCase(),t+(l?fh(r):r)});function fh(t){return pc(Oe(t).toLowerCase())}function hh(t){return t=Oe(t),t&&t.replace(Ue,fv).replace(G0,"")}function TT(t,r,l){t=Oe(t),r=zt(r);var d=t.length;l=l===n?d:Dr(ye(l),0,d);var _=l;return l-=r.length,l>=0&&t.slice(l,_)==r}function wT(t){return t=Oe(t),t&&Ci.test(t)?t.replace(_n,hv):t}function RT(t){return t=Oe(t),t&&Er.test(t)?t.replace(In,"\\$&"):t}var AT=ui(function(t,r,l){return t+(l?"-":"")+r.toLowerCase()}),ET=ui(function(t,r,l){return t+(l?" ":"")+r.toLowerCase()}),ST=mf("toLowerCase");function MT(t,r,l){t=Oe(t),r=ye(r);var d=r?ri(t):0;if(!r||d>=r)return t;var _=(r-d)/2;return aa(Ys(_),l)+t+aa(qs(_),l)}function CT(t,r,l){t=Oe(t),r=ye(r);var d=r?ri(t):0;return r&&d<r?t+aa(r-d,l):t}function IT(t,r,l){t=Oe(t),r=ye(r);var d=r?ri(t):0;return r&&d<r?aa(r-d,l)+t:t}function PT(t,r,l){return l||r==null?r=0:r&&(r=+r),kv(Oe(t).replace(Sr,""),r||0)}function DT(t,r,l){return(l?wt(t,r,l):r===n)?r=1:r=ye(r),Go(Oe(t),r)}function FT(){var t=arguments,r=Oe(t[0]);return t.length<3?r:r.replace(t[1],t[2])}var OT=ui(function(t,r,l){return t+(l?"_":"")+r.toLowerCase()});function LT(t,r,l){return l&&typeof l!="number"&&wt(t,r,l)&&(r=l=n),l=l===n?je:l>>>0,l?(t=Oe(t),t&&(typeof r=="string"||r!=null&&!fc(r))&&(r=zt(r),!r&&ni(t))?sr(un(t),0,l):t.split(r,l)):[]}var NT=ui(function(t,r,l){return t+(l?" ":"")+pc(r)});function BT(t,r,l){return t=Oe(t),l=l==null?0:Dr(ye(l),0,t.length),r=zt(r),t.slice(l,l+r.length)==r}function kT(t,r,l){var d=T.templateSettings;l&&wt(t,r,l)&&(r=n),t=Oe(t),r=ya({},r,d,Tf);var _=ya({},r.imports,d.imports,Tf),w=ot(_),S=Ao(_,w),I,L,W=0,V=r.interpolate||at,Y="__p += '",J=So((r.escape||at).source+"|"+V.source+"|"+(V===$n?re:at).source+"|"+(r.evaluate||at).source+"|$","g"),ie="//# sourceURL="+(Le.call(r,"sourceURL")?(r.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Y0+"]")+`
|
|
4070
|
-
`;t.replace(J,function(de,we,Me,Gt,Rt,Wt){return Me||(Me=Gt),Y+=t.slice(W,Wt).replace(ut,dv),we&&(I=!0,Y+=`' +
|
|
4071
|
-
__e(`+we+`) +
|
|
4072
|
-
'`),Rt&&(L=!0,Y+=`';
|
|
4073
|
-
`+Rt+`;
|
|
4074
|
-
__p += '`),Me&&(Y+=`' +
|
|
4075
|
-
((__t = (`+Me+`)) == null ? '' : __t) +
|
|
4076
|
-
'`),W=Wt+de.length,de}),Y+=`';
|
|
4077
|
-
`;var he=Le.call(r,"variable")&&r.variable;if(!he)Y=`with (obj) {
|
|
4078
|
-
`+Y+`
|
|
4079
|
-
}
|
|
4080
|
-
`;else if(z.test(he))throw new me(u);Y=(L?Y.replace(Cn,""):Y).replace(Tr,"$1").replace(bt,"$1;"),Y="function("+(he||"obj")+`) {
|
|
4081
|
-
`+(he?"":`obj || (obj = {});
|
|
4082
|
-
`)+"var __t, __p = ''"+(I?", __e = _.escape":"")+(L?`, __j = Array.prototype.join;
|
|
4083
|
-
function print() { __p += __j.call(arguments, '') }
|
|
4084
|
-
`:`;
|
|
4085
|
-
`)+Y+`return __p
|
|
4086
|
-
}`;var _e=ph(function(){return Fe(w,ie+"return "+Y).apply(n,S)});if(_e.source=Y,uc(_e))throw _e;return _e}function UT(t){return Oe(t).toLowerCase()}function zT(t){return Oe(t).toUpperCase()}function HT(t,r,l){if(t=Oe(t),t&&(l||r===n))return Tu(t);if(!t||!(r=zt(r)))return t;var d=un(t),_=un(r),w=wu(d,_),S=Ru(d,_)+1;return sr(d,w,S).join("")}function GT(t,r,l){if(t=Oe(t),t&&(l||r===n))return t.slice(0,Eu(t)+1);if(!t||!(r=zt(r)))return t;var d=un(t),_=Ru(d,un(r))+1;return sr(d,0,_).join("")}function WT(t,r,l){if(t=Oe(t),t&&(l||r===n))return t.replace(Sr,"");if(!t||!(r=zt(r)))return t;var d=un(t),_=wu(d,un(r));return sr(d,_).join("")}function VT(t,r){var l=K,d=$;if(qe(r)){var _="separator"in r?r.separator:_;l="length"in r?ye(r.length):l,d="omission"in r?zt(r.omission):d}t=Oe(t);var w=t.length;if(ni(t)){var S=un(t);w=S.length}if(l>=w)return t;var I=l-ri(d);if(I<1)return d;var L=S?sr(S,0,I).join(""):t.slice(0,I);if(_===n)return L+d;if(S&&(I+=L.length-I),fc(_)){if(t.slice(I).search(_)){var W,V=L;for(_.global||(_=So(_.source,Oe(ae.exec(_))+"g")),_.lastIndex=0;W=_.exec(V);)var Y=W.index;L=L.slice(0,Y===n?I:Y)}}else if(t.indexOf(zt(_),I)!=I){var J=L.lastIndexOf(_);J>-1&&(L=L.slice(0,J))}return L+d}function jT(t){return t=Oe(t),t&&wr.test(t)?t.replace(yn,xv):t}var qT=ui(function(t,r,l){return t+(l?" ":"")+r.toUpperCase()}),pc=mf("toUpperCase");function dh(t,r,l){return t=Oe(t),r=l?n:r,r===n?mv(t)?wv(t):av(t):t.match(r)||[]}var ph=xe(function(t,r){try{return kt(t,n,r)}catch(l){return uc(l)?l:new me(l)}}),YT=Nn(function(t,r){return Xt(r,function(l){l=Tn(l),On(t,l,cc(t[l],t))}),t});function KT(t){var r=t==null?0:t.length,l=fe();return t=r?Ve(t,function(d){if(typeof d[1]!="function")throw new Zt(a);return[l(d[0]),d[1]]}):[],xe(function(d){for(var _=-1;++_<r;){var w=t[_];if(kt(w[0],this,d))return kt(w[1],this,d)}})}function XT(t){return xy(Qt(t,g))}function mc(t){return function(){return t}}function ZT(t,r){return t==null||t!==t?r:t}var $T=vf(),QT=vf(!0);function Dt(t){return t}function gc(t){return qu(typeof t=="function"?t:Qt(t,g))}function JT(t){return Ku(Qt(t,g))}function ew(t,r){return Xu(t,Qt(r,g))}var tw=xe(function(t,r){return function(l){return qi(l,t,r)}}),nw=xe(function(t,r){return function(l){return qi(t,l,r)}});function vc(t,r,l){var d=ot(r),_=Js(r,d);l==null&&!(qe(r)&&(_.length||!d.length))&&(l=r,r=t,t=this,_=Js(r,ot(r)));var w=!(qe(l)&&"chain"in l)||!!l.chain,S=kn(t);return Xt(_,function(I){var L=r[I];t[I]=L,S&&(t.prototype[I]=function(){var W=this.__chain__;if(w||W){var V=t(this.__wrapped__),Y=V.__actions__=Ct(this.__actions__);return Y.push({func:L,args:arguments,thisArg:t}),V.__chain__=W,V}return L.apply(t,Jn([this.value()],arguments))})}),t}function rw(){return ft._===this&&(ft._=Cv),this}function yc(){}function iw(t){return t=ye(t),xe(function(r){return Zu(r,t)})}var sw=Xo(Ve),aw=Xo(vu),ow=Xo(xo);function mh(t){return nc(t)?bo(Tn(t)):By(t)}function cw(t){return function(r){return t==null?n:Fr(t,r)}}var lw=_f(),uw=_f(!0);function _c(){return[]}function xc(){return!1}function fw(){return{}}function hw(){return""}function dw(){return!0}function pw(t,r){if(t=ye(t),t<1||t>Ie)return[];var l=je,d=dt(t,je);r=fe(r),t-=je;for(var _=Ro(d,r);++l<t;)r(l);return _}function mw(t){return ve(t)?Ve(t,Tn):Ht(t)?[t]:Ct(Lf(Oe(t)))}function gw(t){var r=++Sv;return Oe(t)+r}var vw=sa(function(t,r){return t+r},0),yw=Zo("ceil"),_w=sa(function(t,r){return t/r},1),xw=Zo("floor");function bw(t){return t&&t.length?Qs(t,Dt,Lo):n}function Tw(t,r){return t&&t.length?Qs(t,fe(r,2),Lo):n}function ww(t){return xu(t,Dt)}function Rw(t,r){return xu(t,fe(r,2))}function Aw(t){return t&&t.length?Qs(t,Dt,Uo):n}function Ew(t,r){return t&&t.length?Qs(t,fe(r,2),Uo):n}var Sw=sa(function(t,r){return t*r},1),Mw=Zo("round"),Cw=sa(function(t,r){return t-r},0);function Iw(t){return t&&t.length?wo(t,Dt):0}function Pw(t,r){return t&&t.length?wo(t,fe(r,2)):0}return T.after=Jx,T.ary=qf,T.assign=zb,T.assignIn=ah,T.assignInWith=ya,T.assignWith=Hb,T.at=Gb,T.before=Yf,T.bind=cc,T.bindAll=YT,T.bindKey=Kf,T.castArray=fb,T.chain=Wf,T.chunk=x_,T.compact=b_,T.concat=T_,T.cond=KT,T.conforms=XT,T.constant=mc,T.countBy=Ix,T.create=Wb,T.curry=Xf,T.curryRight=Zf,T.debounce=$f,T.defaults=Vb,T.defaultsDeep=jb,T.defer=eb,T.delay=tb,T.difference=w_,T.differenceBy=R_,T.differenceWith=A_,T.drop=E_,T.dropRight=S_,T.dropRightWhile=M_,T.dropWhile=C_,T.fill=I_,T.filter=Dx,T.flatMap=Lx,T.flatMapDeep=Nx,T.flatMapDepth=Bx,T.flatten=Uf,T.flattenDeep=P_,T.flattenDepth=D_,T.flip=nb,T.flow=$T,T.flowRight=QT,T.fromPairs=F_,T.functions=Qb,T.functionsIn=Jb,T.groupBy=kx,T.initial=L_,T.intersection=N_,T.intersectionBy=B_,T.intersectionWith=k_,T.invert=tT,T.invertBy=nT,T.invokeMap=zx,T.iteratee=gc,T.keyBy=Hx,T.keys=ot,T.keysIn=Pt,T.map=ha,T.mapKeys=iT,T.mapValues=sT,T.matches=JT,T.matchesProperty=ew,T.memoize=pa,T.merge=aT,T.mergeWith=oh,T.method=tw,T.methodOf=nw,T.mixin=vc,T.negate=ma,T.nthArg=iw,T.omit=oT,T.omitBy=cT,T.once=rb,T.orderBy=Gx,T.over=sw,T.overArgs=ib,T.overEvery=aw,T.overSome=ow,T.partial=lc,T.partialRight=Qf,T.partition=Wx,T.pick=lT,T.pickBy=ch,T.property=mh,T.propertyOf=cw,T.pull=G_,T.pullAll=Hf,T.pullAllBy=W_,T.pullAllWith=V_,T.pullAt=j_,T.range=lw,T.rangeRight=uw,T.rearg=sb,T.reject=qx,T.remove=q_,T.rest=ab,T.reverse=ac,T.sampleSize=Kx,T.set=fT,T.setWith=hT,T.shuffle=Xx,T.slice=Y_,T.sortBy=Qx,T.sortedUniq=ex,T.sortedUniqBy=tx,T.split=LT,T.spread=ob,T.tail=nx,T.take=rx,T.takeRight=ix,T.takeRightWhile=sx,T.takeWhile=ax,T.tap=bx,T.throttle=cb,T.thru=fa,T.toArray=rh,T.toPairs=lh,T.toPairsIn=uh,T.toPath=mw,T.toPlainObject=sh,T.transform=dT,T.unary=lb,T.union=ox,T.unionBy=cx,T.unionWith=lx,T.uniq=ux,T.uniqBy=fx,T.uniqWith=hx,T.unset=pT,T.unzip=oc,T.unzipWith=Gf,T.update=mT,T.updateWith=gT,T.values=di,T.valuesIn=vT,T.without=dx,T.words=dh,T.wrap=ub,T.xor=px,T.xorBy=mx,T.xorWith=gx,T.zip=vx,T.zipObject=yx,T.zipObjectDeep=_x,T.zipWith=xx,T.entries=lh,T.entriesIn=uh,T.extend=ah,T.extendWith=ya,vc(T,T),T.add=vw,T.attempt=ph,T.camelCase=bT,T.capitalize=fh,T.ceil=yw,T.clamp=yT,T.clone=hb,T.cloneDeep=pb,T.cloneDeepWith=mb,T.cloneWith=db,T.conformsTo=gb,T.deburr=hh,T.defaultTo=ZT,T.divide=_w,T.endsWith=TT,T.eq=hn,T.escape=wT,T.escapeRegExp=RT,T.every=Px,T.find=Fx,T.findIndex=Bf,T.findKey=qb,T.findLast=Ox,T.findLastIndex=kf,T.findLastKey=Yb,T.floor=xw,T.forEach=Vf,T.forEachRight=jf,T.forIn=Kb,T.forInRight=Xb,T.forOwn=Zb,T.forOwnRight=$b,T.get=hc,T.gt=vb,T.gte=yb,T.has=eT,T.hasIn=dc,T.head=zf,T.identity=Dt,T.includes=Ux,T.indexOf=O_,T.inRange=_T,T.invoke=rT,T.isArguments=Nr,T.isArray=ve,T.isArrayBuffer=_b,T.isArrayLike=It,T.isArrayLikeObject=$e,T.isBoolean=xb,T.isBuffer=ar,T.isDate=bb,T.isElement=Tb,T.isEmpty=wb,T.isEqual=Rb,T.isEqualWith=Ab,T.isError=uc,T.isFinite=Eb,T.isFunction=kn,T.isInteger=Jf,T.isLength=ga,T.isMap=eh,T.isMatch=Sb,T.isMatchWith=Mb,T.isNaN=Cb,T.isNative=Ib,T.isNil=Db,T.isNull=Pb,T.isNumber=th,T.isObject=qe,T.isObjectLike=Xe,T.isPlainObject=Qi,T.isRegExp=fc,T.isSafeInteger=Fb,T.isSet=nh,T.isString=va,T.isSymbol=Ht,T.isTypedArray=hi,T.isUndefined=Ob,T.isWeakMap=Lb,T.isWeakSet=Nb,T.join=U_,T.kebabCase=AT,T.last=en,T.lastIndexOf=z_,T.lowerCase=ET,T.lowerFirst=ST,T.lt=Bb,T.lte=kb,T.max=bw,T.maxBy=Tw,T.mean=ww,T.meanBy=Rw,T.min=Aw,T.minBy=Ew,T.stubArray=_c,T.stubFalse=xc,T.stubObject=fw,T.stubString=hw,T.stubTrue=dw,T.multiply=Sw,T.nth=H_,T.noConflict=rw,T.noop=yc,T.now=da,T.pad=MT,T.padEnd=CT,T.padStart=IT,T.parseInt=PT,T.random=xT,T.reduce=Vx,T.reduceRight=jx,T.repeat=DT,T.replace=FT,T.result=uT,T.round=Mw,T.runInContext=F,T.sample=Yx,T.size=Zx,T.snakeCase=OT,T.some=$x,T.sortedIndex=K_,T.sortedIndexBy=X_,T.sortedIndexOf=Z_,T.sortedLastIndex=$_,T.sortedLastIndexBy=Q_,T.sortedLastIndexOf=J_,T.startCase=NT,T.startsWith=BT,T.subtract=Cw,T.sum=Iw,T.sumBy=Pw,T.template=kT,T.times=pw,T.toFinite=Un,T.toInteger=ye,T.toLength=ih,T.toLower=UT,T.toNumber=tn,T.toSafeInteger=Ub,T.toString=Oe,T.toUpper=zT,T.trim=HT,T.trimEnd=GT,T.trimStart=WT,T.truncate=VT,T.unescape=jT,T.uniqueId=gw,T.upperCase=qT,T.upperFirst=pc,T.each=Vf,T.eachRight=jf,T.first=zf,vc(T,function(){var t={};return xn(T,function(r,l){Le.call(T.prototype,l)||(t[l]=r)}),t}(),{chain:!1}),T.VERSION=i,Xt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){T[t].placeholder=T}),Xt(["drop","take"],function(t,r){Ae.prototype[t]=function(l){l=l===n?1:it(ye(l),0);var d=this.__filtered__&&!r?new Ae(this):this.clone();return d.__filtered__?d.__takeCount__=dt(l,d.__takeCount__):d.__views__.push({size:dt(l,je),type:t+(d.__dir__<0?"Right":"")}),d},Ae.prototype[t+"Right"]=function(l){return this.reverse()[t](l).reverse()}}),Xt(["filter","map","takeWhile"],function(t,r){var l=r+1,d=l==Q||l==Re;Ae.prototype[t]=function(_){var w=this.clone();return w.__iteratees__.push({iteratee:fe(_,3),type:l}),w.__filtered__=w.__filtered__||d,w}}),Xt(["head","last"],function(t,r){var l="take"+(r?"Right":"");Ae.prototype[t]=function(){return this[l](1).value()[0]}}),Xt(["initial","tail"],function(t,r){var l="drop"+(r?"":"Right");Ae.prototype[t]=function(){return this.__filtered__?new Ae(this):this[l](1)}}),Ae.prototype.compact=function(){return this.filter(Dt)},Ae.prototype.find=function(t){return this.filter(t).head()},Ae.prototype.findLast=function(t){return this.reverse().find(t)},Ae.prototype.invokeMap=xe(function(t,r){return typeof t=="function"?new Ae(this):this.map(function(l){return qi(l,t,r)})}),Ae.prototype.reject=function(t){return this.filter(ma(fe(t)))},Ae.prototype.slice=function(t,r){t=ye(t);var l=this;return l.__filtered__&&(t>0||r<0)?new Ae(l):(t<0?l=l.takeRight(-t):t&&(l=l.drop(t)),r!==n&&(r=ye(r),l=r<0?l.dropRight(-r):l.take(r-t)),l)},Ae.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Ae.prototype.toArray=function(){return this.take(je)},xn(Ae.prototype,function(t,r){var l=/^(?:filter|find|map|reject)|While$/.test(r),d=/^(?:head|last)$/.test(r),_=T[d?"take"+(r=="last"?"Right":""):r],w=d||/^find/.test(r);_&&(T.prototype[r]=function(){var S=this.__wrapped__,I=d?[1]:arguments,L=S instanceof Ae,W=I[0],V=L||ve(S),Y=function(we){var Me=_.apply(T,Jn([we],I));return d&&J?Me[0]:Me};V&&l&&typeof W=="function"&&W.length!=1&&(L=V=!1);var J=this.__chain__,ie=!!this.__actions__.length,he=w&&!J,_e=L&&!ie;if(!w&&V){S=_e?S:new Ae(this);var de=t.apply(S,I);return de.__actions__.push({func:fa,args:[Y],thisArg:n}),new $t(de,J)}return he&&_e?t.apply(this,I):(de=this.thru(Y),he?d?de.value()[0]:de.value():de)})}),Xt(["pop","push","shift","sort","splice","unshift"],function(t){var r=Bs[t],l=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",d=/^(?:pop|shift)$/.test(t);T.prototype[t]=function(){var _=arguments;if(d&&!this.__chain__){var w=this.value();return r.apply(ve(w)?w:[],_)}return this[l](function(S){return r.apply(ve(S)?S:[],_)})}}),xn(Ae.prototype,function(t,r){var l=T[r];if(l){var d=l.name+"";Le.call(oi,d)||(oi[d]=[]),oi[d].push({name:r,func:l})}}),oi[ia(n,A).name]=[{name:"wrapper",func:n}],Ae.prototype.clone=jv,Ae.prototype.reverse=qv,Ae.prototype.value=Yv,T.prototype.at=Tx,T.prototype.chain=wx,T.prototype.commit=Rx,T.prototype.next=Ax,T.prototype.plant=Sx,T.prototype.reverse=Mx,T.prototype.toJSON=T.prototype.valueOf=T.prototype.value=Cx,T.prototype.first=T.prototype.head,Ui&&(T.prototype[Ui]=Ex),T},ii=Rv();Mr?((Mr.exports=ii)._=ii,go._=ii):ft._=ii}).call(g0)}(Si,Si.exports)),Si.exports}var y0=v0();const _0=1e3/60;class x0{constructor(e,n,i,s,c,a){this.isSceneActive=!1,this.animationFrameId=null,this.throttledRender=y0.throttle(()=>{if(!this.renderer||!this.scene||!this.camera){console.warn("AnimationManager: Cannot render - missing required components");return}if(this.isSceneActive||!this.options.staticScene)try{this.renderer.render(this.scene,this.camera)}catch(u){console.error("AnimationManager: Render error",u)}},_0),this.animate=u=>{var f;if(!(!this.isSceneActive&&this.options.staticScene)){if(this.animationFrameId=requestAnimationFrame(this.animate),this.options.animationLoop)try{this.options.animationLoop(u)}catch(p){console.error("AnimationManager: Error in animation loop",p)}this.controls&&this.controls.update(),this.options.usePathTracing&&((f=this.pathTracingManager)!=null&&f.ptRenderer)&&"updateCamera"in this.pathTracingManager.ptRenderer&&this.pathTracingManager.ptRenderer.updateCamera(),this.renderer&&(this.renderer.shadowMap.needsUpdate=!0),this.throttledRender()}},this.renderer=e,this.scene=n,this.camera=i,this.controls=s,this.options=c,this.pathTracingManager=a}setup(){return this.renderer?this.scene?this.camera?this.controls?se.ok(void 0):se.err(new oe("Cannot initialize AnimationManager: Controls are not provided",ue.INVALID_CONFIGURATION,{manager:"AnimationManager",method:"setup"})):se.err(new oe("Cannot initialize AnimationManager: Camera is not provided",ue.CAMERA_INIT_FAILED,{manager:"AnimationManager",method:"setup"})):se.err(new oe("Cannot initialize AnimationManager: Scene is not provided",ue.SCENE_INIT_FAILED,{manager:"AnimationManager",method:"setup"})):se.err(new oe("Cannot initialize AnimationManager: Renderer is not provided",ue.RENDERER_INIT_FAILED,{manager:"AnimationManager",method:"setup"}))}startInitialRendering(){var e;this.animate(performance.now()),this.options.usePathTracing&&((e=this.pathTracingManager)==null||e.startPathTracing())}startRendering(){return!this.renderer||!this.scene||!this.camera||!this.controls?se.err(new oe("Cannot start rendering: Required components not initialized",ue.INVALID_CONFIGURATION,{hasRenderer:!!this.renderer,hasScene:!!this.scene,hasCamera:!!this.camera,hasControls:!!this.controls})):se.wrap(()=>{var e;this.isSceneActive||(this.isSceneActive=!0,this.options.usePathTracing&&((e=this.pathTracingManager)==null||e.stopPathTracing()),this.animate(performance.now()))})}stopRendering(){return se.wrap(()=>{var e;this.isSceneActive=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.options.usePathTracing&&((e=this.pathTracingManager)==null||e.startPathTracing())})}dispose(){this.stopRendering(),this.throttledRender.cancel(),this.renderer=null,this.scene=null,this.camera=null,this.controls=null,this.pathTracingManager=null}}class b0{constructor(e){this.loadedTexture=null,this.pmremGenerator=null,this.renderer=e.renderer,this.scene=e.scene,this.camera=e.camera,this.envMapUrl=e.envMapUrl,this.usePathTracing=e.usePathTracing,this.pathTracingManager=e.pathTracingManager??null,this.backgroundBlurriness=e.backgroundBlurriness??.4,this.blurStrengthPathTracing=e.blurStrengthPathTracing??.4}setup(){return this.renderer?this.scene?this.camera?se.ok(void 0):se.err(new oe("Cannot initialize EnvironmentMapManager: Camera is not provided",ue.CAMERA_INIT_FAILED,{manager:"EnvironmentMapManager",method:"setup"})):se.err(new oe("Cannot initialize EnvironmentMapManager: Scene is not provided",ue.SCENE_INIT_FAILED,{manager:"EnvironmentMapManager",method:"setup"})):se.err(new oe("Cannot initialize EnvironmentMapManager: Renderer is not provided",ue.RENDERER_INIT_FAILED,{manager:"EnvironmentMapManager",method:"setup"}))}async load(){const e=this.setup();if(!e.ok)return se.err(e.error);if(!this.envMapUrl)return se.err(new oe("No environment map URL provided",ue.INVALID_CONFIGURATION,{manager:"EnvironmentMapManager",method:"load"}));const n=this.renderer,i=this.scene,s=this.camera;return new Promise(c=>{new N.TextureLoader().load(this.envMapUrl,u=>{try{this.loadedTexture=u,u.mapping=N.EquirectangularReflectionMapping,this.pmremGenerator=new N.PMREMGenerator(n),this.pmremGenerator.compileEquirectangularShader();const f=this.pmremGenerator.fromEquirectangular(u).texture;if(i.environment=f,i.background=f,i.backgroundBlurriness=this.backgroundBlurriness,this.usePathTracing&&this.pathTracingManager){const p=this.processPathTracingEnvironment(u,i,f);if(!p.ok){c(se.err(p.error));return}}else n.render(i,s),u.dispose(),this.loadedTexture=null;this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=null),c(se.ok(f))}catch(f){c(se.err(oe.fromError(f,ue.RESOURCE_NOT_FOUND,{url:this.envMapUrl,manager:"EnvironmentMapManager"})))}},void 0,u=>{c(se.err(new oe(`Failed to load environment map: ${u}`,ue.RESOURCE_NOT_FOUND,{url:this.envMapUrl,originalError:u})))})})}processPathTracingEnvironment(e,n,i){var s;try{const{BlurredEnvMapGenerator:c}=Cs();if(!c)return se.err(new oe("Failed to import BlurredEnvMapGenerator",ue.RESOURCE_NOT_FOUND,{manager:"EnvironmentMapManager"}));if(!this.renderer)return se.err(new oe("Renderer not available for path tracing environment",ue.RENDERER_INIT_FAILED));const u=new c(this.renderer).generate(e,this.blurStrengthPathTracing);return n.environment=u,n.background=u,(s=this.pathTracingManager)!=null&&s.ptRenderer&&"updateEnvironment"in this.pathTracingManager.ptRenderer&&this.pathTracingManager.ptRenderer.updateEnvironment(),e.dispose(),this.loadedTexture=null,se.ok(void 0)}catch(c){return se.err(oe.fromError(c,ue.RENDER_ERROR,{manager:"EnvironmentMapManager",method:"processPathTracingEnvironment"}))}}updateEnvironment(){return this.scene?this.scene.environment?se.wrap(()=>{var e;this.usePathTracing&&((e=this.pathTracingManager)!=null&&e.ptRenderer)&&"updateEnvironment"in this.pathTracingManager.ptRenderer&&this.pathTracingManager.ptRenderer.updateEnvironment()}):se.err(new oe("No environment map loaded",ue.RESOURCE_NOT_FOUND,{manager:"EnvironmentMapManager"})):se.err(new oe("Scene not available for environment update",ue.SCENE_INIT_FAILED,{manager:"EnvironmentMapManager"}))}dispose(){this.loadedTexture&&(this.loadedTexture.dispose(),this.loadedTexture=null),this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=null),this.scene&&(this.scene.environment=null,this.scene.background=null),this.renderer=null,this.scene=null,this.camera=null,this.pathTracingManager=null}}class T0{constructor(e,n,i,s){this.environmentMapManager=null;const{mountRef:c,sceneRef:a,rendererRef:u,cameraRef:f}=e;if(this.mountRef=c,this.sceneRef=a,this.rendererRef=u,this.cameraRef=f,this.object=n,this.options=i,!this.mountRef.current)throw new oe("Mount element is not ready",ue.COMPONENT_NOT_MOUNTED);this.cameraManager=new Pg(this.mountRef,this.options),this.rendererManager=new Fg(this.options);const p=this.rendererManager.setup();if(!p.ok)throw p.error;this.controlsManager=new Kg(this.cameraManager.camera,p.value.domElement,this.options);const v=this.controlsManager.setup();if(!v.ok)throw v.error;this.sceneInitializer=new p0(this.object,this.cameraManager.camera,v.value,this.options,this.mountRef);const g=this.sceneInitializer.setup();if(!g.ok)throw g.error;if(this.rendererRef.current=p.value,this.cameraRef.current=this.cameraManager.camera,this.sceneRef.current=g.value,this.options.usePathTracing){this.pathTracingManager=new m0(p.value,g.value,this.cameraManager.camera,this.options,s);const R=this.pathTracingManager.setup();R.ok||(console.warn("Failed to setup path tracer:",R.error),this.pathTracingManager=null)}else this.pathTracingManager=null;this.environmentMapManager=new b0({renderer:p.value,scene:g.value,camera:this.cameraManager.camera,envMapUrl:this.options.envMapUrl,usePathTracing:this.options.usePathTracing,pathTracingManager:this.pathTracingManager,backgroundBlurriness:.4,blurStrengthPathTracing:.4});const h=this.environmentMapManager.setup();h.ok||console.warn("Failed to setup environment map manager:",h.error),this.options.envMapUrl&&this.environmentMapManager.load().then(R=>{R.ok||console.warn("Failed to load environment map:",R.error)}),this.mountRef.current.appendChild(p.value.domElement),this.animationManager=new x0(p.value,g.value,this.cameraManager.camera,v.value,this.options,this.pathTracingManager);const b=this.animationManager.setup();if(!b.ok)throw b.error;this.animationManager.startInitialRendering(),v.value.addEventListener("start",()=>{this.onStartRendering()}),v.value.addEventListener("end",()=>{const R=this.animationManager.stopRendering();R.ok||console.warn("Failed to stop rendering:",R.error)})}onStartRendering(){var n;if(this.options.usePathTracing&&!this.pathTracingManager)throw new oe("Path Tracing Manager is not initialized",ue.RENDERER_INIT_FAILED);const e=this.animationManager.startRendering();if(!e.ok)throw console.error("Failed to start rendering:",e.error),e.error;this.options.usePathTracing&&((n=this.pathTracingManager)==null||n.stopPathTracing())}getSceneElements(){return{scene:this.sceneInitializer.scene,camera:this.cameraManager.camera,renderer:this.rendererManager.renderer,controls:this.controlsManager.controls,pathTracingManager:this.pathTracingManager}}}const w0=(o,e,n,i)=>{if(n.current){const s=n.current.clientWidth,c=n.current.clientHeight;o.setSize(s,c),e instanceof N.PerspectiveCamera&&(e.aspect=s/c,e.updateProjectionMatrix()),o.render(i,e)}},R0=(o,e)=>{let n;return(...i)=>{n||(o(...i),n=!0,setTimeout(()=>{n=!1},e))}},Ps={staticScene:!0,usePathTracing:!1,maxSamplesPathTracing:300,envMapUrl:"https://dl.polyhaven.org/file/ph-assets/HDRIs/extra/Tonemapped%20JPG/industrial_sunset_puresky.jpg",pathTracingSettings:{bounces:8,transmissiveBounces:4,lowResScale:.7,renderScale:1,enablePathTracing:!0,dynamicLowRes:!0},backgroundColor:"#f0f0f7",camera:{cameraPosition:[60,60,60],cameraTarget:[0,0,0],cameraFov:75,cameraNear:.1,cameraFar:1e5,autoFitToObject:!1},lightning:{ambientLight:{color:"#404040",intensity:Math.PI},hemisphereLight:{skyColor:"#ffffbb",groundColor:"#080820",intensity:1},directionalLight:{color:"#ffffff",intensity:Math.PI,position:new N.Vector3(6,6,6),castShadow:!0,shadow:{mapSize:{width:4096,height:4096},camera:{near:.5,far:50,left:-10,right:10,top:10,bottom:-10},bias:-1e-4,radius:1}}},renderer:{antialias:!0,alpha:!1,shadowMapEnabled:!0,pixelRatio:window.devicePixelRatio,shadowMapType:N.VSMShadowMap,toneMapping:N.ACESFilmicToneMapping,toneMappingExposure:1},controls:{type:co.OrbitControls,enabled:!0,enableDamping:!0,dampingFactor:.25,enableZoom:!0,enableRotate:!0,enablePan:!0},helpers:{gridHelper:!0,studioEnvironment:!0,color:"#AAAAAA",axesHelper:!1,object3DHelper:!1,addGizmo:!1},threeBaseRefs:{mountPoint:{current:null},scene:{current:null},camera:{current:null},renderer:{current:null},controls:{current:null}},animationLoop:null,replaceWithScreenshotOnComplete:!1};class Gl{constructor(){this.listeners=new Map}on(e,n){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(n),()=>{var i;(i=this.listeners.get(e))==null||i.delete(n)}}emit(e,n){var i;(i=this.listeners.get(e))==null||i.forEach(s=>{try{s(n)}catch(c){console.error(`Error in event listener for ${String(e)}:`,c)}})}once(e,n){const i=this.on(e,s=>{i(),n(s)});return i}removeAllListeners(e){e?this.listeners.delete(e):this.listeners.clear()}listenerCount(e){var n;return((n=this.listeners.get(e))==null?void 0:n.size)||0}}const lo=class lo{static validate(e){return this.errors=[],e.camera&&this.validateCameraOptions(e.camera),e.renderer&&this.validateRendererOptions(e.renderer),e.controls&&this.validateControlsOptions(e.controls),e.helpers&&this.validateHelpersOptions(e.helpers),e.usePathTracing&&e.pathTracingSettings&&this.validatePathTracingOptions(e.pathTracingSettings),e.lightning&&this.validateLightningOptions(e.lightning),this.errors.length>0?se.err(new oe(`Invalid configuration: ${this.errors.length} validation error(s)`,ue.INVALID_CONFIGURATION,{errors:this.errors,options:e})):se.ok(e)}static validateCameraOptions(e){e.cameraFov!==void 0&&(e.cameraFov<1||e.cameraFov>180)&&this.errors.push({field:"camera.cameraFov",message:"Camera FOV must be between 1 and 180 degrees",value:e.cameraFov}),e.cameraNear!==void 0&&e.cameraNear<=0&&this.errors.push({field:"camera.cameraNear",message:"Camera near plane must be positive",value:e.cameraNear}),e.cameraFar!==void 0&&(e.cameraFar<=0&&this.errors.push({field:"camera.cameraFar",message:"Camera far plane must be positive",value:e.cameraFar}),e.cameraNear!==void 0&&e.cameraFar<=e.cameraNear&&this.errors.push({field:"camera.cameraFar",message:"Camera far plane must be greater than near plane",value:{near:e.cameraNear,far:e.cameraFar}})),e.cameraPosition&&(!Array.isArray(e.cameraPosition)||e.cameraPosition.length!==3?this.errors.push({field:"camera.cameraPosition",message:"Camera position must be an array of 3 numbers",value:e.cameraPosition}):e.cameraPosition.every(n=>typeof n=="number"&&!isNaN(n))||this.errors.push({field:"camera.cameraPosition",message:"Camera position values must be valid numbers",value:e.cameraPosition})),e.cameraTarget&&(!Array.isArray(e.cameraTarget)||e.cameraTarget.length!==3?this.errors.push({field:"camera.cameraTarget",message:"Camera target must be an array of 3 numbers",value:e.cameraTarget}):e.cameraTarget.every(n=>typeof n=="number"&&!isNaN(n))||this.errors.push({field:"camera.cameraTarget",message:"Camera target values must be valid numbers",value:e.cameraTarget}))}static validateRendererOptions(e){e.pixelRatio!==void 0&&(e.pixelRatio<=0||e.pixelRatio>4)&&this.errors.push({field:"renderer.pixelRatio",message:"Pixel ratio must be between 0 and 4",value:e.pixelRatio}),e.toneMappingExposure!==void 0&&e.toneMappingExposure<0&&this.errors.push({field:"renderer.toneMappingExposure",message:"Tone mapping exposure must be non-negative",value:e.toneMappingExposure}),e.shadowMapType!==void 0&&([N.BasicShadowMap,N.PCFShadowMap,N.PCFSoftShadowMap,N.VSMShadowMap].includes(e.shadowMapType)||this.errors.push({field:"renderer.shadowMapType",message:"Invalid shadow map type",value:e.shadowMapType})),e.toneMapping!==void 0&&([N.NoToneMapping,N.LinearToneMapping,N.ReinhardToneMapping,N.CineonToneMapping,N.ACESFilmicToneMapping,N.CustomToneMapping,N.AgXToneMapping,N.NeutralToneMapping].includes(e.toneMapping)||this.errors.push({field:"renderer.toneMapping",message:"Invalid tone mapping type",value:e.toneMapping}))}static validateControlsOptions(e){e.dampingFactor!==void 0&&(e.dampingFactor<0||e.dampingFactor>1)&&this.errors.push({field:"controls.dampingFactor",message:"Damping factor must be between 0 and 1",value:e.dampingFactor})}static validateHelpersOptions(e){typeof e.axesHelper=="number"&&e.axesHelper<=0&&this.errors.push({field:"helpers.axesHelper",message:"Axes helper size must be positive",value:e.axesHelper}),e.color!==void 0&&(this.isValidColor(e.color)||this.errors.push({field:"helpers.color",message:"Invalid color format",value:e.color}))}static validatePathTracingOptions(e){e.bounces!==void 0&&(e.bounces<0||e.bounces>32)&&this.errors.push({field:"pathTracingSettings.bounces",message:"Bounces must be between 0 and 32",value:e.bounces}),e.transmissiveBounces!==void 0&&(e.transmissiveBounces<0||e.transmissiveBounces>32)&&this.errors.push({field:"pathTracingSettings.transmissiveBounces",message:"Transmissive bounces must be between 0 and 32",value:e.transmissiveBounces}),e.renderScale!==void 0&&(e.renderScale<=0||e.renderScale>2)&&this.errors.push({field:"pathTracingSettings.renderScale",message:"Render scale must be between 0 and 2",value:e.renderScale}),e.lowResScale!==void 0&&(e.lowResScale<=0||e.lowResScale>1)&&this.errors.push({field:"pathTracingSettings.lowResScale",message:"Low res scale must be between 0 and 1",value:e.lowResScale})}static validateLightningOptions(e){var n;if(e.ambientLight&&(e.ambientLight.intensity!==void 0&&e.ambientLight.intensity<0&&this.errors.push({field:"lightning.ambientLight.intensity",message:"Ambient light intensity must be non-negative",value:e.ambientLight.intensity}),e.ambientLight.color!==void 0&&(this.isValidColor(e.ambientLight.color)||this.errors.push({field:"lightning.ambientLight.color",message:"Invalid ambient light color format",value:e.ambientLight.color}))),e.hemisphereLight&&(e.hemisphereLight.intensity!==void 0&&e.hemisphereLight.intensity<0&&this.errors.push({field:"lightning.hemisphereLight.intensity",message:"Hemisphere light intensity must be non-negative",value:e.hemisphereLight.intensity}),e.hemisphereLight.skyColor!==void 0&&(this.isValidColor(e.hemisphereLight.skyColor)||this.errors.push({field:"lightning.hemisphereLight.skyColor",message:"Invalid hemisphere light sky color format",value:e.hemisphereLight.skyColor})),e.hemisphereLight.groundColor!==void 0&&(this.isValidColor(e.hemisphereLight.groundColor)||this.errors.push({field:"lightning.hemisphereLight.groundColor",message:"Invalid hemisphere light ground color format",value:e.hemisphereLight.groundColor}))),e.directionalLight&&(e.directionalLight.intensity!==void 0&&e.directionalLight.intensity<0&&this.errors.push({field:"lightning.directionalLight.intensity",message:"Directional light intensity must be non-negative",value:e.directionalLight.intensity}),e.directionalLight.color!==void 0&&(this.isValidColor(e.directionalLight.color)||this.errors.push({field:"lightning.directionalLight.color",message:"Invalid directional light color format",value:e.directionalLight.color})),(n=e.directionalLight.shadow)!=null&&n.camera)){const i=e.directionalLight.shadow.camera;i.left!==void 0&&i.right!==void 0&&i.left>=i.right&&this.errors.push({field:"lightning.directionalLight.shadow.camera",message:"Shadow camera left must be less than right",value:{left:i.left,right:i.right}}),i.bottom!==void 0&&i.top!==void 0&&i.bottom>=i.top&&this.errors.push({field:"lightning.directionalLight.shadow.camera",message:"Shadow camera bottom must be less than top",value:{bottom:i.bottom,top:i.top}})}}static getValidationErrors(){return[...this.errors]}static formatErrors(e){return e.map(n=>`${n.field}: ${n.message}${n.value!==void 0?` (value: ${JSON.stringify(n.value)})`:""}`).join(`
|
|
4087
|
-
`)}static isValidColor(e){return typeof e=="number"?!0:typeof e=="string"?/^#[0-9a-f]{6}$/i.test(e)||/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/i.test(e)||/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*[\d.]+\s*\)$/i.test(e)?!0:["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].includes(e.toLowerCase()):!1}};lo.errors=[];let Ds=lo;const A0="[ThreeDViewer Deprecation]",Wl=new Set;function dr(o,e,n="v3.0"){const i=`${A0} ${o} is deprecated and will be removed in ${n}. Use ${e} instead.`;Wl.has(i)||(Wl.add(i),console.warn(i))}function E0(o){"antialias"in o&&dr("antialias prop","render.antialias in options"),"shadowMap"in o&&dr("shadowMap prop","render.shadowMap in options"),("cameraFov"in o||"cameraPosition"in o)&&dr("cameraFov/cameraPosition props","camera.cameraFov/camera.cameraPosition in options"),("enableDamping"in o||"dampingFactor"in o)&&dr("control props at root level","controls.enableDamping/controls.dampingFactor in options"),("axes"in o||"grid"in o)&&dr("axes/grid props","helpers.axes/helpers.grid in options"),("onLoad"in o||"onError"in o)&&dr("onLoad/onError callbacks",'events.on("model:loaded") / events.on("error")'),"pathTracingSamples"in o&&dr("pathTracingSamples prop","pathTracing.samples in options")}function S0(o){const e={...o};return e.render||(e.render={}),e.camera||(e.camera={}),e.controls||(e.controls={}),e.helpers||(e.helpers={}),e.pathTracing||(e.pathTracing={}),"antialias"in e&&(e.render.antialias=e.antialias,delete e.antialias),"shadowMap"in e&&(e.render.shadowMap=e.shadowMap,delete e.shadowMap),"cameraFov"in e&&(e.camera.cameraFov=e.cameraFov,delete e.cameraFov),"cameraPosition"in e&&(e.camera.cameraPosition=e.cameraPosition,delete e.cameraPosition),"enableDamping"in e&&(e.controls.enableDamping=e.enableDamping,delete e.enableDamping),"dampingFactor"in e&&(e.controls.dampingFactor=e.dampingFactor,delete e.dampingFactor),"axes"in e&&(e.helpers.axes=e.axes,delete e.axes),"grid"in e&&(e.helpers.grid=e.grid,delete e.grid),"pathTracingSamples"in e&&(e.pathTracing.samples=e.pathTracingSamples,delete e.pathTracingSamples),e}const Vl=le.forwardRef((o,e)=>{var je,mn,gn,Kn,Lt;le.useEffect(()=>{E0(o)},[]);const n=S0(o),{object:i,options:s=Ps}=n,c=Se=>Se&&typeof Se=="object"&&"current"in Se&&Object.getPrototypeOf(Se)!==Object.prototype,a=c((je=s.threeBaseRefs)==null?void 0:je.mountPoint)?s.threeBaseRefs.mountPoint:le.useRef(null),u=c((mn=s.threeBaseRefs)==null?void 0:mn.renderer)?s.threeBaseRefs.renderer:le.useRef(null),f=c((gn=s.threeBaseRefs)==null?void 0:gn.camera)?s.threeBaseRefs.camera:le.useRef(null),p=c((Kn=s.threeBaseRefs)==null?void 0:Kn.scene)?s.threeBaseRefs.scene:le.useRef(null),v=c((Lt=s.threeBaseRefs)==null?void 0:Lt.controls)?s.threeBaseRefs.controls:le.useRef(null),g=()=>typeof i=="string"?null:i,[h,b]=le.useState(g()),[R,M]=le.useState(null),[x,A]=le.useState(!1),[E,C]=le.useState(0),[P,O]=le.useState(null),[B,k]=le.useState(null),[q,j]=le.useState(!1),K=le.useRef(0),$=le.useRef(null),H=le.useMemo(()=>new Gl,[]),Z=le.useCallback(async Se=>{A(!0),M(null),H.emit("model:loading",{url:Se});const Ke=Date.now();try{const De=new Ac,Te=await zc(Se,De);b(Te),C(Ze=>Ze+1),H.emit("model:loaded",{model:Te,loadTime:Date.now()-Ke})}catch(De){const Te=oe.fromError(De,ue.MODEL_LOAD_FAILED,{url:Se});throw M(Te),console.error("Failed to load model:",Te),H.emit("model:error",{error:Te,url:Se}),H.emit("error",{error:Te}),Te}finally{A(!1)}},[H]),Q=le.useCallback(()=>{B&&(H.emit("render:start",{frame:K.current}),B.onStartRendering())},[B,H]),ce=le.useCallback(()=>{B&&H.emit("render:complete",{frame:K.current,renderTime:0})},[B,H]),Re=le.useCallback(async()=>{if(!u.current)throw new oe("Renderer not initialized",ue.RENDERER_INIT_FAILED);const Se=u.current.domElement.toDataURL("image/png");return H.emit("screenshot:captured",{dataUrl:Se}),Se},[H]),ke=le.useCallback(()=>{$.current&&($.current(),$.current=null)},[]);le.useImperativeHandle(e,()=>({scene:p.current,camera:f.current,renderer:u.current,controls:v.current,events:H,loadModel:Z,startRendering:Q,stopRendering:ce,captureScreenshot:Re,dispose:ke}),[H,Z,Q,ce,Re,ke]),le.useEffect(()=>{(async()=>{if(typeof i=="string"){A(!0),M(null),H.emit("model:loading",{url:i});const Ke=Date.now();try{const De=new Ac,Te=await zc(i,De);b(Te),C(Ze=>Ze+1),H.emit("model:loaded",{model:Te,loadTime:Date.now()-Ke})}catch(De){const Te=oe.fromError(De,ue.MODEL_LOAD_FAILED,{url:i});M(Te),console.error("Failed to load model:",Te),H.emit("model:error",{error:Te,url:i}),H.emit("error",{error:Te})}finally{A(!1)}}else b(i)})()},[i,H]);const Ie=le.useMemo(()=>{var De;const Se={...Ps,...s},Ke=Ds.validate(Se);return Ke.ok?Se:(console.error("SimpleViewer: Invalid options detected:",Ke.error.message),(De=Ke.error.context)!=null&&De.errors&&console.error("Validation errors:",Ds.formatErrors(Ke.error.context.errors)),Ps)},[s]),et=le.useCallback(()=>{if(!u.current||!f.current||!p.current||!a.current){console.warn("Cannot resize: Some refs are not initialized");return}w0(u.current,f.current,a,p.current)},[]);le.useEffect(()=>{var De,Te,Ze,an;if(!a.current||!h&&typeof i=="string")return;const Se=R0(et,Od),Ke={mountRef:a,rendererRef:u,cameraRef:f,sceneRef:p};try{const yt=new T0(Ke,h,Ie,O);k(yt);const{renderer:Nt,scene:ct,camera:lt,controls:_t}=yt.getSceneElements();c((De=s.threeBaseRefs)==null?void 0:De.renderer)||(u.current=Nt),c((Te=s.threeBaseRefs)==null?void 0:Te.scene)||(p.current=ct),c((Ze=s.threeBaseRefs)==null?void 0:Ze.camera)||(f.current=lt),c((an=s.threeBaseRefs)==null?void 0:an.controls)||(v.current=_t),et(),j(!0),H.emit("initialized",{viewer:{scene:p.current,camera:f.current,renderer:u.current,controls:v.current,events:H,loadModel:Z,startRendering:Q,stopRendering:ce,captureScreenshot:Re}}),window.addEventListener("resize",Se);const st=()=>{j(!1),H.emit("disposed",{viewer:{scene:p.current,camera:f.current,renderer:u.current,controls:v.current,events:H,loadModel:Z,startRendering:Q,stopRendering:ce,captureScreenshot:Re,dispose:ke}}),Fd(a,Nt,Se)};return $.current=st,st}catch(yt){const Nt=oe.fromError(yt,ue.SCENE_INIT_FAILED,{options:Ie});M(Nt),console.error("Failed to initialize scene:",Nt),H.emit("error",{error:Nt})}},[i,Ie,et,h,H]);const vt=le.useCallback(()=>{var De;if(!u.current||!v.current||!p.current||!f.current)return;K.current+=1;const Se=K.current;H.emit("render:start",{frame:Se});const Ke=performance.now();try{v.current.update(),Ie.usePathTracing&&(B!=null&&B.pathTracingManager)&&B.pathTracingManager.updatePathTracerRenderer().ok?(De=B.pathTracingManager.ptRenderer)==null||De.renderSample():u.current.render(p.current,f.current);const Te=performance.now()-Ke;H.emit("render:complete",{frame:Se,renderTime:Te})}catch(Te){const Ze=oe.fromError(Te,ue.RENDER_ERROR,{usePathTracing:Ie.usePathTracing});console.error("Render error:",Ze)}},[B,Ie.usePathTracing,H]);return R?Vt.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f8f8f8",color:"#333",padding:"20px",textAlign:"center"},children:Vt.jsxs("div",{children:[Vt.jsx("h3",{children:"Error Loading 3D Viewer"}),Vt.jsx("p",{children:R.message}),R.code===ue.MODEL_LOAD_FAILED&&Vt.jsx("p",{style:{fontSize:"0.9em",color:"#666"},children:"Please check the model URL and try again."})]})}):x?Vt.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f8f8f8"},children:Vt.jsx("div",{children:"Loading 3D model..."})}):Ie.replaceWithScreenshotOnComplete&&P?Vt.jsx("img",{src:P,alt:"Render Complete"}):Vt.jsxs(Vt.Fragment,{children:[q&&Ie.helpers.addGizmo&&f.current&&v.current?Vt.jsx(Dd,{camera:f.current,controls:v.current,render:vt}):null,Vt.jsx("div",{style:{width:"100%",height:"100%"},ref:a})]})});Vl.displayName="SimpleViewer",pn.SimpleViewer=Vl,pn.TypedEventEmitter=Gl,pn.defaultOptions=Ps,Object.defineProperty(pn,Symbol.toStringTag,{value:"Module"})});
|
|
4039
|
+
Check the top-level render call using <`+N+">.")}return I}}function or(m,I){{if(!m._store||m._store.validated||m.key!=null)return;m._store.validated=!0;var N=nn(I);if(sr[N])return;sr[N]=!0;var Z="";m&&m._owner&&m._owner!==De.current&&(Z=" It was passed a child from "+G(m._owner.type)+"."),K(m),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',N,Z),K(null)}}function ar(m,I){{if(typeof m!="object")return;if(Rt(m))for(var N=0;N<m.length;N++){var Z=m[N];Ot(Z)&&or(Z,I)}else if(Ot(m))m._store&&(m._store.validated=!0);else if(m){var ie=g(m);if(typeof ie=="function"&&ie!==m.entries)for(var oe=ie.call(m),Q;!(Q=oe.next()).done;)Ot(Q.value)&&or(Q.value,I)}}}function sn(m){{var I=m.type;if(I==null||typeof I=="string")return;var N;if(typeof I=="function")N=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===c||I.$$typeof===h))N=I.propTypes;else return;if(N){var Z=G(I);Qr(N,m.props,"prop",Z,m)}else if(I.PropTypes!==void 0&&!nt){nt=!0;var ie=G(I);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function on(m){{for(var I=Object.keys(m.props),N=0;N<I.length;N++){var Z=I[N];if(Z!=="children"&&Z!=="key"){K(m),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Z),K(null);break}}m.ref!==null&&(K(m),w("Invalid attribute `ref` supplied to `React.Fragment`."),K(null))}}var cr={};function lr(m,I,N,Z,ie,oe){{var Q=E(m);if(!Q){var $="";(m===void 0||typeof m=="object"&&m!==null&&Object.keys(m).length===0)&&($+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var p=rn();p?$+=p:$+=ir();var y;m===null?y="null":Rt(m)?y="array":m!==void 0&&m.$$typeof===e?(y="<"+(G(m.type)||"Unknown")+" />",$=" Did you accidentally export a JSX literal instead of a component?"):y=typeof m,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",y,$)}var _=Ve(m,I,N,ie,oe);if(_==null)return _;if(Q){var M=I.children;if(M!==void 0)if(Z)if(Rt(M)){for(var k=0;k<M.length;k++)ar(M[k],m);Object.freeze&&Object.freeze(M)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ar(M,m)}if(rt.call(I,"key")){var R=G(m),B=Object.keys(I).filter(function(j){return j!=="key"}),q=B.length>0?"{key: someKey, "+B.join(": ..., ")+": ...}":"{key: someKey}";if(!cr[R+q]){var Y=B.length>0?"{"+B.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
4040
|
+
let props = %s;
|
|
4041
|
+
<%s {...props} />
|
|
4042
|
+
React keys must be passed directly to JSX without using spread:
|
|
4043
|
+
let props = %s;
|
|
4044
|
+
<%s key={someKey} {...props} />`,q,R,Y,R),cr[R+q]=!0}}return m===r?on(_):sn(_),_}}function an(m,I,N){return lr(m,I,N,!0)}function cn(m,I,N){return lr(m,I,N,!1)}var Lr=cn,ln=an;Vn.Fragment=r,Vn.jsx=Lr,Vn.jsxs=ln}()),Vn}process.env.NODE_ENV==="production"?zi.exports=rh():zi.exports=nh();var ih=zi.exports;const sh=(s,e,t,r,n,o)=>{const i=performance.now(),a=()=>{const c=performance.now()-i,u=Math.min(c/n,1);s.position.lerpVectors(t,r,u),e==null||e.update(),o(),u<1&&requestAnimationFrame(a)};requestAnimationFrame(a)},go=(s,e)=>{s.quaternion.copy(e.quaternion);const t=new C.Vector3(0,0,-1).applyQuaternion(s.quaternion).normalize();s.position.copy(t.multiplyScalar(-8)),s.lookAt(new C.Vector3(0,0,0)),s.updateMatrixWorld(!0)},oh=(s,e,t)=>{const r=t.target.clone(),n=s.position.clone().sub(r).length(),o=new C.Vector3(0,0,-1).applyQuaternion(e.quaternion).normalize().multiplyScalar(-n);s.position.copy(r).add(o),s.quaternion.copy(e.quaternion),s.updateMatrixWorld(!0),t.update()},ah=()=>{try{const s=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(s.getContext("webgl")||s.getContext("experimental-webgl")))}catch{return!1}},ch=()=>ah()?new C.WebGLRenderer({alpha:!0,antialias:!1}):(console.error("WebGL is not supported in this environment."),null),vo={type:"change"},Ei={type:"start"},yo={type:"end"},Gn=new f.Ray,bo=new f.Plane,lh=Math.cos(70*f.MathUtils.DEG2RAD),Ne=new f.Vector3,Qe=2*Math.PI,we={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ui=1e-6;class uh extends f.Controls{constructor(e,t=null){super(e,t),this.state=we.NONE,this.enabled=!0,this.target=new f.Vector3,this.cursor=new f.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:f.MOUSE.ROTATE,MIDDLE:f.MOUSE.DOLLY,RIGHT:f.MOUSE.PAN},this.touches={ONE:f.TOUCH.ROTATE,TWO:f.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new f.Vector3,this._lastQuaternion=new f.Quaternion,this._lastTargetPosition=new f.Vector3,this._quat=new f.Quaternion().setFromUnitVectors(e.up,new f.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new f.Spherical,this._sphericalDelta=new f.Spherical,this._scale=1,this._panOffset=new f.Vector3,this._rotateStart=new f.Vector2,this._rotateEnd=new f.Vector2,this._rotateDelta=new f.Vector2,this._panStart=new f.Vector2,this._panEnd=new f.Vector2,this._panDelta=new f.Vector2,this._dollyStart=new f.Vector2,this._dollyEnd=new f.Vector2,this._dollyDelta=new f.Vector2,this._dollyDirection=new f.Vector3,this._mouse=new f.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=fh.bind(this),this._onPointerDown=hh.bind(this),this._onPointerUp=dh.bind(this),this._onContextMenu=xh.bind(this),this._onMouseWheel=gh.bind(this),this._onKeyDown=vh.bind(this),this._onTouchStart=yh.bind(this),this._onTouchMove=bh.bind(this),this._onMouseDown=ph.bind(this),this._onMouseMove=mh.bind(this),this._interceptControlDown=wh.bind(this),this._interceptControlUp=_h.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(vo),this.update(),this.state=we.NONE}update(e=null){const t=this.object.position;Ne.copy(t).sub(this.target),Ne.applyQuaternion(this._quat),this._spherical.setFromVector3(Ne),this.autoRotate&&this.state===we.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(r)&&isFinite(n)&&(r<-Math.PI?r+=Qe:r>Math.PI&&(r-=Qe),n<-Math.PI?n+=Qe:n>Math.PI&&(n-=Qe),r<=n?this._spherical.theta=Math.max(r,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+n)/2?Math.max(r,this._spherical.theta):Math.min(n,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const i=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=i!=this._spherical.radius}if(Ne.setFromSpherical(this._spherical),Ne.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ne),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let i=null;if(this.object.isPerspectiveCamera){const a=Ne.length();i=this._clampDistance(a*this._scale);const c=a-i;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),o=!!c}else if(this.object.isOrthographicCamera){const a=new f.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=c!==this.object.zoom;const u=new f.Vector3(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(a),this.object.updateMatrixWorld(),i=Ne.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;i!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(i).add(this.object.position):(Gn.origin.copy(this.object.position),Gn.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Gn.direction))<lh?this.object.lookAt(this.target):(bo.setFromNormalAndCoplanarPoint(this.object.up,this.target),Gn.intersectPlane(bo,this.target))))}else if(this.object.isOrthographicCamera){const i=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),i!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>Ui||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ui||this._lastTargetPosition.distanceToSquared(this.target)>Ui?(this.dispatchEvent(vo),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Qe/60*this.autoRotateSpeed*e:Qe/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ne.setFromMatrixColumn(t,0),Ne.multiplyScalar(-e),this._panOffset.add(Ne)}_panUp(e,t){this.screenSpacePanning===!0?Ne.setFromMatrixColumn(t,1):(Ne.setFromMatrixColumn(t,0),Ne.crossVectors(this.object.up,Ne)),Ne.multiplyScalar(e),this._panOffset.add(Ne)}_pan(e,t){const r=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;Ne.copy(n).sub(this.target);let o=Ne.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/r.clientHeight,this.object.matrix),this._panUp(2*t*o/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),n=e-r.left,o=t-r.top,i=r.width,a=r.height;this._mouse.x=n/i*2-1,this._mouse.y=-(o/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Qe*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qe*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(Qe*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-Qe*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(Qe*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-Qe*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(r,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(r,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,n=e.pageY-t.y,o=Math.sqrt(r*r+n*n);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),n=.5*(e.pageX+r.x),o=.5*(e.pageY+r.y);this._rotateEnd.set(n,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Qe*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qe*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(r,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,n=e.pageY-t.y,o=Math.sqrt(r*r+n*n);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const i=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(i,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new f.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function hh(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s)))}function fh(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function dh(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(yo),this.state=we.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function ph(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case f.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=we.DOLLY;break;case f.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=we.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=we.ROTATE}break;case f.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=we.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=we.PAN}break;default:this.state=we.NONE}this.state!==we.NONE&&this.dispatchEvent(Ei)}function mh(s){switch(this.state){case we.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case we.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case we.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function gh(s){this.enabled===!1||this.enableZoom===!1||this.state!==we.NONE||(s.preventDefault(),this.dispatchEvent(Ei),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(yo))}function vh(s){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(s)}function yh(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case f.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=we.TOUCH_ROTATE;break;case f.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=we.TOUCH_PAN;break;default:this.state=we.NONE}break;case 2:switch(this.touches.TWO){case f.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=we.TOUCH_DOLLY_PAN;break;case f.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=we.TOUCH_DOLLY_ROTATE;break;default:this.state=we.NONE}break;default:this.state=we.NONE}this.state!==we.NONE&&this.dispatchEvent(Ei)}function bh(s){switch(this._trackPointer(s),this.state){case we.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case we.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case we.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case we.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=we.NONE}}function xh(s){this.enabled!==!1&&s.preventDefault()}function wh(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function _h(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Th=s=>{const e=new C.AmbientLight(16777215,1);s.add(e);const t=new C.DirectionalLight(16777215,1);t.position.set(5,10,5),s.add(t);const r=new C.DirectionalLight(16777215,1);r.position.set(-5,-10,5),s.add(r);const n=new C.PointLight(16777215,1,100);n.position.set(0,0,5),s.add(n),t.castShadow=!1,r.castShadow=!1,n.castShadow=!1},pe={CUBE_SIZE:1.8,EDGE_SECTION_SIZE:.35,FACE_THICKNESS:.35,CANVAS_SIZE:256,FONT_SIZE:"62px",TEXT_COLOR:"#000000",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",FACE_COLOR:"#EFF3F2",EDGE_COLOR:"#EFF3F2",CORNER_COLOR:"#EFF3F2",LINE_COLOR:0};var jt=(s=>(s.FRONT="FRONT",s.BACK="BACK",s.RIGHT="RIGHT",s.LEFT="LEFT",s.TOP="TOP",s.BOTTOM="BOTTOM",s))(jt||{});new C.Vector3(0,1,0);class Sh{static createTextTexture(e){const t=document.createElement("canvas"),r=t.getContext("2d");t.width=pe.CANVAS_SIZE,t.height=pe.CANVAS_SIZE,r&&(r.clearRect(0,0,t.width,t.height),r.font=`${pe.FONT_SIZE} Arial`,r.fillStyle=pe.TEXT_COLOR,r.textAlign=pe.TEXT_ALIGN,r.textBaseline=pe.TEXT_BASELINE,r.fillText(e,t.width/2,t.height/2));const n=new C.CanvasTexture(t);return n.needsUpdate=!0,n}}class jn{static createWireframe([e,t,r]){const n=new C.BoxGeometry(e,t,r),o=new C.EdgesGeometry(n),i=new C.LineBasicMaterial({color:pe.LINE_COLOR}),a=new C.LineSegments(o,i);return a.name="Wireframe",a}static createEdgeBox(e,t,r){const n=pe.CUBE_SIZE-pe.EDGE_SECTION_SIZE,o={x:pe.EDGE_SECTION_SIZE,y:pe.EDGE_SECTION_SIZE,z:pe.EDGE_SECTION_SIZE};o[t]=n;const i=new C.BoxGeometry(o.x,o.y,o.z),a=new C.MeshStandardMaterial({color:pe.EDGE_COLOR}),c=new C.Mesh(i,a);return c.position.copy(e),c.name=`Edge Box ${r}`,c}static createCornerCube(e,t){const r=new C.BoxGeometry(pe.EDGE_SECTION_SIZE,pe.EDGE_SECTION_SIZE,pe.EDGE_SECTION_SIZE),n=new C.MeshStandardMaterial({color:pe.CORNER_COLOR}),o=new C.Mesh(r,n);return o.position.copy(e),o.name=`Corner Cube ${t}`,o}static createFace(e,t,r){const n=new C.Group,o=new C.BoxGeometry(pe.CUBE_SIZE-pe.EDGE_SECTION_SIZE,pe.CUBE_SIZE-pe.EDGE_SECTION_SIZE,pe.FACE_THICKNESS),i=new C.MeshStandardMaterial({color:pe.FACE_COLOR}),a=new C.Mesh(o,i);a.name=`Face Box ${r}`,n.add(a);const c=new C.PlaneGeometry(pe.CUBE_SIZE-pe.EDGE_SECTION_SIZE,pe.CUBE_SIZE-pe.EDGE_SECTION_SIZE),u=new C.MeshStandardMaterial({map:Sh.createTextTexture(r),transparent:!0,depthWrite:!1}),d=new C.Mesh(c,u);return d.position.set(0,0,pe.FACE_THICKNESS/2+.01),n.add(d),n.position.copy(e),n.rotation.copy(t),n}}const Ah=(s,e)=>{const t=document.createElement("canvas");t.width=64,t.height=64;const r=t.getContext("2d");r.fillStyle="rgba(0, 0, 0, 0)",r.fillRect(0,0,t.width,t.height),r.font="Bold 48px Arial",r.fillStyle=`#${e.toString(16).padStart(6,"0")}`,r.textAlign="center",r.textBaseline="middle",r.fillText(s,t.width/2,t.height/2);const n=new C.CanvasTexture(t),o=new C.SpriteMaterial({map:n}),i=new C.Sprite(o);return i.scale.set(.5,.5,.5),i};class Mh{constructor(e){this.hoveredObject=null,this.originalColor=null,this.config=e}get vectorToCube(){var e;return(e=this.hoveredObject)==null?void 0:e.userData.vectorToCube}getInitialRotation(){switch(this.config.initialFace){case jt.BACK:return new C.Euler(0,Math.PI,0);case jt.RIGHT:return new C.Euler(0,-Math.PI/2,0);case jt.LEFT:return new C.Euler(0,Math.PI/2,0);case jt.TOP:return new C.Euler(Math.PI/2,0,0);case jt.BOTTOM:return new C.Euler(-Math.PI/2,0,0);case jt.FRONT:default:return new C.Euler(0,0,0)}}createWireframe(){const e=pe.CUBE_SIZE+pe.EDGE_SECTION_SIZE,t=jn.createWireframe([e,e,e]);return t.userData.gizmoCube=this,t}createEdgeBox(e,t,r){const n=jn.createEdgeBox(e,t,r);return n.userData.gizmoCube=this,n}createCornerCube(e,t){const r=jn.createCornerCube(e,t);return r.userData.gizmoCube=this,r}createFace(e,t,r){const n=jn.createFace(e,t,r),o=n.getObjectByName(`Face Box ${r}`);return o.userData.gizmoCube=this,n}createEdges(e){const t=pe.CUBE_SIZE/2;[{axis:"x",pos:new C.Vector3(0,t,-t)},{axis:"x",pos:new C.Vector3(0,t,t)},{axis:"x",pos:new C.Vector3(0,-t,-t)},{axis:"x",pos:new C.Vector3(0,-t,t)},{axis:"y",pos:new C.Vector3(t,0,-t)},{axis:"y",pos:new C.Vector3(t,0,t)},{axis:"y",pos:new C.Vector3(-t,0,-t)},{axis:"y",pos:new C.Vector3(-t,0,t)},{axis:"z",pos:new C.Vector3(t,t,0)},{axis:"z",pos:new C.Vector3(t,-t,0)},{axis:"z",pos:new C.Vector3(-t,t,0)},{axis:"z",pos:new C.Vector3(-t,-t,0)}].forEach(({axis:r,pos:n},o)=>{const i=this.createEdgeBox(n,r,o+1);e.add(i)})}createCorners(e){const t=pe.CUBE_SIZE/2;[new C.Vector3(-t,-t,-t),new C.Vector3(-t,-t,t),new C.Vector3(-t,t,-t),new C.Vector3(-t,t,t),new C.Vector3(t,-t,-t),new C.Vector3(t,-t,t),new C.Vector3(t,t,-t),new C.Vector3(t,t,t)].forEach((r,n)=>{const o=this.createCornerCube(r,n+1);e.add(o)})}createFaces(e){const t=pe.CUBE_SIZE/2;[{pos:new C.Vector3(0,0,t),rotation:new C.Euler(0,0,0),label:"FRONT"},{pos:new C.Vector3(0,0,-t),rotation:new C.Euler(0,Math.PI,0),label:"BACK"},{pos:new C.Vector3(t,0,0),rotation:new C.Euler(0,Math.PI/2,0),label:"RIGHT"},{pos:new C.Vector3(-t,0,0),rotation:new C.Euler(0,-Math.PI/2,0),label:"LEFT"},{pos:new C.Vector3(0,t,0),rotation:new C.Euler(-Math.PI/2,0,0),label:"TOP"},{pos:new C.Vector3(0,-t,0),rotation:new C.Euler(Math.PI/2,0,0),label:"BOTTOM"}].forEach(({pos:r,rotation:n,label:o})=>{const i=this.createFace(r,n,o);e.add(i)})}createAxis(e){const{color:t,direction:r,length:n,origin:o,lineWidth:i,label:a}=e,c=new C.Group,u=i/2,d=new C.CylinderGeometry(u,u,n,32),h=new C.MeshBasicMaterial({color:t}),l=new C.Mesh(d,h);if(l.position.copy(o).add(r.clone().multiplyScalar(n/2)),!r.equals(new C.Vector3(0,1,0))){const b=new C.Vector3(0,1,0).cross(r).normalize(),T=Math.acos(new C.Vector3(0,1,0).dot(r));l.setRotationFromAxisAngle(b,T)}c.add(l);const v=Ah(a,t);return v.position.copy(o).add(r.clone().multiplyScalar(n+.1)),c.add(v),c}createCoordinateAxes(){const e=new C.Group,t=pe.CUBE_SIZE,r=pe.EDGE_SECTION_SIZE,n=-1.075,o=a=>{const c=new C.Vector3(1,1,1);return new C.Vector3(a,a,a).add(c.clone().normalize().negate().multiplyScalar(.04))},i=t+1.25*r;return[{color:16711680,direction:new C.Vector3(1,0,0),length:i,origin:o(n),lineWidth:.04,label:"X"},{color:65280,direction:new C.Vector3(0,1,0),length:i,origin:o(n),lineWidth:.04,label:"Y"},{color:255,direction:new C.Vector3(0,0,1),length:i,origin:o(n),lineWidth:.04,label:"Z"}].forEach(a=>{const c=this.createAxis(a);e.add(c)}),e}create(){const e=new C.Group;e.name="Gizmo Group";const t=this.createWireframe();e.add(t),this.createEdges(e),this.createCorners(e),this.createFaces(e);const r=this.createCoordinateAxes();e.add(r);const n=this.getInitialRotation();return e.setRotationFromEuler(n),e}highlightObject(e){if(this.hoveredObject!==e)if(this.hoveredObject&&this.originalColor&&this.hoveredObject.material.color.set(this.originalColor),e&&e instanceof C.Mesh){const t=e.material;this.hoveredObject=e,this.originalColor=t.color.clone(),t.color.set(11519973)}else this.hoveredObject=null,this.originalColor=null}handleClick(){if(this.hoveredObject){let e=new C.Vector3;e=this.hoveredObject.getWorldPosition(e).clone();const t=new C.Vector3(0,0,0),r=e.sub(t).normalize();this.hoveredObject.userData.vectorToCube=r}}}class Ih{constructor(e){this.onChangeMainControlsListener=()=>{},this.onChangeGizmoControlsListener=()=>{},this.animationId=0;const{gizmoParams:t,mainParams:r,syncFunctions:n,options:o}=e;this.gizmoDiv=t.gizmoDiv,this.gizmoScene=t.gizmoScene,this.gizmoRenderer=t.gizmoRenderer,this.gizmoCamera=t.gizmoCamera,this.mainCamera=r.mainCamera,this.mainControls=r.mainControls,this.renderGizmo=r.renderGizmo,this.syncFunctions=n,this.options=o,this.gizmoControls=new uh(this.gizmoCamera,this.gizmoRenderer.domElement),this.initializeRenderer(),this.initializeScene(),this.initializeControls(),this.startAnimationLoop()}initializeRenderer(){this.gizmoRenderer.setPixelRatio(window.devicePixelRatio),this.gizmoRenderer.setSize(this.gizmoDiv.clientWidth,this.gizmoDiv.clientHeight),this.gizmoDiv.appendChild(this.gizmoRenderer.domElement)}initializeScene(){var e;const t=new Mh({initialFace:((e=this.options)==null?void 0:e.initialFace)??jt.FRONT}).create();t&&this.gizmoScene.add(t),Th(this.gizmoScene)}initializeControls(){this.onChangeMainControlsListener=()=>this.syncFunctions.syncGizmoCameraWithMain(this.gizmoCamera,this.mainCamera),this.mainControls.addEventListener("change",this.onChangeMainControlsListener),this.gizmoControls.enableZoom=!1,this.gizmoControls.enablePan=!1,this.gizmoControls.rotateSpeed=.5,this.gizmoControls.update(),this.onChangeGizmoControlsListener=()=>{this.syncFunctions.syncMainCameraWithGizmo(this.mainCamera,this.gizmoCamera,this.mainControls),this.renderGizmo()},this.gizmoControls.addEventListener("change",this.onChangeGizmoControlsListener)}startAnimationLoop(){const e=()=>{this.gizmoRenderer.render(this.gizmoScene,this.gizmoCamera)},t=()=>{this.animationId=requestAnimationFrame(t),e()};t()}dispose(){this.mainControls.removeEventListener("change",this.onChangeMainControlsListener),this.gizmoControls.removeEventListener("change",this.onChangeGizmoControlsListener),this.gizmoScene.clear(),cancelAnimationFrame(this.animationId)}}const Ch=(s,e)=>{let t;return function(...r){t||(s.apply(this,r),t=!0,setTimeout(()=>t=!1,e))}};function xo(s,e,t){if(!e)return;const r=e.domElement.getBoundingClientRect();t.x=(s.clientX-r.left)/r.width*2-1,t.y=-((s.clientY-r.top)/r.height)*2+1}function wo(s,e,t,r){var n;if(!e||!t)return null;r.setFromCamera(s,e);const o=r.intersectObjects(t.children,!0),i=["Wireframe",""];return((n=o.find(a=>!i.includes(a.object.name)))==null?void 0:n.object)||null}function Ph(s,e){const t=s==null?void 0:s.userData.gizmoCube;if(s&&t){t.handleClick();const r=t.vectorToCube;r&&e(r)}}const Dh=25,Rh=200;function Fh({gizmoRenderer:s,gizmoScene:e,gizmoCamera:t,alignCameraWithVector:r,gizmoControlRef:n}){const o=ae.useRef(null),i=ae.useRef(null),a=ae.useRef(new C.Raycaster).current,c=ae.useRef(new C.Vector2).current,u=ae.useCallback(Ch(l=>{if(!n.current||!s)return;xo(l,s,c);const v=wo(c,t,e,a);v!=null&&v.userData.gizmoCube?v.userData.gizmoCube.highlightObject(v):e.traverse(b=>{b.userData.gizmoCube&&b.userData.gizmoCube.highlightObject(null)})},1e3/Dh),[n,s,t,e,a,c]),d=ae.useCallback(l=>{o.current=Date.now(),i.current={x:l.clientX,y:l.clientY}},[]),h=ae.useCallback(l=>{if((o.current?Date.now()-o.current:0)<Rh){xo(l,s,c);const v=wo(c,t,e,a);Ph(v,r)}o.current=null,i.current=null},[r,s,t,e,a,c]);return{onMouseDown:d,onMouseMove:u,onMouseUp:h}}const Oh=({camera:s,controls:e,className:t,render:r,options:n})=>{const o=ae.useRef(null),i=ae.useRef(new C.Scene).current,[a]=ae.useState(()=>ch()),c=30,u=1,d=.1,h=10,l=new C.PerspectiveCamera(c,u,d,h),v=ae.useRef(l).current,b=ae.useRef(null),T=ae.useCallback(()=>{a&&(r(),a.render(i,v))},[r,a,i,v]),g=ae.useCallback(A=>{if(!s||!e)return;const P=s.position.length(),D=A.clone().multiplyScalar(P);sh(s,e,s.position.clone(),D,400,T),s.lookAt(new C.Vector3(0,0,0)),s.up.set(0,1,0),e.target.set(0,0,0)},[s,e,T]),{onMouseDown:x,onMouseMove:w,onMouseUp:S}=Fh({gizmoRenderer:a,gizmoScene:i,gizmoCamera:v,alignCameraWithVector:g,gizmoControlRef:b});return ae.useEffect(()=>{const A=o.current;if(!A||!s||!e||!a)return;b.current&&b.current.dispose();const P={gizmoDiv:A,gizmoScene:i,gizmoRenderer:a,gizmoCamera:v},D={mainCamera:s,mainControls:e,renderGizmo:T},F={syncGizmoCameraWithMain:go,syncMainCameraWithGizmo:oh};return b.current=new Ih({gizmoParams:P,mainParams:D,syncFunctions:F,options:n}),A.addEventListener("mousedown",x),A.addEventListener("mousemove",w),A.addEventListener("mouseup",S),()=>{b.current&&(b.current.dispose(),b.current=null),A.removeEventListener("mousedown",x),A.removeEventListener("mousemove",w),A.removeEventListener("mouseup",S)}},[s,e,T,w,x,S]),ae.useEffect(()=>{s&&(go(v,s),T())},[s,T]),ih.jsx("div",{className:t?`${t}`:"gizmo-default",ref:o})},Lh=({camera:s,controls:e,render:t,placement:r="top-right",size:n=128})=>{const o=ae.useRef(null);if(ae.useEffect(()=>{if(!o.current)return;const a=o.current;a.style.position="absolute",a.style.width=`${n}px`,a.style.height=`${n}px`,a.style.zIndex="1000",a.style.top="auto",a.style.bottom="auto",a.style.left="auto",a.style.right="auto";const c="10px";switch(r){case"top-left":a.style.top=c,a.style.left=c;break;case"top-right":a.style.top=c,a.style.right=c;break;case"bottom-left":a.style.bottom=c,a.style.left=c;break;case"bottom-right":a.style.bottom=c,a.style.right=c;break}},[r,n]),!s||!e)return null;const i=e;return qe.jsx("div",{ref:o,className:"viewer-gizmo-container",children:qe.jsx(Oh,{camera:s,controls:i,render:t})})};class Nh extends ae.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("ViewerErrorBoundary caught error:",e,t)}render(){var e;return this.state.hasError?this.props.fallback?this.props.fallback:qe.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f0f0",color:"#333",fontFamily:"sans-serif",padding:"20px",textAlign:"center"},children:qe.jsxs("div",{children:[qe.jsx("h3",{children:"Error Loading 3D Viewer"}),qe.jsx("p",{children:((e=this.state.error)==null?void 0:e.message)||"An unexpected error occurred"})]})}):this.props.children}}class _o{static toThreeObject(e){if("getThreeObject"in e&&typeof e.getThreeObject=="function")return e.getThreeObject();if(e instanceof C.Object3D)return e;const t=new C.Object3D;return t.position.set(e.position.x,e.position.y,e.position.z),t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),t.scale.set(e.scale.x,e.scale.y,e.scale.z),t}static toThreeCamera(e){return"getThreeCamera"in e&&typeof e.getThreeCamera=="function"?e.getThreeCamera():e instanceof C.Camera?e:new C.PerspectiveCamera}static toThreeControls(e){return"getThreeControls"in e&&typeof e.getThreeControls=="function"?e.getThreeControls():e}static convertModelLoaded(e){return{model:this.toThreeObject(e.model),loadTime:e.loadTime}}static convertControlsChange(e){return{type:e.type,camera:e.camera?this.toThreeCamera(e.camera):void 0,controls:e.controls?this.toThreeControls(e.controls):void 0}}static convertObjectSelected(e){return{object:this.toThreeObject(e.object)}}static convertInitialized(e,t){return{viewer:t}}static convertDisposed(e,t){return{viewer:t}}}const To=ae.forwardRef(({object:s,options:e={}},t)=>{var A,P;const r=ae.useRef(null),{viewer:n,isInitialized:o}=Qu(r,e),i=ae.useRef(new fn),a=ae.useRef(void 0),c=ae.useMemo(()=>{if(typeof s=="string")return s;if(s)return`object-${s.uuid||"no-uuid"}`},[s]);ae.useMemo(()=>{a.current=s},[c,s]),ae.useEffect(()=>{if(!n||!o||!a.current)return;const D=typeof a.current=="string"?a.current:new We(a.current);n.loadModel(D).then(F=>{F.ok||console.error("Failed to load model:",F.error)})},[n,o,c]);const u=ae.useMemo(()=>({"model:loaded":D=>i.current.emit("model:loaded",_o.convertModelLoaded(D)),"model:error":D=>i.current.emit("model:error",D),"render:complete":D=>i.current.emit("render:complete",D),"controls:change":D=>i.current.emit("controls:change",_o.convertControlsChange(D)),error:D=>i.current.emit("error",D)}),[]);Ju(n,u);const d=ae.useCallback(D=>{if(D&&typeof D=="object"){const F=D;if(typeof F.getThreeScene=="function")return F.getThreeScene()}return null},[]),h=ae.useCallback(D=>{if(D&&typeof D=="object"){const F=D;if(typeof F.getThreeCamera=="function")return F.getThreeCamera()}return null},[]),l=ae.useCallback(D=>{if(D&&typeof D=="object"){const F=D;if(typeof F.getThreeRenderer=="function")return F.getThreeRenderer()}return null},[]),v=ae.useCallback(D=>{if(D&&typeof D=="object"){const F=D;if(typeof F.getThreeControls=="function")return F.getThreeControls()}return null},[]),b=n?h(n.camera):null,T=n?v(n.controls):null,g=n?l(n.renderer):null,x=ae.useCallback(()=>{if(g&&n){const D=n;D.renderLoopManager&&typeof D.renderLoopManager.requestRender=="function"&&D.renderLoopManager.requestRender()}},[n,g]),w=((A=e.helpers)==null?void 0:A.gizmo)!==void 0&&e.helpers.gizmo!==!1,S=typeof((P=e.helpers)==null?void 0:P.gizmo)=="object"?e.helpers.gizmo:{};return ae.useImperativeHandle(t,()=>({scene:n?d(n.scene):null,camera:b,renderer:g,controls:T,events:i.current}),[n,b,g,T,d]),qe.jsx(Nh,{children:qe.jsx(Hu,{viewer:n,canvasRef:r,children:qe.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[qe.jsx(th,{}),w&&o&&b&&T&&qe.jsx(Lh,{camera:b,controls:T,render:x,placement:S.placement,size:S.size})]})})})});To.displayName="SimpleViewer";const So=ae.forwardRef((s,e)=>qe.jsx(To,{ref:e,...s}));So.displayName="SimpleViewer",wt.SimpleViewer=So,wt.TypedEventEmitter=fn,wt.defaultOptions=ho,Object.defineProperty(wt,Symbol.toStringTag,{value:"Module"})});
|