Using Threejs + OrbitContols in TypeScript

前端 未结 14 1256
清歌不尽
清歌不尽 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:39

    Importing the OrbitControls directly from the source file after importing THREE worked great for me (without using the three-orbitcontrols-ts package):

    import * as THREE from 'three';
    import 'three/examples/js/controls/OrbitControls';
    

    Using only the three and @types/three packages

    0 讨论(0)
  • 2021-02-07 12:40

    Unfortunately none of above answers solved problem for me. I have found solution without installing third party packages by creating three.js file with below content:

    import * as THREE from 'three';
    window.THREE = THREE;
    require('three/examples/js/controls/OrbitControls');
    
    export default THREE;
    

    and then import THREE from './three';

    0 讨论(0)
提交回复
热议问题