xxxxxxxxxx
26
// Asking for permision for motion sensors on iOS 13+ devices
if (typeof DeviceOrientationEvent.requestPermission === 'function') {
document.body.addEventListener('click', function() {
DeviceOrientationEvent.requestPermission();
DeviceMotionEvent.requestPermission();
})
}
function setup() {
createCanvas(windowWidth, windowHeight);
setShakeThreshold(10);
rectMode(CENTER);
}
function draw() {
//background(0);
textAlign(CENTER, CENTER);
text(rotationZ, width / 2, height / 2);
}
function deviceShaken() {
let force = dist(accelerationX, accelerationY, pAccelerationX, pAccelerationY);
console.log(force);
fill('red');
rect(width / 2, height / 2, pow(force, 1.1), pow(force, 1.1));
}