David Catuhe 5 years ago
parent
commit
b0fc97986f

+ 6 - 1
inspector/src/components/actionTabs/lines/textLineComponent.tsx

@@ -2,10 +2,11 @@ import * as React from "react";
 
 interface ITextLineComponentProps {
     label: string;
-    value: string;
+    value?: string;
     color?: string;
     underline?: boolean;
     onLink?: () => void;
+    ignoreValue?: boolean
 }
 
 export class TextLineComponent extends React.Component<ITextLineComponentProps> {
@@ -22,6 +23,10 @@ export class TextLineComponent extends React.Component<ITextLineComponentProps>
     }
 
     renderContent() {
+        if (this.props.ignoreValue) {
+            return null;
+        }
+
         if (this.props.onLink) {
             return (
                 <div className="link-value" title={this.props.value} onClick={() => this.onLink()}>

+ 23 - 4
inspector/src/components/actionTabs/tabs/toolsTabComponent.tsx

@@ -22,11 +22,14 @@ import { FloatLineComponent } from '../lines/floatLineComponent';
 import { IScreenshotSize } from 'babylonjs/Misc/interfaces/screenshotSize';
 import { NumericInputComponent } from '../lines/numericInputComponent';
 import { CheckBoxLineComponent } from '../lines/checkBoxLineComponent';
+import { TextLineComponent } from '../lines/textLineComponent';
 
 export class ToolsTabComponent extends PaneComponent {
     private _videoRecorder: Nullable<VideoRecorder>;
     private _screenShotSize: IScreenshotSize = { precision: 1 };
     private _useWidthHeight = false;
+    private _isExporting = false;
+
     constructor(props: IPaneComponentProps) {
         super(props);
 
@@ -108,11 +111,18 @@ export class ToolsTabComponent extends PaneComponent {
 
     exportGLTF() {
         const scene = this.props.scene;
+        this._isExporting = true;
+        this.forceUpdate();
 
         GLTF2Export.GLBAsync(scene, "scene", {
             shouldExportNode: (node) => this.shouldExport(node)
         }).then((glb: GLTFData) => {
             glb.downloadFiles();
+            this._isExporting = false;
+            this.forceUpdate();
+        }).catch(reason => {      
+            this._isExporting = false;
+            this.forceUpdate();
         });
     }
 
@@ -183,11 +193,20 @@ export class ToolsTabComponent extends PaneComponent {
                     <ButtonLineComponent label="Reset" onClick={() => this.resetReplay()} />
                 </LineContainerComponent>
                 <LineContainerComponent globalState={this.props.globalState} title="SCENE EXPORT">
-                    <ButtonLineComponent label="Export to GLB" onClick={() => this.exportGLTF()} />
-                    <ButtonLineComponent label="Export to Babylon" onClick={() => this.exportBabylon()} />
                     {
-                        !scene.getEngine().premultipliedAlpha && scene.environmentTexture && (scene.environmentTexture as CubeTexture).isPrefiltered && scene.activeCamera &&
-                        <ButtonLineComponent label="Generate .env texture" onClick={() => this.createEnvTexture()} />
+                        this._isExporting && 
+                        <TextLineComponent label="Please wait..exporting" ignoreValue={true} />
+                    }
+                    {
+                        !this._isExporting && 
+                        <>  
+                            <ButtonLineComponent label="Export to GLB" onClick={() => this.exportGLTF()} />
+                            <ButtonLineComponent label="Export to Babylon" onClick={() => this.exportBabylon()} />
+                            {
+                                !scene.getEngine().premultipliedAlpha && scene.environmentTexture && (scene.environmentTexture as CubeTexture).isPrefiltered && scene.activeCamera &&
+                                <ButtonLineComponent label="Generate .env texture" onClick={() => this.createEnvTexture()} />
+                            }
+                        </>
                     }
                 </LineContainerComponent>
                 {

+ 2 - 2
serializers/src/glTF/2.0/glTFAnimation.ts

@@ -365,7 +365,7 @@ export class _GLTFAnimation {
 
             if (i + 1 < length) {
                 nextKeyFrame = keyFrames[i + 1];
-                if (currKeyFrame.value.equals(nextKeyFrame.value)) {
+                if (currKeyFrame.value.equals && currKeyFrame.value.equals(nextKeyFrame.value) || currKeyFrame.value === nextKeyFrame.value) {
                     if (i === 0) { // set the first frame to itself
                         endFrame = currKeyFrame.frame;
                     }
@@ -380,7 +380,7 @@ export class _GLTFAnimation {
             else {
                 // at the last key frame
                 prevKeyFrame = keyFrames[i - 1];
-                if (currKeyFrame.value.equals(prevKeyFrame.value)) {
+                if (currKeyFrame.value.equals && currKeyFrame.value.equals(prevKeyFrame.value) || currKeyFrame.value === prevKeyFrame.value) {
                     continue;
                 }
                 else {