24 lines
No EOL
1.4 KiB
JavaScript
24 lines
No EOL
1.4 KiB
JavaScript
|
|
function MoveClockHand(entityID, jointIndex){
|
|
print("Tick on joint index number "+jointIndex);
|
|
jointRot = Entities.getAbsoluteJointRotationInObjectFrame(entityID,jointIndex); // get current rotation of the joint
|
|
entRot = Quat.safeEulerAngles(jointRot); // convert to Euler
|
|
parentRot = Quat.safeEulerAngles(Entities.getEntityProperties(entityID, "rotation"));
|
|
entRot.x = parentRot.x; // get parent's x and y
|
|
entRot.y = parentRot.y;
|
|
entRot.z -= 6;// (entRot.z - 6)%360; // Increase it by 1 clock unit
|
|
//print(entRot.z);
|
|
newRot = Quat.fromVec3Degrees(entRot); // generate a quaternion from the euler
|
|
Entities.setAbsoluteJointRotationInObjectFrame(entityID, jointIndex, newRot);
|
|
}
|
|
|
|
var clockFaceUID = "6dc15ccf-d5e0-4636-9adf-76a047a5befa"; //; Set to match the UID of the clock please
|
|
var secondJointIndex = Entities.getJointIndex(clockFaceUID, "jointSecond");
|
|
var minuteJointIndex = Entities.getJointIndex(clockFaceUID, "jointMinute");
|
|
var hourJointIndex = Entities.getJointIndex(clockFaceUID, "jointHour");
|
|
|
|
var secondHandTimer = Script.setInterval(function() { MoveClockHand(clockFaceUID, secondJointIndex); }, 1000);
|
|
var minuteHandTimer = Script.setInterval(function() { MoveClockHand(clockFaceUID, minuteJointIndex); }, 3000);
|
|
var hourHandTimer = Script.setInterval(function() { MoveClockHand(clockFaceUID, hourJointIndex); }, 6000);
|
|
|
|
//6dc15ccf-d5e0-4636-9adf-76a047a5befa
|