Просмотр исходного кода

Fixing AssetsManager bug with textures

David Catuhe 10 лет назад
Родитель
Сommit
8aac6bd24f

+ 7 - 0
Babylon/Materials/Textures/babylon.texture.js

@@ -44,6 +44,13 @@ var BABYLON;
                     this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
                 }
             }
+            else {
+                BABYLON.Tools.SetImmediate(function () {
+                    if (onLoad) {
+                        onLoad();
+                    }
+                });
+            }
         }
         Texture.prototype.delayLoad = function () {
             if (this.delayLoadState !== BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {

+ 6 - 0
Babylon/Materials/Textures/babylon.texture.ts

@@ -73,6 +73,12 @@
                 } else {
                     this.delayLoadState = Engine.DELAYLOADSTATE_NOTLOADED;
                 }
+            } else {
+                Tools.SetImmediate(() => {
+                    if (onLoad) {
+                        onLoad();
+                    }
+                });
             }
         }
 

+ 6 - 4
Babylon/Physics/Plugins/babylon.oimoJSPlugin.js

@@ -14,8 +14,9 @@ var BABYLON;
                         var body = registeredMesh.body.body;
                         mesh.computeWorldMatrix(true);
                         var center = mesh.getBoundingInfo().boundingBox.center;
-                        body.setPosition(center.x, center.y, center.z);
-                        body.setRotation(mesh.rotation.x, mesh.rotation.y, mesh.rotation.z);
+                        body.setPosition(new OIMO.Vec3(center.x, center.y, center.z));
+                        body.setRotation(new OIMO.Vec3(mesh.rotation.x, mesh.rotation.y, mesh.rotation.z));
+                        body.sleeping = false;
                         return;
                     }
                     // Case where the parent has been updated
@@ -25,8 +26,9 @@ var BABYLON;
                         var absolutePosition = registeredMesh.mesh.getAbsolutePosition();
                         var absoluteRotation = mesh.rotation;
                         body = registeredMesh.body.body;
-                        body.setPosition(absolutePosition.x, absolutePosition.y, absolutePosition.z);
-                        body.setRotation(absoluteRotation.x, absoluteRotation.y, absoluteRotation.z);
+                        body.setPosition(new OIMO.Vec3(absolutePosition.x, absolutePosition.y, absolutePosition.z));
+                        body.setRotation(new OIMO.Vec3(absoluteRotation.x, absoluteRotation.y, absoluteRotation.z));
+                        body.sleeping = false;
                         return;
                     }
                 }

+ 8 - 0
Babylon/Tools/babylon.tools.js

