* @param {object|object[]} atlases - atlas information. See loader.getJSON * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|CompressedImage|string|OffscreenCanvas[]|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] - Image source * @param {boolean|object
(atlases, src, options)
| 103 | * ); |
| 104 | */ |
| 105 | constructor(atlases, src, options) { |
| 106 | // backward compat: 3rd arg used to be a `cache` boolean. |
| 107 | const opts = |
| 108 | typeof options === "boolean" ? { cache: options } : options || {}; |
| 109 | const cache = opts.cache; |
| 110 | const normalMap = opts.normalMap; |
| 111 | /** |
| 112 | * to identify the atlas format (e.g. texture packer) |
| 113 | * @ignore |
| 114 | */ |
| 115 | this.format = null; |
| 116 | |
| 117 | /** |
| 118 | * the texture source(s) itself |
| 119 | * @type {Map} |
| 120 | * @ignore |
| 121 | */ |
| 122 | this.sources = new Map(); |
| 123 | |
| 124 | /** |
| 125 | * paired normal-map source(s), keyed identically to `sources`. |
| 126 | * Populated from the constructor's `options.normalMap`. Used by |
| 127 | * the WebGL renderer's lit pipeline for per-pixel lighting. |
| 128 | * @type {Map} |
| 129 | * @ignore |
| 130 | */ |
| 131 | this.normalSources = new Map(); |
| 132 | |
| 133 | /** |
| 134 | * the atlas dictionnaries |
| 135 | * @type {Map} |
| 136 | * @ignore |
| 137 | */ |
| 138 | this.atlases = new Map(); |
| 139 | |
| 140 | /** |
| 141 | * the default "active" atlas (used for multiAtlas) |
| 142 | * @type {Map} |
| 143 | * @ignore |
| 144 | */ |
| 145 | this.activeAtlas = undefined; |
| 146 | |
| 147 | /** |
| 148 | * UV lookup cache to avoid per-frame string allocation in drawImage |
| 149 | * @ignore |
| 150 | */ |
| 151 | this._uvCache = { sx: -1, sy: -1, sw: -1, sh: -1, uvs: null }; |
| 152 | |
| 153 | // parse given atlas(es) paremeters |
| 154 | if (typeof atlases !== "undefined") { |
| 155 | // normalize to array to keep the following code generic |
| 156 | atlases = Array.isArray(atlases) ? atlases : [atlases]; |
| 157 | for (const i in atlases) { |
| 158 | const atlas = atlases[i]; |
| 159 | |
| 160 | if (typeof atlas.meta !== "undefined") { |
| 161 | this.format = identifyFormat(atlas.meta.app); |
| 162 | this.repeat = atlas.meta.repeat || "no-repeat"; |
nothing calls this directly
no test coverage detected