@holoscript/core 1.0.0-alpha.1 → 2.0.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.
- package/package.json +10 -9
- package/src/HoloScript2DParser.js +227 -0
- package/src/HoloScript2DParser.ts +5 -0
- package/src/HoloScriptCodeParser.js +1102 -0
- package/src/HoloScriptCodeParser.ts +145 -20
- package/src/HoloScriptDebugger.js +458 -0
- package/src/HoloScriptParser.js +338 -0
- package/src/HoloScriptPlusParser.js +371 -0
- package/src/HoloScriptPlusParser.ts +543 -0
- package/src/HoloScriptRuntime.js +1399 -0
- package/src/HoloScriptRuntime.test.js +351 -0
- package/src/HoloScriptRuntime.ts +257 -3
- package/src/HoloScriptTypeChecker.js +356 -0
- package/src/__tests__/GraphicsServices.test.js +357 -0
- package/src/__tests__/GraphicsServices.test.ts +427 -0
- package/src/__tests__/HoloScriptPlusParser.test.js +317 -0
- package/src/__tests__/HoloScriptPlusParser.test.ts +392 -0
- package/src/__tests__/integration.test.js +336 -0
- package/src/__tests__/performance.bench.js +218 -0
- package/src/__tests__/type-checker.test.js +60 -0
- package/src/__tests__/type-checker.test.ts +73 -0
- package/src/index.js +217 -0
- package/src/index.ts +158 -18
- package/src/interop/Interoperability.js +413 -0
- package/src/interop/Interoperability.ts +494 -0
- package/src/logger.js +42 -0
- package/src/parser/EnhancedParser.js +205 -0
- package/src/parser/EnhancedParser.ts +251 -0
- package/src/parser/HoloScriptPlusParser.js +928 -0
- package/src/parser/HoloScriptPlusParser.ts +1089 -0
- package/src/runtime/HoloScriptPlusRuntime.js +674 -0
- package/src/runtime/HoloScriptPlusRuntime.ts +861 -0
- package/src/runtime/PerformanceTelemetry.js +323 -0
- package/src/runtime/PerformanceTelemetry.ts +467 -0
- package/src/runtime/RuntimeOptimization.js +361 -0
- package/src/runtime/RuntimeOptimization.ts +416 -0
- package/src/services/HololandGraphicsPipelineService.js +506 -0
- package/src/services/HololandGraphicsPipelineService.ts +662 -0
- package/src/services/PlatformPerformanceOptimizer.js +356 -0
- package/src/services/PlatformPerformanceOptimizer.ts +503 -0
- package/src/state/ReactiveState.js +427 -0
- package/src/state/ReactiveState.ts +572 -0
- package/src/tools/DeveloperExperience.js +376 -0
- package/src/tools/DeveloperExperience.ts +438 -0
- package/src/traits/AIDriverTrait.js +322 -0
- package/src/traits/AIDriverTrait.test.js +329 -0
- package/src/traits/AIDriverTrait.test.ts +357 -0
- package/src/traits/AIDriverTrait.ts +474 -0
- package/src/traits/LightingTrait.js +313 -0
- package/src/traits/LightingTrait.test.js +410 -0
- package/src/traits/LightingTrait.test.ts +462 -0
- package/src/traits/LightingTrait.ts +505 -0
- package/src/traits/MaterialTrait.js +194 -0
- package/src/traits/MaterialTrait.test.js +286 -0
- package/src/traits/MaterialTrait.test.ts +329 -0
- package/src/traits/MaterialTrait.ts +324 -0
- package/src/traits/RenderingTrait.js +356 -0
- package/src/traits/RenderingTrait.test.js +363 -0
- package/src/traits/RenderingTrait.test.ts +427 -0
- package/src/traits/RenderingTrait.ts +555 -0
- package/src/traits/VRTraitSystem.js +740 -0
- package/src/traits/VRTraitSystem.ts +1040 -0
- package/src/traits/VoiceInputTrait.js +284 -0
- package/src/traits/VoiceInputTrait.test.js +226 -0
- package/src/traits/VoiceInputTrait.test.ts +252 -0
- package/src/traits/VoiceInputTrait.ts +401 -0
- package/src/types/AdvancedTypeSystem.js +226 -0
- package/src/types/AdvancedTypeSystem.ts +494 -0
- package/src/types/HoloScriptPlus.d.ts +853 -0
- package/src/types.js +6 -0
- package/src/types.ts +96 -1
- package/tsconfig.json +1 -1
- package/tsup.config.d.ts +2 -0
- package/tsup.config.js +18 -0
- package/LICENSE +0 -21
- package/dist/chunk-3X2EGU7Z.cjs +0 -52
- package/dist/chunk-3X2EGU7Z.cjs.map +0 -1
- package/dist/chunk-723TPVHD.js +0 -1074
- package/dist/chunk-723TPVHD.js.map +0 -1
- package/dist/chunk-EOKNAVDO.cjs +0 -424
- package/dist/chunk-EOKNAVDO.cjs.map +0 -1
- package/dist/chunk-HQZ3HUMY.js +0 -1087
- package/dist/chunk-HQZ3HUMY.js.map +0 -1
- package/dist/chunk-KWYIVRIH.js +0 -344
- package/dist/chunk-KWYIVRIH.js.map +0 -1
- package/dist/chunk-LKH4ZAN6.js +0 -421
- package/dist/chunk-LKH4ZAN6.js.map +0 -1
- package/dist/chunk-SATNCODL.js +0 -45
- package/dist/chunk-SATNCODL.js.map +0 -1
- package/dist/chunk-VMZN4EVR.cjs +0 -347
- package/dist/chunk-VMZN4EVR.cjs.map +0 -1
- package/dist/chunk-VV3UUUYP.cjs +0 -1089
- package/dist/chunk-VV3UUUYP.cjs.map +0 -1
- package/dist/chunk-XRYTSQHZ.cjs +0 -1076
- package/dist/chunk-XRYTSQHZ.cjs.map +0 -1
- package/dist/debugger.cjs +0 -19
- package/dist/debugger.cjs.map +0 -1
- package/dist/debugger.d.cts +0 -171
- package/dist/debugger.d.ts +0 -171
- package/dist/debugger.js +0 -6
- package/dist/debugger.js.map +0 -1
- package/dist/index.cjs +0 -755
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -169
- package/dist/index.d.ts +0 -169
- package/dist/index.js +0 -699
- package/dist/index.js.map +0 -1
- package/dist/parser.cjs +0 -13
- package/dist/parser.cjs.map +0 -1
- package/dist/parser.d.cts +0 -154
- package/dist/parser.d.ts +0 -154
- package/dist/parser.js +0 -4
- package/dist/parser.js.map +0 -1
- package/dist/runtime.cjs +0 -13
- package/dist/runtime.cjs.map +0 -1
- package/dist/runtime.d.cts +0 -147
- package/dist/runtime.d.ts +0 -147
- package/dist/runtime.js +0 -4
- package/dist/runtime.js.map +0 -1
- package/dist/type-checker.cjs +0 -16
- package/dist/type-checker.cjs.map +0 -1
- package/dist/type-checker.d.cts +0 -105
- package/dist/type-checker.d.ts +0 -105
- package/dist/type-checker.js +0 -3
- package/dist/type-checker.js.map +0 -1
- package/dist/types-WQSk1Qs2.d.cts +0 -238
- package/dist/types-WQSk1Qs2.d.ts +0 -238
|
@@ -0,0 +1,313 @@
|
|
|
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
|
+
* LightingTrait - Manages dynamic lighting and illumination
|
|
9
|
+
*/
|
|
10
|
+
export class LightingTrait {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.lights = new Map();
|
|
13
|
+
this.lightIdCounter = 0;
|
|
14
|
+
this.globalIllumination = {
|
|
15
|
+
enabled: true,
|
|
16
|
+
intensity: 1.0,
|
|
17
|
+
skyColor: { r: 0.5, g: 0.7, b: 1.0 },
|
|
18
|
+
skyIntensity: 1.0,
|
|
19
|
+
groundColor: { r: 0.4, g: 0.4, b: 0.4 },
|
|
20
|
+
groundIntensity: 0.5,
|
|
21
|
+
probes: true,
|
|
22
|
+
indirectDiffuse: 1.0,
|
|
23
|
+
indirectSpecular: 1.0,
|
|
24
|
+
aoIntensity: 1.0,
|
|
25
|
+
screenSpaceAO: true,
|
|
26
|
+
...config,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Add a light to the scene
|
|
31
|
+
*/
|
|
32
|
+
addLight(light) {
|
|
33
|
+
const id = light.name || `light_${this.lightIdCounter++}`;
|
|
34
|
+
this.lights.set(id, light);
|
|
35
|
+
return id;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get light by ID
|
|
39
|
+
*/
|
|
40
|
+
getLight(id) {
|
|
41
|
+
return this.lights.get(id);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all lights
|
|
45
|
+
*/
|
|
46
|
+
getLights() {
|
|
47
|
+
return Array.from(this.lights.values());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get lights by type
|
|
51
|
+
*/
|
|
52
|
+
getLightsByType(type) {
|
|
53
|
+
return Array.from(this.lights.values()).filter(l => l.type === type);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Update light properties
|
|
57
|
+
*/
|
|
58
|
+
updateLight(id, updates) {
|
|
59
|
+
const light = this.lights.get(id);
|
|
60
|
+
if (!light)
|
|
61
|
+
return false;
|
|
62
|
+
this.lights.set(id, { ...light, ...updates });
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Remove light
|
|
67
|
+
*/
|
|
68
|
+
removeLight(id) {
|
|
69
|
+
return this.lights.delete(id);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Clear all lights
|
|
73
|
+
*/
|
|
74
|
+
clearLights() {
|
|
75
|
+
this.lights.clear();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get global illumination config
|
|
79
|
+
*/
|
|
80
|
+
getGlobalIllumination() {
|
|
81
|
+
return { ...this.globalIllumination };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Update global illumination
|
|
85
|
+
*/
|
|
86
|
+
updateGlobalIllumination(updates) {
|
|
87
|
+
this.globalIllumination = {
|
|
88
|
+
...this.globalIllumination,
|
|
89
|
+
...updates,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Enable/disable GI
|
|
94
|
+
*/
|
|
95
|
+
setGIEnabled(enabled) {
|
|
96
|
+
this.globalIllumination.enabled = enabled;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Set ambient light colors (skybox mode)
|
|
100
|
+
*/
|
|
101
|
+
setAmbientLight(skyColor, groundColor, intensity = 1.0) {
|
|
102
|
+
this.globalIllumination.skyColor = skyColor;
|
|
103
|
+
this.globalIllumination.groundColor = groundColor;
|
|
104
|
+
this.globalIllumination.skyIntensity = intensity;
|
|
105
|
+
this.globalIllumination.groundIntensity = intensity * 0.5;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Enable/disable screen-space ambient occlusion
|
|
109
|
+
*/
|
|
110
|
+
setScreenSpaceAO(enabled, intensity = 1.0) {
|
|
111
|
+
this.globalIllumination.screenSpaceAO = enabled;
|
|
112
|
+
this.globalIllumination.aoIntensity = intensity;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create directional light (sun)
|
|
116
|
+
*/
|
|
117
|
+
createDirectionalLight(direction, color, intensity = 1.0, castShadows = true) {
|
|
118
|
+
const light = {
|
|
119
|
+
type: 'directional',
|
|
120
|
+
name: `sun_${this.lightIdCounter}`,
|
|
121
|
+
direction,
|
|
122
|
+
color,
|
|
123
|
+
intensity,
|
|
124
|
+
shadow: castShadows
|
|
125
|
+
? {
|
|
126
|
+
type: 'soft',
|
|
127
|
+
resolution: 2048,
|
|
128
|
+
cascades: 4,
|
|
129
|
+
softness: 1.0,
|
|
130
|
+
}
|
|
131
|
+
: undefined,
|
|
132
|
+
volumetric: true,
|
|
133
|
+
priority: 100,
|
|
134
|
+
};
|
|
135
|
+
return this.addLight(light);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Create point light
|
|
139
|
+
*/
|
|
140
|
+
createPointLight(position, color, intensity, range, castShadows = false) {
|
|
141
|
+
const light = {
|
|
142
|
+
type: 'point',
|
|
143
|
+
name: `point_${this.lightIdCounter}`,
|
|
144
|
+
position,
|
|
145
|
+
color,
|
|
146
|
+
intensity,
|
|
147
|
+
range,
|
|
148
|
+
shadow: castShadows
|
|
149
|
+
? {
|
|
150
|
+
type: 'soft',
|
|
151
|
+
resolution: 512,
|
|
152
|
+
softness: 0.5,
|
|
153
|
+
}
|
|
154
|
+
: undefined,
|
|
155
|
+
priority: 50,
|
|
156
|
+
};
|
|
157
|
+
return this.addLight(light);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Create spot light
|
|
161
|
+
*/
|
|
162
|
+
createSpotLight(position, direction, color, intensity, range, spotAngle = 45, castShadows = true) {
|
|
163
|
+
const light = {
|
|
164
|
+
type: 'spot',
|
|
165
|
+
name: `spot_${this.lightIdCounter}`,
|
|
166
|
+
position,
|
|
167
|
+
direction,
|
|
168
|
+
color,
|
|
169
|
+
intensity,
|
|
170
|
+
range,
|
|
171
|
+
spotAngle,
|
|
172
|
+
innerSpotAngle: spotAngle * 0.5,
|
|
173
|
+
shadow: castShadows
|
|
174
|
+
? {
|
|
175
|
+
type: 'soft',
|
|
176
|
+
resolution: 1024,
|
|
177
|
+
softness: 0.8,
|
|
178
|
+
}
|
|
179
|
+
: undefined,
|
|
180
|
+
priority: 75,
|
|
181
|
+
};
|
|
182
|
+
return this.addLight(light);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create area light for soft lighting
|
|
186
|
+
*/
|
|
187
|
+
createAreaLight(position, color, intensity, width, height) {
|
|
188
|
+
const light = {
|
|
189
|
+
type: 'area',
|
|
190
|
+
name: `area_${this.lightIdCounter}`,
|
|
191
|
+
position,
|
|
192
|
+
color,
|
|
193
|
+
intensity,
|
|
194
|
+
range: Math.max(width, height) * 2,
|
|
195
|
+
priority: 25,
|
|
196
|
+
};
|
|
197
|
+
return this.addLight(light);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get shadow-casting lights
|
|
201
|
+
*/
|
|
202
|
+
getShadowCastingLights() {
|
|
203
|
+
return Array.from(this.lights.values()).filter(l => l.shadow && l.shadow.type !== 'none');
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get light count by type
|
|
207
|
+
*/
|
|
208
|
+
getLightCount() {
|
|
209
|
+
const counts = {
|
|
210
|
+
directional: 0,
|
|
211
|
+
point: 0,
|
|
212
|
+
spot: 0,
|
|
213
|
+
area: 0,
|
|
214
|
+
probe: 0,
|
|
215
|
+
};
|
|
216
|
+
for (const light of this.lights.values()) {
|
|
217
|
+
counts[light.type]++;
|
|
218
|
+
}
|
|
219
|
+
return counts;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Estimate light impact for performance optimization
|
|
223
|
+
*/
|
|
224
|
+
getPerformanceImpact() {
|
|
225
|
+
const totalLights = this.lights.size;
|
|
226
|
+
const shadowCasters = this.getShadowCastingLights().length;
|
|
227
|
+
let estimatedGPUCost = 'low';
|
|
228
|
+
if (totalLights > 16 || shadowCasters > 4) {
|
|
229
|
+
estimatedGPUCost = 'high';
|
|
230
|
+
}
|
|
231
|
+
else if (totalLights > 8 || shadowCasters > 2) {
|
|
232
|
+
estimatedGPUCost = 'medium';
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
totalLights,
|
|
236
|
+
shadowCasters,
|
|
237
|
+
estimatedGPUCost,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Get scene complexity info
|
|
242
|
+
*/
|
|
243
|
+
getSceneInfo() {
|
|
244
|
+
const counts = this.getLightCount();
|
|
245
|
+
const impact = this.getPerformanceImpact();
|
|
246
|
+
return `Lighting: ${counts.directional} dir, ${counts.point} point, ${counts.spot} spot | ` +
|
|
247
|
+
`Shadows: ${impact.shadowCasters} | GPU: ${impact.estimatedGPUCost}`;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Dispose and cleanup
|
|
251
|
+
*/
|
|
252
|
+
dispose() {
|
|
253
|
+
this.lights.clear();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* HoloScript+ @lighting trait factory
|
|
258
|
+
*/
|
|
259
|
+
export function createLightingTrait(config) {
|
|
260
|
+
return new LightingTrait(config);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Preset lighting configurations
|
|
264
|
+
*/
|
|
265
|
+
export const LIGHTING_PRESETS = {
|
|
266
|
+
/** Neutral studio lighting */
|
|
267
|
+
studio: () => ({
|
|
268
|
+
enabled: true,
|
|
269
|
+
intensity: 1.0,
|
|
270
|
+
skyColor: { r: 0.5, g: 0.5, b: 0.5 },
|
|
271
|
+
skyIntensity: 0.5,
|
|
272
|
+
groundColor: { r: 0.3, g: 0.3, b: 0.3 },
|
|
273
|
+
groundIntensity: 0.3,
|
|
274
|
+
}),
|
|
275
|
+
/** Bright outdoor lighting */
|
|
276
|
+
outdoor: () => ({
|
|
277
|
+
enabled: true,
|
|
278
|
+
intensity: 1.2,
|
|
279
|
+
skyColor: { r: 0.7, g: 0.85, b: 1.0 },
|
|
280
|
+
skyIntensity: 1.0,
|
|
281
|
+
groundColor: { r: 0.4, g: 0.4, b: 0.35 },
|
|
282
|
+
groundIntensity: 0.6,
|
|
283
|
+
indirectDiffuse: 1.2,
|
|
284
|
+
}),
|
|
285
|
+
/** Dim interior lighting */
|
|
286
|
+
interior: () => ({
|
|
287
|
+
enabled: true,
|
|
288
|
+
intensity: 0.6,
|
|
289
|
+
skyColor: { r: 0.3, g: 0.3, b: 0.35 },
|
|
290
|
+
skyIntensity: 0.4,
|
|
291
|
+
groundColor: { r: 0.2, g: 0.2, b: 0.2 },
|
|
292
|
+
groundIntensity: 0.2,
|
|
293
|
+
}),
|
|
294
|
+
/** Night scene */
|
|
295
|
+
night: () => ({
|
|
296
|
+
enabled: true,
|
|
297
|
+
intensity: 0.3,
|
|
298
|
+
skyColor: { r: 0.01, g: 0.01, b: 0.02 },
|
|
299
|
+
skyIntensity: 0.1,
|
|
300
|
+
groundColor: { r: 0.02, g: 0.02, b: 0.02 },
|
|
301
|
+
groundIntensity: 0.05,
|
|
302
|
+
screenSpaceAO: false,
|
|
303
|
+
}),
|
|
304
|
+
/** Sunset/golden hour */
|
|
305
|
+
sunset: () => ({
|
|
306
|
+
enabled: true,
|
|
307
|
+
intensity: 1.1,
|
|
308
|
+
skyColor: { r: 1.0, g: 0.7, b: 0.3 },
|
|
309
|
+
skyIntensity: 1.0,
|
|
310
|
+
groundColor: { r: 0.6, g: 0.4, b: 0.2 },
|
|
311
|
+
groundIntensity: 0.8,
|
|
312
|
+
}),
|
|
313
|
+
};
|