@avs/go 0.12.71739 → 0.13.71745

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": "@avs/go",
3
- "version": "0.12.71739",
3
+ "version": "0.13.71745",
4
4
  "description": "AVS Go",
5
5
  "keywords": [
6
6
  "polymer",
@@ -74,7 +74,39 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
74
74
  position:relative;
75
75
  width:100%;
76
76
  height:100%;
77
- }
77
+ }
78
+ #animationControls {
79
+ display: none;
80
+ position:absolute;
81
+ top: 8px;
82
+ left: 8px;
83
+ padding: 8px;
84
+ background-color: rgba(128, 128, 128, 0.8);
85
+ color: white;
86
+ font-size: 10pt;
87
+ border-radius: 8px;
88
+ }
89
+ button {
90
+ padding: 4px 8px;
91
+ border-radius: 4px;
92
+ margin-top: 4px;
93
+ }
94
+ button:not([disabled]) {
95
+ cursor: pointer;
96
+ }
97
+ #animationControlsTitle {
98
+ font-weight: bold;
99
+ margin-bottom: 8px;
100
+ }
101
+ #animationDelay:not([disabled]) {
102
+ cursor: pointer;
103
+ }
104
+ #animationPlay {
105
+ margin-top: 12px;
106
+ }
107
+ #animationReset {
108
+ margin-top: 12px;
109
+ }
78
110
  #sceneImage {
79
111
  width:100%;
80
112
  height:100%;
@@ -140,6 +172,28 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
140
172
  </style>
141
173
  <div id="container">
142
174
  <div id="dataVizDiv"></div>
175
+ <div id="animationControls">
176
+ <div id="animationControlsTitle">Animation Controls</div>
177
+ <div id="animationDelayLabel">Snapshot Delay (0s)</div>
178
+ <div>
179
+ <input type="range" disabled min="0" max="5" value="0" class="slider" id="animationDelay">
180
+ </div>
181
+ <div>
182
+ <button type="button" id="animationSnapshot">Take Snapshot (0)</button>
183
+ </div>
184
+ <div>
185
+ <button type="button" disabled id="animationPlay">Play Animation</button>
186
+ </div>
187
+ <div>
188
+ <button type="button" disabled id="animationShare">Share Animation</button>
189
+ </div>
190
+ <div>
191
+ <button type="button" id="animationReset">Reset Transform</button>
192
+ </div>
193
+ <div>
194
+ <button type="button" disabled id="animationClear">Clear Animation</button>
195
+ </div>
196
+ </div>
143
197
  <div id="zoomOverlay"></div>
144
198
  <div id="spinnerDiv">
145
199
  <div id="spinner"></div>
@@ -426,6 +480,13 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
426
480
  type: Number,
427
481
  observer: "_transformValueChanged"
428
482
  },
483
+ /**
484
+ * Transform animation encoded string.
485
+ */
486
+ transformAnimation: {
487
+ type: String,
488
+ observer: "_transformAnimationValueChanged"
489
+ },
429
490
  /**
430
491
  * Enable the zoom rectangle interactor. Only available when `renderer` is `THREEJS`
431
492
  *
@@ -476,19 +537,26 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
476
537
  observer: "_panMaximumZoomLevelChanged",
477
538
  value: 1000
478
539
  },
479
- /**
480
- * Show animated glyphs. Only available when `renderer` is `THREEJS`
481
- */
482
- animatedGlyphsVisible: {
540
+ /**
541
+ * Show animated glyphs. Only available when `renderer` is `THREEJS`
542
+ */
543
+ animatedGlyphsVisible: {
483
544
  type: Boolean,
484
- observer: "_animatedGlyphsVisibleChanged"
545
+ observer: "_animatedGlyphsVisibleChanged"
485
546
  },
486
- /**
487
- * Enable animated glyphs. Only available when `renderer` is `THREEJS`
488
- */
489
- animatedGlyphsEnable: {
547
+ /**
548
+ * Enable animated glyphs. Only available when `renderer` is `THREEJS`
549
+ */
550
+ animatedGlyphsEnable: {
490
551
  type: Boolean,
491
- observer: "_animatedGlyphsEnableChanged"
552
+ observer: "_animatedGlyphsEnableChanged"
553
+ },
554
+ /**
555
+ * Enable animation controls overlay. Only available when `renderer` is `THREEJS`
556
+ */
557
+ animationControlsEnable: {
558
+ type: Boolean,
559
+ observer: "_animationControlsEnableChanged"
492
560
  }
493
561
  }
494
562
  }
