From 81d615c9db3c65ef312edd02bfeb6c625c384836 Mon Sep 17 00:00:00 2001 From: Alexia Mandeville Date: Thu, 24 May 2018 17:36:29 -0700 Subject: [PATCH] Revert "Removing sit functionality from teleport" This reverts commit 36df9d7de86a067ef045c459403b7b5cb1041430. --- .../controllers/controllerModules/teleport.js | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/controllerModules/teleport.js b/scripts/system/controllers/controllerModules/teleport.js index 1dc7990f6e..560da57b20 100644 --- a/scripts/system/controllers/controllerModules/teleport.js +++ b/scripts/system/controllers/controllerModules/teleport.js @@ -23,6 +23,7 @@ Script.include("/~/system/libraries/controllers.js"); var TARGET_MODEL_URL = Script.resolvePath("../../assets/models/teleport-destination.fbx"); var TOO_CLOSE_MODEL_URL = Script.resolvePath("../../assets/models/teleport-cancel.fbx"); + var SEAT_MODEL_URL = Script.resolvePath("../../assets/models/teleport-seat.fbx"); var TARGET_MODEL_DIMENSIONS = { x: 1.15, @@ -30,6 +31,12 @@ Script.include("/~/system/libraries/controllers.js"); z: 1.15 }; + var COLORS_TELEPORT_SEAT = { + red: 255, + green: 0, + blue: 170 + }; + var COLORS_TELEPORT_CAN_TELEPORT = { red: 97, green: 247, @@ -72,6 +79,15 @@ Script.include("/~/system/libraries/controllers.js"); drawInFront: true, glow: 1.0 }; + var seatPath = { + type: "line3d", + color: COLORS_TELEPORT_SEAT, + ignoreRayIntersection: true, + alpha: 1, + solid: true, + drawInFront: true, + glow: 1.0 + }; var cancelEnd = { type: "model", url: TOO_CLOSE_MODEL_URL, @@ -84,10 +100,17 @@ Script.include("/~/system/libraries/controllers.js"); dimensions: TARGET_MODEL_DIMENSIONS, ignoreRayIntersection: true }; + var seatEnd = { + type: "model", + url: SEAT_MODEL_URL, + dimensions: TARGET_MODEL_DIMENSIONS, + ignoreRayIntersection: true + }; var teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, - {name: "teleport", path: teleportPath, end: teleportEnd}]; + {name: "teleport", path: teleportPath, end: teleportEnd}, + {name: "seat", path: seatPath, end: seatEnd}]; var DEFAULT_DISTANCE = 50; var teleportDefaultRenderStates = [{name: "cancel", distance: DEFAULT_DISTANCE, path: cancelPath}]; @@ -108,6 +131,7 @@ Script.include("/~/system/libraries/controllers.js"); INVISIBLE: 'invisible', // The current target is an invvsible surface INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.) SURFACE: 'surface', // The current target is a valid surface + SEAT: 'seat' // The current target is a seat }; function Teleporter(hand) { @@ -195,9 +219,11 @@ Script.include("/~/system/libraries/controllers.js"); if (!Vec3.equal(AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS, cancelEnd.dimensions)) { cancelEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; teleportEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; + seatEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, - {name: "teleport", path: teleportPath, end: teleportEnd}]; + {name: "teleport", path: teleportPath, end: teleportEnd}, + {name: "seat", path: seatPath, end: seatEnd}]; Pointers.editRenderState(this.teleportRayHandVisible, "cancel", teleportRenderStates[0]); Pointers.editRenderState(this.teleportRayHandInvisible, "cancel", teleportRenderStates[0]); @@ -209,6 +235,10 @@ Script.include("/~/system/libraries/controllers.js"); Pointers.editRenderState(this.teleportRayHeadVisible, "teleport", teleportRenderStates[1]); Pointers.editRenderState(this.teleportRayHeadInvisible, "teleport", teleportRenderStates[1]); + Pointers.editRenderState(this.teleportRayHandVisible, "seat", teleportRenderStates[2]); + Pointers.editRenderState(this.teleportRayHandInvisible, "seat", teleportRenderStates[2]); + Pointers.editRenderState(this.teleportRayHeadVisible, "seat", teleportRenderStates[2]); + Pointers.editRenderState(this.teleportRayHeadInvisible, "seat", teleportRenderStates[2]); } }; @@ -276,6 +306,8 @@ Script.include("/~/system/libraries/controllers.js"); } else { this.setTeleportState(mode, "teleport", ""); } + } else if (teleportLocationType === TARGET.SEAT) { + this.setTeleportState(mode, "", "seat"); } return this.teleport(result, teleportLocationType); }; @@ -288,6 +320,8 @@ Script.include("/~/system/libraries/controllers.js"); if (target === TARGET.NONE || target === TARGET.INVALID || this.state === TELEPORTER_STATES.COOL_IN) { // Do nothing + } else if (target === TARGET.SEAT) { + Entities.callEntityMethod(result.objectID, 'sit'); } else if (target === TARGET.SURFACE) { var offset = getAvatarFootOffset(); result.intersection.y += offset; @@ -375,6 +409,14 @@ Script.include("/~/system/libraries/controllers.js"); var props = Entities.getEntityProperties(result.objectID, ['userData', 'visible']); var data = parseJSON(props.userData); + if (data !== undefined && data.seat !== undefined) { + var avatarUuid = Uuid.fromString(data.seat.user); + if (Uuid.isNull(avatarUuid) || !AvatarList.getAvatar(avatarUuid).sessionUUID) { + return TARGET.SEAT; + } else { + return TARGET.INVALID; + } + } if (!props.visible) { return TARGET.INVISIBLE;