Converting Matrix4 to Float32Array via the builtin float32Array()
method after a while results in:
error: Uncaught (in promise) TypeError: Cannot perform Construct on a detached ArrayBuffer
return new Float32Array(this.#internal);
^
at new Float32Array (<anonymous>)
at Matrix4.toFloat32Array (https://deno.land/x/gmath@0.1.12/src/matrix4.ts:508:12)
at Renderer.render (file:///C:/Users/user/Projects/weebeepeeuu/src/renderer.ts:223:28)
at file:///C:/Users/user/Projects/weebeepeeuu/src/app.ts:72:21
at fn (https://deno.land/x/dwm@0.3.6/src/platform/glfw/window.ts:1173:13)
at Object.action (ext:deno_web/02_timers.js:154:11)
at handleTimerMacrotask (ext:deno_web/02_timers.js:68:10)
at eventLoopTick (ext:core/01_core.js:71:21)
part of the code that produces this:
(inside a render function which gets called every frame. not async)
const projection = new PerspectiveFov(
new Rad(Math.PI / 4),
800 / 600,
0.1,
1000,
)
.toPerspective().toMatrix4();
const view = Matrix4.lookAtRh(
new Vector3(-2, 0, 2),
new Vector3(0, 0, 0),
new Vector3(0, 0, 1),
);
const model = Matrix4.fromAngleZ(new Rad(this.t));
// lil hacky, but i know that the uniformbuffer is at index 0
state.device.queue.writeBuffer(
this.state.bBuffers[0].buffer,
0,
model.toFloat32Array(),
); // this doesnt. this gets updated with the value t, so i guess it has to have something to do with that
state.device.queue.writeBuffer(
this.state.bBuffers[0].buffer,
64,
view.toFloat32Array(),
); // for some foking reason this erros eventually with `TypeError: Cannot perform Construct on a detached ArrayBuffer`
state.device.queue.writeBuffer(
this.state.bBuffers[0].buffer,
128,
projection.toFloat32Array(),
); // this aswell
but as the comments say, the matrix which gets created every time with a different value (this.t) doesnt have this problem. not sure why.
EDIT: current fix is to call toFloat32Array()
directly. like this:
const view = Matrix4.lookAtRh(
new Vector3(-2, 0, 2),
new Vector3(0, 0, 0),
new Vector3(0, 0, 1),
).toFloat32Array();
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too
We use tracking cookies to understand how you use the product and help us improve it.