Use vite-plugin-dts

This commit is contained in:
Dylan Hu authored and Diego Marcos committed 2025-05-29 10:41:20 -07:00
1 parent ed97485144
commit 72bfeba345
55 files changed
+11262 -7969

No files matched your search

+966 -114
View File
File diff suppressed because it is too large. Load diff
+64 -64
View File
@@ -1,7 +1,7 @@
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("three");var wI=typeof document<"u"?document.currentScript:null;function Vt(Q){const A=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(Q){for(const I in Q)if(I!=="default"){const g=Object.getOwnPropertyDescriptor(Q,I);Object.defineProperty(A,I,g.get?g:{enumerable:!0,get:()=>Q[I]})}}return A.default=Q,Object.freeze(A)}const e=Vt(j);let aA;function Tt(Q){const A=aA.__externref_table_alloc();return aA.__wbindgen_export_2.set(A,Q),A}function vt(Q,A){try{return Q.apply(this,A)}catch(I){const g=Tt(I);aA.__wbindgen_exn_store(g)}}function lI(Q){const A=typeof Q;if(A=="number"||A=="boolean"||Q==null)return`${Q}`;if(A=="string")return`"${Q}"`;if(A=="symbol"){const B=Q.description;return B==null?"Symbol":`Symbol(${B})`}if(A=="function"){const B=Q.name;return typeof B=="string"&&B.length>0?`Function(${B})`:"Function"}if(Array.isArray(Q)){const B=Q.length;let C="[";B>0&&(C+=lI(Q[0]));for(let E=1;E<B;E++)C+=", "+lI(Q[E]);return C+="]",C}const I=/\[object ([^\]]+)\]/.exec(toString.call(Q));let g;if(I&&I.length>1)g=I[1];else return toString.call(Q);if(g=="Object")try{return"Object("+JSON.stringify(Q)+")"}catch{return"Object"}return Q instanceof Error?`${Q.name}: ${Q.message}
${Q.stack}`:g}let MI=0,MQ=null;function OQ(){return(MQ===null||MQ.byteLength===0)&&(MQ=new Uint8Array(aA.memory.buffer)),MQ}const PQ=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Xt=typeof PQ.encodeInto=="function"?function(Q,A){return PQ.encodeInto(Q,A)}:function(Q,A){const I=PQ.encode(Q);return A.set(I),{read:Q.length,written:I.length}};function jt(Q,A,I){if(I===void 0){const t=PQ.encode(Q),s=A(t.length,1)>>>0;return OQ().subarray(s,s+t.length).set(t),MI=t.length,s}let g=Q.length,B=A(g,1)>>>0;const C=OQ();let E=0;for(;E<g;E++){const t=Q.charCodeAt(E);if(t>127)break;C[B+E]=t}if(E!==g){E!==0&&(Q=Q.slice(E)),B=I(B,g,g=E+Q.length*3,1)>>>0;const t=OQ().subarray(B+E,B+g),s=Xt(Q,t);E+=s.written,B=I(B,g,E,1)>>>0}return MI=E,B}let AQ=null;function qI(){return(AQ===null||AQ.buffer.detached===!0||AQ.buffer.detached===void 0&&AQ.buffer!==aA.memory.buffer)&&(AQ=new DataView(aA.memory.buffer)),AQ}const _I=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&_I.decode();function WI(Q,A){return Q=Q>>>0,_I.decode(OQ().subarray(Q,Q+A))}function zt(Q,A,I,g,B,C,E,t,s,o,a){return aA.raycast_splats(Q,A,I,g,B,C,E,t,s,o,a)}async function Ot(Q,A){if(typeof Response=="function"&&Q instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(Q,A)}catch(g){if(Q.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",g);else throw g}const I=await Q.arrayBuffer();return await WebAssembly.instantiate(I,A)}else{const I=await WebAssembly.instantiate(Q,A);return I instanceof WebAssembly.Instance?{instance:I,module:Q}:I}}function Pt(){const Q={};return Q.wbg={},Q.wbg.__wbg_buffer_09165b52af8c5237=function(A){return A.buffer},Q.wbg.__wbg_buffer_609cc3eee51ed158=function(A){return A.buffer},Q.wbg.__wbg_get_b9b93047fe3cf45b=function(A,I){return A[I>>>0]},Q.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9=function(A){let I;try{I=A instanceof Uint8Array}catch{I=!1}return I},Q.wbg.__wbg_length_3b4f022188ae8db6=function(A){return A.length},Q.wbg.__wbg_length_6ca527665d89694d=function(A){return A.length},Q.wbg.__wbg_length_8cfd2c6409af88ad=function(A){return A.length},Q.wbg.__wbg_length_a446193dc22c12f8=function(A){return A.length},Q.wbg.__wbg_length_e2d2a49132c1b256=function(A){return A.length},Q.wbg.__wbg_new_405e22f390576ce2=function(){return new Object},Q.wbg.__wbg_new_9fee97a409b32b68=function(A){return new Uint16Array(A)},Q.wbg.__wbg_new_a12002a7f91c75be=function(A){return new Uint8Array(A)},Q.wbg.__wbg_new_e3b321dcfef89fc7=function(A){return new Uint32Array(A)},Q.wbg.__wbg_newwithbyteoffsetandlength_e6b7e69acd4c7354=function(A,I,g){return new Float32Array(A,I>>>0,g>>>0)},Q.wbg.__wbg_newwithbyteoffsetandlength_f1dead44d1fc7212=function(A,I,g){return new Uint32Array(A,I>>>0,g>>>0)},Q.wbg.__wbg_newwithlength_5a5efe313cfd59f1=function(A){return new Float32Array(A>>>0)},Q.wbg.__wbg_newwithlength_bd3de93688d68fbc=function(A){return new Uint32Array(A>>>0)},Q.wbg.__wbg_set_10bad9bee0e9c58b=function(A,I,g){A.set(I,g>>>0)},Q.wbg.__wbg_set_65595bdd868b3009=function(A,I,g){A.set(I,g>>>0)},Q.wbg.__wbg_set_bb8cecf6a62b9f46=function(){return vt(function(A,I,g){return Reflect.set(A,I,g)},arguments)},Q.wbg.__wbg_set_d23661d19148b229=function(A,I,g){A.set(I,g>>>0)},Q.wbg.__wbg_set_f4f1f0daa30696fc=function(A,I,g){A.set(I,g>>>0)},Q.wbg.__wbg_subarray_3aaeec89bb2544f0=function(A,I,g){return A.subarray(I>>>0,g>>>0)},Q.wbg.__wbg_subarray_769e1e0f81bb259b=function(A,I,g){return A.subarray(I>>>0,g>>>0)},Q.wbg.__wbindgen_debug_string=function(A,I){const g=lI(I),B=jt(g,aA.__wbindgen_malloc,aA.__wbindgen_realloc),C=MI;qI().setInt32(A+4*1,C,!0),qI().setInt32(A+4*0,B,!0)},Q.wbg.__wbindgen_init_externref_table=function(){const A=aA.__wbindgen_export_2,I=A.grow(4);A.set(0,void 0),A.set(I+0,void 0),A.set(I+1,null),A.set(I+2,!0),A.set(I+3,!1)},Q.wbg.__wbindgen_memory=function(){return aA.memory},Q.wbg.__wbindgen_number_new=function(A){return A},Q.wbg.__wbindgen_string_new=function(A,I){return WI(A,I)},Q.wbg.__wbindgen_throw=function(A,I){throw new Error(WI(A,I))},Q}function _t(Q,A){return aA=Q.exports,$I.__wbindgen_wasm_module=A,AQ=null,MQ=null,aA.__wbindgen_start(),aA}async function $I(Q){if(aA!==void 0)return aA;typeof Q<"u"&&(Object.getPrototypeOf(Q)===Object.prototype?{module_or_path:Q}=Q:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof Q>"u"&&(Q=new URL("data:application/wasm;base64,AGFzbQEAAAABtgItYAJ/fwF/YAJ/fwBgA39/fwF/YAF/AGABfwF/YAN/f38AYAV/f39/fwBgBH9/f38AYAFvAX9gAW8Bb2ADb39/AW9gBX9/f39/AX9gA29vfwBgAABgA39+fgBgA39+fgF/YAd/f39/f39/AX9gBn9/f39/fwBgAX0BfWAEf39/fwF/YAABb2ABfwFvYAZ/f39/f Line truncated
`).map(E=>{const t=E.trimEnd();return A?t:t.length>0?(A=!0,t):null}).filter(E=>E!=null);for(;I.length>0&&I[I.length-1].length===0;)I.pop();if(I.length===0)return[];const g=(C=I[0].match(/^\s*/))==null?void 0:C[0];if(!g)return I;const B=new RegExp(`^${g}`);return I.map(E=>E.replace(B,""))}function gA(Q){return dA(Q).join(`
`)}class N extends f{constructor({a:A,outKey:I,outTypeFunc:g}){const B={a:p(A)},C=g(p(A)),E={[I]:C};super({inTypes:B,outTypes:E,inputs:{a:A}}),this.outKey=I}dynoOut(){return new H(this,this.outKey)}}class b extends f{constructor({a:A,b:I,outKey:g,outTypeFunc:B}){const C={a:p(A),b:p(I)},E=B(p(A),p(I)),t={[g]:E};super({inTypes:C,outTypes:t,inputs:{a:A,b:I}}),this.outKey=g}dynoOut(){return new H(this,this.outKey)}}class oQ extends f{constructor({a:A,b:I,c:g,outKey:B,outTypeFunc:C}){const E={a:p(A),b:p(I),c:p(g)},t=C(p(A),p(I),p(g)),s={[B]:t};super({inTypes:E,outTypes:s,inputs:{a:A,b:I,c:g}}),this.outKey=B}dynoOut(){return new H(this,this.outKey)}}const T={type:"Gsplat"},ZQ={type:"PackedSplats"},ii=Q=>new ig({packedSplats:Q}),UQ=(Q,A)=>new og({packedSplats:Q,index:A}),tg=(Q,A,I,g)=>new ag({packedSplats:Q,index:A,base:I,count:g}),FQ=Q=>new eg({gsplat:Q}),rQ=({gsplat:Q,flags:A,index:I,center:g,scales:B,quaternion:C,rgba:E,rgb:t,opacity:s,x:o,y:a,z:i,r:D,g:n,b:w})=>new Dg({gsplat:Q,flags:A,index:I,center:g,scales:B,quaternion:C,rgba:E,rgb:t,opacity:s,x:o,y:a,z:i,r:D,g:n,b:w}),si=Q=>new cg({gsplat:Q}),SI=(Q,{scale:A,rotate:I,translate:g,recolor:B})=>new wg({gsplat:Q,scale:A,rotate:I,translate:g,recolor:B}),hA=gA(`
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const CA=require("three");var pI=typeof document<"u"?document.currentScript:null;function $t(g){const A=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(g){for(const I in g)if(I!=="default"){const B=Object.getOwnPropertyDescriptor(g,I);Object.defineProperty(A,I,B.get?B:{enumerable:!0,get:()=>g[I]})}}return A.default=g,Object.freeze(A)}const a=$t(CA);let wA;function Ai(g){const A=wA.__externref_table_alloc();return wA.__wbindgen_export_2.set(A,g),A}function gi(g,A){try{return g.apply(this,A)}catch(I){const B=Ai(I);wA.__wbindgen_exn_store(B)}}function mI(g){const A=typeof g;if(A=="number"||A=="boolean"||g==null)return`${g}`;if(A=="string")return`"${g}"`;if(A=="symbol"){const Q=g.description;return Q==null?"Symbol":`Symbol(${Q})`}if(A=="function"){const Q=g.name;return typeof Q=="string"&&Q.length>0?`Function(${Q})`:"Function"}if(Array.isArray(g)){const Q=g.length;let C="[";Q>0&&(C+=mI(g[0]));for(let E=1;E<Q;E++)C+=", "+mI(g[E]);return C+="]",C}const I=/\[object ([^\]]+)\]/.exec(toString.call(g));let B;if(I&&I.length>1)B=I[1];else return toString.call(g);if(B=="Object")try{return"Object("+JSON.stringify(g)+")"}catch{return"Object"}return g instanceof Error?`${g.name}: ${g.message}
${g.stack}`:B}let fI=0,Mg=null;function AI(){return(Mg===null||Mg.byteLength===0)&&(Mg=new Uint8Array(wA.memory.buffer)),Mg}const gI=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Ii=typeof gI.encodeInto=="function"?function(g,A){return gI.encodeInto(g,A)}:function(g,A){const I=gI.encode(g);return A.set(I),{read:g.length,written:I.length}};function Bi(g,A,I){if(I===void 0){const t=gI.encode(g),i=A(t.length,1)>>>0;return AI().subarray(i,i+t.length).set(t),fI=t.length,i}let B=g.length,Q=A(B,1)>>>0;const C=AI();let E=0;for(;E<B;E++){const t=g.charCodeAt(E);if(t>127)break;C[Q+E]=t}if(E!==B){E!==0&&(g=g.slice(E)),Q=I(Q,B,B=E+g.length*3,1)>>>0;const t=AI().subarray(Q+E,Q+B),i=Ii(g,t);E+=i.written,Q=I(Q,B,E,1)>>>0}return fI=E,Q}let Ig=null;function AB(){return(Ig===null||Ig.buffer.detached===!0||Ig.buffer.detached===void 0&&Ig.buffer!==wA.memory.buffer)&&(Ig=new DataView(wA.memory.buffer)),Ig}const aB=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&aB.decode();function gB(g,A){return g=g>>>0,aB.decode(AI().subarray(g,g+A))}function Qi(g,A,I){return wA.decode_wlg(g,A,I)}function Ci(g,A,I,B,Q,C,E,t,i,e,n){return wA.raycast_splats(g,A,I,B,Q,C,E,t,i,e,n)}async function Ei(g,A){if(typeof Response=="function"&&g instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(g,A)}catch(B){if(g.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",B);else throw B}const I=await g.arrayBuffer();return await WebAssembly.instantiate(I,A)}else{const I=await WebAssembly.instantiate(g,A);return I instanceof WebAssembly.Instance?{instance:I,module:g}:I}}function ti(){const g={};return g.wbg={},g.wbg.__wbg_buffer_09165b52af8c5237=function(A){return A.buffer},g.wbg.__wbg_buffer_609cc3eee51ed158=function(A){return A.buffer},g.wbg.__wbg_get_b9b93047fe3cf45b=function(A,I){return A[I>>>0]},g.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9=function(A){let I;try{I=A instanceof Uint8Array}catch{I=!1}return I},g.wbg.__wbg_length_3b4f022188ae8db6=function(A){return A.length},g.wbg.__wbg_length_6ca527665d89694d=function(A){return A.length},g.wbg.__wbg_length_8cfd2c6409af88ad=function(A){return A.length},g.wbg.__wbg_length_a446193dc22c12f8=function(A){return A.length},g.wbg.__wbg_length_e2d2a49132c1b256=function(A){return A.length},g.wbg.__wbg_new_405e22f390576ce2=function(){return new Object},g.wbg.__wbg_new_9fee97a409b32b68=function(A){return new Uint16Array(A)},g.wbg.__wbg_new_a12002a7f91c75be=function(A){return new Uint8Array(A)},g.wbg.__wbg_new_e3b321dcfef89fc7=function(A){return new Uint32Array(A)},g.wbg.__wbg_newwithbyteoffsetandlength_e6b7e69acd4c7354=function(A,I,B){return new Float32Array(A,I>>>0,B>>>0)},g.wbg.__wbg_newwithbyteoffsetandlength_f1dead44d1fc7212=function(A,I,B){return new Uint32Array(A,I>>>0,B>>>0)},g.wbg.__wbg_newwithlength_5a5efe313cfd59f1=function(A){return new Float32Array(A>>>0)},g.wbg.__wbg_newwithlength_bd3de93688d68fbc=function(A){return new Uint32Array(A>>>0)},g.wbg.__wbg_set_10bad9bee0e9c58b=function(A,I,B){A.set(I,B>>>0)},g.wbg.__wbg_set_65595bdd868b3009=function(A,I,B){A.set(I,B>>>0)},g.wbg.__wbg_set_bb8cecf6a62b9f46=function(){return gi(function(A,I,B){return Reflect.set(A,I,B)},arguments)},g.wbg.__wbg_set_d23661d19148b229=function(A,I,B){A.set(I,B>>>0)},g.wbg.__wbg_set_f4f1f0daa30696fc=function(A,I,B){A.set(I,B>>>0)},g.wbg.__wbg_subarray_3aaeec89bb2544f0=function(A,I,B){return A.subarray(I>>>0,B>>>0)},g.wbg.__wbg_subarray_769e1e0f81bb259b=function(A,I,B){return A.subarray(I>>>0,B>>>0)},g.wbg.__wbindgen_debug_string=function(A,I){const B=mI(I),Q=Bi(B,wA.__wbindgen_malloc,wA.__wbindgen_realloc),C=fI;AB().setInt32(A+4*1,C,!0),AB().setInt32(A+4*0,Q,!0)},g.wbg.__wbindgen_init_externref_table=function(){const A=wA.__wbindgen_export_2,I=A.grow(4);A.set(0,void 0),A.set(I+0,void 0),A.set(I+1,null),A.set(I+2,!0),A.set(I+3,!1)},g.wbg.__wbindgen_memory=function(){return wA.memory},g.wbg.__wbindgen_number_new=function(A){return A},g.wbg.__wbindgen_string_new=function(A,I){return gB(A,I)},g.wbg.__wbindgen_throw=function(A,I){throw new Error(gB(A,I))},g}function ii(g,A){return wA=g.exports,ZI.__wbindgen_wasm_module=A,Ig=null,Mg=null,wA.__wbindgen_start(),wA}async function ZI(g){if(wA!==void 0)return wA;typeof g<"u"&&(Object.getPrototypeOf(g)===Object.prototype?{module_or_path:g}=g:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof g>"u"&&(g=new URL("data:application/wasm;base64,AGFzbQEAAAABtgItYAJ/fwF/YAJ/fwBgA39/fwF/YAF/AGABfwF/YAN/f38AYAV/f39/fwBgBH9/f38AYAFvAX9gAW8Bb2ADb39/AW9gBX9/f39/AX9gA29vfwBgAABgA39+fgBgA39+fgF/YAd/f39/f39/AX9gBn Line truncated
`).map(E=>{const t=E.trimEnd();return A?t:t.length>0?(A=!0,t):null}).filter(E=>E!=null);for(;I.length>0&&I[I.length-1].length===0;)I.pop();if(I.length===0)return[];const B=(C=I[0].match(/^\s*/))==null?void 0:C[0];if(!B)return I;const Q=new RegExp(`^${B}`);return I.map(E=>E.replace(Q,""))}function nA(g){return fA(g).join(`
`)}class R extends T{constructor({a:A,outKey:I,outTypeFunc:B}){const Q={a:v(A)},C=B(v(A)),E={[I]:C};super({inTypes:Q,outTypes:E,inputs:{a:A}}),this.outKey=I}dynoOut(){return new W(this,this.outKey)}}class O extends T{constructor({a:A,b:I,outKey:B,outTypeFunc:Q}){const C={a:v(A),b:v(I)},E=Q(v(A),v(I)),t={[B]:E};super({inTypes:C,outTypes:t,inputs:{a:A,b:I}}),this.outKey=B}dynoOut(){return new W(this,this.outKey)}}class ng extends T{constructor({a:A,b:I,c:B,outKey:Q,outTypeFunc:C}){const E={a:v(A),b:v(I),c:v(B)},t=C(v(A),v(I),v(B)),i={[Q]:t};super({inTypes:E,outTypes:i,inputs:{a:A,b:I,c:B}}),this.outKey=Q}dynoOut(){return new W(this,this.outKey)}}const BA={type:"Gsplat"},Vg={type:"PackedSplats"},wi=g=>new uB({packedSplats:g}),Sg=(g,A)=>new GB({packedSplats:g,index:A}),yB=(g,A,I,B)=>new MB({packedSplats:g,index:A,base:I,count:B}),kg=g=>new NB({gsplat:g}),lg=({gsplat:g,flags:A,index:I,center:B,scales:Q,quaternion:C,rgba:E,rgb:t,opacity:i,x:e,y:n,z:s,r:o,g:r,b:c})=>new pB({gsplat:g,flags:A,index:I,center:B,scales:Q,quaternion:C,rgba:E,rgb:t,opacity:i,x:e,y:n,z:s,r:o,g:r,b:c}),Di=g=>new FB({gsplat:g}),vI=(g,{scale:A,rotate:I,translate:B,recolor:Q})=>new RB({gsplat:g,scale:A,rotate:I,translate:B,recolor:Q}),kA=nA(`
struct Gsplat {
vec3 center;
uint flags;
@@ -15,12 +15,12 @@ ${Q.stack}`:g}let MI=0,MQ=null;function OQ(){return(MQ===null||MQ.byteLength===0
bool isGsplatActive(uint flags) {
return (flags & GSPLAT_FLAG_ACTIVE) != 0u;
}
`),eI=gA(`
`),rI=nA(`
struct PackedSplats {
usampler2DArray texture;
int numSplats;
};
`);class ig extends N{constructor({packedSplats:A}){super({a:A,outKey:"numSplats",outTypeFunc:()=>"int"}),this.statements=({inputs:I,outputs:g})=>[`${g.numSplats} = ${I.a}.numSplats;`]}}const sg=gA(`
`);class uB extends R{constructor({packedSplats:A}){super({a:A,outKey:"numSplats",outTypeFunc:()=>"int"}),this.statements=({inputs:I,outputs:B})=>[`${B.numSplats} = ${I.a}.numSplats;`]}}const dB=nA(`
bool readPackedSplat(usampler2DArray texture, int numSplats, int index, out Gsplat gsplat) {
if ((index >= 0) && (index < numSplats)) {
uvec4 packed = texelFetch(texture, splatTexCoord(index), 0);
@@ -30,22 +30,22 @@ ${Q.stack}`:g}let MI=0,MQ=null;function OQ(){return(MQ===null||MQ.byteLength===0
return false;
}
}
`);class og extends f{constructor({packedSplats:A,index:I}){super({inTypes:{packedSplats:ZQ,index:"int"},outTypes:{gsplat:T},inputs:{packedSplats:A,index:I},globals:()=>[hA,eI,sg],statements:({inputs:g,outputs:B})=>{const{gsplat:C}=B;if(!C)return[];const{packedSplats:E,index:t}=g;let s;return E&&t?s=dA(`
`);class GB extends T{constructor({packedSplats:A,index:I}){super({inTypes:{packedSplats:Vg,index:"int"},outTypes:{gsplat:BA},inputs:{packedSplats:A,index:I},globals:()=>[kA,rI,dB],statements:({inputs:B,outputs:Q})=>{const{gsplat:C}=Q;if(!C)return[];const{packedSplats:E,index:t}=B;let i;return E&&t?i=fA(`
if (readPackedSplat(${E}.texture, ${E}.numSplats, ${t}, ${C})) {
bool zeroSize = all(equal(${C}.scales, vec3(0.0, 0.0, 0.0)));
${C}.flags = zeroSize ? 0u : GSPLAT_FLAG_ACTIVE;
} else {
${C}.flags = 0u;
}
`):s=[`${C}.flags = 0u;`],s.push(`${C}.index = ${t??"0"};`),s}})}dynoOut(){return new H(this,"gsplat")}}class ag extends f{constructor({packedSplats:A,index:I,base:g,count:B}){super({inTypes:{packedSplats:ZQ,index:"int",base:"int",count:"int"},outTypes:{gsplat:T},inputs:{packedSplats:A,index:I,base:g,count:B},globals:()=>[hA,eI,sg],statements:({inputs:C,outputs:E})=>{const{gsplat:t}=E;if(!t)return[];const{packedSplats:s,index:o,base:a,count:i}=C;let D;return s&&o&&a&&i?D=dA(`
`):i=[`${C}.flags = 0u;`],i.push(`${C}.index = ${t??"0"};`),i}})}dynoOut(){return new W(this,"gsplat")}}class MB extends T{constructor({packedSplats:A,index:I,base:B,count:Q}){super({inTypes:{packedSplats:Vg,index:"int",base:"int",count:"int"},outTypes:{gsplat:BA},inputs:{packedSplats:A,index:I,base:B,count:Q},globals:()=>[kA,rI,dB],statements:({inputs:C,outputs:E})=>{const{gsplat:t}=E;if(!t)return[];const{packedSplats:i,index:e,base:n,count:s}=C;let o;return i&&e&&n&&s?o=fA(`
${t}.flags = 0u;
if ((${o} >= ${a}) && (${o} < (${a} + ${i}))) {
if (readPackedSplat(${s}.texture, ${s}.numSplats, ${o}, ${t})) {
if ((${e} >= ${n}) && (${e} < (${n} + ${s}))) {
if (readPackedSplat(${i}.texture, ${i}.numSplats, ${e}, ${t})) {
bool zeroSize = all(equal(${t}.scales, vec3(0.0, 0.0, 0.0)));
${t}.flags = zeroSize ? 0u : GSPLAT_FLAG_ACTIVE;
}
}
`):D=[`${t}.flags = 0u;`],D.push(`${t}.index = ${o??"0"};`),D}})}dynoOut(){return new H(this,"gsplat")}}class eg extends f{constructor({gsplat:A}){super({inTypes:{gsplat:T},outTypes:{flags:"uint",active:"bool",index:"int",center:"vec3",scales:"vec3",quaternion:"vec4",rgba:"vec4",rgb:"vec3",opacity:"float",x:"float",y:"float",z:"float",r:"float",g:"float",b:"float"},inputs:{gsplat:A},globals:()=>[hA],statements:({inputs:I,outputs:g})=>{const{gsplat:B}=I,{flags:C,active:E,index:t,center:s,scales:o,quaternion:a,rgba:i,rgb:D,opacity:n,x:w,y:c,z:r,r:y,g:G,b:h}=g;return[C?`${C} = ${B?`${B}.flags`:"0u"};`:null,E?`${E} = isGsplatActive(${B?`${B}.flags`:"0u"});`:null,t?`${t} = ${B?`${B}.index`:"0"};`:null,s?`${s} = ${B?`${B}.center`:"vec3(0.0, 0.0, 0.0)"};`:null,o?`${o} = ${B?`${B}.scales`:"vec3(0.0, 0.0, 0.0)"};`:null,a?`${a} = ${B?`${B}.quaternion`:"vec4(0.0, 0.0, 0.0, 1.0)"};`:null,i?`${i} = ${B?`${B}.rgba`:"vec4(0.0, 0.0, 0.0, 0.0)"};`:null,D?`${D} = ${B?`${B}.rgba.rgb`:"vec3(0.0, 0.0, 0.0)"};`:null,n?`${n} = ${B?`${B}.rgba.a`:"0.0"};`:null,w?`${w} = ${B?`${B}.center.x`:"0.0"};`:null,c?`${c} = ${B?`${B}.center.y`:"0.0"};`:null,r?`${r} = ${B?`${B}.center.z`:"0.0"};`:null,y?`${y} = ${B?`${B}.rgba.r`:"0.0"};`:null,G?`${G} = ${B?`${B}.rgba.g`:"0.0"};`:null,h?`${h} = ${B?`${B}.rgba.b`:"0.0"};`:null].filter(Boolean)}})}}class Dg extends f{constructor({gsplat:A,flags:I,index:g,center:B,scales:C,quaternion:E,rgba:t,rgb:s,opacity:o,x:a,y:i,z:D,r:n,g:w,b:c}){super({inTypes:{gsplat:T,flags:"uint",index:"int",center:"vec3",scales:"vec3",quaternion:"vec4",rgba:"vec4",rgb:"vec3",opacity:"float",x:"float",y:"float",z:"float",r:"float",g:"float",b:"float"},outTypes:{gsplat:T},inputs:{gsplat:A,flags:I,index:g,center:B,scales:C,quaternion:E,rgba:t,rgb:s,opacity:o,x:a,y:i,z:D,r:n,g:w,b:c},globals:()=>[hA],statements:({inputs:r,outputs:y})=>{const{gsplat:G}=y;if(!G)return[];const{gsplat:h,flags:M,index:l,center:k,scales:R,quaternion:d,rgba:Y,rgb:m,opacity:J,x,y:U,z:S,r:v,g:V,b:_}=r;return[`${G}.flags = ${M??(h?`${h}.flags`:"0u")};`,`${G}.index = ${l??(h?`${h}.index`:"0")};`,`${G}.center = ${k??(h?`${h}.center`:"vec3(0.0, 0.0, 0.0)")};`,`${G}.scales = ${R??(h?`${h}.scales`:"vec3(0.0, 0.0, 0.0)")};`,`${G}.quaternion = ${d??(h?`${h}.quaternion`:"vec4(0.0, 0.0, 0.0, 1.0)")};`,`${G}.rgba = ${Y??(h?`${h}.rgba`:"vec4(0.0, 0.0, 0.0, 0.0)")};`,m?`${G}.rgba.rgb = ${m};`:null,J?`${G}.rgba.a = ${J};`:null,x?`${G}.center.x = ${x};`:null,U?`${G}.center.y = ${U};`:null,S?`${G}.center.z = ${S};`:null,v?`${G}.rgba.r = ${v};`:null,V?`${G}.rgba.g = ${V};`:null,_?`${G}.rgba.b = ${_};`:null].filter(Boolean)}})}dynoOut(){return new H(this,"gsplat")}}const ng=gA(`
`):o=[`${t}.flags = 0u;`],o.push(`${t}.index = ${e??"0"};`),o}})}dynoOut(){return new W(this,"gsplat")}}class NB extends T{constructor({gsplat:A}){super({inTypes:{gsplat:BA},outTypes:{flags:"uint",active:"bool",index:"int",center:"vec3",scales:"vec3",quaternion:"vec4",rgba:"vec4",rgb:"vec3",opacity:"float",x:"float",y:"float",z:"float",r:"float",g:"float",b:"float"},inputs:{gsplat:A},globals:()=>[kA],statements:({inputs:I,outputs:B})=>{const{gsplat:Q}=I,{flags:C,active:E,index:t,center:i,scales:e,quaternion:n,rgba:s,rgb:o,opacity:r,x:c,y:h,z:w,r:D,g:y,b:l}=B;return[C?`${C} = ${Q?`${Q}.flags`:"0u"};`:null,E?`${E} = isGsplatActive(${Q?`${Q}.flags`:"0u"});`:null,t?`${t} = ${Q?`${Q}.index`:"0"};`:null,i?`${i} = ${Q?`${Q}.center`:"vec3(0.0, 0.0, 0.0)"};`:null,e?`${e} = ${Q?`${Q}.scales`:"vec3(0.0, 0.0, 0.0)"};`:null,n?`${n} = ${Q?`${Q}.quaternion`:"vec4(0.0, 0.0, 0.0, 1.0)"};`:null,s?`${s} = ${Q?`${Q}.rgba`:"vec4(0.0, 0.0, 0.0, 0.0)"};`:null,o?`${o} = ${Q?`${Q}.rgba.rgb`:"vec3(0.0, 0.0, 0.0)"};`:null,r?`${r} = ${Q?`${Q}.rgba.a`:"0.0"};`:null,c?`${c} = ${Q?`${Q}.center.x`:"0.0"};`:null,h?`${h} = ${Q?`${Q}.center.y`:"0.0"};`:null,w?`${w} = ${Q?`${Q}.center.z`:"0.0"};`:null,D?`${D} = ${Q?`${Q}.rgba.r`:"0.0"};`:null,y?`${y} = ${Q?`${Q}.rgba.g`:"0.0"};`:null,l?`${l} = ${Q?`${Q}.rgba.b`:"0.0"};`:null].filter(Boolean)}})}}class pB extends T{constructor({gsplat:A,flags:I,index:B,center:Q,scales:C,quaternion:E,rgba:t,rgb:i,opacity:e,x:n,y:s,z:o,r,g:c,b:h}){super({inTypes:{gsplat:BA,flags:"uint",index:"int",center:"vec3",scales:"vec3",quaternion:"vec4",rgba:"vec4",rgb:"vec3",opacity:"float",x:"float",y:"float",z:"float",r:"float",g:"float",b:"float"},outTypes:{gsplat:BA},inputs:{gsplat:A,flags:I,index:B,center:Q,scales:C,quaternion:E,rgba:t,rgb:i,opacity:e,x:n,y:s,z:o,r,g:c,b:h},globals:()=>[kA],statements:({inputs:w,outputs:D})=>{const{gsplat:y}=D;if(!y)return[];const{gsplat:l,flags:d,index:u,center:p,scales:m,quaternion:M,rgba:G,rgb:J,opacity:k,x:N,y:Y,z:F,r:f,g:U,b:L}=w;return[`${y}.flags = ${d??(l?`${l}.flags`:"0u")};`,`${y}.index = ${u??(l?`${l}.index`:"0")};`,`${y}.center = ${p??(l?`${l}.center`:"vec3(0.0, 0.0, 0.0)")};`,`${y}.scales = ${m??(l?`${l}.scales`:"vec3(0.0, 0.0, 0.0)")};`,`${y}.quaternion = ${M??(l?`${l}.quaternion`:"vec4(0.0, 0.0, 0.0, 1.0)")};`,`${y}.rgba = ${G??(l?`${l}.rgba`:"vec4(0.0, 0.0, 0.0, 0.0)")};`,J?`${y}.rgba.rgb = ${J};`:null,k?`${y}.rgba.a = ${k};`:null,N?`${y}.center.x = ${N};`:null,Y?`${y}.center.y = ${Y};`:null,F?`${y}.center.z = ${F};`:null,f?`${y}.rgba.r = ${f};`:null,U?`${y}.rgba.g = ${U};`:null,L?`${y}.rgba.b = ${L};`:null].filter(Boolean)}})}dynoOut(){return new W(this,"gsplat")}}const kB=nA(`
vec3 gsplatNormal(vec3 scales, vec4 quaternion) {
float minScale = min(scales.x, min(scales.y, scales.z));
vec3 normal;
@@ -58,13 +58,13 @@ ${Q.stack}`:g}let MI=0,MQ=null;function OQ(){return(MQ===null||MQ.byteLength===0
}
return quatVec(quaternion, normal);
}
`);class cg extends N{constructor({gsplat:A}){super({a:A,outKey:"normal",outTypeFunc:()=>"vec3"}),this.globals=()=>[hA,ng],this.statements=({inputs:I,outputs:g})=>[`${g.normal} = gsplatNormal(${I.a}.scales, ${I.a}.quaternion);`]}}class wg extends f{constructor({gsplat:A,scale:I,rotate:g,translate:B,recolor:C}){super({inTypes:{gsplat:T,scale:"float",rotate:"vec4",translate:"vec3",recolor:"vec4"},outTypes:{gsplat:T},inputs:{gsplat:A,scale:I,rotate:g,translate:B,recolor:C},globals:()=>[hA],statements:({inputs:E,outputs:t,compile:s})=>{const{gsplat:o}=t;if(!o||!E.gsplat)return[];const{scale:a,rotate:i,translate:D,recolor:n}=E,w=s.indent;return[`${o} = ${E.gsplat};`,`if (isGsplatActive(${o}.flags)) {`,a?`${w}${o}.center *= ${a};`:null,i?`${w}${o}.center = quatVec(${i}, ${o}.center);`:null,D?`${w}${o}.center += ${D};`:null,a?`${w}${o}.scales *= ${a};`:null,i?`${w}${o}.quaternion = quatQuat(${i}, ${o}.quaternion);`:null,n?`${w}${o}.rgba *= ${n};`:null,"}"].filter(Boolean)}})}dynoOut(){return new H(this,"gsplat")}}const rg=Q=>new hg({gsplat:Q}),oi=Q=>new LI({rgba8:Q});class hg extends f{constructor({gsplat:A}){super({inTypes:{gsplat:T},inputs:{gsplat:A},globals:()=>[hA],statements:({inputs:I,outputs:g})=>{const{output:B}=g;if(!B)return[];const{gsplat:C}=I;return C?dA(`
`);class FB extends R{constructor({gsplat:A}){super({a:A,outKey:"normal",outTypeFunc:()=>"vec3"}),this.globals=()=>[kA,kB],this.statements=({inputs:I,outputs:B})=>[`${B.normal} = gsplatNormal(${I.a}.scales, ${I.a}.quaternion);`]}}class RB extends T{constructor({gsplat:A,scale:I,rotate:B,translate:Q,recolor:C}){super({inTypes:{gsplat:BA,scale:"float",rotate:"vec4",translate:"vec3",recolor:"vec4"},outTypes:{gsplat:BA},inputs:{gsplat:A,scale:I,rotate:B,translate:Q,recolor:C},globals:()=>[kA],statements:({inputs:E,outputs:t,compile:i})=>{const{gsplat:e}=t;if(!e||!E.gsplat)return[];const{scale:n,rotate:s,translate:o,recolor:r}=E,c=i.indent;return[`${e} = ${E.gsplat};`,`if (isGsplatActive(${e}.flags)) {`,n?`${c}${e}.center *= ${n};`:null,s?`${c}${e}.center = quatVec(${s}, ${e}.center);`:null,o?`${c}${e}.center += ${o};`:null,n?`${c}${e}.scales *= ${n};`:null,s?`${c}${e}.quaternion = quatQuat(${s}, ${e}.quaternion);`:null,r?`${c}${e}.rgba *= ${r};`:null,"}"].filter(Boolean)}})}dynoOut(){return new W(this,"gsplat")}}const JB=g=>new mB({gsplat:g}),li=g=>new WI({rgba8:g});class mB extends T{constructor({gsplat:A}){super({inTypes:{gsplat:BA},inputs:{gsplat:A},globals:()=>[kA],statements:({inputs:I,outputs:B})=>{const{output:Q}=B;if(!Q)return[];const{gsplat:C}=I;return C?fA(`
if (isGsplatActive(${C}.flags)) {
${B} = packSplat(${C}.center, ${C}.scales, ${C}.quaternion, ${C}.rgba);
${Q} = packSplat(${C}.center, ${C}.scales, ${C}.quaternion, ${C}.rgba);
} else {
${B} = uvec4(0u, 0u, 0u, 0u);
${Q} = uvec4(0u, 0u, 0u, 0u);
}
`):[`${B} = uvec4(0u, 0u, 0u, 0u);`]}})}dynoOut(){return new H(this,"output")}}class LI extends f{constructor({rgba8:A}){super({inTypes:{rgba8:"vec4"},inputs:{rgba8:A},statements:({inputs:I,outputs:g})=>[`target = ${I.rgba8??"vec4(0.0, 0.0, 0.0, 0.0)"};`]})}dynoOut(){return new H(this,"rgba8")}}const ai=(Q,A,I)=>new F({key:Q,type:A,value:I}),ei=(Q=!1,A)=>new gI({key:A,value:Q}),Di=(Q=0,A)=>new yg({key:A,value:Q}),ni=(Q=0,A)=>new SQ({key:A,value:Q}),pA=(Q=0,A)=>new EQ({key:A,value:Q}),ci=(Q,A)=>new Gg({key:A,value:Q}),wi=(Q,A)=>new lg({key:A,value:Q}),ri=(Q,A)=>new Mg({key:A,value:Q}),hi=(Q,A)=>new Ng({key:A,value:Q}),yi=(Q,A)=>new kg({key:A,value:Q}),Gi=(Q,A)=>new Fg({key:A,value:Q}),li=(Q,A)=>new Rg({key:A,value:Q}),vA=(Q,A)=>new hQ({key:A,value:Q}),Mi=(Q,A)=>new Jg({key:A,value:Q}),Ni=(Q,A)=>new dg({key:A,value:Q}),ki=(Q,A)=>new Yg({key:A,value:Q}),Fi=(Q,A)=>new qQ({key:A,value:Q}),Ri=(Q,A)=>new ug({key:A,value:Q}),Ji=(Q,A)=>new Ug({key:A,value:Q}),di=(Q,A)=>new Sg({key:A,value:Q}),Yi=(Q,A)=>new Lg({key:A,value:Q}),ui=(Q,A)=>new pg({key:A,value:Q}),Ui=(Q,A)=>new Hg({key:A,value:Q}),Si=(Q,A)=>new fg({key:A,value:Q}),Li=(Q,A)=>new mg({key:A,value:Q}),pi=(Q,A)=>new bg({key:A,value:Q}),Hi=(Q,A)=>new xg({key:A,value:Q}),fi=(Q,A)=>new Kg({key:A,value:Q}),mi=(Q,A)=>new Zg({key:A,value:Q}),bi=(Q,A)=>new qg({key:A,value:Q}),xi=(Q,A)=>new Wg({key:A,value:Q}),Ki=(Q,A)=>new Vg({key:A,value:Q}),Zi=(Q,A)=>new RQ({key:A,value:Q}),qi=(Q,A)=>new Tg({key:Q,value:A}),Wi=(Q,A)=>new vg({key:A,value:Q}),Vi=(Q,A)=>new Xg({key:A,value:Q}),Ti=(Q,A)=>new jg({key:A,value:Q}),vi=(Q,A)=>new zg({key:A,value:Q}),Xi=(Q,A)=>new Og({key:A,value:Q}),ji=(Q,A)=>new Pg({key:A,value:Q}),zi=(Q,A)=>new _g({key:A,value:Q}),Oi=(Q,A)=>new $g({key:A,value:Q}),Pi=(Q,A)=>new AB({key:A,value:Q}),_i=(Q,A)=>new QB({key:A,value:Q});class F extends f{constructor({key:A,type:I,count:g,value:B,update:C,globals:E}){A=A??"value",super({outTypes:{[A]:I},update:()=>{if(C){const t=C(this.value);t!==void 0&&(this.value=t)}this.uniform.value=this.value},generate:({inputs:t,outputs:s})=>{const o=(E==null?void 0:E({inputs:t,outputs:s}))??[],a={},i=s[A];return i&&(o.push(`uniform ${UI(i,I,g)};`),a[i]=this.uniform),{globals:o,uniforms:a}}}),this.type=I,this.count=g,this.value=B,this.uniform={value:B},this.outKey=A}dynoOut(){return new H(this,this.outKey)}}class gI extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"bool",value:I,update:g})}}class yg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"uint",value:I,update:g})}}class SQ extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"int",value:I,update:g})}}class EQ extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"float",value:I,update:g})}}class Gg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"bvec2",value:I,update:g})}}class lg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"uvec2",value:I,update:g})}}class Mg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"ivec2",value:I,update:g})}}class Ng extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"vec2",value:I,update:g})}}class kg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"bvec3",value:I,update:g})}}class Fg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"uvec3",value:I,update:g})}}class Rg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"ivec3",value:I,update:g})}}class hQ extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"vec3",value:I,update:g})}}class Jg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"bvec4",value:I,update:g})}}class dg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"uvec4",value:I,update:g})}}class Yg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"ivec4",value:I,update:g})}}class qQ extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"vec4",value:I,update:g})}}class ug extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat2",value:I,update:g})}}class Ug extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat2x2",value:I,update:g})}}class Sg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat2x3",value:I,update:g})}}class Lg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat2x4",value:I,update:g})}}class pg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat3",value:I,update:g})}}class Hg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat3x2",value:I,update:g})}}class fg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat3x3",value:I,update:g})}}class mg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat3x4",value:I,update:g})}}class bg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat4",value:I,update:g})}}class xg extends F{constructor({key:A,value:I,update:g}){super({key:A,type:"mat4x2" Line truncated
`):[`${Q} = uvec4(0u, 0u, 0u, 0u);`]}})}dynoOut(){return new W(this,"output")}}class WI extends T{constructor({rgba8:A}){super({inTypes:{rgba8:"vec4"},inputs:{rgba8:A},statements:({inputs:I,outputs:B})=>[`target = ${I.rgba8??"vec4(0.0, 0.0, 0.0, 0.0)"};`]})}dynoOut(){return new W(this,"rgba8")}}const yi=(g,A,I)=>new S({key:g,type:A,value:I}),ui=(g=!1,A)=>new tI({key:A,value:g}),di=(g=0,A)=>new fB({key:A,value:g}),Gi=(g=0,A)=>new Yg({key:A,value:g}),HA=(g=0,A)=>new ig({key:A,value:g}),Mi=(g,A)=>new SB({key:A,value:g}),Ni=(g,A)=>new YB({key:A,value:g}),pi=(g,A)=>new UB({key:A,value:g}),ki=(g,A)=>new xB({key:A,value:g}),Fi=(g,A)=>new LB({key:A,value:g}),Ri=(g,A)=>new bB({key:A,value:g}),Ji=(g,A)=>new HB({key:A,value:g}),OA=(g,A)=>new yg({key:A,value:g}),mi=(g,A)=>new KB({key:A,value:g}),fi=(g,A)=>new ZB({key:A,value:g}),Si=(g,A)=>new qB({key:A,value:g}),Yi=(g,A)=>new Tg({key:A,value:g}),Ui=(g,A)=>new vB({key:A,value:g}),xi=(g,A)=>new WB({key:A,value:g}),Li=(g,A)=>new VB({key:A,value:g}),bi=(g,A)=>new TB({key:A,value:g}),Hi=(g,A)=>new XB({key:A,value:g}),Ki=(g,A)=>new zB({key:A,value:g}),Zi=(g,A)=>new jB({key:A,value:g}),qi=(g,A)=>new OB({key:A,value:g}),vi=(g,A)=>new PB({key:A,value:g}),Wi=(g,A)=>new _B({key:A,value:g}),Vi=(g,A)=>new $B({key:A,value:g}),Ti=(g,A)=>new AQ({key:A,value:g}),Xi=(g,A)=>new gQ({key:A,value:g}),zi=(g,A)=>new IQ({key:A,value:g}),ji=(g,A)=>new BQ({key:A,value:g}),Oi=(g,A)=>new Fg({key:A,value:g}),Pi=(g,A)=>new QQ({key:g,value:A}),_i=(g,A)=>new CQ({key:A,value:g}),$i=(g,A)=>new EQ({key:A,value:g}),As=(g,A)=>new tQ({key:A,value:g}),gs=(g,A)=>new iQ({key:A,value:g}),Is=(g,A)=>new sQ({key:A,value:g}),Bs=(g,A)=>new eQ({key:A,value:g}),Qs=(g,A)=>new aQ({key:A,value:g}),Cs=(g,A)=>new nQ({key:A,value:g}),Es=(g,A)=>new oQ({key:A,value:g}),ts=(g,A)=>new rQ({key:A,value:g});class S extends T{constructor({key:A,type:I,count:B,value:Q,update:C,globals:E}){A=A??"value",super({outTypes:{[A]:I},update:()=>{if(C){const t=C(this.value);t!==void 0&&(this.value=t)}this.uniform.value=this.value},generate:({inputs:t,outputs:i})=>{const e=(E==null?void 0:E({inputs:t,outputs:i}))??[],n={},s=i[A];return s&&(e.push(`uniform ${qI(s,I,B)};`),n[s]=this.uniform),{globals:e,uniforms:n}}}),this.type=I,this.count=B,this.value=Q,this.uniform={value:Q},this.outKey=A}dynoOut(){return new W(this,this.outKey)}}class tI extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"bool",value:I,update:B})}}class fB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"uint",value:I,update:B})}}class Yg extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"int",value:I,update:B})}}class ig extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"float",value:I,update:B})}}class SB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"bvec2",value:I,update:B})}}class YB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"uvec2",value:I,update:B})}}class UB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"ivec2",value:I,update:B})}}class xB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"vec2",value:I,update:B})}}class LB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"bvec3",value:I,update:B})}}class bB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"uvec3",value:I,update:B})}}class HB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"ivec3",value:I,update:B})}}class yg extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"vec3",value:I,update:B})}}class KB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"bvec4",value:I,update:B})}}class ZB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"uvec4",value:I,update:B})}}class qB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"ivec4",value:I,update:B})}}class Tg extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"vec4",value:I,update:B})}}class vB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat2",value:I,update:B})}}class WB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat2x2",value:I,update:B})}}class VB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat2x3",value:I,update:B})}}class TB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat2x4",value:I,update:B})}}class XB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat3",value:I,update:B})}}class zB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat3x2",value:I,update:B})}}class jB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat3x3",value:I,update:B})}}class OB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat3x4",value:I,update:B})}}class PB extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat4",value:I,update:B})}}class _B extends S{constructor({key:A,value:I,update:B}){super({key:A,type:"mat4x2" Line truncated
precision highp float;
in vec3 position;
@@ -72,19 +72,19 @@ ${Q.stack}`:g}let MI=0,MQ=null;function OQ(){return(MQ===null||MQ.byteLength===0
void main() {
gl_Position = vec4(position.xy, 0.0, 1.0);
}
`);function lB(Q){const A=new e.Vector3;for(const I of Q)A.add(I);return A.divideScalar(Q.length)}function MB(Q){if(Q.length===0)return new e.Quaternion;const A=Q[0].clone();for(let I=1;I<Q.length;I++)Q[I].dot(Q[0])<0?(A.x-=Q[I].x,A.y-=Q[I].y,A.z-=Q[I].z,A.w-=Q[I].w):(A.x+=Q[I].x,A.y+=Q[I].y,A.z+=Q[I].z,A.w+=Q[I].w);return A.normalize()}function NB(Q,A){const I=new e.Vector3(0,0,0).applyMatrix4(Q),g=new e.Vector3(0,0,0).applyMatrix4(A),B=new e.Vector3(0,0,-1).applyMatrix4(Q).sub(I).normalize(),C=new e.Vector3(0,0,-1).applyMatrix4(A).sub(g).normalize(),E=I.distanceTo(g),t=B.dot(C);return{distance:E,coincidence:t}}function Ys({matrix1:Q,matrix2:A,maxDistance:I}){const g=new e.Vector3(0,0,0).applyMatrix4(Q),B=new e.Vector3(0,0,0).applyMatrix4(A);return g.distanceTo(B)<=I}function us({matrix1:Q,matrix2:A,maxDistance:I,minCoincidence:g}){const{distance:B,coincidence:C}=NB(Q,A);return B<=I&&(g==null||C>=g)}function kB(Q,A){const[I,g]=[new e.Vector3,new e.Quaternion],[B,C]=[new e.Vector3,new e.Quaternion];Q.decompose(I,g,new e.Vector3),A.decompose(B,C,new e.Vector3);const E=I.distanceTo(B),t=Math.abs(g.dot(C));return{distance:E,coorient:t}}function EI({matrix1:Q,matrix2:A,maxDistance:I,minCoorient:g}){const{distance:B,coorient:C}=kB(Q,A);return B<=I&&(g==null||C>=g)}function Us(Q,A=.001){return Math.abs(Q)<A?0:Math.sign(Q)}function Ss(Q){const A=Q.w<0,I=dQ(A?-Q.x:Q.x),g=dQ(A?-Q.y:Q.y),B=dQ(A?-Q.z:Q.z),C=I&255,E=g&255,t=B&255;return C|E<<8|t<<16}function Ls(Q,A){const I=Q<<24>>24,g=Q<<16>>24,B=Q<<8>>24;A.set(I/127,g/127,B/127,0);const C=A.x*A.x+A.y*A.y+A.z*A.z;return A.w=Math.sqrt(Math.max(0,1-C)),A}function pI(Q){const A=Q.clone().normalize();A.w<0&&A.set(-A.x,-A.y,-A.z,-A.w);const I=2*Math.acos(A.w),g=Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z),B=g<1e-6?new e.Vector3(1,0,0):new e.Vector3(A.x,A.y,A.z).divideScalar(g),C=Math.abs(B.x)+Math.abs(B.y)+Math.abs(B.z);let E=B.x/C,t=B.y/C;if(B.z<0){const n=E;E=(1-Math.abs(t))*(E>=0?1:-1),t=(1-Math.abs(n))*(t>=0?1:-1)}const s=E*.5+.5,o=t*.5+.5,a=Math.round(s*255),i=Math.round(o*255);return Math.round(I*(255/Math.PI))<<16|i<<8|a}function FB(Q,A){const I=Q&255,g=Q>>>8&255,B=Q>>>16&255,C=I/255,E=g/255;let t=(C-.5)*2,s=(E-.5)*2;const o=1-(Math.abs(t)+Math.abs(s)),a=Math.max(-o,0);t+=t>=0?-a:a,s+=s>=0?-a:a;const i=new e.Vector3(t,s,o).normalize(),n=B/255*Math.PI*.5,w=Math.sin(n),c=Math.cos(n);return A.set(i.x*w,i.y*w,i.z*w,c),A}function ps(Q){const A=Q.clone().normalize(),I=2*(A.w*A.x+A.y*A.z),g=1-2*(A.x*A.x+A.y*A.y),B=Math.atan2(I,g),C=2*(A.w*A.y-A.z*A.x),E=Math.abs(C)>=1?Math.sign(C)*(Math.PI/2):Math.asin(C),t=2*(A.w*A.z+A.x*A.y),s=1-2*(A.y*A.y+A.z*A.z),o=Math.atan2(t,s),a=(B+Math.PI)/(2*Math.PI),i=(E+Math.PI)/(2*Math.PI),D=(o+Math.PI)/(2*Math.PI),n=Math.round(a*255),w=Math.round(i*255);return Math.round(D*255)<<16|w<<8|n}function Hs(Q,A){const I=Q&255,g=Q>>>8&255,B=Q>>>16&255,C=I/255,E=g/255,t=B/255,s=C*(2*Math.PI)-Math.PI,o=E*(2*Math.PI)-Math.PI,a=t*(2*Math.PI)-Math.PI,i=Math.cos(s*.5),D=Math.sin(s*.5),n=Math.cos(o*.5),w=Math.sin(o*.5),c=Math.cos(a*.5),r=Math.sin(a*.5);return A.w=i*n*c+D*w*r,A.x=D*n*c-i*w*r,A.y=i*w*c+D*n*r,A.z=i*n*r-D*w*c,A.normalize(),A}function vQ(Q,A,I,g){const B=Math.max(-127,Math.min(127,Q*127)),C=Math.max(-127,Math.min(127,A*127)),E=Math.max(-127,Math.min(127,I*127)),t=Math.max(-127,Math.min(127,g*127));return B&255|(C&255)<<8|(E&255)<<16|(t&255)<<24}function fs(Q,A,I){const g=A*2;for(let B=0;B<9;++B){const C=Math.max(-63,Math.min(63,I[B]*63))&127,E=B*7,t=E+7,s=Math.floor(E/32),o=E-s*32,a=C<<o&4294967295;if(Q[g+s]|=a,t>s*32+32){const i=C>>>32-o&4294967295;Q[g+s+1]|=i}}}function ms(Q,A,I){Q[A*4+0]=vQ(I[0],I[1],I[2],I[3]),Q[A*4+1]=vQ(I[4],I[5],I[6],I[7]),Q[A*4+2]=vQ(I[8],I[9],I[10],I[11]),Q[A*4+3]=vQ(I[12],I[13],I[14],0)}function bs(Q,A,I){const g=A*4;for(let B=0;B<21;++B){const C=Math.max(-31,Math.min(31,I[B]*31))&63,E=B*6,t=E+6,s=Math.floor(E/32),o=E-s*32,a=C<<o&4294967295;if(Q[g+s]|=a,t>s*32+32){const i=C>>>32-o&4294967295;Q[g+s+1]|=i}}}function RB(Q,A){const I=[];let g=0,B=null;const C=new sB((s,o)=>{if(I.push(s),g+=s.length,o||g>=A){const a=new Uint8Array(g);let i=0;for(const D of I)a.set(D,i),i+=D.length;B=a.slice(0,A)}}),E=1024;let t=0;for(;B==null&&t<Q.length;){const s=Q.slice(t,t+E);C.push(s,!1),t+=E}if(B==null&&(C.push(new Uint8Array,!0),B==null))throw new Error("Failed to decompress partial gzip");return B}class JB{constructor({fileBytes:A,chunkBytes:I=64*1024}){this.fileBytes=A,this.chunkBytes=I,this.offset=0,this.chunks=[],this.totalBytes=0,this.gunzip=new sB((g,B)=>{this.chunks.push(g),this.totalBytes+=g.length})}read(A){for(;this.totalBytes<A&&this.offset<this.fileBytes.length;){const C=Math.min(this.offset+this.chunkBytes,this.fileBytes.length);this.gunzip.push(this.fileBytes.subarray(this.offset,C),!1),this.offset=C}if(this.totalBytes<A&&this.offset>=this.fileBytes.length&&this.gunzip.push(new Uint8Array(0),!0),this.totalBytes<A)throw new Error(`Unexpected EOF: needed ${A}, got ${this.totalBytes}`);const I=new Uint8Array(this.totalBytes);let g=0 Line truncated
`);function YQ(g){const A=new a.Vector3;for(const I of g)A.add(I);return A.divideScalar(g.length)}function UQ(g){if(g.length===0)return new a.Quaternion;const A=g[0].clone();for(let I=1;I<g.length;I++)g[I].dot(g[0])<0?(A.x-=g[I].x,A.y-=g[I].y,A.z-=g[I].z,A.w-=g[I].w):(A.x+=g[I].x,A.y+=g[I].y,A.z+=g[I].z,A.w+=g[I].w);return A.normalize()}function xQ(g,A){const I=new a.Vector3(0,0,0).applyMatrix4(g),B=new a.Vector3(0,0,0).applyMatrix4(A),Q=new a.Vector3(0,0,-1).applyMatrix4(g).sub(I).normalize(),C=new a.Vector3(0,0,-1).applyMatrix4(A).sub(B).normalize(),E=I.distanceTo(B),t=Q.dot(C);return{distance:E,coincidence:t}}function Hs({matrix1:g,matrix2:A,maxDistance:I}){const B=new a.Vector3(0,0,0).applyMatrix4(g),Q=new a.Vector3(0,0,0).applyMatrix4(A);return B.distanceTo(Q)<=I}function Ks({matrix1:g,matrix2:A,maxDistance:I,minCoincidence:B}){const{distance:Q,coincidence:C}=xQ(g,A);return Q<=I&&(B==null||C>=B)}function LQ(g,A){const[I,B]=[new a.Vector3,new a.Quaternion],[Q,C]=[new a.Vector3,new a.Quaternion];g.decompose(I,B,new a.Vector3),A.decompose(Q,C,new a.Vector3);const E=I.distanceTo(Q),t=Math.abs(B.dot(C));return{distance:E,coorient:t}}function sI({matrix1:g,matrix2:A,maxDistance:I,minCoorient:B}){const{distance:Q,coorient:C}=LQ(g,A);return Q<=I&&(B==null||C>=B)}function Zs(g,A=.001){return Math.abs(g)<A?0:Math.sign(g)}function qs(g){const A=g.w<0,I=Jg(A?-g.x:g.x),B=Jg(A?-g.y:g.y),Q=Jg(A?-g.z:g.z),C=I&255,E=B&255,t=Q&255;return C|E<<8|t<<16}function vs(g,A){const I=g<<24>>24,B=g<<16>>24,Q=g<<8>>24;A.set(I/127,B/127,Q/127,0);const C=A.x*A.x+A.y*A.y+A.z*A.z;return A.w=Math.sqrt(Math.max(0,1-C)),A}function VI(g){const A=g.clone().normalize();A.w<0&&A.set(-A.x,-A.y,-A.z,-A.w);const I=2*Math.acos(A.w),B=Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z),Q=B<1e-6?new a.Vector3(1,0,0):new a.Vector3(A.x,A.y,A.z).divideScalar(B),C=Math.abs(Q.x)+Math.abs(Q.y)+Math.abs(Q.z);let E=Q.x/C,t=Q.y/C;if(Q.z<0){const r=E;E=(1-Math.abs(t))*(E>=0?1:-1),t=(1-Math.abs(r))*(t>=0?1:-1)}const i=E*.5+.5,e=t*.5+.5,n=Math.round(i*255),s=Math.round(e*255);return Math.round(I*(255/Math.PI))<<16|s<<8|n}function bQ(g,A){const I=g&255,B=g>>>8&255,Q=g>>>16&255,C=I/255,E=B/255;let t=(C-.5)*2,i=(E-.5)*2;const e=1-(Math.abs(t)+Math.abs(i)),n=Math.max(-e,0);t+=t>=0?-n:n,i+=i>=0?-n:n;const s=new a.Vector3(t,i,e).normalize(),r=Q/255*Math.PI*.5,c=Math.sin(r),h=Math.cos(r);return A.set(s.x*c,s.y*c,s.z*c,h),A}function Ws(g){const A=g.clone().normalize(),I=2*(A.w*A.x+A.y*A.z),B=1-2*(A.x*A.x+A.y*A.y),Q=Math.atan2(I,B),C=2*(A.w*A.y-A.z*A.x),E=Math.abs(C)>=1?Math.sign(C)*(Math.PI/2):Math.asin(C),t=2*(A.w*A.z+A.x*A.y),i=1-2*(A.y*A.y+A.z*A.z),e=Math.atan2(t,i),n=(Q+Math.PI)/(2*Math.PI),s=(E+Math.PI)/(2*Math.PI),o=(e+Math.PI)/(2*Math.PI),r=Math.round(n*255),c=Math.round(s*255);return Math.round(o*255)<<16|c<<8|r}function Vs(g,A){const I=g&255,B=g>>>8&255,Q=g>>>16&255,C=I/255,E=B/255,t=Q/255,i=C*(2*Math.PI)-Math.PI,e=E*(2*Math.PI)-Math.PI,n=t*(2*Math.PI)-Math.PI,s=Math.cos(i*.5),o=Math.sin(i*.5),r=Math.cos(e*.5),c=Math.sin(e*.5),h=Math.cos(n*.5),w=Math.sin(n*.5);return A.w=s*r*h+o*c*w,A.x=o*r*h-s*c*w,A.y=s*c*h+o*r*w,A.z=s*r*w-o*c*h,A.normalize(),A}function Og(g,A,I,B){const Q=Math.max(-127,Math.min(127,g*127)),C=Math.max(-127,Math.min(127,A*127)),E=Math.max(-127,Math.min(127,I*127)),t=Math.max(-127,Math.min(127,B*127));return Q&255|(C&255)<<8|(E&255)<<16|(t&255)<<24}function Ts(g,A,I){const B=A*2;for(let Q=0;Q<9;++Q){const C=Math.max(-63,Math.min(63,I[Q]*63))&127,E=Q*7,t=E+7,i=Math.floor(E/32),e=E-i*32,n=C<<e&4294967295;if(g[B+i]|=n,t>i*32+32){const s=C>>>32-e&4294967295;g[B+i+1]|=s}}}function Xs(g,A,I){g[A*4+0]=Og(I[0],I[1],I[2],I[3]),g[A*4+1]=Og(I[4],I[5],I[6],I[7]),g[A*4+2]=Og(I[8],I[9],I[10],I[11]),g[A*4+3]=Og(I[12],I[13],I[14],0)}function zs(g,A,I){const B=A*4;for(let Q=0;Q<21;++Q){const C=Math.max(-31,Math.min(31,I[Q]*31))&63,E=Q*6,t=E+6,i=Math.floor(E/32),e=E-i*32,n=C<<e&4294967295;if(g[B+i]|=n,t>i*32+32){const s=C>>>32-e&4294967295;g[B+i+1]|=s}}}function HQ(g,A){const I=[];let B=0,Q=null;const C=new dQ((i,e)=>{if(I.push(i),B+=i.length,e||B>=A){const n=new Uint8Array(B);let s=0;for(const o of I)n.set(o,s),s+=o.length;Q=n.slice(0,A)}}),E=1024;let t=0;for(;Q==null&&t<g.length;){const i=g.slice(t,t+E);C.push(i,!1),t+=E}if(Q==null&&(C.push(new Uint8Array,!0),Q==null))throw new Error("Failed to decompress partial gzip");return Q}class KQ{constructor({fileBytes:A,chunkBytes:I=64*1024}){this.fileBytes=A,this.chunkBytes=I,this.offset=0,this.chunks=[],this.totalBytes=0,this.gunzip=new dQ((B,Q)=>{this.chunks.push(B),this.totalBytes+=B.length})}read(A){for(;this.totalBytes<A&&this.offset<this.fileBytes.length;){const C=Math.min(this.offset+this.chunkBytes,this.fileBytes.length);this.gunzip.push(this.fileBytes.subarray(this.offset,C),!1),this.offset=C}if(this.totalBytes<A&&this.offset>=this.fileBytes.length&&this.gunzip.push(new Uint8Array(0),!0),this.totalBytes<A)throw new Error(`Unexpected EOF: needed ${A}, got ${this.totalBytes}`);const I=new Uint8Array(this.totalBytes);let B=0 Line truncated
`)+this.between+I.map(g=>this.indent+g).join(`
`)+this.after}}const TI=new Map;function Ks(Q){let A=TI.get(Q);return A||(A=new e.RawShaderMaterial({glslVersion:e.GLSL3,vertexShader:GB,fragmentShader:Q.shader,uniforms:Q.uniforms}),TI.set(Q,A),A)}function mI(Q,A,I="add"){const g=()=>{throw new Error(`Invalid ${I} types: ${Q}, ${A}`)};if(Q===A)return Q;if(Q==="int"){if(tA(A))return A;g()}if(A==="int"){if(tA(Q))return Q;g()}if(Q==="uint"){if(iA(A))return A;g()}if(A==="uint"){if(iA(Q))return Q;g()}if(Q==="float"){if(_A(A))return A;g()}if(A==="float"){if(_A(Q))return Q;g()}throw new Error(`Invalid ${I} types: ${Q}, ${A}`)}function Zs(Q,A){return mI(Q,A,"sub")}function qs(Q,A){const I=()=>{throw new Error(`Invalid mul types: ${Q}, ${A}`)},g=B=>B;if(Q==="int"){if(tA(A))return g(A);I()}if(A==="int"){if(tA(Q))return g(Q);I()}if(Q==="uint"){if(iA(A))return g(A);I()}if(A==="uint"){if(iA(Q))return g(Q);I()}if(Q==="float"){if(_A(A))return g(A);I()}if(A==="float"){if(_A(Q))return g(Q);I()}if(tA(Q)||iA(Q)||tA(A)||iA(A)){if(Q===A)return g(Q);I()}if(Q==="vec2"){if(A==="vec2"||QQ(A))return g("vec2");if(A==="mat3x2")return g("vec3");if(A==="mat4x2")return g("vec4");I()}if(Q==="vec3"){if(A==="mat2x3")return g("vec2");if(A==="vec3"||IQ(A))return g("vec3");if(A==="mat4x3")return g("vec4");I()}if(Q==="vec4"){if(A==="mat2x4")return g("vec2");if(A==="mat3x4")return g("vec3");if(A==="vec4"||gQ(A))return g("vec4");I()}if(A==="vec2"){if(QQ(Q))return g("vec2");if(Q==="mat2x3")return g("vec3");if(Q==="mat2x4")return g("vec4");I()}if(A==="vec3"){if(Q==="mat3x2")return g("vec2");if(IQ(Q))return g("vec3");if(Q==="mat3x4")return g("vec4");I()}if(A==="vec4"){if(Q==="mat4x2")return g("vec2");if(Q==="mat4x3")return g("vec3");if(gQ(Q))return g("vec4");I()}if(QQ(Q)){if(QQ(A))return g("mat2");if(A==="mat3x2")return g("mat3x2");if(A==="mat4x2")return g("mat4x2");I()}if(Q==="mat2x3"){if(QQ(A))return g("mat2x3");if(A==="mat3x2")return g("mat3");if(A==="mat4x2")return g("mat4x3");I()}if(Q==="mat2x4"){if(QQ(A))return g("mat2x4");if(A==="mat3x2")return g("mat3x4");if(A==="mat4x2")return g("mat4");I()}if(Q==="mat3x2"){if(A==="mat2x3")return g("mat2");if(IQ(A))return g("mat3x2");if(A==="mat4x3")return g("mat4x2");I()}if(IQ(Q)){if(A==="mat2x3")return g("mat2x3");if(IQ(A))return g("mat3");if(A==="mat4x3")return g("mat4x3");I()}if(Q==="mat3x4"){if(A==="mat2x3")return g("mat2x4");if(IQ(A))return g("mat3x4");if(A==="mat4x3")return g("mat4");I()}if(Q==="mat4x2"){if(A==="mat2x4")return g("mat2");if(A==="mat3x4")return g("mat3x2");if(gQ(A))return g("mat4x2");I()}if(Q==="mat4x3"){if(A==="mat2x4")return g("mat2x3");if(A==="mat3x4")return g("mat3");if(gQ(A))return g("mat4x3");I()}if(gQ(Q)){if(A==="mat2x4")return g("mat2x4");if(A==="mat3x4")return g("mat3x4");if(gQ(A))return g("mat4");I()}throw new Error(`Invalid mul types: ${Q}, ${A}`)}function Ws(Q,A){return mI(Q,A,"div")}function Vs(Q,A){if(Q===A)return Q;if(Q==="int"){if(tA(A))return A}else if(A==="int"){if(tA(Q))return Q}else if(Q==="uint"){if(iA(A))return A}else if(A==="uint"&&iA(Q))return Q;throw new Error(`Invalid imod types: ${Q}, ${A}`)}function Ts(Q,A){if(Q===A||A==="float")return Q;throw new Error(`Invalid mod types: ${Q}, ${A}`)}function vs(Q){return Q}function Xs(Q){return Q}function js(Q){return Q}function zs(Q){return Q}function Os(Q){return Q}function Ps(Q){return Q}function _s(Q){return Q}function $s(Q){return Q}function Ao(Q){return Q}function Qo(Q){return Q}function Io(Q){return Q}function go(Q){return Q}function Bo(Q){return Q}function Co(Q){return Q}function Eo(Q){return Q}function to(Q){return Q}function dB(Q,A,I="min"){if(Q===A)return Q;if(A==="float"){if(bQ(Q))return Q}else if(A==="int"){if(tA(Q))return Q}else if(A==="uint"&&iA(Q))return Q;throw new Error(`Invalid ${I} types: ${Q}, ${A}`)}function io(Q,A){return dB(Q,A,"max")}function so(Q,A,I){if(A==="float"){if(bQ(Q))return Q}else if(A==="int"){if(tA(Q))return Q}else if(A==="uint"&&iA(Q))return Q;throw new Error(`Invalid clamp types: ${Q}, ${A}`)}function oo(Q,A,I){if(I===Q||I==="float"||I==="bool"&&Q==="float"||I==="bvec2"&&Q==="vec2"||I==="bvec3"&&Q==="vec3"||I==="bvec4"&&Q==="vec4")return Q;throw new Error(`Invalid mix types: ${Q}, ${A}, ${I}`)}function ao(Q,A){if(Q===A||A==="float")return A;throw new Error(`Invalid step types: ${Q}, ${A}`)}function eo(Q,A,I){if(Q===A&&(Q===I||Q==="float"))return I;throw new Error(`Invalid smoothstep types: ${Q}, ${A}, ${I}`)}function YB(Q,A="isNan"){if(Q==="float")return"bool";if(Q==="vec2")return"bvec2";if(Q==="vec3")return"bvec3";if(Q==="vec4")return"bvec4";throw new Error(`Invalid ${A} types: ${Q}`)}function Do(Q){return YB(Q,"isInf")}const wA=(Q,A)=>new LB({a:Q,b:A}),LQ=(Q,A)=>new pB({a:Q,b:A}),CA=(Q,A)=>new HB({a:Q,b:A}),$Q=(Q,A)=>new fB({a:Q,b:A}),kI=(Q,A)=>new mB({a:Q,b:A}),uB=(Q,A)=>new bB({a:Q,b:A}),no=Q=>new xB({a:Q}).outputs,co=Q=>new KB({a:Q}),wo=Q=>new ZB({a:Q}),ro=Q=>new qB({a:Q}),ho=Q=>new WB({a:Q}),yo=Q=>new VB({a:Q}),Go=Q=>new TB({a:Q}),lo=Q=>new vB({a:Q}),AI=Q=>new XB({a:Q}),Mo=(Q,A)=>new jB({a:Q,b:A}),No=Q=>new zB({a:Q}),ko=Q=>ne Line truncated
`)+this.between+I.map(B=>this.indent+B).join(`
`)+this.after}}const BB=new Map;function Os(g){let A=BB.get(g);return A||(A=new a.RawShaderMaterial({glslVersion:a.GLSL3,vertexShader:SQ,fragmentShader:g.shader,uniforms:g.uniforms}),BB.set(g,A),A)}function zI(g,A,I="add"){const B=()=>{throw new Error(`Invalid ${I} types: ${g}, ${A}`)};if(g===A)return g;if(g==="int"){if(DA(A))return A;B()}if(A==="int"){if(DA(g))return g;B()}if(g==="uint"){if(lA(A))return A;B()}if(A==="uint"){if(lA(g))return g;B()}if(g==="float"){if(gg(A))return A;B()}if(A==="float"){if(gg(g))return g;B()}throw new Error(`Invalid ${I} types: ${g}, ${A}`)}function Ps(g,A){return zI(g,A,"sub")}function _s(g,A){const I=()=>{throw new Error(`Invalid mul types: ${g}, ${A}`)},B=Q=>Q;if(g==="int"){if(DA(A))return B(A);I()}if(A==="int"){if(DA(g))return B(g);I()}if(g==="uint"){if(lA(A))return B(A);I()}if(A==="uint"){if(lA(g))return B(g);I()}if(g==="float"){if(gg(A))return B(A);I()}if(A==="float"){if(gg(g))return B(g);I()}if(DA(g)||lA(g)||DA(A)||lA(A)){if(g===A)return B(g);I()}if(g==="vec2"){if(A==="vec2"||Bg(A))return B("vec2");if(A==="mat3x2")return B("vec3");if(A==="mat4x2")return B("vec4");I()}if(g==="vec3"){if(A==="mat2x3")return B("vec2");if(A==="vec3"||Qg(A))return B("vec3");if(A==="mat4x3")return B("vec4");I()}if(g==="vec4"){if(A==="mat2x4")return B("vec2");if(A==="mat3x4")return B("vec3");if(A==="vec4"||Cg(A))return B("vec4");I()}if(A==="vec2"){if(Bg(g))return B("vec2");if(g==="mat2x3")return B("vec3");if(g==="mat2x4")return B("vec4");I()}if(A==="vec3"){if(g==="mat3x2")return B("vec2");if(Qg(g))return B("vec3");if(g==="mat3x4")return B("vec4");I()}if(A==="vec4"){if(g==="mat4x2")return B("vec2");if(g==="mat4x3")return B("vec3");if(Cg(g))return B("vec4");I()}if(Bg(g)){if(Bg(A))return B("mat2");if(A==="mat3x2")return B("mat3x2");if(A==="mat4x2")return B("mat4x2");I()}if(g==="mat2x3"){if(Bg(A))return B("mat2x3");if(A==="mat3x2")return B("mat3");if(A==="mat4x2")return B("mat4x3");I()}if(g==="mat2x4"){if(Bg(A))return B("mat2x4");if(A==="mat3x2")return B("mat3x4");if(A==="mat4x2")return B("mat4");I()}if(g==="mat3x2"){if(A==="mat2x3")return B("mat2");if(Qg(A))return B("mat3x2");if(A==="mat4x3")return B("mat4x2");I()}if(Qg(g)){if(A==="mat2x3")return B("mat2x3");if(Qg(A))return B("mat3");if(A==="mat4x3")return B("mat4x3");I()}if(g==="mat3x4"){if(A==="mat2x3")return B("mat2x4");if(Qg(A))return B("mat3x4");if(A==="mat4x3")return B("mat4");I()}if(g==="mat4x2"){if(A==="mat2x4")return B("mat2");if(A==="mat3x4")return B("mat3x2");if(Cg(A))return B("mat4x2");I()}if(g==="mat4x3"){if(A==="mat2x4")return B("mat2x3");if(A==="mat3x4")return B("mat3");if(Cg(A))return B("mat4x3");I()}if(Cg(g)){if(A==="mat2x4")return B("mat2x4");if(A==="mat3x4")return B("mat3x4");if(Cg(A))return B("mat4");I()}throw new Error(`Invalid mul types: ${g}, ${A}`)}function $s(g,A){return zI(g,A,"div")}function Ae(g,A){if(g===A)return g;if(g==="int"){if(DA(A))return A}else if(A==="int"){if(DA(g))return g}else if(g==="uint"){if(lA(A))return A}else if(A==="uint"&&lA(g))return g;throw new Error(`Invalid imod types: ${g}, ${A}`)}function ge(g,A){if(g===A||A==="float")return g;throw new Error(`Invalid mod types: ${g}, ${A}`)}function Ie(g){return g}function Be(g){return g}function Qe(g){return g}function Ce(g){return g}function Ee(g){return g}function te(g){return g}function ie(g){return g}function se(g){return g}function ee(g){return g}function ae(g){return g}function ne(g){return g}function oe(g){return g}function re(g){return g}function ce(g){return g}function he(g){return g}function we(g){return g}function ZQ(g,A,I="min"){if(g===A)return g;if(A==="float"){if(qg(g))return g}else if(A==="int"){if(DA(g))return g}else if(A==="uint"&&lA(g))return g;throw new Error(`Invalid ${I} types: ${g}, ${A}`)}function De(g,A){return ZQ(g,A,"max")}function le(g,A,I){if(A==="float"){if(qg(g))return g}else if(A==="int"){if(DA(g))return g}else if(A==="uint"&&lA(g))return g;throw new Error(`Invalid clamp types: ${g}, ${A}`)}function ye(g,A,I){if(I===g||I==="float"||I==="bool"&&g==="float"||I==="bvec2"&&g==="vec2"||I==="bvec3"&&g==="vec3"||I==="bvec4"&&g==="vec4")return g;throw new Error(`Invalid mix types: ${g}, ${A}, ${I}`)}function ue(g,A){if(g===A||A==="float")return A;throw new Error(`Invalid step types: ${g}, ${A}`)}function de(g,A,I){if(g===A&&(g===I||g==="float"))return I;throw new Error(`Invalid smoothstep types: ${g}, ${A}, ${I}`)}function qQ(g,A="isNan"){if(g==="float")return"bool";if(g==="vec2")return"bvec2";if(g==="vec3")return"bvec3";if(g==="vec4")return"bvec4";throw new Error(`Invalid ${A} types: ${g}`)}function Ge(g){return qQ(g,"isInf")}const pA=(g,A)=>new TQ({a:g,b:A}),xg=(g,A)=>new XQ({a:g,b:A}),cA=(g,A)=>new zQ({a:g,b:A}),BI=(g,A)=>new jQ({a:g,b:A}),YI=(g,A)=>new OQ({a:g,b:A}),vQ=(g,A)=>new PQ({a:g,b:A}),Me=g=>new _Q({a:g}).outputs,Ne=g=>new $Q({a:g}),pe=g=>new AC({a:g}),ke=g=>new gC({a:g}),Fe=g=>new IC({a:g}),Re=g=>new BC({a:g}),Je=g=>new QC({a:g}),me=g=>new CC({a:g}),QI=g=>new EC({a:g}),fe=(g,A)=>new tC({a:g,b:A}),Se=g=>new iC({a:g}),Ye=g=>ne Line truncated
uint pcg_next(uint state) {
return state * 747796405u + 2891336453u;
}
`)],statements:({inputs:g,outputs:B})=>{const C=I==="uint"?`${g.state}`:I==="int"?`uint(${g.state})`:`floatBitsToUint(${g.state})`;return[`${B.state} = pcg_next(${C});`]}})}dynoOut(){return new H(this,"state")}}class JA extends f{constructor({state:A}){super({inTypes:{state:"uint"},outTypes:{hash:"uint"},inputs:{state:A},globals:()=>[gA(`
`)],statements:({inputs:B,outputs:Q})=>{const C=I==="uint"?`${B.state}`:I==="int"?`uint(${B.state})`:`floatBitsToUint(${B.state})`;return[`${Q.state} = pcg_next(${C});`]}})}dynoOut(){return new W(this,"state")}}class mA extends T{constructor({state:A}){super({inTypes:{state:"uint"},outTypes:{hash:"uint"},inputs:{state:A},globals:()=>[nA(`
uint pcg_hash(uint state) {
uint hash = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
return (hash >> 22u) ^ hash;
}
`)],statements:({inputs:I,outputs:g})=>[`${g.hash} = pcg_hash(${I.state});`]})}dynoOut(){return new H(this,"hash")}}class lQ extends f{constructor({value:A}){const I=p(A),g=gg(I);super({inTypes:{value:I},outTypes:{state:"uint"},inputs:{value:A},globals:()=>[gA(`
`)],statements:({inputs:I,outputs:B})=>[`${B.hash} = pcg_hash(${I.state});`]})}dynoOut(){return new W(this,"hash")}}class Gg extends T{constructor({value:A}){const I=v(A),B=hB(I);super({inTypes:{value:I},outTypes:{state:"uint"},inputs:{value:A},globals:()=>[nA(`
uint pcg_mix(uint value) {
return value;
}
@@ -97,7 +97,7 @@ ${Q.stack}`:g}let MI=0,MQ=null;function OQ(){return(MQ===null||MQ.byteLength===0
uint pcg_mix(uvec4 value) {
return value.x + 0x9e3779b9u * value.y + 0x85ebca6bu * value.z + 0xc2b2ae35u * value.w;
}
`)],statements:({inputs:B,outputs:C})=>{const E=iA(I)?`${B.value}`:tA(I)?`${g}(${B.value})`:`floatBitsToUint(${B.value})`;return[`${g} bits = ${E};`,`${C.state} = pcg_mix(bits);`]}})}dynoOut(){return new H(this,"state")}}class LE extends bA{constructor({value:A}){super({inTypes:{value:p(A)},outTypes:{hash:"uint"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new lQ({value:I}).outputs.state;return g=new RA({state:g}).outputs.state,new JA({state:g}).outputs}})}dynoOut(){return new H(this,"hash")}}class pE extends bA{constructor({value:A}){super({inTypes:{value:p(A)},outTypes:{hash:"uvec2"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new lQ({value:I}).outputs.state;g=new RA({state:g}).outputs.state;const B=new JA({state:g}).outputs.hash;g=new RA({state:g}).outputs.state;const C=new JA({state:g}).outputs.hash;return{hash:mA({vectorType:"uvec2",x:B,y:C})}}})}dynoOut(){return new H(this,"hash")}}class HE extends bA{constructor({value:A}){super({inTypes:{value:p(A)},outTypes:{hash:"uvec3"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new lQ({value:I}).outputs.state;g=new RA({state:g}).outputs.state;const B=new JA({state:g}).outputs.hash;g=new RA({state:g}).outputs.state;const C=new JA({state:g}).outputs.hash;g=new RA({state:g}).outputs.state;const E=new JA({state:g}).outputs.hash;return{hash:mA({vectorType:"uvec3",x:B,y:C,z:E})}}})}dynoOut(){return new H(this,"hash")}}class fE extends bA{constructor({value:A}){super({inTypes:{value:p(A)},outTypes:{hash:"uvec4"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new lQ({value:I}).outputs.state;g=new RA({state:g}).outputs.state;const B=new JA({state:g}).outputs.hash;g=new RA({state:g}).outputs.state;const C=new JA({state:g}).outputs.hash;g=new RA({state:g}).outputs.state;const E=new JA({state:g}).outputs.hash;g=new RA({state:g}).outputs.state;const t=new JA({state:g}).outputs.hash;return{hash:mA({vectorType:"uvec4",x:B,y:C,z:E,w:t})}}})}dynoOut(){return new H(this,"hash")}}class mE extends bA{constructor({value:A}){super({inTypes:{value:p(A)},outTypes:{hash:"float"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=JE(I);return{hash:CA(FC(g),q("float",1/2**32))}}})}dynoOut(){return new H(this,"hash")}}class bE extends bA{constructor({value:A}){super({inTypes:{value:p(A)},outTypes:{hash:"vec2"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=dE(I);return{hash:CA(RC(g),q("float",1/2**32))}}})}dynoOut(){return new H(this,"hash")}}class xE extends bA{constructor({value:A}){super({inTypes:{value:p(A)},outTypes:{hash:"vec3"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=YE(I);return{hash:CA(tQ(g),q("float",1/2**32))}}})}dynoOut(){return new H(this,"hash")}}class KE extends bA{constructor({value:A}){super({inTypes:{value:p(A)},outTypes:{hash:"vec4"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=uE(I);return{hash:CA(JC(g),q("float",1/2**32))}}})}dynoOut(){return new H(this,"hash")}}const ja=(Q,{scale:A,scales:I,rotate:g,translate:B})=>new ZE({position:Q,scale:A,scales:I,rotate:g,translate:B}).outputs.position,za=(Q,{scale:A,scales:I,rotate:g})=>new qE({ray:Q,scale:A,scales:I,rotate:g}).outputs.ray,Oa=(Q,{rotate:A})=>new WE({quaternion:Q,rotate:A}).outputs.quaternion;class ZE extends f{constructor({position:A,scale:I,scales:g,rotate:B,translate:C}){super({inTypes:{position:"vec3",scale:"float",scales:"vec3",rotate:"vec4",translate:"vec3"},outTypes:{position:"vec3"},inputs:{position:A,scale:I,scales:g,rotate:B,translate:C},statements:({inputs:E,outputs:t})=>{const{position:s}=t;if(!s)return[];const{scale:o,scales:a,rotate:i,translate:D}=E;return[`${s} = ${E.position??"vec3(0.0, 0.0, 0.0)"};`,o?`${s} *= ${o};`:null,a?`${s} *= ${a};`:null,i?`${s} = quatVec(${i}, ${s});`:null,D?`${s} += ${D};`:null].filter(Boolean)}})}}class qE extends f{constructor({ray:A,scale:I,scales:g,rotate:B}){super({inTypes:{ray:"vec3",scale:"float",scales:"vec3",rotate:"vec4"},outTypes:{ray:"vec3"},inputs:{ray:A,scale:I,scales:g,rotate:B},statements:({inputs:C,outputs:E})=>{const{ray:t}=E;if(!t)return[];const{scale:s,scales:o,rotate:a}=C;return[`${t} = ${C.ray??"vec3(0.0, 0.0, 0.0)"};`,s?`${t} *= ${s};`:null,o?`${t} *= ${o};`:null,a?`${t} = quatVec(${a}, ${t});`:null].filter(Boolean)}})}}class WE extends f{constructor({quaternion:A,rotate:I}){super({inTypes:{quaternion:"vec4",rotate:"vec4"},outTypes:{quaternion:"vec4"},inputs:{quaternion:A,rotate:I},statements:({inputs:g,outputs:B})=>{const{quaternion:C}=B;return C?[`${C} = ${g.quaternion??"vec4(0.0, 0.0, 0.0, 1.0)"};`,I?`${C} = quatQuat(${g.rotate}, ${C});`:null].filter(Boolean):[]}})}}const Pa=()=>{throw new Error("Not implemented")},_a=()=>{throw new Error("Not implemented")},$a=()=>{throw new Er Line truncated
`)],statements:({inputs:Q,outputs:C})=>{const E=lA(I)?`${Q.value}`:DA(I)?`${B}(${Q.value})`:`floatBitsToUint(${Q.value})`;return[`${B} bits = ${E};`,`${C.state} = pcg_mix(bits);`]}})}dynoOut(){return new W(this,"state")}}class TE extends vA{constructor({value:A}){super({inTypes:{value:v(A)},outTypes:{hash:"uint"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let B=new Gg({value:I}).outputs.state;return B=new JA({state:B}).outputs.state,new mA({state:B}).outputs}})}dynoOut(){return new W(this,"hash")}}class XE extends vA{constructor({value:A}){super({inTypes:{value:v(A)},outTypes:{hash:"uvec2"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let B=new Gg({value:I}).outputs.state;B=new JA({state:B}).outputs.state;const Q=new mA({state:B}).outputs.hash;B=new JA({state:B}).outputs.state;const C=new mA({state:B}).outputs.hash;return{hash:qA({vectorType:"uvec2",x:Q,y:C})}}})}dynoOut(){return new W(this,"hash")}}class zE extends vA{constructor({value:A}){super({inTypes:{value:v(A)},outTypes:{hash:"uvec3"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let B=new Gg({value:I}).outputs.state;B=new JA({state:B}).outputs.state;const Q=new mA({state:B}).outputs.hash;B=new JA({state:B}).outputs.state;const C=new mA({state:B}).outputs.hash;B=new JA({state:B}).outputs.state;const E=new mA({state:B}).outputs.hash;return{hash:qA({vectorType:"uvec3",x:Q,y:C,z:E})}}})}dynoOut(){return new W(this,"hash")}}class jE extends vA{constructor({value:A}){super({inTypes:{value:v(A)},outTypes:{hash:"uvec4"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let B=new Gg({value:I}).outputs.state;B=new JA({state:B}).outputs.state;const Q=new mA({state:B}).outputs.hash;B=new JA({state:B}).outputs.state;const C=new mA({state:B}).outputs.hash;B=new JA({state:B}).outputs.state;const E=new mA({state:B}).outputs.hash;B=new JA({state:B}).outputs.state;const t=new mA({state:B}).outputs.hash;return{hash:qA({vectorType:"uvec4",x:Q,y:C,z:E,w:t})}}})}dynoOut(){return new W(this,"hash")}}class OE extends vA{constructor({value:A}){super({inTypes:{value:v(A)},outTypes:{hash:"float"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const B=KE(I);return{hash:cA(bC(B),gA("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class PE extends vA{constructor({value:A}){super({inTypes:{value:v(A)},outTypes:{hash:"vec2"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const B=ZE(I);return{hash:cA(HC(B),gA("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class _E extends vA{constructor({value:A}){super({inTypes:{value:v(A)},outTypes:{hash:"vec3"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const B=qE(I);return{hash:cA(sg(B),gA("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class $E extends vA{constructor({value:A}){super({inTypes:{value:v(A)},outTypes:{hash:"vec4"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const B=vE(I);return{hash:cA(KC(B),gA("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}const At=(g,{scale:A,scales:I,rotate:B,translate:Q})=>new It({position:g,scale:A,scales:I,rotate:B,translate:Q}).outputs.position,gt=(g,{scale:A,scales:I,rotate:B})=>new Bt({dir:g,scale:A,scales:I,rotate:B}).outputs.dir,Bn=(g,{rotate:A})=>new Qt({quaternion:g,rotate:A}).outputs.quaternion;class It extends T{constructor({position:A,scale:I,scales:B,rotate:Q,translate:C}){super({inTypes:{position:"vec3",scale:"float",scales:"vec3",rotate:"vec4",translate:"vec3"},outTypes:{position:"vec3"},inputs:{position:A,scale:I,scales:B,rotate:Q,translate:C},statements:({inputs:E,outputs:t})=>{const{position:i}=t;if(!i)return[];const{scale:e,scales:n,rotate:s,translate:o}=E;return[`${i} = ${E.position??"vec3(0.0, 0.0, 0.0)"};`,e?`${i} *= ${e};`:null,n?`${i} *= ${n};`:null,s?`${i} = quatVec(${s}, ${i});`:null,o?`${i} += ${o};`:null].filter(Boolean)}})}}class Bt extends T{constructor({dir:A,scale:I,scales:B,rotate:Q}){super({inTypes:{dir:"vec3",scale:"float",scales:"vec3",rotate:"vec4"},outTypes:{dir:"vec3"},inputs:{dir:A,scale:I,scales:B,rotate:Q},statements:({inputs:C,outputs:E})=>{const{dir:t}=E;if(!t)return[];const{scale:i,scales:e,rotate:n}=C;return[`${t} = ${C.dir??"vec3(0.0, 0.0, 0.0)"};`,i?`${t} *= ${i};`:null,e?`${t} *= ${e};`:null,n?`${t} = quatVec(${n}, ${t});`:null].filter(Boolean)}})}}class Qt extends T{constructor({quaternion:A,rotate:I}){super({inTypes:{quaternion:"vec4",rotate:"vec4"},outTypes:{quaternion:"vec4"},inputs:{quaternion:A,rotate:I},statements:({inputs:B,outputs:Q})=>{const{quaternion:C}=Q;return C?[`${C} = ${B.quaternion??"vec4(0.0, 0.0, 0.0, 1.0)"};`,I?`${C} = quatQuat(${B.rotate}, ${C});`:null].filter(Boolean):[]}})}}const Qn=()=>{throw new Error("Not implemented")},Cn=()=>{throw new Error("Not implemented")},En=()=>{throw ne Line truncated
precision highp int;
precision highp sampler2D;
precision highp usampler2D;
@@ -132,18 +132,18 @@ void main() {
} else {
target = vec4(0.0, 0.0, 0.0, 0.0);
}
}`;const QA=class QA{constructor({renderer:A}={}){this.renderer=A,this.capacity=0,this.count=0}dispose(){this.target&&(this.target.dispose(),this.target=void 0)}ensureBuffer(A,I){const B=Math.ceil(Math.max(1,A)/Z)*Z*4;if(I.byteLength>=B)return I;const C=new ArrayBuffer(B);if(I instanceof ArrayBuffer)return C;const E=I.constructor;return new E(C)}ensureCapacity(A){const{width:I,height:g,depth:B,maxSplats:C}=rA(A);(!this.target||C>this.capacity)&&(this.dispose(),this.capacity=C,this.target=new e.WebGLArrayRenderTarget(I,g,B,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:e.NearestFilter,minFilter:e.NearestFilter}),this.target.texture.format=e.RGBAFormat,this.target.texture.type=e.UnsignedByteType,this.target.texture.internalFormat="RGBA8")}prepareProgramMaterial(A){let I=QA.readbackProgram.get(A);if(!I){const B=SA({index:"int"},{rgba8:"vec4"},({index:C})=>(A.inputs.index=C,{rgba8:new LI({rgba8:A.outputs.rgba8})}));QA.programTemplate||(QA.programTemplate=new fI(Me)),I=new HI({graph:B,inputs:{index:"index"},outputs:{rgba8:"target"},template:QA.programTemplate}),Object.assign(I.uniforms,{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0}}),QA.readbackProgram.set(A,I)}const g=I.prepareMaterial();return QA.mesh.material=g,{program:I,material:g}}saveRenderState(A){return{xrPresenting:A.xr.isPresenting,autoClear:A.autoClear,scissorTest:A.getScissorTest()}}resetRenderState(A,I){A.setRenderTarget(null),A.xr.isPresenting=I.xrPresenting,A.autoClear=I.autoClear,A.setScissorTest(I.scissorTest)}process({count:A,material:I}){const g=this.renderer;if(!g)throw new Error("No renderer");if(!this.target)throw new Error("No target");const B=Z*BQ;I.uniforms.targetBase.value=0,I.uniforms.targetCount.value=A;let C=0;for(;C<A;){const E=Math.floor(C/B),t=E*B,s=Math.min(BQ,Math.ceil((A-t)/Z));I.uniforms.targetLayer.value=E,g.setRenderTarget(this.target,E),g.xr.isPresenting=!1,g.autoClear=!1,g.setScissorTest(!0),g.setScissor(0,0,Z,s),g.render(QA.scene,QA.camera),C+=Z*s}this.count=A}async read({readback:A}){const I=this.renderer;if(!I)throw new Error("No renderer");if(!this.target)throw new Error("No target");const g=Math.ceil(this.count/Z)*Z;if(A.byteLength<g*4)throw new Error(`Readback buffer too small: ${A.byteLength} < ${g*4}`);const B=new Uint8Array(A instanceof ArrayBuffer?A:A.buffer),C=Z*BQ;let E=0;const t=[];for(;E<this.count;){const s=Math.floor(E/C),o=s*C,a=Math.min(BQ,Math.ceil((this.count-o)/Z));I.setRenderTarget(this.target,s);const i=Z*a*4,D=B.subarray(o*4,o*4+i),n=I==null?void 0:I.readRenderTargetPixelsAsync(this.target,0,0,Z,a,D);t.push(n),E+=Z*a}return Promise.all(t).then(()=>A)}render({reader:A,count:I,renderer:g}){if(this.renderer=g||this.renderer,!this.renderer)throw new Error("No renderer");this.ensureCapacity(I);const{program:B,material:C}=this.prepareProgramMaterial(A);B.update();const E=this.saveRenderState(this.renderer);this.process({count:I,material:C}),this.resetRenderState(this.renderer,E)}async readback({readback:A}){if(!this.renderer)throw new Error("No renderer");const I=this.saveRenderState(this.renderer),g=this.read({readback:A});return this.resetRenderState(this.renderer,I),g}async renderReadback({reader:A,count:I,renderer:g,readback:B}){if(this.renderer=g||this.renderer,!this.renderer)throw new Error("No renderer");this.ensureCapacity(I);const{program:C,material:E}=this.prepareProgramMaterial(A);C.update();const t=this.saveRenderState(this.renderer);this.process({count:I,material:E});const s=this.read({readback:B});return this.resetRenderState(this.renderer,t),s}getTexture(){var A;return(A=this.target)==null?void 0:A.texture}};QA.programTemplate=null,QA.readbackProgram=new Map,QA.geometry=new e.PlaneGeometry(2,2),QA.mesh=new e.Mesh(QA.geometry,new e.RawShaderMaterial({visible:!1})),QA.scene=new e.Scene().add(QA.mesh),QA.camera=new e.Camera;let pQ=QA;const IA=class IA{constructor(A={}){this.capacity=0,this.count=0,this.array=null,this.readback=null,this.source=null,this.needsUpdate=!0,this.dyno=new F({key:"rgbaArray",type:ot,globals:()=>[at],value:{texture:IA.getEmpty(),count:0},update:I=>{var g;return I.texture=((g=this.readback)==null?void 0:g.getTexture())??this.source??IA.getEmpty(),I.count=this.count,I}}),A.array?(this.array=A.array,this.capacity=Math.floor(this.array.length/4),this.capacity=Math.floor(this.capacity/Z)*Z,this.count=Math.min(this.capacity,A.count??Number.POSITIVE_INFINITY)):(this.capacity=A.capacity??0,this.count=0)}dispose(){this.readback&&(this.readback.dispose(),this.readback=null),this.source&&(this.source.dispose(),this.source=null)}ensureCapacity(A){var I;if(!this.array||A>(((I=this.array)==null?void 0:I.length)??0)/4){this.capacity=rA(A).maxSplats;const g=new Uint8Array(this.capacity*4);this.array&&g.set(this.array),this.array=g}return this.array}getTexture(){var I;let A=(I=this.readback)==null?void 0:I.getTexture();return(this.source||this.array)&&(A=this.maybeUpdateSource()),A??IA.getEmpty()}maybeUpdateSource(){if(!this.array)throw new Error("No Line truncated
}`;const eA=class eA{constructor({renderer:A}={}){this.renderer=A,this.capacity=0,this.count=0}dispose(){this.target&&(this.target.dispose(),this.target=void 0)}ensureBuffer(A,I){const Q=Math.ceil(Math.max(1,A)/X)*X*4;if(I.byteLength>=Q)return I;const C=new ArrayBuffer(Q);if(I instanceof ArrayBuffer)return C;const E=I.constructor;return new E(C)}ensureCapacity(A){const{width:I,height:B,depth:Q,maxSplats:C}=MA(A);(!this.target||C>this.capacity)&&(this.dispose(),this.capacity=C,this.target=new a.WebGLArrayRenderTarget(I,B,Q,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:a.NearestFilter,minFilter:a.NearestFilter}),this.target.texture.format=a.RGBAFormat,this.target.texture.type=a.UnsignedByteType,this.target.texture.internalFormat="RGBA8")}prepareProgramMaterial(A){let I=eA.readbackProgram.get(A);if(!I){const Q=UA({index:"int"},{rgba8:"vec4"},({index:C})=>(A.inputs.index=C,{rgba8:new WI({rgba8:A.outputs.rgba8})}));eA.programTemplate||(eA.programTemplate=new XI(Jn)),I=new TI({graph:Q,inputs:{index:"index"},outputs:{rgba8:"target"},template:eA.programTemplate}),Object.assign(I.uniforms,{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0}}),eA.readbackProgram.set(A,I)}const B=I.prepareMaterial();return eA.mesh.material=B,{program:I,material:B}}saveRenderState(A){return{xrPresenting:A.xr.isPresenting,autoClear:A.autoClear,scissorTest:A.getScissorTest(),pixelRatio:A.getPixelRatio()}}resetRenderState(A,I){A.setRenderTarget(null),A.setPixelRatio(I.pixelRatio),A.xr.isPresenting=I.xrPresenting,A.autoClear=I.autoClear,A.setScissorTest(I.scissorTest)}process({count:A,material:I}){const B=this.renderer;if(!B)throw new Error("No renderer");if(!this.target)throw new Error("No target");const Q=X*TA;I.uniforms.targetBase.value=0,I.uniforms.targetCount.value=A;let C=0;for(;C<A;){const E=Math.floor(C/Q),t=E*Q,i=Math.min(TA,Math.ceil((A-t)/X));I.uniforms.targetLayer.value=E,B.setPixelRatio(1),B.setRenderTarget(this.target,E),B.xr.isPresenting=!1,B.autoClear=!1,B.setScissorTest(!0),B.setScissor(0,0,X,i),B.render(eA.scene,eA.camera),C+=X*i}this.count=A}async read({readback:A}){const I=this.renderer;if(!I)throw new Error("No renderer");if(!this.target)throw new Error("No target");const B=Math.ceil(this.count/X)*X;if(A.byteLength<B*4)throw new Error(`Readback buffer too small: ${A.byteLength} < ${B*4}`);const Q=new Uint8Array(A instanceof ArrayBuffer?A:A.buffer),C=X*TA;let E=0;const t=[];for(;E<this.count;){const i=Math.floor(E/C),e=i*C,n=Math.min(TA,Math.ceil((this.count-e)/X));I.setPixelRatio(1),I.setRenderTarget(this.target,i);const s=X*n*4,o=Q.subarray(e*4,e*4+s),r=I==null?void 0:I.readRenderTargetPixelsAsync(this.target,0,0,X,n,o);t.push(r),E+=X*n}return Promise.all(t).then(()=>A)}render({reader:A,count:I,renderer:B}){if(this.renderer=B||this.renderer,!this.renderer)throw new Error("No renderer");this.ensureCapacity(I);const{program:Q,material:C}=this.prepareProgramMaterial(A);Q.update();const E=this.saveRenderState(this.renderer);this.process({count:I,material:C}),this.resetRenderState(this.renderer,E)}async readback({readback:A}){if(!this.renderer)throw new Error("No renderer");const I=this.saveRenderState(this.renderer),B=this.read({readback:A});return this.resetRenderState(this.renderer,I),B}async renderReadback({reader:A,count:I,renderer:B,readback:Q}){if(this.renderer=B||this.renderer,!this.renderer)throw new Error("No renderer");this.ensureCapacity(I);const{program:C,material:E}=this.prepareProgramMaterial(A);C.update();const t=this.saveRenderState(this.renderer);this.process({count:I,material:E});const i=this.read({readback:Q});return this.resetRenderState(this.renderer,t),i}getTexture(){var A;return(A=this.target)==null?void 0:A.texture}};eA.programTemplate=null,eA.readbackProgram=new Map,eA.geometry=new a.PlaneGeometry(2,2),eA.mesh=new a.Mesh(eA.geometry,new a.RawShaderMaterial({visible:!1})),eA.scene=new a.Scene().add(eA.mesh),eA.camera=new a.Camera;let Lg=eA;const aA=class aA{constructor(A={}){this.capacity=0,this.count=0,this.array=null,this.readback=null,this.source=null,this.needsUpdate=!0,this.dyno=new S({key:"rgbaArray",type:Nt,globals:()=>[pt],value:{texture:aA.getEmpty(),count:0},update:I=>{var B;return I.texture=((B=this.readback)==null?void 0:B.getTexture())??this.source??aA.getEmpty(),I.count=this.count,I}}),A.array?(this.array=A.array,this.capacity=Math.floor(this.array.length/4),this.capacity=Math.floor(this.capacity/X)*X,this.count=Math.min(this.capacity,A.count??Number.POSITIVE_INFINITY)):(this.capacity=A.capacity??0,this.count=0)}dispose(){this.readback&&(this.readback.dispose(),this.readback=null),this.source&&(this.source.dispose(),this.source=null)}ensureCapacity(A){var I;if(!this.array||A>(((I=this.array)==null?void 0:I.length)??0)/4){this.capacity=MA(A).maxSplats;const B=new Uint8Array(this.capacity*4);this.array&&B.set(this.array),this.array=B}return this.array}getTexture(){var I;let A=(I=this.readback)==null?void 0:I.getTexture();return(this.source||this.array)&&(A= Line truncated
struct RgbaArray {
sampler2DArray texture;
int count;
};
`);function Ne(Q,A){return new f({inTypes:{rgba:ot,index:"int"},outTypes:{rgba:"vec4"},inputs:{rgba:Q,index:A},globals:()=>[at],statements:({inputs:g,outputs:B})=>dA(`
if ((index >= 0) && (index < ${g.rgba}.count)) {
${B.rgba} = texelFetch(${g.rgba}.texture, splatTexCoord(index), 0);
`);function mn(g,A){return new T({inTypes:{rgba:Nt,index:"int"},outTypes:{rgba:"vec4"},inputs:{rgba:g,index:A},globals:()=>[pt],statements:({inputs:B,outputs:Q})=>fA(`
if ((index >= 0) && (index < ${B.rgba}.count)) {
${Q.rgba} = texelFetch(${B.rgba}.texture, splatTexCoord(index), 0);
} else {
${B.rgba} = vec4(0.0, 0.0, 0.0, 0.0);
${Q.rgba} = vec4(0.0, 0.0, 0.0, 0.0);
}
`)}).outputs.rgba}var et=(Q=>(Q.ALL="all",Q.PLANE="plane",Q.SPHERE="sphere",Q.BOX="box",Q.ELLIPSOID="ellipsoid",Q.CYLINDER="cylinder",Q.CAPSULE="capsule",Q.INFINITE_CONE="infinite_cone",Q))(et||{});function ke(Q){switch(Q){case"all":return 0;case"plane":return 1;case"sphere":return 2;case"box":return 3;case"ellipsoid":return 4;case"cylinder":return 5;case"capsule":return 6;case"infinite_cone":return 7;default:throw new Error(`Unknown SDF type: ${Q}`)}}var Dt=(Q=>(Q.MULTIPLY="multiply",Q.SET_RGB="set_rgb",Q.ADD_RGBA="add_rgba",Q))(Dt||{});function Fe(Q){switch(Q){case"multiply":return 0;case"set_rgb":return 1;case"add_rgba":return 2;default:throw new Error(`Unknown blend mode: ${Q}`)}}class nt extends e.Object3D{constructor(A={}){super();const{type:I,invert:g,opacity:B,color:C,displace:E,radius:t}=A;this.type=I??"sphere",this.invert=g??!1,this.opacity=B??1,this.color=C??new e.Color(1,1,1),this.displace=E??new e.Vector3(0,0,0),this.radius=t??0}}const aI=class aI extends e.Object3D{constructor(A={}){const{name:I,rgbaBlendMode:g="multiply",sdfSmooth:B=0,softEdge:C=0,invert:E=!1,sdfs:t=null}=A;super(),this.rgbaBlendMode=g,this.sdfSmooth=B,this.softEdge=C,this.invert=E,this.sdfs=t,this.ordering=aI.nextOrdering++,this.name=I??`Edit ${this.ordering}`}addSdf(A){this.sdfs==null&&(this.sdfs=[]),this.sdfs.push(A)}removeSdf(A){this.sdfs!=null&&(this.sdfs=this.sdfs.filter(I=>I!==A))}};aI.nextOrdering=1;let HQ=aI;class ct{constructor({maxSdfs:A,maxEdits:I}){this.maxSdfs=Math.max(16,A??0),this.numSdfs=0,this.sdfData=new Uint32Array(this.maxSdfs*8*4),this.sdfFloatData=new Float32Array(this.sdfData.buffer),this.sdfTexture=this.newSdfTexture(this.sdfData,this.maxSdfs),this.dynoSdfArray=new F({key:"sdfArray",type:wt,globals:()=>[rt],value:{numSdfs:0,sdfTexture:this.sdfTexture},update:g=>(g.numSdfs=this.numSdfs,g.sdfTexture=this.sdfTexture,g)}),this.maxEdits=Math.max(16,I??0),this.numEdits=0,this.editData=new Uint32Array(this.maxEdits*4),this.editFloatData=new Float32Array(this.editData.buffer),this.dynoNumEdits=new SQ({value:0}),this.dynoEdits=this.newEdits(this.editData,this.maxEdits)}newSdfTexture(A,I){const g=new e.DataTexture(A,8,I,e.RGBAIntegerFormat,e.UnsignedIntType);return g.internalFormat="RGBA32UI",g.needsUpdate=!0,g}newEdits(A,I){return new F({key:"edits",type:"uvec4",count:I,globals:()=>[ht],value:A})}ensureCapacity({maxSdfs:A,maxEdits:I}){let g=!1;return A>this.sdfTexture.image.height&&(this.sdfTexture.dispose(),this.maxSdfs=Math.max(this.maxSdfs*2,A),this.sdfData=new Uint32Array(this.maxSdfs*8*4),this.sdfFloatData=new Float32Array(this.sdfData.buffer),this.sdfTexture=this.newSdfTexture(this.sdfData,this.maxSdfs)),I>(this.dynoEdits.count??0)&&(this.maxEdits=Math.max(this.maxEdits*2,I),this.editData=new Uint32Array(this.maxEdits*4),this.editFloatData=new Float32Array(this.editData.buffer),this.dynoEdits=this.newEdits(this.editData,this.maxEdits),g=!0),g}updateEditData(A,I){const g=this.editData[A]!==I;return this.editData[A]=I,g}updateEditFloatData(A,I){aQ[0]=I;const g=this.editFloatData[A]!==aQ[0];return g&&(this.editFloatData[A]=aQ[0]),g}encodeEdit(A,{sdfFirst:I,sdfCount:g,invert:B,rgbaBlendMode:C,softEdge:E,sdfSmooth:t}){const s=A*4;let o=!1;return o=this.updateEditData(s+0,C|(B?256:0))||o,o=this.updateEditData(s+1,I|g<<16)||o,o=this.updateEditFloatData(s+2,E)||o,o=this.updateEditFloatData(s+3,t)||o,o}updateSdfData(A,I){const g=this.sdfData[A]!==I;return this.sdfData[A]=I,g}updateSdfFloatData(A,I){aQ[0]=I;const g=this.sdfFloatData[A]!==aQ[0];return g&&(this.sdfFloatData[A]=aQ[0]),g}encodeSdf(A,{sdfType:I,invert:g,center:B,quaternion:C,scale:E,sizes:t},s){const o=A*32,a=I|(g?256:0);let i=!1;i=this.updateSdfFloatData(o+0,(B==null?void 0:B.x)??0)||i,i=this.updateSdfFloatData(o+1,(B==null?void 0:B.y)??0)||i,i=this.updateSdfFloatData(o+2,(B==null?void 0:B.z)??0)||i,i=this.updateSdfData(o+3,a)||i,i=this.updateSdfFloatData(o+4,(C==null?void 0:C.x)??0)||i,i=this.updateSdfFloatData(o+5,(C==null?void 0:C.y)??0)||i,i=this.updateSdfFloatData(o+6,(C==null?void 0:C.z)??0)||i,i=this.updateSdfFloatData(o+7,(C==null?void 0:C.w)??0)||i,i=this.updateSdfFloatData(o+8,(E==null?void 0:E.x)??0)||i,i=this.updateSdfFloatData(o+9,(E==null?void 0:E.y)??0)||i,i=this.updateSdfFloatData(o+10,(E==null?void 0:E.z)??0)||i,i=this.updateSdfData(o+11,0)||i,i=this.updateSdfFloatData(o+12,(t==null?void 0:t.x)??0)||i,i=this.updateSdfFloatData(o+13,(t==null?void 0:t.y)??0)||i,i=this.updateSdfFloatData(o+14,(t==null?void 0:t.z)??0)||i,i=this.updateSdfFloatData(o+15,(t==null?void 0:t.w)??0)||i;const D=Math.min(4,s.length);for(let n=0;n<D;++n){const w=o+16+n*4;i=this.updateSdfFloatData(w+0,s[n].x)||i,i=this.updateSdfFloatData(w+1,s[n].y)||i,i=this.updateSdfFloatData(w+2,s[n].z)||i,i=this.updateSdfFloatData(w+3,s[n].w)||i}return i}update(A){const I=A.reduce((i,{sdfs:D})=>i+D.length,0),g=this.ensureCapacity({maxEdits:A.length,maxSdfs:I}),B=[new e.Vector4,new e.Vector4],C=new e.Vector3,E=new e.Quaternion,t=new e.Vector3,s=new e.Vector4;let o=0,a=g;A. Line truncated
`)}).outputs.rgba}var kt=(g=>(g.ALL="all",g.PLANE="plane",g.SPHERE="sphere",g.BOX="box",g.ELLIPSOID="ellipsoid",g.CYLINDER="cylinder",g.CAPSULE="capsule",g.INFINITE_CONE="infinite_cone",g))(kt||{});function fn(g){switch(g){case"all":return 0;case"plane":return 1;case"sphere":return 2;case"box":return 3;case"ellipsoid":return 4;case"cylinder":return 5;case"capsule":return 6;case"infinite_cone":return 7;default:throw new Error(`Unknown SDF type: ${g}`)}}var Ft=(g=>(g.MULTIPLY="multiply",g.SET_RGB="set_rgb",g.ADD_RGBA="add_rgba",g))(Ft||{});function Sn(g){switch(g){case"multiply":return 0;case"set_rgb":return 1;case"add_rgba":return 2;default:throw new Error(`Unknown blend mode: ${g}`)}}class Rt extends a.Object3D{constructor(A={}){super();const{type:I,invert:B,opacity:Q,color:C,displace:E,radius:t}=A;this.type=I??"sphere",this.invert=B??!1,this.opacity=Q??1,this.color=C??new a.Color(1,1,1),this.displace=E??new a.Vector3(0,0,0),this.radius=t??0}}const oI=class oI extends a.Object3D{constructor(A={}){const{name:I,rgbaBlendMode:B="multiply",sdfSmooth:Q=0,softEdge:C=0,invert:E=!1,sdfs:t=null}=A;super(),this.rgbaBlendMode=B,this.sdfSmooth=Q,this.softEdge=C,this.invert=E,this.sdfs=t,this.ordering=oI.nextOrdering++,this.name=I??`Edit ${this.ordering}`}addSdf(A){this.sdfs==null&&(this.sdfs=[]),this.sdfs.push(A)}removeSdf(A){this.sdfs!=null&&(this.sdfs=this.sdfs.filter(I=>I!==A))}};oI.nextOrdering=1;let bg=oI;class Jt{constructor({maxSdfs:A,maxEdits:I}){this.maxSdfs=Math.max(16,A??0),this.numSdfs=0,this.sdfData=new Uint32Array(this.maxSdfs*8*4),this.sdfFloatData=new Float32Array(this.sdfData.buffer),this.sdfTexture=this.newSdfTexture(this.sdfData,this.maxSdfs),this.dynoSdfArray=new S({key:"sdfArray",type:mt,globals:()=>[ft],value:{numSdfs:0,sdfTexture:this.sdfTexture},update:B=>(B.numSdfs=this.numSdfs,B.sdfTexture=this.sdfTexture,B)}),this.maxEdits=Math.max(16,I??0),this.numEdits=0,this.editData=new Uint32Array(this.maxEdits*4),this.editFloatData=new Float32Array(this.editData.buffer),this.dynoNumEdits=new Yg({value:0}),this.dynoEdits=this.newEdits(this.editData,this.maxEdits)}newSdfTexture(A,I){const B=new a.DataTexture(A,8,I,a.RGBAIntegerFormat,a.UnsignedIntType);return B.internalFormat="RGBA32UI",B.needsUpdate=!0,B}newEdits(A,I){return new S({key:"edits",type:"uvec4",count:I,globals:()=>[St],value:A})}ensureCapacity({maxSdfs:A,maxEdits:I}){let B=!1;return A>this.sdfTexture.image.height&&(this.sdfTexture.dispose(),this.maxSdfs=Math.max(this.maxSdfs*2,A),this.sdfData=new Uint32Array(this.maxSdfs*8*4),this.sdfFloatData=new Float32Array(this.sdfData.buffer),this.sdfTexture=this.newSdfTexture(this.sdfData,this.maxSdfs)),I>(this.dynoEdits.count??0)&&(this.maxEdits=Math.max(this.maxEdits*2,I),this.editData=new Uint32Array(this.maxEdits*4),this.editFloatData=new Float32Array(this.editData.buffer),this.dynoEdits=this.newEdits(this.editData,this.maxEdits),B=!0),B}updateEditData(A,I){const B=this.editData[A]!==I;return this.editData[A]=I,B}updateEditFloatData(A,I){og[0]=I;const B=this.editFloatData[A]!==og[0];return B&&(this.editFloatData[A]=og[0]),B}encodeEdit(A,{sdfFirst:I,sdfCount:B,invert:Q,rgbaBlendMode:C,softEdge:E,sdfSmooth:t}){const i=A*4;let e=!1;return e=this.updateEditData(i+0,C|(Q?256:0))||e,e=this.updateEditData(i+1,I|B<<16)||e,e=this.updateEditFloatData(i+2,E)||e,e=this.updateEditFloatData(i+3,t)||e,e}updateSdfData(A,I){const B=this.sdfData[A]!==I;return this.sdfData[A]=I,B}updateSdfFloatData(A,I){og[0]=I;const B=this.sdfFloatData[A]!==og[0];return B&&(this.sdfFloatData[A]=og[0]),B}encodeSdf(A,{sdfType:I,invert:B,center:Q,quaternion:C,scale:E,sizes:t},i){const e=A*32,n=I|(B?256:0);let s=!1;s=this.updateSdfFloatData(e+0,(Q==null?void 0:Q.x)??0)||s,s=this.updateSdfFloatData(e+1,(Q==null?void 0:Q.y)??0)||s,s=this.updateSdfFloatData(e+2,(Q==null?void 0:Q.z)??0)||s,s=this.updateSdfData(e+3,n)||s,s=this.updateSdfFloatData(e+4,(C==null?void 0:C.x)??0)||s,s=this.updateSdfFloatData(e+5,(C==null?void 0:C.y)??0)||s,s=this.updateSdfFloatData(e+6,(C==null?void 0:C.z)??0)||s,s=this.updateSdfFloatData(e+7,(C==null?void 0:C.w)??0)||s,s=this.updateSdfFloatData(e+8,(E==null?void 0:E.x)??0)||s,s=this.updateSdfFloatData(e+9,(E==null?void 0:E.y)??0)||s,s=this.updateSdfFloatData(e+10,(E==null?void 0:E.z)??0)||s,s=this.updateSdfData(e+11,0)||s,s=this.updateSdfFloatData(e+12,(t==null?void 0:t.x)??0)||s,s=this.updateSdfFloatData(e+13,(t==null?void 0:t.y)??0)||s,s=this.updateSdfFloatData(e+14,(t==null?void 0:t.z)??0)||s,s=this.updateSdfFloatData(e+15,(t==null?void 0:t.w)??0)||s;const o=Math.min(4,i.length);for(let r=0;r<o;++r){const c=e+16+r*4;s=this.updateSdfFloatData(c+0,i[r].x)||s,s=this.updateSdfFloatData(c+1,i[r].y)||s,s=this.updateSdfFloatData(c+2,i[r].z)||s,s=this.updateSdfFloatData(c+3,i[r].w)||s}return s}update(A){const I=A.reduce((s,{sdfs:o})=>s+o.length,0),B=this.ensureCapacity({maxEdits:A.length,maxSdfs:I}),Q=[new a.Vector4,new a.Vector4],C=new a.Vector3,E=new a.Quaternion,t=new a.Vector3,i=new a.Vector4;let e=0,n=B;A. Line truncated
struct SdfArray {
int numSdfs;
usampler2D sdfTexture;
@@ -308,7 +308,7 @@ void main() {
return (softEdge == 0.0) ? ((distance < 0.0) ? 1.0 : 0.0)
: clamp(-distance / softEdge + 0.5, 0.0, 1.0);
}
`),ht=gA(`
`),St=nA(`
const uint EDIT_FLAG_BLEND = 0xFFu;
const uint EDIT_BLEND_MULTIPLY = 0u;
const uint EDIT_BLEND_SET_RGB = 1u;
@@ -366,17 +366,17 @@ void main() {
decodeEdit(packedEdit, sdfFirst, sdfCount, invert, rgbaBlendMode, softEdge, sdfSmooth);
applyRgbaDisplaceEdit(sdfTexture, numSdfs, sdfFirst, sdfCount, pos, sdfSmooth, softEdge, invert, rgbaBlendMode, rgba);
}
`);function Re(Q,A,I,g){return new f({inTypes:{gsplat:T,sdfArray:wt,numEdits:"int",rgbaDisplaceEdits:"uvec4"},outTypes:{gsplat:T},globals:()=>[rt,ht],inputs:{gsplat:Q,sdfArray:A,numEdits:I,rgbaDisplaceEdits:g},statements:({inputs:C,outputs:E})=>{const{sdfArray:t,numEdits:s,rgbaDisplaceEdits:o}=C,{gsplat:a}=E;return dA(`
${a} = ${C.gsplat};
if (isGsplatActive(${a}.flags)) {
for (int editIndex = 0; editIndex < ${s}; ++editIndex) {
`);function Yn(g,A,I,B){return new T({inTypes:{gsplat:BA,sdfArray:mt,numEdits:"int",rgbaDisplaceEdits:"uvec4"},outTypes:{gsplat:BA},globals:()=>[ft,St],inputs:{gsplat:g,sdfArray:A,numEdits:I,rgbaDisplaceEdits:B},statements:({inputs:C,outputs:E})=>{const{sdfArray:t,numEdits:i,rgbaDisplaceEdits:e}=C,{gsplat:n}=E;return fA(`
${n} = ${C.gsplat};
if (isGsplatActive(${n}.flags)) {
for (int editIndex = 0; editIndex < ${i}; ++editIndex) {
applyPackedRgbaDisplaceEdit(
${o}[editIndex], ${t}.sdfTexture, ${t}.numSdfs,
${a}.center, ${a}.rgba
${e}[editIndex], ${t}.sdfTexture, ${t}.numSdfs,
${n}.center, ${n}.rgba
);
}
}
`)}}).outputs.gsplat}const aQ=new Float32Array(1);class yt{constructor(A){this.modifier=A,this.cache=new Map}apply(A){let I=this.cache.get(A);return I||(I=SA({index:"int"},{gsplat:T},({index:g})=>{const{gsplat:B}=A.apply({index:g});return this.modifier.apply({gsplat:B})}),this.cache.set(A,I)),I}}class CQ{constructor(){this.scale=new EQ({value:Number.NEGATIVE_INFINITY}),this.rotate=new qQ({value:new e.Quaternion(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}),this.translate=new hQ({value:new e.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)})}modify(A){return SI(A,{scale:this.scale,rotate:this.rotate,translate:this.translate})}updateFromMatrix(A){const I=new e.Vector3,g=new e.Quaternion,B=new e.Vector3;A.decompose(B,g,I);const C=(I.x+I.y+I.z)/3;let E=!1;return C!==this.scale.value&&(this.scale.value=C,E=!0),B.equals(this.translate.value)||(this.translate.value.copy(B),E=!0),g.equals(this.rotate.value)||(this.rotate.value.copy(g),E=!0),E}update(A){return this.updateFromMatrix(A.matrixWorld)}}class TQ extends e.Object3D{constructor({numSplats:A,generator:I,construct:g,update:B}){if(super(),this.numSplats=A??0,this.generator=I,this.frameUpdate=B,this.version=0,g){const C=g(this);Object.assign(this,C)}}updateVersion(){this.version+=1}set needsUpdate(A){A&&this.updateVersion()}}const XA=class XA extends TQ{constructor(A={}){const I=new CQ,g=new CQ,B=new CQ,C=new CQ,E=new qQ({value:new e.Vector4(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY)}),t=new EQ({value:0}),s=new EQ({value:0}),o={transform:I,viewToWorld:g,worldToView:B,viewToObject:C,recolor:E,time:t,deltaTime:s};if(super({update:({time:a,deltaTime:i,viewToWorld:D,globalEdits:n})=>this.update({time:a,deltaTime:i,viewToWorld:D,globalEdits:n})}),this.isInitialized=!1,this.recolor=new e.Color(1,1,1),this.opacity=1,this.enableViewToObject=!1,this.enableViewToWorld=!1,this.enableWorldToView=!1,this.skinning=null,this.edits=null,this.rgbaDisplaceEdits=null,this.splatRgba=null,this.maxSh=3,this.packedSplats=A.packedSplats??new UA,this.numSplats=this.packedSplats.numSplats,this.editable=A.editable??!0,this.onFrame=A.onFrame,this.context=o,this.objectModifier=A.objectModifier,this.worldModifier=A.worldModifier,this.updateGenerator(),A.url||A.fileBytes||A.constructSplats||A.packedSplats&&!A.packedSplats.isInitialized)this.initialized=this.asyncInitialize(A).then(async()=>{if(this.updateGenerator(),this.isInitialized=!0,A.onLoad){const a=A.onLoad(this);a instanceof Promise&&await a}return this});else if(this.isInitialized=!0,this.initialized=Promise.resolve(this),A.onLoad){const a=A.onLoad(this);a instanceof Promise&&(this.initialized=a.then(()=>this))}}async asyncInitialize(A){const{url:I,fileBytes:g,fileType:B,maxSplats:C,constructSplats:E}=A;if(I||g||E){const t={url:I,fileBytes:g,fileType:B,maxSplats:C,construct:E};this.packedSplats.reinitialize(t),this.updateGenerator()}this.packedSplats&&(await this.packedSplats.initialized,this.numSplats=this.packedSplats.numSplats)}static async staticInitialize(){await $I(),XA.isStaticInitialized=!0}pushSplat(A,I,g,B,C){this.packedSplats.pushSplat(A,I,g,B,C)}forEachSplat(A){this.packedSplats.forEachSplat(A)}dispose(){this.packedSplats.dispose()}constructGenerator({transform:A,viewToObject:I,recolor:g}){const B=SA({index:"int"},{gsplat:T},({index:C})=>{if(!C)throw new Error("index is undefined");let E=UQ(this.packedSplats.dyno,C);if(this.maxSh>=1){const{sh1Texture:s,sh2Texture:o,sh3Texture:a}=this.ensureShTextures();if(s){const i=I.translate,{center:D}=FQ(E).outputs,n=tE(LQ(D,i));let w=ue(E,s,n);this.maxSh>=2&&o&&(w=wA(w,Ue(E,o,n))),this.maxSh>=3&&a&&(w=wA(w,Se(E,a,n)));let{rgba:c}=FQ(E).outputs;c=wA(c,iE(w,q("float",0))),E=rQ({gsplat:E,rgba:c})}}if(this.splatRgba){const s=Ne(this.splatRgba.dyno,C);E=rQ({gsplat:E,rgba:s})}this.skinning&&(E=this.skinning.modify(E)),this.objectModifier&&(E=this.objectModifier.apply({gsplat:E}).gsplat),E=A.modify(E);const t=CA(g,FQ(E).outputs.rgba);return E=rQ({gsplat:E,rgba:t}),this.rgbaDisplaceEdits&&(E=this.rgbaDisplaceEdits.modify(E)),this.worldModifier&&(E=this.worldModifier.apply({gsplat:E}).gsplat),{gsplat:E}});this.generator=B}updateGenerator(){this.constructGenerator(this.context)}update({time:A,viewToWorld:I,deltaTime:g,globalEdits:B}){var r;this.numSplats=this.packedSplats.numSplats,this.context.time.value=A,this.context.deltaTime.value=g,XA.dynoTime.value=A;const{transform:C,viewToObject:E,recolor:t}=this.context;let s=C.update(this);this.context.viewToWorld.updateFromMatrix(I)&&this.enableViewToWorld&&(s=!0);const o=I.clone().invert();this.context.worldToView.updateFromMatrix(o)&&this.enableWorldToView&&(s=!0);const D=new e.Matrix4().compose(C.translate.value,C.rotate.value,new e.Vector3().setScalar(C.scale.value)).invert().multiply(I);E.updateFromMatrix(D)&&(this.enableViewToObject||this.packedSplats.extra.sh1)&&(s=!0);const n=new e.Vec Line truncated
`)}}).outputs.gsplat}const og=new Float32Array(1);class Yt{constructor(A){this.modifier=A,this.cache=new Map}apply(A){let I=this.cache.get(A);return I||(I=UA({index:"int"},{gsplat:BA},({index:B})=>{const{gsplat:Q}=A.apply({index:B});return this.modifier.apply({gsplat:Q})}),this.cache.set(A,I)),I}}class tg{constructor(){this.scale=new ig({value:Number.NEGATIVE_INFINITY}),this.rotate=new Tg({value:new a.Quaternion(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}),this.translate=new yg({value:new a.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)})}apply(A){return At(A,{scale:this.scale,rotate:this.rotate,translate:this.translate})}applyDir(A){return gt(A,{rotate:this.rotate})}applyGsplat(A){return vI(A,{scale:this.scale,rotate:this.rotate,translate:this.translate})}updateFromMatrix(A){const I=new a.Vector3,B=new a.Quaternion,Q=new a.Vector3;A.decompose(Q,B,I);const C=(I.x+I.y+I.z)/3;let E=!1;return C!==this.scale.value&&(this.scale.value=C,E=!0),Q.equals(this.translate.value)||(this.translate.value.copy(Q),E=!0),B.equals(this.rotate.value)||(this.rotate.value.copy(B),E=!0),E}update(A){return A.updateMatrixWorld(),this.updateFromMatrix(A.matrixWorld)}}class jg extends a.Object3D{constructor({numSplats:A,generator:I,construct:B,update:Q}){if(super(),this.numSplats=A??0,this.generator=I,this.frameUpdate=Q,this.version=0,B){const C=B(this);Object.assign(this,C)}}updateVersion(){this.version+=1}set needsUpdate(A){A&&this.updateVersion()}}const PA=class PA extends jg{constructor(A={}){const I=new tg,B=new tg,Q=new tg,C=new tg,E=new Tg({value:new a.Vector4(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY)}),t=new ig({value:0}),i=new ig({value:0}),e={transform:I,viewToWorld:B,worldToView:Q,viewToObject:C,recolor:E,time:t,deltaTime:i};if(super({update:({time:n,deltaTime:s,viewToWorld:o,globalEdits:r})=>this.update({time:n,deltaTime:s,viewToWorld:o,globalEdits:r})}),this.isInitialized=!1,this.recolor=new a.Color(1,1,1),this.opacity=1,this.enableViewToObject=!1,this.enableViewToWorld=!1,this.enableWorldToView=!1,this.skinning=null,this.edits=null,this.rgbaDisplaceEdits=null,this.splatRgba=null,this.maxSh=3,this.packedSplats=A.packedSplats??new YA,this.numSplats=this.packedSplats.numSplats,this.editable=A.editable??!0,this.onFrame=A.onFrame,this.context=e,this.objectModifier=A.objectModifier,this.worldModifier=A.worldModifier,this.updateGenerator(),A.url||A.fileBytes||A.constructSplats||A.packedSplats&&!A.packedSplats.isInitialized)this.initialized=this.asyncInitialize(A).then(async()=>{if(this.updateGenerator(),this.isInitialized=!0,A.onLoad){const n=A.onLoad(this);n instanceof Promise&&await n}return this});else if(this.isInitialized=!0,this.initialized=Promise.resolve(this),A.onLoad){const n=A.onLoad(this);n instanceof Promise&&(this.initialized=n.then(()=>this))}}async asyncInitialize(A){const{url:I,fileBytes:B,fileType:Q,fileName:C,maxSplats:E,constructSplats:t}=A;if(I||B||t){const i={url:I,fileBytes:B,fileType:Q,fileName:C,maxSplats:E,construct:t};this.packedSplats.reinitialize(i)}this.packedSplats&&(await this.packedSplats.initialized,this.numSplats=this.packedSplats.numSplats,this.updateGenerator())}static async staticInitialize(){await ZI(),PA.isStaticInitialized=!0}pushSplat(A,I,B,Q,C){this.packedSplats.pushSplat(A,I,B,Q,C)}forEachSplat(A){this.packedSplats.forEachSplat(A)}dispose(){this.packedSplats.dispose()}constructGenerator(A){const{transform:I,viewToObject:B,recolor:Q}=A,C=UA({index:"int"},{gsplat:BA},({index:E})=>{if(!E)throw new Error("index is undefined");let t=Sg(this.packedSplats.dyno,E);if(this.maxSh>=1){const{sh1Texture:e,sh2Texture:n,sh3Texture:s}=this.ensureShTextures();if(e){const o=B.translate,{center:r}=kg(t).outputs,c=yE(xg(r,o));let h=bn(t,e,c);this.maxSh>=2&&n&&(h=pA(h,Hn(t,n,c))),this.maxSh>=3&&s&&(h=pA(h,Kn(t,s,c)));let{rgba:w}=kg(t).outputs;w=pA(w,uE(h,gA("float",0))),t=lg({gsplat:t,rgba:w})}}if(this.splatRgba){const e=mn(this.splatRgba.dyno,E);t=lg({gsplat:t,rgba:e})}this.skinning&&(t=this.skinning.modify(t)),this.objectModifier&&(t=this.objectModifier.apply({gsplat:t}).gsplat),t=I.applyGsplat(t);const i=cA(Q,kg(t).outputs.rgba);return t=lg({gsplat:t,rgba:i}),this.rgbaDisplaceEdits&&(t=this.rgbaDisplaceEdits.modify(t)),this.worldModifier&&(t=this.worldModifier.apply({gsplat:t}).gsplat),{gsplat:t}});this.generator=C}updateGenerator(){this.constructGenerator(this.context)}update({time:A,viewToWorld:I,deltaTime:B,globalEdits:Q}){var w;this.numSplats=this.packedSplats.numSplats,this.context.time.value=A,this.context.deltaTime.value=B,PA.dynoTime.value=A;const{transform:C,viewToObject:E,recolor:t}=this.context;let i=C.update(this);this.context.viewToWorld.updateFromMatrix(I)&&this.enableViewToWorld&&(i=!0);const e=I.clone().invert();this.context.worldToView.updateFromMatrix(e)&&this.enableWorldToView&&(i=!0);const o=new a.Matrix4().compose(C.transl Line truncated
vec3 evaluateSH1(Gsplat gsplat, usampler2DArray sh1, vec3 viewDir) {
// Extract sint7 values packed into 2 x uint32
uvec2 packed = texelFetch(sh1, splatTexCoord(gsplat.index), 0).rg;
@@ -400,7 +400,7 @@ void main() {
+ sh1_1 * (0.4886025 * viewDir.z)
+ sh1_2 * (-0.4886025 * viewDir.x);
}
`),de=gA(`
`),xn=nA(`
vec3 evaluateSH2(Gsplat gsplat, usampler2DArray sh2, vec3 viewDir) {
// Extract sint8 values packed into 4 x uint32
uvec4 packed = texelFetch(sh2, splatTexCoord(gsplat.index), 0);
@@ -436,7 +436,7 @@ void main() {
+ sh2_3 * (1.0925484 * viewDir.x * viewDir.z)
+ sh2_4 * (0.5462742 * (viewDir.x * viewDir.x - viewDir.y * viewDir.y));
}
`),Ye=gA(`
`),Ln=nA(`
vec3 evaluateSH3(Gsplat gsplat, usampler2DArray sh3, vec3 viewDir) {
// Extract sint6 values packed into 4 x uint32
uvec4 packed = texelFetch(sh3, splatTexCoord(gsplat.index), 0);
@@ -491,27 +491,27 @@ void main() {
+ sh3_5 * (1.4453057 * viewDir.z * (xx - yy))
+ sh3_6 * (-0.5900436 * viewDir.x * (xx - 3.0 * yy));
}
`);function ue(Q,A,I){return KQ({inTypes:{gsplat:T,sh1:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:Q,sh1:A,viewDir:I},globals:()=>[hA,Je],statements:({inputs:g,outputs:B})=>dA(`
if (isGsplatActive(${g.gsplat}.flags)) {
${B.rgb} = evaluateSH1(${g.gsplat}, ${g.sh1}, ${g.viewDir});
`);function bn(g,A,I){return Wg({inTypes:{gsplat:BA,sh1:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:g,sh1:A,viewDir:I},globals:()=>[kA,Un],statements:({inputs:B,outputs:Q})=>fA(`
if (isGsplatActive(${B.gsplat}.flags)) {
${Q.rgb} = evaluateSH1(${B.gsplat}, ${B.sh1}, ${B.viewDir});
} else {
${B.rgb} = vec3(0.0);
${Q.rgb} = vec3(0.0);
}
`)}).outputs.rgb}function Ue(Q,A,I){return KQ({inTypes:{gsplat:T,sh2:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:Q,sh2:A,viewDir:I},globals:()=>[hA,de],statements:({inputs:g,outputs:B})=>dA(`
if (isGsplatActive(${g.gsplat}.flags)) {
${B.rgb} = evaluateSH2(${g.gsplat}, ${g.sh2}, ${g.viewDir});
`)}).outputs.rgb}function Hn(g,A,I){return Wg({inTypes:{gsplat:BA,sh2:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:g,sh2:A,viewDir:I},globals:()=>[kA,xn],statements:({inputs:B,outputs:Q})=>fA(`
if (isGsplatActive(${B.gsplat}.flags)) {
${Q.rgb} = evaluateSH2(${B.gsplat}, ${B.sh2}, ${B.viewDir});
} else {
${B.rgb} = vec3(0.0);
${Q.rgb} = vec3(0.0);
}
`)}).outputs.rgb}function Se(Q,A,I){return KQ({inTypes:{gsplat:T,sh3:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:Q,sh3:A,viewDir:I},globals:()=>[hA,Ye],statements:({inputs:g,outputs:B})=>dA(`
if (isGsplatActive(${g.gsplat}.flags)) {
${B.rgb} = evaluateSH3(${g.gsplat}, ${g.sh3}, ${g.viewDir});
`)}).outputs.rgb}function Kn(g,A,I){return Wg({inTypes:{gsplat:BA,sh3:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:g,sh3:A,viewDir:I},globals:()=>[kA,Ln],statements:({inputs:B,outputs:Q})=>fA(`
if (isGsplatActive(${B.gsplat}.flags)) {
${Q.rgb} = evaluateSH3(${B.gsplat}, ${B.sh3}, ${B.viewDir});
} else {
${B.rgb} = vec3(0.0);
${Q.rgb} = vec3(0.0);
}
`)}).outputs.rgb}const cQ=class cQ{constructor({fileBytes:A}){this.header="",this.littleEndian=!0,this.elements={},this.comments=[],this.data=null,this.numSplats=0,this.fileBytes=A instanceof ArrayBuffer?new Uint8Array(A):A}async parseHeader(){const I=new ReadableStream({start:E=>{E.enqueue(this.fileBytes.slice(0,65536)),E.close()}}).pipeThrough(new TextDecoderStream).getReader();this.header="";const g=`end_header
`;for(;;){const{value:E,done:t}=await I.read();if(t)throw new Error("Failed to read header");this.header+=E;const s=this.header.indexOf(g);if(s>=0){this.header=this.header.slice(0,s+g.length);break}}const B=new TextEncoder().encode(this.header).length;this.data=new DataView(this.fileBytes.buffer,B),this.elements={};let C=null;this.comments=[],this.header.trim().split(`
`).forEach((E,t)=>{const s=E.trim();if(t===0){if(s!=="ply")throw new Error("Invalid PLY header");return}if(s.length===0)return;const o=s.split(" ");switch(o[0]){case"format":if(o[1]==="binary_little_endian")this.littleEndian=!0;else if(o[1]==="binary_big_endian")this.littleEndian=!1;else throw new Error(`Unsupported PLY format: ${o[1]}`);if(o[2]!=="1.0")throw new Error(`Unsupported PLY version: ${o[2]}`);break;case"end_header":break;case"comment":this.comments.push(s.slice(8));break;case"element":{const a=o[1];C={name:a,count:Number.parseInt(o[2]),properties:{}},this.elements[a]=C;break}case"property":if(C==null)throw new Error("Property must be inside an element");o[1]==="list"?C.properties[o[4]]={isList:!0,type:o[3],countType:o[2]}:C.properties[o[2]]={isList:!1,type:o[1]};break}}),this.elements.vertex&&(this.numSplats=this.elements.vertex.count)}parseData(A){let I=0;const g=this.data;if(g==null)throw new Error("No data to parse");for(const B in this.elements){const C=this.elements[B],{count:E,properties:t}=C,s={},o=[];for(const[i,D]of Object.entries(t))D.isList?(s[i]=[],o.push(()=>{const n=s[i];n.length=jQ[D.countType](g,I,this.littleEndian),I+=eQ[D.countType];for(let w=0;w<n.length;w++)n[w]=jQ[D.type](g,I,this.littleEndian),I+=eQ[D.type]})):(s[i]=0,o.push(()=>{s[i]=jQ[D.type](g,I,this.littleEndian),I+=eQ[D.type]}));const a=A(C)??(()=>{});for(let i=0;i<E;i++){for(const D of o)D();a(i,s)}}}parseSplats(A,I){if(this.elements.vertex==null)throw new Error("No vertex element found");let g=!1;const B=[];let C=0,E=[],t=[],s=[],o,a,i;function D(){const y=pe[C];E=new Array(3).fill(null).flatMap((G,h)=>[0,1,2].map((M,l)=>`f_rest_${h+l*y/3}`)),t=new Array(5).fill(null).flatMap((G,h)=>[0,1,2].map((M,l)=>`f_rest_${3+h+l*y/3}`)),s=new Array(7).fill(null).flatMap((G,h)=>[0,1,2].map((M,l)=>`f_rest_${8+h+l*y/3}`)),o=C>=1?new Float32Array(3*3):void 0,a=C>=2?new Float32Array(5*3):void 0,i=C>=3?new Float32Array(7*3):void 0}function n(y,G){if(!o)throw new Error("Missing sh1");for(const[h,M]of E.entries())o[h]=G[M]*8/255-4;if(a)for(const[h,M]of t.entries())a[h]=G[M]*8/255-4;if(i)for(const[h,M]of s.entries())i[h]=G[M]*8/255-4;I==null||I(y,o,a,i)}function w(y){const{min_x:G,min_y:h,min_z:M,max_x:l,max_y:k,max_z:R,min_scale_x:d,min_scale_y:Y,min_scale_z:m,max_scale_x:J,max_scale_y:x,max_scale_z:U,min_r:S,min_g:v,min_b:V,max_r:_,max_g:$,max_b:X}=y.properties;if(!G||!h||!M||!l||!k||!R||!d||!Y||!m||!J||!x||!U||!S||!v||!V||!_||!$||!X)throw new Error("Missing PLY chunk properties");return g=!0,(eA,AA)=>{const{min_x:sA,min_y:DA,min_z:YA,max_x:yA,max_y:nA,max_z:L,min_scale_x:GA,min_scale_y:BA,min_scale_z:lA,max_scale_x:MA,max_scale_y:LA,max_scale_z:NA,min_r:xA,min_g:kA,min_b:qA,max_r:WA,max_g:VA,max_b:cA}=AA;B.push({min_x:sA,min_y:DA,min_z:YA,max_x:yA,max_y:nA,max_z:L,min_scale_x:GA,min_scale_y:BA,min_scale_z:lA,max_scale_x:MA,max_scale_y:LA,max_scale_z:NA,min_r:xA,min_g:kA,min_b:qA,max_r:WA,max_g:VA,max_b:cA})}}function c(y){if(I&&y.name==="sh")return C=XI(y.properties),D(),n;if(y.name!=="vertex")return null;const{packed_position:G,packed_rotation:h,packed_scale:M,packed_color:l}=y.properties;if(!G||!h||!M||!l)throw new Error("Missing PLY properties: packed_position, packed_rotation, packed_scale, packed_color");const k=Math.sqrt(2);return(R,d)=>{const Y=B[R>>>8];if(Y==null)throw new Error("Missing PLY chunk");const{min_x:m,min_y:J,min_z:x,max_x:U,max_y:S,max_z:v,min_scale_x:V,min_scale_y:_,min_scale_z:$,max_scale_x:X,max_scale_y:eA,max_scale_z:AA,min_r:sA,min_g:DA,min_b:YA,max_r:yA,max_g:nA,max_b:L}=Y,{packed_position:GA,packed_rotation:BA,packed_scale:lA,packed_color:MA}=d,LA=(GA>>>21&2047)/2047*(U-m)+m,NA=(GA>>>11&1023)/1023*(S-J)+J,xA=(GA&2047)/2047*(v-x)+x,kA=((BA>>>20&1023)/1023-.5)*k,qA=((BA>>>10&1023)/1023-.5)*k,WA=((BA&1023)/1023-.5)*k,VA=Math.sqrt(Math.max(0,1-kA*kA-qA*qA-WA*WA)),cA=BA>>>30,$A=cA===0?kA:cA===1?VA:qA,pt=cA<=1?qA:cA===2?VA:WA,Ht=cA<=2?WA:VA,ft=cA===0?VA:kA,mt=Math.exp((lA>>>21&2047)/2047*(X-V)+V),bt=Math.exp((lA>>>11&1023)/1023*(eA-_)+_),xt=Math.exp((lA&2047)/2047*(AA-$)+$),Kt=(MA>>>24&255)/255*(yA-sA)+sA,Zt=(MA>>>16&255)/255*(nA-DA)+DA,qt=(MA>>>8&255)/255*(L-YA)+YA,Wt=(MA&255)/255;A(R,LA,NA,xA,mt,bt,xt,$A,pt,Ht,ft,Wt,Kt,Zt,qt)}}const r=y=>{if(y.name==="chunk"&&this.comments.some(nA=>nA.toLowerCase().includes("supersplat")))return w(y);if(g)return c(y);if(y.name!=="vertex")return null;const{x:G,y:h,z:M,scale_0:l,scale_1:k,scale_2:R,rot_0:d,rot_1:Y,rot_2:m,rot_3:J,opacity:x,f_dc_0:U,f_dc_1:S,f_dc_2:v,red:V,green:_,blue:$,alpha:X}=y.properties;if(!G||!h||!M)throw new Error("Missing PLY properties: x, y, z");const eA=l&&k&&R,AA=d&&Y&&m&&J,sA=X!=null?zQ[X.type]:1,DA=V!=null?zQ[V.type]:1,YA=_!=null?zQ[_.type]:1,yA=$!=null?zQ[$.type]:1;return C=XI(y.properties),D(),(nA,L)=>{const GA=eA?Math.exp(L.scale_0):cQ.defaultPointScale,BA=eA?Math.exp(L.scale_1):cQ.defaultPointScale,lA=eA?Math.exp(L.scale_2):cQ.defaultPointScale,MA=AA?L.rot_1:0,LA=AA?L.rot_2:0,NA=AA?L.rot_3:0,xA=AA?L.rot_0:1,kA=x!=null?1/(1+Math.exp(-L.opacity) Line truncated
`)}).outputs.rgb}const wg=class wg{constructor({fileBytes:A}){this.header="",this.littleEndian=!0,this.elements={},this.comments=[],this.data=null,this.numSplats=0,this.fileBytes=A instanceof ArrayBuffer?new Uint8Array(A):A}async parseHeader(){const I=new ReadableStream({start:E=>{E.enqueue(this.fileBytes.slice(0,65536)),E.close()}}).pipeThrough(new TextDecoderStream).getReader();this.header="";const B=`end_header
`;for(;;){const{value:E,done:t}=await I.read();if(t)throw new Error("Failed to read header");this.header+=E;const i=this.header.indexOf(B);if(i>=0){this.header=this.header.slice(0,i+B.length);break}}const Q=new TextEncoder().encode(this.header).length;this.data=new DataView(this.fileBytes.buffer,Q),this.elements={};let C=null;this.comments=[],this.header.trim().split(`
`).forEach((E,t)=>{const i=E.trim();if(t===0){if(i!=="ply")throw new Error("Invalid PLY header");return}if(i.length===0)return;const e=i.split(" ");switch(e[0]){case"format":if(e[1]==="binary_little_endian")this.littleEndian=!0;else if(e[1]==="binary_big_endian")this.littleEndian=!1;else throw new Error(`Unsupported PLY format: ${e[1]}`);if(e[2]!=="1.0")throw new Error(`Unsupported PLY version: ${e[2]}`);break;case"end_header":break;case"comment":this.comments.push(i.slice(8));break;case"element":{const n=e[1];C={name:n,count:Number.parseInt(e[2]),properties:{}},this.elements[n]=C;break}case"property":if(C==null)throw new Error("Property must be inside an element");e[1]==="list"?C.properties[e[4]]={isList:!0,type:e[3],countType:e[2]}:C.properties[e[2]]={isList:!1,type:e[1]};break}}),this.elements.vertex&&(this.numSplats=this.elements.vertex.count)}parseData(A){let I=0;const B=this.data;if(B==null)throw new Error("No data to parse");for(const Q in this.elements){const C=this.elements[Q],{count:E,properties:t}=C,i={},e=[];for(const[s,o]of Object.entries(t))o.isList?(i[s]=[],e.push(()=>{const r=i[s];r.length=_g[o.countType](B,I,this.littleEndian),I+=rg[o.countType];for(let c=0;c<r.length;c++)r[c]=_g[o.type](B,I,this.littleEndian),I+=rg[o.type]})):(i[s]=0,e.push(()=>{i[s]=_g[o.type](B,I,this.littleEndian),I+=rg[o.type]}));const n=A(C)??(()=>{});for(let s=0;s<E;s++){for(const o of e)o();n(s,i)}}}parseSplats(A,I){if(this.elements.vertex==null)throw new Error("No vertex element found");let B=!1;const Q=[];let C=0,E=[],t=[],i=[],e,n,s;function o(){const D=qn[C];E=new Array(3).fill(null).flatMap((y,l)=>[0,1,2].map((d,u)=>`f_rest_${l+u*D/3}`)),t=new Array(5).fill(null).flatMap((y,l)=>[0,1,2].map((d,u)=>`f_rest_${3+l+u*D/3}`)),i=new Array(7).fill(null).flatMap((y,l)=>[0,1,2].map((d,u)=>`f_rest_${8+l+u*D/3}`)),e=C>=1?new Float32Array(3*3):void 0,n=C>=2?new Float32Array(5*3):void 0,s=C>=3?new Float32Array(7*3):void 0}function r(D,y){if(!e)throw new Error("Missing sh1");for(const[l,d]of E.entries())e[l]=y[d]*8/255-4;if(n)for(const[l,d]of t.entries())n[l]=y[d]*8/255-4;if(s)for(const[l,d]of i.entries())s[l]=y[d]*8/255-4;I==null||I(D,e,n,s)}function c(D){const{min_x:y,min_y:l,min_z:d,max_x:u,max_y:p,max_z:m,min_scale_x:M,min_scale_y:G,min_scale_z:J,max_scale_x:k,max_scale_y:N,max_scale_z:Y,min_r:F,min_g:f,min_b:U,max_r:L,max_g:K,max_b:Z}=D.properties;if(!y||!l||!d||!u||!p||!m||!M||!G||!J||!k||!N||!Y||!F||!f||!U||!L||!K||!Z)throw new Error("Missing PLY chunk properties");return B=!0,(QA,z)=>{const{min_x:AA,min_y:$,min_z:P,max_x:j,max_y:V,max_z:x,min_scale_x:dA,min_scale_y:sA,min_scale_z:b,max_scale_x:oA,max_scale_y:rA,max_scale_z:H,min_r:FA,min_g:NA,min_b:xA,max_r:LA,max_g:bA,max_b:yA}=z;Q.push({min_x:AA,min_y:$,min_z:P,max_x:j,max_y:V,max_z:x,min_scale_x:dA,min_scale_y:sA,min_scale_z:b,max_scale_x:oA,max_scale_y:rA,max_scale_z:H,min_r:FA,min_g:NA,min_b:xA,max_r:LA,max_g:bA,max_b:yA})}}function h(D){if(I&&D.name==="sh")return C=CB(D.properties),o(),r;if(D.name!=="vertex")return null;const{packed_position:y,packed_rotation:l,packed_scale:d,packed_color:u}=D.properties;if(!y||!l||!d||!u)throw new Error("Missing PLY properties: packed_position, packed_rotation, packed_scale, packed_color");const p=Math.sqrt(2);return(m,M)=>{const G=Q[m>>>8];if(G==null)throw new Error("Missing PLY chunk");const{min_x:J,min_y:k,min_z:N,max_x:Y,max_y:F,max_z:f,min_scale_x:U,min_scale_y:L,min_scale_z:K,max_scale_x:Z,max_scale_y:QA,max_scale_z:z,min_r:AA,min_g:$,min_b:P,max_r:j,max_g:V,max_b:x}=G,{packed_position:dA,packed_rotation:sA,packed_scale:b,packed_color:oA}=M,rA=(dA>>>21&2047)/2047*(Y-J)+J,H=(dA>>>11&1023)/1023*(F-k)+k,FA=(dA&2047)/2047*(f-N)+N,NA=((sA>>>20&1023)/1023-.5)*p,xA=((sA>>>10&1023)/1023-.5)*p,LA=((sA&1023)/1023-.5)*p,bA=Math.sqrt(Math.max(0,1-NA*NA-xA*xA-LA*LA)),yA=sA>>>30,WA=yA===0?NA:yA===1?bA:xA,DI=yA<=1?xA:yA===2?bA:LA,lI=yA<=2?LA:bA,yI=yA===0?bA:NA,uI=Math.exp((b>>>21&2047)/2047*(Z-U)+U),dI=Math.exp((b>>>11&1023)/1023*(QA-L)+L),GI=Math.exp((b&2047)/2047*(z-K)+K),MI=(oA>>>24&255)/255*(j-AA)+AA,NI=(oA>>>16&255)/255*(V-$)+$,Pt=(oA>>>8&255)/255*(x-P)+P,_t=(oA&255)/255;A(m,rA,H,FA,uI,dI,GI,WA,DI,lI,yI,_t,MI,NI,Pt)}}const w=D=>{if(D.name==="chunk"&&this.comments.some(V=>V.toLowerCase().includes("supersplat")))return c(D);if(B)return h(D);if(D.name!=="vertex")return null;const{x:y,y:l,z:d,scale_0:u,scale_1:p,scale_2:m,rot_0:M,rot_1:G,rot_2:J,rot_3:k,opacity:N,f_dc_0:Y,f_dc_1:F,f_dc_2:f,red:U,green:L,blue:K,alpha:Z}=D.properties;if(!y||!l||!d)throw new Error("Missing PLY properties: x, y, z");const QA=u&&p&&m,z=M&&G&&J&&k,AA=Z!=null?$g[Z.type]:1,$=U!=null?$g[U.type]:1,P=L!=null?$g[L.type]:1,j=K!=null?$g[K.type]:1;return C=CB(D.properties),o(),(V,x)=>{const dA=QA?Math.exp(x.scale_0):wg.defaultPointScale,sA=QA?Math.exp(x.scale_1):wg.defaultPointScale,b=QA?Math.exp(x.scale_2):wg.defaultPointScale,oA=z?x.rot_1:0,rA=z?x.rot_2:0,H=z?x.rot_3:0,FA=z?x.rot_0:1,NA=N!=null?1/(1+Math.exp(-x.opacity)):Z!=null?x.alpha/AA:1,xA=Y!=null?x.f_dc_0*Pg Line truncated
precision highp int;
precision highp sampler2D;
precision highp usampler2D;
@@ -546,7 +546,7 @@ void main() {
} else {
target = uvec4(0u, 0u, 0u, 0u);
}
}`;const K=class K{constructor(A={}){this.maxSplats=0,this.numSplats=0,this.packedArray=null,this.isInitialized=!1,this.target=null,this.source=null,this.needsUpdate=!0,this.extra={},this.dyno=new xI({packedSplats:this}),this.initialized=Promise.resolve(this),this.reinitialize(A)}reinitialize(A){this.isInitialized=!1,A.url||A.fileBytes||A.construct?this.initialized=this.asyncInitialize(A).then(()=>(this.isInitialized=!0,this)):(this.initialize(A),this.isInitialized=!0,this.initialized=Promise.resolve(this))}initialize(A){A.packedArray?(this.packedArray=A.packedArray,this.maxSplats=Math.floor(this.packedArray.length/4),this.maxSplats=Math.floor(this.maxSplats/Z)*Z,this.numSplats=Math.min(this.maxSplats,A.numSplats??Number.POSITIVE_INFINITY)):(this.maxSplats=A.maxSplats??0,this.numSplats=0),this.extra=A.extra??{}}async asyncInitialize(A){let{url:I,fileBytes:g,construct:B}=A;if(I&&(g=await fetch(I).then(async C=>{if(!C.ok)throw new Error(`${C.status} "${C.statusText}" fetching URL: ${I}`);return await C.arrayBuffer()})),g){const C=await bI({input:g,fileType:A.fileType,pathOrUrl:I});this.initialize(C)}if(B){const C=B(this);C instanceof Promise&&await C}}dispose(){this.target&&(this.target.dispose(),this.target=null),this.source&&(this.source.dispose(),this.source=null)}ensureSplats(A){const I=A<=this.maxSplats?this.maxSplats:Math.max(A,2*this.maxSplats),g=this.packedArray?this.packedArray.length/4:0;if(!this.packedArray||I>g){this.maxSplats=rA(I).maxSplats;const B=new Uint32Array(this.maxSplats*4);this.packedArray&&B.set(this.packedArray),this.packedArray=B}return this.packedArray}ensureSplatsSh(A,I){let g,B;if(A===0)return this.ensureSplats(I);if(A===1)g=2,B="sh1";else if(A===2)g=4,B="sh2";else if(A===3)g=4,B="sh3";else throw new Error(`Invalid level: ${A}`);let C=this.extra[B]?this.extra[B].length/g:0;const E=I<=C?C:Math.max(I,2*C);if(!this.extra[B]||E>C){C=rA(E).maxSplats;const t=new Uint32Array(C*g);this.extra[B]&&t.set(this.extra[B]),this.extra[B]=t}return this.extra[B]}getSplat(A){if(!this.packedArray||A>=this.numSplats)throw new Error("Invalid index");return CI(this.packedArray,A)}setSplat(A,I,g,B,C,E){const t=this.ensureSplats(A+1);BI(t,A,I.x,I.y,I.z,g.x,g.y,g.z,B.x,B.y,B.z,B.w,C,E.r,E.g,E.b),this.numSplats=Math.max(this.numSplats,A+1)}pushSplat(A,I,g,B,C){const E=this.ensureSplats(this.numSplats+1);BI(E,this.numSplats,A.x,A.y,A.z,I.x,I.y,I.z,g.x,g.y,g.z,g.w,B,C.r,C.g,C.b),++this.numSplats}forEachSplat(A){if(!(!this.packedArray||!this.numSplats))for(let I=0;I<this.numSplats;++I){const g=CI(this.packedArray,I);A(I,g.center,g.scales,g.quaternion,g.opacity,g.color)}}ensureGenerate(A){if(this.target&&(A??1)<=this.maxSplats)return!1;this.dispose();const I=rA(A??1),{width:g,height:B,depth:C}=I;return this.maxSplats=I.maxSplats,this.target=new e.WebGLArrayRenderTarget(g,B,C,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:e.NearestFilter,minFilter:e.NearestFilter}),this.target.texture.format=e.RGBAIntegerFormat,this.target.texture.type=e.UnsignedIntType,this.target.texture.internalFormat="RGBA32UI",!0}generateMapping(A){let I=0;const g=A.map(B=>{const C=I,E=Math.ceil(B/Z)*Z;return I+=E,{base:C,count:B}});return{maxSplats:I,mapping:g}}getTexture(){return this.target?this.target.texture:this.source||this.packedArray?this.maybeUpdateSource():K.getEmpty()}maybeUpdateSource(){if(!this.packedArray)throw new Error("No packed splats");if(this.needsUpdate||!this.source){if(this.needsUpdate=!1,this.source){const{width:A,height:I,depth:g}=this.source.image;this.maxSplats!==A*I*g&&(this.source.dispose(),this.source=null)}if(this.source)this.packedArray.buffer!==this.source.image.data.buffer&&(this.source.image.data=new Uint8Array(this.packedArray.buffer));else{const{width:A,height:I,depth:g}=rA(this.maxSplats);this.source=new e.DataArrayTexture(this.packedArray,A,I,g),this.source.format=e.RGBAIntegerFormat,this.source.type=e.UnsignedIntType,this.source.internalFormat="RGBA32UI",this.source.needsUpdate=!0}this.source.needsUpdate=!0}return this.source}static getEmpty(){if(!K.emptySource){const{width:A,height:I,depth:g,maxSplats:B}=rA(1),C=new Uint32Array(B*4);K.emptySource=new e.DataArrayTexture(C,A,I,g),K.emptySource.format=e.RGBAIntegerFormat,K.emptySource.type=e.UnsignedIntType,K.emptySource.internalFormat="RGBA32UI",K.emptySource.needsUpdate=!0}return K.emptySource}prepareProgramMaterial(A){let I=K.generatorProgram.get(A);if(!I){const B=SA({index:"int"},{output:"uvec4"},({index:C})=>{A.inputs.index=C;const E=A.outputs.gsplat;return{output:rg(E)}});K.programTemplate||(K.programTemplate=new fI(Ze)),I=new HI({graph:B,inputs:{index:"index"},outputs:{output:"target"},template:K.programTemplate}),Object.assign(I.uniforms,{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0}}),K.generatorProgram.set(A,I)}const g=I.prepareMaterial();return K.mesh.material=g,{program:I,material:g}}saveRenderState(A){return{xrPresenting:A.xr.isPresenting,autoClear:A.autoClear,scissorTest:A.getScissorTest()}}resetRenderSt Line truncated
}`;const _=class _{constructor(A={}){this.maxSplats=0,this.numSplats=0,this.packedArray=null,this.isInitialized=!1,this.target=null,this.source=null,this.needsUpdate=!0,this.extra={},this.dyno=new PI({packedSplats:this}),this.initialized=Promise.resolve(this),this.reinitialize(A)}reinitialize(A){this.isInitialized=!1,A.url||A.fileBytes||A.construct?this.initialized=this.asyncInitialize(A).then(()=>(this.isInitialized=!0,this)):(this.initialize(A),this.isInitialized=!0,this.initialized=Promise.resolve(this))}initialize(A){A.packedArray?(this.packedArray=A.packedArray,this.maxSplats=Math.floor(this.packedArray.length/4),this.maxSplats=Math.floor(this.maxSplats/X)*X,this.numSplats=Math.min(this.maxSplats,A.numSplats??Number.POSITIVE_INFINITY)):(this.maxSplats=A.maxSplats??0,this.numSplats=0),this.extra=A.extra??{}}async asyncInitialize(A){let{url:I,fileBytes:B,construct:Q}=A;if(I&&(B=await fetch(I).then(async C=>{if(!C.ok)throw new Error(`${C.status} "${C.statusText}" fetching URL: ${I}`);return await C.arrayBuffer()})),B){const C=await OI({input:B,fileType:A.fileType,pathOrUrl:A.fileName??I});this.initialize(C)}if(Q){const C=Q(this);C instanceof Promise&&await C}}dispose(){this.target&&(this.target.dispose(),this.target=null),this.source&&(this.source.dispose(),this.source=null)}ensureSplats(A){const I=A<=this.maxSplats?this.maxSplats:Math.max(A,2*this.maxSplats),B=this.packedArray?this.packedArray.length/4:0;if(!this.packedArray||I>B){this.maxSplats=MA(I).maxSplats;const Q=new Uint32Array(this.maxSplats*4);this.packedArray&&Q.set(this.packedArray),this.packedArray=Q}return this.packedArray}ensureSplatsSh(A,I){let B,Q;if(A===0)return this.ensureSplats(I);if(A===1)B=2,Q="sh1";else if(A===2)B=4,Q="sh2";else if(A===3)B=4,Q="sh3";else throw new Error(`Invalid level: ${A}`);let C=this.extra[Q]?this.extra[Q].length/B:0;const E=I<=C?C:Math.max(I,2*C);if(!this.extra[Q]||E>C){C=MA(E).maxSplats;const t=new Uint32Array(C*B);this.extra[Q]&&t.set(this.extra[Q]),this.extra[Q]=t}return this.extra[Q]}getSplat(A){if(!this.packedArray||A>=this.numSplats)throw new Error("Invalid index");return Ug(this.packedArray,A)}setSplat(A,I,B,Q,C,E){const t=this.ensureSplats(A+1);iI(t,A,I.x,I.y,I.z,B.x,B.y,B.z,Q.x,Q.y,Q.z,Q.w,C,E.r,E.g,E.b),this.numSplats=Math.max(this.numSplats,A+1)}pushSplat(A,I,B,Q,C){const E=this.ensureSplats(this.numSplats+1);iI(E,this.numSplats,A.x,A.y,A.z,I.x,I.y,I.z,B.x,B.y,B.z,B.w,Q,C.r,C.g,C.b),++this.numSplats}forEachSplat(A){if(!(!this.packedArray||!this.numSplats))for(let I=0;I<this.numSplats;++I){const B=Ug(this.packedArray,I);A(I,B.center,B.scales,B.quaternion,B.opacity,B.color)}}ensureGenerate(A){if(this.target&&(A??1)<=this.maxSplats)return!1;this.dispose();const I=MA(A??1),{width:B,height:Q,depth:C}=I;return this.maxSplats=I.maxSplats,this.target=new a.WebGLArrayRenderTarget(B,Q,C,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:a.NearestFilter,minFilter:a.NearestFilter}),this.target.texture.format=a.RGBAIntegerFormat,this.target.texture.type=a.UnsignedIntType,this.target.texture.internalFormat="RGBA32UI",!0}generateMapping(A){let I=0;const B=A.map(Q=>{const C=I,E=Math.ceil(Q/X)*X;return I+=E,{base:C,count:Q}});return{maxSplats:I,mapping:B}}getTexture(){return this.target?this.target.texture:this.source||this.packedArray?this.maybeUpdateSource():_.getEmpty()}maybeUpdateSource(){if(!this.packedArray)throw new Error("No packed splats");if(this.needsUpdate||!this.source){if(this.needsUpdate=!1,this.source){const{width:A,height:I,depth:B}=this.source.image;this.maxSplats!==A*I*B&&(this.source.dispose(),this.source=null)}if(this.source)this.packedArray.buffer!==this.source.image.data.buffer&&(this.source.image.data=new Uint8Array(this.packedArray.buffer));else{const{width:A,height:I,depth:B}=MA(this.maxSplats);this.source=new a.DataArrayTexture(this.packedArray,A,I,B),this.source.format=a.RGBAIntegerFormat,this.source.type=a.UnsignedIntType,this.source.internalFormat="RGBA32UI",this.source.needsUpdate=!0}this.source.needsUpdate=!0}return this.source}static getEmpty(){if(!_.emptySource){const{width:A,height:I,depth:B,maxSplats:Q}=MA(1),C=new Uint32Array(Q*4);_.emptySource=new a.DataArrayTexture(C,A,I,B),_.emptySource.format=a.RGBAIntegerFormat,_.emptySource.type=a.UnsignedIntType,_.emptySource.internalFormat="RGBA32UI",_.emptySource.needsUpdate=!0}return _.emptySource}prepareProgramMaterial(A){let I=_.generatorProgram.get(A);if(!I){const Q=UA({index:"int"},{output:"uvec4"},({index:C})=>{A.inputs.index=C;const E=A.outputs.gsplat;return{output:JB(E)}});_.programTemplate||(_.programTemplate=new XI(On)),I=new TI({graph:Q,inputs:{index:"index"},outputs:{output:"target"},template:_.programTemplate}),Object.assign(I.uniforms,{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0}}),_.generatorProgram.set(A,I)}const B=I.prepareMaterial();return _.mesh.material=B,{program:I,material:B}}saveRenderState(A){return{xrPresenting:A.xr.isPresenting,autoClear:A.autoClear,scissorTest:A.getScissorTest(),pi Line truncated
float computeSort(Gsplat gsplat, bool sortRadial, vec3 sortOrigin, vec3 sortDirection, float sortDepthBias, bool sort360) {
if (!isGsplatActive(gsplat.flags)) {
return INFINITY;
@@ -560,9 +560,9 @@ void main() {
return sortRadial ? length(center) : biasedDepth;
}
`);function zI({gsplat:Q,sortRadial:A,sortOrigin:I,sortDirection:g,sortDepthBias:B,sort360:C}){return KQ({inTypes:{gsplat:T,sortRadial:"bool",sortOrigin:"vec3",sortDirection:"vec3",sortDepthBias:"float",sort360:"bool"},outTypes:{metric:"float"},globals:()=>[hA,Ve],inputs:{gsplat:Q,sortRadial:A,sortOrigin:I,sortDirection:g,sortDepthBias:B,sort360:C},statements:({inputs:E,outputs:t})=>{const{gsplat:s,sortRadial:o,sortOrigin:a,sortDirection:i,sortDepthBias:D,sort360:n}=E;return dA(`
${t.metric} = computeSort(${s}, ${o}, ${a}, ${i}, ${D}, ${n});
`)}}).outputs.metric}class QI{constructor(){this.splats=new UA,this.toWorld=new e.Matrix4,this.mapping=[],this.refCount=0,this.splatsVersion=-1,this.mappingVersion=-1}ensureGenerate(A){this.splats.ensureGenerate(A)&&(this.mapping=[])}generateSplats({renderer:A,modifier:I,generators:g,forceUpdate:B,originToWorld:C}){const E=this.mapping.reduce((o,a)=>(o.set(a.node,a),o),new Map);let t=0,s=0;for(const{node:o,generator:a,version:i,base:D,count:n}of g){const w=E.get(o);if((B||a!==(w==null?void 0:w.generator)||i!==(w==null?void 0:w.version)||D!==(w==null?void 0:w.base)||n!==(w==null?void 0:w.count))&&a){const c=I.apply(a);try{this.splats.generate({generator:c,base:D,count:n,renderer:A})}catch(r){o.generator=void 0,o.generatorError=r}t+=1}s=Math.max(s,D+n)}return this.splats.numSplats=s,this.toWorld=C,this.mapping=g,t!==0}hasCorrespondence(A){return this.mapping.length!==A.mapping.length?!1:this.mapping.every(({node:I,base:g,count:B},C)=>{const{node:E,base:t,count:s}=A.mapping[C];return I===E&&g===t&&B===s})}}var Te=`const float LN_SCALE_MIN = -9.0;
`);function tB({gsplat:g,sortRadial:A,sortOrigin:I,sortDirection:B,sortDepthBias:Q,sort360:C}){return Wg({inTypes:{gsplat:BA,sortRadial:"bool",sortOrigin:"vec3",sortDirection:"vec3",sortDepthBias:"float",sort360:"bool"},outTypes:{metric:"float"},globals:()=>[kA,$n],inputs:{gsplat:g,sortRadial:A,sortOrigin:I,sortDirection:B,sortDepthBias:Q,sort360:C},statements:({inputs:E,outputs:t})=>{const{gsplat:i,sortRadial:e,sortOrigin:n,sortDirection:s,sortDepthBias:o,sort360:r}=E;return fA(`
${t.metric} = computeSort(${i}, ${e}, ${n}, ${s}, ${o}, ${r});
`)}}).outputs.metric}class CI{constructor(){this.splats=new YA,this.toWorld=new a.Matrix4,this.mapping=[],this.refCount=0,this.splatsVersion=-1,this.mappingVersion=-1}ensureGenerate(A){this.splats.ensureGenerate(A)&&(this.mapping=[])}generateSplats({renderer:A,modifier:I,generators:B,forceUpdate:Q,originToWorld:C}){const E=this.mapping.reduce((e,n)=>(e.set(n.node,n),e),new Map);let t=0,i=0;for(const{node:e,generator:n,version:s,base:o,count:r}of B){const c=E.get(e);if((Q||n!==(c==null?void 0:c.generator)||s!==(c==null?void 0:c.version)||o!==(c==null?void 0:c.base)||r!==(c==null?void 0:c.count))&&n&&r>0){const h=I.apply(n);try{this.splats.generate({generator:h,base:o,count:r,renderer:A})}catch(w){e.generator=void 0,e.generatorError=w}t+=1}i=Math.max(i,o+r)}return this.splats.numSplats=i,this.toWorld=C,this.mapping=B,t!==0}hasCorrespondence(A){return this.mapping.length!==A.mapping.length?!1:this.mapping.every(({node:I,base:B,count:Q},C)=>{const{node:E,base:t,count:i}=A.mapping[C];return I===E&&B===t&&Q===i})}}var Ao=`const float LN_SCALE_MIN = -9.0;
const float LN_SCALE_MAX = 9.0;
const float LN_RESCALE = (LN_SCALE_MAX - LN_SCALE_MIN) / 254.0;
@@ -804,7 +804,7 @@ ivec3 splatTexCoord(int index) {
uint y = (uint(index) >> SPLAT_TEX_WIDTH_BITS) & SPLAT_TEX_HEIGHT_MASK;
uint z = uint(index) >> SPLAT_TEX_LAYER_BITS;
return ivec3(x, y, z);
}`,ve=`precision highp float;
}`,go=`precision highp float;
precision highp int;
#include <splatDefines>
@@ -837,7 +837,7 @@ void main() {
rgb = srgbToLinear(rgb);
}
fragColor = vec4(rgb, alpha);
}`,Xe=`precision highp float;
}`,Io=`precision highp float;
precision highp int;
precision highp usampler2DArray;
@@ -1007,14 +1007,14 @@ void main() {
vSplatUv = position.xy * maxStdDev;
vNdc = ndc;
gl_Position = vec4(ndc.xy * clipCenter.w, clipCenter.zw);
}`;let GI=null;function je(){return GI||(e.ShaderChunk.splatDefines=Te,GI={splatVertex:Xe,splatFragment:ve}),GI}const OI=5;let YI=!1,uI=!1,Rt;const Jt=e.Scene.prototype.add;e.Scene.prototype.add=function(Q){return YI=YI||Q instanceof ZA,uI=uI||Q instanceof mQ,Jt.call(this,Q),this};const ze=e.Scene.prototype.onBeforeRender;e.Scene.prototype.onBeforeRender=function(Q){if(YI){if(!uI){const A=Rt||new mQ({renderer:Q});this.add(A)}e.Scene.prototype.onBeforeRender=ze,e.Scene.prototype.add=Jt}};const oA=class oA extends e.Mesh{constructor(A){const I=oA.makeUniforms(),g=je(),B=new e.ShaderMaterial({glslVersion:e.GLSL3,vertexShader:g.splatVertex,fragmentShader:g.splatFragment,uniforms:I,transparent:!0,blending:e.NormalBlending,depthTest:!0,depthWrite:!1,side:e.DoubleSide});super(PI,B),this.autoViewpoints=[],this.rotateToAccumulator=new qQ({value:new e.Quaternion}),this.translateToAccumulator=new hQ({value:new e.Vector3}),this.lastFrame=-1,this.lastUpdateTime=null,this.defaultCameras=[],this.pendingUpdate=null,this.envViewpoint=null,this.frustumCulled=!1,this.renderer=A.renderer,this.material=B,this.uniforms=I;const C=SA({gsplat:T},{gsplat:T},({gsplat:E})=>{if(!E)throw new Error("gsplat not defined");return E=SI(E,{rotate:this.rotateToAccumulator,translate:this.translateToAccumulator}),{gsplat:E}});this.modifier=new yt(C),this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!1,this.originDistance=A.originDistance??1,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.enable2DGS=A.enable2DGS??!0,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.falloff=A.falloff??1,this.clipXY=A.clipXY??1.4,this.active=new QI,this.accumulatorCount=1,this.freeAccumulators=[];for(let E=0;E<1;++E)this.freeAccumulators.push(new QI),this.accumulatorCount+=1;this.defaultView=new fQ({...A.view,autoUpdate:!0,forge:this}),this.viewpoint=this.defaultView,this.prepareViewpoint(this.viewpoint),this.clock=A.clock?yB(A.clock):new e.Clock,Rt=this}static makeUniforms(){return{renderSize:{value:new e.Vector2},numSplats:{value:0},renderToViewQuat:{value:new e.Quaternion},renderToViewPos:{value:new e.Vector3},maxStdDev:{value:1},enable2DGS:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},falloff:{value:1},clipXY:{value:1.4},packedSplats:{type:"t",value:UA.getEmpty()},time:{value:0},deltaTime:{value:0},encodeLinear:{value:!1},debugFlag:{value:!1}}}canAllocAccumulator(){return this.freeAccumulators.length>0||this.accumulatorCount<OI}maybeAllocAccumulator(){let A=this.freeAccumulators.pop();if(A===void 0){if(this.accumulatorCount>=OI)return null;A=new QI,this.accumulatorCount+=1}return A.refCount=1,A}releaseAccumulator(A){A.refCount-=1,A.refCount===0&&this.freeAccumulators.push(A)}newViewpoint(A){return new fQ({...A,forge:this})}onBeforeRender(A,I,g){var D,n;const B=this.time??this.clock.getElapsedTime(),C=B-(this.viewpoint.lastTime??B);this.viewpoint.lastTime=B;const E=A.info.render.frame,t=E!==this.lastFrame;this.lastFrame=E;const s=this.viewpoint;if(s===this.defaultView){if(t)if(!A.xr.isPresenting)this.defaultView.viewToWorld=g.matrixWorld.clone(),this.defaultCameras=[this.defaultView.viewToWorld];else{const w=A.xr.getCamera().cameras;this.defaultCameras=[w[0].matrixWorld,w[1].matrixWorld],this.defaultView.viewToWorld=Oe(this.defaultCameras)??new e.Matrix4}this.autoUpdate&&this.update({scene:I,viewToWorld:this.defaultView.viewToWorld})}if(t&&(this.uniforms.time.value=B,this.uniforms.deltaTime.value=C,this.uniforms.debugFlag.value=performance.now()/1e3%2<1),s.target)this.uniforms.renderSize.value.set(s.target.width,s.target.height);else{const w=A.getSize(this.uniforms.renderSize.value);if(w.x===1&&w.y===1){const c=(D=A.xr.getSession())==null?void 0:D.renderState.baseLayer;c&&(w.x=c.framebufferWidth,w.y=c.framebufferHeight)}}this.uniforms.encodeLinear.value=s.encodeLinear,this.uniforms.maxStdDev.value=this.maxStdDev,this.uniforms.enable2DGS.value=this.enable2DGS,this.uniforms.preBlurAmount.value=this.preBlurAmount,this.uniforms.blurAmount.value=this.blurAmount,this.uniforms.falloff.value=this.falloff,this.uniforms.clipXY.value=this.clipXY;const o=((n=s.display)==null?void 0:n.accumulator.toWorld)??new e.Matrix4,a=g.matrixWorld.clone().invert();o.clone().premultiply(a).decompose(this.uniforms.renderToViewPos.value,this.uniforms.renderToViewQuat.value,new e.Vector3)}prepareViewpoint(A){if(this.viewpoint=A??this.viewpoint,this.viewpoint.display){const{accumulator:I,geometry:g}=this.viewpoint.display;this.uniforms.numSplats.value=I.splats.numSplats,this.uniforms.packedSplats.value=I.splats.getTexture(),this.geometry=g}else this.uniforms.numSplats.value=0,this.uniforms.packedSplats.value=UA.getEmpty(),this.geometry=PI}update({scene:A,viewToWorld:I}){const g=this.matrixWorld.clone();this.preUpdate?this.updateInternal({scene:A,originToWorld:g,viewToWorld:I}):(this.pendingUpdate={scene:A,originToWorld:g},setTimeout(()=>{if(this.pendingUpdate){const{scene:B,originToWorld:C}=this.pendingUpdate;this.pendingUpdate=null,this.updateI Line truncated
}`;let JI=null;function Bo(){return JI||(a.ShaderChunk.splatDefines=Ao,JI={splatVertex:Io,splatFragment:go}),JI}const iB=5;let HI=!1,KI=!1,Kt;const Zt=a.Scene.prototype.add;a.Scene.prototype.add=function(g){return HI=HI||g instanceof zA,KI=KI||g instanceof Zg,Zt.call(this,g),this};const Qo=a.Scene.prototype.onBeforeRender;a.Scene.prototype.onBeforeRender=function(g){if(HI){if(!KI){const A=Kt||new Zg({renderer:g});this.add(A)}a.Scene.prototype.onBeforeRender=Qo,a.Scene.prototype.add=Zt}};const uA=class uA extends a.Mesh{constructor(A){const I=uA.makeUniforms(),B=Bo(),Q=new a.ShaderMaterial({glslVersion:a.GLSL3,vertexShader:B.splatVertex,fragmentShader:B.splatFragment,uniforms:I,transparent:!0,blending:a.NormalBlending,depthTest:!0,depthWrite:!1,side:a.DoubleSide});super(sB,Q),this.autoViewpoints=[],this.rotateToAccumulator=new Tg({value:new a.Quaternion}),this.translateToAccumulator=new yg({value:new a.Vector3}),this.lastFrame=-1,this.lastUpdateTime=null,this.defaultCameras=[],this.pendingUpdate=null,this.envViewpoint=null,this.frustumCulled=!1,this.renderer=A.renderer,this.material=Q,this.uniforms=I;const C=UA({gsplat:BA},{gsplat:BA},({gsplat:E})=>{if(!E)throw new Error("gsplat not defined");return E=vI(E,{rotate:this.rotateToAccumulator,translate:this.translateToAccumulator}),{gsplat:E}});this.modifier=new Yt(C),this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!1,this.originDistance=A.originDistance??1,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.enable2DGS=A.enable2DGS??!0,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.falloff=A.falloff??1,this.clipXY=A.clipXY??1.4,this.active=new CI,this.accumulatorCount=1,this.freeAccumulators=[];for(let E=0;E<1;++E)this.freeAccumulators.push(new CI),this.accumulatorCount+=1;this.defaultView=new Kg({...A.view,autoUpdate:!0,forge:this}),this.viewpoint=this.defaultView,this.prepareViewpoint(this.viewpoint),this.clock=A.clock?fQ(A.clock):new a.Clock,Kt=this}static makeUniforms(){return{renderSize:{value:new a.Vector2},numSplats:{value:0},renderToViewQuat:{value:new a.Quaternion},renderToViewPos:{value:new a.Vector3},maxStdDev:{value:1},enable2DGS:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},falloff:{value:1},clipXY:{value:1.4},packedSplats:{type:"t",value:YA.getEmpty()},time:{value:0},deltaTime:{value:0},encodeLinear:{value:!1},debugFlag:{value:!1}}}canAllocAccumulator(){return this.freeAccumulators.length>0||this.accumulatorCount<iB}maybeAllocAccumulator(){let A=this.freeAccumulators.pop();if(A===void 0){if(this.accumulatorCount>=iB)return null;A=new CI,this.accumulatorCount+=1}return A.refCount=1,A}releaseAccumulator(A){A.refCount-=1,A.refCount===0&&this.freeAccumulators.push(A)}newViewpoint(A){return new Kg({...A,forge:this})}onBeforeRender(A,I,B){var o,r;const Q=this.time??this.clock.getElapsedTime(),C=Q-(this.viewpoint.lastTime??Q);this.viewpoint.lastTime=Q;const E=A.info.render.frame,t=E!==this.lastFrame;this.lastFrame=E;const i=this.viewpoint;if(i===this.defaultView){if(t)if(!A.xr.isPresenting)this.defaultView.viewToWorld=B.matrixWorld.clone(),this.defaultCameras=[this.defaultView.viewToWorld];else{const c=A.xr.getCamera().cameras;this.defaultCameras=[c[0].matrixWorld,c[1].matrixWorld],this.defaultView.viewToWorld=Co(this.defaultCameras)??new a.Matrix4}this.autoUpdate&&this.update({scene:I,viewToWorld:this.defaultView.viewToWorld})}if(t&&(this.uniforms.time.value=Q,this.uniforms.deltaTime.value=C,this.uniforms.debugFlag.value=performance.now()/1e3%2<1),i.target)this.uniforms.renderSize.value.set(i.target.width,i.target.height);else{const c=A.getSize(this.uniforms.renderSize.value);if(c.x===1&&c.y===1){const h=(o=A.xr.getSession())==null?void 0:o.renderState.baseLayer;h&&(c.x=h.framebufferWidth,c.y=h.framebufferHeight)}}this.uniforms.encodeLinear.value=i.encodeLinear,this.uniforms.maxStdDev.value=this.maxStdDev,this.uniforms.enable2DGS.value=this.enable2DGS,this.uniforms.preBlurAmount.value=this.preBlurAmount,this.uniforms.blurAmount.value=this.blurAmount,this.uniforms.falloff.value=this.falloff,this.uniforms.clipXY.value=this.clipXY;const e=((r=i.display)==null?void 0:r.accumulator.toWorld)??new a.Matrix4,n=B.matrixWorld.clone().invert();e.clone().premultiply(n).decompose(this.uniforms.renderToViewPos.value,this.uniforms.renderToViewQuat.value,new a.Vector3)}prepareViewpoint(A){if(this.viewpoint=A??this.viewpoint,this.viewpoint.display){const{accumulator:I,geometry:B}=this.viewpoint.display;this.uniforms.numSplats.value=I.splats.numSplats,this.uniforms.packedSplats.value=I.splats.getTexture(),this.geometry=B}else this.uniforms.numSplats.value=0,this.uniforms.packedSplats.value=YA.getEmpty(),this.geometry=sB}update({scene:A,viewToWorld:I}){const B=this.matrixWorld.clone();this.preUpdate?this.updateInternal({scene:A,originToWorld:B,viewToWorld:I}):(this.pendingUpdate={scene:A,originToWorld:B},setTimeout(()=>{if(this.pendingUpdate){const{scene:Q,originToWorld:C}=this.pendingUpdate;this.pendingUpdate=null,this.updat Line truncated
struct GsplatSkinning {
int numSplats;
int numBones;
usampler2DArray skinTexture;
sampler2D boneTexture;
};
`),QD=gA(`
`),ro=nA(`
void applyGsplatSkinning(
int numSplats, int numBones,
usampler2DArray skinTexture, sampler2D boneTexture,
@@ -1073,8 +1073,8 @@ void main() {
center = quatVec(quat, center) + translate;
quaternion = quatQuat(quat, quaternion);
}
`);function ID(Q,A){return new f({inTypes:{gsplat:T,skinning:dt},outTypes:{gsplat:T},globals:()=>[Yt,QD],inputs:{gsplat:Q,skinning:A},statements:({inputs:g,outputs:B})=>{const{skinning:C}=g,{gsplat:E}=B;return dA(`
${E} = ${g.gsplat};
`);function co(g,A){return new T({inTypes:{gsplat:BA,skinning:Vt},outTypes:{gsplat:BA},globals:()=>[Tt,ro],inputs:{gsplat:g,skinning:A},statements:({inputs:B,outputs:Q})=>{const{skinning:C}=B,{gsplat:E}=Q;return fA(`
${E} = ${B.gsplat};
if (isGsplatActive(${E}.flags)) {
applyGsplatSkinning(
${C}.numSplats, ${C}.numBones,
@@ -1082,5 +1082,5 @@ void main() {
${E}.index, ${E}.center, ${E}.quaternion
);
}
`)}}).outputs.gsplat}function gD({splats:Q,extents:A,stepSize:I=1,pointRadius:g=.01,pointShadowScale:B=2,opacity:C=1,color:E}){const s=new e.Vector3,o=new e.Vector3,a=new e.Quaternion(0,0,0,1);E==null&&(E=(D,n)=>D.set(.55+.45*Math.cos(n.x*1),.55+.45*Math.cos(n.y*1),.55+.45*Math.cos(n.z*1)));const i=new e.Color;for(let D=A.min.z;D<A.max.z+1e-6;D+=I)for(let n=A.min.y;n<A.max.y+1e-6;n+=I)for(let w=A.min.x;w<A.max.x+1e-6;w+=I){s.set(w,n,D);for(let c=0;c<2;++c)o.setScalar(g*(c?1:B)),c?typeof E=="function"?E(i,s):i.copy(E):i.setScalar(0),Q.pushSplat(s,o,a,C,i)}}function BD({splats:Q,scale:A=.25,axisRadius:I=.0075,axisShadowScale:g=2,origins:B=[new e.Vector3]}){const C=new e.Vector3,E=new e.Vector3,t=new e.Quaternion(0,0,0,1),s=new e.Color,o=1;for(const a of B)for(let i=0;i<3;++i){C.set(a.x+(i===0?A:0),a.y+(i===1?A:0),a.z+(i===2?A:0));for(let D=0;D<2;++D)E.set((i===0?A:I)*(D?1:g),(i===1?A:I)*(D?1:g),(i===2?A:I)*(D?1:g)),s.setRGB(D===0?0:i===0?1:0,D===0?0:i===1?1:0,D===0?0:i===2?1:0),Q.pushSplat(C,E,t,o,s)}}function CD({splats:Q,origin:A=new e.Vector3,radius:I=1,maxDepth:g=3,filter:B=null,pointRadius:C=.02,pointThickness:E=.001,color:t=new e.Color(1,1,1)}){const s={};function o(c){if(B&&!B(c))return;const r=`${c.x},${c.y},${c.z}`;s[r]||(s[r]=c)}function a(c,r,y,G){if(o(r),o(y),o(G),c>=g)return;const h=new e.Vector3().addVectors(r,y).normalize(),M=new e.Vector3().addVectors(y,G).normalize(),l=new e.Vector3().addVectors(G,r).normalize();a(c+1,r,h,l),a(c+1,h,y,M),a(c+1,l,M,G),a(c+1,h,M,l)}for(const c of[-1,1])for(const r of[-1,1])for(const y of[-1,1]){const G=new e.Vector3(c,0,0),h=new e.Vector3(0,r,0),M=new e.Vector3(0,0,y);a(0,G,h,M)}const i=Object.values(s),D=new e.Vector3(C,C,E),n=new e.Quaternion,w=typeof t=="function"?new e.Color:t;for(const c of i)n.setFromUnitVectors(new e.Vector3(0,0,-1),c),typeof t=="function"&&t(w,c),c.multiplyScalar(I),c.add(A),Q.pushSplat(c,D,n,1,w)}function ED({text:Q,font:A,fontSize:I,color:g,rgb:B,dotRadius:C,textAlign:E,lineHeight:t}){A=A??"Arial",I=I??32,g=g??new e.Color(1,1,1),C=C??.8,E=E??"start",t=t??1;const s=Q.split(`
`),o=document.createElement("canvas"),a=o.getContext("2d");if(!a)throw new Error("Failed to create canvas context");a.font=`${I}px ${A}`,a.textAlign=E;const i=a.measureText(""),D=i.fontBoundingBoxAscent+i.fontBoundingBoxDescent;let n=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,c=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(let U=0;U<s.length;++U){const S=a.measureText(s[U]),v=D*t*U;n=Math.min(n,-S.actualBoundingBoxLeft),w=Math.max(w,S.actualBoundingBoxRight),c=Math.min(c,v-S.actualBoundingBoxAscent),r=Math.max(r,v+S.actualBoundingBoxDescent)}const y=Math.floor(n),G=Math.floor(c),h=Math.ceil(w)-y,M=Math.ceil(r)-G;o.width=h,o.height=M,a.font=`${I}px ${A}`,a.textAlign=E,a.textBaseline="alphabetic",a.fillStyle="#FFFFFF";for(let U=0;U<s.length;++U){const S=D*t*U-G;a.fillText(s[U],-y,S)}const l=a.getImageData(0,0,h,M),k=new Uint8Array(l.data.buffer),R=new UA,d=new e.Vector3,Y=new e.Vector3().setScalar(C),m=new e.Quaternion(0,0,0,1);B=B??new e.Color(1,1,1);let J=0;for(let U=0;U<M;++U)for(let S=0;S<h;++S){const v=k[J+3];if(v>0){const V=v/255;d.set(S-.5*(h-1),.5*(M-1)-U,0),R.pushSplat(d,Y,m,V,B)}J+=4}const x=new ZA({packedSplats:R});return x.recolor=g,x}function tD({url:Q,dotRadius:A,subXY:I,forEachSplat:g}){return A=A??.8,I=Math.max(1,Math.floor(I??1)),new ZA({constructSplats:async B=>new Promise((C,E)=>{const t=new Image;t.onerror=E,t.onload=()=>{const{width:s,height:o}=t,a=document.createElement("canvas");a.width=s,a.height=o;const i=a.getContext("2d");if(!i){E(new Error("Failed to create canvas context"));return}i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high";const D=Math.round(s/I),n=Math.round(o/I);i.drawImage(t,0,0,D,n);try{const w=i.getImageData(0,0,D,n),c=new Uint8Array(w.data.buffer),r=new e.Vector3,y=new e.Vector3().setScalar(A),G=new e.Quaternion(0,0,0,1),h=new e.Color;let M=0;for(let l=0;l<n;++l)for(let k=0;k<D;++k){const R=M*4,d=c[R+3];if(d>0){let Y=d/255;h.set(c[R+0]/255,c[R+1]/255,c[R+2]/255),r.set(k-.5*(D-1),.5*(n-1)-l,0),y.setScalar(A),G.set(0,0,0,1);let m=!0;if(g){const J=g(D,n,M,r,y,G,Y,h);Y=J??Y,m=J!==null}m&&B.pushSplat(r,y,G,Y,h)}M+=1}C()}catch(w){E(w)}},t.src=Q})})}function iD({box:Q,cells:A,dotScale:I,color:g,opacity:B}){A.x=Math.max(1,Math.round(A.x)),A.y=Math.max(1,Math.round(A.y)),A.z=Math.max(1,Math.round(A.z)),B=B??1;const C=A.x*A.y*A.z,E=q("int",A.x),t=q("int",A.y);q("int",A.z);const s=pA(0),o=new TQ({numSplats:C,generator:SA({index:"int"},{gsplat:T},({index:i})=>{if(!i)throw new Error("index is undefined");const D=kI(i,E),n=$Q(i,E),w=kI(n,t),c=$Q(n,t),r=mA({vectorType:"ivec3",x:D,y:w,z:c}),y=dC(s),G=mA({vectorType:"ivec2",x:i,y}),h=UE(G),M=q("vec3",Q.min),l=q("vec3",Q.max),k=LQ(l,M),R=$Q(wA(tQ(r),h),q("vec3",A));let d,Y,m;g?(d=q("float",g.r),Y=q("float",g.g),m=q("float",g.b)):{r:d,g:Y,b:m}=YQ(R).outputs;const J=mA({vectorType:"vec4",r:d,g:Y,b:m,a:q("float",B)}),x=wA(M,CA(k,R)),U=tQ(q("float",I)),S=q("vec4",new e.Quaternion(0,0,0,1));let v=rQ({flags:II("uint","GSPLAT_FLAG_ACTIVE"),index:i,center:x,scales:U,quaternion:S,rgba:J});return v=a.modify(v),{gsplat:v}},{globals:()=>[hA]}),update:({time:i})=>{s.value=i,a.update(o),o.updateVersion()}}),a=new CQ;return o}const sD={box:new e.Box3(new e.Vector3(-1,-1,-1),new e.Vector3(1,1,1)),density:100,fallDirection:new e.Vector3(-1,-3,1).normalize(),fallVelocity:.02,wanderScale:.04,wanderVariance:2,color1:new e.Color(1,1,1),color2:new e.Color(.5,.5,1),minScale:.001,maxScale:.005,anisoScale:new e.Vector3(1,1,1)},oD={box:new e.Box3(new e.Vector3(-2,-1,-2),new e.Vector3(2,5,2)),density:10,fallDirection:new e.Vector3(0,-1,0),fallVelocity:2,wanderScale:.1,wanderVariance:1,color1:new e.Color(1,1,1),color2:new e.Color(.25,.25,.5),minScale:.005,maxScale:.01,anisoScale:new e.Vector3(.1,1,.1)};function aD({box:Q,minY:A,numSplats:I,density:g,anisoScale:B,minScale:C,maxScale:E,fallDirection:t,fallVelocity:s,wanderScale:o,wanderVariance:a,color1:i,color2:D,opacity:n,onFrame:w}){Q=Q??new e.Box3(new e.Vector3(-1,-1,-1),new e.Vector3(1,1,1));const c=(Q.max.x-Q.min.x)*(Q.max.y-Q.min.y)*(Q.max.z-Q.min.z);g=g??100,I=I??Math.max(1,Math.min(1e6,Math.round(c*g)));const r=pA(C??.001),y=pA(E??.005),G=vA(((B==null?void 0:B.clone())??new e.Vector3(1,1,1)).normalize()),h=vA((t??new e.Vector3(0,-1,0)).normalize()),M=pA(s??.02),l=pA(o??.01),k=pA(a??2),R=vA(i??new e.Color(1,1,1)),d=vA(D??new e.Color(.5,.5,1)),Y=pA(n??1),m=pA(0),J=vA(new e.Vector3(0,0,0)),x=vA(Q.min),U=vA(Q.max),S=pA(A??Number.NEGATIVE_INFINITY),v=LQ(U,x),V=new TQ({numSplats:I,generator:SA({index:"int"},{gsplat:T},({index:$})=>{if(!$)throw new Error("index not defined");const X=FI($),eA=YQ(X).outputs.w;let AA=tQ(X),sA=AI(CA(eA,q("float",100)));sA=RI(CA(II("float","PI"),sA)),sA=wA(r,CA(sA,LQ(y,r)));const DA=CA(sA,G),YA=AI(CA(eA,q("float",10))),yA=AI(eA),nA=SB(R,d,yA),L=CA(nA,YA),GA=FI(mA({vectorType:"ivec2",x:$,y:q("int",6837)}));let BA=tQ(GA),lA=CA(YQ(GA).outputs.w,k);lA=wA(m,lA),AA=wA(AA,J);const MA=uB(AA,q("vec3",new e.Vector3(1,1,1)));AA=wA(x,CA(v,MA));const LA=q("vec4",new e.Q Line truncated
`)}}).outputs.gsplat}function ho({splats:g,extents:A,stepSize:I=1,pointRadius:B=.01,pointShadowScale:Q=2,opacity:C=1,color:E}){const i=new a.Vector3,e=new a.Vector3,n=new a.Quaternion(0,0,0,1);E==null&&(E=(o,r)=>o.set(.55+.45*Math.cos(r.x*1),.55+.45*Math.cos(r.y*1),.55+.45*Math.cos(r.z*1)));const s=new a.Color;for(let o=A.min.z;o<A.max.z+1e-6;o+=I)for(let r=A.min.y;r<A.max.y+1e-6;r+=I)for(let c=A.min.x;c<A.max.x+1e-6;c+=I){i.set(c,r,o);for(let h=0;h<2;++h)e.setScalar(B*(h?1:Q)),h?typeof E=="function"?E(s,i):s.copy(E):s.setScalar(0),g.pushSplat(i,e,n,C,s)}}function wo({splats:g,scale:A=.25,axisRadius:I=.0075,axisShadowScale:B=2,origins:Q=[new a.Vector3]}){const C=new a.Vector3,E=new a.Vector3,t=new a.Quaternion(0,0,0,1),i=new a.Color,e=1;for(const n of Q)for(let s=0;s<3;++s){C.set(n.x+(s===0?A:0),n.y+(s===1?A:0),n.z+(s===2?A:0));for(let o=0;o<2;++o)E.set((s===0?A:I)*(o?1:B),(s===1?A:I)*(o?1:B),(s===2?A:I)*(o?1:B)),i.setRGB(o===0?0:s===0?1:0,o===0?0:s===1?1:0,o===0?0:s===2?1:0),g.pushSplat(C,E,t,e,i)}}function Do({splats:g,origin:A=new a.Vector3,radius:I=1,maxDepth:B=3,filter:Q=null,pointRadius:C=.02,pointThickness:E=.001,color:t=new a.Color(1,1,1)}){const i={};function e(h){if(Q&&!Q(h))return;const w=`${h.x},${h.y},${h.z}`;i[w]||(i[w]=h)}function n(h,w,D,y){if(e(w),e(D),e(y),h>=B)return;const l=new a.Vector3().addVectors(w,D).normalize(),d=new a.Vector3().addVectors(D,y).normalize(),u=new a.Vector3().addVectors(y,w).normalize();n(h+1,w,l,u),n(h+1,l,D,d),n(h+1,u,d,y),n(h+1,l,d,u)}for(const h of[-1,1])for(const w of[-1,1])for(const D of[-1,1]){const y=new a.Vector3(h,0,0),l=new a.Vector3(0,w,0),d=new a.Vector3(0,0,D);n(0,y,l,d)}const s=Object.values(i),o=new a.Vector3(C,C,E),r=new a.Quaternion,c=typeof t=="function"?new a.Color:t;for(const h of s)r.setFromUnitVectors(new a.Vector3(0,0,-1),h),typeof t=="function"&&t(c,h),h.multiplyScalar(I),h.add(A),g.pushSplat(h,o,r,1,c)}function lo({text:g,font:A,fontSize:I,color:B,rgb:Q,dotRadius:C,textAlign:E,lineHeight:t,objectScale:i}){A=A??"Arial",I=I??32,B=B??new a.Color(1,1,1),C=C??.8,E=E??"start",t=t??1,i=i??1;const e=g.split(`
`),n=document.createElement("canvas"),s=n.getContext("2d");if(!s)throw new Error("Failed to create canvas context");s.font=`${I}px ${A}`,s.textAlign=E;const o=s.measureText(""),r=o.fontBoundingBoxAscent+o.fontBoundingBoxDescent;let c=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,w=Number.POSITIVE_INFINITY,D=Number.NEGATIVE_INFINITY;for(let F=0;F<e.length;++F){const f=s.measureText(e[F]),U=r*t*F;c=Math.min(c,-f.actualBoundingBoxLeft),h=Math.max(h,f.actualBoundingBoxRight),w=Math.min(w,U-f.actualBoundingBoxAscent),D=Math.max(D,U+f.actualBoundingBoxDescent)}const y=Math.floor(c),l=Math.floor(w),d=Math.ceil(h)-y,u=Math.ceil(D)-l;n.width=d,n.height=u,s.font=`${I}px ${A}`,s.textAlign=E,s.textBaseline="alphabetic",s.fillStyle="#FFFFFF";for(let F=0;F<e.length;++F){const f=r*t*F-l;s.fillText(e[F],-y,f)}const p=s.getImageData(0,0,d,u),m=new Uint8Array(p.data.buffer),M=new YA,G=new a.Vector3,J=new a.Vector3().setScalar(C*i),k=new a.Quaternion(0,0,0,1);Q=Q??new a.Color(1,1,1);let N=0;for(let F=0;F<u;++F)for(let f=0;f<d;++f){const U=m[N+3];if(U>0){const L=U/255;G.set(f-.5*(d-1),.5*(u-1)-F,0),G.multiplyScalar(i),M.pushSplat(G,J,k,L,Q)}N+=4}const Y=new zA({packedSplats:M});return Y.recolor=B,Y}function yo({url:g,dotRadius:A,subXY:I,forEachSplat:B}){return A=A??.8,I=Math.max(1,Math.floor(I??1)),new zA({constructSplats:async Q=>new Promise((C,E)=>{const t=new Image;t.crossOrigin="anonymous",t.onerror=E,t.onload=()=>{const{width:i,height:e}=t,n=document.createElement("canvas");n.width=i,n.height=e;const s=n.getContext("2d");if(!s){E(new Error("Failed to create canvas context"));return}s.imageSmoothingEnabled=!0,s.imageSmoothingQuality="high";const o=Math.round(i/I),r=Math.round(e/I);s.drawImage(t,0,0,o,r);try{const c=s.getImageData(0,0,o,r),h=new Uint8Array(c.data.buffer),w=new a.Vector3,D=new a.Vector3().setScalar(A),y=new a.Quaternion(0,0,0,1),l=new a.Color;let d=0;for(let u=0;u<r;++u)for(let p=0;p<o;++p){const m=d*4,M=h[m+3];if(M>0){let G=M/255;l.set(h[m+0]/255,h[m+1]/255,h[m+2]/255),w.set(p-.5*(o-1),.5*(r-1)-u,0),D.setScalar(A),y.set(0,0,0,1);let J=!0;if(B){const k=B(o,r,d,w,D,y,G,l);G=k??G,J=k!==null}J&&Q.pushSplat(w,D,y,G,l)}d+=1}C()}catch(c){E(c)}},t.src=g})})}function uo({box:g,cells:A,dotScale:I,color:B,opacity:Q}){A.x=Math.max(1,Math.round(A.x)),A.y=Math.max(1,Math.round(A.y)),A.z=Math.max(1,Math.round(A.z)),Q=Q??1;const C=A.x*A.y*A.z,E=gA("int",A.x),t=gA("int",A.y);gA("int",A.z);const i=HA(0),e=new jg({numSplats:C,generator:UA({index:"int"},{gsplat:BA},({index:s})=>{if(!s)throw new Error("index is undefined");const o=YI(s,E),r=BI(s,E),c=YI(r,t),h=BI(r,t),w=qA({vectorType:"ivec3",x:o,y:c,z:h}),D=ZC(i),y=qA({vectorType:"ivec2",x:s,y:D}),l=WE(y),d=gA("vec3",g.min),u=gA("vec3",g.max),p=xg(u,d),m=BI(pA(sg(w),l),gA("vec3",A));let M,G,J;B?(M=gA("float",B.r),G=gA("float",B.g),J=gA("float",B.b)):{r:M,g:G,b:J}=mg(m).outputs;const k=qA({vectorType:"vec4",r:M,g:G,b:J,a:gA("float",Q)}),N=pA(d,cA(p,m)),Y=sg(gA("float",I)),F=gA("vec4",new a.Quaternion(0,0,0,1));let f=lg({flags:EI("uint","GSPLAT_FLAG_ACTIVE"),index:s,center:N,scales:Y,quaternion:F,rgba:k});return f=n.applyGsplat(f),{gsplat:f}},{globals:()=>[kA]}),update:({time:s})=>{i.value=s,n.update(e),e.updateVersion()}}),n=new tg;return e}const Go={box:new a.Box3(new a.Vector3(-1,-1,-1),new a.Vector3(1,1,1)),density:100,fallDirection:new a.Vector3(-1,-3,1).normalize(),fallVelocity:.02,wanderScale:.04,wanderVariance:2,color1:new a.Color(1,1,1),color2:new a.Color(.5,.5,1),minScale:.001,maxScale:.005,anisoScale:new a.Vector3(1,1,1)},Mo={box:new a.Box3(new a.Vector3(-2,-1,-2),new a.Vector3(2,5,2)),density:10,fallDirection:new a.Vector3(0,-1,0),fallVelocity:2,wanderScale:.1,wanderVariance:1,color1:new a.Color(1,1,1),color2:new a.Color(.25,.25,.5),minScale:.005,maxScale:.01,anisoScale:new a.Vector3(.1,1,.1)};function No({box:g,minY:A,numSplats:I,density:B,anisoScale:Q,minScale:C,maxScale:E,fallDirection:t,fallVelocity:i,wanderScale:e,wanderVariance:n,color1:s,color2:o,opacity:r,onFrame:c}){g=g??new a.Box3(new a.Vector3(-1,-1,-1),new a.Vector3(1,1,1));const h=(g.max.x-g.min.x)*(g.max.y-g.min.y)*(g.max.z-g.min.z);B=B??100,I=I??Math.max(1,Math.min(1e6,Math.round(h*B)));const w=HA(C??.001),D=HA(E??.005),y=OA(((Q==null?void 0:Q.clone())??new a.Vector3(1,1,1)).normalize()),l=OA((t??new a.Vector3(0,-1,0)).normalize()),d=HA(i??.02),u=HA(e??.01),p=HA(n??2),m=OA(s??new a.Color(1,1,1)),M=OA(o??new a.Color(.5,.5,1)),G=HA(r??1),J=HA(0),k=OA(new a.Vector3(0,0,0)),N=OA(g.min),Y=OA(g.max),F=HA(A??Number.NEGATIVE_INFINITY),f=xg(Y,N),U=new jg({numSplats:I,generator:UA({index:"int"},{gsplat:BA},({index:K})=>{if(!K)throw new Error("index not defined");const Z=UI(K),QA=mg(Z).outputs.w;let z=sg(Z),AA=QI(cA(QA,gA("float",100)));AA=xI(cA(EI("float","PI"),AA)),AA=pA(w,cA(AA,xg(D,w)));const $=cA(AA,y),P=QI(cA(QA,gA("float",10))),j=QI(QA),V=VQ(m,M,j),x=cA(V,P),dA=UI(qA({vectorType:"ivec2",x:K,y:gA("int",6837)}));let sA=sg(dA),b=cA(mg(dA).outputs.w,p);b=pA(J,b),z=pA(z,k);const oA=vQ(z,gA("vec3",new a.V Line truncated
-3398
View File
File diff suppressed because it is too large. Load diff
+966 -114
View File
File diff suppressed because it is too large. Load diff
+4870 -4277
View File
File diff suppressed because it is too large. Load diff
+136
View File
@@ -0,0 +1,136 @@
import { ForgeViewpoint, ForgeViewpointOptions } from './ForgeViewpoint';
import { RgbaArray } from './RgbaArray';
import { SplatAccumulator } from './SplatAccumulator';
import { SplatGenerator } from './SplatGenerator';
import * as THREE from "three";
export type ForgeRendererOptions = {
renderer: THREE.WebGLRenderer;
clock?: THREE.Clock;
autoUpdate?: boolean;
preUpdate?: boolean;
originDistance?: number;
maxStdDev?: number;
enable2DGS?: boolean;
preBlurAmount?: number;
blurAmount?: number;
falloff?: number;
clipXY?: number;
view?: ForgeViewpointOptions;
};
export declare class ForgeRenderer extends THREE.Mesh {
renderer: THREE.WebGLRenderer;
material: THREE.ShaderMaterial;
uniforms: ReturnType<typeof ForgeRenderer.makeUniforms>;
autoUpdate: boolean;
preUpdate: boolean;
originDistance: number;
maxStdDev: number;
enable2DGS: boolean;
preBlurAmount: number;
blurAmount: number;
falloff: number;
clipXY: number;
time?: number;
deltaTime?: number;
clock: THREE.Clock;
active: SplatAccumulator;
private freeAccumulators;
private accumulatorCount;
defaultView: ForgeViewpoint;
autoViewpoints: ForgeViewpoint[];
private rotateToAccumulator;
private translateToAccumulator;
private modifier;
private lastFrame;
private lastUpdateTime;
private defaultCameras;
viewpoint: ForgeViewpoint;
private pendingUpdate;
private envViewpoint;
private static cubeRender;
private static pmrem;
constructor(options: ForgeRendererOptions);
static makeUniforms(): {
renderSize: {
value: THREE.Vector2;
};
numSplats: {
value: number;
};
renderToViewQuat: {
value: THREE.Quaternion;
};
renderToViewPos: {
value: THREE.Vector3;
};
maxStdDev: {
value: number;
};
enable2DGS: {
value: boolean;
};
preBlurAmount: {
value: number;
};
blurAmount: {
value: number;
};
falloff: {
value: number;
};
clipXY: {
value: number;
};
packedSplats: {
type: string;
value: THREE.DataArrayTexture;
};
time: {
value: number;
};
deltaTime: {
value: number;
};
encodeLinear: {
value: boolean;
};
debugFlag: {
value: boolean;
};
};
private canAllocAccumulator;
private maybeAllocAccumulator;
releaseAccumulator(accumulator: SplatAccumulator): void;
newViewpoint(options: ForgeViewpointOptions): ForgeViewpoint;
onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera): void;
prepareViewpoint(viewpoint?: ForgeViewpoint): void;
update({ scene, viewToWorld, }: {
scene: THREE.Scene;
viewToWorld?: THREE.Matrix4;
}): void;
updateInternal({ scene, originToWorld, viewToWorld, }: {
scene: THREE.Scene;
originToWorld?: THREE.Matrix4;
viewToWorld?: THREE.Matrix4;
}): boolean;
private compileScene;
renderEnvMap({ renderer, scene, worldCenter, size, near, far, hideObjects, update, }: {
renderer?: THREE.WebGLRenderer;
scene: THREE.Scene;
worldCenter: THREE.Vector3;
size?: number;
near?: number;
far?: number;
hideObjects?: THREE.Object3D[];
update?: boolean;
}): Promise<THREE.Texture>;
recurseSetEnvMap(root: THREE.Object3D, envMap: THREE.Texture): void;
getRgba({ generator, rgba, }: {
generator: SplatGenerator;
rgba?: RgbaArray;
}): RgbaArray;
readRgba({ generator, rgba, }: {
generator: SplatGenerator;
rgba?: RgbaArray;
}): Promise<Uint8Array>;
}
+83
View File
@@ -0,0 +1,83 @@
import { ForgeRenderer } from './ForgeRenderer';
import { SplatAccumulator } from './SplatAccumulator';
import { SplatGeometry } from './SplatGeometry';
import * as THREE from "three";
export type ForgeViewpointOptions = {
autoUpdate?: boolean;
camera?: THREE.Camera;
viewToWorld?: THREE.Matrix4;
target?: {
width: number;
height: number;
doubleBuffer?: boolean;
superXY?: number;
};
onTextureUpdated?: (texture: THREE.Texture) => void;
sortRadial?: boolean;
sortDistance?: number;
sortCoorient?: boolean;
depthBias?: number;
sort360?: boolean;
};
export declare class ForgeViewpoint {
forge: ForgeRenderer;
autoUpdate: boolean;
camera?: THREE.Camera;
viewToWorld: THREE.Matrix4;
lastTime: number | null;
target?: THREE.WebGLRenderTarget;
private back?;
onTextureUpdated?: (texture: THREE.Texture) => void;
encodeLinear: boolean;
superXY: number;
private superPixels?;
private pixels?;
sortRadial: boolean;
sortDistance?: number;
sortCoorient?: boolean;
depthBias?: number;
sort360?: boolean;
display: {
accumulator: SplatAccumulator;
viewToWorld: THREE.Matrix4;
geometry: SplatGeometry;
} | null;
private sorting;
private pending;
private sortingCheck;
private readback;
private orderingFreelist;
constructor(options: ForgeViewpointOptions & {
forge: ForgeRenderer;
});
dispose(): void;
setAutoUpdate(autoUpdate: boolean): void;
prepare({ scene, camera, viewToWorld, update, forceOrigin, }: {
scene: THREE.Scene;
camera?: THREE.Camera;
viewToWorld?: THREE.Matrix4;
update?: boolean;
forceOrigin?: boolean;
}): Promise<void>;
renderTarget({ scene, camera, }: {
scene: THREE.Scene;
camera?: THREE.Camera;
}): void;
readTarget(): Promise<Uint8Array>;
prepareRenderPixels({ scene, camera, viewToWorld, update, forceOrigin, }: {
scene: THREE.Scene;
camera?: THREE.Camera;
viewToWorld?: THREE.Matrix4;
update?: boolean;
forceOrigin?: boolean;
}): Promise<Uint8Array<ArrayBufferLike>>;
autoPoll({ accumulator }: {
accumulator?: SplatAccumulator;
}): void;
private driveSort;
private sortUpdate;
private updateDisplay;
static EMPTY_TEXTURE: THREE.Texture;
private static dynos;
private static makeSorter;
}
+87
View File
@@ -0,0 +1,87 @@
import { GsplatGenerator } from './SplatGenerator';
import { SplatFileType } from './SplatLoader';
import { DynoProgram, DynoProgramTemplate, DynoUniform } from './dyno';
import { TPackedSplats } from './dyno/splats';
import * as THREE from "three";
export type PackedSplatsOptions = {
url?: string;
fileBytes?: Uint8Array | ArrayBuffer;
fileType?: SplatFileType;
fileName?: string;
maxSplats?: number;
packedArray?: Uint32Array;
numSplats?: number;
construct?: (splats: PackedSplats) => Promise<void> | void;
extra?: Record<string, unknown>;
};
export declare class PackedSplats {
maxSplats: number;
numSplats: number;
packedArray: Uint32Array | null;
extra: Record<string, unknown>;
initialized: Promise<PackedSplats>;
isInitialized: boolean;
target: THREE.WebGLArrayRenderTarget | null;
source: THREE.DataArrayTexture | null;
needsUpdate: boolean;
dyno: DynoUniform<typeof TPackedSplats, "packedSplats">;
constructor(options?: PackedSplatsOptions);
reinitialize(options: PackedSplatsOptions): void;
initialize(options: PackedSplatsOptions): void;
asyncInitialize(options: PackedSplatsOptions): Promise<void>;
dispose(): void;
ensureSplats(numSplats: number): Uint32Array;
ensureSplatsSh(level: number, numSplats: number): Uint32Array;
getSplat(index: number): {
center: THREE.Vector3;
scales: THREE.Vector3;
quaternion: THREE.Quaternion;
opacity: number;
color: THREE.Color;
};
setSplat(index: number, center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color): void;
pushSplat(center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color): void;
forEachSplat(callback: (index: number, center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color) => void): void;
ensureGenerate(maxSplats: number): boolean;
generateMapping(splatCounts: number[]): {
maxSplats: number;
mapping: {
base: number;
count: number;
}[];
};
getTexture(): THREE.DataArrayTexture;
private maybeUpdateSource;
private static emptySource;
static getEmpty(): THREE.DataArrayTexture;
prepareProgramMaterial(generator: GsplatGenerator): {
program: DynoProgram;
material: THREE.RawShaderMaterial;
};
private saveRenderState;
private resetRenderState;
generate({ generator, base, count, renderer, }: {
generator: GsplatGenerator;
base: number;
count: number;
renderer: THREE.WebGLRenderer;
}): {
nextBase: number;
};
static programTemplate: DynoProgramTemplate | null;
static generatorProgram: Map<GsplatGenerator, DynoProgram>;
static geometry: THREE.PlaneGeometry;
static mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.RawShaderMaterial, THREE.Object3DEventMap>;
static scene: THREE.Scene;
static camera: THREE.Camera;
}
export declare const dynoPackedSplats: (packedSplats?: PackedSplats) => DynoPackedSplats;
export declare class DynoPackedSplats extends DynoUniform<typeof TPackedSplats, "packedSplats", {
texture: THREE.DataArrayTexture;
numSplats: number;
}> {
packedSplats?: PackedSplats;
constructor({ packedSplats }?: {
packedSplats?: PackedSplats;
});
}
+50
View File
@@ -0,0 +1,50 @@
import { Dyno } from './dyno';
import { DynoProgram, DynoProgramTemplate } from './dyno/program';
import * as THREE from "three";
export type Rgba8Readback = Dyno<{
index: "int";
}, {
rgba8: "vec4";
}>;
export type ReadbackBuffer = ArrayBuffer | Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array;
export declare class Readback {
renderer?: THREE.WebGLRenderer;
target?: THREE.WebGLArrayRenderTarget;
capacity: number;
count: number;
constructor({ renderer }?: {
renderer?: THREE.WebGLRenderer;
});
dispose(): void;
ensureBuffer<B extends ReadbackBuffer>(count: number, buffer: B): B;
ensureCapacity(capacity: number): void;
prepareProgramMaterial(reader: Rgba8Readback): {
program: DynoProgram;
material: THREE.RawShaderMaterial;
};
private saveRenderState;
private resetRenderState;
private process;
private read;
render({ reader, count, renderer, }: {
reader: Rgba8Readback;
count: number;
renderer?: THREE.WebGLRenderer;
}): void;
readback<B extends ReadbackBuffer>({ readback, }: {
readback: B;
}): Promise<B>;
renderReadback<B extends ReadbackBuffer>({ reader, count, renderer, readback, }: {
reader: Rgba8Readback;
count: number;
renderer?: THREE.WebGLRenderer;
readback: B;
}): Promise<B>;
getTexture(): THREE.DataArrayTexture | undefined;
static programTemplate: DynoProgramTemplate | null;
static readbackProgram: Map<Rgba8Readback, DynoProgram>;
static geometry: THREE.PlaneGeometry;
static mesh: THREE.Mesh<THREE.PlaneGeometry, THREE.RawShaderMaterial, THREE.Object3DEventMap>;
static scene: THREE.Scene;
static camera: THREE.Camera;
}
+44
View File
@@ -0,0 +1,44 @@
import { PackedSplats } from './PackedSplats';
import { Readback, Rgba8Readback } from './Readback';
import { DynoUniform, DynoVal } from './dyno';
import * as THREE from "three";
export type RgbaArrayOptions = {
capacity?: number;
array?: Uint8Array;
count?: number;
};
export declare class RgbaArray {
capacity: number;
count: number;
array: Uint8Array | null;
readback: Readback | null;
source: THREE.DataArrayTexture | null;
needsUpdate: boolean;
dyno: DynoUniform<typeof TRgbaArray, "rgbaArray">;
constructor(options?: RgbaArrayOptions);
dispose(): void;
ensureCapacity(capacity: number): Uint8Array;
getTexture(): THREE.DataArrayTexture;
private maybeUpdateSource;
render({ reader, count, renderer, }: {
reader: Rgba8Readback;
count: number;
renderer: THREE.WebGLRenderer;
}): void;
fromPackedSplats({ packedSplats, base, count, renderer, }: {
packedSplats: PackedSplats;
base: number;
count: number;
renderer: THREE.WebGLRenderer;
}): this;
read(): Promise<Uint8Array>;
private static emptySource;
static getEmpty(): THREE.DataArrayTexture;
private static dynos;
private static makeDynos;
}
export declare const TRgbaArray: {
type: "RgbaArray";
};
export declare const defineRgbaArray: string;
export declare function readRgbaArray(rgba: DynoVal<typeof TRgbaArray>, index: DynoVal<"int">): DynoVal<"vec4">;
+27
View File
@@ -0,0 +1,27 @@
import { PackedSplats } from './PackedSplats';
import { GsplatGenerator, SplatGenerator, SplatModifier } from './SplatGenerator';
import * as THREE from "three";
export type GeneratorMapping = {
node: SplatGenerator;
generator?: GsplatGenerator;
version: number;
base: number;
count: number;
};
export declare class SplatAccumulator {
splats: PackedSplats;
toWorld: THREE.Matrix4;
mapping: GeneratorMapping[];
refCount: number;
splatsVersion: number;
mappingVersion: number;
ensureGenerate(maxSplats: number): void;
generateSplats({ renderer, modifier, generators, forceUpdate, originToWorld, }: {
renderer: THREE.WebGLRenderer;
modifier: SplatModifier;
generators: GeneratorMapping[];
forceUpdate?: boolean;
originToWorld: THREE.Matrix4;
}): boolean;
hasCorrespondence(other: SplatAccumulator): boolean;
}
+94
View File
@@ -0,0 +1,94 @@
import { DynoUniform, DynoVal, Gsplat } from './dyno';
import * as THREE from "three";
export declare enum SplatEditSdfType {
ALL = "all",
PLANE = "plane",
SPHERE = "sphere",
BOX = "box",
ELLIPSOID = "ellipsoid",
CYLINDER = "cylinder",
CAPSULE = "capsule",
INFINITE_CONE = "infinite_cone"
}
export declare enum SplatEditRgbaBlendMode {
MULTIPLY = "multiply",
SET_RGB = "set_rgb",
ADD_RGBA = "add_rgba"
}
export type SplatEditSdfOptions = {
type?: SplatEditSdfType;
invert?: boolean;
opacity?: number;
color?: THREE.Color;
displace?: THREE.Vector3;
radius?: number;
};
export declare class SplatEditSdf extends THREE.Object3D {
type: SplatEditSdfType;
invert: boolean;
opacity: number;
color: THREE.Color;
displace: THREE.Vector3;
radius: number;
constructor(options?: SplatEditSdfOptions);
}
export type SplatEditOptions = {
name?: string;
rgbaBlendMode?: SplatEditRgbaBlendMode;
sdfSmooth?: number;
softEdge?: number;
invert?: boolean;
sdfs?: SplatEditSdf[];
};
export declare class SplatEdit extends THREE.Object3D {
ordering: number;
rgbaBlendMode: SplatEditRgbaBlendMode;
sdfSmooth: number;
softEdge: number;
invert: boolean;
sdfs: SplatEditSdf[] | null;
static nextOrdering: number;
constructor(options?: SplatEditOptions);
addSdf(sdf: SplatEditSdf): void;
removeSdf(sdf: SplatEditSdf): void;
}
export declare class SplatEdits {
maxSdfs: number;
numSdfs: number;
sdfData: Uint32Array;
sdfFloatData: Float32Array;
sdfTexture: THREE.DataTexture;
dynoSdfArray: DynoUniform<typeof SdfArray, "sdfArray">;
maxEdits: number;
numEdits: number;
editData: Uint32Array;
editFloatData: Float32Array;
dynoNumEdits: DynoUniform<"int", "numEdits">;
dynoEdits: DynoUniform<"uvec4", "edits">;
constructor({ maxSdfs, maxEdits }: {
maxSdfs?: number;
maxEdits?: number;
});
private newSdfTexture;
private newEdits;
private ensureCapacity;
private updateEditData;
private updateEditFloatData;
private encodeEdit;
private updateSdfData;
private updateSdfFloatData;
private encodeSdf;
update(edits: {
edit: SplatEdit;
sdfs: SplatEditSdf[];
}[]): {
updated: boolean;
dynoUpdated: boolean;
};
modify(gsplat: DynoVal<typeof Gsplat>): DynoVal<typeof Gsplat>;
}
export declare const SdfArray: {
type: "SdfArray";
};
export declare const defineSdfArray: string;
export declare const defineEdit: string;
+61
View File
@@ -0,0 +1,61 @@
import { SplatEdit } from './SplatEdit';
import { Dyno, DynoFloat, DynoVal, DynoVec3, DynoVec4, Gsplat } from './dyno';
import * as THREE from "three";
export type GsplatGenerator = Dyno<{
index: "int";
}, {
gsplat: typeof Gsplat;
}>;
export type GsplatModifier = Dyno<{
gsplat: typeof Gsplat;
}, {
gsplat: typeof Gsplat;
}>;
export declare class SplatModifier {
modifier: GsplatModifier;
cache: Map<GsplatGenerator, GsplatGenerator>;
constructor(modifier: GsplatModifier);
apply(generator: GsplatGenerator): GsplatGenerator;
}
export declare class SplatTransformer {
scale: DynoFloat;
rotate: DynoVec4<THREE.Quaternion>;
translate: DynoVec3<THREE.Vector3>;
constructor();
apply(position: DynoVal<"vec3">): DynoVal<"vec3">;
applyDir(dir: DynoVal<"vec3">): DynoVal<"vec3">;
applyGsplat(gsplat: DynoVal<typeof Gsplat>): DynoVal<typeof Gsplat>;
updateFromMatrix(transform: THREE.Matrix4): boolean;
update(object: THREE.Object3D): boolean;
}
export declare class SplatGenerator extends THREE.Object3D {
numSplats: number;
generator?: GsplatGenerator;
generatorError?: unknown;
frameUpdate?: ({ object, time, deltaTime, viewToWorld, globalEdits, }: {
object: SplatGenerator;
time: number;
deltaTime: number;
viewToWorld: THREE.Matrix4;
globalEdits: SplatEdit[];
}) => void;
version: number;
constructor({ numSplats, generator, construct, update, }: {
numSplats?: number;
generator?: GsplatGenerator;
construct?: (object: SplatGenerator) => {
generator?: GsplatGenerator;
numSplats?: number;
frameUpdate?: (object: SplatGenerator) => void;
};
update?: ({ object, time, deltaTime, viewToWorld, globalEdits, }: {
object: SplatGenerator;
time: number;
deltaTime: number;
viewToWorld: THREE.Matrix4;
globalEdits: SplatEdit[];
}) => void;
});
updateVersion(): void;
set needsUpdate(value: boolean);
}
+7
View File
@@ -0,0 +1,7 @@
import * as THREE from "three";
export declare class SplatGeometry extends THREE.InstancedBufferGeometry {
ordering: Uint32Array;
attribute: THREE.InstancedBufferAttribute;
constructor(ordering: Uint32Array, activeSplats: number);
update(ordering: Uint32Array, activeSplats: number): void;
}
+81
View File
@@ -0,0 +1,81 @@
import { FileLoader, Loader, LoadingManager } from 'three';
import { PackedSplats } from './PackedSplats';
import { SplatMesh } from './SplatMesh';
export declare class SplatLoader extends Loader {
fileLoader: FileLoader;
fileType?: SplatFileType;
constructor(manager?: LoadingManager);
load(url: string, onLoad?: (decoded: PackedSplats) => void, onProgress?: (event: ProgressEvent) => void, onError?: (error: unknown) => void): void;
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<PackedSplats>;
parse(packedSplats: PackedSplats): SplatMesh;
}
export declare enum SplatFileType {
PLY = "ply",
WLG0 = "wlg0",
SPZ = "spz",
SPLAT = "splat",
KSPLAT = "ksplat"
}
export declare function getSplatFileType(fileBytes: Uint8Array): SplatFileType | undefined;
export declare function getFileExtension(pathOrUrl: string): string;
export declare function getSplatFileTypeFromPath(pathOrUrl: string): SplatFileType | undefined;
export declare function unpackSplats({ input, fileType, pathOrUrl, }: {
input: Uint8Array | ArrayBuffer;
fileType?: SplatFileType;
pathOrUrl?: string;
}): Promise<{
packedArray: Uint32Array;
numSplats: number;
extra?: Record<string, unknown>;
}>;
export declare class SplatData {
numSplats: number;
maxSplats: number;
centers: Float32Array;
scales: Float32Array;
quaternions: Float32Array;
opacities: Float32Array;
colors: Float32Array;
sh1?: Float32Array;
sh2?: Float32Array;
sh3?: Float32Array;
constructor({ maxSplats }?: {
maxSplats?: number;
});
pushSplat(): number;
unpushSplat(index: number): void;
ensureCapacity(numSplats: number): void;
ensureIndex(index: number): void;
setCenter(index: number, x: number, y: number, z: number): void;
setScale(index: number, scaleX: number, scaleY: number, scaleZ: number): void;
setQuaternion(index: number, x: number, y: number, z: number, w: number): void;
setOpacity(index: number, opacity: number): void;
setColor(index: number, r: number, g: number, b: number): void;
setSh1(index: number, sh1: Float32Array): void;
setSh2(index: number, sh2: Float32Array): void;
setSh3(index: number, sh3: Float32Array): void;
}
export declare function transcodeSpz(input: TranscodeSpzInput): Promise<{
input: TranscodeSpzInput;
fileBytes: Uint8Array;
}>;
export type FileInput = {
fileBytes: Uint8Array;
fileType?: SplatFileType;
pathOrUrl?: string;
transform?: {
translate?: number[];
quaternion?: number[];
scale?: number;
};
};
export type TranscodeSpzInput = {
inputs: FileInput[];
maxSh?: number;
clipXyz?: {
min: number[];
max: number[];
};
fractionalBits?: number;
opacityThreshold?: number;
};
+85
View File
@@ -0,0 +1,85 @@
import { PackedSplats } from './PackedSplats';
import { RgbaArray } from './RgbaArray';
import { SplatEdit } from './SplatEdit';
import { GsplatModifier, SplatGenerator, SplatTransformer } from './SplatGenerator';
import { SplatFileType } from './SplatLoader';
import { SplatSkinning } from './SplatSkinning';
import { DynoFloat, DynoUsampler2DArray, DynoVal, DynoVec4, Gsplat } from './dyno';
import * as THREE from "three";
export type SplatMeshOptions = {
url?: string;
fileBytes?: Uint8Array | ArrayBuffer;
fileType?: SplatFileType;
fileName?: string;
packedSplats?: PackedSplats;
maxSplats?: number;
constructSplats?: (splats: PackedSplats) => Promise<void> | void;
onLoad?: (mesh: SplatMesh) => Promise<void> | void;
editable?: boolean;
onFrame?: ({ mesh, time, deltaTime, }: {
mesh: SplatMesh;
time: number;
deltaTime: number;
}) => void;
objectModifier?: GsplatModifier;
worldModifier?: GsplatModifier;
};
export type SplatMeshContext = {
transform: SplatTransformer;
viewToWorld: SplatTransformer;
worldToView: SplatTransformer;
viewToObject: SplatTransformer;
recolor: DynoVec4<THREE.Vector4>;
time: DynoFloat;
deltaTime: DynoFloat;
};
export declare class SplatMesh extends SplatGenerator {
initialized: Promise<SplatMesh>;
isInitialized: boolean;
packedSplats: PackedSplats;
recolor: THREE.Color;
opacity: number;
context: SplatMeshContext;
onFrame?: ({ mesh, time, deltaTime, }: {
mesh: SplatMesh;
time: number;
deltaTime: number;
}) => void;
objectModifier?: GsplatModifier;
worldModifier?: GsplatModifier;
enableViewToObject: boolean;
enableViewToWorld: boolean;
enableWorldToView: boolean;
skinning: SplatSkinning | null;
edits: SplatEdit[] | null;
editable: boolean;
private rgbaDisplaceEdits;
splatRgba: RgbaArray | null;
maxSh: number;
constructor(options?: SplatMeshOptions);
asyncInitialize(options: SplatMeshOptions): Promise<void>;
static staticInitialized: Promise<void>;
static isStaticInitialized: boolean;
static dynoTime: DynoFloat<"value">;
static staticInitialize(): Promise<void>;
pushSplat(center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color): void;
forEachSplat(callback: (index: number, center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color) => void): void;
dispose(): void;
constructGenerator(context: SplatMeshContext): void;
updateGenerator(): void;
update({ time, viewToWorld, deltaTime, globalEdits, }: {
time: number;
viewToWorld: THREE.Matrix4;
deltaTime: number;
globalEdits: SplatEdit[];
}): void;
raycast(raycaster: THREE.Raycaster, intersects: {
distance: number;
point: THREE.Vector3;
object: THREE.Object3D;
}[]): void;
private ensureShTextures;
}
export declare function evaluateSH1(gsplat: DynoVal<typeof Gsplat>, sh1: DynoUsampler2DArray<"sh1", THREE.DataArrayTexture>, viewDir: DynoVal<"vec3">): DynoVal<"vec3">;
export declare function evaluateSH2(gsplat: DynoVal<typeof Gsplat>, sh2: DynoVal<"usampler2DArray">, viewDir: DynoVal<"vec3">): DynoVal<"vec3">;
export declare function evaluateSH3(gsplat: DynoVal<typeof Gsplat>, sh3: DynoVal<"usampler2DArray">, viewDir: DynoVal<"vec3">): DynoVal<"vec3">;
+29
View File
@@ -0,0 +1,29 @@
import { SplatMesh } from './SplatMesh';
import { DynoUniform, DynoVal, Gsplat } from './dyno';
import * as THREE from "three";
export type SplatSkinningOptions = {
mesh: SplatMesh;
numSplats?: number;
numBones?: number;
};
export declare class SplatSkinning {
mesh: SplatMesh;
numSplats: number;
skinData: Uint16Array;
skinTexture: THREE.DataArrayTexture;
numBones: number;
boneData: Float32Array;
boneTexture: THREE.DataTexture;
uniform: DynoUniform<typeof GsplatSkinning, "skinning">;
constructor(options: SplatSkinningOptions);
modify(gsplat: DynoVal<typeof Gsplat>): DynoVal<typeof Gsplat>;
setRestQuatPos(boneIndex: number, quat: THREE.Quaternion, pos: THREE.Vector3): void;
setBoneQuatPos(boneIndex: number, quat: THREE.Quaternion, pos: THREE.Vector3): void;
setSplatBones(splatIndex: number, boneIndices: THREE.Vector4, weights: THREE.Vector4): void;
updateBones(): void;
}
export declare const GsplatSkinning: {
type: "GsplatSkinning";
};
export declare const defineGsplatSkinning: string;
export declare const defineApplyGsplatSkinning: string;
+5
View File
@@ -0,0 +1,5 @@
export declare function decodeAntiSplat(fileBytes: Uint8Array, initNumSplats: (numSplats: number) => void, splatCallback: (index: number, x: number, y: number, z: number, scaleX: number, scaleY: number, scaleZ: number, quatX: number, quatY: number, quatZ: number, quatW: number, opacity: number, r: number, g: number, b: number) => void): void;
export declare function unpackAntiSplat(fileBytes: Uint8Array): {
packedArray: Uint32Array;
numSplats: number;
};
+114
View File
@@ -0,0 +1,114 @@
import * as THREE from "three";
export declare class ForgeControls {
fpsMovement: FpsMovement;
pointerControls: PointerControls;
lastTime: number;
constructor({ canvas }: {
canvas: HTMLCanvasElement;
});
update(control: THREE.Object3D): void;
}
export declare class FpsMovement {
moveSpeed: number;
rollSpeed: number;
stickThreshold: number;
rotateSpeed: number;
keycodeMoveMapping: {
[key: string]: THREE.Vector3;
};
keycodeRotateMapping: {
[key: string]: THREE.Vector3;
};
gamepadMapping: {
[button: number]: "shift" | "ctrl" | "rollLeft" | "rollRight";
};
capsMultiplier: number;
shiftMultiplier: number;
ctrlMultiplier: number;
xr?: THREE.WebXRManager;
enable: boolean;
keydown: {
[key: string]: boolean;
};
keycode: {
[key: string]: boolean;
};
constructor({ moveSpeed, rollSpeed, stickThreshold, rotateSpeed, keycodeMoveMapping, keycodeRotateMapping, gamepadMapping, capsMultiplier, shiftMultiplier, ctrlMultiplier, xr, }?: {
moveSpeed?: number;
rollSpeed?: number;
stickThreshold?: number;
rotateSpeed?: number;
keycodeMoveMapping?: {
[key: string]: THREE.Vector3;
};
keycodeRotateMapping?: {
[key: string]: THREE.Vector3;
};
gamepadMapping?: {
[button: number]: "shift" | "ctrl" | "rollLeft" | "rollRight";
};
capsMultiplier?: number;
shiftMultiplier?: number;
ctrlMultiplier?: number;
xr?: THREE.WebXRManager;
});
update(deltaTime: number, control: THREE.Object3D): void;
}
type PointerState = {
initial: THREE.Vector2;
last: THREE.Vector2;
position: THREE.Vector2;
pointerId: number;
button?: number;
timeStamp: DOMHighResTimeStamp;
};
export declare class PointerControls {
canvas: HTMLCanvasElement;
rotateSpeed: number;
slideSpeed: number;
scrollSpeed: number;
swapRotateSlide: boolean;
reverseRotate: boolean;
reverseSlide: boolean;
reverseSwipe: boolean;
reverseScroll: boolean;
moveInertia: number;
rotateInertia: number;
enable: boolean;
doublePress: ({ position, intervalMs, }: {
position: THREE.Vector2;
intervalMs: number;
}) => void;
doublePressLimitMs: number;
doublePressDistance: number;
lastUp: {
position: THREE.Vector2;
time: number;
} | null;
rotating: PointerState | null;
sliding: PointerState | null;
dualPress: boolean;
scroll: THREE.Vector3;
rotateVelocity: THREE.Vector3;
moveVelocity: THREE.Vector3;
constructor({ canvas, rotateSpeed, slideSpeed, scrollSpeed, swapRotateSlide, reverseRotate, reverseSlide, reverseSwipe, reverseScroll, moveInertia, rotateInertia, doublePress, }: {
canvas: HTMLCanvasElement;
rotateSpeed?: number;
slideSpeed?: number;
scrollSpeed?: number;
swapRotateSlide?: boolean;
reverseRotate?: boolean;
reverseSlide?: boolean;
reverseSwipe?: boolean;
reverseScroll?: boolean;
moveInertia?: number;
rotateInertia?: number;
doublePress?: ({ position, intervalMs, }: {
position: THREE.Vector2;
intervalMs: number;
}) => void;
});
getPointerPosition(event: PointerEvent): THREE.Vector2;
update(deltaTime: number, control: THREE.Object3D): void;
}
export {};
+17
View File
@@ -0,0 +1,17 @@
export declare const LN_SCALE_MIN = -9;
export declare const LN_SCALE_MAX = 9;
export declare const LN_RESCALE: number;
export declare const SCALE_MIN: number;
export declare const SCALE_MAX: number;
export declare const SPLAT_TEX_WIDTH_BITS = 11;
export declare const SPLAT_TEX_HEIGHT_BITS = 11;
export declare const SPLAT_TEX_DEPTH_BITS = 11;
export declare const SPLAT_TEX_LAYER_BITS: number;
export declare const SPLAT_TEX_WIDTH: number;
export declare const SPLAT_TEX_HEIGHT: number;
export declare const SPLAT_TEX_DEPTH: number;
export declare const SPLAT_TEX_MIN_HEIGHT = 1;
export declare const SPLAT_TEX_WIDTH_MASK: number;
export declare const SPLAT_TEX_HEIGHT_MASK: number;
export declare const SPLAT_TEX_DEPTH_MASK: number;
export declare const WASM_SPLAT_SORT = true;
+16
View File
@@ -0,0 +1,16 @@
export * from './dyno/types';
export * from './dyno/base';
export * from './dyno/value';
export * from './dyno/output';
export * from './dyno/uniforms';
export * from './dyno/program';
export * from './dyno/math';
export * from './dyno/logic';
export * from './dyno/util';
export * from './dyno/splats';
export * from './dyno/transform';
export * from './dyno/control';
export * from './dyno/convert';
export * from './dyno/texture';
export * from './dyno/trig';
export * from './dyno/vecmat';
+174
View File
@@ -0,0 +1,174 @@
import { IUniform } from 'three';
import { DynoType } from './types';
import { DynoVal, DynoValue, HasDynoOut } from './value';
export declare class Compilation {
globals: Set<string>;
statements: string[];
uniforms: Record<string, IUniform>;
declares: Set<string>;
updaters: (() => void)[];
sequence: number;
indent: string;
constructor({ indent }?: {
indent?: string;
});
nextSequence(): number;
}
export type IOTypes = Record<string, DynoType>;
type GenerateContext<InTypes extends IOTypes, OutTypes extends IOTypes> = {
inputs: {
[K in keyof InTypes]?: string;
};
outputs: {
[K in keyof OutTypes]?: string;
};
compile: Compilation;
};
export declare class Dyno<InTypes extends IOTypes, OutTypes extends IOTypes> {
inTypes: InTypes;
outTypes: OutTypes;
inputs: {
[K in keyof InTypes]?: DynoVal<InTypes[K]>;
};
update?: () => void;
globals?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => string[];
statements?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => string[];
generate: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => {
globals?: string[];
statements?: string[];
uniforms?: Record<string, IUniform>;
};
constructor({ inTypes, outTypes, inputs, update, globals, statements, generate, }: {
inTypes?: InTypes;
outTypes?: OutTypes;
inputs?: {
[K in keyof InTypes]?: DynoVal<InTypes[K]>;
};
update?: () => void;
globals?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => string[];
statements?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => string[];
generate?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => {
globals?: string[];
statements?: string[];
uniforms?: Record<string, IUniform>;
};
});
get outputs(): {
[K in keyof OutTypes]: DynoVal<OutTypes[K]>;
};
apply(inputs: {
[K in keyof InTypes]?: DynoVal<InTypes[K]>;
}): {
[K in keyof OutTypes]: DynoVal<OutTypes[K]>;
};
compile({ inputs, outputs, compile, }: {
inputs: {
[K in keyof InTypes]?: string;
};
outputs: {
[K in keyof OutTypes]?: string;
};
compile: Compilation;
}): string[];
}
export type DynoBlockType<InTypes extends IOTypes, OutTypes extends IOTypes> = (inputs: {
[K in keyof InTypes]?: DynoVal<InTypes[K]>;
}, outputs: {
[K in keyof OutTypes]?: DynoVal<OutTypes[K]>;
}, { roots }: {
roots: Dyno<InTypes, OutTypes>[];
}) => {
[K in keyof OutTypes]?: DynoVal<OutTypes[K]>;
} | undefined;
export declare class DynoBlock<InTypes extends IOTypes, OutTypes extends IOTypes> extends Dyno<InTypes, OutTypes> {
construct: DynoBlockType<InTypes, OutTypes>;
constructor({ inTypes, outTypes, inputs, update, globals, construct, }: {
inTypes?: InTypes;
outTypes?: OutTypes;
inputs?: {
[K in keyof InTypes]?: DynoVal<InTypes[K]>;
};
update?: () => void;
globals?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => string[];
construct: DynoBlockType<InTypes, OutTypes>;
});
generateBlock({ inputs, outputs, compile, }: {
inputs: {
[K in keyof InTypes]?: string;
};
outputs: {
[K in keyof OutTypes]?: string;
};
compile: Compilation;
}): {
statements: string[];
};
}
export declare function dynoBlock<InTypes extends Record<string, DynoType>, OutTypes extends Record<string, DynoType>>(inTypes: InTypes, outTypes: OutTypes, construct: DynoBlockType<InTypes, OutTypes>, { update, globals }?: {
update?: () => void;
globals?: () => string[];
}): DynoBlock<InTypes, OutTypes>;
export declare function dyno<InTypes extends Record<string, DynoType>, OutTypes extends Record<string, DynoType>>({ inTypes, outTypes, inputs, update, globals, statements, generate, }: {
inTypes: InTypes;
outTypes: OutTypes;
inputs?: {
[K in keyof InTypes]?: DynoVal<InTypes[K]>;
};
update?: () => void;
globals?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => string[];
statements?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => string[];
generate?: ({ inputs, outputs, compile, }: GenerateContext<InTypes, OutTypes>) => {
globals?: string[];
statements?: string[];
uniforms?: Record<string, IUniform>;
};
}): Dyno<InTypes, OutTypes>;
export declare function dynoDeclare(name: string, type: DynoType, count?: number): string;
export declare function unindentLines(s: string): string[];
export declare function unindent(s: string): string;
export declare class UnaryOp<A extends DynoType, OutType extends DynoType, OutKey extends string> extends Dyno<{
a: A;
}, {
[key in OutKey]: OutType;
}> implements HasDynoOut<OutType> {
constructor({ a, outKey, outTypeFunc, }: {
a: DynoVal<A>;
outKey: OutKey;
outTypeFunc: (aType: A) => OutType;
});
outKey: OutKey;
dynoOut(): DynoValue<OutType>;
}
export declare class BinaryOp<A extends DynoType, B extends DynoType, OutType extends DynoType, OutKey extends string> extends Dyno<{
a: A;
b: B;
}, {
[key in OutKey]: OutType;
}> implements HasDynoOut<OutType> {
constructor({ a, b, outKey, outTypeFunc, }: {
a: DynoVal<A>;
b: DynoVal<B>;
outKey: OutKey;
outTypeFunc: (aType: A, bType: B) => OutType;
});
outKey: OutKey;
dynoOut(): DynoValue<OutType>;
}
export declare class TrinaryOp<A extends DynoType, B extends DynoType, C extends DynoType, OutType extends DynoType, OutKey extends string> extends Dyno<{
a: A;
b: B;
c: C;
}, {
[key in OutKey]: OutType;
}> implements HasDynoOut<OutType> {
constructor({ a, b, c, outKey, outTypeFunc, }: {
a: DynoVal<A>;
b: DynoVal<B>;
c: DynoVal<C>;
outKey: OutKey;
outTypeFunc: (aType: A, bType: B, cType: C) => OutType;
});
outKey: OutKey;
dynoOut(): DynoValue<OutType>;
}
export {};
+6
View File
@@ -0,0 +1,6 @@
export declare const dynoIf: () => never;
export declare const dynoSwitch: () => never;
export declare const dynoFor: () => never;
export declare const comment: () => never;
export declare const arrayIndex: () => never;
export declare const arrayLength: () => never;
+190
View File
@@ -0,0 +1,190 @@
import { UnaryOp } from './base';
import { SimpleTypes } from './types';
import { DynoVal } from './value';
export declare const bool: <T extends "bool" | "int" | "uint" | "float">(value: DynoVal<T>) => DynoVal<"bool">;
export declare const int: <T extends "bool" | "int" | "uint" | "float">(value: DynoVal<T>) => DynoVal<"int">;
export declare const uint: <T extends "bool" | "int" | "uint" | "float">(value: DynoVal<T>) => DynoVal<"uint">;
export declare const float: <T extends "bool" | "int" | "uint" | "float">(value: DynoVal<T>) => DynoVal<"float">;
export declare const bvec2: <T extends "bool" | "bvec2" | "ivec2" | "uvec2" | "vec2">(value: DynoVal<T>) => DynoVal<"bvec2">;
export declare const bvec3: <T extends "bool" | "bvec3" | "ivec3" | "uvec3" | "vec3">(value: DynoVal<T>) => DynoVal<"bvec3">;
export declare const bvec4: <T extends "bool" | "bvec4" | "ivec4" | "uvec4" | "vec4">(value: DynoVal<T>) => DynoVal<"bvec4">;
export declare const ivec2: <T extends "int" | "bvec2" | "ivec2" | "uvec2" | "vec2">(value: DynoVal<T>) => DynoVal<"ivec2">;
export declare const ivec3: <T extends "int" | "bvec3" | "ivec3" | "uvec3" | "vec3">(value: DynoVal<T>) => DynoVal<"ivec3">;
export declare const ivec4: <T extends "int" | "bvec4" | "ivec4" | "uvec4" | "vec4">(value: DynoVal<T>) => DynoVal<"ivec4">;
export declare const uvec2: <T extends "uint" | "bvec2" | "ivec2" | "uvec2" | "vec2">(value: DynoVal<T>) => DynoVal<"uvec2">;
export declare const uvec3: <T extends "uint" | "bvec3" | "ivec3" | "uvec3" | "vec3">(value: DynoVal<T>) => DynoVal<"uvec3">;
export declare const uvec4: <T extends "uint" | "bvec4" | "ivec4" | "uvec4" | "vec4">(value: DynoVal<T>) => DynoVal<"uvec4">;
export declare const vec2: <T extends "float" | "bvec2" | "ivec2" | "uvec2" | "vec2" | "vec3" | "vec4">(value: DynoVal<T>) => DynoVal<"vec2">;
export declare const vec3: <T extends "float" | "bvec3" | "ivec3" | "uvec3" | "vec3" | "vec4">(value: DynoVal<T>) => DynoVal<"vec3">;
export declare const vec4: <T extends "float" | "bvec4" | "ivec4" | "uvec4" | "vec4">(value: DynoVal<T>) => DynoVal<"vec4">;
export declare const mat2: <T extends "float" | "mat2" | "mat3" | "mat4">(value: DynoVal<T>) => DynoVal<"mat2">;
export declare const mat3: <T extends "float" | "mat2" | "mat3" | "mat4">(value: DynoVal<T>) => DynoVal<"mat3">;
export declare const mat4: <T extends "float" | "mat2" | "mat3" | "mat4">(value: DynoVal<T>) => DynoVal<"mat4">;
export declare const floatBitsToInt: (value: DynoVal<"float">) => DynoVal<"int">;
export declare const floatBitsToUint: (value: DynoVal<"float">) => DynoVal<"uint">;
export declare const intBitsToFloat: (value: DynoVal<"int">) => DynoVal<"float">;
export declare const uintBitsToFloat: (value: DynoVal<"uint">) => DynoVal<"float">;
export declare const packSnorm2x16: (value: DynoVal<"vec2">) => DynoVal<"uint">;
export declare const unpackSnorm2x16: (value: DynoVal<"uint">) => DynoVal<"vec2">;
export declare const packUnorm2x16: (value: DynoVal<"vec2">) => DynoVal<"uint">;
export declare const unpackUnorm2x16: (value: DynoVal<"uint">) => DynoVal<"vec2">;
export declare const packHalf2x16: (value: DynoVal<"vec2">) => DynoVal<"uint">;
export declare const unpackHalf2x16: (value: DynoVal<"uint">) => DynoVal<"vec2">;
export declare const uintToRgba8: (value: DynoVal<"uint">) => DynoVal<"vec4">;
export declare class SimpleCast<Allowed extends SimpleTypes, OutType extends SimpleTypes, OutKey extends string> extends UnaryOp<Allowed, OutType, OutKey> {
constructor({ value, outType, outKey, }: {
value: DynoVal<Allowed>;
outType: OutType;
outKey: OutKey;
});
}
export declare class Bool extends SimpleCast<"bool" | "int" | "uint" | "float", "bool", "bool"> {
constructor({ value, }: {
value: DynoVal<"bool" | "int" | "uint" | "float">;
});
}
export declare class Int extends SimpleCast<"bool" | "int" | "uint" | "float", "int", "int"> {
constructor({ value, }: {
value: DynoVal<"bool" | "int" | "uint" | "float">;
});
}
export declare class Uint extends SimpleCast<"bool" | "int" | "uint" | "float", "uint", "uint"> {
constructor({ value, }: {
value: DynoVal<"bool" | "int" | "uint" | "float">;
});
}
export declare class Float extends SimpleCast<"bool" | "int" | "uint" | "float", "float", "float"> {
constructor({ value, }: {
value: DynoVal<"bool" | "int" | "uint" | "float">;
});
}
export declare class BVec2 extends SimpleCast<"bool" | "bvec2" | "ivec2" | "uvec2" | "vec2", "bvec2", "bvec2"> {
constructor({ value, }: {
value: DynoVal<"bool" | "bvec2" | "ivec2" | "uvec2" | "vec2">;
});
}
export declare class BVec3 extends SimpleCast<"bool" | "bvec3" | "ivec3" | "uvec3" | "vec3", "bvec3", "bvec3"> {
constructor({ value, }: {
value: DynoVal<"bool" | "bvec3" | "ivec3" | "uvec3" | "vec3">;
});
}
export declare class BVec4 extends SimpleCast<"bool" | "bvec4" | "ivec4" | "uvec4" | "vec4", "bvec4", "bvec4"> {
constructor({ value, }: {
value: DynoVal<"bool" | "bvec4" | "ivec4" | "uvec4" | "vec4">;
});
}
export declare class IVec2 extends SimpleCast<"int" | "bvec2" | "ivec2" | "uvec2" | "vec2", "ivec2", "ivec2"> {
constructor({ value, }: {
value: DynoVal<"int" | "bvec2" | "ivec2" | "uvec2" | "vec2">;
});
}
export declare class IVec3 extends SimpleCast<"int" | "bvec3" | "ivec3" | "uvec3" | "vec3", "ivec3", "ivec3"> {
constructor({ value, }: {
value: DynoVal<"int" | "bvec3" | "ivec3" | "uvec3" | "vec3">;
});
}
export declare class IVec4 extends SimpleCast<"int" | "bvec4" | "ivec4" | "uvec4" | "vec4", "ivec4", "ivec4"> {
constructor({ value, }: {
value: DynoVal<"int" | "bvec4" | "ivec4" | "uvec4" | "vec4">;
});
}
export declare class UVec2 extends SimpleCast<"uint" | "ivec2" | "bvec2" | "uvec2" | "vec2", "uvec2", "uvec2"> {
constructor({ value, }: {
value: DynoVal<"uint" | "ivec2" | "bvec2" | "uvec2" | "vec2">;
});
}
export declare class UVec3 extends SimpleCast<"uint" | "ivec3" | "bvec3" | "uvec3" | "vec3", "uvec3", "uvec3"> {
constructor({ value, }: {
value: DynoVal<"uint" | "ivec3" | "bvec3" | "uvec3" | "vec3">;
});
}
export declare class UVec4 extends SimpleCast<"uint" | "ivec4" | "bvec4" | "uvec4" | "vec4", "uvec4", "uvec4"> {
constructor({ value, }: {
value: DynoVal<"uint" | "ivec4" | "bvec4" | "uvec4" | "vec4">;
});
}
export declare class Vec2 extends SimpleCast<"float" | "bvec2" | "ivec2" | "uvec2" | "vec2" | "vec3" | "vec4", "vec2", "vec2"> {
constructor({ value, }: {
value: DynoVal<"float" | "bvec2" | "ivec2" | "uvec2" | "vec2" | "vec3" | "vec4">;
});
}
export declare class Vec3 extends SimpleCast<"float" | "bvec3" | "ivec3" | "uvec3" | "vec3" | "vec2" | "vec4", "vec3", "vec3"> {
constructor({ value, }: {
value: DynoVal<"float" | "bvec3" | "ivec3" | "uvec3" | "vec3" | "vec2" | "vec4">;
});
}
export declare class Vec4 extends SimpleCast<"float" | "bvec4" | "ivec4" | "uvec4" | "vec4", "vec4", "vec4"> {
constructor({ value, }: {
value: DynoVal<"float" | "bvec4" | "ivec4" | "uvec4" | "vec4">;
});
}
export declare class Mat2 extends SimpleCast<"float" | "mat2" | "mat3" | "mat4", "mat2", "mat2"> {
constructor({ value, }: {
value: DynoVal<"float" | "mat2" | "mat3" | "mat4">;
});
}
export declare class Mat3 extends SimpleCast<"float" | "mat2" | "mat3" | "mat4", "mat3", "mat3"> {
constructor({ value, }: {
value: DynoVal<"float" | "mat2" | "mat3" | "mat4">;
});
}
export declare class Mat4 extends SimpleCast<"float" | "mat2" | "mat3" | "mat4", "mat4", "mat4"> {
constructor({ value, }: {
value: DynoVal<"float" | "mat2" | "mat3" | "mat4">;
});
}
export declare class FloatBitsToInt extends UnaryOp<"float", "int", "int"> {
constructor({ value }: {
value: DynoVal<"float">;
});
}
export declare class FloatBitsToUint extends UnaryOp<"float", "uint", "uint"> {
constructor({ value }: {
value: DynoVal<"float">;
});
}
export declare class IntBitsToFloat extends UnaryOp<"int", "float", "float"> {
constructor({ value }: {
value: DynoVal<"int">;
});
}
export declare class UintBitsToFloat extends UnaryOp<"uint", "float", "float"> {
constructor({ value }: {
value: DynoVal<"uint">;
});
}
export declare class PackSnorm2x16 extends UnaryOp<"vec2", "uint", "uint"> {
constructor({ value }: {
value: DynoVal<"vec2">;
});
}
export declare class UnpackSnorm2x16 extends UnaryOp<"uint", "vec2", "vec2"> {
constructor({ value }: {
value: DynoVal<"uint">;
});
}
export declare class PackUnorm2x16 extends UnaryOp<"vec2", "uint", "uint"> {
constructor({ value }: {
value: DynoVal<"vec2">;
});
}
export declare class UnpackUnorm2x16 extends UnaryOp<"uint", "vec2", "vec2"> {
constructor({ value }: {
value: DynoVal<"uint">;
});
}
export declare class PackHalf2x16 extends UnaryOp<"vec2", "uint", "uint"> {
constructor({ value }: {
value: DynoVal<"vec2">;
});
}
export declare class UnpackHalf2x16 extends UnaryOp<"uint", "vec2", "vec2"> {
constructor({ value }: {
value: DynoVal<"uint">;
});
}
export declare class UintToRgba8 extends UnaryOp<"uint", "vec4", "rgba8"> {
constructor({ value }: {
value: DynoVal<"uint">;
});
}
+103
View File
@@ -0,0 +1,103 @@
import { BinaryOp, TrinaryOp, UnaryOp } from './base';
import { AllIntTypes, BoolTypes, IntTypes, ScalarTypes, SimpleTypes, UintTypes, ValueTypes } from './types';
import { DynoVal } from './value';
export declare const and: <T extends "bool" | AllIntTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<T>;
export declare const or: <T extends "bool" | AllIntTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<T>;
export declare const xor: <T extends "bool" | AllIntTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<T>;
export declare const not: <T extends BoolTypes | AllIntTypes>(a: DynoVal<T>) => DynoVal<T>;
export declare const lessThan: <T extends ValueTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<CompareOutput<T>>;
export declare const lessThanEqual: <T extends ValueTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<CompareOutput<T>>;
export declare const greaterThan: <T extends ValueTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<CompareOutput<T>>;
export declare const greaterThanEqual: <T extends ValueTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<CompareOutput<T>>;
export declare const equal: <T extends ValueTypes | BoolTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<EqualOutput<T>>;
export declare const notEqual: <T extends ValueTypes | BoolTypes>(a: DynoVal<T>, b: DynoVal<T>) => DynoVal<NotEqualOutput<T>>;
export declare const any: <T extends "bvec2" | "bvec3" | "bvec4">(a: DynoVal<T>) => DynoVal<"bool">;
export declare const all: <T extends "bvec2" | "bvec3" | "bvec4">(a: DynoVal<T>) => DynoVal<"bool">;
export declare const select: <T extends SimpleTypes>(cond: DynoVal<"bool">, t: DynoVal<T>, f: DynoVal<T>) => DynoVal<T>;
export declare const compXor: <T extends BoolTypes | AllIntTypes>(a: DynoVal<T>) => DynoVal<CompXorOutput<T>>;
export declare class And<T extends "bool" | AllIntTypes> extends BinaryOp<T, T, T, "and"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class Or<T extends "bool" | AllIntTypes> extends BinaryOp<T, T, T, "or"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class Xor<T extends "bool" | AllIntTypes> extends BinaryOp<T, T, T, "xor"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class Not<T extends BoolTypes | AllIntTypes> extends UnaryOp<T, T, "not"> {
constructor({ a }: {
a: DynoVal<T>;
});
}
export declare class LessThan<T extends ValueTypes> extends BinaryOp<T, T, CompareOutput<T>, "lessThan"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class LessThanEqual<T extends ValueTypes> extends BinaryOp<T, T, CompareOutput<T>, "lessThanEqual"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class GreaterThan<T extends ValueTypes> extends BinaryOp<T, T, CompareOutput<T>, "greaterThan"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class GreaterThanEqual<T extends ValueTypes> extends BinaryOp<T, T, CompareOutput<T>, "greaterThanEqual"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class Equal<T extends ValueTypes | BoolTypes> extends BinaryOp<T, T, EqualOutput<T>, "equal"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class NotEqual<T extends ValueTypes | BoolTypes> extends BinaryOp<T, T, NotEqualOutput<T>, "notEqual"> {
constructor({ a, b }: {
a: DynoVal<T>;
b: DynoVal<T>;
});
}
export declare class Any<T extends BoolTypes> extends UnaryOp<T, "bool", "any"> {
constructor({ a }: {
a: DynoVal<T>;
});
}
export declare class All<T extends BoolTypes> extends UnaryOp<T, "bool", "all"> {
constructor({ a }: {
a: DynoVal<T>;
});
}
export declare class Select<T extends SimpleTypes> extends TrinaryOp<"bool", T, T, T, "select"> {
constructor({ cond, t, f, }: {
cond: DynoVal<"bool">;
t: DynoVal<T>;
f: DynoVal<T>;
});
}
type CompareOutput<T extends ValueTypes> = T extends ScalarTypes ? "bool" : T extends "ivec2" | "uvec2" | "vec2" ? "bvec2" : T extends "ivec3" | "uvec3" | "vec3" ? "bvec3" : T extends "ivec4" | "uvec4" | "vec4" ? "bvec4" : never;
type EqualOutput<A extends ValueTypes | BoolTypes> = A extends ScalarTypes ? "bool" : A extends BoolTypes ? A : A extends "ivec2" | "uvec2" | "vec2" ? "bvec2" : A extends "ivec3" | "uvec3" | "vec3" ? "bvec3" : A extends "ivec4" | "uvec4" | "vec4" ? "bvec4" : never;
type NotEqualOutput<A extends ValueTypes | BoolTypes> = EqualOutput<A>;
type CompXorOutput<A extends BoolTypes | AllIntTypes> = A extends BoolTypes ? "bool" : A extends IntTypes ? "int" : A extends UintTypes ? "uint" : never;
export declare class CompXor<T extends BoolTypes | AllIntTypes> extends UnaryOp<T, CompXorOutput<T>, "compXor"> {
constructor({ a }: {
a: DynoVal<T>;
});
}
export {};
+214
View File
@@ -0,0 +1,214 @@
import { BinaryOp, Dyno, TrinaryOp, UnaryOp } from './base';
import { AddOutput, ClampOutput, DivOutput, IModOutput, IsInfOutput, IsNanOutput, MaxOutput, MinOutput, MixOutput, ModOutput, MulOutput, SmoothstepOutput, StepOutput, SubOutput } from './mathTypes';
import { AllIntTypes, AllSignedTypes, AllValueTypes, BoolTypes, FloatTypes, SignedTypes, ValueTypes } from './types';
import { DynoVal } from './value';
export declare const add: <A extends AllValueTypes, B extends AllValueTypes>(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<AddOutput<A, B>>;
export declare const sub: <A extends AllValueTypes, B extends AllValueTypes>(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<SubOutput<A, B>>;
export declare const mul: <A extends AllValueTypes, B extends AllValueTypes>(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<MulOutput<A, B>>;
export declare const div: <A extends AllValueTypes, B extends AllValueTypes>(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<DivOutput<A, B>>;
export declare const imod: <A extends AllIntTypes, B extends AllIntTypes>(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<IModOutput<A, B>>;
export declare const mod: <A extends FloatTypes, B extends FloatTypes>(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<ModOutput<A, B>>;
export declare const modf: <A extends FloatTypes>(a: DynoVal<A>) => {
fract: DynoVal<A>;
integer: DynoVal<A>;
};
export declare const neg: <A extends AllSignedTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const abs: <A extends SignedTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const sign: <A extends SignedTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const floor: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const ceil: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const trunc: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const round: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const fract: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const pow: <A extends FloatTypes>(a: DynoVal<A>, b: DynoVal<A>) => DynoVal<A>;
export declare const exp: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const exp2: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const log: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const log2: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const sqr: <A extends ValueTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const sqrt: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const inversesqrt: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare const min: <A extends ValueTypes, B extends ValueTypes>(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<MinOutput<A, B>>;
export declare const max: <A extends ValueTypes, B extends ValueTypes>(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<MaxOutput<A, B>>;
export declare const clamp: <A extends ValueTypes, MinMax extends ValueTypes>(a: DynoVal<A>, min: DynoVal<MinMax>, max: DynoVal<MinMax>) => DynoVal<ClampOutput<A, MinMax>>;
export declare const mix: <A extends FloatTypes, T extends FloatTypes | BoolTypes>(a: DynoVal<A>, b: DynoVal<A>, t: DynoVal<T>) => DynoVal<MixOutput<A, T>>;
export declare const step: <A extends FloatTypes, B extends FloatTypes>(edge: DynoVal<A>, x: DynoVal<B>) => DynoVal<StepOutput<A, B>>;
export declare const smoothstep: <X extends FloatTypes, Edge extends X | "float">(edge0: DynoVal<Edge>, edge1: DynoVal<Edge>, x: DynoVal<X>) => DynoVal<SmoothstepOutput<Edge, Edge, X>>;
export declare const isNan: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<IsNanOutput<A>>;
export declare const isInf: <A extends FloatTypes>(a: DynoVal<A>) => DynoVal<IsInfOutput<A>>;
export declare class Add<A extends AllValueTypes, B extends AllValueTypes> extends BinaryOp<A, B, AddOutput<A, B>, "sum"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
export declare class Sub<A extends AllValueTypes, B extends AllValueTypes> extends BinaryOp<A, B, SubOutput<A, B>, "difference"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
export declare class Mul<A extends AllValueTypes, B extends AllValueTypes> extends BinaryOp<A, B, MulOutput<A, B>, "product"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
export declare class Div<A extends AllValueTypes, B extends AllValueTypes> extends BinaryOp<A, B, DivOutput<A, B>, "quotient"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
export declare class IMod<A extends AllIntTypes, B extends AllIntTypes> extends BinaryOp<A, B, IModOutput<A, B>, "remainder"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
export declare class Mod<A extends FloatTypes, B extends FloatTypes> extends BinaryOp<A, B, ModOutput<A, B>, "remainder"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
export declare class Modf<A extends FloatTypes> extends Dyno<{
a: A;
}, {
fract: A;
integer: A;
}> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Neg<A extends AllSignedTypes> extends UnaryOp<A, A, "neg"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Abs<A extends SignedTypes> extends UnaryOp<A, A, "abs"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Sign<A extends SignedTypes> extends UnaryOp<A, A, "sign"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Floor<A extends FloatTypes> extends UnaryOp<A, A, "floor"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Ceil<A extends FloatTypes> extends UnaryOp<A, A, "ceil"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Trunc<A extends FloatTypes> extends UnaryOp<A, A, "trunc"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Round<A extends FloatTypes> extends UnaryOp<A, A, "round"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Fract<A extends FloatTypes> extends UnaryOp<A, A, "fract"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Pow<A extends FloatTypes> extends BinaryOp<A, A, A, "power"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<A>;
});
}
export declare class Exp<A extends FloatTypes> extends UnaryOp<A, A, "exp"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Exp2<A extends FloatTypes> extends UnaryOp<A, A, "exp2"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Log<A extends FloatTypes> extends UnaryOp<A, A, "log"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Log2<A extends FloatTypes> extends UnaryOp<A, A, "log2"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Sqr<A extends ValueTypes> extends UnaryOp<A, A, "sqr"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Sqrt<A extends FloatTypes> extends UnaryOp<A, A, "sqrt"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class InverseSqrt<A extends FloatTypes> extends UnaryOp<A, A, "inversesqrt"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Min<A extends ValueTypes, B extends ValueTypes> extends BinaryOp<A, B, MinOutput<A, B>, "min"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
export declare class Max<A extends ValueTypes, B extends ValueTypes> extends BinaryOp<A, B, MaxOutput<A, B>, "max"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
export declare class Clamp<A extends ValueTypes, MinMax extends ValueTypes> extends TrinaryOp<A, MinMax, MinMax, ClampOutput<A, MinMax>, "clamp"> {
constructor({ a, min, max, }: {
a: DynoVal<A>;
min: DynoVal<MinMax>;
max: DynoVal<MinMax>;
});
}
export declare class Mix<A extends FloatTypes, T extends FloatTypes | BoolTypes> extends TrinaryOp<A, A, T, MixOutput<A, T>, "mix"> {
constructor({ a, b, t }: {
a: DynoVal<A>;
b: DynoVal<A>;
t: DynoVal<T>;
});
}
export declare class Step<Edge extends FloatTypes, X extends FloatTypes> extends BinaryOp<Edge, X, StepOutput<Edge, X>, "step"> {
constructor({ edge, x }: {
edge: DynoVal<Edge>;
x: DynoVal<X>;
});
}
export declare class Smoothstep<X extends FloatTypes, Edge extends X | "float"> extends TrinaryOp<Edge, Edge, X, SmoothstepOutput<Edge, Edge, X>, "smoothstep"> {
constructor({ edge0, edge1, x, }: {
edge0: DynoVal<Edge>;
edge1: DynoVal<Edge>;
x: DynoVal<X>;
});
}
export declare class IsNan<A extends FloatTypes> extends UnaryOp<A, IsNanOutput<A>, "isNan"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class IsInf<A extends FloatTypes> extends UnaryOp<A, IsInfOutput<A>, "isInf"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
+47
View File
@@ -0,0 +1,47 @@
import { AllFloatTypes, AllIntTypes, AllSignedTypes, AllValueTypes, BaseType, BoolTypes, FloatTypes, IntTypes, SignedTypes, UintTypes, ValueTypes } from './types';
export type AddOutput<A extends AllValueTypes, B extends AllValueTypes> = BaseType & (A extends B ? A : A extends "int" ? B extends IntTypes ? B : never : B extends "int" ? A extends IntTypes ? A : never : A extends "uint" ? B extends UintTypes ? B : never : B extends "uint" ? A extends UintTypes ? A : never : A extends "float" ? B extends AllFloatTypes ? B : never : B extends "float" ? A extends AllFloatTypes ? A : never : never);
export type SubOutput<A extends AllValueTypes, B extends AllValueTypes> = AddOutput<A, B>;
export type MulOutput<A extends AllValueTypes, B extends AllValueTypes> = BaseType & (A extends "int" ? B extends IntTypes ? B : never : B extends "int" ? A extends IntTypes ? A : never : A extends "uint" ? B extends UintTypes ? B : never : B extends "uint" ? A extends UintTypes ? A : never : A extends "float" ? B extends AllFloatTypes ? B : never : B extends "float" ? A extends AllFloatTypes ? A : never : A extends IntTypes ? B extends A ? A : never : B extends IntTypes ? A extends B ? A : never : A extends UintTypes ? B extends A ? A : never : B extends UintTypes ? A extends B ? A : never : A extends "vec2" ? B extends "vec2" | "mat2" | "mat2x2" ? "vec2" : B extends "mat3x2" ? "vec3" : B extends "mat4x2" ? "vec4" : never : A extends "vec3" ? B extends "mat2x3" ? "vec2" : B extends "vec3" | "mat3" | "mat3x3" ? "vec3" : B extends "mat4x3" ? "vec4" : never : A extends "vec4" ? B extends "mat2x4" ? "vec2" : B extends "mat3x4" ? "vec3" : B extends "vec4" | "mat4" | "mat4x4" ? "vec4" : never : B extends "vec2" ? A extends "mat2" | "mat2x2" ? "vec2" : A extends "mat2x3" ? "vec3" : A extends "mat2x4" ? "vec4" : never : B extends "vec3" ? A extends "mat3x2" ? "vec2" : A extends "mat3" | "mat3x3" ? "vec3" : A extends "mat3x4" ? "vec4" : never : B extends "vec4" ? A extends "mat4x2" ? "vec2" : A extends "mat4x3" ? "vec3" : A extends "mat4" | "mat4x4" ? "vec4" : never : A extends "mat2" | "mat2x2" ? B extends "mat2" | "mat2x2" ? "mat2" : B extends "mat3x2" ? "mat3x2" : B extends "mat4x2" ? "mat4x2" : never : A extends "mat2x3" ? B extends "mat2" | "mat2x2" ? "mat2x3" : B extends "mat3x2" ? "mat3" : B extends "mat4x2" ? "mat4x3" : never : A extends "mat2x4" ? B extends "mat2" | "mat2x2" ? "mat2x4" : B extends "mat3x2" ? "mat3x4" : B extends "mat4x2" ? "mat4" : never : A extends "mat3x2" ? B extends "mat2x3" ? "mat2" : B extends "mat3" | "mat3x3" ? "mat3x2" : B extends "mat4x3" ? "mat4x2" : never : A extends "mat3" | "mat3x3" ? B extends "mat2x3" ? "mat2x3" : B extends "mat3" | "mat3x3" ? "mat3" : B extends "mat4x3" ? "mat4x3" : never : A extends "mat3x4" ? B extends "mat2x3" ? "mat2x4" : B extends "mat3" | "mat3x3" ? "mat3x4" : B extends "mat4x3" ? "mat4" : never : A extends "mat4x2" ? B extends "mat2x4" ? "mat2" : B extends "mat3x4" ? "mat3x2" : B extends "mat4" | "mat4x4" ? "mat4x2" : never : A extends "mat4x3" ? B extends "mat2x4" ? "mat2x3" : B extends "mat3x4" ? "mat3" : B extends "mat4" | "mat4x4" ? "mat4x3" : never : A extends "mat4" | "mat4x4" ? B extends "mat2x4" ? "mat2x4" : B extends "mat3x4" ? "mat3x4" : B extends "mat4" | "mat4x4" ? "mat4" : never : never);
export type DivOutput<A extends AllValueTypes, B extends AllValueTypes> = AddOutput<A, B>;
export type IModOutput<A extends AllIntTypes, B extends AllIntTypes> = BaseType & (A extends B ? A : A extends "int" ? B extends IntTypes ? B : never : B extends "int" ? A extends IntTypes ? A : never : A extends "uint" ? B extends UintTypes ? B : never : B extends "uint" ? A extends UintTypes ? A : never : never);
export type ModOutput<A extends FloatTypes, B extends FloatTypes> = BaseType & (A extends B ? A : B extends "float" ? A : never);
export type PowOutput<A extends FloatTypes, B extends FloatTypes> = BaseType & (A extends B ? A : never);
export type MinOutput<A extends ValueTypes, B extends ValueTypes> = BaseType & (A extends B ? A : B extends "float" ? A extends FloatTypes ? A : never : B extends "int" ? A extends IntTypes ? A : never : B extends "uint" ? A extends UintTypes ? A : never : never);
export type MaxOutput<A extends ValueTypes, B extends ValueTypes> = MinOutput<A, B>;
export type ClampOutput<A extends ValueTypes, B extends ValueTypes> = BaseType & (B extends "float" ? A extends FloatTypes ? A : never : B extends "int" ? A extends IntTypes ? A : never : B extends "uint" ? A extends UintTypes ? A : never : never);
export type MixOutput<A extends FloatTypes, T extends FloatTypes | BoolTypes> = BaseType & (T extends A ? A : T extends "float" ? A : T extends "bool" ? A extends "float" ? A : never : T extends "bvec2" ? A extends "vec2" ? A : never : T extends "bvec3" ? A extends "vec3" ? A : never : T extends "bvec4" ? A extends "vec4" ? A : never : never);
export type StepOutput<A extends FloatTypes, B extends FloatTypes> = BaseType & (A extends B ? B : A extends "float" ? B : never);
export type SmoothstepOutput<A extends FloatTypes, B extends FloatTypes, C extends FloatTypes> = BaseType & (A extends B ? (A extends C ? C : A extends "float" ? C : never) : never);
export type IsNanOutput<A extends FloatTypes> = BaseType & (A extends "float" ? "bool" : A extends "vec2" ? "bvec2" : A extends "vec3" ? "bvec3" : A extends "vec4" ? "bvec4" : never);
export type IsInfOutput<A extends FloatTypes> = IsNanOutput<A>;
export declare function addOutputType<A extends AllValueTypes, B extends AllValueTypes>(a: A, b: B, operation?: string): AddOutput<A, B>;
export declare function subOutputType<A extends AllValueTypes, B extends AllValueTypes>(a: A, b: B): SubOutput<A, B>;
export declare function mulOutputType<A extends AllValueTypes, B extends AllValueTypes>(a: A, b: B): MulOutput<A, B>;
export declare function divOutputType<A extends AllValueTypes, B extends AllValueTypes>(a: A, b: B): DivOutput<A, B>;
export declare function imodOutputType<A extends AllIntTypes, B extends AllIntTypes>(a: A, b: B): IModOutput<A, B>;
export declare function modOutputType<A extends FloatTypes, B extends FloatTypes>(a: A, b: B): ModOutput<A, B>;
export declare function modfOutputType<A extends FloatTypes>(a: A): A;
export declare function negOutputType<A extends AllSignedTypes>(a: A): A;
export declare function absOutputType<A extends SignedTypes>(a: A): A;
export declare function signOutputType<A extends SignedTypes>(a: A): A;
export declare function floorOutputType<A extends FloatTypes>(a: A): A;
export declare function ceilOutputType<A extends FloatTypes>(a: A): A;
export declare function truncOutputType<A extends FloatTypes>(a: A): A;
export declare function roundOutputType<A extends FloatTypes>(a: A): A;
export declare function fractOutputType<A extends FloatTypes>(a: A): A;
export declare function powOutputType<A extends FloatTypes>(a: A): A;
export declare function expOutputType<A extends FloatTypes>(a: A): A;
export declare function exp2OutputType<A extends FloatTypes>(a: A): A;
export declare function logOutputType<A extends FloatTypes>(a: A): A;
export declare function log2OutputType<A extends FloatTypes>(a: A): A;
export declare function sqrOutputType<A extends ValueTypes>(a: A): A;
export declare function sqrtOutputType<A extends FloatTypes>(a: A): A;
export declare function inversesqrtOutputType<A extends FloatTypes>(a: A): A;
export declare function minOutputType<A extends ValueTypes, B extends ValueTypes>(a: A, b: B, operation?: string): MinOutput<A, B>;
export declare function maxOutputType<A extends ValueTypes, B extends ValueTypes>(a: A, b: B): MaxOutput<A, B>;
export declare function clampOutputType<A extends ValueTypes, B extends ValueTypes>(a: A, b: B, _c: B): ClampOutput<A, B>;
export declare function mixOutputType<A extends FloatTypes, C extends FloatTypes | BoolTypes>(a: A, b: A, c: C): MixOutput<A, C>;
export declare function stepOutputType<A extends FloatTypes, B extends FloatTypes>(a: A, b: B): StepOutput<A, B>;
export declare function smoothstepOutputType<A extends FloatTypes, B extends FloatTypes, C extends FloatTypes>(a: A, b: B, c: C): SmoothstepOutput<A, B, C>;
export declare function isNanOutputType<A extends FloatTypes>(a: A, operation?: string): IsNanOutput<A>;
export declare function isInfOutputType<A extends FloatTypes>(a: A): IsInfOutput<A>;
+25
View File
@@ -0,0 +1,25 @@
import { Dyno } from './base';
import { Gsplat } from './splats';
import { DynoVal, DynoValue, HasDynoOut } from './value';
export declare const outputPackedSplat: (gsplat: DynoVal<typeof Gsplat>) => OutputPackedSplat;
export declare const outputRgba8: (rgba8: DynoVal<"vec4">) => OutputRgba8;
export declare class OutputPackedSplat extends Dyno<{
gsplat: typeof Gsplat;
}, {
output: "uvec4";
}> implements HasDynoOut<"uvec4"> {
constructor({ gsplat }: {
gsplat?: DynoVal<typeof Gsplat>;
});
dynoOut(): DynoValue<"uvec4">;
}
export declare class OutputRgba8 extends Dyno<{
rgba8: "vec4";
}, {
rgba8: "vec4";
}> implements HasDynoOut<"vec4"> {
constructor({ rgba8 }: {
rgba8?: DynoVal<"vec4">;
});
dynoOut(): DynoValue<"vec4">;
}
+30
View File
@@ -0,0 +1,30 @@
import { Dyno, IOTypes } from './base';
import * as THREE from "three";
export declare class DynoProgram {
graph: Dyno<IOTypes, IOTypes>;
template: DynoProgramTemplate;
inputs: Record<string, string>;
outputs: Record<string, string>;
shader: string;
uniforms: Record<string, THREE.IUniform>;
updaters: (() => void)[];
constructor({ graph, inputs, outputs, template, }: {
graph: Dyno<IOTypes, IOTypes>;
inputs?: Record<string, string>;
outputs?: Record<string, string>;
template: DynoProgramTemplate;
});
prepareMaterial(): THREE.RawShaderMaterial;
update(): void;
}
export declare class DynoProgramTemplate {
before: string;
between: string;
after: string;
indent: string;
constructor(template: string);
generate({ globals, statements, }: {
globals: Set<string>;
statements: string[];
}): string;
}
+156
View File
@@ -0,0 +1,156 @@
import { Dyno, UnaryOp } from './base';
import { DynoVal, DynoValue, HasDynoOut } from './value';
export declare const Gsplat: {
type: "Gsplat";
};
export declare const TPackedSplats: {
type: "PackedSplats";
};
export declare const numPackedSplats: (packedSplats: DynoVal<typeof TPackedSplats>) => DynoVal<"int">;
export declare const readPackedSplat: (packedSplats: DynoVal<typeof TPackedSplats>, index: DynoVal<"int">) => DynoVal<typeof Gsplat>;
export declare const readPackedSplatRange: (packedSplats: DynoVal<typeof TPackedSplats>, index: DynoVal<"int">, base: DynoVal<"int">, count: DynoVal<"int">) => DynoVal<typeof Gsplat>;
export declare const splitGsplat: (gsplat: DynoVal<typeof Gsplat>) => SplitGsplat;
export declare const combineGsplat: ({ gsplat, flags, index, center, scales, quaternion, rgba, rgb, opacity, x, y, z, r, g, b, }: {
gsplat?: DynoVal<typeof Gsplat>;
flags?: DynoVal<"uint">;
index?: DynoVal<"int">;
center?: DynoVal<"vec3">;
scales?: DynoVal<"vec3">;
quaternion?: DynoVal<"vec4">;
rgba?: DynoVal<"vec4">;
rgb?: DynoVal<"vec3">;
opacity?: DynoVal<"float">;
x?: DynoVal<"float">;
y?: DynoVal<"float">;
z?: DynoVal<"float">;
r?: DynoVal<"float">;
g?: DynoVal<"float">;
b?: DynoVal<"float">;
}) => DynoVal<typeof Gsplat>;
export declare const gsplatNormal: (gsplat: DynoVal<typeof Gsplat>) => DynoVal<"vec3">;
export declare const transformGsplat: (gsplat: DynoVal<typeof Gsplat>, { scale, rotate, translate, recolor, }: {
scale?: DynoVal<"float">;
rotate?: DynoVal<"vec4">;
translate?: DynoVal<"vec3">;
recolor?: DynoVal<"vec4">;
}) => DynoVal<typeof Gsplat>;
export declare const defineGsplat: string;
export declare const definePackedSplats: string;
export declare class NumPackedSplats extends UnaryOp<typeof TPackedSplats, "int", "numSplats"> {
constructor({ packedSplats, }: {
packedSplats: DynoVal<typeof TPackedSplats>;
});
}
export declare class ReadPackedSplat extends Dyno<{
packedSplats: typeof TPackedSplats;
index: "int";
}, {
gsplat: typeof Gsplat;
}> implements HasDynoOut<typeof Gsplat> {
constructor({ packedSplats, index, }: {
packedSplats?: DynoVal<typeof TPackedSplats>;
index?: DynoVal<"int">;
});
dynoOut(): DynoValue<typeof Gsplat>;
}
export declare class ReadPackedSplatRange extends Dyno<{
packedSplats: typeof TPackedSplats;
index: "int";
base: "int";
count: "int";
}, {
gsplat: typeof Gsplat;
}> implements HasDynoOut<typeof Gsplat> {
constructor({ packedSplats, index, base, count, }: {
packedSplats?: DynoVal<typeof TPackedSplats>;
index?: DynoVal<"int">;
base?: DynoVal<"int">;
count?: DynoVal<"int">;
});
dynoOut(): DynoValue<typeof Gsplat>;
}
export declare class SplitGsplat extends Dyno<{
gsplat: typeof Gsplat;
}, {
flags: "uint";
active: "bool";
index: "int";
center: "vec3";
scales: "vec3";
quaternion: "vec4";
rgba: "vec4";
rgb: "vec3";
opacity: "float";
x: "float";
y: "float";
z: "float";
r: "float";
g: "float";
b: "float";
}> {
constructor({ gsplat }: {
gsplat?: DynoVal<typeof Gsplat>;
});
}
export declare class CombineGsplat extends Dyno<{
gsplat: typeof Gsplat;
flags: "uint";
index: "int";
center: "vec3";
scales: "vec3";
quaternion: "vec4";
rgba: "vec4";
rgb: "vec3";
opacity: "float";
x: "float";
y: "float";
z: "float";
r: "float";
g: "float";
b: "float";
}, {
gsplat: typeof Gsplat;
}> implements HasDynoOut<typeof Gsplat> {
constructor({ gsplat, flags, index, center, scales, quaternion, rgba, rgb, opacity, x, y, z, r, g, b, }: {
gsplat?: DynoVal<typeof Gsplat>;
flags?: DynoVal<"uint">;
index?: DynoVal<"int">;
center?: DynoVal<"vec3">;
scales?: DynoVal<"vec3">;
quaternion?: DynoVal<"vec4">;
rgba?: DynoVal<"vec4">;
rgb?: DynoVal<"vec3">;
opacity?: DynoVal<"float">;
x?: DynoVal<"float">;
y?: DynoVal<"float">;
z?: DynoVal<"float">;
r?: DynoVal<"float">;
g?: DynoVal<"float">;
b?: DynoVal<"float">;
});
dynoOut(): DynoValue<typeof Gsplat>;
}
export declare const defineGsplatNormal: string;
export declare class GsplatNormal extends UnaryOp<typeof Gsplat, "vec3", "normal"> {
constructor({ gsplat }: {
gsplat: DynoVal<typeof Gsplat>;
});
}
export declare class TransformGsplat extends Dyno<{
gsplat: typeof Gsplat;
scale: "float";
rotate: "vec4";
translate: "vec3";
recolor: "vec4";
}, {
gsplat: typeof Gsplat;
}> implements HasDynoOut<typeof Gsplat> {
constructor({ gsplat, scale, rotate, translate, recolor, }: {
gsplat?: DynoVal<typeof Gsplat>;
scale?: DynoVal<"float">;
rotate?: DynoVal<"vec4">;
translate?: DynoVal<"vec3">;
recolor?: DynoVal<"vec4">;
});
dynoOut(): DynoValue<typeof Gsplat>;
}
+50
View File
@@ -0,0 +1,50 @@
import { Dyno } from './base';
import { AllSamplerTypes, IsamplerTypes, NormalSamplerTypes, Sampler2DArrayTypes, Sampler2DTypes, Sampler3DTypes, SamplerCubeTypes, SamplerShadowTypes, SamplerTypes, UsamplerTypes } from './types';
import { DynoVal, DynoValue, HasDynoOut } from './value';
export declare const textureSize: <T extends AllSamplerTypes>(texture: DynoVal<T>, lod?: DynoVal<"int">) => DynoVal<TextureSizeType<T>>;
export declare const texture: <T extends AllSamplerTypes>(texture: DynoVal<T>, coord: DynoVal<TextureCoordType<T>>, bias?: DynoVal<"float">) => DynoVal<TextureReturnType<T>>;
export declare const texelFetch: <T extends NormalSamplerTypes>(texture: DynoVal<T>, coord: DynoVal<TextureSizeType<T>>, lod?: DynoVal<"int">) => DynoVal<TextureReturnType<T>>;
export declare class TextureSize<T extends AllSamplerTypes> extends Dyno<{
texture: T;
lod: "int";
}, {
size: TextureSizeType<T>;
}> implements HasDynoOut<TextureSizeType<T>> {
constructor({ texture, lod }: {
texture: DynoVal<T>;
lod?: DynoVal<"int">;
});
dynoOut(): DynoValue<TextureSizeType<T>>;
}
export declare class Texture<T extends AllSamplerTypes> extends Dyno<{
texture: T;
coord: TextureCoordType<T>;
bias: "float";
}, {
sample: TextureReturnType<T>;
}> implements HasDynoOut<TextureReturnType<T>> {
constructor({ texture, coord, bias, }: {
texture: DynoVal<T>;
coord: DynoVal<TextureCoordType<T>>;
bias?: DynoVal<"float">;
});
dynoOut(): DynoValue<TextureReturnType<T>>;
}
export declare class TexelFetch<T extends NormalSamplerTypes> extends Dyno<{
texture: T;
coord: TextureSizeType<T>;
lod: "int";
}, {
texel: TextureReturnType<T>;
}> implements HasDynoOut<TextureReturnType<T>> {
constructor({ texture, coord, lod, }: {
texture: DynoVal<T>;
coord: DynoVal<TextureSizeType<T>>;
lod?: DynoVal<"int">;
});
dynoOut(): DynoValue<TextureReturnType<T>>;
}
type TextureSizeType<T extends AllSamplerTypes> = T extends Sampler2DTypes | SamplerCubeTypes ? "ivec2" : T extends Sampler3DTypes | Sampler2DArrayTypes ? "ivec3" : never;
type TextureCoordType<T extends AllSamplerTypes> = T extends Sampler2DTypes ? "vec2" : T extends Sampler3DTypes | Sampler2DArrayTypes | SamplerCubeTypes | Sampler2DArrayTypes ? "vec3" : T extends "samperCubeShadow" | "sampler2DArrayShadow" ? "vec4" : never;
type TextureReturnType<T extends AllSamplerTypes> = T extends SamplerTypes ? "vec4" : T extends UsamplerTypes ? "uvec4" : T extends IsamplerTypes ? "ivec4" : T extends SamplerShadowTypes ? "float" : never;
export {};
+59
View File
@@ -0,0 +1,59 @@
import { Dyno } from './base';
import { DynoVal } from './value';
export declare const transformPos: (position: DynoVal<"vec3">, { scale, scales, rotate, translate, }: {
scale?: DynoVal<"float">;
scales?: DynoVal<"vec3">;
rotate?: DynoVal<"vec4">;
translate?: DynoVal<"vec3">;
}) => DynoVal<"vec3">;
export declare const transformDir: (dir: DynoVal<"vec3">, { scale, scales, rotate, }: {
scale?: DynoVal<"float">;
scales?: DynoVal<"vec3">;
rotate?: DynoVal<"vec4">;
}) => DynoVal<"vec3">;
export declare const transformQuat: (quaternion: DynoVal<"vec4">, { rotate }: {
rotate?: DynoVal<"vec4">;
}) => DynoVal<"vec4">;
export declare class TransformPosition extends Dyno<{
position: "vec3";
scale: "float";
scales: "vec3";
rotate: "vec4";
translate: "vec3";
}, {
position: "vec3";
}> {
constructor({ position, scale, scales, rotate, translate, }: {
position?: DynoVal<"vec3">;
scale?: DynoVal<"float">;
scales?: DynoVal<"vec3">;
rotate?: DynoVal<"vec4">;
translate?: DynoVal<"vec3">;
});
}
export declare class TransformDir extends Dyno<{
dir: "vec3";
scale: "float";
scales: "vec3";
rotate: "vec4";
}, {
dir: "vec3";
}> {
constructor({ dir, scale, scales, rotate, }: {
dir?: DynoVal<"vec3">;
scale?: DynoVal<"float">;
scales?: DynoVal<"vec3">;
rotate?: DynoVal<"vec4">;
});
}
export declare class TransformQuaternion extends Dyno<{
quaternion: "vec4";
rotate: "vec4";
}, {
quaternion: "vec4";
}> {
constructor({ quaternion, rotate, }: {
quaternion?: DynoVal<"vec4">;
rotate?: DynoVal<"vec4">;
});
}
+94
View File
@@ -0,0 +1,94 @@
import { BinaryOp, UnaryOp } from './base';
import { FloatTypes } from './types';
import { DynoVal } from './value';
export declare const radians: <A extends FloatTypes>(degrees: DynoVal<A>) => DynoVal<A>;
export declare const degrees: <A extends FloatTypes>(radians: DynoVal<A>) => DynoVal<A>;
export declare const sin: <A extends FloatTypes>(radians: DynoVal<A>) => DynoVal<A>;
export declare const cos: <A extends FloatTypes>(radians: DynoVal<A>) => DynoVal<A>;
export declare const tan: <A extends FloatTypes>(radians: DynoVal<A>) => DynoVal<A>;
export declare const asin: <A extends FloatTypes>(sin: DynoVal<A>) => DynoVal<A>;
export declare const acos: <A extends FloatTypes>(cos: DynoVal<A>) => DynoVal<A>;
export declare const atan: <A extends FloatTypes>(tan: DynoVal<A>) => DynoVal<A>;
export declare const atan2: <A extends FloatTypes>(y: DynoVal<A>, x: DynoVal<A>) => DynoVal<A>;
export declare const sinh: <A extends FloatTypes>(x: DynoVal<A>) => DynoVal<A>;
export declare const cosh: <A extends FloatTypes>(x: DynoVal<A>) => DynoVal<A>;
export declare const tanh: <A extends FloatTypes>(x: DynoVal<A>) => DynoVal<A>;
export declare const asinh: <A extends FloatTypes>(x: DynoVal<A>) => DynoVal<A>;
export declare const acosh: <A extends FloatTypes>(x: DynoVal<A>) => DynoVal<A>;
export declare const atanh: <A extends FloatTypes>(x: DynoVal<A>) => DynoVal<A>;
export declare class Radians<A extends FloatTypes> extends UnaryOp<A, A, "radians"> {
constructor({ degrees }: {
degrees: DynoVal<A>;
});
}
export declare class Degrees<A extends FloatTypes> extends UnaryOp<A, A, "degrees"> {
constructor({ radians }: {
radians: DynoVal<A>;
});
}
export declare class Sin<A extends FloatTypes> extends UnaryOp<A, A, "sin"> {
constructor({ radians }: {
radians: DynoVal<A>;
});
}
export declare class Cos<A extends FloatTypes> extends UnaryOp<A, A, "cos"> {
constructor({ radians }: {
radians: DynoVal<A>;
});
}
export declare class Tan<A extends FloatTypes> extends UnaryOp<A, A, "tan"> {
constructor({ radians }: {
radians: DynoVal<A>;
});
}
export declare class Asin<A extends FloatTypes> extends UnaryOp<A, A, "asin"> {
constructor({ sin }: {
sin: DynoVal<A>;
});
}
export declare class Acos<A extends FloatTypes> extends UnaryOp<A, A, "acos"> {
constructor({ cos }: {
cos: DynoVal<A>;
});
}
export declare class Atan<A extends FloatTypes> extends UnaryOp<A, A, "atan"> {
constructor({ tan }: {
tan: DynoVal<A>;
});
}
export declare class Atan2<A extends FloatTypes> extends BinaryOp<A, A, A, "atan2"> {
constructor({ y, x }: {
y: DynoVal<A>;
x: DynoVal<A>;
});
}
export declare class Sinh<A extends FloatTypes> extends UnaryOp<A, A, "sinh"> {
constructor({ x }: {
x: DynoVal<A>;
});
}
export declare class Cosh<A extends FloatTypes> extends UnaryOp<A, A, "cosh"> {
constructor({ x }: {
x: DynoVal<A>;
});
}
export declare class Tanh<A extends FloatTypes> extends UnaryOp<A, A, "tanh"> {
constructor({ x }: {
x: DynoVal<A>;
});
}
export declare class Asinh<A extends FloatTypes> extends UnaryOp<A, A, "asinh"> {
constructor({ x }: {
x: DynoVal<A>;
});
}
export declare class Acosh<A extends FloatTypes> extends UnaryOp<A, A, "acosh"> {
constructor({ x }: {
x: DynoVal<A>;
});
}
export declare class Atanh<A extends FloatTypes> extends UnaryOp<A, A, "atanh"> {
constructor({ x }: {
x: DynoVal<A>;
});
}
+62
View File
@@ -0,0 +1,62 @@
import type * as THREE from "three";
export type BoolTypes = "bool" | "bvec2" | "bvec3" | "bvec4";
export type IntTypes = "int" | "ivec2" | "ivec3" | "ivec4";
export type UintTypes = "uint" | "uvec2" | "uvec3" | "uvec4";
export type AllIntTypes = IntTypes | UintTypes;
export type FloatTypes = "float" | "vec2" | "vec3" | "vec4";
export type ScalarTypes = "uint" | "int" | "float";
export type Vector2Types = "vec2" | "ivec2" | "uvec2";
export type Vector3Types = "vec3" | "ivec3" | "uvec3";
export type Vector4Types = "vec4" | "ivec4" | "uvec4";
export type VectorTypes = Vector2Types | Vector3Types | Vector4Types;
export type MatFloatTypes = "mat2" | "mat2x2" | "mat2x3" | "mat2x4" | "mat3" | "mat3x2" | "mat3x3" | "mat3x4" | "mat4" | "mat4x2" | "mat4x3" | "mat4x4";
export type SquareMatTypes = "mat2" | "mat3" | "mat4" | "mat2x2" | "mat3x3" | "mat4x4";
export type AllFloatTypes = FloatTypes | MatFloatTypes;
export type SignedTypes = IntTypes | FloatTypes;
export type AllSignedTypes = SignedTypes | MatFloatTypes;
export type ValueTypes = FloatTypes | IntTypes | UintTypes;
export type AllValueTypes = AllFloatTypes | IntTypes | UintTypes;
export type SimpleTypes = BoolTypes | AllValueTypes;
export type VectorElementType<A extends VectorTypes> = A extends FloatTypes ? "float" : A extends IntTypes ? "int" : A extends UintTypes ? "uint" : never;
export type SameSizeVec<T extends ValueTypes> = T extends ScalarTypes ? "float" : T extends "vec2" | "ivec2" | "uvec2" ? "vec2" : T extends "vec3" | "ivec3" | "uvec3" ? "vec3" : T extends "vec4" | "ivec4" | "uvec4" ? "vec4" : never;
export type SameSizeUvec<T extends ValueTypes> = T extends ScalarTypes ? "uint" : T extends "vec2" | "ivec2" | "uvec2" ? "uvec2" : T extends "vec3" | "ivec3" | "uvec3" ? "uvec3" : T extends "vec4" | "ivec4" | "uvec4" ? "uvec4" : never;
export type SameSizeIvec<T extends ValueTypes> = T extends ScalarTypes ? "int" : T extends "vec2" | "ivec2" | "uvec2" ? "ivec2" : T extends "vec3" | "ivec3" | "uvec3" ? "ivec3" : T extends "vec4" | "ivec4" | "uvec4" ? "ivec4" : never;
export type SamplerTypes = "sampler2D" | "sampler2DArray" | "sampler3D" | "samplerCube";
export type UsamplerTypes = "usampler2D" | "usampler2DArray" | "usampler3D" | "usamplerCube";
export type IsamplerTypes = "isampler2D" | "isampler2DArray" | "isampler3D" | "isamplerCube";
export type NormalSamplerTypes = SamplerTypes | UsamplerTypes | IsamplerTypes;
export type SamplerShadowTypes = "sampler2DShadow" | "sampler2DArrayShadow" | "samplerCubeShadow";
export type AllSamplerTypes = NormalSamplerTypes | SamplerShadowTypes;
export type Sampler2DTypes = "sampler2D" | "usampler2D" | "isampler2D" | "sampler2DShadow";
export type Sampler2DArrayTypes = "sampler2DArray" | "usampler2DArray" | "isampler2DArray" | "sampler2DArrayShadow";
export type Sampler3DTypes = "sampler3D" | "usampler3D" | "isampler3D";
export type SamplerCubeTypes = "samplerCube" | "usamplerCube" | "isamplerCube" | "samplerCubeShadow";
export declare function isBoolType(type: DynoType): boolean;
export declare function isScalarType(type: DynoType): boolean;
export declare function isIntType(type: DynoType): boolean;
export declare function isUintType(type: DynoType): boolean;
export declare function isFloatType(type: DynoType): boolean;
export declare function isMatFloatType(type: DynoType): boolean;
export declare function isAllFloatType(type: DynoType): boolean;
export declare function isVector2Type(type: DynoType): boolean;
export declare function isVector3Type(type: DynoType): boolean;
export declare function isVector4Type(type: DynoType): boolean;
export declare function isVectorType(type: DynoType): boolean;
export declare function isMat2(type: DynoType): boolean;
export declare function isMat3(type: DynoType): boolean;
export declare function isMat4(type: DynoType): boolean;
export declare function vectorElementType<A extends VectorTypes>(type: A): VectorElementType<A>;
export declare function vectorDim<A extends VectorTypes>(type: A): number;
export declare function sameSizeVec<T extends ValueTypes>(type: T): SameSizeVec<T>;
export declare function sameSizeUvec<T extends ValueTypes>(type: T): SameSizeUvec<T>;
export declare function sameSizeIvec<T extends ValueTypes>(type: T): SameSizeIvec<T>;
export type BaseType = SimpleTypes | AllSamplerTypes;
export type UserType = {
type: string;
};
export type DynoType = BaseType | UserType;
export type DynoJsType<T extends DynoType> = T extends "bool" ? boolean : T extends "uint" ? number : T extends "int" ? number : T extends "float" ? number : T extends "bvec2" ? [boolean, boolean] : T extends "uvec2" ? THREE.Vector2 | [number, number] | Uint32Array : T extends "ivec2" ? THREE.Vector2 | [number, number] | Int32Array : T extends "vec2" ? THREE.Vector2 | [number, number] | Float32Array : T extends "bvec3" ? [boolean, boolean, boolean] : T extends "uvec3" ? THREE.Vector3 | [number, number, number] | Uint32Array : T extends "ivec3" ? THREE.Vector3 | [number, number, number] | Int32Array : T extends "vec3" ? THREE.Vector3 | THREE.Color | [number, number, number] | Float32Array : T extends "bvec4" ? [boolean, boolean, boolean, boolean] : T extends "uvec4" ? THREE.Vector4 | [number, number, number, number] | Uint32Array : T extends "ivec4" ? THREE.Vector4 | [number, number, number, number] | Int32Array : T extends "vec4" ? THREE.Vector4 | THREE.Quaternion | [number, number, number, number] | Float32Array : T extends "mat2" ? THREE.Matrix2 | Float32Array : T extends "mat2x2" ? THREE.Matrix2 | Float32Array : T extends "mat2x3" ? Float32Array : T extends "mat2x4" ? Float32Array : T extends "mat3" ? THREE.Matrix3 | Float32Array : T extends "mat3x2" ? Float32Array : T extends "mat3x3" ? THREE.Matrix3 | Float32Array : T extends "mat3x4" ? Float32Array : T extends "mat4" ? THREE.Matrix4 | Float32Array : T extends "mat4x2" ? Float32Array : T extends "mat4x3" ? Float32Array : T extends "mat4x4" ? THREE.Matrix4 | Float32Array : T extends "usampler2D" ? THREE.Texture : T extends "isampler2D" ? THREE.Texture : T extends "sampler2D" ? THREE.Texture : T extends "sampler2DShadow" ? THREE.Texture : T extends "usampler2DArray" ? THREE.DataArrayTexture : T extends "isampler2DArray" ? THREE.DataArrayTexture : T extends "sampler2DArray" ? THREE.DataArrayTexture : T extends "sampler2DArrayShadow" ? THREE.Texture : T extends "usampler3D" ? THREE.DataArrayTexture : T extends "isampler3D" ? THREE.DataArrayTexture : T extends "sampler3D" ? THREE.DataArrayTexture : T extends "usamplerCube" ? THREE.DataArrayTexture : T extends "isamplerCube" ? THREE.DataArrayTexture : T extends "samplerCube" ? THREE.DataArrayTexture : T extends "samplerCubeShadow" ? THREE.Texture : unknown;
export declare function typeLiteral(type: DynoType): string;
export declare function numberAsInt(value: number): string;
export declare function numberAsUint(value: number): string;
export declare function numberAsFloat(value: number): string;
+374
View File
@@ -0,0 +1,374 @@
import { Dyno } from './base';
import { DynoJsType, DynoType } from './types';
import { DynoValue, HasDynoOut } from './value';
export declare const uniform: <V extends DynoJsType<DynoType>>(key: string, type: DynoType, value: V) => DynoUniform<DynoType, string, V>;
export declare const dynoBool: (value?: boolean, key?: string) => DynoBool<string>;
export declare const dynoUint: (value?: number, key?: string) => DynoUint<string>;
export declare const dynoInt: (value?: number, key?: string) => DynoInt<string>;
export declare const dynoFloat: (value?: number, key?: string) => DynoFloat<string>;
export declare const dynoBvec2: <V extends DynoJsType<"bvec2">>(value: V, key?: string) => DynoBvec2<string, V>;
export declare const dynoUvec2: <V extends DynoJsType<"uvec2">>(value: V, key?: string) => DynoUvec2<string, V>;
export declare const dynoIvec2: <V extends DynoJsType<"ivec2">>(value: V, key?: string) => DynoIvec2<string, V>;
export declare const dynoVec2: <V extends DynoJsType<"vec2">>(value: V, key?: string) => DynoVec2<string, V>;
export declare const dynoBvec3: <V extends DynoJsType<"bvec3">>(value: V, key?: string) => DynoBvec3<string, V>;
export declare const dynoUvec3: <V extends DynoJsType<"uvec3">>(value: V, key?: string) => DynoUvec3<V, string>;
export declare const dynoIvec3: <V extends DynoJsType<"ivec3">>(value: V, key?: string) => DynoIvec3<V, string>;
export declare const dynoVec3: <V extends DynoJsType<"vec3">>(value: V, key?: string) => DynoVec3<V, string>;
export declare const dynoBvec4: <V extends DynoJsType<"bvec4">>(value: V, key?: string) => DynoBvec4<string, V>;
export declare const dynoUvec4: <V extends DynoJsType<"uvec4">>(value: V, key?: string) => DynoUvec4<string, V>;
export declare const dynoIvec4: <V extends DynoJsType<"ivec4">>(value: V, key?: string) => DynoIvec4<string, V>;
export declare const dynoVec4: <V extends DynoJsType<"vec4">>(value: V, key?: string) => DynoVec4<V, string>;
export declare const dynoMat2: <V extends DynoJsType<"mat2">>(value: V, key?: string) => DynoMat2<string, V>;
export declare const dynoMat2x2: <V extends DynoJsType<"mat2x2">>(value: V, key?: string) => DynoMat2x2<string, V>;
export declare const dynoMat2x3: <V extends DynoJsType<"mat2x3">>(value: V, key?: string) => DynoMat2x3<string, V>;
export declare const dynoMat2x4: <V extends DynoJsType<"mat2x4">>(value: V, key?: string) => DynoMat2x4<string, V>;
export declare const dynoMat3: <V extends DynoJsType<"mat3">>(value: V, key?: string) => DynoMat3<string, V>;
export declare const dynoMat3x2: <V extends DynoJsType<"mat3x2">>(value: V, key?: string) => DynoMat3x2<string, V>;
export declare const dynoMat3x3: <V extends DynoJsType<"mat3x3">>(value: V, key?: string) => DynoMat3x3<string, V>;
export declare const dynoMat3x4: <V extends DynoJsType<"mat3x4">>(value: V, key?: string) => DynoMat3x4<string, V>;
export declare const dynoMat4: <V extends DynoJsType<"mat4">>(value: V, key?: string) => DynoMat4<string, V>;
export declare const dynoMat4x2: <V extends DynoJsType<"mat4x2">>(value: V, key?: string) => DynoMat4x2<string, V>;
export declare const dynoMat4x3: <V extends DynoJsType<"mat4x3">>(value: V, key?: string) => DynoMat4x3<string, V>;
export declare const dynoMat4x4: <V extends DynoJsType<"mat4x4">>(value: V, key?: string) => DynoMat4x4<string, V>;
export declare const dynoUsampler2D: <V extends DynoJsType<"usampler2D">>(value: V, key?: string) => DynoUsampler2D<string, V>;
export declare const dynoIsampler2D: <V extends DynoJsType<"isampler2D">>(value: V, key?: string) => DynoIsampler2D<string, V>;
export declare const dynoSampler2D: <V extends DynoJsType<"sampler2D">>(value: V, key?: string) => DynoSampler2D<string, V>;
export declare const dynoUsampler2DArray: <V extends DynoJsType<"usampler2DArray">>(value: V, key?: string) => DynoUsampler2DArray<string, V>;
export declare const dynoIsampler2DArray: <V extends DynoJsType<"isampler2DArray">>(key: string, value: V) => DynoIsampler2DArray<string, V>;
export declare const dynoSampler2DArray: <V extends DynoJsType<"sampler2DArray">>(value: V, key?: string) => DynoSampler2DArray<string, V>;
export declare const dynoUsampler3D: <V extends DynoJsType<"usampler3D">>(value: V, key?: string) => DynoUsampler3D<string, V>;
export declare const dynoIsampler3D: <V extends DynoJsType<"isampler3D">>(value: V, key?: string) => DynoIsampler3D<string, V>;
export declare const dynoSampler3D: <V extends DynoJsType<"sampler3D">>(value: V, key?: string) => DynoSampler3D<string, V>;
export declare const dynoUsamplerCube: <V extends DynoJsType<"usamplerCube">>(value: V, key?: string) => DynoUsamplerCube<string, V>;
export declare const dynoIsamplerCube: <V extends DynoJsType<"isamplerCube">>(value: V, key?: string) => DynoIsamplerCube<string, V>;
export declare const dynoSamplerCube: <V extends DynoJsType<"samplerCube">>(value: V, key?: string) => DynoSamplerCube<string, V>;
export declare const dynoSampler2DShadow: <V extends DynoJsType<"sampler2DShadow">>(value: V, key?: string) => DynoSampler2DShadow<string, V>;
export declare const dynoSampler2DArrayShadow: <V extends DynoJsType<"sampler2DArrayShadow">>(value: V, key?: string) => DynoSampler2DArrayShadow<string, V>;
export declare const dynoSamplerCubeShadow: <V extends DynoJsType<"samplerCubeShadow">>(value: V, key?: string) => DynoSamplerCubeShadow<string, V>;
export declare class DynoUniform<T extends DynoType, K extends string = "value", V extends DynoJsType<T> = DynoJsType<T>> extends Dyno<Record<string, never>, {
[key in K]: T;
}> implements HasDynoOut<T> {
type: T;
count?: number;
outKey: K;
value: V;
uniform: {
value: V;
type?: string;
};
constructor({ key, type, count, value, update, globals, }: {
key?: K;
type: T;
count?: number;
value: V;
update?: (value: V) => V | undefined;
globals?: ({ inputs, outputs, }: {
inputs: unknown;
outputs: {
[key in K]?: string;
};
}) => string[];
});
dynoOut(): DynoValue<T>;
}
export declare class DynoBool<K extends string> extends DynoUniform<"bool", K, boolean> {
constructor({ key, value, update, }: {
key?: K;
value: boolean;
update?: (value: boolean) => boolean | undefined;
});
}
export declare class DynoUint<K extends string> extends DynoUniform<"uint", K, number> {
constructor({ key, value, update, }: {
key?: K;
value: number;
update?: (value: number) => number | undefined;
});
}
export declare class DynoInt<K extends string> extends DynoUniform<"int", K, number> {
constructor({ key, value, update, }: {
key?: K;
value: number;
update?: (value: number) => number | undefined;
});
}
export declare class DynoFloat<K extends string = "value"> extends DynoUniform<"float", K, number> {
constructor({ key, value, update, }: {
key?: K;
value: number;
update?: (value: number) => number | undefined;
});
}
export declare class DynoBvec2<K extends string, V extends DynoJsType<"bvec2">> extends DynoUniform<"bvec2", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoUvec2<K extends string, V extends DynoJsType<"uvec2">> extends DynoUniform<"uvec2", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoIvec2<K extends string, V extends DynoJsType<"ivec2">> extends DynoUniform<"ivec2", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoVec2<K extends string, V extends DynoJsType<"vec2">> extends DynoUniform<"vec2", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoBvec3<K extends string, V extends DynoJsType<"bvec3">> extends DynoUniform<"bvec3", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoUvec3<V extends DynoJsType<"uvec3">, K extends string = "value"> extends DynoUniform<"uvec3", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoIvec3<V extends DynoJsType<"ivec3">, K extends string = "value"> extends DynoUniform<"ivec3", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoVec3<V extends DynoJsType<"vec3">, K extends string = "value"> extends DynoUniform<"vec3", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoBvec4<K extends string, V extends DynoJsType<"bvec4">> extends DynoUniform<"bvec4", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoUvec4<K extends string, V extends DynoJsType<"uvec4">> extends DynoUniform<"uvec4", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoIvec4<K extends string, V extends DynoJsType<"ivec4">> extends DynoUniform<"ivec4", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoVec4<V extends DynoJsType<"vec4">, K extends string = "value"> extends DynoUniform<"vec4", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat2<K extends string, V extends DynoJsType<"mat2">> extends DynoUniform<"mat2", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat2x2<K extends string, V extends DynoJsType<"mat2x2">> extends DynoUniform<"mat2x2", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat2x3<K extends string, V extends DynoJsType<"mat2x3">> extends DynoUniform<"mat2x3", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat2x4<K extends string, V extends DynoJsType<"mat2x4">> extends DynoUniform<"mat2x4", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat3<K extends string, V extends DynoJsType<"mat3">> extends DynoUniform<"mat3", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat3x2<K extends string, V extends DynoJsType<"mat3x2">> extends DynoUniform<"mat3x2", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat3x3<K extends string, V extends DynoJsType<"mat3x3">> extends DynoUniform<"mat3x3", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat3x4<K extends string, V extends DynoJsType<"mat3x4">> extends DynoUniform<"mat3x4", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat4<K extends string, V extends DynoJsType<"mat4">> extends DynoUniform<"mat4", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat4x2<K extends string, V extends DynoJsType<"mat4x2">> extends DynoUniform<"mat4x2", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat4x3<K extends string, V extends DynoJsType<"mat4x3">> extends DynoUniform<"mat4x3", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoMat4x4<K extends string, V extends DynoJsType<"mat4x4">> extends DynoUniform<"mat4x4", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoUsampler2D<K extends string, V extends DynoJsType<"usampler2D">> extends DynoUniform<"usampler2D", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoIsampler2D<K extends string, V extends DynoJsType<"isampler2D">> extends DynoUniform<"isampler2D", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoSampler2D<K extends string, V extends DynoJsType<"sampler2D">> extends DynoUniform<"sampler2D", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoUsampler2DArray<K extends string, V extends DynoJsType<"usampler2DArray">> extends DynoUniform<"usampler2DArray", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoIsampler2DArray<K extends string, V extends DynoJsType<"isampler2DArray">> extends DynoUniform<"isampler2DArray", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoSampler2DArray<K extends string, V extends DynoJsType<"sampler2DArray">> extends DynoUniform<"sampler2DArray", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoUsampler3D<K extends string, V extends DynoJsType<"usampler3D">> extends DynoUniform<"usampler3D", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoIsampler3D<K extends string, V extends DynoJsType<"isampler3D">> extends DynoUniform<"isampler3D", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoSampler3D<K extends string, V extends DynoJsType<"sampler3D">> extends DynoUniform<"sampler3D", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoUsamplerCube<K extends string, V extends DynoJsType<"usamplerCube">> extends DynoUniform<"usamplerCube", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoIsamplerCube<K extends string, V extends DynoJsType<"isamplerCube">> extends DynoUniform<"isamplerCube", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoSamplerCube<K extends string, V extends DynoJsType<"samplerCube">> extends DynoUniform<"samplerCube", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoSampler2DShadow<K extends string, V extends DynoJsType<"sampler2DShadow">> extends DynoUniform<"sampler2DShadow", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoSampler2DArrayShadow<K extends string, V extends DynoJsType<"sampler2DArrayShadow">> extends DynoUniform<"sampler2DArrayShadow", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
export declare class DynoSamplerCubeShadow<K extends string, V extends DynoJsType<"samplerCubeShadow">> extends DynoUniform<"samplerCubeShadow", K, V> {
constructor({ key, value, update, }: {
key?: K;
value: V;
update?: (value: V) => V | undefined;
});
}
+139
View File
@@ -0,0 +1,139 @@
import { Dyno, DynoBlock } from './base';
import { ValueTypes } from './types';
import { DynoVal, DynoValue, HasDynoOut } from './value';
export declare const remapIndex: (index: DynoVal<"int">, from: DynoVal<"int">, to: DynoVal<"int">) => DynoVal<"int">;
export declare const pcgMix: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"uint">;
export declare const pcgNext: (state: DynoVal<"uint">) => DynoVal<"uint">;
export declare const pcgHash: (state: DynoVal<"uint">) => DynoVal<"uint">;
export declare const hash: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"uint">;
export declare const hash2: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"uvec2">;
export declare const hash3: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"uvec3">;
export declare const hash4: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"uvec4">;
export declare const hashFloat: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"float">;
export declare const hashVec2: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"vec2">;
export declare const hashVec3: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"vec3">;
export declare const hashVec4: <T extends ValueTypes>(value: DynoVal<T>) => DynoVal<"vec4">;
export declare class DynoRemapIndex extends Dyno<{
from: "int";
to: "int";
index: "int";
}, {
index: "int";
}> implements HasDynoOut<"int"> {
constructor({ from, to, index, }: {
from: DynoVal<"int">;
to: DynoVal<"int">;
index: DynoVal<"int">;
});
dynoOut(): DynoValue<"int">;
}
export declare class PcgNext<T extends "uint" | "int" | "float"> extends Dyno<{
state: T;
}, {
state: "uint";
}> implements HasDynoOut<"uint"> {
constructor({ state }: {
state: DynoVal<T>;
});
dynoOut(): DynoValue<"uint">;
}
export declare class PcgHash extends Dyno<{
state: "uint";
}, {
hash: "uint";
}> implements HasDynoOut<"uint"> {
constructor({ state }: {
state: DynoVal<"uint">;
});
dynoOut(): DynoValue<"uint">;
}
export declare class PcgMix<T extends ValueTypes> extends Dyno<{
value: T;
}, {
state: "uint";
}> implements HasDynoOut<"uint"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"uint">;
}
export declare class Hash<T extends ValueTypes> extends DynoBlock<{
value: T;
}, {
hash: "uint";
}> implements HasDynoOut<"uint"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"uint">;
}
export declare class Hash2<T extends ValueTypes> extends DynoBlock<{
value: T;
}, {
hash: "uvec2";
}> implements HasDynoOut<"uvec2"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"uvec2">;
}
export declare class Hash3<T extends ValueTypes> extends DynoBlock<{
value: T;
}, {
hash: "uvec3";
}> implements HasDynoOut<"uvec3"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"uvec3">;
}
export declare class Hash4<T extends ValueTypes> extends DynoBlock<{
value: T;
}, {
hash: "uvec4";
}> implements HasDynoOut<"uvec4"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"uvec4">;
}
export declare class HashFloat<T extends ValueTypes> extends DynoBlock<{
value: T;
}, {
hash: "float";
}> implements HasDynoOut<"float"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"float">;
}
export declare class HashVec2<T extends ValueTypes> extends DynoBlock<{
value: T;
}, {
hash: "vec2";
}> implements HasDynoOut<"vec2"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"vec2">;
}
export declare class HashVec3<T extends ValueTypes> extends DynoBlock<{
value: T;
}, {
hash: "vec3";
}> implements HasDynoOut<"vec3"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"vec3">;
}
export declare class HashVec4<T extends ValueTypes> extends DynoBlock<{
value: T;
}, {
hash: "vec4";
}> implements HasDynoOut<"vec4"> {
constructor({ value }: {
value: DynoVal<T>;
});
dynoOut(): DynoValue<"vec4">;
}
+32
View File
@@ -0,0 +1,32 @@
import { Dyno, IOTypes } from './base';
import { DynoJsType, DynoType, SimpleTypes } from './types';
export type DynoVal<T extends DynoType> = DynoValue<T> | HasDynoOut<T>;
export declare function valType<T extends DynoType>(val: DynoVal<T>): T;
export interface HasDynoOut<T extends DynoType> {
dynoOut(): DynoValue<T>;
}
export declare class DynoValue<T extends DynoType> {
type: T;
private __isDynoValue;
constructor(type: T);
}
export declare class DynoOutput<T extends DynoType, InTypes extends IOTypes, OutTypes extends IOTypes> extends DynoValue<T> {
dyno: Dyno<InTypes, OutTypes>;
key: string;
constructor(dyno: Dyno<InTypes, OutTypes>, key: string);
}
export declare class DynoLiteral<T extends DynoType> extends DynoValue<T> {
literal: string;
constructor(type: T, literal: string);
getLiteral(): string;
}
export declare function dynoLiteral<T extends DynoType>(type: T, literal: string): DynoLiteral<T>;
export declare class DynoConst<T extends DynoType> extends DynoLiteral<T> {
value: DynoJsType<T>;
constructor(type: T, value: DynoJsType<T>);
getLiteral(): string;
}
export declare function dynoConst<T extends DynoType>(type: T, value: DynoJsType<T>): DynoConst<T>;
export declare function literalZero(type: SimpleTypes): string;
export declare function literalOne(type: SimpleTypes): string;
export declare function literalNegOne(type: SimpleTypes): string;
+226
View File
@@ -0,0 +1,226 @@
import { BinaryOp, Dyno, TrinaryOp, UnaryOp } from './base';
import { FloatTypes, IntTypes, MatFloatTypes, SquareMatTypes, UintTypes, VectorElementType, VectorTypes } from './types';
import { DynoVal, DynoValue, HasDynoOut } from './value';
export declare const length: <A extends "vec2" | "vec3" | "vec4">(a: DynoVal<A>) => DynoVal<"float">;
export declare const distance: <A extends "vec2" | "vec3" | "vec4">(a: DynoVal<A>, b: DynoVal<A>) => DynoVal<"float">;
export declare const dot: <A extends "vec2" | "vec3" | "vec4">(a: DynoVal<A>, b: DynoVal<A>) => DynoVal<"float">;
export declare const cross: (a: DynoVal<"vec3">, b: DynoVal<"vec3">) => DynoVal<"vec3">;
export declare const normalize: <A extends "vec2" | "vec3" | "vec4">(a: DynoVal<A>) => DynoVal<A>;
export declare const faceforward: <A extends "vec2" | "vec3" | "vec4">(a: DynoVal<A>, b: DynoVal<A>, c: DynoVal<A>) => DynoVal<A>;
export declare const reflectVec: <A extends "vec2" | "vec3" | "vec4">(incident: DynoVal<A>, normal: DynoVal<A>) => DynoVal<A>;
export declare const refractVec: <A extends "vec2" | "vec3" | "vec4">(incident: DynoVal<A>, normal: DynoVal<A>, eta: DynoVal<"float">) => DynoVal<A>;
export declare const split: <V extends VectorTypes>(vector: DynoVal<V>) => Split<V>;
export declare const combine: <V extends VectorTypes, T extends VectorElementType<V>>({ vector, vectorType, x, y, z, w, r, g, b, a, }: {
vector?: DynoVal<V>;
vectorType?: V;
x?: DynoVal<T>;
y?: DynoVal<T>;
z?: DynoVal<T>;
w?: DynoVal<T>;
r?: DynoVal<T>;
g?: DynoVal<T>;
b?: DynoVal<T>;
a?: DynoVal<T>;
}) => DynoVal<V>;
export declare const projectH: <A extends "vec3" | "vec4">(a: DynoVal<A>) => DynoVal<ProjectHOutput<A>>;
export declare const extendVec: <A extends "float" | "vec2" | "vec3">(a: DynoVal<A>, b: DynoVal<"float">) => DynoVal<ExtendVecOutput<A>>;
export declare const swizzle: <A extends VectorTypes, S extends SwizzleSelect>(a: DynoVal<A>, select: S) => DynoVal<SwizzleOutput<A, SwizzleSelectLen<S>>>;
export declare const compMult: <A extends MatFloatTypes>(a: DynoVal<A>, b: DynoVal<A>) => DynoVal<A>;
export declare const outer: <A extends "vec2" | "vec3" | "vec4", B extends "vec2" | "vec3" | "vec4">(a: DynoVal<A>, b: DynoVal<B>) => DynoVal<OuterOutput<A, B>>;
export declare const transpose: <A extends MatFloatTypes>(a: DynoVal<A>) => DynoVal<TransposeOutput<A>>;
export declare const determinant: <A extends SquareMatTypes>(a: DynoVal<A>) => DynoVal<"float">;
export declare const inverse: <A extends SquareMatTypes>(a: DynoVal<A>) => DynoVal<A>;
export declare class Length<A extends "vec2" | "vec3" | "vec4"> extends UnaryOp<A, "float", "length"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Distance<A extends "vec2" | "vec3" | "vec4"> extends BinaryOp<A, A, "float", "distance"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<A>;
});
}
export declare class Dot<A extends "vec2" | "vec3" | "vec4"> extends BinaryOp<A, A, "float", "dot"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<A>;
});
}
export declare class Cross extends BinaryOp<"vec3", "vec3", "vec3", "cross"> {
constructor({ a, b }: {
a: DynoVal<"vec3">;
b: DynoVal<"vec3">;
});
}
export declare class Normalize<A extends "vec2" | "vec3" | "vec4"> extends UnaryOp<A, A, "normalize"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
type ProjectHOutput<A extends "vec3" | "vec4"> = A extends "vec3" ? "vec2" : A extends "vec4" ? "vec3" : never;
export declare class ProjectH<A extends "vec3" | "vec4"> extends UnaryOp<A, ProjectHOutput<A>, "projected"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
type ExtendVecOutput<A extends "float" | "vec2" | "vec3"> = A extends "float" ? "vec2" : A extends "vec2" ? "vec3" : A extends "vec3" ? "vec4" : never;
export declare class ExtendVec<A extends "float" | "vec2" | "vec3"> extends BinaryOp<A, "float", ExtendVecOutput<A>, "extend"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<"float">;
});
}
export declare class FaceForward<A extends "vec2" | "vec3" | "vec4"> extends TrinaryOp<A, A, A, A, "forward"> {
constructor({ a, b, c }: {
a: DynoVal<A>;
b: DynoVal<A>;
c: DynoVal<A>;
});
}
export declare class ReflectVec<A extends "vec2" | "vec3" | "vec4"> extends BinaryOp<A, A, A, "reflection"> {
constructor({ incident, normal, }: {
incident: DynoVal<A>;
normal: DynoVal<A>;
});
}
export declare class RefractVec<A extends "vec2" | "vec3" | "vec4"> extends TrinaryOp<A, A, "float", A, "refraction"> {
constructor({ incident, normal, eta, }: {
incident: DynoVal<A>;
normal: DynoVal<A>;
eta: DynoVal<"float">;
});
}
export declare class CompMult<A extends MatFloatTypes> extends BinaryOp<A, A, A, "product"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<A>;
});
}
type OuterOutput<A extends "vec2" | "vec3" | "vec4", B extends "vec2" | "vec3" | "vec4"> = A extends "vec2" ? B extends "vec2" ? "mat2" : B extends "vec3" ? "mat3x2" : B extends "vec4" ? "mat4x2" : never : A extends "vec3" ? B extends "vec2" ? "mat2x3" : B extends "vec3" ? "mat3" : B extends "vec4" ? "mat4x3" : never : A extends "vec4" ? B extends "vec2" ? "mat2x4" : B extends "vec3" ? "mat3x4" : B extends "vec4" ? "mat4" : never : never;
export declare class Outer<A extends "vec2" | "vec3" | "vec4", B extends "vec2" | "vec3" | "vec4"> extends BinaryOp<A, B, OuterOutput<A, B>, "outer"> {
constructor({ a, b }: {
a: DynoVal<A>;
b: DynoVal<B>;
});
}
type TransposeOutput<A extends MatFloatTypes> = A extends SquareMatTypes ? A : A extends "mat2x3" ? "mat3x2" : A extends "mat2x4" ? "mat4x2" : A extends "mat3x2" ? "mat2x3" : A extends "mat3x4" ? "mat4x3" : A extends "mat4x2" ? "mat2x4" : A extends "mat4x3" ? "mat3x4" : never;
export declare class Transpose<A extends MatFloatTypes> extends UnaryOp<A, TransposeOutput<A>, "transpose"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Determinant<A extends SquareMatTypes> extends UnaryOp<A, "float", "det"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
export declare class Inverse<A extends SquareMatTypes> extends UnaryOp<A, A, "inverse"> {
constructor({ a }: {
a: DynoVal<A>;
});
}
type SplitOutTypes<A extends VectorTypes> = A extends "vec2" ? {
x: "float";
y: "float";
r: "float";
g: "float";
} : A extends "vec3" ? {
x: "float";
y: "float";
z: "float";
r: "float";
g: "float";
b: "float";
} : A extends "vec4" ? {
x: "float";
y: "float";
z: "float";
w: "float";
r: "float";
g: "float";
b: "float";
a: "float";
} : A extends "ivec2" ? {
x: "int";
y: "int";
r: "int";
g: "int";
} : A extends "ivec3" ? {
x: "int";
y: "int";
z: "int";
r: "int";
g: "int";
b: "int";
} : A extends "ivec4" ? {
x: "int";
y: "int";
z: "int";
w: "int";
r: "int";
g: "int";
b: "int";
a: "int";
} : A extends "uvec2" ? {
x: "uint";
y: "uint";
r: "uint";
g: "uint";
} : A extends "uvec3" ? {
x: "uint";
y: "uint";
z: "uint";
r: "uint";
g: "uint";
b: "uint";
} : A extends "uvec4" ? {
x: "uint";
y: "uint";
z: "uint";
w: "uint";
r: "uint";
g: "uint";
b: "uint";
a: "uint";
} : never;
export declare class Split<V extends VectorTypes> extends Dyno<{
vector: V;
}, SplitOutTypes<V>> {
constructor({ vector }: {
vector: DynoVal<V>;
});
}
export declare class Combine<V extends VectorTypes, T extends VectorElementType<V>> extends Dyno<SplitOutTypes<V> & {
vector: V;
}, {
vector: V;
}> implements HasDynoOut<V> {
constructor({ vector, vectorType, x, y, z, w, r, g, b, a, }: {
vector?: DynoVal<V>;
vectorType?: V;
x?: DynoVal<T>;
y?: DynoVal<T>;
z?: DynoVal<T>;
w?: DynoVal<T>;
r?: DynoVal<T>;
g?: DynoVal<T>;
b?: DynoVal<T>;
a?: DynoVal<T>;
});
dynoOut(): DynoValue<V>;
}
type SwizzleOutput<A extends VectorTypes, Len extends number> = A extends FloatTypes ? Len extends 1 ? "float" : Len extends 2 ? "vec2" : Len extends 3 ? "vec3" : Len extends 4 ? "vec4" : never : A extends IntTypes ? Len extends 1 ? "int" : Len extends 2 ? "ivec2" : Len extends 3 ? "ivec3" : Len extends 4 ? "ivec4" : never : A extends UintTypes ? Len extends 1 ? "uint" : Len extends 2 ? "uvec2" : Len extends 3 ? "uvec3" : Len extends 4 ? "uvec4" : never : never;
type SwizzleSelectLen<S extends SwizzleSelect> = S extends Swizzle1Select ? 1 : S extends Swizzle2Select ? 2 : S extends Swizzle3Select ? 3 : S extends Swizzle4Select ? 4 : never;
type Swizzle1Select = `${"x" | "y" | "z" | "w"}|${"r" | "g" | "b" | "a"}`;
type Swizzle2Select = `${"x" | "y" | "z" | "w"}${"x" | "y" | "z" | "w"}` | `${"r" | "g" | "b" | "a"}${"r" | "g" | "b" | "a"}`;
type Swizzle3Select = `${"x" | "y" | "z" | "w"}${"x" | "y" | "z" | "w"}${"x" | "y" | "z" | "w"}` | `${"r" | "g" | "b" | "a"}${"r" | "g" | "b" | "a"}${"r" | "g" | "b" | "a"}`;
type Swizzle4Select = `${"x" | "y" | "z" | "w"}${"x" | "y" | "z" | "w"}${"x" | "y" | "z" | "w"}${"x" | "y" | "z" | "w"}` | `${"r" | "g" | "b" | "a"}${"r" | "g" | "b" | "a"}${"r" | "g" | "b" | "a"}${"r" | "g" | "b" | "a"}`;
type SwizzleSelect = Swizzle1Select | Swizzle2Select | Swizzle3Select | Swizzle4Select;
export declare class Swizzle<A extends VectorTypes, S extends SwizzleSelect> extends UnaryOp<A, SwizzleOutput<A, SwizzleSelectLen<S>>, "swizzle"> {
constructor({ vector, select }: {
vector: DynoVal<A>;
select: S;
});
}
export {};
+2
View File
@@ -0,0 +1,2 @@
export * from './generators/static';
export * from './generators/snow';
+65
View File
@@ -0,0 +1,65 @@
import { SplatGenerator } from '../SplatGenerator';
import * as THREE from "three";
export declare const DEFAULT_SNOW: {
box: THREE.Box3;
density: number;
fallDirection: THREE.Vector3;
fallVelocity: number;
wanderScale: number;
wanderVariance: number;
color1: THREE.Color;
color2: THREE.Color;
minScale: number;
maxScale: number;
anisoScale: THREE.Vector3;
};
export declare const DEFAULT_RAIN: {
box: THREE.Box3;
density: number;
fallDirection: THREE.Vector3;
fallVelocity: number;
wanderScale: number;
wanderVariance: number;
color1: THREE.Color;
color2: THREE.Color;
minScale: number;
maxScale: number;
anisoScale: THREE.Vector3;
};
export declare function snowBox({ box, minY, numSplats, density, anisoScale, minScale, maxScale, fallDirection, fallVelocity, wanderScale, wanderVariance, color1, color2, opacity, onFrame, }: {
box?: THREE.Box3;
minY?: number;
numSplats?: number;
density?: number;
anisoScale?: THREE.Vector3;
minScale?: number;
maxScale?: number;
fallDirection?: THREE.Vector3;
fallVelocity?: number;
wanderScale?: number;
wanderVariance?: number;
color1?: THREE.Color;
color2?: THREE.Color;
opacity?: number;
onFrame?: ({ object, time, deltaTime, }: {
object: SplatGenerator;
time: number;
deltaTime: number;
}) => void;
}): {
snow: SplatGenerator;
min: import('../dyno').DynoVec3<THREE.Vector3, string>;
max: import('../dyno').DynoVec3<THREE.Vector3, string>;
minY: import('../dyno').DynoFloat<string>;
color1: import('../dyno').DynoVec3<THREE.Color, string>;
color2: import('../dyno').DynoVec3<THREE.Color, string>;
opacity: import('../dyno').DynoFloat<string>;
fallVelocity: import('../dyno').DynoFloat<string>;
wanderVariance: import('../dyno').DynoFloat<string>;
wanderScale: import('../dyno').DynoFloat<string>;
fallDirection: import('../dyno').DynoVec3<THREE.Vector3, string>;
minScale: import('../dyno').DynoFloat<string>;
maxScale: import('../dyno').DynoFloat<string>;
anisoScale: import('../dyno').DynoVec3<THREE.Vector3, string>;
};
export type SNOW_RESULT_TYPE = ReturnType<typeof snowBox>;
+9
View File
@@ -0,0 +1,9 @@
import { SplatGenerator } from '../SplatGenerator';
import * as THREE from "three";
export declare function staticBox({ box, cells, dotScale, color, opacity, }: {
box: THREE.Box3;
cells: THREE.Vector3;
dotScale: number;
color?: THREE.Color;
opacity?: number;
}): SplatGenerator;
+95
View File
@@ -0,0 +1,95 @@
import { Object3D, Quaternion, Vector3, WebXRManager } from 'three';
import { SplatMesh } from './SplatMesh';
export declare enum JointEnum {
w = "wrist",
t0 = "thumb-metacarpal",
t1 = "thumb-phalanx-proximal",
t2 = "thumb-phalanx-distal",
t3 = "thumb-tip",
i0 = "index-finger-metacarpal",
i1 = "index-finger-phalanx-proximal",
i2 = "index-finger-phalanx-intermediate",
i3 = "index-finger-phalanx-distal",
i4 = "index-finger-tip",
m0 = "middle-finger-metacarpal",
m1 = "middle-finger-phalanx-proximal",
m2 = "middle-finger-phalanx-intermediate",
m3 = "middle-finger-phalanx-distal",
m4 = "middle-finger-tip",
r0 = "ring-finger-metacarpal",
r1 = "ring-finger-phalanx-proximal",
r2 = "ring-finger-phalanx-intermediate",
r3 = "ring-finger-phalanx-distal",
r4 = "ring-finger-tip",
p0 = "pinky-finger-metacarpal",
p1 = "pinky-finger-phalanx-proximal",
p2 = "pinky-finger-phalanx-intermediate",
p3 = "pinky-finger-phalanx-distal",
p4 = "pinky-finger-tip"
}
export type JointId = keyof typeof JointEnum;
export declare const JOINT_IDS: JointId[];
export declare const NUM_JOINTS: number;
export declare const JOINT_INDEX: {
[key in JointId]: number;
};
export declare const JOINT_RADIUS: {
[key in JointId]: number;
};
export declare const JOINT_SEGMENTS: JointId[][];
export declare const JOINT_SEGMENT_STEPS: number[][];
export declare const JOINT_TIPS: JointId[];
export declare const FINGER_TIPS: JointId[];
export declare enum Hand {
left = "left",
right = "right"
}
export declare const HANDS: Hand[];
export type Joint = {
position: Vector3;
quaternion: Quaternion;
radius: number;
};
export type HandJoints = {
[key in JointId]?: Joint;
};
export type HandsJoints = {
[key in Hand]?: HandJoints;
};
export declare class XrHands {
hands: HandsJoints;
last: HandsJoints;
values: Record<string, number>;
tests: Record<string, boolean>;
lastTests: Record<string, boolean>;
updated: boolean;
update({ xr, xrFrame }: {
xr: WebXRManager;
xrFrame: XRFrame;
}): void;
makeGhostMesh(): SplatMesh;
distance(handA: Hand, jointA: JointId, handB: Hand, jointB: JointId, last?: boolean): number;
separation(handA: Hand, jointA: JointId, handB: Hand, jointB: JointId, last?: boolean): number;
touching(handA: Hand, jointA: JointId, handB: Hand, jointB: JointId, last?: boolean): number;
allTipsTouching(hand: Hand, last?: boolean): number;
triTipsTouching(hand: Hand, last?: boolean): number;
}
export declare class HandMovement {
xrHands: XrHands;
control: Object3D;
moveInertia: number;
rotateInertia: number;
lastGrip: {
[key in Hand]?: Vector3;
};
lastPivot: Vector3;
rotateVelocity: number;
velocity: Vector3;
constructor({ xrHands, control, moveInertia, rotateInertia, }: {
xrHands: XrHands;
control: Object3D;
moveInertia?: number;
rotateInertia?: number;
});
update(deltaTime: number): void;
}
+20
View File
@@ -0,0 +1,20 @@
export { ForgeRenderer, type ForgeRendererOptions } from './ForgeRenderer';
export { ForgeViewpoint, type ForgeViewpointOptions } from './ForgeViewpoint';
export * as dyno from './dyno';
export { SplatLoader, unpackSplats, SplatFileType, getSplatFileType, } from './SplatLoader';
export { PlyReader } from './ply';
export { SpzReader, SpzWriter, transcodeSpz } from './spz';
export { PackedSplats, type PackedSplatsOptions } from './PackedSplats';
export { SplatGenerator, type GsplatGenerator, SplatModifier, type GsplatModifier, SplatTransformer, } from './SplatGenerator';
export { SplatAccumulator, type GeneratorMapping } from './SplatAccumulator';
export { Readback, type Rgba8Readback, type ReadbackBuffer } from './Readback';
export { SplatMesh, type SplatMeshOptions, type SplatMeshContext, } from './SplatMesh';
export { SplatSkinning, type SplatSkinningOptions } from './SplatSkinning';
export { SplatEdit, type SplatEditOptions, SplatEditSdf, type SplatEditSdfOptions, SplatEditSdfType, SplatEditRgbaBlendMode, SplatEdits, } from './SplatEdit';
export { constructGrid, constructAxes, constructSpherePoints, imageSplats, textSplats, } from './splatConstructors';
export * as generators from './generators';
export { VRButton } from './vrButton';
export { type JointId, JointEnum, JOINT_IDS, NUM_JOINTS, JOINT_INDEX, JOINT_RADIUS, JOINT_SEGMENTS, JOINT_SEGMENT_STEPS, JOINT_TIPS, FINGER_TIPS, Hand, HANDS, type Joint, type HandJoints, type HandsJoints, XrHands, HandMovement, } from './hands';
export { ForgeControls, FpsMovement, PointerControls } from './controls';
export { isMobile, isAndroid, isOculus, flipPixels, pixelsToPngUrl, toHalf, fromHalf, floatToUint8, floatToSint8, Uint8ToFloat, Sint8ToFloat, setPackedSplat, unpackSplat, } from './utils';
export * as utils from './utils';
+6
View File
@@ -0,0 +1,6 @@
export declare function decodeKsplat(fileBytes: Uint8Array, initNumSplats: (numSplats: number) => void, splatCallback: (index: number, x: number, y: number, z: number, scaleX: number, scaleY: number, scaleZ: number, quatX: number, quatY: number, quatZ: number, quatW: number, opacity: number, r: number, g: number, b: number) => void, shCallback?: (index: number, sh1: Float32Array, sh2?: Float32Array, sh3?: Float32Array) => void): void;
export declare function unpackKsplat(fileBytes: Uint8Array): {
packedArray: Uint32Array;
numSplats: number;
extra: Record<string, unknown>;
};
+31
View File
@@ -0,0 +1,31 @@
export type PlyPropertyType = "char" | "uchar" | "short" | "ushort" | "int" | "uint" | "float" | "double";
export type PlyElement = {
name: string;
count: number;
properties: Record<string, PlyProperty>;
};
export type PlyProperty = {
isList: boolean;
type: PlyPropertyType;
countType?: PlyPropertyType;
};
export type SplatCallback = (index: number, x: number, y: number, z: number, scaleX: number, scaleY: number, scaleZ: number, quatX: number, quatY: number, quatZ: number, quatW: number, opacity: number, r: number, g: number, b: number) => void;
export type SplatShCallback = (index: number, sh1: Float32Array, sh2?: Float32Array, sh3?: Float32Array) => void;
export declare class PlyReader {
fileBytes: Uint8Array;
header: string;
littleEndian: boolean;
elements: Record<string, PlyElement>;
comments: string[];
data: DataView | null;
static defaultPointScale: number;
numSplats: number;
constructor({ fileBytes }: {
fileBytes: Uint8Array | ArrayBuffer;
});
parseHeader(): Promise<void>;
parseData(elementCallback: (element: PlyElement) => null | ((index: number, item: Record<string, number | number[]>) => void)): void;
parseSplats(splatCallback: SplatCallback, shCallback?: SplatShCallback): void;
injectRgba(rgba: Uint8Array): void;
}
export declare const SH_C0 = 0.28209479177387814;
+1
View File
@@ -0,0 +1 @@
export declare function getShaders(): Record<string, string>;
+46
View File
@@ -0,0 +1,46 @@
import { PackedSplats } from './PackedSplats';
import { SplatMesh } from './SplatMesh';
import * as THREE from "three";
export declare function constructGrid({ splats, extents, stepSize, pointRadius, pointShadowScale, opacity, color, }: {
splats: PackedSplats;
extents: THREE.Box3;
stepSize?: number;
pointRadius?: number;
pointShadowScale?: number;
opacity?: number;
color?: THREE.Color | ((color: THREE.Color, point: THREE.Vector3) => void);
}): void;
export declare function constructAxes({ splats, scale, axisRadius, axisShadowScale, origins, }: {
splats: PackedSplats;
scale?: number;
axisRadius?: number;
axisShadowScale?: number;
origins?: THREE.Vector3[];
}): void;
export declare function constructSpherePoints({ splats, origin, radius, maxDepth, filter, pointRadius, pointThickness, color, }: {
splats: PackedSplats;
origin?: THREE.Vector3;
radius?: number;
maxDepth?: number;
filter?: ((point: THREE.Vector3) => boolean) | null;
pointRadius?: number;
pointThickness?: number;
color?: THREE.Color | ((color: THREE.Color, point: THREE.Vector3) => void);
}): void;
export declare function textSplats({ text, font, fontSize, color, rgb, dotRadius, textAlign, lineHeight, objectScale, }: {
text: string;
font?: string;
fontSize?: number;
color?: THREE.Color;
rgb?: THREE.Color;
dotRadius?: number;
textAlign?: "left" | "center" | "right" | "start" | "end";
lineHeight?: number;
objectScale?: number;
}): SplatMesh;
export declare function imageSplats({ url, dotRadius, subXY, forEachSplat, }: {
url: string;
dotRadius?: number;
subXY?: number;
forEachSplat?: (width: number, height: number, index: number, center: THREE.Vector3, scales: THREE.Vector3, quaternion: THREE.Quaternion, opacity: number, color: THREE.Color) => number | null;
}): SplatMesh;
+20
View File
@@ -0,0 +1,20 @@
export declare class SplatWorker {
worker: Worker;
messages: Record<number, {
resolve: (value: unknown) => void;
reject: (reason?: unknown) => void;
}>;
messageIdNext: number;
constructor();
makeMessageId(): number;
makeMessagePromiseId(): {
id: number;
promise: Promise<unknown>;
};
onMessage(event: MessageEvent): void;
call(name: string, args: unknown): Promise<unknown>;
}
export declare function setWorkerPool(count?: number): void;
export declare function allocWorker(): Promise<SplatWorker>;
export declare function freeWorker(worker: SplatWorker): void;
export declare function withWorker<T>(callback: (worker: SplatWorker) => Promise<T>): Promise<T>;
+50
View File
@@ -0,0 +1,50 @@
import { TranscodeSpzInput } from './SplatLoader';
import { GunzipReader } from './utils';
export declare class SpzReader {
fileBytes: Uint8Array;
reader: GunzipReader;
version: number;
numSplats: number;
shDegree: number;
fractionalBits: number;
flags: number;
flagAntiAlias: boolean;
reserved: number;
parsed: boolean;
constructor({ fileBytes }: {
fileBytes: Uint8Array | ArrayBuffer;
});
parseSplats(centerCallback?: (index: number, x: number, y: number, z: number) => void, alphaCallback?: (index: number, alpha: number) => void, rgbCallback?: (index: number, r: number, g: number, b: number) => void, scalesCallback?: (index: number, scaleX: number, scaleY: number, scaleZ: number) => void, quatCallback?: (index: number, quatX: number, quatY: number, quatZ: number, quatW: number) => void, shCallback?: (index: number, sh1: Float32Array, sh2?: Float32Array, sh3?: Float32Array) => void): void;
}
export declare const SPZ_MAGIC = 1347635022;
export declare const SPZ_VERSION = 2;
export declare const FLAG_ANTIALIASED = 1;
export declare class SpzWriter {
buffer: ArrayBuffer;
view: DataView;
numSplats: number;
shDegree: number;
fractionalBits: number;
fraction: number;
flagAntiAlias: boolean;
clippedCount: number;
constructor({ numSplats, shDegree, fractionalBits, flagAntiAlias, }: {
numSplats: number;
shDegree: number;
fractionalBits?: number;
flagAntiAlias?: boolean;
});
setCenter(index: number, x: number, y: number, z: number): void;
setAlpha(index: number, alpha: number): void;
static scaleRgb(r: number): number;
setRgb(index: number, r: number, g: number, b: number): void;
setScale(index: number, scaleX: number, scaleY: number, scaleZ: number): void;
setQuat(index: number, quatX: number, quatY: number, quatZ: number, quatW: number): void;
static quantizeSh(sh: number, bits: number): number;
setSh(index: number, sh1: Float32Array, sh2?: Float32Array, sh3?: Float32Array): void;
finalize(): Promise<Uint8Array>;
}
export declare function transcodeSpz(input: TranscodeSpzInput): Promise<{
fileBytes: Uint8Array<ArrayBufferLike>;
clippedCount: number;
}>;
+150
View File
@@ -0,0 +1,150 @@
import { Gunzip } from 'fflate';
import * as THREE from "three";
export declare function floatBitsToUint(f: number): number;
export declare function uintBitsToFloat(u: number): number;
export declare function toHalf(f: number): number;
export declare function fromHalf(h: number): number;
export declare function floatToUint8(v: number): number;
export declare function floatToSint8(v: number): number;
export declare function Uint8ToFloat(v: number): number;
export declare function Sint8ToFloat(v: number): number;
export declare class DataCache {
maxItems: number;
asyncFetch: (key: string) => Promise<unknown>;
items: {
key: string;
data: unknown;
}[];
constructor({ asyncFetch, maxItems, }: {
asyncFetch: (key: string) => Promise<unknown>;
maxItems?: number;
});
getFetch(key: string): Promise<unknown>;
}
export declare function mapObject(obj: Record<string, unknown>, fn: (value: unknown, key: string) => unknown): Record<string, unknown>;
export declare function mapFilterObject(obj: Record<string, unknown>, fn: (value: unknown, key: string) => unknown): Record<string, unknown>;
export declare function getArrayBuffers(ctx: unknown): Transferable[];
export declare function newArray<T>(n: number, initFunction: (index: number) => T): T[];
export declare class FreeList<T, Args> {
items: T[];
allocate: (args: Args) => T;
dispose?: (item: T) => void;
valid: (item: T, args: Args) => boolean;
constructor({ allocate, dispose, valid, }: {
allocate: (args: Args) => T;
dispose?: (item: T) => void;
valid: (item: T, args: Args) => boolean;
});
alloc(args: Args): T;
free(item: T): void;
disposeAll(): void;
}
export declare function setPackedSplat(packedSplats: Uint32Array, index: number, x: number, y: number, z: number, scaleX: number, scaleY: number, scaleZ: number, quatX: number, quatY: number, quatZ: number, quatW: number, opacity: number, r: number, g: number, b: number): void;
export declare function setPackedSplatCenter(packedSplats: Uint32Array, index: number, x: number, y: number, z: number): void;
export declare function setPackedSplatScales(packedSplats: Uint32Array, index: number, scaleX: number, scaleY: number, scaleZ: number): void;
export declare function setPackedSplatQuat(packedSplats: Uint32Array, index: number, quatX: number, quatY: number, quatZ: number, quatW: number): void;
export declare function setPackedSplatRgb(packedSplats: Uint32Array, index: number, r: number, g: number, b: number): void;
export declare function setPackedSplatOpacity(packedSplats: Uint32Array, index: number, opacity: number): void;
export declare function unpackSplat(packedSplats: Uint32Array, index: number): {
center: THREE.Vector3;
scales: THREE.Vector3;
quaternion: THREE.Quaternion;
color: THREE.Color;
opacity: number;
};
export declare function getTextureSize(numSplats: number): {
width: number;
height: number;
depth: number;
maxSplats: number;
};
export declare function computeMaxSplats(numSplats: number): number;
export declare function isMobile(): boolean;
export declare function isAndroid(): boolean;
export declare function isOculus(): boolean;
export declare function flipPixels(pixels: Uint8Array, width: number, height: number): Uint8Array;
export declare function pixelsToPngUrl(pixels: Uint8Array, width: number, height: number): string;
export declare function cloneClock(clock: THREE.Clock): THREE.Clock;
export declare function omitUndefined<T extends object>(obj: T): Partial<T>;
export declare const IDENT_VERTEX_SHADER: string;
export declare function averagePositions(positions: THREE.Vector3[]): THREE.Vector3;
export declare function averageQuaternions(quaternions: THREE.Quaternion[]): THREE.Quaternion;
export declare function coinciDist(matrix1: THREE.Matrix4, matrix2: THREE.Matrix4): {
distance: number;
coincidence: number;
};
export declare function withinDist({ matrix1, matrix2, maxDistance, }: {
matrix1: THREE.Matrix4;
matrix2: THREE.Matrix4;
maxDistance: number;
}): boolean;
export declare function withinCoinciDist({ matrix1, matrix2, maxDistance, minCoincidence, }: {
matrix1: THREE.Matrix4;
matrix2: THREE.Matrix4;
maxDistance: number;
minCoincidence?: number;
}): boolean;
export declare function coorientDist(matrix1: THREE.Matrix4, matrix2: THREE.Matrix4): {
distance: number;
coorient: number;
};
export declare function withinCoorientDist({ matrix1, matrix2, maxDistance, minCoorient, }: {
matrix1: THREE.Matrix4;
matrix2: THREE.Matrix4;
maxDistance: number;
minCoorient?: number;
}): boolean;
export declare function epsilonSign(value: number, epsilon?: number): number;
export declare function encodeQuatXyz888(q: THREE.Quaternion): number;
export declare function decodeQuatXyz888(encoded: number, out: THREE.Quaternion): THREE.Quaternion;
/**
* Encodes a THREE.Quaternion into a 24‐bit integer.
*
* Bit layout (LSB → MSB):
* - Bits 0–7: quantized U (8 bits)
* - Bits 8–15: quantized V (8 bits)
* - Bits 16–23: quantized angle θ (8 bits) from [0,π]
*
* This version uses folded octahedral mapping (all inline).
*/
export declare function encodeQuatOctXy88R8(q: THREE.Quaternion): number;
/**
* Decodes a 24‐bit encoded quaternion (packed in a number) back to a THREE.Quaternion.
*
* Assumes the same bit layout as in encodeQuatOctXy88R8.
*/
export declare function decodeQuatOctXy88R8(encoded: number, out: THREE.Quaternion): THREE.Quaternion;
/**
* Encodes a THREE.Quaternion into a 24‑bit unsigned integer
* by converting it to Euler angles (roll, pitch, yaw).
* The Euler angles are assumed to be in radians in the range [-π, π].
* Each angle is normalized to [0,1] and quantized to 8 bits.
* Bit layout (LSB→MSB):
* - Bits 0–7: roll (quantized)
* - Bits 8–15: pitch (quantized)
* - Bits 16–23: yaw (quantized)
*/
export declare function encodeQuatEulerXyz888(q: THREE.Quaternion): number;
/**
* Decodes a 24‑bit unsigned integer into a THREE.Quaternion
* by unpacking three 8‑bit values (roll, pitch, yaw) in the range [0,255]
* and then converting them back to Euler angles in [-π, π] and to a quaternion.
*/
export declare function decodeQuatEulerXyz888(encoded: number, out: THREE.Quaternion): THREE.Quaternion;
export declare function encodeSh1Rgb(sh1Array: Uint32Array, index: number, sh1Rgb: Float32Array): void;
export declare function encodeSh2Rgb(sh2Array: Uint32Array, index: number, sh2Rgb: Float32Array): void;
export declare function encodeSh3Rgb(sh3Array: Uint32Array, index: number, sh3Rgb: Float32Array): void;
export declare function decompressPartialGzip(fileBytes: Uint8Array, numBytes: number): Uint8Array;
export declare class GunzipReader {
fileBytes: Uint8Array;
chunkBytes: number;
offset: number;
chunks: Uint8Array[];
totalBytes: number;
gunzip: Gunzip;
constructor({ fileBytes, chunkBytes, }: {
fileBytes: Uint8Array;
chunkBytes?: number;
});
read(numBytes: number): Uint8Array;
}
+6
View File
@@ -0,0 +1,6 @@
import type * as THREE from "three";
export declare class VRButton {
static createButton(renderer: THREE.WebGLRenderer, sessionInit?: XRSessionInit): HTMLElement | null;
static registerSessionGrantedListener(): null | undefined;
static xrSessionIsGranted: boolean;
}
+1
View File
@@ -0,0 +1 @@
export {};
+971
View File
File diff suppressed because it is too large. Load diff
+3 -2
View File
@@ -8,7 +8,7 @@
"assets:clean": "node scripts/clean-assets.js",
"assets:compress": "node scripts/compress-to-spz.js",
"assets:download": "node scripts/download-assets.js",
"build": "vite build --mode production && vite build --mode dev && tsc --emitDeclarationOnly --outFile dist/forge.d.ts",
"build": "vite build --mode production && vite build --mode dev",
"build:wasm": "node rust/build_wasm.js",
"build:watch": "onchange 'src/**/*.{ts,glsl}' -- npm run build",
"clean": "rm -rf dist/ && rm -rf node_modules/ && rm -rf rust/target/ && rm -rf rust/forge-internal-rs/pkg/ && npm run assets:clean",
@@ -29,7 +29,7 @@
},
"exports": {
".": {
"types": "./dist/forge.d.ts",
"types": "./dist/types/index.d.ts",
"import": "./dist/forge.module.js",
"require": "./dist/forge.cjs.js"
}
@@ -46,6 +46,7 @@
"ts-node": "10.9.2",
"typescript": "^5.7.3",
"vite": "^6.0.11",
"vite-plugin-dts": "^4.5.4",
"vite-plugin-glsl": "^1.3.1"
},
"dependencies": {
+3
View File
@@ -1,6 +1,7 @@
import fs from "node:fs";
import path from "node:path";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import glsl from "vite-plugin-glsl";
const assetsDirectory = "examples/assets";
@@ -30,6 +31,8 @@ export default defineConfig(({ mode }) => {
include: ["**/*.glsl"],
}),
dts({ outDir: "dist/types" }),
{
name: "serve-three-alias",
configureServer(server) {