Help to rewrite part2
let geometry = new THREE.PlaneGeometry(0.4, 0.2)
#part2
geometry.faces.forEach(function(face){
face.vertexNormals.forEach(function(normal){
normal.set(0.0,1.0,0.0).normalize()
})
})
thanks in advance!
Help to rewrite part2
let geometry = new THREE.PlaneGeometry(0.4, 0.2)
#part2
geometry.faces.forEach(function(face){
face.vertexNormals.forEach(function(normal){
normal.set(0.0,1.0,0.0).normalize()
})
})
thanks in advance!
Hello! Try this
let geometry = new THREE.PlaneGeometry(0.4, 0.2);
var item=geometry.attributes.normal.array;
var max=geometry.attributes.normal.count*3;
for(var n=0;n<max;n+=3){
item[n]=0;
item[n+1]=1;
item[n+2]=0;
}
geometry.normalizeNormals();
geometry.attributes.normal.needsUpdate=true;
Do it like so:
const geometry = new THREE.PlaneGeometry(0.4, 0.2);
const normalAttribute = geometry.getAttribute( 'normal' );
for ( let i = 0; i < normalAttribute.count; i ++ ) {
normalAttribute.setXYZ( i, 0, 1, 0 );
}
@Chaser_Code It’s not recommended to directly work with the array
property of buffer attributes. Your approach breaks with interleaved data.
It’s also not necessary to set needsUpdate
to true
if you have not rendered the data yet. And the call of normalizeNormals()
is also not required since the new normals are already unit vectors.
Thank you so much for the reply! I was struggling with this…once again thank you!