Browse Source

Mixin instead of cocoonJS.3.0.0.d.ts

David Catuhe 10 years ago
parent
commit
d14a1f8dcc

+ 7 - 0
Babylon/Materials/textures/babylon.renderTargetTexture.js

@@ -62,6 +62,13 @@ var BABYLON;
             return false;
         };
 
+        RenderTargetTexture.prototype.isReady = function () {
+            if (!this.getScene().renderTargetsEnabled) {
+                return false;
+            }
+            return _super.prototype.isReady.call(this);
+        };
+
         RenderTargetTexture.prototype.getRenderSize = function () {
             return this._size;
         };

+ 7 - 0
Babylon/Materials/textures/babylon.renderTargetTexture.ts

@@ -61,6 +61,13 @@
             return false;
         }
 
+        public isReady(): boolean {
+            if (!this.getScene().renderTargetsEnabled) {
+                return false;
+            }
+            return super.isReady();
+        }
+
         public getRenderSize(): number {
             return this._size;
         }

+ 2 - 2
Babylon/Shaders/default.fragment.fx

@@ -252,7 +252,7 @@ float computeShadowWithPCF(vec4 vPositionFromLight, sampler2D shadowSampler)
 	if (unpack(texture2D(shadowSampler, uv + poissonDisk[1] / 1500.0))  <  depth.z) visibility -= 0.2;
 	if (unpack(texture2D(shadowSampler, uv + poissonDisk[2] / 1500.0))  <  depth.z) visibility -= 0.2;
 	if (unpack(texture2D(shadowSampler, uv + poissonDisk[3] / 1500.0))  <  depth.z) visibility -= 0.2;
-	
+
 	return visibility;
 }
 
@@ -708,4 +708,4 @@ void main(void) {
 #endif
 
 	gl_FragColor = color;
-}
+}

+ 27 - 6
Babylon/Tools/babylon.sceneOptimizer.js

