Skip to content

Commit 2c3b987

Browse files
authored
Merge pull request #46 from martinRenou/cameraRotation
Expose rotation as quaternion
2 parents bdc00b4 + 5ed4276 commit 2c3b987

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/Scene.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ class Renderer {
158158
return this.camera.position;
159159
}
160160

161-
set cameraUp (position: THREE.Vector3) {
162-
this.camera.up.set(position.x, position.y, position.z);
161+
set cameraRotation (rotation: THREE.Quaternion) {
162+
this.camera.quaternion.set(rotation.x, rotation.y, rotation.z, rotation.w);
163163
}
164164

165-
get cameraUp () {
166-
return this.camera.up;
165+
get cameraRotation () : THREE.Quaternion {
166+
return this.camera.quaternion;
167167
}
168168

169169
set cameraTarget (position: THREE.Vector3) {
@@ -174,6 +174,14 @@ class Renderer {
174174
return this.controls.target;
175175
}
176176

177+
set cameraUp (up: THREE.Vector3) {
178+
this.camera.up.set(up.x, up.y, up.z);
179+
}
180+
181+
get cameraUp () {
182+
return this.camera.up;
183+
}
184+
177185
/**
178186
* Animation
179187
*/
@@ -199,7 +207,7 @@ class Renderer {
199207
}
200208

201209
handleCameraMove () {
202-
this.scene.handleCameraMove(this.camera.position, this.cameraTarget);
210+
this.scene.handleCameraMove(this.camera.position, this.controls.target);
203211
}
204212

205213
handleCameraMoveEnd () {

0 commit comments

Comments
 (0)