Browse Source

Improved NullEngine

David Catuhe 7 năm trước cách đây
mục cha
commit
4c1e3fecf3

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 763 - 751
dist/preview release/babylon.d.ts


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 8 - 7
dist/preview release/babylon.js


+ 111 - 2
dist/preview release/babylon.max.js

@@ -49425,8 +49425,8 @@ var BABYLON;
                 var scene = camera.getScene();
                 var engine = scene.getEngine();
                 var maxSize = engine.getCaps().maxTextureSize;
-                var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderingCanvas().width) * this._options) | 0;
-                var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderingCanvas().height) * this._options) | 0;
+                var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
+                var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
                 var desiredWidth = (this._options.width || requiredWidth);
                 var desiredHeight = this._options.height || requiredHeight;
                 if (this.adaptScaleToCurrentViewport) {
@@ -73536,6 +73536,16 @@ var BABYLON;
             _this._caps.vertexArrayObject = false;
             _this._caps.instancedArrays = false;
             BABYLON.Tools.Log("Babylon.js null engine (v" + BABYLON.Engine.Version + ") launched");
+            // Wrappers
+            if (typeof URL === "undefined") {
+                URL = {
+                    createObjectURL: function () { },
+                    revokeObjectURL: function () { }
+                };
+            }
+            if (typeof Blob === "undefined") {
+                Blob = function () { };
+            }
             return _this;
         }
         NullEngine.prototype.createVertexBuffer = function (vertices) {
@@ -73656,6 +73666,23 @@ var BABYLON;
         };
         NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
         };
+        NullEngine.prototype.wipeCaches = function (bruteForce) {
+            if (this.preventCacheWipeBetweenFrames) {
+                return;
+            }
+            this.resetTextureCache();
+            this._currentEffect = null;
+            if (bruteForce) {
+                this._currentProgram = null;
+                this._stencilState.reset();
+                this._depthCullingState.reset();
+                this.setDepthFunctionToLessOrEqual();
+                this._alphaState.reset();
+            }
+            this._cachedVertexBuffers = null;
+            this._cachedIndexBuffer = null;
+            this._cachedEffectForVertexBuffers = null;
+        };
         NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
         };
         NullEngine.prototype._createTexture = function () {
@@ -73683,6 +73710,88 @@ var BABYLON;
             }
             return texture;
         };
+        NullEngine.prototype.createRenderTargetTexture = function (size, options) {
+            var fullOptions = new BABYLON.RenderTargetCreationOptions();
+            if (options !== undefined && typeof options === "object") {
+                fullOptions.generateMipMaps = options.generateMipMaps;
+                fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
+                fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
+                fullOptions.type = options.type === undefined ? BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
+                fullOptions.samplingMode = options.samplingMode === undefined ? BABYLON.Texture.TRILINEAR_SAMPLINGMODE : options.samplingMode;
+            }
+            else {
+                fullOptions.generateMipMaps = options;
+                fullOptions.generateDepthBuffer = true;
+                fullOptions.generateStencilBuffer = false;
+                fullOptions.type = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT;
+                fullOptions.samplingMode = BABYLON.Texture.TRILINEAR_SAMPLINGMODE;
+            }
+            var texture = new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_RENDERTARGET);
+            var width = size.width || size;
+            var height = size.height || size;
+            texture._depthStencilBuffer = {};
+            texture._framebuffer = {};
+            texture.baseWidth = width;
+            texture.baseHeight = height;
+            texture.width = width;
+            texture.height = height;
+            texture.isReady = true;
+            texture.samples = 1;
+            texture.generateMipMaps = fullOptions.generateMipMaps;
+            texture.samplingMode = fullOptions.samplingMode;
+            texture.type = fullOptions.type;
+            texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
+            texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
+            return texture;
+        };
+        NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
+            texture.samplingMode = samplingMode;
+        };
+        NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
+            if (this._currentRenderTarget) {
+                this.unBindFramebuffer(this._currentRenderTarget);
+            }
+            this._currentRenderTarget = texture;
+            this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
+            if (this._cachedViewport && !forceFullscreenViewport) {
+                this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
+            }
+        };
+        NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
+            if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
+            this._currentRenderTarget = null;
+            if (onBeforeUnbind) {
+                if (texture._MSAAFramebuffer) {
+                    this._currentFramebuffer = texture._framebuffer;
+                }
+                onBeforeUnbind();
+            }
+            this._currentFramebuffer = null;
+        };
+        NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
+            var vbo = {
+                capacity: 1,
+                references: 1,
+                is32Bits: false
+            };
+            return vbo;
+        };
+        NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
+            if (offset === void 0) { offset = 0; }
+        };
+        NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, offset, count) {
+        };
+        NullEngine.prototype._bindTextureDirectly = function (target, texture) {
+            if (this._activeTexturesCache[this._activeTexture] !== texture) {
+                this._activeTexturesCache[this._activeTexture] = texture;
+            }
+        };
+        NullEngine.prototype._bindTexture = function (channel, texture) {
+            if (channel < 0) {
+                return;
+            }
+            this._bindTextureDirectly(0, texture);
+        };
         return NullEngine;
     }(BABYLON.Engine));
     BABYLON.NullEngine = NullEngine;

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 763 - 751
dist/preview release/babylon.module.d.ts


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 8 - 7
dist/preview release/babylon.worker.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 8548 - 8536
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 2 - 2
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -49425,8 +49425,8 @@ var BABYLON;
                 var scene = camera.getScene();
                 var engine = scene.getEngine();
                 var maxSize = engine.getCaps().maxTextureSize;
