Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide change for billboard hierarchy with a static flag #13089

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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