Smart 3D Models

Smart 3D Models script details
Author
matas
Type
Typescript logo image
typescript
App Version
0.13.0
Visibility
public
Date Created
Oct 31, 2023, 1:38:49 PM
Last Edit Date
Dec 5, 2023, 2:09:23 PM

Script Details

The Code
const engine = bitbybit.babylon.engine.getEngine(); const scene = new BABYLON.Scene(engine); bitbybit.babylon.scene.setAndAttachScene({ scene }); var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(100, 30, -100), scene); camera.setTarget(new BABYLON.Vector3(0, 5, 0)); const canvas = bitbybit.babylon.engine.getRenderingCanvas(); camera.attachControl(canvas, true); camera.speed = 1; camera.minZ = 0; const light = new BABYLON.HemisphericLight("HemiLight", new BABYLON.Vector3(0, 1, 0), scene); light.intensityMode = BABYLON.Light.INTENSITYMODE_ILLUMINANCE; light.intensity = 1; const start = async () => { const birdhouseOptions = new Bit.Things.KidsCorner.BirdHouses.ChirpyChalet.ChirpyChaletDto(); const birdhouse = await bitbybit.things.kidsCorner.birdhouses.chirpyChalet.create(birdhouseOptions); const mesh = await bitbybit.draw.drawAnyAsync({ entity: birdhouse }); for (let x = -100; x < 100; x += 10) { for (let z = -100; z < 100; z += 10) { const allChildren = mesh.getChildMeshes(); allChildren.forEach((c: BABYLON.Mesh) => { const instancedMesh = c.createInstance(`${x}-${z}`); instancedMesh.position = new BABYLON.Vector3(x, 0, z); }) } } } start();