Ver código fonte

Fix latest ammo

sebavan 4 anos atrás
pai
commit
cca3c35cff

+ 7 - 0
Playground/src/components/rendererComponent.tsx

@@ -13,6 +13,8 @@ interface IRenderingComponentProps {
     globalState: GlobalState;
 }
 
+declare const Ammo: any;
+
 export class RenderingComponent extends React.Component<IRenderingComponentProps> {
     private _engine: Nullable<Engine>;
     private _scene: Nullable<Scene>;
@@ -156,6 +158,11 @@ export class RenderingComponent extends React.Component<IRenderingComponentProps
                 return;
             }
 
+            // Check for Ammo.js
+            if (code.indexOf("AmmoJSPlugin") > -1 && typeof Ammo === "function") {
+                await Ammo();
+            }
+
             // Check for Unity Toolkit
             if ((location.href.indexOf("UnityToolkit") !== -1 || Utilities.ReadBoolFromStore("unity-toolkit", false)) && !this._unityToolkitWasLoaded) {
                 await this._loadScriptAsync("/libs/babylon.manager.js");

Diferenças do arquivo suprimidas por serem muito extensas
+ 898 - 21
dist/preview release/ammo.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 846 - 10
dist/preview release/ammo.wasm.js


BIN
dist/preview release/ammo.wasm.wasm


+ 2 - 1
src/Physics/Plugins/ammoJSPlugin.ts

@@ -70,7 +70,8 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
      */
     public constructor(private _useDeltaForWorldStep: boolean = true, ammoInjection: any = Ammo, overlappingPairCache: any = null) {
         if (typeof ammoInjection === "function") {
-            ammoInjection(this.bjsAMMO);
+            Logger.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.");
+            return;
         } else {
             this.bjsAMMO = ammoInjection;
         }