I wrote a very simple server to send both ASCII and binary format of PCD file to three.js front-end.
Three.js can show ASCII format correctly.
However, the loader cannot load the binary file with the correct encoding.
When I inspect the content of PCDLoader.js Line:72
/mrdoob/three.js/blob/dev/examples/jsm/loaders/PCDLoader.js#L72 in chrome debugger. The data will be converted to utf-8 encoding (one-byte content will be expended to 2 bytes).
How can I solve this issue?
Reproduce
I made a sample project to reproduce this result.
GitHub: HTLife/pcdutf8
How to use it:
Run server
cd server
node main.js
Start front-end
npm install
npm run dev
You should see the front-end load the ascii file and show with no problem
I don’t understand this. The onLoad() callback gets an array buffer as result (data). Since the header of a PCD file is always in ASCII text, a respective decode is performed. Can you please explain in more detail what you mean?
The parsed position attribute of your file contains some NaN values which is suspicious.
I’ve made another test with your binary PCD file. I’ve just copied it over to the three.js repository and load it from our dev server (http-server). Everything works fine: