@pirireis/webglobeplugins 0.0.2 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -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[globe]) { cache[globe] = {} };
20
- if (!cache[globe][ProgramClass]) {
21
- cache[globe][ProgramClass] = {
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[globe][ProgramClass].program, firstObject);
27
+ globe.api_RegisterPlugin(cache.get(globe).get(ProgramClass).program, firstObject);
27
28
  } else {
28
- cache[globe][ProgramClass].count++;
29
+ cache.get(globe).get(ProgramClass).count++;
29
30
  }
30
- return cache[globe][ProgramClass].program;
31
+ return cache.get(globe).get(ProgramClass).program;
31
32
  };
32
33
 
33
34
  function releaseProgram(globe, ProgramClass) {
34
- if (cache[globe] && cache[globe][ProgramClass]) {
35
- cache[globe][ProgramClass].count--;
36
- if (cache[globe][ProgramClass].count === 0) {
37
- globe.api_UnRegisterPlugin(cache[globe][ProgramClass].program.id); // it calls program.free()
38
- delete cache[globe][ProgramClass];
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[gl]) { cache[gl] = {} };
56
- if (!cache[gl][ProgramClass]) {
57
- cache[gl][ProgramClass] = {
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[gl][ProgramClass].count++;
64
+ cache.get(gl).get(ProgramClass).count++;
63
65
  }
64
- return cache[gl][ProgramClass].program;
66
+ return cache.get(gl).get(ProgramClass).program;
65
67
  };
66
68
 
67
69
  function releaseProgram(gl, ProgramClass) {
68
- if (cache[gl] && cache[gl][ProgramClass]) {
69
- cache[gl][ProgramClass].count--;
70
- if (cache[gl][ProgramClass].count === 0) {
71
- cache[gl][ProgramClass].program.free();
72
- delete cache[gl][ProgramClass];
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[globe]) { cache[globe] = {} };
91
- if (!cache[globe][ProgramClass]) {
92
- cache[globe][ProgramClass] = {
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[globe][ProgramClass].count++;
99
+ cache.get(globe).get(ProgramClass).count++;
98
100
  }
99
- return cache[globe][ProgramClass].program;
100
- }
101
+ return cache.get(globe).get(ProgramClass).program;
102
+ };
101
103
 
102
104
  function releaseProgram(globe, ProgramClass) {
103
- if (cache[globe] && cache[globe][ProgramClass]) {
104
- cache[globe][ProgramClass].count--;
105
- if (cache[globe][ProgramClass].count === 0) {
106
- cache[globe][ProgramClass].program.free();
107
- delete cache[globe][ProgramClass];
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
@@ -126,4 +126,3 @@ export default class
126
126
  }
127
127
  }
128
128
  }
129
-
@@ -24,7 +24,7 @@ const { CircleFlatProgram, PaddyFlatProgram, CirclePaddySharedBuffer } = rings;
24
24
 
25
25
  export default class {
26
26
 
27
- constructor(id, padCount = 12, compass = 0, circleEdgeCount = 72) {
27
+ constructor(id, padCount = 12, compass = 1, circleEdgeCount = 72) {
28
28
  this.id = id;
29
29
  this.compass = compass;
30
30
  this.padCount = padCount;
@@ -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
+