From 1e971cdadd6cf5ffb993d28fa531cb379d6b466c Mon Sep 17 00:00:00 2001 From: Kevin Staunton-Lambert Date: Tue, 23 Jul 2024 14:00:55 +1000 Subject: [PATCH] Fixup Ellipsoidal Cube Maps --- src/plugin.js | 52 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/plugin.js b/src/plugin.js index db895d6a..849a12e1 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -429,23 +429,41 @@ void main() { 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]); + // 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);