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

Method getLodTreeLevel

src/SparkRenderer.ts:2045–2079  ·  view source on GitHub ↗
(
    splats: SplatMesh,
    level: number,
    pageColoring = false,
  )

Source from the content-addressed store, hash-verified

2043 }
2044
2045 async getLodTreeLevel(
2046 splats: SplatMesh,
2047 level: number,
2048 pageColoring = false,
2049 ) {
2050 const instance = this.lodInstances.get(splats);
2051 if (!instance) {
2052 return null;
2053 }
2054
2055 const result = await this.ensureLodWorker().exclusive(async (worker) => {
2056 return (await worker.call("getLodTreeLevel", {
2057 lodId: instance.lodId,
2058 level,
2059 })) as { indices: Uint32Array };
2060 });
2061
2062 if (splats.packedSplats?.lodSplats) {
2063 const newSplats = splats.packedSplats.lodSplats.extractSplats(
2064 result.indices,
2065 pageColoring,
2066 );
2067 return new SplatMesh({ packedSplats: newSplats });
2068 }
2069 if (splats.extSplats?.lodSplats) {
2070 const newSplats = splats.extSplats.lodSplats.extractSplats(
2071 result.indices,
2072 pageColoring,
2073 );
2074 return new SplatMesh({ extSplats: newSplats });
2075 }
2076 throw new Error(
2077 "Only LoD-enabled PackedSplats and ExtSplats are supported",
2078 );
2079 }
2080
2081 get premultipliedAlpha(): boolean {
2082 return this.material.premultipliedAlpha;

Callers

nothing calls this directly

Calls 4

ensureLodWorkerMethod · 0.95
exclusiveMethod · 0.80
callMethod · 0.45
extractSplatsMethod · 0.45

Tested by

no test coverage detected