The Spine Web Player automatically calculates the viewport based on the current animation, determining a rectangle that contains the rendered textures for that specific animation.
The background, being part of your animation, is taken into account and will be included in the calculation of that rectangle.
You can manually specify the viewport using the viewport
configuration property. The x
, y
, width
, and height
properties are all in skeleton world coordinates, meaning x=0
and y=0
correspond to the skeleton world origin.
Regarding the spine-cpp
runtime, all our runtimes provide a Skeleton#getBounds
method, which determines a rectangle that contains the skeleton in its current pose. Rendering-aware runtimes, such as the spine-player
itself, typically use this method to calculate the bounds of the current animation.
You could instantiate a skeleton, hide the attachments you don't want to include in the bounds calculation, and determine your desired viewport. This approach can also be applied to the web player.
Alternatively, you could create an attachment in the editor that simulates your desired viewport and use that attachment in the runtime to easily determine the correct viewport.