mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 23:26:25 +02:00
Merge pull request #8939 from huffman/fix/tutorial-fixes
Tutorial fixes
This commit is contained in:
commit
c41af25776
15 changed files with 514 additions and 196 deletions
|
@ -31,14 +31,24 @@ function resolveHardware(path) {
|
|||
return resolveInner(Controller.Hardware, parts, 0);
|
||||
}
|
||||
|
||||
var DEBUG = true;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("controllerDisplay.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
createControllerDisplay = function(config) {
|
||||
var controllerDisplay = {
|
||||
overlays: [],
|
||||
partOverlays: {},
|
||||
parts: {},
|
||||
mappingName: "mapping-display",
|
||||
mappingName: "mapping-display-" + Math.random(),
|
||||
|
||||
setVisible: function(visible) {
|
||||
debug("Setting visible", this.overlays.length);
|
||||
for (var i = 0; i < this.overlays.length; ++i) {
|
||||
Overlays.editOverlay(this.overlays[i], {
|
||||
visible: visible
|
||||
|
@ -166,7 +176,7 @@ createControllerDisplay = function(config) {
|
|||
} else if (part.type === "static") {
|
||||
// do nothing
|
||||
} else {
|
||||
print("TYPE NOT SUPPORTED: ", part.type);
|
||||
debug("TYPE NOT SUPPORTED: ", part.type);
|
||||
}
|
||||
|
||||
controllerDisplay.overlays.push(overlayID);
|
||||
|
|
|
@ -69,7 +69,6 @@ ControllerDisplayManager = function() {
|
|||
}
|
||||
}
|
||||
|
||||
Messages.subscribe('Controller-Display');
|
||||
var handleMessages = function(channel, message, sender) {
|
||||
var i, data, name, visible;
|
||||
if (!controllerLeft && !controllerRight) {
|
||||
|
|
|
@ -62,6 +62,7 @@ var TIP_TEXTURE_BASE_URL = BASE_URL + "meshes/controller/vive_tips.fbm/";
|
|||
|
||||
var viveModelURL = BASE_URL + "meshes/controller/vive_body.fbx";
|
||||
var viveTipsModelURL = BASE_URL + "meshes/controller/vive_tips.fbx";
|
||||
var viveTriggerModelURL = "meshes/controller/vive_trigger.fbx"
|
||||
|
||||
VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
||||
name: "Vive",
|
||||
|
@ -86,7 +87,7 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
defaultTextureLayer: "blank",
|
||||
textureLayers: {
|
||||
blank: {
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "Blank.png"
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Blank.png"
|
||||
},
|
||||
trigger: {
|
||||
defaultTextureURL: TIP_TEXTURE_BASE_URL + "/Trigger.png"
|
||||
|
@ -141,7 +142,18 @@ VIVE_CONTROLLER_CONFIGURATION_LEFT = {
|
|||
minValue: 0.0,
|
||||
maxValue: 1.0,
|
||||
axis: { x: -1, y: 0, z: 0 },
|
||||
maxAngle: 20
|
||||
maxAngle: 25,
|
||||
|
||||
textureName: "Tex.black-trigger",
|
||||
defaultTextureLayer: "normal",
|
||||
textureLayers: {
|
||||
normal: {
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/black.jpg",
|
||||
},
|
||||
highlight: {
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/yellow.jpg",
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
l_grip: {
|
||||
|
@ -262,7 +274,18 @@ VIVE_CONTROLLER_CONFIGURATION_RIGHT = {
|
|||
minValue: 0.0,
|
||||
maxValue: 1.0,
|
||||
axis: { x: -1, y: 0, z: 0 },
|
||||
maxAngle: 25
|
||||
maxAngle: 25,
|
||||
|
||||
textureName: "Tex.black-trigger",
|
||||
defaultTextureLayer: "normal",
|
||||
textureLayers: {
|
||||
normal: {
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/black.jpg",
|
||||
},
|
||||
highlight: {
|
||||
defaultTextureURL: BASE_URL + viveTriggerModelURL + "/Trigger.fbm/yellow.jpg",
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
l_grip: {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
birdFirework1 = {
|
||||
"clientOnly": 0,
|
||||
"collisionsWillMove": 1,
|
||||
"created": "2016-09-13T23:05:08Z",
|
||||
"dimensions": {
|
||||
"x": 0.10120716691017151,
|
||||
"y": 0.12002291530370712,
|
||||
"z": 0.18833979964256287
|
||||
},
|
||||
fireworkURLs = [
|
||||
"atp:/tutorial_models/bomb1.fbx",
|
||||
"atp:/tutorial_models/bomb2.fbx",
|
||||
"atp:/tutorial_models/bomb3.fbx",
|
||||
"atp:/tutorial_models/bomb4.fbx",
|
||||
"atp:/tutorial_models/bomb5.fbx",
|
||||
"atp:/tutorial_models/bomb6.fbx",
|
||||
];
|
||||
|
||||
fireworkBaseProps = {
|
||||
"collisionsWillMove": 1,
|
||||
velocity: {
|
||||
x: 0,
|
||||
|
@ -20,7 +21,7 @@ birdFirework1 = {
|
|||
"z": 0
|
||||
},
|
||||
"id": "{1c4061bc-b2e7-4435-bc47-3fcc39ae6624}",
|
||||
"modelURL": "atp:/tutorial_models/birdStatue15.fbx",
|
||||
"modelURL": "atp:/tutorial_models/bomb1.fbx",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0.11612319946289062,
|
||||
|
@ -44,15 +45,8 @@ birdFirework1 = {
|
|||
"userData": "{\n \"hifiHomeKey\": {\n \"reset\": true\n }\n}"
|
||||
} ;
|
||||
|
||||
|
||||
birdFirework2 = {
|
||||
"clientOnly": 0,
|
||||
"collisionsWillMove": 1,
|
||||
"created": "2016-09-12T22:56:48Z",
|
||||
"dimensions": {
|
||||
"x": 0.098819166421890259,
|
||||
"y": 0.11143554747104645,
|
||||
"z": 0.18833979964256287
|
||||
},
|
||||
"collisionsWillMove": 1,
|
||||
velocity: {
|
||||
x: 0,
|
||||
|
@ -66,7 +60,7 @@ birdFirework2 = {
|
|||
"z": 0
|
||||
},
|
||||
"id": "{ba067084-8d0f-4eeb-a8a1-c6814527c1bb}",
|
||||
"modelURL": "atp:/tutorial_models/statuebird4.fbx",
|
||||
"modelURL": "atp:/tutorial_models/bomb2.fbx",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0,
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
(function() {
|
||||
|
||||
function debug() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("fire.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
|
||||
var _this = this;
|
||||
|
||||
function Fire() {
|
||||
|
@ -54,30 +60,45 @@
|
|||
|
||||
var colors = [RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET];
|
||||
|
||||
var firePitSoundURL = Script.resolvePath("fire_burst.wav");
|
||||
debug("Firepit burst sound url is: ", firePitSoundURL);
|
||||
|
||||
var explodeTextureURL = Script.resolvePath("explode.png");
|
||||
debug("Firepit explode texture url is: ", explodeTextureURL);
|
||||
|
||||
Fire.prototype = {
|
||||
preload: function(entityID) {
|
||||
debug("Preload");
|
||||
this.entityID = entityID;
|
||||
this.EXPLOSION_SOUND = SoundCache.getSound("atp:/firepit/fire_burst.wav");
|
||||
this.EXPLOSION_SOUND = SoundCache.getSound(firePitSoundURL);
|
||||
},
|
||||
collisionWithEntity: function(myID, otherID, collisionInfo) {
|
||||
debug("Collided with entity: ", myID, otherID);
|
||||
var otherProps = Entities.getEntityProperties(otherID);
|
||||
var data = null;
|
||||
try {
|
||||
data = JSON.parse(otherProps.userData)
|
||||
data = JSON.parse(otherProps.userData);
|
||||
} catch (err) {
|
||||
print('ERROR GETTING USERDATA!');
|
||||
debug('ERROR GETTING USERDATA!');
|
||||
}
|
||||
if (data === null || "") {
|
||||
debug("Data is null or empty", data);
|
||||
return;
|
||||
} else {
|
||||
debug("Got data", data);
|
||||
if (data.hasOwnProperty('hifiHomeKey')) {
|
||||
debug("Has hifiHomeKey");
|
||||
if (data.hifiHomeKey.reset === true) {
|
||||
debug("Reset is true");
|
||||
_this.playSoundAtCurrentPosition();
|
||||
_this.explodeWithColor();
|
||||
Entities.deleteEntity(otherID)
|
||||
debug("Sending local message");
|
||||
Messages.sendLocalMessage('Entity-Exploded', JSON.stringify({
|
||||
entityID: otherID,
|
||||
position: Entities.getEntityProperties(this.entityID).position
|
||||
}));
|
||||
debug("Done sending local message");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +158,7 @@
|
|||
"alphaStart": -0.2,
|
||||
"alphaFinish": 0.5,
|
||||
"emitterShouldTrail": 0,
|
||||
"textures": "atp:/firepit/explode.png",
|
||||
"textures": explodeTextureURL,
|
||||
"type": "ParticleEffect",
|
||||
lifetime: 1,
|
||||
position: myProps.position
|
||||
|
|
|
@ -11,13 +11,17 @@
|
|||
(function() {
|
||||
Script.include('utils.js');
|
||||
|
||||
var DEBUG = false;
|
||||
var DEBUG = true;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(self, arguments);
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("fuse.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
var active = false;
|
||||
|
||||
var fuseSound = SoundCache.getSound("atp:/tutorial_sounds/fuse.wav");
|
||||
function getChildProperties(entityID, propertyNames) {
|
||||
var childEntityIDs = Entities.getChildrenIDs(entityID);
|
||||
|
@ -33,12 +37,20 @@
|
|||
};
|
||||
Fuse.prototype = {
|
||||
light: function() {
|
||||
debug("LIT", this.entityID);
|
||||
var anim = Entities.getEntityProperties(this.entityID, ['animation']).animation;
|
||||
debug("Received light()", this.entityID);
|
||||
|
||||
if (anim.currentFrame < 140) {
|
||||
var visible = Entities.getEntityProperties(this.entityID, ['visible']).visible;
|
||||
if (!visible) {
|
||||
debug("Fuse is not visible, returning");
|
||||
return;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
debug("Fuse is active, returning");
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
|
||||
Entities.editEntity(this.entityID, {
|
||||
animation: {
|
||||
currentFrame: 1,
|
||||
|
@ -56,6 +68,7 @@
|
|||
|
||||
var childrenProps = getChildProperties(this.entityID, ['type']);
|
||||
for (var childEntityID in childrenProps) {
|
||||
debug("Updating: ", childEntityID);
|
||||
var props = childrenProps[childEntityID];
|
||||
if (props.type == "ParticleEffect") {
|
||||
Entities.editEntity(childEntityID, {
|
||||
|
@ -70,13 +83,14 @@
|
|||
|
||||
var self = this;
|
||||
Script.setTimeout(function() {
|
||||
debug("BLOW UP");
|
||||
var spinnerID = Utils.findEntity({ name: "tutorial/equip/spinner" }, 20);
|
||||
debug("Setting off fireworks");
|
||||
var spinnerID = "{dd13fcd5-616f-4749-ab28-2e1e8bc512e9}";
|
||||
Entities.callEntityMethod(spinnerID, "onLit");
|
||||
injector.stop();
|
||||
|
||||
var childrenProps = getChildProperties(self.entityID, ['type']);
|
||||
for (var childEntityID in childrenProps) {
|
||||
debug("Updating: ", childEntityID);
|
||||
var props = childrenProps[childEntityID];
|
||||
if (props.type == "ParticleEffect") {
|
||||
Entities.editEntity(childEntityID, {
|
||||
|
@ -90,8 +104,14 @@
|
|||
}
|
||||
|
||||
}, 4900);
|
||||
|
||||
Script.setTimeout(function() {
|
||||
debug("Setting fuse to inactive");
|
||||
active = false;
|
||||
}, 14000);
|
||||
},
|
||||
preload: function(entityID) {
|
||||
debug("Preload");
|
||||
this.entityID = entityID;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
};
|
||||
Fuse.prototype = {
|
||||
onLit: function() {
|
||||
print("LIT", this.entityID);
|
||||
var fuseID = Utils.findEntity({ name: "tutorial/equip/fuse" }, 20);
|
||||
print("fuseCollider.js | Lit", this.entityID);
|
||||
var fuseID = "{c8944a13-9acb-4d77-b1ee-851845e98357}"
|
||||
Entities.callEntityMethod(fuseID, "light");
|
||||
},
|
||||
preload: function(entityID) {
|
||||
print("fuseCollider.js | preload");
|
||||
this.entityID = entityID;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -53,33 +53,39 @@ createButaneLighter = function(transform) {
|
|||
shapeType: 'simple-compound',
|
||||
type: 'Model',
|
||||
userData: JSON.stringify({
|
||||
tag: "equip-temporary",
|
||||
grabbableKey: {
|
||||
invertSolidWhileHeld: true
|
||||
"tag": "equip-temporary",
|
||||
"grabbableKey": {
|
||||
"invertSolidWhileHeld": true
|
||||
},
|
||||
wearable: {
|
||||
joints: {
|
||||
RightHand: [{
|
||||
x: 0.029085848480463028,
|
||||
y: 0.09807153046131134,
|
||||
z: 0.03062543272972107
|
||||
}, {
|
||||
x: 0.5929139256477356,
|
||||
y: 0.3207578659057617,
|
||||
z: 0.7151655554771423,
|
||||
w: -0.18468326330184937
|
||||
}],
|
||||
LeftHand: [{
|
||||
x: -0.029085848480463028,
|
||||
y: 0.09807153046131134,
|
||||
z: 0.03062543272972107
|
||||
}, {
|
||||
x: -0.5929139256477356,
|
||||
y: 0.3207578659057617,
|
||||
z: 0.7151655554771423,
|
||||
w: -0.18468326330184937
|
||||
}]
|
||||
}
|
||||
"wearable": {
|
||||
"joints": {
|
||||
"RightHand": [
|
||||
{
|
||||
"x": 0.049671292304992676,
|
||||
"y": 0.09825992584228516,
|
||||
"z": 0.03760027885437012
|
||||
},
|
||||
{
|
||||
"x": 0.6562752723693848,
|
||||
"y": 0.27598991990089417,
|
||||
"z": 0.6638742685317993,
|
||||
"w": -0.22890058159828186
|
||||
}
|
||||
],
|
||||
"LeftHand": [
|
||||
{
|
||||
"x": -0.028073370456695557,
|
||||
"y": 0.09609812498092651,
|
||||
"z": 0.039550721645355225
|
||||
},
|
||||
{
|
||||
"x": -0.6697965264320374,
|
||||
"y": 0.22050897777080536,
|
||||
"z": 0.6544681191444397,
|
||||
"w": 0.27283111214637756
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}),
|
||||
script: SCRIPT_URL
|
||||
|
|
|
@ -81,7 +81,6 @@ var TOKEN_STATE_OWNED = 2;
|
|||
|
||||
OwnershipToken = function(name, parentEntityID, options) {
|
||||
this.name = MyAvatar.sessionUUID + "-" + Math.floor(Math.random() * 10000000);
|
||||
this.name = Math.floor(Math.random() * 10000000);
|
||||
this.parentEntityID = parentEntityID;
|
||||
|
||||
// How often to check whether the token is available if we don't currently own it
|
||||
|
@ -160,7 +159,7 @@ OwnershipToken.prototype = {
|
|||
var ownerID = getOwnershipTokenID(this.parentEntityID);
|
||||
if (ownerID !== null) {
|
||||
// Already owned, return
|
||||
debug(this.name, "Token already owned by another client, return");
|
||||
debug(this.name, "Token already owned by another client, returning. Owner: " + owenerID + ", Us: " + this.name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,3 +184,5 @@ OwnershipToken.prototype = {
|
|||
Script.setTimeout(checkOwnershipRequest.bind(this), 2000);
|
||||
},
|
||||
};
|
||||
|
||||
debug("Returning from ownershipToken");
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
//
|
||||
|
||||
(function() {
|
||||
var DEBUG = false;
|
||||
var DEBUG = true;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(self, arguments);
|
||||
print.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
|||
}
|
||||
Spinner.prototype = {
|
||||
onLit: function() {
|
||||
debug("LIT SPINNER", this.entityID);
|
||||
debug("spinner.js | Spinner lit");
|
||||
Entities.editEntity(this.entityID, {
|
||||
"angularDamping": 0.1,
|
||||
"angularVelocity": {
|
||||
|
@ -50,6 +50,7 @@
|
|||
for (var childEntityID in childrenProps) {
|
||||
var props = childrenProps[childEntityID];
|
||||
if (props.type == "ParticleEffect") {
|
||||
debug("spinner.js | Modifying: ", childEntityID);
|
||||
Entities.editEntity(childEntityID, {
|
||||
emitRate: 35,
|
||||
});
|
||||
|
@ -59,13 +60,14 @@
|
|||
|
||||
var self = this;
|
||||
Script.setTimeout(function() {
|
||||
debug("BLOW UP");
|
||||
debug("spinner.js | Finishing spinner");
|
||||
injector.stop();
|
||||
|
||||
var childrenProps = getChildProperties(self.entityID, ['type']);
|
||||
for (var childEntityID in childrenProps) {
|
||||
var props = childrenProps[childEntityID];
|
||||
if (props.type == "ParticleEffect") {
|
||||
debug("spinner.js | Modifying: ", childEntityID);
|
||||
Entities.editEntity(childEntityID, {
|
||||
emitRate: 0,
|
||||
});
|
||||
|
@ -74,6 +76,7 @@
|
|||
}, 4900);
|
||||
},
|
||||
preload: function(entityID) {
|
||||
debug("spinner.js | Preload");
|
||||
this.entityID = entityID;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ if (!Function.prototype.bind) {
|
|||
|
||||
if (this.prototype) {
|
||||
// Function.prototype doesn't have a prototype property
|
||||
fNOP.prototype = this.prototype;
|
||||
fNOP.prototype = this.prototype;
|
||||
}
|
||||
fBound.prototype = new fNOP();
|
||||
|
||||
|
@ -40,26 +40,36 @@ if (!Function.prototype.bind) {
|
|||
};
|
||||
}
|
||||
|
||||
var DEBUG = false;
|
||||
var DEBUG = true;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(this, arguments);
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("tutorial.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
var INFO = true;
|
||||
function info() {
|
||||
if (INFO) {
|
||||
print.apply(this, arguments);
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("tutorial.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
// Return a number between min (inclusive) and max (exclusive)
|
||||
function randomInt(min, max) {
|
||||
return min + Math.floor(Math.random() * (max - min))
|
||||
}
|
||||
|
||||
var NEAR_BOX_SPAWN_NAME = "tutorial/nearGrab/box_spawn";
|
||||
var FAR_BOX_SPAWN_NAME = "tutorial/farGrab/box_spawn";
|
||||
var GUN_SPAWN_NAME = "tutorial/gun_spawn";
|
||||
var TELEPORT_PAD_NAME = "tutorial/teleport/pad"
|
||||
|
||||
var successSound = SoundCache.getSound("atp:/tutorial_sounds/good_one.L.wav");
|
||||
var firecrackerSound = SoundCache.getSound("atp:/tutorial_sounds/Pops_Firecracker.wav");
|
||||
|
||||
|
||||
var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable";
|
||||
|
@ -106,14 +116,6 @@ findEntities = function(properties, searchRadius, filterFn) {
|
|||
return matchedEntities;
|
||||
}
|
||||
|
||||
function setControllerVisible(name, visible) {
|
||||
return;
|
||||
Messages.sendLocalMessage('Controller-Display', JSON.stringify({
|
||||
name: name,
|
||||
visible: visible,
|
||||
}));
|
||||
}
|
||||
|
||||
function setControllerPartsVisible(parts) {
|
||||
Messages.sendLocalMessage('Controller-Display-Parts', JSON.stringify(parts));
|
||||
}
|
||||
|
@ -191,12 +193,17 @@ function deleteEntitiesWithTag(tag) {
|
|||
}
|
||||
}
|
||||
function editEntitiesWithTag(tag, propertiesOrFn) {
|
||||
var entityIDs = findEntitiesWithTag(tag);
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
if (isFunction(propertiesOrFn)) {
|
||||
Entities.editEntity(entityIDs[i], propertiesOrFn(entityIDs[i]));
|
||||
} else {
|
||||
Entities.editEntity(entityIDs[i], propertiesOrFn);
|
||||
var entities = TUTORIAL_TAG_TO_ENTITY_IDS_MAP[tag];
|
||||
|
||||
debug("Editing tag: ", tag);
|
||||
if (entities) {
|
||||
for (entityID in entities) {
|
||||
debug("Editing: ", entityID, ", ", propertiesOrFn, ", Is in local tree: ", isEntityInLocalTree(entityID));
|
||||
if (isFunction(propertiesOrFn)) {
|
||||
Entities.editEntity(entityID, propertiesOrFn(entityIDs[i]));
|
||||
} else {
|
||||
Entities.editEntity(entityID, propertiesOrFn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +212,7 @@ function findEntitiesWithTag(tag) {
|
|||
return findEntities({ userData: "" }, 10000, function(properties, key, value) {
|
||||
data = parseJSON(value);
|
||||
return data.tag == tag;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// From http://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascript-variable-is-function-type
|
||||
|
@ -222,21 +229,30 @@ function playSuccessSound() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
function playFirecrackerSound(position) {
|
||||
Audio.playSound(firecrackerSound, {
|
||||
position: position,
|
||||
volume: 0.7,
|
||||
loop: false
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// STEP: DISABLE CONTROLLERS //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
var stepDisableControllers = function(name) {
|
||||
var stepStart = function(name) {
|
||||
this.tag = name;
|
||||
this.shouldLog = false;
|
||||
}
|
||||
stepDisableControllers.prototype = {
|
||||
stepStart.prototype = {
|
||||
start: function(onFinish) {
|
||||
HMD.requestShowHandControllers();
|
||||
disableEverything();
|
||||
|
||||
HMD.requestShowHandControllers();
|
||||
|
||||
onFinish();
|
||||
},
|
||||
cleanup: function() {
|
||||
|
@ -258,6 +274,7 @@ function disableEverything() {
|
|||
setControllerPartLayer('tips', 'blank');
|
||||
|
||||
hideEntitiesWithTag('finish');
|
||||
|
||||
setAwayEnabled(false);
|
||||
}
|
||||
|
||||
|
@ -275,7 +292,6 @@ function reenableEverything() {
|
|||
setControllerPartLayer('touchpad', 'blank');
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
MyAvatar.shouldRenderLocally = true;
|
||||
HMD.requestHideHandControllers();
|
||||
setAwayEnabled(true);
|
||||
}
|
||||
|
||||
|
@ -293,6 +309,7 @@ var stepEnableControllers = function(name) {
|
|||
stepEnableControllers.prototype = {
|
||||
start: function(onFinish) {
|
||||
reenableEverything();
|
||||
HMD.requestHideHandControllers();
|
||||
onFinish();
|
||||
},
|
||||
cleanup: function() {
|
||||
|
@ -340,13 +357,11 @@ stepOrient.prototype = {
|
|||
var tag = this.tag;
|
||||
|
||||
// Spawn content set
|
||||
debug("raise hands...", this.tag);
|
||||
editEntitiesWithTag(this.tag, { visible: true });
|
||||
|
||||
|
||||
this.checkIntervalID = null;
|
||||
function checkForHandsAboveHead() {
|
||||
debug("Orient: Checking for hands above head...");
|
||||
debug("Orient | Checking for hands above head");
|
||||
if (MyAvatar.getLeftPalmPosition().y > (MyAvatar.getHeadPosition().y + 0.1)) {
|
||||
Script.clearInterval(this.checkIntervalID);
|
||||
this.checkIntervalID = null;
|
||||
|
@ -359,6 +374,7 @@ stepOrient.prototype = {
|
|||
this.checkIntervalID = Script.setInterval(checkForHandsAboveHead.bind(this), 500);
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("Orient | Cleanup");
|
||||
if (this.active) {
|
||||
this.active = false;
|
||||
}
|
||||
|
@ -394,13 +410,12 @@ stepRaiseAboveHead.prototype = {
|
|||
var STATE_HANDS_UP = 2;
|
||||
this.state = STATE_START;
|
||||
|
||||
debug("raise hands...", this.tag);
|
||||
editEntitiesWithTag(this.tag, { visible: true });
|
||||
|
||||
// Wait 2 seconds before starting to check for hands
|
||||
this.checkIntervalID = null;
|
||||
function checkForHandsAboveHead() {
|
||||
debug("Raise above head: Checking hands...");
|
||||
debug("RaiseAboveHead | Checking hands");
|
||||
if (this.state == STATE_START) {
|
||||
if (MyAvatar.getLeftPalmPosition().y < (MyAvatar.getHeadPosition().y - 0.1)) {
|
||||
this.state = STATE_HANDS_DOWN;
|
||||
|
@ -418,6 +433,7 @@ stepRaiseAboveHead.prototype = {
|
|||
this.checkIntervalID = Script.setInterval(checkForHandsAboveHead.bind(this), 500);
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("RaiseAboveHead | Cleanup");
|
||||
if (this.checkIntervalID) {
|
||||
Script.clearInterval(this.checkIntervalID);
|
||||
this.checkIntervalID = null
|
||||
|
@ -451,30 +467,26 @@ stepNearGrab.prototype = {
|
|||
this.finished = false;
|
||||
this.onFinish = onFinish;
|
||||
|
||||
setControllerVisible("trigger", true);
|
||||
setControllerPartLayer('tips', 'trigger');
|
||||
setControllerPartLayer('trigger', 'highlight');
|
||||
var tag = this.tag;
|
||||
|
||||
// Spawn content set
|
||||
showEntitiesWithTag(this.tag, { visible: true });
|
||||
showEntitiesWithTag('bothGrab', { visible: true });
|
||||
|
||||
var boxSpawnID = findEntity({ name: NEAR_BOX_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
info("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
var boxSpawnPosition = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
function createBlock() {
|
||||
//Step1BlockData.position = boxSpawnPosition;
|
||||
birdFirework1.position = boxSpawnPosition;
|
||||
return spawnWithTag([birdFirework1], null, this.tempTag)[0];
|
||||
var boxSpawnPosition = getEntityWithName(NEAR_BOX_SPAWN_NAME).position;
|
||||
function createBlock(fireworkNumber) {
|
||||
fireworkBaseProps.position = boxSpawnPosition;
|
||||
fireworkBaseProps.modelURL = fireworkURLs[fireworkNumber % fireworkURLs.length];
|
||||
debug("Creating firework with url: ", fireworkBaseProps.modelURL);
|
||||
return spawnWithTag([fireworkBaseProps], null, this.tempTag)[0];
|
||||
}
|
||||
|
||||
this.birdIDs = [];
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)(0));
|
||||
this.birdIDs.push(createBlock.bind(this)(1));
|
||||
this.birdIDs.push(createBlock.bind(this)(2));
|
||||
this.positionWatcher = new PositionWatcher(this.birdIDs, boxSpawnPosition, -0.4, 4);
|
||||
},
|
||||
onMessage: function(channel, message, seneder) {
|
||||
|
@ -482,10 +494,12 @@ stepNearGrab.prototype = {
|
|||
return;
|
||||
}
|
||||
if (channel == "Entity-Exploded") {
|
||||
debug("TUTORIAL: Got entity-exploded message");
|
||||
debug("NearGrab | Got entity-exploded message: ", message);
|
||||
|
||||
var data = parseJSON(message);
|
||||
if (this.birdIDs.indexOf(data.entityID) >= 0) {
|
||||
debug("NearGrab | It's one of the firecrackers");
|
||||
playFirecrackerSound(data.position);
|
||||
playSuccessSound();
|
||||
this.finished = true;
|
||||
this.onFinish();
|
||||
|
@ -493,10 +507,10 @@ stepNearGrab.prototype = {
|
|||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("cleaning up near grab");
|
||||
debug("NearGrab | Cleanup");
|
||||
this.finished = true;
|
||||
setControllerVisible("trigger", false);
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
setControllerPartLayer('trigger', 'normal');
|
||||
hideEntitiesWithTag(this.tag, { visible: false});
|
||||
deleteEntitiesWithTag(this.tempTag);
|
||||
if (this.positionWatcher) {
|
||||
|
@ -530,8 +544,8 @@ stepFarGrab.prototype = {
|
|||
|
||||
showEntitiesWithTag('bothGrab', { visible: true });
|
||||
|
||||
setControllerVisible("trigger", true);
|
||||
setControllerPartLayer('tips', 'trigger');
|
||||
setControllerPartLayer('trigger', 'highlight');
|
||||
Messages.sendLocalMessage('Hifi-Grab-Disable', JSON.stringify({
|
||||
farGrabEnabled: true,
|
||||
}));
|
||||
|
@ -540,21 +554,18 @@ stepFarGrab.prototype = {
|
|||
// Spawn content set
|
||||
showEntitiesWithTag(this.tag);
|
||||
|
||||
var boxSpawnID = findEntity({ name: FAR_BOX_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
debug("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
var boxSpawnPosition = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
function createBlock() {
|
||||
birdFirework1.position = boxSpawnPosition;
|
||||
return spawnWithTag([birdFirework1], null, this.tempTag)[0];
|
||||
var boxSpawnPosition = getEntityWithName(FAR_BOX_SPAWN_NAME).position;
|
||||
function createBlock(fireworkNumber) {
|
||||
fireworkBaseProps.position = boxSpawnPosition;
|
||||
fireworkBaseProps.modelURL = fireworkURLs[fireworkNumber % fireworkURLs.length];
|
||||
debug("Creating firework with url: ", fireworkBaseProps.modelURL);
|
||||
return spawnWithTag([fireworkBaseProps], null, this.tempTag)[0];
|
||||
}
|
||||
|
||||
this.birdIDs = [];
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)(3));
|
||||
this.birdIDs.push(createBlock.bind(this)(4));
|
||||
this.birdIDs.push(createBlock.bind(this)(5));
|
||||
this.positionWatcher = new PositionWatcher(this.birdIDs, boxSpawnPosition, -0.4, 4);
|
||||
},
|
||||
onMessage: function(channel, message, seneder) {
|
||||
|
@ -562,9 +573,11 @@ stepFarGrab.prototype = {
|
|||
return;
|
||||
}
|
||||
if (channel == "Entity-Exploded") {
|
||||
debug("TUTORIAL: Got entity-exploded message");
|
||||
debug("FarGrab | Got entity-exploded message: ", message);
|
||||
var data = parseJSON(message);
|
||||
if (this.birdIDs.indexOf(data.entityID) >= 0) {
|
||||
debug("FarGrab | It's one of the firecrackers");
|
||||
playFirecrackerSound(data.position);
|
||||
playSuccessSound();
|
||||
this.finished = true;
|
||||
this.onFinish();
|
||||
|
@ -572,9 +585,10 @@ stepFarGrab.prototype = {
|
|||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("FarGrab | Cleanup");
|
||||
this.finished = true;
|
||||
setControllerVisible("trigger", false);
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
setControllerPartLayer('trigger', 'normal');
|
||||
hideEntitiesWithTag(this.tag, { visible: false});
|
||||
hideEntitiesWithTag('bothGrab', { visible: false});
|
||||
deleteEntitiesWithTag(this.tempTag);
|
||||
|
@ -586,12 +600,13 @@ stepFarGrab.prototype = {
|
|||
};
|
||||
|
||||
function PositionWatcher(entityIDs, originalPosition, minY, maxDistance) {
|
||||
debug("Creating position watcher");
|
||||
this.watcherIntervalID = Script.setInterval(function() {
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
var entityID = entityIDs[i];
|
||||
var props = Entities.getEntityProperties(entityID, ['position']);
|
||||
if (props.position.y < minY || Vec3.distance(originalPosition, props.position) > maxDistance) {
|
||||
Entities.editEntity(entityID, {
|
||||
Entities.editEntity(entityID, {
|
||||
position: originalPosition,
|
||||
velocity: { x: 0, y: -0.01, z: 0 },
|
||||
angularVelocity: { x: 0, y: 0, z: 0 }
|
||||
|
@ -603,6 +618,7 @@ function PositionWatcher(entityIDs, originalPosition, minY, maxDistance) {
|
|||
|
||||
PositionWatcher.prototype = {
|
||||
destroy: function() {
|
||||
debug("Destroying position watcher");
|
||||
Script.clearInterval(this.watcherIntervalID);
|
||||
}
|
||||
};
|
||||
|
@ -630,8 +646,8 @@ var stepEquip = function(name) {
|
|||
}
|
||||
stepEquip.prototype = {
|
||||
start: function(onFinish) {
|
||||
setControllerVisible("trigger", true);
|
||||
setControllerPartLayer('tips', 'trigger');
|
||||
setControllerPartLayer('trigger', 'highlight');
|
||||
Messages.sendLocalMessage('Hifi-Grab-Disable', JSON.stringify({
|
||||
holdEnabled: true,
|
||||
}));
|
||||
|
@ -644,40 +660,41 @@ stepEquip.prototype = {
|
|||
|
||||
this.currentPart = this.PART1;
|
||||
|
||||
function createGun() {
|
||||
var boxSpawnID = findEntity({ name: GUN_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
info("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
|
||||
function createLighter() {
|
||||
var transform = {};
|
||||
|
||||
transform.position = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
transform.rotation = Entities.getEntityProperties(boxSpawnID, 'rotation').rotation;
|
||||
var boxSpawnProps = getEntityWithName(GUN_SPAWN_NAME);
|
||||
transform.position = boxSpawnProps.position;
|
||||
transform.rotation = boxSpawnProps.rotation;
|
||||
transform.velocity = { x: 0, y: -0.01, z: 0 };
|
||||
transform.angularVelocity = { x: 0, y: 0, z: 0 };
|
||||
this.spawnTransform = transform;
|
||||
return doCreateButaneLighter(transform).id;
|
||||
}
|
||||
|
||||
|
||||
this.gunID = createGun.bind(this)();
|
||||
this.startWatchingGun();
|
||||
debug("Created", this.gunID);
|
||||
this.lighterID = createLighter.bind(this)();
|
||||
this.startWatchingLighter();
|
||||
debug("Created lighter", this.lighterID);
|
||||
this.onFinish = onFinish;
|
||||
},
|
||||
startWatchingGun: function() {
|
||||
startWatchingLighter: function() {
|
||||
if (!this.watcherIntervalID) {
|
||||
debug("Starting to watch lighter position");
|
||||
this.watcherIntervalID = Script.setInterval(function() {
|
||||
var props = Entities.getEntityProperties(this.gunID, ['position']);
|
||||
if (props.position.y < -0.4
|
||||
debug("Checking lighter position");
|
||||
var props = Entities.getEntityProperties(this.lighterID, ['position']);
|
||||
if (props.position.y < -0.4
|
||||
|| Vec3.distance(this.spawnTransform.position, props.position) > 4) {
|
||||
Entities.editEntity(this.gunID, this.spawnTransform);
|
||||
debug("Moving lighter back to table");
|
||||
Entities.editEntity(this.lighterID, this.spawnTransform);
|
||||
}
|
||||
}.bind(this), 1000);
|
||||
}
|
||||
},
|
||||
stopWatchingGun: function() {
|
||||
if (this.watcherIntervalID) {
|
||||
debug("Stopping watch of lighter position");
|
||||
Script.clearInterval(this.watcherIntervalID);
|
||||
this.watcherIntervalID = null;
|
||||
}
|
||||
|
@ -687,24 +704,28 @@ stepEquip.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
debug("Got message", channel, message, sender, MyAvatar.sessionUUID);
|
||||
debug("Equip | Got message", channel, message, sender, MyAvatar.sessionUUID);
|
||||
|
||||
if (channel == "Tutorial-Spinner") {
|
||||
if (this.currentPart == this.PART1 && message == "wasLit") {
|
||||
this.currentPart = this.PART2;
|
||||
debug("Equip | Starting part 2");
|
||||
Script.setTimeout(function() {
|
||||
debug("Equip | Starting part 3");
|
||||
this.currentPart = this.PART3;
|
||||
hideEntitiesWithTag(this.tagPart1);
|
||||
showEntitiesWithTag(this.tagPart2);
|
||||
setControllerPartLayer('trigger', 'normal');
|
||||
setControllerPartLayer('tips', 'grip');
|
||||
Messages.subscribe('Hifi-Object-Manipulation');
|
||||
debug("Equip | Finished starting part 3");
|
||||
}.bind(this), 9000);
|
||||
}
|
||||
} else if (channel == "Hifi-Object-Manipulation") {
|
||||
if (this.currentPart == this.PART3) {
|
||||
var data = parseJSON(message);
|
||||
if (data.action == 'release' && data.grabbedEntity == this.gunID) {
|
||||
info("got release");
|
||||
if (data.action == 'release' && data.grabbedEntity == this.lighterID) {
|
||||
debug("Equip | Got release, finishing step");
|
||||
this.stopWatchingGun();
|
||||
this.currentPart = this.COMPLETE;
|
||||
playSuccessSound();
|
||||
|
@ -714,13 +735,14 @@ stepEquip.prototype = {
|
|||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("Equip | Got yaw action");
|
||||
if (this.watcherIntervalID) {
|
||||
Script.clearInterval(this.watcherIntervalID);
|
||||
this.watcherIntervalID = null;
|
||||
}
|
||||
|
||||
setControllerVisible("trigger", false);
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
setControllerPartLayer('trigger', 'normal');
|
||||
this.stopWatchingGun();
|
||||
this.currentPart = this.COMPLETE;
|
||||
|
||||
|
@ -752,9 +774,6 @@ var stepTurnAround = function(name) {
|
|||
}
|
||||
stepTurnAround.prototype = {
|
||||
start: function(onFinish) {
|
||||
setControllerVisible("left", true);
|
||||
setControllerVisible("right", true);
|
||||
|
||||
setControllerPartLayer('touchpad', 'arrows');
|
||||
setControllerPartLayer('tips', 'arrows');
|
||||
|
||||
|
@ -764,8 +783,9 @@ stepTurnAround.prototype = {
|
|||
Controller.actionEvent.connect(this.onActionBound);
|
||||
|
||||
this.interval = Script.setInterval(function() {
|
||||
var FORWARD_THRESHOLD = 30;
|
||||
var REQ_NUM_TIMES_PRESSED = 6;
|
||||
debug("TurnAround | Checking if finished", this.numTimesTurnPressed);
|
||||
var FORWARD_THRESHOLD = 90;
|
||||
var REQ_NUM_TIMES_PRESSED = 3;
|
||||
|
||||
var dir = Quat.getFront(MyAvatar.orientation);
|
||||
var angle = Math.atan2(dir.z, dir.x);
|
||||
|
@ -782,18 +802,17 @@ stepTurnAround.prototype = {
|
|||
onAction: function(action, value) {
|
||||
var STEP_YAW_ACTION = 6;
|
||||
if (action == STEP_YAW_ACTION && value != 0) {
|
||||
debug("TurnAround | Got yaw action");
|
||||
this.numTimesTurnPressed += 1;
|
||||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("TurnAround | Cleanup");
|
||||
try {
|
||||
Controller.actionEvent.disconnect(this.onActionBound);
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
setControllerVisible("left", false);
|
||||
setControllerVisible("right", false);
|
||||
|
||||
setControllerPartLayer('touchpad', 'blank');
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
|
||||
|
@ -826,22 +845,21 @@ stepTeleport.prototype = {
|
|||
Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'none');
|
||||
|
||||
// Wait until touching teleport pad...
|
||||
var padID = findEntity({ name: TELEPORT_PAD_NAME }, 100);
|
||||
var padProps = Entities.getEntityProperties(padID, ["position", "dimensions"]);
|
||||
var padProps = getEntityWithName(TELEPORT_PAD_NAME);
|
||||
var xMin = padProps.position.x - padProps.dimensions.x / 2;
|
||||
var xMax = padProps.position.x + padProps.dimensions.x / 2;
|
||||
var zMin = padProps.position.z - padProps.dimensions.z / 2;
|
||||
var zMax = padProps.position.z + padProps.dimensions.z / 2;
|
||||
function checkCollides() {
|
||||
debug("Checking if on pad...");
|
||||
debug("Teleport | Checking if on pad...");
|
||||
|
||||
var pos = MyAvatar.position;
|
||||
|
||||
debug('x', pos.x, xMin, xMax);
|
||||
debug('z', pos.z, zMin, zMax);
|
||||
debug('Teleport | x', pos.x, xMin, xMax);
|
||||
debug('Teleport | z', pos.z, zMin, zMax);
|
||||
|
||||
if (pos.x > xMin && pos.x < xMax && pos.z > zMin && pos.z < zMax) {
|
||||
debug("On teleport pad");
|
||||
debug("Teleport | On teleport pad");
|
||||
Script.clearInterval(this.checkCollidesTimer);
|
||||
this.checkCollidesTimer = null;
|
||||
playSuccessSound();
|
||||
|
@ -853,6 +871,7 @@ stepTeleport.prototype = {
|
|||
showEntitiesWithTag(this.tag);
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("Teleport | Cleanup");
|
||||
setControllerPartLayer('touchpad', 'blank');
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
|
||||
|
@ -903,6 +922,10 @@ stepCleanupFinish.prototype = {
|
|||
|
||||
|
||||
|
||||
function isEntityInLocalTree(entityID) {
|
||||
return Entities.getEntityProperties(entityID, 'visible').visible !== undefined;
|
||||
}
|
||||
|
||||
function showEntitiesWithTag(tag) {
|
||||
var entities = TUTORIAL_TAG_TO_ENTITY_IDS_MAP[tag];
|
||||
if (entities) {
|
||||
|
@ -921,6 +944,7 @@ function showEntitiesWithTag(tag) {
|
|||
collisionless: collisionless,
|
||||
userData: JSON.stringify(data),
|
||||
};
|
||||
debug("Showing: ", entityID, ", Is in local tree: ", isEntityInLocalTree(entityID));
|
||||
Entities.editEntity(entityID, newProperties);
|
||||
}
|
||||
}
|
||||
|
@ -945,6 +969,7 @@ function showEntitiesWithTag(tag) {
|
|||
Entities.editEntity(entityID, newProperties);
|
||||
});
|
||||
}
|
||||
|
||||
function hideEntitiesWithTag(tag) {
|
||||
var entities = TUTORIAL_TAG_TO_ENTITY_IDS_MAP[tag];
|
||||
if (entities) {
|
||||
|
@ -960,6 +985,8 @@ function hideEntitiesWithTag(tag) {
|
|||
ignoreForCollisions: 1,
|
||||
userData: JSON.stringify(data),
|
||||
};
|
||||
|
||||
debug("Hiding: ", entityID, ", Is in local tree: ", isEntityInLocalTree(entityID));
|
||||
Entities.editEntity(entityID, newProperties);
|
||||
}
|
||||
}
|
||||
|
@ -982,6 +1009,15 @@ function hideEntitiesWithTag(tag) {
|
|||
});
|
||||
}
|
||||
|
||||
// Return the entity properties for an entity with a given name if it is in our
|
||||
// cached list of entities. Otherwise, return undefined.
|
||||
function getEntityWithName(name) {
|
||||
debug("Getting entity with name:", name);
|
||||
var entityID = TUTORIAL_NAME_TO_ENTITY_PROPERTIES_MAP[name];
|
||||
debug("Entity id: ", entityID, ", Is in local tree: ", isEntityInLocalTree(entityID));
|
||||
return entityID;
|
||||
}
|
||||
|
||||
|
||||
TutorialManager = function() {
|
||||
var STEPS;
|
||||
|
@ -998,9 +1034,9 @@ TutorialManager = function() {
|
|||
currentStep = null;
|
||||
startedTutorialAt = Date.now();
|
||||
STEPS = [
|
||||
new stepDisableControllers("step0"),
|
||||
new stepStart("start"),
|
||||
new stepOrient("orient"),
|
||||
new stepRaiseAboveHead("raiseHands"),
|
||||
//new stepRaiseAboveHead("raiseHands"),
|
||||
new stepNearGrab("nearGrab"),
|
||||
new stepFarGrab("farGrab"),
|
||||
new stepEquip("equip"),
|
||||
|
@ -1017,6 +1053,7 @@ TutorialManager = function() {
|
|||
}
|
||||
|
||||
this.onFinish = function() {
|
||||
debug("onFinish", currentStepNum);
|
||||
if (currentStep && currentStep.shouldLog !== false) {
|
||||
var timeToFinishStep = (Date.now() - startedLastStepAt) / 1000;
|
||||
var tutorialTimeElapsed = (Date.now() - startedTutorialAt) / 1000;
|
||||
|
@ -1059,6 +1096,7 @@ TutorialManager = function() {
|
|||
this.stopTutorial = function() {
|
||||
if (currentStep) {
|
||||
currentStep.cleanup();
|
||||
HMD.requestHideHandControllers();
|
||||
}
|
||||
reenableEverything();
|
||||
currentStepNum = -1;
|
||||
|
|
|
@ -83,7 +83,7 @@ TUTORIAL_TAG_TO_ENTITY_IDS_MAP = {
|
|||
}
|
||||
},
|
||||
"equip-part2": {
|
||||
"{8b92eec5-aeed-4368-bce0-432cc9ad4c51}": {
|
||||
"{b5d17eda-90ab-40cf-b973-efcecb2e992e}": {
|
||||
"tag": "equip-part2"
|
||||
},
|
||||
"{6307cd16-dd1d-4988-a339-578178436b45}": {
|
||||
|
@ -148,4 +148,168 @@ TUTORIAL_TAG_TO_ENTITY_IDS_MAP = {
|
|||
"tag": "orient"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TUTORIAL_NAME_TO_ENTITY_PROPERTIES_MAP = {
|
||||
"tutorial/gun_spawn": {
|
||||
"userData": "{\"tag\":\"equip\",\"visible\":false}",
|
||||
"dimensions": {
|
||||
"y": 0.0649842768907547,
|
||||
"x": 0.0649842768907547,
|
||||
"z": 0.0649842768907547
|
||||
},
|
||||
"collisionless": 1,
|
||||
"created": "2016-09-08T18:38:24Z",
|
||||
"color": {
|
||||
"blue": 0,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"queryAACube": {
|
||||
"y": 0.6283726096153259,
|
||||
"x": 0.6865367293357849,
|
||||
"scale": 0.11255607008934021,
|
||||
"z": 0.3359576463699341
|
||||
},
|
||||
"visible": 0,
|
||||
"shape": "Cube",
|
||||
"clientOnly": 0,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"y": 0.6846506595611572,
|
||||
"x": 0.7428147792816162,
|
||||
"z": 0.3922356963157654
|
||||
},
|
||||
"rotation": {
|
||||
"y": 0.7066605091094971,
|
||||
"x": 0.7066605091094971,
|
||||
"z": -0.025131583213806152,
|
||||
"w": -0.025101065635681152
|
||||
},
|
||||
"ignoreForCollisions": 1,
|
||||
"type": "Box",
|
||||
"id": "{9df518da-9e65-4b76-8a79-eeefdb0b7310}",
|
||||
"name": "tutorial/gun_spawn"
|
||||
},
|
||||
"tutorial/nearGrab/box_spawn": {
|
||||
"userData": "{\"tag\":\"nearGrab\",\"visible\":false}",
|
||||
"dimensions": {
|
||||
"y": 0.08225371688604355,
|
||||
"x": 0.08225371688604355,
|
||||
"z": 0.08225371688604355
|
||||
},
|
||||
"collisionless": 1,
|
||||
"created": "2016-09-08T18:38:24Z",
|
||||
"color": {
|
||||
"blue": 255,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"queryAACube": {
|
||||
"y": 0.738319456577301,
|
||||
"x": 0.8985498547554016,
|
||||
"scale": 0.14246761798858643,
|
||||
"z": 0.29067665338516235
|
||||
},
|
||||
"visible": 0,
|
||||
"shape": "Cube",
|
||||
"clientOnly": 0,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"y": 0.8095532655715942,
|
||||
"x": 0.9697836637496948,
|
||||
"z": 0.36191046237945557
|
||||
},
|
||||
"rotation": {
|
||||
"y": -1.52587890625e-05,
|
||||
"x": -1.52587890625e-05,
|
||||
"z": -1.52587890625e-05,
|
||||
"w": 1
|
||||
},
|
||||
"ignoreForCollisions": 1,
|
||||
"type": "Box",
|
||||
"id": "{5cf22b9c-fb22-4854-8821-554422980b24}",
|
||||
"name": "tutorial/nearGrab/box_spawn"
|
||||
},
|
||||
"tutorial/farGrab/box_spawn": {
|
||||
"userData": "{\"tag\":\"farGrab\",\"visible\":false}",
|
||||
"dimensions": {
|
||||
"y": 0.37358683347702026,
|
||||
"x": 0.37358683347702026,
|
||||
"z": 0.37358683347702026
|
||||
},
|
||||
"collisionless": 1,
|
||||
"created": "2016-09-08T18:38:24Z",
|
||||
"color": {
|
||||
"blue": 255,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"queryAACube": {
|
||||
"y": 0.3304251432418823,
|
||||
"x": 3.0951309204101562,
|
||||
"scale": 0.647071361541748,
|
||||
"z": 0.18027013540267944
|
||||
},
|
||||
"visible": 0,
|
||||
"shape": "Cube",
|
||||
"clientOnly": 0,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
x: 3.4866,
|
||||
y: 0.6716,
|
||||
z: 0.4789
|
||||
},
|
||||
"rotation": {
|
||||
"y": -1.52587890625e-05,
|
||||
"x": -1.52587890625e-05,
|
||||
"z": -1.52587890625e-05,
|
||||
"w": 1
|
||||
},
|
||||
"ignoreForCollisions": 1,
|
||||
"type": "Box",
|
||||
"id": "{70fcd96c-cd59-4f23-9ca5-a167f2f85680}",
|
||||
"name": "tutorial/farGrab/box_spawn"
|
||||
},
|
||||
"tutorial/teleport/pad": {
|
||||
"userData": "{\"tag\":\"teleport\"}",
|
||||
"rotation": {
|
||||
"y": -0.9702650308609009,
|
||||
"x": -2.1246911273919977e-05,
|
||||
"z": -4.222852112434339e-06,
|
||||
"w": 0.2420452982187271
|
||||
},
|
||||
"dimensions": {
|
||||
"y": 0.4365682601928711,
|
||||
"x": 2.1751723289489746,
|
||||
"z": 2.175173044204712
|
||||
},
|
||||
"collisionless": 1,
|
||||
"created": "2016-09-08T18:38:24Z",
|
||||
"queryAACube": {
|
||||
"y": -1.7979401350021362,
|
||||
"x": 7.5136213302612305,
|
||||
"scale": 3.106983184814453,
|
||||
"z": -1.4602710008621216
|
||||
},
|
||||
"visible": 0,
|
||||
"angularVelocity": {
|
||||
"y": -0.5235987901687622,
|
||||
"x": 0,
|
||||
"z": 0
|
||||
},
|
||||
"clientOnly": 0,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"angularDamping": 0,
|
||||
"position": {
|
||||
"y": -0.2444484978914261,
|
||||
"x": 9.067112922668457,
|
||||
"z": 0.09322060644626617
|
||||
},
|
||||
"modelURL": "atp:/alan/dev/Teleport-Pad.fbx",
|
||||
"ignoreForCollisions": 1,
|
||||
"type": "Model",
|
||||
"id": "{4478f7b5-d3ac-4213-9a7b-ad8cd69575b8}",
|
||||
"name": "tutorial/teleport/pad"
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
print("TutorialStartZone | Parent ID is: ", parentID);
|
||||
if (parentID) {
|
||||
print("TutorialStartZone | Sending start");
|
||||
Entities.callEntityMethod(parentID, 'start');
|
||||
Entities.callEntityMethod(parentID, 'onEnteredStartZone');
|
||||
} else {
|
||||
print("TutorialStartZone | ERROR: No parent id found on tutorial start zone");
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
|||
sendStart();
|
||||
} else {
|
||||
print("TutorialStartZone | User tried to go to tutorial with HMD and hand controllers, sending back to /");
|
||||
Window.alert("To proceed with this tutorial, please connect your VR headset and hand controllers.");
|
||||
Window.alert("To proceed with this tutorial, please connect your Vive headset and hand controllers.");
|
||||
location = "/";
|
||||
}
|
||||
},
|
||||
|
@ -38,6 +38,12 @@
|
|||
if (this.sendStartIntervalID) {
|
||||
Script.clearInterval(this.sendStartIntervalID);
|
||||
}
|
||||
var parentID = Entities.getEntityProperties(this.entityID, 'parentID').parentID;
|
||||
print("TutorialStartZone | Parent ID is: ", parentID);
|
||||
if (parentID) {
|
||||
print("TutorialStartZone | Sending onLeftStartZone");
|
||||
Entities.callEntityMethod(parentID, 'on');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -27,10 +27,14 @@ if (!Function.prototype.bind) {
|
|||
}
|
||||
|
||||
(function() {
|
||||
var ownershipTokenPath = Script.resolvePath("ownershipToken.js");
|
||||
var tutorialPath = Script.resolvePath("tutorial.js");
|
||||
Script.include(ownershipTokenPath);
|
||||
Script.include(tutorialPath);
|
||||
Script.include("ownershipToken.js");
|
||||
Script.include("tutorial.js");
|
||||
|
||||
var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable";
|
||||
function setAwayEnabled(value) {
|
||||
var message = value ? 'enable' : 'disable';
|
||||
Messages.sendLocalMessage(CHANNEL_AWAY_ENABLE, message);
|
||||
}
|
||||
|
||||
var TutorialZone = function() {
|
||||
print("TutorialZone | Creating");
|
||||
|
@ -59,11 +63,16 @@ if (!Function.prototype.bind) {
|
|||
print("TutorialZone | Preload");
|
||||
this.entityID = entityID;
|
||||
},
|
||||
start: function() {
|
||||
print("TutorialZone | Got start");
|
||||
onEnteredStartZone: function() {
|
||||
print("TutorialZone | Got onEnteredStartZone");
|
||||
var self = this;
|
||||
if (!this.token) {
|
||||
print("TutorialZone | Creating token");
|
||||
// The start zone has been entered, hide the overlays immediately
|
||||
setAwayEnabled(false);
|
||||
Menu.setIsOptionChecked("Overlays", false);
|
||||
MyAvatar.shouldRenderLocally = false;
|
||||
Toolbars.getToolbar("com.highfidelity.interface.toolbar.system").writeProperty("visible", false);
|
||||
this.token = new OwnershipToken(Math.random() * 100000, this.entityID, {
|
||||
onGainedOwnership: function(token) {
|
||||
print("TutorialZone | GOT OWNERSHIP");
|
||||
|
@ -91,6 +100,18 @@ if (!Function.prototype.bind) {
|
|||
});
|
||||
}
|
||||
},
|
||||
onLeftStartZone: function() {
|
||||
print("TutorialZone | Got onLeftStartZone");
|
||||
|
||||
// If the start zone was exited, and the tutorial hasn't started, go ahead and
|
||||
// re-enable the HUD/Overlays
|
||||
if (!this.tutorialManager) {
|
||||
Menu.setIsOptionChecked("Overlays", true);
|
||||
MyAvatar.shouldRenderLocally = true;
|
||||
setAwayEnabled(true);
|
||||
Toolbars.getToolbar("com.highfidelity.interface.toolbar.system").writeProperty("visible", true);
|
||||
}
|
||||
},
|
||||
|
||||
enterEntity: function() {
|
||||
print("TutorialZone | ENTERED THE TUTORIAL AREA");
|
||||
|
@ -102,6 +123,10 @@ if (!Function.prototype.bind) {
|
|||
this.token.destroy();
|
||||
this.token = null;
|
||||
}
|
||||
if (this.tutorialManager) {
|
||||
this.tutorialManager.stopTutorial();
|
||||
this.tutorialManager = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,40 +1,47 @@
|
|||
(function(){
|
||||
var teleport;
|
||||
var portalDestination;
|
||||
var thisEntityID;
|
||||
|
||||
function playSound() {
|
||||
Audio.playSound(teleport, { volume: 0.40, localOnly: true });
|
||||
var properties = Entities.getEntityProperties(thisEntityID, 'position');
|
||||
if (properties) {
|
||||
Audio.playSound(teleport, { position: properties.position, volume: 0.40, localOnly: true });
|
||||
}
|
||||
};
|
||||
|
||||
this.preload = function(entityID) {
|
||||
thisEntityID = entityID;
|
||||
teleport = SoundCache.getSound("atp:/sounds/teleport.raw");
|
||||
|
||||
var properties = Entities.getEntityProperties(entityID);
|
||||
portalDestination = properties.userData;
|
||||
|
||||
print("portal.js | The portal destination is " + portalDestination);
|
||||
var properties = Entities.getEntityProperties(entityID, 'userData');
|
||||
if (properties) {
|
||||
portalDestination = properties.userData;
|
||||
print("portal.js | The portal destination is " + portalDestination);
|
||||
}
|
||||
}
|
||||
|
||||
this.enterEntity = function(entityID) {
|
||||
print("portal.js | enterEntity");
|
||||
|
||||
var properties = Entities.getEntityProperties(entityID); // in case the userData/portalURL has changed
|
||||
portalDestination = properties.userData;
|
||||
var properties = Entities.getEntityProperties(entityID, 'userData'); // in case the userData/portalURL has changed
|
||||
if (properties) {
|
||||
portalDestination = properties.userData;
|
||||
|
||||
print("portal.js | enterEntity() .... The portal destination is " + portalDestination);
|
||||
print("portal.js | enterEntity() .... The portal destination is " + portalDestination);
|
||||
|
||||
if (portalDestination.length > 0) {
|
||||
if (portalDestination[0] == '/') {
|
||||
print("Teleporting to " + portalDestination);
|
||||
Window.location = portalDestination;
|
||||
if (portalDestination.length > 0) {
|
||||
if (portalDestination[0] == '/') {
|
||||
print("Teleporting to " + portalDestination);
|
||||
Window.location = portalDestination;
|
||||
} else {
|
||||
print("Teleporting to hifi://" + portalDestination);
|
||||
Window.location = "hifi://" + portalDestination;
|
||||
}
|
||||
} else {
|
||||
print("Teleporting to hifi://" + portalDestination);
|
||||
Window.location = "hifi://" + portalDestination;
|
||||
location.goToEntry(); // going forward: no data means go to appropriate entry point
|
||||
}
|
||||
} else {
|
||||
location.goToEntry(); // going forward: no data means go to appropriate entry point
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.leaveEntity = function(entityID) {
|
||||
|
|
Loading…
Reference in a new issue