xxxxxxxxxx
122
//var ease = new p5.Ease();
//var easingAlgos = ease.listAlgos();
//var nAlgos = easingAlgos.length;
var curAlgo;
var incrementer = 0;
var angle = 0
var arm;
//===================================================
// User-modifiable global variables.
var myNickname = "MoMar";
var nFramesInLoop = 120;
var bEnableExport = true;
// Other global variables you don't need to touch.
var nElapsedFrames;
var bRecording;
var theCanvas;
var prevSec;
var millisRolloverTime;
//===================================================
function setup() {
theCanvas = createCanvas(640, 640, WEBGL);
bRecording = false;
nElapsedFrames = 0;
millisRolloverTime = 0;
arm = loadModel('arm_highpoly.obj');
angleMode(DEGREES);
let radius = min(width, height) / 2;
secondsRadius = radius * 0.71;
minutesRadius = radius * 0.6;
hoursRadius = radius * 0.5;
}
//===================================================
function draw() {
// Compute a percentage (0...1) representing where we are in the loop.
var percentCompleteFraction = percentCompleteFraction = float(frameCount % nFramesInLoop) / float(nFramesInLoop);
// Render the design, based on that percentage.
background(175);
renderMyDesign(percentCompleteFraction);
rectMode(CENTER);
//model(arm);
clock(0,0, .5);
}
//===================================================
function renderMyDesign(percent) {
}
function clock(locx, locy, size) {
//background(0);
translate(locx, locy);
rotateX(90);
scale(size, size);
let hr = hour();
let mn = minute();
let sc = second();
if (prevSec != sc) {
millisRolloverTime = millis();
}
else prevSec = sc;
var mils = floor(millis() - millisRolloverTime);
var secondsWithFraction = sc + (mils / 1000.0);
stroke(255, 100, 150);
noFill();
let secondAngle = map(sc, 0, 60, 0, 360);
let secondBarWidthSmooth = map(secondsWithFraction, 0, 60, 0, width);
stroke(150, 100, 255);
let minuteAngle = map(mn, 0, 60, 0, 360);
stroke(150, 255, 100);
let hourAngle = map(hr % 12, 0, 12, 0, 360);
push();
//rotate(secondAngle);
rotateY(secondAngle);
stroke(255, 100, 150);
model(arm);
pop();
push();
rotateY(minuteAngle);
stroke(150, 100, 255);
model(arm);
pop();
push();
rotateY(hourAngle);
stroke(150, 255, 100);
model(arm);
pop();
stroke(255);
point(0, 0);
//for (var i = 0; i <= 360; i += 30) {
// text("I", cos(i) * hoursRadius, sin(i) * hoursRadius);
// }
}