vislite 0.4.0 → 0.4.1-alpha.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.
Files changed (47) hide show
  1. package/CHANGELOG +8 -1
  2. package/README.md +1 -1
  3. package/lib/Buffer/index.umd.js +2 -2
  4. package/lib/Buffer/index.umd.min.js +2 -2
  5. package/lib/Canvas/index.umd.js +2 -2
  6. package/lib/Canvas/index.umd.min.js +2 -2
  7. package/lib/Cardinal/index.umd.js +2 -2
  8. package/lib/Cardinal/index.umd.min.js +2 -2
  9. package/lib/Eoap/index.umd.js +2 -2
  10. package/lib/Eoap/index.umd.min.js +2 -2
  11. package/lib/Hermite/index.umd.js +2 -2
  12. package/lib/Hermite/index.umd.min.js +2 -2
  13. package/lib/Matrix4/index.umd.js +2 -2
  14. package/lib/Matrix4/index.umd.min.js +2 -2
  15. package/lib/Mercator/index.umd.js +2 -2
  16. package/lib/Mercator/index.umd.min.js +2 -2
  17. package/lib/OralCanvas/index.es.js +2 -2
  18. package/lib/OralCanvas/index.es.min.js +2 -2
  19. package/lib/OralWebGL/index.es.js +2 -2
  20. package/lib/OralWebGL/index.es.min.js +2 -2
  21. package/lib/SVG/index.umd.js +2 -2
  22. package/lib/SVG/index.umd.min.js +2 -2
  23. package/lib/Shader/index.umd.js +2 -2
  24. package/lib/Shader/index.umd.min.js +2 -2
  25. package/lib/Texture/index.umd.js +2 -2
  26. package/lib/Texture/index.umd.min.js +2 -2
  27. package/lib/WebGL/index.umd.js +3 -2
  28. package/lib/WebGL/index.umd.min.js +3 -3
  29. package/lib/animation/index.umd.js +2 -2
  30. package/lib/animation/index.umd.min.js +2 -2
  31. package/lib/getLoopColors/index.umd.js +2 -2
  32. package/lib/getLoopColors/index.umd.min.js +2 -2
  33. package/lib/getWebGLContext/index.umd.js +2 -2
  34. package/lib/getWebGLContext/index.umd.min.js +2 -2
  35. package/lib/index.umd.js +42 -27
  36. package/lib/index.umd.min.js +3 -3
  37. package/lib/rotate/index.umd.js +2 -2
  38. package/lib/rotate/index.umd.min.js +2 -2
  39. package/lib/ruler/index.umd.js +2 -2
  40. package/lib/ruler/index.umd.min.js +2 -2
  41. package/lib/viewHandler/index.umd.js +41 -27
  42. package/lib/viewHandler/index.umd.min.js +3 -3
  43. package/package.json +2 -2
  44. package/src/WebGL.ts +1 -0
  45. package/src/common/webgl/index.ts +1 -1
  46. package/src/viewHandler.ts +45 -26
  47. package/types/viewHandler.d.ts +2 -1
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.4.0
2
+ * VISLite JavaScript Library v0.4.1-alpha.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  *
5
5
  * Copyright zxl20070701
6
6
  * Released under the MIT license
7
7
  * https://zxl20070701.github.io/notebook/home.html
8
8
  *
9
- * Publish Date: Sat Jul 22 2023 04:42:29 GMT+0800 (中国标准时间)
9
+ * Publish Date: Mon Jul 31 2023 22:52:35 GMT+0800 (中国标准时间)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -37,50 +37,63 @@
37
37
  callback({
38
38
  type: "lookUp",
39
39
  normal: [],
40
- value: 0.1
40
+ value: 0.1,
41
+ event: event
41
42
  });
42
43
  }
43
44
  else if (keyCode == 'down') {
44
45
  callback({
45
46
  type: "lookDown",
46
47
  normal: [],
47
- value: 0.1
48
+ value: 0.1,
49
+ event: event
48
50
  });
49
51
  }
50
52
  else if (keyCode == 'left') {
51
53
  callback({
52
54
  type: "lookLeft",
53
55
  normal: [],
54
- value: 0.1
56
+ value: 0.1,
57
+ event: event
55
58
  });
56
59
  }
57
60
  else if (keyCode == 'right') {
58
61
  callback({
59
62
  type: "lookRight",
60
63
  normal: [],
61
- value: 0.1
64
+ value: 0.1,
65
+ event: event
62
66
  });
63
67
  }
64
68
  });
65
69
  var mouseP = null;
66
70
  var doMove = function (event) {
67
- if (mouseP == null)
68
- return;
69
- var tempMouseP = mousePosition(el, event);
70
- var normal = [tempMouseP.x - mouseP.x, tempMouseP.y - mouseP.y];
71
- var rotateNormal = [
72
- normal[1],
73
- normal[0],
74
- 0
75
- ];
76
- if (rotateNormal[0] == 0 && rotateNormal[1] == 0)
77
- return;
78
- callback({
79
- type: "rotate",
80
- normal: rotateNormal,
81
- value: (Math.abs(tempMouseP.x - mouseP.x) + Math.abs(tempMouseP.y - mouseP.y)) * 0.01
82
- });
83
- mouseP = tempMouseP;
71
+ if (mouseP == null) {
72
+ callback({
73
+ type: "hover",
74
+ normal: [],
75
+ value: 0,
76
+ event: event
77
+ });
78
+ }
79
+ else {
80
+ var tempMouseP = mousePosition(el, event);
81
+ var normal = [tempMouseP.x - mouseP.x, tempMouseP.y - mouseP.y];
82
+ var rotateNormal = [
83
+ normal[1],
84
+ normal[0],
85
+ 0
86
+ ];
87
+ if (rotateNormal[0] == 0 && rotateNormal[1] == 0)
88
+ return;
89
+ callback({
90
+ type: "rotate",
91
+ normal: rotateNormal,
92
+ value: (Math.abs(tempMouseP.x - mouseP.x) + Math.abs(tempMouseP.y - mouseP.y)) * 0.01,
93
+ event: event
94
+ });
95
+ mouseP = tempMouseP;
96
+ }
84
97
  };
85
98
  el.addEventListener("mousedown", function (event) {
86
99
  mouseP = mousePosition(el, event);
@@ -100,22 +113,23 @@
100
113
  el.addEventListener("touchmove", function (event) {
101
114
  doMove(event.touches[0]);
102
115
  });
103
- var doScale = function (value) {
116
+ var doScale = function (value, event) {
104
117
  if (value == 0)
105
118
  return;
106
119
  var baseTimes = 0.899;
107
120
  callback({
108
121
  type: "scale",
109
122
  value: value < 0 ? baseTimes : 2 - baseTimes,
110
- normal: []
123
+ normal: [],
124
+ event: event
111
125
  });
112
126
  };
113
127
  el.addEventListener("mousewheel", function (event) {
114
- doScale(event.wheelDelta);
128
+ doScale(event.wheelDelta, event);
115
129
  });
116
130
  if (window.addEventListener) {
117
131
  window.addEventListener('DOMMouseScroll', function (event) {
118
- doScale(-1 * event.detail);
132
+ doScale(-1 * event.detail, event);
119
133
  }, false);
120
134
  }
121
135
  }
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.4.0
2
+ * VISLite JavaScript Library v0.4.1-alpha.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  *
5
5
  * Copyright zxl20070701
6
6
  * Released under the MIT license
7
7
  * https://zxl20070701.github.io/notebook/home.html
8
8
  *
9
- * Publish Date: Sat Jul 22 2023 04:42:29 GMT+0800 (中国标准时间)
9
+ * Publish Date: Mon Jul 31 2023 22:52:35 GMT+0800 (中国标准时间)
10
10
  */
11
- var e,n;e=this,n=function(){"use strict";var e=function(e,n){var t=e.getBoundingClientRect();return{x:n.clientX-t.left,y:n.clientY-t.top}};return function(n){var t=document.getElementsByTagName("body")[0];t.addEventListener("keydown",(function(e){var t=function(e){return{37:"left",38:"up",39:"right",40:"down"}[e.keyCode||e.which]}(e);"up"==t?n({type:"lookUp",normal:[],value:.1}):"down"==t?n({type:"lookDown",normal:[],value:.1}):"left"==t?n({type:"lookLeft",normal:[],value:.1}):"right"==t&&n({type:"lookRight",normal:[],value:.1})}));var o=null,i=function(i){if(null!=o){var u=e(t,i),l=[u.x-o.x,u.y-o.y],a=[l[1],l[0],0];0==a[0]&&0==a[1]||(n({type:"rotate",normal:a,value:.01*(Math.abs(u.x-o.x)+Math.abs(u.y-o.y))}),o=u)}};t.addEventListener("mousedown",(function(n){o=e(t,n)})),t.addEventListener("mouseup",(function(e){o=null})),t.addEventListener("mousemove",(function(e){i(e)})),t.addEventListener("touchend",(function(e){o=null})),t.addEventListener("touchstart",(function(n){o=e(t,n)})),t.addEventListener("touchmove",(function(e){i(e.touches[0])}));var u=function(e){0!=e&&n({type:"scale",value:e<0?.899:1.101,normal:[]})};t.addEventListener("mousewheel",(function(e){u(e.wheelDelta)})),window.addEventListener&&window.addEventListener("DOMMouseScroll",(function(e){u(-1*e.detail)}),!1)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_viewHandler=n();
11
+ var e,n;e=this,n=function(){"use strict";var e=function(e,n){var t=e.getBoundingClientRect();return{x:n.clientX-t.left,y:n.clientY-t.top}};return function(n){var t=document.getElementsByTagName("body")[0];t.addEventListener("keydown",(function(e){var t=function(e){return{37:"left",38:"up",39:"right",40:"down"}[e.keyCode||e.which]}(e);"up"==t?n({type:"lookUp",normal:[],value:.1,event:e}):"down"==t?n({type:"lookDown",normal:[],value:.1,event:e}):"left"==t?n({type:"lookLeft",normal:[],value:.1,event:e}):"right"==t&&n({type:"lookRight",normal:[],value:.1,event:e})}));var o=null,i=function(i){if(null==o)n({type:"hover",normal:[],value:0,event:i});else{var u=e(t,i),l=[u.x-o.x,u.y-o.y],a=[l[1],l[0],0];if(0==a[0]&&0==a[1])return;n({type:"rotate",normal:a,value:.01*(Math.abs(u.x-o.x)+Math.abs(u.y-o.y)),event:i}),o=u}};t.addEventListener("mousedown",(function(n){o=e(t,n)})),t.addEventListener("mouseup",(function(e){o=null})),t.addEventListener("mousemove",(function(e){i(e)})),t.addEventListener("touchend",(function(e){o=null})),t.addEventListener("touchstart",(function(n){o=e(t,n)})),t.addEventListener("touchmove",(function(e){i(e.touches[0])}));var u=function(e,t){0!=e&&n({type:"scale",value:e<0?.899:1.101,normal:[],event:t})};t.addEventListener("mousewheel",(function(e){u(e.wheelDelta,e)})),window.addEventListener&&window.addEventListener("DOMMouseScroll",(function(e){u(-1*e.detail,e)}),!1)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_viewHandler=n();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vislite",
3
- "version": "0.4.0",
3
+ "version": "0.4.1-alpha.0",
4
4
  "description": "灵活、快速、简单的数据可视化交互式跨端前端库",
5
5
  "main": "./lib/index.umd.min.js",
6
6
  "typings": "./types/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "devDependencies": {
42
42
  "@rollup/plugin-typescript": "^11.1.0",
43
43
  "@types/jasmine": "^4.3.1",
44
- "devby": "^0.3.1",
44
+ "devby": "^0.4.6",
45
45
  "karma": "^6.3.10",
46
46
  "karma-chrome-launcher": "^3.1.0",
47
47
  "karma-jasmine": "^4.0.1",
package/src/WebGL.ts CHANGED
@@ -27,6 +27,7 @@ class WebGL extends OralWebGL implements WebGLType {
27
27
 
28
28
  RegionCanvas.style.position = 'absolute'
29
29
  RegionCanvas.style.zIndex = "-1"
30
+ RegionCanvas.style.opacity = "0"
30
31
 
31
32
  ViewCanvas = document.createElement('canvas')
32
33
  el.appendChild(ViewCanvas)
@@ -2,7 +2,7 @@ import getWebGLContext from './getWebGLContext'
2
2
  import Object3DType from '../../../types/Object3D'
3
3
  import Scene3DType from '../../../types/Scene3D'
4
4
  import getColorFactory from './getColorFactory'
5
- import Matrix4 from '..//../Matrix4/index'
5
+ import Matrix4 from '../../Matrix4/index'
6
6
  import doDraw from './doDraw'
7
7
  import assemble from '../assemble'
8
8
 
@@ -30,7 +30,8 @@ export default function (callback: callbackFun) {
30
30
  callback({
31
31
  type: "lookUp",
32
32
  normal: [],
33
- value: 0.1
33
+ value: 0.1,
34
+ event
34
35
  })
35
36
  }
36
37
 
@@ -39,7 +40,8 @@ export default function (callback: callbackFun) {
39
40
  callback({
40
41
  type: "lookDown",
41
42
  normal: [],
42
- value: 0.1
43
+ value: 0.1,
44
+ event
43
45
  })
44
46
  }
45
47
 
@@ -48,7 +50,8 @@ export default function (callback: callbackFun) {
48
50
  callback({
49
51
  type: "lookLeft",
50
52
  normal: [],
51
- value: 0.1
53
+ value: 0.1,
54
+ event
52
55
  })
53
56
  }
54
57
 
@@ -57,7 +60,8 @@ export default function (callback: callbackFun) {
57
60
  callback({
58
61
  type: "lookRight",
59
62
  normal: [],
60
- value: 0.1
63
+ value: 0.1,
64
+ event
61
65
  })
62
66
  }
63
67
 
@@ -66,30 +70,44 @@ export default function (callback: callbackFun) {
66
70
  // 鼠标控制
67
71
  let mouseP = null;
68
72
  let doMove = function (event) {
69
- if (mouseP == null) return
70
73
 
71
- let tempMouseP = mousePosition(el, event)
74
+ // 单纯移动
75
+ if (mouseP == null) {
76
+ callback({
77
+ type: "hover",
78
+ normal: [],
79
+ value: 0,
80
+ event
81
+ })
82
+ }
72
83
 
73
- // 先求解出轨迹向量
74
- let normal = [tempMouseP.x - mouseP.x, tempMouseP.y - mouseP.y]
84
+ // 按下移动
85
+ else {
75
86
 
76
- // 方向向量旋转90deg得到旋转向量
77
- let rotateNormal = [
78
- normal[1],
79
- normal[0],
80
- 0
81
- ]
87
+ let tempMouseP = mousePosition(el, event)
82
88
 
83
- // 非法射线忽略
84
- if (rotateNormal[0] == 0 && rotateNormal[1] == 0) return
89
+ // 先求解出轨迹向量
90
+ let normal = [tempMouseP.x - mouseP.x, tempMouseP.y - mouseP.y]
85
91
 
86
- callback({
87
- type: "rotate",
88
- normal: rotateNormal,
89
- value: (Math.abs(tempMouseP.x - mouseP.x) + Math.abs(tempMouseP.y - mouseP.y)) * 0.01
90
- })
92
+ // 方向向量旋转90deg得到旋转向量
93
+ let rotateNormal = [
94
+ normal[1],
95
+ normal[0],
96
+ 0
97
+ ]
91
98
 
92
- mouseP = tempMouseP
99
+ // 非法射线忽略
100
+ if (rotateNormal[0] == 0 && rotateNormal[1] == 0) return
101
+
102
+ callback({
103
+ type: "rotate",
104
+ normal: rotateNormal,
105
+ value: (Math.abs(tempMouseP.x - mouseP.x) + Math.abs(tempMouseP.y - mouseP.y)) * 0.01,
106
+ event
107
+ })
108
+
109
+ mouseP = tempMouseP
110
+ }
93
111
  }
94
112
 
95
113
  el.addEventListener("mousedown", (event) => {
@@ -113,27 +131,28 @@ export default function (callback: callbackFun) {
113
131
  doMove(event.touches[0])
114
132
  })
115
133
 
116
- let doScale = function (value: number) {
134
+ let doScale = function (value: number, event: Event) {
117
135
  if (value == 0) return
118
136
 
119
137
  let baseTimes = 0.899
120
138
  callback({
121
139
  type: "scale",
122
140
  value: value < 0 ? baseTimes : 2 - baseTimes,
123
- normal: []
141
+ normal: [],
142
+ event
124
143
  })
125
144
  }
126
145
 
127
146
  // 滚轮控制
128
147
  el.addEventListener("mousewheel", function (event: any) {
129
- doScale(event.wheelDelta)
148
+ doScale(event.wheelDelta, event)
130
149
  })
131
150
 
132
151
  if (window.addEventListener) {
133
152
 
134
153
  // 针对火狐浏览器
135
154
  window.addEventListener('DOMMouseScroll', function (event: any) {
136
- doScale(-1 * event.detail)
155
+ doScale(-1 * event.detail, event)
137
156
  }, false)
138
157
  }
139
158
 
@@ -1,7 +1,8 @@
1
1
  export interface paramsType {
2
2
  type: string
3
3
  value: number,
4
- normal: number[]
4
+ normal: number[],
5
+ event: Event
5
6
  }
6
7
 
7
8
  export interface callbackFun {