Loading files
c44ec7454This file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/stack-chan-374381865.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
import { encodeTrackingPayload, TRACKING_MESSAGE_TYPE } from './tracking.mjs'
export const TRACKING_SEND_INTERVAL_MS = 100
export class LatestTrackingSender {
#inFlight = false
#latest
#faceDirty = false
#session
constructor(session) {
this.#session = session
}
queue(payload) {
this.#latest = payload
this.#faceDirty = true
}
async flush() {
if (this.#inFlight || !this.#latest || !this.#faceDirty) return false
const state = this.#latest
const payload = encodeTrackingPayload(state, { includeEmotion: true, includeHands: true, includeFaceParts: true })
this.#faceDirty = false
this.#inFlight = true
try {
await this.#session.broadcast(TRACKING_MESSAGE_TYPE, payload)
return true
} catch (error) {
if (this.#latest === state) this.#faceDirty = true
throw error
} finally {
this.#inFlight = false
}
}
clear() {
this.#latest = undefined
this.#faceDirty = false
}
}
c44ec7454This file is pinned to the selected release. Download the original to open it in your design tool.