MCPcopy Index your code
hub / github.com/plotly/plotly.js / convert

Function convert

src/traces/cone/convert.js:52–113  ·  view source on GitHub ↗
(scene, trace)

Source from the content-addressed store, hash-verified

50var anchor2coneSpan = {tip: 1, tail: 1, cm: 0.75, center: 0.5};
51
52function convert(scene, trace) {
53 var sceneLayout = scene.fullSceneLayout;
54 var dataScale = scene.dataScale;
55 var coneOpts = {};
56
57 function toDataCoords(arr, axisName) {
58 var ax = sceneLayout[axisName];
59 var scale = dataScale[axisName2scaleIndex[axisName]];
60 return simpleMap(arr, function(v) { return ax.d2l(v) * scale; });
61 }
62
63 coneOpts.vectors = zip3(
64 toDataCoords(trace.u, 'xaxis'),
65 toDataCoords(trace.v, 'yaxis'),
66 toDataCoords(trace.w, 'zaxis'),
67 trace._len
68 );
69
70 coneOpts.positions = zip3(
71 toDataCoords(trace.x, 'xaxis'),
72 toDataCoords(trace.y, 'yaxis'),
73 toDataCoords(trace.z, 'zaxis'),
74 trace._len
75 );
76
77 var cOpts = extractOpts(trace);
78 coneOpts.colormap = parseColorScale(trace);
79 coneOpts.vertexIntensityBounds = [cOpts.min / trace._normMax, cOpts.max / trace._normMax];
80 coneOpts.coneOffset = anchor2coneOffset[trace.anchor];
81
82
83 var sizemode = trace.sizemode;
84 if(sizemode === 'scaled') {
85 // unitless sizeref
86 coneOpts.coneSize = trace.sizeref || 0.5;
87 } else if(sizemode === 'absolute') {
88 // sizeref here has unit of velocity
89 coneOpts.coneSize = trace.sizeref && trace._normMax ?
90 trace.sizeref / trace._normMax :
91 0.5;
92 } else if(sizemode === 'raw') {
93 coneOpts.coneSize = trace.sizeref;
94 }
95 coneOpts.coneSizemode = sizemode;
96
97 var meshData = conePlot(coneOpts);
98
99 // pass gl-mesh3d lighting attributes
100 var lp = trace.lightposition;
101 meshData.lightPosition = [lp.x, lp.y, lp.z];
102 meshData.ambient = trace.lighting.ambient;
103 meshData.diffuse = trace.lighting.diffuse;
104 meshData.specular = trace.lighting.specular;
105 meshData.roughness = trace.lighting.roughness;
106 meshData.fresnel = trace.lighting.fresnel;
107 meshData.opacity = trace.opacity;
108
109 // stash autorange pad value

Callers 4

convert.jsFile · 0.70
createConeTraceFunction · 0.70
plot.jsFile · 0.50
plot.jsFile · 0.50

Calls 3

extractOptsFunction · 0.85
parseColorScaleFunction · 0.85
toDataCoordsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…