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

Function makeDepthColorModifier

src/modifiers/depthColor.ts:17–36  ·  view source on GitHub ↗
(
  splatToView: SplatTransformer,
  minDepth: DynoVal<"float">,
  maxDepth: DynoVal<"float">,
  reverse: DynoVal<"bool">,
)

Source from the content-addressed store, hash-verified

15} from "../dyno";
16
17export function makeDepthColorModifier(
18 splatToView: SplatTransformer,
19 minDepth: DynoVal<"float">,
20 maxDepth: DynoVal<"float">,
21 reverse: DynoVal<"bool">,
22) {
23 return dynoBlock({ gsplat: Gsplat }, { gsplat: Gsplat }, ({ gsplat }) => {
24 if (!gsplat) {
25 throw new Error("No gsplat input");
26 }
27 let { center } = splitGsplat(gsplat).outputs;
28 center = splatToView.apply(center);
29 const { z } = split(center).outputs;
30 let depth = normalizedDepth(neg(z), minDepth, maxDepth);
31 depth = select(reverse, sub(dynoConst("float", 1), depth), depth);
32
33 gsplat = combineGsplat({ gsplat, r: depth, g: depth, b: depth });
34 return { gsplat };
35 });
36}
37
38export function setDepthColor(
39 splats: SplatMesh,

Callers 1

setDepthColorFunction · 0.85

Calls 10

dynoBlockFunction · 0.90
splitGsplatFunction · 0.90
splitFunction · 0.90
normalizedDepthFunction · 0.90
negFunction · 0.90
selectFunction · 0.90
subFunction · 0.90
dynoConstFunction · 0.90
combineGsplatFunction · 0.90
applyMethod · 0.45

Tested by

no test coverage detected