hello
i have a question
A ply model without a uv was added by creating a uv.
and i added texture
The texture stretches along the z-axis. Why is this so? What is the reason?
this is my code
const plyloader = new PLYLoader()
plyloader.load(
'./models/newmesh.ply',
function (geometry) {
geometry.computeBoundingBox();
const positionAttribute = geometry.attributes.position;
// Create a new Float32BufferAttribute to hold the UV coordinates
const uvAttribute = new THREE.Float32BufferAttribute( geometry.attributes.position.count * 3, 3 );
// Calculate the UV coordinates based on the geometry's bounding box
const boundingBox = new THREE.Box3().setFromBufferAttribute( positionAttribute );
console.log(boundingBox)
for ( let i = 0; i < positionAttribute.count; i ++ ) {
const point = new THREE.Vector3().fromBufferAttribute( positionAttribute, i );
const uv = new THREE.Vector4(
( point.x - boundingBox.min.x ) / ( boundingBox.max.x - boundingBox.min.x ),
( point.y - boundingBox.min.y ) / ( boundingBox.max.y - boundingBox.min.y ),
( point.z - boundingBox.min.z ) / ( boundingBox.max.z - boundingBox.min.z ),
);
uvAttribute.setXYZ(i, uv.x, uv.y, uv.z);
}
// Set the UV attribute of the geometry
geometry.setAttribute( 'uv', uvAttribute );
// Create a new Mesh with the geometry and a material
const material = new THREE.MeshStandardMaterial( { map: texture, side: THREE.DoubleSide } );
const mesh = new THREE.Mesh( geometry, material );
mesh.scale.set(0.01,0.01,0.01)
// Add the mesh to the scene
editor.scene.add( mesh );
console.log(mesh)
},
(xhr) => {
console.log((xhr.loaded / xhr.total) * 100 + '% loaded')
},
(error) => {
console.log(error)
}
)