Using Threejs + OrbitContols in TypeScript

前端 未结 14 1239
清歌不尽
清歌不尽 2021-02-07 11:59

I\'m not able to get this example of using the aforementioned combo going in TypeScript.

I have and <

14条回答
  •  余生分开走
    2021-02-07 12:16

    If you actually still want OrbitControls to be accessed from THREE, the following seems to work for me:

    import * as __THREE from 'three';
    import * as X from 'three/examples/jsm/controls/OrbitControls.js';
    
    type THREE = typeof __THREE & typeof X
    

    Only real difference is now if you specify the type of controls, it'll look something like

    const controls: X.OrbitControls = new THREE.OrbitControls(camera, renderer.domElement)
    

提交回复
热议问题