Linear waves

Linear waves script details
Author
matas
Type
Typescript logo image
typescript
App Version
0.13.0
Visibility
public
Date Created
May 8, 2021, 7:43:48 AM
Last Edit Date
Dec 5, 2023, 5:03:49 PM

Script Details

The Code
const circles1 = []; const circles2 = []; for (let x = 0; x < 20; x++) { for (let y = 0; y < 20; y++) { const circle = bitbybit.verb.curve.circle.createCircle({ center: [x, y, 0], radius: 2, xAxis: [1, 0, 0], yAxis: [0, 1, 0] }); const rotated1 = bitbybit.verb.curve.transform({ curve: circle, transformation: bitbybit.babylon.transforms.rotationCenterZ({ angle: y * 10, center: [x, y, 0] }) }) circles1.push(rotated1); const rotated2 = bitbybit.verb.curve.transform({ curve: circle, transformation: bitbybit.babylon.transforms.rotationCenterZ({ angle: -y * 10, center: [x, y, 0] }) }) circles2.push(rotated2); } } const curveDraw = new Bit.Inputs.Verb.DrawCurvesDto(); curveDraw.curves = circles1; let points1 = []; let points2 = []; circles1.forEach(circle => { let point = bitbybit.verb.curve.pointAtParam({ parameter: param1, curve: circle }); points1.push(point); }) circles2.forEach(circle => { let point = bitbybit.verb.curve.pointAtParam({ parameter: param1, curve: circle }); points2.push(point); }) const lines = []; const drawOptionsOut = new Bit.Inputs.Draw.DrawBasicGeometryOptions(); drawOptionsOut.updatable = true; drawOptionsOut.size = 50; drawOptionsOut.opacity = 0.1; drawOptionsOut.colours = '#ffffff'; const drawLinesColor = new Bit.Inputs.Draw.DrawBasicGeometryOptions(); drawLinesColor.updatable = true; drawLinesColor.size = 1; drawLinesColor.opacity = 1; drawLinesColor.colours = '#f2c4aa'; const drawLinesWhite = new Bit.Inputs.Draw.DrawBasicGeometryOptions(); drawLinesWhite.updatable = true; drawLinesWhite.size = 6; drawLinesWhite.opacity = 1; drawLinesWhite.colours = '#ffffff'; let drawLinesWhiteMesh; let drawLinesColorMesh; let drawOptionsOutMesh; let param1 = 0; let param2 = 0.5; let step1 = 0.0004; let step2 = 0.0008; bitbybit.time.registerRenderFunction((update) => { if (param2 > 2 || param2 < -1) { step2 *= -1; } if (param1 > 2 || param1 < -1) { step1 *= -1; } points1.length = 0; points2.length = 0; lines.length = 0; circles1.forEach((circle, index) => { let point = bitbybit.verb.curve.pointAtParam({ parameter: param1 + index / 200, curve: circle }); points1.push(point); }); circles2.forEach((circle, index) => { let point = bitbybit.verb.curve.pointAtParam({ parameter: param2 - index / 200, curve: circle }); points2.push(point); }); param1 += step1; param2 += step2; points1.forEach((pt, i) => { lines.push(bitbybit.line.create({ start: pt, end: points2[i] })); }); drawOptionsOutMesh = bitbybit.draw.drawAny({ entity: lines, babylonMesh: drawOptionsOutMesh, options: drawOptionsOut }); drawLinesWhiteMesh = bitbybit.draw.drawAny({ entity: lines, babylonMesh: drawLinesWhiteMesh, options: drawLinesWhite }); drawLinesColorMesh = bitbybit.draw.drawAny({ entity: lines, babylonMesh: drawLinesColorMesh, options: drawLinesColor }); });