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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Old stuff

November 2015
M T W T F S S
« Sep   Dec »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Oh, btw…


%d bloggers like this: