rwaldron / sensors

Notes for Sensor API unification
3 stars 3 forks source link

Provide a way of tying sensor requests to animation frames #5

Open domenic opened 10 years ago

domenic commented 10 years ago

For games and other animation frame loop-based situations (off the top of my head, accelerometer-based scrolling comes to mind) you want one value per animation frame.

Chrome is actually doing work specifically to integrate our scheduling of input events and animation frames, see Blink Scheduler design doc.

Off the top of my head, frequency: "animationframe" might be good. The contract being that, if you pass that in to the constructor, then given

requestAnimationFrame(function frame() {
  console.log(mySensor.value);
  requestAnimationFrame(frame);
});

you will get an updated value every frame.

I don't think frequency: 60 is quite the same thing (but I could be wrong; will try to tag in some Blink engineers) since animation frames often vary away from 60 Hz and so you will quickly get out of sync.

Posted to blink-dev: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/fLucJ2QH3fA unsure whether people will follow-up here or there.

tobie commented 10 years ago

Off the top of my head, frequency: "animationframe" might be good.

Would it make sense to have that as the default behavior too?

rwaldron commented 10 years ago

Off the top of my head, frequency: "animationframe" might be good.

This is a very cool idea.

tobie commented 9 years ago

Moved to: w3c/sensors#4