Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for detail level in projection sphere #225

Merged
merged 3 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Maintenance Status: Stable
- [`'360_TB'`](#360_tb)
- [`'EAC'`](#eac)
- [`'EAC_LR'`](#eac_lr)
- [`sphereDetail`](#spheredetail)
- [`player.mediainfo.projection`](#playermediainfoprojection)
- [`debug`](#debug)
- [`omnitone`](#omnitone)
Expand Down Expand Up @@ -241,6 +242,14 @@ Used for Equi-Angular Cubemap videos
#### `'EAC_LR'`
Used for side-by-side Equi-Angular Cubemap videos

### `sphereDetail`

> type: `number`, default: `32`

This alters the number of segments in the spherical mesh onto which equirectangular
videos are projected. The default is `32` but in some circumstances you may notice
artifacts and need to increase this number.

### `player.mediainfo.projection`

> type: `string`
Expand Down
34 changes: 28 additions & 6 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const defaults = {
omnitone: false,
forceCardboard: false,
omnitoneOptions: {},
projection: 'AUTO'
projection: 'AUTO',
sphereDetail: 32
};

const errors = {
Expand Down Expand Up @@ -126,7 +127,7 @@ class VR extends Plugin {
}
return this.changeProjection_('NONE');
} else if (projection === '360') {
this.movieGeometry = new THREE.SphereBufferGeometry(256, 32, 32);
this.movieGeometry = new THREE.SphereBufferGeometry(256, this.options_.sphereDetail, this.options_.sphereDetail);
this.movieMaterial = new THREE.MeshBasicMaterial({ map: this.videoTexture, overdraw: true, side: THREE.BackSide });

this.movieScreen = new THREE.Mesh(this.movieGeometry, this.movieMaterial);
Expand All @@ -137,7 +138,11 @@ class VR extends Plugin {
this.scene.add(this.movieScreen);
} else if (projection === '360_LR' || projection === '360_TB') {
// Left eye view
let geometry = new THREE.SphereGeometry(256, 32, 32);
let geometry = new THREE.SphereGeometry(
256,
this.options_.sphereDetail,
this.options_.sphereDetail
);

let uvs = geometry.faceVertexUvs[ 0 ];

Expand All @@ -163,7 +168,11 @@ class VR extends Plugin {
this.scene.add(this.movieScreen);

// Right eye view
geometry = new THREE.SphereGeometry(256, 32, 32);
geometry = new THREE.SphereGeometry(
256,
this.options_.sphereDetail,
this.options_.sphereDetail
);

uvs = geometry.faceVertexUvs[ 0 ];

Expand Down Expand Up @@ -224,7 +233,14 @@ class VR extends Plugin {

this.scene.add(this.movieScreen);
} else if (projection === '180' || projection === '180_LR' || projection === '180_MONO') {
let geometry = new THREE.SphereGeometry(256, 32, 32, Math.PI, Math.PI);
let geometry = new THREE.SphereGeometry(
256,
this.options_.sphereDetail,
this.options_.sphereDetail,
Math.PI,
Math.PI
);


// Left eye view
geometry.scale(-1, 1, 1);
Expand All @@ -249,7 +265,13 @@ class VR extends Plugin {
this.scene.add(this.movieScreen);

// Right eye view
geometry = new THREE.SphereGeometry(256, 32, 32, Math.PI, Math.PI);
geometry = new THREE.SphereGeometry(
256,
this.options_.sphereDetail,
this.options_.sphereDetail,
Math.PI,
Math.PI
);
geometry.scale(-1, 1, 1);
uvs = geometry.faceVertexUvs[0];

Expand Down