@luma.gl/engine 9.1.0-alpha.13 → 9.1.0-alpha.14
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/async-texture/async-texture.d.ts +10 -0
- package/dist/async-texture/async-texture.d.ts.map +1 -1
- package/dist/async-texture/async-texture.js +14 -0
- package/dist/dist.dev.js +14 -17
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +14 -12
- package/dist/index.cjs.map +2 -2
- package/dist/transform/buffer-transform.d.ts +4 -6
- package/dist/transform/buffer-transform.d.ts.map +1 -1
- package/dist/transform/buffer-transform.js +2 -10
- package/dist/transform/texture-transform.d.ts +0 -6
- package/dist/transform/texture-transform.d.ts.map +1 -1
- package/dist/transform/texture-transform.js +0 -12
- package/package.json +2 -2
- package/src/async-texture/async-texture.ts +14 -5
- package/src/transform/buffer-transform.ts +4 -12
- package/src/transform/texture-transform.ts +0 -15
|
@@ -44,6 +44,16 @@ export declare class AsyncTexture {
|
|
|
44
44
|
constructor(device: Device, props: AsyncTextureProps);
|
|
45
45
|
initAsync(props: AsyncTextureProps): Promise<void>;
|
|
46
46
|
destroy(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Textures are immutable and cannot be resized after creation,
|
|
49
|
+
* but we can create a similar texture with the same parameters but a new size.
|
|
50
|
+
* @note Does not copy contents of the texture
|
|
51
|
+
* @todo Abort pending promise and create a texture with the new size?
|
|
52
|
+
*/
|
|
53
|
+
resize(size: {
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
}): void;
|
|
47
57
|
}
|
|
48
58
|
export {};
|
|
49
59
|
//# sourceMappingURL=async-texture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-texture.d.ts","sourceRoot":"","sources":["../../src/async-texture/async-texture.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,OAAO,EACP,WAAW,EACX,MAAM,EACN,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC;AAEnF,KAAK,qBAAqB,GACtB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,GACrB,0BAA0B,CAAC;AAE/B,KAAK,mBAAmB,GAAG;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,GAAG,IAAI,CAAA;CAAC,CAAC;AAClG,KAAK,mBAAmB,GAAG;IAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,GAAG,IAAI,CAAA;CAAC,CAAC;AACnG,KAAK,mBAAmB,GAAG;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,GAAG,IAAI,CAAA;CAAC,CAAC;AAClG,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,UAAU,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAAC;CAC3D,CAAC;AACF,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,GAAG,IAAI,CAAC;CACzD,CAAC;AACF,KAAK,0BAA0B,GAAG;IAChC,SAAS,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,GAAG,IAAI,CAAC;CACnE,CAAC;AAKF;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAIxB,OAAO,EAAE,OAAO,CAAC;IAEjB,OAAO,EAAE,OAAO,CAAC;IAEjB,IAAI,EAAE,WAAW,CAAC;IAElB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAS;IACzB,SAAS,EAAE,OAAO,CAAS;IAE3B,SAAS,CAAC,YAAY,EAAE,MAAM,IAAI,CAAY;IAC9C,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAY;gBAE7C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB;IAmB9C,SAAS,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBxD,OAAO,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"async-texture.d.ts","sourceRoot":"","sources":["../../src/async-texture/async-texture.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,OAAO,EACP,WAAW,EACX,MAAM,EACN,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,qBAAqB,CAAC;AAEnF,KAAK,qBAAqB,GACtB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,GACrB,0BAA0B,CAAC;AAE/B,KAAK,mBAAmB,GAAG;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,GAAG,IAAI,CAAA;CAAC,CAAC;AAClG,KAAK,mBAAmB,GAAG;IAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,GAAG,IAAI,CAAA;CAAC,CAAC;AACnG,KAAK,mBAAmB,GAAG;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,GAAG,IAAI,CAAA;CAAC,CAAC;AAClG,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,UAAU,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAAC;CAC3D,CAAC;AACF,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,GAAG,IAAI,CAAC;CACzD,CAAC;AACF,KAAK,0BAA0B,GAAG;IAChC,SAAS,EAAE,YAAY,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,GAAG,IAAI,CAAC;CACnE,CAAC;AAKF;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAIxB,OAAO,EAAE,OAAO,CAAC;IAEjB,OAAO,EAAE,OAAO,CAAC;IAEjB,IAAI,EAAE,WAAW,CAAC;IAElB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAS;IACzB,SAAS,EAAE,OAAO,CAAS;IAE3B,SAAS,CAAC,YAAY,EAAE,MAAM,IAAI,CAAY;IAC9C,SAAS,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAY;gBAE7C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB;IAmB9C,SAAS,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBxD,OAAO,IAAI,IAAI;IASf;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,GAAG,IAAI;CAQpD"}
|
|
@@ -61,6 +61,20 @@ export class AsyncTexture {
|
|
|
61
61
|
}
|
|
62
62
|
this.destroyed = true;
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Textures are immutable and cannot be resized after creation,
|
|
66
|
+
* but we can create a similar texture with the same parameters but a new size.
|
|
67
|
+
* @note Does not copy contents of the texture
|
|
68
|
+
* @todo Abort pending promise and create a texture with the new size?
|
|
69
|
+
*/
|
|
70
|
+
resize(size) {
|
|
71
|
+
if (!this.isReady) {
|
|
72
|
+
throw new Error('Cannot resize texture before it is ready');
|
|
73
|
+
}
|
|
74
|
+
if (this.texture) {
|
|
75
|
+
this.texture = this.texture.createResizedTexture(size);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
64
78
|
}
|
|
65
79
|
// HELPERS
|
|
66
80
|
/** Resolve all promises in a nested data structure */
|
package/dist/dist.dev.js
CHANGED
|
@@ -1434,11 +1434,20 @@ var __exports__ = (() => {
|
|
|
1434
1434
|
}
|
|
1435
1435
|
this.destroyed = true;
|
|
1436
1436
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1437
|
+
/**
|
|
1438
|
+
* Textures are immutable and cannot be resized after creation,
|
|
1439
|
+
* but we can create a similar texture with the same parameters but a new size.
|
|
1440
|
+
* @note Does not copy contents of the texture
|
|
1441
|
+
* @todo Abort pending promise and create a texture with the new size?
|
|
1442
|
+
*/
|
|
1443
|
+
resize(size) {
|
|
1444
|
+
if (!this.isReady) {
|
|
1445
|
+
throw new Error("Cannot resize texture before it is ready");
|
|
1446
|
+
}
|
|
1447
|
+
if (this.texture) {
|
|
1448
|
+
this.texture = this.texture.createResizedTexture(size);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1442
1451
|
};
|
|
1443
1452
|
async function awaitAllPromises(x) {
|
|
1444
1453
|
x = await x;
|
|
@@ -2112,7 +2121,6 @@ var __exports__ = (() => {
|
|
|
2112
2121
|
device;
|
|
2113
2122
|
model;
|
|
2114
2123
|
transformFeedback;
|
|
2115
|
-
/** @deprecated Use device feature test. */
|
|
2116
2124
|
static isSupported(device) {
|
|
2117
2125
|
return device?.info?.type === "webgl";
|
|
2118
2126
|
}
|
|
@@ -2151,10 +2159,6 @@ var __exports__ = (() => {
|
|
|
2151
2159
|
this.model.draw(renderPass);
|
|
2152
2160
|
renderPass.end();
|
|
2153
2161
|
}
|
|
2154
|
-
/** @deprecated */
|
|
2155
|
-
update(...args) {
|
|
2156
|
-
console.warn("TextureTransform#update() not implemented");
|
|
2157
|
-
}
|
|
2158
2162
|
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
2159
2163
|
getBuffer(varyingName) {
|
|
2160
2164
|
return this.transformFeedback.getBuffer(varyingName);
|
|
@@ -2221,13 +2225,6 @@ var __exports__ = (() => {
|
|
|
2221
2225
|
this.model.draw(renderPass);
|
|
2222
2226
|
renderPass.end();
|
|
2223
2227
|
}
|
|
2224
|
-
/** @deprecated */
|
|
2225
|
-
update(...args) {
|
|
2226
|
-
console.warn("TextureTransform#update() not implemented");
|
|
2227
|
-
}
|
|
2228
|
-
getData({ packed = false } = {}) {
|
|
2229
|
-
throw new Error("getData() not implemented");
|
|
2230
|
-
}
|
|
2231
2228
|
getTargetTexture() {
|
|
2232
2229
|
const { targetTexture } = this.bindings[this.currentIndex];
|
|
2233
2230
|
return targetTexture;
|
package/dist/dist.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var bs=Object.create;var pt=Object.defineProperty;var As=Object.getOwnPropertyDescriptor;var vs=Object.getOwnPropertyNames;var Ps=Object.getPrototypeOf,Os=Object.prototype.hasOwnProperty;var Ts=(s,t,e)=>t in s?pt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var ge=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Es=(s,t)=>{for(var e in t)pt(s,e,{get:t[e],enumerable:!0})},vt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of vs(t))!Os.call(s,i)&&i!==e&&pt(s,i,{get:()=>t[i],enumerable:!(n=As(t,i))||n.enumerable});return s},Pt=(s,t,e)=>(vt(s,t,"default"),e&&vt(e,t,"default")),D=(s,t,e)=>(e=s!=null?bs(Ps(s)):{},vt(t||!s||!s.__esModule?pt(e,"default",{value:s,enumerable:!0}):e,s)),Rs=s=>vt(pt({},"__esModule",{value:!0}),s);var Q=(s,t,e)=>(Ts(s,typeof t!="symbol"?t+"":t,e),e);var V=ge((vn,ye)=>{ye.exports=globalThis.luma});var rt=ge((Vn,be)=>{be.exports=globalThis.luma});var Mt={};Es(Mt,{AnimationLoop:()=>it,AnimationLoopTemplate:()=>Et,AsyncTexture:()=>st,BufferTransform:()=>ht,ClipSpace:()=>Ft,Computation:()=>yt,ConeGeometry:()=>Gt,CubeGeometry:()=>Yt,CylinderGeometry:()=>Ht,GPUGeometry:()=>ot,Geometry:()=>k,GroupNode:()=>mt,IcoSphereGeometry:()=>Xt,KeyFrames:()=>Tt,Model:()=>j,ModelNode:()=>Wt,PipelineFactory:()=>H,PlaneGeometry:()=>Kt,ScenegraphNode:()=>Z,ShaderFactory:()=>X,SphereGeometry:()=>Zt,TextureTransform:()=>Nt,Timeline:()=>Ot,TruncatedConeGeometry:()=>tt,_ShaderInputs:()=>J,cancelAnimationFrame:()=>St,loadImage:()=>Le,loadImageBitmap:()=>It,makeAnimationLoop:()=>we,makeRandomGenerator:()=>gs,requestAnimationFrame:()=>Rt,setPathPrefix:()=>Se});Pt(Mt,D(V(),1));var Ss=1,Ls=1,Ot=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(t){let{delay:e=0,duration:n=Number.POSITIVE_INFINITY,rate:i=1,repeat:r=1}=t,a=Ss++,o={time:0,delay:e,duration:n,rate:i,repeat:r};return this._setChannelTime(o,this.time),this.channels.set(a,o),a}removeChannel(t){this.channels.delete(t);for(let[e,n]of this.animations)n.channel===t&&this.detachAnimation(e)}isFinished(t){let e=this.channels.get(t);return e===void 0?!1:this.time>=e.delay+e.duration*e.repeat}getTime(t){if(t===void 0)return this.time;let e=this.channels.get(t);return e===void 0?-1:e.time}setTime(t){this.time=Math.max(0,t);let e=this.channels.values();for(let i of e)this._setChannelTime(i,this.time);let n=this.animations.values();for(let i of n){let{animation:r,channel:a}=i;r.setTime(this.getTime(a))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(t,e){let n=Ls++;return this.animations.set(n,{animation:t,channel:e}),t.setTime(this.getTime(e)),n}detachAnimation(t){this.animations.delete(t)}update(t){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=t),this.setTime(this.time+(t-this.lastEngineTime)),this.lastEngineTime=t)}_setChannelTime(t,e){let n=e-t.delay,i=t.duration*t.repeat;n>=i?t.time=t.duration*t.rate:(t.time=Math.max(0,n)%t.duration,t.time*=t.rate)}};var Tt=class{startIndex=-1;endIndex=-1;factor=0;times=[];values=[];_lastTime=-1;constructor(t){this.setKeyFrames(t),this.setTime(0)}setKeyFrames(t){let e=t.length;this.times.length=e,this.values.length=e;for(let n=0;n<e;++n)this.times[n]=t[n][0],this.values[n]=t[n][1];this._calculateKeys(this._lastTime)}setTime(t){t=Math.max(0,t),t!==this._lastTime&&(this._calculateKeys(t),this._lastTime=t)}getStartTime(){return this.times[this.startIndex]}getEndTime(){return this.times[this.endIndex]}getStartData(){return this.values[this.startIndex]}getEndData(){return this.values[this.endIndex]}_calculateKeys(t){let e=0,n=this.times.length;for(e=0;e<n-2&&!(this.times[e+1]>t);++e);this.startIndex=e,this.endIndex=e+1;let i=this.times[this.startIndex],r=this.times[this.endIndex];this.factor=Math.min(Math.max(0,(t-i)/(r-i)),1)}};var Et=class{constructor(t){}async onInitialize(t){return null}};var Me=D(V(),1);function Rt(s){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(s):setTimeout(s,1e3/60)}function St(s){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(s):clearTimeout(s)}function ut(){let s;if(typeof window<"u"&&window.performance)s=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();s=t[0]*1e3+t[1]/1e6}else s=Date.now();return s}var et=class{constructor(t,e){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=e,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=ut(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(ut()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var nt=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,e="count"){return this._getOrCreate({name:t,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let e of Object.values(this.stats))t(e)}getTable(){let t={};return this.forEach(e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(e=>this._getOrCreate(e))}_getOrCreate(t){let{name:e,type:n}=t,i=this.stats[e];return i||(t instanceof et?i=t:i=new et(e,n),this.stats[e]=i),i}};var Cs=0,Is={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:s=>console.error(s),stats:Me.luma.stats.get(`animation-loop-${Cs++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},it=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(t){if(this.props={...Is,...t},t=this.props,!t.device)throw new Error("No device provided");let{useDevicePixels:e=!0}=this.props;this.stats=t.stats||new nt({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:t.autoResizeViewport,autoResizeDrawingBuffer:t.autoResizeDrawingBuffer,useDevicePixels:e}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(t){return this.needsRedraw=this.needsRedraw||t,this}setProps(t){return"autoResizeViewport"in t&&(this.props.autoResizeViewport=t.autoResizeViewport||!1),"autoResizeDrawingBuffer"in t&&(this.props.autoResizeDrawingBuffer=t.autoResizeDrawingBuffer||!1),"useDevicePixels"in t&&(this.props.useDevicePixels=t.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let t;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(t!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(t){let e=t instanceof Error?t:new Error("Unknown error");throw this.props.onError(e),e}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(t){return this.timeline=t,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(t=>{this._resolveNextFrame=t})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(t){this.display&&(this.display.destroy(),this.display.animationLoop=null),t&&(t.animationLoop=this),this.display=t}_requestAnimationFrame(){this._running&&(this._animationFrameId=Rt(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(St(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(t){if(this.display){this.display._renderFrame(t);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){let t=this.device?.canvasContext?.canvas;if(!this.device||!t)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:t,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:t,height:e,aspect:n}=this._getSizeAndAspect();(t!==this.animationProps.width||e!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=e,this.animationProps.aspect=n,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let t=document.createElement("div");document.body.appendChild(t),t.style.position="relative";let e=document.createElement("div");e.style.position="absolute",e.style.left="10px",e.style.bottom="10px",e.style.width="300px",e.style.background="white",this.canvas instanceof HTMLCanvasElement&&t.appendChild(this.canvas),t.appendChild(e);let n=this.props.onAddHTML(e);n&&(e.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[t,e]=this.device?.canvasContext?.getPixelSize()||[1,1],n=1,i=this.device?.canvasContext?.canvas;return i&&i.clientHeight?n=i.clientWidth/i.clientHeight:t>0&&e>0&&(n=t/e),{width:t,height:e,aspect:n}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(t){t instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[t.offsetX,t.offsetY])}_onMouseleave(t){this._getAnimationProps()._mousePosition=null}};var _e=D(V(),1);function we(s,t){let e=null,n=t?.device||_e.luma.createDevice({id:"animation-loop"}),i=new it({...t,device:n,async onInitialize(r){return e=new s(r),await e?.onInitialize(r)},onRender:r=>e?.onRender(r),onFinalize:r=>e?.onFinalize(r)});return i.getInfo=()=>this.AnimationLoopTemplateCtor.info,i}var O=D(V(),1),zt=D(rt(),1);var xt=D(V(),1);var Jt={};function C(s="id"){Jt[s]=Jt[s]||1;let t=Jt[s]++;return`${s}-${t}`}var ot=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(t){if(this.id=t.id||C("geometry"),this.topology=t.topology,this.indices=t.indices||null,this.attributes=t.attributes,this.vertexCount=t.vertexCount,this.bufferLayout=t.bufferLayout||[],this.indices&&!(this.indices.usage&xt.Buffer.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(t){return t.byteLength/12}};function Ae(s,t){if(t instanceof ot)return t;let e=zs(s,t),{attributes:n,bufferLayout:i}=Ns(s,t);return new ot({topology:t.topology||"triangle-list",bufferLayout:i,vertexCount:t.vertexCount,indices:e,attributes:n})}function zs(s,t){if(!t.indices)return;let e=t.indices.value;return s.createBuffer({usage:xt.Buffer.INDEX,data:e})}function Ns(s,t){let e=[],n={};for(let[r,a]of Object.entries(t.attributes)){let o=r;switch(r){case"POSITION":o="positions";break;case"NORMAL":o="normals";break;case"TEXCOORD_0":o="texCoords";break;case"COLOR_0":o="colors";break}if(a){n[o]=s.createBuffer({data:a.value,id:`${r}-buffer`});let{value:c,size:h,normalized:f}=a;e.push({name:o,format:(0,xt.getVertexFormatFromAttribute)(c,h,f)})}}let i=t._calculateVertexCount(t.attributes,t.indices);return{attributes:n,bufferLayout:e,vertexCount:i}}var at=D(V(),1);var te=class{static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new te(t),t._lumaData.defaultPipelineFactory}device;destroyPolicy;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};constructor(t){this.device=t,this.destroyPolicy=t.props._factoryDestroyPolicy}createRenderPipeline(t){let e={...at.RenderPipeline.defaultProps,...t},n=this._hashRenderPipeline(e);if(!this._renderPipelineCache[n]){let i=this.device.createRenderPipeline({...e,id:e.id?`${e.id}-cached`:void 0});i.hash=n,this._renderPipelineCache[n]={pipeline:i,useCount:0}}return this._renderPipelineCache[n].useCount++,this._renderPipelineCache[n].pipeline}createComputePipeline(t){let e={...at.ComputePipeline.defaultProps,...t},n=this._hashComputePipeline(e);if(!this._computePipelineCache[n]){let i=this.device.createComputePipeline({...e,id:e.id?`${e.id}-cached`:void 0});i.hash=n,this._computePipelineCache[n]={pipeline:i,useCount:0}}return this._computePipelineCache[n].useCount++,this._computePipelineCache[n].pipeline}release(t){let e=t.hash,n=t instanceof at.ComputePipeline?this._computePipelineCache:this._renderPipelineCache;n[e].useCount--,n[e].useCount===0&&this.destroyPolicy==="unused"&&(n[e].pipeline.destroy(),delete n[e])}_hashComputePipeline(t){return`${this._getHash(t.shader.source)}`}_hashRenderPipeline(t){let e=t.vs?this._getHash(t.vs.source):0,n=t.fs?this._getHash(t.fs.source):0,i="-",r=this._getHash(JSON.stringify(t.bufferLayout));switch(this.device.type){case"webgl":return`${e}/${n}V${i}BL${r}`;default:let a=this._getHash(JSON.stringify(t.parameters));return`${e}/${n}V${i}T${t.topology}P${a}BL${r}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}},H=te;Q(H,"defaultProps",{...at.RenderPipeline.defaultProps});var ve=D(V(),1);var ee=class{static getDefaultShaderFactory(t){return t._lumaData.defaultShaderFactory||=new ee(t),t._lumaData.defaultShaderFactory}device;destroyPolicy;_cache={};constructor(t){this.device=t,this.destroyPolicy=t.props._factoryDestroyPolicy}createShader(t){let e=this._hashShader(t),n=this._cache[e];if(!n){let i=this.device.createShader({...t,id:t.id?`${t.id}-cached`:void 0});this._cache[e]=n={shader:i,useCount:0}}return n.useCount++,n.shader}release(t){let e=this._hashShader(t),n=this._cache[e];n&&(n.useCount--,n.useCount===0&&this.destroyPolicy==="unused"&&(delete this._cache[e],n.shader.destroy()))}_hashShader(t){return`${t.stage}:${t.source}`}},X=ee;Q(X,"defaultProps",{...ve.Shader.defaultProps});function Pe(s,t){let e={},n="Values";if(s.attributes.length===0&&!s.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(let i of s.attributes)if(i){let r=`${i.location} ${i.name}: ${i.type}`;e[`in ${r}`]={[n]:i.stepMode||"vertex"}}for(let i of s.varyings||[]){let r=`${i.location} ${i.name}`;e[`out ${r}`]={[n]:JSON.stringify(i)}}return e}var z=null,se=null;function Oe(s,{id:t,minimap:e,opaque:n,top:i="0",left:r="0",rgbaScale:a=1}){z||(z=document.createElement("canvas"),z.id=t,z.title=t,z.style.zIndex="100",z.style.position="absolute",z.style.top=i,z.style.left=r,z.style.border="blue 1px solid",z.style.transform="scaleY(-1)",document.body.appendChild(z),se=z.getContext("2d")),(z.width!==s.width||z.height!==s.height)&&(z.width=s.width/2,z.height=s.height/2,z.style.width="400px",z.style.height="400px");let o=s.device.readPixelsToArrayWebGL(s),c=se?.createImageData(s.width,s.height);if(c){for(let f=0;f<o.length;f+=4)c.data[0+f+0]=o[f+0]*a,c.data[0+f+1]=o[f+1]*a,c.data[0+f+2]=o[f+2]*a,c.data[0+f+3]=n?255:o[f+3]*a;se?.putImageData(c,0,0)}}function Lt(s,t,e){if(s===t)return!0;if(!e||!s||!t)return!1;if(Array.isArray(s)){if(!Array.isArray(t)||s.length!==t.length)return!1;for(let n=0;n<s.length;n++)if(!Lt(s[n],t[n],e-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof s=="object"&&typeof t=="object"){let n=Object.keys(s),i=Object.keys(t);if(n.length!==i.length)return!1;for(let r of n)if(!t.hasOwnProperty(r)||!Lt(s[r],t[r],e-1))return!1;return!0}return!1}function Te(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Ee(s){return Array.isArray(s)?s.length===0||typeof s[0]=="number":!1}function gt(s){return Te(s)||Ee(s)}function Fs(s){return gt(s)||typeof s=="number"||typeof s=="boolean"}function Ct(s){let t={bindings:{},uniforms:{}};return Object.keys(s).forEach(e=>{let n=s[e];Fs(n)?t.uniforms[e]=n:t.bindings[e]=n}),t}var ne=D(V(),1),Re=D(rt(),1);var J=class{modules;moduleUniforms;moduleBindings;constructor(t){let e=(0,Re.getShaderModuleDependencies)(Object.values(t).filter(n=>n.dependencies));for(let n of e)t[n.name]=n;ne.log.log(1,"Creating ShaderInputs with modules",Object.keys(t))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(let[n,i]of Object.entries(t)){let r=n;this.moduleUniforms[r]=i.defaultUniforms||{},this.moduleBindings[r]={}}}destroy(){}setProps(t){for(let e of Object.keys(t)){let n=e,i=t[n]||{},r=this.modules[n];if(!r){ne.log.warn(`Module ${e} not found`)();continue}let a=this.moduleUniforms[n],o=this.moduleBindings[n],c=r.getUniforms?.(i,this.moduleUniforms[n]);c||={...this.moduleUniforms[n],...i};let{uniforms:h,bindings:f}=Ct(c);this.moduleUniforms[n]={...a,...h},this.moduleBindings[n]={...o,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let t={};for(let e of Object.values(this.moduleBindings))Object.assign(t,e);return t}getDebugTable(){let t={};for(let[e,n]of Object.entries(this.moduleUniforms))for(let[i,r]of Object.entries(n))t[`${e}.${i}`]={type:this.modules[e].uniformTypes?.[i],value:String(r)};return t}};var ie="";function Se(s){ie=s}async function It(s,t){let e=new Image;return e.crossOrigin=t?.crossOrigin||"anonymous",e.src=s.startsWith("http")?s:ie+s,await e.decode(),await createImageBitmap(e)}async function Le(s,t){return await new Promise((e,n)=>{try{let i=new Image;i.onload=()=>e(i),i.onerror=()=>n(new Error(`Could not load image ${s}.`)),i.crossOrigin=t?.crossOrigin||"anonymous",i.src=s.startsWith("http")?s:ie+s}catch(i){n(i)}})}var st=class{device;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};constructor(t,e){this.device=t,typeof e?.data=="string"&&e.dimension==="2d"&&(e={...e,data:It(e.data)}),this.ready=new Promise((n,i)=>{this.resolveReady=()=>{this.isReady=!0,n()},this.rejectReady=i}),this.initAsync(e)}async initAsync(t){let e,n,i=t.data,r=await Ce(i).then(e,n);if(this.destroyed)return;let a={...t,data:r};this.texture=this.device.createTexture(a),this.sampler=this.texture.sampler,this.view=this.texture.view,this.isReady=!0}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}};async function Ce(s){if(s=await s,Array.isArray(s))return await Promise.all(s.map(Ce));if(s&&typeof s=="object"&&s.constructor===Object){let t=s,e=await Promise.all(Object.values(t)),n=Object.keys(t),i={};for(let r=0;r<n.length;r++)i[n[r]]=e[r];return i}return s}var ct=2,Ds=1e4,re=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;constructor(t,e){this.props={...re.defaultProps,...e},e=this.props,this.id=e.id||C("model"),this.device=t,Object.assign(this.userData,e.userData);let n=Object.fromEntries(this.props.modules?.map(o=>[o.name,o])||[]);this.setShaderInputs(e.shaderInputs||new J(n));let i=ks(t),r=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=(0,zt.getShaderLayoutFromWGSL)(this.props.source);let{source:o,getUniforms:c}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:i,...this.props,modules:r});this.source=o,this._getModuleUniforms=c}else{let{vs:o,fs:c,getUniforms:h}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:i,...this.props,modules:r});this.vs=o,this.fs=c,this._getModuleUniforms=h}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,e.geometry&&this.setGeometry(e.geometry),this.pipelineFactory=e.pipelineFactory||H.getDefaultPipelineFactory(this.device),this.shaderFactory=e.shaderFactory||X.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in e&&(this.isInstanced=e.isInstanced),e.instanceCount&&this.setInstanceCount(e.instanceCount),e.vertexCount&&this.setVertexCount(e.vertexCount),e.indexBuffer&&this.setIndexBuffer(e.indexBuffer),e.attributes&&this.setAttributes(e.attributes),e.constantAttributes&&this.setConstantAttributes(e.constantAttributes),e.bindings&&this.setBindings(e.bindings),e.uniforms&&this.setUniforms(e.uniforms),e.moduleSettings&&this.updateModuleSettings(e.moduleSettings),e.transformFeedback&&(this.transformFeedback=e.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let t=this._needsRedraw;return this._needsRedraw=!1,t}setNeedsRedraw(t){this._needsRedraw||=t}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(t){this.predraw();let e;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline();let n=this._getBindings();this.pipeline.setBindings(n,{disableWarnings:this.props.disableWarnings}),Ne(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:i}=this.vertexArray,r=i?i.byteLength/(i.indexType==="uint32"?4:2):void 0;e=this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:r,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(t),e?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",e}setGeometry(t){this._gpuGeometry?.destroy();let e=t&&Ae(this.device,t);e&&(this.setTopology(e.topology||"triangle-list"),this.bufferLayout=Ie(e.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(e)),this._gpuGeometry=e}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){this.bufferLayout=this._gpuGeometry?Ie(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){Lt(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(t){this.instanceCount=t,this.isInstanced===void 0&&t>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(t){this.vertexCount=t,this.setNeedsRedraw("vertexCount")}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new O.UniformStore(this.shaderInputs.modules);for(let e of Object.keys(this.shaderInputs.modules)){let n=this._uniformStore.getManagedUniformBuffer(this.device,e);this.bindings[`${e}Uniforms`]=n}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(t){Object.assign(this.bindings,t),this.setNeedsRedraw("bindings")}setTransformFeedback(t){this.transformFeedback=t,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(t,e){t.indices&&O.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[n,i]of Object.entries(t)){let r=this.bufferLayout.find(c=>ze(c).includes(n));if(!r){O.log.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();continue}let a=ze(r),o=!1;for(let c of a){let h=this._attributeInfos[c];h&&(this.vertexArray.setBuffer(h.location,i),o=!0)}!o&&!(e?.disableWarnings??this.props.disableWarnings)&&O.log.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${n}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(t,e){for(let[n,i]of Object.entries(t)){let r=this._attributeInfos[n];r?this.vertexArray.setConstantWebGL(r.location,i):(e?.disableWarnings??this.props.disableWarnings)||O.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}setUniforms(t){Ne(t)||(this.pipeline.setUniformsWebGL(t),Object.assign(this.uniforms,t)),this.setNeedsRedraw("uniforms")}updateModuleSettings(t){let{bindings:e,uniforms:n}=Ct(this._getModuleUniforms(t));Object.assign(this.bindings,e),Object.assign(this.uniforms,n),this.setNeedsRedraw("moduleSettings")}_getBindings(){return Object.entries(this.bindings).reduce((t,[e,n])=>(n instanceof st?n.isReady&&(t[e]=n.texture):t[e]=n,t),{})}_getBindingsUpdateTimestamp(){let t=0;for(let e of Object.values(this.bindings))e instanceof O.TextureView?t=Math.max(t,e.texture.updateTimestamp):e instanceof O.Buffer||e instanceof O.Texture?t=Math.max(t,e.updateTimestamp):e instanceof st?t=e.texture?Math.max(t,e.texture.updateTimestamp):1/0:e instanceof O.Sampler||(t=Math.max(t,e.buffer.updateTimestamp));return t}_setGeometryAttributes(t){let e={...t.attributes};for(let[n]of Object.entries(e))!this.pipeline.shaderLayout.attributes.find(i=>i.name===n)&&n!=="positions"&&delete e[n];this.vertexCount=t.vertexCount,this.setIndexBuffer(t.indices||null),this.setAttributes(t.attributes,{disableWarnings:!0}),this.setAttributes(e,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate||=t,this.setNeedsRedraw(t)}_updatePipeline(){if(this._pipelineNeedsUpdate){let t=null,e=null;this.pipeline&&(O.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.pipeline.vs,e=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),i=null;this.source?i=n:this.fs&&(i=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:n,fs:i}),this._attributeInfos=(0,O.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout,this.bufferLayout),t&&this.shaderFactory.release(t),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let t=O.log.level>3?0:Ds;O.log.level<2||Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,O.log.group(ct,`>>> DRAWING MODEL ${this.id}`,{collapsed:O.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=Pe(this.pipeline.shaderLayout,this.id);O.log.table(ct,t)();let e=this.shaderInputs.getDebugTable();for(let[i,r]of Object.entries(this.uniforms))e[i]={value:r};O.log.table(ct,e)();let n=this._getAttributeDebugTable();O.log.table(ct,this._attributeInfos)(),O.log.table(ct,n)(),O.log.groupEnd(ct)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(t){let e=O.log.get("framebuffer");if(this._drawCount++,!e||this._drawCount++>3&&this._drawCount%60)return;let n=t.props.framebuffer;n&&Oe(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){let t={};for(let[e,n]of Object.entries(this._attributeInfos)){let i=this.vertexArray.attributes[n.location];t[n.location]={name:e,type:n.shaderType,values:i?this._getBufferOrConstantValues(i,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:e}=this.vertexArray,n=e.indexType==="uint32"?new Uint32Array(e.debugData):new Uint16Array(e.debugData);t.indices={name:"indices",type:e.indexType,values:n.toString()}}return t}_getBufferOrConstantValues(t,e){let n=(0,O.getTypedArrayFromDataType)(e);return(t instanceof O.Buffer?new n(t.debugData):t).toString()}},j=re;Q(j,"defaultProps",{...O.RenderPipeline.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:zt.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function Ie(s,t){let e=[...s];for(let n of t){let i=e.findIndex(r=>r.name===n.name);i<0?e.push(n):e[i]=n}return e}function ks(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,features:s.features}}function ze(s){return s.attributes?s.attributes?.map(t=>t.attribute):[s.name]}function Ne(s){let t=!0;for(let e in s){t=!1;break}return t}var Fe=D(V(),1),De=D(rt(),1);var ht=class{device;model;transformFeedback;static isSupported(t){return t?.info?.type==="webgl"}constructor(t,e=j.defaultProps){if(!ht.isSupported(t))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=t,this.model=new j(this.device,{id:e.id||"buffer-transform-model",fs:e.fs||(0,De.getPassthroughFS)(),topology:e.topology||"point-list",...e}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:e.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(t){let e=this.device.beginRenderPass(t);this.model.draw(e),e.end()}update(...t){console.warn("TextureTransform#update() not implemented")}getBuffer(t){return this.transformFeedback.getBuffer(t)}readAsync(t){let e=this.getBuffer(t);if(!e)throw new Error("BufferTransform#getBuffer");if(e instanceof Fe.Buffer)return e.readAsync();let{buffer:n,byteOffset:i=0,byteLength:r=n.byteLength}=e;return n.readAsync(i,r)}};var ke=D(rt(),1),Bs="transform_output",Nt=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(t,e){this.device=t,this.sampler=t.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new j(this.device,{id:e.id||"texture-transform-model",fs:e.fs||(0,ke.getPassthroughFS)({input:e.targetTextureVarying,inputChannels:e.targetTextureChannels,output:Bs}),vertexCount:e.vertexCount,...e}),this._initialize(e),Object.seal(this)}destroy(){}delete(){this.destroy()}run(t){let{framebuffer:e}=this.bindings[this.currentIndex],n=this.device.beginRenderPass({framebuffer:e,...t});this.model.draw(n),n.end()}update(...t){console.warn("TextureTransform#update() not implemented")}getData({packed:t=!1}={}){throw new Error("getData() not implemented")}getTargetTexture(){let{targetTexture:t}=this.bindings[this.currentIndex];return t}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(t){this._updateBindings(t)}_updateBindings(t){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],t)}_updateBinding(t,{sourceBuffers:e,sourceTextures:n,targetTexture:i}){if(t||(t={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(t.sourceTextures,n),Object.assign(t.sourceBuffers,e),i){t.targetTexture=i;let{width:r,height:a}=i;t.framebuffer&&t.framebuffer.destroy(),t.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:r,height:a,colorAttachments:[i]}),t.framebuffer.resize({width:r,height:a})}return t}_setSourceTextureParameters(){let t=this.currentIndex,{sourceTextures:e}=this.bindings[t];for(let n in e)e[n].sampler=this.sampler}};var k=class{id;topology;vertexCount;indices;attributes;userData={};constructor(t){let{attributes:e={},indices:n=null,vertexCount:i=null}=t;this.id=t.id||C("geometry"),this.topology=t.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[r,a]of Object.entries(e)){let o=ArrayBuffer.isView(a)?{value:a}:a;if(!ArrayBuffer.isView(o.value))throw new Error(`${this._print(r)}: must be typed array or object with value as typed array`);if((r==="POSITION"||r==="positions")&&!o.size&&(o.size=3),r==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=o}else this.attributes[r]=o}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(t){return`Geometry ${this.id} attribute ${t}`}_setAttributes(t,e){return this}_calculateVertexCount(t,e){if(e)return e.value.length;let n=1/0;for(let i of Object.values(t)){let{value:r,size:a,constant:o}=i;!o&&r&&a!==void 0&&a>=1&&(n=Math.min(n,r.length/a))}return n}};var Us=`#version 300 es
|
|
7
|
+
"use strict";var __exports__=(()=>{var bs=Object.create;var ut=Object.defineProperty;var As=Object.getOwnPropertyDescriptor;var vs=Object.getOwnPropertyNames;var Ps=Object.getPrototypeOf,Os=Object.prototype.hasOwnProperty;var Ts=(s,t,e)=>t in s?ut(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var ge=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports),Es=(s,t)=>{for(var e in t)ut(s,e,{get:t[e],enumerable:!0})},vt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of vs(t))!Os.call(s,i)&&i!==e&&ut(s,i,{get:()=>t[i],enumerable:!(n=As(t,i))||n.enumerable});return s},Pt=(s,t,e)=>(vt(s,t,"default"),e&&vt(e,t,"default")),D=(s,t,e)=>(e=s!=null?bs(Ps(s)):{},vt(t||!s||!s.__esModule?ut(e,"default",{value:s,enumerable:!0}):e,s)),Rs=s=>vt(ut({},"__esModule",{value:!0}),s);var Q=(s,t,e)=>(Ts(s,typeof t!="symbol"?t+"":t,e),e);var V=ge((vn,ye)=>{ye.exports=globalThis.luma});var rt=ge((Vn,be)=>{be.exports=globalThis.luma});var Mt={};Es(Mt,{AnimationLoop:()=>it,AnimationLoopTemplate:()=>Et,AsyncTexture:()=>st,BufferTransform:()=>ht,ClipSpace:()=>Ft,Computation:()=>yt,ConeGeometry:()=>Gt,CubeGeometry:()=>Yt,CylinderGeometry:()=>Ht,GPUGeometry:()=>ot,Geometry:()=>k,GroupNode:()=>mt,IcoSphereGeometry:()=>Xt,KeyFrames:()=>Tt,Model:()=>j,ModelNode:()=>Wt,PipelineFactory:()=>H,PlaneGeometry:()=>Kt,ScenegraphNode:()=>Z,ShaderFactory:()=>X,SphereGeometry:()=>Zt,TextureTransform:()=>Nt,Timeline:()=>Ot,TruncatedConeGeometry:()=>tt,_ShaderInputs:()=>J,cancelAnimationFrame:()=>St,loadImage:()=>Le,loadImageBitmap:()=>It,makeAnimationLoop:()=>we,makeRandomGenerator:()=>gs,requestAnimationFrame:()=>Rt,setPathPrefix:()=>Se});Pt(Mt,D(V(),1));var Ss=1,Ls=1,Ot=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(t){let{delay:e=0,duration:n=Number.POSITIVE_INFINITY,rate:i=1,repeat:r=1}=t,a=Ss++,o={time:0,delay:e,duration:n,rate:i,repeat:r};return this._setChannelTime(o,this.time),this.channels.set(a,o),a}removeChannel(t){this.channels.delete(t);for(let[e,n]of this.animations)n.channel===t&&this.detachAnimation(e)}isFinished(t){let e=this.channels.get(t);return e===void 0?!1:this.time>=e.delay+e.duration*e.repeat}getTime(t){if(t===void 0)return this.time;let e=this.channels.get(t);return e===void 0?-1:e.time}setTime(t){this.time=Math.max(0,t);let e=this.channels.values();for(let i of e)this._setChannelTime(i,this.time);let n=this.animations.values();for(let i of n){let{animation:r,channel:a}=i;r.setTime(this.getTime(a))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(t,e){let n=Ls++;return this.animations.set(n,{animation:t,channel:e}),t.setTime(this.getTime(e)),n}detachAnimation(t){this.animations.delete(t)}update(t){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=t),this.setTime(this.time+(t-this.lastEngineTime)),this.lastEngineTime=t)}_setChannelTime(t,e){let n=e-t.delay,i=t.duration*t.repeat;n>=i?t.time=t.duration*t.rate:(t.time=Math.max(0,n)%t.duration,t.time*=t.rate)}};var Tt=class{startIndex=-1;endIndex=-1;factor=0;times=[];values=[];_lastTime=-1;constructor(t){this.setKeyFrames(t),this.setTime(0)}setKeyFrames(t){let e=t.length;this.times.length=e,this.values.length=e;for(let n=0;n<e;++n)this.times[n]=t[n][0],this.values[n]=t[n][1];this._calculateKeys(this._lastTime)}setTime(t){t=Math.max(0,t),t!==this._lastTime&&(this._calculateKeys(t),this._lastTime=t)}getStartTime(){return this.times[this.startIndex]}getEndTime(){return this.times[this.endIndex]}getStartData(){return this.values[this.startIndex]}getEndData(){return this.values[this.endIndex]}_calculateKeys(t){let e=0,n=this.times.length;for(e=0;e<n-2&&!(this.times[e+1]>t);++e);this.startIndex=e,this.endIndex=e+1;let i=this.times[this.startIndex],r=this.times[this.endIndex];this.factor=Math.min(Math.max(0,(t-i)/(r-i)),1)}};var Et=class{constructor(t){}async onInitialize(t){return null}};var Me=D(V(),1);function Rt(s){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(s):setTimeout(s,1e3/60)}function St(s){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(s):clearTimeout(s)}function pt(){let s;if(typeof window<"u"&&window.performance)s=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();s=t[0]*1e3+t[1]/1e6}else s=Date.now();return s}var et=class{constructor(t,e){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=e,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=pt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(pt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var nt=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,e="count"){return this._getOrCreate({name:t,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let e of Object.values(this.stats))t(e)}getTable(){let t={};return this.forEach(e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(e=>this._getOrCreate(e))}_getOrCreate(t){let{name:e,type:n}=t,i=this.stats[e];return i||(t instanceof et?i=t:i=new et(e,n),this.stats[e]=i),i}};var Cs=0,Is={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:s=>console.error(s),stats:Me.luma.stats.get(`animation-loop-${Cs++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},it=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(t){if(this.props={...Is,...t},t=this.props,!t.device)throw new Error("No device provided");let{useDevicePixels:e=!0}=this.props;this.stats=t.stats||new nt({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:t.autoResizeViewport,autoResizeDrawingBuffer:t.autoResizeDrawingBuffer,useDevicePixels:e}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(t){return this.needsRedraw=this.needsRedraw||t,this}setProps(t){return"autoResizeViewport"in t&&(this.props.autoResizeViewport=t.autoResizeViewport||!1),"autoResizeDrawingBuffer"in t&&(this.props.autoResizeDrawingBuffer=t.autoResizeDrawingBuffer||!1),"useDevicePixels"in t&&(this.props.useDevicePixels=t.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let t;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(t!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(t){let e=t instanceof Error?t:new Error("Unknown error");throw this.props.onError(e),e}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(t){return this.timeline=t,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(t=>{this._resolveNextFrame=t})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(t){this.display&&(this.display.destroy(),this.display.animationLoop=null),t&&(t.animationLoop=this),this.display=t}_requestAnimationFrame(){this._running&&(this._animationFrameId=Rt(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(St(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(t){if(this.display){this.display._renderFrame(t);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){let t=this.device?.canvasContext?.canvas;if(!this.device||!t)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:t,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:t,height:e,aspect:n}=this._getSizeAndAspect();(t!==this.animationProps.width||e!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=e,this.animationProps.aspect=n,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let t=document.createElement("div");document.body.appendChild(t),t.style.position="relative";let e=document.createElement("div");e.style.position="absolute",e.style.left="10px",e.style.bottom="10px",e.style.width="300px",e.style.background="white",this.canvas instanceof HTMLCanvasElement&&t.appendChild(this.canvas),t.appendChild(e);let n=this.props.onAddHTML(e);n&&(e.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[t,e]=this.device?.canvasContext?.getPixelSize()||[1,1],n=1,i=this.device?.canvasContext?.canvas;return i&&i.clientHeight?n=i.clientWidth/i.clientHeight:t>0&&e>0&&(n=t/e),{width:t,height:e,aspect:n}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(t){t instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[t.offsetX,t.offsetY])}_onMouseleave(t){this._getAnimationProps()._mousePosition=null}};var _e=D(V(),1);function we(s,t){let e=null,n=t?.device||_e.luma.createDevice({id:"animation-loop"}),i=new it({...t,device:n,async onInitialize(r){return e=new s(r),await e?.onInitialize(r)},onRender:r=>e?.onRender(r),onFinalize:r=>e?.onFinalize(r)});return i.getInfo=()=>this.AnimationLoopTemplateCtor.info,i}var O=D(V(),1),zt=D(rt(),1);var xt=D(V(),1);var Jt={};function C(s="id"){Jt[s]=Jt[s]||1;let t=Jt[s]++;return`${s}-${t}`}var ot=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(t){if(this.id=t.id||C("geometry"),this.topology=t.topology,this.indices=t.indices||null,this.attributes=t.attributes,this.vertexCount=t.vertexCount,this.bufferLayout=t.bufferLayout||[],this.indices&&!(this.indices.usage&xt.Buffer.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let t of Object.values(this.attributes))t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(t){return t.byteLength/12}};function Ae(s,t){if(t instanceof ot)return t;let e=zs(s,t),{attributes:n,bufferLayout:i}=Ns(s,t);return new ot({topology:t.topology||"triangle-list",bufferLayout:i,vertexCount:t.vertexCount,indices:e,attributes:n})}function zs(s,t){if(!t.indices)return;let e=t.indices.value;return s.createBuffer({usage:xt.Buffer.INDEX,data:e})}function Ns(s,t){let e=[],n={};for(let[r,a]of Object.entries(t.attributes)){let o=r;switch(r){case"POSITION":o="positions";break;case"NORMAL":o="normals";break;case"TEXCOORD_0":o="texCoords";break;case"COLOR_0":o="colors";break}if(a){n[o]=s.createBuffer({data:a.value,id:`${r}-buffer`});let{value:c,size:h,normalized:f}=a;e.push({name:o,format:(0,xt.getVertexFormatFromAttribute)(c,h,f)})}}let i=t._calculateVertexCount(t.attributes,t.indices);return{attributes:n,bufferLayout:e,vertexCount:i}}var at=D(V(),1);var te=class{static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new te(t),t._lumaData.defaultPipelineFactory}device;destroyPolicy;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};constructor(t){this.device=t,this.destroyPolicy=t.props._factoryDestroyPolicy}createRenderPipeline(t){let e={...at.RenderPipeline.defaultProps,...t},n=this._hashRenderPipeline(e);if(!this._renderPipelineCache[n]){let i=this.device.createRenderPipeline({...e,id:e.id?`${e.id}-cached`:void 0});i.hash=n,this._renderPipelineCache[n]={pipeline:i,useCount:0}}return this._renderPipelineCache[n].useCount++,this._renderPipelineCache[n].pipeline}createComputePipeline(t){let e={...at.ComputePipeline.defaultProps,...t},n=this._hashComputePipeline(e);if(!this._computePipelineCache[n]){let i=this.device.createComputePipeline({...e,id:e.id?`${e.id}-cached`:void 0});i.hash=n,this._computePipelineCache[n]={pipeline:i,useCount:0}}return this._computePipelineCache[n].useCount++,this._computePipelineCache[n].pipeline}release(t){let e=t.hash,n=t instanceof at.ComputePipeline?this._computePipelineCache:this._renderPipelineCache;n[e].useCount--,n[e].useCount===0&&this.destroyPolicy==="unused"&&(n[e].pipeline.destroy(),delete n[e])}_hashComputePipeline(t){return`${this._getHash(t.shader.source)}`}_hashRenderPipeline(t){let e=t.vs?this._getHash(t.vs.source):0,n=t.fs?this._getHash(t.fs.source):0,i="-",r=this._getHash(JSON.stringify(t.bufferLayout));switch(this.device.type){case"webgl":return`${e}/${n}V${i}BL${r}`;default:let a=this._getHash(JSON.stringify(t.parameters));return`${e}/${n}V${i}T${t.topology}P${a}BL${r}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}},H=te;Q(H,"defaultProps",{...at.RenderPipeline.defaultProps});var ve=D(V(),1);var ee=class{static getDefaultShaderFactory(t){return t._lumaData.defaultShaderFactory||=new ee(t),t._lumaData.defaultShaderFactory}device;destroyPolicy;_cache={};constructor(t){this.device=t,this.destroyPolicy=t.props._factoryDestroyPolicy}createShader(t){let e=this._hashShader(t),n=this._cache[e];if(!n){let i=this.device.createShader({...t,id:t.id?`${t.id}-cached`:void 0});this._cache[e]=n={shader:i,useCount:0}}return n.useCount++,n.shader}release(t){let e=this._hashShader(t),n=this._cache[e];n&&(n.useCount--,n.useCount===0&&this.destroyPolicy==="unused"&&(delete this._cache[e],n.shader.destroy()))}_hashShader(t){return`${t.stage}:${t.source}`}},X=ee;Q(X,"defaultProps",{...ve.Shader.defaultProps});function Pe(s,t){let e={},n="Values";if(s.attributes.length===0&&!s.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(let i of s.attributes)if(i){let r=`${i.location} ${i.name}: ${i.type}`;e[`in ${r}`]={[n]:i.stepMode||"vertex"}}for(let i of s.varyings||[]){let r=`${i.location} ${i.name}`;e[`out ${r}`]={[n]:JSON.stringify(i)}}return e}var z=null,se=null;function Oe(s,{id:t,minimap:e,opaque:n,top:i="0",left:r="0",rgbaScale:a=1}){z||(z=document.createElement("canvas"),z.id=t,z.title=t,z.style.zIndex="100",z.style.position="absolute",z.style.top=i,z.style.left=r,z.style.border="blue 1px solid",z.style.transform="scaleY(-1)",document.body.appendChild(z),se=z.getContext("2d")),(z.width!==s.width||z.height!==s.height)&&(z.width=s.width/2,z.height=s.height/2,z.style.width="400px",z.style.height="400px");let o=s.device.readPixelsToArrayWebGL(s),c=se?.createImageData(s.width,s.height);if(c){for(let f=0;f<o.length;f+=4)c.data[0+f+0]=o[f+0]*a,c.data[0+f+1]=o[f+1]*a,c.data[0+f+2]=o[f+2]*a,c.data[0+f+3]=n?255:o[f+3]*a;se?.putImageData(c,0,0)}}function Lt(s,t,e){if(s===t)return!0;if(!e||!s||!t)return!1;if(Array.isArray(s)){if(!Array.isArray(t)||s.length!==t.length)return!1;for(let n=0;n<s.length;n++)if(!Lt(s[n],t[n],e-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof s=="object"&&typeof t=="object"){let n=Object.keys(s),i=Object.keys(t);if(n.length!==i.length)return!1;for(let r of n)if(!t.hasOwnProperty(r)||!Lt(s[r],t[r],e-1))return!1;return!0}return!1}function Te(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Ee(s){return Array.isArray(s)?s.length===0||typeof s[0]=="number":!1}function gt(s){return Te(s)||Ee(s)}function Fs(s){return gt(s)||typeof s=="number"||typeof s=="boolean"}function Ct(s){let t={bindings:{},uniforms:{}};return Object.keys(s).forEach(e=>{let n=s[e];Fs(n)?t.uniforms[e]=n:t.bindings[e]=n}),t}var ne=D(V(),1),Re=D(rt(),1);var J=class{modules;moduleUniforms;moduleBindings;constructor(t){let e=(0,Re.getShaderModuleDependencies)(Object.values(t).filter(n=>n.dependencies));for(let n of e)t[n.name]=n;ne.log.log(1,"Creating ShaderInputs with modules",Object.keys(t))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(let[n,i]of Object.entries(t)){let r=n;this.moduleUniforms[r]=i.defaultUniforms||{},this.moduleBindings[r]={}}}destroy(){}setProps(t){for(let e of Object.keys(t)){let n=e,i=t[n]||{},r=this.modules[n];if(!r){ne.log.warn(`Module ${e} not found`)();continue}let a=this.moduleUniforms[n],o=this.moduleBindings[n],c=r.getUniforms?.(i,this.moduleUniforms[n]);c||={...this.moduleUniforms[n],...i};let{uniforms:h,bindings:f}=Ct(c);this.moduleUniforms[n]={...a,...h},this.moduleBindings[n]={...o,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let t={};for(let e of Object.values(this.moduleBindings))Object.assign(t,e);return t}getDebugTable(){let t={};for(let[e,n]of Object.entries(this.moduleUniforms))for(let[i,r]of Object.entries(n))t[`${e}.${i}`]={type:this.modules[e].uniformTypes?.[i],value:String(r)};return t}};var ie="";function Se(s){ie=s}async function It(s,t){let e=new Image;return e.crossOrigin=t?.crossOrigin||"anonymous",e.src=s.startsWith("http")?s:ie+s,await e.decode(),await createImageBitmap(e)}async function Le(s,t){return await new Promise((e,n)=>{try{let i=new Image;i.onload=()=>e(i),i.onerror=()=>n(new Error(`Could not load image ${s}.`)),i.crossOrigin=t?.crossOrigin||"anonymous",i.src=s.startsWith("http")?s:ie+s}catch(i){n(i)}})}var st=class{device;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};constructor(t,e){this.device=t,typeof e?.data=="string"&&e.dimension==="2d"&&(e={...e,data:It(e.data)}),this.ready=new Promise((n,i)=>{this.resolveReady=()=>{this.isReady=!0,n()},this.rejectReady=i}),this.initAsync(e)}async initAsync(t){let e,n,i=t.data,r=await Ce(i).then(e,n);if(this.destroyed)return;let a={...t,data:r};this.texture=this.device.createTexture(a),this.sampler=this.texture.sampler,this.view=this.texture.view,this.isReady=!0}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}resize(t){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");this.texture&&(this.texture=this.texture.createResizedTexture(t))}};async function Ce(s){if(s=await s,Array.isArray(s))return await Promise.all(s.map(Ce));if(s&&typeof s=="object"&&s.constructor===Object){let t=s,e=await Promise.all(Object.values(t)),n=Object.keys(t),i={};for(let r=0;r<n.length;r++)i[n[r]]=e[r];return i}return s}var ct=2,Ds=1e4,re=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;constructor(t,e){this.props={...re.defaultProps,...e},e=this.props,this.id=e.id||C("model"),this.device=t,Object.assign(this.userData,e.userData);let n=Object.fromEntries(this.props.modules?.map(o=>[o.name,o])||[]);this.setShaderInputs(e.shaderInputs||new J(n));let i=ks(t),r=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=(0,zt.getShaderLayoutFromWGSL)(this.props.source);let{source:o,getUniforms:c}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:i,...this.props,modules:r});this.source=o,this._getModuleUniforms=c}else{let{vs:o,fs:c,getUniforms:h}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:i,...this.props,modules:r});this.vs=o,this.fs=c,this._getModuleUniforms=h}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,e.geometry&&this.setGeometry(e.geometry),this.pipelineFactory=e.pipelineFactory||H.getDefaultPipelineFactory(this.device),this.shaderFactory=e.shaderFactory||X.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in e&&(this.isInstanced=e.isInstanced),e.instanceCount&&this.setInstanceCount(e.instanceCount),e.vertexCount&&this.setVertexCount(e.vertexCount),e.indexBuffer&&this.setIndexBuffer(e.indexBuffer),e.attributes&&this.setAttributes(e.attributes),e.constantAttributes&&this.setConstantAttributes(e.constantAttributes),e.bindings&&this.setBindings(e.bindings),e.uniforms&&this.setUniforms(e.uniforms),e.moduleSettings&&this.updateModuleSettings(e.moduleSettings),e.transformFeedback&&(this.transformFeedback=e.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let t=this._needsRedraw;return this._needsRedraw=!1,t}setNeedsRedraw(t){this._needsRedraw||=t}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(t){this.predraw();let e;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline();let n=this._getBindings();this.pipeline.setBindings(n,{disableWarnings:this.props.disableWarnings}),Ne(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:i}=this.vertexArray,r=i?i.byteLength/(i.indexType==="uint32"?4:2):void 0;e=this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:r,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(t),e?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",e}setGeometry(t){this._gpuGeometry?.destroy();let e=t&&Ae(this.device,t);e&&(this.setTopology(e.topology||"triangle-list"),this.bufferLayout=Ie(e.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(e)),this._gpuGeometry=e}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){this.bufferLayout=this._gpuGeometry?Ie(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){Lt(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(t){this.instanceCount=t,this.isInstanced===void 0&&t>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(t){this.vertexCount=t,this.setNeedsRedraw("vertexCount")}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new O.UniformStore(this.shaderInputs.modules);for(let e of Object.keys(this.shaderInputs.modules)){let n=this._uniformStore.getManagedUniformBuffer(this.device,e);this.bindings[`${e}Uniforms`]=n}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(t){Object.assign(this.bindings,t),this.setNeedsRedraw("bindings")}setTransformFeedback(t){this.transformFeedback=t,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t),this.setNeedsRedraw("indexBuffer")}setAttributes(t,e){t.indices&&O.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[n,i]of Object.entries(t)){let r=this.bufferLayout.find(c=>ze(c).includes(n));if(!r){O.log.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();continue}let a=ze(r),o=!1;for(let c of a){let h=this._attributeInfos[c];h&&(this.vertexArray.setBuffer(h.location,i),o=!0)}!o&&!(e?.disableWarnings??this.props.disableWarnings)&&O.log.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${n}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(t,e){for(let[n,i]of Object.entries(t)){let r=this._attributeInfos[n];r?this.vertexArray.setConstantWebGL(r.location,i):(e?.disableWarnings??this.props.disableWarnings)||O.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}setUniforms(t){Ne(t)||(this.pipeline.setUniformsWebGL(t),Object.assign(this.uniforms,t)),this.setNeedsRedraw("uniforms")}updateModuleSettings(t){let{bindings:e,uniforms:n}=Ct(this._getModuleUniforms(t));Object.assign(this.bindings,e),Object.assign(this.uniforms,n),this.setNeedsRedraw("moduleSettings")}_getBindings(){return Object.entries(this.bindings).reduce((t,[e,n])=>(n instanceof st?n.isReady&&(t[e]=n.texture):t[e]=n,t),{})}_getBindingsUpdateTimestamp(){let t=0;for(let e of Object.values(this.bindings))e instanceof O.TextureView?t=Math.max(t,e.texture.updateTimestamp):e instanceof O.Buffer||e instanceof O.Texture?t=Math.max(t,e.updateTimestamp):e instanceof st?t=e.texture?Math.max(t,e.texture.updateTimestamp):1/0:e instanceof O.Sampler||(t=Math.max(t,e.buffer.updateTimestamp));return t}_setGeometryAttributes(t){let e={...t.attributes};for(let[n]of Object.entries(e))!this.pipeline.shaderLayout.attributes.find(i=>i.name===n)&&n!=="positions"&&delete e[n];this.vertexCount=t.vertexCount,this.setIndexBuffer(t.indices||null),this.setAttributes(t.attributes,{disableWarnings:!0}),this.setAttributes(e,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate||=t,this.setNeedsRedraw(t)}_updatePipeline(){if(this._pipelineNeedsUpdate){let t=null,e=null;this.pipeline&&(O.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.pipeline.vs,e=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),i=null;this.source?i=n:this.fs&&(i=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:n,fs:i}),this._attributeInfos=(0,O.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout,this.bufferLayout),t&&this.shaderFactory.release(t),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let t=O.log.level>3?0:Ds;O.log.level<2||Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,O.log.group(ct,`>>> DRAWING MODEL ${this.id}`,{collapsed:O.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=Pe(this.pipeline.shaderLayout,this.id);O.log.table(ct,t)();let e=this.shaderInputs.getDebugTable();for(let[i,r]of Object.entries(this.uniforms))e[i]={value:r};O.log.table(ct,e)();let n=this._getAttributeDebugTable();O.log.table(ct,this._attributeInfos)(),O.log.table(ct,n)(),O.log.groupEnd(ct)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(t){let e=O.log.get("framebuffer");if(this._drawCount++,!e||this._drawCount++>3&&this._drawCount%60)return;let n=t.props.framebuffer;n&&Oe(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){let t={};for(let[e,n]of Object.entries(this._attributeInfos)){let i=this.vertexArray.attributes[n.location];t[n.location]={name:e,type:n.shaderType,values:i?this._getBufferOrConstantValues(i,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:e}=this.vertexArray,n=e.indexType==="uint32"?new Uint32Array(e.debugData):new Uint16Array(e.debugData);t.indices={name:"indices",type:e.indexType,values:n.toString()}}return t}_getBufferOrConstantValues(t,e){let n=(0,O.getTypedArrayFromDataType)(e);return(t instanceof O.Buffer?new n(t.debugData):t).toString()}},j=re;Q(j,"defaultProps",{...O.RenderPipeline.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:zt.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function Ie(s,t){let e=[...s];for(let n of t){let i=e.findIndex(r=>r.name===n.name);i<0?e.push(n):e[i]=n}return e}function ks(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,features:s.features}}function ze(s){return s.attributes?s.attributes?.map(t=>t.attribute):[s.name]}function Ne(s){let t=!0;for(let e in s){t=!1;break}return t}var Fe=D(V(),1),De=D(rt(),1);var ht=class{device;model;transformFeedback;static isSupported(t){return t?.info?.type==="webgl"}constructor(t,e=j.defaultProps){if(!ht.isSupported(t))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=t,this.model=new j(this.device,{id:e.id||"buffer-transform-model",fs:e.fs||(0,De.getPassthroughFS)(),topology:e.topology||"point-list",...e}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:e.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(t){let e=this.device.beginRenderPass(t);this.model.draw(e),e.end()}getBuffer(t){return this.transformFeedback.getBuffer(t)}readAsync(t){let e=this.getBuffer(t);if(!e)throw new Error("BufferTransform#getBuffer");if(e instanceof Fe.Buffer)return e.readAsync();let{buffer:n,byteOffset:i=0,byteLength:r=n.byteLength}=e;return n.readAsync(i,r)}};var ke=D(rt(),1),Bs="transform_output",Nt=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(t,e){this.device=t,this.sampler=t.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new j(this.device,{id:e.id||"texture-transform-model",fs:e.fs||(0,ke.getPassthroughFS)({input:e.targetTextureVarying,inputChannels:e.targetTextureChannels,output:Bs}),vertexCount:e.vertexCount,...e}),this._initialize(e),Object.seal(this)}destroy(){}delete(){this.destroy()}run(t){let{framebuffer:e}=this.bindings[this.currentIndex],n=this.device.beginRenderPass({framebuffer:e,...t});this.model.draw(n),n.end()}getTargetTexture(){let{targetTexture:t}=this.bindings[this.currentIndex];return t}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(t){this._updateBindings(t)}_updateBindings(t){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],t)}_updateBinding(t,{sourceBuffers:e,sourceTextures:n,targetTexture:i}){if(t||(t={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(t.sourceTextures,n),Object.assign(t.sourceBuffers,e),i){t.targetTexture=i;let{width:r,height:a}=i;t.framebuffer&&t.framebuffer.destroy(),t.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:r,height:a,colorAttachments:[i]}),t.framebuffer.resize({width:r,height:a})}return t}_setSourceTextureParameters(){let t=this.currentIndex,{sourceTextures:e}=this.bindings[t];for(let n in e)e[n].sampler=this.sampler}};var k=class{id;topology;vertexCount;indices;attributes;userData={};constructor(t){let{attributes:e={},indices:n=null,vertexCount:i=null}=t;this.id=t.id||C("geometry"),this.topology=t.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[r,a]of Object.entries(e)){let o=ArrayBuffer.isView(a)?{value:a}:a;if(!ArrayBuffer.isView(o.value))throw new Error(`${this._print(r)}: must be typed array or object with value as typed array`);if((r==="POSITION"||r==="positions")&&!o.size&&(o.size=3),r==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=o}else this.attributes[r]=o}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=i||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(t){return`Geometry ${this.id} attribute ${t}`}_setAttributes(t,e){return this}_calculateVertexCount(t,e){if(e)return e.value.length;let n=1/0;for(let i of Object.values(t)){let{value:r,size:a,constant:o}=i;!o&&r&&a!==void 0&&a>=1&&(n=Math.min(n,r.length/a))}return n}};var Us=`#version 300 es
|
|
8
8
|
in vec2 aClipSpacePosition;
|
|
9
9
|
in vec2 aTexCoord;
|
|
10
10
|
in vec2 aCoordinate;
|
|
@@ -19,6 +19,6 @@ void main(void) {
|
|
|
19
19
|
coordinate = aCoordinate;
|
|
20
20
|
uv = aTexCoord;
|
|
21
21
|
}
|
|
22
|
-
`,Be=[-1,-1,1,-1,-1,1,1,1],Ft=class extends j{constructor(t,e){let n=Be.map(i=>i===-1?0:i);super(t,{...e,vs:Us,vertexCount:4,geometry:new k({topology:"triangle-strip",vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(Be)},aTexCoord:{size:2,value:new Float32Array(n)},aCoordinate:{size:2,value:new Float32Array(n)}}})})}};var Li=1/Math.PI*180,Ci=1/180*Math.PI,$s={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...$s}};var F=globalThis.mathgl.config;function Ue(s,{precision:t=F.precision}={}){return s=qs(s),`${parseFloat(s.toPrecision(t))}`}function lt(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function oe(s,t,e){let n=F.EPSILON;e&&(F.EPSILON=e);try{if(s===t)return!0;if(lt(s)&<(t)){if(s.length!==t.length)return!1;for(let i=0;i<s.length;++i)if(!oe(s[i],t[i]))return!1;return!0}return s&&s.equals?s.equals(t):t&&t.equals?t.equals(s):typeof s=="number"&&typeof t=="number"?Math.abs(s-t)<=F.EPSILON*Math.max(1,Math.abs(s),Math.abs(t)):!1}finally{F.EPSILON=n}}function qs(s){return Math.round(s/F.EPSILON)*F.EPSILON}var ft=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,e=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+e];return this.check()}toArray(t=[],e=0){for(let n=0;n<this.ELEMENTS;++n)t[e+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:lt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(F)}formatString(t){let e="";for(let n=0;n<this.ELEMENTS;++n)e+=(n>0?", ":"")+Ue(this[n],t);return`${t.printTypes?this.constructor.name:""}[${e}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!oe(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,n){if(n===void 0)return this.lerp(this,t,e);for(let i=0;i<this.ELEMENTS;++i){let r=t[i],a=typeof e=="number"?e:e[i];this[i]=r+n*(a-r)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),e[n]);return this.check()}add(...t){for(let e of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=e[n];return this.check()}subtract(...t){for(let e of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=e[n];return this.check()}scale(t){if(typeof t=="number")for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}check(){if(F.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t),e);return this.check()}get elements(){return this}};function Vs(s,t){if(s.length!==t)return!1;for(let e=0;e<s.length;++e)if(!Number.isFinite(s[e]))return!1;return!0}function B(s){if(!Number.isFinite(s))throw new Error(`Invalid number ${JSON.stringify(s)}`);return s}function Dt(s,t,e=""){if(F.debug&&!Vs(s,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return s}function ae(s,t){if(!s)throw new Error(`math.gl assertion ${t}`)}var kt=class extends ft{get x(){return this[0]}set x(t){this[0]=B(t)}get y(){return this[1]}set y(t){this[1]=B(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let n=0;n<this.ELEMENTS;++n){let i=this[n]-t[n];e+=i*i}return B(e)}dot(t){let e=0;for(let n=0;n<this.ELEMENTS;++n)e+=this[n]*t[n];return B(e)}normalize(){let t=this.magnitude();if(t!==0)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(let e of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=e[n];return this.check()}divide(...t){for(let e of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=e[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return ae(t>=0&&t<this.ELEMENTS,"index is out of range"),B(this[t])}setComponent(t,e){return ae(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}};var K=typeof Float32Array<"u"?Float32Array:Array;var Vi=Math.PI/180;function js(){let s=new K(2);return K!=Float32Array&&(s[0]=0,s[1]=0),s}function Ve(s,t,e){let n=t[0],i=t[1];return s[0]=e[0]*n+e[4]*i+e[12],s[1]=e[1]*n+e[5]*i+e[13],s}var ji=function(){let s=js();return function(t,e,n,i,r,a){let o,c;for(e||(e=2),n||(n=0),i?c=Math.min(i*e+n,t.length):c=t.length,o=n;o<c;o+=e)s[0]=t[o],s[1]=t[o+1],r(s,s,a),t[o]=s[0],t[o+1]=s[1];return t}}();function je(s,t,e){let n=t[0],i=t[1],r=e[3]*n+e[7]*i||1;return s[0]=(e[0]*n+e[4]*i)/r,s[1]=(e[1]*n+e[5]*i)/r,s}function Bt(s,t,e){let n=t[0],i=t[1],r=t[2],a=e[3]*n+e[7]*i+e[11]*r||1;return s[0]=(e[0]*n+e[4]*i+e[8]*r)/a,s[1]=(e[1]*n+e[5]*i+e[9]*r)/a,s[2]=(e[2]*n+e[6]*i+e[10]*r)/a,s}function We(s,t,e){let n=t[0],i=t[1];return s[0]=e[0]*n+e[2]*i,s[1]=e[1]*n+e[3]*i,s[2]=t[2],s}function Ws(){let s=new K(3);return K!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s}function Gs(s,t){return s[0]*t[0]+s[1]*t[1]+s[2]*t[2]}function Ge(s,t,e){let n=t[0],i=t[1],r=t[2],a=e[0],o=e[1],c=e[2];return s[0]=i*c-r*o,s[1]=r*a-n*c,s[2]=n*o-i*a,s}function Ut(s,t,e){let n=t[0],i=t[1],r=t[2],a=e[3]*n+e[7]*i+e[11]*r+e[15];return a=a||1,s[0]=(e[0]*n+e[4]*i+e[8]*r+e[12])/a,s[1]=(e[1]*n+e[5]*i+e[9]*r+e[13])/a,s[2]=(e[2]*n+e[6]*i+e[10]*r+e[14])/a,s}function Ye(s,t,e){let n=t[0],i=t[1],r=t[2];return s[0]=n*e[0]+i*e[3]+r*e[6],s[1]=n*e[1]+i*e[4]+r*e[7],s[2]=n*e[2]+i*e[5]+r*e[8],s}function He(s,t,e){let n=e[0],i=e[1],r=e[2],a=e[3],o=t[0],c=t[1],h=t[2],f=i*h-r*c,l=r*o-n*h,d=n*c-i*o,u=i*d-r*l,M=r*f-n*d,m=n*l-i*f,g=a*2;return f*=g,l*=g,d*=g,u*=2,M*=2,m*=2,s[0]=o+f+u,s[1]=c+l+M,s[2]=h+d+m,s}function Xe(s,t,e,n){let i=[],r=[];return i[0]=t[0]-e[0],i[1]=t[1]-e[1],i[2]=t[2]-e[2],r[0]=i[0],r[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),r[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),s[0]=r[0]+e[0],s[1]=r[1]+e[1],s[2]=r[2]+e[2],s}function Ke(s,t,e,n){let i=[],r=[];return i[0]=t[0]-e[0],i[1]=t[1]-e[1],i[2]=t[2]-e[2],r[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),r[1]=i[1],r[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),s[0]=r[0]+e[0],s[1]=r[1]+e[1],s[2]=r[2]+e[2],s}function Ze(s,t,e,n){let i=[],r=[];return i[0]=t[0]-e[0],i[1]=t[1]-e[1],i[2]=t[2]-e[2],r[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),r[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),r[2]=i[2],s[0]=r[0]+e[0],s[1]=r[1]+e[1],s[2]=r[2]+e[2],s}function Qe(s,t){let e=s[0],n=s[1],i=s[2],r=t[0],a=t[1],o=t[2],c=Math.sqrt((e*e+n*n+i*i)*(r*r+a*a+o*o)),h=c&&Gs(s,t)/c;return Math.acos(Math.min(Math.max(h,-1),1))}var Yi=function(){let s=Ws();return function(t,e,n,i,r,a){let o,c;for(e||(e=3),n||(n=0),i?c=Math.min(i*e+n,t.length):c=t.length,o=n;o<c;o+=e)s[0]=t[o],s[1]=t[o+1],s[2]=t[o+2],r(s,s,a),t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2];return t}}();var he=[0,0,0],$t,$=class extends kt{static get ZERO(){return $t||($t=new $(0,0,0),Object.freeze($t)),$t}constructor(t=0,e=0,n=0){super(-0,-0,-0),arguments.length===1&<(t)?this.copy(t):(F.debug&&(B(t),B(e),B(n)),this[0]=t,this[1]=e,this[2]=n)}set(t,e,n){return this[0]=t,this[1]=e,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return F.debug&&(B(t.x),B(t.y),B(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=B(t)}angle(t){return Qe(this,t)}cross(t){return Ge(this,this,t),this.check()}rotateX({radians:t,origin:e=he}){return Xe(this,this,e,t),this.check()}rotateY({radians:t,origin:e=he}){return Ke(this,this,e,t),this.check()}rotateZ({radians:t,origin:e=he}){return Ze(this,this,e,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Ut(this,this,t),this.check()}transformAsVector(t){return Bt(this,this,t),this.check()}transformByMatrix3(t){return Ye(this,this,t),this.check()}transformByMatrix2(t){return We(this,this,t),this.check()}transformByQuaternion(t){return He(this,this,t),this.check()}};var qt=class extends ft{toString(){let t="[";if(F.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+e]}`}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=` ${this[e]}`}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,n){return this[e*this.RANK+t]=B(n),this}getColumn(t,e=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)e[i]=this[n+i];return e}setColumn(t,e){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)this[n+i]=e[i];return this}};function Ys(s){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function Je(s,t){if(s===t){let e=t[1],n=t[2],i=t[3],r=t[6],a=t[7],o=t[11];s[1]=t[4],s[2]=t[8],s[3]=t[12],s[4]=e,s[6]=t[9],s[7]=t[13],s[8]=n,s[9]=r,s[11]=t[14],s[12]=i,s[13]=a,s[14]=o}else s[0]=t[0],s[1]=t[4],s[2]=t[8],s[3]=t[12],s[4]=t[1],s[5]=t[5],s[6]=t[9],s[7]=t[13],s[8]=t[2],s[9]=t[6],s[10]=t[10],s[11]=t[14],s[12]=t[3],s[13]=t[7],s[14]=t[11],s[15]=t[15];return s}function ts(s,t){let e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],h=t[7],f=t[8],l=t[9],d=t[10],u=t[11],M=t[12],m=t[13],g=t[14],_=t[15],b=e*o-n*a,p=e*c-i*a,x=e*h-r*a,y=n*c-i*o,w=n*h-r*o,T=i*h-r*c,S=f*m-l*M,E=f*g-d*M,L=f*_-u*M,A=l*g-d*m,P=l*_-u*m,R=d*_-u*g,v=b*R-p*P+x*A+y*L-w*E+T*S;return v?(v=1/v,s[0]=(o*R-c*P+h*A)*v,s[1]=(i*P-n*R-r*A)*v,s[2]=(m*T-g*w+_*y)*v,s[3]=(d*w-l*T-u*y)*v,s[4]=(c*L-a*R-h*E)*v,s[5]=(e*R-i*L+r*E)*v,s[6]=(g*x-M*T-_*p)*v,s[7]=(f*T-d*x+u*p)*v,s[8]=(a*P-o*L+h*S)*v,s[9]=(n*L-e*P-r*S)*v,s[10]=(M*w-m*x+_*b)*v,s[11]=(l*x-f*w-u*b)*v,s[12]=(o*E-a*A-c*S)*v,s[13]=(e*A-n*E+i*S)*v,s[14]=(m*p-M*y-g*b)*v,s[15]=(f*y-l*p+d*b)*v,s):null}function es(s){let t=s[0],e=s[1],n=s[2],i=s[3],r=s[4],a=s[5],o=s[6],c=s[7],h=s[8],f=s[9],l=s[10],d=s[11],u=s[12],M=s[13],m=s[14],g=s[15],_=t*a-e*r,b=t*o-n*r,p=e*o-n*a,x=h*M-f*u,y=h*m-l*u,w=f*m-l*M,T=t*w-e*y+n*x,S=r*w-a*y+o*x,E=h*p-f*b+l*_,L=u*p-M*b+m*_;return c*T-i*S+g*E-d*L}function le(s,t,e){let n=t[0],i=t[1],r=t[2],a=t[3],o=t[4],c=t[5],h=t[6],f=t[7],l=t[8],d=t[9],u=t[10],M=t[11],m=t[12],g=t[13],_=t[14],b=t[15],p=e[0],x=e[1],y=e[2],w=e[3];return s[0]=p*n+x*o+y*l+w*m,s[1]=p*i+x*c+y*d+w*g,s[2]=p*r+x*h+y*u+w*_,s[3]=p*a+x*f+y*M+w*b,p=e[4],x=e[5],y=e[6],w=e[7],s[4]=p*n+x*o+y*l+w*m,s[5]=p*i+x*c+y*d+w*g,s[6]=p*r+x*h+y*u+w*_,s[7]=p*a+x*f+y*M+w*b,p=e[8],x=e[9],y=e[10],w=e[11],s[8]=p*n+x*o+y*l+w*m,s[9]=p*i+x*c+y*d+w*g,s[10]=p*r+x*h+y*u+w*_,s[11]=p*a+x*f+y*M+w*b,p=e[12],x=e[13],y=e[14],w=e[15],s[12]=p*n+x*o+y*l+w*m,s[13]=p*i+x*c+y*d+w*g,s[14]=p*r+x*h+y*u+w*_,s[15]=p*a+x*f+y*M+w*b,s}function ss(s,t,e){let n=e[0],i=e[1],r=e[2],a,o,c,h,f,l,d,u,M,m,g,_;return t===s?(s[12]=t[0]*n+t[4]*i+t[8]*r+t[12],s[13]=t[1]*n+t[5]*i+t[9]*r+t[13],s[14]=t[2]*n+t[6]*i+t[10]*r+t[14],s[15]=t[3]*n+t[7]*i+t[11]*r+t[15]):(a=t[0],o=t[1],c=t[2],h=t[3],f=t[4],l=t[5],d=t[6],u=t[7],M=t[8],m=t[9],g=t[10],_=t[11],s[0]=a,s[1]=o,s[2]=c,s[3]=h,s[4]=f,s[5]=l,s[6]=d,s[7]=u,s[8]=M,s[9]=m,s[10]=g,s[11]=_,s[12]=a*n+f*i+M*r+t[12],s[13]=o*n+l*i+m*r+t[13],s[14]=c*n+d*i+g*r+t[14],s[15]=h*n+u*i+_*r+t[15]),s}function ns(s,t,e){let n=e[0],i=e[1],r=e[2];return s[0]=t[0]*n,s[1]=t[1]*n,s[2]=t[2]*n,s[3]=t[3]*n,s[4]=t[4]*i,s[5]=t[5]*i,s[6]=t[6]*i,s[7]=t[7]*i,s[8]=t[8]*r,s[9]=t[9]*r,s[10]=t[10]*r,s[11]=t[11]*r,s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15],s}function is(s,t,e,n){let i=n[0],r=n[1],a=n[2],o=Math.sqrt(i*i+r*r+a*a),c,h,f,l,d,u,M,m,g,_,b,p,x,y,w,T,S,E,L,A,P,R,v,N;return o<1e-6?null:(o=1/o,i*=o,r*=o,a*=o,h=Math.sin(e),c=Math.cos(e),f=1-c,l=t[0],d=t[1],u=t[2],M=t[3],m=t[4],g=t[5],_=t[6],b=t[7],p=t[8],x=t[9],y=t[10],w=t[11],T=i*i*f+c,S=r*i*f+a*h,E=a*i*f-r*h,L=i*r*f-a*h,A=r*r*f+c,P=a*r*f+i*h,R=i*a*f+r*h,v=r*a*f-i*h,N=a*a*f+c,s[0]=l*T+m*S+p*E,s[1]=d*T+g*S+x*E,s[2]=u*T+_*S+y*E,s[3]=M*T+b*S+w*E,s[4]=l*L+m*A+p*P,s[5]=d*L+g*A+x*P,s[6]=u*L+_*A+y*P,s[7]=M*L+b*A+w*P,s[8]=l*R+m*v+p*N,s[9]=d*R+g*v+x*N,s[10]=u*R+_*v+y*N,s[11]=M*R+b*v+w*N,t!==s&&(s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15]),s)}function rs(s,t,e){let n=Math.sin(e),i=Math.cos(e),r=t[4],a=t[5],o=t[6],c=t[7],h=t[8],f=t[9],l=t[10],d=t[11];return t!==s&&(s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15]),s[4]=r*i+h*n,s[5]=a*i+f*n,s[6]=o*i+l*n,s[7]=c*i+d*n,s[8]=h*i-r*n,s[9]=f*i-a*n,s[10]=l*i-o*n,s[11]=d*i-c*n,s}function os(s,t,e){let n=Math.sin(e),i=Math.cos(e),r=t[0],a=t[1],o=t[2],c=t[3],h=t[8],f=t[9],l=t[10],d=t[11];return t!==s&&(s[4]=t[4],s[5]=t[5],s[6]=t[6],s[7]=t[7],s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15]),s[0]=r*i-h*n,s[1]=a*i-f*n,s[2]=o*i-l*n,s[3]=c*i-d*n,s[8]=r*n+h*i,s[9]=a*n+f*i,s[10]=o*n+l*i,s[11]=c*n+d*i,s}function as(s,t,e){let n=Math.sin(e),i=Math.cos(e),r=t[0],a=t[1],o=t[2],c=t[3],h=t[4],f=t[5],l=t[6],d=t[7];return t!==s&&(s[8]=t[8],s[9]=t[9],s[10]=t[10],s[11]=t[11],s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15]),s[0]=r*i+h*n,s[1]=a*i+f*n,s[2]=o*i+l*n,s[3]=c*i+d*n,s[4]=h*i-r*n,s[5]=f*i-a*n,s[6]=l*i-o*n,s[7]=d*i-c*n,s}function cs(s,t){let e=t[0],n=t[1],i=t[2],r=t[3],a=e+e,o=n+n,c=i+i,h=e*a,f=n*a,l=n*o,d=i*a,u=i*o,M=i*c,m=r*a,g=r*o,_=r*c;return s[0]=1-l-M,s[1]=f+_,s[2]=d-g,s[3]=0,s[4]=f-_,s[5]=1-h-M,s[6]=u+m,s[7]=0,s[8]=d+g,s[9]=u-m,s[10]=1-h-l,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function hs(s,t,e,n,i,r,a){let o=1/(e-t),c=1/(i-n),h=1/(r-a);return s[0]=r*2*o,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r*2*c,s[6]=0,s[7]=0,s[8]=(e+t)*o,s[9]=(i+n)*c,s[10]=(a+r)*h,s[11]=-1,s[12]=0,s[13]=0,s[14]=a*r*2*h,s[15]=0,s}function Hs(s,t,e,n,i){let r=1/Math.tan(t/2);if(s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,i!=null&&i!==1/0){let a=1/(n-i);s[10]=(i+n)*a,s[14]=2*i*n*a}else s[10]=-1,s[14]=-2*n;return s}var ls=Hs;function Xs(s,t,e,n,i,r,a){let o=1/(t-e),c=1/(n-i),h=1/(r-a);return s[0]=-2*o,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*h,s[11]=0,s[12]=(t+e)*o,s[13]=(i+n)*c,s[14]=(a+r)*h,s[15]=1,s}var fs=Xs;function ds(s,t,e,n){let i,r,a,o,c,h,f,l,d,u,M=t[0],m=t[1],g=t[2],_=n[0],b=n[1],p=n[2],x=e[0],y=e[1],w=e[2];return Math.abs(M-x)<1e-6&&Math.abs(m-y)<1e-6&&Math.abs(g-w)<1e-6?Ys(s):(l=M-x,d=m-y,u=g-w,i=1/Math.sqrt(l*l+d*d+u*u),l*=i,d*=i,u*=i,r=b*u-p*d,a=p*l-_*u,o=_*d-b*l,i=Math.sqrt(r*r+a*a+o*o),i?(i=1/i,r*=i,a*=i,o*=i):(r=0,a=0,o=0),c=d*o-u*a,h=u*r-l*o,f=l*a-d*r,i=Math.sqrt(c*c+h*h+f*f),i?(i=1/i,c*=i,h*=i,f*=i):(c=0,h=0,f=0),s[0]=r,s[1]=c,s[2]=l,s[3]=0,s[4]=a,s[5]=h,s[6]=d,s[7]=0,s[8]=o,s[9]=f,s[10]=u,s[11]=0,s[12]=-(r*M+a*m+o*g),s[13]=-(c*M+h*m+f*g),s[14]=-(l*M+d*m+u*g),s[15]=1,s)}function Ks(){let s=new K(4);return K!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0,s[3]=0),s}function ms(s,t,e){let n=t[0],i=t[1],r=t[2],a=t[3];return s[0]=e[0]*n+e[4]*i+e[8]*r+e[12]*a,s[1]=e[1]*n+e[5]*i+e[9]*r+e[13]*a,s[2]=e[2]*n+e[6]*i+e[10]*r+e[14]*a,s[3]=e[3]*n+e[7]*i+e[11]*r+e[15]*a,s}var or=function(){let s=Ks();return function(t,e,n,i,r,a){let o,c;for(e||(e=4),n||(n=0),i?c=Math.min(i*e+n,t.length):c=t.length,o=n;o<c;o+=e)s[0]=t[o],s[1]=t[o+1],s[2]=t[o+2],s[3]=t[o+3],r(s,s,a),t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3];return t}}();var me;(function(s){s[s.COL0ROW0=0]="COL0ROW0",s[s.COL0ROW1=1]="COL0ROW1",s[s.COL0ROW2=2]="COL0ROW2",s[s.COL0ROW3=3]="COL0ROW3",s[s.COL1ROW0=4]="COL1ROW0",s[s.COL1ROW1=5]="COL1ROW1",s[s.COL1ROW2=6]="COL1ROW2",s[s.COL1ROW3=7]="COL1ROW3",s[s.COL2ROW0=8]="COL2ROW0",s[s.COL2ROW1=9]="COL2ROW1",s[s.COL2ROW2=10]="COL2ROW2",s[s.COL2ROW3=11]="COL2ROW3",s[s.COL3ROW0=12]="COL3ROW0",s[s.COL3ROW1=13]="COL3ROW1",s[s.COL3ROW2=14]="COL3ROW2",s[s.COL3ROW3=15]="COL3ROW3"})(me||(me={}));var Zs=45*Math.PI/180,Qs=1,fe=.1,de=500,Js=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),G=class extends qt{static get IDENTITY(){return en()}static get ZERO(){return tn()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return me}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,n,i,r,a,o,c,h,f,l,d,u,M,m,g){return this[0]=t,this[1]=e,this[2]=n,this[3]=i,this[4]=r,this[5]=a,this[6]=o,this[7]=c,this[8]=h,this[9]=f,this[10]=l,this[11]=d,this[12]=u,this[13]=M,this[14]=m,this[15]=g,this.check()}setRowMajor(t,e,n,i,r,a,o,c,h,f,l,d,u,M,m,g){return this[0]=t,this[1]=r,this[2]=h,this[3]=u,this[4]=e,this[5]=a,this[6]=f,this[7]=M,this[8]=n,this[9]=o,this[10]=l,this[11]=m,this[12]=i,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Js)}fromObject(t){return this.check()}fromQuaternion(t){return cs(this,t),this.check()}frustum(t){let{left:e,right:n,bottom:i,top:r,near:a=fe,far:o=de}=t;return o===1/0?sn(this,e,n,i,r,a):hs(this,e,n,i,r,a,o),this.check()}lookAt(t){let{eye:e,center:n=[0,0,0],up:i=[0,1,0]}=t;return ds(this,e,n,i),this.check()}ortho(t){let{left:e,right:n,bottom:i,top:r,near:a=fe,far:o=de}=t;return fs(this,e,n,i,r,a,o),this.check()}orthographic(t){let{fovy:e=Zs,aspect:n=Qs,focalDistance:i=1,near:r=fe,far:a=de}=t;ps(e);let o=e/2,c=i*Math.tan(o),h=c*n;return this.ortho({left:-h,right:h,bottom:-c,top:c,near:r,far:a})}perspective(t){let{fovy:e=45*Math.PI/180,aspect:n=1,near:i=.1,far:r=500}=t;return ps(e),ls(this,e,n,i,r),this.check()}determinant(){return es(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let n=this.getScale(e),i=1/n[0],r=1/n[1],a=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*r,t[2]=this[2]*a,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*r,t[6]=this[6]*a,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*r,t[10]=this[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let n=this.getScale(e),i=1/n[0],r=1/n[1],a=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*r,t[2]=this[2]*a,t[3]=this[4]*i,t[4]=this[5]*r,t[5]=this[6]*a,t[6]=this[8]*i,t[7]=this[9]*r,t[8]=this[10]*a,t}transpose(){return Je(this,this),this.check()}invert(){return ts(this,this),this.check()}multiplyLeft(t){return le(this,t,this),this.check()}multiplyRight(t){return le(this,this,t),this.check()}rotateX(t){return rs(this,this,t),this.check()}rotateY(t){return os(this,this,t),this.check()}rotateZ(t){return as(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return is(this,this,t,e),this.check()}scale(t){return ns(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return ss(this,this,t),this.check()}transform(t,e){return t.length===4?(e=ms(e||[-0,-0,-0,-0],t,this),Dt(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){let{length:n}=t,i;switch(n){case 2:i=Ve(e||[-0,-0],t,this);break;case 3:i=Ut(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Dt(i,t.length),i}transformAsVector(t,e){let n;switch(t.length){case 2:n=je(e||[-0,-0],t,this);break;case 3:n=Bt(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Dt(n,t.length),n}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,n){return this.identity().translate([t,e,n])}},Vt,jt;function tn(){return Vt||(Vt=new G([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Vt)),Vt}function en(){return jt||(jt=new G,Object.freeze(jt)),jt}function ps(s){if(s>Math.PI*2)throw Error("expected radians")}function sn(s,t,e,n,i,r){let a=2*r/(e-t),o=2*r/(i-n),c=(e+t)/(e-t),h=(i+n)/(i-n),f=-1,l=-1,d=-2*r;return s[0]=a,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=o,s[6]=0,s[7]=0,s[8]=c,s[9]=h,s[10]=f,s[11]=l,s[12]=0,s[13]=0,s[14]=d,s[15]=0,s}var Z=class{id;matrix=new G;display=!0;position=new $;rotation=new $;scale=new $(1,1,1);userData={};props={};constructor(t={}){let{id:e}=t;this.id=e||C(this.constructor.name),this._setScenegraphNodeProps(t)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(t){return this._setScenegraphNodeProps(t),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(t){return this.position=t,this}setRotation(t){return this.rotation=t,this}setScale(t){return this.scale=t,this}setMatrix(t,e=!0){e?this.matrix.copy(t):this.matrix=t}setMatrixComponents(t){let{position:e,rotation:n,scale:i,update:r=!0}=t;return e&&this.setPosition(e),n&&this.setRotation(n),i&&this.setScale(i),r&&this.updateMatrix(),this}updateMatrix(){let t=this.position,e=this.rotation,n=this.scale;return this.matrix.identity(),this.matrix.translate(t),this.matrix.rotateXYZ(e),this.matrix.scale(n),this}update(t={}){let{position:e,rotation:n,scale:i}=t;return e&&this.setPosition(e),n&&this.setRotation(n),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(t,e){e=e||this.matrix;let n=new G(t).multiplyRight(e),i=n.invert(),r=i.transpose();return{viewMatrix:t,modelMatrix:e,objectMatrix:e,worldMatrix:n,worldInverseMatrix:i,worldInverseTransposeMatrix:r}}_setScenegraphNodeProps(t){"position"in t&&this.setPosition(t.position),"rotation"in t&&this.setRotation(t.rotation),"scale"in t&&this.setScale(t.scale),"matrix"in t&&this.setMatrix(t.matrix),Object.assign(this.props,t)}};var us=D(V(),1);var mt=class extends Z{children;constructor(t={}){t=Array.isArray(t)?{children:t}:t;let{children:e=[]}=t;us.log.assert(e.every(n=>n instanceof Z),"every child must an instance of ScenegraphNode"),super(t),this.children=e}getBounds(){let t=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((e,{worldMatrix:n})=>{let i=e.getBounds();if(!i)return;let[r,a]=i,o=new $(r).add(a).divide([2,2,2]);n.transformAsPoint(o,o);let c=new $(a).subtract(r).divide([2,2,2]);n.transformAsVector(c,c);for(let h=0;h<8;h++){let f=new $(h&1?-1:1,h&2?-1:1,h&4?-1:1).multiply(c).add(o);for(let l=0;l<3;l++)t[0][l]=Math.min(t[0][l],f[l]),t[1][l]=Math.max(t[1][l],f[l])}}),Number.isFinite(t[0][0])?t:null}destroy(){this.children.forEach(t=>t.destroy()),this.removeAll(),super.destroy()}add(...t){for(let e of t)Array.isArray(e)?this.add(...e):this.children.push(e);return this}remove(t){let e=this.children,n=e.indexOf(t);return n>-1&&e.splice(n,1),this}removeAll(){return this.children=[],this}traverse(t,{worldMatrix:e=new G}={}){let n=new G(e).multiplyRight(this.matrix);for(let i of this.children)i instanceof mt?i.traverse(t,{worldMatrix:n}):t(i,{worldMatrix:n})}};var Wt=class extends Z{model;bounds=null;managedResources;constructor(t){super(t),this.model=t.model,this.managedResources=t.managedResources||[],this.bounds=t.bounds||null,this.setProps(t)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(t=>t.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(t){return this.model.draw(t)}};var nn={x:[2,0,1],y:[0,1,2],z:[1,2,0]},tt=class extends k{constructor(t={}){let{id:e=C("truncated-code-geometry")}=t,{indices:n,attributes:i}=rn(t);super({...t,id:e,topology:"triangle-list",indices:n,attributes:{POSITION:{size:3,value:i.POSITION},NORMAL:{size:3,value:i.NORMAL},TEXCOORD_0:{size:2,value:i.TEXCOORD_0},...t.attributes}})}};function rn(s={}){let{bottomRadius:t=0,topRadius:e=0,height:n=1,nradial:i=10,nvertical:r=10,verticalAxis:a="y",topCap:o=!1,bottomCap:c=!1}=s,h=(o?2:0)+(c?2:0),f=(i+1)*(r+1+h),l=Math.atan2(t-e,n),d=Math.sin,u=Math.cos,M=Math.PI,m=u(l),g=d(l),_=o?-2:0,b=r+(c?2:0),p=i+1,x=new Uint16Array(i*(r+h)*6),y=nn[a],w=new Float32Array(f*3),T=new Float32Array(f*3),S=new Float32Array(f*2),E=0,L=0;for(let A=_;A<=b;A++){let P=A/r,R=n*P,v;A<0?(R=0,P=1,v=t):A>r?(R=n,P=1,v=e):v=t+(e-t)*(A/r),(A===-2||A===r+2)&&(v=0,P=0),R-=n/2;for(let N=0;N<p;N++){let Y=d(N*M*2/i),W=u(N*M*2/i);w[E+y[0]]=Y*v,w[E+y[1]]=R,w[E+y[2]]=W*v,T[E+y[0]]=A<0||A>r?0:Y*m,T[E+y[1]]=A<0?-1:A>r?1:g,T[E+y[2]]=A<0||A>r?0:W*m,S[L+0]=N/i,S[L+1]=P,L+=2,E+=3}}for(let A=0;A<r+h;A++)for(let P=0;P<i;P++){let R=(A*i+P)*6;x[R+0]=p*(A+0)+0+P,x[R+1]=p*(A+0)+1+P,x[R+2]=p*(A+1)+1+P,x[R+3]=p*(A+0)+0+P,x[R+4]=p*(A+1)+1+P,x[R+5]=p*(A+1)+0+P}return{indices:x,attributes:{POSITION:w,NORMAL:T,TEXCOORD_0:S}}}var Gt=class extends tt{constructor(t={}){let{id:e=C("cone-geometry"),radius:n=1,cap:i=!0}=t;super({...t,id:e,topRadius:0,topCap:Boolean(i),bottomCap:Boolean(i),bottomRadius:n})}};var Yt=class extends k{constructor(t={}){let{id:e=C("cube-geometry"),indices:n=!0}=t;super(n?{...t,id:e,topology:"triangle-list",indices:{size:1,value:on},attributes:{...mn,...t.attributes}}:{...t,id:e,topology:"triangle-list",indices:void 0,attributes:{...pn,...t.attributes}})}},on=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),an=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),cn=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),hn=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),ln=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),fn=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),dn=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),mn={POSITION:{size:3,value:an},NORMAL:{size:3,value:cn},TEXCOORD_0:{size:2,value:hn}},pn={POSITION:{size:3,value:ln},TEXCOORD_0:{size:2,value:fn},COLOR_0:{size:3,value:dn}};var Ht=class extends tt{constructor(t={}){let{id:e=C("cylinder-geometry"),radius:n=1}=t;super({...t,id:e,bottomRadius:n,topRadius:n})}};var un=[-1,0,0,0,1,0,0,0,-1,0,0,1,0,-1,0,1,0,0],xn=[3,4,5,3,5,1,3,1,0,3,0,4,4,0,2,4,2,5,2,0,1,5,2,1],Xt=class extends k{constructor(t={}){let{id:e=C("ico-sphere-geometry")}=t,{indices:n,attributes:i}=gn(t);super({...t,id:e,topology:"triangle-list",indices:n,attributes:{...i,...t.attributes}})}};function gn(s){let{iterations:t=0}=s,e=Math.PI,n=e*2,i=[...un],r=[...xn];i.push(),r.push();let a=(()=>{let f={};return(l,d)=>{l*=3,d*=3;let u=l<d?l:d,M=l>d?l:d,m=`${u}|${M}`;if(m in f)return f[m];let g=i[l],_=i[l+1],b=i[l+2],p=i[d],x=i[d+1],y=i[d+2],w=(g+p)/2,T=(_+x)/2,S=(b+y)/2,E=Math.sqrt(w*w+T*T+S*S);return w/=E,T/=E,S/=E,i.push(w,T,S),f[m]=i.length/3-1}})();for(let f=0;f<t;f++){let l=[];for(let d=0;d<r.length;d+=3){let u=a(r[d+0],r[d+1]),M=a(r[d+1],r[d+2]),m=a(r[d+2],r[d+0]);l.push(m,r[d+0],u,u,r[d+1],M,M,r[d+2],m,u,M,m)}r=l}let o=new Array(i.length),c=new Array(i.length/3*2),h=r.length;for(let f=h-3;f>=0;f-=3){let l=r[f+0],d=r[f+1],u=r[f+2],M=l*3,m=d*3,g=u*3,_=l*2,b=d*2,p=u*2,x=i[M+0],y=i[M+1],w=i[M+2],T=Math.acos(w/Math.sqrt(x*x+y*y+w*w)),S=Math.atan2(y,x)+e,E=T/e,L=1-S/n,A=i[m+0],P=i[m+1],R=i[m+2],v=Math.acos(R/Math.sqrt(A*A+P*P+R*R)),N=Math.atan2(P,A)+e,Y=v/e,W=1-N/n,_t=i[g+0],wt=i[g+1],bt=i[g+2],ys=Math.acos(bt/Math.sqrt(_t*_t+wt*wt+bt*bt)),Ms=Math.atan2(wt,_t)+e,xe=ys/e,At=1-Ms/n,_s=[_t-A,wt-P,bt-R],ws=[x-A,y-P,w-R],q=new $(_s).cross(ws).normalize(),I;(L===0||W===0||At===0)&&(L===0||L>.5)&&(W===0||W>.5)&&(At===0||At>.5)&&(i.push(i[M+0],i[M+1],i[M+2]),I=i.length/3-1,r.push(I),c[I*2+0]=1,c[I*2+1]=E,o[I*3+0]=q.x,o[I*3+1]=q.y,o[I*3+2]=q.z,i.push(i[m+0],i[m+1],i[m+2]),I=i.length/3-1,r.push(I),c[I*2+0]=1,c[I*2+1]=Y,o[I*3+0]=q.x,o[I*3+1]=q.y,o[I*3+2]=q.z,i.push(i[g+0],i[g+1],i[g+2]),I=i.length/3-1,r.push(I),c[I*2+0]=1,c[I*2+1]=xe,o[I*3+0]=q.x,o[I*3+1]=q.y,o[I*3+2]=q.z),o[M+0]=o[m+0]=o[g+0]=q.x,o[M+1]=o[m+1]=o[g+1]=q.y,o[M+2]=o[m+2]=o[g+2]=q.z,c[_+0]=L,c[_+1]=E,c[b+0]=W,c[b+1]=Y,c[p+0]=At,c[p+1]=xe}return{indices:{size:1,value:new Uint16Array(r)},attributes:{POSITION:{size:3,value:new Float32Array(i)},NORMAL:{size:3,value:new Float32Array(o)},TEXCOORD_0:{size:2,value:new Float32Array(c)}}}}function xs(s){let{indices:t,attributes:e}=s;if(!t)return s;let n=t.value.length,i={};for(let r in e){let a=e[r],{constant:o,value:c,size:h}=a;if(o||!h)continue;let f=new c.constructor(n*h);for(let l=0;l<n;++l){let d=t.value[l];for(let u=0;u<h;u++)f[l*h+u]=c[d*h+u]}i[r]={size:h,value:f}}return{attributes:Object.assign({},e,i)}}var Kt=class extends k{constructor(t={}){let{id:e=C("plane-geometry")}=t,{indices:n,attributes:i}=yn(t);super({...t,id:e,topology:"triangle-list",indices:n,attributes:{...i,...t.attributes}})}};function yn(s){let{type:t="x,y",offset:e=0,flipCull:n=!1,unpack:i=!1}=s,r=t.split(","),a=s[`${r[0]}len`]||1,o=s[`${r[1]}len`]||1,c=s[`n${r[0]}`]||1,h=s[`n${r[1]}`]||1,f=(c+1)*(h+1),l=new Float32Array(f*3),d=new Float32Array(f*3),u=new Float32Array(f*2);n&&(a=-a);let M=0,m=0;for(let p=0;p<=h;p++)for(let x=0;x<=c;x++){let y=x/c,w=p/h;switch(u[M+0]=n?1-y:y,u[M+1]=w,t){case"x,y":l[m+0]=a*y-a*.5,l[m+1]=o*w-o*.5,l[m+2]=e,d[m+0]=0,d[m+1]=0,d[m+2]=n?1:-1;break;case"x,z":l[m+0]=a*y-a*.5,l[m+1]=e,l[m+2]=o*w-o*.5,d[m+0]=0,d[m+1]=n?1:-1,d[m+2]=0;break;case"y,z":l[m+0]=e,l[m+1]=a*y-a*.5,l[m+2]=o*w-o*.5,d[m+0]=n?1:-1,d[m+1]=0,d[m+2]=0;break;default:throw new Error("PlaneGeometry: unknown type")}M+=2,m+=3}let g=c+1,_=new Uint16Array(c*h*6);for(let p=0;p<h;p++)for(let x=0;x<c;x++){let y=(p*c+x)*6;_[y+0]=(p+0)*g+x,_[y+1]=(p+1)*g+x,_[y+2]=(p+0)*g+x+1,_[y+3]=(p+1)*g+x,_[y+4]=(p+1)*g+x+1,_[y+5]=(p+0)*g+x+1}let b={indices:{size:1,value:_},attributes:{POSITION:{size:3,value:l},NORMAL:{size:3,value:d},TEXCOORD_0:{size:2,value:u}}};return i?xs(b):b}var Zt=class extends k{constructor(t={}){let{id:e=C("sphere-geometry")}=t,{indices:n,attributes:i}=Mn(t);super({...t,id:e,topology:"triangle-list",indices:n,attributes:{...i,...t.attributes}})}};function Mn(s){let{nlat:t=10,nlong:e=10}=s,r=Math.PI-0,a=0,c=2*Math.PI-a,h=(t+1)*(e+1),f=(_,b,p,x,y)=>s.radius||1,l=new Float32Array(h*3),d=new Float32Array(h*3),u=new Float32Array(h*2),M=h>65535?Uint32Array:Uint16Array,m=new M(t*e*6);for(let _=0;_<=t;_++)for(let b=0;b<=e;b++){let p=b/e,x=_/t,y=b+_*(e+1),w=y*2,T=y*3,S=c*p,E=r*x,L=Math.sin(S),A=Math.cos(S),P=Math.sin(E),R=Math.cos(E),v=A*P,N=R,Y=L*P,W=f(v,N,Y,p,x);l[T+0]=W*v,l[T+1]=W*N,l[T+2]=W*Y,d[T+0]=v,d[T+1]=N,d[T+2]=Y,u[w+0]=p,u[w+1]=1-x}let g=e+1;for(let _=0;_<e;_++)for(let b=0;b<t;b++){let p=(_*t+b)*6;m[p+0]=b*g+_,m[p+1]=b*g+_+1,m[p+2]=(b+1)*g+_,m[p+3]=(b+1)*g+_,m[p+4]=b*g+_+1,m[p+5]=(b+1)*g+_+1}return{indices:{size:1,value:m},attributes:{POSITION:{size:3,value:l},NORMAL:{size:3,value:d},TEXCOORD_0:{size:2,value:u}}}}function gs(){let s=1,t=1;return()=>(s=Math.sin(t*17.23),t=Math.cos(s*27.92),_n(Math.abs(s*t)*1432.71))}function _n(s){return s-Math.floor(s)}var U=D(V(),1),Qt=D(rt(),1);var pe=2,wn=1e4,ue=class{device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(t,e){if(t.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...ue.defaultProps,...e},e=this.props,this.id=e.id||C("model"),this.device=t,Object.assign(this.userData,e.userData);let n=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]);this.shaderInputs=e.shaderInputs||new J(n),this.setShaderInputs(this.shaderInputs),this.props.shaderLayout||=(0,Qt.getShaderLayoutFromWGSL)(this.props.source);let i=bn(t),r=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];this.pipelineFactory=e.pipelineFactory||H.getDefaultPipelineFactory(this.device),this.shaderFactory=e.shaderFactory||X.getDefaultShaderFactory(this.device);let{source:a,getUniforms:o}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:i,...this.props,modules:r});this.source=a,this._getModuleUniforms=o,this.pipeline=this._updatePipeline(),e.bindings&&this.setBindings(e.bindings),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(){this.updateShaderInputs()}dispatch(t,e,n,i){try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),t.setPipeline(this.pipeline),t.setBindings([]),t.dispatch(e,n,i)}finally{this._logDrawCallEnd()}}setVertexCount(t){}setInstanceCount(t){}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new U.UniformStore(this.shaderInputs.modules);for(let e of Object.keys(this.shaderInputs.modules)){let n=this._uniformStore.getManagedUniformBuffer(this.device,e);this.bindings[`${e}Uniforms`]=n}}setShaderModuleProps(t){let e=this._getModuleUniforms(t),n=Object.keys(e).filter(r=>{let a=e[r];return!gt(a)&&typeof a!="number"&&typeof a!="boolean"}),i={};for(let r of n)i[r]=e[r],delete e[r]}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues())}setBindings(t){Object.assign(this.bindings,t)}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||t}_updatePipeline(){if(this._pipelineNeedsUpdate){let t=null;this.pipeline&&(U.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debug:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let t=U.log.level>3?0:wn;U.log.level<2||Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,U.log.group(pe,`>>> DRAWING MODEL ${this.id}`,{collapsed:U.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=this.shaderInputs.getDebugTable();U.log.table(pe,t)(),U.log.groupEnd(pe)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(t,e){let n=(0,U.getTypedArrayFromDataType)(e);return(t instanceof U.Buffer?new n(t.debugData):t).toString()}},yt=ue;Q(yt,"defaultProps",{...U.ComputePipeline.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Qt.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0});function bn(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,features:s.features}}return Rs(Mt);})();
|
|
22
|
+
`,Be=[-1,-1,1,-1,-1,1,1,1],Ft=class extends j{constructor(t,e){let n=Be.map(i=>i===-1?0:i);super(t,{...e,vs:Us,vertexCount:4,geometry:new k({topology:"triangle-strip",vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(Be)},aTexCoord:{size:2,value:new Float32Array(n)},aCoordinate:{size:2,value:new Float32Array(n)}}})})}};var Li=1/Math.PI*180,Ci=1/180*Math.PI,$s={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...$s}};var F=globalThis.mathgl.config;function Ue(s,{precision:t=F.precision}={}){return s=qs(s),`${parseFloat(s.toPrecision(t))}`}function lt(s){return Array.isArray(s)||ArrayBuffer.isView(s)&&!(s instanceof DataView)}function oe(s,t,e){let n=F.EPSILON;e&&(F.EPSILON=e);try{if(s===t)return!0;if(lt(s)&<(t)){if(s.length!==t.length)return!1;for(let i=0;i<s.length;++i)if(!oe(s[i],t[i]))return!1;return!0}return s&&s.equals?s.equals(t):t&&t.equals?t.equals(s):typeof s=="number"&&typeof t=="number"?Math.abs(s-t)<=F.EPSILON*Math.max(1,Math.abs(s),Math.abs(t)):!1}finally{F.EPSILON=n}}function qs(s){return Math.round(s/F.EPSILON)*F.EPSILON}var ft=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,e=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+e];return this.check()}toArray(t=[],e=0){for(let n=0;n<this.ELEMENTS;++n)t[e+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:lt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(F)}formatString(t){let e="";for(let n=0;n<this.ELEMENTS;++n)e+=(n>0?", ":"")+Ue(this[n],t);return`${t.printTypes?this.constructor.name:""}[${e}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!oe(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,n){if(n===void 0)return this.lerp(this,t,e);for(let i=0;i<this.ELEMENTS;++i){let r=t[i],a=typeof e=="number"?e:e[i];this[i]=r+n*(a-r)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),e[n]);return this.check()}add(...t){for(let e of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=e[n];return this.check()}subtract(...t){for(let e of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=e[n];return this.check()}scale(t){if(typeof t=="number")for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}check(){if(F.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t),e);return this.check()}get elements(){return this}};function Vs(s,t){if(s.length!==t)return!1;for(let e=0;e<s.length;++e)if(!Number.isFinite(s[e]))return!1;return!0}function B(s){if(!Number.isFinite(s))throw new Error(`Invalid number ${JSON.stringify(s)}`);return s}function Dt(s,t,e=""){if(F.debug&&!Vs(s,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return s}function ae(s,t){if(!s)throw new Error(`math.gl assertion ${t}`)}var kt=class extends ft{get x(){return this[0]}set x(t){this[0]=B(t)}get y(){return this[1]}set y(t){this[1]=B(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let n=0;n<this.ELEMENTS;++n){let i=this[n]-t[n];e+=i*i}return B(e)}dot(t){let e=0;for(let n=0;n<this.ELEMENTS;++n)e+=this[n]*t[n];return B(e)}normalize(){let t=this.magnitude();if(t!==0)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(let e of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=e[n];return this.check()}divide(...t){for(let e of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=e[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return ae(t>=0&&t<this.ELEMENTS,"index is out of range"),B(this[t])}setComponent(t,e){return ae(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}};var K=typeof Float32Array<"u"?Float32Array:Array;var Vi=Math.PI/180;function js(){let s=new K(2);return K!=Float32Array&&(s[0]=0,s[1]=0),s}function Ve(s,t,e){let n=t[0],i=t[1];return s[0]=e[0]*n+e[4]*i+e[12],s[1]=e[1]*n+e[5]*i+e[13],s}var ji=function(){let s=js();return function(t,e,n,i,r,a){let o,c;for(e||(e=2),n||(n=0),i?c=Math.min(i*e+n,t.length):c=t.length,o=n;o<c;o+=e)s[0]=t[o],s[1]=t[o+1],r(s,s,a),t[o]=s[0],t[o+1]=s[1];return t}}();function je(s,t,e){let n=t[0],i=t[1],r=e[3]*n+e[7]*i||1;return s[0]=(e[0]*n+e[4]*i)/r,s[1]=(e[1]*n+e[5]*i)/r,s}function Bt(s,t,e){let n=t[0],i=t[1],r=t[2],a=e[3]*n+e[7]*i+e[11]*r||1;return s[0]=(e[0]*n+e[4]*i+e[8]*r)/a,s[1]=(e[1]*n+e[5]*i+e[9]*r)/a,s[2]=(e[2]*n+e[6]*i+e[10]*r)/a,s}function We(s,t,e){let n=t[0],i=t[1];return s[0]=e[0]*n+e[2]*i,s[1]=e[1]*n+e[3]*i,s[2]=t[2],s}function Ws(){let s=new K(3);return K!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s}function Gs(s,t){return s[0]*t[0]+s[1]*t[1]+s[2]*t[2]}function Ge(s,t,e){let n=t[0],i=t[1],r=t[2],a=e[0],o=e[1],c=e[2];return s[0]=i*c-r*o,s[1]=r*a-n*c,s[2]=n*o-i*a,s}function Ut(s,t,e){let n=t[0],i=t[1],r=t[2],a=e[3]*n+e[7]*i+e[11]*r+e[15];return a=a||1,s[0]=(e[0]*n+e[4]*i+e[8]*r+e[12])/a,s[1]=(e[1]*n+e[5]*i+e[9]*r+e[13])/a,s[2]=(e[2]*n+e[6]*i+e[10]*r+e[14])/a,s}function Ye(s,t,e){let n=t[0],i=t[1],r=t[2];return s[0]=n*e[0]+i*e[3]+r*e[6],s[1]=n*e[1]+i*e[4]+r*e[7],s[2]=n*e[2]+i*e[5]+r*e[8],s}function He(s,t,e){let n=e[0],i=e[1],r=e[2],a=e[3],o=t[0],c=t[1],h=t[2],f=i*h-r*c,l=r*o-n*h,d=n*c-i*o,p=i*d-r*l,M=r*f-n*d,m=n*l-i*f,g=a*2;return f*=g,l*=g,d*=g,p*=2,M*=2,m*=2,s[0]=o+f+p,s[1]=c+l+M,s[2]=h+d+m,s}function Xe(s,t,e,n){let i=[],r=[];return i[0]=t[0]-e[0],i[1]=t[1]-e[1],i[2]=t[2]-e[2],r[0]=i[0],r[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),r[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),s[0]=r[0]+e[0],s[1]=r[1]+e[1],s[2]=r[2]+e[2],s}function Ke(s,t,e,n){let i=[],r=[];return i[0]=t[0]-e[0],i[1]=t[1]-e[1],i[2]=t[2]-e[2],r[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),r[1]=i[1],r[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),s[0]=r[0]+e[0],s[1]=r[1]+e[1],s[2]=r[2]+e[2],s}function Ze(s,t,e,n){let i=[],r=[];return i[0]=t[0]-e[0],i[1]=t[1]-e[1],i[2]=t[2]-e[2],r[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),r[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),r[2]=i[2],s[0]=r[0]+e[0],s[1]=r[1]+e[1],s[2]=r[2]+e[2],s}function Qe(s,t){let e=s[0],n=s[1],i=s[2],r=t[0],a=t[1],o=t[2],c=Math.sqrt((e*e+n*n+i*i)*(r*r+a*a+o*o)),h=c&&Gs(s,t)/c;return Math.acos(Math.min(Math.max(h,-1),1))}var Yi=function(){let s=Ws();return function(t,e,n,i,r,a){let o,c;for(e||(e=3),n||(n=0),i?c=Math.min(i*e+n,t.length):c=t.length,o=n;o<c;o+=e)s[0]=t[o],s[1]=t[o+1],s[2]=t[o+2],r(s,s,a),t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2];return t}}();var he=[0,0,0],$t,$=class extends kt{static get ZERO(){return $t||($t=new $(0,0,0),Object.freeze($t)),$t}constructor(t=0,e=0,n=0){super(-0,-0,-0),arguments.length===1&<(t)?this.copy(t):(F.debug&&(B(t),B(e),B(n)),this[0]=t,this[1]=e,this[2]=n)}set(t,e,n){return this[0]=t,this[1]=e,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return F.debug&&(B(t.x),B(t.y),B(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=B(t)}angle(t){return Qe(this,t)}cross(t){return Ge(this,this,t),this.check()}rotateX({radians:t,origin:e=he}){return Xe(this,this,e,t),this.check()}rotateY({radians:t,origin:e=he}){return Ke(this,this,e,t),this.check()}rotateZ({radians:t,origin:e=he}){return Ze(this,this,e,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Ut(this,this,t),this.check()}transformAsVector(t){return Bt(this,this,t),this.check()}transformByMatrix3(t){return Ye(this,this,t),this.check()}transformByMatrix2(t){return We(this,this,t),this.check()}transformByQuaternion(t){return He(this,this,t),this.check()}};var qt=class extends ft{toString(){let t="[";if(F.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+e]}`}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=` ${this[e]}`}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,n){return this[e*this.RANK+t]=B(n),this}getColumn(t,e=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)e[i]=this[n+i];return e}setColumn(t,e){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)this[n+i]=e[i];return this}};function Ys(s){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function Je(s,t){if(s===t){let e=t[1],n=t[2],i=t[3],r=t[6],a=t[7],o=t[11];s[1]=t[4],s[2]=t[8],s[3]=t[12],s[4]=e,s[6]=t[9],s[7]=t[13],s[8]=n,s[9]=r,s[11]=t[14],s[12]=i,s[13]=a,s[14]=o}else s[0]=t[0],s[1]=t[4],s[2]=t[8],s[3]=t[12],s[4]=t[1],s[5]=t[5],s[6]=t[9],s[7]=t[13],s[8]=t[2],s[9]=t[6],s[10]=t[10],s[11]=t[14],s[12]=t[3],s[13]=t[7],s[14]=t[11],s[15]=t[15];return s}function ts(s,t){let e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],h=t[7],f=t[8],l=t[9],d=t[10],p=t[11],M=t[12],m=t[13],g=t[14],_=t[15],b=e*o-n*a,u=e*c-i*a,x=e*h-r*a,y=n*c-i*o,w=n*h-r*o,T=i*h-r*c,S=f*m-l*M,E=f*g-d*M,L=f*_-p*M,A=l*g-d*m,P=l*_-p*m,R=d*_-p*g,v=b*R-u*P+x*A+y*L-w*E+T*S;return v?(v=1/v,s[0]=(o*R-c*P+h*A)*v,s[1]=(i*P-n*R-r*A)*v,s[2]=(m*T-g*w+_*y)*v,s[3]=(d*w-l*T-p*y)*v,s[4]=(c*L-a*R-h*E)*v,s[5]=(e*R-i*L+r*E)*v,s[6]=(g*x-M*T-_*u)*v,s[7]=(f*T-d*x+p*u)*v,s[8]=(a*P-o*L+h*S)*v,s[9]=(n*L-e*P-r*S)*v,s[10]=(M*w-m*x+_*b)*v,s[11]=(l*x-f*w-p*b)*v,s[12]=(o*E-a*A-c*S)*v,s[13]=(e*A-n*E+i*S)*v,s[14]=(m*u-M*y-g*b)*v,s[15]=(f*y-l*u+d*b)*v,s):null}function es(s){let t=s[0],e=s[1],n=s[2],i=s[3],r=s[4],a=s[5],o=s[6],c=s[7],h=s[8],f=s[9],l=s[10],d=s[11],p=s[12],M=s[13],m=s[14],g=s[15],_=t*a-e*r,b=t*o-n*r,u=e*o-n*a,x=h*M-f*p,y=h*m-l*p,w=f*m-l*M,T=t*w-e*y+n*x,S=r*w-a*y+o*x,E=h*u-f*b+l*_,L=p*u-M*b+m*_;return c*T-i*S+g*E-d*L}function le(s,t,e){let n=t[0],i=t[1],r=t[2],a=t[3],o=t[4],c=t[5],h=t[6],f=t[7],l=t[8],d=t[9],p=t[10],M=t[11],m=t[12],g=t[13],_=t[14],b=t[15],u=e[0],x=e[1],y=e[2],w=e[3];return s[0]=u*n+x*o+y*l+w*m,s[1]=u*i+x*c+y*d+w*g,s[2]=u*r+x*h+y*p+w*_,s[3]=u*a+x*f+y*M+w*b,u=e[4],x=e[5],y=e[6],w=e[7],s[4]=u*n+x*o+y*l+w*m,s[5]=u*i+x*c+y*d+w*g,s[6]=u*r+x*h+y*p+w*_,s[7]=u*a+x*f+y*M+w*b,u=e[8],x=e[9],y=e[10],w=e[11],s[8]=u*n+x*o+y*l+w*m,s[9]=u*i+x*c+y*d+w*g,s[10]=u*r+x*h+y*p+w*_,s[11]=u*a+x*f+y*M+w*b,u=e[12],x=e[13],y=e[14],w=e[15],s[12]=u*n+x*o+y*l+w*m,s[13]=u*i+x*c+y*d+w*g,s[14]=u*r+x*h+y*p+w*_,s[15]=u*a+x*f+y*M+w*b,s}function ss(s,t,e){let n=e[0],i=e[1],r=e[2],a,o,c,h,f,l,d,p,M,m,g,_;return t===s?(s[12]=t[0]*n+t[4]*i+t[8]*r+t[12],s[13]=t[1]*n+t[5]*i+t[9]*r+t[13],s[14]=t[2]*n+t[6]*i+t[10]*r+t[14],s[15]=t[3]*n+t[7]*i+t[11]*r+t[15]):(a=t[0],o=t[1],c=t[2],h=t[3],f=t[4],l=t[5],d=t[6],p=t[7],M=t[8],m=t[9],g=t[10],_=t[11],s[0]=a,s[1]=o,s[2]=c,s[3]=h,s[4]=f,s[5]=l,s[6]=d,s[7]=p,s[8]=M,s[9]=m,s[10]=g,s[11]=_,s[12]=a*n+f*i+M*r+t[12],s[13]=o*n+l*i+m*r+t[13],s[14]=c*n+d*i+g*r+t[14],s[15]=h*n+p*i+_*r+t[15]),s}function ns(s,t,e){let n=e[0],i=e[1],r=e[2];return s[0]=t[0]*n,s[1]=t[1]*n,s[2]=t[2]*n,s[3]=t[3]*n,s[4]=t[4]*i,s[5]=t[5]*i,s[6]=t[6]*i,s[7]=t[7]*i,s[8]=t[8]*r,s[9]=t[9]*r,s[10]=t[10]*r,s[11]=t[11]*r,s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15],s}function is(s,t,e,n){let i=n[0],r=n[1],a=n[2],o=Math.sqrt(i*i+r*r+a*a),c,h,f,l,d,p,M,m,g,_,b,u,x,y,w,T,S,E,L,A,P,R,v,N;return o<1e-6?null:(o=1/o,i*=o,r*=o,a*=o,h=Math.sin(e),c=Math.cos(e),f=1-c,l=t[0],d=t[1],p=t[2],M=t[3],m=t[4],g=t[5],_=t[6],b=t[7],u=t[8],x=t[9],y=t[10],w=t[11],T=i*i*f+c,S=r*i*f+a*h,E=a*i*f-r*h,L=i*r*f-a*h,A=r*r*f+c,P=a*r*f+i*h,R=i*a*f+r*h,v=r*a*f-i*h,N=a*a*f+c,s[0]=l*T+m*S+u*E,s[1]=d*T+g*S+x*E,s[2]=p*T+_*S+y*E,s[3]=M*T+b*S+w*E,s[4]=l*L+m*A+u*P,s[5]=d*L+g*A+x*P,s[6]=p*L+_*A+y*P,s[7]=M*L+b*A+w*P,s[8]=l*R+m*v+u*N,s[9]=d*R+g*v+x*N,s[10]=p*R+_*v+y*N,s[11]=M*R+b*v+w*N,t!==s&&(s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15]),s)}function rs(s,t,e){let n=Math.sin(e),i=Math.cos(e),r=t[4],a=t[5],o=t[6],c=t[7],h=t[8],f=t[9],l=t[10],d=t[11];return t!==s&&(s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15]),s[4]=r*i+h*n,s[5]=a*i+f*n,s[6]=o*i+l*n,s[7]=c*i+d*n,s[8]=h*i-r*n,s[9]=f*i-a*n,s[10]=l*i-o*n,s[11]=d*i-c*n,s}function os(s,t,e){let n=Math.sin(e),i=Math.cos(e),r=t[0],a=t[1],o=t[2],c=t[3],h=t[8],f=t[9],l=t[10],d=t[11];return t!==s&&(s[4]=t[4],s[5]=t[5],s[6]=t[6],s[7]=t[7],s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15]),s[0]=r*i-h*n,s[1]=a*i-f*n,s[2]=o*i-l*n,s[3]=c*i-d*n,s[8]=r*n+h*i,s[9]=a*n+f*i,s[10]=o*n+l*i,s[11]=c*n+d*i,s}function as(s,t,e){let n=Math.sin(e),i=Math.cos(e),r=t[0],a=t[1],o=t[2],c=t[3],h=t[4],f=t[5],l=t[6],d=t[7];return t!==s&&(s[8]=t[8],s[9]=t[9],s[10]=t[10],s[11]=t[11],s[12]=t[12],s[13]=t[13],s[14]=t[14],s[15]=t[15]),s[0]=r*i+h*n,s[1]=a*i+f*n,s[2]=o*i+l*n,s[3]=c*i+d*n,s[4]=h*i-r*n,s[5]=f*i-a*n,s[6]=l*i-o*n,s[7]=d*i-c*n,s}function cs(s,t){let e=t[0],n=t[1],i=t[2],r=t[3],a=e+e,o=n+n,c=i+i,h=e*a,f=n*a,l=n*o,d=i*a,p=i*o,M=i*c,m=r*a,g=r*o,_=r*c;return s[0]=1-l-M,s[1]=f+_,s[2]=d-g,s[3]=0,s[4]=f-_,s[5]=1-h-M,s[6]=p+m,s[7]=0,s[8]=d+g,s[9]=p-m,s[10]=1-h-l,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,s}function hs(s,t,e,n,i,r,a){let o=1/(e-t),c=1/(i-n),h=1/(r-a);return s[0]=r*2*o,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r*2*c,s[6]=0,s[7]=0,s[8]=(e+t)*o,s[9]=(i+n)*c,s[10]=(a+r)*h,s[11]=-1,s[12]=0,s[13]=0,s[14]=a*r*2*h,s[15]=0,s}function Hs(s,t,e,n,i){let r=1/Math.tan(t/2);if(s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,i!=null&&i!==1/0){let a=1/(n-i);s[10]=(i+n)*a,s[14]=2*i*n*a}else s[10]=-1,s[14]=-2*n;return s}var ls=Hs;function Xs(s,t,e,n,i,r,a){let o=1/(t-e),c=1/(n-i),h=1/(r-a);return s[0]=-2*o,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*h,s[11]=0,s[12]=(t+e)*o,s[13]=(i+n)*c,s[14]=(a+r)*h,s[15]=1,s}var fs=Xs;function ds(s,t,e,n){let i,r,a,o,c,h,f,l,d,p,M=t[0],m=t[1],g=t[2],_=n[0],b=n[1],u=n[2],x=e[0],y=e[1],w=e[2];return Math.abs(M-x)<1e-6&&Math.abs(m-y)<1e-6&&Math.abs(g-w)<1e-6?Ys(s):(l=M-x,d=m-y,p=g-w,i=1/Math.sqrt(l*l+d*d+p*p),l*=i,d*=i,p*=i,r=b*p-u*d,a=u*l-_*p,o=_*d-b*l,i=Math.sqrt(r*r+a*a+o*o),i?(i=1/i,r*=i,a*=i,o*=i):(r=0,a=0,o=0),c=d*o-p*a,h=p*r-l*o,f=l*a-d*r,i=Math.sqrt(c*c+h*h+f*f),i?(i=1/i,c*=i,h*=i,f*=i):(c=0,h=0,f=0),s[0]=r,s[1]=c,s[2]=l,s[3]=0,s[4]=a,s[5]=h,s[6]=d,s[7]=0,s[8]=o,s[9]=f,s[10]=p,s[11]=0,s[12]=-(r*M+a*m+o*g),s[13]=-(c*M+h*m+f*g),s[14]=-(l*M+d*m+p*g),s[15]=1,s)}function Ks(){let s=new K(4);return K!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0,s[3]=0),s}function ms(s,t,e){let n=t[0],i=t[1],r=t[2],a=t[3];return s[0]=e[0]*n+e[4]*i+e[8]*r+e[12]*a,s[1]=e[1]*n+e[5]*i+e[9]*r+e[13]*a,s[2]=e[2]*n+e[6]*i+e[10]*r+e[14]*a,s[3]=e[3]*n+e[7]*i+e[11]*r+e[15]*a,s}var or=function(){let s=Ks();return function(t,e,n,i,r,a){let o,c;for(e||(e=4),n||(n=0),i?c=Math.min(i*e+n,t.length):c=t.length,o=n;o<c;o+=e)s[0]=t[o],s[1]=t[o+1],s[2]=t[o+2],s[3]=t[o+3],r(s,s,a),t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3];return t}}();var me;(function(s){s[s.COL0ROW0=0]="COL0ROW0",s[s.COL0ROW1=1]="COL0ROW1",s[s.COL0ROW2=2]="COL0ROW2",s[s.COL0ROW3=3]="COL0ROW3",s[s.COL1ROW0=4]="COL1ROW0",s[s.COL1ROW1=5]="COL1ROW1",s[s.COL1ROW2=6]="COL1ROW2",s[s.COL1ROW3=7]="COL1ROW3",s[s.COL2ROW0=8]="COL2ROW0",s[s.COL2ROW1=9]="COL2ROW1",s[s.COL2ROW2=10]="COL2ROW2",s[s.COL2ROW3=11]="COL2ROW3",s[s.COL3ROW0=12]="COL3ROW0",s[s.COL3ROW1=13]="COL3ROW1",s[s.COL3ROW2=14]="COL3ROW2",s[s.COL3ROW3=15]="COL3ROW3"})(me||(me={}));var Zs=45*Math.PI/180,Qs=1,fe=.1,de=500,Js=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),G=class extends qt{static get IDENTITY(){return en()}static get ZERO(){return tn()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return me}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,e,n,i,r,a,o,c,h,f,l,d,p,M,m,g){return this[0]=t,this[1]=e,this[2]=n,this[3]=i,this[4]=r,this[5]=a,this[6]=o,this[7]=c,this[8]=h,this[9]=f,this[10]=l,this[11]=d,this[12]=p,this[13]=M,this[14]=m,this[15]=g,this.check()}setRowMajor(t,e,n,i,r,a,o,c,h,f,l,d,p,M,m,g){return this[0]=t,this[1]=r,this[2]=h,this[3]=p,this[4]=e,this[5]=a,this[6]=f,this[7]=M,this[8]=n,this[9]=o,this[10]=l,this[11]=m,this[12]=i,this[13]=c,this[14]=d,this[15]=g,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Js)}fromObject(t){return this.check()}fromQuaternion(t){return cs(this,t),this.check()}frustum(t){let{left:e,right:n,bottom:i,top:r,near:a=fe,far:o=de}=t;return o===1/0?sn(this,e,n,i,r,a):hs(this,e,n,i,r,a,o),this.check()}lookAt(t){let{eye:e,center:n=[0,0,0],up:i=[0,1,0]}=t;return ds(this,e,n,i),this.check()}ortho(t){let{left:e,right:n,bottom:i,top:r,near:a=fe,far:o=de}=t;return fs(this,e,n,i,r,a,o),this.check()}orthographic(t){let{fovy:e=Zs,aspect:n=Qs,focalDistance:i=1,near:r=fe,far:a=de}=t;us(e);let o=e/2,c=i*Math.tan(o),h=c*n;return this.ortho({left:-h,right:h,bottom:-c,top:c,near:r,far:a})}perspective(t){let{fovy:e=45*Math.PI/180,aspect:n=1,near:i=.1,far:r=500}=t;return us(e),ls(this,e,n,i,r),this.check()}determinant(){return es(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let n=this.getScale(e),i=1/n[0],r=1/n[1],a=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*r,t[2]=this[2]*a,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*r,t[6]=this[6]*a,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*r,t[10]=this[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let n=this.getScale(e),i=1/n[0],r=1/n[1],a=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*r,t[2]=this[2]*a,t[3]=this[4]*i,t[4]=this[5]*r,t[5]=this[6]*a,t[6]=this[8]*i,t[7]=this[9]*r,t[8]=this[10]*a,t}transpose(){return Je(this,this),this.check()}invert(){return ts(this,this),this.check()}multiplyLeft(t){return le(this,t,this),this.check()}multiplyRight(t){return le(this,this,t),this.check()}rotateX(t){return rs(this,this,t),this.check()}rotateY(t){return os(this,this,t),this.check()}rotateZ(t){return as(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return is(this,this,t,e),this.check()}scale(t){return ns(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return ss(this,this,t),this.check()}transform(t,e){return t.length===4?(e=ms(e||[-0,-0,-0,-0],t,this),Dt(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){let{length:n}=t,i;switch(n){case 2:i=Ve(e||[-0,-0],t,this);break;case 3:i=Ut(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Dt(i,t.length),i}transformAsVector(t,e){let n;switch(t.length){case 2:n=je(e||[-0,-0],t,this);break;case 3:n=Bt(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Dt(n,t.length),n}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,n){return this.identity().translate([t,e,n])}},Vt,jt;function tn(){return Vt||(Vt=new G([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Vt)),Vt}function en(){return jt||(jt=new G,Object.freeze(jt)),jt}function us(s){if(s>Math.PI*2)throw Error("expected radians")}function sn(s,t,e,n,i,r){let a=2*r/(e-t),o=2*r/(i-n),c=(e+t)/(e-t),h=(i+n)/(i-n),f=-1,l=-1,d=-2*r;return s[0]=a,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=o,s[6]=0,s[7]=0,s[8]=c,s[9]=h,s[10]=f,s[11]=l,s[12]=0,s[13]=0,s[14]=d,s[15]=0,s}var Z=class{id;matrix=new G;display=!0;position=new $;rotation=new $;scale=new $(1,1,1);userData={};props={};constructor(t={}){let{id:e}=t;this.id=e||C(this.constructor.name),this._setScenegraphNodeProps(t)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(t){return this._setScenegraphNodeProps(t),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(t){return this.position=t,this}setRotation(t){return this.rotation=t,this}setScale(t){return this.scale=t,this}setMatrix(t,e=!0){e?this.matrix.copy(t):this.matrix=t}setMatrixComponents(t){let{position:e,rotation:n,scale:i,update:r=!0}=t;return e&&this.setPosition(e),n&&this.setRotation(n),i&&this.setScale(i),r&&this.updateMatrix(),this}updateMatrix(){let t=this.position,e=this.rotation,n=this.scale;return this.matrix.identity(),this.matrix.translate(t),this.matrix.rotateXYZ(e),this.matrix.scale(n),this}update(t={}){let{position:e,rotation:n,scale:i}=t;return e&&this.setPosition(e),n&&this.setRotation(n),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(t,e){e=e||this.matrix;let n=new G(t).multiplyRight(e),i=n.invert(),r=i.transpose();return{viewMatrix:t,modelMatrix:e,objectMatrix:e,worldMatrix:n,worldInverseMatrix:i,worldInverseTransposeMatrix:r}}_setScenegraphNodeProps(t){"position"in t&&this.setPosition(t.position),"rotation"in t&&this.setRotation(t.rotation),"scale"in t&&this.setScale(t.scale),"matrix"in t&&this.setMatrix(t.matrix),Object.assign(this.props,t)}};var ps=D(V(),1);var mt=class extends Z{children;constructor(t={}){t=Array.isArray(t)?{children:t}:t;let{children:e=[]}=t;ps.log.assert(e.every(n=>n instanceof Z),"every child must an instance of ScenegraphNode"),super(t),this.children=e}getBounds(){let t=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((e,{worldMatrix:n})=>{let i=e.getBounds();if(!i)return;let[r,a]=i,o=new $(r).add(a).divide([2,2,2]);n.transformAsPoint(o,o);let c=new $(a).subtract(r).divide([2,2,2]);n.transformAsVector(c,c);for(let h=0;h<8;h++){let f=new $(h&1?-1:1,h&2?-1:1,h&4?-1:1).multiply(c).add(o);for(let l=0;l<3;l++)t[0][l]=Math.min(t[0][l],f[l]),t[1][l]=Math.max(t[1][l],f[l])}}),Number.isFinite(t[0][0])?t:null}destroy(){this.children.forEach(t=>t.destroy()),this.removeAll(),super.destroy()}add(...t){for(let e of t)Array.isArray(e)?this.add(...e):this.children.push(e);return this}remove(t){let e=this.children,n=e.indexOf(t);return n>-1&&e.splice(n,1),this}removeAll(){return this.children=[],this}traverse(t,{worldMatrix:e=new G}={}){let n=new G(e).multiplyRight(this.matrix);for(let i of this.children)i instanceof mt?i.traverse(t,{worldMatrix:n}):t(i,{worldMatrix:n})}};var Wt=class extends Z{model;bounds=null;managedResources;constructor(t){super(t),this.model=t.model,this.managedResources=t.managedResources||[],this.bounds=t.bounds||null,this.setProps(t)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(t=>t.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(t){return this.model.draw(t)}};var nn={x:[2,0,1],y:[0,1,2],z:[1,2,0]},tt=class extends k{constructor(t={}){let{id:e=C("truncated-code-geometry")}=t,{indices:n,attributes:i}=rn(t);super({...t,id:e,topology:"triangle-list",indices:n,attributes:{POSITION:{size:3,value:i.POSITION},NORMAL:{size:3,value:i.NORMAL},TEXCOORD_0:{size:2,value:i.TEXCOORD_0},...t.attributes}})}};function rn(s={}){let{bottomRadius:t=0,topRadius:e=0,height:n=1,nradial:i=10,nvertical:r=10,verticalAxis:a="y",topCap:o=!1,bottomCap:c=!1}=s,h=(o?2:0)+(c?2:0),f=(i+1)*(r+1+h),l=Math.atan2(t-e,n),d=Math.sin,p=Math.cos,M=Math.PI,m=p(l),g=d(l),_=o?-2:0,b=r+(c?2:0),u=i+1,x=new Uint16Array(i*(r+h)*6),y=nn[a],w=new Float32Array(f*3),T=new Float32Array(f*3),S=new Float32Array(f*2),E=0,L=0;for(let A=_;A<=b;A++){let P=A/r,R=n*P,v;A<0?(R=0,P=1,v=t):A>r?(R=n,P=1,v=e):v=t+(e-t)*(A/r),(A===-2||A===r+2)&&(v=0,P=0),R-=n/2;for(let N=0;N<u;N++){let Y=d(N*M*2/i),W=p(N*M*2/i);w[E+y[0]]=Y*v,w[E+y[1]]=R,w[E+y[2]]=W*v,T[E+y[0]]=A<0||A>r?0:Y*m,T[E+y[1]]=A<0?-1:A>r?1:g,T[E+y[2]]=A<0||A>r?0:W*m,S[L+0]=N/i,S[L+1]=P,L+=2,E+=3}}for(let A=0;A<r+h;A++)for(let P=0;P<i;P++){let R=(A*i+P)*6;x[R+0]=u*(A+0)+0+P,x[R+1]=u*(A+0)+1+P,x[R+2]=u*(A+1)+1+P,x[R+3]=u*(A+0)+0+P,x[R+4]=u*(A+1)+1+P,x[R+5]=u*(A+1)+0+P}return{indices:x,attributes:{POSITION:w,NORMAL:T,TEXCOORD_0:S}}}var Gt=class extends tt{constructor(t={}){let{id:e=C("cone-geometry"),radius:n=1,cap:i=!0}=t;super({...t,id:e,topRadius:0,topCap:Boolean(i),bottomCap:Boolean(i),bottomRadius:n})}};var Yt=class extends k{constructor(t={}){let{id:e=C("cube-geometry"),indices:n=!0}=t;super(n?{...t,id:e,topology:"triangle-list",indices:{size:1,value:on},attributes:{...mn,...t.attributes}}:{...t,id:e,topology:"triangle-list",indices:void 0,attributes:{...un,...t.attributes}})}},on=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),an=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),cn=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),hn=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),ln=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),fn=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),dn=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),mn={POSITION:{size:3,value:an},NORMAL:{size:3,value:cn},TEXCOORD_0:{size:2,value:hn}},un={POSITION:{size:3,value:ln},TEXCOORD_0:{size:2,value:fn},COLOR_0:{size:3,value:dn}};var Ht=class extends tt{constructor(t={}){let{id:e=C("cylinder-geometry"),radius:n=1}=t;super({...t,id:e,bottomRadius:n,topRadius:n})}};var pn=[-1,0,0,0,1,0,0,0,-1,0,0,1,0,-1,0,1,0,0],xn=[3,4,5,3,5,1,3,1,0,3,0,4,4,0,2,4,2,5,2,0,1,5,2,1],Xt=class extends k{constructor(t={}){let{id:e=C("ico-sphere-geometry")}=t,{indices:n,attributes:i}=gn(t);super({...t,id:e,topology:"triangle-list",indices:n,attributes:{...i,...t.attributes}})}};function gn(s){let{iterations:t=0}=s,e=Math.PI,n=e*2,i=[...pn],r=[...xn];i.push(),r.push();let a=(()=>{let f={};return(l,d)=>{l*=3,d*=3;let p=l<d?l:d,M=l>d?l:d,m=`${p}|${M}`;if(m in f)return f[m];let g=i[l],_=i[l+1],b=i[l+2],u=i[d],x=i[d+1],y=i[d+2],w=(g+u)/2,T=(_+x)/2,S=(b+y)/2,E=Math.sqrt(w*w+T*T+S*S);return w/=E,T/=E,S/=E,i.push(w,T,S),f[m]=i.length/3-1}})();for(let f=0;f<t;f++){let l=[];for(let d=0;d<r.length;d+=3){let p=a(r[d+0],r[d+1]),M=a(r[d+1],r[d+2]),m=a(r[d+2],r[d+0]);l.push(m,r[d+0],p,p,r[d+1],M,M,r[d+2],m,p,M,m)}r=l}let o=new Array(i.length),c=new Array(i.length/3*2),h=r.length;for(let f=h-3;f>=0;f-=3){let l=r[f+0],d=r[f+1],p=r[f+2],M=l*3,m=d*3,g=p*3,_=l*2,b=d*2,u=p*2,x=i[M+0],y=i[M+1],w=i[M+2],T=Math.acos(w/Math.sqrt(x*x+y*y+w*w)),S=Math.atan2(y,x)+e,E=T/e,L=1-S/n,A=i[m+0],P=i[m+1],R=i[m+2],v=Math.acos(R/Math.sqrt(A*A+P*P+R*R)),N=Math.atan2(P,A)+e,Y=v/e,W=1-N/n,_t=i[g+0],wt=i[g+1],bt=i[g+2],ys=Math.acos(bt/Math.sqrt(_t*_t+wt*wt+bt*bt)),Ms=Math.atan2(wt,_t)+e,xe=ys/e,At=1-Ms/n,_s=[_t-A,wt-P,bt-R],ws=[x-A,y-P,w-R],q=new $(_s).cross(ws).normalize(),I;(L===0||W===0||At===0)&&(L===0||L>.5)&&(W===0||W>.5)&&(At===0||At>.5)&&(i.push(i[M+0],i[M+1],i[M+2]),I=i.length/3-1,r.push(I),c[I*2+0]=1,c[I*2+1]=E,o[I*3+0]=q.x,o[I*3+1]=q.y,o[I*3+2]=q.z,i.push(i[m+0],i[m+1],i[m+2]),I=i.length/3-1,r.push(I),c[I*2+0]=1,c[I*2+1]=Y,o[I*3+0]=q.x,o[I*3+1]=q.y,o[I*3+2]=q.z,i.push(i[g+0],i[g+1],i[g+2]),I=i.length/3-1,r.push(I),c[I*2+0]=1,c[I*2+1]=xe,o[I*3+0]=q.x,o[I*3+1]=q.y,o[I*3+2]=q.z),o[M+0]=o[m+0]=o[g+0]=q.x,o[M+1]=o[m+1]=o[g+1]=q.y,o[M+2]=o[m+2]=o[g+2]=q.z,c[_+0]=L,c[_+1]=E,c[b+0]=W,c[b+1]=Y,c[u+0]=At,c[u+1]=xe}return{indices:{size:1,value:new Uint16Array(r)},attributes:{POSITION:{size:3,value:new Float32Array(i)},NORMAL:{size:3,value:new Float32Array(o)},TEXCOORD_0:{size:2,value:new Float32Array(c)}}}}function xs(s){let{indices:t,attributes:e}=s;if(!t)return s;let n=t.value.length,i={};for(let r in e){let a=e[r],{constant:o,value:c,size:h}=a;if(o||!h)continue;let f=new c.constructor(n*h);for(let l=0;l<n;++l){let d=t.value[l];for(let p=0;p<h;p++)f[l*h+p]=c[d*h+p]}i[r]={size:h,value:f}}return{attributes:Object.assign({},e,i)}}var Kt=class extends k{constructor(t={}){let{id:e=C("plane-geometry")}=t,{indices:n,attributes:i}=yn(t);super({...t,id:e,topology:"triangle-list",indices:n,attributes:{...i,...t.attributes}})}};function yn(s){let{type:t="x,y",offset:e=0,flipCull:n=!1,unpack:i=!1}=s,r=t.split(","),a=s[`${r[0]}len`]||1,o=s[`${r[1]}len`]||1,c=s[`n${r[0]}`]||1,h=s[`n${r[1]}`]||1,f=(c+1)*(h+1),l=new Float32Array(f*3),d=new Float32Array(f*3),p=new Float32Array(f*2);n&&(a=-a);let M=0,m=0;for(let u=0;u<=h;u++)for(let x=0;x<=c;x++){let y=x/c,w=u/h;switch(p[M+0]=n?1-y:y,p[M+1]=w,t){case"x,y":l[m+0]=a*y-a*.5,l[m+1]=o*w-o*.5,l[m+2]=e,d[m+0]=0,d[m+1]=0,d[m+2]=n?1:-1;break;case"x,z":l[m+0]=a*y-a*.5,l[m+1]=e,l[m+2]=o*w-o*.5,d[m+0]=0,d[m+1]=n?1:-1,d[m+2]=0;break;case"y,z":l[m+0]=e,l[m+1]=a*y-a*.5,l[m+2]=o*w-o*.5,d[m+0]=n?1:-1,d[m+1]=0,d[m+2]=0;break;default:throw new Error("PlaneGeometry: unknown type")}M+=2,m+=3}let g=c+1,_=new Uint16Array(c*h*6);for(let u=0;u<h;u++)for(let x=0;x<c;x++){let y=(u*c+x)*6;_[y+0]=(u+0)*g+x,_[y+1]=(u+1)*g+x,_[y+2]=(u+0)*g+x+1,_[y+3]=(u+1)*g+x,_[y+4]=(u+1)*g+x+1,_[y+5]=(u+0)*g+x+1}let b={indices:{size:1,value:_},attributes:{POSITION:{size:3,value:l},NORMAL:{size:3,value:d},TEXCOORD_0:{size:2,value:p}}};return i?xs(b):b}var Zt=class extends k{constructor(t={}){let{id:e=C("sphere-geometry")}=t,{indices:n,attributes:i}=Mn(t);super({...t,id:e,topology:"triangle-list",indices:n,attributes:{...i,...t.attributes}})}};function Mn(s){let{nlat:t=10,nlong:e=10}=s,r=Math.PI-0,a=0,c=2*Math.PI-a,h=(t+1)*(e+1),f=(_,b,u,x,y)=>s.radius||1,l=new Float32Array(h*3),d=new Float32Array(h*3),p=new Float32Array(h*2),M=h>65535?Uint32Array:Uint16Array,m=new M(t*e*6);for(let _=0;_<=t;_++)for(let b=0;b<=e;b++){let u=b/e,x=_/t,y=b+_*(e+1),w=y*2,T=y*3,S=c*u,E=r*x,L=Math.sin(S),A=Math.cos(S),P=Math.sin(E),R=Math.cos(E),v=A*P,N=R,Y=L*P,W=f(v,N,Y,u,x);l[T+0]=W*v,l[T+1]=W*N,l[T+2]=W*Y,d[T+0]=v,d[T+1]=N,d[T+2]=Y,p[w+0]=u,p[w+1]=1-x}let g=e+1;for(let _=0;_<e;_++)for(let b=0;b<t;b++){let u=(_*t+b)*6;m[u+0]=b*g+_,m[u+1]=b*g+_+1,m[u+2]=(b+1)*g+_,m[u+3]=(b+1)*g+_,m[u+4]=b*g+_+1,m[u+5]=(b+1)*g+_+1}return{indices:{size:1,value:m},attributes:{POSITION:{size:3,value:l},NORMAL:{size:3,value:d},TEXCOORD_0:{size:2,value:p}}}}function gs(){let s=1,t=1;return()=>(s=Math.sin(t*17.23),t=Math.cos(s*27.92),_n(Math.abs(s*t)*1432.71))}function _n(s){return s-Math.floor(s)}var U=D(V(),1),Qt=D(rt(),1);var ue=2,wn=1e4,pe=class{device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;source;shader;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(t,e){if(t.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...pe.defaultProps,...e},e=this.props,this.id=e.id||C("model"),this.device=t,Object.assign(this.userData,e.userData);let n=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]);this.shaderInputs=e.shaderInputs||new J(n),this.setShaderInputs(this.shaderInputs),this.props.shaderLayout||=(0,Qt.getShaderLayoutFromWGSL)(this.props.source);let i=bn(t),r=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];this.pipelineFactory=e.pipelineFactory||H.getDefaultPipelineFactory(this.device),this.shaderFactory=e.shaderFactory||X.getDefaultShaderFactory(this.device);let{source:a,getUniforms:o}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:i,...this.props,modules:r});this.source=a,this._getModuleUniforms=o,this.pipeline=this._updatePipeline(),e.bindings&&this.setBindings(e.bindings),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.shader),this._uniformStore.destroy(),this._destroyed=!0)}predraw(){this.updateShaderInputs()}dispatch(t,e,n,i){try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),t.setPipeline(this.pipeline),t.setBindings([]),t.dispatch(e,n,i)}finally{this._logDrawCallEnd()}}setVertexCount(t){}setInstanceCount(t){}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new U.UniformStore(this.shaderInputs.modules);for(let e of Object.keys(this.shaderInputs.modules)){let n=this._uniformStore.getManagedUniformBuffer(this.device,e);this.bindings[`${e}Uniforms`]=n}}setShaderModuleProps(t){let e=this._getModuleUniforms(t),n=Object.keys(e).filter(r=>{let a=e[r];return!gt(a)&&typeof a!="number"&&typeof a!="boolean"}),i={};for(let r of n)i[r]=e[r],delete e[r]}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues())}setBindings(t){Object.assign(this.bindings,t)}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||t}_updatePipeline(){if(this._pipelineNeedsUpdate){let t=null;this.pipeline&&(U.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.shader),this._pipelineNeedsUpdate=!1,this.shader=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"compute",source:this.source,debug:this.props.debugShaders}),this.pipeline=this.pipelineFactory.createComputePipeline({...this.props,shader:this.shader}),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let t=U.log.level>3?0:wn;U.log.level<2||Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,U.log.group(ue,`>>> DRAWING MODEL ${this.id}`,{collapsed:U.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=this.shaderInputs.getDebugTable();U.log.table(ue,t)(),U.log.groupEnd(ue)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(t,e){let n=(0,U.getTypedArrayFromDataType)(e);return(t instanceof U.Buffer?new n(t.debugData):t).toString()}},yt=pe;Q(yt,"defaultProps",{...U.ComputePipeline.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Qt.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0});function bn(s){return{type:s.type,shaderLanguage:s.info.shadingLanguage,shaderLanguageVersion:s.info.shadingLanguageVersion,gpu:s.info.gpu,features:s.features}}return Rs(Mt);})();
|
|
23
23
|
return __exports__;
|
|
24
24
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -1195,6 +1195,20 @@ var AsyncTexture = class {
|
|
|
1195
1195
|
}
|
|
1196
1196
|
this.destroyed = true;
|
|
1197
1197
|
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Textures are immutable and cannot be resized after creation,
|
|
1200
|
+
* but we can create a similar texture with the same parameters but a new size.
|
|
1201
|
+
* @note Does not copy contents of the texture
|
|
1202
|
+
* @todo Abort pending promise and create a texture with the new size?
|
|
1203
|
+
*/
|
|
1204
|
+
resize(size) {
|
|
1205
|
+
if (!this.isReady) {
|
|
1206
|
+
throw new Error("Cannot resize texture before it is ready");
|
|
1207
|
+
}
|
|
1208
|
+
if (this.texture) {
|
|
1209
|
+
this.texture = this.texture.createResizedTexture(size);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1198
1212
|
};
|
|
1199
1213
|
async function awaitAllPromises(x) {
|
|
1200
1214
|
x = await x;
|
|
@@ -1856,7 +1870,6 @@ var BufferTransform = class {
|
|
|
1856
1870
|
device;
|
|
1857
1871
|
model;
|
|
1858
1872
|
transformFeedback;
|
|
1859
|
-
/** @deprecated Use device feature test. */
|
|
1860
1873
|
static isSupported(device) {
|
|
1861
1874
|
var _a;
|
|
1862
1875
|
return ((_a = device == null ? void 0 : device.info) == null ? void 0 : _a.type) === "webgl";
|
|
@@ -1896,10 +1909,6 @@ var BufferTransform = class {
|
|
|
1896
1909
|
this.model.draw(renderPass);
|
|
1897
1910
|
renderPass.end();
|
|
1898
1911
|
}
|
|
1899
|
-
/** @deprecated */
|
|
1900
|
-
update(...args) {
|
|
1901
|
-
console.warn("TextureTransform#update() not implemented");
|
|
1902
|
-
}
|
|
1903
1912
|
/** Returns the {@link Buffer} or {@link BufferRange} for given varying name. */
|
|
1904
1913
|
getBuffer(varyingName) {
|
|
1905
1914
|
return this.transformFeedback.getBuffer(varyingName);
|
|
@@ -1966,13 +1975,6 @@ var TextureTransform = class {
|
|
|
1966
1975
|
this.model.draw(renderPass);
|
|
1967
1976
|
renderPass.end();
|
|
1968
1977
|
}
|
|
1969
|
-
/** @deprecated */
|
|
1970
|
-
update(...args) {
|
|
1971
|
-
console.warn("TextureTransform#update() not implemented");
|
|
1972
|
-
}
|
|
1973
|
-
getData({ packed = false } = {}) {
|
|
1974
|
-
throw new Error("getData() not implemented");
|
|
1975
|
-
}
|
|
1976
1978
|
getTargetTexture() {
|
|
1977
1979
|
const { targetTexture } = this.bindings[this.currentIndex];
|
|
1978
1980
|
return targetTexture;
|