Setting line width using the viewer APi


I am struggling to set line width on objects of type Objects.Geometry.Line. I am setting the following material using renderer.setMaterial():

    color: 0x1095fb,
    vertexColors: false,
    lineWeight: 4,
    stencilOutlines: true,
    pointSize: 4,

The color parameter works just fine but neither lineWeight nor pointSize seem to have an effect.
Could you please help me?

Many thanks!

Hi @mivalek

There is a known limitations regarding lineWeight and lines. Currently it’s not possible to change the lineWeight of an existing line object. You can only choose the lineWeight of lines at creation/load time. We’re planning on removing this limitation in the near future

Regarding pointSize, that should work correctly. I’ve made a sandbox where the pointSize of some points are changed at runtime programatically. If you’re experiencing issues with this, in other use cases, please let me know



Hi @alex

Thanks a lot for your reply. Do you have a probable (non-binding, of course!) time frame for when the limitation might get lifted? I’m working on a feature that requires dynamic lineWeight setting so this is a bit of a spanner in the works.

On a related note, I would also like to be able to box-select these lines. I am using a modified version of your implementation for other (mesh) objects and it’s not picking up lines.
I figured that the reason is .batcher.getBatches(undefined, GeometryType.MESH) as MeshBatch[]; (line 125 of your sandbox) but changing it to ...Type.LINE) as LineBatch[] doesn’t work as the objects don’t have the .mesh.TAS property used further down (line 139). I have no knowledge of three.js and so this is end of the line for me. If it’s not too much work, would you be able to help me on this?

Thank you for all the support!

Hi @mivalek

Unfortunately there is no planned timeline for making lineWeight dynamic, but I’ll try and figure out a workaround for you until then.

Regarding box-selecting lines, it’s already possible. The only reason the implementation was only working with meshes is because only mesh intersections are currently being accelerated (via a two level BVH). So this means that testing for intersections against meshes scales very well with the total number of meshes in the scene, while testing against lines or points does not, since those are not accelerated at all. Even so, here is the forked box selection sandbox that works for both meshes and lines. Bare in mind though, that if your stream contains a ton of lines performance drops will become visible.


1 Like

That’s great Alex, thanks a lot for the explanation. I’ll give it a go and see. Fingers crossed the performance penalty is bearable.


1 Like