@vitessce/dev 3.9.6 → 4.0.0-test.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/dist/GeometryAndMeshXR-Oj2zI_sI.js +245 -0
- package/dist/OrbitControls-5ELNF_nQ.js +11215 -0
- package/dist/{ReactNeuroglancer-5eQa4brk.js → ReactNeuroglancer-Bs7JMUO5.js} +2 -2
- package/dist/XREnterButton-CIzkyQe9.js +52 -0
- package/dist/XRSceneComponents-44cQ-EFB.js +62 -0
- package/dist/XRWrapper-CPiZ4M25.js +10 -0
- package/dist/{deflate-BlfSi-73.js → deflate-Ddy50BQC.js} +1 -1
- package/dist/emulate-CZbU4bg1.js +36969 -0
- package/dist/{higlass-Dzj0Wtv9.js → higlass-D7Nr2NjU.js} +42238 -38951
- package/dist/{troika-three-text.esm-IXbnNvXc.js → index-B_VSuhac.js} +7661 -2009
- package/dist/{index-Cz_XfJLz.js → index-C9uEW-7L.js} +2 -2
- package/dist/{index-GnGmMble.js → index-CdO3jExn.js} +5339 -4849
- package/dist/index-D3JEwl5a.js +57 -0
- package/dist/index.js +38 -38
- package/dist/{jpeg-GTyf0pdQ.js → jpeg-DQVF89G5.js} +1 -1
- package/dist/{lerc-Cxsf6swu.js → lerc-BcM7iRo4.js} +1 -1
- package/dist/living_room-DmqUeqz8.js +14 -0
- package/dist/{lzw-C4E5VmNh.js → lzw-DJUuf0zY.js} +1 -1
- package/dist/meeting_room-C6Rq8maw.js +14 -0
- package/dist/music_room-Dg5mhyYT.js +14 -0
- package/dist/office_large-ubYYC5Xo.js +14 -0
- package/dist/office_small-CWkD-Rha.js +14 -0
- package/dist/{packbits-CJAiTkd4.js → packbits-LM83yS7N.js} +1 -1
- package/dist/{raw-D9awu0AB.js → raw-CXfphBZa.js} +1 -1
- package/dist/ray-grab-CZLm2XVj.js +5607 -0
- package/dist/{webimage-Ca1vS7aF.js → webimage-DMjnadGD.js} +1 -1
- package/dist/xrStore-BXas99tA.js +10 -0
- package/package.json +5 -5
- package/dist/OrbitControls-L6I9M6QX.js +0 -18694
- package/dist/index-CsQFLn-E.js +0 -9854
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { M as Matrix4, V as Vector3, j as jsxRuntimeExports, F as FrontSide, a as Box3 } from "./index-CdO3jExn.js";
|
|
2
|
+
import { useRef, useEffect, useState } from "react";
|
|
3
|
+
import { M as useXR, s as useXRInputSourceState } from "./ray-grab-CZLm2XVj.js";
|
|
4
|
+
import { i as isValidGeometrySize, M as MeasureLine, s as stringifyLineData, B as Bvh } from "./index-B_VSuhac.js";
|
|
5
|
+
import { u as useThree, a as useFrame } from "./OrbitControls-5ELNF_nQ.js";
|
|
6
|
+
function getHandJoint(hand, jointName) {
|
|
7
|
+
return hand.get(jointName);
|
|
8
|
+
}
|
|
9
|
+
function getJointPosition(hand, jointName, frame, refSpace) {
|
|
10
|
+
if (!hand?.inputSource?.hand)
|
|
11
|
+
return null;
|
|
12
|
+
const jointSpace = getHandJoint(hand.inputSource.hand, jointName);
|
|
13
|
+
if (!jointSpace)
|
|
14
|
+
return null;
|
|
15
|
+
const pose = frame.getJointPose?.(jointSpace, refSpace);
|
|
16
|
+
if (!pose)
|
|
17
|
+
return null;
|
|
18
|
+
return new Vector3(pose.transform.position.x, pose.transform.position.y, pose.transform.position.z);
|
|
19
|
+
}
|
|
20
|
+
function isPinching(hand, frame, refSpace, threshold = 0.02) {
|
|
21
|
+
const thumbPos = getJointPosition(hand, "thumb-tip", frame, refSpace);
|
|
22
|
+
const indexPos = getJointPosition(hand, "index-finger-tip", frame, refSpace);
|
|
23
|
+
if (!thumbPos || !indexPos)
|
|
24
|
+
return false;
|
|
25
|
+
return thumbPos.distanceTo(indexPos) < threshold;
|
|
26
|
+
}
|
|
27
|
+
function GeometryAndMeshXR(props) {
|
|
28
|
+
const { segmentationGroup, segmentationSettings, segmentationSceneScale, renderingSettings, materialRef, highlightEntity, setObsHighlight } = props;
|
|
29
|
+
const model = useRef(null);
|
|
30
|
+
const distanceRef = useRef(null);
|
|
31
|
+
const rayGrabGroup = useRef(null);
|
|
32
|
+
const grabControllerRef = useRef(null);
|
|
33
|
+
useRef(new Matrix4());
|
|
34
|
+
const initialScale = useRef(null);
|
|
35
|
+
const secondPointerId = useRef(null);
|
|
36
|
+
const initialDistance = useRef(0);
|
|
37
|
+
const lastPointerPositions = useRef(/* @__PURE__ */ new Map());
|
|
38
|
+
const session = useXR((state) => state.session);
|
|
39
|
+
const isPresenting = session != null;
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (materialRef?.current?.material?.uniforms?.u_physical_Pixel) {
|
|
42
|
+
materialRef.current.material.uniforms.u_physical_Pixel.value = isPresenting ? 0.2 : 2.5;
|
|
43
|
+
}
|
|
44
|
+
}, [isPresenting, materialRef]);
|
|
45
|
+
const { scene, gl } = useThree();
|
|
46
|
+
const rightHand = useXRInputSourceState("hand", "right");
|
|
47
|
+
const leftHand = useXRInputSourceState("hand", "left");
|
|
48
|
+
const [measureState, setMeasureState] = useState(false);
|
|
49
|
+
const [highlighted, setHighlighted] = useState(false);
|
|
50
|
+
const [showLine, setShowLine] = useState(false);
|
|
51
|
+
const [currentLine, setCurrentLine] = useState({
|
|
52
|
+
startPoint: new Vector3(),
|
|
53
|
+
midPoint: new Vector3(),
|
|
54
|
+
endPoint: new Vector3(),
|
|
55
|
+
setStartPoint: false,
|
|
56
|
+
setEndPoint: false
|
|
57
|
+
});
|
|
58
|
+
const [lines, setLines] = useState([]);
|
|
59
|
+
const [debounce, setDebounce] = useState(0);
|
|
60
|
+
const measureStateRef = useRef(measureState);
|
|
61
|
+
measureStateRef.current = measureState;
|
|
62
|
+
const highlightedRef = useRef(highlighted);
|
|
63
|
+
highlightedRef.current = highlighted;
|
|
64
|
+
const currentLineRef = useRef(currentLine);
|
|
65
|
+
currentLineRef.current = currentLine;
|
|
66
|
+
const linesRef = useRef(lines);
|
|
67
|
+
linesRef.current = lines;
|
|
68
|
+
const debounceRef = useRef(debounce);
|
|
69
|
+
debounceRef.current = debounce;
|
|
70
|
+
useFrame((_state, _delta, frame) => {
|
|
71
|
+
if (!isPresenting || !frame)
|
|
72
|
+
return;
|
|
73
|
+
const refSpace = gl.xr.getReferenceSpace();
|
|
74
|
+
if (!refSpace)
|
|
75
|
+
return;
|
|
76
|
+
const rightTipBbox = scene.getObjectByName("rightTipBbox");
|
|
77
|
+
const leftTipBbox = scene.getObjectByName("leftTipBbox");
|
|
78
|
+
if (!rightTipBbox || !leftTipBbox)
|
|
79
|
+
return;
|
|
80
|
+
const leftTipBB = new Box3().setFromObject(leftTipBbox);
|
|
81
|
+
const rightTipBB = new Box3().setFromObject(rightTipBbox);
|
|
82
|
+
let intersected = false;
|
|
83
|
+
setDebounce((prev) => prev - 1);
|
|
84
|
+
if (leftTipBB.intersectsBox(rightTipBB) && leftTipBB.max.x !== -rightTipBB.min.x) {
|
|
85
|
+
setMeasureState(true);
|
|
86
|
+
setShowLine(true);
|
|
87
|
+
setCurrentLine({
|
|
88
|
+
startPoint: new Vector3(),
|
|
89
|
+
midPoint: new Vector3(),
|
|
90
|
+
endPoint: new Vector3(),
|
|
91
|
+
setStartPoint: false,
|
|
92
|
+
setEndPoint: false
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const curMeasureState = measureStateRef.current;
|
|
96
|
+
const curLine = currentLineRef.current;
|
|
97
|
+
if (curMeasureState) {
|
|
98
|
+
let leftFingerPosition = getJointPosition(leftHand, "index-finger-tip", frame, refSpace);
|
|
99
|
+
let rightFingerPosition = getJointPosition(rightHand, "index-finger-tip", frame, refSpace);
|
|
100
|
+
if (!leftFingerPosition || !rightFingerPosition)
|
|
101
|
+
return;
|
|
102
|
+
if (rayGrabGroup.current) {
|
|
103
|
+
leftFingerPosition = leftFingerPosition.applyMatrix4(rayGrabGroup.current.matrixWorld.clone().invert());
|
|
104
|
+
rightFingerPosition = rightFingerPosition.applyMatrix4(rayGrabGroup.current.matrixWorld.clone().invert());
|
|
105
|
+
}
|
|
106
|
+
let currentStart = leftFingerPosition.clone();
|
|
107
|
+
let currentEnd = rightFingerPosition.clone();
|
|
108
|
+
if (curLine.setStartPoint) {
|
|
109
|
+
currentStart = curLine.startPoint;
|
|
110
|
+
}
|
|
111
|
+
if (curLine.setEndPoint) {
|
|
112
|
+
currentEnd = curLine.endPoint;
|
|
113
|
+
}
|
|
114
|
+
setCurrentLine({
|
|
115
|
+
startPoint: currentStart,
|
|
116
|
+
midPoint: new Vector3().addVectors(currentStart, currentEnd).multiplyScalar(0.5),
|
|
117
|
+
endPoint: currentEnd,
|
|
118
|
+
setStartPoint: curLine.setStartPoint,
|
|
119
|
+
setEndPoint: curLine.setEndPoint
|
|
120
|
+
});
|
|
121
|
+
if (isPinching(rightHand, frame, refSpace)) {
|
|
122
|
+
setCurrentLine((prev) => ({
|
|
123
|
+
...prev,
|
|
124
|
+
setEndPoint: true
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
if (isPinching(leftHand, frame, refSpace)) {
|
|
128
|
+
setCurrentLine((prev) => ({
|
|
129
|
+
...prev,
|
|
130
|
+
setStartPoint: true
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
if (curLine.setStartPoint && curLine.setEndPoint) {
|
|
134
|
+
setLines((prev) => [...prev, curLine]);
|
|
135
|
+
setShowLine(false);
|
|
136
|
+
setMeasureState(false);
|
|
137
|
+
setDebounce(8);
|
|
138
|
+
}
|
|
139
|
+
} else if (debounceRef.current <= 0 && model.current && isPresenting) {
|
|
140
|
+
const modelScene = model.current;
|
|
141
|
+
modelScene.children[0].children.forEach((_childVal, childID) => {
|
|
142
|
+
const child = modelScene.children[0].children[childID];
|
|
143
|
+
const currentObjectBB = new Box3().setFromObject(child);
|
|
144
|
+
const intersectsLeftTip = leftTipBB.intersectsBox(currentObjectBB);
|
|
145
|
+
const intersectsRightTip = rightTipBB.intersectsBox(currentObjectBB);
|
|
146
|
+
if (intersectsLeftTip || intersectsRightTip) {
|
|
147
|
+
intersected = true;
|
|
148
|
+
setObsHighlight(child.name);
|
|
149
|
+
setHighlighted(true);
|
|
150
|
+
if (intersectsLeftTip && isPinching(leftHand, frame, refSpace)) {
|
|
151
|
+
setDebounce(10);
|
|
152
|
+
intersected = false;
|
|
153
|
+
}
|
|
154
|
+
if (intersectsRightTip && isPinching(rightHand, frame, refSpace)) {
|
|
155
|
+
setDebounce(10);
|
|
156
|
+
intersected = false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
if (!intersected && highlightedRef.current) {
|
|
161
|
+
setObsHighlight(null);
|
|
162
|
+
setHighlighted(false);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const handlePointerDown = (e) => {
|
|
167
|
+
if (!isPresenting)
|
|
168
|
+
return;
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
e.target.setPointerCapture(e.pointerId);
|
|
171
|
+
if (grabControllerRef.current === null) {
|
|
172
|
+
grabControllerRef.current = e.pointerId;
|
|
173
|
+
lastPointerPositions.current.set(e.pointerId, e.point.clone());
|
|
174
|
+
if (rayGrabGroup.current) {
|
|
175
|
+
initialScale.current = rayGrabGroup.current.scale.clone();
|
|
176
|
+
}
|
|
177
|
+
} else if (secondPointerId.current === null && e.pointerId !== grabControllerRef.current) {
|
|
178
|
+
secondPointerId.current = e.pointerId;
|
|
179
|
+
lastPointerPositions.current.set(e.pointerId, e.point.clone());
|
|
180
|
+
const p1 = lastPointerPositions.current.get(grabControllerRef.current);
|
|
181
|
+
const p2 = e.point;
|
|
182
|
+
if (p1) {
|
|
183
|
+
initialDistance.current = p1.distanceTo(p2);
|
|
184
|
+
}
|
|
185
|
+
if (rayGrabGroup.current) {
|
|
186
|
+
initialScale.current = rayGrabGroup.current.scale.clone();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const handlePointerUp = (e) => {
|
|
191
|
+
e.target.releasePointerCapture(e.pointerId);
|
|
192
|
+
lastPointerPositions.current.delete(e.pointerId);
|
|
193
|
+
if (grabControllerRef.current === e.pointerId) {
|
|
194
|
+
grabControllerRef.current = null;
|
|
195
|
+
initialScale.current = null;
|
|
196
|
+
}
|
|
197
|
+
if (secondPointerId.current === e.pointerId) {
|
|
198
|
+
secondPointerId.current = null;
|
|
199
|
+
initialDistance.current = 0;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const handlePointerMove = (e) => {
|
|
203
|
+
if (!rayGrabGroup.current || !e.point)
|
|
204
|
+
return;
|
|
205
|
+
const isFirstPointer = grabControllerRef.current === e.pointerId;
|
|
206
|
+
const isSecondPointer = secondPointerId.current === e.pointerId;
|
|
207
|
+
if (!isFirstPointer && !isSecondPointer)
|
|
208
|
+
return;
|
|
209
|
+
const prevPos = lastPointerPositions.current.get(e.pointerId);
|
|
210
|
+
lastPointerPositions.current.set(e.pointerId, e.point.clone());
|
|
211
|
+
if (secondPointerId.current !== null && initialDistance.current > 0 && initialScale.current) {
|
|
212
|
+
const p1 = lastPointerPositions.current.get(grabControllerRef.current);
|
|
213
|
+
const p2 = lastPointerPositions.current.get(secondPointerId.current);
|
|
214
|
+
if (p1 && p2) {
|
|
215
|
+
const currentDistance = p1.distanceTo(p2);
|
|
216
|
+
const scaleFactor = currentDistance / initialDistance.current;
|
|
217
|
+
rayGrabGroup.current.scale.copy(initialScale.current).multiplyScalar(scaleFactor);
|
|
218
|
+
}
|
|
219
|
+
} else if (isFirstPointer && prevPos) {
|
|
220
|
+
const delta = e.point.clone().sub(prevPos);
|
|
221
|
+
rayGrabGroup.current.position.add(delta);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
if (isPresenting) {
|
|
225
|
+
return jsxRuntimeExports.jsxs("group", { children: [jsxRuntimeExports.jsxs("group", { ref: rayGrabGroup, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerMove: handlePointerMove, children: [segmentationGroup?.visible ? jsxRuntimeExports.jsxs("group", { children: [jsxRuntimeExports.jsx("hemisphereLight", { color: 8421504, groundColor: 6316128 }), jsxRuntimeExports.jsx("directionalLight", { color: 16777215, position: [0, -800, 0] }), jsxRuntimeExports.jsx("primitive", { ref: model, object: segmentationGroup, position: [-0.18, 1.13, -1], scale: [
|
|
226
|
+
2e-3 * segmentationSceneScale[0],
|
|
227
|
+
2e-3 * segmentationSceneScale[1],
|
|
228
|
+
2e-3 * segmentationSceneScale[2]
|
|
229
|
+
] })] }) : null, renderingSettings.uniforms && renderingSettings.shader && renderingSettings.meshScale ? jsxRuntimeExports.jsx("group", { children: jsxRuntimeExports.jsxs("mesh", { name: "cube", position: [-0.18, 1.13, -1], rotation: [0, 0, 0], scale: [
|
|
230
|
+
2e-3 * renderingSettings.meshScale[0],
|
|
231
|
+
2e-3 * renderingSettings.meshScale[1],
|
|
232
|
+
2e-3 * renderingSettings.meshScale[2]
|
|
233
|
+
], ref: materialRef, children: [isValidGeometrySize(renderingSettings.geometrySize) && jsxRuntimeExports.jsx("boxGeometry", { args: renderingSettings.geometrySize }), jsxRuntimeExports.jsx("shaderMaterial", { customProgramCacheKey: () => "1", side: FrontSide, uniforms: renderingSettings.uniforms, needsUpdate: true, transparent: true, vertexShader: renderingSettings.shader.vertexShader, fragmentShader: renderingSettings.shader.fragmentShader })] }) }) : null] }), jsxRuntimeExports.jsx("group", { name: "currentLine", ref: distanceRef, children: showLine ? jsxRuntimeExports.jsx(MeasureLine, { currentLine, scale: 1 / 2e-3 * 0.4 }) : null }), jsxRuntimeExports.jsx("group", { name: "lines", children: lines.map((object) => jsxRuntimeExports.jsx(MeasureLine, { currentLine: object, scale: 1 / 2e-3 * 0.4 }, stringifyLineData(object))) })] });
|
|
234
|
+
}
|
|
235
|
+
return jsxRuntimeExports.jsxs("group", { children: [jsxRuntimeExports.jsxs("group", { children: [segmentationGroup?.visible ? jsxRuntimeExports.jsxs("group", { children: [jsxRuntimeExports.jsx("hemisphereLight", { color: 8421504, groundColor: 6316128 }), jsxRuntimeExports.jsx("directionalLight", { color: 16777215, position: [0, -800, 0] }), jsxRuntimeExports.jsx("directionalLight", { color: 16777215, position: [0, 800, 0] }), jsxRuntimeExports.jsx(Bvh, { firstHitOnly: true, children: jsxRuntimeExports.jsx("primitive", { ref: model, object: segmentationGroup, position: [0, 0, 0], onClick: (e) => {
|
|
236
|
+
if (e.object.parent?.userData.name === "finalPass") {
|
|
237
|
+
highlightEntity(e.object.name, e.object.userData.layerScope, e.object.userData.channelScope);
|
|
238
|
+
}
|
|
239
|
+
}, onPointerOver: (e) => {
|
|
240
|
+
setObsHighlight(e.object.name);
|
|
241
|
+
}, onPointerOut: () => setObsHighlight(null) }) })] }) : null, renderingSettings.uniforms && renderingSettings.shader && renderingSettings.meshScale && renderingSettings.geometrySize ? jsxRuntimeExports.jsx("group", { children: jsxRuntimeExports.jsxs("mesh", { scale: renderingSettings.meshScale, ref: materialRef, children: [jsxRuntimeExports.jsx("boxGeometry", { args: renderingSettings.geometrySize }), jsxRuntimeExports.jsx("shaderMaterial", { customProgramCacheKey: () => "1", side: FrontSide, uniforms: renderingSettings.uniforms, needsUpdate: true, transparent: true, vertexShader: renderingSettings.shader.vertexShader, fragmentShader: renderingSettings.shader.fragmentShader })] }) }) : null] }), jsxRuntimeExports.jsx("group", { name: "lines", children: lines.map((object) => jsxRuntimeExports.jsx(MeasureLine, { currentLine: object, scale: 1 }, stringifyLineData(object))) })] });
|
|
242
|
+
}
|
|
243
|
+
export {
|
|
244
|
+
GeometryAndMeshXR as default
|
|
245
|
+
};
|