瀏覽代碼

Fixing tiny issue with SPS

David Catuhe 9 年之前
父節點
當前提交
458f79c823

File diff suppressed because it is too large
+ 15 - 15
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 883 - 868
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 18 - 18
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 2507 - 2478
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 19 - 19
dist/preview release/babylon.noworker.js


+ 5 - 6
src/Audio/babylon.sound.js

@@ -310,6 +310,10 @@ var BABYLON;
             var _this = this;
             if (this._isReadyToPlay && this._scene.audioEnabled) {
                 try {
+                    if (this._startOffset < 0) {
+                        time = -this._startOffset;
+                        this._startOffset = 0;
+                    }
                     var startTime = time ? BABYLON.Engine.audioEngine.audioContext.currentTime + time : BABYLON.Engine.audioEngine.audioContext.currentTime;
                     if (!this._soundSource || !this._streamingSource) {
                         if (this.spatialSound) {
@@ -344,12 +348,7 @@ var BABYLON;
                         this._soundSource.loop = this.loop;
                         this._soundSource.playbackRate.value = this._playbackRate;
                         this._soundSource.onended = function () { _this._onended(); };
-                        if (!this.isPaused) {
-                            this._soundSource.start(startTime);
-                        }
-                        else {
-                            this._soundSource.start(0, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : 0);
-                        }
+                        this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : 0);
                     }
                     this._startTime = startTime;
                     this.isPlaying = true;

+ 3 - 8
src/Audio/babylon.sound.ts

@@ -346,7 +346,7 @@
                     if (this._startOffset < 0) {
                         time = -this._startOffset;
                         this._startOffset = 0;
-                    }
+                    }  
                     var startTime = time ? Engine.audioEngine.audioContext.currentTime + time : Engine.audioEngine.audioContext.currentTime;
                     if (!this._soundSource || !this._streamingSource) {
                         if (this.spatialSound) {
@@ -381,12 +381,7 @@
                         this._soundSource.loop = this.loop;
                         this._soundSource.playbackRate.value = this._playbackRate;
                         this._soundSource.onended = () => { this._onended(); };
-                        if (!this.isPaused) {
-                            this._soundSource.start(startTime);
-                        }
-                        else {
-                            this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : 0);
-                        }
+                        this._soundSource.start(startTime, this.isPaused ? this._startOffset % this._soundSource.buffer.duration : 0);
                     }
                     this._startTime = startTime;
                     this.isPlaying = true;
@@ -601,4 +596,4 @@
             return newSound;
         }
     }
-}
+}

+ 1 - 1
src/Cameras/babylon.camera.js

@@ -586,7 +586,7 @@ var BABYLON;
                 camera = new BABYLON.VRDeviceOrientationFreeCamera(parsedCamera.name, position, scene);
             }
             else if (parsedCamera.type === "FreeCamera") {
-                camera = new BABYLON.UniversalCamera(parsedCamera.name, position, scene);
+                camera = new BABYLON.UniversalCamera(parsedCamera.name, position, scene); // Forcing Universal here
             }
             else {
                 // Universal Camera is the default value

+ 1 - 1
src/Cameras/babylon.camera.ts

@@ -663,7 +663,7 @@
                 camera = new VRDeviceOrientationFreeCamera(parsedCamera.name, position, scene);
 
             } else if (parsedCamera.type === "FreeCamera") {
-                camera = new UniversalCamera(parsedCamera.name, position, scene);   
+                camera = new UniversalCamera(parsedCamera.name, position, scene);   // Forcing Universal here
                         
             } else {
                 // Universal Camera is the default value

+ 31 - 1
src/Particles/babylon.solidParticleSystem.js

@@ -25,6 +25,7 @@ var BABYLON;
             this._index = 0; // indices index
             this._updatable = true;
             this._pickable = false;
+            this._isVisibilityBoxLocked = false;
             this._alwaysVisible = false;
             this._shapeCounter = 0;
             this._copy = new BABYLON.SolidParticle(null, null, null, null, null);
@@ -512,7 +513,18 @@ var BABYLON;
         * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility
         */
         SolidParticleSystem.prototype.refreshVisibleSize = function () {
-            this.mesh.refreshBoundingInfo();
+            if (!this._isVisibilityBoxLocked) {
+                this.mesh.refreshBoundingInfo();
+            }
+        };
+        /** Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
+        * @param size the size (float) of the visibility box
+        * note : this doesn't lock the SPS mesh bounding box.
+        * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility
+        */
+        SolidParticleSystem.prototype.setVisibilityBox = function (size) {
+            var vis = size / 2;
+            this.mesh._boundingInfo = new BABYLON.BoundingInfo(new BABYLON.Vector3(-vis, -vis, -vis), new BABYLON.Vector3(vis, vis, vis));
         };
         Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
             // getter and setter
@@ -533,6 +545,24 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
+            /**
+            * True if the SPS visibility box is locked. The underlying mesh bounding box is then not updatable any more.
+            */
+            get: function () {
+                return this._isVisibilityBoxLocked;
+            },
+            /**
+            * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
+            * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility
+            */
+            set: function (val) {
+                this._isVisibilityBoxLocked = val;
+                this.mesh.getBoundingInfo().isLocked = val;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
             // getters
             get: function () {

+ 2 - 1
src/Particles/babylon.solidParticleSystem.ts

@@ -619,7 +619,7 @@ module BABYLON {
         */
         public set isVisibilityBoxLocked(val: boolean) {
             this._isVisibilityBoxLocked = val;
-            this.mesh.getBoundingInfo.isLocked = val;
+            this.mesh.getBoundingInfo().isLocked = val;
         }
 
         /**
@@ -746,3 +746,4 @@ module BABYLON {
         }
     }
 }
+