@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
@@ -1,11 +1,22 @@
1
1
  import * as utils from "../utils/shared";
2
- import { Quat, Vec3 } from "../math/index";
2
+ import { Quat, Vec3, Vec4 } from "../math/index";
3
3
  import { Object3d } from "../Object3d";
4
- import { RADIANS } from "../math";
4
+ export const LOCAL_FORWARD = new Vec3(0.0, 0.0, -1.0);
5
5
  /**
6
+ * Represents 3D object on the the globe or 3d space
6
7
  * @class
7
- * @param {Object} options - Geo object parameters:
8
- * @param {Vec3} [options.position] - Geo object position.
8
+ * @param {IGeoObjectParams} options - Geo object parameters:
9
+ * @param {Object3d} [options.object3d] - 3D object associated with the geo object.
10
+ * @param {string} [options.objSrc] - Source url of the 3D object.
11
+ * @param {string} [options.tag] - Unique instancing drawing identifier tag.
12
+ * @param {Vec3 | NumberArray3} [options.position] - Position in Cartesian coordinates.
13
+ * @param {number} [options.pitch=0] - Rotation around X-axis in degrees.
14
+ * @param {number} [options.yaw=0] - Rotation around Y-axis in degrees.
15
+ * @param {number} [options.roll=0] - Rotation around Z-axis in degrees.
16
+ * @param {number | Vec3 | NumberArray3} [options.scale=1] - Scale of the object.
17
+ * @param {Vec3 | NumberArray3} [options.translate] - Translation offset.
18
+ * @param {Vec4 | NumberArray4 | string} [options.color] - RGBA color or HTML color string.
19
+ * @param {boolean} [options.visibility=true] - Visibility flag.
9
20
  *
10
21
  * @todo: GeoObject and GeoObjectHandler provides instanced objects only.
11
22
  * It would be nice if it could provide not instanced rendering loop too.
@@ -13,23 +24,15 @@ import { RADIANS } from "../math";
13
24
  class GeoObject {
14
25
  constructor(options) {
15
26
  this._handlerIndex = -1;
16
- this._tag = options.tag || "none";
17
- this.instanced = true;
27
+ this._tag = options.tag || `tag_${GeoObject.__counter__++}`;
18
28
  this._entity = null;
19
29
  this._position = utils.createVector3(options.position);
20
- this._positionHigh = new Vec3();
21
- this._positionLow = new Vec3();
22
- Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
23
- this._pitch = options.pitch || 0.0;
24
- this._yaw = options.yaw || 0.0;
25
- this._roll = options.roll || 0.0;
26
- this._pitchRad = this._pitch * RADIANS;
27
- this._yawRad = this._yaw * RADIANS;
28
- this._rollRad = this._roll * RADIANS;
30
+ this._rtcPositionHigh = new Vec3();
31
+ this._rtcPositionLow = new Vec3();
29
32
  this._scale = utils.createVector3(options.scale, new Vec3(1, 1, 1));
30
33
  this._translate = utils.createVector3(options.translate, new Vec3());
31
- this._color = utils.createColorRGBA(options.color);
32
- this._qRot = Quat.IDENTITY;
34
+ this._localPosition = new Vec3();
35
+ this._color = utils.createColorRGBA(options.color, new Vec4(0.15, 0.15, 0.15, 1.0));
33
36
  this._handler = null;
34
37
  this._handlerIndex = -1;
35
38
  this._tagData = null;
@@ -43,60 +46,91 @@ class GeoObject {
43
46
  this._objectSrc = options.objSrc;
44
47
  }
45
48
  this._object3d = object3d;
46
- if (options.textureSrc) {
47
- this.setTextureSrc(options.textureSrc);
48
- }
49
+ // if (options.colorTexture) {
50
+ // this.setColorTexture(options.colorTexture)
51
+ // }
49
52
  this._visibility = (options.visibility != undefined ? options.visibility : true);
50
53
  this._children = [];
51
54
  this._direction = new Vec3();
52
- this._qNorthFrame = new Quat();
55
+ this._qFrame = new Quat();
56
+ this._qRot = Quat.IDENTITY;
53
57
  }
58
+ /**
59
+ * Gets the unique tag of the geo object.
60
+ * @returns {string}
61
+ */
54
62
  get tag() {
55
63
  return this._tag;
56
64
  }
65
+ /**
66
+ * Gets the position of the geo object.
67
+ * @public
68
+ * @returns {Vec3}
69
+ */
57
70
  getPosition() {
58
71
  return this._position;
59
72
  }
