-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebGLRenderer.js
67 lines (54 loc) · 1.6 KB
/
WebGLRenderer.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
Copyright 2017 Marcel Greter
https://www.github.com/mgreter
*/
// private scope
(function (THREE, THREEAPP)
{
"use strict";
var WebGLRenderer = THREEAPP.Class.create('WebGLRenderer', null, ['Plugin'])
.proto('provides', 'renderer')
.ctor(function (app)
{
// http://threejs.org/docs/#Reference/Renderers/WebGLRenderer
app.renderer = new THREE.WebGLRenderer({
sortObjects: true,
antialias: true, // def: false
precision: 'highp', // def: highp
alpha: true, // def: false
depth: true, // def: true
stencil: true, // def: true
premultipliedAlpha: true,
preserveDrawingBuffer: true,
logarithmicDepthBuffer: true, // def: false
// make background transparent
// clearAlpha: 0, clearColor: 0x000000,
});
// cannot set as an option!?
app.renderer.autoClear = false;
// hook into resized event
app.listen('resized', function () {
// set renderer size from app dimensions
app.renderer.setSize(app.width, app.height);
})
// set initial size from app dimensions
app.renderer.setSize(app.width, app.height);
// attach the dom element
app.viewport.appendChild(
app.renderer.domElement
);
// listen to pre-render events
app.listen('preframe', function () {
app.renderer.clear();
});
// listen to main render events
app.listen('render', function () {
app.invoke('render-scene'); // synchronous
app.renderer.render( app.scene, app.camera );
})
})
;
// assign class to global namespace
THREEAPP('Plugin.WebGLRenderer', WebGLRenderer);
// EO private scope
})(THREE, THREEAPP);