xrblocks 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -30
- package/build/addons/ai/AudioCaptureProcessorCode.d.ts +1 -0
- package/build/addons/ai/AudioCaptureProcessorCode.js +27 -0
- package/build/addons/ai/GeminiManager.d.ts +11 -4
- package/build/addons/ai/GeminiManager.js +80 -34
- package/build/addons/objects/SimpleDecalGeometry.js +9 -5
- package/build/addons/simulator/instructions/CustomInstruction.js +8 -9
- package/build/addons/simulator/instructions/HandsInstructions.js +17 -10
- package/build/addons/simulator/instructions/NavigationInstructions.js +10 -9
- package/build/addons/simulator/instructions/SimulatorInstructions.js +17 -18
- package/build/addons/simulator/instructions/SimulatorInstructionsCard.js +69 -75
- package/build/addons/simulator/instructions/SimulatorInstructionsEvents.js +4 -1
- package/build/addons/simulator/instructions/UserInstructions.js +18 -15
- package/build/addons/simulator/ui/EnterXRButton.js +17 -17
- package/build/addons/simulator/ui/GeminiLiveApiKeyInput.js +45 -39
- package/build/addons/simulator/ui/HandPosePanel.js +20 -10
- package/build/addons/simulator/ui/MicButton.js +23 -18
- package/build/addons/simulator/ui/ModeIndicator.js +17 -17
- package/build/addons/ui/TextBillboard.js +1 -1
- package/build/addons/utils/Palette.js +3 -15
- package/build/addons/virtualkeyboard/Keyboard.js +24 -21
- package/build/addons/volumes/VolumetricCloud.glsl.js +1 -1
- package/build/addons/volumes/VolumetricCloud.js +8 -5
- package/build/agent/Agent.d.ts +25 -1
- package/build/agent/SkyboxAgent.d.ts +119 -3
- package/build/agent/Tool.d.ts +21 -5
- package/build/agent/index.d.ts +1 -0
- package/build/agent/tools/GenerateSkyboxTool.d.ts +3 -3
- package/build/agent/tools/GetWeatherTool.d.ts +7 -8
- package/build/ai/AI.d.ts +1 -1
- package/build/ai/Gemini.d.ts +1 -4
- package/build/camera/XRDeviceCamera.d.ts +1 -1
- package/build/core/Core.d.ts +4 -1
- package/build/core/Options.d.ts +17 -0
- package/build/core/components/ScreenshotSynthesizer.d.ts +6 -4
- package/build/core/components/XRTransition.d.ts +1 -1
- package/build/depth/Depth.d.ts +5 -3
- package/build/depth/DepthMesh.d.ts +8 -1
- package/build/depth/DepthTextures.d.ts +6 -4
- package/build/depth/occlusion/OcclusionPass.d.ts +6 -5
- package/build/input/Hands.d.ts +1 -1
- package/build/input/Input.d.ts +1 -1
- package/build/input/gestures/GestureEvents.d.ts +23 -0
- package/build/input/gestures/GestureRecognition.d.ts +43 -0
- package/build/input/gestures/GestureRecognitionOptions.d.ts +43 -0
- package/build/input/gestures/GestureTypes.d.ts +16 -0
- package/build/input/gestures/providers/HeuristicGestureDetectors.d.ts +2 -0
- package/build/simulator/Simulator.d.ts +2 -0
- package/build/simulator/SimulatorControls.d.ts +1 -1
- package/build/simulator/SimulatorOptions.d.ts +1 -0
- package/build/simulator/controlModes/SimulatorControlMode.d.ts +1 -1
- package/build/simulator/handPoses/HandPoseJoints.d.ts +2 -2
- package/build/simulator/userActions/PinchOnButtonAction.d.ts +2 -2
- package/build/simulator/userActions/WalkTowardsPanelAction.d.ts +1 -1
- package/build/singletons.d.ts +2 -2
- package/build/sound/AudioListener.d.ts +16 -1
- package/build/sound/AudioPlayer.d.ts +21 -2
- package/build/sound/CoreSound.d.ts +26 -1
- package/build/stereo/utils.d.ts +1 -1
- package/build/ui/components/IconButton.d.ts +6 -2
- package/build/ui/components/MaterialSymbolsView.d.ts +1 -1
- package/build/ui/components/ScrollingTroikaTextView.d.ts +1 -1
- package/build/ui/components/TextButton.d.ts +0 -1
- package/build/ui/interaction/ModelViewer.d.ts +6 -2
- package/build/utils/ModelLoader.d.ts +1 -1
- package/build/utils/SparkRendererHolder.d.ts +5 -0
- package/build/utils/Types.d.ts +2 -2
- package/build/video/VideoStream.d.ts +1 -1
- package/build/world/World.d.ts +1 -1
- package/build/world/objects/ObjectDetector.d.ts +1 -1
- package/build/world/planes/PlaneDetector.d.ts +1 -1
- package/build/xrblocks.d.ts +3 -0
- package/build/xrblocks.js +7268 -5884
- package/build/xrblocks.js.map +1 -1
- package/build/xrblocks.min.js +1 -1
- package/build/xrblocks.min.js.map +1 -1
- package/package.json +14 -9
|
@@ -10,23 +10,11 @@ class XRPalette {
|
|
|
10
10
|
*/
|
|
11
11
|
constructor() {
|
|
12
12
|
this.fullGColors_ = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
0xE37400,
|
|
16
|
-
0x0D652D,
|
|
17
|
-
0x4285F4,
|
|
18
|
-
0xEA4335,
|
|
19
|
-
0xFBBC04,
|
|
20
|
-
0x34A853,
|
|
21
|
-
0xD2E3FC,
|
|
22
|
-
0xFAD2CF,
|
|
23
|
-
0xFEEFC3,
|
|
24
|
-
0xCEEAD6,
|
|
25
|
-
0xF1F3F4,
|
|
26
|
-
0x9AA0A6,
|
|
13
|
+
0x174ea6, 0xa50e0e, 0xe37400, 0x0d652d, 0x4285f4, 0xea4335, 0xfbbc04,
|
|
14
|
+
0x34a853, 0xd2e3fc, 0xfad2cf, 0xfeefc3, 0xceead6, 0xf1f3f4, 0x9aa0a6,
|
|
27
15
|
0x202124,
|
|
28
16
|
];
|
|
29
|
-
this.liteGColors_ = [
|
|
17
|
+
this.liteGColors_ = [0xea4335, 0x4285f4, 0x34ab53, 0xfbbc04];
|
|
30
18
|
this.lastRandomColor_ = null;
|
|
31
19
|
if (XRPalette.instance) {
|
|
32
20
|
return XRPalette.instance;
|
|
@@ -88,12 +88,13 @@ class Keyboard extends xb.Script {
|
|
|
88
88
|
this.onEnterPressed = null;
|
|
89
89
|
this.onTextChanged = null;
|
|
90
90
|
this.keyRows = [];
|
|
91
|
-
this.subspace =
|
|
92
|
-
|
|
91
|
+
this.subspace = new xb.SpatialPanel({
|
|
92
|
+
useDefaultPosition: false,
|
|
93
|
+
showEdge: false,
|
|
94
|
+
});
|
|
93
95
|
this.subspace.isRoot = true;
|
|
94
96
|
this.add(this.subspace);
|
|
95
|
-
this.mainPanel =
|
|
96
|
-
this.subspace.add(new xb.Panel({ backgroundColor: KEYBOARD_COLOR }));
|
|
97
|
+
this.mainPanel = this.subspace.add(new xb.Panel({ backgroundColor: KEYBOARD_COLOR }));
|
|
97
98
|
this.mainGrid = new xb.Grid();
|
|
98
99
|
this.mainPanel.add(this.mainGrid);
|
|
99
100
|
this.mainGrid.addRow({ weight: ROW_TOP_PADDING });
|
|
@@ -135,16 +136,16 @@ class Keyboard extends xb.Script {
|
|
|
135
136
|
if (textKeys.length === 0) {
|
|
136
137
|
let currentColumnWeight = 0;
|
|
137
138
|
row.addCol({ weight: 0.145 });
|
|
138
|
-
specialKeys.forEach(key => {
|
|
139
|
+
specialKeys.forEach((key) => {
|
|
139
140
|
currentColumnWeight += key.weight || COLUMN_WEIGHT;
|
|
140
141
|
});
|
|
141
142
|
const missingWeight = TARGET_COLUMN_WEIGHT - currentColumnWeight;
|
|
142
143
|
if (missingWeight > 1) {
|
|
143
|
-
const leftKeys = specialKeys.filter(key => key.position === 'left');
|
|
144
|
-
const rightKeys = specialKeys.filter(key => key.position === 'right');
|
|
145
|
-
const weightForLeftKeys =
|
|
146
|
-
const weightForRightKeys = (missingWeight * 2 / 3
|
|
147
|
-
specialKeys.forEach(key => {
|
|
144
|
+
const leftKeys = specialKeys.filter((key) => key.position === 'left');
|
|
145
|
+
const rightKeys = specialKeys.filter((key) => key.position === 'right');
|
|
146
|
+
const weightForLeftKeys = missingWeight / 3 / (leftKeys.length || 1);
|
|
147
|
+
const weightForRightKeys = (missingWeight * 2) / 3 / (rightKeys.length || 1);
|
|
148
|
+
specialKeys.forEach((key) => {
|
|
148
149
|
let finalWeight = key.weight || COLUMN_WEIGHT;
|
|
149
150
|
if (key.position === 'left') {
|
|
150
151
|
finalWeight += weightForLeftKeys;
|
|
@@ -156,14 +157,14 @@ class Keyboard extends xb.Script {
|
|
|
156
157
|
});
|
|
157
158
|
}
|
|
158
159
|
else {
|
|
159
|
-
specialKeys.forEach(key => this.createSpecialButtons(row, key));
|
|
160
|
+
specialKeys.forEach((key) => this.createSpecialButtons(row, key));
|
|
160
161
|
}
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
|
-
const leftSpecialKeys = specialKeys.filter(key => key.position === 'left');
|
|
164
|
-
const rightSpecialKeys = specialKeys.filter(key => key.position === 'right');
|
|
164
|
+
const leftSpecialKeys = specialKeys.filter((key) => key.position === 'left');
|
|
165
|
+
const rightSpecialKeys = specialKeys.filter((key) => key.position === 'right');
|
|
165
166
|
let remainingWeight = TARGET_COLUMN_WEIGHT;
|
|
166
|
-
leftSpecialKeys.forEach(key => {
|
|
167
|
+
leftSpecialKeys.forEach((key) => {
|
|
167
168
|
this.createSpecialButtons(row, key);
|
|
168
169
|
remainingWeight -= key.weight;
|
|
169
170
|
});
|
|
@@ -172,7 +173,7 @@ class Keyboard extends xb.Script {
|
|
|
172
173
|
this.createTextButtons(row, key, shiftKey);
|
|
173
174
|
remainingWeight -= COLUMN_WEIGHT;
|
|
174
175
|
});
|
|
175
|
-
rightSpecialKeys.forEach(key => {
|
|
176
|
+
rightSpecialKeys.forEach((key) => {
|
|
176
177
|
const finalWeight = (key.weight || COLUMN_WEIGHT) + remainingWeight;
|
|
177
178
|
this.createSpecialButtons(row, { ...key, weight: finalWeight });
|
|
178
179
|
});
|
|
@@ -186,7 +187,7 @@ class Keyboard extends xb.Script {
|
|
|
186
187
|
fontSize: FONT_SIZE,
|
|
187
188
|
backgroundColor: DEFAULT_KEY_COLOR,
|
|
188
189
|
originalKey: key,
|
|
189
|
-
shiftKey: shiftKey
|
|
190
|
+
shiftKey: shiftKey,
|
|
190
191
|
});
|
|
191
192
|
keyPanel.add(textButton);
|
|
192
193
|
this.textButtons.push(textButton);
|
|
@@ -248,17 +249,19 @@ class Keyboard extends xb.Script {
|
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
251
|
refreshKeyboard() {
|
|
251
|
-
this.textButtons.forEach(button => {
|
|
252
|
+
this.textButtons.forEach((button) => {
|
|
252
253
|
const isLetter = button.originalKey.length === 1 && button.originalKey.match(/[a-z]/i);
|
|
253
254
|
let newText;
|
|
254
255
|
const produceUpper = this.isShifted !== this.isCapsLockOn;
|
|
255
256
|
if (isLetter) {
|
|
256
|
-
newText = produceUpper
|
|
257
|
-
button.originalKey.
|
|
257
|
+
newText = produceUpper
|
|
258
|
+
? button.originalKey.toUpperCase()
|
|
259
|
+
: button.originalKey.toLowerCase();
|
|
258
260
|
}
|
|
259
261
|
else {
|
|
260
|
-
newText = this.isShifted
|
|
261
|
-
button.originalKey
|
|
262
|
+
newText = this.isShifted
|
|
263
|
+
? button.shiftKey || button.originalKey
|
|
264
|
+
: button.originalKey;
|
|
262
265
|
}
|
|
263
266
|
button.setText(newText);
|
|
264
267
|
});
|
|
@@ -43,15 +43,18 @@ class VolumetricCloud extends THREE.Object3D {
|
|
|
43
43
|
for (let x = 0; x < this.size; x++) {
|
|
44
44
|
// Calculates the density based on the distance from the center.
|
|
45
45
|
const d = 1.0 -
|
|
46
|
-
vector
|
|
46
|
+
vector
|
|
47
|
+
.set(x, y, z)
|
|
47
48
|
.subScalar(this.size / 2)
|
|
48
49
|
.divideScalar(this.size)
|
|
49
50
|
.length();
|
|
50
51
|
// Populates the data array with density influenced by noise.
|
|
51
|
-
data[i] =
|
|
52
|
-
this.size
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
data[i] =
|
|
53
|
+
(this.size +
|
|
54
|
+
this.size *
|
|
55
|
+
perlin.noise((x * this.cloudScale) / 1.5, y * this.cloudScale, (z * this.cloudScale) / 1.5)) *
|
|
56
|
+
d *
|
|
57
|
+
d;
|
|
55
58
|
i++;
|
|
56
59
|
}
|
|
57
60
|
}
|
package/build/agent/Agent.d.ts
CHANGED
|
@@ -2,6 +2,19 @@ import { AI } from '../ai/AI';
|
|
|
2
2
|
import { Context } from './Context';
|
|
3
3
|
import { Memory } from './Memory';
|
|
4
4
|
import { Tool } from './Tool';
|
|
5
|
+
/**
|
|
6
|
+
* Lifecycle callbacks for agent events.
|
|
7
|
+
*/
|
|
8
|
+
export interface AgentLifecycleCallbacks {
|
|
9
|
+
/** Called when a session starts */
|
|
10
|
+
onSessionStart?: () => void | Promise<void>;
|
|
11
|
+
/** Called when a session ends */
|
|
12
|
+
onSessionEnd?: () => void | Promise<void>;
|
|
13
|
+
/** Called after a tool is executed */
|
|
14
|
+
onToolExecuted?: (toolName: string, result: unknown) => void;
|
|
15
|
+
/** Called when an error occurs */
|
|
16
|
+
onError?: (error: Error) => void;
|
|
17
|
+
}
|
|
5
18
|
/**
|
|
6
19
|
* An agent that can use an AI to reason and execute tools.
|
|
7
20
|
*/
|
|
@@ -11,7 +24,9 @@ export declare class Agent {
|
|
|
11
24
|
tools: Tool[];
|
|
12
25
|
memory: Memory;
|
|
13
26
|
contextBuilder: Context;
|
|
14
|
-
|
|
27
|
+
lifecycleCallbacks?: AgentLifecycleCallbacks;
|
|
28
|
+
isSessionActive: boolean;
|
|
29
|
+
constructor(ai: AI, tools?: Tool[], instruction?: string, callbacks?: AgentLifecycleCallbacks);
|
|
15
30
|
/**
|
|
16
31
|
* Starts the agent's reasoning loop with an initial prompt.
|
|
17
32
|
* @param prompt - The initial prompt from the user.
|
|
@@ -25,4 +40,13 @@ export declare class Agent {
|
|
|
25
40
|
*/
|
|
26
41
|
private run;
|
|
27
42
|
findTool(name: string): Tool | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Get the current session state.
|
|
45
|
+
* @returns Object containing session information
|
|
46
|
+
*/
|
|
47
|
+
getSessionState(): {
|
|
48
|
+
isActive: boolean;
|
|
49
|
+
toolCount: number;
|
|
50
|
+
memorySize: number;
|
|
51
|
+
};
|
|
28
52
|
}
|
|
@@ -2,11 +2,127 @@ import type * as GoogleGenAITypes from '@google/genai';
|
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { AI } from '../ai/AI';
|
|
4
4
|
import { CoreSound } from '../sound/CoreSound';
|
|
5
|
-
import { Agent } from './Agent';
|
|
5
|
+
import { Agent, AgentLifecycleCallbacks } from './Agent';
|
|
6
|
+
import { ToolResult } from './Tool';
|
|
7
|
+
/**
|
|
8
|
+
* State information for a live session.
|
|
9
|
+
*/
|
|
10
|
+
export interface LiveSessionState {
|
|
11
|
+
/** Whether the session is currently active */
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
/** Timestamp when session started */
|
|
14
|
+
startTime?: number;
|
|
15
|
+
/** Timestamp when session ended */
|
|
16
|
+
endTime?: number;
|
|
17
|
+
/** Number of messages received */
|
|
18
|
+
messageCount: number;
|
|
19
|
+
/** Number of tool calls executed */
|
|
20
|
+
toolCallCount: number;
|
|
21
|
+
/** Last error message if any */
|
|
22
|
+
lastError?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Skybox Agent for generating 360-degree equirectangular backgrounds through conversation.
|
|
26
|
+
*
|
|
27
|
+
* @example Basic usage
|
|
28
|
+
* ```typescript
|
|
29
|
+
* // 1. Enable audio (required for live sessions)
|
|
30
|
+
* await xb.core.sound.enableAudio();
|
|
31
|
+
*
|
|
32
|
+
* // 2. Create agent
|
|
33
|
+
* const agent = new xb.SkyboxAgent(xb.core.ai, xb.core.sound, xb.core.scene);
|
|
34
|
+
*
|
|
35
|
+
* // 3. Start session
|
|
36
|
+
* await agent.startLiveSession({
|
|
37
|
+
* onopen: () => console.log('Session ready'),
|
|
38
|
+
* onmessage: (msg) => handleMessage(msg),
|
|
39
|
+
* onclose: () => console.log('Session closed')
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // 4. Clean up when done
|
|
43
|
+
* await agent.stopLiveSession();
|
|
44
|
+
* xb.core.sound.disableAudio();
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example With lifecycle callbacks
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const agent = new xb.SkyboxAgent(
|
|
50
|
+
* xb.core.ai,
|
|
51
|
+
* xb.core.sound,
|
|
52
|
+
* xb.core.scene,
|
|
53
|
+
* {
|
|
54
|
+
* onSessionStart: () => updateUI('active'),
|
|
55
|
+
* onSessionEnd: () => updateUI('inactive'),
|
|
56
|
+
* onError: (error) => showError(error)
|
|
57
|
+
* }
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* - Audio must be enabled BEFORE starting live session using `xb.core.sound.enableAudio()`
|
|
63
|
+
* - Users are responsible for managing audio lifecycle
|
|
64
|
+
* - Always call `stopLiveSession()` before disabling audio
|
|
65
|
+
* - Session state can be checked using `getSessionState()` and `getLiveSessionState()`
|
|
66
|
+
*/
|
|
6
67
|
export declare class SkyboxAgent extends Agent {
|
|
7
68
|
private sound;
|
|
8
|
-
|
|
9
|
-
|
|
69
|
+
private sessionState;
|
|
70
|
+
constructor(ai: AI, sound: CoreSound, scene: THREE.Scene, callbacks?: AgentLifecycleCallbacks);
|
|
71
|
+
/**
|
|
72
|
+
* Starts a live AI session for real-time conversation.
|
|
73
|
+
*
|
|
74
|
+
* @param callbacks - Optional callbacks for session events. Can also be set using ai.setLiveCallbacks()
|
|
75
|
+
* @throws If AI model is not initialized or live session is not available
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* Audio must be enabled separately using `xb.core.sound.enableAudio()` before starting the session.
|
|
79
|
+
* This gives users control over when microphone permissions are requested.
|
|
80
|
+
*/
|
|
81
|
+
startLiveSession(callbacks?: GoogleGenAITypes.LiveCallbacks): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Stops the live AI session.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* Audio must be disabled separately using `xb.core.sound.disableAudio()` after stopping the session.
|
|
87
|
+
*/
|
|
10
88
|
stopLiveSession(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Wraps user callbacks to track session state and trigger lifecycle events.
|
|
91
|
+
* @param callbacks - The callbacks to wrap.
|
|
92
|
+
* @returns The wrapped callbacks.
|
|
93
|
+
*/
|
|
94
|
+
private wrapCallbacks;
|
|
95
|
+
/**
|
|
96
|
+
* Sends tool execution results back to the AI.
|
|
97
|
+
*
|
|
98
|
+
* @param response - The tool response containing function results
|
|
99
|
+
*/
|
|
11
100
|
sendToolResponse(response: GoogleGenAITypes.LiveSendToolResponseParameters): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Validates that a tool response has the correct format.
|
|
103
|
+
* @param response - The tool response to validate.
|
|
104
|
+
* @returns True if the response is valid, false otherwise.
|
|
105
|
+
*/
|
|
106
|
+
private validateToolResponse;
|
|
107
|
+
/**
|
|
108
|
+
* Helper to create a properly formatted tool response from a ToolResult.
|
|
109
|
+
*
|
|
110
|
+
* @param id - The function call ID
|
|
111
|
+
* @param name - The function name
|
|
112
|
+
* @param result - The ToolResult from tool execution
|
|
113
|
+
* @returns A properly formatted FunctionResponse
|
|
114
|
+
*/
|
|
115
|
+
static createToolResponse(id: string, name: string, result: ToolResult): GoogleGenAITypes.FunctionResponse;
|
|
116
|
+
/**
|
|
117
|
+
* Gets the current live session state.
|
|
118
|
+
*
|
|
119
|
+
* @returns Read-only session state information
|
|
120
|
+
*/
|
|
121
|
+
getLiveSessionState(): Readonly<LiveSessionState>;
|
|
122
|
+
/**
|
|
123
|
+
* Gets the duration of the session in milliseconds.
|
|
124
|
+
*
|
|
125
|
+
* @returns Duration in ms, or null if session hasn't started
|
|
126
|
+
*/
|
|
127
|
+
getSessionDuration(): number | null;
|
|
12
128
|
}
|
package/build/agent/Tool.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as GoogleGenAITypes from '@google/genai';
|
|
2
2
|
export interface ToolCall {
|
|
3
3
|
name: string;
|
|
4
4
|
args: unknown;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Standardized result type for tool execution.
|
|
8
|
+
* @typeParam T - The type of data returned on success.
|
|
9
|
+
*/
|
|
10
|
+
export interface ToolResult<T = unknown> {
|
|
11
|
+
/** Whether the tool execution succeeded */
|
|
12
|
+
success: boolean;
|
|
13
|
+
/** The result data if successful */
|
|
14
|
+
data?: T;
|
|
15
|
+
/** Error message if execution failed */
|
|
16
|
+
error?: string;
|
|
17
|
+
/** Additional metadata about the execution */
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}
|
|
6
20
|
export type ToolSchema = Omit<GoogleGenAITypes.Schema, 'type' | 'properties'> & {
|
|
7
21
|
properties?: Record<string, ToolSchema>;
|
|
8
22
|
type?: keyof typeof GoogleGenAITypes.Type;
|
|
@@ -15,7 +29,8 @@ export type ToolOptions = {
|
|
|
15
29
|
/** The parameters of the tool */
|
|
16
30
|
parameters?: ToolSchema;
|
|
17
31
|
/** A callback to execute when the tool is triggered */
|
|
18
|
-
onTriggered?: (args: unknown) => unknown
|
|
32
|
+
onTriggered?: (args: unknown) => unknown | Promise<unknown>;
|
|
33
|
+
behavior?: 'BLOCKING' | 'NON_BLOCKING' | GoogleGenAITypes.Behavior;
|
|
19
34
|
};
|
|
20
35
|
/**
|
|
21
36
|
* A base class for tools that the agent can use.
|
|
@@ -25,16 +40,17 @@ export declare class Tool {
|
|
|
25
40
|
description?: string;
|
|
26
41
|
parameters?: ToolSchema;
|
|
27
42
|
onTriggered?: (args: unknown) => unknown;
|
|
43
|
+
behavior?: 'BLOCKING' | 'NON_BLOCKING';
|
|
28
44
|
/**
|
|
29
45
|
* @param options - The options for the tool.
|
|
30
46
|
*/
|
|
31
47
|
constructor(options: ToolOptions);
|
|
32
48
|
/**
|
|
33
|
-
* Executes the tool's action.
|
|
49
|
+
* Executes the tool's action with standardized error handling.
|
|
34
50
|
* @param args - The arguments for the tool.
|
|
35
|
-
* @returns
|
|
51
|
+
* @returns A promise that resolves with a ToolResult containing success/error information.
|
|
36
52
|
*/
|
|
37
|
-
execute(args: unknown):
|
|
53
|
+
execute(args: unknown): Promise<ToolResult>;
|
|
38
54
|
/**
|
|
39
55
|
* Returns a JSON representation of the tool.
|
|
40
56
|
* @returns A valid FunctionDeclaration object.
|
package/build/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { AI } from '../../ai/AI';
|
|
3
|
-
import { Tool } from '../Tool';
|
|
3
|
+
import { Tool, ToolResult } from '../Tool';
|
|
4
4
|
/**
|
|
5
5
|
* A tool that generates a 360-degree equirectangular skybox image
|
|
6
6
|
* based on a given prompt using an AI service.
|
|
@@ -12,9 +12,9 @@ export declare class GenerateSkyboxTool extends Tool {
|
|
|
12
12
|
/**
|
|
13
13
|
* Executes the tool's action.
|
|
14
14
|
* @param args - The prompt to use to generate the skybox.
|
|
15
|
-
* @returns A promise that resolves with
|
|
15
|
+
* @returns A promise that resolves with a ToolResult containing success/error information.
|
|
16
16
|
*/
|
|
17
17
|
execute(args: {
|
|
18
18
|
prompt: string;
|
|
19
|
-
}): Promise<string
|
|
19
|
+
}): Promise<ToolResult<string>>;
|
|
20
20
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Tool } from '../Tool';
|
|
1
|
+
import { Tool, ToolResult } from '../Tool';
|
|
2
2
|
export interface GetWeatherArgs {
|
|
3
3
|
latitude: number;
|
|
4
4
|
longitude: number;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
6
|
+
export interface WeatherData {
|
|
7
|
+
temperature: number;
|
|
8
|
+
weathercode: number;
|
|
9
|
+
}
|
|
11
10
|
/**
|
|
12
11
|
* A tool that gets the current weather for a specific location.
|
|
13
12
|
*/
|
|
@@ -16,7 +15,7 @@ export declare class GetWeatherTool extends Tool {
|
|
|
16
15
|
/**
|
|
17
16
|
* Executes the tool's action.
|
|
18
17
|
* @param args - The arguments for the tool.
|
|
19
|
-
* @returns A promise that resolves with
|
|
18
|
+
* @returns A promise that resolves with a ToolResult containing weather information.
|
|
20
19
|
*/
|
|
21
|
-
execute(args: GetWeatherArgs): Promise<
|
|
20
|
+
execute(args: GetWeatherArgs): Promise<ToolResult<WeatherData>>;
|
|
22
21
|
}
|
package/build/ai/AI.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare class AI extends Script {
|
|
|
60
60
|
query(input: {
|
|
61
61
|
prompt: string;
|
|
62
62
|
}, tools?: never[]): Promise<GeminiResponse | string | null>;
|
|
63
|
-
startLiveSession(config?:
|
|
63
|
+
startLiveSession(config?: GoogleGenAITypes.LiveConnectConfig, model?: string): Promise<GoogleGenAITypes.Session>;
|
|
64
64
|
stopLiveSession(): Promise<void>;
|
|
65
65
|
setLiveCallbacks(callbacks: GoogleGenAITypes.LiveCallbacks): Promise<void>;
|
|
66
66
|
sendToolResponse(response: GoogleGenAITypes.LiveSendToolResponseParameters): void;
|
package/build/ai/Gemini.d.ts
CHANGED
|
@@ -25,10 +25,7 @@ export declare class Gemini extends BaseAIModel {
|
|
|
25
25
|
init(): Promise<void>;
|
|
26
26
|
isAvailable(): boolean;
|
|
27
27
|
isLiveAvailable(): false | typeof GoogleGenAITypes.Modality | undefined;
|
|
28
|
-
startLiveSession(params?:
|
|
29
|
-
tools?: GoogleGenAITypes.FunctionDeclaration[];
|
|
30
|
-
systemInstruction?: GoogleGenAITypes.ContentUnion | string;
|
|
31
|
-
}): Promise<GoogleGenAITypes.Session>;
|
|
28
|
+
startLiveSession(params?: GoogleGenAITypes.LiveConnectConfig, model?: string): Promise<GoogleGenAITypes.Session>;
|
|
32
29
|
stopLiveSession(): Promise<void>;
|
|
33
30
|
setLiveCallbacks(callbacks: GoogleGenAITypes.LiveCallbacks): void;
|
|
34
31
|
sendToolResponse(response: GoogleGenAITypes.LiveSendToolResponseParameters): void;
|
|
@@ -23,7 +23,7 @@ export declare class XRDeviceCamera extends VideoStream<XRDeviceCameraDetails> {
|
|
|
23
23
|
/**
|
|
24
24
|
* @param options - The configuration options.
|
|
25
25
|
*/
|
|
26
|
-
constructor({ videoConstraints, willCaptureFrequently }?: Partial<DeviceCameraOptions>);
|
|
26
|
+
constructor({ videoConstraints, willCaptureFrequently, }?: Partial<DeviceCameraOptions>);
|
|
27
27
|
/**
|
|
28
28
|
* Retrieves the list of available video input devices.
|
|
29
29
|
* @returns A promise that resolves with an
|
package/build/core/Core.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as THREE from 'three';
|
|
|
2
2
|
import { AI } from '../ai/AI';
|
|
3
3
|
import { XRDeviceCamera } from '../camera/XRDeviceCamera';
|
|
4
4
|
import { Depth } from '../depth/Depth';
|
|
5
|
+
import { GestureRecognition } from '../input/gestures/GestureRecognition';
|
|
5
6
|
import { Input } from '../input/Input';
|
|
6
7
|
import { Lighting } from '../lighting/Lighting';
|
|
7
8
|
import { Physics } from '../physics/Physics';
|
|
@@ -49,13 +50,14 @@ export declare class Core {
|
|
|
49
50
|
/** The main camera for rendering. */
|
|
50
51
|
camera: THREE.PerspectiveCamera;
|
|
51
52
|
/** The root scene graph for all objects. */
|
|
52
|
-
scene: THREE.Scene
|
|
53
|
+
scene: THREE.Scene<THREE.Object3DEventMap>;
|
|
53
54
|
/** Represents the user in the XR scene. */
|
|
54
55
|
user: User;
|
|
55
56
|
/** Manages all UI elements. */
|
|
56
57
|
ui: UI;
|
|
57
58
|
/** Manages all (spatial) audio playback. */
|
|
58
59
|
sound: CoreSound;
|
|
60
|
+
private renderSceneBound;
|
|
59
61
|
/** Manages the desktop XR simulator. */
|
|
60
62
|
simulator: Simulator;
|
|
61
63
|
/** Manages drag-and-drop interactions. */
|
|
@@ -76,6 +78,7 @@ export declare class Core {
|
|
|
76
78
|
xrButton?: XRButton;
|
|
77
79
|
effects?: XREffects;
|
|
78
80
|
ai: AI;
|
|
81
|
+
gestureRecognition?: GestureRecognition;
|
|
79
82
|
transition?: XRTransition;
|
|
80
83
|
currentFrame?: XRFrame;
|
|
81
84
|
scriptsManager: ScriptsManager;
|
package/build/core/Options.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { AIOptions } from '../ai/AIOptions';
|
|
|
2
2
|
import { DeviceCameraOptions } from '../camera/CameraOptions.js';
|
|
3
3
|
import { DepthOptions } from '../depth/DepthOptions.js';
|
|
4
4
|
import { HandsOptions } from '../input/HandsOptions.js';
|
|
5
|
+
import { GestureRecognitionOptions } from '../input/gestures/GestureRecognitionOptions.js';
|
|
5
6
|
import { LightingOptions } from '../lighting/LightingOptions.js';
|
|
6
7
|
import { PhysicsOptions } from '../physics/PhysicsOptions';
|
|
7
8
|
import { SimulatorOptions } from '../simulator/SimulatorOptions';
|
|
@@ -63,11 +64,22 @@ export declare class Options {
|
|
|
63
64
|
* Whether to request a stencil buffer.
|
|
64
65
|
*/
|
|
65
66
|
stencil: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Canvas element to use for rendering.
|
|
69
|
+
* If not defined, a new element will be added to document body.
|
|
70
|
+
*/
|
|
71
|
+
canvas?: HTMLCanvasElement;
|
|
72
|
+
/**
|
|
73
|
+
* Any additional required features when initializing webxr.
|
|
74
|
+
*/
|
|
75
|
+
webxrRequiredFeatures: string[];
|
|
76
|
+
referenceSpaceType: XRReferenceSpaceType;
|
|
66
77
|
controllers: InputOptions;
|
|
67
78
|
depth: DepthOptions;
|
|
68
79
|
lighting: LightingOptions;
|
|
69
80
|
deviceCamera: DeviceCameraOptions;
|
|
70
81
|
hands: HandsOptions;
|
|
82
|
+
gestures: GestureRecognitionOptions;
|
|
71
83
|
reticles: ReticleOptions;
|
|
72
84
|
sound: SoundOptions;
|
|
73
85
|
ai: AIOptions;
|
|
@@ -140,6 +152,11 @@ export declare class Options {
|
|
|
140
152
|
* @returns The instance for chaining.
|
|
141
153
|
*/
|
|
142
154
|
enableHands(): this;
|
|
155
|
+
/**
|
|
156
|
+
* Enables the gesture recognition block and ensures hands are available.
|
|
157
|
+
* @returns The instance for chaining.
|
|
158
|
+
*/
|
|
159
|
+
enableGestures(): this;
|
|
143
160
|
/**
|
|
144
161
|
* Enables the visualization of rays for hand tracking.
|
|
145
162
|
* @returns The instance for chaining.
|
|
@@ -4,11 +4,13 @@ export declare class ScreenshotSynthesizer {
|
|
|
4
4
|
private pendingScreenshotRequests;
|
|
5
5
|
private virtualCanvas?;
|
|
6
6
|
private virtualBuffer;
|
|
7
|
+
private virtualRenderTarget?;
|
|
7
8
|
private virtualRealCanvas?;
|
|
8
9
|
private virtualRealBuffer;
|
|
9
|
-
private
|
|
10
|
+
private virtualRealRenderTarget?;
|
|
10
11
|
private fullScreenQuad?;
|
|
11
|
-
|
|
12
|
+
private renderTargetWidth;
|
|
13
|
+
onAfterRender(renderer: THREE.WebGLRenderer, renderSceneFn: () => void, deviceCamera?: XRDeviceCamera): Promise<void>;
|
|
12
14
|
private createVirtualImageDataURL;
|
|
13
15
|
private resolveVirtualOnlyRequests;
|
|
14
16
|
private createVirtualRealImageDataURL;
|
|
@@ -18,7 +20,7 @@ export declare class ScreenshotSynthesizer {
|
|
|
18
20
|
* Requests a screenshot from the scene as a DataURL.
|
|
19
21
|
* @param overlayOnCamera - If true, overlays the image on a camera image
|
|
20
22
|
* without any projection or aspect ratio correction.
|
|
21
|
-
* @returns Promise which returns the screenshot.
|
|
23
|
+
* @returns Promise which returns the screenshot as a data uri.
|
|
22
24
|
*/
|
|
23
|
-
getScreenshot(overlayOnCamera?: boolean): Promise<
|
|
25
|
+
getScreenshot(overlayOnCamera?: boolean): Promise<string>;
|
|
24
26
|
}
|
|
@@ -35,7 +35,7 @@ export declare class XRTransition extends MeshScript<THREE.SphereGeometry, THREE
|
|
|
35
35
|
private targetAlpha;
|
|
36
36
|
private defaultBackgroundColor;
|
|
37
37
|
constructor();
|
|
38
|
-
init({ renderer, camera, timer, scene, options }: {
|
|
38
|
+
init({ renderer, camera, timer, scene, options, }: {
|
|
39
39
|
renderer: THREE.WebGLRenderer;
|
|
40
40
|
camera: THREE.Camera;
|
|
41
41
|
timer: THREE.Timer;
|
package/build/depth/Depth.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export declare class Depth {
|
|
|
12
12
|
private projectionMatrixInverse;
|
|
13
13
|
private xrRefSpace?;
|
|
14
14
|
view: XRView[];
|
|
15
|
-
|
|
15
|
+
cpuDepthData: XRCPUDepthInformation[];
|
|
16
|
+
gpuDepthData: XRWebGLDepthInformation[];
|
|
16
17
|
depthArray: DepthArray[];
|
|
17
18
|
depthMesh?: DepthMesh;
|
|
18
19
|
private depthTextures?;
|
|
@@ -53,8 +54,9 @@ export declare class Depth {
|
|
|
53
54
|
* @returns Vertex at (u, v)
|
|
54
55
|
*/
|
|
55
56
|
getVertex(u: number, v: number): THREE.Vector3 | null;
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
updateCPUDepthData(depthData: XRCPUDepthInformation, view_id?: number): void;
|
|
58
|
+
updateGPUDepthData(depthData: XRWebGLDepthInformation, view_id?: number): void;
|
|
59
|
+
getTexture(view_id: number): THREE.DataTexture | THREE.ExternalTexture | undefined;
|
|
58
60
|
update(frame: XRFrame): void;
|
|
59
61
|
updateLocalDepth(frame: XRFrame): void;
|
|
60
62
|
renderOcclusionPass(): void;
|
|
@@ -30,6 +30,11 @@ export declare class DepthMesh extends MeshScript {
|
|
|
30
30
|
private lastColliderUpdateTime;
|
|
31
31
|
private options;
|
|
32
32
|
private depthTextureMaterialUniforms?;
|
|
33
|
+
private depthTarget;
|
|
34
|
+
private depthTexture;
|
|
35
|
+
private depthScene;
|
|
36
|
+
private depthCamera;
|
|
37
|
+
private gpuPixels;
|
|
33
38
|
private RAPIER?;
|
|
34
39
|
private blendedWorld?;
|
|
35
40
|
private rigidBody?;
|
|
@@ -38,7 +43,7 @@ export declare class DepthMesh extends MeshScript {
|
|
|
38
43
|
/**
|
|
39
44
|
* Initialize the depth mesh.
|
|
40
45
|
*/
|
|
41
|
-
init({ camera, renderer }: {
|
|
46
|
+
init({ camera, renderer, }: {
|
|
42
47
|
camera: THREE.Camera;
|
|
43
48
|
renderer: THREE.WebGLRenderer;
|
|
44
49
|
}): void;
|
|
@@ -47,6 +52,8 @@ export declare class DepthMesh extends MeshScript {
|
|
|
47
52
|
* and depth data.
|
|
48
53
|
*/
|
|
49
54
|
updateDepth(depthData: XRCPUDepthInformation): void;
|
|
55
|
+
updateGPUDepth(depthData: XRWebGLDepthInformation): void;
|
|
56
|
+
convertGPUToGPU(depthData: XRWebGLDepthInformation): XRCPUDepthInformation;
|
|
50
57
|
/**
|
|
51
58
|
* Method to manually update the full resolution geometry.
|
|
52
59
|
* Only needed if options.updateFullResolutionGeometry is false.
|