mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
Add tutorial and vive controller script
This commit is contained in:
parent
14323a06b3
commit
8ba03abce6
5 changed files with 1753 additions and 0 deletions
596
tutorial/entityData.js
Normal file
596
tutorial/entityData.js
Normal file
|
@ -0,0 +1,596 @@
|
|||
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\"}"
|
||||
}
|
||||
];
|
||||
|
||||
//Step1EntityData = [
|
||||
// {
|
||||
// "clientOnly": 0,
|
||||
// "color": {
|
||||
// "blue": 255,
|
||||
// "green": 0,
|
||||
// "red": 255
|
||||
// },
|
||||
// "created": "2016-08-23T16:29:15Z",
|
||||
// "dimensions": {
|
||||
// "x": 0.018359377980232239,
|
||||
// "y": 0.018359377980232239,
|
||||
// "z": 0.018359377980232239
|
||||
// },
|
||||
// "id": "{387765d2-366d-4775-8e6e-ea45119cf69d}",
|
||||
// visible: false,
|
||||
// "name": "tutorial/box_spawn",
|
||||
// "owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
// "position": {
|
||||
// "x": 0.016568422317504883,
|
||||
// "y": 0.6591796875,
|
||||
// "z": 1.3308790922164917
|
||||
// },
|
||||
// "queryAACube": {
|
||||
// "scale": 0.031799376010894775,
|
||||
// "x": 0.00066873431205749512,
|
||||
// "y": 0.643280029296875,
|
||||
// "z": 1.3149794340133667
|
||||
// },
|
||||
// "shape": "Cube",
|
||||
// "type": "Box"
|
||||
// },
|
||||
// {
|
||||
// "clientOnly": 0,
|
||||
// "compoundShapeURL": "http://hifi-content.s3.amazonaws.com/alan/dev/Trash-Can-4.obj",
|
||||
// "created": "2016-08-22T21:20:11Z",
|
||||
// "dimensions": {
|
||||
// "x": 0.57461458444595337,
|
||||
// "y": 0.35781359672546387,
|
||||
// "z": 0.57461458444595337
|
||||
// },
|
||||
// "gravity": {
|
||||
// "x": 0,
|
||||
// "y": -5,
|
||||
// "z": 0
|
||||
// },
|
||||
// "id": "{ddcb3906-3d80-4111-9171-3a73a2f4f1bb}",
|
||||
// "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,
|
||||
// "y": 0.6480712890625,
|
||||
// "z": 0
|
||||
// },
|
||||
// "queryAACube": {
|
||||
// "scale": 0.88791579008102417,
|
||||
// "x": -0.44395789504051208,
|
||||
// "y": 0.20411339402198792,
|
||||
// "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}}"
|
||||
// },
|
||||
// {
|
||||
// "clientOnly": 0,
|
||||
// "created": "2016-08-22T21:22:22Z",
|
||||
// "dimensions": {
|
||||
// "x": 2.4929797649383545,
|
||||
// "y": 0.94968640804290771,
|
||||
// "z": 1.0870213508605957
|
||||
// },
|
||||
// "id": "{e7030a2d-f573-4c4b-a0aa-ea80e9e25399}",
|
||||
// "name": "tutorial/table",
|
||||
// "modelURL": "http://hifi-content.s3.amazonaws.com/alan/dev/table2_re-oriented.fbx",
|
||||
// "owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
// "position": {
|
||||
// "x": 0.018214225769042969,
|
||||
// "y": 0,
|
||||
// "z": 0.60948663949966431
|
||||
// },
|
||||
// "queryAACube": {
|
||||
// "scale": 2.8807060718536377,
|
||||
// "x": -1.4221388101577759,
|
||||
// "y": -1.4403530359268188,
|
||||
// "z": -0.83086639642715454
|
||||
// },
|
||||
// "rotation": {
|
||||
// "w": 0.70705735683441162,
|
||||
// "x": -1.52587890625e-05,
|
||||
// "y": -0.70717936754226685,
|
||||
// "z": -1.52587890625e-05
|
||||
// },
|
||||
// "shapeType": "static-mesh",
|
||||
// "type": "Model"
|
||||
// },
|
||||
// {
|
||||
// visible: false,
|
||||
// "clientOnly": 0,
|
||||
// "collisionless": 1,
|
||||
// "color": {
|
||||
// "blue": 255,
|
||||
// "green": 0,
|
||||
// "red": 255
|
||||
// },
|
||||
// "created": "2016-08-23T18:09:44Z",
|
||||
// "dimensions": {
|
||||
// "x": 0.43770244717597961,
|
||||
// "y": 0.33723857998847961,
|
||||
// "z": 0.43770244717597961
|
||||
// },
|
||||
// "id": "{54e1d825-b552-48e4-b9c8-1c83c79a673e}",
|
||||
// "ignoreForCollisions": 1,
|
||||
// "name": "tutorial/basket_collider",
|
||||
// "owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
// "position": {
|
||||
// "x": 0.0058171749114990234,
|
||||
// "y": 0.6700439453125,
|
||||
// "z": 0.0017895996570587158
|
||||
// },
|
||||
// "queryAACube": {
|
||||
// "scale": 0.70490902662277222,
|
||||
// "x": -0.34663733839988708,
|
||||
// "y": 0.31758943200111389,
|
||||
// "z": -0.35066491365432739
|
||||
// },
|
||||
// "type": "Sphere"
|
||||
// }
|
||||
//];
|
||||
|
||||
Step1BlockData = {
|
||||
"clientOnly": 0,
|
||||
"color": {
|
||||
"blue": 0,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"created": "2016-08-22T22:54:07Z",
|
||||
"dimensions": {
|
||||
"x": 0.20000000298023224,
|
||||
"y": 0.20000000298023224,
|
||||
"z": 0.20000000298023224
|
||||
},
|
||||
name: "tutorial/block",
|
||||
"collisionsWillMove": 1,
|
||||
velocity: {
|
||||
x: 0,
|
||||
y: -0.2,
|
||||
z: 0
|
||||
},
|
||||
"dynamic": 1,
|
||||
"gravity": {
|
||||
"x": 0,
|
||||
"y": -10,
|
||||
"z": 0
|
||||
},
|
||||
"id": "{5c7223f8-3bc5-4cb4-913c-0e93f5994ca2}",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"queryAACube": {
|
||||
"scale": 0.34641015529632568,
|
||||
"x": -0.17320507764816284,
|
||||
"y": -0.17320507764816284,
|
||||
"z": -0.17320507764816284
|
||||
},
|
||||
"rotation": {
|
||||
"w": 1,
|
||||
"x": -0.0001373291015625,
|
||||
"y": -7.62939453125e-05,
|
||||
"z": -0.0003204345703125
|
||||
},
|
||||
"shape": "Cube",
|
||||
"type": "Box",
|
||||
"userData": "{}",
|
||||
};
|
||||
|
||||
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"
|
||||
}
|
||||
];
|
BIN
tutorial/success.wav
Normal file
BIN
tutorial/success.wav
Normal file
Binary file not shown.
BIN
tutorial/success48.wav
Normal file
BIN
tutorial/success48.wav
Normal file
Binary file not shown.
545
tutorial/tutorial.js
Normal file
545
tutorial/tutorial.js
Normal file
|
@ -0,0 +1,545 @@
|
|||
Script.include("entityData.js");
|
||||
//
|
||||
// var FAR_GRAB_INPUTS = [
|
||||
// Controller.Standard.RT
|
||||
// Controller.Standard.RTClick
|
||||
// Controller.Standard.LT
|
||||
// Controller.Standard.LTClick
|
||||
// ];
|
||||
//
|
||||
// var TELEPORT_INPUTS = [
|
||||
// Controller.Standard.LeftPrimaryThumb
|
||||
// Controller.Standard.RightPrimaryThumb
|
||||
// ];
|
||||
//
|
||||
// function noop(value) { }
|
||||
// var FAR_GRAB_MAPPING_NAME = "com.highfidelity.farGrab.disable";
|
||||
// var farGrabMapping = Controller.newMapping(FAR_GRAB_MAPPING_NAME);
|
||||
// for (var i = 0; i < FAR_GRAB_INPUTS.length; ++i) {
|
||||
// mapping.from([FAR_GRAB_INPUTS[i]]).to(noop);
|
||||
// }
|
||||
//
|
||||
// var TELEPORT_MAPPING_NAME = "com.highfidelity.teleport.disable";
|
||||
// var teleportMapping = Controller.newMapping(TELEPORT_MAPPING_NAME);
|
||||
// for (var i = 0; i < FAR_GRAB_INPUTS.length; ++i) {
|
||||
// mapping.from([TELEPORT_INPUTS[i]]).to(noop);
|
||||
// }
|
||||
//
|
||||
// mapping.from([Controller.Standard.RT]).to(noop);
|
||||
// mapping.from([Controller.Standard.RTClick]).to(noop);
|
||||
//
|
||||
// mapping.from([Controller.Standard.LT]).to(noop);
|
||||
// mapping.from([Controller.Standard.LTClick]).to(noop);
|
||||
//
|
||||
// mapping.from([Controller.Standard.RB]).to(noop);
|
||||
// mapping.from([Controller.Standard.LB]).to(noop);
|
||||
// mapping.from([Controller.Standard.LeftGrip]).to(noop);
|
||||
// mapping.from([Controller.Standard.RightGrip]).to(noop);
|
||||
//
|
||||
// mapping.from([Controller.Standard.LeftPrimaryThumb]).to(noop);
|
||||
// mapping.from([Controller.Standard.RightPrimaryThumb]).to(noop);
|
||||
//
|
||||
// Script.scriptEnding.connect(function() {
|
||||
// Controller.disableMapping(MAPPING_NAME);
|
||||
// });
|
||||
//
|
||||
// Controller.enableMapping(MAPPING_NAME);
|
||||
|
||||
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"));
|
||||
|
||||
function beginsWithFilter(value, key) {
|
||||
return value.indexOf(properties[key]) == 0;
|
||||
}
|
||||
|
||||
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`
|
||||
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;
|
||||
}
|
||||
// On start tutorial...
|
||||
|
||||
// Load assets
|
||||
var BOX_SPAWN_NAME = "tutorial/box_spawn";
|
||||
var BASKET_COLLIDER_NAME = "tutorial/basket_collider";
|
||||
var GUN_SPAWN_NAME = "tutorial/gun_spawn";
|
||||
var GUN_AMMO_NAME = "Tutorial Ping Pong Ball"
|
||||
|
||||
function spawn(entityData, transform, modifyFn) {
|
||||
print("Creating: ", entityData);
|
||||
if (!transform) {
|
||||
transform = {
|
||||
position: { x: 0, y: 0, z: 0 },
|
||||
rotation: { x: 0, y: 0, z: 0, w: 1 }
|
||||
}
|
||||
}
|
||||
var ids = [];
|
||||
for (var i = 0; i < entityData.length; ++i) {
|
||||
var data = entityData[i];
|
||||
print("Creating: ", data.name);
|
||||
data.position = Vec3.sum(transform.position, data.position);
|
||||
data.rotation = Quat.multiply(data.rotation, transform.rotation);
|
||||
if (modifyFn) {
|
||||
data = modifyFn(data);
|
||||
}
|
||||
var id = Entities.addEntity(data);
|
||||
ids.push(id);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
function parseJSON(jsonString) {
|
||||
var data;
|
||||
try {
|
||||
data = JSON.parse(jsonString);
|
||||
} catch(e) {
|
||||
data = {};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function spawnWithTag(entityData, transform, tag) {
|
||||
function modifyFn(data) {
|
||||
var userData = parseJSON(data.userData);
|
||||
userData.tag = tag;
|
||||
data.userData = JSON.stringify(userData);
|
||||
return data;
|
||||
}
|
||||
return spawn(entityData, transform, modifyFn);
|
||||
}
|
||||
|
||||
function findEntitiesWithTag(tag) {
|
||||
return findEntities({ userData: "" }, 10000, function(properties, key, value) {
|
||||
data = parseJSON(value);
|
||||
return data.tag == tag;
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// STEP: DISABLE CONTROLLERS //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
var stepDisableControllers = function(name) {
|
||||
this.tag = name;
|
||||
}
|
||||
stepDisableControllers.prototype = {
|
||||
start: function(onFinish) {
|
||||
Menu.setIsOptionChecked("Overlays", false);
|
||||
Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'both');
|
||||
Messages.sendLocalMessage('Hifi-Grab-Disable', JSON.stringify({
|
||||
nearGrabEnabled: true,
|
||||
holdEnabled: false,
|
||||
farGrabEnabled: false,
|
||||
}));
|
||||
onFinish();
|
||||
},
|
||||
cleanup: function() {
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// STEP: Raise hands above head //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
var stepRaiseAboveHead = function(name) {
|
||||
this.tag = name;
|
||||
}
|
||||
stepRaiseAboveHead.prototype = {
|
||||
start: function(onFinish) {
|
||||
var tag = this.tag;
|
||||
|
||||
var defaultTransform = {
|
||||
position: {
|
||||
x: 0.2459,
|
||||
y: 0.9011,
|
||||
z: 0.7266
|
||||
},
|
||||
rotation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0,
|
||||
w: 1
|
||||
}
|
||||
};
|
||||
|
||||
// Spawn content set
|
||||
spawnWithTag(HandsAboveHeadData, defaultTransform, tag);
|
||||
|
||||
var checkIntervalID = null;
|
||||
function checkForHandsAboveHead() {
|
||||
print("Checking...");
|
||||
if (MyAvatar.getLeftPalmPosition().y > (MyAvatar.getHeadPosition().y + 0.1)) {
|
||||
Script.clearInterval(checkIntervalID);
|
||||
this.soundInjector = Audio.playSound(successSound, {
|
||||
position: defaultTransform.position,
|
||||
volume: 0.7,
|
||||
loop: false
|
||||
});
|
||||
onFinish();
|
||||
}
|
||||
}
|
||||
checkIntervalID = Script.setInterval(checkForHandsAboveHead, 500);
|
||||
},
|
||||
cleanup: function() {
|
||||
var entityIDs = findEntitiesWithTag(this.tag);
|
||||
print("entities: ", entityIDs.length);
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
print("Deleting: ", entityIDs[i]);
|
||||
Entities.deleteEntity(entityIDs[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// STEP: Near Grab //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
var stepNearGrab = function(name) {
|
||||
this.tag = name;
|
||||
}
|
||||
stepNearGrab.prototype = {
|
||||
start: function(onFinish) {
|
||||
var tag = this.tag;
|
||||
|
||||
// Spawn content set
|
||||
spawnWithTag(Step1EntityData, null, tag);
|
||||
|
||||
var basketColliderID = findEntity({ name: BASKET_COLLIDER_NAME }, 10000);
|
||||
var basketPosition = Entities.getEntityProperties(basketColliderID, 'position').position;
|
||||
|
||||
function createBlock() {
|
||||
var boxSpawnID = findEntity({ name: BOX_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
print("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
|
||||
Step1BlockData.position = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
return spawnWithTag([Step1BlockData], null, tag)[0];
|
||||
}
|
||||
|
||||
// Enabled grab
|
||||
// Create table ?
|
||||
// Create blocks and basket
|
||||
var boxID = createBlock();
|
||||
print("Created", boxID);
|
||||
|
||||
function onHit() {
|
||||
onFinish();
|
||||
}
|
||||
|
||||
// When block collides with basket start step 2
|
||||
var checkCollidesTimer = null;
|
||||
function checkCollides() {
|
||||
print("CHECKING...");
|
||||
if (Vec3.distance(basketPosition, Entities.getEntityProperties(boxID, 'position').position) < 0.1) {
|
||||
Script.clearInterval(checkCollidesTimer);
|
||||
this.soundInjector = Audio.playSound(successSound, {
|
||||
position: basketPosition,
|
||||
volume: 0.7,
|
||||
loop: false
|
||||
});
|
||||
Script.setTimeout(onHit, 1000);
|
||||
}
|
||||
}
|
||||
checkCollidesTimer = Script.setInterval(checkCollides, 500);
|
||||
|
||||
// If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block
|
||||
},
|
||||
cleanup: function() {
|
||||
var entityIDs = findEntitiesWithTag(this.tag);
|
||||
print("entities: ", entityIDs.length);
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
print("Deleting: ", entityIDs[i]);
|
||||
Entities.deleteEntity(entityIDs[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// STEP: Far Grab //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
var stepFarGrab = function(name) {
|
||||
this.tag = name;
|
||||
}
|
||||
stepFarGrab.prototype = {
|
||||
start: function(onFinish) {
|
||||
Messages.sendLocalMessage('Hifi-Grab-Disable', JSON.stringify({
|
||||
farGrabEnabled: true,
|
||||
}));
|
||||
var tag = this.tag;
|
||||
var transform = {
|
||||
position: { x: 3, y: 0, z: 0 },
|
||||
rotation: { x: 0, y: 0, z: 0, w: 1 }
|
||||
}
|
||||
|
||||
// Spawn content set
|
||||
spawnWithTag(Step1EntityData, transform, tag);
|
||||
|
||||
var basketColliderID = findEntity({ name: BASKET_COLLIDER_NAME }, 10000);
|
||||
var basketPosition = Entities.getEntityProperties(basketColliderID, 'position').position;
|
||||
|
||||
function createBlock() {
|
||||
var boxSpawnID = findEntity({ name: BOX_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
print("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
|
||||
Step1BlockData.position = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
return spawnWithTag([Step1BlockData], null, tag)[0];
|
||||
}
|
||||
|
||||
// Enabled grab
|
||||
// Create table ?
|
||||
// Create blocks and basket
|
||||
var boxID = createBlock();
|
||||
print("Created", boxID);
|
||||
|
||||
function onHit() {
|
||||
onFinish();
|
||||
}
|
||||
|
||||
// When block collides with basket start step 2
|
||||
var checkCollidesTimer = null;
|
||||
function checkCollides() {
|
||||
print("CHECKING...");
|
||||
if (Vec3.distance(basketPosition, Entities.getEntityProperties(boxID, 'position').position) < 0.1) {
|
||||
Script.clearInterval(checkCollidesTimer);
|
||||
this.soundInjector = Audio.playSound(successSound, {
|
||||
position: basketPosition,
|
||||
volume: 0.7,
|
||||
loop: false
|
||||
});
|
||||
Script.setTimeout(onHit, 1000);
|
||||
}
|
||||
}
|
||||
checkCollidesTimer = Script.setInterval(checkCollides, 500);
|
||||
|
||||
// If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block
|
||||
},
|
||||
cleanup: function() {
|
||||
var entityIDs = findEntitiesWithTag(this.tag);
|
||||
print("entities: ", entityIDs.length);
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
print("Deleting: ", entityIDs[i]);
|
||||
Entities.deleteEntity(entityIDs[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// STEP: Equip //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
var stepEquip = function(name) {
|
||||
this.tag = name;
|
||||
}
|
||||
stepEquip.prototype = {
|
||||
start: function(onFinish) {
|
||||
Messages.sendLocalMessage('Hifi-Grab-Disable', JSON.stringify({
|
||||
holdEnabled: true,
|
||||
}));
|
||||
|
||||
var tag = this.tag;
|
||||
|
||||
var defaultTransform = {
|
||||
position: {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.75
|
||||
},
|
||||
rotation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0,
|
||||
w: 1
|
||||
}
|
||||
};
|
||||
|
||||
// Spawn content set
|
||||
spawnWithTag(StepGunData, defaultTransform, tag);
|
||||
|
||||
var basketColliderID = findEntity({ name: BASKET_COLLIDER_NAME }, 10000);
|
||||
var basketPosition = Entities.getEntityProperties(basketColliderID, 'position').position;
|
||||
|
||||
function createGun() {
|
||||
var boxSpawnID = findEntity({ name: GUN_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
print("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
|
||||
GunData.position = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
Vec3.print("spawn", GunData.position);
|
||||
print("Adding: ", JSON.stringify(GunData));
|
||||
return spawnWithTag([GunData], null, tag)[0];
|
||||
}
|
||||
|
||||
// Enabled grab
|
||||
// Create table ?
|
||||
// Create blocks and basket
|
||||
var gunID = createGun();
|
||||
print("Created", gunID);
|
||||
|
||||
function onHit() {
|
||||
onFinish();
|
||||
}
|
||||
|
||||
// When block collides with basket start step 2
|
||||
var checkCollidesTimer = null;
|
||||
function checkCollides() {
|
||||
print("CHECKING...");
|
||||
var ammoIDs = findEntities({ name: GUN_AMMO_NAME }, 15);
|
||||
for (var i = 0; i < ammoIDs.length; ++i) {
|
||||
if (Vec3.distance(basketPosition, Entities.getEntityProperties(ammoIDs[i], 'position').position) < 0.2) {
|
||||
Script.clearInterval(checkCollidesTimer);
|
||||
this.soundInjector = Audio.playSound(successSound, {
|
||||
position: basketPosition,
|
||||
volume: 0.7,
|
||||
loop: false
|
||||
});
|
||||
Script.setTimeout(onHit, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
checkCollidesTimer = Script.setInterval(checkCollides, 500);
|
||||
|
||||
// If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block
|
||||
},
|
||||
cleanup: function() {
|
||||
var entityIDs = findEntitiesWithTag(this.tag);
|
||||
print("entities: ", entityIDs.length);
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
print("Deleting: ", entityIDs[i]);
|
||||
Entities.deleteEntity(entityIDs[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// STEP: Teleport //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
var stepTeleport = function(name) {
|
||||
this.tag = name;
|
||||
}
|
||||
stepTeleport.prototype = {
|
||||
start: function(onFinish) {
|
||||
Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'none');
|
||||
Menu.setIsOptionChecked("Overlays", false);
|
||||
},
|
||||
cleanup: function() {
|
||||
var entityIDs = findEntitiesWithTag(this.tag);
|
||||
print("entities: ", entityIDs.length);
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
print("Deleting: ", entityIDs[i]);
|
||||
Entities.deleteEntity(entityIDs[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var STEPS;
|
||||
|
||||
var currentStepNum = -1;
|
||||
var currentStep = null;
|
||||
function startTutorial() {
|
||||
currentStepNum = -1;
|
||||
currentStep = null;
|
||||
STEPS = [
|
||||
new stepDisableControllers("step0"),
|
||||
//new stepRaiseAboveHead("step1"),
|
||||
new stepNearGrab("step2"),
|
||||
new stepFarGrab("step3"),
|
||||
new stepEquip("step4"),
|
||||
new stepTeleport("teleport"),
|
||||
]
|
||||
startNextStep();
|
||||
}
|
||||
|
||||
function startNextStep() {
|
||||
if (currentStep) {
|
||||
//currentStep.cleanup();
|
||||
}
|
||||
|
||||
++currentStepNum;
|
||||
|
||||
if (currentStepNum >= STEPS.length) {
|
||||
// Done
|
||||
print("DONE WITH TUTORIAL");
|
||||
} else {
|
||||
print("Starting step", currentStepNum);
|
||||
currentStep = STEPS[currentStepNum];
|
||||
currentStep.start(startNextStep);
|
||||
startNextStep();
|
||||
}
|
||||
}
|
||||
|
||||
function skipTutorial() {
|
||||
}
|
||||
|
||||
function stopTutorial() {
|
||||
if (currentStep) {
|
||||
currentStep.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
location = "/tutorial";
|
||||
startTutorial();
|
||||
|
||||
Script.scriptEnding.connect(stopTutorial);
|
||||
|
612
tutorial/viveHandsv2.js
Normal file
612
tutorial/viveHandsv2.js
Normal file
|
@ -0,0 +1,612 @@
|
|||
var PARENT_ID = MyAvatar.sessionUUID;
|
||||
var LEFT_JOINT_INDEX = MyAvatar.getJointIndex("_CONTROLLER_LEFTHAND");
|
||||
var RIGHT_JOINT_INDEX = MyAvatar.getJointIndex("_CONTROLLER_RIGHTHAND");
|
||||
var LEFT_JOINT_INDEX = MyAvatar.getJointIndex("LeftHand");
|
||||
var RIGHT_JOINT_INDEX = MyAvatar.getJointIndex("RightHand");
|
||||
|
||||
var zeroPosition = { x: 0, y: 0, z: 0 };
|
||||
var zeroRotation = { x: 0, y: 0, z: 0, w: 1 };
|
||||
|
||||
var CONTROLLER_LENGTH_OFFSET = 0.0762;
|
||||
|
||||
var naturalPosition = {
|
||||
x: 0,
|
||||
y: -0.034076502197422087,
|
||||
z: 0.06380049744620919
|
||||
};
|
||||
var naturalPositionL = {
|
||||
x: 0,
|
||||
y: 0.034076502197422087,
|
||||
z: 0.06380049744620919
|
||||
};
|
||||
var naturalPositionR = {
|
||||
x: 0.0,
|
||||
y: 0.034076502197422087,
|
||||
z: 0.06380049744620919
|
||||
};
|
||||
|
||||
// THe CONTROLLER_LEFTHAND
|
||||
var leftBasePosition = {
|
||||
x: CONTROLLER_LENGTH_OFFSET / 2,
|
||||
y: CONTROLLER_LENGTH_OFFSET * 2,
|
||||
z: CONTROLLER_LENGTH_OFFSET / 2
|
||||
};
|
||||
var rightBasePosition = {
|
||||
x: -CONTROLLER_LENGTH_OFFSET / 2,
|
||||
y: CONTROLLER_LENGTH_OFFSET * 2,
|
||||
z: CONTROLLER_LENGTH_OFFSET / 2
|
||||
};
|
||||
|
||||
var leftBasePositionVive = Vec3.sum(leftBasePosition, { x: 0.005, y: 0.03, z: 0 });
|
||||
var rightBasePositionVive = Vec3.sum(rightBasePosition, { x: -0.005, y: 0.03, z: 0 });
|
||||
|
||||
Vec3.print("left offset: ", leftBasePosition);
|
||||
|
||||
var leftBaseRotation = Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(0, 0, 45),
|
||||
Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(90, 0, 0),
|
||||
Quat.fromPitchYawRollDegrees(0, 0, 90)
|
||||
)
|
||||
);
|
||||
|
||||
var rightBaseRotation = Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(0, 0, -45),
|
||||
Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(90, 0, 0),
|
||||
Quat.fromPitchYawRollDegrees(0, 0, -90)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
var touchLeftBaseRotation = Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(0, 0, 0),
|
||||
Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(0, 0, -45),
|
||||
Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(180, 0, 0),
|
||||
Quat.fromPitchYawRollDegrees(0, -90, 0)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
var touchRightBaseRotation = Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(0, 0, 45),
|
||||
Quat.multiply(
|
||||
Quat.fromPitchYawRollDegrees(180, 0, 0),
|
||||
Quat.fromPitchYawRollDegrees(0, 90, 0)
|
||||
)
|
||||
);
|
||||
|
||||
var TOUCH_CONTROLLER_CONFIGURATION = {
|
||||
name: "Touch",
|
||||
controllers: [
|
||||
{
|
||||
modelURL: "C:/Users/Ryan/Assets/controller/touch_l_full.fbx",
|
||||
jointIndex: MyAvatar.getJointIndex("_CONTROLLER_LEFTHAND"),
|
||||
rotation: touchLeftBaseRotation,
|
||||
//position: Vec3.sum(leftBasePosition, { x: 0.032, y: 0.0, z: -0.02 }),
|
||||
position: Vec3.sum(leftBasePosition, { x: 0.0, y: -0.016, z: -0.02 }),
|
||||
//dimensions: naturalDimensions,
|
||||
},
|
||||
{
|
||||
modelURL: "C:/Users/Ryan/Assets/controller/touch_r_full.fbx",
|
||||
jointIndex: MyAvatar.getJointIndex("_CONTROLLER_RIGHTHAND"),
|
||||
rotation: touchRightBaseRotation,
|
||||
//position: rightBasePosition,
|
||||
position: Vec3.sum(rightBasePosition, { x: 0.0, y: -0.016, z: -0.02 }),
|
||||
//dimensions: naturalDimensions,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
var TOUCH_2_CONTROLLER_CONFIGURATION = {
|
||||
name: "Touch",
|
||||
controllers: [
|
||||
{
|
||||
modelURL: "C:/Users/Ryan/Assets/controller/oculus_touch_l.fbx",
|
||||
naturalPosition: {
|
||||
x: 0.016486000269651413,
|
||||
y: -0.035518500953912735,
|
||||
z: -0.018527504056692123
|
||||
},
|
||||
jointIndex: MyAvatar.getJointIndex("_CONTROLLER_LEFTHAND"),
|
||||
rotation: touchLeftBaseRotation,
|
||||
position: leftBasePosition,
|
||||
|
||||
annotationTextRotation: Quat.fromPitchYawRollDegrees(20, -90, 0),
|
||||
annotations: {
|
||||
|
||||
buttonX: {
|
||||
position: {
|
||||
x: -0.00931,
|
||||
y: 0.00212,
|
||||
z: -0.01259,
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 100, green: 100, blue: 100 },
|
||||
},
|
||||
buttonY: {
|
||||
position: {
|
||||
x: -0.01617,
|
||||
y: 0.00216,
|
||||
z: 0.00177,
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 100, green: 255, blue: 100 },
|
||||
},
|
||||
bumper: {
|
||||
position: {
|
||||
x: 0.00678,
|
||||
y: -0.02740,
|
||||
z: -0.02537,
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 100, green: 100, blue: 255 },
|
||||
},
|
||||
trigger: {
|
||||
position: {
|
||||
x: -0.01275,
|
||||
y: -0.01992,
|
||||
z: 0.02314,
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
modelURL: "C:/Users/Ryan/Assets/controller/oculus_touch_r.fbx",
|
||||
naturalPosition: {
|
||||
x: -0.016486000269651413,
|
||||
y: -0.035518500953912735,
|
||||
z: -0.018527504056692123
|
||||
},
|
||||
jointIndex: MyAvatar.getJointIndex("_CONTROLLER_RIGHTHAND"),
|
||||
rotation: touchRightBaseRotation,
|
||||
position: rightBasePosition,
|
||||
|
||||
annotationTextRotation: Quat.fromPitchYawRollDegrees(20, 90, 0),
|
||||
annotations: {
|
||||
|
||||
buttonA: {
|
||||
position: {
|
||||
x: 0.00931,
|
||||
y: 0.00212,
|
||||
z: -0.01259,
|
||||
},
|
||||
direction: "right",
|
||||
color: { red: 100, green: 100, blue: 100 },
|
||||
},
|
||||
buttonB: {
|
||||
position: {
|
||||
x: 0.01617,
|
||||
y: 0.00216,
|
||||
z: 0.00177,
|
||||
},
|
||||
direction: "right",
|
||||
color: { red: 100, green: 255, blue: 100 },
|
||||
},
|
||||
bumper: {
|
||||
position: {
|
||||
x: 0.00678,
|
||||
y: -0.02740,
|
||||
z: -0.02537,
|
||||
},
|
||||
direction: "right",
|
||||
color: { red: 100, green: 100, blue: 255 },
|
||||
},
|
||||
trigger: {
|
||||
position: {
|
||||
x: 0.01275,
|
||||
y: -0.01992,
|
||||
z: 0.02314,
|
||||
},
|
||||
direction: "right",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
}
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
var viveNaturalDimensions = {
|
||||
x: 0.1174320001155138,
|
||||
y: 0.08361100335605443,
|
||||
z: 0.21942697931081057
|
||||
};
|
||||
var viveNaturalPosition = {
|
||||
x: 0,
|
||||
y: -0.034076502197422087,
|
||||
z: 0.06380049744620919
|
||||
};
|
||||
|
||||
var VIVE_CONTROLLER_CONFIGURATION = {
|
||||
name: "Vive",
|
||||
controllers: [
|
||||
{
|
||||
modelURL: "https://hifi-public.s3.amazonaws.com/huffman/controllers/vr_controller_vive_1_5.obj",
|
||||
modelURL: "C:\\Users\\Ryan\\Assets\\controller\\vive2.fbx",
|
||||
jointIndex: MyAvatar.getJointIndex("_CONTROLLER_LEFTHAND"),
|
||||
naturalPosition: viveNaturalPosition,
|
||||
rotation: leftBaseRotation,
|
||||
position: Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, 0, 45), leftBasePosition),
|
||||
|
||||
dimensions: viveNaturalDimensions,
|
||||
|
||||
annotationTextRotation: Quat.fromPitchYawRollDegrees(20, -90, 0),
|
||||
annotations: {
|
||||
// red: {
|
||||
// debug: true,
|
||||
// position: {
|
||||
// x: 0.1,
|
||||
// y: 0.0,
|
||||
// z: 0.0
|
||||
// },
|
||||
// direction: "right",
|
||||
// color: { red: 255, green: 0, blue: 0 },
|
||||
// },
|
||||
// green: {
|
||||
// debug: true,
|
||||
// position: {
|
||||
// x: 0.0,
|
||||
// y: 0.1,
|
||||
// z: 0.0
|
||||
// },
|
||||
// direction: "right",
|
||||
// color: { red: 0, green: 255, blue: 0 },
|
||||
// },
|
||||
// blue: {
|
||||
// debug: true,
|
||||
// position: {
|
||||
// x: 0.0,
|
||||
// y: 0.0,
|
||||
// z: 0.1
|
||||
// },
|
||||
// direction: "right",
|
||||
// color: { red: 0, green: 0, blue: 255 },
|
||||
// },
|
||||
// white: {
|
||||
// debug: true,
|
||||
// position: {
|
||||
// x: 0.0,
|
||||
// y: 0.0,
|
||||
// z: 0.0
|
||||
// },
|
||||
// direction: "right",
|
||||
// color: { red: 255, green: 255, blue: 255 },
|
||||
// },
|
||||
|
||||
center: {
|
||||
position: zeroPosition,
|
||||
direction: "center",
|
||||
color: { red: 100, green: 255, blue: 255 },
|
||||
},
|
||||
trigger: {
|
||||
position: {
|
||||
x: 0,
|
||||
y: -0.023978,
|
||||
z: 0.04546
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
menu: {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0.00770,
|
||||
z: 0.01979
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
grip: {
|
||||
position: {
|
||||
x: 0.01980,
|
||||
y: -0.01561,
|
||||
z: 0.08721
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
pad: {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0.00378,
|
||||
z: 0.04920
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
steam: {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0.00303,
|
||||
z: 0.08838
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
modelURL: "https://hifi-public.s3.amazonaws.com/huffman/controllers/vr_controller_vive_1_5.obj",
|
||||
modelURL: "C:\\Users\\Ryan\\Assets\\controller\\vive2.fbx",
|
||||
jointIndex: MyAvatar.getJointIndex("_CONTROLLER_RIGHTHAND"),
|
||||
//rotation: rightBaseRotation,
|
||||
//position: rightBasePosition,
|
||||
//position: Vec3.sum(Vec3.multiplyQbyV(rightBaseRotation, naturalPositionR), rightBasePositionVive),
|
||||
|
||||
//rotation: zeroRotation,
|
||||
//position: zeroPosition,
|
||||
rotation: rightBaseRotation,
|
||||
position: Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, 0, -45), rightBasePosition),
|
||||
|
||||
dimensions: viveNaturalDimensions,
|
||||
|
||||
naturalPosition: {
|
||||
x: 0,
|
||||
y: -0.034076502197422087,
|
||||
z: 0.06380049744620919
|
||||
},
|
||||
//rotation: touchRightBaseRotation,
|
||||
//position: rightBasePosition,
|
||||
|
||||
annotationTextRotation: Quat.fromPitchYawRollDegrees(20, -90, 0),
|
||||
annotations: {
|
||||
|
||||
trigger: {
|
||||
position: {
|
||||
x: 0,
|
||||
y: -0.023978,
|
||||
z: 0.04546
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
menu: {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0.00770,
|
||||
z: 0.01979
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
grip: {
|
||||
position: {
|
||||
x: 0.01980,
|
||||
y: -0.01561,
|
||||
z: 0.08721
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
pad: {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0.00378,
|
||||
z: 0.04920
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
steam: {
|
||||
position: {
|
||||
x: 0,
|
||||
y: 0.00303,
|
||||
z: 0.08838
|
||||
},
|
||||
direction: "left",
|
||||
color: { red: 255, green: 100, blue: 100 },
|
||||
},
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
var DEBUG = true;
|
||||
|
||||
function setupController(config) {
|
||||
var controllerDisplay = {
|
||||
overlays: [],
|
||||
annotations: {
|
||||
},
|
||||
mappingName: ""
|
||||
};
|
||||
for (var i = 0; i < config.controllers.length; ++i) {
|
||||
var controller = config.controllers[i];
|
||||
var position = controller.position;
|
||||
if (controller.naturalPosition) {
|
||||
position = Vec3.sum(Vec3.multiplyQbyV(
|
||||
controller.rotation, controller.naturalPosition), position);
|
||||
}
|
||||
var overlayID = Overlays.addOverlay("model", {
|
||||
url: controller.modelURL,
|
||||
dimensions: controller.dimensions,
|
||||
localRotation: controller.rotation,
|
||||
localPosition: position,
|
||||
parentID: PARENT_ID,
|
||||
parentJointIndex: controller.jointIndex,
|
||||
ignoreRayIntersection: true,
|
||||
});
|
||||
|
||||
controllerDisplay.overlays.push(overlayID);
|
||||
|
||||
if (controller.annotations) {
|
||||
for (var key in controller.annotations) {
|
||||
var annotation = controller.annotations[key];
|
||||
var annotationPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, annotation.position));
|
||||
if (DEBUG) {
|
||||
overlayID = Overlays.addOverlay("sphere", {
|
||||
localPosition: annotationPosition,
|
||||
//localPosition: Vec3.sum(controller.position, annotation.position),
|
||||
//localPosition: Vec3.sum(position, annotation.position),
|
||||
color: annotation.color || { red: 255, green: 100, blue: 100 },
|
||||
dimensions: {
|
||||
x: 0.01,
|
||||
y: 0.01,
|
||||
z: 0.01
|
||||
},
|
||||
parentID: PARENT_ID,
|
||||
parentJointIndex: controller.jointIndex,
|
||||
});
|
||||
controllerDisplay.overlays.push(overlayID);
|
||||
|
||||
controllerDisplay.annotations[key] = {
|
||||
overlay: overlayID,
|
||||
};
|
||||
}
|
||||
|
||||
var sign = annotation.direction == "right" ? 1 : -1;
|
||||
var textOffset = annotation.direction == "right" ? 0.04 : -0.01;
|
||||
var textOverlayID = Overlays.addOverlay("text3d", {
|
||||
text: key,
|
||||
localPosition: Vec3.sum(annotationPosition, Vec3.multiplyQbyV(controller.rotation, { x: textOffset, y: 0, z: 0.0 })),
|
||||
localRotation: controller.annotationTextRotation,
|
||||
lineHeight: 0.01,
|
||||
leftMargin: 0,
|
||||
rightMargin: 0,
|
||||
topMargin: 0,
|
||||
bottomMargin: 0,
|
||||
backgroundAlpha: 0,
|
||||
dimensions: { x: 0.003, y: 0.003, z: 0.003 },
|
||||
//localPosition: Vec3.sum(controller.position, annotation.position),
|
||||
//localPosition: Vec3.sum(position, annotation.position),
|
||||
color: annotation.textColor || { red: 255, green: 255, blue: 255 },
|
||||
parentID: PARENT_ID,
|
||||
parentJointIndex: controller.jointIndex,
|
||||
});
|
||||
controllerDisplay.overlays.push(textOverlayID);
|
||||
|
||||
var offset = { x: 0, y: 0, z: annotation.direction == "right" ? -0.1 : 0.1 };
|
||||
var lineOverlayID = Overlays.addOverlay("line3d", {
|
||||
visible: false,
|
||||
localPosition: annotationPosition,
|
||||
localStart: { x: 0, y: 0, z: 0 },
|
||||
localEnd: offset,
|
||||
//localPosition: Vec3.sum(controller.position, annotation.position),
|
||||
//localPosition: Vec3.sum(position, annotation.position),
|
||||
color: annotation.color || { red: 255, green: 100, blue: 100 },
|
||||
parentID: PARENT_ID,
|
||||
parentJointIndex: controller.jointIndex,
|
||||
});
|
||||
controllerDisplay.overlays.push(lineOverlayID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return controllerDisplay;
|
||||
}
|
||||
|
||||
ControllerDisplay = function() {
|
||||
};
|
||||
|
||||
function deleteControllerDisplay(controllerDisplay) {
|
||||
for (var i = 0; i < controllerDisplay.overlays.length; ++i) {
|
||||
Overlays.deleteOverlay(controllerDisplay.overlays[i]);
|
||||
}
|
||||
Controller.disableMapping(controllerDisplay.mappingName);
|
||||
}
|
||||
|
||||
// var triggerAnnotationOverlayID = Overlays.addOverlay("text3d", {
|
||||
// text: "Trigger",
|
||||
// lineHeight: 0.025,
|
||||
// backgroundAlpha: 0.0,
|
||||
// dimensions: {
|
||||
// x: 0.2,
|
||||
// y: 0.2,
|
||||
// },
|
||||
// localPosition: Vec3.sum(leftBasePosition, { x: -0.09, y: -0.025, z: 0.03 }),
|
||||
// localRotation: Quat.multiply(Quat.fromPitchYawRollDegrees(180, 0, 90), leftBaseRotation),
|
||||
// parentID: MyAvatar.sessionUUID,
|
||||
// parentJointIndex: MyAvatar.getJointIndex("LeftHand")
|
||||
// });
|
||||
|
||||
// var leftOverlayID = Overlays.addOverlay("model", {
|
||||
// url: "https://hifi-public.s3.amazonaws.com/huffman/controllers/vr_controller_vive_1_5.obj",
|
||||
// dimensions: naturalDimensions,
|
||||
// localRotation: leftBaseRotation,
|
||||
// localPosition: leftBasePosition,
|
||||
// parentID: PARENT_ID,
|
||||
// parentJointIndex: LEFT_JOINT_INDEX
|
||||
// });
|
||||
//
|
||||
// var leftTriggerOverlayID = Overlays.addOverlay("model", {
|
||||
// url: "C:/Users/Ryan/Assets/controller/touch_l_trigger.fbx",
|
||||
// visible: false,
|
||||
// localRotation: leftBaseRotation,
|
||||
// localPosition: Vec3.sum(leftBasePosition, { x: -0.05, y: -0.025, z: 0.02 }),
|
||||
// parentID: PARENT_ID,
|
||||
// parentJointIndex: LEFT_JOINT_INDEX
|
||||
// });
|
||||
|
||||
// var rightOverlayID = Overlays.addOverlay("model", {
|
||||
// url: "https://hifi-public.s3.amazonaws.com/huffman/controllers/vr_controller_vive_1_5.obj",
|
||||
// dimensions: naturalDimensions,
|
||||
// localRotation: rightBaseRotation,
|
||||
// localPosition: rightBasePosition,
|
||||
// parentID: PARENT_ID,
|
||||
// parentJointIndex: RIGHT_JOINT_INDEX
|
||||
// });
|
||||
//
|
||||
// var rightTriggerOverlayID = Overlays.addOverlay("model", {
|
||||
// url: "C:/Users/Ryan/Assets/controller/touch_r_trigger.fbx",
|
||||
// visible: false,
|
||||
// localRotation: rightBaseRotation,
|
||||
// localPosition: Vec3.sum(rightBasePosition, { x: 0.05, y: -0.025, z: 0.02 }),
|
||||
// parentID: PARENT_ID,
|
||||
// parentJointIndex: RIGHT_JOINT_INDEX
|
||||
// });
|
||||
//
|
||||
var overlays = [
|
||||
// leftOverlayID,
|
||||
// leftTriggerOverlayID,
|
||||
// triggerAnnotationOverlayID,
|
||||
|
||||
// rightOverlayID,
|
||||
// rightTriggerOverlayID,
|
||||
];
|
||||
//
|
||||
// Script.setInterval(function() {
|
||||
// // var pose = MyAvatar.getLeftHandControllerPoseInWorldFrame();
|
||||
// // Overlays.editOverlay(leftOverlayID, {
|
||||
// // position: pose.translation,
|
||||
// // rotation: pose.rotation
|
||||
// // });
|
||||
// // pose = MyAvatar.getRightHandControllerPoseInWorldFrame();
|
||||
// // Overlays.editOverlay(rightOverlayID, {
|
||||
// // position: pose.translation,
|
||||
// // rotation: pose.rotation
|
||||
// // });
|
||||
// }, 10);
|
||||
|
||||
|
||||
var MAPPING_NAME = "com.highfidelity.handControllerGrab.disable";
|
||||
var mapping = Controller.newMapping(MAPPING_NAME);
|
||||
mapping.from([Controller.Standard.LT]).to(function(value) {
|
||||
// print(value);
|
||||
// Overlays.editOverlay(leftTriggerOverlayID, {
|
||||
// localRotation: Quat.multiply(Quat.fromPitchYawRollDegrees(0, 0, value * -45), leftBaseRotation)
|
||||
// });
|
||||
});
|
||||
mapping.from([Controller.Standard.RT]).to(function(value) {
|
||||
// print(value);
|
||||
// Overlays.editOverlay(rightTriggerOverlayID, {
|
||||
// localRotation: Quat.multiply(Quat.fromPitchYawRollDegrees(0, 0, value * 45), rightBaseRotation)
|
||||
// });
|
||||
});
|
||||
Controller.enableMapping(MAPPING_NAME);
|
||||
|
||||
//var c = setupController(TOUCH_CONTROLLER_CONFIGURATION);
|
||||
//var c = setupController(TOUCH_2_CONTROLLER_CONFIGURATION);
|
||||
var c = setupController(VIVE_CONTROLLER_CONFIGURATION);
|
||||
//MyAvatar.shouldRenderLocally = false;
|
||||
Script.scriptEnding.connect(function() {
|
||||
deleteControllerDisplay(c);
|
||||
MyAvatar.shouldRenderLocally = true;
|
||||
for (var i = 0; i < overlays.length; ++i) {
|
||||
Overlays.deleteOverlay(overlays[i]);
|
||||
}
|
||||
Controller.disableMapping(MAPPING_NAME);
|
||||
});
|
Loading…
Reference in a new issue