Public
Edited
Nov 16, 2023
1 star
Insert cell
Insert cell
Insert cell
genererFigures = {
const figures = [];
const features = { Name: "" };

// you can't import anything from outside (no functions or libraries)
// you should not produce any collateral effect
// You have access to fxrand()

// if you are unsure of the scale, make all geometry sizes and positions related
// to a constant;

// you can use the anaverse bool to decide if a function has to be executed in
// anaverse or out of it.
// In the anaverse, there is a global (worker-wide) constant as
// const anaverse = true;
//

// ------ your code starts here ------

// Here the variable u is the unit used to scale
const u = 1;

const myCurve = (t) => {
const tx = t * 3 - 1.5;
const ty = Math.sin(2 * Math.PI * t);
const tz = 0;

return { tx, ty, tz };
};

//simple tube

const tube = {
geometry: {
type: "TubeGeometry", // Type of geometry
args: [
"myCurve", // path function name
20, // tubularSegments
2, // radius
8, // radialSegments
false // closed
]
},
pos: {
// Position
x: (-0.5 + fxrand() * 1) * u,
y: (-0.5 + fxrand() * 1) * u,
z: (-0.5 + fxrand() * 1) * u
},
rot: {
// Rotation
x: 0,
y: 0,
z: 0
},
scale: {
x: 0.1,
y: 0.1,
z: 0.1
},
lines: true, // Display color segments (like wireframe, but faces not triangles)
hatch: true, // Fill with white texture
full: false // Fill with color texture (in the anaverse, red and cyan)
};

const curves = { myCurve };

figures.push(tube);

// ------ your code ends here ------

return { figures, features, curves };
}
Insert cell
Insert cell
Insert cell
fxrand()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more