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

Class ExtSplats

src/ExtSplats.ts:76–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74};
75
76export class ExtSplats implements SplatSource {
77 maxSplats = 0;
78 numSplats = 0;
79 extArrays: [Uint32Array, Uint32Array];
80 extra: Record<string, unknown> = {};
81 maxSh = 3;
82 lod?: boolean | "quality";
83 nonLod?: boolean;
84 lodSplats?: ExtSplats;
85
86 initialized: Promise<ExtSplats>;
87 isInitialized = false;
88
89 textures: [THREE.DataArrayTexture, THREE.DataArrayTexture];
90
91 // A PackedSplats can be used in a dyno graph using the below property dyno:
92 // const gsplat = dyno.readPackedSplats(this.dyno, dynoIndex);
93 dyno: DynoUniform<typeof TExtSplats, "extSplats">;
94 dynoNumSh: DynoInt<"numSh">;
95
96 constructor(options: ExtSplatsOptions = {}) {
97 this.extArrays = [new Uint32Array(0), new Uint32Array(0)];
98 this.textures = [ExtSplats.emptyTexture, ExtSplats.emptyTexture];
99
100 this.extra = {};
101 this.dyno = new DynoExtSplats({ extSplats: this });
102 this.dynoNumSh = new DynoInt({
103 key: "numSh",
104 value: 0,
105 update: () => {
106 return Math.min(this.getNumSh(), this.maxSh);
107 },
108 });
109
110 // The following line will be overridden by reinitialize()
111 this.initialized = Promise.resolve(this);
112 this.reinitialize(options);
113 }
114
115 reinitialize(options: ExtSplatsOptions) {
116 this.isInitialized = false;
117
118 this.extra = {};
119 this.maxSplats = options.maxSplats ?? 0;
120 this.lod = options.lod;
121 this.nonLod = options.nonLod;
122
123 if (
124 options.url ||
125 options.fileBytes ||
126 options.stream ||
127 options.construct
128 ) {
129 // We need to initialize asynchronously given the options
130 this.initialized = this.asyncInitialize(options).then(() => {
131 this.isInitialized = true;
132 return this;
133 });

Callers

nothing calls this directly

Calls 2

getTextureSizeFunction · 0.90
newUint32ArrayTextureFunction · 0.85

Tested by

no test coverage detected