Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import { useFrame, useThree } from '@react-three/fiber';
|
import { useFrame, useThree } from '@react-three/fiber';
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
|
// DEVKIT: remove this import + the fake-input block in useFrame to strip devkit
|
||||||
|
import { fakeInput, isFakeActive } from '@/devkit/fakeInputStore';
|
||||||
|
|
||||||
export interface GrabState {
|
export interface GrabState {
|
||||||
/** Analog grip pressure (0..1) */
|
/** Analog grip pressure (0..1) */
|
||||||
@@ -50,6 +52,26 @@ export function useControllerGrab() {
|
|||||||
const { gl } = useThree();
|
const { gl } = useThree();
|
||||||
|
|
||||||
useFrame((_state, _delta, frame: XRFrame | undefined) => {
|
useFrame((_state, _delta, frame: XRFrame | undefined) => {
|
||||||
|
// DEVKIT: fake-input branch — bypasses real WebXR when SimXR is active.
|
||||||
|
if (isFakeActive()) {
|
||||||
|
for (const hand of ['left', 'right'] as const) {
|
||||||
|
const fake = fakeInput[hand];
|
||||||
|
const slot = ref.current[hand];
|
||||||
|
slot.gripValue = fake.gripValue;
|
||||||
|
slot.triggerValue = fake.triggerValue;
|
||||||
|
slot.hasPose = fake.hasPose;
|
||||||
|
slot.gripWorld.copy(fake.gripWorld);
|
||||||
|
if (!slot.isGrabbing && fake.gripValue > GRAB_ON) {
|
||||||
|
slot.isGrabbing = true;
|
||||||
|
console.log(`[XR][grab] ▶ ${hand} START (fake v=${fake.gripValue.toFixed(2)})`);
|
||||||
|
} else if (slot.isGrabbing && fake.gripValue < GRAB_OFF) {
|
||||||
|
slot.isGrabbing = false;
|
||||||
|
console.log(`[XR][grab] ◼ ${hand} END (fake)`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!frame) return;
|
if (!frame) return;
|
||||||
const session = frame.session;
|
const session = frame.session;
|
||||||
const referenceSpace = gl.xr.getReferenceSpace();
|
const referenceSpace = gl.xr.getReferenceSpace();
|
||||||
|
|||||||
Reference in New Issue
Block a user