Blender 2.7X Exporter到.json for three.js JSONLoader [英] Blender 2.7X Exporter to .json For three.js JSONLoader

查看:267
本文介绍了Blender 2.7X Exporter到.json for three.js JSONLoader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JSON路由(用于动画)从Blender导出到Three.js

I am trying to export from Blender into Three.js using the JSON route (for animations)

Three.js版本r71

Three.js version r71

Blender版本2.74

Blender version 2.74

当前的Blender导出器成功导出 .json 文件 NOT 一个.js文件。

The current Blender exporter successfully exports a .json file NOT a .js file.

r71文件夹中的所有示例仅导入.js文件。

All examples within the r71 folders import .js files only.

有没有人有任何关于如何导入从Blender 2.7x导出的.json文件的工作示例?

Does anyone have any working examples on how to import a .json file that has been exported from Blender 2.7x?

如果没有,我将不得不回到Blender 2.69并使用通常记录的.js导入。

If not, I'll have to go back to Blender 2.69 and use the commonly documented .js import.

推荐答案

我可能是错的,但是.json文件只是.js但扩展名不同。
如果你打开一个.json文件,你可以看到它纯粹是一个在变量中声明的JSON对象,就像你在简单的javascript中一样。

I might be wrong but .json files are just .js but with a different extension. If you open a .json file you can see it is purely a JSON object declared inside a variable, like you would do in plain javascript.

你可以仍然通过JSONLoader对象加载JSON文件,只需在变量中声明一个新对象:

You can still load the JSON files through the JSONLoader object, just declare a new object inside a variable:

var jsonLoader = new THREE.JSONLoader();

然后使用方法 .load 可以将导出的文件作为第一个参数加载回调函数,以将导出的网格和导出的材料应用到场景中。

And then with the method .load you can load your exported file as first argument and a callback function to apply the exported mesh and the exported material into the scene.

jsonLoader.load('path_to/exported_model.json', function (geometry, materials) {

  yourModel = new THREE.Mesh(
    geometry,
    new THREE.MeshFaceMaterial( materials )
  );

  scene.add(yourModel);

});

具有多个JSON导出的工作示例运行javascript

这篇关于Blender 2.7X Exporter到.json for three.js JSONLoader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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