Resize THREE.CubeGeometry at runtime

I am using Three.JS r58 and I would like to resize the CubeGeometry object on the screen.

One approach that I tried - when resizing, you need to delete the deleted cubes and add a new one with updated parameters. This process works, but it drastically slows down the rendering. I would like to know if there is a way to resize CubeGeometry dynamically using Three.js, instead of deleting / adding a new one. The sample in jsfiddle is evaluated.

+6
source share
1 answer

Call .scale.set(x, y, z) in the grid (see this ticket ).

Initially, the scale has the value (1, 1, 1) (see the constructor of Object3D , the parent class of the Mesh ), you will want to increase these values ​​by the required percentage scale in the required sizes.

In this fiddle I enlarge the cube in all directions by 50% using .scale.set(1.5, 1.5, 1.5) .

+3
source

Source: https://habr.com/ru/post/946180/


All Articles