Graphics Reference
In-Depth Information
How it works
The transformations used in this recipe are based on matrix calculations. Matrix
calculations by themselves are a rather complex subject. If you're interested in
more information on how matrix calculations work and how they can be used
for all different kinds of transformations, a good explanation can be found at ht-
tp://www.matrix44.net/cms/notes/opengl-3d-graphics/basic-3d-math-matrices .
There's moreā€¦
In the example for this chapter, you can apply a couple of transformations to the ro-
tating cube. The following code snippet shows you the matrices used for these trans-
formations:
this.doScale = function() {
var scaleMatrix = new THREE.Matrix4(
control.x, 0, 0, 0,
0, control.y, 0, 0,
0, 0, control.z, 0,
0, 0, 0, 1
);
cube.geometry.applyMatrix(scaleMatrix);
cube.geometry.verticesNeedUpdate = true;
}
this.doShearing = function() {
var scaleMatrix = new THREE.Matrix4(
1, this.a, this.b, 0,
this.c, 1, this.d, 0,
this.e, this.f, 1, 0,
0, 0, 0, 1
);
cube.geometry.applyMatrix(scaleMatrix);
cube.geometry.verticesNeedUpdate = true;
}
this.doRotationY = function() {
var c = Math.cos(this.theta),
s = Math.sin(this.theta);
Search WWH ::




Custom Search