Skip to content

Commit 52be400

Browse files
committed
Animation: Fix ReferenceError in non-broswer environment
Node.js and Deno do not support `self`.
1 parent 541455a commit 52be400

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/renderers/common/Animation.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class Animation {
3434
*
3535
* @type {Window|XRSession}
3636
*/
37-
this._context = self;
37+
this._context = typeof self !== 'undefined' ? self : // browser or Web Worker
38+
typeof globalThis !== 'undefined' ? globalThis : // ES 2020
39+
typeof global !== 'undefined' ? global : // Node.js
40+
null;
3841

3942
/**
4043
* The user-defined animation loop.

0 commit comments

Comments
 (0)