@pirireis/webglobeplugins 1.5.3 → 1.5.5
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/package.json +2 -2
- package/semiplugins/shape-on-terrain/arc-plugin.js +1 -0
- package/tools/icon-factory/icon-factory.js +0 -1
- package/tools/icon-factory/parts/png-blob-map.js +17 -3
- package/tools/icon-factory/parts/url-image.js +16 -1
- package/tracks/timetracks/plugin-line-strip.js +10 -3
- package/tracks/timetracks/program-line-strip.js +5 -2
- package/vectorfield/wind/plugin.js +14 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pirireis/webglobeplugins",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "Toprak Nihat Deniz Ozturk",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@pirireis/webglobe": "6.2.51^"
|
|
17
17
|
}
|
|
18
|
-
}
|
|
18
|
+
}
|
|
@@ -70,7 +70,6 @@ export class IconFactory {
|
|
|
70
70
|
if (!(combinationsMap instanceof Map)) {
|
|
71
71
|
throw new Error('combinationsMap must be a Map instance.');
|
|
72
72
|
}
|
|
73
|
-
console.log("combinationMap", combinationsMap);
|
|
74
73
|
if (combinationsMap !== this.combinationMap) {
|
|
75
74
|
this.combinationMap = combinationsMap;
|
|
76
75
|
const baseSize = this.printer.baseSize;
|
|
@@ -56,8 +56,7 @@ export class PngBlobMapPart {
|
|
|
56
56
|
img.onload = () => resolve(img);
|
|
57
57
|
img.onerror = () => {
|
|
58
58
|
this.imageCache.delete(src);
|
|
59
|
-
|
|
60
|
-
reject(new Error(`Failed to load base64 image for src: ${src.slice(0, 64)}...`));
|
|
59
|
+
reject(new Error(`Failed to load base64 image`));
|
|
61
60
|
};
|
|
62
61
|
img.src = src;
|
|
63
62
|
});
|
|
@@ -70,11 +69,26 @@ export class PngBlobMapPart {
|
|
|
70
69
|
}
|
|
71
70
|
async printPart(partInput, targetCanvas, partDestination) {
|
|
72
71
|
const source = this.getBase64Source(partInput);
|
|
73
|
-
const img = await this.loadImage(source);
|
|
74
72
|
const ctx = targetCanvas.getContext("2d");
|
|
75
73
|
if (!ctx) {
|
|
76
74
|
throw new Error("Failed to get 2D context from target canvas.");
|
|
77
75
|
}
|
|
76
|
+
let img;
|
|
77
|
+
try {
|
|
78
|
+
img = await this.loadImage(source);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// draw Red Pixels to indicate broken image
|
|
82
|
+
ctx.fillStyle = "red";
|
|
83
|
+
ctx.fillRect(partDestination.x, partDestination.y, partDestination.width, partDestination.height);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (img.naturalWidth === 0 || img.naturalHeight === 0) {
|
|
87
|
+
// draw Red Pixels to indicate broken image
|
|
88
|
+
ctx.fillStyle = "red";
|
|
89
|
+
ctx.fillRect(partDestination.x, partDestination.y, partDestination.width, partDestination.height);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
78
92
|
const { x, y, width, height } = partDestination;
|
|
79
93
|
ctx.drawImage(img, 0, 0, img.width, img.height, x, y, width, height);
|
|
80
94
|
}
|
|
@@ -35,11 +35,26 @@ export class UrlImagePart {
|
|
|
35
35
|
}
|
|
36
36
|
async printPart(partInput, targetCanvas, partDestination) {
|
|
37
37
|
const url = this.getUrl(partInput);
|
|
38
|
-
const img = await this.loadImage(url);
|
|
39
38
|
const ctx = targetCanvas.getContext('2d');
|
|
40
39
|
if (!ctx) {
|
|
41
40
|
throw new Error('Failed to get 2D context from target canvas.');
|
|
42
41
|
}
|
|
42
|
+
let img;
|
|
43
|
+
try {
|
|
44
|
+
img = await this.loadImage(url);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// draw Red Pixels to indicate broken image
|
|
48
|
+
ctx.fillStyle = "red";
|
|
49
|
+
ctx.fillRect(partDestination.x, partDestination.y, partDestination.width, partDestination.height);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (img.naturalWidth === 0 || img.naturalHeight === 0) {
|
|
53
|
+
// draw Red Pixels to indicate broken image
|
|
54
|
+
ctx.fillStyle = "red";
|
|
55
|
+
ctx.fillRect(partDestination.x, partDestination.y, partDestination.width, partDestination.height);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
43
58
|
const { x, y, width, height } = partDestination;
|
|
44
59
|
ctx.drawImage(img, 0, 0, img.width, img.height, // Source rectangle (entire image)
|
|
45
60
|
x, y, // Destination start point on the target canvas
|
|
@@ -182,20 +182,27 @@ export default class TimeTrackMultiColorPlugin {
|
|
|
182
182
|
draw3D(projMatrix, modelviewMatrix, transPos) {
|
|
183
183
|
if (!this._ready)
|
|
184
184
|
return;
|
|
185
|
-
const { _headTime, _tailTime, program, _transporArr, globe } = this;
|
|
185
|
+
const { _headTime, _tailTime, program, _transporArr, globe, gl } = this;
|
|
186
186
|
this.pointProgram?.draw();
|
|
187
187
|
_transporArr.set([transPos.x, transPos.y, transPos.z], 0);
|
|
188
188
|
const geomType = globe.api_GetCurrentGeometry();
|
|
189
|
+
// Save the framebuffer the globe is currently rendering into and pass it to the
|
|
190
|
+
// program so the final composite lands in the globe's render target. The globe may
|
|
191
|
+
// render to its own FBO (3D depth-buffered mode); forcing null would discard the
|
|
192
|
+
// output and break subsequent plugins.
|
|
193
|
+
const targetFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING);
|
|
189
194
|
if (geomType === 0) {
|
|
190
|
-
program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr);
|
|
195
|
+
program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr, null, targetFBO);
|
|
191
196
|
}
|
|
192
197
|
else if (geomType === 1) {
|
|
193
198
|
const { width, height } = globe.api_GetCurrentWorldWH();
|
|
194
|
-
program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr, [width, height]);
|
|
199
|
+
program.draw(_headTime, _tailTime, projMatrix, modelviewMatrix, _transporArr, [width, height], targetFBO);
|
|
195
200
|
}
|
|
196
201
|
else {
|
|
197
202
|
console.error("Unknown geometry type", geomType);
|
|
198
203
|
}
|
|
204
|
+
// Restore the globe's framebuffer in case any internal step changed it.
|
|
205
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, targetFBO);
|
|
199
206
|
}
|
|
200
207
|
resize(width, height) {
|
|
201
208
|
const { program, globe } = this;
|
|
@@ -533,7 +533,7 @@ void main() {
|
|
|
533
533
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA8, _width, _height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
534
534
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
535
535
|
}
|
|
536
|
-
draw(u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH = null) {
|
|
536
|
+
draw(u_head_time, u_tail_time, uProjectionMatrix, uModelViewMatrix, uTranslate, u_mapWH = null, targetFBO = null) {
|
|
537
537
|
const { gl, _lineProgram, _blurProgram, _blurRepetition } = this;
|
|
538
538
|
this._resetTexture();
|
|
539
539
|
gl.enable(gl.BLEND);
|
|
@@ -576,7 +576,10 @@ void main() {
|
|
|
576
576
|
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
577
577
|
}
|
|
578
578
|
// combine
|
|
579
|
-
|
|
579
|
+
// Composite into the globe's render target (targetFBO) instead of forcing the
|
|
580
|
+
// default framebuffer. The globe may render to its own FBO in 3D depth-buffered
|
|
581
|
+
// mode, so forcing null would discard the output and break subsequent plugins.
|
|
582
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, targetFBO);
|
|
580
583
|
gl.useProgram(this._combineProgram.program);
|
|
581
584
|
gl.bindVertexArray(this._combineProgram.vao);
|
|
582
585
|
gl.activeTexture(gl.TEXTURE1);
|
|
@@ -369,6 +369,10 @@ export default class WindPlugin {
|
|
|
369
369
|
this.lastdatas = [[], [], { x: 0, y: 0, z: 0 }];
|
|
370
370
|
this._drawParticles = this._drawParticlesSphere;
|
|
371
371
|
this._lastLOD = 0;
|
|
372
|
+
// Holds the framebuffer the globe was rendering into when draw3D was called.
|
|
373
|
+
// The globe may render to its own FBO (e.g. for depth-buffered 3D mode), so the
|
|
374
|
+
// wind plugin must restore it instead of forcing the default framebuffer (null).
|
|
375
|
+
this._prevFBO = null;
|
|
372
376
|
}
|
|
373
377
|
// Uniforms are loaded once, on initiation and when they are changed.
|
|
374
378
|
set height(value) {
|
|
@@ -633,13 +637,16 @@ export default class WindPlugin {
|
|
|
633
637
|
const gl = this.gl;
|
|
634
638
|
this._drawScreen();
|
|
635
639
|
this._updateParticles();
|
|
636
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER,
|
|
640
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._prevFBO);
|
|
637
641
|
}
|
|
638
642
|
// globe calls `draw3D` method on each frame
|
|
639
643
|
draw3D(projMatrix, modelviewMatrix, transPos) {
|
|
640
644
|
const gl = this.gl;
|
|
641
645
|
if (this._doDraw()) {
|
|
642
|
-
|
|
646
|
+
// Save the framebuffer the globe is currently rendering into and restore it
|
|
647
|
+
// when we are done. The globe may render to its own FBO (3D depth-buffered
|
|
648
|
+
// mode), so we must not force the default framebuffer (null).
|
|
649
|
+
this._prevFBO = gl.getParameter(gl.FRAMEBUFFER_BINDING);
|
|
643
650
|
this.transPos.set([transPos.x, transPos.y, transPos.z], 0);
|
|
644
651
|
this.projMatrix = projMatrix;
|
|
645
652
|
this.modelviewMatrix = modelviewMatrix;
|
|
@@ -673,7 +680,7 @@ export default class WindPlugin {
|
|
|
673
680
|
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); // non-premultiplied alpha
|
|
674
681
|
this._drawTexture(this.backgroundTexture, this._fadeOpacity);
|
|
675
682
|
this._drawParticles();
|
|
676
|
-
bindFramebuffer(gl,
|
|
683
|
+
bindFramebuffer(gl, this._prevFBO);
|
|
677
684
|
this._drawTexture(this.screenTexture, 1.0);
|
|
678
685
|
// gl.disable(gl.BLEND);
|
|
679
686
|
// save the current screen as the background for the next frame
|
|
@@ -793,7 +800,10 @@ export default class WindPlugin {
|
|
|
793
800
|
gl.bindVertexArray(null); // Add this line
|
|
794
801
|
gl.enable(gl.BLEND);
|
|
795
802
|
defaultblendfunction(gl);
|
|
796
|
-
|
|
803
|
+
// Restore the framebuffer the globe was rendering into before draw3D was called.
|
|
804
|
+
// Forcing null here would clobber the globe's FBO in 3D depth-buffered mode and
|
|
805
|
+
// break subsequent plugins (e.g. arc-plugin, plugin-line-strip).
|
|
806
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this._prevFBO);
|
|
797
807
|
gl.viewport(0, 0, globe.api_ScrW(), globe.api_ScrH());
|
|
798
808
|
}
|
|
799
809
|
_loadHeight() {
|