@holoscript/core 2.0.1 → 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,505 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,194 +0,0 @@
|
|
|
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
|
-
};
|