Three.js: InstancedBufferGeometry.instanceCount incorrectly

Created on 9 Jun 2020  路  7Comments  路  Source: mrdoob/three.js

Description of the problem

When I changed InstancedBufferGeometry.instanceCount, I found that the _maxInstanceCount not changed. This will cause the InstancedBufferGeometry to display incorrectly.
W99N1@YTXLI_7BMX7TOGX51

Three.js version
  • [ ] Dev
  • [x] r117
  • [ ] ...
Browser
  • [x] All of them
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [x] All of them
  • [ ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Hardware Requirements (graphics card, VR Device, ...)

Most helpful comment

Thanks a lot ! I will avoid such problems in the future.

All 7 comments

@sanddyl Can you please provide a simple, live demo to show exactly what you did to cause the issue?

@sanddyl Can you please provide a simple, live demo to show exactly what you did to cause the issue?

https://jsfiddle.net/s3xco4hk/95/

You are resizing the attribute buffer. That is not supported.

See https://threejs.org/docs/#manual/en/introduction/How-to-update-things.

/ping @Mugen87 for confirmation.

You are resizing the attribute buffer. That is not supported.

See https://threejs.org/docs/#manual/en/introduction/How-to-update-things.

/ping @Mugen87 for confirmation.

I quite agree,but when I need to modify maxInstanceCount, instanceCount can not achieve my purpose, even if this is rare. I mean, the instanceCount in version 117 is not equal to the maxInstancedCount in the previous version.

You are resizing the attribute buffer. That is not supported.

See https://threejs.org/docs/#manual/en/introduction/How-to-update-things.

/ping @Mugen87 for confirmation.

Maybe both maxInstancedCount and instanceCount are required.

Yes, buffers can't be resized. The idea is to create a sufficiently sized buffer and then control via drawRange or instanceCount (when using InstancedBufferGeometry) the rendering. This approach is demonstrated by webgl_buffergeometry_instancing.

Maybe both maxInstancedCount and instanceCount are required.

Nope. It does work by just using instanceCount. Check out how the updated fiddle controls the amount of rendered instances.

https://jsfiddle.net/brs1f5oa/

Thanks a lot ! I will avoid such problems in the future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jack-jun picture jack-jun  路  3Comments

akshaysrin picture akshaysrin  路  3Comments

jlaquinte picture jlaquinte  路  3Comments

yqrashawn picture yqrashawn  路  3Comments

scrubs picture scrubs  路  3Comments