将Physijs.Vehicle添加到Physijs.Scene时出错 THREE.Object3D.add:对象不是THREE.Object3D的实例
尝试在Physijs页面上浏览车辆示例,但是相同的步骤无效。该示例中的相关代码为:
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 );
我的代码:
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 );
值得一提的是,我可以通过传入vehicle.mesh来克服此错误,但是很显然,该车辆上没有正确配置physijs。看来其他Physijs网格是THREE.Mesh的扩展,但不是Vehicle的扩展,这引起了问题。