My GLB model restarts when image target is lost and that causes the audio to become out of sync. I really need solution I know just basics of programming. is all I need.. I got audio sync with image target thanks George for that!!! but just I need Animations Keeps at time once if found image target again
import * as ecs from ‘@8thwall/ecs’
ecs.registerComponent({
name: ‘PlayGLBClipOnImageFound’,
schema: {
model: ecs.eid, // Nodo del modelo GLB
clipName: ecs.string // Nombre del clip o “*” para reproducir todos
},
stateMachine: ({ world, eid, schemaAttribute }) => {
ecs.defineState(‘default’)
.initial()
.listen(world.events.globalId, ‘reality.imagefound’, () => {
const { model, clipName } = schemaAttribute.get(eid)
setTimeout(() => {
ecs.GltfModel.set(world, model, {
animationClip: clipName || '*',
loop: false,
paused: false,
time: 0,
timeScale: 1,
crossFadeDuration: 0
})
console.log(`🎬 Animación '${clipName || "*"}' reproducida con delay`)
}, 50) // 50 ms de retardo
})
}
})