-                var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderingCanvas().width) * this._options) | 0;
-                var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderingCanvas().height) * this._options) | 0;
+                var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
+                var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
                 var desiredWidth = (this._options.width || requiredWidth);
                 var desiredHeight = this._options.height || requiredHeight;
                 if (this.adaptScaleToCurrentViewport) {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 8548 - 8536
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 1 - 0
dist/preview release/what's new.md

@@ -17,6 +17,7 @@
 - Added support for Windows Motion Controllers ([Lewis Weaver](https://github.com/leweaver))
 - Added support for Particle animation in ParticleSystem. [Doc here](http://doc.babylonjs.com/tutorials/particles#particle-animation) ([Ibraheem Osama](https://github.com/IbraheemOsama))
 - More robust TypeScript code with *noImplicitAny*, *noImplicitThis* and *noImplicitReturns* compiler options ([deltakosh](https://github.com/deltakosh))
+- Introduced `NullEngine` which can be used to use Babylon.js in headless mode. [Doc here](http://doc.babylonjs.com/generals/nullengine) ([deltakosh](https://github.com/deltakosh)) 
 
 ## Updates
 - Added `MultiObserver`. [Doc here](http://doc.babylonjs.com/overviews/observables#multiobserver) ([deltakosh](https://github.com/deltakosh))

+ 9 - 9
src/Engine/babylon.engine.ts

@@ -677,28 +677,28 @@
         }
 
         // States
-        private _depthCullingState = new Internals._DepthCullingState();
-        private _stencilState = new Internals._StencilState();
+        protected _depthCullingState = new Internals._DepthCullingState();
+        protected _stencilState = new Internals._StencilState();
         protected _alphaState = new Internals._AlphaState();
         protected _alphaMode = Engine.ALPHA_DISABLE;
 
         // Cache
         private _internalTexturesCache = new Array<InternalTexture>();
-        private _activeTexture: number;
-        private _activeTexturesCache: { [key: string]: WebGLTexture } = {};
+        protected _activeTexture: number;
+        protected _activeTexturesCache: { [key: string]: WebGLTexture } = {};
         protected _currentEffect: Effect;
-        private _currentProgram: WebGLProgram;
+        protected _currentProgram: WebGLProgram;
         private _compiledEffects: { [key: string]: Effect } = {}
         private _vertexAttribArraysEnabled: boolean[] = [];
         protected _cachedViewport: Viewport;
         private _cachedVertexArrayObject: WebGLVertexArrayObject;
-        private _cachedVertexBuffers: any;
-        private _cachedIndexBuffer: WebGLBuffer;
-        private _cachedEffectForVertexBuffers: Effect;
+        protected _cachedVertexBuffers: any;
+        protected _cachedIndexBuffer: WebGLBuffer;
+        protected _cachedEffectForVertexBuffers: Effect;
         protected _currentRenderTarget: InternalTexture;
         private _uintIndicesCurrentlySet = false;
         private _currentBoundBuffer = new Array<WebGLBuffer>();
-        private _currentFramebuffer: WebGLFramebuffer;
+        protected _currentFramebuffer: WebGLFramebuffer;
         private _currentBufferPointers = new Array<BufferPointer>();
         private _currentInstanceLocations = new Array<number>();
         private _currentInstanceBuffers = new Array<WebGLBuffer>();

+ 127 - 0
src/Engine/babylon.nullEngine.ts

@@ -65,6 +65,18 @@
             this._caps.instancedArrays = false;
 
             Tools.Log("Babylon.js null engine (v" + Engine.Version + ") launched");
+
+            // Wrappers
+            if (typeof URL === "undefined") {
+                (<any>URL) = {
+                    createObjectURL: function() {},
+                    revokeObjectURL: function() {}
+                }
+            }
+
+            if (typeof Blob === "undefined") {
+                (<any>Blob) = function() {};         
+            }   
         }
 
         public createVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer {
@@ -221,6 +233,27 @@
         public bindBuffers(vertexBuffers: { [key: string]: VertexBuffer; }, indexBuffer: WebGLBuffer, effect: Effect): void {
         }
 
+        public wipeCaches(bruteForce?: boolean): void {
+            if (this.preventCacheWipeBetweenFrames) {
+                return;
+            }
+            this.resetTextureCache();
+            this._currentEffect = null;
+
+            if (bruteForce) {
+                this._currentProgram = null;
+
+                this._stencilState.reset();
+                this._depthCullingState.reset();
+                this.setDepthFunctionToLessOrEqual();
+                this._alphaState.reset();
+            }
+
+            this._cachedVertexBuffers = null;
+            this._cachedIndexBuffer = null;
+            this._cachedEffectForVertexBuffers = null;
+        }
+
         public draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void {
         }
 
@@ -250,5 +283,99 @@
 
             return texture;
         }
+
+        public createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture {
+            let fullOptions = new RenderTargetCreationOptions();
+
+            if (options !== undefined && typeof options === "object") {
+                fullOptions.generateMipMaps = options.generateMipMaps;
+                fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
+                fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
+                fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
+                fullOptions.samplingMode = options.samplingMode === undefined ? Texture.TRILINEAR_SAMPLINGMODE : options.samplingMode;
+            } else {
+                fullOptions.generateMipMaps = <boolean>options;
+                fullOptions.generateDepthBuffer = true;
+                fullOptions.generateStencilBuffer = false;
+                fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
+                fullOptions.samplingMode = Texture.TRILINEAR_SAMPLINGMODE;
+            }
+            var texture = new InternalTexture(this, InternalTexture.DATASOURCE_RENDERTARGET);
+
+            var width = size.width || size;
+            var height = size.height || size;
+
+            texture._depthStencilBuffer = {};
+            texture._framebuffer = {};
+            texture.baseWidth = width;
+            texture.baseHeight = height;
+            texture.width = width;
+            texture.height = height;
+            texture.isReady = true;
+            texture.samples = 1;
+            texture.generateMipMaps = fullOptions.generateMipMaps;
+            texture.samplingMode = fullOptions.samplingMode;
+            texture.type = fullOptions.type;
+            texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
+            texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
+            return texture;
+        }     
+        
+        public updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void {
+            texture.samplingMode = samplingMode;
+        }      
+        
+        public bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void {
+            if (this._currentRenderTarget) {
+                this.unBindFramebuffer(this._currentRenderTarget);
+            }
+            this._currentRenderTarget = texture;
+            this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
+            if (this._cachedViewport && !forceFullscreenViewport) {
+                this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
+            } 
+        }
+
+        public unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps = false, onBeforeUnbind?: () => void): void {
+            this._currentRenderTarget = null;
+
+            if (onBeforeUnbind) {
+                if (texture._MSAAFramebuffer) {
+                    this._currentFramebuffer = texture._framebuffer;
+                }
+                onBeforeUnbind();
+            }
+            this._currentFramebuffer = null;
+        }
+
+        public createDynamicVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer {
+            var vbo = {
+                capacity: 1,
+                references: 1,                
+                is32Bits: false
+            }
+
+            return vbo;
+        }
+
+        public updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset: number = 0): void {
+        }
+
+        public updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: number[] | Float32Array, offset?: number, count?: number): void {
+        }        
+
+        public _bindTextureDirectly(target: number, texture: InternalTexture): void {
+            if (this._activeTexturesCache[this._activeTexture] !== texture) {
+                this._activeTexturesCache[this._activeTexture] = texture;
+            }
+        }
+
+        public _bindTexture(channel: number, texture: InternalTexture): void {
+            if (channel < 0) {
+                return;
+            }
+
+            this._bindTextureDirectly(0, texture);
+        }
     }
 }

+ 2 - 2
src/PostProcess/babylon.postProcess.ts

@@ -219,8 +219,8 @@
                 var engine = scene.getEngine();
                 var maxSize = engine.getCaps().maxTextureSize;
 
-                var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderingCanvas().width) * <number>this._options) | 0;
-                var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderingCanvas().height) * <number>this._options) | 0;
+                var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * <number>this._options) | 0;
+                var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * <number>this._options) | 0;
 
                 var desiredWidth = ((<PostProcessOptions>this._options).width || requiredWidth);
                 var desiredHeight = (<PostProcessOptions>this._options).height || requiredHeight;

+ 123 - 105
tests/nullEngine/app.js

@@ -1,113 +1,131 @@
 var BABYLON = require("../../dist/preview release/babylon.max");
 var LOADERS = require("../../dist/preview release/loaders/babylonjs.loaders");
-global.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
+global.XMLHttpRequest = require('xhr2').XMLHttpRequest;
 
 var engine = new BABYLON.NullEngine();
 var scene = new BABYLON.Scene(engine);
 
-// //Create a light
-// var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(-60, 60, 80), scene);
-
-// //Create an Arc Rotate Camera - aimed negative z this time
-// var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, 1.0, 110, BABYLON.Vector3.Zero(), scene);
-
-// //Creation of 6 spheres
-// var sphere1 = BABYLON.Mesh.CreateSphere("Sphere1", 10.0, 9.0, scene);
-// var sphere2 = BABYLON.Mesh.CreateSphere("Sphere2", 2.0, 9.0, scene);//Only two segments
-// var sphere3 = BABYLON.Mesh.CreateSphere("Sphere3", 10.0, 9.0, scene);
-// var sphere4 = BABYLON.Mesh.CreateSphere("Sphere4", 10.0, 9.0, scene);
-// var sphere5 = BABYLON.Mesh.CreateSphere("Sphere5", 10.0, 9.0, scene);
-// var sphere6 = BABYLON.Mesh.CreateSphere("Sphere6", 10.0, 9.0, scene);
-
-// //Position the spheres
-// sphere1.position.x = 40;
-// sphere2.position.x = 25;
-// sphere3.position.x = 10;
-// sphere4.position.x = -5;
-// sphere5.position.x = -20;
-// sphere6.position.x = -35;
-
-// //Creation of a plane
-// var plane = BABYLON.Mesh.CreatePlane("plane", 120, scene);
-// plane.position.y = -5;
-// plane.rotation.x = Math.PI / 2;
-
-// //Creation of a material with wireFrame
-// var materialSphere1 = new BABYLON.StandardMaterial("texture1", scene);
-// materialSphere1.wireframe = true;
-
-// //Creation of a red material with alpha
-// var materialSphere2 = new BABYLON.StandardMaterial("texture2", scene);
-// materialSphere2.diffuseColor = new BABYLON.Color3(1, 0, 0); //Red
-// materialSphere2.alpha = 0.3;
-
-// //Creation of a material with an image texture
-// var materialSphere3 = new BABYLON.StandardMaterial("texture3", scene);
-// materialSphere3.diffuseTexture = new BABYLON.Texture("textures/misc.jpg", scene);
-
-// //Creation of a material with translated texture
-// var materialSphere4 = new BABYLON.StandardMaterial("texture4", scene);
-// materialSphere4.diffuseTexture = new BABYLON.Texture("textures/misc.jpg", scene);
-// materialSphere4.diffuseTexture.vOffset = 0.1;//Vertical offset of 10%
-// materialSphere4.diffuseTexture.uOffset = 0.4;//Horizontal offset of 40%
-
-// //Creation of a material with an alpha texture
-// var materialSphere5 = new BABYLON.StandardMaterial("texture5", scene);
-// materialSphere5.diffuseTexture = new BABYLON.Texture("textures/tree.png", scene);
-// materialSphere5.diffuseTexture.hasAlpha = true;//Has an alpha
-
-// //Creation of a material and show all the faces
-// var materialSphere6 = new BABYLON.StandardMaterial("texture6", scene);
-// materialSphere6.diffuseTexture = new BABYLON.Texture("textures/tree.png", scene);
-// materialSphere6.diffuseTexture.hasAlpha = true;//Have an alpha
-// materialSphere6.backFaceCulling = false;//Show all the faces of the element
-
-// //Creation of a repeated textured material
-// var materialPlane = new BABYLON.StandardMaterial("texturePlane", scene);
-// materialPlane.diffuseTexture = new BABYLON.Texture("textures/grass.jpg", scene);
-// materialPlane.diffuseTexture.uScale = 5.0;//Repeat 5 times on the Vertical Axes
-// materialPlane.diffuseTexture.vScale = 5.0;//Repeat 5 times on the Horizontal Axes
-// materialPlane.backFaceCulling = false;//Always show the front and the back of an element
-
-// //Apply the materials to meshes
-// sphere1.material = materialSphere1;
-// sphere2.material = materialSphere2;
-
-// sphere3.material = materialSphere3;
-// sphere4.material = materialSphere4;
-
-// sphere5.material = materialSphere5;
-// sphere6.material = materialSphere6;
-
-// plane.material = materialPlane;
-
-//Adding a light
-var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);
-
-//Adding an Arc Rotate Camera
-var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene);
-
-// The first parameter can be used to specify which mesh to import. Here we import all meshes
-BABYLON.SceneLoader.ImportMesh("", "https://playground.babylonjs.com/scenes/", "skull.babylon", scene, function (newMeshes) {
-    // Set the target of the camera to the first imported mesh
-    camera.target = newMeshes[0];
-
-    console.log("Meshes loaded from babylon file: " + newMeshes.length);
-    for (var index = 0; index < newMeshes.length; index++) {
-        console.log(newMeshes[index].toString());
-    }
-
-    BABYLON.SceneLoader.ImportMesh("", "https://www.babylonjs.com/Assets/DamagedHelmet/glTF/", "DamagedHelmet.gltf", scene, function (meshes) {
-        console.log("Meshes loaded from gltf file: " + meshes.length);
-        for (var index = 0; index < meshes.length; index++) {
-            console.log(meshes[index].toString());
-        }
-    });
-
-    console.log("render started")
-    engine.runRenderLoop(function() {
-        scene.render();
-    })
-});
+// //Adding a light
+// var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);
+
+// //Adding an Arc Rotate Camera
+// var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene);
+
+// // The first parameter can be used to specify which mesh to import. Here we import all meshes
+// BABYLON.SceneLoader.ImportMesh("", "https://playground.babylonjs.com/scenes/", "skull.babylon", scene, function (newMeshes) {
+//     // Set the target of the camera to the first imported mesh
+//     camera.target = newMeshes[0];
+
+//     console.log("Meshes loaded from babylon file: " + newMeshes.length);
+//     for (var index = 0; index < newMeshes.length; index++) {
+//         console.log(newMeshes[index].toString());
+//     }
+
+//     BABYLON.SceneLoader.ImportMesh("", "https://www.babylonjs.com/Assets/DamagedHelmet/glTF/", "DamagedHelmet.gltf", scene, function (meshes) {
+//         console.log("Meshes loaded from gltf file: " + meshes.length);
+//         for (var index = 0; index < meshes.length; index++) {
+//             console.log(meshes[index].toString());
+//         }
+//     });
+
+//     console.log("render started")
+//     engine.runRenderLoop(function() {
+//         scene.render();
+//     })
+// });
     
