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