I\'m having a lot of trouble getting stuff in threejs\'s examples (like EffectComposer or Detector) to work with webpack and typescript.
First off the relevant *.d
Here's what worked for me.
$ npm install --save-dev exports-loader imports-loader
Then, to use something from three/examples/js
, I do this:
const THREE = require('three');
// imports provides THREE to the OrbitControls example
// exports gets THREE.OrbitControls
THREE.OrbitControls = require('imports?THREE=three!exports?THREE.OrbitControls!../../node_modules\/three\/examples\/js\/controls\/OrbitControls');
// use THREE.OrbitControls ...
I think the right thing to do is use the imports
and exports
loaders by config rather than embedding them in the require. I'll update this answer when I have an example.