@@ -691,22 +759,7 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
691
759
  this._addDataSourceProperties(model);
692
760
 
693
761
  if (this.renderer === 'THREEJS') {
694
- this._addStreamProperties(rendererProperties);
695
-
696
- var styleMap = {};
697
- this._applyCustomCssProperties(styleMap, style,
698
- {
699
- "scene": "--avs-scene-animations",
700
- "sceneTitle": "--avs-scene-title-animations",
701
- "chart": "--avs-chart-animations",
702
- "chartTitle": "--avs-chart-title-animations",
703
- "axis": "--avs-axis-animations",
704
- "legend": "--avs-legend-animations",
705
- "legendTitle": "--avs-legend-title-animations",
706
- "glyph": "--avs-glyph-animations",
707
- "transform": "--avs-transform-animation"
708
- } );
709
- this.animator.setStyleMap(styleMap);
762
+ this._addStreamProperties(rendererProperties);
710
763
  }
711
764
 
712
765
  return model;
@@ -956,29 +1009,34 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
956
1009
  this._handleLoadComplete();
957
1010
  }
958
1011
  else if (json.threejs) {
959
- this.threeViewer.loadGeometryAsJson(json.threejs, this._handleLoadComplete.bind(this));
960
- }
961
- else if (json.chunkId) {
962
- this.threeViewer.loadGeometryAsEvents(json, this._handleLoadComplete.bind(this));
963
-
964
- if (json.moreChunks === true) {
965
- if (this.urlLoadJsonFile) {
966
- this.chunkFile++;
967
- const urlBase = this.url.substring(0, this.url.lastIndexOf('.')) || this.url;
968
- const ext = this.url.split('.').pop();
969
- this._httpRequest(urlBase + '-' + this.chunkFile + '.' + ext, this._handleHttpResponse.bind(this), undefined, this._handleHttpError.bind(this));
970
- }
971
- else {
972
- var model = this._assembleModel();
973
- if (model) {
974
- model.rendererProperties.streamProperties.chunkId = json.chunkId;
975
- this._httpRequest(this.url, this._handleHttpResponse.bind(this), undefined, this._handleHttpError.bind(this), model);
1012
+ if (json.threejs.chunkId) {
1013
+ this.threeViewer.loadGeometryAsEvents(json.threejs, this._handleLoadComplete.bind(this));
1014
+
1015
+ if (json.threejs.moreChunks === true) {
1016
+ if (this.urlLoadJsonFile) {
1017
+ // Load the next chunk file
1018
+ this.chunkFile++;
1019
+ const urlBase = this.url.substring(0, this.url.lastIndexOf('.')) || this.url;
1020
+ const ext = this.url.split('.').pop();
1021
+ this._httpRequest(urlBase + '-' + this.chunkFile + '.' + ext, this._handleHttpResponse.bind(this), undefined, this._handleHttpError.bind(this));
1022
+ }
1023
+ else {
1024
+ // Get the next chunk from the server
1025
+ var model = this._assembleModel();
1026
+ if (model) {
1027
+ model.rendererProperties.streamProperties.chunkId = json.threejs.chunkId;
1028
+ this._httpRequest(this.url, this._handleHttpResponse.bind(this), undefined, this._handleHttpError.bind(this), model);
1029
+ }
976
1030
  }
977
1031
  }
978
1032
  }
1033
+ else {
1034
+ this.threeViewer.loadGeometryAsJson(json.threejs, this._handleLoadComplete.bind(this));
1035
+ }
979
1036
  }
980
- else if (this.urlLoadJsonFile) {
981
- this.threeViewer.loadGeometryAsJson(json, this._handleLoadComplete.bind(this));
1037
+ else {
1038
+ console.log("ERROR: No image, SVG, or ThreeJS found in response.");
1039
+ this._handleLoadComplete();
982
1040
  }
983
1041
  }
984
1042
  }
@@ -1417,7 +1475,7 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
1417
1475
  afterNextRender(this, function() {
1418
1476
  if (this.initialized !== true) {
1419
1477
 
1420
- this._updateSize();
1478
+ this._updateSize();
1421
1479
  if (!this.manualUpdate) {
1422
1480
  this.updateViewer(true);
1423
1481
  }
@@ -1437,13 +1495,96 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
1437
1495
  }
1438
1496
  });
1439
1497
 
1440
- this._resetTimer();
1498
+ this.$.animationDelay.addEventListener('input', this._handleAnimationDelayChange.bind(this));
1499
+ this.$.animationSnapshot.addEventListener('click', this._handleAnimationSnapshot.bind(this));
1500
+ this.$.animationPlay.addEventListener('click', this.runAnimation.bind(this));
1501
+ this.$.animationShare.addEventListener('click', this._handleAnimationShare.bind(this));
1502
+ this.$.animationReset.addEventListener('click', this.resetTransform.bind(this));
1503
+ this.$.animationClear.addEventListener('click', this._handleAnimationClear.bind(this));
1504
+
1505
+ this.animationTime = 0;
1506
+ this.transformAnimationFrames ??= [];
1507
+ if (this.transformAnimationFrames.length > 0) {
1508
+ this.$.animationDelayLabel.innerHTML = "Snapshot Delay (2s)";
1509
+ this.$.animationDelay.value = 2;
1510
+ this.$.animationDelay.disabled = false;
1511
+ this.$.animationSnapshot.innerHTML = "Take Snapshot (" + this.transformAnimationFrames.length + ")";
1512
+ this.$.animationPlay.disabled = false;
1513
+ this.$.animationShare.disabled = false;
1514
+ this.$.animationClear.disabled = false;
1515
+ this.animationTime = this.transformAnimationFrames[this.transformAnimationFrames.length - 1].time / 1000;
1516
+ }
1517
+
1518
+ this._resetTimer();
1441
1519
 
1442
1520
  this.initialized = true;
1443
1521
  }
1444
1522
  });