+// Setup environment
+// var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 90, BABYLON.Vector3.Zero(), scene);
+// camera.lowerBetaLimit = 0.1;
+// camera.upperBetaLimit = (Math.PI / 2) * 0.9;
+// camera.lowerRadiusLimit = 30;
+// camera.upperRadiusLimit = 150;
+
+// // light1
+// var light = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(-1, -2, -1), scene);
+// light.position = new BABYLON.Vector3(20, 40, 20);
+// light.intensity = 0.5;
+
+// var lightSphere = BABYLON.Mesh.CreateSphere("sphere", 10, 2, scene);
+// lightSphere.position = light.position;
+// lightSphere.material = new BABYLON.StandardMaterial("light", scene);
+// lightSphere.material.emissiveColor = new BABYLON.Color3(1, 1, 0);
+
+// // light2
+// var light2 = new BABYLON.SpotLight("spot02", new BABYLON.Vector3(30, 40, 20),
+//                                             new BABYLON.Vector3(-1, -2, -1), 1.1, 16, scene);
+// light2.intensity = 0.5;
+
+// var lightSphere2 = BABYLON.Mesh.CreateSphere("sphere", 10, 2, scene);
+// lightSphere2.position = light2.position;
+// lightSphere2.material = new BABYLON.StandardMaterial("light", scene);
+// lightSphere2.material.emissiveColor = new BABYLON.Color3(1, 1, 0);
+
+// // Ground
+// var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
+// var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
+// groundMaterial.diffuseTexture = new BABYLON.Texture("textures/ground.jpg", scene);
+// groundMaterial.diffuseTexture.uScale = 6;
+// groundMaterial.diffuseTexture.vScale = 6;
+// groundMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
+// ground.position.y = -2.05;
+// ground.material = groundMaterial;
+
+// // Torus
+// var torus = BABYLON.Mesh.CreateTorus("torus", 4, 2, 30, scene, false);
+
+// // Box
+// var box = BABYLON.Mesh.CreateBox("box", 3);
+// box.parent = torus;	
+
+// // Shadows
+// var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
+// shadowGenerator.addShadowCaster(torus);
+// shadowGenerator.useExponentialShadowMap = true;
+
+// var shadowGenerator2 = new BABYLON.ShadowGenerator(1024, light2);
+// shadowGenerator2.addShadowCaster(torus);
+// shadowGenerator2.usePoissonSampling = true;
+
+// ground.receiveShadows = true;
+
+// // Animations
+// var alpha = 0;
+// scene.registerBeforeRender(function () {
+//     torus.rotation.x += 0.01;
+//     torus.rotation.z += 0.02;
+
+//     torus.position = new BABYLON.Vector3(Math.cos(alpha) * 30, 10, Math.sin(alpha) * 30);
+//     alpha += 0.01;
+
+// });
+	//Adding a light
+	var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);
+    
+        //Adding an Arc Rotate Camera
+        var camera = new BABYLON.ArcRotateCamera("Camera", -0.5, 2.2, 100, BABYLON.Vector3.Zero(), scene);
+    
+        // The first parameter can be used to specify which mesh to import. Here we import all meshes
+        BABYLON.SceneLoader.ImportMesh("", "https://www.babylonjs-playground.com/scenes/", "skull.babylon", scene, function (newMeshes) {
+            // Set the target of the camera to the first imported mesh
+            camera.target = newMeshes[0];
+    
+            newMeshes[0].material = new BABYLON.StandardMaterial("skull", scene);
+            newMeshes[0].material.emissiveColor = new BABYLON.Color3(0.2, 0.2, 0.2);
+        });
+    
+        // Create the "God Rays" effect (volumetric light scattering)
+        var godrays = new BABYLON.VolumetricLightScatteringPostProcess('godrays', 1.0, camera, null, 100, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false);
+    
+        // By default it uses a billboard to render the sun, just apply the desired texture
+        // position and scale
+        godrays.mesh.material.diffuseTexture = new BABYLON.Texture('https://www.babylonjs-playground.com/textures/sun.png', scene, true, false, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
+        godrays.mesh.material.diffuseTexture.hasAlpha = true;
+        godrays.mesh.position = new BABYLON.Vector3(-150, 150, 150);
+        godrays.mesh.scaling = new BABYLON.Vector3(350, 350, 350);
+    
+        light.position = godrays.mesh.position;
 
+engine.runRenderLoop(function() {
+    scene.render();
+})

+ 1 - 1
tests/nullEngine/package.json

@@ -1,5 +1,5 @@
 {
   "devDependencies": {
-    "xmlhttprequest": "^1.8.0"
+    "xhr2": "^0.1.4"
   }
 }