* Rotate this renderable towards the given target. * @param {Renderable|Vector2d|Vector3d} target - the renderable or position to look at * @returns {Renderable} Reference to this object for method chaining
(target)
| 685 | * @returns {Renderable} Reference to this object for method chaining |
| 686 | */ |
| 687 | lookAt(target) { |
| 688 | let position; |
| 689 | |
| 690 | if (target instanceof Renderable) { |
| 691 | position = target.pos; |
| 692 | } else { |
| 693 | position = target; |
| 694 | } |
| 695 | |
| 696 | const angle = this.angleTo(position); |
| 697 | |
| 698 | this.rotate(angle); |
| 699 | |
| 700 | return this; |
| 701 | } |
| 702 | |
| 703 | /** |
| 704 | * Rotate this renderable by the specified angle (in radians). |