Script TS TypeScript Free

Alien Nebula Cruiser GLTF Asset

Alien Nebula Cruiser GLTF Asset picture
Author
matas
Created
Nov 9, 2023, 10:42:13 AM
Last edit
Apr 29, 2024, 8:27:11 AM

Edit scriptPreview

Project

Alien Nebula Cruiser

This is a conceptual design of advanced spacecraft that shows off some of the new algorithms of the platform, such as splitting the wire into multiple pieces, selecting geometry by using boolean pattern matching, and adopting advanced lofting techniques.

View full project
const start = async () => {

    const files = [
        "alien-nebula-cruiser-1.glb",
        "alien-nebula-cruiser-2.glb",
        "alien-nebula-cruiser-3.glb"
    ]

    const gltfFiles = await Promise.all(files.map(fileName => bitbybit.asset.getFile({ fileName })));
    const meshes = await Promise.all(gltfFiles.map(assetFile => bitbybit.babylon.io.loadAssetIntoScene({ assetFile, hidden: false })));

    const triangle = await bitbybit.occt.shapes.wire.createNGonWire({
        nrCorners: 3,
        center: [0, 0, 0],
        direction: [0, 1, 0],
        radius: 14,
    });

    const corners = await bitbybit.occt.shapes.edge.getCornerPointsOfEdgesForShape({ shape: triangle });

    corners.forEach((corner, index) => {
        if (meshes[index]) {
            meshes[index].position = new BABYLON.Vector3(corner[0], corner[1], corner[2]);
        }
    })

    const triangleBase = await bitbybit.occt.shapes.wire.createNGonWire({
        nrCorners: 3,
        center: [0, 0, 0],
        direction: [0, 1, 0],
        radius: 30,
    });

    const triangleOffset = await bitbybit.occt.operations.offset({ shape: triangleBase, distance: 5, tolerance: 0.1 });
    const triangleFace = await bitbybit.occt.shapes.face.createFaceFromWire({ shape: triangleOffset, planar: true });
    const triangleExtrusion = await bitbybit.occt.operations.extrude({ shape: triangleFace, direction: [0, 1, 0] });
    const triangleFillet = await bitbybit.occt.fillets.filletEdges({ shape: triangleExtrusion, radius: 0.4 });

    const options = new Bit.Inputs.Draw.DrawOcctShapeOptions();
    options.faceColour = "#ff00ff";
    options.edgeColour = "#000000";
    const triangleMesh = await bitbybit.draw.drawAnyAsync({
        entity: triangleFillet,
        options
    });

    const parentMesh = new BABYLON.Mesh("parent");

    meshes.forEach(m => m.parent = parentMesh);

    triangleMesh.position = new BABYLON.Vector3(0, -6, 0);
    triangleMesh.parent = parentMesh;

    const rotationVec = new BABYLON.Vector3(0, 1, 0);

    const optionsLight = new Bit.Inputs.BabylonScene.DirectionalLightDto();
    optionsLight.direction = [-100, -100, -100];
    optionsLight.intensity = 4;
    optionsLight.shadowGeneratorMapSize = 2056;

    bitbybit.babylon.scene.drawDirectionalLight(optionsLight);

    bitbybit.time.registerRenderFunction(() => {
        parentMesh.rotate(rotationVec, 0.0005);
        meshes.forEach(mesh => {
            mesh.rotate(rotationVec, -0.002);
        })
    });


}

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.