I'm working with storing 3d models into mongodb.
In one case, I want to store all the vertex data (which is an ArrayBuffer) of a 3d model as binary data just like this:
{
name: model_1,
vertexBuffer: <Binary Data>
}
How can I store the arraybuffer as binary data in mongodb via node.js?
There is a Binary() function :
const bson = require('bson');
{
name: model_1,
vertexBuffer: new bson.Binary(<Binary Data>)
}
But you may need to convert ArrayBuffer to Buffer. Please read Convert a binary NodeJS Buffer to JavaScript ArrayBuffer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With