* Sets the camera’s position, orientation, and projection by copying another * camera. * * The parameter, `cam`, is the `p5.Camera` object to copy. For example, calling * `cam2.set(cam1)` will set `cam2` using `cam1`’s configuration. * * @param {p5.Camera} cam camera to copy. *
(cam)
| 1424 | * } |
| 1425 | */ |
| 1426 | set(cam) { |
| 1427 | const keyNamesOfThePropToCopy = [ |
| 1428 | 'eyeX', 'eyeY', 'eyeZ', |
| 1429 | 'centerX', 'centerY', 'centerZ', |
| 1430 | 'upX', 'upY', 'upZ', |
| 1431 | 'cameraFOV', 'aspectRatio', 'cameraNear', 'cameraFar', 'cameraType', |
| 1432 | 'yScale', 'useLinePerspective' |
| 1433 | ]; |
| 1434 | for (const keyName of keyNamesOfThePropToCopy) { |
| 1435 | this[keyName] = cam[keyName]; |
| 1436 | } |
| 1437 | |
| 1438 | this.cameraMatrix = cam.cameraMatrix.copy(); |
| 1439 | this.projMatrix = cam.projMatrix.copy(); |
| 1440 | |
| 1441 | if (this._isActive()) { |
| 1442 | this._renderer.states.setValue('uModelMatrix', this._renderer.states.uModelMatrix.clone()); |
| 1443 | this._renderer.states.setValue('uViewMatrix', this._renderer.states.uViewMatrix.clone()); |
| 1444 | this._renderer.states.setValue('uPMatrix', this._renderer.states.uPMatrix.clone()); |
| 1445 | this._renderer.states.uModelMatrix.reset(); |
| 1446 | this._renderer.states.uViewMatrix.set(this.cameraMatrix); |
| 1447 | this._renderer.states.uPMatrix.set(this.projMatrix); |
| 1448 | } |
| 1449 | } |
| 1450 | /** |
| 1451 | * Sets the camera’s position and orientation to values that are in-between |
| 1452 | * those of two other cameras. |
no test coverage detected