|
57 | 57 | renderer.render( scene, camera );
|
58 | 58 | }
|
59 | 59 |
|
60 |
| - async function create3d(obj, opt, x = 0, lbl = '') { |
| 60 | + async function create3d(obj, opt, x = 0, lbl = '', scale = 1) { |
61 | 61 | return build3d(obj, opt).then(obj3d => {
|
62 | 62 | obj3d.position.x = x;
|
| 63 | + if (scale !== 1) |
| 64 | + obj3d.scale.set(scale, scale, scale); |
63 | 65 |
|
64 | 66 | scene.add(obj3d);
|
65 | 67 |
|
|
70 | 72 | latex.fTextSize = 10; // absolute size
|
71 | 73 |
|
72 | 74 | return build3d(latex);
|
73 |
| - }).then(obj3d => { |
74 |
| - // latex created in X/Y coordinates |
75 |
| - obj3d.geometry.rotateX(Math.PI / 2); |
| 75 | + }).then(text3d => { |
| 76 | + // latex created in X/Y coordinates, |
| 77 | + text3d.traverse(obj3d => obj3d.geometry?.rotateX(Math.PI / 2)); |
76 | 78 |
|
77 |
| - obj3d.position.x = x; |
78 |
| - obj3d.position.z = -100; |
79 |
| - scene.add(obj3d); |
| 79 | + text3d.position.x = x; |
| 80 | + text3d.position.z = -100; |
| 81 | + scene.add(text3d); |
80 | 82 | });
|
81 | 83 | }
|
82 | 84 |
|
|
108 | 110 |
|
109 | 111 | window.addEventListener( 'resize', onWindowResize, false );
|
110 | 112 |
|
111 |
| - let filename = 'https://root.cern/js/files/hsimple.root'; |
| 113 | + let filename = 'https://root.cern/js/files/hsimple.root', |
| 114 | + filename2 = 'https://jsroot.gsi.de/files/graph2d.root'; |
112 | 115 |
|
113 | 116 | let file = await openFile(filename);
|
114 | 117 | let hist2 = await file.readObject('hpxpy');
|
115 | 118 |
|
116 |
| - await create3d(hist2, 'lego2', 0, 'TH2 lego plot'); |
| 119 | + await create3d(hist2, 'lego2', 150, '#color[2]{TH2} #color[4]{lego} plot'); |
117 | 120 |
|
118 | 121 | let tuple = await file.readObject('ntuple');
|
119 | 122 | let hist3 = await treeDraw(tuple, 'px:py:pz;hbins:15');
|
120 | 123 |
|
121 |
| - await create3d(hist3, 'box3', -400, 'TH3 box plot'); |
| 124 | + await create3d(hist3, 'box3', -150, '#color[2]{TH3} #color[4]{box} plot'); |
122 | 125 |
|
123 | 126 | let hist1 = await file.readObject('hpx');
|
124 | 127 |
|
125 |
| - await create3d(hist1, 'lego2', 400, 'TH1 lego plot'); |
| 128 | + await create3d(hist1, 'lego2', 400, '#color[2]{TH1} #color[4]{lego} plot'); |
| 129 | + |
| 130 | + let geom = await httpRequest('https://root.cern/js/files/geom/simple_alice.json.gz', 'object'); |
| 131 | + await create3d(geom, '', -400, '#color[2]{Geometry} build', 0.2); |
| 132 | + |
| 133 | + let file2 = await openFile(filename2); |
| 134 | + let gr2 = await file2.readObject('Graph2D'); |
126 | 135 |
|
| 136 | + await create3d(gr2, 'p', 650, '#color[2]{TGraph2D} drawing with #color[4]{p}'); |
127 | 137 |
|
128 | 138 | camera.updateProjectionMatrix();
|
129 | 139 |
|
|
0 commit comments