Skip to content

Commit c39b55d

Browse files
committed
Fix cleanup of 3d canvas
1 parent b1b0916 commit c39b55d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

scripts/JSRoot.base3d.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,15 @@ JSROOT.define(['d3', 'threejs_jsroot', 'painter'], (d3, THREE, jsrp) => {
118118
let can3d = this.access3dKind(null);
119119
if (can3d < 0) {
120120
// remove first child from main element - if it is canvas
121-
let main = this.selectDom().node();
122-
if (main && main.firstChild && main.firstChild.$jsroot) {
123-
delete main.firstChild.painter;
124-
main.removeChild(main.firstChild);
121+
let main = this.selectDom().node(),
122+
chld = main ? main.firstChild : null;
123+
124+
if (chld && !chld.$jsroot)
125+
chld = chld.nextSibling;
126+
127+
if (chld && chld.$jsroot) {
128+
delete chld.painter;
129+
main.removeChild(chld);
125130
}
126131
return can3d;
127132
}

0 commit comments

Comments
 (0)