I am using Three.JS r58 and I would like to resize a CubeGeometry object on the screen.
One approach I tried is, when resizing required, to remove the effected cubes and add a new one with updated dimentions. This process works but it slows down the visualisation dramatically. I would like to know if there is a way to resize a CubeGeometry dynamically using Three.js rather than removing/adding a new one. A sample in jsfiddle is appreciated.
Call .scale.set(x, y, z)
on the mesh (see this ticket).
Initially the scale
is set to (1, 1, 1)
(see the constructor of Object3D, the parent class of Mesh
). You will want to increase those values by the percentage scale you require, in the dimensions you require.
In this fiddle I increase the cube in all directions by 50 percent using .scale.set(1.5, 1.5, 1.5)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With