vislite 0.7.1 → 0.8.0-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.
- package/CHANGELOG +28 -2
- package/README.md +144 -135
- package/lib/Buffer/index.umd.d.ts +3 -0
- package/lib/Buffer/index.umd.js +2 -2
- package/lib/Buffer/index.umd.min.d.ts +3 -0
- package/lib/Buffer/index.umd.min.js +2 -2
- package/lib/Canvas/index.umd.d.ts +3 -0
- package/lib/Canvas/index.umd.js +26 -2
- package/lib/Canvas/index.umd.min.d.ts +3 -0
- package/lib/Canvas/index.umd.min.js +3 -3
- package/lib/Cardinal/index.umd.d.ts +3 -0
- package/lib/Cardinal/index.umd.js +2 -2
- package/lib/Cardinal/index.umd.min.d.ts +3 -0
- package/lib/Cardinal/index.umd.min.js +2 -2
- package/lib/Eoap/index.umd.d.ts +3 -0
- package/lib/Eoap/index.umd.js +2 -2
- package/lib/Eoap/index.umd.min.d.ts +3 -0
- package/lib/Eoap/index.umd.min.js +2 -2
- package/lib/Geometry/index.umd.d.ts +3 -0
- package/lib/Geometry/index.umd.js +61 -11
- package/lib/Geometry/index.umd.min.d.ts +3 -0
- package/lib/Geometry/index.umd.min.js +3 -3
- package/lib/Hermite/index.umd.d.ts +3 -0
- package/lib/Hermite/index.umd.js +2 -2
- package/lib/Hermite/index.umd.min.d.ts +3 -0
- package/lib/Hermite/index.umd.min.js +2 -2
- package/lib/Matrix4/index.umd.d.ts +3 -0
- package/lib/Matrix4/index.umd.js +2 -2
- package/lib/Matrix4/index.umd.min.d.ts +3 -0
- package/lib/Matrix4/index.umd.min.js +2 -2
- package/lib/Mercator/index.umd.d.ts +3 -0
- package/lib/Mercator/index.umd.js +2 -2
- package/lib/Mercator/index.umd.min.d.ts +3 -0
- package/lib/Mercator/index.umd.min.js +2 -2
- package/lib/OralCanvas/index.es.d.ts +3 -0
- package/lib/OralCanvas/index.es.js +26 -2
- package/lib/OralCanvas/index.es.min.d.ts +3 -0
- package/lib/OralCanvas/index.es.min.js +3 -3
- package/lib/OralWebGL/index.es.d.ts +3 -0
- package/lib/OralWebGL/index.es.js +26 -8
- package/lib/OralWebGL/index.es.min.d.ts +3 -0
- package/lib/OralWebGL/index.es.min.js +3 -3
- package/lib/SVG/index.umd.d.ts +3 -0
- package/lib/SVG/index.umd.js +2 -2
- package/lib/SVG/index.umd.min.d.ts +3 -0
- package/lib/SVG/index.umd.min.js +2 -2
- package/lib/Shader/index.umd.d.ts +3 -0
- package/lib/Shader/index.umd.js +2 -2
- package/lib/Shader/index.umd.min.d.ts +3 -0
- package/lib/Shader/index.umd.min.js +2 -2
- package/lib/Texture/index.umd.d.ts +3 -0
- package/lib/Texture/index.umd.js +2 -2
- package/lib/Texture/index.umd.min.d.ts +3 -0
- package/lib/Texture/index.umd.min.js +2 -2
- package/lib/TreeLayout/index.umd.d.ts +3 -0
- package/lib/TreeLayout/index.umd.js +2 -2
- package/lib/TreeLayout/index.umd.min.d.ts +3 -0
- package/lib/TreeLayout/index.umd.min.js +2 -2
- package/lib/WebGL/index.umd.d.ts +3 -0
- package/lib/WebGL/index.umd.js +27 -9
- package/lib/WebGL/index.umd.min.d.ts +3 -0
- package/lib/WebGL/index.umd.min.js +3 -3
- package/lib/animation/index.umd.d.ts +3 -0
- package/lib/animation/index.umd.js +2 -2
- package/lib/animation/index.umd.min.d.ts +3 -0
- package/lib/animation/index.umd.min.js +2 -2
- package/lib/formatColor/index.umd.d.ts +3 -0
- package/lib/formatColor/index.umd.js +2 -2
- package/lib/formatColor/index.umd.min.d.ts +3 -0
- package/lib/formatColor/index.umd.min.js +2 -2
- package/lib/getLoopColors/index.umd.d.ts +3 -0
- package/lib/getLoopColors/index.umd.js +2 -2
- package/lib/getLoopColors/index.umd.min.d.ts +3 -0
- package/lib/getLoopColors/index.umd.min.js +2 -2
- package/lib/getWebGLContext/index.umd.d.ts +3 -0
- package/lib/getWebGLContext/index.umd.js +25 -7
- package/lib/getWebGLContext/index.umd.min.d.ts +3 -0
- package/lib/getWebGLContext/index.umd.min.js +3 -3
- package/lib/index.umd.js +112 -20
- package/lib/index.umd.min.js +3 -3
- package/lib/move/index.umd.d.ts +3 -0
- package/lib/move/index.umd.js +2 -2
- package/lib/move/index.umd.min.d.ts +3 -0
- package/lib/move/index.umd.min.js +2 -2
- package/lib/resizeObserver/index.umd.d.ts +3 -0
- package/lib/resizeObserver/index.umd.js +2 -2
- package/lib/resizeObserver/index.umd.min.d.ts +3 -0
- package/lib/resizeObserver/index.umd.min.js +2 -2
- package/lib/rotate/index.umd.d.ts +3 -0
- package/lib/rotate/index.umd.js +2 -2
- package/lib/rotate/index.umd.min.d.ts +3 -0
- package/lib/rotate/index.umd.min.js +2 -2
- package/lib/ruler/index.umd.d.ts +3 -0
- package/lib/ruler/index.umd.js +2 -2
- package/lib/ruler/index.umd.min.d.ts +3 -0
- package/lib/ruler/index.umd.min.js +2 -2
- package/lib/scale/index.umd.d.ts +3 -0
- package/lib/scale/index.umd.js +2 -2
- package/lib/scale/index.umd.min.d.ts +3 -0
- package/lib/scale/index.umd.min.js +2 -2
- package/lib/throttle/index.umd.d.ts +3 -0
- package/lib/throttle/index.umd.js +2 -2
- package/lib/throttle/index.umd.min.d.ts +3 -0
- package/lib/throttle/index.umd.min.js +2 -2
- package/lib/viewHandler/index.umd.d.ts +3 -0
- package/lib/viewHandler/index.umd.js +2 -2
- package/lib/viewHandler/index.umd.min.d.ts +3 -0
- package/lib/viewHandler/index.umd.min.js +2 -2
- package/package/getWebGLContext/index.ts +40 -39
- package/package.json +1 -1
- package/src/Canvas.ts +2 -2
- package/src/Geometry.ts +65 -1
- package/src/WebGL.ts +66 -66
- package/src/common/canvas/painter.ts +26 -0
- package/src/common/geometry/prism-horizontal.ts +50 -35
- package/src/common/geometry/prism-vertical.ts +55 -40
- package/src/common/geometry/tool/circle.ts +17 -11
- package/src/common/geometry/tool/rotateLine.ts +48 -35
- package/src/common/webgl/getWebGLContext.ts +45 -28
- package/src/common/webgl/index.ts +227 -226
- package/src/common/webgl/shader.ts +75 -75
- package/types/Canvas.d.ts +318 -308
- package/types/Geometry.d.ts +132 -65
- package/types/Object3D.d.ts +114 -114
- package/types/Shader.d.ts +23 -23
- package/types/WebGLOption.d.ts +14 -7
- package/types/getWebGLContext.d.ts +4 -2
- package/uni-app/drawImage.js +18 -0
- package/uni-app/ui-canvas.vue +10 -1
package/types/Geometry.d.ts
CHANGED
|
@@ -1,66 +1,133 @@
|
|
|
1
|
-
import GeometryResultType from './GeometryResult'
|
|
2
|
-
import GeometryOptionType from './GeometryOption'
|
|
3
|
-
|
|
4
|
-
export default interface GeometryType {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 配置对象
|
|
8
|
-
*/
|
|
9
|
-
config(option: GeometryOptionType): this
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
61
|
-
* @param
|
|
62
|
-
* @param
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
import GeometryResultType from './GeometryResult'
|
|
2
|
+
import GeometryOptionType from './GeometryOption'
|
|
3
|
+
|
|
4
|
+
export default interface GeometryType {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 配置对象
|
|
8
|
+
*/
|
|
9
|
+
config(option: GeometryOptionType): this
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 计算切割份数
|
|
13
|
+
* @param radius
|
|
14
|
+
* @param deg
|
|
15
|
+
*/
|
|
16
|
+
splitNum(radius: number, deg?: number): number
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 物体方向转换
|
|
20
|
+
* @param x1
|
|
21
|
+
* @param y1
|
|
22
|
+
* @param z1
|
|
23
|
+
* @param x2
|
|
24
|
+
* @param y2
|
|
25
|
+
* @param z2
|
|
26
|
+
*/
|
|
27
|
+
rotateLine(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number): (x: number, y: number, z: number, isNormal: boolean) => Array<number>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 棱柱水平部分
|
|
31
|
+
* @param x
|
|
32
|
+
* @param y
|
|
33
|
+
* @param z
|
|
34
|
+
* @param radius
|
|
35
|
+
* @param num
|
|
36
|
+
* @param d
|
|
37
|
+
* @param beginDeg
|
|
38
|
+
* @param deg
|
|
39
|
+
*/
|
|
40
|
+
prismHorizontal(x: number, y: number, z: number, radius: number, num: number, d: number, beginDeg?: number, deg?: number): Array<number>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 棱柱垂直部分
|
|
44
|
+
* @param x
|
|
45
|
+
* @param y
|
|
46
|
+
* @param z
|
|
47
|
+
* @param radius
|
|
48
|
+
* @param height
|
|
49
|
+
* @param num
|
|
50
|
+
* @param beginDeg
|
|
51
|
+
* @param deg
|
|
52
|
+
*/
|
|
53
|
+
prismVertical(x: number, y: number, z: number, radius: number, height: number, num: number, beginDeg?: number, deg?: number): Array<number>
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 球体中的一瓣子
|
|
57
|
+
* @param cx
|
|
58
|
+
* @param cy
|
|
59
|
+
* @param cz
|
|
60
|
+
* @param radius
|
|
61
|
+
* @param num
|
|
62
|
+
* @param index
|
|
63
|
+
*/
|
|
64
|
+
sphereFragment(cx: number, cy: number, cz: number, radius: number, num: number, index: number): Array<number>
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 饼柱体
|
|
68
|
+
* @param x
|
|
69
|
+
* @param y
|
|
70
|
+
* @param z
|
|
71
|
+
* @param radius
|
|
72
|
+
* @param height
|
|
73
|
+
* @param beginDeg
|
|
74
|
+
* @param deg
|
|
75
|
+
*/
|
|
76
|
+
pie(x: number, y: number, z: number, radius: number, height: number, beginDeg: number, deg: number): Array<GeometryResultType>
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 圆柱体
|
|
80
|
+
* @param x
|
|
81
|
+
* @param y
|
|
82
|
+
* @param z
|
|
83
|
+
* @param radius
|
|
84
|
+
* @param height
|
|
85
|
+
*/
|
|
86
|
+
cylinder(x: number, y: number, z: number, radius: number, height: number): Array<GeometryResultType>
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 圆柱体
|
|
90
|
+
* @param x
|
|
91
|
+
* @param y
|
|
92
|
+
* @param z
|
|
93
|
+
* @param radius
|
|
94
|
+
* @param x2
|
|
95
|
+
* @param y2
|
|
96
|
+
* @param z2
|
|
97
|
+
*/
|
|
98
|
+
cylinder(x: number, y: number, z: number, radius: number, x2: number, y2: number, z2: number): Array<GeometryResultType>
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 棱柱体
|
|
102
|
+
* @param x
|
|
103
|
+
* @param y
|
|
104
|
+
* @param z
|
|
105
|
+
* @param radius
|
|
106
|
+
* @param height
|
|
107
|
+
* @param num
|
|
108
|
+
*/
|
|
109
|
+
prism(x: number, y: number, z: number, radius: number, height: number, num: number): Array<GeometryResultType>
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 棱柱体
|
|
113
|
+
* @param x
|
|
114
|
+
* @param y
|
|
115
|
+
* @param z
|
|
116
|
+
* @param radius
|
|
117
|
+
* @param x2
|
|
118
|
+
* @param y2
|
|
119
|
+
* @param z2
|
|
120
|
+
* @param num
|
|
121
|
+
*/
|
|
122
|
+
prism(x: number, y: number, z: number, radius: number, x2: number, y2: number, z2: number, num: number): Array<GeometryResultType>
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 球体
|
|
126
|
+
* @param cx
|
|
127
|
+
* @param cy
|
|
128
|
+
* @param cz
|
|
129
|
+
* @param radius
|
|
130
|
+
*/
|
|
131
|
+
sphere(cx: number, cy: number, cz: number, radius: number): Array<GeometryResultType>
|
|
132
|
+
|
|
66
133
|
}
|
package/types/Object3D.d.ts
CHANGED
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import Matrix4Type from './Matrix4'
|
|
2
|
-
|
|
3
|
-
export type geometryType = "LINES" | "LINE_STRIP" | "LINE_LOOP" | "TRIANGLES" | "TRIANGLE_STRIP" | "TRIANGLE_FAN"
|
|
4
|
-
|
|
5
|
-
export interface meshType {
|
|
6
|
-
|
|
7
|
-
// 形状
|
|
8
|
-
geometry: {
|
|
9
|
-
attributes: {
|
|
10
|
-
|
|
11
|
-
// 点坐标
|
|
12
|
-
position: {
|
|
13
|
-
array: number[] | Float32Array
|
|
14
|
-
count: number
|
|
15
|
-
itemSize: number
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// 法向量
|
|
19
|
-
normal?: {
|
|
20
|
-
array: number[] | Float32Array
|
|
21
|
-
count: number
|
|
22
|
-
itemSize: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 纹理坐标
|
|
26
|
-
uv?: {
|
|
27
|
-
array: number[] | Float32Array
|
|
28
|
-
count: number
|
|
29
|
-
itemSize: number
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 索引
|
|
35
|
-
index?: {
|
|
36
|
-
array: number[] | Uint8Array
|
|
37
|
-
count: number
|
|
38
|
-
itemSize: number
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// 线、还是三角形
|
|
42
|
-
type: geometryType
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// 材质
|
|
46
|
-
material: {
|
|
47
|
-
|
|
48
|
-
// 单一的颜色
|
|
49
|
-
color?: {
|
|
50
|
-
r: number
|
|
51
|
-
g: number
|
|
52
|
-
b: number
|
|
53
|
-
alpha: number
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 多颜色
|
|
57
|
-
colors?: {
|
|
58
|
-
array: number[] | Float32Array
|
|
59
|
-
count: number
|
|
60
|
-
itemSize: number
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 立方体纹理
|
|
64
|
-
cube?: {
|
|
65
|
-
left?: {
|
|
66
|
-
image: {
|
|
67
|
-
value?: TexImageSource
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
right?: {
|
|
71
|
-
image: {
|
|
72
|
-
value?: TexImageSource
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
near?: {
|
|
76
|
-
image: {
|
|
77
|
-
value?: TexImageSource
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
far?: {
|
|
81
|
-
image: {
|
|
82
|
-
value?: TexImageSource
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
top?: {
|
|
86
|
-
image: {
|
|
87
|
-
value?: TexImageSource
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
bottom?: {
|
|
91
|
-
image: {
|
|
92
|
-
value?: TexImageSource
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// 二维纹理
|
|
98
|
-
image?: {
|
|
99
|
-
value?: TexImageSource
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export default interface Object3D {
|
|
106
|
-
|
|
107
|
-
// 区域名称,不设置或设置为空字符串,表示此区域无需记录
|
|
108
|
-
region?: string
|
|
109
|
-
|
|
110
|
-
// 变换矩阵
|
|
111
|
-
matrix?: Matrix4Type
|
|
112
|
-
|
|
113
|
-
// 图形
|
|
114
|
-
mesh: meshType[]
|
|
1
|
+
import Matrix4Type from './Matrix4'
|
|
2
|
+
|
|
3
|
+
export type geometryType = "LINES" | "LINE_STRIP" | "LINE_LOOP" | "TRIANGLES" | "TRIANGLE_STRIP" | "TRIANGLE_FAN"
|
|
4
|
+
|
|
5
|
+
export interface meshType {
|
|
6
|
+
|
|
7
|
+
// 形状
|
|
8
|
+
geometry: {
|
|
9
|
+
attributes: {
|
|
10
|
+
|
|
11
|
+
// 点坐标
|
|
12
|
+
position: {
|
|
13
|
+
array: number[] | Float32Array
|
|
14
|
+
count: number
|
|
15
|
+
itemSize: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 法向量
|
|
19
|
+
normal?: {
|
|
20
|
+
array: number[] | Float32Array
|
|
21
|
+
count: number
|
|
22
|
+
itemSize: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 纹理坐标
|
|
26
|
+
uv?: {
|
|
27
|
+
array: number[] | Float32Array
|
|
28
|
+
count: number
|
|
29
|
+
itemSize: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 索引
|
|
35
|
+
index?: {
|
|
36
|
+
array: number[] | Uint8Array
|
|
37
|
+
count: number
|
|
38
|
+
itemSize: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 线、还是三角形
|
|
42
|
+
type: geometryType
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 材质
|
|
46
|
+
material: {
|
|
47
|
+
|
|
48
|
+
// 单一的颜色
|
|
49
|
+
color?: {
|
|
50
|
+
r: number
|
|
51
|
+
g: number
|
|
52
|
+
b: number
|
|
53
|
+
alpha: number
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 多颜色
|
|
57
|
+
colors?: {
|
|
58
|
+
array: number[] | Float32Array
|
|
59
|
+
count: number
|
|
60
|
+
itemSize: number
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 立方体纹理
|
|
64
|
+
cube?: {
|
|
65
|
+
left?: {
|
|
66
|
+
image: {
|
|
67
|
+
value?: TexImageSource
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
right?: {
|
|
71
|
+
image: {
|
|
72
|
+
value?: TexImageSource
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
near?: {
|
|
76
|
+
image: {
|
|
77
|
+
value?: TexImageSource
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
far?: {
|
|
81
|
+
image: {
|
|
82
|
+
value?: TexImageSource
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
top?: {
|
|
86
|
+
image: {
|
|
87
|
+
value?: TexImageSource
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
bottom?: {
|
|
91
|
+
image: {
|
|
92
|
+
value?: TexImageSource
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 二维纹理
|
|
98
|
+
image?: {
|
|
99
|
+
value?: TexImageSource
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export default interface Object3D {
|
|
106
|
+
|
|
107
|
+
// 区域名称,不设置或设置为空字符串,表示此区域无需记录
|
|
108
|
+
region?: string
|
|
109
|
+
|
|
110
|
+
// 变换矩阵
|
|
111
|
+
matrix?: Matrix4Type
|
|
112
|
+
|
|
113
|
+
// 图形
|
|
114
|
+
mesh: meshType[]
|
|
115
115
|
}
|
package/types/Shader.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export default interface ShaderType {
|
|
2
|
-
|
|
3
|
-
program: WebGLProgram
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 使用这个程序
|
|
7
|
-
* (后于编译)
|
|
8
|
-
*/
|
|
9
|
-
use(): this
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 编译着色器程序
|
|
13
|
-
* @param vshaderSource 顶点着色器
|
|
14
|
-
* @param fshaderSource 片段(元)着色器
|
|
15
|
-
*/
|
|
16
|
-
compile(vshaderSource: string, fshaderSource: string): this
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 编译内置定义好的着色器程序
|
|
20
|
-
* @param shaderName 着色器名称,可选值有:color、colors、image、cube
|
|
21
|
-
*/
|
|
22
|
-
compile(shaderName: string): this
|
|
23
|
-
|
|
1
|
+
export default interface ShaderType {
|
|
2
|
+
|
|
3
|
+
program: WebGLProgram
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 使用这个程序
|
|
7
|
+
* (后于编译)
|
|
8
|
+
*/
|
|
9
|
+
use(): this
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 编译着色器程序
|
|
13
|
+
* @param vshaderSource 顶点着色器
|
|
14
|
+
* @param fshaderSource 片段(元)着色器
|
|
15
|
+
*/
|
|
16
|
+
compile(vshaderSource: string, fshaderSource: string): this
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 编译内置定义好的着色器程序
|
|
20
|
+
* @param shaderName 着色器名称,可选值有:color、colors、image、cube
|
|
21
|
+
*/
|
|
22
|
+
compile(shaderName: string): this
|
|
23
|
+
|
|
24
24
|
}
|
package/types/WebGLOption.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { WebGLmodeType } from "./getWebGLContext"
|
|
2
|
+
|
|
3
|
+
export default interface WebGLOptionType {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 是否支持区域管理,默认true
|
|
7
|
+
*/
|
|
8
|
+
region?: boolean
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 设置画布缩放模式,默认“scaleToFill“
|
|
12
|
+
*/
|
|
13
|
+
mode?: WebGLmodeType
|
|
14
|
+
|
|
8
15
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export type WebGLmodeType = "scaleToFill" | "aspectFit" | "aspectFill"
|
|
2
|
+
|
|
3
|
+
export default interface getWebGLContextType {
|
|
4
|
+
(el: HTMLElement | null, scale?: number, mode?: WebGLmodeType): WebGLRenderingContext
|
|
3
5
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function (_this, drawImage) {
|
|
2
|
+
return function (imgUrl, x, y, w, h) {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
if (/^http/.test(imgUrl)) {
|
|
5
|
+
uni.downloadFile({
|
|
6
|
+
url: imgUrl,
|
|
7
|
+
success: function (res) {
|
|
8
|
+
drawImage.call(_this, res.tempFilePath, x, y, w, h, true);
|
|
9
|
+
resolve({});
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
} else {
|
|
13
|
+
drawImage.call(_this, imgUrl, x, y, w, h, true);
|
|
14
|
+
resolve({});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
};
|
package/uni-app/ui-canvas.vue
CHANGED
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
</template>
|
|
87
87
|
<script>
|
|
88
88
|
import OralCanvas from "../lib/OralCanvas/index.es.js";
|
|
89
|
+
import drawImage from "./drawImage.js";
|
|
89
90
|
export default {
|
|
90
91
|
data() {
|
|
91
92
|
return {
|
|
@@ -98,6 +99,7 @@ export default {
|
|
|
98
99
|
// #ifndef H5
|
|
99
100
|
isH5: false,
|
|
100
101
|
// #endif
|
|
102
|
+
hadFetch:false
|
|
101
103
|
};
|
|
102
104
|
},
|
|
103
105
|
props: {
|
|
@@ -140,7 +142,7 @@ export default {
|
|
|
140
142
|
// #endif
|
|
141
143
|
|
|
142
144
|
// #ifdef MP-ALIPAY
|
|
143
|
-
painter.scale(2, 2);
|
|
145
|
+
if(!this.hadFetch) painter.scale(2, 2);
|
|
144
146
|
// #endif
|
|
145
147
|
|
|
146
148
|
let scaleSize = 1;
|
|
@@ -215,6 +217,8 @@ export default {
|
|
|
215
217
|
}
|
|
216
218
|
});
|
|
217
219
|
};
|
|
220
|
+
|
|
221
|
+
this.hadFetch = true;
|
|
218
222
|
return new Promise((resolve, reject) => {
|
|
219
223
|
this.help.instance.toDataURL = () => {
|
|
220
224
|
return new Promise((resolveUrl) => {
|
|
@@ -232,6 +236,11 @@ export default {
|
|
|
232
236
|
});
|
|
233
237
|
};
|
|
234
238
|
|
|
239
|
+
this.help.instance.drawImage = drawImage(
|
|
240
|
+
this.help.instance,
|
|
241
|
+
this.help.instance.drawImage
|
|
242
|
+
);
|
|
243
|
+
|
|
235
244
|
resolve(this.help.instance);
|
|
236
245
|
});
|
|
237
246
|
},
|