I'm currently in the process of developing a library that consists of 'letter' functions responsible for generating letters in vertex coordinates. The main objective here is to allow users to create words or sentences using an interactive PointsCloud feature. Unfortunately, utilizing TextGeometry hasn't been successful as it doesn't produce an adequate amount of vertex points.
The W() function is designed to incorporate all the corner points, which are inputted manually. On the other hand, the Draw() function works to 'draw' vertex points between the manually provided points.
However, I'm encountering an issue wherein my code is triggering a 'Potential out of Memory error' crash, and the exact cause remains unclear. Google Chrome is highlighting the 'for' loop within the Draw() function as the root of the problem.
function W(int) {
w = new THREE.Geometry();
w.vertices.push(
new THREE.Vector3(-1,1,0),
new THREE.Vector3(-.5,-1,0),
new THREE.Vector3(0,1,0),
new THREE.Vector3(5,-1,0),
new THREE.Vector3(1,1,0)
)
var temp = w;
for(var u = 0; u < temp.vertices.length; u++){
Draw(w,int,u,u++)
}
return w;
}
function Draw(P,intensity, v1, v2)
{
for (var i = 0; i < intensity; i++){
var diffX = Math.abs(P.vertices[v1].x - P.vertices[v2].x);
var spacingX = diffX/intensity;
if(P.vertices[v1].x-P.vertices[v2].x > 0){spacingX=spacingX*-1}
var diffY = Math.abs(P.vertices[v1].y - P.vertices[v2].y);
var spacingY = diffY/intensity;
if(P.vertices[v1].y-P.vertices[v2].y > 0){spacingY=spacingY*-1}
var diffZ = Math.abs(P.vertices[v1].z - P.vertices[v2].z);
var spacingZ = diffZ/intensity;
if(P.vertices[v1].z-P.vertices[v2].z > 0){spacingZ=spacingZ*-1}
p = new THREE.Vector3(
P.vertices[v1].x+spacingX*i,
P.vertices[v1].y+spacingY*i,
P.vertices[v1].z+spacingZ*i
)
P.vertices.push(p)
}
}
pointCloud = new THREE.Points(W(10), pointMaterial)
scene.add(pointCloud)