0.0.3 • Published 5 years ago
@workswithweb/threejs-orbit-controls v0.0.3
@workswithweb/threejs-orbit-controls
Installation
with npm
npm install @workswithweb/threejs-orbit-controls
with yarn
yarn add @workswithweb/threejs-orbit-controls
Usage
All credit goes to OrbitControls.js contributors. See also official OrbitControls documentation.
This repo trasnsalted existing js code to typescript and compiled to es6 module using rollupjs.
You will be able to use this module in typescript and javascript
Usage with typescript or es module code
import { OrbitControls } from '@workswithweb/threejs-orbit-controls';
// Init THREE camera (add your code)
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
camera.position.z = 5;
const renderer = new THREE.WebGLRenderer({ canvas })
// This is how you use OrbitControls with camera
const controls = new OrbitControls(camera);
or
// This is how you use OrbitControls with camera and domElement
const controls = new OrbitControls(camera, renderer.domElement);
Usage with commonjs code
const OrbitControls = require('@workswithweb/threejs-orbit-controls')
// Init THREE camera (add your code)
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
camera.position.z = 5;
const renderer = new THREE.WebGLRenderer({ canvas })
// This is how you use OrbitControls with camera
const controls = new OrbitControls(camera);
or
// This is how you use OrbitControls with camera and domElement
const controls = new OrbitControls(camera, renderer.domElement);
Please note that:
- You call
OrbitControls
directly instead ofTHREE.OrbitControls
. - This package does not depend directly on three.js, which is declared as a peer dependency.
If you want to modify this package
- git clone git@github.com:workswithweb/threejs-orbit-controls.git
- cd threejs-orbit-controls
- npm install
- npm run build