declare var os ; export default class TestLoadMesh { private canvas : any ; private engine : any ; private scene : any ; constructor ( ) { this . canvas = new Canvas ( ) ; this . engine = new BABYLON . Engine ( this . canvas , true , { stencil : true , disableWebGL2Support : false , preserveDrawingBuffer : true , premultipliedAlpha : false } ) ; this . engine . disableManifestCheck = true ; this . engine . enableOfflineSupport = true ; BABYLON . Engine . ShadersRepository = 'Shaders/' ; } createScene ( fileName ) { const scene = new BABYLON . Scene ( this . engine ) ; const camera = new BABYLON . FreeCamera ( 'Camera' , new BABYLON . Vector3 ( 0 , 5 , - 10 ) , scene ) ; camera . setTarget ( BABYLON . Vector3 . Zero ( ) ) ; camera . attachControl ( this . canvas , true ) ; BABYLON . SceneLoader . Load ( '' , 'file://' + ( fileName || 'Assets/Spaceship.babylon' ) , this . engine , ( loadedScene ) => { console . log ( 'Scene loaded' ) ; loadedScene . activeCamera . attachControl ( this . canvas ) ; loadedScene . onPrePointerObservable . add ( function ( pointerInfo , eventState ) { const event = pointerInfo . event ; let delta = 0 ; if ( event . wheelDelta ) { delta = event . wheelDelta ; } else if ( event . detail ) { delta = - event . detail ; } if ( delta ) { const dir = loadedScene . activeCamera . getDirection ( BABYLON . Axis . Z ) ; if ( delta > 0 ) { loadedScene . activeCamera . position . addInPlace ( dir . scaleInPlace ( delta * 100 ) ) ; } else { loadedScene . activeCamera . position . subtractInPlace ( dir . scaleInPlace ( - delta * 100 ) ) ; } } } , BABYLON . PointerEventTypes . POINTERWHEEL , false ) ; this . scene = loadedScene ; } ) ; return scene ; } run ( fileName ) { this . scene = this . createScene ( fileName ) ; this . engine . runRenderLoop ( ( ) => { const before = os . clock ( ) ; this . scene . render ( ) ; const time = ( os . clock ( ) - before ) ; console . log ( `Render time: ${ time } sec.` ) ; } ) ; window . addEventListener ( 'resize' , ( ) => { this . engine . resize ( ) ; } ) ; } }