MCPcopy
hub / github.com/sparkjsdev/spark / ensureGenerate

Method ensureGenerate

src/PackedSplats.ts:637–663  ·  view source on GitHub ↗
(maxSplats: number)

Source from the content-addressed store, hash-verified

635 // Ensures our PackedSplats.target render target has enough space to generate
636 // maxSplats total Gsplats, and reallocate if not large enough.
637 ensureGenerate(maxSplats: number): boolean {
638 if (this.target && (maxSplats ?? 1) <= this.maxSplats) {
639 return false;
640 }
641 if (this.target) {
642 this.target.dispose();
643 }
644
645 const textureSize = getTextureSize(maxSplats ?? 1);
646 const { width, height, depth } = textureSize;
647 this.maxSplats = textureSize.maxSplats;
648
649 // The packed Gsplats are stored in a 2D array texture of max size
650 // 2048 x 2048 x 2048, one RGBA32UI pixel = 4 uint32 = one Gsplat
651 this.target = new THREE.WebGLArrayRenderTarget(width, height, depth, {
652 depthBuffer: false,
653 stencilBuffer: false,
654 generateMipmaps: false,
655 magFilter: THREE.NearestFilter,
656 minFilter: THREE.NearestFilter,
657 });
658 this.target.texture.format = THREE.RGBAIntegerFormat;
659 this.target.texture.type = THREE.UnsignedIntType;
660 this.target.texture.internalFormat = "RGBA32UI";
661 this.target.scissorTest = true;
662 return true;
663 }
664
665 // Given an array of splatCounts (.numSplats for each
666 // SplatGenerator/SplatMesh in the scene), compute a

Callers 1

updateInternalMethod · 0.45

Calls 2

getTextureSizeFunction · 0.90
disposeMethod · 0.65

Tested by

no test coverage detected