I have data that i’m exporting from a CAD system and then importing into a THREE.js scene in the following way:
-
Files (a.k.a parts) are getting translated to STLs
-
Positioning of parts is exported as a 12 value array, where the last three values are the X,Y,Z location, and the first nine values are the rotation transformation values
-
Importing the STLs using THREE.STLLoader
-
Those imports come in as THREE.mesh objects
-
The positioning information is read in via a JSON object
For a 12 value array “pos”, this line of code works (the mesh geometry is visible after positioning):
mesh.position.set(pos[9], pos[10], pos[11]);
As you can see in that line of code above, I’m only applying the translation values (X,Y,Z location).
If I try and apply all 12 values from the pos array in one fell swoop, I end up not seeing any geometry:
var mat = new Matrix4();
mat.set(
pos[0], pos[3], pos[6], pos[9],
pos[1], pos[4], pos[7], pos[10],
pos[2], pos[5], pos[8], pos[11],
0, 0, 0, 1
);mesh.applyMatrix(mat);
Let me know if you see what I’m doing wrong.