I am currently working with three.js and have successfully combined a mesh (.obj), a material (.mtl), and several textures into a single JSON object.
The mesh and material were exported from Blender's wavefront obj export feature.
Below is a snippet of the JSON file:
{
"data": {
"type": "b64obj",
"material": "--Long base64-encoded Material data--",
"mesh": "--Long base64-encoded Mesh data--",
"textures": {
"texture.jpg": "base64-encoded image",
"anothertexture.jpg": "base64-encoded image",
}
}
}
Outlined below is the code snippet that loads this JSON object (excluding the base64-decoding part):
var mtlLoader = new THREE.MTLLoader();
var materials = mtlLoader.parse(data.material);
materials.preload();
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
var object = objLoader.parse(data.mesh);
renderObj(object); //begin using it within the application once loaded
The .mtl file references image files that are expected to be on the hard drive. How can I instruct the system to use the object containing the textures instead?