space-game/src/createSun.ts
Michael Mainguy 5f3fcf6bc0
All checks were successful
Build / build (push) Successful in 1m19s
Adjust lighting, physics, and visual settings for improved gameplay
Increase asteroid sizes, add ship-specific lighting, enhance sun brightness, adjust physics timesteps, and improve planet/asteroid material appearance. Increase planet count to 12 and move them farther from sun for better spatial layout.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 13:19:01 -05:00

48 lines
1.9 KiB
TypeScript

import {
AbstractMesh,
Color3, GlowLayer,
MeshBuilder,
PhysicsAggregate,
PhysicsMotionType,
PhysicsShapeType,
PointLight,
StandardMaterial, Texture,
Vector3
} from "@babylonjs/core";
import {DefaultScene} from "./defaultScene";
import {FireProceduralTexture} from "@babylonjs/procedural-textures";
export function createSun() : AbstractMesh {
const light = new PointLight("light", new Vector3(0, 0, 400), DefaultScene.MainScene);
light.intensity = 1000000;
const sun = MeshBuilder.CreateSphere("sun", {diameter: 50, segments: 32}, DefaultScene.MainScene);
//const sunAggregate = new PhysicsAggregate(sun, PhysicsShapeType.SPHERE, {mass: 0}, DefaultScene.MainScene);
//sunAggregate.body.setMotionType(PhysicsMotionType.STATIC);
const material = new StandardMaterial("material", DefaultScene.MainScene);
material.emissiveTexture =new FireProceduralTexture("fire", 1024, DefaultScene.MainScene);
material.emissiveColor = new Color3(.5, .5, .1);
material.disableLighting = true;
sun.material = material;
const gl = new GlowLayer("glow", DefaultScene.MainScene);
//gl.addIncludedOnlyMesh(sun);
gl.intensity = 1;
sun.position = new Vector3(0, 0, 400);
return sun;
}
export function createPlanet(position: Vector3, diameter: number, name: string) : AbstractMesh {
const planet = MeshBuilder.CreateSphere(name, {diameter: diameter, segments: 32}, DefaultScene.MainScene);
const material = new StandardMaterial(name + "-material", DefaultScene.MainScene);
const texture = new Texture("/planetTextures/Arid/Arid_01-512x512.png", DefaultScene.MainScene);
material.diffuseTexture = texture;
material.ambientTexture = texture;
material.roughness = 1;
material.specularColor = Color3.Black();
//material.diffuseColor = new Color3(Math.random(), Math.random(), Math.random());
planet.material = material;
planet.position = position;
return planet;
}