this.scene.withEntity(targetId, function(target) { var targetPosition = target.get('Position'); var myPosition = self.position; var direction = vec3.create([0,0,0]); vec3.subtract(targetPosition, myPosition, direction); var rotation = Math.atan2(direction[0], -direction[1]); self.parent.dispatch('rotateTo', [rotation]); });
var Camera = function(settings, aspectRatio, fieldOfView) { this.aspectRatio = aspectRatio; this.fieldOfView = fieldOfView; this.centre = vec3.create([0,0,0]); this.distance = 125.0; this.settings = settings; this.width = 0; this.height = 0; if(this.settings) { this.settings.on('updated', this.updateFromSettings, this); this.updateFromSettings() } };
var Tangible = function(x, y, width, height) { this.position = vec3.create([x,y,0]); this.size = vec3.create([width, width, height]); this.rotation = 0; };