fix: harden upload resilience and contracts
This commit is contained in:
@@ -93,7 +93,7 @@ function supportsAlphaMap(material: Material): material is AlphaMapMaterial {
|
||||
return 'alphaMap' in material
|
||||
}
|
||||
|
||||
function isAlphaImageSource(image: object | null | undefined): image is AlphaImageSource {
|
||||
function isAlphaImageSource(image: unknown): image is AlphaImageSource {
|
||||
return image instanceof HTMLImageElement
|
||||
|| image instanceof HTMLCanvasElement
|
||||
|| (typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap)
|
||||
@@ -103,7 +103,7 @@ function createAlphaMapTexture(texture: Texture) {
|
||||
const cachedTexture = alphaMapTextureCache.get(texture)
|
||||
if (cachedTexture) return cachedTexture
|
||||
|
||||
const image = texture.image as object | null | undefined
|
||||
const image = texture.image
|
||||
|
||||
if (!isAlphaImageSource(image)) {
|
||||
texture.flipY = false
|
||||
@@ -243,7 +243,7 @@ function Model({
|
||||
loader.manager.setURLModifier((requestedUrl) => resolveAssetUrl(requestedUrl, assetUrls))
|
||||
})
|
||||
const opacityMapEntries = getOpacityMapEntries(assetUrls)
|
||||
const opacityMaps = useLoader(TextureLoader, opacityMapEntries.map((entry) => entry.url)) as Texture[]
|
||||
const opacityMaps = useLoader(TextureLoader, opacityMapEntries.map((entry) => entry.url))
|
||||
|
||||
useEffect(() => {
|
||||
onStatsReady(getModelStats(scene, assetUrls))
|
||||
|
||||
Reference in New Issue
Block a user