mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Fixed scaling of self
This commit is contained in:
parent
91bfa65fe2
commit
fe92d38b60
1 changed files with 22 additions and 11 deletions
|
@ -26,6 +26,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
//
|
//
|
||||||
// add lines where the hand ray picking is happening
|
// add lines where the hand ray picking is happening
|
||||||
//
|
//
|
||||||
|
|
||||||
var WANT_DEBUG = false;
|
var WANT_DEBUG = false;
|
||||||
var WANT_DEBUG_STATE = false;
|
var WANT_DEBUG_STATE = false;
|
||||||
var WANT_DEBUG_SEARCH_NAME = null;
|
var WANT_DEBUG_SEARCH_NAME = null;
|
||||||
|
@ -752,6 +753,7 @@ function MyController(hand) {
|
||||||
this.previouslyUnhooked = {};
|
this.previouslyUnhooked = {};
|
||||||
|
|
||||||
this.shouldScale = false;
|
this.shouldScale = false;
|
||||||
|
this.isScalingAvatar = false;
|
||||||
|
|
||||||
// handPosition is where the avatar's hand appears to be, in-world.
|
// handPosition is where the avatar's hand appears to be, in-world.
|
||||||
this.getHandPosition = function () {
|
this.getHandPosition = function () {
|
||||||
|
@ -825,10 +827,10 @@ function MyController(hand) {
|
||||||
this.update = function(deltaTime, timestamp) {
|
this.update = function(deltaTime, timestamp) {
|
||||||
this.updateSmoothedTrigger();
|
this.updateSmoothedTrigger();
|
||||||
// If both trigger and grip buttons squeezed and nothing is held, rescale my avatar!
|
// If both trigger and grip buttons squeezed and nothing is held, rescale my avatar!
|
||||||
if (this.hand === RIGHT_HAND && this.state === STATE_SEARCHING &&
|
//if (this.hand === RIGHT_HAND && this.state === STATE_SEARCHING &&
|
||||||
this.getOtherHandController().state === STATE_SEARCHING) {
|
// this.getOtherHandController().state === STATE_SEARCHING) {
|
||||||
this.maybeScaleMyAvatar();
|
this.maybeScaleMyAvatar();
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (this.ignoreInput()) {
|
if (this.ignoreInput()) {
|
||||||
|
|
||||||
|
@ -2595,25 +2597,34 @@ function MyController(hand) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.maybeScaleMyAvatar = function() {
|
this.maybeScaleMyAvatar = function() {
|
||||||
if (!myAvatarScalingEnabled) {
|
if (!myAvatarScalingEnabled || this.shouldScale || this.hand === LEFT_HAND) {
|
||||||
|
// If scaling disabled, or if we are currently scaling an entity, don't scale avatar
|
||||||
|
// and only rescale avatar for one hand (so we're not doing it twice)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.shouldScale) {
|
// Only scale avatar if both triggers and grips are squeezed
|
||||||
|
var tryingToScale = this.secondarySqueezed() && this.getOtherHandController().secondarySqueezed() &&
|
||||||
|
this.triggerSmoothedSqueezed() && this.getOtherHandController().triggerSmoothedSqueezed();
|
||||||
|
|
||||||
|
|
||||||
|
if (!this.isScalingAvatar) {
|
||||||
// If both secondary triggers squeezed, start scaling
|
// If both secondary triggers squeezed, start scaling
|
||||||
if (this.secondarySqueezed() && this.getOtherHandController().secondarySqueezed()) {
|
if (tryingToScale) {
|
||||||
this.scalingStartDistance = Vec3.length(Vec3.subtract(this.getHandPosition(),
|
this.scalingStartDistance = Vec3.length(Vec3.subtract(this.getHandPosition(),
|
||||||
this.getOtherHandController().getHandPosition()));
|
this.getOtherHandController().getHandPosition()));
|
||||||
this.scalingStartAvatarScale = MyAvatar.scale;
|
this.scalingStartAvatarScale = MyAvatar.scale;
|
||||||
this.shouldScale = true;
|
this.isScalingAvatar = true;
|
||||||
}
|
}
|
||||||
} else if (!this.secondarySqueezed() || !this.getOtherHandController().secondarySqueezed()) {
|
} else if (!tryingToScale) {
|
||||||
this.shouldScale = false;
|
this.isScalingAvatar = false;
|
||||||
}
|
}
|
||||||
if (this.shouldScale) {
|
if (this.isScalingAvatar) {
|
||||||
var scalingCurrentDistance = Vec3.length(Vec3.subtract(this.getHandPosition(),
|
var scalingCurrentDistance = Vec3.length(Vec3.subtract(this.getHandPosition(),
|
||||||
this.getOtherHandController().getHandPosition()));
|
this.getOtherHandController().getHandPosition()));
|
||||||
var newAvatarScale = (scalingCurrentDistance / this.scalingStartDistance) * this.scalingStartAvatarScale;
|
var newAvatarScale = (scalingCurrentDistance / this.scalingStartDistance) * this.scalingStartAvatarScale;
|
||||||
|
if (MyAvatar.scale != newAvatarScale) {
|
||||||
|
}
|
||||||
MyAvatar.scale = newAvatarScale;
|
MyAvatar.scale = newAvatarScale;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue