diff --git a/ShadowEditor.Web/src/object/geometry/Box.js b/ShadowEditor.Web/src/object/geometry/Box.js index 03195b92..0c6e08b7 100644 --- a/ShadowEditor.Web/src/object/geometry/Box.js +++ b/ShadowEditor.Web/src/object/geometry/Box.js @@ -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); diff --git a/ShadowEditor.Web/src/player/component/PlayerPhysics.js b/ShadowEditor.Web/src/player/component/PlayerPhysics.js index 39b0a01a..d663a5d3 100644 --- a/ShadowEditor.Web/src/player/component/PlayerPhysics.js +++ b/ShadowEditor.Web/src/player/component/PlayerPhysics.js @@ -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;