1- import React , { useRef } from 'react' ;
2- import { Scene as AScene } from 'aframe' ;
1+ import React , { useEffect , useRef } from 'react' ;
2+ import { Scene as AScene , SystemDefinition } from 'aframe' ;
33import { Scene as SceneComponent } from 'aframe-react-component' ;
44import { getAframeProps } from 'aframe-react-component/dist/utils/common' ;
5+ import { IMindARFaceSystem } from 'mind-ar-ts/types/face-target/aframe' ;
6+ import { IMindARImageSystem } from 'mind-ar-ts/types/image-target/aframe' ;
57import { generateFaceProps , generateImageProps } from '../utils/defaultprops' ;
68import { mergeRefs } from '../utils/common' ;
79import { Scene as _Scene } from '../utils/interfaces' ;
10+ import { AR_COMPONENT_NAME } from '../utils/constant' ;
811
912const Scene = React . forwardRef < AScene , _Scene > ( ( { children, ...props } , ref ) => {
1013 const sceneRef = useRef < AScene > ( null ) ;
@@ -16,6 +19,22 @@ const Scene = React.forwardRef<AScene, _Scene>(({ children, ...props }, ref) =>
1619 ...rest
1720 } = props ;
1821
22+ useEffect ( ( ) => {
23+ if ( ! sceneRef . current ) return ;
24+
25+ if ( ! mindARImage || ! mindARFace ) return ;
26+
27+ const arSystem = sceneRef . current . systems [
28+ mindARImage ? AR_COMPONENT_NAME . IMAGE . IMAGE_SYSTEM : AR_COMPONENT_NAME . FACE . FACE_SYSTEM
29+ ] as SystemDefinition < IMindARImageSystem | IMindARFaceSystem > ;
30+
31+ return ( ) => {
32+ if ( ! arSystem ) return ;
33+
34+ arSystem . stop ( ) ;
35+ } ;
36+ } , [ sceneRef . current ] ) ;
37+
1938 return (
2039 < SceneComponent
2140 { ...rest }
0 commit comments