Iām new to 8th Wall and learning about how to create AR apps. I wanted to try building a simple app that detects image targets and triggers an alert when one is recognized. Is this possible to do with the free version of 8th Wall?
Hi, welcome to the forums!
Yes! You can use the imagefound
event.
import * as ecs from '@8thwall/ecs'
ecs.registerComponent({
name: 'Hero Character',
schema: {
},
schemaDefaults: {
},
data: {
},
stateMachine: ({world, eid}) => {
ecs.defineState('idle')
.initial()
.onEnter(() => {
ecs.GltfModel.set(world, eid, {
animationClip: 'Idle_C',
loop: true,
timeScale: 100,
})
})
.listen(world.events.globalId, 'reality.imagelost', (e) => {
ecs.GltfModel.set(world, eid, {
animationClip: 'Idle_C',
loop: true,
timeScale: 1,
time: 0,
})
})
.listen(world.events.globalId, 'reality.imagefound', (e) => {
ecs.GltfModel.set(world, eid, {
animationClip: '103571_Devouring_Appear',
loop: false,
timeScale: 0.6,
time: 0,
})
})
.listen(eid, ecs.events.GLTF_ANIMATION_FINISHED, () => {
ecs.GltfModel.set(world, eid, {
animationClip: 'Idle_C',
loop: true,
timeScale: 1,
time: 0,
})
})
},
})