1 | **DEPRECATED**
|
2 |
|
3 | [three-js] exposes real modules now via three/examples/jsm/...
|
4 | For example to import the Orbit, do
|
5 |
|
6 | ```js
|
7 | import { 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 |
|
16 | To install with npm do
|
17 |
|
18 | ```bash
|
19 | npm install three
|
20 | npm install three-orbitcontrols
|
21 | ```
|
22 |
|
23 | ## Usage
|
24 |
|
25 | All credit goes to [OrbitControls.js][original_orbitcontrols] contributors.
|
26 | See also [official OrbitControls documentation][orbitcontrols_documentation].
|
27 |
|
28 | I have just **stolen** the code and modified to export it as a module so you can do something like
|
29 |
|
30 | ```javascript
|
31 | const THREE = require('three')
|
32 | const 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 |
|
38 | const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000)
|
39 | camera.position.z = 5
|
40 |
|
41 | const renderer = new THREE.WebGLRenderer({ canvas })
|
42 |
|
43 | const controls = new OrbitControls(camera, renderer.domElement)
|
44 | controls.enableDamping = true
|
45 | controls.dampingFactor = 0.25
|
46 | controls.enableZoom = false
|
47 | ```
|
48 |
|
49 | Please note that:
|
50 |
|
51 | 1. You call `OrbitControls` directly instead of `THREE.OrbitControls`.
|
52 | 2. This package does not depend directly on [three.js], which is declared as a peer dependency.
|
53 |
|
54 | See 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 |
|
61 | See [OrbiControls.js history here](https://github.com/mrdoob/three.js/commits/master/examples/js/controls/OrbitControls.js).
|
62 |
|
63 | Please also note that this repo's minor version equals [three.js] release number.
|
64 |
|
65 | ## Motivation
|
66 |
|
67 | There is another package similar to this one: [three-orbit-controls].
|
68 | I 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 |
|
70 | I 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 |
|
73 | I am using this package for my [3d tic tac toe](http://tris3d.net) online game.
|
74 | -->
|
75 |
|
76 | ## License
|
77 |
|
78 | License 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"
|