Struct Pointer #21712
Unanswered
cemalgnlts
asked this question in
Q&A
Struct Pointer
#21712
Replies: 1 comment
-
This is how I was able to build a structure: function Vector3(x, y, z, ptr) {
memoryApi.setValue(ptr, x, "float");
memoryApi.setValue(ptr + 4, y, "float");
memoryApi.setValue(ptr + 8, z, "float");
}
function Camera3D() {
const camPtr = memoryApi.stackAlloc(44);
const fovy = 45.0;
const projection = 0;
const position = Vector3(0, 10, 10, camPtr);
const target = Vector3(0, 0, 0, camPtr + 12);
const up = Vector3(0, 1, 0, camPtr + 24);
memoryApi.setValue(camPtr + 36, fovy, "float");
memoryApi.setValue(camPtr + 40, projection, "i32");
return camPtr;
} I'm not sure if this is the best way. I also don't know why function Vector3(x, y, z, ptr) {
const arr = new Float32Array([x, y, z]);
memoryApi.writeArrayToMemory(arr, ptr);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
The library I use defines a
struct
like this:Creating pointers for
Vector3
was easy:But
Camera3D
doesn't work the way I want it to. I'm probably using it wrong:I'm not sure how it should be for
Camera3D
.Beta Was this translation helpful? Give feedback.
All reactions