question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Two mesh with Muti-Materials set same renderOrder value, the z-order is not correct?

See original GitHub issue
Description of the problem

I create two mesh with same renderOrder.

var circleGeometry = new THREE.CircleBufferGeometry(radius, segements);                                                                                                                                                                 
var ringGeometry = new THREE.RingBufferGeometry(radius, radius + ringWidth, segements);                                                                                                                                                                 
var cellGeometry = null;
  
//...

var circleMaterial = new THREE.MeshBasicMaterial({                                                                                                                                                                                                                                                                        
  map: texture,                                                                                                                                                                                                                                                                                                         
  // wireframe: true                                                                                                                                                                                                                                                                                                    
});                                                                                                                                                                                                                                                                                                                       
var ringMaterial = new THREE.MeshBasicMaterial({                                                                                                                                                                                                                                                                          
  color: 0x000000,                                                                                                                                                                                                                                                                                                      
  vertexColors: THREE.VertexColors,                                                                                                                                                                                                                                                                                     
  // wireframe: true                                                                                                                                                                                                                                                                                                    
});
                                                                                                                                                                                                                                                                                               
cellGeometry = THREE.BufferGeometryUtils.mergeBufferGeometries([circleGeometry, ringGeometry], true);                                                                                                                                                                                                                     
var mesh1 = new THREE.Mesh(cellGeometry, [circleMaterial, ringMaterial]);                                                                                                                                                                                                                                                 
scene.add(mesh1);                                                                                                                                                                                                                                                                                                         
mesh1.renderOrder = radius;                                                                                                                                                                                                                                                                                               
var mesh2 = new THREE.Mesh(cellGeometry, [circleMaterial, ringMaterial]);                                                                                                                                                                                                                                                 
mesh2.position.x += 2;                                                                                                                                                                                                                                                                                                    
mesh2.renderOrder = radius;    
                                                                                                                                                                                                                                                                             
scene.add(mesh2);  

The result was not correct, see screenshot! 1530709073076

Three.js version
  • r94
Browser
  • Chrome
OS
  • macOS
Hardware Requirements (graphics card, VR Device, …)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:27 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
0b5vrcommented, Dec 25, 2018

Hi! I definitely need material specific renderOrder feature, instead of mesh.renderOrder.

I’m currently working on Unity familiar stuff ( https://hub.vroid.com ), and it has material.renderQueue to deal with multiple material meshes. Since Three.js has no ability to sort its render order per material, We made our own WebGLRenderList to achieve correct rendering order:

https://gist.github.com/FMS-Cat/8e86dad4293516c5f2eeed1eedd88843#file-webglvrmrenderlists-ts-L39-L53

Our current way is too hacky and very vulnerable to future Three.js updates so I want a feature that can tweak its render order by material property.

1reaction
RemusMarcommented, Jul 7, 2018

Michael,

The bad practice is still there. This “SortingGroup” workaround comes with wasted processing power (performances hit). Feel free to take it as ‘feature request’ if you like.

Read more comments on GitHub >

github_iconTop Results From Across the Web

three.js - How to use Object3d.renderOrder to control the z-index
Setting renderOrder in three.js does not cause a renderable object to be "on top". It just controls the rendering order. It can be...
Read more >
Object3D#renderOrder – three.js docs
When this property is set for an instance of Group, all descendants objects will be sorted and rendered together. Sorting is from lowest...
Read more >
Z order issue when using custom meshes - Babylon.js Forum
I am using 2 custom meshes with 2 triangles each under certain angles the ordering is fine. image. But when I rotate the...
Read more >
Cannot find correct rendering order value, it just breaks.
To fix that I set its Rendering Order to +2. Now exterior parts fade out completely and reveal parts underneath.
Read more >
About same Z-Order on ordering - GoJS - Northwoods Software
I found all nodes have the same zOrder and increase or decrease the zOrder same time the nodes do not stack correctly. stack...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found