three-orbitcontrols-ts-port
TypeScript icon, indicating that this package has built-in type declarations

2.102.2 • Public • Published

three-orbitcontrols

is the three.js OrbitControls from official repo examples

Installation

To install with npm do

npm install three
npm install three-orbitcontrols

Usage

All credit goes to OrbitControls.js contributors. See also official OrbitControls documentation.

I have just stolen the code and modified to export it as a module so you can do something like

const THREE = require('three')
const OrbitControls = require('three-orbitcontrols')
// ES6 also works, i.e.
// import OrbitControls from 'three-orbitcontrols'
 
// Init THREE scene (add your code)
 
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000)
camera.position.z = 5
 
const renderer = new THREE.WebGLRenderer({ canvas })
 
const controls = new OrbitControls(camera, renderer.domElement)
controls.enableDamping = true
controls.dampingFactor = 0.25
controls.enableZoom = false

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.

See also examples/ folder:

Motivation

There is another package similar to this one: three-orbit-controls. I decided to create another package with a different approach, see this issue for the rationale.

I am using this package for my 3d tic tac toe online game.

License

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

Package Sidebar

Install

npm i three-orbitcontrols-ts-port

Weekly Downloads

3

Version

2.102.2

License

MIT

Unpacked Size

42.3 kB

Total Files

11

Last publish

Collaborators

  • martin31821