1

I created a ground, then I dug a gap in it, and finally added physical effects through physijs.

let Mesh = new THREE.Mesh(new THREE.BoxGeometry(800, 10, 800), material);
Mesh = new ThreeBSP(Mesh);

let Gap = new THREE.Mesh(new THREE.BoxGeometry(230, 10, 170), material);
Gap = new ThreeBSP(Gap);

Mesh = Mesh.subtract(Gap).toMesh(material);
Mesh = new Physijs.BoxMesh(Mesh.geometry, Mesh.material, 0);
scene.add(Mesh);

Then you create a collection with physical effects. The plan is to fall from the hole in the ground, and the result appears to be suspended in the hole. Why?

let geometry = new Physijs.BoxMesh(new THREE.CylinderGeometry(10, 15, 50, 25), material, 1);
geometry.position.set(0, 500, 0);
scene.add(geometry);

I'm building a house. I'm digging holes in the floor and walls to represent staircases and doors, and then I add physical effects to the floor and walls. In the plan, objects representing people can pass through these holes, but they are blocked. People are directly suspended above the holes in the stairway, and the door can't pass through, as if blocked by an invisible wall

ceshi
  • 31
  • 2

1 Answers1

1

Physijs.BoxMesh will just create a box with eight corners and flat planes in between. Have you looked into using Physijs.ConcaveMesh? I couldn't find any documentation, but you can see it in the source code.

Mesh = Mesh.subtract(Gap).toMesh(material);
Mesh = new Physijs.ConcaveMesh(Mesh.geometry, Mesh.material, 0);
scene.add(Mesh);
M -
  • 26,908
  • 11
  • 49
  • 81
  • As a side note, I recommend you use more variable names other than assigning everything to `Mesh`. It can get confusing when everything is `Mesh`. – M - Oct 01 '20 at 01:17
  • @ceshi did you try just plain `Physijs.Mesh`? – M - Oct 06 '20 at 06:45
  • When I used concavemesh to transform the externally introduced obj model, the browser reported an error – ceshi Oct 09 '20 at 10:14
  • TypeError: Cannot read property 'length' of undefined at new window.Physijs.Physijs.ConcaveMesh (physi.js:1259) – ceshi Oct 09 '20 at 10:14
  • But I converted it through concavemesh three.js The mesh generated by threebsp method is successful, but the physical effect is not correct. For example, I dig a hole at point a in the plane, and the free falling ball does not pass through the hole, but floats in the hole. Instead, it passes through point B (there is no hole in point B) – ceshi Oct 09 '20 at 10:22