|
@@ -7,10 +7,10 @@ module BABYLON {
|
|
|
export interface IExportOptions {
|
|
|
/**
|
|
|
* Function which indicates whether a babylon mesh should be exported or not
|
|
|
- * @param mesh source Babylon mesh. It is used to check whether it should be exported to glTF or not
|
|
|
+ * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
|
|
|
* @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
|
|
|
*/
|
|
|
- shouldExportTransformNode?(mesh: TransformNode): boolean;
|
|
|
+ shouldExportTransformNode?(transformNode: TransformNode): boolean;
|
|
|
/**
|
|
|
* The sample rate to bake animation curves
|
|
|
*/
|
|
@@ -29,16 +29,10 @@ module BABYLON {
|
|
|
* @returns Returns an object with a .gltf file and associates texture names
|
|
|
* as keys and their data and paths as values
|
|
|
*/
|
|
|
- public static GLTF(scene: Scene, filePrefix: string, options?: IExportOptions): Nullable<GLTFData> {
|
|
|
- if (scene.isReady()) {
|
|
|
+ private static GLTF(scene: Scene, filePrefix: string, options?: IExportOptions): GLTFData {
|
|
|
const glTFPrefix = filePrefix.replace(/\.[^/.]+$/, "");
|
|
|
const gltfGenerator = new GLTF2._Exporter(scene, options);
|
|
|
return gltfGenerator._generateGLTF(glTFPrefix);
|
|
|
- }
|
|
|
- else {
|
|
|
- Tools.Error('glTF Serializer: Scene is not ready!');
|
|
|
- return null;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -49,7 +43,7 @@ module BABYLON {
|
|
|
* @returns Returns an object with a .gltf file and associates texture names
|
|
|
* as keys and their data and paths as values
|
|
|
*/
|
|
|
- public static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<Nullable<GLTFData>> {
|
|
|
+ public static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData> {
|
|
|
return Promise.resolve(scene.whenReadyAsync()).then(() => {
|
|
|
return GLTF2Export.GLTF(scene, filePrefix, options);
|
|
|
});
|
|
@@ -62,16 +56,10 @@ module BABYLON {
|
|
|
* @param options Exporter options
|
|
|
* @returns Returns an object with a .glb filename as key and data as value
|
|
|
*/
|
|
|
- public static GLB(scene: Scene, filePrefix: string, options?: IExportOptions): Nullable<GLTFData> {
|
|
|
- if (scene.isReady()) {
|
|
|
+ private static GLB(scene: Scene, filePrefix: string, options?: IExportOptions): GLTFData {
|
|
|
const glTFPrefix = filePrefix.replace(/\.[^/.]+$/, "");
|
|
|
const gltfGenerator = new GLTF2._Exporter(scene, options);
|
|
|
return gltfGenerator._generateGLB(glTFPrefix);
|
|
|
- }
|
|
|
- else {
|
|
|
- Tools.Error('glTF Serializer: Scene is not ready!');
|
|
|
- return null;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -81,7 +69,7 @@ module BABYLON {
|
|
|
* @param options Exporter options
|
|
|
* @returns Returns an object with a .glb filename as key and data as value
|
|
|
*/
|
|
|
- public static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<Nullable<GLTFData>> {
|
|
|
+ public static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData> {
|
|
|
return Promise.resolve(scene.whenReadyAsync()).then(() => {
|
|
|
return GLTF2Export.GLB(scene, filePrefix, options);
|
|
|
});
|