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
I was able to bundle OrbitControls with (webpack v2 + ts-loader) and no other loaders.
package.json:
"dependencies": {
"three": "^0.85.2",
"@types/three": "^0.84.12",
"ts-loader": "^2.1.0",
"typescript": "^2.3.4",
"webpack": "^2.6.1"
},
entrypoint.ts:
import * as THREE from "three";
// OrbitControls.js expects a global THREE object
(window as any).THREE = THREE;
// NOTE: OrbitControls must be included with require:
// using "import" cause it to be executed before global THREE becomes available
require("three/examples/js/controls/OrbitControls");
// ... code that uses THREE and THREE.OrbitControls
NOTE: webpack may warn like "export 'OrbitControls' (imported as 'THREE') was not found in 'three'
, because OrbitControls.js
is not a proper JS module. I suppose we can just ignore this warning.