David Catuhe 10 роки тому
батько
коміт
7f2d15039b

+ 1 - 3
Babylon/Cameras/babylon.camera.js

@@ -120,9 +120,6 @@ var BABYLON;
             this._update();
         };
         // Synchronized
-        Camera.prototype.isSynchronizedWithParent = function () {
-            return false;
-        };
         Camera.prototype._isSynchronized = function () {
             return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
         };
@@ -243,6 +240,7 @@ var BABYLON;
             this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12], this._computedViewMatrix.m[13], this._computedViewMatrix.m[14]);
             this._computedViewMatrix.invert();
             this._currentRenderId = this.getScene().getRenderId();
+            this._markSyncedWithParent();
             return this._computedViewMatrix;
         };
         Camera.prototype._computeViewMatrix = function (force) {

+ 2 - 4
Babylon/Cameras/babylon.camera.ts

@@ -125,10 +125,6 @@
         }
 
         // Synchronized
-        public isSynchronizedWithParent(): boolean {
-            return false;
-        }
-
         public _isSynchronized(): boolean {
             return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
         }
@@ -310,6 +306,8 @@
 
             this._currentRenderId = this.getScene().getRenderId();
 
+            this._markSyncedWithParent();
+
             return this._computedViewMatrix;
         }
 

+ 1 - 0
Babylon/Lights/babylon.light.js

@@ -59,6 +59,7 @@ var BABYLON;
                     this._parentedWorldMatrix = BABYLON.Matrix.Identity();
                 }
                 worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
+                this._markSyncedWithParent();
                 return this._parentedWorldMatrix;
             }
             return worldMatrix;

+ 2 - 0
Babylon/Lights/babylon.light.ts

@@ -90,6 +90,8 @@
 
                 worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
 
+                this._markSyncedWithParent();
+
                 return this._parentedWorldMatrix;
             }
 

+ 1 - 1
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -732,7 +732,7 @@ var BABYLON;
                         var name = parsedAction.properties[i].name;
                         var targetType = parsedAction.properties[i].targetType;
                         if (name === "target")
-                            if (targetType != null && targetType === "SceneProperties")
+                            if (targetType !== null && targetType === "SceneProperties")
                                 value = target = scene;
                             else
                                 value = target = scene.getNodeByName(value);

+ 1 - 1
Babylon/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -918,7 +918,7 @@
                     var targetType = parsedAction.properties[i].targetType;
 
                     if (name === "target")
-                        if (targetType != null && targetType === "SceneProperties")
+                        if (targetType !== null && targetType === "SceneProperties")
                             value = target = scene;
                         else
                             value = target = scene.getNodeByName(value);

+ 1 - 1
Babylon/Materials/babylon.standardMaterial.js

@@ -49,7 +49,7 @@ var BABYLON;
             return (this.alpha < 1.0) || (this.opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled;
         };
         StandardMaterial.prototype.needAlphaTesting = function () {
-            return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && !this.diffuseTexture.getAlphaFromRGB;
+            return this.diffuseTexture != null && this.diffuseTexture.hasAlpha;
         };
         StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
             return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && this.useAlphaFromDiffuseTexture;

+ 1 - 1
Babylon/Materials/babylon.standardMaterial.ts

@@ -59,7 +59,7 @@
         }
 
         public needAlphaTesting(): boolean {
-            return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && !this.diffuseTexture.getAlphaFromRGB;
+            return this.diffuseTexture != null && this.diffuseTexture.hasAlpha;
         }
 
         private _shouldUseAlphaFromDiffuseTexture(): boolean {

+ 1 - 0
Babylon/Mesh/babylon.abstractMesh.js

@@ -410,6 +410,7 @@ var BABYLON;
             this._localPivotScalingRotation.multiplyToRef(this._localTranslation, this._localWorld);
             // Parent
             if (this.parent && this.parent.getWorldMatrix && this.billboardMode === AbstractMesh.BILLBOARDMODE_NONE) {
+                this._markSyncedWithParent();
                 this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
             }
             else {

+ 1 - 0
Babylon/Mesh/babylon.abstractMesh.ts

@@ -465,6 +465,7 @@
 
             // Parent
             if (this.parent && this.parent.getWorldMatrix && this.billboardMode === AbstractMesh.BILLBOARDMODE_NONE) {
+                this._markSyncedWithParent();
                 this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
             } else {
                 this._worldMatrix.copyFrom(this._localWorld);

+ 1 - 2
Babylon/babylon.engine.js

@@ -1897,5 +1897,4 @@ var BABYLON;
     })();
     BABYLON.Engine = Engine;
 })(BABYLON || (BABYLON = {}));
-
-//# sourceMappingURL=babylon.engine.js.map
+//# sourceMappingURL=babylon.engine.js.map

+ 13 - 13
Babylon/babylon.engine.ts

