ngl
ngl copied to clipboard
setParameters on shape component
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?
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}})
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?
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.
Is there anyway to alter the opacity of a buffer?
keep a reference to the buffer
and then do buffer.setParameters({opacity: 0.5})
Is it possible to add a tooltip/hover text to buffers the way it is done with shapes?