@openglobus/og 0.22.1 → 0.23.0

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 (168) hide show
  1. package/css/og.css +137 -1
  2. package/lib/@openglobus/js/Object3d.d.ts +20 -10
  3. package/lib/@openglobus/js/camera/Camera.d.ts +9 -0
  4. package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
  5. package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
  6. package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
  7. package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  8. package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  9. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  10. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  11. package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  12. package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  13. package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  14. package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  15. package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
  16. package/lib/@openglobus/js/control/index.d.ts +2 -0
  17. package/lib/@openglobus/js/entity/Entity.d.ts +278 -19
  18. package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
  19. package/lib/@openglobus/js/entity/GeoObject.d.ts +141 -36
  20. package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
  21. package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
  22. package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
  23. package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
  24. package/lib/@openglobus/js/index.d.ts +2 -1
  25. package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
  26. package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
  27. package/lib/@openglobus/js/math/Quat.d.ts +46 -33
  28. package/lib/@openglobus/js/math/Ray.d.ts +10 -4
  29. package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
  30. package/lib/@openglobus/js/math.d.ts +2 -2
  31. package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
  32. package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
  33. package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  34. package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  35. package/lib/@openglobus/js/renderer/Renderer.d.ts +64 -44
  36. package/lib/@openglobus/js/renderer/RendererEvents.d.ts +1 -0
  37. package/lib/@openglobus/js/scene/Planet.d.ts +11 -7
  38. package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
  39. package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
  40. package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
  41. package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
  42. package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
  43. package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
  44. package/lib/@openglobus/js/ui/Input.d.ts +32 -0
  45. package/lib/@openglobus/js/ui/View.d.ts +3 -1
  46. package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
  47. package/lib/@openglobus/js/utils/shared.d.ts +22 -0
  48. package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
  49. package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
  50. package/lib/@openglobus/js/webgl/Handler.d.ts +3 -0
  51. package/lib/@openglobus/og.css +1 -1
  52. package/lib/@openglobus/og.esm.js +1 -1
  53. package/lib/@openglobus/og.esm.js.map +1 -1
  54. package/lib/@openglobus/og.umd.js +1 -1
  55. package/lib/@openglobus/og.umd.js.map +1 -1
  56. package/lib/js/Globe.js +2 -1
  57. package/lib/js/Object3d.d.ts +20 -10
  58. package/lib/js/Object3d.js +124 -48
  59. package/lib/js/camera/Camera.d.ts +9 -0
  60. package/lib/js/camera/Camera.js +27 -1
  61. package/lib/js/camera/Frustum.d.ts +3 -0
  62. package/lib/js/camera/Frustum.js +7 -0
  63. package/lib/js/control/Atmosphere.js +10 -6
  64. package/lib/js/control/CameraLock.d.ts +38 -0
  65. package/lib/js/control/CameraLock.js +216 -0
  66. package/lib/js/control/Control.js +1 -1
  67. package/lib/js/control/DebugInfo.js +13 -3
  68. package/lib/js/control/KeyboardNavigation.js +1 -1
  69. package/lib/js/control/ScaleControl.js +9 -3
  70. package/lib/js/control/SimpleNavigation.d.ts +27 -10
  71. package/lib/js/control/SimpleNavigation.js +148 -49
  72. package/lib/js/control/Sun.js +1 -1
  73. package/lib/js/control/elevationProfile/ElevationProfileScene.js +4 -4
  74. package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
  75. package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
  76. package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
  77. package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
  78. package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
  79. package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
  80. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
  81. package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +502 -0
  82. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
  83. package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
  84. package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
  85. package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +106 -0
  86. package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
  87. package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +34 -0
  88. package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
  89. package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
  90. package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
  91. package/lib/js/control/geoObjectEditor/colors.js +8 -0
  92. package/lib/js/control/index.d.ts +2 -0
  93. package/lib/js/control/index.js +2 -0
  94. package/lib/js/control/timeline/TimelineControl.js +2 -0
  95. package/lib/js/entity/Entity.d.ts +278 -19
  96. package/lib/js/entity/Entity.js +483 -63
  97. package/lib/js/entity/EntityCollection.d.ts +8 -9
  98. package/lib/js/entity/EntityCollection.js +48 -45
  99. package/lib/js/entity/GeoObject.d.ts +141 -36
  100. package/lib/js/entity/GeoObject.js +153 -90
  101. package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
  102. package/lib/js/entity/GeoObjectHandler.js +198 -295
  103. package/lib/js/entity/InstanceData.d.ts +76 -0
  104. package/lib/js/entity/InstanceData.js +344 -0
  105. package/lib/js/entity/Polyline.d.ts +19 -6
  106. package/lib/js/entity/Polyline.js +76 -36
  107. package/lib/js/entity/PolylineHandler.d.ts +7 -0
  108. package/lib/js/entity/PolylineHandler.js +26 -1
  109. package/lib/js/index.d.ts +2 -1
  110. package/lib/js/index.js +2 -1
  111. package/lib/js/layer/Bing.js +2 -2
  112. package/lib/js/layer/Vector.d.ts +4 -0
  113. package/lib/js/layer/Vector.js +16 -0
  114. package/lib/js/light/LightSource.d.ts +1 -139
  115. package/lib/js/light/LightSource.js +21 -227
  116. package/lib/js/math/Quat.d.ts +46 -33
  117. package/lib/js/math/Quat.js +91 -90
  118. package/lib/js/math/Ray.d.ts +10 -4
  119. package/lib/js/math/Ray.js +20 -4
  120. package/lib/js/math/Vec3.d.ts +15 -0
  121. package/lib/js/math/Vec3.js +30 -1
  122. package/lib/js/math.d.ts +2 -2
  123. package/lib/js/math.js +3 -3
  124. package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
  125. package/lib/js/quadTree/EntityCollectionNode.js +8 -8
  126. package/lib/js/quadTree/Node.d.ts +1 -1
  127. package/lib/js/quadTree/Node.js +2 -2
  128. package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
  129. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
  130. package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
  131. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
  132. package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
  133. package/lib/js/renderer/Renderer.d.ts +64 -44
  134. package/lib/js/renderer/Renderer.js +264 -263
  135. package/lib/js/renderer/RendererEvents.d.ts +1 -0
  136. package/lib/js/renderer/RendererEvents.js +2 -1
  137. package/lib/js/scene/Planet.d.ts +11 -7
  138. package/lib/js/scene/Planet.js +109 -87
  139. package/lib/js/scene/RenderNode.d.ts +10 -25
  140. package/lib/js/scene/RenderNode.js +70 -58
  141. package/lib/js/shaders/depth.js +2 -5
  142. package/lib/js/shaders/drawnode.d.ts +1 -0
  143. package/lib/js/shaders/drawnode.js +51 -52
  144. package/lib/js/shaders/geoObject.d.ts +1 -0
  145. package/lib/js/shaders/geoObject.js +154 -91
  146. package/lib/js/shaders/polyline.js +68 -51
  147. package/lib/js/shaders/utils.d.ts +1 -1
  148. package/lib/js/shaders/utils.js +11 -0
  149. package/lib/js/ui/Checkbox.d.ts +31 -0
  150. package/lib/js/ui/Checkbox.js +110 -0
  151. package/lib/js/ui/Color.js +2 -1
  152. package/lib/js/ui/Dialog.d.ts +3 -0
  153. package/lib/js/ui/Dialog.js +20 -0
  154. package/lib/js/ui/Input.d.ts +32 -0
  155. package/lib/js/ui/Input.js +107 -0
  156. package/lib/js/ui/View.d.ts +3 -1
  157. package/lib/js/ui/View.js +6 -0
  158. package/lib/js/utils/objParser.d.ts +44 -12
  159. package/lib/js/utils/objParser.js +241 -149
  160. package/lib/js/utils/shared.d.ts +22 -0
  161. package/lib/js/utils/shared.js +34 -0
  162. package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
  163. package/lib/js/webgl/Framebuffer.d.ts +35 -8
  164. package/lib/js/webgl/Framebuffer.js +136 -29
  165. package/lib/js/webgl/Handler.d.ts +3 -0
  166. package/lib/js/webgl/Handler.js +11 -1
  167. package/lib/js/webgl/Program.js +0 -8
  168. package/package.json +4 -2
