瀏覽代碼

Fixing issues with sprites and shadows

David Catuhe 10 年之前
父節點
當前提交
ace53742a9

+ 10 - 10
Babylon/Audio/babylon.analyser.js

@@ -5,8 +5,8 @@ var BABYLON;
             this.SMOOTHING = 0.75;
             this.FFT_SIZE = 512;
             this.BARGRAPHAMPLITUDE = 256;
-            this.DEBUGCANVASPOS = { x: 20, y: 20 };
-            this.DEBUGCANVASSIZE = { width: 320, height: 200 };
+            this._debugCanvasWidth = 320;
+            this._debugCanvasHeight = 200;
             this._scene = scene;
             this._audioEngine = scene.getEngine().getAudioEngine();
             if (this._audioEngine.canUseWebAudio) {
@@ -48,11 +48,11 @@ var BABYLON;
             if (this._audioEngine.canUseWebAudio) {
                 if (!this._debugCanvas) {
                     this._debugCanvas = document.createElement("canvas");
-                    this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
-                    this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
+                    this._debugCanvas.width = this._debugCanvasWidth;
+                    this._debugCanvas.height = this._debugCanvasHeight;
                     this._debugCanvas.style.position = "absolute";
-                    this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
-                    this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
+                    this._debugCanvas.style.top = "30px";
+                    this._debugCanvas.style.left = "10px";
                     this._debugCanvasContext = this._debugCanvas.getContext("2d");
                     document.body.appendChild(this._debugCanvas);
                     this._registerFunc = function () {
@@ -64,14 +64,14 @@ var BABYLON;
                     var workingArray = this.getByteFrequencyData();
 
                     this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
-                    this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
+                    this._debugCanvasContext.fillRect(0, 0, this._debugCanvasWidth, this._debugCanvasHeight);
 
                     for (var i = 0; i < this.getFrequencyBinCount(); i++) {
                         var value = workingArray[i];
                         var percent = value / this.BARGRAPHAMPLITUDE;
-                        var height = this.DEBUGCANVASSIZE.height * percent;
-                        var offset = this.DEBUGCANVASSIZE.height - height - 1;
-                        var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
+                        var height = this._debugCanvasHeight * percent;
+                        var offset = this._debugCanvasHeight - height - 1;
+                        var barWidth = this._debugCanvasWidth / this.getFrequencyBinCount();
                         var hue = i / this.getFrequencyBinCount() * 360;
                         this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
                         this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);

+ 21 - 10
Babylon/Audio/babylon.analyser.ts

@@ -30,27 +30,38 @@ module BABYLON {
         }
 
         public getFrequencyBinCount(): number {
-            return this._webAudioAnalyser.frequencyBinCount;
+            if (this._audioEngine.canUseWebAudio) {
+                return this._webAudioAnalyser.frequencyBinCount;
+            }
+            else {
+                return 0;
+            }
         }
 
         public getByteFrequencyData(): Uint8Array {
-            this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
-            this._webAudioAnalyser.fftSize = this.FFT_SIZE;
-            this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
+            if (this._audioEngine.canUseWebAudio) {
+                this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
+                this._webAudioAnalyser.fftSize = this.FFT_SIZE;
+                this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
+            }
             return this._byteFreqs;
         }
 
         public getByteTimeDomainData(): Uint8Array {
-            this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
-            this._webAudioAnalyser.fftSize = this.FFT_SIZE;
-            this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
+            if (this._audioEngine.canUseWebAudio) {
+                this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
+                this._webAudioAnalyser.fftSize = this.FFT_SIZE;
+                this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
+            }
             return this._byteTime;
         }
 
         public getFloatFrequencyData(): Uint8Array {
-            this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
-            this._webAudioAnalyser.fftSize = this.FFT_SIZE;
-            this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
+            if (this._audioEngine.canUseWebAudio) {
+                this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
+                this._webAudioAnalyser.fftSize = this.FFT_SIZE;
+                this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
+            }
             return this._floatFreqs;
         }
 

+ 1 - 17
Babylon/Audio/babylon.audioengine.js

@@ -24,18 +24,6 @@
                 this.masterGain.connect(this.audioContext.destination);
             }
         }
-        AudioEngine.prototype.dispose = function () {
-            if (this.canUseWebAudio) {
-                if (this._connectedAnalyser) {
-                    this._connectedAnalyser.stopDebugCanvas();
-                }
-                this.canUseWebAudio = false;
-                this.masterGain.disconnect();
-                this.masterGain = null;
-                this.audioContext = null;
-            }
-        };
-
         AudioEngine.prototype.getGlobalVolume = function () {
             if (this.canUseWebAudio) {
                 return this.masterGain.gain.value;
@@ -51,13 +39,9 @@
         };
 
         AudioEngine.prototype.connectToAnalyser = function (analyser) {
-            if (this._connectedAnalyser) {
-                this._connectedAnalyser.stopDebugCanvas();
-            }
-            this._connectedAnalyser = analyser;
             if (this.canUseWebAudio) {
                 this.masterGain.disconnect();
-                this._connectedAnalyser.connectAudioNodes(this.masterGain, this.audioContext.destination);
+                analyser.connectAudioNodes(this.masterGain, this.audioContext.destination);
             }
         };
         return AudioEngine;

+ 9 - 38
Babylon/Audio/babylon.sound.js

@@ -19,8 +19,8 @@
             this.maxDistance = 100;
             this.distanceModel = "linear";
             this.panningModel = "HRTF";
-            this._startTime = 0;
-            this._startOffset = 0;
+            this.startTime = 0;
+            this.startOffset = 0;
             this._position = BABYLON.Vector3.Zero();
             this._localDirection = new BABYLON.Vector3(1, 0, 0);
             this._volume = 1;
@@ -33,7 +33,7 @@
             this._coneInnerAngle = 360;
             this._coneOuterAngle = 360;
             this._coneOuterGain = 0;
-            this.name = name;
+            this._name = name;
             this._scene = scene;
             this._audioEngine = this._scene.getEngine().getAudioEngine();
             this._readyToPlayCallback = readyToPlayCallback;
@@ -81,34 +81,6 @@
                 }
             }
         }
