Przeglądaj źródła

Engine optimizations + world matrix improvments

David Catuhe 7 lat temu
rodzic
commit
efba84ea2e

Plik diff jest za duży
+ 7001 - 7001
dist/preview release/babylon.d.ts


Plik diff jest za duży
+ 43 - 43
dist/preview release/babylon.js


+ 81 - 65
dist/preview release/babylon.max.js

@@ -5628,12 +5628,12 @@ var BABYLON;
 
 //# sourceMappingURL=babylon.observable.js.map
 
+
 var BABYLON;
 (function (BABYLON) {
     var SmartArray = /** @class */ (function () {
         function SmartArray(capacity) {
             this.length = 0;
-            this._duplicateId = 0;
             this.data = new Array(capacity);
             this._id = SmartArray._GlobalId++;
         }
@@ -5642,29 +5642,17 @@ var BABYLON;
             if (this.length > this.data.length) {
                 this.data.length *= 2;
             }
-            if (!value.__smartArrayFlags) {
-                value.__smartArrayFlags = {};
-            }
-            value.__smartArrayFlags[this._id] = this._duplicateId;
         };
         SmartArray.prototype.forEach = function (func) {
             for (var index = 0; index < this.length; index++) {
                 func(this.data[index]);
             }
         };
-        SmartArray.prototype.pushNoDuplicate = function (value) {
-            if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
-                return false;
-            }
-            this.push(value);
-            return true;
-        };
         SmartArray.prototype.sort = function (compareFn) {
             this.data.sort(compareFn);
         };
         SmartArray.prototype.reset = function () {
             this.length = 0;
-            this._duplicateId++;
         };
         SmartArray.prototype.dispose = function () {
             this.reset();
@@ -5684,18 +5672,6 @@ var BABYLON;
                 this.data[this.length++] = (array.data || array)[index];
             }
         };
-        SmartArray.prototype.concatWithNoDuplicate = function (array) {
-            if (array.length === 0) {
-                return;
-            }
-            if (this.length + array.length > this.data.length) {
-                this.data.length = (this.length + array.length) * 2;
-            }
-            for (var index = 0; index < array.length; index++) {
-                var item = (array.data || array)[index];
-                this.pushNoDuplicate(item);
-            }
-        };
         SmartArray.prototype.indexOf = function (value) {
             var position = this.data.indexOf(value);
             if (position >= this.length) {
@@ -5711,6 +5687,46 @@ var BABYLON;
         return SmartArray;
     }());
     BABYLON.SmartArray = SmartArray;
+    var SmartArrayNoDuplicate = /** @class */ (function (_super) {
+        __extends(SmartArrayNoDuplicate, _super);
+        function SmartArrayNoDuplicate() {
+            var _this = _super !== null && _super.apply(this, arguments) || this;
+            _this._duplicateId = 0;
+            return _this;
+        }
+        SmartArrayNoDuplicate.prototype.push = function (value) {
+            _super.prototype.push.call(this, value);
+            if (!value.__smartArrayFlags) {
+                value.__smartArrayFlags = {};
+            }
+            value.__smartArrayFlags[this._id] = this._duplicateId;
+        };
+        SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
+            if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
+                return false;
+            }
+            this.push(value);
+            return true;
+        };
+        SmartArrayNoDuplicate.prototype.reset = function () {
+            _super.prototype.reset.call(this);
+            this._duplicateId++;
+        };
+        SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
+            if (array.length === 0) {
+                return;
+            }
+            if (this.length + array.length > this.data.length) {
+                this.data.length = (this.length + array.length) * 2;
+            }
+            for (var index = 0; index < array.length; index++) {
+                var item = (array.data || array)[index];
+                this.pushNoDuplicate(item);
+            }
+        };
+        return SmartArrayNoDuplicate;
+    }(SmartArray));
+    BABYLON.SmartArrayNoDuplicate = SmartArrayNoDuplicate;
 })(BABYLON || (BABYLON = {}));
 
 //# sourceMappingURL=babylon.smartArray.js.map
@@ -8471,7 +8487,7 @@ var BABYLON;
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "3.1-beta";
+                return "3.1-beta-1";
             },
             enumerable: true,
             configurable: true
