zincjs 1.12.3 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zincjs",
3
- "version": "1.12.3",
3
+ "version": "1.13.0",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
@@ -19,7 +19,6 @@ const TextureSlides = function (textureIn) {
19
19
  this.morph = new THREE.Group();
20
20
  this.group = this.morph;
21
21
  this.morph.userData = this;
22
- let edgesLine = undefined;
23
22
  let flipY = true;
24
23
 
25
24
  /**
@@ -60,7 +59,7 @@ const TextureSlides = function (textureIn) {
60
59
  mesh.position.z = 0;
61
60
  switch (settings.direction) {
62
61
  case "x":
63
- const rotation = -Math.PI / 2;
62
+ const rotation = flipY ? -Math.PI / 2 : Math.PI / 2;
64
63
  mesh.rotation.y = rotation;
65
64
  uniforms.direction.value = 1;
66
65
  uniforms.slide.value.set(settings.value, 0, 0);
@@ -304,13 +303,9 @@ const TextureSlides = function (textureIn) {
304
303
  this.boundingBoxUpdateRequired = true;
305
304
  }
306
305
 
307
- this.setRenderOrder = (order) => {
308
- //multiilayers
309
- this.morph.renderOrder = order;
310
- }
311
-
312
306
  this.initialise = (textureData, finishCallback) => {
313
307
  if (textureData) {
308
+
314
309
  const locations = textureData.locations;
315
310
  if (locations && locations.length > 0) {
316
311
  this.applyTransformation(locations[0].orientation,
@@ -325,25 +320,6 @@ const TextureSlides = function (textureIn) {
325
320
  }
326
321
  }
327
322
  }
328
-
329
- this.showEdges = (color) => {
330
- if (!edgesLine) {
331
- const geometry = new THREE.BoxGeometry( 1, 1, 1 );
332
- geometry.translate(0.5, 0.5, 0.5);
333
- const edges = new THREE.EdgesGeometry( geometry );
334
- edgesLine = new THREE.LineSegments(edges, new THREE.LineBasicMaterial( { color } ) );
335
- this.group.add( edgesLine );
336
- } else {
337
- edgesLine.material.color = color;
338
- }
339
- edgesLine.visible = true;
340
- }
341
-
342
- this.hideEdges = () => {
343
- if (edgesLine) {
344
- edgesLine.visible = false;
345
- }
346
- }
347
323
  }
348
324
 
349
325
  TextureSlides.prototype = Object.create((require('./texturePrimitive').TexturePrimitive).prototype);
package/src/scene.js CHANGED
@@ -5,6 +5,7 @@ const SceneExporter = require('./sceneExporter').SceneExporter;
5
5
  const Viewport = require('./controls').Viewport;
6
6
  const createBufferGeometry = require('./utilities').createBufferGeometry;
7
7
  const getCircularTexture = require('./utilities').getCircularTexture;
8
+ const createNewSpriteText = require('./utilities').createNewSpriteText;
8
9
  let uniqueiId = 0;
9
10
 
10
11
  const getUniqueId = function () {
@@ -42,6 +43,7 @@ exports.Scene = function (containerIn, rendererIn) {
42
43
  let zincObjectRemovedCallbacks = {};
43
44
  let zincObjectRemovedCallbacks_id = 0;
44
45
  const scene = new THREE.Scene();
46
+ const miniAxesScene = new THREE.Scene();
45
47
  const rootRegion = new (require('./region').Region)(undefined, this);
46
48
  scene.add(rootRegion.getGroup());
47
49
  const tempGroup = new THREE.Group();
@@ -63,12 +65,13 @@ exports.Scene = function (containerIn, rendererIn) {
63
65
  this.autoClearFlag = true;
64
66
  this.displayMarkers = false;
65
67
  this.displayMinimap = false;
68
+ this.displayMiniAxes = false;
66
69
  this.minimapScissor = {
67
70
  x_offset: 16,
68
71
  y_offset: 16,
69
72
  width: 128,
70
73
  height: 128,
71
- align: "top-left",
74
+ align: "top-right",
72
75
  updateRequired: true
73
76
  };
74
77
  let scissor = {x: 0, y: 0};
@@ -80,6 +83,11 @@ exports.Scene = function (containerIn, rendererIn) {
80
83
  let markerCluster = new MarkerCluster(this);
81
84
  markerCluster.disable();
82
85
  scene.add(markerCluster.group);
86
+ let axisDisplay = {
87
+ main: [],
88
+ mini: [],
89
+ }
90
+ const _v3 = new THREE.Vector3( 0, 0, 0 );
83
91
 
84
92
  const getDrawingWidth = () => {
85
93
  if (container)
@@ -668,7 +676,7 @@ exports.Scene = function (containerIn, rendererIn) {
668
676
  }
669
677
 
670
678
  const renderMinimap = renderer => {
671
- if (this.displayMinimap === true) {
679
+ if (this.displayMinimap || this.displayMiniAxes) {
672
680
  renderer.setScissorTest(true);
673
681
  renderer.getSize(_markerTarget);
674
682
  if (this.minimapScissor.updateRequired) {
@@ -691,9 +699,13 @@ exports.Scene = function (containerIn, rendererIn) {
691
699
  this.minimapScissor.width,
692
700
  this.minimapScissor.height);
693
701
  minimap.updateCamera();
694
- scene.add(minimap.mask);
695
- renderer.render(scene, minimap.camera);
696
- scene.remove(minimap.mask);
702
+ if (this.displayMiniAxes) {
703
+ renderer.render(miniAxesScene, minimap.camera);
704
+ } else {
705
+ scene.add(minimap.mask);
706
+ renderer.render(scene, minimap.camera);
707
+ scene.remove(minimap.mask);
708
+ }
697
709
  renderer.setScissorTest(false);
698
710
  renderer.setViewport(0, 0, _markerTarget.x, _markerTarget.y);
699
711
  }
@@ -799,8 +811,7 @@ exports.Scene = function (containerIn, rendererIn) {
799
811
  */
800
812
  this.alignBoundingBoxToCameraView = (boundingBox, transitionTime) => {
801
813
  if (boundingBox) {
802
- const center = new THREE.Vector3();
803
- boundingBox.getCenter(center);
814
+ boundingBox.getCenter(_v3);
804
815
  const viewport = this.getZincCameraControls().getCurrentViewport();
805
816
  const target = new THREE.Vector3(viewport.targetPosition[0],
806
817
  viewport.targetPosition[1], viewport.targetPosition[2]);
@@ -867,10 +878,9 @@ exports.Scene = function (containerIn, rendererIn) {
867
878
  */
868
879
  this.setCameraTargetToObject = zincObject => {
869
880
  if (this.objectIsInScene(zincObject)) {
870
- const center = new THREE.Vector3();
871
881
  const boundingBox = zincObject.getBoundingBox();
872
882
  const viewport = this.getZincCameraControls().getCurrentViewport();
873
- boundingBox.getCenter(center);
883
+ boundingBox.getCenter(_v3);
874
884
  const target = new THREE.Vector3(viewport.targetPosition[0],
875
885
  viewport.targetPosition[1], viewport.targetPosition[2]);
876
886
  const eyePosition = new THREE.Vector3(viewport.eyePosition[0],
@@ -1274,7 +1284,8 @@ exports.Scene = function (containerIn, rendererIn) {
1274
1284
  region = rootRegion.createChildFromPath(regionPath);
1275
1285
  }
1276
1286
  const box = boundingBox ? boundingBox : this.getBoundingBox();
1277
- const dim = new THREE.Vector3().subVectors(box.max, box.min);
1287
+ _v3.set(0.0, 0.0, 0.0);
1288
+ const dim = _v3.subVectors(box.max, box.min);
1278
1289
  const boxGeo = new THREE.BoxGeometry(dim.x, dim.y, dim.z);
1279
1290
  const primitive = region.createGeometryFromThreeJSGeometry(
1280
1291
  group, boxGeo, colour, opacity, visibility, 10000);
@@ -1296,7 +1307,8 @@ exports.Scene = function (containerIn, rendererIn) {
1296
1307
  region = rootRegion.createChildFromPath(regionPath);
1297
1308
  }
1298
1309
  const box = boundingBox ? boundingBox : this.getBoundingBox();
1299
- const dim = new THREE.Vector3().subVectors(box.max, box.min);
1310
+ _v3.set(0.0, 0.0, 0.0);
1311
+ const dim = _v3.subVectors(box.max, box.min);
1300
1312
  const directions = ["x", "y", "z"];
1301
1313
  const primitives = [];
1302
1314
  let index = 0;
@@ -1350,6 +1362,99 @@ exports.Scene = function (containerIn, rendererIn) {
1350
1362
  }
1351
1363
  this.forcePickableObjectsUpdate = true;
1352
1364
  }
1353
- }
1354
1365
 
1366
+ /*
1367
+ * Destory static axis display object
1368
+ */
1369
+ this.destroyAxisDisplay = () => {
1370
+ this.displayMiniAxes = false;
1371
+ if (axisDisplay.main) {
1372
+ this.enableAxisDisplay(false, false);
1373
+ axisDisplay.main.forEach(axis => {
1374
+ if (axis.dispose) {
1375
+ axis.dispose();
1376
+ }
1377
+ });
1378
+ }
1379
+ if (axisDisplay.mini) {
1380
+ this.enableAxisDisplay(false, true);
1381
+ axisDisplay.mini.forEach(axis => {
1382
+ if (axis.dispose) {
1383
+ axis.dispose();
1384
+ }
1385
+ });
1386
+ }
1387
+ axisDisplay = {
1388
+ main: [],
1389
+ mini: [],
1390
+ };
1391
+ }
1392
+
1393
+ /*
1394
+ * Create static axis display object
1395
+ */
1396
+ this.createAxisDisplay = (fitBoundingBox = false) => {
1397
+ this.destroyAxisDisplay();
1398
+ const XYZ = [
1399
+ {
1400
+ name: "x",
1401
+ dir: new THREE.Vector3(1, 0, 0),
1402
+ colour: "red",
1403
+ hex: 0xFF5555
1404
+ },
1405
+ {
1406
+ name: "y",
1407
+ dir: new THREE.Vector3(0, 1, 0),
1408
+ colour: "green",
1409
+ hex: 0x55FF55
1410
+ },
1411
+ {
1412
+ name: "z",
1413
+ dir: new THREE.Vector3(0, 0, 1),
1414
+ colour: "blue",
1415
+ hex: 0x5555FF
1416
+ }
1417
+ ];
1418
+ const boundingBox = this.getBoundingBox();
1419
+ const size = boundingBox.min.distanceTo(boundingBox.max);
1420
+ let origin = new THREE.Vector3(0, 0, 0);
1421
+ if (fitBoundingBox) {
1422
+ origin.copy(boundingBox.min);
1423
+ }
1424
+ XYZ.forEach((xyzObj) => {
1425
+ const arrowHelper = new THREE.ArrowHelper(xyzObj.dir, origin, size, xyzObj.hex);
1426
+ axisDisplay.main.push(arrowHelper);
1427
+ const miniArrowHelper = new THREE.ArrowHelper(xyzObj.dir, boundingBox.getCenter(_v3), size / 2, xyzObj.hex);
1428
+ axisDisplay.mini.push(miniArrowHelper);
1429
+
1430
+ /*
1431
+ const miniLabel = createNewSpriteText(xyzObj.name, 0.1, xyzObj.colour, "Asap", 120, 400);
1432
+ const miniPosition = xyzObj.dir.clone().multiplyScalar(size/2).add(_v3[xyzObj.name]);
1433
+ miniLabel.position.set(miniPosition.x, miniPosition.y, miniPosition.z);
1434
+ axisDisplay.mini.push(miniLabel);
1435
+ */
1436
+
1437
+ const axesLabel = createNewSpriteText(xyzObj.name, 0.036, xyzObj.colour, "Asap", 120, 700);
1438
+ const position = xyzObj.dir.clone().multiplyScalar(size).add(origin);
1439
+ axesLabel.position.set(position.x, position.y, position.z);
1440
+ axisDisplay.main.push(axesLabel);
1441
+ })
1442
+ }
1355
1443
 
1444
+ /*
1445
+ * Enable static axis display, createAxisDisplay must be called
1446
+ * before the axis can be display.
1447
+ */
1448
+ this.enableAxisDisplay = (enable, miniaxes = false) => {
1449
+ if (miniaxes && axisDisplay?.mini?.length) {
1450
+ this.displayMiniAxes = enable;
1451
+ axisDisplay.mini.forEach(axis => {
1452
+ enable ? miniAxesScene.add(axis) : miniAxesScene.remove(axis);
1453
+ });
1454
+ } else if (!miniaxes && axisDisplay.main) {
1455
+ axisDisplay.main.forEach(axis => {
1456
+ enable ? scene.add(axis) : scene.remove(axis);
1457
+ });
1458
+ }
1459
+ }
1460
+ }
@@ -78,9 +78,8 @@ const TextureArray = function () {
78
78
  if (options) {
79
79
  if (options.vs && options.fs) {
80
80
  let transparent = true;
81
- if ("transparent" in options) {
81
+ if (options.transparent)
82
82
  transparent = options.transparent;
83
- }
84
83
  let side = THREE.FrontSide;
85
84
  if (options.side)
86
85
  side = options.side;