claygl
claygl copied to clipboard
How to set dimensions of primitives?
Hi,
I have searched everywhere in the source code but I cannot find any place where to set dimensions of primitives? For example if I want to create a cube that's 1x2x1.
I tried using scale instead: cube.scale.set(1, 2, 1)
but that doesn't update the bounding box.
Any suggestions or is it a lacking feature?
Thanks Best regards
Sorry for the late reply. You can set the width/height/depth properties when creating cube geometry.
const cube = new clay.geometry.Cube({ width: 1, height: 2, depth: 1});
More commonly we will set scale like in your code. And bounding box can be applied with the scale transform.
cube.scale.set(1, 2, 1);
cube.updateTransform();
cube.geometry.boundingBox.clone().applyTransform(cube.localTransform);
Thanks a lot, will definitely try it out!