@directivegames/genesys.sdk 4.0.2 → 4.1.0

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 (45) hide show
  1. package/dist/src/core/tools/new-project.js +1 -0
  2. package/dist/src/dependencies.js +1 -1
  3. package/dist/src/templates/scripts/genesys/migrate-scenes-and-prefabs.js +179 -0
  4. package/dist/src/templates/scripts/genesys/post-install.js +10 -2
  5. package/dist/src/templates/src/templates/firstPerson/src/game.js +1 -1
  6. package/dist/src/templates/src/templates/firstPerson/src/player.js +8 -13
  7. package/dist/src/templates/src/templates/fps/src/game.js +1 -1
  8. package/dist/src/templates/src/templates/fps/src/player.js +8 -12
  9. package/dist/src/templates/src/templates/fps/src/weapon.js +30 -38
  10. package/dist/src/templates/src/templates/freeCamera/src/game.js +1 -1
  11. package/dist/src/templates/src/templates/freeCamera/src/player.js +6 -11
  12. package/dist/src/templates/src/templates/sideScroller/src/game.js +2 -3
  13. package/dist/src/templates/src/templates/sideScroller/src/level-generator.js +17 -17
  14. package/dist/src/templates/src/templates/sideScroller/src/player.js +12 -17
  15. package/dist/src/templates/src/templates/thirdPerson/src/game.js +1 -1
  16. package/dist/src/templates/src/templates/thirdPerson/src/player.js +13 -18
  17. package/dist/src/templates/src/templates/vehicle/src/base-vehicle.js +1 -1
  18. package/dist/src/templates/src/templates/vehicle/src/game.js +2 -2
  19. package/dist/src/templates/src/templates/vehicle/src/mesh-vehicle.js +8 -9
  20. package/dist/src/templates/src/templates/vehicle/src/player.js +13 -18
  21. package/dist/src/templates/src/templates/vehicle/src/primitive-vehicle.js +11 -12
  22. package/dist/src/templates/src/templates/vehicle/src/ui-hints.js +2 -2
  23. package/dist/src/templates/src/templates/vr-game/src/game.js +5 -5
  24. package/package.json +2 -2
  25. package/src/templates/scripts/genesys/migrate-scenes-and-prefabs.ts +212 -0
  26. package/src/templates/scripts/genesys/post-install.ts +11 -2
  27. package/src/templates/src/templates/firstPerson/src/game.ts +1 -1
  28. package/src/templates/src/templates/firstPerson/src/player.ts +10 -14
  29. package/src/templates/src/templates/fps/src/game.ts +1 -1
  30. package/src/templates/src/templates/fps/src/player.ts +10 -13
  31. package/src/templates/src/templates/fps/src/weapon.ts +31 -38
  32. package/src/templates/src/templates/freeCamera/src/game.ts +1 -1
  33. package/src/templates/src/templates/freeCamera/src/player.ts +7 -12
  34. package/src/templates/src/templates/sideScroller/src/game.ts +2 -3
  35. package/src/templates/src/templates/sideScroller/src/level-generator.ts +21 -21
  36. package/src/templates/src/templates/sideScroller/src/player.ts +15 -17
  37. package/src/templates/src/templates/thirdPerson/src/game.ts +1 -1
  38. package/src/templates/src/templates/thirdPerson/src/player.ts +16 -19
  39. package/src/templates/src/templates/vehicle/src/base-vehicle.ts +1 -1
  40. package/src/templates/src/templates/vehicle/src/game.ts +2 -2
  41. package/src/templates/src/templates/vehicle/src/mesh-vehicle.ts +8 -10
  42. package/src/templates/src/templates/vehicle/src/player.ts +16 -19
  43. package/src/templates/src/templates/vehicle/src/primitive-vehicle.ts +11 -13
  44. package/src/templates/src/templates/vehicle/src/ui-hints.ts +2 -2
  45. package/src/templates/src/templates/vr-game/src/game.ts +5 -5
@@ -11,44 +11,37 @@ import * as THREE from 'three';
11
11
  @ENGINE.GameClass()
