@holoscript/core 2.0.1 → 2.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 (137) hide show
  1. package/dist/chunk-2XXE34KS.js +344 -0
  2. package/dist/chunk-2XXE34KS.js.map +1 -0
  3. package/dist/chunk-3X2EGU7Z.cjs +52 -0
  4. package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
  5. package/dist/chunk-AFFVFO4D.js +1689 -0
  6. package/dist/chunk-AFFVFO4D.js.map +1 -0
  7. package/dist/chunk-DGUM43GV.js +10 -0
  8. package/dist/chunk-DGUM43GV.js.map +1 -0
  9. package/{src/HoloScriptDebugger.ts → dist/chunk-DOY73HDH.js} +118 -257
  10. package/dist/chunk-DOY73HDH.js.map +1 -0
  11. package/dist/chunk-JEQ2X3Z6.cjs +12 -0
  12. package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
  13. package/dist/chunk-L6VLNVKP.cjs +1691 -0
  14. package/dist/chunk-L6VLNVKP.cjs.map +1 -0
  15. package/dist/chunk-MFNO57XL.cjs +347 -0
  16. package/dist/chunk-MFNO57XL.cjs.map +1 -0
  17. package/dist/chunk-R75MREOS.cjs +424 -0
  18. package/dist/chunk-R75MREOS.cjs.map +1 -0
  19. package/dist/chunk-SATNCODL.js +45 -0
  20. package/dist/chunk-SATNCODL.js.map +1 -0
  21. package/dist/chunk-T57ZL7KR.cjs +1281 -0
  22. package/dist/chunk-T57ZL7KR.cjs.map +1 -0
  23. package/dist/chunk-U72GEJZT.js +1279 -0
  24. package/dist/chunk-U72GEJZT.js.map +1 -0
  25. package/dist/debugger.cjs +20 -0
  26. package/dist/debugger.cjs.map +1 -0
  27. package/dist/debugger.d.cts +171 -0
  28. package/dist/debugger.d.ts +171 -0
  29. package/dist/debugger.js +7 -0
  30. package/dist/debugger.js.map +1 -0
  31. package/dist/index.cjs +6803 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.cts +4093 -0
  34. package/dist/index.d.ts +4093 -0
  35. package/dist/index.js +6715 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/parser.cjs +14 -0
  38. package/dist/parser.cjs.map +1 -0
  39. package/dist/parser.d.cts +172 -0
  40. package/dist/parser.d.ts +172 -0
  41. package/dist/parser.js +5 -0
  42. package/dist/parser.js.map +1 -0
  43. package/dist/runtime.cjs +14 -0
  44. package/dist/runtime.cjs.map +1 -0
  45. package/dist/runtime.d.cts +200 -0
  46. package/dist/runtime.d.ts +200 -0
  47. package/dist/runtime.js +5 -0
  48. package/dist/runtime.js.map +1 -0
  49. package/dist/type-checker.cjs +17 -0
  50. package/dist/type-checker.cjs.map +1 -0
  51. package/dist/type-checker.d.cts +105 -0
  52. package/dist/type-checker.d.ts +105 -0
  53. package/dist/type-checker.js +4 -0
  54. package/dist/type-checker.js.map +1 -0
  55. package/dist/types-4h8cbtF_.d.cts +329 -0
  56. package/dist/types-4h8cbtF_.d.ts +329 -0
  57. package/package.json +17 -13
  58. package/src/HoloScript2DParser.js +0 -227
  59. package/src/HoloScript2DParser.ts +0 -261
  60. package/src/HoloScriptCodeParser.js +0 -1102
  61. package/src/HoloScriptCodeParser.ts +0 -1188
  62. package/src/HoloScriptDebugger.js +0 -458
  63. package/src/HoloScriptParser.js +0 -338
  64. package/src/HoloScriptParser.ts +0 -397
  65. package/src/HoloScriptPlusParser.js +0 -371
  66. package/src/HoloScriptPlusParser.ts +0 -543
  67. package/src/HoloScriptRuntime.js +0 -1399
  68. package/src/HoloScriptRuntime.test.js +0 -351
  69. package/src/HoloScriptRuntime.test.ts +0 -436
  70. package/src/HoloScriptRuntime.ts +0 -1653
  71. package/src/HoloScriptTypeChecker.js +0 -356
  72. package/src/HoloScriptTypeChecker.ts +0 -475
  73. package/src/__tests__/GraphicsServices.test.js +0 -357
  74. package/src/__tests__/GraphicsServices.test.ts +0 -427
  75. package/src/__tests__/HoloScriptPlusParser.test.js +0 -317
  76. package/src/__tests__/HoloScriptPlusParser.test.ts +0 -392
  77. package/src/__tests__/integration.test.js +0 -336
  78. package/src/__tests__/integration.test.ts +0 -416
  79. package/src/__tests__/performance.bench.js +0 -218
  80. package/src/__tests__/performance.bench.ts +0 -262
  81. package/src/__tests__/type-checker.test.js +0 -60
  82. package/src/__tests__/type-checker.test.ts +0 -73
  83. package/src/index.js +0 -217
  84. package/src/index.ts +0 -426
  85. package/src/interop/Interoperability.js +0 -413
  86. package/src/interop/Interoperability.ts +0 -494
  87. package/src/logger.js +0 -42
  88. package/src/logger.ts +0 -57
  89. package/src/parser/EnhancedParser.js +0 -205
  90. package/src/parser/EnhancedParser.ts +0 -251
  91. package/src/parser/HoloScriptPlusParser.js +0 -928
  92. package/src/parser/HoloScriptPlusParser.ts +0 -1089
  93. package/src/runtime/HoloScriptPlusRuntime.js +0 -674
  94. package/src/runtime/HoloScriptPlusRuntime.ts +0 -861
  95. package/src/runtime/PerformanceTelemetry.js +0 -323
  96. package/src/runtime/PerformanceTelemetry.ts +0 -467
  97. package/src/runtime/RuntimeOptimization.js +0 -361
  98. package/src/runtime/RuntimeOptimization.ts +0 -416
  99. package/src/services/HololandGraphicsPipelineService.js +0 -506
  100. package/src/services/HololandGraphicsPipelineService.ts +0 -662
  101. package/src/services/PlatformPerformanceOptimizer.js +0 -356
  102. package/src/services/PlatformPerformanceOptimizer.ts +0 -503
  103. package/src/state/ReactiveState.js +0 -427
  104. package/src/state/ReactiveState.ts +0 -572
  105. package/src/tools/DeveloperExperience.js +0 -376
  106. package/src/tools/DeveloperExperience.ts +0 -438
  107. package/src/traits/AIDriverTrait.js +0 -322
  108. package/src/traits/AIDriverTrait.test.js +0 -329
  109. package/src/traits/AIDriverTrait.test.ts +0 -357
  110. package/src/traits/AIDriverTrait.ts +0 -474
  111. package/src/traits/LightingTrait.js +0 -313
  112. package/src/traits/LightingTrait.test.js +0 -410
  113. package/src/traits/LightingTrait.test.ts +0 -462
  114. package/src/traits/LightingTrait.ts +0 -505
  115. package/src/traits/MaterialTrait.js +0 -194
  116. package/src/traits/MaterialTrait.test.js +0 -286
  117. package/src/traits/MaterialTrait.test.ts +0 -329
  118. package/src/traits/MaterialTrait.ts +0 -324
  119. package/src/traits/RenderingTrait.js +0 -356
  120. package/src/traits/RenderingTrait.test.js +0 -363
  121. package/src/traits/RenderingTrait.test.ts +0 -427
  122. package/src/traits/RenderingTrait.ts +0 -555
  123. package/src/traits/VRTraitSystem.js +0 -740
  124. package/src/traits/VRTraitSystem.ts +0 -1040
  125. package/src/traits/VoiceInputTrait.js +0 -284
  126. package/src/traits/VoiceInputTrait.test.js +0 -226
  127. package/src/traits/VoiceInputTrait.test.ts +0 -252
  128. package/src/traits/VoiceInputTrait.ts +0 -401
  129. package/src/types/AdvancedTypeSystem.js +0 -226
  130. package/src/types/AdvancedTypeSystem.ts +0 -494
  131. package/src/types/HoloScriptPlus.d.ts +0 -853
  132. package/src/types.js +0 -6
  133. package/src/types.ts +0 -369
  134. package/tsconfig.json +0 -23
  135. package/tsup.config.d.ts +0 -2
  136. package/tsup.config.js +0 -18
  137. package/tsup.config.ts +0 -19
