After exporting some JSON data from Blender using three.js' addon, I am trying to extract colors from the materials associated with the geometry and convert them to "point" material types.
Even though my console logs display that my .forEach function is working correctly on the model.material array, nothing appears to be displayed. It's as if no material has been applied at all.
Interestingly, a single color material does work, along with the original materials from the JSON file.
var loader = new THREE.JSONLoader();
var model = loader.parse(jsonData);
var mesh;
var pointMats = [];
model.materials.forEach(function(material) {
var color = new THREE.Color(material.color.r, material.color.g, material.color.b);
var specular = new THREE.Color(material.specular.r, material.specular.g, material.specular.b);
var newPointsMaterial = new THREE.PointsMaterial({
name: material.name,
color: color,
lights: true,
size: 1
});
pointMats.push(newPointsMaterial);
});
// var pointsMat = new THREE.PointsMaterial( {
// color: 0xffffff,
// size: 0.01
// }); // this works fine and is applied to all the meshes in my scene
mesh = new THREE.Points(model.geometry, pointMats);
scene.add(mesh);
No errors are showing up in the console, probably because there isn't an error to report.
Appreciate your assistance!