Commit 6bc23ee
fix: emit finished event for one-time animations
Two separate bugs prevented the 'finished' event from being dispatched
when an animation was played a single time (repetitions: 1):
1. Mixer event subscriptions were lost on model load (regression from
4.3.0). The multi-model refactor recreates the animation mixers on
every setSource(), but the mixer event subscriptions are registered
only once, when the animation feature is constructed — before any
model is loaded, while there are no mixers yet. They were never
re-applied to the mixers created later, so 'finished' (and 'loop')
were never dispatched. ModelScene now remembers its subscriptions and
attaches them to every mixer it creates.
2. Setting the animationName property and then calling play() looped
forever (present in all versions). Assigning animationName schedules
an asynchronous reactive update whose updated() re-triggers playback;
it did so with the default options (repetitions: Infinity /
LoopRepeat), overwriting a play({repetitions: 1}) issued in the same
tick, so the clip looped and never finished. Using the declarative
animation-name attribute avoided this only because the property never
changed. play() now records its options and the re-trigger reuses them
instead of resetting to an infinite loop.
Both paths are covered by regression tests in animation-spec.ts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 33e5562 commit 6bc23ee
3 files changed
Lines changed: 78 additions & 7 deletions
File tree
- packages/model-viewer/src
- features
- test/features
- three-components
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| |||
189 | 197 | | |
190 | 198 | | |
191 | 199 | | |
192 | | - | |
| 200 | + | |
| 201 | + | |
193 | 202 | | |
194 | 203 | | |
195 | 204 | | |
| |||
256 | 265 | | |
257 | 266 | | |
258 | 267 | | |
259 | | - | |
260 | | - | |
261 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
262 | 276 | | |
263 | 277 | | |
264 | 278 | | |
265 | 279 | | |
266 | 280 | | |
267 | 281 | | |
268 | 282 | | |
269 | | - | |
| 283 | + | |
270 | 284 | | |
271 | 285 | | |
272 | 286 | | |
| |||
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
84 | 121 | | |
85 | 122 | | |
86 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
| |||
281 | 287 | | |
282 | 288 | | |
283 | 289 | | |
284 | | - | |
| 290 | + | |
285 | 291 | | |
286 | 292 | | |
287 | 293 | | |
288 | | - | |
| 294 | + | |
289 | 295 | | |
290 | 296 | | |
291 | 297 | | |
| |||
1282 | 1288 | | |
1283 | 1289 | | |
1284 | 1290 | | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
1285 | 1294 | | |
1286 | 1295 | | |
1287 | 1296 | | |
1288 | 1297 | | |
1289 | 1298 | | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
1290 | 1310 | | |
1291 | 1311 | | |
1292 | 1312 | | |
| |||
0 commit comments