-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
78 lines (63 loc) · 1.8 KB
/
index.tsx
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import hot from './hot'
import './stage'
import { GLContext, DataContext, Clock, Camera, Stage } from './contexts'
import prez from './scenes'
window['SLIDES'] = prez
import GL from 'luma.gl/constants'
import { Matrix4, radians } from 'math.gl'
import * as Luma from 'luma.gl'
import { render } from 'react-dom'
import * as React from 'react'
import Loop, { Eval, createLoop, isContext } from './loop'
const QUAD_VERTS = new Float32Array([
1, 1, 0, -1, 1, 0,
1, -1, 0, -1, -1, 0])
import defaultClient from './parcel-plugin-writable/src/client'
import Player from './player'
const lumaLoop = new Luma.AnimationLoop({
useDevicePixels: true,
onInitialize({ gl, canvas }) {
console.log('******* Supported Extensions: *******')
console.log(gl.getSupportedExtensions())
console.log('OES_texture_float:', gl.getExtension('OES_texture_float'))
Luma.setParameters(gl, {
clearColor: [0, 0, 0, 1],
clearDepth: 0,
[GL.BLEND]: false,
depthTest: false,
depthFunc: GL.LEQUAL,
})
const $ = createLoop()
window['LOOP'] = $
$(GLContext).write(gl)
$(DataContext).write(defaultClient)
$(Camera.uProjection).write(new Matrix4().ortho({
top: -9,
bottom: 9,
left: -16,
right: 16,
near: -0.1, far: 100
}))
$(Stage.aPosition).write(new Luma.Buffer(gl, QUAD_VERTS))
$(Stage.uCount).write(QUAD_VERTS.length / 3)
render(
<Loop loop={$}>
<Player play={prez} />
</Loop>,
document.getElementById('main'))
canvas.style = ''
return {
$
}
},
onRender({ time, $, }) {
$(Clock).write(time)
$.run(time)
},
})
lumaLoop.start()
hot(module).onDispose(() => {
lumaLoop.stop()
const { canvas=null } = lumaLoop.gl || {}
canvas && canvas.parentNode.removeChild(canvas)
})