@pirireis/webglobeplugins 1.2.21 → 1.2.22
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
CHANGED
|
@@ -270,30 +270,6 @@ export class TerrainPolygonSemiPlugin {
|
|
|
270
270
|
this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([state ? 0.0 : 1.0]));
|
|
271
271
|
this.globe.DrawRender();
|
|
272
272
|
}
|
|
273
|
-
setPickableState(state) {
|
|
274
|
-
throw new Error("setPickableState is buggy. use setPausePickableState instead.");
|
|
275
|
-
const oldState = this._options.pickable;
|
|
276
|
-
if (oldState === state)
|
|
277
|
-
return;
|
|
278
|
-
if (oldState === false && state === true) {
|
|
279
|
-
this._pickIndexBuffer = this.globe.gl.createBuffer();
|
|
280
|
-
this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([1.0]));
|
|
281
|
-
this._uboHandler.updateSingle("hoverColor", new Float32Array(this._options.polygonStyle.hoverColor));
|
|
282
|
-
this._pickerDisplayer = new PickerDisplayer(this.globe, "R32I");
|
|
283
|
-
}
|
|
284
|
-
else if (oldState === true && state === false) {
|
|
285
|
-
this.globe.gl.deleteBuffer(this._pickIndexBuffer);
|
|
286
|
-
this._pickIndexBuffer = null;
|
|
287
|
-
this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([0.0]));
|
|
288
|
-
this._uboHandler.updateSingle("private_pickedIndex", new Float32Array([-1]));
|
|
289
|
-
this._pickerDisplayer?.free();
|
|
290
|
-
this._pickerDisplayer = null;
|
|
291
|
-
this._lastPickedPolygon = null;
|
|
292
|
-
}
|
|
293
|
-
this._options.pickable = state;
|
|
294
|
-
this._workerContact.setPickableState(state);
|
|
295
|
-
this.globe.DrawRender();
|
|
296
|
-
}
|
|
297
273
|
getPickedPolygon() {
|
|
298
274
|
if (this._options.pickable === false) {
|
|
299
275
|
throw new Error("TerrainPolygonSemiPlugin is not pickable. Set pickable option to true on construction to enable picking.");
|
|
@@ -496,6 +472,34 @@ export class TerrainPolygonSemiPlugin {
|
|
|
496
472
|
}
|
|
497
473
|
return targetUBO;
|
|
498
474
|
}
|
|
475
|
+
// setPickableState(state: boolean): void {
|
|
476
|
+
// throw new Error("setPickableState is buggy. use setPausePickableState instead.");
|
|
477
|
+
// const oldState = this._options.pickable;
|
|
478
|
+
// if (oldState === state) return;
|
|
479
|
+
// if (oldState === false && state === true) {
|
|
480
|
+
// this._pickIndexBuffer = this.globe.gl.createBuffer();
|
|
481
|
+
// this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([1.0]));
|
|
482
|
+
// this._uboHandler.updateSingle("hoverColor", new Float32Array(this._options.polygonStyle.hoverColor));
|
|
483
|
+
// this._pickerDisplayer = new PickerDisplayer(this.globe, "R32I");
|
|
484
|
+
// } else if (oldState === true && state === false) {
|
|
485
|
+
// this.globe.gl.deleteBuffer(this._pickIndexBuffer!);
|
|
486
|
+
// this._pickIndexBuffer = null;
|
|
487
|
+
// this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([0.0]));
|
|
488
|
+
// this._uboHandler.updateSingle("private_pickedIndex", new Float32Array([-1]));
|
|
489
|
+
// this._pickerDisplayer?.free();
|
|
490
|
+
// this._pickerDisplayer = null;
|
|
491
|
+
// this._lastPickedPolygon = null;
|
|
492
|
+
// }
|
|
493
|
+
// this._options.pickable = state;
|
|
494
|
+
// this._workerContact.setPickableState(state);
|
|
495
|
+
// this.globe.DrawRender();
|
|
496
|
+
// }
|
|
497
|
+
sagUst4W(long, lat, rowSize, colSize, cellWidth = 100, cellHeight = 100, rotationAngle = 0) {
|
|
498
|
+
const globe = this.globe;
|
|
499
|
+
const data = calculateAndSetCoordinates(globe, "sol_ust", rowSize, colSize, 0, 0, 0, 0, cellWidth, cellHeight, [0.75, 0, 0, 1], rotationAngle, { long, lat });
|
|
500
|
+
//@ts-ignore
|
|
501
|
+
this.insertBulk(data);
|
|
502
|
+
}
|
|
499
503
|
}
|
|
500
504
|
function inputCheck(input) {
|
|
501
505
|
if (!input.geometry || !Array.isArray(input.geometry) || input.geometry.length === 0) {
|
|
@@ -522,3 +526,111 @@ function roundTo6(n) {
|
|
|
522
526
|
const rounded = Math.round(n * 1e6) / 1e6;
|
|
523
527
|
return rounded;
|
|
524
528
|
}
|
|
529
|
+
function calculateAndSetCoordinates(globe, startType, // n13, sol_ust, sol_alt
|
|
530
|
+
rowSize, // only sol_ust, sol_alt
|
|
531
|
+
colSize, // only sol_ust, sol_alt
|
|
532
|
+
topRowSize, // only n13
|
|
533
|
+
bottomRowSize, // only n13
|
|
534
|
+
leftColSize, // only n13
|
|
535
|
+
rightColSize, // only n13
|
|
536
|
+
cellWidth, cellHeight, cellColor = [0.75, 0, 0, 1], rotationAngle, // 0-360
|
|
537
|
+
centerCoords) {
|
|
538
|
+
let totalRowSize, totalColSize, startRowOffset, startColOffset;
|
|
539
|
+
if (startType === 'n13') {
|
|
540
|
+
totalRowSize = topRowSize + bottomRowSize;
|
|
541
|
+
totalColSize = leftColSize + rightColSize;
|
|
542
|
+
startRowOffset = -topRowSize;
|
|
543
|
+
startColOffset = -leftColSize;
|
|
544
|
+
}
|
|
545
|
+
else if (startType === 'sol_ust') {
|
|
546
|
+
totalRowSize = rowSize;
|
|
547
|
+
totalColSize = colSize;
|
|
548
|
+
startRowOffset = 0;
|
|
549
|
+
startColOffset = 0;
|
|
550
|
+
}
|
|
551
|
+
else if (startType === 'sol_alt') {
|
|
552
|
+
totalRowSize = rowSize;
|
|
553
|
+
totalColSize = colSize;
|
|
554
|
+
startRowOffset = -rowSize;
|
|
555
|
+
startColOffset = 0;
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
const toRightAngle = 90 - rotationAngle;
|
|
561
|
+
const toBottomAngle = 180 - rotationAngle;
|
|
562
|
+
const toTopAngle = 0 - rotationAngle;
|
|
563
|
+
const toLeftAngle = 270 - rotationAngle;
|
|
564
|
+
// Traverses each cell (and 1 extra row) and:
|
|
565
|
+
// 3. Population of terrain polygon semi-plugin (tpsp) data
|
|
566
|
+
// Initialize flatArray
|
|
567
|
+
const coordsLength = (totalRowSize + 1) * (totalColSize + 1); // e.g. 3x5 grid has (3+1)*(5+1) = 24 coords (vertices)
|
|
568
|
+
const flatArray = Array(coordsLength);
|
|
569
|
+
// Calculate all vertex positions from center
|
|
570
|
+
for (let rowIndex = 0; rowIndex < totalRowSize + 1; rowIndex++) {
|
|
571
|
+
for (let colIndex = 0; colIndex < totalColSize + 1; colIndex++) {
|
|
572
|
+
const vertexIndex = rowIndex * (totalColSize + 1) + colIndex;
|
|
573
|
+
// Calculate offset from center in terms of cells
|
|
574
|
+
const rowOffsetFromCenter = startRowOffset + rowIndex;
|
|
575
|
+
const colOffsetFromCenter = startColOffset + colIndex;
|
|
576
|
+
// Calculate the actual position
|
|
577
|
+
// First move vertically from center
|
|
578
|
+
const verticalDistance = Math.abs(rowOffsetFromCenter) * cellHeight;
|
|
579
|
+
const verticalAngle = rowOffsetFromCenter < 0 ? toTopAngle : toBottomAngle;
|
|
580
|
+
let coords;
|
|
581
|
+
if (rowOffsetFromCenter === 0) {
|
|
582
|
+
coords = { ...centerCoords };
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
coords = globe.Math.FindPointByPolar(centerCoords.long, centerCoords.lat, verticalDistance, verticalAngle);
|
|
586
|
+
}
|
|
587
|
+
// Then move horizontally
|
|
588
|
+
if (colOffsetFromCenter !== 0) {
|
|
589
|
+
const horizontalDistance = Math.abs(colOffsetFromCenter) * cellWidth;
|
|
590
|
+
const horizontalAngle = colOffsetFromCenter < 0 ? toLeftAngle : toRightAngle;
|
|
591
|
+
coords = globe.Math.FindPointByPolar(coords.long, coords.lat, horizontalDistance, horizontalAngle);
|
|
592
|
+
}
|
|
593
|
+
flatArray[vertexIndex] = { ...coords };
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
// Initialize tpspData array
|
|
597
|
+
const tpspData = [];
|
|
598
|
+
// Populate cells using the pre-calculated vertex positions
|
|
599
|
+
for (let rowIndex = 0; rowIndex < totalRowSize; rowIndex++) {
|
|
600
|
+
for (let colIndex = 0; colIndex < totalColSize; colIndex++) {
|
|
601
|
+
const cellIndex = rowIndex * totalColSize + colIndex;
|
|
602
|
+
// ******************************************** //
|
|
603
|
+
// * 1. Get coordinates from flatArray * //
|
|
604
|
+
// ******************************************** //
|
|
605
|
+
const tlCoordsIndex = rowIndex * (totalColSize + 1) + colIndex;
|
|
606
|
+
const trCoordsIndex = tlCoordsIndex + 1;
|
|
607
|
+
const blCoordsIndex = (rowIndex + 1) * (totalColSize + 1) + colIndex;
|
|
608
|
+
const brCoordsIndex = blCoordsIndex + 1;
|
|
609
|
+
const tlCoords = flatArray[tlCoordsIndex];
|
|
610
|
+
const trCoords = flatArray[trCoordsIndex];
|
|
611
|
+
const blCoords = flatArray[blCoordsIndex];
|
|
612
|
+
const brCoords = flatArray[brCoordsIndex];
|
|
613
|
+
tpspData.push({
|
|
614
|
+
key: cellIndex + Date.now().toString(),
|
|
615
|
+
geometry: [
|
|
616
|
+
{
|
|
617
|
+
vertices: [
|
|
618
|
+
tlCoords.long,
|
|
619
|
+
tlCoords.lat,
|
|
620
|
+
trCoords.long,
|
|
621
|
+
trCoords.lat,
|
|
622
|
+
brCoords.long,
|
|
623
|
+
brCoords.lat,
|
|
624
|
+
blCoords.long,
|
|
625
|
+
blCoords.lat,
|
|
626
|
+
],
|
|
627
|
+
holes: [],
|
|
628
|
+
},
|
|
629
|
+
],
|
|
630
|
+
color: cellColor,
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
// Bulk insert cell data to terrain polygon semi-plugin
|
|
635
|
+
return tpspData;
|
|
636
|
+
}
|