1

I have two object in threejs. And I would like them to share the value of scale vector

  mesh1 = new THREE.Mesh(geometry, material); 
  mesh1.scale.x = 0.47;

  mesh2 = new THREE.Mesh(geometry, material); 
  mesh2.scale=mesh1.scale;  // This does not work

The last line has no effect. The documentation does not state that the scale property is readonly. I've taken a look at the source and found that that property is not defined as writable. Is there a bug in documentation or is this the way threejs works and there is no point in documenting it :-) ?

Is it possible to share scale (and other vector) between different meshes? Is the only way to do it by copying the values

  mesh2.scale.copy(mesh1.scale);  // Copy the vector over

UPDATE: This seemed to work in old versions of threejs - such as the one used in the following example. Was this functionality disabled on purpose?

3
  • scale is vector so you need the copy constructor. Commented Oct 5, 2015 at 21:00
  • Object3D.scale is immutable. See stackoverflow.com/questions/26905929/… Commented Oct 5, 2015 at 21:55
  • @WestLangley Great answer- Now if you can add it as an answer (nto as comment) I can accept it :-) Commented Oct 5, 2015 at 22:11

1 Answer 1

3

Object3D's position, rotation, quaternion and scale properties are immutable.

See the source code file Object3D.js.

For example, you can no longer use the following pattern:

object.scale = vector;

Instead, you must use either

object.scale.set( x, y, z );

or

object.scale.copy( vector );

Similarly for the other properties mentioned.

three.js r.72

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.