Skip to content

Commit

Permalink
Merge pull request #35 from react-spring/bugfix/node-performance-api
Browse files Browse the repository at this point in the history
Bugfix/node performance api
  • Loading branch information
codynova authored Jun 18, 2020
2 parents 3d5556b + 4b6246e commit 52cac8d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
8 changes: 6 additions & 2 deletions dist/cannon-es.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13026,8 +13026,12 @@ var World = /*#__PURE__*/function (_EventTarget) {
var tmpAABB1 = new AABB();
var tmpRay$1 = new Ray(); // performance.now()

if (typeof performance === 'undefined') {
performance = {};
var performance = {};

if (typeof window !== 'undefined') {
performance = window.performance;
} else {
performance = require('perf_hooks').performance;
}

if (!performance.now) {
Expand Down
8 changes: 6 additions & 2 deletions dist/cannon-es.js
Original file line number Diff line number Diff line change
Expand Up @@ -12194,8 +12194,12 @@ class World extends EventTarget {
const tmpAABB1 = new AABB();
const tmpRay$1 = new Ray(); // performance.now()

if (typeof performance === 'undefined') {
performance = {};
let performance = {};

if (typeof window !== 'undefined') {
performance = window.performance;
} else {
performance = require('perf_hooks').performance;
}

if (!performance.now) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cannon-es",
"version": "0.10.0",
"version": "0.11.0",
"description": "A lightweight 3D physics engine written in JavaScript.",
"homepage": "https://github.com/schteppe/cannon.js",
"author": "Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",
Expand Down
9 changes: 7 additions & 2 deletions src/world/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,14 @@ const tmpArray1 = []
const tmpRay = new Ray()

// performance.now()
if (typeof performance === 'undefined') {
;(performance as any) = {}
let performance = {} as Performance

if (typeof window !== 'undefined') {
performance = window.performance
} else {
performance = require('perf_hooks').performance
}

if (!performance.now) {
let nowOffset = Date.now()
if (performance.timing && performance.timing.navigationStart) {
Expand Down

0 comments on commit 52cac8d

Please sign in to comment.