mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 20:17:01 +02:00
visuals update. Will do some cleaning shortly
This commit is contained in:
parent
29e97381eb
commit
5bcd7ca97f
1 changed files with 124 additions and 43 deletions
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
const version = 0.1;
|
const version = 0.1;
|
||||||
const label = "makeUserConnection";
|
const label = "makeUserConnection";
|
||||||
const MAX_AVATAR_DISTANCE = 0.5;
|
const MAX_AVATAR_DISTANCE = 0.2;
|
||||||
const GRIP_MIN = 0.05;
|
const GRIP_MIN = 0.05;
|
||||||
const MESSAGE_CHANNEL = "io.highfidelity.makeUserConnection";
|
const MESSAGE_CHANNEL = "io.highfidelity.makeUserConnection";
|
||||||
const STATES = {
|
const STATES = {
|
||||||
|
@ -25,13 +25,13 @@ const STATES = {
|
||||||
const STATE_STRINGS = ["inactive", "waiting", "friending", "makingFriends"];
|
const STATE_STRINGS = ["inactive", "waiting", "friending", "makingFriends"];
|
||||||
const WAITING_INTERVAL = 100; // ms
|
const WAITING_INTERVAL = 100; // ms
|
||||||
const FRIENDING_INTERVAL = 100; // ms
|
const FRIENDING_INTERVAL = 100; // ms
|
||||||
const MAKING_FRIENDS_TIMEOUT = 1000; // ms
|
const MAKING_FRIENDS_TIMEOUT = 3000; // ms
|
||||||
const FRIENDING_TIME = 2000; // ms
|
const FRIENDING_TIME = 2000; // ms
|
||||||
const FRIENDING_HAPTIC_STRENGTH = 0.5;
|
const FRIENDING_HAPTIC_STRENGTH = 0.5;
|
||||||
const FRIENDING_SUCCESS_HAPTIC_STRENGTH = 1.0;
|
const FRIENDING_SUCCESS_HAPTIC_STRENGTH = 1.0;
|
||||||
const HAPTIC_DURATION = 20;
|
const HAPTIC_DURATION = 20;
|
||||||
const PARTICLE_RADIUS = 0.2;
|
const PARTICLE_RADIUS = 0.1;
|
||||||
const PARTICLE_ANGLE_INCREMENT = 360/45;
|
const PARTICLE_ANGLE_INCREMENT = 360/45; // 1hz
|
||||||
const MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Test/sphere-3-color.fbx";
|
const MODEL_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Test/sphere-3-color.fbx";
|
||||||
const TEXTURES = [
|
const TEXTURES = [
|
||||||
{"Texture": "http://hifi-content.s3.amazonaws.com/alan/dev/Test/sphere-3-color.fbx/sphere-3-color.fbm/green-50pct-opaque-64.png"},
|
{"Texture": "http://hifi-content.s3.amazonaws.com/alan/dev/Test/sphere-3-color.fbx/sphere-3-color.fbm/green-50pct-opaque-64.png"},
|
||||||
|
@ -42,7 +42,7 @@ const PARTICLE_EFFECT_PROPS = {
|
||||||
"alpha": 0.8,
|
"alpha": 0.8,
|
||||||
"azimuthFinish": Math.PI,
|
"azimuthFinish": Math.PI,
|
||||||
"azimuthStart": -1*Math.PI,
|
"azimuthStart": -1*Math.PI,
|
||||||
"emitRate": 220,
|
"emitRate": 500,
|
||||||
"emitSpeed": 0.0,
|
"emitSpeed": 0.0,
|
||||||
"emitterShouldTrail": 1,
|
"emitterShouldTrail": 1,
|
||||||
"isEmitting": 1,
|
"isEmitting": 1,
|
||||||
|
@ -51,8 +51,8 @@ const PARTICLE_EFFECT_PROPS = {
|
||||||
"particleRadius": 0.003,
|
"particleRadius": 0.003,
|
||||||
"polarStart": 1,
|
"polarStart": 1,
|
||||||
"polarFinish": 1,
|
"polarFinish": 1,
|
||||||
"radiusFinish": 0.006,
|
"radiusFinish": 0.008,
|
||||||
"radiusStart": 0.001,
|
"radiusStart": 0.0025,
|
||||||
"speedSpread": 0.025,
|
"speedSpread": 0.025,
|
||||||
"textures": "http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
"textures": "http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
||||||
"color": {"red": 255, "green": 255, "blue": 255},
|
"color": {"red": 255, "green": 255, "blue": 255},
|
||||||
|
@ -64,6 +64,36 @@ const PARTICLE_EFFECT_PROPS = {
|
||||||
"dimensions": {"x":0.05, "y": 0.05, "z": 0.05},
|
"dimensions": {"x":0.05, "y": 0.05, "z": 0.05},
|
||||||
"type": "ParticleEffect"
|
"type": "ParticleEffect"
|
||||||
};
|
};
|
||||||
|
const MAKING_FRIENDS_PARTICLE_PROPS = {
|
||||||
|
"alpha": 0.07,
|
||||||
|
"alphaStart":0.011,
|
||||||
|
"alphaSpread": 0,
|
||||||
|
"alphaFinish": 0,
|
||||||
|
"azimuthFinish": Math.PI,
|
||||||
|
"azimuthStart": -1*Math.PI,
|
||||||
|
"emitRate": 2000,
|
||||||
|
"emitSpeed": 0.0,
|
||||||
|
"emitterShouldTrail": 1,
|
||||||
|
"isEmitting": 1,
|
||||||
|
"lifespan": 3.6,
|
||||||
|
"maxParticles": 4000,
|
||||||
|
"particleRadius": 0.048,
|
||||||
|
"polarStart": 0,
|
||||||
|
"polarFinish": 1,
|
||||||
|
"radiusFinish": 0.2,
|
||||||
|
"radiusStart": 0.04,
|
||||||
|
"speedSpread": 0.01,
|
||||||
|
"radiusSpread": 0.9,
|
||||||
|
"textures": "http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
||||||
|
"color": {"red": 200, "green": 170, "blue": 255},
|
||||||
|
"colorFinish": {"red": 0, "green": 134, "blue": 255},
|
||||||
|
"colorStart": {"red": 185, "green": 222, "blue": 255},
|
||||||
|
"emitOrientation": {"w": -0.71, "x":0.0, "y":0.0, "z": 0.71},
|
||||||
|
"emitAcceleration": {"x": 0.0, "y": 0.0, "z": 0.0},
|
||||||
|
"accelerationSpread": {"x": 0.0, "y": 0.0, "z": 0.0},
|
||||||
|
"dimensions": {"x":0.05, "y": 0.05, "z": 0.05},
|
||||||
|
"type": "ParticleEffect"
|
||||||
|
};
|
||||||
|
|
||||||
var currentHand;
|
var currentHand;
|
||||||
var state = STATES.inactive;
|
var state = STATES.inactive;
|
||||||
|
@ -78,6 +108,9 @@ var waitingList = {};
|
||||||
var particleEffect;
|
var particleEffect;
|
||||||
var waitingBallScale;
|
var waitingBallScale;
|
||||||
var particleRotationAngle = 0.0;
|
var particleRotationAngle = 0.0;
|
||||||
|
var makingFriendsParticleEffect;
|
||||||
|
var makingFriendsEmitRate = 2000;
|
||||||
|
var particleEmitRate = 500;
|
||||||
|
|
||||||
function debug() {
|
function debug() {
|
||||||
var stateString = "<" + STATE_STRINGS[state] + ">";
|
var stateString = "<" + STATE_STRINGS[state] + ">";
|
||||||
|
@ -178,6 +211,17 @@ function deleteParticleEffect() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function calcParticlePos(myHand, otherHand, otherOrientation, reset) {
|
||||||
|
if (reset) {
|
||||||
|
particleRotationAngle = 0.0;
|
||||||
|
}
|
||||||
|
var position = positionFractionallyTowards(myHand, otherHand, 0.5);
|
||||||
|
particleRotationAngle += PARTICLE_ANGLE_INCREMENT; // about 0.5 hz
|
||||||
|
var radius = Math.min(PARTICLE_RADIUS, PARTICLE_RADIUS * particleRotationAngle / 720);
|
||||||
|
var axis = Vec3.mix(Quat.getFront(MyAvatar.orientation), Quat.inverse(Quat.getFront(otherOrientation)), 0.5);
|
||||||
|
return Vec3.sum(position, Vec3.multiplyQbyV(Quat.angleAxis(particleRotationAngle, axis), {x: 0, y: radius, z: 0}));
|
||||||
|
}
|
||||||
|
|
||||||
// this is called frequently, but usually does nothing
|
// this is called frequently, but usually does nothing
|
||||||
function updateVisualization() {
|
function updateVisualization() {
|
||||||
// after making friends, if you are still holding the grip lets transition
|
// after making friends, if you are still holding the grip lets transition
|
||||||
|
@ -189,57 +233,94 @@ function updateVisualization() {
|
||||||
if (state == STATES.inactive) {
|
if (state == STATES.inactive) {
|
||||||
deleteOverlay();
|
deleteOverlay();
|
||||||
deleteParticleEffect();
|
deleteParticleEffect();
|
||||||
|
if (makingFriendsParticleEffect) {
|
||||||
|
makingFriendsParticleEffect = Entities.deleteEntity(makingFriendsParticleEffect);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var textures = TEXTURES[state-1];
|
var textures = TEXTURES[state-1];
|
||||||
var myHandPosition = getHandPosition(MyAvatar, currentHand);
|
var myHandPosition = getHandPosition(MyAvatar, currentHand);
|
||||||
var position = myHandPosition;
|
|
||||||
var otherHand;
|
var otherHand;
|
||||||
|
var otherOrientation;
|
||||||
if (friendingId) {
|
if (friendingId) {
|
||||||
var other = AvatarList.getAvatar(friendingId);
|
var other = AvatarList.getAvatar(friendingId);
|
||||||
if (other) {
|
if (other) {
|
||||||
|
otherOrientation = other.orientation;
|
||||||
otherHand = getHandPosition(other, stringToHand(friendingHand));
|
otherHand = getHandPosition(other, stringToHand(friendingHand));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// scale the dimensions of the waiting/makingFriends ball to hand, capping
|
// scale the dimensions of the waiting/makingFriends ball to hand, capping
|
||||||
// at MAX_AVATAR_DISTANCE if someone happens to be huge
|
// at MAX_AVATAR_DISTANCE if someone happens to be huge
|
||||||
var wrist = MyAvatar.getJointPosition(MyAvatar.getJointIndex(handToString(currentHand)));
|
var wrist = MyAvatar.getJointPosition(MyAvatar.getJointIndex(handToString(currentHand)));
|
||||||
var d = Math.min(MAX_AVATAR_DISTANCE, Vec3.distance(wrist, position));
|
var d = Math.min(MAX_AVATAR_DISTANCE, Vec3.distance(wrist, myHandPosition));
|
||||||
if (state != STATES.friending) {
|
switch (state) {
|
||||||
deleteParticleEffect();
|
case STATES.waiting:
|
||||||
var dimension = {x: d, y: d, z: d};
|
deleteParticleEffect();
|
||||||
if (!overlay) {
|
if (makingFriendsParticleEffect) {
|
||||||
waitingBallScale = (state == STATES.waiting ? 1.0/32.0 : 1.0);
|
makingFriendsParticleEffect = Entities.deleteEntity(makingFriendsParticleEffect);
|
||||||
var props = {
|
}
|
||||||
url: MODEL_URL,
|
var dimension = {x: d, y: d, z: d};
|
||||||
position: myHandPosition,
|
if (!overlay) {
|
||||||
dimensions: Vec3.multiply(waitingBallScale, dimension),
|
waitingBallScale = (state == STATES.waiting ? 1.0/32.0 : 1.0);
|
||||||
textures: textures
|
var props = {
|
||||||
};
|
url: MODEL_URL,
|
||||||
overlay = Overlays.addOverlay("model", props);
|
position: myHandPosition,
|
||||||
} else {
|
dimensions: Vec3.multiply(waitingBallScale, dimension),
|
||||||
waitingBallScale = Math.min(1.0, waitingBallScale * 1.1);
|
textures: textures
|
||||||
Overlays.editOverlay(overlay, {textures: textures});
|
};
|
||||||
Overlays.editOverlay(overlay, {dimensions: Vec3.multiply(waitingBallScale, dimension), position: state == STATES.waiting ? myHandPosition : otherHand});
|
overlay = Overlays.addOverlay("model", props);
|
||||||
}
|
} else {
|
||||||
} else {
|
waitingBallScale = Math.min(1.0, waitingBallScale * 1.1);
|
||||||
deleteOverlay();
|
Overlays.editOverlay(overlay, {textures: textures});
|
||||||
var particleProps = {};
|
Overlays.editOverlay(overlay, {dimensions: Vec3.multiply(waitingBallScale, dimension), position: myHandPosition});
|
||||||
// put the position between the 2 hands, if we have a friendingId. This
|
}
|
||||||
// helps define the plane in which the particles move.
|
break;
|
||||||
position = positionFractionallyTowards(position, otherHand, 0.5);
|
case STATES.friending:
|
||||||
particleProps.position = position;
|
deleteOverlay();
|
||||||
// now manage the rest of the entity
|
var particleProps = {};
|
||||||
if (!particleEffect) {
|
// put the position between the 2 hands, if we have a friendingId. This
|
||||||
particleRotationAngle = 0.0;
|
// helps define the plane in which the particles move.
|
||||||
particleProps = PARTICLE_EFFECT_PROPS;
|
positionFractionallyTowards(myHandPosition, otherHand, 0.5);
|
||||||
particleEffect = Entities.addEntity(particleProps);
|
// now manage the rest of the entity
|
||||||
} else {
|
if (!particleEffect) {
|
||||||
particleRotationAngle += PARTICLE_ANGLE_INCREMENT; // about 1 hz
|
particleRotationAngle = 0.0;
|
||||||
particleProps.position = Vec3.sum(position, Vec3.multiplyQbyV(Quat.angleAxis(particleRotationAngle, Quat.getFront(MyAvatar.orientation)), {x:0, y:PARTICLE_RADIUS, z:0}));
|
var position = calcParticlePos(myHandPosition, otherHand, otherOrientation);
|
||||||
Entities.editEntity(particleEffect, particleProps);
|
particleProps = PARTICLE_EFFECT_PROPS;
|
||||||
}
|
particleProps.isEmitting = 0;
|
||||||
|
particleProps.position = position;
|
||||||
|
particleEffect = Entities.addEntity(particleProps);
|
||||||
|
} else {
|
||||||
|
var position = calcParticlePos(myHandPosition, otherHand, otherOrientation);
|
||||||
|
particleProps.position = position; //Vec3.sum(position, Vec3.multiplyQbyV(Quat.angleAxis(particleRotationAngle, axis), {x: 0, y: radius, z: 0}));
|
||||||
|
//particleProps.position = Vec3.sum(position, Vec3.multiplyQbyV(Quat.angleAxis(particleRotationAngle, Quat.getFront(MyAvatar.orientation)),{x: 0, y: radius, z: 0}));
|
||||||
|
particleProps.isEmitting = 1;
|
||||||
|
/*if (particleRotationAngle > 0.9 * 720) {
|
||||||
|
particleProps.lifespan = 6;
|
||||||
|
particleProps.isEmitting = 0;
|
||||||
|
}*/
|
||||||
|
Entities.editEntity(particleEffect, particleProps);
|
||||||
|
}
|
||||||
|
if (!makingFriendsParticleEffect) {
|
||||||
|
props = MAKING_FRIENDS_PARTICLE_PROPS;
|
||||||
|
makingFriendsEmitRate = 2000;
|
||||||
|
props.emitRate = makingFriendsEmitRate;
|
||||||
|
props.position = myHandPosition;
|
||||||
|
makingFriendsParticleEffect = Entities.addEntity(props);
|
||||||
|
} else {
|
||||||
|
makingFriendsEmitRate *= 0.5;
|
||||||
|
Entities.editEntity(makingFriendsParticleEffect, {emitRate: makingFriendsEmitRate, position: myHandPosition, isEmitting: 1});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STATES.makingFriends:
|
||||||
|
particleEmitRate *= 0.5;
|
||||||
|
Entities.editEntity(makingFriendsParticleEffect, {emitRate: 0, isEmitting: 0, position: myHandPosition});
|
||||||
|
var pos = calcParticlePos(myHandPosition, otherHand, otherOrientation);
|
||||||
|
Entities.editEntity(particleEffect, {position: position, emitRate: particleEmitRate});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
debug("unexpected state", state);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue