Greetings to all.
First of all, I apologize for my lack of knowledge, I’m new to ThreeJS.
I’m trying to find a way to paint a geometric shape based on temperature sensors. This object, in practice, looks like a cylinder/pipe. The effect I’m looking for is something very similar to the one demonstrated in this video:
https://www.youtube.com/watch?v=nimByoIeRJg
I will have the X,Y,Z position information and temperature in degrees Celsius of each sensor, in a json array or something similar. These X,Y,Z positions correspond to points on the object that I want to paint.
To create this object I’m using ExtrudeGeometry, using a function like this:
const CreatePipe = (props: PipeProps) => {
const _props = { ...defaults, ...props };
let pipeShape = new THREE.Shape();
pipeShape.absarc(0, 0, _props.externalRadius, 0, Math.PI * 2);
pipeShape.holes.push(new THREE.Path().absarc(0, 0, _props.internalRadius, 0, Math.PI * 2, true));
let geometry = new THREE.ExtrudeGeometry(pipeShape, {
curveSegments: _props.curveSegments,
depth: _props.depth,
bevelEnabled: false,
steps: _props.steps
});
geometry.center();
geometry.computeVertexNormals();
let colors = [];
for (var i = 0, n = geometry.getAttribute('position').count; i < n; ++i) {
colors.push(1, 1, 1);
}
geometry.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3));
return geometry;
}
which results in something like:
My first question is: By creating the object this way, will it be possible to obtain the effect I’m looking for? Or would it be better to use models imported from Blender or something like that?
I managed to make the user define the sensor positions by clicking on points of the object with the mouse, and assign random temperatures to each point, to test. Then I tried using MeshLambertMaterial with vertexColors = true to apply the colors. But the final result didn’t look very similar to the one in the video. From what I could tell when using ExtrudeGeometry, everything is divided into several triangular faces, so when applying the color to different points, these triangular fragments are exposed:
Is it possible to achieve something similar to the video?
What is the best way?