I'm following the docs exactly in my example.
Firstly, the docs give no information how to resize the Spine Player itself. The example from your link shows a large area left and right that is not part of the animation. If you add a background it also has the same problem. (I tried attaching a movie of it, but 9MB is too big.)
Secondly, if you have a non-simple canvas where things not rendered in sprites are off screen, then it is a whole different level of things broken. The bounding boxes move around, and if you have a background meant for different aspect ratios, it makes it even small and moving around.
The goal is to show in a canvas size of choice (can sniff browser size for example) and to display a responsive animation with no letter boxing. I don't know where all of this background space is coming from, because it's not in the Spine file or atlas.
Finally, the atlas really seems to dictate size, the only way I can get it to zoom in is by guessing and checking, but I have no idea what is happening to the divs. The HTML is dead simple with no added CSS.
What is my big picture? To not have to render frames which would be a few hundred MB loaded in the browser as a gif. I want to display an animation in a div that is a responsive wrapped of the Spine Player canvas and contains nothing that wouldn't be rendered in a frame.
Notes: It's not listed either how you should prepare your file. Should 0,0 be in the middle, top-middle, bottom-left (most logical to me) or somewhere else to have the least trouble guessing where the animation is in the canvas.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Here is an example of the file with broken output:
import { useEffect } from "react";
import { SpinePlayer } from "@esotericsoftware/spine-player";
import "@esotericsoftware/spine-player/dist/spine-player.min.css";
const jsonUrl = "../src/assets/Spine.json";
const atlasUrl = "../src/assets/Tiffany.atlas";
const SpineTest = () => {
useEffect(() => {
const spinePlayer = new SpinePlayer("player-container", {
jsonUrl: jsonUrl,
atlasUrl: atlasUrl,
showControls: true,
preserveDrawingBuffer: true,
premultipliedAlpha: false,
showLoading: true,
viewport: {
debugRender: true,
// Ensure the Spine animation fits to the canvas size
fitToCanvas: true,
},
animation: "eyes track FINAL",
success: function (player) {
player.addAnimation("eyes track FINAL", true);
player.play();
},
});
return () => {
spinePlayer?.dispose();
};
}, []);
return (
<div
id="player-container"
style={{
width: "100vw",
height: "100vh",
}}
></div>
);
};
export default SpineTest;