@directivegames/genesys.sdk 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -0
- package/dist/src/asset-pack/eslint.config.js +43 -0
- package/dist/src/asset-pack/scripts/postinstall.js +64 -0
- package/dist/src/asset-pack/src/index.js +1 -0
- package/dist/src/core/cli.js +306 -0
- package/dist/src/core/common.js +324 -0
- package/dist/src/core/index.js +6 -0
- package/dist/src/core/tools/build-project.js +450 -0
- package/dist/src/core/tools/index.js +2 -0
- package/dist/src/core/tools/new-asset-pack.js +150 -0
- package/dist/src/core/tools/new-project.js +292 -0
- package/dist/src/core/types.js +1 -0
- package/dist/src/dependencies.js +82 -0
- package/dist/src/electron/IpcSerializableError.js +38 -0
- package/dist/src/electron/api.js +7 -0
- package/dist/src/electron/backend/actions.js +56 -0
- package/dist/src/electron/backend/handler.js +441 -0
- package/dist/src/electron/backend/logging.js +41 -0
- package/dist/src/electron/backend/main.js +315 -0
- package/dist/src/electron/backend/menu.js +208 -0
- package/dist/src/electron/backend/state.js +201 -0
- package/dist/src/electron/backend/tools/const.js +9 -0
- package/dist/src/electron/backend/tools/file-server.js +383 -0
- package/dist/src/electron/backend/tools/open-project.js +261 -0
- package/dist/src/electron/backend/window.js +161 -0
- package/dist/src/templates/eslint.config.js +43 -0
- package/dist/src/templates/scripts/genesys/build-project.js +42 -0
- package/dist/src/templates/scripts/genesys/calc-bounding-box.js +205 -0
- package/dist/src/templates/scripts/genesys/common.js +36 -0
- package/dist/src/templates/scripts/genesys/const.js +9 -0
- package/dist/src/templates/scripts/genesys/dev/dump-default-scene.js +8 -0
- package/dist/src/templates/scripts/genesys/dev/generate-manifest.js +116 -0
- package/dist/src/templates/scripts/genesys/dev/launcher.js +39 -0
- package/dist/src/templates/scripts/genesys/dev/storage-provider.js +188 -0
- package/dist/src/templates/scripts/genesys/dev/update-template-scenes.js +67 -0
- package/dist/src/templates/scripts/genesys/doc-server.js +12 -0
- package/dist/src/templates/scripts/genesys/genesys-mcp.js +413 -0
- package/dist/src/templates/scripts/genesys/mcp/doc-tools.js +70 -0
- package/dist/src/templates/scripts/genesys/mcp/editor-functions.js +123 -0
- package/dist/src/templates/scripts/genesys/mcp/editor-tools.js +51 -0
- package/dist/src/templates/scripts/genesys/mcp/get-scene-state.js +26 -0
- package/dist/src/templates/scripts/genesys/mcp/run-subprocess.js +23 -0
- package/dist/src/templates/scripts/genesys/mcp/search-actors.js +703 -0
- package/dist/src/templates/scripts/genesys/mcp/search-assets.js +296 -0
- package/dist/src/templates/scripts/genesys/mcp/utils.js +234 -0
- package/dist/src/templates/scripts/genesys/misc.js +32 -0
- package/dist/src/templates/scripts/genesys/mock.js +5 -0
- package/dist/src/templates/scripts/genesys/place-actors.js +112 -0
- package/dist/src/templates/scripts/genesys/post-install.js +25 -0
- package/dist/src/templates/scripts/genesys/remove-engine-comments.js +113 -0
- package/dist/src/templates/scripts/genesys/storageProvider.js +146 -0
- package/dist/src/templates/scripts/genesys/validate-prefabs.js +115 -0
- package/dist/src/templates/src/index.js +20 -0
- package/dist/src/templates/src/templates/firstPerson/src/auto-imports.js +1 -0
- package/dist/src/templates/src/templates/firstPerson/src/game.js +30 -0
- package/dist/src/templates/src/templates/firstPerson/src/player.js +60 -0
- package/dist/src/templates/src/templates/fps/src/auto-imports.js +1 -0
- package/dist/src/templates/src/templates/fps/src/game.js +30 -0
- package/dist/src/templates/src/templates/fps/src/player.js +64 -0
- package/dist/src/templates/src/templates/fps/src/weapon.js +62 -0
- package/dist/src/templates/src/templates/freeCamera/src/auto-imports.js +1 -0
- package/dist/src/templates/src/templates/freeCamera/src/game.js +30 -0
- package/dist/src/templates/src/templates/freeCamera/src/player.js +43 -0
- package/dist/src/templates/src/templates/sideScroller/src/auto-imports.js +1 -0
- package/dist/src/templates/src/templates/sideScroller/src/const.js +43 -0
- package/dist/src/templates/src/templates/sideScroller/src/game.js +103 -0
- package/dist/src/templates/src/templates/sideScroller/src/level-generator.js +249 -0
- package/dist/src/templates/src/templates/sideScroller/src/player.js +105 -0
- package/dist/src/templates/src/templates/thirdPerson/src/auto-imports.js +1 -0
- package/dist/src/templates/src/templates/thirdPerson/src/game.js +30 -0
- package/dist/src/templates/src/templates/thirdPerson/src/player.js +63 -0
- package/dist/src/templates/src/templates/vehicle/src/auto-imports.js +1 -0
- package/dist/src/templates/src/templates/vehicle/src/base-vehicle.js +122 -0
- package/dist/src/templates/src/templates/vehicle/src/game.js +33 -0
- package/dist/src/templates/src/templates/vehicle/src/mesh-vehicle.js +189 -0
- package/dist/src/templates/src/templates/vehicle/src/player.js +102 -0
- package/dist/src/templates/src/templates/vehicle/src/primitive-vehicle.js +259 -0
- package/dist/src/templates/src/templates/vehicle/src/ui-hints.js +100 -0
- package/dist/src/templates/src/templates/vr-game/src/auto-imports.js +1 -0
- package/dist/src/templates/src/templates/vr-game/src/game.js +55 -0
- package/dist/src/templates/src/templates/vr-game/src/sample-vr-actor.js +29 -0
- package/dist/src/templates/vite.config.js +46 -0
- package/package.json +176 -0
- package/scripts/post-install.ts +143 -0
- package/src/asset-pack/.gitattributes +89 -0
- package/src/asset-pack/eslint.config.js +45 -0
- package/src/asset-pack/gitignore +11 -0
- package/src/asset-pack/scripts/postinstall.ts +81 -0
- package/src/asset-pack/src/index.ts +0 -0
- package/src/asset-pack/tsconfig.json +34 -0
- package/src/templates/.cursor/mcp.json +20 -0
- package/src/templates/.cursorignore +2 -0
- package/src/templates/.gitattributes +89 -0
- package/src/templates/.vscode/settings.json +6 -0
- package/src/templates/AGENTS.md +86 -0
- package/src/templates/CLAUDE.md +1 -0
- package/src/templates/README.md +24 -0
- package/src/templates/eslint.config.js +45 -0
- package/src/templates/gitignore +11 -0
- package/src/templates/index.html +34 -0
- package/src/templates/pnpm-lock.yaml +3676 -0
- package/src/templates/scripts/genesys/build-project.ts +51 -0
- package/src/templates/scripts/genesys/calc-bounding-box.ts +272 -0
- package/src/templates/scripts/genesys/common.ts +46 -0
- package/src/templates/scripts/genesys/const.ts +9 -0
- package/src/templates/scripts/genesys/dev/dump-default-scene.ts +11 -0
- package/src/templates/scripts/genesys/dev/generate-manifest.ts +146 -0
- package/src/templates/scripts/genesys/dev/launcher.ts +46 -0
- package/src/templates/scripts/genesys/dev/storage-provider.ts +229 -0
- package/src/templates/scripts/genesys/dev/update-template-scenes.ts +84 -0
- package/src/templates/scripts/genesys/doc-server.ts +16 -0
- package/src/templates/scripts/genesys/genesys-mcp.ts +526 -0
- package/src/templates/scripts/genesys/mcp/doc-tools.ts +86 -0
- package/src/templates/scripts/genesys/mcp/editor-functions.ts +151 -0
- package/src/templates/scripts/genesys/mcp/editor-tools.ts +73 -0
- package/src/templates/scripts/genesys/mcp/get-scene-state.ts +35 -0
- package/src/templates/scripts/genesys/mcp/run-subprocess.ts +30 -0
- package/src/templates/scripts/genesys/mcp/search-actors.ts +858 -0
- package/src/templates/scripts/genesys/mcp/search-assets.ts +380 -0
- package/src/templates/scripts/genesys/mcp/utils.ts +281 -0
- package/src/templates/scripts/genesys/misc.ts +42 -0
- package/src/templates/scripts/genesys/mock.ts +6 -0
- package/src/templates/scripts/genesys/place-actors.ts +179 -0
- package/src/templates/scripts/genesys/post-install.ts +30 -0
- package/src/templates/scripts/genesys/prefab.schema.json +85 -0
- package/src/templates/scripts/genesys/remove-engine-comments.ts +135 -0
- package/src/templates/scripts/genesys/run-mcp-inspector.bat +5 -0
- package/src/templates/scripts/genesys/storageProvider.ts +182 -0
- package/src/templates/scripts/genesys/validate-prefabs.ts +138 -0
- package/src/templates/src/index.ts +22 -0
- package/src/templates/src/templates/firstPerson/assets/default.genesys-scene +166 -0
- package/src/templates/src/templates/firstPerson/src/auto-imports.ts +0 -0
- package/src/templates/src/templates/firstPerson/src/game.ts +39 -0
- package/src/templates/src/templates/firstPerson/src/player.ts +63 -0
- package/src/templates/src/templates/fps/assets/default.genesys-scene +9460 -0
- package/src/templates/src/templates/fps/assets/models/SM_Beam_400.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_ChamferCube.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Floor_Thick_400x400.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Floor_Thick_400x400_Orange.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Floor_Thin_400x400.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Floor_Thin_400x400_Orange.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Ramp_400x400.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Rifle.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Wall_Thin_400x200.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Wall_Thin_400x200_Orange.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Wall_Thin_400x400.glb +0 -0
- package/src/templates/src/templates/fps/assets/models/SM_Wall_Thin_400x400_Orange.glb +0 -0
- package/src/templates/src/templates/fps/src/auto-imports.ts +0 -0
- package/src/templates/src/templates/fps/src/game.ts +39 -0
- package/src/templates/src/templates/fps/src/player.ts +69 -0
- package/src/templates/src/templates/fps/src/weapon.ts +54 -0
- package/src/templates/src/templates/freeCamera/assets/default.genesys-scene +166 -0
- package/src/templates/src/templates/freeCamera/src/auto-imports.ts +0 -0
- package/src/templates/src/templates/freeCamera/src/game.ts +39 -0
- package/src/templates/src/templates/freeCamera/src/player.ts +45 -0
- package/src/templates/src/templates/sideScroller/assets/default.genesys-scene +122 -0
- package/src/templates/src/templates/sideScroller/src/auto-imports.ts +0 -0
- package/src/templates/src/templates/sideScroller/src/const.ts +46 -0
- package/src/templates/src/templates/sideScroller/src/game.ts +122 -0
- package/src/templates/src/templates/sideScroller/src/level-generator.ts +361 -0
- package/src/templates/src/templates/sideScroller/src/player.ts +125 -0
- package/src/templates/src/templates/thirdPerson/assets/default.genesys-scene +166 -0
- package/src/templates/src/templates/thirdPerson/src/auto-imports.ts +0 -0
- package/src/templates/src/templates/thirdPerson/src/game.ts +39 -0
- package/src/templates/src/templates/thirdPerson/src/player.ts +61 -0
- package/src/templates/src/templates/vehicle/assets/default.genesys-scene +226 -0
- package/src/templates/src/templates/vehicle/assets/models/cyberTruck/chassis.glb +0 -0
- package/src/templates/src/templates/vehicle/assets/models/cyberTruck/wheel.glb +0 -0
- package/src/templates/src/templates/vehicle/src/auto-imports.ts +0 -0
- package/src/templates/src/templates/vehicle/src/base-vehicle.ts +145 -0
- package/src/templates/src/templates/vehicle/src/game.ts +43 -0
- package/src/templates/src/templates/vehicle/src/mesh-vehicle.ts +191 -0
- package/src/templates/src/templates/vehicle/src/player.ts +109 -0
- package/src/templates/src/templates/vehicle/src/primitive-vehicle.ts +266 -0
- package/src/templates/src/templates/vehicle/src/ui-hints.ts +101 -0
- package/src/templates/src/templates/vr-game/assets/default.genesys-scene +247 -0
- package/src/templates/src/templates/vr-game/src/auto-imports.ts +1 -0
- package/src/templates/src/templates/vr-game/src/game.ts +66 -0
- package/src/templates/src/templates/vr-game/src/sample-vr-actor.ts +26 -0
- package/src/templates/tsconfig.json +35 -0
- package/src/templates/vite.config.ts +52 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
import { FPSPlayer } from './player.js';
|
|
5
|
+
|
|
6
|
+
import './auto-imports.js';
|
|
7
|
+
|
|
8
|
+
class MyGame extends ENGINE.BaseGameLoop {
|
|
9
|
+
private pawn: FPSPlayer | null = null;
|
|
10
|
+
private controller: ENGINE.PlayerController | null = null;
|
|
11
|
+
|
|
12
|
+
protected override createLoadingScreen(): ENGINE.ILoadingScreen | null {
|
|
13
|
+
// enable the default loading screen
|
|
14
|
+
return new ENGINE.DefaultLoadingScreen();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected override async preStart(): Promise<void> {
|
|
18
|
+
// default spawn location
|
|
19
|
+
const position = new THREE.Vector3(0, ENGINE.CHARACTER_HEIGHT / 2, 0);
|
|
20
|
+
|
|
21
|
+
// now create the pawn
|
|
22
|
+
this.pawn = new FPSPlayer({ position });
|
|
23
|
+
|
|
24
|
+
// create the controller and possess the pawn
|
|
25
|
+
this.controller = new ENGINE.PlayerController();
|
|
26
|
+
this.controller.possess(this.pawn);
|
|
27
|
+
|
|
28
|
+
// add both to the world
|
|
29
|
+
this.world.addActors(this.pawn, this.controller);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function main(container: HTMLElement, gameId: string): ENGINE.IGameLoop {
|
|
34
|
+
const game = new MyGame(container, {
|
|
35
|
+
...ENGINE.BaseGameLoop.DEFAULT_OPTIONS,
|
|
36
|
+
gameId
|
|
37
|
+
});
|
|
38
|
+
return game;
|
|
39
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
import { DefaultWeapon } from './weapon.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for the FPSPlayer class.
|
|
8
|
+
* Currently empty, can be extended if needed.
|
|
9
|
+
*/
|
|
10
|
+
export interface FPSPlayerOptions extends ENGINE.PawnOptions {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A FPS player class.
|
|
15
|
+
*
|
|
16
|
+
* Key points:
|
|
17
|
+
* - No need to provide rootComponent, movementComponent and camera, they are created internally
|
|
18
|
+
* - The pawn is set to be transient so it's never saved in the level
|
|
19
|
+
* - The directional light follows the player for consistent shadows
|
|
20
|
+
* - The weapon is created and attached to the camera
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
@ENGINE.GameClass()
|
|
24
|
+
export class FPSPlayer extends ENGINE.Pawn<FPSPlayerOptions> {
|
|
25
|
+
// No need to provide rootComponent, movementComponent and camera, they are created internally
|
|
26
|
+
constructor(options: Omit<FPSPlayerOptions, 'rootComponent' | 'movementComponent' | 'camera'>) {
|
|
27
|
+
// simple camera component - contains a perspective camera by default
|
|
28
|
+
const camera = new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, ENGINE.CAMERA_NEAR, ENGINE.CAMERA_FAR);
|
|
29
|
+
// set proper camera height for first person view
|
|
30
|
+
camera.position.set(0, ENGINE.CHARACTER_HEIGHT * 0.4, 0);
|
|
31
|
+
|
|
32
|
+
// create the weapon and attach it to the camera
|
|
33
|
+
const weapon = new DefaultWeapon();
|
|
34
|
+
camera.add(weapon);
|
|
35
|
+
|
|
36
|
+
// use a simple capsule geometry as the root component
|
|
37
|
+
const rootComponent = new ENGINE.MeshComponent({
|
|
38
|
+
geometry: ENGINE.GameBuilder.createDefaultPawnCapsuleGeometry(),
|
|
39
|
+
material: new THREE.MeshStandardMaterial({ color: ENGINE.Color.YELLOW }),
|
|
40
|
+
physicsOptions: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
// KinematicVelocityBased is required to use the physics character controller
|
|
43
|
+
motionType: ENGINE.PhysicsMotionType.KinematicVelocityBased,
|
|
44
|
+
collisionProfile: ENGINE.DefaultCollisionProfile.Pawn,
|
|
45
|
+
generateCollisionEvents: true,
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
// hide the mesh in first person view
|
|
49
|
+
rootComponent.getMesh().visible = false;
|
|
50
|
+
|
|
51
|
+
// create the movement component
|
|
52
|
+
const movementComponent = new ENGINE.CharacterMovementComponent({
|
|
53
|
+
...ENGINE.CharacterMovementComponent.DEFAULT_OPTIONS,
|
|
54
|
+
movementType: ENGINE.CharacterMovementType.FirstPerson,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
super({
|
|
58
|
+
...options,
|
|
59
|
+
rootComponent,
|
|
60
|
+
movementComponent,
|
|
61
|
+
// make sure the directional light follows the player for consistent shadows
|
|
62
|
+
enableDirectionalLightFollowing: true,
|
|
63
|
+
camera
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// set the pawn to be transient so it's never saved in the level
|
|
67
|
+
this.setTransient(true);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A default weapon class.
|
|
6
|
+
*
|
|
7
|
+
* Key points:
|
|
8
|
+
* - Inherits from the ProjectileWeaponComponent class
|
|
9
|
+
* - All the weapon options are configured in the constructor so no need to configure by the user
|
|
10
|
+
*/
|
|
11
|
+
@ENGINE.GameClass()
|
|
12
|
+
export class DefaultWeapon extends ENGINE.ProjectileWeaponComponent {
|
|
13
|
+
constructor() {
|
|
14
|
+
super({
|
|
15
|
+
// firing params
|
|
16
|
+
fireInterval: 0.1,
|
|
17
|
+
isSingleFire: false,
|
|
18
|
+
// configure the weapon model
|
|
19
|
+
modelPath: '@project/assets/models/SM_Rifle.glb',
|
|
20
|
+
modelTransform: {
|
|
21
|
+
position: new THREE.Vector3(0.1, -0.1, -0.25),
|
|
22
|
+
rotation: new THREE.Euler(0, THREE.MathUtils.degToRad(-90), 0),
|
|
23
|
+
},
|
|
24
|
+
// tweak the projectile spawn offset so it matches the muzzle position
|
|
25
|
+
projectileSpawnOffset: new THREE.Vector3(0.8, -0.6, -2),
|
|
26
|
+
// add a crosshair
|
|
27
|
+
crosshairOptions: {
|
|
28
|
+
size: 10,
|
|
29
|
+
color: 'white',
|
|
30
|
+
style: 'dot'
|
|
31
|
+
},
|
|
32
|
+
// add weapon sounds
|
|
33
|
+
fireSoundUrl: '@engine/assets/sounds/game-gun-short.mp3',
|
|
34
|
+
// enable recoil
|
|
35
|
+
recoilOptions: {
|
|
36
|
+
weaponRecoilDistance: 0.05,
|
|
37
|
+
weaponRecoilDuration: 0.05,
|
|
38
|
+
weaponRecoilRotation: 0,
|
|
39
|
+
},
|
|
40
|
+
// configure the projectile
|
|
41
|
+
projectileOptions: {
|
|
42
|
+
velocity: 100,
|
|
43
|
+
range: 500,
|
|
44
|
+
lifeSpan: 3,
|
|
45
|
+
useOverlapCheck: false,
|
|
46
|
+
destroyOnHit: false,
|
|
47
|
+
gravityScale: 0,
|
|
48
|
+
geometry: new THREE.SphereGeometry(0.1),
|
|
49
|
+
material: new THREE.MeshStandardMaterial({ color: ENGINE.Color.YELLOW })
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.setTransient(true);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$version": 0,
|
|
3
|
+
"class": "ENGINE.World",
|
|
4
|
+
"uuid": "c0ae85792bc3b946",
|
|
5
|
+
"ctor": {
|
|
6
|
+
"backgroundColor": 3026478,
|
|
7
|
+
"navigationOptions": {
|
|
8
|
+
"engine": "recast-navigation",
|
|
9
|
+
"debug": false,
|
|
10
|
+
"generateOnStartUp": false
|
|
11
|
+
},
|
|
12
|
+
"physicsOptions": {
|
|
13
|
+
"gravity": [
|
|
14
|
+
0,
|
|
15
|
+
-9.81,
|
|
16
|
+
0,
|
|
17
|
+
"v"
|
|
18
|
+
],
|
|
19
|
+
"engine": "rapier"
|
|
20
|
+
},
|
|
21
|
+
"useManifold": true
|
|
22
|
+
},
|
|
23
|
+
"actors": [
|
|
24
|
+
{
|
|
25
|
+
"uuid": "9a86d389088b361c",
|
|
26
|
+
"class": "ENGINE.Actor",
|
|
27
|
+
"properties": {
|
|
28
|
+
"editorData": {
|
|
29
|
+
"displayName": "Directional Light",
|
|
30
|
+
"hidden": false
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"ctor": {
|
|
34
|
+
"rootComponent": {
|
|
35
|
+
"class": "ENGINE.DirectionalLightComponent",
|
|
36
|
+
"uuid": "cfe05433-9edc-4dfe-a535-c71f33e92d78",
|
|
37
|
+
"ctor": {
|
|
38
|
+
"color": 16777215,
|
|
39
|
+
"intensity": 1,
|
|
40
|
+
"castShadow": true,
|
|
41
|
+
"shadowMapSize": 2048,
|
|
42
|
+
"shadowBias": 0,
|
|
43
|
+
"shadowNormalBias": 0,
|
|
44
|
+
"shadowNear": 0.1,
|
|
45
|
+
"shadowFar": 100
|
|
46
|
+
},
|
|
47
|
+
"properties": {
|
|
48
|
+
"position": [
|
|
49
|
+
10,
|
|
50
|
+
50,
|
|
51
|
+
-10,
|
|
52
|
+
"v"
|
|
53
|
+
],
|
|
54
|
+
"castShadow": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"uuid": "9d428f2a16e5374a",
|
|
61
|
+
"class": "ENGINE.Actor",
|
|
62
|
+
"properties": {
|
|
63
|
+
"editorData": {
|
|
64
|
+
"displayName": "Ground",
|
|
65
|
+
"hidden": false
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"ctor": {
|
|
69
|
+
"rootComponent": {
|
|
70
|
+
"class": "ENGINE.MeshComponent",
|
|
71
|
+
"uuid": "71caea24-62d7-4e45-a76e-4c7519de2c3c",
|
|
72
|
+
"ctor": {
|
|
73
|
+
"geometry": {
|
|
74
|
+
"class": "THREE.BoxGeometry",
|
|
75
|
+
"ctor": [
|
|
76
|
+
500,
|
|
77
|
+
0.1,
|
|
78
|
+
500
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"material": {
|
|
82
|
+
"@external": "DefaultMaterial"
|
|
83
|
+
},
|
|
84
|
+
"uvScaleTilesPerUnit": 0.2,
|
|
85
|
+
"physicsOptions": {
|
|
86
|
+
"enabled": true,
|
|
87
|
+
"motionType": "static",
|
|
88
|
+
"collisionProfile": "BlockAll"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"properties": {
|
|
92
|
+
"position": [
|
|
93
|
+
0,
|
|
94
|
+
-0.9,
|
|
95
|
+
0,
|
|
96
|
+
"v"
|
|
97
|
+
],
|
|
98
|
+
"receiveShadow": true
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"uuid": "b87cbc5e60a2e54c",
|
|
105
|
+
"class": "ENGINE.PlayerStart",
|
|
106
|
+
"properties": {
|
|
107
|
+
"editorData": {
|
|
108
|
+
"displayName": "Player Start",
|
|
109
|
+
"hidden": false
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"ctor": {
|
|
113
|
+
"rootComponent": {
|
|
114
|
+
"class": "ENGINE.SceneComponent",
|
|
115
|
+
"uuid": "b4d5f8f7-2512-45e1-9157-c7ff6772402d",
|
|
116
|
+
"ctor": {},
|
|
117
|
+
"properties": {
|
|
118
|
+
"position": [
|
|
119
|
+
0,
|
|
120
|
+
0.9,
|
|
121
|
+
0,
|
|
122
|
+
"v"
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"uuid": "0ba1f4677e8370d1",
|
|
130
|
+
"class": "ENGINE.Actor",
|
|
131
|
+
"properties": {
|
|
132
|
+
"editorData": {
|
|
133
|
+
"displayName": "Skybox",
|
|
134
|
+
"hidden": false
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"ctor": {
|
|
138
|
+
"rootComponent": {
|
|
139
|
+
"class": "ENGINE.SceneComponent",
|
|
140
|
+
"uuid": "195e88df-73ff-4f4b-82ae-7fb58671463d",
|
|
141
|
+
"ctor": {},
|
|
142
|
+
"properties": {},
|
|
143
|
+
"children": [
|
|
144
|
+
{
|
|
145
|
+
"class": "ENGINE.SkyboxComponent",
|
|
146
|
+
"uuid": "f7e33ae7d5ac74f9",
|
|
147
|
+
"ctor": {
|
|
148
|
+
"textureUrl": "@engine/assets/textures/skybox/citrus_orchard_road_puresky_2k.hdr",
|
|
149
|
+
"width": 2048,
|
|
150
|
+
"height": 1024,
|
|
151
|
+
"bottomColor": "#E6F3FF",
|
|
152
|
+
"middleColor": "#4A90E2",
|
|
153
|
+
"topColor": "#0F1B3C",
|
|
154
|
+
"envMapIntensity": 1
|
|
155
|
+
},
|
|
156
|
+
"properties": {}
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"properties": {
|
|
164
|
+
"editorData": {}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
import * as ENGINE from 'genesys.js';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
|
|
5
|
+
import { FreeCameraPlayer } from './player.js';
|
|
6
|
+
import './auto-imports.js';
|
|
7
|
+
|
|
8
|
+
class MyGame extends ENGINE.BaseGameLoop {
|
|
9
|
+
private pawn: FreeCameraPlayer | null = null;
|
|
10
|
+
private controller: ENGINE.PlayerController | null = null;
|
|
11
|
+
|
|
12
|
+
protected override createLoadingScreen(): ENGINE.ILoadingScreen | null {
|
|
13
|
+
// enable the default loading screen
|
|
14
|
+
return new ENGINE.DefaultLoadingScreen();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected override async preStart(): Promise<void> {
|
|
18
|
+
// default spawn location
|
|
19
|
+
const position = new THREE.Vector3(0, ENGINE.CHARACTER_HEIGHT, 0);
|
|
20
|
+
|
|
21
|
+
// create the pawn with simple movement mechanics
|
|
22
|
+
this.pawn = new FreeCameraPlayer({ position });
|
|
23
|
+
|
|
24
|
+
// create the controller and possess the pawn
|
|
25
|
+
this.controller = new ENGINE.PlayerController();
|
|
26
|
+
this.controller.possess(this.pawn);
|
|
27
|
+
|
|
28
|
+
// add both to the world
|
|
29
|
+
this.world.addActors(this.pawn, this.controller);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function main(container: HTMLElement, gameId: string): ENGINE.IGameLoop {
|
|
34
|
+
const game = new MyGame(container, {
|
|
35
|
+
...ENGINE.BaseGameLoop.DEFAULT_OPTIONS,
|
|
36
|
+
gameId
|
|
37
|
+
});
|
|
38
|
+
return game;
|
|
39
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for the FreeCameraPlayer class.
|
|
7
|
+
* Currently empty, can be extended if needed.
|
|
8
|
+
*/
|
|
9
|
+
export interface FreeCameraPlayerOptions extends ENGINE.PawnOptions {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A free camera player class.
|
|
14
|
+
*
|
|
15
|
+
* Key points:
|
|
16
|
+
* - No need to provide movementComponent and camera, they are created internally
|
|
17
|
+
* - The pawn is set to be transient so it's never saved in the level
|
|
18
|
+
* - The directional light follows the player for consistent shadows
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
@ENGINE.GameClass()
|
|
22
|
+
export class FreeCameraPlayer extends ENGINE.Pawn<FreeCameraPlayerOptions> {
|
|
23
|
+
constructor(options: Omit<FreeCameraPlayerOptions, 'camera' | 'movementComponent'>) {
|
|
24
|
+
// simple perspective camera
|
|
25
|
+
const camera = new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, ENGINE.CAMERA_NEAR, ENGINE.CAMERA_FAR);
|
|
26
|
+
// simple movement component, do not use the character controller
|
|
27
|
+
const movementComponent = new ENGINE.CharacterMovementComponent({
|
|
28
|
+
...ENGINE.CharacterMovementComponent.DEFAULT_OPTIONS,
|
|
29
|
+
// disable the character controller
|
|
30
|
+
characterControllerOptions: null,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// construct the pawn
|
|
34
|
+
super({
|
|
35
|
+
...options,
|
|
36
|
+
camera,
|
|
37
|
+
movementComponent,
|
|
38
|
+
// make sure the directional light follows the player for consistent shadows
|
|
39
|
+
enableDirectionalLightFollowing: true,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// set the pawn to be transient so it's never saved in the level
|
|
43
|
+
this.setTransient(true);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$version": 0,
|
|
3
|
+
"class": "ENGINE.World",
|
|
4
|
+
"uuid": "c0ae85792bc3b946",
|
|
5
|
+
"ctor": {
|
|
6
|
+
"backgroundColor": 3026478,
|
|
7
|
+
"navigationOptions": {
|
|
8
|
+
"engine": "recast-navigation",
|
|
9
|
+
"debug": false,
|
|
10
|
+
"generateOnStartUp": false
|
|
11
|
+
},
|
|
12
|
+
"physicsOptions": {
|
|
13
|
+
"gravity": [
|
|
14
|
+
0,
|
|
15
|
+
-9.81,
|
|
16
|
+
0,
|
|
17
|
+
"v"
|
|
18
|
+
],
|
|
19
|
+
"engine": "rapier"
|
|
20
|
+
},
|
|
21
|
+
"useManifold": true
|
|
22
|
+
},
|
|
23
|
+
"actors": [
|
|
24
|
+
{
|
|
25
|
+
"uuid": "9a86d389088b361c",
|
|
26
|
+
"class": "ENGINE.Actor",
|
|
27
|
+
"properties": {
|
|
28
|
+
"editorData": {
|
|
29
|
+
"displayName": "Directional Light",
|
|
30
|
+
"hidden": false
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"ctor": {
|
|
34
|
+
"rootComponent": {
|
|
35
|
+
"class": "ENGINE.DirectionalLightComponent",
|
|
36
|
+
"uuid": "cfe05433-9edc-4dfe-a535-c71f33e92d78",
|
|
37
|
+
"ctor": {
|
|
38
|
+
"color": 16777215,
|
|
39
|
+
"intensity": 1,
|
|
40
|
+
"castShadow": true,
|
|
41
|
+
"shadowMapSize": 2048,
|
|
42
|
+
"shadowBias": 0,
|
|
43
|
+
"shadowNormalBias": 0,
|
|
44
|
+
"shadowNear": 0.1,
|
|
45
|
+
"shadowFar": 100
|
|
46
|
+
},
|
|
47
|
+
"properties": {
|
|
48
|
+
"position": [
|
|
49
|
+
10,
|
|
50
|
+
50,
|
|
51
|
+
-10,
|
|
52
|
+
"v"
|
|
53
|
+
],
|
|
54
|
+
"castShadow": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"uuid": "b87cbc5e60a2e54c",
|
|
61
|
+
"class": "ENGINE.PlayerStart",
|
|
62
|
+
"properties": {
|
|
63
|
+
"editorData": {
|
|
64
|
+
"displayName": "Player Start",
|
|
65
|
+
"hidden": false
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"ctor": {
|
|
69
|
+
"rootComponent": {
|
|
70
|
+
"class": "ENGINE.SceneComponent",
|
|
71
|
+
"uuid": "b4d5f8f7-2512-45e1-9157-c7ff6772402d",
|
|
72
|
+
"ctor": {},
|
|
73
|
+
"properties": {
|
|
74
|
+
"position": [
|
|
75
|
+
0,
|
|
76
|
+
0.9,
|
|
77
|
+
0,
|
|
78
|
+
"v"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"uuid": "0ba1f4677e8370d1",
|
|
86
|
+
"class": "ENGINE.Actor",
|
|
87
|
+
"properties": {
|
|
88
|
+
"editorData": {
|
|
89
|
+
"displayName": "Skybox",
|
|
90
|
+
"hidden": false
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"ctor": {
|
|
94
|
+
"rootComponent": {
|
|
95
|
+
"class": "ENGINE.SceneComponent",
|
|
96
|
+
"uuid": "195e88df-73ff-4f4b-82ae-7fb58671463d",
|
|
97
|
+
"ctor": {},
|
|
98
|
+
"properties": {},
|
|
99
|
+
"children": [
|
|
100
|
+
{
|
|
101
|
+
"class": "ENGINE.SkyboxComponent",
|
|
102
|
+
"uuid": "f7e33ae7d5ac74f9",
|
|
103
|
+
"ctor": {
|
|
104
|
+
"textureUrl": "@engine/assets/textures/skybox/citrus_orchard_road_puresky_2k.hdr",
|
|
105
|
+
"width": 2048,
|
|
106
|
+
"height": 1024,
|
|
107
|
+
"bottomColor": "#E6F3FF",
|
|
108
|
+
"middleColor": "#4A90E2",
|
|
109
|
+
"topColor": "#0F1B3C",
|
|
110
|
+
"envMapIntensity": 1
|
|
111
|
+
},
|
|
112
|
+
"properties": {}
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"properties": {
|
|
120
|
+
"editorData": {}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Player Movement Configuration
|
|
2
|
+
export const PLAYER_MOVEMENT = {
|
|
3
|
+
JUMP_SPEED: 20,
|
|
4
|
+
MAX_SPEED: 8,
|
|
5
|
+
MAX_MID_AIR_JUMPS: 1,
|
|
6
|
+
ACCELERATION_LAMBDA: 15,
|
|
7
|
+
DECELERATION_LAMBDA: 10,
|
|
8
|
+
MID_AIR_ACCELERATION_LAMBDA: 8,
|
|
9
|
+
MID_AIR_DECELERATION_LAMBDA: 2,
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
// Camera Settings
|
|
13
|
+
export const CAMERA_SETTINGS = {
|
|
14
|
+
FOV: 60,
|
|
15
|
+
NEAR: 0.1,
|
|
16
|
+
FAR: 1000,
|
|
17
|
+
DAMP_FACTOR: 10,
|
|
18
|
+
POSITION: { x: 0, y: 1, z: 8 },
|
|
19
|
+
LOOK_AT: { x: 0, y: 0, z: 0 },
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
// Level Generation Configuration
|
|
23
|
+
export const LEVEL_CONFIG = {
|
|
24
|
+
DEPTH: 3,
|
|
25
|
+
CHUNK_SIZE: 50,
|
|
26
|
+
CHUNKS_AHEAD: 2,
|
|
27
|
+
CHUNKS_BEHIND: 2,
|
|
28
|
+
PLATFORM_HEIGHT_RANGE: { min: 1, max: 2 },
|
|
29
|
+
PLATFORM_WIDTH_RANGE: { min: 3, max: 6 },
|
|
30
|
+
OBSTACLE_HEIGHT_RANGE: { min: 3, max: 6 },
|
|
31
|
+
OBSTACLE_WIDTH_RANGE: { min: 1.5, max: 3.0 },
|
|
32
|
+
CHUNK_MARGIN: 0,
|
|
33
|
+
MIN_SPACING: 4,
|
|
34
|
+
DEBUG_VISUALIZATION_HEIGHT: 6,
|
|
35
|
+
DEBUG_VISUALIZATION_OPACITY: 0.3,
|
|
36
|
+
DEBUG_VISUALIZATION_COLOR: 0x00ff00,
|
|
37
|
+
GROUND_HEIGHT: 0.1,
|
|
38
|
+
GROUND_Y_POSITION: -0.05,
|
|
39
|
+
} as const;
|
|
40
|
+
|
|
41
|
+
// Material colors
|
|
42
|
+
export const COLORS = {
|
|
43
|
+
PLATFORM: 0x90ee90, // Light green
|
|
44
|
+
OBSTACLE: 0xff4444, // Red
|
|
45
|
+
GROUND: 0x8b4513, // Brown
|
|
46
|
+
} as const;
|