After exporting a model from Blender to Three.js, the resulting file contains JSON data. There are two methods I know of for loading this model:
var loader = new THREE.JSONLoader()
var material = new THREE.MeshPhongMaterial({color: '#8080a0'})
1.
loader.load('tower.json', function (geometry) {
var mesh = new THREE.Mesh(geometry, material)
})
2. Make changes to the tower.js file by adding
var tower =
on the first line. Then load it using:
var towerModel = loader.parse(tower)
var mesh = new THREE.Mesh(towerModel.geometry, material)
I personally prefer the second solution as repeatedly using loader.load() when creating multiple meshes based on the same model can significantly slow down performance and potentially crash your browser.
Therefore, my question is - is there a way to extract JSON data from the tower.json file directly into a variable without manual alterations? The ideal scenario would be to retrieve the JSON data without having to modify the file itself.