Closed digimbyte closed 2 years ago
tried another solution by mapping the array of values to a Vec3 but still have an Infinity on the output
const radius = 10;
const SphereMesh = sphere(radius, { segments: radius * 2 });
const spots = RVP(SphereMesh.positions, SphereMesh.cells, 3);
const newSpots = spots.map(spot => new Vec3(spot[0], spot[1], spot[2]));
const worley = new Worley(newSpots, '3d', 'euclidean');
Well, you almost got it right on the first try.
The Worley.st(position)
needs position
to be a Vec3
, which is an object that has x
, y
, and z
, among other features (while you are passing an array).
However, we don't actually need it to be a Vec3
in this case because we only need the x
, the y
, and the z
to get the distances.
This should work:
// let noise = worley.st([x, y, z]);
let noise = worley.st({ x, y, z });
This should work in case you want to use the Vec3
:
// let noise = worley.st([x, y, z]);
let noise = worley.st(new Vec3(...[x, y, z]));
I don't know what the shape of the RVP
looks like, but notice each spot should also have its own x
, y
, and z
attributes.
PD: I think the second try actually generates an array with three vectors, which is not what we need.
Having some trouble - I followed the general guide of a torus example but with a sphere but the values rendering out are returning "Infinity"
I suspect the values aren't handled correctly and would like some advice from the developer