@@ -19,6 +19,14 @@ var BABYLON;
     var Tools = (function () {
         function Tools() {
         }
+        Tools.SetImmediate = function (action) {
+            if (window.setImmediate) {
+                window.setImmediate(action);
+            }
+            else {
+                setTimeout(action, 1);
+            }
+        };
         Tools.GetFilename = function (path) {
             var index = path.lastIndexOf("/");
             if (index < 0)

+ 8 - 0
Babylon/Tools/babylon.tools.ts

@@ -30,6 +30,14 @@
     export class Tools {
         public static BaseUrl = "";
 
+        public static SetImmediate(action: () => void) {
+            if (window.setImmediate) {
+                window.setImmediate(action);
+            } else {
+                setTimeout(action, 1);
+            }
+        }
+
         public static GetExponantOfTwo = (value: number, max: number): number => {
             var count = 1;
 

+ 21 - 4
babylon.2.1-beta.debug.js

@@ -4034,6 +4034,14 @@ var BABYLON;
     var Tools = (function () {
         function Tools() {
         }
+        Tools.SetImmediate = function (action) {
+            if (window.setImmediate) {
+                window.setImmediate(action);
+            }
+            else {
+                setTimeout(action, 1);
+            }
+        };
         Tools.GetFilename = function (path) {
             var index = path.lastIndexOf("/");
             if (index < 0)
@@ -14922,6 +14930,13 @@ var BABYLON;
                     this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
                 }
             }
+            else {
+                BABYLON.Tools.SetImmediate(function () {
+                    if (onLoad) {
+                        onLoad();
+                    }
+                });
+            }
         }
         Texture.prototype.delayLoad = function () {
             if (this.delayLoadState !== BABYLON.Engine.DELAYLOADSTATE_NOTLOADED) {
@@ -21462,8 +21477,9 @@ var BABYLON;
                         var body = registeredMesh.body.body;
                         mesh.computeWorldMatrix(true);
                         var center = mesh.getBoundingInfo().boundingBox.center;
-                        body.setPosition(center.x, center.y, center.z);
-                        body.setRotation(mesh.rotation.x, mesh.rotation.y, mesh.rotation.z);
+                        body.setPosition(new OIMO.Vec3(center.x, center.y, center.z));
+                        body.setRotation(new OIMO.Vec3(mesh.rotation.x, mesh.rotation.y, mesh.rotation.z));
+                        body.sleeping = false;
                         return;
                     }
                     // Case where the parent has been updated
@@ -21473,8 +21489,9 @@ var BABYLON;
                         var absolutePosition = registeredMesh.mesh.getAbsolutePosition();
                         var absoluteRotation = mesh.rotation;
                         body = registeredMesh.body.body;
-                        body.setPosition(absolutePosition.x, absolutePosition.y, absolutePosition.z);
-                        body.setRotation(absoluteRotation.x, absoluteRotation.y, absoluteRotation.z);
+                        body.setPosition(new OIMO.Vec3(absolutePosition.x, absolutePosition.y, absolutePosition.z));
+                        body.setRotation(new OIMO.Vec3(absoluteRotation.x, absoluteRotation.y, absoluteRotation.z));
+                        body.sleeping = false;
                         return;
                     }
                 }

Разница между файлами не показана из-за своего большого размера
+ 15 - 14
babylon.2.1-beta.js


Разница между файлами не показана из-за своего большого размера
+ 15 - 14
babylon.2.1-beta.noworker.js


+ 4 - 1
babylon.2.1.d.ts

@@ -1686,7 +1686,7 @@ declare module BABYLON {
         constructor(name: string, position: Vector3, scene: Scene);
         attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
         detachControl(element: HTMLElement): void;
-        _collideWithWorld(velocity: Vector3, gravityInspection?: boolean): void;
+        _collideWithWorld(velocity: Vector3): void;
         private _onCollisionPositionChange;
         _checkInputs(): void;
         _decideIfNeedsToMove(): boolean;
@@ -2571,6 +2571,7 @@ declare module BABYLON {
         constructor(name: string, scene: Scene);
         getSubMaterial(index: any): Material;
         isReady(mesh?: AbstractMesh): boolean;
+        clone(name: string): MultiMaterial;
     }
 }
 declare module BABYLON {
@@ -3974,7 +3975,9 @@ declare module BABYLON {
         isDisposed(): boolean;
         sideOrientation: number;
         areNormalsFrozen: boolean;
+        /**  This function affects parametric shapes on update only : ribbons, tubes, etc. It has no effect at all on other shapes */
         freezeNormals(): void;
+        /**  This function affects parametric shapes on update only : ribbons, tubes, etc. It has no effect at all on other shapes */
         unfreezeNormals(): void;
         _preActivate(): void;
         _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): void;

+ 1 - 0
what's new - 2.1 - proposal.md

@@ -51,3 +51,4 @@
  - Fixing animatable bug when animation is over ([temechon](http://www.github.com/temechon))
  - useCameraPostProcess whenever there is a special camera in use ([m0ppers](https://github.com/m0ppers))
  - delta in BoundingBox's intersectsPoint is now calculated correctly ([raananw](http://www.github.com/raananw)) 
+ - textures cache fixed ([deltakosh](http://www.github.com/deltakosh))