@loaders.gl/i3s 4.0.0-beta.6 → 4.0.0-beta.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/LICENSE +7 -7
- package/dist/dist.dev.js +864 -1460
- package/dist/i3s-content-worker-node.js +55 -55
- package/dist/i3s-content-worker-node.js.map +4 -4
- package/dist/i3s-content-worker.js +33 -796
- package/dist/i3s-loader.d.ts.map +1 -1
- package/dist/i3s-loader.js +1 -2
- package/dist/i3s-loader.js.map +1 -1
- package/dist/index.cjs +293 -316
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/parsers/constants.d.ts.map +1 -1
- package/dist/lib/parsers/constants.js +1 -1
- package/dist/lib/parsers/constants.js.map +1 -1
- package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +2 -4
- package/dist/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/lib/utils/customize-colors.d.ts +30 -0
- package/dist/lib/utils/customize-colors.d.ts.map +1 -0
- package/dist/lib/utils/customize-colors.js +92 -0
- package/dist/lib/utils/customize-colors.js.map +1 -0
- package/package.json +11 -12
- package/src/i3s-loader.ts +1 -2
- package/src/index.ts +2 -0
- package/src/lib/parsers/constants.ts +4 -1
- package/src/lib/parsers/parse-i3s-attribute.ts +1 -0
- package/src/lib/parsers/parse-i3s-tile-content.ts +2 -11
- package/src/lib/utils/{customize-/321/201olors.ts → customize-colors.ts} +66 -41
- package/dist/lib/utils/customize-/321/201olors.d.ts +0 -14
- package/dist/lib/utils/customize-/321/201olors.d.ts.map +0 -1
- package/dist/lib/utils/customize-/321/201olors.js +0 -98
- package/dist/lib/utils/customize-/321/201olors.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,5 @@ export { I3SNodePageLoader } from './i3s-node-page-loader';
|
|
|
10
10
|
export { ArcGISWebSceneLoader } from './arcgis-webscene-loader';
|
|
11
11
|
export type { SLPKArchive } from './lib/parsers/parse-slpk/slpk-archieve';
|
|
12
12
|
export { parseSLPKArchive } from './lib/parsers/parse-slpk/parse-slpk';
|
|
13
|
+
export { customizeColors } from './lib/utils/customize-colors';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,eAAe,EACf,GAAG,EACH,GAAG,EACH,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,SAAS,EACT,MAAM,EACN,gBAAgB,EAChB,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EAChB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AACjB,YAAY,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAC,2BAA2B,EAAC,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAE9D,YAAY,EAAC,WAAW,EAAC,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAC,gBAAgB,EAAC,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,5 @@ export { I3SBuildingSceneLayerLoader } from "./i3s-building-scene-layer-loader.j
|
|
|
7
7
|
export { I3SNodePageLoader } from "./i3s-node-page-loader.js";
|
|
8
8
|
export { ArcGISWebSceneLoader } from "./arcgis-webscene-loader.js";
|
|
9
9
|
export { parseSLPKArchive } from "./lib/parsers/parse-slpk/parse-slpk.js";
|
|
10
|
+
export { customizeColors } from "./lib/utils/customize-colors.js";
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["COORDINATE_SYSTEM","I3SLoader","SLPKLoader","I3SContentLoader","I3SAttributeLoader","loadFeatureAttributes","I3SBuildingSceneLayerLoader","I3SNodePageLoader","ArcGISWebSceneLoader","parseSLPKArchive"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nexport type {\n BoundingVolumes,\n Mbs,\n Obb,\n I3STilesetHeader,\n I3STileContent,\n I3STileHeader,\n SceneLayer3D,\n AttributeStorageInfo,\n Field,\n ESRIField,\n PopupInfo,\n Node3DIndexDocument,\n LodSelection,\n NodeReference,\n Resource,\n MaxScreenThresholdSQ,\n NodeInPage,\n SharedResources,\n Attribute,\n Extent,\n FeatureAttribute,\n FieldInfo,\n I3SMaterialDefinition,\n TextureDefinitionInfo,\n MaterialDefinitionInfo,\n FullExtent,\n StatisticsInfo,\n StatsInfo,\n Histogram,\n ValueCount,\n BuildingSceneSublayer,\n OperationalLayer,\n TextureSetDefinitionFormats\n} from './types';\nexport type {I3SLoaderOptions} from './i3s-loader';\n\nexport {COORDINATE_SYSTEM} from './lib/parsers/constants';\n\nexport {I3SLoader} from './i3s-loader';\nexport {SLPKLoader} from './i3s-slpk-loader';\nexport {I3SContentLoader} from './i3s-content-loader';\nexport {I3SAttributeLoader, loadFeatureAttributes} from './i3s-attribute-loader';\nexport {I3SBuildingSceneLayerLoader} from './i3s-building-scene-layer-loader';\nexport {I3SNodePageLoader} from './i3s-node-page-loader';\nexport {ArcGISWebSceneLoader} from './arcgis-webscene-loader';\n\nexport type {SLPKArchive} from './lib/parsers/parse-slpk/slpk-archieve';\nexport {parseSLPKArchive} from './lib/parsers/parse-slpk/parse-slpk';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["COORDINATE_SYSTEM","I3SLoader","SLPKLoader","I3SContentLoader","I3SAttributeLoader","loadFeatureAttributes","I3SBuildingSceneLayerLoader","I3SNodePageLoader","ArcGISWebSceneLoader","parseSLPKArchive","customizeColors"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nexport type {\n BoundingVolumes,\n Mbs,\n Obb,\n I3STilesetHeader,\n I3STileContent,\n I3STileHeader,\n SceneLayer3D,\n AttributeStorageInfo,\n Field,\n ESRIField,\n PopupInfo,\n Node3DIndexDocument,\n LodSelection,\n NodeReference,\n Resource,\n MaxScreenThresholdSQ,\n NodeInPage,\n SharedResources,\n Attribute,\n Extent,\n FeatureAttribute,\n FieldInfo,\n I3SMaterialDefinition,\n TextureDefinitionInfo,\n MaterialDefinitionInfo,\n FullExtent,\n StatisticsInfo,\n StatsInfo,\n Histogram,\n ValueCount,\n BuildingSceneSublayer,\n OperationalLayer,\n TextureSetDefinitionFormats\n} from './types';\nexport type {I3SLoaderOptions} from './i3s-loader';\n\nexport {COORDINATE_SYSTEM} from './lib/parsers/constants';\n\nexport {I3SLoader} from './i3s-loader';\nexport {SLPKLoader} from './i3s-slpk-loader';\nexport {I3SContentLoader} from './i3s-content-loader';\nexport {I3SAttributeLoader, loadFeatureAttributes} from './i3s-attribute-loader';\nexport {I3SBuildingSceneLayerLoader} from './i3s-building-scene-layer-loader';\nexport {I3SNodePageLoader} from './i3s-node-page-loader';\nexport {ArcGISWebSceneLoader} from './arcgis-webscene-loader';\n\nexport type {SLPKArchive} from './lib/parsers/parse-slpk/slpk-archieve';\nexport {parseSLPKArchive} from './lib/parsers/parse-slpk/parse-slpk';\nexport {customizeColors} from './lib/utils/customize-colors';\n"],"mappings":"SAwCQA,iBAAiB;AAAA,SAEjBC,SAAS;AAAA,SACTC,UAAU;AAAA,SACVC,gBAAgB;AAAA,SAChBC,kBAAkB,EAAEC,qBAAqB;AAAA,SACzCC,2BAA2B;AAAA,SAC3BC,iBAAiB;AAAA,SACjBC,oBAAoB;AAAA,SAGpBC,gBAAgB;AAAA,SAChBC,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/constants.ts"],"names":[],"mappings":"AAKA,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,+HAe3D;AAED,eAAO,MAAM,WAAW,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAM/C,CAAC;AACF;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkB/C;AAED,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAChD,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAI7C,oBAAY,iBAAiB;IAC3B;;OAEG;IACH,OAAO,KAAK;IACZ;;;OAGG;IACH,MAAM,IAAI;IACV;;OAEG;IACH,aAAa,IAAI;IACjB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;OAEG;IACH,SAAS,IAAI;CACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["GL","getConstructorForDataFormat","dataType","Uint8Array","Uint16Array","Uint32Array","Float32Array","Float64Array","Error","GL_TYPE_MAP","UInt8","UNSIGNED_BYTE","UInt16","UNSIGNED_SHORT","Float32","FLOAT","UInt32","UNSIGNED_INT","UInt64","DOUBLE","sizeOf","STRING_ATTRIBUTE_TYPE","OBJECT_ID_ATTRIBUTE_TYPE","FLOAT_64_TYPE","INT_16_ATTRIBUTE_TYPE","COORDINATE_SYSTEM"],"sources":["../../../src/lib/parsers/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.js","names":["GL","getConstructorForDataFormat","dataType","Uint8Array","Uint16Array","Uint32Array","Float32Array","Float64Array","Error","GL_TYPE_MAP","UInt8","UNSIGNED_BYTE","UInt16","UNSIGNED_SHORT","Float32","FLOAT","UInt32","UNSIGNED_INT","UInt64","DOUBLE","sizeOf","STRING_ATTRIBUTE_TYPE","OBJECT_ID_ATTRIBUTE_TYPE","FLOAT_64_TYPE","INT_16_ATTRIBUTE_TYPE","COORDINATE_SYSTEM"],"sources":["../../../src/lib/parsers/constants.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {GL} from '@loaders.gl/math';\n\nexport function getConstructorForDataFormat(dataType: string) {\n switch (dataType) {\n case 'UInt8':\n return Uint8Array;\n case 'UInt16':\n return Uint16Array;\n case 'UInt32':\n return Uint32Array;\n case 'Float32':\n return Float32Array;\n case 'UInt64':\n return Float64Array;\n default:\n throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);\n }\n}\n\nexport const GL_TYPE_MAP: {[key: string]: number} = {\n UInt8: GL.UNSIGNED_BYTE,\n UInt16: GL.UNSIGNED_SHORT,\n Float32: GL.FLOAT,\n UInt32: GL.UNSIGNED_INT,\n UInt64: GL.DOUBLE\n};\n/**\n * Returns how many bytes a type occupies\n * @param dataType\n * @returns\n */\nexport function sizeOf(dataType: string): number {\n switch (dataType) {\n case 'UInt8':\n return 1;\n case 'UInt16':\n case 'Int16':\n return 2;\n case 'UInt32':\n case 'Int32':\n case 'Float32':\n return 4;\n case 'UInt64':\n case 'Int64':\n case 'Float64':\n return 8;\n default:\n throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);\n }\n}\n\nexport const STRING_ATTRIBUTE_TYPE = 'String';\nexport const OBJECT_ID_ATTRIBUTE_TYPE = 'Oid32';\nexport const FLOAT_64_TYPE = 'Float64';\nexport const INT_16_ATTRIBUTE_TYPE = 'Int16';\n\n// https://github.com/visgl/deck.gl/blob/9548f43cba2234a1f4877b6b17f6c88eb35b2e08/modules/core/src/lib/constants.js#L27\n// Describes the format of positions\nexport enum COORDINATE_SYSTEM {\n /**\n * `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise\n */\n DEFAULT = -1,\n /**\n * Positions are interpreted as [lng, lat, elevation]\n * lng lat are degrees, elevation is meters. distances as meters.\n */\n LNGLAT = 1,\n /**\n * Positions are interpreted as meter offsets, distances as meters\n */\n METER_OFFSETS = 2,\n /**\n * Positions are interpreted as lng lat offsets: [deltaLng, deltaLat, elevation]\n * deltaLng, deltaLat are delta degrees, elevation is meters.\n * distances as meters.\n */\n LNGLAT_OFFSETS = 3,\n /**\n * Non-geospatial\n */\n CARTESIAN = 0\n}\n"],"mappings":"AAGA,SAAQA,EAAE,QAAO,kBAAkB;AAEnC,OAAO,SAASC,2BAA2BA,CAACC,QAAgB,EAAE;EAC5D,QAAQA,QAAQ;IACd,KAAK,OAAO;MACV,OAAOC,UAAU;IACnB,KAAK,QAAQ;MACX,OAAOC,WAAW;IACpB,KAAK,QAAQ;MACX,OAAOC,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"","sources":["../../../src/lib/parsers/parse-i3s-attribute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-i3s-attribute.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-attribute.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAS9C,KAAK,SAAS,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,IAAI,CAAC;AAC9C,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,KAAA,GAAG,iBAAiB,CAS1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-i3s-attribute.js","names":["STRING_ATTRIBUTE_TYPE","OBJECT_ID_ATTRIBUTE_TYPE","FLOAT_64_TYPE","INT_16_ATTRIBUTE_TYPE","parseI3STileAttribute","arrayBuffer","options","attributeName","attributeType","parseAttribute","parseStringsAttribute","parseShortNumberAttribute","parseFloatAttribute","parseInt16ShortNumberAttribute","countOffset","Uint32Array","Int16Array","Float64Array","stringsCountOffset","dataOffset","bytesPerStringSize","stringsArray","stringsCount","DataView","getUint32","stringSizes","stringOffset","stringByteSize","textDecoder","TextDecoder","stringAttribute","Uint8Array","push","decode","error","console","message"],"sources":["../../../src/lib/parsers/parse-i3s-attribute.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {TypedArray} from '@loaders.gl/schema';\n\nimport {\n STRING_ATTRIBUTE_TYPE,\n OBJECT_ID_ATTRIBUTE_TYPE,\n FLOAT_64_TYPE,\n INT_16_ATTRIBUTE_TYPE\n} from './constants';\n\ntype Attribute = string[] | TypedArray | null;\nexport type I3STileAttributes = Record<string, Attribute>;\n\n/**\n * Get particular tile and creates attribute object inside.\n * @param arrayBuffer\n * @param {Object} options\n * @returns {Promise<object>}\n */\nexport function parseI3STileAttribute(arrayBuffer: ArrayBuffer, options): I3STileAttributes {\n const {attributeName, attributeType} = options;\n\n if (!attributeName) {\n return {};\n }\n return {\n [attributeName]: attributeType ? parseAttribute(attributeType, arrayBuffer) : null\n };\n}\n\n/**\n * Parse attributes based on attribute type.\n * @param {String} attributeType\n * @param arrayBuffer\n * @returns\n */\nfunction parseAttribute(attributeType, arrayBuffer: ArrayBuffer): Attribute {\n switch (attributeType) {\n case STRING_ATTRIBUTE_TYPE:\n return parseStringsAttribute(arrayBuffer);\n case OBJECT_ID_ATTRIBUTE_TYPE:\n return parseShortNumberAttribute(arrayBuffer);\n case FLOAT_64_TYPE:\n return parseFloatAttribute(arrayBuffer);\n case INT_16_ATTRIBUTE_TYPE:\n return parseInt16ShortNumberAttribute(arrayBuffer);\n default:\n return parseShortNumberAttribute(arrayBuffer);\n }\n}\n\n/**\n * Parse short number attribute.\n * Short Integer spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param arrayBuffer\n * @returns\n */\nfunction parseShortNumberAttribute(arrayBuffer: ArrayBuffer): Uint32Array {\n const countOffset = 4;\n return new Uint32Array(arrayBuffer, countOffset);\n}\n\n/**\n * Parse Int16 short number attribute.\n * Parsing of such data is not documented. Added to handle Building Scene Layer Tileset attributes data.\n * @param arrayBuffer\n * @returns\n */\nfunction parseInt16ShortNumberAttribute(arrayBuffer: ArrayBuffer): Int16Array {\n const countOffset = 4;\n return new Int16Array(arrayBuffer, countOffset);\n}\n\n/**\n * Parse float attribute.\n * Double Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param arrayBuffer\n * @returns\n */\nfunction parseFloatAttribute(arrayBuffer: ArrayBuffer): Float64Array {\n const countOffset = 8;\n return new Float64Array(arrayBuffer, countOffset);\n}\n\n/**\n * Parse string attribute.\n * String spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param arrayBuffer\n * @returns list of strings\n */\nfunction parseStringsAttribute(arrayBuffer: ArrayBuffer): string[] {\n const stringsCountOffset = 0;\n const dataOffset = 8;\n const bytesPerStringSize = 4;\n const stringsArray: string[] = [];\n\n try {\n // Use DataView to avoid multiple of 4 error on Uint32Array constructor\n const stringsCount = new DataView(\n arrayBuffer,\n stringsCountOffset,\n bytesPerStringSize\n ).getUint32(stringsCountOffset, true);\n const stringSizes = new Uint32Array(arrayBuffer, dataOffset, stringsCount);\n let stringOffset = dataOffset + stringsCount * bytesPerStringSize;\n\n for (const stringByteSize of stringSizes) {\n const textDecoder = new TextDecoder('utf-8');\n const stringAttribute = new Uint8Array(arrayBuffer, stringOffset, stringByteSize);\n stringsArray.push(textDecoder.decode(stringAttribute));\n stringOffset += stringByteSize;\n }\n } catch (error) {\n console.error('Parse string attribute error: ', (error as Error).message); // eslint-disable-line\n }\n\n return stringsArray;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-i3s-attribute.js","names":["STRING_ATTRIBUTE_TYPE","OBJECT_ID_ATTRIBUTE_TYPE","FLOAT_64_TYPE","INT_16_ATTRIBUTE_TYPE","parseI3STileAttribute","arrayBuffer","options","attributeName","attributeType","parseAttribute","parseStringsAttribute","parseShortNumberAttribute","parseFloatAttribute","parseInt16ShortNumberAttribute","countOffset","Uint32Array","Int16Array","Float64Array","stringsCountOffset","dataOffset","bytesPerStringSize","stringsArray","stringsCount","DataView","getUint32","stringSizes","stringOffset","stringByteSize","textDecoder","TextDecoder","stringAttribute","Uint8Array","push","decode","error","console","message"],"sources":["../../../src/lib/parsers/parse-i3s-attribute.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {TypedArray} from '@loaders.gl/schema';\n\nimport {\n STRING_ATTRIBUTE_TYPE,\n OBJECT_ID_ATTRIBUTE_TYPE,\n FLOAT_64_TYPE,\n INT_16_ATTRIBUTE_TYPE\n} from './constants';\n\ntype Attribute = string[] | TypedArray | null;\nexport type I3STileAttributes = Record<string, Attribute>;\n\n/**\n * Get particular tile and creates attribute object inside.\n * @param arrayBuffer\n * @param {Object} options\n * @returns {Promise<object>}\n */\nexport function parseI3STileAttribute(arrayBuffer: ArrayBuffer, options): I3STileAttributes {\n const {attributeName, attributeType} = options;\n\n if (!attributeName) {\n return {};\n }\n return {\n [attributeName]: attributeType ? parseAttribute(attributeType, arrayBuffer) : null\n };\n}\n\n/**\n * Parse attributes based on attribute type.\n * @param {String} attributeType\n * @param arrayBuffer\n * @returns\n */\nfunction parseAttribute(attributeType, arrayBuffer: ArrayBuffer): Attribute {\n switch (attributeType) {\n case STRING_ATTRIBUTE_TYPE:\n return parseStringsAttribute(arrayBuffer);\n case OBJECT_ID_ATTRIBUTE_TYPE:\n return parseShortNumberAttribute(arrayBuffer);\n case FLOAT_64_TYPE:\n return parseFloatAttribute(arrayBuffer);\n case INT_16_ATTRIBUTE_TYPE:\n return parseInt16ShortNumberAttribute(arrayBuffer);\n default:\n return parseShortNumberAttribute(arrayBuffer);\n }\n}\n\n/**\n * Parse short number attribute.\n * Short Integer spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param arrayBuffer\n * @returns\n */\nfunction parseShortNumberAttribute(arrayBuffer: ArrayBuffer): Uint32Array {\n const countOffset = 4;\n return new Uint32Array(arrayBuffer, countOffset);\n}\n\n/**\n * Parse Int16 short number attribute.\n * Parsing of such data is not documented. Added to handle Building Scene Layer Tileset attributes data.\n * @param arrayBuffer\n * @returns\n */\nfunction parseInt16ShortNumberAttribute(arrayBuffer: ArrayBuffer): Int16Array {\n const countOffset = 4;\n return new Int16Array(arrayBuffer, countOffset);\n}\n\n/**\n * Parse float attribute.\n * Double Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param arrayBuffer\n * @returns\n */\nfunction parseFloatAttribute(arrayBuffer: ArrayBuffer): Float64Array {\n const countOffset = 8;\n return new Float64Array(arrayBuffer, countOffset);\n}\n\n/**\n * Parse string attribute.\n * String spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param arrayBuffer\n * @returns list of strings\n */\nfunction parseStringsAttribute(arrayBuffer: ArrayBuffer): string[] {\n const stringsCountOffset = 0;\n const dataOffset = 8;\n const bytesPerStringSize = 4;\n const stringsArray: string[] = [];\n\n try {\n // Use DataView to avoid multiple of 4 error on Uint32Array constructor\n const stringsCount = new DataView(\n arrayBuffer,\n stringsCountOffset,\n bytesPerStringSize\n ).getUint32(stringsCountOffset, true);\n const stringSizes = new Uint32Array(arrayBuffer, dataOffset, stringsCount);\n let stringOffset = dataOffset + stringsCount * bytesPerStringSize;\n\n for (const stringByteSize of stringSizes) {\n const textDecoder = new TextDecoder('utf-8');\n const stringAttribute = new Uint8Array(arrayBuffer, stringOffset, stringByteSize);\n stringsArray.push(textDecoder.decode(stringAttribute));\n stringOffset += stringByteSize;\n }\n } catch (error) {\n console.error('Parse string attribute error: ', (error as Error).message); // eslint-disable-line\n }\n\n return stringsArray;\n}\n"],"mappings":"SAMEA,qBAAqB,EACrBC,wBAAwB,EACxBC,aAAa,EACbC,qBAAqB;AAYvB,OAAO,SAASC,qBAAqBA,CAACC,WAAwB,EAAEC,OAAO,EAAqB;EAC1F,MAAM;IAACC,aAAa;IAAEC;EAAa,CAAC,GAAGF,OAAO;EAE9C,IAAI,CAACC,aAAa,EAAE;IAClB,OAAO,CAAC,CAAC;EACX;EACA,OAAO;IACL,CAACA,aAAa,GAAGC,aAAa,GAAGC,cAAc,CAACD,aAAa,EAAEH,WAAW,CAAC,GAAG;EAChF,CAAC;AACH;AAQA,SAASI,cAAcA,CAACD,aAAa,EAAEH,WAAwB,EAAa;EAC1E,QAAQG,aAAa;IACnB,KAAKR,qBAAqB;MACxB,OAAOU,qBAAqB,CAACL,WAAW,CAAC;IAC3C,KAAKJ,wBAAwB;MAC3B,OAAOU,yBAAyB,CAACN,WAAW,CAAC;IAC/C,KAAKH,aAAa;M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ACW,IAAI,CAACJ,WAAW,CAACK,MAAM,CAACH,eAAe,CAAC,CAAC;MACtDJ,YAAY,IAAIC,cAAc;IAChC;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,gCAAgC,EAAGA,KAAK,CAAWE,OAAO,CAAC;EAC3E;EAEA,OAAOf,YAAY;AACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-i3s-tile-content.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAE,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AAKxF,OAAO,EAQL,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-i3s-tile-content.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAE,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AAKxF,OAAO,EAQL,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAwBrB,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,cAAc,EAC3B,cAAc,EAAE,iBAAiB,EACjC,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,cAAc,CAAC,CA6DzB"}
|
|
@@ -8,7 +8,6 @@ import { BasisLoader, CompressedTextureLoader } from '@loaders.gl/textures';
|
|
|
8
8
|
import { HeaderAttributeProperty } from "../../types.js";
|
|
9
9
|
import { getUrlWithToken } from "../utils/url-utils.js";
|
|
10
10
|
import { GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM } from "./constants.js";
|
|
11
|
-
import { customizeColors } from "../utils/customize-\u0441olors.js";
|
|
12
11
|
const scratchVector = new Vector3([0, 0, 0]);
|
|
13
12
|
function getLoaderForTextureFormat(textureFormat) {
|
|
14
13
|
switch (textureFormat) {
|
|
@@ -39,8 +38,8 @@ export async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptio
|
|
|
39
38
|
var _options$i3s;
|
|
40
39
|
const url = getUrlWithToken(tileOptions.textureUrl, options === null || options === void 0 ? void 0 : (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
41
40
|
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
42
|
-
const
|
|
43
|
-
const response = await
|
|
41
|
+
const fetchFunc = (context === null || context === void 0 ? void 0 : context.fetch) || fetch;
|
|
42
|
+
const response = await fetchFunc(url);
|
|
44
43
|
const arrayBuffer = await response.arrayBuffer();
|
|
45
44
|
if (options !== null && options !== void 0 && options.i3s.decodeTextures) {
|
|
46
45
|
if (loader === ImageLoader) {
|
|
@@ -147,7 +146,6 @@ async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOp
|
|
|
147
146
|
content.modelMatrix = getModelMatrix(attributes.position);
|
|
148
147
|
content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;
|
|
149
148
|
}
|
|
150
|
-
attributes.color = await customizeColors(attributes.color, attributes.id, tileOptions, tilesetOptions, options);
|
|
151
149
|
content.attributes = {
|
|
152
150
|
positions: attributes.position,
|
|
153
151
|
normals: attributes.normal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-i3s-tile-content.js","names":["load","parse","Vector3","Matrix4","Ellipsoid","parseFromContext","ImageLoader","DracoLoader","BasisLoader","CompressedTextureLoader","HeaderAttributeProperty","getUrlWithToken","GL_TYPE_MAP","getConstructorForDataFormat","sizeOf","COORDINATE_SYSTEM","customizeColors","scratchVector","getLoaderForTextureFormat","textureFormat","I3S_ATTRIBUTE_TYPE","parseI3STileContent","arrayBuffer","tileOptions","tilesetOptions","options","context","content","attributes","indices","featureIds","vertexCount","modelMatrix","coordinateSystem","byteLength","texture","textureUrl","_options$i3s","url","i3s","token","loader","fetch","response","decodeTextures","textureLoaderOptions","image","type","e","compressed","mipmaps","width","height","data","material","makePbrMaterial","materialDefinition","parseI3SNodeGeometry","_options$i3s2","contentByteLength","byteOffset","featureCount","isDracoGeometry","_decompressedGeometry","decompressedGeometry","draco","attributeNameEntry","header","value","POSITION","NORMAL","COLOR_0","TEXCOORD_0","featureIndex","uvRegion","position","normal","color","uv0","id","updateAttributesMetadata","getFeatureIdsFromFeatureIndexMetadata","flattenFeatureIdsByFeatureIndices","vertexAttributes","ordering","attributesOrder","featureAttributes","featureAttributeOrder","store","defaultGeometrySchema","headers","parseHeaders","normalizedVertexAttributes","offset","normalizeAttributes","normalizedFeatureAttributes","flattenFeatureIdsByFaceRanges","concatAttributes","METER_OFFSETS","enuMatrix","parsePositions","invert","getModelMatrix","LNGLAT_OFFSETS","positions","normals","colors","normalizeAttribute","texCoords","uvRegions","region","attributeIndex","key","loaderData","dracoAttribute","name","metadata","attribute","normalized","property","TypedArrayTypeHeader","attributeCount","valueType","valuesPerElement","buffer","slice","parseUint64Values","TypedArrayType","size","elementsCount","attributeSize","values","dataView","DataView","index","left","getUint32","right","push","Uint32Array","mbs","cartographicOrigin","cartesianOrigin","WGS84","cartographicToCartesian","eastNorthUpToFixedFrame","offsetsToCartesians","vertices","arguments","length","undefined","Float64Array","scaleX","double","scaleY","i","x","y","z","subarray","_metadata$i3sScale_x","_metadata$i3sScale_y","pbrMaterial","pbrMetallicRoughness","baseColorFactor","baseColorTexture","texCoord","alphaCutoff","alphaMode","toUpperCase","emissiveFactor","convertColorFormat","setMaterialTexture","colorFactor","normalizedColor","source","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","faceRange","range","featureIdsLength","orderedFeatureIndices","startIndex","fillId","Number","endValue","prevValue","trianglesCount","endIndex","fill","featureIndices","result","Float32Array","_featureIndex$metadat","_featureIndex$metadat2","intArray"],"sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\nimport {load, parse} from '@loaders.gl/core';\nimport {Vector3, Matrix4} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {LoaderOptions, LoaderContext, parseFromContext} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {DracoLoader, DracoMesh} from '@loaders.gl/draco';\nimport {BasisLoader, CompressedTextureLoader} from '@loaders.gl/textures';\n\nimport {\n FeatureAttribute,\n VertexAttribute,\n I3SMeshAttributes,\n I3SMeshAttribute,\n TileContentTexture,\n HeaderAttributeProperty,\n I3SMaterialDefinition,\n I3STileContent,\n I3STileOptions,\n I3STilesetOptions\n} from '../../types';\nimport {getUrlWithToken} from '../utils/url-utils';\n\nimport {GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM} from './constants';\nimport {I3SLoaderOptions} from '../../i3s-loader';\nimport {customizeColors} from '../utils/customize-сolors';\n\nconst scratchVector = new Vector3([0, 0, 0]);\n\nfunction getLoaderForTextureFormat(textureFormat?: 'jpg' | 'png' | 'ktx-etc2' | 'dds' | 'ktx2') {\n switch (textureFormat) {\n case 'ktx-etc2':\n case 'dds':\n return CompressedTextureLoader;\n case 'ktx2':\n return BasisLoader;\n case 'jpg':\n case 'png':\n default:\n return ImageLoader;\n }\n}\n\nconst I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';\n\nexport async function parseI3STileContent(\n arrayBuffer: ArrayBuffer,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n): Promise<I3STileContent> {\n const content: I3STileContent = {\n attributes: {},\n indices: null,\n featureIds: [],\n vertexCount: 0,\n modelMatrix: new Matrix4(),\n coordinateSystem: 0,\n byteLength: 0,\n texture: null\n };\n\n if (tileOptions.textureUrl) {\n // @ts-expect-error options is not properly typed\n const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);\n const loader = getLoaderForTextureFormat(tileOptions.textureFormat);\n const fetch = context?.fetch!; // Options already resolved?\n const response = await fetch(url); // options?.fetch\n const arrayBuffer = await response.arrayBuffer();\n\n // @ts-expect-error options is not properly typed\n if (options?.i3s.decodeTextures) {\n // TODO - replace with switch\n if (loader === ImageLoader) {\n const options = {...tileOptions.textureLoaderOptions, image: {type: 'data'}};\n try {\n // Image constructor is not supported in worker thread.\n // Do parsing image data on the main thread by using context to avoid worker issues.\n const texture = await parseFromContext(arrayBuffer, [], options, context!);\n // @ts-expect-error\n content.texture = texture;\n } catch (e) {\n // context object is different between worker and node.js conversion script.\n // To prevent error we parse data in ordinary way if it is not parsed by using context.\n const texture = await parse(arrayBuffer, loader, options, context);\n content.texture = texture;\n }\n } else if (loader === CompressedTextureLoader || loader === BasisLoader) {\n let texture = await load(arrayBuffer, loader, tileOptions.textureLoaderOptions);\n if (loader === BasisLoader) {\n texture = texture[0];\n }\n content.texture = {\n compressed: true,\n mipmaps: false,\n width: texture[0].width,\n height: texture[0].height,\n data: texture\n };\n }\n } else {\n content.texture = arrayBuffer;\n }\n }\n\n content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);\n if (content.material) {\n content.texture = null;\n }\n\n return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);\n}\n\n/* eslint-disable max-statements */\nasync function parseI3SNodeGeometry(\n arrayBuffer: ArrayBuffer,\n content: I3STileContent,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<I3STileContent> {\n const contentByteLength = arrayBuffer.byteLength;\n let attributes: I3SMeshAttributes;\n let vertexCount: number;\n let byteOffset: number = 0;\n let featureCount: number = 0;\n let indices: TypedArray | undefined;\n\n if (tileOptions.isDracoGeometry) {\n const decompressedGeometry: DracoMesh = await parse(arrayBuffer, DracoLoader, {\n draco: {\n attributeNameEntry: I3S_ATTRIBUTE_TYPE\n }\n });\n // @ts-expect-error\n vertexCount = decompressedGeometry.header.vertexCount;\n indices = decompressedGeometry.indices?.value;\n const {\n POSITION,\n NORMAL,\n COLOR_0,\n TEXCOORD_0,\n ['feature-index']: featureIndex,\n ['uv-region']: uvRegion\n } = decompressedGeometry.attributes;\n\n attributes = {\n position: POSITION,\n normal: NORMAL,\n color: COLOR_0,\n uv0: TEXCOORD_0,\n uvRegion,\n id: featureIndex\n };\n\n updateAttributesMetadata(attributes, decompressedGeometry);\n\n const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);\n\n if (featureIds) {\n flattenFeatureIdsByFeatureIndices(attributes, featureIds);\n }\n } else {\n const {\n vertexAttributes,\n ordering: attributesOrder,\n featureAttributes,\n featureAttributeOrder\n } = tilesetOptions.store.defaultGeometrySchema;\n // First 8 bytes reserved for header (vertexCount and featureCount)\n const headers = parseHeaders(arrayBuffer, tilesetOptions);\n byteOffset = headers.byteOffset;\n vertexCount = headers.vertexCount;\n featureCount = headers.featureCount;\n // Getting vertex attributes such as positions, normals, colors, etc...\n const {attributes: normalizedVertexAttributes, byteOffset: offset} = normalizeAttributes(\n arrayBuffer,\n byteOffset,\n vertexAttributes,\n vertexCount,\n attributesOrder\n );\n\n // Getting feature attributes such as featureIds and faceRange\n const {attributes: normalizedFeatureAttributes} = normalizeAttributes(\n arrayBuffer,\n offset,\n featureAttributes,\n featureCount,\n featureAttributeOrder\n );\n\n flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);\n attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);\n }\n\n if (\n !options?.i3s?.coordinateSystem ||\n options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS\n ) {\n const enuMatrix = parsePositions(attributes.position, tileOptions);\n content.modelMatrix = enuMatrix.invert();\n content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;\n } else {\n content.modelMatrix = getModelMatrix(attributes.position);\n content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;\n }\n\n attributes.color = await customizeColors(\n attributes.color,\n attributes.id,\n tileOptions,\n tilesetOptions,\n options\n );\n\n content.attributes = {\n positions: attributes.position,\n normals: attributes.normal,\n colors: normalizeAttribute(attributes.color), // Normalize from UInt8\n texCoords: attributes.uv0,\n uvRegions: normalizeAttribute(attributes.uvRegion || attributes.region) // Normalize from UInt16\n };\n content.indices = indices || null;\n\n if (attributes.id && attributes.id.value) {\n content.featureIds = attributes.id.value;\n }\n\n // Remove undefined attributes\n for (const attributeIndex in content.attributes) {\n if (!content.attributes[attributeIndex]) {\n delete content.attributes[attributeIndex];\n }\n }\n\n content.vertexCount = vertexCount;\n content.byteLength = contentByteLength;\n\n return content;\n}\n\n/**\n * Update attributes with metadata from decompressed geometry.\n * @param decompressedGeometry\n * @param attributes\n */\nfunction updateAttributesMetadata(\n attributes: I3SMeshAttributes,\n decompressedGeometry: DracoMesh\n): void {\n for (const key in decompressedGeometry.loaderData.attributes) {\n const dracoAttribute = decompressedGeometry.loaderData.attributes[key];\n\n switch (dracoAttribute.name) {\n case 'POSITION':\n attributes.position.metadata = dracoAttribute.metadata;\n break;\n case 'feature-index':\n attributes.id.metadata = dracoAttribute.metadata;\n break;\n default:\n break;\n }\n }\n}\n\n/**\n * Do concatenation of attribute objects.\n * Done as separate fucntion to avoid ts errors.\n * @param normalizedVertexAttributes\n * @param normalizedFeatureAttributes\n * @returns - result of attributes concatenation.\n */\nfunction concatAttributes(\n normalizedVertexAttributes: I3SMeshAttributes,\n normalizedFeatureAttributes: I3SMeshAttributes\n): I3SMeshAttributes {\n return {...normalizedVertexAttributes, ...normalizedFeatureAttributes};\n}\n\n/**\n * Normalize attribute to range [0..1] . Eg. convert colors buffer from [255,255,255,255] to [1,1,1,1]\n * @param attribute - geometry attribute\n * @returns - geometry attribute in right format\n */\nfunction normalizeAttribute(attribute: I3SMeshAttribute): I3SMeshAttribute {\n if (!attribute) {\n return attribute;\n }\n attribute.normalized = true;\n return attribute;\n}\n\nfunction parseHeaders(arrayBuffer: ArrayBuffer, options: I3STilesetOptions) {\n let byteOffset = 0;\n // First 8 bytes reserved for header (vertexCount and featurecount)\n let vertexCount = 0;\n let featureCount = 0;\n for (const {property, type} of options.store.defaultGeometrySchema.header) {\n const TypedArrayTypeHeader = getConstructorForDataFormat(type);\n switch (property) {\n case HeaderAttributeProperty.vertexCount:\n vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];\n byteOffset += sizeOf(type);\n break;\n case HeaderAttributeProperty.featureCount:\n featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];\n byteOffset += sizeOf(type);\n break;\n default:\n break;\n }\n }\n\n return {\n vertexCount,\n featureCount,\n byteOffset\n };\n}\n\n/* eslint-enable max-statements */\n\nfunction normalizeAttributes(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n vertexAttributes: VertexAttribute | FeatureAttribute,\n attributeCount: number,\n attributesOrder: string[]\n) {\n const attributes: I3SMeshAttributes = {};\n\n // the order of attributes depend on the order being added to the vertexAttributes object\n for (const attribute of attributesOrder) {\n if (vertexAttributes[attribute]) {\n const {valueType, valuesPerElement}: {valueType: string; valuesPerElement: number} =\n vertexAttributes[attribute];\n // protect from arrayBuffer read overunns by NOT assuming node has regions always even though its declared in defaultGeometrySchema.\n // In i3s 1.6: client is required to decide that based on ./shared resource of the node (materialDefinitions.[Mat_id].params.vertexRegions == true)\n // In i3s 1.7 the property has been rolled into the 3d scene layer json/node pages.\n // Code below does not account when the bytelength is actually bigger than\n // the calculated value (b\\c the tile potentially could have mesh segmentation information).\n // In those cases tiles without regions could fail or have garbage values.\n if (\n byteOffset + attributeCount * valuesPerElement * sizeOf(valueType) <=\n arrayBuffer.byteLength\n ) {\n const buffer = arrayBuffer.slice(byteOffset);\n let value: TypedArray;\n\n if (valueType === 'UInt64') {\n value = parseUint64Values(buffer, attributeCount * valuesPerElement, sizeOf(valueType));\n } else {\n const TypedArrayType = getConstructorForDataFormat(valueType);\n value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);\n }\n\n attributes[attribute] = {\n value,\n type: GL_TYPE_MAP[valueType],\n size: valuesPerElement\n };\n\n switch (attribute) {\n case 'color':\n attributes.color.normalized = true;\n break;\n case 'position':\n case 'region':\n case 'normal':\n default:\n }\n\n byteOffset = byteOffset + attributeCount * valuesPerElement * sizeOf(valueType);\n } else if (attribute !== 'uv0') {\n break;\n }\n }\n }\n\n return {attributes, byteOffset};\n}\n\n/**\n * Parse buffer to return array of uint64 values\n *\n * @param buffer\n * @param elementsCount\n * @returns 64-bit array of values until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Values(\n buffer: ArrayBuffer,\n elementsCount: number,\n attributeSize: number\n): Uint32Array {\n const values: number[] = [];\n const dataView = new DataView(buffer);\n let offset = 0;\n\n for (let index = 0; index < elementsCount; index++) {\n // split 64-bit number into two 32-bit parts\n const left = dataView.getUint32(offset, true);\n const right = dataView.getUint32(offset + 4, true);\n // combine the two 32-bit values\n const value = left + 2 ** 32 * right;\n\n values.push(value);\n offset += attributeSize;\n }\n\n return new Uint32Array(values);\n}\n\nfunction parsePositions(attribute: I3SMeshAttribute, options: I3STileOptions): Matrix4 {\n const mbs = options.mbs;\n const value = attribute.value;\n const metadata = attribute.metadata;\n const enuMatrix = new Matrix4();\n const cartographicOrigin = new Vector3(mbs[0], mbs[1], mbs[2]);\n const cartesianOrigin = new Vector3();\n Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);\n attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);\n\n return enuMatrix;\n}\n\n/**\n * Converts position coordinates to absolute cartesian coordinates\n * @param vertices - \"position\" attribute data\n * @param metadata - When the geometry is DRACO compressed, contain position attribute's metadata\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/compressedAttributes.cmn.md\n * @param cartographicOrigin - Cartographic origin coordinates\n * @returns - converted \"position\" data\n */\nfunction offsetsToCartesians(\n vertices: number[] | TypedArray,\n metadata: any = {},\n cartographicOrigin: Vector3\n): Float64Array {\n const positions = new Float64Array(vertices.length);\n const scaleX = (metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double) || 1;\n const scaleY = (metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double) || 1;\n for (let i = 0; i < positions.length; i += 3) {\n positions[i] = vertices[i] * scaleX + cartographicOrigin.x;\n positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;\n positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;\n }\n\n for (let i = 0; i < positions.length; i += 3) {\n // @ts-ignore\n Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);\n positions[i] = scratchVector.x;\n positions[i + 1] = scratchVector.y;\n positions[i + 2] = scratchVector.z;\n }\n\n return positions;\n}\n\n/**\n * Get model matrix for loaded vertices\n * @param positions positions attribute\n * @returns Matrix4 - model matrix for geometry transformation\n */\nfunction getModelMatrix(positions: I3SMeshAttribute): Matrix4 {\n const metadata = positions.metadata;\n const scaleX: number = metadata?.['i3s-scale_x']?.double || 1;\n const scaleY: number = metadata?.['i3s-scale_y']?.double || 1;\n const modelMatrix = new Matrix4();\n modelMatrix[0] = scaleX;\n modelMatrix[5] = scaleY;\n return modelMatrix;\n}\n\n/**\n * Makes a glTF-compatible PBR material from an I3S material definition\n * @param materialDefinition - i3s material definition\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n * @param texture - texture image\n * @returns {object}\n */\nfunction makePbrMaterial(materialDefinition?: I3SMaterialDefinition, texture?: TileContentTexture) {\n let pbrMaterial;\n if (materialDefinition) {\n pbrMaterial = {\n ...materialDefinition,\n pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness\n ? {...materialDefinition.pbrMetallicRoughness}\n : {baseColorFactor: [255, 255, 255, 255]}\n };\n } else {\n pbrMaterial = {\n pbrMetallicRoughness: {}\n };\n if (texture) {\n pbrMaterial.pbrMetallicRoughness.baseColorTexture = {texCoord: 0};\n } else {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = [255, 255, 255, 255];\n }\n }\n\n // Set default 0.25 per spec https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;\n\n if (pbrMaterial.alphaMode) {\n // I3S contain alphaMode in lowerCase\n pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();\n }\n\n // Convert colors from [255,255,255,255] to [1,1,1,1]\n if (pbrMaterial.emissiveFactor) {\n pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);\n }\n if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(\n pbrMaterial.pbrMetallicRoughness.baseColorFactor\n );\n }\n\n if (texture) {\n setMaterialTexture(pbrMaterial, texture);\n }\n\n return pbrMaterial;\n}\n\n/**\n * Convert color from [255,255,255,255] to [1,1,1,1]\n * @param colorFactor - color array\n * @returns - new color array\n */\nfunction convertColorFormat(colorFactor: number[]): number[] {\n const normalizedColor = [...colorFactor];\n for (let index = 0; index < colorFactor.length; index++) {\n normalizedColor[index] = colorFactor[index] / 255;\n }\n return normalizedColor;\n}\n\n/**\n * Set texture in PBR material\n * @param {object} material - i3s material definition\n * @param image - texture image\n * @returns\n */\nfunction setMaterialTexture(material, image: TileContentTexture): void {\n const texture = {source: {image}};\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {\n material.pbrMetallicRoughness.baseColorTexture = {\n ...material.pbrMetallicRoughness.baseColorTexture,\n texture\n };\n } else if (material.emissiveTexture) {\n material.emissiveTexture = {...material.emissiveTexture, texture};\n } else if (\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n ...material.pbrMetallicRoughness.metallicRoughnessTexture,\n texture\n };\n } else if (material.normalTexture) {\n material.normalTexture = {...material.normalTexture, texture};\n } else if (material.occlusionTexture) {\n material.occlusionTexture = {...material.occlusionTexture, texture};\n }\n}\n\n/**\n * Flatten feature ids using face ranges\n * @param normalizedFeatureAttributes\n * @returns\n */\nfunction flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes: I3SMeshAttributes): void {\n const {id, faceRange} = normalizedFeatureAttributes;\n\n if (!id || !faceRange) {\n return;\n }\n\n const featureIds = id.value;\n const range = faceRange.value;\n const featureIdsLength = range[range.length - 1] + 1;\n const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);\n\n let featureIndex = 0;\n let startIndex = 0;\n\n for (let index = 1; index < range.length; index += 2) {\n const fillId = Number(featureIds[featureIndex]);\n const endValue = range[index];\n const prevValue = range[index - 1];\n const trianglesCount = endValue - prevValue + 1;\n const endIndex = startIndex + trianglesCount * 3;\n\n orderedFeatureIndices.fill(fillId, startIndex, endIndex);\n\n featureIndex++;\n startIndex = endIndex;\n }\n\n normalizedFeatureAttributes.id.value = orderedFeatureIndices;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param attributes\n * @param featureIds\n * @returns\n */\nfunction flattenFeatureIdsByFeatureIndices(\n attributes: I3SMeshAttributes,\n featureIds: Int32Array\n): void {\n const featureIndices = attributes.id.value;\n const result = new Float32Array(featureIndices.length);\n\n for (let index = 0; index < featureIndices.length; index++) {\n result[index] = featureIds[featureIndices[index]];\n }\n\n attributes.id.value = result;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param featureIndex\n * @returns\n */\nfunction getFeatureIdsFromFeatureIndexMetadata(\n featureIndex: I3SMeshAttribute\n): Int32Array | undefined {\n return featureIndex?.metadata?.['i3s-feature-ids']?.intArray;\n}\n"],"mappings":"AACA,SAAQA,IAAI,EAAEC,KAAK,QAAO,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aAAZA,YAAY,wBAAA0H,qBAAA,GAAZ1H,YAAY,CAAE2C,QAAQ,cAAA+E,qBAAA,wBAAAC,sBAAA,GAAtBD,qBAAA,CAAyB,iBAAiB,CAAC,cAAAC,sBAAA,uBAA3CA,sBAAA,CAA6CC,QAAQ;AAC9D"}
|
|
1
|
+
{"version":3,"file":"parse-i3s-tile-content.js","names":["load","parse","Vector3","Matrix4","Ellipsoid","parseFromContext","ImageLoader","DracoLoader","BasisLoader","CompressedTextureLoader","HeaderAttributeProperty","getUrlWithToken","GL_TYPE_MAP","getConstructorForDataFormat","sizeOf","COORDINATE_SYSTEM","scratchVector","getLoaderForTextureFormat","textureFormat","I3S_ATTRIBUTE_TYPE","parseI3STileContent","arrayBuffer","tileOptions","tilesetOptions","options","context","content","attributes","indices","featureIds","vertexCount","modelMatrix","coordinateSystem","byteLength","texture","textureUrl","_options$i3s","url","i3s","token","loader","fetchFunc","fetch","response","decodeTextures","textureLoaderOptions","image","type","e","compressed","mipmaps","width","height","data","material","makePbrMaterial","materialDefinition","parseI3SNodeGeometry","_options$i3s2","contentByteLength","byteOffset","featureCount","isDracoGeometry","_decompressedGeometry","decompressedGeometry","draco","attributeNameEntry","header","value","POSITION","NORMAL","COLOR_0","TEXCOORD_0","featureIndex","uvRegion","position","normal","color","uv0","id","updateAttributesMetadata","getFeatureIdsFromFeatureIndexMetadata","flattenFeatureIdsByFeatureIndices","vertexAttributes","ordering","attributesOrder","featureAttributes","featureAttributeOrder","store","defaultGeometrySchema","headers","parseHeaders","normalizedVertexAttributes","offset","normalizeAttributes","normalizedFeatureAttributes","flattenFeatureIdsByFaceRanges","concatAttributes","METER_OFFSETS","enuMatrix","parsePositions","invert","getModelMatrix","LNGLAT_OFFSETS","positions","normals","colors","normalizeAttribute","texCoords","uvRegions","region","attributeIndex","key","loaderData","dracoAttribute","name","metadata","attribute","normalized","property","TypedArrayTypeHeader","attributeCount","valueType","valuesPerElement","buffer","slice","parseUint64Values","TypedArrayType","size","elementsCount","attributeSize","values","dataView","DataView","index","left","getUint32","right","push","Uint32Array","mbs","cartographicOrigin","cartesianOrigin","WGS84","cartographicToCartesian","eastNorthUpToFixedFrame","offsetsToCartesians","vertices","arguments","length","undefined","Float64Array","scaleX","double","scaleY","i","x","y","z","subarray","_metadata$i3sScale_x","_metadata$i3sScale_y","pbrMaterial","pbrMetallicRoughness","baseColorFactor","baseColorTexture","texCoord","alphaCutoff","alphaMode","toUpperCase","emissiveFactor","convertColorFormat","setMaterialTexture","colorFactor","normalizedColor","source","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","faceRange","range","featureIdsLength","orderedFeatureIndices","startIndex","fillId","Number","endValue","prevValue","trianglesCount","endIndex","fill","featureIndices","result","Float32Array","_featureIndex$metadat","_featureIndex$metadat2","intArray"],"sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\nimport {load, parse} from '@loaders.gl/core';\nimport {Vector3, Matrix4} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {LoaderOptions, LoaderContext, parseFromContext} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {DracoLoader, DracoMesh} from '@loaders.gl/draco';\nimport {BasisLoader, CompressedTextureLoader} from '@loaders.gl/textures';\n\nimport {\n FeatureAttribute,\n VertexAttribute,\n I3SMeshAttributes,\n I3SMeshAttribute,\n TileContentTexture,\n HeaderAttributeProperty,\n I3SMaterialDefinition,\n I3STileContent,\n I3STileOptions,\n I3STilesetOptions\n} from '../../types';\nimport {getUrlWithToken} from '../utils/url-utils';\n\nimport {GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM} from './constants';\nimport {I3SLoaderOptions} from '../../i3s-loader';\n\nconst scratchVector = new Vector3([0, 0, 0]);\n\nfunction getLoaderForTextureFormat(textureFormat?: 'jpg' | 'png' | 'ktx-etc2' | 'dds' | 'ktx2') {\n switch (textureFormat) {\n case 'ktx-etc2':\n case 'dds':\n return CompressedTextureLoader;\n case 'ktx2':\n return BasisLoader;\n case 'jpg':\n case 'png':\n default:\n return ImageLoader;\n }\n}\n\nconst I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';\n\nexport async function parseI3STileContent(\n arrayBuffer: ArrayBuffer,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n): Promise<I3STileContent> {\n const content: I3STileContent = {\n attributes: {},\n indices: null,\n featureIds: [],\n vertexCount: 0,\n modelMatrix: new Matrix4(),\n coordinateSystem: 0,\n byteLength: 0,\n texture: null\n };\n\n if (tileOptions.textureUrl) {\n // @ts-expect-error options is not properly typed\n const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);\n const loader = getLoaderForTextureFormat(tileOptions.textureFormat);\n const fetchFunc = context?.fetch || fetch;\n const response = await fetchFunc(url); // options?.fetch\n const arrayBuffer = await response.arrayBuffer();\n\n // @ts-expect-error options is not properly typed\n if (options?.i3s.decodeTextures) {\n // TODO - replace with switch\n if (loader === ImageLoader) {\n const options = {...tileOptions.textureLoaderOptions, image: {type: 'data'}};\n try {\n // Image constructor is not supported in worker thread.\n // Do parsing image data on the main thread by using context to avoid worker issues.\n const texture = await parseFromContext(arrayBuffer, [], options, context!);\n // @ts-expect-error\n content.texture = texture;\n } catch (e) {\n // context object is different between worker and node.js conversion script.\n // To prevent error we parse data in ordinary way if it is not parsed by using context.\n const texture = await parse(arrayBuffer, loader, options, context);\n content.texture = texture;\n }\n } else if (loader === CompressedTextureLoader || loader === BasisLoader) {\n let texture = await load(arrayBuffer, loader, tileOptions.textureLoaderOptions);\n if (loader === BasisLoader) {\n texture = texture[0];\n }\n content.texture = {\n compressed: true,\n mipmaps: false,\n width: texture[0].width,\n height: texture[0].height,\n data: texture\n };\n }\n } else {\n content.texture = arrayBuffer;\n }\n }\n\n content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);\n if (content.material) {\n content.texture = null;\n }\n\n return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);\n}\n\n/* eslint-disable max-statements */\nasync function parseI3SNodeGeometry(\n arrayBuffer: ArrayBuffer,\n content: I3STileContent,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: I3SLoaderOptions\n): Promise<I3STileContent> {\n const contentByteLength = arrayBuffer.byteLength;\n let attributes: I3SMeshAttributes;\n let vertexCount: number;\n let byteOffset: number = 0;\n let featureCount: number = 0;\n let indices: TypedArray | undefined;\n\n if (tileOptions.isDracoGeometry) {\n const decompressedGeometry: DracoMesh = await parse(arrayBuffer, DracoLoader, {\n draco: {\n attributeNameEntry: I3S_ATTRIBUTE_TYPE\n }\n });\n // @ts-expect-error\n vertexCount = decompressedGeometry.header.vertexCount;\n indices = decompressedGeometry.indices?.value;\n const {\n POSITION,\n NORMAL,\n COLOR_0,\n TEXCOORD_0,\n ['feature-index']: featureIndex,\n ['uv-region']: uvRegion\n } = decompressedGeometry.attributes;\n\n attributes = {\n position: POSITION,\n normal: NORMAL,\n color: COLOR_0,\n uv0: TEXCOORD_0,\n uvRegion,\n id: featureIndex\n };\n\n updateAttributesMetadata(attributes, decompressedGeometry);\n\n const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);\n\n if (featureIds) {\n flattenFeatureIdsByFeatureIndices(attributes, featureIds);\n }\n } else {\n const {\n vertexAttributes,\n ordering: attributesOrder,\n featureAttributes,\n featureAttributeOrder\n } = tilesetOptions.store.defaultGeometrySchema;\n // First 8 bytes reserved for header (vertexCount and featureCount)\n const headers = parseHeaders(arrayBuffer, tilesetOptions);\n byteOffset = headers.byteOffset;\n vertexCount = headers.vertexCount;\n featureCount = headers.featureCount;\n // Getting vertex attributes such as positions, normals, colors, etc...\n const {attributes: normalizedVertexAttributes, byteOffset: offset} = normalizeAttributes(\n arrayBuffer,\n byteOffset,\n vertexAttributes,\n vertexCount,\n attributesOrder\n );\n\n // Getting feature attributes such as featureIds and faceRange\n const {attributes: normalizedFeatureAttributes} = normalizeAttributes(\n arrayBuffer,\n offset,\n featureAttributes,\n featureCount,\n featureAttributeOrder\n );\n\n flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);\n attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);\n }\n\n if (\n !options?.i3s?.coordinateSystem ||\n options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS\n ) {\n const enuMatrix = parsePositions(attributes.position, tileOptions);\n content.modelMatrix = enuMatrix.invert();\n content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;\n } else {\n content.modelMatrix = getModelMatrix(attributes.position);\n content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;\n }\n\n content.attributes = {\n positions: attributes.position,\n normals: attributes.normal,\n colors: normalizeAttribute(attributes.color), // Normalize from UInt8\n texCoords: attributes.uv0,\n uvRegions: normalizeAttribute(attributes.uvRegion || attributes.region) // Normalize from UInt16\n };\n content.indices = indices || null;\n\n if (attributes.id && attributes.id.value) {\n content.featureIds = attributes.id.value;\n }\n\n // Remove undefined attributes\n for (const attributeIndex in content.attributes) {\n if (!content.attributes[attributeIndex]) {\n delete content.attributes[attributeIndex];\n }\n }\n\n content.vertexCount = vertexCount;\n content.byteLength = contentByteLength;\n\n return content;\n}\n\n/**\n * Update attributes with metadata from decompressed geometry.\n * @param decompressedGeometry\n * @param attributes\n */\nfunction updateAttributesMetadata(\n attributes: I3SMeshAttributes,\n decompressedGeometry: DracoMesh\n): void {\n for (const key in decompressedGeometry.loaderData.attributes) {\n const dracoAttribute = decompressedGeometry.loaderData.attributes[key];\n\n switch (dracoAttribute.name) {\n case 'POSITION':\n attributes.position.metadata = dracoAttribute.metadata;\n break;\n case 'feature-index':\n attributes.id.metadata = dracoAttribute.metadata;\n break;\n default:\n break;\n }\n }\n}\n\n/**\n * Do concatenation of attribute objects.\n * Done as separate fucntion to avoid ts errors.\n * @param normalizedVertexAttributes\n * @param normalizedFeatureAttributes\n * @returns - result of attributes concatenation.\n */\nfunction concatAttributes(\n normalizedVertexAttributes: I3SMeshAttributes,\n normalizedFeatureAttributes: I3SMeshAttributes\n): I3SMeshAttributes {\n return {...normalizedVertexAttributes, ...normalizedFeatureAttributes};\n}\n\n/**\n * Normalize attribute to range [0..1] . Eg. convert colors buffer from [255,255,255,255] to [1,1,1,1]\n * @param attribute - geometry attribute\n * @returns - geometry attribute in right format\n */\nfunction normalizeAttribute(attribute: I3SMeshAttribute): I3SMeshAttribute {\n if (!attribute) {\n return attribute;\n }\n attribute.normalized = true;\n return attribute;\n}\n\nfunction parseHeaders(arrayBuffer: ArrayBuffer, options: I3STilesetOptions) {\n let byteOffset = 0;\n // First 8 bytes reserved for header (vertexCount and featurecount)\n let vertexCount = 0;\n let featureCount = 0;\n for (const {property, type} of options.store.defaultGeometrySchema.header) {\n const TypedArrayTypeHeader = getConstructorForDataFormat(type);\n switch (property) {\n case HeaderAttributeProperty.vertexCount:\n vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];\n byteOffset += sizeOf(type);\n break;\n case HeaderAttributeProperty.featureCount:\n featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];\n byteOffset += sizeOf(type);\n break;\n default:\n break;\n }\n }\n\n return {\n vertexCount,\n featureCount,\n byteOffset\n };\n}\n\n/* eslint-enable max-statements */\n\nfunction normalizeAttributes(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n vertexAttributes: VertexAttribute | FeatureAttribute,\n attributeCount: number,\n attributesOrder: string[]\n) {\n const attributes: I3SMeshAttributes = {};\n\n // the order of attributes depend on the order being added to the vertexAttributes object\n for (const attribute of attributesOrder) {\n if (vertexAttributes[attribute]) {\n const {valueType, valuesPerElement}: {valueType: string; valuesPerElement: number} =\n vertexAttributes[attribute];\n // protect from arrayBuffer read overunns by NOT assuming node has regions always even though its declared in defaultGeometrySchema.\n // In i3s 1.6: client is required to decide that based on ./shared resource of the node (materialDefinitions.[Mat_id].params.vertexRegions == true)\n // In i3s 1.7 the property has been rolled into the 3d scene layer json/node pages.\n // Code below does not account when the bytelength is actually bigger than\n // the calculated value (b\\c the tile potentially could have mesh segmentation information).\n // In those cases tiles without regions could fail or have garbage values.\n if (\n byteOffset + attributeCount * valuesPerElement * sizeOf(valueType) <=\n arrayBuffer.byteLength\n ) {\n const buffer = arrayBuffer.slice(byteOffset);\n let value: TypedArray;\n\n if (valueType === 'UInt64') {\n value = parseUint64Values(buffer, attributeCount * valuesPerElement, sizeOf(valueType));\n } else {\n const TypedArrayType = getConstructorForDataFormat(valueType);\n value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);\n }\n\n attributes[attribute] = {\n value,\n type: GL_TYPE_MAP[valueType],\n size: valuesPerElement\n };\n\n switch (attribute) {\n case 'color':\n attributes.color.normalized = true;\n break;\n case 'position':\n case 'region':\n case 'normal':\n default:\n }\n\n byteOffset = byteOffset + attributeCount * valuesPerElement * sizeOf(valueType);\n } else if (attribute !== 'uv0') {\n break;\n }\n }\n }\n\n return {attributes, byteOffset};\n}\n\n/**\n * Parse buffer to return array of uint64 values\n *\n * @param buffer\n * @param elementsCount\n * @returns 64-bit array of values until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Values(\n buffer: ArrayBuffer,\n elementsCount: number,\n attributeSize: number\n): Uint32Array {\n const values: number[] = [];\n const dataView = new DataView(buffer);\n let offset = 0;\n\n for (let index = 0; index < elementsCount; index++) {\n // split 64-bit number into two 32-bit parts\n const left = dataView.getUint32(offset, true);\n const right = dataView.getUint32(offset + 4, true);\n // combine the two 32-bit values\n const value = left + 2 ** 32 * right;\n\n values.push(value);\n offset += attributeSize;\n }\n\n return new Uint32Array(values);\n}\n\nfunction parsePositions(attribute: I3SMeshAttribute, options: I3STileOptions): Matrix4 {\n const mbs = options.mbs;\n const value = attribute.value;\n const metadata = attribute.metadata;\n const enuMatrix = new Matrix4();\n const cartographicOrigin = new Vector3(mbs[0], mbs[1], mbs[2]);\n const cartesianOrigin = new Vector3();\n Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);\n attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);\n\n return enuMatrix;\n}\n\n/**\n * Converts position coordinates to absolute cartesian coordinates\n * @param vertices - \"position\" attribute data\n * @param metadata - When the geometry is DRACO compressed, contain position attribute's metadata\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/compressedAttributes.cmn.md\n * @param cartographicOrigin - Cartographic origin coordinates\n * @returns - converted \"position\" data\n */\nfunction offsetsToCartesians(\n vertices: number[] | TypedArray,\n metadata: any = {},\n cartographicOrigin: Vector3\n): Float64Array {\n const positions = new Float64Array(vertices.length);\n const scaleX = (metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double) || 1;\n const scaleY = (metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double) || 1;\n for (let i = 0; i < positions.length; i += 3) {\n positions[i] = vertices[i] * scaleX + cartographicOrigin.x;\n positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;\n positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;\n }\n\n for (let i = 0; i < positions.length; i += 3) {\n // @ts-ignore\n Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);\n positions[i] = scratchVector.x;\n positions[i + 1] = scratchVector.y;\n positions[i + 2] = scratchVector.z;\n }\n\n return positions;\n}\n\n/**\n * Get model matrix for loaded vertices\n * @param positions positions attribute\n * @returns Matrix4 - model matrix for geometry transformation\n */\nfunction getModelMatrix(positions: I3SMeshAttribute): Matrix4 {\n const metadata = positions.metadata;\n const scaleX: number = metadata?.['i3s-scale_x']?.double || 1;\n const scaleY: number = metadata?.['i3s-scale_y']?.double || 1;\n const modelMatrix = new Matrix4();\n modelMatrix[0] = scaleX;\n modelMatrix[5] = scaleY;\n return modelMatrix;\n}\n\n/**\n * Makes a glTF-compatible PBR material from an I3S material definition\n * @param materialDefinition - i3s material definition\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n * @param texture - texture image\n * @returns {object}\n */\nfunction makePbrMaterial(materialDefinition?: I3SMaterialDefinition, texture?: TileContentTexture) {\n let pbrMaterial;\n if (materialDefinition) {\n pbrMaterial = {\n ...materialDefinition,\n pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness\n ? {...materialDefinition.pbrMetallicRoughness}\n : {baseColorFactor: [255, 255, 255, 255]}\n };\n } else {\n pbrMaterial = {\n pbrMetallicRoughness: {}\n };\n if (texture) {\n pbrMaterial.pbrMetallicRoughness.baseColorTexture = {texCoord: 0};\n } else {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = [255, 255, 255, 255];\n }\n }\n\n // Set default 0.25 per spec https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;\n\n if (pbrMaterial.alphaMode) {\n // I3S contain alphaMode in lowerCase\n pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();\n }\n\n // Convert colors from [255,255,255,255] to [1,1,1,1]\n if (pbrMaterial.emissiveFactor) {\n pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);\n }\n if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(\n pbrMaterial.pbrMetallicRoughness.baseColorFactor\n );\n }\n\n if (texture) {\n setMaterialTexture(pbrMaterial, texture);\n }\n\n return pbrMaterial;\n}\n\n/**\n * Convert color from [255,255,255,255] to [1,1,1,1]\n * @param colorFactor - color array\n * @returns - new color array\n */\nfunction convertColorFormat(colorFactor: number[]): number[] {\n const normalizedColor = [...colorFactor];\n for (let index = 0; index < colorFactor.length; index++) {\n normalizedColor[index] = colorFactor[index] / 255;\n }\n return normalizedColor;\n}\n\n/**\n * Set texture in PBR material\n * @param {object} material - i3s material definition\n * @param image - texture image\n * @returns\n */\nfunction setMaterialTexture(material, image: TileContentTexture): void {\n const texture = {source: {image}};\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {\n material.pbrMetallicRoughness.baseColorTexture = {\n ...material.pbrMetallicRoughness.baseColorTexture,\n texture\n };\n } else if (material.emissiveTexture) {\n material.emissiveTexture = {...material.emissiveTexture, texture};\n } else if (\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n ...material.pbrMetallicRoughness.metallicRoughnessTexture,\n texture\n };\n } else if (material.normalTexture) {\n material.normalTexture = {...material.normalTexture, texture};\n } else if (material.occlusionTexture) {\n material.occlusionTexture = {...material.occlusionTexture, texture};\n }\n}\n\n/**\n * Flatten feature ids using face ranges\n * @param normalizedFeatureAttributes\n * @returns\n */\nfunction flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes: I3SMeshAttributes): void {\n const {id, faceRange} = normalizedFeatureAttributes;\n\n if (!id || !faceRange) {\n return;\n }\n\n const featureIds = id.value;\n const range = faceRange.value;\n const featureIdsLength = range[range.length - 1] + 1;\n const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);\n\n let featureIndex = 0;\n let startIndex = 0;\n\n for (let index = 1; index < range.length; index += 2) {\n const fillId = Number(featureIds[featureIndex]);\n const endValue = range[index];\n const prevValue = range[index - 1];\n const trianglesCount = endValue - prevValue + 1;\n const endIndex = startIndex + trianglesCount * 3;\n\n orderedFeatureIndices.fill(fillId, startIndex, endIndex);\n\n featureIndex++;\n startIndex = endIndex;\n }\n\n normalizedFeatureAttributes.id.value = orderedFeatureIndices;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param attributes\n * @param featureIds\n * @returns\n */\nfunction flattenFeatureIdsByFeatureIndices(\n attributes: I3SMeshAttributes,\n featureIds: Int32Array\n): void {\n const featureIndices = attributes.id.value;\n const result = new Float32Array(featureIndices.length);\n\n for (let index = 0; index < featureIndices.length; index++) {\n result[index] = featureIds[featureIndices[index]];\n }\n\n attributes.id.value = result;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param featureIndex\n * @returns\n */\nfunction getFeatureIdsFromFeatureIndexMetadata(\n featureIndex: I3SMeshAttribute\n): Int32Array | undefined {\n return featureIndex?.metadata?.['i3s-feature-ids']?.intArray;\n}\n"],"mappings":"AACA,SAAQA,IAAI,EAAEC,KAAK,QAAO,kBAAkB;AAC5C,SAAQC,OAAO,EAAEC,OAAO,QAAO,eAAe;AAC9C,SAAQC,SAAS,QAAO,qBAAqB;AAC7C,SAAsCC,gBAAgB,QAAO,0BAA0B;AACvF,SAAQC,WAAW,QAAO,oBAAoB;AAC9C,SAAQC,WAAW,QAAkB,mBAAmB;AACxD,SAAQC,WAAW,EAAEC,uBAAuB,QAAO,sBAAsB;AAAC,SAQxEC,uBAAuB;AAAA,SAMjBC,eAAe;AAAA,SAEfC,WAAW,EAAEC,2BAA2B,EAAEC,MAAM,EAAEC,iBAAiB;AAG3E,MAAMC,aAAa,GAAG,IAAId,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5C,SAASe,yBAAyBA,CAACC,aAA2D,EAAE;EAC9F,QAAQA,aAAa;IACnB,KAAK,UAAU;IACf,KAAK,KAAK;MACR,OAAOT,uBAAuB;IAChC,KAAK,MAAM;MACT,OAAOD,WAAW;IACpB,KAAK,KAAK;IACV,KAAK,KAAK;IACV;MACE,OAAOF,WAAW;EACtB;AACF;AAEA,MAAMa,kBAAkB,GAAG,oBAAoB;AAE/C,OAAO,eAAeC,mBAAmBA,CACvCC,WAAwB,EACxBC,WAA2B,EAC3BC,cAAiC,EACjCC,OAAuB,EACvBC,OAAuB,EACE;EACzB,MAAMC,OA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AE;IAC1D2D,MAAM,CAAC3D,KAAK,CAAC,GAAGzG,UAAU,CAACmK,cAAc,CAAC1D,KAAK,CAAC,CAAC;EACnD;EAEA3G,UAAU,CAACoD,EAAE,CAACX,KAAK,GAAG6H,MAAM;AAC9B;AAOA,SAAShH,qCAAqCA,CAC5CR,YAA8B,EACN;EAAA,IAAA0H,qBAAA,EAAAC,sBAAA;EACxB,OAAO3H,YAAY,aAAZA,YAAY,wBAAA0H,qBAAA,GAAZ1H,YAAY,CAAE2C,QAAQ,cAAA+E,qBAAA,wBAAAC,sBAAA,GAAtBD,qBAAA,CAAyB,iBAAiB,CAAC,cAAAC,sBAAA,uBAA3CA,sBAAA,CAA6CC,QAAQ;AAC9D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MeshAttribute, TypedArray } from '@loaders.gl/schema';
|
|
2
|
+
import type { AttributeStorageInfo, Field } from '../../types';
|
|
3
|
+
type ColorsByAttribute = {
|
|
4
|
+
/** Feature attribute name */
|
|
5
|
+
attributeName: string;
|
|
6
|
+
/** Minimum attribute value */
|
|
7
|
+
minValue: number;
|
|
8
|
+
/** Maximum attribute value */
|
|
9
|
+
maxValue: number;
|
|
10
|
+
/** Minimum color. 3DObject will be colorized with gradient from `minColor to `maxColor` */
|
|
11
|
+
minColor: [number, number, number, number];
|
|
12
|
+
/** Maximum color. 3DObject will be colorized with gradient from `minColor to `maxColor` */
|
|
13
|
+
maxColor: [number, number, number, number];
|
|
14
|
+
/** Colorization mode. `replace` - replace vertex colors with a new colors, `multiply` - multiply vertex colors with new colors */
|
|
15
|
+
mode: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Calculate new vertex colors array to visualize 3D objects in a attribute driven way
|
|
19
|
+
* @param colors - vertex colors attribute
|
|
20
|
+
* @param featureIds - feature Ids attribute
|
|
21
|
+
* @param attributeUrls - array of attribute's urls
|
|
22
|
+
* @param fields - array of attribute's fileds
|
|
23
|
+
* @param attributeStorageInfo - array of attributeStorageInfo
|
|
24
|
+
* @param colorsByAttribute - attribute color options
|
|
25
|
+
* @param token - access token
|
|
26
|
+
* @returns new colors attribute
|
|
27
|
+
*/
|
|
28
|
+
export declare function customizeColors(colors: MeshAttribute, featureIds: number[] | TypedArray, attributeUrls: string[], fields: Field[], attributeStorageInfo: AttributeStorageInfo[], colorsByAttribute: ColorsByAttribute | null, token?: string): Promise<MeshAttribute>;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=customize-colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customize-colors.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/customize-colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAC,oBAAoB,EAAS,KAAK,EAAC,MAAM,aAAa,CAAC;AAOpE,KAAK,iBAAiB,GAAG;IACvB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,2FAA2F;IAC3F,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,2FAA2F;IAC3F,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,kIAAkI;IAClI,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;GAUG;AAEH,wBAAsB,eAAe,CACnC,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,MAAM,EAAE,GAAG,UAAU,EACjC,aAAa,EAAE,MAAM,EAAE,EACvB,MAAM,EAAE,KAAK,EAAE,EACf,oBAAoB,EAAE,oBAAoB,EAAE,EAC5C,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,EAC3C,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC,CA2ExB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { load } from '@loaders.gl/core';
|
|
2
|
+
import { getAttributeValueType, I3SAttributeLoader } from "../../i3s-attribute-loader.js";
|
|
3
|
+
import { getUrlWithToken } from "./url-utils.js";
|
|
4
|
+
export async function customizeColors(colors, featureIds, attributeUrls, fields, attributeStorageInfo, colorsByAttribute, token) {
|
|
5
|
+
if (!colorsByAttribute) {
|
|
6
|
+
return colors;
|
|
7
|
+
}
|
|
8
|
+
const resultColors = {
|
|
9
|
+
...colors,
|
|
10
|
+
value: new Uint8Array(colors.value)
|
|
11
|
+
};
|
|
12
|
+
const colorizeAttributeField = fields.find(_ref => {
|
|
13
|
+
let {
|
|
14
|
+
name
|
|
15
|
+
} = _ref;
|
|
16
|
+
return name === (colorsByAttribute === null || colorsByAttribute === void 0 ? void 0 : colorsByAttribute.attributeName);
|
|
17
|
+
});
|
|
18
|
+
if (!colorizeAttributeField || !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(colorizeAttributeField.type)) {
|
|
19
|
+
return colors;
|
|
20
|
+
}
|
|
21
|
+
const colorizeAttributeData = await loadFeatureAttributeData(colorizeAttributeField.name, attributeUrls, attributeStorageInfo, token);
|
|
22
|
+
if (!colorizeAttributeData) {
|
|
23
|
+
return colors;
|
|
24
|
+
}
|
|
25
|
+
const objectIdField = fields.find(_ref2 => {
|
|
26
|
+
let {
|
|
27
|
+
type
|
|
28
|
+
} = _ref2;
|
|
29
|
+
return type === 'esriFieldTypeOID';
|
|
30
|
+
});
|
|
31
|
+
if (!objectIdField) {
|
|
32
|
+
return colors;
|
|
33
|
+
}
|
|
34
|
+
const objectIdAttributeData = await loadFeatureAttributeData(objectIdField.name, attributeUrls, attributeStorageInfo, token);
|
|
35
|
+
if (!objectIdAttributeData) {
|
|
36
|
+
return colors;
|
|
37
|
+
}
|
|
38
|
+
const attributeValuesMap = {};
|
|
39
|
+
for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {
|
|
40
|
+
attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(colorizeAttributeData[colorizeAttributeField.name][i], colorsByAttribute);
|
|
41
|
+
}
|
|
42
|
+
for (let i = 0; i < featureIds.length; i++) {
|
|
43
|
+
const color = attributeValuesMap[featureIds[i]];
|
|
44
|
+
if (!color) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (colorsByAttribute.mode === 'multiply') {
|
|
48
|
+
color.forEach((colorItem, index) => {
|
|
49
|
+
resultColors.value[i * 4 + index] = resultColors.value[i * 4 + index] * colorItem / 255;
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
resultColors.value.set(color, i * 4);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return resultColors;
|
|
56
|
+
}
|
|
57
|
+
function calculateColorForAttribute(attributeValue, colorsByAttribute) {
|
|
58
|
+
if (!colorsByAttribute) {
|
|
59
|
+
return [255, 255, 255, 255];
|
|
60
|
+
}
|
|
61
|
+
const {
|
|
62
|
+
minValue,
|
|
63
|
+
maxValue,
|
|
64
|
+
minColor,
|
|
65
|
+
maxColor
|
|
66
|
+
} = colorsByAttribute;
|
|
67
|
+
const rate = (attributeValue - minValue) / (maxValue - minValue);
|
|
68
|
+
const color = [255, 255, 255, 255];
|
|
69
|
+
for (let i = 0; i < minColor.length; i++) {
|
|
70
|
+
color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);
|
|
71
|
+
}
|
|
72
|
+
return color;
|
|
73
|
+
}
|
|
74
|
+
async function loadFeatureAttributeData(attributeName, attributeUrls, attributeStorageInfo, token) {
|
|
75
|
+
const attributeIndex = attributeStorageInfo.findIndex(_ref3 => {
|
|
76
|
+
let {
|
|
77
|
+
name
|
|
78
|
+
} = _ref3;
|
|
79
|
+
return attributeName === name;
|
|
80
|
+
});
|
|
81
|
+
if (attributeIndex === -1) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], token);
|
|
85
|
+
const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);
|
|
86
|
+
const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {
|
|
87
|
+
attributeName,
|
|
88
|
+
attributeType
|
|
89
|
+
});
|
|
90
|
+
return objectIdAttributeData;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=customize-colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customize-colors.js","names":["load","getAttributeValueType","I3SAttributeLoader","getUrlWithToken","customizeColors","colors","featureIds","attributeUrls","fields","attributeStorageInfo","colorsByAttribute","token","resultColors","value","Uint8Array","colorizeAttributeField","find","_ref","name","attributeName","includes","type","colorizeAttributeData","loadFeatureAttributeData","objectIdField","_ref2","objectIdAttributeData","attributeValuesMap","i","length","calculateColorForAttribute","color","mode","forEach","colorItem","index","set","attributeValue","minValue","maxValue","minColor","maxColor","rate","Math","round","attributeIndex","findIndex","_ref3","objectIdAttributeUrl","attributeType"],"sources":["../../../src/lib/utils/customize-colors.ts"],"sourcesContent":["import type {MeshAttribute, TypedArray} from '@loaders.gl/schema';\nimport type {AttributeStorageInfo, COLOR, Field} from '../../types';\n\nimport {load} from '@loaders.gl/core';\nimport {getAttributeValueType, I3SAttributeLoader} from '../../i3s-attribute-loader';\nimport {getUrlWithToken} from './url-utils';\nimport {I3STileAttributes} from '../parsers/parse-i3s-attribute';\n\ntype ColorsByAttribute = {\n /** Feature attribute name */\n attributeName: string;\n /** Minimum attribute value */\n minValue: number;\n /** Maximum attribute value */\n maxValue: number;\n /** Minimum color. 3DObject will be colorized with gradient from `minColor to `maxColor` */\n minColor: [number, number, number, number];\n /** Maximum color. 3DObject will be colorized with gradient from `minColor to `maxColor` */\n maxColor: [number, number, number, number];\n /** Colorization mode. `replace` - replace vertex colors with a new colors, `multiply` - multiply vertex colors with new colors */\n mode: string;\n};\n\n/**\n * Calculate new 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 attributeUrls - array of attribute's urls\n * @param fields - array of attribute's fileds\n * @param attributeStorageInfo - array of attributeStorageInfo\n * @param colorsByAttribute - attribute color options\n * @param token - access token\n * @returns new colors attribute\n */\n// eslint-disable-next-line max-params\nexport async function customizeColors(\n colors: MeshAttribute,\n featureIds: number[] | TypedArray,\n attributeUrls: string[],\n fields: Field[],\n attributeStorageInfo: AttributeStorageInfo[],\n colorsByAttribute: ColorsByAttribute | null,\n token?: string\n): Promise<MeshAttribute> {\n if (!colorsByAttribute) {\n return colors;\n }\n\n const resultColors = {\n ...colors,\n value: new Uint8Array(colors.value)\n };\n\n const colorizeAttributeField = fields.find(({name}) => name === colorsByAttribute?.attributeName);\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 attributeUrls,\n attributeStorageInfo,\n token\n );\n if (!colorizeAttributeData) {\n return colors;\n }\n\n const objectIdField = fields.find(({type}) => type === 'esriFieldTypeOID');\n if (!objectIdField) {\n return colors;\n }\n\n const objectIdAttributeData = await loadFeatureAttributeData(\n objectIdField.name,\n attributeUrls,\n attributeStorageInfo,\n token\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 colorsByAttribute\n );\n }\n\n for (let i = 0; i < featureIds.length; i++) {\n const color = attributeValuesMap[featureIds[i]];\n if (!color) {\n continue; // eslint-disable-line no-continue\n }\n\n /* eslint max-statements: [\"error\", 30] */\n /* eslint complexity: [\"error\", 12] */\n if (colorsByAttribute.mode === 'multiply') {\n // multiplying original mesh and calculated for attribute rgba colors in range 0-255\n color.forEach((colorItem, index) => {\n resultColors.value[i * 4 + index] = (resultColors.value[i * 4 + index] * colorItem) / 255;\n });\n } else {\n resultColors.value.set(color, i * 4);\n }\n }\n\n return resultColors;\n}\n\n/**\n * Calculate rgba color from the attribute value\n * @param attributeValue - value of the attribute\n * @param colorsByAttribute - attribute color options\n * @returns - color array for a specific attribute value\n */\nfunction calculateColorForAttribute(\n attributeValue: number,\n colorsByAttribute: ColorsByAttribute\n): COLOR {\n if (!colorsByAttribute) {\n return [255, 255, 255, 255];\n }\n const {minValue, maxValue, minColor, maxColor} = 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 attributeUrls - array of attribute's urls\n * @param attributeStorageInfo - array of attributeStorageInfo\n * @param token - access token\n * @returns - Array-like list of the attribute values\n */\nasync function loadFeatureAttributeData(\n attributeName: string,\n attributeUrls: string[],\n attributeStorageInfo: AttributeStorageInfo[],\n token?: string\n): Promise<I3STileAttributes | null> {\n const attributeIndex = attributeStorageInfo.findIndex(({name}) => attributeName === name);\n if (attributeIndex === -1) {\n return null;\n }\n const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], token);\n const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);\n const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {\n attributeName,\n attributeType\n });\n\n return objectIdAttributeData;\n}\n"],"mappings":"AAGA,SAAQA,IAAI,QAAO,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GED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/i3s",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.8",
|
|
4
4
|
"description": "i3s .",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,21 +41,20 @@
|
|
|
41
41
|
"build-worker-node": "esbuild src/workers/i3s-content-worker-node.ts --outfile=dist/i3s-content-worker-node.js --platform=node --target=node16 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@loaders.gl/compression": "4.0.0-beta.
|
|
45
|
-
"@loaders.gl/crypto": "4.0.0-beta.
|
|
46
|
-
"@loaders.gl/draco": "4.0.0-beta.
|
|
47
|
-
"@loaders.gl/images": "4.0.0-beta.
|
|
48
|
-
"@loaders.gl/loader-utils": "4.0.0-beta.
|
|
49
|
-
"@loaders.gl/schema": "4.0.0-beta.
|
|
50
|
-
"@loaders.gl/textures": "4.0.0-beta.
|
|
51
|
-
"@loaders.gl/tiles": "4.0.0-beta.
|
|
52
|
-
"@luma.gl/constants": "^8.5.4",
|
|
44
|
+
"@loaders.gl/compression": "4.0.0-beta.8",
|
|
45
|
+
"@loaders.gl/crypto": "4.0.0-beta.8",
|
|
46
|
+
"@loaders.gl/draco": "4.0.0-beta.8",
|
|
47
|
+
"@loaders.gl/images": "4.0.0-beta.8",
|
|
48
|
+
"@loaders.gl/loader-utils": "4.0.0-beta.8",
|
|
49
|
+
"@loaders.gl/schema": "4.0.0-beta.8",
|
|
50
|
+
"@loaders.gl/textures": "4.0.0-beta.8",
|
|
51
|
+
"@loaders.gl/tiles": "4.0.0-beta.8",
|
|
53
52
|
"@math.gl/core": "^4.0.0",
|
|
54
53
|
"@math.gl/culling": "^4.0.0",
|
|
55
54
|
"@math.gl/geospatial": "^4.0.0"
|
|
56
55
|
},
|
|
57
56
|
"peerDependencies": {
|
|
58
|
-
"@loaders.gl/core": "4.0.0-beta.
|
|
57
|
+
"@loaders.gl/core": "4.0.0-beta.6"
|
|
59
58
|
},
|
|
60
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "ec3d1747b4c01c52a235455d6462680e711b4e19"
|
|
61
60
|
}
|
package/src/i3s-loader.ts
CHANGED
|
@@ -43,8 +43,7 @@ export const I3SLoader: LoaderWithParser<I3STilesetHeader, never, LoaderOptions>
|
|
|
43
43
|
useDracoGeometry: true,
|
|
44
44
|
useCompressedTextures: true,
|
|
45
45
|
decodeTextures: true,
|
|
46
|
-
coordinateSystem: COORDINATE_SYSTEM.METER_OFFSETS
|
|
47
|
-
colorsByAttribute: null
|
|
46
|
+
coordinateSystem: COORDINATE_SYSTEM.METER_OFFSETS
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// loaders.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
2
3
|
|
|
3
4
|
export type {
|
|
4
5
|
BoundingVolumes,
|
|
@@ -49,3 +50,4 @@ export {ArcGISWebSceneLoader} from './arcgis-webscene-loader';
|
|
|
49
50
|
|
|
50
51
|
export type {SLPKArchive} from './lib/parsers/parse-slpk/slpk-archieve';
|
|
51
52
|
export {parseSLPKArchive} from './lib/parsers/parse-slpk/parse-slpk';
|
|
53
|
+
export {customizeColors} from './lib/utils/customize-colors';
|