Add level configuration system and update base station model
All checks were successful
Build / build (push) Successful in 1m26s
All checks were successful
Build / build (push) Successful in 1m26s
- Add level 1 JSON with 4 asteroids and difficulty config - Add mission directory with recruit and fuel management missions - Update base.glb model for space station - Clean up unused helper functions in planetTextures.ts - Refactor starBase.ts position handling to use container root node 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8275c53fe4
commit
500830779d
Binary file not shown.
@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"difficulty": "rookie",
|
||||||
|
"timestamp": "2025-11-11T02:25:59.322Z",
|
||||||
|
"metadata": {
|
||||||
|
"author": "System",
|
||||||
|
"description": "Simple rookie training mission with 4 asteroids",
|
||||||
|
"type": "default"
|
||||||
|
},
|
||||||
|
"ship": {
|
||||||
|
"position": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"rotation": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"linearVelocity": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"angularVelocity": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"startBase": {
|
||||||
|
"position": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"baseGlbPath": "base.glb"
|
||||||
|
},
|
||||||
|
"sun": {
|
||||||
|
"position": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
400
|
||||||
|
],
|
||||||
|
"diameter": 50,
|
||||||
|
"intensity": 1000000
|
||||||
|
},
|
||||||
|
"planets": [],
|
||||||
|
"asteroids": [
|
||||||
|
{
|
||||||
|
"id": "asteroid-0",
|
||||||
|
"position": [
|
||||||
|
156.94085572623237,
|
||||||
|
7.655071329886562,
|
||||||
|
26.95900640691752
|
||||||
|
],
|
||||||
|
"scale": 4.970871148942566,
|
||||||
|
"linearVelocity": [
|
||||||
|
-11.853991319276782,
|
||||||
|
3.832852411651826,
|
||||||
|
39.00757072935994
|
||||||
|
],
|
||||||
|
"angularVelocity": [
|
||||||
|
-0.42551652358142866,
|
||||||
|
0.5493799332739933,
|
||||||
|
0.30167035132714326
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "asteroid-1",
|
||||||
|
"position": [
|
||||||
|
-23.650269493086213,
|
||||||
|
-7.516649878848993,
|
||||||
|
126.5433266370971
|
||||||
|
],
|
||||||
|
"scale": 4.200577184263548,
|
||||||
|
"linearVelocity": [
|
||||||
|
20.279713396596243,
|
||||||
|
-4.196597143111225,
|
||||||
|
-5.659116138590411
|
||||||
|
],
|
||||||
|
"angularVelocity": [
|
||||||
|
-0.7507666173804273,
|
||||||
|
0.18034984299295997,
|
||||||
|
0.9554422970140839
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "asteroid-2",
|
||||||
|
"position": [
|
||||||
|
-100.57744425293752,
|
||||||
|
-4.133377903929796,
|
||||||
|
-21.366880742332224
|
||||||
|
],
|
||||||
|
"scale": 3.965322849843854,
|
||||||
|
"linearVelocity": [
|
||||||
|
18.06997453473912,
|
||||||
|
3.1358603251655124,
|
||||||
|
-35.05836103718289
|
||||||
|
],
|
||||||
|
"angularVelocity": [
|
||||||
|
-0.6169324864147161,
|
||||||
|
-0.8284153049401051,
|
||||||
|
-0.0018035515865439944
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "asteroid-3",
|
||||||
|
"position": [
|
||||||
|
45.300201764673865,
|
||||||
|
-9.859323425039708,
|
||||||
|
-193.22872370344348
|
||||||
|
],
|
||||||
|
"scale": 4.373890659454386,
|
||||||
|
"linearVelocity": [
|
||||||
|
91.37841304510303,
|
||||||
|
-1.6739562491455018,
|
||||||
|
21.422594263117336
|
||||||
|
],
|
||||||
|
"angularVelocity": [
|
||||||
|
0.39048273397569644,
|
||||||
|
0.8814713796198581,
|
||||||
|
-0.972535786522579
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"difficultyConfig": {
|
||||||
|
"rockCount": 4,
|
||||||
|
"forceMultiplier": 1,
|
||||||
|
"rockSizeMin": 3,
|
||||||
|
"rockSizeMax": 5,
|
||||||
|
"distanceMin": 100,
|
||||||
|
"distanceMax": 200
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
{"missions": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Recruit",
|
||||||
|
"Description": "Simple level to get the hang of things",
|
||||||
|
"missionbrief": [
|
||||||
|
"Destroy the asteroids",
|
||||||
|
"return to base after they're destroyed to complete the mission",
|
||||||
|
"return to base if you need more fuel, ammo, or hull repairs",
|
||||||
|
"don't get too far from base, if you run out of fuel, you'll be stranded",
|
||||||
|
"don't run into things, it damages your hull"
|
||||||
|
],
|
||||||
|
"leveldata": "/levels/1.json",
|
||||||
|
"defaultlocked": false
|
||||||
|
} ,
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "Fuel Management",
|
||||||
|
"Description": "Don't run out of fuel",
|
||||||
|
"missionbrief": [
|
||||||
|
"Astroids are further away and there a more of them",
|
||||||
|
"you'll need to keep an eye on your fuel levels",
|
||||||
|
"return to base after you've destroyed them all"
|
||||||
|
],
|
||||||
|
"leveldata": null,
|
||||||
|
"defaultlocked": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
@ -214,12 +214,4 @@ export const PLANET_TEXTURES_BY_TYPE = {
|
|||||||
"/assets/materials/planetTextures/Tundra/Tundra_04-512x512.png",
|
"/assets/materials/planetTextures/Tundra/Tundra_04-512x512.png",
|
||||||
"/assets/materials/planetTextures/Tundra/Tundral-EQUIRECTANGULAR-5-512x512.png",
|
"/assets/materials/planetTextures/Tundra/Tundral-EQUIRECTANGULAR-5-512x512.png",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a random texture from a specific planet type
|
|
||||||
*/
|
|
||||||
export function getRandomTextureByType(type: keyof typeof PLANET_TEXTURES_BY_TYPE): string {
|
|
||||||
const textures = PLANET_TEXTURES_BY_TYPE[type];
|
|
||||||
return textures[Math.floor(Math.random() * textures.length)];
|
|
||||||
}
|
|
||||||
@ -1,9 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
AbstractMesh,
|
AbstractMesh,
|
||||||
HavokPlugin, Mesh,
|
|
||||||
PhysicsAggregate,
|
PhysicsAggregate,
|
||||||
PhysicsMotionType,
|
PhysicsMotionType,
|
||||||
PhysicsShapeType,
|
PhysicsShapeType, TransformNode,
|
||||||
Vector3
|
Vector3
|
||||||
} from "@babylonjs/core";
|
} from "@babylonjs/core";
|
||||||
import {DefaultScene} from "../../core/defaultScene";
|
import {DefaultScene} from "../../core/defaultScene";
|
||||||
@ -39,9 +38,8 @@ export default class StarBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply position to both meshes (defaults to [0, 0, 0])
|
// Apply position to both meshes (defaults to [0, 0, 0])
|
||||||
const pos = position ? new Vector3(position[0], position[1], position[2]) : new Vector3(0, 0, 0);
|
(importMeshes.container.rootNodes[0] as TransformNode).position
|
||||||
baseMesh.position = pos.clone();
|
= position ? new Vector3(position[0], position[1], position[2]) : new Vector3(0, 0, 0);
|
||||||
landingMesh.position = pos.clone();
|
|
||||||
|
|
||||||
let landingAgg: PhysicsAggregate | null = null;
|
let landingAgg: PhysicsAggregate | null = null;
|
||||||
|
|
||||||
@ -57,14 +55,7 @@ export default class StarBase {
|
|||||||
|
|
||||||
landingAgg = new PhysicsAggregate(landingMesh, PhysicsShapeType.MESH);
|
landingAgg = new PhysicsAggregate(landingMesh, PhysicsShapeType.MESH);
|
||||||
landingAgg.body.setMotionType(PhysicsMotionType.ANIMATED);
|
landingAgg.body.setMotionType(PhysicsMotionType.ANIMATED);
|
||||||
/*landingAgg.body.getCollisionObservable().add((collidedCollidedBody) => {
|
|
||||||
|
|
||||||
});*/
|
|
||||||
landingAgg.shape.isTrigger = true;
|
landingAgg.shape.isTrigger = true;
|
||||||
/*(DefaultScene.MainScene.getPhysicsEngine().getPhysicsPlugin() as HavokPlugin).onTriggerCollisionObservable.add((eventdata, eventState) => {
|
|
||||||
console.log(eventState);
|
|
||||||
console.log(eventdata);
|
|
||||||
})*/
|
|
||||||
landingAgg.body.setCollisionCallbackEnabled(true);
|
landingAgg.body.setCollisionCallbackEnabled(true);
|
||||||
}
|
}
|
||||||
//importMesh.rootNodes[0].dispose();
|
//importMesh.rootNodes[0].dispose();
|
||||||
@ -73,14 +64,4 @@ export default class StarBase {
|
|||||||
landingAggregate: landingAgg
|
landingAggregate: landingAgg
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function clearParent (meshes: Map<string, AbstractMesh>, position?: Vector3) {
|
|
||||||
meshes.forEach((mesh) => {
|
|
||||||
mesh.setParent(null);
|
|
||||||
if (position) {
|
|
||||||
mesh.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
DefaultScene.MainScene.addMesh(mesh);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user