移动框与另一对colission尊重在three.js所相邻的下网(Move a Box with

2019-10-21 20:29发布

Found a lot of physic engines out there but nothing that fit my needs directly. I try to to find a simple way to push and pull boxes including collision detection which respects the next neighboring mesh hit while moving.

Some use cases to understand:

All boxes except box 1 are moveable.

Push or Pull box 4 to west:

  • Should move box 3 to west on collision.
  • Should make box 3 and 4 not able to move west when box 3 hits box 2.

Push 2, 3 or 4 to north:

  • Should stop when it hits box 2, because box 1 is not movable.

it should not possible to push or pull 2 colliding boxes with a box.

Maybe not the best question... I could write such a logic from scratch but this would end in fairly complex code :) and I wonder if nobody solved something like that before. Does there exist an easy way to implement such a logic using an existing physic engine or a three.js plugin?

Hope the question is formulated well enough so that anyone can understand it. Maybe easier If you know the famous boulder dash game.

Possible to move both rocks in both directions.

Impossible to move a rock.

In my case it should be possible to move 2 colliding rocks/cubes but not 3.

Answer 1:

很简单,它更多的是几何学和逻辑比物理...如果我理解你的简化的世界。

在boulderdash(或也推箱子),其中运动被平铺为主,当您要移动您首先检查相邻瓦片的字符,在运动方向的情况下。 这可能是适合步行或由可移动物体(或者也可以是壁)占用。 如果有一个可移动的对象,那么你检查下相邻的瓷砖。 如果它是适合步行的那么意味着运动物体它的确移动。 否则,活动对象是当前没有移动。

在非平铺场景像你看来,你检查与第一箱,当发生这种情况,你检查下一个碰撞盒的存在碰撞,增添了新的colision点的第一个框的大小,方向运动。



Answer 2:

所以基本上你想使某些物体在不同的点不动。 你可以做到这一点physi.js 。 只是增加了物体的质量,使其成为相对它是不可移动的其他对象如此沉重。



Answer 3:

我刚才已经回答这里类似的问题 。

您应该使用类型的边框THREE.Box3用于这一目的。

你一定要检查这个例子了 。 我认为这将是对你非常有用。



文章来源: Move a Box with another on colission respecting the next neighboring mesh in Three.js