mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 04:48:09 +02:00
Fix a couple sitting bugs
This commit is contained in:
parent
698791295a
commit
c1466c2dec
1 changed files with 25 additions and 8 deletions
|
@ -1,6 +1,16 @@
|
||||||
|
//
|
||||||
|
// sit.js
|
||||||
|
//
|
||||||
|
// Created by Clement Brisset on 3/3/17
|
||||||
|
// Copyright 2017 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
|
||||||
|
//
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
Script.include("/~/system/libraries/utils.js");
|
Script.include("/~/system/libraries/utils.js");
|
||||||
|
|
||||||
var SETTING_KEY = "com.highfidelity.avatar.isSitting";
|
var SETTING_KEY = "com.highfidelity.avatar.isSitting";
|
||||||
var ANIMATION_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/clement/production/animations/sitting_idle.fbx";
|
var ANIMATION_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/clement/production/animations/sitting_idle.fbx";
|
||||||
var ANIMATION_FPS = 30;
|
var ANIMATION_FPS = 30;
|
||||||
|
@ -28,6 +38,7 @@
|
||||||
this.interval = null;
|
this.interval = null;
|
||||||
this.sitDownSettlePeriod = null;
|
this.sitDownSettlePeriod = null;
|
||||||
this.lastTimeNoDriveKeys = null;
|
this.lastTimeNoDriveKeys = null;
|
||||||
|
this.sittingDown = false;
|
||||||
|
|
||||||
this.preload = function(entityID) {
|
this.preload = function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
|
@ -106,6 +117,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print("Sitting down (" + this.entityID + ")");
|
print("Sitting down (" + this.entityID + ")");
|
||||||
|
this.sittingDown = true;
|
||||||
|
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
this.sitDownSettlePeriod = now + IK_SETTLE_TIME;
|
this.sitDownSettlePeriod = now + IK_SETTLE_TIME;
|
||||||
|
@ -121,6 +133,11 @@
|
||||||
for (i in ROLES) {
|
for (i in ROLES) {
|
||||||
MyAvatar.overrideRoleAnimation(ROLES[i], ANIMATION_URL, ANIMATION_FPS, true, ANIMATION_FIRST_FRAME, ANIMATION_LAST_FRAME);
|
MyAvatar.overrideRoleAnimation(ROLES[i], ANIMATION_URL, ANIMATION_FPS, true, ANIMATION_FIRST_FRAME, ANIMATION_LAST_FRAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
||||||
|
MyAvatar.disableDriveKey(OVERRIDEN_DRIVE_KEYS[i]);
|
||||||
|
}
|
||||||
|
|
||||||
MyAvatar.resetSensorsAndBody();
|
MyAvatar.resetSensorsAndBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,22 +149,21 @@
|
||||||
return { headType: 0 };
|
return { headType: 0 };
|
||||||
}, ["headType"]);
|
}, ["headType"]);
|
||||||
Script.update.connect(this, this.update);
|
Script.update.connect(this, this.update);
|
||||||
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
|
||||||
MyAvatar.disableDriveKey(OVERRIDEN_DRIVE_KEYS[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.standUp = function() {
|
this.standUp = function() {
|
||||||
print("Standing up (" + this.entityID + ")");
|
print("Standing up (" + this.entityID + ")");
|
||||||
MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);
|
MyAvatar.removeAnimationStateHandler(this.animStateHandlerID);
|
||||||
Script.update.disconnect(this, this.update);
|
Script.update.disconnect(this, this.update);
|
||||||
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
|
||||||
MyAvatar.enableDriveKey(OVERRIDEN_DRIVE_KEYS[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setSeatUser(null);
|
this.setSeatUser(null);
|
||||||
if (Settings.getValue(SETTING_KEY) === this.entityID) {
|
if (Settings.getValue(SETTING_KEY) === this.entityID) {
|
||||||
Settings.setValue(SETTING_KEY, "");
|
Settings.setValue(SETTING_KEY, "");
|
||||||
|
|
||||||
|
for (var i in OVERRIDEN_DRIVE_KEYS) {
|
||||||
|
MyAvatar.enableDriveKey(OVERRIDEN_DRIVE_KEYS[i]);
|
||||||
|
}
|
||||||
|
|
||||||
var ROLES = MyAvatar.getAnimationRoles();
|
var ROLES = MyAvatar.getAnimationRoles();
|
||||||
for (i in ROLES) {
|
for (i in ROLES) {
|
||||||
MyAvatar.restoreRoleAnimation(ROLES[i]);
|
MyAvatar.restoreRoleAnimation(ROLES[i]);
|
||||||
|
@ -165,6 +181,7 @@
|
||||||
MyAvatar.bodyRoll = 0.0;
|
MyAvatar.bodyRoll = 0.0;
|
||||||
}, SIT_DELAY);
|
}, SIT_DELAY);
|
||||||
}
|
}
|
||||||
|
this.sittingDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function called by teleport.js if it detects the appropriate userData
|
// function called by teleport.js if it detects the appropriate userData
|
||||||
|
@ -215,7 +232,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update = function(dt) {
|
this.update = function(dt) {
|
||||||
if (MyAvatar.sessionUUID === this.getSeatUser()) {
|
if (this.sittingDown === true) {
|
||||||
var properties = Entities.getEntityProperties(this.entityID);
|
var properties = Entities.getEntityProperties(this.entityID);
|
||||||
var avatarDistance = Vec3.distance(MyAvatar.position, properties.position);
|
var avatarDistance = Vec3.distance(MyAvatar.position, properties.position);
|
||||||
var ikError = MyAvatar.getIKErrorOnLastSolve();
|
var ikError = MyAvatar.getIKErrorOnLastSolve();
|
||||||
|
|
Loading…
Reference in a new issue