Thank you. But we apply a transformation to a mesh, not to an object. Maybe this is possible to apply a transformation to an object, I don’t know, but in this case this is not what we want: each object is composed of 20 meshes, and each mesh has its own transformation. So you mean I should store the meshes in a two-dimensional array? I’m not sure to understand.
I’ve never tried OrbitControls
, I will give it a look.
Hmm I’m realizing that I need 20 transformation matrices but I create them 180 times, not good…
So I’ve tried to improve that and I don’t understand something. This is a general Javascript question.
When I do:
for (var i = 0; i < 20; i++) {
var axis2 = new THREE.Vector3().fromArray(points[i]);
var mesh = new THREE.Mesh(bufGeom, material);
var transfoMatrix = reorient(axis1,axis2).multiply(new THREE.Matrix4()
.makeRotationAxis(new THREE.Vector3(0, 0, 1), k * 2 * pi / 180));
mesh.matrix = transfoMatrix;
......
then that works, but when I do:
var transfoMatrices = new Array(20);
for (var i = 0; i < 20; i++) {
var axis2 = new THREE.Vector3().fromArray(points[i]);
transfoMatrices[i] = reorient(axis1, axis2);
}
for (var k = 0; k < 180; k++) {
objects[k] = new THREE.Object3D();
for (var i = 0; i < 20; i++) {
var mesh = new THREE.Mesh(bufGeom, material);
var transfoMatrix = transfoMatrices[i].multiply(new THREE.Matrix4()
.makeRotationAxis(new THREE.Vector3(0, 0, 1), k * 2 * pi / 180));
mesh.matrix = transfoMatrix;
......
that does not work. The multiplication by the makeRotationAxis
is not performed! What is this joke please? (I’m not fluent in Javascript).
But this works:
var transfoMatrix = new THREE.Matrix4()
.makeRotationAxis(new THREE.Vector3(0, 0, 1), k * 2 * pi / 180)
.premultiply(transfoMatrices[i]);
As if Javascript ignored everything after transfoMatrices[i]
.