34 lines
673 B
JavaScript
34 lines
673 B
JavaScript
|
|
export default function extension(widget){
|
|
|
|
const ext = {
|
|
|
|
async init(){
|
|
|
|
// let other extensions set this.src if needed
|
|
await widget.emit("init.play", this)
|
|
|
|
if( widget.src ){
|
|
document.querySelector('#scene').setAttribute("gltf-model",`url(${widget.src})`)
|
|
}
|
|
|
|
this.initButton()
|
|
},
|
|
|
|
initButton(){
|
|
const btn_play = document.querySelector("#btn_play")
|
|
btn_play.addEventListener("click", async () => {
|
|
btn_play.style.display = 'none' // hide button
|
|
widget.emit("play")
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
widget.ext.play = ext
|
|
|
|
// register async listeners
|
|
widget.on("init", ext.init.bind(ext) )
|
|
|
|
}
|
|
|