问题
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