0

I'm trying to setup up a simple Plnkr project with Angular and ThreeJS. I've got this so far - https://next.plnkr.co/edit/Jm4D2zgLtiKBGghC?preview

But as soon as I uncomment //var scene = new THREE.Scene(); on app.ts There is an error in the console. It's quite hard to understand the error, but I'm presuming it's simply I haven't imported the ThreeJS library correctly.

I've added in <script src=" https://unpkg.com/three@0.93.0/build/three.js"></script> to the index.html, I'm not sure what else to do.

On my local environment all I had to do was to use npm three install then I was able to import the lib correctly import * as THREE from 'three';

colouredFunk
  • 778
  • 1
  • 13
  • 35
  • Just follow the steps described in this thread: https://stackoverflow.com/questions/44293797/how-to-import-and-use-particles-js-in-an-angular-angular2-angular4-app – Ludwig Jun 10 '18 at 17:14
  • If you comment out `import * as THREE from 'three';`, it seems to work – user184994 Jun 10 '18 at 17:30

1 Answers1

1

You should tell systemjs where to find three package:

config.js

map: {
  ...
  'three': 'npm:three'
},

Forked Plunker

yurzui
  • 205,937
  • 32
  • 433
  • 399