From d1b9cb2bcb321f0a1e76688a2cb5e6479d85362b Mon Sep 17 00:00:00 2001 From: Marco Fugaro Date: Sat, 27 Jun 2020 16:09:28 +0200 Subject: [PATCH 1/2] Use globalThis instead of window --- rollup.config.js | 2 +- src/world/World.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 7726968cc..40f52f2d3 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -40,7 +40,7 @@ export default [ sizeSnapshot(), replace({ // Use node built-in performance.now in commonjs environments - 'window.performance': `require('perf_hooks').performance`, + 'globalThis.performance': `require('perf_hooks').performance`, }), ], }, diff --git a/src/world/World.ts b/src/world/World.ts index 214fd1aec..0a1456928 100644 --- a/src/world/World.ts +++ b/src/world/World.ts @@ -800,7 +800,7 @@ const tmpArray1 = [] const tmpRay = new Ray() // performance.now() fallback on Date.now() -const performance = (window.performance || {}) as Performance +const performance = (globalThis.performance || {}) as Performance if (!performance.now) { let nowOffset = Date.now() From 09d10b4cc4bcc16c956c3a5de98da2dfabfbebad Mon Sep 17 00:00:00 2001 From: Marco Fugaro Date: Sat, 27 Jun 2020 16:09:38 +0200 Subject: [PATCH 2/2] Build --- dist/cannon-es.cjs.js | 6 +++--- dist/cannon-es.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/cannon-es.cjs.js b/dist/cannon-es.cjs.js index 92c1c1654..b2c03bb32 100644 --- a/dist/cannon-es.cjs.js +++ b/dist/cannon-es.cjs.js @@ -9127,7 +9127,7 @@ class Trimesh extends Shape { const n = this.vertices.length / 3, verts = this.vertices; const minx,miny,minz,maxx,maxy,maxz; - const v = tempWorldVertex; + const v = tempWorldVertex; for(let i=0; i maxx || maxx===undefined){ maxx = v.x; } - if (v.y < miny || miny===undefined){ + if (v.y < miny || miny===undefined){ miny = v.y; } else if(v.y > maxy || maxy===undefined){ maxy = v.y; } - if (v.z < minz || minz===undefined){ + if (v.z < minz || minz===undefined){ minz = v.z; } else if(v.z > maxz || maxz===undefined){ maxz = v.z; diff --git a/dist/cannon-es.js b/dist/cannon-es.js index 26d835965..cc3f1c647 100644 --- a/dist/cannon-es.js +++ b/dist/cannon-es.js @@ -9123,7 +9123,7 @@ class Trimesh extends Shape { const n = this.vertices.length / 3, verts = this.vertices; const minx,miny,minz,maxx,maxy,maxz; - const v = tempWorldVertex; + const v = tempWorldVertex; for(let i=0; i maxx || maxx===undefined){ maxx = v.x; } - if (v.y < miny || miny===undefined){ + if (v.y < miny || miny===undefined){ miny = v.y; } else if(v.y > maxy || maxy===undefined){ maxy = v.y; } - if (v.z < minz || minz===undefined){ + if (v.z < minz || minz===undefined){ minz = v.z; } else if(v.z > maxz || maxz===undefined){ maxz = v.z; @@ -12194,7 +12194,7 @@ class World extends EventTarget { const tmpAABB1 = new AABB(); const tmpRay$1 = new Ray(); // performance.now() fallback on Date.now() -const performance = window.performance || {}; +const performance = globalThis.performance || {}; if (!performance.now) { let nowOffset = Date.now();