forked from EXT/VR180-Web-Player
This commit is contained in:
@@ -2,10 +2,13 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
applyHeadPositionLock,
|
||||
applySbsTextureWindow,
|
||||
hideContentMeshes,
|
||||
isLeftEyeCamera,
|
||||
positionPlaneForPresentation,
|
||||
resetHeadPositionLockedContent,
|
||||
shouldLockContentToHeadPosition,
|
||||
showActiveContentMesh
|
||||
} from '../vr180player/rendering/projection.js';
|
||||
|
||||
@@ -30,10 +33,21 @@ function createRenderer({ isPresenting = false, xrCamera = null } = {}) {
|
||||
function createCamera(x, projectionOffset = 0) {
|
||||
return {
|
||||
matrixWorldInverse: { elements: new Array(16).fill(0).with(12, x) },
|
||||
matrixWorld: { elements: new Array(16).fill(0).with(12, x).with(13, 1.7).with(14, 0.25) },
|
||||
projectionMatrix: { elements: new Array(16).fill(0).with(8, projectionOffset) }
|
||||
};
|
||||
}
|
||||
|
||||
function createPositionedMesh() {
|
||||
const calls = [];
|
||||
return {
|
||||
calls,
|
||||
position: {
|
||||
set: (...args) => calls.push(args)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
test('applySbsTextureWindow uses left eye only in non-XR 2D fallback', () => {
|
||||
const material = createMaterial();
|
||||
|
||||
@@ -104,3 +118,44 @@ test('positionPlaneForPresentation uses the fallback camera depth in 2D plane mo
|
||||
assert.deepEqual(calls[0], [0, 1.6, -1.0999999999999999]);
|
||||
assert.deepEqual(calls[1], [0, 1.6, -3]);
|
||||
});
|
||||
|
||||
test('shouldLockContentToHeadPosition defaults to VR180 only in auto mode', () => {
|
||||
assert.equal(shouldLockContentToHeadPosition('auto', 'vr180'), true);
|
||||
assert.equal(shouldLockContentToHeadPosition('auto', 'plane'), false);
|
||||
assert.equal(shouldLockContentToHeadPosition('position', 'plane'), true);
|
||||
assert.equal(shouldLockContentToHeadPosition('none', 'vr180'), false);
|
||||
});
|
||||
|
||||
test('applyHeadPositionLock centers VR180 content on the XR camera position', () => {
|
||||
const mesh = createPositionedMesh();
|
||||
|
||||
applyHeadPositionLock(mesh, createCamera(0.4), 'vr180', true, 3);
|
||||
|
||||
assert.deepEqual(mesh.calls[0], [0.4, 1.7, 0.25]);
|
||||
});
|
||||
|
||||
test('applyHeadPositionLock keeps opt-in plane content in front of the XR camera position', () => {
|
||||
const mesh = createPositionedMesh();
|
||||
|
||||
applyHeadPositionLock(mesh, createCamera(-0.25), 'plane', true, 3);
|
||||
|
||||
assert.deepEqual(mesh.calls[0], [-0.25, 1.7, -2.75]);
|
||||
});
|
||||
|
||||
test('applyHeadPositionLock leaves content untouched when disabled', () => {
|
||||
const mesh = createPositionedMesh();
|
||||
|
||||
applyHeadPositionLock(mesh, createCamera(0.4), 'vr180', false, 3);
|
||||
|
||||
assert.deepEqual(mesh.calls, []);
|
||||
});
|
||||
|
||||
test('resetHeadPositionLockedContent restores default mesh positions', () => {
|
||||
const vr180Mesh = createPositionedMesh();
|
||||
const planeMesh = createPositionedMesh();
|
||||
|
||||
resetHeadPositionLockedContent(vr180Mesh, planeMesh, 3);
|
||||
|
||||
assert.deepEqual(vr180Mesh.calls[0], [0, 0, 0]);
|
||||
assert.deepEqual(planeMesh.calls[0], [0, 1.6, -3]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user