0

Error adding a Physijs.Vehicle to a Physijs.Scene THREE.Object3D.add: object not an instance of THREE.Object3D

Have tried going through the vehicle example on the Physijs page, but the same steps do not work. Relevant code from the example is:

var loader = new THREE.JSONLoader();
loader.load( "models/mustang.js", function( car, car_materials ) {
    loader.load( "models/mustang_wheel.js", function( wheel, wheel_materials ) {
            var mesh = new Physijs.BoxMesh(
                car,
                new THREE.MeshFaceMaterial( car_materials )
            );
            mesh.position.y = 2;
            mesh.castShadow = mesh.receiveShadow = true;

            vehicle = new Physijs.Vehicle(mesh, new Physijs.VehicleTuning(
                10.88,
                1.83,
                0.28,
                500,
                10.5,
                6000
            ));
            scene.add( vehicle );

my code:

var physiBox = new Physijs.BoxMesh(
         box.geometry,
         box.material
    );
physiBox.name = "PhysiBox";
var vehicle = new Physijs.Vehicle(physiBox, new Physijs.VehicleTuning(
                10.88,
                1.83,
                0.28,
                500,
                10.5,
                6000
            ));
scene.add(vehicle );

Its worth mentioning I can get past this error by passing in the vehicle.mesh, but then the vehicle clearly does not have the physijs properly configured on it. It seems that the other Physijs Meshes are extension of THREE.Mesh but not Vehicle, which is causing problems.

4

1 回答 1

0

Seems this is a known issue w/ Physijs: https://github.com/chandlerprall/Physijs/issues/282

于 2019-05-27T22:49:40.933 回答