From eab22a8e6b6250bf8cd8233d3e2aae7cc83cf855 Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Thu, 3 Jan 2019 21:14:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E5=90=AF=E7=94=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=89=8D=E4=BC=9A=E4=BA=A7=E7=94=9F=E9=87=8D=E5=8A=9B?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.Web/src/object/geometry/Box.js | 11 +++++++++++ .../src/player/component/PlayerPhysics.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) 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;