* Sets the position and orientation of the camera. * * `myCamera.camera()` allows objects to be viewed from different angles. It * has nine parameters that are all optional. * * The first three parameters, `x`, `y`, and `z`, are the coordinates of the * camera’s position in "world"
(
eyeX,
eyeY,
eyeZ,
centerX,
centerY,
centerZ,
upX,
upY,
upZ
)
| 1065 | * } |
| 1066 | */ |
| 1067 | camera( |
| 1068 | eyeX, |
| 1069 | eyeY, |
| 1070 | eyeZ, |
| 1071 | centerX, |
| 1072 | centerY, |
| 1073 | centerZ, |
| 1074 | upX, |
| 1075 | upY, |
| 1076 | upZ |
| 1077 | ) { |
| 1078 | if (typeof eyeX === 'undefined') { |
| 1079 | eyeX = this.defaultEyeX; |
| 1080 | eyeY = this.defaultEyeY; |
| 1081 | eyeZ = this.defaultEyeZ; |
| 1082 | centerX = eyeX; |
| 1083 | centerY = eyeY; |
| 1084 | centerZ = 0; |
| 1085 | upX = 0; |
| 1086 | upY = 1; |
| 1087 | upZ = 0; |
| 1088 | } |
| 1089 | |
| 1090 | this.eyeX = eyeX; |
| 1091 | this.eyeY = eyeY; |
| 1092 | this.eyeZ = eyeZ; |
| 1093 | |
| 1094 | if (typeof centerX !== 'undefined') { |
| 1095 | this.centerX = centerX; |
| 1096 | this.centerY = centerY; |
| 1097 | this.centerZ = centerZ; |
| 1098 | } |
| 1099 | |
| 1100 | if (typeof upX !== 'undefined') { |
| 1101 | this.upX = upX; |
| 1102 | this.upY = upY; |
| 1103 | this.upZ = upZ; |
| 1104 | } |
| 1105 | |
| 1106 | const local = this._getLocalAxes(); |
| 1107 | |
| 1108 | // the camera affects the model view matrix, insofar as it |
| 1109 | // inverse translates the world to the eye position of the camera |
| 1110 | // and rotates it. |
| 1111 | |
| 1112 | this.cameraMatrix.set(local.x[0], local.y[0], local.z[0], 0, |
| 1113 | local.x[1], local.y[1], local.z[1], 0, |
| 1114 | local.x[2], local.y[2], local.z[2], 0, |
| 1115 | 0, 0, 0, 1); |
| 1116 | |
| 1117 | |
| 1118 | const tx = -eyeX; |
| 1119 | const ty = -eyeY; |
| 1120 | const tz = -eyeZ; |
| 1121 | |
| 1122 | this.cameraMatrix.translate([tx, ty, tz]); |
| 1123 | |
| 1124 | if (this._isActive()) { |
no test coverage detected