在三个 JS 中将物理添加到 OBJECT 模型

Adding Physics to OBJ Model in ThreeJS

我正在尝试将 PhysiJS 与 ThreeJS 结合使用。我有一个从 Blender 导出的 OBJ 模型。当我用 OBJLoader 加载它时,我看到它是一个 BufferGeometry。我还注意到它缺少 vertices 属性,这是 PhysiJS 寻找的。

我的 ThreeJS 版本是 r101。我将不胜感激任何建议。如果有更合适的图书馆,我也愿意接受。我也很乐意提供任何说明。

如果您需要将 BufferGeometry 转换为 Geometry,您只需使用 .fromBufferGeometry() method.

// Called when your obj finishes loading
onLoadComplete(obj) {
    var geom = new THREE.Geometry();
    geom.fromBufferGeometry(obj);

    // Now you'll have access to vertices
    console.log(geom.vertices);
}