@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
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
import { BaseVehicle } from './base-vehicle.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A vehicle that uses a 3D mesh model for visual representation
|
|
8
|
+
*
|
|
9
|
+
* Key points:
|
|
10
|
+
* - Uses invisible collision box for physics simulation (separate from visual mesh)
|
|
11
|
+
* - Loads GLB model for visual representation via GLTFMeshComponent
|
|
12
|
+
* - Movement parameters configured in createVehicleMovementComponent
|
|
13
|
+
* - No component is persisted (root is transient) in order to support recreating all the components in code (which is desired)
|
|
14
|
+
* - Do not create the builtin wheel mesh since the GLB models are used instead (createWheelMeshes = false)
|
|
15
|
+
* - Visual mesh is positioned and scaled to match collision box
|
|
16
|
+
* - Wheel mesh transforms are updated using the onWheelUpdated delegate
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
@ENGINE.GameClass()
|
|
20
|
+
export class MeshVehicle extends BaseVehicle {
|
|
21
|
+
constructor(options: ENGINE.PawnOptions) {
|
|
22
|
+
// the root component is only used for collision and physics simulation
|
|
23
|
+
const rootComponent = new ENGINE.MeshComponent({
|
|
24
|
+
geometry: new THREE.BoxGeometry(2.77, 1.79, 5.75),
|
|
25
|
+
material: new THREE.MeshStandardMaterial({
|
|
26
|
+
color: 0x4444FF,
|
|
27
|
+
roughness: 0.7,
|
|
28
|
+
metalness: 0.3,
|
|
29
|
+
visible: false,
|
|
30
|
+
transparent: true,
|
|
31
|
+
opacity: 0.5,
|
|
32
|
+
}),
|
|
33
|
+
physicsOptions: {
|
|
34
|
+
enabled: true,
|
|
35
|
+
motionType: ENGINE.PhysicsMotionType.Dynamic,
|
|
36
|
+
generateCollisionEvents: true,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
rootComponent.name = 'root';
|
|
40
|
+
options.rootComponent = rootComponent;
|
|
41
|
+
// mark the component as transient, this prevents all the components from being saved since we're recreating them in code
|
|
42
|
+
rootComponent.setTransient(true);
|
|
43
|
+
|
|
44
|
+
const chassisComponent = new ENGINE.GLTFMeshComponent({
|
|
45
|
+
modelUrl: '@project/assets/models/cyberTruck/chassis.glb',
|
|
46
|
+
position: new THREE.Vector3(0, 0, -0.75),
|
|
47
|
+
material: new THREE.MeshStandardMaterial({
|
|
48
|
+
color: 0x4444FF,
|
|
49
|
+
roughness: 0.7,
|
|
50
|
+
metalness: 0.3,
|
|
51
|
+
}),
|
|
52
|
+
physicsOptions: {
|
|
53
|
+
enabled: false,
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
chassisComponent.castShadow = true;
|
|
57
|
+
chassisComponent.name = 'chassis';
|
|
58
|
+
rootComponent.add(chassisComponent);
|
|
59
|
+
|
|
60
|
+
const wheelMeshes: ENGINE.GLTFMeshComponent[] = [];
|
|
61
|
+
for (let i = 0; i < 4; i++) {
|
|
62
|
+
const wheelComponent = new ENGINE.GLTFMeshComponent({
|
|
63
|
+
modelUrl: '@project/assets/models/cyberTruck/wheel.glb',
|
|
64
|
+
material: new THREE.MeshStandardMaterial({
|
|
65
|
+
color: 0x44FF44,
|
|
66
|
+
roughness: 0.7,
|
|
67
|
+
metalness: 0.3,
|
|
68
|
+
}),
|
|
69
|
+
physicsOptions: {
|
|
70
|
+
enabled: false,
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
wheelComponent.castShadow = true;
|
|
74
|
+
wheelComponent.name = `wheel_${i}`;
|
|
75
|
+
wheelMeshes.push(wheelComponent);
|
|
76
|
+
}
|
|
77
|
+
rootComponent.add(...wheelMeshes);
|
|
78
|
+
const vehicleMovementComponent = MeshVehicle.createVehicleMovementComponent();
|
|
79
|
+
|
|
80
|
+
options.movementComponent = vehicleMovementComponent;
|
|
81
|
+
|
|
82
|
+
super(options);
|
|
83
|
+
|
|
84
|
+
const wheelComponents = this.getComponents(ENGINE.GLTFMeshComponent).filter(component => component.name.startsWith('wheel_'));
|
|
85
|
+
|
|
86
|
+
vehicleMovementComponent.onWheelUpdated.add((component, wheelIndex, wheelState) => {
|
|
87
|
+
// The first mesh component is the chassis component, so we need to skip it
|
|
88
|
+
const wheelMesh = wheelComponents[wheelIndex];
|
|
89
|
+
|
|
90
|
+
// Apply the final transformation to the wheel mesh
|
|
91
|
+
wheelMesh.position.copy(wheelState.relativePosition);
|
|
92
|
+
wheelMesh.quaternion.copy(wheelState.relativeQuaternion);
|
|
93
|
+
|
|
94
|
+
// Apply additional 180-degree rotation around Y-axis for wheels 0 and 2
|
|
95
|
+
if (wheelIndex === 0 || wheelIndex === 2) {
|
|
96
|
+
const yRotation = new THREE.Quaternion();
|
|
97
|
+
yRotation.setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI);
|
|
98
|
+
wheelMesh.quaternion.multiplyQuaternions(wheelMesh.quaternion, yRotation);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static createVehicleMovementComponent(): ENGINE.VehicleMovementComponent {
|
|
104
|
+
const wheelBaseWidth = 3.2;
|
|
105
|
+
const wheelBaseLength = 3.8;
|
|
106
|
+
const wheelBaseHeight = -0.5;
|
|
107
|
+
const wheelRadius = 0.55;
|
|
108
|
+
const suspensionRestLength = 0.8;
|
|
109
|
+
const wheelWidth = 0.53;
|
|
110
|
+
const suspensionStiffness = 20;
|
|
111
|
+
const suspensionCompression = 1.83;
|
|
112
|
+
const suspensionRelaxation = 1.88;
|
|
113
|
+
const sideFrictionStiffness = 2;
|
|
114
|
+
const frictionSlip = 50;
|
|
115
|
+
|
|
116
|
+
// Create vehicle movement component
|
|
117
|
+
const vehicleMovement = new ENGINE.VehicleMovementComponent({
|
|
118
|
+
...ENGINE.BasePawnMovementComponent.DEFAULT_OPTIONS,
|
|
119
|
+
createWheelMeshes: false,
|
|
120
|
+
maxEnginePower: 100,
|
|
121
|
+
maxBrakeForce: 1.5,
|
|
122
|
+
maxSteeringAngle: Math.PI / 6, // 30 degrees
|
|
123
|
+
engineResponseRate: 8.0,
|
|
124
|
+
steeringResponseRate: 12.0,
|
|
125
|
+
brakeResponseRate: 15.0,
|
|
126
|
+
wheelMaterialColor: 0x333333,
|
|
127
|
+
autoBreakWhenNotPossessed: 1,
|
|
128
|
+
autoStopBreak: 1,
|
|
129
|
+
wheels: [
|
|
130
|
+
// Default 4-wheel configuration
|
|
131
|
+
{
|
|
132
|
+
position: new THREE.Vector3(-wheelBaseWidth / 2, wheelBaseHeight, -wheelBaseLength / 2), // Front left
|
|
133
|
+
radius: wheelRadius,
|
|
134
|
+
width: wheelWidth,
|
|
135
|
+
canSteer: true,
|
|
136
|
+
isPowered: false,
|
|
137
|
+
canBrake: true,
|
|
138
|
+
suspensionRestLength,
|
|
139
|
+
suspensionStiffness,
|
|
140
|
+
suspensionCompression,
|
|
141
|
+
suspensionRelaxation,
|
|
142
|
+
sideFrictionStiffness,
|
|
143
|
+
frictionSlip,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
position: new THREE.Vector3(wheelBaseWidth / 2, wheelBaseHeight, -wheelBaseLength / 2), // Front right
|
|
147
|
+
radius: wheelRadius,
|
|
148
|
+
width: wheelWidth,
|
|
149
|
+
canSteer: true,
|
|
150
|
+
isPowered: false,
|
|
151
|
+
canBrake: true,
|
|
152
|
+
suspensionRestLength,
|
|
153
|
+
suspensionStiffness,
|
|
154
|
+
suspensionCompression,
|
|
155
|
+
suspensionRelaxation,
|
|
156
|
+
sideFrictionStiffness,
|
|
157
|
+
frictionSlip,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
position: new THREE.Vector3(-wheelBaseWidth / 2, wheelBaseHeight, wheelBaseLength / 2), // Rear left
|
|
161
|
+
radius: wheelRadius,
|
|
162
|
+
width: wheelWidth,
|
|
163
|
+
canSteer: false,
|
|
164
|
+
isPowered: true,
|
|
165
|
+
canBrake: true,
|
|
166
|
+
suspensionRestLength,
|
|
167
|
+
suspensionStiffness,
|
|
168
|
+
suspensionCompression,
|
|
169
|
+
suspensionRelaxation,
|
|
170
|
+
sideFrictionStiffness,
|
|
171
|
+
frictionSlip,
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
position: new THREE.Vector3(wheelBaseWidth / 2, wheelBaseHeight, wheelBaseLength / 2), // Rear right
|
|
175
|
+
radius: wheelRadius,
|
|
176
|
+
width: wheelWidth,
|
|
177
|
+
canSteer: false,
|
|
178
|
+
isPowered: true,
|
|
179
|
+
canBrake: true,
|
|
180
|
+
suspensionRestLength,
|
|
181
|
+
suspensionStiffness,
|
|
182
|
+
suspensionCompression,
|
|
183
|
+
suspensionRelaxation,
|
|
184
|
+
sideFrictionStiffness,
|
|
185
|
+
frictionSlip,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
return vehicleMovement;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
import { BaseVehicle } from './base-vehicle.js';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A vehicle player class.
|
|
9
|
+
*
|
|
10
|
+
* Key points:
|
|
11
|
+
* - No need to provide movementComponent and camera, they are created internally
|
|
12
|
+
* - The pawn is set to be transient so it's never saved in the level
|
|
13
|
+
* - The directional light follows the player for consistent shadows
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
@ENGINE.GameClass()
|
|
17
|
+
export class VehiclePlayer extends ENGINE.ThirdPersonCharacterPawn {
|
|
18
|
+
// Omit all the options that are created internally
|
|
19
|
+
constructor(options: Omit<ENGINE.ThirdPersonCharacterPawnOptions,
|
|
20
|
+
'rootComponent' | 'movementComponent' | 'camera' | 'modelUrl' | 'configUrl' | 'meshPosition' | 'meshRotation' | 'meshScale'>) {
|
|
21
|
+
// simple camera component - contains a perspective camera by default
|
|
22
|
+
const camera = new THREE.PerspectiveCamera(ENGINE.CAMERA_FOV, 1, 0.1, 1000);
|
|
23
|
+
// set camera position for third person view
|
|
24
|
+
camera.position.set(0, ENGINE.CHARACTER_HEIGHT * 1.3, ENGINE.CHARACTER_HEIGHT * 2);
|
|
25
|
+
camera.lookAt(0, 0, 0);
|
|
26
|
+
|
|
27
|
+
// use capsule root component for collision
|
|
28
|
+
const rootComponent = new ENGINE.MeshComponent({
|
|
29
|
+
geometry: ENGINE.GameBuilder.createDefaultPawnCapsuleGeometry(),
|
|
30
|
+
material: new THREE.MeshStandardMaterial({ color: ENGINE.Color.YELLOW, visible: false, transparent: true, opacity: 0.5 }),
|
|
31
|
+
physicsOptions: {
|
|
32
|
+
enabled: true,
|
|
33
|
+
// KinematicVelocityBased is required to use the physics character controller
|
|
34
|
+
motionType: ENGINE.PhysicsMotionType.KinematicVelocityBased,
|
|
35
|
+
collisionProfile: ENGINE.DefaultCollisionProfile.Character,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// use third person movement mechanics
|
|
40
|
+
const movementComponent = new ENGINE.CharacterMovementComponent({
|
|
41
|
+
...ENGINE.CharacterMovementComponent.DEFAULT_OPTIONS,
|
|
42
|
+
movementType: ENGINE.CharacterMovementType.ThirdPerson,
|
|
43
|
+
});
|
|
44
|
+
|
|
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
|
+
});
|
|
59
|
+
|
|
60
|
+
// set the pawn to be transient so it's never saved in the level
|
|
61
|
+
this.setTransient(true);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected override async doBeginPlay(): Promise<void> {
|
|
65
|
+
await super.doBeginPlay();
|
|
66
|
+
this.setupVehicleInteraction();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected setupVehicleInteraction(): void {
|
|
70
|
+
// Add E key input handler for vehicle possession
|
|
71
|
+
this.onKeyDown.add((e: KeyboardEvent) => {
|
|
72
|
+
if (e.key.toLowerCase() === 'e') {
|
|
73
|
+
this.tryEnterVehicle();
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected tryEnterVehicle(): void {
|
|
81
|
+
// Find nearby vehicles that can be entered
|
|
82
|
+
const vehicles = this.world!.getActors(BaseVehicle);
|
|
83
|
+
|
|
84
|
+
for (const vehicle of vehicles) {
|
|
85
|
+
if (vehicle.canBeEntered() && vehicle.getNearbyPlayer() === this) {
|
|
86
|
+
this.enterVehicle(vehicle);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected enterVehicle(vehicle: BaseVehicle): void {
|
|
93
|
+
// Get the current player controller
|
|
94
|
+
const controller = this.getPlayerController();
|
|
95
|
+
|
|
96
|
+
if (controller) {
|
|
97
|
+
// Set this player as the entered player in the vehicle
|
|
98
|
+
vehicle.setEnteredPlayer(this);
|
|
99
|
+
|
|
100
|
+
// Unpossess current pawn and possess the vehicle
|
|
101
|
+
controller.unpossess();
|
|
102
|
+
controller.possess(vehicle);
|
|
103
|
+
|
|
104
|
+
// Hide the player character
|
|
105
|
+
this.rootComponent.visible = false;
|
|
106
|
+
this.rootComponent.setPhysicsEnabled(false);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
import { BaseVehicle } from './base-vehicle.js';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A simple vehicle with a box geometry
|
|
9
|
+
*
|
|
10
|
+
* Key points:
|
|
11
|
+
* - Movement parameters configured in createVehicleMovementComponent
|
|
12
|
+
* - No component is persisted (root is transient) in order to support recreating all the components in code (which is desired)
|
|
13
|
+
* - Rely on the builtin feature to create the wheel mesh (createWheelMeshes = true), no need to create them manually
|
|
14
|
+
* - All decorative meshes have physics disabled won't mess with the handling
|
|
15
|
+
* - Find the tail light meshes after the constructor so it works with deserialized actor
|
|
16
|
+
* - Rely on the base vehicle class to handle the camera and player interaction
|
|
17
|
+
*/
|
|
18
|
+
@ENGINE.GameClass()
|
|
19
|
+
export class PrimitiveVehicle extends BaseVehicle {
|
|
20
|
+
private tailLightComponents: ENGINE.MeshComponent[] = [];
|
|
21
|
+
|
|
22
|
+
constructor(options: ENGINE.PawnOptions) {
|
|
23
|
+
|
|
24
|
+
// Create chassis mesh
|
|
25
|
+
const rootComponent = new ENGINE.MeshComponent({
|
|
26
|
+
geometry: new THREE.BoxGeometry(2, 1, 4),
|
|
27
|
+
material: new THREE.MeshStandardMaterial({
|
|
28
|
+
color: 0x4444FF,
|
|
29
|
+
roughness: 0.7,
|
|
30
|
+
metalness: 0.3,
|
|
31
|
+
}),
|
|
32
|
+
physicsOptions: {
|
|
33
|
+
enabled: true,
|
|
34
|
+
motionType: ENGINE.PhysicsMotionType.Dynamic,
|
|
35
|
+
generateCollisionEvents: true,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
rootComponent.castShadow = true;
|
|
39
|
+
rootComponent.name = 'chassis';
|
|
40
|
+
// mark the component as transient, this prevents all the components from being saved since we're recreating them in code
|
|
41
|
+
rootComponent.setTransient(true);
|
|
42
|
+
options.rootComponent = rootComponent;
|
|
43
|
+
// create decorative meshes
|
|
44
|
+
PrimitiveVehicle.createDecorativeMeshes(rootComponent);
|
|
45
|
+
options.movementComponent = PrimitiveVehicle.createVehicleMovementComponent();
|
|
46
|
+
|
|
47
|
+
super(options);
|
|
48
|
+
|
|
49
|
+
this.tailLightComponents = this.getComponents(ENGINE.MeshComponent)
|
|
50
|
+
.filter((component) => component.name.includes('_taillight'));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public override tickPrePhysics(deltaTime: number): void {
|
|
54
|
+
super.tickPrePhysics(deltaTime);
|
|
55
|
+
this.updateBrakeLights();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private updateBrakeLights(): void {
|
|
59
|
+
if (!this.movementComponent || this.tailLightComponents.length === 0) return;
|
|
60
|
+
|
|
61
|
+
const inputState = this.movementComponent.getInputState() as ENGINE.VehicleMovementInputState;
|
|
62
|
+
const isBraking = inputState.brakeInput > 0;
|
|
63
|
+
|
|
64
|
+
for (const tailLightComponent of this.tailLightComponents) {
|
|
65
|
+
const mesh = tailLightComponent.getMesh();
|
|
66
|
+
if (mesh && mesh.material) {
|
|
67
|
+
const material = mesh.material as THREE.MeshStandardMaterial;
|
|
68
|
+
if (isBraking) {
|
|
69
|
+
material.color.setHex(0xFF0000);
|
|
70
|
+
} else {
|
|
71
|
+
material.color.setHex(0xFFFFFF);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static createDecorativeMeshes(rootComponent: ENGINE.MeshComponent): void {
|
|
78
|
+
// Add windshield
|
|
79
|
+
const windshieldComponent = new ENGINE.MeshComponent({
|
|
80
|
+
geometry: new THREE.BoxGeometry(1.8, 1.8, 0.1),
|
|
81
|
+
material: new THREE.MeshStandardMaterial({
|
|
82
|
+
color: 0x87CEEB,
|
|
83
|
+
transparent: true,
|
|
84
|
+
opacity: 0.5,
|
|
85
|
+
roughness: 0.1,
|
|
86
|
+
metalness: 0.1,
|
|
87
|
+
}),
|
|
88
|
+
physicsOptions: {
|
|
89
|
+
enabled: false,
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
windshieldComponent.position.set(0, 0.4, -1.5);
|
|
93
|
+
windshieldComponent.rotation.x = Math.PI / 8; // Slight tilt
|
|
94
|
+
windshieldComponent.name = 'windshield';
|
|
95
|
+
rootComponent.add(windshieldComponent);
|
|
96
|
+
|
|
97
|
+
// Add left headlight
|
|
98
|
+
const leftHeadlightComponent = new ENGINE.MeshComponent({
|
|
99
|
+
geometry: new THREE.CylinderGeometry(0.15, 0.15, 0.1, 8),
|
|
100
|
+
material: new THREE.MeshStandardMaterial({
|
|
101
|
+
color: 0xFFFFFF,
|
|
102
|
+
emissive: 0xFFFFAA,
|
|
103
|
+
emissiveIntensity: 0.3,
|
|
104
|
+
}),
|
|
105
|
+
physicsOptions: {
|
|
106
|
+
enabled: false,
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
leftHeadlightComponent.position.set(-0.7, 0.1, -2.05);
|
|
110
|
+
leftHeadlightComponent.rotation.z = Math.PI / 2;
|
|
111
|
+
leftHeadlightComponent.name = 'left_headlight';
|
|
112
|
+
rootComponent.add(leftHeadlightComponent);
|
|
113
|
+
|
|
114
|
+
// Add right headlight
|
|
115
|
+
const rightHeadlightComponent = new ENGINE.MeshComponent({
|
|
116
|
+
geometry: new THREE.CylinderGeometry(0.15, 0.15, 0.1, 8),
|
|
117
|
+
material: new THREE.MeshStandardMaterial({
|
|
118
|
+
color: 0xFFFFFF,
|
|
119
|
+
emissive: 0xFFFFAA,
|
|
120
|
+
emissiveIntensity: 0.3,
|
|
121
|
+
}),
|
|
122
|
+
physicsOptions: {
|
|
123
|
+
enabled: false,
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
rightHeadlightComponent.position.set(0.7, 0.1, -2.05);
|
|
127
|
+
rightHeadlightComponent.rotation.z = Math.PI / 2;
|
|
128
|
+
rightHeadlightComponent.name = 'right_headlight';
|
|
129
|
+
rootComponent.add(rightHeadlightComponent);
|
|
130
|
+
|
|
131
|
+
// Add left tail light
|
|
132
|
+
const leftTaillightMaterial = new THREE.MeshStandardMaterial({
|
|
133
|
+
color: 0xFF0000,
|
|
134
|
+
emissive: 0x440000,
|
|
135
|
+
emissiveIntensity: 0.2,
|
|
136
|
+
});
|
|
137
|
+
const leftTaillightComponent = new ENGINE.MeshComponent({
|
|
138
|
+
geometry: new THREE.CylinderGeometry(0.1, 0.1, 0.1, 8),
|
|
139
|
+
material: leftTaillightMaterial,
|
|
140
|
+
physicsOptions: {
|
|
141
|
+
enabled: false,
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
leftTaillightComponent.position.set(-0.7, 0.1, 2.05);
|
|
145
|
+
leftTaillightComponent.rotation.z = Math.PI / 2;
|
|
146
|
+
leftTaillightComponent.name = 'left_taillight';
|
|
147
|
+
rootComponent.add(leftTaillightComponent);
|
|
148
|
+
|
|
149
|
+
// Add right tail light
|
|
150
|
+
const rightTaillightMaterial = new THREE.MeshStandardMaterial({
|
|
151
|
+
color: 0xFF0000,
|
|
152
|
+
emissive: 0x440000,
|
|
153
|
+
emissiveIntensity: 0.2,
|
|
154
|
+
});
|
|
155
|
+
const rightTaillightComponent = new ENGINE.MeshComponent({
|
|
156
|
+
geometry: new THREE.CylinderGeometry(0.1, 0.1, 0.1, 8),
|
|
157
|
+
material: rightTaillightMaterial,
|
|
158
|
+
physicsOptions: {
|
|
159
|
+
enabled: false,
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
rightTaillightComponent.position.set(0.7, 0.1, 2.05);
|
|
163
|
+
rightTaillightComponent.rotation.z = Math.PI / 2;
|
|
164
|
+
rightTaillightComponent.name = 'right_taillight';
|
|
165
|
+
rootComponent.add(rightTaillightComponent);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static createVehicleMovementComponent(): ENGINE.VehicleMovementComponent {
|
|
169
|
+
const wheelBaseWidth = 2.6;
|
|
170
|
+
const wheelBaseLength = 3.0;
|
|
171
|
+
const wheelBaseHeight = 0;
|
|
172
|
+
const suspensionRestLength = 0.6;
|
|
173
|
+
const wheelRadius = 0.5;
|
|
174
|
+
const wheelWidth = 0.4;
|
|
175
|
+
const suspensionStiffness = 20;
|
|
176
|
+
const suspensionCompression = 0.83;
|
|
177
|
+
const suspensionRelaxation = 0.88;
|
|
178
|
+
const maxSuspensionForce = 6000.0;
|
|
179
|
+
const maxSuspensionTravel = 5.0;
|
|
180
|
+
const sideFrictionStiffness = 2;
|
|
181
|
+
const frictionSlip = 8;
|
|
182
|
+
|
|
183
|
+
const options = {
|
|
184
|
+
...ENGINE.BasePawnMovementComponent.DEFAULT_OPTIONS,
|
|
185
|
+
maxEnginePower: 35,
|
|
186
|
+
maxSteeringAngle: Math.PI / 6, // 30 degrees
|
|
187
|
+
maxBrakeForce: 1,
|
|
188
|
+
engineResponseRate: 8.0,
|
|
189
|
+
steeringResponseRate: 12.0,
|
|
190
|
+
brakeResponseRate: 15.0,
|
|
191
|
+
createWheelMeshes: true,
|
|
192
|
+
wheelMaterialColor: 0x333333,
|
|
193
|
+
autoBreakWhenNotPossessed: 1,
|
|
194
|
+
autoStopBreak: 0.5,
|
|
195
|
+
wheels: [
|
|
196
|
+
// Default 4-wheel configuration
|
|
197
|
+
{
|
|
198
|
+
position: new THREE.Vector3(-wheelBaseWidth / 2, wheelBaseHeight, -wheelBaseLength / 2), // Front left
|
|
199
|
+
radius: wheelRadius,
|
|
200
|
+
width: wheelWidth,
|
|
201
|
+
canSteer: true,
|
|
202
|
+
isPowered: false,
|
|
203
|
+
canBrake: true,
|
|
204
|
+
suspensionRestLength,
|
|
205
|
+
suspensionStiffness,
|
|
206
|
+
suspensionCompression,
|
|
207
|
+
suspensionRelaxation,
|
|
208
|
+
maxSuspensionForce,
|
|
209
|
+
maxSuspensionTravel,
|
|
210
|
+
sideFrictionStiffness,
|
|
211
|
+
frictionSlip,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
position: new THREE.Vector3(wheelBaseWidth / 2, wheelBaseHeight, -wheelBaseLength / 2), // Front right
|
|
215
|
+
radius: wheelRadius,
|
|
216
|
+
width: wheelWidth,
|
|
217
|
+
canSteer: true,
|
|
218
|
+
isPowered: false,
|
|
219
|
+
canBrake: true,
|
|
220
|
+
suspensionRestLength,
|
|
221
|
+
suspensionStiffness,
|
|
222
|
+
suspensionCompression,
|
|
223
|
+
suspensionRelaxation,
|
|
224
|
+
maxSuspensionForce,
|
|
225
|
+
maxSuspensionTravel,
|
|
226
|
+
sideFrictionStiffness,
|
|
227
|
+
frictionSlip,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
position: new THREE.Vector3(-wheelBaseWidth / 2, wheelBaseHeight, wheelBaseLength / 2), // Rear left
|
|
231
|
+
radius: wheelRadius,
|
|
232
|
+
width: wheelWidth,
|
|
233
|
+
canSteer: false,
|
|
234
|
+
isPowered: true,
|
|
235
|
+
canBrake: true,
|
|
236
|
+
suspensionRestLength,
|
|
237
|
+
suspensionStiffness,
|
|
238
|
+
suspensionCompression,
|
|
239
|
+
suspensionRelaxation,
|
|
240
|
+
maxSuspensionForce,
|
|
241
|
+
maxSuspensionTravel,
|
|
242
|
+
sideFrictionStiffness,
|
|
243
|
+
frictionSlip,
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
position: new THREE.Vector3(wheelBaseWidth / 2, wheelBaseHeight, wheelBaseLength / 2), // Rear right
|
|
247
|
+
radius: wheelRadius,
|
|
248
|
+
width: wheelWidth,
|
|
249
|
+
canSteer: false,
|
|
250
|
+
isPowered: true,
|
|
251
|
+
canBrake: true,
|
|
252
|
+
suspensionRestLength,
|
|
253
|
+
suspensionStiffness,
|
|
254
|
+
suspensionCompression,
|
|
255
|
+
suspensionRelaxation,
|
|
256
|
+
maxSuspensionForce,
|
|
257
|
+
maxSuspensionTravel,
|
|
258
|
+
sideFrictionStiffness,
|
|
259
|
+
frictionSlip,
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
return new ENGINE.VehicleMovementComponent(options);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dismissable UI component that displays control hints when the game starts
|
|
5
|
+
*/
|
|
6
|
+
@ENGINE.GameClass()
|
|
7
|
+
export class UIHints extends ENGINE.Actor {
|
|
8
|
+
private uiElement: ENGINE.UIElement | null = null;
|
|
9
|
+
|
|
10
|
+
constructor(options: ENGINE.ActorOptions = {}) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.setTransient(true); // Don't save this UI element to the level
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected override async doBeginPlay(): Promise<void> {
|
|
16
|
+
await super.doBeginPlay();
|
|
17
|
+
this.createHUD();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected override doEndPlay(): void {
|
|
21
|
+
this.removeHUD();
|
|
22
|
+
super.doEndPlay();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private createHUD(): void {
|
|
26
|
+
const uiManager = this.world!.uiManager;
|
|
27
|
+
|
|
28
|
+
// Create the UI element using the engine's UI system
|
|
29
|
+
this.uiElement = uiManager.createElement('game-hints', {
|
|
30
|
+
style: {
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
top: '50px',
|
|
33
|
+
right: '50px',
|
|
34
|
+
background: 'rgba(0, 0, 0, 0.9)',
|
|
35
|
+
color: 'white',
|
|
36
|
+
padding: '25px',
|
|
37
|
+
borderRadius: '12px',
|
|
38
|
+
fontFamily: 'Arial, sans-serif',
|
|
39
|
+
fontSize: '16px',
|
|
40
|
+
lineHeight: '1.5',
|
|
41
|
+
maxWidth: '400px',
|
|
42
|
+
border: '2px solid rgba(76, 175, 80, 0.6)',
|
|
43
|
+
boxShadow: '0 8px 32px rgba(0, 0, 0, 0.8)',
|
|
44
|
+
zIndex: '1001'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Set the HTML content
|
|
49
|
+
this.uiElement.setHTML(`
|
|
50
|
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
|
|
51
|
+
<div style="font-weight: bold; color: #4CAF50; font-size: 18px;">
|
|
52
|
+
🎮 Vehicle Game Controls
|
|
53
|
+
</div>
|
|
54
|
+
<button id="closeHints" style="
|
|
55
|
+
background: #f44336;
|
|
56
|
+
color: white;
|
|
57
|
+
border: none;
|
|
58
|
+
border-radius: 50%;
|
|
59
|
+
width: 30px;
|
|
60
|
+
height: 30px;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
font-size: 16px;
|
|
63
|
+
font-weight: bold;
|
|
64
|
+
">×</button>
|
|
65
|
+
</div>
|
|
66
|
+
<div style="margin-bottom: 12px;">
|
|
67
|
+
<span style="color: #FFA726; font-weight: bold;">Movement:</span>
|
|
68
|
+
<br>• WASD or Arrow Keys - Move/Drive
|
|
69
|
+
<br>• Mouse - Camera control
|
|
70
|
+
</div>
|
|
71
|
+
<div style="margin-bottom: 12px;">
|
|
72
|
+
<span style="color: #FFA726; font-weight: bold;">Vehicle Interaction:</span>
|
|
73
|
+
<br>• E - Enter/Exit vehicle (when nearby)
|
|
74
|
+
<br>• F - Flip vehicle (when inside)
|
|
75
|
+
</div>
|
|
76
|
+
<div style="font-size: 14px; color: #CCCCCC; margin-top: 15px; text-align: center; font-style: italic;">
|
|
77
|
+
💡 Walk near a vehicle and press E to enter
|
|
78
|
+
</div>
|
|
79
|
+
`);
|
|
80
|
+
|
|
81
|
+
// Add close button functionality
|
|
82
|
+
const closeButton = this.uiElement.querySelector('#closeHints') as HTMLButtonElement;
|
|
83
|
+
if (closeButton) {
|
|
84
|
+
closeButton.addEventListener('click', () => {
|
|
85
|
+
this.removeHUD();
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Auto-close after 10 seconds
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
this.removeHUD();
|
|
92
|
+
}, 10000);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private removeHUD(): void {
|
|
96
|
+
if (this.uiElement) {
|
|
97
|
+
this.uiElement.remove();
|
|
98
|
+
this.uiElement = null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|