@@ -147,7 +147,12 @@ function updatePartInstancePlannedTimes(
147147}
148148
149149/**
150- * Replace the `now` time in any timeline objects in infinites
150+ * Replace the `now` time in any timeline objects in freshly-placed infinites.
151+ *
152+ * This is effectively only needed when a new item has been placed on the timeline just now and changes made by
153+ * `updatePlannedTimingsForPieceInstances` haven't been taken into account when generating the timeline. On the next
154+ * regeneration, items will already use the timestamps persited by `updatePlannedTimingsForPieceInstances` and will not
155+ * be included in `infiniteObjs`.
151156 */
152157function deNowifyInfinites (
153158 targetNowTime : number ,
@@ -179,28 +184,31 @@ function deNowifyInfinites(
179184 }
180185
181186 for ( const obj of infiniteObjs ) {
182- if ( ! Array . isArray ( obj . enable ) && obj . enable . start === 'now' ) {
183- if ( obj . inGroup ) {
184- const parentObject = timelineObjsMap [ obj . inGroup ]
185- if ( parentObject ) {
186- const parentStartTime = getStartTime ( parentObject )
187- if ( parentStartTime !== undefined ) {
188- obj . enable = { start : targetNowTime - parentStartTime }
189- } else {
190- logger . error (
191- `Unable to derive an absolute start time of parent "${ obj . inGroup } " for object "${ obj . id } " during deNowifyInfinites`
192- )
193- }
194- } else {
195- logger . error ( `Parent obj "${ obj . inGroup } " not found of object "${ obj . id } " during deNowifyInfinites` )
196- }
197- } else {
198- logger . error (
199- `Unexpected "now" time during deNowifyInfinites, setting to absolute time for a timelineObject not inGroup: "${ obj . id } "`
200- )
201- obj . enable = { start : targetNowTime }
202- }
187+ if ( Array . isArray ( obj . enable ) || obj . enable . start !== 'now' ) continue
188+
189+ if ( ! obj . inGroup ) {
190+ obj . enable = { start : targetNowTime }
191+ continue
203192 }
193+
194+ const parentObject = timelineObjsMap [ obj . inGroup ]
195+ if ( ! parentObject ) {
196+ logger . error ( `deNowifyInfinites: Parent obj "${ obj . inGroup } " not found of object "${ obj . id } "` )
197+ continue
198+ }
199+
200+ const parentStartTime = getStartTime ( parentObject )
201+ if ( parentStartTime === undefined ) {
202+ logger . error (
203+ `deNowifyInfinites: Unable to derive an absolute start time of parent "${ obj . inGroup } " for object "${ obj . id } "`
204+ )
205+ continue
206+ }
207+
208+ obj . enable = { start : targetNowTime - parentStartTime }
209+ logger . silly (
210+ `deNowifyInfinites: Setting "${ obj . id } " enable.start = ${ obj . enable . start } , ${ targetNowTime } ${ parentStartTime } parentObject: "${ parentObject . id } "`
211+ )
204212 }
205213}
206214/**
0 commit comments