Code review in radar.js

This commit is contained in:
Gabriel Calero 2018-05-09 18:20:19 -03:00
parent 7ee067de35
commit e0b57a2228

View file

@ -346,9 +346,9 @@ function pinchUpdate(event) {
} }
Camera.position = { Camera.position = {
x: Camera.position.x, x : Camera.position.x,
y:radarHeight, y : radarHeight,
z:Camera.position.z z : Camera.position.z
}; };
if (!draggingCamera) { if (!draggingCamera) {
@ -360,7 +360,7 @@ function pinchUpdate(event) {
} }
function isInsideSquare(coords0, coords1, halfside) { function isInsideSquare(coords0, coords1, halfside) {
return coords0 != undefined && coords1!= undefined && return coords0 != undefined && coords1 != undefined &&
Math.abs(coords0.x - coords1.x) <= halfside Math.abs(coords0.x - coords1.x) <= halfside
&& Math.abs(coords0.y - coords1.y) <= halfside; && Math.abs(coords0.y - coords1.y) <= halfside;
} }
@ -372,7 +372,7 @@ function dragScrollUpdate(event) {
// drag management // drag management
var pickRay = Camera.computePickRay(event.x, event.y); var pickRay = Camera.computePickRay(event.x, event.y);
var dragAt = Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, var dragAt = Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction,
radarHeight-MyAvatar.position.y)); radarHeight - MyAvatar.position.y));
if (lastDragAt === undefined || lastDragAt === null) { if (lastDragAt === undefined || lastDragAt === null) {
lastDragAt = dragAt; lastDragAt = dragAt;
@ -1082,29 +1082,20 @@ function renderAllOthersAvatarIcons() {
} }
} }
/*******************************************************************************
* Entities (to remark) cache structure for showing entities markers
******************************************************************************/
var ICON_ENTITY_DEFAULT_DIMENSIONS = { var ICON_ENTITY_DEFAULT_DIMENSIONS = {
x : 0.10, x : 0.10,
y : 0.00001, y : 0.00001,
z : 0.10 z : 0.10
}; };
var entityIconModelDimensionsVal = {
x : 0,
y : 0.00001,
z : 0
};
function teleportIconModelDimensions(y) { function teleportIconModelDimensions(y) {
// given the current height, give a size var teleportModelDimensions = ICON_ENTITY_DEFAULT_DIMENSIONS;
// TODO: receive entity.position.y and substract to radarHeight
var xz = -0.002831 * (radarHeight - y) + 0.1; var xz = -0.002831 * (radarHeight - y) + 0.1;
entityIconModelDimensionsVal.x = xz; teleportModelDimensions.x = xz;
entityIconModelDimensionsVal.z = xz; teleportModelDimensions.z = xz;
// reuse object // reuse object
return entityIconModelDimensionsVal; return teleportModelDimensions;
} }
/******************************************************************************* /*******************************************************************************