MCPcopy Create free account
hub / github.com/plotly/plotly.js / handleGl3dDefaults

Function handleGl3dDefaults

src/plots/gl3d/layout/defaults.js:40–139  ·  view source on GitHub ↗
(sceneLayoutIn, sceneLayoutOut, coerce, opts)

Source from the content-addressed store, hash-verified

38};
39
40function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
41 /*
42 * Scene numbering proceeds as follows
43 * scene
44 * scene2
45 * scene3
46 *
47 * and d.scene will be undefined or some number or number string
48 *
49 * Also write back a blank scene object to user layout so that some
50 * attributes like aspectratio can be written back dynamically.
51 */
52
53 var bgcolor = coerce('bgcolor');
54 var bgColorCombined = Color.combine(bgcolor, opts.paper_bgcolor);
55
56 var cameraKeys = ['up', 'center', 'eye'];
57
58 for(var j = 0; j < cameraKeys.length; j++) {
59 coerce('camera.' + cameraKeys[j] + '.x');
60 coerce('camera.' + cameraKeys[j] + '.y');
61 coerce('camera.' + cameraKeys[j] + '.z');
62 }
63
64 coerce('camera.projection.type');
65
66 /*
67 * coerce to positive number (min 0) but also do not accept 0 (>0 not >=0)
68 * note that 0's go false with the !! call
69 */
70 var hasAspect = !!coerce('aspectratio.x') &&
71 !!coerce('aspectratio.y') &&
72 !!coerce('aspectratio.z');
73
74 var defaultAspectMode = hasAspect ? 'manual' : 'auto';
75 var aspectMode = coerce('aspectmode', defaultAspectMode);
76
77 /*
78 * We need aspectratio object in all the Layouts as it is dynamically set
79 * in the calculation steps, ie, we cant set the correct data now, it happens later.
80 * We must also account for the case the user sends bad ratio data with 'manual' set
81 * for the mode. In this case we must force change it here as the default coerce
82 * misses it above.
83 */
84 if(!hasAspect) {
85 sceneLayoutIn.aspectratio = sceneLayoutOut.aspectratio = {x: 1, y: 1, z: 1};
86
87 if(aspectMode === 'manual') sceneLayoutOut.aspectmode = 'auto';
88
89 /*
90 * kind of like autorange - we need the calculated aspectmode back in
91 * the input layout or relayout can cause problems later
92 */
93 sceneLayoutIn.aspectmode = sceneLayoutOut.aspectmode;
94 }
95
96 var fullGl3dData = getSubplotData(opts.fullData, GL3D, opts.id);
97

Callers

nothing calls this directly

Calls 1

coerceFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…