Skip to content

Commit

Permalink
Merge pull request #13089 from CedricGuillemet/billboardFlagOrientation
Browse files Browse the repository at this point in the history
Hide change for billboard hierarchy with a static flag
  • Loading branch information
sebavan authored Oct 10, 2022
2 parents e40f7ae + 4a8c5ee commit e3515ef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/dev/core/src/Meshes/transformNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class TransformNode extends Node {
* Object will rotate to face the camera's position instead of orientation
*/
public static BILLBOARDMODE_USE_POSITION = 128;
/**
* Child transform with Billboard flags should or should not apply parent rotation (default if off)
*/
public static BillboardUseParentOrientation: boolean = false;

private static _TmpRotation = Quaternion.Zero();
private static _TmpScaling = Vector3.Zero();
Expand Down Expand Up @@ -1110,9 +1114,11 @@ export class TransformNode extends Node {
Matrix.ScalingToRef(scale.x, scale.y, scale.z, TmpVectors.Matrix[7]);
TmpVectors.Matrix[7].setTranslation(translation);

// set localMatrix translation to be transformed against parent's orientation.
this._position.applyRotationQuaternionToRef(orientation, translation);
this._localMatrix.setTranslation(translation);
if (TransformNode.BillboardUseParentOrientation) {
// set localMatrix translation to be transformed against parent's orientation.
this._position.applyRotationQuaternionToRef(orientation, translation);
this._localMatrix.setTranslation(translation);
}

this._localMatrix.multiplyToRef(TmpVectors.Matrix[7], this._worldMatrix);
} else {
Expand Down

0 comments on commit e3515ef

Please sign in to comment.