@@ -251,7 +251,7 @@
     var compileShader = (gl: WebGLRenderingContext, source: string, type: string, defines: string): WebGLShader => {
         var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
 
-        gl.shaderSource(shader, (defines ? defines + "\n" : "") + source);
+        gl.shaderSource(shader,(defines ? defines + "\n" : "") + source);
         gl.compileShader(shader);
 
         if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
@@ -315,7 +315,7 @@
         texture._width = potWidth;
         texture._height = potHeight;
         texture.isReady = true;
-        
+
         processFunction(potWidth, potHeight);
 
         var filters = getSamplingParameters(samplingMode, !noMipmap, gl);
@@ -652,10 +652,10 @@
             // Pointer lock
             this._onPointerLockChange = () => {
                 this.isPointerLock = (document.mozPointerLockElement === canvas ||
-                document.webkitPointerLockElement === canvas ||
-                document.msPointerLockElement === canvas ||
-                document.pointerLockElement === canvas
-                );
+                    document.webkitPointerLockElement === canvas ||
+                    document.msPointerLockElement === canvas ||
+                    document.pointerLockElement === canvas
+                    );
             };
 
             document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
@@ -866,7 +866,7 @@
          * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
          */
         public setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void {
-            var width = requiredWidth   || (navigator.isCocoonJS ? window.innerWidth  : this._renderingCanvas.width);
+            var width = requiredWidth || (navigator.isCocoonJS ? window.innerWidth : this._renderingCanvas.width);
             var height = requiredHeight || (navigator.isCocoonJS ? window.innerHeight : this._renderingCanvas.height);
             var x = viewport.x || 0;
             var y = viewport.y || 0;
@@ -898,9 +898,9 @@
          *   });
          */
         public resize(): void {
-            var width  = navigator.isCocoonJS ? window.innerWidth  : this._renderingCanvas.clientWidth;
+            var width = navigator.isCocoonJS ? window.innerWidth : this._renderingCanvas.clientWidth;
             var height = navigator.isCocoonJS ? window.innerHeight : this._renderingCanvas.clientHeight;
-            
+
             this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
         }
 
@@ -1186,7 +1186,7 @@
             return effect;
         }
 
