Skip to content

Commit

Permalink
[deploy] Improve compression support detection
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-roesch committed Nov 2, 2020
1 parent e5be26f commit b56e13b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/components/map/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
Vector3,
WebGLRenderer,
RGBFormat,
RGFormat,
RedFormat,
// eslint-disable-next-line camelcase
RGB_S3TC_DXT1_Format
Expand Down Expand Up @@ -169,7 +168,7 @@ export default {
oathgates_text: { hqAvailable: true, localized: true, pixelFormat: RedFormat },
silver_kingdoms: { hqAvailable: true, pixelFormat: RedFormat },
silver_kingdoms_text: { hqAvailable: true, localized: true, pixelFormat: RedFormat },
graticule: { hqAvailable: true, lossy: true, pixelFormat: RGFormat },
graticule: { hqAvailable: true, lossy: true, pixelFormat: RGBFormat },
graticule_text: { hqAvailable: true, pixelFormat: RedFormat }
}
Expand Down
14 changes: 12 additions & 2 deletions src/components/map/TextureManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isMobile from 'is-mobile'
// eslint-disable-next-line camelcase
import { RGBAFormat, TextureLoader, WebGLUtils } from 'three'
import { LinearFilter, RGBAFormat, TextureLoader, WebGLUtils } from 'three'
import { DDSLoader } from 'three/examples/jsm/loaders/DDSLoader'

export default class TextureManager {
Expand All @@ -21,7 +21,9 @@ export default class TextureManager {
})
const context = renderer.getContext()
this.utils = new WebGLUtils(context, renderer.extensions, renderer.capabilities)
this.supportedCompressionFormats = context.getParameter(context.COMPRESSED_TEXTURE_FORMATS)
this.supportedCompressionFormats = context.getExtension('WEBGL_compressed_texture_s3tc')
? context.getParameter(context.COMPRESSED_TEXTURE_FORMATS)
: []
this.locale = locale
}

Expand Down Expand Up @@ -63,6 +65,14 @@ export default class TextureManager {
texture.loaded = true
const basePixelFormat = texture.pixelFormat ?? RGBAFormat
data.format = compressed ? texture.compressedPixelFormat : basePixelFormat
data.minFilter = LinearFilter

if (texture.options !== undefined) {
Object.keys(texture.options).forEach((key) => {
data[key] = texture.options[key]
})
}

result[name] = data

if (Object.keys(textures).every(t => textures[t].loaded === true)) {
Expand Down

0 comments on commit b56e13b

Please sign in to comment.