forked from EXT/VR180-Web-Player
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { VideoTextureManager } from '../vr180player/rendering/texture-manager.js';
|
||||
import { MediaTextureManager } from '../vr180player/rendering/texture-manager.js';
|
||||
|
||||
function createTexture(name) {
|
||||
return {
|
||||
@@ -17,13 +17,13 @@ function createVideo({ paused = false, ended = false } = {}) {
|
||||
return { ended, paused };
|
||||
}
|
||||
|
||||
test('VideoTextureManager replaces the previous texture when creating a new one', () => {
|
||||
test('MediaTextureManager replaces the previous texture when creating a new one', () => {
|
||||
const created = [];
|
||||
const manager = new VideoTextureManager(createVideo(), () => {
|
||||
const manager = new MediaTextureManager(createVideo(), () => {
|
||||
const texture = createTexture(`texture-${created.length}`);
|
||||
created.push(texture);
|
||||
return texture;
|
||||
});
|
||||
}, () => true);
|
||||
|
||||
const first = manager.create();
|
||||
const second = manager.create();
|
||||
@@ -34,9 +34,9 @@ test('VideoTextureManager replaces the previous texture when creating a new one'
|
||||
assert.equal(created.length, 2);
|
||||
});
|
||||
|
||||
test('VideoTextureManager assigns and clears material maps', () => {
|
||||
test('MediaTextureManager assigns and clears material maps', () => {
|
||||
const material = { map: null, needsUpdate: false };
|
||||
const manager = new VideoTextureManager(createVideo(), () => createTexture('assigned'));
|
||||
const manager = new MediaTextureManager(createVideo(), () => createTexture('assigned'), () => true);
|
||||
|
||||
const texture = manager.assignToMaterial(material);
|
||||
|
||||
@@ -53,21 +53,25 @@ test('VideoTextureManager assigns and clears material maps', () => {
|
||||
assert.equal(manager.current, null);
|
||||
});
|
||||
|
||||
test('VideoTextureManager only marks textures dirty while playback is active', () => {
|
||||
test('MediaTextureManager only marks textures dirty when the update predicate allows it', () => {
|
||||
const video = createVideo();
|
||||
const manager = new VideoTextureManager(video, () => createTexture('playing'));
|
||||
const manager = new MediaTextureManager(
|
||||
video,
|
||||
() => createTexture('playing'),
|
||||
() => !video.paused && !video.ended
|
||||
);
|
||||
const texture = manager.create();
|
||||
|
||||
manager.updateIfPlaying();
|
||||
manager.updateIfNeeded();
|
||||
assert.equal(texture.needsUpdate, true);
|
||||
|
||||
texture.needsUpdate = false;
|
||||
video.paused = true;
|
||||
manager.updateIfPlaying();
|
||||
manager.updateIfNeeded();
|
||||
assert.equal(texture.needsUpdate, false);
|
||||
|
||||
video.paused = false;
|
||||
video.ended = true;
|
||||
manager.updateIfPlaying();
|
||||
manager.updateIfNeeded();
|
||||
assert.equal(texture.needsUpdate, false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user