ondevicemotionイベントハンドラで加速度センサーを拾う。

各座標のオブジェクトプロパティは

accelerationIncludingGravity.x;
accelerationIncludingGravity.y;
accelerationIncludingGravity.z;


んで、jQueryでbindした際

$(window).bind('devicemotion', function(event){
    ax = event.accelerationIncludingGravity.x;
    ay = event.accelerationIncludingGravity.y;
    az = event.accelerationIncludingGravity.z;
});

では取れない。jQueryのドキュメント(Event Object – jQuery API)にSperial Propertiesの項目

Certain native events may have special properties that can be accessed as properties of the event.originalEvent object.

があるように、加速度センサーのイベントは特別なイベントなんだろうね。

だから、

$(window).bind('devicemotion', function(event){
    ax = event.originalEvent.accelerationIncludingGravity.x;
    ay = event.originalEvent.accelerationIncludingGravity.y;
    az = event.originalEvent.accelerationIncludingGravity.z;
});

とプロパティにアクセスする。


余談。

jQueryでcanvasとなるオブジェクトを拾う場合

e.g.
//var cv = document.getElementById('hoge');
var cv = $('#hoge').get(0); # or $('#hoge')[0];
var ctx = cv.getContext('2d');
<canvas id="hoge"></canvas>