60
- getPitch() {
61
- return this._pitch;
62
- }
63
- getYaw() {
64
- return this._yaw;
65
- }
66
- getRoll() {
67
- return this._roll;
68
- }
73
+ /**
74
+ * Gets the 3D object associated with this geo object.
75
+ * @public
76
+ * @returns {Object3d}
77
+ */
69
78
  get object3d() {
70
79
  return this._object3d;
71
80
  }
81
+ /**
82
+ * Gets geometry mesh vertices.
83
+ * @public
84
+ * @returns {number[]}
85
+ */
72
86
  get vertices() {
73
87
  return this._object3d.vertices;
74
88
  }
89
+ /**
90
+ * Gets geometry mesh normals.
91
+ * @public
92
+ * @returns {number[]}
93
+ */
75
94
  get normals() {
76
95
  return this._object3d.normals;
77
96
  }
97
+ /**
98
+ * Gets geometry mesh texture coordinates.
99
+ * @public
100
+ * @returns {number[]}
101
+ */
78
102
  get texCoords() {
79
103
  return this._object3d.texCoords;
80
104
  }
105
+ /**
106
+ * Gets geometry mesh indices.
107
+ * @public
108
+ * @returns {number[]}
109
+ */
81
110
  get indices() {
82
111
  return this._object3d.indices;
83
112
  }
84
113
  /**
85
- * Sets geo object opacity.
86
- * @public
87
- * @param {number} a - Billboard opacity.
114
+ * Sets the opacity of the geo object.
115
+ * @param {number} a - Opacity value (0 to 1).
88
116
  */
89
117
  setOpacity(a) {
90
118
  this._color.w = a;
91
119
  this.setColor(this._color.x, this._color.y, this._color.z, a);
92
120
  }
93
121
  /**
94
- * Sets color.
95
- * @public
96
- * @param {number} r - Red.
97
- * @param {number} g - Green.
98
- * @param {number} b - Blue.
99
- * @param {number} [a] - Alpha.
122
+ * Gets the opacity of the geo object.
123
+ * @returns {number}
124
+ */
125
+ getOpacity() {
126
+ return this._color.w;
127
+ }
128
+ /**
129
+ * Sets the color of the geo object.
130
+ * @param {number} r - Red component.
131
+ * @param {number} g - Green component.
132
+ * @param {number} b - Blue component.
133
+ * @param {number} [a] - Alpha component.
100
134
  */
