@openglobus/og 0.14.10 → 0.15.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 (140) hide show
  1. package/css/og.css +378 -275
  2. package/dist/@openglobus/og.css +1 -1
  3. package/dist/@openglobus/og.esm.js +2 -2
  4. package/dist/@openglobus/og.esm.js.map +1 -1
  5. package/dist/@openglobus/og.umd.js +2 -2
  6. package/dist/@openglobus/og.umd.js.map +1 -1
  7. package/package.json +18 -17
  8. package/src/og/Clock.js +218 -194
  9. package/src/og/Globe.js +5 -5
  10. package/src/og/Object3d.js +104 -145
  11. package/src/og/camera/Camera.js +31 -27
  12. package/src/og/camera/PlanetCamera.js +22 -14
  13. package/src/og/cons.js +107 -107
  14. package/src/og/control/Atmosphere.js +396 -0
  15. package/src/og/control/CompassButton.js +11 -18
  16. package/src/og/control/Control.js +187 -188
  17. package/src/og/control/GeoImageDragControl.js +84 -66
  18. package/src/og/control/LayerSwitcher.js +56 -138
  19. package/src/og/control/Lighting.js +314 -186
  20. package/src/og/control/MouseNavigation.js +2 -2
  21. package/src/og/control/RulerSwitcher.js +24 -19
  22. package/src/og/control/ScaleControl.js +30 -10
  23. package/src/og/control/SimpleSkyBackground.js +210 -0
  24. package/src/og/control/Sun.js +2 -0
  25. package/src/og/control/ZoomControl.js +30 -42
  26. package/src/og/control/index.js +6 -0
  27. package/src/og/control/ruler/RulerScene.js +5 -23
  28. package/src/og/control/selection/Selection.js +99 -0
  29. package/src/og/control/selection/SelectionScene.js +350 -0
  30. package/src/og/control/timeline/TimelineControl.js +99 -0
  31. package/src/og/control/timeline/TimelineModel.js +133 -0
  32. package/src/og/control/timeline/TimelineView.js +449 -0
  33. package/src/og/control/timeline/timelineUtils.js +132 -0
  34. package/src/og/ellipsoid/Ellipsoid.js +120 -93
  35. package/src/og/ellipsoid/wgs84.js +13 -13
  36. package/src/og/entity/Entity.js +36 -9
  37. package/src/og/entity/EntityCollection.js +0 -2
  38. package/src/og/entity/GeoObject.js +72 -56
  39. package/src/og/entity/GeoObjectHandler.js +487 -656
  40. package/src/og/entity/GeometryHandler.js +1341 -1337
  41. package/src/og/entity/Polyline.js +0 -16
  42. package/src/og/entity/Ray.js +0 -10
  43. package/src/og/entity/RayHandler.js +3 -44
  44. package/src/og/entity/Strip.js +1 -6
  45. package/src/og/index.js +10 -6
  46. package/src/og/input/input.js +3 -1
  47. package/src/og/layer/CanvasTiles.js +39 -34
  48. package/src/og/layer/Layer.js +69 -9
  49. package/src/og/layer/Material.js +1 -8
  50. package/src/og/layer/WMS.js +16 -5
  51. package/src/og/light/LightSource.js +2 -0
  52. package/src/og/math/Line3.js +140 -139
  53. package/src/og/math/Plane.js +118 -117
  54. package/src/og/math/Ray.js +242 -239
  55. package/src/og/math/Vec3.js +56 -37
  56. package/src/og/math/Vec4.js +3 -4
  57. package/src/og/math.js +21 -21
  58. package/src/og/quadTree/Node.js +5 -4
  59. package/src/og/quadTree/index.js +12 -0
  60. package/src/og/renderer/Renderer.js +64 -37
  61. package/src/og/renderer/RendererEvents.js +1071 -1065
  62. package/src/og/scene/Planet.js +352 -172
  63. package/src/og/scene/RenderNode.js +27 -12
  64. package/src/og/segment/Segment.js +0 -5
  65. package/src/og/shaders/atmos.js +332 -0
  66. package/src/og/shaders/drawnode.js +475 -109
  67. package/src/og/shaders/geoObject.js +96 -51
  68. package/src/og/shaders/polyline.js +212 -17
  69. package/src/og/shaders/ray.js +13 -6
  70. package/src/og/shaders/toneMapping.js +5 -5
  71. package/src/og/shaders/utils.js +88 -0
  72. package/src/og/terrain/GlobusTerrain.js +5 -4
  73. package/src/og/terrain/MapboxTerrain.js +231 -52
  74. package/src/og/ui/Button.js +106 -0
  75. package/src/og/ui/ButtonGroup.js +57 -0
  76. package/src/og/ui/Dialog.js +242 -0
  77. package/src/og/ui/Slider.js +144 -0
  78. package/src/og/ui/ToggleButton.js +51 -0
  79. package/src/og/{control → ui}/UIhelpers.js +11 -2
  80. package/src/og/ui/View.js +190 -0
  81. package/src/og/utils/shared.js +960 -942
  82. package/src/og/webgl/Framebuffer.js +308 -387
  83. package/src/og/webgl/Handler.js +90 -30
  84. package/src/og/webgl/Multisample.js +8 -0
  85. package/types/Clock.d.ts +7 -2
  86. package/types/Object3d.d.ts +14 -3
  87. package/types/camera/Camera.d.ts +18 -17
  88. package/types/camera/PlanetCamera.d.ts +3 -1
  89. package/types/control/Atmosphere.d.ts +15 -0
  90. package/types/control/CompassButton.d.ts +1 -2
  91. package/types/control/GeoImageDragControl.d.ts +7 -1
  92. package/types/control/LayerSwitcher.d.ts +5 -6
  93. package/types/control/Lighting.d.ts +32 -7
  94. package/types/control/ScaleControl.d.ts +2 -1
  95. package/types/control/SimpleSkyBackground.d.ts +15 -0
  96. package/types/control/ZoomControl.d.ts +0 -1
  97. package/types/control/index.d.ts +4 -1
  98. package/types/control/ruler/RulerScene.d.ts +0 -1
  99. package/types/control/selection/Selection.d.ts +49 -0
  100. package/types/control/selection/SelectionScene.d.ts +34 -0
  101. package/types/ellipsoid/Ellipsoid.d.ts +3 -2
  102. package/types/entity/Entity.d.ts +8 -0
  103. package/types/entity/GeoObject.d.ts +28 -22
  104. package/types/entity/GeoObjectHandler.d.ts +16 -56
  105. package/types/entity/Ray.d.ts +0 -3
  106. package/types/entity/RayHandler.d.ts +0 -4
  107. package/types/index.d.ts +7 -5
  108. package/types/input/input.d.ts +2 -0
  109. package/types/layer/CanvasTiles.d.ts +1 -0
  110. package/types/layer/Layer.d.ts +9 -0
  111. package/types/layer/WMS.d.ts +7 -3
  112. package/types/math/Plane.d.ts +1 -1
  113. package/types/math/Vec3.d.ts +19 -16
  114. package/types/math/Vec4.d.ts +2 -3
  115. package/types/math.d.ts +20 -20
  116. package/types/quadTree/index.d.ts +10 -0
  117. package/types/renderer/Renderer.d.ts +11 -37
  118. package/types/scene/Planet.d.ts +27 -1
  119. package/types/scene/RenderNode.d.ts +2 -1
  120. package/types/segment/Segment.d.ts +1 -1
  121. package/types/shaders/atmos.d.ts +4 -0
  122. package/types/shaders/drawnode.d.ts +3 -2
  123. package/types/shaders/utils.d.ts +1 -0
  124. package/types/terrain/GlobusTerrain.d.ts +1 -1
  125. package/types/terrain/MapboxTerrain.d.ts +2 -1
  126. package/types/ui/Button.d.ts +21 -0
  127. package/types/ui/Dialog.d.ts +41 -0
  128. package/types/ui/Slider.d.ts +30 -0
  129. package/types/ui/ToggleButton.d.ts +10 -0
  130. package/types/{control → ui}/UIhelpers.d.ts +1 -1
  131. package/types/ui/View.d.ts +32 -0
  132. package/types/utils/shared.d.ts +16 -14
  133. package/types/webgl/Framebuffer.d.ts +2 -5
  134. package/types/webgl/Handler.d.ts +15 -10
  135. package/types/webgl/Multisample.d.ts +2 -0
  136. package/src/og/ajax.js +0 -204
  137. package/src/og/entity/Object3d.js +0 -504
  138. package/src/og/utils/quadTreeType.js +0 -11
  139. package/types/ajax.d.ts +0 -24
  140. package/types/utils/quadTreeType.d.ts +0 -8