-        Sound.prototype.dispose = function () {
-            if (this._audioEngine.canUseWebAudio && this._isReadyToPlay) {
-                if (this._isPlaying) {
-                    this.stop();
-                }
-                this._isReadyToPlay = false;
-                if (this.soundTrackId === -1) {
-                    this._scene.mainSoundTrack.RemoveSound(this);
-                } else {
-                    this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
-                }
-                this._soundGain.disconnect();
-                this._soundSource.disconnect();
-                this._audioBuffer = null;
-                this._soundGain = null;
-                this._soundSource = null;
-                if (this._soundPanner) {
-                    this._soundPanner.disconnect();
-                    this._soundPanner = null;
-                }
-                this._audioNode.disconnect();
-                if (this._connectedMesh) {
-                    this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc);
-                    this._connectedMesh = null;
-                }
-            }
-        };
-
         Sound.prototype._soundLoaded = function (audioData) {
             var _this = this;
             this._isLoaded = true;
@@ -249,11 +221,11 @@
                     }
                     this._soundSource.connect(this._audioNode);
                     this._soundSource.loop = this.loop;
-                    this._startTime = startTime;
-                    this._soundSource.start(startTime, this._startOffset % this._soundSource.buffer.duration);
+                    this.startTime = startTime;
+                    this._soundSource.start(startTime, this.startOffset % this._soundSource.buffer.duration);
                     this._isPlaying = true;
                 } catch (ex) {
-                    BABYLON.Tools.Error("Error while trying to play audio: " + this.name + ", " + ex.message);
+                    BABYLON.Tools.Error("Error while trying to play audio: " + this._name + ", " + ex.message);
                 }
             }
         };
@@ -273,7 +245,7 @@
         Sound.prototype.pause = function () {
             if (this._isPlaying) {
                 this._soundSource.stop(0);
-                this._startOffset += this._audioEngine.audioContext.currentTime - this._startTime;
+                this.startOffset += this._audioEngine.audioContext.currentTime - this.startTime;
             }
         };
 
@@ -299,10 +271,9 @@
                     this.play();
                 }
             }
