【发布时间】:2017-12-22 22:30:31
【问题描述】:
我在 Clara.io 中有几个模型,根据他们的帮助,如果你导出选择,它将是 JSONLoader 的文件,如果你导出完整场景,它将是 ObjectLoader 的文件。但是导出函数不能与 JSONLoader (https://forum.clara.io/t/export-to-three-js-json-export-all-and-export-selected-both-export-scene-object/3709) 一起使用。
在我的应用程序中,我只需要模型中的几何图形来构建 Points 对象。所以我正在寻找将加载的对象转换为网格的方法,或者从对象本身进行几何减法之王。在帮助和示例(三个和 clara)中,我只看到一个加载对象的操作 - scene.add(object)。
import THREE from 'three/build/three.module';
import {Scene,PerspectiveCamera,Fog,WebGLRenderer,ObjectLoader,Geometry} from 'three/build/three.module';
....
var loader = new ObjectLoader();
loader.load( 'assets/models/rabbit.json', function ( object ) {
//I don't need to add object here but this is the only thing that works
//scene.add(object);
//I need to do something like this
geometry2 = new Geometry();
geometry2.vertices = object.geometry.vertices; // ???
particles = new Points( geometry2, new PointsMaterial( { color: 0xff0000, size:5 } ) );
scene.add(particles)
});
【问题讨论】:
-
好的,用非工作代码更新。不确定它是否会有所帮助。这 ???评论显示我需要源对象的几何形状。
标签: javascript json three.js