Rendering many objects

Hei Community,
I have two use cases:

A: a scene where I add ONE THREE.Points Object with a large number of Points in it.
B: a scene where I add a large Number of THREE.Points Objects with one Point in it

Material is PointsMaterial in both usecases.

It seams like the performance drops much fast when running usecase B.
My Problem is that I need do use this variant because I need to add metadata to each of the Points.

I googled a lot but did not find the right solution.
Are there any options to treath this much objects as if it was one.
I do not need any interaction or sideeffects between the points.

Hope anyone can help.

Regards Manuel

This is intriguing. Do you really say that in your case, when N is large:

  • 1 THREE.Ponits(containing N vertices) → this is slow
  • N THREE.Points(containing 1 vertex) → this is fast

I want to see it to believe it.

no i mean the exact oposit, sry I edited the question. Can you provide any help ?

I don’t know.

Anyway, in the past I have used two approaches for something similar. I think that both should be OK for you, but it depends on whether these metadata will be used by a shader or by JS:

  • Approach 1: have a JS array with the metadata, so that indices in this array correspond to point numbers. PROS: easy to implement, easy to handle, easy to change the metadata structure; CONS: you will have no access to the data from a shader, unless you manually pass the metadata
  • Approach 2: has a custom buffer attribute that holds the metadata; CONS: harder to maintain, if you have never done this before; might be very hard if metadata contains strings, etc; PROS: you can access the metadata from a custom shader (alternatively, you can pass the data via a texture)

I hope that approach 1 would be sufficient for you, as it is easier to implement.

3 Likes

took approach 2.Did not know that this is possible. Was easier then expected and is pretty close to standard. Thanks for your help :slight_smile:

2 Likes

well what I do know is use the ShaderMaterial instead of PointsMaterial. Everything works perfect but the colors are not the same anymore. It seams like they are more intense. Is there a Possibility to render the Points in the custom shader like if it was rendered in PointsMaterial. What color calculation does PointsMaterial use ?

If you need to review compiled chunks for pointMaterial, or to compare it with your own shaderMaterial solution you can use the resources shared here