diff --git a/scripts/vr-edit/modules/createPalette.js b/scripts/vr-edit/modules/createPalette.js index 928cb48048..be9558e432 100644 --- a/scripts/vr-edit/modules/createPalette.js +++ b/scripts/vr-edit/modules/createPalette.js @@ -21,8 +21,6 @@ CreatePalette = function (side, leftInputs, rightInputs) { cubeHighlightOverlay, LEFT_HAND = 0, - AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}", - ZERO_ROTATION = Quat.fromVec3Radians(Vec3.ZERO), controlJointName, @@ -37,7 +35,7 @@ CreatePalette = function (side, leftInputs, rightInputs) { localRotation: PALETTE_ROOT_ROTATION, color: { red: 255, blue: 0, green: 0 }, alpha: 1.0, - parentID: AVATAR_SELF_ID, + parentID: Uuid.SELF, ignoreRayIntersection: true, visible: false }, @@ -45,7 +43,7 @@ CreatePalette = function (side, leftInputs, rightInputs) { PALETTE_PANEL_PROPERTIES = { dimensions: { x: CANVAS_SIZE.x, y: CANVAS_SIZE.y, z: 0.001 }, localPosition: { x: CANVAS_SIZE.x / 2, y: CANVAS_SIZE.y / 2, z: 0 }, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, color: { red: 192, green: 192, blue: 192 }, alpha: 0.3, solid: true, @@ -56,7 +54,7 @@ CreatePalette = function (side, leftInputs, rightInputs) { CUBE_PROPERTIES = { dimensions: { x: 0.03, y: 0.03, z: 0.03 }, localPosition: { x: 0.02, y: 0.02, z: 0.0 }, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, color: { red: 240, green: 0, blue: 0 }, alpha: 1.0, solid: true, @@ -67,7 +65,7 @@ CreatePalette = function (side, leftInputs, rightInputs) { CUBE_HIGHLIGHT_PROPERTIES = { dimensions: { x: 0.034, y: 0.034, z: 0.034 }, localPosition: { x: 0.02, y: 0.02, z: 0.0 }, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, color: { red: 240, green: 240, blue: 0 }, alpha: 0.8, solid: false, diff --git a/scripts/vr-edit/modules/groups.js b/scripts/vr-edit/modules/groups.js index 39217c8a76..036df1a71c 100644 --- a/scripts/vr-edit/modules/groups.js +++ b/scripts/vr-edit/modules/groups.js @@ -106,8 +106,7 @@ Groups = function () { childrenIDs, childrenIDIndexes, i, - count, - NULL_UUID = "{00000000-0000-0000-0000-000000000000}"; + count; // Compile information on children. rootID = groupRootEntityIDs[0]; @@ -124,7 +123,7 @@ Groups = function () { // Unlink direct children from root entity. for (i = 0, count = childrenIDs.length; i < count; i += 1) { Entities.editEntity(childrenIDs[i], { - parentID: NULL_UUID + parentID: Uuid.NULL }); } @@ -132,7 +131,7 @@ Groups = function () { groupRootEntityIDs = groupRootEntityIDs.concat(childrenIDs); for (i = 0, count = childrenIDs.length; i < count; i += 1) { groupSelectionDetails.push(groupSelectionDetails[0].slice(childrenIDIndexes[i], childrenIDIndexes[i + 1])); - groupSelectionDetails[i + 1][0].parentID = NULL_UUID; + groupSelectionDetails[i + 1][0].parentID = Uuid.NULL; } groupSelectionDetails[0].splice(1, groupSelectionDetails[0].length - childrenIDIndexes[0]); } diff --git a/scripts/vr-edit/modules/handles.js b/scripts/vr-edit/modules/handles.js index b9390b02d3..e32918160a 100644 --- a/scripts/vr-edit/modules/handles.js +++ b/scripts/vr-edit/modules/handles.js @@ -38,7 +38,6 @@ Handles = function (side) { FACE_HANDLE_OVERLAY_OFFSETS, FACE_HANDLE_OVERLAY_ROTATIONS, FACE_HANDLE_OVERLAY_SCALE_AXES, - ZERO_ROTATION = Quat.fromVec3Radians(Vec3.ZERO), DISTANCE_MULTIPLIER_MULTIPLIER = 0.5, hoveredOverlayID = null, isVisible = false, @@ -154,7 +153,7 @@ Handles = function (side) { boundingBoxOverlay = Overlays.addOverlay("cube", { parentID: rootEntityID, localPosition: boundingBoxLocalCenter, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, dimensions: boundingBoxDimensions, color: BOUNDING_BOX_COLOR, alpha: BOUNDING_BOX_ALPHA, @@ -196,7 +195,7 @@ Handles = function (side) { parentID: rootEntityID, localPosition: Vec3.sum(boundingBoxLocalCenter, Vec3.multiplyVbyV(CORNER_HANDLE_OVERLAY_AXES[cornerIndexes[i]], boundingBoxDimensions)), - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, dimensions: cornerHandleDimensions, color: HANDLE_NORMAL_COLOR, alpha: HANDLE_NORMAL_ALPHA, diff --git a/scripts/vr-edit/modules/highlights.js b/scripts/vr-edit/modules/highlights.js index 6a0e789a0d..9f0dc44275 100644 --- a/scripts/vr-edit/modules/highlights.js +++ b/scripts/vr-edit/modules/highlights.js @@ -24,9 +24,7 @@ Highlights = function (side) { ENTITY_HIGHLIGHT_ALPHA = 0.8, HAND_HIGHLIGHT_DIMENSIONS = { x: 0.2, y: 0.2, z: 0.2 }, HAND_HIGHLIGHT_OFFSET = { x: 0.0, y: 0.11, z: 0.02 }, - LEFT_HAND = 0, - AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}", - ZERO_ROTATION = Quat.fromVec3Radians(Vec3.ZERO); + LEFT_HAND = 0; if (!this instanceof Highlights) { return new Highlights(); @@ -34,7 +32,7 @@ Highlights = function (side) { handOverlay = Overlays.addOverlay("sphere", { dimensions: HAND_HIGHLIGHT_DIMENSIONS, - parentID: AVATAR_SELF_ID, + parentID: Uuid.SELF, parentJointIndex: MyAvatar.getJointIndex(side === LEFT_HAND ? "_CONTROLLER_LEFTHAND" : "_CONTROLLER_RIGHTHAND"), @@ -64,7 +62,7 @@ Highlights = function (side) { Overlays.editOverlay(entityOverlays[index], { parentID: details.id, localPosition: offset, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, dimensions: details.dimensions, color: overlayColor, visible: true diff --git a/scripts/vr-edit/modules/laser.js b/scripts/vr-edit/modules/laser.js index fefa13b8ff..991c9173b6 100644 --- a/scripts/vr-edit/modules/laser.js +++ b/scripts/vr-edit/modules/laser.js @@ -46,7 +46,6 @@ Laser = function (side) { specifiedLaserLength = null, LEFT_HAND = 0, - AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}", uiEntityIDs = [], @@ -77,7 +76,7 @@ Laser = function (side) { glow: 1.0, ignoreRayIntersection: true, drawInFront: true, - parentID: AVATAR_SELF_ID, + parentID: Uuid.SELF, parentJointIndex: MyAvatar.getJointIndex(side === LEFT_HAND ? "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND" : "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND"), diff --git a/scripts/vr-edit/modules/toolIcon.js b/scripts/vr-edit/modules/toolIcon.js index 6eaf37e161..4f8f2da752 100644 --- a/scripts/vr-edit/modules/toolIcon.js +++ b/scripts/vr-edit/modules/toolIcon.js @@ -28,7 +28,6 @@ ToolIcon = function (side) { ], LEFT_HAND = 0, - AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}", ICON_DIMENSIONS = { x: 0.1, y: 0.01, z: 0.1 }, ICON_POSITION = { x: 0, y: 0.01, z: 0 }, @@ -41,7 +40,7 @@ ToolIcon = function (side) { localRotation: ICON_ROTATION, solid: true, alpha: 1.0, - parentID: AVATAR_SELF_ID, + parentID: Uuid.SELF, ignoreRayIntersection: false, visible: true }, diff --git a/scripts/vr-edit/modules/toolMenu.js b/scripts/vr-edit/modules/toolMenu.js index e98d38f3b7..3c5fab0e23 100644 --- a/scripts/vr-edit/modules/toolMenu.js +++ b/scripts/vr-edit/modules/toolMenu.js @@ -28,8 +28,6 @@ ToolMenu = function (side, leftInputs, rightInputs, commandCallback) { highlightOverlay, LEFT_HAND = 0, - AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}", - ZERO_ROTATION = Quat.fromVec3Radians(Vec3.ZERO), CANVAS_SIZE = { x: 0.22, y: 0.13 }, PANEL_ORIGIN_POSITION = { x: CANVAS_SIZE.x / 2, y: 0.15, z: -0.04 }, @@ -42,7 +40,7 @@ ToolMenu = function (side, leftInputs, rightInputs, commandCallback) { localRotation: PANEL_ROOT_ROTATION, color: { red: 255, blue: 0, green: 0 }, alpha: 1.0, - parentID: AVATAR_SELF_ID, + parentID: Uuid.SELF, ignoreRayIntersection: true, visible: false }, @@ -50,7 +48,7 @@ ToolMenu = function (side, leftInputs, rightInputs, commandCallback) { MENU_PANEL_PROPERTIES = { dimensions: { x: CANVAS_SIZE.x, y: CANVAS_SIZE.y, z: 0.01 }, localPosition: { x: CANVAS_SIZE.x / 2, y: CANVAS_SIZE.y / 2, z: 0.005 }, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, color: { red: 164, green: 164, blue: 164 }, alpha: 1.0, solid: true, @@ -63,7 +61,7 @@ ToolMenu = function (side, leftInputs, rightInputs, commandCallback) { overlay: "cube", properties: { dimensions: { x: 0.10, y: 0.12, z: 0.01 }, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, color: { red: 192, green: 192, blue: 192 }, alpha: 1.0, solid: true, @@ -75,7 +73,7 @@ ToolMenu = function (side, leftInputs, rightInputs, commandCallback) { overlay: "cube", properties: { dimensions: { x: 0.03, y: 0.03, z: 0.01 }, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, alpha: 1.0, solid: true, ignoreRayIntersection: false, @@ -176,7 +174,7 @@ ToolMenu = function (side, leftInputs, rightInputs, commandCallback) { zDimension: 0.001, properties: { localPosition: { x: 0, y: 0, z: -0.003 }, - localRotation: ZERO_ROTATION, + localRotation: Quat.ZERO, color: { red: 255, green: 255, blue: 0 }, alpha: 0.8, solid: false, diff --git a/scripts/vr-edit/utilities/utilities.js b/scripts/vr-edit/utilities/utilities.js index cbf8206750..62343c5436 100644 --- a/scripts/vr-edit/utilities/utilities.js +++ b/scripts/vr-edit/utilities/utilities.js @@ -20,15 +20,26 @@ if (typeof Vec3.max !== "function") { }; } +if (typeof Quat.ZERO !== "object") { + Quat.ZERO = Quat.fromVec3Radians(Vec3.ZERO); +} + +if (typeof Uuid.NULL !== "string") { + Uuid.NULL = "{00000000-0000-0000-0000-000000000000}"; +} + +if (typeof Uuid.SELF !== "string") { + Uuid.SELF = "{00000000-0000-0000-0000-000000000001}"; +} + if (typeof Entities.rootOf !== "function") { Entities.rootOf = function (entityID) { var rootEntityID, entityProperties, - PARENT_PROPERTIES = ["parentID"], - NULL_UUID = "{00000000-0000-0000-0000-000000000000}"; + PARENT_PROPERTIES = ["parentID"]; rootEntityID = entityID; entityProperties = Entities.getEntityProperties(rootEntityID, PARENT_PROPERTIES); - while (entityProperties.parentID && entityProperties.parentID !== NULL_UUID) { + while (entityProperties.parentID && entityProperties.parentID !== Uuid.NULL) { rootEntityID = entityProperties.parentID; entityProperties = Entities.getEntityProperties(rootEntityID, PARENT_PROPERTIES); } @@ -40,10 +51,9 @@ if (typeof Entities.hasEditableRoot !== "function") { Entities.hasEditableRoot = function (entityID) { var EDITIBLE_ENTITY_QUERY_PROPERTYES = ["parentID", "visible", "locked", "type"], NONEDITABLE_ENTITY_TYPES = ["Unknown", "Zone", "Light"], - NULL_UUID = "{00000000-0000-0000-0000-000000000000}", properties; properties = Entities.getEntityProperties(entityID, EDITIBLE_ENTITY_QUERY_PROPERTYES); - while (properties.parentID && properties.parentID !== NULL_UUID) { + while (properties.parentID && properties.parentID !== Uuid.NULL) { properties = Entities.getEntityProperties(properties.parentID, EDITIBLE_ENTITY_QUERY_PROPERTYES); } return properties.visible && !properties.locked && NONEDITABLE_ENTITY_TYPES.indexOf(properties.type) === -1; @@ -63,4 +73,3 @@ if (typeof Object.merge !== "function") { return JSON.parse(a.slice(0, -1) + "," + b.slice(1)); }; } -