Script TS TypeScript Free

Cloud Assets

Cloud Assets picture
Author
matas
Created
Jan 27, 2024, 7:15:57 AM
Last edit
Jan 27, 2024, 9:57:34 AM

Edit scriptPreview

Project

Getting Started Demos TypeScript

This project contains demo scripts for TypeScript Monaco editor that are used as examples in the "Getting Started" section of the documentation.

View full project
const drawOptions = new Bit.Inputs.Draw.DrawOcctShapeSimpleOptions();
drawOptions.edgeWidth = 1;
drawOptions.precision = 0.001;
drawOptions.faceColour = "#ffffff";

const start = async () => {
    nonEssentials();
    loadBoomBox();
    loadCalmCup();
    createGround();
}

async function loadCalmCup() {
    const fileCalmCup = await bitbybit.asset.getFile({
        fileName: "CalmCup.step"
    });

    const calmCupShape = await bitbybit.occt.io.loadSTEPorIGES({
        assetFile: fileCalmCup,
        adjustZtoY: false,
    });

    const scaledCalmCup = await bitbybit.occt.transforms.scale({
        shape: calmCupShape,
        factor: 0.3,
    });

    const transformedCalmCup = await bitbybit.occt.transforms.translate({
        shape: scaledCalmCup,
        translation: [-2, 0, 0],
    });

    await bitbybit.draw.drawAnyAsync({
        entity: transformedCalmCup,
        options: drawOptions
    });

    // It is a good practice to keep the memory of OCCT clean after you have constructed your drawn mesh.
    // Unless, of course, you will need some of these shapes in the future.
    bitbybit.occt.deleteShapes({
        shapes: [
            calmCupShape,
            scaledCalmCup,
            transformedCalmCup
        ]
    })
}

async function loadBoomBox() {
    const fileBoomBox = await bitbybit.asset.getFile({
        fileName: "BoomBox.glb"
    });
    const boomboxMesh = await bitbybit.babylon.io.loadAssetIntoScene({
        assetFile: fileBoomBox,
        hidden: false
    });
    boomboxMesh.position.x = 2;
}

async function createGround() {
    const groundShape = await bitbybit.occt.shapes.face.createCircleFace({
        radius: 7,
        center: [0, 0, 0],
        direction: [0, 1, 0]
    });
    
    await bitbybit.draw.drawAnyAsync({
        entity: groundShape,
        options: drawOptions
    });

    bitbybit.occt.deleteShape({
        shape: groundShape
    })
}

function nonEssentials() {
    bitbybit.babylon.scene.useRightHandedSystem({
        use: true
    });
    const dirLightOptions = new Bit.Inputs.BabylonScene.DirectionalLightDto();
    dirLightOptions.direction = [-100, -100, 100];
    bitbybit.babylon.scene.drawDirectionalLight(dirLightOptions);
    const skyboxOptions = new Bit.Inputs.BabylonScene.SkyboxDto();
    skyboxOptions.skybox = Bit.Inputs.Base.skyboxEnum.clearSky;
    bitbybit.babylon.scene.enableSkybox(skyboxOptions);
}

start();

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.