claygl icon indicating copy to clipboard operation
claygl copied to clipboard

How to set dimensions of primitives?

Open partynikko opened this issue 6 years ago • 2 comments

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

partynikko avatar Oct 02 '18 14:10 partynikko

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);

pissang avatar Oct 19 '18 05:10 pissang

Thanks a lot, will definitely try it out!

partynikko avatar Oct 29 '18 22:10 partynikko