More WebVR (controller) fixes;

This commit is contained in:
bjorn 2019-10-09 14:53:58 -07:00
parent d8d07bfbe8
commit 8c0ae3fbb3
3 changed files with 11 additions and 4 deletions

View File

@ -51,7 +51,8 @@ if(EMSCRIPTEN)
"-s ALLOW_MEMORY_GROWTH=1 "
"-s \"EXPORTED_FUNCTIONS=[ "
"'_main','_lovrDestroy',"
"'_mat4_identity','_mat4_invert','_mat4_multiply','_mat4_rotateQuat','_mat4_transform','_mat4_transformDirection',"
"'_webvr_onAnimationFrame',"
"'_mat4_set','_mat4_identity','_mat4_invert','_mat4_multiply','_mat4_rotateQuat','_mat4_transform','_mat4_transformDirection',"
"'_quat_fromMat4','_quat_getAngleAxis'"
"]\" "
"-s \"EXTRA_EXPORTED_RUNTIME_METHODS=['getValue','setValue']\" "

View File

@ -28,7 +28,7 @@ static struct {
void* renderData;
} state;
static void webvr_onAnimationFrame(float* leftView, float* rightView, float* leftProjection, float* rightProjection) {
void webvr_onAnimationFrame(float* leftView, float* rightView, float* leftProjection, float* rightProjection) {
Camera camera = { .canvas = NULL, .stereo = true };
memcpy(camera.projection[0], leftProjection, 16 * sizeof(float));
memcpy(camera.projection[1], rightProjection, 16 * sizeof(float));

View File

@ -69,7 +69,8 @@ var LibraryLOVR = {
HEAPF32[webvr.poseTransform >> 2 + 13] = webvr.offset;
}
Module._mat4_invert(Module._mat4_init(e, webvr.poseTransform));
Module._mat4_set(e, webvr.poseTransform);
Module._mat4_invert(e);
HEAPF32.set(webvr.frameData.leftViewMatrix, a >> 2);
HEAPF32.set(webvr.frameData.rightViewMatrix, b >> 2);
HEAPF32.set(webvr.frameData.leftProjectionMatrix, c >> 2);
@ -175,7 +176,8 @@ var LibraryLOVR = {
if (pose.orientation) {
HEAPF32.set(pose.orientation, orientation >> 2);
Module._mat4_rotateQuat(Module._mat4_init(webvr.matA, webvr.poseTransform), orientation);
Module._mat4_set(webvr.matA, webvr.poseTransform);
Module._mat4_rotateQuat(webvr.matA, orientation);
Module._quat_fromMat4(orientation, webvr.matA);
} else {
HEAPF32.fill(0, orientation >> 2, orientation >> 2 + 4);
@ -297,6 +299,10 @@ var LibraryLOVR = {
ORIGIN_HEAD: 0,
ORIGIN_FLOOR: 1,
// Device
DEVICE_HAND_LEFT: 0,
DEVICE_HAND_RIGHT: 1,
// DeviceAxis
AXIS_TRIGGER: 0,
AXIS_THUMBSTICK: 1,