I currently have a traditional clock displayed in my setting that I want to synchronize with the current time. I am able to keep the clock running by calculating each hand's rotation every second, but I am encountering peculiar issues with the minute and hour hands.
hourHand = scene.getObjectByName('Box001');
minuteHand = scene.getObjectByName('Box002');
secondHand = scene.getObjectByName('Cylinder002');
var d = new Date();
var mins = d.getMinutes();
var secs = d.getSeconds();
var hours = d.getHours();
minuteHand.rotateY((-mins / 60) * (2 * Math.PI));
secondHand.rotateY(((mins /60) + (-secs / 3600)) * (2 * Math.PI));
hourHand.rotateY(((-hours / 12) + (mins / 720)) * (2 * Math.PI));
setInterval(function(){
minuteHand.rotateY((2 * Math.PI) / -3600);
secondHand.rotateY((2 * Math.PI) / -60);
hourHand.rotateY((2 * Math.PI) / (-3600 * 12));
},1000);
The challenges I'm facing include:
- When it is 4:30, the hour hand points directly at 4 instead of being positioned between the 4 and 5; the same issue occurs with the minute hand.
- I am uncertain about the accuracy of my mathematical calculations since I am observing some unexpected anomalies over time which are difficult to identify.
Is there a more precise method to achieve this synchronization?