three.js导出器“导出对象"不适用于jsonLoader(r58) [英] three.js exporter 'export object' not working with jsonLoader (r58)

查看:379
本文介绍了three.js导出器“导出对象"不适用于jsonLoader(r58)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加载一个模型从3DWarehouse到three.js.我无法使Collada Loader正常工作,因此我将其导入THREEJS Editor,并使用导出对象"功能将其导出.当我使用以下代码将对象加载到我的应用中时:

I'm trying to load a model I got from 3DWarehouse into three.js. I was unable to get the Collada Loader to work, so instead I imported it into THREEJS Editor and exported it using the "export object" function. When I loaded the object into my app using the following code:

var kiss = new THREE.Object3D(), loader = new THREE.JSONLoader(true);
loader.load("model/kiss/kiss.js", function (geometry, meshKiss) {
    meshKiss = new THREE.Mesh(geometry, new THREE.MeshPhongMaterial());
    kiss.addChild(meshKiss);
});
scene.add(kiss);

我得到了错误:

Uncaught TypeError: Cannot read property 'length' of undefined

引用THREE.JSONLoader.prototype.parse中的行,其中它要求第一个参数的uvs长度.

which refers to the line in THREE.JSONLoader.prototype.parse where it asks for the first paramater's uvs length.

目标文件'geometries'没有uvs(它确实具有顶点,法线和面):

The object file 'geometries' has no uvs (it does have vertices, normals, and faces):

geometries: data: uvs: [[]]

将旧的JSON格式文件导入THREEJS Exporter(我测试了Ginger模型)时,我也发现了这个问题.

I am also finding this issue when importing older JSON format files into the THREEJS Exporter (I tested the Ginger models).

我的进程有效吗?如果是,为什么json对象不能导入THREE.JS?

Is my process valid, and if so, why is the json object not importing into THREE.JS?

推荐答案

这似乎正在开发中.解决方法是,您只能从编辑器中导出几何图形,因此JSON如下所示:

This appears to be under development. As a work-around, you can export the geometry only from the Editor so your JSON looks like this:

{
"metadata": {
    "version": 4,
    "type": "geometry",
    "generator": "GeometryExporter"
},
"vertices": [ ... ]
"normals": [ ... ]
"uvs": [[]],
"faces": [ ... ]
}

然后执行以下操作:

loader.load( "Kiss2.js", function ( geometry, materials ) {
    var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( { color: 0xff0000, ambient: 0xff0000 } ) );
    scene.add( mesh );
});

three.js.r.58

three.js.r.58

这篇关于three.js导出器“导出对象"不适用于jsonLoader(r58)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