@openglobus/og 0.11.5 → 0.12.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.
- package/css/og.css +5 -2
- package/package.json +12 -14
- package/src/og/Clock.js +6 -10
- package/src/og/Events.js +5 -7
- package/src/og/Extent.js +73 -32
- package/src/og/Globe.js +25 -10
- package/src/og/ImageCanvas.js +18 -15
- package/src/og/LonLat.js +13 -10
- package/src/og/Popup.js +19 -17
- package/src/og/QueueArray.js +3 -4
- package/src/og/Rectangle.js +4 -6
- package/src/og/Stack.js +2 -4
- package/src/og/ajax.js +20 -14
- package/src/og/astro/earth.js +21 -15
- package/src/og/bv/Box.js +2 -3
- package/src/og/bv/Sphere.js +10 -7
- package/src/og/camera/Camera.js +70 -79
- package/src/og/camera/Frustum.js +19 -12
- package/src/og/camera/PlanetCamera.js +33 -34
- package/src/og/control/CompassButton.js +1 -2
- package/src/og/control/Control.js +7 -9
- package/src/og/control/DebugInfo.js +2 -3
- package/src/og/control/EarthNavigation.js +26 -17
- package/src/og/control/KeyboardNavigation.js +9 -9
- package/src/og/control/LayerSwitcher.js +21 -20
- package/src/og/control/Lighting.js +74 -64
- package/src/og/control/MouseNavigation.js +30 -29
- package/src/og/control/MouseWheelZoomControl.js +257 -0
- package/src/og/control/SegmentBoundVisualization.js +5 -6
- package/src/og/control/ShowFps.js +12 -7
- package/src/og/control/SimpleNavigation.js +5 -7
- package/src/og/control/Sun.js +24 -14
- package/src/og/control/ToggleWireframe.js +3 -3
- package/src/og/control/TouchNavigation.js +43 -32
- package/src/og/control/ZoomControl.js +40 -24
- package/src/og/control/index.js +2 -0
- package/src/og/control/visibleExtent/Segment.js +1862 -0
- package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
- package/src/og/control/visibleExtent/drawnode.js +751 -0
- package/src/og/ellipsoid/Ellipsoid.js +149 -57
- package/src/og/ellipsoid/wgs84.js +3 -3
- package/src/og/entity/BaseBillboard.js +72 -30
- package/src/og/entity/Billboard.js +9 -5
- package/src/og/entity/BillboardHandler.js +315 -62
- package/src/og/entity/Entity.js +742 -704
- package/src/og/entity/EntityCollection.js +47 -24
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +895 -0
- package/src/og/entity/GeometryHandler.js +595 -123
- package/src/og/entity/Label.js +62 -30
- package/src/og/entity/LabelHandler.js +42 -243
- package/src/og/entity/LabelWorker.js +218 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +76 -28
- package/src/og/entity/PointCloudHandler.js +5 -5
- package/src/og/entity/Ray.js +49 -16
- package/src/og/entity/Strip.js +72 -43
- package/src/og/entity/StripHandler.js +23 -23
- package/src/og/layer/BaseGeoImage.js +50 -19
- package/src/og/layer/CanvasTiles.js +16 -17
- package/src/og/layer/GeoImage.js +8 -16
- package/src/og/layer/GeoTexture2d.js +2 -10
- package/src/og/layer/GeoVideo.js +2 -10
- package/src/og/layer/KML.js +55 -33
- package/src/og/layer/Layer.js +24 -33
- package/src/og/layer/Material.js +1 -1
- package/src/og/layer/Vector.js +94 -48
- package/src/og/layer/WMS.js +33 -18
- package/src/og/layer/XYZ.js +24 -26
- package/src/og/light/LightSource.js +19 -12
- package/src/og/math/Mat3.js +24 -12
- package/src/og/math/Mat4.js +603 -603
- package/src/og/math/Plane.js +19 -18
- package/src/og/math/Ray.js +17 -12
- package/src/og/math/Vec2.js +24 -14
- package/src/og/math/Vec3.js +78 -32
- package/src/og/math/coder.js +7 -7
- package/src/og/proj/EPSG3857.js +3 -3
- package/src/og/proj/EPSG4326.js +3 -3
- package/src/og/proj/Proj.js +2 -4
- package/src/og/quadTree/Node.js +50 -95
- package/src/og/quadTree/quadTree.js +1 -1
- package/src/og/renderer/Renderer.js +106 -126
- package/src/og/renderer/RendererEvents.js +45 -23
- package/src/og/scene/BaseNode.js +2 -3
- package/src/og/scene/Planet.js +139 -191
- package/src/og/scene/RenderNode.js +15 -8
- package/src/og/segment/Segment.js +93 -268
- package/src/og/segment/Slice.js +45 -0
- package/src/og/shaders/drawnode.js +174 -360
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/pointCloud.js +41 -41
- package/src/og/shaders/shape.js +12 -18
- package/src/og/shaders/skybox.js +36 -36
- package/src/og/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +108 -36
- package/src/og/shapes/Icosphere.js +25 -10
- package/src/og/shapes/Sphere.js +8 -11
- package/src/og/terrain/EmptyTerrain.js +3 -2
- package/src/og/terrain/GlobusTerrain.js +2 -0
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/GeoImageCreator.js +5 -1
- package/src/og/utils/Loader.js +1 -1
- package/src/og/utils/PlainSegmentWorker.js +0 -13
- package/src/og/utils/TextureAtlas.js +18 -20
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +2 -2
- package/src/og/webgl/Handler.js +219 -162
- package/src/og/webgl/Multisample.js +44 -16
- package/src/og/webgl/Program.js +78 -33
- package/src/og/webgl/callbacks.js +3 -3
- package/types/Clock.d.ts +0 -94
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -77
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -82
- package/types/ImageCanvas.d.ts +0 -123
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -42
- package/types/QueueArray.d.ts +0 -19
- package/types/Rectangle.d.ts +0 -80
- package/types/Stack.d.ts +0 -19
- package/types/ajax.d.ts +0 -24
- package/types/arial.d.ts +0 -48
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -7
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -30
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -312
- package/types/camera/Frustum.d.ts +0 -133
- package/types/camera/PlanetCamera.d.ts +0 -218
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -17
- package/types/control/Control.d.ts +0 -104
- package/types/control/DebugInfo.d.ts +0 -15
- package/types/control/EarthCoordinates.d.ts +0 -47
- package/types/control/EarthNavigation.d.ts +0 -42
- package/types/control/GeoImageDragControl.d.ts +0 -6
- package/types/control/KeyboardNavigation.d.ts +0 -21
- package/types/control/LayerSwitcher.d.ts +0 -21
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -47
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -11
- package/types/control/SimpleNavigation.d.ts +0 -25
- package/types/control/Sun.d.ts +0 -50
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -48
- package/types/control/ZoomControl.d.ts +0 -27
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -146
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -6
- package/types/entity/BaseBillboard.d.ts +0 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -78
- package/types/entity/Entity.d.ts +0 -333
- package/types/entity/EntityCollection.d.ts +0 -311
- package/types/entity/Geometry.d.ts +0 -74
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -189
- package/types/entity/LabelHandler.d.ts +0 -29
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -306
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -124
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -119
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.core.d.ts +0 -65
- package/types/index.d.ts +0 -45
- package/types/index.webgl.d.ts +0 -7
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -34
- package/types/layer/BaseGeoImage.d.ts +0 -94
- package/types/layer/CanvasTiles.d.ts +0 -68
- package/types/layer/GeoImage.d.ts +0 -52
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -55
- package/types/layer/KML.d.ts +0 -63
- package/types/layer/Layer.d.ts +0 -326
- package/types/layer/Material.d.ts +0 -45
- package/types/layer/Vector.d.ts +0 -208
- package/types/layer/WMS.d.ts +0 -63
- package/types/layer/XYZ.d.ts +0 -120
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -178
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -65
- package/types/math/Mat4.d.ts +0 -176
- package/types/math/Plane.d.ts +0 -18
- package/types/math/Quat.d.ts +0 -379
- package/types/math/Ray.d.ts +0 -82
- package/types/math/Vec2.d.ts +0 -309
- package/types/math/Vec3.d.ts +0 -460
- package/types/math/Vec4.d.ts +0 -162
- package/types/math/coder.d.ts +0 -43
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -261
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -6
- package/types/proj/EPSG4326.d.ts +0 -6
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EntityCollectionNode.d.ts +0 -34
- package/types/quadTree/Node.d.ts +0 -61
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -298
- package/types/renderer/RendererEvents.d.ts +0 -233
- package/types/res/images.d.ts +0 -3
- package/types/scene/Axes.d.ts +0 -11
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -577
- package/types/scene/RenderNode.d.ts +0 -142
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -279
- package/types/segment/SegmentLonLat.d.ts +0 -16
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -7
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/shape.d.ts +0 -4
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shapes/BaseShape.d.ts +0 -250
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -7
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -116
- package/types/terrain/MapboxTerrain.d.ts +0 -7
- package/types/terrain/index.d.ts +0 -5
- package/types/utils/FontAtlas.d.ts +0 -14
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -25
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -10
- package/types/utils/TerrainWorker.d.ts +0 -9
- package/types/utils/TextureAtlas.d.ts +0 -111
- package/types/utils/VectorTileCreator.d.ts +0 -16
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/shared.d.ts +0 -231
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -388
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- package/types/webgl/ProgramController.d.ts +0 -89
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
* @module og/entity/EntityCollection
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import * as math from
|
|
8
|
-
import { BillboardHandler } from
|
|
9
|
-
import { Events } from
|
|
10
|
-
import { LabelHandler } from
|
|
11
|
-
import { PolylineHandler } from
|
|
12
|
-
import { RayHandler } from
|
|
13
|
-
import { PointCloudHandler } from
|
|
14
|
-
import { StripHandler } from
|
|
15
|
-
import { ShapeHandler } from
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as math from "../math.js";
|
|
8
|
+
import { BillboardHandler } from "./BillboardHandler.js";
|
|
9
|
+
import { Events } from "../Events.js";
|
|
10
|
+
import { LabelHandler } from "./LabelHandler.js";
|
|
11
|
+
import { PolylineHandler } from "./PolylineHandler.js";
|
|
12
|
+
import { RayHandler } from "./RayHandler.js";
|
|
13
|
+
import { PointCloudHandler } from "./PointCloudHandler.js";
|
|
14
|
+
import { StripHandler } from "./StripHandler.js";
|
|
15
|
+
import { ShapeHandler } from "./ShapeHandler.js";
|
|
16
|
+
import { GeoObjectHandler } from "./GeoObjectHandler.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* An observable collection of og.Entity instances where each entity has a unique id.
|
|
@@ -65,7 +66,6 @@ import { ShapeHandler } from './ShapeHandler.js';
|
|
|
65
66
|
*/
|
|
66
67
|
class EntityCollection {
|
|
67
68
|
constructor(options) {
|
|
68
|
-
|
|
69
69
|
options = options || {};
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -101,14 +101,16 @@ class EntityCollection {
|
|
|
101
101
|
* @public
|
|
102
102
|
* @type {Number}
|
|
103
103
|
*/
|
|
104
|
-
this.polygonOffsetFactor =
|
|
104
|
+
this.polygonOffsetFactor =
|
|
105
|
+
options.polygonOffsetFactor != undefined ? options.polygonOffsetFactor : 0.0;
|
|
105
106
|
|
|
106
107
|
/**
|
|
107
108
|
* Specifies the scale Units for gl.polygonOffset function to calculate depth values, 0.0 is default.
|
|
108
109
|
* @public
|
|
109
110
|
* @type {Number}
|
|
110
111
|
*/
|
|
111
|
-
this.polygonOffsetUnits =
|
|
112
|
+
this.polygonOffsetUnits =
|
|
113
|
+
options.polygonOffsetUnits != undefined ? options.polygonOffsetUnits : 0.0;
|
|
112
114
|
|
|
113
115
|
/**
|
|
114
116
|
* Billboards handler
|
|
@@ -159,6 +161,13 @@ class EntityCollection {
|
|
|
159
161
|
*/
|
|
160
162
|
this.stripHandler = new StripHandler(this);
|
|
161
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Geo object handler
|
|
166
|
+
* @public
|
|
167
|
+
* @type {og.GeoObjectHandler}
|
|
168
|
+
*/
|
|
169
|
+
this.geoObjectHandler = new GeoObjectHandler(this);
|
|
170
|
+
|
|
162
171
|
if (options.pickingEnabled != undefined) {
|
|
163
172
|
this.setPickingEnabled(options.pickingEnabled);
|
|
164
173
|
}
|
|
@@ -268,6 +277,7 @@ class EntityCollection {
|
|
|
268
277
|
this.shapeHandler.pickingEnabled = enable;
|
|
269
278
|
this.pointCloudHandler.pickingEnabled = enable;
|
|
270
279
|
this.stripHandler.pickingEnabled = enable;
|
|
280
|
+
this.geoObjectHandler.pickingEnabled = enable;
|
|
271
281
|
}
|
|
272
282
|
|
|
273
283
|
/**
|
|
@@ -293,7 +303,6 @@ class EntityCollection {
|
|
|
293
303
|
}
|
|
294
304
|
|
|
295
305
|
_addRecursively(entity) {
|
|
296
|
-
|
|
297
306
|
// billboard
|
|
298
307
|
entity.billboard && this.billboardHandler.add(entity.billboard);
|
|
299
308
|
|
|
@@ -315,6 +324,9 @@ class EntityCollection {
|
|
|
315
324
|
// strip
|
|
316
325
|
entity.strip && this.stripHandler.add(entity.strip);
|
|
317
326
|
|
|
327
|
+
//geoObject
|
|
328
|
+
entity.geoObject && this.geoObjectHandler.add(entity.geoObject);
|
|
329
|
+
|
|
318
330
|
this.events.dispatch(this.events.entityadd, entity);
|
|
319
331
|
|
|
320
332
|
for (var i = 0; i < entity.childrenNodes.length; i++) {
|
|
@@ -369,7 +381,10 @@ class EntityCollection {
|
|
|
369
381
|
* @returns {boolean} -
|
|
370
382
|
*/
|
|
371
383
|
belongs(entity) {
|
|
372
|
-
return (
|
|
384
|
+
return (
|
|
385
|
+
entity._entityCollection &&
|
|
386
|
+
this._renderNodeIndex === entity._entityCollection._renderNodeIndex
|
|
387
|
+
);
|
|
373
388
|
}
|
|
374
389
|
|
|
375
390
|
_removeRecursively(entity) {
|
|
@@ -397,6 +412,9 @@ class EntityCollection {
|
|
|
397
412
|
// strip
|
|
398
413
|
entity.strip && this.stripHandler.remove(entity.strip);
|
|
399
414
|
|
|
415
|
+
// geoObject
|
|
416
|
+
entity.geoObject && this.geoObjectHandler.remove(entity.geoObject);
|
|
417
|
+
|
|
400
418
|
for (var i = 0; i < entity.childrenNodes.length; i++) {
|
|
401
419
|
this._removeRecursively(entity.childrenNodes[i]);
|
|
402
420
|
}
|
|
@@ -493,13 +511,13 @@ class EntityCollection {
|
|
|
493
511
|
* @param {RenderNode} renderNode
|
|
494
512
|
*/
|
|
495
513
|
bindRenderNode(renderNode) {
|
|
496
|
-
|
|
497
514
|
if (renderNode.renderer) {
|
|
498
|
-
|
|
499
515
|
this.billboardHandler.setRenderer(renderNode.renderer);
|
|
500
516
|
this.labelHandler.setRenderer(renderNode.renderer);
|
|
501
517
|
this.rayHandler.setRenderer(renderNode.renderer);
|
|
502
518
|
|
|
519
|
+
this.geoObjectHandler.setRenderNode(renderNode);
|
|
520
|
+
|
|
503
521
|
this.shapeHandler.setRenderNode(renderNode);
|
|
504
522
|
this.polylineHandler.setRenderNode(renderNode);
|
|
505
523
|
this.pointCloudHandler.setRenderNode(renderNode);
|
|
@@ -542,9 +560,10 @@ class EntityCollection {
|
|
|
542
560
|
*/
|
|
543
561
|
updateLabelsFontAtlas() {
|
|
544
562
|
if (this.renderNode) {
|
|
545
|
-
var l = this.labelHandler._billboards;
|
|
546
|
-
|
|
547
|
-
|
|
563
|
+
var l = [].concat(this.labelHandler._billboards);
|
|
564
|
+
this.labelHandler._billboards = [];
|
|
565
|
+
for (var i = 0; i < l.length; i++) {
|
|
566
|
+
this.labelHandler.assignFontAtlas(l[i]);
|
|
548
567
|
}
|
|
549
568
|
}
|
|
550
569
|
}
|
|
@@ -558,7 +577,11 @@ class EntityCollection {
|
|
|
558
577
|
if (this._renderNodeIndex !== -1) {
|
|
559
578
|
this.renderNode.entityCollections.splice(this._renderNodeIndex, 1);
|
|
560
579
|
// reindex in the renderNode
|
|
561
|
-
for (
|
|
580
|
+
for (
|
|
581
|
+
var i = this._renderNodeIndex;
|
|
582
|
+
i < this.renderNode.entityCollections.length;
|
|
583
|
+
i++
|
|
584
|
+
) {
|
|
562
585
|
this.renderNode.entityCollections._renderNodeIndex = i;
|
|
563
586
|
}
|
|
564
587
|
}
|
|
@@ -595,7 +618,6 @@ class EntityCollection {
|
|
|
595
618
|
* @public
|
|
596
619
|
*/
|
|
597
620
|
clear() {
|
|
598
|
-
|
|
599
621
|
// TODO: Optimize by replace delete
|
|
600
622
|
// code to the clearEntity function.
|
|
601
623
|
this.billboardHandler.clear();
|
|
@@ -605,6 +627,7 @@ class EntityCollection {
|
|
|
605
627
|
this.rayHandler.clear();
|
|
606
628
|
this.pointCloudHandler.clear();
|
|
607
629
|
this.stripHandler.clear();
|
|
630
|
+
this.geoObjectHandler.clear();
|
|
608
631
|
|
|
609
632
|
var i = this._entities.length;
|
|
610
633
|
while (i--) {
|
|
@@ -833,4 +856,4 @@ const EVENT_NAMES = [
|
|
|
833
856
|
"touchenter"
|
|
834
857
|
];
|
|
835
858
|
|
|
836
|
-
export { EntityCollection };
|
|
859
|
+
export { EntityCollection };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module og/shape/BaseShape
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { Quat, Vec3 } from "../math/index.js";
|
|
8
|
+
import { MAX32, RADIANS, lerp } from "../math.js";
|
|
9
|
+
import { LonLat } from "../LonLat.js";
|
|
10
|
+
import * as utils from "../utils/shared.js";
|
|
11
|
+
import { Planet } from "../scene/Planet.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @class
|
|
15
|
+
* @param {Object} options - Geo object parameters:
|
|
16
|
+
* @param {og.Vec3} [options.position] - Geo object position.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
class GeoObject {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
options = options || {};
|
|
22
|
+
|
|
23
|
+
this.scale = options.scale || 0.02;
|
|
24
|
+
this.scaleByDistance = new Float32Array(options.scaleByDistance || [MAX32, MAX32, MAX32]);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Geo object center cartesian position.
|
|
28
|
+
* @protected
|
|
29
|
+
* @type {og.Vec3}
|
|
30
|
+
*/
|
|
31
|
+
this._position = utils.createVector3(options.position);
|
|
32
|
+
|
|
33
|
+
this._positionHigh = new Vec3();
|
|
34
|
+
|
|
35
|
+
this._positionLow = new Vec3();
|
|
36
|
+
|
|
37
|
+
Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
|
|
38
|
+
|
|
39
|
+
this._pitch = options.pitch || 0.0;
|
|
40
|
+
this._yaw = options.yaw || 0.0;
|
|
41
|
+
this._roll = options.roll || 0.0;
|
|
42
|
+
|
|
43
|
+
this._planet = options.planet || null;
|
|
44
|
+
this._lonLatAlt = new LonLat(0, 0, 100000);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* RGBA color.
|
|
48
|
+
* @protected
|
|
49
|
+
* @type {og.Vec4}
|
|
50
|
+
*/
|
|
51
|
+
this._color = utils.createColorRGBA(options.color);
|
|
52
|
+
|
|
53
|
+
this._direction = new Vec3(0, 0, 0);
|
|
54
|
+
|
|
55
|
+
this._handler = null;
|
|
56
|
+
this._handlerIndex = -1;
|
|
57
|
+
this._vertices = options.vertices;
|
|
58
|
+
this._normals = options.normals;
|
|
59
|
+
this._indices = options.indices;
|
|
60
|
+
this.instanced = options.instanced;
|
|
61
|
+
this.tag = options.tag || "none";
|
|
62
|
+
if (options.indices) {
|
|
63
|
+
this._indicesCount = options.indices.length;
|
|
64
|
+
}
|
|
65
|
+
if (options.vertices) {
|
|
66
|
+
this._verticesCount = Math.floor(options.vertices.length / 3);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get planet() {
|
|
71
|
+
return this._handler && this._handler._planet;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get renderer() {
|
|
75
|
+
return this.planet && this.planet.renderer;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sets geo object opacity.
|
|
80
|
+
* @public
|
|
81
|
+
* @param {number} a - Billboard opacity.
|
|
82
|
+
*/
|
|
83
|
+
setOpacity(a) {
|
|
84
|
+
this._color.w = a;
|
|
85
|
+
this.setColor(this._color.x, this._color.y, this._color.z, a);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Sets RGBA color. Each channel from 0.0 to 1.0.
|
|
90
|
+
* @public
|
|
91
|
+
* @param {number} r - Red.
|
|
92
|
+
* @param {number} g - Green.
|
|
93
|
+
* @param {number} b - Blue.
|
|
94
|
+
* @param {number} a - Alpha.
|
|
95
|
+
*/
|
|
96
|
+
setColor(r, g, b, a) {
|
|
97
|
+
this._color.x = r;
|
|
98
|
+
this._color.y = g;
|
|
99
|
+
this._color.z = b;
|
|
100
|
+
a != undefined && (this._color.w = a);
|
|
101
|
+
this._handler && this._handler.setRgbaArr(this._handlerIndex, this._color);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Sets RGBA color. Each channel from 0.0 to 1.0.
|
|
106
|
+
* @public
|
|
107
|
+
* @param {og.Vec4} color - RGBA vector.
|
|
108
|
+
*/
|
|
109
|
+
setColor4v(color) {
|
|
110
|
+
this._color.x = color.x;
|
|
111
|
+
this._color.y = color.y;
|
|
112
|
+
this._color.z = color.z;
|
|
113
|
+
color.w != undefined && (this._color.w = color.w);
|
|
114
|
+
this._handler && this._handler.setRgbaArr(this._handlerIndex, color);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Sets geo object visibility.
|
|
119
|
+
* @public
|
|
120
|
+
* @param {boolean} visibility - Visibility flag.
|
|
121
|
+
*/
|
|
122
|
+
setVisibility(visibility) {
|
|
123
|
+
this._visibility = visibility;
|
|
124
|
+
this._handler && this._handler.setVisibility(this._handlerIndex, visibility);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Returns geo object visibility.
|
|
129
|
+
* @public
|
|
130
|
+
* @returns {boolean}
|
|
131
|
+
*/
|
|
132
|
+
getVisibility() {
|
|
133
|
+
return this._visibility;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
setLonLat(lon, lat, alt) {
|
|
137
|
+
this._lonLatAlt.lon = lon;
|
|
138
|
+
this._lonLatAlt.lat = lat;
|
|
139
|
+
this._lonLatAlt.height = alt;
|
|
140
|
+
this._handler._planet.ellipsoid.lonLatToCartesianRes(this._lonLatAlt, this._position);
|
|
141
|
+
this.setPosition3v(this._position);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Sets geoObject position.
|
|
146
|
+
* @public
|
|
147
|
+
* @param {number} x - X coordinate.
|
|
148
|
+
* @param {number} y - Y coordinate.
|
|
149
|
+
* @param {number} z - Z coordinate.
|
|
150
|
+
*/
|
|
151
|
+
setPosition(x, y, z) {
|
|
152
|
+
this._position.x = x;
|
|
153
|
+
this._position.y = y;
|
|
154
|
+
this._position.z = z;
|
|
155
|
+
Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
|
|
156
|
+
this._handler &&
|
|
157
|
+
this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
|
|
158
|
+
this.updateDirection();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Sets billboard position.
|
|
163
|
+
* @public
|
|
164
|
+
* @param {og.Vec3} position - Cartesian coordinates.
|
|
165
|
+
*/
|
|
166
|
+
setPosition3v(position) {
|
|
167
|
+
this._position.x = position.x;
|
|
168
|
+
this._position.y = position.y;
|
|
169
|
+
this._position.z = position.z;
|
|
170
|
+
Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
|
|
171
|
+
this._handler &&
|
|
172
|
+
this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
|
|
173
|
+
this.updateDirection();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
setYaw(yaw) {
|
|
177
|
+
this._yaw = yaw;
|
|
178
|
+
this.updateDirection();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
setPitch(pitch) {
|
|
182
|
+
this._pitch = pitch;
|
|
183
|
+
this._handler && this._handler.setPitchRollArr(this._handlerIndex, pitch, this._roll);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
setRoll(roll) {
|
|
187
|
+
this._roll = roll;
|
|
188
|
+
this._handler && this._handler.setPitchRollArr(this._handlerIndex, this._pitch, roll);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
setScale(scale) {
|
|
192
|
+
this.scale = scale;
|
|
193
|
+
this._handler && this._handler.setScaleArr(this._handlerIndex, scale);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Removes geo object from handler.
|
|
198
|
+
* @public
|
|
199
|
+
*/
|
|
200
|
+
remove() {
|
|
201
|
+
this._entity = null;
|
|
202
|
+
this._handler && this._handler.remove(this);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Sets billboard picking color.
|
|
207
|
+
* @public
|
|
208
|
+
* @param {og.Vec3} color - Picking color.
|
|
209
|
+
*/
|
|
210
|
+
setPickingColor3v(color) {
|
|
211
|
+
this._handler && this._handler.setPickingColorArr(this._handlerIndex, color);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
updateDirection() {
|
|
215
|
+
if (this._entity && this._entity.renderNode && this._entity.renderNode.ellipsoid) {
|
|
216
|
+
this._entity.renderNode.ellipsoid.lonLatToCartesianRes(this._lonLatAlt, this._position);
|
|
217
|
+
}
|
|
218
|
+
this._qNorthFrame = Planet.getBearingNorthRotationQuat(this._position);
|
|
219
|
+
|
|
220
|
+
let qq = Quat.yRotation(this._yaw * RADIANS)
|
|
221
|
+
.mul(this._qNorthFrame)
|
|
222
|
+
.conjugate();
|
|
223
|
+
this._direction = qq.mulVec3(new Vec3(0.0, 0.0, -1.0)).normalize();
|
|
224
|
+
this._handler && this._handler.setDirectionArr(this._handlerIndex, this._direction);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export { GeoObject };
|