I want to render a Spine animation in a webpage. I I just want it to be responsive and scale with a div that scales. The problem I can't figure out (even with chatGPT) is how to make it ever scale to the size of the Spine Player, and for the Spine Player to not letterbox things.
What I have now is the animation playing, but it's small and centered inside bounding boxes that make no sense for this file. In other files, if things fly off the screen the bounding boxes move around. I want output to be exactly like it would be if I rendered frames to a gif or APNG.
While I was able to increase the zoom, it is illogical and relies on CSS that isn't part of Spine Player so it's not a working solution, just a small victory in getting the scale to increase.
How can I make Spine Player behave like a normal div and render content like frames?
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: false,
preserveDrawingBuffer: true,
premultipliedAlpha: false,
showLoading: false,
backgroundColor: "#f100f2",
fullScreenBackgroundColor: "000000",
viewport: {
debugRender: true,
x: -4000,
y: -4000,
width: 4000,
height: 4000,
padLeft: "0%",
padRight: "0%",
padTop: "0%",
padBottom: "0%",
},
animation: "eyes track FINAL",
success: function (player) {
player.fitToCanvas = true;
player.play();
},
});
// Adjust canvas size on window resize
const handleResize = () => {
const container = document.getElementById('player-container');
if (container && spinePlayer) {
spinePlayer.setCanvasSize(container.clientWidth, container.clientHeight);
}
};
window.addEventListener('resize', handleResize);
return () => {
spinePlayer?.dispose();
window.removeEventListener('resize', handleResize);
};
}, []);
return <div id="player-container" style={{ width: '100%', height: '100%' }}></div>;
};
export default SpineTest;```