MCPcopy Create free account
hub / github.com/melonjs/melonJS / lookAt

Method lookAt

packages/melonjs/src/renderable/renderable.js:687–701  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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).

Callers

nothing calls this directly

Calls 2

angleToMethod · 0.95
rotateMethod · 0.95

Tested by

no test coverage detected