diff --git a/src/createPlanets.ts b/src/createPlanets.ts index 268dfd6..1f8e2da 100644 --- a/src/createPlanets.ts +++ b/src/createPlanets.ts @@ -59,9 +59,9 @@ export function createPlanets( // Apply random planet texture const material = new StandardMaterial(`planet-material-${i}`, DefaultScene.MainScene); - material.diffuseTexture = new Texture(getRandomPlanetTexture(), DefaultScene.MainScene); - planet.material = material; - material.specularColor = Color3.Black() + const texture = new Texture(getRandomPlanetTexture(), DefaultScene.MainScene); + material.diffuseTexture = texture; + material.ambientTexture = texture; planets.push(planet); } diff --git a/src/createSun.ts b/src/createSun.ts index ae78163..368fa1b 100644 --- a/src/createSun.ts +++ b/src/createSun.ts @@ -14,13 +14,14 @@ import {FireProceduralTexture} from "@babylonjs/procedural-textures"; export function createSun() : AbstractMesh { 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 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", 512, DefaultScene.MainScene); + material.emissiveTexture =new FireProceduralTexture("fire", 1024, DefaultScene.MainScene); material.emissiveColor = new Color3(.5, .5, .1); material.disableLighting = true; sun.material = material; diff --git a/src/level1.ts b/src/level1.ts index 537f6a7..6131162 100644 --- a/src/level1.ts +++ b/src/level1.ts @@ -74,8 +74,8 @@ export class Level1 implements Level { return { rockCount: 5, forceMultiplier: 1, - rockSizeMin: 5, - rockSizeMax: 10, + rockSizeMin: 10, + rockSizeMax: 20, distanceMin: 150, distanceMax: 200 }; @@ -177,7 +177,7 @@ export class Level1 implements Level { const distRange = config.distanceMax - config.distanceMin; const dist = (Math.random() * distRange) + config.distanceMin; 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), size, @@ -251,12 +251,12 @@ export class Level1 implements Level { // Create planets around the sun const sunPosition = sun.position; const planets = createPlanetsOrbital( - 8, // 8 planets + 12, // 8 planets sunPosition, // sun position - 50, // min diameter - 100, // max diameter - 400, // min distance from sun - 1000 // max distance from sun + 100, // min diameter + 200, // max diameter + 1000, // min distance from sun + 2000 // max distance from sun ); console.log(`Created ${planets.length} planets around sun at position`, sunPosition); diff --git a/src/main.ts b/src/main.ts index 6be1f15..4dfe610 100644 --- a/src/main.ts +++ b/src/main.ts @@ -131,7 +131,7 @@ export class Main { } DefaultScene.DemoScene = 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.."); await this.setupPhysics(); @@ -169,8 +169,8 @@ export class Main { const havokPlugin = new HavokPlugin(true, havok); DefaultScene.MainScene.enablePhysics(new Vector3(0, 0, 0), havokPlugin); - DefaultScene.MainScene.getPhysicsEngine().setTimeStep(1/90); - DefaultScene.MainScene.getPhysicsEngine().setSubTimeStep(9); + DefaultScene.MainScene.getPhysicsEngine().setTimeStep(1/45); + DefaultScene.MainScene.getPhysicsEngine().setSubTimeStep(5); DefaultScene.MainScene.collisionsEnabled = true; } diff --git a/src/ship.ts b/src/ship.ts index 26211ff..d8c6ad3 100644 --- a/src/ship.ts +++ b/src/ship.ts @@ -8,7 +8,7 @@ import { Observable, PhysicsAggregate, PhysicsMotionType, - PhysicsShapeType, + PhysicsShapeType, PointLight, SceneLoader, SpotLight, StandardMaterial, @@ -145,7 +145,7 @@ export class Ship { this._ammoBaseMesh.material = this._ammoMaterial; 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); // landingLight.parent = this._ship; @@ -201,7 +201,15 @@ export class Ship { shipMesh.rotation.y = Math.PI; shipMesh.position.y = 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; } diff --git a/src/starfield.ts b/src/starfield.ts index 6dae1a0..d8a00fc 100644 --- a/src/starfield.ts +++ b/src/starfield.ts @@ -61,12 +61,17 @@ export class RockFactory { this._rockMaterial.id = 'asteroid-material'; const material = (this._rockMaterial as PBRMaterial) //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.emissiveColor = new Color3(1, 1, 1); this._rockMesh.material = this._rockMaterial; - importMesh.meshes[1].dispose(false, true); - importMesh.meshes[0].dispose(); + //importMesh.meshes[1].dispose(false, true); + //importMesh.meshes[0].dispose(); } } }