mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
hack somewhat different visualization in. If this is ok, will cleanup
This commit is contained in:
parent
58ac34b336
commit
c425c32b8f
1 changed files with 28 additions and 22 deletions
|
@ -63,15 +63,17 @@ const PARTICLE_EFFECT_PROPS = {
|
||||||
"y": 0.0,
|
"y": 0.0,
|
||||||
"z": 0.0
|
"z": 0.0
|
||||||
},
|
},
|
||||||
"emitRate": 360,
|
"emitRate": 100,
|
||||||
"emitSpeed": 0.0003,
|
"emitSpeed": 0.001,//0.0003,
|
||||||
"emitterShouldTrail": 1,
|
"emitterShouldTrail": 1,
|
||||||
"maxParticles": 1370,
|
"maxParticles": 25,
|
||||||
"polarFinish": 1,
|
"polarStart" : -Math.PI/2,
|
||||||
|
"polarFinish": Math.PI/2,
|
||||||
"radiusSpread": 9,
|
"radiusSpread": 9,
|
||||||
"radiusStart": 0.04,
|
"radiusStart": 0.04,
|
||||||
"radiusFinish": 0.02,
|
"radiusFinish": 0.02,
|
||||||
"speedSpread": 0.09,
|
"speedSpread": 0.09,
|
||||||
|
"lifespan": 3.0,
|
||||||
"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",
|
||||||
"type": "ParticleEffect"
|
"type": "ParticleEffect"
|
||||||
};
|
};
|
||||||
|
@ -83,12 +85,12 @@ var waitingInterval;
|
||||||
var makingFriendsTimeout;
|
var makingFriendsTimeout;
|
||||||
var overlay;
|
var overlay;
|
||||||
var animHandlerId;
|
var animHandlerId;
|
||||||
var entityDimensionMultiplier = 1.0;
|
|
||||||
var friendingId;
|
var friendingId;
|
||||||
var friendingHand;
|
var friendingHand;
|
||||||
var waitingList = {};
|
var waitingList = {};
|
||||||
var particleEffect;
|
var particleEffect;
|
||||||
var waitingBallScale;
|
var waitingBallScale;
|
||||||
|
var particleRotationAngle = 0.0;
|
||||||
|
|
||||||
function debug() {
|
function debug() {
|
||||||
var stateString = "<" + STATE_STRINGS[state] + ">";
|
var stateString = "<" + STATE_STRINGS[state] + ">";
|
||||||
|
@ -179,42 +181,50 @@ function positionFractionallyTowards(posA, posB, frac) {
|
||||||
|
|
||||||
// this is called frequently, but usually does nothing
|
// this is called frequently, but usually does nothing
|
||||||
function updateVisualization() {
|
function updateVisualization() {
|
||||||
if (state != STATES.waiting) {
|
// after making friends, if you are still holding the grip lets transition
|
||||||
|
// back to waiting
|
||||||
|
if (state == STATES.makingFriends && !friendingId) {
|
||||||
|
startHandshake();
|
||||||
|
}
|
||||||
|
if (state == STATES.friending) {
|
||||||
if (overlay) {
|
if (overlay) {
|
||||||
overlay = Overlays.deleteOverlay(overlay);
|
overlay = Overlays.deleteOverlay(overlay);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (state == STATES.inactive || state == STATES.waiting) {
|
|
||||||
if (particleEffect) {
|
if (particleEffect) {
|
||||||
particleEffect = Entities.deleteEntity(particleEffect);
|
particleEffect = Entities.deleteEntity(particleEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state == STATES.inactive) {
|
if (state == STATES.inactive) {
|
||||||
|
if (overlay) {
|
||||||
|
overlay = Overlays.deleteOverlay(overlay);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var textures = TEXTURES[state-1];
|
var textures = TEXTURES[state-1];
|
||||||
var position = getHandPosition(MyAvatar, currentHand);
|
var myHandPosition = getHandPosition(MyAvatar, currentHand);
|
||||||
|
var position = myHandPosition;
|
||||||
|
|
||||||
// TODO: make the size scale with avatar, up to
|
// TODO: make the size scale with avatar, up to
|
||||||
// the actual size of MAX_AVATAR_DISTANCE
|
// the actual size of MAX_AVATAR_DISTANCE
|
||||||
var wrist = MyAvatar.getJointPosition(MyAvatar.getJointIndex(handToString(currentHand)));
|
var wrist = MyAvatar.getJointPosition(MyAvatar.getJointIndex(handToString(currentHand)));
|
||||||
var d = Math.abs(entityDimensionMultiplier) * Vec3.distance(wrist, position);
|
var d = Vec3.distance(wrist, position);
|
||||||
if (friendingId) {
|
if (friendingId) {
|
||||||
// put the position between the 2 hands, if we have a friendingId
|
// put the position between the 2 hands, if we have a friendingId
|
||||||
var other = AvatarList.getAvatar(friendingId);
|
var other = AvatarList.getAvatar(friendingId);
|
||||||
if (other) {
|
if (other) {
|
||||||
var otherHand = getHandPosition(other, stringToHand(friendingHand));
|
var otherHand = getHandPosition(other, stringToHand(friendingHand));
|
||||||
position = positionFractionallyTowards(position, otherHand, entityDimensionMultiplier);
|
position = positionFractionallyTowards(position, otherHand, 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state == STATES.waiting) {
|
if (state != STATES.friending) {
|
||||||
var dimension = {x: d, y: d, z: d};
|
var dimension = {x: d, y: d, z: d};
|
||||||
if (!overlay) {
|
if (!overlay) {
|
||||||
waitingBallScale = 1.0/32.0;
|
waitingBallScale = (state == STATES.waiting ? 1.0/32.0 : 1.0);
|
||||||
var props = {
|
var props = {
|
||||||
url: MODEL_URL,
|
url: MODEL_URL,
|
||||||
position: position,
|
position: myHandPosition,
|
||||||
dimensions: Vec3.multiply(waitingBallScale, dimension),
|
dimensions: Vec3.multiply(waitingBallScale, dimension),
|
||||||
textures: textures
|
textures: textures
|
||||||
};
|
};
|
||||||
|
@ -222,19 +232,18 @@ function updateVisualization() {
|
||||||
} else {
|
} else {
|
||||||
waitingBallScale = Math.min(1.0, waitingBallScale * 1.1);
|
waitingBallScale = Math.min(1.0, waitingBallScale * 1.1);
|
||||||
Overlays.editOverlay(overlay, {textures: textures});
|
Overlays.editOverlay(overlay, {textures: textures});
|
||||||
Overlays.editOverlay(overlay, {dimensions: Vec3.multiply(waitingBallScale, dimension), position: position});
|
Overlays.editOverlay(overlay, {dimensions: Vec3.multiply(waitingBallScale, dimension), position: myHandPosition});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var particleProps = {};
|
var particleProps = {};
|
||||||
particleProps.position = position;
|
particleProps.position = position;
|
||||||
if (!particleEffect) {
|
if (!particleEffect) {
|
||||||
|
particleRotationAngle = 0.0;
|
||||||
particleProps = PARTICLE_EFFECT_PROPS;
|
particleProps = PARTICLE_EFFECT_PROPS;
|
||||||
particleEffect = Entities.addEntity(particleProps);
|
particleEffect = Entities.addEntity(particleProps);
|
||||||
} else {
|
} else {
|
||||||
if (state == STATES.makingFriends) {
|
particleRotationAngle += 360/45; // about 1 hz
|
||||||
particleProps.colorFinish = {red: 0xFF, green: 0x00, blue: 0x00};
|
particleProps.position = Vec3.sum(position, Vec3.multiplyQbyV(Quat.angleAxis(particleRotationAngle, Quat.getFront(MyAvatar.orientation)), {x:0, y:0.2, z:0}));
|
||||||
particleProps.color = particleProps.colorFinish;
|
|
||||||
}
|
|
||||||
Entities.editEntity(particleEffect, particleProps);
|
Entities.editEntity(particleEffect, particleProps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +297,6 @@ function startHandshake(fromKeyboard) {
|
||||||
}
|
}
|
||||||
debug("starting handshake for", currentHand);
|
debug("starting handshake for", currentHand);
|
||||||
state = STATES.waiting;
|
state = STATES.waiting;
|
||||||
entityDimensionMultiplier = 1.0;
|
|
||||||
friendingId = undefined;
|
friendingId = undefined;
|
||||||
friendingHand = undefined;
|
friendingHand = undefined;
|
||||||
// just in case
|
// just in case
|
||||||
|
@ -418,7 +426,6 @@ function makeFriends(id) {
|
||||||
makingFriendsTimeout = Script.setTimeout(function () {
|
makingFriendsTimeout = Script.setTimeout(function () {
|
||||||
friendingId = undefined;
|
friendingId = undefined;
|
||||||
friendingHand = undefined;
|
friendingHand = undefined;
|
||||||
entityDimensionMultiplier = 1.0;
|
|
||||||
makingFriendsTimeout = undefined;
|
makingFriendsTimeout = undefined;
|
||||||
}, MAKING_FRIENDS_TIMEOUT);
|
}, MAKING_FRIENDS_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
@ -445,7 +452,6 @@ function startFriending(id, hand) {
|
||||||
|
|
||||||
friendingInterval = Script.setInterval(function () {
|
friendingInterval = Script.setInterval(function () {
|
||||||
count += 1;
|
count += 1;
|
||||||
entityDimensionMultiplier = Math.abs(Math.sin(Math.PI * 2 * 2 * count * FRIENDING_INTERVAL / FRIENDING_TIME));
|
|
||||||
if (state != STATES.friending) {
|
if (state != STATES.friending) {
|
||||||
debug("stopping friending interval, state changed");
|
debug("stopping friending interval, state changed");
|
||||||
stopFriending();
|
stopFriending();
|
||||||
|
|
Loading…
Reference in a new issue