Hey all!
I’ve been playing with Three.js for the last few days, but by now I got stuck because all the differences in builds and examples on the internet.
Them main item I get stuck on is IcosahedronGeometry
. The shift from geometry.vertices
to geometry.attributes
Is where I get stuck. I understand it went from a vector array to a single array for each coordinate. But I don’t know how to get → calculate → and set the new values.
This is an example that gets closest to the effect I have in mind. In updateVertices()
you can see a perlin noise beeing applied to the vectors.
And this is my current approach. But the blob just disappears in the abyss of nothingness.
function setNewPoints( a ) {
const positionAttribute = blob.geometry.getAttribute( 'position' );
let newPositionAttribute = [];
const vertex = new THREE.Vector3();
for ( let vertexIndex = 0; vertexIndex < positionAttribute.count; vertexIndex++ ) {
vertex.fromBufferAttribute( positionAttribute, vertexIndex );
var perlin = noise.simplex3(
vertex.x * 0.006 + a * 0.0002,
vertex.y * 0.006 + a * 0.0003,
vertex.z * 0.006 );
var ratio = perlin * 0.4 * ( mouse.y + 0.1 ) + 0.8;
vertex.multiplyScalar( ratio );
newPositionAttribute.push(vertex.x, vertex.y, vertex.z);
}
blob.geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( newPositionAttribute, 3 ) );
blob.geometry.attributes.position.needsUpdate = true; // required after the first render
blob.geometry.computeBoundingSphere();
}
The code above is, I think, the main focus point of the effect.
The MaxTween morphs the mouse with an ease, so that the height of the Perlin is not abrupt.
So, the question would be, how could I get my code in the current build to work and look like the example.