8thwall を使用して作成された webapp があり、アニメーション用の新しいボタンを実装しました。このボタンに他のボタンと同じロジックを追加しました (以前のものは正常に動作しています) が、何らかの理由でこのボタンには機能がありません。
機能していないボタンは、shareButtonComponent です。誰かが私を案内してもらえますか?
const replayButtonComponent = () => ({
init() {
const model = document.getElementById('model')
const replayButton = document.getElementById('replaybutton')
const shopButton = document.getElementById('shopbutton')
const entity = document.querySelector('[sound]')
model.addEventListener('animation-finished', () => {
model.setAttribute('animation-mixer', {
clip: 'rabitidle',
loop: 'once',
timeScale: 0,
})
replayButton.classList.remove('inactive')
shopButton.classList.remove('inactive')
})
replayButton.style.display = 'block'
const replayAnimation = () => {
replayButton.classList.add('inactive')
shopButton.classList.add('inactive')
model.setAttribute('animation-mixer', {
clip: 'rabitanim',
loop: 'once',
timeScale: 1,
})
entity.components.sound.playSound()
}
replayButton.onclick = replayAnimation
},
})
export {replayButtonComponent}
const shareButtonComponent = () => ({
init() {
const shareToggle = document.getElementById('sharebutton')
shareToggle.style.display = 'block'
const holder = document.getElementById('hyperlink-holder')
shareToggle.addEventListener('click', () => {
holder.classList.toggle('holder-active')
})
},
})
export {shareButtonComponent}
const shopButtonComponent = () => ({
init() {
const shopButton = document.getElementById('shopbutton')
shopButton.style.display = 'block'
const shop = () => {
window.open(
'https://www.amazon.com/Goodnight-Bubbala-Sheryl-Haft/dp/0525554777/ref=sr_1_1?crid=1EDVMUS03H9C5&keywords=Sheryl+haft&qid=1640032526&sprefix=sheryl+haft%2Caps%2C120&sr=8-1'
)
}
shopButton.onclick = shop
},
})
export {shopButtonComponent}
const animationComponent = () => ({
init() {
const entity = document.querySelector('[sound]')
const model = document.getElementById('model')
this.el.sceneEl.addEventListener('realityready', () => {
model.setAttribute('animation-mixer', {
clip: 'rabitanim',
loop: 'once',
})
entity.components.sound.playSound()
model.setAttribute('scale', {x: 1, y: 1, z: 1})
})
},
})
export {animationComponent}