Revert "Removing sit functionality from teleport"

This reverts commit 36df9d7de8.
This commit is contained in:
Alexia Mandeville 2018-05-24 17:36:29 -07:00
parent 36df9d7de8
commit 81d615c9db

View file

@ -23,6 +23,7 @@ Script.include("/~/system/libraries/controllers.js");
var TARGET_MODEL_URL = Script.resolvePath("../../assets/models/teleport-destination.fbx"); var TARGET_MODEL_URL = Script.resolvePath("../../assets/models/teleport-destination.fbx");
var TOO_CLOSE_MODEL_URL = Script.resolvePath("../../assets/models/teleport-cancel.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 = { var TARGET_MODEL_DIMENSIONS = {
x: 1.15, x: 1.15,
@ -30,6 +31,12 @@ Script.include("/~/system/libraries/controllers.js");
z: 1.15 z: 1.15
}; };
var COLORS_TELEPORT_SEAT = {
red: 255,
green: 0,
blue: 170
};
var COLORS_TELEPORT_CAN_TELEPORT = { var COLORS_TELEPORT_CAN_TELEPORT = {
red: 97, red: 97,
green: 247, green: 247,
@ -72,6 +79,15 @@ Script.include("/~/system/libraries/controllers.js");
drawInFront: true, drawInFront: true,
glow: 1.0 glow: 1.0
}; };
var seatPath = {
type: "line3d",
color: COLORS_TELEPORT_SEAT,
ignoreRayIntersection: true,
alpha: 1,
solid: true,
drawInFront: true,
glow: 1.0
};
var cancelEnd = { var cancelEnd = {
type: "model", type: "model",
url: TOO_CLOSE_MODEL_URL, url: TOO_CLOSE_MODEL_URL,
@ -84,10 +100,17 @@ Script.include("/~/system/libraries/controllers.js");
dimensions: TARGET_MODEL_DIMENSIONS, dimensions: TARGET_MODEL_DIMENSIONS,
ignoreRayIntersection: true ignoreRayIntersection: true
}; };
var seatEnd = {
type: "model",
url: SEAT_MODEL_URL,
dimensions: TARGET_MODEL_DIMENSIONS,
ignoreRayIntersection: true
};
var teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, 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 DEFAULT_DISTANCE = 50;
var teleportDefaultRenderStates = [{name: "cancel", distance: DEFAULT_DISTANCE, path: cancelPath}]; 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 INVISIBLE: 'invisible', // The current target is an invvsible surface
INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.) INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.)
SURFACE: 'surface', // The current target is a valid surface SURFACE: 'surface', // The current target is a valid surface
SEAT: 'seat' // The current target is a seat
}; };
function Teleporter(hand) { function Teleporter(hand) {
@ -195,9 +219,11 @@ Script.include("/~/system/libraries/controllers.js");
if (!Vec3.equal(AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS, cancelEnd.dimensions)) { if (!Vec3.equal(AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS, cancelEnd.dimensions)) {
cancelEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; cancelEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS;
teleportEnd.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}, 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.teleportRayHandVisible, "cancel", teleportRenderStates[0]);
Pointers.editRenderState(this.teleportRayHandInvisible, "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.teleportRayHeadVisible, "teleport", teleportRenderStates[1]);
Pointers.editRenderState(this.teleportRayHeadInvisible, "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 { } else {
this.setTeleportState(mode, "teleport", ""); this.setTeleportState(mode, "teleport", "");
} }
} else if (teleportLocationType === TARGET.SEAT) {
this.setTeleportState(mode, "", "seat");
} }
return this.teleport(result, teleportLocationType); 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) { if (target === TARGET.NONE || target === TARGET.INVALID || this.state === TELEPORTER_STATES.COOL_IN) {
// Do nothing // Do nothing
} else if (target === TARGET.SEAT) {
Entities.callEntityMethod(result.objectID, 'sit');
} else if (target === TARGET.SURFACE) { } else if (target === TARGET.SURFACE) {
var offset = getAvatarFootOffset(); var offset = getAvatarFootOffset();
result.intersection.y += offset; result.intersection.y += offset;
@ -375,6 +409,14 @@ Script.include("/~/system/libraries/controllers.js");
var props = Entities.getEntityProperties(result.objectID, ['userData', 'visible']); var props = Entities.getEntityProperties(result.objectID, ['userData', 'visible']);
var data = parseJSON(props.userData); 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) { if (!props.visible) {
return TARGET.INVISIBLE; return TARGET.INVISIBLE;