rotation working for second hand

This commit is contained in:
ericrius1 2016-03-23 11:17:49 -07:00
parent 6758c5f210
commit cf9ef1078d
2 changed files with 15 additions and 9 deletions

View file

@ -34,7 +34,7 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
loop: false loop: false
}, },
position: spawnPosition, position: spawnPosition,
// rotation: clockRotation, rotation: clockRotation,
dimensions: { dimensions: {
x: 0.8181, x: 0.8181,
y: 1.3662, y: 1.3662,
@ -84,7 +84,7 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
var myDate = new Date() var myDate = new Date()
// HOUR HAND ************************* // HOUR HAND *************************
var clockHandForwardOffset = -0.05; var clockHandForwardOffset = -0.02;
var hourHandPosition = Vec3.sum(clockFacePosition, Vec3.multiply(Quat.getFront(clockRotation), clockHandForwardOffset)); var hourHandPosition = Vec3.sum(clockFacePosition, Vec3.multiply(Quat.getFront(clockRotation), clockHandForwardOffset));
var DEGREES_FOR_HOUR = 30 var DEGREES_FOR_HOUR = 30
var hours = myDate.getHours(); var hours = myDate.getHours();
@ -94,6 +94,7 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
// var ANGULAR_ROLL_SPEED_HOUR_RADIANS = 0.000029098833; // var ANGULAR_ROLL_SPEED_HOUR_RADIANS = 0.000029098833;
clockHourHand = Entities.addEntity({ clockHourHand = Entities.addEntity({
type: "Model", type: "Model",
visible: false,
name: "hifi-home-model-clockHourHand", name: "hifi-home-model-clockHourHand",
parentID: clockFace, parentID: clockFace,
modelURL: CLOCK_HOUR_HAND_URL, modelURL: CLOCK_HOUR_HAND_URL,
@ -127,7 +128,15 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
var DEGREES_FOR_SECOND = 6; var DEGREES_FOR_SECOND = 6;
var seconds = myDate.getSeconds(); var seconds = myDate.getSeconds();
secondRollDegrees = -seconds * DEGREES_FOR_SECOND; secondRollDegrees = -seconds * DEGREES_FOR_SECOND;
var localClockHandRotation = Quat.fromPitchYawRollDegrees(0, 0, secondRollDegrees);
var worldClockHandRotation = Quat.multiply(clockRotation, localClockHandRotation);
var ANGULAR_ROLL_SPEED_SECOND_RADIANS = 0.10472 var ANGULAR_ROLL_SPEED_SECOND_RADIANS = 0.10472
var localAngularVelocity = {
x: 0,
y: 0,
z: -ANGULAR_ROLL_SPEED_SECOND_RADIANS
};
var worldAngularVelocity = Vec3.multiplyQbyV(clockRotation, localAngularVelocity);
clockSecondHand = Entities.addEntity({ clockSecondHand = Entities.addEntity({
type: "Model", type: "Model",
parentID: clockBody, parentID: clockBody,
@ -149,13 +158,9 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
y: 0.05, y: 0.05,
z: 0.5 z: 0.5
}, },
rotation: Quat.fromPitchYawRollDegrees(0, 0, secondRollDegrees), rotation:worldClockHandRotation,
angularDamping: 0, angularDamping: 0,
angularVelocity: { angularVelocity: worldAngularVelocity ,
x: 0,
y: 0,
z: -ANGULAR_ROLL_SPEED_SECOND_RADIANS
},
userData: JSON.stringify({ userData: JSON.stringify({
hifiHomeKey: { hifiHomeKey: {
reset: true reset: true
@ -175,6 +180,7 @@ MyCuckooClock = function(spawnPosition, spawnRotation) {
modelURL: CLOCK_HOUR_HAND_URL, modelURL: CLOCK_HOUR_HAND_URL,
name: "hifi-home-model-clockMinuteHand", name: "hifi-home-model-clockMinuteHand",
parentID: clockFace, parentID: clockFace,
visible: false,
position: hourHandPosition, position: hourHandPosition,
registrationPoint: { registrationPoint: {
x: 0.5, x: 0.5,

View file

@ -172,7 +172,7 @@
z: -81.9495 z: -81.9495
}, { }, {
x: 0, x: 0,
y: 0, y: -57,
z: 0 z: 0
}); });
// var doppelganger = new Doppelganger(); // var doppelganger = new Doppelganger();