@openglobus/og 0.11.5 → 0.11.6

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 (145) hide show
  1. package/package.json +5 -7
  2. package/src/og/Clock.js +6 -10
  3. package/src/og/Events.js +5 -7
  4. package/src/og/Extent.js +73 -32
  5. package/src/og/ImageCanvas.js +18 -15
  6. package/src/og/LonLat.js +13 -10
  7. package/src/og/Popup.js +18 -17
  8. package/src/og/QueueArray.js +3 -4
  9. package/src/og/Rectangle.js +4 -6
  10. package/src/og/Stack.js +2 -4
  11. package/src/og/ajax.js +20 -14
  12. package/src/og/astro/earth.js +21 -15
  13. package/src/og/bv/Box.js +2 -3
  14. package/src/og/bv/Sphere.js +10 -7
  15. package/src/og/camera/Frustum.js +19 -12
  16. package/src/og/camera/PlanetCamera.js +0 -1
  17. package/src/og/control/CompassButton.js +1 -2
  18. package/src/og/control/Control.js +7 -9
  19. package/src/og/control/DebugInfo.js +0 -1
  20. package/src/og/control/KeyboardNavigation.js +9 -9
  21. package/src/og/control/LayerSwitcher.js +21 -20
  22. package/src/og/control/SegmentBoundVisualization.js +5 -6
  23. package/src/og/control/ShowFps.js +12 -7
  24. package/src/og/control/SimpleNavigation.js +5 -7
  25. package/src/og/control/Sun.js +22 -12
  26. package/src/og/control/ToggleWireframe.js +3 -3
  27. package/src/og/control/TouchNavigation.js +43 -32
  28. package/src/og/control/ZoomControl.js +40 -24
  29. package/src/og/ellipsoid/Ellipsoid.js +148 -56
  30. package/src/og/ellipsoid/wgs84.js +3 -3
  31. package/src/og/entity/BaseBillboard.js +65 -14
  32. package/src/og/entity/Billboard.js +9 -5
  33. package/src/og/entity/BillboardHandler.js +310 -64
  34. package/src/og/entity/Entity.js +39 -1
  35. package/src/og/entity/EntityCollection.js +47 -24
  36. package/src/og/entity/GeoObject.js +228 -0
  37. package/src/og/entity/GeoObjectHandler.js +910 -0
  38. package/src/og/entity/GeometryHandler.js +595 -123
  39. package/src/og/entity/Label.js +53 -18
  40. package/src/og/entity/LabelHandler.js +42 -244
  41. package/src/og/entity/LabelWorker.js +213 -0
  42. package/src/og/entity/Object3d.js +504 -0
  43. package/src/og/entity/PointCloud.js +76 -28
  44. package/src/og/entity/PointCloudHandler.js +5 -5
  45. package/src/og/entity/Ray.js +49 -16
  46. package/src/og/entity/Strip.js +72 -43
  47. package/src/og/entity/StripHandler.js +23 -23
  48. package/src/og/layer/BaseGeoImage.js +50 -19
  49. package/src/og/layer/CanvasTiles.js +16 -16
  50. package/src/og/layer/GeoImage.js +6 -6
  51. package/src/og/layer/KML.js +55 -33
  52. package/src/og/layer/Layer.js +3 -3
  53. package/src/og/layer/Vector.js +94 -48
  54. package/src/og/layer/WMS.js +33 -16
  55. package/src/og/light/LightSource.js +19 -12
  56. package/src/og/math/Mat3.js +24 -12
  57. package/src/og/math/Mat4.js +603 -603
  58. package/src/og/math/Plane.js +19 -18
  59. package/src/og/math/Ray.js +17 -12
  60. package/src/og/math/Vec2.js +24 -14
  61. package/src/og/math/Vec3.js +60 -30
  62. package/src/og/math/coder.js +7 -7
  63. package/src/og/proj/EPSG3857.js +3 -3
  64. package/src/og/proj/EPSG4326.js +3 -3
  65. package/src/og/proj/Proj.js +2 -4
  66. package/src/og/quadTree/Node.js +31 -17
  67. package/src/og/renderer/Renderer.js +23 -6
  68. package/src/og/renderer/RendererEvents.js +1 -1
  69. package/src/og/scene/BaseNode.js +2 -3
  70. package/src/og/scene/Planet.js +2 -2
  71. package/src/og/scene/RenderNode.js +15 -8
  72. package/src/og/shaders/geoObject.js +211 -0
  73. package/src/og/shaders/pointCloud.js +41 -41
  74. package/src/og/shaders/shape.js +12 -18
  75. package/src/og/shaders/skybox.js +36 -36
  76. package/src/og/shapes/BaseShape.js +107 -35
  77. package/src/og/shapes/Icosphere.js +25 -10
  78. package/src/og/shapes/Sphere.js +8 -11
  79. package/src/og/utils/TextureAtlas.js +16 -18
  80. package/src/og/utils/shared.js +1 -1
  81. package/src/og/webgl/Handler.js +68 -49
  82. package/src/og/webgl/Multisample.js +44 -16
  83. package/src/og/webgl/Program.js +78 -33
  84. package/src/og/webgl/callbacks.js +3 -3
  85. package/types/Deferred.d.ts +1 -1
  86. package/types/Events.d.ts +2 -2
  87. package/types/Extent.d.ts +1 -1
  88. package/types/Rectangle.d.ts +1 -1
  89. package/types/ajax.d.ts +1 -1
  90. package/types/bv/Box.d.ts +1 -1
  91. package/types/bv/Sphere.d.ts +1 -1
  92. package/types/camera/Camera.d.ts +5 -5
  93. package/types/camera/Frustum.d.ts +6 -6
  94. package/types/camera/PlanetCamera.d.ts +8 -8
  95. package/types/control/Control.d.ts +1 -1
  96. package/types/control/EarthCoordinates.d.ts +1 -1
  97. package/types/control/Sun.d.ts +1 -1
  98. package/types/entity/BaseBillboard.d.ts +15 -8
  99. package/types/entity/Entity.d.ts +24 -9
  100. package/types/entity/EntityCollection.d.ts +15 -9
  101. package/types/entity/GeoObject.d.ts +111 -0
  102. package/types/entity/GeoObjectHandler.d.ts +77 -0
  103. package/types/entity/Geometry.d.ts +1 -1
  104. package/types/entity/GeometryHandler.d.ts +1 -1
  105. package/types/entity/Label.d.ts +3 -3
  106. package/types/entity/LabelHandler.d.ts +2 -0
  107. package/types/entity/LabelWorker.d.ts +9 -0
  108. package/types/entity/PointCloud.d.ts +1 -1
  109. package/types/entity/Polyline.d.ts +5 -5
  110. package/types/entity/Ray.d.ts +1 -1
  111. package/types/entity/Strip.d.ts +1 -1
  112. package/types/layer/BaseGeoImage.d.ts +3 -3
  113. package/types/layer/CanvasTiles.d.ts +5 -5
  114. package/types/layer/GeoImage.d.ts +1 -1
  115. package/types/layer/GeoVideo.d.ts +1 -1
  116. package/types/layer/Layer.d.ts +5 -5
  117. package/types/layer/Vector.d.ts +9 -9
  118. package/types/layer/XYZ.d.ts +3 -3
  119. package/types/light/LightSource.d.ts +7 -7
  120. package/types/math/Plane.d.ts +1 -1
  121. package/types/math/Ray.d.ts +1 -1
  122. package/types/math/Vec2.d.ts +34 -34
  123. package/types/math/Vec3.d.ts +1 -1
  124. package/types/math/Vec4.d.ts +1 -1
  125. package/types/math/coder.d.ts +1 -1
  126. package/types/math.d.ts +1 -1
  127. package/types/proj/Proj.d.ts +2 -2
  128. package/types/quadTree/Node.d.ts +1 -1
  129. package/types/renderer/Renderer.d.ts +12 -10
  130. package/types/renderer/RendererEvents.d.ts +1 -1
  131. package/types/scene/BaseNode.d.ts +4 -4
  132. package/types/scene/Planet.d.ts +40 -40
  133. package/types/scene/RenderNode.d.ts +9 -9
  134. package/types/segment/Segment.d.ts +9 -9
  135. package/types/shaders/geoObject.d.ts +3 -0
  136. package/types/shapes/BaseShape.d.ts +5 -5
  137. package/types/terrain/EmptyTerrain.d.ts +2 -2
  138. package/types/terrain/GlobusTerrain.d.ts +4 -4
  139. package/types/utils/TextureAtlas.d.ts +4 -4
  140. package/types/utils/shared.d.ts +9 -9
  141. package/types/webgl/Framebuffer.d.ts +1 -1
  142. package/types/webgl/Handler.d.ts +16 -7
  143. package/types/webgl/Multisample.d.ts +2 -2
  144. package/types/webgl/Program.d.ts +6 -0
  145. package/types/webgl/ProgramController.d.ts +1 -1
