Procházet zdrojové kódy

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe před 7 roky
rodič
revize
f0b75cdc18

+ 1 - 0
dist/preview release/what's new.md

@@ -96,6 +96,7 @@
 - (Viewer) Disabling templates now work correctly ([RaananW](https://github.com/RaananW))
 - AMD "define" declaration is no longer anonymous ([RaananW](https://github.com/RaananW))
 - Collision worker didn't initialize instanced meshes correctly - [#3819](https://github.com/BabylonJS/Babylon.js/issues/3819) ([RaananW](https://github.com/RaananW))
+- postMessage calls in webworkers were fixed ([RaananW](https://github.com/RaananW))
 
 ## Breaking changes
 

+ 6 - 3
src/Collisions/babylon.collisionWorker.ts

@@ -1,5 +1,8 @@
 declare function importScripts(...urls: string[]): void;
 
+// since typescript doesn't understand the file's execution context, we need to override postMessage's signature for error-free compilation
+const safePostMessage: any = self.postMessage;
+
 module BABYLON {
 
     //If this file is included in the main thread, this will be initialized.
@@ -192,7 +195,7 @@ module BABYLON {
                 error: WorkerReplyType.SUCCESS,
                 taskType: WorkerTaskType.INIT
             }
-            postMessage(reply, "");
+            safePostMessage(reply);
         }
 
         public onUpdate(payload: UpdatePayload) {
@@ -226,7 +229,7 @@ module BABYLON {
             }
 
 
-            postMessage(replay, "");
+            safePostMessage(replay);
         }
 
         public onCollision(payload: CollidePayload) {
@@ -247,7 +250,7 @@ module BABYLON {
                 taskType: WorkerTaskType.COLLIDE,
                 payload: replyPayload
             }
-            postMessage(reply, "");
+            safePostMessage(reply);
         }
     }