Skip to content

Commit

Permalink
Merge pull request videojs#25 from kevleyski/main
Browse files Browse the repository at this point in the history
chore: Swap webvr for webxr polyfill packages (PR fix ups - cubemap)
  • Loading branch information
kevleyski authored Jan 31, 2023
2 parents e444322 + dc27ea8 commit cd05e47
Showing 1 changed file with 42 additions and 24 deletions.
66 changes: 42 additions & 24 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,32 +208,50 @@ class VR extends Plugin {
this.movieGeometry = new THREE.BoxBufferGeometry(256, 256, 256);
this.movieMaterial = new THREE.MeshBasicMaterial({ map: this.videoTexture, side: THREE.BackSide });

const left = [new THREE.Vector2(0, 0.5), new THREE.Vector2(0.333, 0.5), new THREE.Vector2(0.333, 1), new THREE.Vector2(0, 1)];
const right = [new THREE.Vector2(0.333, 0.5), new THREE.Vector2(0.666, 0.5), new THREE.Vector2(0.666, 1), new THREE.Vector2(0.333, 1)];
const top = [new THREE.Vector2(0.666, 0.5), new THREE.Vector2(1, 0.5), new THREE.Vector2(1, 1), new THREE.Vector2(0.666, 1)];
const bottom = [new THREE.Vector2(0, 0), new THREE.Vector2(0.333, 0), new THREE.Vector2(0.333, 0.5), new THREE.Vector2(0, 0.5)];
const front = [new THREE.Vector2(0.333, 0), new THREE.Vector2(0.666, 0), new THREE.Vector2(0.666, 0.5), new THREE.Vector2(0.333, 0.5)];
const back = [new THREE.Vector2(0.666, 0), new THREE.Vector2(1, 0), new THREE.Vector2(1, 0.5), new THREE.Vector2(0.666, 0.5)];

const uvs = this.movieGeometry.getAttribute('uv');

uvs.setXYZ(0, right[2], right[1], right[3]);
uvs.setXYZ(1, right[1], right[0], right[3]);

uvs.setXYZ(2, left[2], left[1], left[3]);
uvs.setXYZ(3, left[1], left[0], left[3]);

uvs.setXYZ(4, top[2], top[1], top[3]);
uvs.setXYZ(5, top[1], top[0], top[3]);

uvs.setXYZ(6, bottom[2], bottom[1], bottom[3]);
uvs.setXYZ(7, bottom[1], bottom[0], bottom[3]);

uvs.setXYZ(8, front[2], front[1], front[3]);
uvs.setXYZ(9, front[1], front[0], front[3]);

uvs.setXYZ(10, back[2], back[1], back[3]);
uvs.setXYZ(11, back[1], back[0], back[3]);
const front = [new THREE.Vector2(0.333, 0.5), new THREE.Vector2(0.333, 1), new THREE.Vector2(0, 1), new THREE.Vector2(0, 0.5)];
const right = [new THREE.Vector2(0.666, 0.5), new THREE.Vector2(0.666, 1), new THREE.Vector2(0.333, 1), new THREE.Vector2(0.333, 0.5)];
const top = [new THREE.Vector2(1, 1), new THREE.Vector2(0.666, 1), new THREE.Vector2(0.666, 0.5), new THREE.Vector2(1, 0.5)];
const bottom = [new THREE.Vector2(0, 0), new THREE.Vector2(0.333, 0), new THREE.Vector2(0.333, 0.5), new THREE.Vector2(0, 0.5)];
const back = [new THREE.Vector2(0.666, 0), new THREE.Vector2(0.666, 0.5), new THREE.Vector2(0.333, 0.5), new THREE.Vector2(0.333, 0)];
const left = [new THREE.Vector2(1, 0), new THREE.Vector2(1, 0.5), new THREE.Vector2(0.666, 0.5), new THREE.Vector2(0.666, 0) ];

// LEFT
uvs.setXY(0, left[2].x, left[2].y);
uvs.setXY(1, left[1].x, left[1].y);
uvs.setXY(2, left[3].x, left[3].y);
uvs.setXY(3, left[0].x, left[0].y);

// BACK
uvs.setXY(4, back[2].x, back[2].y);
uvs.setXY(5, back[1].x, back[1].y);
uvs.setXY(6, back[3].x, back[3].y);
uvs.setXY(7, back[0].x, back[0].y);

// TOP/UP
uvs.setXY(8, top[2].x, top[2].y);
uvs.setXY(9, top[1].x, top[1].y);
uvs.setXY(10, top[3].x, top[3].y);
uvs.setXY(11, top[0].x, top[0].y);

// BOTTOM/DOWN
uvs.setXY(12, bottom[2].x, bottom[2].y);
uvs.setXY(13, bottom[1].x, bottom[1].y);
uvs.setXY(14, bottom[3].x, bottom[3].y);
uvs.setXY(15, bottom[0].x, bottom[0].y);

// FRONT
uvs.setXY(16, front[2].x, front[2].y);
uvs.setXY(17, front[1].x, front[1].y);
uvs.setXY(18, front[3].x, front[3].y);
uvs.setXY(19, front[0].x, front[0].y);

// RIGHT
uvs.setXY(20, right[2].x, right[2].y);
uvs.setXY(21, right[1].x, right[1].y);
uvs.setXY(22, right[3].x, right[3].y);
uvs.setXY(23, right[0].x, right[0].y);

this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
this.movieScreen.position.set(position.x, position.y, position.z);
Expand Down

0 comments on commit cd05e47

Please sign in to comment.