@openglobus/og 0.22.2 → 0.24.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 +137 -1
- package/lib/@openglobus/js/Globe.d.ts +0 -1
- package/lib/@openglobus/js/Object3d.d.ts +20 -10
- package/lib/@openglobus/js/camera/Camera.d.ts +57 -15
- package/lib/@openglobus/js/camera/Frustum.d.ts +3 -0
- package/lib/@openglobus/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/@openglobus/js/control/CameraLock.d.ts +38 -0
- package/lib/@openglobus/js/control/MouseNavigation.d.ts +62 -51
- package/lib/@openglobus/js/control/OldMouseNavigation.d.ts +64 -0
- package/lib/@openglobus/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/@openglobus/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/@openglobus/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/@openglobus/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/@openglobus/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/@openglobus/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/@openglobus/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/@openglobus/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/@openglobus/js/control/index.d.ts +3 -2
- package/lib/@openglobus/js/entity/Entity.d.ts +282 -19
- package/lib/@openglobus/js/entity/EntityCollection.d.ts +8 -9
- package/lib/@openglobus/js/entity/GeoObject.d.ts +135 -39
- package/lib/@openglobus/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/@openglobus/js/entity/InstanceData.d.ts +76 -0
- package/lib/@openglobus/js/entity/Polyline.d.ts +19 -6
- package/lib/@openglobus/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/@openglobus/js/index.d.ts +2 -1
- package/lib/@openglobus/js/input/MouseHandler.d.ts +1 -0
- package/lib/@openglobus/js/layer/Vector.d.ts +4 -0
- package/lib/@openglobus/js/light/LightSource.d.ts +1 -139
- package/lib/@openglobus/js/math/Mat3.d.ts +1 -1
- package/lib/@openglobus/js/math/Mat4.d.ts +10 -1
- package/lib/@openglobus/js/math/Plane.d.ts +3 -1
- package/lib/@openglobus/js/math/Quat.d.ts +47 -33
- package/lib/@openglobus/js/math/Ray.d.ts +10 -14
- package/lib/@openglobus/js/math/Vec2.d.ts +22 -0
- package/lib/@openglobus/js/math/Vec3.d.ts +15 -0
- package/lib/@openglobus/js/math.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/@openglobus/js/quadTree/Node.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/@openglobus/js/renderer/Renderer.d.ts +63 -44
- package/lib/@openglobus/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/@openglobus/js/scene/Planet.d.ts +15 -7
- package/lib/@openglobus/js/scene/RenderNode.d.ts +10 -25
- package/lib/@openglobus/js/shaders/drawnode.d.ts +1 -0
- package/lib/@openglobus/js/shaders/geoObject.d.ts +1 -0
- package/lib/@openglobus/js/shaders/utils.d.ts +1 -1
- package/lib/@openglobus/js/ui/Checkbox.d.ts +31 -0
- package/lib/@openglobus/js/ui/Dialog.d.ts +3 -0
- package/lib/@openglobus/js/ui/Input.d.ts +32 -0
- package/lib/@openglobus/js/ui/View.d.ts +3 -1
- package/lib/@openglobus/js/utils/objParser.d.ts +44 -12
- package/lib/@openglobus/js/utils/shared.d.ts +22 -0
- package/lib/@openglobus/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/@openglobus/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/@openglobus/js/webgl/Handler.d.ts +22 -12
- package/lib/@openglobus/og.css +1 -1
- package/lib/@openglobus/og.esm.js +1 -1
- package/lib/@openglobus/og.esm.js.map +1 -1
- package/lib/@openglobus/og.umd.js +1 -1
- package/lib/@openglobus/og.umd.js.map +1 -1
- package/lib/js/Globe.d.ts +0 -1
- package/lib/js/Globe.js +4 -2
- package/lib/js/Object3d.d.ts +20 -10
- package/lib/js/Object3d.js +124 -48
- package/lib/js/Popup.js +1 -1
- package/lib/js/camera/Camera.d.ts +57 -15
- package/lib/js/camera/Camera.js +109 -29
- package/lib/js/camera/Frustum.d.ts +3 -0
- package/lib/js/camera/Frustum.js +7 -0
- package/lib/js/camera/PlanetCamera.d.ts +13 -0
- package/lib/js/camera/PlanetCamera.js +52 -5
- package/lib/js/control/Atmosphere.js +10 -6
- package/lib/js/control/CameraLock.d.ts +38 -0
- package/lib/js/control/CameraLock.js +216 -0
- package/lib/js/control/Control.js +1 -1
- package/lib/js/control/DebugInfo.js +38 -8
- package/lib/js/control/KeyboardNavigation.js +9 -9
- package/lib/js/control/MouseNavigation.d.ts +62 -51
- package/lib/js/control/MouseNavigation.js +361 -305
- package/lib/js/control/MouseWheelZoomControl.d.ts +0 -44
- package/lib/js/control/MouseWheelZoomControl.js +270 -181
- package/lib/js/control/OldMouseNavigation.d.ts +64 -0
- package/lib/js/control/OldMouseNavigation.js +368 -0
- package/lib/js/control/ScaleControl.js +11 -5
- package/lib/js/control/SimpleNavigation.d.ts +27 -10
- package/lib/js/control/SimpleNavigation.js +149 -49
- package/lib/js/control/Sun.js +6 -6
- package/lib/js/control/TouchNavigation.js +11 -8
- package/lib/js/control/elevationProfile/ElevationProfileScene.js +6 -5
- package/lib/js/control/geoObjectEditor/ArrowEntity.d.ts +15 -0
- package/lib/js/control/geoObjectEditor/ArrowEntity.js +59 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/AxisTrackEntity.js +93 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.d.ts +13 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditor.js +30 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.d.ts +69 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorDialog.js +488 -0
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.d.ts +78 -9
- package/lib/js/control/geoObjectEditor/GeoObjectEditorScene.js +487 -43
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.d.ts +17 -0
- package/lib/js/control/geoObjectEditor/MoveAxisEntity.js +107 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.d.ts +7 -0
- package/lib/js/control/geoObjectEditor/MovePlaneEntity.js +31 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.d.ts +9 -0
- package/lib/js/control/geoObjectEditor/RotateEntity.js +105 -0
- package/lib/js/control/geoObjectEditor/colors.d.ts +8 -0
- package/lib/js/control/geoObjectEditor/colors.js +8 -0
- package/lib/js/control/index.d.ts +3 -2
- package/lib/js/control/index.js +3 -2
- package/lib/js/control/timeline/TimelineControl.js +2 -0
- package/lib/js/control/visibleExtent/Segment.js +4 -4
- package/lib/js/entity/Entity.d.ts +282 -19
- package/lib/js/entity/Entity.js +497 -62
- package/lib/js/entity/EntityCollection.d.ts +8 -9
- package/lib/js/entity/EntityCollection.js +48 -45
- package/lib/js/entity/GeoObject.d.ts +135 -39
- package/lib/js/entity/GeoObject.js +150 -90
- package/lib/js/entity/GeoObjectHandler.d.ts +39 -63
- package/lib/js/entity/GeoObjectHandler.js +198 -295
- package/lib/js/entity/InstanceData.d.ts +76 -0
- package/lib/js/entity/InstanceData.js +347 -0
- package/lib/js/entity/Polyline.d.ts +19 -6
- package/lib/js/entity/Polyline.js +76 -36
- package/lib/js/entity/PolylineHandler.d.ts +7 -0
- package/lib/js/entity/PolylineHandler.js +26 -1
- package/lib/js/index.d.ts +2 -1
- package/lib/js/index.js +2 -1
- package/lib/js/input/MouseHandler.d.ts +1 -0
- package/lib/js/input/MouseHandler.js +12 -1
- package/lib/js/layer/Bing.js +2 -2
- package/lib/js/layer/Vector.d.ts +4 -0
- package/lib/js/layer/Vector.js +16 -0
- package/lib/js/light/LightSource.d.ts +1 -139
- package/lib/js/light/LightSource.js +21 -227
- package/lib/js/math/Mat3.d.ts +1 -1
- package/lib/js/math/Mat3.js +1 -1
- package/lib/js/math/Mat4.d.ts +10 -1
- package/lib/js/math/Mat4.js +17 -1
- package/lib/js/math/Plane.d.ts +3 -1
- package/lib/js/math/Plane.js +11 -1
- package/lib/js/math/Quat.d.ts +47 -33
- package/lib/js/math/Quat.js +92 -90
- package/lib/js/math/Ray.d.ts +10 -14
- package/lib/js/math/Ray.js +56 -33
- package/lib/js/math/Vec2.d.ts +22 -0
- package/lib/js/math/Vec2.js +32 -0
- package/lib/js/math/Vec3.d.ts +15 -0
- package/lib/js/math/Vec3.js +30 -1
- package/lib/js/math.d.ts +2 -2
- package/lib/js/math.js +3 -3
- package/lib/js/quadTree/EntityCollectionNode.d.ts +2 -2
- package/lib/js/quadTree/EntityCollectionNode.js +8 -8
- package/lib/js/quadTree/Node.d.ts +1 -1
- package/lib/js/quadTree/Node.js +2 -2
- package/lib/js/quadTree/QuadTreeStrategy.js +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/earth/EarthEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.d.ts +1 -1
- package/lib/js/quadTree/equi/EquiEntityCollectionNodeLonLat.js +2 -2
- package/lib/js/renderer/Renderer.d.ts +63 -44
- package/lib/js/renderer/Renderer.js +267 -266
- package/lib/js/renderer/RendererEvents.d.ts +2 -0
- package/lib/js/renderer/RendererEvents.js +5 -2
- package/lib/js/scene/Planet.d.ts +15 -7
- package/lib/js/scene/Planet.js +133 -90
- package/lib/js/scene/RenderNode.d.ts +10 -25
- package/lib/js/scene/RenderNode.js +70 -58
- package/lib/js/segment/Segment.js +4 -4
- package/lib/js/shaders/depth.js +2 -5
- package/lib/js/shaders/drawnode.d.ts +1 -0
- package/lib/js/shaders/drawnode.js +51 -52
- package/lib/js/shaders/geoObject.d.ts +1 -0
- package/lib/js/shaders/geoObject.js +154 -91
- package/lib/js/shaders/polyline.js +68 -51
- package/lib/js/shaders/utils.d.ts +1 -1
- package/lib/js/shaders/utils.js +11 -0
- package/lib/js/terrain/GlobusTerrain.js +2 -2
- package/lib/js/ui/Checkbox.d.ts +31 -0
- package/lib/js/ui/Checkbox.js +110 -0
- package/lib/js/ui/Color.js +2 -1
- package/lib/js/ui/Dialog.d.ts +3 -0
- package/lib/js/ui/Dialog.js +20 -0
- package/lib/js/ui/Input.d.ts +32 -0
- package/lib/js/ui/Input.js +107 -0
- package/lib/js/ui/View.d.ts +3 -1
- package/lib/js/ui/View.js +6 -0
- package/lib/js/utils/objParser.d.ts +44 -12
- package/lib/js/utils/objParser.js +241 -149
- package/lib/js/utils/shared.d.ts +22 -0
- package/lib/js/utils/shared.js +34 -0
- package/lib/js/webgl/BaseFramebuffer.d.ts +0 -1
- package/lib/js/webgl/Framebuffer.d.ts +35 -8
- package/lib/js/webgl/Framebuffer.js +136 -29
- package/lib/js/webgl/Handler.d.ts +22 -12
- package/lib/js/webgl/Handler.js +53 -34
- package/lib/js/webgl/Program.js +0 -8
- package/package.json +5 -3
- package/lib/@openglobus/js/control/EarthNavigation.d.ts +0 -50
- package/lib/@openglobus/js/control/MouseWheelZoomControl.d.ts +0 -44
- package/lib/js/control/EarthNavigation.d.ts +0 -50
- package/lib/js/control/EarthNavigation.js +0 -202
|
@@ -1,11 +1,19 @@
|
|
|
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
|
-
|
|
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 {
|
|
8
|
-
* @param {
|
|
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 | Vec3 | NumberArray3} [options.scale=1] - Scale of the object.
|
|
14
|
+
* @param {Vec3 | NumberArray3} [options.translate] - Translation offset.
|
|
15
|
+
* @param {Vec4 | NumberArray4 | string} [options.color] - RGBA color or HTML color string.
|
|
16
|
+
* @param {boolean} [options.visibility=true] - Visibility flag.
|
|
9
17
|
*
|
|
10
18
|
* @todo: GeoObject and GeoObjectHandler provides instanced objects only.
|
|
11
19
|
* It would be nice if it could provide not instanced rendering loop too.
|
|
@@ -13,23 +21,15 @@ import { RADIANS } from "../math";
|
|
|
13
21
|
class GeoObject {
|
|
14
22
|
constructor(options) {
|
|
15
23
|
this._handlerIndex = -1;
|
|
16
|
-
this._tag = options.tag ||
|
|
17
|
-
this.instanced = true;
|
|
24
|
+
this._tag = options.tag || `tag_${GeoObject.__counter__++}`;
|
|
18
25
|
this._entity = null;
|
|
19
26
|
this._position = utils.createVector3(options.position);
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
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;
|
|
27
|
+
this._rtcPositionHigh = new Vec3();
|
|
28
|
+
this._rtcPositionLow = new Vec3();
|
|
29
29
|
this._scale = utils.createVector3(options.scale, new Vec3(1, 1, 1));
|
|
30
30
|
this._translate = utils.createVector3(options.translate, new Vec3());
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
31
|
+
this._localPosition = new Vec3();
|
|
32
|
+
this._color = utils.createColorRGBA(options.color, new Vec4(0.15, 0.15, 0.15, 1.0));
|
|
33
33
|
this._handler = null;
|
|
34
34
|
this._handlerIndex = -1;
|
|
35
35
|
this._tagData = null;
|
|
@@ -43,60 +43,91 @@ class GeoObject {
|
|
|
43
43
|
this._objectSrc = options.objSrc;
|
|
44
44
|
}
|
|
45
45
|
this._object3d = object3d;
|
|
46
|
-
if (options.
|
|
47
|
-
|
|
48
|
-
}
|
|
46
|
+
// if (options.colorTexture) {
|
|
47
|
+
// this.setColorTexture(options.colorTexture)
|
|
48
|
+
// }
|
|
49
49
|
this._visibility = (options.visibility != undefined ? options.visibility : true);
|
|
50
50
|
this._children = [];
|
|
51
51
|
this._direction = new Vec3();
|
|
52
|
-
this.
|
|
52
|
+
this._qFrame = new Quat();
|
|
53
|
+
this._qRot = Quat.IDENTITY;
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Gets the unique tag of the geo object.
|
|
57
|
+
* @returns {string}
|
|
58
|
+
*/
|
|
54
59
|
get tag() {
|
|
55
60
|
return this._tag;
|
|
56
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Gets the position of the geo object.
|
|
64
|
+
* @public
|
|
65
|
+
* @returns {Vec3}
|
|
66
|
+
*/
|
|
57
67
|
getPosition() {
|
|
58
68
|
return this._position;
|
|
59
69
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
getRoll() {
|
|
67
|
-
return this._roll;
|
|
68
|
-
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the 3D object associated with this geo object.
|
|
72
|
+
* @public
|
|
73
|
+
* @returns {Object3d}
|
|
74
|
+
*/
|
|
69
75
|
get object3d() {
|
|
70
76
|
return this._object3d;
|
|
71
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets geometry mesh vertices.
|
|
80
|
+
* @public
|
|
81
|
+
* @returns {number[]}
|
|
82
|
+
*/
|
|
72
83
|
get vertices() {
|
|
73
84
|
return this._object3d.vertices;
|
|
74
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Gets geometry mesh normals.
|
|
88
|
+
* @public
|
|
89
|
+
* @returns {number[]}
|
|
90
|
+
*/
|
|
75
91
|
get normals() {
|
|
76
92
|
return this._object3d.normals;
|
|
77
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets geometry mesh texture coordinates.
|
|
96
|
+
* @public
|
|
97
|
+
* @returns {number[]}
|
|
98
|
+
*/
|
|
78
99
|
get texCoords() {
|
|
79
100
|
return this._object3d.texCoords;
|
|
80
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Gets geometry mesh indices.
|
|
104
|
+
* @public
|
|
105
|
+
* @returns {number[]}
|
|
106
|
+
*/
|
|
81
107
|
get indices() {
|
|
82
108
|
return this._object3d.indices;
|
|
83
109
|
}
|
|
84
110
|
/**
|
|
85
|
-
* Sets geo object
|
|
86
|
-
* @
|
|
87
|
-
* @param {number} a - Billboard opacity.
|
|
111
|
+
* Sets the opacity of the geo object.
|
|
112
|
+
* @param {number} a - Opacity value (0 to 1).
|
|
88
113
|
*/
|
|
89
114
|
setOpacity(a) {
|
|
90
115
|
this._color.w = a;
|
|
91
116
|
this.setColor(this._color.x, this._color.y, this._color.z, a);
|
|
92
117
|
}
|
|
93
118
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
119
|
+
* Gets the opacity of the geo object.
|
|
120
|
+
* @returns {number}
|
|
121
|
+
*/
|
|
122
|
+
getOpacity() {
|
|
123
|
+
return this._color.w;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Sets the color of the geo object.
|
|
127
|
+
* @param {number} r - Red component.
|
|
128
|
+
* @param {number} g - Green component.
|
|
129
|
+
* @param {number} b - Blue component.
|
|
130
|
+
* @param {number} [a] - Alpha component.
|
|
100
131
|
*/
|
|
101
132
|
setColor(r, g, b, a) {
|
|
102
133
|
this._color.x = r;
|
|
@@ -145,75 +176,69 @@ class GeoObject {
|
|
|
145
176
|
this._position.x = x;
|
|
146
177
|
this._position.y = y;
|
|
147
178
|
this._position.z = z;
|
|
148
|
-
|
|
149
|
-
this._handler &&
|
|
150
|
-
this._handler.setPositionArr(this._tagData, this._tagDataIndex, this._positionHigh, this._positionLow);
|
|
179
|
+
this.updateRTCPosition();
|
|
151
180
|
this.updateRotation();
|
|
152
181
|
}
|
|
182
|
+
updateRTCPosition() {
|
|
183
|
+
//Vec3.doubleToTwoFloats(this._position, this._rtcPositionHigh, this._rtcPositionLow);
|
|
184
|
+
if (this._handler) {
|
|
185
|
+
this._handler.getRTCPosition(this._position, this._rtcPositionHigh, this._rtcPositionLow);
|
|
186
|
+
this._handler.setRTCPositionArr(this._tagData, this._tagDataIndex, this._rtcPositionHigh, this._rtcPositionLow);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
153
189
|
/**
|
|
154
190
|
* Sets geo object position.
|
|
155
191
|
* @public
|
|
156
192
|
* @param {Vec3} position - Cartesian coordinates.
|
|
157
193
|
*/
|
|
158
194
|
setPosition3v(position) {
|
|
159
|
-
this.
|
|
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();
|
|
195
|
+
this.setPosition(position.x, position.y, position.z);
|
|
170
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Sets Object3d for the object
|
|
199
|
+
* @param {Object3d} object
|
|
200
|
+
*/
|
|
171
201
|
setObject(object) {
|
|
172
202
|
this._object3d = object;
|
|
173
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Sets the object url source.
|
|
206
|
+
* @param {string} src
|
|
207
|
+
*/
|
|
174
208
|
setObjectSrc(src) {
|
|
175
209
|
this._objectSrc = src;
|
|
176
210
|
this._handler && this._handler.setObjectSrc(src, this.tag);
|
|
177
211
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
212
|
+
/**
|
|
213
|
+
* Sets object HTML color.
|
|
214
|
+
* @param {string} color
|
|
215
|
+
*/
|
|
183
216
|
setColorHTML(color) {
|
|
184
217
|
this.setColor4v(utils.htmlColorToRgba(color));
|
|
185
218
|
}
|
|
186
219
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @
|
|
220
|
+
* Sets scales.
|
|
221
|
+
* @public
|
|
222
|
+
* @param {number} scale
|
|
189
223
|
*/
|
|
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
224
|
setScale(scale) {
|
|
210
225
|
this._scale.x = this._scale.y = this._scale.z = scale;
|
|
211
226
|
this._handler && this._handler.setScaleArr(this._tagData, this._tagDataIndex, this._scale);
|
|
212
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Sets X, Y, Z axis scales
|
|
230
|
+
* @public
|
|
231
|
+
* @param {Vec3} scale
|
|
232
|
+
*/
|
|
213
233
|
setScale3v(scale) {
|
|
214
234
|
this._scale.copy(scale);
|
|
215
235
|
this._handler && this._handler.setScaleArr(this._tagData, this._tagDataIndex, scale);
|
|
216
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Gets scale.
|
|
239
|
+
* @publci
|
|
240
|
+
* @returns {Vec3}
|
|
241
|
+
*/
|
|
217
242
|
getScale() {
|
|
218
243
|
return this._scale;
|
|
219
244
|
}
|
|
@@ -222,10 +247,26 @@ class GeoObject {
|
|
|
222
247
|
this._handler && this._handler.setTranslateArr(this._tagData, this._tagDataIndex, translate);
|
|
223
248
|
}
|
|
224
249
|
getTranslate() {
|
|
225
|
-
return this._translate;
|
|
250
|
+
return this._translate.clone();
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Sets local offset position.
|
|
254
|
+
* @param {Vec3} localPosition
|
|
255
|
+
*/
|
|
256
|
+
setLocalPosition3v(localPosition) {
|
|
257
|
+
this._localPosition.copy(localPosition);
|
|
258
|
+
this._handler && this._handler.setLocalPositionArr(this._tagData, this._tagDataIndex, localPosition);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Gets local offset position.
|
|
262
|
+
* @public
|
|
263
|
+
* @returns {Vec3}
|
|
264
|
+
*/
|
|
265
|
+
getLocalPosition() {
|
|
266
|
+
return this._localPosition.clone();
|
|
226
267
|
}
|
|
227
268
|
/**
|
|
228
|
-
* Removes geo object from handler.
|
|
269
|
+
* Removes the geo object from the handler.
|
|
229
270
|
* @public
|
|
230
271
|
*/
|
|
231
272
|
remove() {
|
|
@@ -240,19 +281,38 @@ class GeoObject {
|
|
|
240
281
|
setPickingColor3v(color) {
|
|
241
282
|
this._handler && this._handler.setPickingColorArr(this._tagData, this._tagDataIndex, color);
|
|
242
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Sets the rotation quaternion.
|
|
286
|
+
* @public
|
|
287
|
+
* @param {Quat} qRot - Rotation quaternion.
|
|
288
|
+
*/
|
|
289
|
+
setRotation(qRot) {
|
|
290
|
+
this._qRot.copy(qRot);
|
|
291
|
+
this._qRot.mulVec3Res(LOCAL_FORWARD, this._direction).normalize();
|
|
292
|
+
this.updateRotation();
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Returns orientation quaternion.
|
|
296
|
+
* @public
|
|
297
|
+
* @returns {Quat}
|
|
298
|
+
*/
|
|
299
|
+
getRotation() {
|
|
300
|
+
return this._qRot;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Update object rotation
|
|
304
|
+
*/
|
|
243
305
|
updateRotation() {
|
|
244
|
-
|
|
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
|
-
}
|
|
306
|
+
this._handler && this._handler.setQRotArr(this._tagData, this._tagDataIndex, this._qRot);
|
|
253
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Returns object direction
|
|
310
|
+
* @publcu
|
|
311
|
+
* @returns {Vec3}
|
|
312
|
+
*/
|
|
254
313
|
getDirection() {
|
|
255
314
|
return this._direction.clone();
|
|
256
315
|
}
|
|
257
316
|
}
|
|
317
|
+
GeoObject.__counter__ = 0;
|
|
258
318
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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:
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|