@@ -9,9 +9,11 @@ export const geo_object = () => new Program("geo_object", {
9
9
  uScaleByDistance: "vec3",
10
10
  eyePositionHigh: "vec3",
11
11
  eyePositionLow: "vec3",
12
- lightsPositions: "vec3",
13
- lightsParamsv: "vec3",
14
- lightsParamsf: "float",
12
+ rtcEyePositionHigh: "vec3",
13
+ rtcEyePositionLow: "vec3",
14
+ sunPosition: "vec3",
15
+ materialParams: "vec3",
16
+ materialShininess: "float",
15
17
  uTexture: "sampler2d",
16
18
  uUseTexture: "float",
17
19
  useLighting: "float"
@@ -20,8 +22,9 @@ export const geo_object = () => new Program("geo_object", {
20
22
  aVertexPosition: "vec3",
21
23
  aVertexNormal: "vec3",
22
24
  aTexCoord: "vec2",
23
- aPositionHigh: { type: "vec3", divisor: 1 },
24
- aPositionLow: { type: "vec3", divisor: 1 },
25
+ aLocalPosition: { type: "vec3", divisor: 1 },
26
+ aRTCPositionHigh: { type: "vec3", divisor: 1 },
27
+ aRTCPositionLow: { type: "vec3", divisor: 1 },
25
28
  aColor: { type: "vec4", divisor: 1 },
26
29
  aScale: { type: "vec3", divisor: 1 },
27
30
  aTranslate: { type: "vec3", divisor: 1 },
@@ -32,8 +35,10 @@ export const geo_object = () => new Program("geo_object", {
32
35
 
33
36
  attribute vec3 aVertexPosition;
34
37
  attribute vec3 aVertexNormal;
35
- attribute vec3 aPositionHigh;
36
- attribute vec3 aPositionLow;
38
+
39
+ attribute vec3 aRTCPositionHigh;
40
+ attribute vec3 aRTCPositionLow;
41
+
37
42
  attribute vec4 aColor;
38
43
  attribute vec3 aScale;
39
44
  attribute vec3 aTranslate;
@@ -41,6 +46,7 @@ export const geo_object = () => new Program("geo_object", {
41
46
  attribute float aUseTexture;
42
47
  attribute vec2 aTexCoord;
43
48
  attribute vec4 qRot;
49
+ attribute vec3 aLocalPosition;
44
50
 
45
51
  uniform vec3 uScaleByDistance;
46
52
  uniform mat4 projectionMatrix;
@@ -48,6 +54,9 @@ export const geo_object = () => new Program("geo_object", {
48
54
 
49
55
  uniform vec3 eyePositionHigh;
50
56
  uniform vec3 eyePositionLow;
57
+
58
+ uniform vec3 rtcEyePositionHigh;
59
+ uniform vec3 rtcEyePositionLow;
51
60
 
52
61
  varying vec3 cameraPosition;
53
62
  varying vec3 vNormal;
@@ -64,50 +73,37 @@ export const geo_object = () => new Program("geo_object", {
64
73
  return;
65
74
  }
66
75
 
67
- vec3 position = aPositionHigh + aPositionLow;
68
- cameraPosition = eyePositionHigh + eyePositionLow;
69
-
70
- vec3 look = cameraPosition - position;
71
- float lookLength = length(look);
72
-
73
76
  vColor = aColor;
74
- vTexCoords = aTexCoord;
75
-
77
+ vTexCoords = aTexCoord;
78
+
76
79
  mat4 viewMatrixRTE = viewMatrix;
77
80
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
78
-
79
- vec3 highDiff = aPositionHigh - eyePositionHigh;
80
- vec3 lowDiff = aPositionLow - eyePositionLow;
81
-
82
- vNormal = qRotate(qRot, aVertexNormal);
83
-
84
- // if(lookLength > uScaleByDistance[1])
85
- // {
86
- // scd = uScaleByDistance[1] / uScaleByDistance[0];
87
- // }
88
- // else if(lookLength > uScaleByDistance[0])
89
- // {
90
- // scd = lookLength / uScaleByDistance[0];
91
- // }
92
- // ... is the same math
93
- // use scaleByDistance: [1.0, 1.0, 1.0] for real sized objects
94
- float scd = uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
95
81
 
96
- vec3 vert = qRotate(qRot, scd * (aVertexPosition * aScale + aTranslate));
82
+ vec3 highDiff = aRTCPositionHigh - rtcEyePositionHigh;
83
+ vec3 lowDiff = aRTCPositionLow - rtcEyePositionLow;
84
+
85
+ cameraPosition = eyePositionHigh + eyePositionLow;
86
+
87
+ highDiff = highDiff * step(1.0, length(highDiff));
97
88
 
98
- vert += lowDiff;
89
+ vec4 positionInViewSpace = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
90
+
91
+ float lookLength = length(positionInViewSpace.xyz);
92
+
93
+ vNormal = normalize(qRotate(qRot, aVertexNormal));
99
94
 
100
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff * step(1.0, length(highDiff)) + vert, 1.0);
95
+ float scd = uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
96
+ vec3 vert = qRotate(qRot, scd * (aVertexPosition * aScale + aTranslate)) + scd * aLocalPosition;
97
+
98
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff + vert, 1.0);
101
99
 
102
- v_vertex = position + vert;
100
+ v_vertex = positionInViewSpace.xyz + vert;
103
101
  }`,
104
102
  fragmentShader: `precision highp float;
105
-
106
- #define MAX_POINT_LIGHTS 1
107
103
 
108
- uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
109
- uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
110
- uniform float lightsParamsf[MAX_POINT_LIGHTS];
104
+ uniform vec3 sunPosition;
105
+ uniform vec3 materialParams[3];
106
+ uniform float materialShininess;
111
107
  uniform sampler2D uTexture;
112
108
  uniform float uUseTexture;
113
109
  uniform float useLighting;
@@ -123,21 +119,23 @@ export const geo_object = () => new Program("geo_object", {
123
119
  vec3 lightWeighting = vec3(1.0);
124
120
 
125
121
  if(useLighting != 0.0){
126
- vec3 normal = normalize(vNormal);
127
- vec3 lightDir = normalize(lightsPositions[0]);
122
+ vec3 normal = vNormal;
123
+ vec3 lightDir = normalize(sunPosition);
128
124
  vec3 viewDir = normalize(cameraPosition - v_vertex);
129
125
  vec3 reflectionDirection = reflect(-lightDir, normal);
130
126
  float reflection = max( dot(reflectionDirection, viewDir), 0.0);
131
- float specularLightWeighting = pow( reflection, lightsParamsf[0]);
127
+ float specularLightWeighting = pow( reflection, materialShininess);
132
128
  float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
133
- lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
129
+ lightWeighting = vColor.rgb * materialParams[0] + materialParams[1] * diffuseLightWeighting + materialParams[2] * specularLightWeighting;
130
+ } else {
131
+ lightWeighting = vColor.rgb;
134
132
  }
135
133
 
136
134
  if(uUseTexture > 0.0) {
137
- vec4 tColor = texture2D(uTexture, vTexCoords);
138
- gl_FragColor = vec4(tColor.rgb * lightWeighting, tColor.a);
135
+ vec4 texColor = texture2D(uTexture, vTexCoords);
136
+ gl_FragColor = vec4(texColor.rgb * lightWeighting, texColor.a);
139
137
  } else {
140
- gl_FragColor = vec4(vColor.rgb * lightWeighting, vColor.a);
138
+ gl_FragColor = vec4(lightWeighting, vColor.a);
141
139
  }
142
140
  }`
143
141
  });
@@ -146,33 +144,37 @@ export const geo_object_picking = () => new Program("geo_object_picking", {
146
144
  viewMatrix: "mat4",
147
145
  projectionMatrix: "mat4",
148
146
  uScaleByDistance: "vec3",
149
- eyePositionHigh: "vec3",
150
- eyePositionLow: "vec3",
151
- pickingScale: "vec3"
147
+ pickingScale: "vec3",
148
+ rtcEyePositionHigh: "vec3",
149
+ rtcEyePositionLow: "vec3",
152
150
  },
153
151
  attributes: {
154
152
  aVertexPosition: "vec3",
155
- aPositionHigh: { type: "vec3", divisor: 1 },
156
- aPositionLow: { type: "vec3", divisor: 1 },
153
+ aRTCPositionHigh: { type: "vec3", divisor: 1 },
154
+ aRTCPositionLow: { type: "vec3", divisor: 1 },
157
155
  aPickingColor: { type: "vec3", divisor: 1 },
158
156
  aScale: { type: "vec3", divisor: 1 },
159
157
  aTranslate: { type: "vec3", divisor: 1 },
158
+ aLocalPosition: { type: "vec3", divisor: 1 },
160
159
  aDispose: { type: "float", divisor: 1 },
161
160
  qRot: { type: "vec4", divisor: 1 }
162
161
  },
163
162
  vertexShader: `precision highp float;
164
163
 
165
164
  attribute vec3 aVertexPosition;
166
- attribute vec3 aPositionHigh;
167
- attribute vec3 aPositionLow;
165
+ attribute vec3 aRTCPositionHigh;
166
+ attribute vec3 aRTCPositionLow;
168
167
  attribute vec3 aPickingColor;
169
168
  attribute vec3 aScale;
170
169
  attribute vec3 aTranslate;
171
170
  attribute float aDispose;
172
171
  attribute vec4 qRot;
173
172
 
174
- uniform vec3 eyePositionHigh;
175
- uniform vec3 eyePositionLow;
173
+ attribute vec3 aLocalPosition;
174
+
175
+ uniform vec3 rtcEyePositionHigh;
176
+ uniform vec3 rtcEyePositionLow;
177
+
176
178
  uniform vec3 uScaleByDistance;
177
179
  uniform mat4 projectionMatrix;
178
180
  uniform mat4 viewMatrix;
@@ -186,42 +188,27 @@ export const geo_object_picking = () => new Program("geo_object_picking", {
186
188
 
187
189
  if (aDispose == 0.0) {
188
190
  return;
189
- }
190
-
191
- vColor = aPickingColor;
192
-
193
- vec3 position = aPositionHigh + aPositionLow;
194
- vec3 cameraPosition = eyePositionHigh + eyePositionLow;
195
-
196
- mat4 viewMatrixRTE = viewMatrix;
197
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
198
-
199
- vec3 highDiff = aPositionHigh - eyePositionHigh;
200
- vec3 lowDiff = aPositionLow - eyePositionLow;
201
-
202
- vec3 look = cameraPosition - position;
203
- float lookLength = length(look);
204
-
205
- // if(lookLength > uScaleByDistance[1])
206
- // {
207
- // scd = uScaleByDistance[1] / uScaleByDistance[0];
208
- // }
209
- // else if(lookLength > uScaleByDistance[0])
210
- // {
211
- // scd = lookLength / uScaleByDistance[0];
212
- // }
213
- // ... is the same math above
214
- // @hack
215
- // pickingScale replace to this line, because when it s
216
- // tays in the vert above it affects on Mac Safari jitter
217
- float scd = uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
218
-
219
- //vec3 vert = qRotate(qRot, (aVertexPosition * aScale + aTranslate) * pickingScale) * scd;
220
- vec3 vert = qRotate(qRot, scd * pickingScale * (aVertexPosition * aScale + aTranslate));
191
+ }
192
+
193
+ vColor = aPickingColor;
221
194
 
222
- vert += lowDiff;
195
+ mat4 viewMatrixRTE = viewMatrix;
196
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
197
+
198
+ vec3 highDiff = aRTCPositionHigh - rtcEyePositionHigh;
199
+ vec3 lowDiff = aRTCPositionLow - rtcEyePositionLow;
200
+
201
+ highDiff = highDiff * step(1.0, length(highDiff));
202
+
203
+ vec4 positionInViewSpace = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
204
+
205
+ float lookLength = length(positionInViewSpace.xyz);
223
206
 
224
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff * step(1.0, length(highDiff)) + vert, 1.0);
207
+ float scd = uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
208
+
209
+ vec3 vert = qRotate(qRot, scd * pickingScale * (aVertexPosition * aScale + aTranslate)) + scd * aLocalPosition;
210
+
211
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff + vert, 1.0);
225
212
  }`,
226
213
  fragmentShader: `precision highp float;
227
214
  varying vec3 vColor;
@@ -229,3 +216,79 @@ export const geo_object_picking = () => new Program("geo_object_picking", {
229
216
  gl_FragColor = vec4(vColor, 1.0);
230
217
  }`
231
218
  });
219
+ export const geo_object_depth = () => new Program("geo_object_depth", {
220
+ uniforms: {
221
+ viewMatrix: "mat4",
222
+ projectionMatrix: "mat4",
223
+ uScaleByDistance: "vec3",
224
+ rtcEyePositionHigh: "vec3",
225
+ rtcEyePositionLow: "vec3",
226
+ frustumPickingColor: "float"
227
+ },
228
+ attributes: {
229
+ aVertexPosition: "vec3",
230
+ aRTCPositionHigh: { type: "vec3", divisor: 1 },
231
+ aRTCPositionLow: { type: "vec3", divisor: 1 },
232
+ aScale: { type: "vec3", divisor: 1 },
233
+ aTranslate: { type: "vec3", divisor: 1 },
234
+ aDispose: { type: "float", divisor: 1 },
235
+ qRot: { type: "vec4", divisor: 1 },
236
+ aLocalPosition: { type: "vec3", divisor: 1 },
237
+ },
238
+ vertexShader: `#version 300 es
239
+ precision highp float;
240
+
241
+ in vec3 aVertexPosition;
242
+ in vec3 aRTCPositionHigh;
243
+ in vec3 aRTCPositionLow;
244
+ in vec3 aScale;
245
+ in vec3 aTranslate;
246
+ in float aDispose;
247
+ in vec4 qRot;
248
+ in vec3 aLocalPosition;
249
+
250
+ uniform vec3 rtcEyePositionHigh;
251
+ uniform vec3 rtcEyePositionLow;
252
+ uniform vec3 uScaleByDistance;
253
+ uniform mat4 projectionMatrix;
254
+ uniform mat4 viewMatrix;
255
+
256
+ ${QROT}
257
+
258
+ void main(void) {
259
+
260
+ if (aDispose == 0.0) {
261
+ return;
262
+ }
263
+
264
+ mat4 viewMatrixRTE = viewMatrix;
265
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
266
+
267
+ vec3 highDiff = aRTCPositionHigh - rtcEyePositionHigh;
268
+ vec3 lowDiff = aRTCPositionLow - rtcEyePositionLow;
269
+
270
+ highDiff = highDiff * step(1.0, length(highDiff));
271
+
272
+ vec4 positionInViewSpace = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
273
+
274
+ float lookLength = length(positionInViewSpace.xyz);
275
+
276
+ float scd = uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
277
+
278
+ vec3 vert = qRotate(qRot, scd * (aVertexPosition * aScale + aTranslate)) + scd * aLocalPosition;
279
+
280
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff + vert, 1.0);
281
+ }`,
282
+ fragmentShader: `#version 300 es
283
+ precision highp float;
284
+
285
+ uniform float frustumPickingColor;
286
+
287
+ layout(location = 0) out vec4 frustumColor;
288
+ layout(location = 1) out vec4 depthColor;
289
+
290
+ void main () {
291
+ frustumColor = vec4(frustumPickingColor, frustumPickingColor, frustumPickingColor, 1.0);
292
+ depthColor = vec4(gl_FragCoord.z, gl_FragCoord.z, gl_FragCoord.z, 1.0);
293
+ }`
294
+ });
@@ -1,16 +1,17 @@
1
1
  import { Program } from '../webgl/Program';
2
+ import { UTILS } from "./utils";
2
3
  export function polyline_screen() {
3
4
  return new Program("polyline_screen", {
4
5
  uniforms: {
5
6
  viewport: "vec2",
6
7
  proj: "mat4",
7
8
  view: "mat4",
8
- eyePositionHigh: "vec3",
9
- eyePositionLow: "vec3",
10
- //uFloatParams: "vec2",
9
+ rtcEyePositionHigh: "vec3",
10
+ rtcEyePositionLow: "vec3",
11
11
  thickness: "float",
12
12
  opacity: "float",
13
- depthOffset: "float"
13
+ depthOffset: "float",
14
+ visibleSphere: "vec4",
14
15
  },
15
16
  attributes: {
16
17
  prevHigh: "vec3",
@@ -40,10 +41,11 @@ export function polyline_screen() {
40
41
  uniform mat4 proj;
41
42
  uniform mat4 view;
42
43
  uniform vec2 viewport;
43
- uniform vec3 eyePositionHigh;
44
- uniform vec3 eyePositionLow;
44
+ uniform vec3 rtcEyePositionHigh;
45
+ uniform vec3 rtcEyePositionLow;
45
46
  uniform float opacity;
46
47
  uniform float depthOffset;
48
+
47
49
 
48
50
  varying vec4 vColor;
49
51
  varying vec3 vPos;
@@ -70,29 +72,29 @@ export function polyline_screen() {
70
72
 
71
73
  void main(){
72
74
 
73
- uCamPos = eyePositionHigh + eyePositionLow;
74
-
75
+ uCamPos = rtcEyePositionHigh + rtcEyePositionLow;
76
+ vPos = currentHigh + currentLow;
77
+
75
78
  vColor = vec4(color.rgb, color.a * opacity);
76
79
 
77
- vec3 current = currentHigh + currentLow;
78
-
79
- vPos = current;
80
-
81
80
  mat4 viewMatrixRTE = view;
82
81
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
83
82
 
84
83
  vec3 highDiff, lowDiff;
85
84
 
86
- highDiff = currentHigh - eyePositionHigh;
87
- lowDiff = currentLow - eyePositionLow;
85
+ highDiff = currentHigh - rtcEyePositionHigh;
86
+ highDiff = highDiff * step(1.0, length(highDiff));
87
+ lowDiff = currentLow - rtcEyePositionLow;
88
88
  vec4 vCurrent = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
89
89
 
90
- highDiff = prevHigh - eyePositionHigh;
91
- lowDiff = prevLow - eyePositionLow;
90
+ highDiff = prevHigh - rtcEyePositionHigh;
91
+ highDiff = highDiff * step(1.0, length(highDiff));
92
+ lowDiff = prevLow - rtcEyePositionLow;
92
93
  vec4 vPrev = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
93
94
 
94
- highDiff = nextHigh - eyePositionHigh;
95
- lowDiff = nextLow - eyePositionLow;
95
+ highDiff = nextHigh - rtcEyePositionHigh;
96
+ highDiff = highDiff * step(1.0, length(highDiff));
97
+ lowDiff = nextLow - rtcEyePositionLow;
96
98
  vec4 vNext = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
97
99
 
98
100
  /*Clip near plane, the point behind view plane*/
@@ -161,16 +163,26 @@ export function polyline_screen() {
161
163
  gl_Position = vec4((2.0 * m / viewport - 1.0) * dCurrent.w, dCurrent.z + depthOffset, dCurrent.w);
162
164
  }`,
163
165
  fragmentShader: `precision highp float;
164
- //uniform vec2 uFloatParams;
166
+
167
+ uniform vec4 visibleSphere;
168
+
165
169
  varying vec3 uCamPos;
166
170
  varying vec4 vColor;
167
- varying vec3 vPos;
171
+ varying vec3 vPos;
172
+
173
+ ${UTILS}
174
+
168
175
  void main() {
169
- vec3 look = vPos - uCamPos;
170
- float lookLength = length(look);
171
- //float a = vColor.a * step(lookLength, sqrt(dot(uCamPos,uCamPos) - uFloatParams[0]) + sqrt(dot(vPos,vPos) - uFloatParams[0]));
172
- float a = vColor.a;
173
- gl_FragColor = vec4(vColor.rgb, a);
176
+
177
+ if(visibleSphere.w != 0.0) {
178
+ vec3 cam_dir = normalize(vPos - uCamPos);
179
+ vec3 sph_dir = normalize(vPos - visibleSphere.xyz);
180
+ if( dot(cam_dir, sph_dir) > 0.11 ){
181
+ discard;
182
+ }
183
+ }
184
+
185
+ gl_FragColor = vec4(vColor.rgb, vColor.a);
174
186
  }`
175
187
  });
176
188
  }
@@ -180,12 +192,12 @@ export function polyline_picking() {
180
192
  viewport: "vec2",
181
193
  proj: "mat4",
182
194
  view: "mat4",
183
- eyePositionHigh: "vec3",
184
- eyePositionLow: "vec3",
185
- //uFloatParams: "vec2",
195
+ rtcEyePositionHigh: "vec3",
196
+ rtcEyePositionLow: "vec3",
186
197
  color: "vec4",
187
198
  thickness: "float",
188
- depthOffset: "float"
199
+ depthOffset: "float",
200
+ visibleSphere: "vec4",
189
201
  },
190
202
  attributes: {
191
203
  prevHigh: "vec3",
@@ -213,8 +225,8 @@ export function polyline_picking() {
213
225
  uniform mat4 proj;
214
226
  uniform mat4 view;
215
227
  uniform vec2 viewport;
216
- uniform vec3 eyePositionHigh;
217
- uniform vec3 eyePositionLow;
228
+ uniform vec3 rtcEyePositionHigh;
229
+ uniform vec3 rtcEyePositionLow;
218
230
  uniform float depthOffset;
219
231
 
220
232
  varying vec4 vColor;
@@ -243,29 +255,28 @@ export function polyline_picking() {
243
255
 
244
256
  void main(){
245
257
 
246
- uCamPos = eyePositionHigh + eyePositionLow;
247
-
248
- vColor = color;
249
-
250
- vec3 current = currentHigh + currentLow;
251
-
252
- vPos = current;
258
+ uCamPos = rtcEyePositionHigh + rtcEyePositionLow;
259
+ vPos = currentHigh + currentLow;
260
+ vColor = color;
253
261
 
254
262
  vec3 highDiff, lowDiff;
255
263
 
256
264
  mat4 viewMatrixRTE = view;
257
265
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
258
-
259
- highDiff = currentHigh - eyePositionHigh;
260
- lowDiff = currentLow - eyePositionLow;
266
+
267
+ highDiff = currentHigh - rtcEyePositionHigh;
268
+ highDiff = highDiff * step(1.0, length(highDiff));
269
+ lowDiff = currentLow - rtcEyePositionLow;
261
270
  vec4 vCurrent = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
262
271
 
263
- highDiff = prevHigh - eyePositionHigh;
264
- lowDiff = prevLow - eyePositionLow;
272
+ highDiff = prevHigh - rtcEyePositionHigh;
273
+ highDiff = highDiff * step(1.0, length(highDiff));
274
+ lowDiff = prevLow - rtcEyePositionLow;
265
275
  vec4 vPrev = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
266
276
 
267
- highDiff = nextHigh - eyePositionHigh;
268
- lowDiff = nextLow - eyePositionLow;
277
+ highDiff = nextHigh - rtcEyePositionHigh;
278
+ highDiff = highDiff * step(1.0, length(highDiff));
279
+ lowDiff = nextLow - rtcEyePositionLow;
269
280
  vec4 vNext = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
270
281
 
271
282
  /*Clip near plane*/
@@ -332,16 +343,22 @@ export function polyline_picking() {
332
343
  gl_Position = vec4((2.0 * m / viewport - 1.0) * dCurrent.w, dCurrent.z + depthOffset, dCurrent.w);
333
344
  }`,
334
345
  fragmentShader: `precision highp float;
335
- //uniform vec2 uFloatParams;
346
+
347
+ uniform vec4 visibleSphere;
348
+
336
349
  varying vec3 uCamPos;
337
350
  varying vec4 vColor;
338
351
  varying vec3 vPos;
352
+
339
353
  void main() {
340
- vec3 look = vPos - uCamPos;
341
- float lookLength = length(look);
342
- //float a = vColor.a * step(lookLength, sqrt(dot(uCamPos,uCamPos) - uFloatParams[0]) + sqrt(dot(vPos,vPos) - uFloatParams[0]));
343
- float a = vColor.a;
344
- gl_FragColor = vec4(vColor.rgb, a);
354
+ if(visibleSphere.w != 0.0) {
355
+ vec3 cam_dir = normalize(vPos - uCamPos);
356
+ vec3 sph_dir = normalize(vPos - visibleSphere.xyz);
357
+ if( dot(cam_dir, sph_dir) > 0.11 ){
358
+ discard;
359
+ }
360
+ }
361
+ gl_FragColor = vec4(vColor.rgb, vColor.a);
345
362
  }`
346
363
  });
347
364
  }
@@ -1 +1 @@
1
- export declare const UTILS = "\n float getLerpValue(in float min, in float max, in float between)\n {\n return (clamp(between, min, max) - min) / (max - min);\n }\n \n vec3 aces(vec3 color) \n {\n float a = 2.51;\n float b = 0.03;\n float c = 2.43;\n float d = 0.59;\n float e = 0.14;\n return clamp((color * (a * color + b)) / (color * (c * color + d ) + e), 0.0, 1.0);\n }\n \n bool intersectSphere(vec3 rayOrigin, vec3 rayDirection, float radius, inout float t1, inout float t2) \n {\n float b = dot(rayDirection, rayOrigin);\n float c = dot(rayOrigin, rayOrigin) - radius * radius;\n float d = b * b - c;\n if (d < 0.0) {\n return false;\n }\n t1 = -b - sqrt(d);\n t2 = -b + sqrt(d);\n return true;\n }\n \n bool intersectSphere(vec3 rayOrigin, vec3 rayDirection, float radius, inout float t) \n {\n float b = dot(rayDirection, rayOrigin);\n float c = dot(rayOrigin, rayOrigin) - radius * radius;\n float d = b * b - c;\n if (d < 0.0) {\n return false;\n }\n t = -b - sqrt(d);\n return true;\n }\n \n bool intersectEllipsoid( in vec3 ro, in vec3 rd, in vec3 ra, inout float t )\n {\n vec3 ocn = ro/ra;\n vec3 rdn = rd/ra;\n float a = dot( rdn, rdn );\n float b = dot( ocn, rdn );\n float c = dot( ocn, ocn );\n float h = b*b - a*(c-1.0);\n \n if (h < 0.0) \n { \n return false; \n }\n \n t = (-b-sqrt(h))/a;\n \n return true;\n }\n \n bool intersectEllipsoid( in vec3 ro, in vec3 rd, in vec3 ra, inout float t1, inout float t2)\n {\n vec3 ocn = ro/ra;\n vec3 rdn = rd/ra;\n float a = dot( rdn, rdn );\n float b = dot( ocn, rdn );\n float c = dot( ocn, ocn );\n float h = b*b - a*(c-1.0);\n \n if (h < 0.0) \n { \n return false; \n }\n \n h = sqrt(h);\n t1 = (-b-h)/a;\n t2 = (-b+h)/a;\n \n return true;\n }\n \n vec3 normalEllipsoid( in vec3 pos, in vec3 ra )\n {\n return normalize( pos/(ra*ra) );\n }\n";
1
+ export declare const UTILS = "\n float getLerpValue(in float min, in float max, in float between)\n {\n return (clamp(between, min, max) - min) / (max - min);\n }\n \n vec3 aces(vec3 color) \n {\n float a = 2.51;\n float b = 0.03;\n float c = 2.43;\n float d = 0.59;\n float e = 0.14;\n return clamp((color * (a * color + b)) / (color * (c * color + d ) + e), 0.0, 1.0);\n }\n \n bool intersectSphere(vec3 rayOrigin, vec3 rayDirection, float radius, inout float t1, inout float t2) \n {\n float b = dot(rayDirection, rayOrigin);\n float c = dot(rayOrigin, rayOrigin) - radius * radius;\n float d = b * b - c;\n if (d < 0.0) {\n return false;\n }\n t1 = -b - sqrt(d);\n t2 = -b + sqrt(d);\n return true;\n }\n \n bool intersectSphere(vec3 rayOrigin, vec3 rayDirection, float radius, inout float t) \n {\n float b = dot(rayDirection, rayOrigin);\n float c = dot(rayOrigin, rayOrigin) - radius * radius;\n float d = b * b - c;\n if (d < 0.0) {\n return false;\n }\n t = -b - sqrt(d);\n return true;\n }\n \n float intersectSphere( vec3 ro, vec3 rd, vec4 sph )\n {\n vec3 oc = ro - sph.xyz;\n float b = dot( oc, rd );\n float c = dot( oc, oc ) - sph.w*sph.w;\n float h = b*b - c;\n if( h<0.0 ) return -1.0;\n h = sqrt( h );\n return -b - h;\n }\n \n bool intersectEllipsoid( in vec3 ro, in vec3 rd, in vec3 ra, inout float t )\n {\n vec3 ocn = ro/ra;\n vec3 rdn = rd/ra;\n float a = dot( rdn, rdn );\n float b = dot( ocn, rdn );\n float c = dot( ocn, ocn );\n float h = b*b - a*(c-1.0);\n \n if (h < 0.0) \n { \n return false; \n }\n \n t = (-b-sqrt(h))/a;\n \n return true;\n }\n \n bool intersectEllipsoid( in vec3 ro, in vec3 rd, in vec3 ra, inout float t1, inout float t2)\n {\n vec3 ocn = ro/ra;\n vec3 rdn = rd/ra;\n float a = dot( rdn, rdn );\n float b = dot( ocn, rdn );\n float c = dot( ocn, ocn );\n float h = b*b - a*(c-1.0);\n \n if (h < 0.0) \n { \n return false; \n }\n \n h = sqrt(h);\n t1 = (-b-h)/a;\n t2 = (-b+h)/a;\n \n return true;\n }\n \n vec3 normalEllipsoid( in vec3 pos, in vec3 ra )\n {\n return normalize( pos/(ra*ra) );\n }\n";
@@ -39,6 +39,17 @@ export const UTILS = `
39
39
  return true;
40
40
  }
41
41
 
42
+ float intersectSphere( vec3 ro, vec3 rd, vec4 sph )
43
+ {
44
+ vec3 oc = ro - sph.xyz;
45
+ float b = dot( oc, rd );
46
+ float c = dot( oc, oc ) - sph.w*sph.w;
47
+ float h = b*b - c;
48
+ if( h<0.0 ) return -1.0;
49
+ h = sqrt( h );
50
+ return -b - h;
51
+ }
52
+
42
53
  bool intersectEllipsoid( in vec3 ro, in vec3 rd, in vec3 ra, inout float t )
43
54
  {
44
55
  vec3 ocn = ro/ra;
@@ -0,0 +1,31 @@
1
+ import { EventsHandler } from "../Events";
2
+ import { IViewParams, View, ViewEventsList } from './View';
3
+ interface ICheckboxParams extends IViewParams {
4
+ label?: string;
5
+ checked?: boolean;
6
+ disabled?: boolean;
7
+ }
8
+ type CheckboxEventsList = ["change"];
9
+ declare class Checkbox extends View<null> {
10
+ events: EventsHandler<CheckboxEventsList> & EventsHandler<ViewEventsList>;
11
+ protected $label: HTMLElement | null;
12
+ protected $input: HTMLInputElement | null;
13
+ protected _checked: boolean;
14
+ protected _disabled: boolean;
15
+ constructor(options?: ICheckboxParams);
16
+ set disabled(disabled: boolean);
17
+ protected _updateDisabled(): void;
18
+ get disabled(): boolean;
19
+ render(params: any): this;
20
+ protected _onResize: () => void;
21
+ set checked(isChecked: boolean);
22
+ get checked(): boolean;
23
+ protected _initEvents(): void;
24
+ protected _clearEvents(): void;
25
+ protected _onMouseWheel: (e: WheelEvent) => void;
26
+ protected _onMouseWheelFF: (e: WheelEvent) => void;
27
+ protected _onClick: (e: Event) => void;
28
+ remove(): void;
29
+ set visibility(visibility: boolean);
30
+ }
31
+ export { Checkbox };