UNPKG

9.8 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>FluxRenderContext.js - Documentation</title>
6
7 <script src="scripts/prettify/prettify.js"></script>
8 <script src="scripts/prettify/lang-css.js"></script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
13 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
14 <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
15</head>
16<body>
17
18<input type="checkbox" id="nav-trigger" class="nav-trigger" />
19<label for="nav-trigger" class="navicon-button x">
20 <div class="navicon"></div>
21</label>
22
23<label for="nav-trigger" class="overlay"></label>
24
25<nav>
26 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="EdgesHelper.html">EdgesHelper</a><ul class='methods'><li data-type='method'><a href="EdgesHelper.html#.AddEdges">AddEdges</a></li></ul></li><li><a href="FluxCameras.html">FluxCameras</a><ul class='methods'><li data-type='method'><a href="FluxCameras.html#.cameraFromJSON">cameraFromJSON</a></li><li data-type='method'><a href="FluxCameras.html#.cameraToJSON">cameraToJSON</a></li><li data-type='method'><a href="FluxCameras.html#fromJSON">fromJSON</a></li><li data-type='method'><a href="FluxCameras.html#getCamera">getCamera</a></li><li data-type='method'><a href="FluxCameras.html#setView">setView</a></li><li data-type='method'><a href="FluxCameras.html#toJSON">toJSON</a></li><li data-type='method'><a href="FluxCameras.html#updateCamera">updateCamera</a></li></ul></li><li><a href="FluxRenderContext.html">FluxRenderContext</a><ul class='methods'><li data-type='method'><a href="FluxRenderContext.html#.getNextContext">getNextContext</a></li></ul></li><li><a href="FluxRenderer.html">FluxRenderer</a><ul class='methods'><li data-type='method'><a href="FluxRenderer.html#addControls">addControls</a></li><li data-type='method'><a href="FluxRenderer.html#anyValidPrims">anyValidPrims</a></li><li data-type='method'><a href="FluxRenderer.html#detach">detach</a></li><li data-type='method'><a href="FluxRenderer.html#doRender">doRender</a></li><li data-type='method'><a href="FluxRenderer.html#focus">focus</a></li><li data-type='method'><a href="FluxRenderer.html#fromJSON">fromJSON</a></li><li data-type='method'><a href="FluxRenderer.html#getGlCanvas">getGlCanvas</a></li><li data-type='method'><a href="FluxRenderer.html#getSelection">getSelection</a></li><li data-type='method'><a href="FluxRenderer.html#homeCamera">homeCamera</a></li><li data-type='method'><a href="FluxRenderer.html#setClearColor">setClearColor</a></li><li data-type='method'><a href="FluxRenderer.html#setEdgesMode">setEdgesMode</a></li><li data-type='method'><a href="FluxRenderer.html#setHelpersVisible">setHelpersVisible</a></li><li data-type='method'><a href="FluxRenderer.html#setLights">setLights</a></li><li data-type='method'><a href="FluxRenderer.html#setModel">setModel</a></li><li data-type='method'><a href="FluxRenderer.html#setSelection">setSelection</a></li><li data-type='method'><a href="FluxRenderer.html#setSelectionMaterial">setSelectionMaterial</a></li><li data-type='method'><a href="FluxRenderer.html#setSize">setSize</a></li><li data-type='method'><a href="FluxRenderer.html#setView">setView</a></li><li data-type='method'><a href="FluxRenderer.html#toJSON">toJSON</a></li></ul></li><li><a href="FluxViewport.html">FluxViewport</a><ul class='methods'><li data-type='method'><a href="FluxViewport.html#.getChangeEvent">getChangeEvent</a></li><li data-type='method'><a href="FluxViewport.html#.getEdgesModes">getEdgesModes</a></li><li data-type='method'><a href="FluxViewport.html#.getEvents">getEvents</a></li><li data-type='method'><a href="FluxViewport.html#.getSelectionModes">getSelectionModes</a></li><li data-type='method'><a href="FluxViewport.html#.getViews">getViews</a></li><li data-type='method'><a href="FluxViewport.html#.isKnownGeom">isKnownGeom</a></li><li data-type='method'><a href="FluxViewport.html#activateShadows">activateShadows</a></li><li data-type='method'><a href="FluxViewport.html#addControls">addControls</a></li><li data-type='method'><a href="FluxViewport.html#downloadState">downloadState</a></li><li data-type='method'><a href="FluxViewport.html#focus">focus</a></li><li data-type='method'><a href="FluxViewport.html#fromJSON">fromJSON</a></li><li data-type='method'><a href="FluxViewport.html#getAutoFocus">getAutoFocus</a></li><li data-type='method'><a href="FluxViewport.html#getGlCanvas">getGlCanvas</a></li><li data-type='method'><a href="FluxViewport.html#getJson">getJson</a></li><li data-type='method'><a href="FluxViewport.html#getObjectMap">getObjectMap</a></li><li data-type='method'><a href="FluxViewport.html#getSelection">getSelection</a></li><li data-type='method'><a href="FluxViewport.html#homeCamera">homeCamera</a></li><li data-type='method'><a href="FluxViewport.html#render">render</a></li><li data-type='method'><a href="FluxViewport.html#setAutoFocus">setAutoFocus</a></li><li data-type='method'><a href="FluxViewport.html#setClearColor">setClearColor</a></li><li data-type='method'><a href="FluxViewport.html#setEdgesMode">setEdgesMode</a></li><li data-type='method'><a href="FluxViewport.html#setFogDensity">setFogDensity</a></li><li data-type='method'><a href="FluxViewport.html#setGeometryEntity">setGeometryEntity</a></li><li data-type='method'><a href="FluxViewport.html#setGeometryJson">setGeometryJson</a></li><li data-type='method'><a href="FluxViewport.html#setHelpersVisible">setHelpersVisible</a></li><li data-type='method'><a href="FluxViewport.html#setSelection">setSelection</a></li><li data-type='method'><a href="FluxViewport.html#setSelectionMaterial">setSelectionMaterial</a></li><li data-type='method'><a href="FluxViewport.html#setSize">setSize</a></li><li data-type='method'><a href="FluxViewport.html#setTessUrl">setTessUrl</a></li><li data-type='method'><a href="FluxViewport.html#setupDefaultLighting">setupDefaultLighting</a></li><li data-type='method'><a href="FluxViewport.html#setView">setView</a></li><li data-type='method'><a href="FluxViewport.html#toJSON">toJSON</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#_deleteFromScene">_deleteFromScene</a></li><li><a href="global.html#_removeGeometries">_removeGeometries</a></li></ul>
27</nav>
28
29<div id="main">
30
31 <h1 class="page-title">FluxRenderContext.js</h1>
32
33
34
35
36
37
38
39 <section>
40 <article>
41 <pre class="prettyprint source linenums"><code>'use strict';
42
43import * as THREE from 'three';
44
45/**
46* Class to represent a WebGL context which can render for multiple viewports
47* @class FluxRenderContext
48*/
49export default function FluxRenderContext () {
50 /**
51 * Pointer to the shared THREE.js renderer
52 */
53 try {
54 this._hasWebGL = true;
55 this.renderer = new THREE.WebGLRenderer({
56 antialias: true,
57 preserveDrawingBuffer: true,
58 alpha: true
59 });
60 this.renderer.autoClear = false;
61 this.renderer.autoClearStencil = false;
62 this.renderer.gammaInput = false;
63 this.renderer.gammaOutput = false;
64 this.renderer.physicallyCorrectLights = true;
65
66 // Allow interactive canvas to overlap other canvas
67 this.renderer.domElement.style.position = "absolute";
68 } catch (err) {
69 // Replace renderer with mock renderer for tests
70 this.renderer = {
71 render: function () {},
72 setSize: function () {},
73 clear: function () {},
74 setViewport: function () {},
75 setClearColor: function (color, alpha) {
76 this.color = color;
77 this.alpha = alpha;
78 },
79 getClearAlpha: function() { return this.alpha; },
80 getSize: function () { return {width: 100, height: 100}; },
81 getPixelRatio: function () { return 1; },
82 domElement: document.createElement('div')
83 };
84 this._hasWebGL = false;
85 }
86 // Pointer to the three-viewport-renderer instance that is currently being rendered.
87 this.currentHost = null;
88}
89
90/**
91* Maximum number of WebGL contexts allowed.
92* Should be less than or equal to 16, the limit on recent systems.
93*/
94FluxRenderContext.MAX_CONTEXTS = 16;
95
96// List of all render contexts shared globally
97FluxRenderContext.contexts = [];
98
99// Counter so new viewports know which context to create or reuse.
100FluxRenderContext.nextContext = 0;
101
102/**
103* Each viewport uses the next available render context defined by this function
104* @return {FluxRenderContext} The context instance
105*/
106FluxRenderContext.getNextContext = function () {
107 var i = FluxRenderContext.nextContext;
108 FluxRenderContext.nextContext += 1;
109 FluxRenderContext.nextContext = FluxRenderContext.nextContext % FluxRenderContext.MAX_CONTEXTS;
110 return FluxRenderContext.contexts[i];
111};
112
113FluxRenderContext.getNewContext = function () {
114 var context;
115 if (FluxRenderContext.contexts.length >= FluxRenderContext.MAX_CONTEXTS) {
116 context = FluxRenderContext.getNextContext();
117 } else {
118 context = new FluxRenderContext();
119 FluxRenderContext.contexts.push(context);
120 }
121 return context;
122};
123
124FluxRenderContext.prototype.hasWebGL = function() {
125 return this._hasWebGL;
126};
127</code></pre>
128 </article>
129 </section>
130
131
132
133
134</div>
135
136<br class="clear">
137
138<footer>
139 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Thu Jan 05 2017 16:26:56 GMT-0800 (PST) using the Minami theme.
140</footer>
141
142<script>prettyPrint();</script>
143<script src="scripts/linenumber.js"></script>
144</body>
145</html>