I am working on a geometric visualization using Trois.js. My goal is to color the nodes of the mesh according to their values. For that, i have already created the nodes and i would first like to import the values from a file.dat, then assign the nodes with these values, in order to change the colors of the nodes according to their assigned values. Here is the code.js I am using to create the nodes:
``` jsonURL = "/resources/datasets/Mesh.json"; var colors = ['#898ec1', '#9193bd', '#9999ba', '#a19eb7', '#a8a4b4', '#aea9b1', '#b5afae', '#bbb5ac', '#c1bbaa', '#c7c0a9', '#cdc6a8', '#d2cca8', '#d8d2a8', '#ded8a9', '#e3ddab', '#e8e3ae', '#ede9b2', '#f2efb9', '#f7f4c2', '#fcface', '#fff5d1', '#ffeac2', '#ffe0b3', '#fdd6a6', '#fbcc99', '#f7c38c', '#f3b980', '#efb075', '#eaa76a', '#e49e61', '#de9558', '#d88d4f', '#d18448', '#c97c41', '#c1753b', '#b86d37', '#b06733', '#a66030', '#9c5a2e', '#92542e']; $.getJSON(jsonURL , function setPoints(dataset) { var timestamp=1565715018; for (i=0; i<dataset.humidity.length;i++){ if (dataset.humidity[i].time == timestamp){ for (ii=0; i<dataset.humidity[i].data.length;ii++) { var dotPz = dataset.humidity[i].data[ii].x; var dotPx = dataset.humidity[i].data[ii].y; var dotPy = dataset.humidity[i].data[ii].z; var dotGeometry = new THREE.Geometry(); dotGeometry.vertices.push(new THREE.Vector3( dotPx, dotPy, dotPz)); var dotMaterial = new THREE.PointsMaterial( { size: 0.0002, color: "#ffffff", blending: THREE.AdditiveBlending, transparent: true, depthTest: false, sizeAttenuation: true, } ); scene.add(new THREE.Points(dotGeometry, dotMaterial)); } }; } }); ```
Does anyone know how to assign nodes with values imported from a file.dat? Any ideas would be very helpful! Thank you