zincjs 1.7.0 → 1.8.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.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "ZincJS (Web-based-Zinc-Visualisation)",
5
5
  "main": "build/zinc.js",
6
6
  "directories": {
package/src/region.js CHANGED
@@ -321,7 +321,11 @@ let Region = function (parentIn, sceneIn) {
321
321
  if (zincObject === zincObjects[i]) {
322
322
  group.remove(zincObject.getGroup());
323
323
  zincObjects.splice(i, 1);
324
+ if (scene) {
325
+ scene.triggerObjectRemovedCallback(zincObject);
326
+ }
324
327
  zincObject.dispose();
328
+ this.pickableUpdateRequired = true;
325
329
  return;
326
330
  }
327
331
  }
package/src/scene.js CHANGED
@@ -39,6 +39,8 @@ exports.Scene = function (containerIn, rendererIn) {
39
39
  let minimap = undefined;
40
40
  let zincObjectAddedCallbacks = {};
41
41
  let zincObjectAddedCallbacks_id = 0;
42
+ let zincObjectRemovedCallbacks = {};
43
+ let zincObjectRemovedCallbacks_id = 0;
42
44
  const scene = new THREE.Scene();
43
45
  const rootRegion = new (require('./region').Region)(undefined, this);
44
46
  scene.add(rootRegion.getGroup());
@@ -968,6 +970,7 @@ exports.Scene = function (containerIn, rendererIn) {
968
970
  markerCluster.clear();
969
971
  rootRegion.clear(true);
970
972
  this.clearZincObjectAddedCallbacks();
973
+ this.clearZincObjectRemovedCallbacks();
971
974
  sceneLoader.toBeDwonloaded = 0;
972
975
  if (zincCameraControls) {
973
976
  zincCameraControls.calculateMaxAllowedDistance(this);
@@ -1126,6 +1129,18 @@ exports.Scene = function (containerIn, rendererIn) {
1126
1129
  zincObjectAddedCallbacks[zincObjectAddedCallbacks_id] = callbackFunction;
1127
1130
  return zincObjectAddedCallbacks_id;
1128
1131
  }
1132
+
1133
+ /**
1134
+ * Add a callback function which will be called everytime zinc object is removed.
1135
+ * @param {Function} callbackFunction - callbackFunction to be added.
1136
+ *
1137
+ * @return {Number}
1138
+ */
1139
+ this.addZincObjectRemovedCallbacks = callbackFunction => {
1140
+ zincObjectRemovedCallbacks_id = zincObjectRemovedCallbacks_id + 1;
1141
+ zincObjectRemovedCallbacks[zincObjectRemovedCallbacks_id] = callbackFunction;
1142
+ return zincObjectRemovedCallbacks_id;
1143
+ }
1129
1144
 
1130
1145
  /**
1131
1146
  * Remove a callback function that is previously added to the scene.
@@ -1137,6 +1152,16 @@ exports.Scene = function (containerIn, rendererIn) {
1137
1152
  }
1138
1153
  }
1139
1154
 
1155
+ /**
1156
+ * Remove a callback function that is previously added to the scene.
1157
+ * @param {Number} id - identifier of the previously added callback function.
1158
+ */
1159
+ this.removeZincObjectRemovedCallbacks = id => {
1160
+ if (id in zincObjectRemovedCallbacks_id) {
1161
+ delete zincObjectRemovedCallbacks[id];
1162
+ }
1163
+ }
1164
+
1140
1165
  /**
1141
1166
  * Clear all zinc object callback function
1142
1167
  */
@@ -1145,6 +1170,14 @@ exports.Scene = function (containerIn, rendererIn) {
1145
1170
  zincObjectAddedCallbacks_id = 0;
1146
1171
  }
1147
1172
 
1173
+ /**
1174
+ * Clear all zinc object callback function
1175
+ */
1176
+ this.clearZincObjectRemovedCallbacks = () => {
1177
+ zincObjectRemovedCallbacks = {};
1178
+ zincObjectRemovedCallbacks_id = 0;
1179
+ }
1180
+
1148
1181
  /**
1149
1182
  * Used to trigger zinc object added callback
1150
1183
  */
@@ -1156,6 +1189,17 @@ exports.Scene = function (containerIn, rendererIn) {
1156
1189
  }
1157
1190
  }
1158
1191
 
1192
+ /**
1193
+ * Used to trigger zinc object removed callback
1194
+ */
1195
+ this.triggerObjectRemovedCallback= (zincObject) => {
1196
+ for (let key in zincObjectRemovedCallbacks) {
1197
+ if (zincObjectRemovedCallbacks.hasOwnProperty(key)) {
1198
+ zincObjectRemovedCallbacks[key](zincObject);
1199
+ }
1200
+ }
1201
+ }
1202
+
1159
1203
  /*
1160
1204
  * Add temporary points to the scene which can be removed
1161
1205
  * with clearTemporaryPrimitives method.
package/src/zinc.js CHANGED
@@ -18,6 +18,7 @@ const Zinc = function() {
18
18
  this.Glyph = require('./primitives/glyph').Glyph;
19
19
  this.Glyphset = require('./primitives/glyphset').Glyphset;
20
20
  this.Pointset = require('./primitives/pointset').Pointset;
21
+ this.Label = require('./primitives/label').Label;
21
22
  this.Lines = require('./primitives/lines').Lines;
22
23
  this.TextureArray = require('./texture/textureArray').TextureArray;
23
24
  this.TextureSlides = require('./primitives/textureSlides').TextureSlides;