javascript – 在TypeScript中使用Threejs OrbitContols

前端之家收集整理的这篇文章主要介绍了javascript – 在TypeScript中使用Threejs OrbitContols前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法获得使用TypeScript中的上述组合的 this示例.

我有< script src =“lib / three.min.js”>< / script>和< script src =“lib / OrbitControls.js”>< / script>在我的html< head>和< body>中的typescript文件

@H_404_4@/// <reference path="lib\three.d.ts" /> ... this.controls = new THREE.OrbitControls(this.camera); //there's the error this.controls.addEventListener('change',this.render); ...

@H_404_4@this.controls.update();

在周期性调用render()函数.据我所知,设置与expample相同,但在编译OrbitControls构造函数行时给出了一个巨大的错误(缩写):

@H_404_4@The property 'OrbitControls' does not exist on value of type '{REVISION:string; CullFace: {[x: number ...

我猜这个错误中有整个Threejs,因为Visual Studio在我点击它时崩溃了:).谢谢你的帮助.

解决方法

花了几个小时花在这个问题上,我最终创建了一个新包: three-orbitcontrols-ts @H_404_4@import * as THREE from 'three'; import { OrbitControls } from 'three-orbitcontrols-ts'; const controls = new OrbitControls(camera,renderer.domElement);

猜你在找的JavaScript相关文章