Bladeren bron

Rename velocity to direction for moveWithCollisions

David Catuhe 8 jaren geleden
bovenliggende
commit
1686020892

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


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


+ 38 - 4
dist/preview release/babylon.max.js

@@ -7452,6 +7452,7 @@ var BABYLON;
             // To enable/disable IDB support and avoid XHR on .manifest
             this.enableOfflineSupport = false;
             this.scenes = new Array();
+            this.postProcesses = new Array();
             // Observables
             /**
              * Observable event triggered each time the rendering canvas is resized
@@ -8116,9 +8117,13 @@ var BABYLON;
                 scene._rebuildGeometries();
                 scene._rebuildTextures();
             }
+            for (var _b = 0, _c = this.postProcesses; _b < _c.length; _b++) {
+                var postprocess = _c[_b];
+                postprocess._rebuild();
+            }
             // Uniforms
-            for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
-                var uniformBuffer = _c[_b];
+            for (var _d = 0, _e = this._uniformBuffers; _d < _e.length; _d++) {
+                var uniformBuffer = _e[_d];
                 uniformBuffer._rebuild();
             }
         };
@@ -10853,6 +10858,10 @@ var BABYLON;
         Engine.prototype.dispose = function () {
             this.hideLoadingUI();
             this.stopRenderLoop();
+            // Release postProcesses
+            while (this.postProcesses.length) {
+                this.postProcesses[0].dispose();
+            }
             // Empty texture
             if (this._emptyTexture) {
                 this._releaseTexture(this._emptyTexture);
@@ -16471,6 +16480,7 @@ var BABYLON;
             /** Defines the gravity applied to this scene */
             this.gravity = new BABYLON.Vector3(0, -9.807, 0);
             // Postprocesses
+            this.postProcesses = new Array();
             this.postProcessesEnabled = true;
             // Customs render targets
             this.renderTargetsEnabled = true;
@@ -19065,6 +19075,10 @@ var BABYLON;
             while (this.spriteManagers.length) {
                 this.spriteManagers[0].dispose();
             }
+            // Release postProcesses
+            while (this.postProcesses.length) {
+                this.postProcesses[0].dispose();
+            }
             // Release layers
             while (this.layers.length) {
                 this.layers[0].dispose();
@@ -19390,8 +19404,12 @@ var BABYLON;
                 var mesh = _c[_b];
                 mesh._rebuild();
             }
-            for (var _d = 0, _e = this.layers; _d < _e.length; _d++) {
-                var layer = _e[_d];
+            for (var _d = 0, _e = this.postProcesses; _d < _e.length; _d++) {
+                var postprocess = _e[_d];
+                postprocess._rebuild();
+            }
+            for (var _f = 0, _g = this.layers; _f < _g.length; _f++) {
+                var layer = _g[_f];
                 layer._rebuild();
             }
         };
@@ -46564,9 +46582,11 @@ var BABYLON;
                 this._scene = camera.getScene();
                 camera.attachPostProcess(this);
                 this._engine = this._scene.getEngine();
+                this._scene.postProcesses.push(this);
             }
             else {
                 this._engine = engine;
+                this._engine.postProcesses.push(this);
             }
             this._options = options;
             this.renderTargetSamplingMode = samplingMode ? samplingMode : BABYLON.Texture.NEAREST_SAMPLINGMODE;
@@ -46820,9 +46840,23 @@ var BABYLON;
             }
             this._textures.dispose();
         };