101
135
  setColor(r, g, b, a) {
102
136
  this._color.x = r;
@@ -145,75 +179,69 @@ class GeoObject {
145
179
  this._position.x = x;
146
180
  this._position.y = y;
147
181
  this._position.z = z;
148
- Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
149
- this._handler &&
150
- this._handler.setPositionArr(this._tagData, this._tagDataIndex, this._positionHigh, this._positionLow);
182
+ this.updateRTCPosition();
151
183
  this.updateRotation();
152
184
  }
185
+ updateRTCPosition() {
186
+ //Vec3.doubleToTwoFloats(this._position, this._rtcPositionHigh, this._rtcPositionLow);
187
+ if (this._handler) {
188
+ this._handler.getRTCPosition(this._position, this._rtcPositionHigh, this._rtcPositionLow);
189
+ this._handler.setRTCPositionArr(this._tagData, this._tagDataIndex, this._rtcPositionHigh, this._rtcPositionLow);
190
+ }
191
+ }
153
192
  /**
154
193
  * Sets geo object position.
155
194
  * @public
156
195
  * @param {Vec3} position - Cartesian coordinates.
157
196
  */
158
197
  setPosition3v(position) {
159
- this._position.x = position.x;
160
- this._position.y = position.y;
161
- this._position.z = position.z;
162
- Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
163
- this._handler && this._handler.setPositionArr(this._tagData, this._tagDataIndex, this._positionHigh, this._positionLow);
164
- this.updateRotation();
165
- }
166
- setYaw(yaw) {
167
- this._yaw = yaw;
168
- this._yawRad = yaw * RADIANS;
169
- this.updateRotation();
198
+ this.setPosition(position.x, position.y, position.z);
170
199
  }
200
+ /**
201
+ * Sets Object3d for the object
202
+ * @param {Object3d} object
203
+ */
171
204
  setObject(object) {
172
205
  this._object3d = object;
173
206
  }
207
+ /**
208
+ * Sets the object url source.
209
+ * @param {string} src
210
+ */
174
211
  setObjectSrc(src) {
175
212
  this._objectSrc = src;
176
213
  this._handler && this._handler.setObjectSrc(src, this.tag);
177
214
  }
178
- setTextureSrc(src) {
179
- this._textureSrc = src;
180
- this._object3d && (this._object3d.src = src);
181
- this._handler && this._handler.setTextureTag(src, this.tag);
182
- }
215
+ /**
216
+ * Sets object HTML color.
217
+ * @param {string} color
218
+ */
183
219
  setColorHTML(color) {
184
220
  this.setColor4v(utils.htmlColorToRgba(color));
185
221
  }
186
222
  /**
187
- *
188
- * @param {number} pitch - Pitch in radians
223
+ * Sets scales.
224
+ * @public
225
+ * @param {number} scale
189
226
  */
190
- setPitch(pitch) {
191
- this._pitch = pitch;
192
- this._pitchRad = pitch * RADIANS;
193
- this.updateRotation();
194
- }
195
- setRoll(roll) {
196
- this._roll = roll;
197
- this._rollRad = roll * RADIANS;
198
- this.updateRotation();
199
- }
200
- setPitchYawRoll(pitch, yaw, roll) {
201
- this._pitch = pitch;
202
- this._yaw = yaw;
203
- this._roll = roll;
204
- this._pitchRad = pitch * RADIANS;
205
- this._yawRad = yaw * RADIANS;
206
- this._rollRad = roll * RADIANS;
207
- this.updateRotation();
208
- }
209
227
  setScale(scale) {
210
228
  this._scale.x = this._scale.y = this._scale.z = scale;
211
229
  this._handler && this._handler.setScaleArr(this._tagData, this._tagDataIndex, this._scale);
212
230
  }
231
+ /**
232
+ * Sets X, Y, Z axis scales
233
+ * @public
234
+ * @param {Vec3} scale
235
+ */
213
236
  setScale3v(scale) {
214
237
  this._scale.copy(scale);
215
238
  this._handler && this._handler.setScaleArr(this._tagData, this._tagDataIndex, scale);
216
239
  }
240
+ /**
241
+ * Gets scale.
242
+ * @publci
243
+ * @returns {Vec3}
244
+ */
217
245
  getScale() {
218
246
  return this._scale;
219
247
  }
@@ -222,10 +250,26 @@ class GeoObject {
222
250
  this._handler && this._handler.setTranslateArr(this._tagData, this._tagDataIndex, translate);
223
251
  }
224
252
  getTranslate() {
225
- return this._translate;
253
+ return this._translate.clone();
254
+ }
255
+ /**
256
+ * Sets local offset position.
257
+ * @param {Vec3} localPosition
258
+ */
259
+ setLocalPosition3v(localPosition) {
260
+ this._localPosition.copy(localPosition);
261
+ this._handler && this._handler.setLocalPositionArr(this._tagData, this._tagDataIndex, localPosition);
262
+ }
263
+ /**
264
+ * Gets local offset position.
265
+ * @public
266
+ * @returns {Vec3}
267
+ */
268
+ getLocalPosition() {
269
+ return this._localPosition.clone();
226
270
  }
227
271
  /**
228
- * Removes geo object from handler.
272
+ * Removes the geo object from the handler.
229
273
  * @public
230
274
  */
231
275
  remove() {
@@ -240,19 +284,38 @@ class GeoObject {
240
284
  setPickingColor3v(color) {
241
285
  this._handler && this._handler.setPickingColorArr(this._tagData, this._tagDataIndex, color);
242
286
  }
287
+ /**
288
+ * Sets the rotation quaternion.
289
+ * @public
290
+ * @param {Quat} qRot - Rotation quaternion.
291
+ */
292
+ setRotation(qRot) {
293
+ this._qRot.copy(qRot);
294
+ this._qRot.mulVec3Res(LOCAL_FORWARD, this._direction).normalize();
295
+ this.updateRotation();
296
+ }
297
+ /**
298
+ * Returns orientation quaternion.
299
+ * @public
300
+ * @returns {Quat}
301
+ */
302
+ getRotation() {
303
+ return this._qRot;
304
+ }
305
+ /**
306
+ * Update object rotation
307
+ */
243
308
  updateRotation() {
244
- if (this._handler && this._handler._planet) {
245
- this._qNorthFrame = this._handler._planet.getNorthFrameRotation(this._position);
246
- let qp = Quat.xRotation(-this._pitchRad);
247
- let qy = Quat.yRotation(this._yawRad);
248
- let qr = Quat.zRotation(-this._rollRad);
249
- this._qRot = qr.mul(qp).mul(qy).mul(this._qNorthFrame).conjugate();
250
- this._direction = this._qRot.mulVec3(new Vec3(0.0, 0.0, -1.0)).normalize();
251
- this._handler.setQRotArr(this._tagData, this._tagDataIndex, this._qRot);
252
- }
309
+ this._handler && this._handler.setQRotArr(this._tagData, this._tagDataIndex, this._qRot);
253
310
  }
311
+ /**
312
+ * Returns object direction
313
+ * @publcu
314
+ * @returns {Vec3}
315
+ */
254
316
  getDirection() {
255
317
  return this._direction.clone();
256
318
  }
257
319
  }
320
+ GeoObject.__counter__ = 0;
258
321
  export { GeoObject };
@@ -1,65 +1,25 @@
1
- import { TypedArray } from "../utils/shared";
2
1
  import { EntityCollection } from "./EntityCollection";
3
2
  import { GeoObject } from "./GeoObject";
4
- import { Planet } from "../scene/Planet";
5
3
  import { Vec3 } from "../math/Vec3";
6
4
  import { Vec4 } from "../math/Vec4";
7
5
  import { Quat } from "../math/Quat";
8
- import { WebGLBufferExt, WebGLTextureExt } from "../webgl/Handler";
9
6
  import { Object3d } from "../Object3d";
10
- declare class InstanceData {
11
- isFree: boolean;
12
- _geoObjectHandler: GeoObjectHandler;
13
- geoObjects: GeoObject[];
14
- numInstances: number;
15
- _texture: WebGLTextureExt | null;
16
- _textureSrc: string | null;
17
- _objectSrc?: string;
18
- _sizeArr: number[] | TypedArray;
19
- _translateArr: number[] | TypedArray;
20
- _vertexArr: number[] | TypedArray;
21
- _positionHighArr: number[] | TypedArray;
22
- _positionLowArr: number[] | TypedArray;
23
- _qRotArr: number[] | TypedArray;
24
- _rgbaArr: number[] | TypedArray;
25
- _normalsArr: number[] | TypedArray;
26
- _indicesArr: number[] | TypedArray;
27
- _pickingColorArr: number[] | TypedArray;
28
- _visibleArr: number[] | TypedArray;
29
- _texCoordArr: number[] | TypedArray;
30
- _sizeBuffer: WebGLBufferExt | null;
31
- _translateBuffer: WebGLBufferExt | null;
32
- _vertexBuffer: WebGLBufferExt | null;
33
- _positionHighBuffer: WebGLBufferExt | null;
34
- _positionLowBuffer: WebGLBufferExt | null;
35
- _qRotBuffer: WebGLBufferExt | null;
36
- _rgbaBuffer: WebGLBufferExt | null;
37
- _normalsBuffer: WebGLBufferExt | null;
38
- _indicesBuffer: WebGLBufferExt | null;
39
- _pickingColorBuffer: WebGLBufferExt | null;
40
- _visibleBuffer: WebGLBufferExt | null;
41
- _texCoordBuffer: WebGLBufferExt | null;
42
- _buffersUpdateCallbacks: Function[];
43
- _changedBuffers: boolean[];
44
- constructor(geoObjectHandler: GeoObjectHandler);
45
- createTexture(image: HTMLCanvasElement | ImageBitmap | ImageData | HTMLImageElement): void;
46
- clear(): void;
47
- _deleteBuffers(): void;
48
- createVertexBuffer(): void;
49
- createVisibleBuffer(): void;
50
- createSizeBuffer(): void;
51
- createTranslateBuffer(): void;
52
- createTexCoordBuffer(): void;
53
- createPositionBuffer(): void;
54
- createRgbaBuffer(): void;
55
- createQRotBuffer(): void;
56
- createNormalsBuffer(): void;
57
- createIndicesBuffer(): void;
58
- createPickingColorBuffer(): void;
59
- refresh(): void;
60
- update(): void;
61
- }
62
- declare class GeoObjectHandler {
7
+ import { InstanceData } from "./InstanceData";
8
+ import { Renderer } from "../renderer/Renderer";
9
+ import { RenderNode } from "../scene/RenderNode";
10
+ export declare const VERTEX_BUFFER = 0;
11
+ export declare const RTC_POSITION_BUFFER = 1;
12
+ export declare const RGBA_BUFFER = 2;
13
+ export declare const NORMALS_BUFFER = 3;
14
+ export declare const INDEX_BUFFER = 4;
15
+ export declare const QROT_BUFFER = 5;
16
+ export declare const SIZE_BUFFER = 6;
17
+ export declare const PICKINGCOLOR_BUFFER = 7;
18
+ export declare const VISIBLE_BUFFER = 8;
19
+ export declare const TEXCOORD_BUFFER = 9;
20
+ export declare const TRANSLATE_BUFFER = 10;
21
+ export declare const LOCALPOSITION_BUFFER = 11;
22
+ export declare class GeoObjectHandler {
63
23
  static __counter__: number;
64
24
  protected __id: number;
65
25
  /**
@@ -69,37 +29,53 @@ declare class GeoObjectHandler {
69
29
  */
70
30
  pickingEnabled: boolean;
71
31
  protected _entityCollection: EntityCollection;
72
- _planet: Planet | null;
32
+ _renderNode: RenderNode | null;
33
+ _renderer: Renderer | null;
73
34
  protected _geoObjects: GeoObject[];
74
35
  protected _instanceDataMap: Map<string, InstanceData>;
75
36
  protected _instanceDataMapValues: InstanceData[];
76
37
  protected _dataTagUpdateQueue: InstanceData[];
38
+ protected _relativeCenter: Vec3;
39
+ protected _rtcEyePositionHigh: Float32Array;
40
+ protected _rtcEyePositionLow: Float32Array;
77
41
  constructor(entityCollection: EntityCollection);
78
42
  initProgram(): void;
79
- setRenderNode(renderNode: Planet): void;
80
- setTextureTag(src: string, tag: string): void;
43
+ setRenderNode(renderNode: RenderNode): void;
44
+ setColorTextureTag(src: string, tag: string): void;
45
+ setNormalTextureTag(src: string, tag: string): void;
46
+ setMetallicRoughnessTextureTag(src: string, tag: string): void;
81
47
  setObjectSrc(src: string, tag: string): void;
82
48
  _updateInstanceData(object: Object3d, tag: string): void;
83
49
  protected _addGeoObjectToArray(geoObject: GeoObject): void;
84
- _displayPASS(): void;
50
+ protected _bindCommon(): void;
51
+ _displayOpaquePASS(): void;
52
+ _displayTransparentPASS(): void;
53
+ protected _depthPASS(): void;
54
+ drawDepth(): void;
85
55
  drawPicking(): void;
86
56
  protected _pickingPASS(): void;
87
- _loadDataTagTexture(tagData: InstanceData): Promise<void>;
57
+ _loadColorTexture(tagData: InstanceData): Promise<void>;
58
+ _loadNormalTexture(tagData: InstanceData): Promise<void>;
59
+ _loadMetallicRoughnessTexture(tagData: InstanceData): Promise<void>;
88
60
  setQRotArr(tagData: InstanceData, tagDataIndex: number, qRot: Quat): void;
89
61
  setVisibility(tagData: InstanceData, tagDataIndex: number, visibility: boolean): void;
90
- setPositionArr(tagData: InstanceData, tagDataIndex: number, positionHigh: Vec3, positionLow: Vec3): void;
62
+ setRTCPositionArr(tagData: InstanceData, tagDataIndex: number, rtcPositionHigh: Vec3, rtcPositionLow: Vec3): void;
91
63
  setRgbaArr(tagData: InstanceData, tagDataIndex: number, rgba: Vec4): void;
92
64
  setPickingColorArr(tagData: InstanceData, tagDataIndex: number, color: Vec3): void;
93
65
  setScaleArr(tagData: InstanceData, tagDataIndex: number, scale: Vec3): void;
94
66
  setTranslateArr(tagData: InstanceData, tagDataIndex: number, translate: Vec3): void;
67
+ setLocalPositionArr(tagData: InstanceData, tagDataIndex: number, localPosition: Vec3): void;
95
68
  protected _updateTag(dataTag: InstanceData): void;
96
69
  update(): void;
97
70
  _removeAll(): void;
98
71
  clear(): void;
72
+ getRTCPosition(pos: Vec3, rtcPositionHigh: Vec3, rtcPositionLow: Vec3): void;
73
+ setRelativeCenter(c: Vec3): void;
74
+ protected _updateRTCEyePosition(): void;
99
75
  draw(): void;
76
+ drawTransparent(): void;
100
77
  add(geoObject: GeoObject): void;
101
78
  remove(geoObject: GeoObject): void;
102
79
  _clearDataTagQueue(): void;
103
80
  _removeGeoObject(geoObject: GeoObject): void;
104
81
  }
105
- export { GeoObjectHandler, InstanceData };