mirror of
https://github.com/storytold/spark.git
synced 2026-11-20 17:20:47 +01:00
Bump dist build
This commit is contained in:
1 parent
0c07ee2fd4
commit
a98cd0f4c6
9 files changed
+1441
-1467
No files matched your search
Vendored
-1
@@ -1 +0,0 @@
|
||||
3daecd37c72d10f40c0402da279d60575b4ae569
|
||||
Vendored
+24
-33
@@ -7234,6 +7234,7 @@ const _SplatMesh = class _SplatMesh extends SplatGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.add(createRendererDetectionMesh());
|
||||
}
|
||||
async asyncInitialize(options) {
|
||||
const {
|
||||
@@ -7791,6 +7792,29 @@ function evaluateSH3(gsplat, sh3, viewDir) {
|
||||
`)
|
||||
}).outputs.rgb;
|
||||
}
|
||||
const EMPTY_GEOMETRY$1 = new THREE__namespace.BufferGeometry();
|
||||
const EMPTY_MATERIAL = new THREE__namespace.ShaderMaterial();
|
||||
function createRendererDetectionMesh() {
|
||||
const mesh = new THREE__namespace.Mesh(EMPTY_GEOMETRY$1, EMPTY_MATERIAL);
|
||||
mesh.frustumCulled = false;
|
||||
mesh.onBeforeRender = function(renderer, scene) {
|
||||
if (!scene.isScene) {
|
||||
this.removeFromParent();
|
||||
return;
|
||||
}
|
||||
let hasSparkRenderer = false;
|
||||
scene.traverse((c) => {
|
||||
if (c instanceof SparkRenderer) {
|
||||
hasSparkRenderer = true;
|
||||
}
|
||||
});
|
||||
if (!hasSparkRenderer) {
|
||||
scene.add(new SparkRenderer({ renderer }));
|
||||
}
|
||||
this.removeFromParent();
|
||||
};
|
||||
return mesh;
|
||||
}
|
||||
const PLY_PROPERTY_TYPES = [
|
||||
"char",
|
||||
"uchar",
|
||||
@@ -10328,38 +10352,6 @@ function getShaders() {
|
||||
return shaders;
|
||||
}
|
||||
const MAX_ACCUMULATORS = 5;
|
||||
let hasSplatMesh = false;
|
||||
let hasSparkRenderer = false;
|
||||
let sparkRendererInstance;
|
||||
function containsSplatMesh(object3D) {
|
||||
let hasSplatMesh2 = false;
|
||||
if (object3D instanceof SplatMesh) {
|
||||
return true;
|
||||
}
|
||||
object3D.traverse((child) => {
|
||||
hasSplatMesh2 = hasSplatMesh2 || child instanceof SplatMesh;
|
||||
});
|
||||
return hasSplatMesh2;
|
||||
}
|
||||
const sceneAdd = THREE__namespace.Scene.prototype.add;
|
||||
THREE__namespace.Scene.prototype.add = function(object) {
|
||||
hasSplatMesh = hasSplatMesh || containsSplatMesh(object);
|
||||
hasSparkRenderer = hasSparkRenderer || object instanceof SparkRenderer;
|
||||
sceneAdd.call(this, object);
|
||||
return this;
|
||||
};
|
||||
const sceneOnBeforeRender = THREE__namespace.Scene.prototype.onBeforeRender;
|
||||
THREE__namespace.Scene.prototype.onBeforeRender = function(renderer) {
|
||||
if (!hasSplatMesh) {
|
||||
return;
|
||||
}
|
||||
if (!hasSparkRenderer) {
|
||||
const spark = sparkRendererInstance || new SparkRenderer({ renderer });
|
||||
this.add(spark);
|
||||
}
|
||||
THREE__namespace.Scene.prototype.onBeforeRender = sceneOnBeforeRender;
|
||||
THREE__namespace.Scene.prototype.add = sceneAdd;
|
||||
};
|
||||
const _SparkRenderer = class _SparkRenderer extends THREE__namespace.Mesh {
|
||||
constructor(options) {
|
||||
const uniforms = _SparkRenderer.makeUniforms();
|
||||
@@ -10442,7 +10434,6 @@ const _SparkRenderer = class _SparkRenderer extends THREE__namespace.Mesh {
|
||||
this.viewpoint = this.defaultView;
|
||||
this.prepareViewpoint(this.viewpoint);
|
||||
this.clock = options.clock ? cloneClock(options.clock) : new THREE__namespace.Clock();
|
||||
sparkRendererInstance = this;
|
||||
}
|
||||
static makeUniforms() {
|
||||
const uniforms = {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"spark.cjs.js","sources":["../node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/fflate/esm/browser.js","../rust/spark-internal-rs/pkg/spark_internal_rs.js","../src/defines.ts","../src/dyno/types.ts","../src/dyno/value.ts","../src/dyno/base.ts","../src/dyno/splats.ts","../src/dyno/output.ts","../src/dyno/uniforms.ts","../src/utils.ts","../src/dyno/program.ts","../src/dyno/mathTypes.ts","../src/dyno/math.ts","../src/dyno/logic.ts","../src/dyno/convert.ts","../src/dyno/vecmat.ts","../src/dyno/util.ts","../src/dyno/transform.ts","../src/dyno/control.ts","../src/dyno/texture.ts","../src/dyno/trig.ts","../src/shaders/computeVec4.glsl","../src/Readback.ts","../src/RgbaArray.ts","../src/SplatEdit.ts","../src/SplatGenerator.ts","../src/SplatMesh.ts","../src/ply.ts","../src/splatWorker.ts","../src/SplatLoader.ts","../src/shaders/computeUvec4.glsl","../src/PackedSplats.ts","../src/SplatGeometry.ts","../src/SparkViewpoint.ts","../src/SplatAccumulator.ts","../src/shaders/splatDefines.glsl","../src/shaders/splatFragment.glsl","../src/shaders/splatVertex.glsl","../src/shaders.ts","../src/SparkRenderer.ts","../src/antisplat.ts","../src/ksplat.ts","../src/spz.ts","../src/SplatSkinning.ts","../src/splatConstructors.ts","../src/generators/static.ts","../src/generators/snow.ts","../src/modifiers/normalColor.ts","../src/modifiers/depthColor.ts","../src/vrButton.ts","../src/hands.ts","../src/controls.ts"],"sourcesContent":["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebGLRendeLine truncated
|
||||
{"version":3,"file":"spark.cjs.js","sources":["../node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/fflate/esm/browser.js","../rust/spark-internal-rs/pkg/spark_internal_rs.js","../src/defines.ts","../src/dyno/types.ts","../src/dyno/value.ts","../src/dyno/base.ts","../src/dyno/splats.ts","../src/dyno/output.ts","../src/dyno/uniforms.ts","../src/utils.ts","../src/dyno/program.ts","../src/dyno/mathTypes.ts","../src/dyno/math.ts","../src/dyno/logic.ts","../src/dyno/convert.ts","../src/dyno/vecmat.ts","../src/dyno/util.ts","../src/dyno/transform.ts","../src/dyno/control.ts","../src/dyno/texture.ts","../src/dyno/trig.ts","../src/shaders/computeVec4.glsl","../src/Readback.ts","../src/RgbaArray.ts","../src/SplatEdit.ts","../src/SplatGenerator.ts","../src/SplatMesh.ts","../src/ply.ts","../src/splatWorker.ts","../src/SplatLoader.ts","../src/shaders/computeUvec4.glsl","../src/PackedSplats.ts","../src/SplatGeometry.ts","../src/SparkViewpoint.ts","../src/SplatAccumulator.ts","../src/shaders/splatDefines.glsl","../src/shaders/splatFragment.glsl","../src/shaders/splatVertex.glsl","../src/shaders.ts","../src/SparkRenderer.ts","../src/antisplat.ts","../src/ksplat.ts","../src/spz.ts","../src/SplatSkinning.ts","../src/splatConstructors.ts","../src/generators/static.ts","../src/generators/snow.ts","../src/modifiers/normalColor.ts","../src/modifiers/depthColor.ts","../src/vrButton.ts","../src/hands.ts","../src/controls.ts"],"sourcesContent":["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebGLRendeLine truncated
|
||||
Vendored
+36
-36
@@ -1,6 +1,6 @@
|
||||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const sA=require("three");var Ne=typeof document<"u"?document.currentScript:null;function To(t){const A=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(A,e,s.get?s:{enumerable:!0,get:()=>t[e]})}}return A.default=t,Object.freeze(A)}const I=To(sA),Uo=new sA.OrthographicCamera(-1,1,1,-1,0,1);class Go extends sA.BufferGeometry{constructor(){super(),this.setAttribute("position",new sA.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new sA.Float32BufferAttribute([0,2,0,0,2,0],2))}}const Ro=new Go;class Ss{constructor(A){this._mesh=new sA.Mesh(Ro,A)}dispose(){this._mesh.geometry.dispose()}render(A){A.render(this._mesh,Uo)}get material(){return this._mesh.material}set material(A){this._mesh.material=A}}var hA=Uint8Array,xt=Uint16Array,Yo=Int32Array,Ds=new hA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ms=new hA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Jo=new hA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),vs=function(t,A){for(var e=new xt(31),s=0;s<31;++s)e[s]=A+=1<<t[s-1];for(var n=new Yo(e[30]),s=1;s<30;++s)for(var i=e[s];i<e[s+1];++i)n[i]=i-e[s]<<5|s;return{b:e,r:n}},bs=vs(Ds,2),Fs=bs.b,_o=bs.r;Fs[28]=258,_o[258]=28;var Lo=vs(Ms,0),zo=Lo.b,Je=new xt(32768);for(var nA=0;nA<32768;++nA){var et=(nA&43690)>>1|(nA&21845)<<1;et=(et&52428)>>2|(et&13107)<<2,et=(et&61680)>>4|(et&3855)<<4,Je[nA]=((et&65280)>>8|(et&255)<<8)>>1}var Ht=function(t,A,e){for(var s=t.length,n=0,i=new xt(A);n<s;++n)t[n]&&++i[t[n]-1];var r=new xt(A);for(n=1;n<A;++n)r[n]=r[n-1]+i[n-1]<<1;var a;if(e){a=new xt(1<<A);var o=15-A;for(n=0;n<s;++n)if(t[n])for(var g=n<<4|t[n],l=A-t[n],c=r[t[n]-1]++<<l,u=c|(1<<l)-1;c<=u;++c)a[Je[c]>>o]=g}else for(a=new xt(s),n=0;n<s;++n)t[n]&&(a[n]=Je[r[t[n]-1]++]>>15-t[n]);return a},Ae=new hA(288);for(var nA=0;nA<144;++nA)Ae[nA]=8;for(var nA=144;nA<256;++nA)Ae[nA]=9;for(var nA=256;nA<280;++nA)Ae[nA]=7;for(var nA=280;nA<288;++nA)Ae[nA]=8;var Ns=new hA(32);for(var nA=0;nA<32;++nA)Ns[nA]=5;var Ho=Ht(Ae,9,1),qo=Ht(Ns,5,1),ke=function(t){for(var A=t[0],e=1;e<t.length;++e)t[e]>A&&(A=t[e]);return A},_A=function(t,A,e){var s=A/8|0;return(t[s]|t[s+1]<<8)>>(A&7)&e},Te=function(t,A){var e=A/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(A&7)},ks=function(t){return(t+7)/8|0},vt=function(t,A,e){return(A==null||A<0)&&(A=0),(e==null||e>t.length)&&(e=t.length),new hA(t.subarray(A,e))},Ko=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],mA=function(t,A,e){var s=new Error(A||Ko[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,mA),!e)throw s;return s},Ts=function(t,A,e,s){var n=t.length,i=s?s.length:0;if(!n||A.f&&!A.l)return e||new hA(0);var r=!e,a=r||A.i!=2,o=A.i;r&&(e=new hA(n*3));var g=function(wA){var SA=e.length;if(wA>SA){var BA=new hA(Math.max(SA*2,wA));BA.set(e),e=BA}},l=A.f||0,c=A.p||0,u=A.b||0,h=A.l,E=A.d,C=A.m,B=A.n,Q=n*8;do{if(!h){l=_A(t,c,1);var p=_A(t,c+1,3);if(c+=3,p)if(p==1)h=Ho,E=qo,C=9,B=5;else if(p==2){var D=_A(t,c,31)+257,x=_A(t,c+10,15)+4,y=D+_A(t,c+5,31)+1;c+=14;for(var m=new hA(y),k=new hA(19),M=0;M<x;++M)k[Jo[M]]=_A(t,c+M*3,7);c+=x*3;for(var S=ke(k),U=(1<<S)-1,F=Ht(k,S,1),M=0;M<y;){var b=F[_A(t,c,U)];c+=b&15;var f=b>>4;if(f<16)m[M++]=f;else{var T=0,R=0;for(f==16?(R=3+_A(t,c,3),c+=2,T=m[M-1]):f==17?(R=3+_A(t,c,7),c+=3):f==18&&(R=11+_A(t,c,127),c+=7);R--;)m[M++]=T}}var X=m.subarray(0,D),_=m.subarray(D);C=ke(X),B=ke(_),h=Ht(X,C,1),E=Ht(_,B,1)}else mA(1);else{var f=ks(c)+4,d=t[f-4]|t[f-3]<<8,w=f+d;if(w>n){o&&mA(0);break}a&&g(u+d),e.set(t.subarray(f,w),u),A.b=u+=d,A.p=c=w*8,A.f=l;continue}if(c>Q){o&&mA(0);break}}a&&g(u+131072);for(var eA=(1<<C)-1,q=(1<<B)-1,O=c;;O=c){var T=h[Te(t,c)&eA],L=T>>4;if(c+=T&15,c>Q){o&&mA(0);break}if(T||mA(2),L<256)e[u++]=L;else if(L==256){O=c,h=null;break}else{var j=L-254;if(L>264){var M=L-257,P=Ds[M];j=_A(t,c,(1<<P)-1)+Fs[M],c+=P}var W=E[Te(t,c)&q],G=W>>4;W||mA(3),c+=W&15;var _=zo[G];if(G>3){var P=Ms[G];_+=Te(t,c)&(1<<P)-1,c+=P}if(c>Q){o&&mA(0);break}a&&g(u+131072);var dA=u+j;if(u<_){var lA=i-_,yA=Math.min(_,dA);for(lA+u<0&&mA(3);u<yA;++u)e[u]=s[lA+u]}for(;u<dA;++u)e[u]=e[u-_]}}A.l=h,A.p=O,A.b=u,A.f=l,h&&(l=1,A.m=C,A.d=E,A.n=B)}while(!l);return u!=e.length&&r?vt(e,0,u):e.subarray(0,u)},$o=new hA(0),KA=function(t,A){return t[A]|t[A+1]<<8},LA=function(t,A){return(t[A]|t[A+1]<<8|t[A+2]<<16|t[A+3]<<24)>>>0},Ue=function(t,A){return LA(t,A)+LA(t,A+4)*4294967296},Vo=function(t){(t[0]!=31||t[1]!=139||t[2]!=8)&&mA(6,"invalid gzip data");var A=t[3],e=10;A&4&&(e+=(t[10]|t[11]<<8)+2);for(var s=(A>>3&1)+(A>>4&1);s>0;s-=!t[e++]);return e+(A&2)},Ge=function(){function t(A,e){typeof A=="function"&&(e=ALine truncated
|
||||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const sA=require("three");var Ne=typeof document<"u"?document.currentScript:null;function bo(t){const A=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(A,e,s.get?s:{enumerable:!0,get:()=>t[e]})}}return A.default=t,Object.freeze(A)}const I=bo(sA),Fo=new sA.OrthographicCamera(-1,1,1,-1,0,1);class No extends sA.BufferGeometry{constructor(){super(),this.setAttribute("position",new sA.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new sA.Float32BufferAttribute([0,2,0,0,2,0],2))}}const ko=new No;class ms{constructor(A){this._mesh=new sA.Mesh(ko,A)}dispose(){this._mesh.geometry.dispose()}render(A){A.render(this._mesh,Fo)}get material(){return this._mesh.material}set material(A){this._mesh.material=A}}var hA=Uint8Array,xt=Uint16Array,To=Int32Array,xs=new hA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ss=new hA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Uo=new hA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ds=function(t,A){for(var e=new xt(31),s=0;s<31;++s)e[s]=A+=1<<t[s-1];for(var n=new To(e[30]),s=1;s<30;++s)for(var i=e[s];i<e[s+1];++i)n[i]=i-e[s]<<5|s;return{b:e,r:n}},Ms=Ds(xs,2),vs=Ms.b,Go=Ms.r;vs[28]=258,Go[258]=28;var Ro=Ds(Ss,0),Yo=Ro.b,Je=new xt(32768);for(var nA=0;nA<32768;++nA){var tt=(nA&43690)>>1|(nA&21845)<<1;tt=(tt&52428)>>2|(tt&13107)<<2,tt=(tt&61680)>>4|(tt&3855)<<4,Je[nA]=((tt&65280)>>8|(tt&255)<<8)>>1}var Ht=function(t,A,e){for(var s=t.length,n=0,i=new xt(A);n<s;++n)t[n]&&++i[t[n]-1];var r=new xt(A);for(n=1;n<A;++n)r[n]=r[n-1]+i[n-1]<<1;var a;if(e){a=new xt(1<<A);var o=15-A;for(n=0;n<s;++n)if(t[n])for(var g=n<<4|t[n],l=A-t[n],c=r[t[n]-1]++<<l,u=c|(1<<l)-1;c<=u;++c)a[Je[c]>>o]=g}else for(a=new xt(s),n=0;n<s;++n)t[n]&&(a[n]=Je[r[t[n]-1]++]>>15-t[n]);return a},Ae=new hA(288);for(var nA=0;nA<144;++nA)Ae[nA]=8;for(var nA=144;nA<256;++nA)Ae[nA]=9;for(var nA=256;nA<280;++nA)Ae[nA]=7;for(var nA=280;nA<288;++nA)Ae[nA]=8;var bs=new hA(32);for(var nA=0;nA<32;++nA)bs[nA]=5;var Jo=Ht(Ae,9,1),_o=Ht(bs,5,1),ke=function(t){for(var A=t[0],e=1;e<t.length;++e)t[e]>A&&(A=t[e]);return A},_A=function(t,A,e){var s=A/8|0;return(t[s]|t[s+1]<<8)>>(A&7)&e},Te=function(t,A){var e=A/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(A&7)},Fs=function(t){return(t+7)/8|0},vt=function(t,A,e){return(A==null||A<0)&&(A=0),(e==null||e>t.length)&&(e=t.length),new hA(t.subarray(A,e))},Lo=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],mA=function(t,A,e){var s=new Error(A||Lo[t]);if(s.code=t,Error.captureStackTrace&&Error.captureStackTrace(s,mA),!e)throw s;return s},Ns=function(t,A,e,s){var n=t.length,i=s?s.length:0;if(!n||A.f&&!A.l)return e||new hA(0);var r=!e,a=r||A.i!=2,o=A.i;r&&(e=new hA(n*3));var g=function(wA){var SA=e.length;if(wA>SA){var BA=new hA(Math.max(SA*2,wA));BA.set(e),e=BA}},l=A.f||0,c=A.p||0,u=A.b||0,h=A.l,E=A.d,C=A.m,B=A.n,Q=n*8;do{if(!h){l=_A(t,c,1);var p=_A(t,c+1,3);if(c+=3,p)if(p==1)h=Jo,E=_o,C=9,B=5;else if(p==2){var D=_A(t,c,31)+257,x=_A(t,c+10,15)+4,y=D+_A(t,c+5,31)+1;c+=14;for(var m=new hA(y),k=new hA(19),M=0;M<x;++M)k[Uo[M]]=_A(t,c+M*3,7);c+=x*3;for(var S=ke(k),U=(1<<S)-1,F=Ht(k,S,1),M=0;M<y;){var b=F[_A(t,c,U)];c+=b&15;var f=b>>4;if(f<16)m[M++]=f;else{var T=0,R=0;for(f==16?(R=3+_A(t,c,3),c+=2,T=m[M-1]):f==17?(R=3+_A(t,c,7),c+=3):f==18&&(R=11+_A(t,c,127),c+=7);R--;)m[M++]=T}}var X=m.subarray(0,D),_=m.subarray(D);C=ke(X),B=ke(_),h=Ht(X,C,1),E=Ht(_,B,1)}else mA(1);else{var f=Fs(c)+4,d=t[f-4]|t[f-3]<<8,w=f+d;if(w>n){o&&mA(0);break}a&&g(u+d),e.set(t.subarray(f,w),u),A.b=u+=d,A.p=c=w*8,A.f=l;continue}if(c>Q){o&&mA(0);break}}a&&g(u+131072);for(var eA=(1<<C)-1,q=(1<<B)-1,O=c;;O=c){var T=h[Te(t,c)&eA],L=T>>4;if(c+=T&15,c>Q){o&&mA(0);break}if(T||mA(2),L<256)e[u++]=L;else if(L==256){O=c,h=null;break}else{var j=L-254;if(L>264){var M=L-257,P=xs[M];j=_A(t,c,(1<<P)-1)+vs[M],c+=P}var W=E[Te(t,c)&q],G=W>>4;W||mA(3),c+=W&15;var _=Yo[G];if(G>3){var P=Ss[G];_+=Te(t,c)&(1<<P)-1,c+=P}if(c>Q){o&&mA(0);break}a&&g(u+131072);var dA=u+j;if(u<_){var lA=i-_,yA=Math.min(_,dA);for(lA+u<0&&mA(3);u<yA;++u)e[u]=s[lA+u]}for(;u<dA;++u)e[u]=e[u-_]}}A.l=h,A.p=O,A.b=u,A.f=l,h&&(l=1,A.m=C,A.d=E,A.n=B)}while(!l);return u!=e.length&&r?vt(e,0,u):e.subarray(0,u)},zo=new hA(0),KA=function(t,A){return t[A]|t[A+1]<<8},LA=function(t,A){return(t[A]|t[A+1]<<8|t[A+2]<<16|t[A+3]<<24)>>>0},Ue=function(t,A){return LA(t,A)+LA(t,A+4)*4294967296},Ho=function(t){(t[0]!=31||t[1]!=139||t[2]!=8)&&mA(6,"invalid gzip data");var A=t[3],e=10;A&4&&(e+=(t[10]|t[11]<<8)+2);for(var s=(A>>3&1)+(A>>4&1);s>0;s-=!t[e++]);return e+(A&2)},Ge=function(){function t(A,e){typeof A=="function"&&(e=ALine truncated
|
||||
`).map(r=>{const a=r.trimEnd();return A?a:a.length>0?(A=!0,a):null}).filter(r=>r!=null);for(;e.length>0&&e[e.length-1].length===0;)e.pop();if(e.length===0)return[];const s=(i=e[0].match(/^\s*/))==null?void 0:i[0];if(!s)return e;const n=new RegExp(`^${s}`);return e.map(r=>r.replace(n,""))}function CA(t){return YA(t).join(`
|
||||
`)}class v extends V{constructor({a:A,outKey:e,outTypeFunc:s}){const n={a:$(A)},i=s($(A)),r={[e]:i};super({inTypes:n,outTypes:r,inputs:{a:A}}),this.outKey=e}dynoOut(){return new K(this,this.outKey)}}class tA extends V{constructor({a:A,b:e,outKey:s,outTypeFunc:n}){const i={a:$(A),b:$(e)},r=n($(A),$(e)),a={[s]:r};super({inTypes:i,outTypes:a,inputs:{a:A,b:e}}),this.outKey=s}dynoOut(){return new K(this,this.outKey)}}class wt extends V{constructor({a:A,b:e,c:s,outKey:n,outTypeFunc:i}){const r={a:$(A),b:$(e),c:$(s)},a=i($(A),$(e),$(s)),o={[n]:a};super({inTypes:r,outTypes:o,inputs:{a:A,b:e,c:s}}),this.outKey=n}dynoOut(){return new K(this,this.outKey)}}const AA={type:"Gsplat"},ne={type:"PackedSplats"},yc=t=>new Zs({packedSplats:t}),Ft=(t,A)=>new Os({packedSplats:t,index:A}),Ps=(t,A,e,s)=>new js({packedSplats:t,index:A,base:e,count:s}),Bt=t=>new Ws({gsplat:t}),at=({gsplat:t,flags:A,index:e,center:s,scales:n,quaternion:i,rgba:r,rgb:a,opacity:o,x:g,y:l,z:c,r:u,g:h,b:E})=>new An({gsplat:t,flags:A,index:e,center:s,scales:n,quaternion:i,rgba:r,rgb:a,opacity:o,x:g,y:l,z:c,r:u,g:h,b:E}),Le=t=>new en({gsplat:t}),es=(t,{scale:A,rotate:e,translate:s,recolor:n})=>new sn({gsplat:t,scale:A,rotate:e,translate:s,recolor:n}),NA=CA(`
|
||||
`)}class v extends V{constructor({a:A,outKey:e,outTypeFunc:s}){const n={a:$(A)},i=s($(A)),r={[e]:i};super({inTypes:n,outTypes:r,inputs:{a:A}}),this.outKey=e}dynoOut(){return new K(this,this.outKey)}}class tA extends V{constructor({a:A,b:e,outKey:s,outTypeFunc:n}){const i={a:$(A),b:$(e)},r=n($(A),$(e)),a={[s]:r};super({inTypes:i,outTypes:a,inputs:{a:A,b:e}}),this.outKey=s}dynoOut(){return new K(this,this.outKey)}}class wt extends V{constructor({a:A,b:e,c:s,outKey:n,outTypeFunc:i}){const r={a:$(A),b:$(e),c:$(s)},a=i($(A),$(e),$(s)),o={[n]:a};super({inTypes:r,outTypes:o,inputs:{a:A,b:e,c:s}}),this.outKey=n}dynoOut(){return new K(this,this.outKey)}}const AA={type:"Gsplat"},ne={type:"PackedSplats"},Qc=t=>new Vs({packedSplats:t}),Ft=(t,A)=>new Zs({packedSplats:t,index:A}),$s=(t,A,e,s)=>new Xs({packedSplats:t,index:A,base:e,count:s}),Bt=t=>new Os({gsplat:t}),rt=({gsplat:t,flags:A,index:e,center:s,scales:n,quaternion:i,rgba:r,rgb:a,opacity:o,x:g,y:l,z:c,r:u,g:h,b:E})=>new js({gsplat:t,flags:A,index:e,center:s,scales:n,quaternion:i,rgba:r,rgb:a,opacity:o,x:g,y:l,z:c,r:u,g:h,b:E}),Le=t=>new An({gsplat:t}),As=(t,{scale:A,rotate:e,translate:s,recolor:n})=>new tn({gsplat:t,scale:A,rotate:e,translate:s,recolor:n}),NA=CA(`
|
||||
struct Gsplat {
|
||||
vec3 center;
|
||||
uint flags;
|
||||
@@ -20,7 +20,7 @@
|
||||
int numSplats;
|
||||
vec4 rgbMinMaxLnScaleMinMax;
|
||||
};
|
||||
`);class Zs extends v{constructor({packedSplats:A}){super({a:A,outKey:"numSplats",outTypeFunc:()=>"int"}),this.statements=({inputs:e,outputs:s})=>[`${s.numSplats} = ${e.a}.numSplats;`]}}const Xs=CA(`
|
||||
`);class Vs extends v{constructor({packedSplats:A}){super({a:A,outKey:"numSplats",outTypeFunc:()=>"int"}),this.statements=({inputs:e,outputs:s})=>[`${s.numSplats} = ${e.a}.numSplats;`]}}const Ps=CA(`
|
||||
bool readPackedSplat(usampler2DArray texture, int numSplats, vec4 rgbMinMaxLnScaleMinMax, int index, out Gsplat gsplat) {
|
||||
if ((index >= 0) && (index < numSplats)) {
|
||||
uvec4 packed = texelFetch(texture, splatTexCoord(index), 0);
|
||||
@@ -30,14 +30,14 @@
|
||||
return false;
|
||||
}
|
||||
}
|
||||
`);class Os extends V{constructor({packedSplats:A,index:e}){super({inTypes:{packedSplats:ne,index:"int"},outTypes:{gsplat:AA},inputs:{packedSplats:A,index:e},globals:()=>[NA,ye,Xs],statements:({inputs:s,outputs:n})=>{const{gsplat:i}=n;if(!i)return[];const{packedSplats:r,index:a}=s;let o;return r&&a?o=YA(`
|
||||
`);class Zs extends V{constructor({packedSplats:A,index:e}){super({inTypes:{packedSplats:ne,index:"int"},outTypes:{gsplat:AA},inputs:{packedSplats:A,index:e},globals:()=>[NA,ye,Ps],statements:({inputs:s,outputs:n})=>{const{gsplat:i}=n;if(!i)return[];const{packedSplats:r,index:a}=s;let o;return r&&a?o=YA(`
|
||||
if (readPackedSplat(${r}.texture, ${r}.numSplats, ${r}.rgbMinMaxLnScaleMinMax, ${a}, ${i})) {
|
||||
bool zeroSize = all(equal(${i}.scales, vec3(0.0, 0.0, 0.0)));
|
||||
${i}.flags = zeroSize ? 0u : GSPLAT_FLAG_ACTIVE;
|
||||
} else {
|
||||
${i}.flags = 0u;
|
||||
}
|
||||
`):o=[`${i}.flags = 0u;`],o.push(`${i}.index = ${a??"0"};`),o}})}dynoOut(){return new K(this,"gsplat")}}class js extends V{constructor({packedSplats:A,index:e,base:s,count:n}){super({inTypes:{packedSplats:ne,index:"int",base:"int",count:"int"},outTypes:{gsplat:AA},inputs:{packedSplats:A,index:e,base:s,count:n},globals:()=>[NA,ye,Xs],statements:({inputs:i,outputs:r})=>{const{gsplat:a}=r;if(!a)return[];const{packedSplats:o,index:g,base:l,count:c}=i;let u;return o&&g&&l&&c?u=YA(`
|
||||
`):o=[`${i}.flags = 0u;`],o.push(`${i}.index = ${a??"0"};`),o}})}dynoOut(){return new K(this,"gsplat")}}class Xs extends V{constructor({packedSplats:A,index:e,base:s,count:n}){super({inTypes:{packedSplats:ne,index:"int",base:"int",count:"int"},outTypes:{gsplat:AA},inputs:{packedSplats:A,index:e,base:s,count:n},globals:()=>[NA,ye,Ps],statements:({inputs:i,outputs:r})=>{const{gsplat:a}=r;if(!a)return[];const{packedSplats:o,index:g,base:l,count:c}=i;let u;return o&&g&&l&&c?u=YA(`
|
||||
${a}.flags = 0u;
|
||||
if ((${g} >= ${l}) && (${g} < (${l} + ${c}))) {
|
||||
if (readPackedSplat(${o}.texture, ${o}.numSplats, ${o}.rgbMinMaxLnScaleMinMax, ${g}, ${a})) {
|
||||
@@ -45,7 +45,7 @@
|
||||
${a}.flags = zeroSize ? 0u : GSPLAT_FLAG_ACTIVE;
|
||||
}
|
||||
}
|
||||
`):u=[`${a}.flags = 0u;`],u.push(`${a}.index = ${g??"0"};`),u}})}dynoOut(){return new K(this,"gsplat")}}class Ws extends V{constructor({gsplat:A}){super({inTypes:{gsplat:AA},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:()=>[NA],statements:({inputs:e,outputs:s})=>{const{gsplat:n}=e,{flags:i,active:r,index:a,center:o,scales:g,quaternion:l,rgba:c,rgb:u,opacity:h,x:E,y:C,z:B,r:Q,g:p,b:f}=s;return[i?`${i} = ${n?`${n}.flags`:"0u"};`:null,r?`${r} = isGsplatActive(${n?`${n}.flags`:"0u"});`:null,a?`${a} = ${n?`${n}.index`:"0"};`:null,o?`${o} = ${n?`${n}.center`:"vec3(0.0, 0.0, 0.0)"};`:null,g?`${g} = ${n?`${n}.scales`:"vec3(0.0, 0.0, 0.0)"};`:null,l?`${l} = ${n?`${n}.quaternion`:"vec4(0.0, 0.0, 0.0, 1.0)"};`:null,c?`${c} = ${n?`${n}.rgba`:"vec4(0.0, 0.0, 0.0, 0.0)"};`:null,u?`${u} = ${n?`${n}.rgba.rgb`:"vec3(0.0, 0.0, 0.0)"};`:null,h?`${h} = ${n?`${n}.rgba.a`:"0.0"};`:null,E?`${E} = ${n?`${n}.center.x`:"0.0"};`:null,C?`${C} = ${n?`${n}.center.y`:"0.0"};`:null,B?`${B} = ${n?`${n}.center.z`:"0.0"};`:null,Q?`${Q} = ${n?`${n}.rgba.r`:"0.0"};`:null,p?`${p} = ${n?`${n}.rgba.g`:"0.0"};`:null,f?`${f} = ${n?`${n}.rgba.b`:"0.0"};`:null].filter(Boolean)}})}}class An extends V{constructor({gsplat:A,flags:e,index:s,center:n,scales:i,quaternion:r,rgba:a,rgb:o,opacity:g,x:l,y:c,z:u,r:h,g:E,b:C}){super({inTypes:{gsplat:AA,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:AA},inputs:{gsplat:A,flags:e,index:s,center:n,scales:i,quaternion:r,rgba:a,rgb:o,opacity:g,x:l,y:c,z:u,r:h,g:E,b:C},globals:()=>[NA],statements:({inputs:B,outputs:Q})=>{const{gsplat:p}=Q;if(!p)return[];const{gsplat:f,flags:d,index:w,center:D,scales:x,quaternion:y,rgba:m,rgb:k,opacity:M,x:S,y:U,z:F,r:b,g:T,b:R}=B;return[`${p}.flags = ${d??(f?`${f}.flags`:"0u")};`,`${p}.index = ${w??(f?`${f}.index`:"0")};`,`${p}.center = ${D??(f?`${f}.center`:"vec3(0.0, 0.0, 0.0)")};`,`${p}.scales = ${x??(f?`${f}.scales`:"vec3(0.0, 0.0, 0.0)")};`,`${p}.quaternion = ${y??(f?`${f}.quaternion`:"vec4(0.0, 0.0, 0.0, 1.0)")};`,`${p}.rgba = ${m??(f?`${f}.rgba`:"vec4(0.0, 0.0, 0.0, 0.0)")};`,k?`${p}.rgba.rgb = ${k};`:null,M?`${p}.rgba.a = ${M};`:null,S?`${p}.center.x = ${S};`:null,U?`${p}.center.y = ${U};`:null,F?`${p}.center.z = ${F};`:null,b?`${p}.rgba.r = ${b};`:null,T?`${p}.rgba.g = ${T};`:null,R?`${p}.rgba.b = ${R};`:null].filter(Boolean)}})}dynoOut(){return new K(this,"gsplat")}}const tn=CA(`
|
||||
`):u=[`${a}.flags = 0u;`],u.push(`${a}.index = ${g??"0"};`),u}})}dynoOut(){return new K(this,"gsplat")}}class Os extends V{constructor({gsplat:A}){super({inTypes:{gsplat:AA},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:()=>[NA],statements:({inputs:e,outputs:s})=>{const{gsplat:n}=e,{flags:i,active:r,index:a,center:o,scales:g,quaternion:l,rgba:c,rgb:u,opacity:h,x:E,y:C,z:B,r:Q,g:p,b:f}=s;return[i?`${i} = ${n?`${n}.flags`:"0u"};`:null,r?`${r} = isGsplatActive(${n?`${n}.flags`:"0u"});`:null,a?`${a} = ${n?`${n}.index`:"0"};`:null,o?`${o} = ${n?`${n}.center`:"vec3(0.0, 0.0, 0.0)"};`:null,g?`${g} = ${n?`${n}.scales`:"vec3(0.0, 0.0, 0.0)"};`:null,l?`${l} = ${n?`${n}.quaternion`:"vec4(0.0, 0.0, 0.0, 1.0)"};`:null,c?`${c} = ${n?`${n}.rgba`:"vec4(0.0, 0.0, 0.0, 0.0)"};`:null,u?`${u} = ${n?`${n}.rgba.rgb`:"vec3(0.0, 0.0, 0.0)"};`:null,h?`${h} = ${n?`${n}.rgba.a`:"0.0"};`:null,E?`${E} = ${n?`${n}.center.x`:"0.0"};`:null,C?`${C} = ${n?`${n}.center.y`:"0.0"};`:null,B?`${B} = ${n?`${n}.center.z`:"0.0"};`:null,Q?`${Q} = ${n?`${n}.rgba.r`:"0.0"};`:null,p?`${p} = ${n?`${n}.rgba.g`:"0.0"};`:null,f?`${f} = ${n?`${n}.rgba.b`:"0.0"};`:null].filter(Boolean)}})}}class js extends V{constructor({gsplat:A,flags:e,index:s,center:n,scales:i,quaternion:r,rgba:a,rgb:o,opacity:g,x:l,y:c,z:u,r:h,g:E,b:C}){super({inTypes:{gsplat:AA,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:AA},inputs:{gsplat:A,flags:e,index:s,center:n,scales:i,quaternion:r,rgba:a,rgb:o,opacity:g,x:l,y:c,z:u,r:h,g:E,b:C},globals:()=>[NA],statements:({inputs:B,outputs:Q})=>{const{gsplat:p}=Q;if(!p)return[];const{gsplat:f,flags:d,index:w,center:D,scales:x,quaternion:y,rgba:m,rgb:k,opacity:M,x:S,y:U,z:F,r:b,g:T,b:R}=B;return[`${p}.flags = ${d??(f?`${f}.flags`:"0u")};`,`${p}.index = ${w??(f?`${f}.index`:"0")};`,`${p}.center = ${D??(f?`${f}.center`:"vec3(0.0, 0.0, 0.0)")};`,`${p}.scales = ${x??(f?`${f}.scales`:"vec3(0.0, 0.0, 0.0)")};`,`${p}.quaternion = ${y??(f?`${f}.quaternion`:"vec4(0.0, 0.0, 0.0, 1.0)")};`,`${p}.rgba = ${m??(f?`${f}.rgba`:"vec4(0.0, 0.0, 0.0, 0.0)")};`,k?`${p}.rgba.rgb = ${k};`:null,M?`${p}.rgba.a = ${M};`:null,S?`${p}.center.x = ${S};`:null,U?`${p}.center.y = ${U};`:null,F?`${p}.center.z = ${F};`:null,b?`${p}.rgba.r = ${b};`:null,T?`${p}.rgba.g = ${T};`:null,R?`${p}.rgba.b = ${R};`:null].filter(Boolean)}})}dynoOut(){return new K(this,"gsplat")}}const Ws=CA(`
|
||||
vec3 gsplatNormal(vec3 scales, vec4 quaternion) {
|
||||
float minScale = min(scales.x, min(scales.y, scales.z));
|
||||
vec3 normal;
|
||||
@@ -58,13 +58,13 @@
|
||||
}
|
||||
return quatVec(quaternion, normal);
|
||||
}
|
||||
`);class en extends v{constructor({gsplat:A}){super({a:A,outKey:"normal",outTypeFunc:()=>"vec3"}),this.globals=()=>[NA,tn],this.statements=({inputs:e,outputs:s})=>[`${s.normal} = gsplatNormal(${e.a}.scales, ${e.a}.quaternion);`]}}class sn extends V{constructor({gsplat:A,scale:e,rotate:s,translate:n,recolor:i}){super({inTypes:{gsplat:AA,scale:"float",rotate:"vec4",translate:"vec3",recolor:"vec4"},outTypes:{gsplat:AA},inputs:{gsplat:A,scale:e,rotate:s,translate:n,recolor:i},globals:()=>[NA],statements:({inputs:r,outputs:a,compile:o})=>{const{gsplat:g}=a;if(!g||!r.gsplat)return[];const{scale:l,rotate:c,translate:u,recolor:h}=r,E=o.indent;return[`${g} = ${r.gsplat};`,`if (isGsplatActive(${g}.flags)) {`,l?`${E}${g}.center *= ${l};`:null,c?`${E}${g}.center = quatVec(${c}, ${g}.center);`:null,u?`${E}${g}.center += ${u};`:null,l?`${E}${g}.scales *= ${l};`:null,c?`${E}${g}.quaternion = quatQuat(${c}, ${g}.quaternion);`:null,h?`${E}${g}.rgba *= ${h};`:null,"}"].filter(Boolean)}})}dynoOut(){return new K(this,"gsplat")}}const nn=(t,A)=>new rn({gsplat:t,rgbMinMaxLnScaleMinMax:A}),wc=t=>new ss({rgba8:t});class rn extends V{constructor({gsplat:A,rgbMinMaxLnScaleMinMax:e}){super({inTypes:{gsplat:AA,rgbMinMaxLnScaleMinMax:"vec4"},inputs:{gsplat:A,rgbMinMaxLnScaleMinMax:e},globals:()=>[NA],statements:({inputs:s,outputs:n})=>{const{output:i}=n;if(!i)return[];const{gsplat:r,rgbMinMaxLnScaleMinMax:a}=s;return r?YA(`
|
||||
`);class An extends v{constructor({gsplat:A}){super({a:A,outKey:"normal",outTypeFunc:()=>"vec3"}),this.globals=()=>[NA,Ws],this.statements=({inputs:e,outputs:s})=>[`${s.normal} = gsplatNormal(${e.a}.scales, ${e.a}.quaternion);`]}}class tn extends V{constructor({gsplat:A,scale:e,rotate:s,translate:n,recolor:i}){super({inTypes:{gsplat:AA,scale:"float",rotate:"vec4",translate:"vec3",recolor:"vec4"},outTypes:{gsplat:AA},inputs:{gsplat:A,scale:e,rotate:s,translate:n,recolor:i},globals:()=>[NA],statements:({inputs:r,outputs:a,compile:o})=>{const{gsplat:g}=a;if(!g||!r.gsplat)return[];const{scale:l,rotate:c,translate:u,recolor:h}=r,E=o.indent;return[`${g} = ${r.gsplat};`,`if (isGsplatActive(${g}.flags)) {`,l?`${E}${g}.center *= ${l};`:null,c?`${E}${g}.center = quatVec(${c}, ${g}.center);`:null,u?`${E}${g}.center += ${u};`:null,l?`${E}${g}.scales *= ${l};`:null,c?`${E}${g}.quaternion = quatQuat(${c}, ${g}.quaternion);`:null,h?`${E}${g}.rgba *= ${h};`:null,"}"].filter(Boolean)}})}dynoOut(){return new K(this,"gsplat")}}const en=(t,A)=>new sn({gsplat:t,rgbMinMaxLnScaleMinMax:A}),pc=t=>new ts({rgba8:t});class sn extends V{constructor({gsplat:A,rgbMinMaxLnScaleMinMax:e}){super({inTypes:{gsplat:AA,rgbMinMaxLnScaleMinMax:"vec4"},inputs:{gsplat:A,rgbMinMaxLnScaleMinMax:e},globals:()=>[NA],statements:({inputs:s,outputs:n})=>{const{output:i}=n;if(!i)return[];const{gsplat:r,rgbMinMaxLnScaleMinMax:a}=s;return r?YA(`
|
||||
if (isGsplatActive(${r}.flags)) {
|
||||
${i} = packSplatEncoding(${r}.center, ${r}.scales, ${r}.quaternion, ${r}.rgba, ${a});
|
||||
} else {
|
||||
${i} = uvec4(0u, 0u, 0u, 0u);
|
||||
}
|
||||
`):[`${i} = uvec4(0u, 0u, 0u, 0u);`]}})}dynoOut(){return new K(this,"output")}}class ss extends V{constructor({rgba8:A}){super({inTypes:{rgba8:"vec4"},inputs:{rgba8:A},statements:({inputs:e,outputs:s})=>[`target = ${e.rgba8??"vec4(0.0, 0.0, 0.0, 0.0)"};`]})}dynoOut(){return new K(this,"rgba8")}}const mc=(t,A,e)=>new N({key:t,type:A,value:e}),xc=(t=!1,A)=>new he({key:A,value:t}),Sc=(t=0,A)=>new an({key:A,value:t}),Dc=(t=0,A)=>new Pt({key:A,value:t}),qA=(t=0,A)=>new Et({key:A,value:t}),Mc=(t,A)=>new on({key:A,value:t}),vc=(t,A)=>new cn({key:A,value:t}),bc=(t,A)=>new gn({key:A,value:t}),Fc=(t,A)=>new qt({key:A,value:t}),Nc=(t,A)=>new ln({key:A,value:t}),kc=(t,A)=>new In({key:A,value:t}),Tc=(t,A)=>new un({key:A,value:t}),st=(t,A)=>new Nt({key:A,value:t}),Uc=(t,A)=>new hn({key:A,value:t}),Gc=(t,A)=>new Cn({key:A,value:t}),Rc=(t,A)=>new Bn({key:A,value:t}),Yc=(t,A)=>new Gt({key:A,value:t}),Jc=(t,A)=>new En({key:A,value:t}),_c=(t,A)=>new Qn({key:A,value:t}),Lc=(t,A)=>new pn({key:A,value:t}),zc=(t,A)=>new fn({key:A,value:t}),Hc=(t,A)=>new dn({key:A,value:t}),qc=(t,A)=>new yn({key:A,value:t}),Kc=(t,A)=>new wn({key:A,value:t}),$c=(t,A)=>new mn({key:A,value:t}),Vc=(t,A)=>new xn({key:A,value:t}),Pc=(t,A)=>new Sn({key:A,value:t}),Zc=(t,A)=>new Dn({key:A,value:t}),Xc=(t,A)=>new Mn({key:A,value:t}),Oc=(t,A)=>new vn({key:A,value:t}),jc=(t,A)=>new bn({key:A,value:t}),Wc=(t,A)=>new Fn({key:A,value:t}),Ag=(t,A)=>new Kt({key:A,value:t}),tg=(t,A)=>new Nn({key:t,value:A}),eg=(t,A)=>new kn({key:A,value:t}),sg=(t,A)=>new Tn({key:A,value:t}),ng=(t,A)=>new Un({key:A,value:t}),ig=(t,A)=>new Gn({key:A,value:t}),rg=(t,A)=>new Rn({key:A,value:t}),ag=(t,A)=>new Yn({key:A,value:t}),og=(t,A)=>new Jn({key:A,value:t}),cg=(t,A)=>new _n({key:A,value:t}),gg=(t,A)=>new Ln({key:A,value:t}),lg=(t,A)=>new zn({key:A,value:t});class N extends V{constructor({key:A,type:e,count:s,value:n,update:i,globals:r}){A=A??"value",super({outTypes:{[A]:e},update:()=>{if(i){const a=i(this.value);a!==void 0&&(this.value=a)}this.uniform.value=this.value},generate:({inputs:a,outputs:o})=>{const g=(r==null?void 0:r({inputs:a,outputs:o}))??[],l={},c=o[A];return c&&(g.push(`uniform ${ts(c,e,s)};`),l[c]=this.uniform),{globals:g,uniforms:l}}}),this.type=e,this.count=s,this.value=n,this.uniform={value:n},this.outKey=A}dynoOut(){return new K(this,this.outKey)}}class he extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"bool",value:e,update:s})}}class an extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"uint",value:e,update:s})}}class Pt extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"int",value:e,update:s})}}class Et extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"float",value:e,update:s})}}class on extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"bvec2",value:e,update:s})}}class cn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"uvec2",value:e,update:s})}}class gn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"ivec2",value:e,update:s})}}class qt extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"vec2",value:e,update:s})}}class ln extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"bvec3",value:e,update:s})}}class In extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"uvec3",value:e,update:s})}}class un extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"ivec3",value:e,update:s})}}class Nt extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"vec3",value:e,update:s})}}class hn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"bvec4",value:e,update:s})}}class Cn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"uvec4",value:e,update:s})}}class Bn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"ivec4",value:e,update:s})}}class Gt extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"vec4",value:e,update:s})}}class En extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat2",value:e,update:s})}}class Qn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat2x2",value:e,update:s})}}class pn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat2x3",value:e,update:s})}}class fn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat2x4",value:e,update:s})}}class dn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat3",value:e,update:s})}}class yn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat3x2",value:e,update:s})}}class wn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat3x3",value:e,update:s})}}class mn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat3x4",value:e,update:s})}}class xn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat4",value:e,update:s})}}class Sn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat4x2"
Line truncated
|
||||
`):[`${i} = uvec4(0u, 0u, 0u, 0u);`]}})}dynoOut(){return new K(this,"output")}}class ts extends V{constructor({rgba8:A}){super({inTypes:{rgba8:"vec4"},inputs:{rgba8:A},statements:({inputs:e,outputs:s})=>[`target = ${e.rgba8??"vec4(0.0, 0.0, 0.0, 0.0)"};`]})}dynoOut(){return new K(this,"rgba8")}}const fc=(t,A,e)=>new N({key:t,type:A,value:e}),dc=(t=!1,A)=>new he({key:A,value:t}),yc=(t=0,A)=>new nn({key:A,value:t}),wc=(t=0,A)=>new Pt({key:A,value:t}),qA=(t=0,A)=>new Et({key:A,value:t}),mc=(t,A)=>new rn({key:A,value:t}),xc=(t,A)=>new an({key:A,value:t}),Sc=(t,A)=>new on({key:A,value:t}),Dc=(t,A)=>new qt({key:A,value:t}),Mc=(t,A)=>new cn({key:A,value:t}),vc=(t,A)=>new gn({key:A,value:t}),bc=(t,A)=>new ln({key:A,value:t}),et=(t,A)=>new Nt({key:A,value:t}),Fc=(t,A)=>new In({key:A,value:t}),Nc=(t,A)=>new un({key:A,value:t}),kc=(t,A)=>new hn({key:A,value:t}),Tc=(t,A)=>new Gt({key:A,value:t}),Uc=(t,A)=>new Cn({key:A,value:t}),Gc=(t,A)=>new Bn({key:A,value:t}),Rc=(t,A)=>new En({key:A,value:t}),Yc=(t,A)=>new Qn({key:A,value:t}),Jc=(t,A)=>new pn({key:A,value:t}),_c=(t,A)=>new fn({key:A,value:t}),Lc=(t,A)=>new dn({key:A,value:t}),zc=(t,A)=>new yn({key:A,value:t}),Hc=(t,A)=>new wn({key:A,value:t}),qc=(t,A)=>new mn({key:A,value:t}),Kc=(t,A)=>new xn({key:A,value:t}),$c=(t,A)=>new Sn({key:A,value:t}),Vc=(t,A)=>new Dn({key:A,value:t}),Pc=(t,A)=>new Mn({key:A,value:t}),Zc=(t,A)=>new vn({key:A,value:t}),Xc=(t,A)=>new Kt({key:A,value:t}),Oc=(t,A)=>new bn({key:t,value:A}),jc=(t,A)=>new Fn({key:A,value:t}),Wc=(t,A)=>new Nn({key:A,value:t}),Ag=(t,A)=>new kn({key:A,value:t}),tg=(t,A)=>new Tn({key:A,value:t}),eg=(t,A)=>new Un({key:A,value:t}),sg=(t,A)=>new Gn({key:A,value:t}),ng=(t,A)=>new Rn({key:A,value:t}),ig=(t,A)=>new Yn({key:A,value:t}),rg=(t,A)=>new Jn({key:A,value:t}),ag=(t,A)=>new _n({key:A,value:t});class N extends V{constructor({key:A,type:e,count:s,value:n,update:i,globals:r}){A=A??"value",super({outTypes:{[A]:e},update:()=>{if(i){const a=i(this.value);a!==void 0&&(this.value=a)}this.uniform.value=this.value},generate:({inputs:a,outputs:o})=>{const g=(r==null?void 0:r({inputs:a,outputs:o}))??[],l={},c=o[A];return c&&(g.push(`uniform ${We(c,e,s)};`),l[c]=this.uniform),{globals:g,uniforms:l}}}),this.type=e,this.count=s,this.value=n,this.uniform={value:n},this.outKey=A}dynoOut(){return new K(this,this.outKey)}}class he extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"bool",value:e,update:s})}}class nn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"uint",value:e,update:s})}}class Pt extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"int",value:e,update:s})}}class Et extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"float",value:e,update:s})}}class rn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"bvec2",value:e,update:s})}}class an extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"uvec2",value:e,update:s})}}class on extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"ivec2",value:e,update:s})}}class qt extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"vec2",value:e,update:s})}}class cn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"bvec3",value:e,update:s})}}class gn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"uvec3",value:e,update:s})}}class ln extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"ivec3",value:e,update:s})}}class Nt extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"vec3",value:e,update:s})}}class In extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"bvec4",value:e,update:s})}}class un extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"uvec4",value:e,update:s})}}class hn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"ivec4",value:e,update:s})}}class Gt extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"vec4",value:e,update:s})}}class Cn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat2",value:e,update:s})}}class Bn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat2x2",value:e,update:s})}}class En extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat2x3",value:e,update:s})}}class Qn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat2x4",value:e,update:s})}}class pn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat3",value:e,update:s})}}class fn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat3x2",value:e,update:s})}}class dn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat3x3",value:e,update:s})}}class yn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat3x4",value:e,update:s})}}class wn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat4",value:e,update:s})}}class mn extends N{constructor({key:A,value:e,update:s}){super({key:A,type:"mat4x2"
Line truncated
|
||||
precision highp float;
|
||||
|
||||
in vec3 position;
|
||||
@@ -72,10 +72,10 @@
|
||||
void main() {
|
||||
gl_Position = vec4(position.xy, 0.0, 1.0);
|
||||
}
|
||||
`);function Ai(t){const A=new I.Vector3;for(const e of t)A.add(e);return A.divideScalar(t.length)}function ti(t){if(t.length===0)return new I.Quaternion;const A=t[0].clone();for(let e=1;e<t.length;e++)t[e].dot(t[0])<0?(A.x-=t[e].x,A.y-=t[e].y,A.z-=t[e].z,A.w-=t[e].w):(A.x+=t[e].x,A.y+=t[e].y,A.z+=t[e].z,A.w+=t[e].w);return A.normalize()}function ei(t,A){const e=new I.Vector3(0,0,0).applyMatrix4(t),s=new I.Vector3(0,0,0).applyMatrix4(A),n=new I.Vector3(0,0,-1).applyMatrix4(t).sub(e).normalize(),i=new I.Vector3(0,0,-1).applyMatrix4(A).sub(s).normalize(),r=e.distanceTo(s),a=n.dot(i);return{distance:r,coincidence:a}}function Ng({matrix1:t,matrix2:A,maxDistance:e}){const s=new I.Vector3(0,0,0).applyMatrix4(t),n=new I.Vector3(0,0,0).applyMatrix4(A);return s.distanceTo(n)<=e}function kg({matrix1:t,matrix2:A,maxDistance:e,minCoincidence:s}){const{distance:n,coincidence:i}=ei(t,A);return n<=e&&(s==null||i>=s)}function si(t,A){const[e,s]=[new I.Vector3,new I.Quaternion],[n,i]=[new I.Vector3,new I.Quaternion];t.decompose(e,s,new I.Vector3),A.decompose(n,i,new I.Vector3);const r=e.distanceTo(n),a=Math.abs(s.dot(i));return{distance:r,coorient:a}}function Ee({matrix1:t,matrix2:A,maxDistance:e,minCoorient:s}){const{distance:n,coorient:i}=si(t,A);return n<=e&&(s==null||i>=s)}function Tg(t,A=.001){return Math.abs(t)<A?0:Math.sign(t)}function Ug(t){const A=t.w<0,e=$t(A?-t.x:t.x),s=$t(A?-t.y:t.y),n=$t(A?-t.z:t.z),i=e&255,r=s&255,a=n&255;return i|r<<8|a<<16}function Gg(t,A){const e=t<<24>>24,s=t<<16>>24,n=t<<8>>24;A.set(e/127,s/127,n/127,0);const i=A.x*A.x+A.y*A.y+A.z*A.z;return A.w=Math.sqrt(Math.max(0,1-i)),A}const Rg=new I.Quaternion,ze=new I.Vector3;function ns(t){const A=Rg.copy(t).normalize();A.w<0&&A.set(-A.x,-A.y,-A.z,-A.w);const e=2*Math.acos(A.w),s=Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z),n=s<1e-6?ze.set(1,0,0):ze.set(A.x,A.y,A.z).divideScalar(s),i=Math.abs(n.x)+Math.abs(n.y)+Math.abs(n.z);let r=n.x/i,a=n.y/i;if(n.z<0){const h=r;r=(1-Math.abs(a))*(r>=0?1:-1),a=(1-Math.abs(h))*(a>=0?1:-1)}const o=r*.5+.5,g=a*.5+.5,l=Math.round(o*255),c=Math.round(g*255);return Math.round(e*(255/Math.PI))<<16|c<<8|l}function ni(t,A){const e=t&255,s=t>>>8&255,n=t>>>16&255,i=e/255,r=s/255;let a=(i-.5)*2,o=(r-.5)*2;const g=1-(Math.abs(a)+Math.abs(o)),l=Math.max(-g,0);a+=a>=0?-l:l,o+=o>=0?-l:l;const c=ze.set(a,o,g).normalize(),h=n/255*Math.PI*.5,E=Math.sin(h),C=Math.cos(h);return A.set(c.x*E,c.y*E,c.z*E,C),A}function Yg(t){const A=t.clone().normalize(),e=2*(A.w*A.x+A.y*A.z),s=1-2*(A.x*A.x+A.y*A.y),n=Math.atan2(e,s),i=2*(A.w*A.y-A.z*A.x),r=Math.abs(i)>=1?Math.sign(i)*(Math.PI/2):Math.asin(i),a=2*(A.w*A.z+A.x*A.y),o=1-2*(A.y*A.y+A.z*A.z),g=Math.atan2(a,o),l=(n+Math.PI)/(2*Math.PI),c=(r+Math.PI)/(2*Math.PI),u=(g+Math.PI)/(2*Math.PI),h=Math.round(l*255),E=Math.round(c*255);return Math.round(u*255)<<16|E<<8|h}function Jg(t,A){const e=t&255,s=t>>>8&255,n=t>>>16&255,i=e/255,r=s/255,a=n/255,o=i*(2*Math.PI)-Math.PI,g=r*(2*Math.PI)-Math.PI,l=a*(2*Math.PI)-Math.PI,c=Math.cos(o*.5),u=Math.sin(o*.5),h=Math.cos(g*.5),E=Math.sin(g*.5),C=Math.cos(l*.5),B=Math.sin(l*.5);return A.w=c*h*C+u*E*B,A.x=u*h*C-c*E*B,A.y=c*E*C+u*h*B,A.z=c*h*B-u*E*C,A.normalize(),A}function ae(t,A,e,s){const n=Math.max(-127,Math.min(127,t*127)),i=Math.max(-127,Math.min(127,A*127)),r=Math.max(-127,Math.min(127,e*127)),a=Math.max(-127,Math.min(127,s*127));return n&255|(i&255)<<8|(r&255)<<16|(a&255)<<24}function _g(t,A,e,s){const n=(s==null?void 0:s.sh1Min)??-1,i=(s==null?void 0:s.sh1Max)??1,r=.5*(n+i),a=126/(i-n),o=A*2;for(let g=0;g<9;++g){const l=(e[g]-r)*a,c=Math.round(Math.max(-63,Math.min(63,l)))&127,u=g*7,h=u+7,E=Math.floor(u/32),C=u-E*32,B=c<<C&4294967295;if(t[o+E]|=B,h>E*32+32){const Q=c>>>32-C&4294967295;t[o+E+1]|=Q}}}function Lg(t,A,e,s){const n=(s==null?void 0:s.sh2Min)??-1,i=(s==null?void 0:s.sh2Max)??1,r=.5*(n+i),a=2/(i-n);t[A*4+0]=ae((e[0]-r)*a,(e[1]-r)*a,(e[2]-r)*a,(e[3]-r)*a),t[A*4+1]=ae((e[4]-r)*a,(e[5]-r)*a,(e[6]-r)*a,(e[7]-r)*a),t[A*4+2]=ae((e[8]-r)*a,(e[9]-r)*a,(e[10]-r)*a,(e[11]-r)*a),t[A*4+3]=ae((e[12]-r)*a,(e[13]-r)*a,(e[14]-r)*a,0)}function zg(t,A,e,s){const n=(s==null?void 0:s.sh3Min)??-1,i=(s==null?void 0:s.sh3Max)??1,r=.5*(n+i),a=62/(i-n),o=A*4;for(let g=0;g<21;++g){const l=(e[g]-r)*a,c=Math.round(Math.max(-31,Math.min(31,l)))&63,u=g*6,h=u+6,E=Math.floor(u/32),C=u-E*32,B=c<<C&4294967295;if(t[o+E]|=B,h>E*32+32){const Q=c>>>32-C&4294967295;t[o+E+1]|=Q}}}function ii(t,A){const e=[];let s=0,n=null;const i=new Us((o,g)=>{if(e.push(o),s+=o.length,g||s>=A){const l=new Uint8Array(s);let c=0;for(const u of e)l.set(u,c),c+=u.length;n=l.slice(0,A)}}),r=1024;let a=0;for(;n==null&&a<t.length;){const o=t.slice(a,a+r);i.push(o,!1),a+=r}if(n==null&&(i.push(new Uint8Array,!0),n==null))throw new Error("Failed to decompress partial gzip");return n}class ri{constructor({fileBytes:A,chunkBytes:e=64*1024}){this.fileBytes=A,this.chunkBytes=e,this.offset=0,this.chunks=[],this.totalBytes=0,this.gunzip=new Us((s,n)=>{this.chunks.push(s),this.totalBytes+=s.length})}read(A){for(;this.totalBy
Line truncated
|
||||
`);function jn(t){const A=new I.Vector3;for(const e of t)A.add(e);return A.divideScalar(t.length)}function Wn(t){if(t.length===0)return new I.Quaternion;const A=t[0].clone();for(let e=1;e<t.length;e++)t[e].dot(t[0])<0?(A.x-=t[e].x,A.y-=t[e].y,A.z-=t[e].z,A.w-=t[e].w):(A.x+=t[e].x,A.y+=t[e].y,A.z+=t[e].z,A.w+=t[e].w);return A.normalize()}function Ai(t,A){const e=new I.Vector3(0,0,0).applyMatrix4(t),s=new I.Vector3(0,0,0).applyMatrix4(A),n=new I.Vector3(0,0,-1).applyMatrix4(t).sub(e).normalize(),i=new I.Vector3(0,0,-1).applyMatrix4(A).sub(s).normalize(),r=e.distanceTo(s),a=n.dot(i);return{distance:r,coincidence:a}}function Mg({matrix1:t,matrix2:A,maxDistance:e}){const s=new I.Vector3(0,0,0).applyMatrix4(t),n=new I.Vector3(0,0,0).applyMatrix4(A);return s.distanceTo(n)<=e}function vg({matrix1:t,matrix2:A,maxDistance:e,minCoincidence:s}){const{distance:n,coincidence:i}=Ai(t,A);return n<=e&&(s==null||i>=s)}function ti(t,A){const[e,s]=[new I.Vector3,new I.Quaternion],[n,i]=[new I.Vector3,new I.Quaternion];t.decompose(e,s,new I.Vector3),A.decompose(n,i,new I.Vector3);const r=e.distanceTo(n),a=Math.abs(s.dot(i));return{distance:r,coorient:a}}function Ee({matrix1:t,matrix2:A,maxDistance:e,minCoorient:s}){const{distance:n,coorient:i}=ti(t,A);return n<=e&&(s==null||i>=s)}function bg(t,A=.001){return Math.abs(t)<A?0:Math.sign(t)}function Fg(t){const A=t.w<0,e=$t(A?-t.x:t.x),s=$t(A?-t.y:t.y),n=$t(A?-t.z:t.z),i=e&255,r=s&255,a=n&255;return i|r<<8|a<<16}function Ng(t,A){const e=t<<24>>24,s=t<<16>>24,n=t<<8>>24;A.set(e/127,s/127,n/127,0);const i=A.x*A.x+A.y*A.y+A.z*A.z;return A.w=Math.sqrt(Math.max(0,1-i)),A}const kg=new I.Quaternion,ze=new I.Vector3;function es(t){const A=kg.copy(t).normalize();A.w<0&&A.set(-A.x,-A.y,-A.z,-A.w);const e=2*Math.acos(A.w),s=Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z),n=s<1e-6?ze.set(1,0,0):ze.set(A.x,A.y,A.z).divideScalar(s),i=Math.abs(n.x)+Math.abs(n.y)+Math.abs(n.z);let r=n.x/i,a=n.y/i;if(n.z<0){const h=r;r=(1-Math.abs(a))*(r>=0?1:-1),a=(1-Math.abs(h))*(a>=0?1:-1)}const o=r*.5+.5,g=a*.5+.5,l=Math.round(o*255),c=Math.round(g*255);return Math.round(e*(255/Math.PI))<<16|c<<8|l}function ei(t,A){const e=t&255,s=t>>>8&255,n=t>>>16&255,i=e/255,r=s/255;let a=(i-.5)*2,o=(r-.5)*2;const g=1-(Math.abs(a)+Math.abs(o)),l=Math.max(-g,0);a+=a>=0?-l:l,o+=o>=0?-l:l;const c=ze.set(a,o,g).normalize(),h=n/255*Math.PI*.5,E=Math.sin(h),C=Math.cos(h);return A.set(c.x*E,c.y*E,c.z*E,C),A}function Tg(t){const A=t.clone().normalize(),e=2*(A.w*A.x+A.y*A.z),s=1-2*(A.x*A.x+A.y*A.y),n=Math.atan2(e,s),i=2*(A.w*A.y-A.z*A.x),r=Math.abs(i)>=1?Math.sign(i)*(Math.PI/2):Math.asin(i),a=2*(A.w*A.z+A.x*A.y),o=1-2*(A.y*A.y+A.z*A.z),g=Math.atan2(a,o),l=(n+Math.PI)/(2*Math.PI),c=(r+Math.PI)/(2*Math.PI),u=(g+Math.PI)/(2*Math.PI),h=Math.round(l*255),E=Math.round(c*255);return Math.round(u*255)<<16|E<<8|h}function Ug(t,A){const e=t&255,s=t>>>8&255,n=t>>>16&255,i=e/255,r=s/255,a=n/255,o=i*(2*Math.PI)-Math.PI,g=r*(2*Math.PI)-Math.PI,l=a*(2*Math.PI)-Math.PI,c=Math.cos(o*.5),u=Math.sin(o*.5),h=Math.cos(g*.5),E=Math.sin(g*.5),C=Math.cos(l*.5),B=Math.sin(l*.5);return A.w=c*h*C+u*E*B,A.x=u*h*C-c*E*B,A.y=c*E*C+u*h*B,A.z=c*h*B-u*E*C,A.normalize(),A}function ae(t,A,e,s){const n=Math.max(-127,Math.min(127,t*127)),i=Math.max(-127,Math.min(127,A*127)),r=Math.max(-127,Math.min(127,e*127)),a=Math.max(-127,Math.min(127,s*127));return n&255|(i&255)<<8|(r&255)<<16|(a&255)<<24}function Gg(t,A,e,s){const n=(s==null?void 0:s.sh1Min)??-1,i=(s==null?void 0:s.sh1Max)??1,r=.5*(n+i),a=126/(i-n),o=A*2;for(let g=0;g<9;++g){const l=(e[g]-r)*a,c=Math.round(Math.max(-63,Math.min(63,l)))&127,u=g*7,h=u+7,E=Math.floor(u/32),C=u-E*32,B=c<<C&4294967295;if(t[o+E]|=B,h>E*32+32){const Q=c>>>32-C&4294967295;t[o+E+1]|=Q}}}function Rg(t,A,e,s){const n=(s==null?void 0:s.sh2Min)??-1,i=(s==null?void 0:s.sh2Max)??1,r=.5*(n+i),a=2/(i-n);t[A*4+0]=ae((e[0]-r)*a,(e[1]-r)*a,(e[2]-r)*a,(e[3]-r)*a),t[A*4+1]=ae((e[4]-r)*a,(e[5]-r)*a,(e[6]-r)*a,(e[7]-r)*a),t[A*4+2]=ae((e[8]-r)*a,(e[9]-r)*a,(e[10]-r)*a,(e[11]-r)*a),t[A*4+3]=ae((e[12]-r)*a,(e[13]-r)*a,(e[14]-r)*a,0)}function Yg(t,A,e,s){const n=(s==null?void 0:s.sh3Min)??-1,i=(s==null?void 0:s.sh3Max)??1,r=.5*(n+i),a=62/(i-n),o=A*4;for(let g=0;g<21;++g){const l=(e[g]-r)*a,c=Math.round(Math.max(-31,Math.min(31,l)))&63,u=g*6,h=u+6,E=Math.floor(u/32),C=u-E*32,B=c<<C&4294967295;if(t[o+E]|=B,h>E*32+32){const Q=c>>>32-C&4294967295;t[o+E+1]|=Q}}}function si(t,A){const e=[];let s=0,n=null;const i=new ks((o,g)=>{if(e.push(o),s+=o.length,g||s>=A){const l=new Uint8Array(s);let c=0;for(const u of e)l.set(u,c),c+=u.length;n=l.slice(0,A)}}),r=1024;let a=0;for(;n==null&&a<t.length;){const o=t.slice(a,a+r);i.push(o,!1),a+=r}if(n==null&&(i.push(new Uint8Array,!0),n==null))throw new Error("Failed to decompress partial gzip");return n}class ni{constructor({fileBytes:A,chunkBytes:e=64*1024}){this.fileBytes=A,this.chunkBytes=e,this.offset=0,this.chunks=[],this.totalBytes=0,this.gunzip=new ks((s,n)=>{this.chunks.push(s),this.totalBytes+=s.length})}read(A){for(;this.totalBy
Line truncated
|
||||
|
||||
`)+this.between+e.map(s=>this.indent+s).join(`
|
||||
`)+this.after}}const Qs=new Map;function qg(t){let A=Qs.get(t);return A||(A=new I.RawShaderMaterial({glslVersion:I.GLSL3,vertexShader:Wn,fragmentShader:t.shader,uniforms:t.uniforms}),Qs.set(t,A),A)}function as(t,A,e="add"){const s=()=>{throw new Error(`Invalid ${e} types: ${t}, ${A}`)};if(t===A)return t;if(t==="int"){if(QA(A))return A;s()}if(A==="int"){if(QA(t))return t;s()}if(t==="uint"){if(pA(A))return A;s()}if(A==="uint"){if(pA(t))return t;s()}if(t==="float"){if(ct(A))return A;s()}if(A==="float"){if(ct(t))return t;s()}throw new Error(`Invalid ${e} types: ${t}, ${A}`)}function Kg(t,A){return as(t,A,"sub")}function $g(t,A){const e=()=>{throw new Error(`Invalid mul types: ${t}, ${A}`)},s=n=>n;if(t==="int"){if(QA(A))return s(A);e()}if(A==="int"){if(QA(t))return s(t);e()}if(t==="uint"){if(pA(A))return s(A);e()}if(A==="uint"){if(pA(t))return s(t);e()}if(t==="float"){if(ct(A))return s(A);e()}if(A==="float"){if(ct(t))return s(t);e()}if(QA(t)||pA(t)||QA(A)||pA(A)){if(t===A)return s(t);e()}if(t==="vec2"){if(A==="vec2"||gt(A))return s("vec2");if(A==="mat3x2")return s("vec3");if(A==="mat4x2")return s("vec4");e()}if(t==="vec3"){if(A==="mat2x3")return s("vec2");if(A==="vec3"||lt(A))return s("vec3");if(A==="mat4x3")return s("vec4");e()}if(t==="vec4"){if(A==="mat2x4")return s("vec2");if(A==="mat3x4")return s("vec3");if(A==="vec4"||It(A))return s("vec4");e()}if(A==="vec2"){if(gt(t))return s("vec2");if(t==="mat2x3")return s("vec3");if(t==="mat2x4")return s("vec4");e()}if(A==="vec3"){if(t==="mat3x2")return s("vec2");if(lt(t))return s("vec3");if(t==="mat3x4")return s("vec4");e()}if(A==="vec4"){if(t==="mat4x2")return s("vec2");if(t==="mat4x3")return s("vec3");if(It(t))return s("vec4");e()}if(gt(t)){if(gt(A))return s("mat2");if(A==="mat3x2")return s("mat3x2");if(A==="mat4x2")return s("mat4x2");e()}if(t==="mat2x3"){if(gt(A))return s("mat2x3");if(A==="mat3x2")return s("mat3");if(A==="mat4x2")return s("mat4x3");e()}if(t==="mat2x4"){if(gt(A))return s("mat2x4");if(A==="mat3x2")return s("mat3x4");if(A==="mat4x2")return s("mat4");e()}if(t==="mat3x2"){if(A==="mat2x3")return s("mat2");if(lt(A))return s("mat3x2");if(A==="mat4x3")return s("mat4x2");e()}if(lt(t)){if(A==="mat2x3")return s("mat2x3");if(lt(A))return s("mat3");if(A==="mat4x3")return s("mat4x3");e()}if(t==="mat3x4"){if(A==="mat2x3")return s("mat2x4");if(lt(A))return s("mat3x4");if(A==="mat4x3")return s("mat4");e()}if(t==="mat4x2"){if(A==="mat2x4")return s("mat2");if(A==="mat3x4")return s("mat3x2");if(It(A))return s("mat4x2");e()}if(t==="mat4x3"){if(A==="mat2x4")return s("mat2x3");if(A==="mat3x4")return s("mat3");if(It(A))return s("mat4x3");e()}if(It(t)){if(A==="mat2x4")return s("mat2x4");if(A==="mat3x4")return s("mat3x4");if(It(A))return s("mat4");e()}throw new Error(`Invalid mul types: ${t}, ${A}`)}function Vg(t,A){return as(t,A,"div")}function Pg(t,A){if(t===A)return t;if(t==="int"){if(QA(A))return A}else if(A==="int"){if(QA(t))return t}else if(t==="uint"){if(pA(A))return A}else if(A==="uint"&&pA(t))return t;throw new Error(`Invalid imod types: ${t}, ${A}`)}function Zg(t,A){if(t===A||A==="float")return t;throw new Error(`Invalid mod types: ${t}, ${A}`)}function Xg(t){return t}function Og(t){return t}function jg(t){return t}function Wg(t){return t}function Al(t){return t}function tl(t){return t}function el(t){return t}function sl(t){return t}function nl(t){return t}function il(t){return t}function rl(t){return t}function al(t){return t}function ol(t){return t}function cl(t){return t}function gl(t){return t}function ll(t){return t}function ai(t,A,e="min"){if(t===A)return t;if(A==="float"){if(te(t))return t}else if(A==="int"){if(QA(t))return t}else if(A==="uint"&&pA(t))return t;throw new Error(`Invalid ${e} types: ${t}, ${A}`)}function Il(t,A){return ai(t,A,"max")}function ul(t,A,e){if(A==="float"){if(te(t))return t}else if(A==="int"){if(QA(t))return t}else if(A==="uint"&&pA(t))return t;throw new Error(`Invalid clamp types: ${t}, ${A}`)}function hl(t,A,e){if(e===t||e==="float"||e==="bool"&&t==="float"||e==="bvec2"&&t==="vec2"||e==="bvec3"&&t==="vec3"||e==="bvec4"&&t==="vec4")return t;throw new Error(`Invalid mix types: ${t}, ${A}, ${e}`)}function Cl(t,A){if(t===A||A==="float")return A;throw new Error(`Invalid step types: ${t}, ${A}`)}function Bl(t,A,e){if(t===A&&(t===e||t==="float"))return e;throw new Error(`Invalid smoothstep types: ${t}, ${A}, ${e}`)}function oi(t,A="isNan"){if(t==="float")return"bool";if(t==="vec2")return"bvec2";if(t==="vec3")return"bvec3";if(t==="vec4")return"bvec4";throw new Error(`Invalid ${A} types: ${t}`)}function El(t){return oi(t,"isInf")}const EA=(t,A)=>new Ii({a:t,b:A}),ft=(t,A)=>new ui({a:t,b:A}),rA=(t,A)=>new hi({a:t,b:A}),ge=(t,A)=>new Ci({a:t,b:A}),He=(t,A)=>new Bi({a:t,b:A}),ci=(t,A)=>new Ei({a:t,b:A}),Ql=t=>new Qi({a:t}).outputs,os=t=>new pi({a:t}),pl=t=>new fi({a:t}),fl=t=>new di({a:t}),dl=t=>new yi({a:t}),yl=t=>new wi({a:t}),wl=t=>new mi({a:t}),ml=t=>new xi({a:t}),le=t=>new Si({a:t}),xl=(t,A)=>new Di({a:t,b:A}),Sl=t=>new Mi({a:t}),Dl=t=>ne
Line truncated
|
||||
`)+this.after}}const Bs=new Map;function _g(t){let A=Bs.get(t);return A||(A=new I.RawShaderMaterial({glslVersion:I.GLSL3,vertexShader:On,fragmentShader:t.shader,uniforms:t.uniforms}),Bs.set(t,A),A)}function is(t,A,e="add"){const s=()=>{throw new Error(`Invalid ${e} types: ${t}, ${A}`)};if(t===A)return t;if(t==="int"){if(QA(A))return A;s()}if(A==="int"){if(QA(t))return t;s()}if(t==="uint"){if(pA(A))return A;s()}if(A==="uint"){if(pA(t))return t;s()}if(t==="float"){if(ot(A))return A;s()}if(A==="float"){if(ot(t))return t;s()}throw new Error(`Invalid ${e} types: ${t}, ${A}`)}function Lg(t,A){return is(t,A,"sub")}function zg(t,A){const e=()=>{throw new Error(`Invalid mul types: ${t}, ${A}`)},s=n=>n;if(t==="int"){if(QA(A))return s(A);e()}if(A==="int"){if(QA(t))return s(t);e()}if(t==="uint"){if(pA(A))return s(A);e()}if(A==="uint"){if(pA(t))return s(t);e()}if(t==="float"){if(ot(A))return s(A);e()}if(A==="float"){if(ot(t))return s(t);e()}if(QA(t)||pA(t)||QA(A)||pA(A)){if(t===A)return s(t);e()}if(t==="vec2"){if(A==="vec2"||gt(A))return s("vec2");if(A==="mat3x2")return s("vec3");if(A==="mat4x2")return s("vec4");e()}if(t==="vec3"){if(A==="mat2x3")return s("vec2");if(A==="vec3"||lt(A))return s("vec3");if(A==="mat4x3")return s("vec4");e()}if(t==="vec4"){if(A==="mat2x4")return s("vec2");if(A==="mat3x4")return s("vec3");if(A==="vec4"||It(A))return s("vec4");e()}if(A==="vec2"){if(gt(t))return s("vec2");if(t==="mat2x3")return s("vec3");if(t==="mat2x4")return s("vec4");e()}if(A==="vec3"){if(t==="mat3x2")return s("vec2");if(lt(t))return s("vec3");if(t==="mat3x4")return s("vec4");e()}if(A==="vec4"){if(t==="mat4x2")return s("vec2");if(t==="mat4x3")return s("vec3");if(It(t))return s("vec4");e()}if(gt(t)){if(gt(A))return s("mat2");if(A==="mat3x2")return s("mat3x2");if(A==="mat4x2")return s("mat4x2");e()}if(t==="mat2x3"){if(gt(A))return s("mat2x3");if(A==="mat3x2")return s("mat3");if(A==="mat4x2")return s("mat4x3");e()}if(t==="mat2x4"){if(gt(A))return s("mat2x4");if(A==="mat3x2")return s("mat3x4");if(A==="mat4x2")return s("mat4");e()}if(t==="mat3x2"){if(A==="mat2x3")return s("mat2");if(lt(A))return s("mat3x2");if(A==="mat4x3")return s("mat4x2");e()}if(lt(t)){if(A==="mat2x3")return s("mat2x3");if(lt(A))return s("mat3");if(A==="mat4x3")return s("mat4x3");e()}if(t==="mat3x4"){if(A==="mat2x3")return s("mat2x4");if(lt(A))return s("mat3x4");if(A==="mat4x3")return s("mat4");e()}if(t==="mat4x2"){if(A==="mat2x4")return s("mat2");if(A==="mat3x4")return s("mat3x2");if(It(A))return s("mat4x2");e()}if(t==="mat4x3"){if(A==="mat2x4")return s("mat2x3");if(A==="mat3x4")return s("mat3");if(It(A))return s("mat4x3");e()}if(It(t)){if(A==="mat2x4")return s("mat2x4");if(A==="mat3x4")return s("mat3x4");if(It(A))return s("mat4");e()}throw new Error(`Invalid mul types: ${t}, ${A}`)}function Hg(t,A){return is(t,A,"div")}function qg(t,A){if(t===A)return t;if(t==="int"){if(QA(A))return A}else if(A==="int"){if(QA(t))return t}else if(t==="uint"){if(pA(A))return A}else if(A==="uint"&&pA(t))return t;throw new Error(`Invalid imod types: ${t}, ${A}`)}function Kg(t,A){if(t===A||A==="float")return t;throw new Error(`Invalid mod types: ${t}, ${A}`)}function $g(t){return t}function Vg(t){return t}function Pg(t){return t}function Zg(t){return t}function Xg(t){return t}function Og(t){return t}function jg(t){return t}function Wg(t){return t}function Al(t){return t}function tl(t){return t}function el(t){return t}function sl(t){return t}function nl(t){return t}function il(t){return t}function rl(t){return t}function al(t){return t}function ii(t,A,e="min"){if(t===A)return t;if(A==="float"){if(te(t))return t}else if(A==="int"){if(QA(t))return t}else if(A==="uint"&&pA(t))return t;throw new Error(`Invalid ${e} types: ${t}, ${A}`)}function ol(t,A){return ii(t,A,"max")}function cl(t,A,e){if(A==="float"){if(te(t))return t}else if(A==="int"){if(QA(t))return t}else if(A==="uint"&&pA(t))return t;throw new Error(`Invalid clamp types: ${t}, ${A}`)}function gl(t,A,e){if(e===t||e==="float"||e==="bool"&&t==="float"||e==="bvec2"&&t==="vec2"||e==="bvec3"&&t==="vec3"||e==="bvec4"&&t==="vec4")return t;throw new Error(`Invalid mix types: ${t}, ${A}, ${e}`)}function ll(t,A){if(t===A||A==="float")return A;throw new Error(`Invalid step types: ${t}, ${A}`)}function Il(t,A,e){if(t===A&&(t===e||t==="float"))return e;throw new Error(`Invalid smoothstep types: ${t}, ${A}, ${e}`)}function ri(t,A="isNan"){if(t==="float")return"bool";if(t==="vec2")return"bvec2";if(t==="vec3")return"bvec3";if(t==="vec4")return"bvec4";throw new Error(`Invalid ${A} types: ${t}`)}function ul(t){return ri(t,"isInf")}const EA=(t,A)=>new gi({a:t,b:A}),ft=(t,A)=>new li({a:t,b:A}),rA=(t,A)=>new Ii({a:t,b:A}),ge=(t,A)=>new ui({a:t,b:A}),He=(t,A)=>new hi({a:t,b:A}),ai=(t,A)=>new Ci({a:t,b:A}),hl=t=>new Bi({a:t}).outputs,rs=t=>new Ei({a:t}),Cl=t=>new Qi({a:t}),Bl=t=>new pi({a:t}),El=t=>new fi({a:t}),Ql=t=>new di({a:t}),pl=t=>new yi({a:t}),fl=t=>new wi({a:t}),le=t=>new mi({a:t}),dl=(t,A)=>new xi({a:t,b:A}),yl=t=>new Si({a:t}),wl=t=>ne
Line truncated
|
||||
uint pcg_next(uint state) {
|
||||
return state * 747796405u + 2891336453u;
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
uint hash = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
||||
return (hash >> 22u) ^ hash;
|
||||
}
|
||||
`)],statements:({inputs:e,outputs:s})=>[`${s.hash} = pcg_hash(${e.state});`]})}dynoOut(){return new K(this,"hash")}}class Rt extends V{constructor({value:A}){const e=$(A),s=qs(e);super({inTypes:{value:e},outTypes:{state:"uint"},inputs:{value:A},globals:()=>[CA(`
|
||||
`)],statements:({inputs:e,outputs:s})=>[`${s.hash} = pcg_hash(${e.state});`]})}dynoOut(){return new K(this,"hash")}}class Rt extends V{constructor({value:A}){const e=$(A),s=zs(e);super({inTypes:{value:e},outTypes:{state:"uint"},inputs:{value:A},globals:()=>[CA(`
|
||||
uint pcg_mix(uint value) {
|
||||
return value;
|
||||
}
|
||||
@@ -97,7 +97,7 @@
|
||||
uint pcg_mix(uvec4 value) {
|
||||
return value.x + 0x9e3779b9u * value.y + 0x85ebca6bu * value.z + 0xc2b2ae35u * value.w;
|
||||
}
|
||||
`)],statements:({inputs:n,outputs:i})=>{const r=pA(e)?`${n.value}`:QA(e)?`${s}(${n.value})`:`floatBitsToUint(${n.value})`;return[`${s} bits = ${r};`,`${i.state} = pcg_mix(bits);`]}})}dynoOut(){return new K(this,"state")}}class Ca extends ZA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"uint"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");let s=new Rt({value:e}).outputs.state;return s=new GA({state:s}).outputs.state,new RA({state:s}).outputs}})}dynoOut(){return new K(this,"hash")}}class Ba extends ZA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"uvec2"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");let s=new Rt({value:e}).outputs.state;s=new GA({state:s}).outputs.state;const n=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const i=new RA({state:s}).outputs.hash;return{hash:VA({vectorType:"uvec2",x:n,y:i})}}})}dynoOut(){return new K(this,"hash")}}class Ea extends ZA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"uvec3"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");let s=new Rt({value:e}).outputs.state;s=new GA({state:s}).outputs.state;const n=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const i=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const r=new RA({state:s}).outputs.hash;return{hash:VA({vectorType:"uvec3",x:n,y:i,z:r})}}})}dynoOut(){return new K(this,"hash")}}class Qa extends ZA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"uvec4"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");let s=new Rt({value:e}).outputs.state;s=new GA({state:s}).outputs.state;const n=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const i=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const r=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const a=new RA({state:s}).outputs.hash;return{hash:VA({vectorType:"uvec4",x:n,y:i,z:r,w:a})}}})}dynoOut(){return new K(this,"hash")}}class pa extends ZA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"float"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");const s=oa(e);return{hash:rA(ir(s),J("float",1/2**32))}}})}dynoOut(){return new K(this,"hash")}}class fa extends ZA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"vec2"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");const s=ca(e);return{hash:rA(rr(s),J("float",1/2**32))}}})}dynoOut(){return new K(this,"hash")}}class da extends ZA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"vec3"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");const s=ga(e);return{hash:rA(Qt(s),J("float",1/2**32))}}})}dynoOut(){return new K(this,"hash")}}class ya extends ZA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"vec4"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");const s=la(e);return{hash:rA(ar(s),J("float",1/2**32))}}})}dynoOut(){return new K(this,"hash")}}class wa extends V{constructor({z:A,zNear:e,zFar:s}){super({inTypes:{z:"float",zNear:"float",zFar:"float"},outTypes:{depth:"float"},inputs:{z:A,zNear:e,zFar:s},statements:({inputs:n,outputs:i})=>[`float clamped = clamp(${n.z}, ${n.zNear}, ${n.zFar});`,`${i.depth} = (log2(clamped + 1.0) - log2(${n.zNear} + 1.0)) / (log2(${n.zFar} + 1.0) - log2(${n.zNear} + 1.0));`]})}dynoOut(){return new K(this,"depth")}}const ma=(t,{scale:A,scales:e,rotate:s,translate:n})=>new Sa({position:t,scale:A,scales:e,rotate:s,translate:n}).outputs.position,xa=(t,{scale:A,scales:e,rotate:s})=>new Da({dir:t,scale:A,scales:e,rotate:s}).outputs.dir,$I=(t,{rotate:A})=>new Ma({quaternion:t,rotate:A}).outputs.quaternion;class Sa extends V{constructor({position:A,scale:e,scales:s,rotate:n,translate:i}){super({inTypes:{position:"vec3",scale:"float",scales:"vec3",rotate:"vec4",translate:"vec3"},outTypes:{position:"vec3"},inputs:{position:A,scale:e,scales:s,rotate:n,translate:i},statements:({inputs:r,outputs:a})=>{const{position:o}=a;if(!o)return[];const{scale:g,scales:l,rotate:c,translate:u}=r;return[`${o} = ${r.position??"vec3(0.0, 0.0, 0.0)"};`,g?`${o} *= ${g};`:null,l?`${o} *= ${l};`:null,c?`${o} = quatVec(${c}, ${o});`:null,u?`${o} += ${u};`:null].filter(Boolean)}})}}class Da extends V{constructor({dir:A,scale:e,scales:s,rotate:n}){super({inTypes:{dir:"vec3",scale:"float",scales:"vec3",rotate:"vec4"},outTypes:{dir:"vec3"},inputs:{dir:A,scale:e,scales:s,rotate:n},statements:({inputs:i,outputs:r})=>{const{dir:a}=r;if(!a)return[];const{scale:o,scales:g,rotate:l}=i;return[`${a} = ${i.dir??"vec3(0.0, 0.0, 0.0)"};`,o?`${a} *= ${o};`:null,g?`${a} *= ${g};`:null,l?`${a} = quatVec(${l}, ${a});`:null].filter(Boolean)}})}}class Ma extends V{constructor({quaternion:A,rotate:e}){super({
Line truncated
|
||||
`)],statements:({inputs:n,outputs:i})=>{const r=pA(e)?`${n.value}`:QA(e)?`${s}(${n.value})`:`floatBitsToUint(${n.value})`;return[`${s} bits = ${r};`,`${i.state} = pcg_mix(bits);`]}})}dynoOut(){return new K(this,"state")}}class ua extends PA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"uint"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");let s=new Rt({value:e}).outputs.state;return s=new GA({state:s}).outputs.state,new RA({state:s}).outputs}})}dynoOut(){return new K(this,"hash")}}class ha extends PA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"uvec2"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");let s=new Rt({value:e}).outputs.state;s=new GA({state:s}).outputs.state;const n=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const i=new RA({state:s}).outputs.hash;return{hash:VA({vectorType:"uvec2",x:n,y:i})}}})}dynoOut(){return new K(this,"hash")}}class Ca extends PA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"uvec3"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");let s=new Rt({value:e}).outputs.state;s=new GA({state:s}).outputs.state;const n=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const i=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const r=new RA({state:s}).outputs.hash;return{hash:VA({vectorType:"uvec3",x:n,y:i,z:r})}}})}dynoOut(){return new K(this,"hash")}}class Ba extends PA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"uvec4"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");let s=new Rt({value:e}).outputs.state;s=new GA({state:s}).outputs.state;const n=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const i=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const r=new RA({state:s}).outputs.hash;s=new GA({state:s}).outputs.state;const a=new RA({state:s}).outputs.hash;return{hash:VA({vectorType:"uvec4",x:n,y:i,z:r,w:a})}}})}dynoOut(){return new K(this,"hash")}}class Ea extends PA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"float"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");const s=ra(e);return{hash:rA(sr(s),J("float",1/2**32))}}})}dynoOut(){return new K(this,"hash")}}class Qa extends PA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"vec2"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");const s=aa(e);return{hash:rA(nr(s),J("float",1/2**32))}}})}dynoOut(){return new K(this,"hash")}}class pa extends PA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"vec3"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");const s=oa(e);return{hash:rA(Qt(s),J("float",1/2**32))}}})}dynoOut(){return new K(this,"hash")}}class fa extends PA{constructor({value:A}){super({inTypes:{value:$(A)},outTypes:{hash:"vec4"},inputs:{value:A},construct:({value:e})=>{if(!e)throw new Error("value is required");const s=ca(e);return{hash:rA(ir(s),J("float",1/2**32))}}})}dynoOut(){return new K(this,"hash")}}class da extends V{constructor({z:A,zNear:e,zFar:s}){super({inTypes:{z:"float",zNear:"float",zFar:"float"},outTypes:{depth:"float"},inputs:{z:A,zNear:e,zFar:s},statements:({inputs:n,outputs:i})=>[`float clamped = clamp(${n.z}, ${n.zNear}, ${n.zFar});`,`${i.depth} = (log2(clamped + 1.0) - log2(${n.zNear} + 1.0)) / (log2(${n.zFar} + 1.0) - log2(${n.zNear} + 1.0));`]})}dynoOut(){return new K(this,"depth")}}const ya=(t,{scale:A,scales:e,rotate:s,translate:n})=>new ma({position:t,scale:A,scales:e,rotate:s,translate:n}).outputs.position,wa=(t,{scale:A,scales:e,rotate:s})=>new xa({dir:t,scale:A,scales:e,rotate:s}).outputs.dir,zI=(t,{rotate:A})=>new Sa({quaternion:t,rotate:A}).outputs.quaternion;class ma extends V{constructor({position:A,scale:e,scales:s,rotate:n,translate:i}){super({inTypes:{position:"vec3",scale:"float",scales:"vec3",rotate:"vec4",translate:"vec3"},outTypes:{position:"vec3"},inputs:{position:A,scale:e,scales:s,rotate:n,translate:i},statements:({inputs:r,outputs:a})=>{const{position:o}=a;if(!o)return[];const{scale:g,scales:l,rotate:c,translate:u}=r;return[`${o} = ${r.position??"vec3(0.0, 0.0, 0.0)"};`,g?`${o} *= ${g};`:null,l?`${o} *= ${l};`:null,c?`${o} = quatVec(${c}, ${o});`:null,u?`${o} += ${u};`:null].filter(Boolean)}})}}class xa extends V{constructor({dir:A,scale:e,scales:s,rotate:n}){super({inTypes:{dir:"vec3",scale:"float",scales:"vec3",rotate:"vec4"},outTypes:{dir:"vec3"},inputs:{dir:A,scale:e,scales:s,rotate:n},statements:({inputs:i,outputs:r})=>{const{dir:a}=r;if(!a)return[];const{scale:o,scales:g,rotate:l}=i;return[`${a} = ${i.dir??"vec3(0.0, 0.0, 0.0)"};`,o?`${a} *= ${o};`:null,g?`${a} *= ${g};`:null,l?`${a} = quatVec(${l}, ${a});`:null].filter(Boolean)}})}}class Sa extends V{constructor({quaternion:A,rotate:e}){super({
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 UA=class UA{constructor({renderer:A}={}){this.renderer=A,this.capacity=0,this.count=0}dispose(){this.target&&(this.target.dispose(),this.target=void 0)}ensureBuffer(A,e){const n=Math.ceil(Math.max(1,A)/Z)*Z*4;if(e.byteLength>=n)return e;const i=new ArrayBuffer(n);if(e instanceof ArrayBuffer)return i;const r=e.constructor;return new r(i)}ensureCapacity(A){const{width:e,height:s,depth:n,maxSplats:i}=xA(A);(!this.target||i>this.capacity)&&(this.dispose(),this.capacity=i,this.target=new I.WebGLArrayRenderTarget(e,s,n,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:I.NearestFilter,minFilter:I.NearestFilter}),this.target.texture.format=I.RGBAFormat,this.target.texture.type=I.UnsignedByteType,this.target.texture.internalFormat="RGBA8",this.target.scissorTest=!0)}prepareProgramMaterial(A){let e=UA.readbackProgram.get(A);if(!e){const n=FA({index:"int"},{rgba8:"vec4"},({index:i})=>(A.inputs.index=i,{rgba8:new ss({rgba8:A.outputs.rgba8})}));UA.programTemplate||(UA.programTemplate=new rs(Qu)),e=new is({graph:n,inputs:{index:"index"},outputs:{rgba8:"target"},template:UA.programTemplate}),Object.assign(e.uniforms,{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0}}),UA.readbackProgram.set(A,e)}const s=e.prepareMaterial();return UA.fullScreenQuad.material=s,{program:e,material:s}}saveRenderState(A){return{xrEnabled:A.xr.enabled,autoClear:A.autoClear}}resetRenderState(A,e){A.setRenderTarget(null),A.xr.enabled=e.xrEnabled,A.autoClear=e.autoClear}process({count:A,material:e}){const s=this.renderer;if(!s)throw new Error("No renderer");if(!this.target)throw new Error("No target");const n=Z*$A;e.uniforms.targetBase.value=0,e.uniforms.targetCount.value=A;let i=0;for(;i<A;){const r=Math.floor(i/n),a=r*n,o=Math.min($A,Math.ceil((A-a)/Z));e.uniforms.targetLayer.value=r,this.target.scissor.set(0,0,Z,o),s.setRenderTarget(this.target,r),s.xr.enabled=!1,s.autoClear=!1,UA.fullScreenQuad.render(s),i+=Z*o}this.count=A}async read({readback:A}){const e=this.renderer;if(!e)throw new Error("No renderer");if(!this.target)throw new Error("No target");const s=Math.ceil(this.count/Z)*Z;if(A.byteLength<s*4)throw new Error(`Readback buffer too small: ${A.byteLength} < ${s*4}`);const n=new Uint8Array(A instanceof ArrayBuffer?A:A.buffer),i=Z*$A;let r=0;const a=[];for(;r<this.count;){const o=Math.floor(r/i),g=o*i,l=Math.min($A,Math.ceil((this.count-g)/Z));e.setRenderTarget(this.target,o);const c=Z*l*4,u=n.subarray(g*4,g*4+c),h=e==null?void 0:e.readRenderTargetPixelsAsync(this.target,0,0,Z,l,u);a.push(h),r+=Z*l}return Promise.all(a).then(()=>A)}render({reader:A,count:e,renderer:s}){if(this.renderer=s||this.renderer,!this.renderer)throw new Error("No renderer");this.ensureCapacity(e);const{program:n,material:i}=this.prepareProgramMaterial(A);n.update();const r=this.saveRenderState(this.renderer);this.process({count:e,material:i}),this.resetRenderState(this.renderer,r)}async readback({readback:A}){if(!this.renderer)throw new Error("No renderer");const e=this.saveRenderState(this.renderer),s=this.read({readback:A});return this.resetRenderState(this.renderer,e),s}async renderReadback({reader:A,count:e,renderer:s,readback:n}){if(this.renderer=s||this.renderer,!this.renderer)throw new Error("No renderer");this.ensureCapacity(e);const{program:i,material:r}=this.prepareProgramMaterial(A);i.update();const a=this.saveRenderState(this.renderer);this.process({count:e,material:r});const o=this.read({readback:n});return this.resetRenderState(this.renderer,a),o}getTexture(){var A;return(A=this.target)==null?void 0:A.texture}};UA.programTemplate=null,UA.readbackProgram=new Map,UA.fullScreenQuad=new Ss(new I.RawShaderMaterial({visible:!1}));let Zt=UA;const uA=class uA{constructor(A={}){this.capacity=0,this.count=0,this.array=null,this.readback=null,this.source=null,this.needsUpdate=!0,this.dyno=new N({key:"rgbaArray",type:Za,globals:()=>[Xa],value:{texture:uA.getEmpty(),count:0},update:e=>{var s;return e.texture=((s=this.readback)==null?void 0:s.getTexture())??this.source??uA.getEmpty(),e.count=this.count,e}}),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 e;if(!this.array||A>(((e=this.array)==null?void 0:e.length)??0)/4){this.capacity=xA(A).maxSplats;const s=new Uint8Array(this.capacity*4);this.array&&s.set(this.array),this.array=s}return this.array}getTexture(){var e;let A=(e=this.readback)==null?void 0:e.getTexture();return(this.source||this.array)&&(A=this.maybeUpdateSource()),A??uA.getEmpty()}maybeUpdateSource(){if(!this.array)throw new Error("No array");if(this.needsUpdate||!this.source){if(this.needsUpdate=!1,this.source){const{width:A,height:e,depth:s}=this.source.image;this.capacity!==A*e*s&&(this.s
Line truncated
|
||||
}`;const UA=class UA{constructor({renderer:A}={}){this.renderer=A,this.capacity=0,this.count=0}dispose(){this.target&&(this.target.dispose(),this.target=void 0)}ensureBuffer(A,e){const n=Math.ceil(Math.max(1,A)/Z)*Z*4;if(e.byteLength>=n)return e;const i=new ArrayBuffer(n);if(e instanceof ArrayBuffer)return i;const r=e.constructor;return new r(i)}ensureCapacity(A){const{width:e,height:s,depth:n,maxSplats:i}=xA(A);(!this.target||i>this.capacity)&&(this.dispose(),this.capacity=i,this.target=new I.WebGLArrayRenderTarget(e,s,n,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:I.NearestFilter,minFilter:I.NearestFilter}),this.target.texture.format=I.RGBAFormat,this.target.texture.type=I.UnsignedByteType,this.target.texture.internalFormat="RGBA8",this.target.scissorTest=!0)}prepareProgramMaterial(A){let e=UA.readbackProgram.get(A);if(!e){const n=FA({index:"int"},{rgba8:"vec4"},({index:i})=>(A.inputs.index=i,{rgba8:new ts({rgba8:A.outputs.rgba8})}));UA.programTemplate||(UA.programTemplate=new ns(hu)),e=new ss({graph:n,inputs:{index:"index"},outputs:{rgba8:"target"},template:UA.programTemplate}),Object.assign(e.uniforms,{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0}}),UA.readbackProgram.set(A,e)}const s=e.prepareMaterial();return UA.fullScreenQuad.material=s,{program:e,material:s}}saveRenderState(A){return{xrEnabled:A.xr.enabled,autoClear:A.autoClear}}resetRenderState(A,e){A.setRenderTarget(null),A.xr.enabled=e.xrEnabled,A.autoClear=e.autoClear}process({count:A,material:e}){const s=this.renderer;if(!s)throw new Error("No renderer");if(!this.target)throw new Error("No target");const n=Z*$A;e.uniforms.targetBase.value=0,e.uniforms.targetCount.value=A;let i=0;for(;i<A;){const r=Math.floor(i/n),a=r*n,o=Math.min($A,Math.ceil((A-a)/Z));e.uniforms.targetLayer.value=r,this.target.scissor.set(0,0,Z,o),s.setRenderTarget(this.target,r),s.xr.enabled=!1,s.autoClear=!1,UA.fullScreenQuad.render(s),i+=Z*o}this.count=A}async read({readback:A}){const e=this.renderer;if(!e)throw new Error("No renderer");if(!this.target)throw new Error("No target");const s=Math.ceil(this.count/Z)*Z;if(A.byteLength<s*4)throw new Error(`Readback buffer too small: ${A.byteLength} < ${s*4}`);const n=new Uint8Array(A instanceof ArrayBuffer?A:A.buffer),i=Z*$A;let r=0;const a=[];for(;r<this.count;){const o=Math.floor(r/i),g=o*i,l=Math.min($A,Math.ceil((this.count-g)/Z));e.setRenderTarget(this.target,o);const c=Z*l*4,u=n.subarray(g*4,g*4+c),h=e==null?void 0:e.readRenderTargetPixelsAsync(this.target,0,0,Z,l,u);a.push(h),r+=Z*l}return Promise.all(a).then(()=>A)}render({reader:A,count:e,renderer:s}){if(this.renderer=s||this.renderer,!this.renderer)throw new Error("No renderer");this.ensureCapacity(e);const{program:n,material:i}=this.prepareProgramMaterial(A);n.update();const r=this.saveRenderState(this.renderer);this.process({count:e,material:i}),this.resetRenderState(this.renderer,r)}async readback({readback:A}){if(!this.renderer)throw new Error("No renderer");const e=this.saveRenderState(this.renderer),s=this.read({readback:A});return this.resetRenderState(this.renderer,e),s}async renderReadback({reader:A,count:e,renderer:s,readback:n}){if(this.renderer=s||this.renderer,!this.renderer)throw new Error("No renderer");this.ensureCapacity(e);const{program:i,material:r}=this.prepareProgramMaterial(A);i.update();const a=this.saveRenderState(this.renderer);this.process({count:e,material:r});const o=this.read({readback:n});return this.resetRenderState(this.renderer,a),o}getTexture(){var A;return(A=this.target)==null?void 0:A.texture}};UA.programTemplate=null,UA.readbackProgram=new Map,UA.fullScreenQuad=new ms(new I.RawShaderMaterial({visible:!1}));let Zt=UA;const uA=class uA{constructor(A={}){this.capacity=0,this.count=0,this.array=null,this.readback=null,this.source=null,this.needsUpdate=!0,this.dyno=new N({key:"rgbaArray",type:Va,globals:()=>[Pa],value:{texture:uA.getEmpty(),count:0},update:e=>{var s;return e.texture=((s=this.readback)==null?void 0:s.getTexture())??this.source??uA.getEmpty(),e.count=this.count,e}}),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 e;if(!this.array||A>(((e=this.array)==null?void 0:e.length)??0)/4){this.capacity=xA(A).maxSplats;const s=new Uint8Array(this.capacity*4);this.array&&s.set(this.array),this.array=s}return this.array}getTexture(){var e;let A=(e=this.readback)==null?void 0:e.getTexture();return(this.source||this.array)&&(A=this.maybeUpdateSource()),A??uA.getEmpty()}maybeUpdateSource(){if(!this.array)throw new Error("No array");if(this.needsUpdate||!this.source){if(this.needsUpdate=!1,this.source){const{width:A,height:e,depth:s}=this.source.image;this.capacity!==A*e*s&&(this.s
Line truncated
|
||||
struct RgbaArray {
|
||||
sampler2DArray texture;
|
||||
int count;
|
||||
};
|
||||
`);function pu(t,A){return new V({inTypes:{rgba:Za,index:"int"},outTypes:{rgba:"vec4"},inputs:{rgba:t,index:A},globals:()=>[Xa],statements:({inputs:s,outputs:n})=>YA(`
|
||||
`);function Cu(t,A){return new V({inTypes:{rgba:Va,index:"int"},outTypes:{rgba:"vec4"},inputs:{rgba:t,index:A},globals:()=>[Pa],statements:({inputs:s,outputs:n})=>YA(`
|
||||
if ((index >= 0) && (index < ${s.rgba}.count)) {
|
||||
${n.rgba} = texelFetch(${s.rgba}.texture, splatTexCoord(index), 0);
|
||||
} else {
|
||||
${n.rgba} = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
`)}).outputs.rgba}var Oa=(t=>(t.ALL="all",t.PLANE="plane",t.SPHERE="sphere",t.BOX="box",t.ELLIPSOID="ellipsoid",t.CYLINDER="cylinder",t.CAPSULE="capsule",t.INFINITE_CONE="infinite_cone",t))(Oa||{});function fu(t){switch(t){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: ${t}`)}}var ja=(t=>(t.MULTIPLY="multiply",t.SET_RGB="set_rgb",t.ADD_RGBA="add_rgba",t))(ja||{});function du(t){switch(t){case"multiply":return 0;case"set_rgb":return 1;case"add_rgba":return 2;default:throw new Error(`Unknown blend mode: ${t}`)}}class Wa extends I.Object3D{constructor(A={}){super();const{type:e,invert:s,opacity:n,color:i,displace:r,radius:a}=A;this.type=e??"sphere",this.invert=s??!1,this.opacity=n??1,this.color=i??new I.Color(1,1,1),this.displace=r??new I.Vector3(0,0,0),this.radius=a??0}}const de=class de extends I.Object3D{constructor(A={}){const{name:e,rgbaBlendMode:s="multiply",sdfSmooth:n=0,softEdge:i=0,invert:r=!1,sdfs:a=null}=A;super(),this.rgbaBlendMode=s,this.sdfSmooth=n,this.softEdge=i,this.invert=r,this.sdfs=a,this.ordering=de.nextOrdering++,this.name=e??`Edit ${this.ordering}`}addSdf(A){this.sdfs==null&&(this.sdfs=[]),this.sdfs.includes(A)||this.sdfs.push(A)}removeSdf(A){this.sdfs!=null&&(this.sdfs=this.sdfs.filter(e=>e!==A))}};de.nextOrdering=1;let Xt=de;class Ao{constructor({maxSdfs:A,maxEdits:e}){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 N({key:"sdfArray",type:to,globals:()=>[eo],value:{numSdfs:0,sdfTexture:this.sdfTexture},update:s=>(s.numSdfs=this.numSdfs,s.sdfTexture=this.sdfTexture,s)}),this.maxEdits=Math.max(16,e??0),this.numEdits=0,this.editData=new Uint32Array(this.maxEdits*4),this.editFloatData=new Float32Array(this.editData.buffer),this.dynoNumEdits=new Pt({value:0}),this.dynoEdits=this.newEdits(this.editData,this.maxEdits)}newSdfTexture(A,e){const s=new I.DataTexture(A,8,e,I.RGBAIntegerFormat,I.UnsignedIntType);return s.internalFormat="RGBA32UI",s.needsUpdate=!0,s}newEdits(A,e){return new N({key:"edits",type:"uvec4",count:e,globals:()=>[so],value:A})}ensureCapacity({maxSdfs:A,maxEdits:e}){let s=!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)),e>(this.dynoEdits.count??0)&&(this.maxEdits=Math.max(this.maxEdits*2,e),this.editData=new Uint32Array(this.maxEdits*4),this.editFloatData=new Float32Array(this.editData.buffer),this.dynoEdits=this.newEdits(this.editData,this.maxEdits),s=!0),s}updateEditData(A,e){const s=this.editData[A]!==e;return this.editData[A]=e,s}updateEditFloatData(A,e){mt[0]=e;const s=this.editFloatData[A]!==mt[0];return s&&(this.editFloatData[A]=mt[0]),s}encodeEdit(A,{sdfFirst:e,sdfCount:s,invert:n,rgbaBlendMode:i,softEdge:r,sdfSmooth:a}){const o=A*4;let g=!1;return g=this.updateEditData(o+0,i|(n?256:0))||g,g=this.updateEditData(o+1,e|s<<16)||g,g=this.updateEditFloatData(o+2,r)||g,g=this.updateEditFloatData(o+3,a)||g,g}updateSdfData(A,e){const s=this.sdfData[A]!==e;return this.sdfData[A]=e,s}updateSdfFloatData(A,e){mt[0]=e;const s=this.sdfFloatData[A]!==mt[0];return s&&(this.sdfFloatData[A]=mt[0]),s}encodeSdf(A,{sdfType:e,invert:s,center:n,quaternion:i,scale:r,sizes:a},o){const g=A*32,l=e|(s?256:0);let c=!1;c=this.updateSdfFloatData(g+0,(n==null?void 0:n.x)??0)||c,c=this.updateSdfFloatData(g+1,(n==null?void 0:n.y)??0)||c,c=this.updateSdfFloatData(g+2,(n==null?void 0:n.z)??0)||c,c=this.updateSdfData(g+3,l)||c,c=this.updateSdfFloatData(g+4,(i==null?void 0:i.x)??0)||c,c=this.updateSdfFloatData(g+5,(i==null?void 0:i.y)??0)||c,c=this.updateSdfFloatData(g+6,(i==null?void 0:i.z)??0)||c,c=this.updateSdfFloatData(g+7,(i==null?void 0:i.w)??0)||c,c=this.updateSdfFloatData(g+8,(r==null?void 0:r.x)??0)||c,c=this.updateSdfFloatData(g+9,(r==null?void 0:r.y)??0)||c,c=this.updateSdfFloatData(g+10,(r==null?void 0:r.z)??0)||c,c=this.updateSdfData(g+11,0)||c,c=this.updateSdfFloatData(g+12,(a==null?void 0:a.x)??0)||c,c=this.updateSdfFloatData(g+13,(a==null?void 0:a.y)??0)||c,c=this.updateSdfFloatData(g+14,(a==null?void 0:a.z)??0)||c,c=this.updateSdfFloatData(g+15,(a==null?void 0:a.w)??0)||c;const u=Math.min(4,o.length);for(let h=0;h<u;++h){const E=g+16+h*4;c=this.updateSdfFloatData(E+0,o[h].x)||c,c=this.updateSdfFloatData(E+1,o[h].y)||c,c=this.updateSdfFloatData(E+2,o[h].z)||c,c=this.updateSdfFloatData(E+3,o[h].w)||c}return c}update(A){const e=A.reduce((c,{sdfs:u})=>c+u.length,0),s=this.ensureCapacity({maxEdits:A.length,maxSdfs:e}),n=[new I.Vector4,new I.Vector4],i=new I.Vector3,r=new I.Quaternion,a=new I.Vector3,o=new I
Line truncated
|
||||
`)}).outputs.rgba}var Za=(t=>(t.ALL="all",t.PLANE="plane",t.SPHERE="sphere",t.BOX="box",t.ELLIPSOID="ellipsoid",t.CYLINDER="cylinder",t.CAPSULE="capsule",t.INFINITE_CONE="infinite_cone",t))(Za||{});function Bu(t){switch(t){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: ${t}`)}}var Xa=(t=>(t.MULTIPLY="multiply",t.SET_RGB="set_rgb",t.ADD_RGBA="add_rgba",t))(Xa||{});function Eu(t){switch(t){case"multiply":return 0;case"set_rgb":return 1;case"add_rgba":return 2;default:throw new Error(`Unknown blend mode: ${t}`)}}class Oa extends I.Object3D{constructor(A={}){super();const{type:e,invert:s,opacity:n,color:i,displace:r,radius:a}=A;this.type=e??"sphere",this.invert=s??!1,this.opacity=n??1,this.color=i??new I.Color(1,1,1),this.displace=r??new I.Vector3(0,0,0),this.radius=a??0}}const de=class de extends I.Object3D{constructor(A={}){const{name:e,rgbaBlendMode:s="multiply",sdfSmooth:n=0,softEdge:i=0,invert:r=!1,sdfs:a=null}=A;super(),this.rgbaBlendMode=s,this.sdfSmooth=n,this.softEdge=i,this.invert=r,this.sdfs=a,this.ordering=de.nextOrdering++,this.name=e??`Edit ${this.ordering}`}addSdf(A){this.sdfs==null&&(this.sdfs=[]),this.sdfs.includes(A)||this.sdfs.push(A)}removeSdf(A){this.sdfs!=null&&(this.sdfs=this.sdfs.filter(e=>e!==A))}};de.nextOrdering=1;let Xt=de;class ja{constructor({maxSdfs:A,maxEdits:e}){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 N({key:"sdfArray",type:Wa,globals:()=>[Ao],value:{numSdfs:0,sdfTexture:this.sdfTexture},update:s=>(s.numSdfs=this.numSdfs,s.sdfTexture=this.sdfTexture,s)}),this.maxEdits=Math.max(16,e??0),this.numEdits=0,this.editData=new Uint32Array(this.maxEdits*4),this.editFloatData=new Float32Array(this.editData.buffer),this.dynoNumEdits=new Pt({value:0}),this.dynoEdits=this.newEdits(this.editData,this.maxEdits)}newSdfTexture(A,e){const s=new I.DataTexture(A,8,e,I.RGBAIntegerFormat,I.UnsignedIntType);return s.internalFormat="RGBA32UI",s.needsUpdate=!0,s}newEdits(A,e){return new N({key:"edits",type:"uvec4",count:e,globals:()=>[to],value:A})}ensureCapacity({maxSdfs:A,maxEdits:e}){let s=!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)),e>(this.dynoEdits.count??0)&&(this.maxEdits=Math.max(this.maxEdits*2,e),this.editData=new Uint32Array(this.maxEdits*4),this.editFloatData=new Float32Array(this.editData.buffer),this.dynoEdits=this.newEdits(this.editData,this.maxEdits),s=!0),s}updateEditData(A,e){const s=this.editData[A]!==e;return this.editData[A]=e,s}updateEditFloatData(A,e){mt[0]=e;const s=this.editFloatData[A]!==mt[0];return s&&(this.editFloatData[A]=mt[0]),s}encodeEdit(A,{sdfFirst:e,sdfCount:s,invert:n,rgbaBlendMode:i,softEdge:r,sdfSmooth:a}){const o=A*4;let g=!1;return g=this.updateEditData(o+0,i|(n?256:0))||g,g=this.updateEditData(o+1,e|s<<16)||g,g=this.updateEditFloatData(o+2,r)||g,g=this.updateEditFloatData(o+3,a)||g,g}updateSdfData(A,e){const s=this.sdfData[A]!==e;return this.sdfData[A]=e,s}updateSdfFloatData(A,e){mt[0]=e;const s=this.sdfFloatData[A]!==mt[0];return s&&(this.sdfFloatData[A]=mt[0]),s}encodeSdf(A,{sdfType:e,invert:s,center:n,quaternion:i,scale:r,sizes:a},o){const g=A*32,l=e|(s?256:0);let c=!1;c=this.updateSdfFloatData(g+0,(n==null?void 0:n.x)??0)||c,c=this.updateSdfFloatData(g+1,(n==null?void 0:n.y)??0)||c,c=this.updateSdfFloatData(g+2,(n==null?void 0:n.z)??0)||c,c=this.updateSdfData(g+3,l)||c,c=this.updateSdfFloatData(g+4,(i==null?void 0:i.x)??0)||c,c=this.updateSdfFloatData(g+5,(i==null?void 0:i.y)??0)||c,c=this.updateSdfFloatData(g+6,(i==null?void 0:i.z)??0)||c,c=this.updateSdfFloatData(g+7,(i==null?void 0:i.w)??0)||c,c=this.updateSdfFloatData(g+8,(r==null?void 0:r.x)??0)||c,c=this.updateSdfFloatData(g+9,(r==null?void 0:r.y)??0)||c,c=this.updateSdfFloatData(g+10,(r==null?void 0:r.z)??0)||c,c=this.updateSdfData(g+11,0)||c,c=this.updateSdfFloatData(g+12,(a==null?void 0:a.x)??0)||c,c=this.updateSdfFloatData(g+13,(a==null?void 0:a.y)??0)||c,c=this.updateSdfFloatData(g+14,(a==null?void 0:a.z)??0)||c,c=this.updateSdfFloatData(g+15,(a==null?void 0:a.w)??0)||c;const u=Math.min(4,o.length);for(let h=0;h<u;++h){const E=g+16+h*4;c=this.updateSdfFloatData(E+0,o[h].x)||c,c=this.updateSdfFloatData(E+1,o[h].y)||c,c=this.updateSdfFloatData(E+2,o[h].z)||c,c=this.updateSdfFloatData(E+3,o[h].w)||c}return c}update(A){const e=A.reduce((c,{sdfs:u})=>c+u.length,0),s=this.ensureCapacity({maxEdits:A.length,maxSdfs:e}),n=[new I.Vector4,new I.Vector4],i=new I.Vector3,r=new I.Quaternion,a=new I.Vector3,o=new I
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);
|
||||
}
|
||||
`),so=CA(`
|
||||
`),to=CA(`
|
||||
const uint EDIT_FLAG_BLEND = 0xFFu;
|
||||
const uint EDIT_BLEND_MULTIPLY = 0u;
|
||||
const uint EDIT_BLEND_SET_RGB = 1u;
|
||||
@@ -366,7 +366,7 @@ void main() {
|
||||
decodeEdit(packedEdit, sdfFirst, sdfCount, invert, rgbaBlendMode, softEdge, sdfSmooth);
|
||||
applyRgbaDisplaceEdit(sdfTexture, numSdfs, sdfFirst, sdfCount, pos, sdfSmooth, softEdge, invert, rgbaBlendMode, rgba);
|
||||
}
|
||||
`);function yu(t,A,e,s){return new V({inTypes:{gsplat:AA,sdfArray:to,numEdits:"int",rgbaDisplaceEdits:"uvec4"},outTypes:{gsplat:AA},globals:()=>[eo,so],inputs:{gsplat:t,sdfArray:A,numEdits:e,rgbaDisplaceEdits:s},statements:({inputs:i,outputs:r})=>{const{sdfArray:a,numEdits:o,rgbaDisplaceEdits:g}=i,{gsplat:l}=r;return YA(`
|
||||
`);function Qu(t,A,e,s){return new V({inTypes:{gsplat:AA,sdfArray:Wa,numEdits:"int",rgbaDisplaceEdits:"uvec4"},outTypes:{gsplat:AA},globals:()=>[Ao,to],inputs:{gsplat:t,sdfArray:A,numEdits:e,rgbaDisplaceEdits:s},statements:({inputs:i,outputs:r})=>{const{sdfArray:a,numEdits:o,rgbaDisplaceEdits:g}=i,{gsplat:l}=r;return YA(`
|
||||
${l} = ${i.gsplat};
|
||||
if (isGsplatActive(${l}.flags)) {
|
||||
for (int editIndex = 0; editIndex < ${o}; ++editIndex) {
|
||||
@@ -376,7 +376,7 @@ void main() {
|
||||
);
|
||||
}
|
||||
}
|
||||
`)}}).outputs.gsplat}const mt=new Float32Array(1);class no{constructor(A){this.modifier=A,this.cache=new Map}apply(A){let e=this.cache.get(A);return e||(e=FA({index:"int"},{gsplat:AA},({index:s})=>{const{gsplat:n}=A.apply({index:s});return this.modifier.apply({gsplat:n})}),this.cache.set(A,e)),e}}class ht{constructor(){this.scale=new Et({value:Number.NEGATIVE_INFINITY}),this.rotate=new Gt({value:new I.Quaternion(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}),this.translate=new Nt({value:new I.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)})}apply(A){return ma(A,{scale:this.scale,rotate:this.rotate,translate:this.translate})}applyDir(A){return xa(A,{rotate:this.rotate})}applyGsplat(A){return es(A,{scale:this.scale,rotate:this.rotate,translate:this.translate})}updateFromMatrix(A){const e=new I.Vector3,s=new I.Quaternion,n=new I.Vector3;A.decompose(n,s,e);const i=(e.x+e.y+e.z)/3;let r=!1;return i!==this.scale.value&&(this.scale.value=i,r=!0),n.equals(this.translate.value)||(this.translate.value.copy(n),r=!0),s.equals(this.rotate.value)||(this.rotate.value.copy(s),r=!0),r}update(A){return A.updateMatrixWorld(),this.updateFromMatrix(A.matrixWorld)}}class kt extends I.Object3D{constructor({numSplats:A,generator:e,construct:s,update:n}){if(super(),this.numSplats=A??0,this.generator=e,this.frameUpdate=n,this.version=0,s){const i=s(this);Object.assign(this,i)}}updateVersion(){this.version+=1}set needsUpdate(A){A&&this.updateVersion()}}const nt=class nt extends kt{constructor(A={}){const e=new ht,s=new ht,n=new ht,i=new ht,r=new Gt({value:new I.Vector4(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY)}),a=new Et({value:0}),o=new Et({value:0}),g={transform:e,viewToWorld:s,worldToView:n,viewToObject:i,recolor:r,time:a,deltaTime:o};if(super({update:({time:l,deltaTime:c,viewToWorld:u,globalEdits:h})=>this.update({time:l,deltaTime:c,viewToWorld:u,globalEdits:h})}),this.isInitialized=!1,this.recolor=new I.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 HA,this.packedSplats.splatEncoding=A.splatEncoding??{...xe},this.numSplats=this.packedSplats.numSplats,this.editable=A.editable??!0,this.onFrame=A.onFrame,this.context=g,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 l=A.onLoad(this);l instanceof Promise&&await l}return this});else if(this.isInitialized=!0,this.initialized=Promise.resolve(this),A.onLoad){const l=A.onLoad(this);l instanceof Promise&&(this.initialized=l.then(()=>this))}}async asyncInitialize(A){const{url:e,fileBytes:s,fileType:n,fileName:i,maxSplats:r,constructSplats:a,splatEncoding:o}=A;if(e||s||a){const g={url:e,fileBytes:s,fileType:n,fileName:i,maxSplats:r,construct:a,splatEncoding:o};this.packedSplats.reinitialize(g)}this.packedSplats&&(await this.packedSplats.initialized,this.numSplats=this.packedSplats.numSplats,this.updateGenerator())}static async staticInitialize(){await Rs(),nt.isStaticInitialized=!0}pushSplat(A,e,s,n,i){this.packedSplats.pushSplat(A,e,s,n,i)}forEachSplat(A){this.packedSplats.forEachSplat(A)}dispose(){this.packedSplats.dispose()}getBoundingBox(A=!0){if(!this.initialized)throw new Error("Cannot get bounding box before SplatMesh is initialized");const e=new I.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s=new I.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),n=new I.Vector3,i=[-1,1];return this.packedSplats.forEachSplat((a,o,g,l,c,u)=>{if(A)e.min(o),s.max(o);else for(const h of i)for(const E of i)for(const C of i)n.set(h*g.x,E*g.y,C*g.z),n.applyQuaternion(l),n.add(o),e.min(n),s.max(n)}),new I.Box3(e,s)}constructGenerator(A){const{transform:e,viewToObject:s,recolor:n}=A,i=FA({index:"int"},{gsplat:AA},({index:r})=>{if(!r)throw new Error("index is undefined");let a=Ft(this.packedSplats.dyno,r);if(this.maxSh>=1){const{sh1Texture:g,sh2Texture:l,sh3Texture:c}=this.ensureShTextures();if(g){let u=function(f,d){const{x:w,y:D}=pt(d).outputs,x=rA(EA(w,D),J("float",.5)),y=rA(ft(D,w),J("float",.5));return EA(x,rA(f,y))};const h=s.translate,{center:E}=Bt(a).outputs,C=zr(ft(E,h)),B=Su(a,g,C);let Q=u(B,this.packedSplats.dynoSh1MinMax);if(this.maxSh>=2&&l){const f=Du(a,l,C);Q=EA(Q,u(f,this.packedSplats.dynoSh2MinMax))}if(this.maxSh>=3&&c){const f=Mu(a,c,C);Q=EA(Q,u(f,this.packedSplats.dynoSh3MinMax))}let{rgba:p}=Bt(a).outputs;p=EA(p,Hr(Q,J("float",0))),a=at({gsplat:a,rgba:p})}}if(this.splatRgba){const g=pu(this.splatRgba.dyno,r);a=at({gsplat:a,
Line truncated
|
||||
`)}}).outputs.gsplat}const mt=new Float32Array(1);class eo{constructor(A){this.modifier=A,this.cache=new Map}apply(A){let e=this.cache.get(A);return e||(e=FA({index:"int"},{gsplat:AA},({index:s})=>{const{gsplat:n}=A.apply({index:s});return this.modifier.apply({gsplat:n})}),this.cache.set(A,e)),e}}class ht{constructor(){this.scale=new Et({value:Number.NEGATIVE_INFINITY}),this.rotate=new Gt({value:new I.Quaternion(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}),this.translate=new Nt({value:new I.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)})}apply(A){return ya(A,{scale:this.scale,rotate:this.rotate,translate:this.translate})}applyDir(A){return wa(A,{rotate:this.rotate})}applyGsplat(A){return As(A,{scale:this.scale,rotate:this.rotate,translate:this.translate})}updateFromMatrix(A){const e=new I.Vector3,s=new I.Quaternion,n=new I.Vector3;A.decompose(n,s,e);const i=(e.x+e.y+e.z)/3;let r=!1;return i!==this.scale.value&&(this.scale.value=i,r=!0),n.equals(this.translate.value)||(this.translate.value.copy(n),r=!0),s.equals(this.rotate.value)||(this.rotate.value.copy(s),r=!0),r}update(A){return A.updateMatrixWorld(),this.updateFromMatrix(A.matrixWorld)}}class kt extends I.Object3D{constructor({numSplats:A,generator:e,construct:s,update:n}){if(super(),this.numSplats=A??0,this.generator=e,this.frameUpdate=n,this.version=0,s){const i=s(this);Object.assign(this,i)}}updateVersion(){this.version+=1}set needsUpdate(A){A&&this.updateVersion()}}const st=class st extends kt{constructor(A={}){const e=new ht,s=new ht,n=new ht,i=new ht,r=new Gt({value:new I.Vector4(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY)}),a=new Et({value:0}),o=new Et({value:0}),g={transform:e,viewToWorld:s,worldToView:n,viewToObject:i,recolor:r,time:a,deltaTime:o};if(super({update:({time:l,deltaTime:c,viewToWorld:u,globalEdits:h})=>this.update({time:l,deltaTime:c,viewToWorld:u,globalEdits:h})}),this.isInitialized=!1,this.recolor=new I.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 HA,this.packedSplats.splatEncoding=A.splatEncoding??{...xe},this.numSplats=this.packedSplats.numSplats,this.editable=A.editable??!0,this.onFrame=A.onFrame,this.context=g,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 l=A.onLoad(this);l instanceof Promise&&await l}return this});else if(this.isInitialized=!0,this.initialized=Promise.resolve(this),A.onLoad){const l=A.onLoad(this);l instanceof Promise&&(this.initialized=l.then(()=>this))}this.add(Du())}async asyncInitialize(A){const{url:e,fileBytes:s,fileType:n,fileName:i,maxSplats:r,constructSplats:a,splatEncoding:o}=A;if(e||s||a){const g={url:e,fileBytes:s,fileType:n,fileName:i,maxSplats:r,construct:a,splatEncoding:o};this.packedSplats.reinitialize(g)}this.packedSplats&&(await this.packedSplats.initialized,this.numSplats=this.packedSplats.numSplats,this.updateGenerator())}static async staticInitialize(){await Us(),st.isStaticInitialized=!0}pushSplat(A,e,s,n,i){this.packedSplats.pushSplat(A,e,s,n,i)}forEachSplat(A){this.packedSplats.forEachSplat(A)}dispose(){this.packedSplats.dispose()}getBoundingBox(A=!0){if(!this.initialized)throw new Error("Cannot get bounding box before SplatMesh is initialized");const e=new I.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s=new I.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),n=new I.Vector3,i=[-1,1];return this.packedSplats.forEachSplat((a,o,g,l,c,u)=>{if(A)e.min(o),s.max(o);else for(const h of i)for(const E of i)for(const C of i)n.set(h*g.x,E*g.y,C*g.z),n.applyQuaternion(l),n.add(o),e.min(n),s.max(n)}),new I.Box3(e,s)}constructGenerator(A){const{transform:e,viewToObject:s,recolor:n}=A,i=FA({index:"int"},{gsplat:AA},({index:r})=>{if(!r)throw new Error("index is undefined");let a=Ft(this.packedSplats.dyno,r);if(this.maxSh>=1){const{sh1Texture:g,sh2Texture:l,sh3Texture:c}=this.ensureShTextures();if(g){let u=function(f,d){const{x:w,y:D}=pt(d).outputs,x=rA(EA(w,D),J("float",.5)),y=rA(ft(D,w),J("float",.5));return EA(x,rA(f,y))};const h=s.translate,{center:E}=Bt(a).outputs,C=_r(ft(E,h)),B=yu(a,g,C);let Q=u(B,this.packedSplats.dynoSh1MinMax);if(this.maxSh>=2&&l){const f=wu(a,l,C);Q=EA(Q,u(f,this.packedSplats.dynoSh2MinMax))}if(this.maxSh>=3&&c){const f=mu(a,c,C);Q=EA(Q,u(f,this.packedSplats.dynoSh3MinMax))}let{rgba:p}=Bt(a).outputs;p=EA(p,Lr(Q,J("float",0))),a=rt({gsplat:a,rgba:p})}}if(this.splatRgba){const g=Cu(this.splatRgba.dyno,r);a
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);
|
||||
}
|
||||
`),mu=CA(`
|
||||
`),fu=CA(`
|
||||
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));
|
||||
}
|
||||
`),xu=CA(`
|
||||
`),du=CA(`
|
||||
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 Su(t,A,e){return se({inTypes:{gsplat:AA,sh1:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:t,sh1:A,viewDir:e},globals:()=>[NA,wu],statements:({inputs:s,outputs:n})=>YA(`
|
||||
`);function yu(t,A,e){return se({inTypes:{gsplat:AA,sh1:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:t,sh1:A,viewDir:e},globals:()=>[NA,pu],statements:({inputs:s,outputs:n})=>YA(`
|
||||
if (isGsplatActive(${s.gsplat}.flags)) {
|
||||
${n.rgb} = evaluateSH1(${s.gsplat}, ${s.sh1}, ${s.viewDir});
|
||||
} else {
|
||||
${n.rgb} = vec3(0.0);
|
||||
}
|
||||
`)}).outputs.rgb}function Du(t,A,e){return se({inTypes:{gsplat:AA,sh2:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:t,sh2:A,viewDir:e},globals:()=>[NA,mu],statements:({inputs:s,outputs:n})=>YA(`
|
||||
`)}).outputs.rgb}function wu(t,A,e){return se({inTypes:{gsplat:AA,sh2:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:t,sh2:A,viewDir:e},globals:()=>[NA,fu],statements:({inputs:s,outputs:n})=>YA(`
|
||||
if (isGsplatActive(${s.gsplat}.flags)) {
|
||||
${n.rgb} = evaluateSH2(${s.gsplat}, ${s.sh2}, ${s.viewDir});
|
||||
} else {
|
||||
${n.rgb} = vec3(0.0);
|
||||
}
|
||||
`)}).outputs.rgb}function Mu(t,A,e){return se({inTypes:{gsplat:AA,sh3:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:t,sh3:A,viewDir:e},globals:()=>[NA,xu],statements:({inputs:s,outputs:n})=>YA(`
|
||||
`)}).outputs.rgb}function mu(t,A,e){return se({inTypes:{gsplat:AA,sh3:"usampler2DArray",viewDir:"vec3"},outTypes:{rgb:"vec3"},inputs:{gsplat:t,sh3:A,viewDir:e},globals:()=>[NA,du],statements:({inputs:s,outputs:n})=>YA(`
|
||||
if (isGsplatActive(${s.gsplat}.flags)) {
|
||||
${n.rgb} = evaluateSH3(${s.gsplat}, ${s.sh3}, ${s.viewDir});
|
||||
} else {
|
||||
${n.rgb} = vec3(0.0);
|
||||
}
|
||||
`)}).outputs.rgb}const ps=["char","uchar","short","ushort","int","uint","float","double"],Mt=class Mt{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 e=new ReadableStream({start:r=>{r.enqueue(this.fileBytes.slice(0,65536)),r.close()}}).pipeThrough(new TextDecoderStream).getReader();this.header="";const s=`end_header
|
||||
`)}).outputs.rgb}const xu=new I.BufferGeometry,Su=new I.ShaderMaterial;function Du(){const t=new I.Mesh(xu,Su);return t.frustumCulled=!1,t.onBeforeRender=function(A,e){if(!e.isScene){this.removeFromParent();return}let s=!1;e.traverse(n=>{n instanceof Wt&&(s=!0)}),s||e.add(new Wt({renderer:A})),this.removeFromParent()},t}const Es=["char","uchar","short","ushort","int","uint","float","double"],Mt=class Mt{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 e=new ReadableStream({start:r=>{r.enqueue(this.fileBytes.slice(0,65536)),r.close()}}).pipeThrough(new TextDecoderStream).getReader();this.header="";const s=`end_header
|
||||
`;for(;;){const{value:r,done:a}=await e.read();if(a)throw new Error("Failed to read header");this.header+=r;const o=this.header.indexOf(s);if(o>=0){this.header=this.header.slice(0,o+s.length);break}}const n=new TextEncoder().encode(this.header).length;this.data=new DataView(this.fileBytes.buffer,n),this.elements={};let i=null;this.comments=[],this.header.trim().split(`
|
||||
`).forEach((r,a)=>{const o=r.trim();if(a===0){if(o!=="ply")throw new Error("Invalid PLY header");return}if(o.length===0)return;const g=o.split(" ");switch(g[0]){case"format":if(g[1]==="binary_little_endian")this.littleEndian=!0;else if(g[1]==="binary_big_endian")this.littleEndian=!1;else throw new Error(`Unsupported PLY format: ${g[1]}`);if(g[2]!=="1.0")throw new Error(`Unsupported PLY version: ${g[2]}`);break;case"end_header":break;case"comment":this.comments.push(o.slice(8));break;case"element":{const l=g[1];i={name:l,count:Number.parseInt(g[2]),properties:{}},this.elements[l]=i;break}case"property":if(i==null)throw new Error("Property must be inside an element");g[1]==="list"?i.properties[g[4]]={isList:!0,type:g[3],countType:g[2]}:i.properties[g[2]]={isList:!1,type:g[1]};break}}),this.elements.vertex&&(this.numSplats=this.elements.vertex.count)}parseData(A){let e=0;const s=this.data;if(s==null)throw new Error("No data to parse");for(const n in this.elements){const i=this.elements[n],{count:r,properties:a}=i,o=Fu(a),g=Nu(a,this.littleEndian),l=A(i)??(()=>{});for(let c=0;c<r;c++)e=g(s,e,o),l(c,o)}}parseSplats(A,e){if(this.elements.vertex==null)throw new Error("No vertex element found");let s=!1;const n=[];let i=0,r=[],a=[],o=[],g,l,c;function u(){const Q=bu[i];r=new Array(3).fill(null).flatMap((p,f)=>[0,1,2].map((d,w)=>f+w*Q/3)),a=new Array(5).fill(null).flatMap((p,f)=>[0,1,2].map((d,w)=>3+f+w*Q/3)),o=new Array(7).fill(null).flatMap((p,f)=>[0,1,2].map((d,w)=>8+f+w*Q/3)),g=i>=1?new Float32Array(3*3):void 0,l=i>=2?new Float32Array(5*3):void 0,c=i>=3?new Float32Array(7*3):void 0}function h(Q,p){if(!g)throw new Error("Missing sh1");const f=p.f_rest;for(let d=0;d<r.length;d++)g[d]=f[r[d]]*8/255-4;if(l)for(let d=0;d<a.length;d++)l[d]=f[a[d]]*8/255-4;if(c)for(let d=0;d<o.length;d++)c[d]=f[o[d]]*8/255-4;e==null||e(Q,g,l,c)}function E(Q){const{min_x:p,min_y:f,min_z:d,max_x:w,max_y:D,max_z:x,min_scale_x:y,min_scale_y:m,min_scale_z:k,max_scale_x:M,max_scale_y:S,max_scale_z:U}=Q.properties;if(!p||!f||!d||!w||!D||!x||!y||!m||!k||!M||!S||!U)throw new Error("Missing PLY chunk properties");return s=!0,(F,b)=>{const{min_x:T,min_y:R,min_z:X,max_x:_,max_y:eA,max_z:q,min_scale_x:O,min_scale_y:L,min_scale_z:j,max_scale_x:P,max_scale_y:W,max_scale_z:G,min_r:dA,min_g:lA,min_b:yA,max_r:wA,max_g:SA,max_b:BA}=b;n.push({min_x:T,min_y:R,min_z:X,max_x:_,max_y:eA,max_z:q,min_scale_x:O,min_scale_y:L,min_scale_z:j,max_scale_x:P,max_scale_y:W,max_scale_z:G,min_r:dA,min_g:lA,min_b:yA,max_r:wA,max_g:SA,max_b:BA})}}function C(Q){if(e&&Q.name==="sh")return i=Pe(Q.properties),u(),h;if(Q.name!=="vertex")return null;const{packed_position:p,packed_rotation:f,packed_scale:d,packed_color:w}=Q.properties;if(!p||!f||!d||!w)throw new Error("Missing PLY properties: packed_position, packed_rotation, packed_scale, packed_color");const D=Math.sqrt(2);return(x,y)=>{const m=n[x>>>8];if(m==null)throw new Error("Missing PLY chunk");const{min_x:k,min_y:M,min_z:S,max_x:U,max_y:F,max_z:b,min_scale_x:T,min_scale_y:R,min_scale_z:X,max_scale_x:_,max_scale_y:eA,max_scale_z:q,min_r:O,min_g:L,min_b:j,max_r:P,max_g:W,max_b:G}=m,{packed_position:dA,packed_rotation:lA,packed_scale:yA,packed_color:wA}=y,SA=(dA>>>21&2047)/2047*(U-k)+k,BA=(dA>>>11&1023)/1023*(F-M)+M,JA=(dA&2047)/2047*(b-S)+S,DA=((lA>>>20&1023)/1023-.5)*D,WA=((lA>>>10&1023)/1023-.5)*D,At=((lA&1023)/1023-.5)*D,Y=Math.sqrt(Math.max(0,1-DA*DA-WA*WA-At*At)),MA=lA>>>30,IA=MA===0?DA:MA===1?Y:WA,Yt=MA<=1?WA:MA===2?Y:At,re=MA<=2?At:Y,vA=MA===0?Y:DA,z=Math.exp((yA>>>21&2047)/2047*(_-T)+T),XA=Math.exp((yA>>>11&1023)/1023*(eA-R)+R),De=Math.exp((yA&2047)/2047*(q-X)+X),Me=(wA>>>24&255)/255*((P??1)-(O??0))+(O??0),ve=(wA>>>16&255)/255*((W??1)-(L??0))+(L??0),be=(wA>>>8&255)/255*((G??1)-(j??0))+(j??0),Fe=(wA&255)/255;A(x,SA,BA,JA,z,XA,De,IA,Yt,re,vA,Fe,Me,ve,be)}}const B=Q=>{if(Q.name==="chunk")return E(Q);if(s)return C(Q);if(Q.name!=="vertex")return null;const{x:p,y:f,z:d,scale_0:w,scale_1:D,scale_2:x,rot_0:y,rot_1:m,rot_2:k,rot_3:M,opacity:S,f_dc_0:U,f_dc_1:F,f_dc_2:b,red:T,green:R,blue:X,alpha:_}=Q.properties;if(!p||!f||!d)throw new Error("Missing PLY properties: x, y, z");const eA=w&&D&&x,q=y&&m&&k&&M,O=_!=null?ce[_.type]:1,L=T!=null?ce[T.type]:1,j=R!=null?ce[R.type]:1,P=X!=null?ce[X.type]:1;return i=Pe(Q.properties),u(),(W,G)=>{const dA=eA?Math.exp(G.scale_0):Mt.defaultPointScale,lA=eA?Math.exp(G.scale_1):Mt.defaultPointScale,yA=eA?Math.exp(G.scale_2):Mt.defaultPointScale,wA=q?G.rot_1:0,SA=q?G.rot_2:0,BA=q?G.rot_3:0,JA=q?G.rot_0:1,DA=S!=null?1/(1+Math.exp(-G.opacity)):_!=null?G.alpha/O:1,WA=U!=null?G.f_dc_0*oe+.5:T!=null?G.red/L:1,At=F!=null?G.f_dc_1*oe+.5:R!=null?G.green/j:1,Y=b!=null?G.f_dc_2*oe+.5:X!=null?G.blue/P:1;if(A(W,G.x,G.y,G.z,dA,lA,yA,wA,SA,BA,JA,DA,WA,At,Y),e&&g){const MA=G.f_rest;if(g)for(let IA=0;IA<r.length;IA++)g[IA]=MA[r[IA]];if(l)for(let IA=0;IA<a.length;IA++)l[IA]=MA[a[IA]];if(c)for(let IA=0;IA<o.length;IA++)c[IA]=MA[o[IA]];e(W,g,l,c)}}};this.parseData(B)}injectRgba(A){let e=0;const s=this.data;if(s
Line truncated
|
||||
`).forEach((r,a)=>{const o=r.trim();if(a===0){if(o!=="ply")throw new Error("Invalid PLY header");return}if(o.length===0)return;const g=o.split(" ");switch(g[0]){case"format":if(g[1]==="binary_little_endian")this.littleEndian=!0;else if(g[1]==="binary_big_endian")this.littleEndian=!1;else throw new Error(`Unsupported PLY format: ${g[1]}`);if(g[2]!=="1.0")throw new Error(`Unsupported PLY version: ${g[2]}`);break;case"end_header":break;case"comment":this.comments.push(o.slice(8));break;case"element":{const l=g[1];i={name:l,count:Number.parseInt(g[2]),properties:{}},this.elements[l]=i;break}case"property":if(i==null)throw new Error("Property must be inside an element");g[1]==="list"?i.properties[g[4]]={isList:!0,type:g[3],countType:g[2]}:i.properties[g[2]]={isList:!1,type:g[1]};break}}),this.elements.vertex&&(this.numSplats=this.elements.vertex.count)}parseData(A){let e=0;const s=this.data;if(s==null)throw new Error("No data to parse");for(const n in this.elements){const i=this.elements[n],{count:r,properties:a}=i,o=bu(a),g=Fu(a,this.littleEndian),l=A(i)??(()=>{});for(let c=0;c<r;c++)e=g(s,e,o),l(c,o)}}parseSplats(A,e){if(this.elements.vertex==null)throw new Error("No vertex element found");let s=!1;const n=[];let i=0,r=[],a=[],o=[],g,l,c;function u(){const Q=vu[i];r=new Array(3).fill(null).flatMap((p,f)=>[0,1,2].map((d,w)=>f+w*Q/3)),a=new Array(5).fill(null).flatMap((p,f)=>[0,1,2].map((d,w)=>3+f+w*Q/3)),o=new Array(7).fill(null).flatMap((p,f)=>[0,1,2].map((d,w)=>8+f+w*Q/3)),g=i>=1?new Float32Array(3*3):void 0,l=i>=2?new Float32Array(5*3):void 0,c=i>=3?new Float32Array(7*3):void 0}function h(Q,p){if(!g)throw new Error("Missing sh1");const f=p.f_rest;for(let d=0;d<r.length;d++)g[d]=f[r[d]]*8/255-4;if(l)for(let d=0;d<a.length;d++)l[d]=f[a[d]]*8/255-4;if(c)for(let d=0;d<o.length;d++)c[d]=f[o[d]]*8/255-4;e==null||e(Q,g,l,c)}function E(Q){const{min_x:p,min_y:f,min_z:d,max_x:w,max_y:D,max_z:x,min_scale_x:y,min_scale_y:m,min_scale_z:k,max_scale_x:M,max_scale_y:S,max_scale_z:U}=Q.properties;if(!p||!f||!d||!w||!D||!x||!y||!m||!k||!M||!S||!U)throw new Error("Missing PLY chunk properties");return s=!0,(F,b)=>{const{min_x:T,min_y:R,min_z:X,max_x:_,max_y:eA,max_z:q,min_scale_x:O,min_scale_y:L,min_scale_z:j,max_scale_x:P,max_scale_y:W,max_scale_z:G,min_r:dA,min_g:lA,min_b:yA,max_r:wA,max_g:SA,max_b:BA}=b;n.push({min_x:T,min_y:R,min_z:X,max_x:_,max_y:eA,max_z:q,min_scale_x:O,min_scale_y:L,min_scale_z:j,max_scale_x:P,max_scale_y:W,max_scale_z:G,min_r:dA,min_g:lA,min_b:yA,max_r:wA,max_g:SA,max_b:BA})}}function C(Q){if(e&&Q.name==="sh")return i=Pe(Q.properties),u(),h;if(Q.name!=="vertex")return null;const{packed_position:p,packed_rotation:f,packed_scale:d,packed_color:w}=Q.properties;if(!p||!f||!d||!w)throw new Error("Missing PLY properties: packed_position, packed_rotation, packed_scale, packed_color");const D=Math.sqrt(2);return(x,y)=>{const m=n[x>>>8];if(m==null)throw new Error("Missing PLY chunk");const{min_x:k,min_y:M,min_z:S,max_x:U,max_y:F,max_z:b,min_scale_x:T,min_scale_y:R,min_scale_z:X,max_scale_x:_,max_scale_y:eA,max_scale_z:q,min_r:O,min_g:L,min_b:j,max_r:P,max_g:W,max_b:G}=m,{packed_position:dA,packed_rotation:lA,packed_scale:yA,packed_color:wA}=y,SA=(dA>>>21&2047)/2047*(U-k)+k,BA=(dA>>>11&1023)/1023*(F-M)+M,JA=(dA&2047)/2047*(b-S)+S,DA=((lA>>>20&1023)/1023-.5)*D,jA=((lA>>>10&1023)/1023-.5)*D,WA=((lA&1023)/1023-.5)*D,Y=Math.sqrt(Math.max(0,1-DA*DA-jA*jA-WA*WA)),MA=lA>>>30,IA=MA===0?DA:MA===1?Y:jA,Yt=MA<=1?jA:MA===2?Y:WA,re=MA<=2?WA:Y,vA=MA===0?Y:DA,z=Math.exp((yA>>>21&2047)/2047*(_-T)+T),ZA=Math.exp((yA>>>11&1023)/1023*(eA-R)+R),De=Math.exp((yA&2047)/2047*(q-X)+X),Me=(wA>>>24&255)/255*((P??1)-(O??0))+(O??0),ve=(wA>>>16&255)/255*((W??1)-(L??0))+(L??0),be=(wA>>>8&255)/255*((G??1)-(j??0))+(j??0),Fe=(wA&255)/255;A(x,SA,BA,JA,z,ZA,De,IA,Yt,re,vA,Fe,Me,ve,be)}}const B=Q=>{if(Q.name==="chunk")return E(Q);if(s)return C(Q);if(Q.name!=="vertex")return null;const{x:p,y:f,z:d,scale_0:w,scale_1:D,scale_2:x,rot_0:y,rot_1:m,rot_2:k,rot_3:M,opacity:S,f_dc_0:U,f_dc_1:F,f_dc_2:b,red:T,green:R,blue:X,alpha:_}=Q.properties;if(!p||!f||!d)throw new Error("Missing PLY properties: x, y, z");const eA=w&&D&&x,q=y&&m&&k&&M,O=_!=null?ce[_.type]:1,L=T!=null?ce[T.type]:1,j=R!=null?ce[R.type]:1,P=X!=null?ce[X.type]:1;return i=Pe(Q.properties),u(),(W,G)=>{const dA=eA?Math.exp(G.scale_0):Mt.defaultPointScale,lA=eA?Math.exp(G.scale_1):Mt.defaultPointScale,yA=eA?Math.exp(G.scale_2):Mt.defaultPointScale,wA=q?G.rot_1:0,SA=q?G.rot_2:0,BA=q?G.rot_3:0,JA=q?G.rot_0:1,DA=S!=null?1/(1+Math.exp(-G.opacity)):_!=null?G.alpha/O:1,jA=U!=null?G.f_dc_0*oe+.5:T!=null?G.red/L:1,WA=F!=null?G.f_dc_1*oe+.5:R!=null?G.green/j:1,Y=b!=null?G.f_dc_2*oe+.5:X!=null?G.blue/P:1;if(A(W,G.x,G.y,G.z,dA,lA,yA,wA,SA,BA,JA,DA,jA,WA,Y),e&&g){const MA=G.f_rest;if(g)for(let IA=0;IA<r.length;IA++)g[IA]=MA[r[IA]];if(l)for(let IA=0;IA<a.length;IA++)l[IA]=MA[a[IA]];if(c)for(let IA=0;IA<o.length;IA++)c[IA]=MA[o[IA]];e(W,g,l,c)}}};this.parseData(B)}injectRgba(A){let e=0;const s=this.data;if(s
Line truncated
|
||||
item.f_rest[${a}] = PARSE_FIELD['${i.type}'](data, offset, ${A});
|
||||
offset += ${zA[i.type]};
|
||||
`)}else i.isList?e.push(`
|
||||
@@ -526,7 +526,7 @@ void main() {
|
||||
item['${n}'] = PARSE_FIELD['${i.type}'](data, offset, ${A});
|
||||
offset += ${zA[i.type]};
|
||||
`)}e.push("return offset;");const s=new Function("data","offset","item","PARSE_FIELD",e.join(`
|
||||
`));return(n,i,r)=>s(n,i,r,St)}function Ru(t,A){const e=[];for(const[s,n]of Object.entries(t)){const i=s.match(gs);if(i){const r=+i[1];e.push((a,o,g)=>(g.f_rest[r]=St[n.type](a,o,A),o+zA[n.type]))}else n.isList?e.push((r,a,o)=>{const g=o[s];g.length=St[n.countType](r,a,A);let l=a+zA[n.countType];for(let c=0;c<g.length;c++)g[c]=St[n.type](r,l,A),l+=zA[n.type];return l}):e.push((r,a,o)=>(o[s]=St[n.type](r,a,A),a+zA[n.type]))}return(s,n,i)=>{let r=n;for(let a=0;a<e.length;a++)r=e[a](s,r,i);return r}}function Pe(t){let A=0;for(;t[`f_rest_${A}`];)A+=1;const e=vu[A];if(e==null)throw new Error(`Unsupported number of SH coefficients: ${A}`);return e}const io='(function(){"use strict";let pA;const ie=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&ie.decode();let OA=null;function ts(){return(OA===null||OA.byteLength===0)&&(OA=new Uint8Array(pA.memory.buffer)),OA}function es(s,A){return s=s>>>0,ie.decode(ts().subarray(s,s+A))}function ss(s,A,t){return pA.sort_splats(s,A,t)>>>0}function is(s,A,t){return pA.sort32_splats(s,A,t)>>>0}async function ns(s,A){if(typeof Response=="function"&&s instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(s,A)}catch(e){if(s.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n",e);else throw e}const t=await s.arrayBuffer();return await WebAssembly.instantiate(t,A)}else{const t=await WebAssembly.instantiate(s,A);return t instanceof WebAssembly.Instance?{instance:t,module:s}:t}}function gs(){const s={};return s.wbg={},s.wbg.__wbg_buffer_609cc3eee51ed158=function(A){return A.buffer},s.wbg.__wbg_length_3b4f022188ae8db6=function(A){return A.length},s.wbg.__wbg_length_6ca527665d89694d=function(A){return A.length},s.wbg.__wbg_length_8cfd2c6409af88ad=function(A){return A.length},s.wbg.__wbg_new_9fee97a409b32b68=function(A){return new Uint16Array(A)},s.wbg.__wbg_new_e3b321dcfef89fc7=function(A){return new Uint32Array(A)},s.wbg.__wbg_newwithbyteoffsetandlength_e6b7e69acd4c7354=function(A,t,e){return new Float32Array(A,t>>>0,e>>>0)},s.wbg.__wbg_newwithbyteoffsetandlength_f1dead44d1fc7212=function(A,t,e){return new Uint32Array(A,t>>>0,e>>>0)},s.wbg.__wbg_newwithlength_5a5efe313cfd59f1=function(A){return new Float32Array(A>>>0)},s.wbg.__wbg_set_10bad9bee0e9c58b=function(A,t,e){A.set(t,e>>>0)},s.wbg.__wbg_set_d23661d19148b229=function(A,t,e){A.set(t,e>>>0)},s.wbg.__wbg_set_f4f1f0daa30696fc=function(A,t,e){A.set(t,e>>>0)},s.wbg.__wbg_subarray_3aaeec89bb2544f0=function(A,t,e){return A.subarray(t>>>0,e>>>0)},s.wbg.__wbg_subarray_769e1e0f81bb259b=function(A,t,e){return A.subarray(t>>>0,e>>>0)},s.wbg.__wbindgen_init_externref_table=function(){const A=pA.__wbindgen_export_0,t=A.grow(4);A.set(0,void 0),A.set(t+0,void 0),A.set(t+1,null),A.set(t+2,!0),A.set(t+3,!1)},s.wbg.__wbindgen_memory=function(){return pA.memory},s.wbg.__wbindgen_throw=function(A,t){throw new Error(es(A,t))},s}function rs(s,A){return pA=s.exports,ne.__wbindgen_wasm_module=A,OA=null,pA.__wbindgen_start(),pA}async function ne(s){if(pA!==void 0)return pA;typeof s<"u"&&(Object.getPrototypeOf(s)===Object.prototype?{module_or_path:s}=s:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof s>"u"&&(s=new URL("data:application/wasm;base64,AGFzbQEAAAABzAEeYAJ/fwF/YAJ/fwBgA39/fwF/YAN/f38AYAF/AX9gAX8AYANvf38Bb2AFf39/f38Bf2AFf39/f38AYAFvAW9gA29vfwBgAW8Bf2AAAGAAAX9gBH9/f38AYAR/f39/AX9gA39vbwF/YAF/AW9gAAFvYAF9AX1gBn9/f39/fwBgDX19fX19fX19f29/fX0Bb2AGf39/f39/AX9gBX9/fX9/AGAEf31/fwBgBX9/fH9/AGAEf3x/fwBgBX9/fn9/AGAEf35/fwBgAn19AX0C8gQRA3diZx1fX3diZ19idWZmZXJfNjA5Y2MzZWVlNTFlZDE1OAAJA3diZxpfX3diZ19uZXdfOWZlZTk3YTQwOWIzMmI2OAAJA3diZxpfX3diZ19zZXRfZjRmMWYwZGFhMzA2OTZmYwAKA3diZx1fX3diZ19sZW5ndGhfOGNmZDJjNjQwOWFmODhhZAALA3diZzFfX3diZ19uZXd3aXRoYnl0ZW9mZnNldGFuZGxlbmd0aF9mMWRlYWQ0NGQxZmM3MjEyAAYDd2JnGl9fd2JnX25ld19lM2IzMjFkY2ZlZjg5ZmM3AAkDd2JnGl9fd2JnX3NldF9kMjM2NjFkMTkxNDhiMjI5AAoDd2JnHV9fd2JnX2xlbmd0aF82Y2E1Mjc2NjVkODk2OTRkAAsDd2JnMV9fd2JnX25ld3dpdGhieXRlb2Zmc2V0YW5kbGVuZ3RoX2U2YjdlNjlhY2Q0YzczNTQABgN3YmcaX193Ymdfc2V0XzEwYmFkOWJlZTBlOWM1OGIACgN3YmcdX193YmdfbGVuZ3RoXzNiNGYwMjIxODhhZThkYjYACwN3YmcfX193Ymdfc3ViYXJyYXlfNzY5ZTFlMGY4MWJiMjU5YgAGA3diZx9fX3diZ19zdWJhcnJheV8zYWFlZWM4OWJiMjU0NGYwAAYDd2JnJF9fd2JnX25ld3dpdGhsZW5ndGhfNWE1ZWZlMzEzY2ZkNTlmMQARA3diZxBfX3diaW5kZ2VuX3Rocm93AAEDd2JnEV9fd2JpbmRnZW5fbWVtb3J5ABIDd2JnH19fd2JpbmRnZW5faW5pdF9leHRlcm5yZWZfdGFibGUADANeXQQAAQcFAgMCEwEBAA0BAwEAAA0BAwgIAwEBBRQBAw4AAwEDAgwMAgABAQcDABUBFhcIGRsHBQ4CEBAFAx0FBA8CBAQEAA0AAAEBAQAAAAMBAgMBAAEAAAEAAAEEBAQJAnABLi5vAIABBQMBABEGCQF/AUGAgMAACwdiBgZtZW1vcnkCAAtzb3J0X3NwbGF0cwBJDXNvcnQzMl9zcGxhdHMASg5yYXljYXN0X3NwbGF0cwA+E19fd2JpbmRnZW5fZXhwb3J0XzABARBf
Line truncated
|
||||
`));return(n,i,r)=>s(n,i,r,St)}function Gu(t,A){const e=[];for(const[s,n]of Object.entries(t)){const i=s.match(os);if(i){const r=+i[1];e.push((a,o,g)=>(g.f_rest[r]=St[n.type](a,o,A),o+zA[n.type]))}else n.isList?e.push((r,a,o)=>{const g=o[s];g.length=St[n.countType](r,a,A);let l=a+zA[n.countType];for(let c=0;c<g.length;c++)g[c]=St[n.type](r,l,A),l+=zA[n.type];return l}):e.push((r,a,o)=>(o[s]=St[n.type](r,a,A),a+zA[n.type]))}return(s,n,i)=>{let r=n;for(let a=0;a<e.length;a++)r=e[a](s,r,i);return r}}function Pe(t){let A=0;for(;t[`f_rest_${A}`];)A+=1;const e=Mu[A];if(e==null)throw new Error(`Unsupported number of SH coefficients: ${A}`);return e}const so='(function(){"use strict";let pA;const ie=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&ie.decode();let OA=null;function ts(){return(OA===null||OA.byteLength===0)&&(OA=new Uint8Array(pA.memory.buffer)),OA}function es(s,A){return s=s>>>0,ie.decode(ts().subarray(s,s+A))}function ss(s,A,t){return pA.sort_splats(s,A,t)>>>0}function is(s,A,t){return pA.sort32_splats(s,A,t)>>>0}async function ns(s,A){if(typeof Response=="function"&&s instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(s,A)}catch(e){if(s.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n",e);else throw e}const t=await s.arrayBuffer();return await WebAssembly.instantiate(t,A)}else{const t=await WebAssembly.instantiate(s,A);return t instanceof WebAssembly.Instance?{instance:t,module:s}:t}}function gs(){const s={};return s.wbg={},s.wbg.__wbg_buffer_609cc3eee51ed158=function(A){return A.buffer},s.wbg.__wbg_length_3b4f022188ae8db6=function(A){return A.length},s.wbg.__wbg_length_6ca527665d89694d=function(A){return A.length},s.wbg.__wbg_length_8cfd2c6409af88ad=function(A){return A.length},s.wbg.__wbg_new_9fee97a409b32b68=function(A){return new Uint16Array(A)},s.wbg.__wbg_new_e3b321dcfef89fc7=function(A){return new Uint32Array(A)},s.wbg.__wbg_newwithbyteoffsetandlength_e6b7e69acd4c7354=function(A,t,e){return new Float32Array(A,t>>>0,e>>>0)},s.wbg.__wbg_newwithbyteoffsetandlength_f1dead44d1fc7212=function(A,t,e){return new Uint32Array(A,t>>>0,e>>>0)},s.wbg.__wbg_newwithlength_5a5efe313cfd59f1=function(A){return new Float32Array(A>>>0)},s.wbg.__wbg_set_10bad9bee0e9c58b=function(A,t,e){A.set(t,e>>>0)},s.wbg.__wbg_set_d23661d19148b229=function(A,t,e){A.set(t,e>>>0)},s.wbg.__wbg_set_f4f1f0daa30696fc=function(A,t,e){A.set(t,e>>>0)},s.wbg.__wbg_subarray_3aaeec89bb2544f0=function(A,t,e){return A.subarray(t>>>0,e>>>0)},s.wbg.__wbg_subarray_769e1e0f81bb259b=function(A,t,e){return A.subarray(t>>>0,e>>>0)},s.wbg.__wbindgen_init_externref_table=function(){const A=pA.__wbindgen_export_0,t=A.grow(4);A.set(0,void 0),A.set(t+0,void 0),A.set(t+1,null),A.set(t+2,!0),A.set(t+3,!1)},s.wbg.__wbindgen_memory=function(){return pA.memory},s.wbg.__wbindgen_throw=function(A,t){throw new Error(es(A,t))},s}function rs(s,A){return pA=s.exports,ne.__wbindgen_wasm_module=A,OA=null,pA.__wbindgen_start(),pA}async function ne(s){if(pA!==void 0)return pA;typeof s<"u"&&(Object.getPrototypeOf(s)===Object.prototype?{module_or_path:s}=s:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof s>"u"&&(s=new URL("data:application/wasm;base64,AGFzbQEAAAABzAEeYAJ/fwF/YAJ/fwBgA39/fwF/YAN/f38AYAF/AX9gAX8AYANvf38Bb2AFf39/f38Bf2AFf39/f38AYAFvAW9gA29vfwBgAW8Bf2AAAGAAAX9gBH9/f38AYAR/f39/AX9gA39vbwF/YAF/AW9gAAFvYAF9AX1gBn9/f39/fwBgDX19fX19fX19f29/fX0Bb2AGf39/f39/AX9gBX9/fX9/AGAEf31/fwBgBX9/fH9/AGAEf3x/fwBgBX9/fn9/AGAEf35/fwBgAn19AX0C8gQRA3diZx1fX3diZ19idWZmZXJfNjA5Y2MzZWVlNTFlZDE1OAAJA3diZxpfX3diZ19uZXdfOWZlZTk3YTQwOWIzMmI2OAAJA3diZxpfX3diZ19zZXRfZjRmMWYwZGFhMzA2OTZmYwAKA3diZx1fX3diZ19sZW5ndGhfOGNmZDJjNjQwOWFmODhhZAALA3diZzFfX3diZ19uZXd3aXRoYnl0ZW9mZnNldGFuZGxlbmd0aF9mMWRlYWQ0NGQxZmM3MjEyAAYDd2JnGl9fd2JnX25ld19lM2IzMjFkY2ZlZjg5ZmM3AAkDd2JnGl9fd2JnX3NldF9kMjM2NjFkMTkxNDhiMjI5AAoDd2JnHV9fd2JnX2xlbmd0aF82Y2E1Mjc2NjVkODk2OTRkAAsDd2JnMV9fd2JnX25ld3dpdGhieXRlb2Zmc2V0YW5kbGVuZ3RoX2U2YjdlNjlhY2Q0YzczNTQABgN3YmcaX193Ymdfc2V0XzEwYmFkOWJlZTBlOWM1OGIACgN3YmcdX193YmdfbGVuZ3RoXzNiNGYwMjIxODhhZThkYjYACwN3YmcfX193Ymdfc3ViYXJyYXlfNzY5ZTFlMGY4MWJiMjU5YgAGA3diZx9fX3diZ19zdWJhcnJheV8zYWFlZWM4OWJiMjU0NGYwAAYDd2JnJF9fd2JnX25ld3dpdGhsZW5ndGhfNWE1ZWZlMzEzY2ZkNTlmMQARA3diZxBfX3diaW5kZ2VuX3Rocm93AAEDd2JnEV9fd2JpbmRnZW5fbWVtb3J5ABIDd2JnH19fd2JpbmRnZW5faW5pdF9leHRlcm5yZWZfdGFibGUADANeXQQAAQcFAgMCEwEBAA0BAwEAAA0BAwgIAwEBBRQBAw4AAwEDAgwMAgABAQcDABUBFhcIGRsHBQ4CEBAFAx0FBA8CBAQEAA0AAAEBAQAAAAMBAgMBAAEAAAEAAAEEBAQJAnABLi5vAIABBQMBABEGCQF/AUGAgMAACwdiBgZtZW1vcnkCAAtzb3J0X3NwbGF0cwBJDXNvcnQzMl9zcGxhdHMASg5yYXljYXN0X3NwbGF0cwA+E19fd2JpbmRnZW5fZXhwb3J0XzABARBf
Line truncated
|
||||
precision highp int;
|
||||
precision highp sampler2D;
|
||||
precision highp usampler2D;
|
||||
@@ -561,7 +561,7 @@ void main() {
|
||||
} else {
|
||||
target = uvec4(0u, 0u, 0u, 0u);
|
||||
}
|
||||
}`;const xe={rgbMin:0,rgbMax:1,lnScaleMin:kA,lnScaleMax:TA,sh1Min:-1,sh1Max:1,sh2Min:-1,sh2Max:1,sh3Min:-1,sh3Max:1},iA=class iA{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 hs({packedSplats:this}),this.dynoRgbMinMaxLnScaleMinMax=new Gt({key:"rgbMinMaxLnScaleMinMax",value:new I.Vector4(0,1,kA,TA),update:e=>{var s,n,i,r;return e.set(((s=this.splatEncoding)==null?void 0:s.rgbMin)??0,((n=this.splatEncoding)==null?void 0:n.rgbMax)??1,((i=this.splatEncoding)==null?void 0:i.lnScaleMin)??kA,((r=this.splatEncoding)==null?void 0:r.lnScaleMax)??TA),e}}),this.dynoSh1MinMax=new qt({key:"sh1MinMax",value:new I.Vector2(-1,1),update:e=>{var s,n;return e.set(((s=this.splatEncoding)==null?void 0:s.sh1Min)??-1,((n=this.splatEncoding)==null?void 0:n.sh1Max)??1),e}}),this.dynoSh2MinMax=new qt({key:"sh2MinMax",value:new I.Vector2(-1,1),update:e=>{var s,n;return e.set(((s=this.splatEncoding)==null?void 0:s.sh2Min)??-1,((n=this.splatEncoding)==null?void 0:n.sh2Max)??1),e}}),this.dynoSh3MinMax=new qt({key:"sh3MinMax",value:new I.Vector2(-1,1),update:e=>{var s,n;return e.set(((s=this.splatEncoding)==null?void 0:s.sh3Min)??-1,((n=this.splatEncoding)==null?void 0:n.sh3Max)??1),e}}),this.initialized=Promise.resolve(this),this.reinitialize(A)}reinitialize(A){this.isInitialized=!1,this.extra={},this.splatEncoding=A.splatEncoding,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){const{url:e,fileBytes:s,construct:n}=A;if(e){const i=new co;i.packedSplats=this,await i.loadAsync(e)}else if(s){const i=await us({input:s,fileType:A.fileType,pathOrUrl:A.fileName??e,splatEncoding:A.splatEncoding??xe});this.initialize(i)}if(n){const i=n(this);i instanceof Promise&&await i}}dispose(){this.target&&(this.target.dispose(),this.target=null),this.source&&(this.source.dispose(),this.source=null)}ensureSplats(A){const e=A<=this.maxSplats?this.maxSplats:Math.max(A,2*this.maxSplats),s=this.packedArray?this.packedArray.length/4:0;if(!this.packedArray||e>s){this.maxSplats=xA(e).maxSplats;const n=new Uint32Array(this.maxSplats*4);this.packedArray&&n.set(this.packedArray),this.packedArray=n}return this.packedArray}ensureSplatsSh(A,e){let s,n;if(A===0)return this.ensureSplats(e);if(A===1)s=2,n="sh1";else if(A===2)s=4,n="sh2";else if(A===3)s=4,n="sh3";else throw new Error(`Invalid level: ${A}`);let i=this.extra[n]?this.extra[n].length/s:0;const r=e<=i?i:Math.max(e,2*i);if(!this.extra[n]||r>i){i=xA(r).maxSplats;const a=new Uint32Array(i*s);this.extra[n]&&a.set(this.extra[n]),this.extra[n]=a}return this.extra[n]}getSplat(A){if(!this.packedArray||A>=this.numSplats)throw new Error("Invalid index");return Be(this.packedArray,A,this.splatEncoding)}setSplat(A,e,s,n,i,r){const a=this.ensureSplats(A+1);Ce(a,A,e.x,e.y,e.z,s.x,s.y,s.z,n.x,n.y,n.z,n.w,i,r.r,r.g,r.b),this.numSplats=Math.max(this.numSplats,A+1)}pushSplat(A,e,s,n,i){const r=this.ensureSplats(this.numSplats+1);Ce(r,this.numSplats,A.x,A.y,A.z,e.x,e.y,e.z,s.x,s.y,s.z,s.w,n,i.r,i.g,i.b),++this.numSplats}forEachSplat(A){if(!(!this.packedArray||!this.numSplats))for(let e=0;e<this.numSplats;++e){const s=Be(this.packedArray,e,this.splatEncoding);A(e,s.center,s.scales,s.quaternion,s.opacity,s.color)}}ensureGenerate(A){if(this.target&&(A??1)<=this.maxSplats)return!1;this.dispose();const e=xA(A??1),{width:s,height:n,depth:i}=e;return this.maxSplats=e.maxSplats,this.target=new I.WebGLArrayRenderTarget(s,n,i,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:I.NearestFilter,minFilter:I.NearestFilter}),this.target.texture.format=I.RGBAIntegerFormat,this.target.texture.type=I.UnsignedIntType,this.target.texture.internalFormat="RGBA32UI",this.target.scissorTest=!0,!0}generateMapping(A){let e=0;const s=A.map(n=>{const i=e,r=Math.ceil(n/Z)*Z;return e+=r,{base:i,count:n}});return{maxSplats:e,mapping:s}}getTexture(){return this.target?this.target.texture:this.source||this.packedArray?this.maybeUpdateSource():iA.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:e,depth:s}=this.source.image;this.maxSplats!==A*e*s&&(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:e,depth:s}=xA(this.maxSplats);this.source=new I.DataArrayTexture(this.packedArra
Line truncated
|
||||
}`;const xe={rgbMin:0,rgbMax:1,lnScaleMin:kA,lnScaleMax:TA,sh1Min:-1,sh1Max:1,sh2Min:-1,sh2Max:1,sh3Min:-1,sh3Max:1},iA=class iA{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 Is({packedSplats:this}),this.dynoRgbMinMaxLnScaleMinMax=new Gt({key:"rgbMinMaxLnScaleMinMax",value:new I.Vector4(0,1,kA,TA),update:e=>{var s,n,i,r;return e.set(((s=this.splatEncoding)==null?void 0:s.rgbMin)??0,((n=this.splatEncoding)==null?void 0:n.rgbMax)??1,((i=this.splatEncoding)==null?void 0:i.lnScaleMin)??kA,((r=this.splatEncoding)==null?void 0:r.lnScaleMax)??TA),e}}),this.dynoSh1MinMax=new qt({key:"sh1MinMax",value:new I.Vector2(-1,1),update:e=>{var s,n;return e.set(((s=this.splatEncoding)==null?void 0:s.sh1Min)??-1,((n=this.splatEncoding)==null?void 0:n.sh1Max)??1),e}}),this.dynoSh2MinMax=new qt({key:"sh2MinMax",value:new I.Vector2(-1,1),update:e=>{var s,n;return e.set(((s=this.splatEncoding)==null?void 0:s.sh2Min)??-1,((n=this.splatEncoding)==null?void 0:n.sh2Max)??1),e}}),this.dynoSh3MinMax=new qt({key:"sh3MinMax",value:new I.Vector2(-1,1),update:e=>{var s,n;return e.set(((s=this.splatEncoding)==null?void 0:s.sh3Min)??-1,((n=this.splatEncoding)==null?void 0:n.sh3Max)??1),e}}),this.initialized=Promise.resolve(this),this.reinitialize(A)}reinitialize(A){this.isInitialized=!1,this.extra={},this.splatEncoding=A.splatEncoding,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){const{url:e,fileBytes:s,construct:n}=A;if(e){const i=new ao;i.packedSplats=this,await i.loadAsync(e)}else if(s){const i=await ls({input:s,fileType:A.fileType,pathOrUrl:A.fileName??e,splatEncoding:A.splatEncoding??xe});this.initialize(i)}if(n){const i=n(this);i instanceof Promise&&await i}}dispose(){this.target&&(this.target.dispose(),this.target=null),this.source&&(this.source.dispose(),this.source=null)}ensureSplats(A){const e=A<=this.maxSplats?this.maxSplats:Math.max(A,2*this.maxSplats),s=this.packedArray?this.packedArray.length/4:0;if(!this.packedArray||e>s){this.maxSplats=xA(e).maxSplats;const n=new Uint32Array(this.maxSplats*4);this.packedArray&&n.set(this.packedArray),this.packedArray=n}return this.packedArray}ensureSplatsSh(A,e){let s,n;if(A===0)return this.ensureSplats(e);if(A===1)s=2,n="sh1";else if(A===2)s=4,n="sh2";else if(A===3)s=4,n="sh3";else throw new Error(`Invalid level: ${A}`);let i=this.extra[n]?this.extra[n].length/s:0;const r=e<=i?i:Math.max(e,2*i);if(!this.extra[n]||r>i){i=xA(r).maxSplats;const a=new Uint32Array(i*s);this.extra[n]&&a.set(this.extra[n]),this.extra[n]=a}return this.extra[n]}getSplat(A){if(!this.packedArray||A>=this.numSplats)throw new Error("Invalid index");return Be(this.packedArray,A,this.splatEncoding)}setSplat(A,e,s,n,i,r){const a=this.ensureSplats(A+1);Ce(a,A,e.x,e.y,e.z,s.x,s.y,s.z,n.x,n.y,n.z,n.w,i,r.r,r.g,r.b),this.numSplats=Math.max(this.numSplats,A+1)}pushSplat(A,e,s,n,i){const r=this.ensureSplats(this.numSplats+1);Ce(r,this.numSplats,A.x,A.y,A.z,e.x,e.y,e.z,s.x,s.y,s.z,s.w,n,i.r,i.g,i.b),++this.numSplats}forEachSplat(A){if(!(!this.packedArray||!this.numSplats))for(let e=0;e<this.numSplats;++e){const s=Be(this.packedArray,e,this.splatEncoding);A(e,s.center,s.scales,s.quaternion,s.opacity,s.color)}}ensureGenerate(A){if(this.target&&(A??1)<=this.maxSplats)return!1;this.dispose();const e=xA(A??1),{width:s,height:n,depth:i}=e;return this.maxSplats=e.maxSplats,this.target=new I.WebGLArrayRenderTarget(s,n,i,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:I.NearestFilter,minFilter:I.NearestFilter}),this.target.texture.format=I.RGBAIntegerFormat,this.target.texture.type=I.UnsignedIntType,this.target.texture.internalFormat="RGBA32UI",this.target.scissorTest=!0,!0}generateMapping(A){let e=0;const s=A.map(n=>{const i=e,r=Math.ceil(n/Z)*Z;return e+=r,{base:i,count:n}});return{maxSplats:e,mapping:s}}getTexture(){return this.target?this.target.texture:this.source||this.packedArray?this.maybeUpdateSource():iA.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:e,depth:s}=this.source.image;this.maxSplats!==A*e*s&&(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:e,depth:s}=xA(this.maxSplats);this.source=new I.DataArrayTexture(this.packedArra
Line truncated
|
||||
float computeSort(Gsplat gsplat, bool sortRadial, vec3 sortOrigin, vec3 sortDirection, float sortDepthBias, bool sort360) {
|
||||
if (!isGsplatActive(gsplat.flags)) {
|
||||
return INFINITY;
|
||||
@@ -575,9 +575,9 @@ void main() {
|
||||
|
||||
return sortRadial ? length(center) : biasedDepth;
|
||||
}
|
||||
`);function Re({gsplat:t,sortRadial:A,sortOrigin:e,sortDirection:s,sortDepthBias:n,sort360:i}){return se({inTypes:{gsplat:AA,sortRadial:"bool",sortOrigin:"vec3",sortDirection:"vec3",sortDepthBias:"float",sort360:"bool"},outTypes:{metric:"float"},globals:()=>[NA,Zu],inputs:{gsplat:t,sortRadial:A,sortOrigin:e,sortDirection:s,sortDepthBias:n,sort360:i},statements:({inputs:r,outputs:a})=>{const{gsplat:o,sortRadial:g,sortOrigin:l,sortDirection:c,sortDepthBias:u,sort360:h}=r;return YA(`
|
||||
`);function Re({gsplat:t,sortRadial:A,sortOrigin:e,sortDirection:s,sortDepthBias:n,sort360:i}){return se({inTypes:{gsplat:AA,sortRadial:"bool",sortOrigin:"vec3",sortDirection:"vec3",sortDepthBias:"float",sort360:"bool"},outTypes:{metric:"float"},globals:()=>[NA,Pu],inputs:{gsplat:t,sortRadial:A,sortOrigin:e,sortDirection:s,sortDepthBias:n,sort360:i},statements:({inputs:r,outputs:a})=>{const{gsplat:o,sortRadial:g,sortOrigin:l,sortDirection:c,sortDepthBias:u,sort360:h}=r;return YA(`
|
||||
${a.metric} = computeSort(${o}, ${g}, ${l}, ${c}, ${u}, ${h});
|
||||
`)}}).outputs.metric}class Ie{constructor(){this.splats=new HA,this.toWorld=new I.Matrix4,this.mapping=[],this.refCount=0,this.splatsVersion=-1,this.mappingVersion=-1}ensureGenerate(A){this.splats.ensureGenerate(A)&&(this.mapping=[])}generateSplats({renderer:A,modifier:e,generators:s,forceUpdate:n,originToWorld:i}){const r=this.mapping.reduce((g,l)=>(g.set(l.node,l),g),new Map);let a=0,o=0;for(const{node:g,generator:l,version:c,base:u,count:h}of s){const E=r.get(g);if((n||l!==(E==null?void 0:E.generator)||c!==(E==null?void 0:E.version)||u!==(E==null?void 0:E.base)||h!==(E==null?void 0:E.count))&&l&&h>0){const C=e.apply(l);try{this.splats.generate({generator:C,base:u,count:h,renderer:A})}catch(B){g.generator=void 0,g.generatorError=B}a+=1}o=Math.max(o,u+h)}return this.splats.numSplats=o,this.toWorld=i,this.mapping=s,a!==0}hasCorrespondence(A){return this.mapping.length!==A.mapping.length?!1:this.mapping.every(({node:e,base:s,count:n},i)=>{const{node:r,base:a,count:o}=A.mapping[i];return e===r&&s===a&&n===o})}}var Xu=`const float LN_SCALE_MIN = -12.0;
|
||||
`)}}).outputs.metric}class Ie{constructor(){this.splats=new HA,this.toWorld=new I.Matrix4,this.mapping=[],this.refCount=0,this.splatsVersion=-1,this.mappingVersion=-1}ensureGenerate(A){this.splats.ensureGenerate(A)&&(this.mapping=[])}generateSplats({renderer:A,modifier:e,generators:s,forceUpdate:n,originToWorld:i}){const r=this.mapping.reduce((g,l)=>(g.set(l.node,l),g),new Map);let a=0,o=0;for(const{node:g,generator:l,version:c,base:u,count:h}of s){const E=r.get(g);if((n||l!==(E==null?void 0:E.generator)||c!==(E==null?void 0:E.version)||u!==(E==null?void 0:E.base)||h!==(E==null?void 0:E.count))&&l&&h>0){const C=e.apply(l);try{this.splats.generate({generator:C,base:u,count:h,renderer:A})}catch(B){g.generator=void 0,g.generatorError=B}a+=1}o=Math.max(o,u+h)}return this.splats.numSplats=o,this.toWorld=i,this.mapping=s,a!==0}hasCorrespondence(A){return this.mapping.length!==A.mapping.length?!1:this.mapping.every(({node:e,base:s,count:n},i)=>{const{node:r,base:a,count:o}=A.mapping[i];return e===r&&s===a&&n===o})}}var Zu=`const float LN_SCALE_MIN = -12.0;
|
||||
const float LN_SCALE_MAX = 9.0;
|
||||
|
||||
const uint SPLAT_TEX_WIDTH_BITS = 11u;
|
||||
@@ -836,7 +836,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);
|
||||
}`,Ou=`precision highp float;
|
||||
}`,Xu=`precision highp float;
|
||||
precision highp int;
|
||||
|
||||
#include <splatDefines>
|
||||
@@ -930,7 +930,7 @@ void main() {
|
||||
fragColor = rgba;
|
||||
#endif
|
||||
}
|
||||
}`,ju=`precision highp float;
|
||||
}`,Ou=`precision highp float;
|
||||
precision highp int;
|
||||
precision highp usampler2DArray;
|
||||
|
||||
@@ -1142,14 +1142,14 @@ void main() {
|
||||
vSplatUv = position.xy * maxStdDev;
|
||||
vNdc = ndc;
|
||||
gl_Position = vec4(ndc.xy * clipCenter.w, clipCenter.zw);
|
||||
}`;let Ye=null;function Wu(){return Ye||(I.ShaderChunk.splatDefines=Xu,Ye={splatVertex:ju,splatFragment:Ou}),Ye}const ws=5;let Xe=!1,Oe=!1,lo;function Ah(t){let A=!1;return t instanceof PA?!0:(t.traverse(e=>{A=A||e instanceof PA}),A)}const Io=I.Scene.prototype.add;I.Scene.prototype.add=function(t){return Xe=Xe||Ah(t),Oe=Oe||t instanceof Wt,Io.call(this,t),this};const th=I.Scene.prototype.onBeforeRender;I.Scene.prototype.onBeforeRender=function(t){if(Xe){if(!Oe){const A=lo||new Wt({renderer:t});this.add(A)}I.Scene.prototype.onBeforeRender=th,I.Scene.prototype.add=Io}};const cA=class cA extends I.Mesh{constructor(A){const e=cA.makeUniforms(),s=Wu(),n=A.premultipliedAlpha??!0,i=new I.ShaderMaterial({glslVersion:I.GLSL3,vertexShader:s.splatVertex,fragmentShader:s.splatFragment,uniforms:e,premultipliedAlpha:n,transparent:!0,depthTest:!0,depthWrite:!1,side:I.DoubleSide});super(ms,i),this.splatTexture=null,this.autoViewpoints=[],this.rotateToAccumulator=new Gt({value:new I.Quaternion}),this.translateToAccumulator=new Nt({value:new I.Vector3}),this.lastFrame=-1,this.lastUpdateTime=null,this.defaultCameras=[],this.lastStochastic=null,this.pendingUpdate={scene:null,originToWorld:new I.Matrix4,timeoutId:-1},this.envViewpoint=null,this.frustumCulled=!1,this.renderer=A.renderer,this.material=i,this.uniforms=e;const r=FA({gsplat:AA},{gsplat:AA},({gsplat:a})=>{if(!a)throw new Error("gsplat not defined");return a=es(a,{rotate:this.rotateToAccumulator,translate:this.translateToAccumulator}),{gsplat:a}});this.modifier=new no(r),this.premultipliedAlpha=n,this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!1,this.needsUpdate=!1,this.originDistance=A.originDistance??1,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.maxPixelRadius=A.maxPixelRadius??512,this.minAlpha=A.minAlpha??.5*(1/255),this.enable2DGS=A.enable2DGS??!1,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.focalDistance=A.focalDistance??0,this.apertureAngle=A.apertureAngle??0,this.falloff=A.falloff??1,this.clipXY=A.clipXY??1.4,this.focalAdjustment=A.focalAdjustment??1,this.splatEncoding=A.splatEncoding??{...xe},this.active=new Ie,this.accumulatorCount=1,this.freeAccumulators=[];for(let a=0;a<1;++a)this.freeAccumulators.push(new Ie),this.accumulatorCount+=1;this.defaultView=new jt({...A.view,autoUpdate:!0,spark:this}),this.viewpoint=this.defaultView,this.prepareViewpoint(this.viewpoint),this.clock=A.clock?jn(A.clock):new I.Clock,lo=this}static makeUniforms(){return{renderSize:{value:new I.Vector2},near:{value:.1},far:{value:1e3},numSplats:{value:0},renderToViewQuat:{value:new I.Quaternion},renderToViewPos:{value:new I.Vector3},maxStdDev:{value:1},maxPixelRadius:{value:512},minAlpha:{value:.00196078431372549},stochastic:{value:!1},enable2DGS:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},focalDistance:{value:0},apertureAngle:{value:0},falloff:{value:1},clipXY:{value:1.4},focalAdjustment:{value:1},splatTexEnable:{value:!1},splatTexture:{type:"t",value:cA.EMPTY_SPLAT_TEXTURE},splatTexMul:{value:new I.Matrix2},splatTexAdd:{value:new I.Vector2},splatTexNear:{value:.1},splatTexFar:{value:1e3},splatTexMid:{value:0},packedSplats:{type:"t",value:HA.getEmpty()},rgbMinMaxLnScaleMinMax:{value:new I.Vector4},time:{value:0},deltaTime:{value:0},encodeLinear:{value:!1},debugFlag:{value:!1}}}canAllocAccumulator(){return this.freeAccumulators.length>0||this.accumulatorCount<ws}maybeAllocAccumulator(){let A=this.freeAccumulators.pop();if(A===void 0){if(this.accumulatorCount>=ws)return null;A=new Ie,this.accumulatorCount+=1}return A.refCount=1,A}releaseAccumulator(A){A.refCount-=1,A.refCount===0&&this.freeAccumulators.push(A)}newViewpoint(A){return new jt({...A,spark:this})}onBeforeRender(A,e,s){var h,E;const n=this.time??this.clock.getElapsedTime(),i=n-(this.viewpoint.lastTime??n);this.viewpoint.lastTime=n;const r=A.info.render.frame,a=r!==this.lastFrame;this.lastFrame=r;const o=this.viewpoint;if(o===this.defaultView){if(a)if(!A.xr.isPresenting)this.defaultView.viewToWorld=s.matrixWorld.clone(),this.defaultCameras=[this.defaultView.viewToWorld];else{const C=A.xr.getCamera().cameras;this.defaultCameras=C.map(B=>B.matrixWorld),this.defaultView.viewToWorld=eh(this.defaultCameras)??new I.Matrix4}this.autoUpdate&&this.update({scene:e,viewToWorld:this.defaultView.viewToWorld})}if(a&&(this.material.premultipliedAlpha!==this.premultipliedAlpha&&(this.material.premultipliedAlpha=this.premultipliedAlpha,this.material.needsUpdate=!0),this.uniforms.time.value=n,this.uniforms.deltaTime.value=i,this.uniforms.debugFlag.value=performance.now()/1e3%2<1,o.display&&o.stochastic&&(this.geometry.instanceCount=this.uniforms.numSplats.value)),o.target)this.uniforms.renderSize.value.set(o.target.width,o.target.height);else{const C=A.getDrawingBufferSize(this.uniforms.renderSize.value);if(C.x===1&&C.y===1){const B=(h=A.xr.getSession())==null?void 0:h.renderState.baseLayer;B&&(C.x=B.framebufferWidth,C.y=B.framebufferHeight)}}const g=s;if(this.uniforms.near.value=g.n
Line truncated
|
||||
}`;let Ye=null;function ju(){return Ye||(I.ShaderChunk.splatDefines=Zu,Ye={splatVertex:Ou,splatFragment:Xu}),Ye}const ds=5,cA=class cA extends I.Mesh{constructor(A){const e=cA.makeUniforms(),s=ju(),n=A.premultipliedAlpha??!0,i=new I.ShaderMaterial({glslVersion:I.GLSL3,vertexShader:s.splatVertex,fragmentShader:s.splatFragment,uniforms:e,premultipliedAlpha:n,transparent:!0,depthTest:!0,depthWrite:!1,side:I.DoubleSide});super(ys,i),this.splatTexture=null,this.autoViewpoints=[],this.rotateToAccumulator=new Gt({value:new I.Quaternion}),this.translateToAccumulator=new Nt({value:new I.Vector3}),this.lastFrame=-1,this.lastUpdateTime=null,this.defaultCameras=[],this.lastStochastic=null,this.pendingUpdate={scene:null,originToWorld:new I.Matrix4,timeoutId:-1},this.envViewpoint=null,this.frustumCulled=!1,this.renderer=A.renderer,this.material=i,this.uniforms=e;const r=FA({gsplat:AA},{gsplat:AA},({gsplat:a})=>{if(!a)throw new Error("gsplat not defined");return a=As(a,{rotate:this.rotateToAccumulator,translate:this.translateToAccumulator}),{gsplat:a}});this.modifier=new eo(r),this.premultipliedAlpha=n,this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!1,this.needsUpdate=!1,this.originDistance=A.originDistance??1,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.maxPixelRadius=A.maxPixelRadius??512,this.minAlpha=A.minAlpha??.5*(1/255),this.enable2DGS=A.enable2DGS??!1,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.focalDistance=A.focalDistance??0,this.apertureAngle=A.apertureAngle??0,this.falloff=A.falloff??1,this.clipXY=A.clipXY??1.4,this.focalAdjustment=A.focalAdjustment??1,this.splatEncoding=A.splatEncoding??{...xe},this.active=new Ie,this.accumulatorCount=1,this.freeAccumulators=[];for(let a=0;a<1;++a)this.freeAccumulators.push(new Ie),this.accumulatorCount+=1;this.defaultView=new jt({...A.view,autoUpdate:!0,spark:this}),this.viewpoint=this.defaultView,this.prepareViewpoint(this.viewpoint),this.clock=A.clock?Xn(A.clock):new I.Clock}static makeUniforms(){return{renderSize:{value:new I.Vector2},near:{value:.1},far:{value:1e3},numSplats:{value:0},renderToViewQuat:{value:new I.Quaternion},renderToViewPos:{value:new I.Vector3},maxStdDev:{value:1},maxPixelRadius:{value:512},minAlpha:{value:.00196078431372549},stochastic:{value:!1},enable2DGS:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},focalDistance:{value:0},apertureAngle:{value:0},falloff:{value:1},clipXY:{value:1.4},focalAdjustment:{value:1},splatTexEnable:{value:!1},splatTexture:{type:"t",value:cA.EMPTY_SPLAT_TEXTURE},splatTexMul:{value:new I.Matrix2},splatTexAdd:{value:new I.Vector2},splatTexNear:{value:.1},splatTexFar:{value:1e3},splatTexMid:{value:0},packedSplats:{type:"t",value:HA.getEmpty()},rgbMinMaxLnScaleMinMax:{value:new I.Vector4},time:{value:0},deltaTime:{value:0},encodeLinear:{value:!1},debugFlag:{value:!1}}}canAllocAccumulator(){return this.freeAccumulators.length>0||this.accumulatorCount<ds}maybeAllocAccumulator(){let A=this.freeAccumulators.pop();if(A===void 0){if(this.accumulatorCount>=ds)return null;A=new Ie,this.accumulatorCount+=1}return A.refCount=1,A}releaseAccumulator(A){A.refCount-=1,A.refCount===0&&this.freeAccumulators.push(A)}newViewpoint(A){return new jt({...A,spark:this})}onBeforeRender(A,e,s){var h,E;const n=this.time??this.clock.getElapsedTime(),i=n-(this.viewpoint.lastTime??n);this.viewpoint.lastTime=n;const r=A.info.render.frame,a=r!==this.lastFrame;this.lastFrame=r;const o=this.viewpoint;if(o===this.defaultView){if(a)if(!A.xr.isPresenting)this.defaultView.viewToWorld=s.matrixWorld.clone(),this.defaultCameras=[this.defaultView.viewToWorld];else{const C=A.xr.getCamera().cameras;this.defaultCameras=C.map(B=>B.matrixWorld),this.defaultView.viewToWorld=Wu(this.defaultCameras)??new I.Matrix4}this.autoUpdate&&this.update({scene:e,viewToWorld:this.defaultView.viewToWorld})}if(a&&(this.material.premultipliedAlpha!==this.premultipliedAlpha&&(this.material.premultipliedAlpha=this.premultipliedAlpha,this.material.needsUpdate=!0),this.uniforms.time.value=n,this.uniforms.deltaTime.value=i,this.uniforms.debugFlag.value=performance.now()/1e3%2<1,o.display&&o.stochastic&&(this.geometry.instanceCount=this.uniforms.numSplats.value)),o.target)this.uniforms.renderSize.value.set(o.target.width,o.target.height);else{const C=A.getDrawingBufferSize(this.uniforms.renderSize.value);if(C.x===1&&C.y===1){const B=(h=A.xr.getSession())==null?void 0:h.renderState.baseLayer;B&&(C.x=B.framebufferWidth,C.y=B.framebufferHeight)}}const g=s;if(this.uniforms.near.value=g.near,this.uniforms.far.value=g.far,this.uniforms.encodeLinear.value=o.encodeLinear,this.uniforms.maxStdDev.value=this.maxStdDev,this.uniforms.maxPixelRadius.value=this.maxPixelRadius,this.uniforms.minAlpha.value=this.minAlpha,this.uniforms.stochastic.value=o.stochastic,this.uniforms.enable2DGS.value=this.enable2DGS,this.uniforms.preBlurAmount.value=this.preBlurAmount,this.uniforms.blurAmount.value=this.blurAmount,this.uniforms.focalDistance.value=this.focalDista
Line truncated
|
||||
struct GsplatSkinning {
|
||||
int numSplats;
|
||||
int numBones;
|
||||
usampler2DArray skinTexture;
|
||||
sampler2D boneTexture;
|
||||
};
|
||||
`),lh=CA(`
|
||||
`),oh=CA(`
|
||||
void applyGsplatSkinning(
|
||||
int numSplats, int numBones,
|
||||
usampler2DArray skinTexture, sampler2D boneTexture,
|
||||
@@ -1208,7 +1208,7 @@ void main() {
|
||||
center = quatVec(quat, center) + translate;
|
||||
quaternion = quatQuat(quat, quaternion);
|
||||
}
|
||||
`);function Ih(t,A){return new V({inTypes:{gsplat:AA,skinning:Bo},outTypes:{gsplat:AA},globals:()=>[Eo,lh],inputs:{gsplat:t,skinning:A},statements:({inputs:s,outputs:n})=>{const{skinning:i}=s,{gsplat:r}=n;return YA(`
|
||||
`);function ch(t,A){return new V({inTypes:{gsplat:AA,skinning:Io},outTypes:{gsplat:AA},globals:()=>[uo,oh],inputs:{gsplat:t,skinning:A},statements:({inputs:s,outputs:n})=>{const{skinning:i}=s,{gsplat:r}=n;return YA(`
|
||||
${r} = ${s.gsplat};
|
||||
if (isGsplatActive(${r}.flags)) {
|
||||
applyGsplatSkinning(
|
||||
@@ -1217,6 +1217,6 @@ void main() {
|
||||
${r}.index, ${r}.center, ${r}.quaternion
|
||||
);
|
||||
}
|
||||
`)}}).outputs.gsplat}function uh({splats:t,extents:A,stepSize:e=1,pointRadius:s=.01,pointShadowScale:n=2,opacity:i=1,color:r}){const o=new I.Vector3,g=new I.Vector3,l=new I.Quaternion(0,0,0,1);r==null&&(r=(u,h)=>u.set(.55+.45*Math.cos(h.x*1),.55+.45*Math.cos(h.y*1),.55+.45*Math.cos(h.z*1)));const c=new I.Color;for(let u=A.min.z;u<A.max.z+1e-6;u+=e)for(let h=A.min.y;h<A.max.y+1e-6;h+=e)for(let E=A.min.x;E<A.max.x+1e-6;E+=e){o.set(E,h,u);for(let C=0;C<2;++C)g.setScalar(s*(C?1:n)),C?typeof r=="function"?r(c,o):c.copy(r):c.setScalar(0),t.pushSplat(o,g,l,i,c)}}function hh({splats:t,scale:A=.25,axisRadius:e=.0075,axisShadowScale:s=2,origins:n=[new I.Vector3]}){const i=new I.Vector3,r=new I.Vector3,a=new I.Quaternion(0,0,0,1),o=new I.Color,g=1;for(const l of n)for(let c=0;c<3;++c){i.set(l.x+(c===0?A:0),l.y+(c===1?A:0),l.z+(c===2?A:0));for(let u=0;u<2;++u)r.set((c===0?A:e)*(u?1:s),(c===1?A:e)*(u?1:s),(c===2?A:e)*(u?1:s)),o.setRGB(u===0?0:c===0?1:0,u===0?0:c===1?1:0,u===0?0:c===2?1:0),t.pushSplat(i,r,a,g,o)}}function Ch({splats:t,origin:A=new I.Vector3,radius:e=1,maxDepth:s=3,filter:n=null,pointRadius:i=.02,pointThickness:r=.001,color:a=new I.Color(1,1,1)}){const o={};function g(C){if(n&&!n(C))return;const B=`${C.x},${C.y},${C.z}`;o[B]||(o[B]=C)}function l(C,B,Q,p){if(g(B),g(Q),g(p),C>=s)return;const f=new I.Vector3().addVectors(B,Q).normalize(),d=new I.Vector3().addVectors(Q,p).normalize(),w=new I.Vector3().addVectors(p,B).normalize();l(C+1,B,f,w),l(C+1,f,Q,d),l(C+1,w,d,p),l(C+1,f,d,w)}for(const C of[-1,1])for(const B of[-1,1])for(const Q of[-1,1]){const p=new I.Vector3(C,0,0),f=new I.Vector3(0,B,0),d=new I.Vector3(0,0,Q);l(0,p,f,d)}const c=Object.values(o),u=new I.Vector3(i,i,r),h=new I.Quaternion,E=typeof a=="function"?new I.Color:a;for(const C of c)h.setFromUnitVectors(new I.Vector3(0,0,-1),C),typeof a=="function"&&a(E,C),C.multiplyScalar(e),C.add(A),t.pushSplat(C,u,h,1,E)}function Bh({text:t,font:A,fontSize:e,color:s,rgb:n,dotRadius:i,textAlign:r,lineHeight:a,objectScale:o}){A=A??"Arial",e=e??32,s=s??new I.Color(1,1,1),i=i??.8,r=r??"start",a=a??1,o=o??1;const g=t.split(`
|
||||
`),l=document.createElement("canvas"),c=l.getContext("2d");if(!c)throw new Error("Failed to create canvas context");c.font=`${e}px ${A}`,c.textAlign=r;const u=c.measureText(""),h=u.fontBoundingBoxAscent+u.fontBoundingBoxDescent;let E=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,B=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY;for(let F=0;F<g.length;++F){const b=c.measureText(g[F]),T=h*a*F;E=Math.min(E,-b.actualBoundingBoxLeft),C=Math.max(C,b.actualBoundingBoxRight),B=Math.min(B,T-b.actualBoundingBoxAscent),Q=Math.max(Q,T+b.actualBoundingBoxDescent)}const p=Math.floor(E),f=Math.floor(B),d=Math.ceil(C)-p,w=Math.ceil(Q)-f;l.width=d,l.height=w,c.font=`${e}px ${A}`,c.textAlign=r,c.textBaseline="alphabetic",c.fillStyle="#FFFFFF";for(let F=0;F<g.length;++F){const b=h*a*F-f;c.fillText(g[F],-p,b)}const D=c.getImageData(0,0,d,w),x=new Uint8Array(D.data.buffer),y=new HA,m=new I.Vector3,k=new I.Vector3().setScalar(i*o),M=new I.Quaternion(0,0,0,1);n=n??new I.Color(1,1,1);let S=0;for(let F=0;F<w;++F)for(let b=0;b<d;++b){const T=x[S+3];if(T>0){const R=T/255;m.set(b-.5*(d-1),.5*(w-1)-F,0),m.multiplyScalar(o),y.pushSplat(m,k,M,R,n)}S+=4}const U=new PA({packedSplats:y});return U.recolor=s,U}function Eh({url:t,dotRadius:A,subXY:e,forEachSplat:s}){return A=A??.8,e=Math.max(1,Math.floor(e??1)),new PA({constructSplats:async n=>new Promise((i,r)=>{const a=new Image;a.crossOrigin="anonymous",a.onerror=r,a.onload=()=>{const{width:o,height:g}=a,l=document.createElement("canvas");l.width=o,l.height=g;const c=l.getContext("2d");if(!c){r(new Error("Failed to create canvas context"));return}c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high";const u=Math.round(o/e),h=Math.round(g/e);c.drawImage(a,0,0,u,h);try{const E=c.getImageData(0,0,u,h),C=new Uint8Array(E.data.buffer),B=new I.Vector3,Q=new I.Vector3().setScalar(A),p=new I.Quaternion(0,0,0,1),f=new I.Color;let d=0;for(let w=0;w<h;++w)for(let D=0;D<u;++D){const x=d*4,y=C[x+3];if(y>0){let m=y/255;f.set(C[x+0]/255,C[x+1]/255,C[x+2]/255),B.set(D-.5*(u-1),.5*(h-1)-w,0),Q.setScalar(A),p.set(0,0,0,1);let k=!0;if(s){const M=s(u,h,d,B,Q,p,m,f);m=M??m,k=M!==null}k&&n.pushSplat(B,Q,p,m,f)}d+=1}i()}catch(E){r(E)}},a.src=t})})}function Qh({box:t,cells:A,dotScale:e,color:s,opacity:n}){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)),n=n??1;const i=A.x*A.y*A.z,r=J("int",A.x),a=J("int",A.y);J("int",A.z);const o=qA(0),g=new kt({numSplats:i,generator:FA({index:"int"},{gsplat:AA},({index:c})=>{if(!c)throw new Error("index is undefined");const u=He(c,r),h=ge(c,r),E=He(h,a),C=ge(h,a),B=VA({vectorType:"ivec3",x:u,y:E,z:C}),Q=or(o),p=VA({vectorType:"ivec2",x:c,y:Q}),f=Ia(p),d=J("vec3",t.min),w=J("vec3",t.max),D=ft(w,d),x=ge(EA(Qt(B),f),J("vec3",A));let y,m,k;s?(y=J("float",s.r),m=J("float",s.g),k=J("float",s.b)):{r:y,g:m,b:k}=pt(x).outputs;const M=VA({vectorType:"vec4",r:y,g:m,b:k,a:J("float",n)}),S=EA(d,rA(D,x)),U=Qt(J("float",e)),F=J("vec4",new I.Quaternion(0,0,0,1));let b=at({flags:ue("uint","GSPLAT_FLAG_ACTIVE"),index:c,center:S,scales:U,quaternion:F,rgba:M});return b=l.applyGsplat(b),{gsplat:b}},{globals:()=>[NA]}),update:({time:c})=>{o.value=c,l.update(g),g.updateVersion()}}),l=new ht;return g}const ph={box:new I.Box3(new I.Vector3(-1,-1,-1),new I.Vector3(1,1,1)),density:100,fallDirection:new I.Vector3(-1,-3,1).normalize(),fallVelocity:.02,wanderScale:.04,wanderVariance:2,color1:new I.Color(1,1,1),color2:new I.Color(.5,.5,1),minScale:.001,maxScale:.005,anisoScale:new I.Vector3(1,1,1)},fh={box:new I.Box3(new I.Vector3(-2,-1,-2),new I.Vector3(2,5,2)),density:10,fallDirection:new I.Vector3(0,-1,0),fallVelocity:2,wanderScale:.1,wanderVariance:1,color1:new I.Color(1,1,1),color2:new I.Color(.25,.25,.5),minScale:.005,maxScale:.01,anisoScale:new I.Vector3(.1,1,.1)};function dh({box:t,minY:A,numSplats:e,density:s,anisoScale:n,minScale:i,maxScale:r,fallDirection:a,fallVelocity:o,wanderScale:g,wanderVariance:l,color1:c,color2:u,opacity:h,onFrame:E}){t=t??new I.Box3(new I.Vector3(-1,-1,-1),new I.Vector3(1,1,1));const C=(t.max.x-t.min.x)*(t.max.y-t.min.y)*(t.max.z-t.min.z);s=s??100,e=e??Math.max(1,Math.min(1e6,Math.round(C*s)));const B=qA(i??.001),Q=qA(r??.005),p=st(((n==null?void 0:n.clone())??new I.Vector3(1,1,1)).normalize()),f=st((a??new I.Vector3(0,-1,0)).normalize()),d=qA(o??.02),w=qA(g??.01),D=qA(l??2),x=st(c??new I.Color(1,1,1)),y=st(u??new I.Color(.5,.5,1)),m=qA(h??1),k=qA(0),M=st(new I.Vector3(0,0,0)),S=st(t.min),U=st(t.max),F=qA(A??Number.NEGATIVE_INFINITY),b=ft(U,S),T=new kt({numSplats:e,generator:FA({index:"int"},{gsplat:AA},({index:X})=>{if(!X)throw new Error("index not defined");const _=Ke(X),eA=pt(_).outputs.w;let q=Qt(_),O=le(rA(eA,J("float",100)));O=$e(rA(ue("float","PI"),O)),O=EA(B,rA(O,ft(Q,B)));const L=rA(O,p),j=le(rA(eA,J("float",10))),P=le(eA),W=li(x,y,P),G=rA(W,j),dA=Ke(VA({vectorType:"ivec2",x:X,y:J("int",6837)}));let lA=Qt(dA),yA=rA(pt(dA).outputs.w,D);yA=EA(k,yA),q=EA(q,M);const wA=ci(q,J("vec3",new I.Vector3(1,1,1)));q=E
Line truncated
|
||||
`)}}).outputs.gsplat}function gh({splats:t,extents:A,stepSize:e=1,pointRadius:s=.01,pointShadowScale:n=2,opacity:i=1,color:r}){const o=new I.Vector3,g=new I.Vector3,l=new I.Quaternion(0,0,0,1);r==null&&(r=(u,h)=>u.set(.55+.45*Math.cos(h.x*1),.55+.45*Math.cos(h.y*1),.55+.45*Math.cos(h.z*1)));const c=new I.Color;for(let u=A.min.z;u<A.max.z+1e-6;u+=e)for(let h=A.min.y;h<A.max.y+1e-6;h+=e)for(let E=A.min.x;E<A.max.x+1e-6;E+=e){o.set(E,h,u);for(let C=0;C<2;++C)g.setScalar(s*(C?1:n)),C?typeof r=="function"?r(c,o):c.copy(r):c.setScalar(0),t.pushSplat(o,g,l,i,c)}}function lh({splats:t,scale:A=.25,axisRadius:e=.0075,axisShadowScale:s=2,origins:n=[new I.Vector3]}){const i=new I.Vector3,r=new I.Vector3,a=new I.Quaternion(0,0,0,1),o=new I.Color,g=1;for(const l of n)for(let c=0;c<3;++c){i.set(l.x+(c===0?A:0),l.y+(c===1?A:0),l.z+(c===2?A:0));for(let u=0;u<2;++u)r.set((c===0?A:e)*(u?1:s),(c===1?A:e)*(u?1:s),(c===2?A:e)*(u?1:s)),o.setRGB(u===0?0:c===0?1:0,u===0?0:c===1?1:0,u===0?0:c===2?1:0),t.pushSplat(i,r,a,g,o)}}function Ih({splats:t,origin:A=new I.Vector3,radius:e=1,maxDepth:s=3,filter:n=null,pointRadius:i=.02,pointThickness:r=.001,color:a=new I.Color(1,1,1)}){const o={};function g(C){if(n&&!n(C))return;const B=`${C.x},${C.y},${C.z}`;o[B]||(o[B]=C)}function l(C,B,Q,p){if(g(B),g(Q),g(p),C>=s)return;const f=new I.Vector3().addVectors(B,Q).normalize(),d=new I.Vector3().addVectors(Q,p).normalize(),w=new I.Vector3().addVectors(p,B).normalize();l(C+1,B,f,w),l(C+1,f,Q,d),l(C+1,w,d,p),l(C+1,f,d,w)}for(const C of[-1,1])for(const B of[-1,1])for(const Q of[-1,1]){const p=new I.Vector3(C,0,0),f=new I.Vector3(0,B,0),d=new I.Vector3(0,0,Q);l(0,p,f,d)}const c=Object.values(o),u=new I.Vector3(i,i,r),h=new I.Quaternion,E=typeof a=="function"?new I.Color:a;for(const C of c)h.setFromUnitVectors(new I.Vector3(0,0,-1),C),typeof a=="function"&&a(E,C),C.multiplyScalar(e),C.add(A),t.pushSplat(C,u,h,1,E)}function uh({text:t,font:A,fontSize:e,color:s,rgb:n,dotRadius:i,textAlign:r,lineHeight:a,objectScale:o}){A=A??"Arial",e=e??32,s=s??new I.Color(1,1,1),i=i??.8,r=r??"start",a=a??1,o=o??1;const g=t.split(`
|
||||
`),l=document.createElement("canvas"),c=l.getContext("2d");if(!c)throw new Error("Failed to create canvas context");c.font=`${e}px ${A}`,c.textAlign=r;const u=c.measureText(""),h=u.fontBoundingBoxAscent+u.fontBoundingBoxDescent;let E=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,B=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY;for(let F=0;F<g.length;++F){const b=c.measureText(g[F]),T=h*a*F;E=Math.min(E,-b.actualBoundingBoxLeft),C=Math.max(C,b.actualBoundingBoxRight),B=Math.min(B,T-b.actualBoundingBoxAscent),Q=Math.max(Q,T+b.actualBoundingBoxDescent)}const p=Math.floor(E),f=Math.floor(B),d=Math.ceil(C)-p,w=Math.ceil(Q)-f;l.width=d,l.height=w,c.font=`${e}px ${A}`,c.textAlign=r,c.textBaseline="alphabetic",c.fillStyle="#FFFFFF";for(let F=0;F<g.length;++F){const b=h*a*F-f;c.fillText(g[F],-p,b)}const D=c.getImageData(0,0,d,w),x=new Uint8Array(D.data.buffer),y=new HA,m=new I.Vector3,k=new I.Vector3().setScalar(i*o),M=new I.Quaternion(0,0,0,1);n=n??new I.Color(1,1,1);let S=0;for(let F=0;F<w;++F)for(let b=0;b<d;++b){const T=x[S+3];if(T>0){const R=T/255;m.set(b-.5*(d-1),.5*(w-1)-F,0),m.multiplyScalar(o),y.pushSplat(m,k,M,R,n)}S+=4}const U=new ct({packedSplats:y});return U.recolor=s,U}function hh({url:t,dotRadius:A,subXY:e,forEachSplat:s}){return A=A??.8,e=Math.max(1,Math.floor(e??1)),new ct({constructSplats:async n=>new Promise((i,r)=>{const a=new Image;a.crossOrigin="anonymous",a.onerror=r,a.onload=()=>{const{width:o,height:g}=a,l=document.createElement("canvas");l.width=o,l.height=g;const c=l.getContext("2d");if(!c){r(new Error("Failed to create canvas context"));return}c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="high";const u=Math.round(o/e),h=Math.round(g/e);c.drawImage(a,0,0,u,h);try{const E=c.getImageData(0,0,u,h),C=new Uint8Array(E.data.buffer),B=new I.Vector3,Q=new I.Vector3().setScalar(A),p=new I.Quaternion(0,0,0,1),f=new I.Color;let d=0;for(let w=0;w<h;++w)for(let D=0;D<u;++D){const x=d*4,y=C[x+3];if(y>0){let m=y/255;f.set(C[x+0]/255,C[x+1]/255,C[x+2]/255),B.set(D-.5*(u-1),.5*(h-1)-w,0),Q.setScalar(A),p.set(0,0,0,1);let k=!0;if(s){const M=s(u,h,d,B,Q,p,m,f);m=M??m,k=M!==null}k&&n.pushSplat(B,Q,p,m,f)}d+=1}i()}catch(E){r(E)}},a.src=t})})}function Ch({box:t,cells:A,dotScale:e,color:s,opacity:n}){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)),n=n??1;const i=A.x*A.y*A.z,r=J("int",A.x),a=J("int",A.y);J("int",A.z);const o=qA(0),g=new kt({numSplats:i,generator:FA({index:"int"},{gsplat:AA},({index:c})=>{if(!c)throw new Error("index is undefined");const u=He(c,r),h=ge(c,r),E=He(h,a),C=ge(h,a),B=VA({vectorType:"ivec3",x:u,y:E,z:C}),Q=rr(o),p=VA({vectorType:"ivec2",x:c,y:Q}),f=ga(p),d=J("vec3",t.min),w=J("vec3",t.max),D=ft(w,d),x=ge(EA(Qt(B),f),J("vec3",A));let y,m,k;s?(y=J("float",s.r),m=J("float",s.g),k=J("float",s.b)):{r:y,g:m,b:k}=pt(x).outputs;const M=VA({vectorType:"vec4",r:y,g:m,b:k,a:J("float",n)}),S=EA(d,rA(D,x)),U=Qt(J("float",e)),F=J("vec4",new I.Quaternion(0,0,0,1));let b=rt({flags:ue("uint","GSPLAT_FLAG_ACTIVE"),index:c,center:S,scales:U,quaternion:F,rgba:M});return b=l.applyGsplat(b),{gsplat:b}},{globals:()=>[NA]}),update:({time:c})=>{o.value=c,l.update(g),g.updateVersion()}}),l=new ht;return g}const Bh={box:new I.Box3(new I.Vector3(-1,-1,-1),new I.Vector3(1,1,1)),density:100,fallDirection:new I.Vector3(-1,-3,1).normalize(),fallVelocity:.02,wanderScale:.04,wanderVariance:2,color1:new I.Color(1,1,1),color2:new I.Color(.5,.5,1),minScale:.001,maxScale:.005,anisoScale:new I.Vector3(1,1,1)},Eh={box:new I.Box3(new I.Vector3(-2,-1,-2),new I.Vector3(2,5,2)),density:10,fallDirection:new I.Vector3(0,-1,0),fallVelocity:2,wanderScale:.1,wanderVariance:1,color1:new I.Color(1,1,1),color2:new I.Color(.25,.25,.5),minScale:.005,maxScale:.01,anisoScale:new I.Vector3(.1,1,.1)};function Qh({box:t,minY:A,numSplats:e,density:s,anisoScale:n,minScale:i,maxScale:r,fallDirection:a,fallVelocity:o,wanderScale:g,wanderVariance:l,color1:c,color2:u,opacity:h,onFrame:E}){t=t??new I.Box3(new I.Vector3(-1,-1,-1),new I.Vector3(1,1,1));const C=(t.max.x-t.min.x)*(t.max.y-t.min.y)*(t.max.z-t.min.z);s=s??100,e=e??Math.max(1,Math.min(1e6,Math.round(C*s)));const B=qA(i??.001),Q=qA(r??.005),p=et(((n==null?void 0:n.clone())??new I.Vector3(1,1,1)).normalize()),f=et((a??new I.Vector3(0,-1,0)).normalize()),d=qA(o??.02),w=qA(g??.01),D=qA(l??2),x=et(c??new I.Color(1,1,1)),y=et(u??new I.Color(.5,.5,1)),m=qA(h??1),k=qA(0),M=et(new I.Vector3(0,0,0)),S=et(t.min),U=et(t.max),F=qA(A??Number.NEGATIVE_INFINITY),b=ft(U,S),T=new kt({numSplats:e,generator:FA({index:"int"},{gsplat:AA},({index:X})=>{if(!X)throw new Error("index not defined");const _=Ke(X),eA=pt(_).outputs.w;let q=Qt(_),O=le(rA(eA,J("float",100)));O=$e(rA(ue("float","PI"),O)),O=EA(B,rA(O,ft(Q,B)));const L=rA(O,p),j=le(rA(eA,J("float",10))),P=le(eA),W=ci(x,y,P),G=rA(W,j),dA=Ke(VA({vectorType:"ivec2",x:X,y:J("int",6837)}));let lA=Qt(dA),yA=rA(pt(dA).outputs.w,D);yA=EA(k,yA),q=EA(q,M);const wA=ai(q,J("vec3",new I.Vector3(1,1,1)));q=E
Line truncated
|
||||
//# sourceMappingURL=spark.cjs.min.js.map
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"spark.cjs.min.js","sources":["../node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/fflate/esm/browser.js","../rust/spark-internal-rs/pkg/spark_internal_rs.js","../src/defines.ts","../src/dyno/types.ts","../src/dyno/value.ts","../src/dyno/base.ts","../src/dyno/splats.ts","../src/dyno/output.ts","../src/dyno/uniforms.ts","../src/utils.ts","../src/dyno/program.ts","../src/dyno/mathTypes.ts","../src/dyno/math.ts","../src/dyno/logic.ts","../src/dyno/convert.ts","../src/dyno/vecmat.ts","../src/dyno/util.ts","../src/dyno/transform.ts","../src/dyno/control.ts","../src/dyno/texture.ts","../src/dyno/trig.ts","../src/shaders/computeVec4.glsl","../src/Readback.ts","../src/RgbaArray.ts","../src/SplatEdit.ts","../src/SplatGenerator.ts","../src/SplatMesh.ts","../src/ply.ts","../src/splatWorker.ts","../src/SplatLoader.ts","../src/shaders/computeUvec4.glsl","../src/PackedSplats.ts","../src/SplatGeometry.ts","../src/SparkViewpoint.ts","../src/SplatAccumulator.ts","../src/shaders/splatDefines.glsl","../src/shaders/splatFragment.glsl","../src/shaders/splatVertex.glsl","../src/shaders.ts","../src/SparkRenderer.ts","../src/antisplat.ts","../src/ksplat.ts","../src/spz.ts","../src/SplatSkinning.ts","../src/splatConstructors.ts","../src/generators/static.ts","../src/generators/snow.ts","../src/modifiers/normalColor.ts","../src/modifiers/depthColor.ts","../src/vrButton.ts","../src/hands.ts","../src/controls.ts"],"sourcesContent":["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebGLRLine truncated
|
||||
{"version":3,"file":"spark.cjs.min.js","sources":["../node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/fflate/esm/browser.js","../rust/spark-internal-rs/pkg/spark_internal_rs.js","../src/defines.ts","../src/dyno/types.ts","../src/dyno/value.ts","../src/dyno/base.ts","../src/dyno/splats.ts","../src/dyno/output.ts","../src/dyno/uniforms.ts","../src/utils.ts","../src/dyno/program.ts","../src/dyno/mathTypes.ts","../src/dyno/math.ts","../src/dyno/logic.ts","../src/dyno/convert.ts","../src/dyno/vecmat.ts","../src/dyno/util.ts","../src/dyno/transform.ts","../src/dyno/control.ts","../src/dyno/texture.ts","../src/dyno/trig.ts","../src/shaders/computeVec4.glsl","../src/Readback.ts","../src/RgbaArray.ts","../src/SplatEdit.ts","../src/SplatGenerator.ts","../src/SplatMesh.ts","../src/ply.ts","../src/splatWorker.ts","../src/SplatLoader.ts","../src/shaders/computeUvec4.glsl","../src/PackedSplats.ts","../src/SplatGeometry.ts","../src/SparkViewpoint.ts","../src/SplatAccumulator.ts","../src/shaders/splatDefines.glsl","../src/shaders/splatFragment.glsl","../src/shaders/splatVertex.glsl","../src/shaders.ts","../src/SparkRenderer.ts","../src/antisplat.ts","../src/ksplat.ts","../src/spz.ts","../src/SplatSkinning.ts","../src/splatConstructors.ts","../src/generators/static.ts","../src/generators/snow.ts","../src/modifiers/normalColor.ts","../src/modifiers/depthColor.ts","../src/vrButton.ts","../src/hands.ts","../src/controls.ts"],"sourcesContent":["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebGLRLine truncated
|
||||
Vendored
+24
-33
@@ -7215,6 +7215,7 @@ const _SplatMesh = class _SplatMesh extends SplatGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.add(createRendererDetectionMesh());
|
||||
}
|
||||
async asyncInitialize(options) {
|
||||
const {
|
||||
@@ -7772,6 +7773,29 @@ function evaluateSH3(gsplat, sh3, viewDir) {
|
||||
`)
|
||||
}).outputs.rgb;
|
||||
}
|
||||
const EMPTY_GEOMETRY$1 = new THREE.BufferGeometry();
|
||||
const EMPTY_MATERIAL = new THREE.ShaderMaterial();
|
||||
function createRendererDetectionMesh() {
|
||||
const mesh = new THREE.Mesh(EMPTY_GEOMETRY$1, EMPTY_MATERIAL);
|
||||
mesh.frustumCulled = false;
|
||||
mesh.onBeforeRender = function(renderer, scene) {
|
||||
if (!scene.isScene) {
|
||||
this.removeFromParent();
|
||||
return;
|
||||
}
|
||||
let hasSparkRenderer = false;
|
||||
scene.traverse((c) => {
|
||||
if (c instanceof SparkRenderer) {
|
||||
hasSparkRenderer = true;
|
||||
}
|
||||
});
|
||||
if (!hasSparkRenderer) {
|
||||
scene.add(new SparkRenderer({ renderer }));
|
||||
}
|
||||
this.removeFromParent();
|
||||
};
|
||||
return mesh;
|
||||
}
|
||||
const PLY_PROPERTY_TYPES = [
|
||||
"char",
|
||||
"uchar",
|
||||
@@ -10309,38 +10333,6 @@ function getShaders() {
|
||||
return shaders;
|
||||
}
|
||||
const MAX_ACCUMULATORS = 5;
|
||||
let hasSplatMesh = false;
|
||||
let hasSparkRenderer = false;
|
||||
let sparkRendererInstance;
|
||||
function containsSplatMesh(object3D) {
|
||||
let hasSplatMesh2 = false;
|
||||
if (object3D instanceof SplatMesh) {
|
||||
return true;
|
||||
}
|
||||
object3D.traverse((child) => {
|
||||
hasSplatMesh2 = hasSplatMesh2 || child instanceof SplatMesh;
|
||||
});
|
||||
return hasSplatMesh2;
|
||||
}
|
||||
const sceneAdd = THREE.Scene.prototype.add;
|
||||
THREE.Scene.prototype.add = function(object) {
|
||||
hasSplatMesh = hasSplatMesh || containsSplatMesh(object);
|
||||
hasSparkRenderer = hasSparkRenderer || object instanceof SparkRenderer;
|
||||
sceneAdd.call(this, object);
|
||||
return this;
|
||||
};
|
||||
const sceneOnBeforeRender = THREE.Scene.prototype.onBeforeRender;
|
||||
THREE.Scene.prototype.onBeforeRender = function(renderer) {
|
||||
if (!hasSplatMesh) {
|
||||
return;
|
||||
}
|
||||
if (!hasSparkRenderer) {
|
||||
const spark = sparkRendererInstance || new SparkRenderer({ renderer });
|
||||
this.add(spark);
|
||||
}
|
||||
THREE.Scene.prototype.onBeforeRender = sceneOnBeforeRender;
|
||||
THREE.Scene.prototype.add = sceneAdd;
|
||||
};
|
||||
const _SparkRenderer = class _SparkRenderer extends THREE.Mesh {
|
||||
constructor(options) {
|
||||
const uniforms = _SparkRenderer.makeUniforms();
|
||||
@@ -10423,7 +10415,6 @@ const _SparkRenderer = class _SparkRenderer extends THREE.Mesh {
|
||||
this.viewpoint = this.defaultView;
|
||||
this.prepareViewpoint(this.viewpoint);
|
||||
this.clock = options.clock ? cloneClock(options.clock) : new THREE.Clock();
|
||||
sparkRendererInstance = this;
|
||||
}
|
||||
static makeUniforms() {
|
||||
const uniforms = {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"spark.module.js","sources":["../node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/fflate/esm/browser.js","../rust/spark-internal-rs/pkg/spark_internal_rs.js","../src/defines.ts","../src/dyno/types.ts","../src/dyno/value.ts","../src/dyno/base.ts","../src/dyno/splats.ts","../src/dyno/output.ts","../src/dyno/uniforms.ts","../src/utils.ts","../src/dyno/program.ts","../src/dyno/mathTypes.ts","../src/dyno/math.ts","../src/dyno/logic.ts","../src/dyno/convert.ts","../src/dyno/vecmat.ts","../src/dyno/util.ts","../src/dyno/transform.ts","../src/dyno/control.ts","../src/dyno/texture.ts","../src/dyno/trig.ts","../src/shaders/computeVec4.glsl","../src/Readback.ts","../src/RgbaArray.ts","../src/SplatEdit.ts","../src/SplatGenerator.ts","../src/SplatMesh.ts","../src/ply.ts","../src/splatWorker.ts","../src/SplatLoader.ts","../src/shaders/computeUvec4.glsl","../src/PackedSplats.ts","../src/SplatGeometry.ts","../src/SparkViewpoint.ts","../src/SplatAccumulator.ts","../src/shaders/splatDefines.glsl","../src/shaders/splatFragment.glsl","../src/shaders/splatVertex.glsl","../src/shaders.ts","../src/SparkRenderer.ts","../src/antisplat.ts","../src/ksplat.ts","../src/spz.ts","../src/SplatSkinning.ts","../src/splatConstructors.ts","../src/generators/static.ts","../src/generators/snow.ts","../src/modifiers/normalColor.ts","../src/modifiers/depthColor.ts","../src/vrButton.ts","../src/hands.ts","../src/controls.ts"],"sourcesContent":["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebGLReLine truncated
|
||||
{"version":3,"file":"spark.module.js","sources":["../node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/fflate/esm/browser.js","../rust/spark-internal-rs/pkg/spark_internal_rs.js","../src/defines.ts","../src/dyno/types.ts","../src/dyno/value.ts","../src/dyno/base.ts","../src/dyno/splats.ts","../src/dyno/output.ts","../src/dyno/uniforms.ts","../src/utils.ts","../src/dyno/program.ts","../src/dyno/mathTypes.ts","../src/dyno/math.ts","../src/dyno/logic.ts","../src/dyno/convert.ts","../src/dyno/vecmat.ts","../src/dyno/util.ts","../src/dyno/transform.ts","../src/dyno/control.ts","../src/dyno/texture.ts","../src/dyno/trig.ts","../src/shaders/computeVec4.glsl","../src/Readback.ts","../src/RgbaArray.ts","../src/SplatEdit.ts","../src/SplatGenerator.ts","../src/SplatMesh.ts","../src/ply.ts","../src/splatWorker.ts","../src/SplatLoader.ts","../src/shaders/computeUvec4.glsl","../src/PackedSplats.ts","../src/SplatGeometry.ts","../src/SparkViewpoint.ts","../src/SplatAccumulator.ts","../src/shaders/splatDefines.glsl","../src/shaders/splatFragment.glsl","../src/shaders/splatVertex.glsl","../src/shaders.ts","../src/SparkRenderer.ts","../src/antisplat.ts","../src/ksplat.ts","../src/spz.ts","../src/SplatSkinning.ts","../src/splatConstructors.ts","../src/generators/static.ts","../src/generators/snow.ts","../src/modifiers/normalColor.ts","../src/modifiers/depthColor.ts","../src/vrButton.ts","../src/hands.ts","../src/controls.ts"],"sourcesContent":["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebGLReLine truncated
|
||||
Vendored
+1353
-1360
File diff suppressed because it is too large.
Load diff
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"spark.module.min.js","sources":["../node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/fflate/esm/browser.js","../rust/spark-internal-rs/pkg/spark_internal_rs.js","../src/defines.ts","../src/dyno/types.ts","../src/dyno/value.ts","../src/dyno/base.ts","../src/dyno/splats.ts","../src/dyno/output.ts","../src/dyno/uniforms.ts","../src/utils.ts","../src/dyno/program.ts","../src/dyno/mathTypes.ts","../src/dyno/math.ts","../src/dyno/logic.ts","../src/dyno/convert.ts","../src/dyno/vecmat.ts","../src/dyno/util.ts","../src/dyno/transform.ts","../src/dyno/control.ts","../src/dyno/texture.ts","../src/dyno/trig.ts","../src/shaders/computeVec4.glsl","../src/Readback.ts","../src/RgbaArray.ts","../src/SplatEdit.ts","../src/SplatGenerator.ts","../src/SplatMesh.ts","../src/ply.ts","../src/splatWorker.ts","../src/SplatLoader.ts","../src/shaders/computeUvec4.glsl","../src/PackedSplats.ts","../src/SplatGeometry.ts","../src/SparkViewpoint.ts","../src/SplatAccumulator.ts","../src/shaders/splatDefines.glsl","../src/shaders/splatFragment.glsl","../src/shaders/splatVertex.glsl","../src/shaders.ts","../src/SparkRenderer.ts","../src/antisplat.ts","../src/ksplat.ts","../src/spz.ts","../src/SplatSkinning.ts","../src/splatConstructors.ts","../src/generators/static.ts","../src/generators/snow.ts","../src/modifiers/normalColor.ts","../src/modifiers/depthColor.ts","../src/vrButton.ts","../src/hands.ts","../src/controls.ts"],"sourcesContent":["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebLine truncated
|
||||
{"version":3,"file":"spark.module.min.js","sources":["../node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/fflate/esm/browser.js","../rust/spark-internal-rs/pkg/spark_internal_rs.js","../src/defines.ts","../src/dyno/types.ts","../src/dyno/value.ts","../src/dyno/base.ts","../src/dyno/splats.ts","../src/dyno/output.ts","../src/dyno/uniforms.ts","../src/utils.ts","../src/dyno/program.ts","../src/dyno/mathTypes.ts","../src/dyno/math.ts","../src/dyno/logic.ts","../src/dyno/convert.ts","../src/dyno/vecmat.ts","../src/dyno/util.ts","../src/dyno/transform.ts","../src/dyno/control.ts","../src/dyno/texture.ts","../src/dyno/trig.ts","../src/shaders/computeVec4.glsl","../src/Readback.ts","../src/RgbaArray.ts","../src/SplatEdit.ts","../src/SplatGenerator.ts","../src/SplatMesh.ts","../src/ply.ts","../src/splatWorker.ts","../src/SplatLoader.ts","../src/shaders/computeUvec4.glsl","../src/PackedSplats.ts","../src/SplatGeometry.ts","../src/SparkViewpoint.ts","../src/SplatAccumulator.ts","../src/shaders/splatDefines.glsl","../src/shaders/splatFragment.glsl","../src/shaders/splatVertex.glsl","../src/shaders.ts","../src/SparkRenderer.ts","../src/antisplat.ts","../src/ksplat.ts","../src/spz.ts","../src/SplatSkinning.ts","../src/splatConstructors.ts","../src/generators/static.ts","../src/generators/snow.ts","../src/modifiers/normalColor.ts","../src/modifiers/depthColor.ts","../src/vrButton.ts","../src/hands.ts","../src/controls.ts"],"sourcesContent":["import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebLine truncated
|
||||
Reference in new issue
Block a user