MCPcopy Index your code
hub / github.com/processing/p5.js / move

Method move

src/webgl/p5.Camera.js:1202–1222  ·  view source on GitHub ↗

* Moves the camera along its "local" axes without changing its orientation. * * The parameters, `x`, `y`, and `z`, are the distances the camera should * move. For example, calling `myCamera.move(10, 20, 30)` moves the camera 10 * pixels to the right, 20 pixels down, and 30 pixels backwar

(x, y, z)

Source from the content-addressed store, hash-verified

1200 * }
1201 */
1202 move(x, y, z) {
1203 const local = this._getLocalAxes();
1204
1205 // scale local axes by movement amounts
1206 // based on http://learnwebgl.brown37.net/07_cameras/camera_linear_motion.html
1207 const dx = [local.x[0] * x, local.x[1] * x, local.x[2] * x];
1208 const dy = [local.y[0] * y, local.y[1] * y, local.y[2] * y];
1209 const dz = [local.z[0] * z, local.z[1] * z, local.z[2] * z];
1210
1211 this.camera(
1212 this.eyeX + dx[0] + dy[0] + dz[0],
1213 this.eyeY + dx[1] + dy[1] + dz[1],
1214 this.eyeZ + dx[2] + dy[2] + dz[2],
1215 this.centerX + dx[0] + dy[0] + dz[0],
1216 this.centerY + dx[1] + dy[1] + dz[1],
1217 this.centerZ + dx[2] + dy[2] + dz[2],
1218 this.upX,
1219 this.upY,
1220 this.upZ
1221 );
1222 }
1223
1224 /**
1225 * Sets the camera’s position in "world" space without changing its

Callers

nothing calls this directly

Calls 2

_getLocalAxesMethod · 0.95
cameraMethod · 0.95

Tested by

no test coverage detected