-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
SkinnedMesh+InstancedMesh: Removing the buffer array in onUploadCallback throws errors while rendering #25960
Comments
I think your workflow is problematic and it just became visible in recent versions of Using the If you decide to delete buffer data right after the upload, you have to define bounding volumes by yourself. This will avoid the call of In any event, some suggestions of your proposed fixes make sense. E.g. the bounding volumes should be honored by |
Regarding point 3. We had to introduce bounding volumes on certain object3D classes since the bounding volumes on geometry level can't access all information which are required to compute correct results. However, I'm not sure how I feel with completely removing the bounding volumes on geometry level though. But I agree some API clean up to avoid the pattern in |
What if we were to make a change like this? This way we could keep
|
I think it would make more sense not to extend Object3D with a Renderable class but rather just update Object3D (because all objects are assumed to be renderable, no?). |
I'm defining "renderable" as an object that has a |
Description
I'm using
onUploadCallback
to remove the array because it saves hundreds of MB of RAM in our application.With r150, this was a safe operation that didn't have any problems. Starting with r151 though, there have been a few changes to the
WebGLRenderer
's render pipeline regarding the bounding sphere's usage: #25913, #25591. In the case ofSkinnedMesh
andInstancedMesh
, the bounding sphere is now stored on theObject3D
itself, which can cause the bounding sphere to recompute afteronUploadCallback
runs. I'm seeing errors like this:I'm able to use this workaround during model initialization to prevent the renderer from doing the computation too late:
Here's my best guest as to how this can be fixed in three.js source:
Object3D.copy()
(or in each applicable subclass), make sure to copy theboundingSphere
thatSkinned/InstancedMesh
creates if it exists. If we look inBufferGeometry.copy
, it also clones the bounding sphere.WebGLRenderer.projectObject()
, during depth sorting, useobject.boundingSphere
instead ofgeometry.boundingSphere
for the case ofSkinned/InstancedMesh
. If we look inFrustum.intersectsObject()
, it's doing the same distinction that I thinkprojectObject()
should also be doing. (It's a little awkward though thatboundingSphere === null
vs.boundingSphere === undefined
is howFrustum
distinguishes between a normalMesh
vs.Skinned/InstancedMesh
)Mesh.computeBoundingSphere/Box()
and override the pair inSkinned/InstancedMesh
. Then we could removeBufferGeometry.computeBoundingBlah()
entirely and never have to detect whether to useobject.boundingSphere
vs.geometry.boundingSphere
.Reproduction steps
a. Change
BufferAttribute.prototype.onUploadCallback
to set the array to nullb. Clone the stormtrooper mesh (clonetrooper??)
Code
/
Live example
/
Screenshots
No response
Version
r152
Device
Desktop
Browser
Chrome
OS
Linux
The text was updated successfully, but these errors were encountered: