UNPKG

2.96 kBMarkdownView Raw
1**DEPRECATED**
2
3[three-js] exposes real modules now via three/examples/jsm/...
4For example to import the Orbit, do
5
6```js
7import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
8```
9
10# three-orbitcontrols
11
12> is the [three.js] OrbitControls from official repo examples
13
14## Installation
15
16To install with npm do
17
18```bash
19npm install three
20npm install three-orbitcontrols
21```
22
23## Usage
24
25All credit goes to [OrbitControls.js][original_orbitcontrols] contributors.
26See also [official OrbitControls documentation][orbitcontrols_documentation].
27
28I have just **stolen** the code and modified to export it as a module so you can do something like
29
30```javascript
31const THREE = require('three')
32const OrbitControls = require('three-orbitcontrols')
33// ES6 also works, i.e.
34// import OrbitControls from 'three-orbitcontrols'
35
36// Init THREE scene (add your code)
37
38const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000)
39camera.position.z = 5
40
41const renderer = new THREE.WebGLRenderer({ canvas })
42
43const controls = new OrbitControls(camera, renderer.domElement)
44controls.enableDamping = true
45controls.dampingFactor = 0.25
46controls.enableZoom = false
47```
48
49Please note that:
50
511. You call `OrbitControls` directly instead of `THREE.OrbitControls`.
522. This package does not depend directly on [three.js], which is declared as a peer dependency.
53
54See also examples:
55
56- [CommonJS example](https://github.com/fibo/three-orbitcontrols/tree/master/example.js): clone this repo, install deps and launch `npm run example_commonjs`.
57- [TypeScript example](https://github.com/fibo/three-orbitcontrols/tree/master/example.ts): clone this repo, install deps and launch `npm run example_typescript`.
58
59## Changelog
60
61See [OrbiControls.js history here](https://github.com/mrdoob/three.js/commits/master/examples/js/controls/OrbitControls.js).
62
63Please also note that this repo's minor version equals [three.js] release number.
64
65## Motivation
66
67There is another package similar to this one: [three-orbit-controls].
68I decided to create another package with a different approach, see [this issue for the rationale](https://github.com/mattdesl/three-orbit-controls/issues/17).
69
70I am using this package for my [3d tic tac toe canvas](https://github.com/fibo/tris3d-canvas): see also online [demo](http://g14n.info/tris3d-canvas/example/).
71
72<!--
73I am using this package for my [3d tic tac toe](http://tris3d.net) online game.
74-->
75
76## License
77
78License is the same as [three.js], i.e. [MIT].
79
80[original_orbitcontrols]: https://github.com/mrdoob/three.js/tree/master/examples/js/controls/OrbitControls.js "OrbitControls.js"
81[orbitcontrols_documentation]: https://threejs.org/docs/#examples/controls/OrbitControls "OrbitControls documentation"
82[three.js]: http://threejs.org/ "three.js"
83[MIT]: https://github.com/mrdoob/three.js/blob/master/LICENSE "three.js license"
84[three-orbit-controls]: https://www.npmjs.com/package/three-orbit-controls "three-orbit-controls"