i am using three.js to display a .ply model, and i found a modified version of three.js’ official example webgl_loader-ply(from https://editor.p5js.org/setapolo/full/7idSig9acP). This modified version load all library and models from remote servers using url, and i can run this file in my browser without problem.
const loader = new PLYLoader();
// 'https://threejs.org/examples/models/ply/ascii/dolphins.ply' The author uses this url to load model from a remote server
loader.load( 'http://127.0.0.1:8080/static/dolphins.ply', function ( geometry ) { // I replaced his url with mine which is a local server running on my pc
geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial( { color: 0x0055ff, flatShading: true } );
const mesh = new THREE.Mesh( geometry, material );
mesh.position.y = - 0.2;
mesh.position.z = 0.3;
mesh.rotation.x = - Math.PI / 2;
mesh.scale.multiplyScalar( 0.001 );
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add( mesh );
} );
However, when i tried to replace the model with my own, nothing is displayed. i tried either a local directory path or a url to a local golang static file server, and they all failed. I am pretty sure these two dolphines.ply files are exactly the same.
I’ve seen some other question, tried to reference mesh.rotate.x
or mesh.scale.multiplyscalar
and didnot work.
By the way, my .ply model comes with texture, i also want to know how to disply the model’s texture, instead of create a pure color texture in the js code.
Thank you very much.