Skip to content

body.addShape VS body({ shape: ... }) #495

Description

@eric-t-a

I have a RaycastVehicle positioned at the origin. Then I tried to create a floor.
If I do it like this it works fine:

const groundBody = new CANNON.Body();
groundBody.addShape(new CANNON.Plane());

groundBody.quaternion.setFromAxisAngle(
    new CANNON.Vec3(-1, 0, 0),
    Math.PI * 0.5
);

but if I do it like the below, seems like the floor does not get rotated and my car get's stuck at the origin cause there seem to be a wall that did not get rotated to be the floor.

const groundBody = new CANNON.Body({
   shape: new CANNON.Plane()
});

groundBody.quaternion.setFromAxisAngle(
    new CANNON.Vec3(-1, 0, 0),
    Math.PI * 0.5
);

Am I doing something wrong? Docs aren't very descriptive so I don't know why there's two ways to do the same thing (if they do indeed the same thing)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions