Browse Source

Merge pull request #2943 from BabylonJS/master

Nightly
David Catuhe 8 năm trước cách đây
mục cha
commit
c4d34b1e0e
41 tập tin đã thay đổi với 34241 bổ sung33278 xóa
  1. 6 0
      .vscode/launch.json
  2. 18 28
      Tools/Gulp/config.json
  3. 4030 3971
      dist/preview release/babylon.d.ts
  4. 49 49
      dist/preview release/babylon.js
  5. 2273 2037
      dist/preview release/babylon.max.js
  6. 4030 3971
      dist/preview release/babylon.module.d.ts
  7. 50 50
      dist/preview release/babylon.worker.js
  8. 10539 10480
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  9. 49 49
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  10. 1869 1848
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  11. 10539 10480
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts
  12. 7 0
      dist/preview release/gui/babylon.gui.d.ts
  13. 24 0
      dist/preview release/gui/babylon.gui.js
  14. 3 3
      dist/preview release/gui/babylon.gui.min.js
  15. 7 0
      dist/preview release/gui/babylon.gui.module.d.ts
  16. 263 263
      dist/preview release/inspector/babylon.inspector.bundle.js
  17. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  18. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  19. 2 2
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  20. 3 3
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  21. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  22. 3 3
      dist/preview release/loaders/babylonjs.loaders.min.js
  23. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  24. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  25. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  26. 3 3
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  27. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  28. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  29. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  30. 18 1
      gui/src/controls/button.ts
  31. 1 0
      gui/src/controls/control.ts
  32. 14 0
      gui/src/controls/textBlock.ts
  33. 1 2
      src/Debug/babylon.debugLayer.ts
  34. 12 7
      src/babylon.engine.ts
  35. 257 0
      src/Engine/babylon.nullEngine.ts
  36. 0 0
      src/Engine/babylon.webgl2.ts
  37. 14 10
      src/Materials/babylon.effect.ts
  38. 24 5
      src/Tools/babylon.tools.ts
  39. 3 1
      src/babylon.scene.ts
  40. 113 0
      tests/nullEngine/app.js
  41. 5 0
      tests/nullEngine/package.json

+ 6 - 0
.vscode/launch.json

@@ -2,6 +2,12 @@
     "version": "0.1.0",
     "configurations": [
         {
+            "name": "Launch nullEngine",
+            "type": "node",
+            "request": "launch",
+            "program": "${workspaceFolder}/tests/nullEngine/app.js"
+        },
+        {
             "name": "Launch sandbox (Chrome)",
             "type": "chrome",
             "request": "launch",

+ 18 - 28
Tools/Gulp/config.json

@@ -60,7 +60,6 @@
             "textureFormats",
             "debug",
             "morphTargets",
-            "colorCurves",
             "octrees",
             "simd",
             "vr",
@@ -70,12 +69,12 @@
             "assetsManager",
             "mapTexture",
             "dynamicFloatArray",
-            "imageProcessing",
             "serialization",
             "probes",
             "layer",
             "textureTools",
-            "cameraBehaviors"
+            "cameraBehaviors",
+            "nullEngine"
         ],
         "minimal": [
             "standardMaterial",
@@ -137,7 +136,6 @@
             "textureFormats",
             "debug",
             "morphTargets",
-            "colorCurves",
             "octrees",
             "simd",
             "vr",
@@ -175,7 +173,7 @@
                 "../../src/States/babylon.alphaCullingState.js",
                 "../../src/States/babylon.depthCullingState.js",
                 "../../src/States/babylon.stencilState.js",
-                "../../src/babylon.engine.js",
+                "../../src/Engine/babylon.engine.js",
                 "../../src/babylon.node.js",
                 "../../src/Culling/babylon.boundingSphere.js",
                 "../../src/Culling/babylon.boundingBox.js",
@@ -201,10 +199,15 @@
                 "../../src/Mesh/babylon.mesh.vertexData.js",
                 "../../src/Mesh/babylon.geometry.js",
                 "../../src/PostProcess/babylon.postProcessManager.js",
-                "../../src/Tools/babylon.performanceMonitor.js"
+                "../../src/Tools/babylon.performanceMonitor.js",
+                "../../src/Materials/babylon.imageProcessingConfiguration.js",
+                "../../src/Materials/Textures/babylon.colorGradingTexture.js",
+                "../../src/Materials/babylon.colorCurves.js"
             ],
             "shaderIncludes": [
-                "depthPrePass"
+                "depthPrePass",
+                "imageProcessingDeclaration",
+                "imageProcessingFunctions"
             ]
         },
         "particles": {
@@ -220,6 +223,14 @@
                 "particles.fragment"
             ]
         },
+        "nullEngine": {
+            "files": [
+                "../../src/Engine/babylon.nullEngine.js"
+            ],
+            "dependUpon": [
+                "core"
+            ]
+        },        
         "cameraBehaviors": {
             "files": [
                 "../../src/Behaviors/Cameras/babylon.framingBehavior.js",
@@ -932,27 +943,6 @@
                 "core"
             ]
         },
-        "colorCurves": {
-            "files": [
-                "../../src/Materials/Textures/babylon.colorGradingTexture.js",
-                "../../src/Materials/babylon.colorCurves.js"
-            ],
-            "dependUpon": [
-                "core"
-            ]
-        },
-        "imageProcessing": {
-            "files": [
-                "../../src/Materials/babylon.imageProcessingConfiguration.js"
-            ],
-            "dependUpon": [
-                "colorCurves"
-            ],
-            "shaderIncludes": [
-                "imageProcessingDeclaration",
-                "imageProcessingFunctions"
-            ]
-        },
         "octrees": {
             "files": [
                 "../../src/Culling/Octrees/babylon.octree.js",

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


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


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


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


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


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


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


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


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


+ 7 - 0
dist/preview release/gui/babylon.gui.d.ts

@@ -508,6 +508,11 @@ declare module BABYLON.GUI {
         private _lines;
         private _totalHeight;
         private _resizeToFit;
+        /**
+        * An event triggered after the text is changed
+        * @type {BABYLON.Observable}
+        */
+        onTextChangedObservable: Observable<TextBlock>;
         resizeToFit: boolean;
         textWrapping: boolean;
         text: string;
@@ -521,6 +526,7 @@ declare module BABYLON.GUI {
         protected _parseLine(line: string, context: CanvasRenderingContext2D): object;
         protected _parseLineWithTextWrapping(line: string, context: CanvasRenderingContext2D): object;
         protected _renderLines(context: CanvasRenderingContext2D): void;
+        dispose(): void;
     }
 }
 
@@ -582,6 +588,7 @@ declare module BABYLON.GUI {
         static CreateImageButton(name: string, text: string, imageUrl: string): Button;
         static CreateImageOnlyButton(name: string, imageUrl: string): Button;
         static CreateSimpleButton(name: string, text: string): Button;
+        static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
     }
 }
 

+ 24 - 0
dist/preview release/gui/babylon.gui.js

@@ -1627,6 +1627,7 @@ var BABYLON;
             };
             Control.prototype.dispose = function () {
                 this.onDirtyObservable.clear();
+                this.onAfterDrawObservable.clear();
                 this.onPointerDownObservable.clear();
                 this.onPointerEnterObservable.clear();
                 this.onPointerMoveObservable.clear();
@@ -2945,6 +2946,11 @@ var BABYLON;
                 _this._textHorizontalAlignment = GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
                 _this._textVerticalAlignment = GUI.Control.VERTICAL_ALIGNMENT_CENTER;
                 _this._resizeToFit = false;
+                /**
+                * An event triggered after the text is changed
+                * @type {BABYLON.Observable}
+                */
+                _this.onTextChangedObservable = new BABYLON.Observable();
                 _this.text = text;
                 return _this;
             }
@@ -2986,6 +2992,7 @@ var BABYLON;
                     }
                     this._text = value;
                     this._markAsDirty();
+                    this.onTextChangedObservable.notifyObservers(this);
                 },
                 enumerable: true,
                 configurable: true
@@ -3119,6 +3126,10 @@ var BABYLON;
                     this.height = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length + 'px';
                 }
             };
+            TextBlock.prototype.dispose = function () {
+                _super.prototype.dispose.call(this);
+                this.onTextChangedObservable.clear();
+            };
             return TextBlock;
         }(GUI.Control));
         GUI.TextBlock = TextBlock;
@@ -3478,6 +3489,19 @@ var BABYLON;
                 result.addControl(textBlock);
                 return result;
             };
+            Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
+                var result = new Button(name);
+                // Adding image
+                var iconImage = new BABYLON.GUI.Image(name + "_icon", imageUrl);
+                iconImage.stretch = BABYLON.GUI.Image.STRETCH_FILL;
+                result.addControl(iconImage);
+                // Adding text
+                var textBlock = new BABYLON.GUI.TextBlock(name + "_button", text);
+                textBlock.textWrapping = true;
+                textBlock.textHorizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
+                result.addControl(textBlock);
+                return result;
+            };
             return Button;
         }(GUI.Rectangle));
         GUI.Button = Button;

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


+ 7 - 0
dist/preview release/gui/babylon.gui.module.d.ts

@@ -513,6 +513,11 @@ declare module BABYLON.GUI {
         private _lines;
         private _totalHeight;
         private _resizeToFit;
+        /**
+        * An event triggered after the text is changed
+        * @type {BABYLON.Observable}
+        */
+        onTextChangedObservable: Observable<TextBlock>;
         resizeToFit: boolean;
         textWrapping: boolean;
         text: string;
@@ -526,6 +531,7 @@ declare module BABYLON.GUI {
         protected _parseLine(line: string, context: CanvasRenderingContext2D): object;
         protected _parseLineWithTextWrapping(line: string, context: CanvasRenderingContext2D): object;
         protected _renderLines(context: CanvasRenderingContext2D): void;
+        dispose(): void;
     }
 }
 
@@ -587,6 +593,7 @@ declare module BABYLON.GUI {
         static CreateImageButton(name: string, text: string, imageUrl: string): Button;
         static CreateImageOnlyButton(name: string, imageUrl: string): Button;
         static CreateSimpleButton(name: string, text: string): Button;
+        static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
     }
 }
 

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


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


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


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


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


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


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


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


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


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


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 3 - 3
dist/preview release/materialsLibrary/babylonjs.materials.min.js


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


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


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


+ 18 - 1
gui/src/controls/button.ts

@@ -136,5 +136,22 @@ module BABYLON.GUI {
 
             return result;
         }
+        
+        public static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button {
+            var result = new Button(name);
+
+            // Adding image
+            var iconImage = new BABYLON.GUI.Image(name + "_icon", imageUrl);
+            iconImage.stretch = BABYLON.GUI.Image.STRETCH_FILL;
+            result.addControl(iconImage);         
+            
+            // Adding text
+            var textBlock = new BABYLON.GUI.TextBlock(name + "_button", text);
+            textBlock.textWrapping = true;
+            textBlock.textHorizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
+            result.addControl(textBlock);   
+
+            return result;
+        }
     }    
-}
+}

+ 1 - 0
gui/src/controls/control.ts

