Hi, in an ASP.NET solution, I have to load models in the client from a byte array that I get from this MeshController.cs (for the purpose of my test I use a local .ply file that I convert into a byte array):
[HttpGet]
public async Task<IActionResult> GetMesh(string meshFileName)
{
byte[] result;
using (FileStream fs = System.IO.File.OpenRead($@"{meshFileName}.ply"))
{
using (BinaryReader binaryReader = new BinaryReader(fs))
{
result = binaryReader.ReadBytes((int)fs.Length);
}
}
return File(result, "application/octet-stream");
}
Then the data that is read as such:
var meshData = await response.Content.ReadAsByteArrayAsync();
I try to get inspired from the file dialog ref: Load file from Buffer not Path - #5 by BretCameron.
So here is the load method in my .js:
loadModelFromData() {
var loader = new PLYLoader();
var plyGeometry = loader.parse(this.meshData);
plyGeometry.sourceType = "ply";
var plyMaterial = new THREE.MeshStandardMaterial({ color: 0xFFA500 });
var plyMesh = new THREE.Mesh(plyGeometry, plyMaterial);
thisScene.add(plyMesh);
}
I tried different things with the parse method of the loader, but I remain unsuccessful.
What is it that I am missing?