How to set object.matrix in three.js?

While all the top google hits for this problem revolve around messing with matrixAutoUpdate property, I thought I’d share this simple trick:

object.matrix.copy (...); // or fromArray (...), etc
object.matrix.decompose (
    object.position,
    object.quaternion,
    object.scale
);

This only really works with the matrices that can be represented with three.js’ position/quaternion/scale model, but in practice this is vast majority of the cases. You’re welcome.

2 Responses to “How to set object.matrix in three.js?”


  1. 1 barradeau January 28, 2016 at 20:15

    isn’t it Recompose rather than Decompose ? anyway very handy :)


Ask a Question




Old stuff

November 2015
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30