-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Advanced render items sorting / customizable render lists #13732
Comments
I'm not sure I understand this concern — |
You also try to set |
@Mugen87 I forgot to mention this -> all of the layers (except the last one on the top) have @donmccurdy Lets say I implement a surface that will render list of items/images on the surface in the order of insertion. I would like to have many of those layers and would prefer not to set |
@coder89 For the 'readability and encapsulation' of the rendering logic you should add a level of abstraction to your gui managing internaly the renderOrder via a system of DisplayObject / DisplayObjectContainer => parse every frame and setting the right renderOrder. Keep it independent from threejs will make the code much easier and reusable. |
Any chance you can create a jsfiddle to visualise the issue? |
Recently, I've encountered the render order problem. I have multiple layers (just like the layers in AE / PS) in the scene, and if their depths (distances to camera) are the same, the later added layer should be render on top of the previous one, otherwise, just act as the default render order sort strategy in Three.js. Of course, I can use a manager to handle If I don't use set Another simpler way is to hack in render list's sort function to compare Based on the above cases, if the feature to customize render sort function is added, no hacks are needed and keep things simple. |
So the solution here is being able to do |
#16909 added support for custom sort functions. |
Hi,
In my current project I have to implement some complex 2D objects (multilayered GUI) and those will be anchored in 3D space.
I have noticed lots of artifacts on those planar 2D objects caused by z-index sorting of 2D layers in the same GUI object. There are few ways to solve it:
THREE.Object3D.renderOrder
to sort items - this is not the best option as I would need to keep track ofTHREE.Object3D.renderOrder
globally and update it on many objects if only one item gets inserted in the middle.None of the above are good enough nor easy to implement. IMO the cleanest solution to the problem (which I implemented and tested) was to modify the way WebGLRendererList sorts items by adding possibility to group render items into some kind of layers and then play with rather "local" than "global"
THREE.Object3D.renderOrder
property.The easiest implementation of this feature would look like this:
Being able to group items with layers is a nice and clean way to solve the limitation of ThreeJS (big one in my project at least) when working with GUI/2D objects embedded in 3D space.
Another way (even more extensible IMO) would be to add support for customizing sorting logics so app can do whatever crazy stuff they want (i.e. via data stored in
THREE.Object3D.userData
property).One would simply pass custom sorter into the
THREE.WebGLRendererLists
or even pass entirely new implementation to theTHREE.WebGLRenderer.renderLists
property.I could make a PR with either of the proposed changes if anyone thinks it is a good idea. Otherwise I will stick with my little hack where I override the prototype of the WebGLRendererLists - ugly but works for me now. :)
Thanks,
Lukasz
The text was updated successfully, but these errors were encountered: