vislite 0.3.0-alpha.0 → 0.3.0-alpha.1

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 (39) hide show
  1. package/CHANGELOG +12 -4
  2. package/lib/Canvas/index.umd.js +2 -6
  3. package/lib/Canvas/index.umd.min.js +2 -6
  4. package/lib/Cardinal/index.umd.js +16 -9
  5. package/lib/Cardinal/index.umd.min.js +3 -7
  6. package/lib/Eoap/index.umd.js +2 -6
  7. package/lib/Eoap/index.umd.min.js +2 -6
  8. package/lib/Hermite/index.umd.js +2 -6
  9. package/lib/Hermite/index.umd.min.js +2 -6
  10. package/lib/Matrix4/index.umd.js +2 -6
  11. package/lib/Matrix4/index.umd.min.js +2 -6
  12. package/lib/Mercator/index.umd.js +2 -6
  13. package/lib/Mercator/index.umd.min.js +2 -6
  14. package/lib/OralCanvas/index.es.js +2 -6
  15. package/lib/OralCanvas/index.es.min.js +2 -6
  16. package/lib/OralWebGL/index.es.js +15 -10
  17. package/lib/OralWebGL/index.es.min.js +3 -7
  18. package/lib/SVG/index.umd.js +2 -6
  19. package/lib/SVG/index.umd.min.js +2 -6
  20. package/lib/WebGL/index.umd.js +15 -10
  21. package/lib/WebGL/index.umd.min.js +3 -7
  22. package/lib/animation/index.umd.js +2 -6
  23. package/lib/animation/index.umd.min.js +2 -6
  24. package/lib/getLoopColors/index.umd.js +2 -6
  25. package/lib/getLoopColors/index.umd.min.js +2 -6
  26. package/lib/index.umd.js +29 -13
  27. package/lib/index.umd.min.js +3 -7
  28. package/lib/rotate/index.umd.js +2 -6
  29. package/lib/rotate/index.umd.min.js +2 -6
  30. package/lib/ruler/index.umd.js +2 -6
  31. package/lib/ruler/index.umd.min.js +2 -6
  32. package/lib/viewHandler/index.umd.js +2 -6
  33. package/lib/viewHandler/index.umd.min.js +2 -6
  34. package/package.json +1 -1
  35. package/src/common/webgl/doDraw.ts +13 -3
  36. package/src/common/webgl/getShader.ts +6 -0
  37. package/src/common/webgl/index.ts +4 -0
  38. package/src/interpolation/Cardinal.ts +22 -4
  39. package/types/Object3D.d.ts +7 -0
@@ -1,16 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.3.0-alpha.0
2
+ * VISLite JavaScript Library v0.3.0-alpha.1
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
- * 本版本系测试版本,请认真阅读下述说明再使用:
10
- *
11
- *【测试版本细则】
12
- * alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
13
- * beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
9
+ * Publish Date: Wed Jun 28 2023 22:51:53 GMT+0800 (中国标准时间)
14
10
  */
