@loaders.gl/terrain 3.1.8 → 3.2.0-alpha.1
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/dist/dist.min.js +4 -4
- package/dist/es5/lib/helpers/skirt.js +4 -4
- package/dist/es5/lib/helpers/skirt.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/esm/lib/helpers/skirt.js +4 -4
- package/dist/esm/lib/helpers/skirt.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/lib/utils/version.js.map +1 -1
- package/dist/lib/helpers/skirt.js +4 -4
- package/dist/quantized-mesh-worker.js +50 -19
- package/dist/terrain-worker.js +50 -19
- package/package.json +4 -4
- package/src/lib/helpers/skirt.ts +4 -4
package/dist/dist.min.js
CHANGED
|
@@ -368,11 +368,11 @@
|
|
|
368
368
|
newTexcoord0.set(attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2), vertex2Offset * 2);
|
|
369
369
|
const triangle1Offset = edgeIndex * 2 * 3;
|
|
370
370
|
newTriangles[triangle1Offset] = edge[0];
|
|
371
|
-
newTriangles[triangle1Offset + 1] =
|
|
372
|
-
newTriangles[triangle1Offset + 2] =
|
|
371
|
+
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
372
|
+
newTriangles[triangle1Offset + 2] = edge[1];
|
|
373
373
|
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
374
|
-
newTriangles[triangle1Offset + 4] =
|
|
375
|
-
newTriangles[triangle1Offset + 5] =
|
|
374
|
+
newTriangles[triangle1Offset + 4] = edge[0];
|
|
375
|
+
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
376
376
|
}
|
|
377
377
|
var init_skirt = __esm({
|
|
378
378
|
"src/lib/helpers/skirt.ts"() {
|
|
@@ -113,10 +113,10 @@ function updateAttributesForNewEdge(_ref) {
|
|
|
113
113
|
newTexcoord0.set(attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2), vertex2Offset * 2);
|
|
114
114
|
var triangle1Offset = edgeIndex * 2 * 3;
|
|
115
115
|
newTriangles[triangle1Offset] = edge[0];
|
|
116
|
-
newTriangles[triangle1Offset + 1] =
|
|
117
|
-
newTriangles[triangle1Offset + 2] =
|
|
116
|
+
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
117
|
+
newTriangles[triangle1Offset + 2] = edge[1];
|
|
118
118
|
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
119
|
-
newTriangles[triangle1Offset + 4] =
|
|
120
|
-
newTriangles[triangle1Offset + 5] =
|
|
119
|
+
newTriangles[triangle1Offset + 4] = edge[0];
|
|
120
|
+
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
121
121
|
}
|
|
122
122
|
//# sourceMappingURL=skirt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/helpers/skirt.ts"],"names":["addSkirt","attributes","triangles","skirtHeight","outsideIndices","outsideEdges","getOutsideEdgesFromIndices","POSITION","value","getOutsideEdgesFromTriangles","newPosition","constructor","length","newTexcoord0","TEXCOORD_0","newTriangles","i","edge","updateAttributesForNewEdge","edgeIndex","resultTriangles","Array","concat","edges","push","sort","a","b","Math","min","max","index","indices","position","westIndices","eastIndices","southIndices","northIndices","indexGroup","positionsLength","vertex1Offset","vertex2Offset","set","subarray","triangle1Offset"],"mappings":";;;;;;;;;;;AAAA;;AAiBO,SAASA,QAAT,CAAkBC,UAAlB,EAA8BC,SAA9B,EAAyCC,WAAzC,EAA8DC,cAA9D,EAA4F;AACjG,MAAMC,YAAY,GAAGD,cAAc,GAC/BE,0BAA0B,CAACF,cAAD,EAAiBH,UAAU,CAACM,QAAX,CAAoBC,KAArC,CADK,GAE/BC,4BAA4B,C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e,GAAG,CAAlB,GAAsBC,aAA1D;AACAzB,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoC3B,IAAI,CAAC,CAAD,CAAxC;AACD","sourcesContent":["import {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nexport type EdgeIndices = {\n westIndices: number[];\n northIndices: number[];\n eastIndices: number[];\n southIndices: number[];\n};\n\n/**\n * Add skirt to existing mesh\n * @param {object} attributes - POSITION and TEXCOOD_0 attributes data\n * @param {any} triangles - indices array of the mesh geometry\n * @param skirtHeight - height of the skirt geometry\n * @param outsideIndices - edge indices from quantized mesh data\n * @returns - geometry data with added skirt\n */\nexport function addSkirt(attributes, triangles, skirtHeight: number, outsideIndices?: EdgeIndices) {\n const outsideEdges = outsideIndices\n ? getOutsideEdgesFromIndices(outsideIndices, attributes.POSITION.value)\n : getOutsideEdgesFromTriangles(triangles);\n\n // 2 new vertices for each outside edge\n const newPosition = new attributes.POSITION.value.constructor(outsideEdges.length * 6);\n const newTexcoord0 = new attributes.TEXCOORD_0.value.constructor(outsideEdges.length * 4);\n\n // 2 new triangles for each outside edge\n const newTriangles = new triangles.constructor(outsideEdges.length * 6);\n\n for (let i = 0; i < outsideEdges.length; i++) {\n const edge = outsideEdges[i];\n\n updateAttributesForNewEdge({\n edge,\n edgeIndex: i,\n attributes,\n skirtHeight,\n newPosition,\n newTexcoord0,\n newTriangles\n });\n }\n\n attributes.POSITION.value = concatenateTypedArrays(attributes.POSITION.value, newPosition);\n attributes.TEXCOORD_0.value = concatenateTypedArrays(attributes.TEXCOORD_0.value, newTexcoord0);\n const resultTriangles =\n triangles instanceof Array\n ? triangles.concat(newTriangles)\n : concatenateTypedArrays(triangles, newTriangles);\n\n return {\n attributes,\n triangles: resultTriangles\n };\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {any} triangles - indices array of the mesh geometry\n * @returns {number[][]} - outside edges data\n */\nfunction getOutsideEdgesFromTriangles(triangles) {\n const edges: number[][] = [];\n for (let i = 0; i < triangles.length; i += 3) {\n edges.push([triangles[i], triangles[i + 1]]);\n edges.push([triangles[i + 1], triangles[i + 2]]);\n edges.push([triangles[i + 2], triangles[i]]);\n }\n\n edges.sort((a, b) => Math.min(...a) - Math.min(...b) || Math.max(...a) - Math.max(...b));\n\n const outsideEdges: number[][] = [];\n let index = 0;\n while (index < edges.length) {\n if (edges[index][0] === edges[index + 1]?.[1] && edges[index][1] === edges[index + 1]?.[0]) {\n index += 2;\n } else {\n outsideEdges.push(edges[index]);\n index++;\n }\n }\n return outsideEdges;\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {object} indices - edge indices from quantized mesh data\n * @param {TypedArray} position - position attribute geometry data\n * @returns {number[][]} - outside edges data\n */\nfunction getOutsideEdgesFromIndices(indices: EdgeIndices, position) {\n // Sort skirt indices to create adjacent triangles\n indices.westIndices.sort((a, b) => position[3 * a + 1] - position[3 * b + 1]);\n // Reverse (b - a) to match triangle winding\n indices.eastIndices.sort((a, b) => position[3 * b + 1] - position[3 * a + 1]);\n indices.southIndices.sort((a, b) => position[3 * b] - position[3 * a]);\n // Reverse (b - a) to match triangle winding\n indices.northIndices.sort((a, b) => position[3 * a] - position[3 * b]);\n\n const edges: number[][] = [];\n for (const index in indices) {\n const indexGroup = indices[index];\n for (let i = 0; i < indexGroup.length - 1; i++) {\n edges.push([indexGroup[i], indexGroup[i + 1]]);\n }\n }\n return edges;\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {object} args\n * @param {number[]} args.edge - edge indices in geometry\n * @param {number} args.edgeIndex - edge index in outsideEdges array\n * @param {object} args.attributes - POSITION and TEXCOORD_0 attributes\n * @param {number} args.skirtHeight - height of the skirt geometry\n * @param {TypedArray} args.newPosition - POSITION array for skirt data\n * @param {TypedArray} args.newTexcoord0 - TEXCOORD_0 array for skirt data\n * @param {TypedArray | Array} args.newTriangles - trinagle indices array for skirt data\n * @returns {void}\n */\nfunction updateAttributesForNewEdge({\n edge,\n edgeIndex,\n attributes,\n skirtHeight,\n newPosition,\n newTexcoord0,\n newTriangles\n}) {\n const positionsLength = attributes.POSITION.value.length;\n const vertex1Offset = edgeIndex * 2;\n const vertex2Offset = edgeIndex * 2 + 1;\n\n // Define POSITION for new 1st vertex\n newPosition.set(\n attributes.POSITION.value.subarray(edge[0] * 3, edge[0] * 3 + 3),\n vertex1Offset * 3\n );\n newPosition[vertex1Offset * 3 + 2] = newPosition[vertex1Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height\n\n // Define POSITION for new 2nd vertex\n newPosition.set(\n attributes.POSITION.value.subarray(edge[1] * 3, edge[1] * 3 + 3),\n vertex2Offset * 3\n );\n newPosition[vertex2Offset * 3 + 2] = newPosition[vertex2Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height\n\n // Use same TEXCOORDS for skirt vertices\n newTexcoord0.set(\n attributes.TEXCOORD_0.value.subarray(edge[0] * 2, edge[0] * 2 + 2),\n vertex1Offset * 2\n );\n newTexcoord0.set(\n attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2),\n vertex2Offset * 2\n );\n\n // Define new triangles\n const triangle1Offset = edgeIndex * 2 * 3;\n newTriangles[triangle1Offset] = edge[0];\n newTriangles[triangle1Offset + 1] = edge[1];\n newTriangles[triangle1Offset + 2] = positionsLength / 3 + vertex2Offset;\n\n newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;\n newTriangles[triangle1Offset + 4] = positionsLength / 3 + vertex1Offset;\n newTriangles[triangle1Offset + 5] = edge[0];\n}\n"],"file":"skirt.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/helpers/skirt.ts"],"names":["addSkirt","attributes","triangles","skirtHeight","outsideIndices","outsideEdges","getOutsideEdgesFromIndices","POSITION","value","getOutsideEdgesFromTriangles","newPosition","constructor","length","newTexcoord0","TEXCOORD_0","newTriangles","i","edge","updateAttributesForNewEdge","edgeIndex","resultTriangles","Array","concat","edges","push","sort","a","b","Math","min","max","index","indices","position","westIndices","eastIndices","southIndices","northIndices","indexGroup","positionsLength","vertex1Offset","vertex2Offset","set","subarray","triangle1Offset"],"mappings":";;;;;;;;;;;AAAA;;AAiBO,SAASA,QAAT,CAAkBC,UAAlB,EAA8BC,SAA9B,EAAyCC,WAAzC,EAA8DC,cAA9D,EAA4F;AACjG,MAAMC,YAAY,GAAGD,cAAc,GAC/BE,0BAA0B,CAACF,cAAD,EAAiBH,UAAU,CAACM,QAAX,CAAoBC,KAArC,CADK,GAE/BC,4BAA4B,CAACP,SAAD,CAFhC;AAKA,MAAMQ,WAAW,GAAG,IAAIT,UAAU,CAACM,QAAX,CAAoBC,KAApB,CAA0BG,WAA9B,CAA0CN,YAAY,CAACO,MAAb,GAAsB,CAAhE,CAApB;AACA,MAAMC,YAAY,GAAG,IAAIZ,UAAU,CAACa,UAAX,CAAsBN,KAAtB,CAA4BG,WAAhC,CAA4CN,YAAY,CAACO,MAAb,GAAsB,CAAlE,CAArB;AAGA,MAAMG,YAAY,GAAG,IAAIb,SAAS,CAACS,WAAd,CAA0BN,YAAY,CAACO,MAAb,GAAsB,CAAhD,CAArB;;AAEA,OAAK,IAAII,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGX,YAAY,CAACO,MAAjC,EAAyCI,CAAC,EAA1C,EAA8C;AAC5C,QAAMC,IAAI,GAAGZ,YAAY,CAACW,CAAD,CAAzB;AAEAE,IAAAA,0BAA0B,CAAC;AACzBD,MAAAA,IAAI,EAAJA,IADyB;AAEzBE,MAAAA,SAAS,EAAEH,CAFc;AAGzBf,MAAAA,UAAU,EAAVA,UAHyB;AAIzBE,MAAAA,WAAW,EAAXA,WAJyB;AAKzBO,MAAAA,WAAW,EAAXA,WALyB;AAMzBG,MAAAA,YAAY,EAAZA,YANyB;AAOzBE,MAAAA,YAAY,EAAZA;AAPyB,KAAD,CAA1B;AASD;;AAEDd,EAAAA,UAAU,CAACM,QAAX,CAAoBC,KAApB,GAA4B,yCAAuBP,UAAU,CAACM,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,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBE,aAA1D;AACA1B,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoC3B,IAAI,CAAC,CAAD,CAAxC;AAEAF,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBE,aAA1D;AACA1B,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoC3B,IAAI,CAAC,CAAD,CAAxC;AACAF,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBC,aAA1D;AACD","sourcesContent":["import {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nexport type EdgeIndices = {\n westIndices: number[];\n northIndices: number[];\n eastIndices: number[];\n southIndices: number[];\n};\n\n/**\n * Add skirt to existing mesh\n * @param {object} attributes - POSITION and TEXCOOD_0 attributes data\n * @param {any} triangles - indices array of the mesh geometry\n * @param skirtHeight - height of the skirt geometry\n * @param outsideIndices - edge indices from quantized mesh data\n * @returns - geometry data with added skirt\n */\nexport function addSkirt(attributes, triangles, skirtHeight: number, outsideIndices?: EdgeIndices) {\n const outsideEdges = outsideIndices\n ? getOutsideEdgesFromIndices(outsideIndices, attributes.POSITION.value)\n : getOutsideEdgesFromTriangles(triangles);\n\n // 2 new vertices for each outside edge\n const newPosition = new attributes.POSITION.value.constructor(outsideEdges.length * 6);\n const newTexcoord0 = new attributes.TEXCOORD_0.value.constructor(outsideEdges.length * 4);\n\n // 2 new triangles for each outside edge\n const newTriangles = new triangles.constructor(outsideEdges.length * 6);\n\n for (let i = 0; i < outsideEdges.length; i++) {\n const edge = outsideEdges[i];\n\n updateAttributesForNewEdge({\n edge,\n edgeIndex: i,\n attributes,\n skirtHeight,\n newPosition,\n newTexcoord0,\n newTriangles\n });\n }\n\n attributes.POSITION.value = concatenateTypedArrays(attributes.POSITION.value, newPosition);\n attributes.TEXCOORD_0.value = concatenateTypedArrays(attributes.TEXCOORD_0.value, newTexcoord0);\n const resultTriangles =\n triangles instanceof Array\n ? triangles.concat(newTriangles)\n : concatenateTypedArrays(triangles, newTriangles);\n\n return {\n attributes,\n triangles: resultTriangles\n };\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {any} triangles - indices array of the mesh geometry\n * @returns {number[][]} - outside edges data\n */\nfunction getOutsideEdgesFromTriangles(triangles) {\n const edges: number[][] = [];\n for (let i = 0; i < triangles.length; i += 3) {\n edges.push([triangles[i], triangles[i + 1]]);\n edges.push([triangles[i + 1], triangles[i + 2]]);\n edges.push([triangles[i + 2], triangles[i]]);\n }\n\n edges.sort((a, b) => Math.min(...a) - Math.min(...b) || Math.max(...a) - Math.max(...b));\n\n const outsideEdges: number[][] = [];\n let index = 0;\n while (index < edges.length) {\n if (edges[index][0] === edges[index + 1]?.[1] && edges[index][1] === edges[index + 1]?.[0]) {\n index += 2;\n } else {\n outsideEdges.push(edges[index]);\n index++;\n }\n }\n return outsideEdges;\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {object} indices - edge indices from quantized mesh data\n * @param {TypedArray} position - position attribute geometry data\n * @returns {number[][]} - outside edges data\n */\nfunction getOutsideEdgesFromIndices(indices: EdgeIndices, position) {\n // Sort skirt indices to create adjacent triangles\n indices.westIndices.sort((a, b) => position[3 * a + 1] - position[3 * b + 1]);\n // Reverse (b - a) to match triangle winding\n indices.eastIndices.sort((a, b) => position[3 * b + 1] - position[3 * a + 1]);\n indices.southIndices.sort((a, b) => position[3 * b] - position[3 * a]);\n // Reverse (b - a) to match triangle winding\n indices.northIndices.sort((a, b) => position[3 * a] - position[3 * b]);\n\n const edges: number[][] = [];\n for (const index in indices) {\n const indexGroup = indices[index];\n for (let i = 0; i < indexGroup.length - 1; i++) {\n edges.push([indexGroup[i], indexGroup[i + 1]]);\n }\n }\n return edges;\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {object} args\n * @param {number[]} args.edge - edge indices in geometry\n * @param {number} args.edgeIndex - edge index in outsideEdges array\n * @param {object} args.attributes - POSITION and TEXCOORD_0 attributes\n * @param {number} args.skirtHeight - height of the skirt geometry\n * @param {TypedArray} args.newPosition - POSITION array for skirt data\n * @param {TypedArray} args.newTexcoord0 - TEXCOORD_0 array for skirt data\n * @param {TypedArray | Array} args.newTriangles - trinagle indices array for skirt data\n * @returns {void}\n */\nfunction updateAttributesForNewEdge({\n edge,\n edgeIndex,\n attributes,\n skirtHeight,\n newPosition,\n newTexcoord0,\n newTriangles\n}) {\n const positionsLength = attributes.POSITION.value.length;\n const vertex1Offset = edgeIndex * 2;\n const vertex2Offset = edgeIndex * 2 + 1;\n\n // Define POSITION for new 1st vertex\n newPosition.set(\n attributes.POSITION.value.subarray(edge[0] * 3, edge[0] * 3 + 3),\n vertex1Offset * 3\n );\n newPosition[vertex1Offset * 3 + 2] = newPosition[vertex1Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height\n\n // Define POSITION for new 2nd vertex\n newPosition.set(\n attributes.POSITION.value.subarray(edge[1] * 3, edge[1] * 3 + 3),\n vertex2Offset * 3\n );\n newPosition[vertex2Offset * 3 + 2] = newPosition[vertex2Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height\n\n // Use same TEXCOORDS for skirt vertices\n newTexcoord0.set(\n attributes.TEXCOORD_0.value.subarray(edge[0] * 2, edge[0] * 2 + 2),\n vertex1Offset * 2\n );\n newTexcoord0.set(\n attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2),\n vertex2Offset * 2\n );\n\n // Define new triangles\n const triangle1Offset = edgeIndex * 2 * 3;\n newTriangles[triangle1Offset] = edge[0];\n newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;\n newTriangles[triangle1Offset + 2] = edge[1];\n\n newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;\n newTriangles[triangle1Offset + 4] = edge[0];\n newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;\n}\n"],"file":"skirt.js"}
|
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.VERSION = void 0;
|
|
7
|
-
var VERSION = typeof "3.1
|
|
7
|
+
var VERSION = typeof "3.2.0-alpha.1" !== 'undefined' ? "3.2.0-alpha.1" : 'latest';
|
|
8
8
|
exports.VERSION = VERSION;
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/utils/version.ts"],"names":["VERSION"],"mappings":";;;;;;AAGO,IAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/utils/version.ts"],"names":["VERSION"],"mappings":";;;;;;AAGO,IAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE","sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"file":"version.js"}
|
|
@@ -92,10 +92,10 @@ function updateAttributesForNewEdge({
|
|
|
92
92
|
newTexcoord0.set(attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2), vertex2Offset * 2);
|
|
93
93
|
const triangle1Offset = edgeIndex * 2 * 3;
|
|
94
94
|
newTriangles[triangle1Offset] = edge[0];
|
|
95
|
-
newTriangles[triangle1Offset + 1] =
|
|
96
|
-
newTriangles[triangle1Offset + 2] =
|
|
95
|
+
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
96
|
+
newTriangles[triangle1Offset + 2] = edge[1];
|
|
97
97
|
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
98
|
-
newTriangles[triangle1Offset + 4] =
|
|
99
|
-
newTriangles[triangle1Offset + 5] =
|
|
98
|
+
newTriangles[triangle1Offset + 4] = edge[0];
|
|
99
|
+
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
100
100
|
}
|
|
101
101
|
//# sourceMappingURL=skirt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/helpers/skirt.ts"],"names":["concatenateTypedArrays","addSkirt","attributes","triangles","skirtHeight","outsideIndices","outsideEdges","getOutsideEdgesFromIndices","POSITION","value","getOutsideEdgesFromTriangles","newPosition","constructor","length","newTexcoord0","TEXCOORD_0","newTriangles","i","edge","updateAttributesForNewEdge","edgeIndex","resultTriangles","Array","concat","edges","push","sort","a","b","Math","min","max","index","indices","position","westIndices","eastIndices","southIndices","northIndices","indexGroup","positionsLength","vertex1Offset","vertex2Offset","set","subarray","triangle1Offset"],"mappings":"AAAA,SAAQA,sBAAR,QAAqC,0BAArC;AAiBA,OAAO,SAASC,QAAT,CAAkBC,UAAlB,EAA8BC,SAA9B,EAAyCC,WAAzC,EAA8DC,cAA9D,EAA4F;AACjG,QAAMC,YAAY,GAAGD,cAAc,GAC/BE,0BAA0B,CAACF,cAAD,EAAiBH,UAAU,CAACM,QAAX,CAAoBC,KAArC,CADK,GAE/BC,4BAA4B,CAACP,SAAD,CAFhC;AAKA,QAAMQ,WAAW,GAAG,IAAIT,UAAU,CAACM,QAAX,CAAoBC,KAApB,CAA0BG,WAA9B,CAA0CN,YAAY,CAACO,MAAb,GAAsB,CAAhE,CAApB;AACA,QAAMC,YAAY,GAAG,IAAIZ,UAAU,CAACa,UAAX,CAAsBN,KAAtB,CAA4BG,WAAhC,CAA4CN,YAAY,CAACO,MAAb,GAAsB,CAAlE,CAArB;AAGA,QAAMG,YAAY,GAAG,IAAIb,SAAS,CAACS,WAAd,CAA0BN,YAAY,CAACO,MAAb,GAAsB,CAAhD,CAArB;;AAEA,OAAK,IAAII,CAAC,G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AI,CAAC,CAAD,CAAJ,GAAU,CAAV,GAAc,CAAhE,CADF,EAEEwB,aAAa,GAAG,CAFlB;AAMA,QAAMG,eAAe,GAAGzB,SAAS,GAAG,CAAZ,GAAgB,CAAxC;AACAJ,EAAAA,YAAY,CAAC6B,eAAD,CAAZ,GAAgC3B,IAAI,CAAC,CAAD,CAApC;AACAF,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoC3B,IAAI,CAAC,CAAD,CAAxC;AACAF,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBE,aAA1D;AAEA1B,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBE,aAA1D;AACA1B,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBC,aAA1D;AACAzB,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoC3B,IAAI,CAAC,CAAD,CAAxC;AACD","sourcesContent":["import {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nexport type EdgeIndices = {\n westIndices: number[];\n northIndices: number[];\n eastIndices: number[];\n southIndices: number[];\n};\n\n/**\n * Add skirt to existing mesh\n * @param {object} attributes - POSITION and TEXCOOD_0 attributes data\n * @param {any} triangles - indices array of the mesh geometry\n * @param skirtHeight - height of the skirt geometry\n * @param outsideIndices - edge indices from quantized mesh data\n * @returns - geometry data with added skirt\n */\nexport function addSkirt(attributes, triangles, skirtHeight: number, outsideIndices?: EdgeIndices) {\n const outsideEdges = outsideIndices\n ? getOutsideEdgesFromIndices(outsideIndices, attributes.POSITION.value)\n : getOutsideEdgesFromTriangles(triangles);\n\n // 2 new vertices for each outside edge\n const newPosition = new attributes.POSITION.value.constructor(outsideEdges.length * 6);\n const newTexcoord0 = new attributes.TEXCOORD_0.value.constructor(outsideEdges.length * 4);\n\n // 2 new triangles for each outside edge\n const newTriangles = new triangles.constructor(outsideEdges.length * 6);\n\n for (let i = 0; i < outsideEdges.length; i++) {\n const edge = outsideEdges[i];\n\n updateAttributesForNewEdge({\n edge,\n edgeIndex: i,\n attributes,\n skirtHeight,\n newPosition,\n newTexcoord0,\n newTriangles\n });\n }\n\n attributes.POSITION.value = concatenateTypedArrays(attributes.POSITION.value, newPosition);\n attributes.TEXCOORD_0.value = concatenateTypedArrays(attributes.TEXCOORD_0.value, newTexcoord0);\n const resultTriangles =\n triangles instanceof Array\n ? triangles.concat(newTriangles)\n : concatenateTypedArrays(triangles, newTriangles);\n\n return {\n attributes,\n triangles: resultTriangles\n };\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {any} triangles - indices array of the mesh geometry\n * @returns {number[][]} - outside edges data\n */\nfunction getOutsideEdgesFromTriangles(triangles) {\n const edges: number[][] = [];\n for (let i = 0; i < triangles.length; i += 3) {\n edges.push([triangles[i], triangles[i + 1]]);\n edges.push([triangles[i + 1], triangles[i + 2]]);\n edges.push([triangles[i + 2], triangles[i]]);\n }\n\n edges.sort((a, b) => Math.min(...a) - Math.min(...b) || Math.max(...a) - Math.max(...b));\n\n const outsideEdges: number[][] = [];\n let index = 0;\n while (index < edges.length) {\n if (edges[index][0] === edges[index + 1]?.[1] && edges[index][1] === edges[index + 1]?.[0]) {\n index += 2;\n } else {\n outsideEdges.push(edges[index]);\n index++;\n }\n }\n return outsideEdges;\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {object} indices - edge indices from quantized mesh data\n * @param {TypedArray} position - position attribute geometry data\n * @returns {number[][]} - outside edges data\n */\nfunction getOutsideEdgesFromIndices(indices: EdgeIndices, position) {\n // Sort skirt indices to create adjacent triangles\n indices.westIndices.sort((a, b) => position[3 * a + 1] - position[3 * b + 1]);\n // Reverse (b - a) to match triangle winding\n indices.eastIndices.sort((a, b) => position[3 * b + 1] - position[3 * a + 1]);\n indices.southIndices.sort((a, b) => position[3 * b] - position[3 * a]);\n // Reverse (b - a) to match triangle winding\n indices.northIndices.sort((a, b) => position[3 * a] - position[3 * b]);\n\n const edges: number[][] = [];\n for (const index in indices) {\n const indexGroup = indices[index];\n for (let i = 0; i < indexGroup.length - 1; i++) {\n edges.push([indexGroup[i], indexGroup[i + 1]]);\n }\n }\n return edges;\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {object} args\n * @param {number[]} args.edge - edge indices in geometry\n * @param {number} args.edgeIndex - edge index in outsideEdges array\n * @param {object} args.attributes - POSITION and TEXCOORD_0 attributes\n * @param {number} args.skirtHeight - height of the skirt geometry\n * @param {TypedArray} args.newPosition - POSITION array for skirt data\n * @param {TypedArray} args.newTexcoord0 - TEXCOORD_0 array for skirt data\n * @param {TypedArray | Array} args.newTriangles - trinagle indices array for skirt data\n * @returns {void}\n */\nfunction updateAttributesForNewEdge({\n edge,\n edgeIndex,\n attributes,\n skirtHeight,\n newPosition,\n newTexcoord0,\n newTriangles\n}) {\n const positionsLength = attributes.POSITION.value.length;\n const vertex1Offset = edgeIndex * 2;\n const vertex2Offset = edgeIndex * 2 + 1;\n\n // Define POSITION for new 1st vertex\n newPosition.set(\n attributes.POSITION.value.subarray(edge[0] * 3, edge[0] * 3 + 3),\n vertex1Offset * 3\n );\n newPosition[vertex1Offset * 3 + 2] = newPosition[vertex1Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height\n\n // Define POSITION for new 2nd vertex\n newPosition.set(\n attributes.POSITION.value.subarray(edge[1] * 3, edge[1] * 3 + 3),\n vertex2Offset * 3\n );\n newPosition[vertex2Offset * 3 + 2] = newPosition[vertex2Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height\n\n // Use same TEXCOORDS for skirt vertices\n newTexcoord0.set(\n attributes.TEXCOORD_0.value.subarray(edge[0] * 2, edge[0] * 2 + 2),\n vertex1Offset * 2\n );\n newTexcoord0.set(\n attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2),\n vertex2Offset * 2\n );\n\n // Define new triangles\n const triangle1Offset = edgeIndex * 2 * 3;\n newTriangles[triangle1Offset] = edge[0];\n newTriangles[triangle1Offset + 1] = edge[1];\n newTriangles[triangle1Offset + 2] = positionsLength / 3 + vertex2Offset;\n\n newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;\n newTriangles[triangle1Offset + 4] = positionsLength / 3 + vertex1Offset;\n newTriangles[triangle1Offset + 5] = edge[0];\n}\n"],"file":"skirt.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/helpers/skirt.ts"],"names":["concatenateTypedArrays","addSkirt","attributes","triangles","skirtHeight","outsideIndices","outsideEdges","getOutsideEdgesFromIndices","POSITION","value","getOutsideEdgesFromTriangles","newPosition","constructor","length","newTexcoord0","TEXCOORD_0","newTriangles","i","edge","updateAttributesForNewEdge","edgeIndex","resultTriangles","Array","concat","edges","push","sort","a","b","Math","min","max","index","indices","position","westIndices","eastIndices","southIndices","northIndices","indexGroup","positionsLength","vertex1Offset","vertex2Offset","set","subarray","triangle1Offset"],"mappings":"AAAA,SAAQA,sBAAR,QAAqC,0BAArC;AAiBA,OAAO,SAASC,QAAT,CAAkBC,UAAlB,EAA8BC,SAA9B,EAAyCC,WAAzC,EAA8DC,cAA9D,EAA4F;AACjG,QAAMC,YAAY,GAAGD,cAAc,GAC/BE,0BAA0B,CAACF,cAAD,EAAiBH,UAAU,CAACM,QAAX,CAAoBC,KAArC,CADK,GAE/BC,4BAA4B,CAACP,SAAD,CAFhC;AAKA,QAAMQ,WAAW,GAAG,IAAIT,UAAU,CAACM,QAAX,CAAoBC,KAApB,CAA0BG,WAA9B,CAA0CN,YAAY,CAACO,MAAb,GAAsB,CAAhE,CAApB;AACA,QAAMC,YAAY,GAAG,IAAIZ,UAAU,CAACa,UAAX,CAAsBN,KAAtB,CAA4BG,WAAhC,CAA4CN,YAAY,CAACO,MAAb,GAAsB,CAAlE,CAArB;AAGA,QAAMG,YAAY,GAA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ACa,UAAX,CAAsBN,KAAtB,CAA4BmC,QAA5B,CAAqC1B,IAAI,CAAC,CAAD,CAAJ,GAAU,CAA/C,EAAkDA,IAAI,CAAC,CAAD,CAAJ,GAAU,CAAV,GAAc,CAAhE,CADF,EAEEwB,aAAa,GAAG,CAFlB;AAMA,QAAMG,eAAe,GAAGzB,SAAS,GAAG,CAAZ,GAAgB,CAAxC;AACAJ,EAAAA,YAAY,CAAC6B,eAAD,CAAZ,GAAgC3B,IAAI,CAAC,CAAD,CAApC;AACAF,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBE,aAA1D;AACA1B,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoC3B,IAAI,CAAC,CAAD,CAAxC;AAEAF,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBE,aAA1D;AACA1B,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoC3B,IAAI,CAAC,CAAD,CAAxC;AACAF,EAAAA,YAAY,CAAC6B,eAAe,GAAG,CAAnB,CAAZ,GAAoCL,eAAe,GAAG,CAAlB,GAAsBC,aAA1D;AACD","sourcesContent":["import {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nexport type EdgeIndices = {\n westIndices: number[];\n northIndices: number[];\n eastIndices: number[];\n southIndices: number[];\n};\n\n/**\n * Add skirt to existing mesh\n * @param {object} attributes - POSITION and TEXCOOD_0 attributes data\n * @param {any} triangles - indices array of the mesh geometry\n * @param skirtHeight - height of the skirt geometry\n * @param outsideIndices - edge indices from quantized mesh data\n * @returns - geometry data with added skirt\n */\nexport function addSkirt(attributes, triangles, skirtHeight: number, outsideIndices?: EdgeIndices) {\n const outsideEdges = outsideIndices\n ? getOutsideEdgesFromIndices(outsideIndices, attributes.POSITION.value)\n : getOutsideEdgesFromTriangles(triangles);\n\n // 2 new vertices for each outside edge\n const newPosition = new attributes.POSITION.value.constructor(outsideEdges.length * 6);\n const newTexcoord0 = new attributes.TEXCOORD_0.value.constructor(outsideEdges.length * 4);\n\n // 2 new triangles for each outside edge\n const newTriangles = new triangles.constructor(outsideEdges.length * 6);\n\n for (let i = 0; i < outsideEdges.length; i++) {\n const edge = outsideEdges[i];\n\n updateAttributesForNewEdge({\n edge,\n edgeIndex: i,\n attributes,\n skirtHeight,\n newPosition,\n newTexcoord0,\n newTriangles\n });\n }\n\n attributes.POSITION.value = concatenateTypedArrays(attributes.POSITION.value, newPosition);\n attributes.TEXCOORD_0.value = concatenateTypedArrays(attributes.TEXCOORD_0.value, newTexcoord0);\n const resultTriangles =\n triangles instanceof Array\n ? triangles.concat(newTriangles)\n : concatenateTypedArrays(triangles, newTriangles);\n\n return {\n attributes,\n triangles: resultTriangles\n };\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {any} triangles - indices array of the mesh geometry\n * @returns {number[][]} - outside edges data\n */\nfunction getOutsideEdgesFromTriangles(triangles) {\n const edges: number[][] = [];\n for (let i = 0; i < triangles.length; i += 3) {\n edges.push([triangles[i], triangles[i + 1]]);\n edges.push([triangles[i + 1], triangles[i + 2]]);\n edges.push([triangles[i + 2], triangles[i]]);\n }\n\n edges.sort((a, b) => Math.min(...a) - Math.min(...b) || Math.max(...a) - Math.max(...b));\n\n const outsideEdges: number[][] = [];\n let index = 0;\n while (index < edges.length) {\n if (edges[index][0] === edges[index + 1]?.[1] && edges[index][1] === edges[index + 1]?.[0]) {\n index += 2;\n } else {\n outsideEdges.push(edges[index]);\n index++;\n }\n }\n return outsideEdges;\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {object} indices - edge indices from quantized mesh data\n * @param {TypedArray} position - position attribute geometry data\n * @returns {number[][]} - outside edges data\n */\nfunction getOutsideEdgesFromIndices(indices: EdgeIndices, position) {\n // Sort skirt indices to create adjacent triangles\n indices.westIndices.sort((a, b) => position[3 * a + 1] - position[3 * b + 1]);\n // Reverse (b - a) to match triangle winding\n indices.eastIndices.sort((a, b) => position[3 * b + 1] - position[3 * a + 1]);\n indices.southIndices.sort((a, b) => position[3 * b] - position[3 * a]);\n // Reverse (b - a) to match triangle winding\n indices.northIndices.sort((a, b) => position[3 * a] - position[3 * b]);\n\n const edges: number[][] = [];\n for (const index in indices) {\n const indexGroup = indices[index];\n for (let i = 0; i < indexGroup.length - 1; i++) {\n edges.push([indexGroup[i], indexGroup[i + 1]]);\n }\n }\n return edges;\n}\n\n/**\n * Get geometry edges that located on a border of the mesh\n * @param {object} args\n * @param {number[]} args.edge - edge indices in geometry\n * @param {number} args.edgeIndex - edge index in outsideEdges array\n * @param {object} args.attributes - POSITION and TEXCOORD_0 attributes\n * @param {number} args.skirtHeight - height of the skirt geometry\n * @param {TypedArray} args.newPosition - POSITION array for skirt data\n * @param {TypedArray} args.newTexcoord0 - TEXCOORD_0 array for skirt data\n * @param {TypedArray | Array} args.newTriangles - trinagle indices array for skirt data\n * @returns {void}\n */\nfunction updateAttributesForNewEdge({\n edge,\n edgeIndex,\n attributes,\n skirtHeight,\n newPosition,\n newTexcoord0,\n newTriangles\n}) {\n const positionsLength = attributes.POSITION.value.length;\n const vertex1Offset = edgeIndex * 2;\n const vertex2Offset = edgeIndex * 2 + 1;\n\n // Define POSITION for new 1st vertex\n newPosition.set(\n attributes.POSITION.value.subarray(edge[0] * 3, edge[0] * 3 + 3),\n vertex1Offset * 3\n );\n newPosition[vertex1Offset * 3 + 2] = newPosition[vertex1Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height\n\n // Define POSITION for new 2nd vertex\n newPosition.set(\n attributes.POSITION.value.subarray(edge[1] * 3, edge[1] * 3 + 3),\n vertex2Offset * 3\n );\n newPosition[vertex2Offset * 3 + 2] = newPosition[vertex2Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height\n\n // Use same TEXCOORDS for skirt vertices\n newTexcoord0.set(\n attributes.TEXCOORD_0.value.subarray(edge[0] * 2, edge[0] * 2 + 2),\n vertex1Offset * 2\n );\n newTexcoord0.set(\n attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2),\n vertex2Offset * 2\n );\n\n // Define new triangles\n const triangle1Offset = edgeIndex * 2 * 3;\n newTriangles[triangle1Offset] = edge[0];\n newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;\n newTriangles[triangle1Offset + 2] = edge[1];\n\n newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;\n newTriangles[triangle1Offset + 4] = edge[0];\n newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;\n}\n"],"file":"skirt.js"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = typeof "3.1
|
|
1
|
+
export const VERSION = typeof "3.2.0-alpha.1" !== 'undefined' ? "3.2.0-alpha.1" : 'latest';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/utils/version.ts"],"names":["VERSION"],"mappings":"AAGA,OAAO,MAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/utils/version.ts"],"names":["VERSION"],"mappings":"AAGA,OAAO,MAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE","sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"file":"version.js"}
|
|
@@ -119,9 +119,9 @@ function updateAttributesForNewEdge({ edge, edgeIndex, attributes, skirtHeight,
|
|
|
119
119
|
// Define new triangles
|
|
120
120
|
const triangle1Offset = edgeIndex * 2 * 3;
|
|
121
121
|
newTriangles[triangle1Offset] = edge[0];
|
|
122
|
-
newTriangles[triangle1Offset + 1] =
|
|
123
|
-
newTriangles[triangle1Offset + 2] =
|
|
122
|
+
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
123
|
+
newTriangles[triangle1Offset + 2] = edge[1];
|
|
124
124
|
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
125
|
-
newTriangles[triangle1Offset + 4] =
|
|
126
|
-
newTriangles[triangle1Offset + 5] =
|
|
125
|
+
newTriangles[triangle1Offset + 4] = edge[0];
|
|
126
|
+
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
127
127
|
}
|
|
@@ -35,16 +35,33 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
38
|
+
function getParentPort() {
|
|
39
|
+
let parentPort;
|
|
40
|
+
try {
|
|
41
|
+
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
42
|
+
parentPort = globalThis.parentPort;
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
return parentPort;
|
|
46
|
+
}
|
|
38
47
|
var onMessageWrapperMap = new Map();
|
|
39
48
|
var WorkerBody = class {
|
|
49
|
+
static inWorkerThread() {
|
|
50
|
+
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
51
|
+
}
|
|
40
52
|
static set onmessage(onMessage) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const { type, payload } = message.data;
|
|
53
|
+
function handleMessage(message) {
|
|
54
|
+
const parentPort3 = getParentPort();
|
|
55
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
46
56
|
onMessage(type, payload);
|
|
47
|
-
}
|
|
57
|
+
}
|
|
58
|
+
const parentPort2 = getParentPort();
|
|
59
|
+
if (parentPort2) {
|
|
60
|
+
parentPort2.on("message", handleMessage);
|
|
61
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
62
|
+
} else {
|
|
63
|
+
globalThis.onmessage = handleMessage;
|
|
64
|
+
}
|
|
48
65
|
}
|
|
49
66
|
static addEventListener(onMessage) {
|
|
50
67
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
@@ -53,22 +70,36 @@
|
|
|
53
70
|
if (!isKnownMessage(message)) {
|
|
54
71
|
return;
|
|
55
72
|
}
|
|
56
|
-
const
|
|
73
|
+
const parentPort3 = getParentPort();
|
|
74
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
57
75
|
onMessage(type, payload);
|
|
58
76
|
};
|
|
59
77
|
}
|
|
60
|
-
|
|
78
|
+
const parentPort2 = getParentPort();
|
|
79
|
+
if (parentPort2) {
|
|
80
|
+
console.error("not implemented");
|
|
81
|
+
} else {
|
|
82
|
+
globalThis.addEventListener("message", onMessageWrapper);
|
|
83
|
+
}
|
|
61
84
|
}
|
|
62
85
|
static removeEventListener(onMessage) {
|
|
63
86
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
64
87
|
onMessageWrapperMap.delete(onMessage);
|
|
65
|
-
|
|
88
|
+
const parentPort2 = getParentPort();
|
|
89
|
+
if (parentPort2) {
|
|
90
|
+
console.error("not implemented");
|
|
91
|
+
} else {
|
|
92
|
+
globalThis.removeEventListener("message", onMessageWrapper);
|
|
93
|
+
}
|
|
66
94
|
}
|
|
67
95
|
static postMessage(type, payload) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
96
|
+
const data = { source: "loaders.gl", type, payload };
|
|
97
|
+
const transferList = getTransferList(payload);
|
|
98
|
+
const parentPort2 = getParentPort();
|
|
99
|
+
if (parentPort2) {
|
|
100
|
+
parentPort2.postMessage(data, transferList);
|
|
101
|
+
} else {
|
|
102
|
+
globalThis.postMessage(data, transferList);
|
|
72
103
|
}
|
|
73
104
|
}
|
|
74
105
|
};
|
|
@@ -80,7 +111,7 @@
|
|
|
80
111
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
81
112
|
var requestId = 0;
|
|
82
113
|
function createLoaderWorker(loader) {
|
|
83
|
-
if (
|
|
114
|
+
if (!WorkerBody.inWorkerThread()) {
|
|
84
115
|
return;
|
|
85
116
|
}
|
|
86
117
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -479,11 +510,11 @@
|
|
|
479
510
|
newTexcoord0.set(attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2), vertex2Offset * 2);
|
|
480
511
|
const triangle1Offset = edgeIndex * 2 * 3;
|
|
481
512
|
newTriangles[triangle1Offset] = edge[0];
|
|
482
|
-
newTriangles[triangle1Offset + 1] =
|
|
483
|
-
newTriangles[triangle1Offset + 2] =
|
|
513
|
+
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
514
|
+
newTriangles[triangle1Offset + 2] = edge[1];
|
|
484
515
|
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
485
|
-
newTriangles[triangle1Offset + 4] =
|
|
486
|
-
newTriangles[triangle1Offset + 5] =
|
|
516
|
+
newTriangles[triangle1Offset + 4] = edge[0];
|
|
517
|
+
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
487
518
|
}
|
|
488
519
|
|
|
489
520
|
// src/lib/parse-quantized-mesh.ts
|
|
@@ -1161,7 +1192,7 @@
|
|
|
1161
1192
|
}
|
|
1162
1193
|
|
|
1163
1194
|
// src/lib/utils/version.ts
|
|
1164
|
-
var VERSION = true ? "3.1
|
|
1195
|
+
var VERSION = true ? "3.2.0-alpha.1" : "latest";
|
|
1165
1196
|
|
|
1166
1197
|
// src/terrain-loader.ts
|
|
1167
1198
|
var TerrainLoader = {
|
package/dist/terrain-worker.js
CHANGED
|
@@ -35,16 +35,33 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
38
|
+
function getParentPort() {
|
|
39
|
+
let parentPort;
|
|
40
|
+
try {
|
|
41
|
+
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
42
|
+
parentPort = globalThis.parentPort;
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
return parentPort;
|
|
46
|
+
}
|
|
38
47
|
var onMessageWrapperMap = new Map();
|
|
39
48
|
var WorkerBody = class {
|
|
49
|
+
static inWorkerThread() {
|
|
50
|
+
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
51
|
+
}
|
|
40
52
|
static set onmessage(onMessage) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
const { type, payload } = message.data;
|
|
53
|
+
function handleMessage(message) {
|
|
54
|
+
const parentPort3 = getParentPort();
|
|
55
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
46
56
|
onMessage(type, payload);
|
|
47
|
-
}
|
|
57
|
+
}
|
|
58
|
+
const parentPort2 = getParentPort();
|
|
59
|
+
if (parentPort2) {
|
|
60
|
+
parentPort2.on("message", handleMessage);
|
|
61
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
62
|
+
} else {
|
|
63
|
+
globalThis.onmessage = handleMessage;
|
|
64
|
+
}
|
|
48
65
|
}
|
|
49
66
|
static addEventListener(onMessage) {
|
|
50
67
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
@@ -53,22 +70,36 @@
|
|
|
53
70
|
if (!isKnownMessage(message)) {
|
|
54
71
|
return;
|
|
55
72
|
}
|
|
56
|
-
const
|
|
73
|
+
const parentPort3 = getParentPort();
|
|
74
|
+
const { type, payload } = parentPort3 ? message : message.data;
|
|
57
75
|
onMessage(type, payload);
|
|
58
76
|
};
|
|
59
77
|
}
|
|
60
|
-
|
|
78
|
+
const parentPort2 = getParentPort();
|
|
79
|
+
if (parentPort2) {
|
|
80
|
+
console.error("not implemented");
|
|
81
|
+
} else {
|
|
82
|
+
globalThis.addEventListener("message", onMessageWrapper);
|
|
83
|
+
}
|
|
61
84
|
}
|
|
62
85
|
static removeEventListener(onMessage) {
|
|
63
86
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
64
87
|
onMessageWrapperMap.delete(onMessage);
|
|
65
|
-
|
|
88
|
+
const parentPort2 = getParentPort();
|
|
89
|
+
if (parentPort2) {
|
|
90
|
+
console.error("not implemented");
|
|
91
|
+
} else {
|
|
92
|
+
globalThis.removeEventListener("message", onMessageWrapper);
|
|
93
|
+
}
|
|
66
94
|
}
|
|
67
95
|
static postMessage(type, payload) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
96
|
+
const data = { source: "loaders.gl", type, payload };
|
|
97
|
+
const transferList = getTransferList(payload);
|
|
98
|
+
const parentPort2 = getParentPort();
|
|
99
|
+
if (parentPort2) {
|
|
100
|
+
parentPort2.postMessage(data, transferList);
|
|
101
|
+
} else {
|
|
102
|
+
globalThis.postMessage(data, transferList);
|
|
72
103
|
}
|
|
73
104
|
}
|
|
74
105
|
};
|
|
@@ -80,7 +111,7 @@
|
|
|
80
111
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
81
112
|
var requestId = 0;
|
|
82
113
|
function createLoaderWorker(loader) {
|
|
83
|
-
if (
|
|
114
|
+
if (!WorkerBody.inWorkerThread()) {
|
|
84
115
|
return;
|
|
85
116
|
}
|
|
86
117
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -479,11 +510,11 @@
|
|
|
479
510
|
newTexcoord0.set(attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2), vertex2Offset * 2);
|
|
480
511
|
const triangle1Offset = edgeIndex * 2 * 3;
|
|
481
512
|
newTriangles[triangle1Offset] = edge[0];
|
|
482
|
-
newTriangles[triangle1Offset + 1] =
|
|
483
|
-
newTriangles[triangle1Offset + 2] =
|
|
513
|
+
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
514
|
+
newTriangles[triangle1Offset + 2] = edge[1];
|
|
484
515
|
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
485
|
-
newTriangles[triangle1Offset + 4] =
|
|
486
|
-
newTriangles[triangle1Offset + 5] =
|
|
516
|
+
newTriangles[triangle1Offset + 4] = edge[0];
|
|
517
|
+
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
487
518
|
}
|
|
488
519
|
|
|
489
520
|
// src/lib/parse-quantized-mesh.ts
|
|
@@ -1161,7 +1192,7 @@
|
|
|
1161
1192
|
}
|
|
1162
1193
|
|
|
1163
1194
|
// src/lib/utils/version.ts
|
|
1164
|
-
var VERSION = true ? "3.1
|
|
1195
|
+
var VERSION = true ? "3.2.0-alpha.1" : "latest";
|
|
1165
1196
|
|
|
1166
1197
|
// src/terrain-loader.ts
|
|
1167
1198
|
var TerrainLoader = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/terrain",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.0-alpha.1",
|
|
4
4
|
"description": "Framework-independent loader for terrain raster formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/runtime": "^7.3.1",
|
|
38
|
-
"@loaders.gl/loader-utils": "3.1
|
|
39
|
-
"@loaders.gl/schema": "3.1
|
|
38
|
+
"@loaders.gl/loader-utils": "3.2.0-alpha.1",
|
|
39
|
+
"@loaders.gl/schema": "3.2.0-alpha.1",
|
|
40
40
|
"@mapbox/martini": "^0.2.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "423a2815092b08dcf93ad5b7dc2940b167305afe"
|
|
43
43
|
}
|
package/src/lib/helpers/skirt.ts
CHANGED
|
@@ -159,10 +159,10 @@ function updateAttributesForNewEdge({
|
|
|
159
159
|
// Define new triangles
|
|
160
160
|
const triangle1Offset = edgeIndex * 2 * 3;
|
|
161
161
|
newTriangles[triangle1Offset] = edge[0];
|
|
162
|
-
newTriangles[triangle1Offset + 1] =
|
|
163
|
-
newTriangles[triangle1Offset + 2] =
|
|
162
|
+
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
163
|
+
newTriangles[triangle1Offset + 2] = edge[1];
|
|
164
164
|
|
|
165
165
|
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
166
|
-
newTriangles[triangle1Offset + 4] =
|
|
167
|
-
newTriangles[triangle1Offset + 5] =
|
|
166
|
+
newTriangles[triangle1Offset + 4] = edge[0];
|
|
167
|
+
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
168
168
|
}
|