12
12
  export class DefaultWeapon extends ENGINE.ProjectileWeaponComponent {
13
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
- });
14
+ super();
15
+
16
+ this.fireInterval = 0.1;
17
+ this.isSingleFire = false;
18
+ this.modelPath = '@project/assets/models/SM_Rifle.glb';
19
+ this.modelTransform = {
20
+ position: new THREE.Vector3(0.1, -0.1, -0.25),
21
+ rotation: new THREE.Euler(0, THREE.MathUtils.degToRad(-90), 0),
22
+ };
23
+ this.projectileSpawnOffset = new THREE.Vector3(0.8, -0.6, -2);
24
+ this.crosshairOptions = {
25
+ size: 10,
26
+ color: 'white',
27
+ style: 'dot'
28
+ };
29
+ this.fireSoundUrl = '@engine/assets/sounds/game-gun-short.mp3';
30
+ this.recoilOptions = {
31
+ weaponRecoilDistance: 0.05,
32
+ weaponRecoilDuration: 0.05,
33
+ weaponRecoilRotation: 0,
34
+ };
35
+ this.projectileOptions = {
36
+ velocity: 100,
37
+ range: 500,
38
+ lifeSpan: 3,
39
+ useOverlapCheck: false,
40
+ destroyOnHit: false,
41
+ gravityScale: 0,
42
+ geometry: new THREE.SphereGeometry(0.1),
43
+ material: new THREE.MeshStandardMaterial({ color: ENGINE.Color.YELLOW })
44
+ };
52
45
  this.setTransient(true);
53
46
  }
54
47
  }
