Browse Source

moving .env out of labs

Raanan Weber 7 years ago
parent
commit
2601c4fa31

+ 5 - 0
Viewer/src/configuration/configuration.ts

@@ -1,5 +1,6 @@
 import { EngineOptions } from 'babylonjs';
 import { EngineOptions } from 'babylonjs';
 import { ICameraConfiguration, IDefaultRenderingPipelineConfiguration, IGroundConfiguration, ILightConfiguration, IModelConfiguration, IObserversConfiguration, ISceneConfiguration, ISceneOptimizerConfiguration, ISkyboxConfiguration, ITemplateConfiguration, IVRConfiguration } from './interfaces';
 import { ICameraConfiguration, IDefaultRenderingPipelineConfiguration, IGroundConfiguration, ILightConfiguration, IModelConfiguration, IObserversConfiguration, ISceneConfiguration, ISceneOptimizerConfiguration, ISkyboxConfiguration, ITemplateConfiguration, IVRConfiguration } from './interfaces';
+import { IEnvironmentMapConfiguration } from './interfaces/environmentMapConfiguration';
 
 
 export function getConfigurationKey(key: string, configObject: any) {
 export function getConfigurationKey(key: string, configObject: any) {
     let splits = key.split('.');
     let splits = key.split('.');
@@ -80,6 +81,8 @@ export interface ViewerConfiguration {
         [propName: string]: boolean | undefined;
         [propName: string]: boolean | undefined;
     };
     };
 
 
+    environmentMap?: IEnvironmentMapConfiguration
+
     vr?: IVRConfiguration;
     vr?: IVRConfiguration;
 
 
     // features that are being tested.
     // features that are being tested.
@@ -94,8 +97,10 @@ export interface ViewerConfiguration {
             specular?: { r: number, g: number, b: number };
             specular?: { r: number, g: number, b: number };
         }
         }
         hideLoadingDelay?: number;
         hideLoadingDelay?: number;
+        /** Deprecated */
         assetsRootURL?: string;
         assetsRootURL?: string;
         environmentMainColor?: { r: number, g: number, b: number };
         environmentMainColor?: { r: number, g: number, b: number };
+        /** Deprecated */
         environmentMap?: {
         environmentMap?: {
             /**
             /**
              * Environment map texture path in relative to the asset folder.
              * Environment map texture path in relative to the asset folder.

+ 9 - 0
Viewer/src/configuration/configurationCompatibility.ts

@@ -36,6 +36,15 @@ export function processConfigurationCompatibility(configuration: ViewerConfigura
             configuration.model.castShadow = (<any>configuration.model).castShadows;
             configuration.model.castShadow = (<any>configuration.model).castShadows;
         }
         }
     }
     }
+
+    if (configuration.lab) {
+        if (configuration.lab.assetsRootURL) {
+            setKeyInObject(configuration, "scene.assetsRootURL", configuration.lab.assetsRootURL);
+        }
+        if (configuration.lab.environmentMap) {
+            setKeyInObject(configuration, "scene.environmentMap", configuration.lab.environmentMap);
+        }
+    }
 }
 }
 
 
 function setKeyInObject(object: any, keys: string, value: any, shouldOverwrite?: boolean) {
 function setKeyInObject(object: any, keys: string, value: any, shouldOverwrite?: boolean) {

+ 16 - 0
Viewer/src/configuration/interfaces/environmentMapConfiguration.ts

@@ -0,0 +1,16 @@
+export interface IEnvironmentMapConfiguration {
+    /**
+     * Environment map texture path in relative to the asset folder.
+     */
+    texture: string;
+
+    /**
+     * Default rotation to apply to the environment map.
+     */
+    rotationY: number;
+
+    /**
+     * Tint level of the main color on the environment map.
+     */
+    tintLevel: number;
+}

+ 2 - 1
Viewer/src/configuration/interfaces/index.ts

@@ -11,4 +11,5 @@ export * from './sceneConfiguration';
 export * from './sceneOptimizerConfiguration';
 export * from './sceneOptimizerConfiguration';
 export * from './skyboxConfiguration';
 export * from './skyboxConfiguration';
 export * from './templateConfiguration';
 export * from './templateConfiguration';
-export * from './vrConfiguration';
+export * from './vrConfiguration';
+export * from './environmentMapConfiguration';

+ 2 - 1
Viewer/src/configuration/interfaces/sceneConfiguration.ts

@@ -36,5 +36,6 @@ export interface ISceneConfiguration {
         spritesEnabled?: boolean;
         spritesEnabled?: boolean;
         skeletonsEnabled?: boolean;
         skeletonsEnabled?: boolean;
         audioEnabled?: boolean;
         audioEnabled?: boolean;
-    }
+    };
+    assetsRootURL?: string;
 }
 }

+ 16 - 0
Viewer/src/managers/sceneManager.ts

@@ -8,6 +8,7 @@ import { getCustomOptimizerByName } from '../optimizer/custom/';
 import { ObservablesManager } from '../managers/observablesManager';
 import { ObservablesManager } from '../managers/observablesManager';
 import { ConfigurationContainer } from '../configuration/configurationContainer';
 import { ConfigurationContainer } from '../configuration/configurationContainer';
 import { deepmerge } from '../helper';
 import { deepmerge } from '../helper';
+import { IEnvironmentMapConfiguration } from '../configuration/interfaces/environmentMapConfiguration';
 
 
 /**
 /**
  * This interface describes the structure of the variable sent with the configuration observables of the scene manager.
  * This interface describes the structure of the variable sent with the configuration observables of the scene manager.
@@ -441,6 +442,10 @@ export class SceneManager {
         // camera
         // camera
         this._configureCamera(newConfiguration.camera);
         this._configureCamera(newConfiguration.camera);
 
 
+        if (newConfiguration.environmentMap !== undefined) {
+            this._configureEnvironmentMap(newConfiguration.environmentMap);
+        }
+
         if (newConfiguration.vr !== undefined) {
         if (newConfiguration.vr !== undefined) {
             this._configureVR(newConfiguration.vr);
             this._configureVR(newConfiguration.vr);
         }
         }
@@ -847,6 +852,17 @@ export class SceneManager {
         });
         });
     }
     }
 
 
+    protected _configureEnvironmentMap(environmentMapConfiguration: IEnvironmentMapConfiguration): any {
+        let rot = environmentMapConfiguration.rotationY;
+        this.labs.loadEnvironment(environmentMapConfiguration.texture, () => {
+            this.labs.applyEnvironmentMapConfiguration(rot);
+        });
+
+        if (!environmentMapConfiguration.texture && environmentMapConfiguration.rotationY) {
+            this.labs.applyEnvironmentMapConfiguration(environmentMapConfiguration.rotationY);
+        }
+    }
+
     /**
     /**
      * (Re) configure the camera. The camera will only be created once and from this point will only be reconfigured.
      * (Re) configure the camera. The camera will only be created once and from this point will only be reconfigured.
      * @param cameraConfig the new camera configuration
      * @param cameraConfig the new camera configuration