import RnObject from '../core/RnObject' ; import SceneGraphComponent from '../components/SceneGraphComponent' ; import EntityRepository from '../core/EntityRepository' ; import Entity from '../core/Entity' ; /**
 * Abstract Gizmo class
 */ export default abstract class Gizmo extends RnObject { protected __entityRepository = EntityRepository . getInstance ( ) ; /**
     * The top entity of this gizmo group.
     * A programmer who implements a gizmo class has to make this entity
     * a child of the target entity's scene graph component
     * that the gizmo will belong to manually.
     */ protected __topEntity ? : Entity ; /** the target entity which this gizmo belong to */ protected __target : Entity ; protected __isVisible = false ; param entity constructor ( target ) { super ( ) ; this . __target = target ; this . setGizmoTag ( ) ; } set isVisible ( flg ) { this . __isVisible = flg ; if ( this . __topEntity ) { this . __topEntity . getSceneGraph ( ) . setVisibilityRecursively ( flg ) ; } } get isVisible ( ) { return this . __isVisible ; } abstract isSetup : boolean ; private abstract _setup ( ) ; private abstract _update ( ) ; protected __toSkipSetup ( ) { if ( this . isSetup ) { return true ; } if ( this . __target . matchTag ( 'Being' , 'gizmo' ) ) { return true ; } return false ; } protected setGizmoTag ( ) { if ( this . __topEntity ) { this . __topEntity . tryToSetTag ( { tag : 'Being' , value : 'gizmo' } ) ; this . __topEntity . tryToSetTag ( { tag : 'Gizmo' , value : 'top' } ) ; const sceneGraphs = SceneGraphComponent . flattenHierarchy ( this . __topEntity . getSceneGraph ( ) , false ) ; for ( const sg of sceneGraphs ) { sg . entity . tryToSetTag ( { tag : 'Being' , value : 'gizmo' } ) ; } } } }