@quick-threejs/reactive 0.1.41 → 0.1.42
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/dist/{FontLoader-Cp39O036.mjs → FontLoader-Dz0z8aMc.mjs} +41 -8
- package/dist/common/blueprints/props.blueprint.d.ts +9 -1
- package/dist/common/interfaces/core.interface.d.ts +2 -1
- package/dist/core/app/app.module.d.ts +2 -2
- package/dist/core/app/app.service.d.ts +2 -2
- package/dist/core/app/sizes/sizes.module.d.ts +1 -1
- package/dist/core/app/sizes/sizes.service.d.ts +1 -1
- package/dist/core/register/register.module.d.ts +7 -5
- package/dist/core/register/register.service.d.ts +2 -2
- package/dist/main.js +4 -4
- package/dist/main.mjs +823 -671
- package/dist/worker.js +1 -1
- package/dist/worker.mjs +351 -298
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ft=Object.defineProperty;var ht=(s,e,t)=>e in s?ft(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var L=(s,e,t)=>ht(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./FontLoader-DvGzwRip.js"),h=require("three");class se{constructor(){L(this,"location");L(this,"initOnConstruct");L(this,"canvas");L(this,"fullScreen");L(this,"defaultCamera");L(this,"startTimer");L(this,"loaderDataSources",[]);L(this,"loaderDracoDecoderPath");L(this,"loadResourcesOnInit");L(this,"enableDebug");L(this,"enableControls");L(this,"axesSizes");L(this,"gridSizes");L(this,"withMiniCamera");L(this,"onReady")}}class pt{constructor(){L(this,"onReady")}}var K={},ge={},N={},z={},Ne;function mt(){if(Ne)return z;Ne=1,Object.defineProperty(z,"__esModule",{value:!0}),z.getBundleURL=z.getBaseURL=void 0;let s;function e(){return s||(s=t()),s}z.getBundleURL=e;function t(){try{throw new Error}catch(r){const o=(""+r.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);if(o)return n(o[0])}return"/"}function n(r){return(""+r).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)?\/[^/]+(?:\?.*)?$/,"$1")+"/"}return z.getBaseURL=n,z}var De;function nt(){if(De)return N;De=1,Object.defineProperty(N,"__esModule",{value:!0}),N.isWorkerRuntime=N.getWorkerImplementation=N.defaultPoolSize=void 0;const s=mt();N.defaultPoolSize=typeof navigator<"u"&&navigator.hardwareConcurrency?navigator.hardwareConcurrency:4;const e=a=>/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a);function t(a){const c=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(c)}function n(){if(typeof Worker>"u")return class{constructor(){throw Error("No web worker implementation available. You might have tried to spawn a worker within a worker in a browser that doesn't support workers in workers.")}};class a extends Worker{constructor(u,l){var f,p;typeof u=="string"&&l&&l._baseURL?u=new URL(u,l._baseURL):typeof u=="string"&&!e(u)&&s.getBundleURL().match(/^file:\/\//i)&&(u=new URL(u,s.getBundleURL().replace(/\/[^\/]+$/,"/")),(!((f=l==null?void 0:l.CORSWorkaround)!==null&&f!==void 0)||f)&&(u=t(`importScripts(${JSON.stringify(u)});`))),typeof u=="string"&&e(u)&&(!((p=l==null?void 0:l.CORSWorkaround)!==null&&p!==void 0)||p)&&(u=t(`importScripts(${JSON.stringify(u)});`)),super(u,l)}}class c extends a{constructor(u,l){const f=window.URL.createObjectURL(u);super(f,l)}static fromText(u,l){const f=new window.Blob([u],{type:"text/javascript"});return new c(f,l)}}return{blob:c,default:a}}let r;function o(){return r||(r=n()),r}N.getWorkerImplementation=o;function i(){const a=typeof self<"u"&&typeof Window<"u"&&self instanceof Window;return!!(typeof self<"u"&&self.postMessage&&!a)}return N.isWorkerRuntime=i,N}var q={},oe={exports:{}},_e,Fe;function gt(){if(Fe)return _e;Fe=1;var s=1e3,e=s*60,t=e*60,n=t*24,r=n*7,o=n*365.25;_e=function(u,l){l=l||{};var f=typeof u;if(f==="string"&&u.length>0)return i(u);if(f==="number"&&isFinite(u))return l.long?c(u):a(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function i(u){if(u=String(u),!(u.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(l){var f=parseFloat(l[1]),p=(l[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return f*o;case"weeks":case"week":case"w":return f*r;case"days":case"day":case"d":return f*n;case"hours":case"hour":case"hrs":case"hr":case"h":return f*t;case"minutes":case"minute":case"mins":case"min":case"m":return f*e;case"seconds":case"second":case"secs":case"sec":case"s":return f*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function a(u){var l=Math.abs(u);return l>=n?Math.round(u/n)+"d":l>=t?Math.round(u/t)+"h":l>=e?Math.round(u/e)+"m":l>=s?Math.round(u/s)+"s":u+"ms"}function c(u){var l=Math.abs(u);return l>=n?d(u,l,n,"day"):l>=t?d(u,l,t,"hour"):l>=e?d(u,l,e,"minute"):l>=s?d(u,l,s,"second"):u+" ms"}function d(u,l,f,p){var A=l>=f*1.5;return Math.round(u/f)+" "+p+(A?"s":"")}return _e}var ye,je;function _t(){if(je)return ye;je=1;function s(e){n.debug=n,n.default=n,n.coerce=d,n.disable=i,n.enable=o,n.enabled=a,n.humanize=gt(),n.destroy=u,Object.keys(e).forEach(l=>{n[l]=e[l]}),n.names=[],n.skips=[],n.formatters={};function t(l){let f=0;for(let p=0;p<l.length;p++)f=(f<<5)-f+l.charCodeAt(p),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=t;function n(l){let f,p=null,A,R;function v(...m){if(!v.enabled)return;const g=v,_=Number(new Date),b=_-(f||_);g.diff=b,g.prev=f,g.curr=_,f=_,m[0]=n.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let T=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(E,x)=>{if(E==="%%")return"%";T++;const C=n.formatters[x];if(typeof C=="function"){const M=m[T];E=C.call(g,M),m.splice(T,1),T--}return E}),n.formatArgs.call(g,m),(g.log||n.log).apply(g,m)}return v.namespace=l,v.useColors=n.useColors(),v.color=n.selectColor(l),v.extend=r,v.destroy=n.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(A!==n.namespaces&&(A=n.namespaces,R=n.enabled(l)),R),set:m=>{p=m}}),typeof n.init=="function"&&n.init(v),v}function r(l,f){const p=n(this.namespace+(typeof f>"u"?":":f)+l);return p.log=this.log,p}function o(l){n.save(l),n.namespaces=l,n.names=[],n.skips=[];let f;const p=(typeof l=="string"?l:"").split(/[\s,]+/),A=p.length;for(f=0;f<A;f++)p[f]&&(l=p[f].replace(/\*/g,".*?"),l[0]==="-"?n.skips.push(new RegExp("^"+l.slice(1)+"$")):n.names.push(new RegExp("^"+l+"$")))}function i(){const l=[...n.names.map(c),...n.skips.map(c).map(f=>"-"+f)].join(",");return n.enable(""),l}function a(l){if(l[l.length-1]==="*")return!0;let f,p;for(f=0,p=n.skips.length;f<p;f++)if(n.skips[f].test(l))return!1;for(f=0,p=n.names.length;f<p;f++)if(n.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function d(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}return ye=s,ye}var Be;function Oe(){return Be||(Be=1,function(s,e){e.formatArgs=n,e.save=r,e.load=o,e.useColors=t,e.storage=i(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+s.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;c.splice(1,0,d,"color: inherit");let u=0,l=0;c[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&(u++,f==="%c"&&(l=u))}),c.splice(l,0,d)}e.log=console.debug||console.log||(()=>{});function r(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function o(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function i(){try{return localStorage}catch{}}s.exports=_t()(e);const{formatters:a}=s.exports;a.j=function(c){try{return JSON.stringify(c)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}}(oe,oe.exports)),oe.exports}var yt=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})};class fe{constructor(e){this._baseObserver=e,this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then(()=>this._baseObserver.complete()).catch(e=>this._baseObserver.error(e))}error(e){this._baseObserver.error(e)}schedule(e){const t=Promise.all(this._pendingPromises),n=[],r=i=>n.push(i),o=Promise.resolve().then(()=>yt(this,void 0,void 0,function*(){yield t,yield e(r),this._pendingPromises.delete(o);for(const i of n)this._baseObserver.next(i)})).catch(i=>{this._pendingPromises.delete(o),this._baseObserver.error(i)});this._pendingPromises.add(o)}}const rt=()=>typeof Symbol=="function",ie=s=>rt()&&!!Symbol[s],Ie=s=>ie(s)?Symbol[s]:"@@"+s;ie("asyncIterator")||(Symbol.asyncIterator=Symbol.asyncIterator||Symbol.for("Symbol.asyncIterator"));const bt=Ie("iterator"),Se=Ie("observable"),st=Ie("species");function ce(s,e){const t=s[e];if(t!=null){if(typeof t!="function")throw new TypeError(t+" is not a function");return t}}function J(s){let e=s.constructor;return e!==void 0&&(e=e[st],e===null&&(e=void 0)),e!==void 0?e:P}function Tt(s){return s instanceof P}function Y(s){Y.log?Y.log(s):setTimeout(()=>{throw s},0)}function ae(s){Promise.resolve().then(()=>{try{s()}catch(e){Y(e)}})}function it(s){const e=s._cleanup;if(e!==void 0&&(s._cleanup=void 0,!!e))try{if(typeof e=="function")e();else{const t=ce(e,"unsubscribe");t&&t.call(e)}}catch(t){Y(t)}}function xe(s){s._observer=void 0,s._queue=void 0,s._state="closed"}function wt(s){const e=s._queue;if(e){s._queue=void 0,s._state="ready";for(const t of e)if(ot(s,t.type,t.value),s._state==="closed")break}}function ot(s,e,t){s._state="running";const n=s._observer;try{const r=n?ce(n,e):void 0;switch(e){case"next":r&&r.call(n,t);break;case"error":if(xe(s),r)r.call(n,t);else throw t;break;case"complete":xe(s),r&&r.call(n);break}}catch(r){Y(r)}s._state==="closed"?it(s):s._state==="running"&&(s._state="ready")}function be(s,e,t){if(s._state!=="closed"){if(s._state==="buffering"){s._queue=s._queue||[],s._queue.push({type:e,value:t});return}if(s._state!=="ready"){s._state="buffering",s._queue=[{type:e,value:t}],ae(()=>wt(s));return}ot(s,e,t)}}class vt{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";const n=new At(this);try{this._cleanup=t.call(void 0,n)}catch(r){n.error(r)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(xe(this),it(this))}}class At{constructor(e){this._subscription=e}get closed(){return this._subscription._state==="closed"}next(e){be(this._subscription,"next",e)}error(e){be(this._subscription,"error",e)}complete(){be(this._subscription,"complete")}}class P{constructor(e){if(!(this instanceof P))throw new TypeError("Observable cannot be called as a function");if(typeof e!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e,t,n){return(typeof e!="object"||e===null)&&(e={next:e,error:t,complete:n}),new vt(e,this._subscriber)}pipe(e,...t){let n=this;for(const r of[e,...t])n=r(n);return n}tap(e,t,n){const r=typeof e!="object"||e===null?{next:e,error:t,complete:n}:e;return new P(o=>this.subscribe({next(i){r.next&&r.next(i),o.next(i)},error(i){r.error&&r.error(i),o.error(i)},complete(){r.complete&&r.complete(),o.complete()},start(i){r.start&&r.start(i)}}))}forEach(e){return new Promise((t,n)=>{if(typeof e!="function"){n(new TypeError(e+" is not a function"));return}function r(){o.unsubscribe(),t(void 0)}const o=this.subscribe({next(i){try{e(i,r)}catch(a){n(a),o.unsubscribe()}},error(i){n(i)},complete(){t(void 0)}})})}map(e){if(typeof e!="function")throw new TypeError(e+" is not a function");const t=J(this);return new t(n=>this.subscribe({next(r){let o=r;try{o=e(r)}catch(i){return n.error(i)}n.next(o)},error(r){n.error(r)},complete(){n.complete()}}))}filter(e){if(typeof e!="function")throw new TypeError(e+" is not a function");const t=J(this);return new t(n=>this.subscribe({next(r){try{if(!e(r))return}catch(o){return n.error(o)}n.next(r)},error(r){n.error(r)},complete(){n.complete()}}))}reduce(e,t){if(typeof e!="function")throw new TypeError(e+" is not a function");const n=J(this),r=arguments.length>1;let o=!1,i=t;return new n(a=>this.subscribe({next(c){const d=!o;if(o=!0,!d||r)try{i=e(i,c)}catch(u){return a.error(u)}else i=c},error(c){a.error(c)},complete(){if(!o&&!r)return a.error(new TypeError("Cannot reduce an empty sequence"));a.next(i),a.complete()}}))}concat(...e){const t=J(this);return new t(n=>{let r,o=0;function i(a){r=a.subscribe({next(c){n.next(c)},error(c){n.error(c)},complete(){o===e.length?(r=void 0,n.complete()):i(t.from(e[o++]))}})}return i(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(e){if(typeof e!="function")throw new TypeError(e+" is not a function");const t=J(this);return new t(n=>{const r=[],o=this.subscribe({next(a){let c;if(e)try{c=e(a)}catch(u){return n.error(u)}else c=a;const d=t.from(c).subscribe({next(u){n.next(u)},error(u){n.error(u)},complete(){const u=r.indexOf(d);u>=0&&r.splice(u,1),i()}});r.push(d)},error(a){n.error(a)},complete(){i()}});function i(){o.closed&&r.length===0&&n.complete()}return()=>{r.forEach(a=>a.unsubscribe()),o.unsubscribe()}})}[Se](){return this}static from(e){const t=typeof this=="function"?this:P;if(e==null)throw new TypeError(e+" is not an object");const n=ce(e,Se);if(n){const r=n.call(e);if(Object(r)!==r)throw new TypeError(r+" is not an object");return Tt(r)&&r.constructor===t?r:new t(o=>r.subscribe(o))}if(ie("iterator")){const r=ce(e,bt);if(r)return new t(o=>{ae(()=>{if(!o.closed){for(const i of r.call(e))if(o.next(i),o.closed)return;o.complete()}})})}if(Array.isArray(e))return new t(r=>{ae(()=>{if(!r.closed){for(const o of e)if(r.next(o),r.closed)return;r.complete()}})});throw new TypeError(e+" is not observable")}static of(...e){const t=typeof this=="function"?this:P;return new t(n=>{ae(()=>{if(!n.closed){for(const r of e)if(n.next(r),n.closed)return;n.complete()}})})}static get[st](){return this}}rt()&&Object.defineProperty(P,Symbol("extensions"),{value:{symbol:Se,hostReportError:Y},configurable:!0});function $(s){typeof s=="function"?s():s&&typeof s.unsubscribe=="function"&&s.unsubscribe()}var Et=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})};function Rt(s){return e=>new P(t=>{const n=new fe(t),r=e.subscribe({complete(){n.complete()},error(o){n.error(o)},next(o){n.schedule(i=>Et(this,void 0,void 0,function*(){(yield s(o))&&i(o)}))}});return()=>$(r)})}function Ct(s){return s&&ie("asyncIterator")&&s[Symbol.asyncIterator]}function St(s){return s&&ie("iterator")&&s[Symbol.iterator]}var xt=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})},Lt=function(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof __values=="function"?__values(s):s[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=s[o]&&function(i){return new Promise(function(a,c){i=s[o](i),r(a,c,i.done,i.value)})}}function r(o,i,a,c){Promise.resolve(c).then(function(d){o({value:d,done:a})},i)}};function Mt(s){return e=>new P(t=>{const n=new fe(t),r=e.subscribe({complete(){n.complete()},error(o){n.error(o)},next(o){n.schedule(i=>xt(this,void 0,void 0,function*(){var a,c;const d=yield s(o);if(St(d)||Ct(d))try{for(var u=Lt(d),l;l=yield u.next(),!l.done;){const f=l.value;i(f)}}catch(f){a={error:f}}finally{try{l&&!l.done&&(c=u.return)&&(yield c.call(u))}finally{if(a)throw a.error}}else d.map(f=>i(f))}))}});return()=>$(r)})}function kt(s){return new P(e=>{let t=0;const n=setInterval(()=>{e.next(t++)},s);return()=>clearInterval(n)})}var Pt=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})};function Ot(s){return e=>new P(t=>{const n=new fe(t),r=e.subscribe({complete(){n.complete()},error(o){n.error(o)},next(o){n.schedule(i=>Pt(this,void 0,void 0,function*(){const a=yield s(o);i(a)}))}});return()=>$(r)})}function It(...s){return s.length===0?P.from([]):new P(e=>{let t=0;const n=s.map(o=>o.subscribe({error(i){e.error(i),r()},next(i){e.next(i)},complete(){++t===s.length&&(e.complete(),r())}})),r=()=>{n.forEach(o=>$(o))};return r})}class at extends P{constructor(){super(e=>(this._observers.add(e),()=>this._observers.delete(e))),this._observers=new Set}next(e){for(const t of this._observers)t.next(e)}error(e){for(const t of this._observers)t.error(e)}complete(){for(const e of this._observers)e.complete()}}function Nt(s){const e=new at;let t,n=0;return new P(r=>{t||(t=s.subscribe(e));const o=e.subscribe(r);return n++,()=>{n--,o.unsubscribe(),n===0&&($(t),t=void 0)}})}var Dt=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})};function Ft(s,e){return t=>new P(n=>{let r,o=0;const i=new fe(n),a=t.subscribe({complete(){i.complete()},error(c){i.error(c)},next(c){i.schedule(d=>Dt(this,void 0,void 0,function*(){r=yield s(o===0?typeof e>"u"?c:e:r,c,o++),d(r)}))}});return()=>$(a)})}const jt=Object.freeze(Object.defineProperty({__proto__:null,Observable:P,Subject:at,filter:Rt,flatMap:Mt,interval:kt,map:Ot,merge:It,multicast:Nt,scan:Ft,unsubscribe:$},Symbol.toStringTag,{value:"Module"})),he=y.getAugmentedNamespace(jt);var Z={},He;function Bt(){if(He)return Z;He=1,Object.defineProperty(Z,"__esModule",{value:!0}),Z.allSettled=void 0;function s(e){return Promise.all(e.map(t=>{const n=i=>({status:"fulfilled",value:i}),r=i=>({status:"rejected",reason:i}),o=Promise.resolve(t);try{return o.then(n,r)}catch(i){return Promise.reject(i)}}))}return Z.allSettled=s,Z}var Te={},Ue;function Ht(){return Ue||(Ue=1,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.PoolEventType=void 0,function(e){e.initialized="initialized",e.taskCanceled="taskCanceled",e.taskCompleted="taskCompleted",e.taskFailed="taskFailed",e.taskQueued="taskQueued",e.taskQueueDrained="taskQueueDrained",e.taskStart="taskStart",e.terminated="terminated"}(s.PoolEventType||(s.PoolEventType={}))}(Te)),Te}var ee={},Ge;function ct(){if(Ge)return ee;Ge=1,Object.defineProperty(ee,"__esModule",{value:!0}),ee.Thread=void 0;const s=y.requireSymbols();function e(t){throw Error(t)}return ee.Thread={errors(t){return t[s.$errors]||e("Error observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},events(t){return t[s.$events]||e("Events observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},terminate(t){return t[s.$terminate]()}},ee}var We;function Ut(){return We||(We=1,function(s){var e=q&&q.__awaiter||function(m,g,_,b){function T(w){return w instanceof _?w:new _(function(E){E(w)})}return new(_||(_=Promise))(function(w,E){function x(k){try{M(b.next(k))}catch(I){E(I)}}function C(k){try{M(b.throw(k))}catch(I){E(I)}}function M(k){k.done?w(k.value):T(k.value).then(x,C)}M((b=b.apply(m,g||[])).next())})},t=q&&q.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(s,"__esModule",{value:!0}),s.Pool=s.Thread=s.PoolEventType=void 0;const n=t(Oe()),r=he,o=Bt(),i=nt(),a=Ht();Object.defineProperty(s,"PoolEventType",{enumerable:!0,get:function(){return a.PoolEventType}});const c=ct();Object.defineProperty(s,"Thread",{enumerable:!0,get:function(){return c.Thread}});let d=1;function u(m){const g=[];for(let _=0;_<m;_++)g.push(_);return g}function l(m){return new Promise(g=>setTimeout(g,m))}function f(m,g){return m.reduce((_,b)=>[..._,...g(b)],[])}function p(m){return m.replace(/\W/g," ").trim().replace(/\s+/g,"-")}function A(m,g){return u(g).map(()=>({init:m(),runningTasks:[]}))}class R{constructor(g,_){this.eventSubject=new r.Subject,this.initErrors=[],this.isClosing=!1,this.nextTaskID=1,this.taskQueue=[];const b=typeof _=="number"?{size:_}:_||{},{size:T=i.defaultPoolSize}=b;this.debug=n.default(`threads:pool:${p(b.name||String(d++))}`),this.options=b,this.workers=A(g,T),this.eventObservable=r.multicast(r.Observable.from(this.eventSubject)),Promise.all(this.workers.map(w=>w.init)).then(()=>this.eventSubject.next({type:a.PoolEventType.initialized,size:this.workers.length}),w=>{this.debug("Error while initializing pool worker:",w),this.eventSubject.error(w),this.initErrors.push(w)})}findIdlingWorker(){const{concurrency:g=1}=this.options;return this.workers.find(_=>_.runningTasks.length<g)}runPoolTask(g,_){return e(this,void 0,void 0,function*(){const b=this.workers.indexOf(g)+1;this.debug(`Running task #${_.id} on worker #${b}...`),this.eventSubject.next({type:a.PoolEventType.taskStart,taskID:_.id,workerID:b});try{const T=yield _.run(yield g.init);this.debug(`Task #${_.id} completed successfully`),this.eventSubject.next({type:a.PoolEventType.taskCompleted,returnValue:T,taskID:_.id,workerID:b})}catch(T){this.debug(`Task #${_.id} failed`),this.eventSubject.next({type:a.PoolEventType.taskFailed,taskID:_.id,error:T,workerID:b})}})}run(g,_){return e(this,void 0,void 0,function*(){const b=e(this,void 0,void 0,function*(){const T=()=>{g.runningTasks=g.runningTasks.filter(w=>w!==b)};yield l(0);try{yield this.runPoolTask(g,_)}finally{T(),this.isClosing||this.scheduleWork()}});g.runningTasks.push(b)})}scheduleWork(){this.debug("Attempt de-queueing a task in order to run it...");const g=this.findIdlingWorker();if(!g)return;const _=this.taskQueue.shift();if(!_){this.debug("Task queue is empty"),this.eventSubject.next({type:a.PoolEventType.taskQueueDrained});return}this.run(g,_)}taskCompletion(g){return new Promise((_,b)=>{const T=this.events().subscribe(w=>{w.type===a.PoolEventType.taskCompleted&&w.taskID===g?(T.unsubscribe(),_(w.returnValue)):w.type===a.PoolEventType.taskFailed&&w.taskID===g?(T.unsubscribe(),b(w.error)):w.type===a.PoolEventType.terminated&&(T.unsubscribe(),b(Error("Pool has been terminated before task was run.")))})})}settled(g=!1){return e(this,void 0,void 0,function*(){const _=()=>f(this.workers,w=>w.runningTasks),b=[],T=this.eventObservable.subscribe(w=>{w.type===a.PoolEventType.taskFailed&&b.push(w.error)});return this.initErrors.length>0?Promise.reject(this.initErrors[0]):g&&this.taskQueue.length===0?(yield o.allSettled(_()),b):(yield new Promise((w,E)=>{const x=this.eventObservable.subscribe({next(C){C.type===a.PoolEventType.taskQueueDrained&&(x.unsubscribe(),w(void 0))},error:E})}),yield o.allSettled(_()),T.unsubscribe(),b)})}completed(g=!1){return e(this,void 0,void 0,function*(){const _=this.settled(g),b=new Promise((w,E)=>{const x=this.eventObservable.subscribe({next(C){C.type===a.PoolEventType.taskQueueDrained?(x.unsubscribe(),w(_)):C.type===a.PoolEventType.taskFailed&&(x.unsubscribe(),E(C.error))},error:E})}),T=yield Promise.race([_,b]);if(T.length>0)throw T[0]})}events(){return this.eventObservable}queue(g){const{maxQueuedJobs:_=1/0}=this.options;if(this.isClosing)throw Error("Cannot schedule pool tasks after terminate() has been called.");if(this.initErrors.length>0)throw this.initErrors[0];const b=this.nextTaskID++,T=this.taskCompletion(b);T.catch(E=>{this.debug(`Task #${b} errored:`,E)});const w={id:b,run:g,cancel:()=>{this.taskQueue.indexOf(w)!==-1&&(this.taskQueue=this.taskQueue.filter(E=>E!==w),this.eventSubject.next({type:a.PoolEventType.taskCanceled,taskID:w.id}))},then:T.then.bind(T)};if(this.taskQueue.length>=_)throw Error(`Maximum number of pool tasks queued. Refusing to queue another one.
|
|
2
|
-
This usually happens for one of two reasons: We are either at peak workload right now or some tasks just won't finish, thus blocking the pool.`);return this.debug(`Queueing task #${w.id}...`),this.taskQueue.push(w),this.eventSubject.next({type:a.PoolEventType.taskQueued,taskID:w.id}),this.scheduleWork(),w}terminate(g){return e(this,void 0,void 0,function*(){this.isClosing=!0,g||(yield this.completed(!0)),this.eventSubject.next({type:a.PoolEventType.terminated,remainingQueue:[...this.taskQueue]}),this.eventSubject.complete(),yield Promise.all(this.workers.map(_=>e(this,void 0,void 0,function*(){return c.Thread.terminate(yield _.init)})))})}}R.EventType=a.PoolEventType;function v(m,g){return new R(m,g)}v.EventType=a.PoolEventType,s.Pool=v}(q)),q}var D={},te={},Ke;function Gt(){if(Ke)return te;Ke=1,Object.defineProperty(te,"__esModule",{value:!0}),te.createPromiseWithResolver=void 0;const s=()=>{};function e(){let t=!1,n,r=s;return[new Promise(a=>{t?a(n):r=a}),a=>{t=!0,n=a,r(n)}]}return te.createPromiseWithResolver=e,te}var we={},ze;function Wt(){return ze||(ze=1,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.WorkerEventType=void 0,function(e){e.internalError="internalError",e.message="message",e.termination="termination"}(s.WorkerEventType||(s.WorkerEventType={}))}(we)),we}var F={},ne={},qe;function Kt(){if(qe)return ne;qe=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.ObservablePromise=void 0;const s=he,e=()=>{},t=a=>a,n=a=>Promise.resolve().then(a);function r(a){throw a}function o(a){return a&&typeof a.then=="function"}class i extends s.Observable{constructor(c){super(d=>{const u=this,l=Object.assign(Object.assign({},d),{complete(){d.complete(),u.onCompletion()},error(f){d.error(f),u.onError(f)},next(f){d.next(f),u.onNext(f)}});try{return this.initHasRun=!0,c(l)}catch(f){l.error(f)}}),this.initHasRun=!1,this.fulfillmentCallbacks=[],this.rejectionCallbacks=[],this.firstValueSet=!1,this.state="pending"}onNext(c){this.firstValueSet||(this.firstValue=c,this.firstValueSet=!0)}onError(c){this.state="rejected",this.rejection=c;for(const d of this.rejectionCallbacks)n(()=>d(c))}onCompletion(){this.state="fulfilled";for(const c of this.fulfillmentCallbacks)n(()=>c(this.firstValue))}then(c,d){const u=c||t,l=d||r;let f=!1;return new Promise((p,A)=>{const R=m=>{if(!f){f=!0;try{p(l(m))}catch(g){A(g)}}},v=m=>{try{p(u(m))}catch(g){R(g)}};if(this.initHasRun||this.subscribe({error:R}),this.state==="fulfilled")return p(u(this.firstValue));if(this.state==="rejected")return f=!0,p(l(this.rejection));this.fulfillmentCallbacks.push(v),this.rejectionCallbacks.push(R)})}catch(c){return this.then(void 0,c)}finally(c){const d=c||e;return this.then(u=>(d(),u),()=>d())}static from(c){return o(c)?new i(d=>{const u=f=>{d.next(f),d.complete()},l=f=>{d.error(f)};c.then(u,l)}):super.from(c)}}return ne.ObservablePromise=i,ne}var Ve;function zt(){if(Ve)return F;Ve=1;var s=F&&F.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(F,"__esModule",{value:!0}),F.createProxyModule=F.createProxyFunction=void 0;const e=s(Oe()),t=he,n=y.requireCommon(),r=Kt(),o=y.requireTransferable(),i=y.requireMessages(),a=e.default("threads:master:messages");let c=1;const d=m=>Array.from(new Set(m)),u=m=>m&&m.type===i.WorkerMessageType.error,l=m=>m&&m.type===i.WorkerMessageType.result,f=m=>m&&m.type===i.WorkerMessageType.running;function p(m,g){return new t.Observable(_=>{let b;const T=w=>{if(a("Message from worker:",w.data),!(!w.data||w.data.uid!==g)){if(f(w.data))b=w.data.resultType;else if(l(w.data))b==="promise"?(typeof w.data.payload<"u"&&_.next(n.deserialize(w.data.payload)),_.complete(),m.removeEventListener("message",T)):(w.data.payload&&_.next(n.deserialize(w.data.payload)),w.data.complete&&(_.complete(),m.removeEventListener("message",T)));else if(u(w.data)){const E=n.deserialize(w.data.error);_.error(E),m.removeEventListener("message",T)}}};return m.addEventListener("message",T),()=>{if(b==="observable"||!b){const w={type:i.MasterMessageType.cancel,uid:g};m.postMessage(w)}m.removeEventListener("message",T)}})}function A(m){if(m.length===0)return{args:[],transferables:[]};const g=[],_=[];for(const b of m)o.isTransferDescriptor(b)?(g.push(n.serialize(b.send)),_.push(...b.transferables)):g.push(n.serialize(b));return{args:g,transferables:_.length===0?_:d(_)}}function R(m,g){return(..._)=>{const b=c++,{args:T,transferables:w}=A(_),E={type:i.MasterMessageType.run,uid:b,method:g,args:T};a("Sending command to run function to worker:",E);try{m.postMessage(E,w)}catch(x){return r.ObservablePromise.from(Promise.reject(x))}return r.ObservablePromise.from(t.multicast(p(m,b)))}}F.createProxyFunction=R;function v(m,g){const _={};for(const b of g)_[b]=R(m,b);return _}return F.createProxyModule=v,F}var $e;function qt(){if($e)return D;$e=1;var s=D&&D.__awaiter||function(T,w,E,x){function C(M){return M instanceof E?M:new E(function(k){k(M)})}return new(E||(E=Promise))(function(M,k){function I(W){try{pe(x.next(W))}catch(me){k(me)}}function G(W){try{pe(x.throw(W))}catch(me){k(me)}}function pe(W){W.done?M(W.value):C(W.value).then(I,G)}pe((x=x.apply(T,w||[])).next())})},e=D&&D.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(D,"__esModule",{value:!0}),D.spawn=void 0;const t=e(Oe()),n=he,r=y.requireCommon(),o=Gt(),i=y.requireSymbols(),a=Wt(),c=zt(),d=t.default("threads:master:messages"),u=t.default("threads:master:spawn"),l=t.default("threads:master:thread-utils"),f=T=>T&&T.type==="init",p=T=>T&&T.type==="uncaughtError",A=typeof process<"u"&&process.env.THREADS_WORKER_INIT_TIMEOUT?Number.parseInt(process.env.THREADS_WORKER_INIT_TIMEOUT,10):1e4;function R(T,w,E){return s(this,void 0,void 0,function*(){let x;const C=new Promise((k,I)=>{x=setTimeout(()=>I(Error(E)),w)}),M=yield Promise.race([T,C]);return clearTimeout(x),M})}function v(T){return new Promise((w,E)=>{const x=C=>{d("Message from worker before finishing initialization:",C.data),f(C.data)?(T.removeEventListener("message",x),w(C.data)):p(C.data)&&(T.removeEventListener("message",x),E(r.deserialize(C.data.error)))};T.addEventListener("message",x)})}function m(T,w){return new n.Observable(E=>{const x=M=>{const k={type:a.WorkerEventType.message,data:M.data};E.next(k)},C=M=>{l("Unhandled promise rejection event in thread:",M);const k={type:a.WorkerEventType.internalError,error:Error(M.reason)};E.next(k)};T.addEventListener("message",x),T.addEventListener("unhandledrejection",C),w.then(()=>{const M={type:a.WorkerEventType.termination};T.removeEventListener("message",x),T.removeEventListener("unhandledrejection",C),E.next(M),E.complete()})})}function g(T){const[w,E]=o.createPromiseWithResolver();return{terminate:()=>s(this,void 0,void 0,function*(){l("Terminating worker"),yield T.terminate(),E()}),termination:w}}function _(T,w,E,x){const C=E.filter(M=>M.type===a.WorkerEventType.internalError).map(M=>M.error);return Object.assign(T,{[i.$errors]:C,[i.$events]:E,[i.$terminate]:x,[i.$worker]:w})}function b(T,w){return s(this,void 0,void 0,function*(){u("Initializing new thread");const E=w&&w.timeout?w.timeout:A,C=(yield R(v(T),E,`Timeout: Did not receive an init message from worker after ${E}ms. Make sure the worker calls expose().`)).exposed,{termination:M,terminate:k}=g(T),I=m(T,M);if(C.type==="function"){const G=c.createProxyFunction(T);return _(G,T,I,k)}else if(C.type==="module"){const G=c.createProxyModule(T,C.methods);return _(G,T,I,k)}else{const G=C.type;throw Error(`Worker init message states unexpected type of expose(): ${G}`)}})}return D.spawn=b,D}var Xe;function Vt(){return Xe||(Xe=1,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.Worker=s.BlobWorker=s.isWorkerRuntime=s.Thread=s.spawn=s.Pool=void 0;const e=nt();Object.defineProperty(s,"isWorkerRuntime",{enumerable:!0,get:function(){return e.isWorkerRuntime}});var t=Ut();Object.defineProperty(s,"Pool",{enumerable:!0,get:function(){return t.Pool}});var n=qt();Object.defineProperty(s,"spawn",{enumerable:!0,get:function(){return n.spawn}});var r=ct();Object.defineProperty(s,"Thread",{enumerable:!0,get:function(){return r.Thread}}),s.BlobWorker=e.getWorkerImplementation().blob,s.Worker=e.getWorkerImplementation().default}(ge)),ge}var Qe;function $t(){return Qe||(Qe=1,function(s){var e=K&&K.__createBinding||(Object.create?function(a,c,d,u){u===void 0&&(u=d),Object.defineProperty(a,u,{enumerable:!0,get:function(){return c[d]}})}:function(a,c,d,u){u===void 0&&(u=d),a[u]=c[d]}),t=K&&K.__exportStar||function(a,c){for(var d in a)d!=="default"&&!Object.prototype.hasOwnProperty.call(c,d)&&e(c,a,d)};Object.defineProperty(s,"__esModule",{value:!0}),s.Transfer=s.DefaultSerializer=s.expose=s.registerSerializer=void 0;var n=y.requireCommon();Object.defineProperty(s,"registerSerializer",{enumerable:!0,get:function(){return n.registerSerializer}}),t(Vt(),s);var r=y.requireWorker();Object.defineProperty(s,"expose",{enumerable:!0,get:function(){return r.expose}});var o=y.requireSerializers();Object.defineProperty(s,"DefaultSerializer",{enumerable:!0,get:function(){return o.DefaultSerializer}});var i=y.requireTransferable();Object.defineProperty(s,"Transfer",{enumerable:!0,get:function(){return i.Transfer}})}(K)),K}var Xt=$t();const U=y.getDefaultExportFromCjs(Xt);U.registerSerializer;const Qt=U.spawn;U.BlobWorker;U.DefaultSerializer;U.Pool;const Yt=U.Thread;U.Transfer;const Jt=U.Worker;var Zt=Object.defineProperty,en=(s,e,t)=>e in s?Zt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,j=(s,e,t)=>en(s,typeof e!="symbol"?e+"":e,t);const tn=()=>{try{if(window){if(navigator!=null&&navigator.hardwareConcurrency)return navigator.hardwareConcurrency;throw new Error("Unable to determine the number of cores")}else return require("os").cpus().length}catch(s){return console.error("🛑 Unable to detect available cores",s),2}},nn=()=>tn()-1,rn="TERMINATE_THREAD_FROM_WORKER";let sn=-1;class on{constructor(e){j(this,"_handleTerminate"),j(this,"_handleError"),j(this,"_task"),j(this,"id",sn+=1),j(this,"idle",!0),j(this,"worker"),j(this,"thread"),this._handleTerminate=e==null?void 0:e.onTerminate,this._handleError=e==null?void 0:e.onError}_handleMessages(e){var t;e instanceof MessageEvent&&((t=e.data)==null?void 0:t.token)===rn&&this.terminate()}async run(e){var t;try{const{payload:n,options:r}=e;return this.idle=!1,this.worker=new Jt(n.path,{type:"module",...r==null?void 0:r.worker}),this.thread=await Qt(this.worker,{timeout:1e4,...r==null?void 0:r.spawn}),this._task=e,this.worker.postMessage(n.subject,n.transferSubject),this.worker.addEventListener("message",this._handleMessages.bind(this)),this}catch(n){(t=this._handleError)==null||t.call(this,n);return}}get task(){return this._task}async terminate(){var e,t,n;(e=this.worker)==null||e.removeEventListener("message",this._handleMessages.bind(this)),this.thread&&await Yt.terminate(this.thread),await((t=this.worker)==null?void 0:t.terminate()),this.worker=void 0,this.thread=void 0,this._task=void 0,this.idle=!0,(n=this._handleTerminate)==null||n.call(this)}}class an{constructor(e,t,n){j(this,"_workerThreads",[]),j(this,"_tasksQueue",[]),this.maxWorkersCount=e,this.debugMode=t,this.onWorkerThreadRun=n;for(let r=0;r<this.maxWorkersCount;r++)this._workerThreads.push(this._createWorkerThread())}_handleWorkerThreadTerminate(e){this.debugMode&&console.log(`WorkerThread #${e.id} freed`),this.runNext()}_handleWorkerThreadError(e,t){console.error(`Error from worker #${t.id}:`,e),this.runNext()}_createWorkerThread(){const e=new on({onTerminate:()=>this._handleWorkerThreadTerminate(e),onError:t=>this._handleWorkerThreadError(t,e)});return e}get workerThreads(){return this._workerThreads}get tasksQueue(){return this._tasksQueue}get nextAvailableWorkerThread(){return this._workerThreads.find(e=>e.idle)}getAvailableWorkerThreads(e=!1){return this._workerThreads.filter(t=>e?!t.idle:t.idle)}async runNext(){if(!this.nextAvailableWorkerThread||this._tasksQueue.length===0)return;const e=this._tasksQueue.shift();e&&await this.run(e)}async run(e,t=!1){var n;if(t){const i=this._createWorkerThread();return this.debugMode&&console.log(`Running On Untracked Thread #${i==null?void 0:i.id}. Task:`,e),[await i.run(e),!0]}const r=this.nextAvailableWorkerThread;if(!r)return this._tasksQueue.push(e),this.debugMode&&console.log("Queued Thread Task:",e),[void 0,!0];this.debugMode&&console.log(`Running On Thread #${r==null?void 0:r.id}. Task:`,e);const o=await r.run(e);if(o)return(n=this.onWorkerThreadRun)==null||n.call(this,o),[o,!1]}async terminateAll(){this._tasksQueue=[],await Promise.all(this._workerThreads.map(e=>e.terminate()))}}const cn=(s,e)=>new an(nn(),!!e);var un=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(s,e,t,n)=>{for(var r=n>1?void 0:n?ln(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&un(e,t,r),r},fn=(s,e)=>(t,n)=>e(t,n,s);let ue=class{constructor(s){L(this,"workerPool");L(this,"canvas");L(this,"offscreenCanvas");L(this,"worker");L(this,"thread");this._props=s,this.workerPool=cn(void 0,this._props.enableDebug)}init(s){this.worker=s.worker,this.thread=s.thread}preventDefaultHandler(s){return s.preventDefault(),{type:s.type}}getScreenSizes(){var s,e;return{width:(s=this.canvas)==null?void 0:s.width,height:(e=this.canvas)==null?void 0:e.height,windowWidth:(window==null?void 0:window.innerWidth)??0,windowHeight:(window==null?void 0:window.innerHeight)??0}}uiEventHandler(s){var t;const e=(t=this.canvas)==null?void 0:t.getBoundingClientRect();return{...this.getScreenSizes(),type:s.type,top:e==null?void 0:e.top,left:e==null?void 0:e.left}}mouseEventHandler(s){return{...this.getScreenSizes(),...y.R(s,["ctrlKey","metaKey","shiftKey","button","pointerType","clientX","clientY","pageX","pageY"])}}touchEventHandler(s){const e=[],t={type:s.type,touches:e};for(let n=0;n<s.touches.length;++n){const r=s.touches[n];e.push({pageX:(r==null?void 0:r.pageX)??0,pageY:(r==null?void 0:r.pageY)??0})}return{...this.getScreenSizes(),...t}}wheelEventHandler(s){return s.preventDefault(),{...this.getScreenSizes(),...y.R(s,["deltaX","deltaY"])}}keyEventHandler(s){if(y.KEYBOARD_EVENT_CODES.includes(s.code))return s.preventDefault(),{...this.getScreenSizes(),...y.R(s,["ctrlKey","metaKey","shiftKey","keyCode"])}}};ue=dn([y.scoped(y.Lifecycle.ContainerScoped),fn(0,y.inject(se))],ue);var hn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,mn=(s,e,t,n)=>{for(var r=n>1?void 0:n?pn(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&hn(e,t,r),r},gn=(s,e)=>(t,n)=>e(t,n,s);let Le=class extends y.ProxyEventHandlersBlueprint{constructor(s){super(),this._service=s}init(){for(const s of y.PROXY_EVENT_LISTENERS){const e=s.startsWith("mouse")||s.startsWith("pointer")||s.startsWith("touch")?this._service.mouseEventHandler.bind(this._service):s.startsWith("key")?this._service.keyEventHandler.bind(this._service):s==="resize"?this._service.uiEventHandler.bind(this._service):s==="wheel"?this._service.wheelEventHandler.bind(this._service):this._service.preventDefaultHandler.bind(this._service);this[`${s}$`]=y.fromEvent(s==="resize"?window:this._service.canvas,s).pipe(y.map(e.bind(this)),y.filter(t=>!(s==="keydown"&&!t))),this[`${s}$`].subscribe(t=>{var n,r;(r=(n=this._service.thread)==null?void 0:n[s])==null||r.call(n,t)})}}};Le=mn([y.scoped(y.Lifecycle.ContainerScoped),gn(0,y.inject(ue))],Le);function Ye(s,e){if(e===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===h.TriangleFanDrawMode||e===h.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 n=t.count-2,r=[];if(e===h.TriangleFanDrawMode)for(let i=1;i<=n;i++)r.push(t.getX(0)),r.push(t.getX(i)),r.push(t.getX(i+1));else for(let i=0;i<n;i++)i%2===0?(r.push(t.getX(i)),r.push(t.getX(i+1)),r.push(t.getX(i+2))):(r.push(t.getX(i+2)),r.push(t.getX(i+1)),r.push(t.getX(i)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=s.clone();return o.setIndex(r),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}const ve=new WeakMap;class ut extends h.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const o=new h.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,i=>{this.parse(i,t,r)},n,r)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,h.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,r,o=h.LinearSRGBColorSpace,i=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:o};return this.decodeGeometry(e,a).then(t).catch(i)}decodeGeometry(e,t){const n=JSON.stringify(t);if(ve.has(e)){const c=ve.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const o=this.workerNextTaskID++,i=e.byteLength,a=this._getWorker(o,i).then(c=>(r=c,new Promise((d,u)=>{r._callbacks[o]={resolve:d,reject:u},r.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{r&&o&&this._releaseTask(r,o)}),ve.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new h.BufferGeometry;e.index&&t.setIndex(new h.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],o=r.name,i=r.array,a=r.itemSize,c=new h.BufferAttribute(i,a);o==="color"&&(this._assignVertexColorSpace(c,r.vertexColorSpace),c.normalized=!(i instanceof Float32Array)),t.setAttribute(o,c)}return t}_assignVertexColorSpace(e,t){if(t!==h.SRGBColorSpace)return;const n=new h.Color;for(let r=0,o=e.count;r<o;r++)n.fromBufferAttribute(e,r),h.ColorManagement.toWorkingColorSpace(n,h.SRGBColorSpace),e.setXYZ(r,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new h.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((r,o)=>{n.load(e,r,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const r=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=_n.toString(),i=["/* draco decoder */",r,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
|
|
3
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(o){const i=o.data;switch(i.type){case"decode":r._callbacks[i.id].resolve(i);break;case"error":r._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,o){return r._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function _n(){let s,e;onmessage=function(i){const a=i.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise(function(u){s.onModuleLoaded=function(l){u({draco:l})},DracoDecoderModule(s)});break;case"decode":const c=a.buffer,d=a.taskConfig;e.then(u=>{const l=u.draco,f=new l.Decoder;try{const p=t(l,f,new Int8Array(c),d),A=p.attributes.map(R=>R.array.buffer);p.index&&A.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},A)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{l.destroy(f)}});break}};function t(i,a,c,d){const u=d.attributeIDs,l=d.attributeTypes;let f,p;const A=a.GetEncodedGeometryType(c);if(A===i.TRIANGULAR_MESH)f=new i.Mesh,p=a.DecodeArrayToMesh(c,c.byteLength,f);else if(A===i.POINT_CLOUD)f=new i.PointCloud,p=a.DecodeArrayToPointCloud(c,c.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const R={index:null,attributes:[]};for(const v in u){const m=self[l[v]];let g,_;if(d.useUniqueIDs)_=u[v],g=a.GetAttributeByUniqueId(f,_);else{if(_=a.GetAttributeId(f,i[u[v]]),_===-1)continue;g=a.GetAttribute(f,_)}const b=r(i,a,f,v,m,g);v==="color"&&(b.vertexColorSpace=d.vertexColorSpace),R.attributes.push(b)}return A===i.TRIANGULAR_MESH&&(R.index=n(i,a,f)),i.destroy(f),R}function n(i,a,c){const u=c.num_faces()*3,l=u*4,f=i._malloc(l);a.GetTrianglesUInt32Array(c,l,f);const p=new Uint32Array(i.HEAPF32.buffer,f,u).slice();return i._free(f),{array:p,itemSize:1}}function r(i,a,c,d,u,l){const f=l.num_components(),A=c.num_points()*f,R=A*u.BYTES_PER_ELEMENT,v=o(i,u),m=i._malloc(R);a.GetAttributeDataArrayForAllPoints(c,l,v,R,m);const g=new u(i.HEAPF32.buffer,m,A).slice();return i._free(m),{name:d,array:g,itemSize:f}}function o(i,a){switch(a){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}class yn extends h.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new An(t)}),this.register(function(t){return new En(t)}),this.register(function(t){return new On(t)}),this.register(function(t){return new In(t)}),this.register(function(t){return new Nn(t)}),this.register(function(t){return new Cn(t)}),this.register(function(t){return new Sn(t)}),this.register(function(t){return new xn(t)}),this.register(function(t){return new Ln(t)}),this.register(function(t){return new vn(t)}),this.register(function(t){return new Mn(t)}),this.register(function(t){return new Rn(t)}),this.register(function(t){return new Pn(t)}),this.register(function(t){return new kn(t)}),this.register(function(t){return new Tn(t)}),this.register(function(t){return new Dn(t)}),this.register(function(t){return new Fn(t)})}load(e,t,n,r){const o=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const d=h.LoaderUtils.extractUrlBase(e);i=h.LoaderUtils.resolveURL(d,this.path)}else i=h.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(d){r?r(d):console.error(d),o.manager.itemError(e),o.manager.itemEnd(e)},c=new h.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(d){try{o.parse(d,i,function(u){t(u),o.manager.itemEnd(e)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}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,n,r){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))===lt){try{i[S.KHR_BINARY_GLTF]=new jn(e)}catch(l){r&&r(l);return}o=JSON.parse(i[S.KHR_BINARY_GLTF].content)}else o=JSON.parse(c.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const d=new Yn(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const l=this.pluginCallbacks[u](d);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,i[l.name]=!0}if(o.extensionsUsed)for(let u=0;u<o.extensionsUsed.length;++u){const l=o.extensionsUsed[u],f=o.extensionsRequired||[];switch(l){case S.KHR_MATERIALS_UNLIT:i[l]=new wn;break;case S.KHR_DRACO_MESH_COMPRESSION:i[l]=new Bn(o,this.dracoLoader);break;case S.KHR_TEXTURE_TRANSFORM:i[l]=new Hn;break;case S.KHR_MESH_QUANTIZATION:i[l]=new Un;break;default:f.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}d.setExtensions(i),d.setPlugins(a),d.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,o){n.parse(e,t,r,o)})}}function bn(){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 S={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 Tn{constructor(e){this.parser=e,this.name=S.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const o=t[n];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,n="light:"+e;let r=t.cache.get(n);if(r)return r;const o=t.json,c=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let d;const u=new h.Color(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],h.LinearSRGBColorSpace);const l=c.range!==void 0?c.range:0;switch(c.type){case"directional":d=new h.DirectionalLight(u),d.target.position.set(0,0,-1),d.add(d.target);break;case"point":d=new h.PointLight(u),d.distance=l;break;case"spot":d=new h.SpotLight(u),d.distance=l,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,d.angle=c.spot.outerConeAngle,d.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,d.target.position.set(0,0,-1),d.add(d.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return d.position.set(0,0,0),d.decay=2,B(d,c),c.intensity!==void 0&&(d.intensity=c.intensity),d.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(d),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],a=(o.extensions&&o.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}}class wn{constructor(){this.name=S.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(e,t,n){const r=[];e.color=new h.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],h.LinearSRGBColorSpace),e.opacity=i[3]}o.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",o.baseColorTexture,h.SRGBColorSpace))}return Promise.all(r)}}class vn{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class An{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new h.Vector2(a,a)}return Promise.all(o)}}class En{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class Rn{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&o.push(n.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(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(o)}}class Cn{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new h.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=r.extensions[this.name];if(i.sheenColorFactor!==void 0){const a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,h.SRGBColorSpace)),i.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(o)}}class Sn{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(o)}}class xn{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),Promise.all(o)}}class Ln{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class Mn{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),i.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,h.SRGBColorSpace)),Promise.all(o)}}class kn{constructor(e){this.parser=e,this.name=S.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&o.push(n.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(o)}}class Pn{constructor(e){this.parser=e,this.name=S.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.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(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(o)}}class On{constructor(e){this.parser=e,this.name=S.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const o=r.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.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 In{constructor(e){this.parser=e,this.name=S.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],a=r.images[i.source];let c=n.textureLoader;if(a.uri){const d=n.options.manager.getHandler(a.uri);d!==null&&(c=d)}return this.detectSupport().then(function(d){if(d)return n.loadTextureImage(e,i.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.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 Nn{constructor(e){this.parser=e,this.name=S.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],a=r.images[i.source];let c=n.textureLoader;if(a.uri){const d=n.options.manager.getHandler(a.uri);d!==null&&(c=d)}return this.detectSupport().then(function(d){if(d)return n.loadTextureImage(e,i.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.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 Dn{constructor(e){this.name=S.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const r=n.extensions[this.name],o=this.parser.getDependency("buffer",r.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=r.byteOffset||0,d=r.byteLength||0,u=r.count,l=r.byteStride,f=new Uint8Array(a,c,d);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(u,l,f,r.mode,r.filter).then(function(p){return p.buffer}):i.ready.then(function(){const p=new ArrayBuffer(u*l);return i.decodeGltfBuffer(new Uint8Array(p),u,l,f,r.mode,r.filter),p})})}else return null}}class Fn{constructor(e){this.name=S.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const r=t.meshes[n.mesh];for(const d of r.primitives)if(d.mode!==O.TRIANGLES&&d.mode!==O.TRIANGLE_STRIP&&d.mode!==O.TRIANGLE_FAN&&d.mode!==void 0)return null;const i=n.extensions[this.name].attributes,a=[],c={};for(const d in i)a.push(this.parser.getDependency("accessor",i[d]).then(u=>(c[d]=u,c[d])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(d=>{const u=d.pop(),l=u.isGroup?u.children:[u],f=d[0].count,p=[];for(const A of l){const R=new h.Matrix4,v=new h.Vector3,m=new h.Quaternion,g=new h.Vector3(1,1,1),_=new h.InstancedMesh(A.geometry,A.material,f);for(let b=0;b<f;b++)c.TRANSLATION&&v.fromBufferAttribute(c.TRANSLATION,b),c.ROTATION&&m.fromBufferAttribute(c.ROTATION,b),c.SCALE&&g.fromBufferAttribute(c.SCALE,b),_.setMatrixAt(b,R.compose(v,m,g));for(const b in c)if(b==="_COLOR_0"){const T=c[b];_.instanceColor=new h.InstancedBufferAttribute(T.array,T.itemSize,T.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&A.geometry.setAttribute(b,c[b]);h.Object3D.prototype.copy.call(_,A),this.parser.assignFinalMaterial(_),p.push(_)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const lt="glTF",re=12,Je={JSON:1313821514,BIN:5130562};class jn{constructor(e){this.name=S.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,re),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==lt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-re,o=new DataView(e,re);let i=0;for(;i<r;){const a=o.getUint32(i,!0);i+=4;const c=o.getUint32(i,!0);if(i+=4,c===Je.JSON){const d=new Uint8Array(e,re+i,a);this.content=n.decode(d)}else if(c===Je.BIN){const d=re+i;this.body=e.slice(d,d+a)}i+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Bn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=S.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},c={},d={};for(const u in i){const l=Me[u]||u.toLowerCase();a[l]=i[u]}for(const u in e.attributes){const l=Me[u]||u.toLowerCase();if(i[u]!==void 0){const f=n.accessors[e.attributes[u]],p=Q[f.componentType];d[l]=p.name,c[l]=f.normalized===!0}}return t.getDependency("bufferView",o).then(function(u){return new Promise(function(l,f){r.decodeDracoFile(u,function(p){for(const A in p.attributes){const R=p.attributes[A],v=c[A];v!==void 0&&(R.normalized=v)}l(p)},a,d,h.LinearSRGBColorSpace,f)})})}}class Hn{constructor(){this.name=S.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 Un{constructor(){this.name=S.KHR_MESH_QUANTIZATION}}class dt extends h.Interpolant{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r*3+r;for(let i=0;i!==r;i++)t[i]=n[o+i];return t}interpolate_(e,t,n,r){const o=this.resultBuffer,i=this.sampleValues,a=this.valueSize,c=a*2,d=a*3,u=r-t,l=(n-t)/u,f=l*l,p=f*l,A=e*d,R=A-d,v=-2*p+3*f,m=p-f,g=1-v,_=m-f+l;for(let b=0;b!==a;b++){const T=i[R+b+a],w=i[R+b+c]*u,E=i[A+b+a],x=i[A+b]*u;o[b]=g*T+_*w+v*E+m*x}return o}}const Gn=new h.Quaternion;class Wn extends dt{interpolate_(e,t,n,r){const o=super.interpolate_(e,t,n,r);return Gn.fromArray(o).normalize().toArray(o),o}}const O={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Q={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ze={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},et={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},Ae={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Me={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Kn={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},Ee={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function zn(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),s.DefaultMaterial}function V(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function B(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 qn(s,e,t){let n=!1,r=!1,o=!1;for(let d=0,u=e.length;d<u;d++){const l=e[d];if(l.POSITION!==void 0&&(n=!0),l.NORMAL!==void 0&&(r=!0),l.COLOR_0!==void 0&&(o=!0),n&&r&&o)break}if(!n&&!r&&!o)return Promise.resolve(s);const i=[],a=[],c=[];for(let d=0,u=e.length;d<u;d++){const l=e[d];if(n){const f=l.POSITION!==void 0?t.getDependency("accessor",l.POSITION):s.attributes.position;i.push(f)}if(r){const f=l.NORMAL!==void 0?t.getDependency("accessor",l.NORMAL):s.attributes.normal;a.push(f)}if(o){const f=l.COLOR_0!==void 0?t.getDependency("accessor",l.COLOR_0):s.attributes.color;c.push(f)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c)]).then(function(d){const u=d[0],l=d[1],f=d[2];return n&&(s.morphAttributes.position=u),r&&(s.morphAttributes.normal=l),o&&(s.morphAttributes.color=f),s.morphTargetsRelative=!0,s})}function Vn(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;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 n=0,r=t.length;n<r;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function $n(s){let e;const t=s.extensions&&s.extensions[S.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Re(t.attributes):e=s.indices+":"+Re(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,r=s.targets.length;n<r;n++)e+=":"+Re(s.targets[n]);return e}function Re(s){let e="";const t=Object.keys(s).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+s[t[n]]+";";return e}function ke(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 Xn(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":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Qn=new h.Matrix4;class Yn{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new bn,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 n=!1,r=-1,o=!1,i=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);r=n&&c?parseInt(c[1],10):-1,o=a.indexOf("Firefox")>-1,i=o?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&r<17||o&&i<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.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 n=this,r=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){const a={scene:i[0][r.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:r.asset,parser:n,userData:{}};return V(o,a,r),B(a,r),Promise.all(n._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||[],n=this.json.meshes||[];for(let r=0,o=t.length;r<o;r++){const i=t[r].joints;for(let a=0,c=i.length;a<c;a++)e[i[a]].isBone=!0}for(let r=0,o=e.length;r<o;r++){const i=e[r];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[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,n){if(e.refs[t]<=1)return n;const r=n.clone(),o=(i,a)=>{const c=this.associations.get(i);c!=null&&this.associations.set(a,c);for(const[d,u]of i.children.entries())o(u,a.children[d])};return o(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const o=e(t[r]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":r=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(o,i){return n.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[S.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(o,i){n.load(h.LoaderUtils.resolveURL(t.uri,r.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(n){const r=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+r)})}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const i=Ae[r.type],a=Q[r.componentType],c=r.normalized===!0,d=new a(r.count*i);return Promise.resolve(new h.BufferAttribute(d,i,c))}const o=[];return r.bufferView!==void 0?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),r.sparse!==void 0&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(i){const a=i[0],c=Ae[r.type],d=Q[r.componentType],u=d.BYTES_PER_ELEMENT,l=u*c,f=r.byteOffset||0,p=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,A=r.normalized===!0;let R,v;if(p&&p!==l){const m=Math.floor(f/p),g="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+m+":"+r.count;let _=t.cache.get(g);_||(R=new d(a,m*p,r.count*p/u),_=new h.InterleavedBuffer(R,p/u),t.cache.add(g,_)),v=new h.InterleavedBufferAttribute(_,c,f%p/u,A)}else a===null?R=new d(r.count*c):R=new d(a,f,r.count*c),v=new h.BufferAttribute(R,c,A);if(r.sparse!==void 0){const m=Ae.SCALAR,g=Q[r.sparse.indices.componentType],_=r.sparse.indices.byteOffset||0,b=r.sparse.values.byteOffset||0,T=new g(i[1],_,r.sparse.count*m),w=new d(i[2],b,r.sparse.count*c);a!==null&&(v=new h.BufferAttribute(v.array.slice(),v.itemSize,v.normalized)),v.normalized=!1;for(let E=0,x=T.length;E<x;E++){const C=T[E];if(v.setX(C,w[E*c]),c>=2&&v.setY(C,w[E*c+1]),c>=3&&v.setZ(C,w[E*c+2]),c>=4&&v.setW(C,w[E*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}v.normalized=A}return v})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,i=t.images[o];let a=this.textureLoader;if(i.uri){const c=n.manager.getHandler(i.uri);c!==null&&(a=c)}return this.loadTextureImage(e,o,a)}loadTextureImage(e,t,n){const r=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 d=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=i.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const f=(o.samplers||{})[i.sampler]||{};return u.magFilter=Ze[f.magFilter]||h.LinearFilter,u.minFilter=Ze[f.minFilter]||h.LinearMipmapLinearFilter,u.wrapS=et[f.wrapS]||h.RepeatWrapping,u.wrapT=et[f.wrapT]||h.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==h.NearestFilter&&u.minFilter!==h.LinearFilter,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=d,d}loadImageSource(e,t){const n=this,r=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(l=>l.clone());const i=r.images[e],a=self.URL||self.webkitURL;let c=i.uri||"",d=!1;if(i.bufferView!==void 0)c=n.getDependency("bufferView",i.bufferView).then(function(l){d=!0;const f=new Blob([l],{type:i.mimeType});return c=a.createObjectURL(f),c});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(l){return new Promise(function(f,p){let A=f;t.isImageBitmapLoader===!0&&(A=function(R){const v=new h.Texture(R);v.needsUpdate=!0,f(v)}),t.load(h.LoaderUtils.resolveURL(l,o.path),A,void 0,p)})}).then(function(l){return d===!0&&a.revokeObjectURL(c),B(l,i),l.userData.mimeType=i.mimeType||Xn(i.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),l});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){const o=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),o.extensions[S.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[S.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=o.associations.get(i);i=o.extensions[S.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),o.associations.set(i,c)}}return r!==void 0&&(i.colorSpace=r),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new h.PointsMaterial,h.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new h.LineBasicMaterial,h.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(r||o||i){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),o&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),o&&(c.vertexColors=!0),i&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,o=n.materials[e];let i;const a={},c=o.extensions||{},d=[];if(c[S.KHR_MATERIALS_UNLIT]){const l=r[S.KHR_MATERIALS_UNLIT];i=l.getMaterialType(),d.push(l.extendParams(a,o,t))}else{const l=o.pbrMetallicRoughness||{};if(a.color=new h.Color(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const f=l.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],h.LinearSRGBColorSpace),a.opacity=f[3]}l.baseColorTexture!==void 0&&d.push(t.assignTexture(a,"map",l.baseColorTexture,h.SRGBColorSpace)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(d.push(t.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),d.push(t.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),d.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}o.doubleSided===!0&&(a.side=h.DoubleSide);const u=o.alphaMode||Ee.OPAQUE;if(u===Ee.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===Ee.MASK&&(a.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&i!==h.MeshBasicMaterial&&(d.push(t.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new h.Vector2(1,1),o.normalTexture.scale!==void 0)){const l=o.normalTexture.scale;a.normalScale.set(l,l)}if(o.occlusionTexture!==void 0&&i!==h.MeshBasicMaterial&&(d.push(t.assignTexture(a,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&i!==h.MeshBasicMaterial){const l=o.emissiveFactor;a.emissive=new h.Color().setRGB(l[0],l[1],l[2],h.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&i!==h.MeshBasicMaterial&&d.push(t.assignTexture(a,"emissiveMap",o.emissiveTexture,h.SRGBColorSpace)),Promise.all(d).then(function(){const l=new i(a);return o.name&&(l.name=o.name),B(l,o),t.associations.set(l,{materials:e}),o.extensions&&V(r,l,o),l})}createUniqueName(e){const t=h.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function o(a){return n[S.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return tt(c,a,t)})}const i=[];for(let a=0,c=e.length;a<c;a++){const d=e[a],u=$n(d),l=r[u];if(l)i.push(l.promise);else{let f;d.extensions&&d.extensions[S.KHR_DRACO_MESH_COMPRESSION]?f=o(d):f=tt(new h.BufferGeometry,d,t),r[u]={primitive:d,promise:f},i.push(f)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,r=this.extensions,o=n.meshes[e],i=o.primitives,a=[];for(let c=0,d=i.length;c<d;c++){const u=i[c].material===void 0?zn(this.cache):this.getDependency("material",i[c].material);a.push(u)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(c){const d=c.slice(0,c.length-1),u=c[c.length-1],l=[];for(let p=0,A=u.length;p<A;p++){const R=u[p],v=i[p];let m;const g=d[p];if(v.mode===O.TRIANGLES||v.mode===O.TRIANGLE_STRIP||v.mode===O.TRIANGLE_FAN||v.mode===void 0)m=o.isSkinnedMesh===!0?new h.SkinnedMesh(R,g):new h.Mesh(R,g),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),v.mode===O.TRIANGLE_STRIP?m.geometry=Ye(m.geometry,h.TriangleStripDrawMode):v.mode===O.TRIANGLE_FAN&&(m.geometry=Ye(m.geometry,h.TriangleFanDrawMode));else if(v.mode===O.LINES)m=new h.LineSegments(R,g);else if(v.mode===O.LINE_STRIP)m=new h.Line(R,g);else if(v.mode===O.LINE_LOOP)m=new h.LineLoop(R,g);else if(v.mode===O.POINTS)m=new h.Points(R,g);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(m.geometry.morphAttributes).length>0&&Vn(m,o),m.name=t.createUniqueName(o.name||"mesh_"+e),B(m,o),v.extensions&&V(r,m,v),t.assignFinalMaterial(m),l.push(m)}for(let p=0,A=l.length;p<A;p++)t.associations.set(l[p],{meshes:e,primitives:p});if(l.length===1)return o.extensions&&V(r,l[0],o),l[0];const f=new h.Group;o.extensions&&V(r,f,o),t.associations.set(f,{meshes:e});for(let p=0,A=l.length;p<A;p++)f.add(l[p]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new h.PerspectiveCamera(h.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new h.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),B(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let r=0,o=t.joints.length;r<o;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){const o=r.pop(),i=r,a=[],c=[];for(let d=0,u=i.length;d<u;d++){const l=i[d];if(l){a.push(l);const f=new h.Matrix4;o!==null&&f.fromArray(o.array,d*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[d])}return new h.Skeleton(a,c)})}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],o=r.name?r.name:"animation_"+e,i=[],a=[],c=[],d=[],u=[];for(let l=0,f=r.channels.length;l<f;l++){const p=r.channels[l],A=r.samplers[p.sampler],R=p.target,v=R.node,m=r.parameters!==void 0?r.parameters[A.input]:A.input,g=r.parameters!==void 0?r.parameters[A.output]:A.output;R.node!==void 0&&(i.push(this.getDependency("node",v)),a.push(this.getDependency("accessor",m)),c.push(this.getDependency("accessor",g)),d.push(A),u.push(R))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c),Promise.all(d),Promise.all(u)]).then(function(l){const f=l[0],p=l[1],A=l[2],R=l[3],v=l[4],m=[];for(let g=0,_=f.length;g<_;g++){const b=f[g],T=p[g],w=A[g],E=R[g],x=v[g];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const C=n._createAnimationTracks(b,T,w,E,x);if(C)for(let M=0;M<C.length;M++)m.push(C[M])}return new h.AnimationClip(o,void 0,m)})}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(o){const i=n._getNodeRef(n.meshCache,r.mesh,o);return r.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let c=0,d=r.weights.length;c<d;c++)a.morphTargetInfluences[c]=r.weights[c]}),i})}loadNode(e){const t=this.json,n=this,r=t.nodes[e],o=n._loadNodeShallow(e),i=[],a=r.children||[];for(let d=0,u=a.length;d<u;d++)i.push(n.getDependency("node",a[d]));const c=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([o,Promise.all(i),c]).then(function(d){const u=d[0],l=d[1],f=d[2];f!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Qn)});for(let p=0,A=l.length;p<A;p++)u.add(l[p]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],i=o.name?r.createUniqueName(o.name):"",a=[],c=r._invokeOne(function(d){return d.createNodeMesh&&d.createNodeMesh(e)});return c&&a.push(c),o.camera!==void 0&&a.push(r.getDependency("camera",o.camera).then(function(d){return r._getNodeRef(r.cameraCache,o.camera,d)})),r._invokeAll(function(d){return d.createNodeAttachment&&d.createNodeAttachment(e)}).forEach(function(d){a.push(d)}),this.nodeCache[e]=Promise.all(a).then(function(d){let u;if(o.isBone===!0?u=new h.Bone:d.length>1?u=new h.Group:d.length===1?u=d[0]:u=new h.Object3D,u!==d[0])for(let l=0,f=d.length;l<f;l++)u.add(d[l]);if(o.name&&(u.userData.name=o.name,u.name=i),B(u,o),o.extensions&&V(n,u,o),o.matrix!==void 0){const l=new h.Matrix4;l.fromArray(o.matrix),u.applyMatrix4(l)}else o.translation!==void 0&&u.position.fromArray(o.translation),o.rotation!==void 0&&u.quaternion.fromArray(o.rotation),o.scale!==void 0&&u.scale.fromArray(o.scale);return r.associations.has(u)||r.associations.set(u,{}),r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,o=new h.Group;n.name&&(o.name=r.createUniqueName(n.name)),B(o,n),n.extensions&&V(t,o,n);const i=n.nodes||[],a=[];for(let c=0,d=i.length;c<d;c++)a.push(r.getDependency("node",i[c]));return Promise.all(a).then(function(c){for(let u=0,l=c.length;u<l;u++)o.add(c[u]);const d=u=>{const l=new Map;for(const[f,p]of r.associations)(f instanceof h.Material||f instanceof h.Texture)&&l.set(f,p);return u.traverse(f=>{const p=r.associations.get(f);p!=null&&l.set(f,p)}),l};return r.associations=d(o),o})}_createAnimationTracks(e,t,n,r,o){const i=[],a=e.name?e.name:e.uuid,c=[];H[o.path]===H.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let d;switch(H[o.path]){case H.weights:d=h.NumberKeyframeTrack;break;case H.rotation:d=h.QuaternionKeyframeTrack;break;case H.position:case H.scale:d=h.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:d=h.NumberKeyframeTrack;break;case 2:case 3:default:d=h.VectorKeyframeTrack;break}break}const u=r.interpolation!==void 0?Kn[r.interpolation]:h.InterpolateLinear,l=this._getArrayFromAccessor(n);for(let f=0,p=c.length;f<p;f++){const A=new d(c[f]+"."+H[o.path],t.array,l,u);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(A),i.push(A)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=ke(t.constructor),r=new Float32Array(t.length);for(let o=0,i=t.length;o<i;o++)r[o]=t[o]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const r=this instanceof h.QuaternionKeyframeTrack?Wn:dt;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Jn(s,e,t){const n=e.attributes,r=new h.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,d=a.max;if(c!==void 0&&d!==void 0){if(r.set(new h.Vector3(c[0],c[1],c[2]),new h.Vector3(d[0],d[1],d[2])),a.normalized){const u=ke(Q[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}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 h.Vector3,c=new h.Vector3;for(let d=0,u=o.length;d<u;d++){const l=o[d];if(l.POSITION!==void 0){const f=t.json.accessors[l.POSITION],p=f.min,A=f.max;if(p!==void 0&&A!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(A[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(A[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(A[2]))),f.normalized){const R=ke(Q[f.componentType]);c.multiplyScalar(R)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}s.boundingBox=r;const i=new h.Sphere;r.getCenter(i.center),i.radius=r.min.distanceTo(r.max)/2,s.boundingSphere=i}function tt(s,e,t){const n=e.attributes,r=[];function o(i,a){return t.getDependency("accessor",i).then(function(c){s.setAttribute(a,c)})}for(const i in n){const a=Me[i]||i.toLowerCase();a in s.attributes||r.push(o(n[i],a))}if(e.indices!==void 0&&!s.index){const i=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});r.push(i)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),B(s,e),Jn(s,e,t),Promise.all(r).then(function(){return e.targets!==void 0?qn(s,e.targets,t):s})}var Zn=Object.defineProperty,er=Object.getOwnPropertyDescriptor,tr=(s,e,t,n)=>{for(var r=n>1?void 0:n?er(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&Zn(e,t,r),r};let le=class{constructor(){L(this,"loadingManager",new h.LoadingManager);L(this,"loaders",{});L(this,"sources",[]);L(this,"loadedResources",{});L(this,"toLoadCount",0);L(this,"loadedCount",0)}get videoLoader(){return{load:(s,e)=>{const t=document.createElement("video");t.muted=!0,t.loop=!0,t.crossOrigin="anonymous",t.controls=!1,t.playsInline=!0,t.src=s,t.autoplay=!0;const n=async()=>{e(t),t.removeEventListener("canplaythrough",n)};t.addEventListener("canplaythrough",n)}}}_initLoaders(){this.loaders.dracoLoader=new ut(this.loadingManager),this.loaders.audioLoader=new h.AudioLoader(this.loadingManager),this.loaders.fontLoader=new y.FontLoader(this.loadingManager),this.loaders.gltfLoader=new yn(this.loadingManager),this.loaders.imageLoader=new h.ImageBitmapLoader(this.loadingManager),this.loaders.videoLoader=this.videoLoader}_initSources(s){this.sources=s,this.toLoadCount=this.sources.length,this.loadedCount=0}init(s=[]){this._initLoaders(),this._initSources(s)}setDracoDecoder(s){var e;this.loaders.dracoLoader&&(this.loaders.dracoLoader.setDecoderPath(s??"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),(e=this.loaders.gltfLoader)==null||e.setDRACOLoader(this.loaders.dracoLoader))}handleLoad({source:s,resource:e,toLoadCount:t,loadedCount:n}){e&&(this.loadedResources[s.name]=e,this.loadedCount=n,this.toLoadCount=t)}launchLoad(s){var t,n,r,o,i;const e=this.sources[0];if(e){s==null||s(e);for(const a of this.sources){if(this.loadedResources[a.name]||typeof a.path!="string")return;a.type==="gltf"&&((t=this.loaders.gltfLoader)==null||t.load(a.path,c=>s==null?void 0:s(a,c))),a.type==="audio"&&((n=this.loaders.audioLoader)==null||n.load(a.path,c=>s==null?void 0:s(a,c))),a.type==="image"&&((r=this.loaders.imageLoader)==null||r.load(a.path,c=>s==null?void 0:s(a,c))),a.type==="video"&&((o=this.loaders.videoLoader)==null||o.load(a.path,c=>s==null?void 0:s(a,c))),a.type==="font"&&((i=this.loaders.fontLoader)==null||i.load(a.path,c=>s==null?void 0:s(a,c)))}}}};le=tr([y.scoped(y.Lifecycle.ContainerScoped)],le);var nr=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,sr=(s,e,t,n)=>{for(var r=n>1?void 0:n?rr(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&nr(e,t,r),r},ir=(s,e)=>(t,n)=>e(t,n,s);let de=class{constructor(s){L(this,"load$$",new y.Subject);L(this,"load$",this.load$$.pipe(y.map(s=>({...s,loadedCount:s.resource?this._service.loadedCount+1:this._service.loadedCount,toLoadCount:this._service.toLoadCount})),y.share()));L(this,"serializedLoad$",this.load$.pipe(y.map(s=>{var t,n,r;let e=s.resource;if((t=s==null?void 0:s.resource)!=null&&t.parser){const o=s.resource,i=o.scenes.map(a=>y.g(a));e={animations:(s==null?void 0:s.resource).animations.map(a=>a.toJSON()),cameras:o.cameras.map(a=>y.g(a)),parser:{json:o.parser.json},scene:i==null?void 0:i[0],scenes:i,userData:o.userData}}return((n=s==null?void 0:s.source)==null?void 0:n.type)==="audio"&&s.resource instanceof AudioBuffer&&(e={arrayBuffer:s.resource.getChannelData(0),length:s.resource.length,sampleRate:s.resource.sampleRate,duration:s.resource.duration}),((r=s==null?void 0:s.source)==null?void 0:r.type)==="video"&&s.resource instanceof HTMLVideoElement&&(e={...y.R(s.resource,["autoplay","baseURI","controls","crossOrigin","currentTime","defaultMuted","disablePictureInPicture","draggable","duration","ended","height","hidden","loop","muted","nodeName","nodeType","paused","playbackRate","playsInline","poster","preload","readyState","seeking","spellcheck","src","tabIndex","translate","videoHeight","videoWidth","volume","width"]),buffered:s.resource.buffered.length,error:s.resource.error?y.E(s.resource.error,[]):{},played:s.resource.played.length,seekable:s.resource.seekable.length,textTracks:s.resource.textTracks.length}),{...s,resource:e}}),y.share()));L(this,"loadCompleted$",this.load$.pipe(y.filter(s=>s.toLoadCount===s.loadedCount),y.map(()=>y.R(this._service,["loadedCount","loadedResources","toLoadCount"])),y.share()));this._service=s}};de=sr([y.scoped(y.Lifecycle.ContainerScoped),ir(0,y.inject(le))],de);var or=Object.defineProperty,ar=Object.getOwnPropertyDescriptor,cr=(s,e,t,n)=>{for(var r=n>1?void 0:n?ar(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&or(e,t,r),r},Ce=(s,e)=>(t,n)=>e(t,n,s);let Pe=class{constructor(s,e,t){L(this,"_subscriptions",[]);this._controller=s,this._service=e,this._props=t,this._subscriptions.push(this._controller.load$.subscribe(this._service.handleLoad.bind(this._service)))}init(s){this._service.init(s.sources||[]),this._service.setDracoDecoder(s.dracoDecoderPath),[void 0,!0].includes(this._props.loadResourcesOnInit)&&this.load()}load(){this._service.launchLoad((s,e)=>this._controller.load$$.next({source:s,resource:e}))}getLoadedResources(){return this._service.loadedResources}getLoaders(){return this._service.loaders}getSources(){return this._service.sources}getLoadedCount(){return this._service.loadedCount}getToLoadCount(){return this._service.toLoadCount}getLoad$(){return this._controller.load$}getLoadCompleted$(){return this._controller.loadCompleted$}setDracoDecoder(s){this._service.setDracoDecoder(s)}dispose(){this._subscriptions.forEach(s=>s.unsubscribe()),Object.keys(this._service.loaders).forEach(s=>{const e=this._service.loaders[s];e instanceof ut&&e.dispose(),this._service.loaders[s]=void 0}),this._controller.load$$.complete()}};Pe=cr([y.scoped(y.Lifecycle.ContainerScoped),Ce(0,y.inject(de)),Ce(1,y.inject(le)),Ce(2,y.inject(se))],Pe);var ur=Object.defineProperty,lr=Object.getOwnPropertyDescriptor,dr=(s,e,t,n)=>{for(var r=n>1?void 0:n?lr(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&ur(e,t,r),r},X=(s,e)=>(t,n)=>e(t,n,s);exports.RegisterModule=class extends y.RegisterProxyEventHandlersBlueprint{constructor(t,n,r,o,i,a){super();L(this,"_subscriptions",[]);L(this,"_initialized",!1);this._service=t,this._controller=n,this._loaderController=r,this.container=o,this.props=i,this.loader=a,this.props.initOnConstruct&&this.init()}async _initCanvas(){try{if(this.props.canvas instanceof HTMLCanvasElement&&(this._service.canvas=this.props.canvas),typeof this.props.canvas=="string"){const t=document.querySelector(this.props.canvas);t instanceof HTMLCanvasElement&&(this._service.canvas=t)}this._service.canvas||(this._service.canvas=document.createElement("canvas"),this._service.canvas.dataset.reactive="true",document.body.appendChild(this._service.canvas))}catch(t){console.error(`🛑 Unable to initialize the canvas:
|
|
4
|
-
${t instanceof Error?t.message:"Something went wrong"}`)}}async
|
|
1
|
+
"use strict";var ft=Object.defineProperty;var ht=(s,e,t)=>e in s?ft(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var x=(s,e,t)=>ht(s,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./FontLoader-DvGzwRip.js"),h=require("three");class se{constructor(){x(this,"location");x(this,"initOnConstruct");x(this,"mainThread");x(this,"canvas");x(this,"fullScreen");x(this,"defaultCamera");x(this,"startTimer");x(this,"loaderDataSources",[]);x(this,"loaderDracoDecoderPath");x(this,"loadResourcesOnInit");x(this,"enableDebug");x(this,"enableControls");x(this,"axesSizes");x(this,"gridSizes");x(this,"withMiniCamera");x(this,"onReady")}}class pt{constructor(){x(this,"canvas");x(this,"onReady")}}var K={},ge={},D={},z={},Ne;function mt(){if(Ne)return z;Ne=1,Object.defineProperty(z,"__esModule",{value:!0}),z.getBundleURL=z.getBaseURL=void 0;let s;function e(){return s||(s=t()),s}z.getBundleURL=e;function t(){try{throw new Error}catch(r){const o=(""+r.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);if(o)return n(o[0])}return"/"}function n(r){return(""+r).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)?\/[^/]+(?:\?.*)?$/,"$1")+"/"}return z.getBaseURL=n,z}var De;function nt(){if(De)return D;De=1,Object.defineProperty(D,"__esModule",{value:!0}),D.isWorkerRuntime=D.getWorkerImplementation=D.defaultPoolSize=void 0;const s=mt();D.defaultPoolSize=typeof navigator<"u"&&navigator.hardwareConcurrency?navigator.hardwareConcurrency:4;const e=a=>/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(a);function t(a){const c=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(c)}function n(){if(typeof Worker>"u")return class{constructor(){throw Error("No web worker implementation available. You might have tried to spawn a worker within a worker in a browser that doesn't support workers in workers.")}};class a extends Worker{constructor(u,l){var f,p;typeof u=="string"&&l&&l._baseURL?u=new URL(u,l._baseURL):typeof u=="string"&&!e(u)&&s.getBundleURL().match(/^file:\/\//i)&&(u=new URL(u,s.getBundleURL().replace(/\/[^\/]+$/,"/")),(!((f=l==null?void 0:l.CORSWorkaround)!==null&&f!==void 0)||f)&&(u=t(`importScripts(${JSON.stringify(u)});`))),typeof u=="string"&&e(u)&&(!((p=l==null?void 0:l.CORSWorkaround)!==null&&p!==void 0)||p)&&(u=t(`importScripts(${JSON.stringify(u)});`)),super(u,l)}}class c extends a{constructor(u,l){const f=window.URL.createObjectURL(u);super(f,l)}static fromText(u,l){const f=new window.Blob([u],{type:"text/javascript"});return new c(f,l)}}return{blob:c,default:a}}let r;function o(){return r||(r=n()),r}D.getWorkerImplementation=o;function i(){const a=typeof self<"u"&&typeof Window<"u"&&self instanceof Window;return!!(typeof self<"u"&&self.postMessage&&!a)}return D.isWorkerRuntime=i,D}var $={},oe={exports:{}},_e,Fe;function gt(){if(Fe)return _e;Fe=1;var s=1e3,e=s*60,t=e*60,n=t*24,r=n*7,o=n*365.25;_e=function(u,l){l=l||{};var f=typeof u;if(f==="string"&&u.length>0)return i(u);if(f==="number"&&isFinite(u))return l.long?c(u):a(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function i(u){if(u=String(u),!(u.length>100)){var l=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(l){var f=parseFloat(l[1]),p=(l[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return f*o;case"weeks":case"week":case"w":return f*r;case"days":case"day":case"d":return f*n;case"hours":case"hour":case"hrs":case"hr":case"h":return f*t;case"minutes":case"minute":case"mins":case"min":case"m":return f*e;case"seconds":case"second":case"secs":case"sec":case"s":return f*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function a(u){var l=Math.abs(u);return l>=n?Math.round(u/n)+"d":l>=t?Math.round(u/t)+"h":l>=e?Math.round(u/e)+"m":l>=s?Math.round(u/s)+"s":u+"ms"}function c(u){var l=Math.abs(u);return l>=n?d(u,l,n,"day"):l>=t?d(u,l,t,"hour"):l>=e?d(u,l,e,"minute"):l>=s?d(u,l,s,"second"):u+" ms"}function d(u,l,f,p){var E=l>=f*1.5;return Math.round(u/f)+" "+p+(E?"s":"")}return _e}var ye,je;function _t(){if(je)return ye;je=1;function s(e){n.debug=n,n.default=n,n.coerce=d,n.disable=i,n.enable=o,n.enabled=a,n.humanize=gt(),n.destroy=u,Object.keys(e).forEach(l=>{n[l]=e[l]}),n.names=[],n.skips=[],n.formatters={};function t(l){let f=0;for(let p=0;p<l.length;p++)f=(f<<5)-f+l.charCodeAt(p),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=t;function n(l){let f,p=null,E,R;function v(...m){if(!v.enabled)return;const _=v,g=Number(new Date),T=g-(f||g);_.diff=T,_.prev=f,_.curr=g,f=g,m[0]=n.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let b=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(C,L)=>{if(C==="%%")return"%";b++;const S=n.formatters[L];if(typeof S=="function"){const A=m[b];C=S.call(_,A),m.splice(b,1),b--}return C}),n.formatArgs.call(_,m),(_.log||n.log).apply(_,m)}return v.namespace=l,v.useColors=n.useColors(),v.color=n.selectColor(l),v.extend=r,v.destroy=n.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(E!==n.namespaces&&(E=n.namespaces,R=n.enabled(l)),R),set:m=>{p=m}}),typeof n.init=="function"&&n.init(v),v}function r(l,f){const p=n(this.namespace+(typeof f>"u"?":":f)+l);return p.log=this.log,p}function o(l){n.save(l),n.namespaces=l,n.names=[],n.skips=[];let f;const p=(typeof l=="string"?l:"").split(/[\s,]+/),E=p.length;for(f=0;f<E;f++)p[f]&&(l=p[f].replace(/\*/g,".*?"),l[0]==="-"?n.skips.push(new RegExp("^"+l.slice(1)+"$")):n.names.push(new RegExp("^"+l+"$")))}function i(){const l=[...n.names.map(c),...n.skips.map(c).map(f=>"-"+f)].join(",");return n.enable(""),l}function a(l){if(l[l.length-1]==="*")return!0;let f,p;for(f=0,p=n.skips.length;f<p;f++)if(n.skips[f].test(l))return!1;for(f=0,p=n.names.length;f<p;f++)if(n.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function d(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}return ye=s,ye}var He;function Oe(){return He||(He=1,function(s,e){e.formatArgs=n,e.save=r,e.load=o,e.useColors=t,e.storage=i(),e.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function t(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function n(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+s.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;c.splice(1,0,d,"color: inherit");let u=0,l=0;c[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&(u++,f==="%c"&&(l=u))}),c.splice(l,0,d)}e.log=console.debug||console.log||(()=>{});function r(c){try{c?e.storage.setItem("debug",c):e.storage.removeItem("debug")}catch{}}function o(){let c;try{c=e.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function i(){try{return localStorage}catch{}}s.exports=_t()(e);const{formatters:a}=s.exports;a.j=function(c){try{return JSON.stringify(c)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}}(oe,oe.exports)),oe.exports}var yt=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})};class fe{constructor(e){this._baseObserver=e,this._pendingPromises=new Set}complete(){Promise.all(this._pendingPromises).then(()=>this._baseObserver.complete()).catch(e=>this._baseObserver.error(e))}error(e){this._baseObserver.error(e)}schedule(e){const t=Promise.all(this._pendingPromises),n=[],r=i=>n.push(i),o=Promise.resolve().then(()=>yt(this,void 0,void 0,function*(){yield t,yield e(r),this._pendingPromises.delete(o);for(const i of n)this._baseObserver.next(i)})).catch(i=>{this._pendingPromises.delete(o),this._baseObserver.error(i)});this._pendingPromises.add(o)}}const rt=()=>typeof Symbol=="function",ie=s=>rt()&&!!Symbol[s],Ie=s=>ie(s)?Symbol[s]:"@@"+s;ie("asyncIterator")||(Symbol.asyncIterator=Symbol.asyncIterator||Symbol.for("Symbol.asyncIterator"));const bt=Ie("iterator"),xe=Ie("observable"),st=Ie("species");function ce(s,e){const t=s[e];if(t!=null){if(typeof t!="function")throw new TypeError(t+" is not a function");return t}}function J(s){let e=s.constructor;return e!==void 0&&(e=e[st],e===null&&(e=void 0)),e!==void 0?e:P}function Tt(s){return s instanceof P}function Y(s){Y.log?Y.log(s):setTimeout(()=>{throw s},0)}function ae(s){Promise.resolve().then(()=>{try{s()}catch(e){Y(e)}})}function it(s){const e=s._cleanup;if(e!==void 0&&(s._cleanup=void 0,!!e))try{if(typeof e=="function")e();else{const t=ce(e,"unsubscribe");t&&t.call(e)}}catch(t){Y(t)}}function Me(s){s._observer=void 0,s._queue=void 0,s._state="closed"}function wt(s){const e=s._queue;if(e){s._queue=void 0,s._state="ready";for(const t of e)if(ot(s,t.type,t.value),s._state==="closed")break}}function ot(s,e,t){s._state="running";const n=s._observer;try{const r=n?ce(n,e):void 0;switch(e){case"next":r&&r.call(n,t);break;case"error":if(Me(s),r)r.call(n,t);else throw t;break;case"complete":Me(s),r&&r.call(n);break}}catch(r){Y(r)}s._state==="closed"?it(s):s._state==="running"&&(s._state="ready")}function be(s,e,t){if(s._state!=="closed"){if(s._state==="buffering"){s._queue=s._queue||[],s._queue.push({type:e,value:t});return}if(s._state!=="ready"){s._state="buffering",s._queue=[{type:e,value:t}],ae(()=>wt(s));return}ot(s,e,t)}}class vt{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";const n=new Et(this);try{this._cleanup=t.call(void 0,n)}catch(r){n.error(r)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(Me(this),it(this))}}class Et{constructor(e){this._subscription=e}get closed(){return this._subscription._state==="closed"}next(e){be(this._subscription,"next",e)}error(e){be(this._subscription,"error",e)}complete(){be(this._subscription,"complete")}}class P{constructor(e){if(!(this instanceof P))throw new TypeError("Observable cannot be called as a function");if(typeof e!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e,t,n){return(typeof e!="object"||e===null)&&(e={next:e,error:t,complete:n}),new vt(e,this._subscriber)}pipe(e,...t){let n=this;for(const r of[e,...t])n=r(n);return n}tap(e,t,n){const r=typeof e!="object"||e===null?{next:e,error:t,complete:n}:e;return new P(o=>this.subscribe({next(i){r.next&&r.next(i),o.next(i)},error(i){r.error&&r.error(i),o.error(i)},complete(){r.complete&&r.complete(),o.complete()},start(i){r.start&&r.start(i)}}))}forEach(e){return new Promise((t,n)=>{if(typeof e!="function"){n(new TypeError(e+" is not a function"));return}function r(){o.unsubscribe(),t(void 0)}const o=this.subscribe({next(i){try{e(i,r)}catch(a){n(a),o.unsubscribe()}},error(i){n(i)},complete(){t(void 0)}})})}map(e){if(typeof e!="function")throw new TypeError(e+" is not a function");const t=J(this);return new t(n=>this.subscribe({next(r){let o=r;try{o=e(r)}catch(i){return n.error(i)}n.next(o)},error(r){n.error(r)},complete(){n.complete()}}))}filter(e){if(typeof e!="function")throw new TypeError(e+" is not a function");const t=J(this);return new t(n=>this.subscribe({next(r){try{if(!e(r))return}catch(o){return n.error(o)}n.next(r)},error(r){n.error(r)},complete(){n.complete()}}))}reduce(e,t){if(typeof e!="function")throw new TypeError(e+" is not a function");const n=J(this),r=arguments.length>1;let o=!1,i=t;return new n(a=>this.subscribe({next(c){const d=!o;if(o=!0,!d||r)try{i=e(i,c)}catch(u){return a.error(u)}else i=c},error(c){a.error(c)},complete(){if(!o&&!r)return a.error(new TypeError("Cannot reduce an empty sequence"));a.next(i),a.complete()}}))}concat(...e){const t=J(this);return new t(n=>{let r,o=0;function i(a){r=a.subscribe({next(c){n.next(c)},error(c){n.error(c)},complete(){o===e.length?(r=void 0,n.complete()):i(t.from(e[o++]))}})}return i(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(e){if(typeof e!="function")throw new TypeError(e+" is not a function");const t=J(this);return new t(n=>{const r=[],o=this.subscribe({next(a){let c;if(e)try{c=e(a)}catch(u){return n.error(u)}else c=a;const d=t.from(c).subscribe({next(u){n.next(u)},error(u){n.error(u)},complete(){const u=r.indexOf(d);u>=0&&r.splice(u,1),i()}});r.push(d)},error(a){n.error(a)},complete(){i()}});function i(){o.closed&&r.length===0&&n.complete()}return()=>{r.forEach(a=>a.unsubscribe()),o.unsubscribe()}})}[xe](){return this}static from(e){const t=typeof this=="function"?this:P;if(e==null)throw new TypeError(e+" is not an object");const n=ce(e,xe);if(n){const r=n.call(e);if(Object(r)!==r)throw new TypeError(r+" is not an object");return Tt(r)&&r.constructor===t?r:new t(o=>r.subscribe(o))}if(ie("iterator")){const r=ce(e,bt);if(r)return new t(o=>{ae(()=>{if(!o.closed){for(const i of r.call(e))if(o.next(i),o.closed)return;o.complete()}})})}if(Array.isArray(e))return new t(r=>{ae(()=>{if(!r.closed){for(const o of e)if(r.next(o),r.closed)return;r.complete()}})});throw new TypeError(e+" is not observable")}static of(...e){const t=typeof this=="function"?this:P;return new t(n=>{ae(()=>{if(!n.closed){for(const r of e)if(n.next(r),n.closed)return;n.complete()}})})}static get[st](){return this}}rt()&&Object.defineProperty(P,Symbol("extensions"),{value:{symbol:xe,hostReportError:Y},configurable:!0});function q(s){typeof s=="function"?s():s&&typeof s.unsubscribe=="function"&&s.unsubscribe()}var Ct=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})};function Rt(s){return e=>new P(t=>{const n=new fe(t),r=e.subscribe({complete(){n.complete()},error(o){n.error(o)},next(o){n.schedule(i=>Ct(this,void 0,void 0,function*(){(yield s(o))&&i(o)}))}});return()=>q(r)})}function St(s){return s&&ie("asyncIterator")&&s[Symbol.asyncIterator]}function xt(s){return s&&ie("iterator")&&s[Symbol.iterator]}var Mt=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})},Lt=function(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=s[Symbol.asyncIterator],t;return e?e.call(s):(s=typeof __values=="function"?__values(s):s[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=s[o]&&function(i){return new Promise(function(a,c){i=s[o](i),r(a,c,i.done,i.value)})}}function r(o,i,a,c){Promise.resolve(c).then(function(d){o({value:d,done:a})},i)}};function At(s){return e=>new P(t=>{const n=new fe(t),r=e.subscribe({complete(){n.complete()},error(o){n.error(o)},next(o){n.schedule(i=>Mt(this,void 0,void 0,function*(){var a,c;const d=yield s(o);if(xt(d)||St(d))try{for(var u=Lt(d),l;l=yield u.next(),!l.done;){const f=l.value;i(f)}}catch(f){a={error:f}}finally{try{l&&!l.done&&(c=u.return)&&(yield c.call(u))}finally{if(a)throw a.error}}else d.map(f=>i(f))}))}});return()=>q(r)})}function kt(s){return new P(e=>{let t=0;const n=setInterval(()=>{e.next(t++)},s);return()=>clearInterval(n)})}var Pt=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})};function Ot(s){return e=>new P(t=>{const n=new fe(t),r=e.subscribe({complete(){n.complete()},error(o){n.error(o)},next(o){n.schedule(i=>Pt(this,void 0,void 0,function*(){const a=yield s(o);i(a)}))}});return()=>q(r)})}function It(...s){return s.length===0?P.from([]):new P(e=>{let t=0;const n=s.map(o=>o.subscribe({error(i){e.error(i),r()},next(i){e.next(i)},complete(){++t===s.length&&(e.complete(),r())}})),r=()=>{n.forEach(o=>q(o))};return r})}class at extends P{constructor(){super(e=>(this._observers.add(e),()=>this._observers.delete(e))),this._observers=new Set}next(e){for(const t of this._observers)t.next(e)}error(e){for(const t of this._observers)t.error(e)}complete(){for(const e of this._observers)e.complete()}}function Nt(s){const e=new at;let t,n=0;return new P(r=>{t||(t=s.subscribe(e));const o=e.subscribe(r);return n++,()=>{n--,o.unsubscribe(),n===0&&(q(t),t=void 0)}})}var Dt=function(s,e,t,n){function r(o){return o instanceof t?o:new t(function(i){i(o)})}return new(t||(t=Promise))(function(o,i){function a(u){try{d(n.next(u))}catch(l){i(l)}}function c(u){try{d(n.throw(u))}catch(l){i(l)}}function d(u){u.done?o(u.value):r(u.value).then(a,c)}d((n=n.apply(s,e||[])).next())})};function Ft(s,e){return t=>new P(n=>{let r,o=0;const i=new fe(n),a=t.subscribe({complete(){i.complete()},error(c){i.error(c)},next(c){i.schedule(d=>Dt(this,void 0,void 0,function*(){r=yield s(o===0?typeof e>"u"?c:e:r,c,o++),d(r)}))}});return()=>q(a)})}const jt=Object.freeze(Object.defineProperty({__proto__:null,Observable:P,Subject:at,filter:Rt,flatMap:At,interval:kt,map:Ot,merge:It,multicast:Nt,scan:Ft,unsubscribe:q},Symbol.toStringTag,{value:"Module"})),he=y.getAugmentedNamespace(jt);var Z={},Ue;function Ht(){if(Ue)return Z;Ue=1,Object.defineProperty(Z,"__esModule",{value:!0}),Z.allSettled=void 0;function s(e){return Promise.all(e.map(t=>{const n=i=>({status:"fulfilled",value:i}),r=i=>({status:"rejected",reason:i}),o=Promise.resolve(t);try{return o.then(n,r)}catch(i){return Promise.reject(i)}}))}return Z.allSettled=s,Z}var Te={},Be;function Ut(){return Be||(Be=1,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.PoolEventType=void 0,function(e){e.initialized="initialized",e.taskCanceled="taskCanceled",e.taskCompleted="taskCompleted",e.taskFailed="taskFailed",e.taskQueued="taskQueued",e.taskQueueDrained="taskQueueDrained",e.taskStart="taskStart",e.terminated="terminated"}(s.PoolEventType||(s.PoolEventType={}))}(Te)),Te}var ee={},Ge;function ct(){if(Ge)return ee;Ge=1,Object.defineProperty(ee,"__esModule",{value:!0}),ee.Thread=void 0;const s=y.requireSymbols();function e(t){throw Error(t)}return ee.Thread={errors(t){return t[s.$errors]||e("Error observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},events(t){return t[s.$events]||e("Events observable not found. Make sure to pass a thread instance as returned by the spawn() promise.")},terminate(t){return t[s.$terminate]()}},ee}var We;function Bt(){return We||(We=1,function(s){var e=$&&$.__awaiter||function(m,_,g,T){function b(w){return w instanceof g?w:new g(function(C){C(w)})}return new(g||(g=Promise))(function(w,C){function L(k){try{A(T.next(k))}catch(I){C(I)}}function S(k){try{A(T.throw(k))}catch(I){C(I)}}function A(k){k.done?w(k.value):b(k.value).then(L,S)}A((T=T.apply(m,_||[])).next())})},t=$&&$.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(s,"__esModule",{value:!0}),s.Pool=s.Thread=s.PoolEventType=void 0;const n=t(Oe()),r=he,o=Ht(),i=nt(),a=Ut();Object.defineProperty(s,"PoolEventType",{enumerable:!0,get:function(){return a.PoolEventType}});const c=ct();Object.defineProperty(s,"Thread",{enumerable:!0,get:function(){return c.Thread}});let d=1;function u(m){const _=[];for(let g=0;g<m;g++)_.push(g);return _}function l(m){return new Promise(_=>setTimeout(_,m))}function f(m,_){return m.reduce((g,T)=>[...g,..._(T)],[])}function p(m){return m.replace(/\W/g," ").trim().replace(/\s+/g,"-")}function E(m,_){return u(_).map(()=>({init:m(),runningTasks:[]}))}class R{constructor(_,g){this.eventSubject=new r.Subject,this.initErrors=[],this.isClosing=!1,this.nextTaskID=1,this.taskQueue=[];const T=typeof g=="number"?{size:g}:g||{},{size:b=i.defaultPoolSize}=T;this.debug=n.default(`threads:pool:${p(T.name||String(d++))}`),this.options=T,this.workers=E(_,b),this.eventObservable=r.multicast(r.Observable.from(this.eventSubject)),Promise.all(this.workers.map(w=>w.init)).then(()=>this.eventSubject.next({type:a.PoolEventType.initialized,size:this.workers.length}),w=>{this.debug("Error while initializing pool worker:",w),this.eventSubject.error(w),this.initErrors.push(w)})}findIdlingWorker(){const{concurrency:_=1}=this.options;return this.workers.find(g=>g.runningTasks.length<_)}runPoolTask(_,g){return e(this,void 0,void 0,function*(){const T=this.workers.indexOf(_)+1;this.debug(`Running task #${g.id} on worker #${T}...`),this.eventSubject.next({type:a.PoolEventType.taskStart,taskID:g.id,workerID:T});try{const b=yield g.run(yield _.init);this.debug(`Task #${g.id} completed successfully`),this.eventSubject.next({type:a.PoolEventType.taskCompleted,returnValue:b,taskID:g.id,workerID:T})}catch(b){this.debug(`Task #${g.id} failed`),this.eventSubject.next({type:a.PoolEventType.taskFailed,taskID:g.id,error:b,workerID:T})}})}run(_,g){return e(this,void 0,void 0,function*(){const T=e(this,void 0,void 0,function*(){const b=()=>{_.runningTasks=_.runningTasks.filter(w=>w!==T)};yield l(0);try{yield this.runPoolTask(_,g)}finally{b(),this.isClosing||this.scheduleWork()}});_.runningTasks.push(T)})}scheduleWork(){this.debug("Attempt de-queueing a task in order to run it...");const _=this.findIdlingWorker();if(!_)return;const g=this.taskQueue.shift();if(!g){this.debug("Task queue is empty"),this.eventSubject.next({type:a.PoolEventType.taskQueueDrained});return}this.run(_,g)}taskCompletion(_){return new Promise((g,T)=>{const b=this.events().subscribe(w=>{w.type===a.PoolEventType.taskCompleted&&w.taskID===_?(b.unsubscribe(),g(w.returnValue)):w.type===a.PoolEventType.taskFailed&&w.taskID===_?(b.unsubscribe(),T(w.error)):w.type===a.PoolEventType.terminated&&(b.unsubscribe(),T(Error("Pool has been terminated before task was run.")))})})}settled(_=!1){return e(this,void 0,void 0,function*(){const g=()=>f(this.workers,w=>w.runningTasks),T=[],b=this.eventObservable.subscribe(w=>{w.type===a.PoolEventType.taskFailed&&T.push(w.error)});return this.initErrors.length>0?Promise.reject(this.initErrors[0]):_&&this.taskQueue.length===0?(yield o.allSettled(g()),T):(yield new Promise((w,C)=>{const L=this.eventObservable.subscribe({next(S){S.type===a.PoolEventType.taskQueueDrained&&(L.unsubscribe(),w(void 0))},error:C})}),yield o.allSettled(g()),b.unsubscribe(),T)})}completed(_=!1){return e(this,void 0,void 0,function*(){const g=this.settled(_),T=new Promise((w,C)=>{const L=this.eventObservable.subscribe({next(S){S.type===a.PoolEventType.taskQueueDrained?(L.unsubscribe(),w(g)):S.type===a.PoolEventType.taskFailed&&(L.unsubscribe(),C(S.error))},error:C})}),b=yield Promise.race([g,T]);if(b.length>0)throw b[0]})}events(){return this.eventObservable}queue(_){const{maxQueuedJobs:g=1/0}=this.options;if(this.isClosing)throw Error("Cannot schedule pool tasks after terminate() has been called.");if(this.initErrors.length>0)throw this.initErrors[0];const T=this.nextTaskID++,b=this.taskCompletion(T);b.catch(C=>{this.debug(`Task #${T} errored:`,C)});const w={id:T,run:_,cancel:()=>{this.taskQueue.indexOf(w)!==-1&&(this.taskQueue=this.taskQueue.filter(C=>C!==w),this.eventSubject.next({type:a.PoolEventType.taskCanceled,taskID:w.id}))},then:b.then.bind(b)};if(this.taskQueue.length>=g)throw Error(`Maximum number of pool tasks queued. Refusing to queue another one.
|
|
2
|
+
This usually happens for one of two reasons: We are either at peak workload right now or some tasks just won't finish, thus blocking the pool.`);return this.debug(`Queueing task #${w.id}...`),this.taskQueue.push(w),this.eventSubject.next({type:a.PoolEventType.taskQueued,taskID:w.id}),this.scheduleWork(),w}terminate(_){return e(this,void 0,void 0,function*(){this.isClosing=!0,_||(yield this.completed(!0)),this.eventSubject.next({type:a.PoolEventType.terminated,remainingQueue:[...this.taskQueue]}),this.eventSubject.complete(),yield Promise.all(this.workers.map(g=>e(this,void 0,void 0,function*(){return c.Thread.terminate(yield g.init)})))})}}R.EventType=a.PoolEventType;function v(m,_){return new R(m,_)}v.EventType=a.PoolEventType,s.Pool=v}($)),$}var F={},te={},Ke;function Gt(){if(Ke)return te;Ke=1,Object.defineProperty(te,"__esModule",{value:!0}),te.createPromiseWithResolver=void 0;const s=()=>{};function e(){let t=!1,n,r=s;return[new Promise(a=>{t?a(n):r=a}),a=>{t=!0,n=a,r(n)}]}return te.createPromiseWithResolver=e,te}var we={},ze;function Wt(){return ze||(ze=1,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.WorkerEventType=void 0,function(e){e.internalError="internalError",e.message="message",e.termination="termination"}(s.WorkerEventType||(s.WorkerEventType={}))}(we)),we}var j={},ne={},$e;function Kt(){if($e)return ne;$e=1,Object.defineProperty(ne,"__esModule",{value:!0}),ne.ObservablePromise=void 0;const s=he,e=()=>{},t=a=>a,n=a=>Promise.resolve().then(a);function r(a){throw a}function o(a){return a&&typeof a.then=="function"}class i extends s.Observable{constructor(c){super(d=>{const u=this,l=Object.assign(Object.assign({},d),{complete(){d.complete(),u.onCompletion()},error(f){d.error(f),u.onError(f)},next(f){d.next(f),u.onNext(f)}});try{return this.initHasRun=!0,c(l)}catch(f){l.error(f)}}),this.initHasRun=!1,this.fulfillmentCallbacks=[],this.rejectionCallbacks=[],this.firstValueSet=!1,this.state="pending"}onNext(c){this.firstValueSet||(this.firstValue=c,this.firstValueSet=!0)}onError(c){this.state="rejected",this.rejection=c;for(const d of this.rejectionCallbacks)n(()=>d(c))}onCompletion(){this.state="fulfilled";for(const c of this.fulfillmentCallbacks)n(()=>c(this.firstValue))}then(c,d){const u=c||t,l=d||r;let f=!1;return new Promise((p,E)=>{const R=m=>{if(!f){f=!0;try{p(l(m))}catch(_){E(_)}}},v=m=>{try{p(u(m))}catch(_){R(_)}};if(this.initHasRun||this.subscribe({error:R}),this.state==="fulfilled")return p(u(this.firstValue));if(this.state==="rejected")return f=!0,p(l(this.rejection));this.fulfillmentCallbacks.push(v),this.rejectionCallbacks.push(R)})}catch(c){return this.then(void 0,c)}finally(c){const d=c||e;return this.then(u=>(d(),u),()=>d())}static from(c){return o(c)?new i(d=>{const u=f=>{d.next(f),d.complete()},l=f=>{d.error(f)};c.then(u,l)}):super.from(c)}}return ne.ObservablePromise=i,ne}var Ve;function zt(){if(Ve)return j;Ve=1;var s=j&&j.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(j,"__esModule",{value:!0}),j.createProxyModule=j.createProxyFunction=void 0;const e=s(Oe()),t=he,n=y.requireCommon(),r=Kt(),o=y.requireTransferable(),i=y.requireMessages(),a=e.default("threads:master:messages");let c=1;const d=m=>Array.from(new Set(m)),u=m=>m&&m.type===i.WorkerMessageType.error,l=m=>m&&m.type===i.WorkerMessageType.result,f=m=>m&&m.type===i.WorkerMessageType.running;function p(m,_){return new t.Observable(g=>{let T;const b=w=>{if(a("Message from worker:",w.data),!(!w.data||w.data.uid!==_)){if(f(w.data))T=w.data.resultType;else if(l(w.data))T==="promise"?(typeof w.data.payload<"u"&&g.next(n.deserialize(w.data.payload)),g.complete(),m.removeEventListener("message",b)):(w.data.payload&&g.next(n.deserialize(w.data.payload)),w.data.complete&&(g.complete(),m.removeEventListener("message",b)));else if(u(w.data)){const C=n.deserialize(w.data.error);g.error(C),m.removeEventListener("message",b)}}};return m.addEventListener("message",b),()=>{if(T==="observable"||!T){const w={type:i.MasterMessageType.cancel,uid:_};m.postMessage(w)}m.removeEventListener("message",b)}})}function E(m){if(m.length===0)return{args:[],transferables:[]};const _=[],g=[];for(const T of m)o.isTransferDescriptor(T)?(_.push(n.serialize(T.send)),g.push(...T.transferables)):_.push(n.serialize(T));return{args:_,transferables:g.length===0?g:d(g)}}function R(m,_){return(...g)=>{const T=c++,{args:b,transferables:w}=E(g),C={type:i.MasterMessageType.run,uid:T,method:_,args:b};a("Sending command to run function to worker:",C);try{m.postMessage(C,w)}catch(L){return r.ObservablePromise.from(Promise.reject(L))}return r.ObservablePromise.from(t.multicast(p(m,T)))}}j.createProxyFunction=R;function v(m,_){const g={};for(const T of _)g[T]=R(m,T);return g}return j.createProxyModule=v,j}var qe;function $t(){if(qe)return F;qe=1;var s=F&&F.__awaiter||function(b,w,C,L){function S(A){return A instanceof C?A:new C(function(k){k(A)})}return new(C||(C=Promise))(function(A,k){function I(W){try{pe(L.next(W))}catch(me){k(me)}}function G(W){try{pe(L.throw(W))}catch(me){k(me)}}function pe(W){W.done?A(W.value):S(W.value).then(I,G)}pe((L=L.apply(b,w||[])).next())})},e=F&&F.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(F,"__esModule",{value:!0}),F.spawn=void 0;const t=e(Oe()),n=he,r=y.requireCommon(),o=Gt(),i=y.requireSymbols(),a=Wt(),c=zt(),d=t.default("threads:master:messages"),u=t.default("threads:master:spawn"),l=t.default("threads:master:thread-utils"),f=b=>b&&b.type==="init",p=b=>b&&b.type==="uncaughtError",E=typeof process<"u"&&process.env.THREADS_WORKER_INIT_TIMEOUT?Number.parseInt(process.env.THREADS_WORKER_INIT_TIMEOUT,10):1e4;function R(b,w,C){return s(this,void 0,void 0,function*(){let L;const S=new Promise((k,I)=>{L=setTimeout(()=>I(Error(C)),w)}),A=yield Promise.race([b,S]);return clearTimeout(L),A})}function v(b){return new Promise((w,C)=>{const L=S=>{d("Message from worker before finishing initialization:",S.data),f(S.data)?(b.removeEventListener("message",L),w(S.data)):p(S.data)&&(b.removeEventListener("message",L),C(r.deserialize(S.data.error)))};b.addEventListener("message",L)})}function m(b,w){return new n.Observable(C=>{const L=A=>{const k={type:a.WorkerEventType.message,data:A.data};C.next(k)},S=A=>{l("Unhandled promise rejection event in thread:",A);const k={type:a.WorkerEventType.internalError,error:Error(A.reason)};C.next(k)};b.addEventListener("message",L),b.addEventListener("unhandledrejection",S),w.then(()=>{const A={type:a.WorkerEventType.termination};b.removeEventListener("message",L),b.removeEventListener("unhandledrejection",S),C.next(A),C.complete()})})}function _(b){const[w,C]=o.createPromiseWithResolver();return{terminate:()=>s(this,void 0,void 0,function*(){l("Terminating worker"),yield b.terminate(),C()}),termination:w}}function g(b,w,C,L){const S=C.filter(A=>A.type===a.WorkerEventType.internalError).map(A=>A.error);return Object.assign(b,{[i.$errors]:S,[i.$events]:C,[i.$terminate]:L,[i.$worker]:w})}function T(b,w){return s(this,void 0,void 0,function*(){u("Initializing new thread");const C=w&&w.timeout?w.timeout:E,S=(yield R(v(b),C,`Timeout: Did not receive an init message from worker after ${C}ms. Make sure the worker calls expose().`)).exposed,{termination:A,terminate:k}=_(b),I=m(b,A);if(S.type==="function"){const G=c.createProxyFunction(b);return g(G,b,I,k)}else if(S.type==="module"){const G=c.createProxyModule(b,S.methods);return g(G,b,I,k)}else{const G=S.type;throw Error(`Worker init message states unexpected type of expose(): ${G}`)}})}return F.spawn=T,F}var Xe;function Vt(){return Xe||(Xe=1,function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.Worker=s.BlobWorker=s.isWorkerRuntime=s.Thread=s.spawn=s.Pool=void 0;const e=nt();Object.defineProperty(s,"isWorkerRuntime",{enumerable:!0,get:function(){return e.isWorkerRuntime}});var t=Bt();Object.defineProperty(s,"Pool",{enumerable:!0,get:function(){return t.Pool}});var n=$t();Object.defineProperty(s,"spawn",{enumerable:!0,get:function(){return n.spawn}});var r=ct();Object.defineProperty(s,"Thread",{enumerable:!0,get:function(){return r.Thread}}),s.BlobWorker=e.getWorkerImplementation().blob,s.Worker=e.getWorkerImplementation().default}(ge)),ge}var Qe;function qt(){return Qe||(Qe=1,function(s){var e=K&&K.__createBinding||(Object.create?function(a,c,d,u){u===void 0&&(u=d),Object.defineProperty(a,u,{enumerable:!0,get:function(){return c[d]}})}:function(a,c,d,u){u===void 0&&(u=d),a[u]=c[d]}),t=K&&K.__exportStar||function(a,c){for(var d in a)d!=="default"&&!Object.prototype.hasOwnProperty.call(c,d)&&e(c,a,d)};Object.defineProperty(s,"__esModule",{value:!0}),s.Transfer=s.DefaultSerializer=s.expose=s.registerSerializer=void 0;var n=y.requireCommon();Object.defineProperty(s,"registerSerializer",{enumerable:!0,get:function(){return n.registerSerializer}}),t(Vt(),s);var r=y.requireWorker();Object.defineProperty(s,"expose",{enumerable:!0,get:function(){return r.expose}});var o=y.requireSerializers();Object.defineProperty(s,"DefaultSerializer",{enumerable:!0,get:function(){return o.DefaultSerializer}});var i=y.requireTransferable();Object.defineProperty(s,"Transfer",{enumerable:!0,get:function(){return i.Transfer}})}(K)),K}var Xt=qt();const B=y.getDefaultExportFromCjs(Xt);B.registerSerializer;const Qt=B.spawn;B.BlobWorker;B.DefaultSerializer;B.Pool;const Yt=B.Thread;B.Transfer;const Jt=B.Worker;var Zt=Object.defineProperty,en=(s,e,t)=>e in s?Zt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,H=(s,e,t)=>en(s,typeof e!="symbol"?e+"":e,t);const tn=()=>{try{if(window){if(navigator!=null&&navigator.hardwareConcurrency)return navigator.hardwareConcurrency;throw new Error("Unable to determine the number of cores")}else return require("os").cpus().length}catch(s){return console.error("🛑 Unable to detect available cores",s),2}},nn=()=>tn()-1,rn="TERMINATE_THREAD_FROM_WORKER";let sn=-1;class on{constructor(e){H(this,"_handleTerminate"),H(this,"_handleError"),H(this,"_task"),H(this,"id",sn+=1),H(this,"idle",!0),H(this,"worker"),H(this,"thread"),this._handleTerminate=e==null?void 0:e.onTerminate,this._handleError=e==null?void 0:e.onError}_handleMessages(e){var t;e instanceof MessageEvent&&((t=e.data)==null?void 0:t.token)===rn&&this.terminate()}async run(e){var t;try{const{payload:n,options:r}=e;return this.idle=!1,this.worker=new Jt(n.path,{type:"module",...r==null?void 0:r.worker}),this.thread=await Qt(this.worker,{timeout:1e4,...r==null?void 0:r.spawn}),this._task=e,this.worker.postMessage(n.subject,n.transferSubject),this.worker.addEventListener("message",this._handleMessages.bind(this)),this}catch(n){(t=this._handleError)==null||t.call(this,n);return}}get task(){return this._task}async terminate(){var e,t,n;(e=this.worker)==null||e.removeEventListener("message",this._handleMessages.bind(this)),this.thread&&await Yt.terminate(this.thread),await((t=this.worker)==null?void 0:t.terminate()),this.worker=void 0,this.thread=void 0,this._task=void 0,this.idle=!0,(n=this._handleTerminate)==null||n.call(this)}}class an{constructor(e,t,n){H(this,"_workerThreads",[]),H(this,"_tasksQueue",[]),this.maxWorkersCount=e,this.debugMode=t,this.onWorkerThreadRun=n;for(let r=0;r<this.maxWorkersCount;r++)this._workerThreads.push(this._createWorkerThread())}_handleWorkerThreadTerminate(e){this.debugMode&&console.log(`WorkerThread #${e.id} freed`),this.runNext()}_handleWorkerThreadError(e,t){console.error(`Error from worker #${t.id}:`,e),this.runNext()}_createWorkerThread(){const e=new on({onTerminate:()=>this._handleWorkerThreadTerminate(e),onError:t=>this._handleWorkerThreadError(t,e)});return e}get workerThreads(){return this._workerThreads}get tasksQueue(){return this._tasksQueue}get nextAvailableWorkerThread(){return this._workerThreads.find(e=>e.idle)}getAvailableWorkerThreads(e=!1){return this._workerThreads.filter(t=>e?!t.idle:t.idle)}async runNext(){if(!this.nextAvailableWorkerThread||this._tasksQueue.length===0)return;const e=this._tasksQueue.shift();e&&await this.run(e)}async run(e,t=!1){var n;if(t){const i=this._createWorkerThread();return this.debugMode&&console.log(`Running On Untracked Thread #${i==null?void 0:i.id}. Task:`,e),[await i.run(e),!0]}const r=this.nextAvailableWorkerThread;if(!r)return this._tasksQueue.push(e),this.debugMode&&console.log("Queued Thread Task:",e),[void 0,!0];this.debugMode&&console.log(`Running On Thread #${r==null?void 0:r.id}. Task:`,e);const o=await r.run(e);if(o)return(n=this.onWorkerThreadRun)==null||n.call(this,o),[o,!1]}async terminateAll(){this._tasksQueue=[],await Promise.all(this._workerThreads.map(e=>e.terminate()))}}const cn=(s,e)=>new an(nn(),!!e);var un=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,dn=(s,e,t,n)=>{for(var r=n>1?void 0:n?ln(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&un(e,t,r),r},fn=(s,e)=>(t,n)=>e(t,n,s);let ue=class{constructor(s){x(this,"workerPool");x(this,"canvas");x(this,"offscreenCanvas");x(this,"worker");x(this,"thread");this._props=s,this.workerPool=cn(void 0,this._props.enableDebug)}init(s){this.worker=s.worker,this.thread=s.thread}preventDefaultHandler(s){return s.preventDefault(),{type:s.type}}getScreenSizes(){var s,e;return{width:(s=this.canvas)==null?void 0:s.width,height:(e=this.canvas)==null?void 0:e.height,windowWidth:(window==null?void 0:window.innerWidth)??0,windowHeight:(window==null?void 0:window.innerHeight)??0}}uiEventHandler(s){var t;const e=(t=this.canvas)==null?void 0:t.getBoundingClientRect();return{...this.getScreenSizes(),type:s.type,top:e==null?void 0:e.top,left:e==null?void 0:e.left}}mouseEventHandler(s){return{...this.getScreenSizes(),...y.R(s,["ctrlKey","metaKey","shiftKey","button","pointerType","clientX","clientY","pageX","pageY"])}}touchEventHandler(s){const e=[],t={type:s.type,touches:e};for(let n=0;n<s.touches.length;++n){const r=s.touches[n];e.push({pageX:(r==null?void 0:r.pageX)??0,pageY:(r==null?void 0:r.pageY)??0})}return{...this.getScreenSizes(),...t}}wheelEventHandler(s){return s.preventDefault(),{...this.getScreenSizes(),...y.R(s,["deltaX","deltaY"])}}keyEventHandler(s){if(y.KEYBOARD_EVENT_CODES.includes(s.code))return s.preventDefault(),{...this.getScreenSizes(),...y.R(s,["ctrlKey","metaKey","shiftKey","keyCode"])}}};ue=dn([y.scoped(y.Lifecycle.ContainerScoped),fn(0,y.inject(se))],ue);var hn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,mn=(s,e,t,n)=>{for(var r=n>1?void 0:n?pn(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&hn(e,t,r),r},gn=(s,e)=>(t,n)=>e(t,n,s);let Le=class extends y.ProxyEventHandlersBlueprint{constructor(s){super(),this._service=s}init(){let s;try{s=y.instance.resolve("MAIN_THREAD_APP")}catch{s=void 0}for(const e of y.PROXY_EVENT_LISTENERS){const t=e.startsWith("mouse")||e.startsWith("pointer")||e.startsWith("touch")?this._service.mouseEventHandler.bind(this._service):e.startsWith("key")?this._service.keyEventHandler.bind(this._service):e==="resize"?this._service.uiEventHandler.bind(this._service):e==="wheel"?this._service.wheelEventHandler.bind(this._service):this._service.preventDefaultHandler.bind(this._service);this[`${e}$$`]=new y.Subject,y.fromEvent(e==="resize"?window:this._service.canvas,e).pipe(y.map(t.bind(this)),y.filter(n=>!(e==="keydown"&&!n))).subscribe(n=>{this[`${e}$$`].next(n)}),this[`${e}$`]=this[`${e}$$`].asObservable(),this[`${e}$`].subscribe(n=>{var r,o,i;(o=(r=this._service.thread)==null?void 0:r[e])==null||o.call(r,n),(i=s==null?void 0:s[e])==null||i.call(s,n)})}}};Le=mn([y.scoped(y.Lifecycle.ContainerScoped),gn(0,y.inject(ue))],Le);function Ye(s,e){if(e===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===h.TriangleFanDrawMode||e===h.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 n=t.count-2,r=[];if(e===h.TriangleFanDrawMode)for(let i=1;i<=n;i++)r.push(t.getX(0)),r.push(t.getX(i)),r.push(t.getX(i+1));else for(let i=0;i<n;i++)i%2===0?(r.push(t.getX(i)),r.push(t.getX(i+1)),r.push(t.getX(i+2))):(r.push(t.getX(i+2)),r.push(t.getX(i+1)),r.push(t.getX(i)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=s.clone();return o.setIndex(r),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}const ve=new WeakMap;class ut extends h.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const o=new h.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,i=>{this.parse(i,t,r)},n,r)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,h.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,r,o=h.LinearSRGBColorSpace,i=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:o};return this.decodeGeometry(e,a).then(t).catch(i)}decodeGeometry(e,t){const n=JSON.stringify(t);if(ve.has(e)){const c=ve.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const o=this.workerNextTaskID++,i=e.byteLength,a=this._getWorker(o,i).then(c=>(r=c,new Promise((d,u)=>{r._callbacks[o]={resolve:d,reject:u},r.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{r&&o&&this._releaseTask(r,o)}),ve.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new h.BufferGeometry;e.index&&t.setIndex(new h.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],o=r.name,i=r.array,a=r.itemSize,c=new h.BufferAttribute(i,a);o==="color"&&(this._assignVertexColorSpace(c,r.vertexColorSpace),c.normalized=!(i instanceof Float32Array)),t.setAttribute(o,c)}return t}_assignVertexColorSpace(e,t){if(t!==h.SRGBColorSpace)return;const n=new h.Color;for(let r=0,o=e.count;r<o;r++)n.fromBufferAttribute(e,r),h.ColorManagement.colorSpaceToWorking(n,h.SRGBColorSpace),e.setXYZ(r,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new h.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((r,o)=>{n.load(e,r,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const r=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=_n.toString(),i=["/* draco decoder */",r,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
|
|
3
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(o){const i=o.data;switch(i.type){case"decode":r._callbacks[i.id].resolve(i);break;case"error":r._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,o){return r._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function _n(){let s,e;onmessage=function(i){const a=i.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise(function(u){s.onModuleLoaded=function(l){u({draco:l})},DracoDecoderModule(s)});break;case"decode":const c=a.buffer,d=a.taskConfig;e.then(u=>{const l=u.draco,f=new l.Decoder;try{const p=t(l,f,new Int8Array(c),d),E=p.attributes.map(R=>R.array.buffer);p.index&&E.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},E)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{l.destroy(f)}});break}};function t(i,a,c,d){const u=d.attributeIDs,l=d.attributeTypes;let f,p;const E=a.GetEncodedGeometryType(c);if(E===i.TRIANGULAR_MESH)f=new i.Mesh,p=a.DecodeArrayToMesh(c,c.byteLength,f);else if(E===i.POINT_CLOUD)f=new i.PointCloud,p=a.DecodeArrayToPointCloud(c,c.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const R={index:null,attributes:[]};for(const v in u){const m=self[l[v]];let _,g;if(d.useUniqueIDs)g=u[v],_=a.GetAttributeByUniqueId(f,g);else{if(g=a.GetAttributeId(f,i[u[v]]),g===-1)continue;_=a.GetAttribute(f,g)}const T=r(i,a,f,v,m,_);v==="color"&&(T.vertexColorSpace=d.vertexColorSpace),R.attributes.push(T)}return E===i.TRIANGULAR_MESH&&(R.index=n(i,a,f)),i.destroy(f),R}function n(i,a,c){const u=c.num_faces()*3,l=u*4,f=i._malloc(l);a.GetTrianglesUInt32Array(c,l,f);const p=new Uint32Array(i.HEAPF32.buffer,f,u).slice();return i._free(f),{array:p,itemSize:1}}function r(i,a,c,d,u,l){const f=l.num_components(),E=c.num_points()*f,R=E*u.BYTES_PER_ELEMENT,v=o(i,u),m=i._malloc(R);a.GetAttributeDataArrayForAllPoints(c,l,v,R,m);const _=new u(i.HEAPF32.buffer,m,E).slice();return i._free(m),{name:d,array:_,itemSize:f}}function o(i,a){switch(a){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}class yn extends h.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new En(t)}),this.register(function(t){return new Cn(t)}),this.register(function(t){return new On(t)}),this.register(function(t){return new In(t)}),this.register(function(t){return new Nn(t)}),this.register(function(t){return new Sn(t)}),this.register(function(t){return new xn(t)}),this.register(function(t){return new Mn(t)}),this.register(function(t){return new Ln(t)}),this.register(function(t){return new vn(t)}),this.register(function(t){return new An(t)}),this.register(function(t){return new Rn(t)}),this.register(function(t){return new Pn(t)}),this.register(function(t){return new kn(t)}),this.register(function(t){return new Tn(t)}),this.register(function(t){return new Dn(t)}),this.register(function(t){return new Fn(t)})}load(e,t,n,r){const o=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const d=h.LoaderUtils.extractUrlBase(e);i=h.LoaderUtils.resolveURL(d,this.path)}else i=h.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(d){r?r(d):console.error(d),o.manager.itemError(e),o.manager.itemEnd(e)},c=new h.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(d){try{o.parse(d,i,function(u){t(u),o.manager.itemEnd(e)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}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,n,r){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))===lt){try{i[M.KHR_BINARY_GLTF]=new jn(e)}catch(l){r&&r(l);return}o=JSON.parse(i[M.KHR_BINARY_GLTF].content)}else o=JSON.parse(c.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const d=new Yn(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const l=this.pluginCallbacks[u](d);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,i[l.name]=!0}if(o.extensionsUsed)for(let u=0;u<o.extensionsUsed.length;++u){const l=o.extensionsUsed[u],f=o.extensionsRequired||[];switch(l){case M.KHR_MATERIALS_UNLIT:i[l]=new wn;break;case M.KHR_DRACO_MESH_COMPRESSION:i[l]=new Hn(o,this.dracoLoader);break;case M.KHR_TEXTURE_TRANSFORM:i[l]=new Un;break;case M.KHR_MESH_QUANTIZATION:i[l]=new Bn;break;default:f.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}d.setExtensions(i),d.setPlugins(a),d.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,o){n.parse(e,t,r,o)})}}function bn(){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 M={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 Tn{constructor(e){this.parser=e,this.name=M.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const o=t[n];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,n="light:"+e;let r=t.cache.get(n);if(r)return r;const o=t.json,c=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let d;const u=new h.Color(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],h.LinearSRGBColorSpace);const l=c.range!==void 0?c.range:0;switch(c.type){case"directional":d=new h.DirectionalLight(u),d.target.position.set(0,0,-1),d.add(d.target);break;case"point":d=new h.PointLight(u),d.distance=l;break;case"spot":d=new h.SpotLight(u),d.distance=l,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,d.angle=c.spot.outerConeAngle,d.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,d.target.position.set(0,0,-1),d.add(d.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return d.position.set(0,0,0),N(d,c),c.intensity!==void 0&&(d.intensity=c.intensity),d.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(d),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],a=(o.extensions&&o.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}}class wn{constructor(){this.name=M.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(e,t,n){const r=[];e.color=new h.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],h.LinearSRGBColorSpace),e.opacity=i[3]}o.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",o.baseColorTexture,h.SRGBColorSpace))}return Promise.all(r)}}class vn{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class En{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new h.Vector2(a,a)}return Promise.all(o)}}class Cn{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class Rn{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&o.push(n.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(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(o)}}class Sn{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new h.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=r.extensions[this.name];if(i.sheenColorFactor!==void 0){const a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,h.SRGBColorSpace)),i.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(o)}}class xn{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(o)}}class Mn{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),Promise.all(o)}}class Ln{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class An{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=new h.Color().setRGB(a[0],a[1],a[2],h.LinearSRGBColorSpace),i.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,h.SRGBColorSpace)),Promise.all(o)}}class kn{constructor(e){this.parser=e,this.name=M.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&o.push(n.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(o)}}class Pn{constructor(e){this.parser=e,this.name=M.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],i=r.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(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(o)}}class On{constructor(e){this.parser=e,this.name=M.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const o=r.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.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 In{constructor(e){this.parser=e,this.name=M.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],a=r.images[i.source];let c=n.textureLoader;if(a.uri){const d=n.options.manager.getHandler(a.uri);d!==null&&(c=d)}return n.loadTextureImage(e,i.source,c)}}class Nn{constructor(e){this.parser=e,this.name=M.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const i=o.extensions[t],a=r.images[i.source];let c=n.textureLoader;if(a.uri){const d=n.options.manager.getHandler(a.uri);d!==null&&(c=d)}return n.loadTextureImage(e,i.source,c)}}class Dn{constructor(e){this.name=M.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const r=n.extensions[this.name],o=this.parser.getDependency("buffer",r.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=r.byteOffset||0,d=r.byteLength||0,u=r.count,l=r.byteStride,f=new Uint8Array(a,c,d);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(u,l,f,r.mode,r.filter).then(function(p){return p.buffer}):i.ready.then(function(){const p=new ArrayBuffer(u*l);return i.decodeGltfBuffer(new Uint8Array(p),u,l,f,r.mode,r.filter),p})})}else return null}}class Fn{constructor(e){this.name=M.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const r=t.meshes[n.mesh];for(const d of r.primitives)if(d.mode!==O.TRIANGLES&&d.mode!==O.TRIANGLE_STRIP&&d.mode!==O.TRIANGLE_FAN&&d.mode!==void 0)return null;const i=n.extensions[this.name].attributes,a=[],c={};for(const d in i)a.push(this.parser.getDependency("accessor",i[d]).then(u=>(c[d]=u,c[d])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(d=>{const u=d.pop(),l=u.isGroup?u.children:[u],f=d[0].count,p=[];for(const E of l){const R=new h.Matrix4,v=new h.Vector3,m=new h.Quaternion,_=new h.Vector3(1,1,1),g=new h.InstancedMesh(E.geometry,E.material,f);for(let T=0;T<f;T++)c.TRANSLATION&&v.fromBufferAttribute(c.TRANSLATION,T),c.ROTATION&&m.fromBufferAttribute(c.ROTATION,T),c.SCALE&&_.fromBufferAttribute(c.SCALE,T),g.setMatrixAt(T,R.compose(v,m,_));for(const T in c)if(T==="_COLOR_0"){const b=c[T];g.instanceColor=new h.InstancedBufferAttribute(b.array,b.itemSize,b.normalized)}else T!=="TRANSLATION"&&T!=="ROTATION"&&T!=="SCALE"&&E.geometry.setAttribute(T,c[T]);h.Object3D.prototype.copy.call(g,E),this.parser.assignFinalMaterial(g),p.push(g)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const lt="glTF",re=12,Je={JSON:1313821514,BIN:5130562};class jn{constructor(e){this.name=M.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,re),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==lt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-re,o=new DataView(e,re);let i=0;for(;i<r;){const a=o.getUint32(i,!0);i+=4;const c=o.getUint32(i,!0);if(i+=4,c===Je.JSON){const d=new Uint8Array(e,re+i,a);this.content=n.decode(d)}else if(c===Je.BIN){const d=re+i;this.body=e.slice(d,d+a)}i+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Hn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=M.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},c={},d={};for(const u in i){const l=Ae[u]||u.toLowerCase();a[l]=i[u]}for(const u in e.attributes){const l=Ae[u]||u.toLowerCase();if(i[u]!==void 0){const f=n.accessors[e.attributes[u]],p=Q[f.componentType];d[l]=p.name,c[l]=f.normalized===!0}}return t.getDependency("bufferView",o).then(function(u){return new Promise(function(l,f){r.decodeDracoFile(u,function(p){for(const E in p.attributes){const R=p.attributes[E],v=c[E];v!==void 0&&(R.normalized=v)}l(p)},a,d,h.LinearSRGBColorSpace,f)})})}}class Un{constructor(){this.name=M.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 Bn{constructor(){this.name=M.KHR_MESH_QUANTIZATION}}class dt extends h.Interpolant{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r*3+r;for(let i=0;i!==r;i++)t[i]=n[o+i];return t}interpolate_(e,t,n,r){const o=this.resultBuffer,i=this.sampleValues,a=this.valueSize,c=a*2,d=a*3,u=r-t,l=(n-t)/u,f=l*l,p=f*l,E=e*d,R=E-d,v=-2*p+3*f,m=p-f,_=1-v,g=m-f+l;for(let T=0;T!==a;T++){const b=i[R+T+a],w=i[R+T+c]*u,C=i[E+T+a],L=i[E+T]*u;o[T]=_*b+g*w+v*C+m*L}return o}}const Gn=new h.Quaternion;class Wn extends dt{interpolate_(e,t,n,r){const o=super.interpolate_(e,t,n,r);return Gn.fromArray(o).normalize().toArray(o),o}}const O={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Q={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ze={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},et={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},Ee={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ae={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"},U={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Kn={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},Ce={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function zn(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),s.DefaultMaterial}function V(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function N(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 $n(s,e,t){let n=!1,r=!1,o=!1;for(let d=0,u=e.length;d<u;d++){const l=e[d];if(l.POSITION!==void 0&&(n=!0),l.NORMAL!==void 0&&(r=!0),l.COLOR_0!==void 0&&(o=!0),n&&r&&o)break}if(!n&&!r&&!o)return Promise.resolve(s);const i=[],a=[],c=[];for(let d=0,u=e.length;d<u;d++){const l=e[d];if(n){const f=l.POSITION!==void 0?t.getDependency("accessor",l.POSITION):s.attributes.position;i.push(f)}if(r){const f=l.NORMAL!==void 0?t.getDependency("accessor",l.NORMAL):s.attributes.normal;a.push(f)}if(o){const f=l.COLOR_0!==void 0?t.getDependency("accessor",l.COLOR_0):s.attributes.color;c.push(f)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c)]).then(function(d){const u=d[0],l=d[1],f=d[2];return n&&(s.morphAttributes.position=u),r&&(s.morphAttributes.normal=l),o&&(s.morphAttributes.color=f),s.morphTargetsRelative=!0,s})}function Vn(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;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 n=0,r=t.length;n<r;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function qn(s){let e;const t=s.extensions&&s.extensions[M.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Re(t.attributes):e=s.indices+":"+Re(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,r=s.targets.length;n<r;n++)e+=":"+Re(s.targets[n]);return e}function Re(s){let e="";const t=Object.keys(s).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+s[t[n]]+";";return e}function ke(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 Xn(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":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Qn=new h.Matrix4;class Yn{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new bn,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 n=!1,r=-1,o=!1,i=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const c=a.match(/Version\/(\d+)/);r=n&&c?parseInt(c[1],10):-1,o=a.indexOf("Firefox")>-1,i=o?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&r<17||o&&i<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.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 n=this,r=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){const a={scene:i[0][r.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:r.asset,parser:n,userData:{}};return V(o,a,r),N(a,r),Promise.all(n._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||[],n=this.json.meshes||[];for(let r=0,o=t.length;r<o;r++){const i=t[r].joints;for(let a=0,c=i.length;a<c;a++)e[i[a]].isBone=!0}for(let r=0,o=e.length;r<o;r++){const i=e[r];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[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,n){if(e.refs[t]<=1)return n;const r=n.clone(),o=(i,a)=>{const c=this.associations.get(i);c!=null&&this.associations.set(a,c);for(const[d,u]of i.children.entries())o(u,a.children[d])};return o(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const o=e(t[r]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":r=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(o,i){return n.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[M.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(o,i){n.load(h.LoaderUtils.resolveURL(t.uri,r.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(n){const r=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+r)})}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const i=Ee[r.type],a=Q[r.componentType],c=r.normalized===!0,d=new a(r.count*i);return Promise.resolve(new h.BufferAttribute(d,i,c))}const o=[];return r.bufferView!==void 0?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),r.sparse!==void 0&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(i){const a=i[0],c=Ee[r.type],d=Q[r.componentType],u=d.BYTES_PER_ELEMENT,l=u*c,f=r.byteOffset||0,p=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,E=r.normalized===!0;let R,v;if(p&&p!==l){const m=Math.floor(f/p),_="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+m+":"+r.count;let g=t.cache.get(_);g||(R=new d(a,m*p,r.count*p/u),g=new h.InterleavedBuffer(R,p/u),t.cache.add(_,g)),v=new h.InterleavedBufferAttribute(g,c,f%p/u,E)}else a===null?R=new d(r.count*c):R=new d(a,f,r.count*c),v=new h.BufferAttribute(R,c,E);if(r.sparse!==void 0){const m=Ee.SCALAR,_=Q[r.sparse.indices.componentType],g=r.sparse.indices.byteOffset||0,T=r.sparse.values.byteOffset||0,b=new _(i[1],g,r.sparse.count*m),w=new d(i[2],T,r.sparse.count*c);a!==null&&(v=new h.BufferAttribute(v.array.slice(),v.itemSize,v.normalized)),v.normalized=!1;for(let C=0,L=b.length;C<L;C++){const S=b[C];if(v.setX(S,w[C*c]),c>=2&&v.setY(S,w[C*c+1]),c>=3&&v.setZ(S,w[C*c+2]),c>=4&&v.setW(S,w[C*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}v.normalized=E}return v})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,i=t.images[o];let a=this.textureLoader;if(i.uri){const c=n.manager.getHandler(i.uri);c!==null&&(a=c)}return this.loadTextureImage(e,o,a)}loadTextureImage(e,t,n){const r=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 d=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=i.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const f=(o.samplers||{})[i.sampler]||{};return u.magFilter=Ze[f.magFilter]||h.LinearFilter,u.minFilter=Ze[f.minFilter]||h.LinearMipmapLinearFilter,u.wrapS=et[f.wrapS]||h.RepeatWrapping,u.wrapT=et[f.wrapT]||h.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==h.NearestFilter&&u.minFilter!==h.LinearFilter,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=d,d}loadImageSource(e,t){const n=this,r=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(l=>l.clone());const i=r.images[e],a=self.URL||self.webkitURL;let c=i.uri||"",d=!1;if(i.bufferView!==void 0)c=n.getDependency("bufferView",i.bufferView).then(function(l){d=!0;const f=new Blob([l],{type:i.mimeType});return c=a.createObjectURL(f),c});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(l){return new Promise(function(f,p){let E=f;t.isImageBitmapLoader===!0&&(E=function(R){const v=new h.Texture(R);v.needsUpdate=!0,f(v)}),t.load(h.LoaderUtils.resolveURL(l,o.path),E,void 0,p)})}).then(function(l){return d===!0&&a.revokeObjectURL(c),N(l,i),l.userData.mimeType=i.mimeType||Xn(i.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),l});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){const o=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),o.extensions[M.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[M.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=o.associations.get(i);i=o.extensions[M.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),o.associations.set(i,c)}}return r!==void 0&&(i.colorSpace=r),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new h.PointsMaterial,h.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new h.LineBasicMaterial,h.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(r||o||i){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),o&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),o&&(c.vertexColors=!0),i&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,o=n.materials[e];let i;const a={},c=o.extensions||{},d=[];if(c[M.KHR_MATERIALS_UNLIT]){const l=r[M.KHR_MATERIALS_UNLIT];i=l.getMaterialType(),d.push(l.extendParams(a,o,t))}else{const l=o.pbrMetallicRoughness||{};if(a.color=new h.Color(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const f=l.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],h.LinearSRGBColorSpace),a.opacity=f[3]}l.baseColorTexture!==void 0&&d.push(t.assignTexture(a,"map",l.baseColorTexture,h.SRGBColorSpace)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(d.push(t.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),d.push(t.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),d.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}o.doubleSided===!0&&(a.side=h.DoubleSide);const u=o.alphaMode||Ce.OPAQUE;if(u===Ce.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===Ce.MASK&&(a.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&i!==h.MeshBasicMaterial&&(d.push(t.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new h.Vector2(1,1),o.normalTexture.scale!==void 0)){const l=o.normalTexture.scale;a.normalScale.set(l,l)}if(o.occlusionTexture!==void 0&&i!==h.MeshBasicMaterial&&(d.push(t.assignTexture(a,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&i!==h.MeshBasicMaterial){const l=o.emissiveFactor;a.emissive=new h.Color().setRGB(l[0],l[1],l[2],h.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&i!==h.MeshBasicMaterial&&d.push(t.assignTexture(a,"emissiveMap",o.emissiveTexture,h.SRGBColorSpace)),Promise.all(d).then(function(){const l=new i(a);return o.name&&(l.name=o.name),N(l,o),t.associations.set(l,{materials:e}),o.extensions&&V(r,l,o),l})}createUniqueName(e){const t=h.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function o(a){return n[M.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return tt(c,a,t)})}const i=[];for(let a=0,c=e.length;a<c;a++){const d=e[a],u=qn(d),l=r[u];if(l)i.push(l.promise);else{let f;d.extensions&&d.extensions[M.KHR_DRACO_MESH_COMPRESSION]?f=o(d):f=tt(new h.BufferGeometry,d,t),r[u]={primitive:d,promise:f},i.push(f)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,r=this.extensions,o=n.meshes[e],i=o.primitives,a=[];for(let c=0,d=i.length;c<d;c++){const u=i[c].material===void 0?zn(this.cache):this.getDependency("material",i[c].material);a.push(u)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(c){const d=c.slice(0,c.length-1),u=c[c.length-1],l=[];for(let p=0,E=u.length;p<E;p++){const R=u[p],v=i[p];let m;const _=d[p];if(v.mode===O.TRIANGLES||v.mode===O.TRIANGLE_STRIP||v.mode===O.TRIANGLE_FAN||v.mode===void 0)m=o.isSkinnedMesh===!0?new h.SkinnedMesh(R,_):new h.Mesh(R,_),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),v.mode===O.TRIANGLE_STRIP?m.geometry=Ye(m.geometry,h.TriangleStripDrawMode):v.mode===O.TRIANGLE_FAN&&(m.geometry=Ye(m.geometry,h.TriangleFanDrawMode));else if(v.mode===O.LINES)m=new h.LineSegments(R,_);else if(v.mode===O.LINE_STRIP)m=new h.Line(R,_);else if(v.mode===O.LINE_LOOP)m=new h.LineLoop(R,_);else if(v.mode===O.POINTS)m=new h.Points(R,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(m.geometry.morphAttributes).length>0&&Vn(m,o),m.name=t.createUniqueName(o.name||"mesh_"+e),N(m,o),v.extensions&&V(r,m,v),t.assignFinalMaterial(m),l.push(m)}for(let p=0,E=l.length;p<E;p++)t.associations.set(l[p],{meshes:e,primitives:p});if(l.length===1)return o.extensions&&V(r,l[0],o),l[0];const f=new h.Group;o.extensions&&V(r,f,o),t.associations.set(f,{meshes:e});for(let p=0,E=l.length;p<E;p++)f.add(l[p]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new h.PerspectiveCamera(h.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new h.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),N(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let r=0,o=t.joints.length;r<o;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){const o=r.pop(),i=r,a=[],c=[];for(let d=0,u=i.length;d<u;d++){const l=i[d];if(l){a.push(l);const f=new h.Matrix4;o!==null&&f.fromArray(o.array,d*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[d])}return new h.Skeleton(a,c)})}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],o=r.name?r.name:"animation_"+e,i=[],a=[],c=[],d=[],u=[];for(let l=0,f=r.channels.length;l<f;l++){const p=r.channels[l],E=r.samplers[p.sampler],R=p.target,v=R.node,m=r.parameters!==void 0?r.parameters[E.input]:E.input,_=r.parameters!==void 0?r.parameters[E.output]:E.output;R.node!==void 0&&(i.push(this.getDependency("node",v)),a.push(this.getDependency("accessor",m)),c.push(this.getDependency("accessor",_)),d.push(E),u.push(R))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c),Promise.all(d),Promise.all(u)]).then(function(l){const f=l[0],p=l[1],E=l[2],R=l[3],v=l[4],m=[];for(let g=0,T=f.length;g<T;g++){const b=f[g],w=p[g],C=E[g],L=R[g],S=v[g];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const A=n._createAnimationTracks(b,w,C,L,S);if(A)for(let k=0;k<A.length;k++)m.push(A[k])}const _=new h.AnimationClip(o,void 0,m);return N(_,r),_})}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(o){const i=n._getNodeRef(n.meshCache,r.mesh,o);return r.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let c=0,d=r.weights.length;c<d;c++)a.morphTargetInfluences[c]=r.weights[c]}),i})}loadNode(e){const t=this.json,n=this,r=t.nodes[e],o=n._loadNodeShallow(e),i=[],a=r.children||[];for(let d=0,u=a.length;d<u;d++)i.push(n.getDependency("node",a[d]));const c=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([o,Promise.all(i),c]).then(function(d){const u=d[0],l=d[1],f=d[2];f!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Qn)});for(let p=0,E=l.length;p<E;p++)u.add(l[p]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],i=o.name?r.createUniqueName(o.name):"",a=[],c=r._invokeOne(function(d){return d.createNodeMesh&&d.createNodeMesh(e)});return c&&a.push(c),o.camera!==void 0&&a.push(r.getDependency("camera",o.camera).then(function(d){return r._getNodeRef(r.cameraCache,o.camera,d)})),r._invokeAll(function(d){return d.createNodeAttachment&&d.createNodeAttachment(e)}).forEach(function(d){a.push(d)}),this.nodeCache[e]=Promise.all(a).then(function(d){let u;if(o.isBone===!0?u=new h.Bone:d.length>1?u=new h.Group:d.length===1?u=d[0]:u=new h.Object3D,u!==d[0])for(let l=0,f=d.length;l<f;l++)u.add(d[l]);if(o.name&&(u.userData.name=o.name,u.name=i),N(u,o),o.extensions&&V(n,u,o),o.matrix!==void 0){const l=new h.Matrix4;l.fromArray(o.matrix),u.applyMatrix4(l)}else o.translation!==void 0&&u.position.fromArray(o.translation),o.rotation!==void 0&&u.quaternion.fromArray(o.rotation),o.scale!==void 0&&u.scale.fromArray(o.scale);if(!r.associations.has(u))r.associations.set(u,{});else if(o.mesh!==void 0&&r.meshCache.refs[o.mesh]>1){const l=r.associations.get(u);r.associations.set(u,{...l})}return r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,o=new h.Group;n.name&&(o.name=r.createUniqueName(n.name)),N(o,n),n.extensions&&V(t,o,n);const i=n.nodes||[],a=[];for(let c=0,d=i.length;c<d;c++)a.push(r.getDependency("node",i[c]));return Promise.all(a).then(function(c){for(let u=0,l=c.length;u<l;u++)o.add(c[u]);const d=u=>{const l=new Map;for(const[f,p]of r.associations)(f instanceof h.Material||f instanceof h.Texture)&&l.set(f,p);return u.traverse(f=>{const p=r.associations.get(f);p!=null&&l.set(f,p)}),l};return r.associations=d(o),o})}_createAnimationTracks(e,t,n,r,o){const i=[],a=e.name?e.name:e.uuid,c=[];U[o.path]===U.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let d;switch(U[o.path]){case U.weights:d=h.NumberKeyframeTrack;break;case U.rotation:d=h.QuaternionKeyframeTrack;break;case U.translation:case U.scale:d=h.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:d=h.NumberKeyframeTrack;break;case 2:case 3:default:d=h.VectorKeyframeTrack;break}break}const u=r.interpolation!==void 0?Kn[r.interpolation]:h.InterpolateLinear,l=this._getArrayFromAccessor(n);for(let f=0,p=c.length;f<p;f++){const E=new d(c[f]+"."+U[o.path],t.array,l,u);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(E),i.push(E)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=ke(t.constructor),r=new Float32Array(t.length);for(let o=0,i=t.length;o<i;o++)r[o]=t[o]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const r=this instanceof h.QuaternionKeyframeTrack?Wn:dt;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Jn(s,e,t){const n=e.attributes,r=new h.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,d=a.max;if(c!==void 0&&d!==void 0){if(r.set(new h.Vector3(c[0],c[1],c[2]),new h.Vector3(d[0],d[1],d[2])),a.normalized){const u=ke(Q[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}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 h.Vector3,c=new h.Vector3;for(let d=0,u=o.length;d<u;d++){const l=o[d];if(l.POSITION!==void 0){const f=t.json.accessors[l.POSITION],p=f.min,E=f.max;if(p!==void 0&&E!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(E[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(E[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(E[2]))),f.normalized){const R=ke(Q[f.componentType]);c.multiplyScalar(R)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}s.boundingBox=r;const i=new h.Sphere;r.getCenter(i.center),i.radius=r.min.distanceTo(r.max)/2,s.boundingSphere=i}function tt(s,e,t){const n=e.attributes,r=[];function o(i,a){return t.getDependency("accessor",i).then(function(c){s.setAttribute(a,c)})}for(const i in n){const a=Ae[i]||i.toLowerCase();a in s.attributes||r.push(o(n[i],a))}if(e.indices!==void 0&&!s.index){const i=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});r.push(i)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),N(s,e),Jn(s,e,t),Promise.all(r).then(function(){return e.targets!==void 0?$n(s,e.targets,t):s})}var Zn=Object.defineProperty,er=Object.getOwnPropertyDescriptor,tr=(s,e,t,n)=>{for(var r=n>1?void 0:n?er(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&Zn(e,t,r),r};let le=class{constructor(){x(this,"loadingManager",new h.LoadingManager);x(this,"loaders",{});x(this,"sources",[]);x(this,"loadedResources",{});x(this,"toLoadCount",0);x(this,"loadedCount",0)}get videoLoader(){return{load:(s,e)=>{const t=document.createElement("video");t.muted=!0,t.loop=!0,t.crossOrigin="anonymous",t.controls=!1,t.playsInline=!0,t.src=s,t.autoplay=!0;const n=async()=>{e(t),t.removeEventListener("canplaythrough",n)};t.addEventListener("canplaythrough",n)}}}_initLoaders(){this.loaders.dracoLoader=new ut(this.loadingManager),this.loaders.audioLoader=new h.AudioLoader(this.loadingManager),this.loaders.fontLoader=new y.FontLoader(this.loadingManager),this.loaders.gltfLoader=new yn(this.loadingManager),this.loaders.imageLoader=new h.ImageBitmapLoader(this.loadingManager),this.loaders.videoLoader=this.videoLoader}_initSources(s){this.sources=s,this.toLoadCount=this.sources.length,this.loadedCount=0}init(s=[]){this._initLoaders(),this._initSources(s)}setDracoDecoder(s){var e;this.loaders.dracoLoader&&(this.loaders.dracoLoader.setDecoderPath(s??"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),(e=this.loaders.gltfLoader)==null||e.setDRACOLoader(this.loaders.dracoLoader))}handleLoad({source:s,resource:e,toLoadCount:t,loadedCount:n}){e&&(this.loadedResources[s.name]=e,this.loadedCount=n,this.toLoadCount=t)}launchLoad(s){var t,n,r,o,i;const e=this.sources[0];if(e){s==null||s(e);for(const a of this.sources){if(this.loadedResources[a.name]||typeof a.path!="string")return;a.type==="gltf"&&((t=this.loaders.gltfLoader)==null||t.load(a.path,c=>s==null?void 0:s(a,c))),a.type==="audio"&&((n=this.loaders.audioLoader)==null||n.load(a.path,c=>s==null?void 0:s(a,c))),a.type==="image"&&((r=this.loaders.imageLoader)==null||r.load(a.path,c=>s==null?void 0:s(a,c))),a.type==="video"&&((o=this.loaders.videoLoader)==null||o.load(a.path,c=>s==null?void 0:s(a,c))),a.type==="font"&&((i=this.loaders.fontLoader)==null||i.load(a.path,c=>s==null?void 0:s(a,c)))}}}};le=tr([y.scoped(y.Lifecycle.ContainerScoped)],le);var nr=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,sr=(s,e,t,n)=>{for(var r=n>1?void 0:n?rr(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&nr(e,t,r),r},ir=(s,e)=>(t,n)=>e(t,n,s);let de=class{constructor(s){x(this,"load$$",new y.Subject);x(this,"load$",this.load$$.pipe(y.map(s=>({...s,loadedCount:s.resource?this._service.loadedCount+1:this._service.loadedCount,toLoadCount:this._service.toLoadCount})),y.share()));x(this,"serializedLoad$",this.load$.pipe(y.map(s=>{var t,n,r;let e=s.resource;if((t=s==null?void 0:s.resource)!=null&&t.parser){const o=s.resource,i=o.scenes.map(a=>y.g(a));e={animations:(s==null?void 0:s.resource).animations.map(a=>a.toJSON()),cameras:o.cameras.map(a=>y.g(a)),parser:{json:o.parser.json},scene:i==null?void 0:i[0],scenes:i,userData:o.userData}}return((n=s==null?void 0:s.source)==null?void 0:n.type)==="audio"&&s.resource instanceof AudioBuffer&&(e={arrayBuffer:s.resource.getChannelData(0),length:s.resource.length,sampleRate:s.resource.sampleRate,duration:s.resource.duration}),((r=s==null?void 0:s.source)==null?void 0:r.type)==="video"&&s.resource instanceof HTMLVideoElement&&(e={...y.R(s.resource,["autoplay","baseURI","controls","crossOrigin","currentTime","defaultMuted","disablePictureInPicture","draggable","duration","ended","height","hidden","loop","muted","nodeName","nodeType","paused","playbackRate","playsInline","poster","preload","readyState","seeking","spellcheck","src","tabIndex","translate","videoHeight","videoWidth","volume","width"]),buffered:s.resource.buffered.length,error:s.resource.error?y.E(s.resource.error,[]):{},played:s.resource.played.length,seekable:s.resource.seekable.length,textTracks:s.resource.textTracks.length}),{...s,resource:e}}),y.share()));x(this,"loadCompleted$",this.load$.pipe(y.filter(s=>s.toLoadCount===s.loadedCount),y.map(()=>y.R(this._service,["loadedCount","loadedResources","toLoadCount"])),y.share()));this._service=s}};de=sr([y.scoped(y.Lifecycle.ContainerScoped),ir(0,y.inject(le))],de);var or=Object.defineProperty,ar=Object.getOwnPropertyDescriptor,cr=(s,e,t,n)=>{for(var r=n>1?void 0:n?ar(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&or(e,t,r),r},Se=(s,e)=>(t,n)=>e(t,n,s);let Pe=class{constructor(s,e,t){x(this,"_subscriptions",[]);this._controller=s,this._service=e,this._props=t,this._subscriptions.push(this._controller.load$.subscribe(this._service.handleLoad.bind(this._service)))}init(s){this._service.init(s.sources||[]),this._service.setDracoDecoder(s.dracoDecoderPath),[void 0,!0].includes(this._props.loadResourcesOnInit)&&this.load()}load(){this._service.launchLoad((s,e)=>this._controller.load$$.next({source:s,resource:e}))}getLoadedResources(){return this._service.loadedResources}getLoaders(){return this._service.loaders}getSources(){return this._service.sources}getLoadedCount(){return this._service.loadedCount}getToLoadCount(){return this._service.toLoadCount}getLoad$(){return this._controller.load$}getLoadCompleted$(){return this._controller.loadCompleted$}setDracoDecoder(s){this._service.setDracoDecoder(s)}dispose(){this._subscriptions.forEach(s=>s.unsubscribe()),Object.keys(this._service.loaders).forEach(s=>{const e=this._service.loaders[s];e instanceof ut&&e.dispose(),this._service.loaders[s]=void 0}),this._controller.load$$.complete()}};Pe=cr([y.scoped(y.Lifecycle.ContainerScoped),Se(0,y.inject(de)),Se(1,y.inject(le)),Se(2,y.inject(se))],Pe);var ur=Object.defineProperty,lr=Object.getOwnPropertyDescriptor,dr=(s,e,t,n)=>{for(var r=n>1?void 0:n?lr(e,t):e,o=s.length-1,i;o>=0;o--)(i=s[o])&&(r=(n?i(e,t,r):i(r))||r);return n&&r&&ur(e,t,r),r},X=(s,e)=>(t,n)=>e(t,n,s);exports.RegisterModule=class extends y.RegisterProxyEventHandlersBlueprint{constructor(t,n,r,o,i,a){super();x(this,"_subscriptions",[]);x(this,"_initialized",!1);this._service=t,this._controller=n,this._loaderController=r,this.container=o,this.props=i,this.loader=a,this.props.initOnConstruct&&this.init()}get currentWorker(){return this.props.mainThread?self:this._service.worker}async _initCanvas(){try{if(this.props.canvas instanceof HTMLCanvasElement&&(this._service.canvas=this.props.canvas),typeof this.props.canvas=="string"){const t=document.querySelector(this.props.canvas);t instanceof HTMLCanvasElement&&(this._service.canvas=t)}this._service.canvas||(this._service.canvas=document.createElement("canvas"),this._service.canvas.dataset.reactive="true",document.body.appendChild(this._service.canvas))}catch(t){console.error(`🛑 Unable to initialize the canvas:
|
|
4
|
+
${t instanceof Error?t.message:"Something went wrong"}`)}}async _initServiceWorker(){this._service.init({worker:this._service.worker,thread:this._service.thread})}async _initEvents(){if(!this._service.canvas)throw new Error("Canvas element is not initialized.");this._controller.init(),setTimeout(()=>{const t=new UIEvent("resize");t.width=window.innerWidth,t.height=window.innerHeight,t.windowWidth=window.innerWidth,t.windowHeight=window.innerHeight,this._controller.resize$$.next(this._service.uiEventHandler(t))},0)}async _initOnMainThread(){await import(`${this.props.location}`),self.postMessage({mainThread:!0,...y.E(this.props,["canvas","location","onReady","loaderDataSources"])})}async _initOnWorkerThread(){if(!this._service.canvas)throw new Error("Canvas element is not initialized.");this._service.offscreenCanvas=this._service.canvas.transferControlToOffscreen(),this._service.offscreenCanvas.width=this._service.canvas.clientWidth,this._service.offscreenCanvas.height=this._service.canvas.clientHeight;const[t,n]=await this._service.workerPool.run({payload:{path:this.props.location,subject:{...y.E(this.props,["canvas","location","onReady","loaderDataSources"]),canvas:this._service.offscreenCanvas},transferSubject:[this._service.offscreenCanvas]}})||[];if(!t||n)throw new Error("Unable to retrieve the worker-thread info.");this._service.worker=t.worker,this._service.thread=t.thread}async _initObservables(){y.PROXY_EVENT_LISTENERS.forEach(t=>this[`${t}$`]=()=>{var n;return(n=this._controller)==null?void 0:n[`${t}$`]})}async _initLoader(){this.loader.init({sources:this.props.loaderDataSources,dracoDecoderPath:this.props.loaderDracoDecoderPath}),this._subscriptions.push(this._loaderController.serializedLoad$.subscribe(t=>{var n,r;if(t.resource instanceof ArrayBuffer)return(n=this.currentWorker)==null?void 0:n.postMessage(t.resource,[t.resource]);(r=this.currentWorker)==null||r.postMessage({token:y.LOADER_SERIALIZED_LOAD_TOKEN,payload:t})}))}async init(){var t,n;this._initialized||(this._initialized=!0,await this._initCanvas(),this.props.mainThread?await this._initOnMainThread():await this._initOnWorkerThread(),await this._initServiceWorker(),await this._initObservables(),await this._initLoader(),await this._initEvents(),(n=(t=this.props).onReady)==null||n.call(t,{module:this,container:this.container}))}getCanvas(){return this._service.canvas}getOffscreenCanvas(){return this._service.offscreenCanvas}getThread(){return this._service.thread}getWorker(){return this._service.worker}getWorkerPool(){return this._service.workerPool}isInitialized(){return this._initialized}async dispose(){var t;this._subscriptions.map(n=>n.unsubscribe()),await this._service.workerPool.terminateAll(),((t=this._service.canvas)==null?void 0:t.dataset.reactive)==="true"&&(document.body.removeChild(this._service.canvas),this._service.canvas.remove(),this._service.canvas=void 0),this._initialized=!1}};exports.RegisterModule=dr([y.scoped(y.Lifecycle.ContainerScoped),X(0,y.inject(ue)),X(1,y.inject(Le)),X(2,y.inject(de)),X(3,y.inject(y.CONTAINER_TOKEN)),X(4,y.inject(se)),X(5,y.inject(Pe))],exports.RegisterModule);const fr=s=>{if(!(s!=null&&s.location)||!URL.canParse(s.location))throw new Error("Invalid register props detected. location path is required");const e=y.instance.createChildContainer();s.initOnConstruct=y.x(s.initOnConstruct)||!y.N(s.initOnConstruct)?!0:s.initOnConstruct,s.defaultCamera=s!=null&&s.defaultCamera&&s.defaultCamera in y.DefaultCameraType?s.defaultCamera:y.DefaultCameraType.PERSPECTIVE,s.withMiniCamera=y.x(s.withMiniCamera)||!y.N(s.withMiniCamera)?!1:s.withMiniCamera,s.startTimer=y.x(s.startTimer)||!y.N(s.startTimer)?!0:s.startTimer,s.fullScreen=y.x(s.fullScreen)||!y.N(s.fullScreen)?!0:s.fullScreen,s.onReady=y.P(s.onReady)?s.onReady:void 0,e.register(y.CONTAINER_TOKEN,{useValue:e}),e.register(se,{useValue:s});const t=e.resolve(exports.RegisterModule);return{container:e,module:t}};exports.AppProxyEventHandlersBlueprint=y.AppProxyEventHandlersBlueprint;exports.CONTAINER_TOKEN=y.CONTAINER_TOKEN;exports.DefaultCameraType=y.DefaultCameraType;exports.KEYBOARD_EVENT_CODES=y.KEYBOARD_EVENT_CODES;exports.LOADER_SERIALIZED_LOAD_TOKEN=y.LOADER_SERIALIZED_LOAD_TOKEN;exports.PROXY_EVENT_LISTENERS=y.PROXY_EVENT_LISTENERS;exports.ProxyEventHandlersBlueprint=y.ProxyEventHandlersBlueprint;exports.ProxyEventObservablesBlueprint=y.ProxyEventObservablesBlueprint;exports.ProxyEventSubjectsBlueprint=y.ProxyEventSubjectsBlueprint;exports.RegisterProxyEventHandlersBlueprint=y.RegisterProxyEventHandlersBlueprint;exports.LaunchAppProps=pt;exports.RegisterPropsBlueprint=se;exports.register=fr;
|