Scale loaded collada object

Hi I’m new on Three JS!
I’m trying to load dae (collada) file. Collada files have xml tag for units if you check: page 51. So when I load object I scale it like that:

const daeLoader =
  async (file: File): typeof Object3D => {
    const loader = new ColladaLoader();
    // $FlowFixMe 
    const strBuffer: string = await file.text();

    const collada = loader.parse(strBuffer);

    const threeObject: typeof Object3D = collada.scene;

    const scale: typeof Vector3 = scaleColladaObject(threeObject.scale.x);
    threeObject.scale.set(scale.x, scale.y, scale.z);

    return threeObject;

Scale gets updated but I’must scale position one by one?
NOTE: I need positions array to compute the area and volume of object 3D.

Well, you normally compute the world matrix for a 3D object and then use it to transform the vertices (which are defined in local space) into world space. This is something you have to do vertex by vertex.

Or you clone the position attribute and use BufferAttribute.applyMatrix4().

First of all thank you for the fast response. I solve the problem based on your response, but using the method scale, like that
threeObject.traverse(child => { const { geometry } = child; if (geometry) geometry.scale(scale.x, scale.y, scale.z); });
But I don’t understand something, in the first request I was scaling object3D, If I scale both object3D and geometry it does like a ‘double scaling’, but when I scale geometry works well. So when scaling object, we must only scale the geometry?

Relating post:

If you transform an object by changing Object3D.position, Object3D.scale or Object3D.rotation, the transformation is baked into a matrix which is later used in the vertex shader to compute the final position of all vertices.

Transforming a geometry directly means you change the vertex data already in your JavaScript code. This should only be done if it’s a one time transformation. For example if you plan to move your object in 3D space while animating, modifying the geometry each animation step is way too expensive.

1 Like

Nice, got it! :ok_hand:t2:
Understood both scenarios, in my case transforming a geometry directly is a valid solution because I scale the object only when loaded.

Thank you!