@eva/plugin-renderer
Advanced tools
Comparing version 1.1.1-fix.1 to 1.1.1-fix.2
@@ -11,3 +11,3 @@ 'use strict'; | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; } | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; } | ||
@@ -244,3 +244,3 @@ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual); | ||
var container = this.containerMap[name]; | ||
if (!container) | ||
if (!container || !transform) | ||
return; | ||
@@ -375,2 +375,399 @@ var anchor = transform.anchor, origin = transform.origin, position = transform.position, rotation = transform.rotation, scale = transform.scale, size = transform.size, skew = transform.skew; | ||
var result = undefined; | ||
function getSuportCompressedTextureFormats(gl) { | ||
if (result) | ||
return result; | ||
if (!gl) { | ||
console.warn('WebGL not available for compressed textures. Silently failing.'); | ||
return { | ||
s3tc: false, | ||
etc: false, | ||
etc1: false, | ||
pvrtc: false, | ||
atc: false, | ||
astc: false, | ||
}; | ||
} | ||
result = { | ||
s3tc: !!gl.getExtension('WEBGL_compressed_texture_s3tc'), | ||
etc: !!gl.getExtension('WEBGL_compressed_texture_etc'), | ||
etc1: !!gl.getExtension('WEBGL_compressed_texture_etc1'), | ||
pvrtc: !!gl.getExtension('WEBGL_compressed_texture_pvrtc') | ||
|| !!gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'), | ||
atc: !!gl.getExtension('WEBGL_compressed_texture_atc'), | ||
astc: !!gl.getExtension('WEBGL_compressed_texture_astc') | ||
}; | ||
try { | ||
console.log('Eva.js Supported Compressed Texture Format List: ' + Object.keys(result).filter(function (type) { return result[type]; }).join(', ')); | ||
} | ||
catch (e) { } | ||
return result; | ||
} | ||
var XLS = eva_js.resourceLoader.XhrLoadStrategy; | ||
var XhrLoadStrategy = XLS; | ||
var _a, _b; | ||
var INTERNAL_FORMATS; | ||
(function (INTERNAL_FORMATS) { | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_S3TC_DXT1_EXT"] = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT1_EXT"] = 33777] = "COMPRESSED_RGBA_S3TC_DXT1_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT3_EXT"] = 33778] = "COMPRESSED_RGBA_S3TC_DXT3_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT5_EXT"] = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"] = 35917] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"] = 35918] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"] = 35919] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_S3TC_DXT1_EXT"] = 35916] = "COMPRESSED_SRGB_S3TC_DXT1_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_R11_EAC"] = 37488] = "COMPRESSED_R11_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SIGNED_R11_EAC"] = 37489] = "COMPRESSED_SIGNED_R11_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RG11_EAC"] = 37490] = "COMPRESSED_RG11_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SIGNED_RG11_EAC"] = 37491] = "COMPRESSED_SIGNED_RG11_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB8_ETC2"] = 37492] = "COMPRESSED_RGB8_ETC2"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA8_ETC2_EAC"] = 37496] = "COMPRESSED_RGBA8_ETC2_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ETC2"] = 37493] = "COMPRESSED_SRGB8_ETC2"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"] = 37497] = "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"] = 37494] = "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"] = 37495] = "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_PVRTC_4BPPV1_IMG"] = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"] = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_PVRTC_2BPPV1_IMG"] = 35841] = "COMPRESSED_RGB_PVRTC_2BPPV1_IMG"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"] = 35843] = "COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_ETC1_WEBGL"] = 36196] = "COMPRESSED_RGB_ETC1_WEBGL"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_ATC_WEBGL"] = 35986] = "COMPRESSED_RGB_ATC_WEBGL"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL"] = 35986] = "COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL"] = 34798] = "COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x10_KHR"] = 37819] = "COMPRESSED_RGBA_ASTC_10x10_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x5_KHR"] = 37816] = "COMPRESSED_RGBA_ASTC_10x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x6_KHR"] = 37817] = "COMPRESSED_RGBA_ASTC_10x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x8_KHR"] = 37818] = "COMPRESSED_RGBA_ASTC_10x8_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_12x10_KHR"] = 37820] = "COMPRESSED_RGBA_ASTC_12x10_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_12x12_KHR"] = 37821] = "COMPRESSED_RGBA_ASTC_12x12_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_4x4_KHR"] = 37808] = "COMPRESSED_RGBA_ASTC_4x4_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_5x4_KHR"] = 37809] = "COMPRESSED_RGBA_ASTC_5x4_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_5x5_KHR"] = 37810] = "COMPRESSED_RGBA_ASTC_5x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_6x5_KHR"] = 37811] = "COMPRESSED_RGBA_ASTC_6x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_6x6_KHR"] = 37812] = "COMPRESSED_RGBA_ASTC_6x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x5_KHR"] = 37813] = "COMPRESSED_RGBA_ASTC_8x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x6_KHR"] = 37814] = "COMPRESSED_RGBA_ASTC_8x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x8_KHR"] = 37815] = "COMPRESSED_RGBA_ASTC_8x8_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"] = 3781] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"] = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"] = 37849] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"] = 37850] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"] = 37852] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"] = 37853] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"] = 37840] = "COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"] = 37841] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"] = 37842] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"] = 37843] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"] = 37844] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"] = 37845] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"] = 37846] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"] = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"; | ||
})(INTERNAL_FORMATS || (INTERNAL_FORMATS = {})); | ||
var INTERNAL_FORMAT_TO_BLOCK_SIZE = (_a = {}, | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = [8, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = [8, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x5_KHR] = [5, 5], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x6_KHR] = [6, 6], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x8_KHR] = [8, 8], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x10_KHR] = [10, 10], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x12_KHR] = [12, 12], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x5_KHR] = [10, 5], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x6_KHR] = [10, 6], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x8_KHR] = [10, 8], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x10_KHR] = [12, 10], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x4_KHR] = [5, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x5_KHR] = [6, 5], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x5_KHR] = [8, 5], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x6_KHR] = [8, 6], | ||
_a); | ||
var INTERNAL_FORMATS_TO_EXTENSION_NAME = (_b = {}, | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = 'WEBGL_compressed_texture_s3tc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = 'WEBGL_compressed_texture_s3tc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', | ||
_b[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = 'WEBGL_compressed_texture_etc1', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = 'WEBGL_compressed_texture_atc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 'WEBGL_compressed_texture_atc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 'WEBGL_compressed_texture_atc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x5_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x6_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x8_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x10_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x12_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b); | ||
var CompressedTextureResource = (function () { | ||
function CompressedTextureResource() { | ||
this.levelBuffers = []; | ||
} | ||
CompressedTextureResource.prototype.upload = function (gl) { | ||
var levels = this.levels; | ||
var name = INTERNAL_FORMATS_TO_EXTENSION_NAME[this.internalFormat]; | ||
if (!gl[name]) { | ||
gl[name] = true; | ||
if (name === 'WEBGL_compressed_texture_pvrtc') { | ||
gl.getExtension(name) || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'); | ||
} | ||
else { | ||
gl.getExtension(name); | ||
} | ||
} | ||
for (var i = 0; i < this.levels; ++i) { | ||
var _a = this.levelBuffers[i], levelWidth = _a.levelWidth, levelHeight = _a.levelHeight, levelBuffer = _a.levelBuffer; | ||
gl.compressedTexImage2D(gl.TEXTURE_2D, i, this.internalFormat, levelWidth, levelHeight, 0, levelBuffer); | ||
} | ||
if (levels > 1) { | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); | ||
} | ||
else { | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); | ||
} | ||
}; | ||
return CompressedTextureResource; | ||
}()); | ||
var FILE_HEADER_SIZE = 64; | ||
var KTX_FIELDS = { | ||
FILE_IDENTIFIER: 0, | ||
ENDIANNESS: 12, | ||
GL_TYPE: 16, | ||
GL_TYPE_SIZE: 20, | ||
GL_FORMAT: 24, | ||
GL_INTERNAL_FORMAT: 28, | ||
GL_BASE_INTERNAL_FORMAT: 32, | ||
PIXEL_WIDTH: 36, | ||
PIXEL_HEIGHT: 40, | ||
PIXEL_DEPTH: 44, | ||
NUMBER_OF_ARRAY_ELEMENTS: 48, | ||
NUMBER_OF_FACES: 52, | ||
NUMBER_OF_MIPMAP_LEVELS: 56, | ||
BYTES_OF_KEY_VALUE_DATA: 60 | ||
}; | ||
var FILE_IDENTIFIER = [0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A]; | ||
var ENDIANNESS = 0x04030201; | ||
var KTXTextureResource = (function (_super) { | ||
__extends(KTXTextureResource, _super); | ||
function KTXTextureResource(source, config) { | ||
var _a; | ||
var _this = _super.call(this) || this; | ||
_this.complete = true; | ||
_this.src = config.url; | ||
var dataView = new DataView(source); | ||
if (!validateKTX(dataView)) { | ||
throw new Error('Not a valid KTX Texture'); | ||
} | ||
var littleEndian = dataView.getUint32(KTX_FIELDS.ENDIANNESS, true) === ENDIANNESS; | ||
_this.internalFormat = dataView.getUint32(KTX_FIELDS.GL_INTERNAL_FORMAT, littleEndian); | ||
var pixelWidth = _this.formerWidth = dataView.getUint32(KTX_FIELDS.PIXEL_WIDTH, littleEndian); | ||
var pixelHeight = _this.formerHeight = dataView.getUint32(KTX_FIELDS.PIXEL_HEIGHT, littleEndian) || 1; | ||
var size = INTERNAL_FORMAT_TO_BLOCK_SIZE[_this.internalFormat]; | ||
_this.width = pixelWidth % size[0] === 0 ? pixelWidth : (pixelWidth + size[0] - (pixelWidth % size[0])); | ||
_this.height = pixelHeight % size[1] === 0 ? pixelHeight : (pixelHeight + size[1] - (pixelHeight % size[1])); | ||
var src = eva_js.resource.resourcesMap[config.metadata.name].src[config.metadata.key]; | ||
var _b = (_a = src === null || src === void 0 ? void 0 : src.size) !== null && _a !== void 0 ? _a : {}, width = _b.width, height = _b.height; | ||
if (width && height) { | ||
_this.naturalWidth = width; | ||
_this.naturalHeight = height; | ||
} | ||
var pixelDepth = dataView.getUint32(KTX_FIELDS.PIXEL_DEPTH, littleEndian) || 1; | ||
var numberOfArrayElements = dataView.getUint32(KTX_FIELDS.NUMBER_OF_ARRAY_ELEMENTS, littleEndian) || 1; | ||
var numberOfFaces = dataView.getUint32(KTX_FIELDS.NUMBER_OF_FACES, littleEndian); | ||
var numberOfMipmapLevels = _this.levels = dataView.getUint32(KTX_FIELDS.NUMBER_OF_MIPMAP_LEVELS, littleEndian); | ||
var bytesOfKeyValueData = dataView.getUint32(KTX_FIELDS.BYTES_OF_KEY_VALUE_DATA, littleEndian); | ||
if (pixelHeight === 0 || pixelDepth !== 1) { | ||
throw new Error('Only 2D textures are supported!'); | ||
} | ||
if (numberOfFaces !== 1) { | ||
throw new Error('CubeTextures are not supported!'); | ||
} | ||
if (numberOfArrayElements !== 1) { | ||
throw new Error('It does not support array textures!'); | ||
} | ||
var mipWidth = pixelWidth; | ||
var mipHeight = pixelHeight; | ||
var imageOffset = FILE_HEADER_SIZE + bytesOfKeyValueData; | ||
for (var mipmapLevel = 0; mipmapLevel < numberOfMipmapLevels; mipmapLevel++) { | ||
var imageSize = dataView.getUint32(imageOffset, littleEndian); | ||
imageOffset += 4; | ||
var size_1 = INTERNAL_FORMAT_TO_BLOCK_SIZE[_this.internalFormat]; | ||
var levelWidth = mipWidth % size_1[0] === 0 ? mipWidth : mipWidth + size_1[0] - (mipWidth % size_1[0]); | ||
var levelHeight = mipHeight % size_1[1] === 0 ? mipHeight : mipHeight + size_1[1] - (mipHeight % size_1[1]); | ||
var mip = { | ||
levelID: mipmapLevel, | ||
levelWidth: levelWidth, | ||
levelHeight: levelHeight, | ||
levelBuffer: new Uint8Array(source, imageOffset, imageSize) | ||
}; | ||
_this.levelBuffers.push(mip); | ||
imageOffset += imageSize; | ||
imageOffset += 3 - ((imageOffset + 3) % 4); | ||
mipWidth = (mipWidth >> 1) || 1; | ||
mipHeight = (mipHeight >> 1) || 1; | ||
} | ||
return _this; | ||
} | ||
return KTXTextureResource; | ||
}(CompressedTextureResource)); | ||
function validateKTX(dataView) { | ||
for (var i = 0; i < FILE_IDENTIFIER.length; i++) { | ||
if (dataView.getUint8(i) !== FILE_IDENTIFIER[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
var KTXLoadStrategy = (function (_super) { | ||
__extends(KTXLoadStrategy, _super); | ||
function KTXLoadStrategy() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
KTXLoadStrategy.prototype._complete = function (type, data) { | ||
_super.prototype._complete.call(this, type, new KTXTextureResource(data, this.config)); | ||
}; | ||
return KTXLoadStrategy; | ||
}(XhrLoadStrategy)); | ||
var KTXLoadStrategy$1 = KTXLoadStrategy; | ||
var XhrResponseType = eva_js.resourceLoader.XhrResponseType; | ||
function addPreProcessResourceHandler(resource, gl) { | ||
resource.addPreProcessResourceHandler(function normalizeResource(resource) { | ||
var _a, _b, _c; | ||
var textures = (_b = (_a = resource.src) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.texture; | ||
if (!textures) | ||
return; | ||
if (!Array.isArray(textures)) { | ||
textures = [textures]; | ||
} | ||
var formats = (_c = getSuportCompressedTextureFormats(gl)) !== null && _c !== void 0 ? _c : {}; | ||
var target = textures.find(function (texture) { return formats[texture.type]; }); | ||
if (target) { | ||
Object.assign(resource.src.image, target); | ||
} | ||
}); | ||
} | ||
function addKTXStragetyAndRegister() { | ||
Object.assign(eva_js.RESOURCE_TYPE_STRATEGY, { | ||
astc: KTXLoadStrategy$1, | ||
etc: KTXLoadStrategy$1, | ||
pvrtc: KTXLoadStrategy$1, | ||
s3tc: KTXLoadStrategy$1, | ||
atc: KTXLoadStrategy$1, | ||
}); | ||
KTXLoadStrategy$1.setExtensionXhrType('ktx', XhrResponseType.Buffer); | ||
} | ||
var GLTexture = pixi_js.glCore.GLTexture; | ||
var GLTextureMixin = { | ||
isCompressed: false, | ||
uploadNotCompressed: GLTexture.prototype.upload, | ||
upload: function (source) { | ||
if (!(source instanceof CompressedTextureResource)) { | ||
return this.uploadNotCompressed(source); | ||
} | ||
this.bind(); | ||
var gl = this.gl; | ||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha); | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST); | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); | ||
this.isCompressed = true; | ||
source.upload(gl); | ||
}, | ||
enableMipmap: function () { | ||
if (this.isCompressed) { | ||
return; | ||
} | ||
var gl = this.gl; | ||
this.bind(); | ||
this.mipmap = true; | ||
gl.generateMipmap(gl.TEXTURE_2D); | ||
} | ||
}; | ||
var TextureMixin = { | ||
oldFrom: pixi_js.Texture.from, | ||
from: function (source) { | ||
if (!(source instanceof CompressedTextureResource)) { | ||
return this.oldFrom(source); | ||
} | ||
return new pixi_js.Texture(pixi_js.BaseTexture.from(source)); | ||
} | ||
}; | ||
var BaseTextureMixin = { | ||
oldFrom: pixi_js.BaseTexture.from, | ||
from: function (source, scaleMode, sourceScale) { | ||
if (!(source instanceof CompressedTextureResource)) { | ||
return this.oldFrom(source, scaleMode, sourceScale); | ||
} | ||
var imageUrl = source.src; | ||
var baseTexture = pixi_js.utils.BaseTextureCache[imageUrl]; | ||
if (!baseTexture) { | ||
baseTexture = new pixi_js.BaseTexture(source, scaleMode); | ||
baseTexture.imageUrl = imageUrl; | ||
if (sourceScale) { | ||
baseTexture.sourceScale = sourceScale; | ||
} | ||
pixi_js.BaseTexture.addToCache(baseTexture, imageUrl); | ||
} | ||
return baseTexture; | ||
} | ||
}; | ||
function registerCompressedTexture(gl) { | ||
addPreProcessResourceHandler(eva_js.resource, gl); | ||
addKTXStragetyAndRegister(); | ||
Object.assign(pixi_js.glCore.GLTexture.prototype, GLTextureMixin); | ||
Object.assign(pixi_js.Texture, TextureMixin); | ||
Object.assign(pixi_js.BaseTexture, BaseTextureMixin); | ||
} | ||
exports.RENDERER_TYPE = void 0; | ||
@@ -429,2 +826,7 @@ (function (RENDERER_TYPE) { | ||
}); | ||
var gl = this.application.renderer.gl; | ||
if (gl) { | ||
this.suportedCompressedTextureFormats = getSuportCompressedTextureFormats(gl); | ||
registerCompressedTexture(gl); | ||
} | ||
}; | ||
@@ -452,5 +854,13 @@ Renderer.prototype.registerObserver = function (observerInfo) { | ||
} | ||
var app; | ||
try { | ||
app = new rendererAdapter.Application(__assign({ sharedTicker: true }, params)); | ||
} | ||
catch (e) { | ||
if (e.message.match(/not support webgl/i) !== undefined) { | ||
app = new rendererAdapter.Application(__assign(__assign({ sharedTicker: true }, params), { forceCanvas: true })); | ||
} | ||
} | ||
pixi_js.ticker.shared.stop(); | ||
pixi_js.ticker.shared.autoStart = false; | ||
pixi_js.ticker.shared.stop(); | ||
var app = new rendererAdapter.Application(__assign({ sharedTicker: true }, params)); | ||
if (params.preventScroll !== undefined) { | ||
@@ -550,2 +960,3 @@ console.warn('PreventScroll property will deprecate at next major version, please use enableEnable instead. https://eva.js.org/#/tutorials/game'); | ||
var _this = _super.call(this, params) || this; | ||
_this.asyncIdMap = {}; | ||
_this.observerInfo = _this.constructor.observerInfo; | ||
@@ -556,3 +967,3 @@ return _this; | ||
Renderer.prototype.rendererUpdate = function (_gameObject) { }; | ||
Renderer.prototype.update = function () { | ||
Renderer.prototype.update = function (e) { | ||
var e_1, _a; | ||
@@ -574,2 +985,9 @@ var changes = this.componentObserver.clear(); | ||
}; | ||
Renderer.prototype.increaseAsyncId = function (id) { | ||
this.asyncIdMap[id] = (this.asyncIdMap[id] || 0) + 1; | ||
return this.asyncIdMap[id]; | ||
}; | ||
Renderer.prototype.validateAsyncId = function (id, asyncId) { | ||
return this.asyncIdMap[id] === asyncId; | ||
}; | ||
return Renderer; | ||
@@ -579,2 +997,18 @@ }(eva_js.System)); | ||
var mixinPIXI = function () { | ||
pixi_js.BaseTexture.prototype.destroy = function () { | ||
if (this.imageUrl) { | ||
delete pixi_js.utils.TextureCache[this.imageUrl]; | ||
this.imageUrl = null; | ||
} | ||
this.source = null; | ||
this.dispose(); | ||
pixi_js.BaseTexture.removeFromCache(this); | ||
this.textureCacheIds = null; | ||
this._destroyed = true; | ||
}; | ||
}; | ||
mixinPIXI(); | ||
exports.ContainerManager = ContainerManager$1; | ||
@@ -581,0 +1015,0 @@ exports.Renderer = Renderer$1; |
@@ -1,1 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),r=require("@eva/renderer-adapter"),t=require("lodash-es/isEqual"),n=require("eventemitter3"),a=require("pixi.js");function o(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=o(t),c=o(n),s=function(e,r){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])},s(e,r)};function l(e,r){function t(){this.constructor=e}s(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}var p=function(){return p=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e},p.apply(this,arguments)};function h(e,r,t,n){var a,o=arguments.length,i=o<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,r,t,n);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(i=(o<3?a(i):o>3?a(r,t,i):a(r,t))||i);return o>3&&i&&Object.defineProperty(r,t,i),i}function u(e){var r="function"==typeof Symbol&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}function f(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,a,o=t.call(e),i=[];try{for(;(void 0===r||r-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(a)throw a.error}}return i}function d(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(f(arguments[r]));return e}var v,y=function(){function r(e){var r=e.game,t=e.rendererSystem;this.renderers=[],this.game=r,this.rendererSystem=t}return r.prototype.register=function(){for(var e,r,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{for(var a=u(t),o=a.next();!o.done;o=a.next()){var i=o.value;i.game=this.game,i.rendererManager=this.rendererSystem.rendererManager,i.containerManager=this.rendererSystem.containerManager,this.renderers.push(i)}}catch(r){e={error:r}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}},r.prototype.componentChanged=function(r){var t,n,a=function(r){var t,n;try{for(var a=(t=void 0,u(o.renderers)),c=a.next();!c.done;c=a.next()){var s=c.value,l=s.observerInfo[r.componentName];if(l){if([e.OBSERVER_TYPE.ADD,e.OBSERVER_TYPE.REMOVE].indexOf(r.type)>-1){try{s.componentChanged&&s.componentChanged(r)}catch(e){console.error("gameObject: "+r.gameObject.name+", "+r.componentName+" is error.",r,e)}continue}if(l.findIndex((function(e){return i(e,r.prop)}))>-1)try{s.componentChanged&&s.componentChanged(r)}catch(e){console.error("gameObject: "+(r.gameObject&&r.gameObject.name)+", "+r.componentName+" is componentChanged error.",r,e)}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},o=this;try{for(var c=u(r),s=c.next();!s.done;s=c.next()){a(s.value)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}},r.prototype.update=function(e){var r,t,n,a;try{for(var o=u(e.components),i=o.next();!i.done;i=o.next()){var c=i.value;try{for(var s=(n=void 0,u(this.renderers)),l=s.next();!l.done;l=s.next()){var p=l.value,h=[];if(p.observerInfo[c.name]&&-1===h.indexOf(e)){h.push(e);try{p.rendererUpdate&&p.rendererUpdate(e)}catch(r){console.info("gameObject: "+e.name+", "+c.name+" is update error",r)}}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}},r}(),m=function(){function e(){this.containerMap={}}return e.prototype.addContainer=function(e){var r=e.name,t=e.container;this.containerMap[r]=t},e.prototype.getContainer=function(e){return this.containerMap[e]},e.prototype.removeContainer=function(e){var r;null===(r=this.containerMap[e])||void 0===r||r.destroy({children:!0}),delete this.containerMap[e]},e.prototype.updateTransform=function(e){var r=e.name,t=e.transform,n=this.containerMap[r];if(n){var a=t.anchor,o=t.origin,i=t.position,c=t.rotation,s=t.scale,l=t.size,p=t.skew;n.rotation=c,n.scale=s,n.pivot.x=l.width*o.x,n.pivot.y=l.height*o.y,n.skew=p;var h=i.x,u=i.y;if(t.parent){var f=t.parent;h+=f.size.width*a.x,u+=f.size.height*a.y}n.position={x:h,y:u}}},e}(),g=function(t){function n(e){var r=e.system,n=e.containerManager,a=t.call(this)||this;return a.name="Transform",a.waitRemoveIds=[],a.waitChangeScenes=[],a.containerManager=n,a.init(r),a}return l(n,t),n.prototype.init=function(e){var r=this;this.system=e,this.on("changeScene",(function(e){var t=e.scene,n=e.mode,a=e.application;r.waitChangeScenes.push({scene:t,mode:n,application:a})}))},n.prototype.update=function(){var e,r,t,n;try{for(var a=u(this.waitRemoveIds),o=a.next();!o.done;o=a.next()){var i=o.value;this.containerManager.removeContainer(i)}}catch(r){e={error:r}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}this.waitRemoveIds=[];try{for(var c=u(this.waitChangeScenes),s=c.next();!s.done;s=c.next()){var l=s.value,p=this.containerManager.getContainer(l.scene.id);p&&(l.application.stage.removeChildren(),l.application.stage.addChild(p))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}this.waitChangeScenes=[]},n.prototype.componentChanged=function(r){r.type===e.OBSERVER_TYPE.ADD?this.addContainer(r):r.type===e.OBSERVER_TYPE.CHANGE?this.change(r):r.type===e.OBSERVER_TYPE.REMOVE&&this.waitRemoveIds.push(r.gameObject.id)},n.prototype.addContainer=function(e){var t=new r.Container;t.name=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:t}),e.component.worldTransform=t.transform.worldTransform},n.prototype.change=function(e){var r=e.component;if(r.parent){this.containerManager.getContainer(r.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));var t=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");t&&(t.sortDirty=!0)}else{var n=this.containerManager.getContainer(e.gameObject.id);delete r.worldTransform,n.parent&&n.parent.removeChild(n)}},n.prototype.destroy=function(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null},n=h([e.decorators.componentObserver({Transform:["_parent"]})],n)}(c);exports.RENDERER_TYPE=void 0,(v=exports.RENDERER_TYPE||(exports.RENDERER_TYPE={}))[v.UNKNOWN=0]="UNKNOWN",v[v.WEBGL=1]="WEBGL",v[v.CANVAS=2]="CANVAS";var w=function(e){e.plugins.interaction.autoPreventDefault=!0,e.view.style.touchAction="none"},E=function(e){e.plugins.interaction.autoPreventDefault=!1,e.view.style.touchAction="auto"},O=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.multiApps=[],e}return l(n,t),n.prototype.init=function(r){var t=this;this.params=r,this.application=this.createApplication(r),this.containerManager=new m,this.rendererManager=new y({game:this.game,rendererSystem:this}),this.game.canvas=this.application.view,this.transform=new g({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",(function(r){var n,a=r.scene,o=r.mode,i=r.params;switch(o){case e.LOAD_SCENE_MODE.SINGLE:n=t.application;break;case e.LOAD_SCENE_MODE.MULTI_CANVAS:n=t.createMultiApplication({params:i})}a.canvas=n.view,t.transform.emit("changeScene",{scene:a,mode:o,application:n})}))},n.prototype.registerObserver=function(e){var r,t=this.constructor.observerInfo;for(var n in e)t[n]||(t[n]=[]),(r=t[n]).push.apply(r,d(e[n]))},n.prototype.createMultiApplication=function(e){var r=e.params,t=this.createApplication(r);return this.multiApps.push(t),t},n.prototype.createApplication=function(e){e.view=e.canvas,e.renderType===exports.RENDERER_TYPE.CANVAS&&(e.forceCanvas=!0),a.ticker.shared.autoStart=!1,a.ticker.shared.stop();var t=new r.Application(p({sharedTicker:!0},e));return void 0!==e.preventScroll&&(console.warn("PreventScroll property will deprecate at next major version, please use enableEnable instead. https://eva.js.org/#/tutorials/game"),e.preventScroll?E(t.renderer):w(t.renderer)),void 0!==e.enableScroll&&(e.enableScroll?E(t.renderer):w(t.renderer)),void 0===e.preventScroll&&void 0===e.enableScroll&&E(t.renderer),t},n.prototype.update=function(){var e,r,t,n,a=this.componentObserver.clear();try{for(var o=u(a),i=o.next();!i.done;i=o.next()){var c=i.value;this.transform.componentChanged(c)}}catch(r){e={error:r}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}try{for(var s=u(this.game.gameObjects),l=s.next();!l.done;l=s.next()){var p=l.value;this.containerManager.updateTransform({name:p.id,transform:p.transform}),this.rendererManager.update(p)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},n.prototype.lateUpdate=function(e){this.transform.update(),this.application.ticker.update(e.time)},n.prototype.onDestroy=function(){var e,r;this.application.destroy();try{for(var t=u(this.multiApps),n=t.next();!n.done;n=t.next()){var a=n.value;a&&a.destroy()}}catch(r){e={error:r}}finally{try{n&&!n.done&&(r=t.return)&&r.call(t)}finally{if(e)throw e.error}}this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null},n.prototype.resize=function(e,r){this.params.width=e,this.params.height=r,this.application.renderer.resize(e,r)},n.systemName="Renderer",n=h([e.decorators.componentObserver({Transform:["_parent"]})],n)}(e.System),b=O,x=function(e){function r(r){var t=e.call(this,r)||this;return t.observerInfo=t.constructor.observerInfo,t}return l(r,e),r.prototype.componentChanged=function(e){},r.prototype.rendererUpdate=function(e){},r.prototype.update=function(){var e,r,t=this.componentObserver.clear();try{for(var n=u(t),a=n.next();!a.done;a=n.next()){var o=a.value;this.componentChanged(o)}}catch(r){e={error:r}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},r}(e.System);exports.ContainerManager=m,exports.Renderer=x,exports.RendererManager=y,exports.RendererSystem=b; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),r=require("@eva/renderer-adapter"),t=require("lodash-es/isEqual"),n=require("eventemitter3"),a=require("pixi.js");function o(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=o(t),c=o(n),s=function(e,r){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};function l(e,r){function t(){this.constructor=e}s(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}var p=function(){return(p=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e}).apply(this,arguments)};function h(e,r,t,n){var a,o=arguments.length,i=o<3?r:null===n?n=Object.getOwnPropertyDescriptor(r,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,r,t,n);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(i=(o<3?a(i):o>3?a(r,t,i):a(r,t))||i);return o>3&&i&&Object.defineProperty(r,t,i),i}function u(e){var r="function"==typeof Symbol&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}function f(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,a,o=t.call(e),i=[];try{for(;(void 0===r||r-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(a)throw a.error}}return i}function d(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(f(arguments[r]));return e}var v,y=function(){function r(e){var r=e.game,t=e.rendererSystem;this.renderers=[],this.game=r,this.rendererSystem=t}return r.prototype.register=function(){for(var e,r,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{for(var a=u(t),o=a.next();!o.done;o=a.next()){var i=o.value;i.game=this.game,i.rendererManager=this.rendererSystem.rendererManager,i.containerManager=this.rendererSystem.containerManager,this.renderers.push(i)}}catch(r){e={error:r}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}},r.prototype.componentChanged=function(r){var t,n,a=function(r){var t,n;try{for(var a=(t=void 0,u(o.renderers)),c=a.next();!c.done;c=a.next()){var s=c.value,l=s.observerInfo[r.componentName];if(l){if([e.OBSERVER_TYPE.ADD,e.OBSERVER_TYPE.REMOVE].indexOf(r.type)>-1){try{s.componentChanged&&s.componentChanged(r)}catch(e){console.error("gameObject: "+r.gameObject.name+", "+r.componentName+" is error.",r,e)}continue}if(l.findIndex((function(e){return i(e,r.prop)}))>-1)try{s.componentChanged&&s.componentChanged(r)}catch(e){console.error("gameObject: "+(r.gameObject&&r.gameObject.name)+", "+r.componentName+" is componentChanged error.",r,e)}}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}},o=this;try{for(var c=u(r),s=c.next();!s.done;s=c.next()){a(s.value)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}},r.prototype.update=function(e){var r,t,n,a;try{for(var o=u(e.components),i=o.next();!i.done;i=o.next()){var c=i.value;try{for(var s=(n=void 0,u(this.renderers)),l=s.next();!l.done;l=s.next()){var p=l.value,h=[];if(p.observerInfo[c.name]&&-1===h.indexOf(e)){h.push(e);try{p.rendererUpdate&&p.rendererUpdate(e)}catch(r){console.info("gameObject: "+e.name+", "+c.name+" is update error",r)}}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(n)throw n.error}}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}},r}(),m=function(){function e(){this.containerMap={}}return e.prototype.addContainer=function(e){var r=e.name,t=e.container;this.containerMap[r]=t},e.prototype.getContainer=function(e){return this.containerMap[e]},e.prototype.removeContainer=function(e){var r;null===(r=this.containerMap[e])||void 0===r||r.destroy({children:!0}),delete this.containerMap[e]},e.prototype.updateTransform=function(e){var r=e.name,t=e.transform,n=this.containerMap[r];if(n){var a=t.anchor,o=t.origin,i=t.position,c=t.rotation,s=t.scale,l=t.size,p=t.skew;n.rotation=c,n.scale=s,n.pivot.x=l.width*o.x,n.pivot.y=l.height*o.y,n.skew=p;var h=i.x,u=i.y;if(t.parent){var f=t.parent;h+=f.size.width*a.x,u+=f.size.height*a.y}n.position={x:h,y:u}}},e}(),g=function(t){function n(e){var r=e.system,n=e.containerManager,a=t.call(this)||this;return a.name="Transform",a.waitRemoveIds=[],a.waitChangeScenes=[],a.containerManager=n,a.init(r),a}return l(n,t),n.prototype.init=function(e){var r=this;this.system=e,this.on("changeScene",(function(e){var t=e.scene,n=e.mode,a=e.application;r.waitChangeScenes.push({scene:t,mode:n,application:a})}))},n.prototype.update=function(){var e,r,t,n;try{for(var a=u(this.waitRemoveIds),o=a.next();!o.done;o=a.next()){var i=o.value;this.containerManager.removeContainer(i)}}catch(r){e={error:r}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}this.waitRemoveIds=[];try{for(var c=u(this.waitChangeScenes),s=c.next();!s.done;s=c.next()){var l=s.value,p=this.containerManager.getContainer(l.scene.id);p&&(l.application.stage.removeChildren(),l.application.stage.addChild(p))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}this.waitChangeScenes=[]},n.prototype.componentChanged=function(r){r.type===e.OBSERVER_TYPE.ADD?this.addContainer(r):r.type===e.OBSERVER_TYPE.CHANGE?this.change(r):r.type===e.OBSERVER_TYPE.REMOVE&&this.waitRemoveIds.push(r.gameObject.id)},n.prototype.addContainer=function(e){var t=new r.Container;t.name=e.gameObject.name,this.containerManager.addContainer({name:e.gameObject.id,container:t}),e.component.worldTransform=t.transform.worldTransform},n.prototype.change=function(e){var r=e.component;if(r.parent){this.containerManager.getContainer(r.parent.gameObject.id).addChild(this.containerManager.getContainer(e.gameObject.id));var t=e.gameObject.transform.parent&&e.gameObject.transform.parent.gameObject.getComponent("Render");t&&(t.sortDirty=!0)}else{var n=this.containerManager.getContainer(e.gameObject.id);delete r.worldTransform,n.parent&&n.parent.removeChild(n)}},n.prototype.destroy=function(){this.removeAllListeners(),this.waitRemoveIds=null,this.waitChangeScenes=null,this.system=null,this.containerManager=null},n=h([e.decorators.componentObserver({Transform:["_parent"]})],n)}(c);exports.RENDERER_TYPE=void 0,(v=exports.RENDERER_TYPE||(exports.RENDERER_TYPE={}))[v.UNKNOWN=0]="UNKNOWN",v[v.WEBGL=1]="WEBGL",v[v.CANVAS=2]="CANVAS";var w=function(e){e.plugins.interaction.autoPreventDefault=!0,e.view.style.touchAction="none"},E=function(e){e.plugins.interaction.autoPreventDefault=!1,e.view.style.touchAction="auto"},O=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.multiApps=[],e}return l(n,t),n.prototype.init=function(r){var t=this;this.params=r,this.application=this.createApplication(r),this.containerManager=new m,this.rendererManager=new y({game:this.game,rendererSystem:this}),this.game.canvas=this.application.view,this.transform=new g({system:this,containerManager:this.containerManager}),this.game.on("sceneChanged",(function(r){var n,a=r.scene,o=r.mode,i=r.params;switch(o){case e.LOAD_SCENE_MODE.SINGLE:n=t.application;break;case e.LOAD_SCENE_MODE.MULTI_CANVAS:n=t.createMultiApplication({params:i})}a.canvas=n.view,t.transform.emit("changeScene",{scene:a,mode:o,application:n})}))},n.prototype.registerObserver=function(e){var r,t=this.constructor.observerInfo;for(var n in e)t[n]||(t[n]=[]),(r=t[n]).push.apply(r,d(e[n]))},n.prototype.createMultiApplication=function(e){var r=e.params,t=this.createApplication(r);return this.multiApps.push(t),t},n.prototype.createApplication=function(e){e.view=e.canvas,e.renderType===exports.RENDERER_TYPE.CANVAS&&(e.forceCanvas=!0),a.ticker.shared.autoStart=!1,a.ticker.shared.stop();var t=new r.Application(p({sharedTicker:!0},e));return void 0!==e.preventScroll&&(console.warn("PreventScroll property will deprecate at next major version, please use enableEnable instead. https://eva.js.org/#/tutorials/game"),e.preventScroll?E(t.renderer):w(t.renderer)),void 0!==e.enableScroll&&(e.enableScroll?E(t.renderer):w(t.renderer)),void 0===e.preventScroll&&void 0===e.enableScroll&&E(t.renderer),t},n.prototype.update=function(){var e,r,t,n,a=this.componentObserver.clear();try{for(var o=u(a),i=o.next();!i.done;i=o.next()){var c=i.value;this.transform.componentChanged(c)}}catch(r){e={error:r}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}try{for(var s=u(this.game.gameObjects),l=s.next();!l.done;l=s.next()){var p=l.value;this.containerManager.updateTransform({name:p.id,transform:p.transform}),this.rendererManager.update(p)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},n.prototype.lateUpdate=function(e){this.transform.update(),this.application.ticker.update(e.time)},n.prototype.onDestroy=function(){var e,r;this.application.destroy();try{for(var t=u(this.multiApps),n=t.next();!n.done;n=t.next()){var a=n.value;a&&a.destroy()}}catch(r){e={error:r}}finally{try{n&&!n.done&&(r=t.return)&&r.call(t)}finally{if(e)throw e.error}}this.transform.destroy(),this.transform=null,this.params=null,this.rendererManager=null,this.containerManager=null,this.application=null,this.game=null,this.multiApps=null},n.prototype.resize=function(e,r){this.params.width=e,this.params.height=r,this.application.renderer.resize(e,r)},n.systemName="Renderer",n=h([e.decorators.componentObserver({Transform:["_parent"]})],n)}(e.System),b=function(e){function r(r){var t=e.call(this,r)||this;return t.observerInfo=t.constructor.observerInfo,t}return l(r,e),r.prototype.componentChanged=function(e){},r.prototype.rendererUpdate=function(e){},r.prototype.update=function(){var e,r,t=this.componentObserver.clear();try{for(var n=u(t),a=n.next();!a.done;a=n.next()){var o=a.value;this.componentChanged(o)}}catch(r){e={error:r}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}},r}(e.System);exports.ContainerManager=m,exports.Renderer=b,exports.RendererManager=y,exports.RendererSystem=O; | ||
//# sourceMappingURL=plugin-renderer.cjs.prod.js.map |
@@ -1,6 +0,6 @@ | ||
import { OBSERVER_TYPE, decorators, LOAD_SCENE_MODE, System } from '@eva/eva.js'; | ||
import { OBSERVER_TYPE, decorators, resourceLoader, resource, RESOURCE_TYPE_STRATEGY, LOAD_SCENE_MODE, System } from '@eva/eva.js'; | ||
import { Container, Application } from '@eva/renderer-adapter'; | ||
import isEqual from 'lodash-es/isEqual'; | ||
import EventEmitter from 'eventemitter3'; | ||
import { ticker } from 'pixi.js'; | ||
import { glCore, Texture, BaseTexture, utils, ticker } from 'pixi.js'; | ||
@@ -234,3 +234,3 @@ /*! ***************************************************************************** | ||
var container = this.containerMap[name]; | ||
if (!container) | ||
if (!container || !transform) | ||
return; | ||
@@ -365,2 +365,399 @@ var anchor = transform.anchor, origin = transform.origin, position = transform.position, rotation = transform.rotation, scale = transform.scale, size = transform.size, skew = transform.skew; | ||
var result = undefined; | ||
function getSuportCompressedTextureFormats(gl) { | ||
if (result) | ||
return result; | ||
if (!gl) { | ||
console.warn('WebGL not available for compressed textures. Silently failing.'); | ||
return { | ||
s3tc: false, | ||
etc: false, | ||
etc1: false, | ||
pvrtc: false, | ||
atc: false, | ||
astc: false, | ||
}; | ||
} | ||
result = { | ||
s3tc: !!gl.getExtension('WEBGL_compressed_texture_s3tc'), | ||
etc: !!gl.getExtension('WEBGL_compressed_texture_etc'), | ||
etc1: !!gl.getExtension('WEBGL_compressed_texture_etc1'), | ||
pvrtc: !!gl.getExtension('WEBGL_compressed_texture_pvrtc') | ||
|| !!gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'), | ||
atc: !!gl.getExtension('WEBGL_compressed_texture_atc'), | ||
astc: !!gl.getExtension('WEBGL_compressed_texture_astc') | ||
}; | ||
try { | ||
console.log('Eva.js Supported Compressed Texture Format List: ' + Object.keys(result).filter(function (type) { return result[type]; }).join(', ')); | ||
} | ||
catch (e) { } | ||
return result; | ||
} | ||
var XLS = resourceLoader.XhrLoadStrategy; | ||
var XhrLoadStrategy = XLS; | ||
var _a, _b; | ||
var INTERNAL_FORMATS; | ||
(function (INTERNAL_FORMATS) { | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_S3TC_DXT1_EXT"] = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT1_EXT"] = 33777] = "COMPRESSED_RGBA_S3TC_DXT1_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT3_EXT"] = 33778] = "COMPRESSED_RGBA_S3TC_DXT3_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_S3TC_DXT5_EXT"] = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"] = 35917] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"] = 35918] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"] = 35919] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB_S3TC_DXT1_EXT"] = 35916] = "COMPRESSED_SRGB_S3TC_DXT1_EXT"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_R11_EAC"] = 37488] = "COMPRESSED_R11_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SIGNED_R11_EAC"] = 37489] = "COMPRESSED_SIGNED_R11_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RG11_EAC"] = 37490] = "COMPRESSED_RG11_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SIGNED_RG11_EAC"] = 37491] = "COMPRESSED_SIGNED_RG11_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB8_ETC2"] = 37492] = "COMPRESSED_RGB8_ETC2"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA8_ETC2_EAC"] = 37496] = "COMPRESSED_RGBA8_ETC2_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ETC2"] = 37493] = "COMPRESSED_SRGB8_ETC2"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"] = 37497] = "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"] = 37494] = "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"] = 37495] = "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_PVRTC_4BPPV1_IMG"] = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"] = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_PVRTC_2BPPV1_IMG"] = 35841] = "COMPRESSED_RGB_PVRTC_2BPPV1_IMG"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"] = 35843] = "COMPRESSED_RGBA_PVRTC_2BPPV1_IMG"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_ETC1_WEBGL"] = 36196] = "COMPRESSED_RGB_ETC1_WEBGL"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGB_ATC_WEBGL"] = 35986] = "COMPRESSED_RGB_ATC_WEBGL"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL"] = 35986] = "COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL"] = 34798] = "COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x10_KHR"] = 37819] = "COMPRESSED_RGBA_ASTC_10x10_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x5_KHR"] = 37816] = "COMPRESSED_RGBA_ASTC_10x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x6_KHR"] = 37817] = "COMPRESSED_RGBA_ASTC_10x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_10x8_KHR"] = 37818] = "COMPRESSED_RGBA_ASTC_10x8_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_12x10_KHR"] = 37820] = "COMPRESSED_RGBA_ASTC_12x10_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_12x12_KHR"] = 37821] = "COMPRESSED_RGBA_ASTC_12x12_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_4x4_KHR"] = 37808] = "COMPRESSED_RGBA_ASTC_4x4_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_5x4_KHR"] = 37809] = "COMPRESSED_RGBA_ASTC_5x4_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_5x5_KHR"] = 37810] = "COMPRESSED_RGBA_ASTC_5x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_6x5_KHR"] = 37811] = "COMPRESSED_RGBA_ASTC_6x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_6x6_KHR"] = 37812] = "COMPRESSED_RGBA_ASTC_6x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x5_KHR"] = 37813] = "COMPRESSED_RGBA_ASTC_8x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x6_KHR"] = 37814] = "COMPRESSED_RGBA_ASTC_8x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_RGBA_ASTC_8x8_KHR"] = 37815] = "COMPRESSED_RGBA_ASTC_8x8_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"] = 3781] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"] = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"] = 37849] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"] = 37850] = "COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"] = 37852] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"] = 37853] = "COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"] = 37840] = "COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"] = 37841] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"] = 37842] = "COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"] = 37843] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"] = 37844] = "COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"] = 37845] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"] = 37846] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR"; | ||
INTERNAL_FORMATS[INTERNAL_FORMATS["COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"] = 37847] = "COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR"; | ||
})(INTERNAL_FORMATS || (INTERNAL_FORMATS = {})); | ||
var INTERNAL_FORMAT_TO_BLOCK_SIZE = (_a = {}, | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = [8, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = [8, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = [4, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x5_KHR] = [5, 5], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x6_KHR] = [6, 6], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x8_KHR] = [8, 8], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x10_KHR] = [10, 10], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x12_KHR] = [12, 12], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x5_KHR] = [10, 5], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x6_KHR] = [10, 6], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x8_KHR] = [10, 8], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x10_KHR] = [12, 10], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x4_KHR] = [5, 4], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x5_KHR] = [6, 5], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x5_KHR] = [8, 5], | ||
_a[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x6_KHR] = [8, 6], | ||
_a); | ||
var INTERNAL_FORMATS_TO_EXTENSION_NAME = (_b = {}, | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT3_EXT] = 'WEBGL_compressed_texture_s3tc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_S3TC_DXT5_EXT] = 'WEBGL_compressed_texture_s3tc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = 'WEBGL_compressed_texture_s3tc_srgb', | ||
_b[INTERNAL_FORMATS.COMPRESSED_R11_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SIGNED_R11_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RG11_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SIGNED_RG11_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB8_ETC2] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA8_ETC2_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB8_ETC2] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = 'WEBGL_compressed_texture_etc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 'WEBGL_compressed_texture_pvrtc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_ETC1_WEBGL] = 'WEBGL_compressed_texture_etc1', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGB_ATC_WEBGL] = 'WEBGL_compressed_texture_atc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 'WEBGL_compressed_texture_atc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 'WEBGL_compressed_texture_atc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_4x4_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_5x5_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_6x6_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_8x8_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_10x10_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b[INTERNAL_FORMATS.COMPRESSED_RGBA_ASTC_12x12_KHR] = 'WEBGL_compressed_texture_astc', | ||
_b); | ||
var CompressedTextureResource = (function () { | ||
function CompressedTextureResource() { | ||
this.levelBuffers = []; | ||
} | ||
CompressedTextureResource.prototype.upload = function (gl) { | ||
var levels = this.levels; | ||
var name = INTERNAL_FORMATS_TO_EXTENSION_NAME[this.internalFormat]; | ||
if (!gl[name]) { | ||
gl[name] = true; | ||
if (name === 'WEBGL_compressed_texture_pvrtc') { | ||
gl.getExtension(name) || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc'); | ||
} | ||
else { | ||
gl.getExtension(name); | ||
} | ||
} | ||
for (var i = 0; i < this.levels; ++i) { | ||
var _a = this.levelBuffers[i], levelWidth = _a.levelWidth, levelHeight = _a.levelHeight, levelBuffer = _a.levelBuffer; | ||
gl.compressedTexImage2D(gl.TEXTURE_2D, i, this.internalFormat, levelWidth, levelHeight, 0, levelBuffer); | ||
} | ||
if (levels > 1) { | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); | ||
} | ||
else { | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); | ||
} | ||
}; | ||
return CompressedTextureResource; | ||
}()); | ||
var FILE_HEADER_SIZE = 64; | ||
var KTX_FIELDS = { | ||
FILE_IDENTIFIER: 0, | ||
ENDIANNESS: 12, | ||
GL_TYPE: 16, | ||
GL_TYPE_SIZE: 20, | ||
GL_FORMAT: 24, | ||
GL_INTERNAL_FORMAT: 28, | ||
GL_BASE_INTERNAL_FORMAT: 32, | ||
PIXEL_WIDTH: 36, | ||
PIXEL_HEIGHT: 40, | ||
PIXEL_DEPTH: 44, | ||
NUMBER_OF_ARRAY_ELEMENTS: 48, | ||
NUMBER_OF_FACES: 52, | ||
NUMBER_OF_MIPMAP_LEVELS: 56, | ||
BYTES_OF_KEY_VALUE_DATA: 60 | ||
}; | ||
var FILE_IDENTIFIER = [0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A]; | ||
var ENDIANNESS = 0x04030201; | ||
var KTXTextureResource = (function (_super) { | ||
__extends(KTXTextureResource, _super); | ||
function KTXTextureResource(source, config) { | ||
var _a; | ||
var _this = _super.call(this) || this; | ||
_this.complete = true; | ||
_this.src = config.url; | ||
var dataView = new DataView(source); | ||
if (!validateKTX(dataView)) { | ||
throw new Error('Not a valid KTX Texture'); | ||
} | ||
var littleEndian = dataView.getUint32(KTX_FIELDS.ENDIANNESS, true) === ENDIANNESS; | ||
_this.internalFormat = dataView.getUint32(KTX_FIELDS.GL_INTERNAL_FORMAT, littleEndian); | ||
var pixelWidth = _this.formerWidth = dataView.getUint32(KTX_FIELDS.PIXEL_WIDTH, littleEndian); | ||
var pixelHeight = _this.formerHeight = dataView.getUint32(KTX_FIELDS.PIXEL_HEIGHT, littleEndian) || 1; | ||
var size = INTERNAL_FORMAT_TO_BLOCK_SIZE[_this.internalFormat]; | ||
_this.width = pixelWidth % size[0] === 0 ? pixelWidth : (pixelWidth + size[0] - (pixelWidth % size[0])); | ||
_this.height = pixelHeight % size[1] === 0 ? pixelHeight : (pixelHeight + size[1] - (pixelHeight % size[1])); | ||
var src = resource.resourcesMap[config.metadata.name].src[config.metadata.key]; | ||
var _b = (_a = src === null || src === void 0 ? void 0 : src.size) !== null && _a !== void 0 ? _a : {}, width = _b.width, height = _b.height; | ||
if (width && height) { | ||
_this.naturalWidth = width; | ||
_this.naturalHeight = height; | ||
} | ||
var pixelDepth = dataView.getUint32(KTX_FIELDS.PIXEL_DEPTH, littleEndian) || 1; | ||
var numberOfArrayElements = dataView.getUint32(KTX_FIELDS.NUMBER_OF_ARRAY_ELEMENTS, littleEndian) || 1; | ||
var numberOfFaces = dataView.getUint32(KTX_FIELDS.NUMBER_OF_FACES, littleEndian); | ||
var numberOfMipmapLevels = _this.levels = dataView.getUint32(KTX_FIELDS.NUMBER_OF_MIPMAP_LEVELS, littleEndian); | ||
var bytesOfKeyValueData = dataView.getUint32(KTX_FIELDS.BYTES_OF_KEY_VALUE_DATA, littleEndian); | ||
if (pixelHeight === 0 || pixelDepth !== 1) { | ||
throw new Error('Only 2D textures are supported!'); | ||
} | ||
if (numberOfFaces !== 1) { | ||
throw new Error('CubeTextures are not supported!'); | ||
} | ||
if (numberOfArrayElements !== 1) { | ||
throw new Error('It does not support array textures!'); | ||
} | ||
var mipWidth = pixelWidth; | ||
var mipHeight = pixelHeight; | ||
var imageOffset = FILE_HEADER_SIZE + bytesOfKeyValueData; | ||
for (var mipmapLevel = 0; mipmapLevel < numberOfMipmapLevels; mipmapLevel++) { | ||
var imageSize = dataView.getUint32(imageOffset, littleEndian); | ||
imageOffset += 4; | ||
var size_1 = INTERNAL_FORMAT_TO_BLOCK_SIZE[_this.internalFormat]; | ||
var levelWidth = mipWidth % size_1[0] === 0 ? mipWidth : mipWidth + size_1[0] - (mipWidth % size_1[0]); | ||
var levelHeight = mipHeight % size_1[1] === 0 ? mipHeight : mipHeight + size_1[1] - (mipHeight % size_1[1]); | ||
var mip = { | ||
levelID: mipmapLevel, | ||
levelWidth: levelWidth, | ||
levelHeight: levelHeight, | ||
levelBuffer: new Uint8Array(source, imageOffset, imageSize) | ||
}; | ||
_this.levelBuffers.push(mip); | ||
imageOffset += imageSize; | ||
imageOffset += 3 - ((imageOffset + 3) % 4); | ||
mipWidth = (mipWidth >> 1) || 1; | ||
mipHeight = (mipHeight >> 1) || 1; | ||
} | ||
return _this; | ||
} | ||
return KTXTextureResource; | ||
}(CompressedTextureResource)); | ||
function validateKTX(dataView) { | ||
for (var i = 0; i < FILE_IDENTIFIER.length; i++) { | ||
if (dataView.getUint8(i) !== FILE_IDENTIFIER[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
var KTXLoadStrategy = (function (_super) { | ||
__extends(KTXLoadStrategy, _super); | ||
function KTXLoadStrategy() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
KTXLoadStrategy.prototype._complete = function (type, data) { | ||
_super.prototype._complete.call(this, type, new KTXTextureResource(data, this.config)); | ||
}; | ||
return KTXLoadStrategy; | ||
}(XhrLoadStrategy)); | ||
var KTXLoadStrategy$1 = KTXLoadStrategy; | ||
var XhrResponseType = resourceLoader.XhrResponseType; | ||
function addPreProcessResourceHandler(resource, gl) { | ||
resource.addPreProcessResourceHandler(function normalizeResource(resource) { | ||
var _a, _b, _c; | ||
var textures = (_b = (_a = resource.src) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.texture; | ||
if (!textures) | ||
return; | ||
if (!Array.isArray(textures)) { | ||
textures = [textures]; | ||
} | ||
var formats = (_c = getSuportCompressedTextureFormats(gl)) !== null && _c !== void 0 ? _c : {}; | ||
var target = textures.find(function (texture) { return formats[texture.type]; }); | ||
if (target) { | ||
Object.assign(resource.src.image, target); | ||
} | ||
}); | ||
} | ||
function addKTXStragetyAndRegister() { | ||
Object.assign(RESOURCE_TYPE_STRATEGY, { | ||
astc: KTXLoadStrategy$1, | ||
etc: KTXLoadStrategy$1, | ||
pvrtc: KTXLoadStrategy$1, | ||
s3tc: KTXLoadStrategy$1, | ||
atc: KTXLoadStrategy$1, | ||
}); | ||
KTXLoadStrategy$1.setExtensionXhrType('ktx', XhrResponseType.Buffer); | ||
} | ||
var GLTexture = glCore.GLTexture; | ||
var GLTextureMixin = { | ||
isCompressed: false, | ||
uploadNotCompressed: GLTexture.prototype.upload, | ||
upload: function (source) { | ||
if (!(source instanceof CompressedTextureResource)) { | ||
return this.uploadNotCompressed(source); | ||
} | ||
this.bind(); | ||
var gl = this.gl; | ||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha); | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST); | ||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); | ||
this.isCompressed = true; | ||
source.upload(gl); | ||
}, | ||
enableMipmap: function () { | ||
if (this.isCompressed) { | ||
return; | ||
} | ||
var gl = this.gl; | ||
this.bind(); | ||
this.mipmap = true; | ||
gl.generateMipmap(gl.TEXTURE_2D); | ||
} | ||
}; | ||
var TextureMixin = { | ||
oldFrom: Texture.from, | ||
from: function (source) { | ||
if (!(source instanceof CompressedTextureResource)) { | ||
return this.oldFrom(source); | ||
} | ||
return new Texture(BaseTexture.from(source)); | ||
} | ||
}; | ||
var BaseTextureMixin = { | ||
oldFrom: BaseTexture.from, | ||
from: function (source, scaleMode, sourceScale) { | ||
if (!(source instanceof CompressedTextureResource)) { | ||
return this.oldFrom(source, scaleMode, sourceScale); | ||
} | ||
var imageUrl = source.src; | ||
var baseTexture = utils.BaseTextureCache[imageUrl]; | ||
if (!baseTexture) { | ||
baseTexture = new BaseTexture(source, scaleMode); | ||
baseTexture.imageUrl = imageUrl; | ||
if (sourceScale) { | ||
baseTexture.sourceScale = sourceScale; | ||
} | ||
BaseTexture.addToCache(baseTexture, imageUrl); | ||
} | ||
return baseTexture; | ||
} | ||
}; | ||
function registerCompressedTexture(gl) { | ||
addPreProcessResourceHandler(resource, gl); | ||
addKTXStragetyAndRegister(); | ||
Object.assign(glCore.GLTexture.prototype, GLTextureMixin); | ||
Object.assign(Texture, TextureMixin); | ||
Object.assign(BaseTexture, BaseTextureMixin); | ||
} | ||
var RENDERER_TYPE; | ||
@@ -419,2 +816,7 @@ (function (RENDERER_TYPE) { | ||
}); | ||
var gl = this.application.renderer.gl; | ||
if (gl) { | ||
this.suportedCompressedTextureFormats = getSuportCompressedTextureFormats(gl); | ||
registerCompressedTexture(gl); | ||
} | ||
}; | ||
@@ -442,5 +844,13 @@ Renderer.prototype.registerObserver = function (observerInfo) { | ||
} | ||
var app; | ||
try { | ||
app = new Application(__assign({ sharedTicker: true }, params)); | ||
} | ||
catch (e) { | ||
if (e.message.match(/not support webgl/i) !== undefined) { | ||
app = new Application(__assign(__assign({ sharedTicker: true }, params), { forceCanvas: true })); | ||
} | ||
} | ||
ticker.shared.stop(); | ||
ticker.shared.autoStart = false; | ||
ticker.shared.stop(); | ||
var app = new Application(__assign({ sharedTicker: true }, params)); | ||
if (params.preventScroll !== undefined) { | ||
@@ -540,2 +950,3 @@ console.warn('PreventScroll property will deprecate at next major version, please use enableEnable instead. https://eva.js.org/#/tutorials/game'); | ||
var _this = _super.call(this, params) || this; | ||
_this.asyncIdMap = {}; | ||
_this.observerInfo = _this.constructor.observerInfo; | ||
@@ -546,3 +957,3 @@ return _this; | ||
Renderer.prototype.rendererUpdate = function (_gameObject) { }; | ||
Renderer.prototype.update = function () { | ||
Renderer.prototype.update = function (e) { | ||
var e_1, _a; | ||
@@ -564,2 +975,9 @@ var changes = this.componentObserver.clear(); | ||
}; | ||
Renderer.prototype.increaseAsyncId = function (id) { | ||
this.asyncIdMap[id] = (this.asyncIdMap[id] || 0) + 1; | ||
return this.asyncIdMap[id]; | ||
}; | ||
Renderer.prototype.validateAsyncId = function (id, asyncId) { | ||
return this.asyncIdMap[id] === asyncId; | ||
}; | ||
return Renderer; | ||
@@ -569,2 +987,18 @@ }(System)); | ||
var mixinPIXI = function () { | ||
BaseTexture.prototype.destroy = function () { | ||
if (this.imageUrl) { | ||
delete utils.TextureCache[this.imageUrl]; | ||
this.imageUrl = null; | ||
} | ||
this.source = null; | ||
this.dispose(); | ||
BaseTexture.removeFromCache(this); | ||
this.textureCacheIds = null; | ||
this._destroyed = true; | ||
}; | ||
}; | ||
mixinPIXI(); | ||
export { ContainerManager$1 as ContainerManager, RENDERER_TYPE, Renderer$1 as Renderer, RendererManager$1 as RendererManager, Renderer$3 as RendererSystem }; |
{ | ||
"name": "@eva/plugin-renderer", | ||
"version": "1.1.1-fix.1", | ||
"version": "1.1.1-fix.2", | ||
"description": "@eva/plugin-renderer", | ||
@@ -21,4 +21,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@eva/eva.js": "1.1.1-fix.1", | ||
"@eva/renderer-adapter": "1.1.1-fix.1", | ||
"@eva/eva.js": "1.1.1-fix.2", | ||
"@eva/renderer-adapter": "1.1.1-fix.2", | ||
"eventemitter3": "^3.1.2", | ||
@@ -25,0 +25,0 @@ "lodash-es": "^4.17.21", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
367965
11
4150
3
+ Added@eva/eva.js@1.1.1-fix.2(transitive)
+ Added@eva/renderer-adapter@1.1.1-fix.2(transitive)
- Removed@eva/eva.js@1.1.1-fix.1(transitive)
- Removed@eva/renderer-adapter@1.1.1-fix.1(transitive)
Updated@eva/eva.js@1.1.1-fix.2