@@ -935,6 +935,7 @@ module BABYLON.GUI {
 
         public dispose() {
             this.onDirtyObservable.clear();
+            this.onAfterDrawObservable.clear();
             this.onPointerDownObservable.clear();
             this.onPointerEnterObservable.clear();
             this.onPointerMoveObservable.clear();

+ 14 - 0
gui/src/controls/textBlock.ts

@@ -12,6 +12,12 @@ module BABYLON.GUI {
         private _totalHeight: number;
         private _resizeToFit: boolean = false;
 
+        /**
+        * An event triggered after the text is changed
+        * @type {BABYLON.Observable}
+        */
+        public onTextChangedObservable = new Observable<TextBlock>();
+
         get resizeToFit(): boolean {
             return this._resizeToFit;
         }
@@ -47,6 +53,8 @@ module BABYLON.GUI {
             }
             this._text = value;
             this._markAsDirty();
+
+            this.onTextChangedObservable.notifyObservers(this);
         }
 
         public get textHorizontalAlignment(): number {
@@ -194,5 +202,11 @@ module BABYLON.GUI {
                 this.height = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length + 'px';
             }
         }
+
+        dispose(): void {
+            super.dispose();
+
+            this.onTextChangedObservable.clear();
+        }
     }
 }

+ 1 - 2
src/Debug/babylon.debugLayer.ts

