refactor: clean upload pipeline and restore draco delivery
This commit is contained in:
@@ -29,6 +29,8 @@ interface AlphaMapMaterial extends Material {
|
||||
alphaTest: number
|
||||
}
|
||||
|
||||
type AlphaImageSource = HTMLImageElement | HTMLCanvasElement | ImageBitmap
|
||||
|
||||
const alphaMapTextureCache = new WeakMap<Texture, Texture>()
|
||||
|
||||
function getRequestedFilename(requestedUrl: string) {
|
||||
@@ -91,14 +93,19 @@ function supportsAlphaMap(material: Material): material is AlphaMapMaterial {
|
||||
return 'alphaMap' in material
|
||||
}
|
||||
|
||||
function isAlphaImageSource(image: object | null | undefined): image is AlphaImageSource {
|
||||
return image instanceof HTMLImageElement
|
||||
|| image instanceof HTMLCanvasElement
|
||||
|| (typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap)
|
||||
}
|
||||
|
||||
function createAlphaMapTexture(texture: Texture) {
|
||||
const cachedTexture = alphaMapTextureCache.get(texture)
|
||||
if (cachedTexture) return cachedTexture
|
||||
|
||||
const image = texture.image as unknown
|
||||
const isImageBitmap = typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap
|
||||
const image = texture.image as object | null | undefined
|
||||
|
||||
if (!(image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || isImageBitmap)) {
|
||||
if (!isAlphaImageSource(image)) {
|
||||
texture.flipY = false
|
||||
alphaMapTextureCache.set(texture, texture)
|
||||
return texture
|
||||
|
||||
Reference in New Issue
Block a user