@holoscript/core 2.0.0 → 2.0.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/LICENSE +21 -0
- package/dist/chunk-3N67RLQP.cjs +1298 -0
- package/dist/chunk-3N67RLQP.cjs.map +1 -0
- package/dist/chunk-3X2EGU7Z.cjs +52 -0
- package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
- package/dist/chunk-4CV4JOE5.js +24 -0
- package/dist/chunk-4CV4JOE5.js.map +1 -0
- package/dist/chunk-4OHVW4XR.cjs +1027 -0
- package/dist/chunk-4OHVW4XR.cjs.map +1 -0
- package/dist/chunk-CZLDE2OZ.cjs +28 -0
- package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
- package/{src/HoloScriptRuntime.ts → dist/chunk-EU6CZMGJ.js} +437 -794
- package/dist/chunk-EU6CZMGJ.js.map +1 -0
- package/dist/chunk-KWYIVRIH.js +344 -0
- package/dist/chunk-KWYIVRIH.js.map +1 -0
- package/dist/chunk-MCP6D4LT.js +1025 -0
- package/dist/chunk-MCP6D4LT.js.map +1 -0
- package/dist/chunk-SATNCODL.js +45 -0
- package/dist/chunk-SATNCODL.js.map +1 -0
- package/dist/chunk-VMZN4EVR.cjs +347 -0
- package/dist/chunk-VMZN4EVR.cjs.map +1 -0
- package/{src/HoloScriptDebugger.ts → dist/chunk-VYIDLUCV.js} +118 -257
- package/dist/chunk-VYIDLUCV.js.map +1 -0
- package/dist/chunk-WFI4T3XB.cjs +424 -0
- package/dist/chunk-WFI4T3XB.cjs.map +1 -0
- package/dist/debugger.cjs +20 -0
- package/dist/debugger.cjs.map +1 -0
- package/dist/debugger.d.cts +171 -0
- package/dist/debugger.d.ts +171 -0
- package/dist/debugger.js +7 -0
- package/dist/debugger.js.map +1 -0
- package/dist/index.cjs +6006 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2482 -0
- package/dist/index.d.ts +2482 -0
- package/dist/index.js +5926 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.cjs +14 -0
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +139 -0
- package/dist/parser.d.ts +139 -0
- package/dist/parser.js +5 -0
- package/dist/parser.js.map +1 -0
- package/dist/runtime.cjs +14 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +180 -0
- package/dist/runtime.d.ts +180 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/type-checker.cjs +17 -0
- package/dist/type-checker.cjs.map +1 -0
- package/dist/type-checker.d.cts +105 -0
- package/dist/type-checker.d.ts +105 -0
- package/dist/type-checker.js +4 -0
- package/dist/type-checker.js.map +1 -0
- package/dist/types-D6g4ACjP.d.cts +262 -0
- package/dist/types-D6g4ACjP.d.ts +262 -0
- package/package.json +11 -8
- package/src/HoloScript2DParser.js +0 -227
- package/src/HoloScript2DParser.ts +0 -261
- package/src/HoloScriptCodeParser.js +0 -1102
- package/src/HoloScriptCodeParser.ts +0 -1188
- package/src/HoloScriptDebugger.js +0 -458
- package/src/HoloScriptParser.js +0 -338
- package/src/HoloScriptParser.ts +0 -397
- package/src/HoloScriptPlusParser.js +0 -371
- package/src/HoloScriptPlusParser.ts +0 -543
- package/src/HoloScriptRuntime.js +0 -1399
- package/src/HoloScriptRuntime.test.js +0 -351
- package/src/HoloScriptRuntime.test.ts +0 -436
- package/src/HoloScriptTypeChecker.js +0 -356
- package/src/HoloScriptTypeChecker.ts +0 -475
- package/src/__tests__/GraphicsServices.test.js +0 -357
- package/src/__tests__/GraphicsServices.test.ts +0 -427
- package/src/__tests__/HoloScriptPlusParser.test.js +0 -317
- package/src/__tests__/HoloScriptPlusParser.test.ts +0 -392
- package/src/__tests__/integration.test.js +0 -336
- package/src/__tests__/integration.test.ts +0 -416
- package/src/__tests__/performance.bench.js +0 -218
- package/src/__tests__/performance.bench.ts +0 -262
- package/src/__tests__/type-checker.test.js +0 -60
- package/src/__tests__/type-checker.test.ts +0 -73
- package/src/index.js +0 -217
- package/src/index.ts +0 -426
- package/src/interop/Interoperability.js +0 -413
- package/src/interop/Interoperability.ts +0 -494
- package/src/logger.js +0 -42
- package/src/logger.ts +0 -57
- package/src/parser/EnhancedParser.js +0 -205
- package/src/parser/EnhancedParser.ts +0 -251
- package/src/parser/HoloScriptPlusParser.js +0 -928
- package/src/parser/HoloScriptPlusParser.ts +0 -1089
- package/src/runtime/HoloScriptPlusRuntime.js +0 -674
- package/src/runtime/HoloScriptPlusRuntime.ts +0 -861
- package/src/runtime/PerformanceTelemetry.js +0 -323
- package/src/runtime/PerformanceTelemetry.ts +0 -467
- package/src/runtime/RuntimeOptimization.js +0 -361
- package/src/runtime/RuntimeOptimization.ts +0 -416
- package/src/services/HololandGraphicsPipelineService.js +0 -506
- package/src/services/HololandGraphicsPipelineService.ts +0 -662
- package/src/services/PlatformPerformanceOptimizer.js +0 -356
- package/src/services/PlatformPerformanceOptimizer.ts +0 -503
- package/src/state/ReactiveState.js +0 -427
- package/src/state/ReactiveState.ts +0 -572
- package/src/tools/DeveloperExperience.js +0 -376
- package/src/tools/DeveloperExperience.ts +0 -438
- package/src/traits/AIDriverTrait.js +0 -322
- package/src/traits/AIDriverTrait.test.js +0 -329
- package/src/traits/AIDriverTrait.test.ts +0 -357
- package/src/traits/AIDriverTrait.ts +0 -474
- package/src/traits/LightingTrait.js +0 -313
- package/src/traits/LightingTrait.test.js +0 -410
- package/src/traits/LightingTrait.test.ts +0 -462
- package/src/traits/LightingTrait.ts +0 -505
- package/src/traits/MaterialTrait.js +0 -194
- package/src/traits/MaterialTrait.test.js +0 -286
- package/src/traits/MaterialTrait.test.ts +0 -329
- package/src/traits/MaterialTrait.ts +0 -324
- package/src/traits/RenderingTrait.js +0 -356
- package/src/traits/RenderingTrait.test.js +0 -363
- package/src/traits/RenderingTrait.test.ts +0 -427
- package/src/traits/RenderingTrait.ts +0 -555
- package/src/traits/VRTraitSystem.js +0 -740
- package/src/traits/VRTraitSystem.ts +0 -1040
- package/src/traits/VoiceInputTrait.js +0 -284
- package/src/traits/VoiceInputTrait.test.js +0 -226
- package/src/traits/VoiceInputTrait.test.ts +0 -252
- package/src/traits/VoiceInputTrait.ts +0 -401
- package/src/types/AdvancedTypeSystem.js +0 -226
- package/src/types/AdvancedTypeSystem.ts +0 -494
- package/src/types/HoloScriptPlus.d.ts +0 -853
- package/src/types.js +0 -6
- package/src/types.ts +0 -369
- package/tsconfig.json +0 -23
- package/tsup.config.d.ts +0 -2
- package/tsup.config.js +0 -18
- package/tsup.config.ts +0 -19
|
@@ -1,555 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @holoscript/core Rendering Trait
|
|
3
|
-
*
|
|
4
|
-
* Enables GPU optimization directives, level of detail management,
|
|
5
|
-
* and rendering performance tuning
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export type CullingMode = 'none' | 'back' | 'front' | 'both';
|
|
9
|
-
export type LodStrategy = 'automatic' | 'manual' | 'disabled';
|
|
10
|
-
export type GPUResourceTier = 'low' | 'medium' | 'high' | 'ultra';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Level of Detail configuration
|
|
14
|
-
*/
|
|
15
|
-
export interface LODLevel {
|
|
16
|
-
/** LOD level (0 = highest detail) */
|
|
17
|
-
level: number;
|
|
18
|
-
|
|
19
|
-
/** Screen-relative size threshold for this LOD */
|
|
20
|
-
screenRelativeSize: number;
|
|
21
|
-
|
|
22
|
-
/** Polygon reduction ratio (0-1) */
|
|
23
|
-
polygonReduction?: number;
|
|
24
|
-
|
|
25
|
-
/** Disable features at this LOD */
|
|
26
|
-
disabledFeatures?: ('shadows' | 'normals' | 'specular' | 'animation')[];
|
|
27
|
-
|
|
28
|
-
/** Texture resolution multiplier (0.25 = 1/4 resolution) */
|
|
29
|
-
textureScale?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Culling configuration
|
|
34
|
-
*/
|
|
35
|
-
export interface CullingConfig {
|
|
36
|
-
/** Face culling mode */
|
|
37
|
-
mode: CullingMode;
|
|
38
|
-
|
|
39
|
-
/** Frustum culling */
|
|
40
|
-
frustum?: boolean;
|
|
41
|
-
|
|
42
|
-
/** Occlusion culling */
|
|
43
|
-
occlusion?: boolean;
|
|
44
|
-
|
|
45
|
-
/** Occlusion query distance in units */
|
|
46
|
-
occlusionDistance?: number;
|
|
47
|
-
|
|
48
|
-
/** Hierarchical Z-buffer culling */
|
|
49
|
-
hierarchicalZ?: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Batching configuration
|
|
54
|
-
*/
|
|
55
|
-
export interface BatchingConfig {
|
|
56
|
-
/** Static batching (for non-moving objects) */
|
|
57
|
-
static?: boolean;
|
|
58
|
-
|
|
59
|
-
/** Dynamic batching */
|
|
60
|
-
dynamic?: boolean;
|
|
61
|
-
|
|
62
|
-
/** Max batch size in vertices */
|
|
63
|
-
maxBatchSize?: number;
|
|
64
|
-
|
|
65
|
-
/** GPU instancing */
|
|
66
|
-
instancing?: boolean;
|
|
67
|
-
|
|
68
|
-
/** Instancing buffer size */
|
|
69
|
-
maxInstanceCount?: number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Texture optimization
|
|
74
|
-
*/
|
|
75
|
-
export interface TextureOptimization {
|
|
76
|
-
/** Enable texture streaming */
|
|
77
|
-
streaming?: boolean;
|
|
78
|
-
|
|
79
|
-
/** Streaming budget in MB */
|
|
80
|
-
streamingBudget?: number;
|
|
81
|
-
|
|
82
|
-
/** Virtual texture paging */
|
|
83
|
-
virtualTexturing?: boolean;
|
|
84
|
-
|
|
85
|
-
/** Texture compression */
|
|
86
|
-
compression?: 'none' | 'dxt' | 'astc' | 'basis' | 'auto';
|
|
87
|
-
|
|
88
|
-
/** Mipmap generation */
|
|
89
|
-
mipmaps?: boolean;
|
|
90
|
-
|
|
91
|
-
/** Max texture resolution */
|
|
92
|
-
maxResolution?: 256 | 512 | 1024 | 2048 | 4096;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Shader optimization
|
|
97
|
-
*/
|
|
98
|
-
export interface ShaderOptimization {
|
|
99
|
-
/** Shader LOD bias */
|
|
100
|
-
lodBias?: number;
|
|
101
|
-
|
|
102
|
-
/** Use simplified shaders for distant objects */
|
|
103
|
-
simplifiedShaders?: boolean;
|
|
104
|
-
|
|
105
|
-
/** Compile shader variants for performance */
|
|
106
|
-
variants?: {
|
|
107
|
-
[key: string]: {
|
|
108
|
-
enabled: boolean;
|
|
109
|
-
cost?: 'low' | 'medium' | 'high';
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Rendering optimization hints
|
|
116
|
-
*/
|
|
117
|
-
export interface RenderingOptimization {
|
|
118
|
-
/** LOD strategy */
|
|
119
|
-
lodStrategy?: LodStrategy;
|
|
120
|
-
|
|
121
|
-
/** LOD levels */
|
|
122
|
-
lodLevels?: LODLevel[];
|
|
123
|
-
|
|
124
|
-
/** Culling configuration */
|
|
125
|
-
culling?: CullingConfig;
|
|
126
|
-
|
|
127
|
-
/** Batching configuration */
|
|
128
|
-
batching?: BatchingConfig;
|
|
129
|
-
|
|
130
|
-
/** Texture optimization */
|
|
131
|
-
textures?: TextureOptimization;
|
|
132
|
-
|
|
133
|
-
/** Shader optimization */
|
|
134
|
-
shaders?: ShaderOptimization;
|
|
135
|
-
|
|
136
|
-
/** Target GPU tier */
|
|
137
|
-
targetGPUTier?: GPUResourceTier;
|
|
138
|
-
|
|
139
|
-
/** Fixed time-step rendering (for VR/AR) */
|
|
140
|
-
fixedTimestep?: number;
|
|
141
|
-
|
|
142
|
-
/** Enable adaptive quality */
|
|
143
|
-
adaptiveQuality?: boolean;
|
|
144
|
-
|
|
145
|
-
/** Target frame rate */
|
|
146
|
-
targetFrameRate?: number;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* RenderingTrait - Manages GPU optimization and rendering performance
|
|
151
|
-
*/
|
|
152
|
-
export class RenderingTrait {
|
|
153
|
-
private optimization: RenderingOptimization;
|
|
154
|
-
|
|
155
|
-
constructor(config?: RenderingOptimization) {
|
|
156
|
-
this.optimization = {
|
|
157
|
-
lodStrategy: 'automatic',
|
|
158
|
-
culling: {
|
|
159
|
-
mode: 'back',
|
|
160
|
-
frustum: true,
|
|
161
|
-
occlusion: true,
|
|
162
|
-
},
|
|
163
|
-
batching: {
|
|
164
|
-
static: true,
|
|
165
|
-
dynamic: true,
|
|
166
|
-
instancing: true,
|
|
167
|
-
maxInstanceCount: 1000,
|
|
168
|
-
},
|
|
169
|
-
textures: {
|
|
170
|
-
streaming: true,
|
|
171
|
-
compression: 'auto',
|
|
172
|
-
mipmaps: true,
|
|
173
|
-
maxResolution: 2048,
|
|
174
|
-
},
|
|
175
|
-
shaders: {
|
|
176
|
-
simplifiedShaders: true,
|
|
177
|
-
lodBias: 0,
|
|
178
|
-
},
|
|
179
|
-
targetGPUTier: 'high',
|
|
180
|
-
adaptiveQuality: true,
|
|
181
|
-
targetFrameRate: 60,
|
|
182
|
-
...config,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Get rendering optimization config
|
|
188
|
-
*/
|
|
189
|
-
public getOptimization(): RenderingOptimization {
|
|
190
|
-
return JSON.parse(JSON.stringify(this.optimization));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Update rendering configuration
|
|
195
|
-
*/
|
|
196
|
-
public updateOptimization(updates: Partial<RenderingOptimization>): void {
|
|
197
|
-
this.optimization = { ...this.optimization, ...updates };
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Setup LOD levels (3 levels is typical)
|
|
202
|
-
*/
|
|
203
|
-
public setupLODLevels(strategy: LodStrategy = 'automatic'): void {
|
|
204
|
-
const levels: LODLevel[] = [
|
|
205
|
-
{
|
|
206
|
-
level: 0,
|
|
207
|
-
screenRelativeSize: 0.5,
|
|
208
|
-
polygonReduction: 1.0,
|
|
209
|
-
textureScale: 1.0,
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
level: 1,
|
|
213
|
-
screenRelativeSize: 0.25,
|
|
214
|
-
polygonReduction: 0.6,
|
|
215
|
-
disabledFeatures: ['specular'],
|
|
216
|
-
textureScale: 0.5,
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
level: 2,
|
|
220
|
-
screenRelativeSize: 0.1,
|
|
221
|
-
polygonReduction: 0.3,
|
|
222
|
-
disabledFeatures: ['specular', 'normals'],
|
|
223
|
-
textureScale: 0.25,
|
|
224
|
-
},
|
|
225
|
-
];
|
|
226
|
-
|
|
227
|
-
this.optimization.lodStrategy = strategy;
|
|
228
|
-
this.optimization.lodLevels = levels;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Get LOD levels
|
|
233
|
-
*/
|
|
234
|
-
public getLODLevels(): LODLevel[] {
|
|
235
|
-
return [...(this.optimization.lodLevels || [])];
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Configure culling
|
|
240
|
-
*/
|
|
241
|
-
public setCulling(config: Partial<CullingConfig>): void {
|
|
242
|
-
const defaultCulling: CullingConfig = { mode: 'back' };
|
|
243
|
-
this.optimization.culling = {
|
|
244
|
-
...defaultCulling,
|
|
245
|
-
...this.optimization.culling,
|
|
246
|
-
...config,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Enable frustum culling
|
|
252
|
-
*/
|
|
253
|
-
public setFrustumCulling(enabled: boolean): void {
|
|
254
|
-
if (!this.optimization.culling) {
|
|
255
|
-
this.optimization.culling = { mode: 'back' };
|
|
256
|
-
}
|
|
257
|
-
this.optimization.culling.frustum = enabled;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Enable occlusion culling
|
|
262
|
-
*/
|
|
263
|
-
public setOcclusionCulling(
|
|
264
|
-
enabled: boolean,
|
|
265
|
-
distance?: number
|
|
266
|
-
): void {
|
|
267
|
-
if (!this.optimization.culling) {
|
|
268
|
-
this.optimization.culling = { mode: 'back' };
|
|
269
|
-
}
|
|
270
|
-
this.optimization.culling.occlusion = enabled;
|
|
271
|
-
if (distance) {
|
|
272
|
-
this.optimization.culling.occlusionDistance = distance;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Configure batching
|
|
278
|
-
*/
|
|
279
|
-
public setBatching(config: Partial<BatchingConfig>): void {
|
|
280
|
-
this.optimization.batching = {
|
|
281
|
-
...this.optimization.batching,
|
|
282
|
-
...config,
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Enable GPU instancing
|
|
288
|
-
*/
|
|
289
|
-
public setInstancing(enabled: boolean, maxInstances?: number): void {
|
|
290
|
-
if (!this.optimization.batching) {
|
|
291
|
-
this.optimization.batching = {};
|
|
292
|
-
}
|
|
293
|
-
this.optimization.batching.instancing = enabled;
|
|
294
|
-
if (maxInstances) {
|
|
295
|
-
this.optimization.batching.maxInstanceCount = maxInstances;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Configure texture optimization
|
|
301
|
-
*/
|
|
302
|
-
public setTextureOptimization(config: Partial<TextureOptimization>): void {
|
|
303
|
-
this.optimization.textures = {
|
|
304
|
-
...this.optimization.textures,
|
|
305
|
-
...config,
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Enable texture streaming
|
|
311
|
-
*/
|
|
312
|
-
public setTextureStreaming(
|
|
313
|
-
enabled: boolean,
|
|
314
|
-
budgetMB?: number
|
|
315
|
-
): void {
|
|
316
|
-
if (!this.optimization.textures) {
|
|
317
|
-
this.optimization.textures = {};
|
|
318
|
-
}
|
|
319
|
-
this.optimization.textures.streaming = enabled;
|
|
320
|
-
if (budgetMB) {
|
|
321
|
-
this.optimization.textures.streamingBudget = budgetMB;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Set texture compression
|
|
327
|
-
*/
|
|
328
|
-
public setTextureCompression(
|
|
329
|
-
compression: 'none' | 'dxt' | 'astc' | 'basis' | 'auto'
|
|
330
|
-
): void {
|
|
331
|
-
if (!this.optimization.textures) {
|
|
332
|
-
this.optimization.textures = {};
|
|
333
|
-
}
|
|
334
|
-
this.optimization.textures.compression = compression;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Set max texture resolution
|
|
339
|
-
*/
|
|
340
|
-
public setMaxTextureResolution(
|
|
341
|
-
resolution: 256 | 512 | 1024 | 2048 | 4096
|
|
342
|
-
): void {
|
|
343
|
-
if (!this.optimization.textures) {
|
|
344
|
-
this.optimization.textures = {};
|
|
345
|
-
}
|
|
346
|
-
this.optimization.textures.maxResolution = resolution;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Configure shader optimization
|
|
351
|
-
*/
|
|
352
|
-
public setShaderOptimization(config: Partial<ShaderOptimization>): void {
|
|
353
|
-
this.optimization.shaders = {
|
|
354
|
-
...this.optimization.shaders,
|
|
355
|
-
...config,
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Set target GPU tier
|
|
361
|
-
*/
|
|
362
|
-
public setTargetGPUTier(tier: GPUResourceTier): void {
|
|
363
|
-
this.optimization.targetGPUTier = tier;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Enable adaptive quality (adjust based on frame rate)
|
|
368
|
-
*/
|
|
369
|
-
public setAdaptiveQuality(
|
|
370
|
-
enabled: boolean,
|
|
371
|
-
targetFrameRate?: number
|
|
372
|
-
): void {
|
|
373
|
-
this.optimization.adaptiveQuality = enabled;
|
|
374
|
-
if (targetFrameRate) {
|
|
375
|
-
this.optimization.targetFrameRate = targetFrameRate;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Set fixed timestep for VR/AR
|
|
381
|
-
*/
|
|
382
|
-
public setFixedTimestep(timestep: number): void {
|
|
383
|
-
this.optimization.fixedTimestep = timestep;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Get rendering preset for quality level
|
|
388
|
-
*/
|
|
389
|
-
public getPresetForQuality(
|
|
390
|
-
quality: 'low' | 'medium' | 'high' | 'ultra'
|
|
391
|
-
): RenderingOptimization {
|
|
392
|
-
const presets: Record<string, Partial<RenderingOptimization>> = {
|
|
393
|
-
low: {
|
|
394
|
-
targetGPUTier: 'low',
|
|
395
|
-
lodStrategy: 'automatic',
|
|
396
|
-
culling: { mode: 'back', frustum: true, occlusion: false },
|
|
397
|
-
batching: { instancing: true, maxInstanceCount: 500 },
|
|
398
|
-
textures: {
|
|
399
|
-
compression: 'astc',
|
|
400
|
-
maxResolution: 512,
|
|
401
|
-
streaming: true,
|
|
402
|
-
streamingBudget: 128,
|
|
403
|
-
},
|
|
404
|
-
adaptiveQuality: true,
|
|
405
|
-
targetFrameRate: 30,
|
|
406
|
-
},
|
|
407
|
-
medium: {
|
|
408
|
-
targetGPUTier: 'medium',
|
|
409
|
-
lodStrategy: 'automatic',
|
|
410
|
-
culling: { mode: 'back', frustum: true, occlusion: true },
|
|
411
|
-
batching: { instancing: true, maxInstanceCount: 1000 },
|
|
412
|
-
textures: {
|
|
413
|
-
compression: 'basis',
|
|
414
|
-
maxResolution: 1024,
|
|
415
|
-
streaming: true,
|
|
416
|
-
streamingBudget: 256,
|
|
417
|
-
},
|
|
418
|
-
adaptiveQuality: true,
|
|
419
|
-
targetFrameRate: 60,
|
|
420
|
-
},
|
|
421
|
-
high: {
|
|
422
|
-
targetGPUTier: 'high',
|
|
423
|
-
lodStrategy: 'automatic',
|
|
424
|
-
culling: { mode: 'back', frustum: true, occlusion: true },
|
|
425
|
-
batching: { instancing: true, maxInstanceCount: 2000 },
|
|
426
|
-
textures: {
|
|
427
|
-
compression: 'dxt',
|
|
428
|
-
maxResolution: 2048,
|
|
429
|
-
streaming: true,
|
|
430
|
-
streamingBudget: 512,
|
|
431
|
-
},
|
|
432
|
-
adaptiveQuality: false,
|
|
433
|
-
targetFrameRate: 60,
|
|
434
|
-
},
|
|
435
|
-
ultra: {
|
|
436
|
-
targetGPUTier: 'ultra',
|
|
437
|
-
lodStrategy: 'manual',
|
|
438
|
-
culling: {
|
|
439
|
-
mode: 'back',
|
|
440
|
-
frustum: true,
|
|
441
|
-
occlusion: true,
|
|
442
|
-
hierarchicalZ: true,
|
|
443
|
-
},
|
|
444
|
-
batching: { instancing: true, maxInstanceCount: 5000 },
|
|
445
|
-
textures: {
|
|
446
|
-
compression: 'none',
|
|
447
|
-
maxResolution: 4096,
|
|
448
|
-
virtualTexturing: true,
|
|
449
|
-
streaming: true,
|
|
450
|
-
streamingBudget: 1024,
|
|
451
|
-
},
|
|
452
|
-
adaptiveQuality: false,
|
|
453
|
-
targetFrameRate: 120,
|
|
454
|
-
},
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
return { ...this.optimization, ...presets[quality] };
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Apply quality preset
|
|
462
|
-
*/
|
|
463
|
-
public applyQualityPreset(quality: 'low' | 'medium' | 'high' | 'ultra'): void {
|
|
464
|
-
const preset = this.getPresetForQuality(quality);
|
|
465
|
-
this.optimization = preset as RenderingOptimization;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Estimate GPU memory usage
|
|
470
|
-
*/
|
|
471
|
-
public estimateGPUMemory(): {
|
|
472
|
-
textureMemory: number;
|
|
473
|
-
vertexBuffers: number;
|
|
474
|
-
estimatedTotal: number;
|
|
475
|
-
} {
|
|
476
|
-
let textureMemory = 0;
|
|
477
|
-
let vertexBuffers = 0;
|
|
478
|
-
|
|
479
|
-
// Estimate texture memory based on max resolution
|
|
480
|
-
// Assuming RGBA format at 4 bytes per pixel
|
|
481
|
-
const maxRes = this.optimization.textures?.maxResolution || 2048;
|
|
482
|
-
textureMemory = (maxRes * maxRes * 4) / (1024 * 1024); // MB
|
|
483
|
-
|
|
484
|
-
// Estimate based on instancing
|
|
485
|
-
// Typical mesh: 10K vertices, position (12) + normal (12) + UV (8) + color (4) = 36 bytes
|
|
486
|
-
const instanceCount = this.optimization.batching?.maxInstanceCount || 1000;
|
|
487
|
-
const verticesPerMesh = 10000;
|
|
488
|
-
vertexBuffers = ((verticesPerMesh * 36 * instanceCount) / (1024 * 1024)) * 0.1; // 10% for practical estimate
|
|
489
|
-
|
|
490
|
-
return {
|
|
491
|
-
textureMemory: Math.round(textureMemory),
|
|
492
|
-
vertexBuffers: Math.max(1, Math.round(vertexBuffers)), // At least 1MB
|
|
493
|
-
estimatedTotal: Math.round(textureMemory + Math.max(1, vertexBuffers)),
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Get rendering statistics/info
|
|
499
|
-
*/
|
|
500
|
-
public getInfo(): string {
|
|
501
|
-
const tier = this.optimization.targetGPUTier;
|
|
502
|
-
const lod = this.optimization.lodStrategy;
|
|
503
|
-
const culling = this.optimization.culling?.mode;
|
|
504
|
-
const instancing = this.optimization.batching?.instancing ? 'yes' : 'no';
|
|
505
|
-
const memory = this.estimateGPUMemory();
|
|
506
|
-
|
|
507
|
-
return `Rendering: tier=${tier} | LOD=${lod} | culling=${culling} | instancing=${instancing} | ` +
|
|
508
|
-
`memory=${memory.estimatedTotal}MB`;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Optimize for VR/AR (fixed timestep, fast culling)
|
|
513
|
-
*/
|
|
514
|
-
public optimizeForVRAR(targetFPS: number = 90): void {
|
|
515
|
-
this.optimization.fixedTimestep = 1 / targetFPS;
|
|
516
|
-
this.optimization.targetFrameRate = targetFPS;
|
|
517
|
-
this.setOcclusionCulling(true, 50);
|
|
518
|
-
this.setInstancing(true, 5000);
|
|
519
|
-
this.setAdaptiveQuality(true, targetFPS);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Optimize for mobile (lower resources)
|
|
524
|
-
*/
|
|
525
|
-
public optimizeForMobile(): void {
|
|
526
|
-
this.applyQualityPreset('low');
|
|
527
|
-
this.setTextureCompression('astc');
|
|
528
|
-
this.setInstancing(true, 256);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Optimize for desktop (higher resources)
|
|
533
|
-
*/
|
|
534
|
-
public optimizeForDesktop(): void {
|
|
535
|
-
this.applyQualityPreset('ultra');
|
|
536
|
-
this.setTextureCompression('none');
|
|
537
|
-
this.setInstancing(true, 5000);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Dispose and cleanup
|
|
542
|
-
*/
|
|
543
|
-
public dispose(): void {
|
|
544
|
-
// Cleanup if needed
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* HoloScript+ @rendering trait factory
|
|
550
|
-
*/
|
|
551
|
-
export function createRenderingTrait(
|
|
552
|
-
config?: RenderingOptimization
|
|
553
|
-
): RenderingTrait {
|
|
554
|
-
return new RenderingTrait(config);
|
|
555
|
-
}
|