Blender 2.7X Exporter to .json For three.js JSONLoader

匆匆过客 提交于 2019-12-24 03:16:11

问题


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

Three.js version r71

Blender version 2.74

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

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

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

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


回答1:


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.

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

var jsonLoader = new THREE.JSONLoader();

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);

});

Working example with multiple JSON exports and the running javascript for it.



来源:https://stackoverflow.com/questions/30476723/blender-2-7x-exporter-to-json-for-three-js-jsonloader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!