在 TypeScript 中使用三个 Js + OrbitControl

2024-05-04

我无法得到this http://www.example.com/在 TypeScript 中使用上述组合的示例。

I have <script src="lib/three.min.js"></script> and <script src="lib/OrbitControls.js"></script>在我的html中<head>和打字稿文件<body>:

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

and

this.controls.update();

在定期调用render()功能。据我所知,设置与示例相同,但在编译 OrbitControls 构造函数行时给了我一个巨大的错误(缩写):

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

我猜想这个错误中有整个 Threejs,因为 Visual Studio 在我点击它的那一刻就崩溃了:)。感谢您的帮助。


如中所述docs https://threejs.org/docs/#manual/en/introduction/Installation请执行下列操作:

import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';

重要的是您使用该文件夹jsm代替js。请记住,jsm 文件夹中尚未提供所有模块

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 TypeScript 中使用三个 Js + OrbitControl 的相关文章

随机推荐