import { Singleton } from "typescript-ioc" ; import { Intersection } from "three" ; import { Subject } from "rxjs" ; @ Singleton export class PortalPlacingComponent { private readonly leftPortalSubject = new Subject < Intersection > ( ) ; readonly leftPortal$ = this . leftPortalSubject . pipe ( ) ; private readonly rightPortalSubject = new Subject < Intersection > ( ) ; readonly rightPortal$ = this . rightPortalSubject . pipe ( ) ; private target ? : Intersection ; setTarget ( target ) { this . target = target ; } removeTarget ( ) { this . target = null ; } placeLeftPortal ( ) { if ( this . target ) { this . leftPortalSubject . next ( this . target ) ; } } placeRightPortal ( ) { if ( this . target ) { this . rightPortalSubject . next ( this . target ) ; } } }