【问题标题】:Clara.io json, geometry in three jsClara.io json,三个js中的几何
【发布时间】: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


【解决方案1】:

所以 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)
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多