|
@@ -66,10 +66,12 @@ A reference to the [Gizmos](gizmos.md) object.
|
66
|
66
|
|
67
|
67
|
Schedules a call to the `callback` function, which is intended to update and render the virtual scene. Your `callback` function must itself call `session.requestAnimationFrame()` again in order to continue to update and render the virtual scene.
|
68
|
68
|
|
69
|
|
-!!! info "Note"
|
|
69
|
+!!! info "Notes"
|
70
|
70
|
|
71
|
71
|
`session.requestAnimationFrame()` is analogous to `window.requestAnimationFrame()`, but they are not the same! The former is a call to the WebAR engine, whereas the latter is a standard call to the web browser.
|
72
|
72
|
|
|
73
|
+ This call will be ignored and an invalid handle will be returned if the session has been [ended](#ended) (*since 0.3.0*). Previously, it would raise an exception.
|
|
74
|
+
|
73
|
75
|
**Arguments**
|
74
|
76
|
|
75
|
77
|
* `callback: function`. A function that receives two parameters:
|
|
@@ -83,15 +85,20 @@ A handle.
|
83
|
85
|
**Example**
|
84
|
86
|
|
85
|
87
|
```js
|
|
88
|
+//
|
|
89
|
+// This is the animation loop:
|
|
90
|
+//
|
|
91
|
+
|
86
|
92
|
function animate(time, frame)
|
87
|
93
|
{
|
88
|
94
|
// update and render the virtual scene
|
89
|
95
|
// ...
|
90
|
96
|
|
91
|
|
- // repeat the call
|
|
97
|
+ // repeat
|
92
|
98
|
session.requestAnimationFrame(animate);
|
93
|
99
|
}
|
94
|
100
|
|
|
101
|
+// start the animation loop
|
95
|
102
|
session.requestAnimationFrame(animate);
|
96
|
103
|
```
|
97
|
104
|
|
|
@@ -103,7 +110,7 @@ Cancels an animation frame request.
|
103
|
110
|
|
104
|
111
|
**Arguments**
|
105
|
112
|
|
106
|
|
-* `handle: SessionRequestAnimationFrameHandle`. A handle returned by `session.requestAnimationFrame()`.
|
|
113
|
+* `handle: SessionRequestAnimationFrameHandle`. A handle returned by `session.requestAnimationFrame()`. If the handle is invalid, this method does nothing.
|
107
|
114
|
|
108
|
115
|
### end
|
109
|
116
|
|