@openglobus/og 0.13.7 → 0.13.10
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/README.md +1 -1
- package/css/og.css +388 -129
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +20 -19
- package/src/og/Globe.js +15 -16
- package/src/og/Object3d.js +417 -0
- package/src/og/arial.js +1705 -1703
- package/src/og/camera/Camera.js +640 -640
- package/src/og/control/EarthCoordinates.js +1 -1
- package/src/og/control/GeoImageDragControl.js +102 -75
- package/src/og/control/LayerAnimation.js +383 -0
- package/src/og/control/LayerSwitcher.js +506 -159
- package/src/og/control/Lighting.js +27 -27
- package/src/og/control/MouseNavigation.js +460 -460
- package/src/og/control/RulerSwitcher.js +69 -0
- package/src/og/control/Sun.js +170 -170
- package/src/og/control/UIhelpers.js +146 -0
- package/src/og/control/ZoomControl.js +0 -2
- package/src/og/control/index.js +5 -1
- package/src/og/control/ruler/Ruler.js +43 -0
- package/src/og/control/ruler/RulerScene.js +374 -0
- package/src/og/control/visibleExtent/Segment.js +3 -5
- package/src/og/ellipsoid/Ellipsoid.js +19 -0
- package/src/og/ellipsoid/wgs84.js +1 -1
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/GeoObject.js +1 -1
- package/src/og/entity/LabelHandler.js +6 -2
- package/src/og/entity/LabelWorker.js +38 -53
- package/src/og/layer/BaseGeoImage.js +347 -312
- package/src/og/layer/CanvasTiles.js +312 -290
- package/src/og/layer/GeoImage.js +222 -214
- package/src/og/layer/GeoVideo.js +291 -291
- package/src/og/layer/Layer.js +94 -70
- package/src/og/layer/Material.js +109 -109
- package/src/og/layer/Vector.js +81 -14
- package/src/og/layer/XYZ.js +23 -11
- package/src/og/light/LightSource.js +364 -363
- package/src/og/math/Vec3.js +1 -1
- package/src/og/math.js +6 -6
- package/src/og/quadTree/Node.js +8 -6
- package/src/og/renderer/Renderer.js +2 -3
- package/src/og/res/images.js +0 -2
- package/src/og/scene/Planet.js +106 -44
- package/src/og/segment/Segment.js +34 -64
- package/src/og/segment/Slice.js +1 -1
- package/src/og/shaders/drawnode.js +1 -1
- package/src/og/shaders/label.js +30 -42
- package/src/og/terrain/GlobusTerrain.js +31 -20
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/BaseWorker.js +46 -0
- package/src/og/utils/FontAtlas.js +1 -2
- package/src/og/utils/GeoImageCreator.js +164 -161
- package/src/og/utils/Loader.js +187 -153
- package/src/og/utils/NormalMapCreator.js +403 -412
- package/src/og/utils/PlainSegmentWorker.js +29 -55
- package/src/og/utils/TerrainWorker.js +572 -589
- package/src/og/utils/VectorTileCreator.js +1 -1
- package/src/og/utils/functionComposition.js +13 -0
- package/src/og/webgl/Handler.js +42 -41
- package/src/og/webgl/ProgramController.js +143 -143
- package/types/Object3d.d.ts +22 -0
- package/types/arial.d.ts +1 -0
- package/types/camera/PlanetCamera.d.ts +4 -0
- package/types/control/GeoImageDragControl.d.ts +2 -0
- package/types/control/LayerAnimation.d.ts +73 -0
- package/types/control/LayerSwitcher.d.ts +55 -11
- package/types/control/MouseNavigation.d.ts +1 -0
- package/types/control/MouseWheelZoomControl.d.ts +1 -0
- package/types/control/Sun.d.ts +2 -1
- package/types/control/TouchNavigation.d.ts +1 -0
- package/types/control/UIhelpers.d.ts +13 -0
- package/types/control/index.d.ts +3 -1
- package/types/control/ruler/Ruler.d.ts +13 -0
- package/types/control/ruler/RulerScene.d.ts +48 -0
- package/types/ellipsoid/Ellipsoid.d.ts +8 -0
- package/types/entity/LabelHandler.d.ts +2 -0
- package/types/entity/LabelWorker.d.ts +5 -7
- package/types/layer/BaseGeoImage.d.ts +9 -1
- package/types/layer/CanvasTiles.d.ts +5 -1
- package/types/layer/GeoImage.d.ts +1 -0
- package/types/layer/GeoTexture2d.d.ts +1 -0
- package/types/layer/Layer.d.ts +28 -32
- package/types/layer/Vector.d.ts +9 -0
- package/types/layer/WMS.d.ts +1 -0
- package/types/layer/XYZ.d.ts +8 -5
- package/types/math.d.ts +2 -2
- package/types/quadTree/EntityCollectionNode.d.ts +7 -0
- package/types/quadTree/Node.d.ts +1 -2
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +16 -0
- package/types/res/images.d.ts +0 -1
- package/types/scene/Planet.d.ts +21 -6
- package/types/segment/SegmentLonLat.d.ts +2 -0
- package/types/terrain/BilTerrain.d.ts +6 -0
- package/types/terrain/GlobusTerrain.d.ts +7 -0
- package/types/terrain/MapboxTerrain.d.ts +8 -0
- package/types/utils/BaseWorker.d.ts +14 -0
- package/types/utils/Loader.d.ts +4 -1
- package/types/utils/PlainSegmentWorker.d.ts +4 -6
- package/types/utils/TerrainWorker.d.ts +4 -6
- package/types/utils/functionComposition.d.ts +5 -0
- package/types/webgl/Handler.d.ts +4 -1
package/src/og/layer/GeoVideo.js
CHANGED
|
@@ -1,291 +1,291 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/layer/GeoVideo
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Used to load and display a video stream by specific corners coordinates on the globe, implements og.layer.BaseGeoImage interface.
|
|
11
|
-
* @class
|
|
12
|
-
* @extends {BaseGeoImage}
|
|
13
|
-
*/
|
|
14
|
-
class GeoVideo extends BaseGeoImage {
|
|
15
|
-
constructor(name, options) {
|
|
16
|
-
super(name, options);
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @protected
|
|
20
|
-
* @const
|
|
21
|
-
* @type {Boolean}
|
|
22
|
-
*/
|
|
23
|
-
this._animate = true;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* HTML5 video element object.
|
|
27
|
-
* @private
|
|
28
|
-
* @type {Object}
|
|
29
|
-
*/
|
|
30
|
-
this._video = options.videoElement || null;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* VIdeo source url path.
|
|
34
|
-
* @private
|
|
35
|
-
* @type {String}
|
|
36
|
-
*/
|
|
37
|
-
this._src = options.src || null;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get instanceName() {
|
|
41
|
-
return "GeoVideo";
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Sets video source url path.
|
|
46
|
-
* @public
|
|
47
|
-
* @param {String} srs - Video url path.
|
|
48
|
-
*/
|
|
49
|
-
setSrc(src) {
|
|
50
|
-
this._planet && this._planet._geoImageCreator.remove(this);
|
|
51
|
-
this._src = src;
|
|
52
|
-
this._sourceReady = false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Sets HTML5 video object.
|
|
57
|
-
* @public
|
|
58
|
-
* @param {Object} video - HTML5 video element object.
|
|
59
|
-
*/
|
|
60
|
-
setVideoElement(video) {
|
|
61
|
-
this._planet && this._planet._geoImageCreator.remove(this);
|
|
62
|
-
this._video = video;
|
|
63
|
-
this._src = video.src;
|
|
64
|
-
this._sourceReady = false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Sets layer visibility.
|
|
69
|
-
* @public
|
|
70
|
-
* @param {boolean} visibility - Layer visibility.
|
|
71
|
-
*/
|
|
72
|
-
setVisibility(visibility) {
|
|
73
|
-
if (visibility != this._visibility) {
|
|
74
|
-
super.setVisibility(visibility);
|
|
75
|
-
|
|
76
|
-
// remove from creator
|
|
77
|
-
if (visibility) {
|
|
78
|
-
this._sourceReady && this._planet._geoImageCreator.add(this);
|
|
79
|
-
this._video && this._video.play();
|
|
80
|
-
} else {
|
|
81
|
-
this._sourceReady && this._planet._geoImageCreator.remove(this);
|
|
82
|
-
this._video && this._video.pause();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Creates or refresh source video GL texture.
|
|
89
|
-
* @virtual
|
|
90
|
-
* @protected
|
|
91
|
-
*/
|
|
92
|
-
_createSourceTexture() {
|
|
93
|
-
if (!this._sourceCreated) {
|
|
94
|
-
this._sourceTexture = this._planet.renderer.handler.
|
|
95
|
-
this._sourceCreated = true;
|
|
96
|
-
} else {
|
|
97
|
-
var gl = this._planet.renderer.handler.gl;
|
|
98
|
-
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
99
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @private
|
|
105
|
-
*/
|
|
106
|
-
_onCanPlay(video) {
|
|
107
|
-
this._frameWidth = video.videoWidth;
|
|
108
|
-
this._frameHeight = video.videoHeight;
|
|
109
|
-
video.width = video.videoWidth;
|
|
110
|
-
video.height = video.videoHeight;
|
|
111
|
-
video.play();
|
|
112
|
-
this._sourceReady = true;
|
|
113
|
-
this._planet._geoImageCreator.add(this);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @private
|
|
118
|
-
*/
|
|
119
|
-
_onError(video) {
|
|
120
|
-
var err = "unknown error";
|
|
121
|
-
switch (video.error.code) {
|
|
122
|
-
case 1:
|
|
123
|
-
err = "video loading aborted";
|
|
124
|
-
break;
|
|
125
|
-
case 2:
|
|
126
|
-
err = "network loading error";
|
|
127
|
-
break;
|
|
128
|
-
case 3:
|
|
129
|
-
err = "video decoding failed / corrupted data or unsupported codec";
|
|
130
|
-
break;
|
|
131
|
-
case 4:
|
|
132
|
-
err = "video not supported";
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
console.log("Error: " + err + " (errorcode=" + video.error.code + ")");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Loads planet segment material. In this case - GeoImage source video.
|
|
140
|
-
* @virtual
|
|
141
|
-
* @public
|
|
142
|
-
* @param {Material} material - GeoImage planet material.
|
|
143
|
-
*/
|
|
144
|
-
loadMaterial(material) {
|
|
145
|
-
material.isLoading = true;
|
|
146
|
-
this._creationProceeding = true;
|
|
147
|
-
if (!this._sourceReady && this._src) {
|
|
148
|
-
if (this._video) {
|
|
149
|
-
if (this._video.readyState === this._video.HAVE_ENOUGH_DATA) {
|
|
150
|
-
this._onCanPlay(this._video);
|
|
151
|
-
} else if (this._video.src) {
|
|
152
|
-
let that = this;
|
|
153
|
-
this._video.addEventListener("canplay", function (e) {
|
|
154
|
-
that._onCanPlay(this);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
this._video = document.createElement("video");
|
|
159
|
-
let that = this;
|
|
160
|
-
this._video.addEventListener("canplay", function () {
|
|
161
|
-
that._onCanPlay(this);
|
|
162
|
-
});
|
|
163
|
-
this._video.addEventListener("error", function () {
|
|
164
|
-
that._onError(this);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
this._video.autoplay = true;
|
|
168
|
-
this._video.loop = true;
|
|
169
|
-
this._video.src = this._src;
|
|
170
|
-
this._video.muted = "muted";
|
|
171
|
-
this._video.setAttribute("playsinline", "true");
|
|
172
|
-
this._video.setAttribute("webkit-playsinline", "true");
|
|
173
|
-
} else {
|
|
174
|
-
this._planet._geoImageCreator.add(this);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* @virtual
|
|
180
|
-
* @param {Material} material - GeoImage material.
|
|
181
|
-
*/
|
|
182
|
-
abortMaterialLoading(material) {
|
|
183
|
-
this._video && (this._video.src = "");
|
|
184
|
-
this._creationProceeding = false;
|
|
185
|
-
material.isLoading = false;
|
|
186
|
-
material.isReady = false;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
_renderingProjType1() {
|
|
190
|
-
var p = this._planet,
|
|
191
|
-
h = p.renderer.handler,
|
|
192
|
-
gl = h.gl,
|
|
193
|
-
creator = p._geoImageCreator;
|
|
194
|
-
|
|
195
|
-
this._refreshFrame && this._createFrame();
|
|
196
|
-
|
|
197
|
-
if (this._sourceCreated) {
|
|
198
|
-
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
199
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
|
|
200
|
-
} else {
|
|
201
|
-
this._sourceTexture = this._planet.renderer.handler.
|
|
202
|
-
this._sourceCreated = true;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
var f = creator._framebuffer;
|
|
206
|
-
f.setSize(this._frameWidth, this._frameHeight);
|
|
207
|
-
f.activate();
|
|
208
|
-
|
|
209
|
-
h.programs.geoImageTransform.activate();
|
|
210
|
-
var sh = h.programs.geoImageTransform._program;
|
|
211
|
-
var sha = sh.attributes,
|
|
212
|
-
shu = sh.uniforms;
|
|
213
|
-
|
|
214
|
-
gl.disable(gl.CULL_FACE);
|
|
215
|
-
|
|
216
|
-
f.bindOutputTexture(this._materialTexture);
|
|
217
|
-
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
218
|
-
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
219
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
220
|
-
|
|
221
|
-
gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
|
|
222
|
-
|
|
223
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
|
|
224
|
-
gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
225
|
-
gl.uniform4fv(shu.extentParams, this._extentMercParams);
|
|
226
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
227
|
-
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
228
|
-
gl.uniform1i(shu.sourceTexture, 0);
|
|
229
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
|
|
230
|
-
gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
231
|
-
f.deactivate();
|
|
232
|
-
|
|
233
|
-
gl.enable(gl.CULL_FACE);
|
|
234
|
-
|
|
235
|
-
this._ready = true;
|
|
236
|
-
|
|
237
|
-
this._creationProceeding = false;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
_renderingProjType0() {
|
|
241
|
-
var p = this._planet,
|
|
242
|
-
h = p.renderer.handler,
|
|
243
|
-
gl = h.gl,
|
|
244
|
-
creator = p._geoImageCreator;
|
|
245
|
-
|
|
246
|
-
this._refreshFrame && this._createFrame();
|
|
247
|
-
if (!this._sourceCreated) {
|
|
248
|
-
this._sourceTexture = this._planet.renderer.handler.
|
|
249
|
-
this._sourceCreated = true;
|
|
250
|
-
} else {
|
|
251
|
-
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
252
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
var f = creator._framebuffer;
|
|
256
|
-
f.setSize(this._frameWidth, this._frameHeight);
|
|
257
|
-
f.activate();
|
|
258
|
-
|
|
259
|
-
h.programs.geoImageTransform.activate();
|
|
260
|
-
var sh = h.programs.geoImageTransform._program;
|
|
261
|
-
var sha = sh.attributes,
|
|
262
|
-
shu = sh.uniforms;
|
|
263
|
-
|
|
264
|
-
gl.disable(gl.CULL_FACE);
|
|
265
|
-
|
|
266
|
-
f.bindOutputTexture(this._materialTexture);
|
|
267
|
-
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
268
|
-
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
269
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
270
|
-
|
|
271
|
-
gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
|
|
272
|
-
|
|
273
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
|
|
274
|
-
gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
275
|
-
gl.uniform4fv(shu.extentParams, this._extentWgs84Params);
|
|
276
|
-
gl.activeTexture(gl.TEXTURE0);
|
|
277
|
-
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
278
|
-
gl.uniform1i(shu.sourceTexture, 0);
|
|
279
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
|
|
280
|
-
gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
281
|
-
f.deactivate();
|
|
282
|
-
|
|
283
|
-
gl.enable(gl.CULL_FACE);
|
|
284
|
-
|
|
285
|
-
this._ready = true;
|
|
286
|
-
|
|
287
|
-
this._creationProceeding = false;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export { GeoVideo };
|
|
1
|
+
/**
|
|
2
|
+
* @module og/layer/GeoVideo
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Used to load and display a video stream by specific corners coordinates on the globe, implements og.layer.BaseGeoImage interface.
|
|
11
|
+
* @class
|
|
12
|
+
* @extends {BaseGeoImage}
|
|
13
|
+
*/
|
|
14
|
+
class GeoVideo extends BaseGeoImage {
|
|
15
|
+
constructor(name, options) {
|
|
16
|
+
super(name, options);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @protected
|
|
20
|
+
* @const
|
|
21
|
+
* @type {Boolean}
|
|
22
|
+
*/
|
|
23
|
+
this._animate = true;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* HTML5 video element object.
|
|
27
|
+
* @private
|
|
28
|
+
* @type {Object}
|
|
29
|
+
*/
|
|
30
|
+
this._video = options.videoElement || null;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* VIdeo source url path.
|
|
34
|
+
* @private
|
|
35
|
+
* @type {String}
|
|
36
|
+
*/
|
|
37
|
+
this._src = options.src || null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get instanceName() {
|
|
41
|
+
return "GeoVideo";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Sets video source url path.
|
|
46
|
+
* @public
|
|
47
|
+
* @param {String} srs - Video url path.
|
|
48
|
+
*/
|
|
49
|
+
setSrc(src) {
|
|
50
|
+
this._planet && this._planet._geoImageCreator.remove(this);
|
|
51
|
+
this._src = src;
|
|
52
|
+
this._sourceReady = false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Sets HTML5 video object.
|
|
57
|
+
* @public
|
|
58
|
+
* @param {Object} video - HTML5 video element object.
|
|
59
|
+
*/
|
|
60
|
+
setVideoElement(video) {
|
|
61
|
+
this._planet && this._planet._geoImageCreator.remove(this);
|
|
62
|
+
this._video = video;
|
|
63
|
+
this._src = video.src;
|
|
64
|
+
this._sourceReady = false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Sets layer visibility.
|
|
69
|
+
* @public
|
|
70
|
+
* @param {boolean} visibility - Layer visibility.
|
|
71
|
+
*/
|
|
72
|
+
setVisibility(visibility) {
|
|
73
|
+
if (visibility != this._visibility) {
|
|
74
|
+
super.setVisibility(visibility);
|
|
75
|
+
|
|
76
|
+
// remove from creator
|
|
77
|
+
if (visibility) {
|
|
78
|
+
this._sourceReady && this._planet._geoImageCreator.add(this);
|
|
79
|
+
this._video && this._video.play();
|
|
80
|
+
} else {
|
|
81
|
+
this._sourceReady && this._planet._geoImageCreator.remove(this);
|
|
82
|
+
this._video && this._video.pause();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Creates or refresh source video GL texture.
|
|
89
|
+
* @virtual
|
|
90
|
+
* @protected
|
|
91
|
+
*/
|
|
92
|
+
_createSourceTexture() {
|
|
93
|
+
if (!this._sourceCreated) {
|
|
94
|
+
this._sourceTexture = this._planet.renderer.handler.createTexture_n_webgl1(this._video);
|
|
95
|
+
this._sourceCreated = true;
|
|
96
|
+
} else {
|
|
97
|
+
var gl = this._planet.renderer.handler.gl;
|
|
98
|
+
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
99
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @private
|
|
105
|
+
*/
|
|
106
|
+
_onCanPlay(video) {
|
|
107
|
+
this._frameWidth = video.videoWidth;
|
|
108
|
+
this._frameHeight = video.videoHeight;
|
|
109
|
+
video.width = video.videoWidth;
|
|
110
|
+
video.height = video.videoHeight;
|
|
111
|
+
video.play();
|
|
112
|
+
this._sourceReady = true;
|
|
113
|
+
this._planet._geoImageCreator.add(this);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
_onError(video) {
|
|
120
|
+
var err = "unknown error";
|
|
121
|
+
switch (video.error.code) {
|
|
122
|
+
case 1:
|
|
123
|
+
err = "video loading aborted";
|
|
124
|
+
break;
|
|
125
|
+
case 2:
|
|
126
|
+
err = "network loading error";
|
|
127
|
+
break;
|
|
128
|
+
case 3:
|
|
129
|
+
err = "video decoding failed / corrupted data or unsupported codec";
|
|
130
|
+
break;
|
|
131
|
+
case 4:
|
|
132
|
+
err = "video not supported";
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
console.log("Error: " + err + " (errorcode=" + video.error.code + ")");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Loads planet segment material. In this case - GeoImage source video.
|
|
140
|
+
* @virtual
|
|
141
|
+
* @public
|
|
142
|
+
* @param {Material} material - GeoImage planet material.
|
|
143
|
+
*/
|
|
144
|
+
loadMaterial(material) {
|
|
145
|
+
material.isLoading = true;
|
|
146
|
+
this._creationProceeding = true;
|
|
147
|
+
if (!this._sourceReady && this._src) {
|
|
148
|
+
if (this._video) {
|
|
149
|
+
if (this._video.readyState === this._video.HAVE_ENOUGH_DATA) {
|
|
150
|
+
this._onCanPlay(this._video);
|
|
151
|
+
} else if (this._video.src) {
|
|
152
|
+
let that = this;
|
|
153
|
+
this._video.addEventListener("canplay", function (e) {
|
|
154
|
+
that._onCanPlay(this);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
this._video = document.createElement("video");
|
|
159
|
+
let that = this;
|
|
160
|
+
this._video.addEventListener("canplay", function () {
|
|
161
|
+
that._onCanPlay(this);
|
|
162
|
+
});
|
|
163
|
+
this._video.addEventListener("error", function () {
|
|
164
|
+
that._onError(this);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
this._video.autoplay = true;
|
|
168
|
+
this._video.loop = true;
|
|
169
|
+
this._video.src = this._src;
|
|
170
|
+
this._video.muted = "muted";
|
|
171
|
+
this._video.setAttribute("playsinline", "true");
|
|
172
|
+
this._video.setAttribute("webkit-playsinline", "true");
|
|
173
|
+
} else {
|
|
174
|
+
this._planet._geoImageCreator.add(this);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @virtual
|
|
180
|
+
* @param {Material} material - GeoImage material.
|
|
181
|
+
*/
|
|
182
|
+
abortMaterialLoading(material) {
|
|
183
|
+
this._video && (this._video.src = "");
|
|
184
|
+
this._creationProceeding = false;
|
|
185
|
+
material.isLoading = false;
|
|
186
|
+
material.isReady = false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
_renderingProjType1() {
|
|
190
|
+
var p = this._planet,
|
|
191
|
+
h = p.renderer.handler,
|
|
192
|
+
gl = h.gl,
|
|
193
|
+
creator = p._geoImageCreator;
|
|
194
|
+
|
|
195
|
+
this._refreshFrame && this._createFrame();
|
|
196
|
+
|
|
197
|
+
if (this._sourceCreated) {
|
|
198
|
+
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
199
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
|
|
200
|
+
} else {
|
|
201
|
+
this._sourceTexture = this._planet.renderer.handler.createTexture_n_webgl1(this._video);
|
|
202
|
+
this._sourceCreated = true;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
var f = creator._framebuffer;
|
|
206
|
+
f.setSize(this._frameWidth, this._frameHeight);
|
|
207
|
+
f.activate();
|
|
208
|
+
|
|
209
|
+
h.programs.geoImageTransform.activate();
|
|
210
|
+
var sh = h.programs.geoImageTransform._program;
|
|
211
|
+
var sha = sh.attributes,
|
|
212
|
+
shu = sh.uniforms;
|
|
213
|
+
|
|
214
|
+
gl.disable(gl.CULL_FACE);
|
|
215
|
+
|
|
216
|
+
f.bindOutputTexture(this._materialTexture);
|
|
217
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
218
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
219
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
220
|
+
|
|
221
|
+
gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
|
|
222
|
+
|
|
223
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
|
|
224
|
+
gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
225
|
+
gl.uniform4fv(shu.extentParams, this._extentMercParams);
|
|
226
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
227
|
+
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
228
|
+
gl.uniform1i(shu.sourceTexture, 0);
|
|
229
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
|
|
230
|
+
gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
231
|
+
f.deactivate();
|
|
232
|
+
|
|
233
|
+
gl.enable(gl.CULL_FACE);
|
|
234
|
+
|
|
235
|
+
this._ready = true;
|
|
236
|
+
|
|
237
|
+
this._creationProceeding = false;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
_renderingProjType0() {
|
|
241
|
+
var p = this._planet,
|
|
242
|
+
h = p.renderer.handler,
|
|
243
|
+
gl = h.gl,
|
|
244
|
+
creator = p._geoImageCreator;
|
|
245
|
+
|
|
246
|
+
this._refreshFrame && this._createFrame();
|
|
247
|
+
if (!this._sourceCreated) {
|
|
248
|
+
this._sourceTexture = this._planet.renderer.handler.createTexture_n_webgl1(this._video);
|
|
249
|
+
this._sourceCreated = true;
|
|
250
|
+
} else {
|
|
251
|
+
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
252
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
var f = creator._framebuffer;
|
|
256
|
+
f.setSize(this._frameWidth, this._frameHeight);
|
|
257
|
+
f.activate();
|
|
258
|
+
|
|
259
|
+
h.programs.geoImageTransform.activate();
|
|
260
|
+
var sh = h.programs.geoImageTransform._program;
|
|
261
|
+
var sha = sh.attributes,
|
|
262
|
+
shu = sh.uniforms;
|
|
263
|
+
|
|
264
|
+
gl.disable(gl.CULL_FACE);
|
|
265
|
+
|
|
266
|
+
f.bindOutputTexture(this._materialTexture);
|
|
267
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
268
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
269
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, creator._texCoordsBuffer);
|
|
270
|
+
|
|
271
|
+
gl.vertexAttribPointer(sha.texCoords, 2, gl.UNSIGNED_SHORT, true, 0, 0);
|
|
272
|
+
|
|
273
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._gridBuffer);
|
|
274
|
+
gl.vertexAttribPointer(sha.corners, this._gridBuffer.itemSize, gl.FLOAT, false, 0, 0);
|
|
275
|
+
gl.uniform4fv(shu.extentParams, this._extentWgs84Params);
|
|
276
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
277
|
+
gl.bindTexture(gl.TEXTURE_2D, this._sourceTexture);
|
|
278
|
+
gl.uniform1i(shu.sourceTexture, 0);
|
|
279
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, creator._indexBuffer);
|
|
280
|
+
gl.drawElements(gl.TRIANGLE_STRIP, creator._indexBuffer.numItems, gl.UNSIGNED_INT, 0);
|
|
281
|
+
f.deactivate();
|
|
282
|
+
|
|
283
|
+
gl.enable(gl.CULL_FACE);
|
|
284
|
+
|
|
285
|
+
this._ready = true;
|
|
286
|
+
|
|
287
|
+
this._creationProceeding = false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export { GeoVideo };
|