Script TS TypeScript Free

Multi slot laptop vertical stand

Multi slot laptop vertical stand picture
Author
matas
Created
Apr 9, 2021, 8:12:43 PM
Last edit
Dec 5, 2023, 5:05:43 PM

Edit scriptPreview

Project

Laptop vertical stand

Multi slot and single slot configurable laptop stand. Change parameters and you will be able to configure this stand for your own purposes in minutes.

View full project
const whiteColor = '#ffffff';
const holderColor = '#333333';

const laptopLiftedHeight = 3;
const distanceBetweenLaptops = 1.7;
const exportSTEP = false;

const laptops: Latop[] = [
    {
        width: 30.41,
        length: 1.5,
        height: 21.24,
    },
    {
        width: 30.41,
        length: 1.5,
        height: 21.24,
    }
]

bitbybit.babylon.scene.backgroundColour({ colour: '#bbbbbb' });

const cameraConf = new Bit.Inputs.BabylonScene.CameraConfigurationDto();
cameraConf.lookAt = [0, 11, 0];
cameraConf.position = [30, 10, 35];
cameraConf.wheelPrecision = 0.3;
cameraConf.panningSensibility = 1000;
bitbybit.babylon.scene.adjustActiveArcRotateCamera(cameraConf);

const pointLightConf = new Bit.Inputs.BabylonScene.PointLightDto();
pointLightConf.position = [-15, 20, -5];
pointLightConf.intensity = 8000;
pointLightConf.diffuse = '#3333ff';
pointLightConf.radius = 0;
bitbybit.babylon.scene.drawPointLight(pointLightConf);

const controlPoints = [
    [-12.5, 0, 0],
    [-8, 13, 0],
    [-4, 11, 0],
    [-2, 6, 0],
    [2, 6, 0],
    [4, 14, 0],
    [8, 17, 0],
    [12.5, 0, 0]
] as Bit.Inputs.Base.Point3[];

let laptopStand;
let laptopStandMesh;

const laptopsFilletsMesh = [];

start();

async function start() {
    const ground = await bitbybit.occt.shapes.face.createCircleFace({ center: [0, 0, 0], direction: [0, 1, 0], radius: 75, });
    const groundOptions = new Bit.Inputs.Draw.DrawOcctShapeOptions();
    groundOptions.faceColour = whiteColor;
    groundOptions.drawEdges = false;
    await bitbybit.draw.drawAnyAsync({ entity: ground, options: groundOptions });

    const renderLaptops = async (laptops) => {

        laptops.forEach(laptop => {
            laptop.center = [0, laptop.height / 2 + laptopLiftedHeight, 0] as Bit.Inputs.Base.Point3;
        });

        let laptopFillets = [];
        let totalDistance = 0;
        let previousLaptopLength = 0;

        laptops.forEach(async (laptop, index) => {
            totalDistance += distanceBetweenLaptops + laptop.length / 2 + previousLaptopLength / 2;
            previousLaptopLength = laptop.length;
            laptop.center[2] = totalDistance;
            const laptopBaseModel = await bitbybit.occt.shapes.solid.createBox({
                width: laptop.width,
                length: laptop.length,
                height: laptop.height,
                center: laptop.center
            });
            const laptopFillet = await bitbybit.occt.fillets.filletEdges({ shape: laptopBaseModel, indexes: undefined, radius: 0.2 });
            laptopFillets.push(laptopFillet);

            const laptopVisModel = await bitbybit.occt.shapes.solid.createBox({
                width: laptop.width,
                length: laptop.length - 0.01,
                height: laptop.height,
                center: laptop.center
            });
            const laptopVisFillet = await bitbybit.occt.fillets.filletEdges({ shape: laptopVisModel, indexes: undefined, radius: 0.2 });
            laptopFillets.push(laptopFillet);

            const di = new Bit.Inputs.OCCT.DrawShapeDto(laptopVisFillet);
            di.faceOpacity = 0.2;
            di.edgeWidth = 5;
            di.edgeOpacity = 0.6;
            di.edgeColour = whiteColor;
            di.faceColour = whiteColor;
            const laptopFilletMesh = await bitbybit.occt.drawShape(di);
            laptopsFilletsMesh.push(laptopFilletMesh);
        })

        const polygonWire = await bitbybit.occt.shapes.wire.createPolygonWire({
            points: controlPoints
        });
        const extrusion = await bitbybit.occt.operations.extrude({
            shape: polygonWire, direction: [0, 0, totalDistance += distanceBetweenLaptops + previousLaptopLength / 2]
        });
        const laptopStandFillet = await bitbybit.occt.fillets.filletEdges({ shape: extrusion, indexes: undefined, radius: 1 });
        const laptopStandThick = await bitbybit.occt.operations.makeThickSolidSimple({ shape: laptopStandFillet, offset: -0.5 });

        laptopStand = await bitbybit.occt.booleans.difference({ shape: laptopStandThick, shapes: laptopFillets, keepEdges: false });
        const li = new Bit.Inputs.OCCT.DrawShapeDto(laptopStand);
        li.faceOpacity = 1;
        li.faceColour = holderColor;
        li.edgeColour = whiteColor;
        li.edgeWidth = 5;
        laptopStandMesh = await bitbybit.draw.drawAnyAsync({ entity: laptopStand, options: li });
    }

    await renderLaptops(laptops);
}

class Latop {
    width: number;
    length: number;
    height: number;
    center?: Bit.Inputs.Base.Point3;
}

Plans and pricing

Choose your plan

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

EnterpriseB2BCustompricing

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

Learn moreContact us

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

All prices exclude applicable taxesView all plan details

Contact

Talk to us

Tell us what you are building or what is blocking you, through whichever channel suits you.