我开始在angular.io使用three.js所,并有此错误:Angular.io(SystemJS)三是没有定义的ReferenceError:三是没有定义
(index):18 Error: (SystemJS) THREE is not defined
ReferenceError: THREE is not defined
at Object.eval (http://localhost:3000/node_modules/three/examples/js/controls/OrbitControls.js:16:1)
at eval (http://localhost:3000/node_modules/three/examples/js/controls/OrbitControls.js:1044:4)
at eval (http://localhost:3000/node_modules/three/examples/js/controls/OrbitControls.js:1045:3)
at eval (<anonymous>)
Evaluating http://localhost:3000/node_modules/three/examples/js/controls/OrbitControls.js
Evaluating http://localhost:3000/app/three-basis/three-camera-orbit-control.component.js
我进口和组件:
import {Component} from '@angular/core';
import {CameraProvider} from './camera-provider.service';
import 'threejs/controls/OrbitControls';
import {OrbitControls} from 'three';
@Component({selector: 'three-camera-orbit-control', template: ''})
export class ThreeCameraOrbitControlComponent {
constructor(private cameraProvider: CameraProvider) {
let camera = this.cameraProvider.getCamera();
let controls = new OrbitControls(camera);
controls.addEventListener('change',() => {});
}
}
如果我在我的node_modules/three的OrbitControls.js中添加这个var THREE = require("three");
,错误gones和一切正常。我不擅长js,可以请一些人帮助我,如何做到这一点?谢谢。
作为增加新的模块三-orbitcontrol-ts,通过不喜欢这个,想要了解js /角度级别上的问题的解决方法。 –