-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(tile-converter): skip failing content #2576
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,13 @@ import {Matrix4, Vector3} from '@math.gl/core'; | |
import {Ellipsoid} from '@math.gl/geospatial'; | ||
import {convertTextureAtlas} from './texture-atlas'; | ||
import {generateSyntheticIndices} from '../../lib/utils/geometry-utils'; | ||
import {I3STileContent} from '@loaders.gl/i3s'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
const Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]); | ||
const scratchVector = new Vector3(); | ||
|
||
export type I3SAttributesData = { | ||
tileContent: any; | ||
tileContent: I3STileContent; | ||
box: number[]; | ||
textureFormat: string; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import {TypedArray} from '@loaders.gl/loader-utils'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
/** | ||
* Apply uvRegions to texture coordinates. | ||
* Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md | ||
* Shader formula vec2 uv = fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy; | ||
* @param texCoords | ||
* @param uvRegions | ||
*/ | ||
export function convertTextureAtlas(texCoords: Float32Array, uvRegions: Uint16Array): Float32Array { | ||
const convertedTexCoords = new Float32Array(texCoords.length); | ||
export function convertTextureAtlas(texCoords: TypedArray, uvRegions: TypedArray): Float32Array { | ||
const convertedTexCoords = new texCoords[Symbol.species](texCoords.length); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I have never needed to use Also do we still need the original texCoords after conversion? If not consider converting "in place" and avoid an allocation? Finally an unrelated comment: In the algorithm below there are lots of little arrays being created for each iteration. I would recommend creating a few scratch arrays before the loop and reusing those, to reduce memory pressure and improve performance. |
||
const normalisedRegions = normalizeRegions(uvRegions); | ||
|
||
for (let index = 0; index < texCoords.length; index += 2) { | ||
|
@@ -43,7 +45,9 @@ function fract(uv: [number, number]): [number, number] { | |
* Normalize uvRegions by dividing by the maximum Uint16 value | ||
* @param regions | ||
*/ | ||
function normalizeRegions(regions: Uint16Array): number[] { | ||
function normalizeRegions(regions: TypedArray): number[] { | ||
// The code is for Uint16Array because it is the spec requirement | ||
// https://github.com/Esri/i3s-spec/blob/master/docs/1.8/geometryUVRegion.cmn.md | ||
const MAX_UINT_16_VALUE = 65535; | ||
const normalizedRegions: number[] = []; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a comment?