Alien Nebula Cruiser GLTF Asset

Alien Nebula Cruiser GLTF Asset script details
Author
matas
Type
Typescript logo image
typescript
App Version
0.15.9
Visibility
public
Date Created
Nov 9, 2023, 10:42:13 AM
Last Edit Date
Apr 29, 2024, 8:27:11 AM

Script Details

The Code
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();