Skip to content

instanceColor attribute is not defined when InstancedMesh is populated asynchronously #21786

Description

Just as the title says. It all boils down to this line https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLPrograms.js#L171. Setting any color for any instance just after the instanced mesh is created, solves the issue. But this is not obvious and looks like it's not documented.

To Reproduce

  1. Prepare a scene with InstancedMesh
  2. Render it
  3. Populate the instanced mesh asynchronously

Live example

jsfiddle

Expected behavior

When setColorAt is called, the shader should be recompiled to include the instanceColor. Or there should be a valid and documented way to make sure that this attribute is always defined.

Platform

  • Device: Desktop
  • OS: Windows
  • Browser: Chrome
  • Three.js version: r128

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions