@pirireis/webglobeplugins 0.0.3 → 0.0.4
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
package/programs/programcache.js
CHANGED
|
@@ -14,28 +14,29 @@
|
|
|
14
14
|
|
|
15
15
|
const globeProgramCache = (function () {
|
|
16
16
|
|
|
17
|
-
const cache =
|
|
17
|
+
const cache = new Map();
|
|
18
|
+
|
|
18
19
|
function getProgram(globe, ProgramClass) {
|
|
19
|
-
if (!cache
|
|
20
|
-
if (!cache
|
|
21
|
-
cache
|
|
20
|
+
if (!cache.has(globe)) { cache.set(globe, new Map()) };
|
|
21
|
+
if (!cache.get(globe).has(ProgramClass)) {
|
|
22
|
+
cache.get(globe).set(ProgramClass, {
|
|
22
23
|
program: new ProgramClass(),
|
|
23
24
|
count: 1
|
|
24
|
-
}
|
|
25
|
+
})
|
|
25
26
|
const firstObject = globe.DrawOrder.GetObj(0)
|
|
26
|
-
globe.api_RegisterPlugin(cache
|
|
27
|
+
globe.api_RegisterPlugin(cache.get(globe).get(ProgramClass).program, firstObject);
|
|
27
28
|
} else {
|
|
28
|
-
cache
|
|
29
|
+
cache.get(globe).get(ProgramClass).count++;
|
|
29
30
|
}
|
|
30
|
-
return cache
|
|
31
|
+
return cache.get(globe).get(ProgramClass).program;
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
function releaseProgram(globe, ProgramClass) {
|
|
34
|
-
if (cache
|
|
35
|
-
cache
|
|
36
|
-
if (cache
|
|
37
|
-
globe.api_UnRegisterPlugin(cache
|
|
38
|
-
|
|
35
|
+
if (cache.has(globe) && cache.get(globe).has(ProgramClass)) {
|
|
36
|
+
cache.get(globe).get(ProgramClass).count--;
|
|
37
|
+
if (cache.get(globe).get(ProgramClass).count === 0) {
|
|
38
|
+
globe.api_UnRegisterPlugin(cache.get(globe).get(ProgramClass).program.id); // it calls program.free()
|
|
39
|
+
cache.get(globe).delete(ProgramClass);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
};
|
|
@@ -50,26 +51,27 @@ const globeProgramCache = (function () {
|
|
|
50
51
|
|
|
51
52
|
const glProgramCache = (function () {
|
|
52
53
|
|
|
53
|
-
const cache =
|
|
54
|
+
const cache = new Map();
|
|
55
|
+
|
|
54
56
|
function getProgram(gl, ProgramClass) {
|
|
55
|
-
if (!cache
|
|
56
|
-
if (!cache
|
|
57
|
-
cache
|
|
57
|
+
if (!cache.has(gl)) { cache.set(gl, new Map()) };
|
|
58
|
+
if (!cache.get(gl).has(ProgramClass)) {
|
|
59
|
+
cache.get(gl).set(ProgramClass, {
|
|
58
60
|
program: new ProgramClass(gl),
|
|
59
61
|
count: 1
|
|
60
|
-
}
|
|
62
|
+
})
|
|
61
63
|
} else {
|
|
62
|
-
cache
|
|
64
|
+
cache.get(gl).get(ProgramClass).count++;
|
|
63
65
|
}
|
|
64
|
-
return cache
|
|
66
|
+
return cache.get(gl).get(ProgramClass).program;
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
function releaseProgram(gl, ProgramClass) {
|
|
68
|
-
if (cache
|
|
69
|
-
cache
|
|
70
|
-
if (cache
|
|
71
|
-
cache
|
|
72
|
-
|
|
70
|
+
if (cache.has(gl) && cache.get(gl).has(ProgramClass)) {
|
|
71
|
+
cache.get(gl).get(ProgramClass).count--;
|
|
72
|
+
if (cache.get(gl).get(ProgramClass).count === 0) {
|
|
73
|
+
cache.get(gl).get(ProgramClass).program.free();
|
|
74
|
+
cache.get(gl).delete(ProgramClass);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
};
|
|
@@ -84,31 +86,32 @@ const glProgramCache = (function () {
|
|
|
84
86
|
|
|
85
87
|
const noRegisterGlobeProgramCache = (function () {
|
|
86
88
|
|
|
87
|
-
const cache =
|
|
89
|
+
const cache = new Map();
|
|
88
90
|
|
|
89
91
|
function getProgram(globe, ProgramClass) {
|
|
90
|
-
if (!cache
|
|
91
|
-
if (!cache
|
|
92
|
-
cache
|
|
92
|
+
if (!cache.has(globe)) { cache.set(globe, new Map()) };
|
|
93
|
+
if (!cache.get(globe).has(ProgramClass)) {
|
|
94
|
+
cache.get(globe).set(ProgramClass, {
|
|
93
95
|
program: new ProgramClass(globe),
|
|
94
96
|
count: 1
|
|
95
|
-
}
|
|
97
|
+
})
|
|
96
98
|
} else {
|
|
97
|
-
cache
|
|
99
|
+
cache.get(globe).get(ProgramClass).count++;
|
|
98
100
|
}
|
|
99
|
-
return cache
|
|
100
|
-
}
|
|
101
|
+
return cache.get(globe).get(ProgramClass).program;
|
|
102
|
+
};
|
|
101
103
|
|
|
102
104
|
function releaseProgram(globe, ProgramClass) {
|
|
103
|
-
if (cache
|
|
104
|
-
cache
|
|
105
|
-
if (cache
|
|
106
|
-
cache
|
|
107
|
-
|
|
105
|
+
if (cache.has(globe) && cache.get(globe).has(ProgramClass)) {
|
|
106
|
+
cache.get(globe).get(ProgramClass).count--;
|
|
107
|
+
if (cache.get(globe).get(ProgramClass).count === 0) {
|
|
108
|
+
cache.get(globe).get(ProgramClass).program.free();
|
|
109
|
+
cache.get(globe).delete(ProgramClass);
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
|
114
|
+
|
|
112
115
|
return Object.freeze({
|
|
113
116
|
getProgram,
|
|
114
117
|
releaseProgram
|
|
@@ -64,7 +64,11 @@ vec4 mercatorXYTo2DPoint( vec2 position) { // projection, translate, mapWH, scre
|
|
|
64
64
|
}
|
|
65
65
|
`;
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
export const cartesian3DToGLPosition = `
|
|
68
|
+
vec4 cartesian3DToGLPosition( vec3 position) {
|
|
69
|
+
return projection * view * vec4(position - translate, 1.0);
|
|
70
|
+
}
|
|
71
|
+
`
|
|
68
72
|
|
|
69
73
|
|
|
70
74
|
// pi / pole = 2 / R
|
|
@@ -127,3 +131,5 @@ vec2 circleLimpFromLongLatRadCenterMercatorCompass(vec2 center, float radius, fl
|
|
|
127
131
|
float x = cos(angle) * radius + center_.x;
|
|
128
132
|
return vec2(x, y);
|
|
129
133
|
}`;
|
|
134
|
+
|
|
135
|
+
|