@holoscript/core 1.0.0-alpha.2 → 2.0.1

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 (74) hide show
  1. package/package.json +2 -2
  2. package/src/HoloScript2DParser.js +227 -0
  3. package/src/HoloScript2DParser.ts +5 -0
  4. package/src/HoloScriptCodeParser.js +1102 -0
  5. package/src/HoloScriptCodeParser.ts +145 -20
  6. package/src/HoloScriptDebugger.js +458 -0
  7. package/src/HoloScriptParser.js +338 -0
  8. package/src/HoloScriptPlusParser.js +371 -0
  9. package/src/HoloScriptPlusParser.ts +543 -0
  10. package/src/HoloScriptRuntime.js +1399 -0
  11. package/src/HoloScriptRuntime.test.js +351 -0
  12. package/src/HoloScriptRuntime.ts +17 -3
  13. package/src/HoloScriptTypeChecker.js +356 -0
  14. package/src/__tests__/GraphicsServices.test.js +357 -0
  15. package/src/__tests__/GraphicsServices.test.ts +427 -0
  16. package/src/__tests__/HoloScriptPlusParser.test.js +317 -0
  17. package/src/__tests__/HoloScriptPlusParser.test.ts +392 -0
  18. package/src/__tests__/integration.test.js +336 -0
  19. package/src/__tests__/performance.bench.js +218 -0
  20. package/src/__tests__/type-checker.test.js +60 -0
  21. package/src/__tests__/type-checker.test.ts +73 -0
  22. package/src/index.js +217 -0
  23. package/src/index.ts +158 -18
  24. package/src/interop/Interoperability.js +413 -0
  25. package/src/interop/Interoperability.ts +494 -0
  26. package/src/logger.js +42 -0
  27. package/src/parser/EnhancedParser.js +205 -0
  28. package/src/parser/EnhancedParser.ts +251 -0
  29. package/src/parser/HoloScriptPlusParser.js +928 -0
  30. package/src/parser/HoloScriptPlusParser.ts +1089 -0
  31. package/src/runtime/HoloScriptPlusRuntime.js +674 -0
  32. package/src/runtime/HoloScriptPlusRuntime.ts +861 -0
  33. package/src/runtime/PerformanceTelemetry.js +323 -0
  34. package/src/runtime/PerformanceTelemetry.ts +467 -0
  35. package/src/runtime/RuntimeOptimization.js +361 -0
  36. package/src/runtime/RuntimeOptimization.ts +416 -0
  37. package/src/services/HololandGraphicsPipelineService.js +506 -0
  38. package/src/services/HololandGraphicsPipelineService.ts +662 -0
  39. package/src/services/PlatformPerformanceOptimizer.js +356 -0
  40. package/src/services/PlatformPerformanceOptimizer.ts +503 -0
  41. package/src/state/ReactiveState.js +427 -0
  42. package/src/state/ReactiveState.ts +572 -0
  43. package/src/tools/DeveloperExperience.js +376 -0
  44. package/src/tools/DeveloperExperience.ts +438 -0
  45. package/src/traits/AIDriverTrait.js +322 -0
  46. package/src/traits/AIDriverTrait.test.js +329 -0
  47. package/src/traits/AIDriverTrait.test.ts +357 -0
  48. package/src/traits/AIDriverTrait.ts +474 -0
  49. package/src/traits/LightingTrait.js +313 -0
  50. package/src/traits/LightingTrait.test.js +410 -0
  51. package/src/traits/LightingTrait.test.ts +462 -0
  52. package/src/traits/LightingTrait.ts +505 -0
  53. package/src/traits/MaterialTrait.js +194 -0
  54. package/src/traits/MaterialTrait.test.js +286 -0
  55. package/src/traits/MaterialTrait.test.ts +329 -0
  56. package/src/traits/MaterialTrait.ts +324 -0
  57. package/src/traits/RenderingTrait.js +356 -0
  58. package/src/traits/RenderingTrait.test.js +363 -0
  59. package/src/traits/RenderingTrait.test.ts +427 -0
  60. package/src/traits/RenderingTrait.ts +555 -0
  61. package/src/traits/VRTraitSystem.js +740 -0
  62. package/src/traits/VRTraitSystem.ts +1040 -0
  63. package/src/traits/VoiceInputTrait.js +284 -0
  64. package/src/traits/VoiceInputTrait.test.js +226 -0
  65. package/src/traits/VoiceInputTrait.test.ts +252 -0
  66. package/src/traits/VoiceInputTrait.ts +401 -0
  67. package/src/types/AdvancedTypeSystem.js +226 -0
  68. package/src/types/AdvancedTypeSystem.ts +494 -0
  69. package/src/types/HoloScriptPlus.d.ts +853 -0
  70. package/src/types.js +6 -0
  71. package/src/types.ts +96 -1
  72. package/tsconfig.json +1 -1
  73. package/tsup.config.d.ts +2 -0
  74. package/tsup.config.js +18 -0
