ngl icon indicating copy to clipboard operation
ngl copied to clipboard

setParameters on shape component

Open giagitom opened this issue 7 years ago • 6 comments

Hi, I have two questions about shape components.

I have a shape component with a cylinder and a label. Is it possible to alter the color and the size of both objects in the shape component without disposing and rebuilding entirely (like using a setParameter method)?

And is it possible to keep the label in front of the cylinder like a distance representation?

giagitom avatar Aug 30 '17 09:08 giagitom

I have a shape component with a cylinder and a label. Is it possible to alter the color and the size of both objects in the shape component without disposing and rebuilding entirely (like using a setParameter method)?

No, not possible. If you have a large number of cylinders and labels it is good to create CylinderBuffer and TextBuffer objects instead of shape.addCylinder and shape.addLabel, plus you can change the color and size of the buffer objects without disposing and rebuilding. See this example https://codepen.io/arose/pen/qXgxap?editors=0010.

And is it possible to keep the label in front of the cylinder like a distance representation?

Yes, using the zOffset parameter http://nglviewer.org/ngldev/api/typedef/index.html#static-typedef-TextBufferParameters, for shape.addLabel set it when instantiating new Shape({labelParams: {zOffset: 5}})

arose avatar Sep 01 '17 17:09 arose

Great solution, only one thing. In my example hear I tried to alter the length of a cylinder created before and at the same time tried to add two other cylinders. I noticed that the dimension of the first cylinder was changed but the other cylinders did not appeared. Is it possible that the new buffers length is not updated?

giagitom avatar Sep 02 '17 09:09 giagitom

At the moment it is not possible to alter the size of buffers, you will need to re-create them. There is some exception for mesh-buffer (which makes changing the isosurface threshold so fast) but I haven't generalized that. Eventually it will be possible.

arose avatar Sep 13 '17 04:09 arose

Is there anyway to alter the opacity of a buffer?

lenhsherr avatar Sep 27 '17 13:09 lenhsherr

keep a reference to the buffer and then do buffer.setParameters({opacity: 0.5})

arose avatar Sep 30 '17 03:09 arose

Is it possible to add a tooltip/hover text to buffers the way it is done with shapes?

garboit avatar Feb 06 '22 05:02 garboit