我在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)。
在我的应用程序中,我只需要从模型中构建几何点对象。所以我正在寻找将加载的对象转换为Mesh的方法,或者从对象本身中减去几何减法的几何方法。在帮助和示例(三个和克拉拉)中,我只看到一个带有加载对象的动作 - 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)
});
答案 0 :(得分:0)
所以clara.io似乎在场景中导出单个对象。因此,从中提取网格的方法如下:
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.children[0].geometry.vertices;
//object.children[0] - the first mesh in exported object
particles = new Points( geometry2, new PointsMaterial( { color: 0xff0000, size:5 } ) );
scene.add(particles)
});