-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path7-interaction-drag.js
48 lines (43 loc) · 1.09 KB
/
7-interaction-drag.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
45
46
47
48
import '../components/checker-texture.js'
import '../components/drag-checker-texture.js'
/**
* This room spawns a plane with a checkered texture.
* Visitors can click and drag on the plane to drag the texture.
* The drag effect is networked for all visitors.
*/
const assets = document.querySelector('a-assets')
assets.insertAdjacentHTML(
'beforeend',
`
<template id="drag-media">
<a-entity
geometry="primitive: plane"
material="side: double"
scale="2 2 2"
checker-texture="repeat: 2 2; offset: 0 0"
drag-checker-texture
></a-entity>
</template>
`
)
/**
* In our schema, we network the UV offset of our custom checker texture
* so that everyone can see it drag in sync.
*/
NAF.schemas.add({
template: '#drag-media',
components: [
{
component: 'checker-texture',
property: 'offset',
},
],
})
const entity = document.createElement('a-entity')
entity.setAttribute('position', { x: 0, y: 2, z: 1 })
entity.setAttribute('networked', {
template: '#drag-media',
networkId: 'drag',
owner: 'scene',
})
APP.scene.appendChild(entity)