@pirireis/webglobeplugins 0.13.0-alpha → 0.14.0-alpha
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/Math/arc-cdf-points.js +20 -0
- package/Math/arc-generate-points copy.js +1 -0
- package/Math/arc.js +21 -8
- package/Math/circle.js +35 -16
- package/Math/templete-shapes/grid-visually-equal.js +66 -0
- package/altitude-locator/plugin.js +3 -2
- package/bearing-line/plugin.js +1 -2
- package/circle-line-chain/plugin.js +4 -7
- package/compass-rose/compass-rose-padding-flat.js +12 -0
- package/package.json +1 -1
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
- package/programs/line-on-globe/linestrip/linestrip.js +5 -3
- package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
- package/programs/picking/pickable-renderer.js +1 -2
- package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
- package/programs/rings/partial-ring/piece-of-pie.js +26 -13
- package/programs/totems/camerauniformblock.js +1 -1
- package/programs/totems/index.js +1 -1
- package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
- package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
- package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
- package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
- package/range-tools-on-terrain/circle-line-chain/plugin.js +389 -0
- package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
- package/range-tools-on-terrain/range-ring/adapters.js +25 -0
- package/range-tools-on-terrain/range-ring/plugin.js +31 -0
- package/range-tools-on-terrain/range-ring/types.js +1 -0
- package/rangerings/plugin.js +7 -11
- package/semiplugins/lightweight/line-plugin.js +195 -0
- package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
- package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
- package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +67 -38
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +96 -0
- package/semiplugins/type.js +1 -0
- package/types.js +0 -11
- package/util/account/create-buffermap-orchastration.js +39 -0
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
- package/util/check/typecheck.js +15 -1
- package/util/geometry/index.js +3 -2
- package/util/gl-util/buffer/attribute-loader.js +2 -5
- package/util/gl-util/draw-options/methods.js +4 -5
- package/util/webglobjectbuilders.js +4 -9
- package/write-text/context-text3.js +17 -0
- package/write-text/context-text3old.js +152 -0
- package/programs/line-on-globe/circle-accurate.js +0 -176
- package/programs/line-on-globe/circle.js +0 -166
- package/programs/line-on-globe/to-the-surface.js +0 -111
- package/programs/totems/canvas-webglobe-info1.js +0 -106
- package/shape-on-terrain/arc/naive/plugin.js +0 -250
- package/util/check/get.js +0 -14
- package/util/gl-util/buffer/types.js +0 -1
- package/util/gl-util/draw-options/types.js +0 -15
- package/util/webglobjectbuilders1.js +0 -219
- /package/{shape-on-terrain/type.js → range-tools-on-terrain/bearing-line/types.js} +0 -0
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
// export function createShader(gl, type, source) {
|
|
2
|
-
// const shader = gl.createShader(type);
|
|
3
|
-
// gl.shaderSource(shader, source);
|
|
4
|
-
// gl.compileShader(shader);
|
|
5
|
-
// if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
6
|
-
// throw new Error(gl.getShaderInfoLog(shader));
|
|
7
|
-
// }
|
|
8
|
-
// return shader;
|
|
9
|
-
// }
|
|
10
|
-
export function createShader(gl, type, source) {
|
|
11
|
-
const shader = gl.createShader(type);
|
|
12
|
-
gl.shaderSource(shader, source);
|
|
13
|
-
gl.compileShader(shader);
|
|
14
|
-
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
15
|
-
const errorLog = gl.getShaderInfoLog(shader);
|
|
16
|
-
const shaderType = type === gl.VERTEX_SHADER ? 'VERTEX_SHADER' : 'FRAGMENT_SHADER';
|
|
17
|
-
const sourceWithLineNumbers = source.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
|
|
18
|
-
throw new Error(`Error compiling ${shaderType}:\n${errorLog}\nSource:\n${sourceWithLineNumbers}`);
|
|
19
|
-
}
|
|
20
|
-
return shader;
|
|
21
|
-
}
|
|
22
|
-
export function createProgram(gl, vertexSource, fragmentSource) {
|
|
23
|
-
const program = gl.createProgram();
|
|
24
|
-
const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
25
|
-
const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
26
|
-
gl.compileShader(vertexShader);
|
|
27
|
-
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
|
|
28
|
-
console.error(gl.getShaderInfoLog(vertexShader));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
gl.compileShader(fragmentShader);
|
|
32
|
-
if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
|
|
33
|
-
console.error(gl.getShaderInfoLog(fragmentShader));
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
gl.attachShader(program, vertexShader);
|
|
37
|
-
gl.attachShader(program, fragmentShader);
|
|
38
|
-
gl.linkProgram(program);
|
|
39
|
-
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
40
|
-
console.error(gl.getProgramInfoLog(program));
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
return program;
|
|
44
|
-
}
|
|
45
|
-
export function createProgramWrapper(gl, vertexSource, fragmentSource) {
|
|
46
|
-
const program = gl.createProgram();
|
|
47
|
-
const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
|
|
48
|
-
const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
|
|
49
|
-
gl.attachShader(program, vertexShader);
|
|
50
|
-
gl.attachShader(program, fragmentShader);
|
|
51
|
-
gl.linkProgram(program);
|
|
52
|
-
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
53
|
-
// console.log(gl.getProgramInfoLog(program));
|
|
54
|
-
throw new Error(gl.getProgramInfoLog(program));
|
|
55
|
-
}
|
|
56
|
-
const wrapper = { program: program };
|
|
57
|
-
const numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
|
|
58
|
-
for (let i = 0; i < numAttributes; i++) {
|
|
59
|
-
const attribute = gl.getActiveAttrib(program, i);
|
|
60
|
-
wrapper[attribute.name] = gl.getAttribLocation(program, attribute.name);
|
|
61
|
-
}
|
|
62
|
-
const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
|
|
63
|
-
for (let i = 0; i < numUniforms; i++) {
|
|
64
|
-
const uniform = gl.getActiveUniform(program, i);
|
|
65
|
-
wrapper[uniform.name] = gl.getUniformLocation(program, uniform.name);
|
|
66
|
-
}
|
|
67
|
-
return wrapper;
|
|
68
|
-
}
|
|
69
|
-
export function createTexture(gl, filter, data, width, height) {
|
|
70
|
-
const texture = gl.createTexture();
|
|
71
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
72
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
73
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
74
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
|
|
75
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
|
|
76
|
-
if (data instanceof Uint8Array) {
|
|
77
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);
|
|
81
|
-
}
|
|
82
|
-
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
83
|
-
return texture;
|
|
84
|
-
}
|
|
85
|
-
export function bindTexture(gl, texture, unit) {
|
|
86
|
-
gl.activeTexture(gl.TEXTURE0 + unit);
|
|
87
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
88
|
-
}
|
|
89
|
-
export function createBuffer(gl, data) {
|
|
90
|
-
const buffer = gl.createBuffer();
|
|
91
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
92
|
-
gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
|
|
93
|
-
return buffer;
|
|
94
|
-
}
|
|
95
|
-
export function bindAttribute(gl, buffer, attribute, numComponents) {
|
|
96
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
97
|
-
gl.enableVertexAttribArray(attribute);
|
|
98
|
-
gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
|
|
99
|
-
}
|
|
100
|
-
export function bindFramebuffer(gl, framebuffer, texture) {
|
|
101
|
-
if (texture) {
|
|
102
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
103
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export function decodeBase64(data) {
|
|
110
|
-
const binary_string = atob(data);
|
|
111
|
-
const len = binary_string.length;
|
|
112
|
-
const bytes = new Uint8Array(len);
|
|
113
|
-
for (let i = 0; i < len; i++) {
|
|
114
|
-
bytes[i] = binary_string.charCodeAt(i);
|
|
115
|
-
}
|
|
116
|
-
return bytes;
|
|
117
|
-
}
|
|
118
|
-
export function createImageFromBase64(encodedData) {
|
|
119
|
-
const bytes = decodeBase64(encodedData);
|
|
120
|
-
const blob = new Blob([bytes.buffer], { type: "image/png" });
|
|
121
|
-
const urlCreator = window.URL || window.webkitURL;
|
|
122
|
-
const imageUrl = urlCreator.createObjectURL(blob);
|
|
123
|
-
const image = new Image();
|
|
124
|
-
image.src = imageUrl;
|
|
125
|
-
return image;
|
|
126
|
-
}
|
|
127
|
-
export function getColorRamp(colors) {
|
|
128
|
-
// console.log("getColorRamp", colors)
|
|
129
|
-
const canvas = document.createElement('canvas');
|
|
130
|
-
const ctx = canvas.getContext('2d');
|
|
131
|
-
canvas.width = 256;
|
|
132
|
-
canvas.height = 1;
|
|
133
|
-
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
134
|
-
for (const stop in colors) {
|
|
135
|
-
// console.log("stop", stop);
|
|
136
|
-
gradient.addColorStop(colors[stop][0], colors[stop][1]);
|
|
137
|
-
// Alttaki satir ile gradienti cevirip, shaderda ki `speed_t = 1.0 - speed_t`' kaldirdim.
|
|
138
|
-
// gradientin en dusuk olmasi gereken siyah - mavi aralikta, mor renk gozlemledim.
|
|
139
|
-
// gradient.addColorStop( 1.0 - colors[stop][0], colors[stop][1]);
|
|
140
|
-
}
|
|
141
|
-
ctx.fillStyle = gradient;
|
|
142
|
-
ctx.fillRect(0, 0, 256, 1);
|
|
143
|
-
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
144
|
-
}
|
|
145
|
-
export function getColorRampDiscrate(values, thresholds) {
|
|
146
|
-
const canvas = document.createElement('canvas');
|
|
147
|
-
const ctx = canvas.getContext('2d');
|
|
148
|
-
canvas.width = 256;
|
|
149
|
-
canvas.height = 1;
|
|
150
|
-
const gap = 1.0 / 256;
|
|
151
|
-
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
152
|
-
for (let i = 0; i < thresholds.length - 1; i++) {
|
|
153
|
-
gradient.addColorStop(thresholds[i], values[i]);
|
|
154
|
-
gradient.addColorStop(thresholds[i + 1] - gap, values[i]);
|
|
155
|
-
}
|
|
156
|
-
gradient.addColorStop(thresholds[thresholds.length - 1], values[values.length - 1]);
|
|
157
|
-
ctx.fillStyle = gradient;
|
|
158
|
-
ctx.fillRect(0, 0, 256, 1);
|
|
159
|
-
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
160
|
-
}
|
|
161
|
-
export function getColorRampInterpolated(values, thresholds) {
|
|
162
|
-
const canvas = document.createElement('canvas');
|
|
163
|
-
const ctx = canvas.getContext('2d');
|
|
164
|
-
canvas.width = 256;
|
|
165
|
-
canvas.height = 1;
|
|
166
|
-
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
167
|
-
// const gap = 1.0 / 256;
|
|
168
|
-
// gradient.addColorStop(thresholds[0], values[0]);
|
|
169
|
-
// gradient.addColorStop(thresholds[0] + gap, values[1]);
|
|
170
|
-
for (let i = 0; i < thresholds.length; i++) {
|
|
171
|
-
gradient.addColorStop(thresholds[i], values[i]);
|
|
172
|
-
}
|
|
173
|
-
// gradient.addColorStop(thresholds[thresholds.length - 1] - gap, values[values.length - 1]);
|
|
174
|
-
ctx.fillStyle = gradient;
|
|
175
|
-
ctx.fillRect(0, 0, 256, 1);
|
|
176
|
-
return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* values: n + 1 number of color hex values without alpha channel. Ex: ["#ff0000", "#00ff00", "#0000ff"]
|
|
180
|
-
* thresholds: n number of thresholds. Ex: [0, 10, 20]
|
|
181
|
-
* mode: [discrete, interpolated,]
|
|
182
|
-
*/
|
|
183
|
-
export function getColorRampModed(values, thresholds, mode = "interpolated") {
|
|
184
|
-
if (mode === "discrete") {
|
|
185
|
-
return getColorRampDiscrate(values, thresholds);
|
|
186
|
-
}
|
|
187
|
-
else if (mode === "interpolated") {
|
|
188
|
-
return getColorRampInterpolated(values, thresholds);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
throw new Error("mode is not valid");
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
export function defaultColorRamp() {
|
|
195
|
-
const defaultRampColors = [
|
|
196
|
-
[0.0, '#5e4fa2'],
|
|
197
|
-
[0.15, '#3288bd'],
|
|
198
|
-
[0.20, '#66c2a5'],
|
|
199
|
-
[0.25, '#66c2a5'],
|
|
200
|
-
[0.3, '#abdda4'],
|
|
201
|
-
[0.4, '#e6f598'],
|
|
202
|
-
[0.5, '#fee08b'],
|
|
203
|
-
[0.6, '#fdae61'],
|
|
204
|
-
[0.7, '#f46d43'],
|
|
205
|
-
[1.0, '#ff1e13']
|
|
206
|
-
];
|
|
207
|
-
return getColorRamp(defaultRampColors);
|
|
208
|
-
}
|
|
209
|
-
export function reloadCurrentGLProgram() {
|
|
210
|
-
return function (target, key, descriptor) {
|
|
211
|
-
const originalMethod = descriptor.value;
|
|
212
|
-
descriptor.value = function () {
|
|
213
|
-
const gl = target.gl;
|
|
214
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
215
|
-
originalMethod.apply(this, arguments);
|
|
216
|
-
gl.useProgram(currentProgram);
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
}
|
|
File without changes
|