15
11
  (function (global, factory) {
16
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1,15 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.3.0-alpha.0
2
+ * VISLite JavaScript Library v0.3.0-alpha.1
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
- * 本版本系测试版本,请认真阅读下述说明再使用:
10
- *
11
- *【测试版本细则】
12
- * alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
13
- * beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
9
+ * Publish Date: Wed Jun 28 2023 22:51:53 GMT+0800 (中国标准时间)
14
10
  */
15
11
  var e,r;e=this,r=function(){"use strict";return function(e,r,t){if(e<r){var f=r;r=e,e=f}else if(e==r)return[e];var n=function(e){for(var r=e<100&&e>-100?10:.1,t=-1,f=e;10==r?f>=-100&&f<=100:f<=-100||f>=100;)t+=1,f*=r;if(10==r)return Math.pow(10,t);for(var n="0.",o=1;o<t;o++)n+="0";return+(n+"1")}(e-r),o=Math.ceil((e-r)*n/t),i=(o={3:2,4:5,6:5,7:5,8:10,9:10,11:10,12:10,13:15,14:15,16:15,17:15,18:20,19:20,21:20,22:20,23:25,24:25,26:25,27:25}[o]||o)/n,u=Math.floor(r/i)*i,a=[];a.push(u);for(var l=1;a[a.length-1]<e;l++)a.push(u+i*l);return a}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_ruler=r();
@@ -1,16 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.3.0-alpha.0
2
+ * VISLite JavaScript Library v0.3.0-alpha.1
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
- * 本版本系测试版本,请认真阅读下述说明再使用:
10
- *
11
- *【测试版本细则】
12
- * alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
13
- * beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
9
+ * Publish Date: Wed Jun 28 2023 22:51:53 GMT+0800 (中国标准时间)
14
10
  */
15
11
  (function (global, factory) {
16
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1,15 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.3.0-alpha.0
2
+ * VISLite JavaScript Library v0.3.0-alpha.1
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
- * 本版本系测试版本,请认真阅读下述说明再使用:
10
- *
11
- *【测试版本细则】
12
- * alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
13
- * beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
9
+ * Publish Date: Wed Jun 28 2023 22:51:53 GMT+0800 (中国标准时间)
14
10
  */
15
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vislite",
3
- "version": "0.3.0-alpha.0",
3
+ "version": "0.3.0-alpha.1",
4
4
  "description": "灵活、快速、简单的数据可视化交互式跨端前端库",
5
5
  "main": "./lib/index.umd.min.js",
6
6
  "typings": "./types/index.d.ts",
@@ -20,7 +20,7 @@ export default function (type: string, painter: WebGLRenderingContext, mesh: mes
20
20
  // 点数据写入缓冲区
21
21
  new BufferObject(painter).use()
22
22
  .write(mesh.geometry.attributes.position.array as Float32Array)
23
- .divide(painter.getAttribLocation(shader.program, "a_position"), mesh.geometry.attributes.position.itemSize, 3, 0)
23
+ .divide(painter.getAttribLocation(shader.program, "a_position"), mesh.geometry.attributes.position.itemSize, mesh.geometry.attributes.position.itemSize, 0)
24
24
 
25
25
  // 写入矩阵
26
26
  painter.uniformMatrix4fv(painter.getUniformLocation(shader.program, "u_matrix_world"), false, globalWorld.matrix)
@@ -31,7 +31,7 @@ export default function (type: string, painter: WebGLRenderingContext, mesh: mes
31
31
  if (mesh.geometry.attributes.normal) {
32
32
  new BufferObject(painter).use()
33
33
  .write(mesh.geometry.attributes.normal.array as Float32Array)
34
- .divide(painter.getAttribLocation(shader.program, "a_normal"), mesh.geometry.attributes.normal.itemSize, 3, 0)
34
+ .divide(painter.getAttribLocation(shader.program, "a_normal"), mesh.geometry.attributes.normal.itemSize, mesh.geometry.attributes.normal.itemSize, 0)
35
35
  }
36
36
 
37
37
  // 颜色
@@ -45,10 +45,20 @@ export default function (type: string, painter: WebGLRenderingContext, mesh: mes
45
45
  , mesh.material.color.alpha)
46
46
  }
47
47
 
48
+ // 多颜色
49
+ if ("colors" in mesh.material) {
50
+
51
+ // 写入颜色序列
52
+ new BufferObject(painter).use()
53
+ .write(mesh.material.colors.array as Float32Array)
54
+ .divide(painter.getAttribLocation(shader.program, "a_color"), mesh.material.colors.itemSize, mesh.material.colors.itemSize, 0)
55
+
56
+ }
57
+
48
58
  // 立方纹理
49
59
  else if ("cube" in mesh.material) {
50
60
 
51
- let size = mesh.material.cube.right.image.value.width
61
+ let size = (mesh.material.cube.right.image.value as any).width
52
62
 
53
63
  getTexture(type, painter, 'cube').useCube([
54
64
  mesh.material.cube.right.image.value,
@@ -9,6 +9,7 @@ export default function (type: string, painter: WebGLRenderingContext, mesh: mes
9
9
  (mesh.geometry.attributes.normal ? "1" : "0") +
10
10
  (mesh.material.image ? "1" : "0") +
11
11
  (mesh.material.color ? "1" : "0") +
12
+ (mesh.material.colors ? "1" : "0") +
12
13
  (mesh.material.cube ? "1" : "0")
13
14
  if (shaders[uniqueName]) return shaders[uniqueName].use()
14
15
 
@@ -24,6 +25,8 @@ export default function (type: string, painter: WebGLRenderingContext, mesh: mes
24
25
 
25
26
  ${mesh.material.image ? 'attribute vec2 a_textcoord;varying vec2 v_textcoord;' : ''}
26
27
 
28
+ ${mesh.material.colors ? 'attribute vec4 a_color;varying vec4 v_color;' : ''}
29
+
27
30
  void main(){
28
31
  vec4 temp = a_position;
29
32
 
@@ -43,6 +46,7 @@ export default function (type: string, painter: WebGLRenderingContext, mesh: mes
43
46
 
44
47
  ${mesh.geometry.attributes.normal ? 'v_normal = normalize(vec3(a_normal));' : ''}
45
48
  ${mesh.material.image ? 'v_textcoord = a_textcoord;' : ''}
49
+ ${mesh.material.colors ? 'v_color=a_color;' : ''}
46
50
  }
47
51
  `
48
52
 
@@ -54,11 +58,13 @@ export default function (type: string, painter: WebGLRenderingContext, mesh: mes
54
58
  ${mesh.material.color ? 'uniform vec4 u_color;' : ''}
55
59
  ${mesh.material.cube ? 'uniform samplerCube u_texture;' : ''}
56
60
  ${mesh.material.image ? 'uniform sampler2D u_sampler;varying vec2 v_textcoord;' : ''}
61
+ ${mesh.material.colors ? 'varying vec4 v_color;' : ''}
57
62
 
58
63
  void main(){
59
64
  ${mesh.material.color ? 'gl_FragColor = u_color;' : ''}
60
65
  ${mesh.material.cube ? 'gl_FragColor = textureCube(u_texture,normalize(v_normal));' : ''}
61
66
  ${mesh.material.image ? 'gl_FragColor = texture2D(u_sampler,v_textcoord);' : ''}
67
+ ${mesh.material.colors ? 'gl_FragColor=v_color;' : ''}
62
68
  }
63
69
  `
64
70
 
@@ -165,6 +165,10 @@ class WebGL {
165
165
  mesh.geometry.index.array = new Uint8Array(mesh.geometry.index.array)
166
166
  }
167
167
 
168
+ if (mesh.material.colors && Array.isArray(mesh.material.colors.array)) {
169
+ mesh.material.colors.array = new Float32Array(mesh.material.colors.array)
170
+ }
171
+
168
172
  }
169
173
 
170
174
  this.__scene.children.push(object3D)
@@ -46,11 +46,29 @@ class Cardinal implements CardinalType {
46
46
  this.__HS.x[flag] = points[flag][0]
47
47
 
48
48
  // 求点斜率
49
- temp = flag < points.length - 1 ?
50
- (points[flag + 1][1] - points[flag - 1][1]) / (points[flag + 1][0] - points[flag - 1][0]) :
51
- (points[flag][1] - points[flag - 1][1]) / (points[flag][0] - points[flag - 1][0])
52
49
 
53
- // 求解两个点直接的拟合方程
50
+ // temp = flag < points.length - 1 ?
51
+ // (points[flag + 1][1] - points[flag - 1][1]) / (points[flag + 1][0] - points[flag - 1][0]) :
52
+ // (points[flag][1] - points[flag - 1][1]) / (points[flag][0] - points[flag - 1][0])
53
+
54
+ // 修复超过界限的值问题
55
+ // 2023年6月25日 于南京
56
+ if (flag < points.length - 1) {
57
+ if (
58
+ (points[flag + 1][1] > points[flag][1] && points[flag - 1][1] > points[flag][1]) ||
59
+ (points[flag + 1][1] < points[flag][1] && points[flag - 1][1] < points[flag][1]) ||
60
+ points[flag + 1][1] == points[flag][1] ||
61
+ points[flag - 1][1] == points[flag][1]
62
+ ) {
63
+ temp = 0
64
+ } else {
65
+ temp = (points[flag + 1][1] - points[flag - 1][1]) / (points[flag + 1][0] - points[flag - 1][0])
66
+ }
67
+ } else {
68
+ temp = (points[flag][1] - points[flag - 1][1]) / (points[flag][0] - points[flag - 1][0])
69
+ }
70
+
71
+ // 求解两个点直接的插值方程
54
72
  // 第一个点的前一个点直接取第一个点
55
73
  // 最后一个点的后一个点直接取最后一个点
56
74
  this.__HS.h[flag - 1] = new Hermite((1 - this.__t) * 0.5).setP(points[flag - 1][0], points[flag - 1][1], points[flag][0], points[flag][1], slope, temp)
@@ -52,6 +52,13 @@ export interface meshType {
52
52
  alpha: number
53
53
  }
54
54
 
55
+ // 多颜色
56
+ colors?: {
57
+ array: number[] | Float32Array
58
+ count: number
59
+ itemSize: number
60
+ }
61
+
55
62
  // 立方体纹理
56
63
  cube?: {
57
64
  left?: {