import { Camera } from '@babylonjs/core/Cameras/camera.js' ; import { CreatedInstance } from '../CreatedInstance' ; import { FiberCameraProps } from '../generatedProps' ; import BaseLifecycleListener from './BaseLifecycleListener' ; export default class CameraLifecycleListener extends BaseLifecycleListener < Camera , FiberCameraProps > { onParented ( parent , child ) { super . onParented ( parent , child ) ; if ( parent . metadata . isNode && child . metadata . isNode ) { child . hostInstance . parent = parent . hostInstance ; } } onMount ( instance ) { if ( instance . hostInstance === undefined ) { console . error ( 'Missing instance' ) ; return ; } const camera = instance . hostInstance as Camera ; const noPreventDefault = this . props . noPreventDefault === false ? false : true ; camera . attachControl ( this . scene . getEngine ( ) . getRenderingCanvas ( ) , noPreventDefault ) ; } }