One draw (§64), as a discriminated union on RenderItemKind.
for (constitemofbuildRenderList(scene, out)) { if (item.kind === "sprite") { bind(item.material.texture); // narrowed to SpriteMaterial } elseif (item.kind === "particles") { upload(item.instances, item.count); } else { upload(item.material.color); // narrowed to UnlitMaterial } }
A union rather than one interface with a widened material so that a backend
gets the concrete material type from an ordinary kind check, with no cast
and no instanceof on the draw path. The builders pay for that with one
documented cast where the invariant is actually established — see
itemAt.
One draw (§64), as a discriminated union on RenderItemKind.
A union rather than one interface with a widened
materialso that a backend gets the concrete material type from an ordinarykindcheck, with no cast and noinstanceofon the draw path. The builders pay for that with one documented cast where the invariant is actually established — seeitemAt.