@terraware/web-components 4.2.14-rc.0 → 4.2.14
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/components/VirtualWalkthrough/VirtualWalkthroughViewer.d.ts +27 -0
- package/components/VirtualWalkthrough/VirtualWalkthroughViewer.d.ts.map +1 -0
- package/components/VirtualWalkthrough/VirtualWalkthroughViewer.js +282 -0
- package/hooks/useDevicePerformance.d.ts +9 -0
- package/hooks/useDevicePerformance.d.ts.map +1 -0
- package/hooks/useDevicePerformance.js +16 -0
- package/package.json +1 -1
- package/virtualWalkthrough.d.ts +4 -1
- package/virtualWalkthrough.d.ts.map +1 -1
- package/virtualWalkthrough.js +3 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AnnotationProps } from './Annotation';
|
|
2
|
+
import { SplatControlsStrings } from './SplatControls';
|
|
3
|
+
export interface VirtualWalkthroughViewerProps {
|
|
4
|
+
splatSrc: string;
|
|
5
|
+
origin?: [number, number, number];
|
|
6
|
+
cameraPosition?: [number, number, number];
|
|
7
|
+
sceneBounds?: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
z: number;
|
|
11
|
+
m: number;
|
|
12
|
+
};
|
|
13
|
+
groundPlane?: [number, number, number][];
|
|
14
|
+
skyColor?: string;
|
|
15
|
+
groundColor?: string;
|
|
16
|
+
averageCameraHeight?: number;
|
|
17
|
+
annotations: AnnotationProps[];
|
|
18
|
+
onSaveAnnotations: (annotations: AnnotationProps[]) => void | Promise<void>;
|
|
19
|
+
strings: SplatControlsStrings;
|
|
20
|
+
editable?: boolean;
|
|
21
|
+
showFreeFly?: boolean;
|
|
22
|
+
isFullScreen?: boolean;
|
|
23
|
+
onToggleFullScreen?: () => void;
|
|
24
|
+
}
|
|
25
|
+
declare const VirtualWalkthroughViewer: ({ splatSrc, origin, cameraPosition, sceneBounds, groundPlane: groundPlaneProp, skyColor, groundColor, averageCameraHeight, annotations, onSaveAnnotations, strings, editable, showFreeFly, isFullScreen, onToggleFullScreen, }: VirtualWalkthroughViewerProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export default VirtualWalkthroughViewer;
|
|
27
|
+
//# sourceMappingURL=VirtualWalkthroughViewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualWalkthroughViewer.d.ts","sourceRoot":"","sources":["../../../src/components/VirtualWalkthrough/VirtualWalkthroughViewer.tsx"],"names":[],"mappings":"AAWA,OAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK3D,OAAsB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAStE,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,WAAW,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,iBAAiB,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,OAAO,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC;AAED,QAAA,MAAM,wBAAwB,GAAI,gOAgB/B,6BAA6B,4CAwR/B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { useTheme } from '@mui/material';
|
|
3
|
+
import { Entity } from '@playcanvas/react';
|
|
4
|
+
import { Camera, Script } from '@playcanvas/react/components';
|
|
5
|
+
import { useApp } from '@playcanvas/react/hooks';
|
|
6
|
+
import { Color, Vec3 } from 'playcanvas';
|
|
7
|
+
import { XrControllers } from 'playcanvas/scripts/esm/xr-controllers.mjs';
|
|
8
|
+
import { useCameraPosition } from '../../hooks/useCameraPosition';
|
|
9
|
+
import { useDevicePerformance } from '../../hooks/useDevicePerformance';
|
|
10
|
+
import Annotation from './Annotation';
|
|
11
|
+
import AnnotationPanel from './AnnotationPanel';
|
|
12
|
+
import { AutoRotator } from './AutoRotator';
|
|
13
|
+
import BoundaryRing from './BoundaryRing';
|
|
14
|
+
import GradientSky from './GradientSky';
|
|
15
|
+
import SplatControls from './SplatControls';
|
|
16
|
+
import SplatModel from './SplatModel';
|
|
17
|
+
import { TfAnnotationManager } from './TfAnnotationManager';
|
|
18
|
+
import { TfXrNavigation } from './TfXrNavigation';
|
|
19
|
+
import { WalkthroughCamera } from './walkthrough-camera';
|
|
20
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
+
const DEFAULT_FOCUS_POINT = [0, 0.1, 0];
|
|
22
|
+
const DEFAULT_POSITION = [1, 0.1, 0];
|
|
23
|
+
const VirtualWalkthroughViewer = ({
|
|
24
|
+
splatSrc,
|
|
25
|
+
origin = DEFAULT_FOCUS_POINT,
|
|
26
|
+
cameraPosition = DEFAULT_POSITION,
|
|
27
|
+
sceneBounds,
|
|
28
|
+
groundPlane: groundPlaneProp,
|
|
29
|
+
skyColor,
|
|
30
|
+
groundColor,
|
|
31
|
+
averageCameraHeight = 0,
|
|
32
|
+
annotations,
|
|
33
|
+
onSaveAnnotations,
|
|
34
|
+
strings,
|
|
35
|
+
editable = false,
|
|
36
|
+
showFreeFly = false,
|
|
37
|
+
isFullScreen = false,
|
|
38
|
+
onToggleFullScreen
|
|
39
|
+
}) => {
|
|
40
|
+
const theme = useTheme();
|
|
41
|
+
const {
|
|
42
|
+
setCamera
|
|
43
|
+
} = useCameraPosition();
|
|
44
|
+
const {
|
|
45
|
+
isHighPerformance
|
|
46
|
+
} = useDevicePerformance();
|
|
47
|
+
const app = useApp();
|
|
48
|
+
const [showAnnotations, setShowAnnotations] = useState(true);
|
|
49
|
+
const [autoRotate, setAutoRotate] = useState(true);
|
|
50
|
+
const [isEdit, setIsEdit] = useState(false);
|
|
51
|
+
const [isFreeFly, setIsFreeFly] = useState(false);
|
|
52
|
+
const [selectedAnnotationIndex, setSelectedAnnotationIndex] = useState(-1);
|
|
53
|
+
const [localAnnotations, setLocalAnnotations] = useState(annotations);
|
|
54
|
+
const [isTextFieldFocused, setIsTextFieldFocused] = useState(false);
|
|
55
|
+
const [viewingAnnotation, setViewingAnnotation] = useState(null);
|
|
56
|
+
const [viewingAnnotationIndex, setViewingAnnotationIndex] = useState(-1);
|
|
57
|
+
const [viewedScreenPos, setViewedScreenPos] = useState(null);
|
|
58
|
+
const sceneBoundsRadius = useMemo(() => {
|
|
59
|
+
if (sceneBounds?.m !== undefined) {
|
|
60
|
+
return sceneBounds.m;
|
|
61
|
+
}
|
|
62
|
+
const dx = cameraPosition[0] - origin[0];
|
|
63
|
+
const dy = cameraPosition[1] - origin[1];
|
|
64
|
+
const dz = cameraPosition[2] - origin[2];
|
|
65
|
+
return Math.sqrt(dx * dx + dy * dy + dz * dz) * 0.5;
|
|
66
|
+
}, [cameraPosition, sceneBounds, origin]);
|
|
67
|
+
const sceneBoundsCenter = useMemo(() => sceneBounds ? new Vec3(sceneBounds.x, sceneBounds.y, sceneBounds.z) : new Vec3(origin[0], cameraPosition[1], origin[2]), [sceneBounds, origin, cameraPosition]);
|
|
68
|
+
const groundPlane = useMemo(() => groundPlaneProp?.length === 3 ? groundPlaneProp.map(p => new Vec3(p[0], p[1], p[2])) : [], [groundPlaneProp]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setCamera(origin, cameraPosition);
|
|
71
|
+
}, [origin, cameraPosition, setCamera]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!groundPlane.length) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// @ts-expect-error - scripts are added dynamically to the camera entity
|
|
77
|
+
const walkthroughCam = app.root.findByName('camera')?.script?.walkthroughCamera;
|
|
78
|
+
if (walkthroughCam) {
|
|
79
|
+
// Should be changed to a react prop if shallowEquals in playcanvas/react is fixed (see https://github.com/playcanvas/react/pull/298)
|
|
80
|
+
walkthroughCam.groundPlane = groundPlane;
|
|
81
|
+
}
|
|
82
|
+
}, [groundPlane, app]);
|
|
83
|
+
const handleToggleFreeFly = useCallback(() => {
|
|
84
|
+
const newFreeFly = !isFreeFly;
|
|
85
|
+
// @ts-expect-error - scripts are added dynamically to the camera entity
|
|
86
|
+
const walkthroughCam = app.root.findByName('camera')?.script?.walkthroughCamera;
|
|
87
|
+
if (walkthroughCam) {
|
|
88
|
+
walkthroughCam.freeFly = newFreeFly;
|
|
89
|
+
}
|
|
90
|
+
if (!newFreeFly) {
|
|
91
|
+
setCamera(origin, cameraPosition);
|
|
92
|
+
}
|
|
93
|
+
setIsFreeFly(newFreeFly);
|
|
94
|
+
}, [isFreeFly, app, setCamera, origin, cameraPosition]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
setLocalAnnotations(annotations);
|
|
97
|
+
}, [annotations]);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (!isEdit) {
|
|
100
|
+
setSelectedAnnotationIndex(-1);
|
|
101
|
+
}
|
|
102
|
+
}, [isEdit]);
|
|
103
|
+
const handleAnnotationPositionChange = useCallback(position => {
|
|
104
|
+
setLocalAnnotations(prev => {
|
|
105
|
+
if (selectedAnnotationIndex === -1) {
|
|
106
|
+
return prev;
|
|
107
|
+
}
|
|
108
|
+
const updated = [...prev];
|
|
109
|
+
updated[selectedAnnotationIndex] = {
|
|
110
|
+
...updated[selectedAnnotationIndex],
|
|
111
|
+
position
|
|
112
|
+
};
|
|
113
|
+
return updated;
|
|
114
|
+
});
|
|
115
|
+
}, [selectedAnnotationIndex]);
|
|
116
|
+
const handleSave = useCallback(() => {
|
|
117
|
+
const saveAndClose = async () => {
|
|
118
|
+
await onSaveAnnotations(localAnnotations);
|
|
119
|
+
setIsEdit(false);
|
|
120
|
+
setSelectedAnnotationIndex(-1);
|
|
121
|
+
};
|
|
122
|
+
void saveAndClose();
|
|
123
|
+
}, [onSaveAnnotations, localAnnotations]);
|
|
124
|
+
const handleCancel = useCallback(() => {
|
|
125
|
+
setLocalAnnotations(annotations);
|
|
126
|
+
setIsEdit(false);
|
|
127
|
+
setSelectedAnnotationIndex(-1);
|
|
128
|
+
}, [annotations]);
|
|
129
|
+
const handleAddAnnotation = useCallback(() => {
|
|
130
|
+
const newAnnotation = {
|
|
131
|
+
position: origin,
|
|
132
|
+
title: ''
|
|
133
|
+
};
|
|
134
|
+
setLocalAnnotations(prev => [...prev, newAnnotation]);
|
|
135
|
+
setSelectedAnnotationIndex(localAnnotations.length);
|
|
136
|
+
}, [origin, localAnnotations]);
|
|
137
|
+
const handleDeleteAnnotation = useCallback(() => {
|
|
138
|
+
if (selectedAnnotationIndex === -1) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
setLocalAnnotations(prev => prev.filter((_, index) => index !== selectedAnnotationIndex));
|
|
142
|
+
setSelectedAnnotationIndex(-1);
|
|
143
|
+
}, [selectedAnnotationIndex]);
|
|
144
|
+
const handleDeselectAnnotation = useCallback(() => {
|
|
145
|
+
setSelectedAnnotationIndex(-1);
|
|
146
|
+
}, []);
|
|
147
|
+
const handleAnnotationView = useCallback(
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
149
|
+
(annotation, annotationIndex, screenX, screenY) => {
|
|
150
|
+
setViewingAnnotation(annotation);
|
|
151
|
+
setViewingAnnotationIndex(annotationIndex);
|
|
152
|
+
// Cleared so the connector line waits for the hotspot's post-aim position
|
|
153
|
+
// rather than briefly pointing at its old spot.
|
|
154
|
+
setViewedScreenPos(null);
|
|
155
|
+
}, []);
|
|
156
|
+
const handleAnnotationScreenPositionUpdate = useCallback((_index, screenX, screenY, size) => {
|
|
157
|
+
// The scene is frozen while the panel is open, so guard against redundant
|
|
158
|
+
// updates from the per-frame callback to avoid needless re-renders.
|
|
159
|
+
setViewedScreenPos(prev => prev && prev.x === screenX && prev.y === screenY && prev.size === size ? prev : {
|
|
160
|
+
x: screenX,
|
|
161
|
+
y: screenY,
|
|
162
|
+
size
|
|
163
|
+
});
|
|
164
|
+
}, []);
|
|
165
|
+
const handleCloseAnnotation = useCallback(() => {
|
|
166
|
+
setViewingAnnotation(null);
|
|
167
|
+
setViewingAnnotationIndex(-1);
|
|
168
|
+
setViewedScreenPos(null);
|
|
169
|
+
}, []);
|
|
170
|
+
const handleAnnotationUpdate = useCallback(updates => {
|
|
171
|
+
if (selectedAnnotationIndex === -1) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
setLocalAnnotations(prev => {
|
|
175
|
+
const updated = [...prev];
|
|
176
|
+
updated[selectedAnnotationIndex] = {
|
|
177
|
+
...updated[selectedAnnotationIndex],
|
|
178
|
+
...updates
|
|
179
|
+
};
|
|
180
|
+
return updated;
|
|
181
|
+
});
|
|
182
|
+
}, [selectedAnnotationIndex]);
|
|
183
|
+
const canSave = useMemo(() => localAnnotations.every(annotation => annotation.title && annotation.title.trim() !== ''), [localAnnotations]);
|
|
184
|
+
const splatModel = useMemo(() => /*#__PURE__*/_jsx(SplatModel, {
|
|
185
|
+
splatSrc: splatSrc,
|
|
186
|
+
rotation: [-180, 0, 0],
|
|
187
|
+
revealRain: isHighPerformance
|
|
188
|
+
}, 'splat'), [isHighPerformance, splatSrc]);
|
|
189
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
190
|
+
children: [/*#__PURE__*/_jsx(GradientSky, {
|
|
191
|
+
topColor: skyColor || '#FFFFFF',
|
|
192
|
+
horizonColor: skyColor || '#EAF8FF',
|
|
193
|
+
groundColor: groundColor || '#C3BDB7'
|
|
194
|
+
}), /*#__PURE__*/_jsxs(Entity, {
|
|
195
|
+
name: "camera-root",
|
|
196
|
+
children: [/*#__PURE__*/_jsxs(Entity, {
|
|
197
|
+
name: "camera",
|
|
198
|
+
children: [/*#__PURE__*/_jsx(Camera, {
|
|
199
|
+
clearColor: "#EAF8FF",
|
|
200
|
+
fov: 60
|
|
201
|
+
}), /*#__PURE__*/_jsx(Script, {
|
|
202
|
+
script: WalkthroughCamera,
|
|
203
|
+
boundsCenter: sceneBoundsCenter,
|
|
204
|
+
boundsRadius: sceneBoundsRadius,
|
|
205
|
+
enableFly: !isTextFieldFocused,
|
|
206
|
+
averageCameraHeight: averageCameraHeight
|
|
207
|
+
})]
|
|
208
|
+
}), /*#__PURE__*/_jsx(Script, {
|
|
209
|
+
script: XrControllers,
|
|
210
|
+
enabled: !isEdit
|
|
211
|
+
}), /*#__PURE__*/_jsx(Script, {
|
|
212
|
+
script: TfXrNavigation,
|
|
213
|
+
enabled: !isEdit,
|
|
214
|
+
enableTeleport: false
|
|
215
|
+
}), /*#__PURE__*/_jsx(Script, {
|
|
216
|
+
script: AutoRotator,
|
|
217
|
+
enabled: !isEdit && autoRotate && !viewingAnnotation,
|
|
218
|
+
startDelay: 0.5,
|
|
219
|
+
restartDelay: 3,
|
|
220
|
+
startFadeInTime: 0.5
|
|
221
|
+
})]
|
|
222
|
+
}), splatModel, sceneBounds?.m !== undefined && groundPlane.length === 3 && /*#__PURE__*/_jsx(BoundaryRing, {
|
|
223
|
+
center: sceneBoundsCenter,
|
|
224
|
+
radius: sceneBoundsRadius,
|
|
225
|
+
groundPlane: groundPlane
|
|
226
|
+
}), localAnnotations.length > 0 && /*#__PURE__*/_jsxs(Entity, {
|
|
227
|
+
name: "annotations-root",
|
|
228
|
+
children: [/*#__PURE__*/_jsx(Script, {
|
|
229
|
+
script: TfAnnotationManager,
|
|
230
|
+
enabled: true,
|
|
231
|
+
hotspotSize: 30,
|
|
232
|
+
maxWorldSize: 0.05,
|
|
233
|
+
opacity: 1,
|
|
234
|
+
hotspotColor: new Color().fromString(theme.palette.TwClrIcnBrand),
|
|
235
|
+
hoverColor: new Color().fromString('#ffffff'),
|
|
236
|
+
hotspotBackgroundColor: theme.palette.TwClrBaseWhite
|
|
237
|
+
}), localAnnotations.map((annotation, index) => /*#__PURE__*/_jsx(Annotation, {
|
|
238
|
+
...annotation,
|
|
239
|
+
index: index,
|
|
240
|
+
visible: showAnnotations,
|
|
241
|
+
isEdit: isEdit,
|
|
242
|
+
isSelected: selectedAnnotationIndex === index,
|
|
243
|
+
isViewed: viewingAnnotationIndex === index,
|
|
244
|
+
onSelect: () => setSelectedAnnotationIndex(index),
|
|
245
|
+
onPositionChange: handleAnnotationPositionChange,
|
|
246
|
+
onView: (anno, screenX, screenY) => handleAnnotationView(anno, index, screenX, screenY),
|
|
247
|
+
onScreenPositionUpdate: handleAnnotationScreenPositionUpdate
|
|
248
|
+
}, `annotation-${index}`))]
|
|
249
|
+
}), /*#__PURE__*/_jsx(SplatControls, {
|
|
250
|
+
defaultCameraFocus: origin,
|
|
251
|
+
defaultCameraPosition: cameraPosition,
|
|
252
|
+
showAnnotations: showAnnotations,
|
|
253
|
+
onToggleAnnotations: setShowAnnotations,
|
|
254
|
+
autoRotate: autoRotate,
|
|
255
|
+
onToggleAutoRotate: setAutoRotate,
|
|
256
|
+
isEdit: isEdit,
|
|
257
|
+
onToggleEdit: setIsEdit,
|
|
258
|
+
onSave: handleSave,
|
|
259
|
+
onCancel: handleCancel,
|
|
260
|
+
onAddAnnotation: handleAddAnnotation,
|
|
261
|
+
onDeleteAnnotation: handleDeleteAnnotation,
|
|
262
|
+
onDeselectAnnotation: handleDeselectAnnotation,
|
|
263
|
+
hasSelectedAnnotation: selectedAnnotationIndex >= 0,
|
|
264
|
+
selectedAnnotation: selectedAnnotationIndex >= 0 ? localAnnotations[selectedAnnotationIndex] : null,
|
|
265
|
+
onAnnotationUpdate: handleAnnotationUpdate,
|
|
266
|
+
onTextFieldFocus: setIsTextFieldFocused,
|
|
267
|
+
canSave: canSave,
|
|
268
|
+
editable: editable,
|
|
269
|
+
isFullScreen: isFullScreen,
|
|
270
|
+
onToggleFullScreen: onToggleFullScreen,
|
|
271
|
+
isFreeFly: isFreeFly,
|
|
272
|
+
onToggleFreeFly: handleToggleFreeFly,
|
|
273
|
+
showFreeFly: showFreeFly,
|
|
274
|
+
strings: strings
|
|
275
|
+
}), /*#__PURE__*/_jsx(AnnotationPanel, {
|
|
276
|
+
annotation: viewingAnnotation,
|
|
277
|
+
hotspotPosition: viewedScreenPos,
|
|
278
|
+
onClose: handleCloseAnnotation
|
|
279
|
+
})]
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
export default VirtualWalkthroughViewer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface DevicePerformance {
|
|
2
|
+
isHighPerformance: boolean;
|
|
3
|
+
cpuCores: number;
|
|
4
|
+
deviceMemory?: number;
|
|
5
|
+
isMobile: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const useDevicePerformance: () => DevicePerformance;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=useDevicePerformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDevicePerformance.d.ts","sourceRoot":"","sources":["../../src/hooks/useDevicePerformance.ts"],"names":[],"mappings":"AAIA,UAAU,iBAAiB;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,oBAAoB,QAAO,iBAavC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import useDeviceInfo from '../utils/useDeviceInfo';
|
|
3
|
+
export const useDevicePerformance = () => {
|
|
4
|
+
const {
|
|
5
|
+
isMobile
|
|
6
|
+
} = useDeviceInfo();
|
|
7
|
+
const cpuCores = useMemo(() => navigator.hardwareConcurrency || 4, []);
|
|
8
|
+
const deviceMemory = useMemo(() => navigator.deviceMemory, []);
|
|
9
|
+
const isHighPerformance = useMemo(() => !isMobile && cpuCores >= 4 || deviceMemory !== undefined && deviceMemory >= 8 || cpuCores >= 6, [cpuCores, deviceMemory, isMobile]);
|
|
10
|
+
return {
|
|
11
|
+
isHighPerformance,
|
|
12
|
+
cpuCores,
|
|
13
|
+
deviceMemory,
|
|
14
|
+
isMobile
|
|
15
|
+
};
|
|
16
|
+
};
|
package/package.json
CHANGED
package/virtualWalkthrough.d.ts
CHANGED
|
@@ -15,9 +15,11 @@ import SplatModel from './components/VirtualWalkthrough/SplatModel';
|
|
|
15
15
|
import SplatRevealRain from './components/VirtualWalkthrough/SplatRevealRain';
|
|
16
16
|
import { TfAnnotationManager } from './components/VirtualWalkthrough/TfAnnotationManager';
|
|
17
17
|
import { TfXrNavigation } from './components/VirtualWalkthrough/TfXrNavigation';
|
|
18
|
+
import VirtualWalkthroughViewer from './components/VirtualWalkthrough/VirtualWalkthroughViewer';
|
|
18
19
|
import { BoundaryRingScript, boundaryRingMesh } from './components/VirtualWalkthrough/boundary-ring';
|
|
19
20
|
import { computeGroundPlane, yOnPlane } from './components/VirtualWalkthrough/groundPlane';
|
|
20
21
|
import { WalkthroughCamera } from './components/VirtualWalkthrough/walkthrough-camera';
|
|
22
|
+
import { useDevicePerformance } from './hooks/useDevicePerformance';
|
|
21
23
|
export type { AnnotationProps, AnnotationIconType } from './components/VirtualWalkthrough/Annotation';
|
|
22
24
|
export type { AnnotationEditPaneStrings } from './components/VirtualWalkthrough/AnnotationEditPane';
|
|
23
25
|
export type { CameraInfoStrings, CameraState } from './components/VirtualWalkthrough/CameraInfo';
|
|
@@ -27,5 +29,6 @@ export type { BoundaryRingGeometry, BoundaryRingGeometryParams } from './compone
|
|
|
27
29
|
export type { GroundPlane } from './components/VirtualWalkthrough/groundPlane';
|
|
28
30
|
export type { BoundaryRingProps } from './components/VirtualWalkthrough/BoundaryRing';
|
|
29
31
|
export type { SplatModelProps } from './components/VirtualWalkthrough/SplatModel';
|
|
30
|
-
export {
|
|
32
|
+
export type { VirtualWalkthroughViewerProps } from './components/VirtualWalkthrough/VirtualWalkthroughViewer';
|
|
33
|
+
export { Annotation, AnnotationEditPane, AnnotationPanel, Application, AutoRotator, BlockingSpinner, BoundaryRing, boundaryRingMesh, BoundaryRingScript, CameraInfo, computeGroundPlane, ControlsInfoPane, GradientSky, SplatControls, SplatCrop, SplatFadeCrop, SplatModel, SplatRevealRain, TfAnnotationManager, TfXrNavigation, useDevicePerformance, VirtualWalkthroughViewer, WalkthroughCamera, yOnPlane, };
|
|
31
34
|
//# sourceMappingURL=virtualWalkthrough.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtualWalkthrough.d.ts","sourceRoot":"","sources":["../src/virtualWalkthrough.ts"],"names":[],"mappings":"AAOA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,kBAAkB,MAAM,oDAAoD,CAAC;AACpF,OAAO,eAAe,MAAM,iDAAiD,CAAC;AAC9E,OAAO,WAAW,MAAM,6CAA6C,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,eAAe,MAAM,iDAAiD,CAAC;AAC9E,OAAO,YAAY,MAAM,8CAA8C,CAAC;AACxE,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,O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ACnB,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,EACjB,QAAQ,GACT,CAAC"}
|
package/virtualWalkthrough.js
CHANGED
|
@@ -22,7 +22,9 @@ import SplatModel from './components/VirtualWalkthrough/SplatModel';
|
|
|
22
22
|
import SplatRevealRain from './components/VirtualWalkthrough/SplatRevealRain';
|
|
23
23
|
import { TfAnnotationManager } from './components/VirtualWalkthrough/TfAnnotationManager';
|
|
24
24
|
import { TfXrNavigation } from './components/VirtualWalkthrough/TfXrNavigation';
|
|
25
|
+
import VirtualWalkthroughViewer from './components/VirtualWalkthrough/VirtualWalkthroughViewer';
|
|
25
26
|
import { BoundaryRingScript, boundaryRingMesh } from './components/VirtualWalkthrough/boundary-ring';
|
|
26
27
|
import { computeGroundPlane, yOnPlane } from './components/VirtualWalkthrough/groundPlane';
|
|
27
28
|
import { WalkthroughCamera } from './components/VirtualWalkthrough/walkthrough-camera';
|
|
28
|
-
|
|
29
|
+
import { useDevicePerformance } from './hooks/useDevicePerformance';
|
|
30
|
+
export { Annotation, AnnotationEditPane, AnnotationPanel, Application, AutoRotator, BlockingSpinner, BoundaryRing, boundaryRingMesh, BoundaryRingScript, CameraInfo, computeGroundPlane, ControlsInfoPane, GradientSky, SplatControls, SplatCrop, SplatFadeCrop, SplatModel, SplatRevealRain, TfAnnotationManager, TfXrNavigation, useDevicePerformance, VirtualWalkthroughViewer, WalkthroughCamera, yOnPlane };
|