Skip to content

Commit

Permalink
Hide change for billboard hierarchy with a static flag
Browse files Browse the repository at this point in the history
  • Loading branch information
CedricGuillemet committed Oct 10, 2022
1 parent e354fe0 commit 4a8c5ee
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
@@ -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();
@@ -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 {

0 comments on commit 4a8c5ee

Please sign in to comment.