@abi-software/scaffoldvuer 0.1.53 → 0.1.54-beta.2

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.
@@ -1,8 +1,9 @@
1
1
  const EVENT_TYPE = { ALL: 0, SELECTED: 1, HIGHLIGHTED: 2, MOVE: 3 };
2
2
 
3
- const SelectionEvent = function(eventTypeIn, identifiersIn) {
3
+ const SelectionEvent = function(eventTypeIn, identifiersIn, zincObjects) {
4
4
  this.eventType = eventTypeIn;
5
5
  this.identifiers = identifiersIn;
6
+ this.zincObjects = zincObjects;
6
7
  }
7
8
 
8
9
  const returnFullID = function(sourceId) {
@@ -23,12 +24,12 @@ const Subscription = function(subscriberIn, callbackIn, eventType) {
23
24
  return eventType;
24
25
  }
25
26
 
26
- this.notify = function(source, eventType, ids) {
27
+ this.notify = function(source, eventType, ids, zincObjects) {
27
28
  if (source !== subscriber && (_this.targetEventType === EVENT_TYPE.ALL ||
28
29
  _this.targetEventType === eventType)) {
29
30
  //should support different type of id e.g lyph, name, fmas...
30
31
  //need a function that finds all relavant ids
31
- const event = new SelectionEvent(eventType, ids);
32
+ const event = new SelectionEvent(eventType, ids, zincObjects);
32
33
  callback(event);
33
34
  }
34
35
  }
@@ -37,9 +38,9 @@ const Subscription = function(subscriberIn, callbackIn, eventType) {
37
38
  exports.EventNotifier = function() {
38
39
  const subscriptions = [];
39
40
 
40
- this.publish = function(source, eventType, id) {
41
+ this.publish = function(source, eventType, id, zincObjects) {
41
42
  for (let i = 0; i < subscriptions.length;i++) {
42
- subscriptions[i].notify(source, eventType, id);
43
+ subscriptions[i].notify(source, eventType, id, zincObjects);
43
44
  }
44
45
  }
45
46
 
@@ -474,14 +474,15 @@ const OrgansSceneData = function() {
474
474
  _this.sceneData.currentName = name;
475
475
  }
476
476
 
477
- this.loadOrgansFromURL = function(url, speciesName, systemName, partName, viewURL) {
477
+ this.loadOrgansFromURL = function(url, speciesName, systemName, partName, viewURL, clearFirst) {
478
478
  if (_this.zincRenderer) {
479
479
  if (partName && (_this.sceneData.metaURL !== url)) {
480
480
  setSceneData(speciesName, systemName, partName, undefined);
481
481
  const name = _this.sceneData.currentName;
482
482
  let organScene = _this.zincRenderer.getSceneByName(name);
483
483
  if (organScene) {
484
- organScene.clearAll();
484
+ if (clearFirst)
485
+ organScene.clearAll();
485
486
  } else {
486
487
  organScene = _this.zincRenderer.createScene(name);
487
488
  }
@@ -507,6 +508,36 @@ const OrgansSceneData = function() {
507
508
  }
508
509
  }
509
510
  }
511
+
512
+ this.loadGLTFFromURL = function(url, partName, clearFirst) {
513
+ if (_this.zincRenderer) {
514
+ if (partName && (_this.sceneData.metaURL !== url)) {
515
+ setSceneData(undefined, undefined, partName, undefined);
516
+ const name = _this.sceneData.currentName;
517
+ let organScene = _this.zincRenderer.getSceneByName(name);
518
+ if (organScene) {
519
+ if (clearFirst)
520
+ organScene.clearAll();
521
+ } else {
522
+ organScene = _this.zincRenderer.createScene(name);
523
+ }
524
+ for (let i = 0; i < sceneChangedCallbacks.length;i++) {
525
+ sceneChangedCallbacks[i](_this.sceneData);
526
+ }
527
+ _this.sceneData.viewURL = undefined;
528
+ _this.sceneData.metaURL = url;
529
+ organScene.loadGLTF(url, _addOrganPartCallback(undefined, partName, false),
530
+ downloadCompletedCallback());
531
+ _this.scene = organScene;
532
+ _this.zincRenderer.setCurrentScene(organScene);
533
+ _this.graphicsHighlight.reset();
534
+ const zincCameraControl = organScene.getZincCameraControls();
535
+ zincCameraControl.enableRaycaster(organScene, _pickingCallback(), _hoverCallback());
536
+ zincCameraControl.setMouseButtonAction("AUXILIARY", "ZOOM");
537
+ zincCameraControl.setMouseButtonAction("SECONDARY", "PAN");
538
+ }
539
+ }
540
+ }
510
541
 
511
542
  this.alignCameraWithSelectedObject = function(transitionTime) {
512
543
  const objects = _this.graphicsHighlight.getSelected();
@@ -536,7 +567,7 @@ const OrgansSceneData = function() {
536
567
  _this.setName(settings.name);
537
568
  if (settings.metaURL !== undefined && settings.metaURL != "") {
538
569
  _this.loadOrgansFromURL(settings.metaURL, settings.species,
539
- settings.system, settings.part, settings.viewURL);
570
+ settings.system, settings.part, settings.viewURL, true);
540
571
  } else {
541
572
  _this.loadOrgans(settings.species, settings.system, settings.part);
542
573
  }