Optionalcomponents: OBJ_SurfaceGridconst { Figure, surfaceGrid } = Fig;
// Orthographic scene with camera oriented so z is up
const figure = new Figure({
scene: {
style: 'orthographic',
camera: { up: [0, 0, 1], position: [1, 0.5, 0.5] },
},
});
// Use surfaceGrid to generate a 3D surface from an xy grid
const points = surfaceGrid({
x: [-0.8, 0.8, 0.02],
y: [-0.8, 0.8, 0.02],
z: (x, y) => 1 / ((x * 5) ** 2 + (y * 5) ** 2 + 1),
});
figure.add([
{
make: 'surface',
points,
color: [1, 0, 0, 1],
normals: 'curve',
},
{
make: 'surface',
points,
lines: true,
color: [0, 0, 0, 1],
position: [0, 0, 0.0001],
},
{ make: 'cameraControl', axis: [0, 0, 1] },
]);
Create a matrix of points that define a surface.
Start with a grid of points in two components (x, y), (x, z), or (y, z), and define the third component (z, y or x repsectively) based on the first two.
Resulting matrix can be used to create a 3D surface.