Fix ViewPanel axis registration
This commit is contained in:
parent
34f8bc5c33
commit
1f29ff5098
1 changed files with 7 additions and 3 deletions
|
|
@ -22,7 +22,10 @@ export default function ViewerPanel({className, style}: {className?: string, sty
|
||||||
for (const ref of [modelViewerRef, axesViewerRef]) {
|
for (const ref of [modelViewerRef, axesViewerRef]) {
|
||||||
const otherRef = ref === modelViewerRef ? axesViewerRef : modelViewerRef;
|
const otherRef = ref === modelViewerRef ? axesViewerRef : modelViewerRef;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!ref.current) return;
|
||||||
|
|
||||||
function handleCameraChange(e: any) {
|
function handleCameraChange(e: any) {
|
||||||
|
if (!otherRef.current) return;
|
||||||
if (e.detail.source === 'user-interaction') {
|
if (e.detail.source === 'user-interaction') {
|
||||||
const cameraOrbit = ref.current.getCameraOrbit();
|
const cameraOrbit = ref.current.getCameraOrbit();
|
||||||
cameraOrbit.radius = otherRef.current.getCameraOrbit().radius;
|
cameraOrbit.radius = otherRef.current.getCameraOrbit().radius;
|
||||||
|
|
@ -30,8 +33,9 @@ export default function ViewerPanel({className, style}: {className?: string, sty
|
||||||
otherRef.current.cameraOrbit = cameraOrbit.toString();
|
otherRef.current.cameraOrbit = cameraOrbit.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ref.current.addEventListener('camera-change', handleCameraChange);
|
const element = ref.current;
|
||||||
return () => ref.current.removeEventListener('camera-change', handleCameraChange);
|
element.addEventListener('camera-change', handleCameraChange);
|
||||||
|
return () => element.removeEventListener('camera-change', handleCameraChange);
|
||||||
}, [ref.current, otherRef.current]);
|
}, [ref.current, otherRef.current]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,7 +73,7 @@ export default function ViewerPanel({className, style}: {className?: string, sty
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
right: 0,
|
left: 0,
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
height: '100px',
|
height: '100px',
|
||||||
width: '100px',
|
width: '100px',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue