Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InstancedBufferGeometry.instanceCount incorrectly #19595

Closed
3 of 13 tasks
sanddyl opened this issue Jun 9, 2020 · 7 comments
Closed
3 of 13 tasks

InstancedBufferGeometry.instanceCount incorrectly #19595

sanddyl opened this issue Jun 9, 2020 · 7 comments

Comments

@sanddyl
Copy link

sanddyl commented Jun 9, 2020

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
  • r117
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)
@WestLangley
Copy link
Collaborator

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

@sanddyl
Copy link
Author

sanddyl commented Jun 9, 2020

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

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

@WestLangley
Copy link
Collaborator

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.

@sanddyl
Copy link
Author

sanddyl commented Jun 9, 2020

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.

@sanddyl
Copy link
Author

sanddyl commented Jun 9, 2020

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.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 9, 2020

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/

@sanddyl
Copy link
Author

sanddyl commented Jun 9, 2020

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

@sanddyl sanddyl closed this as completed Jun 9, 2020
lojjic added a commit to protectwise/troika that referenced this issue Jul 19, 2020
Fixes #69. This works around an issue introduced in Three r117 where a
given geometry uses the size of any InstancedBufferAttribute as a max
for `instanceCount`, and caches that for the lifetime of the geometry
even if the attribute is replaced with one of a different size.

It's unclear if this is a ThreeJS bug or a if our approach of "resizing"
by replacing the attribute is truly unsupported; the discussion in
mrdoob/three.js#19706 is ambiguous,
mrdoob/three.js#19595 implies it's not
allowed, and mrdoob/three.js#17418 implies it
should be allowed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants