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

Mesh: Fix billboards in right-handed systems #13885

Merged
merged 1 commit into from May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/dev/core/src/Meshes/transformNode.ts
Expand Up @@ -9,6 +9,9 @@ import { Node } from "../node";
import type { Bone } from "../Bones/bone";
import type { AbstractMesh } from "../Meshes/abstractMesh";
import { Space } from "../Maths/math.axis";

const convertRHSToLHS = Matrix.Compose(Vector3.One(), Quaternion.FromEulerAngles(0, Math.PI, 0), Vector3.Zero());

/**
* A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/parent_pivot/transform_node
Expand Down Expand Up @@ -1165,6 +1168,11 @@ export class TransformNode extends Node {

// Cancel camera rotation
TmpVectors.Matrix[1].copyFrom(camera.getViewMatrix());

if (this._scene.useRightHandedSystem) {
TmpVectors.Matrix[1].multiplyToRef(convertRHSToLHS, TmpVectors.Matrix[1]);
}

TmpVectors.Matrix[1].setTranslationFromFloats(0, 0, 0);
TmpVectors.Matrix[1].invertToRef(TmpVectors.Matrix[0]);

Expand Down