How to load three-orbitcontrols with import syntax?

前端 未结 5 1616
遇见更好的自我
遇见更好的自我 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:31

    I just did it like this when using parcel bundler:

    app.js:

    import * as THREE from "three";
    import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
    
    // the rest of the example from threejs web page 
    // https://github.com/mrdoob/three.js/blob/master/examples/misc_controls_orbit.html
    

    index.html:

    
    
      
        
        Parcel threejs example
        
      
      
        
      
    
    

    package.json:

    {
      "name": "test-threejs-with-parcel",
      "version": "0.1.0",
      "description": "Threejs with parcel test",
      "main": "app.js",
      "scripts": {
        "start": "parcel index.html",
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC",
      "devDependencies": {
        "parcel-bundler": "^1.10.0"
      },
      "dependencies": {
        "three": "^0.109.0"
      }
    }
    

提交回复
热议问题