zincjs 1.8.5 → 1.9.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.8.5",
3
+ "version": "1.9.0",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
package/src/controls.js CHANGED
@@ -1508,6 +1508,7 @@ const RayCaster = function (sceneIn, hostSceneIn, callbackFunctionIn, hoverCallb
1508
1508
  let timeDiff = 0;
1509
1509
  let pickedObjects = new Array();
1510
1510
  let lastPosition = { zincCamera: undefined, x: -1 ,y: -1};
1511
+ let pickableObjects = undefined;
1511
1512
 
1512
1513
  this.enable = () => {
1513
1514
  enable = true;
@@ -1522,18 +1523,31 @@ const RayCaster = function (sceneIn, hostSceneIn, callbackFunctionIn, hoverCallb
1522
1523
  const threejsScene = scene.getThreeJSScene();
1523
1524
  renderer.render(threejsScene, zincCamera.cameraObject);
1524
1525
  }
1525
- let objects = scene.getPickableThreeJSObjects();
1526
+ let objects = pickableObjects ? pickableObjects : scene.getPickableThreeJSObjects();
1526
1527
  //Reset pickedObjects array
1527
1528
  pickedObjects.length = 0;
1528
1529
  return raycaster.intersectObjects( objects, true, pickedObjects );
1529
1530
  }
1530
1531
 
1532
+ this.setPickableObjects = (zincObjects) => {
1533
+ if (zincObjects === undefined) {
1534
+ pickableObjects = undefined;
1535
+ } else {
1536
+ pickableObjects = [];
1537
+ zincObjects.forEach(zincObject => {
1538
+ if (zincObject.getGroup() && zincObject.getGroup().visible) {
1539
+ pickableObjects.push(zincObject.getGroup());
1540
+ }
1541
+ });
1542
+ }
1543
+ }
1544
+
1531
1545
  this.getIntersectsObjectWithOrigin = (zincCamera, origin, direction) => {
1532
1546
  raycaster.set(origin, direction);
1533
1547
  return this.getIntersectsObject(zincCamera);
1534
1548
  }
1535
1549
 
1536
- const getIntersectsObjectWithCamera = (zincCamera, x, y) => {
1550
+ this.getIntersectsObjectWithCamera = (zincCamera, x, y) => {
1537
1551
  zincCamera.getNDCFromDocumentCoords(x, y, mouse);
1538
1552
  raycaster.setFromCamera(mouse, zincCamera.cameraObject);
1539
1553
  return this.getIntersectsObject(zincCamera);
@@ -1541,7 +1555,7 @@ const RayCaster = function (sceneIn, hostSceneIn, callbackFunctionIn, hoverCallb
1541
1555
 
1542
1556
  this.pick = (zincCamera, x, y) => {
1543
1557
  if (enabled && renderer && scene && zincCamera && callbackFunction) {
1544
- getIntersectsObjectWithCamera(zincCamera, x, y);
1558
+ this.getIntersectsObjectWithCamera(zincCamera, x, y);
1545
1559
  const length = pickedObjects.length;
1546
1560
  for (let i = 0; i < length; i++) {
1547
1561
  let zincObject = pickedObjects[i].object ? pickedObjects[i].object.userData : undefined;
@@ -1557,7 +1571,7 @@ const RayCaster = function (sceneIn, hostSceneIn, callbackFunctionIn, hoverCallb
1557
1571
 
1558
1572
  let hovered = (zincCamera, x, y) => {
1559
1573
  if (enabled && renderer && scene && zincCamera && hoverCallbackFunction) {
1560
- getIntersectsObjectWithCamera(zincCamera, x, y);
1574
+ this.getIntersectsObjectWithCamera(zincCamera, x, y);
1561
1575
  lastHoveredDate.setTime(Date.now());
1562
1576
  if (pickedObjects.length === 0) {
1563
1577
  //skip hovered callback if the previous one is empty