import { expect } from "@esm-bundle/chai"; import { VoxelManager } from "../../src/grid/VoxelManager.js"; import { VoxelGrid } from "../../src/grid/VoxelGrid.js"; import * as THREE from "three"; describe.skip("Phase 1: VoxelManager Rendering (WebGL)", () => { let grid; let scene; let manager; let renderer; before(() => { // 1. Setup a real WebGL Renderer (Headless) const canvas = document.createElement("canvas"); // Force context creation to check support const context = canvas.getContext("webgl"); if (!context) { console.warn( "WebGL not supported in this test environment. Skipping render checks." ); this.skip(); } renderer = new THREE.WebGLRenderer({ canvas, context }); }); beforeEach(() => { grid = new VoxelGrid(4, 4, 4); scene = new THREE.Scene(); manager = new VoxelManager(grid, scene, null); }); it("CoA 1: init() should create a real InstancedMesh in the scene", () => { grid.fill(1); // Fill with stone manager.init(); const mesh = scene.children.find((c) => c.isInstancedMesh); expect(mesh).to.exist; expect(mesh.count).to.equal(64); // 4*4*4 }); it("CoA 2: update() should correctly position instances", () => { grid.setCell(0, 0, 0, 1); // Only one block manager.init(); const mesh = scene.children[0]; const matrix = new THREE.Matrix4(); mesh.getMatrixAt(0, matrix); // Get transform of first block const position = new THREE.Vector3().setFromMatrixPosition(matrix); expect(position.x).to.equal(0); expect(position.y).to.equal(0); expect(position.z).to.equal(0); }); it("CoA 3: render loop should not crash", () => { // Verify we can actually call render() without WebGL errors const camera = new THREE.PerspectiveCamera(); manager.init(); expect(() => renderer.render(scene, camera)).to.not.throw(); }); });