David Catuhe 7 роки тому
батько
коміт
60deab4575

Різницю між файлами не показано, бо вона завелика
+ 5875 - 5588
Playground/babylon.d.txt


Різницю між файлами не показано, бо вона завелика
+ 4049 - 4017
dist/preview release/babylon.d.ts


+ 71 - 1
dist/preview release/gui/babylon.gui.d.ts

@@ -975,6 +975,7 @@ declare module BABYLON.GUI {
         private _rootContainer;
         /** Gets the hosting scene */
         readonly scene: Scene;
+        readonly utilityLayer: Nullable<UtilityLayerRenderer>;
         /**
          * Creates a new GUI3DManager
          * @param scene
@@ -985,6 +986,24 @@ declare module BABYLON.GUI {
          */
         readonly rootContainer: Container3D;
         /**
+         * Gets a boolean indicating if the given control is in the root child list
+         * @param control defines the control to check
+         * @returns true if the control is in the root child list
+         */
+        containsControl(control: Control3D): boolean;
+        /**
+         * Adds a control to the root child list
+         * @param control defines the control to add
+         * @returns the current manager
+         */
+        addControl(control: Control3D): GUI3DManager;
+        /**
+         * Removes the control from the root child list
+         * @param control defines the control to remove
+         * @returns the current container
+         */
+        removeControl(control: Control3D): GUI3DManager;
+        /**
          * Releases all associated resources
          */
         dispose(): void;
@@ -1001,6 +1020,11 @@ declare module BABYLON.GUI {
         name: string | undefined;
         /** @hidden */
         _host: GUI3DManager;
+        private _mesh;
+        /**
+         * Gets or sets the parent container
+         */
+        parent: Nullable<Container3D>;
         private _behaviors;
         /**
          * Gets the list of attached behaviors
@@ -1041,6 +1065,19 @@ declare module BABYLON.GUI {
         readonly typeName: string;
         protected _getTypeName(): string;
         /**
+         * Get the attached mesh used to render the control
+         * @param scene defines the scene where the mesh must be attached
+         * @returns the attached mesh or null if none
+         */
+        getAttachedMesh(scene: Scene): Nullable<Mesh>;
+        /**
+         * Mesh creation.
+         * Can be overriden by children
+         * @param scene defines the scene where the mesh must be attached
+         * @returns the attached mesh or null if none
+         */
+        protected _createMesh(scene: Scene): Nullable<Mesh>;
+        /**
          * Releases all associated resources
          */
         dispose(): void;
@@ -1059,7 +1096,24 @@ declare module BABYLON.GUI {
          * @param name defines the container name
          */
         constructor(name?: string);
-        readonly typeName: string;
+        /**
+         * Gets a boolean indicating if the given control is in the children of this control
+         * @param control defines the control to check
+         * @returns true if the control is in the child list
+         */
+        containsControl(control: Control3D): boolean;
+        /**
+         * Adds a control to the children of this control
+         * @param control defines the control to add
+         * @returns the current container
+         */
+        addControl(control: Control3D): Container3D;
+        /**
+         * Removes the control from the children of this control
+         * @param control defines the control to remove
+         * @returns the current container
+         */
+        removeControl(control: Control3D): Container3D;
         protected _getTypeName(): string;
         /**
          * Releases all associated resources
@@ -1067,3 +1121,19 @@ declare module BABYLON.GUI {
         dispose(): void;
     }
 }
+
+
+declare module BABYLON.GUI {
+    /**
+     * Class used to create a button in 3D
+     */
+    class Button3D extends Control3D {
+        /**
+         * Creates a new button
+         * @param name defines the control name
+         */
+        constructor(name?: string);
+        protected _getTypeName(): string;
+        protected _createMesh(scene: Scene): Mesh;
+    }
+}

+ 127 - 7
dist/preview release/gui/babylon.gui.js

@@ -5625,6 +5625,13 @@ var BABYLON;
                 enumerable: true,
                 configurable: true
             });