@@ -1,662 +0,0 @@
1
- /**
2
- * Hololand Graphics Pipeline Service
3
- *
4
- * Core service for managing graphics rendering pipeline in Hololand.
5
- * Integrates HoloScript graphics traits with Hololand's rendering backend.
6
- *
7
- * Responsibilities:
8
- * - Material management and asset pipeline
9
- * - Light management and shadow mapping
10
- * - GPU memory optimization
11
- * - Performance monitoring and profiling
12
- * - Cross-platform optimization (mobile/VR/desktop)
13
- */
14
-
15
- import type { GraphicsConfiguration } from '../HoloScriptPlusParser';
16
- import type { MaterialTrait } from '../traits/MaterialTrait';
17
-
18
- // ============================================================================
19
- // GPU Memory Estimation
20
- // ============================================================================
21
-
22
- export interface GPUMemoryEstimate {
23
- textureMemory: number; // MB
24
- geometryMemory: number; // MB
25
- bufferMemory: number; // MB
26
- estimatedTotal: number; // MB
27
- budget: number; // MB (allocated limit)
28
- utilization: number; // percentage
29
- }
30
-
31
- // ============================================================================
32
- // Material Asset Pipeline
33
- // ============================================================================
34
-
35
- export interface MaterialAsset {
36
- id: string;
37
- name: string;
38
- material: MaterialTrait;
39
- shaders: ShaderProgram[];
40
- textures: TextureAsset[];
41
- instances: number;
42
- gpuMemory: number;
43
- lastUsed: number;
44
- }
45
-
46
- export interface TextureAsset {
47
- id: string;
48
- path: string;
49
- format: 'RGBA8' | 'RGB565' | 'BC1' | 'BC3' | 'ASTC' | 'PVRTC';
50
- width: number;
51
- height: number;
52
- mipLevels: number;
53
- gpuMemory: number;
54
- loaded: boolean;
55
- }
56
-
57
- export interface ShaderProgram {
58
- id: string;
59
- name: string;
60
- vertexShader: string;
61
- fragmentShader: string;
62
- uniforms: Record<string, string>;
63
- compiled: boolean;
64
- compilationTime: number;
65
- }
66
-
67
- // ============================================================================
68
- // Performance Metrics
69
- // ============================================================================
70
-
71
- export interface PerformanceMetrics {
72
- drawCalls: number;
73
- trianglesRendered: number;
74
- gpuFrameTime: number; // ms
75
- cpuFrameTime: number; // ms
76
- fps: number;
77
- gpuMemoryUsed: number; // MB
78
- textureBinds: number;
79
- shaderSwitches: number;
80
- batchCount: number;
81
- }
82
-
83
- // ============================================================================
84
- // Platform Configuration
85
- // ============================================================================
86
-
87
- export type Platform = 'mobile' | 'vr' | 'desktop';
88
-
89
- export interface PlatformConfig {
90
- platform: Platform;
91
- maxGPUMemory: number; // MB
92
- maxDrawCalls: number;
93
- maxTextureResolution: number;
94
- targetFPS: number;
95
- shadowQuality: 'none' | 'low' | 'medium' | 'high';
96
- textureCompression: 'none' | 'dxt' | 'astc' | 'basis';
97
- instancingEnabled: boolean;
98
- maxLights: number;
99
- maxShadowCasters: number;
100
- }
101
-
102
- // ============================================================================
103
- // Hololand Graphics Pipeline Service
104
- // ============================================================================
105
-
106
- export class HololandGraphicsPipelineService {
107
- private materialCache: Map<string, MaterialAsset> = new Map();
108
- private textureCache: Map<string, TextureAsset> = new Map();
109
- private shaderCache: Map<string, ShaderProgram> = new Map();
110
-
111
- private platformConfig: PlatformConfig;
112
- private metrics: PerformanceMetrics;
113
-
114
- // private _memoryBudget: number = 512; // MB default - unused
115
- private memoryUsed: number = 0;
116
-
117
- constructor(platform: Platform = 'desktop') {
118
- this.platformConfig = this.getPlatformConfig(platform);
119
- this.metrics = this.initializeMetrics();
120
- }
121
-
122
- /**
123
- * Initialize graphics pipeline with configuration
124
- */
125
- initialize(config: GraphicsConfiguration): void {
126
- if (config.material) {
127
- this.initializeMaterials(config.material);
128
- }
129
-
130
- if (config.lighting) {
131
- this.initializeLighting(config.lighting);
132
- }
133
-
134
- if (config.rendering) {
135
- this.initializeRendering(config.rendering);
136
- }
137
- }
138
-
139
- /**
140
- * Initialize materials from configuration
141
- */
142
- private initializeMaterials(materialConfig: any): void {
143
- // Create material assets
144
- const material = this.createMaterialAsset(materialConfig);
145
- this.materialCache.set(material.id, material);
146
-
147
- // Pre-compile shaders
148
- material.shaders.forEach((shader) => {
149
- this.compileShader(shader);
150
- });
151
-
152
- // Load textures
153
- material.textures.forEach((texture) => {
154
- this.loadTexture(texture);
155
- });
156
- }
157
-
158
- /**
159
- * Initialize lighting from configuration
160
- */
161
- private initializeLighting(lightingConfig: any): void {
162
- // Configure shadow mapping
163
- if (lightingConfig.shadows) {
164
- this.setupShadowMapping(lightingConfig);
165
- }
166
-
167
- // Configure global illumination
168
- if (lightingConfig.globalIllumination) {
169
- this.setupGlobalIllumination(lightingConfig.globalIllumination);
170
- }
171
- }
172
-
173
- /**
174
- * Initialize rendering from configuration
175
- */
176
- private initializeRendering(renderingConfig: any): void {
177
- // Apply quality preset
178
- if (renderingConfig.quality) {
179
- this.applyQualityPreset(renderingConfig.quality);
180
- }
181
-
182
- // Configure platform-specific settings
183
- if (renderingConfig.platform) {
184
- this.platformConfig = this.getPlatformConfig(renderingConfig.platform);
185
- }
186
-
187
- // Enable optimizations
188
- if (renderingConfig.lod !== false) {
189
- this.enableLOD();
190
- }
191
-
192
- if (renderingConfig.culling !== false) {
193
- this.enableCulling();
194
- }
195
-
196
- if (renderingConfig.instancing !== false) {
197
- this.platformConfig.instancingEnabled = true;
198
- }
199
- }
200
-
201
- /**
202
- * Create material asset from configuration
203
- */
204
- private createMaterialAsset(config: any): MaterialAsset {
205
- const id = `mat_${Date.now()}_${Math.random()}`;
206
-
207
- const asset: MaterialAsset = {
208
- id,
209
- name: config.name || 'Material',
210
- material: null as any, // Would be actual MaterialTrait
211
- shaders: this.generateShaders(config),
212
- textures: this.loadTexturesFromConfig(config),
213
- instances: 0,
214
- gpuMemory: 0,
215
- lastUsed: Date.now(),
216
- };
217
-
218
- // Estimate GPU memory
219
- asset.gpuMemory = this.estimateMaterialMemory(asset);
220
- this.memoryUsed += asset.gpuMemory;
221
-
222
- return asset;
223
- }
224
-
225
- /**
226
- * Generate shaders from material configuration
227
- */
228
- private generateShaders(config: any): ShaderProgram[] {
229
- const shaders: ShaderProgram[] = [];
230
-
231
- // Generate PBR shader
232
- if (config.type === 'pbr' || config.pbr) {
233
- shaders.push(this.generatePBRShader(config));
234
- }
235
-
236
- return shaders;
237
- }
238
-
239
- /**
240
- * Generate PBR shader program
241
- */
242
- private generatePBRShader(_config: any): ShaderProgram {
243
- const vertexShader = `
244
- #version 300 es
245
- precision highp float;
246
-
247
- in vec3 aPosition;
248
- in vec3 aNormal;
249
- in vec2 aTexCoord;
250
- in vec3 aTangent;
251
-
252
- uniform mat4 uMatrix;
253
- uniform mat4 uNormalMatrix;
254
- uniform mat4 uProjectionMatrix;
255
-
256
- out vec3 vPosition;
257
- out vec3 vNormal;
258
- out vec2 vTexCoord;
259
- out mat3 vTBN;
260
-
261
- void main() {
262
- vPosition = (uMatrix * vec4(aPosition, 1.0)).xyz;
263
- vNormal = normalize((uNormalMatrix * vec4(aNormal, 0.0)).xyz);
264
- vTexCoord = aTexCoord;
265
-
266
- vec3 T = normalize((uNormalMatrix * vec4(aTangent, 0.0)).xyz);
267
- vec3 B = cross(vNormal, T);
268
- vTBN = mat3(T, B, vNormal);
269
-
270
- gl_Position = uProjectionMatrix * uMatrix * vec4(aPosition, 1.0);
271
- }
272
- `;
273
-
274
- const fragmentShader = `
275
- #version 300 es
276
- precision highp float;
277
-
278
- in vec3 vPosition;
279
- in vec3 vNormal;
280
- in vec2 vTexCoord;
281
- in mat3 vTBN;
282
-
283
- uniform sampler2D uBaseColorMap;
284
- uniform sampler2D uNormalMap;
285
- uniform sampler2D uRoughnessMap;
286
- uniform sampler2D uMetallicMap;
287
- uniform sampler2D uAOMap;
288
-
289
- uniform vec3 uViewPos;
290
- uniform float uMetallic;
291
- uniform float uRoughness;
292
-
293
- out vec4 FragColor;
294
-
295
- const float PI = 3.14159265359;
296
-
297
- vec3 fresnelSchlick(float cosTheta, vec3 F0) {
298
- return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
299
- }
300
-
301
- void main() {
302
- vec3 baseColor = texture(uBaseColorMap, vTexCoord).rgb;
303
- vec3 normal = normalize(vTBN * (texture(uNormalMap, vTexCoord).rgb * 2.0 - 1.0));
304
- float roughness = texture(uRoughnessMap, vTexCoord).r;
305
- float metallic = texture(uMetallicMap, vTexCoord).r;
306
- float ao = texture(uAOMap, vTexCoord).r;
307
-
308
- vec3 N = normalize(normal);
309
- vec3 V = normalize(uViewPos - vPosition);
310
-
311
- vec3 F0 = vec3(0.04);
312
- F0 = mix(F0, baseColor, metallic);
313
-
314
- // Simplified lighting (full PBR in production)
315
- vec3 lightDir = normalize(vec3(0.5, 1.0, 0.5));
316
- float NdotL = max(dot(N, lightDir), 0.0);
317
-
318
- vec3 result = baseColor * NdotL * ao;
319
-
320
- // Tone mapping
321
- result = result / (result + vec3(1.0));
322
- result = pow(result, vec3(1.0 / 2.2));
323
-
324
- FragColor = vec4(result, 1.0);
325
- }
326
- `;
327
-
328
- return {
329
- id: `shader_pbr_${Date.now()}`,
330
- name: 'PBRShader',
331
- vertexShader,
332
- fragmentShader,
333
- uniforms: {
334
- uMatrix: 'mat4',
335
- uNormalMatrix: 'mat4',
336
- uProjectionMatrix: 'mat4',
337
- uViewPos: 'vec3',
338
- uMetallic: 'float',
339
- uRoughness: 'float',
340
- uBaseColorMap: 'sampler2D',
341
- uNormalMap: 'sampler2D',
342
- uRoughnessMap: 'sampler2D',
343
- uMetallicMap: 'sampler2D',
344
- uAOMap: 'sampler2D',
345
- },
346
- compiled: false,
347
- compilationTime: 0,
348
- };
349
- }
350
-
351
- /**
352
- * Load textures from configuration
353
- */
354
- private loadTexturesFromConfig(config: any): TextureAsset[] {
355
- const textures: TextureAsset[] = [];
356
-
357
- if (config.textures) {
358
- config.textures.forEach((tex: any) => {
359
- textures.push({
360
- id: `tex_${Date.now()}_${Math.random()}`,
361
- path: tex.path,
362
- format: this.selectTextureFormat(config.compression),
363
- width: 2048,
364
- height: 2048,
365
- mipLevels: 8,
366
- gpuMemory: this.estimateTextureMemory(2048, 2048, this.selectTextureFormat(config.compression)),
367
- loaded: false,
368
- });
369
- });
370
- }
371
-
372
- return textures;
373
- }
374
-
375
- /**
376
- * Select appropriate texture format based on compression type
377
- */
378
- private selectTextureFormat(compression?: string): TextureAsset['format'] {
379
- switch (compression) {
380
- case 'dxt':
381
- return 'BC3';
382
- case 'astc':
383
- return 'ASTC';
384
- case 'basis':
385
- return 'PVRTC';
386
- default:
387
- return 'RGBA8';
388
- }
389
- }
390
-
391
- /**
392
- * Estimate texture memory usage
393
- */
394
- private estimateTextureMemory(width: number, height: number, format: TextureAsset['format']): number {
395
- const pixels = width * height;
396
- let bytesPerPixel = 4; // RGBA8
397
-
398
- switch (format) {
399
- case 'RGB565':
400
- bytesPerPixel = 2;
401
- break;
402
- case 'BC1':
403
- case 'BC3':
404
- case 'ASTC':
405
- bytesPerPixel = 0.5; // Compressed
406
- break;
407
- case 'PVRTC':
408
- bytesPerPixel = 0.25; // Highly compressed
409
- break;
410
- }
411
-
412
- // Account for mipmaps (roughly 1.33x base size)
413
- return (pixels * bytesPerPixel * 1.33) / (1024 * 1024);
414
- }
415
-
416
- /**
417
- * Estimate material GPU memory
418
- */
419
- private estimateMaterialMemory(asset: MaterialAsset): number {
420
- let total = 0;
421
-
422
- // Shader memory (typically negligible, but count)
423
- total += 0.1; // 100KB per shader
424
-
425
- // Texture memory
426
- asset.textures.forEach((tex) => {
427
- total += tex.gpuMemory;
428
- });
429
-
430
- return total;
431
- }
432
-
433
- /**
434
- * Compile shader program
435
- */
436
- private compileShader(shader: ShaderProgram): void {
437
- const start = performance.now();
438
-
439
- // In real implementation, this would compile to WebGL/WebGPU
440
- // For now, just mark as compiled
441
- shader.compiled = true;
442
- shader.compilationTime = performance.now() - start;
443
-
444
- this.shaderCache.set(shader.id, shader);
445
- }
446
-
447
- /**
448
- * Load texture into GPU memory
449
- */
450
- private loadTexture(texture: TextureAsset): void {
451
- // In real implementation, this would load from disk/network
452
- // For now, just mark as loaded
453
- texture.loaded = true;
454
- this.textureCache.set(texture.id, texture);
455
- }
456
-
457
- /**
458
- * Setup shadow mapping
459
- */
460
- private setupShadowMapping(_config: any): void {
461
- // Configure shadow map resolution and filtering
462
- // const shadowQuality = this.platformConfig.shadowQuality;
463
- // const _shadowResolution = this.shadowResolutionForQuality(shadowQuality);
464
-
465
- // Create shadow map textures
466
- // This would allocate GPU memory for shadow maps
467
- }
468
-
469
- /**
470
- * Get shadow map resolution for quality level
471
- */
472
- // private shadowResolutionForQuality(quality: string): number {
473
- // switch (quality) {
474
- // case 'none':
475
- // return 0;
476
- // case 'low':
477
- // return 512;
478
- // case 'medium':
479
- // return 1024;
480
- // case 'high':
481
- // return 2048;
482
- // default:
483
- // return 1024;
484
- // }
485
- // }
486
-
487
- /**
488
- * Setup global illumination
489
- */
490
- private setupGlobalIllumination(__config: any): void {
491
- // Create light probes for indirect lighting
492
- // const _probeCount = __config.probes || 16;
493
-
494
- // Allocate GPU memory for probes
495
- // Each probe stores 6 faces of cubemap
496
- }
497
-
498
- /**
499
- * Apply quality preset
500
- */
501
- private applyQualityPreset(quality: string): void {
502
- switch (quality) {
503
- case 'low':
504
- this.platformConfig.maxTextureResolution = 512;
505
- this.platformConfig.shadowQuality = 'none';
506
- this.platformConfig.targetFPS = 30;
507
- break;
508
-
509
- case 'medium':
510
- this.platformConfig.maxTextureResolution = 1024;
511
- this.platformConfig.shadowQuality = 'low';
512
- this.platformConfig.targetFPS = 60;
513
- break;
514
-
515
- case 'high':
516
- this.platformConfig.maxTextureResolution = 2048;
517
- this.platformConfig.shadowQuality = 'medium';
518
- this.platformConfig.targetFPS = 60;
519
- break;
520
-
521
- case 'ultra':
522
- this.platformConfig.maxTextureResolution = 4096;
523
- this.platformConfig.shadowQuality = 'high';
524
- this.platformConfig.targetFPS = 120;
525
- break;
526
- }
527
- }
528
-
529
- /**
530
- * Enable LOD system
531
- */
532
- private enableLOD(): void {
533
- // Configure automatic LOD switching based on screen coverage
534
- }
535
-
536
- /**
537
- * Enable culling
538
- */
539
- private enableCulling(): void {
540
- // Enable frustum culling and occlusion culling
541
- }
542
-
543
- /**
544
- * Get platform-specific configuration
545
- */
546
- private getPlatformConfig(platform: Platform): PlatformConfig {
547
- switch (platform) {
548
- case 'mobile':
549
- return {
550
- platform: 'mobile',
551
- maxGPUMemory: 256,
552
- maxDrawCalls: 200,
553
- maxTextureResolution: 512,
554
- targetFPS: 30,
555
- shadowQuality: 'none',
556
- textureCompression: 'astc',
557
- instancingEnabled: true,
558
- maxLights: 2,
559
- maxShadowCasters: 0,
560
- };
561
-
562
- case 'vr':
563
- return {
564
- platform: 'vr',
565
- maxGPUMemory: 512,
566
- maxDrawCalls: 500,
567
- maxTextureResolution: 2048,
568
- targetFPS: 90,
569
- shadowQuality: 'low',
570
- textureCompression: 'basis',
571
- instancingEnabled: true,
572
- maxLights: 4,
573
- maxShadowCasters: 2,
574
- };
575
-
576
- case 'desktop':
577
- return {
578
- platform: 'desktop',
579
- maxGPUMemory: 2048,
580
- maxDrawCalls: 2000,
581
- maxTextureResolution: 4096,
582
- targetFPS: 120,
583
- shadowQuality: 'high',
584
- textureCompression: 'none',
585
- instancingEnabled: true,
586
- maxLights: 8,
587
- maxShadowCasters: 4,
588
- };
589
- }
590
- }
591
-
592
- /**
593
- * Initialize performance metrics
594
- */
595
- private initializeMetrics(): PerformanceMetrics {
596
- return {
597
- drawCalls: 0,
598
- trianglesRendered: 0,
599
- gpuFrameTime: 0,
600
- cpuFrameTime: 0,
601
- fps: 60,
602
- gpuMemoryUsed: 0,
603
- textureBinds: 0,
604
- shaderSwitches: 0,
605
- batchCount: 0,
606
- };
607
- }
608
-
609
- /**
610
- * Get current GPU memory estimate
611
- */
612
- getGPUMemoryEstimate(): GPUMemoryEstimate {
613
- let textureMemory = 0;
614
- let geometryMemory = 0;
615
- let bufferMemory = 0;
616
-
617
- this.textureCache.forEach((tex) => {
618
- if (tex.loaded) {
619
- textureMemory += tex.gpuMemory;
620
- }
621
- });
622
-
623
- this.materialCache.forEach((mat) => {
624
- geometryMemory += mat.gpuMemory;
625
- });
626
-
627
- const total = textureMemory + geometryMemory + bufferMemory;
628
-
629
- return {
630
- textureMemory,
631
- geometryMemory,
632
- bufferMemory,
633
- estimatedTotal: total,
634
- budget: this.platformConfig.maxGPUMemory,
635
- utilization: (total / this.platformConfig.maxGPUMemory) * 100,
636
- };
637
- }
638
-
639
- /**
640
- * Get performance metrics
641
- */
642
- getPerformanceMetrics(): PerformanceMetrics {
643
- return { ...this.metrics };
644
- }
645
-
646
- /**
647
- * Set memory budget
648
- */
649
- setMemoryBudget(budget: number): void {
650
- // this._memoryBudget = budget; // field removed
651
- this.platformConfig.maxGPUMemory = budget;
652
- }
653
-
654
- /**
655
- * Optimize for specific platform
656
- */
657
- optimizePlatform(platform: Platform): void {
658
- this.platformConfig = this.getPlatformConfig(platform);
659
- }
660
- }
661
-
662
- export default HololandGraphicsPipelineService;