@reactvision/react-viro 2.54.0 → 2.55.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 +85 -46
- package/android/react_viro/react_viro-release.aar +0 -0
- package/android/viro_renderer/viro_renderer-release.aar +0 -0
- package/components/AR/ViroARCamera.tsx +5 -0
- package/components/AR/ViroARImageMarker.tsx +5 -0
- package/components/AR/ViroARObjectMarker.tsx +5 -0
- package/components/AR/ViroARPlane.tsx +5 -0
- package/components/AR/ViroARPlaneSelector.tsx +5 -0
- package/components/AR/ViroARScene.tsx +5 -0
- package/components/AR/ViroARSceneNavigator.tsx +54 -0
- package/components/Studio/StudioARScene.tsx +368 -0
- package/components/Studio/StudioSceneNavigator.tsx +191 -0
- package/components/Studio/VRTStudioModule.ts +40 -0
- package/components/Studio/domain/animationRegistry.ts +86 -0
- package/components/Studio/domain/collisionBindingsRuntime.ts +93 -0
- package/components/Studio/domain/collisionPairKey.ts +15 -0
- package/components/Studio/domain/dragConfiguration.ts +48 -0
- package/components/Studio/domain/materialConfig.ts +276 -0
- package/components/Studio/domain/physicsConfig.ts +204 -0
- package/components/Studio/domain/sceneNavigationHandler.ts +150 -0
- package/components/Studio/domain/studioMaterials.ts +33 -0
- package/components/Studio/domain/triggerImageRegistry.ts +64 -0
- package/components/Studio/domain/useStudioShaderTimeUniforms.ts +51 -0
- package/components/Studio/domain/useStudioShaderViewportUniforms.ts +52 -0
- package/components/Studio/domain/viroNodeFactory.tsx +323 -0
- package/components/Studio/index.ts +18 -0
- package/components/Studio/types.ts +164 -0
- package/components/Types/ViroEvents.ts +53 -0
- package/components/Utilities/VRModuleOpenXR.ts +50 -0
- package/components/Utilities/VRQuestNavigatorBridge.ts +168 -0
- package/components/Utilities/ViroPlatform.ts +52 -0
- package/components/Utilities/ViroVersion.ts +1 -1
- package/components/Utilities/useAnySourceHover.ts +55 -0
- package/components/Utilities/useAnySourcePressed.ts +70 -0
- package/components/ViroQuestEntryPoint.tsx +79 -0
- package/components/ViroVRSceneNavigator.tsx +44 -19
- package/components/ViroXRSceneNavigator.tsx +217 -0
- package/components/VisionOS/ViroVisionOSModule.ts +93 -0
- package/dist/components/AR/ViroARCamera.d.ts +1 -1
- package/dist/components/AR/ViroARCamera.js +5 -0
- package/dist/components/AR/ViroARImageMarker.d.ts +1 -1
- package/dist/components/AR/ViroARImageMarker.js +5 -0
- package/dist/components/AR/ViroARObjectMarker.d.ts +1 -1
- package/dist/components/AR/ViroARObjectMarker.js +5 -0
- package/dist/components/AR/ViroARPlane.d.ts +1 -1
- package/dist/components/AR/ViroARPlane.js +5 -0
- package/dist/components/AR/ViroARPlaneSelector.d.ts +1 -1
- package/dist/components/AR/ViroARPlaneSelector.js +5 -0
- package/dist/components/AR/ViroARScene.d.ts +1 -1
- package/dist/components/AR/ViroARScene.js +5 -0
- package/dist/components/AR/ViroARSceneNavigator.d.ts +13 -0
- package/dist/components/AR/ViroARSceneNavigator.js +36 -0
- package/dist/components/Studio/StudioARScene.d.ts +15 -0
- package/dist/components/Studio/StudioARScene.js +299 -0
- package/dist/components/Studio/StudioSceneNavigator.d.ts +31 -0
- package/dist/components/Studio/StudioSceneNavigator.js +174 -0
- package/dist/components/Studio/VRTStudioModule.d.ts +15 -0
- package/dist/components/Studio/VRTStudioModule.js +31 -0
- package/dist/components/Studio/domain/animationRegistry.d.ts +11 -0
- package/dist/components/Studio/domain/animationRegistry.js +67 -0
- package/dist/components/Studio/domain/collisionBindingsRuntime.d.ts +21 -0
- package/dist/components/Studio/domain/collisionBindingsRuntime.js +54 -0
- package/dist/components/Studio/domain/collisionPairKey.d.ts +8 -0
- package/dist/components/Studio/domain/collisionPairKey.js +15 -0
- package/dist/components/Studio/domain/dragConfiguration.d.ts +20 -0
- package/dist/components/Studio/domain/dragConfiguration.js +37 -0
- package/dist/components/Studio/domain/materialConfig.d.ts +56 -0
- package/dist/components/Studio/domain/materialConfig.js +239 -0
- package/dist/components/Studio/domain/physicsConfig.d.ts +69 -0
- package/dist/components/Studio/domain/physicsConfig.js +165 -0
- package/dist/components/Studio/domain/sceneNavigationHandler.d.ts +12 -0
- package/dist/components/Studio/domain/sceneNavigationHandler.js +112 -0
- package/dist/components/Studio/domain/studioMaterials.d.ts +6 -0
- package/dist/components/Studio/domain/studioMaterials.js +30 -0
- package/dist/components/Studio/domain/triggerImageRegistry.d.ts +13 -0
- package/dist/components/Studio/domain/triggerImageRegistry.js +47 -0
- package/dist/components/Studio/domain/useStudioShaderTimeUniforms.d.ts +6 -0
- package/dist/components/Studio/domain/useStudioShaderTimeUniforms.js +48 -0
- package/dist/components/Studio/domain/useStudioShaderViewportUniforms.d.ts +6 -0
- package/dist/components/Studio/domain/useStudioShaderViewportUniforms.js +48 -0
- package/dist/components/Studio/domain/viroNodeFactory.d.ts +28 -0
- package/dist/components/Studio/domain/viroNodeFactory.js +193 -0
- package/dist/components/Studio/index.d.ts +3 -0
- package/dist/components/Studio/index.js +7 -0
- package/dist/components/Studio/types.d.ts +149 -0
- package/dist/components/Studio/types.js +4 -0
- package/dist/components/Types/ViroEvents.d.ts +49 -1
- package/dist/components/Types/ViroEvents.js +1 -0
- package/dist/components/Utilities/VRModuleOpenXR.d.ts +32 -0
- package/dist/components/Utilities/VRModuleOpenXR.js +44 -0
- package/dist/components/Utilities/VRQuestNavigatorBridge.d.ts +85 -0
- package/dist/components/Utilities/VRQuestNavigatorBridge.js +124 -0
- package/dist/components/Utilities/ViroPlatform.d.ts +10 -0
- package/dist/components/Utilities/ViroPlatform.js +43 -0
- package/dist/components/Utilities/ViroVersion.d.ts +1 -1
- package/dist/components/Utilities/ViroVersion.js +1 -1
- package/dist/components/Utilities/useAnySourceHover.d.ts +36 -0
- package/dist/components/Utilities/useAnySourceHover.js +48 -0
- package/dist/components/Utilities/useAnySourcePressed.d.ts +37 -0
- package/dist/components/Utilities/useAnySourcePressed.js +61 -0
- package/dist/components/ViroQuestEntryPoint.d.ts +13 -0
- package/dist/components/ViroQuestEntryPoint.js +104 -0
- package/dist/components/ViroVRSceneNavigator.d.ts +24 -10
- package/dist/components/ViroVRSceneNavigator.js +21 -18
- package/dist/components/ViroXRSceneNavigator.d.ts +54 -0
- package/dist/components/ViroXRSceneNavigator.js +173 -0
- package/dist/components/VisionOS/ViroVisionOSModule.d.ts +65 -0
- package/dist/components/VisionOS/ViroVisionOSModule.js +91 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +32 -2
- package/dist/plugins/withViro.d.ts +17 -1
- package/dist/plugins/withViroAndroid.js +312 -7
- package/dist/plugins/withViroIos.js +5 -0
- package/dist/plugins/withViroVisionOS.d.ts +24 -0
- package/dist/plugins/withViroVisionOS.js +265 -0
- package/index.ts +58 -0
- package/ios/ViroReact.podspec +13 -4
- package/ios/dist/ViroRenderer/ViroKit.framework/ARCoreCoreMLSemanticsResources.bundle/Info.plist +0 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/ARCoreResources.bundle/Info.plist +0 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROARSession.h +10 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROARSessioniOS.h +4 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROInputControllerBase.h +74 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROInputType.h +11 -3
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROPlatformUtil.h +13 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VRORenderer.h +8 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Info.plist +0 -0
- package/ios/dist/ViroRenderer/ViroKit.framework/Shaders.dat +1 -1
- package/ios/dist/ViroRenderer/ViroKit.framework/ViroKit +0 -0
- package/ios/dist/ViroRenderer/ViroKit.podspec +5 -0
- package/ios/dist/include/VRTARSceneNavigator.h +3 -0
- package/ios/dist/include/VRTStudioModule.h +6 -0
- package/ios/dist/lib/libViroReact.a +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerTriggerImageTargets = registerTriggerImageTargets;
|
|
4
|
+
exports.cleanupTriggerImageTargets = cleanupTriggerImageTargets;
|
|
5
|
+
const ViroARTrackingTargets_1 = require("../../AR/ViroARTrackingTargets");
|
|
6
|
+
const DEFAULT_PHYSICAL_WIDTH = 0.2; // meters
|
|
7
|
+
const DEFAULT_ORIENTATION = "Up";
|
|
8
|
+
/**
|
|
9
|
+
* Registers trigger image targets with ViroReact for image recognition.
|
|
10
|
+
* One target per asset with trigger_image_url.
|
|
11
|
+
* Must be called before rendering ViroARImageMarker components.
|
|
12
|
+
*
|
|
13
|
+
* @returns Map from trigger_image_url → target name for lookup in ViroARImageMarker
|
|
14
|
+
*/
|
|
15
|
+
function registerTriggerImageTargets(assets) {
|
|
16
|
+
const assetsWithTrigger = assets.filter((a) => !!a.trigger_image_url);
|
|
17
|
+
if (assetsWithTrigger.length === 0) {
|
|
18
|
+
return new Map();
|
|
19
|
+
}
|
|
20
|
+
const urlToTargetName = new Map();
|
|
21
|
+
const targets = {};
|
|
22
|
+
assetsWithTrigger.forEach((asset, index) => {
|
|
23
|
+
const targetName = `studio-trigger-${index}`;
|
|
24
|
+
urlToTargetName.set(asset.trigger_image_url, targetName);
|
|
25
|
+
targets[targetName] = {
|
|
26
|
+
source: { uri: asset.trigger_image_url },
|
|
27
|
+
orientation: asset.trigger_image_orientation ?? DEFAULT_ORIENTATION,
|
|
28
|
+
physicalWidth: asset.trigger_image_physical_width_m ?? DEFAULT_PHYSICAL_WIDTH,
|
|
29
|
+
type: "Image",
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
ViroARTrackingTargets_1.ViroARTrackingTargets.createTargets(targets);
|
|
33
|
+
return urlToTargetName;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Cleans up trigger image targets when the scene unmounts.
|
|
37
|
+
*/
|
|
38
|
+
function cleanupTriggerImageTargets(targetNames) {
|
|
39
|
+
targetNames.forEach((name) => {
|
|
40
|
+
try {
|
|
41
|
+
ViroARTrackingTargets_1.ViroARTrackingTargets.deleteTarget(name);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.warn(`[Studio] Failed to delete trigger target "${name}":`, error);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StudioAsset } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Drives the `time` shader uniform for materials that use animated presets.
|
|
4
|
+
* Uses `setInterval(16)` and `Date.now() % 1000000` like working Viro starter kits.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useStudioShaderTimeUniforms(assets: StudioAsset[]): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStudioShaderTimeUniforms = useStudioShaderTimeUniforms;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ViroMaterials_1 = require("../../Material/ViroMaterials");
|
|
6
|
+
const materialConfig_1 = require("./materialConfig");
|
|
7
|
+
/** ~60fps — matches Viro starter kit / shader docs. */
|
|
8
|
+
const TIME_TICK_MS = 16;
|
|
9
|
+
function computeTimeUniformPayload(assets) {
|
|
10
|
+
const names = [];
|
|
11
|
+
for (const asset of assets) {
|
|
12
|
+
if (asset.asset_type_name !== "3D-MODEL")
|
|
13
|
+
continue;
|
|
14
|
+
if (asset.material_config == null)
|
|
15
|
+
continue;
|
|
16
|
+
const config = (0, materialConfig_1.parseMaterialConfig)(asset.material_config);
|
|
17
|
+
if (!config || !(0, materialConfig_1.materialConfigNeedsTimeUniform)(config))
|
|
18
|
+
continue;
|
|
19
|
+
names.push((0, materialConfig_1.studioMaterialName)(asset.id));
|
|
20
|
+
}
|
|
21
|
+
names.sort();
|
|
22
|
+
return { key: names.join("|"), names };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Drives the `time` shader uniform for materials that use animated presets.
|
|
26
|
+
* Uses `setInterval(16)` and `Date.now() % 1000000` like working Viro starter kits.
|
|
27
|
+
*/
|
|
28
|
+
function useStudioShaderTimeUniforms(assets) {
|
|
29
|
+
const payload = (0, react_1.useMemo)(() => computeTimeUniformPayload(assets), [assets]);
|
|
30
|
+
const payloadRef = (0, react_1.useRef)(payload);
|
|
31
|
+
payloadRef.current = payload;
|
|
32
|
+
const applyTimeUniforms = (0, react_1.useCallback)(() => {
|
|
33
|
+
const { names } = payloadRef.current;
|
|
34
|
+
if (names.length === 0)
|
|
35
|
+
return;
|
|
36
|
+
const time = Date.now() % 1_000_000;
|
|
37
|
+
for (const name of names) {
|
|
38
|
+
ViroMaterials_1.ViroMaterials.updateShaderUniform(name, "time", "float", time);
|
|
39
|
+
}
|
|
40
|
+
}, []);
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
if (payload.names.length === 0)
|
|
43
|
+
return;
|
|
44
|
+
const id = setInterval(applyTimeUniforms, TIME_TICK_MS);
|
|
45
|
+
applyTimeUniforms();
|
|
46
|
+
return () => clearInterval(id);
|
|
47
|
+
}, [payload.key, applyTimeUniforms]);
|
|
48
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StudioAsset } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Pushes _rf_vpw / _rf_vph (physical pixel dimensions) to materials that sample the camera
|
|
4
|
+
* feed via gl_FragCoord. Called on mount and whenever the screen dimensions change.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useStudioShaderViewportUniforms(assets: StudioAsset[]): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStudioShaderViewportUniforms = useStudioShaderViewportUniforms;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const ViroMaterials_1 = require("../../Material/ViroMaterials");
|
|
7
|
+
const materialConfig_1 = require("./materialConfig");
|
|
8
|
+
function computeViewportPayload(assets) {
|
|
9
|
+
const names = [];
|
|
10
|
+
for (const asset of assets) {
|
|
11
|
+
if (asset.asset_type_name !== "3D-MODEL")
|
|
12
|
+
continue;
|
|
13
|
+
if (asset.material_config == null)
|
|
14
|
+
continue;
|
|
15
|
+
const config = (0, materialConfig_1.parseMaterialConfig)(asset.material_config);
|
|
16
|
+
if (!config || !(0, materialConfig_1.materialConfigNeedsViewportUniforms)(config))
|
|
17
|
+
continue;
|
|
18
|
+
names.push((0, materialConfig_1.studioMaterialName)(asset.id));
|
|
19
|
+
}
|
|
20
|
+
names.sort();
|
|
21
|
+
return { key: names.join("|"), names };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Pushes _rf_vpw / _rf_vph (physical pixel dimensions) to materials that sample the camera
|
|
25
|
+
* feed via gl_FragCoord. Called on mount and whenever the screen dimensions change.
|
|
26
|
+
*/
|
|
27
|
+
function useStudioShaderViewportUniforms(assets) {
|
|
28
|
+
const payload = (0, react_1.useMemo)(() => computeViewportPayload(assets), [assets]);
|
|
29
|
+
const pushViewport = (0, react_1.useCallback)(() => {
|
|
30
|
+
if (payload.names.length === 0)
|
|
31
|
+
return;
|
|
32
|
+
const { width, height } = react_native_1.Dimensions.get("screen");
|
|
33
|
+
const pr = react_native_1.PixelRatio.get();
|
|
34
|
+
const pw = width * pr;
|
|
35
|
+
const ph = height * pr;
|
|
36
|
+
for (const name of payload.names) {
|
|
37
|
+
ViroMaterials_1.ViroMaterials.updateShaderUniform(name, "_rf_vpw", "float", pw);
|
|
38
|
+
ViroMaterials_1.ViroMaterials.updateShaderUniform(name, "_rf_vph", "float", ph);
|
|
39
|
+
}
|
|
40
|
+
}, [payload]);
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
if (payload.names.length === 0)
|
|
43
|
+
return;
|
|
44
|
+
pushViewport();
|
|
45
|
+
const sub = react_native_1.Dimensions.addEventListener("change", pushViewport);
|
|
46
|
+
return () => sub.remove();
|
|
47
|
+
}, [payload.key, pushViewport]);
|
|
48
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StudioAnimation, StudioAsset, StudioSceneMeta, ViroAnimationProp } from "../types";
|
|
3
|
+
type SceneNavigator = any;
|
|
4
|
+
export type NodeConfig = {
|
|
5
|
+
position: [number, number, number];
|
|
6
|
+
rotation: [number, number, number];
|
|
7
|
+
scale: [number, number, number];
|
|
8
|
+
dragType?: "FixedDistance" | "FixedDistanceOrigin" | "FixedToWorld" | "FixedToPlane";
|
|
9
|
+
dragPlane?: {
|
|
10
|
+
planePoint: [number, number, number];
|
|
11
|
+
planeNormal: [number, number, number];
|
|
12
|
+
maxDistance: number;
|
|
13
|
+
};
|
|
14
|
+
physicsBody?: Record<string, unknown>;
|
|
15
|
+
viroTag?: string;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
animation?: ViroAnimationProp;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Derives the transform config for an asset.
|
|
21
|
+
* Clamps Z to -2 for non-trigger assets to guarantee visibility.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createNodeConfig(asset: StudioAsset, sceneNavigator: SceneNavigator | undefined, animations: StudioAnimation[], scene: StudioSceneMeta | null, onAnimationTrigger?: (targetAssetId: string, animKey: string) => void, animationStates?: Record<string, ViroAnimationProp>, onSceneChange?: (sceneId: string, sceneName: string) => void): NodeConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Creates the appropriate Viro component for a StudioAsset.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createNode(asset: StudioAsset, sceneNavigator: SceneNavigator | undefined, animations: StudioAnimation[], scene: StudioSceneMeta | null, onAnimationTrigger?: (targetAssetId: string, animKey: string) => void, animationStates?: Record<string, ViroAnimationProp>, onAssetLoaded?: (id: string) => void, onCollision?: (viroTag: string, collidedPoint: [number, number, number], collidedNormal: [number, number, number]) => void, onSceneChange?: (sceneId: string, sceneName: string) => void): React.ReactElement | null;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createNodeConfig = createNodeConfig;
|
|
37
|
+
exports.createNode = createNode;
|
|
38
|
+
const React = __importStar(require("react"));
|
|
39
|
+
const react_native_1 = require("react-native");
|
|
40
|
+
const Viro3DObject_1 = require("../../Viro3DObject");
|
|
41
|
+
const ViroImage_1 = require("../../ViroImage");
|
|
42
|
+
const ViroText_1 = require("../../ViroText");
|
|
43
|
+
const ViroVideo_1 = require("../../ViroVideo");
|
|
44
|
+
const sceneNavigationHandler_1 = require("./sceneNavigationHandler");
|
|
45
|
+
const materialConfig_1 = require("./materialConfig");
|
|
46
|
+
const dragConfiguration_1 = require("./dragConfiguration");
|
|
47
|
+
const physicsConfig_1 = require("./physicsConfig");
|
|
48
|
+
/**
|
|
49
|
+
* Derives the transform config for an asset.
|
|
50
|
+
* Clamps Z to -2 for non-trigger assets to guarantee visibility.
|
|
51
|
+
*/
|
|
52
|
+
function createNodeConfig(asset, sceneNavigator, animations, scene, onAnimationTrigger, animationStates, onSceneChange) {
|
|
53
|
+
const hasTriggerImage = !!asset.trigger_image_url;
|
|
54
|
+
let posZ = asset.position_z ?? -2;
|
|
55
|
+
if (!hasTriggerImage && posZ > -0.5) {
|
|
56
|
+
console.warn(`[Studio/NodeFactory] Asset "${asset.name}" Z=${posZ} too close, clamping to -2`);
|
|
57
|
+
posZ = -2;
|
|
58
|
+
}
|
|
59
|
+
const position = [
|
|
60
|
+
asset.position_x ?? 0,
|
|
61
|
+
asset.position_y ?? 0,
|
|
62
|
+
posZ,
|
|
63
|
+
];
|
|
64
|
+
// Apply trigger image orientation offset to rotation Z
|
|
65
|
+
let rotationZ = asset.rotation_z ?? 0;
|
|
66
|
+
if (hasTriggerImage && asset.trigger_image_orientation) {
|
|
67
|
+
const offsets = {
|
|
68
|
+
Left: -90,
|
|
69
|
+
Right: 90,
|
|
70
|
+
Down: 180,
|
|
71
|
+
Up: 0,
|
|
72
|
+
};
|
|
73
|
+
rotationZ += offsets[asset.trigger_image_orientation] ?? 0;
|
|
74
|
+
}
|
|
75
|
+
const rotation = [
|
|
76
|
+
asset.rotation_x ?? 0,
|
|
77
|
+
asset.rotation_y ?? 0,
|
|
78
|
+
rotationZ,
|
|
79
|
+
];
|
|
80
|
+
let scaleValue = asset.scale ?? 1;
|
|
81
|
+
if (scaleValue < 0.01)
|
|
82
|
+
scaleValue = 0.1;
|
|
83
|
+
if (scaleValue > 10)
|
|
84
|
+
scaleValue = 2;
|
|
85
|
+
const scale = [scaleValue, scaleValue, scaleValue];
|
|
86
|
+
const dragType = dragConfiguration_1.DragConfiguration.getDragType(asset, scene);
|
|
87
|
+
let dragPlane;
|
|
88
|
+
if (dragType === "FixedToPlane") {
|
|
89
|
+
dragPlane = dragConfiguration_1.DragConfiguration.getDragPlane(scene?.plane_direction ?? "Horizontal", position);
|
|
90
|
+
}
|
|
91
|
+
const parsedPhysics = (0, physicsConfig_1.parsePhysicsBodyConfig)(asset.physics_config);
|
|
92
|
+
const physicsBody = parsedPhysics ? (0, physicsConfig_1.buildViroPhysicsBody)(parsedPhysics) : undefined;
|
|
93
|
+
const viroTag = parsedPhysics ? asset.id : undefined;
|
|
94
|
+
const onClick = createOnClickHandler(asset, sceneNavigator, animations, onAnimationTrigger, onSceneChange);
|
|
95
|
+
const animation = animationStates?.[asset.id];
|
|
96
|
+
return { position, rotation, scale, dragType, dragPlane, physicsBody, viroTag, onClick, animation };
|
|
97
|
+
}
|
|
98
|
+
function createOnClickHandler(asset, sceneNavigator, animations, onAnimationTrigger, onSceneChange) {
|
|
99
|
+
const fn = asset.scene_function;
|
|
100
|
+
if (!fn)
|
|
101
|
+
return undefined;
|
|
102
|
+
if (fn.function_type === "NAVIGATION" && !fn.scene_navigation?.navigate_to) {
|
|
103
|
+
console.warn(`[Studio] Asset "${asset.name}" has NAVIGATION but no target scene`);
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
if (fn.function_type === "ALERT" && !fn.scene_alert) {
|
|
107
|
+
console.warn(`[Studio] Asset "${asset.name}" has ALERT but no alert data`);
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
if (fn.function_type === "ANIMATION" && !fn.scene_animation) {
|
|
111
|
+
console.warn(`[Studio] Asset "${asset.name}" has ANIMATION but no animation data`);
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
return () => (0, sceneNavigationHandler_1.executeFunctionWithRelations)(fn, sceneNavigator, animations, onAnimationTrigger, 0, onSceneChange);
|
|
115
|
+
}
|
|
116
|
+
/** Resolves asset type from asset_type_name. */
|
|
117
|
+
function resolveType(asset) {
|
|
118
|
+
return asset.asset_type_name ?? null;
|
|
119
|
+
}
|
|
120
|
+
/** Infers 3D model format from file extension. */
|
|
121
|
+
function inferModelType(url) {
|
|
122
|
+
const ext = url.toLowerCase().split(".").pop();
|
|
123
|
+
if (ext === "gltf")
|
|
124
|
+
return "GLTF";
|
|
125
|
+
if (ext === "obj")
|
|
126
|
+
return "OBJ";
|
|
127
|
+
if (ext === "vrx")
|
|
128
|
+
return "VRX";
|
|
129
|
+
return "GLB";
|
|
130
|
+
}
|
|
131
|
+
function create3DObject(asset, config, onAssetLoaded, onCollision) {
|
|
132
|
+
if (!asset.file_url) {
|
|
133
|
+
console.warn(`[Studio] 3D model "${asset.name}" has no file_url`);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
const modelType = inferModelType(asset.file_url);
|
|
137
|
+
// Android: slightly reduce scale for stability
|
|
138
|
+
const scale = react_native_1.Platform.OS === "android"
|
|
139
|
+
? [
|
|
140
|
+
config.scale[0] * 0.8,
|
|
141
|
+
config.scale[1] * 0.8,
|
|
142
|
+
config.scale[2] * 0.8,
|
|
143
|
+
]
|
|
144
|
+
: config.scale;
|
|
145
|
+
const hasMaterialConfig = (0, materialConfig_1.parseMaterialConfig)(asset.material_config) !== null;
|
|
146
|
+
const shaderOverrides = hasMaterialConfig ? [(0, materialConfig_1.studioMaterialName)(asset.id)] : undefined;
|
|
147
|
+
return (<Viro3DObject_1.Viro3DObject key={asset.id} source={{ uri: asset.file_url }} position={config.position} rotation={config.rotation} scale={scale} type={modelType} dragType={config.dragType} dragPlane={config.dragPlane} animation={config.animation} onClick={config.onClick} renderingOrder={react_native_1.Platform.OS === "android" ? 1 : 0} onLoadEnd={() => onAssetLoaded?.(asset.id)} onError={(e) => console.error(`[Studio] 3D model "${asset.name}" error:`, e)}
|
|
148
|
+
// Viro derives native canDrag from `onDrag != undefined`; without this prop
|
|
149
|
+
// the drag recognizer is never attached, even when dragType is set.
|
|
150
|
+
{...(config.dragType ? { onDrag: () => { } } : {})} {...(shaderOverrides ? { shaderOverrides } : {})} {...(config.physicsBody ? { physicsBody: config.physicsBody, viroTag: config.viroTag } : {})} {...(onCollision ? { onCollision: onCollision } : {})}/>);
|
|
151
|
+
}
|
|
152
|
+
function createImage(asset, config, onAssetLoaded) {
|
|
153
|
+
if (!asset.file_url) {
|
|
154
|
+
console.warn(`[Studio] Image "${asset.name}" has no file_url`);
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return (<ViroImage_1.ViroImage key={asset.id} source={{ uri: asset.file_url }} position={config.position} rotation={config.rotation} scale={config.scale} dragType={config.dragType} animation={config.animation} onClick={config.onClick} onLoadEnd={() => onAssetLoaded?.(asset.id)} onError={(e) => console.error(`[Studio] Image "${asset.name}" error:`, e)} {...(config.dragType ? { onDrag: () => { } } : {})}/>);
|
|
158
|
+
}
|
|
159
|
+
function createText(asset, config) {
|
|
160
|
+
return (<ViroText_1.ViroText key={asset.id} text={asset.name ?? ""} position={config.position} rotation={config.rotation} scale={config.scale} dragType={config.dragType} animation={config.animation} onClick={config.onClick} style={{
|
|
161
|
+
fontFamily: "Arial",
|
|
162
|
+
fontSize: 20,
|
|
163
|
+
color: "#FFFFFF",
|
|
164
|
+
textAlign: "center",
|
|
165
|
+
}} {...(config.dragType ? { onDrag: () => { } } : {})}/>);
|
|
166
|
+
}
|
|
167
|
+
function createVideo(asset, config) {
|
|
168
|
+
if (!asset.file_url) {
|
|
169
|
+
console.warn(`[Studio] Video "${asset.name}" has no file_url`);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return (<ViroVideo_1.ViroVideo key={asset.id} source={{ uri: asset.file_url }} position={config.position} rotation={config.rotation} scale={config.scale} dragType={config.dragType} animation={config.animation} onClick={config.onClick} loop={true} muted={false} onError={(e) => console.error(`[Studio] Video "${asset.name}" error:`, e)} {...(config.dragType ? { onDrag: () => { } } : {})}/>);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Creates the appropriate Viro component for a StudioAsset.
|
|
176
|
+
*/
|
|
177
|
+
function createNode(asset, sceneNavigator, animations, scene, onAnimationTrigger, animationStates, onAssetLoaded, onCollision, onSceneChange) {
|
|
178
|
+
const type = resolveType(asset);
|
|
179
|
+
const config = createNodeConfig(asset, sceneNavigator, animations, scene, onAnimationTrigger, animationStates, onSceneChange);
|
|
180
|
+
switch (type) {
|
|
181
|
+
case "3D-MODEL":
|
|
182
|
+
return create3DObject(asset, config, onAssetLoaded, onCollision);
|
|
183
|
+
case "IMAGE":
|
|
184
|
+
return createImage(asset, config, onAssetLoaded);
|
|
185
|
+
case "TEXT":
|
|
186
|
+
return createText(asset, config);
|
|
187
|
+
case "VIDEO":
|
|
188
|
+
return createVideo(asset, config);
|
|
189
|
+
default:
|
|
190
|
+
console.warn(`[Studio] Unknown asset type "${type}" for "${asset.name}"`);
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { StudioARScene } from "./StudioARScene";
|
|
2
|
+
export { StudioSceneNavigator } from "./StudioSceneNavigator";
|
|
3
|
+
export type { StudioAnimation, StudioAsset, StudioCollisionBinding, StudioProjectApiResponse, StudioProjectAsset, StudioProjectMeta, StudioProjectOpeningScene, StudioProjectOverview, StudioProjectSceneSummary, StudioSceneCreatedBy, StudioSceneFunction, StudioSceneMeta, StudioSceneResponse, ViroAnimationProp, } from "./types";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StudioSceneNavigator = exports.StudioARScene = void 0;
|
|
4
|
+
var StudioARScene_1 = require("./StudioARScene");
|
|
5
|
+
Object.defineProperty(exports, "StudioARScene", { enumerable: true, get: function () { return StudioARScene_1.StudioARScene; } });
|
|
6
|
+
var StudioSceneNavigator_1 = require("./StudioSceneNavigator");
|
|
7
|
+
Object.defineProperty(exports, "StudioSceneNavigator", { enumerable: true, get: function () { return StudioSceneNavigator_1.StudioSceneNavigator; } });
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export interface StudioSceneCreatedBy {
|
|
2
|
+
id: string;
|
|
3
|
+
first_name: string | null;
|
|
4
|
+
last_name: string | null;
|
|
5
|
+
}
|
|
6
|
+
export interface StudioSceneMeta {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string | null;
|
|
9
|
+
belongs_to_project: string;
|
|
10
|
+
plane_detection: string | null;
|
|
11
|
+
plane_direction: string | null;
|
|
12
|
+
on_load_function: string | null;
|
|
13
|
+
physics_world_config: Record<string, unknown> | null;
|
|
14
|
+
created_at: string;
|
|
15
|
+
created_by: StudioSceneCreatedBy | null;
|
|
16
|
+
}
|
|
17
|
+
export interface StudioProjectMeta {
|
|
18
|
+
id: string;
|
|
19
|
+
occlusion_mode: "NONE" | "PEOPLEONLY" | "DEPTHBASED";
|
|
20
|
+
}
|
|
21
|
+
export interface StudioSceneFunction {
|
|
22
|
+
id: string;
|
|
23
|
+
scene: string;
|
|
24
|
+
function_type: "NAVIGATION" | "ALERT" | "ANIMATION";
|
|
25
|
+
navigation: string | null;
|
|
26
|
+
alert: string | null;
|
|
27
|
+
animation: string | null;
|
|
28
|
+
scene_navigation: {
|
|
29
|
+
id: string;
|
|
30
|
+
navigate_to: string;
|
|
31
|
+
} | null;
|
|
32
|
+
scene_alert: {
|
|
33
|
+
id: string;
|
|
34
|
+
alert_title: string | null;
|
|
35
|
+
alert_message: string | null;
|
|
36
|
+
} | null;
|
|
37
|
+
scene_animation: {
|
|
38
|
+
id: string;
|
|
39
|
+
animation_key: string;
|
|
40
|
+
duration_ms: number | null;
|
|
41
|
+
delay_ms: number | null;
|
|
42
|
+
properties: Record<string, unknown>;
|
|
43
|
+
} | null;
|
|
44
|
+
}
|
|
45
|
+
export interface StudioAsset {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string | null;
|
|
48
|
+
description: string | null;
|
|
49
|
+
file_url: string | null;
|
|
50
|
+
file_size: number | null;
|
|
51
|
+
asset_type_name: "3D-MODEL" | "TEXT" | "IMAGE" | "VIDEO" | null;
|
|
52
|
+
position_x: number | null;
|
|
53
|
+
position_y: number | null;
|
|
54
|
+
position_z: number | null;
|
|
55
|
+
rotation_x: number | null;
|
|
56
|
+
rotation_y: number | null;
|
|
57
|
+
rotation_z: number | null;
|
|
58
|
+
scale: number | null;
|
|
59
|
+
latitude: number | null;
|
|
60
|
+
longitude: number | null;
|
|
61
|
+
is_draggable: boolean;
|
|
62
|
+
trigger_image_url: string | null;
|
|
63
|
+
trigger_image_orientation: "Up" | "Down" | "Left" | "Right" | null;
|
|
64
|
+
trigger_image_physical_width_m: number | null;
|
|
65
|
+
material_config: Record<string, unknown> | null;
|
|
66
|
+
physics_config: Record<string, unknown> | null;
|
|
67
|
+
on_click_function: string | null;
|
|
68
|
+
asset_id: string | null;
|
|
69
|
+
created_at: string;
|
|
70
|
+
updated_at: string;
|
|
71
|
+
scene_function: StudioSceneFunction | null;
|
|
72
|
+
}
|
|
73
|
+
export interface StudioCollisionBinding {
|
|
74
|
+
id: string;
|
|
75
|
+
scene_id: string;
|
|
76
|
+
function_id: string;
|
|
77
|
+
asset_x_id: string;
|
|
78
|
+
asset_y_id: string;
|
|
79
|
+
scene_function: StudioSceneFunction;
|
|
80
|
+
}
|
|
81
|
+
export interface StudioAnimation {
|
|
82
|
+
id: string;
|
|
83
|
+
scene_id: string;
|
|
84
|
+
target_asset_id: string;
|
|
85
|
+
animation_key: string;
|
|
86
|
+
properties: Record<string, unknown>;
|
|
87
|
+
duration_ms: number | null;
|
|
88
|
+
delay_ms: number | null;
|
|
89
|
+
easing: "Linear" | "EaseIn" | "EaseOut" | "EaseInEaseOut" | "Bounce" | null;
|
|
90
|
+
loop: boolean;
|
|
91
|
+
interruptible: boolean;
|
|
92
|
+
on_start_function: string | null;
|
|
93
|
+
on_finish_function: string | null;
|
|
94
|
+
}
|
|
95
|
+
export interface StudioProjectAsset {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string | null;
|
|
98
|
+
url: string | null;
|
|
99
|
+
}
|
|
100
|
+
export interface StudioProjectSceneSummary {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string | null;
|
|
103
|
+
created_at: string;
|
|
104
|
+
created_by: StudioSceneCreatedBy | null;
|
|
105
|
+
assets: StudioProjectAsset[];
|
|
106
|
+
}
|
|
107
|
+
export interface StudioProjectOpeningScene {
|
|
108
|
+
id: string;
|
|
109
|
+
name: string | null;
|
|
110
|
+
}
|
|
111
|
+
export interface StudioProjectOverview {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
thumbnail: string | null;
|
|
115
|
+
occlusion_mode: "NONE" | "PEOPLEONLY" | "DEPTHBASED";
|
|
116
|
+
created_at: string;
|
|
117
|
+
created_by: StudioSceneCreatedBy | null;
|
|
118
|
+
opening_scene: StudioProjectOpeningScene | null;
|
|
119
|
+
scenes: StudioProjectSceneSummary[];
|
|
120
|
+
}
|
|
121
|
+
/** Top-level response from GET /functions/v1/projects/{project_id} (after JSON.parse) */
|
|
122
|
+
export interface StudioProjectApiResponse {
|
|
123
|
+
project: StudioProjectOverview;
|
|
124
|
+
meta: {
|
|
125
|
+
request_id: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** Top-level response from GET /functions/v1/scenes/{scene_id} (after JSON.parse) */
|
|
129
|
+
export interface StudioSceneResponse {
|
|
130
|
+
scene: StudioSceneMeta;
|
|
131
|
+
project: StudioProjectMeta;
|
|
132
|
+
assets: StudioAsset[];
|
|
133
|
+
collision_bindings: StudioCollisionBinding[];
|
|
134
|
+
animations: StudioAnimation[];
|
|
135
|
+
functions: StudioSceneFunction[];
|
|
136
|
+
meta: {
|
|
137
|
+
request_id: string;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** Viro animation prop shape passed to Viro components */
|
|
141
|
+
export type ViroAnimationProp = {
|
|
142
|
+
name: string;
|
|
143
|
+
run: boolean;
|
|
144
|
+
loop: boolean;
|
|
145
|
+
interruptible: boolean;
|
|
146
|
+
delay: number;
|
|
147
|
+
onStart?: () => void;
|
|
148
|
+
onFinish?: () => void;
|
|
149
|
+
};
|
|
@@ -100,7 +100,8 @@ export type ViroPlatformInfo = {
|
|
|
100
100
|
};
|
|
101
101
|
export declare enum ViroPlatformTypes {
|
|
102
102
|
GVR = "gvr",
|
|
103
|
-
GEAR_VR = "ovr-mobile"
|
|
103
|
+
GEAR_VR = "ovr-mobile",
|
|
104
|
+
QUEST = "quest"
|
|
104
105
|
}
|
|
105
106
|
export declare enum ViroHeadsetTypes {
|
|
106
107
|
CARDBOARD = "cardboard",
|
|
@@ -135,6 +136,53 @@ export type ViroExitViroEvent = {};
|
|
|
135
136
|
export type ViroErrorEvent = {
|
|
136
137
|
error: Error;
|
|
137
138
|
};
|
|
139
|
+
/** ===========================================================================
|
|
140
|
+
* Quest / OpenXR Hand Tracking Types (M4)
|
|
141
|
+
* ============================================================================ */
|
|
142
|
+
export type ViroJoint = {
|
|
143
|
+
position: Viro3DPoint;
|
|
144
|
+
/** Sphere radius representing finger pad size (meters). */
|
|
145
|
+
radius: number;
|
|
146
|
+
};
|
|
147
|
+
export type ViroHandJoints = {
|
|
148
|
+
wrist: ViroJoint;
|
|
149
|
+
thumbMetacarpal: ViroJoint;
|
|
150
|
+
thumbProximal: ViroJoint;
|
|
151
|
+
thumbDistal: ViroJoint;
|
|
152
|
+
thumbTip: ViroJoint;
|
|
153
|
+
indexMetacarpal: ViroJoint;
|
|
154
|
+
indexProximal: ViroJoint;
|
|
155
|
+
indexIntermediate: ViroJoint;
|
|
156
|
+
indexDistal: ViroJoint;
|
|
157
|
+
indexTip: ViroJoint;
|
|
158
|
+
middleMetacarpal: ViroJoint;
|
|
159
|
+
middleProximal: ViroJoint;
|
|
160
|
+
middleIntermediate: ViroJoint;
|
|
161
|
+
middleDistal: ViroJoint;
|
|
162
|
+
middleTip: ViroJoint;
|
|
163
|
+
ringMetacarpal: ViroJoint;
|
|
164
|
+
ringProximal: ViroJoint;
|
|
165
|
+
ringIntermediate: ViroJoint;
|
|
166
|
+
ringDistal: ViroJoint;
|
|
167
|
+
ringTip: ViroJoint;
|
|
168
|
+
littleMetacarpal: ViroJoint;
|
|
169
|
+
littleProximal: ViroJoint;
|
|
170
|
+
littleIntermediate: ViroJoint;
|
|
171
|
+
littleDistal: ViroJoint;
|
|
172
|
+
littleTip: ViroJoint;
|
|
173
|
+
};
|
|
174
|
+
export type ViroHandPinchEvent = {
|
|
175
|
+
hand: "left" | "right";
|
|
176
|
+
/** World-space position of the pinch point (midpoint between thumb tip and index tip). */
|
|
177
|
+
position: Viro3DPoint;
|
|
178
|
+
/** Pinch strength [0..1] from XR_FB_hand_tracking_aim, or 1.0 on pinch-complete fallback. */
|
|
179
|
+
pinchStrength: number;
|
|
180
|
+
};
|
|
181
|
+
/** Per-frame skeletal hand data dispatched via onHandUpdate. null when hand is not tracked. */
|
|
182
|
+
export type ViroHandUpdateEvent = {
|
|
183
|
+
left: ViroHandJoints | null;
|
|
184
|
+
right: ViroHandJoints | null;
|
|
185
|
+
};
|
|
138
186
|
/** ===========================================================================
|
|
139
187
|
* Viro Animation Events
|
|
140
188
|
* ============================================================================ */
|
|
@@ -35,6 +35,7 @@ var ViroPlatformTypes;
|
|
|
35
35
|
(function (ViroPlatformTypes) {
|
|
36
36
|
ViroPlatformTypes["GVR"] = "gvr";
|
|
37
37
|
ViroPlatformTypes["GEAR_VR"] = "ovr-mobile";
|
|
38
|
+
ViroPlatformTypes["QUEST"] = "quest";
|
|
38
39
|
})(ViroPlatformTypes || (exports.ViroPlatformTypes = ViroPlatformTypes = {}));
|
|
39
40
|
var ViroHeadsetTypes;
|
|
40
41
|
(function (ViroHeadsetTypes) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finishes VRActivity and returns the user to the panel (MainActivity).
|
|
3
|
+
* Safe to call on any platform — no-op when VRLauncher is unavailable.
|
|
4
|
+
*/
|
|
5
|
+
export declare function exitVRScene(): void;
|
|
6
|
+
export type VRModuleOpenXRType = {
|
|
7
|
+
recenterTracking?: (viewTag: number) => void;
|
|
8
|
+
setPassthroughEnabled?: (viewTag: number, enabled: boolean) => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Typed reference to the VRModuleOpenXR native module.
|
|
12
|
+
* undefined when not running on Meta Quest (no-op calls are safe via optional chaining).
|
|
13
|
+
*/
|
|
14
|
+
export declare const VRModuleOpenXR: VRModuleOpenXRType | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the live viewTag of the ViroVRSceneNavigator running in VRActivity,
|
|
17
|
+
* kept in sync via VRQuestNavigatorBridge. null until ViroQuestEntryPoint has
|
|
18
|
+
* mounted and published the tag.
|
|
19
|
+
*
|
|
20
|
+
* Use this inside VR scenes when you need to call VRModuleOpenXR methods:
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* function MyVRScene() {
|
|
24
|
+
* const viewTag = useVRViewTag();
|
|
25
|
+
* const recenter = () => {
|
|
26
|
+
* if (viewTag != null) VRModuleOpenXR?.recenterTracking?.(viewTag);
|
|
27
|
+
* };
|
|
28
|
+
* return <ViroScene>...</ViroScene>;
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function useVRViewTag(): number | null;
|