Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
sebavan committed Aug 3, 2022
1 parent 7efc2e6 commit 2c886c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/dev/core/src/Maths/math.vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ export class Vector3 {
* @param origin defines the origin of the projection ray
* @returns the projected vector3
*/
public projectOnPlane(plane: Plane, origin: Vector3): Vector3 {
public projectOnPlane(plane: Plane, origin: Vector3): Vector3 {
const result = Vector3.Zero();

this.projectOnPlaneToRef(plane, origin, result);
Expand Down
24 changes: 9 additions & 15 deletions packages/dev/core/test/unit/Math/babylon.math.vector.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plane, Vector3 } from 'core/Maths'
import { Plane, Vector3 } from "core/Maths";

/**
* Describes the test suite.
Expand All @@ -7,34 +7,28 @@ describe("Babylon Vectors", () => {
describe("#Vector3", () => {
it("can project from an origin onto a plane", () => {
// A ground plane at origin
const simplePlane = Plane.FromPositionAndNormal(
Vector3.Zero(),
Vector3.Up(),
);
const simplePlane = Plane.FromPositionAndNormal(Vector3.Zero(), Vector3.Up());

const rayOrigin = new Vector3(0, 10, 0);
const rayGoingThrough = new Vector3(1, 8, 0);

// Going left 1 unit for each 2 units downs
const expected = new Vector3(5, 0, 0);

expect(rayGoingThrough.projectOnPlane(simplePlane, rayOrigin)).toEqual(expected)
})
expect(rayGoingThrough.projectOnPlane(simplePlane, rayOrigin)).toEqual(expected);
});

it("can project from an origin onto an offset plane", () => {
// A ground plane 10 units below origin
const simplePlane = Plane.FromPositionAndNormal(
new Vector3(0, -10, 0),
Vector3.Up(),
);
const simplePlane = Plane.FromPositionAndNormal(new Vector3(0, -10, 0), Vector3.Up());

const rayOrigin = new Vector3(0, 10, 0);
const rayGoingThrough = new Vector3(1, 8, 0);

// Going left 1 unit for each 2 units downs
const expected = new Vector3(10, -10, 0);

expect(rayGoingThrough.projectOnPlane(simplePlane, rayOrigin)).toEqual(expected)
})
})
})
expect(rayGoingThrough.projectOnPlane(simplePlane, rayOrigin)).toEqual(expected);
});
});
});

0 comments on commit 2c886c0

Please sign in to comment.