0.0.3 • Published 5 years ago

@workswithweb/threejs-orbit-controls v0.0.3

Weekly downloads
25
License
MIT
Repository
github
Last release
5 years ago

@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:

  1. You call OrbitControls directly instead of THREE.OrbitControls.
  2. This package does not depend directly on three.js, which is declared as a peer dependency.

If you want to modify this package

  1. git clone git@github.com:workswithweb/threejs-orbit-controls.git
  2. cd threejs-orbit-controls
  3. npm install
  4. npm run build

License

License is the same as three.js, i.e. MIT.