我開始在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 /角度級別上的問題的解決方法。 –