@@ -0,0 +1,505 @@
1
+ /**
2
+ * @holoscript/core Lighting Trait
3
+ *
4
+ * Enables dynamic lighting with support for multiple light types,
5
+ * shadows, and global illumination
6
+ */
7
+
8
+ export type LightType = 'directional' | 'point' | 'spot' | 'area' | 'probe';
9
+ export type ShadowType = 'none' | 'hard' | 'soft' | 'raytraced';
10
+
11
+ /**
12
+ * Color definition
13
+ */
14
+ export interface Color {
15
+ r: number;
16
+ g: number;
17
+ b: number;
18
+ a?: number;
19
+ }
20
+
21
+ /**
22
+ * Vector3 position or direction
23
+ */
24
+ export interface Vector3 {
25
+ x: number;
26
+ y: number;
27
+ z: number;
28
+ }
29
+
30
+ /**
31
+ * Shadow configuration
32
+ */
33
+ export interface ShadowConfig {
34
+ /** Shadow type */
35
+ type: ShadowType;
36
+
37
+ /** Shadow map resolution */
38
+ resolution?: number;
39
+
40
+ /** Shadow bias to prevent artifacts */
41
+ bias?: number;
42
+
43
+ /** Softness/blur radius */
44
+ softness?: number;
45
+
46
+ /** Max shadow distance */
47
+ maxDistance?: number;
48
+
49
+ /** Cascade levels for directional lights */
50
+ cascades?: number;
51
+ }
52
+
53
+ /**
54
+ * Light source definition
55
+ */
56
+ export interface LightSource {
57
+ /** Light type */
58
+ type: LightType;
59
+
60
+ /** Light name */
61
+ name?: string;
62
+
63
+ /** Position in world space */
64
+ position?: Vector3;
65
+
66
+ /** Direction (for directional/spot) */
67
+ direction?: Vector3;
68
+
69
+ /** Color */
70
+ color: Color;
71
+
72
+ /** Intensity/brightness 0-1+ */
73
+ intensity: number;
74
+
75
+ /** Attenuation range (point/spot) */
76
+ range?: number;
77
+
78
+ /** Spot angle in degrees */
79
+ spotAngle?: number;
80
+
81
+ /** Inner spot angle */
82
+ innerSpotAngle?: number;
83
+
84
+ /** Shadow configuration */
85
+ shadow?: ShadowConfig;
86
+
87
+ /** Light cookie/projection */
88
+ cookie?: string;
89
+
90
+ /** Enable volumetric fog interaction */
91
+ volumetric?: boolean;
92
+
93
+ /** Light priority for batching */
94
+ priority?: number;
95
+ }
96
+
97
+ /**
98
+ * Global illumination configuration
99
+ */
100
+ export interface GlobalIlluminationConfig {
101
+ /** Enable global illumination */
102
+ enabled: boolean;
103
+
104
+ /** Intensity multiplier */
105
+ intensity?: number;
106
+
107
+ /** Sky color for ambient light */
108
+ skyColor?: Color;
109
+
110
+ /** Sky intensity */
111
+ skyIntensity?: number;
112
+
113
+ /** Ground color for ambient light */
114
+ groundColor?: Color;
115
+
116
+ /** Ground intensity */
117
+ groundIntensity?: number;
118
+
119
+ /** Use light probes */
120
+ probes?: boolean;
121
+
122
+ /** Indirect diffuse intensity */
123
+ indirectDiffuse?: number;
124
+
125
+ /** Indirect specular intensity */
126
+ indirectSpecular?: number;
127
+
128
+ /** Ambient occlusion intensity */
129
+ aoIntensity?: number;
130
+
131
+ /** Use screen-space AO */
132
+ screenSpaceAO?: boolean;
133
+ }
134
+
135
+ /**
136
+ * LightingTrait - Manages dynamic lighting and illumination
137
+ */
138
+ export class LightingTrait {
139
+ private lights: Map<string, LightSource> = new Map();
140
+ private globalIllumination: GlobalIlluminationConfig;
141
+ private lightIdCounter: number = 0;
142
+
143
+ constructor(config?: GlobalIlluminationConfig) {
144
+ this.globalIllumination = {
145
+ enabled: true,
146
+ intensity: 1.0,
147
+ skyColor: { r: 0.5, g: 0.7, b: 1.0 },
148
+ skyIntensity: 1.0,
149
+ groundColor: { r: 0.4, g: 0.4, b: 0.4 },
150
+ groundIntensity: 0.5,
151
+ probes: true,
152
+ indirectDiffuse: 1.0,
153
+ indirectSpecular: 1.0,
154
+ aoIntensity: 1.0,
155
+ screenSpaceAO: true,
156
+ ...config,
157
+ };
158
+ }
159
+
160
+ /**
161
+ * Add a light to the scene
162
+ */
163
+ public addLight(light: LightSource): string {
164
+ const id = light.name || `light_${this.lightIdCounter++}`;
165
+ this.lights.set(id, light);
166
+ return id;
167
+ }
168
+
169
+ /**
170
+ * Get light by ID
171
+ */
172
+ public getLight(id: string): LightSource | undefined {
173
+ return this.lights.get(id);
174
+ }
175
+
176
+ /**
177
+ * Get all lights
178
+ */
179
+ public getLights(): LightSource[] {
180
+ return Array.from(this.lights.values());
181
+ }
182
+
183
+ /**
184
+ * Get lights by type
185
+ */
186
+ public getLightsByType(type: LightType): LightSource[] {
187
+ return Array.from(this.lights.values()).filter(l => l.type === type);
188
+ }
189
+
190
+ /**
191
+ * Update light properties
192
+ */
193
+ public updateLight(id: string, updates: Partial<LightSource>): boolean {
194
+ const light = this.lights.get(id);
195
+ if (!light) return false;
196
+ this.lights.set(id, { ...light, ...updates });
197
+ return true;
198
+ }
199
+
200
+ /**
201
+ * Remove light
202
+ */
203
+ public removeLight(id: string): boolean {
204
+ return this.lights.delete(id);
205
+ }
206
+
207
+ /**
208
+ * Clear all lights
209
+ */
210
+ public clearLights(): void {
211
+ this.lights.clear();
212
+ }
213
+
214
+ /**
215
+ * Get global illumination config
216
+ */
217
+ public getGlobalIllumination(): GlobalIlluminationConfig {
218
+ return { ...this.globalIllumination };
219
+ }
220
+
221
+ /**
222
+ * Update global illumination
223
+ */
224
+ public updateGlobalIllumination(
225
+ updates: Partial<GlobalIlluminationConfig>
226
+ ): void {
227
+ this.globalIllumination = {
228
+ ...this.globalIllumination,
229
+ ...updates,
230
+ };
231
+ }
232
+
233
+ /**
234
+ * Enable/disable GI
235
+ */
236
+ public setGIEnabled(enabled: boolean): void {
237
+ this.globalIllumination.enabled = enabled;
238
+ }
239
+
240
+ /**
241
+ * Set ambient light colors (skybox mode)
242
+ */
243
+ public setAmbientLight(
244
+ skyColor: Color,
245
+ groundColor: Color,
246
+ intensity: number = 1.0
247
+ ): void {
248
+ this.globalIllumination.skyColor = skyColor;
249
+ this.globalIllumination.groundColor = groundColor;
250
+ this.globalIllumination.skyIntensity = intensity;
251
+ this.globalIllumination.groundIntensity = intensity * 0.5;
252
+ }
253
+
254
+ /**
255
+ * Enable/disable screen-space ambient occlusion
256
+ */
257
+ public setScreenSpaceAO(enabled: boolean, intensity: number = 1.0): void {
258
+ this.globalIllumination.screenSpaceAO = enabled;
259
+ this.globalIllumination.aoIntensity = intensity;
260
+ }
261
+
262
+ /**
263
+ * Create directional light (sun)
264
+ */
265
+ public createDirectionalLight(
266
+ direction: Vector3,
267
+ color: Color,
268
+ intensity: number = 1.0,
269
+ castShadows: boolean = true
270
+ ): string {
271
+ const light: LightSource = {
272
+ type: 'directional',
273
+ name: `sun_${this.lightIdCounter}`,
274
+ direction,
275
+ color,
276
+ intensity,
277
+ shadow: castShadows
278
+ ? {
279
+ type: 'soft',
280
+ resolution: 2048,
281
+ cascades: 4,
282
+ softness: 1.0,
283
+ }
284
+ : undefined,
285
+ volumetric: true,
286
+ priority: 100,
287
+ };
288
+ return this.addLight(light);
289
+ }
290
+
291
+ /**
292
+ * Create point light
293
+ */
294
+ public createPointLight(
295
+ position: Vector3,
296
+ color: Color,
297
+ intensity: number,
298
+ range: number,
299
+ castShadows: boolean = false
300
+ ): string {
301
+ const light: LightSource = {
302
+ type: 'point',
303
+ name: `point_${this.lightIdCounter}`,
304
+ position,
305
+ color,
306
+ intensity,
307
+ range,
308
+ shadow: castShadows
309
+ ? {
310
+ type: 'soft',
311
+ resolution: 512,
312
+ softness: 0.5,
313
+ }
314
+ : undefined,
315
+ priority: 50,
316
+ };
317
+ return this.addLight(light);
318
+ }
319
+
320
+ /**
321
+ * Create spot light
322
+ */
323
+ public createSpotLight(
324
+ position: Vector3,
325
+ direction: Vector3,
326
+ color: Color,
327
+ intensity: number,
328
+ range: number,
329
+ spotAngle: number = 45,
330
+ castShadows: boolean = true
331
+ ): string {
332
+ const light: LightSource = {
333
+ type: 'spot',
334
+ name: `spot_${this.lightIdCounter}`,
335
+ position,
336
+ direction,
337
+ color,
338
+ intensity,
339
+ range,
340
+ spotAngle,
341
+ innerSpotAngle: spotAngle * 0.5,
342
+ shadow: castShadows
343
+ ? {
344
+ type: 'soft',
345
+ resolution: 1024,
346
+ softness: 0.8,
347
+ }
348
+ : undefined,
349
+ priority: 75,
350
+ };
351
+ return this.addLight(light);
352
+ }
353
+
354
+ /**
355
+ * Create area light for soft lighting
356
+ */
357
+ public createAreaLight(
358
+ position: Vector3,
359
+ color: Color,
360
+ intensity: number,
361
+ width: number,
362
+ height: number
363
+ ): string {
364
+ const light: LightSource = {
365
+ type: 'area',
366
+ name: `area_${this.lightIdCounter}`,
367
+ position,
368
+ color,
369
+ intensity,
370
+ range: Math.max(width, height) * 2,
371
+ priority: 25,
372
+ };
373
+ return this.addLight(light);
374
+ }
375
+
376
+ /**
377
+ * Get shadow-casting lights
378
+ */
379
+ public getShadowCastingLights(): LightSource[] {
380
+ return Array.from(this.lights.values()).filter(l => l.shadow && l.shadow.type !== 'none');
381
+ }
382
+
383
+ /**
384
+ * Get light count by type
385
+ */
386
+ public getLightCount(): { [key in LightType]: number } {
387
+ const counts = {
388
+ directional: 0,
389
+ point: 0,
390
+ spot: 0,
391
+ area: 0,
392
+ probe: 0,
393
+ };
394
+ for (const light of this.lights.values()) {
395
+ counts[light.type]++;
396
+ }
397
+ return counts;
398
+ }
399
+
400
+ /**
401
+ * Estimate light impact for performance optimization
402
+ */
403
+ public getPerformanceImpact(): {
404
+ totalLights: number;
405
+ shadowCasters: number;
406
+ estimatedGPUCost: 'low' | 'medium' | 'high';
407
+ } {
408
+ const totalLights = this.lights.size;
409
+ const shadowCasters = this.getShadowCastingLights().length;
410
+
411
+ let estimatedGPUCost: 'low' | 'medium' | 'high' = 'low';
412
+ if (totalLights > 16 || shadowCasters > 4) {
413
+ estimatedGPUCost = 'high';
414
+ } else if (totalLights > 8 || shadowCasters > 2) {
415
+ estimatedGPUCost = 'medium';
416
+ }
417
+
418
+ return {
419
+ totalLights,
420
+ shadowCasters,
421
+ estimatedGPUCost,
422
+ };
423
+ }
424
+
425
+ /**
426
+ * Get scene complexity info
427
+ */
428
+ public getSceneInfo(): string {
429
+ const counts = this.getLightCount();
430
+ const impact = this.getPerformanceImpact();
431
+ return `Lighting: ${counts.directional} dir, ${counts.point} point, ${counts.spot} spot | ` +
432
+ `Shadows: ${impact.shadowCasters} | GPU: ${impact.estimatedGPUCost}`;
433
+ }
434
+
435
+ /**
436
+ * Dispose and cleanup
437
+ */
438
+ public dispose(): void {
439
+ this.lights.clear();
440
+ }
441
+ }
442
+
443
+ /**
444
+ * HoloScript+ @lighting trait factory
445
+ */
446
+ export function createLightingTrait(config?: GlobalIlluminationConfig): LightingTrait {
447
+ return new LightingTrait(config);
448
+ }
449
+
450
+ /**
451
+ * Preset lighting configurations
452
+ */
453
+ export const LIGHTING_PRESETS = {
454
+ /** Neutral studio lighting */
455
+ studio: (): GlobalIlluminationConfig => ({
456
+ enabled: true,
457
+ intensity: 1.0,
458
+ skyColor: { r: 0.5, g: 0.5, b: 0.5 },
459
+ skyIntensity: 0.5,
460
+ groundColor: { r: 0.3, g: 0.3, b: 0.3 },
461
+ groundIntensity: 0.3,
462
+ }),
463
+
464
+ /** Bright outdoor lighting */
465
+ outdoor: (): GlobalIlluminationConfig => ({
466
+ enabled: true,
467
+ intensity: 1.2,
468
+ skyColor: { r: 0.7, g: 0.85, b: 1.0 },
469
+ skyIntensity: 1.0,
470
+ groundColor: { r: 0.4, g: 0.4, b: 0.35 },
471
+ groundIntensity: 0.6,
472
+ indirectDiffuse: 1.2,
473
+ }),
474
+
475
+ /** Dim interior lighting */
476
+ interior: (): GlobalIlluminationConfig => ({
477
+ enabled: true,
478
+ intensity: 0.6,
479
+ skyColor: { r: 0.3, g: 0.3, b: 0.35 },
480
+ skyIntensity: 0.4,
481
+ groundColor: { r: 0.2, g: 0.2, b: 0.2 },
482
+ groundIntensity: 0.2,
483
+ }),
484
+
485
+ /** Night scene */
486
+ night: (): GlobalIlluminationConfig => ({
487
+ enabled: true,
488
+ intensity: 0.3,
489
+ skyColor: { r: 0.01, g: 0.01, b: 0.02 },
490
+ skyIntensity: 0.1,
491
+ groundColor: { r: 0.02, g: 0.02, b: 0.02 },
492
+ groundIntensity: 0.05,
493
+ screenSpaceAO: false,
494
+ }),
495
+
496
+ /** Sunset/golden hour */
497
+ sunset: (): GlobalIlluminationConfig => ({
498
+ enabled: true,
499
+ intensity: 1.1,
500
+ skyColor: { r: 1.0, g: 0.7, b: 0.3 },
501
+ skyIntensity: 1.0,
502
+ groundColor: { r: 0.6, g: 0.4, b: 0.2 },
503
+ groundIntensity: 0.8,
504
+ }),
505
+ };
@@ -0,0 +1,194 @@
1
+ /**
2
+ * @holoscript/core Material Trait
3
+ *
4
+ * Enables advanced material and shader properties for photorealistic rendering
5
+ * Supports PBR (Physically Based Rendering) workflows
6
+ */
7
+ /**
8
+ * MaterialTrait - Enables photorealistic material rendering
9
+ */
10
+ export class MaterialTrait {
11
+ constructor(config) {
12
+ this.textureCache = new Map();
13
+ this.material = {
14
+ type: 'pbr',
15
+ ...config,
16
+ };
17
+ }
18
+ /**
19
+ * Get material properties
20
+ */
21
+ getMaterial() {
22
+ return { ...this.material };
23
+ }
24
+ /**
25
+ * Update material property
26
+ */
27
+ setProperty(key, value) {
28
+ this.material[key] = value;
29
+ }
30
+ /**
31
+ * Get PBR properties
32
+ */
33
+ getPBRProperties() {
34
+ return this.material.pbr;
35
+ }
36
+ /**
37
+ * Update PBR material
38
+ */
39
+ updatePBR(pbr) {
40
+ if (!this.material.pbr) {
41
+ this.material.pbr = {
42
+ baseColor: { r: 1, g: 1, b: 1 },
43
+ metallic: 0,
44
+ roughness: 0.5,
45
+ };
46
+ }
47
+ this.material.pbr = { ...this.material.pbr, ...pbr };
48
+ }
49
+ /**
50
+ * Add texture map
51
+ */
52
+ addTexture(texture) {
53
+ if (!this.material.textures) {
54
+ this.material.textures = [];
55
+ }
56
+ this.material.textures.push(texture);
57
+ }
58
+ /**
59
+ * Get all textures
60
+ */
61
+ getTextures() {
62
+ return [...(this.material.textures || [])];
63
+ }
64
+ /**
65
+ * Clear texture cache (for memory optimization)
66
+ */
67
+ clearTextureCache() {
68
+ this.textureCache.clear();
69
+ }
70
+ /**
71
+ * Get shader code if custom
72
+ */
73
+ getCustomShader() {
74
+ return this.material.customShader;
75
+ }
76
+ /**
77
+ * Set custom shader
78
+ */
79
+ setCustomShader(shader) {
80
+ this.material.customShader = shader;
81
+ }
82
+ /**
83
+ * Get optimization hints
84
+ */
85
+ getOptimization() {
86
+ return this.material.optimization;
87
+ }
88
+ /**
89
+ * Enable/disable texture streaming
90
+ */
91
+ setTextureStreaming(enabled) {
92
+ if (!this.material.optimization) {
93
+ this.material.optimization = {};
94
+ }
95
+ this.material.optimization.streamTextures = enabled;
96
+ }
97
+ /**
98
+ * Set texture compression
99
+ */
100
+ setCompression(compression) {
101
+ if (!this.material.optimization) {
102
+ this.material.optimization = {};
103
+ }
104
+ this.material.optimization.compression = compression;
105
+ }
106
+ /**
107
+ * Enable material instancing for performance
108
+ */
109
+ setInstanced(instanced) {
110
+ if (!this.material.optimization) {
111
+ this.material.optimization = {};
112
+ }
113
+ this.material.optimization.instanced = instanced;
114
+ }
115
+ /**
116
+ * Dispose and cleanup
117
+ */
118
+ dispose() {
119
+ this.textureCache.clear();
120
+ }
121
+ }
122
+ /**
123
+ * HoloScript+ @material trait factory
124
+ */
125
+ export function createMaterialTrait(config) {
126
+ return new MaterialTrait(config);
127
+ }
128
+ /**
129
+ * Preset materials for common use cases
130
+ */
131
+ export const MATERIAL_PRESETS = {
132
+ /** Shiny metal */
133
+ chrome: () => ({
134
+ type: 'pbr',
135
+ pbr: {
136
+ baseColor: { r: 0.77, g: 0.77, b: 0.77 },
137
+ metallic: 1.0,
138
+ roughness: 0.1,
139
+ },
140
+ }),
141
+ /** Rough plastic */
142
+ plastic: () => ({
143
+ type: 'pbr',
144
+ pbr: {
145
+ baseColor: { r: 1, g: 1, b: 1 },
146
+ metallic: 0,
147
+ roughness: 0.8,
148
+ },
149
+ }),
150
+ /** Wood texture */
151
+ wood: () => ({
152
+ type: 'pbr',
153
+ pbr: {
154
+ baseColor: { r: 0.6, g: 0.4, b: 0.2 },
155
+ metallic: 0,
156
+ roughness: 0.4,
157
+ },
158
+ }),
159
+ /** Glass */
160
+ glass: () => ({
161
+ type: 'transparent',
162
+ blendMode: 'blend',
163
+ pbr: {
164
+ baseColor: { r: 1, g: 1, b: 1, a: 0.3 },
165
+ metallic: 0,
166
+ roughness: 0.0,
167
+ ior: 1.5,
168
+ transmission: 0.9,
169
+ },
170
+ }),
171
+ /** Emissive (glowing) */
172
+ emissive: () => ({
173
+ type: 'pbr',
174
+ pbr: {
175
+ baseColor: { r: 0, g: 1, b: 0 },
176
+ metallic: 0,
177
+ roughness: 1.0,
178
+ emission: {
179
+ color: { r: 0, g: 1, b: 0 },
180
+ intensity: 2.0,
181
+ },
182
+ },
183
+ }),
184
+ /** Skin material */
185
+ skin: () => ({
186
+ type: 'pbr',
187
+ pbr: {
188
+ baseColor: { r: 1, g: 0.8, b: 0.7 },
189
+ metallic: 0,
190
+ roughness: 0.5,
191
+ ambientOcclusion: 0.8,
192
+ },
193
+ }),
194
+ };