我正在使用three.js处理angular2。
这是我对angular cli的配置。
在package.json中:
"three": "^0.81.2",
"three-stl-loader": "^1.0.4",
在angular.cli.json中:
"../node_modules/three/build/three.min.js",
"../node_modules/three/examples/js/Detector.js",
"../node_modules/three/examples/js/controls/OrbitControls.js",
"../node_modules/three/examples/js/controls/TrackballControls.js",
"../node_modules/three/examples/js/loaders/STLLoader.js",
在组件文件中,我加载了THREE和OrbitControls:
import * as THREE from 'three';
import PerspectiveCamera = THREE.PerspectiveCamera;
import OrbitControls = THREE.OrbitControls;
当应用程序运行时,控制台会显示以下消息:
'THREE.WebGLRenderer 81
three.js:41149 THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.
three.js:41158 THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.
'
所以很明显三个.js被加载了,但是为什么找不到OrbitControls?
答案 0 :(得分:5)
我遇到了类似的问题。这是我的工作,运行以下命令:
npm install three-orbit-controls
编辑import语句下的component.ts文件,但在@Component:
之上const THREE = require('three');
const OrbitControls = require('three-orbit-controls')(THREE);
现在它将被称为OrbitControls而不是THREE.OrbitControls