MCPcopy Create free account
hub / github.com/melonjs/melonJS / resolveTextureAtlas

Function resolveTextureAtlas

packages/melonjs/src/renderable/mesh.js:33–45  ·  view source on GitHub ↗
(src, framewidth, frameheight)

Source from the content-addressed store, hash-verified

31// to the whole image); a subclass like Sprite3d passes them so the atlas
32// carries an animation frame grid.
33function resolveTextureAtlas(src, framewidth, frameheight) {
34 if (src instanceof TextureAtlas) {
35 return src;
36 }
37 const image = typeof src === "object" ? src : getImage(src);
38 if (!image) {
39 throw new Error("Mesh: '" + src + "' image/texture not found!");
40 }
41 return game.renderer.cache.get(image, {
42 framewidth: framewidth || image.width,
43 frameheight: frameheight || image.height,
44 });
45}
46
47/**
48 * Normalize an emissive color input (`[r, g, b]` array / Float32Array, or

Callers 1

constructorMethod · 0.85

Calls 2

getImageFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected