mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into 20638
This commit is contained in:
commit
229b7ae128
25 changed files with 1835 additions and 910 deletions
|
@ -11,6 +11,8 @@
|
||||||
//
|
//
|
||||||
Script.include("http://s3.amazonaws.com/hifi-public/scripts/libraries/toolBars.js");
|
Script.include("http://s3.amazonaws.com/hifi-public/scripts/libraries/toolBars.js");
|
||||||
|
|
||||||
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
|
||||||
var nullActionID = "00000000-0000-0000-0000-000000000000";
|
var nullActionID = "00000000-0000-0000-0000-000000000000";
|
||||||
var controllerID;
|
var controllerID;
|
||||||
var controllerActive;
|
var controllerActive;
|
||||||
|
@ -20,7 +22,7 @@ var leftHandActionID = nullActionID;
|
||||||
var rightHandActionID = nullActionID;
|
var rightHandActionID = nullActionID;
|
||||||
|
|
||||||
var TRIGGER_THRESHOLD = 0.2;
|
var TRIGGER_THRESHOLD = 0.2;
|
||||||
var GRAB_RADIUS = 0.25;
|
var GRAB_RADIUS = 0.15;
|
||||||
|
|
||||||
var LEFT_HAND_CLICK = Controller.findAction("LEFT_HAND_CLICK");
|
var LEFT_HAND_CLICK = Controller.findAction("LEFT_HAND_CLICK");
|
||||||
var RIGHT_HAND_CLICK = Controller.findAction("RIGHT_HAND_CLICK");
|
var RIGHT_HAND_CLICK = Controller.findAction("RIGHT_HAND_CLICK");
|
||||||
|
@ -32,7 +34,7 @@ var leftHandGrabAction = LEFT_HAND_CLICK;
|
||||||
|
|
||||||
var rightHandGrabValue = 0;
|
var rightHandGrabValue = 0;
|
||||||
var leftHandGrabValue = 0;
|
var leftHandGrabValue = 0;
|
||||||
var prevRightHandGrabValue = 0;
|
var prevRightHandGrabValue = 0
|
||||||
var prevLeftHandGrabValue = 0;
|
var prevLeftHandGrabValue = 0;
|
||||||
|
|
||||||
var grabColor = { red: 0, green: 255, blue: 0};
|
var grabColor = { red: 0, green: 255, blue: 0};
|
||||||
|
@ -46,8 +48,8 @@ var toolBar = new ToolBar(0, 0, ToolBar.vertical, "highfidelity.toybox.toolbar",
|
||||||
});
|
});
|
||||||
|
|
||||||
var BUTTON_SIZE = 32;
|
var BUTTON_SIZE = 32;
|
||||||
var SWORD_IMAGE = "https://hifi-public.s3.amazonaws.com/images/sword/sword.svg"; // replace this with a table icon
|
var SWORD_IMAGE = "https://hifi-public.s3.amazonaws.com/images/sword/sword.svg"; // TODO: replace this with a table icon
|
||||||
var CLEANUP_IMAGE = "http://s3.amazonaws.com/hifi-public/images/delete.png"; // cleanup table
|
var CLEANUP_IMAGE = "http://s3.amazonaws.com/hifi-public/images/delete.png";
|
||||||
var tableButton = toolBar.addOverlay("image", {
|
var tableButton = toolBar.addOverlay("image", {
|
||||||
width: BUTTON_SIZE,
|
width: BUTTON_SIZE,
|
||||||
height: BUTTON_SIZE,
|
height: BUTTON_SIZE,
|
||||||
|
@ -61,20 +63,25 @@ var cleanupButton = toolBar.addOverlay("image", {
|
||||||
alpha: 1
|
alpha: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
var leftHandOverlay = Overlays.addOverlay("sphere", {
|
var overlays = false;
|
||||||
|
var leftHandOverlay;
|
||||||
|
var rightHandOverlay;
|
||||||
|
if (overlays) {
|
||||||
|
leftHandOverlay = Overlays.addOverlay("sphere", {
|
||||||
position: MyAvatar.getLeftPalmPosition(),
|
position: MyAvatar.getLeftPalmPosition(),
|
||||||
size: GRAB_RADIUS,
|
size: GRAB_RADIUS,
|
||||||
color: releaseColor,
|
color: releaseColor,
|
||||||
alpha: 0.5,
|
alpha: 0.5,
|
||||||
solid: false
|
solid: false
|
||||||
});
|
});
|
||||||
var rightHandOverlay = Overlays.addOverlay("sphere", {
|
rightHandOverlay = Overlays.addOverlay("sphere", {
|
||||||
position: MyAvatar.getRightPalmPosition(),
|
position: MyAvatar.getRightPalmPosition(),
|
||||||
size: GRAB_RADIUS,
|
size: GRAB_RADIUS,
|
||||||
color: releaseColor,
|
color: releaseColor,
|
||||||
alpha: 0.5,
|
alpha: 0.5,
|
||||||
solid: false
|
solid: false
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var OBJECT_HEIGHT_OFFSET = 0.5;
|
var OBJECT_HEIGHT_OFFSET = 0.5;
|
||||||
var MIN_OBJECT_SIZE = 0.05;
|
var MIN_OBJECT_SIZE = 0.05;
|
||||||
|
@ -86,9 +93,9 @@ var TABLE_DIMENSIONS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var GRAVITY = {
|
var GRAVITY = {
|
||||||
x: 0,
|
x: 0.0,
|
||||||
y: -2,
|
y: -2.0,
|
||||||
z: 0
|
z: 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
var LEFT = 0;
|
var LEFT = 0;
|
||||||
|
@ -101,6 +108,8 @@ var tableEntities = Array(NUM_OBJECTS + 1); // Also includes table
|
||||||
|
|
||||||
var VELOCITY_MAG = 0.3;
|
var VELOCITY_MAG = 0.3;
|
||||||
|
|
||||||
|
var entitiesToResize = [];
|
||||||
|
|
||||||
var MODELS = Array(
|
var MODELS = Array(
|
||||||
{ modelURL: "https://hifi-public.s3.amazonaws.com/ozan/props/sword/sword.fbx" },
|
{ modelURL: "https://hifi-public.s3.amazonaws.com/ozan/props/sword/sword.fbx" },
|
||||||
{ modelURL: "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Vehicles/clara/spaceshuttle.fbx" },
|
{ modelURL: "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Vehicles/clara/spaceshuttle.fbx" },
|
||||||
|
@ -113,11 +122,41 @@ var MODELS = Array(
|
||||||
{ modelURL: "https://hifi-public.s3.amazonaws.com/marketplace/contents/029db3d4-da2c-4cb2-9c08-b9612ba576f5/02949063e7c4aed42ad9d1a58461f56d.fst?1427169842" },
|
{ modelURL: "https://hifi-public.s3.amazonaws.com/marketplace/contents/029db3d4-da2c-4cb2-9c08-b9612ba576f5/02949063e7c4aed42ad9d1a58461f56d.fst?1427169842" },
|
||||||
{ modelURL: "https://hifi-public.s3.amazonaws.com/models/props/MidCenturyModernLivingRoom/Interior/Bar.fbx" },
|
{ modelURL: "https://hifi-public.s3.amazonaws.com/models/props/MidCenturyModernLivingRoom/Interior/Bar.fbx" },
|
||||||
{ modelURL: "https://hifi-public.s3.amazonaws.com/marketplace/contents/96124d04-d603-4707-a5b3-e03bf47a53b2/1431770eba362c1c25c524126f2970fb.fst?1436924721" }
|
{ modelURL: "https://hifi-public.s3.amazonaws.com/marketplace/contents/96124d04-d603-4707-a5b3-e03bf47a53b2/1431770eba362c1c25c524126f2970fb.fst?1436924721" }
|
||||||
|
// Complex models:
|
||||||
// { modelURL: "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Architecture/sketchfab/cudillero.fbx" },
|
// { modelURL: "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Architecture/sketchfab/cudillero.fbx" },
|
||||||
// { modelURL: "https://hifi-public.s3.amazonaws.com/ozan/sets/musicality/musicality.fbx" },
|
// { modelURL: "https://hifi-public.s3.amazonaws.com/ozan/sets/musicality/musicality.fbx" },
|
||||||
// { modelURL: "https://hifi-public.s3.amazonaws.com/ozan/sets/statelyHome/statelyHome.fbx" }
|
// { modelURL: "https://hifi-public.s3.amazonaws.com/ozan/sets/statelyHome/statelyHome.fbx" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var COLLISION_SOUNDS = Array(
|
||||||
|
"http://public.highfidelity.io/sounds/Collisions-ballhitsandcatches/pingpong_TableBounceMono.wav",
|
||||||
|
"http://public.highfidelity.io/sounds/Collisions-ballhitsandcatches/billiards/collision1.wav"
|
||||||
|
);
|
||||||
|
|
||||||
|
var RESIZE_TIMER = 0.0;
|
||||||
|
var RESIZE_WAIT = 0.05; // 50 milliseconds
|
||||||
|
|
||||||
|
var leftFist = Entities.addEntity( {
|
||||||
|
type: "Sphere",
|
||||||
|
shapeType: 'sphere',
|
||||||
|
position: MyAvatar.getLeftPalmPosition(),
|
||||||
|
dimensions: { x: GRAB_RADIUS, y: GRAB_RADIUS, z: GRAB_RADIUS },
|
||||||
|
rotation: MyAvatar.getLeftPalmRotation(),
|
||||||
|
visible: false,
|
||||||
|
collisionsWillMove: false,
|
||||||
|
ignoreForCollisions: true
|
||||||
|
});
|
||||||
|
var rightFist = Entities.addEntity( {
|
||||||
|
type: "Sphere",
|
||||||
|
shapeType: 'sphere',
|
||||||
|
position: MyAvatar.getRightPalmPosition(),
|
||||||
|
dimensions: { x: GRAB_RADIUS, y: GRAB_RADIUS, z: GRAB_RADIUS },
|
||||||
|
rotation: MyAvatar.getRightPalmRotation(),
|
||||||
|
visible: false,
|
||||||
|
collisionsWillMove: false,
|
||||||
|
ignoreForCollisions: true
|
||||||
|
});
|
||||||
|
|
||||||
function letGo(hand) {
|
function letGo(hand) {
|
||||||
var actionIDToRemove = (hand == LEFT) ? leftHandActionID : rightHandActionID;
|
var actionIDToRemove = (hand == LEFT) ? leftHandActionID : rightHandActionID;
|
||||||
var entityIDToEdit = (hand == LEFT) ? leftHandObjectID : rightHandObjectID;
|
var entityIDToEdit = (hand == LEFT) ? leftHandObjectID : rightHandObjectID;
|
||||||
|
@ -126,6 +165,7 @@ function letGo(hand) {
|
||||||
MyAvatar.getRightPalmAngularVelocity();
|
MyAvatar.getRightPalmAngularVelocity();
|
||||||
if (actionIDToRemove != nullActionID && entityIDToEdit != null) {
|
if (actionIDToRemove != nullActionID && entityIDToEdit != null) {
|
||||||
Entities.deleteAction(entityIDToEdit, actionIDToRemove);
|
Entities.deleteAction(entityIDToEdit, actionIDToRemove);
|
||||||
|
// TODO: upon successful letGo, restore collision groups
|
||||||
if (hand == LEFT) {
|
if (hand == LEFT) {
|
||||||
leftHandObjectID = null;
|
leftHandObjectID = null;
|
||||||
leftHandActionID = nullActionID;
|
leftHandActionID = nullActionID;
|
||||||
|
@ -142,12 +182,15 @@ function setGrabbedObject(hand) {
|
||||||
var objectID = null;
|
var objectID = null;
|
||||||
var minDistance = GRAB_RADIUS;
|
var minDistance = GRAB_RADIUS;
|
||||||
for (var i = 0; i < entities.length; i++) {
|
for (var i = 0; i < entities.length; i++) {
|
||||||
|
// Don't grab the object in your other hands, your fists, or the table
|
||||||
if ((hand == LEFT && entities[i] == rightHandObjectID) ||
|
if ((hand == LEFT && entities[i] == rightHandObjectID) ||
|
||||||
(hand == RIGHT) && entities[i] == leftHandObjectID) {
|
(hand == RIGHT && entities[i] == leftHandObjectID) ||
|
||||||
|
entities[i] == leftFist || entities[i] == rightFist ||
|
||||||
|
(tableCreated && entities[i] == tableEntities[0])) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
var distance = Vec3.distance(Entities.getEntityProperties(entities[i]).position, handPosition);
|
var distance = Vec3.distance(Entities.getEntityProperties(entities[i]).position, handPosition);
|
||||||
if (distance < minDistance) {
|
if (distance <= minDistance) {
|
||||||
objectID = entities[i];
|
objectID = entities[i];
|
||||||
minDistance = distance;
|
minDistance = distance;
|
||||||
}
|
}
|
||||||
|
@ -166,19 +209,23 @@ function setGrabbedObject(hand) {
|
||||||
|
|
||||||
function grab(hand) {
|
function grab(hand) {
|
||||||
if (!setGrabbedObject(hand)) {
|
if (!setGrabbedObject(hand)) {
|
||||||
|
// If you don't grab an object, make a fist
|
||||||
|
Entities.editEntity((hand == LEFT) ? leftFist : rightFist, { ignoreForCollisions: false } );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var objectID = (hand == LEFT) ? leftHandObjectID : rightHandObjectID;
|
var objectID = (hand == LEFT) ? leftHandObjectID : rightHandObjectID;
|
||||||
var handRotation = (hand == LEFT) ? MyAvatar.getLeftPalmRotation() : MyAvatar.getRightPalmRotation();
|
var handRotation = (hand == LEFT) ? MyAvatar.getLeftPalmRotation() : MyAvatar.getRightPalmRotation();
|
||||||
|
var handPosition = (hand == LEFT) ? MyAvatar.getLeftPalmPosition() : MyAvatar.getRightPalmPosition();
|
||||||
|
|
||||||
var objectRotation = Entities.getEntityProperties(objectID).rotation;
|
var objectRotation = Entities.getEntityProperties(objectID).rotation;
|
||||||
var offsetRotation = Quat.multiply(Quat.inverse(handRotation), objectRotation);
|
var offsetRotation = Quat.multiply(Quat.inverse(handRotation), objectRotation);
|
||||||
|
|
||||||
|
var objectPosition = Entities.getEntityProperties(objectID).position;
|
||||||
|
var offset = Vec3.subtract(objectPosition, handPosition);
|
||||||
|
var offsetPosition = Vec3.multiplyQbyV(Quat.inverse(Quat.multiply(handRotation, offsetRotation)), offset);
|
||||||
|
// print(JSON.stringify(offsetPosition));
|
||||||
var actionID = Entities.addAction("hold", objectID, {
|
var actionID = Entities.addAction("hold", objectID, {
|
||||||
relativePosition: {
|
relativePosition: { x: 0, y: 0, z: 0 },
|
||||||
x: 0.0,
|
|
||||||
y: 0.0,
|
|
||||||
z: 0.0
|
|
||||||
},
|
|
||||||
relativeRotation: offsetRotation,
|
relativeRotation: offsetRotation,
|
||||||
hand: (hand == LEFT) ? "left" : "right",
|
hand: (hand == LEFT) ? "left" : "right",
|
||||||
timeScale: 0.05
|
timeScale: 0.05
|
||||||
|
@ -190,7 +237,7 @@ function grab(hand) {
|
||||||
rightHandObjectID = null;
|
rightHandObjectID = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Entities.editEntity(objectID, { ignore});
|
// TODO: upon successful grab, add to collision group so object doesn't collide with immovable entities
|
||||||
if (hand == LEFT) {
|
if (hand == LEFT) {
|
||||||
leftHandActionID = actionID;
|
leftHandActionID = actionID;
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,28 +246,70 @@ function grab(hand) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function resizeModels() {
|
||||||
Overlays.editOverlay(leftHandOverlay, { position: MyAvatar.getLeftPalmPosition() });
|
var newEntitiesToResize = [];
|
||||||
Overlays.editOverlay(rightHandOverlay, { position: MyAvatar.getRightPalmPosition() });
|
for (var i = 0; i < entitiesToResize.length; i++) {
|
||||||
|
var naturalDimensions = Entities.getEntityProperties(entitiesToResize[i]).naturalDimensions;
|
||||||
|
if (naturalDimensions.x != 1.0 || naturalDimensions.y != 1.0 || naturalDimensions.z != 1.0) {
|
||||||
|
// bigger range of sizes for models
|
||||||
|
var dimensions = Vec3.multiply(randFloat(MIN_OBJECT_SIZE, 3.0*MAX_OBJECT_SIZE), Vec3.normalize(naturalDimensions));
|
||||||
|
Entities.editEntity(entitiesToResize[i], {
|
||||||
|
dimensions: dimensions,
|
||||||
|
shapeType: "box"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
newEntitiesToResize.push(entitiesToResize[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
entitiesToResize = newEntitiesToResize;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update(deltaTime) {
|
||||||
|
if (overlays) {
|
||||||
|
Overlays.editOverlay(leftHandOverlay, { position: MyAvatar.getLeftPalmPosition() });
|
||||||
|
Overlays.editOverlay(rightHandOverlay, { position: MyAvatar.getRightPalmPosition() });
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (tableCreated && RESIZE_TIMER < RESIZE_WAIT) {
|
||||||
|
// RESIZE_TIMER += deltaTime;
|
||||||
|
// } else if (tableCreated) {
|
||||||
|
// resizeModels();
|
||||||
|
// }
|
||||||
|
|
||||||
rightHandGrabValue = Controller.getActionValue(rightHandGrabAction);
|
rightHandGrabValue = Controller.getActionValue(rightHandGrabAction);
|
||||||
leftHandGrabValue = Controller.getActionValue(leftHandGrabAction);
|
leftHandGrabValue = Controller.getActionValue(leftHandGrabAction);
|
||||||
|
|
||||||
if (rightHandGrabValue > TRIGGER_THRESHOLD && rightHandObjectID == null) {
|
Entities.editEntity(leftFist, { position: MyAvatar.getLeftPalmPosition() });
|
||||||
Overlays.editOverlay(rightHandOverlay, { color: grabColor });
|
Entities.editEntity(rightFist, { position: MyAvatar.getRightPalmPosition() });
|
||||||
|
|
||||||
|
if (rightHandGrabValue > TRIGGER_THRESHOLD &&
|
||||||
|
prevRightHandGrabValue < TRIGGER_THRESHOLD) {
|
||||||
|
if (overlays) {
|
||||||
|
Overlays.editOverlay(rightHandOverlay, { color: grabColor });
|
||||||
|
}
|
||||||
grab(RIGHT);
|
grab(RIGHT);
|
||||||
} else if (rightHandGrabValue < TRIGGER_THRESHOLD &&
|
} else if (rightHandGrabValue < TRIGGER_THRESHOLD &&
|
||||||
prevRightHandGrabValue > TRIGGER_THRESHOLD) {
|
prevRightHandGrabValue > TRIGGER_THRESHOLD) {
|
||||||
Overlays.editOverlay(rightHandOverlay, { color: releaseColor });
|
Entities.editEntity(rightFist, { ignoreForCollisions: true } );
|
||||||
|
if (overlays) {
|
||||||
|
Overlays.editOverlay(rightHandOverlay, { color: releaseColor });
|
||||||
|
}
|
||||||
letGo(RIGHT);
|
letGo(RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftHandGrabValue > TRIGGER_THRESHOLD && leftHandObjectID == null) {
|
if (leftHandGrabValue > TRIGGER_THRESHOLD &&
|
||||||
Overlays.editOverlay(leftHandOverlay, { color: grabColor });
|
prevLeftHandGrabValue < TRIGGER_THRESHOLD) {
|
||||||
|
if (overlays) {
|
||||||
|
Overlays.editOverlay(leftHandOverlay, { color: grabColor });
|
||||||
|
}
|
||||||
grab(LEFT);
|
grab(LEFT);
|
||||||
} else if (leftHandGrabValue < TRIGGER_THRESHOLD &&
|
} else if (leftHandGrabValue < TRIGGER_THRESHOLD &&
|
||||||
prevLeftHandGrabValue > TRIGGER_THRESHOLD) {
|
prevLeftHandGrabValue > TRIGGER_THRESHOLD) {
|
||||||
Overlays.editOverlay(leftHandOverlay, { color: releaseColor });
|
Entities.editEntity(leftFist, { ignoreForCollisions: true } );
|
||||||
|
if (overlays) {
|
||||||
|
Overlays.editOverlay(leftHandOverlay, { color: releaseColor });
|
||||||
|
}
|
||||||
letGo(LEFT);
|
letGo(LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,8 +320,12 @@ function update() {
|
||||||
function cleanUp() {
|
function cleanUp() {
|
||||||
letGo(RIGHT);
|
letGo(RIGHT);
|
||||||
letGo(LEFT);
|
letGo(LEFT);
|
||||||
Overlays.deleteOverlay(leftHandOverlay);
|
if (overlays) {
|
||||||
Overlays.deleteOverlay(rightHandOverlay);
|
Overlays.deleteOverlay(leftHandOverlay);
|
||||||
|
Overlays.deleteOverlay(rightHandOverlay);
|
||||||
|
}
|
||||||
|
Entities.deleteEntity(leftFist);
|
||||||
|
Entities.deleteEntity(rightFist);
|
||||||
removeTable();
|
removeTable();
|
||||||
toolBar.cleanup();
|
toolBar.cleanup();
|
||||||
}
|
}
|
||||||
|
@ -268,11 +361,14 @@ randInt = function(low, high) {
|
||||||
function createTable() {
|
function createTable() {
|
||||||
var tablePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(MyAvatar.orientation)));
|
var tablePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(MyAvatar.orientation)));
|
||||||
tableEntities[0] = Entities.addEntity( {
|
tableEntities[0] = Entities.addEntity( {
|
||||||
type: "Box",
|
type: "Model",
|
||||||
|
shapeType: 'box',
|
||||||
position: tablePosition,
|
position: tablePosition,
|
||||||
dimensions: TABLE_DIMENSIONS,
|
dimensions: TABLE_DIMENSIONS,
|
||||||
rotation: MyAvatar.orientation,
|
rotation: MyAvatar.orientation,
|
||||||
color: { red: 255, green: 0, blue: 0 }
|
// color: { red: 102, green: 51, blue: 0 },
|
||||||
|
modelURL: HIFI_PUBLIC_BUCKET + 'eric/models/woodFloor.fbx',
|
||||||
|
collisionSoundURL: "http://public.highfidelity.io/sounds/dice/diceCollide.wav"
|
||||||
});
|
});
|
||||||
|
|
||||||
for (var i = 1; i < NUM_OBJECTS + 1; i++) {
|
for (var i = 1; i < NUM_OBJECTS + 1; i++) {
|
||||||
|
@ -308,7 +404,8 @@ function createTable() {
|
||||||
restitution: 0.01,
|
restitution: 0.01,
|
||||||
density: 0.5,
|
density: 0.5,
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
color: { red: randInt(0, 255), green: randInt(0, 255), blue: randInt(0, 255) }
|
color: { red: randInt(0, 255), green: randInt(0, 255), blue: randInt(0, 255) },
|
||||||
|
// collisionSoundURL: COLLISION_SOUNDS[randInt(0, COLLISION_SOUNDS.length)]
|
||||||
});
|
});
|
||||||
if (type == "Model") {
|
if (type == "Model") {
|
||||||
var randModel = randInt(0, MODELS.length);
|
var randModel = randInt(0, MODELS.length);
|
||||||
|
@ -316,11 +413,13 @@ function createTable() {
|
||||||
shapeType: "box",
|
shapeType: "box",
|
||||||
modelURL: MODELS[randModel].modelURL
|
modelURL: MODELS[randModel].modelURL
|
||||||
});
|
});
|
||||||
|
entitiesToResize.push(tableEntities[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeTable() {
|
function removeTable() {
|
||||||
|
RESIZE_TIMER = 0.0;
|
||||||
for (var i = 0; i < tableEntities.length; i++) {
|
for (var i = 0; i < tableEntities.length; i++) {
|
||||||
Entities.deleteEntity(tableEntities[i]);
|
Entities.deleteEntity(tableEntities[i]);
|
||||||
}
|
}
|
|
@ -574,8 +574,14 @@ function findClickedEntity(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var mouseHasMovedSincePress = false;
|
var mouseHasMovedSincePress = false;
|
||||||
|
var mousePressStartTime = 0;
|
||||||
|
var mousePressStartPosition = { x: 0, y: 0 };
|
||||||
|
var mouseDown = false;
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
|
mouseDown = true;
|
||||||
|
mousePressStartPosition = { x: event.x, y: event.y };
|
||||||
|
mousePressStartTime = Date.now();
|
||||||
mouseHasMovedSincePress = false;
|
mouseHasMovedSincePress = false;
|
||||||
mouseCapturedByTool = false;
|
mouseCapturedByTool = false;
|
||||||
|
|
||||||
|
@ -595,6 +601,8 @@ var highlightedEntityID = null;
|
||||||
var mouseCapturedByTool = false;
|
var mouseCapturedByTool = false;
|
||||||
var lastMousePosition = null;
|
var lastMousePosition = null;
|
||||||
var idleMouseTimerId = null;
|
var idleMouseTimerId = null;
|
||||||
|
var CLICK_TIME_THRESHOLD = 500 * 1000; // 500 ms
|
||||||
|
var CLICK_MOVE_DISTANCE_THRESHOLD = 8;
|
||||||
var IDLE_MOUSE_TIMEOUT = 200;
|
var IDLE_MOUSE_TIMEOUT = 200;
|
||||||
var DEFAULT_ENTITY_DRAG_DROP_DISTANCE = 2.0;
|
var DEFAULT_ENTITY_DRAG_DROP_DISTANCE = 2.0;
|
||||||
|
|
||||||
|
@ -603,7 +611,21 @@ function mouseMoveEventBuffered(event) {
|
||||||
lastMouseMoveEvent = event;
|
lastMouseMoveEvent = event;
|
||||||
}
|
}
|
||||||
function mouseMove(event) {
|
function mouseMove(event) {
|
||||||
mouseHasMovedSincePress = true;
|
if (mouseDown && !mouseHasMovedSincePress) {
|
||||||
|
var timeSincePressMicro = Date.now() - mousePressStartTime;
|
||||||
|
|
||||||
|
var dX = mousePressStartPosition.x - event.x;
|
||||||
|
var dY = mousePressStartPosition.y - event.y;
|
||||||
|
var sqDist = (dX * dX) + (dY * dY);
|
||||||
|
|
||||||
|
// If less than CLICK_TIME_THRESHOLD has passed since the mouse click AND the mouse has moved
|
||||||
|
// less than CLICK_MOVE_DISTANCE_THRESHOLD distance, then don't register this as a mouse move
|
||||||
|
// yet. The goal is to provide mouse clicks that are more lenient to small movements.
|
||||||
|
if (timeSincePressMicro < CLICK_TIME_THRESHOLD && sqDist < CLICK_MOVE_DISTANCE_THRESHOLD) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mouseHasMovedSincePress = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (placingEntityID) {
|
if (placingEntityID) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
@ -670,6 +692,8 @@ function highlightEntityUnderCursor(position, accurateRay) {
|
||||||
|
|
||||||
|
|
||||||
function mouseReleaseEvent(event) {
|
function mouseReleaseEvent(event) {
|
||||||
|
mouseDown = false;
|
||||||
|
|
||||||
if (lastMouseMoveEvent) {
|
if (lastMouseMoveEvent) {
|
||||||
mouseMove(lastMouseMoveEvent);
|
mouseMove(lastMouseMoveEvent);
|
||||||
lastMouseMoveEvent = null;
|
lastMouseMoveEvent = null;
|
||||||
|
|
|
@ -19,7 +19,9 @@ Script.include('../utilities/tools/vector.js');
|
||||||
|
|
||||||
var URL = "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/";
|
var URL = "https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/";
|
||||||
|
|
||||||
SatelliteGame = function() {
|
SatelliteCreator = function() {
|
||||||
|
print("initializing satellite game");
|
||||||
|
|
||||||
var MAX_RANGE = 50.0;
|
var MAX_RANGE = 50.0;
|
||||||
var Y_AXIS = {
|
var Y_AXIS = {
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -36,6 +38,10 @@ SatelliteGame = function() {
|
||||||
var ZONE_DIM = 100.0;
|
var ZONE_DIM = 100.0;
|
||||||
var LIGHT_INTENSITY = 1.5;
|
var LIGHT_INTENSITY = 1.5;
|
||||||
|
|
||||||
|
var center, distance;
|
||||||
|
var earth;
|
||||||
|
|
||||||
|
|
||||||
Earth = function(position, size) {
|
Earth = function(position, size) {
|
||||||
this.earth = Entities.addEntity({
|
this.earth = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
|
@ -68,7 +74,7 @@ SatelliteGame = function() {
|
||||||
this.clouds = Entities.addEntity({
|
this.clouds = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
shapeType: 'sphere',
|
shapeType: 'sphere',
|
||||||
modelURL: URL + "clouds.fbx?i=2",
|
modelURL: URL + "clouds.fbx",
|
||||||
position: position,
|
position: position,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: size + CLOUDS_OFFSET,
|
x: size + CLOUDS_OFFSET,
|
||||||
|
@ -101,16 +107,42 @@ SatelliteGame = function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.cleanup = function() {
|
this.cleanup = function() {
|
||||||
|
print('cleaning up earth models');
|
||||||
Entities.deleteEntity(this.clouds);
|
Entities.deleteEntity(this.clouds);
|
||||||
Entities.deleteEntity(this.earth);
|
Entities.deleteEntity(this.earth);
|
||||||
Entities.deleteEntity(this.zone);
|
Entities.deleteEntity(this.zone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create earth model
|
|
||||||
var center = Vec3.sum(Camera.getPosition(), Vec3.multiply(MAX_RANGE, Quat.getFront(Camera.getOrientation())));
|
this.init = function() {
|
||||||
var distance = Vec3.length(Vec3.subtract(center, Camera.getPosition()));
|
if (this.isActive) {
|
||||||
var earth = new Earth(center, EARTH_SIZE);
|
this.quitGame();
|
||||||
|
}
|
||||||
|
var confirmed = Window.confirm("Start satellite game?");
|
||||||
|
if (!confirmed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isActive = true;
|
||||||
|
MyAvatar.position = {
|
||||||
|
x: 1000,
|
||||||
|
y: 1000,
|
||||||
|
z: 1000
|
||||||
|
};
|
||||||
|
Camera.setPosition({
|
||||||
|
x: 1000,
|
||||||
|
y: 1000,
|
||||||
|
z: 1000
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create earth model
|
||||||
|
center = Vec3.sum(Camera.getPosition(), Vec3.multiply(MAX_RANGE, Quat.getFront(Camera.getOrientation())));
|
||||||
|
distance = Vec3.length(Vec3.subtract(center, Camera.getPosition()));
|
||||||
|
earth = new Earth(center, EARTH_SIZE);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var satellites = [];
|
var satellites = [];
|
||||||
var SATELLITE_SIZE = 2.0;
|
var SATELLITE_SIZE = 2.0;
|
||||||
|
@ -257,12 +289,16 @@ SatelliteGame = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.endGame = function() {
|
this.quitGame = function() {
|
||||||
|
print("ending satellite game");
|
||||||
|
this.isActive = false;
|
||||||
|
|
||||||
for (var i = 0; i < satellites.length; i++) {
|
for (var i = 0; i < satellites.length; i++) {
|
||||||
Entities.deleteEntity(satellites[i].satellite);
|
Entities.deleteEntity(satellites[i].satellite);
|
||||||
satellites[i].arrow.cleanup();
|
satellites[i].arrow.cleanup();
|
||||||
}
|
}
|
||||||
earth.cleanup();
|
earth.cleanup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,6 +319,7 @@ SatelliteGame = function() {
|
||||||
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
Controller.mouseMoveEvent.connect(mouseMoveEvent);
|
||||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
Script.scriptEnding.connect(this.endGame);
|
Script.scriptEnding.connect(this.quitGame);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
515
examples/example/planets-ui.js
Normal file
515
examples/example/planets-ui.js
Normal file
|
@ -0,0 +1,515 @@
|
||||||
|
//
|
||||||
|
// widgets-example.js
|
||||||
|
// games
|
||||||
|
//
|
||||||
|
// Copyright 2015 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 ICONS_URL = 'https://s3.amazonaws.com/hifi-public/marketplace/hificontent/Scripts/planets/images/';
|
||||||
|
|
||||||
|
var panelX = 1250;
|
||||||
|
var panelY = 500;
|
||||||
|
var panelWidth = 50;
|
||||||
|
var panelHeight = 210;
|
||||||
|
|
||||||
|
Script.include('../libraries/uiwidgets.js');
|
||||||
|
|
||||||
|
UI.setDefaultVisibility(true);
|
||||||
|
|
||||||
|
var ICON_WIDTH = 40.0;
|
||||||
|
var ICON_HEIGHT = 40.0;
|
||||||
|
var ICON_COLOR = UI.rgba(45, 45, 45, 0.7);
|
||||||
|
var FOCUSED_COLOR = UI.rgba(250, 250, 250, 1.0);
|
||||||
|
|
||||||
|
var PANEL_BACKGROUND_COLOR = UI.rgba(120, 120, 120, 0.8);
|
||||||
|
|
||||||
|
var PANEL_PADDING = 7.0;
|
||||||
|
var PANEL_BORDER = 12.0;
|
||||||
|
var SUBPANEL_GAP = 1.0;
|
||||||
|
|
||||||
|
var icons = [];
|
||||||
|
|
||||||
|
function addImage(panel, iconId) {
|
||||||
|
var icon = panel.add(new UI.Image({
|
||||||
|
'imageURL': ICONS_URL + iconId + '.svg',
|
||||||
|
'width': ICON_WIDTH,
|
||||||
|
'height': ICON_HEIGHT,
|
||||||
|
'color': ICON_COLOR,
|
||||||
|
'alpha': ICON_COLOR.a
|
||||||
|
}));
|
||||||
|
icons.push(icon);
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var panels = [];
|
||||||
|
|
||||||
|
function addPanel(properties) {
|
||||||
|
properties.background = properties.background || {};
|
||||||
|
properties.background.backgroundColor = properties.background.backgroundColor ||
|
||||||
|
PANEL_BACKGROUND_COLOR;
|
||||||
|
properties.background.backgroundAlpha = properties.background.backgroundAlpha ||
|
||||||
|
PANEL_BACKGROUND_COLOR.a;
|
||||||
|
properties.padding = properties.padding || {
|
||||||
|
x: PANEL_PADDING,
|
||||||
|
y: PANEL_PADDING
|
||||||
|
};
|
||||||
|
properties.border = properties.border || {
|
||||||
|
x: PANEL_BORDER,
|
||||||
|
y: PANEL_BORDER
|
||||||
|
};
|
||||||
|
|
||||||
|
var panel = new UI.WidgetStack(properties);
|
||||||
|
panels.push(panel);
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeDraggable(panel, target) {
|
||||||
|
if (!target) {
|
||||||
|
target = panel;
|
||||||
|
}
|
||||||
|
var dragStart = null;
|
||||||
|
var initialPos = null;
|
||||||
|
|
||||||
|
panel.addAction('onDragBegin', function(event) {
|
||||||
|
dragStart = {
|
||||||
|
x: event.x,
|
||||||
|
y: event.y
|
||||||
|
};
|
||||||
|
initialPos = {
|
||||||
|
x: target.position.x,
|
||||||
|
y: target.position.y
|
||||||
|
};
|
||||||
|
});
|
||||||
|
panel.addAction('onDragUpdate', function(event) {
|
||||||
|
target.setPosition(
|
||||||
|
initialPos.x + event.x - dragStart.x,
|
||||||
|
initialPos.y + event.y - dragStart.y
|
||||||
|
);
|
||||||
|
UI.updateLayout();
|
||||||
|
});
|
||||||
|
panel.addAction('onDragEnd', function() {
|
||||||
|
dragStart = dragEnd = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setText(text) {
|
||||||
|
return function() {
|
||||||
|
demoLabel.setText(text);
|
||||||
|
UI.updateLayout();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function join(obj) {
|
||||||
|
var s = "{";
|
||||||
|
var sep = "\n";
|
||||||
|
for (var k in obj) {
|
||||||
|
s += sep + k + ": " + ("" + obj[k]).replace("\n", "\n");
|
||||||
|
sep = ",\n";
|
||||||
|
}
|
||||||
|
if (s.length > 1)
|
||||||
|
return s + " }";
|
||||||
|
return s + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
setText = undefined;
|
||||||
|
|
||||||
|
var tooltipWidget = new UI.Label({
|
||||||
|
text: "<tooltip>",
|
||||||
|
width: 500,
|
||||||
|
height: 20,
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
|
||||||
|
function addTooltip(widget, text) {
|
||||||
|
widget.addAction('onMouseOver', function(event, widget) {
|
||||||
|
tooltipWidget.setVisible(true);
|
||||||
|
tooltipWidget.setPosition(widget.position.x + widget.getWidth() + 20, widget.position.y + 10);
|
||||||
|
tooltipWidget.setText(text);
|
||||||
|
UI.updateLayout();
|
||||||
|
});
|
||||||
|
widget.addAction('onMouseExit', function() {
|
||||||
|
tooltipWidget.setVisible(false);
|
||||||
|
UI.updateLayout();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var mainPanel = addPanel({
|
||||||
|
dir: '+y'
|
||||||
|
});
|
||||||
|
makeDraggable(mainPanel);
|
||||||
|
mainPanel.setPosition(1200, 250);
|
||||||
|
mainPanel.setVisible(true);
|
||||||
|
|
||||||
|
var systemViewButton = addImage(mainPanel, 'solarsystems');
|
||||||
|
var zoomButton = addImage(mainPanel, 'magnifier');
|
||||||
|
var satelliteButton = addImage(mainPanel, 'satellite');
|
||||||
|
var settingsButton = addImage(mainPanel, 'settings');
|
||||||
|
var stopButton = addImage(mainPanel, 'close');
|
||||||
|
|
||||||
|
addTooltip(systemViewButton, "system view");
|
||||||
|
addTooltip(zoomButton, "zoom");
|
||||||
|
addTooltip(satelliteButton, "satelite view");
|
||||||
|
addTooltip(settingsButton, "settings");
|
||||||
|
addTooltip(stopButton, "exit");
|
||||||
|
|
||||||
|
var systemViewPanel = addPanel({
|
||||||
|
dir: '+x',
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
var restartButton = addImage(systemViewPanel, 'refresh');
|
||||||
|
var pauseButton = addImage(systemViewPanel, 'playpause');
|
||||||
|
var rideButton = addImage(systemViewPanel, 'rocket');
|
||||||
|
|
||||||
|
var tweening, tweeningPaused;
|
||||||
|
Script.include('https://hifi-staff.s3.amazonaws.com/bridget/tween.js');
|
||||||
|
|
||||||
|
|
||||||
|
pauseButton.addAction('onClick', function() {
|
||||||
|
if (tweening) {
|
||||||
|
if (!tweeningPaused) {
|
||||||
|
tweeningPaused = true;
|
||||||
|
} else {
|
||||||
|
tweeningPaused = false;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!paused) {
|
||||||
|
pause();
|
||||||
|
} else {
|
||||||
|
resume();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Allow to toggle pause with spacebar
|
||||||
|
function keyPressEvent(event) {
|
||||||
|
if (event.text == "SPACE") {
|
||||||
|
if (!paused) {
|
||||||
|
pause();
|
||||||
|
} else {
|
||||||
|
resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rideButton.addAction('onClick', function() {
|
||||||
|
if (!paused) {
|
||||||
|
pause();
|
||||||
|
}
|
||||||
|
if (tweening) {
|
||||||
|
tweening = false;
|
||||||
|
tweeningPaused = true;
|
||||||
|
restart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var confirmed = Window.confirm('Ride through the solar system?');
|
||||||
|
if (confirmed) {
|
||||||
|
init();
|
||||||
|
tweening = true;
|
||||||
|
tweeningPaused = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
restartButton.addAction('onClick', function() {
|
||||||
|
restart();
|
||||||
|
tweening = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
var zoomPanel = addPanel({
|
||||||
|
dir: '+x',
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
var zoomButtons = [];
|
||||||
|
for (var i = 0; i < planets.length; ++i) {
|
||||||
|
var label = zoomPanel.add(new UI.Label({
|
||||||
|
text: planets[i].name,
|
||||||
|
width: 80,
|
||||||
|
height: 20
|
||||||
|
}));
|
||||||
|
zoomButtons.push(label);
|
||||||
|
UI.updateLayout();
|
||||||
|
}
|
||||||
|
UI.updateLayout();
|
||||||
|
|
||||||
|
|
||||||
|
var zoomView = false;
|
||||||
|
zoomButtons.forEach(function(button, i) {
|
||||||
|
var planet = planets[i];
|
||||||
|
button.addAction('onClick', function() {
|
||||||
|
if (!planets[i].isZoomed) {
|
||||||
|
planet.zoom();
|
||||||
|
planet.isZoomed = true;
|
||||||
|
zoomView = true;
|
||||||
|
} else {
|
||||||
|
MyAvatar.position = startingPosition;
|
||||||
|
Camera.setPosition(cameraStart);
|
||||||
|
planet.isZoomed = false;
|
||||||
|
zoomView = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var settingsPanel = addPanel({
|
||||||
|
dir: '+y',
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
|
||||||
|
function addCheckbox(parent, label, labelWidth, enabled, onValueChanged) {
|
||||||
|
var layout = parent.add(new UI.WidgetStack({
|
||||||
|
dir: '+x',
|
||||||
|
visible: true,
|
||||||
|
backgroundAlpha: 0.0
|
||||||
|
}));
|
||||||
|
var label = layout.add(new UI.Label({
|
||||||
|
text: label,
|
||||||
|
width: labelWidth,
|
||||||
|
height: 20,
|
||||||
|
backgroundAlpha: 0.0
|
||||||
|
}));
|
||||||
|
|
||||||
|
var defaultColor = UI.rgb(10, 10, 10);
|
||||||
|
|
||||||
|
var checkbox = layout.add(new UI.Checkbox({
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
padding: {
|
||||||
|
x: 3,
|
||||||
|
y: 3
|
||||||
|
},
|
||||||
|
backgroundColor: defaultColor,
|
||||||
|
backgroundAlpha: 0.9,
|
||||||
|
checked: enabled,
|
||||||
|
onValueChanged: onValueChanged
|
||||||
|
}));
|
||||||
|
|
||||||
|
checkbox.label = label;
|
||||||
|
checkbox.layout = layout;
|
||||||
|
checkbox.setValue = function(value) {
|
||||||
|
checkbox.setChecked(value);
|
||||||
|
}
|
||||||
|
return checkbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addSlider(parent, label, labelWidth, defaultValue, min, max, valueChanged) {
|
||||||
|
var layout = parent.add(new UI.WidgetStack({
|
||||||
|
dir: '+x',
|
||||||
|
visible: true
|
||||||
|
}));
|
||||||
|
var label = layout.add(new UI.Label({
|
||||||
|
text: label,
|
||||||
|
width: labelWidth,
|
||||||
|
height: 27
|
||||||
|
}));
|
||||||
|
var display = layout.add(new UI.Label({
|
||||||
|
text: " ",
|
||||||
|
width: 50,
|
||||||
|
height: 27
|
||||||
|
}));
|
||||||
|
var slider = layout.add(new UI.Slider({
|
||||||
|
value: defaultValue,
|
||||||
|
maxValue: max,
|
||||||
|
minValue: min,
|
||||||
|
width: 300,
|
||||||
|
height: 20,
|
||||||
|
backgroundColor: UI.rgb(10, 10, 10),
|
||||||
|
backgroundAlpha: 1.0,
|
||||||
|
slider: { // slider knob
|
||||||
|
width: 30,
|
||||||
|
height: 18,
|
||||||
|
backgroundColor: UI.rgb(120, 120, 120),
|
||||||
|
backgroundAlpha: 1.0
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
slider.addAction('onDoubleClick', function() {
|
||||||
|
slider.setValue(defaultValue);
|
||||||
|
UI.updateLayout();
|
||||||
|
});
|
||||||
|
display.setText("" + (+slider.getValue().toFixed(2)));
|
||||||
|
slider.onValueChanged = function(value) {
|
||||||
|
valueChanged(value);
|
||||||
|
display.setText("" + (+value.toFixed(2)));
|
||||||
|
UI.updateLayout();
|
||||||
|
}
|
||||||
|
slider.label = label;
|
||||||
|
slider.layout = layout;
|
||||||
|
return slider;
|
||||||
|
}
|
||||||
|
|
||||||
|
settingsPanel.showTrailsButton = addCheckbox(settingsPanel, "show trails", 120, trailsEnabled, function(value) {
|
||||||
|
trailsEnabled = value;
|
||||||
|
if (trailsEnabled) {
|
||||||
|
for (var i = 0; i < planets.length; ++i) {
|
||||||
|
planets[i].resetTrails();
|
||||||
|
}
|
||||||
|
//if trails are off and we've already created trails, remove existing trails
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < planets.length; ++i) {
|
||||||
|
planets[i].clearTrails();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var g_multiplier = 1.0;
|
||||||
|
settingsPanel.gravitySlider = addSlider(settingsPanel, "gravity scale ", 200, g_multiplier, 0.0, 5.0, function(value) {
|
||||||
|
g_multiplier = value;
|
||||||
|
GRAVITY = REFERENCE_GRAVITY * g_multiplier;
|
||||||
|
});
|
||||||
|
|
||||||
|
var period_multiplier = 1.0;
|
||||||
|
var last_alpha = period_multiplier;
|
||||||
|
|
||||||
|
settingsPanel.periodSlider = addSlider(settingsPanel, "orbital period scale ", 200, period_multiplier, 0.0, 3.0, function(value) {
|
||||||
|
period_multiplier = value;
|
||||||
|
changePeriod(period_multiplier);
|
||||||
|
});
|
||||||
|
|
||||||
|
function changePeriod(alpha) {
|
||||||
|
var ratio = last_alpha / alpha;
|
||||||
|
GRAVITY = Math.pow(ratio, 2.0) * GRAVITY;
|
||||||
|
for (var i = 0; i < planets.length; ++i) {
|
||||||
|
planets[i].period = ratio * planets[i].period;
|
||||||
|
planets[i].velocity = Vec3.multiply(ratio, planets[i].velocity);
|
||||||
|
planets[i].resetTrails();
|
||||||
|
}
|
||||||
|
last_alpha = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
var satelliteGame;
|
||||||
|
satelliteButton.addAction('onClick', function() {
|
||||||
|
if (satelliteGame && satelliteGame.isActive) {
|
||||||
|
MyAvatar.position = startingPosition;
|
||||||
|
satelliteGame.quitGame();
|
||||||
|
if (paused) {
|
||||||
|
resume();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pause();
|
||||||
|
satelliteGame = new SatelliteCreator();
|
||||||
|
satelliteGame.init();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var subpanels = [systemViewPanel, zoomPanel, settingsPanel];
|
||||||
|
|
||||||
|
function hideSubpanelsExcept(panel) {
|
||||||
|
subpanels.forEach(function(x) {
|
||||||
|
if (x != panel) {
|
||||||
|
x.setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function attachPanel(panel, button) {
|
||||||
|
button.addAction('onClick', function() {
|
||||||
|
hideSubpanelsExcept(panel);
|
||||||
|
panel.setVisible(!panel.isVisible());
|
||||||
|
UI.updateLayout();
|
||||||
|
})
|
||||||
|
|
||||||
|
UI.addAttachment(panel, button, function(target, rel) {
|
||||||
|
target.setPosition(
|
||||||
|
rel.position.x - (target.getWidth() + target.border.x + SUBPANEL_GAP),
|
||||||
|
rel.position.y - target.border.y
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
attachPanel(systemViewPanel, systemViewButton);
|
||||||
|
attachPanel(zoomPanel, zoomButton);
|
||||||
|
attachPanel(settingsPanel, settingsButton);
|
||||||
|
|
||||||
|
|
||||||
|
var addColorToggle = function(widget) {
|
||||||
|
widget.addAction('onMouseOver', function() {
|
||||||
|
widget.setColor(FOCUSED_COLOR);
|
||||||
|
});
|
||||||
|
widget.addAction('onMouseExit', function() {
|
||||||
|
widget.setColor(ICON_COLOR);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
systemViewPanel.addAction('onMouseOver', function() {
|
||||||
|
hideSubpanelsExcept(systemViewPanel);
|
||||||
|
UI.updateLayout();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
zoomButton.addAction('onClick', function() {
|
||||||
|
if (zoomView) {
|
||||||
|
restart();
|
||||||
|
}
|
||||||
|
hideSubpanelsExcept(zoomPanel);
|
||||||
|
UI.updateLayout();
|
||||||
|
});
|
||||||
|
UI.updateLayout();
|
||||||
|
|
||||||
|
stopButton.addAction('onClick', function() {
|
||||||
|
teardown();
|
||||||
|
Script.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Panel drag behavior
|
||||||
|
// (click + drag on border to drag)
|
||||||
|
(function() {
|
||||||
|
var dragged = null;
|
||||||
|
this.startDrag = function(dragAction) {
|
||||||
|
dragged = dragAction;
|
||||||
|
}
|
||||||
|
this.updateDrag = function(event) {
|
||||||
|
if (dragged) {
|
||||||
|
print("Update drag");
|
||||||
|
dragged.updateDrag(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.clearDrag = function(event) {
|
||||||
|
if (dragged)
|
||||||
|
print("End drag");
|
||||||
|
dragged = null;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
var buttons = icons;
|
||||||
|
|
||||||
|
buttons.map(addColorToggle);
|
||||||
|
panels.map(function(panel) {
|
||||||
|
makeDraggable(panel, mainPanel);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cleanup script resources
|
||||||
|
function teardown() {
|
||||||
|
UI.teardown();
|
||||||
|
if (satelliteGame) {
|
||||||
|
satelliteGame.quitGame();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UI.debug.setVisible(false);
|
||||||
|
|
||||||
|
var inputHandler = {
|
||||||
|
onMouseMove: function(event) {
|
||||||
|
updateDrag(event);
|
||||||
|
UI.handleMouseMove(event);
|
||||||
|
},
|
||||||
|
onMousePress: function(event) {
|
||||||
|
UI.handleMousePress(event);
|
||||||
|
},
|
||||||
|
onMouseRelease: function(event) {
|
||||||
|
clearDrag(event);
|
||||||
|
UI.handleMouseRelease(event);
|
||||||
|
},
|
||||||
|
onMouseDoublePress: function(event) {
|
||||||
|
UI.handleMouseDoublePress(event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Controller.mousePressEvent.connect(inputHandler.onMousePress);
|
||||||
|
Controller.mouseMoveEvent.connect(inputHandler.onMouseMove);
|
||||||
|
Controller.mouseReleaseEvent.connect(inputHandler.onMouseRelease);
|
||||||
|
Controller.mouseDoublePressEvent.connect(inputHandler.onMouseDoublePress);
|
||||||
|
|
||||||
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(teardown);
|
File diff suppressed because it is too large
Load diff
251
examples/fireworks.js
Normal file
251
examples/fireworks.js
Normal file
|
@ -0,0 +1,251 @@
|
||||||
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
var fireSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Guns/GUN-SHOT2.raw");
|
||||||
|
var audioOptions = {
|
||||||
|
volume: 0.9,
|
||||||
|
position: Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()))
|
||||||
|
};
|
||||||
|
|
||||||
|
var DISTANCE_FROM_CAMERA = 7.0;
|
||||||
|
|
||||||
|
var bluePalette = [{
|
||||||
|
red: 0,
|
||||||
|
green: 206,
|
||||||
|
blue: 209
|
||||||
|
}, {
|
||||||
|
red: 173,
|
||||||
|
green: 216,
|
||||||
|
blue: 230
|
||||||
|
}, {
|
||||||
|
red: 0,
|
||||||
|
green: 191,
|
||||||
|
blue: 255
|
||||||
|
}];
|
||||||
|
|
||||||
|
var greenPalette = [{
|
||||||
|
red: 152,
|
||||||
|
green: 251,
|
||||||
|
blue: 152
|
||||||
|
}, {
|
||||||
|
red: 127,
|
||||||
|
green: 255,
|
||||||
|
blue: 0
|
||||||
|
}, {
|
||||||
|
red: 50,
|
||||||
|
green: 205,
|
||||||
|
blue: 50
|
||||||
|
}];
|
||||||
|
|
||||||
|
var redPalette = [{
|
||||||
|
red: 255,
|
||||||
|
green: 20,
|
||||||
|
blue: 147
|
||||||
|
}, {
|
||||||
|
red: 255,
|
||||||
|
green: 69,
|
||||||
|
blue: 0
|
||||||
|
}, {
|
||||||
|
red: 255,
|
||||||
|
green: 90,
|
||||||
|
blue: 120
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
var COLOR_RED = {red: 255, green: 0, blue: 0 };
|
||||||
|
var COLOR_GREEN = {red: 0, green: 255, blue: 0};
|
||||||
|
var COLOR_BLUE = {red: 0, green: 0, blue: 255};
|
||||||
|
var iconsX = 700;
|
||||||
|
var iconsY = 660;
|
||||||
|
var ICON_SIZE = 30;
|
||||||
|
|
||||||
|
var redIcon = Overlays.addOverlay("text", {
|
||||||
|
backgroundColor: COLOR_RED,
|
||||||
|
x: iconsX,
|
||||||
|
y: iconsY,
|
||||||
|
width: ICON_SIZE,
|
||||||
|
height: ICON_SIZE,
|
||||||
|
alpha: 0.0,
|
||||||
|
backgroundAlpha: 1.0,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
var greenIcon = Overlays.addOverlay("text", {
|
||||||
|
backgroundColor: COLOR_GREEN,
|
||||||
|
x: iconsX + 50,
|
||||||
|
y: iconsY,
|
||||||
|
width: ICON_SIZE,
|
||||||
|
height: ICON_SIZE,
|
||||||
|
alpha: 0.0,
|
||||||
|
backgroundAlpha: 1.0,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
var blueIcon = Overlays.addOverlay("text", {
|
||||||
|
backgroundColor: COLOR_BLUE,
|
||||||
|
x: iconsX + 100,
|
||||||
|
y: iconsY,
|
||||||
|
width: ICON_SIZE,
|
||||||
|
height: ICON_SIZE,
|
||||||
|
alpha: 0.0,
|
||||||
|
backgroundAlpha: 1.0,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var NUM_BURSTS = 11;
|
||||||
|
var SPEED = 6.0;
|
||||||
|
|
||||||
|
var rockets = [];
|
||||||
|
Rocket = function(point, colorPalette) {
|
||||||
|
//default to blue palette if no palette passed in
|
||||||
|
this.colors = colorPalette;
|
||||||
|
this.point = point;
|
||||||
|
this.bursts = [];
|
||||||
|
this.burst = false;
|
||||||
|
|
||||||
|
this.emitRate = randInt(80, 120);
|
||||||
|
this.emitStrength = randInt(5.0, 7.0);
|
||||||
|
|
||||||
|
this.rocket = Entities.addEntity({
|
||||||
|
type: "Sphere",
|
||||||
|
position: this.point,
|
||||||
|
dimensions: {
|
||||||
|
x: 0.07,
|
||||||
|
y: 0.07,
|
||||||
|
z: 0.07
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 240,
|
||||||
|
green: 240,
|
||||||
|
blue: 240
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.animationSettings = JSON.stringify({
|
||||||
|
fps: 40,
|
||||||
|
frameIndex: 0,
|
||||||
|
running: true,
|
||||||
|
firstFrame: 0,
|
||||||
|
lastFrame: 20,
|
||||||
|
loop: false
|
||||||
|
});
|
||||||
|
|
||||||
|
this.direction = {
|
||||||
|
x: randFloat(-0.4, 0.4),
|
||||||
|
y: 1.0,
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
this.time = 0.0;
|
||||||
|
this.timeout = randInt(15, 40);
|
||||||
|
};
|
||||||
|
|
||||||
|
Rocket.prototype.update = function(deltaTime) {
|
||||||
|
this.time++;
|
||||||
|
|
||||||
|
Entities.editEntity(this.rocket, {
|
||||||
|
velocity: Vec3.multiply(SPEED, this.direction)
|
||||||
|
});
|
||||||
|
var position = Entities.getEntityProperties(this.rocket).position;
|
||||||
|
|
||||||
|
if (this.time > this.timeout) {
|
||||||
|
this.explode(position);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Rocket.prototype.explode = function(position) {
|
||||||
|
Audio.playSound(fireSound, audioOptions);
|
||||||
|
Entities.editEntity(this.rocket, {
|
||||||
|
velocity: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var colorIndex = 0;
|
||||||
|
for (var i = 0; i < NUM_BURSTS; ++i) {
|
||||||
|
var color = this.colors[colorIndex];
|
||||||
|
print(JSON.stringify(color));
|
||||||
|
this.bursts.push(Entities.addEntity({
|
||||||
|
type: "ParticleEffect",
|
||||||
|
animationSettings: this.animationSettings,
|
||||||
|
position: position,
|
||||||
|
textures: 'https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png',
|
||||||
|
emitRate: this.emitRate,
|
||||||
|
emitStrength: this.emitStrength,
|
||||||
|
emitDirection: {
|
||||||
|
x: Math.pow(-1, i) * randFloat(0.0, 1.4),
|
||||||
|
y: 1.0,
|
||||||
|
z: 0.0
|
||||||
|
},
|
||||||
|
color: color,
|
||||||
|
lifespan: 1.0,
|
||||||
|
visible: true,
|
||||||
|
locked: false
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (colorIndex < this.colors.length - 1) {
|
||||||
|
colorIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.burst = true;
|
||||||
|
Entities.deleteEntity(this.rocket);
|
||||||
|
};
|
||||||
|
|
||||||
|
//var lastLoudness;
|
||||||
|
var LOUDNESS_RADIUS_RATIO = 10;
|
||||||
|
|
||||||
|
function update(deltaTime) {
|
||||||
|
for (var i = 0; i < rockets.length; i++) {
|
||||||
|
if (!rockets[i].burst) {
|
||||||
|
rockets[i].update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function randFloat(min, max) {
|
||||||
|
return Math.random() * (max - min) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
function randInt(min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeWorldPoint(event) {
|
||||||
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
var addVector = Vec3.multiply(Vec3.normalize(pickRay.direction), DISTANCE_FROM_CAMERA);
|
||||||
|
return Vec3.sum(Camera.getPosition(), addVector);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mousePressEvent(event) {
|
||||||
|
var clickedOverlay = Overlays.getOverlayAtPoint({
|
||||||
|
x: event.x,
|
||||||
|
y: event.y
|
||||||
|
});
|
||||||
|
if(clickedOverlay === redIcon) {
|
||||||
|
rockets.push(new Rocket(computeWorldPoint(event), redPalette));
|
||||||
|
} else if (clickedOverlay === greenIcon) {
|
||||||
|
rockets.push(new Rocket(computeWorldPoint(event), greenPalette));
|
||||||
|
} else if (clickedOverlay === blueIcon) {
|
||||||
|
rockets.push(new Rocket(computeWorldPoint(event), bluePalette));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
Overlays.deleteOverlay(redIcon);
|
||||||
|
Overlays.deleteOverlay(greenIcon);
|
||||||
|
Overlays.deleteOverlay(blueIcon);
|
||||||
|
for (var i = 0; i < rockets.length; ++i) {
|
||||||
|
Entities.deleteEntity(rockets[i].rocket);
|
||||||
|
for (var j = 0; j < NUM_BURSTS; ++j) {
|
||||||
|
Entities.deleteEntity(rockets[i].bursts[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.update.connect(update);
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
Controller.mousePressEvent.connect(mousePressEvent);
|
|
@ -5,6 +5,9 @@
|
||||||
// Created by Zander Otavka on 7/24/15
|
// Created by Zander Otavka on 7/24/15
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 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
|
||||||
|
//
|
||||||
// Manage overlays with object oriented goodness, instead of ugly `Overlays.h` methods.
|
// Manage overlays with object oriented goodness, instead of ugly `Overlays.h` methods.
|
||||||
// Instead of:
|
// Instead of:
|
||||||
//
|
//
|
||||||
|
@ -22,39 +25,59 @@
|
||||||
// ...
|
// ...
|
||||||
// billboard.destroy();
|
// billboard.destroy();
|
||||||
//
|
//
|
||||||
// See more on usage below.
|
// More on usage below. Examples in `examples/example/overlayPanelExample.js`.
|
||||||
//
|
//
|
||||||
// Note that including this file will delete Overlays from the global scope. All the
|
// Note that including this file will delete `Overlays` from the global scope. All the
|
||||||
// functionality of Overlays is represented here, just better. If you try to use Overlays in
|
// functionality of `Overlays` is represented here, just better. If you try to use `Overlays`
|
||||||
// tandem, there may be performance problems or nasty surprises.
|
// in tandem, there may be performance problems or nasty surprises.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Delete `Overlays` from the global scope.
|
// Delete `Overlays` from the global scope.
|
||||||
var Overlays = this.Overlays;
|
var Overlays = this.Overlays;
|
||||||
delete this.Overlays;
|
delete this.Overlays;
|
||||||
|
|
||||||
|
|
||||||
|
var ABSTRACT = null;
|
||||||
|
|
||||||
var overlays = {};
|
var overlays = {};
|
||||||
var panels = {};
|
var panels = {};
|
||||||
|
|
||||||
var overlayTypes;
|
var overlayTypes = {};
|
||||||
|
|
||||||
// Abstract overlay types
|
|
||||||
var Overlay,
|
|
||||||
Overlay2D,
|
|
||||||
Base3DOverlay,
|
|
||||||
Planar3DOverlay,
|
|
||||||
Billboard3DOverlay,
|
|
||||||
Volume3DOverlay;
|
|
||||||
|
|
||||||
// Multiple inheritance mixins
|
function generateOverlayClass(superclass, type, properties) {
|
||||||
var PanelAttachable,
|
var that;
|
||||||
Billboardable;
|
if (type == ABSTRACT) {
|
||||||
|
that = function(type, params) {
|
||||||
|
superclass.call(this, type, params);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
that = function(params) {
|
||||||
|
superclass.call(this, type, params);
|
||||||
|
};
|
||||||
|
overlayTypes[type] = that;
|
||||||
|
}
|
||||||
|
|
||||||
|
that.prototype = new superclass();
|
||||||
|
that.prototype.constructor = that;
|
||||||
|
|
||||||
|
properties.forEach(function(prop) {
|
||||||
|
Object.defineProperty(that.prototype, prop, {
|
||||||
|
get: function() {
|
||||||
|
return Overlays.getProperty(this._id, prop);
|
||||||
|
},
|
||||||
|
set: function(newValue) {
|
||||||
|
var keyValuePair = {};
|
||||||
|
keyValuePair[prop] = newValue;
|
||||||
|
this.setProperties(keyValuePair);
|
||||||
|
},
|
||||||
|
configurable: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a new JavaScript object for an overlay of given ID.
|
// Create a new JavaScript object for an overlay of given ID.
|
||||||
|
@ -137,249 +160,131 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
var Overlay = (function() {
|
||||||
// Perform global scoped operations on overlays, such as finding by ray intersection.
|
var that = function(type, params) {
|
||||||
//
|
if (type && params) {
|
||||||
OverlayManager = {
|
this._id = Overlays.addOverlay(type, params);
|
||||||
findOnRay: function(pickRay, knownOverlaysOnly, searchList) {
|
overlays[this._id] = this;
|
||||||
var rayPickResult = Overlays.findRayIntersection(pickRay);
|
|
||||||
if (rayPickResult.intersects) {
|
|
||||||
return findOverlay(rayPickResult.overlayID, knownOverlaysOnly, searchList);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
findAtPoint: function(point, knownOverlaysOnly, searchList) {
|
|
||||||
var foundID = Overlays.getOverlayAtPoint(point);
|
|
||||||
if (foundID) {
|
|
||||||
return findOverlay(foundID, knownOverlaysOnly, searchList);
|
|
||||||
} else {
|
} else {
|
||||||
var pickRay = Camera.computePickRay(point.x, point.y);
|
this._id = 0;
|
||||||
return OverlayManager.findOnRay(pickRay, knownOverlaysOnly, searchList);
|
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
makeSearchList: function(array) {
|
|
||||||
var searchList = {};
|
|
||||||
array.forEach(function(object) {
|
|
||||||
searchList[object._id] = object;
|
|
||||||
});
|
|
||||||
return searchList;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
that.prototype.constructor = that;
|
||||||
|
|
||||||
//
|
Object.defineProperty(that.prototype, "isLoaded", {
|
||||||
// Object oriented abstraction layer for overlays.
|
get: function() {
|
||||||
//
|
return Overlays.isLoaded(this._id);
|
||||||
// Usage:
|
|
||||||
// // Create an overlay
|
|
||||||
// var billboard = new Image3DOverlay({
|
|
||||||
// visible: true,
|
|
||||||
// isFacingAvatar: true,
|
|
||||||
// ignoreRayIntersections: false
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // Get a property
|
|
||||||
// var isVisible = billboard.visible;
|
|
||||||
//
|
|
||||||
// // Set a single property
|
|
||||||
// billboard.position = { x: 1, y: 3, z: 2 };
|
|
||||||
//
|
|
||||||
// // Set multiple properties at the same time
|
|
||||||
// billboard.setProperties({
|
|
||||||
// url: "http://images.com/overlayImage.jpg",
|
|
||||||
// dimensions: { x: 2, y: 2 }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // Clone an overlay
|
|
||||||
// var clonedBillboard = billboard.clone();
|
|
||||||
//
|
|
||||||
// // Remove an overlay from the world
|
|
||||||
// billboard.destroy();
|
|
||||||
//
|
|
||||||
// // Remember, there is a poor orphaned JavaScript object left behind. You should
|
|
||||||
// // remove any references to it so you don't accidentally try to modify an overlay that
|
|
||||||
// // isn't there.
|
|
||||||
// billboard = undefined;
|
|
||||||
//
|
|
||||||
(function() {
|
|
||||||
var ABSTRACT = null;
|
|
||||||
overlayTypes = {};
|
|
||||||
|
|
||||||
function generateOverlayClass(superclass, type, properties) {
|
|
||||||
var that;
|
|
||||||
if (type == ABSTRACT) {
|
|
||||||
that = function(type, params) {
|
|
||||||
superclass.call(this, type, params);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
that = function(params) {
|
|
||||||
superclass.call(this, type, params);
|
|
||||||
};
|
|
||||||
overlayTypes[type] = that;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
that.prototype = new superclass();
|
Object.defineProperty(that.prototype, "parentPanel", {
|
||||||
that.prototype.constructor = that;
|
get: function() {
|
||||||
|
return findPanel(Overlays.getParentPanel(this._id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
properties.forEach(function(prop) {
|
that.prototype.getTextSize = function(text) {
|
||||||
Object.defineProperty(that.prototype, prop, {
|
return Overlays.textSize(this._id, text);
|
||||||
get: function() {
|
};
|
||||||
return Overlays.getProperty(this._id, prop);
|
|
||||||
},
|
|
||||||
set: function(newValue) {
|
|
||||||
var keyValuePair = {};
|
|
||||||
keyValuePair[prop] = newValue;
|
|
||||||
this.setProperties(keyValuePair);
|
|
||||||
},
|
|
||||||
configurable: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return that;
|
that.prototype.setProperties = function(properties) {
|
||||||
}
|
Overlays.editOverlay(this._id, properties);
|
||||||
|
};
|
||||||
|
|
||||||
Overlay = (function() {
|
that.prototype.clone = function() {
|
||||||
var that = function(type, params) {
|
return makeOverlayFromId(Overlays.cloneOverlay(this._id));
|
||||||
if (type && params) {
|
};
|
||||||
this._id = Overlays.addOverlay(type, params);
|
|
||||||
overlays[this._id] = this;
|
|
||||||
} else {
|
|
||||||
this._id = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
that.prototype.constructor = that;
|
that.prototype.destroy = function() {
|
||||||
|
Overlays.deleteOverlay(this._id);
|
||||||
|
};
|
||||||
|
|
||||||
Object.defineProperty(that.prototype, "isLoaded", {
|
that.prototype.isPanelAttachable = function() {
|
||||||
get: function() {
|
return false;
|
||||||
return Overlays.isLoaded(this._id);
|
};
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.defineProperty(that.prototype, "parentPanel", {
|
return generateOverlayClass(that, ABSTRACT, [
|
||||||
get: function() {
|
"alpha", "glowLevel", "pulseMax", "pulseMin", "pulsePeriod", "glowLevelPulse",
|
||||||
return findPanel(Overlays.getParentPanel(this._id));
|
"alphaPulse", "colorPulse", "visible", "anchor"
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
that.prototype.getTextSize = function(text) {
|
|
||||||
return Overlays.textSize(this._id, text);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.prototype.setProperties = function(properties) {
|
|
||||||
Overlays.editOverlay(this._id, properties);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.prototype.clone = function() {
|
|
||||||
return makeOverlayFromId(Overlays.cloneOverlay(this._id));
|
|
||||||
};
|
|
||||||
|
|
||||||
that.prototype.destroy = function() {
|
|
||||||
Overlays.deleteOverlay(this._id);
|
|
||||||
};
|
|
||||||
|
|
||||||
that.prototype.isPanelAttachable = function() {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
return generateOverlayClass(that, ABSTRACT, [
|
|
||||||
"alpha", "glowLevel", "pulseMax", "pulseMin", "pulsePeriod", "glowLevelPulse",
|
|
||||||
"alphaPulse", "colorPulse", "visible", "anchor"
|
|
||||||
]);
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Supports multiple inheritance of properties. Just `concat` them onto the end of the
|
|
||||||
// properties list.
|
|
||||||
PanelAttachable = ["offsetPosition", "offsetRotation", "offsetScale"];
|
|
||||||
Billboardable = ["isFacingAvatar"];
|
|
||||||
|
|
||||||
Overlay2D = generateOverlayClass(Overlay, ABSTRACT, [
|
|
||||||
"bounds", "x", "y", "width", "height"
|
|
||||||
]);
|
|
||||||
|
|
||||||
Base3DOverlay = generateOverlayClass(Overlay, ABSTRACT, [
|
|
||||||
"position", "lineWidth", "rotation", "isSolid", "isFilled", "isWire", "isDashedLine",
|
|
||||||
"ignoreRayIntersection", "drawInFront", "drawOnHUD"
|
|
||||||
]);
|
|
||||||
|
|
||||||
Planar3DOverlay = generateOverlayClass(Base3DOverlay, ABSTRACT, [
|
|
||||||
"dimensions"
|
|
||||||
]);
|
|
||||||
|
|
||||||
Billboard3DOverlay = generateOverlayClass(Planar3DOverlay, ABSTRACT, [
|
|
||||||
].concat(PanelAttachable).concat(Billboardable));
|
|
||||||
Billboard3DOverlay.prototype.isPanelAttachable = function() { return true; };
|
|
||||||
|
|
||||||
Volume3DOverlay = generateOverlayClass(Base3DOverlay, ABSTRACT, [
|
|
||||||
"dimensions"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Overlay2D, "image", [
|
|
||||||
"subImage", "imageURL"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Billboard3DOverlay, "image3d", [
|
|
||||||
"url", "subImage"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Overlay2D, "text", [
|
|
||||||
"font", "text", "backgroundColor", "backgroundAlpha", "leftMargin", "topMargin"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Billboard3DOverlay, "text3d", [
|
|
||||||
"text", "backgroundColor", "backgroundAlpha", "lineHeight", "leftMargin", "topMargin",
|
|
||||||
"rightMargin", "bottomMargin"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Volume3DOverlay, "cube", [
|
|
||||||
"borderSize"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Volume3DOverlay, "sphere", [
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Planar3DOverlay, "circle3d", [
|
|
||||||
"startAt", "endAt", "outerRadius", "innerRadius", "hasTickMarks",
|
|
||||||
"majorTickMarksAngle", "minorTickMarksAngle", "majorTickMarksLength",
|
|
||||||
"minorTickMarksLength", "majorTickMarksColor", "minorTickMarksColor"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Planar3DOverlay, "rectangle3d", [
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Base3DOverlay, "line3d", [
|
|
||||||
"start", "end"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Planar3DOverlay, "grid", [
|
|
||||||
"minorGridWidth", "majorGridEvery"
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Volume3DOverlay, "localmodels", [
|
|
||||||
]);
|
|
||||||
|
|
||||||
generateOverlayClass(Volume3DOverlay, "model", [
|
|
||||||
"url", "dimensions", "textures"
|
|
||||||
]);
|
]);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
ImageOverlay = overlayTypes["image"];
|
// Supports multiple inheritance of properties. Just `concat` them onto the end of the
|
||||||
Image3DOverlay = overlayTypes["image3d"];
|
// properties list.
|
||||||
TextOverlay = overlayTypes["text"];
|
var PanelAttachable = ["offsetPosition", "offsetRotation", "offsetScale"];
|
||||||
Text3DOverlay = overlayTypes["text3d"];
|
var Billboardable = ["isFacingAvatar"];
|
||||||
Cube3DOverlay = overlayTypes["cube"];
|
|
||||||
Sphere3DOverlay = overlayTypes["sphere"];
|
var Overlay2D = generateOverlayClass(Overlay, ABSTRACT, [
|
||||||
Circle3DOverlay = overlayTypes["circle3d"];
|
"bounds", "x", "y", "width", "height"
|
||||||
Rectangle3DOverlay = overlayTypes["rectangle3d"];
|
]);
|
||||||
Line3DOverlay = overlayTypes["line3d"];
|
|
||||||
Grid3DOverlay = overlayTypes["grid"];
|
var Base3DOverlay = generateOverlayClass(Overlay, ABSTRACT, [
|
||||||
LocalModelsOverlay = overlayTypes["localmodels"];
|
"position", "lineWidth", "rotation", "isSolid", "isFilled", "isWire", "isDashedLine",
|
||||||
ModelOverlay = overlayTypes["model"];
|
"ignoreRayIntersection", "drawInFront", "drawOnHUD"
|
||||||
|
]);
|
||||||
|
|
||||||
|
var Planar3DOverlay = generateOverlayClass(Base3DOverlay, ABSTRACT, [
|
||||||
|
"dimensions"
|
||||||
|
]);
|
||||||
|
|
||||||
|
var Billboard3DOverlay = generateOverlayClass(Planar3DOverlay, ABSTRACT, [
|
||||||
|
].concat(PanelAttachable).concat(Billboardable));
|
||||||
|
Billboard3DOverlay.prototype.isPanelAttachable = function() { return true; };
|
||||||
|
|
||||||
|
var Volume3DOverlay = generateOverlayClass(Base3DOverlay, ABSTRACT, [
|
||||||
|
"dimensions"
|
||||||
|
]);
|
||||||
|
|
||||||
|
ImageOverlay = generateOverlayClass(Overlay2D, "image", [
|
||||||
|
"subImage", "imageURL"
|
||||||
|
]);
|
||||||
|
|
||||||
|
Image3DOverlay = generateOverlayClass(Billboard3DOverlay, "image3d", [
|
||||||
|
"url", "subImage"
|
||||||
|
]);
|
||||||
|
|
||||||
|
TextOverlay = generateOverlayClass(Overlay2D, "text", [
|
||||||
|
"font", "text", "backgroundColor", "backgroundAlpha", "leftMargin", "topMargin"
|
||||||
|
]);
|
||||||
|
|
||||||
|
Text3DOverlay = generateOverlayClass(Billboard3DOverlay, "text3d", [
|
||||||
|
"text", "backgroundColor", "backgroundAlpha", "lineHeight", "leftMargin", "topMargin",
|
||||||
|
"rightMargin", "bottomMargin"
|
||||||
|
]);
|
||||||
|
|
||||||
|
Cube3DOverlay = generateOverlayClass(Volume3DOverlay, "cube", [
|
||||||
|
"borderSize"
|
||||||
|
]);
|
||||||
|
|
||||||
|
Sphere3DOverlay = generateOverlayClass(Volume3DOverlay, "sphere", [
|
||||||
|
]);
|
||||||
|
|
||||||
|
Circle3DOverlay = generateOverlayClass(Planar3DOverlay, "circle3d", [
|
||||||
|
"startAt", "endAt", "outerRadius", "innerRadius", "hasTickMarks",
|
||||||
|
"majorTickMarksAngle", "minorTickMarksAngle", "majorTickMarksLength",
|
||||||
|
"minorTickMarksLength", "majorTickMarksColor", "minorTickMarksColor"
|
||||||
|
]);
|
||||||
|
|
||||||
|
Rectangle3DOverlay = generateOverlayClass(Planar3DOverlay, "rectangle3d", [
|
||||||
|
]);
|
||||||
|
|
||||||
|
Line3DOverlay = generateOverlayClass(Base3DOverlay, "line3d", [
|
||||||
|
"start", "end"
|
||||||
|
]);
|
||||||
|
|
||||||
|
Grid3DOverlay = generateOverlayClass(Planar3DOverlay, "grid", [
|
||||||
|
"minorGridWidth", "majorGridEvery"
|
||||||
|
]);
|
||||||
|
|
||||||
|
LocalModelsOverlay = generateOverlayClass(Volume3DOverlay, "localmodels", [
|
||||||
|
]);
|
||||||
|
|
||||||
|
ModelOverlay = generateOverlayClass(Volume3DOverlay, "model", [
|
||||||
|
"url", "dimensions", "textures"
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Object oriented abstraction layer for panels.
|
|
||||||
//
|
|
||||||
OverlayPanel = (function() {
|
OverlayPanel = (function() {
|
||||||
var that = function(params) {
|
var that = function(params) {
|
||||||
this._id = Overlays.addPanel(params);
|
this._id = Overlays.addPanel(params);
|
||||||
|
@ -455,6 +360,35 @@
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
OverlayManager = {
|
||||||
|
findOnRay: function(pickRay, knownOverlaysOnly, searchList) {
|
||||||
|
var rayPickResult = Overlays.findRayIntersection(pickRay);
|
||||||
|
if (rayPickResult.intersects) {
|
||||||
|
return findOverlay(rayPickResult.overlayID, knownOverlaysOnly, searchList);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
findAtPoint: function(point, knownOverlaysOnly, searchList) {
|
||||||
|
var foundID = Overlays.getOverlayAtPoint(point);
|
||||||
|
if (foundID) {
|
||||||
|
return findOverlay(foundID, knownOverlaysOnly, searchList);
|
||||||
|
} else {
|
||||||
|
var pickRay = Camera.computePickRay(point.x, point.y);
|
||||||
|
return OverlayManager.findOnRay(pickRay, knownOverlaysOnly, searchList);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
makeSearchList: function(array) {
|
||||||
|
var searchList = {};
|
||||||
|
array.forEach(function(object) {
|
||||||
|
searchList[object._id] = object;
|
||||||
|
});
|
||||||
|
return searchList;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Threadsafe cleanup of JavaScript objects.
|
||||||
|
|
||||||
function onOverlayDeleted(id) {
|
function onOverlayDeleted(id) {
|
||||||
if (id in overlays) {
|
if (id in overlays) {
|
||||||
if (overlays[id].parentPanel) {
|
if (overlays[id].parentPanel) {
|
||||||
|
|
|
@ -501,7 +501,7 @@ Box.prototype.destroy = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Box.prototype.hasOverlay = function (overlayId) {
|
Box.prototype.hasOverlay = function (overlayId) {
|
||||||
return this.overlay && this.overlay.getId() === overlayId;
|
return /*this.overlay &&*/ this.overlay.getId() === overlayId;
|
||||||
}
|
}
|
||||||
Box.prototype.getOverlay = function () {
|
Box.prototype.getOverlay = function () {
|
||||||
return this.overlay;
|
return this.overlay;
|
||||||
|
@ -615,7 +615,7 @@ Slider.prototype.toString = function () {
|
||||||
}
|
}
|
||||||
Slider.prototype.applyLayout = function () {
|
Slider.prototype.applyLayout = function () {
|
||||||
if (!this.slider) {
|
if (!this.slider) {
|
||||||
ui.complain("Slider.applyLayout on " + this + " failed");
|
// ui.complain("Slider.applyLayout on " + this + " failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var val = (this.value - this.minValue) / (this.maxValue - this.minValue);
|
var val = (this.value - this.minValue) / (this.maxValue - this.minValue);
|
||||||
|
@ -654,6 +654,7 @@ var Checkbox = UI.Checkbox = function (properties) {
|
||||||
this.position.x + (this.width - this.checkMark.width) * 0.5,
|
this.position.x + (this.width - this.checkMark.width) * 0.5,
|
||||||
this.position.y + (this.height - this.checkMark.height) * 0.5
|
this.position.y + (this.height - this.checkMark.height) * 0.5
|
||||||
);
|
);
|
||||||
|
this.checkMark.parent = this;
|
||||||
|
|
||||||
this.onValueChanged = properties.onValueChanged || function () {};
|
this.onValueChanged = properties.onValueChanged || function () {};
|
||||||
|
|
||||||
|
@ -919,9 +920,16 @@ var getFocusedWidget = function (event) {
|
||||||
|
|
||||||
var dispatchEvent = function (action, event, widget) {
|
var dispatchEvent = function (action, event, widget) {
|
||||||
function dispatchActions (actions) {
|
function dispatchActions (actions) {
|
||||||
|
var dispatchedActions = false;
|
||||||
|
ui.logEvent("dispatching to [" + actions.join(", ") + "]");
|
||||||
actions.forEach(function(action) {
|
actions.forEach(function(action) {
|
||||||
action(event, widget);
|
action(event, widget);
|
||||||
|
ui.logEvent("dispatched to " + action);
|
||||||
|
dispatchedActions = true;
|
||||||
});
|
});
|
||||||
|
if (!dispatchedActions) {
|
||||||
|
// ui.logEvent("No actions to dispatch");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.actions[action]) {
|
if (widget.actions[action]) {
|
||||||
|
@ -963,7 +971,7 @@ UI.handleMouseMove = function (event, canStartDrag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
UI.handleMousePress = function (event) {
|
UI.handleMousePress = function (event) {
|
||||||
print("Mouse clicked");
|
// print("Mouse clicked");
|
||||||
UI.handleMouseMove(event);
|
UI.handleMouseMove(event);
|
||||||
ui.clickedWidget = ui.focusedWidget;
|
ui.clickedWidget = ui.focusedWidget;
|
||||||
if (ui.clickedWidget) {
|
if (ui.clickedWidget) {
|
||||||
|
@ -971,8 +979,18 @@ UI.handleMousePress = function (event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI.handleMouseDoublePress = function (event) {
|
||||||
|
// print("DOUBLE CLICK!");
|
||||||
|
var focused = getFocusedWidget(event);
|
||||||
|
UI.handleMouseMove(event);
|
||||||
|
if (focused) {
|
||||||
|
// print("dispatched onDoubleClick");
|
||||||
|
dispatchEvent('onDoubleClick', event, focused);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UI.handleMouseRelease = function (event) {
|
UI.handleMouseRelease = function (event) {
|
||||||
print("Mouse released");
|
// print("Mouse released");
|
||||||
|
|
||||||
if (ui.draggedWidget) {
|
if (ui.draggedWidget) {
|
||||||
dispatchEvent('onDragEnd', event, ui.draggedWidget);
|
dispatchEvent('onDragEnd', event, ui.draggedWidget);
|
||||||
|
|
155
examples/particleDance.js
Normal file
155
examples/particleDance.js
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
(function() {
|
||||||
|
var NUM_BURSTS = 3;
|
||||||
|
var NUM_EMITTERS_PER_BURST = 11;
|
||||||
|
|
||||||
|
var RANGE = 5.0;
|
||||||
|
var AUDIO_RANGE = 0.5 * RANGE;
|
||||||
|
var DIST_BETWEEN_BURSTS = 1.0;
|
||||||
|
|
||||||
|
var LOUDNESS_RADIUS_RATIO = 10;
|
||||||
|
|
||||||
|
var TEXTURE_PATH = 'https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png';
|
||||||
|
var cameraAxis = Quat.getFront(Camera.getOrientation());
|
||||||
|
var center = Vec3.sum(Camera.getPosition(), Vec3.multiply(RANGE, cameraAxis));
|
||||||
|
var audioPosition = Vec3.sum(Camera.getPosition(), Vec3.multiply(AUDIO_RANGE, cameraAxis));
|
||||||
|
|
||||||
|
var song = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/songs/Made%20In%20Heights%20-%20Forgiveness.wav");
|
||||||
|
var audioOptions = {
|
||||||
|
volume: 0.9, position: audioPosition
|
||||||
|
};
|
||||||
|
|
||||||
|
var DISTANCE_FROM_CAMERA = 7.0;
|
||||||
|
|
||||||
|
var colorPalette = [{
|
||||||
|
red: 0,
|
||||||
|
green: 206,
|
||||||
|
blue: 209
|
||||||
|
}, {
|
||||||
|
red: 173,
|
||||||
|
green: 216,
|
||||||
|
blue: 230
|
||||||
|
}, {
|
||||||
|
red: 0,
|
||||||
|
green: 191,
|
||||||
|
blue: 255
|
||||||
|
}];
|
||||||
|
|
||||||
|
var bursts = [];
|
||||||
|
var audioStats;
|
||||||
|
|
||||||
|
Burst = function(point) {
|
||||||
|
if (!audioStats) {
|
||||||
|
audioStats = Audio.playSound(song, audioOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.point = point;
|
||||||
|
this.emitters = [];
|
||||||
|
|
||||||
|
this.emitRate = randInt(80, 120);
|
||||||
|
this.emitStrength = randInt(4.0, 6.0);
|
||||||
|
|
||||||
|
this.animationSettings = JSON.stringify({
|
||||||
|
fps: 10,
|
||||||
|
frameIndex: 0,
|
||||||
|
running: true,
|
||||||
|
firstFrame: 0,
|
||||||
|
lastFrame: 50,
|
||||||
|
loop: true
|
||||||
|
});
|
||||||
|
|
||||||
|
this.direction = {
|
||||||
|
x: randFloat(-0.3, 0.3),
|
||||||
|
y: 1.0,
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
this.base = Entities.addEntity({
|
||||||
|
type: "Sphere",
|
||||||
|
position: this.point,
|
||||||
|
dimensions: {
|
||||||
|
x: 0.05,
|
||||||
|
y: 0.05,
|
||||||
|
z: 0.05
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 240,
|
||||||
|
green: 240,
|
||||||
|
blue: 240
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (var i = 0; i < NUM_EMITTERS_PER_BURST; ++i) {
|
||||||
|
var colorIndex = randInt(0, colorPalette.length - 1);
|
||||||
|
var color = colorPalette[colorIndex];
|
||||||
|
this.emitters.push(Entities.addEntity({
|
||||||
|
type: "ParticleEffect",
|
||||||
|
animationSettings: this.animationSettings,
|
||||||
|
position: this.point,
|
||||||
|
textures: TEXTURE_PATH,
|
||||||
|
emitRate: this.emitRate,
|
||||||
|
emitStrength: this.emitStrength,
|
||||||
|
emitDirection: {
|
||||||
|
x: Math.pow(-1, i) * randFloat(0.0, 0.4),
|
||||||
|
y: 1.0,
|
||||||
|
z: 0.0
|
||||||
|
},
|
||||||
|
color: color,
|
||||||
|
lifespan: 1.0,
|
||||||
|
visible: true,
|
||||||
|
locked: false
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var nextPosition = center;
|
||||||
|
var posOrNeg = -1;
|
||||||
|
|
||||||
|
for (var i = 0; i < NUM_BURSTS; ++i) {
|
||||||
|
posOrNeg *= -1;
|
||||||
|
bursts.push(new Burst(nextPosition));
|
||||||
|
var offset = {
|
||||||
|
x: RANGE/(i+2) * posOrNeg,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
|
var nextPosition = Vec3.sum(nextPosition, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function update(deltaTime) {
|
||||||
|
for (var i = 0; i < NUM_BURSTS; i++) {
|
||||||
|
if (audioStats && audioStats.loudness > 0.0) {
|
||||||
|
for (var j = 0; j < NUM_EMITTERS_PER_BURST; ++j) {
|
||||||
|
Entities.editEntity(bursts[i].emitters[j], {
|
||||||
|
particleRadius: audioStats.loudness / LOUDNESS_RADIUS_RATIO
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function randFloat(min, max) {
|
||||||
|
return Math.random() * (max - min) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
function randInt(min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cleanup = function() {
|
||||||
|
for (var i = 0; i < NUM_BURSTS; ++i) {
|
||||||
|
Entities.deleteEntity(bursts[i].base);
|
||||||
|
for (var j = 0; j < NUM_EMITTERS_PER_BURST; ++j) {
|
||||||
|
var emitter = bursts[i].emitters[j];
|
||||||
|
Entities.deleteEntity(emitter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Audio.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.update.connect(update);
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
|
|
@ -1360,7 +1360,7 @@ var CHECK_MARK_COLOR = {
|
||||||
|
|
||||||
this.nextY = this.y + this.getHeight();
|
this.nextY = this.y + this.getHeight();
|
||||||
|
|
||||||
var item = new CollapsablePanelItem(name, this.x, this.nextY, textWidth, rawHeight, panel);
|
var item = new CollapsablePanelItem(name, this.x, this.nextY, textWidth, rawHeight);
|
||||||
item.isSubPanel = true;
|
item.isSubPanel = true;
|
||||||
|
|
||||||
this.nextY += 1.5 * item.height;
|
this.nextY += 1.5 * item.height;
|
||||||
|
|
|
@ -4729,6 +4729,11 @@ void Application::updateDisplayMode() {
|
||||||
if (oldDisplayPlugin) {
|
if (oldDisplayPlugin) {
|
||||||
oldDisplayPlugin->deactivate();
|
oldDisplayPlugin->deactivate();
|
||||||
_offscreenContext->makeCurrent();
|
_offscreenContext->makeCurrent();
|
||||||
|
|
||||||
|
// if the old plugin was HMD and the new plugin is not HMD, then hide our hmdtools
|
||||||
|
if (oldDisplayPlugin->isHmd() && !newDisplayPlugin->isHmd()) {
|
||||||
|
DependencyManager::get<DialogsManager>()->hmdTools(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
emit activeDisplayPluginChanged();
|
emit activeDisplayPluginChanged();
|
||||||
resetSensors();
|
resetSensors();
|
||||||
|
|
|
@ -289,16 +289,6 @@ Menu::Menu() {
|
||||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::CenterPlayerInView,
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::CenterPlayerInView,
|
||||||
0, false, qApp, SLOT(rotationModeChanged()));
|
0, false, qApp, SLOT(rotationModeChanged()));
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::HMDTools,
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
Qt::META | Qt::Key_H,
|
|
||||||
#else
|
|
||||||
Qt::CTRL | Qt::Key_H,
|
|
||||||
#endif
|
|
||||||
false,
|
|
||||||
dialogsManager.data(),
|
|
||||||
SLOT(hmdTools(bool)));
|
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::TurnWithHead, 0, false);
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::TurnWithHead, 0, false);
|
||||||
|
|
||||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::StandingHMDSensorMode, 0, false,
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::StandingHMDSensorMode, 0, false,
|
||||||
|
|
|
@ -199,7 +199,6 @@ namespace MenuOption {
|
||||||
const QString FullscreenMirror = "Fullscreen Mirror";
|
const QString FullscreenMirror = "Fullscreen Mirror";
|
||||||
const QString GlowWhenSpeaking = "Glow When Speaking";
|
const QString GlowWhenSpeaking = "Glow When Speaking";
|
||||||
const QString HandMouseInput = "Enable Hand Mouse Input";
|
const QString HandMouseInput = "Enable Hand Mouse Input";
|
||||||
const QString HMDTools = "HMD Tools";
|
|
||||||
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
||||||
const QString IndependentMode = "Independent Mode";
|
const QString IndependentMode = "Independent Mode";
|
||||||
const QString InputMenu = "Avatar>Input Devices";
|
const QString InputMenu = "Avatar>Input Devices";
|
||||||
|
|
|
@ -58,6 +58,7 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid
|
||||||
auto dialogWidget = new QDialog(Application::getInstance()->getWindow(), Qt::Window);
|
auto dialogWidget = new QDialog(Application::getInstance()->getWindow(), Qt::Window);
|
||||||
dialogWidget->setWindowTitle(title);
|
dialogWidget->setWindowTitle(title);
|
||||||
dialogWidget->resize(width, height);
|
dialogWidget->resize(width, height);
|
||||||
|
dialogWidget->installEventFilter(this);
|
||||||
connect(dialogWidget, &QDialog::finished, this, &WebWindowClass::hasClosed);
|
connect(dialogWidget, &QDialog::finished, this, &WebWindowClass::hasClosed);
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(dialogWidget);
|
auto layout = new QVBoxLayout(dialogWidget);
|
||||||
|
@ -93,6 +94,19 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid
|
||||||
WebWindowClass::~WebWindowClass() {
|
WebWindowClass::~WebWindowClass() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebWindowClass::eventFilter(QObject* sender, QEvent* event) {
|
||||||
|
if (sender == _windowWidget) {
|
||||||
|
if (event->type() == QEvent::Move) {
|
||||||
|
emit moved(getPosition());
|
||||||
|
}
|
||||||
|
if (event->type() == QEvent::Resize) {
|
||||||
|
emit resized(getSize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void WebWindowClass::hasClosed() {
|
void WebWindowClass::hasClosed() {
|
||||||
emit closed();
|
emit closed();
|
||||||
}
|
}
|
||||||
|
@ -122,6 +136,32 @@ void WebWindowClass::setURL(const QString& url) {
|
||||||
_webView->setUrl(url);
|
_webView->setUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSizeF WebWindowClass::getSize() const {
|
||||||
|
QSizeF size = _windowWidget->size();
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebWindowClass::setSize(QSizeF size) {
|
||||||
|
setSize(size.width(), size.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebWindowClass::setSize(int width, int height) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "setSize", Qt::AutoConnection, Q_ARG(int, width), Q_ARG(int, height));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_windowWidget->resize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec2 WebWindowClass::getPosition() const {
|
||||||
|
QPoint position = _windowWidget->pos();
|
||||||
|
return glm::vec2(position.x(), position.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebWindowClass::setPosition(glm::vec2 position) {
|
||||||
|
setPosition(position.x, position.y);
|
||||||
|
}
|
||||||
|
|
||||||
void WebWindowClass::setPosition(int x, int y) {
|
void WebWindowClass::setPosition(int x, int y) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "setPosition", Qt::AutoConnection, Q_ARG(int, x), Q_ARG(int, y));
|
QMetaObject::invokeMethod(this, "setPosition", Qt::AutoConnection, Q_ARG(int, x), Q_ARG(int, y));
|
||||||
|
|
|
@ -35,6 +35,9 @@ class WebWindowClass : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QObject* eventBridge READ getEventBridge)
|
Q_PROPERTY(QObject* eventBridge READ getEventBridge)
|
||||||
Q_PROPERTY(QString url READ getURL)
|
Q_PROPERTY(QString url READ getURL)
|
||||||
|
Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition);
|
||||||
|
Q_PROPERTY(QSizeF size READ getSize WRITE setSize);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WebWindowClass(const QString& title, const QString& url, int width, int height, bool isToolWindow = false);
|
WebWindowClass(const QString& title, const QString& url, int width, int height, bool isToolWindow = false);
|
||||||
~WebWindowClass();
|
~WebWindowClass();
|
||||||
|
@ -43,7 +46,12 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
|
glm::vec2 getPosition() const;
|
||||||
void setPosition(int x, int y);
|
void setPosition(int x, int y);
|
||||||
|
void setPosition(glm::vec2 position);
|
||||||
|
QSizeF getSize() const;
|
||||||
|
void setSize(QSizeF size);
|
||||||
|
void setSize(int width, int height);
|
||||||
QString getURL() const { return _webView->url().url(); }
|
QString getURL() const { return _webView->url().url(); }
|
||||||
void setURL(const QString& url);
|
void setURL(const QString& url);
|
||||||
void raise();
|
void raise();
|
||||||
|
@ -52,8 +60,13 @@ public slots:
|
||||||
void setTitle(const QString& title);
|
void setTitle(const QString& title);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void moved(glm::vec2 position);
|
||||||
|
void resized(QSizeF size);
|
||||||
void closed();
|
void closed();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool eventFilter(QObject* sender, QEvent* event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void hasClosed();
|
void hasClosed();
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,6 @@ void DialogsManager::hmdTools(bool showTools) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsManager::hmdToolsClosed() {
|
void DialogsManager::hmdToolsClosed() {
|
||||||
Menu::getInstance()->getActionForOption(MenuOption::HMDTools)->setChecked(false);
|
|
||||||
_hmdToolsDialog->hide();
|
_hmdToolsDialog->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,9 @@
|
||||||
static const int WIDTH = 350;
|
static const int WIDTH = 350;
|
||||||
static const int HEIGHT = 100;
|
static const int HEIGHT = 100;
|
||||||
|
|
||||||
|
|
||||||
HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
|
HMDToolsDialog::HMDToolsDialog(QWidget* parent) :
|
||||||
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint)
|
QDialog(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowStaysOnTopHint)
|
||||||
{
|
{
|
||||||
// FIXME do we want to support more than one connected HMD? It seems like a pretty corner case
|
// FIXME do we want to support more than one connected HMD? It seems like a pretty corner case
|
||||||
foreach(auto displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
|
foreach(auto displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
|
||||||
|
@ -171,14 +172,12 @@ void HMDToolsDialog::leaveHMDMode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMDToolsDialog::reject() {
|
void HMDToolsDialog::reject() {
|
||||||
// Just regularly close upon ESC
|
// We don't want this window to be closable from a close icon, just from our "Leave HMD Mode" button
|
||||||
close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMDToolsDialog::closeEvent(QCloseEvent* event) {
|
void HMDToolsDialog::closeEvent(QCloseEvent* event) {
|
||||||
// TODO: consider if we want to prevent closing of this window with event->ignore();
|
// We don't want this window to be closable from a close icon, just from our "Leave HMD Mode" button
|
||||||
QDialog::closeEvent(event);
|
event->ignore();
|
||||||
emit closed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMDToolsDialog::centerCursorOnWidget(QWidget* widget) {
|
void HMDToolsDialog::centerCursorOnWidget(QWidget* widget) {
|
||||||
|
|
|
@ -5,14 +5,15 @@
|
||||||
// Modified by Zander Otavka on 7/15/15
|
// Modified by Zander Otavka on 7/15/15
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Exposes methods for managing `Overlay`s and `OverlayPanel`s to scripts.
|
|
||||||
//
|
|
||||||
// YOU SHOULD NOT USE `Overlays` DIRECTLY, unless you like pain and deprecation. Instead, use the
|
|
||||||
// object oriented abstraction layer found in `examples/libraries/overlayUtils.js`.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
// Exposes methods to scripts for managing `Overlay`s and `OverlayPanel`s.
|
||||||
|
//
|
||||||
|
// YOU SHOULD NOT USE `Overlays` DIRECTLY, unless you like pain and deprecation. Instead, use
|
||||||
|
// the object oriented API replacement found in `examples/libraries/overlayManager.js`. See
|
||||||
|
// that file for docs and usage.
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef hifi_Overlays_h
|
#ifndef hifi_Overlays_h
|
||||||
#define hifi_Overlays_h
|
#define hifi_Overlays_h
|
||||||
|
@ -57,11 +58,11 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
|
||||||
|
|
||||||
class Overlays : public QObject {
|
class Overlays : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Overlays();
|
Overlays();
|
||||||
~Overlays();
|
~Overlays();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void update(float deltatime);
|
void update(float deltatime);
|
||||||
void renderHUD(RenderArgs* renderArgs);
|
void renderHUD(RenderArgs* renderArgs);
|
||||||
|
@ -103,7 +104,7 @@ public slots:
|
||||||
|
|
||||||
/// returns details about the closest 3D Overlay hit by the pick ray
|
/// returns details about the closest 3D Overlay hit by the pick ray
|
||||||
RayToOverlayIntersectionResult findRayIntersection(const PickRay& ray);
|
RayToOverlayIntersectionResult findRayIntersection(const PickRay& ray);
|
||||||
|
|
||||||
/// returns whether the overlay's assets are loaded or not
|
/// returns whether the overlay's assets are loaded or not
|
||||||
bool isLoaded(unsigned int id);
|
bool isLoaded(unsigned int id);
|
||||||
|
|
||||||
|
@ -153,5 +154,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // hifi_Overlays_h
|
#endif // hifi_Overlays_h
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// PanelAttachable.cpp
|
// PanelAttachable.cpp
|
||||||
// hifi
|
// interface/src/ui/overlays
|
||||||
//
|
//
|
||||||
// Created by Zander Otavka on 7/15/15.
|
// Created by Zander Otavka on 7/15/15.
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
|
|
@ -8,6 +8,24 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
// Base class for anything that can attach itself to an `OverlayPanel` as a child.
|
||||||
|
// `PanelAttachable keeps an `std::shared_ptr` to it's parent panel, and sets its
|
||||||
|
// transformations and visibility based on the parent.
|
||||||
|
//
|
||||||
|
// When subclassing `PanelAttachable`, make sure `applyTransformTo`, `getProperty`, and
|
||||||
|
// `setProperties are all called in the appropriate places. Look through `Image3DOverlay` and
|
||||||
|
// `Billboard3DOverlay` for examples. Pay special attention to `applyTransformTo`; it should
|
||||||
|
// be called in three places for `Overlay`s: `render`, `update`, and `findRayIntersection`.
|
||||||
|
//
|
||||||
|
// When overriding `applyTransformTo`, make sure to wrap all of your code, including the call
|
||||||
|
// to the superclass method, with the following `if` block. Then call the superclass method
|
||||||
|
// with force = true.
|
||||||
|
//
|
||||||
|
// if (force || usecTimestampNow() > _transformExpiry) {
|
||||||
|
// PanelAttachable::applyTransformTo(transform, true);
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef hifi_PanelAttachable_h
|
#ifndef hifi_PanelAttachable_h
|
||||||
#define hifi_PanelAttachable_h
|
#define hifi_PanelAttachable_h
|
||||||
|
@ -42,6 +60,8 @@ protected:
|
||||||
QScriptValue getProperty(QScriptEngine* scriptEngine, const QString& property);
|
QScriptValue getProperty(QScriptEngine* scriptEngine, const QString& property);
|
||||||
void setProperties(const QScriptValue& properties);
|
void setProperties(const QScriptValue& properties);
|
||||||
|
|
||||||
|
/// set position, rotation and scale on transform based on offsets, and parent panel offsets
|
||||||
|
/// if force is false, only apply transform if it hasn't been applied in the last .1 seconds
|
||||||
virtual void applyTransformTo(Transform& transform, bool force = false);
|
virtual void applyTransformTo(Transform& transform, bool force = false);
|
||||||
quint64 _transformExpiry = 0;
|
quint64 _transformExpiry = 0;
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ void GLBackend::updateTransform() {
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
glBindBufferRange(GL_UNIFORM_BUFFER, TRANSFORM_CAMERA_SLOT,
|
glBindBufferRange(GL_UNIFORM_BUFFER, TRANSFORM_CAMERA_SLOT,
|
||||||
_transform._transformCameraBuffer,
|
_transform._transformCameraBuffer,
|
||||||
offset, sizeof(Backend::TransformObject));
|
offset, sizeof(Backend::TransformCamera));
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
|
|
|
@ -535,8 +535,8 @@ void SixenseManager::assignDefaultInputMapping(UserInputMapper& mapper) {
|
||||||
mapper.addInputChannel(UserInputMapper::LEFT_HAND, makeInput(LEFT_HAND));
|
mapper.addInputChannel(UserInputMapper::LEFT_HAND, makeInput(LEFT_HAND));
|
||||||
mapper.addInputChannel(UserInputMapper::RIGHT_HAND, makeInput(RIGHT_HAND));
|
mapper.addInputChannel(UserInputMapper::RIGHT_HAND, makeInput(RIGHT_HAND));
|
||||||
|
|
||||||
mapper.addInputChannel(UserInputMapper::LEFT_HAND_CLICK, makeInput(BUTTON_FWD, 0));
|
mapper.addInputChannel(UserInputMapper::LEFT_HAND_CLICK, makeInput(BACK_TRIGGER, 0));
|
||||||
mapper.addInputChannel(UserInputMapper::RIGHT_HAND_CLICK, makeInput(BUTTON_FWD, 1));
|
mapper.addInputChannel(UserInputMapper::RIGHT_HAND_CLICK, makeInput(BACK_TRIGGER, 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -401,8 +401,8 @@ void ViveControllerManager::assignDefaultInputMapping(UserInputMapper& mapper) {
|
||||||
mapper.addInputChannel(UserInputMapper::ACTION1, makeInput(GRIP_BUTTON, 0));
|
mapper.addInputChannel(UserInputMapper::ACTION1, makeInput(GRIP_BUTTON, 0));
|
||||||
mapper.addInputChannel(UserInputMapper::ACTION2, makeInput(GRIP_BUTTON, 1));
|
mapper.addInputChannel(UserInputMapper::ACTION2, makeInput(GRIP_BUTTON, 1));
|
||||||
|
|
||||||
mapper.addInputChannel(UserInputMapper::LEFT_HAND_CLICK, makeInput(TRIGGER_BUTTON, 0));
|
mapper.addInputChannel(UserInputMapper::LEFT_HAND_CLICK, makeInput(BACK_TRIGGER, 0));
|
||||||
mapper.addInputChannel(UserInputMapper::RIGHT_HAND_CLICK, makeInput(TRIGGER_BUTTON, 1));
|
mapper.addInputChannel(UserInputMapper::RIGHT_HAND_CLICK, makeInput(BACK_TRIGGER, 1));
|
||||||
|
|
||||||
// Hands
|
// Hands
|
||||||
mapper.addInputChannel(UserInputMapper::LEFT_HAND, makeInput(LEFT_HAND));
|
mapper.addInputChannel(UserInputMapper::LEFT_HAND, makeInput(LEFT_HAND));
|
||||||
|
|
|
@ -34,11 +34,9 @@ OffscreenGlCanvas::~OffscreenGlCanvas() {
|
||||||
void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) {
|
void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) {
|
||||||
if (nullptr != sharedContext) {
|
if (nullptr != sharedContext) {
|
||||||
sharedContext->doneCurrent();
|
sharedContext->doneCurrent();
|
||||||
_context->setFormat(sharedContext->format());
|
|
||||||
_context->setShareContext(sharedContext);
|
_context->setShareContext(sharedContext);
|
||||||
} else {
|
|
||||||
_context->setFormat(getDefaultOpenGlSurfaceFormat());
|
|
||||||
}
|
}
|
||||||
|
_context->setFormat(getDefaultOpenGlSurfaceFormat());
|
||||||
_context->create();
|
_context->create();
|
||||||
|
|
||||||
_offscreenSurface->setFormat(_context->format());
|
_offscreenSurface->setFormat(_context->format());
|
||||||
|
|
Loading…
Reference in a new issue