Compound of sprites without depth(?) sorting

Hi,

question is: Can I have a Sprite or Object3D as base, that allows me to add 1 or more sprites on/to it without those objects being sorted.

Thing is, I want to create sort of 2D´ish menu (object3D/sprite) and add 3 to 4 sprites on it that then act as one layer without being depth sorted (being affected by sorting)…

By now its more like, I have a base (sprite) and add another sprite on it. This sprite, depending on perspective/distance is then in front or behind the base-sprite. Can I somehow say, make a compound of 3d-objects/sprites that act as one unsorted layer?

I made a quick Codepen for this:

Here I add the white quad (sprite) on top of those particles base sprite. Sometimes its in front of the base sprite, sometimes behind… can I somehow create some where they are on the same depth, aka, not testing depth?

Defining a grouped ordering of render items is currently not possible with three.js. I’ve tried to integrate an functionality similar to Unity’s SortingGroup but without success.

I hope we can add such a feature in the future. In the meanwhile, you might want to use the code from the PR for your own custom solution.

Rendering has to follow an order. You could:

  1. Draw a white square
  2. Draw a purple circle

or

  1. Draw a purple circle
  2. Draw a white square

But you cannot do both simultaneously. However, what you could do is blend them, so that adding a color changes the appearance of the previous color. In the example below, I added

depthTest: false,
blending: THREE.AdditiveBlending,

to your materials, which could yield interesting results, and it removes the appearance of rendering order (even though technically, it still follows one).

You can see additional blending alternatives in this example.

Ok, I understand. So my current solution differs from both suggestion. I understand it is not possible with threejs by now, correct?

So I now use pixi.js to create and animate all 2d menu/navigation like structures on a one canvas, that I then use as texture in threejs… maybe an too odd approach, but works for me

Yes. I think SortingGroups would actually solve your issue.

@Mugen87 is there a proper example of how to use/implement it?

No. You would have to study the PR and/or how this feature is implemented in Unity. You can then start to build something new.

Your PR is where?

I’ve already linked it in this topic, see Compound of sprites without depth(?) sorting