-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (59 loc) · 3.09 KB
/
index.html
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<html>
<head>
<script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
<script type="module">
import 'https://cdn.jsdelivr.net/npm/@theatre/[email protected]/dist/core-only.min.js'
const { core } = Theatre
import projectState from 'https://jerryhou77.github.io/aframe/theatre-project-state.json' assert { type: 'json' }
window.rafDriver = core.createRafDriver({ name: 'a-frame raf' }) //create custom rafDriver
const project = core.getProject('Aframe Animation',{ state: projectState })
window.sheet = project.sheet('Sheet')
project.ready.then(() => {
sheet.sequence.play({ rafDriver, iterationCount: Infinity, range: [0, 5] })
})
</script>
<script>
AFRAME.registerComponent('theatre-animation', {
init: function () {
const el = this.el
const options = {visible: true,
positionX: Theatre.core.types.number(0, { range: [-10, 10] }),
positionY: Theatre.core.types.number(0, { range: [-10, 10] }),
positionZ: Theatre.core.types.number(0, { range: [-10, 10] }),
rotationX: Theatre.core.types.number(0, { range: [-10, 10] }),
rotationY: Theatre.core.types.number(0, { range: [-10, 10] }),
rotationZ: Theatre.core.types.number(0, { range: [-10, 10] }),
scaleX: Theatre.core.types.number(1, { range: [0, 10] }),
scaleY: Theatre.core.types.number(1, { range: [0, 10] }),
scaleZ: Theatre.core.types.number(1, { range: [0, 10] }),}
const Obj = window.sheet.object('box', options)
Theatre.core.onChange( //using onChange
Obj.props,
(propValues) => {
el.setAttribute('visible',propValues.visible)
el.object3D.position.x = propValues.positionX
el.object3D.position.y = propValues.positionY
el.object3D.position.z = propValues.positionZ
el.object3D.rotation.x = propValues.rotationX
el.object3D.rotation.y = propValues.rotationY
el.object3D.rotation.z = propValues.rotationZ
el.object3D.scale.x = propValues.scaleX
el.object3D.scale.y = propValues.scaleY
el.object3D.scale.z = propValues.scaleZ
},rafDriver) //using custom rafDriver
},
tick: function () {
rafDriver.tick(performance.now()) //binding rafDriver tick to aframe component tick
}
})
</script>
</head>
<body >
<a-scene xr-mode-ui="XRMode: xr">
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" theatre-animation></a-box>
<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
<a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
<a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
</a-scene>
</body>
</html>