node-raylib icon indicating copy to clipboard operation
node-raylib copied to clipboard

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

Open Triazic opened this issue 2 years ago • 5 comments

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.

Triazic avatar Jul 01 '23 11:07 Triazic

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.

konsumer avatar Jul 01 '23 20:07 konsumer

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 avatar Jul 02 '23 05:07 twuky

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

twuky avatar Jul 02 '23 05:07 twuky

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).

Triazic avatar Jul 04 '23 15:07 Triazic

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

twuky avatar Jul 04 '23 16:07 twuky