import { Scene } from '@babylonjs/core/scene.js' ; import { CreatedInstance } from '../CreatedInstance' ; import { LifecycleListener } from '../LifecycleListener' ; import { applyInitialPropsToCreatedInstance } from '../UpdateInstance' ; export default abstract class BaseLifecycleListener < T , U > implements LifecycleListener < T > { constructor ( protected scene , protected props ) { } onParented ( parent , child ) { if ( child . customProps . assignFrom !== undefined ) { const parentHostInstance = parent . metadata . className === 'root' ? this . scene : parent . hostInstance ; if ( parentHostInstance [ child . customProps . assignFrom ] === undefined ) { console . error ( `Cannot find existing property ${ child . customProps . assignFrom } on parent component (check your 'assignFrom')` ) ; } else { child . hostInstance = parentHostInstance [ child . customProps . assignFrom ] ; if ( child . deferredCreationProps && child . propsHandlers ) { applyInitialPropsToCreatedInstance ( child , child . deferredCreationProps ) ; } else { console . warn ( 'cannot assign deferred props.  they are lost.' ) ; } child . deferredCreationProps = undefined ; } } } onChildAdded ( child , parent ) { } onMount ( instance ) { } onUnmount ( ) { } }