@directivegames/genesys.sdk 3.2.2 → 3.2.4
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 -60
- package/dist/src/core/cli.js +22 -22
- package/dist/src/templates/scripts/genesys/genesys-mcp.js +25 -25
- package/dist/src/templates/scripts/genesys/mcp/editor-functions.js +4 -4
- package/dist/src/templates/src/templates/vehicle/src/ui-hints.js +30 -30
- package/package.json +176 -176
- package/scripts/post-install.ts +143 -143
- package/src/asset-pack/.gitattributes +88 -88
- package/src/asset-pack/eslint.config.js +45 -45
- package/src/asset-pack/gitignore +11 -11
- package/src/asset-pack/scripts/postinstall.ts +81 -81
- package/src/asset-pack/tsconfig.json +33 -33
- package/src/templates/.cursor/mcp.json +20 -20
- package/src/templates/.cursorignore +2 -2
- package/src/templates/.gitattributes +88 -88
- package/src/templates/.vscode/settings.json +6 -6
- package/src/templates/AGENTS.md +86 -86
- package/src/templates/README.md +24 -24
- package/src/templates/eslint.config.js +45 -45
- package/src/templates/gitignore +11 -11
- package/src/templates/index.html +34 -34
- package/src/templates/pnpm-lock.yaml +3676 -3676
- package/src/templates/scripts/genesys/build-project.ts +51 -51
- package/src/templates/scripts/genesys/calc-bounding-box.ts +272 -272
- package/src/templates/scripts/genesys/common.ts +46 -46
- package/src/templates/scripts/genesys/const.ts +9 -9
- package/src/templates/scripts/genesys/dev/dump-default-scene.ts +11 -11
- package/src/templates/scripts/genesys/dev/generate-manifest.ts +146 -146
- package/src/templates/scripts/genesys/dev/launcher.ts +46 -46
- package/src/templates/scripts/genesys/dev/storage-provider.ts +229 -229
- package/src/templates/scripts/genesys/dev/update-template-scenes.ts +84 -84
- package/src/templates/scripts/genesys/doc-server.ts +16 -16
- package/src/templates/scripts/genesys/genesys-mcp.ts +526 -526
- package/src/templates/scripts/genesys/mcp/doc-tools.ts +86 -86
- package/src/templates/scripts/genesys/mcp/editor-functions.ts +151 -151
- package/src/templates/scripts/genesys/mcp/editor-tools.ts +73 -73
- package/src/templates/scripts/genesys/mcp/get-scene-state.ts +35 -35
- package/src/templates/scripts/genesys/mcp/run-subprocess.ts +30 -30
- package/src/templates/scripts/genesys/mcp/search-actors.ts +858 -858
- package/src/templates/scripts/genesys/mcp/search-assets.ts +380 -380
- package/src/templates/scripts/genesys/mcp/utils.ts +281 -281
- package/src/templates/scripts/genesys/misc.ts +42 -42
- package/src/templates/scripts/genesys/mock.ts +6 -6
- package/src/templates/scripts/genesys/place-actors.ts +179 -179
- package/src/templates/scripts/genesys/post-install.ts +30 -30
- package/src/templates/scripts/genesys/prefab.schema.json +84 -84
- package/src/templates/scripts/genesys/remove-engine-comments.ts +134 -134
- package/src/templates/scripts/genesys/run-mcp-inspector.bat +4 -4
- package/src/templates/scripts/genesys/storageProvider.ts +182 -182
- package/src/templates/scripts/genesys/validate-prefabs.ts +138 -138
- package/src/templates/src/index.ts +22 -22
- package/src/templates/src/templates/firstPerson/assets/default.genesys-scene +165 -165
- package/src/templates/src/templates/firstPerson/src/game.ts +39 -39
- package/src/templates/src/templates/firstPerson/src/player.ts +63 -63
- package/src/templates/src/templates/fps/assets/default.genesys-scene +9459 -9459
- package/src/templates/src/templates/fps/src/game.ts +39 -39
- package/src/templates/src/templates/fps/src/player.ts +69 -69
- package/src/templates/src/templates/fps/src/weapon.ts +54 -54
- package/src/templates/src/templates/freeCamera/assets/default.genesys-scene +165 -165
- package/src/templates/src/templates/freeCamera/src/game.ts +39 -39
- package/src/templates/src/templates/freeCamera/src/player.ts +45 -45
- package/src/templates/src/templates/sideScroller/assets/default.genesys-scene +121 -121
- package/src/templates/src/templates/sideScroller/src/const.ts +45 -45
- package/src/templates/src/templates/sideScroller/src/game.ts +122 -122
- package/src/templates/src/templates/sideScroller/src/level-generator.ts +361 -361
- package/src/templates/src/templates/sideScroller/src/player.ts +125 -125
- package/src/templates/src/templates/thirdPerson/assets/default.genesys-scene +165 -165
- package/src/templates/src/templates/thirdPerson/src/game.ts +39 -39
- package/src/templates/src/templates/thirdPerson/src/player.ts +61 -61
- package/src/templates/src/templates/vehicle/assets/default.genesys-scene +225 -225
- package/src/templates/src/templates/vehicle/src/base-vehicle.ts +145 -145
- package/src/templates/src/templates/vehicle/src/game.ts +43 -43
- package/src/templates/src/templates/vehicle/src/mesh-vehicle.ts +191 -191
- package/src/templates/src/templates/vehicle/src/player.ts +109 -109
- package/src/templates/src/templates/vehicle/src/primitive-vehicle.ts +266 -266
- package/src/templates/src/templates/vehicle/src/ui-hints.ts +101 -101
- package/src/templates/src/templates/vr-game/assets/default.genesys-scene +246 -246
- package/src/templates/src/templates/vr-game/src/auto-imports.ts +1 -1
- package/src/templates/src/templates/vr-game/src/game.ts +66 -66
- package/src/templates/src/templates/vr-game/src/sample-vr-actor.ts +26 -26
- package/src/templates/tsconfig.json +34 -34
- package/src/templates/vite.config.ts +52 -52
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
|
|
7
|
-
export const isDev = process.env.NODE_ENV === 'development' ||
|
|
8
|
-
process.env.NODE_ENV === 'dev' ||
|
|
9
|
-
process.argv.includes('--dev');
|
|
10
|
-
|
|
11
|
-
export function mockEsModule() {
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = path.dirname(__filename);
|
|
14
|
-
(global as any).__filename = __filename;
|
|
15
|
-
(global as any).__dirname = __dirname;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
mockEsModule();
|
|
19
|
-
|
|
20
|
-
export function getProjectRoot() {
|
|
21
|
-
let currentDir = __dirname;
|
|
22
|
-
while (true) {
|
|
23
|
-
if (fs.existsSync(path.join(currentDir, 'package.json'))) {
|
|
24
|
-
return currentDir;
|
|
25
|
-
}
|
|
26
|
-
const parentDir = path.dirname(currentDir);
|
|
27
|
-
if (parentDir === currentDir) {
|
|
28
|
-
throw new Error('Project root not found');
|
|
29
|
-
}
|
|
30
|
-
currentDir = parentDir;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const TransformSchema = z.object({
|
|
35
|
-
position: z.array(z.number()).length(3).optional().describe('Position as [x, y, z]'),
|
|
36
|
-
rotation: z.array(z.number()).length(3).optional().describe('Rotation in radians as [x, y, z]'),
|
|
37
|
-
scale: z.array(z.number()).length(3).optional().describe('Scale as [x, y, z], use this to scale the actor up or down'),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export type Transform = z.infer<typeof TransformSchema>;
|
|
41
|
-
|
|
42
|
-
export const ActorInfoSchema = z.object({
|
|
43
|
-
displayName: z.string().describe('Display name of the actor'),
|
|
44
|
-
description: z.string().optional().describe('Description of the actor, including its purpose, how to use it, etc.'),
|
|
45
|
-
});
|
|
46
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
export const isDev = process.env.NODE_ENV === 'development' ||
|
|
8
|
+
process.env.NODE_ENV === 'dev' ||
|
|
9
|
+
process.argv.includes('--dev');
|
|
10
|
+
|
|
11
|
+
export function mockEsModule() {
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
(global as any).__filename = __filename;
|
|
15
|
+
(global as any).__dirname = __dirname;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
mockEsModule();
|
|
19
|
+
|
|
20
|
+
export function getProjectRoot() {
|
|
21
|
+
let currentDir = __dirname;
|
|
22
|
+
while (true) {
|
|
23
|
+
if (fs.existsSync(path.join(currentDir, 'package.json'))) {
|
|
24
|
+
return currentDir;
|
|
25
|
+
}
|
|
26
|
+
const parentDir = path.dirname(currentDir);
|
|
27
|
+
if (parentDir === currentDir) {
|
|
28
|
+
throw new Error('Project root not found');
|
|
29
|
+
}
|
|
30
|
+
currentDir = parentDir;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const TransformSchema = z.object({
|
|
35
|
+
position: z.array(z.number()).length(3).optional().describe('Position as [x, y, z]'),
|
|
36
|
+
rotation: z.array(z.number()).length(3).optional().describe('Rotation in radians as [x, y, z]'),
|
|
37
|
+
scale: z.array(z.number()).length(3).optional().describe('Scale as [x, y, z], use this to scale the actor up or down'),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export type Transform = z.infer<typeof TransformSchema>;
|
|
41
|
+
|
|
42
|
+
export const ActorInfoSchema = z.object({
|
|
43
|
+
displayName: z.string().describe('Display name of the actor'),
|
|
44
|
+
description: z.string().optional().describe('Description of the actor, including its purpose, how to use it, etc.'),
|
|
45
|
+
});
|
|
46
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// MUST be kept in sync with https://github.com/directivegames/genesys.ai/blob/develop/src/const.ts
|
|
2
|
-
export const SCENE_EXTENSION: string = '.genesys-scene';
|
|
3
|
-
export const PUBLIC_FOLDER: string = 'public';
|
|
4
|
-
export const PROJECT_PREFIX: string = '@project';
|
|
5
|
-
export const ENGINE_PREFIX: string = '@engine';
|
|
6
|
-
export const DEFAULT_GAME_NAME: string = 'game.ts';
|
|
7
|
-
export const DEFAULT_GAME_BUNDLE_NAME: string = 'game.js';
|
|
8
|
-
export const BUILT_PROJECT_FOLDER: string = '.dist';
|
|
9
|
-
export const JS_CLASSES_DIR_NAME: string = '@js-classes';
|
|
1
|
+
// MUST be kept in sync with https://github.com/directivegames/genesys.ai/blob/develop/src/const.ts
|
|
2
|
+
export const SCENE_EXTENSION: string = '.genesys-scene';
|
|
3
|
+
export const PUBLIC_FOLDER: string = 'public';
|
|
4
|
+
export const PROJECT_PREFIX: string = '@project';
|
|
5
|
+
export const ENGINE_PREFIX: string = '@engine';
|
|
6
|
+
export const DEFAULT_GAME_NAME: string = 'game.ts';
|
|
7
|
+
export const DEFAULT_GAME_BUNDLE_NAME: string = 'game.js';
|
|
8
|
+
export const BUILT_PROJECT_FOLDER: string = '.dist';
|
|
9
|
+
export const JS_CLASSES_DIR_NAME: string = '@js-classes';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as ENGINE from 'genesys.js';
|
|
2
|
-
|
|
3
|
-
import { defaultWorldOptions } from '../mcp/utils.js';
|
|
4
|
-
|
|
5
|
-
function main() {
|
|
6
|
-
const world = new ENGINE.World(defaultWorldOptions);
|
|
7
|
-
ENGINE.GameBuilder.createDefaultEditorScene(world);
|
|
8
|
-
console.log(JSON.stringify(world.asExportedObject(), null, 2));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
main();
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
|
|
3
|
+
import { defaultWorldOptions } from '../mcp/utils.js';
|
|
4
|
+
|
|
5
|
+
function main() {
|
|
6
|
+
const world = new ENGINE.World(defaultWorldOptions);
|
|
7
|
+
ENGINE.GameBuilder.createDefaultEditorScene(world);
|
|
8
|
+
console.log(JSON.stringify(world.asExportedObject(), null, 2));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
main();
|
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
// pnpm exec tsx ./scripts/genesys/dev/generate-manifest.ts
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
|
|
5
|
-
import * as ENGINE from 'genesys.js';
|
|
6
|
-
|
|
7
|
-
import { ManifestPath } from './storage-provider.js';
|
|
8
|
-
|
|
9
|
-
import type { FileManifest, FileManifestItem} from './storage-provider.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Recursively scans a directory and returns file information
|
|
13
|
-
*/
|
|
14
|
-
function scanDirectory(
|
|
15
|
-
dirPath: string,
|
|
16
|
-
basePath: string = '',
|
|
17
|
-
): FileManifestItem[] {
|
|
18
|
-
|
|
19
|
-
const items: FileManifestItem[] = [];
|
|
20
|
-
|
|
21
|
-
if (!fs.existsSync(dirPath)) {
|
|
22
|
-
return items;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
27
|
-
|
|
28
|
-
for (const entry of entries) {
|
|
29
|
-
const fullPath = path.join(dirPath, entry.name);
|
|
30
|
-
const relativePath = basePath ? path.join(basePath, entry.name) : entry.name;
|
|
31
|
-
const stats = fs.statSync(fullPath);
|
|
32
|
-
|
|
33
|
-
const item: FileManifestItem = {
|
|
34
|
-
name: entry.name,
|
|
35
|
-
path: relativePath.replace(/\\/g, '/'), // Normalize to forward slashes
|
|
36
|
-
size: stats.size,
|
|
37
|
-
modifiedTime: stats.mtime,
|
|
38
|
-
isDirectory: entry.isDirectory(),
|
|
39
|
-
contentType: getContentType(entry.name)
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
items.push(item);
|
|
43
|
-
|
|
44
|
-
// Recursively scan subdirectories
|
|
45
|
-
if (entry.isDirectory()) {
|
|
46
|
-
const subItems = scanDirectory(fullPath, relativePath);
|
|
47
|
-
items.push(...subItems);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.warn(`Failed to scan directory ${dirPath}:`, error);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return items;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Gets content type based on file extension
|
|
59
|
-
*/
|
|
60
|
-
function getContentType(fileName: string): string | undefined {
|
|
61
|
-
const ext = path.extname(fileName).toLowerCase();
|
|
62
|
-
const contentTypes: Record<string, string> = {
|
|
63
|
-
'.json': 'application/json',
|
|
64
|
-
'.js': 'application/javascript',
|
|
65
|
-
'.ts': 'application/typescript',
|
|
66
|
-
'.html': 'text/html',
|
|
67
|
-
'.css': 'text/css',
|
|
68
|
-
'.png': 'image/png',
|
|
69
|
-
'.jpg': 'image/jpeg',
|
|
70
|
-
'.jpeg': 'image/jpeg',
|
|
71
|
-
'.gif': 'image/gif',
|
|
72
|
-
'.webp': 'image/webp',
|
|
73
|
-
'.svg': 'image/svg+xml',
|
|
74
|
-
'.glb': 'model/gltf-binary',
|
|
75
|
-
'.gltf': 'model/gltf+json',
|
|
76
|
-
'.wav': 'audio/wav',
|
|
77
|
-
'.mp3': 'audio/mpeg',
|
|
78
|
-
'.ogg': 'audio/ogg',
|
|
79
|
-
'.genesys-scene': 'application/json',
|
|
80
|
-
'.genesys-project': 'application/json'
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return contentTypes[ext];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Groups files by directory path for efficient lookup
|
|
88
|
-
*/
|
|
89
|
-
function groupFilesByDirectory(files: FileManifestItem[]): Record<string, FileManifestItem[]> {
|
|
90
|
-
const grouped: Record<string, FileManifestItem[]> = {};
|
|
91
|
-
|
|
92
|
-
// Add root directory
|
|
93
|
-
grouped[''] = [];
|
|
94
|
-
|
|
95
|
-
for (const file of files) {
|
|
96
|
-
const dir = path.dirname(file.path).replace(/\\/g, '/');
|
|
97
|
-
const normalizedDir = dir === '.' ? '' : dir;
|
|
98
|
-
|
|
99
|
-
if (!grouped[normalizedDir]) {
|
|
100
|
-
grouped[normalizedDir] = [];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
grouped[normalizedDir].push(file);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return grouped;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Generates the file manifest
|
|
111
|
-
*/
|
|
112
|
-
export async function generateManifest(): Promise<void> {
|
|
113
|
-
console.log('Generating file manifest...');
|
|
114
|
-
|
|
115
|
-
const manifest: FileManifest = {
|
|
116
|
-
generated: new Date().toISOString(),
|
|
117
|
-
projectFiles: {},
|
|
118
|
-
engineFiles: {}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// Scan project files
|
|
122
|
-
console.log('Scanning project files...');
|
|
123
|
-
const projectRoot = process.cwd();
|
|
124
|
-
const builtProjectRoot = path.join(projectRoot, ENGINE.BUILT_PROJECT_FOLDER);
|
|
125
|
-
const projectFiles = scanDirectory(builtProjectRoot);
|
|
126
|
-
manifest.projectFiles = groupFilesByDirectory(projectFiles);
|
|
127
|
-
|
|
128
|
-
// Scan engine files
|
|
129
|
-
console.log('Scanning engine files...');
|
|
130
|
-
const engineAssetsRoot = path.join(projectRoot, 'node_modules', 'genesys.js', 'assets');
|
|
131
|
-
if (fs.existsSync(engineAssetsRoot)) {
|
|
132
|
-
const engineFiles = scanDirectory(engineAssetsRoot, 'assets');
|
|
133
|
-
manifest.engineFiles = groupFilesByDirectory(engineFiles);
|
|
134
|
-
console.log(`Engine files: ${Object.values(manifest.engineFiles).flat().length}`);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Write manifest to public directory so it's accessible to the dev server
|
|
138
|
-
const manifestPath = path.join(projectRoot, ManifestPath);
|
|
139
|
-
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
140
|
-
|
|
141
|
-
console.log(`File manifest generated: ${manifestPath}`);
|
|
142
|
-
console.log(`Project files: ${Object.values(manifest.projectFiles).flat().length}`);
|
|
143
|
-
console.log(`Engine files: ${Object.values(manifest.engineFiles).flat().length}`);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
generateManifest().catch(console.error);
|
|
1
|
+
// pnpm exec tsx ./scripts/genesys/dev/generate-manifest.ts
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
|
|
5
|
+
import * as ENGINE from 'genesys.js';
|
|
6
|
+
|
|
7
|
+
import { ManifestPath } from './storage-provider.js';
|
|
8
|
+
|
|
9
|
+
import type { FileManifest, FileManifestItem} from './storage-provider.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Recursively scans a directory and returns file information
|
|
13
|
+
*/
|
|
14
|
+
function scanDirectory(
|
|
15
|
+
dirPath: string,
|
|
16
|
+
basePath: string = '',
|
|
17
|
+
): FileManifestItem[] {
|
|
18
|
+
|
|
19
|
+
const items: FileManifestItem[] = [];
|
|
20
|
+
|
|
21
|
+
if (!fs.existsSync(dirPath)) {
|
|
22
|
+
return items;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
27
|
+
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
30
|
+
const relativePath = basePath ? path.join(basePath, entry.name) : entry.name;
|
|
31
|
+
const stats = fs.statSync(fullPath);
|
|
32
|
+
|
|
33
|
+
const item: FileManifestItem = {
|
|
34
|
+
name: entry.name,
|
|
35
|
+
path: relativePath.replace(/\\/g, '/'), // Normalize to forward slashes
|
|
36
|
+
size: stats.size,
|
|
37
|
+
modifiedTime: stats.mtime,
|
|
38
|
+
isDirectory: entry.isDirectory(),
|
|
39
|
+
contentType: getContentType(entry.name)
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
items.push(item);
|
|
43
|
+
|
|
44
|
+
// Recursively scan subdirectories
|
|
45
|
+
if (entry.isDirectory()) {
|
|
46
|
+
const subItems = scanDirectory(fullPath, relativePath);
|
|
47
|
+
items.push(...subItems);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.warn(`Failed to scan directory ${dirPath}:`, error);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return items;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Gets content type based on file extension
|
|
59
|
+
*/
|
|
60
|
+
function getContentType(fileName: string): string | undefined {
|
|
61
|
+
const ext = path.extname(fileName).toLowerCase();
|
|
62
|
+
const contentTypes: Record<string, string> = {
|
|
63
|
+
'.json': 'application/json',
|
|
64
|
+
'.js': 'application/javascript',
|
|
65
|
+
'.ts': 'application/typescript',
|
|
66
|
+
'.html': 'text/html',
|
|
67
|
+
'.css': 'text/css',
|
|
68
|
+
'.png': 'image/png',
|
|
69
|
+
'.jpg': 'image/jpeg',
|
|
70
|
+
'.jpeg': 'image/jpeg',
|
|
71
|
+
'.gif': 'image/gif',
|
|
72
|
+
'.webp': 'image/webp',
|
|
73
|
+
'.svg': 'image/svg+xml',
|
|
74
|
+
'.glb': 'model/gltf-binary',
|
|
75
|
+
'.gltf': 'model/gltf+json',
|
|
76
|
+
'.wav': 'audio/wav',
|
|
77
|
+
'.mp3': 'audio/mpeg',
|
|
78
|
+
'.ogg': 'audio/ogg',
|
|
79
|
+
'.genesys-scene': 'application/json',
|
|
80
|
+
'.genesys-project': 'application/json'
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return contentTypes[ext];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Groups files by directory path for efficient lookup
|
|
88
|
+
*/
|
|
89
|
+
function groupFilesByDirectory(files: FileManifestItem[]): Record<string, FileManifestItem[]> {
|
|
90
|
+
const grouped: Record<string, FileManifestItem[]> = {};
|
|
91
|
+
|
|
92
|
+
// Add root directory
|
|
93
|
+
grouped[''] = [];
|
|
94
|
+
|
|
95
|
+
for (const file of files) {
|
|
96
|
+
const dir = path.dirname(file.path).replace(/\\/g, '/');
|
|
97
|
+
const normalizedDir = dir === '.' ? '' : dir;
|
|
98
|
+
|
|
99
|
+
if (!grouped[normalizedDir]) {
|
|
100
|
+
grouped[normalizedDir] = [];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
grouped[normalizedDir].push(file);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return grouped;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Generates the file manifest
|
|
111
|
+
*/
|
|
112
|
+
export async function generateManifest(): Promise<void> {
|
|
113
|
+
console.log('Generating file manifest...');
|
|
114
|
+
|
|
115
|
+
const manifest: FileManifest = {
|
|
116
|
+
generated: new Date().toISOString(),
|
|
117
|
+
projectFiles: {},
|
|
118
|
+
engineFiles: {}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Scan project files
|
|
122
|
+
console.log('Scanning project files...');
|
|
123
|
+
const projectRoot = process.cwd();
|
|
124
|
+
const builtProjectRoot = path.join(projectRoot, ENGINE.BUILT_PROJECT_FOLDER);
|
|
125
|
+
const projectFiles = scanDirectory(builtProjectRoot);
|
|
126
|
+
manifest.projectFiles = groupFilesByDirectory(projectFiles);
|
|
127
|
+
|
|
128
|
+
// Scan engine files
|
|
129
|
+
console.log('Scanning engine files...');
|
|
130
|
+
const engineAssetsRoot = path.join(projectRoot, 'node_modules', 'genesys.js', 'assets');
|
|
131
|
+
if (fs.existsSync(engineAssetsRoot)) {
|
|
132
|
+
const engineFiles = scanDirectory(engineAssetsRoot, 'assets');
|
|
133
|
+
manifest.engineFiles = groupFilesByDirectory(engineFiles);
|
|
134
|
+
console.log(`Engine files: ${Object.values(manifest.engineFiles).flat().length}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Write manifest to public directory so it's accessible to the dev server
|
|
138
|
+
const manifestPath = path.join(projectRoot, ManifestPath);
|
|
139
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
140
|
+
|
|
141
|
+
console.log(`File manifest generated: ${manifestPath}`);
|
|
142
|
+
console.log(`Project files: ${Object.values(manifest.projectFiles).flat().length}`);
|
|
143
|
+
console.log(`Engine files: ${Object.values(manifest.engineFiles).flat().length}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
generateManifest().catch(console.error);
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import * as ENGINE from 'genesys.js';
|
|
2
|
-
|
|
3
|
-
import { DevStorageProvider } from './storage-provider.js';
|
|
4
|
-
|
|
5
|
-
// Ensure process is available globally with minimal implementation
|
|
6
|
-
if (typeof globalThis.process === 'undefined') {
|
|
7
|
-
(globalThis as any).process = {
|
|
8
|
-
cwd: () => '/',
|
|
9
|
-
env: {},
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Initialize the game - can be called manually
|
|
14
|
-
export async function launchGame() {
|
|
15
|
-
const container = document.getElementById('game-container');
|
|
16
|
-
if (!container) {
|
|
17
|
-
console.error('Game container not found!');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
// Create the storage provider for Vite dev environment
|
|
23
|
-
const storageProvider = new DevStorageProvider();
|
|
24
|
-
|
|
25
|
-
ENGINE.projectContext({
|
|
26
|
-
project: 'dev-game',
|
|
27
|
-
storageProvider,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Create the game runtime
|
|
31
|
-
const gameRuntime = new ENGINE.GameRuntime({
|
|
32
|
-
provider: storageProvider,
|
|
33
|
-
container: container,
|
|
34
|
-
gameId: 'dev-game',
|
|
35
|
-
buildProject: false,
|
|
36
|
-
skipClearGameClasses: false
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
console.log('Starting game runtime...');
|
|
40
|
-
|
|
41
|
-
// Start the game with the default scene
|
|
42
|
-
await gameRuntime.startGame();
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error('Failed to initialize game:', error);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import * as ENGINE from 'genesys.js';
|
|
2
|
+
|
|
3
|
+
import { DevStorageProvider } from './storage-provider.js';
|
|
4
|
+
|
|
5
|
+
// Ensure process is available globally with minimal implementation
|
|
6
|
+
if (typeof globalThis.process === 'undefined') {
|
|
7
|
+
(globalThis as any).process = {
|
|
8
|
+
cwd: () => '/',
|
|
9
|
+
env: {},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Initialize the game - can be called manually
|
|
14
|
+
export async function launchGame() {
|
|
15
|
+
const container = document.getElementById('game-container');
|
|
16
|
+
if (!container) {
|
|
17
|
+
console.error('Game container not found!');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// Create the storage provider for Vite dev environment
|
|
23
|
+
const storageProvider = new DevStorageProvider();
|
|
24
|
+
|
|
25
|
+
ENGINE.projectContext({
|
|
26
|
+
project: 'dev-game',
|
|
27
|
+
storageProvider,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Create the game runtime
|
|
31
|
+
const gameRuntime = new ENGINE.GameRuntime({
|
|
32
|
+
provider: storageProvider,
|
|
33
|
+
container: container,
|
|
34
|
+
gameId: 'dev-game',
|
|
35
|
+
buildProject: false,
|
|
36
|
+
skipClearGameClasses: false
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
console.log('Starting game runtime...');
|
|
40
|
+
|
|
41
|
+
// Start the game with the default scene
|
|
42
|
+
await gameRuntime.startGame();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Failed to initialize game:', error);
|
|
45
|
+
}
|
|
46
|
+
}
|