@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
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,2482 @@
|
|
|
1
|
+
import { U as UI2DNode, P as Position2D, V as VoiceCommand$1, A as ASTNode, G as GestureData, S as SpatialPosition } from './types-D6g4ACjP.cjs';
|
|
2
|
+
export { o as CollisionEvent, k as Color, C as ConnectionNode, D as Duration, B as ExecutionResult, E as ExportNode, u as ForEachLoopNode, F as ForLoopNode, f as GateNode, h as GenericASTNode, c as GestureType, p as GrabbableTrait, d as HandType, b as HologramProperties, H as HologramShape, s as HoverableTrait, v as ImportLoader, I as ImportNode, M as MethodNode, O as OrbNode, e as ParameterNode, J as ParticleSystem, r as PointableTrait, R as RotatableTrait, z as RuntimeContext, L as RuntimeSecurityLimits, t as ScalableTrait, K as SecurityConfig, a as Size2D, g as StreamNode, n as ThrowVelocity, q as ThrowableTrait, l as Transform, T as TransformationNode, x as UIElementType, y as UIStyle, m as VRHand, w as VariableDeclarationNode, j as Vector2, i as Vector3, W as WhileLoopNode } from './types-D6g4ACjP.cjs';
|
|
3
|
+
import { HoloScriptRuntime } from './runtime.cjs';
|
|
4
|
+
export { HoloScriptCodeParser, ParseError, ParseResult } from './parser.cjs';
|
|
5
|
+
export { HoloScriptTypeChecker, TypeCheckResult, TypeDiagnostic, TypeInfo, createTypeChecker } from './type-checker.cjs';
|
|
6
|
+
export { Breakpoint, DebugEvent, DebugState, HoloScriptDebugger, StackFrame, StepMode, createDebugger } from './debugger.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* HoloScript 2D Parser Extension
|
|
10
|
+
*
|
|
11
|
+
* Adds support for 2D UI elements to HoloScript for desktop/mobile apps.
|
|
12
|
+
* Works alongside 3D VR syntax for hybrid applications.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
declare class HoloScript2DParser {
|
|
16
|
+
private uiElements;
|
|
17
|
+
/**
|
|
18
|
+
* Parse 2D UI element from HoloScript code
|
|
19
|
+
*/
|
|
20
|
+
parse2DElement(code: string, depth?: number): UI2DNode | null;
|
|
21
|
+
private splitIntoLogicalBlocks;
|
|
22
|
+
/**
|
|
23
|
+
* Parse voice command for 2D UI creation
|
|
24
|
+
*/
|
|
25
|
+
parse2DVoiceCommand(command: string): UI2DNode | null;
|
|
26
|
+
/**
|
|
27
|
+
* Parse gesture for 2D UI interaction
|
|
28
|
+
*/
|
|
29
|
+
parse2DGesture(gestureType: string, position: Position2D): UI2DNode | null;
|
|
30
|
+
private createQuick2DElement;
|
|
31
|
+
private isValidUIElementType;
|
|
32
|
+
private parsePropertyValue;
|
|
33
|
+
private getDefaultProperties;
|
|
34
|
+
getUIElements(): Map<string, UI2DNode>;
|
|
35
|
+
findElement(name: string): UI2DNode | null;
|
|
36
|
+
clear(): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* HoloScript Parser
|
|
41
|
+
*
|
|
42
|
+
* Parses voice commands, gestures, and code into HoloScript AST.
|
|
43
|
+
* Supports both 3D VR and 2D UI elements.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
declare class HoloScriptParser {
|
|
47
|
+
private ast;
|
|
48
|
+
private parser2D;
|
|
49
|
+
constructor();
|
|
50
|
+
/**
|
|
51
|
+
* Parse voice command into AST nodes
|
|
52
|
+
*/
|
|
53
|
+
parseVoiceCommand(command: VoiceCommand$1): ASTNode[];
|
|
54
|
+
private parse2DUICommand;
|
|
55
|
+
/**
|
|
56
|
+
* Parse gesture input
|
|
57
|
+
*/
|
|
58
|
+
parseGesture(gesture: GestureData): ASTNode[];
|
|
59
|
+
private parseCreateCommand;
|
|
60
|
+
private parseConnectCommand;
|
|
61
|
+
private createOrbNode;
|
|
62
|
+
private createFunctionNode;
|
|
63
|
+
private createGateNode;
|
|
64
|
+
private createStreamNode;
|
|
65
|
+
private createGenericNode;
|
|
66
|
+
private parsePinchGesture;
|
|
67
|
+
private parseSwipeGesture;
|
|
68
|
+
private parseRotateGesture;
|
|
69
|
+
private parseGrabGesture;
|
|
70
|
+
private tokenizeCommand;
|
|
71
|
+
private sanitizeTokens;
|
|
72
|
+
private parseExecuteCommand;
|
|
73
|
+
private parseDebugCommand;
|
|
74
|
+
private parseVisualizeCommand;
|
|
75
|
+
private parseGenericCommand;
|
|
76
|
+
getAST(): ASTNode[];
|
|
77
|
+
addNode(node: ASTNode): void;
|
|
78
|
+
clear(): void;
|
|
79
|
+
findNode(name: string): ASTNode | null;
|
|
80
|
+
getNodesAtPosition(position: SpatialPosition, radius?: number): ASTNode[];
|
|
81
|
+
parse2DCode(code: string): UI2DNode | null;
|
|
82
|
+
get2DParser(): HoloScript2DParser;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface HSPlusCompileResult {
|
|
86
|
+
success: boolean;
|
|
87
|
+
code?: string;
|
|
88
|
+
sourceMap?: any;
|
|
89
|
+
errors: Array<{
|
|
90
|
+
message: string;
|
|
91
|
+
line: number;
|
|
92
|
+
column: number;
|
|
93
|
+
}>;
|
|
94
|
+
ast?: any;
|
|
95
|
+
compiledExpressions?: any;
|
|
96
|
+
requiredCompanions?: string[];
|
|
97
|
+
features?: any;
|
|
98
|
+
warnings?: any[];
|
|
99
|
+
[key: string]: any;
|
|
100
|
+
}
|
|
101
|
+
interface HSPlusParserOptions {
|
|
102
|
+
sourceMap?: boolean;
|
|
103
|
+
strict?: boolean;
|
|
104
|
+
enableTypeScriptImports?: boolean;
|
|
105
|
+
enableVRTraits?: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* HoloScript+ Parser
|
|
110
|
+
*
|
|
111
|
+
* Parses HoloScript+ source code into an AST with support for:
|
|
112
|
+
* - Standard HoloScript syntax (backward compatible)
|
|
113
|
+
* - @ directive parsing for VR traits, state, control flow
|
|
114
|
+
* - Expression interpolation with ${...}
|
|
115
|
+
* - TypeScript companion imports
|
|
116
|
+
*
|
|
117
|
+
* @version 1.0.0
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
declare class HoloScriptPlusParser$1 {
|
|
121
|
+
private tokens;
|
|
122
|
+
private pos;
|
|
123
|
+
private options;
|
|
124
|
+
private errors;
|
|
125
|
+
private warnings;
|
|
126
|
+
private imports;
|
|
127
|
+
private hasState;
|
|
128
|
+
private hasVRTraits;
|
|
129
|
+
private hasControlFlow;
|
|
130
|
+
private compiledExpressions;
|
|
131
|
+
constructor(options?: HSPlusParserOptions);
|
|
132
|
+
parse(source: string): HSPlusCompileResult;
|
|
133
|
+
private parseDocument;
|
|
134
|
+
private parseNode;
|
|
135
|
+
private parseDirective;
|
|
136
|
+
private parseTraitConfig;
|
|
137
|
+
private parseStateBlock;
|
|
138
|
+
private parseControlFlowBody;
|
|
139
|
+
private parseCodeBlock;
|
|
140
|
+
private parseInlineExpression;
|
|
141
|
+
private parseValue;
|
|
142
|
+
private parseArray;
|
|
143
|
+
private parseObject;
|
|
144
|
+
private current;
|
|
145
|
+
private check;
|
|
146
|
+
private advance;
|
|
147
|
+
private expect;
|
|
148
|
+
private skipNewlines;
|
|
149
|
+
private error;
|
|
150
|
+
private warn;
|
|
151
|
+
}
|
|
152
|
+
declare function createParser(options?: HSPlusParserOptions): HoloScriptPlusParser$1;
|
|
153
|
+
declare function parse(source: string, options?: HSPlusParserOptions): HSPlusCompileResult;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* HoloScriptPlus Parser - Extended DSL with Trait Annotations
|
|
157
|
+
*
|
|
158
|
+
* Extends HoloScript with support for:
|
|
159
|
+
* - @material trait annotations for PBR materials
|
|
160
|
+
* - @lighting trait annotations for dynamic lighting
|
|
161
|
+
* - @rendering trait annotations for GPU optimization
|
|
162
|
+
*
|
|
163
|
+
* Syntax:
|
|
164
|
+
* orb#sphere {
|
|
165
|
+
* @material { type: pbr, metallic: 0.5, roughness: 0.4 }
|
|
166
|
+
* @lighting { preset: studio, shadows: true }
|
|
167
|
+
* @rendering { quality: high, lod: true }
|
|
168
|
+
* }
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
interface TraitAnnotation {
|
|
172
|
+
type: 'material' | 'lighting' | 'rendering';
|
|
173
|
+
config: Record<string, unknown>;
|
|
174
|
+
line?: number;
|
|
175
|
+
column?: number;
|
|
176
|
+
}
|
|
177
|
+
interface MaterialTraitAnnotation extends TraitAnnotation {
|
|
178
|
+
type: 'material';
|
|
179
|
+
config: {
|
|
180
|
+
type?: string;
|
|
181
|
+
pbr?: {
|
|
182
|
+
baseColor?: {
|
|
183
|
+
r: number;
|
|
184
|
+
g: number;
|
|
185
|
+
b: number;
|
|
186
|
+
};
|
|
187
|
+
metallic?: number;
|
|
188
|
+
roughness?: number;
|
|
189
|
+
ambientOcclusion?: number;
|
|
190
|
+
emission?: {
|
|
191
|
+
r: number;
|
|
192
|
+
g: number;
|
|
193
|
+
b: number;
|
|
194
|
+
};
|
|
195
|
+
emissionStrength?: number;
|
|
196
|
+
};
|
|
197
|
+
textures?: Array<{
|
|
198
|
+
path: string;
|
|
199
|
+
channel: string;
|
|
200
|
+
}>;
|
|
201
|
+
compression?: 'none' | 'dxt' | 'astc' | 'basis';
|
|
202
|
+
instancing?: boolean;
|
|
203
|
+
streaming?: boolean;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
interface LightingTraitAnnotation extends TraitAnnotation {
|
|
207
|
+
type: 'lighting';
|
|
208
|
+
config: {
|
|
209
|
+
preset?: 'studio' | 'outdoor' | 'interior' | 'night' | 'sunset';
|
|
210
|
+
lights?: Array<{
|
|
211
|
+
type: 'directional' | 'point' | 'spot' | 'area' | 'ambient';
|
|
212
|
+
position?: {
|
|
213
|
+
x: number;
|
|
214
|
+
y: number;
|
|
215
|
+
z: number;
|
|
216
|
+
};
|
|
217
|
+
direction?: {
|
|
218
|
+
x: number;
|
|
219
|
+
y: number;
|
|
220
|
+
z: number;
|
|
221
|
+
};
|
|
222
|
+
color?: {
|
|
223
|
+
r: number;
|
|
224
|
+
g: number;
|
|
225
|
+
b: number;
|
|
226
|
+
};
|
|
227
|
+
intensity?: number;
|
|
228
|
+
range?: number;
|
|
229
|
+
shadows?: boolean;
|
|
230
|
+
}>;
|
|
231
|
+
globalIllumination?: {
|
|
232
|
+
skyColor?: {
|
|
233
|
+
r: number;
|
|
234
|
+
g: number;
|
|
235
|
+
b: number;
|
|
236
|
+
};
|
|
237
|
+
groundColor?: {
|
|
238
|
+
r: number;
|
|
239
|
+
g: number;
|
|
240
|
+
b: number;
|
|
241
|
+
};
|
|
242
|
+
probes?: number;
|
|
243
|
+
};
|
|
244
|
+
shadows?: boolean;
|
|
245
|
+
ao?: boolean;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
interface RenderingTraitAnnotation extends TraitAnnotation {
|
|
249
|
+
type: 'rendering';
|
|
250
|
+
config: {
|
|
251
|
+
quality?: 'low' | 'medium' | 'high' | 'ultra';
|
|
252
|
+
platform?: 'mobile' | 'vr' | 'desktop';
|
|
253
|
+
lod?: boolean;
|
|
254
|
+
culling?: boolean;
|
|
255
|
+
batching?: boolean;
|
|
256
|
+
instancing?: boolean;
|
|
257
|
+
maxTextureResolution?: number;
|
|
258
|
+
compression?: 'none' | 'dxt' | 'astc' | 'basis';
|
|
259
|
+
targetFPS?: number;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
type AnyTraitAnnotation = MaterialTraitAnnotation | LightingTraitAnnotation | RenderingTraitAnnotation;
|
|
263
|
+
interface GraphicsConfiguration {
|
|
264
|
+
material?: MaterialTraitAnnotation['config'];
|
|
265
|
+
lighting?: LightingTraitAnnotation['config'];
|
|
266
|
+
rendering?: RenderingTraitAnnotation['config'];
|
|
267
|
+
}
|
|
268
|
+
declare class HoloScriptPlusParser {
|
|
269
|
+
private baseParser;
|
|
270
|
+
constructor();
|
|
271
|
+
/**
|
|
272
|
+
* Parse HoloScript+ code with trait annotations
|
|
273
|
+
*/
|
|
274
|
+
parse(code: string): ASTNode[];
|
|
275
|
+
/**
|
|
276
|
+
* Enhance AST nodes with trait annotations
|
|
277
|
+
*/
|
|
278
|
+
private enhanceWithTraits;
|
|
279
|
+
/**
|
|
280
|
+
* Enhance OrbNode with trait annotations
|
|
281
|
+
*/
|
|
282
|
+
private enhanceOrbNodeWithTraits;
|
|
283
|
+
/**
|
|
284
|
+
* Extract trait annotations from code
|
|
285
|
+
*/
|
|
286
|
+
extractTraitAnnotations(code: string, _orbLine?: number): AnyTraitAnnotation[];
|
|
287
|
+
/**
|
|
288
|
+
* Parse object literal from string
|
|
289
|
+
* Supports nested objects and arrays
|
|
290
|
+
*/
|
|
291
|
+
parseObjectLiteral(str: string): Record<string, unknown>;
|
|
292
|
+
/**
|
|
293
|
+
* Parse individual values
|
|
294
|
+
*/
|
|
295
|
+
parseValue(str: string): unknown;
|
|
296
|
+
/**
|
|
297
|
+
* Build GraphicsConfiguration from trait annotations
|
|
298
|
+
*/
|
|
299
|
+
buildGraphicsConfig(traits: AnyTraitAnnotation[]): GraphicsConfiguration;
|
|
300
|
+
/**
|
|
301
|
+
* Validate trait annotation configuration
|
|
302
|
+
*/
|
|
303
|
+
validateTraitAnnotation(trait: AnyTraitAnnotation): {
|
|
304
|
+
valid: boolean;
|
|
305
|
+
errors: string[];
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Validate material trait configuration
|
|
309
|
+
*/
|
|
310
|
+
private validateMaterialTrait;
|
|
311
|
+
/**
|
|
312
|
+
* Validate lighting trait configuration
|
|
313
|
+
*/
|
|
314
|
+
private validateLightingTrait;
|
|
315
|
+
/**
|
|
316
|
+
* Validate rendering trait configuration
|
|
317
|
+
*/
|
|
318
|
+
private validateRenderingTrait;
|
|
319
|
+
/**
|
|
320
|
+
* Get trait annotations as graphics traits
|
|
321
|
+
*/
|
|
322
|
+
createGraphicsTraits(config: GraphicsConfiguration): any;
|
|
323
|
+
/**
|
|
324
|
+
* Create MaterialTrait from config
|
|
325
|
+
*/
|
|
326
|
+
private createMaterialTrait;
|
|
327
|
+
/**
|
|
328
|
+
* Create LightingTrait from config
|
|
329
|
+
*/
|
|
330
|
+
private createLightingTrait;
|
|
331
|
+
/**
|
|
332
|
+
* Create RenderingTrait from config
|
|
333
|
+
*/
|
|
334
|
+
private createRenderingTrait;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* HoloScript+ Type Definitions
|
|
339
|
+
*
|
|
340
|
+
* Enhanced HoloScript with VR interactions, state management, and TypeScript interop.
|
|
341
|
+
* Backward compatible with original HoloScript - new features are opt-in via @ directives.
|
|
342
|
+
*
|
|
343
|
+
* uaa2-service maintains its own evolved implementation for service-level enhancements.
|
|
344
|
+
* Core baseline: @holoscript/core
|
|
345
|
+
*
|
|
346
|
+
* @version 1.0.0
|
|
347
|
+
* @license MIT
|
|
348
|
+
*/
|
|
349
|
+
|
|
350
|
+
// =============================================================================
|
|
351
|
+
// CORE TYPES
|
|
352
|
+
// =============================================================================
|
|
353
|
+
|
|
354
|
+
type Vector3$1 = [number, number, number];
|
|
355
|
+
|
|
356
|
+
// =============================================================================
|
|
357
|
+
// VR INTERACTION TYPES
|
|
358
|
+
// =============================================================================
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Hand reference for VR interactions
|
|
362
|
+
*/
|
|
363
|
+
interface VRHand {
|
|
364
|
+
id: 'left' | 'right';
|
|
365
|
+
position: Vector3$1;
|
|
366
|
+
rotation: Vector3$1;
|
|
367
|
+
velocity: Vector3$1;
|
|
368
|
+
grip: number; // 0-1 grip strength
|
|
369
|
+
trigger: number; // 0-1 trigger pressure
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// =============================================================================
|
|
373
|
+
// VR INTERACTION TYPES
|
|
374
|
+
// =============================================================================
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Hand reference for VR interactions
|
|
378
|
+
*/
|
|
379
|
+
interface VRHand {
|
|
380
|
+
id: 'left' | 'right';
|
|
381
|
+
position: Vector3$1;
|
|
382
|
+
rotation: Vector3$1;
|
|
383
|
+
velocity: Vector3$1;
|
|
384
|
+
grip: number; // 0-1 grip strength
|
|
385
|
+
trigger: number; // 0-1 trigger pressure
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Velocity data for throw calculations
|
|
390
|
+
*/
|
|
391
|
+
interface ThrowVelocity {
|
|
392
|
+
direction: Vector3$1;
|
|
393
|
+
magnitude: number;
|
|
394
|
+
angularVelocity: Vector3$1;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Velocity data for throw calculations
|
|
399
|
+
*/
|
|
400
|
+
interface ThrowVelocity {
|
|
401
|
+
direction: Vector3$1;
|
|
402
|
+
magnitude: number;
|
|
403
|
+
angularVelocity: Vector3$1;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Collision event data
|
|
408
|
+
*/
|
|
409
|
+
interface CollisionEvent {
|
|
410
|
+
target: HSPlusNode;
|
|
411
|
+
point: Vector3$1;
|
|
412
|
+
normal: Vector3$1;
|
|
413
|
+
impulse: number;
|
|
414
|
+
relativeVelocity: Vector3$1;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Collision event data
|
|
419
|
+
*/
|
|
420
|
+
interface CollisionEvent {
|
|
421
|
+
target: HSPlusNode;
|
|
422
|
+
point: Vector3$1;
|
|
423
|
+
normal: Vector3$1;
|
|
424
|
+
impulse: number;
|
|
425
|
+
relativeVelocity: Vector3$1;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// =============================================================================
|
|
429
|
+
// STATE MANAGEMENT
|
|
430
|
+
// =============================================================================
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Reactive state declaration
|
|
434
|
+
*/
|
|
435
|
+
interface StateDeclaration {
|
|
436
|
+
[key: string]: unknown;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// =============================================================================
|
|
440
|
+
// STATE MANAGEMENT
|
|
441
|
+
// =============================================================================
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Reactive state declaration
|
|
445
|
+
*/
|
|
446
|
+
interface StateDeclaration {
|
|
447
|
+
[key: string]: unknown;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* State proxy for reactive updates
|
|
452
|
+
*/
|
|
453
|
+
interface ReactiveState$1<T extends StateDeclaration> {
|
|
454
|
+
get<K extends keyof T>(key: K): T[K];
|
|
455
|
+
set<K extends keyof T>(key: K, value: T[K]): void;
|
|
456
|
+
subscribe(callback: (state: T) => void): () => void;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* State proxy for reactive updates
|
|
461
|
+
*/
|
|
462
|
+
interface ReactiveState$1<T extends StateDeclaration> {
|
|
463
|
+
get<K extends keyof T>(key: K): T[K];
|
|
464
|
+
set<K extends keyof T>(key: K, value: T[K]): void;
|
|
465
|
+
subscribe(callback: (state: T) => void): () => void;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// =============================================================================
|
|
469
|
+
// LIFECYCLE HOOKS
|
|
470
|
+
// =============================================================================
|
|
471
|
+
|
|
472
|
+
type LifecycleHook =
|
|
473
|
+
| 'on_mount'
|
|
474
|
+
| 'on_unmount'
|
|
475
|
+
| 'on_update'
|
|
476
|
+
| 'on_data_update';
|
|
477
|
+
|
|
478
|
+
// =============================================================================
|
|
479
|
+
// LIFECYCLE HOOKS
|
|
480
|
+
// =============================================================================
|
|
481
|
+
|
|
482
|
+
type LifecycleHook =
|
|
483
|
+
| 'on_mount'
|
|
484
|
+
| 'on_unmount'
|
|
485
|
+
| 'on_update'
|
|
486
|
+
| 'on_data_update';
|
|
487
|
+
|
|
488
|
+
type VRLifecycleHook =
|
|
489
|
+
| 'on_grab'
|
|
490
|
+
| 'on_release'
|
|
491
|
+
| 'on_hover_enter'
|
|
492
|
+
| 'on_hover_exit'
|
|
493
|
+
| 'on_point_enter'
|
|
494
|
+
| 'on_point_exit'
|
|
495
|
+
| 'on_collision'
|
|
496
|
+
| 'on_trigger_enter'
|
|
497
|
+
| 'on_trigger_exit'
|
|
498
|
+
| 'on_click'
|
|
499
|
+
| 'on_double_click';
|
|
500
|
+
|
|
501
|
+
type VRLifecycleHook =
|
|
502
|
+
| 'on_grab'
|
|
503
|
+
| 'on_release'
|
|
504
|
+
| 'on_hover_enter'
|
|
505
|
+
| 'on_hover_exit'
|
|
506
|
+
| 'on_point_enter'
|
|
507
|
+
| 'on_point_exit'
|
|
508
|
+
| 'on_collision'
|
|
509
|
+
| 'on_trigger_enter'
|
|
510
|
+
| 'on_trigger_exit'
|
|
511
|
+
| 'on_click'
|
|
512
|
+
| 'on_double_click';
|
|
513
|
+
|
|
514
|
+
type ControllerHook =
|
|
515
|
+
| 'on_controller_button'
|
|
516
|
+
| 'on_trigger_hold'
|
|
517
|
+
| 'on_trigger_release'
|
|
518
|
+
| 'on_grip_hold'
|
|
519
|
+
| 'on_grip_release';
|
|
520
|
+
|
|
521
|
+
type ControllerHook =
|
|
522
|
+
| 'on_controller_button'
|
|
523
|
+
| 'on_trigger_hold'
|
|
524
|
+
| 'on_trigger_release'
|
|
525
|
+
| 'on_grip_hold'
|
|
526
|
+
| 'on_grip_release';
|
|
527
|
+
|
|
528
|
+
// =============================================================================
|
|
529
|
+
// AST NODE TYPES
|
|
530
|
+
// =============================================================================
|
|
531
|
+
|
|
532
|
+
type HSPlusDirective =
|
|
533
|
+
| { type: 'state'; body: StateDeclaration }
|
|
534
|
+
| { type: 'for'; variable: string; iterable: string; body: HSPlusNode[] }
|
|
535
|
+
| { type: 'if'; condition: string; body: HSPlusNode[]; else?: HSPlusNode[] }
|
|
536
|
+
| { type: 'import'; path: string; alias: string }
|
|
537
|
+
| { type: 'lifecycle'; hook: LifecycleHook | VRLifecycleHook | ControllerHook; params?: string[]; body: string }
|
|
538
|
+
| { type: 'trait'; name: VRTraitName; config: Record<string, unknown> };
|
|
539
|
+
|
|
540
|
+
// =============================================================================
|
|
541
|
+
// AST NODE TYPES
|
|
542
|
+
// =============================================================================
|
|
543
|
+
|
|
544
|
+
type HSPlusDirective =
|
|
545
|
+
| { type: 'state'; body: StateDeclaration }
|
|
546
|
+
| { type: 'for'; variable: string; iterable: string; body: HSPlusNode[] }
|
|
547
|
+
| { type: 'if'; condition: string; body: HSPlusNode[]; else?: HSPlusNode[] }
|
|
548
|
+
| { type: 'import'; path: string; alias: string }
|
|
549
|
+
| { type: 'lifecycle'; hook: LifecycleHook | VRLifecycleHook | ControllerHook; params?: string[]; body: string }
|
|
550
|
+
| { type: 'trait'; name: VRTraitName; config: Record<string, unknown> };
|
|
551
|
+
|
|
552
|
+
type VRTraitName =
|
|
553
|
+
| 'grabbable'
|
|
554
|
+
| 'throwable'
|
|
555
|
+
| 'pointable'
|
|
556
|
+
| 'hoverable'
|
|
557
|
+
| 'scalable'
|
|
558
|
+
| 'rotatable'
|
|
559
|
+
| 'stackable'
|
|
560
|
+
| 'snappable'
|
|
561
|
+
| 'breakable';
|
|
562
|
+
|
|
563
|
+
type VRTraitName =
|
|
564
|
+
| 'grabbable'
|
|
565
|
+
| 'throwable'
|
|
566
|
+
| 'pointable'
|
|
567
|
+
| 'hoverable'
|
|
568
|
+
| 'scalable'
|
|
569
|
+
| 'rotatable'
|
|
570
|
+
| 'stackable'
|
|
571
|
+
| 'snappable'
|
|
572
|
+
| 'breakable';
|
|
573
|
+
|
|
574
|
+
interface HSPlusNode {
|
|
575
|
+
type: string;
|
|
576
|
+
id?: string;
|
|
577
|
+
properties: Record<string, unknown>;
|
|
578
|
+
directives: HSPlusDirective[];
|
|
579
|
+
children: HSPlusNode[];
|
|
580
|
+
traits: Map<VRTraitName, unknown>;
|
|
581
|
+
// Source location for debugging
|
|
582
|
+
loc?: {
|
|
583
|
+
start: { line: number; column: number };
|
|
584
|
+
end: { line: number; column: number };
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
interface HSPlusNode {
|
|
589
|
+
type: string;
|
|
590
|
+
id?: string;
|
|
591
|
+
properties: Record<string, unknown>;
|
|
592
|
+
directives: HSPlusDirective[];
|
|
593
|
+
children: HSPlusNode[];
|
|
594
|
+
traits: Map<VRTraitName, unknown>;
|
|
595
|
+
// Source location for debugging
|
|
596
|
+
loc?: {
|
|
597
|
+
start: { line: number; column: number };
|
|
598
|
+
end: { line: number; column: number };
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
interface HSPlusAST {
|
|
603
|
+
version: '1.0';
|
|
604
|
+
root: HSPlusNode;
|
|
605
|
+
imports: Array<{ path: string; alias: string }>;
|
|
606
|
+
hasState: boolean;
|
|
607
|
+
hasVRTraits: boolean;
|
|
608
|
+
hasControlFlow: boolean;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
interface HSPlusAST {
|
|
612
|
+
version: '1.0';
|
|
613
|
+
root: HSPlusNode;
|
|
614
|
+
imports: Array<{ path: string; alias: string }>;
|
|
615
|
+
hasState: boolean;
|
|
616
|
+
hasVRTraits: boolean;
|
|
617
|
+
hasControlFlow: boolean;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
interface HSPlusRuntime {
|
|
621
|
+
// Mount the scene
|
|
622
|
+
mount: (container: unknown) => void;
|
|
623
|
+
|
|
624
|
+
// Unmount and cleanup
|
|
625
|
+
unmount: () => void;
|
|
626
|
+
|
|
627
|
+
// Update with new data
|
|
628
|
+
updateData: (data: unknown) => void;
|
|
629
|
+
|
|
630
|
+
// Get current state
|
|
631
|
+
getState: () => StateDeclaration;
|
|
632
|
+
|
|
633
|
+
// Set state
|
|
634
|
+
setState: (updates: Partial<StateDeclaration>) => void;
|
|
635
|
+
|
|
636
|
+
// Emit event
|
|
637
|
+
emit: (event: string, payload?: unknown) => void;
|
|
638
|
+
|
|
639
|
+
// Subscribe to events
|
|
640
|
+
on: (event: string, handler: (payload: unknown) => void) => () => void;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
interface HSPlusRuntime {
|
|
644
|
+
// Mount the scene
|
|
645
|
+
mount: (container: unknown) => void;
|
|
646
|
+
|
|
647
|
+
// Unmount and cleanup
|
|
648
|
+
unmount: () => void;
|
|
649
|
+
|
|
650
|
+
// Update with new data
|
|
651
|
+
updateData: (data: unknown) => void;
|
|
652
|
+
|
|
653
|
+
// Get current state
|
|
654
|
+
getState: () => StateDeclaration;
|
|
655
|
+
|
|
656
|
+
// Set state
|
|
657
|
+
setState: (updates: Partial<StateDeclaration>) => void;
|
|
658
|
+
|
|
659
|
+
// Emit event
|
|
660
|
+
emit: (event: string, payload?: unknown) => void;
|
|
661
|
+
|
|
662
|
+
// Subscribe to events
|
|
663
|
+
on: (event: string, handler: (payload: unknown) => void) => () => void;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* VR Trait System
|
|
668
|
+
*
|
|
669
|
+
* Implements VR interaction traits for HoloScript+ objects:
|
|
670
|
+
* - @grabbable - Hand grab interactions
|
|
671
|
+
* - @throwable - Physics-based throwing
|
|
672
|
+
* - @pointable - Laser pointer interactions
|
|
673
|
+
* - @hoverable - Hover state and highlights
|
|
674
|
+
* - @scalable - Two-handed scaling
|
|
675
|
+
* - @rotatable - Rotation interactions
|
|
676
|
+
* - @stackable - Stacking behavior
|
|
677
|
+
* - @snappable - Snap-to-point behavior
|
|
678
|
+
* - @breakable - Destruction on impact
|
|
679
|
+
*
|
|
680
|
+
* @version 1.0.0
|
|
681
|
+
*/
|
|
682
|
+
|
|
683
|
+
interface TraitHandler<TConfig = unknown> {
|
|
684
|
+
name: VRTraitName;
|
|
685
|
+
defaultConfig: TConfig;
|
|
686
|
+
onAttach?: (node: HSPlusNode, config: TConfig, context: TraitContext) => void;
|
|
687
|
+
onDetach?: (node: HSPlusNode, config: TConfig, context: TraitContext) => void;
|
|
688
|
+
onUpdate?: (node: HSPlusNode, config: TConfig, context: TraitContext, delta: number) => void;
|
|
689
|
+
onEvent?: (node: HSPlusNode, config: TConfig, context: TraitContext, event: TraitEvent) => void;
|
|
690
|
+
}
|
|
691
|
+
interface TraitContext {
|
|
692
|
+
vr: VRContext;
|
|
693
|
+
physics: PhysicsContext;
|
|
694
|
+
audio: AudioContext;
|
|
695
|
+
haptics: HapticsContext;
|
|
696
|
+
emit: (event: string, payload?: unknown) => void;
|
|
697
|
+
getState: () => Record<string, unknown>;
|
|
698
|
+
setState: (updates: Record<string, unknown>) => void;
|
|
699
|
+
}
|
|
700
|
+
interface VRContext {
|
|
701
|
+
hands: {
|
|
702
|
+
left: VRHand | null;
|
|
703
|
+
right: VRHand | null;
|
|
704
|
+
};
|
|
705
|
+
headset: {
|
|
706
|
+
position: Vector3$1;
|
|
707
|
+
rotation: Vector3$1;
|
|
708
|
+
};
|
|
709
|
+
getPointerRay: (hand: 'left' | 'right') => {
|
|
710
|
+
origin: Vector3$1;
|
|
711
|
+
direction: Vector3$1;
|
|
712
|
+
} | null;
|
|
713
|
+
getDominantHand: () => VRHand | null;
|
|
714
|
+
}
|
|
715
|
+
interface PhysicsContext {
|
|
716
|
+
applyVelocity: (node: HSPlusNode, velocity: Vector3$1) => void;
|
|
717
|
+
applyAngularVelocity: (node: HSPlusNode, angularVelocity: Vector3$1) => void;
|
|
718
|
+
setKinematic: (node: HSPlusNode, kinematic: boolean) => void;
|
|
719
|
+
raycast: (origin: Vector3$1, direction: Vector3$1, maxDistance: number) => RaycastHit | null;
|
|
720
|
+
}
|
|
721
|
+
interface RaycastHit {
|
|
722
|
+
node: HSPlusNode;
|
|
723
|
+
point: Vector3$1;
|
|
724
|
+
normal: Vector3$1;
|
|
725
|
+
distance: number;
|
|
726
|
+
}
|
|
727
|
+
interface AudioContext {
|
|
728
|
+
playSound: (source: string, options?: {
|
|
729
|
+
position?: Vector3$1;
|
|
730
|
+
volume?: number;
|
|
731
|
+
spatial?: boolean;
|
|
732
|
+
}) => void;
|
|
733
|
+
}
|
|
734
|
+
interface HapticsContext {
|
|
735
|
+
pulse: (hand: 'left' | 'right', intensity: number, duration?: number) => void;
|
|
736
|
+
rumble: (hand: 'left' | 'right', intensity: number) => void;
|
|
737
|
+
}
|
|
738
|
+
type TraitEvent = {
|
|
739
|
+
type: 'grab_start';
|
|
740
|
+
hand: VRHand;
|
|
741
|
+
} | {
|
|
742
|
+
type: 'grab_end';
|
|
743
|
+
hand: VRHand;
|
|
744
|
+
velocity: ThrowVelocity;
|
|
745
|
+
} | {
|
|
746
|
+
type: 'hover_enter';
|
|
747
|
+
hand: VRHand;
|
|
748
|
+
} | {
|
|
749
|
+
type: 'hover_exit';
|
|
750
|
+
hand: VRHand;
|
|
751
|
+
} | {
|
|
752
|
+
type: 'point_enter';
|
|
753
|
+
hand: VRHand;
|
|
754
|
+
} | {
|
|
755
|
+
type: 'point_exit';
|
|
756
|
+
hand: VRHand;
|
|
757
|
+
} | {
|
|
758
|
+
type: 'collision';
|
|
759
|
+
data: CollisionEvent;
|
|
760
|
+
} | {
|
|
761
|
+
type: 'trigger_enter';
|
|
762
|
+
other: HSPlusNode;
|
|
763
|
+
} | {
|
|
764
|
+
type: 'trigger_exit';
|
|
765
|
+
other: HSPlusNode;
|
|
766
|
+
} | {
|
|
767
|
+
type: 'click';
|
|
768
|
+
hand: VRHand;
|
|
769
|
+
} | {
|
|
770
|
+
type: 'scale_start';
|
|
771
|
+
hands: {
|
|
772
|
+
left: VRHand;
|
|
773
|
+
right: VRHand;
|
|
774
|
+
};
|
|
775
|
+
} | {
|
|
776
|
+
type: 'scale_update';
|
|
777
|
+
scale: number;
|
|
778
|
+
} | {
|
|
779
|
+
type: 'scale_end';
|
|
780
|
+
finalScale: number;
|
|
781
|
+
} | {
|
|
782
|
+
type: 'rotate_start';
|
|
783
|
+
hand: VRHand;
|
|
784
|
+
} | {
|
|
785
|
+
type: 'rotate_update';
|
|
786
|
+
rotation: Vector3$1;
|
|
787
|
+
} | {
|
|
788
|
+
type: 'rotate_end';
|
|
789
|
+
finalRotation: Vector3$1;
|
|
790
|
+
};
|
|
791
|
+
declare class VRTraitRegistry {
|
|
792
|
+
private handlers;
|
|
793
|
+
constructor();
|
|
794
|
+
register<T>(handler: TraitHandler<T>): void;
|
|
795
|
+
getHandler(name: VRTraitName): TraitHandler | undefined;
|
|
796
|
+
attachTrait(node: HSPlusNode, traitName: VRTraitName, config: unknown, context: TraitContext): void;
|
|
797
|
+
detachTrait(node: HSPlusNode, traitName: VRTraitName, context: TraitContext): void;
|
|
798
|
+
updateTrait(node: HSPlusNode, traitName: VRTraitName, context: TraitContext, delta: number): void;
|
|
799
|
+
handleEvent(node: HSPlusNode, traitName: VRTraitName, context: TraitContext, event: TraitEvent): void;
|
|
800
|
+
updateAllTraits(node: HSPlusNode, context: TraitContext, delta: number): void;
|
|
801
|
+
handleEventForAllTraits(node: HSPlusNode, context: TraitContext, event: TraitEvent): void;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* HoloScript+ Runtime Engine
|
|
806
|
+
*
|
|
807
|
+
* Executes parsed HoloScript+ AST with:
|
|
808
|
+
* - Control flow (@for, @if) evaluation
|
|
809
|
+
* - Lifecycle hook management
|
|
810
|
+
* - VR trait integration
|
|
811
|
+
* - Reactive state binding
|
|
812
|
+
* - TypeScript companion integration
|
|
813
|
+
*
|
|
814
|
+
* @version 1.0.0
|
|
815
|
+
*/
|
|
816
|
+
|
|
817
|
+
interface RuntimeOptions {
|
|
818
|
+
renderer?: Renderer;
|
|
819
|
+
vrEnabled?: boolean;
|
|
820
|
+
companions?: Record<string, Record<string, (...args: unknown[]) => unknown>>;
|
|
821
|
+
}
|
|
822
|
+
interface Renderer {
|
|
823
|
+
createElement(type: string, properties: Record<string, unknown>): unknown;
|
|
824
|
+
updateElement(element: unknown, properties: Record<string, unknown>): void;
|
|
825
|
+
appendChild(parent: unknown, child: unknown): void;
|
|
826
|
+
removeChild(parent: unknown, child: unknown): void;
|
|
827
|
+
destroy(element: unknown): void;
|
|
828
|
+
}
|
|
829
|
+
declare class HoloScriptPlusRuntimeImpl implements HSPlusRuntime {
|
|
830
|
+
private ast;
|
|
831
|
+
private options;
|
|
832
|
+
private state;
|
|
833
|
+
private evaluator;
|
|
834
|
+
private builtins;
|
|
835
|
+
private traitRegistry;
|
|
836
|
+
private rootInstance;
|
|
837
|
+
private eventHandlers;
|
|
838
|
+
private templates;
|
|
839
|
+
private updateLoopId;
|
|
840
|
+
private lastUpdateTime;
|
|
841
|
+
private companions;
|
|
842
|
+
private mounted;
|
|
843
|
+
vrContext: {
|
|
844
|
+
hands: {
|
|
845
|
+
left: VRHand | null;
|
|
846
|
+
right: VRHand | null;
|
|
847
|
+
};
|
|
848
|
+
headset: {
|
|
849
|
+
position: Vector3$1;
|
|
850
|
+
rotation: Vector3$1;
|
|
851
|
+
};
|
|
852
|
+
controllers: {
|
|
853
|
+
left: unknown;
|
|
854
|
+
right: unknown;
|
|
855
|
+
};
|
|
856
|
+
};
|
|
857
|
+
constructor(ast: HSPlusAST, options?: RuntimeOptions);
|
|
858
|
+
private initializeState;
|
|
859
|
+
private loadImports;
|
|
860
|
+
mount(container: unknown): void;
|
|
861
|
+
unmount(): void;
|
|
862
|
+
private instantiateNode;
|
|
863
|
+
private processDirectives;
|
|
864
|
+
private registerLifecycleHandler;
|
|
865
|
+
private processControlFlow;
|
|
866
|
+
private cloneNodeWithContext;
|
|
867
|
+
private interpolateString;
|
|
868
|
+
private interpolateProperties;
|
|
869
|
+
private evaluateExpression;
|
|
870
|
+
private evaluateProperties;
|
|
871
|
+
private callLifecycle;
|
|
872
|
+
private startUpdateLoop;
|
|
873
|
+
private stopUpdateLoop;
|
|
874
|
+
private update;
|
|
875
|
+
private updateInstance;
|
|
876
|
+
private createTraitContext;
|
|
877
|
+
private destroyInstance;
|
|
878
|
+
updateData(data: unknown): void;
|
|
879
|
+
getState(): StateDeclaration;
|
|
880
|
+
setState(updates: Partial<StateDeclaration>): void;
|
|
881
|
+
emit(event: string, payload?: unknown): void;
|
|
882
|
+
on(event: string, handler: (payload: unknown) => void): () => void;
|
|
883
|
+
updateVRContext(context: typeof this.vrContext): void;
|
|
884
|
+
handleVREvent(event: TraitEvent, node: HSPlusNode): void;
|
|
885
|
+
private findInstance;
|
|
886
|
+
registerTemplate(name: string, node: HSPlusNode): void;
|
|
887
|
+
spawnTemplate(name: string, position: Vector3$1): HSPlusNode;
|
|
888
|
+
destroyNode(node: HSPlusNode): void;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Reactive State System for HoloScript+
|
|
893
|
+
*
|
|
894
|
+
* Provides reactive state management with:
|
|
895
|
+
* - Proxy-based reactivity
|
|
896
|
+
* - Computed properties
|
|
897
|
+
* - Effect system for side effects
|
|
898
|
+
* - Batched updates for performance
|
|
899
|
+
*
|
|
900
|
+
* @version 1.0.0
|
|
901
|
+
*/
|
|
902
|
+
|
|
903
|
+
type Subscriber<T> = (state: T, changedKey?: keyof T) => void;
|
|
904
|
+
type UnsubscribeFunc = () => void;
|
|
905
|
+
type EffectFunc = () => void | (() => void);
|
|
906
|
+
type ComputedFunc<T> = () => T;
|
|
907
|
+
interface EffectOptions {
|
|
908
|
+
immediate?: boolean;
|
|
909
|
+
deep?: boolean;
|
|
910
|
+
}
|
|
911
|
+
declare class ReactiveState<T extends StateDeclaration> implements ReactiveState$1<T> {
|
|
912
|
+
private state;
|
|
913
|
+
private proxy;
|
|
914
|
+
private subscribers;
|
|
915
|
+
private computedCache;
|
|
916
|
+
private watchCleanups;
|
|
917
|
+
constructor(initialState: T);
|
|
918
|
+
get<K extends keyof T>(key: K): T[K];
|
|
919
|
+
set<K extends keyof T>(key: K, value: T[K]): void;
|
|
920
|
+
update(updates: Partial<T>): void;
|
|
921
|
+
subscribe(callback: Subscriber<T>): UnsubscribeFunc;
|
|
922
|
+
private notifySubscribers;
|
|
923
|
+
computed<R>(key: string, getter: ComputedFunc<R>): R;
|
|
924
|
+
watch<K extends keyof T>(key: K, handler: (newValue: T[K], oldValue: T[K]) => void, options?: EffectOptions): UnsubscribeFunc;
|
|
925
|
+
watchEffect(effect: EffectFunc, _options?: EffectOptions): UnsubscribeFunc;
|
|
926
|
+
getSnapshot(): T;
|
|
927
|
+
reset(newState?: T): void;
|
|
928
|
+
destroy(): void;
|
|
929
|
+
}
|
|
930
|
+
declare function createState<T extends StateDeclaration>(initialState: T): ReactiveState<T>;
|
|
931
|
+
declare function reactive<T extends object>(target: T): T;
|
|
932
|
+
declare function effect(fn: EffectFunc, _options?: EffectOptions): UnsubscribeFunc;
|
|
933
|
+
declare function computed<T>(getter: ComputedFunc<T>): {
|
|
934
|
+
readonly value: T;
|
|
935
|
+
};
|
|
936
|
+
interface StateBinding<T> {
|
|
937
|
+
get: () => T;
|
|
938
|
+
set: (value: T) => void;
|
|
939
|
+
subscribe: (callback: (value: T) => void) => UnsubscribeFunc;
|
|
940
|
+
}
|
|
941
|
+
declare function bind<T extends StateDeclaration, K extends keyof T>(state: ReactiveState<T>, key: K): StateBinding<T[K]>;
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* @holoscript/core VoiceInput Trait
|
|
945
|
+
*
|
|
946
|
+
* Enables voice-driven interactions for HoloScript+ objects
|
|
947
|
+
* Integrates speech recognition with confidence-based command parsing
|
|
948
|
+
*/
|
|
949
|
+
type VoiceInputMode = 'continuous' | 'push-to-talk' | 'always-listening';
|
|
950
|
+
type ConfidenceThreshold = number;
|
|
951
|
+
/**
|
|
952
|
+
* Voice input configuration for HoloScript+ objects
|
|
953
|
+
*/
|
|
954
|
+
interface VoiceInputConfig {
|
|
955
|
+
/** Speech recognition mode */
|
|
956
|
+
mode: VoiceInputMode;
|
|
957
|
+
/** Minimum confidence level (0-1) to trigger command */
|
|
958
|
+
confidenceThreshold: ConfidenceThreshold;
|
|
959
|
+
/** Languages supported (BCP 47 codes) */
|
|
960
|
+
languages?: string[];
|
|
961
|
+
/** Commands this object responds to */
|
|
962
|
+
commands?: VoiceCommand[];
|
|
963
|
+
/** Enable speech-to-text display */
|
|
964
|
+
showTranscript?: boolean;
|
|
965
|
+
/** Audio feedback (beep on recognition) */
|
|
966
|
+
audioFeedback?: boolean;
|
|
967
|
+
/** Max command processing time (ms) */
|
|
968
|
+
timeout?: number;
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Voice command definition
|
|
972
|
+
*/
|
|
973
|
+
interface VoiceCommand {
|
|
974
|
+
/** Primary trigger phrase */
|
|
975
|
+
phrase: string;
|
|
976
|
+
/** Alternative phrases (fuzzy matching) */
|
|
977
|
+
aliases?: string[];
|
|
978
|
+
/** Confidence threshold for this specific command */
|
|
979
|
+
confidence?: number;
|
|
980
|
+
/** Action to execute */
|
|
981
|
+
action: string;
|
|
982
|
+
/** Parameters extracted from command */
|
|
983
|
+
params?: Record<string, string>;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Voice recognition result
|
|
987
|
+
*/
|
|
988
|
+
interface VoiceRecognitionResult {
|
|
989
|
+
/** Transcribed text */
|
|
990
|
+
transcript: string;
|
|
991
|
+
/** Confidence (0-1) */
|
|
992
|
+
confidence: number;
|
|
993
|
+
/** Is final result or interim? */
|
|
994
|
+
isFinal: boolean;
|
|
995
|
+
/** Language detected */
|
|
996
|
+
language: string;
|
|
997
|
+
/** Matched command if any */
|
|
998
|
+
matchedCommand?: VoiceCommand;
|
|
999
|
+
/** Timestamp */
|
|
1000
|
+
timestamp: number;
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Voice input event
|
|
1004
|
+
*/
|
|
1005
|
+
interface VoiceInputEvent {
|
|
1006
|
+
type: 'start' | 'interim' | 'final' | 'error' | 'timeout';
|
|
1007
|
+
result: VoiceRecognitionResult;
|
|
1008
|
+
hologramId: string;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* VoiceInputTrait - Enables speech recognition on HoloScript+ objects
|
|
1012
|
+
*/
|
|
1013
|
+
declare class VoiceInputTrait {
|
|
1014
|
+
private config;
|
|
1015
|
+
private recognition;
|
|
1016
|
+
private isListening;
|
|
1017
|
+
private listeners;
|
|
1018
|
+
private interimTranscript;
|
|
1019
|
+
private commandCache;
|
|
1020
|
+
constructor(config: VoiceInputConfig);
|
|
1021
|
+
/**
|
|
1022
|
+
* Initialize Web Speech API
|
|
1023
|
+
*/
|
|
1024
|
+
private initializeRecognition;
|
|
1025
|
+
/**
|
|
1026
|
+
* Setup Web Speech API event handlers
|
|
1027
|
+
*/
|
|
1028
|
+
private setupRecognitionHandlers;
|
|
1029
|
+
/**
|
|
1030
|
+
* Process voice command with fuzzy matching
|
|
1031
|
+
*/
|
|
1032
|
+
private processVoiceCommand;
|
|
1033
|
+
/**
|
|
1034
|
+
* Fuzzy string matching (simple Levenshtein-like approach)
|
|
1035
|
+
*/
|
|
1036
|
+
private fuzzyMatch;
|
|
1037
|
+
/**
|
|
1038
|
+
* Build command index for faster lookup
|
|
1039
|
+
*/
|
|
1040
|
+
private buildCommandCache;
|
|
1041
|
+
/**
|
|
1042
|
+
* Start listening for voice input
|
|
1043
|
+
*/
|
|
1044
|
+
startListening(): void;
|
|
1045
|
+
/**
|
|
1046
|
+
* Stop listening for voice input
|
|
1047
|
+
*/
|
|
1048
|
+
stopListening(): void;
|
|
1049
|
+
/**
|
|
1050
|
+
* Toggle listening state
|
|
1051
|
+
*/
|
|
1052
|
+
toggleListening(): void;
|
|
1053
|
+
/**
|
|
1054
|
+
* Add command listener
|
|
1055
|
+
*/
|
|
1056
|
+
on(listener: (event: VoiceInputEvent) => void): void;
|
|
1057
|
+
/**
|
|
1058
|
+
* Remove command listener
|
|
1059
|
+
*/
|
|
1060
|
+
off(listener: (event: VoiceInputEvent) => void): void;
|
|
1061
|
+
/**
|
|
1062
|
+
* Emit voice event to all listeners
|
|
1063
|
+
*/
|
|
1064
|
+
private emitEvent;
|
|
1065
|
+
/**
|
|
1066
|
+
* Play audio feedback beep
|
|
1067
|
+
*/
|
|
1068
|
+
private playBeep;
|
|
1069
|
+
/**
|
|
1070
|
+
* Get current listening state
|
|
1071
|
+
*/
|
|
1072
|
+
isActive(): boolean;
|
|
1073
|
+
/**
|
|
1074
|
+
* Dispose and cleanup
|
|
1075
|
+
*/
|
|
1076
|
+
dispose(): void;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* HoloScript+ @voice_input trait factory
|
|
1080
|
+
*/
|
|
1081
|
+
declare function createVoiceInputTrait(config: VoiceInputConfig): VoiceInputTrait;
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* @holoscript/core AI-Driven NPC Trait
|
|
1085
|
+
*
|
|
1086
|
+
* Enables intelligent NPC behaviors using behavior trees and goal planning
|
|
1087
|
+
* Integrates with Infinity Assistant service for agent-based decision making
|
|
1088
|
+
*/
|
|
1089
|
+
type BehaviorState = 'idle' | 'moving' | 'acting' | 'talking' | 'reacting';
|
|
1090
|
+
type DecisionMode = 'reactive' | 'goal-driven' | 'learning' | 'hybrid';
|
|
1091
|
+
/**
|
|
1092
|
+
* Behavior tree node
|
|
1093
|
+
*/
|
|
1094
|
+
interface BehaviorNode {
|
|
1095
|
+
id: string;
|
|
1096
|
+
type: 'sequence' | 'selector' | 'parallel' | 'action' | 'condition';
|
|
1097
|
+
children?: BehaviorNode[];
|
|
1098
|
+
action?: (context: NPCContext) => Promise<boolean>;
|
|
1099
|
+
condition?: (context: NPCContext) => boolean;
|
|
1100
|
+
metadata?: Record<string, unknown>;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* NPC Context for behavior execution
|
|
1104
|
+
*/
|
|
1105
|
+
interface NPCContext {
|
|
1106
|
+
npcId: string;
|
|
1107
|
+
position: [number, number, number];
|
|
1108
|
+
rotation: [number, number, number];
|
|
1109
|
+
targetId?: string;
|
|
1110
|
+
targetPosition?: [number, number, number];
|
|
1111
|
+
memory: Map<string, unknown>;
|
|
1112
|
+
state: BehaviorState;
|
|
1113
|
+
energy: number;
|
|
1114
|
+
mood: number;
|
|
1115
|
+
perception: {
|
|
1116
|
+
nearbyEntities: string[];
|
|
1117
|
+
visibleEntities: string[];
|
|
1118
|
+
hearableVoice?: string;
|
|
1119
|
+
};
|
|
1120
|
+
dialogue?: {
|
|
1121
|
+
lastSaid?: string;
|
|
1122
|
+
lastHeard?: string;
|
|
1123
|
+
conversationHistory: Array<{
|
|
1124
|
+
speaker: string;
|
|
1125
|
+
text: string;
|
|
1126
|
+
}>;
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Goal for GOAP-style planning
|
|
1131
|
+
*/
|
|
1132
|
+
interface NPCGoal {
|
|
1133
|
+
id: string;
|
|
1134
|
+
name: string;
|
|
1135
|
+
priority: number;
|
|
1136
|
+
preconditions: Map<string, unknown>;
|
|
1137
|
+
effects: Map<string, unknown>;
|
|
1138
|
+
cost: number;
|
|
1139
|
+
timeoutMs?: number;
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* AI-Driven NPC configuration
|
|
1143
|
+
*/
|
|
1144
|
+
interface AIDriverConfig {
|
|
1145
|
+
/** NPC identifier */
|
|
1146
|
+
npcId: string;
|
|
1147
|
+
/** Decision making mode */
|
|
1148
|
+
decisionMode: DecisionMode;
|
|
1149
|
+
/** Base behavior tree */
|
|
1150
|
+
behaviorTree?: BehaviorNode;
|
|
1151
|
+
/** Available goals */
|
|
1152
|
+
goals?: NPCGoal[];
|
|
1153
|
+
/** Personality traits */
|
|
1154
|
+
personality?: {
|
|
1155
|
+
sociability: number;
|
|
1156
|
+
aggression: number;
|
|
1157
|
+
curiosity: number;
|
|
1158
|
+
loyalty: number;
|
|
1159
|
+
};
|
|
1160
|
+
/** Response to stimuli */
|
|
1161
|
+
stimuliThresholds?: {
|
|
1162
|
+
hearing: number;
|
|
1163
|
+
sight: number;
|
|
1164
|
+
touch: number;
|
|
1165
|
+
};
|
|
1166
|
+
/** Learning config */
|
|
1167
|
+
enableLearning?: boolean;
|
|
1168
|
+
learningRate?: number;
|
|
1169
|
+
/** Infinity Assistant integration */
|
|
1170
|
+
agentId?: string;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Behavior tree runner
|
|
1174
|
+
*/
|
|
1175
|
+
declare class BehaviorTreeRunner {
|
|
1176
|
+
private rootNode;
|
|
1177
|
+
constructor(rootNode: BehaviorNode);
|
|
1178
|
+
tick(context: NPCContext): Promise<boolean>;
|
|
1179
|
+
private executeNode;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* Goal-Oriented Action Planning (GOAP)
|
|
1183
|
+
*/
|
|
1184
|
+
declare class GOAPPlanner {
|
|
1185
|
+
private goals;
|
|
1186
|
+
constructor(goals: NPCGoal[]);
|
|
1187
|
+
/**
|
|
1188
|
+
* Plan a sequence of actions to reach goal
|
|
1189
|
+
*/
|
|
1190
|
+
planGoal(currentState: Map<string, unknown>, _goal: NPCGoal): NPCGoal[];
|
|
1191
|
+
private canAchieve;
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* AIDriverTrait - Enables intelligent NPC behaviors
|
|
1195
|
+
*/
|
|
1196
|
+
declare class AIDriverTrait {
|
|
1197
|
+
private config;
|
|
1198
|
+
private context;
|
|
1199
|
+
private behaviorRunner;
|
|
1200
|
+
private goapPlanner;
|
|
1201
|
+
private updateInterval;
|
|
1202
|
+
private learningModel;
|
|
1203
|
+
constructor(config: AIDriverConfig);
|
|
1204
|
+
/**
|
|
1205
|
+
* Start NPC AI loop
|
|
1206
|
+
*/
|
|
1207
|
+
startAI(): void;
|
|
1208
|
+
/**
|
|
1209
|
+
* Stop NPC AI loop
|
|
1210
|
+
*/
|
|
1211
|
+
stopAI(): void;
|
|
1212
|
+
/**
|
|
1213
|
+
* Main AI tick
|
|
1214
|
+
*/
|
|
1215
|
+
private tick;
|
|
1216
|
+
/**
|
|
1217
|
+
* Reactive decision: immediate response to stimuli
|
|
1218
|
+
*/
|
|
1219
|
+
private reactiveDecision;
|
|
1220
|
+
/**
|
|
1221
|
+
* Goal-driven decision: plan towards objectives
|
|
1222
|
+
*/
|
|
1223
|
+
private goalDrivenDecision;
|
|
1224
|
+
/**
|
|
1225
|
+
* Learning decision: adapt behavior from experience
|
|
1226
|
+
*/
|
|
1227
|
+
private learningDecision;
|
|
1228
|
+
/**
|
|
1229
|
+
* Hybrid decision: combination of reactive and goal-driven
|
|
1230
|
+
*/
|
|
1231
|
+
private hybridDecision;
|
|
1232
|
+
/**
|
|
1233
|
+
* Build world state for planning
|
|
1234
|
+
*/
|
|
1235
|
+
private buildWorldState;
|
|
1236
|
+
/**
|
|
1237
|
+
* Update learning model from interactions
|
|
1238
|
+
*/
|
|
1239
|
+
private updateLearningModel;
|
|
1240
|
+
/**
|
|
1241
|
+
* Calculate immediate reward
|
|
1242
|
+
*/
|
|
1243
|
+
private calculateReward;
|
|
1244
|
+
/**
|
|
1245
|
+
* Set NPC position
|
|
1246
|
+
*/
|
|
1247
|
+
setPosition(position: [number, number, number]): void;
|
|
1248
|
+
/**
|
|
1249
|
+
* Update perception (nearby entities, visible targets)
|
|
1250
|
+
*/
|
|
1251
|
+
updatePerception(nearbyEntities: string[], visibleEntities: string[]): void;
|
|
1252
|
+
/**
|
|
1253
|
+
* Add dialogue to conversation history
|
|
1254
|
+
*/
|
|
1255
|
+
speak(text: string): void;
|
|
1256
|
+
/**
|
|
1257
|
+
* Receive dialogue from another entity
|
|
1258
|
+
*/
|
|
1259
|
+
hear(speaker: string, text: string): void;
|
|
1260
|
+
/**
|
|
1261
|
+
* Get current NPC context
|
|
1262
|
+
*/
|
|
1263
|
+
getContext(): Readonly<NPCContext>;
|
|
1264
|
+
/**
|
|
1265
|
+
* Dispose and cleanup
|
|
1266
|
+
*/
|
|
1267
|
+
dispose(): void;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* HoloScript+ @ai_driven trait factory
|
|
1271
|
+
*/
|
|
1272
|
+
declare function createAIDriverTrait(config: AIDriverConfig): AIDriverTrait;
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* @holoscript/core Material Trait
|
|
1276
|
+
*
|
|
1277
|
+
* Enables advanced material and shader properties for photorealistic rendering
|
|
1278
|
+
* Supports PBR (Physically Based Rendering) workflows
|
|
1279
|
+
*/
|
|
1280
|
+
type MaterialType = 'pbr' | 'standard' | 'unlit' | 'transparent' | 'custom';
|
|
1281
|
+
type TextureChannel = 'baseColor' | 'normalMap' | 'roughnessMap' | 'metallicMap' | 'ambientOcclusionMap' | 'emissionMap' | 'heightMap';
|
|
1282
|
+
/**
|
|
1283
|
+
* Texture map configuration
|
|
1284
|
+
*/
|
|
1285
|
+
interface TextureMap {
|
|
1286
|
+
/** Texture path or URL */
|
|
1287
|
+
path: string;
|
|
1288
|
+
/** Channel this texture maps to */
|
|
1289
|
+
channel: TextureChannel;
|
|
1290
|
+
/** UV scale (tiling) */
|
|
1291
|
+
scale?: {
|
|
1292
|
+
x: number;
|
|
1293
|
+
y: number;
|
|
1294
|
+
};
|
|
1295
|
+
/** UV offset */
|
|
1296
|
+
offset?: {
|
|
1297
|
+
x: number;
|
|
1298
|
+
y: number;
|
|
1299
|
+
};
|
|
1300
|
+
/** Texture filtering: linear, nearest, anisotropic */
|
|
1301
|
+
filter?: 'linear' | 'nearest' | 'anisotropic';
|
|
1302
|
+
/** Anisotropic level (1-16) */
|
|
1303
|
+
anisotropy?: number;
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* PBR Material properties
|
|
1307
|
+
*/
|
|
1308
|
+
interface PBRMaterial {
|
|
1309
|
+
/** Base color in linear space [0-1] */
|
|
1310
|
+
baseColor: {
|
|
1311
|
+
r: number;
|
|
1312
|
+
g: number;
|
|
1313
|
+
b: number;
|
|
1314
|
+
a?: number;
|
|
1315
|
+
};
|
|
1316
|
+
/** Metallic value 0-1 */
|
|
1317
|
+
metallic: number;
|
|
1318
|
+
/** Roughness value 0-1 */
|
|
1319
|
+
roughness: number;
|
|
1320
|
+
/** Ambient occlusion 0-1 */
|
|
1321
|
+
ambientOcclusion?: number;
|
|
1322
|
+
/** Emission color and intensity */
|
|
1323
|
+
emission?: {
|
|
1324
|
+
color: {
|
|
1325
|
+
r: number;
|
|
1326
|
+
g: number;
|
|
1327
|
+
b: number;
|
|
1328
|
+
};
|
|
1329
|
+
intensity: number;
|
|
1330
|
+
};
|
|
1331
|
+
/** Normal map strength */
|
|
1332
|
+
normalStrength?: number;
|
|
1333
|
+
/** Parallax/height map strength */
|
|
1334
|
+
parallaxHeight?: number;
|
|
1335
|
+
/** Index of refraction for transmission */
|
|
1336
|
+
ior?: number;
|
|
1337
|
+
/** Transmission amount for transparent materials */
|
|
1338
|
+
transmission?: number;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Material configuration
|
|
1342
|
+
*/
|
|
1343
|
+
interface MaterialConfig {
|
|
1344
|
+
/** Material type */
|
|
1345
|
+
type: MaterialType;
|
|
1346
|
+
/** Material name for reuse */
|
|
1347
|
+
name?: string;
|
|
1348
|
+
/** PBR properties (for PBR materials) */
|
|
1349
|
+
pbr?: PBRMaterial;
|
|
1350
|
+
/** Texture maps */
|
|
1351
|
+
textures?: TextureMap[];
|
|
1352
|
+
/** Double-sided rendering */
|
|
1353
|
+
doubleSided?: boolean;
|
|
1354
|
+
/** Blend mode for transparency */
|
|
1355
|
+
blendMode?: 'opaque' | 'blend' | 'additive' | 'multiply';
|
|
1356
|
+
/** Custom shader code/reference */
|
|
1357
|
+
customShader?: {
|
|
1358
|
+
vertex?: string;
|
|
1359
|
+
fragment?: string;
|
|
1360
|
+
shaderLanguage?: 'glsl' | 'hlsl' | 'shadergraph';
|
|
1361
|
+
};
|
|
1362
|
+
/** GPU memory optimization hints */
|
|
1363
|
+
optimization?: {
|
|
1364
|
+
/** Stream textures if needed */
|
|
1365
|
+
streamTextures?: boolean;
|
|
1366
|
+
/** Compress textures */
|
|
1367
|
+
compression?: 'none' | 'dxt' | 'astc' | 'basis';
|
|
1368
|
+
/** Instance this material */
|
|
1369
|
+
instanced?: boolean;
|
|
1370
|
+
/** LOD bias for texture streaming */
|
|
1371
|
+
lodBias?: number;
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* MaterialTrait - Enables photorealistic material rendering
|
|
1376
|
+
*/
|
|
1377
|
+
declare class MaterialTrait {
|
|
1378
|
+
private material;
|
|
1379
|
+
private textureCache;
|
|
1380
|
+
constructor(config: MaterialConfig);
|
|
1381
|
+
/**
|
|
1382
|
+
* Get material properties
|
|
1383
|
+
*/
|
|
1384
|
+
getMaterial(): MaterialConfig;
|
|
1385
|
+
/**
|
|
1386
|
+
* Update material property
|
|
1387
|
+
*/
|
|
1388
|
+
setProperty<K extends keyof MaterialConfig>(key: K, value: MaterialConfig[K]): void;
|
|
1389
|
+
/**
|
|
1390
|
+
* Get PBR properties
|
|
1391
|
+
*/
|
|
1392
|
+
getPBRProperties(): PBRMaterial | undefined;
|
|
1393
|
+
/**
|
|
1394
|
+
* Update PBR material
|
|
1395
|
+
*/
|
|
1396
|
+
updatePBR(pbr: Partial<PBRMaterial>): void;
|
|
1397
|
+
/**
|
|
1398
|
+
* Add texture map
|
|
1399
|
+
*/
|
|
1400
|
+
addTexture(texture: TextureMap): void;
|
|
1401
|
+
/**
|
|
1402
|
+
* Get all textures
|
|
1403
|
+
*/
|
|
1404
|
+
getTextures(): TextureMap[];
|
|
1405
|
+
/**
|
|
1406
|
+
* Clear texture cache (for memory optimization)
|
|
1407
|
+
*/
|
|
1408
|
+
clearTextureCache(): void;
|
|
1409
|
+
/**
|
|
1410
|
+
* Get shader code if custom
|
|
1411
|
+
*/
|
|
1412
|
+
getCustomShader(): {
|
|
1413
|
+
vertex?: string;
|
|
1414
|
+
fragment?: string;
|
|
1415
|
+
shaderLanguage?: "glsl" | "hlsl" | "shadergraph";
|
|
1416
|
+
} | undefined;
|
|
1417
|
+
/**
|
|
1418
|
+
* Set custom shader
|
|
1419
|
+
*/
|
|
1420
|
+
setCustomShader(shader: MaterialConfig['customShader']): void;
|
|
1421
|
+
/**
|
|
1422
|
+
* Get optimization hints
|
|
1423
|
+
*/
|
|
1424
|
+
getOptimization(): MaterialConfig['optimization'];
|
|
1425
|
+
/**
|
|
1426
|
+
* Enable/disable texture streaming
|
|
1427
|
+
*/
|
|
1428
|
+
setTextureStreaming(enabled: boolean): void;
|
|
1429
|
+
/**
|
|
1430
|
+
* Set texture compression
|
|
1431
|
+
*/
|
|
1432
|
+
setCompression(compression: 'none' | 'dxt' | 'astc' | 'basis'): void;
|
|
1433
|
+
/**
|
|
1434
|
+
* Enable material instancing for performance
|
|
1435
|
+
*/
|
|
1436
|
+
setInstanced(instanced: boolean): void;
|
|
1437
|
+
/**
|
|
1438
|
+
* Dispose and cleanup
|
|
1439
|
+
*/
|
|
1440
|
+
dispose(): void;
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* HoloScript+ @material trait factory
|
|
1444
|
+
*/
|
|
1445
|
+
declare function createMaterialTrait(config: MaterialConfig): MaterialTrait;
|
|
1446
|
+
/**
|
|
1447
|
+
* Preset materials for common use cases
|
|
1448
|
+
*/
|
|
1449
|
+
declare const MATERIAL_PRESETS: {
|
|
1450
|
+
/** Shiny metal */
|
|
1451
|
+
chrome: () => MaterialConfig;
|
|
1452
|
+
/** Rough plastic */
|
|
1453
|
+
plastic: () => MaterialConfig;
|
|
1454
|
+
/** Wood texture */
|
|
1455
|
+
wood: () => MaterialConfig;
|
|
1456
|
+
/** Glass */
|
|
1457
|
+
glass: () => MaterialConfig;
|
|
1458
|
+
/** Emissive (glowing) */
|
|
1459
|
+
emissive: () => MaterialConfig;
|
|
1460
|
+
/** Skin material */
|
|
1461
|
+
skin: () => MaterialConfig;
|
|
1462
|
+
};
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* @holoscript/core Lighting Trait
|
|
1466
|
+
*
|
|
1467
|
+
* Enables dynamic lighting with support for multiple light types,
|
|
1468
|
+
* shadows, and global illumination
|
|
1469
|
+
*/
|
|
1470
|
+
type LightType = 'directional' | 'point' | 'spot' | 'area' | 'probe';
|
|
1471
|
+
type ShadowType = 'none' | 'hard' | 'soft' | 'raytraced';
|
|
1472
|
+
/**
|
|
1473
|
+
* Color definition
|
|
1474
|
+
*/
|
|
1475
|
+
interface Color {
|
|
1476
|
+
r: number;
|
|
1477
|
+
g: number;
|
|
1478
|
+
b: number;
|
|
1479
|
+
a?: number;
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Vector3 position or direction
|
|
1483
|
+
*/
|
|
1484
|
+
interface Vector3 {
|
|
1485
|
+
x: number;
|
|
1486
|
+
y: number;
|
|
1487
|
+
z: number;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Shadow configuration
|
|
1491
|
+
*/
|
|
1492
|
+
interface ShadowConfig {
|
|
1493
|
+
/** Shadow type */
|
|
1494
|
+
type: ShadowType;
|
|
1495
|
+
/** Shadow map resolution */
|
|
1496
|
+
resolution?: number;
|
|
1497
|
+
/** Shadow bias to prevent artifacts */
|
|
1498
|
+
bias?: number;
|
|
1499
|
+
/** Softness/blur radius */
|
|
1500
|
+
softness?: number;
|
|
1501
|
+
/** Max shadow distance */
|
|
1502
|
+
maxDistance?: number;
|
|
1503
|
+
/** Cascade levels for directional lights */
|
|
1504
|
+
cascades?: number;
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Light source definition
|
|
1508
|
+
*/
|
|
1509
|
+
interface LightSource {
|
|
1510
|
+
/** Light type */
|
|
1511
|
+
type: LightType;
|
|
1512
|
+
/** Light name */
|
|
1513
|
+
name?: string;
|
|
1514
|
+
/** Position in world space */
|
|
1515
|
+
position?: Vector3;
|
|
1516
|
+
/** Direction (for directional/spot) */
|
|
1517
|
+
direction?: Vector3;
|
|
1518
|
+
/** Color */
|
|
1519
|
+
color: Color;
|
|
1520
|
+
/** Intensity/brightness 0-1+ */
|
|
1521
|
+
intensity: number;
|
|
1522
|
+
/** Attenuation range (point/spot) */
|
|
1523
|
+
range?: number;
|
|
1524
|
+
/** Spot angle in degrees */
|
|
1525
|
+
spotAngle?: number;
|
|
1526
|
+
/** Inner spot angle */
|
|
1527
|
+
innerSpotAngle?: number;
|
|
1528
|
+
/** Shadow configuration */
|
|
1529
|
+
shadow?: ShadowConfig;
|
|
1530
|
+
/** Light cookie/projection */
|
|
1531
|
+
cookie?: string;
|
|
1532
|
+
/** Enable volumetric fog interaction */
|
|
1533
|
+
volumetric?: boolean;
|
|
1534
|
+
/** Light priority for batching */
|
|
1535
|
+
priority?: number;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Global illumination configuration
|
|
1539
|
+
*/
|
|
1540
|
+
interface GlobalIlluminationConfig {
|
|
1541
|
+
/** Enable global illumination */
|
|
1542
|
+
enabled: boolean;
|
|
1543
|
+
/** Intensity multiplier */
|
|
1544
|
+
intensity?: number;
|
|
1545
|
+
/** Sky color for ambient light */
|
|
1546
|
+
skyColor?: Color;
|
|
1547
|
+
/** Sky intensity */
|
|
1548
|
+
skyIntensity?: number;
|
|
1549
|
+
/** Ground color for ambient light */
|
|
1550
|
+
groundColor?: Color;
|
|
1551
|
+
/** Ground intensity */
|
|
1552
|
+
groundIntensity?: number;
|
|
1553
|
+
/** Use light probes */
|
|
1554
|
+
probes?: boolean;
|
|
1555
|
+
/** Indirect diffuse intensity */
|
|
1556
|
+
indirectDiffuse?: number;
|
|
1557
|
+
/** Indirect specular intensity */
|
|
1558
|
+
indirectSpecular?: number;
|
|
1559
|
+
/** Ambient occlusion intensity */
|
|
1560
|
+
aoIntensity?: number;
|
|
1561
|
+
/** Use screen-space AO */
|
|
1562
|
+
screenSpaceAO?: boolean;
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* LightingTrait - Manages dynamic lighting and illumination
|
|
1566
|
+
*/
|
|
1567
|
+
declare class LightingTrait {
|
|
1568
|
+
private lights;
|
|
1569
|
+
private globalIllumination;
|
|
1570
|
+
private lightIdCounter;
|
|
1571
|
+
constructor(config?: GlobalIlluminationConfig);
|
|
1572
|
+
/**
|
|
1573
|
+
* Add a light to the scene
|
|
1574
|
+
*/
|
|
1575
|
+
addLight(light: LightSource): string;
|
|
1576
|
+
/**
|
|
1577
|
+
* Get light by ID
|
|
1578
|
+
*/
|
|
1579
|
+
getLight(id: string): LightSource | undefined;
|
|
1580
|
+
/**
|
|
1581
|
+
* Get all lights
|
|
1582
|
+
*/
|
|
1583
|
+
getLights(): LightSource[];
|
|
1584
|
+
/**
|
|
1585
|
+
* Get lights by type
|
|
1586
|
+
*/
|
|
1587
|
+
getLightsByType(type: LightType): LightSource[];
|
|
1588
|
+
/**
|
|
1589
|
+
* Update light properties
|
|
1590
|
+
*/
|
|
1591
|
+
updateLight(id: string, updates: Partial<LightSource>): boolean;
|
|
1592
|
+
/**
|
|
1593
|
+
* Remove light
|
|
1594
|
+
*/
|
|
1595
|
+
removeLight(id: string): boolean;
|
|
1596
|
+
/**
|
|
1597
|
+
* Clear all lights
|
|
1598
|
+
*/
|
|
1599
|
+
clearLights(): void;
|
|
1600
|
+
/**
|
|
1601
|
+
* Get global illumination config
|
|
1602
|
+
*/
|
|
1603
|
+
getGlobalIllumination(): GlobalIlluminationConfig;
|
|
1604
|
+
/**
|
|
1605
|
+
* Update global illumination
|
|
1606
|
+
*/
|
|
1607
|
+
updateGlobalIllumination(updates: Partial<GlobalIlluminationConfig>): void;
|
|
1608
|
+
/**
|
|
1609
|
+
* Enable/disable GI
|
|
1610
|
+
*/
|
|
1611
|
+
setGIEnabled(enabled: boolean): void;
|
|
1612
|
+
/**
|
|
1613
|
+
* Set ambient light colors (skybox mode)
|
|
1614
|
+
*/
|
|
1615
|
+
setAmbientLight(skyColor: Color, groundColor: Color, intensity?: number): void;
|
|
1616
|
+
/**
|
|
1617
|
+
* Enable/disable screen-space ambient occlusion
|
|
1618
|
+
*/
|
|
1619
|
+
setScreenSpaceAO(enabled: boolean, intensity?: number): void;
|
|
1620
|
+
/**
|
|
1621
|
+
* Create directional light (sun)
|
|
1622
|
+
*/
|
|
1623
|
+
createDirectionalLight(direction: Vector3, color: Color, intensity?: number, castShadows?: boolean): string;
|
|
1624
|
+
/**
|
|
1625
|
+
* Create point light
|
|
1626
|
+
*/
|
|
1627
|
+
createPointLight(position: Vector3, color: Color, intensity: number, range: number, castShadows?: boolean): string;
|
|
1628
|
+
/**
|
|
1629
|
+
* Create spot light
|
|
1630
|
+
*/
|
|
1631
|
+
createSpotLight(position: Vector3, direction: Vector3, color: Color, intensity: number, range: number, spotAngle?: number, castShadows?: boolean): string;
|
|
1632
|
+
/**
|
|
1633
|
+
* Create area light for soft lighting
|
|
1634
|
+
*/
|
|
1635
|
+
createAreaLight(position: Vector3, color: Color, intensity: number, width: number, height: number): string;
|
|
1636
|
+
/**
|
|
1637
|
+
* Get shadow-casting lights
|
|
1638
|
+
*/
|
|
1639
|
+
getShadowCastingLights(): LightSource[];
|
|
1640
|
+
/**
|
|
1641
|
+
* Get light count by type
|
|
1642
|
+
*/
|
|
1643
|
+
getLightCount(): {
|
|
1644
|
+
[key in LightType]: number;
|
|
1645
|
+
};
|
|
1646
|
+
/**
|
|
1647
|
+
* Estimate light impact for performance optimization
|
|
1648
|
+
*/
|
|
1649
|
+
getPerformanceImpact(): {
|
|
1650
|
+
totalLights: number;
|
|
1651
|
+
shadowCasters: number;
|
|
1652
|
+
estimatedGPUCost: 'low' | 'medium' | 'high';
|
|
1653
|
+
};
|
|
1654
|
+
/**
|
|
1655
|
+
* Get scene complexity info
|
|
1656
|
+
*/
|
|
1657
|
+
getSceneInfo(): string;
|
|
1658
|
+
/**
|
|
1659
|
+
* Dispose and cleanup
|
|
1660
|
+
*/
|
|
1661
|
+
dispose(): void;
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* HoloScript+ @lighting trait factory
|
|
1665
|
+
*/
|
|
1666
|
+
declare function createLightingTrait(config?: GlobalIlluminationConfig): LightingTrait;
|
|
1667
|
+
/**
|
|
1668
|
+
* Preset lighting configurations
|
|
1669
|
+
*/
|
|
1670
|
+
declare const LIGHTING_PRESETS: {
|
|
1671
|
+
/** Neutral studio lighting */
|
|
1672
|
+
studio: () => GlobalIlluminationConfig;
|
|
1673
|
+
/** Bright outdoor lighting */
|
|
1674
|
+
outdoor: () => GlobalIlluminationConfig;
|
|
1675
|
+
/** Dim interior lighting */
|
|
1676
|
+
interior: () => GlobalIlluminationConfig;
|
|
1677
|
+
/** Night scene */
|
|
1678
|
+
night: () => GlobalIlluminationConfig;
|
|
1679
|
+
/** Sunset/golden hour */
|
|
1680
|
+
sunset: () => GlobalIlluminationConfig;
|
|
1681
|
+
};
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* @holoscript/core Rendering Trait
|
|
1685
|
+
*
|
|
1686
|
+
* Enables GPU optimization directives, level of detail management,
|
|
1687
|
+
* and rendering performance tuning
|
|
1688
|
+
*/
|
|
1689
|
+
type CullingMode = 'none' | 'back' | 'front' | 'both';
|
|
1690
|
+
type LodStrategy = 'automatic' | 'manual' | 'disabled';
|
|
1691
|
+
type GPUResourceTier = 'low' | 'medium' | 'high' | 'ultra';
|
|
1692
|
+
/**
|
|
1693
|
+
* Level of Detail configuration
|
|
1694
|
+
*/
|
|
1695
|
+
interface LODLevel {
|
|
1696
|
+
/** LOD level (0 = highest detail) */
|
|
1697
|
+
level: number;
|
|
1698
|
+
/** Screen-relative size threshold for this LOD */
|
|
1699
|
+
screenRelativeSize: number;
|
|
1700
|
+
/** Polygon reduction ratio (0-1) */
|
|
1701
|
+
polygonReduction?: number;
|
|
1702
|
+
/** Disable features at this LOD */
|
|
1703
|
+
disabledFeatures?: ('shadows' | 'normals' | 'specular' | 'animation')[];
|
|
1704
|
+
/** Texture resolution multiplier (0.25 = 1/4 resolution) */
|
|
1705
|
+
textureScale?: number;
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Culling configuration
|
|
1709
|
+
*/
|
|
1710
|
+
interface CullingConfig {
|
|
1711
|
+
/** Face culling mode */
|
|
1712
|
+
mode: CullingMode;
|
|
1713
|
+
/** Frustum culling */
|
|
1714
|
+
frustum?: boolean;
|
|
1715
|
+
/** Occlusion culling */
|
|
1716
|
+
occlusion?: boolean;
|
|
1717
|
+
/** Occlusion query distance in units */
|
|
1718
|
+
occlusionDistance?: number;
|
|
1719
|
+
/** Hierarchical Z-buffer culling */
|
|
1720
|
+
hierarchicalZ?: boolean;
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Batching configuration
|
|
1724
|
+
*/
|
|
1725
|
+
interface BatchingConfig {
|
|
1726
|
+
/** Static batching (for non-moving objects) */
|
|
1727
|
+
static?: boolean;
|
|
1728
|
+
/** Dynamic batching */
|
|
1729
|
+
dynamic?: boolean;
|
|
1730
|
+
/** Max batch size in vertices */
|
|
1731
|
+
maxBatchSize?: number;
|
|
1732
|
+
/** GPU instancing */
|
|
1733
|
+
instancing?: boolean;
|
|
1734
|
+
/** Instancing buffer size */
|
|
1735
|
+
maxInstanceCount?: number;
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Texture optimization
|
|
1739
|
+
*/
|
|
1740
|
+
interface TextureOptimization {
|
|
1741
|
+
/** Enable texture streaming */
|
|
1742
|
+
streaming?: boolean;
|
|
1743
|
+
/** Streaming budget in MB */
|
|
1744
|
+
streamingBudget?: number;
|
|
1745
|
+
/** Virtual texture paging */
|
|
1746
|
+
virtualTexturing?: boolean;
|
|
1747
|
+
/** Texture compression */
|
|
1748
|
+
compression?: 'none' | 'dxt' | 'astc' | 'basis' | 'auto';
|
|
1749
|
+
/** Mipmap generation */
|
|
1750
|
+
mipmaps?: boolean;
|
|
1751
|
+
/** Max texture resolution */
|
|
1752
|
+
maxResolution?: 256 | 512 | 1024 | 2048 | 4096;
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Shader optimization
|
|
1756
|
+
*/
|
|
1757
|
+
interface ShaderOptimization {
|
|
1758
|
+
/** Shader LOD bias */
|
|
1759
|
+
lodBias?: number;
|
|
1760
|
+
/** Use simplified shaders for distant objects */
|
|
1761
|
+
simplifiedShaders?: boolean;
|
|
1762
|
+
/** Compile shader variants for performance */
|
|
1763
|
+
variants?: {
|
|
1764
|
+
[key: string]: {
|
|
1765
|
+
enabled: boolean;
|
|
1766
|
+
cost?: 'low' | 'medium' | 'high';
|
|
1767
|
+
};
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Rendering optimization hints
|
|
1772
|
+
*/
|
|
1773
|
+
interface RenderingOptimization {
|
|
1774
|
+
/** LOD strategy */
|
|
1775
|
+
lodStrategy?: LodStrategy;
|
|
1776
|
+
/** LOD levels */
|
|
1777
|
+
lodLevels?: LODLevel[];
|
|
1778
|
+
/** Culling configuration */
|
|
1779
|
+
culling?: CullingConfig;
|
|
1780
|
+
/** Batching configuration */
|
|
1781
|
+
batching?: BatchingConfig;
|
|
1782
|
+
/** Texture optimization */
|
|
1783
|
+
textures?: TextureOptimization;
|
|
1784
|
+
/** Shader optimization */
|
|
1785
|
+
shaders?: ShaderOptimization;
|
|
1786
|
+
/** Target GPU tier */
|
|
1787
|
+
targetGPUTier?: GPUResourceTier;
|
|
1788
|
+
/** Fixed time-step rendering (for VR/AR) */
|
|
1789
|
+
fixedTimestep?: number;
|
|
1790
|
+
/** Enable adaptive quality */
|
|
1791
|
+
adaptiveQuality?: boolean;
|
|
1792
|
+
/** Target frame rate */
|
|
1793
|
+
targetFrameRate?: number;
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* RenderingTrait - Manages GPU optimization and rendering performance
|
|
1797
|
+
*/
|
|
1798
|
+
declare class RenderingTrait {
|
|
1799
|
+
private optimization;
|
|
1800
|
+
constructor(config?: RenderingOptimization);
|
|
1801
|
+
/**
|
|
1802
|
+
* Get rendering optimization config
|
|
1803
|
+
*/
|
|
1804
|
+
getOptimization(): RenderingOptimization;
|
|
1805
|
+
/**
|
|
1806
|
+
* Update rendering configuration
|
|
1807
|
+
*/
|
|
1808
|
+
updateOptimization(updates: Partial<RenderingOptimization>): void;
|
|
1809
|
+
/**
|
|
1810
|
+
* Setup LOD levels (3 levels is typical)
|
|
1811
|
+
*/
|
|
1812
|
+
setupLODLevels(strategy?: LodStrategy): void;
|
|
1813
|
+
/**
|
|
1814
|
+
* Get LOD levels
|
|
1815
|
+
*/
|
|
1816
|
+
getLODLevels(): LODLevel[];
|
|
1817
|
+
/**
|
|
1818
|
+
* Configure culling
|
|
1819
|
+
*/
|
|
1820
|
+
setCulling(config: Partial<CullingConfig>): void;
|
|
1821
|
+
/**
|
|
1822
|
+
* Enable frustum culling
|
|
1823
|
+
*/
|
|
1824
|
+
setFrustumCulling(enabled: boolean): void;
|
|
1825
|
+
/**
|
|
1826
|
+
* Enable occlusion culling
|
|
1827
|
+
*/
|
|
1828
|
+
setOcclusionCulling(enabled: boolean, distance?: number): void;
|
|
1829
|
+
/**
|
|
1830
|
+
* Configure batching
|
|
1831
|
+
*/
|
|
1832
|
+
setBatching(config: Partial<BatchingConfig>): void;
|
|
1833
|
+
/**
|
|
1834
|
+
* Enable GPU instancing
|
|
1835
|
+
*/
|
|
1836
|
+
setInstancing(enabled: boolean, maxInstances?: number): void;
|
|
1837
|
+
/**
|
|
1838
|
+
* Configure texture optimization
|
|
1839
|
+
*/
|
|
1840
|
+
setTextureOptimization(config: Partial<TextureOptimization>): void;
|
|
1841
|
+
/**
|
|
1842
|
+
* Enable texture streaming
|
|
1843
|
+
*/
|
|
1844
|
+
setTextureStreaming(enabled: boolean, budgetMB?: number): void;
|
|
1845
|
+
/**
|
|
1846
|
+
* Set texture compression
|
|
1847
|
+
*/
|
|
1848
|
+
setTextureCompression(compression: 'none' | 'dxt' | 'astc' | 'basis' | 'auto'): void;
|
|
1849
|
+
/**
|
|
1850
|
+
* Set max texture resolution
|
|
1851
|
+
*/
|
|
1852
|
+
setMaxTextureResolution(resolution: 256 | 512 | 1024 | 2048 | 4096): void;
|
|
1853
|
+
/**
|
|
1854
|
+
* Configure shader optimization
|
|
1855
|
+
*/
|
|
1856
|
+
setShaderOptimization(config: Partial<ShaderOptimization>): void;
|
|
1857
|
+
/**
|
|
1858
|
+
* Set target GPU tier
|
|
1859
|
+
*/
|
|
1860
|
+
setTargetGPUTier(tier: GPUResourceTier): void;
|
|
1861
|
+
/**
|
|
1862
|
+
* Enable adaptive quality (adjust based on frame rate)
|
|
1863
|
+
*/
|
|
1864
|
+
setAdaptiveQuality(enabled: boolean, targetFrameRate?: number): void;
|
|
1865
|
+
/**
|
|
1866
|
+
* Set fixed timestep for VR/AR
|
|
1867
|
+
*/
|
|
1868
|
+
setFixedTimestep(timestep: number): void;
|
|
1869
|
+
/**
|
|
1870
|
+
* Get rendering preset for quality level
|
|
1871
|
+
*/
|
|
1872
|
+
getPresetForQuality(quality: 'low' | 'medium' | 'high' | 'ultra'): RenderingOptimization;
|
|
1873
|
+
/**
|
|
1874
|
+
* Apply quality preset
|
|
1875
|
+
*/
|
|
1876
|
+
applyQualityPreset(quality: 'low' | 'medium' | 'high' | 'ultra'): void;
|
|
1877
|
+
/**
|
|
1878
|
+
* Estimate GPU memory usage
|
|
1879
|
+
*/
|
|
1880
|
+
estimateGPUMemory(): {
|
|
1881
|
+
textureMemory: number;
|
|
1882
|
+
vertexBuffers: number;
|
|
1883
|
+
estimatedTotal: number;
|
|
1884
|
+
};
|
|
1885
|
+
/**
|
|
1886
|
+
* Get rendering statistics/info
|
|
1887
|
+
*/
|
|
1888
|
+
getInfo(): string;
|
|
1889
|
+
/**
|
|
1890
|
+
* Optimize for VR/AR (fixed timestep, fast culling)
|
|
1891
|
+
*/
|
|
1892
|
+
optimizeForVRAR(targetFPS?: number): void;
|
|
1893
|
+
/**
|
|
1894
|
+
* Optimize for mobile (lower resources)
|
|
1895
|
+
*/
|
|
1896
|
+
optimizeForMobile(): void;
|
|
1897
|
+
/**
|
|
1898
|
+
* Optimize for desktop (higher resources)
|
|
1899
|
+
*/
|
|
1900
|
+
optimizeForDesktop(): void;
|
|
1901
|
+
/**
|
|
1902
|
+
* Dispose and cleanup
|
|
1903
|
+
*/
|
|
1904
|
+
dispose(): void;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* HoloScript+ @rendering trait factory
|
|
1908
|
+
*/
|
|
1909
|
+
declare function createRenderingTrait(config?: RenderingOptimization): RenderingTrait;
|
|
1910
|
+
|
|
1911
|
+
/**
|
|
1912
|
+
* @holoscript/core Performance Telemetry
|
|
1913
|
+
*
|
|
1914
|
+
* Real-time performance monitoring, profiling, and metrics collection
|
|
1915
|
+
* Exports metrics to analytics platforms and provides performance budgets
|
|
1916
|
+
*/
|
|
1917
|
+
type MetricType = 'gauge' | 'counter' | 'histogram' | 'timer';
|
|
1918
|
+
type SeverityLevel = 'info' | 'warning' | 'critical';
|
|
1919
|
+
/**
|
|
1920
|
+
* Performance metric
|
|
1921
|
+
*/
|
|
1922
|
+
interface Metric {
|
|
1923
|
+
name: string;
|
|
1924
|
+
type: MetricType;
|
|
1925
|
+
value: number;
|
|
1926
|
+
timestamp: number;
|
|
1927
|
+
tags?: Record<string, string>;
|
|
1928
|
+
unit?: string;
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Performance budget threshold
|
|
1932
|
+
*/
|
|
1933
|
+
interface PerformanceBudget {
|
|
1934
|
+
metricName: string;
|
|
1935
|
+
maxValue: number;
|
|
1936
|
+
severity: SeverityLevel;
|
|
1937
|
+
enabled: boolean;
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Frame timing information
|
|
1941
|
+
*/
|
|
1942
|
+
interface FrameTiming {
|
|
1943
|
+
frameNumber: number;
|
|
1944
|
+
fps: number;
|
|
1945
|
+
frameDuration: number;
|
|
1946
|
+
cpuTime: number;
|
|
1947
|
+
gpuTime: number;
|
|
1948
|
+
renderTime: number;
|
|
1949
|
+
logicTime: number;
|
|
1950
|
+
timestamp: number;
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Memory snapshot
|
|
1954
|
+
*/
|
|
1955
|
+
interface MemorySnapshot {
|
|
1956
|
+
usedJSHeapSize: number;
|
|
1957
|
+
totalJSHeapSize: number;
|
|
1958
|
+
jsHeapSizeLimit: number;
|
|
1959
|
+
objectCount: number;
|
|
1960
|
+
gcEventsSinceLastSnapshot: number;
|
|
1961
|
+
timestamp: number;
|
|
1962
|
+
}
|
|
1963
|
+
/**
|
|
1964
|
+
* Performance analytics exporter
|
|
1965
|
+
*/
|
|
1966
|
+
interface AnalyticsExporter {
|
|
1967
|
+
export(metrics: Metric[]): Promise<void>;
|
|
1968
|
+
flush(): Promise<void>;
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* PerformanceTelemetry - Monitor and analyze runtime performance
|
|
1972
|
+
*/
|
|
1973
|
+
declare class PerformanceTelemetry {
|
|
1974
|
+
private metrics;
|
|
1975
|
+
private budgets;
|
|
1976
|
+
private frameTimings;
|
|
1977
|
+
private memorySnapshots;
|
|
1978
|
+
private exporters;
|
|
1979
|
+
private frameCounter;
|
|
1980
|
+
private lastFrameTime;
|
|
1981
|
+
private frameTimes;
|
|
1982
|
+
private maxFrameHistory;
|
|
1983
|
+
private monitoringEnabled;
|
|
1984
|
+
private exportInterval;
|
|
1985
|
+
private exportIntervalMs;
|
|
1986
|
+
constructor();
|
|
1987
|
+
/**
|
|
1988
|
+
* Initialize default performance budgets
|
|
1989
|
+
*/
|
|
1990
|
+
private initializeDefaultBudgets;
|
|
1991
|
+
/**
|
|
1992
|
+
* Start performance monitoring
|
|
1993
|
+
*/
|
|
1994
|
+
startMonitoring(): void;
|
|
1995
|
+
/**
|
|
1996
|
+
* Stop performance monitoring
|
|
1997
|
+
*/
|
|
1998
|
+
stopMonitoring(): void;
|
|
1999
|
+
/**
|
|
2000
|
+
* Record frame timing
|
|
2001
|
+
*/
|
|
2002
|
+
recordFrame(cpuTime: number, gpuTime: number, renderTime: number, logicTime: number): void;
|
|
2003
|
+
/**
|
|
2004
|
+
* Record custom metric
|
|
2005
|
+
*/
|
|
2006
|
+
recordMetric(metric: Omit<Metric, 'timestamp'> & {
|
|
2007
|
+
timestamp?: number;
|
|
2008
|
+
}): void;
|
|
2009
|
+
/**
|
|
2010
|
+
* Record memory snapshot
|
|
2011
|
+
*/
|
|
2012
|
+
recordMemorySnapshot(): void;
|
|
2013
|
+
/**
|
|
2014
|
+
* Check frame metrics against budgets
|
|
2015
|
+
*/
|
|
2016
|
+
private checkBudgets;
|
|
2017
|
+
/**
|
|
2018
|
+
* Emit budget violation warning
|
|
2019
|
+
*/
|
|
2020
|
+
private emitBudgetViolation;
|
|
2021
|
+
/**
|
|
2022
|
+
* Set or update performance budget
|
|
2023
|
+
*/
|
|
2024
|
+
setBudget(budget: PerformanceBudget): void;
|
|
2025
|
+
/**
|
|
2026
|
+
* Get average FPS over recent frames
|
|
2027
|
+
*/
|
|
2028
|
+
getAverageFPS(): number;
|
|
2029
|
+
/**
|
|
2030
|
+
* Get memory usage stats
|
|
2031
|
+
*/
|
|
2032
|
+
getMemoryStats(): {
|
|
2033
|
+
used: number;
|
|
2034
|
+
total: number;
|
|
2035
|
+
limit: number;
|
|
2036
|
+
percentage: number;
|
|
2037
|
+
};
|
|
2038
|
+
/**
|
|
2039
|
+
* Get recent frame timings
|
|
2040
|
+
*/
|
|
2041
|
+
getRecentFrameTimings(count?: number): FrameTiming[];
|
|
2042
|
+
/**
|
|
2043
|
+
* Add analytics exporter
|
|
2044
|
+
*/
|
|
2045
|
+
addExporter(exporter: AnalyticsExporter): void;
|
|
2046
|
+
/**
|
|
2047
|
+
* Export all metrics to registered exporters
|
|
2048
|
+
*/
|
|
2049
|
+
exportMetrics(): Promise<void>;
|
|
2050
|
+
/**
|
|
2051
|
+
* Generate performance report
|
|
2052
|
+
*/
|
|
2053
|
+
generateReport(): string;
|
|
2054
|
+
/**
|
|
2055
|
+
* Dispose and cleanup
|
|
2056
|
+
*/
|
|
2057
|
+
dispose(): void;
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* Get or create telemetry instance
|
|
2061
|
+
*/
|
|
2062
|
+
declare function getPerformanceTelemetry(): PerformanceTelemetry;
|
|
2063
|
+
|
|
2064
|
+
/**
|
|
2065
|
+
* Hololand Graphics Pipeline Service
|
|
2066
|
+
*
|
|
2067
|
+
* Core service for managing graphics rendering pipeline in Hololand.
|
|
2068
|
+
* Integrates HoloScript graphics traits with Hololand's rendering backend.
|
|
2069
|
+
*
|
|
2070
|
+
* Responsibilities:
|
|
2071
|
+
* - Material management and asset pipeline
|
|
2072
|
+
* - Light management and shadow mapping
|
|
2073
|
+
* - GPU memory optimization
|
|
2074
|
+
* - Performance monitoring and profiling
|
|
2075
|
+
* - Cross-platform optimization (mobile/VR/desktop)
|
|
2076
|
+
*/
|
|
2077
|
+
|
|
2078
|
+
interface GPUMemoryEstimate {
|
|
2079
|
+
textureMemory: number;
|
|
2080
|
+
geometryMemory: number;
|
|
2081
|
+
bufferMemory: number;
|
|
2082
|
+
estimatedTotal: number;
|
|
2083
|
+
budget: number;
|
|
2084
|
+
utilization: number;
|
|
2085
|
+
}
|
|
2086
|
+
interface MaterialAsset {
|
|
2087
|
+
id: string;
|
|
2088
|
+
name: string;
|
|
2089
|
+
material: MaterialTrait;
|
|
2090
|
+
shaders: ShaderProgram[];
|
|
2091
|
+
textures: TextureAsset[];
|
|
2092
|
+
instances: number;
|
|
2093
|
+
gpuMemory: number;
|
|
2094
|
+
lastUsed: number;
|
|
2095
|
+
}
|
|
2096
|
+
interface TextureAsset {
|
|
2097
|
+
id: string;
|
|
2098
|
+
path: string;
|
|
2099
|
+
format: 'RGBA8' | 'RGB565' | 'BC1' | 'BC3' | 'ASTC' | 'PVRTC';
|
|
2100
|
+
width: number;
|
|
2101
|
+
height: number;
|
|
2102
|
+
mipLevels: number;
|
|
2103
|
+
gpuMemory: number;
|
|
2104
|
+
loaded: boolean;
|
|
2105
|
+
}
|
|
2106
|
+
interface ShaderProgram {
|
|
2107
|
+
id: string;
|
|
2108
|
+
name: string;
|
|
2109
|
+
vertexShader: string;
|
|
2110
|
+
fragmentShader: string;
|
|
2111
|
+
uniforms: Record<string, string>;
|
|
2112
|
+
compiled: boolean;
|
|
2113
|
+
compilationTime: number;
|
|
2114
|
+
}
|
|
2115
|
+
interface PerformanceMetrics {
|
|
2116
|
+
drawCalls: number;
|
|
2117
|
+
trianglesRendered: number;
|
|
2118
|
+
gpuFrameTime: number;
|
|
2119
|
+
cpuFrameTime: number;
|
|
2120
|
+
fps: number;
|
|
2121
|
+
gpuMemoryUsed: number;
|
|
2122
|
+
textureBinds: number;
|
|
2123
|
+
shaderSwitches: number;
|
|
2124
|
+
batchCount: number;
|
|
2125
|
+
}
|
|
2126
|
+
type Platform = 'mobile' | 'vr' | 'desktop';
|
|
2127
|
+
interface PlatformConfig {
|
|
2128
|
+
platform: Platform;
|
|
2129
|
+
maxGPUMemory: number;
|
|
2130
|
+
maxDrawCalls: number;
|
|
2131
|
+
maxTextureResolution: number;
|
|
2132
|
+
targetFPS: number;
|
|
2133
|
+
shadowQuality: 'none' | 'low' | 'medium' | 'high';
|
|
2134
|
+
textureCompression: 'none' | 'dxt' | 'astc' | 'basis';
|
|
2135
|
+
instancingEnabled: boolean;
|
|
2136
|
+
maxLights: number;
|
|
2137
|
+
maxShadowCasters: number;
|
|
2138
|
+
}
|
|
2139
|
+
declare class HololandGraphicsPipelineService {
|
|
2140
|
+
private materialCache;
|
|
2141
|
+
private textureCache;
|
|
2142
|
+
private shaderCache;
|
|
2143
|
+
private platformConfig;
|
|
2144
|
+
private metrics;
|
|
2145
|
+
private memoryUsed;
|
|
2146
|
+
constructor(platform?: Platform);
|
|
2147
|
+
/**
|
|
2148
|
+
* Initialize graphics pipeline with configuration
|
|
2149
|
+
*/
|
|
2150
|
+
initialize(config: GraphicsConfiguration): void;
|
|
2151
|
+
/**
|
|
2152
|
+
* Initialize materials from configuration
|
|
2153
|
+
*/
|
|
2154
|
+
private initializeMaterials;
|
|
2155
|
+
/**
|
|
2156
|
+
* Initialize lighting from configuration
|
|
2157
|
+
*/
|
|
2158
|
+
private initializeLighting;
|
|
2159
|
+
/**
|
|
2160
|
+
* Initialize rendering from configuration
|
|
2161
|
+
*/
|
|
2162
|
+
private initializeRendering;
|
|
2163
|
+
/**
|
|
2164
|
+
* Create material asset from configuration
|
|
2165
|
+
*/
|
|
2166
|
+
private createMaterialAsset;
|
|
2167
|
+
/**
|
|
2168
|
+
* Generate shaders from material configuration
|
|
2169
|
+
*/
|
|
2170
|
+
private generateShaders;
|
|
2171
|
+
/**
|
|
2172
|
+
* Generate PBR shader program
|
|
2173
|
+
*/
|
|
2174
|
+
private generatePBRShader;
|
|
2175
|
+
/**
|
|
2176
|
+
* Load textures from configuration
|
|
2177
|
+
*/
|
|
2178
|
+
private loadTexturesFromConfig;
|
|
2179
|
+
/**
|
|
2180
|
+
* Select appropriate texture format based on compression type
|
|
2181
|
+
*/
|
|
2182
|
+
private selectTextureFormat;
|
|
2183
|
+
/**
|
|
2184
|
+
* Estimate texture memory usage
|
|
2185
|
+
*/
|
|
2186
|
+
private estimateTextureMemory;
|
|
2187
|
+
/**
|
|
2188
|
+
* Estimate material GPU memory
|
|
2189
|
+
*/
|
|
2190
|
+
private estimateMaterialMemory;
|
|
2191
|
+
/**
|
|
2192
|
+
* Compile shader program
|
|
2193
|
+
*/
|
|
2194
|
+
private compileShader;
|
|
2195
|
+
/**
|
|
2196
|
+
* Load texture into GPU memory
|
|
2197
|
+
*/
|
|
2198
|
+
private loadTexture;
|
|
2199
|
+
/**
|
|
2200
|
+
* Setup shadow mapping
|
|
2201
|
+
*/
|
|
2202
|
+
private setupShadowMapping;
|
|
2203
|
+
/**
|
|
2204
|
+
* Get shadow map resolution for quality level
|
|
2205
|
+
*/
|
|
2206
|
+
/**
|
|
2207
|
+
* Setup global illumination
|
|
2208
|
+
*/
|
|
2209
|
+
private setupGlobalIllumination;
|
|
2210
|
+
/**
|
|
2211
|
+
* Apply quality preset
|
|
2212
|
+
*/
|
|
2213
|
+
private applyQualityPreset;
|
|
2214
|
+
/**
|
|
2215
|
+
* Enable LOD system
|
|
2216
|
+
*/
|
|
2217
|
+
private enableLOD;
|
|
2218
|
+
/**
|
|
2219
|
+
* Enable culling
|
|
2220
|
+
*/
|
|
2221
|
+
private enableCulling;
|
|
2222
|
+
/**
|
|
2223
|
+
* Get platform-specific configuration
|
|
2224
|
+
*/
|
|
2225
|
+
private getPlatformConfig;
|
|
2226
|
+
/**
|
|
2227
|
+
* Initialize performance metrics
|
|
2228
|
+
*/
|
|
2229
|
+
private initializeMetrics;
|
|
2230
|
+
/**
|
|
2231
|
+
* Get current GPU memory estimate
|
|
2232
|
+
*/
|
|
2233
|
+
getGPUMemoryEstimate(): GPUMemoryEstimate;
|
|
2234
|
+
/**
|
|
2235
|
+
* Get performance metrics
|
|
2236
|
+
*/
|
|
2237
|
+
getPerformanceMetrics(): PerformanceMetrics;
|
|
2238
|
+
/**
|
|
2239
|
+
* Set memory budget
|
|
2240
|
+
*/
|
|
2241
|
+
setMemoryBudget(budget: number): void;
|
|
2242
|
+
/**
|
|
2243
|
+
* Optimize for specific platform
|
|
2244
|
+
*/
|
|
2245
|
+
optimizePlatform(platform: Platform): void;
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
/**
|
|
2249
|
+
* Platform Performance Optimization System
|
|
2250
|
+
*
|
|
2251
|
+
* Provides adaptive quality and performance tuning for:
|
|
2252
|
+
* - Mobile devices (battery/bandwidth constrained)
|
|
2253
|
+
* - VR/AR platforms (latency-critical, 90 FPS required)
|
|
2254
|
+
* - Desktop (quality-focused, high resolution)
|
|
2255
|
+
*
|
|
2256
|
+
* Features:
|
|
2257
|
+
* - Automatic quality adjustment based on device
|
|
2258
|
+
* - Performance profiling and analysis
|
|
2259
|
+
* - Bottleneck detection and mitigation
|
|
2260
|
+
* - Cross-platform benchmark testing
|
|
2261
|
+
*/
|
|
2262
|
+
interface DeviceInfo {
|
|
2263
|
+
platform: 'mobile' | 'vr' | 'desktop';
|
|
2264
|
+
gpuVendor: string;
|
|
2265
|
+
gpuModel: string;
|
|
2266
|
+
gpuMemory: number;
|
|
2267
|
+
cpuCores: number;
|
|
2268
|
+
ramTotal: number;
|
|
2269
|
+
screenResolution: {
|
|
2270
|
+
width: number;
|
|
2271
|
+
height: number;
|
|
2272
|
+
};
|
|
2273
|
+
refreshRate: number;
|
|
2274
|
+
isLowPowerMode?: boolean;
|
|
2275
|
+
}
|
|
2276
|
+
interface DeviceCapabilities {
|
|
2277
|
+
maxTextureResolution: number;
|
|
2278
|
+
supportsCompression: boolean;
|
|
2279
|
+
compressionFormats: string[];
|
|
2280
|
+
maxSimultaneousLights: number;
|
|
2281
|
+
shadowsSupported: boolean;
|
|
2282
|
+
computeShaderSupported: boolean;
|
|
2283
|
+
rayTracingSupported: boolean;
|
|
2284
|
+
estimatedMemory: number;
|
|
2285
|
+
}
|
|
2286
|
+
interface PerformanceProfile {
|
|
2287
|
+
device: DeviceInfo;
|
|
2288
|
+
capabilities: DeviceCapabilities;
|
|
2289
|
+
targetFPS: number;
|
|
2290
|
+
qualityLevel: 'low' | 'medium' | 'high' | 'ultra';
|
|
2291
|
+
adaptiveQuality: boolean;
|
|
2292
|
+
fpsTarget: number;
|
|
2293
|
+
fpsMin: number;
|
|
2294
|
+
cpuBudget: number;
|
|
2295
|
+
gpuBudget: number;
|
|
2296
|
+
}
|
|
2297
|
+
interface BenchmarkResult {
|
|
2298
|
+
testName: string;
|
|
2299
|
+
platform: string;
|
|
2300
|
+
fps: number;
|
|
2301
|
+
gpuFrameTime: number;
|
|
2302
|
+
cpuFrameTime: number;
|
|
2303
|
+
gpuMemoryUsed: number;
|
|
2304
|
+
trianglesPerSecond: number;
|
|
2305
|
+
drawCallsPerSecond: number;
|
|
2306
|
+
qualityLevel: string;
|
|
2307
|
+
passed: boolean;
|
|
2308
|
+
}
|
|
2309
|
+
interface AdaptiveQualitySettings {
|
|
2310
|
+
enabled: boolean;
|
|
2311
|
+
checkInterval: number;
|
|
2312
|
+
fpsDeltaThreshold: number;
|
|
2313
|
+
memoryThreshold: number;
|
|
2314
|
+
temperatureThreshold?: number;
|
|
2315
|
+
}
|
|
2316
|
+
type CompressionFormat = 'none' | 'lz4' | 'zstd' | 'bc1' | 'bc7' | 'astc' | 'etc2' | 'pvrtc';
|
|
2317
|
+
interface PerformanceRecommendation {
|
|
2318
|
+
category: 'texture' | 'geometry' | 'shader' | 'memory' | 'rendering';
|
|
2319
|
+
priority: 'low' | 'medium' | 'high' | 'critical';
|
|
2320
|
+
recommendation: string;
|
|
2321
|
+
expectedImprovement: number;
|
|
2322
|
+
estimatedCost: string;
|
|
2323
|
+
}
|
|
2324
|
+
declare class PlatformPerformanceOptimizer {
|
|
2325
|
+
private deviceInfo;
|
|
2326
|
+
private capabilities;
|
|
2327
|
+
private profile;
|
|
2328
|
+
private adaptiveSettings;
|
|
2329
|
+
private currentFPS;
|
|
2330
|
+
private frameHistory;
|
|
2331
|
+
private lastAdaptTime;
|
|
2332
|
+
constructor(device: DeviceInfo);
|
|
2333
|
+
/**
|
|
2334
|
+
* Detect device capabilities
|
|
2335
|
+
*/
|
|
2336
|
+
private detectCapabilities;
|
|
2337
|
+
/**
|
|
2338
|
+
* Create performance profile for device
|
|
2339
|
+
*/
|
|
2340
|
+
private createProfile;
|
|
2341
|
+
/**
|
|
2342
|
+
* Get adaptive quality settings for platform
|
|
2343
|
+
*/
|
|
2344
|
+
private getAdaptiveSettings;
|
|
2345
|
+
/**
|
|
2346
|
+
* Optimize for device - returns recommended rendering settings
|
|
2347
|
+
*/
|
|
2348
|
+
optimizeForDevice(): any;
|
|
2349
|
+
/**
|
|
2350
|
+
* Select best compression format for platform
|
|
2351
|
+
*/
|
|
2352
|
+
private selectCompression;
|
|
2353
|
+
/**
|
|
2354
|
+
* Update frame metrics for adaptive quality
|
|
2355
|
+
*/
|
|
2356
|
+
updateFrameMetrics(fps: number, gpuMemoryUsed: number, gpuFrameTime: number): void;
|
|
2357
|
+
/**
|
|
2358
|
+
* Check and adapt quality settings
|
|
2359
|
+
*/
|
|
2360
|
+
private checkAndAdapt;
|
|
2361
|
+
/**
|
|
2362
|
+
* Degrade quality for better performance
|
|
2363
|
+
*/
|
|
2364
|
+
private degradeQuality;
|
|
2365
|
+
/**
|
|
2366
|
+
* Improve quality for better visuals
|
|
2367
|
+
*/
|
|
2368
|
+
private improveQuality;
|
|
2369
|
+
/**
|
|
2370
|
+
* Get average FPS from history
|
|
2371
|
+
*/
|
|
2372
|
+
private getAverageFPS;
|
|
2373
|
+
/**
|
|
2374
|
+
* Run performance benchmark
|
|
2375
|
+
*/
|
|
2376
|
+
runBenchmark(name: string, renderFunc: (iterations: number) => Promise<{
|
|
2377
|
+
fps: number;
|
|
2378
|
+
gpuTime: number;
|
|
2379
|
+
cpuTime: number;
|
|
2380
|
+
triangles: number;
|
|
2381
|
+
drawCalls: number;
|
|
2382
|
+
}>): Promise<BenchmarkResult>;
|
|
2383
|
+
/**
|
|
2384
|
+
* Get benchmark iterations based on platform
|
|
2385
|
+
*/
|
|
2386
|
+
private getBenchmarkIterations;
|
|
2387
|
+
/**
|
|
2388
|
+
* Get current performance profile
|
|
2389
|
+
*/
|
|
2390
|
+
getProfile(): PerformanceProfile;
|
|
2391
|
+
/**
|
|
2392
|
+
* Get optimization recommendations
|
|
2393
|
+
*/
|
|
2394
|
+
getRecommendations(): string[];
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
/**
|
|
2398
|
+
* @holoscript/core Logger
|
|
2399
|
+
*
|
|
2400
|
+
* Simple pluggable logger for HoloScript
|
|
2401
|
+
*/
|
|
2402
|
+
interface HoloScriptLogger {
|
|
2403
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
2404
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
2405
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
2406
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
2407
|
+
}
|
|
2408
|
+
declare class NoOpLogger implements HoloScriptLogger {
|
|
2409
|
+
debug(): void;
|
|
2410
|
+
info(): void;
|
|
2411
|
+
warn(): void;
|
|
2412
|
+
error(): void;
|
|
2413
|
+
}
|
|
2414
|
+
declare class ConsoleLogger implements HoloScriptLogger {
|
|
2415
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
2416
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
2417
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
2418
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
2419
|
+
}
|
|
2420
|
+
declare function setHoloScriptLogger(logger: HoloScriptLogger): void;
|
|
2421
|
+
declare function enableConsoleLogging(): void;
|
|
2422
|
+
declare function resetLogger(): void;
|
|
2423
|
+
declare const logger: HoloScriptLogger;
|
|
2424
|
+
|
|
2425
|
+
/**
|
|
2426
|
+
* @holoscript/core
|
|
2427
|
+
*
|
|
2428
|
+
* HoloScript+ - VR language with declarative syntax, state management, and VR interactions.
|
|
2429
|
+
* Enhanced version of HoloScript with:
|
|
2430
|
+
* - VR interaction traits (@grabbable, @throwable, @hoverable, etc.)
|
|
2431
|
+
* - Reactive state management (@state { ... })
|
|
2432
|
+
* - Control flow (@for, @if directives)
|
|
2433
|
+
* - TypeScript companion imports
|
|
2434
|
+
* - Expression interpolation ${...}
|
|
2435
|
+
*
|
|
2436
|
+
* Fully backward compatible with original HoloScript syntax.
|
|
2437
|
+
*
|
|
2438
|
+
* @example
|
|
2439
|
+
* ```typescript
|
|
2440
|
+
* import { HoloScriptPlusParser, HoloScriptPlusRuntime } from '@holoscript/core';
|
|
2441
|
+
*
|
|
2442
|
+
* const parser = new HoloScriptPlusParser();
|
|
2443
|
+
* const result = parser.parse(`
|
|
2444
|
+
* orb#myOrb {
|
|
2445
|
+
* position: [0, 0, 0]
|
|
2446
|
+
* @grabbable(snap_to_hand: true)
|
|
2447
|
+
* @throwable(bounce: true)
|
|
2448
|
+
* }
|
|
2449
|
+
* `);
|
|
2450
|
+
*
|
|
2451
|
+
* const runtime = new HoloScriptPlusRuntime(result.ast);
|
|
2452
|
+
* await runtime.mount(document.body);
|
|
2453
|
+
* ```
|
|
2454
|
+
*
|
|
2455
|
+
* @packageDocumentation
|
|
2456
|
+
*/
|
|
2457
|
+
|
|
2458
|
+
declare const HOLOSCRIPT_VERSION = "1.0.0-alpha.1";
|
|
2459
|
+
declare const HOLOSCRIPT_SUPPORTED_PLATFORMS: readonly ["WebXR", "Oculus Quest", "HTC Vive", "Valve Index", "Apple Vision Pro", "Windows Mixed Reality"];
|
|
2460
|
+
declare const HOLOSCRIPT_VOICE_COMMANDS: readonly ["create orb [name]", "summon function [name]", "connect [from] to [to]", "execute [function]", "debug program", "visualize [data]", "gate [condition]", "stream [source] through [transformations]", "create button [name]", "add textinput [name]", "create panel [name]", "add slider [name]"];
|
|
2461
|
+
declare const HOLOSCRIPT_GESTURES: readonly ["pinch - create object", "swipe - connect objects", "rotate - modify properties", "grab - select object", "spread - expand view", "fist - execute action"];
|
|
2462
|
+
declare const HOLOSCRIPT_DEMO_SCRIPTS: {
|
|
2463
|
+
readonly helloWorld: "orb greeting {\n message: \"Hello, HoloScript World!\"\n color: \"#00ffff\"\n glow: true\n}\n\nfunction displayGreeting() {\n show greeting\n}";
|
|
2464
|
+
readonly aiAgent: "orb agentCore {\n personality: \"helpful\"\n capabilities: [\"conversation\", \"problem_solving\", \"learning\"]\n energy: 100\n}\n\nfunction processQuery(query: string): string {\n analyze query\n generate response\n return response\n}";
|
|
2465
|
+
readonly neuralNetwork: "orb inputLayer { neurons: 784 }\norb hiddenLayer { neurons: 128 }\norb outputLayer { neurons: 10 }\n\nconnect inputLayer to hiddenLayer as \"weights\"\nconnect hiddenLayer to outputLayer as \"weights\"\n\nfunction trainNetwork(data: array): object {\n forward_pass data\n calculate_loss\n backward_pass\n update_weights\n return metrics\n}";
|
|
2466
|
+
readonly loginForm: "button loginBtn {\n text: \"Login\"\n x: 100\n y: 150\n width: 200\n height: 40\n onClick: handleLogin\n}\n\ntextinput usernameInput {\n placeholder: \"Username\"\n x: 100\n y: 50\n width: 200\n height: 36\n}\n\ntextinput passwordInput {\n placeholder: \"Password\"\n x: 100\n y: 100\n width: 200\n height: 36\n}";
|
|
2467
|
+
readonly dashboard: "panel sidebar {\n x: 0\n y: 0\n width: 200\n height: 600\n backgroundColor: \"#2c3e50\"\n}\n\ntext title {\n content: \"Dashboard\"\n x: 220\n y: 20\n fontSize: 24\n color: \"#34495e\"\n}\n\nbutton refreshBtn {\n text: \"Refresh Data\"\n x: 220\n y: 60\n onClick: refreshData\n}";
|
|
2468
|
+
};
|
|
2469
|
+
/**
|
|
2470
|
+
* Create a pre-configured HoloScript environment
|
|
2471
|
+
*/
|
|
2472
|
+
declare function createHoloScriptEnvironment(): {
|
|
2473
|
+
parser: HoloScriptParser;
|
|
2474
|
+
runtime: HoloScriptRuntime;
|
|
2475
|
+
version: string;
|
|
2476
|
+
};
|
|
2477
|
+
/**
|
|
2478
|
+
* Check if the current environment supports VR/XR
|
|
2479
|
+
*/
|
|
2480
|
+
declare function isHoloScriptSupported(): boolean;
|
|
2481
|
+
|
|
2482
|
+
export { type AIDriverConfig, AIDriverTrait, ASTNode, type AdaptiveQualitySettings, type AnalyticsExporter, type BatchingConfig, type BehaviorNode, type BehaviorState, BehaviorTreeRunner, type BenchmarkResult, type CompressionFormat, ConsoleLogger, type CullingConfig, type CullingMode, type DecisionMode, type DeviceCapabilities, type DeviceInfo, type FrameTiming, GOAPPlanner, type GPUMemoryEstimate, type GPUResourceTier, GestureData, type GlobalIlluminationConfig, type GraphicsConfiguration, HOLOSCRIPT_DEMO_SCRIPTS, HOLOSCRIPT_GESTURES, HOLOSCRIPT_SUPPORTED_PLATFORMS, HOLOSCRIPT_VERSION, HOLOSCRIPT_VOICE_COMMANDS, HoloScript2DParser, type HoloScriptLogger, HoloScriptParser, HoloScriptPlusParser$1 as HoloScriptPlusParser, HoloScriptPlusRuntimeImpl, HoloScriptRuntime, HoloScriptPlusParser as HoloScriptTraitAnnotationParser, HololandGraphicsPipelineService, LIGHTING_PRESETS, type LODLevel, type LightSource, type LightType, LightingTrait, type LightingTraitAnnotation, type LodStrategy, MATERIAL_PRESETS, type MaterialAsset, type MaterialConfig, MaterialTrait, type MaterialTraitAnnotation, type MaterialType, type MemorySnapshot, type Metric, type MetricType, type NPCContext, type NPCGoal, NoOpLogger, type PBRMaterial, type PerformanceBudget, type PerformanceMetrics, type PerformanceProfile, type PerformanceRecommendation, PerformanceTelemetry, type PlatformConfig, PlatformPerformanceOptimizer, Position2D, ReactiveState, type RenderingOptimization, RenderingTrait, type RenderingTraitAnnotation, type SeverityLevel, type ShaderOptimization, type ShaderProgram, type ShadowConfig, type ShadowType, SpatialPosition, type TextureAsset, type TextureChannel, type TextureMap, type TextureOptimization, UI2DNode, VRTraitRegistry, VoiceCommand$1 as VoiceCommand, type VoiceInputConfig, type VoiceInputEvent, type VoiceInputMode, VoiceInputTrait, type VoiceRecognitionResult, bind, computed, createAIDriverTrait, createHoloScriptEnvironment, createLightingTrait, createMaterialTrait, createParser, createRenderingTrait, createState, createVoiceInputTrait, effect, enableConsoleLogging, getPerformanceTelemetry, isHoloScriptSupported, logger, parse as parseHoloScriptPlus, reactive, resetLogger, setHoloScriptLogger };
|