package/src/og/ajax.js DELETED
@@ -1,204 +0,0 @@
1
- /**
2
- * @module og/ajax
3
- */
4
-
5
- "use strict";
6
-
7
- /**
8
- * Ajax parameters.
9
- * @namespace og.ajax
10
- */
11
- const ajax = {
12
- /**
13
- * Ajax ready state result.
14
- * @enum
15
- */
16
- ReadyState: {
17
- Uninitialized: 0,
18
- Loading: 1,
19
- Loaded: 2,
20
- Interactive: 3,
21
- Complete: 4
22
- },
23
- /**
24
- * Ajax status code.
25
- * @enum
26
- */
27
- Status: {
28
- OK: 200,
29
- Created: 201,
30
- Accepted: 202,
31
- NoContent: 204,
32
- BadRequest: 400,
33
- Forbidden: 403,
34
- NotFound: 404,
35
- Gone: 410,
36
- ServerError: 500
37
- },
38
- /**
39
- * Ajax query method.
40
- * @enum
41
- */
42
- Method: {
43
- Get: "GET",
44
- Post: "POST"
45
- },
46
- /**
47
- * Ajax query type is asynchronous.
48
- * @type {boolean}
49
- */
50
- Asynchronous: true,
51
- /**
52
- * Ajax query type is synchronous.
53
- * @type {boolean}
54
- */
55
- Synchronous: false
56
- };
57
-
58
- /**
59
- * Xhr object that returned by ajax query.
60
- * @class
61
- * @param {Object} xhr - Current ActiveXObject object.
62
- */
63
- const Xhr = function (xhr) {
64
- /**
65
- * ActiveXObject object.
66
- * @private
67
- * @type {Object}
68
- */
69
- var _xhr = xhr;
70
-
71
- /**
72
- * Aborts current ajax.
73
- * @public
74
- */
75
- this.abort = function () {
76
- _xhr.aborted = true;
77
- _xhr.abort();
78
- };
79
- };
80
-
81
- const defaultParams = {
82
- type: ajax.Method.Get,
83
- async: ajax.Asynchronous,
84
- data: null,
85
- sender: null,
86
- responseType: "text"
87
- };
88
-
89
- /**
90
- * Send an ajax request.
91
- * @function
92
- * @param {string} url - Url path.
93
- * @param {Object} [params] - Ajax parameters:
94
- * @param {ajax.Method|string} [params.type] - 'POST' or 'GET' ajax method. 'GET' is default.
95
- * @param {boolean} [params.async] - Asynchronous ajax flag. True is default.
96
- * @param {Object} [params.data] - Qery data.
97
- * @param {Object} [params.sender] - Sender object, that success callback binded with. ActiveXObject is default.
98
- * @param {string} [params.responseType] - Responce data type. Culd be 'text', 'json', 'jsonp', 'html'. 'text' is default.
99
- * @param {ajax.Xhr~successCallback} [params.success] - The callback that handles the success response.
100
- * @param {ajax.Xhr~errorCallback} [params.error] - The callback that handles the failed response.
101
- * @param {ajax.Xhr~abortCallback} [params.abort] - The callback that handles aborted requests.
102
- * @returns {ajax.Xhr} - Returns object that could be aborted.
103
- */
104
- ajax.request = function (url, params) {
105
- params = params || {};
106
-
107
- var p = {},
108
- i;
109
-
110
- for (i in defaultParams) {
111
- p[i] = defaultParams[i];
112
- }
113
-
114
- for (i in params) {
115
- p[i] = params[i];
116
- }
117
-
118
- p.data = params.data;
119
-
120
- var xhr = new XMLHttpRequest();
121
-
122
- var customXhr = new Xhr(xhr);
123
-
124
- var body = null,
125
- d;
126
-
127
- if (p.type === ajax.Method.Post) {
128
- if (p.data) {
129
- body = "";
130
- for (let key in p.data) {
131
- d = p.data[key];
132
- body +=
133
- key +
134
- "=" +
135
- encodeURIComponent(d instanceof Object ? JSON.stringify(d) : d) +
136
- "&";
137
- }
138
- body = body.slice(0, -1);
139
- }
140
- xhr.open(p.type, url, p.async);
141
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
142
- } else if (p.data) {
143
- var tail = "?";
144
- for (let key in p.data) {
145
- d = p.data[key];
146
- tail +=
147
- key + "=" + encodeURIComponent(d instanceof Object ? JSON.stringify(d) : d) + "&";
148
- }
149
- tail = tail.slice(0, -1);
150
- xhr.open(p.type, url + tail, p.async);
151
- } else {
152
- xhr.open(p.type, url, p.async);
153
- }
154
-
155
- if (p.async) {
156
- xhr.responseType = p.responseType;
157
- }
158
-
159
- xhr.overrideMimeType("text/plain");
160
-
161
- xhr.onreadystatechange = function () {
162
- if (xhr.readyState === ajax.ReadyState.Complete) {
163
- if (xhr.status === ajax.Status.OK) {
164
- if (params.success) {
165
- /**
166
- * Success callback.
167
- * @callback ajax.Xhr~successCallback
168
- * @param {Object} Response data
169
- */
170
- params.success.call(params.sender || customXhr, xhr.response);
171
- }
172
- } else if (xhr.aborted) {
173
- /**
174
- * Abort callback.
175
- * @callback ajax.Xhr~abortCallback
176
- * @param {Object} Response data
177
- * @param {Object} Status object
178
- */
179
- params.abort &&
180
- params.abort.call(params.sender || customXhr, xhr.response, xhr.status);
181
- } else {
182
- /**
183
- * Error callback.
184
- * @callback ajax.Xhr~errorCallback
185
- * @param {Object} Response data
186
- * @param {Object} Status object
187
- */
188
- params.error &&
189
- params.error.call(params.sender || customXhr, xhr.response, xhr.status);
190
- }
191
- delete xhr["onreadystatechange"];
192
- xhr.onreadystatechange = null;
193
- xhr = null;
194
- } else {
195
- // still loading
196
- }
197
- };
198
-
199
- xhr.send(body);
200
-
201
- return customXhr;
202
- };
203
-
204
- export { ajax };
@@ -1,504 +0,0 @@
1
- /* eslint-disable no-param-reassign */
2
- "use strict";
3
-
4
- import { htmlColorToFloat32Array } from "../utils/shared.js";
5
- import { Vec3 } from "../math/Vec3.js";
6
-
7
- function getColor(color) {
8
- if (color instanceof Array) {
9
- return color;
10
- } else if (typeof color === "string") {
11
- return htmlColorToFloat32Array(color);
12
- }
13
- return [1.0, 1.0, 1.0, 1.0];
14
- }
15
-
16
- class Object3d {
17
- constructor(data) {
18
- this._name = data.name || "noname";
19
- this._vertices = data.vertices || [];
20
- this._texCoords = [];
21
-
22
- this.color = getColor(data.color);
23
-
24
- if (data.scale) {
25
- Object3d.scale(this._vertices, data.scale);
26
- }
27
-
28
- if (data.indexes) {
29
- this._indexes = data.indexes || [];
30
- this._normals = data.normals || [];
31
- } else {
32
- this._normals = Object3d.getNormals(this._vertices);
33
- }
34
- }
35
-
36
- get name() {
37
- return this._name;
38
- }
39
-
40
- get vertices() {
41
- return this._vertices;
42
- }
43
-
44
- get normals() {
45
- return this._normals;
46
- }
47
-
48
- get indexes() {
49
- return this._indexes;
50
- }
51
-
52
- get indices() {
53
- return this._indexes;
54
- }
55
-
56
- static scale(vertices, s) {
57
- for (let i = 0; i < vertices.length; i++) {
58
- vertices[i] *= s;
59
- }
60
- }
61
-
62
- static centroid(vertices) {
63
- let minX = 1000.0,
64
- minY = 1000.0,
65
- minZ = 1000.0,
66
- maxX = -1000.0,
67
- maxY = -1000.0,
68
- maxZ = -1000.0;
69
-
70
- for (let i = 0; i < vertices.length; i += 3) {
71
- let x = vertices[i],
72
- y = vertices[i + 1],
73
- z = vertices[i + 2];
74
- if (x < minX) minX = x;
75
- if (y < minY) minY = y;
76
- if (z < minZ) minZ = z;
77
- if (x > maxX) maxX = x;
78
- if (y > maxY) maxY = y;
79
- if (z > maxZ) maxZ = z;
80
- }
81
-
82
- return [minX + (maxX - minX) * 0.5, minY + (maxY - minY) * 0.5, minZ + (maxZ - minZ) * 0.5];
83
- }
84
-
85
- static translate(vertices, v) {
86
- for (let i = 0; i < vertices.length; i += 3) {
87
- vertices[i] -= v[0];
88
- vertices[i + 1] -= v[1];
89
- vertices[i + 2] -= v[2];
90
- }
91
- }
92
-
93
- static getNormals(vertices) {
94
- let res = new Array(vertices.length);
95
-
96
- for (var i = 0; i < vertices.length; i += 9) {
97
- let t03 = i,
98
- t13 = i + 3,
99
- t23 = i + 6,
100
- v0_x = vertices[t03],
101
- v0_y = vertices[t03 + 1],
102
- v0_z = vertices[t03 + 2],
103
- v1_x = vertices[t13],
104
- v1_y = vertices[t13 + 1],
105
- v1_z = vertices[t13 + 2],
106
- v2_x = vertices[t23],
107
- v2_y = vertices[t23 + 1],
108
- v2_z = vertices[t23 + 2],
109
- vv0_x = v1_x - v0_x,
110
- vv0_y = v1_y - v0_y,
111
- vv0_z = v1_z - v0_z,
112
- vv1_x = v2_x - v0_x,
113
- vv1_y = v2_y - v0_y,
114
- vv1_z = v2_z - v0_z,
115
- n_x = vv0_y * vv1_z - vv0_z * vv1_y,
116
- n_y = vv0_z * vv1_x - vv0_x * vv1_z,
117
- n_z = vv0_x * vv1_y - vv0_y * vv1_x;
118
-
119
- let l = Math.sqrt(n_x * n_x + n_y * n_y + n_z * n_z);
120
-
121
- n_x /= l;
122
- n_y /= l;
123
- n_z /= l;
124
-
125
- res[t03] = n_x;
126
- res[t03 + 1] = n_y;
127
- res[t03 + 2] = n_z;
128
-
129
- res[t13] = n_x;
130
- res[t13 + 1] = n_y;
131
- res[t13 + 2] = n_z;
132
-
133
- res[t23] = n_x;
134
- res[t23 + 1] = n_y;
135
- res[t23 + 2] = n_z;
136
- }
137
-
138
- return res;
139
- }
140
-
141
- static createSphere(
142
- lonBands = 16,
143
- latBands = 16,
144
- radius = 1.0,
145
- offsetX = 0,
146
- offsetY = 0,
147
- offsetZ = 0
148
- ) {
149
- let vertices = [],
150
- indexes = [],
151
- normals = [];
152
-
153
- for (let latNumber = 0; latNumber <= latBands; latNumber++) {
154
- var theta = (latNumber * Math.PI) / latBands;
155
- var sinTheta = Math.sin(theta);
156
- var cosTheta = Math.cos(theta);
157
-
158
- for (let longNumber = 0; longNumber <= lonBands; longNumber++) {
159
- var phi = (longNumber * 2 * Math.PI) / lonBands;
160
- var sinPhi = Math.sin(phi);
161
- var cosPhi = Math.cos(phi);
162
- var x = cosPhi * sinTheta + offsetX;
163
- var y = cosTheta + offsetY;
164
- var z = sinPhi * sinTheta + offsetZ;
165
- //var u = 1 - (longNumber / lonBands);
166
- //var v = latNumber / latBands;
167
- normals.push(x);
168
- normals.push(y);
169
- normals.push(z);
170
- //texCoords.push(u);
171
- //texCoords.push(v);
172
- vertices.push(radius * x);
173
- vertices.push(radius * y);
174
- vertices.push(radius * z);
175
- }
176
- }
177
-
178
- for (let latNumber = 0; latNumber < latBands; latNumber++) {
179
- for (let longNumber = 0; longNumber < lonBands; longNumber++) {
180
- var first = latNumber * (lonBands + 1) + longNumber;
181
- var second = first + lonBands + 1;
182
-
183
- indexes.push(first);
184
- indexes.push(first + 1);
185
- indexes.push(second);
186
-
187
- indexes.push(second);
188
- indexes.push(first + 1);
189
- indexes.push(second + 1);
190
- }
191
- }
192
-
193
- return new Object3d({
194
- vertices: vertices,
195
- normals: normals,
196
- indexes: indexes
197
- });
198
- }
199
-
200
- static createDisc(
201
- radius = 1.0,
202
- height = 0.0,
203
- radialSegments = 8,
204
- isTop = true,
205
- startIndex = 0,
206
- offsetX = 0,
207
- offsetY,
208
- offsetZ = 0
209
- ) {
210
- let vertices = [],
211
- indexes = [],
212
- normals = [];
213
-
214
- let thetaStart = 0.0,
215
- thetaLength = Math.PI * 2;
216
-
217
- let sign = isTop === true ? 1.0 : -1.0;
218
-
219
- let centerIndexStart = startIndex;
220
-
221
- for (let x = 1; x <= radialSegments; x++) {
222
- vertices.push(0 + offsetX, height * sign + offsetY, 0 + offsetZ);
223
- normals.push(0, sign, 0);
224
- //texCoords.push(0.5, 0.5);
225
- startIndex++;
226
- }
227
-
228
- let centerIndexEnd = startIndex;
229
-
230
- for (let x = 0; x <= radialSegments; x++) {
231
- let u = x / radialSegments;
232
- let theta = u * thetaLength + thetaStart;
233
-
234
- let cosTheta = Math.cos(theta);
235
- let sinTheta = Math.sin(theta);
236
-
237
- vertices.push(
238
- radius * sinTheta + offsetX,
239
- height * sign + offsetY,
240
- radius * cosTheta + offsetZ
241
- );
242
- normals.push(0, sign, 0);
243
- //texCoords.push((cosTheta * 0.5) + 0.5, (sinTheta * 0.5 * sign) + 0.5);
244
-
245
- startIndex++;
246
- }
247
-
248
- for (let x = 0; x < radialSegments; x++) {
249
- let c = centerIndexStart + x,
250
- i = centerIndexEnd + x;
251
- if (isTop === true) {
252
- indexes.push(i, i + 1, c);
253
- } else {
254
- indexes.push(i + 1, i, c);
255
- }
256
- }
257
-
258
- return new Object3d({
259
- vertices: vertices,
260
- normals: normals,
261
- indexes: indexes
262
- });
263
- }
264
-
265
- static createCylinder(
266
- radiusTop = 1.0,
267
- radiusBottom = 1.0,
268
- height = 1.0,
269
- radialSegments = 32,
270
- heightSegments = 1.0,
271
- isTop = true,
272
- isBottom = true,
273
- offsetX = 0,
274
- offsetY = 0,
275
- offsetZ = 0
276
- ) {
277
- let vertices = [],
278
- indexes = [],
279
- normals = [];
280
-
281
- let thetaStart = 0.0,
282
- thetaLength = Math.PI * 2;
283
-
284
- let index = 0;
285
- let indexArray = [];
286
-
287
- let normal = new Vec3();
288
-
289
- var slope = (radiusBottom - radiusTop) / height;
290
-
291
- for (let y = 0; y <= heightSegments; y++) {
292
- let indexRow = [];
293
-
294
- let v = y / heightSegments;
295
-
296
- let radius = v * (radiusBottom - radiusTop) + radiusTop;
297
-
298
- for (let x = 0; x <= radialSegments; x++) {
299
- let u = x / radialSegments;
300
-
301
- let theta = u * thetaLength + thetaStart;
302
-
303
- let sinTheta = Math.sin(theta),
304
- cosTheta = Math.cos(theta);
305
-
306
- vertices.push(
307
- radius * sinTheta + offsetX,
308
- -v * height + height + offsetY,
309
- radius * cosTheta + offsetZ
310
- );
311
-
312
- normal.set(sinTheta, slope, cosTheta).normalize();
313
- normals.push(normal.x, normal.y, normal.z);
314
-
315
- //texCoords.push(u, 1 - v);
316
-
317
- indexRow.push(index++);
318
- }
319
- indexArray.push(indexRow);
320
- }
321
-
322
- for (let x = 0; x < radialSegments; x++) {
323
- for (let y = 0; y < heightSegments; y++) {
324
- let a = indexArray[y][x],
325
- b = indexArray[y + 1][x],
326
- c = indexArray[y + 1][x + 1],
327
- d = indexArray[y][x + 1];
328
-
329
- indexes.push(a, b, d);
330
- indexes.push(b, c, d);
331
- }
332
- }
333
-
334
- if (radiusTop !== 0.0 && isTop) {
335
- let cap = Object3d.createDisc(
336
- radiusTop,
337
- height,
338
- radialSegments,
339
- true,
340
- index,
341
- offsetX,
342
- offsetY,
343
- offsetZ
344
- );
345
- vertices.push(...cap.vertices);
346
- normals.push(...cap.normals);
347
- indexes.push(...cap.indexes);
348
- }
349
-
350
- if (radiusBottom !== 0.0 && isBottom) {
351
- let cap = Object3d.createDisc(
352
- radiusBottom,
353
- 0,
354
- radialSegments,
355
- false,
356
- index + (isTop ? 1 + 2 * radialSegments : 0),
357
- offsetX,
358
- offsetY,
359
- offsetZ
360
- );
361
- vertices.push(...cap.vertices);
362
- normals.push(...cap.normals);
363
- indexes.push(...cap.indexes);
364
- }
365
-
366
- return new Object3d({
367
- vertices: vertices,
368
- normals: normals,
369
- indexes: indexes
370
- });
371
- }
372
-
373
- static createCube(length = 1, height = 1, depth = 1, xOffset = 0, yOffset = 0, zOffset = 0) {
374
- let l = length * 0.5 + xOffset,
375
- h = height * 0.5 + yOffset,
376
- d = depth * 0.5 + zOffset;
377
-
378
- return new Object3d({
379
- vertices: [
380
- //bottom
381
- -l,
382
- -h,
383
- d,
384
- l,
385
- -h,
386
- -d,
387
- l,
388
- -h,
389
- d,
390
- -l,
391
- -h,
392
- d,
393
- -l,
394
- -h,
395
- -d,
396
- l,
397
- -h,
398
- -d,
399
-
400
- //top
401
- -l,
402
- h,
403
- d,
404
- l,
405
- h,
406
- d,
407
- l,
408
- h,
409
- -d,
410
- -l,
411
- h,
412
- d,
413
- l,
414
- h,
415
- -d,
416
- -l,
417
- h,
418
- -d,
419
-
420
- //front
421
- -l,
422
- -h,
423
- d,
424
- l,
425
- -h,
426
- d,
427
- -l,
428
- h,
429
- d,
430
- -l,
431
- h,
432
- d,
433
- l,
434
- -h,
435
- d,
436
- l,
437
- h,
438
- d,
439
-
440
- //back
441
- -l,
442
- -h,
443
- -d,
444
- -l,
445
- h,
446
- -d,
447
- l,
448
- -h,
449
- -d,
450
- -l,
451
- h,
452
- -d,
453
- l,
454
- h,
455
- -d,
456
- l,
457
- -h,
458
- -d,
459
-
460
- //left
461
- l,
462
- -h,
463
- d,
464
- l,
465
- -h,
466
- -d,
467
- l,
468
- h,
469
- d,
470
- l,
471
- h,
472
- d,
473
- l,
474
- -h,
475
- -d,
476
- l,
477
- h,
478
- -d,
479
-
480
- //right
481
- -l,
482
- -h,
483
- d,
484
- -l,
485
- h,
486
- d,
487
- -l,
488
- -h,
489
- -d,
490
- -l,
491
- h,
492
- d,
493
- -l,
494
- h,
495
- -d,
496
- -l,
497
- -h,
498
- -d
499
- ]
500
- });
501
- }
502
- }
503
-
504
- export { Object3d };
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- import { EarthQuadTreeStrategy } from "../quadTree/EarthQuadTreeStrategy.js";
4
- import { MarsQuadTreeStrategy } from "../quadTree/MarsQuadTreeStrategy.js";
5
- import { Wgs84QuadTreeStrategy } from "../quadTree/Wgs84QuadTreeStrategy.js";
6
-
7
- export const quadTreeStrategyType = {
8
- earth: EarthQuadTreeStrategy,
9
- mars: MarsQuadTreeStrategy,
10
- wgs84: Wgs84QuadTreeStrategy
11
- }