gaussian-splat-lite 0.1.12 → 0.1.13
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/CHANGELOG.md +8 -1
- package/dist/assets/worker-C26a7h-J.js.map +1 -0
- package/dist/assets/worker-Cx-xVLFg.js.map +1 -0
- package/dist/gaussian-splat-lite.cjs +17 -1
- package/dist/gaussian-splat-lite.cjs.map +1 -1
- package/dist/gaussian-splat-lite.min.cjs +1 -1
- package/dist/gaussian-splat-lite.min.cjs.map +1 -1
- package/dist/gaussian-splat-lite.module.js +17 -1
- package/dist/gaussian-splat-lite.module.js.map +1 -1
- package/dist/gaussian-splat-lite.module.min.js +17 -1
- package/dist/gaussian-splat-lite.module.min.js.map +1 -1
- package/dist/types/postDecode.d.cts +8 -0
- package/dist/types/postDecode.d.ts +8 -0
- package/docs/PostDecode.md +1 -1
- package/package.json +1 -1
- package/dist/assets/worker-DUqmK1X0.js.map +0 -1
- package/dist/assets/worker-asMKfeTW.js.map +0 -1
|
@@ -834,5 +834,5 @@ void main() {
|
|
|
834
834
|
if (index >= 0 && index < targetCount) {
|
|
835
835
|
produceSplat(index);
|
|
836
836
|
}
|
|
837
|
-
}`;const zA=new e.Matrix4,m=new e.Vector3,Z=new e.Vector3,V=new e.Vector3,_A=new e.Vector3;function zg(B,A,I){const g=B.elements,Q=Math.hypot(g[0],g[1],g[2]),C=Math.hypot(g[4],g[5],g[6]),t=Math.hypot(g[8],g[9],g[10]);A.set(Q,C,t),m.set(g[0],g[1],g[2]),Z.set(g[4],g[5],g[6]),V.set(g[8],g[9],g[10]),Q>0&&m.multiplyScalar(1/Q),C>0&&Z.multiplyScalar(1/C),t>0&&V.multiplyScalar(1/t);const E=+(Q>0)+ +(C>0)+ +(t>0);if(E===0){I.identity();return}if(E===1){const i=Q>0?0:C>0?1:2;_A.set(i===0?1:0,i===1?1:0,i===2?1:0),I.setFromUnitVectors(_A,i===0?m:i===1?Z:V).normalize();return}Q===0&&m.copy(Z).cross(V).normalize(),C===0&&Z.copy(V).cross(m).normalize(),t===0&&V.copy(m).cross(Z).normalize(),B.determinant()<0&&m.negate(),zA.makeBasis(m,Z,V),I.setFromRotationMatrix(zA).normalize()}const Y=class Y{constructor(){if(this.time=0,this.deltaTime=0,this.viewOrigin=new e.Vector3,this.viewDirection=new e.Vector3,this.maxSplats=0,this.numSplats=0,this.target=null,this.mapping=[],this.version=-1,this.mappingVersion=-1,this.transformScale=new e.Vector3,this.transformQuaternion=new e.Quaternion,!yI)throw new Error("Gaussian Splat Lite requires THREE.js r179 or above")}dispose(){this.disposeTarget(),this.mapping=[],this.numSplats=0,this.version=-1,this.mappingVersion=-1}disposeTarget(){var A;(A=this.target)==null||A.dispose(),this.target=null,this.maxSplats=0}getTextures(){var A;return((A=this.target)==null?void 0:A.textures)??Y.emptyTextures}generateMapping(A){let I=0;const g=A.map(Q=>{const C=I;return I+=Math.ceil(Q/H)*H,{base:C,count:Q}});return{maxSplats:I,mapping:g}}ensureGenerate({maxSplats:A,shrinkResources:I=!1}){const g=x(Math.max(1,A));if(this.target&&(I?g.maxSplats===this.maxSplats:g.maxSplats<=this.maxSplats))return!1;this.disposeTarget();const{width:Q,height:C,depth:t}=g;this.maxSplats=g.maxSplats,this.target=new e.WebGLArrayRenderTarget(Q,C,t,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:e.NearestFilter,minFilter:e.NearestFilter,format:e.RGBAIntegerFormat,type:e.UnsignedIntType}),this.target.scissorTest=!0;const E=this.target.texture.clone();return this.target.textures=[this.target.texture,E],!0}getMaterial(){let A=Y.material;return A||(LI(),A=new e.RawShaderMaterial({glslVersion:e.GLSL3,vertexShader:NI,fragmentShader:jg,uniforms:_g(),depthTest:!1,depthWrite:!1}),Y.material=A),A}prepareMaterial(A){const I=A.splats;if(!I)throw new Error("SplatMesh has no source");const g=this.getMaterial(),Q=g.uniforms;I.setTextureUniforms(Q),Q.numSh.value=Math.min(A.maxSh,I.getNumSh()),zg(A.matrixWorld,this.transformScale,this.transformQuaternion),Q.objectBasis.value.setFromMatrix4(A.matrixWorld),Q.objectOffset.value.setFromMatrixPosition(A.matrixWorld),Q.objectOffset.value.sub(this.viewOrigin),Q.objectLnScale.value.set(Math.log(this.transformScale.x),Math.log(this.transformScale.y),Math.log(this.transformScale.z)),Q.objectQuaternion.value.copy(this.transformQuaternion),Q.recolor.value.set(A.recolor.r,A.recolor.g,A.recolor.b,e.MathUtils.clamp(A.opacity,0,1));const C=A.sdfEdits;return Q.numSdfs.value=(C==null?void 0:C.numSdfs)??0,Q.numEdits.value=(C==null?void 0:C.numEdits)??0,Q.sdfTexture.value=(C==null?void 0:C.sdfTexture)??q.emptyTexture,Q.editTexture.value=(C==null?void 0:C.editTexture)??q.emptyTexture,Y.fullScreenQuad.material=g,g}generate({mesh:A,base:I,count:g,renderer:Q}){if(!this.target)throw new Error("Accumulator target is not initialized");if(I+g>this.maxSplats)throw new Error("Splat generation range exceeds accumulator capacity");const t=this.prepareMaterial(A).uniforms,E=this.saveRenderState(Q),i=Math.ceil((I+g)/H)*H,s=H*rA;for(t.targetBase.value=I,t.targetCount.value=g;I<i;){const D=Math.floor(I/s);t.targetLayer.value=D;const o=D*s,w=Math.floor((I-o)/H),n=Math.min(rA,Math.ceil((i-o)/H));this.target.scissor.set(0,w,H,n-w),Q.setRenderTarget(this.target,D),Q.xr.enabled=!1,Q.autoClear=!1,Y.fullScreenQuad.render(Q),I+=H*(n-w)}this.resetRenderState(Q,E)}prepareGenerate({renderer:A,scene:I,timer:g,camera:Q,previous:C}){Q.getWorldPosition(this.viewOrigin),Q.getWorldDirection(this.viewDirection),this.time=g.getElapsed(),this.deltaTime=g.getDelta();const t=[];I.traverse(a=>{a instanceof sA&&Q.layers.test(a.layers)&&t.push(a)});const E=new Set;I.traverseVisible(a=>{if(!(a instanceof oA))return;let r=a.parent;for(;r&&!(r instanceof sA);)r=r.parent;r||E.add(a)});for(const a of t)try{a.frameUpdate({time:this.time,deltaTime:this.deltaTime,camera:Q,globalEdits:Array.from(E)})}catch(r){console.error("SplatMesh frame update failed",r)}const i=[];I.traverseVisible(a=>{a instanceof sA&&Q.layers.test(a.layers)&&a.opacity>0&&i.push(a)});const{maxSplats:s,mapping:D}=this.generateMapping(i.map(a=>a.numSplats));this.mapping=[],this.numSplats=0,D.forEach(({base:a,count:r},h)=>{const c=i[h];!c.splats||r<=0||(this.mapping.push({node:c,version:c.version,sortVersion:c.sortVersion,centerVersion:c.centerVersion,mappingVersion:c.mappingVersion,base:a,count:r}),this.numSplats=Math.max(this.numSplats,a+r))});const{splatsUpdated:o,mappingUpdated:w,sortUpdated:n}=C.checkVersions(this.mapping);return this.version=C.version+(o?1:0),this.mappingVersion=C.mappingVersion+(w?1:0),{version:this.version,sortUpdated:n,requiredMaxSplats:x(Math.max(1,s)).maxSplats,generate:(a=!1)=>{this.ensureGenerate({maxSplats:s,shrinkResources:a});for(const{node:r,base:h,count:c}of this.mapping)this.generate({mesh:r,base:h,count:c,renderer:A})}}}checkVersions(A){return this.mapping.length!==A.length?{splatsUpdated:!0,mappingUpdated:!0,sortUpdated:!0}:this.mapping.some((g,Q)=>{const C=A[Q];return g.node!==C.node||g.base!==C.base||g.count!==C.count||g.mappingVersion!==C.mappingVersion})?{splatsUpdated:!0,mappingUpdated:!0,sortUpdated:!0}:{splatsUpdated:this.mapping.some((g,Q)=>g.version!==A[Q].version),mappingUpdated:!1,sortUpdated:this.mapping.some((g,Q)=>g.sortVersion!==A[Q].sortVersion)}}saveRenderState(A){return{target:A.getRenderTarget(),activeCubeFace:A.getActiveCubeFace(),activeMipmapLevel:A.getActiveMipmapLevel(),xrEnabled:A.xr.enabled,autoClear:A.autoClear}}resetRenderState(A,I){A.setRenderTarget(I.target,I.activeCubeFace,I.activeMipmapLevel),A.xr.enabled=I.xrEnabled,A.autoClear=I.autoClear}};Y.emptyTexture=(()=>{const{width:A,height:I,depth:g,maxSplats:Q}=x(1),C=new e.DataArrayTexture(new Uint32Array(Q*4),A,I,g);return C.format=e.RGBAIntegerFormat,C.type=e.UnsignedIntType,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})(),Y.emptyTextures=[Y.emptyTexture,Y.emptyTexture],Y.material=null,Y.fullScreenQuad=new qI.FullScreenQuad(new e.RawShaderMaterial({visible:!1}));let K=Y;function _g(){return{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0},sourceSplats:{value:K.emptyTexture},sourceSplats2:{value:K.emptyTexture},numSh:{value:0},sh1Texture:{value:K.emptyTexture},sh2Texture:{value:K.emptyTexture},sh3TextureA:{value:K.emptyTexture},sh3TextureB:{value:K.emptyTexture},objectBasis:{value:new e.Matrix3},objectOffset:{value:new e.Vector3},objectLnScale:{value:new e.Vector3},objectQuaternion:{value:new e.Quaternion},recolor:{value:new e.Vector4(1,1,1,1)},numSdfs:{value:0},numEdits:{value:0},sdfTexture:{value:q.emptyTexture},editTexture:{value:q.emptyTexture}}}class $g extends e.InstancedBufferGeometry{constructor(){super(),this.setAttribute("position",new e.BufferAttribute(AQ,3)),this.setIndex(new e.BufferAttribute(IQ,1))}}const AQ=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),IQ=new Uint16Array([0,1,2,0,2,3]),JI='(function(){"use strict";class nt{static __wrap(n){n=n>>>0;const o=Object.create(nt.prototype);return o.__wbg_ptr=n,Ut.register(o,o.__wbg_ptr,o),o}__destroy_into_raw(){const n=this.__wbg_ptr;return this.__wbg_ptr=0,Ut.unregister(this),n}free(){const n=this.__destroy_into_raw();P.__wbg_chunkdecoder_free(n,0)}finish(){const n=this.__destroy_into_raw(),o=P.chunkdecoder_finish(n);if(o[2])throw ct(o[1]);return ct(o[0])}push(n){const o=P.chunkdecoder_push(this.__wbg_ptr,n);if(o[1])throw ct(o[0])}set_expected_input_size(n){const o=P.chunkdecoder_set_expected_input_size(this.__wbg_ptr,n);if(o[1])throw ct(o[0])}}Symbol.dispose&&(nt.prototype[Symbol.dispose]=nt.prototype.free);function Jt(t,n){var o=St(t)?0:ht(t,P.__wbindgen_malloc,P.__wbindgen_realloc),s=k,e=St(n)?0:ht(n,P.__wbindgen_malloc,P.__wbindgen_realloc),i=k;const f=P.decode_to_splats(o,s,e,i);if(f[2])throw ct(f[1]);return nt.__wrap(f[0])}function Kt(t,n,o,s,e,i,f){P.set_sort_center_state(t,n,o,s,e,i,f)}function kt(t,n,o,s,e,i,f,_,l){return P.sort32_centers(t,n,o,s,e,i,f,_,l)>>>0}function zt(){return{__proto__:null,"./gaussian_splat_rs_bg.js":{__proto__:null,__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57:function(n,o){const s=At(o),e=ht(s,P.__wbindgen_malloc,P.__wbindgen_realloc),i=k;_t().setInt32(n+4,i,!0),_t().setInt32(n+0,e,!0)},__wbg___wbindgen_throw_81fc77679af83bc6:function(n,o){throw new Error(Et(n,o))},__wbg_error_a6fa202b58aa1cd3:function(n,o){let s,e;try{s=n,e=o,console.error(Et(n,o))}finally{P.__wbindgen_free(s,e,1)}},__wbg_get_index_983d655608220248:function(n,o){return n[o>>>0]},__wbg_length_0c32cb8543c8e4c8:function(n){return n.length},__wbg_length_1e701798fdcaa3b4:function(n){return n.length},__wbg_length_526c0f6e4ebae15d:function(n){return n.length},__wbg_length_fd4646b401926788:function(n){return n.length},__wbg_new_227d7c05414eb861:function(){return new Error},__wbg_new_4f9fafbb3909af72:function(){return new Object},__wbg_new_with_length_26bffbe236bf73f9:function(n){return new Float32Array(n>>>0)},__wbg_new_with_length_41a22191b9bdfd66:function(n){return new Uint32Array(n>>>0)},__wbg_prototypesetcall_021fd89d67217368:function(n,o,s){Float64Array.prototype.set.call(nn(n,o),s)},__wbg_prototypesetcall_3e05eb9545565046:function(n,o,s){Uint8Array.prototype.set.call(en(n,o),s)},__wbg_prototypesetcall_66c8e1fb820946be:function(n,o,s){Float32Array.prototype.set.call(bt(n,o),s)},__wbg_prototypesetcall_e42275e601e14eeb:function(n,o,s){Uint32Array.prototype.set.call(xt(n,o),s)},__wbg_set_448126769bf7c181:function(n,o,s){n.set(xt(o,s))},__wbg_set_8ee2d34facb8466e:function(){return sn(function(n,o,s){return Reflect.set(n,o,s)},arguments)},__wbg_set_a98c8da6557e63de:function(n,o,s){n.set(bt(o,s))},__wbg_set_index_a561936dd7004b5a:function(n,o,s){n[o>>>0]=s},__wbg_stack_3b0d974bbf31e44f:function(n,o){const s=o.stack,e=ht(s,P.__wbindgen_malloc,P.__wbindgen_realloc),i=k;_t().setInt32(n+4,i,!0),_t().setInt32(n+0,e,!0)},__wbg_subarray_0f98d3fb634508ad:function(n,o,s){return n.subarray(o>>>0,s>>>0)},__wbg_subarray_1230568a23d546e8:function(n,o,s){return n.subarray(o>>>0,s>>>0)},__wbg_subarray_4342405c1ffc86d6:function(n,o,s){return n.subarray(o>>>0,s>>>0)},__wbg_subarray_d51e89458b3fdbf6:function(n,o,s){return n.subarray(o>>>0,s>>>0)},__wbindgen_cast_0000000000000001:function(n){return n},__wbindgen_cast_0000000000000002:function(n,o){return bt(n,o)},__wbindgen_cast_0000000000000003:function(n,o){return xt(n,o)},__wbindgen_cast_0000000000000004:function(n,o){return Et(n,o)},__wbindgen_init_externref_table:function(){const n=P.__wbindgen_externrefs,o=n.grow(4);n.set(0,void 0),n.set(o+0,void 0),n.set(o+1,null),n.set(o+2,!0),n.set(o+3,!1)}}}}const Ut=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>P.__wbg_chunkdecoder_free(t>>>0,1));function tn(t){const n=P.__externref_table_alloc();return P.__wbindgen_externrefs.set(n,t),n}function At(t){const n=typeof t;if(n=="number"||n=="boolean"||t==null)return`${t}`;if(n=="string")return`"${t}"`;if(n=="symbol"){const e=t.description;return e==null?"Symbol":`Symbol(${e})`}if(n=="function"){const e=t.name;return typeof e=="string"&&e.length>0?`Function(${e})`:"Function"}if(Array.isArray(t)){const e=t.length;let i="[";e>0&&(i+=At(t[0]));for(let f=1;f<e;f++)i+=", "+At(t[f]);return i+="]",i}const o=/\\[object ([^\\]]+)\\]/.exec(toString.call(t));let s;if(o&&o.length>1)s=o[1];else return toString.call(t);if(s=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:s}function bt(t,n){return t=t>>>0,on().subarray(t/4,t/4+n)}function nn(t,n){return t=t>>>0,an().subarray(t/8,t/8+n)}function xt(t,n){return t=t>>>0,rn().subarray(t/4,t/4+n)}function en(t,n){return t=t>>>0,st().subarray(t/1,t/1+n)}let j=null;function _t(){return(j===null||j.buffer.detached===!0||j.buffer.detached===void 0&&j.buffer!==P.memory.buffer)&&(j=new DataView(P.memory.buffer)),j}let et=null;function on(){return(et===null||et.byteLength===0)&&(et=new Float32Array(P.memory.buffer)),et}let ot=null;function an(){return(ot===null||ot.byteLength===0)&&(ot=new Float64Array(P.memory.buffer)),ot}function Et(t,n){return t=t>>>0,fn(t,n)}let at=null;function rn(){return(at===null||at.byteLength===0)&&(at=new Uint32Array(P.memory.buffer)),at}let rt=null;function st(){return(rt===null||rt.byteLength===0)&&(rt=new Uint8Array(P.memory.buffer)),rt}function sn(t,n){try{return t.apply(this,n)}catch(o){const s=tn(o);P.__wbindgen_exn_store(s)}}function St(t){return t==null}function ht(t,n,o){if(o===void 0){const _=ft.encode(t),l=n(_.length,1)>>>0;return st().subarray(l,l+_.length).set(_),k=_.length,l}let s=t.length,e=n(s,1)>>>0;const i=st();let f=0;for(;f<s;f++){const _=t.charCodeAt(f);if(_>127)break;i[e+f]=_}if(f!==s){f!==0&&(t=t.slice(f)),e=o(e,s,s=f+t.length*3,1)>>>0;const _=st().subarray(e+f,e+s),l=ft.encodeInto(t,_);f+=l.written,e=o(e,s,f,1)>>>0}return k=f,e}function ct(t){const n=P.__wbindgen_externrefs.get(t);return P.__externref_table_dealloc(t),n}let wt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});wt.decode();const cn=2146435072;let Mt=0;function fn(t,n){return Mt+=n,Mt>=cn&&(wt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),wt.decode(),Mt=n),wt.decode(st().subarray(t,t+n))}const ft=new TextEncoder;"encodeInto"in ft||(ft.encodeInto=function(t,n){const o=ft.encode(t);return n.set(o),{read:t.length,written:o.length}});let k=0,P;function ln(t,n){return P=t.exports,j=null,et=null,ot=null,at=null,rt=null,P.__wbindgen_start(),P}async function un(t,n){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,n)}catch(e){if(t.ok&&o(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n",e);else throw e}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,n)}else{const s=await WebAssembly.instantiate(t,n);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}function o(s){switch(s){case"basic":case"cors":case"default":return!0}return!1}}async function _n(t){if(P!==void 0)return P;t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead"));const n=zt();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));const{instance:o}=await un(await t,n);return ln(o)}const Tt=new Float32Array(1),Ct=new Uint32Array(Tt.buffer),pt="Float16Array"in globalThis,it=pt?new globalThis.Float16Array(1):null,Rt=new Uint16Array(it==null?void 0:it.buffer);function hn(t){return it[0]=t,Rt[0]}function wn(t){Tt[0]=t;const n=Ct[0],o=n>>>16&32768,s=n>>>23&255,e=n&8388607;if(s===255)return o|(e===0?31744:32767);const i=s-127+15;return i>=31?o|31744:i<=0?i<-10?o:o|(e|8388608)>>>1-i+13:o|i<<10|e>>>13}function yn(t){return Rt[0]=t,it[0]}function dn(t){const n=t>>>15&1,o=t>>>10&31,s=t&1023;let e;if(o===0)if(s===0)e=n<<31;else{let i=s,f=-14;for(;(i&1024)===0;)i<<=1,f-=1;e=n<<31|f+127<<23|(i&1023)<<13}else o===31?e=n<<31|(s===0?2139095040:2143289344):e=n<<31|o-15+127<<23|s<<13;return Ct[0]=e,Tt[0]}const V=pt?hn:wn,Y=pt?yn:dn;var d=(t=>(t[t.Constant=1]="Constant",t[t.InputField=2]="InputField",t[t.InputAttribute=3]="InputAttribute",t[t.Negate=10]="Negate",t[t.Abs=11]="Abs",t[t.Sqrt=12]="Sqrt",t[t.Log=13]="Log",t[t.Exp=14]="Exp",t[t.Floor=15]="Floor",t[t.Ceil=16]="Ceil",t[t.Round=17]="Round",t[t.Normalize=18]="Normalize",t[t.Length=19]="Length",t[t.IsFinite=20]="IsFinite",t[t.Not=22]="Not",t[t.Sin=23]="Sin",t[t.Cos=24]="Cos",t[t.Acos=25]="Acos",t[t.Add=30]="Add",t[t.Subtract=31]="Subtract",t[t.Multiply=32]="Multiply",t[t.Divide=33]="Divide",t[t.Min=34]="Min",t[t.Max=35]="Max",t[t.Pow=36]="Pow",t[t.Dot=37]="Dot",t[t.Cross=38]="Cross",t[t.Equal=39]="Equal",t[t.NotEqual=40]="NotEqual",t[t.Less=41]="Less",t[t.LessEqual=42]="LessEqual",t[t.Greater=43]="Greater",t[t.GreaterEqual=44]="GreaterEqual",t[t.And=45]="And",t[t.Or=46]="Or",t[t.QuaternionMultiply=47]="QuaternionMultiply",t[t.RotateVector=48]="RotateVector",t[t.Select=60]="Select",t[t.Clamp=61]="Clamp",t[t.Mix=62]="Mix",t[t.Vec2=70]="Vec2",t[t.Vec3=71]="Vec3",t[t.Vec4=72]="Vec4",t[t.Component=74]="Component",t[t.MaxComponentIndex=75]="MaxComponentIndex",t))(d||{}),Q=(t=>(t[t.Position=1]="Position",t[t.Scale=2]="Scale",t[t.Quaternion=3]="Quaternion",t[t.Opacity=4]="Opacity",t[t.Alpha=5]="Alpha",t[t.Color=6]="Color",t[t.Sh0=7]="Sh0",t))(Q||{});const mn=15,gt=0,z=1,Pt=2,Dt=3,An=4,H=7,Z=65535,bn={f32:4,f16:2,u8:1,unorm8:1,i8:1,snorm8:1,u16:2,unorm16:2,i16:2,snorm16:2,u32:4,i32:4},xn=0,yt=1,Lt=2,En=3,Mn=4,tt=5,Ft=1e3,Tn=11920928955078125e-23,pn=525311;function lt(t,n,o){return Math.min(o,Math.max(n,t))}function gn(t){const n=Y(t>>>16);if(n>0){const o=n*4+1;return Math.min(Ft,Math.exp((o*o-1)/Math.E))}return Y(t&65535)}function In(t){if(t>0&&t<=1)return V(t);const n=lt(t,0,Ft);if(n>1){const o=.25*(Math.sqrt(Math.log(n)*Math.E+1)-1);return(V(1)|V(o)<<16)>>>0}return V(n)}function Nn(t,n,o=0,s=1){const e=t&1023,i=t>>>10&1023,f=t>>>20;let _=e/1023*2-1,l=i/1023*2-1;const c=1-Math.abs(_)-Math.abs(l),a=Math.max(-c,0);_+=_>=0?-a:a,l+=l>=0?-a:a;const w=1/Math.sqrt(_*_+l*l+c*c),E=f/4095*.5*Math.PI,h=Math.sin(E);n[o]=_*w*h,n[o+s]=l*w*h,n[o+s*2]=c*w*h,n[o+s*3]=Math.cos(E)}function vn(t,n,o,s,e){const i=t*t+n*n+o*o+s*s;if(!Number.isFinite(i)||i<=e)return;if(t===0&&n===0&&o===0)return pn;const f=1/Math.sqrt(i);let _=t*f,l=n*f,c=o*f,a=s*f;a<0&&(_=-_,l=-l,c=-c,a=-a);const w=2*Math.acos(lt(a,0,1)),E=Math.sin(w*.5),h=Math.abs(E)<1e-6?1:_/E,A=Math.abs(E)<1e-6?0:l/E,y=Math.abs(E)<1e-6?0:c/E,m=Math.abs(h)+Math.abs(A)+Math.abs(y);let C=h/m,M=A/m;if(y<0){const g=C;C=(1-Math.abs(M))*(C>=0?1:-1),M=(1-Math.abs(g))*(M>=0?1:-1)}const u=Math.round(lt((C*.5+.5)*1023,0,1023)),R=Math.round(lt((M*.5+.5)*1023,0,1023));return(Math.round(lt(w/Math.PI*4095,0,4095))<<20|R<<10|u)>>>0}function Un(t,n,o,s){return vn(t,n,o,s,Tn)}const Sn=512,Cn=4*1024**2,Rn=2147483647,Ot=2147483648;function Bt(t){const n=t.length/H;if(!Number.isInteger(n))throw new Error("Invalid packed postDecode instructions");return n}function ut(t,n){return t[n*H+z]}function Pn(t,n){const o=t*Float32Array.BYTES_PER_ELEMENT;return Math.min(n,Sn,Math.max(1,Math.floor(Cn/o)))}function Dn(t){const{instructions:n,outputs:o,condition:s}=t,e=Bt(n),i=new Uint32Array(e);for(let u=0;u<e;u+=1){i[u]=u;const R=u*H;for(let U=0;U<An;U+=1){const g=n[R+Dt+U];if(g===Z)break;i[g]=u}}const f=s==null?void 0:s.stages;if(f)for(let u=0;u<f.length;u+=tt){const R=f[u+Lt],U=f[u+yt];i[R]=Math.max(i[R],U)}const _=e;for(const u of[o.position,o.scale,o.quaternion,o.opacity,o.alpha,o.color,...o.sh??[]])u!==void 0&&(i[u]=_);const l=new Uint32Array(e),c=new Uint8Array(e);let a=0;for(let u=0;u<e;u+=1){const R=u*H;n[R+gt]===d.Constant&&(c[u]=1,i[u]=_,l[u]=a,a+=n[R+z])}const w=new Int32Array(e+1).fill(-1),E=new Int32Array(e).fill(-1),h=[],A=(u,R)=>{let U=u,g=R,p=0;for(;p<h.length&&h[p].offset<U;)p+=1;const S=h[p-1];S&&S.offset+S.width===U&&(U=S.offset,g+=S.width,h.splice(p-1,1),p-=1);const b=h[p];b&&U+g===b.offset&&(g+=b.width,h.splice(p,1)),h.splice(p,0,{offset:U,width:g})},y=u=>{let R=-1;for(let p=0;p<h.length;p+=1){const S=h[p];S.width>=u&&(R===-1||S.width<h[R].width)&&(R=p)}if(R===-1){const p=a;return a+=u,p}const U=h[R],g=U.offset;return U.width===u?h.splice(R,1):(U.offset+=u,U.width-=u),g};for(let u=0;u<e;u+=1){for(let p=w[u];p!==-1;p=E[p])A(l[p],ut(n,p));if(c[u])continue;const R=ut(n,u),U=y(R);l[u]=U;const g=i[u]+1;g<=e&&(E[u]=w[g],w[g]=u)}const m=f?f.length/tt:0;if(!Number.isInteger(m))throw new Error("Invalid packed postDecode condition flow");let C=new Uint32Array,M=new Uint32Array;if(f&&m!==0){if(a>65536)throw new Error("postDecode register offsets exceed Uint16 capacity");const u=new Uint16Array(m);for(let v=0;v<m;v+=1){const L=f[v*tt+yt]+1;if(L>e||v!==0&&L<=u[v-1])throw new Error("Invalid postDecode condition stage boundary");u[v]=L}const R=v=>{let L=0,O=m;for(;L<O;){const W=L+O>>>1;u[W]<=v?L=W+1:O=W}return L},U=new Uint16Array(e),g=new Uint16Array(e),p=new Uint32Array(m),S=new Uint32Array(m);for(let v=0;v<e;v+=1){if(c[v])continue;const L=R(v),O=R(i[v]);if(L>=O)continue;U[v]=L,g[v]=O;const W=n[v*H+z];p[L]+=W,O<m&&(p[O]+=W,S[O]+=W)}const b=new Uint32Array(m+1);for(let v=0;v<m;v+=1)b[v+1]=b[v]+p[v];C=b,M=new Uint32Array(b[m]);const I=new Uint32Array(b.subarray(0,m)),G=new Uint32Array(m);for(let v=0;v<m;v+=1)G[v]=b[v]+S[v];for(let v=0;v<e;v+=1){const L=U[v],O=g[v];if(L>=O)continue;const W=n[v*H+z],r=l[v];for(let T=0;T<W;T+=1){const x=r+T;O<m&&(M[I[O]]=Ot|x,I[O]+=1),M[G[L]]=x,G[L]+=1}}}return{registerOffsets:l,registerValueCount:a,conditionCarryStageStarts:C,conditionCarryEvents:M}}function Wt(t,n){return Number.isNaN(t)?n:Number.isNaN(n)?t:Math.min(t,n)}function dt(t,n){return Number.isNaN(t)?n:Number.isNaN(n)?t:Math.max(t,n)}function It(t){return t<0?-Math.round(-t):Math.round(t)}function Nt(t,n,o){return Math.min(o,Math.max(n,t))}const Ln={f32:(t,n)=>t.getFloat32(n,!0),f16:(t,n)=>Y(t.getUint16(n,!0)),u8:(t,n)=>t.getUint8(n),unorm8:(t,n)=>t.getUint8(n)/255,i8:(t,n)=>t.getInt8(n),snorm8:(t,n)=>Math.max(-1,t.getInt8(n)/127),u16:(t,n)=>t.getUint16(n,!0),unorm16:(t,n)=>t.getUint16(n,!0)/65535,i16:(t,n)=>t.getInt16(n,!0),snorm16:(t,n)=>Math.max(-1,t.getInt16(n,!0)/32767),u32:(t,n)=>t.getUint32(n,!0),i32:(t,n)=>t.getInt32(n,!0)};function Fn(t,n,o,s,e,i,f,_){const l=bn[n.format],c=Ln[n.format];for(let a=0;a<n.components;a+=1){const w=f+a*e;if(_)for(let E=0;E<s;E+=1){const h=n.byteOffset+(o+_[E])*n.byteStride+a*l;i[w+E]=c(t,h)}else{let E=n.byteOffset+o*n.byteStride+a*l;for(let h=0;h<s;h+=1)i[w+h]=c(t,E),E+=n.byteStride}}}function On(t,n,o){return Un(t[n],t[n+o],t[n+o*2],t[n+o*3])}function Bn(t,n,o,s){const e=t>>>24,i=2**((e>>>3)-15)/255;for(let f=0;f<3;f+=1){const _=(t>>>f*8&255)*i;n[o+f*s]=e&1<<f?-_:_}}function Wn(t,n,o){const s=t[n],e=t[n+o],i=t[n+o*2],f=dt(Math.abs(s),dt(Math.abs(e),Math.abs(i))),_=It(Nt(Math.floor(Math.log2(f))+15,0,31)),l=2**(_-15)/255,c=w=>It(Nt(Math.abs(w)/l,0,255)),a=(s<0?1:0)|(e<0?2:0)|(i<0?4:0);return(c(s)|c(e)<<8|c(i)<<16|(_<<3|a)<<24)>>>0}function qt(t,n){if(n<=2&&t.sh1)return[t.sh1,n];if(n===3&&t.sh1&&t.sh2)return[t.sh1,3];if(n<=7&&t.sh2)return[t.sh2,n-4];if(n<=11&&t.sh3a)return[t.sh3a,n-8];if(n<=14&&t.sh3b)return[t.sh3b,n-12]}const Vt=0,Gt=1,$t=2,Yt=3,Xt=4,Qt=5,qn=6,J=4294967295;function Vn(t,n,o){const{outputs:s}=n,e=new Uint32Array(qn);e.fill(J);let i=0;const f=(a,w)=>{w!==void 0&&(e[a]=o[w],i+=1)};f(Vt,s.position),f(Gt,s.scale),f($t,s.quaternion),f(Yt,s.opacity),f(Xt,s.alpha),f(Qt,s.color);const _=[],l=[],c=[];if(s.sh)for(let a=0;a<mn;a+=1){const w=qt(t,a);w&&(_.push(w[0]),l.push(w[1]),c.push(o[s.sh[a]]))}return{outputBases:e,shTargetArrays:_,shWordOffsets:new Uint8Array(l),shRegisterBases:new Uint32Array(c),updatesSortCenter:s.position!==void 0||s.scale!==void 0,writesOutputs:i!==0||_.length!==0}}function Gn(t,n,o,s,e,i,f,_,l){switch(t){case Q.Position:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c,w=(n+a)*4;f[_+c]=i[w],f[_+s+c]=i[w+1],f[_+s*2+c]=i[w+2]}break;case Q.Scale:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c,w=(n+a)*4,E=e.splat1[w+1],h=e.splat1[w+2];f[_+c]=Math.exp(Y(E>>>16)),f[_+s+c]=Math.exp(Y(h&65535)),f[_+s*2+c]=Math.exp(Y(h>>>16))}break;case Q.Quaternion:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c,w=(n+a)*4;Nn(e.splat1[w+3],f,_+c,s)}break;case Q.Opacity:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c;f[_+c]=gn(e.splat0[(n+a)*4+3])}break;case Q.Alpha:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c;f[_+c]=Y(e.splat0[(n+a)*4+3]&65535)}break;case Q.Color:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c,w=(n+a)*4,E=e.splat1[w],h=e.splat1[w+1];f[_+c]=Y(E&65535),f[_+s+c]=Y(E>>>16),f[_+s*2+c]=Y(h&65535)}break;default:{const c=t-Q.Sh0,a=qt(e,c);if(a)for(let w=0;w<o;w+=1){const E=(l==null?void 0:l[w])??w;Bn(a[0][(n+E)*4+a[1]],f,_+w,s)}else f.fill(0,_,_+o),f.fill(0,_+s,_+s+o),f.fill(0,_+s*2,_+s*2+o)}}}function $n(t,n,o){var w;const{registerOffsets:s,registerValueCount:e,conditionCarryStageStarts:i,conditionCarryEvents:f}=Dn(n),_=Pn(e,o);for(let E=0;E<s.length;E+=1)s[E]*=_;const l=(w=n.condition)==null?void 0:w.stages,c=((l==null?void 0:l.length)??0)/tt,a=((l==null?void 0:l[l.length-tt+yt])??-1)+1;return{outputPlan:Vn(t,n,s),registerBases:s,conditionStages:l,conditionStageCount:c,outputInstructionStart:a,conditionCarryStageStarts:i,conditionCarryEvents:f,blockSize:_,registerValueCount:e}}function Yn(t,n,o,s,e,i){for(let f=0;f<o;f+=1){const l=n[f]*i;for(let c=0;c<e;c+=1)t[l+c]=t[l+s[c]]}}function Xn(t,n){for(;t.nextStage<=n;){const o=t.stageStarts[t.nextStage],s=t.stageStarts[t.nextStage+1];for(let e=o;e<s;e+=1){const i=t.events[e],f=i&Rn;if(i&Ot){const _=t.activePositions[f];if(_===-1)throw new Error("Invalid postDecode condition carry removal");const l=t.activeCount-1,c=t.activeOffsets[l];_!==l&&(t.activeOffsets[_]=c,t.activePositions[c]=_),t.activePositions[f]=-1,t.activeCount=l}else{if(t.activePositions[f]!==-1)throw new Error("Invalid postDecode condition carry addition");t.activePositions[f]=t.activeCount,t.activeOffsets[t.activeCount]=f,t.activeCount+=1}}t.nextStage+=1}}function Qn(t,n,o,s,e=0){let i=e,f=t[s];for(;f!==-1;)o[i]=f,i+=1,f=n[f];return t[s]=-1,i}function Hn(t,n,o,s){o<0||o>=t.length||(n[s]=t[o],t[o]=s)}function Zn(t,n,o,s,e,i,f){for(let _=0;_<e;_+=1){const l=o+_*i,c=s+_*i;switch(t){case d.Negate:for(let a=0;a<f;a+=1)n[l+a]=-n[c+a];break;case d.Abs:for(let a=0;a<f;a+=1)n[l+a]=Math.abs(n[c+a]);break;case d.Log:for(let a=0;a<f;a+=1)n[l+a]=Math.log(n[c+a]);break;case d.Exp:for(let a=0;a<f;a+=1)n[l+a]=Math.exp(n[c+a]);break;case d.Floor:for(let a=0;a<f;a+=1)n[l+a]=Math.floor(n[c+a]);break;case d.Ceil:for(let a=0;a<f;a+=1)n[l+a]=Math.ceil(n[c+a]);break;case d.Round:for(let a=0;a<f;a+=1)n[l+a]=It(n[c+a]);break;case d.Sin:for(let a=0;a<f;a+=1)n[l+a]=Math.sin(n[c+a]);break;case d.Cos:for(let a=0;a<f;a+=1)n[l+a]=Math.cos(n[c+a]);break;case d.Acos:for(let a=0;a<f;a+=1)n[l+a]=Math.acos(n[c+a])}}}function jn(t,n,o,s,e,i,f,_,l){for(let c=0;c<i;c+=1){const a=o+c*_,w=s+c*_,E=e+(f===1?0:c*_);switch(t){case d.Add:for(let h=0;h<l;h+=1)n[a+h]=n[w+h]+n[E+h];break;case d.Subtract:for(let h=0;h<l;h+=1)n[a+h]=n[w+h]-n[E+h];break;case d.Multiply:for(let h=0;h<l;h+=1)n[a+h]=n[w+h]*n[E+h];break;case d.Divide:for(let h=0;h<l;h+=1)n[a+h]=n[w+h]/n[E+h];break;case d.Pow:for(let h=0;h<l;h+=1)n[a+h]=n[w+h]**n[E+h];break;case d.Min:for(let h=0;h<l;h+=1)n[a+h]=Wt(n[w+h],n[E+h]);break;case d.Max:for(let h=0;h<l;h+=1)n[a+h]=dt(n[w+h],n[E+h])}}}function Jn(t,n,o,s,e,i,f,_,l,c,a,w){const{attributes:E,instructions:h}=n;for(let A=f;A<_;A+=1){const y=A*H,m=h[y+gt];if(m===d.Constant)continue;const C=h[y+z],M=h[y+Pt],u=i[A],R=y+Dt,U=h[R],g=h[R+1],p=h[R+2],S=h[R+3],b=U===Z?0:i[U],I=g===Z?0:i[g],G=p===Z?0:i[p],v=S===Z?0:i[S],L=U===Z?0:ut(h,U),O=g===Z?0:ut(h,g),W=p===Z?0:ut(h,p);switch(m){case d.InputField:Gn(M,l,c,a,t,s,e,u,w);break;case d.InputAttribute:Fn(o,E[M],l,c,a,e,u,w);break;case d.Negate:case d.Abs:case d.Log:case d.Exp:case d.Floor:case d.Ceil:case d.Round:case d.Sin:case d.Cos:case d.Acos:Zn(m,e,u,b,C,a,c);break;case d.Sqrt:for(let r=0;r<C;r+=1){const T=u+r*a,x=b+r*a;for(let N=0;N<c;N+=1)e[T+N]=Math.sqrt(e[x+N])}break;case d.Normalize:for(let r=0;r<c;r+=1){let T=0;for(let N=0;N<C;N+=1){const D=e[b+N*a+r];T+=D*D}const x=Math.sqrt(T);for(let N=0;N<C;N+=1){const D=e[b+N*a+r];e[u+N*a+r]=x===0||!Number.isFinite(x)?D:D/x}}break;case d.Length:for(let r=0;r<c;r+=1){let T=0;for(let x=0;x<L;x+=1){const N=e[b+x*a+r];T+=N*N}e[u+r]=Math.sqrt(T)}break;case d.IsFinite:for(let r=0;r<c;r+=1){let T=!0;for(let x=0;x<L;x+=1)T&&(T=Number.isFinite(e[b+x*a+r]));e[u+r]=T?1:0}break;case d.Not:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]===0?1:0;break;case d.Add:case d.Subtract:case d.Multiply:case d.Divide:case d.Pow:case d.Min:case d.Max:jn(m,e,u,b,I,C,O,a,c);break;case d.Dot:for(let r=0;r<c;r+=1){let T=0;for(let x=0;x<L;x+=1)T+=e[b+x*a+r]*e[I+x*a+r];e[u+r]=T}break;case d.Cross:for(let r=0;r<c;r+=1)e[u+r]=e[b+a+r]*e[I+a*2+r]-e[b+a*2+r]*e[I+a+r],e[u+a+r]=e[b+a*2+r]*e[I+r]-e[b+r]*e[I+a*2+r],e[u+a*2+r]=e[b+r]*e[I+a+r]-e[b+a+r]*e[I+r];break;case d.Equal:case d.NotEqual:for(let r=0;r<c;r+=1){let T=!0;for(let x=0;x<L;x+=1)T&&(T=e[b+x*a+r]===e[I+x*a+r]);e[u+r]=(m===d.Equal?T:!T)?1:0}break;case d.Less:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]<e[I+r]?1:0;break;case d.LessEqual:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]<=e[I+r]?1:0;break;case d.Greater:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]>e[I+r]?1:0;break;case d.GreaterEqual:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]>=e[I+r]?1:0;break;case d.And:case d.Or:for(let r=0;r<c;r+=1){const T=m===d.And?e[b+r]!==0&&e[I+r]!==0:e[b+r]!==0||e[I+r]!==0;e[u+r]=T?1:0}break;case d.QuaternionMultiply:for(let r=0;r<c;r+=1){const T=e[b+r],x=e[b+a+r],N=e[b+a*2+r],D=e[b+a*3+r],F=e[I+r],q=e[I+a+r],$=e[I+a*2+r],B=e[I+a*3+r];e[u+r]=D*F+T*B+x*$-N*q,e[u+a+r]=D*q-T*$+x*B+N*F,e[u+a*2+r]=D*$+T*q-x*F+N*B,e[u+a*3+r]=D*B-T*F-x*q-N*$}break;case d.RotateVector:for(let r=0;r<c;r+=1){const T=e[b+r],x=e[b+a+r],N=e[b+a*2+r],D=e[b+a*3+r],F=e[I+r],q=e[I+a+r],$=e[I+a*2+r],B=2*(x*$-N*q),K=2*(N*F-T*$),X=2*(T*q-x*F);e[u+r]=F+D*B+x*X-N*K,e[u+a+r]=q+D*K+N*B-T*X,e[u+a*2+r]=$+D*X+T*K-x*B}break;case d.Select:for(let r=0;r<C;r+=1){const T=u+r*a,x=I+r*a,N=G+r*a;for(let D=0;D<c;D+=1)e[T+D]=e[b+D]!==0?e[x+D]:e[N+D]}break;case d.Clamp:for(let r=0;r<C;r+=1){const T=u+r*a,x=b+r*a,N=I+(O===1?0:r*a),D=G+(W===1?0:r*a);for(let F=0;F<c;F+=1)e[T+F]=Wt(dt(e[x+F],e[N+F]),e[D+F])}break;case d.Mix:for(let r=0;r<C;r+=1){const T=u+r*a,x=b+r*a,N=I+(O===1?0:r*a),D=G+(W===1?0:r*a);for(let F=0;F<c;F+=1){const q=e[x+F];e[T+F]=q+(e[N+F]-q)*e[D+F]}}break;case d.Vec2:for(let r=0;r<c;r+=1)e[u+r]=e[b+r],e[u+a+r]=e[I+r];break;case d.Vec3:for(let r=0;r<c;r+=1)e[u+r]=e[b+r],e[u+a+r]=e[I+r],e[u+a*2+r]=e[G+r];break;case d.Vec4:for(let r=0;r<c;r+=1)e[u+r]=e[b+r],e[u+a+r]=e[I+r],e[u+a*2+r]=e[G+r],e[u+a*3+r]=e[v+r];break;case d.Component:for(let r=0;r<c;r+=1)e[u+r]=e[b+M*a+r];break;case d.MaxComponentIndex:for(let r=0;r<c;r+=1){let T=0,x=e[b+r];for(let N=1;N<L;N+=1){const D=e[b+N*a+r];D>x&&(T=N,x=D)}e[u+r]=T}break;default:throw new Error(`Unknown postDecode opcode: ${m}`)}}}function Kn(t,n,o,s,e,i,f){const{constants:_,instructions:l}=n,{registerBases:c,conditionStages:a,conditionStageCount:w,outputInstructionStart:E,conditionCarryStageStarts:h,conditionCarryEvents:A,blockSize:y,outputPlan:m}=o,C=Bt(l),M=a?{stages:a,sourceIndices:new Uint16Array(y),laneIndices:new Uint16Array(y),nextIndices:new Int32Array(y).fill(-1),heads:new Int32Array(w+1).fill(-1)}:void 0,u=A.length===0?void 0:{stageStarts:h,events:A,nextStage:0,activeOffsets:new Uint16Array(i.length/y),activePositions:new Int32Array(i.length/y).fill(-1),activeCount:0},R=m.writesOutputs?new Uint32Array(y):void 0;for(let U=0;U<C;U+=1){const g=U*H;if(l[g+gt]!==d.Constant)continue;const p=c[U],S=l[g+z],b=l[g+Pt];for(let I=0;I<S;I+=1)i.fill(_[b+I],p+I*y,p+(I+1)*y)}for(let U=0;U<f;U+=y){let g=Math.min(y,f-U),p;u&&(u.nextStage=0,u.activeCount=0);for(let S=0;S<=w;S+=1){const b=S<w;if(M&&M.heads[S]!==-1){if(p!==M.sourceIndices)if(p)M.sourceIndices.set(p.subarray(0,g),0);else for(let L=0;L<g;L+=1)M.sourceIndices[L]=L;g=Qn(M.heads,M.nextIndices,M.sourceIndices,S,g),p=M.sourceIndices}const I=S*tt,G=M&&b?M.stages[I+xn]:E,v=M&&b?M.stages[I+yt]+1:C;if(g!==0&&Jn(t,n,s,e,i,c,G,v,U,g,y,p),M&&b&&g!==0){const L=M.stages[I+Lt],O=c[L],W=S+1,r=p,T=g;let x=0;const N=M.stages[I+En],D=M.stages[I+Mn],F=N===W,q=D===W,$=M.heads.length;if(F&&D===$||q&&N===$)for(let B=0;B<g;B+=1){if(i[O+B]!==0!==F)continue;const X=r==null?void 0:r[B];M.laneIndices[x]=B,X!==void 0&&(M.sourceIndices[x]=X),x+=1}else for(let B=0;B<g;B+=1){const K=(r==null?void 0:r[B])??B,X=i[O+B]!==0?N:D;X===W?(M.laneIndices[x]=B,r&&(M.sourceIndices[x]=K),x+=1):Hn(M.heads,M.nextIndices,X,K)}x!==0&&x!==T&&u&&(Xn(u,S),Yn(i,u.activeOffsets,u.activeCount,M.laneIndices,x,y)),(x!==T||r===M.laneIndices)&&(p=x===0?void 0:r?M.sourceIndices:M.laneIndices),g=x}}if(R&&g!==0){if(p)for(let S=0;S<g;S+=1)R[S]=(U+p[S])*4;else{let S=U*4;for(let b=0;b<g;b+=1)R[b]=S,S+=4}kn(t,e,i,m,R,y,g)}if(u)for(let S=0;S<u.activeCount;S+=1)u.activePositions[u.activeOffsets[S]]=-1}}function kn(t,n,o,s,e,i,f){const{outputBases:_}=s,l=_[Vt];if(l!==J)for(let A=0;A<f;A+=1){const y=e[A],m=l+A;n[y]=o[m],n[y+1]=o[m+i],n[y+2]=o[m+i*2]}const c=_[Gt];if(c!==J)for(let A=0;A<f;A+=1){const y=e[A],m=c+A,C=t.splat1[y+1]&65535;t.splat1[y+1]=(C|V(Math.log(o[m]))<<16)>>>0,t.splat1[y+2]=(V(Math.log(o[m+i]))|V(Math.log(o[m+i*2]))<<16)>>>0}const a=_[$t];if(a!==J)for(let A=0;A<f;A+=1){const y=e[A],m=On(o,a+A,i);m!==void 0&&(t.splat1[y+3]=m)}const w=_[Yt];if(w!==J)for(let A=0;A<f;A+=1){const y=e[A];t.splat0[y+3]=In(o[w+A])}const E=_[Xt];if(E!==J)for(let A=0;A<f;A+=1){const y=e[A]+3;t.splat0[y]=(t.splat0[y]&4294901760|V(Nt(o[E+A],0,1)))>>>0}const h=_[Qt];if(h!==J)for(let A=0;A<f;A+=1){const y=e[A],m=h+A;t.splat1[y]=(V(o[m])|V(o[m+i])<<16)>>>0,t.splat1[y+1]=(t.splat1[y+1]&4294901760|V(o[m+i*2]))>>>0}for(let A=0;A<s.shTargetArrays.length;A+=1){const y=s.shTargetArrays[A],m=s.shWordOffsets[A],C=s.shRegisterBases[A];for(let M=0;M<f;M+=1){const u=e[M];y[u+m]=Wn(o,C+M,i)}}if(s.updatesSortCenter)for(let A=0;A<f;A+=1){const y=e[A],m=t.splat1[y+1]>>>16===64512&&(t.splat1[y+2]&65535)===64512&&t.splat1[y+2]>>>16===64512,C=(y>>>2)*3;m?(t.sortCenters[C]=Number.NaN,t.sortCenters[C+1]=Number.NaN,t.sortCenters[C+2]=Number.NaN):(t.sortCenters[C]=n[y],t.sortCenters[C+1]=n[y+1],t.sortCenters[C+2]=n[y+2])}}function zn(t,n){let o=t.numSplats;for(const _ of n.attributes)o=Math.min(o,_.count);if(o===0||n.instructions.length===0)return;const s=$n(t,n,o),e=new Float32Array(s.registerValueCount*s.blockSize),i=new DataView(n.attributeData.buffer,n.attributeData.byteOffset,n.attributeData.byteLength),f=new Float32Array(t.splat0.buffer,t.splat0.byteOffset,t.splat0.length);Kn(t,n,s,i,f,e,o)}function vt(t){const n=new Set,o=new Set;function s(e){!e||typeof e!="object"||o.has(e)||(o.add(e),e instanceof ArrayBuffer?n.add(e):ArrayBuffer.isView(e)?n.add(e.buffer):Object.values(e).forEach(s))}return s(t),[...n]}const te={setSortCenterState:ne,sortCenters32:ee,loadSplats:re,nextChunk:se};let mt;function Ht(){return(mt==null?void 0:mt.buffer.byteLength)??0}function ne({centerUpdateRangeIndices:t,updateCenters:n,matrixUpdateRangeIndices:o,updateMatrices:s,rangeMeshIds:e,rangeBases:i,rangeCounts:f}){Kt(t,n,o,s,e,i,f)}function ee({numSplats:t,cameraPosition:n,direction:o,radial:s,ordering:e}){return{activeSplats:kt(t,n[0],n[1],n[2],o[0],o[1],o[2],s,e),ordering:e}}async function Zt(t){const{id:n,name:o,args:s}=t.data;try{const e=te[o];if(!e)throw new Error(`Unknown worker RPC: ${o}`);const f=await e(s,{sendStatus:_=>{self.postMessage({id:n,status:_},{transfer:vt(_)})}});self.postMessage({id:n,result:f,wasmMemoryBytes:Ht()},{transfer:vt(f)})}catch(e){console.warn(`Worker error: ${e}`),self.postMessage({id:n,error:e,wasmMemoryBytes:Ht()},{transfer:vt(e)})}}async function oe({decoder:t,fileBytes:n,url:o,requestHeader:s,withCredentials:e,chunked:i,chunkedLength:f,sendStatus:_}){if(n){const y=n.length;return y>0&&t.set_expected_input_size(y),_({loaded:y,total:y}),t.push(n),t.finish()}const l=f??0;if(!Number.isSafeInteger(l)||l<0)throw new Error("streamLength must be a non-negative integer");let c=l,a=0,w;if(o){const y=new Request(o,{headers:s?new Headers(s):void 0,credentials:e?"include":"same-origin"}),m=await fetch(y);if(!m.ok||!m.body)throw new Error(`Failed to fetch "${o}": ${m.status} ${m.statusText}`);w=m.body;const C=Number(m.headers.get("Content-Length")||"0"),M=Number.isSafeInteger(C)&&C>0?C:0;c||(c=M);const u=m.headers.get("Content-Encoding"),R=!u||u.toLowerCase()==="identity";m.type==="basic"&&R&&(a=M)}else if(!i)throw new Error("No url or fileBytes provided");const E=w==null?void 0:w.getReader(),h=async()=>{if(E){const{done:m,value:C}=await E.read();return m?void 0:C}const y=await new Promise(m=>{jt=m,_({nextChunk:!0})});return y.length===0?void 0:y};let A=0;try{for(a>0&&t.set_expected_input_size(a);;){const y=await h();if(!y)break;if(A+=y.length,a>0&&A>a)throw new Error(`Input length exceeds the expected ${a} bytes`);_({loaded:A,total:c}),t.push(y)}if(a>0&&A!==a)throw new Error(`Input length mismatch: expected ${a} bytes, received ${A}`);return i&&c===0&&_({loaded:A,total:A}),t.finish()}catch(y){try{await(E==null?void 0:E.cancel(y))}catch{}throw y}finally{E==null||E.releaseLock()}}function ae(t){return{numSplats:t.numSplats,splatArrays:[t.splat0,t.splat1],sortCenters:t.sortCenters,extra:{sh1:t.sh1,sh2:t.sh2,sh3a:t.sh3a,sh3b:t.sh3b}}}async function re({url:t,requestHeader:n,withCredentials:o,fileBytes:s,fileType:e,pathName:i,chunked:f,chunkedLength:_,postDecode:l},{sendStatus:c}){const a=Jt(e,i??t),w=await oe({decoder:a,fileBytes:s,url:t,requestHeader:n,withCredentials:o,chunked:f,chunkedLength:_,sendStatus:c});return l&&zn(w,l),ae(w)}let jt=t=>{};async function se({chunk:t}){jt(t)}async function ce(){let t;const n=new Promise(i=>{t=i}),o=[],s=i=>{if(i.data.name==="init-wasm"){t(i.data.module);return}o.push(i)};self.addEventListener("message",s),mt=(await _n({module_or_path:await n})).memory,self.removeEventListener("message",s),self.addEventListener("message",Zt);for(const i of o)Zt(i);o.length=0}ce().catch(console.error)})();\n//# sourceMappingURL=worker-DUqmK1X0.js.map\n',$A=typeof self<"u"&&self.Blob&&new Blob([JI],{type:"text/javascript;charset=utf-8"});function gQ(B){let A;try{if(A=$A&&(self.URL||self.webkitURL).createObjectURL($A),!A)throw"";const I=new Worker(A,{name:B==null?void 0:B.name});return I.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(A)}),I}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(JI),{name:B==null?void 0:B.name})}finally{A&&(self.URL||self.webkitURL).revokeObjectURL(A)}}const lI=1024*1024,JA=64*lI,AI=256*lI,II=3*60*1e3,QQ=3*1e3;function BQ(B){const I=(Math.min(AI,Math.max(JA,B))-JA)/(AI-JA);return Math.round(II+I*(QQ-II))}function CQ(B){let A=-1,I=Number.POSITIVE_INFINITY;for(let g=B.length-1;g>=0;g-=1){const Q=B[g].peakWasmMemoryBytes;Q<I&&(A=g,I=Q)}return A}const NA=class NA{constructor(){this.messages={},this.peakWasmMemoryBytes=0,this.worker=new gQ,this.worker.onmessage=A=>this.onMessage(A),MI.then(A=>{this.worker.postMessage({name:"init-wasm",module:A})})}onMessage(A){const{id:I,result:g,error:Q,status:C,wasmMemoryBytes:t}=A.data;Number.isSafeInteger(t)&&t>=0&&(this.peakWasmMemoryBytes=Math.max(this.peakWasmMemoryBytes,t));const E=this.messages[I];if(E){if(C!==void 0){E.statusQueue=E.statusQueue.then(()=>{var i;if(this.messages[I]===E)return(i=E.onStatus)==null?void 0:i.call(E,C)}),E.statusQueue.catch(()=>{});return}E.statusQueue.then(()=>{if(Q!==void 0)throw Q;return g}).finally(()=>{delete this.messages[I]}).then(E.resolve,E.reject)}}async call(A,I,g={}){const Q=++NA.currentId,C=new Promise((t,E)=>{this.messages[Q]={resolve:i=>t(i),reject:E,onStatus:g.onStatus,statusQueue:Promise.resolve()}});return this.worker.postMessage({id:Q,name:A,args:I},{transfer:rI(I)}),C}dispose(){this.worker.terminate();const A=Object.values(this.messages);this.messages={};for(const I of A)I.reject(new Error("Worker terminate"))}};NA.currentId=0;let hA=NA;class EQ{constructor(A=4){this.numWorkers=0,this.freelist=[],this.idleWorkerTimeouts=new Map,this.queue=[],this.maxWorkers=A}async withWorker(A){const I=await this.allocWorker();try{return await A(I)}finally{this.freeWorker(I)}}async allocWorker(){const A=CQ(this.freelist);if(A!==-1){const I=this.freelist.splice(A,1)[0],g=this.idleWorkerTimeouts.get(I);return g!==void 0&&(clearTimeout(g),this.idleWorkerTimeouts.delete(I)),I}if(this.numWorkers<this.maxWorkers){const I=new hA;return this.numWorkers+=1,I}return new Promise(I=>{this.queue.push(I)})}freeWorker(A){if(this.numWorkers>this.maxWorkers){A.dispose(),this.numWorkers-=1;return}const I=this.queue.shift();if(I){I(A);return}this.freelist.push(A);const g=setTimeout(()=>{this.idleWorkerTimeouts.delete(A);const Q=this.freelist.indexOf(A);Q!==-1&&(this.freelist.splice(Q,1),A.dispose(),this.numWorkers-=1)},BQ(A.peakWasmMemoryBytes));this.idleWorkerTimeouts.set(A,g)}}const iQ=new EQ,BA=new e.Vector3,CA=4096,yA=CA*4,gI=1/255;function QI(B){return Math.max(1,Math.ceil(B/yA))*yA}function tQ(B){const A=B.getWorldScale(BA);return(A.x+A.y+A.z)/3}const N=class N extends e.Mesh{constructor(A){if(!A)throw new Error("GaussianSplatRenderer options are required");if(!A.renderer)throw new Error("renderer is required in GaussianSplatRenderer options");const I=N.makeUniforms();Object.assign(I,A.extraUniforms??{});const g=LI(),Q=A.premultipliedAlpha??!0,C=new $g,t=new e.ShaderMaterial({glslVersion:e.GLSL3,vertexShader:A.vertexShader??g.splatVertex,fragmentShader:A.fragmentShader??g.splatFragment,uniforms:I,premultipliedAlpha:Q,transparent:A.transparent??!0,depthTest:A.depthTest??!0,depthWrite:A.depthWrite??!1,side:e.DoubleSide,allowOverride:!1});super(C,t),this.renderSize=new e.Vector2,this.lastFrame=-1,this.updateTimeoutId=-1,this.orderingTexture=null,this.orderingBuffer=new Uint32Array(0),this.maxSplats=0,this.activeSplats=0,this.accumulators=[],this.sorting=!1,this.sortDirty=!1,this.lastSortTime=0,this.sortWorker=null,this.sortedCenter=new e.Vector3().setScalar(Number.NEGATIVE_INFINITY),this.sortedDir=new e.Vector3().setScalar(0),this.sortCenterCache=new ZI,this.sortStateRevision=0,this.uploadedSortStateRevision=-1,this.updateRunning=!1,this.updatePromise=Promise.resolve(),this.queuedUpdate=null,this.disposed=!1,this.superXY=1,this.material=t,this.uniforms=I,this.frustumCulled=!1,this.renderer=A.renderer,this.onDirty=A.onDirty,this.dirty=!0,this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!0,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.minPixelRadius=A.minPixelRadius??1,this.maxPixelRadius=A.maxPixelRadius??512,this.minAlpha=A.minAlpha??gI,this.enable2DGS=A.enable2DGS??!1,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.clipXY=A.clipXY??1.25,this.focalAdjustment=A.focalAdjustment??2,this.sortRadial=A.sortRadial??!1,this.minSortIntervalMs=A.minSortIntervalMs??0;const{timer:E,ownsTimer:i}=RI(A.timer);this.timer=E,this.ownsTimer=i,this.display=this.createAccumulator(),this.current=this.display,this.accumulators.push(this.createAccumulator());const s=this.renderer.getContext().getExtension("WEBGL_provoking_vertex");if(s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL),A.target){const{width:D,height:o,doubleBuffer:w,superXY:n,...a}=A.target,r=Math.max(1,Math.min(4,n??1));if(D*r>8192||o*r>8192)throw new Error("Target size too large");this.superXY=r;const h=D*r,c=o*r,y={format:e.RGBAFormat,type:e.UnsignedByteType,colorSpace:e.SRGBColorSpace,...a};this.target=new e.WebGLRenderTarget(h,c,y),w&&(this.backTarget=new e.WebGLRenderTarget(h,c,y))}}raycast(A,I){}static makeUniforms(){return{renderSize:{value:new e.Vector2},near:{value:.1},far:{value:1e3},renderToViewQuat:{value:new e.Quaternion},renderToViewPos:{value:new e.Vector3},renderToViewScale:{value:1},maxStdDev:{value:1},minPixelRadius:{value:1},maxPixelRadius:{value:512},minAlpha:{value:gI},enable2DGS:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},clipXY:{value:1.25},focalAdjustment:{value:2},encodeLinear:{value:!1},ordering:{type:"t",value:N.emptyOrdering},splats:{type:"t",value:K.emptyTexture},splats2:{type:"t",value:K.emptyTexture},time:{value:0},deltaTime:{value:0},debugFlag:{value:!1}}}dispose(){var I;if(this.disposed)return;this.disposed=!0,this.queuedUpdate=null,(I=super.dispose)==null||I.call(this),this.target&&(this.target.dispose(),this.target=void 0),this.backTarget&&(this.backTarget.dispose(),this.backTarget=void 0),this.orderingTexture&&(this.orderingTexture.dispose(),this.orderingTexture=null);const A=new Set;A.add(this.display),A.add(this.current);for(const g of this.accumulators)A.add(g);for(const g of A)g.dispose();this.accumulators.length=0,this.resetSortWorker(),this.releaseReadbackBuffers(),this.orderingBuffer=new Uint32Array(0),this.maxSplats=0,this.activeSplats=0,this.geometry.dispose(),this.material.dispose()}setDirty(){var A;this.dirty||(this.dirty=!0,(A=this.onDirty)==null||A.call(this))}resetSortWorker(){var A;(A=this.sortWorker)==null||A.dispose(),this.sortWorker=null,this.sortCenterCache.dispose(),this.uploadedSortStateRevision=-1}releaseReadbackBuffers(){this.superPixels=void 0,this.targetPixels=void 0}createAccumulator(){return new K}takeAccumulator(){return this.accumulators.pop()??this.createAccumulator()}releaseAccumulator(A){this.accumulators.push(A)}disposeOversizedAccumulators(A){for(const I of this.accumulators)I.maxSplats>A&&I.dispose()}onBeforeRender(A,I,g){var y;const Q=N.gaussianSplatOverride??this,C=A.info.render.frame,t=C!==Q.lastFrame;Q.lastFrame=C;const E=A.getRenderTarget(),i=sQ(E);if(E){if(Q.renderSize.set(E.width,E.height),i&&Q.renderSize.x===1&&Q.renderSize.y===1){const S=(y=A.xr.getSession())==null?void 0:y.renderState.baseLayer;S&&(Q.renderSize.x=S.framebufferWidth,Q.renderSize.y=S.framebufferHeight)}}else A.getDrawingBufferSize(Q.renderSize);if(this.uniforms.renderSize.value.copy(Q.renderSize),Q.autoUpdate&&t){const S=Q.preUpdate&&!A.xr.isPresenting;let M=g;if(A.xr.isPresenting){const k=A.xr.getCamera();M=k.cameras[0]??k}S?Q.updateInternal({scene:I,camera:M,autoUpdate:!0,shrinkResources:!1}):Q.updateTimeoutId===-1&&(Q.updateTimeoutId=setTimeout(()=>{Q.updateTimeoutId=-1,Q.updateInternal({scene:I,camera:M,autoUpdate:!0,shrinkResources:!1})},1))}const s=g;this.uniforms.near.value=s.near,this.uniforms.far.value=s.far;const D=this.geometry;D.instanceCount=Q.activeSplats;const o=Q.display,w=new e.Matrix4().makeTranslation(o.viewOrigin);g.matrixWorld.clone().invert().multiply(w).decompose(this.uniforms.renderToViewPos.value,this.uniforms.renderToViewQuat.value,BA),this.uniforms.renderToViewScale.value=(BA.x+BA.y+BA.z)/3,this.uniforms.maxStdDev.value=Q.maxStdDev,this.uniforms.minPixelRadius.value=Q.minPixelRadius,this.uniforms.maxPixelRadius.value=Q.maxPixelRadius,this.uniforms.minAlpha.value=Q.minAlpha,this.uniforms.enable2DGS.value=Q.enable2DGS,this.uniforms.preBlurAmount.value=Q.preBlurAmount,this.uniforms.blurAmount.value=Q.blurAmount,this.uniforms.clipXY.value=Q.clipXY,this.uniforms.focalAdjustment.value=Q.focalAdjustment;const h=E===null?A.outputColorSpace:i?E.texture.colorSpace:e.ColorManagement.workingColorSpace;this.uniforms.encodeLinear.value=h!==e.SRGBColorSpace,this.uniforms.ordering.value=Q.orderingTexture??N.emptyOrdering;const c=o.getTextures();this.uniforms.splats.value=c[0],this.uniforms.splats2.value=c[1],this.uniforms.time.value=o.time,this.uniforms.deltaTime.value=o.deltaTime,this.uniforms.debugFlag.value=performance.now()/1e3%2<1,Q.dirty=!1}clearSplats(){this.activeSplats=0,this.display.numSplats=0,this.setDirty()}async update({scene:A,camera:I}){await this.updateInternal({scene:A,camera:I,autoUpdate:!1,shrinkResources:!1})}async shrinkResources({scene:A,camera:I}){await this.updateInternal({scene:A,camera:I,autoUpdate:!1,shrinkResources:!0})}updateInternal(A){if(this.disposed)return Promise.resolve();const I=this.queuedUpdate;return this.queuedUpdate={scene:A.scene,camera:A.camera,autoUpdate:A.autoUpdate&&((I==null?void 0:I.autoUpdate)??!0),shrinkResources:A.shrinkResources||((I==null?void 0:I.shrinkResources)??!1)},this.updateRunning||(this.updateRunning=!0,this.updatePromise=this.drainUpdates()),this.updatePromise}async drainUpdates(){try{for(;this.queuedUpdate;){const A=this.queuedUpdate;this.queuedUpdate=null,await this.performUpdate(A)}}catch(A){throw this.queuedUpdate=null,A}finally{this.updateRunning=!1}}async performUpdate({scene:A,camera:I,autoUpdate:g,shrinkResources:Q}){const C=this.renderer;Q&&this.releaseReadbackBuffers(),this.ownsTimer&&this.timer.update();const t=I.getWorldPosition(new e.Vector3),E=I.getWorldDirection(new e.Vector3),i=t.distanceTo(this.sortedCenter)>.001*tQ(I)||E.dot(this.sortedDir)<.999||this.sortRadial!==this.sortedRadial,s=this.takeAccumulator();if(s===this.current)throw new Error("Next accumulator is the same as the current accumulator");let D;try{D=s.prepareGenerate({renderer:C,scene:A,timer:this.timer,camera:I,previous:this.current})}catch(y){throw this.releaseAccumulator(s),y}const{version:o,sortUpdated:w,requiredMaxSplats:n,generate:a}=D,r=Q&&QI(n)<this.maxSplats,h=!g||i||o!==this.current.version,c=r||i||w;if(!h)this.releaseAccumulator(s);else{try{a(Q)}catch(y){throw this.releaseAccumulator(s),y}w&&(this.sortStateRevision+=1),this.display.mappingVersion===s.mappingVersion&&!c?(this.releaseAccumulator(this.display),this.display=s):this.display!==this.current&&this.releaseAccumulator(this.current),this.current=s,this.sortDirty||(this.sortDirty=c),this.setDirty()}await this.driveSort(r),Q&&this.disposeOversizedAccumulators(this.current.maxSplats)}async driveSort(A=!1){var t;if(this.disposed||this.sorting||!this.sortDirty)return;const I=performance.now(),g=this.lastSortTime?this.lastSortTime+this.minSortIntervalMs:I;if(I<g&&(await new Promise(E=>setTimeout(E,g-I)),this.disposed))return;this.sorting=!0,this.sortDirty=!1,this.lastSortTime=performance.now();const Q=this.current,C=this.activeSplats;try{A&&this.resetSortWorker();const E=this.sortRadial;this.sortWorker&&this.sortedRadial!==E&&this.resetSortWorker(),this.sortWorker??(this.sortWorker=new hA);const i=this.sortWorker,{numSplats:s,maxSplats:D}=Q,o=QI(D),w=o/yA;this.maxSplats=A?o:Math.max(this.maxSplats,o),this.orderingBuffer.length!==this.maxSplats&&(this.orderingBuffer=new Uint32Array(this.maxSplats));const n=this.sortStateRevision;if(this.uploadedSortStateRevision!==n){const{payload:c,commit:y}=this.sortCenterCache.prepare(Q);await i.call("setSortCenterState",c),y(),this.uploadedSortStateRevision=n}const a=await i.call("sortCenters32",{numSplats:s,cameraPosition:[Q.viewOrigin.x,Q.viewOrigin.y,Q.viewOrigin.z],direction:[Q.viewDirection.x,Q.viewDirection.y,Q.viewDirection.z],radial:E,ordering:this.orderingBuffer});this.activeSplats=a.activeSplats;const r=Math.ceil(a.activeSplats/yA),h=(t=this.orderingTexture)==null?void 0:t.image.data;if(this.orderingTexture&&(w>this.orderingTexture.image.height||A&&w!==this.orderingTexture.image.height)&&(this.orderingTexture.dispose(),this.orderingTexture=null),this.orderingTexture){this.orderingTexture.image.data=a.ordering;const c=this.renderer;c.properties.has(this.orderingTexture)?r>0&&FI(c,this.orderingTexture,CA,r,a.ordering):this.orderingTexture.needsUpdate=!0}else{const c=new e.DataTexture(a.ordering,CA,w,e.RGBAIntegerFormat,e.UnsignedIntType);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.orderingTexture=c}this.orderingBuffer=h instanceof Uint32Array&&h.length===this.maxSplats?h:new Uint32Array(this.maxSplats),this.sortedCenter.copy(Q.viewOrigin),this.sortedDir.copy(Q.viewDirection),this.sortedRadial=E,this.current===Q&&this.display!==Q&&(this.releaseAccumulator(this.display),this.display=Q),this.setDirty()}catch(E){if(this.disposed)return;throw this.sortDirty=!0,this.current===Q&&Q!==this.display&&this.accumulators.length===0&&(this.current=this.display,this.releaseAccumulator(Q),this.activeSplats=C,this.sortDirty=!1,this.uploadedSortStateRevision=-1),E}finally{this.sorting=!1}}render(A,I){const g=N.gaussianSplatOverride;try{N.gaussianSplatOverride=this,this.renderer.render(A,I)}finally{N.gaussianSplatOverride=g}}renderTarget({scene:A,camera:I}){const g=this.backTarget??this.target;if(!g)throw new Error("No target");const Q=this.renderer.getRenderTarget(),C=N.gaussianSplatOverride;try{this.renderer.setRenderTarget(g),N.gaussianSplatOverride=this,this.renderer.render(A,I)}finally{N.gaussianSplatOverride=C,this.renderer.setRenderTarget(Q)}return g!==this.target&&([this.target,this.backTarget]=[this.backTarget,this.target]),g}async readTarget(){if(!this.target)throw new Error("Must initialize with target");const{width:A,height:I}=this.target,g=A*I*4;(!this.superPixels||this.superPixels.length<g)&&(this.superPixels=new Uint8Array(g));const Q=this.superPixels;await this.renderer.readRenderTargetPixelsAsync(this.target,0,0,A,I,Q);const{superXY:C}=this;if(C===1)return Q;const t=A/C,E=I/C,i=t*E*4;(!this.targetPixels||this.targetPixels.length<i)&&(this.targetPixels=new Uint8Array(i));const s=this.targetPixels,D=C*C;for(let o=0;o<E;o++){const w=o*t;for(let n=0;n<t;n++){const a=n*C;let r=0,h=0,c=0,y=0;for(let M=0;M<C;M++){const k=(o*C+M)*A;for(let l=0;l<C;l++){const d=(k+a+l)*4;r+=Q[d],h+=Q[d+1],c+=Q[d+2],y+=Q[d+3]}}const S=(w+n)*4;s[S]=r/D,s[S+1]=h/D,s[S+2]=c/D,s[S+3]=y/D}}return s}async renderReadTarget({scene:A,camera:I}){return this.renderTarget({scene:A,camera:I}),this.readTarget()}async renderCubeMap({scene:A,worldCenter:I,size:g=256,near:Q=.1,far:C=1e3,hideObjects:t=[],update:E=!0,filter:i=!1}){if(!N.cubeRender||N.cubeRender.target.width!==g||N.cubeRender.near!==Q||N.cubeRender.far!==C){N.cubeRender&&N.cubeRender.target.dispose();const n=new e.WebGLCubeRenderTarget(g,{format:e.RGBAFormat,type:e.UnsignedByteType,generateMipmaps:i,minFilter:i?e.LinearMipMapLinearFilter:e.LinearFilter,magFilter:e.LinearFilter,colorSpace:i?e.LinearSRGBColorSpace:e.SRGBColorSpace}),a=new e.CubeCamera(Q,C,n);N.cubeRender={target:n,cubeCamera:a,near:Q,far:C}}const{target:s,cubeCamera:D}=N.cubeRender;D.position.copy(I);const o=new Map;for(const n of t)o.has(n)||o.set(n,n.visible),n.visible=!1;const w=N.gaussianSplatOverride;try{if(E){const n=new e.Camera;n.position.copy(I),await this.update({scene:A,camera:n})}return N.gaussianSplatOverride=this,D.update(this.renderer,A),s.texture}finally{N.gaussianSplatOverride=w;for(const[n,a]of o.entries())n.visible=a}}async readCubeTargets(){if(!N.cubeRender)throw new Error("No cube render");const{target:A}=N.cubeRender,{width:I,height:g}=A,Q=[],C=[];for(let t=0;t<A.texture.images.length;++t){const E=I*g*4,i=new Uint8Array(E);C.push(i);const s=this.renderer.readRenderTargetPixelsAsync(A,0,0,I,g,i,t);Q.push(s)}return await Promise.all(Q),C}async renderEnvMap({scene:A,worldCenter:I,size:g=256,near:Q=.1,far:C=1e3,hideObjects:t=[],update:E=!0}){var s;const i=await this.renderCubeMap({scene:A,worldCenter:I,size:g,near:Q,far:C,hideObjects:t,update:E,filter:!0});return N.pmrem||(N.pmrem=new e.PMREMGenerator(this.renderer)),(s=N.pmrem)==null?void 0:s.fromCubemap(i).texture}recurseSetEnvMap(A,I){A.traverse(g=>{if(g instanceof e.Mesh)if(Array.isArray(g.material))for(const Q of g.material)Q instanceof e.MeshStandardMaterial&&(Q.envMap=I);else g.material instanceof e.MeshStandardMaterial&&(g.material.envMap=I)})}get premultipliedAlpha(){return this.material.premultipliedAlpha}set premultipliedAlpha(A){this.material.premultipliedAlpha!==A&&(this.material.premultipliedAlpha=A,this.material.needsUpdate=!0)}get transparent(){return this.material.transparent}set transparent(A){this.material.transparent!==A&&(this.material.transparent=A,this.material.needsUpdate=!0)}get depthTest(){return this.material.depthTest}set depthTest(A){this.material.depthTest=A}get depthWrite(){return this.material.depthWrite}set depthWrite(A){this.material.depthWrite=A}};N.emptyOrdering=(()=>{const A=4*CA,I=new Uint32Array(A),g=new e.DataTexture(I,CA,1);return g.format=e.RGBAIntegerFormat,g.type=e.UnsignedIntType,g.internalFormat="RGBA32UI",g.needsUpdate=!0,g})(),N.cubeRender=null,N.pmrem=null;let fA=N;function sQ(B){return B==null?void 0:B.isXRRenderTarget}var UI;const oQ=15,O={float:1,bool:1,vec2:2,vec3:3,vec4:4,quaternion:4};class lA{constructor(A,I,g){this.type=A,this.register=I,this.owner=g}}const DQ=0,eQ=1,aQ=2,nQ=3,wQ=4,BI=7,CI=65535,dI={f32:4,f16:2,u8:1,unorm8:1,i8:1,snorm8:1,u16:2,unorm16:2,i16:2,snorm16:2,u32:4,i32:4};class YI{constructor(A,I){this.owner=A,this.coefficients=I}}class cQ{constructor(A){this.owner=A}coefficient(A){if(!Number.isInteger(A)||A<0||A>=oQ)throw new Error("SH coefficient index must be between 0 and 14");return this.owner.inputField("vec3",7+A)}map(A){const I=[];let g=0;for(let Q=1;Q<=3;Q+=1)for(let C=-Q;C<=Q;C+=1)I.push(this.owner.coerce(A(this.coefficient(g),{index:g,degree:Q,order:C}),"vec3")),g+=1;return new YI(this.owner,I)}}const rQ=0,hQ=1,yQ=2,GQ=3,NQ=4,UA=5,SQ=Symbol("SplatPostDecodeProgram"),uI=["float","vec2","vec3","vec4"];function FQ(B){if(typeof B=="boolean")return"bool";if(typeof B=="number")return"float";if(Array.isArray(B)&&B.length>=2&&B.length<=4)return uI[B.length-1];throw new Error("Unsupported postDecode literal")}function RQ(B,A){return`${B}:${A.map(I=>Object.is(I,-0)?"-0":I).join(":")}`}class MQ{constructor(){this.instructions=[],this.constants=[],this.attributes=[],this.constantRegisters=new Map,this.inputRegisters=new Map,this.op=this.createOperations();const A=this,I=new cQ(this);this.splat={get position(){return A.inputField("vec3",1)},get scale(){return A.inputField("vec3",2)},get quaternion(){return A.inputField("quaternion",3)},get opacity(){return A.inputField("float",4)},get alpha(){return A.inputField("float",5)},get color(){return A.inputField("vec3",6)},sh:I}}instruction(A,I,g=[],Q=0){if(this.instructions.length>=4096)throw new Error("postDecode program exceeds 4096 instructions");const C=this.instructions.length;return this.instructions.push({opcode:I,type:A,args:g,immediate:Q}),new lA(A,C,this)}inputField(A,I){const g=this.inputRegisters.get(I);if(g)return g;const Q=this.instruction(A,2,[],I);return this.inputRegisters.set(I,Q),Q}attribute(A){if(!ArrayBuffer.isView(A.data))throw new Error("postDecode attribute data must be an ArrayBuffer view");const I=dI[A.format];if(!I)throw new Error(`Unknown postDecode format: ${A.format}`);const g=A.count,Q=A.components??1,C=A.byteOffset??0,t=I*Q,E=A.byteStride??t;if(!Number.isSafeInteger(g)||g<0)throw new Error("postDecode attribute count must be non-negative");if(!Number.isInteger(Q)||Q<1||Q>4)throw new Error("postDecode attribute components must be between 1 and 4");if(!Number.isSafeInteger(C)||C<0||!Number.isSafeInteger(E)||E<t)throw new Error("Invalid postDecode attribute byteOffset or byteStride");const i=g===0?C:C+(g-1)*E+t;if(!Number.isSafeInteger(i)||i>A.data.byteLength)throw new Error("postDecode attribute data is too small");const s=this.attributes.length;return this.attributes.push({data:A.data,format:A.format,count:g,components:Q,byteOffset:C,byteStride:E}),this.instruction(uI[Q-1],3,[],s)}coerce(A,I){if(A instanceof lA){if(A.owner!==this)throw new Error("Cannot combine values from different postDecode programs");if(I&&A.type!==I&&!(I==="quaternion"&&A.type==="vec4"||I==="vec4"&&A.type==="quaternion"))throw new Error(`Expected ${I}, received ${A.type}`);return A}const g=I??FQ(A),Q=typeof A=="boolean"?[A?1:0]:typeof A=="number"?[A]:[...A],C=O[g];if(Q.length!==C)throw new Error(`Expected ${C} values for ${g}`);const t=Q.map(Math.fround);if(!t.every(Number.isFinite))throw new Error("postDecode constants must be finite");const E=RQ(g,t),i=this.constantRegisters.get(E);if(i)return i;const s=this.constants.length;this.constants.push(...t);const D=this.instruction(g,1,[],s);return this.constantRegisters.set(E,D),D}unary(A,I,g){const Q=this.coerce(I);return this.instruction(g??Q.type,A,[Q.register])}binary(A,I,g,Q){const C=this.coerce(I),t=this.coerceForBinary(g,C.type);return this.instruction(Q??C.type,A,[C.register,t.register])}ternary(A,I,g,Q){const C=this.coerce(I),t=this.coerceForBinary(g,C.type),E=this.coerceForBinary(Q,C.type);return this.instruction(C.type,A,[C.register,t.register,E.register])}coerceForBinary(A,I){return A instanceof lA?A.type==="float"&&O[I]>1?this.coerce(A):this.coerce(A,I):this.coerce(A,typeof A=="number"&&O[I]>1?"float":I)}createOperations(){const A=E=>(i,...s)=>{let D=this.coerce(i);for(const o of s)D=this.binary(E,D,o);return D},I=E=>(i,s)=>this.binary(E,i,s),g=E=>i=>this.unary(E,i),Q=E=>(i,s)=>this.binary(E,i,s,"bool"),C=E=>(i,...s)=>{let D=this.coerce(i,"bool");for(const o of s)D=this.binary(E,D,o,"bool");return D},t=(E,i,s)=>this.instruction(i,E,s.map(D=>this.coerce(D,"float").register));return{add:A(30),sub:I(31),mul:A(32),div:I(33),min:I(34),max:I(35),pow:I(36),clamp:(E,i,s)=>this.ternary(61,E,i,s),mix:(E,i,s)=>this.ternary(62,E,i,s),neg:g(10),abs:g(11),sqrt:g(12),log:g(13),exp:g(14),floor:g(15),ceil:g(16),round:g(17),sin:g(23),cos:g(24),acos:g(25),normalize:E=>this.unary(18,E),length:E=>this.unary(19,E,"float"),isFinite:E=>this.unary(20,E,"bool"),not:E=>this.unary(22,this.coerce(E,"bool"),"bool"),eq:Q(39),ne:Q(40),lt:Q(41),lte:Q(42),gt:Q(43),gte:Q(44),and:C(45),or:C(46),select:(E,i,s)=>{const D=this.coerce(i),o=this.coerce(s,D.type);return this.instruction(D.type,60,[this.coerce(E,"bool").register,D.register,o.register])},dot:(E,i)=>this.binary(37,E,i,"float"),cross:(E,i)=>this.binary(38,E,i),vec2:(E,i)=>t(70,"vec2",[E,i]),vec3:(E,i,s)=>t(71,"vec3",[E,i,s]),vec4:(E,i,s,D)=>t(72,"vec4",[E,i,s,D]),quaternion:(E,i,s,D)=>t(72,"quaternion",[E,i,s,D]),component:(E,i)=>{const s=this.coerce(E);if(!Number.isInteger(i)||i<0||i>=O[s.type])throw new Error("postDecode component index is out of bounds");return this.instruction("float",74,[s.register],i)},maxComponentIndex:E=>this.unary(75,E,"float"),quatMul:(E,i)=>{const s=this.coerce(E,"quaternion"),D=this.coerce(i,"quaternion");return this.instruction("quaternion",47,[s.register,D.register])},rotateVector:(E,i)=>{const s=this.coerce(E,"quaternion"),D=this.coerce(i,"vec3");return this.instruction("vec3",48,[s.register,D.register])}}}}class KI{constructor(A){this.generation=1,this.values=new Int32Array(A),this.generations=new Uint32Array(A)}clear(){this.generation===4294967295?(this.generations.fill(0),this.generation=1):this.generation+=1}has(A){return this.generations[A]===this.generation}get(A){return this.has(A)?this.values[A]:void 0}set(A,I){this.generations[A]=this.generation,this.values[A]=I}delete(A){this.generations[A]=0}}function kQ(B,A,I){const g=[];for(const Q of A)Q===void 0||I[Q]||(I[Q]=1,g.push(Q));for(;g.length!==0;){const Q=g.pop();if(Q===void 0)break;for(const C of B.instructions[Q].args)I[C]||(I[C]=1,g.push(C))}}class fI{constructor(A){this.builder=A,this.instructions=[],this.constants=[],this.attributes=[],this.constantMap=new Map,this.attributeMap=new Map,this.dependencyGeneration=0,this.dependencyMarks=new Uint32Array(A.instructions.length)}appendDependencies(A,I,g=!1){if(g)for(const E of A)E!==void 0&&this.builder.instructions[E].opcode!==1&&I.delete(E);this.dependencyGeneration+=1;const Q=this.dependencyGeneration,C=[],t=[];for(const E of A)E!==void 0&&!I.has(E)&&C.push(E);for(;C.length!==0;){const E=C.pop();if(!(E===void 0||I.has(E)||this.dependencyMarks[E]===Q)){this.dependencyMarks[E]=Q,t.push(E);for(const i of this.builder.instructions[E].args)I.has(i)||C.push(i)}}return t.sort((E,i)=>E-i),this.append(t,I),I}append(A,I){for(const g of A){const Q=this.builder.instructions[g];if(Q.opcode===1){let E=this.constantMap.get(g);if(E===void 0){this.reserveInstruction(),E=this.instructions.length,this.constantMap.set(g,E);const i=this.constants.length;this.constants.push(...this.builder.constants.slice(Q.immediate,Q.immediate+O[Q.type])),this.instructions.push({...Q,immediate:i})}I.set(g,E);continue}this.reserveInstruction();let C=Q.immediate;if(Q.opcode===3){let E=this.attributeMap.get(C);E===void 0&&(E=this.attributes.length,this.attributeMap.set(C,E),this.attributes.push(this.builder.attributes[C])),C=E}const t=Q.args.map(E=>{const i=I.get(E);if(i===void 0)throw new Error("Invalid postDecode instruction dependency");return i});I.set(g,this.instructions.length),this.instructions.push({...Q,args:t,immediate:C})}}reserveInstruction(){if(this.instructions.length>=4096)throw new Error("postDecode compiled program exceeds 4096 instructions")}}function HI(){return{instructions:[],constants:[],outputs:{},condition:void 0,attributes:[]}}function pI(B,A){var g;const I=Q=>Q===void 0?void 0:A.get(Q);return{position:I(B.position),scale:I(B.scale),quaternion:I(B.quaternion),opacity:I(B.opacity),alpha:I(B.alpha),color:I(B.color),sh:(g=B.sh)==null?void 0:g.map(Q=>{const C=A.get(Q);if(C===void 0)throw new Error("Invalid postDecode output dependency");return C})}}function LQ(B,A,I,g){const s=new Uint8Array(g+1);for(let G=0;G<=g;G+=1){const F=B.instructions[G];if(F.opcode===1&&F.type==="bool"){s[G]=B.constants[F.immediate]?2:1;continue}const U=s[F.args[0]];if(F.opcode===22)s[G]=U===2?1:U===1?2:0;else if(F.opcode===45){const L=s[F.args[1]];s[G]=U===1||L===1?1:U===2&&L===2?2:0}else if(F.opcode===46){const L=s[F.args[1]];s[G]=U===2||L===2?2:U===1&&L===1?1:0}}const D=[],o=0,w=1,n=3;let a,r=0,h=g,c=-1,y=-2,S=-2;for(;;){const G=s[h];if(G!==0)S=G===2?c:y;else{const L=B.instructions[h];if(L.opcode===22){h=L.args[0];const W=c;c=y,y=W;continue}if(L.opcode===45||L.opcode===46){if(a??(a=new Int32Array((g+1)*n)),r===a.length)throw new Error("Invalid postDecode condition depth");const W=L.opcode===45;a[r]=W?o:w,a[r+1]=L.args[0],a[r+2]=W?y:c,r+=n,h=L.args[1];continue}if(D.length>=4096)throw new Error("postDecode condition exceeds 4096 flow nodes");S=D.length,D.push({register:h,onTrue:c,onFalse:y})}if(r===0)break;if(r-=n,!a)throw new Error("Invalid postDecode condition continuation");const F=a[r];h=a[r+1];const U=a[r+2];F===o?(c=S,y=U):(c=U,y=S)}const M=S;if(M===-2)return HI();if(M===-1){A.when=void 0;return}const k=D.length;if(M!==k-1)throw new Error("Invalid postDecode condition flow");const l=k,d=l+1,f=new Uint16Array(k*UA),b=new Int32Array(k).fill(-1);let DA=-1;const qA=(G,F)=>{if(G!==d){if(G===l){DA=DA===-1||DA===F?F:-2;return}b[G]=b[G]===-1||b[G]===F?F:-2}},TA=G=>G===-1?l:G===-2?d:k-1-G;for(let G=0;G<k;G+=1){const F=D[k-1-G],U=G*UA,L=TA(F.onTrue),W=TA(F.onFalse);f[U+GQ]=L,f[U+NQ]=W,qA(L,G),qA(W,G)}const T=new fI(B),X=new KI(B.instructions.length);for(let G=0;G<k;G+=1){(G===0||b[G]!==G-1)&&X.clear();const F=D[k-1-G],U=G*UA;f[U+rQ]=T.instructions.length,T.appendDependencies([F.register],X,!0),f[U+hQ]=T.instructions.length-1;const L=X.get(F.register);if(L===void 0)throw new Error("Invalid postDecode condition register");f[U+yQ]=L}return DA!==k-1&&X.clear(),T.appendDependencies(I,X),{instructions:T.instructions,constants:T.constants,outputs:pI(A,X),condition:{mode:"flow",stages:f},attributes:T.attributes}}function JQ(B,A){const I={...A};if(I.when!==void 0){const i=B.instructions[I.when];if(i.opcode===1){if(B.constants[i.immediate]===0)return HI();I.when=void 0}}const g=[I.position,I.scale,I.quaternion,I.opacity,I.alpha,I.color,...I.sh??[]];if(I.when!==void 0){const i=LQ(B,I,g,I.when);if(i)return i}const Q=new Uint8Array(B.instructions.length);kQ(B,g,Q);const C=[];for(let i=0;i<Q.length;i+=1)Q[i]&&C.push(i);const t=new fI(B),E=new KI(B.instructions.length);return t.append(C,E),{instructions:t.instructions,constants:t.constants,outputs:pI(I,E),attributes:t.attributes}}function lQ(B){const A=new Uint16Array(B.length*BI);A.fill(CI);for(let I=0;I<B.length;I+=1){const g=B[I];if(g.args.length>wQ||!Number.isInteger(g.immediate)||g.immediate<0||g.immediate>65535||g.args.some(C=>!Number.isInteger(C)||C<0||C>=CI))throw new Error("postDecode instruction exceeds Uint16 bytecode limits");const Q=I*BI;A[Q+DQ]=g.opcode,A[Q+eQ]=O[g.type],A[Q+aQ]=g.immediate;for(let C=0;C<g.args.length;C+=1)A[Q+nQ+C]=g.args[C]}return A}function UQ(B){const A=new Map;for(const E of B){if(E.count===0)continue;const i=dI[E.format]*E.components,s=E.data.byteOffset+E.byteOffset,D=s+(E.count-1)*E.byteStride+i,o=A.get(E.data.buffer)??[];o.push({start:s,end:D}),A.set(E.data.buffer,o)}const I=[],g=new Map;for(const[E,i]of A){i.sort((D,o)=>D.start-o.start);const s=[];for(const D of i){const o=s[s.length-1];if(o&&D.start<=o.end)o.end=Math.max(o.end,D.end);else{const w={buffer:E,...D,outputOffset:0};s.push(w),I.push(w)}}g.set(E,s)}let Q=0;for(const E of I)E.outputOffset=Q,Q+=E.end-E.start;const C=new Uint8Array(Q);for(const E of I)C.set(new Uint8Array(E.buffer,E.start,E.end-E.start),E.outputOffset);const t=B.map(E=>{var s;let i=0;if(E.count!==0){const D=E.data.byteOffset+E.byteOffset,o=(s=g.get(E.data.buffer))==null?void 0:s.find(w=>D>=w.start&&D<w.end);if(!o)throw new Error("postDecode attribute view was not serialized");i=o.outputOffset+D-o.start}return{format:E.format,components:E.components,byteOffset:i,byteStride:E.byteStride,count:E.count}});return{data:C,attributes:t}}UI=SQ;const dQ=class bI{constructor(A,I){this.builder=A,this.outputs=I,this[UI]=!0}static serialize(A){if(!(A instanceof bI))throw new Error("Invalid postDecode program");const I=JQ(A.builder,A.outputs),g=UQ(I.attributes);return{instructions:lQ(I.instructions),constants:new Float32Array(I.constants),outputs:I.outputs,condition:I.condition,attributeData:g.data,attributes:g.attributes}}};let mI=dQ;function YQ(B){return mI.serialize(B)}function uQ(B,A){if(A.opacity!==void 0&&A.alpha!==void 0)throw new Error("postDecode opacity cannot be combined with alpha");const I=(Q,C)=>Q===void 0?void 0:B.coerce(Q,C).register,g={when:I(A.when,"bool"),position:I(A.position,"vec3"),scale:I(A.scale,"vec3"),quaternion:I(A.quaternion,"quaternion"),opacity:I(A.opacity,"float"),alpha:I(A.alpha,"float"),color:I(A.color,"vec3")};if(A.sh!==void 0){if(!(A.sh instanceof YI)||A.sh.owner!==B)throw new Error("postDecode SH output must be created from splat.sh.map()");g.sh=A.sh.coefficients.map(Q=>Q.register)}return g}function KQ(B){const A=new MQ,I=B({splat:A.splat,op:A.op,attribute:g=>A.attribute(g)});if(!I||typeof I!="object")throw new Error("postDecode builder must return a splat patch object");return new mI(A,uQ(A,I))}const fQ={define:KQ};class xI extends EI.Loader{load(A,I,g,Q){return this.loadInternal({url:A,onLoad:I,onProgress:g,onError:Q})}async loadAsync(A,I){return new Promise((g,Q)=>{this.load(A,g,I,Q)})}parse(A){return new sA({splats:A})}loadInternal({splats:A,url:I,fileBytes:g,fileType:Q,fileName:C,stream:t,streamLength:E,postDecode:i,onLoad:s,onProgress:D,onError:o}){const w=g instanceof ArrayBuffer?new Uint8Array(g):g,n=w?void 0:this.manager.resolveURL((this.path??"")+(I??""));let a=t==null?void 0:t.getReader();const r=async h=>{const c=a;if(a=void 0,!!c){try{await c.cancel(h)}catch{}c.releaseLock()}};this.manager.itemStart(n??""),iQ.withWorker(async h=>{const c=async()=>{const l=a;if(!l)return new Uint8Array(0);try{const{done:d,value:f}=await l.read();return d?(l.releaseLock(),a=void 0,new Uint8Array(0)):f}catch(d){throw await h.call("nextChunk",{chunk:new Uint8Array(0)}),d}},y=async l=>{const{loaded:d,total:f}=l;if(d!==void 0&&D)try{D(new ProgressEvent("progress",{lengthComputable:f!==0,loaded:d,total:f??0}))}catch(b){console.error("Progress callback failed",b)}if(l.nextChunk){const b=await c();await h.call("nextChunk",{chunk:b})}},S=n?new URL(n,window.location.href).toString():void 0,M=await h.call("loadSplats",{url:S,requestHeader:this.requestHeader,withCredentials:this.withCredentials,fileBytes:w==null?void 0:w.slice(),fileType:Q,pathName:n||C,chunked:t!==void 0,chunkedLength:E,postDecode:i?YQ(i):void 0},{onStatus:y}),k=A??new P;k.initialize(M),s==null||s(k)}).catch(async h=>{await r(h),this.manager.itemError(n??""),o==null||o(h)}).finally(()=>{this.manager.itemEnd(n??"")})}async loadInternalAsync({splats:A,url:I,fileBytes:g,fileType:Q,fileName:C,stream:t,streamLength:E,postDecode:i,onProgress:s}){return new Promise((D,o)=>{this.loadInternal({splats:A,url:I,fileBytes:g,fileType:Q,fileName:C,stream:t,streamLength:E,postDecode:i,onLoad:D,onProgress:s,onError:o})})}}const HQ=Object.freeze(Object.defineProperty({__proto__:null,SplatLoader:xI},Symbol.toStringTag,{value:"Module"}));exports.GaussianSplatRenderer=fA;exports.SplatAccumulator=K;exports.SplatEdit=oA;exports.SplatEditRgbaBlendMode=tI;exports.SplatEditSdf=sI;exports.SplatEditSdfType=iI;exports.SplatEdits=q;exports.SplatFileType=bA;exports.SplatLoader=xI;exports.SplatMesh=sA;exports.Splats=P;exports.defines=yg;exports.fromHalf=p;exports.postDecode=fQ;exports.toHalf=u;exports.utils=kg;
|
|
837
|
+
}`;const zA=new e.Matrix4,m=new e.Vector3,Z=new e.Vector3,V=new e.Vector3,_A=new e.Vector3;function zg(B,A,I){const g=B.elements,Q=Math.hypot(g[0],g[1],g[2]),C=Math.hypot(g[4],g[5],g[6]),t=Math.hypot(g[8],g[9],g[10]);A.set(Q,C,t),m.set(g[0],g[1],g[2]),Z.set(g[4],g[5],g[6]),V.set(g[8],g[9],g[10]),Q>0&&m.multiplyScalar(1/Q),C>0&&Z.multiplyScalar(1/C),t>0&&V.multiplyScalar(1/t);const E=+(Q>0)+ +(C>0)+ +(t>0);if(E===0){I.identity();return}if(E===1){const i=Q>0?0:C>0?1:2;_A.set(i===0?1:0,i===1?1:0,i===2?1:0),I.setFromUnitVectors(_A,i===0?m:i===1?Z:V).normalize();return}Q===0&&m.copy(Z).cross(V).normalize(),C===0&&Z.copy(V).cross(m).normalize(),t===0&&V.copy(m).cross(Z).normalize(),B.determinant()<0&&m.negate(),zA.makeBasis(m,Z,V),I.setFromRotationMatrix(zA).normalize()}const Y=class Y{constructor(){if(this.time=0,this.deltaTime=0,this.viewOrigin=new e.Vector3,this.viewDirection=new e.Vector3,this.maxSplats=0,this.numSplats=0,this.target=null,this.mapping=[],this.version=-1,this.mappingVersion=-1,this.transformScale=new e.Vector3,this.transformQuaternion=new e.Quaternion,!yI)throw new Error("Gaussian Splat Lite requires THREE.js r179 or above")}dispose(){this.disposeTarget(),this.mapping=[],this.numSplats=0,this.version=-1,this.mappingVersion=-1}disposeTarget(){var A;(A=this.target)==null||A.dispose(),this.target=null,this.maxSplats=0}getTextures(){var A;return((A=this.target)==null?void 0:A.textures)??Y.emptyTextures}generateMapping(A){let I=0;const g=A.map(Q=>{const C=I;return I+=Math.ceil(Q/H)*H,{base:C,count:Q}});return{maxSplats:I,mapping:g}}ensureGenerate({maxSplats:A,shrinkResources:I=!1}){const g=x(Math.max(1,A));if(this.target&&(I?g.maxSplats===this.maxSplats:g.maxSplats<=this.maxSplats))return!1;this.disposeTarget();const{width:Q,height:C,depth:t}=g;this.maxSplats=g.maxSplats,this.target=new e.WebGLArrayRenderTarget(Q,C,t,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:e.NearestFilter,minFilter:e.NearestFilter,format:e.RGBAIntegerFormat,type:e.UnsignedIntType}),this.target.scissorTest=!0;const E=this.target.texture.clone();return this.target.textures=[this.target.texture,E],!0}getMaterial(){let A=Y.material;return A||(LI(),A=new e.RawShaderMaterial({glslVersion:e.GLSL3,vertexShader:NI,fragmentShader:jg,uniforms:_g(),depthTest:!1,depthWrite:!1}),Y.material=A),A}prepareMaterial(A){const I=A.splats;if(!I)throw new Error("SplatMesh has no source");const g=this.getMaterial(),Q=g.uniforms;I.setTextureUniforms(Q),Q.numSh.value=Math.min(A.maxSh,I.getNumSh()),zg(A.matrixWorld,this.transformScale,this.transformQuaternion),Q.objectBasis.value.setFromMatrix4(A.matrixWorld),Q.objectOffset.value.setFromMatrixPosition(A.matrixWorld),Q.objectOffset.value.sub(this.viewOrigin),Q.objectLnScale.value.set(Math.log(this.transformScale.x),Math.log(this.transformScale.y),Math.log(this.transformScale.z)),Q.objectQuaternion.value.copy(this.transformQuaternion),Q.recolor.value.set(A.recolor.r,A.recolor.g,A.recolor.b,e.MathUtils.clamp(A.opacity,0,1));const C=A.sdfEdits;return Q.numSdfs.value=(C==null?void 0:C.numSdfs)??0,Q.numEdits.value=(C==null?void 0:C.numEdits)??0,Q.sdfTexture.value=(C==null?void 0:C.sdfTexture)??q.emptyTexture,Q.editTexture.value=(C==null?void 0:C.editTexture)??q.emptyTexture,Y.fullScreenQuad.material=g,g}generate({mesh:A,base:I,count:g,renderer:Q}){if(!this.target)throw new Error("Accumulator target is not initialized");if(I+g>this.maxSplats)throw new Error("Splat generation range exceeds accumulator capacity");const t=this.prepareMaterial(A).uniforms,E=this.saveRenderState(Q),i=Math.ceil((I+g)/H)*H,s=H*rA;for(t.targetBase.value=I,t.targetCount.value=g;I<i;){const D=Math.floor(I/s);t.targetLayer.value=D;const o=D*s,w=Math.floor((I-o)/H),n=Math.min(rA,Math.ceil((i-o)/H));this.target.scissor.set(0,w,H,n-w),Q.setRenderTarget(this.target,D),Q.xr.enabled=!1,Q.autoClear=!1,Y.fullScreenQuad.render(Q),I+=H*(n-w)}this.resetRenderState(Q,E)}prepareGenerate({renderer:A,scene:I,timer:g,camera:Q,previous:C}){Q.getWorldPosition(this.viewOrigin),Q.getWorldDirection(this.viewDirection),this.time=g.getElapsed(),this.deltaTime=g.getDelta();const t=[];I.traverse(a=>{a instanceof sA&&Q.layers.test(a.layers)&&t.push(a)});const E=new Set;I.traverseVisible(a=>{if(!(a instanceof oA))return;let r=a.parent;for(;r&&!(r instanceof sA);)r=r.parent;r||E.add(a)});for(const a of t)try{a.frameUpdate({time:this.time,deltaTime:this.deltaTime,camera:Q,globalEdits:Array.from(E)})}catch(r){console.error("SplatMesh frame update failed",r)}const i=[];I.traverseVisible(a=>{a instanceof sA&&Q.layers.test(a.layers)&&a.opacity>0&&i.push(a)});const{maxSplats:s,mapping:D}=this.generateMapping(i.map(a=>a.numSplats));this.mapping=[],this.numSplats=0,D.forEach(({base:a,count:r},h)=>{const c=i[h];!c.splats||r<=0||(this.mapping.push({node:c,version:c.version,sortVersion:c.sortVersion,centerVersion:c.centerVersion,mappingVersion:c.mappingVersion,base:a,count:r}),this.numSplats=Math.max(this.numSplats,a+r))});const{splatsUpdated:o,mappingUpdated:w,sortUpdated:n}=C.checkVersions(this.mapping);return this.version=C.version+(o?1:0),this.mappingVersion=C.mappingVersion+(w?1:0),{version:this.version,sortUpdated:n,requiredMaxSplats:x(Math.max(1,s)).maxSplats,generate:(a=!1)=>{this.ensureGenerate({maxSplats:s,shrinkResources:a});for(const{node:r,base:h,count:c}of this.mapping)this.generate({mesh:r,base:h,count:c,renderer:A})}}}checkVersions(A){return this.mapping.length!==A.length?{splatsUpdated:!0,mappingUpdated:!0,sortUpdated:!0}:this.mapping.some((g,Q)=>{const C=A[Q];return g.node!==C.node||g.base!==C.base||g.count!==C.count||g.mappingVersion!==C.mappingVersion})?{splatsUpdated:!0,mappingUpdated:!0,sortUpdated:!0}:{splatsUpdated:this.mapping.some((g,Q)=>g.version!==A[Q].version),mappingUpdated:!1,sortUpdated:this.mapping.some((g,Q)=>g.sortVersion!==A[Q].sortVersion)}}saveRenderState(A){return{target:A.getRenderTarget(),activeCubeFace:A.getActiveCubeFace(),activeMipmapLevel:A.getActiveMipmapLevel(),xrEnabled:A.xr.enabled,autoClear:A.autoClear}}resetRenderState(A,I){A.setRenderTarget(I.target,I.activeCubeFace,I.activeMipmapLevel),A.xr.enabled=I.xrEnabled,A.autoClear=I.autoClear}};Y.emptyTexture=(()=>{const{width:A,height:I,depth:g,maxSplats:Q}=x(1),C=new e.DataArrayTexture(new Uint32Array(Q*4),A,I,g);return C.format=e.RGBAIntegerFormat,C.type=e.UnsignedIntType,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})(),Y.emptyTextures=[Y.emptyTexture,Y.emptyTexture],Y.material=null,Y.fullScreenQuad=new qI.FullScreenQuad(new e.RawShaderMaterial({visible:!1}));let K=Y;function _g(){return{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0},sourceSplats:{value:K.emptyTexture},sourceSplats2:{value:K.emptyTexture},numSh:{value:0},sh1Texture:{value:K.emptyTexture},sh2Texture:{value:K.emptyTexture},sh3TextureA:{value:K.emptyTexture},sh3TextureB:{value:K.emptyTexture},objectBasis:{value:new e.Matrix3},objectOffset:{value:new e.Vector3},objectLnScale:{value:new e.Vector3},objectQuaternion:{value:new e.Quaternion},recolor:{value:new e.Vector4(1,1,1,1)},numSdfs:{value:0},numEdits:{value:0},sdfTexture:{value:q.emptyTexture},editTexture:{value:q.emptyTexture}}}class $g extends e.InstancedBufferGeometry{constructor(){super(),this.setAttribute("position",new e.BufferAttribute(AQ,3)),this.setIndex(new e.BufferAttribute(IQ,1))}}const AQ=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),IQ=new Uint16Array([0,1,2,0,2,3]),JI='(function(){"use strict";class nt{static __wrap(n){n=n>>>0;const o=Object.create(nt.prototype);return o.__wbg_ptr=n,Ut.register(o,o.__wbg_ptr,o),o}__destroy_into_raw(){const n=this.__wbg_ptr;return this.__wbg_ptr=0,Ut.unregister(this),n}free(){const n=this.__destroy_into_raw();D.__wbg_chunkdecoder_free(n,0)}finish(){const n=this.__destroy_into_raw(),o=D.chunkdecoder_finish(n);if(o[2])throw ct(o[1]);return ct(o[0])}push(n){const o=D.chunkdecoder_push(this.__wbg_ptr,n);if(o[1])throw ct(o[0])}set_expected_input_size(n){const o=D.chunkdecoder_set_expected_input_size(this.__wbg_ptr,n);if(o[1])throw ct(o[0])}}Symbol.dispose&&(nt.prototype[Symbol.dispose]=nt.prototype.free);function Jt(t,n){var o=St(t)?0:ht(t,D.__wbindgen_malloc,D.__wbindgen_realloc),s=k,e=St(n)?0:ht(n,D.__wbindgen_malloc,D.__wbindgen_realloc),i=k;const f=D.decode_to_splats(o,s,e,i);if(f[2])throw ct(f[1]);return nt.__wrap(f[0])}function Kt(t,n,o,s,e,i,f){D.set_sort_center_state(t,n,o,s,e,i,f)}function kt(t,n,o,s,e,i,f,_,l){return D.sort32_centers(t,n,o,s,e,i,f,_,l)>>>0}function zt(){return{__proto__:null,"./gaussian_splat_rs_bg.js":{__proto__:null,__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57:function(n,o){const s=At(o),e=ht(s,D.__wbindgen_malloc,D.__wbindgen_realloc),i=k;_t().setInt32(n+4,i,!0),_t().setInt32(n+0,e,!0)},__wbg___wbindgen_throw_81fc77679af83bc6:function(n,o){throw new Error(Et(n,o))},__wbg_error_a6fa202b58aa1cd3:function(n,o){let s,e;try{s=n,e=o,console.error(Et(n,o))}finally{D.__wbindgen_free(s,e,1)}},__wbg_get_index_983d655608220248:function(n,o){return n[o>>>0]},__wbg_length_0c32cb8543c8e4c8:function(n){return n.length},__wbg_length_1e701798fdcaa3b4:function(n){return n.length},__wbg_length_526c0f6e4ebae15d:function(n){return n.length},__wbg_length_fd4646b401926788:function(n){return n.length},__wbg_new_227d7c05414eb861:function(){return new Error},__wbg_new_4f9fafbb3909af72:function(){return new Object},__wbg_new_with_length_26bffbe236bf73f9:function(n){return new Float32Array(n>>>0)},__wbg_new_with_length_41a22191b9bdfd66:function(n){return new Uint32Array(n>>>0)},__wbg_prototypesetcall_021fd89d67217368:function(n,o,s){Float64Array.prototype.set.call(nn(n,o),s)},__wbg_prototypesetcall_3e05eb9545565046:function(n,o,s){Uint8Array.prototype.set.call(en(n,o),s)},__wbg_prototypesetcall_66c8e1fb820946be:function(n,o,s){Float32Array.prototype.set.call(bt(n,o),s)},__wbg_prototypesetcall_e42275e601e14eeb:function(n,o,s){Uint32Array.prototype.set.call(xt(n,o),s)},__wbg_set_448126769bf7c181:function(n,o,s){n.set(xt(o,s))},__wbg_set_8ee2d34facb8466e:function(){return sn(function(n,o,s){return Reflect.set(n,o,s)},arguments)},__wbg_set_a98c8da6557e63de:function(n,o,s){n.set(bt(o,s))},__wbg_set_index_a561936dd7004b5a:function(n,o,s){n[o>>>0]=s},__wbg_stack_3b0d974bbf31e44f:function(n,o){const s=o.stack,e=ht(s,D.__wbindgen_malloc,D.__wbindgen_realloc),i=k;_t().setInt32(n+4,i,!0),_t().setInt32(n+0,e,!0)},__wbg_subarray_0f98d3fb634508ad:function(n,o,s){return n.subarray(o>>>0,s>>>0)},__wbg_subarray_1230568a23d546e8:function(n,o,s){return n.subarray(o>>>0,s>>>0)},__wbg_subarray_4342405c1ffc86d6:function(n,o,s){return n.subarray(o>>>0,s>>>0)},__wbg_subarray_d51e89458b3fdbf6:function(n,o,s){return n.subarray(o>>>0,s>>>0)},__wbindgen_cast_0000000000000001:function(n){return n},__wbindgen_cast_0000000000000002:function(n,o){return bt(n,o)},__wbindgen_cast_0000000000000003:function(n,o){return xt(n,o)},__wbindgen_cast_0000000000000004:function(n,o){return Et(n,o)},__wbindgen_init_externref_table:function(){const n=D.__wbindgen_externrefs,o=n.grow(4);n.set(0,void 0),n.set(o+0,void 0),n.set(o+1,null),n.set(o+2,!0),n.set(o+3,!1)}}}}const Ut=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>D.__wbg_chunkdecoder_free(t>>>0,1));function tn(t){const n=D.__externref_table_alloc();return D.__wbindgen_externrefs.set(n,t),n}function At(t){const n=typeof t;if(n=="number"||n=="boolean"||t==null)return`${t}`;if(n=="string")return`"${t}"`;if(n=="symbol"){const e=t.description;return e==null?"Symbol":`Symbol(${e})`}if(n=="function"){const e=t.name;return typeof e=="string"&&e.length>0?`Function(${e})`:"Function"}if(Array.isArray(t)){const e=t.length;let i="[";e>0&&(i+=At(t[0]));for(let f=1;f<e;f++)i+=", "+At(t[f]);return i+="]",i}const o=/\\[object ([^\\]]+)\\]/.exec(toString.call(t));let s;if(o&&o.length>1)s=o[1];else return toString.call(t);if(s=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:s}function bt(t,n){return t=t>>>0,on().subarray(t/4,t/4+n)}function nn(t,n){return t=t>>>0,an().subarray(t/8,t/8+n)}function xt(t,n){return t=t>>>0,rn().subarray(t/4,t/4+n)}function en(t,n){return t=t>>>0,st().subarray(t/1,t/1+n)}let j=null;function _t(){return(j===null||j.buffer.detached===!0||j.buffer.detached===void 0&&j.buffer!==D.memory.buffer)&&(j=new DataView(D.memory.buffer)),j}let et=null;function on(){return(et===null||et.byteLength===0)&&(et=new Float32Array(D.memory.buffer)),et}let ot=null;function an(){return(ot===null||ot.byteLength===0)&&(ot=new Float64Array(D.memory.buffer)),ot}function Et(t,n){return t=t>>>0,fn(t,n)}let at=null;function rn(){return(at===null||at.byteLength===0)&&(at=new Uint32Array(D.memory.buffer)),at}let rt=null;function st(){return(rt===null||rt.byteLength===0)&&(rt=new Uint8Array(D.memory.buffer)),rt}function sn(t,n){try{return t.apply(this,n)}catch(o){const s=tn(o);D.__wbindgen_exn_store(s)}}function St(t){return t==null}function ht(t,n,o){if(o===void 0){const _=ft.encode(t),l=n(_.length,1)>>>0;return st().subarray(l,l+_.length).set(_),k=_.length,l}let s=t.length,e=n(s,1)>>>0;const i=st();let f=0;for(;f<s;f++){const _=t.charCodeAt(f);if(_>127)break;i[e+f]=_}if(f!==s){f!==0&&(t=t.slice(f)),e=o(e,s,s=f+t.length*3,1)>>>0;const _=st().subarray(e+f,e+s),l=ft.encodeInto(t,_);f+=l.written,e=o(e,s,f,1)>>>0}return k=f,e}function ct(t){const n=D.__wbindgen_externrefs.get(t);return D.__externref_table_dealloc(t),n}let wt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});wt.decode();const cn=2146435072;let Mt=0;function fn(t,n){return Mt+=n,Mt>=cn&&(wt=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),wt.decode(),Mt=n),wt.decode(st().subarray(t,t+n))}const ft=new TextEncoder;"encodeInto"in ft||(ft.encodeInto=function(t,n){const o=ft.encode(t);return n.set(o),{read:t.length,written:o.length}});let k=0,D;function ln(t,n){return D=t.exports,j=null,et=null,ot=null,at=null,rt=null,D.__wbindgen_start(),D}async function un(t,n){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,n)}catch(e){if(t.ok&&o(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n",e);else throw e}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,n)}else{const s=await WebAssembly.instantiate(t,n);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}function o(s){switch(s){case"basic":case"cors":case"default":return!0}return!1}}async function _n(t){if(D!==void 0)return D;t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead"));const n=zt();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));const{instance:o}=await un(await t,n);return ln(o)}const Tt=new Float32Array(1),Rt=new Uint32Array(Tt.buffer),pt="Float16Array"in globalThis,it=pt?new globalThis.Float16Array(1):null,Pt=new Uint16Array(it==null?void 0:it.buffer);function hn(t){return it[0]=t,Pt[0]}function wn(t){Tt[0]=t;const n=Rt[0],o=n>>>16&32768,s=n>>>23&255,e=n&8388607;if(s===255)return o|(e===0?31744:32767);const i=s-127+15;return i>=31?o|31744:i<=0?i<-10?o:o|(e|8388608)>>>1-i+13:o|i<<10|e>>>13}function yn(t){return Pt[0]=t,it[0]}function dn(t){const n=t>>>15&1,o=t>>>10&31,s=t&1023;let e;if(o===0)if(s===0)e=n<<31;else{let i=s,f=-14;for(;(i&1024)===0;)i<<=1,f-=1;e=n<<31|f+127<<23|(i&1023)<<13}else o===31?e=n<<31|(s===0?2139095040:2143289344):e=n<<31|o-15+127<<23|s<<13;return Rt[0]=e,Tt[0]}const V=pt?hn:wn,Y=pt?yn:dn;var w=(t=>(t[t.Constant=1]="Constant",t[t.InputField=2]="InputField",t[t.InputAttribute=3]="InputAttribute",t[t.Negate=10]="Negate",t[t.Abs=11]="Abs",t[t.Sqrt=12]="Sqrt",t[t.Log=13]="Log",t[t.Exp=14]="Exp",t[t.Floor=15]="Floor",t[t.Ceil=16]="Ceil",t[t.Round=17]="Round",t[t.Normalize=18]="Normalize",t[t.Length=19]="Length",t[t.IsFinite=20]="IsFinite",t[t.Not=22]="Not",t[t.Sin=23]="Sin",t[t.Cos=24]="Cos",t[t.Acos=25]="Acos",t[t.Tan=26]="Tan",t[t.Asin=27]="Asin",t[t.Atan=28]="Atan",t[t.Add=30]="Add",t[t.Subtract=31]="Subtract",t[t.Multiply=32]="Multiply",t[t.Divide=33]="Divide",t[t.Min=34]="Min",t[t.Max=35]="Max",t[t.Pow=36]="Pow",t[t.Dot=37]="Dot",t[t.Cross=38]="Cross",t[t.Equal=39]="Equal",t[t.NotEqual=40]="NotEqual",t[t.Less=41]="Less",t[t.LessEqual=42]="LessEqual",t[t.Greater=43]="Greater",t[t.GreaterEqual=44]="GreaterEqual",t[t.And=45]="And",t[t.Or=46]="Or",t[t.QuaternionMultiply=47]="QuaternionMultiply",t[t.RotateVector=48]="RotateVector",t[t.Atan2=49]="Atan2",t[t.Select=60]="Select",t[t.Clamp=61]="Clamp",t[t.Mix=62]="Mix",t[t.Vec2=70]="Vec2",t[t.Vec3=71]="Vec3",t[t.Vec4=72]="Vec4",t[t.Component=74]="Component",t[t.MaxComponentIndex=75]="MaxComponentIndex",t))(w||{}),Q=(t=>(t[t.Position=1]="Position",t[t.Scale=2]="Scale",t[t.Quaternion=3]="Quaternion",t[t.Opacity=4]="Opacity",t[t.Alpha=5]="Alpha",t[t.Color=6]="Color",t[t.Sh0=7]="Sh0",t))(Q||{});const mn=15,gt=0,z=1,Dt=2,Ct=3,An=4,H=7,Z=65535,bn={f32:4,f16:2,u8:1,unorm8:1,i8:1,snorm8:1,u16:2,unorm16:2,i16:2,snorm16:2,u32:4,i32:4},xn=0,yt=1,Lt=2,En=3,Mn=4,tt=5,Ft=1e3,Tn=11920928955078125e-23,pn=525311;function lt(t,n,o){return Math.min(o,Math.max(n,t))}function gn(t){const n=Y(t>>>16);if(n>0){const o=n*4+1;return Math.min(Ft,Math.exp((o*o-1)/Math.E))}return Y(t&65535)}function In(t){if(t>0&&t<=1)return V(t);const n=lt(t,0,Ft);if(n>1){const o=.25*(Math.sqrt(Math.log(n)*Math.E+1)-1);return(V(1)|V(o)<<16)>>>0}return V(n)}function Nn(t,n,o=0,s=1){const e=t&1023,i=t>>>10&1023,f=t>>>20;let _=e/1023*2-1,l=i/1023*2-1;const c=1-Math.abs(_)-Math.abs(l),a=Math.max(-c,0);_+=_>=0?-a:a,l+=l>=0?-a:a;const y=1/Math.sqrt(_*_+l*l+c*c),E=f/4095*.5*Math.PI,h=Math.sin(E);n[o]=_*y*h,n[o+s]=l*y*h,n[o+s*2]=c*y*h,n[o+s*3]=Math.cos(E)}function vn(t,n,o,s,e){const i=t*t+n*n+o*o+s*s;if(!Number.isFinite(i)||i<=e)return;if(t===0&&n===0&&o===0)return pn;const f=1/Math.sqrt(i);let _=t*f,l=n*f,c=o*f,a=s*f;a<0&&(_=-_,l=-l,c=-c,a=-a);const y=2*Math.acos(lt(a,0,1)),E=Math.sin(y*.5),h=Math.abs(E)<1e-6?1:_/E,A=Math.abs(E)<1e-6?0:l/E,d=Math.abs(E)<1e-6?0:c/E,m=Math.abs(h)+Math.abs(A)+Math.abs(d);let R=h/m,M=A/m;if(d<0){const g=R;R=(1-Math.abs(M))*(R>=0?1:-1),M=(1-Math.abs(g))*(M>=0?1:-1)}const u=Math.round(lt((R*.5+.5)*1023,0,1023)),P=Math.round(lt((M*.5+.5)*1023,0,1023));return(Math.round(lt(y/Math.PI*4095,0,4095))<<20|P<<10|u)>>>0}function Un(t,n,o,s){return vn(t,n,o,s,Tn)}const Sn=512,Rn=4*1024**2,Pn=2147483647,Ot=2147483648;function Bt(t){const n=t.length/H;if(!Number.isInteger(n))throw new Error("Invalid packed postDecode instructions");return n}function ut(t,n){return t[n*H+z]}function Dn(t,n){const o=t*Float32Array.BYTES_PER_ELEMENT;return Math.min(n,Sn,Math.max(1,Math.floor(Rn/o)))}function Cn(t){const{instructions:n,outputs:o,condition:s}=t,e=Bt(n),i=new Uint32Array(e);for(let u=0;u<e;u+=1){i[u]=u;const P=u*H;for(let U=0;U<An;U+=1){const g=n[P+Ct+U];if(g===Z)break;i[g]=u}}const f=s==null?void 0:s.stages;if(f)for(let u=0;u<f.length;u+=tt){const P=f[u+Lt],U=f[u+yt];i[P]=Math.max(i[P],U)}const _=e;for(const u of[o.position,o.scale,o.quaternion,o.opacity,o.alpha,o.color,...o.sh??[]])u!==void 0&&(i[u]=_);const l=new Uint32Array(e),c=new Uint8Array(e);let a=0;for(let u=0;u<e;u+=1){const P=u*H;n[P+gt]===w.Constant&&(c[u]=1,i[u]=_,l[u]=a,a+=n[P+z])}const y=new Int32Array(e+1).fill(-1),E=new Int32Array(e).fill(-1),h=[],A=(u,P)=>{let U=u,g=P,p=0;for(;p<h.length&&h[p].offset<U;)p+=1;const S=h[p-1];S&&S.offset+S.width===U&&(U=S.offset,g+=S.width,h.splice(p-1,1),p-=1);const b=h[p];b&&U+g===b.offset&&(g+=b.width,h.splice(p,1)),h.splice(p,0,{offset:U,width:g})},d=u=>{let P=-1;for(let p=0;p<h.length;p+=1){const S=h[p];S.width>=u&&(P===-1||S.width<h[P].width)&&(P=p)}if(P===-1){const p=a;return a+=u,p}const U=h[P],g=U.offset;return U.width===u?h.splice(P,1):(U.offset+=u,U.width-=u),g};for(let u=0;u<e;u+=1){for(let p=y[u];p!==-1;p=E[p])A(l[p],ut(n,p));if(c[u])continue;const P=ut(n,u),U=d(P);l[u]=U;const g=i[u]+1;g<=e&&(E[u]=y[g],y[g]=u)}const m=f?f.length/tt:0;if(!Number.isInteger(m))throw new Error("Invalid packed postDecode condition flow");let R=new Uint32Array,M=new Uint32Array;if(f&&m!==0){if(a>65536)throw new Error("postDecode register offsets exceed Uint16 capacity");const u=new Uint16Array(m);for(let v=0;v<m;v+=1){const L=f[v*tt+yt]+1;if(L>e||v!==0&&L<=u[v-1])throw new Error("Invalid postDecode condition stage boundary");u[v]=L}const P=v=>{let L=0,O=m;for(;L<O;){const W=L+O>>>1;u[W]<=v?L=W+1:O=W}return L},U=new Uint16Array(e),g=new Uint16Array(e),p=new Uint32Array(m),S=new Uint32Array(m);for(let v=0;v<e;v+=1){if(c[v])continue;const L=P(v),O=P(i[v]);if(L>=O)continue;U[v]=L,g[v]=O;const W=n[v*H+z];p[L]+=W,O<m&&(p[O]+=W,S[O]+=W)}const b=new Uint32Array(m+1);for(let v=0;v<m;v+=1)b[v+1]=b[v]+p[v];R=b,M=new Uint32Array(b[m]);const I=new Uint32Array(b.subarray(0,m)),G=new Uint32Array(m);for(let v=0;v<m;v+=1)G[v]=b[v]+S[v];for(let v=0;v<e;v+=1){const L=U[v],O=g[v];if(L>=O)continue;const W=n[v*H+z],r=l[v];for(let T=0;T<W;T+=1){const x=r+T;O<m&&(M[I[O]]=Ot|x,I[O]+=1),M[G[L]]=x,G[L]+=1}}}return{registerOffsets:l,registerValueCount:a,conditionCarryStageStarts:R,conditionCarryEvents:M}}function Wt(t,n){return Number.isNaN(t)?n:Number.isNaN(n)?t:Math.min(t,n)}function dt(t,n){return Number.isNaN(t)?n:Number.isNaN(n)?t:Math.max(t,n)}function It(t){return t<0?-Math.round(-t):Math.round(t)}function Nt(t,n,o){return Math.min(o,Math.max(n,t))}const Ln={f32:(t,n)=>t.getFloat32(n,!0),f16:(t,n)=>Y(t.getUint16(n,!0)),u8:(t,n)=>t.getUint8(n),unorm8:(t,n)=>t.getUint8(n)/255,i8:(t,n)=>t.getInt8(n),snorm8:(t,n)=>Math.max(-1,t.getInt8(n)/127),u16:(t,n)=>t.getUint16(n,!0),unorm16:(t,n)=>t.getUint16(n,!0)/65535,i16:(t,n)=>t.getInt16(n,!0),snorm16:(t,n)=>Math.max(-1,t.getInt16(n,!0)/32767),u32:(t,n)=>t.getUint32(n,!0),i32:(t,n)=>t.getInt32(n,!0)};function Fn(t,n,o,s,e,i,f,_){const l=bn[n.format],c=Ln[n.format];for(let a=0;a<n.components;a+=1){const y=f+a*e;if(_)for(let E=0;E<s;E+=1){const h=n.byteOffset+(o+_[E])*n.byteStride+a*l;i[y+E]=c(t,h)}else{let E=n.byteOffset+o*n.byteStride+a*l;for(let h=0;h<s;h+=1)i[y+h]=c(t,E),E+=n.byteStride}}}function On(t,n,o){return Un(t[n],t[n+o],t[n+o*2],t[n+o*3])}function Bn(t,n,o,s){const e=t>>>24,i=2**((e>>>3)-15)/255;for(let f=0;f<3;f+=1){const _=(t>>>f*8&255)*i;n[o+f*s]=e&1<<f?-_:_}}function Wn(t,n,o){const s=t[n],e=t[n+o],i=t[n+o*2],f=dt(Math.abs(s),dt(Math.abs(e),Math.abs(i))),_=It(Nt(Math.floor(Math.log2(f))+15,0,31)),l=2**(_-15)/255,c=y=>It(Nt(Math.abs(y)/l,0,255)),a=(s<0?1:0)|(e<0?2:0)|(i<0?4:0);return(c(s)|c(e)<<8|c(i)<<16|(_<<3|a)<<24)>>>0}function qt(t,n){if(n<=2&&t.sh1)return[t.sh1,n];if(n===3&&t.sh1&&t.sh2)return[t.sh1,3];if(n<=7&&t.sh2)return[t.sh2,n-4];if(n<=11&&t.sh3a)return[t.sh3a,n-8];if(n<=14&&t.sh3b)return[t.sh3b,n-12]}const Vt=0,Gt=1,$t=2,Yt=3,Xt=4,Qt=5,qn=6,J=4294967295;function Vn(t,n,o){const{outputs:s}=n,e=new Uint32Array(qn);e.fill(J);let i=0;const f=(a,y)=>{y!==void 0&&(e[a]=o[y],i+=1)};f(Vt,s.position),f(Gt,s.scale),f($t,s.quaternion),f(Yt,s.opacity),f(Xt,s.alpha),f(Qt,s.color);const _=[],l=[],c=[];if(s.sh)for(let a=0;a<mn;a+=1){const y=qt(t,a);y&&(_.push(y[0]),l.push(y[1]),c.push(o[s.sh[a]]))}return{outputBases:e,shTargetArrays:_,shWordOffsets:new Uint8Array(l),shRegisterBases:new Uint32Array(c),updatesSortCenter:s.position!==void 0||s.scale!==void 0,writesOutputs:i!==0||_.length!==0}}function Gn(t,n,o,s,e,i,f,_,l){switch(t){case Q.Position:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c,y=(n+a)*4;f[_+c]=i[y],f[_+s+c]=i[y+1],f[_+s*2+c]=i[y+2]}break;case Q.Scale:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c,y=(n+a)*4,E=e.splat1[y+1],h=e.splat1[y+2];f[_+c]=Math.exp(Y(E>>>16)),f[_+s+c]=Math.exp(Y(h&65535)),f[_+s*2+c]=Math.exp(Y(h>>>16))}break;case Q.Quaternion:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c,y=(n+a)*4;Nn(e.splat1[y+3],f,_+c,s)}break;case Q.Opacity:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c;f[_+c]=gn(e.splat0[(n+a)*4+3])}break;case Q.Alpha:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c;f[_+c]=Y(e.splat0[(n+a)*4+3]&65535)}break;case Q.Color:for(let c=0;c<o;c+=1){const a=(l==null?void 0:l[c])??c,y=(n+a)*4,E=e.splat1[y],h=e.splat1[y+1];f[_+c]=Y(E&65535),f[_+s+c]=Y(E>>>16),f[_+s*2+c]=Y(h&65535)}break;default:{const c=t-Q.Sh0,a=qt(e,c);if(a)for(let y=0;y<o;y+=1){const E=(l==null?void 0:l[y])??y;Bn(a[0][(n+E)*4+a[1]],f,_+y,s)}else f.fill(0,_,_+o),f.fill(0,_+s,_+s+o),f.fill(0,_+s*2,_+s*2+o)}}}function $n(t,n,o){var y;const{registerOffsets:s,registerValueCount:e,conditionCarryStageStarts:i,conditionCarryEvents:f}=Cn(n),_=Dn(e,o);for(let E=0;E<s.length;E+=1)s[E]*=_;const l=(y=n.condition)==null?void 0:y.stages,c=((l==null?void 0:l.length)??0)/tt,a=((l==null?void 0:l[l.length-tt+yt])??-1)+1;return{outputPlan:Vn(t,n,s),registerBases:s,conditionStages:l,conditionStageCount:c,outputInstructionStart:a,conditionCarryStageStarts:i,conditionCarryEvents:f,blockSize:_,registerValueCount:e}}function Yn(t,n,o,s,e,i){for(let f=0;f<o;f+=1){const l=n[f]*i;for(let c=0;c<e;c+=1)t[l+c]=t[l+s[c]]}}function Xn(t,n){for(;t.nextStage<=n;){const o=t.stageStarts[t.nextStage],s=t.stageStarts[t.nextStage+1];for(let e=o;e<s;e+=1){const i=t.events[e],f=i&Pn;if(i&Ot){const _=t.activePositions[f];if(_===-1)throw new Error("Invalid postDecode condition carry removal");const l=t.activeCount-1,c=t.activeOffsets[l];_!==l&&(t.activeOffsets[_]=c,t.activePositions[c]=_),t.activePositions[f]=-1,t.activeCount=l}else{if(t.activePositions[f]!==-1)throw new Error("Invalid postDecode condition carry addition");t.activePositions[f]=t.activeCount,t.activeOffsets[t.activeCount]=f,t.activeCount+=1}}t.nextStage+=1}}function Qn(t,n,o,s,e=0){let i=e,f=t[s];for(;f!==-1;)o[i]=f,i+=1,f=n[f];return t[s]=-1,i}function Hn(t,n,o,s){o<0||o>=t.length||(n[s]=t[o],t[o]=s)}function Zn(t,n,o,s,e,i,f){for(let _=0;_<e;_+=1){const l=o+_*i,c=s+_*i;switch(t){case w.Negate:for(let a=0;a<f;a+=1)n[l+a]=-n[c+a];break;case w.Abs:for(let a=0;a<f;a+=1)n[l+a]=Math.abs(n[c+a]);break;case w.Log:for(let a=0;a<f;a+=1)n[l+a]=Math.log(n[c+a]);break;case w.Exp:for(let a=0;a<f;a+=1)n[l+a]=Math.exp(n[c+a]);break;case w.Floor:for(let a=0;a<f;a+=1)n[l+a]=Math.floor(n[c+a]);break;case w.Ceil:for(let a=0;a<f;a+=1)n[l+a]=Math.ceil(n[c+a]);break;case w.Round:for(let a=0;a<f;a+=1)n[l+a]=It(n[c+a]);break;case w.Sin:for(let a=0;a<f;a+=1)n[l+a]=Math.sin(n[c+a]);break;case w.Cos:for(let a=0;a<f;a+=1)n[l+a]=Math.cos(n[c+a]);break;case w.Acos:for(let a=0;a<f;a+=1)n[l+a]=Math.acos(n[c+a]);break;case w.Tan:for(let a=0;a<f;a+=1)n[l+a]=Math.tan(n[c+a]);break;case w.Asin:for(let a=0;a<f;a+=1)n[l+a]=Math.asin(n[c+a]);break;case w.Atan:for(let a=0;a<f;a+=1)n[l+a]=Math.atan(n[c+a]);break}}}function jn(t,n,o,s,e,i,f,_,l){for(let c=0;c<i;c+=1){const a=o+c*_,y=s+c*_,E=e+(f===1?0:c*_);switch(t){case w.Add:for(let h=0;h<l;h+=1)n[a+h]=n[y+h]+n[E+h];break;case w.Subtract:for(let h=0;h<l;h+=1)n[a+h]=n[y+h]-n[E+h];break;case w.Multiply:for(let h=0;h<l;h+=1)n[a+h]=n[y+h]*n[E+h];break;case w.Divide:for(let h=0;h<l;h+=1)n[a+h]=n[y+h]/n[E+h];break;case w.Pow:for(let h=0;h<l;h+=1)n[a+h]=n[y+h]**n[E+h];break;case w.Min:for(let h=0;h<l;h+=1)n[a+h]=Wt(n[y+h],n[E+h]);break;case w.Max:for(let h=0;h<l;h+=1)n[a+h]=dt(n[y+h],n[E+h]);break;case w.Atan2:for(let h=0;h<l;h+=1)n[a+h]=Math.atan2(n[y+h],n[E+h]);break}}}function Jn(t,n,o,s,e,i,f,_,l,c,a,y){const{attributes:E,instructions:h}=n;for(let A=f;A<_;A+=1){const d=A*H,m=h[d+gt];if(m===w.Constant)continue;const R=h[d+z],M=h[d+Dt],u=i[A],P=d+Ct,U=h[P],g=h[P+1],p=h[P+2],S=h[P+3],b=U===Z?0:i[U],I=g===Z?0:i[g],G=p===Z?0:i[p],v=S===Z?0:i[S],L=U===Z?0:ut(h,U),O=g===Z?0:ut(h,g),W=p===Z?0:ut(h,p);switch(m){case w.InputField:Gn(M,l,c,a,t,s,e,u,y);break;case w.InputAttribute:Fn(o,E[M],l,c,a,e,u,y);break;case w.Negate:case w.Abs:case w.Log:case w.Exp:case w.Floor:case w.Ceil:case w.Round:case w.Sin:case w.Cos:case w.Acos:case w.Tan:case w.Asin:case w.Atan:Zn(m,e,u,b,R,a,c);break;case w.Sqrt:for(let r=0;r<R;r+=1){const T=u+r*a,x=b+r*a;for(let N=0;N<c;N+=1)e[T+N]=Math.sqrt(e[x+N])}break;case w.Normalize:for(let r=0;r<c;r+=1){let T=0;for(let N=0;N<R;N+=1){const C=e[b+N*a+r];T+=C*C}const x=Math.sqrt(T);for(let N=0;N<R;N+=1){const C=e[b+N*a+r];e[u+N*a+r]=x===0||!Number.isFinite(x)?C:C/x}}break;case w.Length:for(let r=0;r<c;r+=1){let T=0;for(let x=0;x<L;x+=1){const N=e[b+x*a+r];T+=N*N}e[u+r]=Math.sqrt(T)}break;case w.IsFinite:for(let r=0;r<c;r+=1){let T=!0;for(let x=0;x<L;x+=1)T&&(T=Number.isFinite(e[b+x*a+r]));e[u+r]=T?1:0}break;case w.Not:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]===0?1:0;break;case w.Add:case w.Subtract:case w.Multiply:case w.Divide:case w.Pow:case w.Min:case w.Max:case w.Atan2:jn(m,e,u,b,I,R,O,a,c);break;case w.Dot:for(let r=0;r<c;r+=1){let T=0;for(let x=0;x<L;x+=1)T+=e[b+x*a+r]*e[I+x*a+r];e[u+r]=T}break;case w.Cross:for(let r=0;r<c;r+=1)e[u+r]=e[b+a+r]*e[I+a*2+r]-e[b+a*2+r]*e[I+a+r],e[u+a+r]=e[b+a*2+r]*e[I+r]-e[b+r]*e[I+a*2+r],e[u+a*2+r]=e[b+r]*e[I+a+r]-e[b+a+r]*e[I+r];break;case w.Equal:case w.NotEqual:for(let r=0;r<c;r+=1){let T=!0;for(let x=0;x<L;x+=1)T&&(T=e[b+x*a+r]===e[I+x*a+r]);e[u+r]=(m===w.Equal?T:!T)?1:0}break;case w.Less:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]<e[I+r]?1:0;break;case w.LessEqual:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]<=e[I+r]?1:0;break;case w.Greater:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]>e[I+r]?1:0;break;case w.GreaterEqual:for(let r=0;r<c;r+=1)e[u+r]=e[b+r]>=e[I+r]?1:0;break;case w.And:case w.Or:for(let r=0;r<c;r+=1){const T=m===w.And?e[b+r]!==0&&e[I+r]!==0:e[b+r]!==0||e[I+r]!==0;e[u+r]=T?1:0}break;case w.QuaternionMultiply:for(let r=0;r<c;r+=1){const T=e[b+r],x=e[b+a+r],N=e[b+a*2+r],C=e[b+a*3+r],F=e[I+r],q=e[I+a+r],$=e[I+a*2+r],B=e[I+a*3+r];e[u+r]=C*F+T*B+x*$-N*q,e[u+a+r]=C*q-T*$+x*B+N*F,e[u+a*2+r]=C*$+T*q-x*F+N*B,e[u+a*3+r]=C*B-T*F-x*q-N*$}break;case w.RotateVector:for(let r=0;r<c;r+=1){const T=e[b+r],x=e[b+a+r],N=e[b+a*2+r],C=e[b+a*3+r],F=e[I+r],q=e[I+a+r],$=e[I+a*2+r],B=2*(x*$-N*q),K=2*(N*F-T*$),X=2*(T*q-x*F);e[u+r]=F+C*B+x*X-N*K,e[u+a+r]=q+C*K+N*B-T*X,e[u+a*2+r]=$+C*X+T*K-x*B}break;case w.Select:for(let r=0;r<R;r+=1){const T=u+r*a,x=I+r*a,N=G+r*a;for(let C=0;C<c;C+=1)e[T+C]=e[b+C]!==0?e[x+C]:e[N+C]}break;case w.Clamp:for(let r=0;r<R;r+=1){const T=u+r*a,x=b+r*a,N=I+(O===1?0:r*a),C=G+(W===1?0:r*a);for(let F=0;F<c;F+=1)e[T+F]=Wt(dt(e[x+F],e[N+F]),e[C+F])}break;case w.Mix:for(let r=0;r<R;r+=1){const T=u+r*a,x=b+r*a,N=I+(O===1?0:r*a),C=G+(W===1?0:r*a);for(let F=0;F<c;F+=1){const q=e[x+F];e[T+F]=q+(e[N+F]-q)*e[C+F]}}break;case w.Vec2:for(let r=0;r<c;r+=1)e[u+r]=e[b+r],e[u+a+r]=e[I+r];break;case w.Vec3:for(let r=0;r<c;r+=1)e[u+r]=e[b+r],e[u+a+r]=e[I+r],e[u+a*2+r]=e[G+r];break;case w.Vec4:for(let r=0;r<c;r+=1)e[u+r]=e[b+r],e[u+a+r]=e[I+r],e[u+a*2+r]=e[G+r],e[u+a*3+r]=e[v+r];break;case w.Component:for(let r=0;r<c;r+=1)e[u+r]=e[b+M*a+r];break;case w.MaxComponentIndex:for(let r=0;r<c;r+=1){let T=0,x=e[b+r];for(let N=1;N<L;N+=1){const C=e[b+N*a+r];C>x&&(T=N,x=C)}e[u+r]=T}break;default:throw new Error(`Unknown postDecode opcode: ${m}`)}}}function Kn(t,n,o,s,e,i,f){const{constants:_,instructions:l}=n,{registerBases:c,conditionStages:a,conditionStageCount:y,outputInstructionStart:E,conditionCarryStageStarts:h,conditionCarryEvents:A,blockSize:d,outputPlan:m}=o,R=Bt(l),M=a?{stages:a,sourceIndices:new Uint16Array(d),laneIndices:new Uint16Array(d),nextIndices:new Int32Array(d).fill(-1),heads:new Int32Array(y+1).fill(-1)}:void 0,u=A.length===0?void 0:{stageStarts:h,events:A,nextStage:0,activeOffsets:new Uint16Array(i.length/d),activePositions:new Int32Array(i.length/d).fill(-1),activeCount:0},P=m.writesOutputs?new Uint32Array(d):void 0;for(let U=0;U<R;U+=1){const g=U*H;if(l[g+gt]!==w.Constant)continue;const p=c[U],S=l[g+z],b=l[g+Dt];for(let I=0;I<S;I+=1)i.fill(_[b+I],p+I*d,p+(I+1)*d)}for(let U=0;U<f;U+=d){let g=Math.min(d,f-U),p;u&&(u.nextStage=0,u.activeCount=0);for(let S=0;S<=y;S+=1){const b=S<y;if(M&&M.heads[S]!==-1){if(p!==M.sourceIndices)if(p)M.sourceIndices.set(p.subarray(0,g),0);else for(let L=0;L<g;L+=1)M.sourceIndices[L]=L;g=Qn(M.heads,M.nextIndices,M.sourceIndices,S,g),p=M.sourceIndices}const I=S*tt,G=M&&b?M.stages[I+xn]:E,v=M&&b?M.stages[I+yt]+1:R;if(g!==0&&Jn(t,n,s,e,i,c,G,v,U,g,d,p),M&&b&&g!==0){const L=M.stages[I+Lt],O=c[L],W=S+1,r=p,T=g;let x=0;const N=M.stages[I+En],C=M.stages[I+Mn],F=N===W,q=C===W,$=M.heads.length;if(F&&C===$||q&&N===$)for(let B=0;B<g;B+=1){if(i[O+B]!==0!==F)continue;const X=r==null?void 0:r[B];M.laneIndices[x]=B,X!==void 0&&(M.sourceIndices[x]=X),x+=1}else for(let B=0;B<g;B+=1){const K=(r==null?void 0:r[B])??B,X=i[O+B]!==0?N:C;X===W?(M.laneIndices[x]=B,r&&(M.sourceIndices[x]=K),x+=1):Hn(M.heads,M.nextIndices,X,K)}x!==0&&x!==T&&u&&(Xn(u,S),Yn(i,u.activeOffsets,u.activeCount,M.laneIndices,x,d)),(x!==T||r===M.laneIndices)&&(p=x===0?void 0:r?M.sourceIndices:M.laneIndices),g=x}}if(P&&g!==0){if(p)for(let S=0;S<g;S+=1)P[S]=(U+p[S])*4;else{let S=U*4;for(let b=0;b<g;b+=1)P[b]=S,S+=4}kn(t,e,i,m,P,d,g)}if(u)for(let S=0;S<u.activeCount;S+=1)u.activePositions[u.activeOffsets[S]]=-1}}function kn(t,n,o,s,e,i,f){const{outputBases:_}=s,l=_[Vt];if(l!==J)for(let A=0;A<f;A+=1){const d=e[A],m=l+A;n[d]=o[m],n[d+1]=o[m+i],n[d+2]=o[m+i*2]}const c=_[Gt];if(c!==J)for(let A=0;A<f;A+=1){const d=e[A],m=c+A,R=t.splat1[d+1]&65535;t.splat1[d+1]=(R|V(Math.log(o[m]))<<16)>>>0,t.splat1[d+2]=(V(Math.log(o[m+i]))|V(Math.log(o[m+i*2]))<<16)>>>0}const a=_[$t];if(a!==J)for(let A=0;A<f;A+=1){const d=e[A],m=On(o,a+A,i);m!==void 0&&(t.splat1[d+3]=m)}const y=_[Yt];if(y!==J)for(let A=0;A<f;A+=1){const d=e[A];t.splat0[d+3]=In(o[y+A])}const E=_[Xt];if(E!==J)for(let A=0;A<f;A+=1){const d=e[A]+3;t.splat0[d]=(t.splat0[d]&4294901760|V(Nt(o[E+A],0,1)))>>>0}const h=_[Qt];if(h!==J)for(let A=0;A<f;A+=1){const d=e[A],m=h+A;t.splat1[d]=(V(o[m])|V(o[m+i])<<16)>>>0,t.splat1[d+1]=(t.splat1[d+1]&4294901760|V(o[m+i*2]))>>>0}for(let A=0;A<s.shTargetArrays.length;A+=1){const d=s.shTargetArrays[A],m=s.shWordOffsets[A],R=s.shRegisterBases[A];for(let M=0;M<f;M+=1){const u=e[M];d[u+m]=Wn(o,R+M,i)}}if(s.updatesSortCenter)for(let A=0;A<f;A+=1){const d=e[A],m=t.splat1[d+1]>>>16===64512&&(t.splat1[d+2]&65535)===64512&&t.splat1[d+2]>>>16===64512,R=(d>>>2)*3;m?(t.sortCenters[R]=Number.NaN,t.sortCenters[R+1]=Number.NaN,t.sortCenters[R+2]=Number.NaN):(t.sortCenters[R]=n[d],t.sortCenters[R+1]=n[d+1],t.sortCenters[R+2]=n[d+2])}}function zn(t,n){let o=t.numSplats;for(const _ of n.attributes)o=Math.min(o,_.count);if(o===0||n.instructions.length===0)return;const s=$n(t,n,o),e=new Float32Array(s.registerValueCount*s.blockSize),i=new DataView(n.attributeData.buffer,n.attributeData.byteOffset,n.attributeData.byteLength),f=new Float32Array(t.splat0.buffer,t.splat0.byteOffset,t.splat0.length);Kn(t,n,s,i,f,e,o)}function vt(t){const n=new Set,o=new Set;function s(e){!e||typeof e!="object"||o.has(e)||(o.add(e),e instanceof ArrayBuffer?n.add(e):ArrayBuffer.isView(e)?n.add(e.buffer):Object.values(e).forEach(s))}return s(t),[...n]}const te={setSortCenterState:ne,sortCenters32:ee,loadSplats:re,nextChunk:se};let mt;function Ht(){return(mt==null?void 0:mt.buffer.byteLength)??0}function ne({centerUpdateRangeIndices:t,updateCenters:n,matrixUpdateRangeIndices:o,updateMatrices:s,rangeMeshIds:e,rangeBases:i,rangeCounts:f}){Kt(t,n,o,s,e,i,f)}function ee({numSplats:t,cameraPosition:n,direction:o,radial:s,ordering:e}){return{activeSplats:kt(t,n[0],n[1],n[2],o[0],o[1],o[2],s,e),ordering:e}}async function Zt(t){const{id:n,name:o,args:s}=t.data;try{const e=te[o];if(!e)throw new Error(`Unknown worker RPC: ${o}`);const f=await e(s,{sendStatus:_=>{self.postMessage({id:n,status:_},{transfer:vt(_)})}});self.postMessage({id:n,result:f,wasmMemoryBytes:Ht()},{transfer:vt(f)})}catch(e){console.warn(`Worker error: ${e}`),self.postMessage({id:n,error:e,wasmMemoryBytes:Ht()},{transfer:vt(e)})}}async function oe({decoder:t,fileBytes:n,url:o,requestHeader:s,withCredentials:e,chunked:i,chunkedLength:f,sendStatus:_}){if(n){const d=n.length;return d>0&&t.set_expected_input_size(d),_({loaded:d,total:d}),t.push(n),t.finish()}const l=f??0;if(!Number.isSafeInteger(l)||l<0)throw new Error("streamLength must be a non-negative integer");let c=l,a=0,y;if(o){const d=new Request(o,{headers:s?new Headers(s):void 0,credentials:e?"include":"same-origin"}),m=await fetch(d);if(!m.ok||!m.body)throw new Error(`Failed to fetch "${o}": ${m.status} ${m.statusText}`);y=m.body;const R=Number(m.headers.get("Content-Length")||"0"),M=Number.isSafeInteger(R)&&R>0?R:0;c||(c=M);const u=m.headers.get("Content-Encoding"),P=!u||u.toLowerCase()==="identity";m.type==="basic"&&P&&(a=M)}else if(!i)throw new Error("No url or fileBytes provided");const E=y==null?void 0:y.getReader(),h=async()=>{if(E){const{done:m,value:R}=await E.read();return m?void 0:R}const d=await new Promise(m=>{jt=m,_({nextChunk:!0})});return d.length===0?void 0:d};let A=0;try{for(a>0&&t.set_expected_input_size(a);;){const d=await h();if(!d)break;if(A+=d.length,a>0&&A>a)throw new Error(`Input length exceeds the expected ${a} bytes`);_({loaded:A,total:c}),t.push(d)}if(a>0&&A!==a)throw new Error(`Input length mismatch: expected ${a} bytes, received ${A}`);return i&&c===0&&_({loaded:A,total:A}),t.finish()}catch(d){try{await(E==null?void 0:E.cancel(d))}catch{}throw d}finally{E==null||E.releaseLock()}}function ae(t){return{numSplats:t.numSplats,splatArrays:[t.splat0,t.splat1],sortCenters:t.sortCenters,extra:{sh1:t.sh1,sh2:t.sh2,sh3a:t.sh3a,sh3b:t.sh3b}}}async function re({url:t,requestHeader:n,withCredentials:o,fileBytes:s,fileType:e,pathName:i,chunked:f,chunkedLength:_,postDecode:l},{sendStatus:c}){const a=Jt(e,i??t),y=await oe({decoder:a,fileBytes:s,url:t,requestHeader:n,withCredentials:o,chunked:f,chunkedLength:_,sendStatus:c});return l&&zn(y,l),ae(y)}let jt=t=>{};async function se({chunk:t}){jt(t)}async function ce(){let t;const n=new Promise(i=>{t=i}),o=[],s=i=>{if(i.data.name==="init-wasm"){t(i.data.module);return}o.push(i)};self.addEventListener("message",s),mt=(await _n({module_or_path:await n})).memory,self.removeEventListener("message",s),self.addEventListener("message",Zt);for(const i of o)Zt(i);o.length=0}ce().catch(console.error)})();\n//# sourceMappingURL=worker-C26a7h-J.js.map\n',$A=typeof self<"u"&&self.Blob&&new Blob([JI],{type:"text/javascript;charset=utf-8"});function gQ(B){let A;try{if(A=$A&&(self.URL||self.webkitURL).createObjectURL($A),!A)throw"";const I=new Worker(A,{name:B==null?void 0:B.name});return I.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(A)}),I}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(JI),{name:B==null?void 0:B.name})}finally{A&&(self.URL||self.webkitURL).revokeObjectURL(A)}}const lI=1024*1024,JA=64*lI,AI=256*lI,II=3*60*1e3,QQ=3*1e3;function BQ(B){const I=(Math.min(AI,Math.max(JA,B))-JA)/(AI-JA);return Math.round(II+I*(QQ-II))}function CQ(B){let A=-1,I=Number.POSITIVE_INFINITY;for(let g=B.length-1;g>=0;g-=1){const Q=B[g].peakWasmMemoryBytes;Q<I&&(A=g,I=Q)}return A}const NA=class NA{constructor(){this.messages={},this.peakWasmMemoryBytes=0,this.worker=new gQ,this.worker.onmessage=A=>this.onMessage(A),MI.then(A=>{this.worker.postMessage({name:"init-wasm",module:A})})}onMessage(A){const{id:I,result:g,error:Q,status:C,wasmMemoryBytes:t}=A.data;Number.isSafeInteger(t)&&t>=0&&(this.peakWasmMemoryBytes=Math.max(this.peakWasmMemoryBytes,t));const E=this.messages[I];if(E){if(C!==void 0){E.statusQueue=E.statusQueue.then(()=>{var i;if(this.messages[I]===E)return(i=E.onStatus)==null?void 0:i.call(E,C)}),E.statusQueue.catch(()=>{});return}E.statusQueue.then(()=>{if(Q!==void 0)throw Q;return g}).finally(()=>{delete this.messages[I]}).then(E.resolve,E.reject)}}async call(A,I,g={}){const Q=++NA.currentId,C=new Promise((t,E)=>{this.messages[Q]={resolve:i=>t(i),reject:E,onStatus:g.onStatus,statusQueue:Promise.resolve()}});return this.worker.postMessage({id:Q,name:A,args:I},{transfer:rI(I)}),C}dispose(){this.worker.terminate();const A=Object.values(this.messages);this.messages={};for(const I of A)I.reject(new Error("Worker terminate"))}};NA.currentId=0;let hA=NA;class EQ{constructor(A=4){this.numWorkers=0,this.freelist=[],this.idleWorkerTimeouts=new Map,this.queue=[],this.maxWorkers=A}async withWorker(A){const I=await this.allocWorker();try{return await A(I)}finally{this.freeWorker(I)}}async allocWorker(){const A=CQ(this.freelist);if(A!==-1){const I=this.freelist.splice(A,1)[0],g=this.idleWorkerTimeouts.get(I);return g!==void 0&&(clearTimeout(g),this.idleWorkerTimeouts.delete(I)),I}if(this.numWorkers<this.maxWorkers){const I=new hA;return this.numWorkers+=1,I}return new Promise(I=>{this.queue.push(I)})}freeWorker(A){if(this.numWorkers>this.maxWorkers){A.dispose(),this.numWorkers-=1;return}const I=this.queue.shift();if(I){I(A);return}this.freelist.push(A);const g=setTimeout(()=>{this.idleWorkerTimeouts.delete(A);const Q=this.freelist.indexOf(A);Q!==-1&&(this.freelist.splice(Q,1),A.dispose(),this.numWorkers-=1)},BQ(A.peakWasmMemoryBytes));this.idleWorkerTimeouts.set(A,g)}}const iQ=new EQ,BA=new e.Vector3,CA=4096,yA=CA*4,gI=1/255;function QI(B){return Math.max(1,Math.ceil(B/yA))*yA}function tQ(B){const A=B.getWorldScale(BA);return(A.x+A.y+A.z)/3}const N=class N extends e.Mesh{constructor(A){if(!A)throw new Error("GaussianSplatRenderer options are required");if(!A.renderer)throw new Error("renderer is required in GaussianSplatRenderer options");const I=N.makeUniforms();Object.assign(I,A.extraUniforms??{});const g=LI(),Q=A.premultipliedAlpha??!0,C=new $g,t=new e.ShaderMaterial({glslVersion:e.GLSL3,vertexShader:A.vertexShader??g.splatVertex,fragmentShader:A.fragmentShader??g.splatFragment,uniforms:I,premultipliedAlpha:Q,transparent:A.transparent??!0,depthTest:A.depthTest??!0,depthWrite:A.depthWrite??!1,side:e.DoubleSide,allowOverride:!1});super(C,t),this.renderSize=new e.Vector2,this.lastFrame=-1,this.updateTimeoutId=-1,this.orderingTexture=null,this.orderingBuffer=new Uint32Array(0),this.maxSplats=0,this.activeSplats=0,this.accumulators=[],this.sorting=!1,this.sortDirty=!1,this.lastSortTime=0,this.sortWorker=null,this.sortedCenter=new e.Vector3().setScalar(Number.NEGATIVE_INFINITY),this.sortedDir=new e.Vector3().setScalar(0),this.sortCenterCache=new ZI,this.sortStateRevision=0,this.uploadedSortStateRevision=-1,this.updateRunning=!1,this.updatePromise=Promise.resolve(),this.queuedUpdate=null,this.disposed=!1,this.superXY=1,this.material=t,this.uniforms=I,this.frustumCulled=!1,this.renderer=A.renderer,this.onDirty=A.onDirty,this.dirty=!0,this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!0,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.minPixelRadius=A.minPixelRadius??1,this.maxPixelRadius=A.maxPixelRadius??512,this.minAlpha=A.minAlpha??gI,this.enable2DGS=A.enable2DGS??!1,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.clipXY=A.clipXY??1.25,this.focalAdjustment=A.focalAdjustment??2,this.sortRadial=A.sortRadial??!1,this.minSortIntervalMs=A.minSortIntervalMs??0;const{timer:E,ownsTimer:i}=RI(A.timer);this.timer=E,this.ownsTimer=i,this.display=this.createAccumulator(),this.current=this.display,this.accumulators.push(this.createAccumulator());const s=this.renderer.getContext().getExtension("WEBGL_provoking_vertex");if(s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL),A.target){const{width:D,height:o,doubleBuffer:w,superXY:n,...a}=A.target,r=Math.max(1,Math.min(4,n??1));if(D*r>8192||o*r>8192)throw new Error("Target size too large");this.superXY=r;const h=D*r,c=o*r,y={format:e.RGBAFormat,type:e.UnsignedByteType,colorSpace:e.SRGBColorSpace,...a};this.target=new e.WebGLRenderTarget(h,c,y),w&&(this.backTarget=new e.WebGLRenderTarget(h,c,y))}}raycast(A,I){}static makeUniforms(){return{renderSize:{value:new e.Vector2},near:{value:.1},far:{value:1e3},renderToViewQuat:{value:new e.Quaternion},renderToViewPos:{value:new e.Vector3},renderToViewScale:{value:1},maxStdDev:{value:1},minPixelRadius:{value:1},maxPixelRadius:{value:512},minAlpha:{value:gI},enable2DGS:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},clipXY:{value:1.25},focalAdjustment:{value:2},encodeLinear:{value:!1},ordering:{type:"t",value:N.emptyOrdering},splats:{type:"t",value:K.emptyTexture},splats2:{type:"t",value:K.emptyTexture},time:{value:0},deltaTime:{value:0},debugFlag:{value:!1}}}dispose(){var I;if(this.disposed)return;this.disposed=!0,this.queuedUpdate=null,(I=super.dispose)==null||I.call(this),this.target&&(this.target.dispose(),this.target=void 0),this.backTarget&&(this.backTarget.dispose(),this.backTarget=void 0),this.orderingTexture&&(this.orderingTexture.dispose(),this.orderingTexture=null);const A=new Set;A.add(this.display),A.add(this.current);for(const g of this.accumulators)A.add(g);for(const g of A)g.dispose();this.accumulators.length=0,this.resetSortWorker(),this.releaseReadbackBuffers(),this.orderingBuffer=new Uint32Array(0),this.maxSplats=0,this.activeSplats=0,this.geometry.dispose(),this.material.dispose()}setDirty(){var A;this.dirty||(this.dirty=!0,(A=this.onDirty)==null||A.call(this))}resetSortWorker(){var A;(A=this.sortWorker)==null||A.dispose(),this.sortWorker=null,this.sortCenterCache.dispose(),this.uploadedSortStateRevision=-1}releaseReadbackBuffers(){this.superPixels=void 0,this.targetPixels=void 0}createAccumulator(){return new K}takeAccumulator(){return this.accumulators.pop()??this.createAccumulator()}releaseAccumulator(A){this.accumulators.push(A)}disposeOversizedAccumulators(A){for(const I of this.accumulators)I.maxSplats>A&&I.dispose()}onBeforeRender(A,I,g){var y;const Q=N.gaussianSplatOverride??this,C=A.info.render.frame,t=C!==Q.lastFrame;Q.lastFrame=C;const E=A.getRenderTarget(),i=sQ(E);if(E){if(Q.renderSize.set(E.width,E.height),i&&Q.renderSize.x===1&&Q.renderSize.y===1){const S=(y=A.xr.getSession())==null?void 0:y.renderState.baseLayer;S&&(Q.renderSize.x=S.framebufferWidth,Q.renderSize.y=S.framebufferHeight)}}else A.getDrawingBufferSize(Q.renderSize);if(this.uniforms.renderSize.value.copy(Q.renderSize),Q.autoUpdate&&t){const S=Q.preUpdate&&!A.xr.isPresenting;let M=g;if(A.xr.isPresenting){const k=A.xr.getCamera();M=k.cameras[0]??k}S?Q.updateInternal({scene:I,camera:M,autoUpdate:!0,shrinkResources:!1}):Q.updateTimeoutId===-1&&(Q.updateTimeoutId=setTimeout(()=>{Q.updateTimeoutId=-1,Q.updateInternal({scene:I,camera:M,autoUpdate:!0,shrinkResources:!1})},1))}const s=g;this.uniforms.near.value=s.near,this.uniforms.far.value=s.far;const D=this.geometry;D.instanceCount=Q.activeSplats;const o=Q.display,w=new e.Matrix4().makeTranslation(o.viewOrigin);g.matrixWorld.clone().invert().multiply(w).decompose(this.uniforms.renderToViewPos.value,this.uniforms.renderToViewQuat.value,BA),this.uniforms.renderToViewScale.value=(BA.x+BA.y+BA.z)/3,this.uniforms.maxStdDev.value=Q.maxStdDev,this.uniforms.minPixelRadius.value=Q.minPixelRadius,this.uniforms.maxPixelRadius.value=Q.maxPixelRadius,this.uniforms.minAlpha.value=Q.minAlpha,this.uniforms.enable2DGS.value=Q.enable2DGS,this.uniforms.preBlurAmount.value=Q.preBlurAmount,this.uniforms.blurAmount.value=Q.blurAmount,this.uniforms.clipXY.value=Q.clipXY,this.uniforms.focalAdjustment.value=Q.focalAdjustment;const h=E===null?A.outputColorSpace:i?E.texture.colorSpace:e.ColorManagement.workingColorSpace;this.uniforms.encodeLinear.value=h!==e.SRGBColorSpace,this.uniforms.ordering.value=Q.orderingTexture??N.emptyOrdering;const c=o.getTextures();this.uniforms.splats.value=c[0],this.uniforms.splats2.value=c[1],this.uniforms.time.value=o.time,this.uniforms.deltaTime.value=o.deltaTime,this.uniforms.debugFlag.value=performance.now()/1e3%2<1,Q.dirty=!1}clearSplats(){this.activeSplats=0,this.display.numSplats=0,this.setDirty()}async update({scene:A,camera:I}){await this.updateInternal({scene:A,camera:I,autoUpdate:!1,shrinkResources:!1})}async shrinkResources({scene:A,camera:I}){await this.updateInternal({scene:A,camera:I,autoUpdate:!1,shrinkResources:!0})}updateInternal(A){if(this.disposed)return Promise.resolve();const I=this.queuedUpdate;return this.queuedUpdate={scene:A.scene,camera:A.camera,autoUpdate:A.autoUpdate&&((I==null?void 0:I.autoUpdate)??!0),shrinkResources:A.shrinkResources||((I==null?void 0:I.shrinkResources)??!1)},this.updateRunning||(this.updateRunning=!0,this.updatePromise=this.drainUpdates()),this.updatePromise}async drainUpdates(){try{for(;this.queuedUpdate;){const A=this.queuedUpdate;this.queuedUpdate=null,await this.performUpdate(A)}}catch(A){throw this.queuedUpdate=null,A}finally{this.updateRunning=!1}}async performUpdate({scene:A,camera:I,autoUpdate:g,shrinkResources:Q}){const C=this.renderer;Q&&this.releaseReadbackBuffers(),this.ownsTimer&&this.timer.update();const t=I.getWorldPosition(new e.Vector3),E=I.getWorldDirection(new e.Vector3),i=t.distanceTo(this.sortedCenter)>.001*tQ(I)||E.dot(this.sortedDir)<.999||this.sortRadial!==this.sortedRadial,s=this.takeAccumulator();if(s===this.current)throw new Error("Next accumulator is the same as the current accumulator");let D;try{D=s.prepareGenerate({renderer:C,scene:A,timer:this.timer,camera:I,previous:this.current})}catch(y){throw this.releaseAccumulator(s),y}const{version:o,sortUpdated:w,requiredMaxSplats:n,generate:a}=D,r=Q&&QI(n)<this.maxSplats,h=!g||i||o!==this.current.version,c=r||i||w;if(!h)this.releaseAccumulator(s);else{try{a(Q)}catch(y){throw this.releaseAccumulator(s),y}w&&(this.sortStateRevision+=1),this.display.mappingVersion===s.mappingVersion&&!c?(this.releaseAccumulator(this.display),this.display=s):this.display!==this.current&&this.releaseAccumulator(this.current),this.current=s,this.sortDirty||(this.sortDirty=c),this.setDirty()}await this.driveSort(r),Q&&this.disposeOversizedAccumulators(this.current.maxSplats)}async driveSort(A=!1){var t;if(this.disposed||this.sorting||!this.sortDirty)return;const I=performance.now(),g=this.lastSortTime?this.lastSortTime+this.minSortIntervalMs:I;if(I<g&&(await new Promise(E=>setTimeout(E,g-I)),this.disposed))return;this.sorting=!0,this.sortDirty=!1,this.lastSortTime=performance.now();const Q=this.current,C=this.activeSplats;try{A&&this.resetSortWorker();const E=this.sortRadial;this.sortWorker&&this.sortedRadial!==E&&this.resetSortWorker(),this.sortWorker??(this.sortWorker=new hA);const i=this.sortWorker,{numSplats:s,maxSplats:D}=Q,o=QI(D),w=o/yA;this.maxSplats=A?o:Math.max(this.maxSplats,o),this.orderingBuffer.length!==this.maxSplats&&(this.orderingBuffer=new Uint32Array(this.maxSplats));const n=this.sortStateRevision;if(this.uploadedSortStateRevision!==n){const{payload:c,commit:y}=this.sortCenterCache.prepare(Q);await i.call("setSortCenterState",c),y(),this.uploadedSortStateRevision=n}const a=await i.call("sortCenters32",{numSplats:s,cameraPosition:[Q.viewOrigin.x,Q.viewOrigin.y,Q.viewOrigin.z],direction:[Q.viewDirection.x,Q.viewDirection.y,Q.viewDirection.z],radial:E,ordering:this.orderingBuffer});this.activeSplats=a.activeSplats;const r=Math.ceil(a.activeSplats/yA),h=(t=this.orderingTexture)==null?void 0:t.image.data;if(this.orderingTexture&&(w>this.orderingTexture.image.height||A&&w!==this.orderingTexture.image.height)&&(this.orderingTexture.dispose(),this.orderingTexture=null),this.orderingTexture){this.orderingTexture.image.data=a.ordering;const c=this.renderer;c.properties.has(this.orderingTexture)?r>0&&FI(c,this.orderingTexture,CA,r,a.ordering):this.orderingTexture.needsUpdate=!0}else{const c=new e.DataTexture(a.ordering,CA,w,e.RGBAIntegerFormat,e.UnsignedIntType);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.orderingTexture=c}this.orderingBuffer=h instanceof Uint32Array&&h.length===this.maxSplats?h:new Uint32Array(this.maxSplats),this.sortedCenter.copy(Q.viewOrigin),this.sortedDir.copy(Q.viewDirection),this.sortedRadial=E,this.current===Q&&this.display!==Q&&(this.releaseAccumulator(this.display),this.display=Q),this.setDirty()}catch(E){if(this.disposed)return;throw this.sortDirty=!0,this.current===Q&&Q!==this.display&&this.accumulators.length===0&&(this.current=this.display,this.releaseAccumulator(Q),this.activeSplats=C,this.sortDirty=!1,this.uploadedSortStateRevision=-1),E}finally{this.sorting=!1}}render(A,I){const g=N.gaussianSplatOverride;try{N.gaussianSplatOverride=this,this.renderer.render(A,I)}finally{N.gaussianSplatOverride=g}}renderTarget({scene:A,camera:I}){const g=this.backTarget??this.target;if(!g)throw new Error("No target");const Q=this.renderer.getRenderTarget(),C=N.gaussianSplatOverride;try{this.renderer.setRenderTarget(g),N.gaussianSplatOverride=this,this.renderer.render(A,I)}finally{N.gaussianSplatOverride=C,this.renderer.setRenderTarget(Q)}return g!==this.target&&([this.target,this.backTarget]=[this.backTarget,this.target]),g}async readTarget(){if(!this.target)throw new Error("Must initialize with target");const{width:A,height:I}=this.target,g=A*I*4;(!this.superPixels||this.superPixels.length<g)&&(this.superPixels=new Uint8Array(g));const Q=this.superPixels;await this.renderer.readRenderTargetPixelsAsync(this.target,0,0,A,I,Q);const{superXY:C}=this;if(C===1)return Q;const t=A/C,E=I/C,i=t*E*4;(!this.targetPixels||this.targetPixels.length<i)&&(this.targetPixels=new Uint8Array(i));const s=this.targetPixels,D=C*C;for(let o=0;o<E;o++){const w=o*t;for(let n=0;n<t;n++){const a=n*C;let r=0,h=0,c=0,y=0;for(let M=0;M<C;M++){const k=(o*C+M)*A;for(let l=0;l<C;l++){const d=(k+a+l)*4;r+=Q[d],h+=Q[d+1],c+=Q[d+2],y+=Q[d+3]}}const S=(w+n)*4;s[S]=r/D,s[S+1]=h/D,s[S+2]=c/D,s[S+3]=y/D}}return s}async renderReadTarget({scene:A,camera:I}){return this.renderTarget({scene:A,camera:I}),this.readTarget()}async renderCubeMap({scene:A,worldCenter:I,size:g=256,near:Q=.1,far:C=1e3,hideObjects:t=[],update:E=!0,filter:i=!1}){if(!N.cubeRender||N.cubeRender.target.width!==g||N.cubeRender.near!==Q||N.cubeRender.far!==C){N.cubeRender&&N.cubeRender.target.dispose();const n=new e.WebGLCubeRenderTarget(g,{format:e.RGBAFormat,type:e.UnsignedByteType,generateMipmaps:i,minFilter:i?e.LinearMipMapLinearFilter:e.LinearFilter,magFilter:e.LinearFilter,colorSpace:i?e.LinearSRGBColorSpace:e.SRGBColorSpace}),a=new e.CubeCamera(Q,C,n);N.cubeRender={target:n,cubeCamera:a,near:Q,far:C}}const{target:s,cubeCamera:D}=N.cubeRender;D.position.copy(I);const o=new Map;for(const n of t)o.has(n)||o.set(n,n.visible),n.visible=!1;const w=N.gaussianSplatOverride;try{if(E){const n=new e.Camera;n.position.copy(I),await this.update({scene:A,camera:n})}return N.gaussianSplatOverride=this,D.update(this.renderer,A),s.texture}finally{N.gaussianSplatOverride=w;for(const[n,a]of o.entries())n.visible=a}}async readCubeTargets(){if(!N.cubeRender)throw new Error("No cube render");const{target:A}=N.cubeRender,{width:I,height:g}=A,Q=[],C=[];for(let t=0;t<A.texture.images.length;++t){const E=I*g*4,i=new Uint8Array(E);C.push(i);const s=this.renderer.readRenderTargetPixelsAsync(A,0,0,I,g,i,t);Q.push(s)}return await Promise.all(Q),C}async renderEnvMap({scene:A,worldCenter:I,size:g=256,near:Q=.1,far:C=1e3,hideObjects:t=[],update:E=!0}){var s;const i=await this.renderCubeMap({scene:A,worldCenter:I,size:g,near:Q,far:C,hideObjects:t,update:E,filter:!0});return N.pmrem||(N.pmrem=new e.PMREMGenerator(this.renderer)),(s=N.pmrem)==null?void 0:s.fromCubemap(i).texture}recurseSetEnvMap(A,I){A.traverse(g=>{if(g instanceof e.Mesh)if(Array.isArray(g.material))for(const Q of g.material)Q instanceof e.MeshStandardMaterial&&(Q.envMap=I);else g.material instanceof e.MeshStandardMaterial&&(g.material.envMap=I)})}get premultipliedAlpha(){return this.material.premultipliedAlpha}set premultipliedAlpha(A){this.material.premultipliedAlpha!==A&&(this.material.premultipliedAlpha=A,this.material.needsUpdate=!0)}get transparent(){return this.material.transparent}set transparent(A){this.material.transparent!==A&&(this.material.transparent=A,this.material.needsUpdate=!0)}get depthTest(){return this.material.depthTest}set depthTest(A){this.material.depthTest=A}get depthWrite(){return this.material.depthWrite}set depthWrite(A){this.material.depthWrite=A}};N.emptyOrdering=(()=>{const A=4*CA,I=new Uint32Array(A),g=new e.DataTexture(I,CA,1);return g.format=e.RGBAIntegerFormat,g.type=e.UnsignedIntType,g.internalFormat="RGBA32UI",g.needsUpdate=!0,g})(),N.cubeRender=null,N.pmrem=null;let fA=N;function sQ(B){return B==null?void 0:B.isXRRenderTarget}var UI;const oQ=15,O={float:1,bool:1,vec2:2,vec3:3,vec4:4,quaternion:4};class lA{constructor(A,I,g){this.type=A,this.register=I,this.owner=g}}const DQ=0,eQ=1,aQ=2,nQ=3,wQ=4,BI=7,CI=65535,dI={f32:4,f16:2,u8:1,unorm8:1,i8:1,snorm8:1,u16:2,unorm16:2,i16:2,snorm16:2,u32:4,i32:4};class YI{constructor(A,I){this.owner=A,this.coefficients=I}}class cQ{constructor(A){this.owner=A}coefficient(A){if(!Number.isInteger(A)||A<0||A>=oQ)throw new Error("SH coefficient index must be between 0 and 14");return this.owner.inputField("vec3",7+A)}map(A){const I=[];let g=0;for(let Q=1;Q<=3;Q+=1)for(let C=-Q;C<=Q;C+=1)I.push(this.owner.coerce(A(this.coefficient(g),{index:g,degree:Q,order:C}),"vec3")),g+=1;return new YI(this.owner,I)}}const rQ=0,hQ=1,yQ=2,GQ=3,NQ=4,UA=5,SQ=Symbol("SplatPostDecodeProgram"),uI=["float","vec2","vec3","vec4"];function FQ(B){if(typeof B=="boolean")return"bool";if(typeof B=="number")return"float";if(Array.isArray(B)&&B.length>=2&&B.length<=4)return uI[B.length-1];throw new Error("Unsupported postDecode literal")}function RQ(B,A){return`${B}:${A.map(I=>Object.is(I,-0)?"-0":I).join(":")}`}class MQ{constructor(){this.instructions=[],this.constants=[],this.attributes=[],this.constantRegisters=new Map,this.inputRegisters=new Map,this.op=this.createOperations();const A=this,I=new cQ(this);this.splat={get position(){return A.inputField("vec3",1)},get scale(){return A.inputField("vec3",2)},get quaternion(){return A.inputField("quaternion",3)},get opacity(){return A.inputField("float",4)},get alpha(){return A.inputField("float",5)},get color(){return A.inputField("vec3",6)},sh:I}}instruction(A,I,g=[],Q=0){if(this.instructions.length>=4096)throw new Error("postDecode program exceeds 4096 instructions");const C=this.instructions.length;return this.instructions.push({opcode:I,type:A,args:g,immediate:Q}),new lA(A,C,this)}inputField(A,I){const g=this.inputRegisters.get(I);if(g)return g;const Q=this.instruction(A,2,[],I);return this.inputRegisters.set(I,Q),Q}attribute(A){if(!ArrayBuffer.isView(A.data))throw new Error("postDecode attribute data must be an ArrayBuffer view");const I=dI[A.format];if(!I)throw new Error(`Unknown postDecode format: ${A.format}`);const g=A.count,Q=A.components??1,C=A.byteOffset??0,t=I*Q,E=A.byteStride??t;if(!Number.isSafeInteger(g)||g<0)throw new Error("postDecode attribute count must be non-negative");if(!Number.isInteger(Q)||Q<1||Q>4)throw new Error("postDecode attribute components must be between 1 and 4");if(!Number.isSafeInteger(C)||C<0||!Number.isSafeInteger(E)||E<t)throw new Error("Invalid postDecode attribute byteOffset or byteStride");const i=g===0?C:C+(g-1)*E+t;if(!Number.isSafeInteger(i)||i>A.data.byteLength)throw new Error("postDecode attribute data is too small");const s=this.attributes.length;return this.attributes.push({data:A.data,format:A.format,count:g,components:Q,byteOffset:C,byteStride:E}),this.instruction(uI[Q-1],3,[],s)}coerce(A,I){if(A instanceof lA){if(A.owner!==this)throw new Error("Cannot combine values from different postDecode programs");if(I&&A.type!==I&&!(I==="quaternion"&&A.type==="vec4"||I==="vec4"&&A.type==="quaternion"))throw new Error(`Expected ${I}, received ${A.type}`);return A}const g=I??FQ(A),Q=typeof A=="boolean"?[A?1:0]:typeof A=="number"?[A]:[...A],C=O[g];if(Q.length!==C)throw new Error(`Expected ${C} values for ${g}`);const t=Q.map(Math.fround);if(!t.every(Number.isFinite))throw new Error("postDecode constants must be finite");const E=RQ(g,t),i=this.constantRegisters.get(E);if(i)return i;const s=this.constants.length;this.constants.push(...t);const D=this.instruction(g,1,[],s);return this.constantRegisters.set(E,D),D}unary(A,I,g){const Q=this.coerce(I);return this.instruction(g??Q.type,A,[Q.register])}binary(A,I,g,Q){const C=this.coerce(I),t=this.coerceForBinary(g,C.type);return this.instruction(Q??C.type,A,[C.register,t.register])}ternary(A,I,g,Q){const C=this.coerce(I),t=this.coerceForBinary(g,C.type),E=this.coerceForBinary(Q,C.type);return this.instruction(C.type,A,[C.register,t.register,E.register])}coerceForBinary(A,I){return A instanceof lA?A.type==="float"&&O[I]>1?this.coerce(A):this.coerce(A,I):this.coerce(A,typeof A=="number"&&O[I]>1?"float":I)}createOperations(){const A=E=>(i,...s)=>{let D=this.coerce(i);for(const o of s)D=this.binary(E,D,o);return D},I=E=>(i,s)=>this.binary(E,i,s),g=E=>i=>this.unary(E,i),Q=E=>(i,s)=>this.binary(E,i,s,"bool"),C=E=>(i,...s)=>{let D=this.coerce(i,"bool");for(const o of s)D=this.binary(E,D,o,"bool");return D},t=(E,i,s)=>this.instruction(i,E,s.map(D=>this.coerce(D,"float").register));return{add:A(30),sub:I(31),mul:A(32),div:I(33),min:I(34),max:I(35),pow:I(36),clamp:(E,i,s)=>this.ternary(61,E,i,s),mix:(E,i,s)=>this.ternary(62,E,i,s),neg:g(10),abs:g(11),sqrt:g(12),log:g(13),exp:g(14),floor:g(15),ceil:g(16),round:g(17),sin:g(23),cos:g(24),acos:g(25),tan:g(26),asin:g(27),atan:g(28),atan2:I(49),normalize:E=>this.unary(18,E),length:E=>this.unary(19,E,"float"),isFinite:E=>this.unary(20,E,"bool"),not:E=>this.unary(22,this.coerce(E,"bool"),"bool"),eq:Q(39),ne:Q(40),lt:Q(41),lte:Q(42),gt:Q(43),gte:Q(44),and:C(45),or:C(46),select:(E,i,s)=>{const D=this.coerce(i),o=this.coerce(s,D.type);return this.instruction(D.type,60,[this.coerce(E,"bool").register,D.register,o.register])},dot:(E,i)=>this.binary(37,E,i,"float"),cross:(E,i)=>this.binary(38,E,i),vec2:(E,i)=>t(70,"vec2",[E,i]),vec3:(E,i,s)=>t(71,"vec3",[E,i,s]),vec4:(E,i,s,D)=>t(72,"vec4",[E,i,s,D]),quaternion:(E,i,s,D)=>t(72,"quaternion",[E,i,s,D]),component:(E,i)=>{const s=this.coerce(E);if(!Number.isInteger(i)||i<0||i>=O[s.type])throw new Error("postDecode component index is out of bounds");return this.instruction("float",74,[s.register],i)},maxComponentIndex:E=>this.unary(75,E,"float"),quatMul:(E,i)=>{const s=this.coerce(E,"quaternion"),D=this.coerce(i,"quaternion");return this.instruction("quaternion",47,[s.register,D.register])},rotateVector:(E,i)=>{const s=this.coerce(E,"quaternion"),D=this.coerce(i,"vec3");return this.instruction("vec3",48,[s.register,D.register])}}}}class KI{constructor(A){this.generation=1,this.values=new Int32Array(A),this.generations=new Uint32Array(A)}clear(){this.generation===4294967295?(this.generations.fill(0),this.generation=1):this.generation+=1}has(A){return this.generations[A]===this.generation}get(A){return this.has(A)?this.values[A]:void 0}set(A,I){this.generations[A]=this.generation,this.values[A]=I}delete(A){this.generations[A]=0}}function kQ(B,A,I){const g=[];for(const Q of A)Q===void 0||I[Q]||(I[Q]=1,g.push(Q));for(;g.length!==0;){const Q=g.pop();if(Q===void 0)break;for(const C of B.instructions[Q].args)I[C]||(I[C]=1,g.push(C))}}class fI{constructor(A){this.builder=A,this.instructions=[],this.constants=[],this.attributes=[],this.constantMap=new Map,this.attributeMap=new Map,this.dependencyGeneration=0,this.dependencyMarks=new Uint32Array(A.instructions.length)}appendDependencies(A,I,g=!1){if(g)for(const E of A)E!==void 0&&this.builder.instructions[E].opcode!==1&&I.delete(E);this.dependencyGeneration+=1;const Q=this.dependencyGeneration,C=[],t=[];for(const E of A)E!==void 0&&!I.has(E)&&C.push(E);for(;C.length!==0;){const E=C.pop();if(!(E===void 0||I.has(E)||this.dependencyMarks[E]===Q)){this.dependencyMarks[E]=Q,t.push(E);for(const i of this.builder.instructions[E].args)I.has(i)||C.push(i)}}return t.sort((E,i)=>E-i),this.append(t,I),I}append(A,I){for(const g of A){const Q=this.builder.instructions[g];if(Q.opcode===1){let E=this.constantMap.get(g);if(E===void 0){this.reserveInstruction(),E=this.instructions.length,this.constantMap.set(g,E);const i=this.constants.length;this.constants.push(...this.builder.constants.slice(Q.immediate,Q.immediate+O[Q.type])),this.instructions.push({...Q,immediate:i})}I.set(g,E);continue}this.reserveInstruction();let C=Q.immediate;if(Q.opcode===3){let E=this.attributeMap.get(C);E===void 0&&(E=this.attributes.length,this.attributeMap.set(C,E),this.attributes.push(this.builder.attributes[C])),C=E}const t=Q.args.map(E=>{const i=I.get(E);if(i===void 0)throw new Error("Invalid postDecode instruction dependency");return i});I.set(g,this.instructions.length),this.instructions.push({...Q,args:t,immediate:C})}}reserveInstruction(){if(this.instructions.length>=4096)throw new Error("postDecode compiled program exceeds 4096 instructions")}}function HI(){return{instructions:[],constants:[],outputs:{},condition:void 0,attributes:[]}}function pI(B,A){var g;const I=Q=>Q===void 0?void 0:A.get(Q);return{position:I(B.position),scale:I(B.scale),quaternion:I(B.quaternion),opacity:I(B.opacity),alpha:I(B.alpha),color:I(B.color),sh:(g=B.sh)==null?void 0:g.map(Q=>{const C=A.get(Q);if(C===void 0)throw new Error("Invalid postDecode output dependency");return C})}}function LQ(B,A,I,g){const s=new Uint8Array(g+1);for(let G=0;G<=g;G+=1){const F=B.instructions[G];if(F.opcode===1&&F.type==="bool"){s[G]=B.constants[F.immediate]?2:1;continue}const U=s[F.args[0]];if(F.opcode===22)s[G]=U===2?1:U===1?2:0;else if(F.opcode===45){const L=s[F.args[1]];s[G]=U===1||L===1?1:U===2&&L===2?2:0}else if(F.opcode===46){const L=s[F.args[1]];s[G]=U===2||L===2?2:U===1&&L===1?1:0}}const D=[],o=0,w=1,n=3;let a,r=0,h=g,c=-1,y=-2,S=-2;for(;;){const G=s[h];if(G!==0)S=G===2?c:y;else{const L=B.instructions[h];if(L.opcode===22){h=L.args[0];const W=c;c=y,y=W;continue}if(L.opcode===45||L.opcode===46){if(a??(a=new Int32Array((g+1)*n)),r===a.length)throw new Error("Invalid postDecode condition depth");const W=L.opcode===45;a[r]=W?o:w,a[r+1]=L.args[0],a[r+2]=W?y:c,r+=n,h=L.args[1];continue}if(D.length>=4096)throw new Error("postDecode condition exceeds 4096 flow nodes");S=D.length,D.push({register:h,onTrue:c,onFalse:y})}if(r===0)break;if(r-=n,!a)throw new Error("Invalid postDecode condition continuation");const F=a[r];h=a[r+1];const U=a[r+2];F===o?(c=S,y=U):(c=U,y=S)}const M=S;if(M===-2)return HI();if(M===-1){A.when=void 0;return}const k=D.length;if(M!==k-1)throw new Error("Invalid postDecode condition flow");const l=k,d=l+1,f=new Uint16Array(k*UA),b=new Int32Array(k).fill(-1);let DA=-1;const qA=(G,F)=>{if(G!==d){if(G===l){DA=DA===-1||DA===F?F:-2;return}b[G]=b[G]===-1||b[G]===F?F:-2}},TA=G=>G===-1?l:G===-2?d:k-1-G;for(let G=0;G<k;G+=1){const F=D[k-1-G],U=G*UA,L=TA(F.onTrue),W=TA(F.onFalse);f[U+GQ]=L,f[U+NQ]=W,qA(L,G),qA(W,G)}const T=new fI(B),X=new KI(B.instructions.length);for(let G=0;G<k;G+=1){(G===0||b[G]!==G-1)&&X.clear();const F=D[k-1-G],U=G*UA;f[U+rQ]=T.instructions.length,T.appendDependencies([F.register],X,!0),f[U+hQ]=T.instructions.length-1;const L=X.get(F.register);if(L===void 0)throw new Error("Invalid postDecode condition register");f[U+yQ]=L}return DA!==k-1&&X.clear(),T.appendDependencies(I,X),{instructions:T.instructions,constants:T.constants,outputs:pI(A,X),condition:{mode:"flow",stages:f},attributes:T.attributes}}function JQ(B,A){const I={...A};if(I.when!==void 0){const i=B.instructions[I.when];if(i.opcode===1){if(B.constants[i.immediate]===0)return HI();I.when=void 0}}const g=[I.position,I.scale,I.quaternion,I.opacity,I.alpha,I.color,...I.sh??[]];if(I.when!==void 0){const i=LQ(B,I,g,I.when);if(i)return i}const Q=new Uint8Array(B.instructions.length);kQ(B,g,Q);const C=[];for(let i=0;i<Q.length;i+=1)Q[i]&&C.push(i);const t=new fI(B),E=new KI(B.instructions.length);return t.append(C,E),{instructions:t.instructions,constants:t.constants,outputs:pI(I,E),attributes:t.attributes}}function lQ(B){const A=new Uint16Array(B.length*BI);A.fill(CI);for(let I=0;I<B.length;I+=1){const g=B[I];if(g.args.length>wQ||!Number.isInteger(g.immediate)||g.immediate<0||g.immediate>65535||g.args.some(C=>!Number.isInteger(C)||C<0||C>=CI))throw new Error("postDecode instruction exceeds Uint16 bytecode limits");const Q=I*BI;A[Q+DQ]=g.opcode,A[Q+eQ]=O[g.type],A[Q+aQ]=g.immediate;for(let C=0;C<g.args.length;C+=1)A[Q+nQ+C]=g.args[C]}return A}function UQ(B){const A=new Map;for(const E of B){if(E.count===0)continue;const i=dI[E.format]*E.components,s=E.data.byteOffset+E.byteOffset,D=s+(E.count-1)*E.byteStride+i,o=A.get(E.data.buffer)??[];o.push({start:s,end:D}),A.set(E.data.buffer,o)}const I=[],g=new Map;for(const[E,i]of A){i.sort((D,o)=>D.start-o.start);const s=[];for(const D of i){const o=s[s.length-1];if(o&&D.start<=o.end)o.end=Math.max(o.end,D.end);else{const w={buffer:E,...D,outputOffset:0};s.push(w),I.push(w)}}g.set(E,s)}let Q=0;for(const E of I)E.outputOffset=Q,Q+=E.end-E.start;const C=new Uint8Array(Q);for(const E of I)C.set(new Uint8Array(E.buffer,E.start,E.end-E.start),E.outputOffset);const t=B.map(E=>{var s;let i=0;if(E.count!==0){const D=E.data.byteOffset+E.byteOffset,o=(s=g.get(E.data.buffer))==null?void 0:s.find(w=>D>=w.start&&D<w.end);if(!o)throw new Error("postDecode attribute view was not serialized");i=o.outputOffset+D-o.start}return{format:E.format,components:E.components,byteOffset:i,byteStride:E.byteStride,count:E.count}});return{data:C,attributes:t}}UI=SQ;const dQ=class bI{constructor(A,I){this.builder=A,this.outputs=I,this[UI]=!0}static serialize(A){if(!(A instanceof bI))throw new Error("Invalid postDecode program");const I=JQ(A.builder,A.outputs),g=UQ(I.attributes);return{instructions:lQ(I.instructions),constants:new Float32Array(I.constants),outputs:I.outputs,condition:I.condition,attributeData:g.data,attributes:g.attributes}}};let mI=dQ;function YQ(B){return mI.serialize(B)}function uQ(B,A){if(A.opacity!==void 0&&A.alpha!==void 0)throw new Error("postDecode opacity cannot be combined with alpha");const I=(Q,C)=>Q===void 0?void 0:B.coerce(Q,C).register,g={when:I(A.when,"bool"),position:I(A.position,"vec3"),scale:I(A.scale,"vec3"),quaternion:I(A.quaternion,"quaternion"),opacity:I(A.opacity,"float"),alpha:I(A.alpha,"float"),color:I(A.color,"vec3")};if(A.sh!==void 0){if(!(A.sh instanceof YI)||A.sh.owner!==B)throw new Error("postDecode SH output must be created from splat.sh.map()");g.sh=A.sh.coefficients.map(Q=>Q.register)}return g}function KQ(B){const A=new MQ,I=B({splat:A.splat,op:A.op,attribute:g=>A.attribute(g)});if(!I||typeof I!="object")throw new Error("postDecode builder must return a splat patch object");return new mI(A,uQ(A,I))}const fQ={define:KQ};class xI extends EI.Loader{load(A,I,g,Q){return this.loadInternal({url:A,onLoad:I,onProgress:g,onError:Q})}async loadAsync(A,I){return new Promise((g,Q)=>{this.load(A,g,I,Q)})}parse(A){return new sA({splats:A})}loadInternal({splats:A,url:I,fileBytes:g,fileType:Q,fileName:C,stream:t,streamLength:E,postDecode:i,onLoad:s,onProgress:D,onError:o}){const w=g instanceof ArrayBuffer?new Uint8Array(g):g,n=w?void 0:this.manager.resolveURL((this.path??"")+(I??""));let a=t==null?void 0:t.getReader();const r=async h=>{const c=a;if(a=void 0,!!c){try{await c.cancel(h)}catch{}c.releaseLock()}};this.manager.itemStart(n??""),iQ.withWorker(async h=>{const c=async()=>{const l=a;if(!l)return new Uint8Array(0);try{const{done:d,value:f}=await l.read();return d?(l.releaseLock(),a=void 0,new Uint8Array(0)):f}catch(d){throw await h.call("nextChunk",{chunk:new Uint8Array(0)}),d}},y=async l=>{const{loaded:d,total:f}=l;if(d!==void 0&&D)try{D(new ProgressEvent("progress",{lengthComputable:f!==0,loaded:d,total:f??0}))}catch(b){console.error("Progress callback failed",b)}if(l.nextChunk){const b=await c();await h.call("nextChunk",{chunk:b})}},S=n?new URL(n,window.location.href).toString():void 0,M=await h.call("loadSplats",{url:S,requestHeader:this.requestHeader,withCredentials:this.withCredentials,fileBytes:w==null?void 0:w.slice(),fileType:Q,pathName:n||C,chunked:t!==void 0,chunkedLength:E,postDecode:i?YQ(i):void 0},{onStatus:y}),k=A??new P;k.initialize(M),s==null||s(k)}).catch(async h=>{await r(h),this.manager.itemError(n??""),o==null||o(h)}).finally(()=>{this.manager.itemEnd(n??"")})}async loadInternalAsync({splats:A,url:I,fileBytes:g,fileType:Q,fileName:C,stream:t,streamLength:E,postDecode:i,onProgress:s}){return new Promise((D,o)=>{this.loadInternal({splats:A,url:I,fileBytes:g,fileType:Q,fileName:C,stream:t,streamLength:E,postDecode:i,onLoad:D,onProgress:s,onError:o})})}}const HQ=Object.freeze(Object.defineProperty({__proto__:null,SplatLoader:xI},Symbol.toStringTag,{value:"Module"}));exports.GaussianSplatRenderer=fA;exports.SplatAccumulator=K;exports.SplatEdit=oA;exports.SplatEditRgbaBlendMode=tI;exports.SplatEditSdf=sI;exports.SplatEditSdfType=iI;exports.SplatEdits=q;exports.SplatFileType=bA;exports.SplatLoader=xI;exports.SplatMesh=sA;exports.Splats=P;exports.defines=yg;exports.fromHalf=p;exports.postDecode=fQ;exports.toHalf=u;exports.utils=kg;
|
|
838
838
|
//# sourceMappingURL=gaussian-splat-lite.min.cjs.map
|