Scaling does not work - Cannot understand why

Hello three.js community.

I have a problem that i tried working around it many ways but it cannot go away.
Scaling does not work properly and i cannot understand why.

I have already posted this question in SO, so i will link it here.
I am new to this forum and i don’t know if this allowed. If there is a problem with this, please let me know and i will take care of it.

Here is the link:

Answering the questions from SO:

2) When the y parameter has an initial value of 0.00001... Why it cannot be changed from the GUI at all?

It can. But scaling works as a multiplication. So anything less than 100000 (100000 x 0.00001 = 1.0) will give you barely any effect.

1) When the values are initialized at 20... Why does a new values that is less than 20 make the mesh appear bigger?

I’m not 100% sure if I understand, but the answer is probably the same - scale works as multiplication. So if scale = 1.0, you will receive the original size of the box.
If scale > 1.0, your box will always get bigger.
If scale is between 0.0 and 0.99999..., your box will get smaller than the original size (scale = 0.5 will for example make it half the size.)
Values of scale lower than zero will give you a mirrored effect.

Thanks. user marquizzo at stack overflow edited the code. Now it is a snippet and can run in the browser. If you can you can look at the results there (for the question #1)

My only suggestion is to not set initial box Y size to 0.00001. It makes scaling unpractical - since as I said, you would need to scale it with ridiculous values to get normal results.

A better approach may be:

var cubeGeometry = new THREE.BoxGeometry(20, 20, 20);
var cubeMaterial = new THREE.MeshLambertMaterial({color: 0xffff00 }); //0xF7F7F7 = gray
cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
cube.scale.y = 0.00002; // Initial box size will be 0.00001, but this way you do not "disable" scaling by setting a very small height value
cube.userData.originalColor = 0xffff00;

The reason i set such a low values, is because i want the cube to start as a flat surface in the beginning.

That’s ok, but then set original height to 1.0, and adjust further using scale (so BoxGeometry(20, 1, 20) and scale.y = 0.00001). You can change the scaling at any point, changing the original height is not that simple.

You mean to use this constructor:
BoxGeometry(20, 1, 20)
and immediately use this
scale.y = 0.00001
in order to have my falt sheet.

is thsi correct?

1 Like

Looks like mjurczyk and I are both trying to explain the same thing:

1 Like

I want to express my gratitude guys!
Thank you very much for all your help!