@@ -5,8 +5,7 @@ module BABYLON {
 
     export class DebugLayer {
         private _scene: Scene;
-        // Get protocol used - http or https
-        public static InspectorURL = window.location.href.split('/')[0] + '//preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
+        public static InspectorURL = 'https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js';
         // The inspector instance
         private _inspector: any;
 

+ 12 - 7
src/babylon.engine.ts

@@ -628,7 +628,7 @@
         public onVRRequestPresentStart = new Observable<Engine>();
 
         private _hardwareScalingLevel: number;
-        private _caps: EngineCapabilities;
+        protected _caps: EngineCapabilities;
         private _pointerLockRequested: boolean;
         private _alphaTest: boolean;
         private _isStencilEnable: boolean;
@@ -675,24 +675,24 @@
         // States
         private _depthCullingState = new Internals._DepthCullingState();
         private _stencilState = new Internals._StencilState();
-        private _alphaState = new Internals._AlphaState();
-        private _alphaMode = Engine.ALPHA_DISABLE;
+        protected _alphaState = new Internals._AlphaState();
+        protected _alphaMode = Engine.ALPHA_DISABLE;
 
         // Cache
         private _internalTexturesCache = new Array<InternalTexture>();
         private _maxTextureChannels = 16;
         private _activeTexture: number;
         private _activeTexturesCache: { [key: string]: WebGLTexture } = {};
-        private _currentEffect: Effect;
+        protected _currentEffect: Effect;
         private _currentProgram: WebGLProgram;
         private _compiledEffects = {};
         private _vertexAttribArraysEnabled: boolean[] = [];
-        private _cachedViewport: Viewport;
+        protected _cachedViewport: Viewport;
         private _cachedVertexArrayObject: WebGLVertexArrayObject;
         private _cachedVertexBuffers: any;
         private _cachedIndexBuffer: WebGLBuffer;
         private _cachedEffectForVertexBuffers: Effect;
-        private _currentRenderTarget: InternalTexture;
+        protected _currentRenderTarget: InternalTexture;
         private _uintIndicesCurrentlySet = false;
         private _currentBoundBuffer = new Array<WebGLBuffer>();
         private _currentFramebuffer: WebGLFramebuffer;
@@ -761,6 +761,11 @@
         constructor(canvasOrContext: HTMLCanvasElement | WebGLRenderingContext, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio = false) {
             var canvas: HTMLCanvasElement;
             Engine.Instances.push(this);
+
+            if (!canvasOrContext) {
+                return;
+            }
+
             options = options || {};
 
             if ((<HTMLCanvasElement>canvasOrContext).getContext) {
@@ -1413,7 +1418,7 @@
 
             if (this._activeRenderLoops.length > 0) {
                 // Register new frame
-                var requester = window;
+                var requester = null;
                 if (this._vrDisplay && this._vrDisplay.isPresenting)
                     requester = this._vrDisplay;
                 this._frameHandler = Tools.QueueNewFrame(this._bindedRenderFunction, requester);

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

@@ -0,0 +1,257 @@
+module BABYLON {
+
+    export class NullEngineOptions {
+        public renderWidth = 512;
+        public renderHeight = 256;
+
+        public textureSize = 512;
+    }
+   
+    /**
+     * The null engine class provides support for headless version of babylon.js.
+     * This can be used in server side scenario or for testing purposes
+     */
+    export class NullEngine extends Engine {  
+        private _options: NullEngineOptions;
+
+        public constructor(options: NullEngineOptions = new NullEngineOptions()) {
+            super(null);
+
+            this._options = options;
+
+            // Init caps
+            // We consider we are on a webgl1 capable device
+
+            this._caps = new EngineCapabilities();
+            this._caps.maxTexturesImageUnits = 16;
+            this._caps.maxVertexTextureImageUnits = 16;
+            this._caps.maxTextureSize = 512;
+            this._caps.maxCubemapTextureSize = 512;
+            this._caps.maxRenderTextureSize = 512;
+            this._caps.maxVertexAttribs = 16;
+            this._caps.maxVaryingVectors = 16;
+            this._caps.maxFragmentUniformVectors = 16;
+            this._caps.maxVertexUniformVectors = 16;
+
+            // Extensions
+            this._caps.standardDerivatives = false;
+
+            this._caps.astc = null;
+            this._caps.s3tc = null;
+            this._caps.pvrtc = null;
+            this._caps.etc1 = null;
+            this._caps.etc2 = null;
+
+            this._caps.textureAnisotropicFilterExtension = null;
+            this._caps.maxAnisotropy = 0;
+            this._caps.uintIndices = false;
+            this._caps.fragmentDepthSupported = false;
+            this._caps.highPrecisionShaderSupported = true;
+
+            this._caps.colorBufferFloat = false;
+            this._caps.textureFloat = false;
+            this._caps.textureFloatLinearFiltering = false;
+            this._caps.textureFloatRender = false;
+
+            this._caps.textureHalfFloat = false;
+            this._caps.textureHalfFloatLinearFiltering = false;
+            this._caps.textureHalfFloatRender = false;
+
+            this._caps.textureLOD = false;
+            this._caps.drawBuffersExtension = false;
+
+            this._caps.depthTextureExtension = false;
+            this._caps.vertexArrayObject = false;
+            this._caps.instancedArrays = false;
+
+            Tools.Log("Babylon.js null engine (v" + Engine.Version + ") launched");
+        }
+
+        public createVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer {
+            return {
+                capacity: 0,
+                references: 1,
+                is32Bits: false
+            };
+        }
+
+        public createIndexBuffer(indices: IndicesArray): WebGLBuffer {
+            return {
+                capacity: 0,
+                references: 1,
+                is32Bits: false
+            };
+        }
+
+        public clear(color: Color4, backBuffer: boolean, depth: boolean, stencil: boolean = false): void {
+        }
+
+        public getRenderWidth(useScreen = false): number {
+            if (!useScreen && this._currentRenderTarget) {
+                return this._currentRenderTarget.width;
+            }
+
+            return this._options.renderWidth;
+        }
+
+        public getRenderHeight(useScreen = false): number {
+            if (!useScreen && this._currentRenderTarget) {
+                return this._currentRenderTarget.height;
+            }
+
+            return this._options.renderHeight;
+        }
+
+        public setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void {
+            var width = requiredWidth || this.getRenderWidth();
+            var height = requiredHeight || this.getRenderHeight();
+            var x = viewport.x || 0;
+            var y = viewport.y || 0;
+
+            this._cachedViewport = viewport;
+        }
+
+        public createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram {
+            return {};
+        }
+
+        public getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[] {
+            return [];
+        }
+
+        public getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[] {
+            return [];
+        }
+
+        public bindSamplers(effect: Effect): void {
+            this._currentEffect = null;
+        }
+
+        public enableEffect(effect: Effect): void {
+            this._currentEffect = effect;
+
+            if (effect.onBind) {
+                effect.onBind(effect);
+            }
+            effect.onBindObservable.notifyObservers(effect);
+        }   
+        
+        public setState(culling: boolean, zOffset: number = 0, force?: boolean, reverseSide = false): void {
+        }        
+        
+        public setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void {
+        }
+
+        public setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void {
+        }
+
+        public setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void {
+        }
+
+        public setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void {
+        }
+
+        public setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void {
+        }
+
+        public setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void {
+        }
+
+        public setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void {
+        }
+
+        public setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void {
+        }
+
+        public setArray(uniform: WebGLUniformLocation, array: number[]): void {
+        }
+
+        public setArray2(uniform: WebGLUniformLocation, array: number[]): void {
+        }
+
+        public setArray3(uniform: WebGLUniformLocation, array: number[]): void {
+        }
+
+        public setArray4(uniform: WebGLUniformLocation, array: number[]): void {
+        }
+
+        public setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void {
+        }
+
+        public setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void {
+        }
+
+        public setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void {
+        }
+
+        public setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void {
+        }
+
+        public setFloat(uniform: WebGLUniformLocation, value: number): void {
+        }
+
+        public setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void {
+        }
+
+        public setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void {
+        }
+
+        public setBool(uniform: WebGLUniformLocation, bool: number): void {
+        }
+
+        public setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void {
+        }
+
+        public setColor3(uniform: WebGLUniformLocation, color3: Color3): void {
+        }
+
+        public setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void {
+        }
+
+        public setAlphaMode(mode: number, noDepthWriteChange: boolean = false): void {
+            if (this._alphaMode === mode) {
+                return;
+            }
+
+            this._alphaState.alphaBlend = (mode !== Engine.ALPHA_DISABLE);
+
+            if (!noDepthWriteChange) {
+                this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
+            }
+            this._alphaMode = mode;
+        }        
+
+        public bindBuffers(vertexBuffers: { [key: string]: VertexBuffer; }, indexBuffer: WebGLBuffer, effect: Effect): void {
+        }
+
+        public draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void {
+        }
+
+        public _createTexture(): WebGLTexture {
+            return {};
+        }
+
+        public createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, onLoad: () => void = null, onError: () => void = null, buffer: ArrayBuffer | HTMLImageElement = null, fallBack?: InternalTexture, format?: number): InternalTexture {
+            var texture = new InternalTexture(this, InternalTexture.DATASOURCE_URL);
+            var url = String(urlArg); 
+
+            texture.url = url;
+            texture.generateMipMaps = !noMipmap;
+            texture.samplingMode = samplingMode;
+            texture.invertY = invertY;
+            texture.baseWidth = this._options.textureSize;
+            texture.baseHeight = this._options.textureSize;
+            texture.width = this._options.textureSize;
+            texture.height = this._options.textureSize;            
+            texture.format = format;
+
+            texture.isReady = true;            
+
+            if (onLoad) {
+                onLoad();
+            }
+
+            return texture;
+        }
+    }
+}

src/babylon.webgl2.ts → src/Engine/babylon.webgl2.ts


+ 14 - 10
src/Materials/babylon.effect.ts

@@ -268,11 +268,13 @@
         }
 
         public _loadVertexShader(vertex: any, callback: (data: any) => void): void {
-            // DOM element ?
-            if (vertex instanceof HTMLElement) {
-                var vertexCode = Tools.GetDOMTextContent(vertex);
-                callback(vertexCode);
-                return;
+            if (Tools.IsWindowObjectExist()) {
+                // DOM element ?
+                if (vertex instanceof HTMLElement) {
+                    var vertexCode = Tools.GetDOMTextContent(vertex);
+                    callback(vertexCode);
+                    return;
+                }
             }
 
             // Base64 encoded ?
@@ -301,11 +303,13 @@
         }
 
         public _loadFragmentShader(fragment: any, callback: (data: any) => void): void {
-            // DOM element ?
-            if (fragment instanceof HTMLElement) {
-                var fragmentCode = Tools.GetDOMTextContent(fragment);
-                callback(fragmentCode);
-                return;
+            if (Tools.IsWindowObjectExist()) {
+                // DOM element ?
+                if (fragment instanceof HTMLElement) {
+                    var fragmentCode = Tools.GetDOMTextContent(fragment);
+                    callback(fragmentCode);
+                    return;
+                }
             }
 
             // Base64 encoded ?

+ 24 - 5
src/Tools/babylon.tools.ts

@@ -314,7 +314,7 @@
             var eventPrefix = "pointer";
 
             // Check if pointer events are supported
-            if (!window.PointerEvent && !navigator.pointerEnabled) {
+            if (Tools.IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
                 eventPrefix = "mouse";
             }
 
@@ -325,7 +325,15 @@
          * @param func - the function to be called
          * @param requester - the object that will request the next frame. Falls back to window.
          */
-        public static QueueNewFrame(func, requester: any = window): number {
+        public static QueueNewFrame(func, requester?): number {
+            if (!Tools.IsWindowObjectExist()) {
+                return setTimeout(func, 16);
+            }
+
+            if (!requester) {
+                requester = window;
+            }
+
             if (requester.requestAnimationFrame) {
                 return requester.requestAnimationFrame(func);
             }
@@ -491,7 +499,7 @@
                     if (request.readyState === (XMLHttpRequest.DONE || 4)) {
                         request.onreadystatechange = null;//some browsers have issues where onreadystatechange can be called multiple times with the same value
 
-                        if (request.status >= 200 && request.status < 300 || (navigator.isCocoonJS && (request.status === 0))) {
+                        if (request.status >= 200 && request.status < 300 || (!Tools.IsWindowObjectExist() && (request.status === 0))) {
                             callback(!useArrayBuffer ? request.responseText : request.response);
                         } else { // Failed
                             let e = new Error("Error status: " + request.status + " - Unable to load " + loadUrl);
@@ -1065,12 +1073,16 @@
             }
         }
 
+        public static IsWindowObjectExist(): boolean {
+            return (typeof window) !== "undefined";
+        }
+
         // Performances
         private static _PerformanceNoneLogLevel = 0;
         private static _PerformanceUserMarkLogLevel = 1;
         private static _PerformanceConsoleLogLevel = 2;
 
-        private static _performance: Performance = window.performance;
+        private static _performance: Performance;
 
         static get PerformanceNoneLogLevel(): number {
             return Tools._PerformanceNoneLogLevel;
@@ -1108,6 +1120,13 @@
         }
 
         static _StartUserMark(counterName: string, condition = true): void {
+            if (!Tools._performance) {
+                if (!Tools.IsWindowObjectExist()) {
+                    return;
+                }
+                Tools._performance = window.performance;
+            }
+
             if (!condition || !Tools._performance.mark) {
                 return;
             }
@@ -1150,7 +1169,7 @@
         public static EndPerformanceCounter: (counterName: string, condition?: boolean) => void = Tools._EndPerformanceCounterDisabled;
 
         public static get Now(): number {
-            if (window.performance && window.performance.now) {
+            if (Tools.IsWindowObjectExist() && window.performance && window.performance.now) {
                 return window.performance.now();
             }
 

+ 3 - 1
src/babylon.scene.ts

@@ -821,7 +821,9 @@
                 this._outlineRenderer = new OutlineRenderer(this);
             }
 
-            this.attachControl();
+            if (Tools.IsWindowObjectExist()) {
+                this.attachControl();
+            }
 
             //simplification queue
             if (SimplificationQueue) {

+ 113 - 0
tests/nullEngine/app.js

@@ -0,0 +1,113 @@
+var BABYLON = require("../../dist/preview release/babylon.max");
+var LOADERS = require("../../dist/preview release/loaders/babylonjs.loaders");
+global.XMLHttpRequest = require('xmlhttprequest').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();
+    })
+});
+    
+

+ 5 - 0
tests/nullEngine/package.json

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