@luma.gl/webgpu 9.0.0-alpha.32 → 9.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/helpers/generate-mipmaps.js +18 -6
- package/dist/adapter/helpers/generate-mipmaps.js.map +1 -1
- package/dist/adapter/helpers/get-bind-group.js +1 -1
- package/dist/adapter/helpers/get-bind-group.js.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-vertex-buffer-layout.js +12 -11
- package/dist/adapter/helpers/get-vertex-buffer-layout.js.map +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js +1 -1
- package/dist/adapter/helpers/webgpu-parameters.js.map +1 -1
- package/dist/adapter/resources/webgpu-buffer.js +3 -4
- package/dist/adapter/resources/webgpu-buffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-command-encoder.js +2 -3
- package/dist/adapter/resources/webgpu-command-encoder.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pass.js +3 -4
- package/dist/adapter/resources/webgpu-compute-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-compute-pipeline.js +2 -3
- package/dist/adapter/resources/webgpu-compute-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-external-texture.js +3 -4
- package/dist/adapter/resources/webgpu-external-texture.js.map +1 -1
- package/dist/adapter/resources/webgpu-framebuffer.js +1 -2
- package/dist/adapter/resources/webgpu-framebuffer.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pass.js +3 -4
- package/dist/adapter/resources/webgpu-render-pass.js.map +1 -1
- package/dist/adapter/resources/webgpu-render-pipeline.js +13 -14
- package/dist/adapter/resources/webgpu-render-pipeline.js.map +1 -1
- package/dist/adapter/resources/webgpu-sampler.js +2 -3
- package/dist/adapter/resources/webgpu-sampler.js.map +1 -1
- package/dist/adapter/resources/webgpu-shader.js +4 -5
- package/dist/adapter/resources/webgpu-shader.js.map +1 -1
- package/dist/adapter/resources/webgpu-texture.js +6 -7
- package/dist/adapter/resources/webgpu-texture.js.map +1 -1
- package/dist/adapter/webgpu-canvas-context.js +8 -9
- package/dist/adapter/webgpu-canvas-context.js.map +1 -1
- package/dist/adapter/webgpu-device.js +10 -11
- package/dist/adapter/webgpu-device.js.map +1 -1
- package/dist/dist.dev.js +213 -44
- package/dist/index.cjs +9 -7
- package/dist.min.js +5 -4
- package/package.json +3 -3
- package/src/adapter/helpers/get-vertex-buffer-layout.ts +12 -9
package/dist.min.js
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
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
|
-
var __exports__=(()=>{var jr=Object.create;var xe=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,Dr=Object.prototype.hasOwnProperty;var Ke=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),Gr=(t,n)=>{for(var e in n)xe(t,e,{get:n[e],enumerable:!0})},lt=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of Br(n))!Dr.call(t,o)&&o!==e&&xe(t,o,{get:()=>n[o],enumerable:!(r=Ar(n,o))||r.enumerable});return t};var qe=(t,n,e)=>(e=t!=null?jr(Ir(t)):{},lt(n||!t||!t.__esModule?xe(e,"default",{value:t,enumerable:!0}):e,t)),Lr=t=>lt(xe({},"__esModule",{value:!0}),t);var ht=Ke((Do,q)=>{function Je(t){return q.exports=Je=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},q.exports.__esModule=!0,q.exports.default=q.exports,Je(t)}q.exports=Je,q.exports.__esModule=!0,q.exports.default=q.exports});var gt=Ke((Go,X)=>{var dt=ht().default;function mt(){"use strict";X.exports=mt=function(){return t},X.exports.__esModule=!0,X.exports.default=X.exports;var t={},n=Object.prototype,e=n.hasOwnProperty,r=Object.defineProperty||function(h,l,p){h[l]=p.value},o=typeof Symbol=="function"?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(h,l,p){return Object.defineProperty(h,l,{value:p,enumerable:!0,configurable:!0,writable:!0}),h[l]}try{u({},"")}catch{u=function(p,b,x){return p[b]=x}}function m(h,l,p,b){var x=l&&l.prototype instanceof S?l:S,_=Object.create(x.prototype),k=new te(b||[]);return r(_,"_invoke",{value:ve(h,p,k)}),_}function y(h,l,p){try{return{type:"normal",arg:h.call(l,p)}}catch(b){return{type:"throw",arg:b}}}t.wrap=m;var O={};function S(){}function T(){}function E(){}var H={};u(H,i,function(){return this});var G=Object.getPrototypeOf,z=G&&G(G(Q([])));z&&z!==n&&e.call(z,i)&&(H=z);var B=E.prototype=S.prototype=Object.create(H);function M(h){["next","throw","return"].forEach(function(l){u(h,l,function(p){return this._invoke(l,p)})})}function V(h,l){function p(x,_,k,D){var L=y(h[x],h,_);if(L.type!=="throw"){var re=L.arg,Z=re.value;return Z&&dt(Z)=="object"&&e.call(Z,"__await")?l.resolve(Z.__await).then(function(ne){p("next",ne,k,D)},function(ne){p("throw",ne,k,D)}):l.resolve(Z).then(function(ne){re.value=ne,k(re)},function(ne){return p("throw",ne,k,D)})}D(L.arg)}var b;r(this,"_invoke",{value:function(_,k){function D(){return new l(function(L,re){p(_,k,L,re)})}return b=b?b.then(D,D):D()}})}function ve(h,l,p){var b="suspendedStart";return function(x,_){if(b==="executing")throw new Error("Generator is already running");if(b==="completed"){if(x==="throw")throw _;return{value:void 0,done:!0}}for(p.method=x,p.arg=_;;){var k=p.delegate;if(k){var D=J(k,p);if(D){if(D===O)continue;return D}}if(p.method==="next")p.sent=p._sent=p.arg;else if(p.method==="throw"){if(b==="suspendedStart")throw b="completed",p.arg;p.dispatchException(p.arg)}else p.method==="return"&&p.abrupt("return",p.arg);b="executing";var L=y(h,l,p);if(L.type==="normal"){if(b=p.done?"completed":"suspendedYield",L.arg===O)continue;return{value:L.arg,done:p.done}}L.type==="throw"&&(b="completed",p.method="throw",p.arg=L.arg)}}}function J(h,l){var p=l.method,b=h.iterator[p];if(b===void 0)return l.delegate=null,p==="throw"&&h.iterator.return&&(l.method="return",l.arg=void 0,J(h,l),l.method==="throw")||p!=="return"&&(l.method="throw",l.arg=new TypeError("The iterator does not provide a '"+p+"' method")),O;var x=y(b,h.iterator,l.arg);if(x.type==="throw")return l.method="throw",l.arg=x.arg,l.delegate=null,O;var _=x.arg;return _?_.done?(l[h.resultName]=_.value,l.next=h.nextLoc,l.method!=="return"&&(l.method="next",l.arg=void 0),l.delegate=null,O):_:(l.method="throw",l.arg=new TypeError("iterator result is not an object"),l.delegate=null,O)}function ye(h){var l={tryLoc:h[0]};1 in h&&(l.catchLoc=h[1]),2 in h&&(l.finallyLoc=h[2],l.afterLoc=h[3]),this.tryEntries.push(l)}function Y(h){var l=h.completion||{};l.type="normal",delete l.arg,h.completion=l}function te(h){this.tryEntries=[{tryLoc:"root"}],h.forEach(ye,this),this.reset(!0)}function Q(h){if(h||h===""){var l=h[i];if(l)return l.call(h);if(typeof h.next=="function")return h;if(!isNaN(h.length)){var p=-1,b=function x(){for(;++p<h.length;)if(e.call(h,p))return x.value=h[p],x.done=!1,x;return x.value=void 0,x.done=!0,x};return b.next=b}}throw new TypeError(dt(h)+" is not iterable")}return T.prototype=E,r(B,"constructor",{value:E,configurable:!0}),r(E,"constructor",{value:T,configurable:!0}),T.displayName=u(E,c,"GeneratorFunction"),t.isGeneratorFunction=function(h){var l=typeof h=="function"&&h.constructor;return!!l&&(l===T||(l.displayName||l.name)==="GeneratorFunction")},t.mark=function(h){return Object.setPrototypeOf?Object.setPrototypeOf(h,E):(h.__proto__=E,u(h,c,"GeneratorFunction")),h.prototype=Object.create(B),h},t.awrap=function(h){return{__await:h}},M(V.prototype),u(V.prototype,a,function(){return this}),t.AsyncIterator=V,t.async=function(h,l,p,b,x){x===void 0&&(x=Promise);var _=new V(m(h,l,p,b),x);return t.isGeneratorFunction(l)?_:_.next().then(function(k){return k.done?k.value:_.next()})},M(B),u(B,c,"Generator"),u(B,i,function(){return this}),u(B,"toString",function(){return"[object Generator]"}),t.keys=function(h){var l=Object(h),p=[];for(var b in l)p.push(b);return p.reverse(),function x(){for(;p.length;){var _=p.pop();if(_ in l)return x.value=_,x.done=!1,x}return x.done=!0,x}},t.values=Q,te.prototype={constructor:te,reset:function(l){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(Y),!l)for(var p in this)p.charAt(0)==="t"&&e.call(this,p)&&!isNaN(+p.slice(1))&&(this[p]=void 0)},stop:function(){this.done=!0;var l=this.tryEntries[0].completion;if(l.type==="throw")throw l.arg;return this.rval},dispatchException:function(l){if(this.done)throw l;var p=this;function b(re,Z){return k.type="throw",k.arg=l,p.next=re,Z&&(p.method="next",p.arg=void 0),!!Z}for(var x=this.tryEntries.length-1;x>=0;--x){var _=this.tryEntries[x],k=_.completion;if(_.tryLoc==="root")return b("end");if(_.tryLoc<=this.prev){var D=e.call(_,"catchLoc"),L=e.call(_,"finallyLoc");if(D&&L){if(this.prev<_.catchLoc)return b(_.catchLoc,!0);if(this.prev<_.finallyLoc)return b(_.finallyLoc)}else if(D){if(this.prev<_.catchLoc)return b(_.catchLoc,!0)}else{if(!L)throw new Error("try statement without catch or finally");if(this.prev<_.finallyLoc)return b(_.finallyLoc)}}}},abrupt:function(l,p){for(var b=this.tryEntries.length-1;b>=0;--b){var x=this.tryEntries[b];if(x.tryLoc<=this.prev&&e.call(x,"finallyLoc")&&this.prev<x.finallyLoc){var _=x;break}}_&&(l==="break"||l==="continue")&&_.tryLoc<=p&&p<=_.finallyLoc&&(_=null);var k=_?_.completion:{};return k.type=l,k.arg=p,_?(this.method="next",this.next=_.finallyLoc,O):this.complete(k)},complete:function(l,p){if(l.type==="throw")throw l.arg;return l.type==="break"||l.type==="continue"?this.next=l.arg:l.type==="return"?(this.rval=this.arg=l.arg,this.method="return",this.next="end"):l.type==="normal"&&p&&(this.next=p),O},finish:function(l){for(var p=this.tryEntries.length-1;p>=0;--p){var b=this.tryEntries[p];if(b.finallyLoc===l)return this.complete(b.completion,b.afterLoc),Y(b),O}},catch:function(l){for(var p=this.tryEntries.length-1;p>=0;--p){var b=this.tryEntries[p];if(b.tryLoc===l){var x=b.completion;if(x.type==="throw"){var _=x.arg;Y(b)}return _}}throw new Error("illegal catch attempt")},delegateYield:function(l,p,b){return this.delegate={iterator:Q(l),resultName:p,nextLoc:b},this.method==="next"&&(this.arg=void 0),O}},t}X.exports=mt,X.exports.__esModule=!0,X.exports.default=X.exports});var Re=Ke((Lo,vt)=>{var Ce=gt()();vt.exports=Ce;try{regeneratorRuntime=Ce}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Ce:Function("r","regeneratorRuntime = r")(Ce)}});var po={};Gr(po,{WebGPUBuffer:()=>He,WebGPUDevice:()=>ct,WebGPUSampler:()=>F,WebGPUShader:()=>$e,WebGPUTexture:()=>Ve});function ft(t,n,e,r,o,i,a){try{var c=t[i](a),u=c.value}catch(m){e(m);return}c.done?n(u):Promise.resolve(u).then(r,o)}function K(t){return function(){var n=this,e=arguments;return new Promise(function(r,o){var i=t.apply(n,e);function a(u){ft(i,r,o,a,c,"next",u)}function c(u){ft(i,r,o,a,c,"throw",u)}a(void 0)})}}function g(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function $(t){return $=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},$(t)}function Xe(t,n){if($(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var r=e.call(t,n||"default");if($(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function be(t){var n=Xe(t,"string");return $(n)==="symbol"?n:String(n)}function pt(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,be(r.key),r)}}function v(t,n,e){return n&&pt(t.prototype,n),e&&pt(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _e(t,n){return _e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},_e(t,n)}function w(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&_e(t,n)}function P(t,n){if(n&&($(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(t)}function s(t,n,e){return n=be(n),n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}var Oe=qe(Re(),1);function Qe(t){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let n=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,e=t||n;return!!(e&&e.indexOf("Electron")>=0)}function I(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||Qe()}var Nr=globalThis.self||globalThis.window||globalThis.global,ue=globalThis.window||globalThis.self||globalThis.global,Mr=globalThis.document||{},oe=globalThis.process||{},Ur=globalThis.console,Fo=globalThis.navigator||{};var Te=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",Ho=I();function Fr(t){try{let n=window[t],e="__storage_test__";return n.setItem(e,e),n.removeItem(e),n}catch{return null}}var Ee=class{constructor(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";this.storage=void 0,this.id=void 0,this.config=void 0,this.storage=Fr(r),this.id=n,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(n){if(Object.assign(this.config,n),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let n={};if(this.storage){let e=this.storage.getItem(this.id);n=e?JSON.parse(e):{}}return Object.assign(this.config,n),this}};function yt(t){let n;return t<10?n="".concat(t.toFixed(2),"ms"):t<100?n="".concat(t.toFixed(1),"ms"):t<1e3?n="".concat(t.toFixed(0),"ms"):n="".concat((t/1e3).toFixed(2),"s"),n}function bt(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,e=Math.max(n-t.length,0);return"".concat(" ".repeat(e)).concat(t)}function ke(t,n,e){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,o=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>r&&(e=Math.min(e,r/t.width));let i=t.width*e,a=t.height*e,c=["font-size:1px;","padding:".concat(Math.floor(a/2),"px ").concat(Math.floor(i/2),"px;"),"line-height:".concat(a,"px;"),"background:url(".concat(o,");"),"background-size:".concat(i,"px ").concat(a,"px;"),"color:transparent;"].join("");return["".concat(n," %c+"),c]}var je;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(je||(je={}));var Wr=10;function _t(t){return typeof t!="string"?t:(t=t.toUpperCase(),je[t]||je.WHITE)}function wt(t,n,e){if(!I&&typeof t=="string"){if(n){let r=_t(n);t="\x1B[".concat(r,"m").concat(t,"\x1B[39m")}if(e){let r=_t(e);t="\x1B[".concat(r+Wr,"m").concat(t,"\x1B[49m")}}return t}function Pt(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],e=Object.getPrototypeOf(t),r=Object.getOwnPropertyNames(e),o=t;for(let i of r){let a=o[i];typeof a=="function"&&(n.find(c=>i===c)||(o[i]=a.bind(t)))}}function ce(t,n){if(!t)throw new Error(n||"Assertion failed")}function ie(){let t;if(I()&&ue.performance){var n,e;t=ue===null||ue===void 0||(n=ue.performance)===null||n===void 0||(e=n.now)===null||e===void 0?void 0:e.call(n)}else if("hrtime"in oe){var r;let o=oe===null||oe===void 0||(r=oe.hrtime)===null||r===void 0?void 0:r.call(oe);t=o[0]*1e3+o[1]/1e6}else t=Date.now();return t}var le={debug:I()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},zr={enabled:!0,level:0};function U(){}var St={},Ot={once:!0},ee=class{constructor(){let{id:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=Te,this._startTs=ie(),this._deltaTs=ie(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new Ee("__probe-".concat(this.id,"__"),zr),this.timeStamp("".concat(this.id," started")),Pt(this),Object.seal(this)}set level(n){this.setLevel(n)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((ie()-this._startTs).toPrecision(10))}getDelta(){return Number((ie()-this._deltaTs).toPrecision(10))}set priority(n){this.level=n}get priority(){return this.level}getPriority(){return this.level}enable(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:n}),this}setLevel(n){return this._storage.setConfiguration({level:n}),this}get(n){return this._storage.config[n]}set(n,e){this._storage.setConfiguration({[n]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(n,e){ce(n,e)}warn(n){return this._getLogFunction(0,n,le.warn,arguments,Ot)}error(n){return this._getLogFunction(0,n,le.error,arguments)}deprecated(n,e){return this.warn("`".concat(n,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(n,e){return this.error("`".concat(n,"` has been removed. Use `").concat(e,"` instead"))}probe(n,e){return this._getLogFunction(n,e,le.log,arguments,{time:!0,once:!0})}log(n,e){return this._getLogFunction(n,e,le.debug,arguments)}info(n,e){return this._getLogFunction(n,e,console.info,arguments)}once(n,e){return this._getLogFunction(n,e,le.debug||le.info,arguments,Ot)}table(n,e,r){return e?this._getLogFunction(n,e,console.table||U,r&&[r],{tag:Yr(e)}):U}image(n){let{logLevel:e,priority:r,image:o,message:i="",scale:a=1}=n;return this._shouldLog(e||r)?I()?$r({image:o,message:i,scale:a}):Vr({image:o,message:i,scale:a}):U}time(n,e){return this._getLogFunction(n,e,console.time?console.time:console.info)}timeEnd(n,e){return this._getLogFunction(n,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(n,e){return this._getLogFunction(n,e,console.timeStamp||U)}group(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},o=xt({logLevel:n,message:e,opts:r}),{collapsed:i}=r;return o.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(o)}groupCollapsed(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(n,e,Object.assign({},r,{collapsed:!0}))}groupEnd(n){return this._getLogFunction(n,"",console.groupEnd||U)}withGroup(n,e,r){this.group(n,e)();try{r()}finally{this.groupEnd(n)()}}trace(){console.trace&&console.trace()}_shouldLog(n){return this.isEnabled()&&this.getLevel()>=Ct(n)}_getLogFunction(n,e,r,o,i){if(this._shouldLog(n)){i=xt({logLevel:n,message:e,args:o,opts:i}),r=r||i.method,ce(r),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=ie();let a=i.tag||i.message;if(i.once&&a)if(!St[a])St[a]=ie();else return U;return e=Hr(this.id,i.message,i),r.bind(console,e,...i.args)}return U}};ee.VERSION=Te;function Ct(t){if(!t)return 0;let n;switch(typeof t){case"number":n=t;break;case"object":n=t.logLevel||t.priority||0;break;default:return 0}return ce(Number.isFinite(n)&&n>=0),n}function xt(t){let{logLevel:n,message:e}=t;t.logLevel=Ct(n);let r=t.args?Array.from(t.args):[];for(;r.length&&r.shift()!==e;);switch(typeof n){case"string":case"function":e!==void 0&&r.unshift(e),t.message=n;break;case"object":Object.assign(t,n);break;default:}typeof t.message=="function"&&(t.message=t.message());let o=typeof t.message;return ce(o==="string"||o==="object"),Object.assign(t,{args:r},t.opts)}function Hr(t,n,e){if(typeof n=="string"){let r=e.time?bt(yt(e.total)):"";n=e.time?"".concat(t,": ").concat(r," ").concat(n):"".concat(t,": ").concat(n),n=wt(n,e.color,e.background)}return n}function Vr(t){let{image:n,message:e="",scale:r=1}=t;return console.warn("removed"),U}function $r(t){let{image:n,message:e="",scale:r=1}=t;if(typeof n=="string"){let i=new Image;return i.onload=()=>{let a=ke(i,e,r);console.log(...a)},i.src=n,U}let o=n.nodeName||"";if(o.toLowerCase()==="img")return console.log(...ke(n,e,r)),U;if(o.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...ke(i,e,r)),i.src=n.toDataURL(),U}return U}function Yr(t){for(let n in t)for(let e in t[n])return e||"untitled";return"empty"}var mi=new ee({id:"@probe.gl/log"});var R=new ee({id:"luma.gl"});function we(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let n=process.hrtime();t=n[0]*1e3+n[1]/1e6}else t=Date.now();return t}var ae=class{constructor(n,e){this.name=void 0,this.type=void 0,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=n,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(n){return this.sampleSize=n,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(n){return this._count+=n,this._samples++,this._checkSampling(),this}subtractCount(n){return this._count-=n,this._samples++,this._checkSampling(),this}addTime(n){return this._time+=n,this.lastTiming=n,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=we(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(we()-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 fe=class{constructor(n){this.id=void 0,this.stats={},this.id=n.id,this.stats={},this._initializeStats(n.stats),Object.seal(this)}get(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"count";return this._getOrCreate({name:n,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let n of Object.values(this.stats))n.reset();return this}forEach(n){for(let e of Object.values(this.stats))n(e)}getTable(){let n={};return this.forEach(e=>{n[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),n}_initializeStats(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(e=>this._getOrCreate(e))}_getOrCreate(n){let{name:e,type:r}=n,o=this.stats[e];return o||(n instanceof ae?o=n:o=new ae(e,r),this.stats[e]=o),o}};var Kr=function(){function t(){g(this,t),s(this,"stats",new Map)}return v(t,[{key:"getStats",value:function(e){return this.get(e)}},{key:"get",value:function(e){return this.stats.has(e)||this.stats.set(e,new fe({id:e})),this.stats.get(e)}}]),t}(),Ae=new Kr;function qr(){var t=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",n="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==t)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat(t));return globalThis.luma||(I()&&R.log(1,"luma.gl ".concat(t," - ").concat(n))(),globalThis.luma=globalThis.luma||{VERSION:t,version:t,log:R,stats:Ae}),t}var Rt=qr();var Ze={};function se(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";Ze[t]=Ze[t]||1;var n=Ze[t]++;return"".concat(t,"-").concat(n)}function Be(t){var n=!0;for(var e in t){n=!1;break}return n}function Tt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Xr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Tt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Tt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var C=function(){function t(n,e,r){if(g(this,t),s(this,"id",void 0),s(this,"props",void 0),s(this,"userData",{}),s(this,"device",void 0),s(this,"_device",void 0),s(this,"destroyed",!1),s(this,"allocatedBytes",0),s(this,"_attachedResources",new Set),!n)throw new Error("no device");this._device=n,this.props=Jr(e,r);var o=this.props.id!=="undefined"?this.props.id:se(this[Symbol.toStringTag]);this.props.id=o,this.id=o,this.userData=this.props.userData||{},this.addStats()}return v(t,[{key:"destroy",value:function(){this.destroyResource()}},{key:"delete",value:function(){return this.destroy(),this}},{key:"toString",value:function(){return"".concat(this[Symbol.toStringTag]||this.constructor.name,"(").concat(this.id,")")}},{key:"getProps",value:function(){return this.props}},{key:"attachResource",value:function(e){this._attachedResources.add(e)}},{key:"detachResource",value:function(e){this._attachedResources.delete(e)}},{key:"destroyAttachedResource",value:function(e){this._attachedResources.delete(e)&&e.destroy()}},{key:"destroyAttachedResources",value:function(){for(var e=0,r=Object.values(this._attachedResources);e<r.length;e++){var o=r[e];o.destroy()}this._attachedResources=new Set}},{key:"destroyResource",value:function(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}},{key:"removeStats",value:function(){var e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("".concat(r,"s Active")).decrementCount()}},{key:"trackAllocatedMemory",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[Symbol.toStringTag],o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(e),o.get("".concat(r," Memory")).addCount(e),this.allocatedBytes=e}},{key:"trackDeallocatedMemory",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this[Symbol.toStringTag],r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get("".concat(e," Memory")).subtractCount(this.allocatedBytes),this.allocatedBytes=0}},{key:"addStats",value:function(){var e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get("".concat(r,"s Created")).incrementCount(),e.get("".concat(r,"s Active")).incrementCount()}}]),t}();s(C,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Jr(t,n){var e=Xr({},n);for(var r in t)t[r]!==void 0&&(e[r]=t[r]);return e}var kt;function Et(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function et(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Et(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Et(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Qr(t){var n=Zr();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Zr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}kt=Symbol.toStringTag;var j=function(t){w(e,t);var n=Qr(e);function e(r,o){var i;g(this,e);var a=et({},o);return(o.usage||0)&e.INDEX&&!o.indexType&&(o.data instanceof Uint32Array?a.indexType="uint32":o.data instanceof Uint16Array&&(a.indexType="uint16")),i=n.call(this,r,a,e.defaultProps),s(f(i),"usage",void 0),s(f(i),"indexType",void 0),s(f(i),"byteLength",void 0),i.usage=o.usage||0,i.indexType=a.indexType,i}return v(e,[{key:kt,get:function(){return"Buffer"}},{key:"write",value:function(o,i){throw new Error("not implemented")}},{key:"readAsync",value:function(o,i){throw new Error("not implemented")}},{key:"getData",value:function(){throw new Error("not implemented")}}]),e}(C);s(j,"defaultProps",et(et({},C.defaultProps),{},{usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}));s(j,"MAP_READ",1);s(j,"MAP_WRITE",2);s(j,"COPY_SRC",4);s(j,"COPY_DST",8);s(j,"INDEX",16);s(j,"VERTEX",32);s(j,"UNIFORM",64);s(j,"STORAGE",128);s(j,"INDIRECT",256);s(j,"QUERY_RESOLVE",512);var At;function jt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function tt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?jt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):jt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var en={id:null,type:"best-available",canvas:null,container:null,webgl2:!0,webgl1:!0,manageState:!0,width:800,height:600,debug:Boolean(R.get("debug")),break:[],gl:null};At=Symbol.toStringTag;var Ie=function(){function t(n){g(this,t),s(this,"id",void 0),s(this,"statsManager",Ae),s(this,"props",void 0),s(this,"userData",{}),s(this,"_lumaData",{}),s(this,"info",void 0),s(this,"lost",void 0),s(this,"canvasContext",void 0),this.props=tt(tt({},en),n),this.id=this.props.id||se(this[Symbol.toStringTag].toLowerCase())}return v(t,[{key:At,get:function(){return"Device"}},{key:"loseDevice",value:function(){return!1}},{key:"createTexture",value:function(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}},{key:"createCommandEncoder",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};throw new Error("not implemented")}},{key:"_getBufferProps",value:function(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{data:e};var r=tt({},e);return(e.usage||0)&j.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array&&(r.indexType="uint16")),r}}]),t}();s(Ie,"VERSION",Rt);function rt(t){if(Array.isArray(t))return t}function nt(t,n){var e=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(e!=null){var r,o,i,a,c=[],u=!0,m=!1;try{if(i=(e=e.call(t)).next,n===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(r=i.call(e)).done)&&(c.push(r.value),c.length!==n);u=!0);}catch(y){m=!0,o=y}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(m)throw o}}return c}}function De(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function ot(t,n){if(t){if(typeof t=="string")return De(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return De(t,n)}}function it(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
9
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,a=!1,c;return{s:function(){e=e.call(t)},n:function(){var m=e.next();return i=m.done,m},e:function(m){a=!0,c=m},f:function(){try{!i&&e.return!=null&&e.return()}finally{if(a)throw c}}}}function rn(t,n){if(t){if(typeof t=="string")return Bt(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Bt(t,n)}}function Bt(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function It(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Dt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?It(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):It(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var nn=I()&&typeof document<"u",Ge=function(){return nn&&document.readyState==="complete"},on={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},pe=function(){function t(n){var e=this;if(g(this,t),s(this,"device",void 0),s(this,"id",void 0),s(this,"props",void 0),s(this,"canvas",void 0),s(this,"htmlCanvas",void 0),s(this,"offscreenCanvas",void 0),s(this,"type",void 0),s(this,"width",1),s(this,"height",1),s(this,"resizeObserver",void 0),s(this,"_canvasSizeInfo",{clientWidth:0,clientHeight:0,devicePixelRatio:1}),this.props=Dt(Dt({},on),n),n=this.props,!I()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(n.canvas)typeof n.canvas=="string"?this.canvas=un(n.canvas):this.canvas=n.canvas;else{var r,o,i=cn(n),a=sn(((r=n)===null||r===void 0?void 0:r.container)||null);a.insertBefore(i,a.firstChild),this.canvas=i,(o=n)!==null&&o!==void 0&&o.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&n.autoResize&&(this.resizeObserver=new ResizeObserver(function(c){var u=tn(c),m;try{for(u.s();!(m=u.n()).done;){var y=m.value;y.target===e.canvas&&e.update()}}catch(O){u.e(O)}finally{u.f()}}),this.resizeObserver.observe(this.canvas))}return v(t,[{key:"getDevicePixelRatio",value:function(e){if(typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0))return 1;if(e===!0){var r=typeof window<"u"&&window.devicePixelRatio;return r||1}return e}},{key:"getPixelSize",value:function(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":var e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}},{key:"getAspect",value:function(){var e=this.getPixelSize(),r=A(e,2),o=r[0],i=r[1];return o/i}},{key:"cssToDeviceRatio",value:function(){try{var e=this.getDrawingBufferSize(),r=A(e,1),o=r[0],i=this._canvasSizeInfo.clientWidth;return i?o/i:1}catch{return 1}}},{key:"cssToDevicePixels",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,o=this.cssToDeviceRatio(),i=this.getDrawingBufferSize(),a=A(i,2),c=a[0],u=a[1];return ln(e,o,c,u,r)}},{key:"setDevicePixelRatio",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.htmlCanvas){var o="width"in r?r.width:this.htmlCanvas.clientWidth,i="height"in r?r.height:this.htmlCanvas.clientHeight;(!o||!i)&&(R.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,o=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);var a=this._canvasSizeInfo;if(a.clientWidth!==o||a.clientHeight!==i||a.devicePixelRatio!==e){var c=e,u=Math.floor(o*c),m=Math.floor(i*c);this.htmlCanvas.width=u,this.htmlCanvas.height=m;var y=this.getDrawingBufferSize(),O=A(y,2),S=O[0],T=O[1];(S!==u||T!==m)&&(c=Math.min(S/o,T/i),this.htmlCanvas.width=Math.floor(o*c),this.htmlCanvas.height=Math.floor(i*c),R.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=o,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}}},{key:"getDrawingBufferSize",value:function(){var e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}},{key:"_setAutoCreatedCanvasId",value:function(e){var r;((r=this.htmlCanvas)===null||r===void 0?void 0:r.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}}],[{key:"isPageLoaded",get:function(){return Ge()}}]),t}();s(pe,"pageLoaded",an());function an(){return Ge()||typeof window>"u"?Promise.resolve():new Promise(function(t){window.addEventListener("load",function(){return t()})})}function sn(t){if(typeof t=="string"){var n=document.getElementById(t);if(!n&&!Ge())throw new Error("Accessing '".concat(t,"' before page was loaded"));if(!n)throw new Error("".concat(t," is not an HTML element"));return n}else if(t)return t;return document.body}function un(t){var n=document.getElementById(t);if(!n&&!Ge())throw new Error("Accessing '".concat(t,"' before page was loaded"));if(!(n instanceof HTMLCanvasElement))throw new Error("'".concat(n,"' is not a canvas element"));return n}function cn(t){var n=t.width,e=t.height,r=document.createElement("canvas");return r.id="lumagl-auto-created-canvas",r.width=n||1,r.height=e||1,r.style.width=Number.isFinite(n)?"".concat(n,"px"):"100%",r.style.height=Number.isFinite(e)?"".concat(e,"px"):"100%",r}function ln(t,n,e,r,o){var i=t,a=Gt(i[0],n,e),c=Lt(i[1],n,r,o),u=Gt(i[0]+1,n,e),m=u===e-1?u:u-1;u=Lt(i[1]+1,n,r,o);var y;return o?(u=u===0?u:u+1,y=c,c=u):y=u===r-1?u:u-1,{x:a,y:c,width:Math.max(m-a+1,1),height:Math.max(y-c+1,1)}}function Gt(t,n,e){var r=Math.min(Math.round(t*n),e-1);return r}function Lt(t,n,e,r){return r?Math.max(0,e-1-Math.round(t*n)):Math.min(Math.round(t*n),e-1)}var Ut;function Nt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Mt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Nt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Nt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function fn(t){var n=pn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function pn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Ut=Symbol.toStringTag;var N=function(t){w(e,t);var n=fn(e);function e(r,o){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.defaultProps;return g(this,e),i=n.call(this,r,o,a),s(f(i),"dimension",void 0),s(f(i),"format",void 0),s(f(i),"width",void 0),s(f(i),"height",void 0),s(f(i),"depth",void 0),s(f(i),"sampler",void 0),i.dimension=i.props.dimension,i.format=i.props.format,i.width=i.props.width,i.height=i.props.height,i.depth=i.props.depth,i}return v(e,[{key:Ut,get:function(){return"Texture"}}]),e}(C);s(N,"defaultProps",Mt(Mt({},C.defaultProps),{},{data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,sampler:{},compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0}));s(N,"COPY_SRC",1);s(N,"COPY_DST",2);s(N,"TEXTURE_BINDING",4);s(N,"STORAGE_BINDING",8);s(N,"RENDER_ATTACHMENT",16);var zt;function Ft(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Wt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ft(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ft(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function hn(t){var n=dn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function dn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}zt=Symbol.toStringTag;var Le=function(t){w(e,t);var n=hn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:zt,get:function(){return"ExternalTexture"}}]),e}(C);s(Le,"defaultProps",Wt(Wt({},C.defaultProps),{},{source:null,colorSpace:"srgb"}));var $t;function Ht(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Vt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ht(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ht(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function mn(t){var n=gn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function gn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}$t=Symbol.toStringTag;var Ne=function(t){w(e,t);var n=mn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,e.defaultProps),s(f(i),"stage",void 0),s(f(i),"source",void 0),i.stage=i.props.stage,i.source=i.props.source,i}return v(e,[{key:$t,get:function(){return"Shader"}}]),e}(C);s(Ne,"defaultProps",Vt(Vt({},C.defaultProps),{},{stage:"vertex",source:"",sourceMap:null,language:"glsl",shaderType:0}));var qt;function Yt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Kt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Yt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Yt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function vn(t){var n=yn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function yn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}qt=Symbol.toStringTag;var he=function(t){w(e,t);var n=vn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:qt,get:function(){return"Sampler"}}]),e}(C);s(he,"defaultProps",Kt(Kt({},C.defaultProps),{},{type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1}));var Jt;function Xt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function de(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Xt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Xt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function bn(t){var n=_n();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function _n(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Jt=Symbol.toStringTag;var Me=function(t){w(e,t);var n=bn(e);function e(r){var o,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return g(this,e),o=n.call(this,r,i,e.defaultProps),s(f(o),"width",void 0),s(f(o),"height",void 0),s(f(o),"colorAttachments",[]),s(f(o),"depthStencilAttachment",null),o.width=o.props.width,o.height=o.props.height,o}return v(e,[{key:Jt,get:function(){return"Framebuffer"}},{key:"resize",value:function(o){var i=!o;if(o){var a=Array.isArray(o)?o:[o.width,o.height],c=A(a,2),u=c[0],m=c[1];i=i||m!==this.height||u!==this.width,this.width=u,this.height=m}i&&(R.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(this.width,"x").concat(this.height))(),this.resizeAttachments(this.width,this.height))}},{key:"autoCreateAttachmentTextures",value:function(){var o=this;if(this.colorAttachments=this.props.colorAttachments.map(function(a){if(typeof a=="string"){var c=o.createColorTexture(a);return o.attachResource(c),c}return a}),this.props.depthStencilAttachment)if(typeof this.props.depthStencilAttachment=="string"){var i=this.createDepthStencilTexture(this.props.depthStencilAttachment);this.attachResource(i),this.depthStencilAttachment=i}else this.depthStencilAttachment=this.props.depthStencilAttachment}},{key:"createColorTexture",value:function(o){return this.device.createTexture({id:"color-attachment",usage:N.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})}},{key:"createDepthStencilTexture",value:function(o){return this.device.createTexture({id:"depth-stencil-attachment",usage:N.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})}},{key:"resizeAttachments",value:function(o,i){for(var a=0;a<this.colorAttachments.length;++a)if(this.colorAttachments[a]){var c=this.device._createTexture(de(de({},this.colorAttachments[a].props),{},{width:o,height:i}));this.destroyAttachedResource(this.colorAttachments[a]),this.colorAttachments[a]=c,this.attachResource(c)}if(this.depthStencilAttachment){var u=this.device._createTexture(de(de({},this.depthStencilAttachment.props),{},{width:o,height:i}));this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=u,this.attachResource(u)}}}]),e}(C);s(Me,"defaultProps",de(de({},C.defaultProps),{},{width:1,height:1,colorAttachments:[],depthStencilAttachment:null}));var er;function Qt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Zt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Qt(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Qt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function wn(t){var n=Pn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Pn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}er=Symbol.toStringTag;var Ue=function(t){w(e,t);var n=wn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,e.defaultProps),s(f(i),"hash",""),s(f(i),"vs",void 0),s(f(i),"fs",void 0),i}return v(e,[{key:er,get:function(){return"RenderPipeline"}}]),e}(C);s(Ue,"defaultProps",Zt(Zt({},C.defaultProps),{},{vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,indices:null,attributes:{},bindings:{},uniforms:{}}));var nr;function tr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function rr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?tr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):tr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Sn(t){var n=On();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function On(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}nr=Symbol.toStringTag;var Fe=function(t){w(e,t);var n=Sn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o,e.defaultProps),s(f(i),"hash",""),i}return v(e,[{key:nr,get:function(){return"ComputePipeline"}}]),e}(C);s(Fe,"defaultProps",rr(rr({},C.defaultProps),{},{cs:void 0,csEntryPoint:void 0,csConstants:{},shaderLayout:[]}));var ar;function or(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function ir(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?or(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function xn(t){var n=Cn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Cn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}ar=Symbol.toStringTag;var We=function(t){w(e,t);var n=xn(e);function e(r,o){return g(this,e),n.call(this,r,o,e.defaultProps)}return v(e,[{key:ar,get:function(){return"RenderPass"}}]),e}(C);s(We,"defaultProps",ir(ir({},C.defaultProps),{},{framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1}));var ur;function sr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Rn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?sr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):sr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Tn(t){var n=En();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function En(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}ur=Symbol.toStringTag;var ze=function(t){w(e,t);var n=Tn(e);function e(r,o){return g(this,e),n.call(this,r,o,C.defaultProps)}return v(e,[{key:ur,get:function(){return"ComputePass"}}]),e}(C);s(ze,"defaultProps",Rn({},C.defaultProps));function lr(t){var n=cr[t],e=kn(n),r=t.includes("norm"),o=!r&&!t.startsWith("float"),i=t.startsWith("s");return{dataType:cr[t],byteLength:e,integer:o,signed:i,normalized:r}}function kn(t){var n=jn[t];return n}var cr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},jn={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Pe(t){var n;t.endsWith("-webgl")&&(t.replace("-webgl",""),n=!0);var e=t.split("x"),r=A(e,2),o=r[0],i=r[1],a=o,c=i?parseInt(i):1,u=lr(a),m={type:a,components:c,byteLength:u.byteLength*c,integer:u.integer,signed:u.signed,normalized:u.normalized};return n&&(m.webglOnly=!0),m}var at=qe(Re(),1);function An(t){var n=Bn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Bn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function In(t){var n;return t.byteLength||((n=t.data)===null||n===void 0?void 0:n.byteLength)||0}var He=function(t){w(e,t);var n=An(e);function e(r,o){var i;g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"byteLength",void 0),i.device=r,i.byteLength=In(o);var a=Boolean(o.data);return i.handle=i.props.handle||i.device.handle.createBuffer({size:i.byteLength,usage:i.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:i.props.mappedAtCreation||a,label:i.props.id}),o.data&&i._writeMapped(o.data),a&&!o.mappedAtCreation&&i.handle.unmap(),i}return v(e,[{key:"destroy",value:function(){this.handle.destroy()}},{key:"write",value:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.device.handle.queue.writeBuffer(this.handle,i,o.buffer,o.byteOffset,o.byteLength)}},{key:"readAsync",value:function(){var r=K(at.default.mark(function i(){var a,c,u,m,y,O=arguments;return at.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return a=O.length>0&&O[0]!==void 0?O[0]:0,c=O.length>1&&O[1]!==void 0?O[1]:this.byteLength,u=new e(this.device,{usage:j.MAP_READ|j.COPY_DST,byteLength:c}),m=this.device.handle.createCommandEncoder(),m.copyBufferToBuffer(this.handle,a,u.handle,0,c),this.device.handle.queue.submit([m.finish()]),T.next=8,u.handle.mapAsync(GPUMapMode.READ,a,c);case 8:return y=u.handle.getMappedRange().slice(0),u.handle.unmap(),u.destroy(),T.abrupt("return",y);case 12:case"end":return T.stop()}},i,this)}));function o(){return r.apply(this,arguments)}return o}()},{key:"_writeMapped",value:function(o){var i=this.handle.getMappedRange();new o.constructor(i).set(o)}},{key:"mapAsync",value:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2?arguments[2]:void 0;return this.handle.mapAsync(o,i,a)}},{key:"getMappedRange",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,i=arguments.length>1?arguments[1]:void 0;return this.handle.getMappedRange(o,i)}},{key:"unmap",value:function(){this.handle.unmap()}}]),e}(j);function me(t){if(t.includes("webgl"))throw new Error("webgl-only format");return t}function fr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function Dn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?fr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):fr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Gn(t){var n=Ln();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Ln(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var F=function(t){w(e,t);var n=Gn(e);function e(r,o){var i;g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),i.device=r;var a=Dn({},i.props);return a.type!=="comparison-sampler"&&delete a.compare,i.handle=i.handle||i.device.handle.createSampler(a),i.handle.label=i.props.id,i}return v(e,[{key:"destroy",value:function(){}}]),e}(he);function Nn(t){var n=Mn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Mn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Un={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Ve=function(t){w(e,t);var n=Nn(e);function e(r,o){var i;if(g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"view",void 0),s(f(i),"sampler",void 0),s(f(i),"height",void 0),s(f(i),"width",void 0),typeof i.props.format=="number")throw new Error("number format");return i.device=r,i.handle=i.props.handle||i.createHandle(),i.props.data&&i.setData({data:i.props.data}),i.width=i.handle.width,i.height=i.handle.height,i.sampler=o.sampler instanceof F?o.sampler:new F(i.device,o.sampler),i.view=i.handle.createView({}),i}return v(e,[{key:"createHandle",value:function(){var o,i;if(typeof this.props.format=="number")throw new Error("number format");var a=this.props.width||((o=this.props.data)===null||o===void 0?void 0:o.width)||1,c=this.props.height||((i=this.props.data)===null||i===void 0?void 0:i.height)||1;return this.device.handle.createTexture({size:{width:a,height:c,depthOrArrayLayers:this.props.depth},dimension:Un[this.props.dimension],format:me(this.props.format),usage:this.props.usage,mipLevelCount:this.props.mipLevels,sampleCount:this.props.samples})}},{key:"destroy",value:function(){this.handle.destroy()}},{key:"setSampler",value:function(o){return this.sampler=o instanceof F?o:new F(this.device,o),this}},{key:"setData",value:function(o){return this.setImage({source:o.data})}},{key:"setImage",value:function(o){var i=o.source,a=o.width,c=a===void 0?o.source.width:a,u=o.height,m=u===void 0?o.source.height:u,y=o.depth,O=y===void 0?1:y,S=o.sourceX,T=S===void 0?0:S,E=o.sourceY,H=E===void 0?0:E,G=o.mipLevel,z=G===void 0?0:G,B=o.x,M=B===void 0?0:B,V=o.y,ve=V===void 0?0:V,J=o.z,ye=J===void 0?0:J,Y=o.aspect,te=Y===void 0?"all":Y,Q=o.colorSpace,h=Q===void 0?"srgb":Q,l=o.premultipliedAlpha,p=l===void 0?!1:l;return this.device.handle.queue.copyExternalImageToTexture({source:i,origin:[T,H]},{texture:this.handle,origin:[M,ve,ye],mipLevel:z,aspect:te,colorSpace:h,premultipliedAlpha:p},[c,m,O]),{width:c,height:m}}}]),e}(N);function Fn(t){var n=Wn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Wn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var pr=function(t){w(e,t);var n=Fn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"sampler",void 0),i.device=r,i.handle=i.props.handle||i.device.handle.importExternalTexture({source:o.source,colorSpace:o.colorSpace}),i.sampler=null,i}return v(e,[{key:"destroy",value:function(){}},{key:"setSampler",value:function(o){return this.sampler=o instanceof F?o:new F(this.device,o),this}}]),e}(Le);var Se=qe(Re(),1);function zn(t){var n=Hn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Hn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var $e=function(t){w(e,t);var n=zn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),i.device=r,i.device.handle.pushErrorScope("validation"),i.handle=i.props.handle||i.createHandle(),i.handle.label=i.props.id,i._checkCompilationError(i.device.handle.popErrorScope()),i}return v(e,[{key:"_checkCompilationError",value:function(){var r=K(Se.default.mark(function i(a){var c,u;return Se.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,a;case 2:if(c=y.sent,!c){y.next=9;break}return y.next=6,this.compilationInfo();case 6:throw u=y.sent,R.error("Shader compilation error: ".concat(c.message),u)(),new Error("Shader compilation error: ".concat(c.message));case 9:case"end":return y.stop()}},i,this)}));function o(i){return r.apply(this,arguments)}return o}()},{key:"destroy",value:function(){}},{key:"createHandle",value:function(){var o=this,i=this.props,a=i.source,c=i.stage,u=this.props.language;switch(u||(u=a.includes("->")?"wgsl":"glsl"),u){case"wgsl":return this.device.handle.createShaderModule({code:a});case"glsl":return this.device.handle.createShaderModule({code:a,transform:function(y){return o.device.glslang.compileGLSL(y,c)}});default:throw new Error(u)}}},{key:"compilationInfo",value:function(){var r=K(Se.default.mark(function i(){var a;return Se.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.handle.getCompilationInfo();case 2:return a=u.sent,u.abrupt("return",a.messages);case 4:case"end":return u.stop()}},i,this)}));function o(){return r.apply(this,arguments)}return o}()}]),e}(Ne);function hr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function dr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?hr(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):hr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function W(t){return t.depthStencil=t.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:void 0,depthCompare:void 0},t.depthStencil}var Vn={cullMode:function(n,e,r){r.primitive=r.primitive||{},r.primitive.cullMode=e},frontFace:function(n,e,r){r.primitive=r.primitive||{},r.primitive.frontFace=e},depthWriteEnabled:function(n,e,r){var o=W(r);o.depthWriteEnabled=e},depthCompare:function(n,e,r){var o=W(r);o.depthCompare=e},depthFormat:function(n,e,r){var o=W(r);o.format=e},depthBias:function(n,e,r){var o=W(r);o.depthBias=e},depthBiasSlopeScale:function(n,e,r){var o=W(r);o.depthBiasSlopeScale=e},depthBiasClamp:function(n,e,r){var o=W(r);o.depthBiasClamp=e},stencilReadMask:function(n,e,r){var o=W(r);o.stencilReadMask=e},stencilWriteMask:function(n,e,r){var o=W(r);o.stencilWriteMask=e},stencilCompare:function(n,e,r){var o=W(r);o.stencilFront.compare=e,o.stencilBack.compare=e},stencilPassOperation:function(n,e,r){var o=W(r);o.stencilFront.passOp=e,o.stencilBack.passOp=e},stencilFailOperation:function(n,e,r){var o=W(r);o.stencilFront.failOp=e,o.stencilBack.failOp=e},stencilDepthFailOperation:function(n,e,r){var o=W(r);o.stencilFront.depthFailOp=e,o.stencilBack.depthFailOp=e},sampleCount:function(n,e,r){r.multisample=r.multisample||{},r.multisample.count=e},sampleMask:function(n,e,r){r.multisample=r.multisample||{},r.multisample.mask=e},sampleAlphaToCoverageEnabled:function(n,e,r){r.multisample=r.multisample||{},r.multisample.alphaToCoverageEnabled=e},colorMask:function(n,e,r){var o=mr(r);o[0].writeMask=e},blendColorOperation:function(n,e,r){mr(r)}},$n={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function gr(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(t,dr(dr({},$n),t)),Yn(t,n)}function Yn(t,n){for(var e=0,r=Object.entries(n);e<r.length;e++){var o=A(r[e],2),i=o[0],a=o[1],c=Vn[i];if(!c)throw new Error("Illegal parameter ".concat(i));c(i,a,t)}}function mr(t){var n,e,r,o;if(t.fragment.targets=((n=t.fragment)===null||n===void 0?void 0:n.targets)||[],!Array.isArray((e=t.fragment)===null||e===void 0?void 0:e.targets))throw new Error("colorstate");if(((r=t.fragment)===null||r===void 0||(r=r.targets)===null||r===void 0?void 0:r.length)===0){var i;(i=t.fragment.targets)===null||i===void 0||i.push({})}return(o=t.fragment)===null||o===void 0?void 0:o.targets}function vr(t,n,e,r){var o=qn(r,e);return t.createBindGroup({layout:n,entries:o})}function Kn(t,n){var e=t.bindings.find(function(r){return r.name===n});return e||R.warn("Binding ".concat(n," not set: Not found in shader layout."))(),e}function qn(t,n){for(var e=[],r=0,o=Object.entries(t);r<o.length;r++){var i=A(o[r],2),a=i[0],c=i[1],u=Kn(n,a);u&&e.push(Xn(c,u.location))}return e}function Xn(t,n){if(t instanceof j)return{binding:n,resource:{buffer:t.handle}};if(t instanceof he)return{binding:n,resource:t.handle};if(t instanceof N)return{binding:n,resource:t.handle.createView()};throw new Error("invalid binding")}function ge(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Jn(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(m){throw m},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
10
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,a=!1,c;return{s:function(){e=e.call(t)},n:function(){var m=e.next();return i=m.done,m},e:function(m){a=!0,c=m},f:function(){try{!i&&e.return!=null&&e.return()}finally{if(a)throw c}}}}function Jn(t,n){if(t){if(typeof t=="string")return yr(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return yr(t,n)}}function yr(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function st(t){if(t.endsWith("-webgl"))throw new Error("WebGPU does not support vertex format ".concat(t));return t}function _r(t,n){var e=[],r=new Set,o=ge(n),i;try{for(o.s();!(i=o.n()).done;){var a=i.value,c=[],u="vertex",m=0,y=a.byteOffset||0;if(a.attributes){var O=ge(a.attributes),S;try{for(O.s();!(S=O.n()).done;){var T=S.value,E=br(t,T.name,r);u=E.stepMode||"vertex",c.push({format:st(T.format||a.format),offset:y+m,shaderLocation:E.location}),m+=Pe(a.format).byteLength}}catch(M){O.e(M)}finally{O.f()}}else{var H=br(t,a.name,r);m=Pe(a.format).byteLength,u=H.stepMode||"vertex",c.push({format:st(a.format),offset:y,shaderLocation:H.location})}e.push({arrayStride:a.byteStride||m,stepMode:u||"vertex",attributes:c})}}catch(M){o.e(M)}finally{o.f()}var G=ge(t.attributes),z;try{for(G.s();!(z=G.n()).done;){var B=z.value;r.has(B.name)||e.push({arrayStride:Pe("float32x3").byteLength,stepMode:B.stepMode||"vertex",attributes:[{format:st("float32x3"),offset:0,shaderLocation:B.location}]})}}catch(M){G.e(M)}finally{G.f()}return e}function wr(t,n){var e=new Set,r=0,o={},i=ge(n),a;try{for(i.s();!(a=i.n()).done;){var c=a.value;if("attributes"in c){var u=ge(c.attributes),m;try{for(u.s();!(m=u.n()).done;){var y=m.value;e.add(y.name)}}catch(E){u.e(E)}finally{u.f()}}else e.add(c.name);o[c.name]=r++}}catch(E){i.e(E)}finally{i.f()}var O=ge(t.attributes),S;try{for(O.s();!(S=O.n()).done;){var T=S.value;e.has(T.name)||(o[T.name]=r++)}}catch(E){O.e(E)}finally{O.f()}return o}function br(t,n,e){var r=t.attributes.find(function(o){return o.name===n});if(!r)throw new Error("Unknown attribute ".concat(n));if(e.has(n))throw new Error("Duplicate attribute ".concat(n));return e.add(n),r}function Qn(t){var n=Zn();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function Zn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Pr=function(t){w(e,t);var n=Qn(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),s(f(i),"vs",void 0),s(f(i),"fs",null),s(f(i),"_bufferSlots",void 0),s(f(i),"_buffers",void 0),s(f(i),"_indexBuffer",null),s(f(i),"_bindGroupLayout",void 0),s(f(i),"_bindGroup",null),i.device=r,i.handle=i.props.handle||i.createHandle(),i.handle.label=i.props.id,i.vs=o.vs,i.fs=o.fs,i._bufferSlots=wr(i.props.shaderLayout,i.props.bufferLayout),i._buffers=new Array(Object.keys(i._bufferSlots).length).fill(null),i._bindGroupLayout=i.handle.getBindGroupLayout(0),i}return v(e,[{key:"createHandle",value:function(){var o=this._getRenderPipelineDescriptor(),i=this.device.handle.createRenderPipeline(o);return R.groupCollapsed(1,"new WebGPRenderPipeline(".concat(this.id,")"))(),R.log(1,JSON.stringify(o,null,2))(),R.groupEnd(1)(),i}},{key:"destroy",value:function(){}},{key:"setIndexBuffer",value:function(o){this._indexBuffer=o}},{key:"setAttributes",value:function(o){for(var i=0,a=Object.entries(o);i<a.length;i++){var c=A(a[i],2),u=c[0],m=c[1],y=this._bufferSlots[u];if(y>=0)this._buffers[y]=m;else throw new Error("Setting attribute '".concat(u,"' not listed in shader layout for program ").concat(this.id))}}},{key:"setConstantAttributes",value:function(o){throw new Error("not implemented")}},{key:"setBindings",value:function(o){Be(this.props.bindings)||(Object.assign(this.props.bindings,o),this._bindGroup=vr(this.device.handle,this._bindGroupLayout,this.props.shaderLayout,this.props.bindings))}},{key:"setUniforms",value:function(o){if(!Be(o))throw new Error("WebGPU does not support uniforms")}},{key:"_getBuffers",value:function(){return this._buffers}},{key:"_getBindGroup",value:function(){return this._bindGroup}},{key:"_getRenderPipelineDescriptor",value:function(){var o={module:this.props.vs.handle,entryPoint:this.props.vsEntryPoint||"main",buffers:_r(this.props.shaderLayout,this.props.bufferLayout)},i;if(this.props.fs){var a;i={module:this.props.fs.handle,entryPoint:this.props.fsEntryPoint||"main",targets:[{format:me((a=this.device)===null||a===void 0||(a=a.canvasContext)===null||a===void 0?void 0:a.format)}]}}switch(this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":throw new Error("WebGPU does not support primitive topology ".concat(this.props.topology));default:}var c={vertex:o,fragment:i,primitive:{topology:this.props.topology},layout:"auto"};return gr(c,this.props.parameters),c}},{key:"draw",value:function(o){var i=o.renderPass||this.device.getDefaultRenderPass();i.handle.setPipeline(this.handle);var a=this._getBindGroup();a&&i.handle.setBindGroup(0,a),this._setAttributeBuffers(i),o.indexCount?i.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):i.handle.draw(o.vertexCount||0,o.instanceCount,o.firstIndex,o.firstInstance)}},{key:"_setAttributeBuffers",value:function(o){var i=this;this._indexBuffer&&o.handle.setIndexBuffer(this._indexBuffer.handle,this._indexBuffer.props.indexType);for(var a=this._getBuffers(),c=function(y){var O=a[y];if(!O){var S=i.props.shaderLayout.attributes.find(function(T){return T.location===y});throw new Error("No buffer provided for attribute '".concat(S?.name||"","' in Model '").concat(i.props.id,"'"))}o.handle.setVertexBuffer(y,O.handle)},u=0;u<a.length;++u)c(u)}}]),e}(Ue);function eo(t){var n=to();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function to(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Sr=function(t){w(e,t);var n=eo(e);function e(r,o){var i;g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),s(f(i),"handle",void 0),i.device=r;var a=i.props.cs.handle;return i.handle=i.props.handle||i.device.handle.createComputePipeline({label:i.props.id,compute:{module:a,entryPoint:i.props.csEntryPoint},layout:"auto"}),i}return v(e,[{key:"_getBindGroupLayout",value:function(){return this.handle.getBindGroupLayout(0)}}]),e}(Fe);function Or(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function xr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Or(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Or(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function ro(t){var n=no();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function no(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Cr=function(t){w(e,t);var n=ro(e);function e(r){var o,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};g(this,e),o=n.call(this,r,i),s(f(o),"device",void 0),s(f(o),"handle",void 0),s(f(o),"pipeline",null),o.device=r;var a=i.framebuffer||r.canvasContext.getCurrentFramebuffer(),c=o.getRenderPassDescriptor(a);return o.handle=o.props.handle||r.commandEncoder.beginRenderPass(c),o.handle.label=o.props.id,o}return v(e,[{key:"destroy",value:function(){}},{key:"end",value:function(){this.handle.end()}},{key:"setPipeline",value:function(o){this.pipeline=o,this.handle.setPipeline(this.pipeline.handle)}},{key:"setBindings",value:function(o){var i,a;(i=this.pipeline)===null||i===void 0||i.setBindings(o);var c=(a=this.pipeline)===null||a===void 0?void 0:a._getBindGroup();c&&this.handle.setBindGroup(0,c)}},{key:"setIndexBuffer",value:function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,c=arguments.length>3?arguments[3]:void 0;this.handle.setIndexBuffer(o.handle,i,a,c)}},{key:"setVertexBuffer",value:function(o,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;this.handle.setVertexBuffer(o,i.handle,a)}},{key:"draw",value:function(o){o.indexCount?this.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):this.handle.draw(o.vertexCount||0,o.instanceCount,o.firstIndex,o.firstInstance)}},{key:"drawIndirect",value:function(){}},{key:"setParameters",value:function(o){var i=o.blendConstant,a=o.stencilReference,c=o.scissorRect,u=o.viewport;i&&this.handle.setBlendConstant(i),a&&this.handle.setStencilReference(a),c&&this.handle.setScissorRect(c[0],c[1],c[2],c[3]),u&&this.handle.setViewport(u[0],u[1],u[2],u[3],u[4],u[5])}},{key:"pushDebugGroup",value:function(o){this.handle.pushDebugGroup(o)}},{key:"popDebugGroup",value:function(){this.handle.popDebugGroup()}},{key:"insertDebugMarker",value:function(o){this.handle.insertDebugMarker(o)}},{key:"getRenderPassDescriptor",value:function(o){var i=this,a={colorAttachments:[]};return a.colorAttachments=o.colorAttachments.map(function(c){return{loadOp:"clear",colorClearValue:i.props.clearColor||[0,0,0,0],storeOp:i.props.discard?"discard":"store",view:c.handle.createView()}}),o.depthStencilAttachment&&(a.depthStencilAttachment=xr(xr({},this.props),{},{view:o.depthStencilAttachment.handle.createView()})),a}}]),e}(We);function oo(t){var n=io();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function io(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Rr=function(t){w(e,t);var n=oo(e);function e(r,o){var i,a;return g(this,e),a=n.call(this,r,o),s(f(a),"device",void 0),s(f(a),"handle",void 0),s(f(a),"_bindGroupLayout",null),a.device=r,a.handle=a.props.handle||((i=r.commandEncoder)===null||i===void 0?void 0:i.beginComputePass({label:a.props.id})),a}return v(e,[{key:"destroy",value:function(){}},{key:"end",value:function(){this.handle.end()}},{key:"setPipeline",value:function(o){var i=o;this.handle.setPipeline(i.handle),this._bindGroupLayout=i._getBindGroupLayout()}},{key:"setBindings",value:function(o){throw new Error("fix me")}},{key:"dispatch",value:function(o,i,a){this.handle.dispatchWorkgroups(o,i,a)}},{key:"dispatchIndirect",value:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.handle.dispatchWorkgroupsIndirect(o.handle,i)}},{key:"pushDebugGroup",value:function(o){this.handle.pushDebugGroup(o)}},{key:"popDebugGroup",value:function(){this.handle.popDebugGroup()}},{key:"insertDebugMarker",value:function(o){this.handle.insertDebugMarker(o)}}]),e}(ze);function ao(t){var n=so();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function so(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Tr=function(t){w(e,t);var n=ao(e);function e(r,o){var i;return g(this,e),i=n.call(this,r,o),s(f(i),"device",void 0),i.device=r,i.autoCreateAttachmentTextures(),i}return v(e)}(Me);function uo(t){var n=co();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function co(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ut=function(t){w(e,t);var n=uo(e);function e(r,o,i){var a;return g(this,e),a=n.call(this,i),s(f(a),"device",void 0),s(f(a),"gpuCanvasContext",void 0),s(f(a),"format",void 0),s(f(a),"depthStencilFormat","depth24plus"),s(f(a),"sampleCount",1),s(f(a),"depthStencilAttachment",null),a.device=r,a.width=-1,a.height=-1,a._setAutoCreatedCanvasId("".concat(a.device.id,"-canvas")),a.gpuCanvasContext=a.canvas.getContext("webgpu"),a.format=a.gpuCanvasContext.getPreferredFormat(o),a}return v(e,[{key:"destroy",value:function(){this.gpuCanvasContext.unconfigure()}},{key:"getCurrentFramebuffer",value:function(){this.update();var o=this.device.createTexture({id:"default-render-target",handle:this.gpuCanvasContext.getCurrentTexture(),format:this.format,width:this.width,height:this.height});return this._createDepthStencilAttachment(),new Tr(this.device,{colorAttachments:[o],depthStencilAttachment:this.depthStencilAttachment})}},{key:"update",value:function(){var o=this.getPixelSize(),i=A(o,2),a=i[0],c=i[1],u=a!==this.width||c!==this.height;u&&(this.width=a,this.height=c,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:me(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),R.log(1,"Resized to ".concat(this.width,"x").concat(this.height,"px"))())}},{key:"resize",value:function(o){this.update()}},{key:"_createDepthStencilAttachment",value:function(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:"depth-stencil-target",format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment}}]),e}(pe);function Er(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),e.push.apply(e,r)}return e}function kr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Er(Object(e),!0).forEach(function(r){s(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Er(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function lo(t){var n=fo();return function(){var r=d(t),o;if(n){var i=d(this).constructor;o=Reflect.construct(r,arguments,i)}else o=r.apply(this,arguments);return P(this,o)}}function fo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ct=function(t){w(e,t);var n=lo(e);function e(r,o,i){var a;return g(this,e),a=n.call(this,kr(kr({},i),{},{id:i.id||se("webgpu-device")})),s(f(a),"handle",void 0),s(f(a),"adapter",void 0),s(f(a),"lost",void 0),s(f(a),"canvasContext",null),s(f(a),"commandEncoder",null),s(f(a),"renderPass",null),s(f(a),"_info",void 0),s(f(a),"_isLost",!1),s(f(a),"features",void 0),a.handle=r,a.adapter=o,a._info={type:"webgpu",vendor:a.adapter.__brand,renderer:"",version:"",gpu:"unknown",shadingLanguages:["glsl","wgsl"],shadingLanguageVersions:{glsl:"450",wgsl:"100"},vendorMasked:"",rendererMasked:""},a.lost=new Promise(function(){var c=K(Oe.default.mark(function u(m){var y;return Oe.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,a.handle.lost;case 2:y=S.sent,a._isLost=!0,m({reason:"destroyed",message:y.message});case 5:case"end":return S.stop()}},u)}));return function(u){return c.apply(this,arguments)}}()),i.canvas&&(a.canvasContext=new ut(f(a),a.adapter,{canvas:i.canvas})),a.features=a._getFeatures(),a}return v(e,[{key:"destroy",value:function(){this.handle.destroy()}},{key:"info",get:function(){return this._info}},{key:"limits",get:function(){return this.handle.limits}},{key:"isTextureFormatSupported",value:function(o){return!o.includes("webgl")}},{key:"isTextureFormatFilterable",value:function(o){return this.isTextureFormatSupported(o)}},{key:"isTextureFormatRenderable",value:function(o){return this.isTextureFormatSupported(o)}},{key:"isLost",get:function(){return this._isLost}},{key:"createBuffer",value:function(o){var i=this._getBufferProps(o);return new He(this,i)}},{key:"_createTexture",value:function(o){return new Ve(this,o)}},{key:"createExternalTexture",value:function(o){return new pr(this,o)}},{key:"createShader",value:function(o){return new $e(this,o)}},{key:"createSampler",value:function(o){return new F(this,o)}},{key:"createRenderPipeline",value:function(o){return new Pr(this,o)}},{key:"createFramebuffer",value:function(o){throw new Error("Not implemented")}},{key:"createComputePipeline",value:function(o){return new Sr(this,o)}},{key:"beginRenderPass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Cr(this,o)}},{key:"beginComputePass",value:function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Rr(this,o)}},{key:"createCanvasContext",value:function(o){return new ut(this,this.adapter,o)}},{key:"getDefaultRenderPass",value:function(){var o;return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:(o=this.canvasContext)===null||o===void 0?void 0:o.getCurrentFramebuffer()}),this.renderPass}},{key:"submit",value:function(){var o,i;(o=this.renderPass)===null||o===void 0||o.end();var a=(i=this.commandEncoder)===null||i===void 0?void 0:i.finish();a&&this.handle.queue.submit([a]),this.commandEncoder=null,this.renderPass=null}},{key:"_getFeatures",value:function(){var o=new Set(this.handle.features);return o.has("depth-clamping")&&(o.delete("depth-clamping"),o.add("depth-clip-control")),o.has("texture-compression-bc")&&o.add("texture-compression-bc5-webgl"),o.add("webgpu"),o.add("timer-query-webgl"),o.add("vertex-array-object-webgl1"),o.add("instanced-rendering-webgl1"),o.add("multiple-render-targets-webgl1"),o.add("index-uint32-webgl1"),o.add("blend-minmax-webgl1"),o.add("texture-blend-float-webgl1"),o.add("texture-formats-srgb-webgl1"),o.add("texture-formats-depth-webgl1"),o.add("texture-formats-float32-webgl1"),o.add("texture-formats-float16-webgl1"),o.add("texture-filter-linear-float32-webgl"),o.add("texture-filter-linear-float16-webgl"),o.add("texture-filter-anisotropic-webgl"),o.add("texture-renderable-rgba32float-webgl"),o.add("texture-renderable-float32-webgl"),o.add("texture-renderable-float16-webgl"),o.add("glsl-frag-data"),o.add("glsl-frag-depth"),o.add("glsl-derivatives"),o.add("glsl-texture-lod"),o}},{key:"copyExternalImageToTexture",value:function(o){var i,a=o.source,c=o.sourceX,u=c===void 0?0:c,m=o.sourceY,y=m===void 0?0:m,O=o.texture,S=o.mipLevel,T=S===void 0?0:S,E=o.aspect,H=E===void 0?"all":E,G=o.colorSpace,z=G===void 0?"display-p3":G,B=o.premultipliedAlpha,M=B===void 0?!1:B,V=o.width,ve=V===void 0?O.width:V,J=o.height,ye=J===void 0?O.height:J,Y=o.depth,te=Y===void 0?1:Y,Q=O;(i=this.handle)===null||i===void 0||i.queue.copyExternalImageToTexture({source:a,origin:[u,y]},{texture:Q.handle,origin:[0,0,0],mipLevel:T,aspect:H,colorSpace:z,premultipliedAlpha:M},[ve,ye,te])}}],[{key:"isSupported",value:function(){return Boolean(typeof navigator<"u"&&navigator.gpu)}},{key:"create",value:function(){var r=K(Oe.default.mark(function i(a){var c,u,m,y;return Oe.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(navigator.gpu){S.next=2;break}throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");case 2:return R.groupCollapsed(1,"WebGPUDevice created")(),S.next=5,navigator.gpu.requestAdapter({powerPreference:"high-performance"});case 5:if(c=S.sent,c){S.next=8;break}throw new Error("Failed to request WebGPU adapter");case 8:return S.next=10,c.requestAdapterInfo();case 10:return u=S.sent,R.probe(1,"Adapter available",u)(),S.next=14,c.requestDevice({requiredFeatures:c.features});case 14:if(m=S.sent,R.probe(1,"GPUDevice available")(),typeof a.canvas!="string"){S.next=20;break}return S.next=19,pe.pageLoaded;case 19:R.probe(1,"DOM is loaded")();case 20:return y=new e(m,c,a),R.probe(1,"Device created",y.info)(),R.table(1,y.info)(),R.groupEnd(1)(),S.abrupt("return",y);case 25:case"end":return S.stop()}},i)}));function o(i){return r.apply(this,arguments)}return o}()}]),e}(Ie);s(ct,"type","webgpu");return Lr(po);})();
|
|
7
|
+
var __exports__=(()=>{var Gr=Object.create;var Ce=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var Mr=Object.getOwnPropertyNames;var Lr=Object.getPrototypeOf,kr=Object.prototype.hasOwnProperty;var qe=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),Fr=(t,n)=>{for(var e in n)Ce(t,e,{get:n[e],enumerable:!0})},pt=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Mr(n))!kr.call(t,i)&&i!==e&&Ce(t,i,{get:()=>n[i],enumerable:!(r=Nr(n,i))||r.enumerable});return t};var Xe=(t,n,e)=>(e=t!=null?Gr(Lr(t)):{},pt(n||!t||!t.__esModule?Ce(e,"default",{value:t,enumerable:!0}):e,t)),Ur=t=>pt(Ce({},"__esModule",{value:!0}),t);var mt=qe((qo,K)=>{function Ze(t){return K.exports=Ze=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},K.exports.__esModule=!0,K.exports.default=K.exports,Ze(t)}K.exports=Ze,K.exports.__esModule=!0,K.exports.default=K.exports});var yt=qe((Xo,q)=>{var gt=mt().default;function vt(){"use strict";q.exports=vt=function(){return t},q.exports.__esModule=!0,q.exports.default=q.exports;var t={},n=Object.prototype,e=n.hasOwnProperty,r=Object.defineProperty||function(p,f,l){p[f]=l.value},i=typeof Symbol=="function"?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(p,f,l){return Object.defineProperty(p,f,{value:l,enumerable:!0,configurable:!0,writable:!0}),p[f]}try{u({},"")}catch{u=function(l,v,S){return l[v]=S}}function c(p,f,l,v){var S=f&&f.prototype instanceof O?f:O,_=Object.create(S.prototype),E=new $(v||[]);return r(_,"_invoke",{value:Q(p,l,E)}),_}function y(p,f,l){try{return{type:"normal",arg:p.call(f,l)}}catch(v){return{type:"throw",arg:v}}}t.wrap=c;var d={};function O(){}function b(){}function T(){}var k={};u(k,o,function(){return this});var H=Object.getPrototypeOf,D=H&&H(H(re([])));D&&D!==n&&e.call(D,o)&&(k=D);var L=T.prototype=O.prototype=Object.create(k);function F(p){["next","throw","return"].forEach(function(f){u(p,f,function(l){return this._invoke(f,l)})})}function G(p,f){function l(S,_,E,I){var N=y(p[S],p,_);if(N.type!=="throw"){var ne=N.arg,X=ne.value;return X&>(X)=="object"&&e.call(X,"__await")?f.resolve(X.__await).then(function(oe){l("next",oe,E,I)},function(oe){l("throw",oe,E,I)}):f.resolve(X).then(function(oe){ne.value=oe,E(ne)},function(oe){return l("throw",oe,E,I)})}I(N.arg)}var v;r(this,"_invoke",{value:function(_,E){function I(){return new f(function(N,ne){l(_,E,N,ne)})}return v=v?v.then(I,I):I()}})}function Q(p,f,l){var v="suspendedStart";return function(S,_){if(v==="executing")throw new Error("Generator is already running");if(v==="completed"){if(S==="throw")throw _;return{value:void 0,done:!0}}for(l.method=S,l.arg=_;;){var E=l.delegate;if(E){var I=ce(E,l);if(I){if(I===d)continue;return I}}if(l.method==="next")l.sent=l._sent=l.arg;else if(l.method==="throw"){if(v==="suspendedStart")throw v="completed",l.arg;l.dispatchException(l.arg)}else l.method==="return"&&l.abrupt("return",l.arg);v="executing";var N=y(p,f,l);if(N.type==="normal"){if(v=l.done?"completed":"suspendedYield",N.arg===d)continue;return{value:N.arg,done:l.done}}N.type==="throw"&&(v="completed",l.method="throw",l.arg=N.arg)}}}function ce(p,f){var l=f.method,v=p.iterator[l];if(v===void 0)return f.delegate=null,l==="throw"&&p.iterator.return&&(f.method="return",f.arg=void 0,ce(p,f),f.method==="throw")||l!=="return"&&(f.method="throw",f.arg=new TypeError("The iterator does not provide a '"+l+"' method")),d;var S=y(v,p.iterator,f.arg);if(S.type==="throw")return f.method="throw",f.arg=S.arg,f.delegate=null,d;var _=S.arg;return _?_.done?(f[p.resultName]=_.value,f.next=p.nextLoc,f.method!=="return"&&(f.method="next",f.arg=void 0),f.delegate=null,d):_:(f.method="throw",f.arg=new TypeError("iterator result is not an object"),f.delegate=null,d)}function ee(p){var f={tryLoc:p[0]};1 in p&&(f.catchLoc=p[1]),2 in p&&(f.finallyLoc=p[2],f.afterLoc=p[3]),this.tryEntries.push(f)}function te(p){var f=p.completion||{};f.type="normal",delete f.arg,p.completion=f}function $(p){this.tryEntries=[{tryLoc:"root"}],p.forEach(ee,this),this.reset(!0)}function re(p){if(p||p===""){var f=p[o];if(f)return f.call(p);if(typeof p.next=="function")return p;if(!isNaN(p.length)){var l=-1,v=function S(){for(;++l<p.length;)if(e.call(p,l))return S.value=p[l],S.done=!1,S;return S.value=void 0,S.done=!0,S};return v.next=v}}throw new TypeError(gt(p)+" is not iterable")}return b.prototype=T,r(L,"constructor",{value:T,configurable:!0}),r(T,"constructor",{value:b,configurable:!0}),b.displayName=u(T,s,"GeneratorFunction"),t.isGeneratorFunction=function(p){var f=typeof p=="function"&&p.constructor;return!!f&&(f===b||(f.displayName||f.name)==="GeneratorFunction")},t.mark=function(p){return Object.setPrototypeOf?Object.setPrototypeOf(p,T):(p.__proto__=T,u(p,s,"GeneratorFunction")),p.prototype=Object.create(L),p},t.awrap=function(p){return{__await:p}},F(G.prototype),u(G.prototype,a,function(){return this}),t.AsyncIterator=G,t.async=function(p,f,l,v,S){S===void 0&&(S=Promise);var _=new G(c(p,f,l,v),S);return t.isGeneratorFunction(f)?_:_.next().then(function(E){return E.done?E.value:_.next()})},F(L),u(L,s,"Generator"),u(L,o,function(){return this}),u(L,"toString",function(){return"[object Generator]"}),t.keys=function(p){var f=Object(p),l=[];for(var v in f)l.push(v);return l.reverse(),function S(){for(;l.length;){var _=l.pop();if(_ in f)return S.value=_,S.done=!1,S}return S.done=!0,S}},t.values=re,$.prototype={constructor:$,reset:function(f){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(te),!f)for(var l in this)l.charAt(0)==="t"&&e.call(this,l)&&!isNaN(+l.slice(1))&&(this[l]=void 0)},stop:function(){this.done=!0;var f=this.tryEntries[0].completion;if(f.type==="throw")throw f.arg;return this.rval},dispatchException:function(f){if(this.done)throw f;var l=this;function v(ne,X){return E.type="throw",E.arg=f,l.next=ne,X&&(l.method="next",l.arg=void 0),!!X}for(var S=this.tryEntries.length-1;S>=0;--S){var _=this.tryEntries[S],E=_.completion;if(_.tryLoc==="root")return v("end");if(_.tryLoc<=this.prev){var I=e.call(_,"catchLoc"),N=e.call(_,"finallyLoc");if(I&&N){if(this.prev<_.catchLoc)return v(_.catchLoc,!0);if(this.prev<_.finallyLoc)return v(_.finallyLoc)}else if(I){if(this.prev<_.catchLoc)return v(_.catchLoc,!0)}else{if(!N)throw new Error("try statement without catch or finally");if(this.prev<_.finallyLoc)return v(_.finallyLoc)}}}},abrupt:function(f,l){for(var v=this.tryEntries.length-1;v>=0;--v){var S=this.tryEntries[v];if(S.tryLoc<=this.prev&&e.call(S,"finallyLoc")&&this.prev<S.finallyLoc){var _=S;break}}_&&(f==="break"||f==="continue")&&_.tryLoc<=l&&l<=_.finallyLoc&&(_=null);var E=_?_.completion:{};return E.type=f,E.arg=l,_?(this.method="next",this.next=_.finallyLoc,d):this.complete(E)},complete:function(f,l){if(f.type==="throw")throw f.arg;return f.type==="break"||f.type==="continue"?this.next=f.arg:f.type==="return"?(this.rval=this.arg=f.arg,this.method="return",this.next="end"):f.type==="normal"&&l&&(this.next=l),d},finish:function(f){for(var l=this.tryEntries.length-1;l>=0;--l){var v=this.tryEntries[l];if(v.finallyLoc===f)return this.complete(v.completion,v.afterLoc),te(v),d}},catch:function(f){for(var l=this.tryEntries.length-1;l>=0;--l){var v=this.tryEntries[l];if(v.tryLoc===f){var S=v.completion;if(S.type==="throw"){var _=S.arg;te(v)}return _}}throw new Error("illegal catch attempt")},delegateYield:function(f,l,v){return this.delegate={iterator:re(f),resultName:l,nextLoc:v},this.method==="next"&&(this.arg=void 0),d}},t}q.exports=vt,q.exports.__esModule=!0,q.exports.default=q.exports});var Te=qe((Jo,bt)=>{var Re=yt()();bt.exports=Re;try{regeneratorRuntime=Re}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Re:Function("r","regeneratorRuntime = r")(Re)}});var Ro={};Fr(Ro,{WebGPUBuffer:()=>Ve,WebGPUDevice:()=>lt,WebGPUSampler:()=>W,WebGPUShader:()=>Ye,WebGPUTexture:()=>$e});function V(t){return V=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},V(t)}function Je(t,n){if(V(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var r=e.call(t,n||"default");if(V(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function be(t){var n=Je(t,"string");return V(n)==="symbol"?n:String(n)}function x(t,n,e){return n=be(n),n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function ht(t,n,e,r,i,o,a){try{var s=t[o](a),u=s.value}catch(c){e(c);return}s.done?n(u):Promise.resolve(u).then(r,i)}function Y(t){return function(){var n=this,e=arguments;return new Promise(function(r,i){var o=t.apply(n,e);function a(u){ht(o,r,i,a,s,"next",u)}function s(u){ht(o,r,i,a,s,"throw",u)}a(void 0)})}}function m(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function dt(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,be(r.key),r)}}function g(t,n,e){return n&&dt(t.prototype,n),e&&dt(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function _e(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function we(t,n){return we=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},we(t,n)}function w(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&we(t,n)}function P(t,n){if(n&&(V(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _e(t)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(t)}var xe=Xe(Te(),1);function Qe(t){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let n=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,e=t||n;return!!(e&&e.indexOf("Electron")>=0)}function B(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||Qe()}var Wr=globalThis.self||globalThis.window||globalThis.global,fe=globalThis.window||globalThis.self||globalThis.global,zr=globalThis.document||{},ie=globalThis.process||{},Hr=globalThis.console,ti=globalThis.navigator||{};var Ee=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",oi=B();function Vr(t){try{let n=window[t],e="__storage_test__";return n.setItem(e,e),n.removeItem(e),n}catch{return null}}var Ae=class{constructor(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";this.storage=void 0,this.id=void 0,this.config=void 0,this.storage=Vr(r),this.id=n,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(n){if(Object.assign(this.config,n),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let n={};if(this.storage){let e=this.storage.getItem(this.id);n=e?JSON.parse(e):{}}return Object.assign(this.config,n),this}};function _t(t){let n;return t<10?n="".concat(t.toFixed(2),"ms"):t<100?n="".concat(t.toFixed(1),"ms"):t<1e3?n="".concat(t.toFixed(0),"ms"):n="".concat((t/1e3).toFixed(2),"s"),n}function wt(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,e=Math.max(n-t.length,0);return"".concat(" ".repeat(e)).concat(t)}function je(t,n,e){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,i=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>r&&(e=Math.min(e,r/t.width));let o=t.width*e,a=t.height*e,s=["font-size:1px;","padding:".concat(Math.floor(a/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(a,"px;"),"background:url(".concat(i,");"),"background-size:".concat(o,"px ").concat(a,"px;"),"color:transparent;"].join("");return["".concat(n," %c+"),s]}var Be;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Be||(Be={}));var $r=10;function Pt(t){return typeof t!="string"?t:(t=t.toUpperCase(),Be[t]||Be.WHITE)}function St(t,n,e){if(!B&&typeof t=="string"){if(n){let r=Pt(n);t="\x1B[".concat(r,"m").concat(t,"\x1B[39m")}if(e){let r=Pt(e);t="\x1B[".concat(r+$r,"m").concat(t,"\x1B[49m")}}return t}function Ot(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],e=Object.getPrototypeOf(t),r=Object.getOwnPropertyNames(e),i=t;for(let o of r){let a=i[o];typeof a=="function"&&(n.find(s=>o===s)||(i[o]=a.bind(t)))}}function le(t,n){if(!t)throw new Error(n||"Assertion failed")}function ae(){let t;if(B()&&fe.performance){var n,e;t=fe===null||fe===void 0||(n=fe.performance)===null||n===void 0||(e=n.now)===null||e===void 0?void 0:e.call(n)}else if("hrtime"in ie){var r;let i=ie===null||ie===void 0||(r=ie.hrtime)===null||r===void 0?void 0:r.call(ie);t=i[0]*1e3+i[1]/1e6}else t=Date.now();return t}var pe={debug:B()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Yr={enabled:!0,level:0};function U(){}var xt={},Ct={once:!0},J=class{constructor(){let{id:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=Ee,this._startTs=ae(),this._deltaTs=ae(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=n,this.userData={},this._storage=new Ae("__probe-".concat(this.id,"__"),Yr),this.timeStamp("".concat(this.id," started")),Ot(this),Object.seal(this)}set level(n){this.setLevel(n)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((ae()-this._startTs).toPrecision(10))}getDelta(){return Number((ae()-this._deltaTs).toPrecision(10))}set priority(n){this.level=n}get priority(){return this.level}getPriority(){return this.level}enable(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:n}),this}setLevel(n){return this._storage.setConfiguration({level:n}),this}get(n){return this._storage.config[n]}set(n,e){this._storage.setConfiguration({[n]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(n,e){le(n,e)}warn(n){return this._getLogFunction(0,n,pe.warn,arguments,Ct)}error(n){return this._getLogFunction(0,n,pe.error,arguments)}deprecated(n,e){return this.warn("`".concat(n,"` is deprecated and will be removed in a later version. Use `").concat(e,"` instead"))}removed(n,e){return this.error("`".concat(n,"` has been removed. Use `").concat(e,"` instead"))}probe(n,e){return this._getLogFunction(n,e,pe.log,arguments,{time:!0,once:!0})}log(n,e){return this._getLogFunction(n,e,pe.debug,arguments)}info(n,e){return this._getLogFunction(n,e,console.info,arguments)}once(n,e){return this._getLogFunction(n,e,pe.debug||pe.info,arguments,Ct)}table(n,e,r){return e?this._getLogFunction(n,e,console.table||U,r&&[r],{tag:Jr(e)}):U}image(n){let{logLevel:e,priority:r,image:i,message:o="",scale:a=1}=n;return this._shouldLog(e||r)?B()?Xr({image:i,message:o,scale:a}):qr({image:i,message:o,scale:a}):U}time(n,e){return this._getLogFunction(n,e,console.time?console.time:console.info)}timeEnd(n,e){return this._getLogFunction(n,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(n,e){return this._getLogFunction(n,e,console.timeStamp||U)}group(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},i=Rt({logLevel:n,message:e,opts:r}),{collapsed:o}=r;return i.method=(o?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(n,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(n,e,Object.assign({},r,{collapsed:!0}))}groupEnd(n){return this._getLogFunction(n,"",console.groupEnd||U)}withGroup(n,e,r){this.group(n,e)();try{r()}finally{this.groupEnd(n)()}}trace(){console.trace&&console.trace()}_shouldLog(n){return this.isEnabled()&&this.getLevel()>=Tt(n)}_getLogFunction(n,e,r,i,o){if(this._shouldLog(n)){o=Rt({logLevel:n,message:e,args:i,opts:o}),r=r||o.method,le(r),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=ae();let a=o.tag||o.message;if(o.once&&a)if(!xt[a])xt[a]=ae();else return U;return e=Kr(this.id,o.message,o),r.bind(console,e,...o.args)}return U}};J.VERSION=Ee;function Tt(t){if(!t)return 0;let n;switch(typeof t){case"number":n=t;break;case"object":n=t.logLevel||t.priority||0;break;default:return 0}return le(Number.isFinite(n)&&n>=0),n}function Rt(t){let{logLevel:n,message:e}=t;t.logLevel=Tt(n);let r=t.args?Array.from(t.args):[];for(;r.length&&r.shift()!==e;);switch(typeof n){case"string":case"function":e!==void 0&&r.unshift(e),t.message=n;break;case"object":Object.assign(t,n);break;default:}typeof t.message=="function"&&(t.message=t.message());let i=typeof t.message;return le(i==="string"||i==="object"),Object.assign(t,{args:r},t.opts)}function Kr(t,n,e){if(typeof n=="string"){let r=e.time?wt(_t(e.total)):"";n=e.time?"".concat(t,": ").concat(r," ").concat(n):"".concat(t,": ").concat(n),n=St(n,e.color,e.background)}return n}function qr(t){let{image:n,message:e="",scale:r=1}=t;return console.warn("removed"),U}function Xr(t){let{image:n,message:e="",scale:r=1}=t;if(typeof n=="string"){let o=new Image;return o.onload=()=>{let a=je(o,e,r);console.log(...a)},o.src=n,U}let i=n.nodeName||"";if(i.toLowerCase()==="img")return console.log(...je(n,e,r)),U;if(i.toLowerCase()==="canvas"){let o=new Image;return o.onload=()=>console.log(...je(o,e,r)),o.src=n.toDataURL(),U}return U}function Jr(t){for(let n in t)for(let e in t[n])return e||"untitled";return"empty"}var Ei=new J({id:"@probe.gl/log"});var C=new J({id:"luma.gl"});function Pe(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let n=process.hrtime();t=n[0]*1e3+n[1]/1e6}else t=Date.now();return t}var se=class{constructor(n,e){this.name=void 0,this.type=void 0,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=n,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(n){return this.sampleSize=n,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(n){return this._count+=n,this._samples++,this._checkSampling(),this}subtractCount(n){return this._count-=n,this._samples++,this._checkSampling(),this}addTime(n){return this._time+=n,this.lastTiming=n,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Pe(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Pe()-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 he=class{constructor(n){this.id=void 0,this.stats={},this.id=n.id,this.stats={},this._initializeStats(n.stats),Object.seal(this)}get(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"count";return this._getOrCreate({name:n,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let n of Object.values(this.stats))n.reset();return this}forEach(n){for(let e of Object.values(this.stats))n(e)}getTable(){let n={};return this.forEach(e=>{n[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),n}_initializeStats(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(e=>this._getOrCreate(e))}_getOrCreate(n){let{name:e,type:r}=n,i=this.stats[e];return i||(n instanceof se?i=n:i=new se(e,r),this.stats[e]=i),i}};var Zr=function(){function t(){m(this,t),this.stats=new Map}var n=t.prototype;return n.getStats=function(r){return this.get(r)},n.get=function(r){return this.stats.has(r)||this.stats.set(r,new he({id:r})),this.stats.get(r)},g(t)}(),De=new Zr;function Qr(){var t=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",n="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==t)throw new Error("luma.gl - multiple VERSIONs detected: ".concat(globalThis.luma.VERSION," vs ").concat(t));return globalThis.luma||(B()&&C.log(1,"luma.gl ".concat(t," - ").concat(n))(),globalThis.luma=globalThis.luma||{VERSION:t,version:t,log:C,stats:De}),t}var Et=Qr();var et={};function ue(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";et[t]=et[t]||1;var n=et[t]++;return"".concat(t,"-").concat(n)}function Ie(t){var n=!0;for(var e in t){n=!1;break}return n}function At(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function en(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?At(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):At(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var R=function(){function t(e,r,i){if(m(this,t),this.id=void 0,this.props=void 0,this.userData={},this.device=void 0,this._device=void 0,this.destroyed=!1,this.allocatedBytes=0,this._attachedResources=new Set,!e)throw new Error("no device");this._device=e,this.props=tn(r,i);var o=this.props.id!=="undefined"?this.props.id:ue(this[Symbol.toStringTag]);this.props.id=o,this.id=o,this.userData=this.props.userData||{},this.addStats()}var n=t.prototype;return n.destroy=function(){this.destroyResource()},n.delete=function(){return this.destroy(),this},n.toString=function(){return"".concat(this[Symbol.toStringTag]||this.constructor.name,"(").concat(this.id,")")},n.getProps=function(){return this.props},n.attachResource=function(r){this._attachedResources.add(r)},n.detachResource=function(r){this._attachedResources.delete(r)},n.destroyAttachedResource=function(r){this._attachedResources.delete(r)&&r.destroy()},n.destroyAttachedResources=function(){for(var r=0,i=Object.values(this._attachedResources);r<i.length;r++){var o=i[r];o.destroy()}this._attachedResources=new Set},n.destroyResource=function(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0},n.removeStats=function(){var r=this._device.statsManager.getStats("Resource Counts"),i=this[Symbol.toStringTag];r.get("".concat(i,"s Active")).decrementCount()},n.trackAllocatedMemory=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[Symbol.toStringTag],o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(r),o.get("".concat(i," Memory")).addCount(r),this.allocatedBytes=r},n.trackDeallocatedMemory=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this[Symbol.toStringTag],i=this._device.statsManager.getStats("Resource Counts");i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get("".concat(r," Memory")).subtractCount(this.allocatedBytes),this.allocatedBytes=0},n.addStats=function(){var r=this._device.statsManager.getStats("Resource Counts"),i=this[Symbol.toStringTag];r.get("Resources Created").incrementCount(),r.get("".concat(i,"s Created")).incrementCount(),r.get("".concat(i,"s Active")).incrementCount()},g(t)}();R.defaultProps={id:"undefined",handle:void 0,userData:void 0};function tn(t,n){var e=en({},n);for(var r in t)t[r]!==void 0&&(e[r]=t[r]);return e}var Bt;function jt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function tt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?jt(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):jt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function rn(t){var n=nn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function nn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Bt=Symbol.toStringTag;var A=function(t){w(e,t);var n=rn(e);function e(i,o){var a;m(this,e);var s=tt({},o);return(o.usage||0)&e.INDEX&&!o.indexType&&(o.data instanceof Uint32Array?s.indexType="uint32":o.data instanceof Uint16Array&&(s.indexType="uint16")),a=n.call(this,i,s,e.defaultProps),a.usage=void 0,a.indexType=void 0,a.byteLength=void 0,a.usage=o.usage||0,a.indexType=s.indexType,a}var r=e.prototype;return r.write=function(o,a){throw new Error("not implemented")},r.readAsync=function(o,a){throw new Error("not implemented")},r.getData=function(){throw new Error("not implemented")},g(e,[{key:Bt,get:function(){return"Buffer"}}]),e}(R);A.defaultProps=tt(tt({},R.defaultProps),{},{usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1});A.MAP_READ=1;A.MAP_WRITE=2;A.COPY_SRC=4;A.COPY_DST=8;A.INDEX=16;A.VERTEX=32;A.UNIFORM=64;A.STORAGE=128;A.INDIRECT=256;A.QUERY_RESOLVE=512;var It;function Dt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function rt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Dt(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Dt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var on={id:null,type:"best-available",canvas:null,container:null,webgl2:!0,webgl1:!0,manageState:!0,width:800,height:600,debug:Boolean(C.get("debug")),break:[],gl:null};It=Symbol.toStringTag;var Ge=function(){function t(e){m(this,t),this.id=void 0,this.statsManager=De,this.props=void 0,this.userData={},this._lumaData={},this.info=void 0,this.lost=void 0,this.canvasContext=void 0,this.props=rt(rt({},on),e),this.id=this.props.id||ue(this[Symbol.toStringTag].toLowerCase())}var n=t.prototype;return n.loseDevice=function(){return!1},n.createTexture=function(r){return(r instanceof Promise||typeof r=="string")&&(r={data:r}),this._createTexture(r)},n.createCommandEncoder=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};throw new Error("not implemented")},n._getBufferProps=function(r){(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});var i=rt({},r);return(r.usage||0)&A.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?i.indexType="uint32":r.data instanceof Uint16Array?i.indexType="uint16":C.warn("indices buffer content must be of integer type")()),i},g(t,[{key:It,get:function(){return"Device"}}]),t}();Ge.VERSION=Et;function nt(t){if(Array.isArray(t))return t}function ot(t,n){var e=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(e!=null){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(e=e.call(t)).next,n===0){if(Object(e)!==e)return;u=!1}else for(;!(u=(r=o.call(e)).done)&&(s.push(r.value),s.length!==n);u=!0);}catch(y){c=!0,i=y}finally{try{if(!u&&e.return!=null&&(a=e.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function Ne(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function it(t,n){if(t){if(typeof t=="string")return Ne(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Ne(t,n)}}function at(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function j(t,n){return nt(t)||ot(t,n)||it(t,n)||at()}function an(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=sn(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
9
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,s;return{s:function(){e=e.call(t)},n:function(){var c=e.next();return o=c.done,c},e:function(c){a=!0,s=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function sn(t,n){if(t){if(typeof t=="string")return Gt(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Gt(t,n)}}function Gt(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function Nt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Mt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Nt(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Nt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var un=B()&&typeof document<"u",Me=function(){return un&&document.readyState==="complete"},cn={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},de=function(){function t(e){var r=this;if(m(this,t),this.device=void 0,this.id=void 0,this.props=void 0,this.canvas=void 0,this.htmlCanvas=void 0,this.offscreenCanvas=void 0,this.type=void 0,this.width=1,this.height=1,this.resizeObserver=void 0,this._canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1},this.props=Mt(Mt({},cn),e),e=this.props,!B()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=pn(e.canvas):this.canvas=e.canvas;else{var i,o,a=hn(e),s=ln(((i=e)===null||i===void 0?void 0:i.container)||null);s.insertBefore(a,s.firstChild),this.canvas=a,(o=e)!==null&&o!==void 0&&o.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(function(u){var c=an(u),y;try{for(c.s();!(y=c.n()).done;){var d=y.value;d.target===r.canvas&&r.update()}}catch(O){c.e(O)}finally{c.f()}}),this.resizeObserver.observe(this.canvas))}var n=t.prototype;return n.getDevicePixelRatio=function(r){if(typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(r=r===void 0?this.props.useDevicePixels:r,!r||r<=0))return 1;if(r===!0){var i=typeof window<"u"&&window.devicePixelRatio;return i||1}return r},n.getPixelSize=function(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":var r=this.getDevicePixelRatio(),i=this.canvas;return i.parentElement?[i.clientWidth*r,i.clientHeight*r]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}},n.getAspect=function(){var r=this.getPixelSize(),i=j(r,2),o=i[0],a=i[1];return o/a},n.cssToDeviceRatio=function(){try{var r=this.getDrawingBufferSize(),i=j(r,1),o=i[0],a=this._canvasSizeInfo.clientWidth;return a?o/a:1}catch{return 1}},n.cssToDevicePixels=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,o=this.cssToDeviceRatio(),a=this.getDrawingBufferSize(),s=j(a,2),u=s[0],c=s[1];return dn(r,o,u,c,i)},n.setDevicePixelRatio=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.htmlCanvas){var o="width"in i?i.width:this.htmlCanvas.clientWidth,a="height"in i?i.height:this.htmlCanvas.clientHeight;(!o||!a)&&(C.log(1,"Canvas clientWidth/clientHeight is 0")(),r=1,o=this.htmlCanvas.width||1,a=this.htmlCanvas.height||1);var s=this._canvasSizeInfo;if(s.clientWidth!==o||s.clientHeight!==a||s.devicePixelRatio!==r){var u=r,c=Math.floor(o*u),y=Math.floor(a*u);this.htmlCanvas.width=c,this.htmlCanvas.height=y;var d=this.getDrawingBufferSize(),O=j(d,2),b=O[0],T=O[1];(b!==c||T!==y)&&(u=Math.min(b/o,T/a),this.htmlCanvas.width=Math.floor(o*u),this.htmlCanvas.height=Math.floor(a*u),C.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=o,this._canvasSizeInfo.clientHeight=a,this._canvasSizeInfo.devicePixelRatio=r}}},n.getDrawingBufferSize=function(){var r=this.device.gl;if(!r)throw new Error("canvas size");return[r.drawingBufferWidth,r.drawingBufferHeight]},n._setAutoCreatedCanvasId=function(r){var i;((i=this.htmlCanvas)===null||i===void 0?void 0:i.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=r)},g(t,null,[{key:"isPageLoaded",get:function(){return Me()}}]),t}();de.pageLoaded=fn();function fn(){return Me()||typeof window>"u"?Promise.resolve():new Promise(function(t){window.addEventListener("load",function(){return t()})})}function ln(t){if(typeof t=="string"){var n=document.getElementById(t);if(!n&&!Me())throw new Error("Accessing '".concat(t,"' before page was loaded"));if(!n)throw new Error("".concat(t," is not an HTML element"));return n}else if(t)return t;return document.body}function pn(t){var n=document.getElementById(t);if(!n&&!Me())throw new Error("Accessing '".concat(t,"' before page was loaded"));if(!(n instanceof HTMLCanvasElement))throw new Error("'".concat(n,"' is not a canvas element"));return n}function hn(t){var n=t.width,e=t.height,r=document.createElement("canvas");return r.id="lumagl-auto-created-canvas",r.width=n||1,r.height=e||1,r.style.width=Number.isFinite(n)?"".concat(n,"px"):"100%",r.style.height=Number.isFinite(e)?"".concat(e,"px"):"100%",r}function dn(t,n,e,r,i){var o=t,a=Lt(o[0],n,e),s=kt(o[1],n,r,i),u=Lt(o[0]+1,n,e),c=u===e-1?u:u-1;u=kt(o[1]+1,n,r,i);var y;return i?(u=u===0?u:u+1,y=s,s=u):y=u===r-1?u:u-1,{x:a,y:s,width:Math.max(c-a+1,1),height:Math.max(y-s+1,1)}}function Lt(t,n,e){var r=Math.min(Math.round(t*n),e-1);return r}function kt(t,n,e,r){return r?Math.max(0,e-1-Math.round(t*n)):Math.min(Math.round(t*n),e-1)}var Wt;function Ft(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Ut(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Ft(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Ft(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function mn(t){var n=gn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function gn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Wt=Symbol.toStringTag;var M=function(t){w(e,t);var n=mn(e);function e(r,i){var o,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.defaultProps;return m(this,e),o=n.call(this,r,i,a),o.dimension=void 0,o.format=void 0,o.width=void 0,o.height=void 0,o.depth=void 0,o.sampler=void 0,o.dimension=o.props.dimension,o.format=o.props.format,o.width=o.props.width,o.height=o.props.height,o.depth=o.props.depth,o}return g(e,[{key:Wt,get:function(){return"Texture"}}]),e}(R);M.defaultProps=Ut(Ut({},R.defaultProps),{},{data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,sampler:{},compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0});M.COPY_SRC=1;M.COPY_DST=2;M.TEXTURE_BINDING=4;M.STORAGE_BINDING=8;M.RENDER_ATTACHMENT=16;var Vt;function zt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Ht(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?zt(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):zt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function vn(t){var n=yn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function yn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Vt=Symbol.toStringTag;var Le=function(t){w(e,t);var n=vn(e);function e(r,i){return m(this,e),n.call(this,r,i,e.defaultProps)}return g(e,[{key:Vt,get:function(){return"ExternalTexture"}}]),e}(R);Le.defaultProps=Ht(Ht({},R.defaultProps),{},{source:null,colorSpace:"srgb"});var Kt;function $t(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Yt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?$t(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):$t(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function bn(t){var n=_n();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function _n(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Kt=Symbol.toStringTag;var ke=function(t){w(e,t);var n=bn(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i,e.defaultProps),o.stage=void 0,o.source=void 0,o.stage=o.props.stage,o.source=o.props.source,o}return g(e,[{key:Kt,get:function(){return"Shader"}}]),e}(R);ke.defaultProps=Yt(Yt({},R.defaultProps),{},{stage:"vertex",source:"",sourceMap:null,language:"glsl",shaderType:0});var Jt;function qt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Xt(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?qt(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):qt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function wn(t){var n=Pn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Pn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Jt=Symbol.toStringTag;var me=function(t){w(e,t);var n=wn(e);function e(r,i){return m(this,e),n.call(this,r,i,e.defaultProps)}return g(e,[{key:Jt,get:function(){return"Sampler"}}]),e}(R);me.defaultProps=Xt(Xt({},R.defaultProps),{},{type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var Qt;function Zt(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function ge(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Zt(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Zt(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Sn(t){var n=On();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function On(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Qt=Symbol.toStringTag;var Fe=function(t){w(e,t);var n=Sn(e);function e(i){var o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return m(this,e),o=n.call(this,i,a,e.defaultProps),o.width=void 0,o.height=void 0,o.colorAttachments=[],o.depthStencilAttachment=null,o.width=o.props.width,o.height=o.props.height,o}var r=e.prototype;return r.resize=function(o){var a=!o;if(o){var s=Array.isArray(o)?o:[o.width,o.height],u=j(s,2),c=u[0],y=u[1];a=a||y!==this.height||c!==this.width,this.width=c,this.height=y}a&&(C.log(2,"Resizing framebuffer ".concat(this.id," to ").concat(this.width,"x").concat(this.height))(),this.resizeAttachments(this.width,this.height))},r.autoCreateAttachmentTextures=function(){var o=this;if(this.colorAttachments=this.props.colorAttachments.map(function(s){if(typeof s=="string"){var u=o.createColorTexture(s);return o.attachResource(u),u}return s}),this.props.depthStencilAttachment)if(typeof this.props.depthStencilAttachment=="string"){var a=this.createDepthStencilTexture(this.props.depthStencilAttachment);this.attachResource(a),this.depthStencilAttachment=a}else this.depthStencilAttachment=this.props.depthStencilAttachment},r.createColorTexture=function(o){return this.device.createTexture({id:"color-attachment",usage:M.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})},r.createDepthStencilTexture=function(o){return this.device.createTexture({id:"depth-stencil-attachment",usage:M.RENDER_ATTACHMENT,format:o,width:this.width,height:this.height})},r.resizeAttachments=function(o,a){for(var s=0;s<this.colorAttachments.length;++s)if(this.colorAttachments[s]){var u=this.device._createTexture(ge(ge({},this.colorAttachments[s].props),{},{width:o,height:a}));this.destroyAttachedResource(this.colorAttachments[s]),this.colorAttachments[s]=u,this.attachResource(u)}if(this.depthStencilAttachment){var c=this.device._createTexture(ge(ge({},this.depthStencilAttachment.props),{},{width:o,height:a}));this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=c,this.attachResource(c)}},g(e,[{key:Qt,get:function(){return"Framebuffer"}}]),e}(R);Fe.defaultProps=ge(ge({},R.defaultProps),{},{width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var rr;function er(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function tr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?er(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):er(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function xn(t){var n=Cn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Cn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}rr=Symbol.toStringTag;var Ue=function(t){w(e,t);var n=xn(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i,e.defaultProps),o.hash="",o.vs=void 0,o.fs=void 0,o}return g(e,[{key:rr,get:function(){return"RenderPipeline"}}]),e}(R);Ue.defaultProps=tr(tr({},R.defaultProps),{},{vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,indices:null,attributes:{},bindings:{},uniforms:{}});var ir;function nr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function or(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?nr(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):nr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Rn(t){var n=Tn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Tn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}ir=Symbol.toStringTag;var We=function(t){w(e,t);var n=Rn(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i,e.defaultProps),o.hash="",o}return g(e,[{key:ir,get:function(){return"ComputePipeline"}}]),e}(R);We.defaultProps=or(or({},R.defaultProps),{},{cs:void 0,csEntryPoint:void 0,csConstants:{},shaderLayout:[]});var ur;function ar(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function sr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?ar(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):ar(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function En(t){var n=An();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function An(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}ur=Symbol.toStringTag;var ze=function(t){w(e,t);var n=En(e);function e(r,i){return m(this,e),n.call(this,r,i,e.defaultProps)}return g(e,[{key:ur,get:function(){return"RenderPass"}}]),e}(R);ze.defaultProps=sr(sr({},R.defaultProps),{},{framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1});var fr;function cr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function jn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?cr(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):cr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Bn(t){var n=Dn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Dn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}fr=Symbol.toStringTag;var He=function(t){w(e,t);var n=Bn(e);function e(r,i){return m(this,e),n.call(this,r,i,R.defaultProps)}return g(e,[{key:fr,get:function(){return"ComputePass"}}]),e}(R);He.defaultProps=jn({},R.defaultProps);function pr(t){var n=lr[t],e=In(n),r=t.includes("norm"),i=!r&&!t.startsWith("float"),o=t.startsWith("s");return{dataType:lr[t],byteLength:e,integer:i,signed:o,normalized:r}}function In(t){var n=Gn[t];return n}var lr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Gn={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Z(t){var n;t.endsWith("-webgl")&&(t.replace("-webgl",""),n=!0);var e=t.split("x"),r=j(e,2),i=r[0],o=r[1],a=i,s=o?parseInt(o):1,u=pr(a),c={type:a,components:s,byteLength:u.byteLength*s,integer:u.integer,signed:u.signed,normalized:u.normalized};return n&&(c.webglOnly=!0),c}function hr(t){var n=j(Mn[t],2),e=n[0],r=n[1],i=e==="i32"||e==="u32",o=e!=="u32",a=Ln[e]*r,s=Nn(e,r);return{dataType:e,components:r,defaultVertexFormat:s,byteLength:a,integer:i,signed:o}}function Nn(t,n){var e;switch(t){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return n<=2?"float16x2":"float16x4"}return n===1?e:"".concat(e,"x").concat(n)}var Mn={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Ln={f32:4,f16:2,i32:4,u32:4};function Se(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=kn(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
10
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,s;return{s:function(){e=e.call(t)},n:function(){var c=e.next();return o=c.done,c},e:function(c){a=!0,s=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function kn(t,n){if(t){if(typeof t=="string")return dr(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return dr(t,n)}}function dr(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function st(t,n){var e={},r=Se(t.attributes),i;try{for(r.s();!(i=r.n()).done;){var o=i.value;e[o.name]=Fn(t,n,o.name)}}catch(a){r.e(a)}finally{r.f()}return e}function Fn(t,n,e){var r=Un(t,e),i=Wn(n,e);if(!r)return null;var o=hr(r.type),a=i?.vertexFormat||o.defaultVertexFormat,s=Z(a);return{attributeName:i?.attributeName||r.name,bufferName:i?.bufferName||r.name,location:r.location,shaderType:r.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:a,bufferDataType:s.type,bufferComponents:s.components,normalized:s.normalized,integer:o.integer,stepMode:i?.stepMode||r.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function Un(t,n){var e=t.attributes.find(function(r){return r.name===n});return e||C.warn('shader layout attribute "'.concat(n,'" not present in shader')),e||null}function Wn(t,n){zn(t);var e=Hn(t,n);return e||(e=Vn(t,n),e)?e:(C.warn('layout for attribute "'.concat(n,'" not present in buffer layout')),null)}function zn(t){var n=Se(t),e;try{for(n.s();!(e=n.n()).done;){var r=e.value;(r.attributes&&r.format||!r.attributes&&!r.format)&&C.warn("BufferLayout ".concat(name," must have either 'attributes' or 'format' field"))}}catch(i){n.e(i)}finally{n.f()}}function Hn(t,n){var e=Se(t),r;try{for(e.s();!(r=e.n()).done;){var i=r.value;if(i.format&&i.name===n)return{attributeName:i.name,bufferName:n,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0}}}catch(o){e.e(o)}finally{e.f()}return null}function Vn(t,n){var e=Se(t),r;try{for(e.s();!(r=e.n()).done;){var i,o=r.value,a=o.byteStride;if(typeof o.byteStride!="number"){var s=Se(o.attributes||[]),u;try{for(s.s();!(u=s.n()).done;){var c=u.value,y=Z(c.format);a+=y.byteLength}}catch(O){s.e(O)}finally{s.f()}}var d=(i=o.attributes)===null||i===void 0?void 0:i.find(function(O){return O.attribute===n});if(d)return{attributeName:d.attribute,bufferName:o.name,stepMode:o.stepMode,vertexFormat:d.format,byteOffset:d.byteOffset,byteStride:a}}}catch(O){e.e(O)}finally{e.f()}return null}var ut=Xe(Te(),1);function $n(t){var n=Yn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Yn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Kn(t){var n;return t.byteLength||((n=t.data)===null||n===void 0?void 0:n.byteLength)||0}var Ve=function(t){w(e,t);var n=$n(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.byteLength=void 0,a.device=i,a.byteLength=Kn(o);var s=Boolean(o.data);return a.handle=a.props.handle||a.device.handle.createBuffer({size:a.byteLength,usage:a.props.usage||GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:a.props.mappedAtCreation||s,label:a.props.id}),o.data&&a._writeMapped(o.data),s&&!o.mappedAtCreation&&a.handle.unmap(),a}var r=e.prototype;return r.destroy=function(){this.handle.destroy()},r.write=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.device.handle.queue.writeBuffer(this.handle,a,o.buffer,o.byteOffset,o.byteLength)},r.readAsync=function(){var i=Y(ut.default.mark(function a(){var s,u,c,y,d,O=arguments;return ut.default.wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return s=O.length>0&&O[0]!==void 0?O[0]:0,u=O.length>1&&O[1]!==void 0?O[1]:this.byteLength,c=new e(this.device,{usage:A.MAP_READ|A.COPY_DST,byteLength:u}),y=this.device.handle.createCommandEncoder(),y.copyBufferToBuffer(this.handle,s,c.handle,0,u),this.device.handle.queue.submit([y.finish()]),T.next=8,c.handle.mapAsync(GPUMapMode.READ,s,u);case 8:return d=c.handle.getMappedRange().slice(0),c.handle.unmap(),c.destroy(),T.abrupt("return",d);case 12:case"end":return T.stop()}},a,this)}));function o(){return i.apply(this,arguments)}return o}(),r._writeMapped=function(o){var a=this.handle.getMappedRange();new o.constructor(a).set(o)},r.mapAsync=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2?arguments[2]:void 0;return this.handle.mapAsync(o,a,s)},r.getMappedRange=function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,a=arguments.length>1?arguments[1]:void 0;return this.handle.getMappedRange(o,a)},r.unmap=function(){this.handle.unmap()},g(e)}(A);function ve(t){if(t.includes("webgl"))throw new Error("webgl-only format");return t}function mr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function qn(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?mr(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):mr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function Xn(t){var n=Jn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Jn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var W=function(t){w(e,t);var n=Xn(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i;var s=qn({},a.props);return s.type!=="comparison-sampler"&&delete s.compare,a.handle=a.handle||a.device.handle.createSampler(s),a.handle.label=a.props.id,a}var r=e.prototype;return r.destroy=function(){},g(e)}(me);function Zn(t){var n=Qn();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Qn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var eo={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},$e=function(t){w(e,t);var n=Zn(e);function e(i,o){var a;if(m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.view=void 0,a.sampler=void 0,a.height=void 0,a.width=void 0,typeof a.props.format=="number")throw new Error("number format");return a.device=i,a.handle=a.props.handle||a.createHandle(),a.props.data&&a.setData({data:a.props.data}),a.width=a.handle.width,a.height=a.handle.height,a.sampler=o.sampler instanceof W?o.sampler:new W(a.device,o.sampler),a.view=a.handle.createView({}),a}var r=e.prototype;return r.createHandle=function(){var o,a;if(typeof this.props.format=="number")throw new Error("number format");var s=this.props.width||((o=this.props.data)===null||o===void 0?void 0:o.width)||1,u=this.props.height||((a=this.props.data)===null||a===void 0?void 0:a.height)||1;return this.device.handle.createTexture({size:{width:s,height:u,depthOrArrayLayers:this.props.depth},dimension:eo[this.props.dimension],format:ve(this.props.format),usage:this.props.usage,mipLevelCount:this.props.mipLevels,sampleCount:this.props.samples})},r.destroy=function(){this.handle.destroy()},r.setSampler=function(o){return this.sampler=o instanceof W?o:new W(this.device,o),this},r.setData=function(o){return this.setImage({source:o.data})},r.setImage=function(o){var a=o.source,s=o.width,u=s===void 0?o.source.width:s,c=o.height,y=c===void 0?o.source.height:c,d=o.depth,O=d===void 0?1:d,b=o.sourceX,T=b===void 0?0:b,k=o.sourceY,H=k===void 0?0:k,D=o.mipLevel,L=D===void 0?0:D,F=o.x,G=F===void 0?0:F,Q=o.y,ce=Q===void 0?0:Q,ee=o.z,te=ee===void 0?0:ee,$=o.aspect,re=$===void 0?"all":$,p=o.colorSpace,f=p===void 0?"srgb":p,l=o.premultipliedAlpha,v=l===void 0?!1:l;return this.device.handle.queue.copyExternalImageToTexture({source:a,origin:[T,H]},{texture:this.handle,origin:[G,ce,te],mipLevel:L,aspect:re,colorSpace:f,premultipliedAlpha:v},[u,y,O]),{width:u,height:y}},g(e)}(M);function to(t){var n=ro();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function ro(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var gr=function(t){w(e,t);var n=to(e);function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.sampler=void 0,a.device=i,a.handle=a.props.handle||a.device.handle.importExternalTexture({source:o.source,colorSpace:o.colorSpace}),a.sampler=null,a}var r=e.prototype;return r.destroy=function(){},r.setSampler=function(o){return this.sampler=o instanceof W?o:new W(this.device,o),this},g(e)}(Le);var Oe=Xe(Te(),1);function no(t){var n=oo();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function oo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=function(t){w(e,t);var n=no(e);function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i,a.device.handle.pushErrorScope("validation"),a.handle=a.props.handle||a.createHandle(),a.handle.label=a.props.id,a._checkCompilationError(a.device.handle.popErrorScope()),a}var r=e.prototype;return r._checkCompilationError=function(){var i=Y(Oe.default.mark(function a(s){var u,c;return Oe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,s;case 2:if(u=d.sent,!u){d.next=9;break}return d.next=6,this.compilationInfo();case 6:throw c=d.sent,C.error("Shader compilation error: ".concat(u.message),c)(),new Error("Shader compilation error: ".concat(u.message));case 9:case"end":return d.stop()}},a,this)}));function o(a){return i.apply(this,arguments)}return o}(),r.destroy=function(){},r.createHandle=function(){var o=this,a=this.props,s=a.source,u=a.stage,c=this.props.language;switch(c||(c=s.includes("->")?"wgsl":"glsl"),c){case"wgsl":return this.device.handle.createShaderModule({code:s});case"glsl":return this.device.handle.createShaderModule({code:s,transform:function(d){return o.device.glslang.compileGLSL(d,u)}});default:throw new Error(c)}},r.compilationInfo=function(){var i=Y(Oe.default.mark(function a(){var s;return Oe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.handle.getCompilationInfo();case 2:return s=c.sent,c.abrupt("return",s.messages);case 4:case"end":return c.stop()}},a,this)}));function o(){return i.apply(this,arguments)}return o}(),g(e)}(ke);function vr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function yr(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?vr(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):vr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function z(t){return t.depthStencil=t.depthStencil||{format:"depth24plus",stencilFront:{},stencilBack:{},depthWriteEnabled:void 0,depthCompare:void 0},t.depthStencil}var io={cullMode:function(n,e,r){r.primitive=r.primitive||{},r.primitive.cullMode=e},frontFace:function(n,e,r){r.primitive=r.primitive||{},r.primitive.frontFace=e},depthWriteEnabled:function(n,e,r){var i=z(r);i.depthWriteEnabled=e},depthCompare:function(n,e,r){var i=z(r);i.depthCompare=e},depthFormat:function(n,e,r){var i=z(r);i.format=e},depthBias:function(n,e,r){var i=z(r);i.depthBias=e},depthBiasSlopeScale:function(n,e,r){var i=z(r);i.depthBiasSlopeScale=e},depthBiasClamp:function(n,e,r){var i=z(r);i.depthBiasClamp=e},stencilReadMask:function(n,e,r){var i=z(r);i.stencilReadMask=e},stencilWriteMask:function(n,e,r){var i=z(r);i.stencilWriteMask=e},stencilCompare:function(n,e,r){var i=z(r);i.stencilFront.compare=e,i.stencilBack.compare=e},stencilPassOperation:function(n,e,r){var i=z(r);i.stencilFront.passOp=e,i.stencilBack.passOp=e},stencilFailOperation:function(n,e,r){var i=z(r);i.stencilFront.failOp=e,i.stencilBack.failOp=e},stencilDepthFailOperation:function(n,e,r){var i=z(r);i.stencilFront.depthFailOp=e,i.stencilBack.depthFailOp=e},sampleCount:function(n,e,r){r.multisample=r.multisample||{},r.multisample.count=e},sampleMask:function(n,e,r){r.multisample=r.multisample||{},r.multisample.mask=e},sampleAlphaToCoverageEnabled:function(n,e,r){r.multisample=r.multisample||{},r.multisample.alphaToCoverageEnabled=e},colorMask:function(n,e,r){var i=br(r);i[0].writeMask=e},blendColorOperation:function(n,e,r){br(r)}},ao={primitive:{cullMode:"back",topology:"triangle-list"},vertex:{module:void 0,entryPoint:"main"},fragment:{module:void 0,entryPoint:"main",targets:[]},layout:"auto"};function _r(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Object.assign(t,yr(yr({},ao),t)),so(t,n)}function so(t,n){for(var e=0,r=Object.entries(n);e<r.length;e++){var i=j(r[e],2),o=i[0],a=i[1],s=io[o];if(!s)throw new Error("Illegal parameter ".concat(o));s(o,a,t)}}function br(t){var n,e,r,i;if(t.fragment.targets=((n=t.fragment)===null||n===void 0?void 0:n.targets)||[],!Array.isArray((e=t.fragment)===null||e===void 0?void 0:e.targets))throw new Error("colorstate");if(((r=t.fragment)===null||r===void 0||(r=r.targets)===null||r===void 0?void 0:r.length)===0){var o;(o=t.fragment.targets)===null||o===void 0||o.push({})}return(i=t.fragment)===null||i===void 0?void 0:i.targets}function wr(t,n,e,r){var i=co(r,e);return t.createBindGroup({layout:n,entries:i})}function uo(t,n){var e=t.bindings.find(function(r){return r.name===n});return e||C.warn("Binding ".concat(n," not set: Not found in shader layout."))(),e}function co(t,n){for(var e=[],r=0,i=Object.entries(t);r<i.length;r++){var o=j(i[r],2),a=o[0],s=o[1],u=uo(n,a);u&&e.push(fo(s,u.location))}return e}function fo(t,n){if(t instanceof A)return{binding:n,resource:{buffer:t.handle}};if(t instanceof me)return{binding:n,resource:t.handle};if(t instanceof M)return{binding:n,resource:t.handle.createView()};throw new Error("invalid binding")}function ye(t,n){var e=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=lo(t))||n&&t&&typeof t.length=="number"){e&&(t=e);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
11
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,a=!1,s;return{s:function(){e=e.call(t)},n:function(){var c=e.next();return o=c.done,c},e:function(c){a=!0,s=c},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(a)throw s}}}}function lo(t,n){if(t){if(typeof t=="string")return Pr(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return Pr(t,n)}}function Pr(t,n){(n==null||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function ct(t){if(t.endsWith("-webgl"))throw new Error("WebGPU does not support vertex format ".concat(t));return t}function Or(t,n){var e=st(t,n),r=[],i=new Set,o=ye(n),a;try{for(o.s();!(a=o.n()).done;){var s=a.value,u=[],c="vertex",y=0;if(s.attributes){var d=ye(s.attributes),O;try{for(d.s();!(O=d.n()).done;){var b=O.value,T=b.attribute,k=Sr(t,T,i);c=k.stepMode||"vertex",u.push({format:ct(b.format||s.format),offset:b.byteOffset,shaderLocation:k.location}),y+=Z(s.format).byteLength}}catch(G){d.e(G)}finally{d.f()}}else{var H=Sr(t,s.name,i);y=Z(s.format).byteLength,c=H.stepMode||"vertex",u.push({format:ct(s.format),offset:0,shaderLocation:H.location})}r.push({arrayStride:s.byteStride||y,stepMode:c||"vertex",attributes:u})}}catch(G){o.e(G)}finally{o.f()}var D=ye(t.attributes),L;try{for(D.s();!(L=D.n()).done;){var F=L.value;i.has(F.name)||r.push({arrayStride:Z("float32x3").byteLength,stepMode:F.stepMode||"vertex",attributes:[{format:ct("float32x3"),offset:0,shaderLocation:F.location}]})}}catch(G){D.e(G)}finally{D.f()}return r}function xr(t,n){var e=new Set,r=0,i={},o=ye(n),a;try{for(o.s();!(a=o.n()).done;){var s=a.value;if("attributes"in s){var u=ye(s.attributes),c;try{for(u.s();!(c=u.n()).done;){var y=c.value;e.add(y.attribute)}}catch(T){u.e(T)}finally{u.f()}}else e.add(s.name);i[s.name]=r++}}catch(T){o.e(T)}finally{o.f()}var d=ye(t.attributes),O;try{for(d.s();!(O=d.n()).done;){var b=O.value;e.has(b.name)||(i[b.name]=r++)}}catch(T){d.e(T)}finally{d.f()}return i}function Sr(t,n,e){var r=t.attributes.find(function(i){return i.name===n});if(!r)throw new Error("Unknown attribute ".concat(n));if(e.has(n))throw new Error("Duplicate attribute ".concat(n));return e.add(n),r}function po(t){var n=ho();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function ho(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Cr=function(t){w(e,t);var n=po(e);function e(i,o){var a;return m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.vs=void 0,a.fs=null,a._bufferSlots=void 0,a._buffers=void 0,a._indexBuffer=null,a._bindGroupLayout=void 0,a._bindGroup=null,a.device=i,a.handle=a.props.handle||a.createHandle(),a.handle.label=a.props.id,a.vs=o.vs,a.fs=o.fs,a._bufferSlots=xr(a.props.shaderLayout,a.props.bufferLayout),a._buffers=new Array(Object.keys(a._bufferSlots).length).fill(null),a._bindGroupLayout=a.handle.getBindGroupLayout(0),a}var r=e.prototype;return r.createHandle=function(){var o=this._getRenderPipelineDescriptor(),a=this.device.handle.createRenderPipeline(o);return C.groupCollapsed(1,"new WebGPRenderPipeline(".concat(this.id,")"))(),C.log(1,JSON.stringify(o,null,2))(),C.groupEnd(1)(),a},r.destroy=function(){},r.setIndexBuffer=function(o){this._indexBuffer=o},r.setAttributes=function(o){for(var a=0,s=Object.entries(o);a<s.length;a++){var u=j(s[a],2),c=u[0],y=u[1],d=this._bufferSlots[c];if(d>=0)this._buffers[d]=y;else throw new Error("Setting attribute '".concat(c,"' not listed in shader layout for program ").concat(this.id))}},r.setConstantAttributes=function(o){throw new Error("not implemented")},r.setBindings=function(o){Ie(this.props.bindings)||(Object.assign(this.props.bindings,o),this._bindGroup=wr(this.device.handle,this._bindGroupLayout,this.props.shaderLayout,this.props.bindings))},r.setUniforms=function(o){if(!Ie(o))throw new Error("WebGPU does not support uniforms")},r._getBuffers=function(){return this._buffers},r._getBindGroup=function(){return this._bindGroup},r._getRenderPipelineDescriptor=function(){var o={module:this.props.vs.handle,entryPoint:this.props.vsEntryPoint||"main",buffers:Or(this.props.shaderLayout,this.props.bufferLayout)},a;if(this.props.fs){var s;a={module:this.props.fs.handle,entryPoint:this.props.fsEntryPoint||"main",targets:[{format:ve((s=this.device)===null||s===void 0||(s=s.canvasContext)===null||s===void 0?void 0:s.format)}]}}switch(this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":throw new Error("WebGPU does not support primitive topology ".concat(this.props.topology));default:}var u={vertex:o,fragment:a,primitive:{topology:this.props.topology},layout:"auto"};return _r(u,this.props.parameters),u},r.draw=function(o){var a=o.renderPass||this.device.getDefaultRenderPass();a.handle.setPipeline(this.handle);var s=this._getBindGroup();s&&a.handle.setBindGroup(0,s),this._setAttributeBuffers(a),o.indexCount?a.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):a.handle.draw(o.vertexCount||0,o.instanceCount,o.firstIndex,o.firstInstance)},r._setAttributeBuffers=function(o){var a=this;this._indexBuffer&&o.handle.setIndexBuffer(this._indexBuffer.handle,this._indexBuffer.props.indexType);for(var s=this._getBuffers(),u=function(d){var O=s[d];if(!O){var b=a.props.shaderLayout.attributes.find(function(T){return T.location===d});throw new Error("No buffer provided for attribute '".concat(b?.name||"","' in Model '").concat(a.props.id,"'"))}o.handle.setVertexBuffer(d,O.handle)},c=0;c<s.length;++c)u(c)},g(e)}(Ue);function mo(t){var n=go();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function go(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Rr=function(t){w(e,t);var n=mo(e);function e(i,o){var a;m(this,e),a=n.call(this,i,o),a.device=void 0,a.handle=void 0,a.device=i;var s=a.props.cs.handle;return a.handle=a.props.handle||a.device.handle.createComputePipeline({label:a.props.id,compute:{module:s,entryPoint:a.props.csEntryPoint},layout:"auto"}),a}var r=e.prototype;return r._getBindGroupLayout=function(){return this.handle.getBindGroupLayout(0)},g(e)}(We);function Tr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Er(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Tr(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Tr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function vo(t){var n=yo();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function yo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ar=function(t){w(e,t);var n=vo(e);function e(i){var o,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};m(this,e),o=n.call(this,i,a),o.device=void 0,o.handle=void 0,o.pipeline=null,o.device=i;var s=a.framebuffer||i.canvasContext.getCurrentFramebuffer(),u=o.getRenderPassDescriptor(s);return o.handle=o.props.handle||i.commandEncoder.beginRenderPass(u),o.handle.label=o.props.id,o}var r=e.prototype;return r.destroy=function(){},r.end=function(){this.handle.end()},r.setPipeline=function(o){this.pipeline=o,this.handle.setPipeline(this.pipeline.handle)},r.setBindings=function(o){var a,s;(a=this.pipeline)===null||a===void 0||a.setBindings(o);var u=(s=this.pipeline)===null||s===void 0?void 0:s._getBindGroup();u&&this.handle.setBindGroup(0,u)},r.setIndexBuffer=function(o,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,u=arguments.length>3?arguments[3]:void 0;this.handle.setIndexBuffer(o.handle,a,s,u)},r.setVertexBuffer=function(o,a){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;this.handle.setVertexBuffer(o,a.handle,s)},r.draw=function(o){o.indexCount?this.handle.drawIndexed(o.indexCount,o.instanceCount,o.firstIndex,o.baseVertex,o.firstInstance):this.handle.draw(o.vertexCount||0,o.instanceCount,o.firstIndex,o.firstInstance)},r.drawIndirect=function(){},r.setParameters=function(o){var a=o.blendConstant,s=o.stencilReference,u=o.scissorRect,c=o.viewport;a&&this.handle.setBlendConstant(a),s&&this.handle.setStencilReference(s),u&&this.handle.setScissorRect(u[0],u[1],u[2],u[3]),c&&this.handle.setViewport(c[0],c[1],c[2],c[3],c[4],c[5])},r.pushDebugGroup=function(o){this.handle.pushDebugGroup(o)},r.popDebugGroup=function(){this.handle.popDebugGroup()},r.insertDebugMarker=function(o){this.handle.insertDebugMarker(o)},r.getRenderPassDescriptor=function(o){var a=this,s={colorAttachments:[]};return s.colorAttachments=o.colorAttachments.map(function(u){return{loadOp:"clear",colorClearValue:a.props.clearColor||[0,0,0,0],storeOp:a.props.discard?"discard":"store",view:u.handle.createView()}}),o.depthStencilAttachment&&(s.depthStencilAttachment=Er(Er({},this.props),{},{view:o.depthStencilAttachment.handle.createView()})),s},g(e)}(ze);function bo(t){var n=_o();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function _o(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var jr=function(t){w(e,t);var n=bo(e);function e(i,o){var a,s;return m(this,e),s=n.call(this,i,o),s.device=void 0,s.handle=void 0,s._bindGroupLayout=null,s.device=i,s.handle=s.props.handle||((a=i.commandEncoder)===null||a===void 0?void 0:a.beginComputePass({label:s.props.id})),s}var r=e.prototype;return r.destroy=function(){},r.end=function(){this.handle.end()},r.setPipeline=function(o){var a=o;this.handle.setPipeline(a.handle),this._bindGroupLayout=a._getBindGroupLayout()},r.setBindings=function(o){throw new Error("fix me")},r.dispatch=function(o,a,s){this.handle.dispatchWorkgroups(o,a,s)},r.dispatchIndirect=function(o){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.handle.dispatchWorkgroupsIndirect(o.handle,a)},r.pushDebugGroup=function(o){this.handle.pushDebugGroup(o)},r.popDebugGroup=function(){this.handle.popDebugGroup()},r.insertDebugMarker=function(o){this.handle.insertDebugMarker(o)},g(e)}(He);function wo(t){var n=Po();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Po(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Br=function(t){w(e,t);var n=wo(e);function e(r,i){var o;return m(this,e),o=n.call(this,r,i),o.device=void 0,o.device=r,o.autoCreateAttachmentTextures(),o}return g(e)}(Fe);function So(t){var n=Oo();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Oo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ft=function(t){w(e,t);var n=So(e);function e(i,o,a){var s;return m(this,e),s=n.call(this,a),s.device=void 0,s.gpuCanvasContext=void 0,s.format=void 0,s.depthStencilFormat="depth24plus",s.sampleCount=1,s.depthStencilAttachment=null,s.device=i,s.width=-1,s.height=-1,s._setAutoCreatedCanvasId("".concat(s.device.id,"-canvas")),s.gpuCanvasContext=s.canvas.getContext("webgpu"),s.format=s.gpuCanvasContext.getPreferredFormat(o),s}var r=e.prototype;return r.destroy=function(){this.gpuCanvasContext.unconfigure()},r.getCurrentFramebuffer=function(){this.update();var o=this.device.createTexture({id:"default-render-target",handle:this.gpuCanvasContext.getCurrentTexture(),format:this.format,width:this.width,height:this.height});return this._createDepthStencilAttachment(),new Br(this.device,{colorAttachments:[o],depthStencilAttachment:this.depthStencilAttachment})},r.update=function(){var o=this.getPixelSize(),a=j(o,2),s=a[0],u=a[1],c=s!==this.width||u!==this.height;c&&(this.width=s,this.height=u,this.depthStencilAttachment&&(this.depthStencilAttachment.destroy(),this.depthStencilAttachment=null),this.gpuCanvasContext.configure({device:this.device.handle,format:ve(this.format),colorSpace:this.props.colorSpace,alphaMode:this.props.alphaMode}),C.log(1,"Resized to ".concat(this.width,"x").concat(this.height,"px"))())},r.resize=function(o){this.update()},r._createDepthStencilAttachment=function(){return this.depthStencilAttachment||(this.depthStencilAttachment=this.device.createTexture({id:"depth-stencil-target",format:this.depthStencilFormat,width:this.width,height:this.height,usage:GPUTextureUsage.RENDER_ATTACHMENT})),this.depthStencilAttachment},g(e)}(de);function Dr(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,r)}return e}function Ir(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?Dr(Object(e),!0).forEach(function(r){x(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Dr(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function xo(t){var n=Co();return function(){var r=h(t),i;if(n){var o=h(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return P(this,i)}}function Co(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var lt=function(t){w(e,t);var n=xo(e);e.isSupported=function(){return Boolean(typeof navigator<"u"&&navigator.gpu)},e.create=function(){var i=Y(xe.default.mark(function a(s){var u,c,y,d;return xe.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(navigator.gpu){b.next=2;break}throw new Error("WebGPU not available. Open in Chrome Canary and turn on chrome://flags/#enable-unsafe-webgpu");case 2:return C.groupCollapsed(1,"WebGPUDevice created")(),b.next=5,navigator.gpu.requestAdapter({powerPreference:"high-performance"});case 5:if(u=b.sent,u){b.next=8;break}throw new Error("Failed to request WebGPU adapter");case 8:return b.next=10,u.requestAdapterInfo();case 10:return c=b.sent,C.probe(1,"Adapter available",c)(),b.next=14,u.requestDevice({requiredFeatures:u.features});case 14:if(y=b.sent,C.probe(1,"GPUDevice available")(),typeof s.canvas!="string"){b.next=20;break}return b.next=19,de.pageLoaded;case 19:C.probe(1,"DOM is loaded")();case 20:return d=new e(y,u,s),C.probe(1,"Device created",d.info)(),C.table(1,d.info)(),C.groupEnd(1)(),b.abrupt("return",d);case 25:case"end":return b.stop()}},a)}));function o(a){return i.apply(this,arguments)}return o}();function e(i,o,a){var s;return m(this,e),s=n.call(this,Ir(Ir({},a),{},{id:a.id||ue("webgpu-device")})),s.handle=void 0,s.adapter=void 0,s.lost=void 0,s.canvasContext=null,s.commandEncoder=null,s.renderPass=null,s._info=void 0,s._isLost=!1,s.features=void 0,s.handle=i,s.adapter=o,s._info={type:"webgpu",vendor:s.adapter.__brand,renderer:"",version:"",gpu:"unknown",shadingLanguages:["glsl","wgsl"],shadingLanguageVersions:{glsl:"450",wgsl:"100"},vendorMasked:"",rendererMasked:""},s.lost=new Promise(function(){var u=Y(xe.default.mark(function c(y){var d;return xe.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,s.handle.lost;case 2:d=b.sent,s._isLost=!0,y({reason:"destroyed",message:d.message});case 5:case"end":return b.stop()}},c)}));return function(c){return u.apply(this,arguments)}}()),a.canvas&&(s.canvasContext=new ft(_e(s),s.adapter,{canvas:a.canvas})),s.features=s._getFeatures(),s}var r=e.prototype;return r.destroy=function(){this.handle.destroy()},r.isTextureFormatSupported=function(o){return!o.includes("webgl")},r.isTextureFormatFilterable=function(o){return this.isTextureFormatSupported(o)},r.isTextureFormatRenderable=function(o){return this.isTextureFormatSupported(o)},r.createBuffer=function(o){var a=this._getBufferProps(o);return new Ve(this,a)},r._createTexture=function(o){return new $e(this,o)},r.createExternalTexture=function(o){return new gr(this,o)},r.createShader=function(o){return new Ye(this,o)},r.createSampler=function(o){return new W(this,o)},r.createRenderPipeline=function(o){return new Cr(this,o)},r.createFramebuffer=function(o){throw new Error("Not implemented")},r.createComputePipeline=function(o){return new Rr(this,o)},r.beginRenderPass=function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new Ar(this,o)},r.beginComputePass=function(o){return this.commandEncoder=this.commandEncoder||this.handle.createCommandEncoder(),new jr(this,o)},r.createCanvasContext=function(o){return new ft(this,this.adapter,o)},r.getDefaultRenderPass=function(){var o;return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:(o=this.canvasContext)===null||o===void 0?void 0:o.getCurrentFramebuffer()}),this.renderPass},r.submit=function(){var o,a;(o=this.renderPass)===null||o===void 0||o.end();var s=(a=this.commandEncoder)===null||a===void 0?void 0:a.finish();s&&this.handle.queue.submit([s]),this.commandEncoder=null,this.renderPass=null},r._getFeatures=function(){var o=new Set(this.handle.features);return o.has("depth-clamping")&&(o.delete("depth-clamping"),o.add("depth-clip-control")),o.has("texture-compression-bc")&&o.add("texture-compression-bc5-webgl"),o.add("webgpu"),o.add("timer-query-webgl"),o.add("vertex-array-object-webgl1"),o.add("instanced-rendering-webgl1"),o.add("multiple-render-targets-webgl1"),o.add("index-uint32-webgl1"),o.add("blend-minmax-webgl1"),o.add("texture-blend-float-webgl1"),o.add("texture-formats-srgb-webgl1"),o.add("texture-formats-depth-webgl1"),o.add("texture-formats-float32-webgl1"),o.add("texture-formats-float16-webgl1"),o.add("texture-filter-linear-float32-webgl"),o.add("texture-filter-linear-float16-webgl"),o.add("texture-filter-anisotropic-webgl"),o.add("texture-renderable-rgba32float-webgl"),o.add("texture-renderable-float32-webgl"),o.add("texture-renderable-float16-webgl"),o.add("glsl-frag-data"),o.add("glsl-frag-depth"),o.add("glsl-derivatives"),o.add("glsl-texture-lod"),o},r.copyExternalImageToTexture=function(o){var a,s=o.source,u=o.sourceX,c=u===void 0?0:u,y=o.sourceY,d=y===void 0?0:y,O=o.texture,b=o.mipLevel,T=b===void 0?0:b,k=o.aspect,H=k===void 0?"all":k,D=o.colorSpace,L=D===void 0?"display-p3":D,F=o.premultipliedAlpha,G=F===void 0?!1:F,Q=o.width,ce=Q===void 0?O.width:Q,ee=o.height,te=ee===void 0?O.height:ee,$=o.depth,re=$===void 0?1:$,p=O;(a=this.handle)===null||a===void 0||a.queue.copyExternalImageToTexture({source:s,origin:[c,d]},{texture:p.handle,origin:[0,0,0],mipLevel:T,aspect:H,colorSpace:L,premultipliedAlpha:G},[ce,te,re])},g(e,[{key:"info",get:function(){return this._info}},{key:"limits",get:function(){return this.handle.limits}},{key:"isLost",get:function(){return this._isLost}}]),e}(Ge);lt.type="webgpu";return Ur(Ro);})();
|
|
11
12
|
/*! Bundled license information:
|
|
12
13
|
|
|
13
14
|
@babel/runtime/helpers/regeneratorRuntime.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgpu",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.34",
|
|
4
4
|
"description": "WebGPU adapter for the luma.gl API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@babel/runtime": "^7.0.0",
|
|
40
|
-
"@luma.gl/core": "9.0.0-alpha.
|
|
40
|
+
"@luma.gl/core": "9.0.0-alpha.34",
|
|
41
41
|
"@probe.gl/env": "^4.0.2",
|
|
42
42
|
"@webgpu/types": "^0.1.34"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "66ab5fe7caa59ef83224a0b7c892e00bd43cbefd"
|
|
45
45
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {ShaderLayout, BufferLayout, AttributeDeclaration, VertexFormat} from '@luma.gl/core';
|
|
2
|
-
import {decodeVertexFormat} from '@luma.gl/core';
|
|
2
|
+
import {getAttributeInfosFromLayouts, decodeVertexFormat} from '@luma.gl/core';
|
|
3
3
|
|
|
4
4
|
/** Throw error on any WebGL-only vertex formats */
|
|
5
5
|
function getWebGPUVertexFormat(format: VertexFormat): GPUVertexFormat {
|
|
@@ -20,6 +20,9 @@ export function getVertexBufferLayout(
|
|
|
20
20
|
shaderLayout: ShaderLayout,
|
|
21
21
|
bufferLayout: BufferLayout[]
|
|
22
22
|
): GPUVertexBufferLayout[] {
|
|
23
|
+
// @ts-expect-error Deduplicate and make use of the new core attribute logic here in webgpu module
|
|
24
|
+
const attributeInfos = getAttributeInfosFromLayouts(shaderLayout, bufferLayout);
|
|
25
|
+
|
|
23
26
|
const vertexBufferLayouts: GPUVertexBufferLayout[] = [];
|
|
24
27
|
const usedAttributes = new Set<string>();
|
|
25
28
|
|
|
@@ -31,18 +34,17 @@ export function getVertexBufferLayout(
|
|
|
31
34
|
// TODO verify that all stepModes for one buffer are the same
|
|
32
35
|
let stepMode: 'vertex' | 'instance' = 'vertex';
|
|
33
36
|
let byteStride = 0;
|
|
34
|
-
const byteOffset = mapping.byteOffset || 0;
|
|
35
|
-
|
|
36
37
|
// interleaved mapping {..., attributes: [{...}, ...]}
|
|
37
38
|
if (mapping.attributes) {
|
|
38
39
|
// const arrayStride = mapping.byteStride; TODO
|
|
39
|
-
for (const
|
|
40
|
-
const
|
|
40
|
+
for (const attributeMapping of mapping.attributes) {
|
|
41
|
+
const attributeName = attributeMapping.attribute;
|
|
42
|
+
const attributeLayout = findAttributeLayout(shaderLayout, attributeName, usedAttributes);
|
|
41
43
|
|
|
42
44
|
stepMode = attributeLayout.stepMode || 'vertex';
|
|
43
45
|
vertexAttributes.push({
|
|
44
|
-
format: getWebGPUVertexFormat(
|
|
45
|
-
offset: byteOffset
|
|
46
|
+
format: getWebGPUVertexFormat(attributeMapping.format || mapping.format),
|
|
47
|
+
offset: attributeMapping.byteOffset,
|
|
46
48
|
shaderLocation: attributeLayout.location
|
|
47
49
|
});
|
|
48
50
|
|
|
@@ -56,7 +58,8 @@ export function getVertexBufferLayout(
|
|
|
56
58
|
stepMode = attributeLayout.stepMode || 'vertex';
|
|
57
59
|
vertexAttributes.push({
|
|
58
60
|
format: getWebGPUVertexFormat(mapping.format),
|
|
59
|
-
offset
|
|
61
|
+
// We only support 0 offset for non-interleaved buffer layouts
|
|
62
|
+
offset: 0,
|
|
60
63
|
shaderLocation: attributeLayout.location
|
|
61
64
|
});
|
|
62
65
|
}
|
|
@@ -102,7 +105,7 @@ export function getBufferSlots(
|
|
|
102
105
|
// interleaved mapping {..., attributes: [{...}, ...]}
|
|
103
106
|
if ('attributes' in mapping) {
|
|
104
107
|
for (const interleaved of mapping.attributes) {
|
|
105
|
-
usedAttributes.add(interleaved.
|
|
108
|
+
usedAttributes.add(interleaved.attribute);
|
|
106
109
|
}
|
|
107
110
|
// non-interleaved mapping (just set offset and stride)
|
|
108
111
|
} else {
|