Skip to content

Seven REVIEW(shared-instance) markers are candidates for <Instances>/InstancedMesh #3

Description

@DennisSmolek

What

House style rule 3 has a carve-out: a single material/geometry instance shared by many
meshes gets useMemo(() => new X()) + material={…} instead of a JSX child (JSX would
create one instance per mesh), flagged with a REVIEW(shared-instance): comment for a
human to weigh whether the scene actually wants <Instances>/InstancedMesh instead.

Seven live in the corpus:

file what's shared
postprocessing-ao/Furniture.tsx:51 3 materials across ~20 meshes
postprocessing-ao/Gallery.tsx:160 wall material ×3, column material ×N
scene/backdrop-water/WaterScene.tsx:51 1 geometry + 1 material across 100 icosahedra
scene/backdrop-area.tsx:94 4 materials, picked by prop (see review-queue #9)
compute-particles-snow/SnowParticles.tsx:207 1 sphere across both instanced meshes
compute-particles-snow/SnowScenery.tsx:27 1 material for 8 tree cones + trunk
tsl/tsl-angular-slicing.tsx:73 2 physical materials over a traversed GLTF

WaterScene's 100 icosahedra sharing one geometry + one material is the strongest
<Instances> candidate of the seven — the clearest case where per-mesh draw calls are
being paid for no visual reason.

Why it matters

Performance/style polish across seven single-demo files, not a correctness bug and not
site-wide — the rule's carve-out is working as intended (each is REVIEW-flagged rather
than silently accepted). Worth tracking as a batch rather than fixing ad hoc, since
converting to <Instances> changes the component shape (data-driven instances vs. JSX
children) and is worth doing consistently if done at all.

Recommendation already on file

docs/REVIEW-QUEUE.md #8: review each of the seven for whether <Instances> is a better
fit, starting with WaterScene as the strongest candidate. Not urgent — the current code
is correct and performant, just possibly not idiomatic.

Pointer

docs/REVIEW-QUEUE.md §8 ("Shared-instance markers — is <Instances> the real answer?").
See also §9, which covers backdrop-area.tsx's variant of the pattern (N instances, one
live, picked by a leva switcher) — decided separately as "leave marked, no new rule needed
yet" since it's a single occurrence.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions