@directivegames/genesys.sdk 3.2.2 → 3.2.5

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.
Files changed (125) hide show
  1. package/README.md +60 -60
  2. package/dist/src/asset-pack/eslint.config.js +4 -4
  3. package/dist/src/core/cli.js +22 -22
  4. package/dist/src/core/common.js +2 -2
  5. package/dist/src/core/tools/build-project.js +1 -1
  6. package/dist/src/core/tools/new-asset-pack.js +1 -1
  7. package/dist/src/core/tools/new-project.js +1 -1
  8. package/dist/src/dependencies.js +1 -1
  9. package/dist/src/electron/backend/tools/const.js +1 -1
  10. package/dist/src/electron/backend/tools/open-project.js +1 -1
  11. package/dist/src/templates/eslint.config.js +4 -4
  12. package/dist/src/templates/scripts/genesys/calc-bounding-box.js +2 -2
  13. package/dist/src/templates/scripts/genesys/dev/dump-default-scene.js +1 -1
  14. package/dist/src/templates/scripts/genesys/dev/generate-manifest.js +1 -1
  15. package/dist/src/templates/scripts/genesys/dev/launcher.js +1 -1
  16. package/dist/src/templates/scripts/genesys/dev/storage-provider.js +4 -4
  17. package/dist/src/templates/scripts/genesys/genesys-mcp.js +26 -26
  18. package/dist/src/templates/scripts/genesys/mcp/doc-tools.js +2 -2
  19. package/dist/src/templates/scripts/genesys/mcp/editor-functions.js +5 -5
  20. package/dist/src/templates/scripts/genesys/mcp/search-actors.js +1 -1
  21. package/dist/src/templates/scripts/genesys/mcp/search-assets.js +1 -1
  22. package/dist/src/templates/scripts/genesys/mcp/utils.js +1 -1
  23. package/dist/src/templates/scripts/genesys/misc.js +1 -1
  24. package/dist/src/templates/scripts/genesys/mock.js +1 -1
  25. package/dist/src/templates/scripts/genesys/place-actors.js +1 -1
  26. package/dist/src/templates/scripts/genesys/post-install.js +1 -1
  27. package/dist/src/templates/scripts/genesys/storageProvider.js +2 -2
  28. package/dist/src/templates/src/index.js +1 -1
  29. package/dist/src/templates/src/templates/firstPerson/src/game.js +1 -1
  30. package/dist/src/templates/src/templates/firstPerson/src/player.js +1 -1
  31. package/dist/src/templates/src/templates/fps/src/game.js +1 -1
  32. package/dist/src/templates/src/templates/fps/src/player.js +1 -1
  33. package/dist/src/templates/src/templates/fps/src/weapon.js +1 -1
  34. package/dist/src/templates/src/templates/freeCamera/src/game.js +1 -1
  35. package/dist/src/templates/src/templates/freeCamera/src/player.js +1 -1
  36. package/dist/src/templates/src/templates/sideScroller/src/game.js +1 -1
  37. package/dist/src/templates/src/templates/sideScroller/src/level-generator.js +1 -1
  38. package/dist/src/templates/src/templates/sideScroller/src/player.js +1 -1
  39. package/dist/src/templates/src/templates/thirdPerson/src/game.js +1 -1
  40. package/dist/src/templates/src/templates/thirdPerson/src/player.js +1 -1
  41. package/dist/src/templates/src/templates/vehicle/src/base-vehicle.js +1 -1
  42. package/dist/src/templates/src/templates/vehicle/src/game.js +1 -1
  43. package/dist/src/templates/src/templates/vehicle/src/mesh-vehicle.js +1 -1
  44. package/dist/src/templates/src/templates/vehicle/src/player.js +1 -1
  45. package/dist/src/templates/src/templates/vehicle/src/primitive-vehicle.js +1 -1
  46. package/dist/src/templates/src/templates/vehicle/src/ui-hints.js +31 -31
  47. package/dist/src/templates/src/templates/vr-game/src/game.js +1 -1
  48. package/dist/src/templates/src/templates/vr-game/src/sample-vr-actor.js +1 -1
  49. package/package.json +176 -176
  50. package/scripts/post-install.ts +143 -143
  51. package/src/asset-pack/.gitattributes +88 -88
  52. package/src/asset-pack/eslint.config.js +45 -45
  53. package/src/asset-pack/gitignore +11 -11
  54. package/src/asset-pack/scripts/postinstall.ts +81 -81
  55. package/src/asset-pack/tsconfig.json +33 -33
  56. package/src/templates/.cursor/mcp.json +20 -20
  57. package/src/templates/.cursorignore +2 -2
  58. package/src/templates/.gitattributes +88 -88
  59. package/src/templates/.vscode/settings.json +6 -6
  60. package/src/templates/AGENTS.md +86 -86
  61. package/src/templates/README.md +24 -24
  62. package/src/templates/eslint.config.js +45 -45
  63. package/src/templates/gitignore +11 -11
  64. package/src/templates/index.html +34 -34
  65. package/src/templates/pnpm-lock.yaml +3676 -3676
  66. package/src/templates/scripts/genesys/build-project.ts +51 -51
  67. package/src/templates/scripts/genesys/calc-bounding-box.ts +272 -272
  68. package/src/templates/scripts/genesys/common.ts +46 -46
  69. package/src/templates/scripts/genesys/const.ts +9 -9
  70. package/src/templates/scripts/genesys/dev/dump-default-scene.ts +11 -11
  71. package/src/templates/scripts/genesys/dev/generate-manifest.ts +146 -146
  72. package/src/templates/scripts/genesys/dev/launcher.ts +46 -46
  73. package/src/templates/scripts/genesys/dev/storage-provider.ts +229 -229
  74. package/src/templates/scripts/genesys/dev/update-template-scenes.ts +84 -84
  75. package/src/templates/scripts/genesys/doc-server.ts +16 -16
  76. package/src/templates/scripts/genesys/genesys-mcp.ts +526 -526
  77. package/src/templates/scripts/genesys/mcp/doc-tools.ts +86 -86
  78. package/src/templates/scripts/genesys/mcp/editor-functions.ts +151 -151
  79. package/src/templates/scripts/genesys/mcp/editor-tools.ts +73 -73
  80. package/src/templates/scripts/genesys/mcp/get-scene-state.ts +35 -35
  81. package/src/templates/scripts/genesys/mcp/run-subprocess.ts +30 -30
  82. package/src/templates/scripts/genesys/mcp/search-actors.ts +858 -858
  83. package/src/templates/scripts/genesys/mcp/search-assets.ts +380 -380
  84. package/src/templates/scripts/genesys/mcp/utils.ts +281 -281
  85. package/src/templates/scripts/genesys/misc.ts +42 -42
  86. package/src/templates/scripts/genesys/mock.ts +6 -6
  87. package/src/templates/scripts/genesys/place-actors.ts +179 -179
  88. package/src/templates/scripts/genesys/post-install.ts +30 -30
  89. package/src/templates/scripts/genesys/prefab.schema.json +84 -84
  90. package/src/templates/scripts/genesys/remove-engine-comments.ts +134 -134
  91. package/src/templates/scripts/genesys/run-mcp-inspector.bat +4 -4
  92. package/src/templates/scripts/genesys/storageProvider.ts +182 -182
  93. package/src/templates/scripts/genesys/validate-prefabs.ts +138 -138
  94. package/src/templates/src/index.ts +22 -22
  95. package/src/templates/src/templates/firstPerson/assets/default.genesys-scene +165 -165
  96. package/src/templates/src/templates/firstPerson/src/game.ts +39 -39
  97. package/src/templates/src/templates/firstPerson/src/player.ts +63 -63
  98. package/src/templates/src/templates/fps/assets/default.genesys-scene +9459 -9459
  99. package/src/templates/src/templates/fps/src/game.ts +39 -39
  100. package/src/templates/src/templates/fps/src/player.ts +69 -69
  101. package/src/templates/src/templates/fps/src/weapon.ts +54 -54
  102. package/src/templates/src/templates/freeCamera/assets/default.genesys-scene +165 -165
  103. package/src/templates/src/templates/freeCamera/src/game.ts +39 -39
  104. package/src/templates/src/templates/freeCamera/src/player.ts +45 -45
  105. package/src/templates/src/templates/sideScroller/assets/default.genesys-scene +121 -121
  106. package/src/templates/src/templates/sideScroller/src/const.ts +45 -45
  107. package/src/templates/src/templates/sideScroller/src/game.ts +122 -122
  108. package/src/templates/src/templates/sideScroller/src/level-generator.ts +361 -361
  109. package/src/templates/src/templates/sideScroller/src/player.ts +125 -125
  110. package/src/templates/src/templates/thirdPerson/assets/default.genesys-scene +165 -165
  111. package/src/templates/src/templates/thirdPerson/src/game.ts +39 -39
  112. package/src/templates/src/templates/thirdPerson/src/player.ts +61 -61
  113. package/src/templates/src/templates/vehicle/assets/default.genesys-scene +225 -225
  114. package/src/templates/src/templates/vehicle/src/base-vehicle.ts +145 -145
  115. package/src/templates/src/templates/vehicle/src/game.ts +43 -43
  116. package/src/templates/src/templates/vehicle/src/mesh-vehicle.ts +191 -191
  117. package/src/templates/src/templates/vehicle/src/player.ts +109 -109
  118. package/src/templates/src/templates/vehicle/src/primitive-vehicle.ts +266 -266
  119. package/src/templates/src/templates/vehicle/src/ui-hints.ts +101 -101
  120. package/src/templates/src/templates/vr-game/assets/default.genesys-scene +246 -246
  121. package/src/templates/src/templates/vr-game/src/auto-imports.ts +1 -1
  122. package/src/templates/src/templates/vr-game/src/game.ts +66 -66
  123. package/src/templates/src/templates/vr-game/src/sample-vr-actor.ts +26 -26
  124. package/src/templates/tsconfig.json +34 -34
  125. package/src/templates/vite.config.ts +52 -52
@@ -1,145 +1,145 @@
1
- import * as ENGINE from 'genesys.js';
2
- import * as THREE from 'three';
3
-
4
- import { VehiclePlayer } from './player.js';
5
-
6
- /**
7
- * Base vehicle class that provides common vehicle functionality
8
- *
9
- * Key points:
10
- * - Handles camera setup with follow component for smooth third-person view
11
- * - Manages player interaction (enter/exit vehicle with proximity detection)
12
- * - Provides E key input handler for vehicle exit
13
- * - Calculates safe exit position when player leaves vehicle
14
- * - Automatically switches possession between player and vehicle
15
- *
16
- */
17
- export abstract class BaseVehicle extends ENGINE.Pawn {
18
- protected readonly interactionDistance = 5;
19
- protected nearbyPlayer: ENGINE.Pawn | null = null;
20
- protected enteredPlayer: ENGINE.Pawn | null = null;
21
-
22
- protected override doBeginPlay(): void {
23
- super.doBeginPlay();
24
- this.setupCamera();
25
- this.setupVicinityCheck();
26
- this.setupExitHandler();
27
- }
28
-
29
- protected setupCamera(): void {
30
- // create a follow component for smooth camera movement
31
- const followComponent = new ENGINE.FollowComponent({
32
- positionOffset: new THREE.Vector3(0, 4, 10),
33
- positionDamping: 0.02,
34
- lookAtOffset: new THREE.Vector3(0, 0, 0),
35
- target: this.rootComponent,
36
- useCameraLookAtConvention: true,
37
- });
38
- this.rootComponent.add(followComponent);
39
-
40
- // create a camera and add it to the follow component
41
- const camera = new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, ENGINE.CAMERA_NEAR, ENGINE.CAMERA_FAR);
42
- followComponent.add(camera);
43
- }
44
-
45
- protected setupVicinityCheck(): void {
46
- // Check every frame for nearby players using tick delegate
47
- this.onTickPostPhysics.add(() => {
48
- this.checkForNearbyPlayer();
49
- });
50
- }
51
-
52
- protected checkForNearbyPlayer(): void {
53
- const players = this.world!.getActors(VehiclePlayer);
54
-
55
- let foundNearbyPlayer = false;
56
- for (const player of players) {
57
- const distance = this.rootComponent.position.distanceTo(player.rootComponent.position);
58
- if (distance <= this.interactionDistance) {
59
- this.nearbyPlayer = player;
60
- foundNearbyPlayer = true;
61
- break;
62
- }
63
- }
64
-
65
- if (!foundNearbyPlayer) {
66
- this.nearbyPlayer = null;
67
- }
68
- }
69
-
70
- public canBeEntered(): boolean {
71
- return this.nearbyPlayer !== null;
72
- }
73
-
74
- public getNearbyPlayer(): ENGINE.Pawn | null {
75
- return this.nearbyPlayer;
76
- }
77
-
78
- protected setupExitHandler(): void {
79
- // Add E key input handler for vehicle exit
80
- this.onKeyDown.add((e: KeyboardEvent) => {
81
- if (e.key.toLowerCase() === 'e' && this.enteredPlayer) {
82
- this.exitVehicle();
83
- return true;
84
- } else if (e.key.toLowerCase() === 'f') {
85
- if (this.movementComponent instanceof ENGINE.VehicleMovementComponent) {
86
- this.movementComponent.flipVehicle(false);
87
- }
88
- return true;
89
- }
90
- return false;
91
- });
92
- }
93
-
94
- public setEnteredPlayer(player: ENGINE.Pawn | null): void {
95
- this.enteredPlayer = player;
96
- }
97
-
98
- protected exitVehicle(): void {
99
- if (!this.enteredPlayer) return;
100
-
101
- // Calculate exit position (to the side of the vehicle)
102
- const exitPosition = this.calculateExitPosition();
103
-
104
- // Get the current player controller
105
- const controller = this.getPlayerController();
106
-
107
- if (controller) {
108
- // Move player to exit position
109
- this.enteredPlayer.rootComponent.position.copy(exitPosition);
110
-
111
- // Make player face the same direction as the vehicle (yaw only)
112
- this.enteredPlayer.rootComponent.rotation.x = 0;
113
- this.enteredPlayer.rootComponent.rotation.z = 0;
114
- this.enteredPlayer.rootComponent.rotation.y = this.rootComponent.rotation.y;
115
-
116
- // Restore player visibility and physics
117
- this.enteredPlayer.rootComponent.visible = true;
118
- // Only the root component has physics, do not propagate to children
119
- this.enteredPlayer.rootComponent.setPhysicsEnabled(true, false);
120
-
121
- // Switch possession back to player
122
- controller.unpossess();
123
- controller.possess(this.enteredPlayer);
124
-
125
- // Clear entered player reference
126
- this.enteredPlayer = null;
127
- }
128
- }
129
-
130
- protected calculateExitPosition(): THREE.Vector3 {
131
- // Calculate a position to the right side of the vehicle
132
- const vehiclePosition = this.rootComponent.position.clone();
133
- const vehicleRotation = this.rootComponent.rotation;
134
-
135
- // Create a vector pointing to the right of the vehicle
136
- const rightVector = new THREE.Vector3(1, 0, 0);
137
- rightVector.applyEuler(vehicleRotation);
138
-
139
- // Position the player 2 units to the right and slightly forward
140
- const exitOffset = rightVector.multiplyScalar(2);
141
- exitOffset.y = 1; // Raise slightly above ground
142
-
143
- return vehiclePosition.add(exitOffset);
144
- }
145
- }
1
+ import * as ENGINE from '@directivegames/genesys.js';
2
+ import * as THREE from 'three';
3
+
4
+ import { VehiclePlayer } from './player.js';
5
+
6
+ /**
7
+ * Base vehicle class that provides common vehicle functionality
8
+ *
9
+ * Key points:
10
+ * - Handles camera setup with follow component for smooth third-person view
11
+ * - Manages player interaction (enter/exit vehicle with proximity detection)
12
+ * - Provides E key input handler for vehicle exit
13
+ * - Calculates safe exit position when player leaves vehicle
14
+ * - Automatically switches possession between player and vehicle
15
+ *
16
+ */
17
+ export abstract class BaseVehicle extends ENGINE.Pawn {
18
+ protected readonly interactionDistance = 5;
19
+ protected nearbyPlayer: ENGINE.Pawn | null = null;
20
+ protected enteredPlayer: ENGINE.Pawn | null = null;
21
+
22
+ protected override doBeginPlay(): void {
23
+ super.doBeginPlay();
24
+ this.setupCamera();
25
+ this.setupVicinityCheck();
26
+ this.setupExitHandler();
27
+ }
28
+
29
+ protected setupCamera(): void {
30
+ // create a follow component for smooth camera movement
31
+ const followComponent = new ENGINE.FollowComponent({
32
+ positionOffset: new THREE.Vector3(0, 4, 10),
33
+ positionDamping: 0.02,
34
+ lookAtOffset: new THREE.Vector3(0, 0, 0),
35
+ target: this.rootComponent,
36
+ useCameraLookAtConvention: true,
37
+ });
38
+ this.rootComponent.add(followComponent);
39
+
40
+ // create a camera and add it to the follow component
41
+ const camera = new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, ENGINE.CAMERA_NEAR, ENGINE.CAMERA_FAR);
42
+ followComponent.add(camera);
43
+ }
44
+
45
+ protected setupVicinityCheck(): void {
46
+ // Check every frame for nearby players using tick delegate
47
+ this.onTickPostPhysics.add(() => {
48
+ this.checkForNearbyPlayer();
49
+ });
50
+ }
51
+
52
+ protected checkForNearbyPlayer(): void {
53
+ const players = this.world!.getActors(VehiclePlayer);
54
+
55
+ let foundNearbyPlayer = false;
56
+ for (const player of players) {
57
+ const distance = this.rootComponent.position.distanceTo(player.rootComponent.position);
58
+ if (distance <= this.interactionDistance) {
59
+ this.nearbyPlayer = player;
60
+ foundNearbyPlayer = true;
61
+ break;
62
+ }
63
+ }
64
+
65
+ if (!foundNearbyPlayer) {
66
+ this.nearbyPlayer = null;
67
+ }
68
+ }
69
+
70
+ public canBeEntered(): boolean {
71
+ return this.nearbyPlayer !== null;
72
+ }
73
+
74
+ public getNearbyPlayer(): ENGINE.Pawn | null {
75
+ return this.nearbyPlayer;
76
+ }
77
+
78
+ protected setupExitHandler(): void {
79
+ // Add E key input handler for vehicle exit
80
+ this.onKeyDown.add((e: KeyboardEvent) => {
81
+ if (e.key.toLowerCase() === 'e' && this.enteredPlayer) {
82
+ this.exitVehicle();
83
+ return true;
84
+ } else if (e.key.toLowerCase() === 'f') {
85
+ if (this.movementComponent instanceof ENGINE.VehicleMovementComponent) {
86
+ this.movementComponent.flipVehicle(false);
87
+ }
88
+ return true;
89
+ }
90
+ return false;
91
+ });
92
+ }
93
+
94
+ public setEnteredPlayer(player: ENGINE.Pawn | null): void {
95
+ this.enteredPlayer = player;
96
+ }
97
+
98
+ protected exitVehicle(): void {
99
+ if (!this.enteredPlayer) return;
100
+
101
+ // Calculate exit position (to the side of the vehicle)
102
+ const exitPosition = this.calculateExitPosition();
103
+
104
+ // Get the current player controller
105
+ const controller = this.getPlayerController();
106
+
107
+ if (controller) {
108
+ // Move player to exit position
109
+ this.enteredPlayer.rootComponent.position.copy(exitPosition);
110
+
111
+ // Make player face the same direction as the vehicle (yaw only)
112
+ this.enteredPlayer.rootComponent.rotation.x = 0;
113
+ this.enteredPlayer.rootComponent.rotation.z = 0;
114
+ this.enteredPlayer.rootComponent.rotation.y = this.rootComponent.rotation.y;
115
+
116
+ // Restore player visibility and physics
117
+ this.enteredPlayer.rootComponent.visible = true;
118
+ // Only the root component has physics, do not propagate to children
119
+ this.enteredPlayer.rootComponent.setPhysicsEnabled(true, false);
120
+
121
+ // Switch possession back to player
122
+ controller.unpossess();
123
+ controller.possess(this.enteredPlayer);
124
+
125
+ // Clear entered player reference
126
+ this.enteredPlayer = null;
127
+ }
128
+ }
129
+
130
+ protected calculateExitPosition(): THREE.Vector3 {
131
+ // Calculate a position to the right side of the vehicle
132
+ const vehiclePosition = this.rootComponent.position.clone();
133
+ const vehicleRotation = this.rootComponent.rotation;
134
+
135
+ // Create a vector pointing to the right of the vehicle
136
+ const rightVector = new THREE.Vector3(1, 0, 0);
137
+ rightVector.applyEuler(vehicleRotation);
138
+
139
+ // Position the player 2 units to the right and slightly forward
140
+ const exitOffset = rightVector.multiplyScalar(2);
141
+ exitOffset.y = 1; // Raise slightly above ground
142
+
143
+ return vehiclePosition.add(exitOffset);
144
+ }
145
+ }
@@ -1,43 +1,43 @@
1
-
2
- import * as ENGINE from 'genesys.js';
3
- import * as THREE from 'three';
4
-
5
- import './auto-imports.js';
6
- import { VehiclePlayer } from './player.js';
7
- import { UIHints } from './ui-hints.js';
8
-
9
- class MyGame extends ENGINE.BaseGameLoop {
10
- private pawn: VehiclePlayer | null = null;
11
- private controller: ENGINE.PlayerController | null = null;
12
-
13
- protected override createLoadingScreen(): ENGINE.ILoadingScreen | null {
14
- // enable the default loading screen
15
- return new ENGINE.DefaultLoadingScreen();
16
- }
17
-
18
- protected override async preStart(): Promise<void> {
19
- // default spawn location
20
- const position = new THREE.Vector3(0, ENGINE.CHARACTER_HEIGHT / 2, 0);
21
-
22
- // create the pawn
23
- this.pawn = new VehiclePlayer({ position });
24
-
25
- // create the controller and possess the pawn
26
- this.controller = new ENGINE.PlayerController();
27
- this.controller.possess(this.pawn);
28
-
29
- // create UI hints
30
- const uiHints = new UIHints();
31
-
32
- // add all actors to the world
33
- this.world.addActors(this.pawn, this.controller, uiHints);
34
- }
35
- }
36
-
37
- export function main(container: HTMLElement, gameId: string): ENGINE.IGameLoop {
38
- const game = new MyGame(container, {
39
- ...ENGINE.BaseGameLoop.DEFAULT_OPTIONS,
40
- gameId
41
- });
42
- return game;
43
- }
1
+
2
+ import * as ENGINE from '@directivegames/genesys.js';
3
+ import * as THREE from 'three';
4
+
5
+ import './auto-imports.js';
6
+ import { VehiclePlayer } from './player.js';
7
+ import { UIHints } from './ui-hints.js';
8
+
9
+ class MyGame extends ENGINE.BaseGameLoop {
10
+ private pawn: VehiclePlayer | null = null;
11
+ private controller: ENGINE.PlayerController | null = null;
12
+
13
+ protected override createLoadingScreen(): ENGINE.ILoadingScreen | null {
14
+ // enable the default loading screen
15
+ return new ENGINE.DefaultLoadingScreen();
16
+ }
17
+
18
+ protected override async preStart(): Promise<void> {
19
+ // default spawn location
20
+ const position = new THREE.Vector3(0, ENGINE.CHARACTER_HEIGHT / 2, 0);
21
+
22
+ // create the pawn
23
+ this.pawn = new VehiclePlayer({ position });
24
+
25
+ // create the controller and possess the pawn
26
+ this.controller = new ENGINE.PlayerController();
27
+ this.controller.possess(this.pawn);
28
+
29
+ // create UI hints
30
+ const uiHints = new UIHints();
31
+
32
+ // add all actors to the world
33
+ this.world.addActors(this.pawn, this.controller, uiHints);
34
+ }
35
+ }
36
+
37
+ export function main(container: HTMLElement, gameId: string): ENGINE.IGameLoop {
38
+ const game = new MyGame(container, {
39
+ ...ENGINE.BaseGameLoop.DEFAULT_OPTIONS,
40
+ gameId
41
+ });
42
+ return game;
43
+ }