+        PostProcess.prototype._rebuild = function () {
+        };
         PostProcess.prototype.dispose = function (camera) {
             camera = camera || this._camera;
             this._disposeTextures();
+            if (this._scene) {
+                var index_1 = this._scene.postProcesses.indexOf(this);
+                if (index_1 !== -1) {
+                    this._scene.postProcesses.splice(index_1, 1);
+                }
+            }
+            else {
+                var index_2 = this._engine.postProcesses.indexOf(this);
+                if (index_2 !== -1) {
+                    this._engine.postProcesses.splice(index_2, 1);
+                }
+            }
             if (!camera) {
                 return;
             }

File diff suppressed because it is too large
+ 1841 - 1838
dist/preview release/babylon.module.d.ts


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


File diff suppressed because it is too large
+ 6831 - 6828
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


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


+ 40 - 6
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -7452,6 +7452,7 @@ var BABYLON;
             // To enable/disable IDB support and avoid XHR on .manifest
             this.enableOfflineSupport = false;
             this.scenes = new Array();
+            this.postProcesses = new Array();
             // Observables
             /**
              * Observable event triggered each time the rendering canvas is resized
@@ -8116,9 +8117,13 @@ var BABYLON;
                 scene._rebuildGeometries();
                 scene._rebuildTextures();
             }
+            for (var _b = 0, _c = this.postProcesses; _b < _c.length; _b++) {
+                var postprocess = _c[_b];
+                postprocess._rebuild();
+            }
             // Uniforms
-            for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
-                var uniformBuffer = _c[_b];
+            for (var _d = 0, _e = this._uniformBuffers; _d < _e.length; _d++) {
+                var uniformBuffer = _e[_d];
                 uniformBuffer._rebuild();
             }
         };
@@ -10853,6 +10858,10 @@ var BABYLON;
         Engine.prototype.dispose = function () {
             this.hideLoadingUI();
             this.stopRenderLoop();
+            // Release postProcesses
+            while (this.postProcesses.length) {
+                this.postProcesses[0].dispose();
+            }
             // Empty texture
             if (this._emptyTexture) {
                 this._releaseTexture(this._emptyTexture);
@@ -13338,7 +13347,7 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
-        AbstractMesh.prototype.moveWithCollisions = function (velocity) {
+        AbstractMesh.prototype.moveWithCollisions = function (direction) {
             var globalPosition = this.getAbsolutePosition();
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
             this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset);
@@ -13346,7 +13355,7 @@ var BABYLON;
                 this._collider = new BABYLON.Collider();
             }
             this._collider.radius = this.ellipsoid;
-            this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
+            this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions, direction, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
             return this;
         };
         // Submeshes octree
@@ -16471,6 +16480,7 @@ var BABYLON;
             /** Defines the gravity applied to this scene */
             this.gravity = new BABYLON.Vector3(0, -9.807, 0);
             // Postprocesses
+            this.postProcesses = new Array();
             this.postProcessesEnabled = true;
             // Customs render targets
             this.renderTargetsEnabled = true;
@@ -19065,6 +19075,10 @@ var BABYLON;
             while (this.spriteManagers.length) {
                 this.spriteManagers[0].dispose();
             }
+            // Release postProcesses
+            while (this.postProcesses.length) {
+                this.postProcesses[0].dispose();
+            }
             // Release layers
             while (this.layers.length) {
                 this.layers[0].dispose();
@@ -19390,8 +19404,12 @@ var BABYLON;
                 var mesh = _c[_b];
                 mesh._rebuild();
             }
-            for (var _d = 0, _e = this.layers; _d < _e.length; _d++) {
-                var layer = _e[_d];
+            for (var _d = 0, _e = this.postProcesses; _d < _e.length; _d++) {
+                var postprocess = _e[_d];
+                postprocess._rebuild();
+            }
+            for (var _f = 0, _g = this.layers; _f < _g.length; _f++) {
+                var layer = _g[_f];
                 layer._rebuild();
             }
         };
@@ -34982,9 +35000,11 @@ var BABYLON;
                 this._scene = camera.getScene();
                 camera.attachPostProcess(this);
                 this._engine = this._scene.getEngine();
+                this._scene.postProcesses.push(this);
             }
             else {
                 this._engine = engine;
+                this._engine.postProcesses.push(this);
             }
             this._options = options;
             this.renderTargetSamplingMode = samplingMode ? samplingMode : BABYLON.Texture.NEAREST_SAMPLINGMODE;
@@ -35238,9 +35258,23 @@ var BABYLON;
             }
             this._textures.dispose();
         };
+        PostProcess.prototype._rebuild = function () {
+        };
         PostProcess.prototype.dispose = function (camera) {
             camera = camera || this._camera;
             this._disposeTextures();
+            if (this._scene) {
+                var index_1 = this._scene.postProcesses.indexOf(this);
+                if (index_1 !== -1) {
+                    this._scene.postProcesses.splice(index_1, 1);
+                }
+            }
+            else {
+                var index_2 = this._engine.postProcesses.indexOf(this);
+                if (index_2 !== -1) {
+                    this._engine.postProcesses.splice(index_2, 1);
+                }
+            }
             if (!camera) {
                 return;
             }

File diff suppressed because it is too large
+ 6831 - 6828
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 5 - 5
src/Cameras/babylon.freeCamera.ts

@@ -114,7 +114,7 @@
             this._collisionMask = !isNaN(mask) ? mask : -1;
         }
 	 
