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

Method constructor

src/SplatMesh.ts:312–445  ·  view source on GitHub ↗
(options: SplatMeshOptions = {})

Source from the content-addressed store, hash-verified

310 showLodPageDyno = new DynoInt({ value: 0 });
311
312 constructor(options: SplatMeshOptions = {}) {
313 super({
314 update: (context) => this.update(context),
315 });
316
317 if (options.splats) {
318 this.splats = options.splats;
319 this.numSplats = options.splats.getNumSplats();
320 } else if (options.paged) {
321 if (options.extSplats) {
322 console.warn(
323 "To set extSplats with the paged option, set SparkRenderer.pagedExtSplats",
324 );
325 }
326 const rootUrl = options.url ?? "";
327 if (options.paged === true) {
328 this.paged = new PagedSplats({ rootUrl });
329 } else if (options.paged instanceof PagedSplats) {
330 this.paged = options.paged;
331 } else if (options.paged instanceof SplatPager) {
332 this.paged = new PagedSplats({ rootUrl, pager: options.paged });
333 } else {
334 throw new Error("Invalid paged option");
335 }
336 this.splats = this.paged;
337 } else if (options.extSplats) {
338 this.extSplats =
339 options.extSplats instanceof ExtSplats
340 ? options.extSplats
341 : new ExtSplats();
342 options.extSplats = this.extSplats;
343 this.numSplats = this.extSplats.numSplats;
344 this.splats = this.extSplats;
345 } else if (options.packedSplats) {
346 this.packedSplats = options.packedSplats;
347 this.packedSplats.splatEncoding = options.splatEncoding ?? {
348 ...DEFAULT_SPLAT_ENCODING,
349 };
350 this.splats = this.packedSplats;
351 } else {
352 this.packedSplats = new PackedSplats();
353 }
354
355 this.editable = options.editable ?? true;
356 this.raycastable = options.raycastable ?? true;
357 this.minRaycastOpacity = options.minRaycastOpacity ?? 0.2;
358 this.onFrame = options.onFrame;
359
360 this.context = {
361 transform: new SplatTransformer(),
362 viewToWorld: new SplatTransformer(),
363 worldToView: new SplatTransformer(),
364 viewToObject: new SplatTransformer(),
365 covTransform: new CovSplatTransformer(),
366 covViewToWorld: new CovSplatTransformer(),
367 covWorldToView: new CovSplatTransformer(),
368 covViewToObject: new CovSplatTransformer(),
369 recolor: new DynoVec4({

Callers

nothing calls this directly

Calls 4

updateMethod · 0.95
updateGeneratorMethod · 0.95
asyncInitializeMethod · 0.95
getNumSplatsMethod · 0.65

Tested by

no test coverage detected