RobLoach / node-raylib

Node.js bindings for Raylib
https://robloach.github.io/node-raylib/
Other
233 stars 20 forks source link

Please add example of drawing an .obj with a material/texture. #176

Open Triazic opened 1 year ago

Triazic commented 1 year ago

I can use 'LoadModel' to load my obj and I can render it using DrawModel with a tint.

But I can't figure out how to apply texture/material to it. Of the following functions in the cheatsheet:

image

Only SetModelMeshMaterial is exposed which I can't do, if I can't load it in the first place: image

And the approach used in the raylib example here doesn't work due to type errors: image

I don't doubt there is a way but I'd rather not dig into the cryptic bowels of the js/ts wrappings etc. Please provide an example using the API as it stands today.

konsumer commented 1 year ago

I would recommend looking at the original raylib examples, which all of our examples are based on. If you can't find an example of what you are trying to do, there are lots of helpful people on the raylib discord (including the 3 maintainers of this lib, like me, and the original author of raylib) that can probably help you put one together.

twuky commented 1 year ago

right now the typescript definitions for this are correct - it is a number instead of an array - or rather its a pointer address to the array in c memory, and there isn't a way to work with it from JS at the moment. there are a lot of places like this that still are pretty lacking in node-raylib, and it largely affects the 3d workflow. in all likelyhood this may not be the best library to work in 3d with, at the moment

twuky commented 1 year ago

this PR has some work in this regard - but materials still don't work in it https://github.com/RobLoach/node-raylib/pull/172

Triazic commented 1 year ago

Noting the comment re. 3D not being great and the types being cooked, I have moved on from this library. The C# implementation Raylib-cs so far seems to have all the functions ported it's also not perfect (orbital camera doesn't work zz).

twuky commented 1 year ago

C# will also give you a far easier time outputting builds as complete EXEs too. unless you are 100% married to TS/JS, or need your Express server to render some text/images, it just needs more work. theres a lot of hard-to-handle stuff going on with memory management with the C code, and representing that data in JS, and handing it back-and-forth efficiently