Thanks James, this is helpfully for me, but I still have problem with this task.
Now I don't know how get a event from iframe. When I write this script:
var iframe = document.getElementById('api-frame');
var version = '1.0.0';
var urlid = '';
var client = new Sketchfab(version, iframe);
client.init(urlid, {
success: function onSuccess(api) {
api.start(function() {
$('body').mousemove(function(event) {
api.getCameraLookAt(function(err, camera) {
var currentPos = camera.position;
var currentTarg = camera.target;
z = currentPos[2];
if (z < 0) {
api.lookat(
[currentPos[0], currentPos[1], 0], [currentTarg[0], currentTarg[1], 0],
0
);
}
});
});
console.log('Viewer is ready');
});
},
error: function onError() {
console.log('Viewer error');
}
});
model back to right position but only when I move the mouse outside of the iframe.
I tried use $('#api-frame').contents() but I get answer: 'Error: Permission denied to access property "document" '.
So my problem is: how can I get event from iframe?