/* Copyright (C) 2024 Sebastián Santisi , CSC-CONICET */ import * as THREE from 'three'; function checkBoard(width, height) { var geometry = new THREE.PlaneGeometry(width, height, width, height); geometry = geometry.toNonIndexed(); const colors = new three.BufferAttribute(new Float32Array(geometry.attributes.position.array.length), 3); for(var i = 0; i < colors.count; i++) { var col = Math.trunc(i / 6) % width; var row = Math.trunc(i / 6 / width); if((col + row % 2) % 2) colors.setXYZ(i, 0x44 / 0xff, 0xaa / 0xff, 0); else colors.setXYZ(i, 0x55 / 0xff, 0xd4 / 0xff, 0); } geometry.setAttribute('color', colors); const material = new THREE.MeshBasicMaterial({vertexColors: THREE.VertexColors}); var mesh = new THREE.Mesh(geometry, material); mesh.position.x = width / 2; mesh.position.y = height / 2; return mesh; } export { checkBoard };