Adjust lighting, physics, and visual settings for improved gameplay
All checks were successful
Build / build (push) Successful in 1m19s
All checks were successful
Build / build (push) Successful in 1m19s
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>
This commit is contained in:
parent
44989d5145
commit
5f3fcf6bc0
@ -59,9 +59,9 @@ export function createPlanets(
|
|||||||
|
|
||||||
// Apply random planet texture
|
// Apply random planet texture
|
||||||
const material = new StandardMaterial(`planet-material-${i}`, DefaultScene.MainScene);
|
const material = new StandardMaterial(`planet-material-${i}`, DefaultScene.MainScene);
|
||||||
material.diffuseTexture = new Texture(getRandomPlanetTexture(), DefaultScene.MainScene);
|
const texture = new Texture(getRandomPlanetTexture(), DefaultScene.MainScene);
|
||||||
planet.material = material;
|
material.diffuseTexture = texture;
|
||||||
material.specularColor = Color3.Black()
|
material.ambientTexture = texture;
|
||||||
|
|
||||||
planets.push(planet);
|
planets.push(planet);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,13 +14,14 @@ import {FireProceduralTexture} from "@babylonjs/procedural-textures";
|
|||||||
|
|
||||||
export function createSun() : AbstractMesh {
|
export function createSun() : AbstractMesh {
|
||||||
const light = new PointLight("light", new Vector3(0, 0, 400), DefaultScene.MainScene);
|
const light = new PointLight("light", new Vector3(0, 0, 400), DefaultScene.MainScene);
|
||||||
light.intensity = 100;
|
light.intensity = 1000000;
|
||||||
|
|
||||||
const sun = MeshBuilder.CreateSphere("sun", {diameter: 50, segments: 32}, DefaultScene.MainScene);
|
const sun = MeshBuilder.CreateSphere("sun", {diameter: 50, segments: 32}, DefaultScene.MainScene);
|
||||||
|
|
||||||
//const sunAggregate = new PhysicsAggregate(sun, PhysicsShapeType.SPHERE, {mass: 0}, DefaultScene.MainScene);
|
//const sunAggregate = new PhysicsAggregate(sun, PhysicsShapeType.SPHERE, {mass: 0}, DefaultScene.MainScene);
|
||||||
//sunAggregate.body.setMotionType(PhysicsMotionType.STATIC);
|
//sunAggregate.body.setMotionType(PhysicsMotionType.STATIC);
|
||||||
const material = new StandardMaterial("material", DefaultScene.MainScene);
|
const material = new StandardMaterial("material", DefaultScene.MainScene);
|
||||||
material.emissiveTexture =new FireProceduralTexture("fire", 512, DefaultScene.MainScene);
|
material.emissiveTexture =new FireProceduralTexture("fire", 1024, DefaultScene.MainScene);
|
||||||
material.emissiveColor = new Color3(.5, .5, .1);
|
material.emissiveColor = new Color3(.5, .5, .1);
|
||||||
material.disableLighting = true;
|
material.disableLighting = true;
|
||||||
sun.material = material;
|
sun.material = material;
|
||||||
|
|||||||
@ -74,8 +74,8 @@ export class Level1 implements Level {
|
|||||||
return {
|
return {
|
||||||
rockCount: 5,
|
rockCount: 5,
|
||||||
forceMultiplier: 1,
|
forceMultiplier: 1,
|
||||||
rockSizeMin: 5,
|
rockSizeMin: 10,
|
||||||
rockSizeMax: 10,
|
rockSizeMax: 20,
|
||||||
distanceMin: 150,
|
distanceMin: 150,
|
||||||
distanceMax: 200
|
distanceMax: 200
|
||||||
};
|
};
|
||||||
@ -177,7 +177,7 @@ export class Level1 implements Level {
|
|||||||
const distRange = config.distanceMax - config.distanceMin;
|
const distRange = config.distanceMax - config.distanceMin;
|
||||||
const dist = (Math.random() * distRange) + config.distanceMin;
|
const dist = (Math.random() * distRange) + config.distanceMin;
|
||||||
const sizeRange = config.rockSizeMax - config.rockSizeMin;
|
const sizeRange = config.rockSizeMax - config.rockSizeMin;
|
||||||
const size = Vector3.Random(1,1.3).scale(Math.random() * sizeRange + config.rockSizeMin)
|
const size = Vector3.One().scale(Math.random() * sizeRange + config.rockSizeMin)
|
||||||
|
|
||||||
const rock = await RockFactory.createRock(i, new Vector3(0,1,dist),
|
const rock = await RockFactory.createRock(i, new Vector3(0,1,dist),
|
||||||
size,
|
size,
|
||||||
@ -251,12 +251,12 @@ export class Level1 implements Level {
|
|||||||
// Create planets around the sun
|
// Create planets around the sun
|
||||||
const sunPosition = sun.position;
|
const sunPosition = sun.position;
|
||||||
const planets = createPlanetsOrbital(
|
const planets = createPlanetsOrbital(
|
||||||
8, // 8 planets
|
12, // 8 planets
|
||||||
sunPosition, // sun position
|
sunPosition, // sun position
|
||||||
50, // min diameter
|
100, // min diameter
|
||||||
100, // max diameter
|
200, // max diameter
|
||||||
400, // min distance from sun
|
1000, // min distance from sun
|
||||||
1000 // max distance from sun
|
2000 // max distance from sun
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(`Created ${planets.length} planets around sun at position`, sunPosition);
|
console.log(`Created ${planets.length} planets around sun at position`, sunPosition);
|
||||||
|
|||||||
@ -131,7 +131,7 @@ export class Main {
|
|||||||
}
|
}
|
||||||
DefaultScene.DemoScene = new Scene(this._engine);
|
DefaultScene.DemoScene = new Scene(this._engine);
|
||||||
DefaultScene.MainScene = new Scene(this._engine);
|
DefaultScene.MainScene = new Scene(this._engine);
|
||||||
DefaultScene.MainScene.ambientColor = new Color3(.2, .2, .2);
|
DefaultScene.MainScene.ambientColor = new Color3(.5, .5, .5);
|
||||||
|
|
||||||
setLoadingMessage("Initializing Physics Engine..");
|
setLoadingMessage("Initializing Physics Engine..");
|
||||||
await this.setupPhysics();
|
await this.setupPhysics();
|
||||||
@ -169,8 +169,8 @@ export class Main {
|
|||||||
const havokPlugin = new HavokPlugin(true, havok);
|
const havokPlugin = new HavokPlugin(true, havok);
|
||||||
|
|
||||||
DefaultScene.MainScene.enablePhysics(new Vector3(0, 0, 0), havokPlugin);
|
DefaultScene.MainScene.enablePhysics(new Vector3(0, 0, 0), havokPlugin);
|
||||||
DefaultScene.MainScene.getPhysicsEngine().setTimeStep(1/90);
|
DefaultScene.MainScene.getPhysicsEngine().setTimeStep(1/45);
|
||||||
DefaultScene.MainScene.getPhysicsEngine().setSubTimeStep(9);
|
DefaultScene.MainScene.getPhysicsEngine().setSubTimeStep(5);
|
||||||
|
|
||||||
DefaultScene.MainScene.collisionsEnabled = true;
|
DefaultScene.MainScene.collisionsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/ship.ts
14
src/ship.ts
@ -8,7 +8,7 @@ import {
|
|||||||
Observable,
|
Observable,
|
||||||
PhysicsAggregate,
|
PhysicsAggregate,
|
||||||
PhysicsMotionType,
|
PhysicsMotionType,
|
||||||
PhysicsShapeType,
|
PhysicsShapeType, PointLight,
|
||||||
SceneLoader,
|
SceneLoader,
|
||||||
SpotLight,
|
SpotLight,
|
||||||
StandardMaterial,
|
StandardMaterial,
|
||||||
@ -145,7 +145,7 @@ export class Ship {
|
|||||||
this._ammoBaseMesh.material = this._ammoMaterial;
|
this._ammoBaseMesh.material = this._ammoMaterial;
|
||||||
this._ammoBaseMesh.setEnabled(false);
|
this._ammoBaseMesh.setEnabled(false);
|
||||||
|
|
||||||
//const light = new DirectionalLight("light", new Vector3(.1, -1, 0), DefaultScene.MainScene);
|
|
||||||
|
|
||||||
//const landingLight = new SpotLight("landingLight", new Vector3(0, 0, 0), new Vector3(0, -.5, .5), 1.5, .5, DefaultScene.MainScene);
|
//const landingLight = new SpotLight("landingLight", new Vector3(0, 0, 0), new Vector3(0, -.5, .5), 1.5, .5, DefaultScene.MainScene);
|
||||||
// landingLight.parent = this._ship;
|
// landingLight.parent = this._ship;
|
||||||
@ -201,7 +201,15 @@ export class Ship {
|
|||||||
shipMesh.rotation.y = Math.PI;
|
shipMesh.rotation.y = Math.PI;
|
||||||
shipMesh.position.y = 1;
|
shipMesh.position.y = 1;
|
||||||
shipMesh.position.z = -1;
|
shipMesh.position.z = -1;
|
||||||
|
const light = new PointLight("ship.light", new Vector3(0, 1, .9), DefaultScene.MainScene);
|
||||||
|
light.intensity = 4;
|
||||||
|
light.includedOnlyMeshes = [shipMesh];
|
||||||
|
for (const mesh of shipMesh.getChildMeshes()) {
|
||||||
|
if (mesh.material.id.indexOf('glass') === -1) {
|
||||||
|
light.includedOnlyMeshes.push(mesh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
light.parent = this._ship;
|
||||||
DefaultScene.MainScene.getMaterialById('glass_mat.002').alpha = .4;
|
DefaultScene.MainScene.getMaterialById('glass_mat.002').alpha = .4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,12 +61,17 @@ export class RockFactory {
|
|||||||
this._rockMaterial.id = 'asteroid-material';
|
this._rockMaterial.id = 'asteroid-material';
|
||||||
const material = (this._rockMaterial as PBRMaterial)
|
const material = (this._rockMaterial as PBRMaterial)
|
||||||
//material.albedoTexture = null;
|
//material.albedoTexture = null;
|
||||||
material.ambientColor = new Color3(.4, .4 ,.4);
|
//material.ambientColor = new Color3(.4, .4 ,.4);
|
||||||
|
material.albedoColor = new Color3(.4, .4 ,.4);
|
||||||
|
//material.ambientTexture = material.albedoTexture;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//material.albedoColor = new Color3(1, 1, 1);
|
//material.albedoColor = new Color3(1, 1, 1);
|
||||||
//material.emissiveColor = new Color3(1, 1, 1);
|
//material.emissiveColor = new Color3(1, 1, 1);
|
||||||
this._rockMesh.material = this._rockMaterial;
|
this._rockMesh.material = this._rockMaterial;
|
||||||
importMesh.meshes[1].dispose(false, true);
|
//importMesh.meshes[1].dispose(false, true);
|
||||||
importMesh.meshes[0].dispose();
|
//importMesh.meshes[0].dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user