mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
只有启用状态才会产生重力。
This commit is contained in:
parent
0aa2b6dd00
commit
eab22a8e6b
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user