How to load three-orbitcontrols with import syntax?

前端 未结 5 1626
遇见更好的自我
遇见更好的自我 2021-01-17 14:59

Has anyone tried using the OrbitControls function with ReactJS? Here is the sample code I wrote:

import React, { Component } from \'react\';
import \'tachy         


        
5条回答
  •  鱼传尺愫
    2021-01-17 15:10

    There is an npm package that you can use: Orbit Controls ES6

    Link: https://www.npmjs.com/package/orbit-controls-es6

    Installation:

    npm i orbit-controls-es6 --save
    

    Usage:

    import OrbitControls from 'orbit-controls-es6';
    
    const controls = new OrbitControls(camera, renderer.domElement);
    

    Update 2020:

    three.js now exports OrbitControls as a module by default, and as others have pointed out, it can be used as follows:

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

提交回复
热议问题