只有启用状态才会产生重力。

This commit is contained in:
liteng 2019-01-03 21:14:09 +08:00
parent 0aa2b6dd00
commit eab22a8e6b
2 changed files with 12 additions and 1 deletions

View File

@ -9,6 +9,17 @@ function Box(geometry = new THREE.BoxBufferGeometry(1, 1, 1), material = new THR
this.name = '正方体';
this.castShadow = true;
this.receiveShadow = true;
this.userData.physics = this.userData.physics || {
enabled: false,
shape: 'btBoxShape',
mass: 1,
inertia: {
x: 0,
y: 0,
z: 0,
}
};
}
Box.prototype = Object.create(THREE.Mesh.prototype);

View File

@ -42,7 +42,7 @@ PlayerPhysics.prototype.create = function (scene, camera, renderer) {
this.scene = scene;
this.scene.traverse(n => {
if (n.userData && n.userData.physics) {
if (n.userData && n.userData.physics && n.userData.physics.enabled) {
var body = PlysicsUtils.createRigidBody(n, this.margin);
if (body) {
n.userData.physics.body = body;