@@ -19,7 +19,7 @@ class MyGame extends ENGINE.BaseGameLoop {
19
19
  const position = new THREE.Vector3(0, ENGINE.CHARACTER_HEIGHT, 0);
20
20
 
21
21
  // create the pawn with simple movement mechanics
22
- this.pawn = new FreeCameraPlayer({ position });
22
+ this.pawn = FreeCameraPlayer.create({ position });
23
23
 
24
24
  // create the controller and possess the pawn
25
25
  this.controller = new ENGINE.PlayerController();
@@ -19,25 +19,20 @@ export interface FreeCameraPlayerOptions extends ENGINE.PawnOptions {
19
19
  *
20
20
  */
21
21
  @ENGINE.GameClass()
22
- export class FreeCameraPlayer extends ENGINE.Pawn<FreeCameraPlayerOptions> {
23
- constructor(options: Omit<FreeCameraPlayerOptions, 'camera' | 'movementComponent'>) {
22
+ export class FreeCameraPlayer extends ENGINE.Pawn {
23
+ constructor() {
24
+ super();
24
25
  // simple perspective camera
25
26
  const camera = new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, ENGINE.CAMERA_NEAR, ENGINE.CAMERA_FAR);
27
+ this.rootComponent.add(camera);
26
28
  // simple movement component, do not use the character controller
27
- const movementComponent = new ENGINE.CharacterMovementComponent({
28
- ...ENGINE.CharacterMovementComponent.DEFAULT_OPTIONS,
29
+ const movementComponent = ENGINE.CharacterMovementComponent.create({
29
30
  // disable the character controller
30
31
  characterControllerOptions: null,
31
32
  });
33
+ this.movementComponent = movementComponent;
32
34
 
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
- });
35
+ this.enableDirectionalLightFollowing = true;
41
36
 
42
37
  // set the pawn to be transient so it's never saved in the level
43
38
  this.setTransient(true);
@@ -39,9 +39,8 @@ class SideScrollerGame extends ENGINE.BaseGameLoop {
39
39
  private createPlayer(): void {
40
40
  const spawnX = 1;
41
41
  // Create the side-scroller player with animated character
42
- this.player = new SideScrollerPlayer({
43
- position: new THREE.Vector3(spawnX, ENGINE.CHARACTER_HEIGHT / 2, 0),
44
- });
42
+ const position = new THREE.Vector3(spawnX, ENGINE.CHARACTER_HEIGHT / 2, 0);
43
+ this.player = SideScrollerPlayer.create({ position });
45
44
 
46
45
  // Create the controller and possess the player
47
46
  this.playerController = new ENGINE.PlayerController();
@@ -198,7 +198,7 @@ export class SideScrollerLevelGenerator {
198
198
  const geometry = new THREE.BoxGeometry(element.width, element.height, LEVEL_CONFIG.DEPTH);
199
199
  const material = new THREE.MeshStandardMaterial({ color: element.type === 'platform' ? COLORS.PLATFORM : COLORS.OBSTACLE });
200
200
 
201
- const meshComponent = new ENGINE.MeshComponent({
201
+ const meshComponent = ENGINE.MeshComponent.create({
202
202
  geometry: geometry,
203
203
  material: material,
204
204
  position: new THREE.Vector3(element.x, element.height / 2, 0), // Position at ground level
@@ -213,9 +213,9 @@ export class SideScrollerLevelGenerator {
213
213
  meshComponent.castShadow = true;
214
214
  meshComponent.receiveShadow = true;
215
215
 
216
- return new ENGINE.Actor({
217
- rootComponent: meshComponent,
218
- });
216
+ const actor = new ENGINE.Actor();
217
+ actor.setRootComponent(meshComponent, false);
218
+ return actor;
219
219
  }
220
220
 
221
221
  private createChunkDebugVisualization(startX: number): ENGINE.Actor {
@@ -233,21 +233,21 @@ export class SideScrollerLevelGenerator {
233
233
  transparent: true,
234
234
  });
235
235
 
236
- const chunkBoundary = new ENGINE.Actor({
237
- rootComponent: new ENGINE.MeshComponent({
238
- geometry: chunkGeometry,
239
- material: chunkMaterial,
240
- position: new THREE.Vector3(
241
- startX + this.chunkSize / 2,
242
- LEVEL_CONFIG.DEBUG_VISUALIZATION_HEIGHT / 2,
243
- 0
244
- ),
245
- physicsOptions: {
246
- enabled: false,
247
- },
248
- }),
236
+ const meshComponent = ENGINE.MeshComponent.create({
237
+ geometry: chunkGeometry,
238
+ material: chunkMaterial,
239
+ position: new THREE.Vector3(
240
+ startX + this.chunkSize / 2,
241
+ LEVEL_CONFIG.DEBUG_VISUALIZATION_HEIGHT / 2,
242
+ 0
243
+ ),
244
+ physicsOptions: {
245
+ enabled: false,
246
+ },
249
247
  });
250
248
 
249
+ const chunkBoundary = new ENGINE.Actor();
250
+ chunkBoundary.setRootComponent(meshComponent, false);
251
251
  return chunkBoundary;
252
252
  }
253
253
 
@@ -263,7 +263,7 @@ export class SideScrollerLevelGenerator {
263
263
  color: COLORS.GROUND,
264
264
  });
265
265
 
266
- const groundMeshComponent = new ENGINE.MeshComponent({
266
+ const groundMeshComponent = ENGINE.MeshComponent.create({
267
267
  geometry: groundGeometry,
268
268
  material: groundMaterial,
269
269
  position: new THREE.Vector3(
@@ -281,9 +281,9 @@ export class SideScrollerLevelGenerator {
281
281
  // Enable shadow receiving
282
282
  groundMeshComponent.receiveShadow = true;
283
283
 
284
- return new ENGINE.Actor({
285
- rootComponent: groundMeshComponent,
286
- });
284
+ const actor = new ENGINE.Actor();
285
+ actor.setRootComponent(groundMeshComponent, false);
286
+ return actor;
287
287
  }
288
288
 
289
289
  /**
@@ -15,10 +15,10 @@ export class SideScrollerPlayer extends ENGINE.ThirdPersonCharacterPawn {
15
15
  smoothedCameraHeight: number | null = null;
16
16
  smoothedLookAtHeight: number | null = null;
17
17
 
18
- constructor(options: Omit<ENGINE.ThirdPersonCharacterPawnOptions, 'movementComponent' | 'camera' | 'rootComponent'>) {
18
+ constructor() {
19
+ super();
19
20
  // Create directional movement component for side-scrolling
20
- const movementComponent = new ENGINE.DirectionalCharacterMovementComponent({
21
- ...ENGINE.DirectionalCharacterMovementComponent.DEFAULT_OPTIONS,
21
+ const movementComponent = ENGINE.DirectionalCharacterMovementComponent.create({
22
22
  direction: ENGINE.CharacterMovementDirection.LeftRight, // Move left and right
23
23
  autoMove: false, // Player controls movement manually
24
24
  jumpSpeed: PLAYER_MOVEMENT.JUMP_SPEED,
@@ -40,7 +40,7 @@ export class SideScrollerPlayer extends ENGINE.ThirdPersonCharacterPawn {
40
40
  };
41
41
 
42
42
  // Create root component with physics (invisible capsule for collision)
43
- const rootComponent = new ENGINE.MeshComponent({
43
+ const rootComponent = ENGINE.MeshComponent.create({
44
44
  geometry: new THREE.CapsuleGeometry(
45
45
  ENGINE.CHARACTER_WIDTH / 2,
46
46
  ENGINE.CHARACTER_HEIGHT - ENGINE.CHARACTER_WIDTH
@@ -54,23 +54,21 @@ export class SideScrollerPlayer extends ENGINE.ThirdPersonCharacterPawn {
54
54
  physicsOptions,
55
55
  });
56
56
 
57
- super({
58
- ...options,
59
- // Use default character model from engine assets
60
- modelUrl: '@engine/assets/character/mannequinG.glb',
61
- configUrl: '@engine/assets/character/config/mannequin-anim.json',
62
- meshPosition: new THREE.Vector3(0, -ENGINE.CHARACTER_HEIGHT / 2, 0),
63
- meshRotation: new THREE.Euler(0, Math.PI, 0), // Face right initially
64
- meshScale: new THREE.Vector3(1, 1, 1),
65
- movementComponent,
66
- camera: null, // Do not attach the camera to the player directly
67
- rootComponent,
68
- enableDirectionalLightFollowing: true,
69
- });
57
+ this.setRootComponent(rootComponent, true);
58
+ this.movementComponent = movementComponent;
59
+
60
+ // Use default character model from engine assets
61
+ this.configUrl = '@engine/assets/character/config/mannequin-anim.json';
62
+
63
+ this.meshComponent.position.copy(new THREE.Vector3(0, -ENGINE.CHARACTER_HEIGHT / 2, 0));
64
+ this.meshComponent.rotation.copy(new THREE.Euler(0, Math.PI, 0)); // Face right initially
65
+ rootComponent.add(this.meshComponent);
70
66
 
71
67
  // Enable shadow casting for the character
72
68
  this.rootComponent.castShadow = true;
73
69
  this.camera = new THREE.PerspectiveCamera(CAMERA_SETTINGS.FOV, 1, CAMERA_SETTINGS.NEAR, CAMERA_SETTINGS.FAR);
70
+
71
+ this.enableDirectionalLightFollowing = true;
74
72
  }
75
73
 
76
74
  public override async doBeginPlay(): Promise<void> {
@@ -19,7 +19,7 @@ class ThirdPersonGame extends ENGINE.BaseGameLoop {
19
19
  const position = new THREE.Vector3(0, ENGINE.CHARACTER_HEIGHT / 2, 0);
20
20
 
21
21
  // create the pawn
22
- this.pawn = new ThirdPersonPlayer({ position });
22
+ this.pawn = ThirdPersonPlayer.create({ position });
23
23
 
24
24
  // create the controller and possess the pawn
25
25
  this.controller = new ENGINE.PlayerController();
@@ -14,8 +14,8 @@ import * as THREE from 'three';
14
14
  @ENGINE.GameClass()
15
15
  export class ThirdPersonPlayer extends ENGINE.ThirdPersonCharacterPawn {
16
16
  // Omit all the options that are created internally
17
- constructor(options: Omit<ENGINE.ThirdPersonCharacterPawnOptions,
18
- 'rootComponent' | 'movementComponent' | 'camera' | 'modelUrl' | 'configUrl' | 'meshPosition' | 'meshRotation' | 'meshScale'>) {
17
+ constructor() {
18
+ super();
19
19
  // simple camera component - contains a perspective camera by default
20
20
  const camera = new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, 0.1, 1000);
21
21
  // set camera position for third person view
@@ -23,7 +23,7 @@ export class ThirdPersonPlayer extends ENGINE.ThirdPersonCharacterPawn {
23
23
  camera.lookAt(0, 0, 0);
24
24
 
25
25
  // use capsule root component for collision
26
- const rootComponent = new ENGINE.MeshComponent({
26
+ const rootComponent = ENGINE.MeshComponent.create({
27
27
  geometry: ENGINE.GameBuilder.createDefaultPawnCapsuleGeometry(),
28
28
  material: new THREE.MeshStandardMaterial({ color: ENGINE.Color.YELLOW, visible: false, transparent: true, opacity: 0.5 }),
29
29
  physicsOptions: {
@@ -33,27 +33,24 @@ export class ThirdPersonPlayer extends ENGINE.ThirdPersonCharacterPawn {
33
33
  collisionProfile: ENGINE.DefaultCollisionProfile.Character,
34
34
  },
35
35
  });
36
+ this.setRootComponent(rootComponent, true);
36
37
 
37
38
  // use third person movement mechanics
38
- const movementComponent = new ENGINE.CharacterMovementComponent({
39
- ...ENGINE.CharacterMovementComponent.DEFAULT_OPTIONS,
39
+ const movementComponent = ENGINE.CharacterMovementComponent.create({
40
40
  movementType: ENGINE.CharacterMovementType.ThirdPerson,
41
41
  });
42
42
 
43
- // construct the pawn
44
- super({
45
- ...options,
46
- rootComponent,
47
- movementComponent,
48
- camera,
49
- // make sure the directional light follows the player for consistent shadows
50
- enableDirectionalLightFollowing: true,
51
- modelUrl: '@engine/assets/character/mannequinG.glb',
52
- configUrl: '@engine/assets/character/config/mannequin-anim.json',
53
- meshPosition: new THREE.Vector3(0, -ENGINE.CHARACTER_HEIGHT / 2, 0),
54
- meshRotation: new THREE.Euler(0, Math.PI, 0),
55
- meshScale: new THREE.Vector3(1, 1, 1),
56
- });
43
+ this.movementComponent = movementComponent;
44
+ rootComponent.add(camera);
45
+
46
+ this.enableDirectionalLightFollowing = true;
47
+
48
+ // Character model settings
49
+ this.configUrl = '@engine/assets/character/config/mannequin-anim.json';
50
+
51
+ this.meshComponent.position.copy(new THREE.Vector3(0, -ENGINE.CHARACTER_HEIGHT / 2, 0));
52
+ this.meshComponent.rotation.copy(new THREE.Euler(0, Math.PI, 0));
53
+ rootComponent.add(this.meshComponent);
57
54
 
58
55
  // set the pawn to be transient so it's never saved in the level
59
56
  this.setTransient(true);
@@ -28,7 +28,7 @@ export abstract class BaseVehicle extends ENGINE.Pawn {
28
28
 
29
29
  protected setupCamera(): void {
30
30
  // create a follow component for smooth camera movement
31
- const followComponent = new ENGINE.FollowComponent({
31
+ const followComponent = ENGINE.FollowComponent.create({
32
32
  positionOffset: new THREE.Vector3(0, 4, 10),
33
33
  positionDamping: 0.02,
34
34
  lookAtOffset: new THREE.Vector3(0, 0, 0),
@@ -20,14 +20,14 @@ class MyGame extends ENGINE.BaseGameLoop {
20
20
  const position = new THREE.Vector3(0, ENGINE.CHARACTER_HEIGHT / 2, 0);
21
21
 
22
22
  // create the pawn
23
- this.pawn = new VehiclePlayer({ position });
23
+ this.pawn = VehiclePlayer.create({ position });
24
24
 
25
25
  // create the controller and possess the pawn
26
26
  this.controller = new ENGINE.PlayerController();
27
27
  this.controller.possess(this.pawn);
28
28
 
29
29
  // create UI hints
30
- const uiHints = new UIHints();
30
+ const uiHints = UIHints.create();
31
31
 
32
32
  // add all actors to the world
33
33
  this.world.addActors(this.pawn, this.controller, uiHints);
@@ -18,9 +18,10 @@ import { BaseVehicle } from './base-vehicle.js';
18
18
  */
19
19
  @ENGINE.GameClass()
20
20
  export class MeshVehicle extends BaseVehicle {
21
- constructor(options: ENGINE.PawnOptions) {
21
+ constructor() {
22
+ super();
22
23
  // the root component is only used for collision and physics simulation
23
- const rootComponent = new ENGINE.MeshComponent({
24
+ const rootComponent = ENGINE.MeshComponent.create({
24
25
  geometry: new THREE.BoxGeometry(2.77, 1.79, 5.75),
25
26
  material: new THREE.MeshStandardMaterial({
26
27
  color: 0x4444FF,
@@ -37,11 +38,11 @@ export class MeshVehicle extends BaseVehicle {
37
38
  },
38
39
  });
39
40
  rootComponent.name = 'root';
40
- options.rootComponent = rootComponent;
41
+ this.setRootComponent(rootComponent, true);
41
42
  // mark the component as transient, this prevents all the components from being saved since we're recreating them in code
42
43
  rootComponent.setTransient(true);
43
44
 
44
- const chassisComponent = new ENGINE.GLTFMeshComponent({
45
+ const chassisComponent = ENGINE.GLTFMeshComponent.create({
45
46
  modelUrl: '@project/assets/models/cyberTruck/chassis.glb',
46
47
  position: new THREE.Vector3(0, 0, -0.75),
47
48
  material: new THREE.MeshStandardMaterial({
@@ -59,7 +60,7 @@ export class MeshVehicle extends BaseVehicle {
59
60
 
60
61
  const wheelMeshes: ENGINE.GLTFMeshComponent[] = [];
61
62
  for (let i = 0; i < 4; i++) {
62
- const wheelComponent = new ENGINE.GLTFMeshComponent({
63
+ const wheelComponent = ENGINE.GLTFMeshComponent.create({
63
64
  modelUrl: '@project/assets/models/cyberTruck/wheel.glb',
64
65
  material: new THREE.MeshStandardMaterial({
65
66
  color: 0x44FF44,
@@ -77,9 +78,7 @@ export class MeshVehicle extends BaseVehicle {
77
78
  rootComponent.add(...wheelMeshes);
78
79
  const vehicleMovementComponent = MeshVehicle.createVehicleMovementComponent();
79
80
 
80
- options.movementComponent = vehicleMovementComponent;
81
-
82
- super(options);
81
+ this.movementComponent = vehicleMovementComponent;
83
82
 
84
83
  const wheelComponents = this.getComponents(ENGINE.GLTFMeshComponent).filter(component => component.name.startsWith('wheel_'));
85
84
 
@@ -114,8 +113,7 @@ export class MeshVehicle extends BaseVehicle {
114
113
  const frictionSlip = 50;
115
114
 
116
115
  // Create vehicle movement component
117
- const vehicleMovement = new ENGINE.VehicleMovementComponent({
118
- ...ENGINE.BasePawnMovementComponent.DEFAULT_OPTIONS,
116
+ const vehicleMovement = ENGINE.VehicleMovementComponent.create({
119
117
  createWheelMeshes: false,
120
118
  maxEnginePower: 100,
121
119
  maxBrakeForce: 1.5,
@@ -16,8 +16,8 @@ import { BaseVehicle } from './base-vehicle.js';
16
16
  @ENGINE.GameClass()
17
17
  export class VehiclePlayer extends ENGINE.ThirdPersonCharacterPawn {
18
18
  // Omit all the options that are created internally
19
- constructor(options: Omit<ENGINE.ThirdPersonCharacterPawnOptions,
20
- 'rootComponent' | 'movementComponent' | 'camera' | 'modelUrl' | 'configUrl' | 'meshPosition' | 'meshRotation' | 'meshScale'>) {
19
+ constructor() {
20
+ super();
21
21
  // simple camera component - contains a perspective camera by default
22
22
  const camera = new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, 0.1, 1000);
23
23
  // set camera position for third person view
@@ -25,7 +25,7 @@ export class VehiclePlayer extends ENGINE.ThirdPersonCharacterPawn {
25
25
  camera.lookAt(0, 0, 0);
26
26
 
27
27
  // use capsule root component for collision
28
- const rootComponent = new ENGINE.MeshComponent({
28
+ const rootComponent = ENGINE.MeshComponent.create({
29
29
  geometry: ENGINE.GameBuilder.createDefaultPawnCapsuleGeometry(),
30
30
  material: new THREE.MeshStandardMaterial({ color: ENGINE.Color.YELLOW, visible: false, transparent: true, opacity: 0.5 }),
31
31
  physicsOptions: {
@@ -36,26 +36,23 @@ export class VehiclePlayer extends ENGINE.ThirdPersonCharacterPawn {
36
36
  },
37
37
  });
38
38
 
39
+ this.setRootComponent(rootComponent, true);
40
+ this.rootComponent.add(camera);
41
+
39
42
  // use third person movement mechanics
40
- const movementComponent = new ENGINE.CharacterMovementComponent({
41
- ...ENGINE.CharacterMovementComponent.DEFAULT_OPTIONS,
43
+ const movementComponent = ENGINE.CharacterMovementComponent.create({
42
44
  movementType: ENGINE.CharacterMovementType.ThirdPerson,
43
45
  });
44
46
 
45
- // construct the pawn
46
- super({
47
- ...options,
48
- rootComponent,
49
- movementComponent,
50
- camera,
51
- // make sure the directional light follows the player for consistent shadows
52
- enableDirectionalLightFollowing: true,
53
- modelUrl: '@engine/assets/character/mannequinG.glb',
54
- configUrl: '@engine/assets/character/config/mannequin-anim.json',
55
- meshPosition: new THREE.Vector3(0, -ENGINE.CHARACTER_HEIGHT / 2, 0),
56
- meshRotation: new THREE.Euler(0, Math.PI, 0),
57
- meshScale: new THREE.Vector3(1, 1, 1),
58
- });
47
+ this.movementComponent = movementComponent;
48
+
49
+ // Character model settings
50
+ this.enableDirectionalLightFollowing = true;
51
+ this.configUrl = '@engine/assets/character/config/mannequin-anim.json';
52
+
53
+ this.meshComponent.position.copy(new THREE.Vector3(0, -ENGINE.CHARACTER_HEIGHT / 2, 0));
54
+ this.meshComponent.rotation.copy(new THREE.Euler(0, Math.PI, 0));
55
+ rootComponent.add(this.meshComponent);
59
56
 
60
57
  // set the pawn to be transient so it's never saved in the level
61
58
  this.setTransient(true);
@@ -19,10 +19,11 @@ import { BaseVehicle } from './base-vehicle.js';
19
19
  export class PrimitiveVehicle extends BaseVehicle {
20
20
  private tailLightComponents: ENGINE.MeshComponent[] = [];
21
21
 
22
- constructor(options: ENGINE.PawnOptions) {
22
+ constructor() {
23
+ super();
23
24
 
24
25
  // Create chassis mesh
25
- const rootComponent = new ENGINE.MeshComponent({
26
+ const rootComponent = ENGINE.MeshComponent.create({
26
27
  geometry: new THREE.BoxGeometry(2, 1, 4),
27
28
  material: new THREE.MeshStandardMaterial({
28
29
  color: 0x4444FF,
@@ -39,12 +40,10 @@ export class PrimitiveVehicle extends BaseVehicle {
39
40
  rootComponent.name = 'chassis';
40
41
  // mark the component as transient, this prevents all the components from being saved since we're recreating them in code
41
42
  rootComponent.setTransient(true);
42
- options.rootComponent = rootComponent;
43
+ this.setRootComponent(rootComponent, true);
43
44
  // create decorative meshes
44
45
  PrimitiveVehicle.createDecorativeMeshes(rootComponent);
45
- options.movementComponent = PrimitiveVehicle.createVehicleMovementComponent();
46
-
47
- super(options);
46
+ this.movementComponent = PrimitiveVehicle.createVehicleMovementComponent();
48
47
 
49
48
  this.tailLightComponents = this.getComponents(ENGINE.MeshComponent)
50
49
  .filter((component) => component.name.includes('_taillight'));
@@ -76,7 +75,7 @@ export class PrimitiveVehicle extends BaseVehicle {
76
75
 
77
76
  static createDecorativeMeshes(rootComponent: ENGINE.MeshComponent): void {
78
77
  // Add windshield
79
- const windshieldComponent = new ENGINE.MeshComponent({
78
+ const windshieldComponent = ENGINE.MeshComponent.create({
80
79
  geometry: new THREE.BoxGeometry(1.8, 1.8, 0.1),
81
80
  material: new THREE.MeshStandardMaterial({
82
81
  color: 0x87CEEB,
@@ -95,7 +94,7 @@ export class PrimitiveVehicle extends BaseVehicle {
95
94
  rootComponent.add(windshieldComponent);
96
95
 
97
96
  // Add left headlight
98
- const leftHeadlightComponent = new ENGINE.MeshComponent({
97
+ const leftHeadlightComponent = ENGINE.MeshComponent.create({
99
98
  geometry: new THREE.CylinderGeometry(0.15, 0.15, 0.1, 8),
100
99
  material: new THREE.MeshStandardMaterial({
101
100
  color: 0xFFFFFF,
@@ -112,7 +111,7 @@ export class PrimitiveVehicle extends BaseVehicle {
112
111
  rootComponent.add(leftHeadlightComponent);
113
112
 
114
113
  // Add right headlight
115
- const rightHeadlightComponent = new ENGINE.MeshComponent({
114
+ const rightHeadlightComponent = ENGINE.MeshComponent.create({
116
115
  geometry: new THREE.CylinderGeometry(0.15, 0.15, 0.1, 8),
117
116
  material: new THREE.MeshStandardMaterial({
118
117
  color: 0xFFFFFF,
@@ -134,7 +133,7 @@ export class PrimitiveVehicle extends BaseVehicle {
134
133
  emissive: 0x440000,
135
134
  emissiveIntensity: 0.2,
136
135
  });
137
- const leftTaillightComponent = new ENGINE.MeshComponent({
136
+ const leftTaillightComponent = ENGINE.MeshComponent.create({
138
137
  geometry: new THREE.CylinderGeometry(0.1, 0.1, 0.1, 8),
139
138
  material: leftTaillightMaterial,
140
139
  physicsOptions: {
@@ -152,7 +151,7 @@ export class PrimitiveVehicle extends BaseVehicle {
152
151
  emissive: 0x440000,
153
152
  emissiveIntensity: 0.2,
154
153
  });
155
- const rightTaillightComponent = new ENGINE.MeshComponent({
154
+ const rightTaillightComponent = ENGINE.MeshComponent.create({
156
155
  geometry: new THREE.CylinderGeometry(0.1, 0.1, 0.1, 8),
157
156
  material: rightTaillightMaterial,
158
157
  physicsOptions: {
@@ -181,7 +180,6 @@ export class PrimitiveVehicle extends BaseVehicle {
181
180
  const frictionSlip = 8;
182
181
 
183
182
  const options = {
184
- ...ENGINE.BasePawnMovementComponent.DEFAULT_OPTIONS,
185
183
  maxEnginePower: 35,
186
184
  maxSteeringAngle: Math.PI / 6, // 30 degrees
187
185
  maxBrakeForce: 1,
@@ -261,6 +259,6 @@ export class PrimitiveVehicle extends BaseVehicle {
261
259
  ],
262
260
  };
263
261
 
264
- return new ENGINE.VehicleMovementComponent(options);
262
+ return ENGINE.VehicleMovementComponent.create(options);
265
263
  }
266
264
  }
@@ -7,8 +7,8 @@ import * as ENGINE from '@directivegames/genesys.js';
7
7
  export class UIHints extends ENGINE.Actor {
8
8
  private uiElement: ENGINE.UIElement | null = null;
9
9
 
10
- constructor(options: ENGINE.ActorOptions = {}) {
11
- super(options);
10
+ constructor() {
11
+ super();
12
12
  this.setTransient(true); // Don't save this UI element to the level
13
13
  }
14
14
 
@@ -29,7 +29,7 @@ class MyGame extends ENGINE.BaseGameLoop {
29
29
  this.world.postProcessManager.disablePasses(ENGINE.PostProcessPass.ToneMapping);
30
30
 
31
31
  // create the vr pawn
32
- this.pawn = new ENGINE.VRPawn({
32
+ this.pawn = ENGINE.VRPawn.create({
33
33
  position: new THREE.Vector3(0, 0, 0),
34
34
  movementComponent: null,
35
35
  camera: new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, ENGINE.CAMERA_NEAR, ENGINE.CAMERA_FAR),
@@ -47,10 +47,10 @@ class MyGame extends ENGINE.BaseGameLoop {
47
47
  this.controller = new ENGINE.PlayerController();
48
48
  this.controller.possess(this.pawn);
49
49
 
50
- this.pawn.addComponent(new ENGINE.VRGrabComponent({}));
51
- this.pawn.addComponent(new ENGINE.VRSnapTurnComponent({ angleDeg: this.pawn.getSnapTurnAngleDegrees() }));
52
- this.pawn.addComponent(new ENGINE.VRInteractComponent({ button: ENGINE.XRButton.Trigger }));
53
- this.pawn.addComponent(new ENGINE.VRTeleportComponent({ maxDistance: 15 }));
50
+ this.pawn.addComponent(ENGINE.VRGrabComponent.create());
51
+ this.pawn.addComponent(ENGINE.VRSnapTurnComponent.create({ angleDeg: this.pawn.getSnapTurnAngleDegrees() }));
52
+ this.pawn.addComponent(ENGINE.VRInteractComponent.create({ button: ENGINE.XRButton.Trigger }));
53
+ this.pawn.addComponent(ENGINE.VRTeleportComponent.create({ maxDistance: 15 }));
54
54
 
55
55
  // add both to the world
56
56
  this.world.addActors(this.pawn, this.controller);