-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathdraw.js
50 lines (42 loc) · 1.53 KB
/
draw.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
/**
* 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';
var drawRaw = require('../annotations/draw').drawRaw;
var project = require('../../plots/gl3d/project');
var axLetters = ['x', 'y', 'z'];
module.exports = function draw(scene) {
var fullSceneLayout = scene.fullSceneLayout;
var dataScale = scene.dataScale;
var anns = fullSceneLayout.annotations;
for(var i = 0; i < anns.length; i++) {
var ann = anns[i];
var annotationIsOffscreen = false;
for(var j = 0; j < 3; j++) {
var axLetter = axLetters[j];
var pos = ann[axLetter];
var ax = fullSceneLayout[axLetter + 'axis'];
var posFraction = ax.r2fraction(pos);
if(posFraction < 0 || posFraction > 1) {
annotationIsOffscreen = true;
break;
}
}
if(annotationIsOffscreen) {
scene.fullLayout._infolayer
.select('.annotation-' + scene.id + '[data-index="' + i + '"]')
.remove();
} else {
ann._pdata = project(scene.glplot.cameraParams, [
fullSceneLayout.xaxis.r2l(ann.x) * dataScale[0],
fullSceneLayout.yaxis.r2l(ann.y) * dataScale[1],
fullSceneLayout.zaxis.r2l(ann.z) * dataScale[2]
]);
drawRaw(scene.graphDiv, ann, i, scene.id, ann._xa, ann._ya);
}
}
};