@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,543 +0,0 @@
1
- /**
2
- * HoloScriptPlus Parser - Extended DSL with Trait Annotations
3
- *
4
- * Extends HoloScript with support for:
5
- * - @material trait annotations for PBR materials
6
- * - @lighting trait annotations for dynamic lighting
7
- * - @rendering trait annotations for GPU optimization
8
- *
9
- * Syntax:
10
- * orb#sphere {
11
- * @material { type: pbr, metallic: 0.5, roughness: 0.4 }
12
- * @lighting { preset: studio, shadows: true }
13
- * @rendering { quality: high, lod: true }
14
- * }
15
- */
16
-
17
- import { HoloScriptCodeParser } from './HoloScriptCodeParser';
18
- import type {
19
- ASTNode,
20
- OrbNode,
21
- } from './types';
22
-
23
- // ============================================================================
24
- // Trait Annotation Types
25
- // ============================================================================
26
-
27
- export interface TraitAnnotation {
28
- type: 'material' | 'lighting' | 'rendering';
29
- config: Record<string, unknown>;
30
- line?: number;
31
- column?: number;
32
- }
33
-
34
- export interface MaterialTraitAnnotation extends TraitAnnotation {
35
- type: 'material';
36
- config: {
37
- type?: string;
38
- pbr?: {
39
- baseColor?: { r: number; g: number; b: number };
40
- metallic?: number;
41
- roughness?: number;
42
- ambientOcclusion?: number;
43
- emission?: { r: number; g: number; b: number };
44
- emissionStrength?: number;
45
- };
46
- textures?: Array<{ path: string; channel: string }>;
47
- compression?: 'none' | 'dxt' | 'astc' | 'basis';
48
- instancing?: boolean;
49
- streaming?: boolean;
50
- };
51
- }
52
-
53
- export interface LightingTraitAnnotation extends TraitAnnotation {
54
- type: 'lighting';
55
- config: {
56
- preset?: 'studio' | 'outdoor' | 'interior' | 'night' | 'sunset';
57
- lights?: Array<{
58
- type: 'directional' | 'point' | 'spot' | 'area' | 'ambient';
59
- position?: { x: number; y: number; z: number };
60
- direction?: { x: number; y: number; z: number };
61
- color?: { r: number; g: number; b: number };
62
- intensity?: number;
63
- range?: number;
64
- shadows?: boolean;
65
- }>;
66
- globalIllumination?: {
67
- skyColor?: { r: number; g: number; b: number };
68
- groundColor?: { r: number; g: number; b: number };
69
- probes?: number;
70
- };
71
- shadows?: boolean;
72
- ao?: boolean;
73
- };
74
- }
75
-
76
- export interface RenderingTraitAnnotation extends TraitAnnotation {
77
- type: 'rendering';
78
- config: {
79
- quality?: 'low' | 'medium' | 'high' | 'ultra';
80
- platform?: 'mobile' | 'vr' | 'desktop';
81
- lod?: boolean;
82
- culling?: boolean;
83
- batching?: boolean;
84
- instancing?: boolean;
85
- maxTextureResolution?: number;
86
- compression?: 'none' | 'dxt' | 'astc' | 'basis';
87
- targetFPS?: number;
88
- };
89
- }
90
-
91
- export type AnyTraitAnnotation =
92
- | MaterialTraitAnnotation
93
- | LightingTraitAnnotation
94
- | RenderingTraitAnnotation;
95
-
96
- // ============================================================================
97
- // Enhanced OrbNode with Graphics Traits
98
- // ============================================================================
99
-
100
- export interface GraphicsConfiguration {
101
- material?: MaterialTraitAnnotation['config'];
102
- lighting?: LightingTraitAnnotation['config'];
103
- rendering?: RenderingTraitAnnotation['config'];
104
- }
105
-
106
- export interface EnhancedOrbNode extends OrbNode {
107
- graphics?: GraphicsConfiguration;
108
- traits?: AnyTraitAnnotation[];
109
- }
110
-
111
- // ============================================================================
112
- // HoloScriptPlus Parser
113
- // ============================================================================
114
-
115
- export class HoloScriptPlusParser {
116
- private baseParser: HoloScriptCodeParser;
117
-
118
- constructor() {
119
- this.baseParser = new HoloScriptCodeParser();
120
- }
121
-
122
- /**
123
- * Parse HoloScript+ code with trait annotations
124
- */
125
- parse(code: string): ASTNode[] {
126
- // First, parse with base parser
127
- const baseResult = this.baseParser.parse(code);
128
- const ast = (Array.isArray(baseResult) ? baseResult : [baseResult]) as ASTNode[];
129
-
130
- // Then enhance with trait annotations
131
- return this.enhanceWithTraits(ast, code);
132
- }
133
-
134
- /**
135
- * Enhance AST nodes with trait annotations
136
- */
137
- private enhanceWithTraits(ast: ASTNode[], code: string): ASTNode[] {
138
- return ast.map((node) => {
139
- if (node.type === 'orb') {
140
- return this.enhanceOrbNodeWithTraits(node, code);
141
- }
142
- return node;
143
- });
144
- }
145
-
146
- /**
147
- * Enhance OrbNode with trait annotations
148
- */
149
- private enhanceOrbNodeWithTraits(node: ASTNode, code: string): EnhancedOrbNode {
150
- const orbNode = node as OrbNode;
151
- const enhanced: EnhancedOrbNode = {
152
- ...orbNode,
153
- traits: [],
154
- graphics: {},
155
- };
156
-
157
- // Find trait annotations in the code near this node
158
- const traits = this.extractTraitAnnotations(code, node.line);
159
-
160
- enhanced.traits = traits;
161
-
162
- // Build graphics configuration from traits
163
- if (traits.length > 0) {
164
- enhanced.graphics = this.buildGraphicsConfig(traits);
165
- }
166
-
167
- return enhanced;
168
- }
169
-
170
- /**
171
- * Extract trait annotations from code
172
- */
173
- extractTraitAnnotations(code: string, _orbLine?: number): AnyTraitAnnotation[] {
174
- const traits: AnyTraitAnnotation[] = [];
175
- const traitRegex = /@(material|lighting|rendering)\s*\{([^}]*(?:\{[^}]*\}[^}]*)*)\}/g;
176
-
177
- let match;
178
- while ((match = traitRegex.exec(code)) !== null) {
179
- const type = match[1] as 'material' | 'lighting' | 'rendering';
180
- const configStr = match[2];
181
-
182
- try {
183
- const config = this.parseObjectLiteral(configStr);
184
-
185
- switch (type) {
186
- case 'material':
187
- traits.push({
188
- type: 'material',
189
- config: config as MaterialTraitAnnotation['config'],
190
- });
191
- break;
192
-
193
- case 'lighting':
194
- traits.push({
195
- type: 'lighting',
196
- config: config as LightingTraitAnnotation['config'],
197
- });
198
- break;
199
-
200
- case 'rendering':
201
- traits.push({
202
- type: 'rendering',
203
- config: config as RenderingTraitAnnotation['config'],
204
- });
205
- break;
206
- }
207
- } catch (e) {
208
- console.warn(`Failed to parse ${type} trait annotation:`, e);
209
- }
210
- }
211
-
212
- return traits;
213
- }
214
-
215
- /**
216
- * Parse object literal from string
217
- * Supports nested objects and arrays
218
- */
219
- parseObjectLiteral(str: string): Record<string, unknown> {
220
- const config: Record<string, unknown> = {};
221
-
222
- // Split by comma, but respect nested braces and brackets
223
- let depth = 0;
224
- let current = '';
225
- let pairs: string[] = [];
226
-
227
- for (let i = 0; i < str.length; i++) {
228
- const char = str[i];
229
-
230
- if (char === '{' || char === '[') {
231
- depth++;
232
- } else if (char === '}' || char === ']') {
233
- depth--;
234
- } else if (char === ',' && depth === 0) {
235
- pairs.push(current.trim());
236
- current = '';
237
- continue;
238
- }
239
-
240
- current += char;
241
- }
242
-
243
- if (current.trim()) {
244
- pairs.push(current.trim());
245
- }
246
-
247
- // Parse each key:value pair
248
- for (const pair of pairs) {
249
- const colonIndex = pair.indexOf(':');
250
- if (colonIndex === -1) continue;
251
-
252
- const key = pair.substring(0, colonIndex).trim();
253
- const value = pair.substring(colonIndex + 1).trim();
254
-
255
- config[key] = this.parseValue(value);
256
- }
257
-
258
- return config;
259
- }
260
-
261
- /**
262
- * Parse individual values
263
- */
264
- parseValue(str: string): unknown {
265
- str = str.trim();
266
-
267
- // Boolean
268
- if (str === 'true') return true;
269
- if (str === 'false') return false;
270
-
271
- // Number
272
- if (/^-?\d+(\.\d+)?$/.test(str)) return parseFloat(str);
273
-
274
- // String
275
- if ((str.startsWith('"') && str.endsWith('"')) || (str.startsWith("'") && str.endsWith("'"))) {
276
- return str.slice(1, -1);
277
- }
278
-
279
- // Color object: { r: 0.8, g: 0.2, b: 0.2 }
280
- if (str.startsWith('{') && str.endsWith('}')) {
281
- return this.parseObjectLiteral(str.slice(1, -1));
282
- }
283
-
284
- // Array: [1, 2, 3]
285
- if (str.startsWith('[') && str.endsWith(']')) {
286
- const items = str.slice(1, -1).split(',');
287
- return items.map((item) => this.parseValue(item));
288
- }
289
-
290
- return str;
291
- }
292
-
293
- /**
294
- * Build GraphicsConfiguration from trait annotations
295
- */
296
- buildGraphicsConfig(traits: AnyTraitAnnotation[]): GraphicsConfiguration {
297
- const config: GraphicsConfiguration = {};
298
-
299
- for (const trait of traits) {
300
- switch (trait.type) {
301
- case 'material':
302
- config.material = (trait as MaterialTraitAnnotation).config;
303
- break;
304
-
305
- case 'lighting':
306
- config.lighting = (trait as LightingTraitAnnotation).config;
307
- break;
308
-
309
- case 'rendering':
310
- config.rendering = (trait as RenderingTraitAnnotation).config;
311
- break;
312
- }
313
- }
314
-
315
- return config;
316
- }
317
-
318
- /**
319
- * Validate trait annotation configuration
320
- */
321
- validateTraitAnnotation(trait: AnyTraitAnnotation): { valid: boolean; errors: string[] } {
322
- const errors: string[] = [];
323
-
324
- switch (trait.type) {
325
- case 'material':
326
- errors.push(...this.validateMaterialTrait(trait as MaterialTraitAnnotation));
327
- break;
328
-
329
- case 'lighting':
330
- errors.push(...this.validateLightingTrait(trait as LightingTraitAnnotation));
331
- break;
332
-
333
- case 'rendering':
334
- errors.push(...this.validateRenderingTrait(trait as RenderingTraitAnnotation));
335
- break;
336
- }
337
-
338
- return {
339
- valid: errors.length === 0,
340
- errors,
341
- };
342
- }
343
-
344
- /**
345
- * Validate material trait configuration
346
- */
347
- private validateMaterialTrait(trait: MaterialTraitAnnotation): string[] {
348
- const errors: string[] = [];
349
- const { config } = trait;
350
-
351
- if (config.pbr) {
352
- if (config.pbr.metallic !== undefined && (config.pbr.metallic < 0 || config.pbr.metallic > 1)) {
353
- errors.push('material.pbr.metallic must be between 0 and 1');
354
- }
355
-
356
- if (config.pbr.roughness !== undefined && (config.pbr.roughness < 0 || config.pbr.roughness > 1)) {
357
- errors.push('material.pbr.roughness must be between 0 and 1');
358
- }
359
- }
360
-
361
- if (config.compression && !['none', 'dxt', 'astc', 'basis'].includes(config.compression)) {
362
- errors.push(`material.compression must be one of: none, dxt, astc, basis`);
363
- }
364
-
365
- return errors;
366
- }
367
-
368
- /**
369
- * Validate lighting trait configuration
370
- */
371
- private validateLightingTrait(trait: LightingTraitAnnotation): string[] {
372
- const errors: string[] = [];
373
- const { config } = trait;
374
-
375
- if (config.preset && !['studio', 'outdoor', 'interior', 'night', 'sunset'].includes(config.preset)) {
376
- errors.push('lighting.preset must be one of: studio, outdoor, interior, night, sunset');
377
- }
378
-
379
- if (config.lights) {
380
- config.lights.forEach((light, index) => {
381
- if (!['directional', 'point', 'spot', 'area', 'ambient'].includes(light.type)) {
382
- errors.push(`lighting.lights[${index}].type must be a valid light type`);
383
- }
384
-
385
- if (light.intensity !== undefined && light.intensity < 0) {
386
- errors.push(`lighting.lights[${index}].intensity must be >= 0`);
387
- }
388
- });
389
- }
390
-
391
- return errors;
392
- }
393
-
394
- /**
395
- * Validate rendering trait configuration
396
- */
397
- private validateRenderingTrait(trait: RenderingTraitAnnotation): string[] {
398
- const errors: string[] = [];
399
- const { config } = trait;
400
-
401
- if (config.quality && !['low', 'medium', 'high', 'ultra'].includes(config.quality)) {
402
- errors.push('rendering.quality must be one of: low, medium, high, ultra');
403
- }
404
-
405
- if (config.platform && !['mobile', 'vr', 'desktop'].includes(config.platform)) {
406
- errors.push('rendering.platform must be one of: mobile, vr, desktop');
407
- }
408
-
409
- if (config.compression && !['none', 'dxt', 'astc', 'basis'].includes(config.compression)) {
410
- errors.push('rendering.compression must be one of: none, dxt, astc, basis');
411
- }
412
-
413
- if (config.maxTextureResolution && config.maxTextureResolution < 128) {
414
- errors.push('rendering.maxTextureResolution must be >= 128');
415
- }
416
-
417
- if (config.targetFPS && (config.targetFPS < 24 || config.targetFPS > 240)) {
418
- errors.push('rendering.targetFPS must be between 24 and 240');
419
- }
420
-
421
- return errors;
422
- }
423
-
424
- /**
425
- * Get trait annotations as graphics traits
426
- */
427
- createGraphicsTraits(config: GraphicsConfiguration): any {
428
- // This will be called by the runtime to create actual trait instances
429
- return {
430
- material: config.material ? this.createMaterialTrait(config.material) : null,
431
- lighting: config.lighting ? this.createLightingTrait(config.lighting) : null,
432
- rendering: config.rendering ? this.createRenderingTrait(config.rendering) : null,
433
- };
434
- }
435
-
436
- /**
437
- * Create MaterialTrait from config
438
- */
439
- private createMaterialTrait(config: any): any {
440
- // Lazy import to avoid circular dependencies
441
- const { MaterialTrait } = require('./traits/MaterialTrait');
442
-
443
- const material = new MaterialTrait({
444
- type: config.type || 'pbr',
445
- pbr: config.pbr,
446
- });
447
-
448
- if (config.compression) {
449
- material.setCompression(config.compression);
450
- }
451
-
452
- if (config.instancing) {
453
- material.setInstanced(true);
454
- }
455
-
456
- if (config.streaming) {
457
- material.setTextureStreaming(true);
458
- }
459
-
460
- if (config.textures) {
461
- config.textures.forEach((tex: any) => {
462
- material.addTexture(tex);
463
- });
464
- }
465
-
466
- return material;
467
- }
468
-
469
- /**
470
- * Create LightingTrait from config
471
- */
472
- private createLightingTrait(config: any): any {
473
- const { LightingTrait, LIGHTING_PRESETS } = require('./traits/LightingTrait');
474
-
475
- let lighting: any;
476
-
477
- if (config.preset) {
478
- const preset = LIGHTING_PRESETS[config.preset];
479
- lighting = new LightingTrait(preset);
480
- } else {
481
- lighting = new LightingTrait();
482
- }
483
-
484
- if (config.globalIllumination) {
485
- lighting.setGlobalIllumination(config.globalIllumination);
486
- }
487
-
488
- if (config.lights) {
489
- config.lights.forEach((light: any) => {
490
- lighting.addLight(light);
491
- });
492
- }
493
-
494
- return lighting;
495
- }
496
-
497
- /**
498
- * Create RenderingTrait from config
499
- */
500
- private createRenderingTrait(config: any): any {
501
- const { RenderingTrait } = require('./traits/RenderingTrait');
502
-
503
- const rendering = new RenderingTrait();
504
-
505
- if (config.quality) {
506
- rendering.applyQualityPreset(config.quality);
507
- }
508
-
509
- if (config.platform) {
510
- switch (config.platform) {
511
- case 'mobile':
512
- rendering.optimizeForMobile();
513
- break;
514
- case 'vr':
515
- rendering.optimizeForVRAR(config.targetFPS || 90);
516
- break;
517
- case 'desktop':
518
- rendering.optimizeForDesktop();
519
- break;
520
- }
521
- }
522
-
523
- if (config.lod !== false) {
524
- rendering.setupLODLevels('automatic');
525
- }
526
-
527
- if (config.culling !== false) {
528
- rendering.setFrustumCulling(true);
529
- }
530
-
531
- if (config.compression) {
532
- rendering.setTextureCompression(config.compression);
533
- }
534
-
535
- if (config.maxTextureResolution) {
536
- rendering.setMaxTextureResolution(config.maxTextureResolution);
537
- }
538
-
539
- return rendering;
540
- }
541
- }
542
-
543
- export default HoloScriptPlusParser;