-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext-button.js
More file actions
30 lines (26 loc) · 990 Bytes
/
next-button.js
File metadata and controls
30 lines (26 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const nextButtonComponent = () => ({
init() {
const modelList = ['firstModel', 'secondModel', 'thirdModel', 'fourthModel', 'fifthModel']
const model = document.getElementById('model')
const nextButton = document.getElementById('nextbutton')
nextButton.style.display = 'block'
const bg1 = require('./assets/images/one.jpg')
const bg2 = require('./assets/images/two.jpg')
let buttonBackground = bg1
let idx = 1
const nextModel = () => {
if (buttonBackground === bg1) {
buttonBackground = bg2
} else {
buttonBackground = bg1
}
nextButton.style.backgroundImage = `url(${buttonBackground})`
model.removeAttribute('gltf-model')
model.setAttribute('gltf-model', `#${modelList[idx]}`)
// model.setAttribute('animation-mixer', 'clip: Action; loop: once; clampWhenFinished: true')
idx = (idx + 1) % modelList.length
}
nextButton.onclick = nextModel
},
})
export {nextButtonComponent}