@loaders.gl/i3s 3.4.13 → 3.4.15
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 +124 -111
- package/dist/es5/arcgis-webscene-loader.js +5 -22
- package/dist/es5/arcgis-webscene-loader.js.map +1 -1
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +58 -123
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +8 -28
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +16 -35
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +49 -148
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +8 -39
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/i3s-slpk-loader.js +2 -2
- package/dist/es5/i3s-slpk-loader.js.map +1 -1
- package/dist/es5/index.js +8 -8
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +161 -267
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +6 -6
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js +64 -146
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +26 -55
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +27 -47
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +278 -347
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +55 -79
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js +30 -81
- package/dist/es5/lib/parsers/parse-slpk/parse-slpk.js.map +1 -1
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js +44 -90
- package/dist/es5/lib/parsers/parse-slpk/slpk-archieve.js.map +1 -1
- package/dist/es5/lib/parsers/parse-zip/cd-file-header.js +17 -17
- package/dist/es5/lib/parsers/parse-zip/cd-file-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-zip/local-file-header.js +10 -10
- package/dist/es5/lib/parsers/parse-zip/local-file-header.js.map +1 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +4 -6
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/es5/lib/utils/customizeColors.js +79 -140
- package/dist/es5/lib/utils/customizeColors.js.map +1 -1
- package/dist/es5/lib/utils/url-utils.js +14 -11
- package/dist/es5/lib/utils/url-utils.js.map +1 -1
- package/dist/es5/types.js +2 -2
- 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/i3s-content-nodejs-worker.js +61 -59
- package/dist/i3s-content-nodejs-worker.js.map +3 -3
- package/dist/i3s-content-worker.js +69 -81
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-i3s-tile-content.js","names":["_core","require","_core2","_geospatial","_images","_draco","_textures","_types","_urlUtils","_constants","_customizeColors","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","i","F","s","n","done","value","e","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","Object","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","ownKeys","object","enumerableOnly","keys","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","arguments","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","scratchVector","Vector3","getLoaderForTextureFormat","textureFormat","CompressedTextureLoader","BasisLoader","ImageLoader","I3S_ATTRIBUTE_TYPE","parseI3STileContent","_x","_x2","_x3","_x4","_x5","_parseI3STileContent","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","tileOptions","tilesetOptions","options","context","content","_options$i3s","url","loader","response","_arrayBuffer","_options","texture","wrap","_callee$","_context","prev","attributes","indices","featureIds","vertexCount","modelMatrix","Matrix4","coordinateSystem","byteLength","textureUrl","getUrlWithToken","i3s","token","fetch","sent","decodeTextures","textureLoaderOptions","image","type","parse","t0","load","compressed","mipmaps","width","height","data","material","makePbrMaterial","materialDefinition","parseI3SNodeGeometry","abrupt","stop","_x6","_x7","_x8","_x9","_x10","_parseI3SNodeGeometry","_callee2","_options$i3s2","contentByteLength","byteOffset","featureCount","_decompressedGeometry","decompressedGeometry","_decompressedGeometry2","POSITION","NORMAL","COLOR_0","TEXCOORD_0","featureIndex","uvRegion","_tilesetOptions$store","vertexAttributes","attributesOrder","featureAttributes","featureAttributeOrder","headers","_normalizeAttributes","normalizedVertexAttributes","offset","_normalizeAttributes2","normalizedFeatureAttributes","enuMatrix","attributeIndex","_callee2$","_context2","isDracoGeometry","DracoLoader","draco","attributeNameEntry","header","position","normal","color","uv0","id","updateAttributesMetadata","getFeatureIdsFromFeatureIndexMetadata","flattenFeatureIdsByFeatureIndices","store","defaultGeometrySchema","ordering","parseHeaders","normalizeAttributes","flattenFeatureIdsByFaceRanges","concatAttributes","COORDINATE_SYSTEM","METER_OFFSETS","parsePositions","invert","getModelMatrix","LNGLAT_OFFSETS","customizeColors","positions","normals","colors","normalizeAttribute","texCoords","uvRegions","region","loaderData","dracoAttribute","metadata","attribute","normalized","_iterator","_step","_step$value","property","TypedArrayTypeHeader","getConstructorForDataFormat","HeaderAttributeProperty","sizeOf","attributeCount","_iterator2","_step2","_vertexAttributes$att","valueType","valuesPerElement","buffer","parseUint64Values","TypedArrayType","GL_TYPE_MAP","size","elementsCount","attributeSize","values","dataView","DataView","index","left","getUint32","right","Math","pow","Uint32Array","mbs","cartographicOrigin","cartesianOrigin","Ellipsoid","WGS84","cartographicToCartesian","eastNorthUpToFixedFrame","offsetsToCartesians","vertices","undefined","Float64Array","scaleX","double","scaleY","x","y","z","subarray","_metadata$i3sScale_x","_metadata$i3sScale_y","pbrMaterial","pbrMetallicRoughness","baseColorFactor","baseColorTexture","texCoord","alphaCutoff","alphaMode","toUpperCase","emissiveFactor","convertColorFormat","setMaterialTexture","colorFactor","normalizedColor","_toConsumableArray2","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 type {LoaderOptions, LoaderContext} 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/customizeColors';\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 response = await fetch(url, options?.fetch as RequestInit);\n const arrayBuffer = await response.arrayBuffer();\n\n // @ts-expect-error options is not properly typed\n if (options?.i3s.decodeTextures) {\n if (loader === ImageLoader) {\n const options = {...tileOptions.textureLoaderOptions, image: {type: 'data'}};\n try {\n // @ts-ignore context must be defined\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 content.texture = await context.parse(arrayBuffer, options);\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 content.texture = await parse(arrayBuffer, loader, options);\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,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAYA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,UAAA,GAAAR,OAAA;AAEA,IAAAS,gBAAA,GAAAT,OAAA;AAAyD,SAAAU,2BAAAC,CAAA,EAAAC,cAAA,QAAAC,EAAA,UAAAC,MAAA,oBAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,qBAAAE,EAAA,QAAAG,KAAA,CAAAC,OAAA,CAAAN,CAAA,MAAAE,EAAA,GAAAK,2BAAA,CAAAP,CAAA,MAAAC,cAAA,IAAAD,CAAA,WAAAA,CAAA,CAAAQ,MAAA,qBAAAN,EAAA,EAAAF,CAA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Q,GAAGC,SAAS,GAAG,CAAC;IAC/C,IAAME,QAAQ,GAAGN,UAAU,GAAGK,cAAc,GAAG,CAAC;IAEhDN,qBAAqB,CAACQ,IAAI,CAACN,MAAM,EAAED,UAAU,EAAEM,QAAQ,CAAC;IAExDvI,YAAY,EAAE;IACdiI,UAAU,GAAGM,QAAQ;EACvB;EAEA3H,2BAA2B,CAACc,EAAE,CAACjK,KAAK,GAAGuQ,qBAAqB;AAC9D;AAQA,SAASnG,iCAAiCA,CACxC/E,UAA6B,EAC7BE,UAAsB,EAChB;EACN,IAAMyL,cAAc,GAAG3L,UAAU,CAAC4E,EAAE,CAACjK,KAAK;EAC1C,IAAMiR,MAAM,GAAG,IAAIC,YAAY,CAACF,cAAc,CAACtR,MAAM,CAAC;EAEtD,KAAK,IAAI6N,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGyD,cAAc,CAACtR,MAAM,EAAE6N,KAAK,EAAE,EAAE;IAC1D0D,MAAM,CAAC1D,KAAK,CAAC,GAAGhI,UAAU,CAACyL,cAAc,CAACzD,KAAK,CAAC,CAAC;EACnD;EAEAlI,UAAU,CAAC4E,EAAE,CAACjK,KAAK,GAAGiR,MAAM;AAC9B;AAOA,SAAS9G,qCAAqCA,CAC5C5B,YAA8B,EACN;EAAA,IAAA4I,qBAAA,EAAAC,sBAAA;EACxB,OAAO7I,YAAY,aAAZA,YAAY,wBAAA4I,qBAAA,GAAZ5I,YAAY,CAAEqD,QAAQ,cAAAuF,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":["_core","require","_core2","_geospatial","_images","_draco","_textures","_types","_urlUtils","_constants","_customizeColors","scratchVector","Vector3","getLoaderForTextureFormat","textureFormat","CompressedTextureLoader","BasisLoader","ImageLoader","I3S_ATTRIBUTE_TYPE","parseI3STileContent","arrayBuffer","tileOptions","tilesetOptions","options","context","content","attributes","indices","featureIds","vertexCount","modelMatrix","Matrix4","coordinateSystem","byteLength","texture","textureUrl","_options$i3s","url","getUrlWithToken","i3s","token","loader","response","fetch","decodeTextures","textureLoaderOptions","image","type","parse","e","load","compressed","mipmaps","width","height","data","material","makePbrMaterial","materialDefinition","parseI3SNodeGeometry","_options$i3s2","contentByteLength","byteOffset","featureCount","isDracoGeometry","_decompressedGeometry","decompressedGeometry","DracoLoader","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","COORDINATE_SYSTEM","METER_OFFSETS","enuMatrix","parsePositions","invert","getModelMatrix","LNGLAT_OFFSETS","customizeColors","positions","normals","colors","normalizeAttribute","texCoords","uvRegions","region","attributeIndex","key","loaderData","dracoAttribute","name","metadata","attribute","normalized","property","TypedArrayTypeHeader","getConstructorForDataFormat","HeaderAttributeProperty","sizeOf","attributeCount","valueType","valuesPerElement","buffer","slice","parseUint64Values","TypedArrayType","GL_TYPE_MAP","size","elementsCount","attributeSize","values","dataView","DataView","index","left","getUint32","right","push","Uint32Array","mbs","cartographicOrigin","cartesianOrigin","Ellipsoid","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 type {LoaderOptions, LoaderContext} 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/customizeColors';\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 response = await fetch(url, options?.fetch as RequestInit);\n const arrayBuffer = await response.arrayBuffer();\n\n // @ts-expect-error options is not properly typed\n if (options?.i3s.decodeTextures) {\n if (loader === ImageLoader) {\n const options = {...tileOptions.textureLoaderOptions, image: {type: 'data'}};\n try {\n // @ts-ignore context must be defined\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 content.texture = await context.parse(arrayBuffer, options);\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 content.texture = await parse(arrayBuffer, loader, options);\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 {\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AAQ,cAAAoF,qBAAA,wBAAAC,sBAAA,GAAtBD,qBAAA,CAAyB,iBAAiB,CAAC,cAAAC,sBAAA,uBAA3CA,sBAAA,CAA6CC,QAAQ;AAC9D"}
|
|
@@ -7,110 +7,86 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.normalizeTileData = normalizeTileData;
|
|
8
8
|
exports.normalizeTileNonUrlData = normalizeTileNonUrlData;
|
|
9
9
|
exports.normalizeTilesetData = normalizeTilesetData;
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
10
|
var _culling = require("@math.gl/culling");
|
|
15
11
|
var _geospatial = require("@math.gl/geospatial");
|
|
16
12
|
var _core = require("@loaders.gl/core");
|
|
17
13
|
var _tiles = require("@loaders.gl/tiles");
|
|
18
14
|
var _i3sNodepagesTiles = _interopRequireDefault(require("../helpers/i3s-nodepages-tiles"));
|
|
19
15
|
var _urlUtils = require("../utils/url-utils");
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
16
|
function normalizeTileData(tile, context) {
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const url = context.url || '';
|
|
18
|
+
let contentUrl;
|
|
25
19
|
if (tile.geometryData) {
|
|
26
20
|
contentUrl = "".concat(url, "/").concat(tile.geometryData[0].href);
|
|
27
21
|
}
|
|
28
|
-
|
|
22
|
+
let textureUrl;
|
|
29
23
|
if (tile.textureData) {
|
|
30
24
|
textureUrl = "".concat(url, "/").concat(tile.textureData[0].href);
|
|
31
25
|
}
|
|
32
|
-
|
|
26
|
+
let attributeUrls;
|
|
33
27
|
if (tile.attributeData) {
|
|
34
28
|
attributeUrls = (0, _urlUtils.generateTileAttributeUrls)(url, tile);
|
|
35
29
|
}
|
|
36
|
-
return normalizeTileNonUrlData(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
return normalizeTileNonUrlData({
|
|
31
|
+
...tile,
|
|
32
|
+
url,
|
|
33
|
+
contentUrl,
|
|
34
|
+
textureUrl,
|
|
35
|
+
attributeUrls,
|
|
41
36
|
isDracoGeometry: false
|
|
42
|
-
})
|
|
37
|
+
});
|
|
43
38
|
}
|
|
44
39
|
function normalizeTileNonUrlData(tile) {
|
|
45
40
|
var _tile$lodSelection, _tile$lodSelection2;
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
const boundingVolume = {};
|
|
42
|
+
let mbs = [0, 0, 0, 1];
|
|
48
43
|
if (tile.mbs) {
|
|
49
44
|
mbs = tile.mbs;
|
|
50
|
-
boundingVolume.sphere = [
|
|
45
|
+
boundingVolume.sphere = [..._geospatial.Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)), tile.mbs[3]];
|
|
51
46
|
} else if (tile.obb) {
|
|
52
|
-
boundingVolume.box = [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
boundingVolume.sphere = [
|
|
56
|
-
mbs = [
|
|
47
|
+
boundingVolume.box = [..._geospatial.Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center), ...tile.obb.halfSize, ...tile.obb.quaternion];
|
|
48
|
+
const obb = new _culling.OrientedBoundingBox().fromCenterHalfSizeQuaternion(boundingVolume.box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
|
|
49
|
+
const boundingSphere = obb.getBoundingSphere();
|
|
50
|
+
boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
|
|
51
|
+
mbs = [...tile.obb.center, boundingSphere.radius];
|
|
57
52
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
const lodMetricType = (_tile$lodSelection = tile.lodSelection) === null || _tile$lodSelection === void 0 ? void 0 : _tile$lodSelection[0].metricType;
|
|
54
|
+
const lodMetricValue = (_tile$lodSelection2 = tile.lodSelection) === null || _tile$lodSelection2 === void 0 ? void 0 : _tile$lodSelection2[0].maxError;
|
|
55
|
+
const transformMatrix = tile.transform;
|
|
56
|
+
const type = _tiles.TILE_TYPE.MESH;
|
|
57
|
+
const refine = _tiles.TILE_REFINEMENT.REPLACE;
|
|
58
|
+
return {
|
|
59
|
+
...tile,
|
|
60
|
+
mbs,
|
|
61
|
+
boundingVolume,
|
|
62
|
+
lodMetricType,
|
|
63
|
+
lodMetricValue,
|
|
64
|
+
transformMatrix,
|
|
65
|
+
type,
|
|
66
|
+
refine
|
|
67
|
+
};
|
|
72
68
|
}
|
|
73
|
-
function normalizeTilesetData(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
tileset.root = tileset.nodePagesTile.formTileFromNodePages(0);
|
|
89
|
-
_context.next = 10;
|
|
90
|
-
break;
|
|
91
|
-
case 6:
|
|
92
|
-
rootNodeUrl = (0, _urlUtils.getUrlWithToken)("".concat(tileset.url, "/nodes/root"), (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
93
|
-
_context.next = 9;
|
|
94
|
-
return (0, _core.load)(rootNodeUrl, tileset.loader, _objectSpread(_objectSpread({}, options), {}, {
|
|
95
|
-
i3s: _objectSpread(_objectSpread({}, options.i3s), {}, {
|
|
96
|
-
loadContent: false,
|
|
97
|
-
isTileHeader: true,
|
|
98
|
-
isTileset: false
|
|
99
|
-
})
|
|
100
|
-
}));
|
|
101
|
-
case 9:
|
|
102
|
-
tileset.root = _context.sent;
|
|
103
|
-
case 10:
|
|
104
|
-
tileset.basePath = tileset.url;
|
|
105
|
-
tileset.type = _tiles.TILESET_TYPE.I3S;
|
|
106
|
-
tileset.lodMetricType = tileset.root.lodMetricType;
|
|
107
|
-
tileset.lodMetricValue = tileset.root.lodMetricValue;
|
|
108
|
-
case 14:
|
|
109
|
-
case "end":
|
|
110
|
-
return _context.stop();
|
|
69
|
+
async function normalizeTilesetData(tileset, options, context) {
|
|
70
|
+
tileset.url = context.url;
|
|
71
|
+
if (tileset.nodePages) {
|
|
72
|
+
tileset.nodePagesTile = new _i3sNodepagesTiles.default(tileset, options);
|
|
73
|
+
tileset.root = tileset.nodePagesTile.formTileFromNodePages(0);
|
|
74
|
+
} else {
|
|
75
|
+
var _options$i3s;
|
|
76
|
+
const rootNodeUrl = (0, _urlUtils.getUrlWithToken)("".concat(tileset.url, "/nodes/root"), (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
77
|
+
tileset.root = await (0, _core.load)(rootNodeUrl, tileset.loader, {
|
|
78
|
+
...options,
|
|
79
|
+
i3s: {
|
|
80
|
+
...options.i3s,
|
|
81
|
+
loadContent: false,
|
|
82
|
+
isTileHeader: true,
|
|
83
|
+
isTileset: false
|
|
111
84
|
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
tileset.basePath = tileset.url;
|
|
88
|
+
tileset.type = _tiles.TILESET_TYPE.I3S;
|
|
89
|
+
tileset.lodMetricType = tileset.root.lodMetricType;
|
|
90
|
+
tileset.lodMetricValue = tileset.root.lodMetricValue;
|
|
115
91
|
}
|
|
116
92
|
//# sourceMappingURL=parse-i3s.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-i3s.js","names":["_culling","require","_geospatial","_core","_tiles","_i3sNodepagesTiles","_interopRequireDefault","_urlUtils","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","normalizeTileData","tile","context","url","contentUrl","geometryData","concat","href","textureUrl","textureData","attributeUrls","attributeData","generateTileAttributeUrls","normalizeTileNonUrlData","isDracoGeometry","_tile$lodSelection","_tile$lodSelection2","boundingVolume","mbs","sphere","_toConsumableArray2","Ellipsoid","WGS84","cartographicToCartesian","slice","obb","box","center","halfSize","quaternion","OrientedBoundingBox","fromCenterHalfSizeQuaternion","boundingSphere","getBoundingSphere","radius","lodMetricType","lodSelection","metricType","lodMetricValue","maxError","transformMatrix","transform","type","TILE_TYPE","MESH","refine","TILE_REFINEMENT","REPLACE","normalizeTilesetData","_x","_x2","_x3","_normalizeTilesetData","_asyncToGenerator2","_regenerator","mark","_callee","tileset","options","_options$i3s","rootNodeUrl","wrap","_callee$","_context","prev","next","nodePages","nodePagesTile","I3SNodePagesTiles","root","formTileFromNodePages","getUrlWithToken","i3s","token","load","loader","loadContent","isTileHeader","isTileset","sent","basePath","TILESET_TYPE","I3S","stop"],"sources":["../../../../src/lib/parsers/parse-i3s.ts"],"sourcesContent":["import {OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {load} from '@loaders.gl/core';\nimport {TILE_TYPE, TILE_REFINEMENT, TILESET_TYPE} from '@loaders.gl/tiles';\nimport I3SNodePagesTiles from '../helpers/i3s-nodepages-tiles';\nimport {generateTileAttributeUrls, getUrlWithToken} from '../utils/url-utils';\nimport {\n I3STilesetHeader,\n I3STileHeader,\n Mbs,\n I3SMinimalNodeData,\n Node3DIndexDocument\n} from '../../types';\nimport type {LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\n\nexport function normalizeTileData(tile : Node3DIndexDocument, context: LoaderContext): I3STileHeader {\n const url: string = context.url || '';\n let contentUrl: string | undefined;\n if (tile.geometryData) {\n contentUrl = `${url}/${tile.geometryData[0].href}`;\n }\n\n let textureUrl: string | undefined;\n if (tile.textureData) {\n textureUrl = `${url}/${tile.textureData[0].href}`;\n }\n\n let attributeUrls: string[] | undefined;\n if (tile.attributeData) {\n attributeUrls = generateTileAttributeUrls(url, tile);\n }\n\n return normalizeTileNonUrlData({\n ...tile,\n url,\n contentUrl,\n textureUrl,\n attributeUrls,\n isDracoGeometry: false\n });\n}\n\nexport function normalizeTileNonUrlData(tile : I3SMinimalNodeData): I3STileHeader {\n const boundingVolume: {box?: number[]; sphere?: number[]} = {};\n let mbs: Mbs = [0, 0, 0, 1];\n if (tile.mbs) {\n mbs = tile.mbs;\n boundingVolume.sphere = [\n ...Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)), // cartesian center of sphere\n tile.mbs[3] // radius of sphere\n ] as Mbs;\n } else if (tile.obb) {\n boundingVolume.box = [\n ...Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center), // cartesian center of box\n ...tile.obb.halfSize, // halfSize\n ...tile.obb.quaternion // quaternion\n ];\n const obb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(\n boundingVolume.box.slice(0, 3),\n tile.obb.halfSize,\n tile.obb.quaternion\n );\n const boundingSphere = obb.getBoundingSphere();\n boundingVolume.sphere = [...boundingSphere.center , boundingSphere.radius] as Mbs;\n mbs = [...tile.obb.center, boundingSphere.radius] as Mbs;\n }\n\n const lodMetricType = tile.lodSelection?.[0].metricType;\n const lodMetricValue = tile.lodSelection?.[0].maxError;\n const transformMatrix = tile.transform;\n const type = TILE_TYPE.MESH;\n /**\n * I3S specification supports only REPLACE\n */\n const refine = TILE_REFINEMENT.REPLACE;\n\n return {...tile, mbs, boundingVolume, lodMetricType, lodMetricValue, transformMatrix, type, refine};\n}\n\nexport async function normalizeTilesetData(tileset : I3STilesetHeader, options : LoaderOptions, context: LoaderContext) {\n tileset.url = context.url;\n\n if (tileset.nodePages) {\n tileset.nodePagesTile = new I3SNodePagesTiles(tileset, options);\n tileset.root = tileset.nodePagesTile.formTileFromNodePages(0);\n } else {\n // @ts-expect-error options is not properly typed\n const rootNodeUrl = getUrlWithToken(`${tileset.url}/nodes/root`, options.i3s?.token);\n // eslint-disable-next-line no-use-before-define\n tileset.root = await load(rootNodeUrl, tileset.loader, {\n ...options,\n i3s: {\n // @ts-expect-error options is not properly typed\n ...options.i3s,\n loadContent: false, isTileHeader: true, isTileset: false}\n });\n }\n\n // base path that non-absolute paths in tileset are relative to.\n tileset.basePath = tileset.url;\n tileset.type = TILESET_TYPE.I3S;\n\n // populate from root node\n tileset.lodMetricType = tileset.root.lodMetricType;\n tileset.lodMetricValue = tileset.root.lodMetricValue;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAA8E,SAAAO,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAA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K;cAAEC,YAAY,EAAE,IAAI;cAAEC,SAAS,EAAE;YAAK;UAAC,EAC5D,CAAC;QAAA;UANFrB,OAAO,CAACY,IAAI,GAAAN,QAAA,CAAAgB,IAAA;QAAA;UAUdtB,OAAO,CAACuB,QAAQ,GAAGvB,OAAO,CAACtD,GAAG;UAC9BsD,OAAO,CAACf,IAAI,GAAGuC,mBAAY,CAACC,GAAG;UAG/BzB,OAAO,CAACtB,aAAa,GAAGsB,OAAO,CAACY,IAAI,CAAClC,aAAa;UAClDsB,OAAO,CAACnB,cAAc,GAAGmB,OAAO,CAACY,IAAI,CAAC/B,cAAc;QAAC;QAAA;UAAA,OAAAyB,QAAA,CAAAoB,IAAA;MAAA;IAAA,GAAA3B,OAAA;EAAA,CACtD;EAAA,OAAAJ,qBAAA,CAAAlE,KAAA,OAAAI,SAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"parse-i3s.js","names":["_culling","require","_geospatial","_core","_tiles","_i3sNodepagesTiles","_interopRequireDefault","_urlUtils","normalizeTileData","tile","context","url","contentUrl","geometryData","concat","href","textureUrl","textureData","attributeUrls","attributeData","generateTileAttributeUrls","normalizeTileNonUrlData","isDracoGeometry","_tile$lodSelection","_tile$lodSelection2","boundingVolume","mbs","sphere","Ellipsoid","WGS84","cartographicToCartesian","slice","obb","box","center","halfSize","quaternion","OrientedBoundingBox","fromCenterHalfSizeQuaternion","boundingSphere","getBoundingSphere","radius","lodMetricType","lodSelection","metricType","lodMetricValue","maxError","transformMatrix","transform","type","TILE_TYPE","MESH","refine","TILE_REFINEMENT","REPLACE","normalizeTilesetData","tileset","options","nodePages","nodePagesTile","I3SNodePagesTiles","root","formTileFromNodePages","_options$i3s","rootNodeUrl","getUrlWithToken","i3s","token","load","loader","loadContent","isTileHeader","isTileset","basePath","TILESET_TYPE","I3S"],"sources":["../../../../src/lib/parsers/parse-i3s.ts"],"sourcesContent":["import {OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {load} from '@loaders.gl/core';\nimport {TILE_TYPE, TILE_REFINEMENT, TILESET_TYPE} from '@loaders.gl/tiles';\nimport I3SNodePagesTiles from '../helpers/i3s-nodepages-tiles';\nimport {generateTileAttributeUrls, getUrlWithToken} from '../utils/url-utils';\nimport {\n I3STilesetHeader,\n I3STileHeader,\n Mbs,\n I3SMinimalNodeData,\n Node3DIndexDocument\n} from '../../types';\nimport type {LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\n\nexport function normalizeTileData(tile : Node3DIndexDocument, context: LoaderContext): I3STileHeader {\n const url: string = context.url || '';\n let contentUrl: string | undefined;\n if (tile.geometryData) {\n contentUrl = `${url}/${tile.geometryData[0].href}`;\n }\n\n let textureUrl: string | undefined;\n if (tile.textureData) {\n textureUrl = `${url}/${tile.textureData[0].href}`;\n }\n\n let attributeUrls: string[] | undefined;\n if (tile.attributeData) {\n attributeUrls = generateTileAttributeUrls(url, tile);\n }\n\n return normalizeTileNonUrlData({\n ...tile,\n url,\n contentUrl,\n textureUrl,\n attributeUrls,\n isDracoGeometry: false\n });\n}\n\nexport function normalizeTileNonUrlData(tile : I3SMinimalNodeData): I3STileHeader {\n const boundingVolume: {box?: number[]; sphere?: number[]} = {};\n let mbs: Mbs = [0, 0, 0, 1];\n if (tile.mbs) {\n mbs = tile.mbs;\n boundingVolume.sphere = [\n ...Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)), // cartesian center of sphere\n tile.mbs[3] // radius of sphere\n ] as Mbs;\n } else if (tile.obb) {\n boundingVolume.box = [\n ...Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center), // cartesian center of box\n ...tile.obb.halfSize, // halfSize\n ...tile.obb.quaternion // quaternion\n ];\n const obb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(\n boundingVolume.box.slice(0, 3),\n tile.obb.halfSize,\n tile.obb.quaternion\n );\n const boundingSphere = obb.getBoundingSphere();\n boundingVolume.sphere = [...boundingSphere.center , boundingSphere.radius] as Mbs;\n mbs = [...tile.obb.center, boundingSphere.radius] as Mbs;\n }\n\n const lodMetricType = tile.lodSelection?.[0].metricType;\n const lodMetricValue = tile.lodSelection?.[0].maxError;\n const transformMatrix = tile.transform;\n const type = TILE_TYPE.MESH;\n /**\n * I3S specification supports only REPLACE\n */\n const refine = TILE_REFINEMENT.REPLACE;\n\n return {...tile, mbs, boundingVolume, lodMetricType, lodMetricValue, transformMatrix, type, refine};\n}\n\nexport async function normalizeTilesetData(tileset : I3STilesetHeader, options : LoaderOptions, context: LoaderContext) {\n tileset.url = context.url;\n\n if (tileset.nodePages) {\n tileset.nodePagesTile = new I3SNodePagesTiles(tileset, options);\n tileset.root = tileset.nodePagesTile.formTileFromNodePages(0);\n } else {\n // @ts-expect-error options is not properly typed\n const rootNodeUrl = getUrlWithToken(`${tileset.url}/nodes/root`, options.i3s?.token);\n // eslint-disable-next-line no-use-before-define\n tileset.root = await load(rootNodeUrl, tileset.loader, {\n ...options,\n i3s: {\n // @ts-expect-error options is not properly typed\n ...options.i3s,\n loadContent: false, isTileHeader: true, isTileset: false}\n });\n }\n\n // base path that non-absolute paths in tileset are relative to.\n tileset.basePath = tileset.url;\n tileset.type = TILESET_TYPE.I3S;\n\n // populate from root node\n tileset.lodMetricType = tileset.root.lodMetricType;\n tileset.lodMetricValue = tileset.root.lodMetricValue;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAUO,SAASO,iBAAiBA,CAACC,IAA0B,EAAEC,OAAsB,EAAiB;EACnG,MAAMC,GAAW,GAAGD,OAAO,CAACC,GAAG,IAAI,EAAE;EACrC,IAAIC,UAA8B;EAClC,IAAIH,IAAI,CAACI,YAAY,EAAE;IAC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EAEzB,IAAI6C,OAAO,CAACE,SAAS,EAAE;IACrBF,OAAO,CAACG,aAAa,GAAG,IAAIC,0BAAiB,CAACJ,OAAO,EAAEC,OAAO,CAAC;IAC/DD,OAAO,CAACK,IAAI,GAAGL,OAAO,CAACG,aAAa,CAACG,qBAAqB,CAAC,CAAC,CAAC;EAC/D,CAAC,MAAM;IAAA,IAAAC,YAAA;IAEL,MAAMC,WAAW,GAAG,IAAAC,yBAAe,KAAAnD,MAAA,CAAI0C,OAAO,CAAC7C,GAAG,mBAAAoD,YAAA,GAAeN,OAAO,CAACS,GAAG,cAAAH,YAAA,uBAAXA,YAAA,CAAaI,KAAK,CAAC;IAEpFX,OAAO,CAACK,IAAI,GAAG,MAAM,IAAAO,UAAI,EAACJ,WAAW,EAAER,OAAO,CAACa,MAAM,EAAE;MACrD,GAAGZ,OAAO;MACVS,GAAG,EAAE;QAEH,GAAGT,OAAO,CAACS,GAAG;QACdI,WAAW,EAAE,KAAK;QAAEC,YAAY,EAAE,IAAI;QAAEC,SAAS,EAAE;MAAK;IAC5D,CAAC,CAAC;EACJ;EAGAhB,OAAO,CAACiB,QAAQ,GAAGjB,OAAO,CAAC7C,GAAG;EAC9B6C,OAAO,CAACP,IAAI,GAAGyB,mBAAY,CAACC,GAAG;EAG/BnB,OAAO,CAACd,aAAa,GAAGc,OAAO,CAACK,IAAI,CAACnB,aAAa;EAClDc,OAAO,CAACX,cAAc,GAAGW,OAAO,CAACK,IAAI,CAAChB,cAAc;AACtD"}
|
|
@@ -1,94 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.parseSLPK = parseSLPK;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
7
|
var _cdFileHeader = require("../parse-zip/cd-file-header");
|
|
11
8
|
var _localFileHeader = require("../parse-zip/local-file-header");
|
|
12
9
|
var _slpkArchieve = require("./slpk-archieve");
|
|
13
|
-
|
|
10
|
+
const getByteAt = (offset, buffer) => {
|
|
14
11
|
return buffer.getUint8(buffer.byteOffset + offset);
|
|
15
12
|
};
|
|
16
|
-
function parseSLPK(
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
_context.next = 17;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
searchWindow[3] = searchWindow[2];
|
|
49
|
-
searchWindow[2] = searchWindow[1];
|
|
50
|
-
searchWindow[1] = searchWindow[0];
|
|
51
|
-
searchWindow[0] = getByteAt(i, archive);
|
|
52
|
-
if (!searchWindow.every(function (val, index) {
|
|
53
|
-
return val === cdFileHeaderSignature[index];
|
|
54
|
-
})) {
|
|
55
|
-
_context.next = 14;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
hashCDOffset = i;
|
|
59
|
-
return _context.abrupt("break", 17);
|
|
60
|
-
case 14:
|
|
61
|
-
i--;
|
|
62
|
-
_context.next = 6;
|
|
63
|
-
break;
|
|
64
|
-
case 17:
|
|
65
|
-
cdFileHeader = (0, _cdFileHeader.parseZipCDFileHeader)(hashCDOffset, archive);
|
|
66
|
-
textDecoder = new TextDecoder();
|
|
67
|
-
if (!(textDecoder.decode(cdFileHeader.fileName) !== '@specialIndexFileHASH128@')) {
|
|
68
|
-
_context.next = 21;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
throw new Error('No hash file in slpk');
|
|
72
|
-
case 21:
|
|
73
|
-
localFileHeader = (0, _localFileHeader.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, archive);
|
|
74
|
-
fileDataOffset = localFileHeader.fileDataOffset;
|
|
75
|
-
hashFile = archive.buffer.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
|
|
76
|
-
if (hashFile) {
|
|
77
|
-
_context.next = 26;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
throw new Error('No hash file in slpk');
|
|
81
|
-
case 26:
|
|
82
|
-
_context.next = 28;
|
|
83
|
-
return new _slpkArchieve.SLPKArchive(data, hashFile).getFile((_options$path = options.path) !== null && _options$path !== void 0 ? _options$path : '');
|
|
84
|
-
case 28:
|
|
85
|
-
return _context.abrupt("return", _context.sent);
|
|
86
|
-
case 29:
|
|
87
|
-
case "end":
|
|
88
|
-
return _context.stop();
|
|
89
|
-
}
|
|
90
|
-
}, _callee);
|
|
91
|
-
}));
|
|
92
|
-
return _parseSLPK.apply(this, arguments);
|
|
13
|
+
async function parseSLPK(data) {
|
|
14
|
+
var _options$path;
|
|
15
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16
|
+
const archive = new DataView(data);
|
|
17
|
+
const cdFileHeaderSignature = [80, 75, 1, 2];
|
|
18
|
+
const searchWindow = [getByteAt(archive.byteLength - 1, archive), getByteAt(archive.byteLength - 2, archive), getByteAt(archive.byteLength - 3, archive), undefined];
|
|
19
|
+
let hashCDOffset = 0;
|
|
20
|
+
for (let i = archive.byteLength - 4; i > -1; i--) {
|
|
21
|
+
searchWindow[3] = searchWindow[2];
|
|
22
|
+
searchWindow[2] = searchWindow[1];
|
|
23
|
+
searchWindow[1] = searchWindow[0];
|
|
24
|
+
searchWindow[0] = getByteAt(i, archive);
|
|
25
|
+
if (searchWindow.every((val, index) => val === cdFileHeaderSignature[index])) {
|
|
26
|
+
hashCDOffset = i;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const cdFileHeader = (0, _cdFileHeader.parseZipCDFileHeader)(hashCDOffset, archive);
|
|
31
|
+
const textDecoder = new TextDecoder();
|
|
32
|
+
if (textDecoder.decode(cdFileHeader.fileName) !== '@specialIndexFileHASH128@') {
|
|
33
|
+
throw new Error('No hash file in slpk');
|
|
34
|
+
}
|
|
35
|
+
const localFileHeader = (0, _localFileHeader.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, archive);
|
|
36
|
+
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
37
|
+
const hashFile = archive.buffer.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
|
|
38
|
+
if (!hashFile) {
|
|
39
|
+
throw new Error('No hash file in slpk');
|
|
40
|
+
}
|
|
41
|
+
return await new _slpkArchieve.SLPKArchive(data, hashFile).getFile((_options$path = options.path) !== null && _options$path !== void 0 ? _options$path : '');
|
|
93
42
|
}
|
|
94
43
|
//# sourceMappingURL=parse-slpk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-slpk.js","names":["_cdFileHeader","require","_localFileHeader","_slpkArchieve","getByteAt","offset","buffer","getUint8","byteOffset","parseSLPK","
|
|
1
|
+
{"version":3,"file":"parse-slpk.js","names":["_cdFileHeader","require","_localFileHeader","_slpkArchieve","getByteAt","offset","buffer","getUint8","byteOffset","parseSLPK","data","_options$path","options","arguments","length","undefined","archive","DataView","cdFileHeaderSignature","searchWindow","byteLength","hashCDOffset","i","every","val","index","cdFileHeader","parseZipCDFileHeader","textDecoder","TextDecoder","decode","fileName","Error","localFileHeader","parseZipLocalFileHeader","localHeaderOffset","fileDataOffset","hashFile","slice","compressedSize","SLPKArchive","getFile","path"],"sources":["../../../../../src/lib/parsers/parse-slpk/parse-slpk.ts"],"sourcesContent":["import type {SLPKLoaderOptions} from '../../../i3s-slpk-loader';\nimport {parseZipCDFileHeader} from '../parse-zip/cd-file-header';\nimport {parseZipLocalFileHeader} from '../parse-zip/local-file-header';\nimport {SLPKArchive} from './slpk-archieve';\n\n/**\n * Returns one byte from the provided buffer at the provided position\n * @param offset - position where to read\n * @param buffer - buffer to read\n * @returns one byte from the provided buffer at the provided position\n */\nconst getByteAt = (offset: number, buffer: DataView): number => {\n return buffer.getUint8(buffer.byteOffset + offset);\n};\n\nexport async function parseSLPK(data: ArrayBuffer, options: SLPKLoaderOptions = {}) {\n const archive = new DataView(data);\n const cdFileHeaderSignature = [80, 75, 1, 2];\n\n const searchWindow = [\n getByteAt(archive.byteLength - 1, archive),\n getByteAt(archive.byteLength - 2, archive),\n getByteAt(archive.byteLength - 3, archive),\n undefined\n ];\n\n let hashCDOffset = 0;\n\n // looking for the last record in the central directory\n for (let i = archive.byteLength - 4; i > -1; i--) {\n searchWindow[3] = searchWindow[2];\n searchWindow[2] = searchWindow[1];\n searchWindow[1] = searchWindow[0];\n searchWindow[0] = getByteAt(i, archive);\n if (searchWindow.every((val, index) => val === cdFileHeaderSignature[index])) {\n hashCDOffset = i;\n break;\n }\n }\n\n const cdFileHeader = parseZipCDFileHeader(hashCDOffset, archive);\n\n const textDecoder = new TextDecoder();\n if (textDecoder.decode(cdFileHeader.fileName) !== '@specialIndexFileHASH128@') {\n throw new Error('No hash file in slpk');\n }\n\n const localFileHeader = parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, archive);\n\n const fileDataOffset = localFileHeader.fileDataOffset;\n const hashFile = archive.buffer.slice(\n fileDataOffset,\n fileDataOffset + localFileHeader.compressedSize\n );\n\n if (!hashFile) {\n throw new Error('No hash file in slpk');\n }\n\n return await new SLPKArchive(data, hashFile).getFile(options.path ?? '');\n}\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;A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