Skip to content

Commit

Permalink
optionally apply angle/axis rotations
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieroberts committed Jun 5, 2024
1 parent 4930e4f commit 0c0f7a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions js/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const MatrixWrap = function ( shouldInvert = false ) {
m.translation = {}
m.scale = {}
m.shouldInvert = shouldInvert
m.shouldRotate = true
m.rotation = {
axis: {}
}
Expand Down Expand Up @@ -184,10 +185,14 @@ MatrixWrap.prototype = {
this.__data = this.__data.multiply( Matrix.translate( this.translation.x, this.translation.y, this.translation.z ) )

// handle cumulative rotations via .rotateBy() method
this.__rotations.forEach( r => this.__data = this.__data.multiply( r ) )
this.__rotations.forEach( r => {
this.__data = this.__data.multiply( r )
})

// handle absolute rotations via .rotate() method... should this be aliased to rotateTo() ?
this.__data = this.__data.multiply( Matrix.rotate( this.rotation.angle, this.rotation.axis.x, this.rotation.axis.y, this.rotation.axis.z ) )
if( this.shouldRotate ) {
this.__data = this.__data.multiply( Matrix.rotate( this.rotation.angle, this.rotation.axis.x, this.rotation.axis.y, this.rotation.axis.z ) )
}

this.__data = this.__data.multiply( Matrix.scale( this.scale, this.scale, this.scale ) )
},
Expand Down

0 comments on commit 0c0f7a9

Please sign in to comment.