Skip to content

Commit 4ad6b6a

Browse files
authored
feat!: manual normalizeRotations method (#579)
* manual normalizeRotations * updating contributing instructions for dev + corepack usage
1 parent c8f0f55 commit 4ad6b6a

File tree

11 files changed

+41
-15
lines changed

11 files changed

+41
-15
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version: "20"
22+
node-version-file: ".nvmrc"
2323
cache: "npm"
2424
- id: main
2525
run: |
File renamed without changes.

CONTRIBUTING.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1+
# INSTALL
2+
13
Pre-requisites:
24

3-
- `npm ci`
5+
- Install [nvm](https://github.com/nvm-sh/nvm), then:
6+
```sh
7+
$ nvm install
8+
$ nvm use
9+
$ node -v # make sure your version satisfies package.json#engines.node
10+
```
11+
nb: if you want this node version to be your default nvm's one: `nvm alias default node`
12+
- Install npm:
13+
```sh
14+
$ corepack enable
15+
$ corepack prepare --activate # it reads "packageManager"
16+
$ npm -v # make sure your version satisfies package.json#engines.npm
17+
```
18+
19+
```sh
20+
$ npm ci
21+
```
22+
23+
# Development
424

525
```sh
626
$ npm run dev

examples/await-transitions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125

126126
function lookAt() {
127127

128-
return cameraControls.setLookAt(
128+
return cameraControls.normalizeRotations().setLookAt(
129129
THREE.MathUtils.randFloat( 0, 5 ), THREE.MathUtils.randFloat( 0, 5 ), THREE.MathUtils.randFloat( 0, 5 ),
130130
0, 0, 0,
131131
true,

examples/basic.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
<br>
3737
<button onclick="cameraControls.setPosition( - 5, 2, 1, true )">move to ( -5, 2, 1 )</button>
3838
<button onclick="cameraControls.setTarget( 3, 0, -3, true )">look at ( 3, 0, -3 )</button>
39-
<button onclick="cameraControls.setLookAt( 1, 2, 3, 1, 1, 0, true )">move to ( 1, 2, 3 ), look at ( 1, 1, 0 )</button>
39+
<button onclick="cameraControls.normalizeRotations().setLookAt( 1, 2, 3, 1, 1, 0, true )">move to ( 1, 2, 3 ), look at ( 1, 1, 0 )</button>
4040
<br>
41-
<button onclick="cameraControls.lerpLookAt( - 2, 0, 0, 1, 1, 0, 0, 2, 5, - 1, 0, 0, Math.random(), true )">move to somewhere between ( -2, 0, 0 ) -> ( 1, 1, 0 ) and ( 0, 2, 5 ) -> ( -1, 0, 0 )</button>
41+
<button onclick="cameraControls.normalizeRotations().lerpLookAt( - 2, 0, 0, 1, 1, 0, 0, 2, 5, - 1, 0, 0, Math.random(), true )">move to somewhere between ( -2, 0, 0 ) -> ( 1, 1, 0 ) and ( 0, 2, 5 ) -> ( -1, 0, 0 )</button>
4242
<br>
4343
<button onclick="cameraControls.reset( true )">reset</button>
4444
<button onclick="cameraControls.saveState()">saveState</button>

examples/fit-to-rect.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
const distance = cameraControls.getDistanceToFitBox( rectWidth, rectHeight, 0 );
9191
const cameraPosition = _cameraPosition.copy( rectNormal ).multiplyScalar( - distance ).add( rectCenterPosition );
9292

93-
cameraControls.setLookAt(
93+
cameraControls.normalizeRotations().setLookAt(
9494
cameraPosition.x, cameraPosition.y, cameraPosition.z,
9595
rectCenterPosition.x, rectCenterPosition.y, rectCenterPosition.z,
9696
true,

examples/path-animation.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
const moveToStartPoint = () => {
7070

7171
curve.getPoint ( 0, _tmp );
72-
cameraControls.setLookAt( _tmp.x, _tmp.y, _tmp.z, 0, 0, 0, true );
72+
cameraControls.normalizeRotations().setLookAt( _tmp.x, _tmp.y, _tmp.z, 0, 0, 0, true );
7373

7474
};
7575

@@ -98,7 +98,7 @@
9898
const lookAtY = 0;
9999
const lookAtZ = 0;
100100

101-
cameraControls.setLookAt(
101+
cameraControls.normalizeRotations().setLookAt(
102102
cameraX,
103103
cameraY,
104104
cameraZ,

examples/rest-and-sleep.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<p><a href="https://github.com/yomotsu/camera-controls">GitHub repo</a></p>
1212
<button type="button" onclick="cameraControls.reset( true )">Reset</button>
1313
<button type="button" onclick="cameraControls.rotateTo( THREE.MathUtils.randFloat( 0, 2 * Math.PI ), THREE.MathUtils.randFloat( 0, Math.PI ), true )">Rotate</button>
14-
<button onclick="cameraControls.lerpLookAt( -2, 0, 0, 1, 1, 0, 0, 2, 5, -1, 0, 0, Math.random(), true )">Move</button>
14+
<button onclick="cameraControls.normalizeRotations().lerpLookAt( -2, 0, 0, 1, 1, 0, 0, 2, 5, -1, 0, 0, Math.random(), true )">Move</button>
1515
<p>These buttons will be disabled whenever a transition is occuring and then re-enabled when the transition is complete.</p>
1616
<button id="restEventBtn">Enable on Rest</button><br>
1717
<button id="sleepEventBtn">Enable on Sleep</button>

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,10 @@
6767
"controls",
6868
"OrbitControls",
6969
"camera"
70-
]
70+
],
71+
"packageManager": "[email protected]+sha256.c8c61ba0fa0ab3b5120efd5ba97fdaf0e0b495eef647a97c4413919eda0a878b",
72+
"engines": {
73+
"node": ">=20.11.0",
74+
"npm": ">=10.8.2"
75+
}
7176
}

rollup.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import pkg from './package.json' assert { type: 'json' };
21
import rollupReplace from '@rollup/plugin-replace';
32
import rollupTypescript from '@rollup/plugin-typescript';
43
import typescript from 'typescript';
4+
import { createRequire } from 'module';
5+
const require = createRequire(import.meta.url);
6+
const pkg = require('./package.json');
57

68
const license = `/*!
79
* ${ pkg.name }

0 commit comments

Comments
 (0)