xrblocks 0.3.1 → 0.5.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/build/addons/ai/GeminiManager.d.ts +1 -0
- package/build/addons/ai/GeminiManager.js +3 -2
- package/build/core/Core.d.ts +2 -0
- package/build/core/Options.d.ts +10 -6
- package/build/core/components/PermissionsManager.d.ts +54 -0
- package/build/core/components/WebXRSessionManager.d.ts +1 -0
- package/build/core/components/XRButton.d.ts +8 -1
- package/build/depth/DepthOptions.d.ts +8 -0
- package/build/simulator/Simulator.d.ts +2 -0
- package/build/simulator/SimulatorOptions.d.ts +5 -1
- package/build/sound/AudioPlayer.d.ts +1 -0
- package/build/xrblocks.js +294 -26
- 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 +1 -1
|
@@ -26,6 +26,7 @@ export declare class GeminiManager extends xb.Script<GeminiManagerEventMap> {
|
|
|
26
26
|
currentInputText: string;
|
|
27
27
|
currentOutputText: string;
|
|
28
28
|
tools: xb.Tool[];
|
|
29
|
+
scheduleAheadTime: number;
|
|
29
30
|
constructor();
|
|
30
31
|
init(): void;
|
|
31
32
|
startGeminiLive({ liveParams, model, }?: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as xb from 'xrblocks';
|
|
2
2
|
import { AUDIO_CAPTURE_PROCESSOR_CODE } from './AudioCaptureProcessorCode.js';
|
|
3
3
|
|
|
4
|
+
const DEFAULT_SCHEDULE_AHEAD_TIME = 1.0;
|
|
4
5
|
class GeminiManager extends xb.Script {
|
|
5
6
|
constructor() {
|
|
6
7
|
super();
|
|
@@ -19,6 +20,7 @@ class GeminiManager extends xb.Script {
|
|
|
19
20
|
this.currentInputText = '';
|
|
20
21
|
this.currentOutputText = '';
|
|
21
22
|
this.tools = [];
|
|
23
|
+
this.scheduleAheadTime = DEFAULT_SCHEDULE_AHEAD_TIME;
|
|
22
24
|
}
|
|
23
25
|
init() {
|
|
24
26
|
this.xrDeviceCamera = xb.core.deviceCamera;
|
|
@@ -191,10 +193,9 @@ class GeminiManager extends xb.Script {
|
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
scheduleAudioBuffers() {
|
|
194
|
-
const SCHEDULE_AHEAD_TIME = 0.2;
|
|
195
196
|
while (this.audioQueue.length > 0 &&
|
|
196
197
|
this.nextAudioStartTime <=
|
|
197
|
-
this.audioContext.currentTime +
|
|
198
|
+
this.audioContext.currentTime + this.scheduleAheadTime) {
|
|
198
199
|
const audioBuffer = this.audioQueue.shift();
|
|
199
200
|
const source = this.audioContext.createBufferSource();
|
|
200
201
|
source.buffer = audioBuffer;
|
package/build/core/Core.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { XREffects } from './components/XREffects';
|
|
|
21
21
|
import { XRTransition } from './components/XRTransition';
|
|
22
22
|
import { Options } from './Options';
|
|
23
23
|
import { User } from './User';
|
|
24
|
+
import { PermissionsManager } from './components/PermissionsManager';
|
|
24
25
|
/**
|
|
25
26
|
* Core is the central engine of the XR Blocks framework, acting as a
|
|
26
27
|
* singleton manager for all XR subsystems. Its primary goal is to abstract
|
|
@@ -84,6 +85,7 @@ export declare class Core {
|
|
|
84
85
|
scriptsManager: ScriptsManager;
|
|
85
86
|
renderSceneOverride?: (renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => void;
|
|
86
87
|
webXRSessionManager?: WebXRSessionManager;
|
|
88
|
+
permissionsManager: PermissionsManager;
|
|
87
89
|
/**
|
|
88
90
|
* Core is a singleton manager that manages all XR "blocks".
|
|
89
91
|
* It initializes core components and abstractions like the scene, camera,
|
package/build/core/Options.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ export declare class Options {
|
|
|
95
95
|
* Whether to use post-processing effects.
|
|
96
96
|
*/
|
|
97
97
|
usePostprocessing: boolean;
|
|
98
|
+
enableSimulator: boolean;
|
|
98
99
|
/**
|
|
99
100
|
* Configuration for the XR session button.
|
|
100
101
|
*/
|
|
@@ -104,9 +105,17 @@ export declare class Options {
|
|
|
104
105
|
endText: string;
|
|
105
106
|
invalidText: string;
|
|
106
107
|
startSimulatorText: string;
|
|
107
|
-
|
|
108
|
+
showEnterSimulatorButton: boolean;
|
|
108
109
|
alwaysAutostartSimulator: boolean;
|
|
109
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Which permissions to request before entering the XR session.
|
|
113
|
+
*/
|
|
114
|
+
permissions: {
|
|
115
|
+
geolocation: boolean;
|
|
116
|
+
camera: boolean;
|
|
117
|
+
microphone: boolean;
|
|
118
|
+
};
|
|
110
119
|
/**
|
|
111
120
|
* Constructs the Options object by merging default values with provided
|
|
112
121
|
* custom options.
|
|
@@ -160,11 +169,6 @@ export declare class Options {
|
|
|
160
169
|
* @returns The instance for chaining.
|
|
161
170
|
*/
|
|
162
171
|
enableHandRays(): this;
|
|
163
|
-
/**
|
|
164
|
-
* Enables the Gemini Live feature.
|
|
165
|
-
* @returns The instance for chaining.
|
|
166
|
-
*/
|
|
167
|
-
enableGeminiLive(): this;
|
|
168
172
|
/**
|
|
169
173
|
* Enables a standard set of AI features, including Gemini Live.
|
|
170
174
|
* @returns The instance for chaining.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing the result of a permission request.
|
|
3
|
+
*/
|
|
4
|
+
export interface PermissionResult {
|
|
5
|
+
granted: boolean;
|
|
6
|
+
status: PermissionState | 'unknown' | 'error';
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A utility class to manage and request browser permissions for
|
|
11
|
+
* Location, Camera, and Microphone.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PermissionsManager {
|
|
14
|
+
/**
|
|
15
|
+
* Requests permission to access the user's geolocation.
|
|
16
|
+
* Note: This actually attempts to fetch the position to trigger the prompt.
|
|
17
|
+
*/
|
|
18
|
+
requestLocationPermission(): Promise<PermissionResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Requests permission to access the microphone.
|
|
21
|
+
* Opens a stream to trigger the prompt, then immediately closes it.
|
|
22
|
+
*/
|
|
23
|
+
requestMicrophonePermission(): Promise<PermissionResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Requests permission to access the camera.
|
|
26
|
+
* Opens a stream to trigger the prompt, then immediately closes it.
|
|
27
|
+
*/
|
|
28
|
+
requestCameraPermission(): Promise<PermissionResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Requests permission for both camera and microphone simultaneously.
|
|
31
|
+
*/
|
|
32
|
+
requestAVPermission(): Promise<PermissionResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Internal helper to handle getUserMedia requests.
|
|
35
|
+
* Crucially, this stops the tracks immediately after permission is granted
|
|
36
|
+
* so the hardware doesn't remain active.
|
|
37
|
+
*/
|
|
38
|
+
private requestMediaPermission;
|
|
39
|
+
/**
|
|
40
|
+
* Requests multiple permissions sequentially.
|
|
41
|
+
* Returns a single result: granted is true only if ALL requested permissions are granted.
|
|
42
|
+
*/
|
|
43
|
+
checkAndRequestPermissions({ geolocation, camera, microphone, }: {
|
|
44
|
+
geolocation?: boolean;
|
|
45
|
+
camera?: boolean;
|
|
46
|
+
microphone?: boolean;
|
|
47
|
+
}): Promise<PermissionResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Checks the current status of a permission without triggering a prompt.
|
|
50
|
+
* Useful for UI state (e.g., disabling buttons if already denied).
|
|
51
|
+
* * @param permissionName - 'geolocation', 'camera', or 'microphone'
|
|
52
|
+
*/
|
|
53
|
+
checkPermissionStatus(permissionName: 'geolocation' | 'camera' | 'microphone'): Promise<PermissionState | 'unknown'>;
|
|
54
|
+
}
|
|
@@ -34,6 +34,7 @@ export declare class WebXRSessionManager extends THREE.EventDispatcher<WebXRSess
|
|
|
34
34
|
private sessionOptions?;
|
|
35
35
|
private onSessionEndedBound;
|
|
36
36
|
private xrModeSupported?;
|
|
37
|
+
private waitingForXRSession;
|
|
37
38
|
constructor(renderer: THREE.WebGLRenderer, sessionInit: XRSessionInit, mode: XRSessionMode);
|
|
38
39
|
/**
|
|
39
40
|
* Checks for WebXR support and availability of the requested session mode.
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
import { PermissionsManager } from './PermissionsManager';
|
|
1
2
|
import { WebXRSessionManager } from './WebXRSessionManager';
|
|
2
3
|
export declare class XRButton {
|
|
3
4
|
private sessionManager;
|
|
5
|
+
private permissionsManager;
|
|
4
6
|
private startText;
|
|
5
7
|
private endText;
|
|
6
8
|
private invalidText;
|
|
7
9
|
private startSimulatorText;
|
|
8
10
|
startSimulator: () => void;
|
|
11
|
+
private permissions;
|
|
9
12
|
domElement: HTMLDivElement;
|
|
10
13
|
simulatorButtonElement: HTMLButtonElement;
|
|
11
14
|
xrButtonElement: HTMLButtonElement;
|
|
12
|
-
constructor(sessionManager: WebXRSessionManager, startText?: string, endText?: string, invalidText?: string, startSimulatorText?: string,
|
|
15
|
+
constructor(sessionManager: WebXRSessionManager, permissionsManager: PermissionsManager, startText?: string, endText?: string, invalidText?: string, startSimulatorText?: string, showEnterSimulatorButton?: boolean, startSimulator?: () => void, permissions?: {
|
|
16
|
+
geolocation: boolean;
|
|
17
|
+
camera: boolean;
|
|
18
|
+
microphone: boolean;
|
|
19
|
+
});
|
|
13
20
|
private createSimulatorButton;
|
|
14
21
|
private createXRButtonElement;
|
|
15
22
|
private onSessionReady;
|
|
@@ -28,6 +28,8 @@ export declare class DepthOptions {
|
|
|
28
28
|
enabled: boolean;
|
|
29
29
|
};
|
|
30
30
|
useFloat32: boolean;
|
|
31
|
+
depthTypeRequest: XRDepthType[];
|
|
32
|
+
matchDepthView: boolean;
|
|
31
33
|
constructor(options?: DeepReadonly<DeepPartial<DepthOptions>>);
|
|
32
34
|
}
|
|
33
35
|
export declare const xrDepthMeshOptions: {
|
|
@@ -58,6 +60,8 @@ export declare const xrDepthMeshOptions: {
|
|
|
58
60
|
readonly enabled: boolean;
|
|
59
61
|
};
|
|
60
62
|
readonly useFloat32: boolean;
|
|
63
|
+
readonly depthTypeRequest: readonly XRDepthType[];
|
|
64
|
+
readonly matchDepthView: boolean;
|
|
61
65
|
};
|
|
62
66
|
export declare const xrDepthMeshVisualizationOptions: {
|
|
63
67
|
readonly debugging: boolean;
|
|
@@ -87,6 +91,8 @@ export declare const xrDepthMeshVisualizationOptions: {
|
|
|
87
91
|
readonly enabled: boolean;
|
|
88
92
|
};
|
|
89
93
|
readonly useFloat32: boolean;
|
|
94
|
+
readonly depthTypeRequest: readonly XRDepthType[];
|
|
95
|
+
readonly matchDepthView: boolean;
|
|
90
96
|
};
|
|
91
97
|
export declare const xrDepthMeshPhysicsOptions: {
|
|
92
98
|
readonly debugging: boolean;
|
|
@@ -116,4 +122,6 @@ export declare const xrDepthMeshPhysicsOptions: {
|
|
|
116
122
|
readonly enabled: boolean;
|
|
117
123
|
};
|
|
118
124
|
readonly useFloat32: boolean;
|
|
125
|
+
readonly depthTypeRequest: readonly XRDepthType[];
|
|
126
|
+
readonly matchDepthView: boolean;
|
|
119
127
|
};
|
|
@@ -42,6 +42,8 @@ export declare class Simulator extends Script {
|
|
|
42
42
|
effects?: XREffects;
|
|
43
43
|
virtualSceneRenderTarget?: THREE.WebGLRenderTarget;
|
|
44
44
|
virtualSceneFullScreenQuad?: FullScreenQuad;
|
|
45
|
+
backgroundVideoQuad?: FullScreenQuad;
|
|
46
|
+
videoElement?: HTMLVideoElement;
|
|
45
47
|
camera?: SimulatorCamera;
|
|
46
48
|
options: SimulatorOptions;
|
|
47
49
|
renderer: THREE.WebGLRenderer;
|
|
@@ -23,6 +23,7 @@ export declare class SimulatorOptions {
|
|
|
23
23
|
z: number;
|
|
24
24
|
};
|
|
25
25
|
scenePath: string;
|
|
26
|
+
videoPath?: string;
|
|
26
27
|
initialScenePosition: {
|
|
27
28
|
x: number;
|
|
28
29
|
y: number;
|
|
@@ -43,7 +44,10 @@ export declare class SimulatorOptions {
|
|
|
43
44
|
enabled: boolean;
|
|
44
45
|
element: string;
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
geminiLivePanel: {
|
|
48
|
+
enabled: boolean;
|
|
49
|
+
element: string;
|
|
50
|
+
};
|
|
47
51
|
stereo: {
|
|
48
52
|
enabled: boolean;
|
|
49
53
|
};
|
|
@@ -14,6 +14,7 @@ export declare class AudioPlayer extends Script {
|
|
|
14
14
|
private categoryVolumes?;
|
|
15
15
|
private volume;
|
|
16
16
|
private category;
|
|
17
|
+
scheduleAheadTime: number;
|
|
17
18
|
constructor(options?: AudioPlayerOptions);
|
|
18
19
|
/**
|
|
19
20
|
* Sets the CategoryVolumes instance for this player to respect
|