Using Threejs + OrbitContols in TypeScript

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

    The solution is from this issue. Just install three-full and @types/three and add the types definitions to "compilerOptions" in tsconfig.json.

      "compilerOptions": {
        /* ... */
        "baseUrl": ".",        // needed to use path aliases!
        "paths": {
          "three-full": ["node_modules/@types/three"]
      }
    }
    

    Then import THREE like

    import * as THREE from 'three-full';
    

    Afterwards everything works fine including intellisense.

    Without @types/three,` it still works, but you do not get intellisense.

提交回复
热议问题