+            Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
+                get: function () {
+                    return this._utilityLayer;
+                },
+                enumerable: true,
+                configurable: true
+            });
             Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
                 /**
                  * Gets the root container
@@ -5636,6 +5643,32 @@ var BABYLON;
                 configurable: true
             });
             /**
+             * Gets a boolean indicating if the given control is in the root child list
+             * @param control defines the control to check
+             * @returns true if the control is in the root child list
+             */
+            GUI3DManager.prototype.containsControl = function (control) {
+                return this._rootContainer.containsControl(control);
+            };
+            /**
+             * Adds a control to the root child list
+             * @param control defines the control to add
+             * @returns the current manager
+             */
+            GUI3DManager.prototype.addControl = function (control) {
+                this._rootContainer.addControl(control);
+                return this;
+            };
+            /**
+             * Removes the control from the root child list
+             * @param control defines the control to remove
+             * @returns the current container
+             */
+            GUI3DManager.prototype.removeControl = function (control) {
+                this._rootContainer.removeControl(control);
+                return this;
+            };
+            /**
              * Releases all associated resources
              */
             GUI3DManager.prototype.dispose = function () {
@@ -5755,6 +5788,27 @@ var BABYLON;
                 return "Control3D";
             };
             /**
+             * Get the attached mesh used to render the control
+             * @param scene defines the scene where the mesh must be attached
+             * @returns the attached mesh or null if none
+             */
+            Control3D.prototype.getAttachedMesh = function (scene) {
+                if (!this._mesh) {
+                    this._mesh = this._createMesh(scene);
+                }
+                return this._mesh;
+            };
+            /**
+             * Mesh creation.
+             * Can be overriden by children
+             * @param scene defines the scene where the mesh must be attached
+             * @returns the attached mesh or null if none
+             */
+            Control3D.prototype._createMesh = function (scene) {
+                // Do nothing by default
+                return null;
+            };
+            /**
              * Releases all associated resources
              */
             Control3D.prototype.dispose = function () {
@@ -5790,13 +5844,44 @@ var BABYLON;
                 _this._children = new Array();
                 return _this;
             }
-            Object.defineProperty(Container3D.prototype, "typeName", {
-                get: function () {
-                    return this._getTypeName();
-                },
-                enumerable: true,
-                configurable: true
-            });
+            /**
+             * Gets a boolean indicating if the given control is in the children of this control
+             * @param control defines the control to check
+             * @returns true if the control is in the child list
+             */
+            Container3D.prototype.containsControl = function (control) {
+                return this._children.indexOf(control) !== -1;
+            };
+            /**
+             * Adds a control to the children of this control
+             * @param control defines the control to add
+             * @returns the current container
+             */
+            Container3D.prototype.addControl = function (control) {
+                var index = this._children.indexOf(control);
+                if (index !== -1) {
+                    return this;
+                }
+                control.parent = this;
+                control._host = this._host;
+                if (this._host.utilityLayer) {
+                    control.getAttachedMesh(this._host.utilityLayer.utilityLayerScene);
+                }
+                return this;
+            };
+            /**
+             * Removes the control from the children of this control
+             * @param control defines the control to remove
+             * @returns the current container
+             */
+            Container3D.prototype.removeControl = function (control) {
+                var index = this._children.indexOf(control);
+                if (index !== -1) {
+                    this._children.splice(index, 1);
+                    control.parent = null;
+                }
+                return this;
+            };
             Container3D.prototype._getTypeName = function () {
                 return "Container3D";
             };
@@ -5817,6 +5902,41 @@ var BABYLON;
     })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
 })(BABYLON || (BABYLON = {}));
 
