Interface SpriteFinder
Sprite
s from baked texture coordinates.
Example use cases include interpolating the textures of a submodel's quads in
FabricBlockStateModel.emitQuads(QuadEmitter, BlockRenderView, BlockPos, BlockState, Random, Predicate)
or
finding the sprite for use in QuadView.toBakedQuad(Sprite)
.
A sprite finder can be retrieved from various vanilla objects. Always use
FabricErrorCollectingSpriteGetter.spriteFinder(Identifier)
, FabricStitchResult.spriteFinder()
, or
FabricAtlasPreparation.spriteFinder()
whenever an applicable instance is available. For example, model
baking is supplied with a ErrorCollectingSpriteGetter
, so it should be used to retrieve the sprite finder.
In most other cases, it is safe to use FabricSpriteAtlasTexture.spriteFinder()
.
-
Method Summary
Modifier and TypeMethodDescriptionfind
(float u, float v) Alternative tofind(QuadView, int)
when vertex centroid is already known or unsuitable.Finds the atlas sprite containing the vertex centroid of the quad.default Sprite
Deprecated.static SpriteFinder
get
(SpriteAtlasTexture atlas) Deprecated.UseFabricSpriteAtlasTexture.spriteFinder()
instead.
-
Method Details
-
find
Finds the atlas sprite containing the vertex centroid of the quad. Vertex centroid is essentially the mean u,v coordinate - the intent being to find a point that is unambiguously inside the sprite (vs on an edge.)Should be reliable for any convex quad or triangle. May fail for non-convex quads. Note that all the above refers to u,v coordinates. Geometric vertex does not matter, except to the extent it was used to determine u,v.
-
find
Alternative tofind(QuadView, int)
when vertex centroid is already known or unsuitable. Expects normalized (0-1) coordinates on the atlas texture, which should already be the case for u,v values in vanilla baked quads and inQuadView
after callingMutableQuadView.spriteBake(Sprite, int)
.Coordinates must be in the sprite interior for reliable results. Generally will be easier to use
find(QuadView, int)
unless you know the vertex centroid will somehow not be in the quad interior. This method will be slightly faster if you already have the centroid or another appropriate value. -
get
Deprecated.UseFabricSpriteAtlasTexture.spriteFinder()
instead. -
find
Deprecated.Usefind(QuadView)
instead.
-
find(QuadView)
instead.