@luma.gl/engine 9.0.0 → 9.0.3
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/dist.dev.js +260 -115
- package/dist/dist.min.js +13 -13
- package/dist/index.cjs +9 -12
- package/dist/index.cjs.map +2 -2
- package/dist/model/model.d.ts +6 -4
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +9 -13
- package/dist.min.js +25 -0
- package/package.json +4 -4
- package/src/model/model.ts +17 -20
package/dist/model/model.d.ts
CHANGED
|
@@ -33,8 +33,8 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
|
33
33
|
attributes?: Record<string, Buffer>;
|
|
34
34
|
/** */
|
|
35
35
|
constantAttributes?: Record<string, TypedArray>;
|
|
36
|
-
/** Some applications intentionally supply unused attributes */
|
|
37
|
-
|
|
36
|
+
/** Some applications intentionally supply unused attributes and bindings, and want to disable warnings */
|
|
37
|
+
disableWarnings?: boolean;
|
|
38
38
|
/** @internal For use with {@link TransformFeedback}, WebGL only. */
|
|
39
39
|
varyings?: string[];
|
|
40
40
|
transformFeedback?: TransformFeedback;
|
|
@@ -171,7 +171,7 @@ export declare class Model {
|
|
|
171
171
|
* @note Overrides any attributes previously set with the same name
|
|
172
172
|
*/
|
|
173
173
|
setAttributes(buffers: Record<string, Buffer>, options?: {
|
|
174
|
-
|
|
174
|
+
disableWarnings?: boolean;
|
|
175
175
|
}): void;
|
|
176
176
|
/**
|
|
177
177
|
* Sets constant attributes
|
|
@@ -181,7 +181,9 @@ export declare class Model {
|
|
|
181
181
|
* is read from the context's global constant value for that attribute location.
|
|
182
182
|
* @param constantAttributes
|
|
183
183
|
*/
|
|
184
|
-
setConstantAttributes(attributes: Record<string, TypedArray
|
|
184
|
+
setConstantAttributes(attributes: Record<string, TypedArray>, options?: {
|
|
185
|
+
disableWarnings?: boolean;
|
|
186
|
+
}): void;
|
|
185
187
|
/**
|
|
186
188
|
* Sets individual uniforms
|
|
187
189
|
* @deprecated WebGL only, use uniform buffers for portability
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model/model.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,EAAE,mBAAmB,EAAE,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,KAAK,EAAC,YAAY,EAAU,WAAW,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACxF,OAAO,KAAK,EAAC,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAC,MAAM,EAAiB,MAAM,EAAgC,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAC,cAAc,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAIvE,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAC,eAAe,EAA0B,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAC,QAAQ,EAAC,gCAA6B;AACnD,OAAO,EAAC,WAAW,EAAkB,oCAAiC;AACtE,OAAO,EAAC,YAAY,EAAC,4BAAyB;AAC9C,OAAO,EAAC,eAAe,EAAC,mCAAgC;AACxD,OAAO,EAAC,aAAa,EAAC,iCAA8B;AAOpD,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAElB,uDAAuD;IACvD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,C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;IAwBvB,SAAS,CAAC,UAAU,SAAK;IACzB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAe7C,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA4BlE,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,MAAM;CAMlF;AAkBD,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAS5D"}
|
package/dist/model/model.js
CHANGED
|
@@ -45,7 +45,7 @@ export class Model {
|
|
|
45
45
|
transformFeedback: undefined,
|
|
46
46
|
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler(),
|
|
47
47
|
debugShaders: undefined,
|
|
48
|
-
|
|
48
|
+
disableWarnings: undefined
|
|
49
49
|
};
|
|
50
50
|
device;
|
|
51
51
|
id;
|
|
@@ -167,16 +167,12 @@ export class Model {
|
|
|
167
167
|
if (props.instanceCount) {
|
|
168
168
|
this.setInstanceCount(props.instanceCount);
|
|
169
169
|
}
|
|
170
|
-
// @ts-expect-error
|
|
171
|
-
if (props.indices) {
|
|
172
|
-
throw new Error('Model.props.indices removed. Use props.indexBuffer');
|
|
173
|
-
}
|
|
174
170
|
if (props.indexBuffer) {
|
|
175
171
|
this.setIndexBuffer(props.indexBuffer);
|
|
176
172
|
}
|
|
177
173
|
if (props.attributes) {
|
|
178
174
|
this.setAttributes(props.attributes, {
|
|
179
|
-
|
|
175
|
+
disableWarnings: props.disableWarnings
|
|
180
176
|
});
|
|
181
177
|
}
|
|
182
178
|
if (props.constantAttributes) {
|
|
@@ -243,7 +239,7 @@ export class Model {
|
|
|
243
239
|
this.pipeline = this._updatePipeline();
|
|
244
240
|
// Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw
|
|
245
241
|
// Any caching needs to be done inside the pipeline functions
|
|
246
|
-
this.pipeline.setBindings(this.bindings);
|
|
242
|
+
this.pipeline.setBindings(this.bindings, { disableWarnings: this.props.disableWarnings });
|
|
247
243
|
if (!isObjectEmpty(this.uniforms)) {
|
|
248
244
|
this.pipeline.setUniformsWebGL(this.uniforms);
|
|
249
245
|
}
|
|
@@ -412,7 +408,7 @@ export class Model {
|
|
|
412
408
|
set = true;
|
|
413
409
|
}
|
|
414
410
|
}
|
|
415
|
-
if (!set && (options?.
|
|
411
|
+
if (!set && !(options?.disableWarnings || this.props.disableWarnings)) {
|
|
416
412
|
log.warn(`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`)();
|
|
417
413
|
}
|
|
418
414
|
}
|
|
@@ -426,13 +422,13 @@ export class Model {
|
|
|
426
422
|
* is read from the context's global constant value for that attribute location.
|
|
427
423
|
* @param constantAttributes
|
|
428
424
|
*/
|
|
429
|
-
setConstantAttributes(attributes) {
|
|
425
|
+
setConstantAttributes(attributes, options) {
|
|
430
426
|
for (const [attributeName, value] of Object.entries(attributes)) {
|
|
431
427
|
const attributeInfo = this._attributeInfos[attributeName];
|
|
432
428
|
if (attributeInfo) {
|
|
433
429
|
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
434
430
|
}
|
|
435
|
-
else {
|
|
431
|
+
else if (!(options?.disableWarnings || this.props.disableWarnings)) {
|
|
436
432
|
log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`)();
|
|
437
433
|
}
|
|
438
434
|
}
|
|
@@ -494,9 +490,9 @@ export class Model {
|
|
|
494
490
|
}
|
|
495
491
|
// TODO - delete previous geometry?
|
|
496
492
|
this.vertexCount = gpuGeometry.vertexCount;
|
|
497
|
-
this.setIndexBuffer(gpuGeometry.indices);
|
|
498
|
-
this.setAttributes(gpuGeometry.attributes, {
|
|
499
|
-
this.setAttributes(attributes, {
|
|
493
|
+
this.setIndexBuffer(gpuGeometry.indices || null);
|
|
494
|
+
this.setAttributes(gpuGeometry.attributes, { disableWarnings: true });
|
|
495
|
+
this.setAttributes(attributes, { disableWarnings: this.props.disableWarnings });
|
|
500
496
|
this.setNeedsRedraw('geometry attributes');
|
|
501
497
|
}
|
|
502
498
|
/** Mark pipeline as needing update */
|
package/dist.min.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if (typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
|
+
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
|
+
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
+
"use strict";var __exports__=(()=>{var bn=Object.create;var ye=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var vn=Object.getOwnPropertyNames;var Rn=Object.getPrototypeOf,_n=Object.prototype.hasOwnProperty;var An=(n,e,t)=>e in n?ye(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var pt=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Tn=(n,e)=>{for(var t in e)ye(n,t,{get:e[t],enumerable:!0})},mt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vn(e))!_n.call(n,s)&&s!==t&&ye(n,s,{get:()=>e[s],enumerable:!(r=Pn(e,s))||r.enumerable});return n};var O=(n,e,t)=>(t=n!=null?bn(Rn(n)):{},mt(e||!n||!n.__esModule?ye(t,"default",{value:n,enumerable:!0}):t,n)),Sn=n=>mt(ye({},"__esModule",{value:!0}),n);var J=(n,e,t)=>(An(n,typeof e!="symbol"?e+"":e,t),t);var C=pt((_r,ft)=>{ft.exports=globalThis.luma});var oe=pt((Gr,xt)=>{xt.exports=globalThis.luma});var Mr={};Tn(Mr,{AnimationLoop:()=>ie,AnimationLoopTemplate:()=>Te,BufferTransform:()=>le,ClipSpace:()=>Ne,Computation:()=>Me,ConeGeometry:()=>Ve,CubeGeometry:()=>je,CylinderGeometry:()=>Ye,GPUGeometry:()=>ae,Geometry:()=>k,GroupNode:()=>ue,IcoSphereGeometry:()=>$e,KeyFrames:()=>Ae,Model:()=>q,ModelNode:()=>qe,PipelineFactory:()=>H,PlaneGeometry:()=>We,ScenegraphNode:()=>Q,ShaderFactory:()=>X,SphereGeometry:()=>He,TextureTransform:()=>Le,Timeline:()=>_e,TruncatedConeGeometry:()=>te,_ShaderInputs:()=>ee,makeAnimationLoop:()=>yt});var wn=1,On=1,_e=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:r=Number.POSITIVE_INFINITY,rate:s=1,repeat:i=1}=e,a=wn++,o={time:0,delay:t,duration:r,rate:s,repeat:i};return this._setChannelTime(o,this.time),this.channels.set(a,o),a}removeChannel(e){this.channels.delete(e);for(let[t,r]of this.animations)r.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let s of t)this._setChannelTime(s,this.time);let r=this.animations.values();for(let s of r){let{animation:i,channel:a}=s;i.setTime(this.getTime(a))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let r=On++;return this.animations.set(r,{animation:e,channel:t}),e.setTime(this.getTime(t)),r}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let r=t-e.delay,s=e.duration*e.repeat;r>=s?e.time=e.duration*e.rate:(e.time=Math.max(0,r)%e.duration,e.time*=e.rate)}};var Ae=class{startIndex=-1;endIndex=-1;factor=0;times=[];values=[];_lastTime=-1;constructor(e){this.setKeyFrames(e),this.setTime(0)}setKeyFrames(e){let t=e.length;this.times.length=t,this.values.length=t;for(let r=0;r<t;++r)this.times[r]=e[r][0],this.values[r]=e[r][1];this._calculateKeys(this._lastTime)}setTime(e){e=Math.max(0,e),e!==this._lastTime&&(this._calculateKeys(e),this._lastTime=e)}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(e){let t=0,r=this.times.length;for(t=0;t<r-2&&!(this.times[t+1]>e);++t);this.startIndex=t,this.endIndex=t+1;let s=this.times[this.startIndex],i=this.times[this.endIndex];this.factor=Math.min(Math.max(0,(e-s)/(i-s)),1)}};var Te=class{constructor(e){}async onInitialize(e){return null}};var ut=O(C(),1),Se=O(C(),1);function xe(){let n;if(typeof window<"u"&&window.performance)n=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();n=e[0]*1e3+e[1]/1e6}else n=Date.now();return n}var ne=class{constructor(e,t){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=e,this.type=t,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(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=xe(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(xe()-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 se=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:r}=e,s=this.stats[t];return s||(e instanceof ne?s=e:s=new ne(t,r),this.stats[t]=s),s}};var En=0,Cn={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:n=>console.error(n),stats:ut.luma.stats.get(`animation-loop-${En++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},ie=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(e){if(this.props={...Cn,...e},e=this.props,!e.device)throw new Error("No device provided");let{useDevicePixels:t=!0}=this.props;this.stats=e.stats||new se({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:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:t}),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(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}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(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),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(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=(0,Se.requestAnimationFrame)(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&((0,Se.cancelAnimationFrame)(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,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:e,height:t,aspect:r}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),r!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=r,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 e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let r=this.props.onAddHTML(t);r&&(t.innerHTML=r)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device?.canvasContext?.getPixelSize()||[1,1],r=1,s=this.device?.canvasContext?.canvas;return s&&s.clientHeight?r=s.clientWidth/s.clientHeight:e>0&&t>0&&(r=e/t),{width:e,height:t,aspect:r}}_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(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};var gt=O(C(),1);function yt(n,e){let t=null,r=e?.device||gt.luma.createDevice(),s=new ie({...e,device:r,async onInitialize(i){return t=new n(i),await t?.onInitialize(i)},onRender:i=>t?.onRender(i),onFinalize:i=>t?.onFinalize(i)});return s.getInfo=()=>this.AnimationLoopTemplateCtor.info,s}var K=O(C(),1),we=O(C(),1),L=O(C(),1),Oe=O(C(),1),Ee=O(oe(),1);var W=O(C(),1),ae=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||(0,W.uid)("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&(0,W.assert)(this.indices.usage===W.Buffer.INDEX)}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}};function Mt(n,e){if(e instanceof ae)return e;let t=Ln(n,e),{attributes:r,bufferLayout:s}=Nn(n,e);return new ae({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:t,attributes:r})}function Ln(n,e){if(!e.indices)return;let t=e.indices.value;return n.createBuffer({usage:W.Buffer.INDEX,data:t})}function Nn(n,e){let t=[],r={};for(let[i,a]of Object.entries(e.attributes)){let o=i;switch(i){case"POSITION":o="positions";break;case"NORMAL":o="normals";break;case"TEXCOORD_0":o="texCoords";break;case"COLOR_0":o="colors";break}r[o]=n.createBuffer({data:a.value,id:`${i}-buffer`});let{value:c,size:h,normalized:d}=a;t.push({name:o,format:(0,W.getVertexFormatFromAttribute)(c,h,d)})}let s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:r,bufferLayout:t,vertexCount:s}}var Ke=O(C(),1),bt=O(oe(),1),ee=class{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){let t=(0,bt._resolveModules)(Object.values(e));Ke.log.log(1,"Creating ShaderInputs with modules",t.map(r=>r.name))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[r,s]of Object.entries(e)){let i=r;this.moduleUniforms[i]=s.defaultUniforms||{},this.moduleBindings[i]={}}}destroy(){}setProps(e){for(let t of Object.keys(e)){let r=t,s=e[r],i=this.modules[r];if(!i){Ke.log.warn(`Module ${t} not found`)();continue}let a=this.moduleUniforms[r],o=i.getUniforms?.(s,this.moduleUniforms[r])||s;this.moduleUniforms[r]={...a,...o}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){let e={};for(let[t,r]of Object.entries(this.moduleUniforms))for(let[s,i]of Object.entries(r))e[`${t}.${s}`]={type:this.modules[t].uniformTypes?.[s],value:String(i)};return e}};var ce=O(C(),1);var Ze=class{device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Ze(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){let t={...ce.RenderPipeline.defaultProps,...e},r=this._hashRenderPipeline(t);if(!this._renderPipelineCache[r]){let s=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:void 0});s.hash=r,this._renderPipelineCache[r]={pipeline:s,useCount:0}}return this._renderPipelineCache[r].useCount++,this._renderPipelineCache[r].pipeline}createComputePipeline(e){let t={...ce.ComputePipeline.defaultProps,...e},r=this._hashComputePipeline(t);if(!this._computePipelineCache[r]){let s=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0});s.hash=r,this._computePipelineCache[r]={pipeline:s,useCount:0}}return this._computePipelineCache[r].useCount++,this._computePipelineCache[r].pipeline}release(e){let t=e.hash,r=e instanceof ce.ComputePipeline?this._computePipelineCache:this._renderPipelineCache;r[t].useCount--,r[t].useCount===0&&(r[t].pipeline.destroy(),delete r[t])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){let t=this._getHash(e.vs.source),r=e.fs?this._getHash(e.fs.source):0,s="-",i=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){default:let a=this._getHash(JSON.stringify(e.parameters));return`${t}/${r}V${s}T${e.topology}P${a}BL${i}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}},H=Ze;J(H,"defaultProps",{...ce.RenderPipeline.defaultProps});var Pt=O(C(),1);var Qe=class{device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new Qe(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){let t=this._hashShader(e),r=this._cache[t];if(!r){let s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=r={shader:s,useCount:0}}return r.useCount++,r.shader}release(e){let t=this._hashShader(e),r=this._cache[t];r&&(r.useCount--,r.useCount===0&&(delete this._cache[t],r.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}},X=Qe;J(X,"defaultProps",{...Pt.Shader.defaultProps});function vt(n,e){let t={},r="Values";if(n.attributes.length===0&&!n.varyings?.length)return{"No attributes or varyings":{[r]:"N/A"}};for(let s of n.attributes)if(s){let i=`${s.location} ${s.name}: ${s.type}`;t[`in ${i}`]={[r]:s.stepMode||"vertex"}}for(let s of n.varyings||[]){let i=`${s.location} ${s.name}`;t[`out ${i}`]={[r]:JSON.stringify(s.accessor)}}return t}var z=null,Je=null;function Rt(n,{id:e,minimap:t,opaque:r,top:s="0",left:i="0",rgbaScale:a=1}){z||(z=document.createElement("canvas"),z.id=e,z.title=e,z.style.zIndex="100",z.style.position="absolute",z.style.top=s,z.style.left=i,z.style.border="blue 1px solid",z.style.transform="scaleY(-1)",document.body.appendChild(z),Je=z.getContext("2d")),(z.width!==n.width||z.height!==n.height)&&(z.width=n.width/2,z.height=n.height/2,z.style.width="400px",z.style.height="400px");let o=n.device.readPixelsToArrayWebGL(n),c=Je.createImageData(n.width,n.height),h=0;for(let d=0;d<o.length;d+=4)c.data[h+d+0]=o[d+0]*a,c.data[h+d+1]=o[d+1]*a,c.data[h+d+2]=o[d+2]*a,c.data[h+d+3]=r?255:o[d+3]*a;Je.putImageData(c,0,0)}var he=2,In=1e4,et=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;vertexCount;instanceCount=0;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(e,t){this.props={...et.defaultProps,...t},t=this.props,this.id=t.id||(0,L.uid)("model"),this.device=e,Object.assign(this.userData,t.userData);let r=Object.fromEntries(this.props.modules?.map(o=>[o.name,o])||[]);this.setShaderInputs(t.shaderInputs||new ee(r));let s=zn(e),i=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=(0,Ee.getShaderLayoutFromWGSL)(this.props.source);let{source:o,getUniforms:c}=this.props.shaderAssembler.assembleShader({platformInfo:s,...this.props,modules:i});this.source=o,this._getModuleUniforms=c}else{let{vs:o,fs:c,getUniforms:h}=this.props.shaderAssembler.assembleShaderPair({platformInfo:s,...this.props,modules:i});this.vs=o,this.fs=c,this._getModuleUniforms=h}if(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,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||H.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||X.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),t.vertexCount&&this.setVertexCount(t.vertexCount),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.indices)throw new Error("Model.props.indices removed. Use props.indexBuffer");t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes,{ignoreUnknownAttributes:t.ignoreUnknownAttributes}),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.uniforms&&this.setUniforms(t.uniforms),t.moduleSettings&&(L.log.warn("Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()")(),this.updateModuleSettings(t.moduleSettings)),t.transformFeedback&&(this.transformFeedback=t.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 e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){this.predraw();let t;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),(0,L.isObjectEmpty)(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:r}=this.vertexArray,s=r?r.byteLength/(r.indexType==="uint32"?4:2):void 0;t=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:s,transformFeedback:this.transformFeedback})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),t?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",t}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&Mt(this.device,e);t&&(this.setTopology(t.topology||"triangle-list"),this.bufferLayout=_t(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)),this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?_t(e,this._gpuGeometry.bufferLayout):e,this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),this._setPipelineNeedsUpdate("bufferLayout")}setParameters(e){(0,L.deepEqual)(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setInstanceCount(e){this.instanceCount=e,this.setNeedsRedraw("instanceCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new we.UniformStore(this.shaderInputs.modules);for(let t of Object.keys(this.shaderInputs.modules)){let r=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){e.indices&&L.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[r,s]of Object.entries(e)){let i=this.bufferLayout.find(c=>At(c).includes(r));if(!i){L.log.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}let a=At(i),o=!1;for(let c of a){let h=this._attributeInfos[c];h&&(this.vertexArray.setBuffer(h.location,s),o=!0)}!o&&(t?.ignoreUnknownAttributes||this.props.ignoreUnknownAttributes)&&L.log.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e){for(let[t,r]of Object.entries(e)){let s=this._attributeInfos[t];s?this.vertexArray.setConstantWebGL(s.location,r):L.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${t}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){(0,L.isObjectEmpty)(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){L.log.warn("Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()")();let{bindings:t,uniforms:r}=(0,L.splitUniformsAndBindings)(this._getModuleUniforms(e));Object.assign(this.bindings,t),Object.assign(this.uniforms,r),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(let t of Object.values(this.bindings))t instanceof K.TextureView?e=Math.max(e,t.texture.updateTimestamp):t instanceof K.Buffer||t instanceof K.Texture?e=Math.max(e,t.updateTimestamp):t instanceof K.Sampler||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let t={...e.attributes};for(let[r]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(s=>s.name===r)&&r!=="positions"&&delete t[r];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices),this.setAttributes(e.attributes,{ignoreUnknownAttributes:!0}),this.setAttributes(t,{ignoreUnknownAttributes:this.props.ignoreUnknownAttributes}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(L.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let r=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),s=null;this.source?s=r:this.fs&&(s=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,vs:r,fs:s}),this._attributeInfos=(0,Oe.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=L.log.level>3?0:In;L.log.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,L.log.group(he,`>>> DRAWING MODEL ${this.id}`,{collapsed:L.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=vt(this.pipeline.shaderLayout,this.id);L.log.table(he,e)();let t=this.shaderInputs.getDebugTable();for(let[s,i]of Object.entries(this.uniforms))t[s]={value:i};L.log.table(he,t)();let r=this._getAttributeDebugTable();L.log.table(he,this._attributeInfos)(),L.log.table(he,r)(),L.log.groupEnd(he)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=L.log.get("framebuffer");if(this._drawCount++,!t||this._drawCount++>3&&this._drawCount%60)return;let r=e.props.framebuffer;r&&Rt(r,{id:r.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,r]of Object.entries(this._attributeInfos))e[r.location]={name:t,type:r.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[r.location],r.bufferDataType)};if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,r=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:r.toString()}}return e}_getBufferOrConstantValues(e,t){let r=(0,Oe.getTypedArrayFromDataType)(t);return(e instanceof K.Buffer?new r(e.debugData):e).toString()}},q=et;J(q,"defaultProps",{...we.RenderPipeline.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Ee.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0,ignoreUnknownAttributes:void 0});function _t(n,e){let t=[...n];for(let r of e){let s=t.findIndex(i=>i.name===r.name);s<0?t.push(r):t[s]=r}return t}function zn(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,features:n.features}}function At(n){return n.attributes?n.attributes?.map(e=>e.attribute):[n.name]}var Ce=O(C(),1),Tt=O(oe(),1);var le=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=q.defaultProps){(0,Ce.assert)(le.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new q(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||(0,Tt.getPassthroughFS)(),topology:t.topology||"point-list",...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){let t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(t instanceof Ce.Buffer)return t.readAsync();let{buffer:r,byteOffset:s=0,byteLength:i=r.byteLength}=t;return r.readAsync(s,i)}};var St=O(oe(),1),Fn="transform_output",Le=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,t){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new q(this.device,{id:t.id||"texture-transform-model",fs:t.fs||(0,St.getPassthroughFS)({input:t.targetTextureVarying,inputChannels:t.targetTextureChannels,output:Fn}),vertexCount:t.vertexCount,...t}),this._initialize(t),Object.seal(this)}destroy(){}delete(){this.destroy()}run(e){let{framebuffer:t}=this.bindings[this.currentIndex],r=this.device.beginRenderPass({framebuffer:t,...e});this.model.draw(r),r.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getData({packed:e=!1}={}){throw new Error("getData() not implemented")}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:t,sourceTextures:r,targetTexture:s}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,r),Object.assign(e.sourceBuffers,t),s){e.targetTexture=s;let{width:i,height:a}=s;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:i,height:a,colorAttachments:[s]}),e.framebuffer.resize({width:i,height:a})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:t}=this.bindings[e];for(let r in t)t[r].sampler=this.sampler}};var Ot=O(C(),1);var de=O(C(),1),k=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:t={},indices:r=null,vertexCount:s=null}=e;this.id=e.id||(0,de.uid)("geometry"),this.topology=e.topology,r&&(this.indices=ArrayBuffer.isView(r)?{value:r,size:1}:r),this.attributes={};for(let[i,a]of Object.entries(t)){let o=ArrayBuffer.isView(a)?{value:a}:a;(0,de.assert)(ArrayBuffer.isView(o.value),`${this._print(i)}: must be typed array or object with value as typed array`),(i==="POSITION"||i==="positions")&&!o.size&&(o.size=3),i==="indices"?((0,de.assert)(!this.indices),this.indices=o):this.attributes[i]=o}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let r=1/0;for(let s of Object.values(e)){let{value:i,size:a,constant:o}=s;!o&&i&&a>=1&&(r=Math.min(r,i.length/a))}return(0,de.assert)(Number.isFinite(r)),r}};var Dn=Ot.glsl`\
|
|
8
|
+
#version 300 es
|
|
9
|
+
in vec2 aClipSpacePosition;
|
|
10
|
+
in vec2 aTexCoord;
|
|
11
|
+
in vec2 aCoordinate;
|
|
12
|
+
|
|
13
|
+
out vec2 position;
|
|
14
|
+
out vec2 coordinate;
|
|
15
|
+
out vec2 uv;
|
|
16
|
+
|
|
17
|
+
void main(void) {
|
|
18
|
+
gl_Position = vec4(aClipSpacePosition, 0., 1.);
|
|
19
|
+
position = aClipSpacePosition;
|
|
20
|
+
coordinate = aCoordinate;
|
|
21
|
+
uv = aTexCoord;
|
|
22
|
+
}
|
|
23
|
+
`,wt=[-1,-1,1,-1,-1,1,1,1],Ne=class extends q{constructor(e,t){let r=wt.map(s=>s===-1?0:s);super(e,{...t,vs:Dn,vertexCount:4,geometry:new k({topology:"triangle-strip",vertexCount:4,attributes:{aClipSpacePosition:{size:2,value:new Float32Array(wt)},aTexCoord:{size:2,value:new Float32Array(r)},aCoordinate:{size:2,value:new Float32Array(r)}}})})}};var re=O(C(),1);var ws=1/Math.PI*180,Os=1/180*Math.PI,kn={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...kn}};var D=globalThis.mathgl.config;function Et(n,{precision:e=D.precision}={}){return n=Bn(n),"".concat(parseFloat(n.toPrecision(e)))}function pe(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function tt(n,e,t){let r=D.EPSILON;t&&(D.EPSILON=t);try{if(n===e)return!0;if(pe(n)&&pe(e)){if(n.length!==e.length)return!1;for(let s=0;s<n.length;++s)if(!tt(n[s],e[s]))return!1;return!0}return n&&n.equals?n.equals(e):e&&e.equals?e.equals(n):typeof n=="number"&&typeof e=="number"?Math.abs(n-e)<=D.EPSILON*Math.max(1,Math.abs(n),Math.abs(e)):!1}finally{D.EPSILON=r}}function Bn(n){return Math.round(n/D.EPSILON)*D.EPSILON}function Un(n){function e(){var t=Reflect.construct(n,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return e.prototype=Object.create(n.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,n):e.__proto__=n,e}var me=class extends Un(Array){clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:pe(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(D)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+Et(this[r],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(t,"]")}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!tt(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){if(r===void 0)return this.lerp(this,e,t);for(let s=0;s<this.ELEMENTS;++s){let i=e[s],a=typeof t=="number"?t:t[s];this[s]=i+r*(a-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(let t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=t[r];return this.check()}subtract(...e){for(let t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=t[r];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(D.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}get elements(){return this}};function Gn(n,e){if(n.length!==e)return!1;for(let t=0;t<n.length;++t)if(!Number.isFinite(n[t]))return!1;return!0}function B(n){if(!Number.isFinite(n))throw new Error("Invalid number ".concat(JSON.stringify(n)));return n}function Ie(n,e,t=""){if(D.debug&&!Gn(n,e))throw new Error("math.gl: ".concat(t," some fields set to invalid numbers'"));return n}function nt(n,e){if(!n)throw new Error("math.gl assertion ".concat(e))}var ze=class extends me{get x(){return this[0]}set x(e){this[0]=B(e)}get y(){return this[1]}set y(e){this[1]=B(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-e[r];t+=s*s}return B(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return B(t)}normalize(){let e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(let t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]*=t[r];return this.check()}divide(...e){for(let t of e)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return nt(e>=0&&e<this.ELEMENTS,"index is out of range"),B(this[e])}setComponent(e,t){return nt(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}};var Z=typeof Float32Array<"u"?Float32Array:Array;var Us=Math.PI/180;function qn(){let n=new Z(2);return Z!=Float32Array&&(n[0]=0,n[1]=0),n}function Nt(n,e,t){let r=e[0],s=e[1];return n[0]=t[0]*r+t[4]*s+t[12],n[1]=t[1]*r+t[5]*s+t[13],n}var Gs=function(){let n=qn();return function(e,t,r,s,i,a){let o,c;for(t||(t=2),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,o=r;o<c;o+=t)n[0]=e[o],n[1]=e[o+1],i(n,n,a),e[o]=n[0],e[o+1]=n[1];return e}}();function It(n,e,t){let r=e[0],s=e[1],i=t[3]*r+t[7]*s||1;return n[0]=(t[0]*r+t[4]*s)/i,n[1]=(t[1]*r+t[5]*s)/i,n}function Fe(n,e,t){let r=e[0],s=e[1],i=e[2],a=t[3]*r+t[7]*s+t[11]*i||1;return n[0]=(t[0]*r+t[4]*s+t[8]*i)/a,n[1]=(t[1]*r+t[5]*s+t[9]*i)/a,n[2]=(t[2]*r+t[6]*s+t[10]*i)/a,n}function zt(n,e,t){let r=e[0],s=e[1];return n[0]=t[0]*r+t[2]*s,n[1]=t[1]*r+t[3]*s,n[2]=e[2],n}function Vn(){let n=new Z(3);return Z!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function jn(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Ft(n,e,t){let r=e[0],s=e[1],i=e[2],a=t[0],o=t[1],c=t[2];return n[0]=s*c-i*o,n[1]=i*a-r*c,n[2]=r*o-s*a,n}function De(n,e,t){let r=e[0],s=e[1],i=e[2],a=t[3]*r+t[7]*s+t[11]*i+t[15];return a=a||1,n[0]=(t[0]*r+t[4]*s+t[8]*i+t[12])/a,n[1]=(t[1]*r+t[5]*s+t[9]*i+t[13])/a,n[2]=(t[2]*r+t[6]*s+t[10]*i+t[14])/a,n}function Dt(n,e,t){let r=e[0],s=e[1],i=e[2];return n[0]=r*t[0]+s*t[3]+i*t[6],n[1]=r*t[1]+s*t[4]+i*t[7],n[2]=r*t[2]+s*t[5]+i*t[8],n}function kt(n,e,t){let r=t[0],s=t[1],i=t[2],a=t[3],o=e[0],c=e[1],h=e[2],d=s*h-i*c,l=i*o-r*h,p=r*c-s*o,u=s*p-i*l,M=i*d-r*p,m=r*l-s*d,y=a*2;return d*=y,l*=y,p*=y,u*=2,M*=2,m*=2,n[0]=o+d+u,n[1]=c+l+M,n[2]=h+p+m,n}function Bt(n,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function Ut(n,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function Gt(n,e,t,r){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],n[0]=i[0]+t[0],n[1]=i[1]+t[1],n[2]=i[2]+t[2],n}function qt(n,e){let t=n[0],r=n[1],s=n[2],i=e[0],a=e[1],o=e[2],c=Math.sqrt((t*t+r*r+s*s)*(i*i+a*a+o*o)),h=c&&jn(n,e)/c;return Math.acos(Math.min(Math.max(h,-1),1))}var js=function(){let n=Vn();return function(e,t,r,s,i,a){let o,c;for(t||(t=3),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,o=r;o<c;o+=t)n[0]=e[o],n[1]=e[o+1],n[2]=e[o+2],i(n,n,a),e[o]=n[0],e[o+1]=n[1],e[o+2]=n[2];return e}}();var st=[0,0,0],ke,U=class extends ze{static get ZERO(){return ke||(ke=new U(0,0,0),Object.freeze(ke)),ke}constructor(e=0,t=0,r=0){super(-0,-0,-0),arguments.length===1&&pe(e)?this.copy(e):(D.debug&&(B(e),B(t),B(r)),this[0]=e,this[1]=t,this[2]=r)}set(e,t,r){return this[0]=e,this[1]=t,this[2]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return D.debug&&(B(e.x),B(e.y),B(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=B(e)}angle(e){return qt(this,e)}cross(e){return Ft(this,this,e),this.check()}rotateX({radians:e,origin:t=st}){return Bt(this,this,t,e),this.check()}rotateY({radians:e,origin:t=st}){return Ut(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=st}){return Gt(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return De(this,this,e),this.check()}transformAsVector(e){return Fe(this,this,e),this.check()}transformByMatrix3(e){return Dt(this,this,e),this.check()}transformByMatrix2(e){return zt(this,this,e),this.check()}transformByQuaternion(e){return kt(this,this,e),this.check()}};var Be=class extends me{toString(){let e="[";if(D.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=" ".concat(this[r*this.RANK+t])}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=" ".concat(this[t])}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=B(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){let r=e*this.RANK;for(let s=0;s<this.RANK;++s)t[s]=this[r+s];return t}setColumn(e,t){let r=e*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=t[s];return this}};function Yn(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Vt(n,e){if(n===e){let t=e[1],r=e[2],s=e[3],i=e[6],a=e[7],o=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=r,n[9]=i,n[11]=e[14],n[12]=s,n[13]=a,n[14]=o}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n}function jt(n,e){let t=e[0],r=e[1],s=e[2],i=e[3],a=e[4],o=e[5],c=e[6],h=e[7],d=e[8],l=e[9],p=e[10],u=e[11],M=e[12],m=e[13],y=e[14],b=e[15],v=t*o-r*a,f=t*c-s*a,g=t*h-i*a,x=r*c-s*o,P=r*h-i*o,T=s*h-i*c,E=d*m-l*M,S=d*y-p*M,N=d*b-u*M,R=l*y-p*m,A=l*b-u*m,w=p*b-u*y,_=v*w-f*A+g*R+x*N-P*S+T*E;return _?(_=1/_,n[0]=(o*w-c*A+h*R)*_,n[1]=(s*A-r*w-i*R)*_,n[2]=(m*T-y*P+b*x)*_,n[3]=(p*P-l*T-u*x)*_,n[4]=(c*N-a*w-h*S)*_,n[5]=(t*w-s*N+i*S)*_,n[6]=(y*g-M*T-b*f)*_,n[7]=(d*T-p*g+u*f)*_,n[8]=(a*A-o*N+h*E)*_,n[9]=(r*N-t*A-i*E)*_,n[10]=(M*P-m*g+b*v)*_,n[11]=(l*g-d*P-u*v)*_,n[12]=(o*S-a*R-c*E)*_,n[13]=(t*R-r*S+s*E)*_,n[14]=(m*f-M*x-y*v)*_,n[15]=(d*x-l*f+p*v)*_,n):null}function Yt(n){let e=n[0],t=n[1],r=n[2],s=n[3],i=n[4],a=n[5],o=n[6],c=n[7],h=n[8],d=n[9],l=n[10],p=n[11],u=n[12],M=n[13],m=n[14],y=n[15],b=e*a-t*i,v=e*o-r*i,f=t*o-r*a,g=h*M-d*u,x=h*m-l*u,P=d*m-l*M,T=e*P-t*x+r*g,E=i*P-a*x+o*g,S=h*f-d*v+l*b,N=u*f-M*v+m*b;return c*T-s*E+y*S-p*N}function it(n,e,t){let r=e[0],s=e[1],i=e[2],a=e[3],o=e[4],c=e[5],h=e[6],d=e[7],l=e[8],p=e[9],u=e[10],M=e[11],m=e[12],y=e[13],b=e[14],v=e[15],f=t[0],g=t[1],x=t[2],P=t[3];return n[0]=f*r+g*o+x*l+P*m,n[1]=f*s+g*c+x*p+P*y,n[2]=f*i+g*h+x*u+P*b,n[3]=f*a+g*d+x*M+P*v,f=t[4],g=t[5],x=t[6],P=t[7],n[4]=f*r+g*o+x*l+P*m,n[5]=f*s+g*c+x*p+P*y,n[6]=f*i+g*h+x*u+P*b,n[7]=f*a+g*d+x*M+P*v,f=t[8],g=t[9],x=t[10],P=t[11],n[8]=f*r+g*o+x*l+P*m,n[9]=f*s+g*c+x*p+P*y,n[10]=f*i+g*h+x*u+P*b,n[11]=f*a+g*d+x*M+P*v,f=t[12],g=t[13],x=t[14],P=t[15],n[12]=f*r+g*o+x*l+P*m,n[13]=f*s+g*c+x*p+P*y,n[14]=f*i+g*h+x*u+P*b,n[15]=f*a+g*d+x*M+P*v,n}function $t(n,e,t){let r=t[0],s=t[1],i=t[2],a,o,c,h,d,l,p,u,M,m,y,b;return e===n?(n[12]=e[0]*r+e[4]*s+e[8]*i+e[12],n[13]=e[1]*r+e[5]*s+e[9]*i+e[13],n[14]=e[2]*r+e[6]*s+e[10]*i+e[14],n[15]=e[3]*r+e[7]*s+e[11]*i+e[15]):(a=e[0],o=e[1],c=e[2],h=e[3],d=e[4],l=e[5],p=e[6],u=e[7],M=e[8],m=e[9],y=e[10],b=e[11],n[0]=a,n[1]=o,n[2]=c,n[3]=h,n[4]=d,n[5]=l,n[6]=p,n[7]=u,n[8]=M,n[9]=m,n[10]=y,n[11]=b,n[12]=a*r+d*s+M*i+e[12],n[13]=o*r+l*s+m*i+e[13],n[14]=c*r+p*s+y*i+e[14],n[15]=h*r+u*s+b*i+e[15]),n}function Wt(n,e,t){let r=t[0],s=t[1],i=t[2];return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*s,n[5]=e[5]*s,n[6]=e[6]*s,n[7]=e[7]*s,n[8]=e[8]*i,n[9]=e[9]*i,n[10]=e[10]*i,n[11]=e[11]*i,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Ht(n,e,t,r){let s=r[0],i=r[1],a=r[2],o=Math.sqrt(s*s+i*i+a*a),c,h,d,l,p,u,M,m,y,b,v,f,g,x,P,T,E,S,N,R,A,w,_,F;return o<1e-6?null:(o=1/o,s*=o,i*=o,a*=o,h=Math.sin(t),c=Math.cos(t),d=1-c,l=e[0],p=e[1],u=e[2],M=e[3],m=e[4],y=e[5],b=e[6],v=e[7],f=e[8],g=e[9],x=e[10],P=e[11],T=s*s*d+c,E=i*s*d+a*h,S=a*s*d-i*h,N=s*i*d-a*h,R=i*i*d+c,A=a*i*d+s*h,w=s*a*d+i*h,_=i*a*d-s*h,F=a*a*d+c,n[0]=l*T+m*E+f*S,n[1]=p*T+y*E+g*S,n[2]=u*T+b*E+x*S,n[3]=M*T+v*E+P*S,n[4]=l*N+m*R+f*A,n[5]=p*N+y*R+g*A,n[6]=u*N+b*R+x*A,n[7]=M*N+v*R+P*A,n[8]=l*w+m*_+f*F,n[9]=p*w+y*_+g*F,n[10]=u*w+b*_+x*F,n[11]=M*w+v*_+P*F,e!==n&&(n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n)}function Xt(n,e,t){let r=Math.sin(t),s=Math.cos(t),i=e[4],a=e[5],o=e[6],c=e[7],h=e[8],d=e[9],l=e[10],p=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=i*s+h*r,n[5]=a*s+d*r,n[6]=o*s+l*r,n[7]=c*s+p*r,n[8]=h*s-i*r,n[9]=d*s-a*r,n[10]=l*s-o*r,n[11]=p*s-c*r,n}function Kt(n,e,t){let r=Math.sin(t),s=Math.cos(t),i=e[0],a=e[1],o=e[2],c=e[3],h=e[8],d=e[9],l=e[10],p=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*s-h*r,n[1]=a*s-d*r,n[2]=o*s-l*r,n[3]=c*s-p*r,n[8]=i*r+h*s,n[9]=a*r+d*s,n[10]=o*r+l*s,n[11]=c*r+p*s,n}function Zt(n,e,t){let r=Math.sin(t),s=Math.cos(t),i=e[0],a=e[1],o=e[2],c=e[3],h=e[4],d=e[5],l=e[6],p=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=i*s+h*r,n[1]=a*s+d*r,n[2]=o*s+l*r,n[3]=c*s+p*r,n[4]=h*s-i*r,n[5]=d*s-a*r,n[6]=l*s-o*r,n[7]=p*s-c*r,n}function Qt(n,e){let t=e[0],r=e[1],s=e[2],i=e[3],a=t+t,o=r+r,c=s+s,h=t*a,d=r*a,l=r*o,p=s*a,u=s*o,M=s*c,m=i*a,y=i*o,b=i*c;return n[0]=1-l-M,n[1]=d+b,n[2]=p-y,n[3]=0,n[4]=d-b,n[5]=1-h-M,n[6]=u+m,n[7]=0,n[8]=p+y,n[9]=u-m,n[10]=1-h-l,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Jt(n,e,t,r,s,i,a){let o=1/(t-e),c=1/(s-r),h=1/(i-a);return n[0]=i*2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*c,n[6]=0,n[7]=0,n[8]=(t+e)*o,n[9]=(s+r)*c,n[10]=(a+i)*h,n[11]=-1,n[12]=0,n[13]=0,n[14]=a*i*2*h,n[15]=0,n}function $n(n,e,t,r,s){let i=1/Math.tan(e/2);if(n[0]=i/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,s!=null&&s!==1/0){let a=1/(r-s);n[10]=(s+r)*a,n[14]=2*s*r*a}else n[10]=-1,n[14]=-2*r;return n}var en=$n;function Wn(n,e,t,r,s,i,a){let o=1/(e-t),c=1/(r-s),h=1/(i-a);return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*c,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*h,n[11]=0,n[12]=(e+t)*o,n[13]=(s+r)*c,n[14]=(a+i)*h,n[15]=1,n}var tn=Wn;function nn(n,e,t,r){let s,i,a,o,c,h,d,l,p,u,M=e[0],m=e[1],y=e[2],b=r[0],v=r[1],f=r[2],g=t[0],x=t[1],P=t[2];return Math.abs(M-g)<1e-6&&Math.abs(m-x)<1e-6&&Math.abs(y-P)<1e-6?Yn(n):(l=M-g,p=m-x,u=y-P,s=1/Math.sqrt(l*l+p*p+u*u),l*=s,p*=s,u*=s,i=v*u-f*p,a=f*l-b*u,o=b*p-v*l,s=Math.sqrt(i*i+a*a+o*o),s?(s=1/s,i*=s,a*=s,o*=s):(i=0,a=0,o=0),c=p*o-u*a,h=u*i-l*o,d=l*a-p*i,s=Math.sqrt(c*c+h*h+d*d),s?(s=1/s,c*=s,h*=s,d*=s):(c=0,h=0,d=0),n[0]=i,n[1]=c,n[2]=l,n[3]=0,n[4]=a,n[5]=h,n[6]=p,n[7]=0,n[8]=o,n[9]=d,n[10]=u,n[11]=0,n[12]=-(i*M+a*m+o*y),n[13]=-(c*M+h*m+d*y),n[14]=-(l*M+p*m+u*y),n[15]=1,n)}function Hn(){let n=new Z(4);return Z!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function rn(n,e,t){let r=e[0],s=e[1],i=e[2],a=e[3];return n[0]=t[0]*r+t[4]*s+t[8]*i+t[12]*a,n[1]=t[1]*r+t[5]*s+t[9]*i+t[13]*a,n[2]=t[2]*r+t[6]*s+t[10]*i+t[14]*a,n[3]=t[3]*r+t[7]*s+t[11]*i+t[15]*a,n}var ri=function(){let n=Hn();return function(e,t,r,s,i,a){let o,c;for(t||(t=4),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,o=r;o<c;o+=t)n[0]=e[o],n[1]=e[o+1],n[2]=e[o+2],n[3]=e[o+3],i(n,n,a),e[o]=n[0],e[o+1]=n[1],e[o+2]=n[2],e[o+3]=n[3];return e}}();var ct;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(ct||(ct={}));var Xn=45*Math.PI/180,Kn=1,ot=.1,at=500,Zn=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Y=class extends Be{static get IDENTITY(){return Jn()}static get ZERO(){return Qn()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return ct}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,s,i,a,o,c,h,d,l,p,u,M,m,y){return this[0]=e,this[1]=t,this[2]=r,this[3]=s,this[4]=i,this[5]=a,this[6]=o,this[7]=c,this[8]=h,this[9]=d,this[10]=l,this[11]=p,this[12]=u,this[13]=M,this[14]=m,this[15]=y,this.check()}setRowMajor(e,t,r,s,i,a,o,c,h,d,l,p,u,M,m,y){return this[0]=e,this[1]=i,this[2]=h,this[3]=u,this[4]=t,this[5]=a,this[6]=d,this[7]=M,this[8]=r,this[9]=o,this[10]=l,this[11]=m,this[12]=s,this[13]=c,this[14]=p,this[15]=y,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Zn)}fromObject(e){return this.check()}fromQuaternion(e){return Qt(this,e),this.check()}frustum(e){let{left:t,right:r,bottom:s,top:i,near:a=ot,far:o=at}=e;return o===1/0?er(this,t,r,s,i,a):Jt(this,t,r,s,i,a,o),this.check()}lookAt(e){let{eye:t,center:r=[0,0,0],up:s=[0,1,0]}=e;return nn(this,t,r,s),this.check()}ortho(e){let{left:t,right:r,bottom:s,top:i,near:a=ot,far:o=at}=e;return tn(this,t,r,s,i,a,o),this.check()}orthographic(e){let{fovy:t=Xn,aspect:r=Kn,focalDistance:s=1,near:i=ot,far:a=at}=e;sn(t);let o=t/2,c=s*Math.tan(o),h=c*r;return this.ortho({left:-h,right:h,bottom:-c,top:c,near:i,far:a})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=e;return sn(t),en(this,t,r,s,i),this.check()}determinant(){return Yt(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let r=this.getScale(t),s=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let r=this.getScale(t),s=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*s,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*s,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return Vt(this,this),this.check()}invert(){return jt(this,this),this.check()}multiplyLeft(e){return it(this,e,this),this.check()}multiplyRight(e){return it(this,this,e),this.check()}rotateX(e){return Xt(this,this,e),this.check()}rotateY(e){return Kt(this,this,e),this.check()}rotateZ(e){return Zt(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return Ht(this,this,e,t),this.check()}scale(e){return Wt(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return $t(this,this,e),this.check()}transform(e,t){return e.length===4?(t=rn(t||[-0,-0,-0,-0],e,this),Ie(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:r}=e,s;switch(r){case 2:s=Nt(t||[-0,-0],e,this);break;case 3:s=De(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ie(s,e.length),s}transformAsVector(e,t){let r;switch(e.length){case 2:r=It(t||[-0,-0],e,this);break;case 3:r=Fe(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ie(r,e.length),r}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}},Ue,Ge;function Qn(){return Ue||(Ue=new Y([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ue)),Ue}function Jn(){return Ge||(Ge=new Y,Object.freeze(Ge)),Ge}function sn(n){if(n>Math.PI*2)throw Error("expected radians")}function er(n,e,t,r,s,i){let a=2*i/(t-e),o=2*i/(s-r),c=(t+e)/(t-e),h=(s+r)/(s-r),d=-1,l=-1,p=-2*i;return n[0]=a,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=o,n[6]=0,n[7]=0,n[8]=c,n[9]=h,n[10]=d,n[11]=l,n[12]=0,n[13]=0,n[14]=p,n[15]=0,n}var Q=class{id;matrix=new Y;display=!0;position=new U;rotation=new U;scale=new U(1,1,1);userData={};props={};constructor(e={}){let{id:t}=e;this.id=t||(0,re.uid)(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return(0,re.assert)(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return(0,re.assert)(e.length===3,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return(0,re.assert)(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:t,rotation:r,scale:s,update:i=!0}=e;return t&&this.setPosition(t),r&&this.setRotation(r),s&&this.setScale(s),i&&this.updateMatrix(),this}updateMatrix(){let e=this.position,t=this.rotation,r=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(t),this.matrix.scale(r),this}update(e={}){let{position:t,rotation:r,scale:s}=e;return t&&this.setPosition(t),r&&this.setRotation(r),s&&this.setScale(s),this.updateMatrix(),this}getCoordinateUniforms(e,t){(0,re.assert)(e),t=t||this.matrix;let r=new Y(e).multiplyRight(t),s=r.invert(),i=s.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:r,worldInverseMatrix:s,worldInverseTransposeMatrix:i}}_setScenegraphNodeProps(e){"display"in e&&(this.display=e.display),"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};var on=O(C(),1);var ue=class extends Q{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:t=[]}=e;on.log.assert(t.every(r=>r instanceof Q),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:r})=>{let s=t.getBounds();if(!s)return;let[i,a]=s,o=new U(i).add(a).divide([2,2,2]);r.transformAsPoint(o,o);let c=new U(a).subtract(i).divide([2,2,2]);r.transformAsVector(c,c);for(let h=0;h<8;h++){let d=new U(h&1?-1:1,h&2?-1:1,h&4?-1:1).multiply(c).add(o);for(let l=0;l<3;l++)e[0][l]=Math.min(e[0][l],d[l]),e[1][l]=Math.max(e[1][l],d[l])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){let t=this.children,r=t.indexOf(e);return r>-1&&t.splice(r,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new Y}={}){let r=new Y(t).multiplyRight(this.matrix);for(let s of this.children)s instanceof ue?s.traverse(e,{worldMatrix:r}):e(s,{worldMatrix:r})}};var qe=class extends Q{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}getBounds(){return this.bounds}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}draw(e){return this.model.draw(e)}};var cn=O(C(),1);var an=O(C(),1);var tr={x:[2,0,1],y:[0,1,2],z:[1,2,0]},te=class extends k{constructor(e={}){let{id:t=(0,an.uid)("truncated-code-geometry")}=e,{indices:r,attributes:s}=nr(e);super({...e,id:t,topology:"triangle-list",indices:r,attributes:{POSITION:{size:3,value:s.POSITION},NORMAL:{size:3,value:s.NORMAL},TEXCOORD_0:{size:2,value:s.TEXCOORD_0},...e.attributes}})}};function nr(n={}){let{bottomRadius:e=0,topRadius:t=0,height:r=1,nradial:s=10,nvertical:i=10,verticalAxis:a="y",topCap:o=!1,bottomCap:c=!1}=n,h=(o?2:0)+(c?2:0),d=(s+1)*(i+1+h),l=Math.atan2(e-t,r),p=Math.sin,u=Math.cos,M=Math.PI,m=u(l),y=p(l),b=o?-2:0,v=i+(c?2:0),f=s+1,g=new Uint16Array(s*(i+h)*6),x=tr[a],P=new Float32Array(d*3),T=new Float32Array(d*3),E=new Float32Array(d*2),S=0,N=0;for(let R=b;R<=v;R++){let A=R/i,w=r*A,_;R<0?(w=0,A=1,_=e):R>i?(w=r,A=1,_=t):_=e+(t-e)*(R/i),(R===-2||R===i+2)&&(_=0,A=0),w-=r/2;for(let F=0;F<f;F++){let $=p(F*M*2/s),j=u(F*M*2/s);P[S+x[0]]=$*_,P[S+x[1]]=w,P[S+x[2]]=j*_,T[S+x[0]]=R<0||R>i?0:$*m,T[S+x[1]]=R<0?-1:R>i?1:y,T[S+x[2]]=R<0||R>i?0:j*m,E[N+0]=F/s,E[N+1]=A,N+=2,S+=3}}for(let R=0;R<i+h;R++)for(let A=0;A<s;A++){let w=(R*s+A)*6;g[w+0]=f*(R+0)+0+A,g[w+1]=f*(R+0)+1+A,g[w+2]=f*(R+1)+1+A,g[w+3]=f*(R+0)+0+A,g[w+4]=f*(R+1)+1+A,g[w+5]=f*(R+1)+0+A}return{indices:g,attributes:{POSITION:P,NORMAL:T,TEXCOORD_0:E}}}var Ve=class extends te{constructor(e={}){let{id:t=(0,cn.uid)("cone-geometry"),radius:r=1,cap:s=!0}=e;super({...e,id:t,topRadius:0,topCap:Boolean(s),bottomCap:Boolean(s),bottomRadius:r})}};var hn=O(C(),1);var je=class extends k{constructor(e={}){let{id:t=(0,hn.uid)("cube-geometry"),indices:r=!0}=e;super(r?{...e,id:t,topology:"triangle-list",indices:{size:1,value:rr},attributes:{...lr,...e.attributes}}:{...e,id:t,topology:"triangle-list",indices:void 0,attributes:{...dr,...e.attributes}})}},rr=new Uint16Array([0,1,2,0,2,3,4,5,6,4,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,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]),lr={POSITION:{size:3,value:sr},NORMAL:{size:3,value:ir},TEXCOORD_0:{size:2,value:or}},dr={POSITION:{size:3,value:ar},TEXCOORD_0:{size:2,value:cr},COLOR_0:{size:3,value:hr}};var ln=O(C(),1);var Ye=class extends te{constructor(e={}){let{id:t=(0,ln.uid)("cylinder-geometry"),radius:r=1}=e;super({...e,id:t,bottomRadius:r,topRadius:r})}};var dn=O(C(),1);var pr=[-1,0,0,0,1,0,0,0,-1,0,0,1,0,-1,0,1,0,0],mr=[3,4,5,3,5,1,3,1,0,3,0,4,4,0,2,4,2,5,2,0,1,5,2,1],$e=class extends k{constructor(e={}){let{id:t=(0,dn.uid)("ico-sphere-geometry")}=e,{indices:r,attributes:s}=fr(e);super({...e,id:t,topology:"triangle-list",indices:r,attributes:{...s,...e.attributes}})}};function fr(n){let{iterations:e=0}=n,t=Math.PI,r=t*2,s=[...pr],i=[...mr];s.push(),i.push();let a=(()=>{let d={};return(l,p)=>{l*=3,p*=3;let u=l<p?l:p,M=l>p?l:p,m=`${u}|${M}`;if(m in d)return d[m];let y=s[l],b=s[l+1],v=s[l+2],f=s[p],g=s[p+1],x=s[p+2],P=(y+f)/2,T=(b+g)/2,E=(v+x)/2,S=Math.sqrt(P*P+T*T+E*E);return P/=S,T/=S,E/=S,s.push(P,T,E),d[m]=s.length/3-1}})();for(let d=0;d<e;d++){let l=[];for(let p=0;p<i.length;p+=3){let u=a(i[p+0],i[p+1]),M=a(i[p+1],i[p+2]),m=a(i[p+2],i[p+0]);l.push(m,i[p+0],u,u,i[p+1],M,M,i[p+2],m,u,M,m)}i=l}let o=new Array(s.length),c=new Array(s.length/3*2),h=i.length;for(let d=h-3;d>=0;d-=3){let l=i[d+0],p=i[d+1],u=i[d+2],M=l*3,m=p*3,y=u*3,b=l*2,v=p*2,f=u*2,g=s[M+0],x=s[M+1],P=s[M+2],T=Math.acos(P/Math.sqrt(g*g+x*x+P*P)),E=Math.atan2(x,g)+t,S=T/t,N=1-E/r,R=s[m+0],A=s[m+1],w=s[m+2],_=Math.acos(w/Math.sqrt(R*R+A*A+w*w)),F=Math.atan2(A,R)+t,$=_/t,j=1-F/r,be=s[y+0],Pe=s[y+1],ve=s[y+2],gn=Math.acos(ve/Math.sqrt(be*be+Pe*Pe+ve*ve)),yn=Math.atan2(Pe,be)+t,dt=gn/t,Re=1-yn/r,xn=[be-R,Pe-A,ve-w],Mn=[g-R,x-A,P-w],G=new U(xn).cross(Mn).normalize(),I;(N===0||j===0||Re===0)&&(N===0||N>.5)&&(j===0||j>.5)&&(Re===0||Re>.5)&&(s.push(s[M+0],s[M+1],s[M+2]),I=s.length/3-1,i.push(I),c[I*2+0]=1,c[I*2+1]=S,o[I*3+0]=G.x,o[I*3+1]=G.y,o[I*3+2]=G.z,s.push(s[m+0],s[m+1],s[m+2]),I=s.length/3-1,i.push(I),c[I*2+0]=1,c[I*2+1]=$,o[I*3+0]=G.x,o[I*3+1]=G.y,o[I*3+2]=G.z,s.push(s[y+0],s[y+1],s[y+2]),I=s.length/3-1,i.push(I),c[I*2+0]=1,c[I*2+1]=dt,o[I*3+0]=G.x,o[I*3+1]=G.y,o[I*3+2]=G.z),o[M+0]=o[m+0]=o[y+0]=G.x,o[M+1]=o[m+1]=o[y+1]=G.y,o[M+2]=o[m+2]=o[y+2]=G.z,c[b+0]=N,c[b+1]=S,c[v+0]=j,c[v+1]=$,c[f+0]=Re,c[f+1]=dt}return{indices:{size:1,value:new Uint16Array(i)},attributes:{POSITION:{size:3,value:new Float32Array(s)},NORMAL:{size:3,value:new Float32Array(o)},TEXCOORD_0:{size:2,value:new Float32Array(c)}}}}var mn=O(C(),1);function pn(n){let{indices:e,attributes:t}=n;if(!e)return n;let r=e.value.length,s={};for(let i in t){let a=t[i],{constant:o,value:c,size:h}=a;if(o||!h)continue;let d=new c.constructor(r*h);for(let l=0;l<r;++l){let p=e.value[l];for(let u=0;u<h;u++)d[l*h+u]=c[p*h+u]}s[i]={size:h,value:d}}return{attributes:Object.assign({},t,s)}}var We=class extends k{constructor(e={}){let{id:t=(0,mn.uid)("plane-geometry")}=e,{indices:r,attributes:s}=ur(e);super({...e,id:t,topology:"triangle-list",indices:r,attributes:{...s,...e.attributes}})}};function ur(n){let{type:e="x,y",offset:t=0,flipCull:r=!1,unpack:s=!1}=n,i=e.split(","),a=n[`${i[0]}len`]||1,o=n[`${i[1]}len`]||1,c=n[`n${i[0]}`]||1,h=n[`n${i[1]}`]||1,d=(c+1)*(h+1),l=new Float32Array(d*3),p=new Float32Array(d*3),u=new Float32Array(d*2);r&&(a=-a);let M=0,m=0;for(let f=0;f<=h;f++)for(let g=0;g<=c;g++){let x=g/c,P=f/h;switch(u[M+0]=r?1-x:x,u[M+1]=P,e){case"x,y":l[m+0]=a*x-a*.5,l[m+1]=o*P-o*.5,l[m+2]=t,p[m+0]=0,p[m+1]=0,p[m+2]=r?1:-1;break;case"x,z":l[m+0]=a*x-a*.5,l[m+1]=t,l[m+2]=o*P-o*.5,p[m+0]=0,p[m+1]=r?1:-1,p[m+2]=0;break;case"y,z":l[m+0]=t,l[m+1]=a*x-a*.5,l[m+2]=o*P-o*.5,p[m+0]=r?1:-1,p[m+1]=0,p[m+2]=0;break;default:throw new Error("PlaneGeometry: unknown type")}M+=2,m+=3}let y=c+1,b=new Uint16Array(c*h*6);for(let f=0;f<h;f++)for(let g=0;g<c;g++){let x=(f*c+g)*6;b[x+0]=(f+0)*y+g,b[x+1]=(f+1)*y+g,b[x+2]=(f+0)*y+g+1,b[x+3]=(f+1)*y+g,b[x+4]=(f+1)*y+g+1,b[x+5]=(f+0)*y+g+1}let v={indices:{size:1,value:b},attributes:{POSITION:{size:3,value:l},NORMAL:{size:3,value:p},TEXCOORD_0:{size:2,value:u}}};return s?pn(v):v}var fn=O(C(),1);var He=class extends k{constructor(e={}){let{id:t=(0,fn.uid)("sphere-geometry")}=e,{indices:r,attributes:s}=gr(e);super({...e,id:t,topology:"triangle-list",indices:r,attributes:{...s,...e.attributes}})}};function gr(n){let{nlat:e=10,nlong:t=10}=n,i=Math.PI-0,a=0,c=2*Math.PI-a,h=(e+1)*(t+1),d=(b,v,f,g,x)=>n.radius||1,l=new Float32Array(h*3),p=new Float32Array(h*3),u=new Float32Array(h*2),M=h>65535?Uint32Array:Uint16Array,m=new M(e*t*6);for(let b=0;b<=e;b++)for(let v=0;v<=t;v++){let f=v/t,g=b/e,x=v+b*(t+1),P=x*2,T=x*3,E=c*f,S=i*g,N=Math.sin(E),R=Math.cos(E),A=Math.sin(S),w=Math.cos(S),_=R*A,F=w,$=N*A,j=d(_,F,$,f,g);l[T+0]=j*_,l[T+1]=j*F,l[T+2]=j*$,p[T+0]=_,p[T+1]=F,p[T+2]=$,u[P+0]=f,u[P+1]=1-g}let y=t+1;for(let b=0;b<t;b++)for(let v=0;v<e;v++){let f=(b*e+v)*6;m[f+0]=v*y+b,m[f+1]=v*y+b+1,m[f+2]=(v+1)*y+b,m[f+3]=(v+1)*y+b,m[f+4]=v*y+b+1,m[f+5]=(v+1)*y+b+1}return{indices:{size:1,value:m},attributes:{POSITION:{size:3,value:l},NORMAL:{size:3,value:p},TEXCOORD_0:{size:2,value:u}}}}var ge=O(C(),1),V=O(C(),1),un=O(C(),1),Xe=O(oe(),1);var ht=2,yr=1e4,lt=class{device;id;pipelineFactory;shaderFactory;userData={};bindings={};pipeline;shader;source;shaderInputs;_uniformStore;_pipelineNeedsUpdate="newly created";_getModuleUniforms;props;_destroyed=!1;constructor(e,t){if(e.type!=="webgpu")throw new Error("Computation is only supported in WebGPU");this.props={...lt.defaultProps,...t},t=this.props,this.id=t.id||(0,V.uid)("model"),this.device=e,Object.assign(this.userData,t.userData);let r=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]);this.setShaderInputs(t.shaderInputs||new ee(r)),this.props.shaderLayout||=(0,Xe.getShaderLayoutFromWGSL)(this.props.source);let s=xr(e),i=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];this.pipelineFactory=t.pipelineFactory||H.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||X.getDefaultShaderFactory(this.device);let{source:a,getUniforms:o}=this.props.shaderAssembler.assembleShader({platformInfo:s,...this.props,modules:i});this.source=a,this._getModuleUniforms=o,this.pipeline=this._updatePipeline(),t.bindings&&this.setBindings(t.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(e,t,r,s){try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),e.setPipeline(this.pipeline),e.setBindings([]),e.dispatch(t,r,s)}finally{this._logDrawCallEnd()}}setVertexCount(e){}setInstanceCount(e){}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new ge.UniformStore(this.shaderInputs.modules);for(let t of Object.keys(this.shaderInputs.modules)){let r=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=r}}setShaderModuleProps(e){let t=this._getModuleUniforms(e),r=Object.keys(t).filter(i=>{let a=t[i];return!(0,V.isNumberArray)(a)&&typeof a!="number"&&typeof a!="boolean"}),s={};for(let i of r)s[i]=t[i],delete t[i]}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues())}setBindings(e){Object.assign(this.bindings,e)}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null;this.pipeline&&(V.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=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}),e&&this.shaderFactory.release(e)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=V.log.level>3?0:yr;V.log.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,V.log.group(ht,`>>> DRAWING MODEL ${this.id}`,{collapsed:V.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=this.shaderInputs.getDebugTable();V.log.table(ht,e)(),V.log.groupEnd(ht)(),this._logOpen=!1}}_drawCount=0;_getBufferOrConstantValues(e,t){let r=(0,un.getTypedArrayFromDataType)(t);return(e instanceof ge.Buffer?new r(e.debugData):e).toString()}},Me=lt;J(Me,"defaultProps",{...ge.ComputePipeline.defaultProps,id:"unnamed",handle:void 0,userData:{},source:"",modules:[],defines:{},bindings:void 0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,shaderAssembler:Xe.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0});function xr(n){return{type:n.type,shaderLanguage:n.info.shadingLanguage,shaderLanguageVersion:n.info.shadingLanguageVersion,gpu:n.info.gpu,features:n.features}}return Sn(Mr);})();
|
|
24
|
+
return __exports__;
|
|
25
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"description": "3D Engine Components for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"prepublishOnly": "npm run build-minified-bundle && npm run build-dev-bundle"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@luma.gl/core": "^9.0.0
|
|
43
|
+
"@luma.gl/core": "^9.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/shadertools": "9.0.
|
|
46
|
+
"@luma.gl/shadertools": "9.0.3",
|
|
47
47
|
"@math.gl/core": "^4.0.0",
|
|
48
48
|
"@probe.gl/log": "^4.0.2",
|
|
49
49
|
"@probe.gl/stats": "^4.0.2"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "543e03b2d4bd865ac86cc8927611b91cc3e0393c"
|
|
52
52
|
}
|
package/src/model/model.ts
CHANGED
|
@@ -55,8 +55,9 @@ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
|
|
|
55
55
|
attributes?: Record<string, Buffer>;
|
|
56
56
|
/** */
|
|
57
57
|
constantAttributes?: Record<string, TypedArray>;
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
|
|
59
|
+
/** Some applications intentionally supply unused attributes and bindings, and want to disable warnings */
|
|
60
|
+
disableWarnings?: boolean;
|
|
60
61
|
|
|
61
62
|
/** @internal For use with {@link TransformFeedback}, WebGL only. */
|
|
62
63
|
varyings?: string[];
|
|
@@ -109,8 +110,8 @@ export class Model {
|
|
|
109
110
|
transformFeedback: undefined,
|
|
110
111
|
shaderAssembler: ShaderAssembler.getDefaultShaderAssembler(),
|
|
111
112
|
|
|
112
|
-
debugShaders: undefined
|
|
113
|
-
|
|
113
|
+
debugShaders: undefined!,
|
|
114
|
+
disableWarnings: undefined!
|
|
114
115
|
};
|
|
115
116
|
|
|
116
117
|
readonly device: Device;
|
|
@@ -265,16 +266,12 @@ export class Model {
|
|
|
265
266
|
if (props.instanceCount) {
|
|
266
267
|
this.setInstanceCount(props.instanceCount);
|
|
267
268
|
}
|
|
268
|
-
// @ts-expect-error
|
|
269
|
-
if (props.indices) {
|
|
270
|
-
throw new Error('Model.props.indices removed. Use props.indexBuffer');
|
|
271
|
-
}
|
|
272
269
|
if (props.indexBuffer) {
|
|
273
270
|
this.setIndexBuffer(props.indexBuffer);
|
|
274
271
|
}
|
|
275
272
|
if (props.attributes) {
|
|
276
273
|
this.setAttributes(props.attributes, {
|
|
277
|
-
|
|
274
|
+
disableWarnings: props.disableWarnings
|
|
278
275
|
});
|
|
279
276
|
}
|
|
280
277
|
if (props.constantAttributes) {
|
|
@@ -350,7 +347,7 @@ export class Model {
|
|
|
350
347
|
|
|
351
348
|
// Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw
|
|
352
349
|
// Any caching needs to be done inside the pipeline functions
|
|
353
|
-
this.pipeline.setBindings(this.bindings);
|
|
350
|
+
this.pipeline.setBindings(this.bindings, {disableWarnings: this.props.disableWarnings});
|
|
354
351
|
if (!isObjectEmpty(this.uniforms)) {
|
|
355
352
|
this.pipeline.setUniformsWebGL(this.uniforms);
|
|
356
353
|
}
|
|
@@ -517,10 +514,7 @@ export class Model {
|
|
|
517
514
|
* Sets attributes (buffers)
|
|
518
515
|
* @note Overrides any attributes previously set with the same name
|
|
519
516
|
*/
|
|
520
|
-
setAttributes(
|
|
521
|
-
buffers: Record<string, Buffer>,
|
|
522
|
-
options?: {ignoreUnknownAttributes?: boolean}
|
|
523
|
-
): void {
|
|
517
|
+
setAttributes(buffers: Record<string, Buffer>, options?: {disableWarnings?: boolean}): void {
|
|
524
518
|
if (buffers.indices) {
|
|
525
519
|
log.warn(
|
|
526
520
|
`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`
|
|
@@ -545,7 +539,7 @@ export class Model {
|
|
|
545
539
|
set = true;
|
|
546
540
|
}
|
|
547
541
|
}
|
|
548
|
-
if (!set && (options?.
|
|
542
|
+
if (!set && !(options?.disableWarnings || this.props.disableWarnings)) {
|
|
549
543
|
log.warn(
|
|
550
544
|
`Model(${this.id}): Ignoring buffer "${buffer.id}" for unknown attribute "${bufferName}"`
|
|
551
545
|
)();
|
|
@@ -562,12 +556,15 @@ export class Model {
|
|
|
562
556
|
* is read from the context's global constant value for that attribute location.
|
|
563
557
|
* @param constantAttributes
|
|
564
558
|
*/
|
|
565
|
-
setConstantAttributes(
|
|
559
|
+
setConstantAttributes(
|
|
560
|
+
attributes: Record<string, TypedArray>,
|
|
561
|
+
options?: {disableWarnings?: boolean}
|
|
562
|
+
): void {
|
|
566
563
|
for (const [attributeName, value] of Object.entries(attributes)) {
|
|
567
564
|
const attributeInfo = this._attributeInfos[attributeName];
|
|
568
565
|
if (attributeInfo) {
|
|
569
566
|
this.vertexArray.setConstantWebGL(attributeInfo.location, value);
|
|
570
|
-
} else {
|
|
567
|
+
} else if (!(options?.disableWarnings || this.props.disableWarnings)) {
|
|
571
568
|
log.warn(
|
|
572
569
|
`Model "${this.id}: Ignoring constant supplied for unknown attribute "${attributeName}"`
|
|
573
570
|
)();
|
|
@@ -638,9 +635,9 @@ export class Model {
|
|
|
638
635
|
|
|
639
636
|
// TODO - delete previous geometry?
|
|
640
637
|
this.vertexCount = gpuGeometry.vertexCount;
|
|
641
|
-
this.setIndexBuffer(gpuGeometry.indices);
|
|
642
|
-
this.setAttributes(gpuGeometry.attributes, {
|
|
643
|
-
this.setAttributes(attributes, {
|
|
638
|
+
this.setIndexBuffer(gpuGeometry.indices || null);
|
|
639
|
+
this.setAttributes(gpuGeometry.attributes, {disableWarnings: true});
|
|
640
|
+
this.setAttributes(attributes, {disableWarnings: this.props.disableWarnings});
|
|
644
641
|
|
|
645
642
|
this.setNeedsRedraw('geometry attributes');
|
|
646
643
|
}
|