JavaScript library not working in Shopify liquid template
I’m helping someone set up their Shopify store and trying to integrate a JavaScript graphics library. I created a liquid template file called graphics-display.liquid but when I include it in the theme, only text appears instead of the expected visual content.
My current setup:
<head>
<meta charset="utf-8">
<title>3D Graphics Demo</title>
<style>
body { margin: 0; padding: 0; }
</style>
</head>
<body>
<script src="babylon.js"></script>
<script>
var canvas = document.createElement('canvas');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
document.body.appendChild(canvas);
var engine = new BABYLON.Engine(canvas, true);
var createScene = function() {
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera("camera", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
var light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);
var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {diameter: 2}, scene);
return scene;
};
var gameScene = createScene();
engine.runRenderLoop(function() {
gameScene.render();
});
</script>
</body>
I’m including this in my main theme file using {% render 'graphics-display' %} but it’s not displaying the 3D content properly. The JavaScript library seems to load but the visual elements don’t appear. Has anyone dealt with similar asset loading issues in Shopify themes?