+/// <reference path="../../../../dist/preview release/babylon.d.ts"/>
+
+var BABYLON;
+(function (BABYLON) {
+    var GUI;
+    (function (GUI) {
+        /**
+         * Class used to create a button in 3D
+         */
+        var Button3D = /** @class */ (function (_super) {
+            __extends(Button3D, _super);
+            /**
+             * Creates a new button
+             * @param name defines the control name
+             */
+            function Button3D(name) {
+                return _super.call(this, name) || this;
+            }
+            Button3D.prototype._getTypeName = function () {
+                return "Button3D";
+            };
+            // Mesh association
+            Button3D.prototype._createMesh = function (scene) {
+                return BABYLON.MeshBuilder.CreateBox(this.name + "Mesh", {
+                    width: 1.0,
+                    height: 1.0,
+                    depth: 0.1
+                }, scene);
+            };
+            return Button3D;
+        }(GUI.Control3D));
+        GUI.Button3D = Button3D;
+    })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
+})(BABYLON || (BABYLON = {}));
+
     
 
     return BABYLON.GUI;

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


+ 71 - 1
dist/preview release/gui/babylon.gui.module.d.ts

@@ -980,6 +980,7 @@ declare module BABYLON.GUI {
         private _rootContainer;
         /** Gets the hosting scene */
         readonly scene: Scene;
+        readonly utilityLayer: Nullable<UtilityLayerRenderer>;
         /**
          * Creates a new GUI3DManager
          * @param scene
@@ -990,6 +991,24 @@ declare module BABYLON.GUI {
          */
         readonly rootContainer: Container3D;
         /**
+         * Gets a boolean indicating if the given control is in the root child list
+         * @param control defines the control to check
+         * @returns true if the control is in the root child list
+         */
+        containsControl(control: Control3D): boolean;
+        /**
+         * Adds a control to the root child list
+         * @param control defines the control to add
+         * @returns the current manager
+         */
+        addControl(control: Control3D): GUI3DManager;
+        /**
+         * Removes the control from the root child list
+         * @param control defines the control to remove
+         * @returns the current container
+         */
+        removeControl(control: Control3D): GUI3DManager;
+        /**
          * Releases all associated resources
          */
         dispose(): void;
@@ -1006,6 +1025,11 @@ declare module BABYLON.GUI {
         name: string | undefined;
         /** @hidden */
         _host: GUI3DManager;
+        private _mesh;
+        /**
+         * Gets or sets the parent container
+         */
+        parent: Nullable<Container3D>;
         private _behaviors;
         /**
          * Gets the list of attached behaviors
@@ -1046,6 +1070,19 @@ declare module BABYLON.GUI {
         readonly typeName: string;
         protected _getTypeName(): string;
         /**
+         * Get the attached mesh used to render the control
+         * @param scene defines the scene where the mesh must be attached
+         * @returns the attached mesh or null if none
+         */
+        getAttachedMesh(scene: Scene): Nullable<Mesh>;
+        /**
+         * Mesh creation.
+         * Can be overriden by children
+         * @param scene defines the scene where the mesh must be attached
+         * @returns the attached mesh or null if none
+         */
+        protected _createMesh(scene: Scene): Nullable<Mesh>;
+        /**
          * Releases all associated resources
          */
         dispose(): void;
@@ -1064,7 +1101,24 @@ declare module BABYLON.GUI {
          * @param name defines the container name
          */
         constructor(name?: string);
-        readonly typeName: string;
+        /**
+         * Gets a boolean indicating if the given control is in the children of this control
+         * @param control defines the control to check
+         * @returns true if the control is in the child list
+         */
+        containsControl(control: Control3D): boolean;
+        /**
+         * Adds a control to the children of this control
+         * @param control defines the control to add
+         * @returns the current container
+         */
+        addControl(control: Control3D): Container3D;
+        /**
+         * Removes the control from the children of this control
+         * @param control defines the control to remove
+         * @returns the current container
+         */
+        removeControl(control: Control3D): Container3D;
         protected _getTypeName(): string;
         /**
          * Releases all associated resources
@@ -1072,3 +1126,19 @@ declare module BABYLON.GUI {
         dispose(): void;
     }
 }
+
+
+declare module BABYLON.GUI {
+    /**
+     * Class used to create a button in 3D
+     */
+    class Button3D extends Control3D {
+        /**
+         * Creates a new button
+         * @param name defines the control name
+         */
+        constructor(name?: string);
+        protected _getTypeName(): string;
+        protected _createMesh(scene: Scene): Mesh;
+    }
+}

+ 27 - 31
dist/preview release/serializers/babylon.glTF2Serializer.d.ts

@@ -20,15 +20,6 @@ declare module BABYLON {
      */
     class GLTF2Export {
         /**
-         * Exports the geometry of the scene to .gltf file format synchronously
-         * @param scene Babylon scene with scene hierarchy information
-         * @param filePrefix File prefix to use when generating the glTF file
-         * @param options Exporter options
-         * @returns Returns an object with a .gltf file and associates texture names
-         * as keys and their data and paths as values
-         */
-        private static GLTF(scene, filePrefix, options?);
-        /**
          * Exports the geometry of the scene to .gltf file format asynchronously
          * @param scene Babylon scene with scene hierarchy information
          * @param filePrefix File prefix to use when generating the glTF file
@@ -38,14 +29,6 @@ declare module BABYLON {
          */
         static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
         /**
-         * Exports the geometry of the scene to .glb file format synchronously
-         * @param scene Babylon scene with scene hierarchy information
-         * @param filePrefix File prefix to use when generating glb file
-         * @param options Exporter options
-         * @returns Returns an object with a .glb filename as key and data as value
-         */
-        private static GLB(scene, filePrefix, options?);
-        /**
          * Exports the geometry of the scene to .glb file format asychronously
          * @param scene Babylon scene with scene hierarchy information
          * @param filePrefix File prefix to use when generating glb file
@@ -139,6 +122,9 @@ declare module BABYLON.GLTF2 {
          * Baked animation sample rate
          */
         private animationSampleRate;
+        /**
+         * Callback which specifies if a transform node should be exported or not
+         */
         private shouldExportTransformNode;
         /**
          * Creates a glTF Exporter instance, which can accept optional exporter options
@@ -226,12 +212,12 @@ declare module BABYLON.GLTF2 {
          * @param glTFPrefix Text to use when prefixing a glTF file
          * @returns GLTFData with glTF file data
          */
-        _generateGLTF(glTFPrefix: string): GLTFData;
+        _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
         /**
          * Creates a binary buffer for glTF
          * @returns array buffer for binary data
          */
-        private generateBinary();
+        private _generateBinaryAsync();
         /**
          * Pads the number to a multiple of 4
          * @param num number to pad
@@ -244,7 +230,7 @@ declare module BABYLON.GLTF2 {
          * @param glTFPrefix
          * @returns object with glb filename as key and data as value
          */
-        _generateGLB(glTFPrefix: string): GLTFData;
+        _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
         /**
          * Sets the TRS for each node
          * @param node glTF Node for storing the transformation data
@@ -290,10 +276,12 @@ declare module BABYLON.GLTF2 {
          * @param babylonScene Babylon scene to get the mesh data from
          * @param binaryWriter Buffer to write binary data to
          */
-        private createScene(babylonScene, binaryWriter);
+        private createSceneAsync(babylonScene, binaryWriter);
         /**
          * Creates a mapping of Node unique id to node index and handles animations
          * @param babylonScene Babylon Scene
+         * @param nodes Babylon transform nodes
+         * @param shouldExportTransformNode Callback specifying if a transform node should be exported
          * @param binaryWriter Buffer to write binary data to
          * @returns Node mapping of unique id to index
          */
@@ -433,12 +421,12 @@ declare module BABYLON.GLTF2 {
          * @param imageData mapping of texture names to base64 textures
          * @param hasTextureCoords specifies if texture coordinates are present on the material
          */
-        static _ConvertMaterialsToGLTF(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
         /**
          * Makes a copy of the glTF material without the texture parameters
          * @param originalMaterial original glTF material
@@ -481,12 +469,19 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertStandardMaterial(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
+        /**
+         *
+         * @param texture Texture with alpha to overwrite to one
+         * @param useAlpha Specifies if alpha should be preserved or not
+         * @returns Promise with texture
+         */
+        static _SetAlphaToOneAsync(texture: BaseTexture, useAlpha: boolean): Promise<Texture>;
         /**
          * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
          * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
@@ -497,12 +492,12 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertPBRMetallicRoughnessMaterial(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
         /**
          * Converts an image typed array buffer to a base64 image
          * @param buffer typed array buffer
@@ -568,7 +563,7 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private static _ConvertMetalRoughFactorsToMetallicRoughness(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
+        private static _ConvertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
         private static _GetGLTFTextureSampler(texture);
         private static _GetGLTFTextureWrapMode(wrapMode);
         private static _GetGLTFTextureWrapModesSampler(texture);
@@ -594,12 +589,13 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertPBRMaterial(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
+        private static SetMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, images, textures, samplers, materials, imageData, hasTextureCoords);
         private static GetPixelsFromTexture(babylonTexture);
         /**
          * Extracts a texture from a Babylon texture into file data and glTF data
@@ -610,7 +606,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name and data
          * @return glTF texture info, or null if the texture format is not supported
          */
-        private static _ExportTexture(babylonTexture, mimeType, images, textures, samplers, imageData);
+        private static _ExportTextureAsync(babylonTexture, mimeType, images, textures, samplers, imageData, useAlpha);
         /**
          * Builds a texture from base64 string
          * @param base64Texture base64 texture string

Різницю між файлами не показано, бо вона завелика
+ 453 - 407
dist/preview release/serializers/babylon.glTF2Serializer.js


Різницю між файлами не показано, бо вона завелика
+ 2 - 2
dist/preview release/serializers/babylon.glTF2Serializer.min.js


+ 27 - 31
dist/preview release/serializers/babylonjs.serializers.d.ts

@@ -28,15 +28,6 @@ declare module BABYLON {
      */
     class GLTF2Export {
         /**
-         * Exports the geometry of the scene to .gltf file format synchronously
-         * @param scene Babylon scene with scene hierarchy information
-         * @param filePrefix File prefix to use when generating the glTF file
-         * @param options Exporter options
-         * @returns Returns an object with a .gltf file and associates texture names
-         * as keys and their data and paths as values
-         */
-        private static GLTF(scene, filePrefix, options?);
-        /**
          * Exports the geometry of the scene to .gltf file format asynchronously
          * @param scene Babylon scene with scene hierarchy information
          * @param filePrefix File prefix to use when generating the glTF file
@@ -46,14 +37,6 @@ declare module BABYLON {
          */
         static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
         /**
-         * Exports the geometry of the scene to .glb file format synchronously
-         * @param scene Babylon scene with scene hierarchy information
-         * @param filePrefix File prefix to use when generating glb file
-         * @param options Exporter options
-         * @returns Returns an object with a .glb filename as key and data as value
-         */
-        private static GLB(scene, filePrefix, options?);
-        /**
          * Exports the geometry of the scene to .glb file format asychronously
          * @param scene Babylon scene with scene hierarchy information
          * @param filePrefix File prefix to use when generating glb file
@@ -147,6 +130,9 @@ declare module BABYLON.GLTF2 {
          * Baked animation sample rate
          */
         private animationSampleRate;
+        /**
+         * Callback which specifies if a transform node should be exported or not
+         */
         private shouldExportTransformNode;
         /**
          * Creates a glTF Exporter instance, which can accept optional exporter options
@@ -234,12 +220,12 @@ declare module BABYLON.GLTF2 {
          * @param glTFPrefix Text to use when prefixing a glTF file
          * @returns GLTFData with glTF file data
          */
-        _generateGLTF(glTFPrefix: string): GLTFData;
+        _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
         /**
          * Creates a binary buffer for glTF
          * @returns array buffer for binary data
          */
-        private generateBinary();
+        private _generateBinaryAsync();
         /**
          * Pads the number to a multiple of 4
          * @param num number to pad
@@ -252,7 +238,7 @@ declare module BABYLON.GLTF2 {
          * @param glTFPrefix
          * @returns object with glb filename as key and data as value
          */
-        _generateGLB(glTFPrefix: string): GLTFData;
+        _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
         /**
          * Sets the TRS for each node
          * @param node glTF Node for storing the transformation data
@@ -298,10 +284,12 @@ declare module BABYLON.GLTF2 {
          * @param babylonScene Babylon scene to get the mesh data from
          * @param binaryWriter Buffer to write binary data to
          */
-        private createScene(babylonScene, binaryWriter);
+        private createSceneAsync(babylonScene, binaryWriter);
         /**
          * Creates a mapping of Node unique id to node index and handles animations
          * @param babylonScene Babylon Scene
+         * @param nodes Babylon transform nodes
+         * @param shouldExportTransformNode Callback specifying if a transform node should be exported
          * @param binaryWriter Buffer to write binary data to
          * @returns Node mapping of unique id to index
          */
@@ -441,12 +429,12 @@ declare module BABYLON.GLTF2 {
          * @param imageData mapping of texture names to base64 textures
          * @param hasTextureCoords specifies if texture coordinates are present on the material
          */
-        static _ConvertMaterialsToGLTF(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
         /**
          * Makes a copy of the glTF material without the texture parameters
          * @param originalMaterial original glTF material
@@ -489,12 +477,19 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertStandardMaterial(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
+        /**
+         *
+         * @param texture Texture with alpha to overwrite to one
+         * @param useAlpha Specifies if alpha should be preserved or not
+         * @returns Promise with texture
+         */
+        static _SetAlphaToOneAsync(texture: BaseTexture, useAlpha: boolean): Promise<Texture>;
         /**
          * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
          * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
@@ -505,12 +500,12 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertPBRMetallicRoughnessMaterial(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
         /**
          * Converts an image typed array buffer to a base64 image
          * @param buffer typed array buffer
@@ -576,7 +571,7 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private static _ConvertMetalRoughFactorsToMetallicRoughness(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
+        private static _ConvertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
         private static _GetGLTFTextureSampler(texture);
         private static _GetGLTFTextureWrapMode(wrapMode);
         private static _GetGLTFTextureWrapModesSampler(texture);
@@ -602,12 +597,13 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertPBRMaterial(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
+        private static SetMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, images, textures, samplers, materials, imageData, hasTextureCoords);
         private static GetPixelsFromTexture(babylonTexture);
         /**
          * Extracts a texture from a Babylon texture into file data and glTF data
@@ -618,7 +614,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name and data
          * @return glTF texture info, or null if the texture format is not supported
          */
-        private static _ExportTexture(babylonTexture, mimeType, images, textures, samplers, imageData);
+        private static _ExportTextureAsync(babylonTexture, mimeType, images, textures, samplers, imageData, useAlpha);
         /**
          * Builds a texture from base64 string
          * @param base64Texture base64 texture string

Різницю між файлами не показано, бо вона завелика
+ 453 - 407
dist/preview release/serializers/babylonjs.serializers.js


Різницю між файлами не показано, бо вона завелика
+ 2 - 2
dist/preview release/serializers/babylonjs.serializers.min.js


+ 27 - 31
dist/preview release/serializers/babylonjs.serializers.module.d.ts

@@ -35,15 +35,6 @@ declare module BABYLON {
      */
     class GLTF2Export {
         /**
-         * Exports the geometry of the scene to .gltf file format synchronously
-         * @param scene Babylon scene with scene hierarchy information
-         * @param filePrefix File prefix to use when generating the glTF file
-         * @param options Exporter options
-         * @returns Returns an object with a .gltf file and associates texture names
-         * as keys and their data and paths as values
-         */
-        private static GLTF(scene, filePrefix, options?);
-        /**
          * Exports the geometry of the scene to .gltf file format asynchronously
          * @param scene Babylon scene with scene hierarchy information
          * @param filePrefix File prefix to use when generating the glTF file
@@ -53,14 +44,6 @@ declare module BABYLON {
          */
         static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
         /**
-         * Exports the geometry of the scene to .glb file format synchronously
-         * @param scene Babylon scene with scene hierarchy information
-         * @param filePrefix File prefix to use when generating glb file
-         * @param options Exporter options
-         * @returns Returns an object with a .glb filename as key and data as value
-         */
-        private static GLB(scene, filePrefix, options?);
-        /**
          * Exports the geometry of the scene to .glb file format asychronously
          * @param scene Babylon scene with scene hierarchy information
          * @param filePrefix File prefix to use when generating glb file
@@ -154,6 +137,9 @@ declare module BABYLON.GLTF2 {
          * Baked animation sample rate
          */
         private animationSampleRate;
+        /**
+         * Callback which specifies if a transform node should be exported or not
+         */
         private shouldExportTransformNode;
         /**
          * Creates a glTF Exporter instance, which can accept optional exporter options
@@ -241,12 +227,12 @@ declare module BABYLON.GLTF2 {
          * @param glTFPrefix Text to use when prefixing a glTF file
          * @returns GLTFData with glTF file data
          */
-        _generateGLTF(glTFPrefix: string): GLTFData;
+        _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
         /**
          * Creates a binary buffer for glTF
          * @returns array buffer for binary data
          */
-        private generateBinary();
+        private _generateBinaryAsync();
         /**
          * Pads the number to a multiple of 4
          * @param num number to pad
@@ -259,7 +245,7 @@ declare module BABYLON.GLTF2 {
          * @param glTFPrefix
          * @returns object with glb filename as key and data as value
          */
-        _generateGLB(glTFPrefix: string): GLTFData;
+        _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
         /**
          * Sets the TRS for each node
          * @param node glTF Node for storing the transformation data
@@ -305,10 +291,12 @@ declare module BABYLON.GLTF2 {
          * @param babylonScene Babylon scene to get the mesh data from
          * @param binaryWriter Buffer to write binary data to
          */
-        private createScene(babylonScene, binaryWriter);
+        private createSceneAsync(babylonScene, binaryWriter);
         /**
          * Creates a mapping of Node unique id to node index and handles animations
          * @param babylonScene Babylon Scene
+         * @param nodes Babylon transform nodes
+         * @param shouldExportTransformNode Callback specifying if a transform node should be exported
          * @param binaryWriter Buffer to write binary data to
          * @returns Node mapping of unique id to index
          */
@@ -448,12 +436,12 @@ declare module BABYLON.GLTF2 {
          * @param imageData mapping of texture names to base64 textures
          * @param hasTextureCoords specifies if texture coordinates are present on the material
          */
-        static _ConvertMaterialsToGLTF(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
         /**
          * Makes a copy of the glTF material without the texture parameters
          * @param originalMaterial original glTF material
@@ -496,12 +484,19 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertStandardMaterial(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
+        /**
+         *
+         * @param texture Texture with alpha to overwrite to one
+         * @param useAlpha Specifies if alpha should be preserved or not
+         * @returns Promise with texture
+         */
+        static _SetAlphaToOneAsync(texture: BaseTexture, useAlpha: boolean): Promise<Texture>;
         /**
          * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
          * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
@@ -512,12 +507,12 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertPBRMetallicRoughnessMaterial(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
         /**
          * Converts an image typed array buffer to a base64 image
          * @param buffer typed array buffer
@@ -583,7 +578,7 @@ declare module BABYLON.GLTF2 {
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          * @returns glTF PBR Metallic Roughness factors
          */
-        private static _ConvertMetalRoughFactorsToMetallicRoughness(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
+        private static _ConvertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, images, textures, samplers, glTFPbrMetallicRoughness, imageData, hasTextureCoords);
         private static _GetGLTFTextureSampler(texture);
         private static _GetGLTFTextureWrapMode(wrapMode);
         private static _GetGLTFTextureWrapModesSampler(texture);
@@ -609,12 +604,13 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name to data
          * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
          */
-        static _ConvertPBRMaterial(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
+        static _ConvertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, images: IImage[], textures: ITexture[], samplers: ISampler[], materials: IMaterial[], imageData: {
             [fileName: string]: {
                 data: Uint8Array;
                 mimeType: ImageMimeType;
             };
-        }, hasTextureCoords: boolean): void;
+        }, hasTextureCoords: boolean): Promise<void>;
+        private static SetMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, images, textures, samplers, materials, imageData, hasTextureCoords);
         private static GetPixelsFromTexture(babylonTexture);
         /**
          * Extracts a texture from a Babylon texture into file data and glTF data
@@ -625,7 +621,7 @@ declare module BABYLON.GLTF2 {
          * @param imageData map of image file name and data
          * @return glTF texture info, or null if the texture format is not supported
          */
-        private static _ExportTexture(babylonTexture, mimeType, images, textures, samplers, imageData);
+        private static _ExportTextureAsync(babylonTexture, mimeType, images, textures, samplers, imageData, useAlpha);
         /**
          * Builds a texture from base64 string
          * @param base64Texture base64 texture string

+ 2 - 40
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 4307,
+  "errors": 4301,
   "babylon.typedoc.json": {
-    "errors": 4307,
+    "errors": 4301,
     "Animatable": {
       "Class": {
         "Comments": {
@@ -22168,44 +22168,6 @@
         }
       }
     },
-    "Behavior": {
-      "Interface": {
-        "Comments": {
-          "MissingText": true
-        }
-      },
-      "Property": {
-        "name": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      },
-      "Method": {
-        "attach": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "node": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
-        "detach": {
-          "Comments": {
-            "MissingText": true
-          }
-        },
-        "init": {
-          "Comments": {
-            "MissingText": true
-          }
-        }
-      }
-    },
     "CameraInputsMap": {
       "Interface": {
         "Comments": {

+ 32 - 0
src/Behaviors/babylon.behavior.ts

@@ -1,15 +1,47 @@
 module BABYLON {
+    /**
+     * Interface used to define a behavior
+     */
     export interface Behavior<T> {
+        /** gets or sets behavior's name */
         name: string;
 
+        /**
+         * Function called when the behavior needs to be initialized (after attaching it to a target)
+         */
         init(): void
+        /**
+         * Called when the behavior is attached to a target
+         * @param target defines the target where the behavior is attached to
+         */
         attach(target: T): void;
+        /**
+         * Called when the behavior is detached from its target
+         */
         detach(): void;
     }
 
+    /**
+     * Interface implemented by classes supporting behaviors
+     */
     export interface IBehaviorAware<T> {
+        /**
+         * Attach a behavior
+         * @param behavior defines the behavior to attach
+         * @returns the current host
+         */
         addBehavior(behavior: Behavior<T>): T
+        /**
+         * Remove a behavior from the current object
+         * @param behavior defines the behavior to detach
+         * @returns the current host
+         */
         removeBehavior(behavior: Behavior<T>): T;
+        /**
+         * Gets a behavior using its name to search
+         * @param name defines the name to search
+         * @returns the behavior or null if not found
+         */
         getBehaviorByName(name: string): Nullable<Behavior<T>>;
     }
 }