I searched this and found some examples in stackoverflow, but the answers did not solve my problem.
What I tried:
First, I create a geometric bucket that will be used for the group, and an array for storing my materials.
var totalGeom = new THREE.Geometry(); var materials = [];
Then I run my data (strData) with a for loop and call addMapMarker3d.
for(var i=0; i<strData.length;i++){ addMapMarker3d([strData[i].lat,strData[i].lon], strData[i].time, measureColors[i]); }
The addMapMarker3d function is as follows:
addMapMarker3d = function(latLng, height, color){ var max = 600; var dist = 25; var opacity = (height/max); var geometry = new THREE.BoxGeometry( Math.floor(dist), height, Math.floor(dist));
After starting the for loop and creating all the cubes:
var mats = new THREE.MeshFaceMaterial(materials) var total = new THREE.Mesh(totalGeom, mats); world.scene.add(total);
Question
While the geometry merge functions and my view port work with significantly improved FPS, all the cubes have exactly the same color and opacity. It seems that the merge uses one material from 10k I. Is there a way to make sure that the geometry uses the material supplied in the array ? Am I doing something wrong?
If I try this in addMapMarker3d:
totalGeom.merge( cube.geometry, cube.matrix, materials.length-1);
I get "Uncaught TypeError: I can not read the property" transparently "undefined", and does not display anything, which I do not understand, because by the examples each geometry should index the material in the array of materials.
three.js r.70