0

I am currently trying to import a WebGL engine known as PlayCanvas. It is very similar to three.js, but unlike three.js; it unfortunately does not have a npm package/bundle. Through the solution I got from this StackOverflow solution; I downloaded the engine code and imported it into my React Component.

The weird problem is that there is errors in the playcanvas.min.js I imported. I know for a fact that the engine code is correct, however the code relies on a physics engine called ammo.js and most of the not defined are as follows...

When I try to import the physics engine ammo.js into the playcanvas engine, my local host server crashes and refuses to render anything.

Line 3:     'define' is not defined              no-undef
  Line 4:     'define' is not defined              no-undef
  Line 780:   'webkitAudioContext' is not defined  no-undef
  Line 880:   Unexpected use of 'self'             no-restricted-globals
  Line 1125:  'Ammo' is not defined                no-undef
  Line 1125:  'Ammo' is not defined                no-undef
  Line 1125:  'Ammo' is not defined                no-undef
  Line 1125:  'Ammo' is not defined                no-undef

I believe the main problem is that <script src="https://code.playcanvas.com/playcanvas-latest.js"></script> is very different from import * as pc from './playcanvas.min.js'

gman
  • 100,619
  • 31
  • 269
  • 393
user9878643
  • 308
  • 4
  • 15
  • Out of interest, have you seen [this GitHub issue](https://github.com/playcanvas/engine/issues/932)? – Sam Holmes Jul 17 '18 at 23:52
  • Yes. I did have a look but did not pay much attention to it. Now I know you can install the whole engine because the contributors have created a `package.json` file. I can now install it by calling the github repo as such -> [link](https://stackoverflow.com/questions/17509669/how-to-install-an-npm-package-from-github-directly). Is this the viable option? @SamHolmes Thanks. – user9878643 Jul 18 '18 at 00:18
  • It absolutely is! – Sam Holmes Jul 18 '18 at 00:32

1 Answers1

0

This looks like a linter issue, try using eslint-config-playcanvas as a configuration rule. This seems to disable the warnings and errors related to PlayCanvas environment.

Here's the instruction on how to do it.

ChrisR
  • 3,922
  • 1
  • 14
  • 24