@@ -21,13 +21,13 @@ var BABYLON;
 
     var TextureSceneOptimization = (function (_super) {
         __extends(TextureSceneOptimization, _super);
-        function TextureSceneOptimization(maximumSize, priority) {
-            if (typeof maximumSize === "undefined") { maximumSize = 1024; }
+        function TextureSceneOptimization(priority, maximumSize) {
             if (typeof priority === "undefined") { priority = 0; }
+            if (typeof maximumSize === "undefined") { maximumSize = 1024; }
             var _this = this;
             _super.call(this, priority);
-            this.maximumSize = maximumSize;
             this.priority = priority;
+            this.maximumSize = maximumSize;
             this.apply = function (scene) {
                 var allDone = true;
                 for (var index = 0; index < scene.textures.length; index++) {
@@ -55,13 +55,13 @@ var BABYLON;
 
     var HardwareScalingSceneOptimization = (function (_super) {
         __extends(HardwareScalingSceneOptimization, _super);
-        function HardwareScalingSceneOptimization(maximumScale, priority) {
-            if (typeof maximumScale === "undefined") { maximumScale = 2; }
+        function HardwareScalingSceneOptimization(priority, maximumScale) {
             if (typeof priority === "undefined") { priority = 0; }
+            if (typeof maximumScale === "undefined") { maximumScale = 2; }
             var _this = this;
             _super.call(this, priority);
-            this.maximumScale = maximumScale;
             this.priority = priority;
+            this.maximumScale = maximumScale;
             this._currentScale = 1;
             this.apply = function (scene) {
                 _this._currentScale++;
@@ -127,6 +127,19 @@ var BABYLON;
     })(SceneOptimization);
     BABYLON.ParticlesSceneOptimization = ParticlesSceneOptimization;
 
+    var RenderTargetsSceneOptimization = (function (_super) {
+        __extends(RenderTargetsSceneOptimization, _super);
+        function RenderTargetsSceneOptimization() {
+            _super.apply(this, arguments);
+            this.apply = function (scene) {
+                scene.renderTargetsEnabled = false;
+                return true;
+            };
+        }
+        return RenderTargetsSceneOptimization;
+    })(SceneOptimization);
+    BABYLON.RenderTargetsSceneOptimization = RenderTargetsSceneOptimization;
+
     // Options
     var SceneOptimizerOptions = (function () {
         function SceneOptimizerOptions(targetFrameRate, trackerDuration) {
@@ -173,6 +186,10 @@ var BABYLON;
 
             // Next priority
             priority++;
+            result.optimizations.push(new RenderTargetsSceneOptimization(priority));
+
+            // Next priority
+            priority++;
             result.optimizations.push(new HardwareScalingSceneOptimization(priority, 2));
 
             return result;
@@ -196,6 +213,10 @@ var BABYLON;
 
             // Next priority
             priority++;
+            result.optimizations.push(new RenderTargetsSceneOptimization(priority));
+
+            // Next priority
+            priority++;
             result.optimizations.push(new HardwareScalingSceneOptimization(priority, 4));
 
             return result;

+ 17 - 2
Babylon/Tools/babylon.sceneOptimizer.ts

@@ -10,7 +10,7 @@
     }
 
     export class TextureSceneOptimization extends SceneOptimization {
-        constructor(public maximumSize: number = 1024, public priority: number = 0) {
+        constructor(public priority: number = 0, public maximumSize: number = 1024) {
             super(priority);
         }
 
@@ -40,7 +40,7 @@
     export class HardwareScalingSceneOptimization extends SceneOptimization {
         private _currentScale = 1;
 
-        constructor(public maximumScale: number = 2, public priority: number = 0) {
+        constructor(public priority: number = 0, public maximumScale: number = 2) {
             super(priority);
         }
 
@@ -81,6 +81,13 @@
         };
     }
 
+    export class RenderTargetsSceneOptimization extends SceneOptimization {
+        public apply = (scene: Scene): boolean => {
+            scene.renderTargetsEnabled = false;
+            return true;
+        };
+    }
+
     // Options
     export class SceneOptimizerOptions {
         public optimizations = new Array<SceneOptimization>();
@@ -125,6 +132,10 @@
 
             // Next priority
             priority++;
+            result.optimizations.push(new RenderTargetsSceneOptimization(priority));
+
+            // Next priority
+            priority++;
             result.optimizations.push(new HardwareScalingSceneOptimization(priority, 2));
 
             return result;
@@ -148,6 +159,10 @@
 
             // Next priority
             priority++;
+            result.optimizations.push(new RenderTargetsSceneOptimization(priority));
+
+            // Next priority
+            priority++;
             result.optimizations.push(new HardwareScalingSceneOptimization(priority, 4));
 
             return result;

+ 11 - 3
Babylon/babylon.engine.js

@@ -528,7 +528,7 @@
 
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "1.14.0";
+                return "2.0.0";
             },
             enumerable: true,
             configurable: true
@@ -693,8 +693,12 @@
         };
 
         Engine.prototype.resize = function () {
-            this._renderingCanvas.width = this._renderingCanvas.clientWidth / this._hardwareScalingLevel;
-            this._renderingCanvas.height = this._renderingCanvas.clientHeight / this._hardwareScalingLevel;
+            this.setSize(this._renderingCanvas.clientWidth / this._hardwareScalingLevel, this._renderingCanvas.clientHeight / this._hardwareScalingLevel);
+        };
+
+        Engine.prototype.setSize = function (width, height) {
+            this._renderingCanvas.width = width;
+            this._renderingCanvas.height = height;
 
             this._canvasClientRect = this._renderingCanvas.getBoundingClientRect();
         };
@@ -1828,6 +1832,10 @@
         // Statics
         Engine.isSupported = function () {
             try  {
+                // Avoid creating an unsized context for CocoonJS, since size determined on first creation.  Is not resizable
+                if (navigator.isCocoonJS) {
+                    return true;
+                }
                 var tempcanvas = document.createElement("canvas");
                 var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
 

+ 3 - 3
Babylon/babylon.engine.ts

@@ -706,7 +706,7 @@
             this.setSize(this._renderingCanvas.clientWidth / this._hardwareScalingLevel, this._renderingCanvas.clientHeight / this._hardwareScalingLevel);
         }
 
-        public setSize(width : number, height : number): void {
+        public setSize(width: number, height: number): void {
             this._renderingCanvas.width = width;
             this._renderingCanvas.height = height;
 
@@ -1258,7 +1258,7 @@
                     callback(buffer);
 
             } else if (isDDS) {
-                callback = (data) => {
+                 callback = (data) => {
                     var info = BABYLON.Internals.DDSTools.GetDDSInfo(data);
 
                     var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) == 1);
@@ -1839,7 +1839,7 @@
         public static isSupported(): boolean {
             try {
                 // Avoid creating an unsized context for CocoonJS, since size determined on first creation.  Is not resizable
-                if (navigator.isCocoonJS){
+                if (navigator.isCocoonJS) {
                     return true;
                 }
                 var tempcanvas = document.createElement("canvas");

+ 1 - 0
Babylon/babylon.mixins.ts

@@ -88,4 +88,5 @@ interface MSStyleCSSProperties {
 interface Navigator {
     getVRDevices: () => any;
     mozGetVRDevices: (any) => any;
+    isCocoonJS: boolean;
 }

+ 0 - 213
Babylon/cocoonJS.3.0.0.d.ts

@@ -1,213 +0,0 @@
-interface Navigator  {
-    /** http://stackoverflow.com/questions/13641692/how-to-use-getusermedia-from-typesecript */
-    isCocoonJS : boolean;
-}
-
-declare module Cocoon {
-    class Ad{
-        public hideBanner() : void;  
-        public loadBanner() : void;
-        public loadInterstitial() : void;
-        public setBannerLayout(bannerLayout : string) : void; // problem example wrong
-        public showBanner() : void;
-        public showInterstitial() : void;
-        public on(event : string, callback: () => void) : void;
-        public static TOP_CENTER : string;
-        public static BOTTOM_CENTER : string;
-    }
-    class App{
-        public exit() : void;  
-        public exitCallback(callback: () => boolean) : void;
-        public forward(code : string) : void;
-        public forwardAsync(javaScriptCode : string, callback: () => void) : void; 
-        public hideTheWebView() :void;
-        public load(path : string, storageType : Cocoon.App.StorageType) : void;
-        public loadInTheWebView(path : string, cb : Array<() => void>, storageType : Cocoon.App.StorageType) : void;
-        public openURL(url : string) : void;
-        public pause() : void;  
-        public reload() : void;
-        public reloadWebView() : void;
-        public resume() : void;
-        public showTheWebView(x : number, y : number, width : number, height : number) : void;
-        public on(event : string, callback: () => void) : void;
-    }
-    class Camera{
-        public getAllCamerasInfo() : Array<Cocoon.Camera.CameraInfo>;
-        public getCameraInfoByIndex(cameraIndex : number) : Cocoon.Camera.CameraInfo;
-        public getNumberOfCameras() : number;
-        public isCapturing(cameraIndex : number) : boolean;
-        public start(params : any) : any; // not sure what params is, example does not help
-        public stop(cameraIndex : number) : void;
-    }
-    class Device{
-        public autoLock(enabled : boolean)
-        public getDeviceId() : string;
-        public getDeviceInfo() : Cocoon.Device.DeviceInfo;
-        public getOrientation() : number;
-        public setOrientation(preferredOrientation : number) : void;
-
-    }
-    class Dialog{
-        public confirm(params, callback : (boolean) => void) : void;
-        public prompt(param, callbacks)
-    }
-    class Motion{
-        public getAccelerometerInterval() : number;
-        public getGyroscopeInterval() : number;
-        public setAccelerometerInterval(seconds : number) : void;
-        public setGyroscopeInterval(seconds : number) : void;
-    }
-    class Multiplayer{
-//        public 
-    }
-    class Notification{
-//        public 
-    }
-    class Proxify{
-        public static audio() : void;
-        public static console() : void;
-        public static deproxifyConsole() : void;
-        public static xhr() : void;
-    }
-    class Social{
-//        public 
-    }
-    class Store{
-//        public 
-    }
-    class Touch{
-        public static disable() : void;
-        public static disableInWebView() : void;
-        public static enable() : void;
-        public static enableInWebView() : void;
-    }
-    class Utils{
-        public captureScreen(fileName : string, storageType? : Cocoon.App.StorageType, captureType? : Cocoon.Utils.CaptureType) : string;
-        public captureScreenAsync(fileName : string, storageType? : Cocoon.App.StorageType, captureType? : Cocoon.Utils.CaptureType, callback? : () => void) : void;
-        public existsPath(path : string, storageType? : Cocoon.App.StorageType) : boolean;
-        public logMemoryInfo() : void;
-        public markAsMusic(filePath : string) : void;
-        public setAntialias(antialias : boolean) : void;
-        public setTextCacheSize(size : number) : void;
-        public setTextureReduction(sizeThreshold : number, applyTo? : any, forbidFor? : any) : void;
-    }
-    class WebView{
-        public hide() : void;
-        public show(x? : number, y? : number, width? : number, height? : number) : void;    
-    }
-}
-
-declare module Cocoon.App{
-    class StorageType{
-        public static PORTRAIT : string; // ????
-        public static INTERNAL_STORAGE : string;
-        public static EXTERNAL_STORAGE : string;
-        public static TEMPORARY_STORAGE : string;
-    }
-}
-
-declare module Cocoon.Camera{
-    class CameraInfo{
-        public cameraIndex : number;
-//        public supportedVideoSizes : Array<Cocoon.Size>;  // !!!!!!!!!!!!!!!!!!!!!!!!!!! could not find Cocoon.Size
-        public supportedVideoFrameRates: Array<number>;
-        public supportedImageFormats : Array<Cocoon.Camera.CaptureFormatType>;
-    }
-    
-    class CameraType{
-        public static FRONT : string;
-        public static BACK : string;
-    }
-    
-    class CaptureFormatType{
-        public static JPEG : string;
-        public static RGB_565 : string;
-        public static NV21 : string;
-        public static NV16 : string;  
-        public static YUY2 : string;
-        public static YV12 : string;
-        public static BGRA32 : string;
-    }
-}
-
-declare module Cocoon.Device{
-    class DeviceInfo{
-        /** The operating system name (ios, android,...). */
-        public os : string;  
-        /** The operating system version (4.2.2, 5.0,...). */
-        public version : string;  
-        /** The operating system screen density in dpi. */
-        public dpi : string;  
-        /** The device manufacturer (apple, samsung, lg,...). */
-        brand : string;  
-        /** The device model (iPhone 4S, SAMSUNG-SGH-I997, SAMSUNG-SGH-I997R, etc). */
-        public model : string;  
-        /** The phone IMEI. Android: The phone IMEI is returned or null if the device has not telepohny. iOS: null is returned as we cannot get the IMEI in iOS, no public API available for that yet. */
-        public imei : string;  
-        /** The platform Id. */
-        public platformId : string;  
-        /** The Odin generated id: https://code.google.com/p/odinmobile/ */
-        public odin : string;  
-        /** The OpenUDID generated Id: https://github.com/ylechelle/OpenUDID */
-        public openudid : string;       
-    }
-    
-    class Orientations{
-        public static PORTRAIT : string 
-        public static PORTRAIT_UPSIDE_DOWN : string;
-        public static LANDSCAPE_LEFT : string;
-        public static LANDSCAPE_RIGHT : string;
-        public static LANDSCAPE : string;
-        public static BOTH : string;
-    }
-}
-
-declare module Cocoon.Dialog{
-    class keyboardType{
-        public static TEXT : string;
-        public static NUMBER : string;
-        public static PHONE : string;
-        public static EMAIL : string;
-        public static URL : string;
-    }
-}
-
-declare module Cocoon.Multiplayer{
-    class Match{
-        constructor(nativeExtensionName : string, extensionName : string, matchID: number);
-        public disconnect() : void;
-        public getExpectedPlayerCount() : number;
-        public getLocalPlayerID() : Cocoon.Multiplayer.PlayerInfo;
-        public getPlayerIDs() : Array<Cocoon.Multiplayer.PlayerInfo>;
-        public requestPlayersInfo(callback) : void;
-        public sendData(data, playerIDs, sendMode) : boolean;
-        public sendDataToAllPlayers(data, sendMode) : boolean
-    }
-    class ConnectionState{
-        
-    }
-    class PlayerInfo{
-        public userID : string;
-        public userName : string;
-    }
-    class SendDataMode{
-        public static RELIABLE : string;
-        public static UNRELIABLE : string;
-    }
-}
-
-declare module Cocoon.Utils{
-    class CaptureType{
-        public static EVERYTHING : string;
-        public static COCOONJS_GL_SURFACE : string;
-        public static JUST_SYSTEM_VIEWS : string;
-    }
-}
-
-declare module Coocoon.Widget{
-    class WebDialog{
-        public close() : void;  
-        public eval() : void;  
-        public show(url : string, closeCallback: () => void) : void;  
-    }    
-}

+ 1 - 0
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJS/babylonJS.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <files xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="babylonJS.xsd">
+  <script src="Babylon/Tools/babylon.sceneOptimizer.js"></script>
   <script src="Babylon/Cameras/babylon.vrDeviceOrientationCamera.js"></script>
   <script src="Babylon/Cameras/babylon.webVRCamera.js"></script>
   <script src="Babylon/Tools/babylon.assetsManager.js"></script>

+ 2 - 1
Tools/Gulp/gulpfile.js

@@ -155,7 +155,8 @@ gulp.task('scripts', ['shaders'] ,function() {
       '../../Babylon/Rendering/babylon.outlineRenderer.js',
       '../../Babylon/Tools/babylon.assetsManager.js',
       '../../Babylon/Cameras/babylon.vrDeviceOrientationCamera.js',
-      '../../Babylon/Cameras/babylon.webVRCamera.js'
+      '../../Babylon/Cameras/babylon.webVRCamera.js',
+      '../../Babylon/Tools/babylon.sceneOptimizer.js',
     ])
     .pipe(concat('babylon.js'))
     .pipe(gulp.dest('build/'))

File diff suppressed because it is too large
+ 46 - 10
babylon.2.0-alpha.debug.js


File diff suppressed because it is too large
+ 9 - 9
babylon.2.0-alpha.js


+ 10 - 4
babylon.2.0.d.ts

@@ -123,6 +123,7 @@ declare module BABYLON {
         public beginFrame(): void;
         public endFrame(): void;
         public resize(): void;
+        public setSize(width: number, height: number): void;
         public bindFramebuffer(texture: WebGLTexture): void;
         public unBindFramebuffer(texture: WebGLTexture): void;
         public flushFramebuffer(): void;
@@ -271,6 +272,7 @@ interface MSStyleCSSProperties {
 interface Navigator {
     getVRDevices: () => any;
     mozGetVRDevices: (any: any) => any;
+    isCocoonJS: boolean;
 }
 declare module BABYLON {
     class Node {
@@ -1826,6 +1828,7 @@ declare module BABYLON {
         public resetRefreshCounter(): void;
         public refreshRate : number;
         public _shouldRender(): boolean;
+        public isReady(): boolean;
         public getRenderSize(): number;
         public canRescale : boolean;
         public scale(ratio: number): void;
@@ -3603,16 +3606,16 @@ declare module BABYLON {
         constructor(priority?: number);
     }
     class TextureSceneOptimization extends SceneOptimization {
-        public maximumSize: number;
         public priority: number;
-        constructor(maximumSize?: number, priority?: number);
+        public maximumSize: number;
+        constructor(priority?: number, maximumSize?: number);
         public apply: (scene: Scene) => boolean;
     }
     class HardwareScalingSceneOptimization extends SceneOptimization {
-        public maximumScale: number;
         public priority: number;
+        public maximumScale: number;
         private _currentScale;
-        constructor(maximumScale?: number, priority?: number);
+        constructor(priority?: number, maximumScale?: number);
         public apply: (scene: Scene) => boolean;
     }
     class ShadowsSceneOptimization extends SceneOptimization {
@@ -3627,6 +3630,9 @@ declare module BABYLON {
     class ParticlesSceneOptimization extends SceneOptimization {
         public apply: (scene: Scene) => boolean;
     }
+    class RenderTargetsSceneOptimization extends SceneOptimization {
+        public apply: (scene: Scene) => boolean;
+    }
     class SceneOptimizerOptions {
         public targetFrameRate: number;
         public trackerDuration: number;