@luma.gl/engine 9.2.0-alpha.3 → 9.2.0-alpha.5

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.
@@ -118,7 +118,7 @@ export declare class AsyncTexture {
118
118
  /** Check if texture data is a typed array */
119
119
  isTextureLevelData(data: TextureData): data is TextureImageData;
120
120
  /** Get the size of the texture described by the provided TextureData */
121
- getTextureDataSize(data: TextureData | TextureCubeData | TextureArrayData | TextureCubeArrayData | TypedArray): {
121
+ getTextureDataSize(data: TextureData | TextureCubeData | TextureArrayData | TextureCubeArrayData | TypedArray | null): {
122
122
  width: number;
123
123
  height: number;
124
124
  } | null;
@@ -1 +1 @@
1
- {"version":3,"file":"async-texture.d.ts","sourceRoot":"","sources":["../../src/async-texture/async-texture.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,MAAM,EACN,UAAU,EACV,aAAa,EACb,aAAa,EACd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,OAAO,EAAE,OAAO,EAAM,MAAM,eAAe,CAAC;AAKpD,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;CAA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AE,aAAa,GAAG,IAAI;IAI9D,4CAA4C;IAC5C,iBAAiB,CAAC,OAAO,EAAE,aAAa,EAAE,KAAK,SAAI,GAAG,IAAI;IAuB1D;;;OAGG;IACH,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;IAS9D;;;;;OAKG;IACH,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,GAAG,IAAI;IAUlE;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,GAAG,IAAI;IASpE;;;OAGG;IACH,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAI5E,mBAAmB;IACnB,uBAAuB,CACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,eAAe,EACrB,KAAK,GAAE,MAAU,GAChB,IAAI;IAaP;;;;;OAKG;IACH,qBAAqB,CAAC,IAAI,EAAE,aAAa,GAAG,CAAC,gBAAgB,GAAG,aAAa,CAAC,EAAE;IAqBhF,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAI9C;CACH"}
@@ -60,10 +60,9 @@ export class AsyncTexture {
60
60
  this.initAsync(props);
61
61
  }
62
62
  async initAsync(props) {
63
- let resolveReady;
64
- let rejectReady;
65
63
  const asyncData = props.data;
66
- const data = await awaitAllPromises(asyncData).then(resolveReady, rejectReady);
64
+ // @ts-expect-error not clear how to convince TS that null will be returned
65
+ const data = await awaitAllPromises(asyncData).then(undefined, this.rejectReady);
67
66
  // Check that we haven't been destroyed while waiting for texture data to load
68
67
  if (this.destroyed) {
69
68
  return;
@@ -85,7 +84,6 @@ export class AsyncTexture {
85
84
  this.texture = this.device.createTexture(syncProps);
86
85
  this.sampler = this.texture.sampler;
87
86
  this.view = this.texture.view;
88
- this.isReady = true;
89
87
  if (props.data) {
90
88
  switch (this.props.dimension) {
91
89
  case '1d':
@@ -113,6 +111,7 @@ export class AsyncTexture {
113
111
  this.generateMipmaps();
114
112
  }
115
113
  log.info(1, `${this} loaded`);
114
+ this.resolveReady();
116
115
  }
117
116
  destroy() {
118
117
  if (this.texture) {
@@ -1 +1 @@
1
- {"version":3,"file":"async-texture.js","sourceRoot":"","sources":["../../src/async-texture/async-texture.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,oCAAoC;AAYpC,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAC,eAAe,EAAC,0CAAuC;AAC/D,OAAO,EAAC,GAAG,EAAC,wBAAqB;AA8BjC,MAAM,CAAC,MAAM,gBAAgB,GAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACxF,kBAAkB;AAClB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAC,CAAC;AA8CzF,MAAM,CAAC,MAAM,SAAS,GAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAejF;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACd,MAAM,CAAS;IACf,EAAE,CAAS;IACpB,KAAK,CAA4C;IAEjD,6EAA6E;IAC7E,mBAAmB;IACnB,OAAO,CAAU;IACjB,mBAAmB;IACnB,OAAO,CAAU;IACjB,mBAAmB;IACnB,IAAI,CAAc;IAET,KAAK,CAAgB;IAC9B,OAAO,GAAY,KAAK,CAAC;IACzB,SAAS,GAAY,KAAK,CAAC;IAEjB,YAAY,GAAe,GAAG,EAAE,GAAE,CAAC,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,GAAgC;QACjD,GAAG,OAAO,CAAC,YAAY;QACvB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,KAAK;KACf,CAAC;;AAGJ,kDAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDE;AAEF,UAAU;AAEV,sDAAsD;AACtD,KAAK,UAAU,gBAAgB,CAAC,CAAM;IACpC,CAAC,GAAG,MAAM,CAAC,CAAC;IACZ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3D,MAAM,MAAM,GAAwB,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,MAAM,cAAc,GAAwB,EAAE,CAAC;QAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
package/dist/dist.dev.js CHANGED
@@ -1627,10 +1627,11 @@ var __exports__ = (() => {
1627
1627
  this.initAsync(props);
1628
1628
  }
1629
1629
  async initAsync(props) {
1630
- let resolveReady;
1631
- let rejectReady;
1632
1630
  const asyncData = props.data;
1633
- const data = await awaitAllPromises(asyncData).then(resolveReady, rejectReady);
1631
+ const data = await awaitAllPromises(asyncData).then(
1632
+ void 0,
1633
+ this.rejectReady
1634
+ );
1634
1635
  if (this.destroyed) {
1635
1636
  return;
1636
1637
  }
@@ -1644,7 +1645,6 @@ var __exports__ = (() => {
1644
1645
  this.texture = this.device.createTexture(syncProps);
1645
1646
  this.sampler = this.texture.sampler;
1646
1647
  this.view = this.texture.view;
1647
- this.isReady = true;
1648
1648
  if (props.data) {
1649
1649
  switch (this.props.dimension) {
1650
1650
  case "1d":
@@ -1671,6 +1671,7 @@ var __exports__ = (() => {
1671
1671
  this.generateMipmaps();
1672
1672
  }
1673
1673
  import_core8.log.info(1, `${this} loaded`);
1674
+ this.resolveReady();
1674
1675
  }
1675
1676
  destroy() {
1676
1677
  if (this.texture) {
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 qi=Object.create;var wt=Object.defineProperty;var Wi=Object.getOwnPropertyDescriptor;var Yi=Object.getOwnPropertyNames;var Xi=Object.getPrototypeOf,Hi=Object.prototype.hasOwnProperty;var Ki=(i,t,e)=>t in i?wt(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var De=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),Zi=(i,t)=>{for(var e in t)wt(i,e,{get:t[e],enumerable:!0})},Nt=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Yi(t))!Hi.call(i,n)&&n!==e&&wt(i,n,{get:()=>t[n],enumerable:!(s=Wi(t,n))||s.enumerable});return i},Ft=(i,t,e)=>(Nt(i,t,"default"),e&&Nt(e,t,"default")),k=(i,t,e)=>(e=i!=null?qi(Xi(i)):{},Nt(t||!i||!i.__esModule?wt(e,"default",{value:i,enumerable:!0}):e,i)),Qi=i=>Nt(wt({},"__esModule",{value:!0}),i);var z=(i,t,e)=>(Ki(i,typeof t!="symbol"?t+"":t,e),e);var j=De((pn,ze)=>{ze.exports=globalThis.luma});var ht=De((kn,je)=>{je.exports=globalThis.luma});var Et={};Zi(Et,{AnimationLoop:()=>ct,AnimationLoopTemplate:()=>Bt,AsyncTexture:()=>tt,BackgroundTextureModel:()=>ft,BufferTransform:()=>It,ClipSpace:()=>et,Computation:()=>Ct,ConeGeometry:()=>se,CubeGeometry:()=>ne,CylinderGeometry:()=>re,GPUGeometry:()=>pt,Geometry:()=>B,GroupNode:()=>bt,IcoSphereGeometry:()=>oe,KeyFrames:()=>zt,LegacyPickingManager:()=>pe,Model:()=>W,ModelNode:()=>ie,PickingManager:()=>Pt,PipelineFactory:()=>Q,PlaneGeometry:()=>ae,ScenegraphNode:()=>st,ShaderFactory:()=>J,ShaderInputs:()=>H,ShaderPassRenderer:()=>le,SphereGeometry:()=>ce,Swap:()=>Mt,SwapBuffers:()=>he,SwapFramebuffers:()=>vt,TextureTransform:()=>Yt,Timeline:()=>Dt,TruncatedConeGeometry:()=>ot,cancelAnimationFramePolyfill:()=>Ut,colorPicking:()=>$i,indexPicking:()=>Bi,loadImage:()=>Je,loadImageBitmap:()=>Gt,makeAnimationLoop:()=>Ue,makeRandomGenerator:()=>Fi,requestAnimationFramePolyfill:()=>$t,setPathPrefix:()=>Qe});Ft(Et,k(j(),1));var Ji=1,ts=1,Dt=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(t){let{delay:e=0,duration:s=Number.POSITIVE_INFINITY,rate:n=1,repeat:r=1}=t,o=Ji++,a={time:0,delay:e,duration:s,rate:n,repeat:r};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(t){this.channels.delete(t);for(let[e,s]of this.animations)s.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 n of e)this._setChannelTime(n,this.time);let s=this.animations.values();for(let n of s){let{animation:r,channel:o}=n;r.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(t,e){let s=ts++;return this.animations.set(s,{animation:t,channel:e}),t.setTime(this.getTime(e)),s}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 s=e-t.delay,n=t.duration*t.repeat;s>=n?t.time=t.duration*t.rate:(t.time=Math.max(0,s)%t.duration,t.time*=t.rate)}};var zt=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 s=0;s<e;++s)this.times[s]=t[s][0],this.values[s]=t[s][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,s=this.times.length;for(e=0;e<s-2&&!(this.times[e+1]>t);++e);this.startIndex=e,this.endIndex=e+1;let n=this.times[this.startIndex],r=this.times[this.endIndex];this.factor=Math.min(Math.max(0,(t-n)/(r-n)),1)}};var Bt=class{constructor(t){}async onInitialize(t){return null}};var Be=k(j(),1);function $t(i){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(i):setTimeout(i,1e3/60)}function Ut(i){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(i):clearTimeout(i)}function At(){let i;if(typeof window<"u"&&window.performance)i=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();i=t[0]*1e3+t[1]/1e6}else i=Date.now();return i}var at=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=At(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(At()-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 ut=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:s}=t,n=this.stats[e];return n||(t instanceof at?n=t:n=new at(e,s),this.stats[e]=n),n}};var es=0,me=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;_error=null;constructor(t){if(this.props={...me.defaultAnimationLoopProps,...t},t=this.props,!t.device)throw new Error("No device provided");this.stats=t.stats||new ut({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}),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()}reportError(t){this.props.onError(t),this._error=t}setNeedsRedraw(t){return this.needsRedraw=this.needsRedraw||t,this}setProps(t){return"autoResizeViewport"in t&&(this.props.autoResizeViewport=t.autoResizeViewport||!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._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||this._error?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._resizeViewport()}_setDisplay(t){this.display&&(this.display.destroy(),this.display.animationLoop=null),t&&(t.animationLoop=this),this.display=t}_requestAnimationFrame(){this._running&&(this._animationFrameId=$t(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Ut(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._resizeViewport()}_initializeAnimationProps(){let t=this.device?.getDefaultCanvasContext();if(!this.device||!t)throw new Error("loop");let e=t?.canvas,s=t.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:t,canvas:e,useDevicePixels:s,timeline:this.timeline,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:s}=this._getSizeAndAspect();(t!==this.animationProps.width||e!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),s!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=e,this.animationProps.aspect=s,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.getDefaultCanvasContext().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 s=this.props.onAddHTML(e);s&&(e.innerHTML=s)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[t,e]=this.device?.getDefaultCanvasContext().getDevicePixelSize()||[1,1],s=1,n=this.device?.getDefaultCanvasContext().canvas;return n&&n.clientHeight?s=n.clientWidth/n.clientHeight:t>0&&e>0&&(s=t/e),{width:t,height:e,aspect:s}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_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}},ct=me;z(ct,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:Be.luma.stats.get(`animation-loop-${es++}`),autoResizeViewport:!1});var $e=k(j(),1);function Ue(i,t){let e=null,s=t?.device||$e.luma.createDevice({id:"animation-loop",adapters:t?.adapters,createCanvasContext:!0}),n=new ct({...t,device:s,async onInitialize(r){ss(r.animationLoop.device);try{return e=new i(r),await e?.onInitialize(r)}catch(o){return is(r.animationLoop.device,o),null}},onRender:r=>e?.onRender(r),onFinalize:r=>e?.onFinalize(r)});return n.getInfo=()=>this.AnimationLoopTemplateCtor.info,n}function is(i,t){let e=i?.getDefaultCanvasContext().canvas;if(e instanceof HTMLCanvasElement){e.style.overflow="visible";let s=document.getElementById("animation-loop-error");s?.remove(),s=document.createElement("h1"),s.id="animation-loop-error",s.innerHTML=t.message,s.style.position="absolute",s.style.top="10px",s.style.left="10px",s.style.color="black",s.style.backgroundColor="red",e.parentElement?.appendChild(s)}}function ss(i){let t=document.getElementById("animation-loop-error");t&&t.remove()}var S=k(j(),1),qt=k(ht(),1);var Tt=k(j(),1);var ge={};function C(i="id"){ge[i]=ge[i]||1;let t=ge[i]++;return`${i}-${t}`}var pt=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&Tt.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 Ve(i,t){if(t instanceof pt)return t;let e=ns(i,t),{attributes:s,bufferLayout:n}=rs(i,t);return new pt({topology:t.topology||"triangle-list",bufferLayout:n,vertexCount:t.vertexCount,indices:e,attributes:s})}function ns(i,t){if(!t.indices)return;let e=t.indices.value;return i.createBuffer({usage:Tt.Buffer.INDEX,data:e})}function rs(i,t){let e=[],s={};for(let[r,o]of Object.entries(t.attributes)){let a=r;switch(r){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){s[a]=i.createBuffer({data:o.value,id:`${r}-buffer`});let{value:c,size:l,normalized:h}=o;e.push({name:a,format:(0,Tt.getVertexFormatFromAttribute)(c,l,h)})}}let n=t._calculateVertexCount(t.attributes,t.indices);return{attributes:s,bufferLayout:e,vertexCount:n}}var V=k(j(),1);var xe=class{static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new xe(t),t._lumaData.defaultPipelineFactory}device;cachingEnabled;destroyPolicy;debug;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(t){this.device=t,this.cachingEnabled=t.props._cachePipelines,this.destroyPolicy=t.props._cacheDestroyPolicy,this.debug=t.props.debugFactories}createRenderPipeline(t){if(!this.cachingEnabled)return this.device.createRenderPipeline(t);let e={...V.RenderPipeline.defaultProps,...t},s=this._renderPipelineCache,n=this._hashRenderPipeline(e),r=s[n]?.pipeline;return r?(s[n].useCount++,this.debug&&V.log.warn(`${this}: ${s[n].pipeline} reused, count=${s[n].useCount}, (id=${t.id})`)()):(r=this.device.createRenderPipeline({...e,id:e.id?`${e.id}-cached`:C("unnamed-cached")}),r.hash=n,s[n]={pipeline:r,useCount:1},this.debug&&V.log.warn(`${this}: ${r} created, count=${s[n].useCount}`)()),r}createComputePipeline(t){if(!this.cachingEnabled)return this.device.createComputePipeline(t);let e={...V.ComputePipeline.defaultProps,...t},s=this._computePipelineCache,n=this._hashComputePipeline(e),r=s[n]?.pipeline;return r?(s[n].useCount++,this.debug&&V.log.warn(`${this}: ${s[n].pipeline} reused, count=${s[n].useCount}, (id=${t.id})`)()):(r=this.device.createComputePipeline({...e,id:e.id?`${e.id}-cached`:void 0}),r.hash=n,s[n]={pipeline:r,useCount:1},this.debug&&V.log.warn(`${this}: ${r} created, count=${s[n].useCount}`)()),r}release(t){if(!this.cachingEnabled){t.destroy();return}let e=this._getCache(t),s=t.hash;e[s].useCount--,e[s].useCount===0?(this._destroyPipeline(t),this.debug&&V.log.warn(`${this}: ${t} released and destroyed`)()):e[s].useCount<0?(V.log.error(`${this}: ${t} released, useCount < 0, resetting`)(),e[s].useCount=0):this.debug&&V.log.warn(`${this}: ${t} released, count=${e[s].useCount}`)()}_destroyPipeline(t){let e=this._getCache(t);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete e[t.hash],t.destroy(),!0}}_getCache(t){let e;if(t instanceof V.ComputePipeline&&(e=this._computePipelineCache),t instanceof V.RenderPipeline&&(e=this._renderPipelineCache),!e)throw new Error(`${this}`);if(!e[t.hash])throw new Error(`${this}: ${t} matched incorrect entry`);return e}_hashComputePipeline(t){let{type:e}=this.device,s=this._getHash(t.shader.source);return`${e}/C/${s}`}_hashRenderPipeline(t){let e=t.vs?this._getHash(t.vs.source):0,s=t.fs?this._getHash(t.fs.source):0,n="-",r=this._getHash(JSON.stringify(t.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${e}/${s}V${n}BL${r}`;case"webgpu":default:let a=this._getHash(JSON.stringify(t.parameters));return`${o}/R/${e}/${s}V${n}T${t.topology}P${a}BL${r}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}},Q=xe;z(Q,"defaultProps",{...V.RenderPipeline.defaultProps});var lt=k(j(),1);var ye=class{static getDefaultShaderFactory(t){return t._lumaData.defaultShaderFactory||=new ye(t),t._lumaData.defaultShaderFactory}device;cachingEnabled;destroyPolicy;debug;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(t){this.device=t,this.cachingEnabled=t.props._cacheShaders,this.destroyPolicy=t.props._cacheDestroyPolicy,this.debug=!0}createShader(t){if(!this.cachingEnabled)return this.device.createShader(t);let e=this._hashShader(t),s=this._cache[e];if(s)s.useCount++,this.debug&&lt.log.warn(`${this}: Reusing shader ${s.shader.id} count=${s.useCount}`)();else{let n=this.device.createShader({...t,id:t.id?`${t.id}-cached`:void 0});this._cache[e]=s={shader:n,useCount:1},this.debug&&lt.log.warn(`${this}: Created new shader ${n.id}`)()}return s.shader}release(t){if(!this.cachingEnabled){t.destroy();return}let e=this._hashShader(t),s=this._cache[e];if(s)if(s.useCount--,s.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[e],s.shader.destroy(),this.debug&&lt.log.warn(`${this}: Releasing shader ${t.id}, destroyed`)());else{if(s.useCount<0)throw new Error(`ShaderFactory: Shader ${t.id} released too many times`);this.debug&&lt.log.warn(`${this}: Releasing shader ${t.id} count=${s.useCount}`)()}}_hashShader(t){return`${t.stage}:${t.source}`}},J=ye;z(J,"defaultProps",{...lt.Shader.defaultProps});function Ge(i,t){let e={},s="Values";if(i.attributes.length===0&&!i.varyings?.length)return{"No attributes or varyings":{[s]:"N/A"}};for(let n of i.attributes)if(n){let r=`${n.location} ${n.name}: ${n.type}`;e[`in ${r}`]={[s]:n.stepMode||"vertex"}}for(let n of i.varyings||[]){let r=`${n.location} ${n.name}`;e[`out ${r}`]={[s]:JSON.stringify(n)}}return e}var N=null,be=null;function qe(i,{id:t,minimap:e,opaque:s,top:n="0",left:r="0",rgbaScale:o=1}){N||(N=document.createElement("canvas"),N.id=t,N.title=t,N.style.zIndex="100",N.style.position="absolute",N.style.top=n,N.style.left=r,N.style.border="blue 5px solid",N.style.transform="scaleY(-1)",document.body.appendChild(N),be=N.getContext("2d")),(N.width!==i.width||N.height!==i.height)&&(N.width=i.width/2,N.height=i.height/2,N.style.width="400px",N.style.height="400px");let a=i.device.readPixelsToArrayWebGL(i),c=be?.createImageData(i.width,i.height);if(c){for(let h=0;h<a.length;h+=4)c.data[0+h+0]=a[h+0]*o,c.data[0+h+1]=a[h+1]*o,c.data[0+h+2]=a[h+2]*o,c.data[0+h+3]=s?255:a[h+3]*o;be?.putImageData(c,0,0)}}function jt(i,t,e){if(i===t)return!0;if(!e||!i||!t)return!1;if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(let s=0;s<i.length;s++)if(!jt(i[s],t[s],e-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof i=="object"&&typeof t=="object"){let s=Object.keys(i),n=Object.keys(t);if(s.length!==n.length)return!1;for(let r of s)if(!t.hasOwnProperty(r)||!jt(i[r],t[r],e-1))return!1;return!0}return!1}var We=k(j(),1),mt=class{bufferLayouts;constructor(t){this.bufferLayouts=t}getBufferLayout(t){return this.bufferLayouts.find(e=>e.name===t)||null}getAttributeNamesForBuffer(t){return t.attributes?t.attributes?.map(e=>e.attribute):[t.name]}mergeBufferLayouts(t,e){let s=[...t];for(let n of e){let r=s.findIndex(o=>o.name===n.name);r<0?s.push(n):s[r]=n}return s}getBufferIndex(t){let e=this.bufferLayouts.findIndex(s=>s.name===t);return e===-1&&We.log.warn(`BufferLayout: Missing buffer for "${t}".`)(),e}};function Ye(i,t){let e=Object.fromEntries(i.attributes.map(n=>[n.name,n.location])),s=t.slice();return s.sort((n,r)=>{let o=n.attributes?n.attributes.map(h=>h.attribute):[n.name],a=r.attributes?r.attributes.map(h=>h.attribute):[r.name],c=Math.min(...o.map(h=>e[h])),l=Math.min(...a.map(h=>e[h]));return c-l}),s}var Vt=k(j(),1),Ze=k(ht(),1);function Xe(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function He(i){return Array.isArray(i)?i.length===0||typeof i[0]=="number":!1}function St(i){return Xe(i)||He(i)}function os(i){return St(i)||typeof i=="number"||typeof i=="boolean"}function Ke(i){let t={bindings:{},uniforms:{}};return Object.keys(i).forEach(e=>{let s=i[e];os(s)?t.uniforms[e]=s:t.bindings[e]=s}),t}var H=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(t,e){Object.assign(this.options,e);let s=(0,Ze.getShaderModuleDependencies)(Object.values(t).filter(n=>n.dependencies));for(let n of s)t[n.name]=n;Vt.log.log(1,"Creating ShaderInputs with modules",Object.keys(t))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(let[n,r]of Object.entries(t))this._addModule(r),r.name&&n!==r.name&&!this.options.disableWarnings&&Vt.log.warn(`Module name: ${n} vs ${r.name}`)()}destroy(){}setProps(t){for(let e of Object.keys(t)){let s=e,n=t[s]||{},r=this.modules[s];if(!r){this.options.disableWarnings||Vt.log.warn(`Module ${e} not found`)();continue}let o=this.moduleUniforms[s],a=this.moduleBindings[s],c=r.getUniforms?.(n,o)||n,{uniforms:l,bindings:h}=Ke(c);this.moduleUniforms[s]={...o,...l},this.moduleBindings[s]={...a,...h}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let t={};for(let e of Object.values(this.moduleBindings))Object.assign(t,e);return t}getDebugTable(){let t={};for(let[e,s]of Object.entries(this.moduleUniforms))for(let[n,r]of Object.entries(s))t[`${e}.${n}`]={type:this.modules[e].uniformTypes?.[n],value:String(r)};return t}_addModule(t){let e=t.name;this.moduleUniforms[e]=t.defaultUniforms||{},this.moduleBindings[e]={}}};var rt=k(j(),1);var Me="";function Qe(i){Me=i}async function Gt(i,t){let e=new Image;return e.crossOrigin=t?.crossOrigin||"anonymous",e.src=i.startsWith("http")?i:Me+i,await e.decode(),t?await createImageBitmap(e,t):await createImageBitmap(e)}async function Je(i,t){return await new Promise((e,s)=>{try{let n=new Image;n.onload=()=>e(n),n.onerror=()=>s(new Error(`Could not load image ${i}.`)),n.crossOrigin=t?.crossOrigin||"anonymous",n.src=i.startsWith("http")?i:Me+i}catch(n){s(n)}})}var as=["+X","-X","+Y","-Y","+Z","-Z"];var cs=["+X","-X","+Y","-Y","+Z","-Z"],ve=class{device;id;props;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}constructor(t,e){this.device=t;let s=C("async-texture");this.props={...ve.defaultProps,id:s,...e},this.id=this.props.id,e={...e},typeof e?.data=="string"&&e.dimension==="2d"&&(e.data=Gt(e.data)),e.mipmaps&&(e.mipLevels="auto"),this.ready=new Promise((n,r)=>{this.resolveReady=()=>{this.isReady=!0,n()},this.rejectReady=r}),this.initAsync(e)}async initAsync(t){let e,s,n=t.data,r=await ti(n).then(e,s);if(this.destroyed)return;let o=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(r);if(!o)throw new Error("Texture size could not be determined");let a={...o,...t,data:void 0,mipLevels:1},c=this.device.getMipLevelCount(a.width,a.height);if(a.mipLevels=this.props.mipLevels==="auto"?c:Math.min(c,this.props.mipLevels),this.texture=this.device.createTexture(a),this.sampler=this.texture.sampler,this.view=this.texture.view,this.isReady=!0,t.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,r);break;case"2d":this._setTexture2DData(r);break;case"3d":this._setTexture3DData(this.texture,r);break;case"2d-array":this._setTextureArrayData(this.texture,r);break;case"cube":this._setTextureCubeData(this.texture,r);break;case"cube-array":this._setTextureCubeArrayData(this.texture,r);break}this.props.mipmaps&&this.generateMipmaps(),rt.log.info(1,`${this} loaded`)}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}generateMipmaps(){this.texture.generateMipmapsWebGL()}setSampler(t={}){this.texture.setSampler(t instanceof rt.Sampler?t:this.device.createSampler(t))}resize(t){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(t.width===this.texture.width&&t.height===this.texture.height)return!1;if(this.texture){let e=this.texture;this.texture=e.clone(t),e.destroy()}return!0}isTextureLevelData(t){let e=t?.data;return ArrayBuffer.isView(e)}getTextureDataSize(t){if(!t||ArrayBuffer.isView(t))return null;if(Array.isArray(t))return this.getTextureDataSize(t[0]);if(this.device.isExternalImage(t))return this.device.getExternalImageSize(t);if(t&&typeof t=="object"&&t.constructor===Object){let s=Object.values(t)[0];return{width:s.width,height:s.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(t){switch(t){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(t)}}setTextureData(t){}_setTexture1DData(t,e){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(t,e=0){if(!this.texture)throw new Error("Texture not initialized");let s=this._normalizeTextureData(t);s.length>1&&this.props.mipmaps!==!1&&rt.log.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let n=0;n<s.length;n++){let r=s[n];this.device.isExternalImage(r)?this.texture.copyExternalImage({image:r,depth:e,mipLevel:n,flipY:!0}):this.texture.copyImageData({data:r.data,mipLevel:n})}}_setTexture3DData(t,e){if(this.texture?.props.dimension!=="3d")throw new Error(this.id);for(let s=0;s<e.length;s++)this._setTexture2DData(e[s],s)}_setTextureCubeData(t,e){if(this.texture?.props.dimension!=="cube")throw new Error(this.id);for(let[s,n]of Object.entries(e)){let r=cs.indexOf(s);this._setTexture2DData(n,r)}}_setTextureArrayData(t,e){if(this.texture?.props.dimension!=="2d-array")throw new Error(this.id);for(let s=0;s<e.length;s++)this._setTexture2DData(e[s],s)}_setTextureCubeArrayData(t,e){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(t,e,s,n=0){Array.isArray(e)&&e.length>1&&this.props.mipmaps!==!1&&rt.log.warn(`${this.id} has mipmap and multiple LODs.`)();let r=as.indexOf(s);this._setTexture2DData(e,r)}_normalizeTextureData(t){let e=this.texture,s;return ArrayBuffer.isView(t)?s=[{data:t,width:e.width,height:e.height}]:Array.isArray(t)?s=t:s=[t],s}},tt=ve;z(tt,"defaultProps",{...rt.Texture.defaultProps,data:null,mipmaps:!1});async function ti(i){if(i=await i,Array.isArray(i))return await Promise.all(i.map(ti));if(i&&typeof i=="object"&&i.constructor===Object){let t=i,e=await Promise.all(Object.values(t)),s=Object.keys(t),n={};for(let r=0;r<s.length;r++)n[s[r]]=e[r];return n}return i}var dt=2,hs=1e4,_e=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(t,e){this.props={..._e.defaultProps,...e},e=this.props,this.id=e.id||C("model"),this.device=t,Object.assign(this.userData,e.userData);let s=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),n=e.shaderInputs||new H(s,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(n);let r=ds(t),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:r,...this.props,modules:o});this.source=c,this._getModuleUniforms=l,this.props.shaderLayout||=(0,qt.getShaderLayoutFromWGSL)(this.source)}else{let{vs:c,fs:l,getUniforms:h}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:r,...this.props,modules:o});this.vs=c,this.fs=l,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||Q.getDefaultPipelineFactory(this.device),this.shaderFactory=e.shaderFactory||J.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),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.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){let e=this._areBindingsLoading();if(e)return S.log.info(dt,`>>> DRAWING ABORTED ${this.id}: ${e} not loaded`)(),!1;try{t.pushDebugGroup(`${this}.predraw(${t})`),this.predraw()}finally{t.popDebugGroup()}let s;try{t.pushDebugGroup(`${this}.draw(${t})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();let n=this._getBindings();this.pipeline.setBindings(n,{disableWarnings:this.props.disableWarnings});let{indexBuffer:r}=this.vertexArray,o=r?r.byteLength/(r.indexType==="uint32"?4:2):void 0;s=this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{t.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(t),s?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",s}setGeometry(t){this._gpuGeometry?.destroy();let e=t&&Ve(this.device,t);if(e){this.setTopology(e.topology||"triangle-list");let s=new mt(this.bufferLayout);this.bufferLayout=s.mergeBufferLayouts(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){let e=new mt(this.bufferLayout);this.bufferLayout=this._gpuGeometry?e.mergeBufferLayouts(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){jt(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 S.UniformStore(this.shaderInputs.modules);for(let[e,s]of Object.entries(this.shaderInputs.modules))if(ls(s)){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.getBindingValues()),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){let s=e?.disableWarnings??this.props.disableWarnings;t.indices&&S.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=Ye(this.pipeline.shaderLayout,this.bufferLayout);let n=new mt(this.bufferLayout);for(let[r,o]of Object.entries(t)){let a=n.getBufferLayout(r);if(!a){s||S.log.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}let c=n.getAttributeNamesForBuffer(a),l=!1;for(let h of c){let d=this._attributeInfos[h];if(d){let f=this.device.type==="webgpu"?n.getBufferIndex(d.bufferName):d.location;this.vertexArray.setBuffer(f,o),l=!0}}!l&&!s&&S.log.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(t,e){for(let[s,n]of Object.entries(t)){let r=this._attributeInfos[s];r?this.vertexArray.setConstantWebGL(r.location,n):(e?.disableWarnings??this.props.disableWarnings)||S.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${s}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let t of Object.values(this.bindings))if(t instanceof tt&&!t.isReady)return t.id;return!1}_getBindings(){let t={};for(let[e,s]of Object.entries(this.bindings))s instanceof tt?s.isReady&&(t[e]=s.texture):t[e]=s;return t}_getBindingsUpdateTimestamp(){let t=0;for(let e of Object.values(this.bindings))e instanceof S.TextureView?t=Math.max(t,e.texture.updateTimestamp):e instanceof S.Buffer||e instanceof S.Texture?t=Math.max(t,e.updateTimestamp):e instanceof tt?t=e.texture?Math.max(t,e.texture.updateTimestamp):1/0:e instanceof S.Sampler||(t=Math.max(t,e.buffer.updateTimestamp));return t}_setGeometryAttributes(t){let e={...t.attributes};for(let[s]of Object.entries(e))!this.pipeline.shaderLayout.attributes.find(n=>n.name===s)&&s!=="positions"&&delete e[s];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&&(S.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.pipeline.vs,e=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let s=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),n=null;this.source?n=s:this.fs&&(n=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:s,fs:n}),this._attributeInfos=(0,S.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=S.log.level>3?0:hs;S.log.level<2||Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,S.log.group(dt,`>>> DRAWING MODEL ${this.id}`,{collapsed:S.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=Ge(this.pipeline.shaderLayout,this.id);S.log.table(dt,t)();let e=this.shaderInputs.getDebugTable();S.log.table(dt,e)();let s=this._getAttributeDebugTable();S.log.table(dt,this._attributeInfos)(),S.log.table(dt,s)(),S.log.groupEnd(dt)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(t){let e=this.device.props.debugFramebuffers;if(this._drawCount++,!e)return;let s=t.props.framebuffer;s&&qe(s,{id:s.id,minimap:!0})}_getAttributeDebugTable(){let t={};for(let[e,s]of Object.entries(this._attributeInfos)){let n=this.vertexArray.attributes[s.location];t[s.location]={name:e,type:s.shaderType,values:n?this._getBufferOrConstantValues(n,s.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:e}=this.vertexArray,s=e.indexType==="uint32"?new Uint32Array(e.debugData):new Uint16Array(e.debugData);t.indices={name:"indices",type:e.indexType,values:s.toString()}}return t}_getBufferOrConstantValues(t,e){let s=(0,S.getTypedArrayConstructor)(e);return(t instanceof S.Buffer?new s(t.debugData):t).toString()}},W=_e;z(W,"defaultProps",{...S.RenderPipeline.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],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:qt.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function ls(i){return Boolean(i.uniformTypes&&!fs(i.uniformTypes))}function ds(i){return{type:i.type,shaderLanguage:i.info.shadingLanguage,shaderLanguageVersion:i.info.shadingLanguageVersion,gpu:i.info.gpu,features:i.features}}function fs(i){for(let t in i)return!1;return!0}var ei=k(j(),1),ii=k(ht(),1);var Wt=class{device;model;transformFeedback;static isSupported(t){return t?.info?.type==="webgl"}constructor(t,e=Wt.defaultProps){if(!Wt.isSupported(t))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=t,this.model=new W(this.device,{id:e.id||"buffer-transform-model",fs:e.fs||(0,ii.getPassthroughFS)(),topology:e.topology||"point-list",varyings:e.outputs||e.varyings,...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){t?.inputBuffers&&this.model.setAttributes(t.inputBuffers),t?.outputBuffers&&this.transformFeedback.setBuffers(t.outputBuffers);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 ei.Buffer)return e.readAsync();let{buffer:s,byteOffset:n=0,byteLength:r=s.byteLength}=e;return s.readAsync(n,r)}},It=Wt;z(It,"defaultProps",{...W.defaultProps,outputs:void 0,feedbackBuffers:void 0});var si=k(ht(),1);var us="transform_output",Yt=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 W(this.device,{id:e.id||C("texture-transform-model"),fs:e.fs||(0,si.getPassthroughFS)({input:e.targetTextureVarying,inputChannels:e.targetTextureChannels,output:us}),vertexCount:e.vertexCount,...e}),this._initialize(e),Object.seal(this)}destroy(){this.model.destroy();for(let t of this.bindings)t.framebuffer?.destroy()}delete(){this.destroy()}run(t){let{framebuffer:e}=this.bindings[this.currentIndex],s=this.device.beginRenderPass({framebuffer:e,...t});this.model.draw(s),s.end(),this.device.submit()}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:s,targetTexture:n}){if(t||(t={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(t.sourceTextures,s),Object.assign(t.sourceBuffers,e),n){t.targetTexture=n;let{width:r,height:o}=n;t.framebuffer&&t.framebuffer.destroy(),t.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:r,height:o,colorAttachments:[n]}),t.framebuffer.resize({width:r,height:o})}return t}_setSourceTextureParameters(){let t=this.currentIndex,{sourceTextures:e}=this.bindings[t];for(let s in e)e[s].sampler=this.sampler}};var B=class{id;topology;vertexCount;indices;attributes;userData={};constructor(t){let{attributes:e={},indices:s=null,vertexCount:n=null}=t;this.id=t.id||C("geometry"),this.topology=t.topology,s&&(this.indices=ArrayBuffer.isView(s)?{value:s,size:1}:s),this.attributes={};for(let[r,o]of Object.entries(e)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(r)}: must be typed array or object with value as typed array`);if((r==="POSITION"||r==="positions")&&!a.size&&(a.size=3),r==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[r]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||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 s=1/0;for(let n of Object.values(t)){let{value:r,size:o,constant:a}=n;!a&&r&&o!==void 0&&o>=1&&(s=Math.min(s,r.length/o))}return s}};var ps=`struct VertexInputs {
7
+ "use strict";var __exports__=(()=>{var qi=Object.create;var wt=Object.defineProperty;var Wi=Object.getOwnPropertyDescriptor;var Yi=Object.getOwnPropertyNames;var Xi=Object.getPrototypeOf,Hi=Object.prototype.hasOwnProperty;var Ki=(i,t,e)=>t in i?wt(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var De=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),Zi=(i,t)=>{for(var e in t)wt(i,e,{get:t[e],enumerable:!0})},Nt=(i,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Yi(t))!Hi.call(i,n)&&n!==e&&wt(i,n,{get:()=>t[n],enumerable:!(s=Wi(t,n))||s.enumerable});return i},Ft=(i,t,e)=>(Nt(i,t,"default"),e&&Nt(e,t,"default")),k=(i,t,e)=>(e=i!=null?qi(Xi(i)):{},Nt(t||!i||!i.__esModule?wt(e,"default",{value:i,enumerable:!0}):e,i)),Qi=i=>Nt(wt({},"__esModule",{value:!0}),i);var z=(i,t,e)=>(Ki(i,typeof t!="symbol"?t+"":t,e),e);var j=De((pn,ze)=>{ze.exports=globalThis.luma});var ht=De((kn,je)=>{je.exports=globalThis.luma});var Et={};Zi(Et,{AnimationLoop:()=>ct,AnimationLoopTemplate:()=>Bt,AsyncTexture:()=>tt,BackgroundTextureModel:()=>ft,BufferTransform:()=>It,ClipSpace:()=>et,Computation:()=>Ct,ConeGeometry:()=>se,CubeGeometry:()=>ne,CylinderGeometry:()=>re,GPUGeometry:()=>pt,Geometry:()=>B,GroupNode:()=>bt,IcoSphereGeometry:()=>oe,KeyFrames:()=>zt,LegacyPickingManager:()=>pe,Model:()=>W,ModelNode:()=>ie,PickingManager:()=>Pt,PipelineFactory:()=>Q,PlaneGeometry:()=>ae,ScenegraphNode:()=>st,ShaderFactory:()=>J,ShaderInputs:()=>H,ShaderPassRenderer:()=>le,SphereGeometry:()=>ce,Swap:()=>Mt,SwapBuffers:()=>he,SwapFramebuffers:()=>vt,TextureTransform:()=>Yt,Timeline:()=>Dt,TruncatedConeGeometry:()=>ot,cancelAnimationFramePolyfill:()=>Ut,colorPicking:()=>$i,indexPicking:()=>Bi,loadImage:()=>Je,loadImageBitmap:()=>Gt,makeAnimationLoop:()=>Ue,makeRandomGenerator:()=>Fi,requestAnimationFramePolyfill:()=>$t,setPathPrefix:()=>Qe});Ft(Et,k(j(),1));var Ji=1,ts=1,Dt=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(t){let{delay:e=0,duration:s=Number.POSITIVE_INFINITY,rate:n=1,repeat:r=1}=t,o=Ji++,a={time:0,delay:e,duration:s,rate:n,repeat:r};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(t){this.channels.delete(t);for(let[e,s]of this.animations)s.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 n of e)this._setChannelTime(n,this.time);let s=this.animations.values();for(let n of s){let{animation:r,channel:o}=n;r.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(t,e){let s=ts++;return this.animations.set(s,{animation:t,channel:e}),t.setTime(this.getTime(e)),s}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 s=e-t.delay,n=t.duration*t.repeat;s>=n?t.time=t.duration*t.rate:(t.time=Math.max(0,s)%t.duration,t.time*=t.rate)}};var zt=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 s=0;s<e;++s)this.times[s]=t[s][0],this.values[s]=t[s][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,s=this.times.length;for(e=0;e<s-2&&!(this.times[e+1]>t);++e);this.startIndex=e,this.endIndex=e+1;let n=this.times[this.startIndex],r=this.times[this.endIndex];this.factor=Math.min(Math.max(0,(t-n)/(r-n)),1)}};var Bt=class{constructor(t){}async onInitialize(t){return null}};var Be=k(j(),1);function $t(i){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(i):setTimeout(i,1e3/60)}function Ut(i){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(i):clearTimeout(i)}function At(){let i;if(typeof window<"u"&&window.performance)i=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();i=t[0]*1e3+t[1]/1e6}else i=Date.now();return i}var at=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=At(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(At()-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 ut=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:s}=t,n=this.stats[e];return n||(t instanceof at?n=t:n=new at(e,s),this.stats[e]=n),n}};var es=0,me=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;_error=null;constructor(t){if(this.props={...me.defaultAnimationLoopProps,...t},t=this.props,!t.device)throw new Error("No device provided");this.stats=t.stats||new ut({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}),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()}reportError(t){this.props.onError(t),this._error=t}setNeedsRedraw(t){return this.needsRedraw=this.needsRedraw||t,this}setProps(t){return"autoResizeViewport"in t&&(this.props.autoResizeViewport=t.autoResizeViewport||!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._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||this._error?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._resizeViewport()}_setDisplay(t){this.display&&(this.display.destroy(),this.display.animationLoop=null),t&&(t.animationLoop=this),this.display=t}_requestAnimationFrame(){this._running&&(this._animationFrameId=$t(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Ut(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._resizeViewport()}_initializeAnimationProps(){let t=this.device?.getDefaultCanvasContext();if(!this.device||!t)throw new Error("loop");let e=t?.canvas,s=t.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:t,canvas:e,useDevicePixels:s,timeline:this.timeline,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:s}=this._getSizeAndAspect();(t!==this.animationProps.width||e!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),s!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=t,this.animationProps.height=e,this.animationProps.aspect=s,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.getDefaultCanvasContext().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 s=this.props.onAddHTML(e);s&&(e.innerHTML=s)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[t,e]=this.device?.getDefaultCanvasContext().getDevicePixelSize()||[1,1],s=1,n=this.device?.getDefaultCanvasContext().canvas;return n&&n.clientHeight?s=n.clientWidth/n.clientHeight:t>0&&e>0&&(s=t/e),{width:t,height:e,aspect:s}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_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}},ct=me;z(ct,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:Be.luma.stats.get(`animation-loop-${es++}`),autoResizeViewport:!1});var $e=k(j(),1);function Ue(i,t){let e=null,s=t?.device||$e.luma.createDevice({id:"animation-loop",adapters:t?.adapters,createCanvasContext:!0}),n=new ct({...t,device:s,async onInitialize(r){ss(r.animationLoop.device);try{return e=new i(r),await e?.onInitialize(r)}catch(o){return is(r.animationLoop.device,o),null}},onRender:r=>e?.onRender(r),onFinalize:r=>e?.onFinalize(r)});return n.getInfo=()=>this.AnimationLoopTemplateCtor.info,n}function is(i,t){let e=i?.getDefaultCanvasContext().canvas;if(e instanceof HTMLCanvasElement){e.style.overflow="visible";let s=document.getElementById("animation-loop-error");s?.remove(),s=document.createElement("h1"),s.id="animation-loop-error",s.innerHTML=t.message,s.style.position="absolute",s.style.top="10px",s.style.left="10px",s.style.color="black",s.style.backgroundColor="red",e.parentElement?.appendChild(s)}}function ss(i){let t=document.getElementById("animation-loop-error");t&&t.remove()}var S=k(j(),1),qt=k(ht(),1);var Tt=k(j(),1);var ge={};function C(i="id"){ge[i]=ge[i]||1;let t=ge[i]++;return`${i}-${t}`}var pt=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&Tt.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 Ve(i,t){if(t instanceof pt)return t;let e=ns(i,t),{attributes:s,bufferLayout:n}=rs(i,t);return new pt({topology:t.topology||"triangle-list",bufferLayout:n,vertexCount:t.vertexCount,indices:e,attributes:s})}function ns(i,t){if(!t.indices)return;let e=t.indices.value;return i.createBuffer({usage:Tt.Buffer.INDEX,data:e})}function rs(i,t){let e=[],s={};for(let[r,o]of Object.entries(t.attributes)){let a=r;switch(r){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){s[a]=i.createBuffer({data:o.value,id:`${r}-buffer`});let{value:c,size:l,normalized:h}=o;e.push({name:a,format:(0,Tt.getVertexFormatFromAttribute)(c,l,h)})}}let n=t._calculateVertexCount(t.attributes,t.indices);return{attributes:s,bufferLayout:e,vertexCount:n}}var V=k(j(),1);var xe=class{static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new xe(t),t._lumaData.defaultPipelineFactory}device;cachingEnabled;destroyPolicy;debug;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(t){this.device=t,this.cachingEnabled=t.props._cachePipelines,this.destroyPolicy=t.props._cacheDestroyPolicy,this.debug=t.props.debugFactories}createRenderPipeline(t){if(!this.cachingEnabled)return this.device.createRenderPipeline(t);let e={...V.RenderPipeline.defaultProps,...t},s=this._renderPipelineCache,n=this._hashRenderPipeline(e),r=s[n]?.pipeline;return r?(s[n].useCount++,this.debug&&V.log.warn(`${this}: ${s[n].pipeline} reused, count=${s[n].useCount}, (id=${t.id})`)()):(r=this.device.createRenderPipeline({...e,id:e.id?`${e.id}-cached`:C("unnamed-cached")}),r.hash=n,s[n]={pipeline:r,useCount:1},this.debug&&V.log.warn(`${this}: ${r} created, count=${s[n].useCount}`)()),r}createComputePipeline(t){if(!this.cachingEnabled)return this.device.createComputePipeline(t);let e={...V.ComputePipeline.defaultProps,...t},s=this._computePipelineCache,n=this._hashComputePipeline(e),r=s[n]?.pipeline;return r?(s[n].useCount++,this.debug&&V.log.warn(`${this}: ${s[n].pipeline} reused, count=${s[n].useCount}, (id=${t.id})`)()):(r=this.device.createComputePipeline({...e,id:e.id?`${e.id}-cached`:void 0}),r.hash=n,s[n]={pipeline:r,useCount:1},this.debug&&V.log.warn(`${this}: ${r} created, count=${s[n].useCount}`)()),r}release(t){if(!this.cachingEnabled){t.destroy();return}let e=this._getCache(t),s=t.hash;e[s].useCount--,e[s].useCount===0?(this._destroyPipeline(t),this.debug&&V.log.warn(`${this}: ${t} released and destroyed`)()):e[s].useCount<0?(V.log.error(`${this}: ${t} released, useCount < 0, resetting`)(),e[s].useCount=0):this.debug&&V.log.warn(`${this}: ${t} released, count=${e[s].useCount}`)()}_destroyPipeline(t){let e=this._getCache(t);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete e[t.hash],t.destroy(),!0}}_getCache(t){let e;if(t instanceof V.ComputePipeline&&(e=this._computePipelineCache),t instanceof V.RenderPipeline&&(e=this._renderPipelineCache),!e)throw new Error(`${this}`);if(!e[t.hash])throw new Error(`${this}: ${t} matched incorrect entry`);return e}_hashComputePipeline(t){let{type:e}=this.device,s=this._getHash(t.shader.source);return`${e}/C/${s}`}_hashRenderPipeline(t){let e=t.vs?this._getHash(t.vs.source):0,s=t.fs?this._getHash(t.fs.source):0,n="-",r=this._getHash(JSON.stringify(t.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${e}/${s}V${n}BL${r}`;case"webgpu":default:let a=this._getHash(JSON.stringify(t.parameters));return`${o}/R/${e}/${s}V${n}T${t.topology}P${a}BL${r}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}},Q=xe;z(Q,"defaultProps",{...V.RenderPipeline.defaultProps});var lt=k(j(),1);var ye=class{static getDefaultShaderFactory(t){return t._lumaData.defaultShaderFactory||=new ye(t),t._lumaData.defaultShaderFactory}device;cachingEnabled;destroyPolicy;debug;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(t){this.device=t,this.cachingEnabled=t.props._cacheShaders,this.destroyPolicy=t.props._cacheDestroyPolicy,this.debug=!0}createShader(t){if(!this.cachingEnabled)return this.device.createShader(t);let e=this._hashShader(t),s=this._cache[e];if(s)s.useCount++,this.debug&&lt.log.warn(`${this}: Reusing shader ${s.shader.id} count=${s.useCount}`)();else{let n=this.device.createShader({...t,id:t.id?`${t.id}-cached`:void 0});this._cache[e]=s={shader:n,useCount:1},this.debug&&lt.log.warn(`${this}: Created new shader ${n.id}`)()}return s.shader}release(t){if(!this.cachingEnabled){t.destroy();return}let e=this._hashShader(t),s=this._cache[e];if(s)if(s.useCount--,s.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[e],s.shader.destroy(),this.debug&&lt.log.warn(`${this}: Releasing shader ${t.id}, destroyed`)());else{if(s.useCount<0)throw new Error(`ShaderFactory: Shader ${t.id} released too many times`);this.debug&&lt.log.warn(`${this}: Releasing shader ${t.id} count=${s.useCount}`)()}}_hashShader(t){return`${t.stage}:${t.source}`}},J=ye;z(J,"defaultProps",{...lt.Shader.defaultProps});function Ge(i,t){let e={},s="Values";if(i.attributes.length===0&&!i.varyings?.length)return{"No attributes or varyings":{[s]:"N/A"}};for(let n of i.attributes)if(n){let r=`${n.location} ${n.name}: ${n.type}`;e[`in ${r}`]={[s]:n.stepMode||"vertex"}}for(let n of i.varyings||[]){let r=`${n.location} ${n.name}`;e[`out ${r}`]={[s]:JSON.stringify(n)}}return e}var N=null,be=null;function qe(i,{id:t,minimap:e,opaque:s,top:n="0",left:r="0",rgbaScale:o=1}){N||(N=document.createElement("canvas"),N.id=t,N.title=t,N.style.zIndex="100",N.style.position="absolute",N.style.top=n,N.style.left=r,N.style.border="blue 5px solid",N.style.transform="scaleY(-1)",document.body.appendChild(N),be=N.getContext("2d")),(N.width!==i.width||N.height!==i.height)&&(N.width=i.width/2,N.height=i.height/2,N.style.width="400px",N.style.height="400px");let a=i.device.readPixelsToArrayWebGL(i),c=be?.createImageData(i.width,i.height);if(c){for(let h=0;h<a.length;h+=4)c.data[0+h+0]=a[h+0]*o,c.data[0+h+1]=a[h+1]*o,c.data[0+h+2]=a[h+2]*o,c.data[0+h+3]=s?255:a[h+3]*o;be?.putImageData(c,0,0)}}function jt(i,t,e){if(i===t)return!0;if(!e||!i||!t)return!1;if(Array.isArray(i)){if(!Array.isArray(t)||i.length!==t.length)return!1;for(let s=0;s<i.length;s++)if(!jt(i[s],t[s],e-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof i=="object"&&typeof t=="object"){let s=Object.keys(i),n=Object.keys(t);if(s.length!==n.length)return!1;for(let r of s)if(!t.hasOwnProperty(r)||!jt(i[r],t[r],e-1))return!1;return!0}return!1}var We=k(j(),1),mt=class{bufferLayouts;constructor(t){this.bufferLayouts=t}getBufferLayout(t){return this.bufferLayouts.find(e=>e.name===t)||null}getAttributeNamesForBuffer(t){return t.attributes?t.attributes?.map(e=>e.attribute):[t.name]}mergeBufferLayouts(t,e){let s=[...t];for(let n of e){let r=s.findIndex(o=>o.name===n.name);r<0?s.push(n):s[r]=n}return s}getBufferIndex(t){let e=this.bufferLayouts.findIndex(s=>s.name===t);return e===-1&&We.log.warn(`BufferLayout: Missing buffer for "${t}".`)(),e}};function Ye(i,t){let e=Object.fromEntries(i.attributes.map(n=>[n.name,n.location])),s=t.slice();return s.sort((n,r)=>{let o=n.attributes?n.attributes.map(h=>h.attribute):[n.name],a=r.attributes?r.attributes.map(h=>h.attribute):[r.name],c=Math.min(...o.map(h=>e[h])),l=Math.min(...a.map(h=>e[h]));return c-l}),s}var Vt=k(j(),1),Ze=k(ht(),1);function Xe(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function He(i){return Array.isArray(i)?i.length===0||typeof i[0]=="number":!1}function St(i){return Xe(i)||He(i)}function os(i){return St(i)||typeof i=="number"||typeof i=="boolean"}function Ke(i){let t={bindings:{},uniforms:{}};return Object.keys(i).forEach(e=>{let s=i[e];os(s)?t.uniforms[e]=s:t.bindings[e]=s}),t}var H=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(t,e){Object.assign(this.options,e);let s=(0,Ze.getShaderModuleDependencies)(Object.values(t).filter(n=>n.dependencies));for(let n of s)t[n.name]=n;Vt.log.log(1,"Creating ShaderInputs with modules",Object.keys(t))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(let[n,r]of Object.entries(t))this._addModule(r),r.name&&n!==r.name&&!this.options.disableWarnings&&Vt.log.warn(`Module name: ${n} vs ${r.name}`)()}destroy(){}setProps(t){for(let e of Object.keys(t)){let s=e,n=t[s]||{},r=this.modules[s];if(!r){this.options.disableWarnings||Vt.log.warn(`Module ${e} not found`)();continue}let o=this.moduleUniforms[s],a=this.moduleBindings[s],c=r.getUniforms?.(n,o)||n,{uniforms:l,bindings:h}=Ke(c);this.moduleUniforms[s]={...o,...l},this.moduleBindings[s]={...a,...h}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let t={};for(let e of Object.values(this.moduleBindings))Object.assign(t,e);return t}getDebugTable(){let t={};for(let[e,s]of Object.entries(this.moduleUniforms))for(let[n,r]of Object.entries(s))t[`${e}.${n}`]={type:this.modules[e].uniformTypes?.[n],value:String(r)};return t}_addModule(t){let e=t.name;this.moduleUniforms[e]=t.defaultUniforms||{},this.moduleBindings[e]={}}};var rt=k(j(),1);var Me="";function Qe(i){Me=i}async function Gt(i,t){let e=new Image;return e.crossOrigin=t?.crossOrigin||"anonymous",e.src=i.startsWith("http")?i:Me+i,await e.decode(),t?await createImageBitmap(e,t):await createImageBitmap(e)}async function Je(i,t){return await new Promise((e,s)=>{try{let n=new Image;n.onload=()=>e(n),n.onerror=()=>s(new Error(`Could not load image ${i}.`)),n.crossOrigin=t?.crossOrigin||"anonymous",n.src=i.startsWith("http")?i:Me+i}catch(n){s(n)}})}var as=["+X","-X","+Y","-Y","+Z","-Z"];var cs=["+X","-X","+Y","-Y","+Z","-Z"],ve=class{device;id;props;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}constructor(t,e){this.device=t;let s=C("async-texture");this.props={...ve.defaultProps,id:s,...e},this.id=this.props.id,e={...e},typeof e?.data=="string"&&e.dimension==="2d"&&(e.data=Gt(e.data)),e.mipmaps&&(e.mipLevels="auto"),this.ready=new Promise((n,r)=>{this.resolveReady=()=>{this.isReady=!0,n()},this.rejectReady=r}),this.initAsync(e)}async initAsync(t){let e=t.data,s=await ti(e).then(void 0,this.rejectReady);if(this.destroyed)return;let n=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(s);if(!n)throw new Error("Texture size could not be determined");let r={...n,...t,data:void 0,mipLevels:1},o=this.device.getMipLevelCount(r.width,r.height);if(r.mipLevels=this.props.mipLevels==="auto"?o:Math.min(o,this.props.mipLevels),this.texture=this.device.createTexture(r),this.sampler=this.texture.sampler,this.view=this.texture.view,t.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,s);break;case"2d":this._setTexture2DData(s);break;case"3d":this._setTexture3DData(this.texture,s);break;case"2d-array":this._setTextureArrayData(this.texture,s);break;case"cube":this._setTextureCubeData(this.texture,s);break;case"cube-array":this._setTextureCubeArrayData(this.texture,s);break}this.props.mipmaps&&this.generateMipmaps(),rt.log.info(1,`${this} loaded`),this.resolveReady()}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}generateMipmaps(){this.texture.generateMipmapsWebGL()}setSampler(t={}){this.texture.setSampler(t instanceof rt.Sampler?t:this.device.createSampler(t))}resize(t){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(t.width===this.texture.width&&t.height===this.texture.height)return!1;if(this.texture){let e=this.texture;this.texture=e.clone(t),e.destroy()}return!0}isTextureLevelData(t){let e=t?.data;return ArrayBuffer.isView(e)}getTextureDataSize(t){if(!t||ArrayBuffer.isView(t))return null;if(Array.isArray(t))return this.getTextureDataSize(t[0]);if(this.device.isExternalImage(t))return this.device.getExternalImageSize(t);if(t&&typeof t=="object"&&t.constructor===Object){let s=Object.values(t)[0];return{width:s.width,height:s.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(t){switch(t){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(t)}}setTextureData(t){}_setTexture1DData(t,e){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(t,e=0){if(!this.texture)throw new Error("Texture not initialized");let s=this._normalizeTextureData(t);s.length>1&&this.props.mipmaps!==!1&&rt.log.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let n=0;n<s.length;n++){let r=s[n];this.device.isExternalImage(r)?this.texture.copyExternalImage({image:r,depth:e,mipLevel:n,flipY:!0}):this.texture.copyImageData({data:r.data,mipLevel:n})}}_setTexture3DData(t,e){if(this.texture?.props.dimension!=="3d")throw new Error(this.id);for(let s=0;s<e.length;s++)this._setTexture2DData(e[s],s)}_setTextureCubeData(t,e){if(this.texture?.props.dimension!=="cube")throw new Error(this.id);for(let[s,n]of Object.entries(e)){let r=cs.indexOf(s);this._setTexture2DData(n,r)}}_setTextureArrayData(t,e){if(this.texture?.props.dimension!=="2d-array")throw new Error(this.id);for(let s=0;s<e.length;s++)this._setTexture2DData(e[s],s)}_setTextureCubeArrayData(t,e){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(t,e,s,n=0){Array.isArray(e)&&e.length>1&&this.props.mipmaps!==!1&&rt.log.warn(`${this.id} has mipmap and multiple LODs.`)();let r=as.indexOf(s);this._setTexture2DData(e,r)}_normalizeTextureData(t){let e=this.texture,s;return ArrayBuffer.isView(t)?s=[{data:t,width:e.width,height:e.height}]:Array.isArray(t)?s=t:s=[t],s}},tt=ve;z(tt,"defaultProps",{...rt.Texture.defaultProps,data:null,mipmaps:!1});async function ti(i){if(i=await i,Array.isArray(i))return await Promise.all(i.map(ti));if(i&&typeof i=="object"&&i.constructor===Object){let t=i,e=await Promise.all(Object.values(t)),s=Object.keys(t),n={};for(let r=0;r<s.length;r++)n[s[r]]=e[r];return n}return i}var dt=2,hs=1e4,_e=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(t,e){this.props={..._e.defaultProps,...e},e=this.props,this.id=e.id||C("model"),this.device=t,Object.assign(this.userData,e.userData);let s=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),n=e.shaderInputs||new H(s,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(n);let r=ds(t),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:r,...this.props,modules:o});this.source=c,this._getModuleUniforms=l,this.props.shaderLayout||=(0,qt.getShaderLayoutFromWGSL)(this.source)}else{let{vs:c,fs:l,getUniforms:h}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:r,...this.props,modules:o});this.vs=c,this.fs=l,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||Q.getDefaultPipelineFactory(this.device),this.shaderFactory=e.shaderFactory||J.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),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.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){let e=this._areBindingsLoading();if(e)return S.log.info(dt,`>>> DRAWING ABORTED ${this.id}: ${e} not loaded`)(),!1;try{t.pushDebugGroup(`${this}.predraw(${t})`),this.predraw()}finally{t.popDebugGroup()}let s;try{t.pushDebugGroup(`${this}.draw(${t})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();let n=this._getBindings();this.pipeline.setBindings(n,{disableWarnings:this.props.disableWarnings});let{indexBuffer:r}=this.vertexArray,o=r?r.byteLength/(r.indexType==="uint32"?4:2):void 0;s=this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{t.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(t),s?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",s}setGeometry(t){this._gpuGeometry?.destroy();let e=t&&Ve(this.device,t);if(e){this.setTopology(e.topology||"triangle-list");let s=new mt(this.bufferLayout);this.bufferLayout=s.mergeBufferLayouts(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){let e=new mt(this.bufferLayout);this.bufferLayout=this._gpuGeometry?e.mergeBufferLayouts(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){jt(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 S.UniformStore(this.shaderInputs.modules);for(let[e,s]of Object.entries(this.shaderInputs.modules))if(ls(s)){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.getBindingValues()),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){let s=e?.disableWarnings??this.props.disableWarnings;t.indices&&S.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=Ye(this.pipeline.shaderLayout,this.bufferLayout);let n=new mt(this.bufferLayout);for(let[r,o]of Object.entries(t)){let a=n.getBufferLayout(r);if(!a){s||S.log.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}let c=n.getAttributeNamesForBuffer(a),l=!1;for(let h of c){let d=this._attributeInfos[h];if(d){let f=this.device.type==="webgpu"?n.getBufferIndex(d.bufferName):d.location;this.vertexArray.setBuffer(f,o),l=!0}}!l&&!s&&S.log.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(t,e){for(let[s,n]of Object.entries(t)){let r=this._attributeInfos[s];r?this.vertexArray.setConstantWebGL(r.location,n):(e?.disableWarnings??this.props.disableWarnings)||S.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${s}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let t of Object.values(this.bindings))if(t instanceof tt&&!t.isReady)return t.id;return!1}_getBindings(){let t={};for(let[e,s]of Object.entries(this.bindings))s instanceof tt?s.isReady&&(t[e]=s.texture):t[e]=s;return t}_getBindingsUpdateTimestamp(){let t=0;for(let e of Object.values(this.bindings))e instanceof S.TextureView?t=Math.max(t,e.texture.updateTimestamp):e instanceof S.Buffer||e instanceof S.Texture?t=Math.max(t,e.updateTimestamp):e instanceof tt?t=e.texture?Math.max(t,e.texture.updateTimestamp):1/0:e instanceof S.Sampler||(t=Math.max(t,e.buffer.updateTimestamp));return t}_setGeometryAttributes(t){let e={...t.attributes};for(let[s]of Object.entries(e))!this.pipeline.shaderLayout.attributes.find(n=>n.name===s)&&s!=="positions"&&delete e[s];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&&(S.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),t=this.pipeline.vs,e=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let s=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),n=null;this.source?n=s:this.fs&&(n=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:s,fs:n}),this._attributeInfos=(0,S.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=S.log.level>3?0:hs;S.log.level<2||Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,S.log.group(dt,`>>> DRAWING MODEL ${this.id}`,{collapsed:S.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=Ge(this.pipeline.shaderLayout,this.id);S.log.table(dt,t)();let e=this.shaderInputs.getDebugTable();S.log.table(dt,e)();let s=this._getAttributeDebugTable();S.log.table(dt,this._attributeInfos)(),S.log.table(dt,s)(),S.log.groupEnd(dt)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(t){let e=this.device.props.debugFramebuffers;if(this._drawCount++,!e)return;let s=t.props.framebuffer;s&&qe(s,{id:s.id,minimap:!0})}_getAttributeDebugTable(){let t={};for(let[e,s]of Object.entries(this._attributeInfos)){let n=this.vertexArray.attributes[s.location];t[s.location]={name:e,type:s.shaderType,values:n?this._getBufferOrConstantValues(n,s.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:e}=this.vertexArray,s=e.indexType==="uint32"?new Uint32Array(e.debugData):new Uint16Array(e.debugData);t.indices={name:"indices",type:e.indexType,values:s.toString()}}return t}_getBufferOrConstantValues(t,e){let s=(0,S.getTypedArrayConstructor)(e);return(t instanceof S.Buffer?new s(t.debugData):t).toString()}},W=_e;z(W,"defaultProps",{...S.RenderPipeline.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],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:qt.ShaderAssembler.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function ls(i){return Boolean(i.uniformTypes&&!fs(i.uniformTypes))}function ds(i){return{type:i.type,shaderLanguage:i.info.shadingLanguage,shaderLanguageVersion:i.info.shadingLanguageVersion,gpu:i.info.gpu,features:i.features}}function fs(i){for(let t in i)return!1;return!0}var ei=k(j(),1),ii=k(ht(),1);var Wt=class{device;model;transformFeedback;static isSupported(t){return t?.info?.type==="webgl"}constructor(t,e=Wt.defaultProps){if(!Wt.isSupported(t))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=t,this.model=new W(this.device,{id:e.id||"buffer-transform-model",fs:e.fs||(0,ii.getPassthroughFS)(),topology:e.topology||"point-list",varyings:e.outputs||e.varyings,...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){t?.inputBuffers&&this.model.setAttributes(t.inputBuffers),t?.outputBuffers&&this.transformFeedback.setBuffers(t.outputBuffers);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 ei.Buffer)return e.readAsync();let{buffer:s,byteOffset:n=0,byteLength:r=s.byteLength}=e;return s.readAsync(n,r)}},It=Wt;z(It,"defaultProps",{...W.defaultProps,outputs:void 0,feedbackBuffers:void 0});var si=k(ht(),1);var us="transform_output",Yt=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 W(this.device,{id:e.id||C("texture-transform-model"),fs:e.fs||(0,si.getPassthroughFS)({input:e.targetTextureVarying,inputChannels:e.targetTextureChannels,output:us}),vertexCount:e.vertexCount,...e}),this._initialize(e),Object.seal(this)}destroy(){this.model.destroy();for(let t of this.bindings)t.framebuffer?.destroy()}delete(){this.destroy()}run(t){let{framebuffer:e}=this.bindings[this.currentIndex],s=this.device.beginRenderPass({framebuffer:e,...t});this.model.draw(s),s.end(),this.device.submit()}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:s,targetTexture:n}){if(t||(t={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(t.sourceTextures,s),Object.assign(t.sourceBuffers,e),n){t.targetTexture=n;let{width:r,height:o}=n;t.framebuffer&&t.framebuffer.destroy(),t.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:r,height:o,colorAttachments:[n]}),t.framebuffer.resize({width:r,height:o})}return t}_setSourceTextureParameters(){let t=this.currentIndex,{sourceTextures:e}=this.bindings[t];for(let s in e)e[s].sampler=this.sampler}};var B=class{id;topology;vertexCount;indices;attributes;userData={};constructor(t){let{attributes:e={},indices:s=null,vertexCount:n=null}=t;this.id=t.id||C("geometry"),this.topology=t.topology,s&&(this.indices=ArrayBuffer.isView(s)?{value:s,size:1}:s),this.attributes={};for(let[r,o]of Object.entries(e)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(r)}: must be typed array or object with value as typed array`);if((r==="POSITION"||r==="positions")&&!a.size&&(a.size=3),r==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[r]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||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 s=1/0;for(let n of Object.values(t)){let{value:r,size:o,constant:a}=n;!a&&r&&o!==void 0&&o>=1&&(s=Math.min(s,r.length/o))}return s}};var ps=`struct VertexInputs {
8
8
  @location(0) clipSpacePosition: vec2<f32>,
9
9
  @location(1) texCoord: vec2<f32>,
10
10
  @location(2) coordinate: vec2<f32>
package/dist/index.cjs CHANGED
@@ -1384,10 +1384,8 @@ var _AsyncTexture = class {
1384
1384
  this.initAsync(props);
1385
1385
  }
1386
1386
  async initAsync(props) {
1387
- let resolveReady;
1388
- let rejectReady;
1389
1387
  const asyncData = props.data;
1390
- const data = await awaitAllPromises(asyncData).then(resolveReady, rejectReady);
1388
+ const data = await awaitAllPromises(asyncData).then(void 0, this.rejectReady);
1391
1389
  if (this.destroyed) {
1392
1390
  return;
1393
1391
  }
@@ -1401,7 +1399,6 @@ var _AsyncTexture = class {
1401
1399
  this.texture = this.device.createTexture(syncProps);
1402
1400
  this.sampler = this.texture.sampler;
1403
1401
  this.view = this.texture.view;
1404
- this.isReady = true;
1405
1402
  if (props.data) {
1406
1403
  switch (this.props.dimension) {
1407
1404
  case "1d":
@@ -1428,6 +1425,7 @@ var _AsyncTexture = class {
1428
1425
  this.generateMipmaps();
1429
1426
  }
1430
1427
  import_core8.log.info(1, `${this} loaded`);
1428
+ this.resolveReady();
1431
1429
  }
1432
1430
  destroy() {
1433
1431
  if (this.texture) {