@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 691 B
JavaScript
import*as Platform from"../../../core/platform/platform.js";const filmStripCache=new Map;export function fromTraceData(t,e){const r=[],n=void 0!==e?e:t.Meta.traceBounds.min,s=t.Meta.traceBounds.range,o=filmStripCache.get(t)?.get(n);if(o)return o;for(const e of t.Screenshots){if(e.ts<n)continue;const t={index:r.length,screenshotEvent:e,screenshotAsString:e.args.snapshot};r.push(t)}const a={zeroTime:n,spanTime:s,frames:Array.from(r)};return Platform.MapUtilities.getWithDefault(filmStripCache,t,(()=>new Map)).set(n,a),a}export function frameClosestToTimestamp(t,e){const r=Platform.ArrayUtilities.nearestIndexFromEnd(t.frames,(t=>t.screenshotEvent.ts<e));return null===r?null:t.frames[r]}