@@ -16,6 +16,7 @@ import { TextureAtlas } from "../utils/TextureAtlas.js";
16
16
  import * as arial from "../arial.js";
17
17
  import { depth } from "../shaders/depth.js";
18
18
  import { ARIAL_FONT_B64 } from "../res/images.js";
19
+ import { LabelWorker } from "../entity/LabelWorker.js";
19
20
 
20
21
  let __pickingCallbackCounter__ = 0;
21
22
 
@@ -55,7 +56,6 @@ let __depthCallbackCounter__ = 0;
55
56
  * @fires og.RendererEvents#touchenter
56
57
  */
57
58
  class Renderer {
58
-
59
59
  constructor(handler, params) {
60
60
  params = params || {};
61
61
 
@@ -212,6 +212,8 @@ class Renderer {
212
212
  }
213
213
 
214
214
  this._currentOutput = "screen";
215
+
216
+ this.labelWorker = new LabelWorker();
215
217
  }
216
218
 
217
219
  /**
@@ -441,7 +443,7 @@ class Renderer {
441
443
  useDepth: false
442
444
  }).init();
443
445
 
444
- this.readPixels = () => { };
446
+ this.readPixels = () => {};
445
447
 
446
448
  if (this.handler.gl.type === "webgl") {
447
449
  this.sceneFramebuffer = new Framebuffer(this.handler);
@@ -538,7 +540,8 @@ class Renderer {
538
540
  );
539
541
  this.toneMappingFramebuffer &&
540
542
  this.toneMappingFramebuffer.setSize(obj.clientWidth, obj.clientHeight, true);
541
- this.depthFramebuffer && this.depthFramebuffer.setSize(obj.clientWidth, obj.clientHeight, true);
543
+ this.depthFramebuffer &&
544
+ this.depthFramebuffer.setSize(obj.clientWidth, obj.clientHeight, true);
542
545
  this.screenDepthFramebuffer &&
543
546
  this.screenDepthFramebuffer.setSize(obj.clientWidth, obj.clientHeight, true);
544
547
 
@@ -610,7 +613,11 @@ class Renderer {
610
613
 
611
614
  getMaxMSAA(internalFormat) {
612
615
  var gl = this.handler.gl;
613
- let samples = gl.getInternalformatParameter(gl.RENDERBUFFER, gl[internalFormat], gl.SAMPLES);
616
+ let samples = gl.getInternalformatParameter(
617
+ gl.RENDERBUFFER,
618
+ gl[internalFormat],
619
+ gl.SAMPLES
620
+ );
614
621
  return samples[0];
615
622
  }
616
623
 
@@ -671,6 +678,12 @@ class Renderer {
671
678
  ec[i]._fadingOpacity && ec[i].labelHandler.draw();
672
679
  }
673
680
 
681
+ //geoObject
682
+ i = ec.length;
683
+ while (i--) {
684
+ ec[i]._fadingOpacity && ec[i].geoObjectHandler.draw();
685
+ }
686
+
674
687
  // rays
675
688
  i = ec.length;
676
689
  while (i--) {
@@ -735,7 +748,12 @@ class Renderer {
735
748
 
736
749
  let h = this.handler;
737
750
 
738
- h.gl.clearColor(this.backgroundColor.x, this.backgroundColor.y, this.backgroundColor.z, 1.0);
751
+ h.gl.clearColor(
752
+ this.backgroundColor.x,
753
+ this.backgroundColor.y,
754
+ this.backgroundColor.z,
755
+ 1.0
756
+ );
739
757
  h.gl.clear(h.gl.COLOR_BUFFER_BIT | h.gl.DEPTH_BUFFER_BIT);
740
758
 
741
759
  e.dispatch(e.draw, this);
@@ -964,7 +982,6 @@ class Renderer {
964
982
  start() {
965
983
  this.handler.start();
966
984
  }
967
-
968
985
  }
969
986
 
970
987
  export { Renderer };
@@ -335,7 +335,7 @@ class RendererEvents extends Events {
335
335
  */
336
336
  onMouseMove(event, sys) {
337
337
  var ms = this.mouseState;
338
- this.updateButtonsStates(sys.buttons)
338
+ this.updateButtonsStates(sys.buttons);
339
339
  ms.sys = event;
340
340
 
341
341
  let ex = event.clientX,
@@ -2,7 +2,7 @@
2
2
  * @module og/scene/BaseNode
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
7
  /**
8
8
  * Scene node base class.
@@ -11,7 +11,6 @@
11
11
  */
12
12
  class BaseNode {
13
13
  constructor(name) {
14
-
15
14
  /**
16
15
  * Node name.
17
16
  * @public
@@ -111,4 +110,4 @@ class BaseNode {
111
110
  }
112
111
  }
113
112
 
114
- export { BaseNode };
113
+ export { BaseNode };
@@ -1124,7 +1124,7 @@ export class Planet extends RenderNode {
1124
1124
  gl.disable(gl.POLYGON_OFFSET_FILL);
1125
1125
 
1126
1126
  if (frustumIndex === cam.FARTHEST_FRUSTUM_INDEX) {
1127
- if (this._skipPreRender && (!this._renderCompletedActivated || cam.isMoved)) {
1127
+ if (this._skipPreRender/* && (!this._renderCompletedActivated || cam.isMoved)*/) {
1128
1128
  this._collectRenderNodes();
1129
1129
  }
1130
1130
  this._skipPreRender = true;
@@ -1171,7 +1171,7 @@ export class Planet extends RenderNode {
1171
1171
  gl.TEXTURE_2D,
1172
1172
  (this.camera._lonLat.height > 329958.0 &&
1173
1173
  (this._nightTexture || this.transparentTexture)) ||
1174
- this.transparentTexture
1174
+ this.transparentTexture
1175
1175
  );
1176
1176
  gl.uniform1i(shu.nightTexture, this.SLICE_SIZE);
1177
1177
 
@@ -1,7 +1,7 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- import { BaseNode } from './BaseNode.js';
4
- import { Events } from '../Events.js';
3
+ import { BaseNode } from "./BaseNode.js";
4
+ import { Events } from "../Events.js";
5
5
 
6
6
  /**
7
7
  * Render node is a logical part of a render mechanism. Represents scene rendering.
@@ -98,8 +98,7 @@ class RenderNode extends BaseNode {
98
98
  n = this.name;
99
99
 
100
100
  if (r) {
101
- if (r.renderNodes[n] &&
102
- r.renderNodes[n].isEqual(this)) {
101
+ if (r.renderNodes[n] && r.renderNodes[n].isEqual(this)) {
103
102
  r.renderNodes[n] = null;
104
103
  delete r.renderNodes[n];
105
104
  }
@@ -195,7 +194,10 @@ class RenderNode extends BaseNode {
195
194
 
196
195
  if (this.renderer) {
197
196
  if (this._isActive && this._pickingId === -1) {
198
- this._pickingId = this.renderer.addPickingCallback(this, this._entityCollectionPickingCallback);
197
+ this._pickingId = this.renderer.addPickingCallback(
198
+ this,
199
+ this._entityCollectionPickingCallback
200
+ );
199
201
  } else if (!this._isActive && this._pickingId !== -1) {
200
202
  this.renderer.removePickingCallback(this._pickingId);
201
203
  this._pickingId = -1;
@@ -277,7 +279,6 @@ class RenderNode extends BaseNode {
277
279
  */
278
280
  drawPickingEntityCollections(ec) {
279
281
  if (ec.length) {
280
-
281
282
  var gl = this.renderer.handler.gl;
282
283
 
283
284
  gl.disable(gl.CULL_FACE);
@@ -292,6 +293,12 @@ class RenderNode extends BaseNode {
292
293
  ec[i]._fadingOpacity && ec[i].billboardHandler.drawPicking();
293
294
  }
294
295
 
296
+ // geoObject pass
297
+ i = ec.length;
298
+ while (i--) {
299
+ ec[i]._fadingOpacity && ec[i].geoObjectHandler.drawPicking();
300
+ }
301
+
295
302
  // label pass
296
303
  i = ec.length;
297
304
  while (i--) {
@@ -344,4 +351,4 @@ class RenderNode extends BaseNode {
344
351
  }
345
352
  }
346
353
 
347
- export { RenderNode };
354
+ export { RenderNode };
@@ -0,0 +1,211 @@
1
+ /**
2
+ * @module og/shaders/drawnode
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Program } from "../webgl/Program.js";
8
+
9
+ export const geo_object = () =>
10
+ new Program("geo_object", {
11
+ uniforms: {
12
+ viewMatrix: "mat4",
13
+ projectionMatrix: "mat4",
14
+ normalMatrix: "mat3",
15
+
16
+ uScaleByDistance: "vec3",
17
+
18
+ eyePositionHigh: "vec3",
19
+ eyePositionLow: "vec3",
20
+
21
+ lightsPositions: "vec4",
22
+ lightsParamsv: "vec3",
23
+ lightsParamsf: "float"
24
+ },
25
+ attributes: {
26
+ aVertexPosition: "vec3",
27
+ aVertexNormal: "vec3",
28
+ aPositionHigh: { type: "vec3", divisor: 1 },
29
+ aPositionLow: { type: "vec3", divisor: 1 },
30
+ aDirection: { type: "vec3", divisor: 1 },
31
+ aPitchRoll: { type: "vec2", divisor: 1 },
32
+ aColor: { type: "vec4", divisor: 1 },
33
+ aScale: { type: "float", divisor: 1 }
34
+ },
35
+ vertexShader: `precision highp float;
36
+
37
+ attribute vec3 aVertexPosition;
38
+ attribute vec3 aVertexNormal;
39
+ attribute vec3 aPositionHigh;
40
+ attribute vec3 aPositionLow;
41
+ attribute vec3 aDirection;
42
+ attribute vec2 aPitchRoll;
43
+ attribute vec4 aColor;
44
+ attribute float aScale;
45
+
46
+ uniform vec3 uScaleByDistance;
47
+ uniform mat4 projectionMatrix;
48
+ uniform mat4 viewMatrix;
49
+ uniform mat3 normalMatrix;
50
+
51
+ uniform vec3 eyePositionHigh;
52
+ uniform vec3 eyePositionLow;
53
+
54
+ varying vec3 vNormal;
55
+ varying vec4 vPosition;
56
+ varying vec4 vColor;
57
+
58
+ const float RADIANS = 3.141592653589793 / 180.0;
59
+
60
+ void main(void) {
61
+
62
+ vColor = aColor;
63
+ float roll = aPitchRoll.y * RADIANS;
64
+ mat3 rotZ = mat3(
65
+ vec3(cos(roll), sin(roll), 0.0),
66
+ vec3(-sin(roll), cos(roll), 0.0),
67
+ vec3(0.0, 0.0, 1.0)
68
+ );
69
+
70
+ float pitch = aPitchRoll.x * RADIANS;
71
+ mat3 rotX = mat3(
72
+ vec3(1.0, 0.0, 0.0),
73
+ vec3(0.0, cos(pitch), sin(pitch)),
74
+ vec3(0.0, -sin(pitch), cos(pitch))
75
+ );
76
+
77
+ vec3 position = aPositionHigh + aPositionLow;
78
+ vec3 r = cross(normalize(-position), aDirection);
79
+ mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ; /*up=-cross(aDirection, r)*/
80
+
81
+ vec3 look = position - (eyePositionHigh + eyePositionLow);
82
+ float lookLength = length(look);
83
+ float scd = aScale * (1.0 - smoothstep(uScaleByDistance[0], uScaleByDistance[1], lookLength)) * (1.0 - step(uScaleByDistance[2], lookLength));
84
+ vNormal = normalMatrix * modelMatrix * aVertexNormal;
85
+
86
+ vec3 highDiff = aPositionHigh - eyePositionHigh;
87
+ vec3 lowDiff = aPositionLow + modelMatrix * (aVertexPosition * scd) - eyePositionLow;
88
+
89
+ mat4 viewMatrixRTE = viewMatrix;
90
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
91
+
92
+ vPosition = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
93
+
94
+ gl_Position = projectionMatrix * vPosition;
95
+ }`,
96
+ fragmentShader: `precision highp float;
97
+
98
+ varying vec4 vColor;
99
+ #define MAX_POINT_LIGHTS 1
100
+
101
+ uniform vec4 lightsPositions[MAX_POINT_LIGHTS];
102
+ uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
103
+ uniform float lightsParamsf[MAX_POINT_LIGHTS];
104
+
105
+ varying vec3 vNormal;
106
+ varying vec4 vPosition;
107
+
108
+ void main(void) {
109
+ vec3 lightWeighting;
110
+ vec3 lightDirection;
111
+ vec3 normal;
112
+ vec3 eyeDirection;
113
+ vec3 reflectionDirection;
114
+ float specularLightWeighting;
115
+ float diffuseLightWeighting;
116
+
117
+ lightDirection = normalize(lightsPositions[0].xyz - vPosition.xyz * lightsPositions[0].w);
118
+ normal = normalize(vNormal);
119
+ eyeDirection = normalize(-vPosition.xyz);
120
+ reflectionDirection = reflect(-lightDirection, normal);
121
+ specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), lightsParamsf[0]);
122
+ diffuseLightWeighting = max(dot(normal, lightDirection), 0.0);
123
+ lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
124
+ gl_FragColor = vec4(lightWeighting, 1.0) * vColor;
125
+ }`
126
+ });
127
+
128
+ export const geo_object_picking = () =>
129
+ new Program("geo_object_picking", {
130
+ uniforms: {
131
+ viewMatrix: "mat4",
132
+ projectionMatrix: "mat4",
133
+
134
+ uScaleByDistance: "vec3",
135
+
136
+ eyePositionHigh: "vec3",
137
+ eyePositionLow: "vec3",
138
+ pickingScale: "float",
139
+
140
+ },
141
+ attributes: {
142
+ aVertexPosition: "vec3",
143
+ aPositionHigh: { type: "vec3", divisor: 1 },
144
+ aPositionLow: { type: "vec3", divisor: 1 },
145
+ aDirection: { type: "vec3", divisor: 1 },
146
+ aPitchRoll: { type: "vec2", divisor: 1 },
147
+ aPickingColor: { type: "vec3", divisor: 1 },
148
+ aScale: { type: "float", divisor: 1 }
149
+ },
150
+ vertexShader: `precision highp float;
151
+
152
+ attribute vec3 aVertexPosition;
153
+ attribute vec3 aPositionHigh;
154
+ attribute vec3 aPositionLow;
155
+ attribute vec3 aDirection;
156
+ attribute vec2 aPitchRoll;
157
+ attribute vec3 aPickingColor;
158
+ attribute float aScale;
159
+
160
+ uniform vec3 uScaleByDistance;
161
+ uniform mat4 projectionMatrix;
162
+ uniform mat4 viewMatrix;
163
+ uniform float pickingScale;
164
+
165
+ uniform vec3 eyePositionHigh;
166
+ uniform vec3 eyePositionLow;
167
+
168
+ varying vec3 vColor;
169
+
170
+ const float RADIANS = 3.141592653589793 / 180.0;
171
+
172
+ void main(void) {
173
+
174
+ vColor = aPickingColor;
175
+ float roll = aPitchRoll.y * RADIANS;
176
+ mat3 rotZ = mat3(
177
+ vec3(cos(roll), sin(roll), 0.0),
178
+ vec3(-sin(roll), cos(roll), 0.0),
179
+ vec3(0.0, 0.0, 1.0)
180
+ );
181
+
182
+ float pitch = aPitchRoll.x * RADIANS;
183
+ mat3 rotX = mat3(
184
+ vec3(1.0, 0.0, 0.0),
185
+ vec3(0.0, cos(pitch), sin(pitch)),
186
+ vec3(0.0, -sin(pitch), cos(pitch))
187
+ );
188
+
189
+ vec3 position = aPositionHigh + aPositionLow;
190
+ vec3 r = cross(normalize(-position), aDirection);
191
+ mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ; /*up=-cross(aDirection, r)*/
192
+
193
+ vec3 look = position - (eyePositionHigh + eyePositionLow);
194
+ float lookLength = length(look);
195
+ float scd = aScale * pickingScale * (1.0 - smoothstep(uScaleByDistance[0], uScaleByDistance[1], lookLength)) * (1.0 - step(uScaleByDistance[2], lookLength));
196
+
197
+ vec3 highDiff = aPositionHigh - eyePositionHigh;
198
+ vec3 lowDiff = aPositionLow + modelMatrix * (aVertexPosition * scd) - eyePositionLow;
199
+
200
+ mat4 viewMatrixRTE = viewMatrix;
201
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
202
+
203
+ gl_Position = projectionMatrix *viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
204
+ }`,
205
+ fragmentShader:
206
+ `precision highp float;
207
+ varying vec3 vColor;
208
+ void main () {
209
+ gl_FragColor = vec4(vColor, 1.0);
210
+ }`
211
+ });
@@ -1,42 +1,42 @@
1
- /**
2
- * @module og/shaders/pointCloud
3
- */
4
-
5
- 'use strict';
6
-
7
- import { Program } from '../webgl/Program.js';
8
- import { types } from '../webgl/types.js';
9
-
10
- //Picking is the same
11
- export function pointCloud() {
12
- return new Program("pointCloud", {
13
- uniforms: {
14
- projectionViewMatrix: { type: types.MAT4 },
15
- opacity: { type: types.FLOAT },
16
- pointSize: { type: types.FLOAT }
17
- },
18
- attributes: {
19
- coordinates: { type: types.VEC3, enableArray: true },
20
- colors: { type: types.VEC3, enableArray: true }
21
- },
22
- vertexShader:
23
- `attribute vec3 coordinates;
24
- attribute vec4 colors;
25
- uniform mat4 projectionViewMatrix;
26
- uniform float opacity;
27
- uniform float pointSize;
28
- varying vec4 color;
29
- void main() {
30
- color = colors;
31
- color.a *= opacity;
32
- gl_Position = projectionViewMatrix * vec4(coordinates, 1.0);
33
- gl_PointSize = pointSize;
34
- }`,
35
- fragmentShader:
36
- `precision highp float;
37
- varying vec4 color;
38
- void main(void) {
39
- gl_FragColor = color;
40
- }`
41
- });
1
+ /**
2
+ * @module og/shaders/pointCloud
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ import { Program } from '../webgl/Program.js';
8
+ import { types } from '../webgl/types.js';
9
+
10
+ //Picking is the same
11
+ export function pointCloud() {
12
+ return new Program("pointCloud", {
13
+ uniforms: {
14
+ projectionViewMatrix: { type: types.MAT4 },
15
+ opacity: { type: types.FLOAT },
16
+ pointSize: { type: types.FLOAT }
17
+ },
18
+ attributes: {
19
+ coordinates: { type: types.VEC3, enableArray: true },
20
+ colors: { type: types.VEC3, enableArray: true }
21
+ },
22
+ vertexShader:
23
+ `attribute vec3 coordinates;
24
+ attribute vec4 colors;
25
+ uniform mat4 projectionViewMatrix;
26
+ uniform float opacity;
27
+ uniform float pointSize;
28
+ varying vec4 color;
29
+ void main() {
30
+ color = colors;
31
+ color.a *= opacity;
32
+ gl_Position = projectionViewMatrix * vec4(coordinates, 1.0);
33
+ gl_PointSize = pointSize;
34
+ }`,
35
+ fragmentShader:
36
+ `precision highp float;
37
+ varying vec4 color;
38
+ void main(void) {
39
+ gl_FragColor = color;
40
+ }`
41
+ });
42
42
  }
@@ -2,10 +2,10 @@
2
2
  * @module og/shaders/shape
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { Program } from '../webgl/Program.js';
8
- import { types } from '../webgl/types.js';
7
+ import { Program } from "../webgl/Program.js";
8
+ import { types } from "../webgl/types.js";
9
9
 
10
10
  export function shape_wl() {
11
11
  return new Program("shape_wl", {
@@ -23,12 +23,11 @@ export function shape_wl() {
23
23
  uSampler: { type: types.SAMPLER2D }
24
24
  },
25
25
  attributes: {
26
- aVertexNormal: { type: types.VEC3, enableArray: true },
27
- aVertexPosition: { type: types.VEC3, enableArray: true },
28
- aTextureCoord: { type: types.VEC2, enableArray: true }
26
+ aVertexNormal: { type: types.VEC3 },
27
+ aVertexPosition: { type: types.VEC3 },
28
+ aTextureCoord: { type: types.VEC2 }
29
29
  },
30
- vertexShader:
31
- `attribute vec3 aVertexNormal;
30
+ vertexShader: `attribute vec3 aVertexNormal;
32
31
  attribute vec3 aVertexPosition;
33
32
  attribute vec2 aTextureCoord;
34
33
  uniform mat4 projectionMatrix;
@@ -45,8 +44,7 @@ export function shape_wl() {
45
44
  vPosition = viewMatrix * modelMatrix * vec4(aVertexPosition, 1.0);
46
45
  gl_Position = projectionMatrix * vPosition;
47
46
  }`,
48
- fragmentShader:
49
- `precision highp float;
47
+ fragmentShader: `precision highp float;
50
48
  varying vec2 vTextureCoord;
51
49
  varying vec3 vNormal;
52
50
  varying vec4 vPosition;
@@ -90,8 +88,7 @@ export function shape_nl() {
90
88
  aVertexPosition: { type: types.VEC3, enableArray: true },
91
89
  aTextureCoord: { type: types.VEC2, enableArray: true }
92
90
  },
93
- vertexShader:
94
- `attribute vec3 aVertexPosition;
91
+ vertexShader: `attribute vec3 aVertexPosition;
95
92
  attribute vec2 aTextureCoord;
96
93
  uniform mat4 projectionViewMatrix;
97
94
  uniform mat4 modelMatrix;
@@ -101,8 +98,7 @@ export function shape_nl() {
101
98
  gl_Position = projectionViewMatrix * (modelMatrix * vec4(aVertexPosition, 1.0));
102
99
  vTextureCoord = aTextureCoord;
103
100
  }`,
104
- fragmentShader:
105
- `precision highp float;
101
+ fragmentShader: `precision highp float;
106
102
  uniform vec4 uColor;
107
103
  uniform sampler2D uSampler;
108
104
  varying vec2 vTextureCoord;
@@ -122,16 +118,14 @@ export function shape_picking() {
122
118
  attributes: {
123
119
  aVertexPosition: { type: types.VEC3, enableArray: true }
124
120
  },
125
- vertexShader:
126
- `attribute vec3 aVertexPosition;
121
+ vertexShader: `attribute vec3 aVertexPosition;
127
122
  uniform mat4 projectionViewMatrix;
128
123
  uniform mat4 modelMatrix;
129
124
 
130
125
  void main(void) {
131
126
  gl_Position = projectionViewMatrix * (modelMatrix * vec4(aVertexPosition, 1.0));
132
127
  }`,
133
- fragmentShader:
134
- `precision highp float;
128
+ fragmentShader: `precision highp float;
135
129
  uniform vec4 uColor;
136
130
  uniform sampler2D uSampler;
137
131
  void main(void) {
@@ -1,37 +1,37 @@
1
- /**
2
- * @module og/shaders/skybox
3
- */
4
-
5
- 'use strict';
6
-
7
- import { Program } from '../webgl/Program.js';
8
- import { types } from '../webgl/types.js';
9
-
10
- export function skybox() {
11
- return new Program("skybox", {
12
- uniforms: {
13
- projectionViewMatrix: { type: types.MAT4 },
14
- uSampler: { type: types.SAMPLERCUBE },
15
- pos: { type: types.VEC3 }
16
- },
17
- attributes: {
18
- aVertexPosition: { type: types.VEC3, enableArray: true }
19
- },
20
- vertexShader:
21
- `attribute vec3 aVertexPosition;
22
- uniform mat4 projectionViewMatrix;
23
- uniform vec3 pos;
24
- varying vec3 vTextureCoord;
25
- void main(void) {
26
- vTextureCoord = aVertexPosition;
27
- gl_Position = projectionViewMatrix * vec4(aVertexPosition + pos, 1.0);
28
- }`,
29
- fragmentShader:
30
- `precision lowp float;
31
- varying vec3 vTextureCoord;
32
- uniform samplerCube uSampler;
33
- void main(void) {
34
- gl_FragColor = textureCube(uSampler, vTextureCoord);
35
- }`
36
- });
1
+ /**
2
+ * @module og/shaders/skybox
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ import { Program } from '../webgl/Program.js';
8
+ import { types } from '../webgl/types.js';
9
+
10
+ export function skybox() {
11
+ return new Program("skybox", {
12
+ uniforms: {
13
+ projectionViewMatrix: { type: types.MAT4 },
14
+ uSampler: { type: types.SAMPLERCUBE },
15
+ pos: { type: types.VEC3 }
16
+ },
17
+ attributes: {
18
+ aVertexPosition: { type: types.VEC3, enableArray: true }
19
+ },
20
+ vertexShader:
21
+ `attribute vec3 aVertexPosition;
22
+ uniform mat4 projectionViewMatrix;
23
+ uniform vec3 pos;
24
+ varying vec3 vTextureCoord;
25
+ void main(void) {
26
+ vTextureCoord = aVertexPosition;
27
+ gl_Position = projectionViewMatrix * vec4(aVertexPosition + pos, 1.0);
28
+ }`,
29
+ fragmentShader:
30
+ `precision lowp float;
31
+ varying vec3 vTextureCoord;
32
+ uniform samplerCube uSampler;
33
+ void main(void) {
34
+ gl_FragColor = textureCube(uSampler, vTextureCoord);
35
+ }`
36
+ });
37
37
  }