-        public _collideWithWorld(velocity: Vector3): void {
+        public _collideWithWorld(direction: Vector3): void {
             var globalPosition: Vector3;
 
             if (this.parent) {
@@ -133,15 +133,15 @@
             this._collider.collisionMask = this._collisionMask;
 		
             //no need for clone, as long as gravity is not on.
-            var actualVelocity = velocity;
+            var actualDirection = direction;
 			
-            //add gravity to the velocity to prevent the dual-collision checking
+            //add gravity to the direction to prevent the dual-collision checking
             if (this.applyGravity) {
                 //this prevents mending with cameraDirection, a global variable of the free camera class.
-                actualVelocity = velocity.add(this.getScene().gravity);
+                actualDirection = direction.add(this.getScene().gravity);
             }
 
-            this.getScene().collisionCoordinator.getNewPosition(this._oldPosition, actualVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
+            this.getScene().collisionCoordinator.getNewPosition(this._oldPosition, actualDirection, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
 
         }
 

+ 2 - 2
src/Mesh/babylon.abstractMesh.ts

@@ -1529,7 +1529,7 @@
             }
         }
 
-        public moveWithCollisions(velocity: Vector3): AbstractMesh {
+        public moveWithCollisions(direction: Vector3): AbstractMesh {
             var globalPosition = this.getAbsolutePosition();
 
             globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPositionForCollisions);
@@ -1541,7 +1541,7 @@
 
             this._collider.radius = this.ellipsoid;
 
-            this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions, velocity, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
+            this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions, direction, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
             return this;
         }
 

+ 19 - 0
src/PostProcess/babylon.postProcess.ts

@@ -142,9 +142,12 @@
                 this._scene = camera.getScene();
                 camera.attachPostProcess(this);
                 this._engine = this._scene.getEngine();
+
+                this._scene.postProcesses.push(this);
             }
             else {
                 this._engine = engine;
+                this._engine.postProcesses.push(this);
             }
 
             this._options = options;
@@ -366,11 +369,27 @@
             this._textures.dispose();
         }
 
+        public _rebuild(): void {
+            
+        }
+
         public dispose(camera?: Camera): void {
             camera = camera || this._camera;            
 
             this._disposeTextures();
 
+            if (this._scene) {
+                let index = this._scene.postProcesses.indexOf(this);
+                if (index !== -1) {
+                    this._scene.postProcesses.splice(index, 1);
+                }                
+            } else {
+                let index = this._engine.postProcesses.indexOf(this);
+                if (index !== -1) {
+                    this._engine.postProcesses.splice(index, 1);
+                }         
+            }
+
             if (!camera) {
                 return;
             }

+ 10 - 0
src/babylon.engine.ts

@@ -529,6 +529,7 @@
         // To enable/disable IDB support and avoid XHR on .manifest
         public enableOfflineSupport = false;
         public scenes = new Array<Scene>();
+        public postProcesses = new Array<PostProcess>();
 
         // Observables
 
@@ -956,6 +957,10 @@
                 scene._rebuildTextures();
             }
 
+            for (var postprocess of this.postProcesses) {
+                postprocess._rebuild();
+            }
+
             // Uniforms
             for (var uniformBuffer of this._uniformBuffers) {
                 uniformBuffer._rebuild();
@@ -4250,6 +4255,11 @@
 
             this.stopRenderLoop();
 
+            // Release postProcesses
+            while (this.postProcesses.length) {
+                this.postProcesses[0].dispose();
+            }
+
             // Empty texture
             if (this._emptyTexture) {
                 this._releaseTexture(this._emptyTexture);

+ 10 - 0
src/babylon.scene.ts

@@ -694,6 +694,7 @@
         public gravity = new Vector3(0, -9.807, 0);
 
         // Postprocesses
+        public postProcesses = new Array<PostProcess>();
         public postProcessesEnabled = true;
         public postProcessManager: PostProcessManager;
         private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager
@@ -3449,6 +3450,11 @@
                 this.spriteManagers[0].dispose();
             }
 
+            // Release postProcesses
+            while (this.postProcesses.length) {
+                this.postProcesses[0].dispose();
+            }
+
             // Release layers
             while (this.layers.length) {
                 this.layers[0].dispose();
@@ -3840,6 +3846,10 @@
                 mesh._rebuild();
             }
 
+            for (var postprocess of this.postProcesses) {
+                postprocess._rebuild();
+            }            
+
             for (var layer of this.layers) {
                 layer._rebuild();
             }