I’m trying to get an effect to apply inside a 3D line shape.
I have a line which is drawn in space - 3d points - and I would like to draw a different color / apply a shader to the pixels inside the shape from the viewport of the camera.
My hint would be to use a shader which applies to the whole scene and process every point of my line and check if the pixel is inside or outside the line?
Thanks, I think i will try that even though that’s not quite right.
I have a generative 3D typography which looks like this :
It’s a 3d outline in space. - this is why I simplified it in the demo with 3d points on a circle with different depths … -
I want to apply a shader to the inside of the outline, but I believe the quickest way / less computationally intensive is to make a mesh in the first place rather than processing the inside after its creation.
Best approach to fill up an outline is to use this, or that from here? or something else?
fillUpFromVector3Array takes a list of 3D points and fills it up like Shape would do.
export function fillUpFromVector3Array(array){
var letterShape = new THREE.Shape(array);
var geometry = new THREE.ShapeBufferGeometry( letterShape );
var mWireframe = new THREE.MeshBasicMaterial( { color: 0x00ff00, side:THREE.DoubleSide, wireframe: true } );
var mColor = new THREE.MeshBasicMaterial( { color: 0xfe00ef, side:THREE.DoubleSide } );
mColor.opacity = 0.4;
var mesh = new THREE.Mesh( geometry, mColor ) ;
var customGeom = new THREE.Geometry();
console.log(geometry);
console.log(mesh);
var points3D = geometry.attributes.position.array;
for( var i = 0; i < points3D.length; i+=3){
var indexArray = i / 3;
var pointToAdd = new THREE.Vector3(points3D[i], points3D[i + 1], array[indexArray].z);
customGeom.vertices.push(pointToAdd);
}
var faces3D = geometry.index.array;
for( var i = 0; i < faces3D.length; i+=3){
customGeom.faces.push( new THREE.Face3( faces3D[i], faces3D[i + 1], faces3D[i + 2]));
}
customGeom.computeBoundingSphere();
var customMesh = new THREE.Mesh( customGeom, mWireframe);
// customMesh.add(wFrame);
return customMesh;
}
It seems like the Shape is meant to do that already, but it doesn’t, as seen in the example WebGL_geometry_shapes.html : californiaPts is meant to have a random depth, but is rendered flat?
I’m asking as i feel that what I am doing is a little convoluted maybe?