@@ -11395,23 +11411,23 @@ var BABYLON;
             }
             this._currentEffect = null;
         };
-        Engine.prototype.activateTexture = function (texture) {
-            if (this._activeTexture !== texture) {
-                this._gl.activeTexture(texture);
-                this._activeTexture = texture;
+        Engine.prototype.activateTextureChannel = function (textureChannel) {
+            if (this._activeTextureChannel !== textureChannel) {
+                this._gl.activeTexture(textureChannel);
+                this._activeTextureChannel = textureChannel;
             }
         };
         Engine.prototype._bindTextureDirectly = function (target, texture) {
-            if (this._activeTexturesCache[this._activeTexture] !== texture) {
+            if (this._activeTexturesCache[this._activeTextureChannel] !== texture) {
                 this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
-                this._activeTexturesCache[this._activeTexture] = texture;
+                this._activeTexturesCache[this._activeTextureChannel] = texture;
             }
         };
         Engine.prototype._bindTexture = function (channel, texture) {
             if (channel < 0) {
                 return;
             }
-            this.activateTexture(this._gl.TEXTURE0 + channel);
+            this.activateTextureChannel(this._gl.TEXTURE0 + channel);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
         };
         Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
@@ -11419,7 +11435,7 @@ var BABYLON;
         };
         Engine.prototype.unbindAllTextures = function () {
             for (var channel = 0; channel < this._caps.maxTexturesImageUnits; channel++) {
-                this.activateTexture(this._gl["TEXTURE" + channel]);
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                 this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
                 this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
                 if (this.webGLVersion > 1) {
@@ -11431,32 +11447,33 @@ var BABYLON;
             if (channel < 0) {
                 return;
             }
-            this._gl.uniform1i(uniform, channel);
-            this._setTexture(channel, texture);
+            if (this._setTexture(channel, texture)) {
+                this._gl.uniform1i(uniform, channel);
+            }
         };
         Engine.prototype._setTexture = function (channel, texture) {
             // Not ready?
             if (!texture) {
                 if (this._activeTexturesCache[channel] != null) {
-                    this.activateTexture(this._gl["TEXTURE" + channel]);
+                    this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                     this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
                     this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
                     if (this.webGLVersion > 1) {
                         this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
                     }
                 }
-                return;
+                return false;
             }
             // Video
             var alreadyActivated = false;
             if (texture.video) {
-                this.activateTexture(this._gl["TEXTURE" + channel]);
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                 alreadyActivated = true;
                 texture.update();
             }
             else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) {
                 texture.delayLoad();
-                return;
+                return false;
             }
             var internalTexture;
             if (texture.isReady()) {
@@ -11471,11 +11488,11 @@ var BABYLON;
             else {
                 internalTexture = this.emptyTexture;
             }
-            if (this._activeTexturesCache[channel] === internalTexture) {
-                return;
-            }
             if (!alreadyActivated) {
-                this.activateTexture(this._gl["TEXTURE" + channel]);
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
+            }
+            if (this._activeTexturesCache[this._activeTextureChannel] === internalTexture) {
+                return false;
             }
             if (internalTexture && internalTexture.is3D) {
                 this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture);
@@ -11566,6 +11583,7 @@ var BABYLON;
                 }
                 this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
             }
+            return true;
         };
         Engine.prototype.setTextureArray = function (channel, uniform, textures) {
             if (channel < 0 || !uniform) {
@@ -13710,15 +13728,12 @@ var BABYLON;
          * Returns the last update of the World matrix
          * Returns a Matrix.
          */
-        AbstractMesh.prototype.getWorldMatrix = function (useCachedVersion) {
-            if (useCachedVersion === void 0) { useCachedVersion = false; }
+        AbstractMesh.prototype.getWorldMatrix = function () {
             if (this._masterMesh) {
                 return this._masterMesh.getWorldMatrix();
             }
-            if (!useCachedVersion) {
-                if (this._currentRenderId !== this.getScene().getRenderId() || !this.isSynchronized()) {
-                    this.computeWorldMatrix();
-                }
+            if (this._currentRenderId !== this.getScene().getRenderId()) {
+                this.computeWorldMatrix();
             }
             return this._worldMatrix;
         };
@@ -17659,7 +17674,7 @@ var BABYLON;
             this.probesEnabled = true;
             this.reflectionProbes = new Array();
             this._actionManagers = new Array();
-            this._meshesForIntersections = new BABYLON.SmartArray(256);
+            this._meshesForIntersections = new BABYLON.SmartArrayNoDuplicate(256);
             // Procedural textures
             this.proceduralTexturesEnabled = true;
             this._proceduralTextures = new Array();
@@ -17685,10 +17700,10 @@ var BABYLON;
             this._isDisposed = false;
             this._activeMeshes = new BABYLON.SmartArray(256);
             this._processedMaterials = new BABYLON.SmartArray(256);
-            this._renderTargets = new BABYLON.SmartArray(256);
+            this._renderTargets = new BABYLON.SmartArrayNoDuplicate(256);
             this._activeParticleSystems = new BABYLON.SmartArray(256);
-            this._activeSkeletons = new BABYLON.SmartArray(32);
-            this._softwareSkinnedMeshes = new BABYLON.SmartArray(32);
+            this._activeSkeletons = new BABYLON.SmartArrayNoDuplicate(32);
+            this._softwareSkinnedMeshes = new BABYLON.SmartArrayNoDuplicate(32);
             this._activeAnimatables = new Array();
             this._transformMatrix = BABYLON.Matrix.Zero();
             this._useAlternateCameraConfiguration = false;
@@ -23468,7 +23483,7 @@ var BABYLON;
             }
             var offset = 0;
             var instancesCount = 0;
-            var world = this.getWorldMatrix(true);
+            var world = this.getWorldMatrix();
             if (batch.renderSelf[subMesh._id]) {
                 world.copyToArray(this._instancesData, offset);
                 offset += 16;
@@ -23477,7 +23492,7 @@ var BABYLON;
             if (visibleInstances) {
                 for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
                     var instance = visibleInstances[instanceIndex];
-                    instance.getWorldMatrix(true).copyToArray(this._instancesData, offset);
+                    instance.getWorldMatrix().copyToArray(this._instancesData, offset);
                     offset += 16;
                     instancesCount++;
                 }
@@ -23511,7 +23526,7 @@ var BABYLON;
                 if (batch.renderSelf[subMesh._id]) {
                     // Draw
                     if (onBeforeDraw) {
-                        onBeforeDraw(false, this.getWorldMatrix(true), effectiveMaterial);
+                        onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
                     }
                     this._draw(subMesh, fillMode, this._overridenInstanceCount);
                 }
@@ -23520,7 +23535,7 @@ var BABYLON;
                     for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
                         var instance = visibleInstancesForSubMesh[instanceIndex];
                         // World
-                        var world = instance.getWorldMatrix(true);
+                        var world = instance.getWorldMatrix();
                         if (onBeforeDraw) {
                             onBeforeDraw(true, world, effectiveMaterial);
                         }
@@ -23598,7 +23613,7 @@ var BABYLON;
             if (!hardwareInstancedRendering) {
                 this._bind(subMesh, effect, fillMode);
             }
-            var world = this.getWorldMatrix(true);
+            var world = this.getWorldMatrix();
             if (this._effectiveMaterial.storeEffectOnSubMeshes) {
                 this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
             }
@@ -26330,11 +26345,12 @@ var BABYLON;
             return changed;
         };
         Effect.prototype.bindUniformBuffer = function (buffer, name) {
-            if (Effect._baseCache[this._uniformBuffersNames[name]] === buffer) {
+            var bufferName = this._uniformBuffersNames[name];
+            if (Effect._baseCache[bufferName] === buffer) {
                 return;
             }
-            Effect._baseCache[this._uniformBuffersNames[name]] = buffer;
-            this._engine.bindUniformBufferBase(buffer, this._uniformBuffersNames[name]);
+            Effect._baseCache[bufferName] = buffer;
+            this._engine.bindUniformBufferBase(buffer, bufferName);
         };
         Effect.prototype.bindUniformBlock = function (blockName, index) {
             this._engine.bindUniformBlock(this._program, blockName, index);
@@ -69283,7 +69299,7 @@ var BABYLON;
             this.maxDepth = maxDepth;
             this.dynamicContent = new Array();
             this._maxBlockCapacity = maxBlockCapacity || 64;
-            this._selectionContent = new BABYLON.SmartArray(1024);
+            this._selectionContent = new BABYLON.SmartArrayNoDuplicate(1024);
             this._creationFunc = creationFunc;
         }
         // Methods
@@ -75410,8 +75426,8 @@ var BABYLON;
         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;
+            if (this._activeTexturesCache[this._activeTextureChannel] !== texture) {
+                this._activeTexturesCache[this._activeTextureChannel] = texture;
             }
         };
         NullEngine.prototype._bindTexture = function (channel, texture) {

Plik diff jest za duży
+ 7001 - 7001
dist/preview release/babylon.module.d.ts


Plik diff jest za duży
+ 43 - 43
dist/preview release/babylon.worker.js


Plik diff jest za duży
+ 2876 - 2871
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Plik diff jest za duży
+ 31 - 31
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


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

@@ -5628,12 +5628,12 @@ var BABYLON;
 
 //# sourceMappingURL=babylon.observable.js.map
 
+
 var BABYLON;
 (function (BABYLON) {
     var SmartArray = /** @class */ (function () {
         function SmartArray(capacity) {
             this.length = 0;
-            this._duplicateId = 0;
             this.data = new Array(capacity);
             this._id = SmartArray._GlobalId++;
         }
@@ -5642,29 +5642,17 @@ var BABYLON;
             if (this.length > this.data.length) {
                 this.data.length *= 2;
             }
-            if (!value.__smartArrayFlags) {
-                value.__smartArrayFlags = {};
-            }
-            value.__smartArrayFlags[this._id] = this._duplicateId;
         };
         SmartArray.prototype.forEach = function (func) {
             for (var index = 0; index < this.length; index++) {
                 func(this.data[index]);
             }
         };
-        SmartArray.prototype.pushNoDuplicate = function (value) {
-            if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
-                return false;
-            }
-            this.push(value);
-            return true;
-        };
         SmartArray.prototype.sort = function (compareFn) {
             this.data.sort(compareFn);
         };
         SmartArray.prototype.reset = function () {
             this.length = 0;
-            this._duplicateId++;
         };
         SmartArray.prototype.dispose = function () {
             this.reset();
@@ -5684,18 +5672,6 @@ var BABYLON;
                 this.data[this.length++] = (array.data || array)[index];
             }
         };
-        SmartArray.prototype.concatWithNoDuplicate = function (array) {
-            if (array.length === 0) {
-                return;
-            }
-            if (this.length + array.length > this.data.length) {
-                this.data.length = (this.length + array.length) * 2;
-            }
-            for (var index = 0; index < array.length; index++) {
-                var item = (array.data || array)[index];
-                this.pushNoDuplicate(item);
-            }
-        };
         SmartArray.prototype.indexOf = function (value) {
             var position = this.data.indexOf(value);
             if (position >= this.length) {
@@ -5711,6 +5687,46 @@ var BABYLON;
         return SmartArray;
     }());
     BABYLON.SmartArray = SmartArray;
+    var SmartArrayNoDuplicate = /** @class */ (function (_super) {
+        __extends(SmartArrayNoDuplicate, _super);
+        function SmartArrayNoDuplicate() {
+            var _this = _super !== null && _super.apply(this, arguments) || this;
+            _this._duplicateId = 0;
+            return _this;
+        }
+        SmartArrayNoDuplicate.prototype.push = function (value) {
+            _super.prototype.push.call(this, value);
+            if (!value.__smartArrayFlags) {
+                value.__smartArrayFlags = {};
+            }
+            value.__smartArrayFlags[this._id] = this._duplicateId;
+        };
+        SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
+            if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
+                return false;
+            }
+            this.push(value);
+            return true;
+        };
+        SmartArrayNoDuplicate.prototype.reset = function () {
+            _super.prototype.reset.call(this);
+            this._duplicateId++;
+        };
+        SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
+            if (array.length === 0) {
+                return;
+            }
+            if (this.length + array.length > this.data.length) {
+                this.data.length = (this.length + array.length) * 2;
+            }
+            for (var index = 0; index < array.length; index++) {
+                var item = (array.data || array)[index];
+                this.pushNoDuplicate(item);
+            }
+        };
+        return SmartArrayNoDuplicate;
+    }(SmartArray));
+    BABYLON.SmartArrayNoDuplicate = SmartArrayNoDuplicate;
 })(BABYLON || (BABYLON = {}));
 
 //# sourceMappingURL=babylon.smartArray.js.map
@@ -8471,7 +8487,7 @@ var BABYLON;
         });
         Object.defineProperty(Engine, "Version", {
             get: function () {
-                return "3.1-beta";
+                return "3.1-beta-1";
             },
             enumerable: true,
             configurable: true
@@ -11395,23 +11411,23 @@ var BABYLON;
             }
             this._currentEffect = null;
         };
-        Engine.prototype.activateTexture = function (texture) {
-            if (this._activeTexture !== texture) {
-                this._gl.activeTexture(texture);
-                this._activeTexture = texture;
+        Engine.prototype.activateTextureChannel = function (textureChannel) {
+            if (this._activeTextureChannel !== textureChannel) {
+                this._gl.activeTexture(textureChannel);
+                this._activeTextureChannel = textureChannel;
             }
         };
         Engine.prototype._bindTextureDirectly = function (target, texture) {
-            if (this._activeTexturesCache[this._activeTexture] !== texture) {
+            if (this._activeTexturesCache[this._activeTextureChannel] !== texture) {
                 this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
-                this._activeTexturesCache[this._activeTexture] = texture;
+                this._activeTexturesCache[this._activeTextureChannel] = texture;
             }
         };
         Engine.prototype._bindTexture = function (channel, texture) {
             if (channel < 0) {
                 return;
             }
-            this.activateTexture(this._gl.TEXTURE0 + channel);
+            this.activateTextureChannel(this._gl.TEXTURE0 + channel);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
         };
         Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
@@ -11419,7 +11435,7 @@ var BABYLON;
         };
         Engine.prototype.unbindAllTextures = function () {
             for (var channel = 0; channel < this._caps.maxTexturesImageUnits; channel++) {
-                this.activateTexture(this._gl["TEXTURE" + channel]);
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                 this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
                 this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
                 if (this.webGLVersion > 1) {
@@ -11431,32 +11447,33 @@ var BABYLON;
             if (channel < 0) {
                 return;
             }
-            this._gl.uniform1i(uniform, channel);
-            this._setTexture(channel, texture);
+            if (this._setTexture(channel, texture)) {
+                this._gl.uniform1i(uniform, channel);
+            }
         };
         Engine.prototype._setTexture = function (channel, texture) {
             // Not ready?
             if (!texture) {
                 if (this._activeTexturesCache[channel] != null) {
-                    this.activateTexture(this._gl["TEXTURE" + channel]);
+                    this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                     this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
                     this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
                     if (this.webGLVersion > 1) {
                         this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
                     }
                 }
-                return;
+                return false;
             }
             // Video
             var alreadyActivated = false;
             if (texture.video) {
-                this.activateTexture(this._gl["TEXTURE" + channel]);
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                 alreadyActivated = true;
                 texture.update();
             }
             else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) {
                 texture.delayLoad();
-                return;
+                return false;
             }
             var internalTexture;
             if (texture.isReady()) {
@@ -11471,11 +11488,11 @@ var BABYLON;
             else {
                 internalTexture = this.emptyTexture;
             }
-            if (this._activeTexturesCache[channel] === internalTexture) {
-                return;
-            }
             if (!alreadyActivated) {
-                this.activateTexture(this._gl["TEXTURE" + channel]);
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
+            }
+            if (this._activeTexturesCache[this._activeTextureChannel] === internalTexture) {
+                return false;
             }
             if (internalTexture && internalTexture.is3D) {
                 this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture);
@@ -11566,6 +11583,7 @@ var BABYLON;
                 }
                 this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
             }
+            return true;
         };
         Engine.prototype.setTextureArray = function (channel, uniform, textures) {
             if (channel < 0 || !uniform) {
@@ -13710,15 +13728,12 @@ var BABYLON;
          * Returns the last update of the World matrix
          * Returns a Matrix.
          */
-        AbstractMesh.prototype.getWorldMatrix = function (useCachedVersion) {
-            if (useCachedVersion === void 0) { useCachedVersion = false; }
+        AbstractMesh.prototype.getWorldMatrix = function () {
             if (this._masterMesh) {
                 return this._masterMesh.getWorldMatrix();
             }
-            if (!useCachedVersion) {
-                if (this._currentRenderId !== this.getScene().getRenderId() || !this.isSynchronized()) {
-                    this.computeWorldMatrix();
-                }
+            if (this._currentRenderId !== this.getScene().getRenderId()) {
+                this.computeWorldMatrix();
             }
             return this._worldMatrix;
         };
@@ -17659,7 +17674,7 @@ var BABYLON;
             this.probesEnabled = true;
             this.reflectionProbes = new Array();
             this._actionManagers = new Array();
-            this._meshesForIntersections = new BABYLON.SmartArray(256);
+            this._meshesForIntersections = new BABYLON.SmartArrayNoDuplicate(256);
             // Procedural textures
             this.proceduralTexturesEnabled = true;
             this._proceduralTextures = new Array();
@@ -17685,10 +17700,10 @@ var BABYLON;
             this._isDisposed = false;
             this._activeMeshes = new BABYLON.SmartArray(256);
             this._processedMaterials = new BABYLON.SmartArray(256);
-            this._renderTargets = new BABYLON.SmartArray(256);
+            this._renderTargets = new BABYLON.SmartArrayNoDuplicate(256);
             this._activeParticleSystems = new BABYLON.SmartArray(256);
-            this._activeSkeletons = new BABYLON.SmartArray(32);
-            this._softwareSkinnedMeshes = new BABYLON.SmartArray(32);
+            this._activeSkeletons = new BABYLON.SmartArrayNoDuplicate(32);
+            this._softwareSkinnedMeshes = new BABYLON.SmartArrayNoDuplicate(32);
             this._activeAnimatables = new Array();
             this._transformMatrix = BABYLON.Matrix.Zero();
             this._useAlternateCameraConfiguration = false;
@@ -23468,7 +23483,7 @@ var BABYLON;
             }
             var offset = 0;
             var instancesCount = 0;
-            var world = this.getWorldMatrix(true);
+            var world = this.getWorldMatrix();
             if (batch.renderSelf[subMesh._id]) {
                 world.copyToArray(this._instancesData, offset);
                 offset += 16;
@@ -23477,7 +23492,7 @@ var BABYLON;
             if (visibleInstances) {
                 for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
                     var instance = visibleInstances[instanceIndex];
-                    instance.getWorldMatrix(true).copyToArray(this._instancesData, offset);
+                    instance.getWorldMatrix().copyToArray(this._instancesData, offset);
                     offset += 16;
                     instancesCount++;
                 }
@@ -23511,7 +23526,7 @@ var BABYLON;
                 if (batch.renderSelf[subMesh._id]) {
                     // Draw
                     if (onBeforeDraw) {
-                        onBeforeDraw(false, this.getWorldMatrix(true), effectiveMaterial);
+                        onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
                     }
                     this._draw(subMesh, fillMode, this._overridenInstanceCount);
                 }
@@ -23520,7 +23535,7 @@ var BABYLON;
                     for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
                         var instance = visibleInstancesForSubMesh[instanceIndex];
                         // World
-                        var world = instance.getWorldMatrix(true);
+                        var world = instance.getWorldMatrix();
                         if (onBeforeDraw) {
                             onBeforeDraw(true, world, effectiveMaterial);
                         }
@@ -23598,7 +23613,7 @@ var BABYLON;
             if (!hardwareInstancedRendering) {
                 this._bind(subMesh, effect, fillMode);
             }
-            var world = this.getWorldMatrix(true);
+            var world = this.getWorldMatrix();
             if (this._effectiveMaterial.storeEffectOnSubMeshes) {
                 this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
             }
@@ -26330,11 +26345,12 @@ var BABYLON;
             return changed;
         };
         Effect.prototype.bindUniformBuffer = function (buffer, name) {
-            if (Effect._baseCache[this._uniformBuffersNames[name]] === buffer) {
+            var bufferName = this._uniformBuffersNames[name];
+            if (Effect._baseCache[bufferName] === buffer) {
                 return;
             }
-            Effect._baseCache[this._uniformBuffersNames[name]] = buffer;
-            this._engine.bindUniformBufferBase(buffer, this._uniformBuffersNames[name]);
+            Effect._baseCache[bufferName] = buffer;
+            this._engine.bindUniformBufferBase(buffer, bufferName);
         };
         Effect.prototype.bindUniformBlock = function (blockName, index) {
             this._engine.bindUniformBlock(this._program, blockName, index);
@@ -69129,7 +69145,7 @@ var BABYLON;
             this.maxDepth = maxDepth;
             this.dynamicContent = new Array();
             this._maxBlockCapacity = maxBlockCapacity || 64;
-            this._selectionContent = new BABYLON.SmartArray(1024);
+            this._selectionContent = new BABYLON.SmartArrayNoDuplicate(1024);
             this._creationFunc = creationFunc;
         }
         // Methods

Plik diff jest za duży
+ 2876 - 2871
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


Plik diff jest za duży
+ 14 - 14
dist/preview release/inspector/babylon.inspector.bundle.js


Plik diff jest za duży
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


Plik diff jest za duży
+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.min.js


+ 23 - 20
src/Engine/babylon.engine.ts

@@ -716,7 +716,7 @@
 
         // Cache
         private _internalTexturesCache = new Array<InternalTexture>();
-        protected _activeTexture: number;
+        protected _activeTextureChannel: number;
         protected _activeTexturesCache: { [key: string]: Nullable<WebGLTexture> } = {};
         protected _currentEffect: Nullable<Effect>;
         protected _currentProgram: Nullable<WebGLProgram>;
@@ -4448,17 +4448,17 @@
             this._currentEffect = null;
         }
 
-        private activateTexture(texture: number): void {
-            if (this._activeTexture !== texture) {
-                this._gl.activeTexture(texture);
-                this._activeTexture = texture;
+        private activateTextureChannel(textureChannel: number): void {
+            if (this._activeTextureChannel !== textureChannel) {
+                this._gl.activeTexture(textureChannel);
+                this._activeTextureChannel = textureChannel;
             }
         }
 
         public _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>): void {
-            if (this._activeTexturesCache[this._activeTexture] !== texture) {
+            if (this._activeTexturesCache[this._activeTextureChannel] !== texture) {
                 this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
-                this._activeTexturesCache[this._activeTexture] = texture;
+                this._activeTexturesCache[this._activeTextureChannel] = texture;
             }
         }
 
@@ -4467,7 +4467,7 @@
                 return;
             }
 
-            this.activateTexture(this._gl.TEXTURE0 + channel);
+            this.activateTextureChannel(this._gl.TEXTURE0 + channel);
             this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
         }
 
@@ -4477,7 +4477,7 @@
 
         public unbindAllTextures(): void {
             for (var channel = 0; channel < this._caps.maxTexturesImageUnits; channel++) {
-                this.activateTexture((<any>this._gl)["TEXTURE" + channel]);
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                 this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
                 this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
                 if (this.webGLVersion > 1) {
@@ -4491,33 +4491,34 @@
                 return;
             }
 
-            this._gl.uniform1i(uniform, channel);
-            this._setTexture(channel, texture);
+            if (this._setTexture(channel, texture)) {
+                this._gl.uniform1i(uniform, channel);
+            }
         }
 
-        private _setTexture(channel: number, texture: Nullable<BaseTexture>): void {
+        private _setTexture(channel: number, texture: Nullable<BaseTexture>): boolean {
             // Not ready?
             if (!texture) {
                 if (this._activeTexturesCache[channel] != null) {
-                    this.activateTexture((<any>this._gl)["TEXTURE" + channel]);
+                    this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                     this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
                     this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
                     if (this.webGLVersion > 1) {
                         this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
                     }
                 }
-                return;
+                return false;
             }
 
             // Video
             var alreadyActivated = false;
             if ((<VideoTexture>texture).video) {
-                this.activateTexture((<any>this._gl)["TEXTURE" + channel]);
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
                 alreadyActivated = true;
                 (<VideoTexture>texture).update();
             } else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
                 texture.delayLoad();
-                return;
+                return false;
             }
 
             let internalTexture: InternalTexture;
@@ -4534,12 +4535,12 @@
                 internalTexture = this.emptyTexture;
             }
 
-            if (this._activeTexturesCache[channel] === internalTexture) {
-                return;
+            if (!alreadyActivated) {
+                this.activateTextureChannel(this._gl.TEXTURE0 + channel);
             }
 
-            if (!alreadyActivated) {
-                this.activateTexture((<any>this._gl)["TEXTURE" + channel]);
+            if (this._activeTexturesCache[this._activeTextureChannel] === internalTexture) {
+                return false;
             }
 
             if (internalTexture && internalTexture.is3D) {
@@ -4641,6 +4642,8 @@
 
                 this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
             }
+
+            return true;
         }
 
         public setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void {

+ 2 - 2
src/Engine/babylon.nullEngine.ts

@@ -368,8 +368,8 @@
         }        
 
         public _bindTextureDirectly(target: number, texture: InternalTexture): void {
-            if (this._activeTexturesCache[this._activeTexture] !== texture) {
-                this._activeTexturesCache[this._activeTexture] = texture;
+            if (this._activeTexturesCache[this._activeTextureChannel] !== texture) {
+                this._activeTexturesCache[this._activeTextureChannel] = texture;
             }
         }
 

+ 5 - 7
src/Mesh/babylon.abstractMesh.ts

@@ -820,24 +820,22 @@
         }
 
         /**
-         * Returns the last update of the World matrix
+         * Returns the latest update of the World matrix
          * Returns a Matrix.  
          */
-        public getWorldMatrix(useCachedVersion = false): Matrix {
+        public getWorldMatrix(): Matrix {
             if (this._masterMesh) {
                 return this._masterMesh.getWorldMatrix();
             }
 
-            if (!useCachedVersion) {
-                if (this._currentRenderId !== this.getScene().getRenderId() || !this.isSynchronized()) {
-                    this.computeWorldMatrix();
-                }
+            if (this._currentRenderId !== this.getScene().getRenderId()) {
+                this.computeWorldMatrix();
             }
             return this._worldMatrix;
         }
 
         /**
-         * Returns directly the last state of the mesh World matrix. 
+         * Returns directly the latest state of the mesh World matrix. 
          * A Matrix is returned.    
          */
         public get worldMatrixFromCache(): Matrix {

+ 5 - 5
src/Mesh/babylon.mesh.ts

@@ -1140,7 +1140,7 @@
             var offset = 0;
             var instancesCount = 0;
 
-            var world = this.getWorldMatrix(true);
+            var world = this.getWorldMatrix();
             if (batch.renderSelf[subMesh._id]) {
                 world.copyToArray(this._instancesData, offset);
                 offset += 16;
@@ -1150,7 +1150,7 @@
             if (visibleInstances) {
                 for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
                     var instance = visibleInstances[instanceIndex];
-                    instance.getWorldMatrix(true).copyToArray(this._instancesData, offset);
+                    instance.getWorldMatrix().copyToArray(this._instancesData, offset);
                     offset += 16;
                     instancesCount++;
                 }
@@ -1190,7 +1190,7 @@
                 if (batch.renderSelf[subMesh._id]) {
                     // Draw
                     if (onBeforeDraw) {
-                        onBeforeDraw(false, this.getWorldMatrix(true), effectiveMaterial);
+                        onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
                     }
 
                     this._draw(subMesh, fillMode, this._overridenInstanceCount);
@@ -1203,7 +1203,7 @@
                         var instance = visibleInstancesForSubMesh[instanceIndex];
 
                         // World
-                        var world = instance.getWorldMatrix(true);
+                        var world = instance.getWorldMatrix();
                         if (onBeforeDraw) {
                             onBeforeDraw(true, world, effectiveMaterial);
                         }
@@ -1301,7 +1301,7 @@
                 this._bind(subMesh, effect, fillMode);
             }
 
-            var world = this.getWorldMatrix(true);
+            var world = this.getWorldMatrix();
 
             if (this._effectiveMaterial.storeEffectOnSubMeshes) {
                 this._effectiveMaterial.bindForSubMesh(world, this, subMesh);