3D Girl Gaussian Splat Animations

3D Girl Gaussian Splat Animations script details
Type
Typescript logo image
typescript
App Version
0.15.13
Visibility
public
Date Created
Jun 6, 2024, 2:01:53 PM
Last Edit Date
Jul 3, 2024, 3:40:45 PM

Script Details

The Code
const { occt } = bitbybit; enum cameraAnimationEnum { ellipse, spiral, line, }; let activeAnimation = cameraAnimationEnum.ellipse; const start = async () => { const gs = await bitbybit.babylon.gaussianSplatting.create({ url: "https://firebasestorage.googleapis.com/v0/b/bit-by-bit-prod.appspot.com/o/users%2FyVqNAFXmieX0iAkdP6wAz5BJ4X82%2Fprojects%2FUBzXJuiF3BaG3Yuu2Kaa%2Fassets%2Fruta.splat?alt=media&token=5151d734-9519-4bba-ba29-7173c2bab431" }); gs.position = new BABYLON.Vector3(-0.6, 0.1, -0.1); const skyboxDto = new Bit.Inputs.BabylonScene.SkyboxDto(); skyboxDto.blur = 0.5; skyboxDto.skybox = Bit.Inputs.Base.skyboxEnum.city; bitbybit.babylon.scene.enableSkybox(skyboxDto); const lightDto = new Bit.Inputs.BabylonScene.DirectionalLightDto(); lightDto.intensity = 2; lightDto.shadowGeneratorMapSize = 4000; lightDto.diffuse = "#2E58FF"; bitbybit.babylon.scene.drawDirectionalLight(lightDto); const lightDto2 = new Bit.Inputs.BabylonScene.DirectionalLightDto(); lightDto2.direction = [-100, -100, 100]; lightDto2.intensity = 2; lightDto2.shadowGeneratorMapSize = 4000; lightDto2.diffuse = "#2E58FF"; bitbybit.babylon.scene.drawDirectionalLight(lightDto2); const assetTableRes = await fetch("https://firebasestorage.googleapis.com/v0/b/bit-by-bit-prod.appspot.com/o/users%2FyVqNAFXmieX0iAkdP6wAz5BJ4X82%2Fprojects%2FUBzXJuiF3BaG3Yuu2Kaa%2Fassets%2Fchair-base.glb?alt=media&token=cd322fb4-ba93-4902-8f48-ac059bb6c8c9"); const assetTableBlob = await assetTableRes.blob(); const file = new File([assetTableBlob], "chair.glb"); const x = await bitbybit.babylon.io.loadAssetIntoScene({ assetFile: file, hidden: false, }); setupCameraAndAnimations(); return { meshes: [x, gs] } } async function setupCameraAndAnimations() { let wire; if (activeAnimation === cameraAnimationEnum.ellipse) { wire = await occt.shapes.wire.createEllipseWire({ center: [0, 3, 0], radiusMinor: 4, radiusMajor: 5, direction: [0, 1, -0.1] }); } else if (activeAnimation === cameraAnimationEnum.line) { wire = await occt.shapes.wire.createLineWire({ start: [10, 3, 2], end: [-6, 3, 9], }); } else if (activeAnimation === cameraAnimationEnum.spiral) { const radius = 6; const step = 0.5; const ptsSpiralBase: Bit.Inputs.Base.Point3[] = [ [radius, step * 4, 0], [0, step * 5, radius], [-radius, step * 6, 0], [0, step * 7, -radius], [radius, step * 8, 0], [0, step * 9, radius], [-radius, step * 10, 0], [0, step * 11, -radius], ]; wire = await occt.shapes.wire.interpolatePoints({ points: ptsSpiralBase, periodic: false, tolerance: 0.01 }); } const points = await occt.shapes.wire.divideWireByEqualDistanceToPoints({ shape: wire, nrOfDivisions: 5000, removeStartPoint: false, removeEndPoint: true }); const ptsLooped = [...points, ...points.reverse()] const camera = bitbybit.babylon.scene.getActiveCamera() as BABYLON.ArcRotateCamera; camera.target = new BABYLON.Vector3(0, 1.75, 0); let index = 0; bitbybit.time.registerRenderFunction(() => { if (index < ptsLooped.length) { const pt = ptsLooped[index]; camera.setPosition(new BABYLON.Vector3(pt[0], pt[1], pt[2])) index++; } else { index = 0; } }); } start(); // Bit.setBitbybitRunnerResult(start());