Script: Linear waves

Linear waves picture
Type
Typescript logo indicatortypescript
Author
matas
Date Created
May 8, 2021, 9:43:48 AM
Last Edit Date
Jul 24, 2025, 9:11:45 AM

Project Information

Creative coding experiments

View Full Project

Script 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 });


});
Plans & Pricing

Choose Your Plan

Editor plans for 3D development, API keys for server-side CAD algorithms

B2B

ENTERPRISE

Custom pricing

Custom software development, dedicated servers & CAD automation at scale.

CAD Automation & Software
  • Custom software development
  • Cloud CAD automation pipelines
  • 3D configurators (STEP & GLTF)
  • Batch export jobs
  • Custom algorithms & deployment
Infrastructure & Support
  • Custom compute allocation
  • Dedicated / VPS server tenants
  • Long-running computation jobs
  • Custom upload limits & overage
  • SLA & premium support