@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,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// TODO: Delete this file if it is not needed anymore.
|
|
3
|
-
// import { createProgram } from "../../util/webglobjectbuilders";
|
|
4
|
-
// import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/camerauniformblock";
|
|
5
|
-
// import { noRegisterGlobeProgramCache } from "../programcache";
|
|
6
|
-
// import { vaoAttributeLoader } from "../../util/account/util";
|
|
7
|
-
// import {
|
|
8
|
-
// longLatRadToMercator, longLatRadToCartesian3D, cartesian3DToGLPosition, mercatorXYToGLPosition, realDistanceOnSphereR1,
|
|
9
|
-
// circleLimpFromLongLatRadCenterCartesian3D,
|
|
10
|
-
// circleLimpFromLongLatRadCenterMercatorCompass,
|
|
11
|
-
// circleLimpFromLongLatRadCenterMercatorRealDistance,
|
|
12
|
-
// POLE
|
|
13
|
-
// } from "../../util/shaderfunctions/geometrytransformations";
|
|
14
|
-
// /**
|
|
15
|
-
// * TODO:
|
|
16
|
-
// * 1. integrate geometry functions for radius angle and center
|
|
17
|
-
// * 2. integrate attributes
|
|
18
|
-
// *
|
|
19
|
-
// * TODO:
|
|
20
|
-
// * center_position is too small or doenst loaded as expected.
|
|
21
|
-
// */
|
|
22
|
-
// const EDGE_COUNT_ON_SPHERE = 360;
|
|
23
|
-
// const vertexShaderSource = `#version 300 es
|
|
24
|
-
// precision highp float;
|
|
25
|
-
// ${CameraUniformBlockString}
|
|
26
|
-
// ${longLatRadToMercator}
|
|
27
|
-
// ${longLatRadToCartesian3D}
|
|
28
|
-
// ${cartesian3DToGLPosition}
|
|
29
|
-
// ${mercatorXYToGLPosition}
|
|
30
|
-
// ${realDistanceOnSphereR1}
|
|
31
|
-
// ${circleLimpFromLongLatRadCenterCartesian3D}
|
|
32
|
-
// ${circleLimpFromLongLatRadCenterMercatorCompass}
|
|
33
|
-
// ${circleLimpFromLongLatRadCenterMercatorRealDistance}
|
|
34
|
-
// uniform float edge_count;
|
|
35
|
-
// in vec2 center_position;
|
|
36
|
-
// in float radius;
|
|
37
|
-
// in vec4 color;
|
|
38
|
-
// in float dash_ratio;
|
|
39
|
-
// in float dash_opacity;
|
|
40
|
-
// out float interpolation;
|
|
41
|
-
// out vec4 v_color;
|
|
42
|
-
// out float v_dash_ratio;
|
|
43
|
-
// out float v_dash_opacity;
|
|
44
|
-
// out vec2 v_limp;
|
|
45
|
-
// void main() {
|
|
46
|
-
// interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
|
|
47
|
-
// float angle = PI * 2.0 * interpolation;
|
|
48
|
-
// if ( is3D ) {
|
|
49
|
-
// vec3 position = circleLimpFromLongLatRadCenterCartesian3D( center_position, radius, angle);
|
|
50
|
-
// gl_Position = cartesian3DToGLPosition(position);
|
|
51
|
-
// v_limp = vec2(0.0, 0.0);
|
|
52
|
-
// } else {
|
|
53
|
-
// vec2 position;
|
|
54
|
-
// if (radius < 1400.0) {
|
|
55
|
-
// position = circleLimpFromLongLatRadCenterMercatorCompass( center_position, radius/ cos(center_position.y), angle);
|
|
56
|
-
// } else {
|
|
57
|
-
// position = circleLimpFromLongLatRadCenterMercatorRealDistance( center_position, radius, angle);
|
|
58
|
-
// }
|
|
59
|
-
// v_limp = position;
|
|
60
|
-
// gl_Position = mercatorXYToGLPosition( position);
|
|
61
|
-
// }
|
|
62
|
-
// v_dash_ratio = dash_ratio;
|
|
63
|
-
// v_dash_opacity = dash_opacity;
|
|
64
|
-
// v_color = color;
|
|
65
|
-
// }`
|
|
66
|
-
// const fragmentShaderSource = `#version 300 es
|
|
67
|
-
// ${POLE}
|
|
68
|
-
// precision highp float;
|
|
69
|
-
// uniform float opacity;
|
|
70
|
-
// in vec4 v_color;
|
|
71
|
-
// in float v_dash_ratio;
|
|
72
|
-
// in float v_dash_opacity;
|
|
73
|
-
// in float interpolation;
|
|
74
|
-
// in vec2 v_limp;
|
|
75
|
-
// out vec4 color;
|
|
76
|
-
// void main() {
|
|
77
|
-
// if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ color = vec4(0.0,0.0,0.0,0.0); return; }
|
|
78
|
-
// color = v_color;
|
|
79
|
-
// color.a *= opacity;
|
|
80
|
-
// if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
|
|
81
|
-
// if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
|
|
82
|
-
// color.a *= v_dash_opacity;
|
|
83
|
-
// }
|
|
84
|
-
// }
|
|
85
|
-
// `;
|
|
86
|
-
// class Logic {
|
|
87
|
-
// constructor(globe) {
|
|
88
|
-
// this.globe = globe;
|
|
89
|
-
// this.gl = globe.gl;
|
|
90
|
-
// this._lastOpacity = 1.0;
|
|
91
|
-
// this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
|
|
92
|
-
// const { gl, program } = this;
|
|
93
|
-
// this.program.uniforms = {
|
|
94
|
-
// opacity: gl.getUniformLocation(program, "opacity")
|
|
95
|
-
// };
|
|
96
|
-
// { // initial uniform values
|
|
97
|
-
// const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
98
|
-
// gl.useProgram(program);
|
|
99
|
-
// gl.uniform1f(program.uniforms.opacity, 1.0);
|
|
100
|
-
// gl.useProgram(currentProgram);
|
|
101
|
-
// }
|
|
102
|
-
// { // assign attribute locations
|
|
103
|
-
// gl.bindAttribLocation(program, 0, "center_position");
|
|
104
|
-
// gl.bindAttribLocation(program, 1, "radius");
|
|
105
|
-
// gl.bindAttribLocation(program, 2, "color");
|
|
106
|
-
// gl.bindAttribLocation(program, 3, "dash_ratio");
|
|
107
|
-
// gl.bindAttribLocation(program, 4, "dash_opacity");
|
|
108
|
-
// }
|
|
109
|
-
// this.cameraBindingPoint = 0;
|
|
110
|
-
// this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
|
|
111
|
-
// const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
|
|
112
|
-
// gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
|
|
113
|
-
// }
|
|
114
|
-
// createVAO(centerObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj) {
|
|
115
|
-
// const { gl } = this;
|
|
116
|
-
// const vao = gl.createVertexArray();
|
|
117
|
-
// const divisor = 1;
|
|
118
|
-
// gl.bindVertexArray(vao);
|
|
119
|
-
// { // make this a function end import from account module.
|
|
120
|
-
// const { buffer, stride = 0, offset = 0 } = centerObj;
|
|
121
|
-
// vaoAttributeLoader(gl, buffer, 0, 2, stride, offset, divisor);
|
|
122
|
-
// }
|
|
123
|
-
// {
|
|
124
|
-
// const { buffer, stride = 0, offset = 0 } = radiusObj;
|
|
125
|
-
// vaoAttributeLoader(gl, buffer, 1, 1, stride, offset, divisor);
|
|
126
|
-
// }
|
|
127
|
-
// {
|
|
128
|
-
// const { buffer, stride = 0, offset = 0 } = colorObj;
|
|
129
|
-
// vaoAttributeLoader(gl, buffer, 2, 4, stride, offset, divisor);
|
|
130
|
-
// }
|
|
131
|
-
// {
|
|
132
|
-
// const { buffer, stride = 0, offset = 0 } = dashRatioObj;
|
|
133
|
-
// vaoAttributeLoader(gl, buffer, 3, 1, stride, offset, divisor);
|
|
134
|
-
// }
|
|
135
|
-
// {
|
|
136
|
-
// const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
|
|
137
|
-
// vaoAttributeLoader(gl, buffer, 4, 1, stride, offset, divisor);
|
|
138
|
-
// }
|
|
139
|
-
// gl.bindVertexArray(null);
|
|
140
|
-
// gl.bindVertexArray(null);
|
|
141
|
-
// return vao;
|
|
142
|
-
// }
|
|
143
|
-
// draw(vao, length, opacity) {
|
|
144
|
-
// const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
|
|
145
|
-
// gl.useProgram(program);
|
|
146
|
-
// if (this._lastOpacity !== opacity) {
|
|
147
|
-
// gl.uniform1f(program.uniforms.opacity, opacity);
|
|
148
|
-
// this._lastOpacity = opacity;
|
|
149
|
-
// }
|
|
150
|
-
// gl.bindVertexArray(vao);
|
|
151
|
-
// cameraBlockTotem.bind(cameraBindingPoint);
|
|
152
|
-
// gl.drawArraysInstanced(gl.LINE_STRIP, 0, EDGE_COUNT_ON_SPHERE + 1, length);
|
|
153
|
-
// cameraBlockTotem.unbind(cameraBindingPoint);
|
|
154
|
-
// gl.bindVertexArray(null);
|
|
155
|
-
// }
|
|
156
|
-
// free() {
|
|
157
|
-
// if (this.isFreed) return;
|
|
158
|
-
// CameraUniformBlockTotemCache.release(this.globe);
|
|
159
|
-
// this.gl.deleteProgram(this.program);
|
|
160
|
-
// this.isFreed = true;
|
|
161
|
-
// }
|
|
162
|
-
// }
|
|
163
|
-
// export const CircleCache = Object.freeze({
|
|
164
|
-
// get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
|
|
165
|
-
// release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
|
|
166
|
-
// });
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// TODO: Delete this file if it is not needed anymore.
|
|
3
|
-
// import { createProgram } from './util'
|
|
4
|
-
// import { CameraUniformBlockTotemCache, CameraUniformBlockString } from '../totems';
|
|
5
|
-
// import { cartesian3DToGLPosition, R_3D } from '../../util/shaderfunctions/geometrytransformations';
|
|
6
|
-
// import { noRegisterGlobeProgramCache } from '../programcache';
|
|
7
|
-
// import { attributeLoader } from '../../util/gl-util/buffer/attribute-loader';
|
|
8
|
-
// import '../draw-options/types';
|
|
9
|
-
// import { drawInstanced } from '../draw-options/methods';
|
|
10
|
-
// const vs = `#version 300 es
|
|
11
|
-
// ${R_3D}
|
|
12
|
-
// ${CameraUniformBlockString}
|
|
13
|
-
// ${cartesian3DToGLPosition}
|
|
14
|
-
// in vec3 pos3D
|
|
15
|
-
// in vec4 color;
|
|
16
|
-
// out float ratio;
|
|
17
|
-
// out flat vec4 vColor;
|
|
18
|
-
// void main(){
|
|
19
|
-
// if ( gl_VertexID == 0) {
|
|
20
|
-
// gl_Position = cartesian3DToGLPosition(pos3D);
|
|
21
|
-
// ratio =0.0;
|
|
22
|
-
// } else {
|
|
23
|
-
// vec3 sea_level_pos3D = norm(pos3D) * R_3D;
|
|
24
|
-
// gl_Position = cartesian3DToGLPosition(pos3D);
|
|
25
|
-
// ratio = 1.0;
|
|
26
|
-
// }
|
|
27
|
-
// vColor = color;
|
|
28
|
-
// }`;
|
|
29
|
-
// const fs = `#version 300 es
|
|
30
|
-
// uniform float opacity;
|
|
31
|
-
// uniform float phase;
|
|
32
|
-
// uniform float fadeOpacity;
|
|
33
|
-
// in flat vec4 vColor;
|
|
34
|
-
// in float ratio;
|
|
35
|
-
// out vec4 fragColor;
|
|
36
|
-
// void main(){
|
|
37
|
-
// fragColor = vec4( vColor.rgb, vColor.a * opacity);
|
|
38
|
-
// if (fadeOpacity < 1.0) {
|
|
39
|
-
// float alpha= mix( fadeOpacity, vColor.a, fract( ratio + phase ));
|
|
40
|
-
// fragColor.a *= alpha;
|
|
41
|
-
// }
|
|
42
|
-
// }`;
|
|
43
|
-
// class Logic {
|
|
44
|
-
// constructor(globe) {
|
|
45
|
-
// this.globe = globe;
|
|
46
|
-
// this.gl = globe.gl;
|
|
47
|
-
// this.program = createProgram(this.gl, vs, fs);
|
|
48
|
-
// const { gl, program } = this;
|
|
49
|
-
// this._opacity = {
|
|
50
|
-
// lastValue: 1.0,
|
|
51
|
-
// location: gl.getUniformLocation(program, 'opacity')
|
|
52
|
-
// }
|
|
53
|
-
// this._phase = {
|
|
54
|
-
// lastValue: 1.0,
|
|
55
|
-
// location: gl.getUniformLocation(program, 'phase')
|
|
56
|
-
// }
|
|
57
|
-
// this._fadeOpacity = {
|
|
58
|
-
// lastValue: 1.0,
|
|
59
|
-
// location: gl.getUniformBlockLocation(program, 'fadeOpacity')
|
|
60
|
-
// }
|
|
61
|
-
// const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
62
|
-
// gl.useProgram(program);
|
|
63
|
-
// [this._opacity, this._phase, this._fadeOpacity].forEach((wrapper) => gl.uniform1f(wrapper.location, wrapper.lastValue))
|
|
64
|
-
// gl.useProgram(currentProgram)
|
|
65
|
-
// gl.useProgram(program);
|
|
66
|
-
// gl.bindAttribLocation(program, 0, 'pos3D');
|
|
67
|
-
// gl.bindAttribLocation(program, 1, 'color');
|
|
68
|
-
// this.cameraUniformBlockTotem = new CameraUniformBlockTotemCache.get(globe);
|
|
69
|
-
// this.cameraBlockBindingPoint = 0;
|
|
70
|
-
// const cameraBlockIndex = gl.getUniformBlockLocation(program, 'CameraUniformBlock');
|
|
71
|
-
// gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint)
|
|
72
|
-
// }
|
|
73
|
-
// createVao(pos3DObj, colorObj) {
|
|
74
|
-
// const { gl } = this;
|
|
75
|
-
// const vao = gl.createVertexArray();
|
|
76
|
-
// const divisor = 1;
|
|
77
|
-
// gl.bindVertexArray(vao);
|
|
78
|
-
// attributeLoader(gl, pos3DObj, 0, 3, { divisor });
|
|
79
|
-
// attributeLoader(gl, colorObj, 1, 4, { divisor, escapeValue: [-1, -1, -1, -1] });
|
|
80
|
-
// gl.bindVertexArray(null);
|
|
81
|
-
// this._vaoCache.push(vao);
|
|
82
|
-
// return vao;
|
|
83
|
-
// }
|
|
84
|
-
// /**
|
|
85
|
-
// *
|
|
86
|
-
// * @param {WebGL2RenderingContext.vertexArrayObject} vao
|
|
87
|
-
// * @param {Render} drawOptions
|
|
88
|
-
// */
|
|
89
|
-
// draw(vao, drawOptions, { opacity = 1.0, fadeOpacity = 1.0, }) {
|
|
90
|
-
// const { globe, gl, program, _opacity, _fadeOpacity } = this;
|
|
91
|
-
// gl.useProgram(program);
|
|
92
|
-
// gl.bindVertexArray(vao);
|
|
93
|
-
// if (fadeOpacity < 1.0) {
|
|
94
|
-
// this._updatePhase();
|
|
95
|
-
// globe.drawRender();
|
|
96
|
-
// }
|
|
97
|
-
// if (fadeOpacity !== _fadeOpacity.lastValue) {
|
|
98
|
-
// _fadeOpacity.lastValue = fadeOpacity;
|
|
99
|
-
// gl.uniform1f(_fadeOpacity.location, fadeOpacity);
|
|
100
|
-
// }
|
|
101
|
-
// if (opacity !== _opacity.lastValue) {
|
|
102
|
-
// _opacity.lastValue = opacity;
|
|
103
|
-
// gl.uniform1f(_opacity.location, opacity);
|
|
104
|
-
// }
|
|
105
|
-
// drawInstanced(gl, gl.TRIANGLE_FAN, drawOptions)
|
|
106
|
-
// }
|
|
107
|
-
// _updatePhase() {
|
|
108
|
-
// this._phase.lastValue = (Date.now() / 3.0) % 1000;
|
|
109
|
-
// gl.uniform1f(_phase.location, _phase.lastValue);
|
|
110
|
-
// }
|
|
111
|
-
// }
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { globeProgramCache } from "../programcache";
|
|
2
|
-
export const WebglobeInfoUniformBlockString = `
|
|
3
|
-
layout(std140) uniform WebglobeInfo {
|
|
4
|
-
vec2 canvas_resolution;
|
|
5
|
-
vec2 mouse_radian_long_lat;
|
|
6
|
-
vec2 mouse_pixel_xy;
|
|
7
|
-
float north_angle;
|
|
8
|
-
float world_tilt;
|
|
9
|
-
float earth_distance;
|
|
10
|
-
};
|
|
11
|
-
`;
|
|
12
|
-
export default class CameraUniformBlockTotem {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.id = "CameraUniformBlockTotem";
|
|
15
|
-
this.description = `Sets a uniform block and provides buffer for it. The following is the glsl uniform block:` + CameraUniformBlockString;
|
|
16
|
-
this.gl = null;
|
|
17
|
-
this.globe = null;
|
|
18
|
-
this.ubo = null;
|
|
19
|
-
}
|
|
20
|
-
init(globe, gl) {
|
|
21
|
-
this.gl = gl;
|
|
22
|
-
this.globe = globe;
|
|
23
|
-
this.ubo = this._createUBO();
|
|
24
|
-
this.traslateFloat32 = new Float32Array(3);
|
|
25
|
-
this.mapWHFloat32 = new Float32Array(2);
|
|
26
|
-
this.setGeometry();
|
|
27
|
-
this.resize();
|
|
28
|
-
}
|
|
29
|
-
_createUBO() {
|
|
30
|
-
const { gl } = this;
|
|
31
|
-
const ubo = gl.createBuffer();
|
|
32
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
33
|
-
gl.bufferData(gl.UNIFORM_BUFFER, 164, gl.STREAM_DRAW);
|
|
34
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, ubo);
|
|
35
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
36
|
-
return ubo;
|
|
37
|
-
}
|
|
38
|
-
resize() {
|
|
39
|
-
const { gl, globe, ubo } = this;
|
|
40
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
41
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 152, new Float32Array([globe.api_ScrW(), globe.api_ScrH()]));
|
|
42
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
43
|
-
}
|
|
44
|
-
setGeometry() {
|
|
45
|
-
const { gl, globe, ubo } = this;
|
|
46
|
-
const is3D = globe.api_GetCurrentGeometry() === 0;
|
|
47
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
48
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 140, new Float32Array([is3D]));
|
|
49
|
-
}
|
|
50
|
-
draw3D(projection, modelView, translate) {
|
|
51
|
-
const { gl, traslateFloat32, ubo, mapWHFloat32, globe } = this;
|
|
52
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
|
|
53
|
-
{ // view, projection, translate
|
|
54
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 0, modelView);
|
|
55
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 64, projection);
|
|
56
|
-
traslateFloat32.set([translate.x, translate.y, translate.z], 0);
|
|
57
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 128, traslateFloat32);
|
|
58
|
-
}
|
|
59
|
-
{
|
|
60
|
-
// zoom level
|
|
61
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 160, new Float32Array([globe.api_GetCurrentLODWithDecimal()]));
|
|
62
|
-
}
|
|
63
|
-
{ // mapWH
|
|
64
|
-
if (globe.api_GetCurrentGeometry() === 1) {
|
|
65
|
-
const { width, height } = globe.api_GetCurrentWorldWH();
|
|
66
|
-
mapWHFloat32.set([width, height]);
|
|
67
|
-
gl.bufferSubData(gl.UNIFORM_BUFFER, 144, mapWHFloat32);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
gl.bindBuffer(gl.UNIFORM_BUFFER, null);
|
|
71
|
-
}
|
|
72
|
-
getUBO() {
|
|
73
|
-
return this.ubo;
|
|
74
|
-
}
|
|
75
|
-
bind(bindingPoint) {
|
|
76
|
-
const { gl, ubo } = this;
|
|
77
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, ubo);
|
|
78
|
-
}
|
|
79
|
-
unbind(bindingPoint) {
|
|
80
|
-
const { gl } = this;
|
|
81
|
-
gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, null);
|
|
82
|
-
}
|
|
83
|
-
free() {
|
|
84
|
-
const { gl, ubo } = this;
|
|
85
|
-
gl.deleteBuffer(ubo);
|
|
86
|
-
}
|
|
87
|
-
readBuffer() {
|
|
88
|
-
const result = new Float32Array(41);
|
|
89
|
-
this.gl.bindBuffer(this.gl.UNIFORM_BUFFER, this.ubo);
|
|
90
|
-
this.gl.getBufferSubData(this.gl.UNIFORM_BUFFER, 0, result);
|
|
91
|
-
this.gl.bindBuffer(this.gl.UNIFORM_BUFFER, null);
|
|
92
|
-
return {
|
|
93
|
-
view: result.slice(0, 16),
|
|
94
|
-
projection: result.slice(16, 32),
|
|
95
|
-
translate: result.slice(32, 35),
|
|
96
|
-
is3D: result[35],
|
|
97
|
-
mapWH: result.slice(36, 38),
|
|
98
|
-
screenWH: result.slice(38, 40),
|
|
99
|
-
z_level: result[40]
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
export const CameraUniformBlockTotemCache = Object.freeze({
|
|
104
|
-
get: (globe) => { return globeProgramCache.getProgram(globe, CameraUniformBlockTotem); },
|
|
105
|
-
release: (globe) => { return globeProgramCache.releaseProgram(globe, CameraUniformBlockTotem); }
|
|
106
|
-
});
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { LineStripProgramCache } from "../../../programs/line-on-globe/linestrip/linestrip";
|
|
2
|
-
import { createBufferAndReadInfo } from '../../../util/gl-util/buffer/attribute-loader';
|
|
3
|
-
// import { populateFloat32Array } from "../../../util/jshelpers/data-filler";
|
|
4
|
-
import { BufferManager, BufferOrchestrator } from "../../../util/account/single-attribute-buffer-management/index";
|
|
5
|
-
import { globe3Dcoordinates, globe2Dcoordinates, RADIANS } from "../../../Math/methods";
|
|
6
|
-
import { generateArcPoints } from "../../../Math/arc-cdf-points";
|
|
7
|
-
import { StaticDynamicState, StaticDynamicStrategy } from "../../../util/build-strategy/static-dynamic";
|
|
8
|
-
import * as vec3 from "../../../Math/vec3";
|
|
9
|
-
import * as arc from "../../../Math/arc";
|
|
10
|
-
import { CameraUniformBlockTotemCache } from "../../../programs/totems/camerauniformblock";
|
|
11
|
-
import { WORLD_RADIUS_3D } from "../../../Math/constants";
|
|
12
|
-
const VERTEX_COUNT = 70;
|
|
13
|
-
const INITAL_CAPACITY = 10;
|
|
14
|
-
const _attractionPoint = [0, 0, 0];
|
|
15
|
-
const _start = [0, 0, 0];
|
|
16
|
-
const _end = [0, 0, 0];
|
|
17
|
-
const _0arc = arc.create([1, 0, 0], [0, 1, 0]); // zero arc for intersection tests
|
|
18
|
-
const _colorArray = new Float32Array(4); // For color buffer
|
|
19
|
-
export class NaiveLineOnTerrainPlugin {
|
|
20
|
-
id;
|
|
21
|
-
program = null;
|
|
22
|
-
bufferManagerMap = null;
|
|
23
|
-
_bufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
|
|
24
|
-
_opacity = 1;
|
|
25
|
-
_arcUBOHandler = null;
|
|
26
|
-
_vao = null;
|
|
27
|
-
globe = null;
|
|
28
|
-
gl = null;
|
|
29
|
-
_arcMap;
|
|
30
|
-
_cameraUniformBlock = null;
|
|
31
|
-
_staticDynamicStrategy = null;
|
|
32
|
-
_styleOptions = {
|
|
33
|
-
variativeColorsOn: false,
|
|
34
|
-
defaultColor: [0.1, 0.1, 1, 1], // Default color in RGBA format
|
|
35
|
-
defaultHeightFromGroundIn3D: 30.0 // Default height from ground in
|
|
36
|
-
};
|
|
37
|
-
constructor(id, drawStyleOptions = null) {
|
|
38
|
-
this.id = id;
|
|
39
|
-
this._arcMap = new Map();
|
|
40
|
-
if (drawStyleOptions) {
|
|
41
|
-
this._styleOptions = drawStyleOptions;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
insertArcFromLongLat(key, startPoint, endPoint, height = null) {
|
|
45
|
-
if (this._arcMap.has(key)) {
|
|
46
|
-
this._arcMap.delete(key);
|
|
47
|
-
}
|
|
48
|
-
vec3.fromLongLatToUnitVector(_start, [startPoint.long * RADIANS, startPoint.lat * RADIANS]);
|
|
49
|
-
vec3.fromLongLatToUnitVector(_end, [endPoint.long * RADIANS, endPoint.lat * RADIANS]);
|
|
50
|
-
const _arc = arc.create(_start, _end);
|
|
51
|
-
this._arcMap.set(key, [_arc, height]);
|
|
52
|
-
// TODO: insert into buffer if NOT DYNAMIC state
|
|
53
|
-
if (this._staticDynamicStrategy?.getState() !== StaticDynamicState.DYNAMIC) {
|
|
54
|
-
this.__buildStaticArcs([key]);
|
|
55
|
-
}
|
|
56
|
-
this.globe.DrawRender();
|
|
57
|
-
}
|
|
58
|
-
deleteArcs(keys) {
|
|
59
|
-
for (const key of keys) {
|
|
60
|
-
if (this._arcMap.has(key)) {
|
|
61
|
-
this._arcMap.delete(key);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// DELETE FROM BUFFER IF not DYNAMIC state
|
|
65
|
-
this.globe.DrawRender();
|
|
66
|
-
}
|
|
67
|
-
init(globe, gl) {
|
|
68
|
-
this.globe = globe;
|
|
69
|
-
this.gl = gl;
|
|
70
|
-
this.program = LineStripProgramCache.get(globe);
|
|
71
|
-
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, 8); // Initialize static-dynamic strategy with a transition level of 8
|
|
72
|
-
const g2D = globe2Dcoordinates(globe);
|
|
73
|
-
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
74
|
-
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, 8); // Initialize static-dynamic strategy with a transition level of 8
|
|
75
|
-
this.bufferManagerMap = new Map([
|
|
76
|
-
["position3d", {
|
|
77
|
-
bufferManager: new BufferManager(gl, 3 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
78
|
-
adaptor: (item) => {
|
|
79
|
-
const { longLatArr, height = this._styleOptions.defaultHeightFromGroundIn3D } = item;
|
|
80
|
-
const result = globe3Dcoordinates(globe, height)(longLatArr, { paddingCount: 1 });
|
|
81
|
-
// console.log("result", result);
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
}],
|
|
85
|
-
["position2d", {
|
|
86
|
-
bufferManager: new BufferManager(gl, 2 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
87
|
-
adaptor: (item) => {
|
|
88
|
-
const { longLatArr } = item;
|
|
89
|
-
return g2D(longLatArr, { paddingCount: 1 });
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
]);
|
|
94
|
-
if (this._styleOptions.variativeColorsOn) {
|
|
95
|
-
this.bufferManagerMap.set("color", {
|
|
96
|
-
bufferManager: new BufferManager(gl, 4, { initialCapacity: INITAL_CAPACITY }),
|
|
97
|
-
adaptor: (item) => {
|
|
98
|
-
const { radius } = item;
|
|
99
|
-
// Calculate color based on radius
|
|
100
|
-
if (item.color) {
|
|
101
|
-
_colorArray.set(item.color);
|
|
102
|
-
return _colorArray;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
return this._styleOptions.defaultColor;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
this._bufferOrchestrator = new BufferOrchestrator();
|
|
111
|
-
this._arcUBOHandler = this.program.createUBO();
|
|
112
|
-
this._arcUBOHandler.update(new Map([
|
|
113
|
-
["u_color", new Float32Array([1, 0, 0, 1])],
|
|
114
|
-
]));
|
|
115
|
-
this._vao = this.program.createVAO(createBufferAndReadInfo(this.bufferManagerMap.get("position3d")?.bufferManager.buffer), createBufferAndReadInfo(this.bufferManagerMap.get("position2d")?.bufferManager.buffer), null);
|
|
116
|
-
}
|
|
117
|
-
draw3D() {
|
|
118
|
-
// Drawing logic here
|
|
119
|
-
if (!this.globe || !this.gl) {
|
|
120
|
-
console.warn("Globe or WebGL context is not initialized.");
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
this._staticDynamicStrategy?.updateState();
|
|
124
|
-
this._buildArcs(); // can be async
|
|
125
|
-
const { gl, program, _bufferOrchestrator, _vao, _arcUBOHandler, } = this;
|
|
126
|
-
if (!gl || !program || !_bufferOrchestrator || !_vao || !_arcUBOHandler) {
|
|
127
|
-
console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
gl.disable(gl.DEPTH_TEST);
|
|
131
|
-
const drawOptions = {
|
|
132
|
-
drawRange: {
|
|
133
|
-
first: 0,
|
|
134
|
-
count: _bufferOrchestrator.length * (VERTEX_COUNT + 1)
|
|
135
|
-
},
|
|
136
|
-
indexes: null
|
|
137
|
-
};
|
|
138
|
-
program.draw(_vao, drawOptions, this._opacity, _arcUBOHandler);
|
|
139
|
-
gl.enable(gl.DEPTH_TEST);
|
|
140
|
-
}
|
|
141
|
-
_buildArcs() {
|
|
142
|
-
const state = this._staticDynamicStrategy?.getState();
|
|
143
|
-
if (state === StaticDynamicState.TO_STATIC) {
|
|
144
|
-
this.__buildStaticArcs();
|
|
145
|
-
}
|
|
146
|
-
else if (state === StaticDynamicState.DYNAMIC) {
|
|
147
|
-
this.__buildArcs();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
__buildStaticArcs(keys = []) {
|
|
151
|
-
const { globe, _arcMap, _cameraUniformBlock, bufferManagerMap, _bufferOrchestrator } = this;
|
|
152
|
-
if (!globe || !_cameraUniformBlock || !bufferManagerMap || !_bufferOrchestrator) {
|
|
153
|
-
console.warn("Globe or camera uniform block is not initialized.");
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const longLat = [0, 0];
|
|
157
|
-
const _attractionStrength = 0;
|
|
158
|
-
const longLatArr = new Float32Array(2 * VERTEX_COUNT);
|
|
159
|
-
const data = [{
|
|
160
|
-
key: "staticArcs",
|
|
161
|
-
longLatArr: longLatArr,
|
|
162
|
-
height: null
|
|
163
|
-
}];
|
|
164
|
-
if (keys.length == 0) {
|
|
165
|
-
for (const [key, [arcInstance, height]] of _arcMap) {
|
|
166
|
-
arc.copy(_0arc, arcInstance);
|
|
167
|
-
const generatedPoints = generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, VERTEX_COUNT, _attractionStrength);
|
|
168
|
-
for (let i = 0; i < generatedPoints.length; i++) {
|
|
169
|
-
const point = generatedPoints[i];
|
|
170
|
-
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
171
|
-
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
172
|
-
}
|
|
173
|
-
data[0].key = key;
|
|
174
|
-
data[0].height = height;
|
|
175
|
-
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
for (let key of keys) {
|
|
180
|
-
if (!_arcMap.has(key)) {
|
|
181
|
-
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const [arcInstance, height] = _arcMap.get(key);
|
|
185
|
-
arc.copy(_0arc, arcInstance);
|
|
186
|
-
const generatedPoints = generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, VERTEX_COUNT, _attractionStrength);
|
|
187
|
-
for (let i = 0; i < generatedPoints.length; i++) {
|
|
188
|
-
const point = generatedPoints[i];
|
|
189
|
-
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
190
|
-
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
191
|
-
}
|
|
192
|
-
data[0].key = key;
|
|
193
|
-
data[0].height = height;
|
|
194
|
-
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
__buildArcs() {
|
|
199
|
-
const { globe, _arcMap, _cameraUniformBlock, bufferManagerMap } = this;
|
|
200
|
-
if (!globe || !_cameraUniformBlock || !bufferManagerMap) {
|
|
201
|
-
console.warn("Globe or camera uniform block is not initialized.");
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
const lookAtPosition = _cameraUniformBlock.getLookAtVector();
|
|
205
|
-
const cameraPosition = _cameraUniformBlock.getCameraVector();
|
|
206
|
-
vec3.divideScalar(cameraPosition, cameraPosition, WORLD_RADIUS_3D);
|
|
207
|
-
vec3.add(cameraPosition, cameraPosition, lookAtPosition);
|
|
208
|
-
// vec3.normalize(cameraPosition, cameraPosition);
|
|
209
|
-
vec3.divideScalar(cameraPosition, cameraPosition, 2);
|
|
210
|
-
// vec3.multiplyScalar(cameraPosition, cameraPosition, 1.3);
|
|
211
|
-
const _attractionStrength = (() => {
|
|
212
|
-
const lod = globe.api_GetCurrentLODWithDecimal();
|
|
213
|
-
if (lod < 11) {
|
|
214
|
-
return 1;
|
|
215
|
-
}
|
|
216
|
-
return lod * (lod - 8.5);
|
|
217
|
-
})();
|
|
218
|
-
console.log("Attraction strength: ", _attractionStrength);
|
|
219
|
-
const result = [];
|
|
220
|
-
const longLat = [0, 0];
|
|
221
|
-
for (const [key, [arcInstance, height]] of _arcMap) {
|
|
222
|
-
arc.copy(_0arc, arcInstance);
|
|
223
|
-
const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPosition);
|
|
224
|
-
if (!isOnArc) {
|
|
225
|
-
if (vec3.distanceSquared(cameraPosition, _0arc.p0) < vec3.distanceSquared(cameraPosition, _0arc.p1)) {
|
|
226
|
-
vec3.copy(_attractionPoint, _0arc.p0);
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
vec3.copy(_attractionPoint, _0arc.p1);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
const generatedPoints = generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, VERTEX_COUNT, _attractionStrength);
|
|
233
|
-
const longLatArr = new Float32Array(2 * VERTEX_COUNT);
|
|
234
|
-
for (let i = 0; i < generatedPoints.length; i++) {
|
|
235
|
-
const point = generatedPoints[i];
|
|
236
|
-
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
237
|
-
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
238
|
-
}
|
|
239
|
-
result.push({
|
|
240
|
-
key: key,
|
|
241
|
-
longLatArr: longLatArr,
|
|
242
|
-
height: height
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
this._bufferOrchestrator.resetWithCapacity(bufferManagerMap, result.length);
|
|
246
|
-
this._bufferOrchestrator.insertBulk(result, bufferManagerMap);
|
|
247
|
-
}
|
|
248
|
-
_buildStaticArc() {
|
|
249
|
-
}
|
|
250
|
-
}
|
package/util/check/get.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const mapGetOrThrow = (errorNote) => {
|
|
2
|
-
return (mapInstance, ids) => {
|
|
3
|
-
if (!ids)
|
|
4
|
-
throw new Error("There is no map keys to get");
|
|
5
|
-
const result = [];
|
|
6
|
-
for (let i = 0; i < ids.length; i++) {
|
|
7
|
-
const e = mapInstance.get(ids[i]);
|
|
8
|
-
if (e === undefined)
|
|
9
|
-
throw new Error(errorNote + " " + ids[i]);
|
|
10
|
-
result.push(e);
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef DrawRange
|
|
3
|
-
* @type {Object}
|
|
4
|
-
* @property {int} first
|
|
5
|
-
* @property {int} count
|
|
6
|
-
*
|
|
7
|
-
* @typedef DrawRangeIndexParams
|
|
8
|
-
* @type {Object}
|
|
9
|
-
* @property {null|DrawRange} drawRange
|
|
10
|
-
* @property {null|ElementBuffer} elementBuffer
|
|
11
|
-
* @property {null|indexType} indexType
|
|
12
|
-
* @property {null|int} drawMode
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
export {};
|