Repeated updates for individual instance positions of SkinnedMesh with InstancedBufferAttribute

I should preface by saying I’m working off a local copy of three.js version 161

I’ve tried to adapt the code from this example to modify individual instances repeatedly:

https://threejs.org/examples/webgpu_skinning_instancing

but I can only get the update to occur on the first call, and subsequent calls do not change the instance positions.

I have tried manually setting the x and z elements of the instance matrix. This function is set up as an event handler and is called repeatedly:


  RepositionInstances() {
    for (let i = 0; i < this.instanceCount_; i ++) {
      this.mesh.instanceMatrix.array[i * 16 + 12] = Math.random() * 400;
      this.mesh.instanceMatrix.array[i * 16 + 13] = Math.random() * 400;
    }
    this.mesh.instanceMatrix.needsUpdate = true;
  }

I would expect each instance to be randomly repositioned each time this function is called, but they are updated only once.

Is it possible to individually update the positions of SkinnedMesh instances repeatedly?

I can see that the Float32Array of the InstancedBufferAttribute is being updated on each call, but for some reason the rendered positions do not change. Is there another update property that needs to be set?

I have tried setting this.mesh.matrixAutoUpdate = false but it does not seem to work.

I have also tried using this.mesh.computeBoundingBox() and this.mesh.computeBoundingSphere() but still only one update is made.

I am able to step thru the three.js code and see that the version is not getting updated for this InstancedBufferAttribute, and actually it seems to appear as type InstancedInterleavedBuffer, which makes me suspect that a different object is being used to track updates to the GPU than the original one used for creation.

I can also confirm that changing L57 of Attributes.js from < to <= will allow the necessary updates to be made:

if ( data.version <= bufferAttribute.version || bufferAttribute.usage === DynamicDrawUsage ) {
    ...
}

Looking at the cited L57 of Attributes.js, I’m curious whether it will work if you use the setUsage method with parameter DynamicDrawUsage. In this way you may keep the file unmodified.