forked from kscience/visionforge
GDML update
This commit is contained in:
parent
5c8665ac3e
commit
4865c76158
@ -1,7 +1,6 @@
|
||||
package hep.dataforge.vis.spatial
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.meta.buildMeta
|
||||
import hep.dataforge.meta.number
|
||||
import hep.dataforge.meta.set
|
||||
import hep.dataforge.vis.ApplicationBase
|
||||
@ -56,12 +55,7 @@ class ThreeDemoApp : ApplicationBase() {
|
||||
// }
|
||||
gdml {
|
||||
y = 110.0
|
||||
shape = buildMeta {
|
||||
"_typename" to "TGeoBBox"
|
||||
"fDX" to 50.0
|
||||
"fDY" to 50.0
|
||||
"fDZ" to 50.0
|
||||
}
|
||||
shape = box(50, 50, 50)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package hep.dataforge.vis.spatial.gdml
|
||||
import hep.dataforge.meta.EmptyMeta
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.meta.MetaItem
|
||||
import hep.dataforge.meta.buildMeta
|
||||
import hep.dataforge.vis.*
|
||||
import hep.dataforge.vis.spatial.GenericThreeBuilder
|
||||
import hep.dataforge.vis.spatial.Materials
|
||||
@ -19,6 +20,37 @@ class GDMLObject(parent: DisplayObject?, meta: Meta) : DisplayLeaf(parent, TYPE,
|
||||
|
||||
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 {
|
||||
const val TYPE = "geometry.spatial.gdml"
|
||||
}
|
||||
|
@ -4,8 +4,7 @@
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(['three-full', 'ThreeCSG'], factory);
|
||||
} else
|
||||
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||
} else if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||
factory(require("three-full"), require("./ThreeCSG.js"));
|
||||
} else {
|
||||
if (typeof THREE == 'undefined')
|
||||
@ -27,7 +26,9 @@
|
||||
* @param {number} n bit number
|
||||
* @returns {Number} produced make
|
||||
* @private */
|
||||
JSROOT.BIT = function(n) { return 1 << (n); };
|
||||
JSROOT.BIT = function (n) {
|
||||
return 1 << (n);
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Generic method to invoke callback function.
|
||||
@ -171,8 +172,10 @@
|
||||
this.indx = indx + 9;
|
||||
};
|
||||
|
||||
GEO.GeometryCreator.prototype.StartPolygon = function() {};
|
||||
GEO.GeometryCreator.prototype.StopPolygon = function() {};
|
||||
GEO.GeometryCreator.prototype.StartPolygon = function () {
|
||||
};
|
||||
GEO.GeometryCreator.prototype.StopPolygon = function () {
|
||||
};
|
||||
|
||||
GEO.GeometryCreator.prototype.AddFace4 = function (x1, y1, z1,
|
||||
x2, y2, z2,
|
||||
@ -431,8 +434,7 @@
|
||||
if (next.diff(first) < 1e-12) {
|
||||
//console.log('polygon closed!!!', polygon.vertices.length);
|
||||
this.multi = 0;
|
||||
} else
|
||||
if (this.mnormal) {
|
||||
} else if (this.mnormal) {
|
||||
polygon.vertices.push(this.v3);
|
||||
} else {
|
||||
polygon.vertices.unshift(this.v2);
|
||||
@ -445,9 +447,15 @@
|
||||
var polygon = new ThreeBSP.Polygon;
|
||||
|
||||
switch (reduce) {
|
||||
case 0: polygon.vertices.push(this.v1, this.v2, this.v3, this.v4); 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;
|
||||
case 0:
|
||||
polygon.vertices.push(this.v1, this.v2, this.v3, this.v4);
|
||||
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);
|
||||
@ -529,17 +537,23 @@
|
||||
|
||||
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();
|
||||
};
|
||||
@ -558,8 +572,7 @@
|
||||
i4 = indicies[n + 3] * 3;
|
||||
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]);
|
||||
if (n===0) creator.SetNormal(0,0,1); else
|
||||
if (n===20) creator.SetNormal(0,0,-1); else creator.CalcNormal();
|
||||
if (n === 0) creator.SetNormal(0, 0, 1); else if (n === 20) creator.SetNormal(0, 0, -1); else creator.CalcNormal();
|
||||
}
|
||||
|
||||
return creator.Create();
|
||||
@ -594,7 +607,8 @@
|
||||
if (shape._typename == "TGeoTrd1") {
|
||||
y1 = y2 = shape.fDY;
|
||||
} else {
|
||||
y1 = shape.fDy1; y2 = shape.fDy2;
|
||||
y1 = shape.fDy1;
|
||||
y2 = shape.fDy2;
|
||||
}
|
||||
|
||||
var v = [
|
||||
@ -676,8 +690,7 @@
|
||||
|
||||
if ((i1 >= 0) && (i4 >= 0) && faces_limit) {
|
||||
// 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===30) 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 {
|
||||
var norm1 = GEO.GetNormal(vertices[i1], vertices[i1 + 1], vertices[i1 + 2],
|
||||
vertices[i2], vertices[i2 + 1], vertices[i2 + 2],
|
||||
vertices[i3], vertices[i3 + 1], vertices[i3 + 2]);
|
||||
@ -769,8 +782,14 @@
|
||||
_cosp[n] = Math.cos(phi);
|
||||
}
|
||||
|
||||
if (Math.abs(_sint[0]) <= epsilon) { numoutside -= widthSegments; numtop = 0; }
|
||||
if (Math.abs(_sint[heightSegments]) <= epsilon) { numoutside -= widthSegments; numbottom = 0; }
|
||||
if (Math.abs(_sint[0]) <= epsilon) {
|
||||
numoutside -= widthSegments;
|
||||
numtop = 0;
|
||||
}
|
||||
if (Math.abs(_sint[heightSegments]) <= epsilon) {
|
||||
numoutside -= widthSegments;
|
||||
numbottom = 0;
|
||||
}
|
||||
|
||||
var numfaces = numoutside * (noInside ? 1 : 2) + numtop + numbottom + numcut;
|
||||
|
||||
@ -791,8 +810,7 @@
|
||||
var k1 = k + d1, k2 = k + d2;
|
||||
|
||||
var skip = 0;
|
||||
if (Math.abs(_sint[k1]) <= epsilon) skip = 1; else
|
||||
if (Math.abs(_sint[k2]) <= epsilon) skip = 2;
|
||||
if (Math.abs(_sint[k1]) <= epsilon) skip = 1; else if (Math.abs(_sint[k2]) <= epsilon) skip = 2;
|
||||
|
||||
for (var n = 0; n < widthSegments; ++n) {
|
||||
creator.AddFace4(
|
||||
@ -926,8 +944,7 @@
|
||||
nz *= -1;
|
||||
}
|
||||
var reduce = 0;
|
||||
if (R[0] <= 0) reduce = 2; else
|
||||
if (R[1] <= 0) reduce = 1;
|
||||
if (R[0] <= 0) reduce = 2; else if (R[1] <= 0) reduce = 1;
|
||||
|
||||
for (var seg = 0; seg < radiusSegments; ++seg) {
|
||||
creator.AddFace4(
|
||||
@ -1020,11 +1037,13 @@
|
||||
x[seg + 1], y[seg + 1], shape.fDZ);
|
||||
|
||||
// calculate normals ourself
|
||||
nx1 = nx2; ny1 = ny2;
|
||||
nx1 = nx2;
|
||||
ny1 = ny2;
|
||||
nx2 = x[seg + 1] * shape.fRmax / shape.fRmin;
|
||||
ny2 = y[seg + 1] * shape.fRmin / shape.fRmax;
|
||||
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);
|
||||
}
|
||||
@ -1089,14 +1108,24 @@
|
||||
|
||||
for (var t = 0; t < tubularSegments; ++t) {
|
||||
var t1 = t + d1, t2 = t + d2;
|
||||
center1.x = radius * _cost[t1]; center1.y = radius * _sint[t1];
|
||||
center2.x = radius * _cost[t2]; center2.y = radius * _sint[t2];
|
||||
center1.x = radius * _cost[t1];
|
||||
center1.y = radius * _sint[t1];
|
||||
center2.x = radius * _cost[t2];
|
||||
center2.y = radius * _sint[t2];
|
||||
|
||||
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];
|
||||
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];
|
||||
p1.x = (radius + tube * _cosr[n]) * _cost[t1];
|
||||
p1.y = (radius + tube * _cosr[n]) * _sint[t1];
|
||||
p1.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,
|
||||
p2.x, p2.y, p2.z,
|
||||
@ -1186,8 +1215,7 @@
|
||||
if (pnts !== null) {
|
||||
if (side === 0) {
|
||||
pnts.push(new THREE.Vector2(rad, layerz));
|
||||
} else
|
||||
if (rad < shape.fRmax[layer]) {
|
||||
} else if (rad < shape.fRmax[layer]) {
|
||||
pnts.unshift(new THREE.Vector2(rad, layerz));
|
||||
}
|
||||
}
|
||||
@ -1250,7 +1278,10 @@
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
z1 = z2; r1 = r2;
|
||||
z1 = z2;
|
||||
r1 = r2;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1415,9 +1447,18 @@
|
||||
if ((layer === heightSegments + 1) && (lastr === 0)) break;
|
||||
|
||||
switch (layer) {
|
||||
case 0: layerz = zmin; radius = rmin; break;
|
||||
case heightSegments: layerz = zmax; radius = rmax; break;
|
||||
case heightSegments + 1: layerz = zmax; radius = 0; break;
|
||||
case 0:
|
||||
layerz = zmin;
|
||||
radius = rmin;
|
||||
break;
|
||||
case heightSegments:
|
||||
layerz = zmax;
|
||||
radius = rmax;
|
||||
break;
|
||||
case heightSegments + 1:
|
||||
layerz = zmax;
|
||||
radius = 0;
|
||||
break;
|
||||
default: {
|
||||
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)
|
||||
@ -1431,8 +1472,7 @@
|
||||
nz = (shape.fA > 0) ? -1 : 1;
|
||||
|
||||
var skip = 0;
|
||||
if (lastr === 0) skip = 1; else
|
||||
if (radius === 0) skip = 2;
|
||||
if (lastr === 0) skip = 1; else if (radius === 0) skip = 2;
|
||||
|
||||
for (var seg = 0; seg < radiusSegments; ++seg) {
|
||||
creator.AddFace4(radius * _cos[seg], radius * _sin[seg], layerz,
|
||||
@ -1451,8 +1491,10 @@
|
||||
creator.SetNormal(0, 0, (layer < heightSegments) ? -1 : 1);
|
||||
}
|
||||
|
||||
lastz = layerz; lastr = radius;
|
||||
lastnxy = nxy; lastnz = nz;
|
||||
lastz = layerz;
|
||||
lastr = radius;
|
||||
lastnxy = nxy;
|
||||
lastnz = nz;
|
||||
}
|
||||
|
||||
return creator.Create();
|
||||
@ -1540,9 +1582,15 @@
|
||||
var translation = null, rotation = null, scale = null;
|
||||
|
||||
switch (matrix._typename) {
|
||||
case 'TGeoTranslation': translation = matrix.fTranslation; break;
|
||||
case 'TGeoRotation': rotation = matrix.fRotationMatrix; break;
|
||||
case 'TGeoScale': scale = matrix.fScale; break;
|
||||
case 'TGeoTranslation':
|
||||
translation = matrix.fTranslation;
|
||||
break;
|
||||
case 'TGeoRotation':
|
||||
rotation = matrix.fRotationMatrix;
|
||||
break;
|
||||
case 'TGeoScale':
|
||||
scale = matrix.fScale;
|
||||
break;
|
||||
case 'TGeoGenTrans':
|
||||
scale = matrix.fScale; // no break, translation and rotation follows
|
||||
case 'TGeoCombiTrans':
|
||||
@ -1599,11 +1647,9 @@
|
||||
// second - set position with proper sign
|
||||
matrix.setPosition({x: node.fTrans[12], y: node.fTrans[13], z: node.fTrans[14]});
|
||||
}
|
||||
} else
|
||||
if (('fMatrix' in node) && (node.fMatrix !== null))
|
||||
} else if (('fMatrix' in node) && (node.fMatrix !== null))
|
||||
matrix = GEO.createMatrix(node.fMatrix);
|
||||
else
|
||||
if ((node._typename == "TGeoNodeOffset") && (node.fFinder !== null)) {
|
||||
else if ((node._typename == "TGeoNodeOffset") && (node.fFinder !== null)) {
|
||||
var kPatternReflected = GEO.BITS.kVisBranch;
|
||||
if ((node.fFinder.fBits & kPatternReflected) !== 0)
|
||||
GEO.warn('Unsupported reflected pattern ' + node.fFinder._typename);
|
||||
@ -1625,9 +1671,15 @@
|
||||
matrix = new THREE.Matrix4();
|
||||
|
||||
switch (node.fFinder._typename[node.fFinder._typename.length - 1]) {
|
||||
case 'X': matrix.setPosition(new THREE.Vector3(_shift, 0, 0)); break;
|
||||
case 'Y': matrix.setPosition(new THREE.Vector3(0, _shift, 0)); break;
|
||||
case 'Z': matrix.setPosition(new THREE.Vector3(0, 0, _shift)); break;
|
||||
case 'X':
|
||||
matrix.setPosition(new THREE.Vector3(_shift, 0, 0));
|
||||
break;
|
||||
case 'Y':
|
||||
matrix.setPosition(new THREE.Vector3(0, _shift, 0));
|
||||
break;
|
||||
case 'Z':
|
||||
matrix.setPosition(new THREE.Vector3(0, 0, _shift));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1733,9 +1785,15 @@
|
||||
bsp1.maxid = bsp2.maxid;
|
||||
|
||||
switch (shape.fNode._typename) {
|
||||
case 'TGeoIntersection': bsp1.direct_intersect(bsp2); break; // "*"
|
||||
case 'TGeoUnion': bsp1.direct_union(bsp2); break; // "+"
|
||||
case 'TGeoSubtraction': bsp1.direct_subtract(bsp2); break; // "/"
|
||||
case 'TGeoIntersection':
|
||||
bsp1.direct_intersect(bsp2);
|
||||
break; // "*"
|
||||
case 'TGeoUnion':
|
||||
bsp1.direct_union(bsp2);
|
||||
break; // "+"
|
||||
case 'TGeoSubtraction':
|
||||
bsp1.direct_subtract(bsp2);
|
||||
break; // "/"
|
||||
default:
|
||||
GEO.warn('unsupported bool operation ' + shape.fNode._typename + ', use first geom');
|
||||
}
|
||||
@ -1774,9 +1832,15 @@
|
||||
size = 10000;
|
||||
|
||||
switch (projection) {
|
||||
case "x": size = Math.max(sizey,sizez); break;
|
||||
case "y": size = Math.max(sizex,sizez); break;
|
||||
case "z": size = Math.max(sizex,sizey); break;
|
||||
case "x":
|
||||
size = Math.max(sizey, sizez);
|
||||
break;
|
||||
case "y":
|
||||
size = Math.max(sizex, sizez);
|
||||
break;
|
||||
case "z":
|
||||
size = Math.max(sizex, sizey);
|
||||
break;
|
||||
}
|
||||
|
||||
var bsp2 = ThreeBSP.CreateNormal(projection, position, size);
|
||||
@ -1799,35 +1863,50 @@
|
||||
|
||||
try {
|
||||
switch (shape._typename) {
|
||||
case "TGeoBBox": return GEO.createCubeBuffer( shape, limit );
|
||||
case "TGeoPara": return GEO.createParaBuffer( shape, limit );
|
||||
case "TGeoBBox":
|
||||
return GEO.createCubeBuffer(shape, limit);
|
||||
case "TGeoPara":
|
||||
return GEO.createParaBuffer(shape, limit);
|
||||
case "TGeoTrd1":
|
||||
case "TGeoTrd2": return GEO.createTrapezoidBuffer( shape, limit );
|
||||
case "TGeoTrd2":
|
||||
return GEO.createTrapezoidBuffer(shape, limit);
|
||||
case "TGeoArb8":
|
||||
case "TGeoTrap":
|
||||
case "TGeoGtra": return GEO.createArb8Buffer( shape, limit );
|
||||
case "TGeoSphere": return GEO.createSphereBuffer( shape , limit );
|
||||
case "TGeoGtra":
|
||||
return GEO.createArb8Buffer(shape, limit);
|
||||
case "TGeoSphere":
|
||||
return GEO.createSphereBuffer(shape, limit);
|
||||
case "TGeoCone":
|
||||
case "TGeoConeSeg":
|
||||
case "TGeoTube":
|
||||
case "TGeoTubeSeg":
|
||||
case "TGeoCtub": return GEO.createTubeBuffer( shape, limit );
|
||||
case "TGeoEltu": return GEO.createEltuBuffer( shape, limit );
|
||||
case "TGeoTorus": return GEO.createTorusBuffer( shape, limit );
|
||||
case "TGeoCtub":
|
||||
return GEO.createTubeBuffer(shape, limit);
|
||||
case "TGeoEltu":
|
||||
return GEO.createEltuBuffer(shape, limit);
|
||||
case "TGeoTorus":
|
||||
return GEO.createTorusBuffer(shape, limit);
|
||||
case "TGeoPcon":
|
||||
case "TGeoPgon": return GEO.createPolygonBuffer( shape, limit );
|
||||
case "TGeoXtru": return GEO.createXtruBuffer( shape, limit );
|
||||
case "TGeoParaboloid": return GEO.createParaboloidBuffer( shape, limit );
|
||||
case "TGeoHype": return GEO.createHypeBuffer( shape, limit );
|
||||
case "TGeoCompositeShape": return GEO.createComposite( shape, limit );
|
||||
case "TGeoShapeAssembly": break;
|
||||
case "TGeoPgon":
|
||||
return GEO.createPolygonBuffer(shape, limit);
|
||||
case "TGeoXtru":
|
||||
return GEO.createXtruBuffer(shape, limit);
|
||||
case "TGeoParaboloid":
|
||||
return GEO.createParaboloidBuffer(shape, limit);
|
||||
case "TGeoHype":
|
||||
return GEO.createHypeBuffer(shape, limit);
|
||||
case "TGeoCompositeShape":
|
||||
return GEO.createComposite(shape, limit);
|
||||
case "TGeoShapeAssembly":
|
||||
break;
|
||||
case "TGeoScaledShape": {
|
||||
var res = GEO.createGeometry(shape.fShape, limit);
|
||||
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]);
|
||||
return res;
|
||||
}
|
||||
default: GEO.warn('unsupported shape type ' + shape._typename);
|
||||
default:
|
||||
GEO.warn('unsupported shape type ' + shape._typename);
|
||||
}
|
||||
} catch (e) {
|
||||
var place = "";
|
||||
@ -1846,9 +1925,7 @@
|
||||
GEO.provideInfo = function (obj) {
|
||||
var info = [], shape = null;
|
||||
|
||||
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.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 (!shape) {
|
||||
info.push(obj._typename);
|
||||
@ -1869,13 +1946,22 @@
|
||||
info.push("DX=" + conv(shape.fDX) + " DY=" + conv(shape.fDY) + " DZ=" + conv(shape.fDZ));
|
||||
|
||||
switch (shape._typename) {
|
||||
case "TGeoBBox": break;
|
||||
case "TGeoPara": info.push("Alpha=" + shape.fAlpha + " Phi=" + shape.fPhi + " Theta=" + shape.fTheta); break;
|
||||
case "TGeoTrd2": 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 "TGeoBBox":
|
||||
break;
|
||||
case "TGeoPara":
|
||||
info.push("Alpha=" + shape.fAlpha + " Phi=" + shape.fPhi + " Theta=" + shape.fTheta);
|
||||
break;
|
||||
case "TGeoTrd2":
|
||||
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":
|
||||
info.push("Rmin=" + conv(shape.fRmin) + " Rmax=" + conv(shape.fRmax));
|
||||
info.push("Phi1=" + shape.fPhi1 + " Phi2=" + shape.fPhi2);
|
||||
@ -1899,8 +1985,10 @@
|
||||
info.push("Phi1=" + shape.fPhi1 + " Dphi=" + shape.fDphi);
|
||||
break;
|
||||
case "TGeoPcon":
|
||||
case "TGeoPgon": break;
|
||||
case "TGeoXtru": break;
|
||||
case "TGeoPgon":
|
||||
break;
|
||||
case "TGeoXtru":
|
||||
break;
|
||||
case "TGeoParaboloid":
|
||||
info.push("Rlo=" + conv(shape.fRlo) + " Rhi=" + conv(shape.fRhi));
|
||||
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("StIn=" + conv(shape.fStIn) + " StOut=" + conv(shape.fStOut));
|
||||
break;
|
||||
case "TGeoCompositeShape": break;
|
||||
case "TGeoShapeAssembly": break;
|
||||
case "TGeoCompositeShape":
|
||||
break;
|
||||
case "TGeoShapeAssembly":
|
||||
break;
|
||||
case "TGeoScaledShape":
|
||||
info = GEO.provideInfo(shape.fShape);
|
||||
if (shape.fScale)
|
||||
@ -2092,8 +2182,7 @@
|
||||
if (obj) {
|
||||
if (obj.$geoh) this.toplevel = false;
|
||||
this.CreateClones(obj);
|
||||
} else
|
||||
if (clones) this.nodes = clones;
|
||||
} else if (clones) this.nodes = clones;
|
||||
};
|
||||
|
||||
GEO.ClonedNodes.prototype.GetNodeShape = function (indx) {
|
||||
@ -2185,8 +2274,7 @@
|
||||
if (kind === 1) {
|
||||
shape = obj.fShape;
|
||||
if (obj.fElements) chlds = obj.fElements.arr;
|
||||
} else
|
||||
if (obj.fVolume) {
|
||||
} else if (obj.fVolume) {
|
||||
shape = obj.fVolume.fShape;
|
||||
if (obj.fVolume.fNodes) chlds = obj.fVolume.fNodes.arr;
|
||||
}
|
||||
@ -2227,7 +2315,9 @@
|
||||
delete this.origin[n]._refid;
|
||||
|
||||
// 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
|
||||
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.last = 0;
|
||||
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
|
||||
for (var n = 0; n < this.last; ++n) entry.stack[n] = this.stack[n + 1]; // copy stack
|
||||
return entry;
|
||||
@ -2328,7 +2422,9 @@
|
||||
if (arg.domatrix) {
|
||||
arg.matrices = [];
|
||||
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) {
|
||||
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
|
||||
@ -2517,10 +2617,12 @@
|
||||
var prop = {name: clone.name, nname: clone.name, shape: null, material: null, chlds: null};
|
||||
var _opacity = entry.opacity;
|
||||
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,
|
||||
side: THREE.FrontSide /* THREE.DoubleSide*/, vertexColors: THREE.NoColors /*THREE.VertexColors */,
|
||||
overdraw: 0., depthWrite: _opacity == 1 } );
|
||||
overdraw: 0., depthWrite: _opacity == 1
|
||||
});
|
||||
prop.material.inherentOpacity = _opacity;
|
||||
|
||||
return prop;
|
||||
@ -2536,17 +2638,25 @@
|
||||
if (clone.kind === 1) {
|
||||
// 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 (visible) {
|
||||
var _opacity = Math.min(1, node.fRGBA[3]);
|
||||
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,
|
||||
side: THREE.FrontSide /* THREE.DoubleSide*/, vertexColors: THREE.NoColors /*THREE.VertexColors */,
|
||||
overdraw: 0., depthWrite: _opacity == 1 } );
|
||||
overdraw: 0., depthWrite: _opacity == 1
|
||||
});
|
||||
prop.material.inherentOpacity = _opacity;
|
||||
}
|
||||
|
||||
@ -2555,7 +2665,14 @@
|
||||
|
||||
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;
|
||||
|
||||
@ -2565,8 +2682,7 @@
|
||||
var _opacity = 1.0;
|
||||
if ((volume.fFillColor > 1) && (volume.fLineColor == 1))
|
||||
prop.fillcolor = JSROOT.Painter.root_colors[volume.fFillColor];
|
||||
else
|
||||
if (volume.fLineColor >= 0)
|
||||
else if (volume.fLineColor >= 0)
|
||||
prop.fillcolor = JSROOT.Painter.root_colors[volume.fLineColor];
|
||||
|
||||
if (volume.fMedium && volume.fMedium.fMaterial) {
|
||||
@ -2580,10 +2696,12 @@
|
||||
if (prop.fillcolor === undefined)
|
||||
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,
|
||||
side: THREE.FrontSide /* THREE.DoubleSide */, vertexColors: THREE.NoColors /*THREE.VertexColors*/,
|
||||
overdraw: 0., depthWrite: _opacity == 1 } );
|
||||
overdraw: 0., depthWrite: _opacity == 1
|
||||
});
|
||||
prop.material.inherentOpacity = _opacity;
|
||||
|
||||
}
|
||||
@ -2728,7 +2846,8 @@
|
||||
|
||||
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);
|
||||
|
||||
@ -2778,8 +2897,7 @@
|
||||
arg.func = function (node) {
|
||||
if (node.sortid < sortidcut) {
|
||||
this.items.push(this.CopyStack());
|
||||
} else
|
||||
if ((camVol >= 0) && (node.vol > camVol))
|
||||
} else if ((camVol >= 0) && (node.vol > camVol))
|
||||
if (this.frustum.CheckShape(this.getmatrix(), node)) {
|
||||
this.items.push(this.CopyStack(camFact));
|
||||
}
|
||||
@ -2830,7 +2948,14 @@
|
||||
if (shape._id === undefined) {
|
||||
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 });
|
||||
} else {
|
||||
@ -2845,7 +2970,9 @@
|
||||
}
|
||||
|
||||
// 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
|
||||
for (var n = 0; n < shapes.length; ++n) {
|
||||
@ -2918,7 +3045,10 @@
|
||||
var item = lst[n];
|
||||
|
||||
// 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.geom === undefined) {
|
||||
@ -2935,8 +3065,7 @@
|
||||
|
||||
if (res.faces >= limit) {
|
||||
res.done = true;
|
||||
} else
|
||||
if ((created > 0.01*lst.length) && (timelimit!==undefined)) {
|
||||
} else if ((created > 0.01 * lst.length) && (timelimit !== undefined)) {
|
||||
var tm2 = new Date().getTime();
|
||||
if (tm2 - tm1 > timelimit) return res;
|
||||
}
|
||||
@ -3009,7 +3138,8 @@
|
||||
dnorm[ii * 3 + 2] = norm[k * 3 + 2];
|
||||
}
|
||||
|
||||
pos = dpos; norm = dnorm;
|
||||
pos = dpos;
|
||||
norm = dnorm;
|
||||
}
|
||||
|
||||
var len = pos.length, n, shift = 0,
|
||||
@ -3026,7 +3156,8 @@
|
||||
newnorm[n + 1] = norm[n + 1 + 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();
|
||||
@ -3044,7 +3175,9 @@
|
||||
var face, d, n = 0;
|
||||
while (n < shape.geomZ.faces.length) {
|
||||
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
|
||||
@ -3107,8 +3240,7 @@
|
||||
setdefaults(chld);
|
||||
}
|
||||
}
|
||||
} else
|
||||
if ((obj.$jsroot_depth===undefined) || (obj.$jsroot_depth < lvl)) traverse(chld, lvl, arr);
|
||||
} else if ((obj.$jsroot_depth === undefined) || (obj.$jsroot_depth < lvl)) traverse(chld, lvl, arr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3163,7 +3295,9 @@
|
||||
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);
|
||||
|
||||
@ -3278,20 +3412,17 @@
|
||||
var shape = null;
|
||||
|
||||
if (('fShapeBits' in obj) && ('fShapeId' in obj)) {
|
||||
shape = obj; obj = null;
|
||||
} else
|
||||
if ((obj._typename === 'TGeoVolumeAssembly') || (obj._typename === 'TGeoVolume')) {
|
||||
shape = obj;
|
||||
obj = null;
|
||||
} else if ((obj._typename === 'TGeoVolumeAssembly') || (obj._typename === 'TGeoVolume')) {
|
||||
shape = obj.fShape;
|
||||
} else
|
||||
if ((obj._typename === "TEveGeoShapeExtract") || (obj._typename === "ROOT::Experimental::TEveGeoShapeExtract") ) {
|
||||
} else if ((obj._typename === "TEveGeoShapeExtract") || (obj._typename === "ROOT::Experimental::TEveGeoShapeExtract")) {
|
||||
shape = obj.fShape;
|
||||
} else
|
||||
if (obj._typename === 'TGeoManager') {
|
||||
} else if (obj._typename === 'TGeoManager') {
|
||||
obj = obj.fMasterVolume;
|
||||
GEO.SetBit(obj, GEO.BITS.kVisThis, false);
|
||||
shape = obj.fShape;
|
||||
} else
|
||||
if ('fVolume' in obj) {
|
||||
} else if ('fVolume' in obj) {
|
||||
if (obj.fVolume) shape = obj.fVolume.fShape;
|
||||
} else {
|
||||
obj = null;
|
||||
@ -3391,7 +3522,10 @@
|
||||
|
||||
if (!node || !node.geometry) return box3;
|
||||
|
||||
if (!box3) { box3 = new THREE.Box3(); box3.makeEmpty(); }
|
||||
if (!box3) {
|
||||
box3 = new THREE.Box3();
|
||||
box3.makeEmpty();
|
||||
}
|
||||
|
||||
node.updateMatrixWorld();
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(['three-full'], factory);
|
||||
} else
|
||||
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||
} else if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||
factory(require("three-full"), exports);
|
||||
} else {
|
||||
|
||||
@ -758,7 +757,9 @@
|
||||
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];
|
||||
|
||||
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.ny = e[1] * x + e[5] * y + e[9] * z;
|
||||
@ -853,7 +854,9 @@
|
||||
var node = new ThreeBSP.Node();
|
||||
|
||||
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.back = this.back && this.back.clone();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user