-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathprepare_regl.js
43 lines (38 loc) · 1.25 KB
/
prepare_regl.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
/**
* Copyright 2012-2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
// Note that this module should be ONLY required into
// files corresponding to regl trace modules
// so that bundles with non-regl only don't include
// regl and all its bytes.
var createRegl = require('regl');
/**
* Idempotent version of createRegl. Create regl instances
* in the correct canvases with the correct attributes and
* options
*
* @param {DOM node or object} gd : graph div object
* @param {array} extensions : list of extension to pass to createRegl
*/
module.exports = function prepareRegl(gd, extensions) {
var fullLayout = gd._fullLayout;
fullLayout._glcanvas.each(function(d) {
if(d.regl) return;
// only parcoords needs pick layer
if(d.pick && !fullLayout._has('parcoords')) return;
d.regl = createRegl({
canvas: this,
attributes: {
antialias: !d.pick,
preserveDrawingBuffer: true
},
pixelRatio: gd._context.plotGlPixelRatio || global.devicePixelRatio,
extensions: extensions || []
});
});
};