David Catuhe 6 سال پیش
والد
کامیت
876e234f92

+ 2 - 2
Playground/babylon.d.txt

@@ -28589,7 +28589,7 @@ declare module BABYLON {
         /**
          * Compiled shader to webGL program.
          * @hidden
-         */
pipelineContext: IPipelineContext;
+         */
pipelineContext: Nullable<IPipelineContext>;
         private _valueCache;
         private static _baseCache;
         /**
@@ -28625,7 +28625,7 @@ declare module BABYLON {
          * The pipeline context for this effect
          * @returns the associated pipeline context
          */
-        getPipelineContext(): IPipelineContext;
+        getPipelineContext(): Nullable<IPipelineContext>;
         /**
          * The set of names of attribute variables for the shader.
          * @returns An array of attribute names.

+ 2 - 2
dist/preview release/babylon.d.ts

@@ -29134,7 +29134,7 @@ declare module BABYLON {
          * Compiled shader to webGL program.
          * @hidden
          */
-        _pipelineContext: IPipelineContext;
+        _pipelineContext: Nullable<IPipelineContext>;
         private _valueCache;
         private static _baseCache;
         /**
@@ -29170,7 +29170,7 @@ declare module BABYLON {
          * The pipeline context for this effect
          * @returns the associated pipeline context
          */
-        getPipelineContext(): IPipelineContext;
+        getPipelineContext(): Nullable<IPipelineContext>;
         /**
          * The set of names of attribute variables for the shader.
          * @returns An array of attribute names.

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/babylon.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 91 - 51
dist/preview release/babylon.max.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 4 - 4
dist/preview release/babylon.module.d.ts

@@ -29908,7 +29908,7 @@ declare module "babylonjs/Materials/effect" {
          * Compiled shader to webGL program.
          * @hidden
          */
-        _pipelineContext: IPipelineContext;
+        _pipelineContext: Nullable<IPipelineContext>;
         private _valueCache;
         private static _baseCache;
         /**
@@ -29944,7 +29944,7 @@ declare module "babylonjs/Materials/effect" {
          * The pipeline context for this effect
          * @returns the associated pipeline context
          */
-        getPipelineContext(): IPipelineContext;
+        getPipelineContext(): Nullable<IPipelineContext>;
         /**
          * The set of names of attribute variables for the shader.
          * @returns An array of attribute names.
@@ -89129,7 +89129,7 @@ declare module BABYLON {
          * Compiled shader to webGL program.
          * @hidden
          */
-        _pipelineContext: IPipelineContext;
+        _pipelineContext: Nullable<IPipelineContext>;
         private _valueCache;
         private static _baseCache;
         /**
@@ -89165,7 +89165,7 @@ declare module BABYLON {
          * The pipeline context for this effect
          * @returns the associated pipeline context
          */
-        getPipelineContext(): IPipelineContext;
+        getPipelineContext(): Nullable<IPipelineContext>;
         /**
          * The set of names of attribute variables for the shader.
          * @returns An array of attribute names.

+ 1 - 1
dist/preview release/packagesSizeBaseLine.json

@@ -1 +1 @@
-{"engineOnly":289483,"sceneOnly":498668,"minGridMaterial":625153,"minStandardMaterial":749912}
+{"engineOnly":289856,"sceneOnly":499041,"minGridMaterial":625526,"minStandardMaterial":750285}

+ 4 - 4
dist/preview release/viewer/babylon.module.d.ts

@@ -29908,7 +29908,7 @@ declare module "babylonjs/Materials/effect" {
          * Compiled shader to webGL program.
          * @hidden
          */
-        _pipelineContext: IPipelineContext;
+        _pipelineContext: Nullable<IPipelineContext>;
         private _valueCache;
         private static _baseCache;
         /**
@@ -29944,7 +29944,7 @@ declare module "babylonjs/Materials/effect" {
          * The pipeline context for this effect
          * @returns the associated pipeline context
          */
-        getPipelineContext(): IPipelineContext;
+        getPipelineContext(): Nullable<IPipelineContext>;
         /**
          * The set of names of attribute variables for the shader.
          * @returns An array of attribute names.
@@ -89129,7 +89129,7 @@ declare module BABYLON {
          * Compiled shader to webGL program.
          * @hidden
          */
-        _pipelineContext: IPipelineContext;
+        _pipelineContext: Nullable<IPipelineContext>;
         private _valueCache;
         private static _baseCache;
         /**
@@ -89165,7 +89165,7 @@ declare module BABYLON {
          * The pipeline context for this effect
          * @returns the associated pipeline context
          */
-        getPipelineContext(): IPipelineContext;
+        getPipelineContext(): Nullable<IPipelineContext>;
         /**
          * The set of names of attribute variables for the shader.
          * @returns An array of attribute names.

+ 37 - 59
dist/preview release/viewer/babylon.viewer.d.ts

@@ -5,9 +5,9 @@
 // Dependencies for this module:
 //   ../../../../../Tools/Gulp/babylonjs
 //   ../../../../../Tools/Gulp/babylonjs-loaders
-//   ../../../../../Tools/Gulp/babylonjs/Misc/observable
 //   ../../../../../Tools/Gulp/babylonjs/Engines/engine
 //   ../../../../../Tools/Gulp/babylonjs/Loading/sceneLoader
+//   ../../../../../Tools/Gulp/babylonjs/Misc/observable
 //   ../../../../../Tools/Gulp/babylonjs/scene
 //   ../../../../../Tools/Gulp/babylonjs/Meshes/abstractMesh
 //   ../../../../../Tools/Gulp/babylonjs/Particles/IParticleSystem
@@ -96,59 +96,6 @@ declare module BabylonViewer {
 }
 declare module BabylonViewer {
     /**
-        * The viewer manager is the container for all viewers currently registered on this page.
-        * It is possible to have more than one viewer on a single page.
-        */
-    export class ViewerManager {
-            /**
-                * A callback that will be triggered when a new viewer was added
-                */
-            onViewerAdded: (viewer: AbstractViewer) => void;
-            /**
-                * Will notify when a new viewer was added
-                */
-            onViewerAddedObservable: BABYLON.Observable<AbstractViewer>;
-            /**
-                * Will notify when a viewer was removed (disposed)
-                */
-            onViewerRemovedObservable: BABYLON.Observable<string>;
-            constructor();
-            /**
-                * Adding a new viewer to the viewer manager and start tracking it.
-                * @param viewer the viewer to add
-                */
-            addViewer(viewer: AbstractViewer): void;
-            /**
-                * remove a viewer from the viewer manager
-                * @param viewer the viewer to remove
-                */
-            removeViewer(viewer: AbstractViewer): void;
-            /**
-                * Get a viewer by its baseId (if the container element has an ID, it is the this is. if not, a random id was assigned)
-                * @param id the id of the HTMl element (or the viewer's, if none provided)
-                */
-            getViewerById(id: string): AbstractViewer;
-            /**
-                * Get a viewer using a container element
-                * @param element the HTML element to search viewers associated with
-                */
-            getViewerByHTMLElement(element: HTMLElement): AbstractViewer | undefined;
-            /**
-                * Get a promise that will fullfil when this viewer was initialized.
-                * Since viewer initialization and template injection is asynchronous, using the promise will guaranty that
-                * you will get the viewer after everything was already configured.
-                * @param id the viewer id to find
-                */
-            getViewerPromiseById(id: string): Promise<AbstractViewer>;
-            /**
-                * dispose the manager and all of its associated viewers
-                */
-            dispose(): void;
-    }
-    export let viewerManager: ViewerManager;
-}
-declare module BabylonViewer {
-    /**
         * The Default viewer is the default implementation of the AbstractViewer.
         * It uses the templating system to render a new canvas and controls.
         */
@@ -197,11 +144,11 @@ declare module BabylonViewer {
                 * Mainly used for help and errors
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 */
-            showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
+            showOverlayScreen(subScreen: string): Promise<Template> | Promise<string>;
             /**
                 * Hide the overlay screen.
                 */
-            hideOverlayScreen(): Promise<string> | Promise<Template>;
+            hideOverlayScreen(): Promise<Template> | Promise<string>;
             /**
                 * show the viewer (in case it was hidden)
                 *
@@ -218,11 +165,11 @@ declare module BabylonViewer {
                 * Show the loading screen.
                 * The loading screen can be configured using the configuration object
                 */
-            showLoadingScreen(): Promise<string> | Promise<Template>;
+            showLoadingScreen(): Promise<Template> | Promise<string>;
             /**
                 * Hide the loading screen
                 */
-            hideLoadingScreen(): Promise<string> | Promise<Template>;
+            hideLoadingScreen(): Promise<Template> | Promise<string>;
             dispose(): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
     }
@@ -951,7 +898,7 @@ declare module BabylonViewer {
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 declare module BabylonViewer {
@@ -1594,6 +1541,20 @@ declare module BabylonViewer {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 declare module BabylonViewer {
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+declare module BabylonViewer {
     export interface IEnvironmentMapConfiguration {
             /**
                 * Environment map texture path in relative to the asset folder.
@@ -2209,6 +2170,23 @@ declare module BabylonViewer {
     }
 }
 declare module BabylonViewer {
+    export interface IVRConfiguration {
+        disabled?: boolean;
+        objectScaleFactor?: number;
+        disableInteractions?: boolean;
+        disableTeleportation?: boolean;
+        overrideFloorMeshName?: string;
+        vrOptions?: BABYLON.VRExperienceHelperOptions;
+        modelHeightCorrection?: number | boolean;
+        rotateUsingControllers?: boolean;
+        cameraPosition?: {
+            x: number;
+            y: number;
+            z: number;
+        };
+    }
+}
+declare module BabylonViewer {
     /**
         * Spherical polynomial coefficients (counter part to spherical harmonic coefficients used in shader irradiance calculation)
         * @ignoreChildren

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 8 - 8
dist/preview release/viewer/babylon.viewer.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 40 - 60
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -6,9 +6,9 @@
 // Dependencies for this module:
 //   ../../../../../Tools/Gulp/babylonjs
 //   ../../../../../Tools/Gulp/babylonjs-loaders
-//   ../../../../../Tools/Gulp/babylonjs/Misc/observable
 //   ../../../../../Tools/Gulp/babylonjs/Engines/engine
 //   ../../../../../Tools/Gulp/babylonjs/Loading/sceneLoader
+//   ../../../../../Tools/Gulp/babylonjs/Misc/observable
 //   ../../../../../Tools/Gulp/babylonjs/scene
 //   ../../../../../Tools/Gulp/babylonjs/Meshes/abstractMesh
 //   ../../../../../Tools/Gulp/babylonjs/Particles/IParticleSystem
@@ -119,59 +119,7 @@ declare module 'babylonjs-viewer/configuration/globals' {
 }
 
 declare module 'babylonjs-viewer/viewer/viewerManager' {
-    import { Observable } from 'babylonjs/Misc/observable';
-    import { AbstractViewer } from 'babylonjs-viewer/viewer/viewer';
-    /**
-        * The viewer manager is the container for all viewers currently registered on this page.
-        * It is possible to have more than one viewer on a single page.
-        */
-    export class ViewerManager {
-            /**
-                * A callback that will be triggered when a new viewer was added
-                */
-            onViewerAdded: (viewer: AbstractViewer) => void;
-            /**
-                * Will notify when a new viewer was added
-                */
-            onViewerAddedObservable: Observable<AbstractViewer>;
-            /**
-                * Will notify when a viewer was removed (disposed)
-                */
-            onViewerRemovedObservable: Observable<string>;
-            constructor();
-            /**
-                * Adding a new viewer to the viewer manager and start tracking it.
-                * @param viewer the viewer to add
-                */
-            addViewer(viewer: AbstractViewer): void;
-            /**
-                * remove a viewer from the viewer manager
-                * @param viewer the viewer to remove
-                */
-            removeViewer(viewer: AbstractViewer): void;
-            /**
-                * Get a viewer by its baseId (if the container element has an ID, it is the this is. if not, a random id was assigned)
-                * @param id the id of the HTMl element (or the viewer's, if none provided)
-                */
-            getViewerById(id: string): AbstractViewer;
-            /**
-                * Get a viewer using a container element
-                * @param element the HTML element to search viewers associated with
-                */
-            getViewerByHTMLElement(element: HTMLElement): AbstractViewer | undefined;
-            /**
-                * Get a promise that will fullfil when this viewer was initialized.
-                * Since viewer initialization and template injection is asynchronous, using the promise will guaranty that
-                * you will get the viewer after everything was already configured.
-                * @param id the viewer id to find
-                */
-            getViewerPromiseById(id: string): Promise<AbstractViewer>;
-            /**
-                * dispose the manager and all of its associated viewers
-                */
-            dispose(): void;
-    }
-    export let viewerManager: ViewerManager;
+    
 }
 
 declare module 'babylonjs-viewer/viewer/defaultViewer' {
@@ -230,11 +178,11 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * Mainly used for help and errors
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 */
-            showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
+            showOverlayScreen(subScreen: string): Promise<Template> | Promise<string>;
             /**
                 * Hide the overlay screen.
                 */
-            hideOverlayScreen(): Promise<string> | Promise<Template>;
+            hideOverlayScreen(): Promise<Template> | Promise<string>;
             /**
                 * show the viewer (in case it was hidden)
                 *
@@ -251,11 +199,11 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * Show the loading screen.
                 * The loading screen can be configured using the configuration object
                 */
-            showLoadingScreen(): Promise<string> | Promise<Template>;
+            showLoadingScreen(): Promise<Template> | Promise<string>;
             /**
                 * Hide the loading screen
                 */
-            hideLoadingScreen(): Promise<string> | Promise<Template>;
+            hideLoadingScreen(): Promise<Template> | Promise<string>;
             dispose(): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
     }
@@ -1031,13 +979,14 @@ declare module 'babylonjs-viewer/templating/viewerTemplatePlugin' {
 }
 
 declare module 'babylonjs-viewer/optimizer/custom' {
+    import { extendedUpgrade } from "babylonjs-viewer/optimizer/custom/extended";
     import { SceneManager } from "babylonjs-viewer/managers/sceneManager";
     /**
       *
       * @param name the name of the custom optimizer configuration
       * @param upgrade set to true if you want to upgrade optimizer and false if you want to degrade
       */
-    export function getCustomOptimizerByName(name: string, upgrade?: boolean): (sceneManager: SceneManager) => boolean;
+    export function getCustomOptimizerByName(name: string, upgrade?: boolean): typeof extendedUpgrade;
     export function registerCustomOptimizer(name: string, optimizer: (sceneManager: SceneManager) => boolean): void;
 }
 
@@ -1737,6 +1686,22 @@ declare module 'babylonjs-viewer/loader/plugins' {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 
+declare module 'babylonjs-viewer/optimizer/custom/extended' {
+    import { SceneManager } from 'babylonjs-viewer/managers/sceneManager';
+    /**
+        * A custom upgrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedUpgrade(sceneManager: SceneManager): boolean;
+    /**
+        * A custom degrade-oriented function configuration for the scene optimizer.
+        *
+        * @param viewer the viewer to optimize
+        */
+    export function extendedDegrade(sceneManager: SceneManager): boolean;
+}
+
 declare module 'babylonjs-viewer/configuration/interfaces' {
     export * from 'babylonjs-viewer/configuration/interfaces/cameraConfiguration';
     export * from 'babylonjs-viewer/configuration/interfaces/colorGradingConfiguration';
@@ -2415,7 +2380,22 @@ declare module 'babylonjs-viewer/configuration/interfaces/templateConfiguration'
 }
 
 declare module 'babylonjs-viewer/configuration/interfaces/vrConfiguration' {
-    
+    import { VRExperienceHelperOptions } from "babylonjs";
+    export interface IVRConfiguration {
+        disabled?: boolean;
+        objectScaleFactor?: number;
+        disableInteractions?: boolean;
+        disableTeleportation?: boolean;
+        overrideFloorMeshName?: string;
+        vrOptions?: VRExperienceHelperOptions;
+        modelHeightCorrection?: number | boolean;
+        rotateUsingControllers?: boolean;
+        cameraPosition?: {
+            x: number;
+            y: number;
+            z: number;
+        };
+    }
 }
 
 declare module 'babylonjs-viewer/labs/environmentSerializer' {

+ 21 - 21
src/Materials/effect.ts

@@ -24,7 +24,7 @@ export class EffectFallbacks {
     private _currentRank = 32;
     private _maxRank = -1;
 
-    private _mesh: Nullable<AbstractMesh>;
+    private _mesh: Nullable<AbstractMesh> = null;
 
     /**
      * Removes the fallback from the bound mesh.
@@ -192,23 +192,23 @@ export class Effect implements IDisposable {
     /**
      * Name of the effect.
      */
-    public name: any;
+    public name: any = null;
     /**
      * String container all the define statements that should be set on the shader.
      */
-    public defines: string;
+    public defines: string = "";
     /**
      * Callback that will be called when the shader is compiled.
      */
-    public onCompiled: Nullable<(effect: Effect) => void>;
+    public onCompiled: Nullable<(effect: Effect) => void> = null;
     /**
      * Callback that will be called if an error occurs during shader compilation.
      */
-    public onError: Nullable<(effect: Effect, errors: string) => void>;
+    public onError: Nullable<(effect: Effect, errors: string) => void> = null;
     /**
      * Callback that will be called when effect is bound.
      */
-    public onBind: Nullable<(effect: Effect) => void>;
+    public onBind: Nullable<(effect: Effect) => void> = null;
     /**
      * Unique ID of the effect.
      */
@@ -224,7 +224,7 @@ export class Effect implements IDisposable {
     public onErrorObservable = new Observable<Effect>();
 
     /** @hidden */
-    public _onBindObservable: Nullable<Observable<Effect>>;
+    public _onBindObservable: Nullable<Observable<Effect>> = null;
 
     /**
      * Observable that will be called when effect is bound.
@@ -255,20 +255,20 @@ export class Effect implements IDisposable {
      * Key for the effect.
      * @hidden
      */
-    public _key: string;
+    public _key: string = "";
     private _indexParameters: any;
-    private _fallbacks: Nullable<EffectFallbacks>;
-    private _vertexSourceCode: string;
-    private _fragmentSourceCode: string;
-    private _vertexSourceCodeOverride: string;
-    private _fragmentSourceCodeOverride: string;
-    private _transformFeedbackVaryings: Nullable<string[]>;
+    private _fallbacks: Nullable<EffectFallbacks> = null;
+    private _vertexSourceCode: string = "";
+    private _fragmentSourceCode: string = "";
+    private _vertexSourceCodeOverride: string = "";
+    private _fragmentSourceCodeOverride: string = "";
+    private _transformFeedbackVaryings: Nullable<string[]> = null;
     /**
      * Compiled shader to webGL program.
      * @hidden
      */
-    public _pipelineContext: IPipelineContext;
-    private _valueCache: { [key: string]: any };
+    public _pipelineContext: Nullable<IPipelineContext> = null;
+    private _valueCache: { [key: string]: any } = {};
     private static _baseCache: { [key: number]: DataBuffer } = {};
 
     /**
@@ -405,7 +405,7 @@ export class Effect implements IDisposable {
      * The pipeline context for this effect
      * @returns the associated pipeline context
      */
-    public getPipelineContext(): IPipelineContext {
+    public getPipelineContext(): Nullable<IPipelineContext> {
         return this._pipelineContext;
     }
 
@@ -793,7 +793,7 @@ export class Effect implements IDisposable {
                 scenes[i].markAllMaterialsAsDirty(Constants.MATERIAL_AllDirtyFlag);
             }
 
-            this._pipelineContext._handlesSpectorRebuildCallback(onCompiled);
+            this._pipelineContext!._handlesSpectorRebuildCallback(onCompiled);
         };
         this._fallbacks = null;
         this._prepareEffect();
@@ -831,12 +831,12 @@ export class Effect implements IDisposable {
                     }
                 }
 
-                let uniforms = engine.getUniforms(this._pipelineContext, this._uniformsNames);
+                let uniforms = engine.getUniforms(this._pipelineContext!, this._uniformsNames);
                 uniforms.forEach((uniform, index) => {
                     this._uniforms[this._uniformsNames[index]] = uniform;
                 });
 
-                this._attributes = engine.getAttributes(this._pipelineContext, attributesNames);
+                this._attributes = engine.getAttributes(this._pipelineContext!, attributesNames);
 
                 var index: number;
                 for (index = 0; index < this._samplerList.length; index++) {
@@ -1100,7 +1100,7 @@ export class Effect implements IDisposable {
      * @param index Index to bind.
      */
     public bindUniformBlock(blockName: string, index: number): void {
-        this._engine.bindUniformBlock(this._pipelineContext, blockName, index);
+        this._engine.bindUniformBlock(this._pipelineContext!, blockName, index);
     }
 
     /**