Skip to content

Commit

Permalink
Merge pull request #613 from gkjohnson/visualizer-matrix-update
Browse files Browse the repository at this point in the history
Fix matrix update, copy
  • Loading branch information
gkjohnson authored Jan 11, 2024
2 parents 5b0907c + f4c9f1f commit ae9b1d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- `MeshBVHVisualizer` has been deprecated and renamed `MeshBVHHelper` to align with three.js' conventions.

### Fixed
- `MeshBVHHelper` will now display correctly regardless of parent in hierarchy.
- `MeshBVHHelper.copy` now correctly copies opacity, color

## [0.6.8] - 2023-10-08
### Changed
- Small performance improvements to bvhcast function (up to ~10%).
Expand Down
29 changes: 26 additions & 3 deletions src/objects/MeshBVHHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,30 @@ class MeshBVHHelper extends Group {

updateMatrixWorld( ...args ) {

this.position.copy( this.mesh.position );
this.rotation.copy( this.mesh.rotation );
this.scale.copy( this.mesh.scale );
const mesh = this.mesh;
const parent = this.parent;

mesh.updateWorldMatrix( true, false );

if ( parent ) {

this.matrix
.copy( parent.matrixWorld )
.invert()
.multiply( mesh.matrixWorld );

} else {

this.matrix
.copy( mesh.matrixWorld );

}

this.matrix.decompose(
this.position,
this.quaternion,
this.scale,
);

super.updateMatrixWorld( ...args );

Expand All @@ -301,6 +322,8 @@ class MeshBVHHelper extends Group {

this.depth = source.depth;
this.mesh = source.mesh;
this.opacity = source.opacity;
this.color.copy( source.color );

}

Expand Down

0 comments on commit ae9b1d3

Please sign in to comment.