-            this._registerFunc = function (connectedMesh) {
+            meshToConnectTo.registerAfterWorldMatrixUpdate(function (connectedMesh) {
                 return _this._onRegisterAfterWorldMatrixUpdate(connectedMesh);
-            };
-            meshToConnectTo.registerAfterWorldMatrixUpdate(this._registerFunc);
+            });
         };
 
         Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (connectedMesh) {

+ 14 - 16
Babylon/Audio/babylon.sound.ts

@@ -20,7 +20,7 @@
         private _isReadyToPlay: boolean = false;
         private _isPlaying: boolean = false;
         private _isDirectional: boolean = false;
-        private _audioEngine: BABYLON.AudioEngine;
+        private _audioEngine: AudioEngine;
         private _readyToPlayCallback;
         private _audioBuffer;
         private _soundSource: AudioBufferSourceNode;
@@ -32,8 +32,8 @@
         private _coneInnerAngle: number = 360;
         private _coneOuterAngle: number = 360;
         private _coneOuterGain: number = 0;
-        private _scene: BABYLON.Scene;
-        private _connectedMesh: BABYLON.AbstractMesh;
+        private _scene: Scene;
+        private _connectedMesh: AbstractMesh;
         private _customAttenuationFunction: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number;
         private _registerFunc;
 
@@ -44,7 +44,7 @@
         * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
         * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel
         */
-        constructor(name: string, urlOrArrayBuffer: any, scene: BABYLON.Scene, readyToPlayCallback?: () => void, options?) {
+        constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?) {
             this.name = name;
             this._scene = scene;
             this._audioEngine = this._scene.getEngine().getAudioEngine();
@@ -82,14 +82,14 @@
                 }
                 this._scene.mainSoundTrack.AddSound(this);
                 if (typeof (urlOrArrayBuffer) === "string") {
-                    BABYLON.Tools.LoadFile(urlOrArrayBuffer,(data) => { this._soundLoaded(data); }, null, null, true);
+                    Tools.LoadFile(urlOrArrayBuffer, (data) => { this._soundLoaded(data); }, null, null, true);
                 }
                 else {
                     if (urlOrArrayBuffer instanceof ArrayBuffer) {
                         this._soundLoaded(urlOrArrayBuffer);
                     }
                     else {
-                        BABYLON.Tools.Error("Parameter must be a URL to the sound or an ArrayBuffer of the sound.");
+                        Tools.Error("Parameter must be a URL to the sound or an ArrayBuffer of the sound.");
                     }
                 }
             }
@@ -126,14 +126,12 @@
 
         private _soundLoaded(audioData: ArrayBuffer) {
             this._isLoaded = true;
-            this._audioEngine.audioContext.decodeAudioData(audioData,(buffer) => {
+            this._audioEngine.audioContext.decodeAudioData(audioData, (buffer) => {
                 this._audioBuffer = buffer;
                 this._isReadyToPlay = true;
                 if (this.autoplay) { this.play(); }
                 if (this._readyToPlayCallback) { this._readyToPlayCallback(); }
-            }, function (error) {
-                    BABYLON.Tools.Error("Error while decoding audio data: " + error.err);
-                });
+            }, (error) => { Tools.Error("Error while decoding audio data: " + error.err); });
         }
 
         public updateOptions(options) {
@@ -187,7 +185,7 @@
         */
         public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number) {
             if (coneOuterAngle < coneInnerAngle) {
-                BABYLON.Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
+                Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
                 return;
             }
             this._coneInnerAngle = coneInnerAngle;
@@ -219,7 +217,7 @@
 
         private _updateDirection() {
             var mat = this._connectedMesh.getWorldMatrix();
-            var direction = BABYLON.Vector3.TransformNormal(this._localDirection, mat);
+            var direction = Vector3.TransformNormal(this._localDirection, mat);
             direction.normalize();
             this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
         }
@@ -266,7 +264,7 @@
                     this._isPlaying = true;
                 }
                 catch (ex) {
-                    BABYLON.Tools.Error("Error while trying to play audio: " + this.name + ", " + ex.message);
+                    Tools.Error("Error while trying to play audio: " + this.name + ", " + ex.message);
                 }
             }
         }
@@ -301,7 +299,7 @@
             return this._volume;
         }
 
-        public attachToMesh(meshToConnectTo: BABYLON.AbstractMesh) {
+        public attachToMesh(meshToConnectTo: AbstractMesh) {
             this._connectedMesh = meshToConnectTo;
             if (!this.spatialSound) {
                 this._createSpatialParameters();
@@ -311,11 +309,11 @@
                     this.play();
                 }
             }
-            this._registerFunc = (connectedMesh: BABYLON.AbstractMesh) => this._onRegisterAfterWorldMatrixUpdate(connectedMesh);
+            this._registerFunc = (connectedMesh: AbstractMesh) => this._onRegisterAfterWorldMatrixUpdate(connectedMesh);
             meshToConnectTo.registerAfterWorldMatrixUpdate(this._registerFunc);
         }
 
