GDML update
This commit is contained in:
parent
5c8665ac3e
commit
4865c76158
@ -1,7 +1,6 @@
|
|||||||
package hep.dataforge.vis.spatial
|
package hep.dataforge.vis.spatial
|
||||||
|
|
||||||
import hep.dataforge.context.Global
|
import hep.dataforge.context.Global
|
||||||
import hep.dataforge.meta.buildMeta
|
|
||||||
import hep.dataforge.meta.number
|
import hep.dataforge.meta.number
|
||||||
import hep.dataforge.meta.set
|
import hep.dataforge.meta.set
|
||||||
import hep.dataforge.vis.ApplicationBase
|
import hep.dataforge.vis.ApplicationBase
|
||||||
@ -56,12 +55,7 @@ class ThreeDemoApp : ApplicationBase() {
|
|||||||
// }
|
// }
|
||||||
gdml {
|
gdml {
|
||||||
y = 110.0
|
y = 110.0
|
||||||
shape = buildMeta {
|
shape = box(50, 50, 50)
|
||||||
"_typename" to "TGeoBBox"
|
|
||||||
"fDX" to 50.0
|
|
||||||
"fDY" to 50.0
|
|
||||||
"fDZ" to 50.0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package hep.dataforge.vis.spatial.gdml
|
|||||||
import hep.dataforge.meta.EmptyMeta
|
import hep.dataforge.meta.EmptyMeta
|
||||||
import hep.dataforge.meta.Meta
|
import hep.dataforge.meta.Meta
|
||||||
import hep.dataforge.meta.MetaItem
|
import hep.dataforge.meta.MetaItem
|
||||||
|
import hep.dataforge.meta.buildMeta
|
||||||
import hep.dataforge.vis.*
|
import hep.dataforge.vis.*
|
||||||
import hep.dataforge.vis.spatial.GenericThreeBuilder
|
import hep.dataforge.vis.spatial.GenericThreeBuilder
|
||||||
import hep.dataforge.vis.spatial.Materials
|
import hep.dataforge.vis.spatial.Materials
|
||||||
@ -19,6 +20,37 @@ class GDMLObject(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, TYPE,
|
|||||||
|
|
||||||
var facesLimit by int(0)
|
var facesLimit by int(0)
|
||||||
|
|
||||||
|
fun box(xSize: Number, ySize: Number, zSize: Number) = buildMeta {
|
||||||
|
"_typename" to "TGeoBBox"
|
||||||
|
"fDX" to xSize
|
||||||
|
"fDY" to ySize
|
||||||
|
"fDZ" to zSize
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a GDML union
|
||||||
|
*/
|
||||||
|
operator fun Meta.plus(other: Meta) = buildMeta {
|
||||||
|
"fNode.fLeft" to this
|
||||||
|
"fNode.fRight" to other
|
||||||
|
"fNode._typename" to "TGeoUnion"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a GDML subtraction
|
||||||
|
*/
|
||||||
|
operator fun Meta.minus(other: Meta) = buildMeta {
|
||||||
|
"fNode.fLeft" to this
|
||||||
|
"fNode.fRight" to other
|
||||||
|
"fNode._typename" to "TGeoSubtraction"
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun Meta.intersect(other: Meta) = buildMeta {
|
||||||
|
"fNode.fLeft" to this
|
||||||
|
"fNode.fRight" to other
|
||||||
|
"fNode._typename" to "TGeoIntersection"
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TYPE = "geometry.spatial.gdml"
|
const val TYPE = "geometry.spatial.gdml"
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
(function (factory) {
|
(function (factory) {
|
||||||
if (typeof define === "function" && define.amd) {
|
if (typeof define === "function" && define.amd) {
|
||||||
define(['three-full', 'ThreeCSG'], factory);
|
define(['three-full', 'ThreeCSG'], factory);
|
||||||
} else
|
} else if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||||
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|
||||||
factory(require("three-full"), require("./ThreeCSG.js"));
|
factory(require("three-full"), require("./ThreeCSG.js"));
|
||||||
} else {
|
} else {
|
||||||
if (typeof THREE == 'undefined')
|
if (typeof THREE == 'undefined')
|
||||||
@ -27,7 +26,9 @@
|
|||||||
* @param {number} n bit number
|
* @param {number} n bit number
|
||||||
* @returns {Number} produced make
|
* @returns {Number} produced make
|
||||||
* @private */
|
* @private */
|
||||||
JSROOT.BIT = function(n) { return 1 << (n); };
|
JSROOT.BIT = function (n) {
|
||||||
|
return 1 << (n);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary Generic method to invoke callback function.
|
* @summary Generic method to invoke callback function.
|
||||||
@ -171,8 +172,10 @@
|
|||||||
this.indx = indx + 9;
|
this.indx = indx + 9;
|
||||||
};
|
};
|
||||||
|
|
||||||
GEO.GeometryCreator.prototype.StartPolygon = function() {};
|
GEO.GeometryCreator.prototype.StartPolygon = function () {
|
||||||
GEO.GeometryCreator.prototype.StopPolygon = function() {};
|
};
|
||||||
|
GEO.GeometryCreator.prototype.StopPolygon = function () {
|
||||||
|
};
|
||||||
|
|
||||||
GEO.GeometryCreator.prototype.AddFace4 = function (x1, y1, z1,
|
GEO.GeometryCreator.prototype.AddFace4 = function (x1, y1, z1,
|
||||||
x2, y2, z2,
|
x2, y2, z2,
|
||||||
@ -431,8 +434,7 @@
|
|||||||
if (next.diff(first) < 1e-12) {
|
if (next.diff(first) < 1e-12) {
|
||||||
//console.log('polygon closed!!!', polygon.vertices.length);
|
//console.log('polygon closed!!!', polygon.vertices.length);
|
||||||
this.multi = 0;
|
this.multi = 0;
|
||||||
} else
|
} else if (this.mnormal) {
|
||||||
if (this.mnormal) {
|
|
||||||
polygon.vertices.push(this.v3);
|
polygon.vertices.push(this.v3);
|
||||||
} else {
|
} else {
|
||||||
polygon.vertices.unshift(this.v2);
|
polygon.vertices.unshift(this.v2);
|
||||||
@ -445,9 +447,15 @@
|
|||||||
var polygon = new ThreeBSP.Polygon;
|
var polygon = new ThreeBSP.Polygon;
|
||||||
|
|
||||||
switch (reduce) {
|
switch (reduce) {
|
||||||
case 0: polygon.vertices.push(this.v1, this.v2, this.v3, this.v4); break;
|
case 0:
|
||||||
case 1: polygon.vertices.push(this.v1, this.v3, this.v4); break;
|
polygon.vertices.push(this.v1, this.v2, this.v3, this.v4);
|
||||||
case 2: polygon.vertices.push(this.v1, this.v2, this.v3); break;
|
break;
|
||||||
|
case 1:
|
||||||
|
polygon.vertices.push(this.v1, this.v3, this.v4);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
polygon.vertices.push(this.v1, this.v2, this.v3);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.polygons.push(polygon);
|
this.polygons.push(polygon);
|
||||||
@ -529,17 +537,23 @@
|
|||||||
|
|
||||||
var creator = faces_limit ? new GEO.PolygonsCreator : new GEO.GeometryCreator(12);
|
var creator = faces_limit ? new GEO.PolygonsCreator : new GEO.GeometryCreator(12);
|
||||||
|
|
||||||
creator.AddFace4(dx,dy,dz, dx,-dy,dz, dx,-dy,-dz, dx,dy,-dz); creator.SetNormal(1,0,0);
|
creator.AddFace4(dx, dy, dz, dx, -dy, dz, dx, -dy, -dz, dx, dy, -dz);
|
||||||
|
creator.SetNormal(1, 0, 0);
|
||||||
|
|
||||||
creator.AddFace4(-dx,dy,-dz, -dx,-dy,-dz, -dx,-dy,dz, -dx,dy,dz); creator.SetNormal(-1,0,0);
|
creator.AddFace4(-dx, dy, -dz, -dx, -dy, -dz, -dx, -dy, dz, -dx, dy, dz);
|
||||||
|
creator.SetNormal(-1, 0, 0);
|
||||||
|
|
||||||
creator.AddFace4(-dx,dy,-dz, -dx,dy,dz, dx,dy,dz, dx,dy,-dz); creator.SetNormal(0,1,0);
|
creator.AddFace4(-dx, dy, -dz, -dx, dy, dz, dx, dy, dz, dx, dy, -dz);
|
||||||
|
creator.SetNormal(0, 1, 0);
|
||||||
|
|
||||||
creator.AddFace4(-dx,-dy,dz, -dx,-dy,-dz, dx,-dy,-dz, dx,-dy,dz); creator.SetNormal(0,-1,0);
|
creator.AddFace4(-dx, -dy, dz, -dx, -dy, -dz, dx, -dy, -dz, dx, -dy, dz);
|
||||||
|
creator.SetNormal(0, -1, 0);
|
||||||
|
|
||||||
creator.AddFace4(-dx,dy,dz, -dx,-dy,dz, dx,-dy,dz, dx,dy,dz); creator.SetNormal(0,0,1);
|
creator.AddFace4(-dx, dy, dz, -dx, -dy, dz, dx, -dy, dz, dx, dy, dz);
|
||||||
|
creator.SetNormal(0, 0, 1);
|
||||||
|
|
||||||
creator.AddFace4(dx,dy,-dz, dx,-dy,-dz, -dx,-dy,-dz, -dx,dy,-dz); creator.SetNormal(0,0,-1);
|
creator.AddFace4(dx, dy, -dz, dx, -dy, -dz, -dx, -dy, -dz, -dx, dy, -dz);
|
||||||
|
creator.SetNormal(0, 0, -1);
|
||||||
|
|
||||||
return creator.Create();
|
return creator.Create();
|
||||||
};
|
};
|
||||||
@ -558,8 +572,7 @@
|
|||||||
i4 = indicies[n + 3] * 3;
|
i4 = indicies[n + 3] * 3;
|
||||||
creator.AddFace4(v[i1], v[i1 + 1], v[i1 + 2], v[i2], v[i2 + 1], v[i2 + 2],
|
creator.AddFace4(v[i1], v[i1 + 1], v[i1 + 2], v[i2], v[i2 + 1], v[i2 + 2],
|
||||||
v[i3], v[i3 + 1], v[i3 + 2], v[i4], v[i4 + 1], v[i4 + 2]);
|
v[i3], v[i3 + 1], v[i3 + 2], v[i4], v[i4 + 1], v[i4 + 2]);
|
||||||
if (n===0) creator.SetNormal(0,0,1); else
|
if (n === 0) creator.SetNormal(0, 0, 1); else if (n === 20) creator.SetNormal(0, 0, -1); else creator.CalcNormal();
|
||||||
if (n===20) creator.SetNormal(0,0,-1); else creator.CalcNormal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return creator.Create();
|
return creator.Create();
|
||||||
@ -594,7 +607,8 @@
|
|||||||
if (shape._typename == "TGeoTrd1") {
|
if (shape._typename == "TGeoTrd1") {
|
||||||
y1 = y2 = shape.fDY;
|
y1 = y2 = shape.fDY;
|
||||||
} else {
|
} else {
|
||||||
y1 = shape.fDy1; y2 = shape.fDy2;
|
y1 = shape.fDy1;
|
||||||
|
y2 = shape.fDy2;
|
||||||
}
|
}
|
||||||
|
|
||||||
var v = [
|
var v = [
|
||||||
@ -676,8 +690,7 @@
|
|||||||
|
|
||||||
if ((i1 >= 0) && (i4 >= 0) && faces_limit) {
|
if ((i1 >= 0) && (i4 >= 0) && faces_limit) {
|
||||||
// try to identify two faces with same normal - very useful if one can create face4
|
// try to identify two faces with same normal - very useful if one can create face4
|
||||||
if (n===0) norm = new THREE.Vector3(0,0,1); else
|
if (n === 0) norm = new THREE.Vector3(0, 0, 1); else if (n === 30) norm = new THREE.Vector3(0, 0, -1); else {
|
||||||
if (n===30) norm = new THREE.Vector3(0,0,-1); else {
|
|
||||||
var norm1 = GEO.GetNormal(vertices[i1], vertices[i1 + 1], vertices[i1 + 2],
|
var norm1 = GEO.GetNormal(vertices[i1], vertices[i1 + 1], vertices[i1 + 2],
|
||||||
vertices[i2], vertices[i2 + 1], vertices[i2 + 2],
|
vertices[i2], vertices[i2 + 1], vertices[i2 + 2],
|
||||||
vertices[i3], vertices[i3 + 1], vertices[i3 + 2]);
|
vertices[i3], vertices[i3 + 1], vertices[i3 + 2]);
|
||||||
@ -769,8 +782,14 @@
|
|||||||
_cosp[n] = Math.cos(phi);
|
_cosp[n] = Math.cos(phi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.abs(_sint[0]) <= epsilon) { numoutside -= widthSegments; numtop = 0; }
|
if (Math.abs(_sint[0]) <= epsilon) {
|
||||||
if (Math.abs(_sint[heightSegments]) <= epsilon) { numoutside -= widthSegments; numbottom = 0; }
|
numoutside -= widthSegments;
|
||||||
|
numtop = 0;
|
||||||
|
}
|
||||||
|
if (Math.abs(_sint[heightSegments]) <= epsilon) {
|
||||||
|
numoutside -= widthSegments;
|
||||||
|
numbottom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
var numfaces = numoutside * (noInside ? 1 : 2) + numtop + numbottom + numcut;
|
var numfaces = numoutside * (noInside ? 1 : 2) + numtop + numbottom + numcut;
|
||||||
|
|
||||||
@ -791,8 +810,7 @@
|
|||||||
var k1 = k + d1, k2 = k + d2;
|
var k1 = k + d1, k2 = k + d2;
|
||||||
|
|
||||||
var skip = 0;
|
var skip = 0;
|
||||||
if (Math.abs(_sint[k1]) <= epsilon) skip = 1; else
|
if (Math.abs(_sint[k1]) <= epsilon) skip = 1; else if (Math.abs(_sint[k2]) <= epsilon) skip = 2;
|
||||||
if (Math.abs(_sint[k2]) <= epsilon) skip = 2;
|
|
||||||
|
|
||||||
for (var n = 0; n < widthSegments; ++n) {
|
for (var n = 0; n < widthSegments; ++n) {
|
||||||
creator.AddFace4(
|
creator.AddFace4(
|
||||||
@ -926,8 +944,7 @@
|
|||||||
nz *= -1;
|
nz *= -1;
|
||||||
}
|
}
|
||||||
var reduce = 0;
|
var reduce = 0;
|
||||||
if (R[0] <= 0) reduce = 2; else
|
if (R[0] <= 0) reduce = 2; else if (R[1] <= 0) reduce = 1;
|
||||||
if (R[1] <= 0) reduce = 1;
|
|
||||||
|
|
||||||
for (var seg = 0; seg < radiusSegments; ++seg) {
|
for (var seg = 0; seg < radiusSegments; ++seg) {
|
||||||
creator.AddFace4(
|
creator.AddFace4(
|
||||||
@ -1020,11 +1037,13 @@
|
|||||||
x[seg + 1], y[seg + 1], shape.fDZ);
|
x[seg + 1], y[seg + 1], shape.fDZ);
|
||||||
|
|
||||||
// calculate normals ourself
|
// calculate normals ourself
|
||||||
nx1 = nx2; ny1 = ny2;
|
nx1 = nx2;
|
||||||
|
ny1 = ny2;
|
||||||
nx2 = x[seg + 1] * shape.fRmax / shape.fRmin;
|
nx2 = x[seg + 1] * shape.fRmax / shape.fRmin;
|
||||||
ny2 = y[seg + 1] * shape.fRmin / shape.fRmax;
|
ny2 = y[seg + 1] * shape.fRmin / shape.fRmax;
|
||||||
var dist = Math.sqrt(nx2 * nx2 + ny2 * ny2);
|
var dist = Math.sqrt(nx2 * nx2 + ny2 * ny2);
|
||||||
nx2 = nx2 / dist; ny2 = ny2/dist;
|
nx2 = nx2 / dist;
|
||||||
|
ny2 = ny2 / dist;
|
||||||
|
|
||||||
creator.SetNormal_12_34(nx1, ny1, 0, nx2, ny2, 0);
|
creator.SetNormal_12_34(nx1, ny1, 0, nx2, ny2, 0);
|
||||||
}
|
}
|
||||||
@ -1089,14 +1108,24 @@
|
|||||||
|
|
||||||
for (var t = 0; t < tubularSegments; ++t) {
|
for (var t = 0; t < tubularSegments; ++t) {
|
||||||
var t1 = t + d1, t2 = t + d2;
|
var t1 = t + d1, t2 = t + d2;
|
||||||
center1.x = radius * _cost[t1]; center1.y = radius * _sint[t1];
|
center1.x = radius * _cost[t1];
|
||||||
center2.x = radius * _cost[t2]; center2.y = radius * _sint[t2];
|
center1.y = radius * _sint[t1];
|
||||||
|
center2.x = radius * _cost[t2];
|
||||||
|
center2.y = radius * _sint[t2];
|
||||||
|
|
||||||
for (var n = 0; n < radialSegments; ++n) {
|
for (var n = 0; n < radialSegments; ++n) {
|
||||||
p1.x = (radius + tube * _cosr[n]) * _cost[t1]; p1.y = (radius + tube * _cosr[n]) * _sint[t1]; p1.z = tube*_sinr[n];
|
p1.x = (radius + tube * _cosr[n]) * _cost[t1];
|
||||||
p2.x = (radius + tube * _cosr[n+1]) * _cost[t1]; p2.y = (radius + tube * _cosr[n+1]) * _sint[t1]; p2.z = tube*_sinr[n+1];
|
p1.y = (radius + tube * _cosr[n]) * _sint[t1];
|
||||||
p3.x = (radius + tube * _cosr[n+1]) * _cost[t2]; p3.y = (radius + tube * _cosr[n+1]) * _sint[t2]; p3.z = tube*_sinr[n+1];
|
p1.z = tube * _sinr[n];
|
||||||
p4.x = (radius + tube * _cosr[n]) * _cost[t2]; p4.y = (radius + tube * _cosr[n]) * _sint[t2]; p4.z = tube*_sinr[n];
|
p2.x = (radius + tube * _cosr[n + 1]) * _cost[t1];
|
||||||
|
p2.y = (radius + tube * _cosr[n + 1]) * _sint[t1];
|
||||||
|
p2.z = tube * _sinr[n + 1];
|
||||||
|
p3.x = (radius + tube * _cosr[n + 1]) * _cost[t2];
|
||||||
|
p3.y = (radius + tube * _cosr[n + 1]) * _sint[t2];
|
||||||
|
p3.z = tube * _sinr[n + 1];
|
||||||
|
p4.x = (radius + tube * _cosr[n]) * _cost[t2];
|
||||||
|
p4.y = (radius + tube * _cosr[n]) * _sint[t2];
|
||||||
|
p4.z = tube * _sinr[n];
|
||||||
|
|
||||||
creator.AddFace4(p1.x, p1.y, p1.z,
|
creator.AddFace4(p1.x, p1.y, p1.z,
|
||||||
p2.x, p2.y, p2.z,
|
p2.x, p2.y, p2.z,
|
||||||
@ -1186,8 +1215,7 @@
|
|||||||
if (pnts !== null) {
|
if (pnts !== null) {
|
||||||
if (side === 0) {
|
if (side === 0) {
|
||||||
pnts.push(new THREE.Vector2(rad, layerz));
|
pnts.push(new THREE.Vector2(rad, layerz));
|
||||||
} else
|
} else if (rad < shape.fRmax[layer]) {
|
||||||
if (rad < shape.fRmax[layer]) {
|
|
||||||
pnts.unshift(new THREE.Vector2(rad, layerz));
|
pnts.unshift(new THREE.Vector2(rad, layerz));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1250,7 +1278,10 @@
|
|||||||
nz = Math.sin(angle);
|
nz = Math.sin(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (side>0) { nxy*=-1; nz*=-1; }
|
if (side > 0) {
|
||||||
|
nxy *= -1;
|
||||||
|
nz *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (var seg = 0; seg < radiusSegments; ++seg) {
|
for (var seg = 0; seg < radiusSegments; ++seg) {
|
||||||
creator.AddFace4(r1 * _cos[seg + d1], r1 * _sin[seg + d1], z1,
|
creator.AddFace4(r1 * _cos[seg + d1], r1 * _sin[seg + d1], z1,
|
||||||
@ -1260,7 +1291,8 @@
|
|||||||
creator.SetNormal_12_34(nxy * _cos[seg + d1], nxy * _sin[seg + d1], nz, nxy * _cos[seg + d2], nxy * _sin[seg + d2], nz);
|
creator.SetNormal_12_34(nxy * _cos[seg + d1], nxy * _sin[seg + d1], nz, nxy * _cos[seg + d2], nxy * _sin[seg + d2], nz);
|
||||||
}
|
}
|
||||||
|
|
||||||
z1 = z2; r1 = r2;
|
z1 = z2;
|
||||||
|
r1 = r2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1415,9 +1447,18 @@
|
|||||||
if ((layer === heightSegments + 1) && (lastr === 0)) break;
|
if ((layer === heightSegments + 1) && (lastr === 0)) break;
|
||||||
|
|
||||||
switch (layer) {
|
switch (layer) {
|
||||||
case 0: layerz = zmin; radius = rmin; break;
|
case 0:
|
||||||
case heightSegments: layerz = zmax; radius = rmax; break;
|
layerz = zmin;
|
||||||
case heightSegments + 1: layerz = zmax; radius = 0; break;
|
radius = rmin;
|
||||||
|
break;
|
||||||
|
case heightSegments:
|
||||||
|
layerz = zmax;
|
||||||
|
radius = rmax;
|
||||||
|
break;
|
||||||
|
case heightSegments + 1:
|
||||||
|
layerz = zmax;
|
||||||
|
radius = 0;
|
||||||
|
break;
|
||||||
default: {
|
default: {
|
||||||
var tt = Math.tan(ttmin + (ttmax - ttmin) * layer / heightSegments);
|
var tt = Math.tan(ttmin + (ttmax - ttmin) * layer / heightSegments);
|
||||||
var delta = tt * tt - 4 * shape.fA * shape.fB; // should be always positive (a*b<0)
|
var delta = tt * tt - 4 * shape.fA * shape.fB; // should be always positive (a*b<0)
|
||||||
@ -1431,8 +1472,7 @@
|
|||||||
nz = (shape.fA > 0) ? -1 : 1;
|
nz = (shape.fA > 0) ? -1 : 1;
|
||||||
|
|
||||||
var skip = 0;
|
var skip = 0;
|
||||||
if (lastr === 0) skip = 1; else
|
if (lastr === 0) skip = 1; else if (radius === 0) skip = 2;
|
||||||
if (radius === 0) skip = 2;
|
|
||||||
|
|
||||||
for (var seg = 0; seg < radiusSegments; ++seg) {
|
for (var seg = 0; seg < radiusSegments; ++seg) {
|
||||||
creator.AddFace4(radius * _cos[seg], radius * _sin[seg], layerz,
|
creator.AddFace4(radius * _cos[seg], radius * _sin[seg], layerz,
|
||||||
@ -1451,8 +1491,10 @@
|
|||||||
creator.SetNormal(0, 0, (layer < heightSegments) ? -1 : 1);
|
creator.SetNormal(0, 0, (layer < heightSegments) ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastz = layerz; lastr = radius;
|
lastz = layerz;
|
||||||
lastnxy = nxy; lastnz = nz;
|
lastr = radius;
|
||||||
|
lastnxy = nxy;
|
||||||
|
lastnz = nz;
|
||||||
}
|
}
|
||||||
|
|
||||||
return creator.Create();
|
return creator.Create();
|
||||||
@ -1540,9 +1582,15 @@
|
|||||||
var translation = null, rotation = null, scale = null;
|
var translation = null, rotation = null, scale = null;
|
||||||
|
|
||||||
switch (matrix._typename) {
|
switch (matrix._typename) {
|
||||||
case 'TGeoTranslation': translation = matrix.fTranslation; break;
|
case 'TGeoTranslation':
|
||||||
case 'TGeoRotation': rotation = matrix.fRotationMatrix; break;
|
translation = matrix.fTranslation;
|
||||||
case 'TGeoScale': scale = matrix.fScale; break;
|
break;
|
||||||
|
case 'TGeoRotation':
|
||||||
|
rotation = matrix.fRotationMatrix;
|
||||||
|
break;
|
||||||
|
case 'TGeoScale':
|
||||||
|
scale = matrix.fScale;
|
||||||
|
break;
|
||||||
case 'TGeoGenTrans':
|
case 'TGeoGenTrans':
|
||||||
scale = matrix.fScale; // no break, translation and rotation follows
|
scale = matrix.fScale; // no break, translation and rotation follows
|
||||||
case 'TGeoCombiTrans':
|
case 'TGeoCombiTrans':
|
||||||
@ -1599,11 +1647,9 @@
|
|||||||
// second - set position with proper sign
|
// second - set position with proper sign
|
||||||
matrix.setPosition({x: node.fTrans[12], y: node.fTrans[13], z: node.fTrans[14]});
|
matrix.setPosition({x: node.fTrans[12], y: node.fTrans[13], z: node.fTrans[14]});
|
||||||
}
|
}
|
||||||
} else
|
} else if (('fMatrix' in node) && (node.fMatrix !== null))
|
||||||
if (('fMatrix' in node) && (node.fMatrix !== null))
|
|
||||||
matrix = GEO.createMatrix(node.fMatrix);
|
matrix = GEO.createMatrix(node.fMatrix);
|
||||||
else
|
else if ((node._typename == "TGeoNodeOffset") && (node.fFinder !== null)) {
|
||||||
if ((node._typename == "TGeoNodeOffset") && (node.fFinder !== null)) {
|
|
||||||
var kPatternReflected = GEO.BITS.kVisBranch;
|
var kPatternReflected = GEO.BITS.kVisBranch;
|
||||||
if ((node.fFinder.fBits & kPatternReflected) !== 0)
|
if ((node.fFinder.fBits & kPatternReflected) !== 0)
|
||||||
GEO.warn('Unsupported reflected pattern ' + node.fFinder._typename);
|
GEO.warn('Unsupported reflected pattern ' + node.fFinder._typename);
|
||||||
@ -1625,9 +1671,15 @@
|
|||||||
matrix = new THREE.Matrix4();
|
matrix = new THREE.Matrix4();
|
||||||
|
|
||||||
switch (node.fFinder._typename[node.fFinder._typename.length - 1]) {
|
switch (node.fFinder._typename[node.fFinder._typename.length - 1]) {
|
||||||
case 'X': matrix.setPosition(new THREE.Vector3(_shift, 0, 0)); break;
|
case 'X':
|
||||||
case 'Y': matrix.setPosition(new THREE.Vector3(0, _shift, 0)); break;
|
matrix.setPosition(new THREE.Vector3(_shift, 0, 0));
|
||||||
case 'Z': matrix.setPosition(new THREE.Vector3(0, 0, _shift)); break;
|
break;
|
||||||
|
case 'Y':
|
||||||
|
matrix.setPosition(new THREE.Vector3(0, _shift, 0));
|
||||||
|
break;
|
||||||
|
case 'Z':
|
||||||
|
matrix.setPosition(new THREE.Vector3(0, 0, _shift));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1733,9 +1785,15 @@
|
|||||||
bsp1.maxid = bsp2.maxid;
|
bsp1.maxid = bsp2.maxid;
|
||||||
|
|
||||||
switch (shape.fNode._typename) {
|
switch (shape.fNode._typename) {
|
||||||
case 'TGeoIntersection': bsp1.direct_intersect(bsp2); break; // "*"
|
case 'TGeoIntersection':
|
||||||
case 'TGeoUnion': bsp1.direct_union(bsp2); break; // "+"
|
bsp1.direct_intersect(bsp2);
|
||||||
case 'TGeoSubtraction': bsp1.direct_subtract(bsp2); break; // "/"
|
break; // "*"
|
||||||
|
case 'TGeoUnion':
|
||||||
|
bsp1.direct_union(bsp2);
|
||||||
|
break; // "+"
|
||||||
|
case 'TGeoSubtraction':
|
||||||
|
bsp1.direct_subtract(bsp2);
|
||||||
|
break; // "/"
|
||||||
default:
|
default:
|
||||||
GEO.warn('unsupported bool operation ' + shape.fNode._typename + ', use first geom');
|
GEO.warn('unsupported bool operation ' + shape.fNode._typename + ', use first geom');
|
||||||
}
|
}
|
||||||
@ -1774,9 +1832,15 @@
|
|||||||
size = 10000;
|
size = 10000;
|
||||||
|
|
||||||
switch (projection) {
|
switch (projection) {
|
||||||
case "x": size = Math.max(sizey,sizez); break;
|
case "x":
|
||||||
case "y": size = Math.max(sizex,sizez); break;
|
size = Math.max(sizey, sizez);
|
||||||
case "z": size = Math.max(sizex,sizey); break;
|
break;
|
||||||
|
case "y":
|
||||||
|
size = Math.max(sizex, sizez);
|
||||||
|
break;
|
||||||
|
case "z":
|
||||||
|
size = Math.max(sizex, sizey);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bsp2 = ThreeBSP.CreateNormal(projection, position, size);
|
var bsp2 = ThreeBSP.CreateNormal(projection, position, size);
|
||||||
@ -1799,35 +1863,50 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
switch (shape._typename) {
|
switch (shape._typename) {
|
||||||
case "TGeoBBox": return GEO.createCubeBuffer( shape, limit );
|
case "TGeoBBox":
|
||||||
case "TGeoPara": return GEO.createParaBuffer( shape, limit );
|
return GEO.createCubeBuffer(shape, limit);
|
||||||
|
case "TGeoPara":
|
||||||
|
return GEO.createParaBuffer(shape, limit);
|
||||||
case "TGeoTrd1":
|
case "TGeoTrd1":
|
||||||
case "TGeoTrd2": return GEO.createTrapezoidBuffer( shape, limit );
|
case "TGeoTrd2":
|
||||||
|
return GEO.createTrapezoidBuffer(shape, limit);
|
||||||
case "TGeoArb8":
|
case "TGeoArb8":
|
||||||
case "TGeoTrap":
|
case "TGeoTrap":
|
||||||
case "TGeoGtra": return GEO.createArb8Buffer( shape, limit );
|
case "TGeoGtra":
|
||||||
case "TGeoSphere": return GEO.createSphereBuffer( shape , limit );
|
return GEO.createArb8Buffer(shape, limit);
|
||||||
|
case "TGeoSphere":
|
||||||
|
return GEO.createSphereBuffer(shape, limit);
|
||||||
case "TGeoCone":
|
case "TGeoCone":
|
||||||
case "TGeoConeSeg":
|
case "TGeoConeSeg":
|
||||||
case "TGeoTube":
|
case "TGeoTube":
|
||||||
case "TGeoTubeSeg":
|
case "TGeoTubeSeg":
|
||||||
case "TGeoCtub": return GEO.createTubeBuffer( shape, limit );
|
case "TGeoCtub":
|
||||||
case "TGeoEltu": return GEO.createEltuBuffer( shape, limit );
|
return GEO.createTubeBuffer(shape, limit);
|
||||||
case "TGeoTorus": return GEO.createTorusBuffer( shape, limit );
|
case "TGeoEltu":
|
||||||
|
return GEO.createEltuBuffer(shape, limit);
|
||||||
|
case "TGeoTorus":
|
||||||
|
return GEO.createTorusBuffer(shape, limit);
|
||||||
case "TGeoPcon":
|
case "TGeoPcon":
|
||||||
case "TGeoPgon": return GEO.createPolygonBuffer( shape, limit );
|
case "TGeoPgon":
|
||||||
case "TGeoXtru": return GEO.createXtruBuffer( shape, limit );
|
return GEO.createPolygonBuffer(shape, limit);
|
||||||
case "TGeoParaboloid": return GEO.createParaboloidBuffer( shape, limit );
|
case "TGeoXtru":
|
||||||
case "TGeoHype": return GEO.createHypeBuffer( shape, limit );
|
return GEO.createXtruBuffer(shape, limit);
|
||||||
case "TGeoCompositeShape": return GEO.createComposite( shape, limit );
|
case "TGeoParaboloid":
|
||||||
case "TGeoShapeAssembly": break;
|
return GEO.createParaboloidBuffer(shape, limit);
|
||||||
|
case "TGeoHype":
|
||||||
|
return GEO.createHypeBuffer(shape, limit);
|
||||||
|
case "TGeoCompositeShape":
|
||||||
|
return GEO.createComposite(shape, limit);
|
||||||
|
case "TGeoShapeAssembly":
|
||||||
|
break;
|
||||||
case "TGeoScaledShape": {
|
case "TGeoScaledShape": {
|
||||||
var res = GEO.createGeometry(shape.fShape, limit);
|
var res = GEO.createGeometry(shape.fShape, limit);
|
||||||
if (shape.fScale && (limit >= 0) && (typeof res === 'object') && (typeof res.scale === 'function'))
|
if (shape.fScale && (limit >= 0) && (typeof res === 'object') && (typeof res.scale === 'function'))
|
||||||
res.scale(shape.fScale.fScale[0], shape.fScale.fScale[1], shape.fScale.fScale[2]);
|
res.scale(shape.fScale.fScale[0], shape.fScale.fScale[1], shape.fScale.fScale[2]);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
default: GEO.warn('unsupported shape type ' + shape._typename);
|
default:
|
||||||
|
GEO.warn('unsupported shape type ' + shape._typename);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var place = "";
|
var place = "";
|
||||||
@ -1846,9 +1925,7 @@
|
|||||||
GEO.provideInfo = function (obj) {
|
GEO.provideInfo = function (obj) {
|
||||||
var info = [], shape = null;
|
var info = [], shape = null;
|
||||||
|
|
||||||
if (obj.fVolume !== undefined) shape = obj.fVolume.fShape; else
|
if (obj.fVolume !== undefined) shape = obj.fVolume.fShape; else if (obj.fShape !== undefined) shape = obj.fShape; else if ((obj.fShapeBits !== undefined) && (obj.fShapeId !== undefined)) shape = obj;
|
||||||
if (obj.fShape !== undefined) shape = obj.fShape; else
|
|
||||||
if ((obj.fShapeBits !== undefined) && (obj.fShapeId !== undefined)) shape = obj;
|
|
||||||
|
|
||||||
if (!shape) {
|
if (!shape) {
|
||||||
info.push(obj._typename);
|
info.push(obj._typename);
|
||||||
@ -1869,13 +1946,22 @@
|
|||||||
info.push("DX=" + conv(shape.fDX) + " DY=" + conv(shape.fDY) + " DZ=" + conv(shape.fDZ));
|
info.push("DX=" + conv(shape.fDX) + " DY=" + conv(shape.fDY) + " DZ=" + conv(shape.fDZ));
|
||||||
|
|
||||||
switch (shape._typename) {
|
switch (shape._typename) {
|
||||||
case "TGeoBBox": break;
|
case "TGeoBBox":
|
||||||
case "TGeoPara": info.push("Alpha=" + shape.fAlpha + " Phi=" + shape.fPhi + " Theta=" + shape.fTheta); break;
|
break;
|
||||||
case "TGeoTrd2": info.push("Dy1=" + conv(shape.fDy1) + " Dy2=" + conv(shape.fDy1));
|
case "TGeoPara":
|
||||||
case "TGeoTrd1": info.push("Dx1=" + conv(shape.fDx1) + " Dx2=" + conv(shape.fDx1)); break;
|
info.push("Alpha=" + shape.fAlpha + " Phi=" + shape.fPhi + " Theta=" + shape.fTheta);
|
||||||
case "TGeoArb8": break;
|
break;
|
||||||
case "TGeoTrap": break;
|
case "TGeoTrd2":
|
||||||
case "TGeoGtra": break;
|
info.push("Dy1=" + conv(shape.fDy1) + " Dy2=" + conv(shape.fDy1));
|
||||||
|
case "TGeoTrd1":
|
||||||
|
info.push("Dx1=" + conv(shape.fDx1) + " Dx2=" + conv(shape.fDx1));
|
||||||
|
break;
|
||||||
|
case "TGeoArb8":
|
||||||
|
break;
|
||||||
|
case "TGeoTrap":
|
||||||
|
break;
|
||||||
|
case "TGeoGtra":
|
||||||
|
break;
|
||||||
case "TGeoSphere":
|
case "TGeoSphere":
|
||||||
info.push("Rmin=" + conv(shape.fRmin) + " Rmax=" + conv(shape.fRmax));
|
info.push("Rmin=" + conv(shape.fRmin) + " Rmax=" + conv(shape.fRmax));
|
||||||
info.push("Phi1=" + shape.fPhi1 + " Phi2=" + shape.fPhi2);
|
info.push("Phi1=" + shape.fPhi1 + " Phi2=" + shape.fPhi2);
|
||||||
@ -1899,8 +1985,10 @@
|
|||||||
info.push("Phi1=" + shape.fPhi1 + " Dphi=" + shape.fDphi);
|
info.push("Phi1=" + shape.fPhi1 + " Dphi=" + shape.fDphi);
|
||||||
break;
|
break;
|
||||||
case "TGeoPcon":
|
case "TGeoPcon":
|
||||||
case "TGeoPgon": break;
|
case "TGeoPgon":
|
||||||
case "TGeoXtru": break;
|
break;
|
||||||
|
case "TGeoXtru":
|
||||||
|
break;
|
||||||
case "TGeoParaboloid":
|
case "TGeoParaboloid":
|
||||||
info.push("Rlo=" + conv(shape.fRlo) + " Rhi=" + conv(shape.fRhi));
|
info.push("Rlo=" + conv(shape.fRlo) + " Rhi=" + conv(shape.fRhi));
|
||||||
info.push("A=" + conv(shape.fA) + " B=" + conv(shape.fB));
|
info.push("A=" + conv(shape.fA) + " B=" + conv(shape.fB));
|
||||||
@ -1909,8 +1997,10 @@
|
|||||||
info.push("Rmin=" + conv(shape.fRmin) + " Rmax=" + conv(shape.fRmax));
|
info.push("Rmin=" + conv(shape.fRmin) + " Rmax=" + conv(shape.fRmax));
|
||||||
info.push("StIn=" + conv(shape.fStIn) + " StOut=" + conv(shape.fStOut));
|
info.push("StIn=" + conv(shape.fStIn) + " StOut=" + conv(shape.fStOut));
|
||||||
break;
|
break;
|
||||||
case "TGeoCompositeShape": break;
|
case "TGeoCompositeShape":
|
||||||
case "TGeoShapeAssembly": break;
|
break;
|
||||||
|
case "TGeoShapeAssembly":
|
||||||
|
break;
|
||||||
case "TGeoScaledShape":
|
case "TGeoScaledShape":
|
||||||
info = GEO.provideInfo(shape.fShape);
|
info = GEO.provideInfo(shape.fShape);
|
||||||
if (shape.fScale)
|
if (shape.fScale)
|
||||||
@ -2092,8 +2182,7 @@
|
|||||||
if (obj) {
|
if (obj) {
|
||||||
if (obj.$geoh) this.toplevel = false;
|
if (obj.$geoh) this.toplevel = false;
|
||||||
this.CreateClones(obj);
|
this.CreateClones(obj);
|
||||||
} else
|
} else if (clones) this.nodes = clones;
|
||||||
if (clones) this.nodes = clones;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GEO.ClonedNodes.prototype.GetNodeShape = function (indx) {
|
GEO.ClonedNodes.prototype.GetNodeShape = function (indx) {
|
||||||
@ -2185,8 +2274,7 @@
|
|||||||
if (kind === 1) {
|
if (kind === 1) {
|
||||||
shape = obj.fShape;
|
shape = obj.fShape;
|
||||||
if (obj.fElements) chlds = obj.fElements.arr;
|
if (obj.fElements) chlds = obj.fElements.arr;
|
||||||
} else
|
} else if (obj.fVolume) {
|
||||||
if (obj.fVolume) {
|
|
||||||
shape = obj.fVolume.fShape;
|
shape = obj.fVolume.fShape;
|
||||||
if (obj.fVolume.fNodes) chlds = obj.fVolume.fNodes.arr;
|
if (obj.fVolume.fNodes) chlds = obj.fVolume.fNodes.arr;
|
||||||
}
|
}
|
||||||
@ -2227,7 +2315,9 @@
|
|||||||
delete this.origin[n]._refid;
|
delete this.origin[n]._refid;
|
||||||
|
|
||||||
// do sorting once
|
// do sorting once
|
||||||
sortarr.sort(function(a,b) { return b.vol - a.vol; });
|
sortarr.sort(function (a, b) {
|
||||||
|
return b.vol - a.vol;
|
||||||
|
});
|
||||||
|
|
||||||
// remember sort map and also sortid
|
// remember sort map and also sortid
|
||||||
this.sortmap = new Int32Array(this.nodes.length);
|
this.sortmap = new Int32Array(this.nodes.length);
|
||||||
@ -2319,7 +2409,11 @@
|
|||||||
arg.counter = 0; // sequence ID of the node, used to identify it later
|
arg.counter = 0; // sequence ID of the node, used to identify it later
|
||||||
arg.last = 0;
|
arg.last = 0;
|
||||||
arg.CopyStack = function (factor) {
|
arg.CopyStack = function (factor) {
|
||||||
var entry = { nodeid: this.nodeid, seqid: this.counter, stack: (this.last>10) ? new Int32Array(this.last) : new Array(this.last) };
|
var entry = {
|
||||||
|
nodeid: this.nodeid,
|
||||||
|
seqid: this.counter,
|
||||||
|
stack: (this.last > 10) ? new Int32Array(this.last) : new Array(this.last)
|
||||||
|
};
|
||||||
if (factor) entry.factor = factor; // factor used to indicate importance of entry, will be build as first
|
if (factor) entry.factor = factor; // factor used to indicate importance of entry, will be build as first
|
||||||
for (var n = 0; n < this.last; ++n) entry.stack[n] = this.stack[n + 1]; // copy stack
|
for (var n = 0; n < this.last; ++n) entry.stack[n] = this.stack[n + 1]; // copy stack
|
||||||
return entry;
|
return entry;
|
||||||
@ -2328,7 +2422,9 @@
|
|||||||
if (arg.domatrix) {
|
if (arg.domatrix) {
|
||||||
arg.matrices = [];
|
arg.matrices = [];
|
||||||
arg.mpool = [new THREE.Matrix4()]; // pool of Matrix objects to avoid permanent creation
|
arg.mpool = [new THREE.Matrix4()]; // pool of Matrix objects to avoid permanent creation
|
||||||
arg.getmatrix = function() { return this.matrices[this.last]; }
|
arg.getmatrix = function () {
|
||||||
|
return this.matrices[this.last];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2495,7 +2591,11 @@
|
|||||||
|
|
||||||
for (var k = 0; k < node.chlds.length; ++k) {
|
for (var k = 0; k < node.chlds.length; ++k) {
|
||||||
var chldid = node.chlds[k];
|
var chldid = node.chlds[k];
|
||||||
if (this.GetNodeName(chldid) === names[n]) { stack.push(k); currid = chldid; break; }
|
if (this.GetNodeName(chldid) === names[n]) {
|
||||||
|
stack.push(k);
|
||||||
|
currid = chldid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no new entry - not found stack
|
// no new entry - not found stack
|
||||||
@ -2517,10 +2617,12 @@
|
|||||||
var prop = {name: clone.name, nname: clone.name, shape: null, material: null, chlds: null};
|
var prop = {name: clone.name, nname: clone.name, shape: null, material: null, chlds: null};
|
||||||
var _opacity = entry.opacity;
|
var _opacity = entry.opacity;
|
||||||
prop.fillcolor = new THREE.Color(entry.color ? "rgb(" + entry.color + ")" : "blue");
|
prop.fillcolor = new THREE.Color(entry.color ? "rgb(" + entry.color + ")" : "blue");
|
||||||
prop.material = new THREE.MeshLambertMaterial( { transparent: _opacity < 1,
|
prop.material = new THREE.MeshLambertMaterial({
|
||||||
|
transparent: _opacity < 1,
|
||||||
opacity: _opacity, wireframe: false, color: prop.fillcolor,
|
opacity: _opacity, wireframe: false, color: prop.fillcolor,
|
||||||
side: THREE.FrontSide /* THREE.DoubleSide*/, vertexColors: THREE.NoColors /*THREE.VertexColors */,
|
side: THREE.FrontSide /* THREE.DoubleSide*/, vertexColors: THREE.NoColors /*THREE.VertexColors */,
|
||||||
overdraw: 0., depthWrite: _opacity == 1 } );
|
overdraw: 0., depthWrite: _opacity == 1
|
||||||
|
});
|
||||||
prop.material.inherentOpacity = _opacity;
|
prop.material.inherentOpacity = _opacity;
|
||||||
|
|
||||||
return prop;
|
return prop;
|
||||||
@ -2536,17 +2638,25 @@
|
|||||||
if (clone.kind === 1) {
|
if (clone.kind === 1) {
|
||||||
// special handling for EVE nodes
|
// special handling for EVE nodes
|
||||||
|
|
||||||
var prop = { name: GEO.ObjectName(node), nname: GEO.ObjectName(node), shape: node.fShape, material: null, chlds: null };
|
var prop = {
|
||||||
|
name: GEO.ObjectName(node),
|
||||||
|
nname: GEO.ObjectName(node),
|
||||||
|
shape: node.fShape,
|
||||||
|
material: null,
|
||||||
|
chlds: null
|
||||||
|
};
|
||||||
|
|
||||||
if (node.fElements !== null) prop.chlds = node.fElements.arr;
|
if (node.fElements !== null) prop.chlds = node.fElements.arr;
|
||||||
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
var _opacity = Math.min(1, node.fRGBA[3]);
|
var _opacity = Math.min(1, node.fRGBA[3]);
|
||||||
prop.fillcolor = new THREE.Color(node.fRGBA[0], node.fRGBA[1], node.fRGBA[2]);
|
prop.fillcolor = new THREE.Color(node.fRGBA[0], node.fRGBA[1], node.fRGBA[2]);
|
||||||
prop.material = new THREE.MeshLambertMaterial( { transparent: _opacity < 1,
|
prop.material = new THREE.MeshLambertMaterial({
|
||||||
|
transparent: _opacity < 1,
|
||||||
opacity: _opacity, wireframe: false, color: prop.fillcolor,
|
opacity: _opacity, wireframe: false, color: prop.fillcolor,
|
||||||
side: THREE.FrontSide /* THREE.DoubleSide*/, vertexColors: THREE.NoColors /*THREE.VertexColors */,
|
side: THREE.FrontSide /* THREE.DoubleSide*/, vertexColors: THREE.NoColors /*THREE.VertexColors */,
|
||||||
overdraw: 0., depthWrite: _opacity == 1 } );
|
overdraw: 0., depthWrite: _opacity == 1
|
||||||
|
});
|
||||||
prop.material.inherentOpacity = _opacity;
|
prop.material.inherentOpacity = _opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2555,7 +2665,14 @@
|
|||||||
|
|
||||||
var volume = node.fVolume;
|
var volume = node.fVolume;
|
||||||
|
|
||||||
var prop = { name: GEO.ObjectName(volume), nname: GEO.ObjectName(node), volume: node.fVolume, shape: volume.fShape, material: null, chlds: null };
|
var prop = {
|
||||||
|
name: GEO.ObjectName(volume),
|
||||||
|
nname: GEO.ObjectName(node),
|
||||||
|
volume: node.fVolume,
|
||||||
|
shape: volume.fShape,
|
||||||
|
material: null,
|
||||||
|
chlds: null
|
||||||
|
};
|
||||||
|
|
||||||
if (node.fVolume.fNodes !== null) prop.chlds = node.fVolume.fNodes.arr;
|
if (node.fVolume.fNodes !== null) prop.chlds = node.fVolume.fNodes.arr;
|
||||||
|
|
||||||
@ -2565,8 +2682,7 @@
|
|||||||
var _opacity = 1.0;
|
var _opacity = 1.0;
|
||||||
if ((volume.fFillColor > 1) && (volume.fLineColor == 1))
|
if ((volume.fFillColor > 1) && (volume.fLineColor == 1))
|
||||||
prop.fillcolor = JSROOT.Painter.root_colors[volume.fFillColor];
|
prop.fillcolor = JSROOT.Painter.root_colors[volume.fFillColor];
|
||||||
else
|
else if (volume.fLineColor >= 0)
|
||||||
if (volume.fLineColor >= 0)
|
|
||||||
prop.fillcolor = JSROOT.Painter.root_colors[volume.fLineColor];
|
prop.fillcolor = JSROOT.Painter.root_colors[volume.fLineColor];
|
||||||
|
|
||||||
if (volume.fMedium && volume.fMedium.fMaterial) {
|
if (volume.fMedium && volume.fMedium.fMaterial) {
|
||||||
@ -2580,10 +2696,12 @@
|
|||||||
if (prop.fillcolor === undefined)
|
if (prop.fillcolor === undefined)
|
||||||
prop.fillcolor = "lightgrey";
|
prop.fillcolor = "lightgrey";
|
||||||
|
|
||||||
prop.material = new THREE.MeshLambertMaterial( { transparent: _opacity < 1,
|
prop.material = new THREE.MeshLambertMaterial({
|
||||||
|
transparent: _opacity < 1,
|
||||||
opacity: _opacity, wireframe: false, color: prop.fillcolor,
|
opacity: _opacity, wireframe: false, color: prop.fillcolor,
|
||||||
side: THREE.FrontSide /* THREE.DoubleSide */, vertexColors: THREE.NoColors /*THREE.VertexColors*/,
|
side: THREE.FrontSide /* THREE.DoubleSide */, vertexColors: THREE.NoColors /*THREE.VertexColors*/,
|
||||||
overdraw: 0., depthWrite: _opacity == 1 } );
|
overdraw: 0., depthWrite: _opacity == 1
|
||||||
|
});
|
||||||
prop.material.inherentOpacity = _opacity;
|
prop.material.inherentOpacity = _opacity;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2728,7 +2846,8 @@
|
|||||||
|
|
||||||
for (var n = 0; n < arg.viscnt.length; ++n) arg.viscnt[n] = 0;
|
for (var n = 0; n < arg.viscnt.length; ++n) arg.viscnt[n] = 0;
|
||||||
|
|
||||||
var total = this.ScanVisible(arg), minVol = 0, maxVol = 0, camVol = -1, camFact = 10, sortidcut = this.nodes.length + 1;
|
var total = this.ScanVisible(arg), minVol = 0, maxVol = 0, camVol = -1, camFact = 10,
|
||||||
|
sortidcut = this.nodes.length + 1;
|
||||||
|
|
||||||
// console.log('Total visible nodes ' + total + ' numfaces ' + arg.facecnt);
|
// console.log('Total visible nodes ' + total + ' numfaces ' + arg.facecnt);
|
||||||
|
|
||||||
@ -2778,8 +2897,7 @@
|
|||||||
arg.func = function (node) {
|
arg.func = function (node) {
|
||||||
if (node.sortid < sortidcut) {
|
if (node.sortid < sortidcut) {
|
||||||
this.items.push(this.CopyStack());
|
this.items.push(this.CopyStack());
|
||||||
} else
|
} else if ((camVol >= 0) && (node.vol > camVol))
|
||||||
if ((camVol >= 0) && (node.vol > camVol))
|
|
||||||
if (this.frustum.CheckShape(this.getmatrix(), node)) {
|
if (this.frustum.CheckShape(this.getmatrix(), node)) {
|
||||||
this.items.push(this.CopyStack(camFact));
|
this.items.push(this.CopyStack(camFact));
|
||||||
}
|
}
|
||||||
@ -2830,7 +2948,14 @@
|
|||||||
if (shape._id === undefined) {
|
if (shape._id === undefined) {
|
||||||
shape._id = shapes.length;
|
shape._id = shapes.length;
|
||||||
|
|
||||||
shapes.push({ id: shape._id, shape: shape, vol: this.nodes[entry.nodeid].vol, refcnt: 1, factor: 1, ready: false });
|
shapes.push({
|
||||||
|
id: shape._id,
|
||||||
|
shape: shape,
|
||||||
|
vol: this.nodes[entry.nodeid].vol,
|
||||||
|
refcnt: 1,
|
||||||
|
factor: 1,
|
||||||
|
ready: false
|
||||||
|
});
|
||||||
|
|
||||||
// shapes.push( { obj: shape, vol: this.nodes[entry.nodeid].vol });
|
// shapes.push( { obj: shape, vol: this.nodes[entry.nodeid].vol });
|
||||||
} else {
|
} else {
|
||||||
@ -2845,7 +2970,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now sort shapes in volume decrease order
|
// now sort shapes in volume decrease order
|
||||||
shapes.sort(function(a,b) { return b.vol*b.factor - a.vol*a.factor; });
|
shapes.sort(function (a, b) {
|
||||||
|
return b.vol * b.factor - a.vol * a.factor;
|
||||||
|
});
|
||||||
|
|
||||||
// now set new shape ids according to the sorted order and delete temporary field
|
// now set new shape ids according to the sorted order and delete temporary field
|
||||||
for (var n = 0; n < shapes.length; ++n) {
|
for (var n = 0; n < shapes.length; ++n) {
|
||||||
@ -2918,7 +3045,10 @@
|
|||||||
var item = lst[n];
|
var item = lst[n];
|
||||||
|
|
||||||
// if enough faces are produced, nothing else is required
|
// if enough faces are produced, nothing else is required
|
||||||
if (res.done) { item.ready = true; continue; }
|
if (res.done) {
|
||||||
|
item.ready = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!item.ready) {
|
if (!item.ready) {
|
||||||
if (item.geom === undefined) {
|
if (item.geom === undefined) {
|
||||||
@ -2935,8 +3065,7 @@
|
|||||||
|
|
||||||
if (res.faces >= limit) {
|
if (res.faces >= limit) {
|
||||||
res.done = true;
|
res.done = true;
|
||||||
} else
|
} else if ((created > 0.01 * lst.length) && (timelimit !== undefined)) {
|
||||||
if ((created > 0.01*lst.length) && (timelimit!==undefined)) {
|
|
||||||
var tm2 = new Date().getTime();
|
var tm2 = new Date().getTime();
|
||||||
if (tm2 - tm1 > timelimit) return res;
|
if (tm2 - tm1 > timelimit) return res;
|
||||||
}
|
}
|
||||||
@ -3009,7 +3138,8 @@
|
|||||||
dnorm[ii * 3 + 2] = norm[k * 3 + 2];
|
dnorm[ii * 3 + 2] = norm[k * 3 + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = dpos; norm = dnorm;
|
pos = dpos;
|
||||||
|
norm = dnorm;
|
||||||
}
|
}
|
||||||
|
|
||||||
var len = pos.length, n, shift = 0,
|
var len = pos.length, n, shift = 0,
|
||||||
@ -3026,7 +3156,8 @@
|
|||||||
newnorm[n + 1] = norm[n + 1 + shift];
|
newnorm[n + 1] = norm[n + 1 + shift];
|
||||||
newnorm[n + 2] = -norm[n + 2 + shift];
|
newnorm[n + 2] = -norm[n + 2 + shift];
|
||||||
|
|
||||||
shift+=3; if (shift===6) shift=-3; // values 0,3,-3
|
shift += 3;
|
||||||
|
if (shift === 6) shift = -3; // values 0,3,-3
|
||||||
}
|
}
|
||||||
|
|
||||||
shape.geomZ = new THREE.BufferGeometry();
|
shape.geomZ = new THREE.BufferGeometry();
|
||||||
@ -3044,7 +3175,9 @@
|
|||||||
var face, d, n = 0;
|
var face, d, n = 0;
|
||||||
while (n < shape.geomZ.faces.length) {
|
while (n < shape.geomZ.faces.length) {
|
||||||
face = geom.faces[n++];
|
face = geom.faces[n++];
|
||||||
d = face.b; face.b = face.c; face.c = d;
|
d = face.b;
|
||||||
|
face.b = face.c;
|
||||||
|
face.c = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
// normals are calculated with normal geometry and correctly scaled
|
// normals are calculated with normal geometry and correctly scaled
|
||||||
@ -3107,8 +3240,7 @@
|
|||||||
setdefaults(chld);
|
setdefaults(chld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else if ((obj.$jsroot_depth === undefined) || (obj.$jsroot_depth < lvl)) traverse(chld, lvl, arr);
|
||||||
if ((obj.$jsroot_depth===undefined) || (obj.$jsroot_depth < lvl)) traverse(chld, lvl, arr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3163,7 +3295,9 @@
|
|||||||
mesh.$jsroot_distance = dist;
|
mesh.$jsroot_distance = dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
arr.sort(function(a,b) { return a.$jsroot_distance - b.$jsroot_distance; });
|
arr.sort(function (a, b) {
|
||||||
|
return a.$jsroot_distance - b.$jsroot_distance;
|
||||||
|
});
|
||||||
|
|
||||||
var resort = new Array(arr.length);
|
var resort = new Array(arr.length);
|
||||||
|
|
||||||
@ -3278,20 +3412,17 @@
|
|||||||
var shape = null;
|
var shape = null;
|
||||||
|
|
||||||
if (('fShapeBits' in obj) && ('fShapeId' in obj)) {
|
if (('fShapeBits' in obj) && ('fShapeId' in obj)) {
|
||||||
shape = obj; obj = null;
|
shape = obj;
|
||||||
} else
|
obj = null;
|
||||||
if ((obj._typename === 'TGeoVolumeAssembly') || (obj._typename === 'TGeoVolume')) {
|
} else if ((obj._typename === 'TGeoVolumeAssembly') || (obj._typename === 'TGeoVolume')) {
|
||||||
shape = obj.fShape;
|
shape = obj.fShape;
|
||||||
} else
|
} else if ((obj._typename === "TEveGeoShapeExtract") || (obj._typename === "ROOT::Experimental::TEveGeoShapeExtract")) {
|
||||||
if ((obj._typename === "TEveGeoShapeExtract") || (obj._typename === "ROOT::Experimental::TEveGeoShapeExtract") ) {
|
|
||||||
shape = obj.fShape;
|
shape = obj.fShape;
|
||||||
} else
|
} else if (obj._typename === 'TGeoManager') {
|
||||||
if (obj._typename === 'TGeoManager') {
|
|
||||||
obj = obj.fMasterVolume;
|
obj = obj.fMasterVolume;
|
||||||
GEO.SetBit(obj, GEO.BITS.kVisThis, false);
|
GEO.SetBit(obj, GEO.BITS.kVisThis, false);
|
||||||
shape = obj.fShape;
|
shape = obj.fShape;
|
||||||
} else
|
} else if ('fVolume' in obj) {
|
||||||
if ('fVolume' in obj) {
|
|
||||||
if (obj.fVolume) shape = obj.fVolume.fShape;
|
if (obj.fVolume) shape = obj.fVolume.fShape;
|
||||||
} else {
|
} else {
|
||||||
obj = null;
|
obj = null;
|
||||||
@ -3391,7 +3522,10 @@
|
|||||||
|
|
||||||
if (!node || !node.geometry) return box3;
|
if (!node || !node.geometry) return box3;
|
||||||
|
|
||||||
if (!box3) { box3 = new THREE.Box3(); box3.makeEmpty(); }
|
if (!box3) {
|
||||||
|
box3 = new THREE.Box3();
|
||||||
|
box3.makeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
node.updateMatrixWorld();
|
node.updateMatrixWorld();
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
(function (factory) {
|
(function (factory) {
|
||||||
if (typeof define === "function" && define.amd) {
|
if (typeof define === "function" && define.amd) {
|
||||||
define(['three-full'], factory);
|
define(['three-full'], factory);
|
||||||
} else
|
} else if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||||
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
|
||||||
factory(require("three-full"), exports);
|
factory(require("three-full"), exports);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -758,7 +757,9 @@
|
|||||||
this.y = e[1] * x + e[5] * y + e[9] * z + e[13];
|
this.y = e[1] * x + e[5] * y + e[9] * z + e[13];
|
||||||
this.z = e[2] * x + e[6] * y + e[10] * z + e[14];
|
this.z = e[2] * x + e[6] * y + e[10] * z + e[14];
|
||||||
|
|
||||||
x = this.nx; y = this.ny; z = this.nz;
|
x = this.nx;
|
||||||
|
y = this.ny;
|
||||||
|
z = this.nz;
|
||||||
|
|
||||||
this.nx = e[0] * x + e[4] * y + e[8] * z;
|
this.nx = e[0] * x + e[4] * y + e[8] * z;
|
||||||
this.ny = e[1] * x + e[5] * y + e[9] * z;
|
this.ny = e[1] * x + e[5] * y + e[9] * z;
|
||||||
@ -853,7 +854,9 @@
|
|||||||
var node = new ThreeBSP.Node();
|
var node = new ThreeBSP.Node();
|
||||||
|
|
||||||
node.divider = this.divider.clone();
|
node.divider = this.divider.clone();
|
||||||
node.polygons = this.polygons.map( function( polygon ) { return polygon.clone(); } );
|
node.polygons = this.polygons.map(function (polygon) {
|
||||||
|
return polygon.clone();
|
||||||
|
});
|
||||||
node.front = this.front && this.front.clone();
|
node.front = this.front && this.front.clone();
|
||||||
node.back = this.back && this.back.clone();
|
node.back = this.back && this.back.clone();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user