11import { AttributeBinding , createProgramFromRaw } from "./shaderUtils"
22import { AmbientLight , DirectionalLight , PointLight } from "./light" ;
3- import { m4fromPositionAndEuler , m4inverse , m4multiply , m4orthographic , m4perspective , m4PositionMultiply , m4xRotation , Mat4 } from "./mat4" ;
3+ import { m4fromPositionAndEuler , m4inverse , m4multiply , m4orthographic , m4perspective , m4PositionMultiply , m4ToArray , m4xRotation , Mat4 } from "./mat4" ;
44import { Camera } from "./camera" ;
55import { InputState } from "./input" ;
66
@@ -103,9 +103,9 @@ export function updateUniforms(
103103 camera . aspect ,
104104 camera . near ,
105105 camera . far )
106- gl . uniformMatrix4fv ( renderProgram . worldMatrixUniformLocation , false , shapeWorld ) ;
107- gl . uniformMatrix4fv ( renderProgram . viewUniformLocation , false , viewMatrix ) ;
108- gl . uniformMatrix4fv ( renderProgram . projectionUniformLocation , false , projectionMatrix ) ;
106+ gl . uniformMatrix4fv ( renderProgram . worldMatrixUniformLocation , false , m4ToArray ( shapeWorld ) ) ;
107+ gl . uniformMatrix4fv ( renderProgram . viewUniformLocation , false , m4ToArray ( viewMatrix ) ) ;
108+ gl . uniformMatrix4fv ( renderProgram . projectionUniformLocation , false , m4ToArray ( projectionMatrix ) ) ;
109109
110110 // update material uniforms
111111 gl . uniform3fv ( renderProgram . materialUniform . colorLocation , colorToArray ( mesh . material . color ) ) ;
@@ -122,7 +122,7 @@ export function updateUniforms(
122122
123123 // shadows
124124 // shadow map must be bound
125- gl . uniformMatrix4fv ( renderProgram . shadowUniform . lightViewLocation , false , lightViewProjectionMatrix ) ;
125+ gl . uniformMatrix4fv ( renderProgram . shadowUniform . lightViewLocation , false , m4ToArray ( lightViewProjectionMatrix ) ) ;
126126
127127
128128 // set point light
@@ -585,8 +585,8 @@ export function drawShadowScene(
585585 const drawInitializedMesh = ( mesh : Mesh ) => {
586586 const vao = glState . vaos . get ( mesh . _id ! ) ! ;
587587 gl . bindVertexArray ( vao ) ;
588- gl . uniformMatrix4fv ( shadowProgram . u_model , false , node . _worldTransform ) ;
589- gl . uniformMatrix4fv ( shadowProgram . u_lightViewProj , false , lightViewProj ) ;
588+ gl . uniformMatrix4fv ( shadowProgram . u_model , false , m4ToArray ( node . _worldTransform ) ) ;
589+ gl . uniformMatrix4fv ( shadowProgram . u_lightViewProj , false , m4ToArray ( lightViewProj ) ) ;
590590 if ( mesh . vertices . indices ) {
591591 gl . drawElements ( gl . TRIANGLES , mesh . vertices . indices . length , gl . UNSIGNED_SHORT , 0 ) ;
592592 } else {
0 commit comments