-        public createEffectForParticles(fragmentName: string, uniformsNames: string[]= [], samplers: string[]= [], defines = "", fallbacks?: EffectFallbacks,
+        public createEffectForParticles(fragmentName: string, uniformsNames: string[] = [], samplers: string[] = [], defines = "", fallbacks?: EffectFallbacks,
             onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect {
 
             return this.createEffect(
@@ -1521,7 +1521,7 @@
 
                     var header = Internals.TGATools.GetTGAHeader(data);
 
-                    prepareWebGLTexture(texture, this._gl, scene, header.width, header.height, invertY, noMipmap, false, () => {
+                    prepareWebGLTexture(texture, this._gl, scene, header.width, header.height, invertY, noMipmap, false,() => {
                         Internals.TGATools.UploadContent(this._gl, data);
 
                         if (onLoad) {
@@ -1542,7 +1542,7 @@
                     var info = Internals.DDSTools.GetDDSInfo(data);
 
                     var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) === 1);
-                    prepareWebGLTexture(texture, this._gl, scene, info.width, info.height, invertY, !loadMipmap, info.isFourCC, () => {
+                    prepareWebGLTexture(texture, this._gl, scene, info.width, info.height, invertY, !loadMipmap, info.isFourCC,() => {
 
                         Internals.DDSTools.UploadDDSLevels(this._gl, this.getCaps().s3tc, data, info, loadMipmap, 1);
 
@@ -1561,7 +1561,7 @@
 
             } else {
                 var onload = (img) => {
-                    prepareWebGLTexture(texture, this._gl, scene, img.width, img.height, invertY, noMipmap, false, (potWidth, potHeight) => {
+                    prepareWebGLTexture(texture, this._gl, scene, img.width, img.height, invertY, noMipmap, false,(potWidth, potHeight) => {
                         var isPot = (img.width === potWidth && img.height === potHeight);
                         if (!isPot) {
                             this._prepareWorkingCanvas();

+ 3 - 1
Babylon/babylon.node.js

@@ -52,12 +52,14 @@ var BABYLON;
         Node.prototype._isSynchronized = function () {
             return true;
         };
+        Node.prototype._markSyncedWithParent = function () {
+            this._parentRenderId = this.parent._currentRenderId;
+        };
         Node.prototype.isSynchronizedWithParent = function () {
             if (!this.parent) {
                 return true;
             }
             if (this._parentRenderId !== this.parent._currentRenderId) {
-                this._parentRenderId = this.parent._currentRenderId;
                 return false;
             }
             return this.parent.isSynchronized();

+ 4 - 1
Babylon/babylon.node.ts

@@ -76,13 +76,16 @@
             return true;
         }
 
+        public _markSyncedWithParent() {
+            this._parentRenderId = this.parent._currentRenderId;
+        }
+        
         public isSynchronizedWithParent(): boolean {
             if (!this.parent) {
                 return true;
             }
 
             if (this._parentRenderId !== this.parent._currentRenderId) {
-                this._parentRenderId = this.parent._currentRenderId;
                 return false;
             }
 

+ 17 - 10
babylon.2.1-beta.debug.js

@@ -4235,7 +4235,7 @@ var __extends = this.__extends || function (d, b) {
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "2.1.0 alpha";
+                return "2.1.0 beta";
             },
             enumerable: true,
             configurable: true
@@ -4406,8 +4406,8 @@ var __extends = this.__extends || function (d, b) {
          * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
          */
         Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
-            var width = requiredWidth || this._renderingCanvas.width;
-            var height = requiredHeight || this._renderingCanvas.height;
+            var width = requiredWidth || (navigator.isCocoonJS ? window.innerWidth : this._renderingCanvas.width);
+            var height = requiredHeight || (navigator.isCocoonJS ? window.innerHeight : this._renderingCanvas.height);
             var x = viewport.x || 0;
             var y = viewport.y || 0;
             this._cachedViewport = viewport;
@@ -4431,7 +4431,9 @@ var __extends = this.__extends || function (d, b) {
          *   });
          */
         Engine.prototype.resize = function () {
-            this.setSize(this._renderingCanvas.clientWidth / this._hardwareScalingLevel, this._renderingCanvas.clientHeight / this._hardwareScalingLevel);
+            var width = navigator.isCocoonJS ? window.innerWidth : this._renderingCanvas.clientWidth;
+            var height = navigator.isCocoonJS ? window.innerHeight : this._renderingCanvas.clientHeight;
+            this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
         };
         /**
          * force a specific size of the canvas
@@ -5608,12 +5610,14 @@ var __extends = this.__extends || function (d, b) {
         Node.prototype._isSynchronized = function () {
             return true;
         };
+        Node.prototype._markSyncedWithParent = function () {
+            this._parentRenderId = this.parent._currentRenderId;
+        };
         Node.prototype.isSynchronizedWithParent = function () {
             if (!this.parent) {
                 return true;
             }
             if (this._parentRenderId !== this.parent._currentRenderId) {
-                this._parentRenderId = this.parent._currentRenderId;
                 return false;
             }
             return this.parent.isSynchronized();
@@ -6062,6 +6066,7 @@ var BABYLON;
                     this._parentedWorldMatrix = BABYLON.Matrix.Identity();
                 }
                 worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
+                this._markSyncedWithParent();
                 return this._parentedWorldMatrix;
             }
             return worldMatrix;
@@ -7021,9 +7026,9 @@ var BABYLON;
             this._update();
         };
         // Synchronized
-        Camera.prototype.isSynchronizedWithParent = function () {
-            return false;
-        };
+        //public isSynchronizedWithParent(): boolean {
+        //    return false;
+        //}
         Camera.prototype._isSynchronized = function () {
             return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
         };
@@ -7144,6 +7149,7 @@ var BABYLON;
             this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12], this._computedViewMatrix.m[13], this._computedViewMatrix.m[14]);
             this._computedViewMatrix.invert();
             this._currentRenderId = this.getScene().getRenderId();
+            this._markSyncedWithParent();
             return this._computedViewMatrix;
         };
         Camera.prototype._computeViewMatrix = function (force) {
@@ -10477,6 +10483,7 @@ var BABYLON;
             this._localPivotScalingRotation.multiplyToRef(this._localTranslation, this._localWorld);
             // Parent
             if (this.parent && this.parent.getWorldMatrix && this.billboardMode === AbstractMesh.BILLBOARDMODE_NONE) {
+                this._markSyncedWithParent();
                 this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
             }
             else {
@@ -14899,7 +14906,7 @@ var BABYLON;
             return (this.alpha < 1.0) || (this.opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled;
         };
         StandardMaterial.prototype.needAlphaTesting = function () {
-            return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && !this.diffuseTexture.getAlphaFromRGB;
+            return this.diffuseTexture != null && this.diffuseTexture.hasAlpha;
         };
         StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
             return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && this.useAlphaFromDiffuseTexture;
@@ -20422,7 +20429,7 @@ var BABYLON;
                         var name = parsedAction.properties[i].name;
                         var targetType = parsedAction.properties[i].targetType;
                         if (name === "target")
-                            if (targetType != null && targetType === "SceneProperties")
+                            if (targetType !== null && targetType === "SceneProperties")
                                 value = target = scene;
                             else
                                 value = target = scene.getNodeByName(value);

Різницю між файлами не показано, бо вона завелика
+ 11 - 12
babylon.2.1-beta.js