Fix transformation matrix decomposing
This commit is contained in:
parent
a390a849a3
commit
72c13c8535
@ -64,9 +64,6 @@ class Node {
|
||||
// Set translation
|
||||
mat4.translate(matrix, matrix, this.pos)
|
||||
|
||||
// Set scale
|
||||
mat4.scale(matrix, matrix, this.scale)
|
||||
|
||||
// Set rotation
|
||||
if (this.rotation[0] !== 0) {
|
||||
mat4.rotateX(matrix, matrix, this.rotation[0])
|
||||
@ -80,9 +77,12 @@ class Node {
|
||||
mat4.rotateZ(matrix, matrix, this.rotation[2])
|
||||
}
|
||||
|
||||
// Set scale
|
||||
mat4.scale(matrix, matrix, this.scale)
|
||||
|
||||
// Add parent node's transform
|
||||
if (this.parent) {
|
||||
mat4.add(matrix, this.parent.transform, matrix)
|
||||
mat4.mul(matrix, this.parent.transform, matrix)
|
||||
}
|
||||
|
||||
// Set the matrix
|
||||
@ -102,6 +102,8 @@ class Node {
|
||||
let rotation = vec3.create()
|
||||
let scale = vec3.create()
|
||||
|
||||
mat4.transpose(transform, transform)
|
||||
|
||||
mat4.getTranslation(translation, transform)
|
||||
mat4.getScaling(scale, transform)
|
||||
mat4.getRotation(quaternion, transform)
|
||||
@ -325,7 +327,7 @@ class MeshInstance extends Node {
|
||||
// Invoke children's draw methods
|
||||
for (let i in this.children) {
|
||||
let child = this.children[i]
|
||||
if (!(child instanceof Mesh)) continue
|
||||
if (!(child instanceof MeshInstance)) continue
|
||||
child.draw(gl, shader)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user