setLinesfunctionnacatamalon
setLines(lines: TLines, next: Float32Array<ArrayBufferLike> | typeOperator) => voidReplaces what a set of lines draws, from the next frame on.
Two forms, for two sizes of job:
- A few lines, as a list:
{ from, to, color }each, the colour as text ('#ffcc00'). An outline, a path, an arrow. - Thousands, rewritten every frame, as a
Float32Array: seven numbers a corner,x, y, z, r, g, b, a, the colour from 0 to 1, and two corners a line. A cloth, a field of stars, rain. Fill the same array every frame: it is copied, so it can be reused straight away.
Either form can be shorter or longer than the last.
Parámetros
linesTLinesThe lines
useLinesgave.nextFloat32Array<ArrayBufferLike> | typeOperatorWhat they draw now.
Ejemplo
const Level = () => {
useCamera3d({ projection: 'perspective', fov: 60, transform: { z: 6 } });
const box = useLines();
const at = new Float32Array(7 * 2 * 4);
useUpdate((_delta, time) => {
// A square turning on the floor, written as numbers: four lines, two corners each.
for (let i = 0; i < 4; i++) {
for (const [end, turn] of [[0, i], [1, i + 1]]) {
const angle = time + (turn * Math.PI) / 2;
at.set([Math.cos(angle), 0, Math.sin(angle), 0.3, 1, 0.6, 1], (i * 2 + end) * 7);
}
}
setLines(box, at);
});
return createScene();
};