@loaders.gl/i3s 4.0.0-alpha.7 → 4.0.0-alpha.8
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 +99 -31
- package/dist/es5/arcgis-webscene-loader.js +1 -1
- package/dist/es5/i3s-attribute-loader.js +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
- package/dist/es5/i3s-content-loader.js +1 -1
- package/dist/es5/i3s-loader.js +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -1
- package/dist/es5/i3s-slpk-loader.js +1 -1
- package/dist/es5/i3s-slpk-loader.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +2 -2
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +2 -2
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +140 -23
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
- package/dist/es5/lib/utils/{customizeColors.js → customize-/321/201olors.js} +65 -40
- package/dist/es5/lib/utils/customize-/321/201olors.js.map +1 -0
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +1 -1
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js +1 -1
- package/dist/esm/i3s-loader.js +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/i3s-slpk-loader.js +1 -1
- package/dist/esm/i3s-slpk-loader.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js +2 -2
- package/dist/esm/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js +59 -9
- package/dist/esm/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
- package/dist/esm/lib/utils/{customizeColors.js → customize-/321/201olors.js} +9 -3
- package/dist/esm/lib/utils/customize-/321/201olors.js.map +1 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-content-worker-node.js +2 -2
- package/dist/i3s-content-worker-node.js.map +3 -3
- package/dist/i3s-content-worker.js +16 -10
- package/dist/i3s-slpk-loader.d.ts +6 -3
- package/dist/i3s-slpk-loader.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +2 -2
- package/dist/lib/parsers/parse-slpk/parse-slpk.d.ts.map +1 -1
- package/dist/lib/parsers/parse-slpk/parse-slpk.js +1 -1
- package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts +6 -0
- package/dist/lib/parsers/parse-slpk/slpk-archieve.d.ts.map +1 -1
- package/dist/lib/parsers/parse-slpk/slpk-archieve.js +72 -9
- package/dist/lib/utils/{customizeColors.d.ts → customize-/321/201olors.d.ts} +1 -1
- package/dist/lib/utils/customize-/321/201olors.d.ts.map +1 -0
- package/dist/lib/utils/{customizeColors.js → customize-/321/201olors.js} +12 -2
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/i3s-slpk-loader.ts +5 -3
- package/src/index.ts +2 -1
- package/src/lib/parsers/parse-i3s-tile-content.ts +1 -1
- package/src/lib/parsers/parse-slpk/parse-slpk.ts +4 -1
- package/src/lib/parsers/parse-slpk/slpk-archieve.ts +73 -9
- package/src/lib/utils/{customizeColors.ts → customize-/321/201olors.ts} +12 -2
- package/src/types.ts +1 -0
- package/dist/es5/lib/utils/customizeColors.js.map +0 -1
- package/dist/esm/lib/utils/customizeColors.js.map +0 -1
- package/dist/lib/utils/customizeColors.d.ts.map +0 -1
|
@@ -4,7 +4,7 @@ import type {COLOR, I3STileOptions, I3STilesetOptions} from '../../types';
|
|
|
4
4
|
import {load} from '@loaders.gl/core';
|
|
5
5
|
import {getAttributeValueType, I3SAttributeLoader} from '../../i3s-attribute-loader';
|
|
6
6
|
import {I3SLoaderOptions} from '../../i3s-loader';
|
|
7
|
-
import {getUrlWithToken} from '
|
|
7
|
+
import {getUrlWithToken} from './url-utils';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Modify vertex colors array to visualize 3D objects in a attribute driven way
|
|
@@ -79,7 +79,17 @@ export async function customizeColors(
|
|
|
79
79
|
if (!color) {
|
|
80
80
|
continue; // eslint-disable-line no-continue
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
|
+
/* eslint max-statements: ["error", 30] */
|
|
84
|
+
/* eslint complexity: ["error", 12] */
|
|
85
|
+
if (options.i3s.colorsByAttribute.mode === 'multiply') {
|
|
86
|
+
// multiplying original mesh and calculated for attribute rgba colors in range 0-255
|
|
87
|
+
color.forEach((colorItem, index) => {
|
|
88
|
+
colors.value[i * 4 + index] = (colors.value[i * 4 + index] * colorItem) / 255;
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
colors.value.set(color, i * 4);
|
|
92
|
+
}
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
return colors;
|
package/src/types.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customizeColors.js","names":["_core","require","_i3sAttributeLoader","_urlUtils","customizeColors","_x","_x2","_x3","_x4","_x5","_customizeColors","apply","arguments","_asyncToGenerator2","default","_regenerator","mark","_callee","colors","featureIds","tileOptions","tilesetOptions","options","_options$i3s2","colorizeAttributeField","colorizeAttributeData","objectIdField","objectIdAttributeData","attributeValuesMap","i","_i","color","wrap","_callee$","_context","prev","next","i3s","colorsByAttribute","abrupt","fields","find","_ref3","_options$i3s3","_options$i3s3$colorsB","name","attributeName","includes","type","loadFeatureAttributeData","sent","_ref4","length","calculateColorForAttribute","value","set","stop","attributeValue","_options$i3s","_options$i3s$colorsBy","minValue","maxValue","minColor","maxColor","rate","Math","round","_x6","_x7","_x8","_x9","_loadFeatureAttributeData","_callee2","_ref","_ref2","_options$i3s4","attributeUrls","attributeStorageInfo","attributeIndex","objectIdAttributeUrl","attributeType","_callee2$","_context2","findIndex","_ref5","getUrlWithToken","token","getAttributeValueType","load","I3SAttributeLoader"],"sources":["../../../../src/lib/utils/customizeColors.ts"],"sourcesContent":["import type {MeshAttribute} from '@loaders.gl/schema';\nimport type {COLOR, I3STileOptions, I3STilesetOptions} from '../../types';\n\nimport {load} from '@loaders.gl/core';\nimport {getAttributeValueType, I3SAttributeLoader} from '../../i3s-attribute-loader';\nimport {I3SLoaderOptions} from '../../i3s-loader';\nimport {getUrlWithToken} from '../utils/url-utils';\n\n/**\n * Modify vertex colors array to visualize 3D objects in a attribute driven way\n * @param colors - vertex colors attribute\n * @param featureIds - feature Ids attribute\n * @param tileOptions - tile - related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns midified colors attribute\n */\nexport async function customizeColors(\n colors: MeshAttribute,\n featureIds: MeshAttribute,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<MeshAttribute> {\n if (!options?.i3s?.colorsByAttribute) {\n return colors;\n }\n\n const colorizeAttributeField = tilesetOptions.fields.find(\n ({name}) => name === options?.i3s?.colorsByAttribute?.attributeName\n );\n if (\n !colorizeAttributeField ||\n !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(\n colorizeAttributeField.type\n )\n ) {\n return colors;\n }\n\n const colorizeAttributeData = await loadFeatureAttributeData(\n colorizeAttributeField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!colorizeAttributeData) {\n return colors;\n }\n\n const objectIdField = tilesetOptions.fields.find(({type}) => type === 'esriFieldTypeOID');\n if (!objectIdField) {\n return colors;\n }\n\n const objectIdAttributeData = await loadFeatureAttributeData(\n objectIdField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!objectIdAttributeData) {\n return colors;\n }\n\n const attributeValuesMap: {[key: number]: COLOR} = {};\n // @ts-expect-error\n for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {\n // @ts-expect-error\n attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(\n // @ts-expect-error\n colorizeAttributeData[colorizeAttributeField.name][i] as number,\n options\n );\n }\n\n for (let i = 0; i < featureIds.value.length; i++) {\n const color = attributeValuesMap[featureIds.value[i]];\n if (!color) {\n continue; // eslint-disable-line no-continue\n }\n colors.value.set(color, i * 4);\n }\n\n return colors;\n}\n\n/**\n * Calculate rgba color from the attribute value\n * @param attributeValue - value of the attribute\n * @param options - loader options\n * @returns - color array for a specific attribute value\n */\nfunction calculateColorForAttribute(attributeValue: number, options?: I3SLoaderOptions): COLOR {\n if (!options?.i3s?.colorsByAttribute) {\n return [255, 255, 255, 255];\n }\n const {minValue, maxValue, minColor, maxColor} = options.i3s.colorsByAttribute;\n const rate = (attributeValue - minValue) / (maxValue - minValue);\n const color: COLOR = [255, 255, 255, 255];\n for (let i = 0; i < minColor.length; i++) {\n color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);\n }\n return color;\n}\n\n/**\n * Load feature attribute data from the ArcGIS rest service\n * @param attributeName - attribute name\n * @param tileOptions - tile-related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns - Array-like list of the attribute values\n */\nasync function loadFeatureAttributeData(\n attributeName: string,\n {attributeUrls}: I3STileOptions,\n {attributeStorageInfo}: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<{[key: string]: string[] | Uint32Array | Uint16Array | Float64Array | null} | null> {\n const attributeIndex = attributeStorageInfo.findIndex(({name}) => attributeName === name);\n if (attributeIndex === -1) {\n return null;\n }\n const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], options?.i3s?.token);\n const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);\n const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {\n attributeName,\n attributeType\n });\n\n // @ts-expect-error TODO action engine\n return objectIdAttributeData;\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAAmD,SAW7BG,eAAeA,CAAAC,EAAA,EAAAC,GAAA,EAAAC,GAAA,EAAAC,GAAA,EAAAC,GAAA;EAAA,OAAAC,gBAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAAA,SAAAF,iBAAA;EAAAA,gBAAA,OAAAG,kBAAA,CAAAC,OAAA,EAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAA9B,SAAAC,QACLC,MAAqB,EACrBC,UAAyB,EACzBC,WAA2B,EAC3BC,cAAiC,EACjCC,OAA0B;IAAA,IAAAC,aAAA;IAAA,IAAAC,sBAAA,EAAAC,qBAAA,EAAAC,aAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,CAAA,EAAAC,EAAA,EAAAC,KAAA;IAAA,OAAAhB,YAAA,CAAAD,OAAA,CAAAkB,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAAA,IAErBd,OAAO,aAAPA,OAAO,gBAAAC,aAAA,GAAPD,OAAO,CAAEe,GAAG,cAAAd,aAAA,eAAZA,aAAA,CAAce,iBAAiB;YAAAJ,QAAA,CAAAE,IAAA;YAAA;UAAA;UAAA,OAAAF,QAAA,CAAAK,MAAA,WAC3BrB,MAAM;QAAA;UAGTM,sBAAsB,GAAGH,cAAc,CAACmB,MAAM,CAACC,IAAI,CACvD,UAAAC,KAAA;YAAA,IAAAC,aAAA,EAAAC,qBAAA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AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customizeColors.js","names":["load","getAttributeValueType","I3SAttributeLoader","getUrlWithToken","customizeColors","colors","featureIds","tileOptions","tilesetOptions","options","_options$i3s","i3s","colorsByAttribute","colorizeAttributeField","fields","find","_ref","_options$i3s2","_options$i3s2$colorsB","name","attributeName","includes","type","colorizeAttributeData","loadFeatureAttributeData","objectIdField","_ref2","objectIdAttributeData","attributeValuesMap","i","length","calculateColorForAttribute","value","color","set","attributeValue","_options$i3s3","minValue","maxValue","minColor","maxColor","rate","Math","round","_ref3","_ref4","_options$i3s4","attributeUrls","attributeStorageInfo","attributeIndex","findIndex","_ref5","objectIdAttributeUrl","token","attributeType"],"sources":["../../../../src/lib/utils/customizeColors.ts"],"sourcesContent":["import type {MeshAttribute} from '@loaders.gl/schema';\nimport type {COLOR, I3STileOptions, I3STilesetOptions} from '../../types';\n\nimport {load} from '@loaders.gl/core';\nimport {getAttributeValueType, I3SAttributeLoader} from '../../i3s-attribute-loader';\nimport {I3SLoaderOptions} from '../../i3s-loader';\nimport {getUrlWithToken} from '../utils/url-utils';\n\n/**\n * Modify vertex colors array to visualize 3D objects in a attribute driven way\n * @param colors - vertex colors attribute\n * @param featureIds - feature Ids attribute\n * @param tileOptions - tile - related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns midified colors attribute\n */\nexport async function customizeColors(\n colors: MeshAttribute,\n featureIds: MeshAttribute,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<MeshAttribute> {\n if (!options?.i3s?.colorsByAttribute) {\n return colors;\n }\n\n const colorizeAttributeField = tilesetOptions.fields.find(\n ({name}) => name === options?.i3s?.colorsByAttribute?.attributeName\n );\n if (\n !colorizeAttributeField ||\n !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(\n colorizeAttributeField.type\n )\n ) {\n return colors;\n }\n\n const colorizeAttributeData = await loadFeatureAttributeData(\n colorizeAttributeField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!colorizeAttributeData) {\n return colors;\n }\n\n const objectIdField = tilesetOptions.fields.find(({type}) => type === 'esriFieldTypeOID');\n if (!objectIdField) {\n return colors;\n }\n\n const objectIdAttributeData = await loadFeatureAttributeData(\n objectIdField.name,\n tileOptions,\n tilesetOptions,\n options\n );\n if (!objectIdAttributeData) {\n return colors;\n }\n\n const attributeValuesMap: {[key: number]: COLOR} = {};\n // @ts-expect-error\n for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {\n // @ts-expect-error\n attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(\n // @ts-expect-error\n colorizeAttributeData[colorizeAttributeField.name][i] as number,\n options\n );\n }\n\n for (let i = 0; i < featureIds.value.length; i++) {\n const color = attributeValuesMap[featureIds.value[i]];\n if (!color) {\n continue; // eslint-disable-line no-continue\n }\n colors.value.set(color, i * 4);\n }\n\n return colors;\n}\n\n/**\n * Calculate rgba color from the attribute value\n * @param attributeValue - value of the attribute\n * @param options - loader options\n * @returns - color array for a specific attribute value\n */\nfunction calculateColorForAttribute(attributeValue: number, options?: I3SLoaderOptions): COLOR {\n if (!options?.i3s?.colorsByAttribute) {\n return [255, 255, 255, 255];\n }\n const {minValue, maxValue, minColor, maxColor} = options.i3s.colorsByAttribute;\n const rate = (attributeValue - minValue) / (maxValue - minValue);\n const color: COLOR = [255, 255, 255, 255];\n for (let i = 0; i < minColor.length; i++) {\n color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);\n }\n return color;\n}\n\n/**\n * Load feature attribute data from the ArcGIS rest service\n * @param attributeName - attribute name\n * @param tileOptions - tile-related options\n * @param tilesetOptions - tileset-related options\n * @param options - loader options\n * @returns - Array-like list of the attribute values\n */\nasync function loadFeatureAttributeData(\n attributeName: string,\n {attributeUrls}: I3STileOptions,\n {attributeStorageInfo}: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<{[key: string]: string[] | Uint32Array | Uint16Array | Float64Array | null} | null> {\n const attributeIndex = attributeStorageInfo.findIndex(({name}) => attributeName === name);\n if (attributeIndex === -1) {\n return null;\n }\n const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], options?.i3s?.token);\n const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);\n const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {\n attributeName,\n attributeType\n });\n\n // @ts-expect-error TODO action engine\n return objectIdAttributeData;\n}\n"],"mappings":"AAGA,SAAQA,IAAI,QAAO,kBAAkB;AACrC,SAAQC,qBAAqB,EAAEC,kBAAkB,QAAO,4BAA4B;AAEpF,SAAQC,eAAe,QAAO,oBAAoB;AAWlD,OAAO,eAAeC,eAAeA,CACnCC,MAAqB,EACrBC,UAAyB,EACzBC,WAA2B,EAC3BC,cAAiC,EACjCC,OAA0B,EACF;EAAA,IAAAC,YAAA;EACxB,IAAI,EAACD,OAAO,aAAPA,OAAO,gBAAAC,YAAA,GAAPD,OAAO,CAAEE,GAAG,cAAAD,YAAA,eAAZA,YAAA,CAAcE,iBAAiB,GAAE;IACpC,OAAOP,MAAM;EACf;EAEA,MAAMQ,sBAAsB,GAAGL,cAAc,CAACM,MAAM,CAACC,IAAI,CACvDC,IAAA;IAAA,IAAAC,aAAA,EAAAC,qBAAA;IAAA,IAAC;MAACC;IAAI,CAAC,GAAAH,IAAA;IAAA,OAAKG,IAAI,MAAKV,OAAO,aAAPA,OAAO,wBAAAQ,aAAA,GAAPR,OAAO,CAAEE,GAAG,cAAAM,aAAA,wBAAAC,qBAAA,GAAZD,aAAA,CAAcL,iBAAiB,cAAAM,qBAAA,uBAA/BA,qBAAA,CAAiCE,aAAa;EAAA,CACrE,CAAC;EACD,IACE,CAACP,sBAAsB,IACvB,CAAC,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,2BAA2B,CAAC,CAACQ,QAAQ,CACpFR,sBAAsB,CAACS,IAC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