-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzine-camera-utils.js
51 lines (49 loc) · 1.51 KB
/
zine-camera-utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
export const setPerspectiveCameraFromJson = (camera, cameraJson) => {
camera.position.fromArray(cameraJson.position);
camera.quaternion.fromArray(cameraJson.quaternion);
camera.scale.fromArray(cameraJson.scale);
camera.updateMatrixWorld();
camera.near = cameraJson.near;
camera.far = cameraJson.far;
camera.fov = cameraJson.fov;
camera.updateProjectionMatrix();
return camera;
};
export const getPerspectiveCameraJson = camera => {
return {
position: camera.position.toArray(),
quaternion: camera.quaternion.toArray(),
scale: camera.scale.toArray(),
near: camera.near,
far: camera.far,
fov: camera.fov,
};
};
//
export const setOrthographicCameraFromJson = (camera, cameraJson) => {
camera.position.fromArray(cameraJson.position);
camera.quaternion.fromArray(cameraJson.quaternion);
camera.scale.fromArray(cameraJson.scale);
camera.updateMatrixWorld();
camera.near = cameraJson.near;
camera.far = cameraJson.far;
camera.left = cameraJson.left;
camera.right = cameraJson.right;
camera.top = cameraJson.top;
camera.bottom = cameraJson.bottom;
camera.updateProjectionMatrix();
return camera;
};
export const getOrthographicCameraJson = camera => {
return {
position: camera.position.toArray(),
quaternion: camera.quaternion.toArray(),
scale: camera.scale.toArray(),
near: camera.near,
far: camera.far,
left: camera.left,
right: camera.right,
top: camera.top,
bottom: camera.bottom,
};
};