declare var os ; declare var Canvas ; export default class TestApp2 { private canvas : any ; private engine : any ; constructor ( ) { this . canvas = new Canvas ( ) ; this . engine = new BABYLON . Engine ( this . canvas , true , { stencil : true , disableWebGL2Support : false , preserveDrawingBuffer : true , premultipliedAlpha : false } ) ; BABYLON . Engine . ShadersRepository = 'Shaders/' ; } createScene ( ) { const scene = new BABYLON . Scene ( this . engine ) ; const camera = new BABYLON . FreeCamera ( 'camera1' , new BABYLON . Vector3 ( 0 , 5 , 150 ) , scene ) ; camera . setTarget ( BABYLON . Vector3 . Zero ( ) ) ; camera . attachControl ( this . canvas , true ) ; const light0 = new BABYLON . PointLight ( "Omni" , new BABYLON . Vector3 ( 20 , 20 , 100 ) , scene ) ; const sphere1 = BABYLON . Mesh . CreateSphere ( "Sphere1" , 10 , 6.0 , scene ) ; const sphere2 = BABYLON . Mesh . CreateSphere ( "Sphere2" , 2 , 7.0 , scene ) ; const sphere3 = BABYLON . Mesh . CreateSphere ( "Sphere3" , 10 , 9.0 , scene ) ; const sphere4 = BABYLON . Mesh . CreateSphere ( "Sphere4" , 10 , 9.0 , scene ) ; const sphere5 = BABYLON . Mesh . CreateSphere ( "Sphere5" , 10 , 9.0 , scene ) ; const sphere6 = BABYLON . Mesh . CreateSphere ( "Sphere6" , 10 , 9.0 , scene ) ; sphere1 . position . x = 40 ; sphere2 . position . x = 30 ; sphere3 . position . x = 10 ; sphere4 . position . x = 0 ; sphere5 . position . x = - 20 ; sphere6 . position . x = - 30 ; const plan = BABYLON . Mesh . CreatePlane ( "plan" , 120 , scene ) ; plan . position . z = - 10 ; plan . rotation . y = 3.14 ; const materialSphere1 = new BABYLON . StandardMaterial ( "texture1" , scene ) ; materialSphere1 . wireframe = true ; const materialSphere2 = new BABYLON . StandardMaterial ( "texture2" , scene ) ; materialSphere2 . diffuseColor = new BABYLON . Color3 ( 1 , 0 , 0 ) ; materialSphere2 . alpha = 0.7 ; const materialSphere3 = new BABYLON . StandardMaterial ( "texture3" , scene ) ; materialSphere3 . diffuseTexture = new BABYLON . Texture ( "Textures/text.jpg" , scene ) ; const materialSphere4 = new BABYLON . StandardMaterial ( "texture4" , scene ) ; materialSphere4 . diffuseTexture = new BABYLON . Texture ( "Textures/text.jpg" , scene ) ; materialSphere4 . diffuseTexture . vOffset = 0.1 ; materialSphere4 . diffuseTexture . uOffset = 0.4 ; const materialSphere5 = new BABYLON . StandardMaterial ( "texture5" , scene ) ; materialSphere5 . diffuseTexture = new BABYLON . Texture ( "Textures/Planet.png" , scene ) ; materialSphere5 . diffuseTexture . hasAlpha = true ; const materialSphere6 = new BABYLON . StandardMaterial ( "texture6" , scene ) ; materialSphere6 . diffuseTexture = new BABYLON . Texture ( "Textures/Planet.png" , scene ) ; materialSphere6 . diffuseTexture . hasAlpha = true ; materialSphere6 . backFaceCulling = false ; const materialPlan = new BABYLON . StandardMaterial ( "texturePlane" , scene ) ; materialPlan . diffuseTexture = new BABYLON . Texture ( "Textures/grass_texture.jpg" , scene ) ; materialPlan . diffuseTexture . uScale = 5.0 ; materialPlan . diffuseTexture . vScale = 5.0 ; materialPlan . backFaceCulling = false ; sphere1 . material = materialSphere1 ; sphere2 . material = materialSphere2 ; sphere3 . material = materialSphere3 ; sphere4 . material = materialSphere4 ; sphere5 . material = materialSphere5 ; sphere6 . material = materialSphere6 ; plan . material = materialPlan ; scene . 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 = scene . activeCamera . getDirection ( BABYLON . Axis . Z ) ; if ( delta > 0 ) { scene . activeCamera . position . addInPlace ( dir . scaleInPlace ( delta * 10 ) ) ; } else { scene . activeCamera . position . subtractInPlace ( dir . scaleInPlace ( - delta * 10 ) ) ; } } } , BABYLON . PointerEventTypes . POINTERWHEEL , false ) ; return scene ; } run ( ) { const scene = this . createScene ( ) ; this . engine . runRenderLoop ( ( ) => { const before = os . clock ( ) ; scene . render ( ) ; const time = ( os . clock ( ) - before ) ; console . log ( `Render time: ${ time } sec.` ) ; } ) ; window . addEventListener ( 'resize' , ( ) => { this . engine . resize ( ) ; } ) ; } }