mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Clean up tutorial scripts
This commit is contained in:
parent
a758942403
commit
1d699186a3
8 changed files with 136 additions and 633 deletions
|
@ -1,7 +1,7 @@
|
|||
var DEBUG = false;
|
||||
var VISIBLE_BY_DEFAULT = false;
|
||||
var PARENT_ID = "{00000000-0000-0000-0000-000000000001}";
|
||||
|
||||
var DEBUG = false;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(self, arguments);
|
||||
|
|
|
@ -1,188 +1,3 @@
|
|||
Step1EntityData = [
|
||||
{
|
||||
"clientOnly": 0,
|
||||
"color": {
|
||||
"blue": 255,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"created": "2016-08-29T22:57:55Z",
|
||||
"dimensions": {
|
||||
"x": 0.018359377980232239,
|
||||
"y": 0.018359377980232239,
|
||||
"z": 0.018359377980232239
|
||||
},
|
||||
"id": "{3bb83d9c-11db-4bc1-a61b-36921370cb40}",
|
||||
"name": "tutorial/box_spawn",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"collisionless": 1,
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0.8,
|
||||
"z": 0.7790381908416748
|
||||
},
|
||||
"queryAACube": {
|
||||
"scale": 0.031799376010894775,
|
||||
"x": -0.015899688005447388,
|
||||
"y": 0.79706859588623047,
|
||||
"z": 0.7631385326385498
|
||||
},
|
||||
"rotation": {
|
||||
"w": 1,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"shape": "Cube",
|
||||
"type": "Box",
|
||||
"userData": "{\"tag\":\"step2\"}",
|
||||
"visible": 0
|
||||
},
|
||||
{
|
||||
"color": {
|
||||
"blue": 181,
|
||||
"green": 181,
|
||||
"red": 181
|
||||
},
|
||||
"dimensions": {
|
||||
"x": 0.37322089076042175,
|
||||
"y": 0.8015166997909546,
|
||||
"z": 0.37322089076042175
|
||||
},
|
||||
"name": "tutorial/pillar2",
|
||||
//"shapeType": "simple-hull",
|
||||
"position": {
|
||||
"x": 0.019208565354347229,
|
||||
"y": -0.1,
|
||||
"z": 0.75276124477386475
|
||||
},
|
||||
"rotation": {
|
||||
"w": 1,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"shape": "Cube",
|
||||
"type": "Box",
|
||||
"userData": "{\"tag\":\"step2\"}"
|
||||
},
|
||||
{
|
||||
"clientOnly": 0,
|
||||
"compoundShapeURL": "http://hifi-content.s3.amazonaws.com/alan/dev/Trash-Can-4.obj",
|
||||
"created": "2016-08-29T22:57:55Z",
|
||||
"dimensions": {
|
||||
"x": 0.57461458444595337,
|
||||
"y": 0.35781359672546387,
|
||||
"z": 0.57461458444595337
|
||||
},
|
||||
"gravity": {
|
||||
"x": 0,
|
||||
"y": -5,
|
||||
"z": 0
|
||||
},
|
||||
"id": "{2a8a9cb8-4501-4089-8fb8-6b1b5100db10}",
|
||||
"modelURL": "http://hifi-content.s3.amazonaws.com/alan/dev/Trach-Can-3.fbx",
|
||||
"name": "tutorial/basket",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0.022034257650375366,
|
||||
"y": 0.47968916893005371,
|
||||
"z": 0
|
||||
},
|
||||
"queryAACube": {
|
||||
"scale": 0.88791579008102417,
|
||||
"x": -0.42192363739013672,
|
||||
"y": 0.23573127388954163,
|
||||
"z": -0.44395789504051208
|
||||
},
|
||||
"rotation": {
|
||||
"w": 1,
|
||||
"x": -1.52587890625e-05,
|
||||
"y": -1.52587890625e-05,
|
||||
"z": -1.52587890625e-05
|
||||
},
|
||||
"shapeType": "compound",
|
||||
"type": "Model",
|
||||
"userData": "{\"hifiHomeKey\":{\"reset\":true},\"tag\":\"step2\"}"
|
||||
},
|
||||
{
|
||||
"clientOnly": 0,
|
||||
"collisionless": 1,
|
||||
"color": {
|
||||
"blue": 255,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"created": "2016-08-29T22:57:55Z",
|
||||
"dimensions": {
|
||||
"x": 0.43770244717597961,
|
||||
"y": 0.33723857998847961,
|
||||
"z": 0.43770244717597961
|
||||
},
|
||||
"id": "{436aec80-15e8-4fc3-bd74-f173b731a922}",
|
||||
"ignoreForCollisions": 1,
|
||||
"name": "tutorial/basket_collider",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0.02785143256187439,
|
||||
"y": 0.50166182518005371,
|
||||
"z": 0.0017895996570587158
|
||||
},
|
||||
"queryAACube": {
|
||||
"scale": 0.70490902662277222,
|
||||
"x": -0.32460308074951172,
|
||||
"y": 0.3492073118686676,
|
||||
"z": -0.35066491365432739
|
||||
},
|
||||
"rotation": {
|
||||
"w": 1,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"type": "Sphere",
|
||||
"userData": "{\"tag\":\"step2\"}",
|
||||
"visible": 0
|
||||
},
|
||||
{
|
||||
"clientOnly": 0,
|
||||
"color": {
|
||||
"blue": 181,
|
||||
"green": 181,
|
||||
"red": 181
|
||||
},
|
||||
"created": "2016-08-29T22:57:55Z",
|
||||
"dimensions": {
|
||||
"x": 0.37322089076042175,
|
||||
"y": 0.8015000104904175,
|
||||
"z": 0.37322089076042175
|
||||
},
|
||||
"id": "{221be6c2-e0d6-4a7c-b9d4-a77e6b7d1c9a}",
|
||||
"name": "tutorial/pillar1",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0.019208565354347229,
|
||||
"y": -0.1,
|
||||
"z": 0.025902509689331055
|
||||
},
|
||||
"queryAACube": {
|
||||
"scale": 1.1320732831954956,
|
||||
"x": -0.54682809114456177,
|
||||
"y": -0.5660366415977478,
|
||||
"z": -0.54013413190841675
|
||||
},
|
||||
"rotation": {
|
||||
"w": 1,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"shape": "Cube",
|
||||
"type": "Box",
|
||||
"userData": "{\"tag\":\"step2\"}"
|
||||
}
|
||||
];
|
||||
|
||||
birdFirework1 = {
|
||||
"clientOnly": 0,
|
||||
"collisionsWillMove": 1,
|
||||
|
@ -320,233 +135,3 @@ Step1BlockData = {
|
|||
"type": "Box",
|
||||
"userData": JSON.stringify({ hifiHomeKey: { reset: true } }),
|
||||
};
|
||||
|
||||
StepGunData = [
|
||||
{
|
||||
"clientOnly": 0,
|
||||
"created": "2016-08-23T22:18:46Z",
|
||||
"dimensions": {
|
||||
"x": 2.4929797649383545,
|
||||
"y": 0.94968640804290771,
|
||||
"z": 1.0870213508605957
|
||||
},
|
||||
"id": "{de28363f-d1f8-4001-8e6b-1b5876699f49}",
|
||||
"modelURL": "http://hifi-content.s3.amazonaws.com/alan/dev/table2_re-oriented.fbx",
|
||||
"name": "tutorial/table",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0.17360222339630127,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"queryAACube": {
|
||||
"scale": 2.8807060718536377,
|
||||
"x": -1.2667508125305176,
|
||||
"y": -1.4403530359268188,
|
||||
"z": -1.4403530359268188
|
||||
},
|
||||
"rotation": {
|
||||
"w": 0.70705735683441162,
|
||||
"x": -1.52587890625e-05,
|
||||
"y": -0.70717936754226685,
|
||||
"z": -1.52587890625e-05
|
||||
},
|
||||
"shapeType": "static-mesh",
|
||||
"type": "Model",
|
||||
"userData": "{\"tag\":\"step4\"}"
|
||||
},
|
||||
{
|
||||
"clientOnly": 0,
|
||||
"compoundShapeURL": "http://hifi-content.s3.amazonaws.com/alan/dev/Trash-Can-4.obj",
|
||||
"created": "2016-08-23T22:18:46Z",
|
||||
"dimensions": {
|
||||
"x": 0.57461458444595337,
|
||||
"y": 0.35781359672546387,
|
||||
"z": 0.57461458444595337
|
||||
},
|
||||
"gravity": {
|
||||
"x": 0,
|
||||
"y": -5,
|
||||
"z": 0
|
||||
},
|
||||
"id": "{51e7cf16-e624-44a8-b835-47c35c6ad5f0}",
|
||||
"modelURL": "http://hifi-content.s3.amazonaws.com/alan/dev/Trach-Can-3.fbx",
|
||||
"name": "tutorial/basket",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 3.8134055137634277,
|
||||
"y": 0.6480712890625,
|
||||
"z": 0.015498995780944824
|
||||
},
|
||||
"queryAACube": {
|
||||
"scale": 0.88791579008102417,
|
||||
"x": 3.3694477081298828,
|
||||
"y": 0.20411339402198792,
|
||||
"z": -0.42845889925956726
|
||||
},
|
||||
"rotation": {
|
||||
"w": 1,
|
||||
"x": -1.52587890625e-05,
|
||||
"y": -1.52587890625e-05,
|
||||
"z": -1.52587890625e-05
|
||||
},
|
||||
"shapeType": "compound",
|
||||
"type": "Model",
|
||||
"userData": "{\"hifiHomeKey\":{\"reset\":true},\"tag\":\"step4\"}"
|
||||
},
|
||||
{
|
||||
"clientOnly": 0,
|
||||
"collisionless": 1,
|
||||
"color": {
|
||||
"blue": 0,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"created": "2016-08-23T22:20:57Z",
|
||||
"dimensions": {
|
||||
"x": 0.0649842768907547,
|
||||
"y": 0.0649842768907547,
|
||||
"z": 0.0649842768907547
|
||||
},
|
||||
"id": "{264943d2-600f-4d22-ad30-ccd57f7c4424}",
|
||||
"ignoreForCollisions": 1,
|
||||
"name": "tutorial/gun_spawn",
|
||||
visible: false,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0,
|
||||
"y": 0.62629544734954834,
|
||||
"z": 0.028602004051208496
|
||||
},
|
||||
"queryAACube": {
|
||||
"scale": 0.11255607008934021,
|
||||
"x": -0.056278035044670105,
|
||||
"y": 0.57001739740371704,
|
||||
"z": -0.027676030993461609
|
||||
},
|
||||
"shape": "Cube",
|
||||
"type": "Box"
|
||||
},
|
||||
{
|
||||
"clientOnly": 0,
|
||||
"collisionless": 1,
|
||||
"color": {
|
||||
"blue": 255,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"created": "2016-08-23T22:18:46Z",
|
||||
"dimensions": {
|
||||
"x": 0.43770244717597961,
|
||||
"y": 0.33723857998847961,
|
||||
"z": 0.43770244717597961
|
||||
},
|
||||
"id": "{a8944645-3234-484f-aed1-1a63d76aa51c}",
|
||||
"ignoreForCollisions": 1,
|
||||
"name": "tutorial/basket_collider",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 3.8192229270935059,
|
||||
"y": 0.6700439453125,
|
||||
"z": 0.017288565635681152
|
||||
},
|
||||
"queryAACube": {
|
||||
"scale": 0.70490902662277222,
|
||||
"x": 3.4667685031890869,
|
||||
"y": 0.31758943200111389,
|
||||
"z": -0.33516594767570496
|
||||
},
|
||||
"rotation": {
|
||||
"w": 1,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"type": "Sphere",
|
||||
"userData": "{\"tag\":\"step4\"}",
|
||||
"visible": 0
|
||||
}
|
||||
];
|
||||
|
||||
GunData = {
|
||||
"clientOnly": 0,
|
||||
"collisionsWillMove": 1,
|
||||
"compoundShapeURL": "http://hifi-production.s3.amazonaws.com/tutorials/pingPongGun/Pingpong-Gun-New.obj",
|
||||
"created": "2016-08-23T22:12:13Z",
|
||||
"dimensions": {
|
||||
"x": 0.125,
|
||||
"y": 0.38749998807907104,
|
||||
"z": 0.99309998750686646
|
||||
},
|
||||
"dynamic": 1,
|
||||
"gravity": {
|
||||
"x": 0,
|
||||
"y": -5,
|
||||
"z": 0
|
||||
},
|
||||
|
||||
"id": "{8d3fa3f2-8b59-4f47-8bb4-c03574239c9f}",
|
||||
"modelURL": "http://hifi-production.s3.amazonaws.com/tutorials/pingPongGun/Pingpong-Gun-New.fbx",
|
||||
"name": "tutorial/gun",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"queryAACube": {
|
||||
"scale": 3.219977855682373,
|
||||
"x": -2.5046753883361816,
|
||||
"y": -1.8901374340057373,
|
||||
"z": -0.68512386083602905
|
||||
},
|
||||
velocity: {
|
||||
x: 0,
|
||||
y: -1,
|
||||
z: 0
|
||||
},
|
||||
"rotation": {
|
||||
"w": 0.69534718990325928,
|
||||
"x": -0.13302478194236755,
|
||||
"y": -0.12684555351734161,
|
||||
"z": 0.69477111101150513
|
||||
},
|
||||
"script": "http://hifi-production.s3.amazonaws.com/tutorials/entity_scripts/pingPongGun.js",
|
||||
"shapeType": "compound",
|
||||
"type": "Model",
|
||||
"userData": "{\"grabbableKey\":{\"invertSolidWhileHeld\":true},\"wearable\":{\"joints\":{\"RightHand\":[{\"x\":0.1177130937576294,\"y\":0.12922893464565277,\"z\":0.08307232707738876},{\"x\":0.4934672713279724,\"y\":0.3605862259864807,\"z\":0.6394805908203125,\"w\":-0.4664038419723511}],\"LeftHand\":[{\"x\":0.09151676297187805,\"y\":0.13639454543590546,\"z\":0.09354984760284424},{\"x\":-0.19628101587295532,\"y\":0.6418180465698242,\"z\":0.2830369472503662,\"w\":0.6851521730422974}]}}}"
|
||||
};
|
||||
|
||||
HandsAboveHeadData = [
|
||||
{
|
||||
name: "tutorial/sign",
|
||||
"backgroundColor": {
|
||||
"blue": 187,
|
||||
"green": 242,
|
||||
"red": 198
|
||||
},
|
||||
"clientOnly": 0,
|
||||
"created": "2016-08-23T22:42:48Z",
|
||||
"dimensions": {
|
||||
"x": 0.58140444755554199,
|
||||
"y": 0.38676983118057251,
|
||||
"z": 0.0099999997764825821
|
||||
},
|
||||
"id": "{c0ceabcf-501e-41fe-99e9-aca47a44122f}",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"queryAACube": {
|
||||
"scale": 0.69837099313735962,
|
||||
"x": -0.34918549656867981,
|
||||
"y": -0.34918549656867981,
|
||||
"z": -0.34918549656867981
|
||||
},
|
||||
"rotation": {
|
||||
"w": 0.70710676908493042,
|
||||
"x": 0,
|
||||
"y": -0.70710670948028564,
|
||||
"z": 0
|
||||
},
|
||||
"text": "Put your hands above your head.",
|
||||
"textColor": {
|
||||
"blue": 0,
|
||||
"green": 0,
|
||||
"red": 0
|
||||
},
|
||||
"type": "Text"
|
||||
}
|
||||
];
|
||||
|
|
|
@ -1,36 +1,21 @@
|
|||
//
|
||||
// fuse.js
|
||||
//
|
||||
// Created by Ryan Huffman on 9/1/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function() {
|
||||
var findEntity = function(properties, searchRadius, filterFn) {
|
||||
var entities = findEntities(properties, searchRadius, filterFn);
|
||||
return entities.length > 0 ? entities[0] : null;
|
||||
}
|
||||
Script.include('utils.js');
|
||||
|
||||
// Return all entities with properties `properties` within radius `searchRadius`
|
||||
var findEntities = function(properties, searchRadius, filterFn) {
|
||||
if (!filterFn) {
|
||||
filterFn = function(properties, key, value) {
|
||||
return value == properties[key];
|
||||
}
|
||||
var DEBUG = false;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(self, arguments);
|
||||
}
|
||||
searchRadius = searchRadius ? searchRadius : 100000;
|
||||
var entities = Entities.findEntities({ x: 0, y: 0, z: 0 }, searchRadius);
|
||||
var matchedEntities = [];
|
||||
var keys = Object.keys(properties);
|
||||
for (var i = 0; i < entities.length; ++i) {
|
||||
var match = true;
|
||||
var candidateProperties = Entities.getEntityProperties(entities[i], keys);
|
||||
for (var key in properties) {
|
||||
if (!filterFn(properties, key, candidateProperties[key])) {
|
||||
// This isn't a match, move to next entity
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
matchedEntities.push(entities[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return matchedEntities;
|
||||
}
|
||||
|
||||
var fuseSound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/DomainContent/Tutorial/Sounds/fuse.wav");
|
||||
|
@ -48,9 +33,8 @@
|
|||
};
|
||||
Fuse.prototype = {
|
||||
light: function() {
|
||||
print("LIT", this.entityID);
|
||||
debug("LIT", this.entityID);
|
||||
var anim = Entities.getEntityProperties(this.entityID, ['animation']).animation;
|
||||
print("anim: ", anim.currentFrame, Object.keys(anim));
|
||||
|
||||
if (anim.currentFrame < 140) {
|
||||
return;
|
||||
|
@ -86,8 +70,8 @@
|
|||
|
||||
var self = this;
|
||||
Script.setTimeout(function() {
|
||||
print("BLOW UP");
|
||||
var spinnerID = findEntity({ name: "tutorial/equip/spinner" }, 20);
|
||||
debug("BLOW UP");
|
||||
var spinnerID = Utils.findEntity({ name: "tutorial/equip/spinner" }, 20);
|
||||
Entities.callEntityMethod(spinnerID, "onLit");
|
||||
injector.stop();
|
||||
|
||||
|
|
|
@ -1,55 +1,12 @@
|
|||
(function() {
|
||||
var findEntity = function(properties, searchRadius, filterFn) {
|
||||
var entities = findEntities(properties, searchRadius, filterFn);
|
||||
return entities.length > 0 ? entities[0] : null;
|
||||
}
|
||||
|
||||
// Return all entities with properties `properties` within radius `searchRadius`
|
||||
var findEntities = function(properties, searchRadius, filterFn) {
|
||||
if (!filterFn) {
|
||||
filterFn = function(properties, key, value) {
|
||||
return value == properties[key];
|
||||
}
|
||||
}
|
||||
searchRadius = searchRadius ? searchRadius : 100000;
|
||||
var entities = Entities.findEntities({ x: 0, y: 0, z: 0 }, searchRadius);
|
||||
var matchedEntities = [];
|
||||
var keys = Object.keys(properties);
|
||||
for (var i = 0; i < entities.length; ++i) {
|
||||
var match = true;
|
||||
var candidateProperties = Entities.getEntityProperties(entities[i], keys);
|
||||
for (var key in properties) {
|
||||
if (!filterFn(properties, key, candidateProperties[key])) {
|
||||
// This isn't a match, move to next entity
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
matchedEntities.push(entities[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return matchedEntities;
|
||||
}
|
||||
|
||||
function getChildProperties(entityID, propertyNames) {
|
||||
var childEntityIDs = Entities.getChildrenIDs(entityID);
|
||||
var results = {}
|
||||
for (var i = 0; i < childEntityIDs.length; ++i) {
|
||||
var childEntityID = childEntityIDs[i];
|
||||
var properties = Entities.getEntityProperties(childEntityID, propertyNames);
|
||||
results[childEntityID] = properties;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
Script.include('utils.js');
|
||||
|
||||
var Fuse = function() {
|
||||
};
|
||||
Fuse.prototype = {
|
||||
onLit: function() {
|
||||
print("LIT", this.entityID);
|
||||
var fuseID = findEntity({ name: "tutorial/equip/fuse" }, 20);
|
||||
var fuseID = Utils.findEntity({ name: "tutorial/equip/fuse" }, 20);
|
||||
Entities.callEntityMethod(fuseID, "light");
|
||||
},
|
||||
preload: function(entityID) {
|
||||
|
|
|
@ -18,7 +18,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();
|
||||
|
||||
|
@ -43,8 +43,7 @@ function getOwnershipTokenID(parentEntityID) {
|
|||
var childID = childEntityIDs[i];
|
||||
var properties = Entities.getEntityProperties(childID, ['name', 'userData', 'lifetime', 'age']);
|
||||
var childName = properties.name;
|
||||
//debug("Owner lifetime: ", properties.lifetime, properties.age);
|
||||
if (properties.age > 0.5 && childName.indexOf(TOKEN_NAME_PREFIX) == 0) {
|
||||
if (childName.indexOf(TOKEN_NAME_PREFIX) == 0) {
|
||||
if (ownerID === null || childName < ownerName) {
|
||||
ownerID = childID;
|
||||
ownerName = childName;
|
||||
|
@ -89,7 +88,6 @@ OwnershipToken = function(name, parentEntityID, options) {
|
|||
this.checkEverySeconds = getOption(options, 'checkEverySeconds', 1000);
|
||||
this.updateTokenLifetimeEvery = getOption(options, 'updateTokenLifetimeEvery', 2000);
|
||||
|
||||
//this.onRequestingOwnership = getOption(options, 'onRequestingOwnership', function() { });
|
||||
this.onGainedOwnership = getOption(options, 'onGainedOwnership', function() { });
|
||||
this.onLostOwnership = getOption(options, 'onLostOwnership', function() { });
|
||||
|
||||
|
|
|
@ -1,4 +1,21 @@
|
|||
//
|
||||
// spinner.js
|
||||
//
|
||||
// Created by Ryan Huffman on 9/1/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function() {
|
||||
var DEBUG = false;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(self, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
var spinnerSound = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/DomainContent/Tutorial/Sounds/Pinwheel.L.wav");
|
||||
var Spinner = function() {
|
||||
};
|
||||
|
@ -14,7 +31,7 @@
|
|||
}
|
||||
Spinner.prototype = {
|
||||
onLit: function() {
|
||||
print("LIT SPINNER", this.entityID);
|
||||
debug("LIT SPINNER", this.entityID);
|
||||
Entities.editEntity(this.entityID, {
|
||||
"angularDamping": 0.1,
|
||||
"angularVelocity": {
|
||||
|
@ -26,10 +43,9 @@
|
|||
var injector = Audio.playSound(spinnerSound, {
|
||||
position: Entities.getEntityProperties(this.entityID, 'position').position,
|
||||
volume: 1.0,
|
||||
loop: false
|
||||
loop: false
|
||||
});
|
||||
|
||||
print("HERE2");
|
||||
var childrenProps = getChildProperties(this.entityID, ['type']);
|
||||
for (var childEntityID in childrenProps) {
|
||||
var props = childrenProps[childEntityID];
|
||||
|
@ -43,10 +59,9 @@
|
|||
|
||||
var self = this;
|
||||
Script.setTimeout(function() {
|
||||
print("BLOW UP");
|
||||
debug("BLOW UP");
|
||||
injector.stop();
|
||||
|
||||
print("HERE");
|
||||
var childrenProps = getChildProperties(self.entityID, ['type']);
|
||||
for (var childEntityID in childrenProps) {
|
||||
var props = childrenProps[childEntityID];
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
//
|
||||
// touchControllerConfiguration.js
|
||||
//
|
||||
// Created by Ryan Huffman on 9/1/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var CONTROLLER_LENGTH_OFFSET = 0.0762;
|
||||
var leftBasePosition = {
|
||||
x: CONTROLLER_LENGTH_OFFSET / 2,
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//
|
||||
// tutorial.js
|
||||
//
|
||||
// Created by Ryan Huffman on 9/1/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.include("entityData.js");
|
||||
Script.include("viveHandsv2.js");
|
||||
Script.include("lighter/createButaneLighter.js");
|
||||
Script.include('ownershipToken.js');
|
||||
|
||||
if (!Function.prototype.bind) {
|
||||
Function.prototype.bind = function(oThis) {
|
||||
if (typeof this !== 'function') {
|
||||
|
@ -26,15 +41,31 @@ if (!Function.prototype.bind) {
|
|||
};
|
||||
}
|
||||
|
||||
Script.include("entityData.js");
|
||||
var DEBUG = false;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(self, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
Script.include("viveHandsv2.js");
|
||||
Script.include("lighter/createButaneLighter.js");
|
||||
Script.include('ownershipToken.js');
|
||||
var INFO = true;
|
||||
function info() {
|
||||
if (INFO) {
|
||||
print.apply(self, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
var BASKET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Trach-Can-3.fbx";
|
||||
var BASKET_COLLIDER_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Trash-Can-4.obj";
|
||||
//var successSound = SoundCache.getSound(Script.resolvePath("success48.wav"));
|
||||
|
||||
var NEAR_BOX_SPAWN_NAME = "tutorial/nearGrab/box_spawn";
|
||||
var FAR_BOX_SPAWN_NAME = "tutorial/farGrab/box_spawn";
|
||||
var NEAR_BASKET_COLLIDER_NAME = "tutorial/nearGrab/basket_collider";
|
||||
var FAR_BASKET_COLLIDER_NAME = "tutorial/farGrab/basket_collider";
|
||||
var GUN_BASKET_COLLIDER_NAME = "tutorial/equip/basket_collider";
|
||||
var GUN_SPAWN_NAME = "tutorial/gun_spawn";
|
||||
var TELEPORT_PAD_NAME = "tutorial/teleport/pad"
|
||||
|
||||
var successSound = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/DomainContent/Tutorial/Sounds/good_one.L.wav");
|
||||
|
||||
function beginsWithFilter(value, key) {
|
||||
|
@ -74,8 +105,24 @@ findEntities = function(properties, searchRadius, filterFn) {
|
|||
|
||||
return matchedEntities;
|
||||
}
|
||||
// On start tutorial...
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
function setControllerPartLayer(part, layer) {
|
||||
data = {};
|
||||
data[part] = layer;
|
||||
Messages.sendLocalMessage('Controller-Set-Part-Layer', JSON.stringify(data));
|
||||
}
|
||||
|
||||
function triggerHapticPulse() {
|
||||
function scheduleHaptics(delay, strength, duration) {
|
||||
|
@ -91,18 +138,8 @@ function triggerHapticPulse() {
|
|||
scheduleHaptics(1200, 0.1, 100);
|
||||
}
|
||||
|
||||
// Load assets
|
||||
var NEAR_BOX_SPAWN_NAME = "tutorial/nearGrab/box_spawn";
|
||||
var FAR_BOX_SPAWN_NAME = "tutorial/farGrab/box_spawn";
|
||||
var NEAR_BASKET_COLLIDER_NAME = "tutorial/nearGrab/basket_collider";
|
||||
var FAR_BASKET_COLLIDER_NAME = "tutorial/farGrab/basket_collider";
|
||||
var GUN_BASKET_COLLIDER_NAME = "tutorial/equip/basket_collider";
|
||||
var GUN_SPAWN_NAME = "tutorial/gun_spawn";
|
||||
var GUN_AMMO_NAME = "Tutorial Ping Pong Ball"
|
||||
var TELEPORT_PAD_NAME = "tutorial/teleport/pad"
|
||||
|
||||
function spawn(entityData, transform, modifyFn) {
|
||||
print("Creating: ", entityData);
|
||||
debug("Creating: ", entityData);
|
||||
if (!transform) {
|
||||
transform = {
|
||||
position: { x: 0, y: 0, z: 0 },
|
||||
|
@ -112,7 +149,7 @@ function spawn(entityData, transform, modifyFn) {
|
|||
var ids = [];
|
||||
for (var i = 0; i < entityData.length; ++i) {
|
||||
var data = entityData[i];
|
||||
print("Creating: ", data.name);
|
||||
debug("Creating: ", data.name);
|
||||
data.position = Vec3.sum(transform.position, data.position);
|
||||
data.rotation = Quat.multiply(data.rotation, transform.rotation);
|
||||
if (modifyFn) {
|
||||
|
@ -120,7 +157,7 @@ function spawn(entityData, transform, modifyFn) {
|
|||
}
|
||||
var id = Entities.addEntity(data);
|
||||
ids.push(id);
|
||||
print(id, "data:", JSON.stringify(data));
|
||||
debug(id, "data:", JSON.stringify(data));
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
@ -140,26 +177,22 @@ function spawnWithTag(entityData, transform, tag) {
|
|||
var userData = parseJSON(data.userData);
|
||||
userData.tag = tag;
|
||||
data.userData = JSON.stringify(userData);
|
||||
print("In modify", tag, userData, data.userData);
|
||||
debug("In modify", tag, userData, data.userData);
|
||||
return data;
|
||||
}
|
||||
return spawn(entityData, transform, modifyFn);
|
||||
}
|
||||
|
||||
function deleteEntitiesWithTag(tag) {
|
||||
print("searching for...:", tag);
|
||||
debug("searching for...:", tag);
|
||||
var entityIDs = findEntitiesWithTag(tag);
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
//print("Deleteing:", entityIDs[i]);
|
||||
Entities.deleteEntity(entityIDs[i]);
|
||||
}
|
||||
}
|
||||
function editEntitiesWithTag(tag, propertiesOrFn) {
|
||||
//print("Editing:", tag);
|
||||
var entityIDs = findEntitiesWithTag(tag);
|
||||
//print("Editing...", entityIDs);
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
//print("Editing...", entityIDs[i]);
|
||||
if (isFunction(propertiesOrFn)) {
|
||||
Entities.editEntity(entityIDs[i], propertiesOrFn(entityIDs[i]));
|
||||
} else {
|
||||
|
@ -349,21 +382,14 @@ stepOrient.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
// this.overlay = new StayInFrontOverlay("model", {
|
||||
// url: "http://hifi-content.s3.amazonaws.com/alan/dev/Prompt-Cards/welcome.fbx?11",
|
||||
// ignoreRayIntersection: true,
|
||||
// visible: false
|
||||
// }, 1.5, { x: 0, y: 0.3, z: 0 });
|
||||
|
||||
// Spawn content set
|
||||
//spawnWithTag(HandsAboveHeadData, defaultTransform, tag);
|
||||
print("raise hands...", this.tag);
|
||||
debug("raise hands...", this.tag);
|
||||
editEntitiesWithTag(this.tag, { visible: true });
|
||||
|
||||
|
||||
this.checkIntervalID = null;
|
||||
function checkForHandsAboveHead() {
|
||||
print("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;
|
||||
|
@ -421,16 +447,14 @@ stepRaiseAboveHead.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
// Spawn content set
|
||||
print("raise hands...", this.tag);
|
||||
debug("raise hands...", this.tag);
|
||||
editEntitiesWithTag(this.tag, { visible: true });
|
||||
|
||||
|
||||
// Wait 2 seconds before starting to check for hands
|
||||
this.waitTimeoutID = Script.setTimeout(function() {
|
||||
this.checkIntervalID = null;
|
||||
function checkForHandsAboveHead() {
|
||||
print("Raise above head: Checking for hands above head...");
|
||||
debug("Raise above head: Checking for hands above head...");
|
||||
if (MyAvatar.getLeftPalmPosition().y > (MyAvatar.getHeadPosition().y + 0.1)) {
|
||||
Script.clearInterval(this.checkIntervalID);
|
||||
this.checkIntervalID = null;
|
||||
|
@ -455,24 +479,6 @@ stepRaiseAboveHead.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
function setControllerPartLayer(part, layer) {
|
||||
data = {};
|
||||
data[part] = layer;
|
||||
Messages.sendLocalMessage('Controller-Set-Part-Layer', JSON.stringify(data));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -498,13 +504,12 @@ stepNearGrab.prototype = {
|
|||
var tag = this.tag;
|
||||
|
||||
// Spawn content set
|
||||
//spawnWithTag(Step1EntityData, null, tag);
|
||||
showEntitiesWithTag(this.tag, { visible: true });
|
||||
showEntitiesWithTag('bothGrab', { visible: true });
|
||||
|
||||
var boxSpawnID = findEntity({ name: NEAR_BOX_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
print("Error creating block, cannot find spawn");
|
||||
info("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
var boxSpawnPosition = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
|
@ -530,7 +535,7 @@ stepNearGrab.prototype = {
|
|||
return;
|
||||
}
|
||||
if (channel == "Entity-Exploded") {
|
||||
print("TUTORIAL: Got entity-exploded message");
|
||||
debug("TUTORIAL: Got entity-exploded message");
|
||||
|
||||
var data = parseJSON(message);
|
||||
if (this.birdIDs.indexOf(data.entityID) >= 0) {
|
||||
|
@ -541,7 +546,7 @@ stepNearGrab.prototype = {
|
|||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
print("cleaning up near grab");
|
||||
debug("cleaning up near grab");
|
||||
this.finished = true;
|
||||
setControllerVisible("trigger", false);
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
|
@ -590,7 +595,7 @@ stepFarGrab.prototype = {
|
|||
|
||||
var boxSpawnID = findEntity({ name: FAR_BOX_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
print("Error creating block, cannot find spawn");
|
||||
debug("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
var boxSpawnPosition = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
|
@ -610,7 +615,7 @@ stepFarGrab.prototype = {
|
|||
return;
|
||||
}
|
||||
if (channel == "Entity-Exploded") {
|
||||
print("TUTORIAL: Got entity-exploded message");
|
||||
debug("TUTORIAL: Got entity-exploded message");
|
||||
var data = parseJSON(message);
|
||||
if (this.birdIDs.indexOf(data.entityID) >= 0) {
|
||||
playSuccessSound();
|
||||
|
@ -694,7 +699,7 @@ stepEquip.prototype = {
|
|||
function createGun() {
|
||||
var boxSpawnID = findEntity({ name: GUN_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
print("Error creating block, cannot find spawn");
|
||||
info("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -707,12 +712,9 @@ stepEquip.prototype = {
|
|||
}
|
||||
|
||||
|
||||
// Enabled grab
|
||||
// Create table ?
|
||||
// Create blocks and basket
|
||||
this.gunID = createGun.bind(this)();
|
||||
this.startWatchingGun();
|
||||
print("Created", this.gunID);
|
||||
debug("Created", this.gunID);
|
||||
this.onFinish = onFinish;
|
||||
},
|
||||
startWatchingGun: function() {
|
||||
|
@ -737,7 +739,7 @@ stepEquip.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
print("Got message", channel, message, sender, MyAvatar.sessionUUID);
|
||||
debug("Got message", channel, message, sender, MyAvatar.sessionUUID);
|
||||
|
||||
if (channel == "Tutorial-Spinner") {
|
||||
if (this.currentPart == this.PART1 && message == "wasLit") {
|
||||
|
@ -753,7 +755,7 @@ stepEquip.prototype = {
|
|||
if (this.currentPart == this.PART2) {
|
||||
var data = parseJSON(message);
|
||||
if (data.action == 'release' && data.grabbedEntity == this.gunID) {
|
||||
print("got release");
|
||||
info("got release");
|
||||
this.stopWatchingGun();
|
||||
this.currentPart = this.COMPLETE;
|
||||
playSuccessSound();
|
||||
|
@ -820,17 +822,16 @@ stepTurnAround.prototype = {
|
|||
var dir = Quat.getFront(MyAvatar.orientation);
|
||||
var angle = Math.atan2(dir.z, dir.x);
|
||||
var angleDegrees = ((angle / Math.PI) * 180);
|
||||
print("CHECK");
|
||||
if (!hasTurnedAround) {
|
||||
if (Math.abs(angleDegrees) > 140) {
|
||||
hasTurnedAround = true;
|
||||
print("half way there...");
|
||||
info("Half way turned around");
|
||||
}
|
||||
} else {
|
||||
if (Math.abs(angleDegrees) < 30) {
|
||||
Script.clearInterval(this.interval);
|
||||
this.interval = null;
|
||||
print("DONE");
|
||||
info("Turned around");
|
||||
playSuccessSound();
|
||||
onFinish();
|
||||
}
|
||||
|
@ -876,20 +877,21 @@ stepTeleport.prototype = {
|
|||
|
||||
// Wait until touching teleport pad...
|
||||
var padID = findEntity({ name: TELEPORT_PAD_NAME }, 100);
|
||||
print(padID);
|
||||
var padProps = Entities.getEntityProperties(padID, ["position", "dimensions"]);
|
||||
print(Object.keys(padProps));
|
||||
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() {
|
||||
print("Checking if on pad...");
|
||||
debug("Checking if on pad...");
|
||||
|
||||
var pos = MyAvatar.position;
|
||||
print('x', pos.x, xMin, xMax);
|
||||
print('z', pos.z, zMin, zMax);
|
||||
|
||||
debug('x', pos.x, xMin, xMax);
|
||||
debug('z', pos.z, zMin, zMax);
|
||||
|
||||
if (pos.x > xMin && pos.x < xMax && pos.z > zMin && pos.z < zMax) {
|
||||
print("On pad!!");
|
||||
debug("On teleport pad");
|
||||
Script.clearInterval(this.checkCollidesTimer);
|
||||
this.checkCollidesTimer = null;
|
||||
playSuccessSound();
|
||||
|
@ -901,8 +903,6 @@ stepTeleport.prototype = {
|
|||
showEntitiesWithTag(this.tag);
|
||||
},
|
||||
cleanup: function() {
|
||||
//setControllerVisible("teleport", false);
|
||||
|
||||
setControllerPartLayer('touchpad', 'blank');
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
|
||||
|
@ -968,7 +968,7 @@ function showEntitiesWithTag(tag) {
|
|||
collisionless = data.collidable === true ? false : true;
|
||||
}
|
||||
if (data.soundKey) {
|
||||
print("Setting sound key to true");
|
||||
debug("Setting sound key to true");
|
||||
data.soundKey.playing = true;
|
||||
}
|
||||
var newProperties = {
|
||||
|
@ -1055,12 +1055,12 @@ TutorialManager = function() {
|
|||
|
||||
if (currentStepNum >= STEPS.length) {
|
||||
// Done
|
||||
print("DONE WITH TUTORIAL");
|
||||
info("DONE WITH TUTORIAL");
|
||||
currentStepNum = -1;
|
||||
currentStep = null;
|
||||
return false;
|
||||
} else {
|
||||
print("Starting step", currentStepNum);
|
||||
info("Starting step", currentStepNum);
|
||||
currentStep = STEPS[currentStepNum];
|
||||
startedLastStepAt = Date.now();
|
||||
currentStep.start(this.onFinish);
|
||||
|
@ -1082,49 +1082,3 @@ TutorialManager = function() {
|
|||
currentStep = null;
|
||||
}
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
Controller.enableMapping('handControllerPointer-click');
|
||||
});
|
||||
|
||||
// var entityID = '{be3d10a3-262a-4827-b30c-ec025c4325dc}';
|
||||
// var token = new OwnershipToken(Math.random() * 100000, entityID, {
|
||||
// onGainedOwnership: function(token) {
|
||||
// //Script.setTimeout(function() { token.destroy() }, 15000);
|
||||
// Controller.keyReleaseEvent.connect(keyReleaseHandler);
|
||||
// startTutorial();
|
||||
// },
|
||||
// onLostOwnership: function(token) {
|
||||
// Controller.keyReleaseEvent.disconnect(keyReleaseHandler);
|
||||
// stopTutorial();
|
||||
// }
|
||||
// });
|
||||
|
||||
//tutorialManager = new TutorialManager();
|
||||
//tutorialManager.startTutorial();
|
||||
//Controller.keyReleaseEvent.connect(keyReleaseHandler);
|
||||
Script.scriptEnding.connect(function() {
|
||||
//token.destroy();
|
||||
//stopTutorial();
|
||||
});
|
||||
|
||||
// function keyReleaseHandler(event) {
|
||||
// print(event.text);
|
||||
// if (event.text == ",") {
|
||||
// if (!tutorialManager.startNextStep()) {
|
||||
// tutorialManager.startTutorial();
|
||||
// }
|
||||
// } else if (event.text == "F11") {
|
||||
// tutorialManager.restartStep();
|
||||
// } else if (event.text == "F10") {
|
||||
// MyAvatar.shouldRenderLocally = !MyAvatar.shouldRenderLocally;
|
||||
// } else if (event.text == "r") {
|
||||
// tutorialManager.stopTutorial();
|
||||
// tutorialManager.startTutorial();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Messages.sendLocalMessage('Controller-Display', JSON.stringify({
|
||||
// name: "menu",
|
||||
// visible: false,
|
||||
// }));
|
||||
|
|
Loading…
Reference in a new issue