-        private _onRegisterAfterWorldMatrixUpdate(connectedMesh: BABYLON.AbstractMesh) {
+        private _onRegisterAfterWorldMatrixUpdate(connectedMesh: AbstractMesh) {
             this.setPosition(connectedMesh.position);
             if (this._isDirectional && this._isPlaying) {
                 this._updateDirection();

+ 3 - 24
Babylon/Audio/babylon.soundtrack.js

@@ -9,6 +9,9 @@
             this.soundCollection = new Array();
             if (this._audioEngine.canUseWebAudio) {
                 this._trackGain = this._audioEngine.audioContext.createGain();
+
+                //this._trackConvolver = this._audioEngine.audioContext.createConvolver();
+                //this._trackConvolver.connect(this._trackGain);
                 this._trackGain.connect(this._audioEngine.masterGain);
 
                 if (options) {
@@ -25,19 +28,6 @@
                 this.id = this._scene.soundTracks.length - 1;
             }
         }
-        SoundTrack.prototype.dispose = function () {
-            if (this._audioEngine.canUseWebAudio) {
-                if (this._connectedAnalyser) {
-                    this._connectedAnalyser.stopDebugCanvas();
-                }
-                while (this.soundCollection.length) {
-                    this.soundCollection[0].dispose();
-                }
-                this._trackGain.disconnect();
-                this._trackGain = null;
-            }
-        };
-
         SoundTrack.prototype.AddSound = function (sound) {
             sound.connectToSoundTrackAudioNode(this._trackGain);
             if (sound.soundTrackId) {
@@ -63,17 +53,6 @@
                 this._trackGain.gain.value = newVolume;
             }
         };
-
-        SoundTrack.prototype.connectToAnalyser = function (analyser) {
-            if (this._connectedAnalyser) {
-                this._connectedAnalyser.stopDebugCanvas();
-            }
-            this._connectedAnalyser = analyser;
-            if (this._audioEngine.canUseWebAudio) {
-                this._trackGain.disconnect();
-                this._connectedAnalyser.connectAudioNodes(this._trackGain, this._audioEngine.masterGain);
-            }
-        };
         return SoundTrack;
     })();
     BABYLON.SoundTrack = SoundTrack;

+ 0 - 45
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -928,43 +928,6 @@
             }
         };
 
-        var parseSound = function (parsedSound, scene, rootUrl) {
-            var soundName = parsedSound.name;
-            var soundUrl = rootUrl + soundName;
-
-            var options = {
-                autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
-                spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
-                rolloffFactor: parsedSound.rolloffFactor,
-                refDistance: parsedSound.refDistance,
-                distanceModel: parsedSound.distanceModel,
-                panningModel: parsedSound.panningModel
-            };
-
-            var newSound = new BABYLON.Sound(soundName, soundUrl, scene, function () {
-                scene._removePendingData(newSound);
-            }, options);
-            scene._addPendingData(newSound);
-
-            if (parsedSound.position) {
-                var soundPosition = BABYLON.Vector3.FromArray(parsedSound.position);
-                newSound.setPosition(soundPosition);
-            }
-            if (parsedSound.isDirectional) {
-                newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
-                if (parsedSound.localDirectionToMesh) {
-                    var localDirectionToMesh = BABYLON.Vector3.FromArray(parsedSound.localDirectionToMesh);
-                    newSound.setLocalDirectionToMesh(localDirectionToMesh);
-                }
-            }
-            if (parsedSound.connectedMeshId) {
-                var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
-                if (connectedMesh) {
-                    newSound.attachToMesh(connectedMesh);
-                }
-            }
-        };
-
         var isDescendantOf = function (mesh, names, hierarchyIds) {
             names = (names instanceof Array) ? names : [names];
             for (var i in names) {
@@ -1448,14 +1411,6 @@
                     }
                 }
 
-                // Sounds
-                if (parsedData.sounds && scene.getEngine().getAudioEngine().canUseWebAudio) {
-                    for (index = 0; index < parsedData.sounds.length; index++) {
-                        var parsedSound = parsedData.sounds[index];
-                        parseSound(parsedSound, scene, rootUrl);
-                    }
-                }
-
                 // Actions (scene)
                 if (parsedData.actions) {
                     parseActions(parsedData.actions, null, scene);

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

@@ -956,9 +956,7 @@
             panningModel: parsedSound.panningModel
         };
 
-        var newSound = new BABYLON.Sound(soundName, soundUrl, scene, function () {
-            scene._removePendingData(newSound);
-        }, options);
+        var newSound = new BABYLON.Sound(soundName, soundUrl, scene, () => { scene._removePendingData(newSound); }, options);
         scene._addPendingData(newSound);
 
         if (parsedSound.position) {

+ 7 - 9
Babylon/Materials/Textures/babylon.renderTargetTexture.js

@@ -54,7 +54,7 @@ var BABYLON;
                 return true;
             }
 
-            if (this.refreshRate === this._currentRefreshId) {
+            if (this.refreshRate == this._currentRefreshId) {
                 this._currentRefreshId = 1;
                 return true;
             }
@@ -107,7 +107,7 @@ var BABYLON;
                 delete this._waitingRenderList;
             }
 
