From 510eb08be1ea332daf34fc0d6aea52094da1fdef Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Tue, 1 Dec 2020 22:56:17 -0500 Subject: [PATCH] Replace Overlays by Local Entities 1- Replace Overlays by Local Entities 2- Add the missing header with copyright and license (I have assumed that the author was the same person that make the grid parameter that is referenced there and only used in create App.) 3- Minor requested code change (0.0 instead of 0 in condition using real numbers) --- scripts/system/libraries/gridTool.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/system/libraries/gridTool.js b/scripts/system/libraries/gridTool.js index 90a6745ff4..1dbe1fea4c 100644 --- a/scripts/system/libraries/gridTool.js +++ b/scripts/system/libraries/gridTool.js @@ -1,3 +1,12 @@ +// gridTool.js +// +// Created by Ryan Huffman on 6 Nov 2014 +// Copyright 2014 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// /* global keyUpEventFromUIWindow */ var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html'); @@ -16,18 +25,19 @@ Grid = function() { var snapToGrid = false; - var gridOverlay = Overlays.addOverlay("grid", { + var gridEntityTool = Entities.addEntity({ + type: "Grid", rotation: Quat.fromPitchYawRollDegrees(90, 0, 0), dimensions: { x: scale, y: scale, z: scale }, position: origin, visible: false, - drawInFront: false, + renderLayer: "world", color: gridColor, alpha: gridAlpha, minorGridEvery: minorGridEvery, majorGridEvery: majorGridEvery, ignorePickIntersection: true - }); + }, "local"); that.visible = false; that.enabled = false; @@ -166,7 +176,7 @@ Grid = function() { that.moveToAvatar = function() { var position = MyAvatar.getJointPosition("LeftFoot"); - if (position.x === 0 && position.y === 0 && position.z === 0) { + if (position.x === 0.0 && position.y === 0.0 && position.z === 0.0) { position = MyAvatar.position; } that.setPosition(position); @@ -222,7 +232,7 @@ Grid = function() { }; function updateGrid(noUpdate) { - Overlays.editOverlay(gridOverlay, { + Entities.editEntity(gridEntityTool, { position: { x: 0, y: origin.y, z: 0 }, visible: that.visible && that.enabled, minorGridEvery: minorGridEvery, @@ -230,6 +240,7 @@ Grid = function() { color: gridColor, alpha: gridAlpha }); + if (!noUpdate) { that.emitUpdate(); @@ -237,7 +248,7 @@ Grid = function() { } function cleanup() { - Overlays.deleteOverlay(gridOverlay); + Entities.deleteEntity(gridEntityTool); } that.addListener = function(callback) {