interface SourceParameters { camera : THREE . Camera | null ; renderer : THREE . WebGLRenderer | null ; sourceType : "imageData" ; width : number ; height : number ; } param parameters export class Source { private parameters : SourceParameters ; constructor ( parameters ) { if ( ! parameters . renderer ) { throw Error ( "ThreeJS Renderer is required" ) ; } if ( ! parameters . camera ) { throw Error ( "ThreeJS Camera is required" ) ; } this . parameters = { renderer : null , camera : null , sourceType : "imageData" , width : 480 , height : 853 } ; this . setParameters ( parameters ) ; } public setParameters ( parameters ) { if ( ! parameters ) { return ; } for ( const key in parameters ) { if ( key ) { const newValue = parameters [ key ] ; if ( newValue === undefined ) { console . warn ( key + "' parameter is undefined." ) ; continue ; } const currentValue = ( this . parameters as any ) [ key ] ; if ( currentValue === undefined ) { console . warn ( key + "' is not a property of this Source." ) ; continue ; } ( this . parameters as any ) [ key ] = newValue ; } } } get renderer ( ) { return this . parameters . renderer ; } get camera ( ) { return this . parameters . camera ; } public dispose ( ) { } public initialize ( ) { return new Promise ( ( resolve , reject ) => { const onReady = ( ) => { resolve ( ) ; } ; const onError = ( message ) => { reject ( message ) ; } ; this . _initSourceImageData ( onReady , onError ) ; return this ; } ) ; } private _initSourceImageData ( onReady , onError ) { onReady ( ) ; } } export default Source ;