@pirireis/webglobeplugins 0.13.0-alpha → 0.15.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.
Files changed (55) hide show
  1. package/Math/arc-cdf-points.js +20 -0
  2. package/Math/arc-generate-points copy.js +1 -0
  3. package/Math/arc.js +21 -8
  4. package/Math/circle.js +35 -16
  5. package/Math/templete-shapes/grid-visually-equal.js +66 -0
  6. package/altitude-locator/plugin.js +3 -2
  7. package/bearing-line/plugin.js +1 -2
  8. package/circle-line-chain/plugin.js +4 -7
  9. package/compass-rose/compass-rose-padding-flat.js +12 -0
  10. package/package.json +1 -1
  11. package/programs/line-on-globe/degree-padding-around-circle-3d.js +1 -1
  12. package/programs/line-on-globe/linestrip/linestrip.js +6 -4
  13. package/programs/line-on-globe/naive-accurate-flexible.js +23 -16
  14. package/programs/picking/pickable-renderer.js +1 -2
  15. package/programs/rings/partial-ring/piece-of-pie copy.js +286 -0
  16. package/programs/rings/partial-ring/piece-of-pie.js +26 -13
  17. package/programs/totems/camerauniformblock.js +1 -1
  18. package/programs/totems/index.js +1 -1
  19. package/range-tools-on-terrain/bearing-line/adapters.js +111 -0
  20. package/range-tools-on-terrain/bearing-line/plugin.js +360 -0
  21. package/range-tools-on-terrain/circle-line-chain/adapters.js +83 -0
  22. package/range-tools-on-terrain/circle-line-chain/chain-list-map.js +351 -0
  23. package/range-tools-on-terrain/circle-line-chain/plugin.js +388 -0
  24. package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
  25. package/range-tools-on-terrain/range-ring/adapters.js +25 -0
  26. package/range-tools-on-terrain/range-ring/plugin.js +31 -0
  27. package/range-tools-on-terrain/range-ring/types.js +1 -0
  28. package/rangerings/plugin.js +7 -11
  29. package/semiplugins/lightweight/line-plugin.js +195 -0
  30. package/semiplugins/lightweight/piece-of-pie-plugin.js +175 -0
  31. package/semiplugins/shape-on-terrain/arc-plugin.js +368 -0
  32. package/{shape-on-terrain/circle/plugin.js → semiplugins/shape-on-terrain/circle-plugin.js} +67 -38
  33. package/semiplugins/shape-on-terrain/derived/padding-plugin.js +101 -0
  34. package/semiplugins/shape-on-terrain/one-degree-padding.js +85 -0
  35. package/semiplugins/type.js +1 -0
  36. package/types.js +0 -11
  37. package/util/account/create-buffermap-orchastration.js +39 -0
  38. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +14 -3
  39. package/util/check/typecheck.js +15 -1
  40. package/util/geometry/index.js +3 -2
  41. package/util/gl-util/buffer/attribute-loader.js +2 -5
  42. package/util/gl-util/draw-options/methods.js +4 -5
  43. package/util/webglobjectbuilders.js +5 -10
  44. package/write-text/context-text3.js +17 -0
  45. package/write-text/context-text3old.js +152 -0
  46. package/programs/line-on-globe/circle-accurate.js +0 -176
  47. package/programs/line-on-globe/circle.js +0 -166
  48. package/programs/line-on-globe/to-the-surface.js +0 -111
  49. package/programs/totems/canvas-webglobe-info1.js +0 -106
  50. package/shape-on-terrain/arc/naive/plugin.js +0 -250
  51. package/util/check/get.js +0 -14
  52. package/util/gl-util/draw-options/types.js +0 -15
  53. package/util/webglobjectbuilders1.js +0 -219
  54. /package/{util/gl-util/buffer/types.js → programs/line-on-globe/paddings/paddings.js} +0 -0
  55. /package/{shape-on-terrain/type.js → range-tools-on-terrain/bearing-line/types.js} +0 -0