1445
1523
  }
1446
1524
 
1525
+ _round2dp(n) {
1526
+ return Math.round((n + Number.EPSILON) * 100) / 100;
1527
+ }
1528
+
1529
+ _handleAnimationDelayChange() {
1530
+ const delay = this.$.animationDelay.value;
1531
+ this.$.animationDelayLabel.innerHTML = "Snapshot Delay (" + delay + "s)";
1532
+ }
1533
+
1534
+ _handleAnimationSnapshot() {
1535
+ const transform = this._getTransformComponents();
1536
+ const delay = Number(this.$.animationDelay.value);
1537
+ if (this.transformAnimationFrames.length > 0) {
1538
+ this.animationTime += delay;
1539
+ }
1540
+ const frame = {
1541
+ time: this.animationTime * 1000,
1542
+ scale: this._round2dp(transform.scale),
1543
+ position: [this._round2dp(transform.position[0]),
1544
+ this._round2dp(transform.position[1]),
1545
+ this._round2dp(transform.position[2])],
1546
+ rotation: [this._round2dp(transform.rotation[0]),
1547
+ this._round2dp(transform.rotation[1]),
1548
+ this._round2dp(transform.rotation[2]),
1549
+ transform.rotation[3]]
1550
+ };
1551
+ this.transformAnimationFrames.push(frame);
1552
+
1553
+ if (this.transformAnimationFrames.length == 1) {
1554
+ this.$.animationDelayLabel.innerHTML = "Snapshot Delay (2s)";
1555
+ this.$.animationDelay.value = 2;
1556
+ this.$.animationDelay.disabled = false;
1557
+ this.$.animationPlay.disabled = false;
1558
+ this.$.animationShare.disabled = false;
1559
+ this.$.animationClear.disabled = false;
1560
+ }
1561
+ this.$.animationSnapshot.innerHTML = "Take Snapshot (" + this.transformAnimationFrames.length + ")";
1562
+ }
1563
+
1564
+ _handleAnimationClear() {
1565
+ this.transformAnimationFrames.length = 0;
1566
+ this.$.animationDelayLabel.innerHTML = "Snapshot Delay (0s)";
1567
+ this.$.animationDelay.value = 0;
1568
+ this.$.animationDelay.disabled = true;
1569
+ this.$.animationSnapshot.innerHTML = "Take Snapshot (0)";
1570
+ this.$.animationPlay.disabled = true;
1571
+ this.$.animationShare.disabled = true;
1572
+ this.$.animationClear.disabled = true;
1573
+ this.animationTime = 0;
1574
+ }
1575
+
1576
+ _handleAnimationShare() {
1577
+ const json = JSON.stringify(this.transformAnimationFrames);
1578
+ const encoded = btoa(json);
1579
+
1580
+ /**
1581
+ * A transform animation share event occurred.
1582
+ * @event avs-transform-animation-share
1583
+ */
1584
+
1585
+ this.dispatchEvent(new CustomEvent('avs-transform-animation-share', { detail: encoded }));
1586
+ }
1587
+
1447
1588
  _updatePixelRatio(change) {
1448
1589
  const pr = window.devicePixelRatio;
1449
1590
  matchMedia( `(resolution: ${pr}dppx)` ).addEventListener('change', this._updatePixelRatio.bind(this, true), { once: true } );
@@ -1452,6 +1593,18 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
1452
1593
  }
1453
1594
  }
1454
1595
 
1596
+ /**
1597
+ * Change in 'animation-controls-enable' property.
1598
+ */
1599
+ _animationControlsEnableChanged(newValue, oldValue) {
1600
+ if (newValue) {
1601
+ this.$.animationControls.style.display = "block";
1602
+ }
1603
+ else {
1604
+ this.$.animationControls.style.display = "none";
1605
+ }
1606
+ }
1607
+
1455
1608
  /**
1456
1609
  * Change in 'hidden' property.
1457
1610
  */
@@ -1474,7 +1627,7 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
1474
1627
  if (this.threeViewer) {
1475
1628
  if (newValue) {
1476
1629
  if (this.transformInteractor === undefined) {
1477
- this.transformInteractor = new TransformInteractor( this );
1630
+ this.transformInteractor = new TransformInteractor( this.$.dataVizDiv );
1478
1631
  }
1479
1632
  this.threeViewer.addInteractor( this.transformInteractor );
1480
1633
 
@@ -1572,7 +1725,7 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
1572
1725
  }
1573
1726
  }
1574
1727
 
1575
- getTransformComponents() {
1728
+ _getTransformComponents() {
1576
1729
  var pos = new Vector3();
1577
1730
  var quat = new Quaternion();
1578
1731
  var scale = new Vector3();
@@ -1597,10 +1750,8 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
1597
1750
  }
1598
1751
 
1599
1752
  runAnimation() {
1600
-
1601
- var style = window.getComputedStyle(this, null);
1602
-
1603
1753
  if (this.renderer === 'THREEJS') {
1754
+ var style = window.getComputedStyle(this, null);
1604
1755
  var styleMap = {};
1605
1756
  this._applyCustomCssProperties(styleMap, style,
1606
1757
  {
@@ -1611,11 +1762,12 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
1611
1762
  "axis": "--avs-axis-animations",
1612
1763
  "legend": "--avs-legend-animations",
1613
1764
  "legendTitle": "--avs-legend-title-animations",
1614
- "glyph": "--avs-glyph-animations",
1615
- "transform": "--avs-transform-animation"
1616
- } );
1765
+ "glyph": "--avs-glyph-animations"
1766
+ });
1767
+ styleMap.transform = this.transformAnimationFrames.length > 0 ? JSON.stringify(this.transformAnimationFrames) : null;
1768
+
1617
1769
  this.animator.setStyleMap(styleMap);
1618
- this.threeViewer.runAnimation();
1770
+ this.threeViewer.runAnimation();
1619
1771
  }
1620
1772
  }
1621
1773
 
@@ -1661,6 +1813,16 @@ export class AvsGoDataViz extends AvsDataSourceMixin(AvsStreamMixin(AvsHttpMixin
1661
1813
  }
1662
1814
  }
1663
1815
 
1816
+ /**
1817
+ * Change in 'transform-animation' property.
1818
+ */
1819
+ _transformAnimationValueChanged(newValue, oldValue) {
1820
+ if (newValue) {
1821
+ const decoded = atob(newValue);
1822
+ this.transformAnimationFrames = JSON.parse(decoded);
1823
+ }
1824
+ }
1825
+
1664
1826
  /**
1665
1827
  * Change in 'zoom-rectangle-enable' property.
1666
1828
  */
package/src/constants.js CHANGED
@@ -18,4 +18,4 @@
18
18
  * Advanced Visual Systems Inc. (http://www.avs.com)
19
19
  */
20
20
 
21
- export var VERSION = '0.12.71739';
21
+ export var VERSION = '0.13.71745';