Browse Source

Merge pull request #8616 from RaananW/oneEightyDome

Allow 180 monoscopic videos in the video dome
sebavan 5 years ago
parent
commit
97c7030a8c
2 changed files with 30 additions and 17 deletions
  1. 1 0
      dist/preview release/what's new.md
  2. 29 17
      src/Helpers/videoDome.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -36,6 +36,7 @@
 - Added an option when creating the engine to switch matrix computation to 64 bits ([Popov72](https://github.com/Popov72))
 - Added support for the alpha component to the SSR post-process ([Popov72](https://github.com/Popov72))
 - Force compute world matrix of the newly-attached mesh of a ray helper ([RaananW](https://github.com/RaananW))
+- Allow 180 monoscopic videos on top of the video dome ([#8575](https://github.com/BabylonJS/Babylon.js/issues/8575)) ([RaananW](https://github.com/RaananW))
 
 ### Engine
 

+ 29 - 17
src/Helpers/videoDome.ts

@@ -7,9 +7,9 @@ import { BackgroundMaterial } from "../Materials/Background/backgroundMaterial";
 import "../Meshes/Builders/sphereBuilder";
 import { Nullable } from "../types";
 import { Observer } from "../Misc/observable";
-import { Vector3 } from '../Maths/math.vector';
-import { Axis } from '../Maths/math';
-import { SphereBuilder } from '../Meshes/Builders/sphereBuilder';
+import { Vector3 } from "../Maths/math.vector";
+import { Axis } from "../Maths/math";
+import { SphereBuilder } from "../Meshes/Builders/sphereBuilder";
 
 declare type Camera = import("../Cameras/camera").Camera;
 
@@ -126,24 +126,29 @@ export class VideoDome extends TransformNode {
      * @param urlsOrVideo defines the url(s) or the video element to use
      * @param options An object containing optional or exposed sub element properties
      */
-    constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
-        resolution?: number,
-        clickToPlay?: boolean,
-        autoPlay?: boolean,
-        loop?: boolean,
-        size?: number,
-        poster?: string,
-        faceForward?: boolean,
-        useDirectMapping?: boolean,
-        halfDomeMode?: boolean
-    }, scene: Scene) {
+    constructor(
+        name: string,
+        urlsOrVideo: string | string[] | HTMLVideoElement,
+        options: {
+            resolution?: number;
+            clickToPlay?: boolean;
+            autoPlay?: boolean;
+            loop?: boolean;
+            size?: number;
+            poster?: string;
+            faceForward?: boolean;
+            useDirectMapping?: boolean;
+            halfDomeMode?: boolean;
+        },
+        scene: Scene
+    ) {
         super(name, scene);
 
         scene = this.getScene();
 
         // set defaults and manage values
         name = name || "videoDome";
-        options.resolution = (Math.abs(options.resolution as any) | 0) || 32;
+        options.resolution = Math.abs(options.resolution as any) | 0 || 32;
         options.clickToPlay = Boolean(options.clickToPlay);
         options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
         options.loop = options.loop === undefined ? true : Boolean(options.loop);
@@ -163,8 +168,8 @@ export class VideoDome extends TransformNode {
 
         // create
         let tempOptions: VideoTextureSettings = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
-        let material = this._material = new BackgroundMaterial(name + "_material", scene);
-        let texture = this._videoTexture = new VideoTexture(name + "_texture", urlsOrVideo, scene, false, this._useDirectMapping, Texture.TRILINEAR_SAMPLINGMODE, tempOptions);
+        let material = (this._material = new BackgroundMaterial(name + "_material", scene));
+        let texture = (this._videoTexture = new VideoTexture(name + "_texture", urlsOrVideo, scene, false, this._useDirectMapping, Texture.TRILINEAR_SAMPLINGMODE, tempOptions));
         this._mesh = Mesh.CreateSphere(name + "_mesh", options.resolution, options.size, scene, false, Mesh.BACKSIDE);
         texture.anisotropicFilteringLevel = 1;
         texture.onLoadObservable.addOnce(() => {
@@ -216,6 +221,8 @@ export class VideoDome extends TransformNode {
 
             this.rotation.y = Math.acos(Vector3.Dot(forward, direction));
         }
+
+        this._changeVideoMode(this._videoMode);
     }
 
     private _changeVideoMode(value: number): void {
@@ -229,6 +236,11 @@ export class VideoDome extends TransformNode {
         this._videoTexture.vOffset = 0;
 
         switch (value) {
+            case VideoDome.MODE_MONOSCOPIC:
+                if (this._halfDome) {
+                    this._videoTexture.uScale = 2;
+                }
+                break;
             case VideoDome.MODE_SIDEBYSIDE:
                 // in half-dome mode the uScale should be double of 360 videos
                 // Use 0.99999 to boost perf by not switching program