@@ -1,176 +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_accurate,
10
- // circleLimpFromLongLatRadCenterMercatorCompass_accurate,
11
- // circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate,
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_accurate}
32
- // ${circleLimpFromLongLatRadCenterMercatorCompass_accurate}
33
- // ${circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate}
34
- // uniform float edge_count;
35
- // in vec2 center_position;
36
- // in vec3 center_position3d;
37
- // in float radius;
38
- // in vec4 color;
39
- // in float dash_ratio;
40
- // in float dash_opacity;
41
- // out float interpolation;
42
- // out vec4 v_color;
43
- // out float v_dash_ratio;
44
- // out float v_dash_opacity;
45
- // out vec2 v_limp;
46
- // void main() {
47
- // interpolation = float( gl_VertexID ) / ${EDGE_COUNT_ON_SPHERE}.0;
48
- // float angle = PI * 2.0 * interpolation;
49
- // if ( is3D ) {
50
- // vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, radius, angle);
51
- // gl_Position = cartesian3DToGLPosition(position);
52
- // v_limp = vec2(0.0, 0.0);
53
- // } else {
54
- // vec2 position;
55
- // if ( radius < 0.0) {
56
- // float cosine1 = cos(asin(tanh(center_position.y / 6378137.0)));
57
- // position = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center_position, radius / cosine1 , angle);
58
- // } else {
59
- // position = circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate( center_position, radius, angle);
60
- // }
61
- // v_limp = position;
62
- // gl_Position = mercatorXYToGLPosition( position);
63
- // }
64
- // v_dash_ratio = dash_ratio;
65
- // v_dash_opacity = dash_opacity;
66
- // v_color = color;
67
- // gl_PointSize = 3.0;
68
- // }`
69
- // const fragmentShaderSource = `#version 300 es
70
- // ${POLE}
71
- // precision highp float;
72
- // uniform float opacity;
73
- // in vec4 v_color;
74
- // in float v_dash_ratio;
75
- // in float v_dash_opacity;
76
- // in float interpolation;
77
- // in vec2 v_limp;
78
- // out vec4 color;
79
- // void main() {
80
- // 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; }
81
- // color = v_color;
82
- // color.a *= opacity;
83
- // if ( v_dash_ratio == 1.0 || v_dash_ratio == 0.0 ) return;
84
- // if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5 ) {
85
- // color.a *= v_dash_opacity;
86
- // }
87
- // }
88
- // `;
89
- // class Logic {
90
- // constructor(globe) {
91
- // this.globe = globe;
92
- // this.gl = globe.gl;
93
- // this._lastOpacity = 1.0;
94
- // this.program = createProgram(this.gl, vertexShaderSource, fragmentShaderSource);
95
- // const { gl, program } = this;
96
- // this.program.uniforms = {
97
- // opacity: gl.getUniformLocation(program, "opacity")
98
- // };
99
- // { // initial uniform values
100
- // const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
101
- // gl.useProgram(program);
102
- // gl.uniform1f(program.uniforms.opacity, 1.0);
103
- // gl.useProgram(currentProgram);
104
- // }
105
- // //
106
- // { // assign attribute locations
107
- // gl.bindAttribLocation(program, 0, "center_position");
108
- // gl.bindAttribLocation(program, 1, "center_position3d");
109
- // gl.bindAttribLocation(program, 2, "radius");
110
- // gl.bindAttribLocation(program, 3, "color");
111
- // gl.bindAttribLocation(program, 4, "dash_ratio");
112
- // gl.bindAttribLocation(program, 5, "dash_opacity");
113
- // }
114
- // this.cameraBindingPoint = 0;
115
- // this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
116
- // const cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
117
- // gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
118
- // }
119
- // createVAO(centerObj, center3dObj, radiusObj, colorObj, dashRatioObj, dashOpacityObj) {
120
- // const { gl } = this;
121
- // const vao = gl.createVertexArray();
122
- // const divisor = 1;
123
- // gl.bindVertexArray(vao);
124
- // { // make this a function end import from account module.
125
- // const { buffer, stride = 0, offset = 0 } = centerObj;
126
- // vaoAttributeLoader(gl, buffer, 0, 2, stride, offset, divisor);
127
- // }
128
- // { // make this a function end import from account module.
129
- // const { buffer, stride = 0, offset = 0 } = center3dObj;
130
- // vaoAttributeLoader(gl, buffer, 1, 3, stride, offset, divisor);
131
- // }
132
- // {
133
- // const { buffer, stride = 0, offset = 0 } = radiusObj;
134
- // vaoAttributeLoader(gl, buffer, 2, 1, stride, offset, divisor);
135
- // }
136
- // {
137
- // const { buffer, stride = 0, offset = 0 } = colorObj;
138
- // vaoAttributeLoader(gl, buffer, 3, 4, stride, offset, divisor);
139
- // }
140
- // {
141
- // const { buffer, stride = 0, offset = 0 } = dashRatioObj;
142
- // vaoAttributeLoader(gl, buffer, 4, 1, stride, offset, divisor);
143
- // }
144
- // {
145
- // const { buffer, stride = 0, offset = 0 } = dashOpacityObj;
146
- // vaoAttributeLoader(gl, buffer, 5, 1, stride, offset, divisor);
147
- // }
148
- // gl.bindVertexArray(null);
149
- // gl.bindVertexArray(null);
150
- // return vao;
151
- // }
152
- // draw(vao, length, opacity) {
153
- // const { gl, program, cameraBlockTotem, cameraBindingPoint } = this;
154
- // gl.useProgram(program);
155
- // if (this._lastOpacity !== opacity) {
156
- // gl.uniform1f(program.uniforms.opacity, opacity);
157
- // this._lastOpacity = opacity;
158
- // }
159
- // gl.bindVertexArray(vao);
160
- // cameraBlockTotem.bind(cameraBindingPoint);
161
- // gl.drawArraysInstanced(gl.LINE_STRIP, 0, EDGE_COUNT_ON_SPHERE + 1, length);
162
- // gl.drawArraysInstanced(gl.POINTS, 0, EDGE_COUNT_ON_SPHERE + 1, length);
163
- // cameraBlockTotem.unbind(cameraBindingPoint);
164
- // gl.bindVertexArray(null);
165
- // }
166
- // free() {
167
- // if (this.isFreed) return;
168
- // CameraUniformBlockTotemCache.release(this.globe);
169
- // this.gl.deleteProgram(this.program);
170
- // this.isFreed = true;
171
- // }
172
- // }
173
- // export const CircleCache = Object.freeze({
174
- // get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
175
- // release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
176
- // });
@@ -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
- });