Attempting to construct numbers along a 3D grid using THREE.TextGeometry()
However, only one number is being generated. How can I fix this issue?
The "current" variable ranges from -10 to 10, excluding 0. My IDE (PyCharm) is indicating that the "Mutable Variable is accessible from closure"
I'm unsure of what mistake I am making and how to resolve it. Thank you
function createGridNumbersX(size){
var grpGridNumbersX = new THREE.Group();
grpGridNumbersX.name = 'grpGridNrsX' ;
var loader = new THREE.FontLoader();
var fontType = 'fonts/helvetiker_regular.typeface.json';
var textMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff});
for (i=0; i<(size*2)+1; i++) {
var counter = i + 1;
var start = -size - 1;
var current = start + counter;
if (i === size) {
continue
}
console.log('current ' + current);
loader.load(fontType, function (font, ) {
var textGeometry = new THREE.TextGeometry(**current**, {
font: font,
size: 0.3,
height: false,
});
var mesh = new THREE.Mesh(textGeometry, textMaterial);
mesh.name = 'xNr' + i;
mesh.position.x = current;
grpGridNumbersX.add(mesh);
});
}
scene.add(grpGridNumbersX);
} createGridNumbersX(10);