-            if (this.renderList && this.renderList.length === 0) {
+            if (!this.renderList) {
                 return;
             }
 
@@ -121,10 +121,8 @@ var BABYLON;
 
             this._renderingManager.reset();
 
-            var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
-
-            for (var meshIndex = 0; meshIndex < currentRenderList.length; meshIndex++) {
-                var mesh = currentRenderList[meshIndex];
+            for (var meshIndex = 0; meshIndex < this.renderList.length; meshIndex++) {
+                var mesh = this.renderList[meshIndex];
 
                 if (mesh) {
                     if (!mesh.isReady() || (mesh.material && !mesh.material.isReady())) {
@@ -133,7 +131,7 @@ var BABYLON;
                         continue;
                     }
 
-                    if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && ((mesh.layerMask & scene.activeCamera.layerMask) !== 0)) {
+                    if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && ((mesh.layerMask & scene.activeCamera.layerMask) != 0)) {
                         mesh._activate(scene.getRenderId());
 
                         for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
@@ -154,7 +152,7 @@ var BABYLON;
             }
 
             // Render
-            this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
+            this._renderingManager.render(this.customRenderFunction, this.renderList, this.renderParticles, this.renderSprites);
 
             if (useCameraPostProcess) {
                 scene.postProcessManager._finalizeFrame(false, this._texture);
@@ -174,7 +172,7 @@ var BABYLON;
 
         RenderTargetTexture.prototype.clone = function () {
             var textureSize = this.getSize();
-            var newTexture = new RenderTargetTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps);
+            var newTexture = new BABYLON.RenderTargetTexture(this.name, textureSize.width, this.getScene(), this._generateMipMaps);
 
             // Base texture
             newTexture.hasAlpha = this.hasAlpha;

+ 1 - 4
Babylon/Mesh/babylon.InstancedMesh.js

@@ -6,9 +6,6 @@
 };
 var BABYLON;
 (function (BABYLON) {
-    /**
-    * Creates an instance based on a source mesh.
-    */
     var InstancedMesh = (function (_super) {
         __extends(InstancedMesh, _super);
         function InstancedMesh(name, source) {
@@ -163,7 +160,7 @@ var BABYLON;
                 for (var index = 0; index < this.getScene().meshes.length; index++) {
                     var mesh = this.getScene().meshes[index];
 
-                    if (mesh.parent === this) {
+                    if (mesh.parent == this) {
                         mesh.clone(mesh.name, result);
                     }
                 }

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

@@ -11,7 +11,6 @@ var BABYLON;
         function AbstractMesh(name, scene) {
             _super.call(this, name, scene);
             // Properties
-            this.definedFacingForward = true;
             this.position = new BABYLON.Vector3(0, 0, 0);
             this.rotation = new BABYLON.Vector3(0, 0, 0);
             this.scaling = new BABYLON.Vector3(1, 1, 1);
@@ -259,62 +258,6 @@ var BABYLON;
             }
         };
 
-        // ================================== Point of View Movement =================================
-        /**
-        * Perform relative position change from the point of view of behind the front of the mesh.
-        * This is performed taking into account the meshes current rotation, so you do not have to care.
-        * Supports definition of mesh facing forward or backward.
-        * @param {number} amountRight
-        * @param {number} amountUp
-        * @param {number} amountForward
-        */
-        AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
-            this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
-        };
-
-        /**
-        * Calculate relative position change from the point of view of behind the front of the mesh.
-        * This is performed taking into account the meshes current rotation, so you do not have to care.
-        * Supports definition of mesh facing forward or backward.
-        * @param {number} amountRight
-        * @param {number} amountUp
-        * @param {number} amountForward
-        */
-        AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
-            var rotMatrix = new BABYLON.Matrix();
-            var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
-            rotQuaternion.toRotationMatrix(rotMatrix);
-
-            var translationDelta = BABYLON.Vector3.Zero();
-            var defForwardMult = this.definedFacingForward ? -1 : 1;
-            BABYLON.Vector3.TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
-            return translationDelta;
-        };
-
-        // ================================== Point of View Rotation =================================
-        /**
-        * Perform relative rotation change from the point of view of behind the front of the mesh.
-        * Supports definition of mesh facing forward or backward.
-        * @param {number} flipBack
-        * @param {number} twirlClockwise
-        * @param {number} tiltRight
-        */
-        AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
-            this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
-        };
-
-        /**
-        * Calculate relative rotation change from the point of view of behind the front of the mesh.
-        * Supports definition of mesh facing forward or backward.
-        * @param {number} flipBack
-        * @param {number} twirlClockwise
-        * @param {number} tiltRight
-        */
-        AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
-            var defForwardMult = this.definedFacingForward ? 1 : -1;
-            return new BABYLON.Vector3(flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
-        };
-
         AbstractMesh.prototype.setPivotMatrix = function (matrix) {
             this._pivotMatrix = matrix;
             this._cache.pivotMatrixUpdated = true;

+ 5 - 24
Babylon/Mesh/babylon.mesh.js

@@ -19,7 +19,6 @@ var BABYLON;
     var Mesh = (function (_super) {
         __extends(Mesh, _super);
         /**
-        * @constructor
         * @param {string} name - The value used by scene.getMeshByName() to do a lookup.
         * @param {Scene} scene - The scene to add this mesh to.
         * @param {Node} parent - The parent of this mesh, if it has one
@@ -80,6 +79,9 @@ var BABYLON;
                 this.parent = parent;
             }
         }
+        Mesh.prototype._clone = function () {
+        };
+
         Object.defineProperty(Mesh.prototype, "hasLODLevels", {
             // Methods
             get: function () {
@@ -102,12 +104,6 @@ var BABYLON;
             });
         };
 
-        /**
-        * Add a mesh as LOD level triggered at the given distance.
-        * @param {number} distance - the distance from the center of the object to show this level
-        * @param {BABYLON.Mesh} mesh - the mesh to be added as LOD level
-        * @return {BABYLON.Mesh} this mesh (for chaining)
-        */
         Mesh.prototype.addLODLevel = function (distance, mesh) {
             if (mesh && mesh._masterMesh) {
                 BABYLON.Tools.Warn("You cannot use a mesh as LOD level twice");
@@ -126,11 +122,6 @@ var BABYLON;
             return this;
         };
 
-        /**
-        * Remove a mesh from the LOD array
-        * @param {BABYLON.Mesh} mesh - the mesh to be removed.
-        * @return {BABYLON.Mesh} this mesh (for chaining)
-        */
         Mesh.prototype.removeLODLevel = function (mesh) {
             for (var index = 0; index < this._LODLevels.length; index++) {
                 if (this._LODLevels[index].mesh === mesh) {
@@ -841,7 +832,7 @@ var BABYLON;
         };
 
         // Geometric tools
-        Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess) {
+        Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight) {
             var _this = this;
             var scene = this.getScene();
 
@@ -860,11 +851,6 @@ var BABYLON;
                 var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
 
                 _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight);
-
-                //execute success callback, if set
-                if (onSuccess) {
-                    onSuccess(_this);
-                }
             };
 
             BABYLON.Tools.LoadImage(url, onload, function () {
@@ -1172,7 +1158,7 @@ var BABYLON;
             return tiledGround;
         };
 
-        Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady) {
+        Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable) {
             var ground = new BABYLON.GroundMesh(name, scene);
             ground._subdivisions = subdivisions;
 
@@ -1196,11 +1182,6 @@ var BABYLON;
                 vertexData.applyToMesh(ground, updatable);
 
                 ground._setReady(true);
-
-                //execute ready callback, if set
-                if (onReady) {
-                    onReady(ground);
-                }
             };
 
             BABYLON.Tools.LoadImage(url, onload, function () {

+ 6 - 19
Babylon/Rendering/babylon.renderingManager.js

@@ -1,4 +1,4 @@
-var BABYLON;
+var BABYLON;
 (function (BABYLON) {
     var RenderingManager = (function () {
         function RenderingManager(scene) {
@@ -9,35 +9,28 @@
             if (this._scene._activeParticleSystems.length === 0) {
                 return;
             }
-
             // Particles
             var beforeParticlesDate = BABYLON.Tools.Now;
             for (var particleIndex = 0; particleIndex < this._scene._activeParticleSystems.length; particleIndex++) {
                 var particleSystem = this._scene._activeParticleSystems.data[particleIndex];
-
                 if (particleSystem.renderingGroupId !== index) {
                     continue;
                 }
-
                 this._clearDepthBuffer();
-
                 if (!particleSystem.emitter.position || !activeMeshes || activeMeshes.indexOf(particleSystem.emitter) !== -1) {
                     this._scene._activeParticles += particleSystem.render();
                 }
             }
             this._scene._particlesDuration += BABYLON.Tools.Now - beforeParticlesDate;
         };
-
         RenderingManager.prototype._renderSprites = function (index) {
             if (this._scene.spriteManagers.length === 0) {
                 return;
             }
-
-            // Sprites
+            // Sprites       
             var beforeSpritessDate = BABYLON.Tools.Now;
             for (var id = 0; id < this._scene.spriteManagers.length; id++) {
                 var spriteManager = this._scene.spriteManagers[id];
-
                 if (spriteManager.renderingGroupId === index) {
                     this._clearDepthBuffer();
                     spriteManager.render();
@@ -45,49 +38,43 @@
             }
             this._scene._spritesDuration += BABYLON.Tools.Now - beforeSpritessDate;
         };
-
         RenderingManager.prototype._clearDepthBuffer = function () {
             if (this._depthBufferAlreadyCleaned) {
                 return;
             }
-
             this._scene.getEngine().clear(0, false, true);
             this._depthBufferAlreadyCleaned = true;
         };
-
         RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
             for (var index = 0; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
                 this._depthBufferAlreadyCleaned = false;
                 var renderingGroup = this._renderingGroups[index];
-
                 if (renderingGroup) {
                     this._clearDepthBuffer();
                     if (!renderingGroup.render(customRenderFunction)) {
                         this._renderingGroups.splice(index, 1);
                     }
                 }
-                this._renderSprites(index);
+                if (renderSprites) {
+                    this._renderSprites(index);
+                }
                 if (renderParticles) {
                     this._renderParticles(index, activeMeshes);
                 }
             }
         };
-
         RenderingManager.prototype.reset = function () {
             for (var index in this._renderingGroups) {
                 var renderingGroup = this._renderingGroups[index];
                 renderingGroup.prepare();
             }
         };
-
         RenderingManager.prototype.dispatch = function (subMesh) {
             var mesh = subMesh.getMesh();
             var renderingGroupId = mesh.renderingGroupId || 0;
-
             if (!this._renderingGroups[renderingGroupId]) {
                 this._renderingGroups[renderingGroupId] = new BABYLON.RenderingGroup(renderingGroupId, this._scene);
             }
-
             this._renderingGroups[renderingGroupId].dispatch(subMesh);
         };
         RenderingManager.MAX_RENDERINGGROUPS = 4;
@@ -95,4 +82,4 @@
     })();
     BABYLON.RenderingManager = RenderingManager;
 })(BABYLON || (BABYLON = {}));
-//# sourceMappingURL=babylon.renderingManager.js.map
+//# sourceMappingURL=babylon.renderingManager.js.map

+ 5 - 1
Babylon/Rendering/babylon.renderingManager.ts

@@ -72,7 +72,11 @@
                         this._renderingGroups.splice(index, 1);
                     }
                 }
-                this._renderSprites(index);
+
+                if (renderSprites) {
+                    this._renderSprites(index);
+                }
+
                 if (renderParticles) {
                     this._renderParticles(index, activeMeshes);
                 }

+ 0 - 46
Babylon/babylon.engine.js

@@ -366,16 +366,7 @@
     })();
     BABYLON.EngineCapabilities = EngineCapabilities;
 
-    /**
-    * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
-    */
     var Engine = (function () {
-        /**
-        * @constructor
-        * @param {HTMLCanvasElement} canvas - the canvas to be used for rendering
-        * @param {boolean} [antialias] - enable antialias
-        * @param options - further options to be sent to the getContext function
-        */
         function Engine(canvas, antialias, options) {
             var _this = this;
             // Public members
@@ -724,10 +715,6 @@
             this._depthCullingState.depthFunc = this._gl.LEQUAL;
         };
 
-        /**
-        * stop executing a render loop function and remove it from the execution array
-        * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
-        */
         Engine.prototype.stopRenderLoop = function (renderFunction) {
             if (!renderFunction) {
                 this._activeRenderLoops = [];
@@ -772,14 +759,6 @@
             }
         };
 
-        /**
-        * Register and execute a render loop. The engine can have more than one render function.
-        * @param {Function} renderFunction - the function to continuesly execute starting the next render loop.
-        * @example
-        * engine.runRenderLoop(function () {
-        *      scene.render()
-        * })
-        */
         Engine.prototype.runRenderLoop = function (renderFunction) {
             var _this = this;
             if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
@@ -796,10 +775,6 @@
             }
         };
 
-        /**
-        * Toggle full screen mode.
-        * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
-        */
         Engine.prototype.switchFullscreen = function (requestPointerLock) {
             if (this.isFullscreen) {
                 BABYLON.Tools.ExitFullscreen();
@@ -827,12 +802,6 @@
             this._gl.clear(mode);
         };
 
-        /**
-        * Set the WebGL's viewport
-        * @param {BABYLON.Viewport} viewport - the viewport element to be used.
-        * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
-        * @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;
@@ -858,22 +827,10 @@
             this.flushFramebuffer();
         };
 
-        /**
-        * resize the view according to the canvas' size.
-        * @example
-        *   window.addEventListener("resize", function () {
-        *      engine.resize();
-        *   });
-        */
         Engine.prototype.resize = function () {
             this.setSize(this._renderingCanvas.clientWidth / this._hardwareScalingLevel, this._renderingCanvas.clientHeight / this._hardwareScalingLevel);
         };
 
-        /**
-        * force a specific size of the canvas
-        * @param {number} width - the new canvas' width
-        * @param {number} height - the new canvas' height
-        */
         Engine.prototype.setSize = function (width, height) {
             this._renderingCanvas.width = width;
             this._renderingCanvas.height = height;
@@ -1984,9 +1941,6 @@
                 this.scenes[0].dispose();
             }
 
-            // Release audio engine
-            this._audioEngine.dispose();
-
             for (var name in this._compiledEffects) {
                 this._gl.deleteProgram(this._compiledEffects[name]._program);
             }

+ 11 - 69
Babylon/babylon.scene.js

@@ -821,24 +821,6 @@
             return null;
         };
 
-        Scene.prototype.getSoundByName = function (name) {
-            for (var index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
-                if (this.mainSoundTrack.soundCollection[index].name === name) {
-                    return this.mainSoundTrack.soundCollection[index];
-                }
-            }
-
-            for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
-                for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
-                    if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
-                        return this.soundTracks[sdIndex].soundCollection[index];
-                    }
-                }
-            }
-
-            return null;
-        };
-
         Scene.prototype.getLastSkeletonByID = function (id) {
             for (var index = this.skeletons.length - 1; index >= 0; index--) {
                 if (this.skeletons[index].id === id) {
@@ -1296,11 +1278,6 @@
                 }
             }
 
-            // Depth renderer
-            if (this._depthRenderer) {
-                this._renderTargets.push(this._depthRenderer.getDepthMap());
-            }
-
             // RenderPipeline
             this.postProcessRenderPipelineManager.update();
 
@@ -1367,9 +1344,9 @@
                         sound.updateDistanceFromListener();
                     }
                 }
-                for (i = 0; i < this.soundTracks.length; i++) {
+                for (var i = 0; i < this.soundTracks.length; i++) {
                     for (var j = 0; j < this.soundTracks[i].soundCollection.length; j++) {
-                        sound = this.soundTracks[i].soundCollection[j];
+                        var sound = this.soundTracks[i].soundCollection[j];
                         if (sound.useCustomAttenuation) {
                             sound.updateDistanceFromListener();
                         }
@@ -1378,25 +1355,6 @@
             }
         };
 
-        Scene.prototype.enableDepthRenderer = function () {
-            if (this._depthRenderer) {
-                return this._depthRenderer;
-            }
-
-            this._depthRenderer = new BABYLON.DepthRenderer(this);
-
-            return this._depthRenderer;
-        };
-
-        Scene.prototype.disableDepthRenderer = function () {
-            if (!this._depthRenderer) {
-                return;
-            }
-
-            this._depthRenderer.dispose();
-            this._depthRenderer = null;
-        };
-
         Scene.prototype.dispose = function () {
             this.beforeRender = null;
             this.afterRender = null;
@@ -1405,10 +1363,6 @@
 
             this._boundingBoxRenderer.dispose();
 
-            if (this._depthRenderer) {
-                this._depthRenderer.dispose();
-            }
-
             // Debug layer
             this.debugLayer.hide();
 
@@ -1422,13 +1376,6 @@
 
             this.detachControl();
 
-            // Release sounds & sounds tracks
-            this.mainSoundTrack.dispose();
-
-            for (var scIndex = 0; scIndex < this.soundTracks.length; scIndex++) {
-                this.soundTracks[scIndex].dispose();
-            }
-
             // Detach cameras
             var canvas = this._engine.getRenderingCanvas();
             var index;
@@ -1736,7 +1683,7 @@
         };
 
         // Tags
-        Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
+        Scene.prototype._getByTags = function (list, tagsQuery) {
             if (tagsQuery === undefined) {
                 // returns the complete list (could be done with BABYLON.Tags.MatchesQuery but no need to have a for-loop here)
                 return list;
@@ -1744,35 +1691,30 @@
 
             var listByTags = [];
 
-            forEach = forEach || (function (item) {
-                return;
-            });
-
             for (var i in list) {
                 var item = list[i];
                 if (BABYLON.Tags.MatchesQuery(item, tagsQuery)) {
                     listByTags.push(item);
-                    forEach(item);
                 }
             }
 
             return listByTags;
         };
 
-        Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
-            return this._getByTags(this.meshes, tagsQuery, forEach);
+        Scene.prototype.getMeshesByTags = function (tagsQuery) {
+            return this._getByTags(this.meshes, tagsQuery);
         };
 
-        Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
-            return this._getByTags(this.cameras, tagsQuery, forEach);
+        Scene.prototype.getCamerasByTags = function (tagsQuery) {
+            return this._getByTags(this.cameras, tagsQuery);
         };
 
-        Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
-            return this._getByTags(this.lights, tagsQuery, forEach);
+        Scene.prototype.getLightsByTags = function (tagsQuery) {
+            return this._getByTags(this.lights, tagsQuery);
         };
 
-        Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
-            return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
+        Scene.prototype.getMaterialByTags = function (tagsQuery) {
+            return this._getByTags(this.materials, tagsQuery).concat(this._getByTags(this.multiMaterials, tagsQuery));
         };
         Scene.FOGMODE_NONE = 0;
         Scene.FOGMODE_EXP = 1;