-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Skip unnecessary matrices update in performance_static example #15862
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
Conversation
85d4bf5 to
253f84e
Compare
|
Thanks! |
|
Setting I expect there are very few users that understand this subtly. I wonder if this will cause confusion... Users copy these examples. |
|
True that. We should probably revert this. |
|
Setting https://threejs.org/docs/#manual/en/introduction/Matrix-transformations I think this example with |
|
I don't know... This specific example is more about performance testing. A better practice would be to merge all these meshes, or to use instancing... |
|
I am quite surprised to see four three.js examples with scene.matrixAutoUpdate = false;I wonder if the authors of those examples understood what this did. Do you think other users should be copying this pattern? |
Yes, this example is for static objects performance test. So I thought user expects to see the performance of an example optimized for static objects (maybe without instancing nor merging). |
Personally, I think yes. Because as we discussed #14138 (comment) it's difficult on our current API to automatically skip unnecessary matrices update so I think better to encourage setting Do you think for users it's hard to understand and/or problematic to use? |
|
From my point of view, the "average" user should not bother with this flag. Otherwise they will be surprised why certain transformation changes do not have any affect. I think the ultimate goal is to have some sort caching in the near future so this flag becomes more or less obsolete. Even if this means to change the API in context of Because of this, I agree with @WestLangley. We should consider to clean up the other four examples. |
|
Even if we end up removing is for skipping unnecessary matrices update and I was surprised to see unnecessary world matrices update function spends a lot of time when I got CPU profile. Probably this isn't intentional. I think if we add comment like this, it isn't confusing to users. What do you think? (Feel free to improve and simplify the comment.) // Set .matrixAutoUpdate = false here for skipping unnecessary matrices calculation for static object.
// Note that by setting this flag false .position/quaternion/scale change doesn't affect to transform
// without explicitly calling .updateMatrix(). You shouldn't set false for dynamic objects.
// See https://threejs.org/docs/#manual/en/introduction/Matrix-transformations
scene.matrixAutoUpdate = false;BTW
I thought it may not be doable in short term because the API change can break a lot of core/example/user code so I suggested setting flag false. Yeah of course happy if we can do in the near future tho. Update: Or the purpose may be clearer by adding |
That sounds good to me. |
I think
scene.matrixAutoUpdateshould befalseinperformance_static.htmlexample. Otherwise, rootscenelocal and world matrices are updated and then the world matrices of all the objects under thesceneare unnecessarily updated every frame.https://github.com/mrdoob/three.js/blob/r101/src/core/Object3D.js#L593-L634
Another option is
scene.autoUpdate = false.