Skip to content

Commit d1f38b2

Browse files
committed
Build with build3d support
1 parent dbe5489 commit d1f38b2

File tree

10 files changed

+566
-317
lines changed

10 files changed

+566
-317
lines changed

build/jsroot.js

Lines changed: 551 additions & 293 deletions
Large diffs are not rendered by default.

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Changes in dev
44
1. RNtuple support, thanks to Kriti Mahajan (https://github.com/Krmjn09)
55
1. Implement RTreeMapPainter to display RNTuple structure, thanks to Patryk Pilichowski (https://github.com/magnustymoteus)
6+
1. Implement `build3d` function for supported classes #368
67
1. Let use hex colors in histogram draw options like "fill_00ff00" or "line_77aa1166"
78
1. Let configure exact axis ticks position via draw option like "xticks:[-3,-1,1,3]"
89
1. Support gStyle.fBarOffset for `TGraph` bar drawing

modules/core.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const version_id = 'dev',
44

55
/** @summary version date
66
* @desc Release date in format day/month/year like '14/04/2022' */
7-
version_date = '25/09/2025',
7+
version_date = '29/09/2025',
88

99
/** @summary version id and date
1010
* @desc Produced by concatenation of {@link version_id} and {@link version_date}

modules/draw.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ async function build3d(obj, opt) {
562562
return Promise.reject(Error(`not able to create three.js for ${obj._typename}`));
563563

564564
if (handle.build3d)
565-
return handle.build3d().then(func => func(obj, opt))
565+
return handle.build3d().then(func => func(obj, opt));
566566

567567
return handle.class().then(cl => {
568568
if (!isFunc(cl?.build3d))
@@ -780,4 +780,4 @@ Object.assign(internals, { addStreamerInfosForPainter, addDrawFunc, setDefaultDr
780780
Object.assign(internals.jsroot, { draw, redraw, makeSVG, makeImage, addDrawFunc });
781781

782782
export { addDrawFunc, getDrawHandle, canDrawHandle, getDrawSettings, setDefaultDrawOpt,
783-
draw, redraw,cleanup, build3d, makeSVG, makeImage, assignPadPainterDraw };
783+
draw, redraw, cleanup, build3d, makeSVG, makeImage, assignPadPainterDraw };

modules/geom/TGeoPainter.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5481,15 +5481,14 @@ class TGeoPainter extends ObjectPainter {
54815481
if (!obj)
54825482
return null;
54835483

5484-
let opt = null;
5484+
let opt = sopt || {};
54855485
if (isStr(sopt)) {
54865486
const painter = new TGeoPainter(null, obj);
54875487
painter.decodeOptions(sopt);
54885488
opt = painter.ctrl;
54895489
opt.numfaces = opt.maxfaces;
54905490
opt.numnodes = opt.maxnodes;
5491-
} else
5492-
opt = sopt || {};
5491+
}
54935492

54945493
if (!opt.numfaces)
54955494
opt.numfaces = 100000;

modules/hist/TGraph2DPainter.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,9 +1124,8 @@ class TGraph2DPainter extends ObjectPainter {
11241124
res.Axis = 'lego2';
11251125
if (res.Zscale)
11261126
res.Axis += 'z';
1127-
} else {
1127+
} else
11281128
res.Axis = opt;
1129-
}
11301129

11311130
this.storeDrawOpt(opt);
11321131
}
@@ -1599,8 +1598,8 @@ class TGraph2DPainter extends ObjectPainter {
15991598
painter.getFramePainter = () => fp;
16001599
painter.getMainPainter = () => hist_painter;
16011600

1602-
return painter.drawGraph2D().then(() => fp.create3DScene(-1, true))
1603-
})
1601+
return painter.drawGraph2D().then(() => fp.create3DScene(-1, true));
1602+
});
16041603
}
16051604

16061605
/** @summary draw TGraph2D object */

modules/hist/TH1Painter.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class TH1Painter extends TH1Painter2D {
1717

1818
const fp = this.getFramePainter(), // who makes axis drawing
1919
is_main = this.isMainPainter(), // is main histogram
20-
histo = this.getHisto(),
2120
o = this.getOptions();
2221

2322
o.zmult = 1 + 2*gStyle.fHistTopMargin;

modules/hist/TH2Painter.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { settings, constants, gStyle, clTMultiGraph, kNoZoom } from '../core.mjs';
1+
import { gStyle, clTMultiGraph, kNoZoom } from '../core.mjs';
22
import { getMaterialArgs, THREE } from '../base/base3d.mjs';
33
import { crete3DFrame, drawBinsLego, drawBinsError3D, drawBinsContour3D, drawBinsSurf3D } from './hist3d.mjs';
44
import { TAxisPainter } from '../gpad/TAxisPainter.mjs';
@@ -244,7 +244,6 @@ class TH2Painter extends TH2Painter2D {
244244
drawBinsError3D(this);
245245
else
246246
drawBinsLego(this);
247-
248247
}
249248

250249
/** @summary draw TH2 object in 3D mode */
@@ -253,7 +252,6 @@ class TH2Painter extends TH2Painter2D {
253252

254253
const fp = this.getFramePainter(), // who makes axis drawing
255254
is_main = this.isMainPainter(), // is main histogram
256-
histo = this.getHisto(),
257255
o = this.getOptions();
258256

259257
let pr = Promise.resolve(true), full_draw = true;
@@ -304,7 +302,7 @@ class TH2Painter extends TH2Painter2D {
304302
const painter = new TH2Painter(null, histo);
305303
painter.decodeOptions(opt);
306304

307-
const o = painter.getOptions(), logz = false;
305+
const o = painter.getOptions();
308306
if (painter.isTH2Poly())
309307
o.Lego = 12;
310308
painter.scanContent();

modules/hist/TH3Painter.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { gStyle, settings, kInspect, clTF1, clTF3, clTProfile3D, BIT, isFunc } from '../core.mjs';
1+
import { gStyle, kInspect, clTF1, clTF3, clTProfile3D, BIT, isFunc } from '../core.mjs';
22
import { TRandom, floatToString } from '../base/BasePainter.mjs';
33
import { ensureTCanvas } from '../gpad/TCanvasPainter.mjs';
44
import { TAxisPainter } from '../gpad/TAxisPainter.mjs';
@@ -636,7 +636,6 @@ class TH3Painter extends THistPainter {
636636
/** @summary Redraw TH3 histogram */
637637
async redraw(reason) {
638638
const fp = this.getFramePainter(), // who makes axis and 3D drawing
639-
histo = this.getHisto(),
640639
o = this.getOptions();
641640

642641
let pr = Promise.resolve(true), full_draw = true;

modules/hist/hist3d.mjs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function build3dlatex(obj) {
204204
geom.computeBoundingBox();
205205
bb.expandByPoint(geom.boundingBox.max);
206206
bb.expandByPoint(geom.boundingBox.min);
207-
})
207+
});
208208

209209
let width = bb.max.x - bb.min.x,
210210
height = bb.max.y - bb.min.y;
@@ -219,7 +219,8 @@ function build3dlatex(obj) {
219219
else if (valign === 2)
220220
height *= 0.5;
221221

222-
const materials = [],
222+
const obj3d = new THREE.Object3D(),
223+
materials = [],
223224
getMaterial = color => {
224225
if (!color)
225226
color = 'black';
@@ -228,11 +229,6 @@ function build3dlatex(obj) {
228229
return materials[color];
229230
};
230231

231-
232-
const material0 = new THREE.MeshBasicMaterial(getMaterialArgs(handle.color || 'black', { vertexColors: false }));
233-
234-
const obj3d = new THREE.Object3D();
235-
236232
arr3d.forEach(geom => {
237233
geom.translate(-width, -height, 0);
238234
obj3d.add(new THREE.Mesh(geom, getMaterial(geom._fill || handle.color)));

0 commit comments

Comments
 (0)