-
Notifications
You must be signed in to change notification settings - Fork 149
CSG optimizations for animation #39
Copy link
Copy link
Open
Description
Hello,
I want to create an animation where an object is subtracted with a box but csg is a bit slow to do what i want.
The object is not moving but the box does. i wanted to add the possibility to move box csg without recreate it each time but it doesn t work. Could you look at this code please ?
`ThreeBSP.prototype.transform = function(transformation_matrix) {
var i, j,
polygons = this.tree.polygons/.allPolygons()/,
polygon_count = polygons.length,
polygon, polygon_vertice_count;
var transformation_matrix_elements = transformation_matrix.elements;
for ( i = 0; i < polygon_count; i++ ) {
polygon = polygons[i];
polygon_vertice_count = polygon.vertices.length;
for ( j = 0; j < polygon_vertice_count; j++ ) {
polygon.vertices[j].applyMatrix4_2(transformation_matrix_elements);
polygon.calculateProperties();
}
}
console.log(polygons[0].vertices[0].x + " " + polygons[0].vertices[0].y + " " + polygons[0].vertices[0].z);
this.matrix = this.matrix.multiply(transformation_matrix);
this.tree = new ThreeBSP.Node( polygons );
};
ThreeBSP.Vertex.prototype.applyMatrix4_2 = function ( e ) {
// input: THREE.Matrix4 affine matrix
var x = this.x, y = this.y, z = this.z;
this.x = e[0] * x + e[4] * y + e[8] * z + e[12];
this.y = e[1] * x + e[5] * y + e[9] * z + e[13];
this.z = e[2] * x + e[6] * y + e[10] * z + e[14];
return this;
}
`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels