MCPcopy Create free account
hub / github.com/adobe/leonardo / create3dModel

Function create3dModel

docs/ui/src/js/create3dModel.js:17–135  ·  view source on GitHub ↗
(dest, colorClasses, mode, scaleType = 'theme')

Source from the content-addressed store, hash-verified

15import {filterNaN, convertToCartesian, getChannelsAndFunction} from './utils';
16
17function create3dModel(dest, colorClasses, mode, scaleType = 'theme') {
18 // Force colorClasses to be an array if it was erroneously passed
19 // as a single color class.
20 if (!Array.isArray(colorClasses)) colorClasses = [colorClasses];
21
22 // Hide all example images
23 if (scaleType === 'theme') {
24 let images = document.getElementsByClassName('ModelImage');
25 for (let i = 0; i < images.length; i++) {
26 if (!images[i].classList.contains('is-hidden')) images[i].classList.add('is-hidden');
27 }
28 }
29
30 var pointCount = 3142;
31 var i, r;
32
33 var x = [];
34 var y = [];
35 var z = [];
36 var c = [];
37
38 for (i = 0; i < pointCount; i++) {
39 r = i * (pointCount - i);
40 x.push(r * Math.cos(i / 30));
41 y.push(r * Math.sin(i / 30));
42 z.push(i);
43 c.push(i);
44 }
45
46 const data = createColorData(colorClasses, mode, scaleType);
47
48 const colorWay = colorClasses.map((c) => {
49 return c.colorKeys[0];
50 });
51 const mq = window.matchMedia('(prefers-color-scheme: dark)');
52 const downloadFileName = scaleType === 'theme' ? `${getThemeName()}_3dModel` : `${scaleType}Scale_3dModel`;
53 const windowWidth = window.innerWidth;
54 const windowHeight = window.innerHeight;
55 const height = dest === 'paletteModelWrapper' ? windowHeight - 120 : windowHeight - 260;
56 let width = windowWidth - (424 + 304 + 32); // Fit to window, minus panel and padding
57 if (dest === 'sequentialModelWrapper' || dest === 'tabModelContent' || dest === 'divergingModelWrapper') {
58 if (width > 796) width = 796; // Max width for scale views of 3d model
59 }
60
61 const canvasColor = mq.matches ? '#1d1d1d' : '#f5f5f5';
62
63 const layout = {
64 colorway: colorWay,
65 autosize: true,
66 height: height,
67 width: width,
68 showLegend: false,
69 showscale: false,
70 margin: {
71 l: 24,
72 r: 24,
73 b: 24,
74 t: 24,

Callers 8

addScaleKeyColorInputFunction · 0.90
themeUpdateFunction · 0.90
colorWheel.jsFile · 0.90
updateModelFunction · 0.90
showColorDetailsFunction · 0.90
bulkScaleItemColorInputFunction · 0.90
colorScaleDivergingFunction · 0.90
colorScaleSequentialFunction · 0.90

Calls 2

getThemeNameFunction · 0.90
createColorDataFunction · 0.70

Tested by

no test coverage detected