-
Notifications
You must be signed in to change notification settings - Fork 2
/
6-interaction-click.js
44 lines (39 loc) · 1.04 KB
/
6-interaction-click.js
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import '../components/single-action-button.js'
import '../components/randomize-networked-color.js'
/**
* This room script is almost identical to the previous, the only difference is that
* color randomization is now triggered by clicks from the interaction system.
*
* Take a look at the single-action-button component for the interesting stuff.
*/
const assets = document.querySelector('a-assets')
assets.insertAdjacentHTML(
'beforeend',
`
<template id="color-media">
<a-entity
geometry="primitive: sphere"
material="shader: flat"
single-action-button="event: click"
randomize-networked-color="event: click"
></a-entity>
</template>
`
)
NAF.schemas.add({
template: '#color-media',
components: [
{
component: 'material',
property: 'color',
},
],
})
const entity = document.createElement('a-entity')
entity.setAttribute('position', { x: 0, y: 2, z: 0 })
entity.setAttribute('networked', {
template: '#color-media',
networkId: 'button',
owner: 'scene',
})
APP.scene.appendChild(entity)