@abi-software/scaffoldvuer 0.1.53-beta.1 → 0.1.53-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.
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/scaffoldvuer",
3
- "version": "0.1.53-beta.1",
3
+ "version": "0.1.53-beta.2",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -17192,9 +17192,9 @@
17192
17192
  }
17193
17193
  },
17194
17194
  "zincjs": {
17195
- "version": "1.0.3",
17196
- "resolved": "https://registry.npmjs.org/zincjs/-/zincjs-1.0.3.tgz",
17197
- "integrity": "sha512-S4ajnPitOO8VD6i9MpLXW4s9p1SBj1hQSxTnIbT6GwHUSDhGXCjkNPSqXhX4Ki/q6/48mbz2hLdDBBJY7qkkxA==",
17195
+ "version": "1.0.4",
17196
+ "resolved": "https://registry.npmjs.org/zincjs/-/zincjs-1.0.4.tgz",
17197
+ "integrity": "sha512-dJKwUbJSSH3UbBUkG3/5+w+JcPfhp8/tWzZGgPRTkYaFHoO8h2I9oPVqxKMO4h4AL8blbR6ux4zyMtZAMLznUw==",
17198
17198
  "requires": {
17199
17199
  "css-element-queries": "^1.2.2",
17200
17200
  "lodash": "^4.17.19",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/scaffoldvuer",
3
- "version": "0.1.53-beta.1",
3
+ "version": "0.1.53-beta.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "vue": "^2.6.10",
34
34
  "vue-drag-resize": "^1.3.2",
35
35
  "vue-router": "^3.5.1",
36
- "zincjs": "^1.0.3"
36
+ "zincjs": "^1.0.4"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@vue/cli-plugin-babel": "^4.0.0",
package/src/App.vue CHANGED
@@ -21,6 +21,7 @@
21
21
  :render="render"
22
22
  :region="region"
23
23
  :view-u-r-l="viewURL"
24
+ :format="format"
24
25
  @on-ready="onReady"
25
26
  @scaffold-selected="onSelected"
26
27
  @scaffold-navigated="onNavigated"
@@ -288,6 +289,8 @@ export default {
288
289
  rendererInfo: undefined,
289
290
  zoom: 1,
290
291
  pos: [0, 0],
292
+ format: "metadata",
293
+ sceneSettings: [],
291
294
  };
292
295
  },
293
296
  watch: {
@@ -307,7 +310,6 @@ export default {
307
310
  }
308
311
  },
309
312
  mounted: function() {
310
- this._sceneSettings = [];
311
313
  this.selectedCoordinates = this.$refs.scaffold.getDynamicSelectedCoordinates();
312
314
  this.rendererInfo = this.$refs.scaffold.getRendererInfo();
313
315
  },
@@ -339,11 +341,11 @@ export default {
339
341
  },
340
342
  saveSettings: function() {
341
343
  const state = this.$refs.scaffold.getState();
342
- this._sceneSettings.push(this.$refs.scaffold.getState());
344
+ this.sceneSettings.push(this.$refs.scaffold.getState());
343
345
  },
344
346
  restoreSettings: function() {
345
- if (this._sceneSettings.length > 0)
346
- this.$refs.scaffold.setState(this._sceneSettings.pop());
347
+ if (this.sceneSettings.length > 0)
348
+ this.$refs.scaffold.setState(this.sceneSettings.pop());
347
349
  },
348
350
  viewModelClicked: function(location) {
349
351
  this.input = location;
@@ -381,8 +383,10 @@ export default {
381
383
  this.pos[0] = data.target[0];
382
384
  this.pos[1] = data.target[1];
383
385
  },
384
- onFilesDrop: function(metaURL) {
385
- this.input = metaURL;
386
+ onFilesDrop: function(payload) {
387
+ if (payload.format == "gltf") this.format = "gltf";
388
+ else this.format = "metadata";
389
+ this.input = payload.url;
386
390
  },
387
391
  parseInput: function() {
388
392
  if (this.$route.query.url !== this.input) {
@@ -404,6 +408,11 @@ export default {
404
408
  this.url =
405
409
  "https://mapcore-bucket1.s3-us-west-2.amazonaws.com/others/29_Jan_2020/heartICN_metadata.json";
406
410
  }
411
+ if (this.url.includes(".gltf") || this.url.includes(".glb")) {
412
+ this.format = "gltf";
413
+ } else if (this.url.includes(".json")) {
414
+ this.format = "metadata";
415
+ }
407
416
  this.input = this.url;
408
417
  if (query.region) {
409
418
  this.region = query.region;
@@ -33,7 +33,7 @@ export default {
33
33
  });
34
34
  },
35
35
  methods: {
36
- createObjectURLs: function (text, list) {
36
+ createMetadataObjectURLs: function (text, list) {
37
37
  let content = text;
38
38
  for (const [key, file] of Object.entries(list)) {
39
39
  if (content.includes(key)) {
@@ -45,7 +45,14 @@ export default {
45
45
  let blob = new Blob([content], { type: "application/json" });
46
46
  const metaURL = URL.createObjectURL(blob);
47
47
  this.objectURLs.push(metaURL);
48
- this.$emit("files-drop", metaURL);
48
+ this.$emit("files-drop", { url: metaURL, format : "metadata" } );
49
+ },
50
+ createGLTFURL: function (content, binary) {
51
+ let type = binary ? 'model/gltf+binary' : 'model/gltf+json';
52
+ let blob = new Blob([content], { type });
53
+ const gltfURL = URL.createObjectURL(blob);
54
+ this.objectURLs.push(gltfURL);
55
+ this.$emit("files-drop", { url: gltfURL, format : "gltf" });
49
56
  },
50
57
  revokeURLs: function () {
51
58
  this.objectURLs.forEach(objectURL => URL.revokeObjectURL(objectURL));
@@ -55,6 +62,8 @@ export default {
55
62
  const dataMaps = {};
56
63
  let list = {};
57
64
  let metadata = undefined;
65
+ let gltf = undefined;
66
+ let binary = false;
58
67
  const flatarray = Array.from(fileMap);
59
68
  let rootPath = "";
60
69
  for (let i = 0; i < flatarray.length; i++) {
@@ -63,6 +72,16 @@ export default {
63
72
  metadata = { rootPath, file: flatarray[i][1] };
64
73
  break;
65
74
  }
75
+ if (flatarray[i][1].name.includes(".glb")) {
76
+ gltf = { rootPath, file: flatarray[i][1] };
77
+ binary = true;
78
+ break;
79
+ }
80
+ if (flatarray[i][1].name.includes(".gltf")) {
81
+ gltf = { rootPath, file: flatarray[i][1] };
82
+ binary = false;
83
+ break;
84
+ }
66
85
  }
67
86
  if (metadata) {
68
87
  flatarray.forEach(([filePath, file]) => {
@@ -74,9 +93,12 @@ export default {
74
93
  const metaFileURL = URL.createObjectURL(metadata.file);
75
94
  fetch(metaFileURL)
76
95
  .then((response) => response.text())
77
- .then((text) => this.createObjectURLs(text, list));
96
+ .then((text) => this.createMetadataObjectURLs(text, list));
78
97
  URL.revokeObjectURL(metaFileURL);
79
98
  }
99
+ if (gltf) {
100
+ this.createGLTFURL(gltf.file, binary);
101
+ }
80
102
  },
81
103
  },
82
104
  };
@@ -363,6 +363,13 @@ export default {
363
363
  type: Boolean,
364
364
  default: false
365
365
  },
366
+ /**
367
+ * Format of the input URL
368
+ */
369
+ format: {
370
+ type: String,
371
+ default: "metadata"
372
+ },
366
373
  /**
367
374
  * Settings for minimap position, size and alignment.
368
375
  */
@@ -473,10 +480,17 @@ export default {
473
480
  visible: false,
474
481
  x: 200,
475
482
  y: 200
476
- }
483
+ },
484
+ fileFormat: "metadata",
477
485
  };
478
486
  },
479
487
  watch: {
488
+ format: {
489
+ handler: function(value) {
490
+ this.fileFormat = value;
491
+ },
492
+ immediate: true
493
+ },
480
494
  url: {
481
495
  handler: function(newValue) {
482
496
  if (this.state === undefined || this.state.url === undefined)
@@ -989,9 +1003,10 @@ export default {
989
1003
  */
990
1004
  getState: function() {
991
1005
  let state = {
1006
+ format: this.fileFormat,
992
1007
  url: this._currentURL,
993
1008
  viewport: undefined,
994
- visibility: undefined
1009
+ visibility: undefined,
995
1010
  };
996
1011
  if (this.$refs.treeControl)
997
1012
  state.visibility = this.$refs.treeControl.getState();
@@ -1011,6 +1026,7 @@ export default {
1011
1026
  if (state) {
1012
1027
  if (state.url && state.url !== this._currentURL) {
1013
1028
  this.setURLAndState(state.url, {
1029
+ fileFormat: state.fileFormat,
1014
1030
  viewport: state.viewport,
1015
1031
  visibility: state.visibility
1016
1032
  });
@@ -1047,6 +1063,7 @@ export default {
1047
1063
  */
1048
1064
  setURLAndState: function(newValue, state) {
1049
1065
  if (newValue != this._currentURL) {
1066
+ if (state && state.format) this.fileFormat = state.format;
1050
1067
  let viewport = state && state.viewport ? state.viewport : undefined;
1051
1068
  let visibility =
1052
1069
  state && state.visibility ? state.visibility : undefined;
@@ -1063,13 +1080,18 @@ export default {
1063
1080
  visibility: visibility
1064
1081
  })
1065
1082
  );
1066
- this.$module.loadOrgansFromURL(
1067
- newValue,
1068
- undefined,
1069
- undefined,
1070
- "scene",
1071
- undefined
1072
- );
1083
+ if (this.fileFormat === "gltf") {
1084
+ this.$module.loadGLTFFromURL(newValue, "scene", true);
1085
+ } else {
1086
+ this.$module.loadOrgansFromURL(
1087
+ newValue,
1088
+ undefined,
1089
+ undefined,
1090
+ "scene",
1091
+ undefined,
1092
+ true
1093
+ );
1094
+ }
1073
1095
  this.$module.scene.displayMarkers = this.displayMarkers;
1074
1096
  this.$module.scene.displayMinimap = this.displayMinimap;
1075
1097
  this.updateMinimapScissor();
@@ -1086,9 +1108,8 @@ export default {
1086
1108
  },
1087
1109
  /**
1088
1110
  * Callback when drawer is toggled.
1089
- *
1090
1111
  */
1091
- drawerToggled: function(flag) {
1112
+ drawerToggled: function(flag) {pppp
1092
1113
  this.drawerOpen = flag;
1093
1114
  this.adjustLayout();
1094
1115
  },
@@ -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
  }