David Catuhe пре 5 година
родитељ
комит
06f6761447

+ 1 - 1
inspector/src/components/actionTabs/actionTabs.scss

@@ -292,7 +292,7 @@ $line-padding-left: 2px;
                     }
 
                     .file-upload {
-                        background: transparent;
+                        background: #222222;
                         border: 1px solid rgb(51, 122, 183);
                         margin: 0px 10px;
                         color:white;

+ 31 - 22
inspector/src/components/actionTabs/lines/textureLineComponent.tsx

@@ -8,6 +8,7 @@ import { PostProcess } from "babylonjs/PostProcesses/postProcess";
 import { PassPostProcess, PassCubePostProcess } from "babylonjs/PostProcesses/passPostProcess";
 
 import { GlobalState } from "../../../components/globalState";
+import { ButtonLineComponent } from './buttonLineComponent';
 
 interface ITextureLineComponentProps {
     texture: BaseTexture;
@@ -184,30 +185,38 @@ export class TextureLineComponent extends React.Component<ITextureLineComponentP
         var texture = this.props.texture;
 
         return (
-            <div className="textureLine">
-                {
-                    !this.props.hideChannelSelect && texture.isCube &&
-                    <div className="control3D">
-                        <button className={this.state.face === 0 ? "px command selected" : "px command"} onClick={() => this.setState({ face: 0 })}>PX</button>
-                        <button className={this.state.face === 1 ? "nx command selected" : "nx command"} onClick={() => this.setState({ face: 1 })}>NX</button>
-                        <button className={this.state.face === 2 ? "py command selected" : "py command"} onClick={() => this.setState({ face: 2 })}>PY</button>
-                        <button className={this.state.face === 3 ? "ny command selected" : "ny command"} onClick={() => this.setState({ face: 3 })}>NY</button>
-                        <button className={this.state.face === 4 ? "pz command selected" : "pz command"} onClick={() => this.setState({ face: 4 })}>PZ</button>
-                        <button className={this.state.face === 5 ? "nz command selected" : "nz command"} onClick={() => this.setState({ face: 5 })}>NZ</button>
-                    </div>
-                }
+            <>
+                <div className="textureLine">
+                    {
+                        !this.props.hideChannelSelect && texture.isCube &&
+                        <div className="control3D">
+                            <button className={this.state.face === 0 ? "px command selected" : "px command"} onClick={() => this.setState({ face: 0 })}>PX</button>
+                            <button className={this.state.face === 1 ? "nx command selected" : "nx command"} onClick={() => this.setState({ face: 1 })}>NX</button>
+                            <button className={this.state.face === 2 ? "py command selected" : "py command"} onClick={() => this.setState({ face: 2 })}>PY</button>
+                            <button className={this.state.face === 3 ? "ny command selected" : "ny command"} onClick={() => this.setState({ face: 3 })}>NY</button>
+                            <button className={this.state.face === 4 ? "pz command selected" : "pz command"} onClick={() => this.setState({ face: 4 })}>PZ</button>
+                            <button className={this.state.face === 5 ? "nz command selected" : "nz command"} onClick={() => this.setState({ face: 5 })}>NZ</button>
+                        </div>
+                    }
+                    {
+                        !this.props.hideChannelSelect && !texture.isCube &&
+                        <div className="control">
+                            <button className={this.state.channel === ChannelToDisplay.R ? "red command selected" : "red command"} onClick={() => this.setState({ channel: ChannelToDisplay.R })}>R</button>
+                            <button className={this.state.channel === ChannelToDisplay.G ? "green command selected" : "green command"} onClick={() => this.setState({ channel: ChannelToDisplay.G })}>G</button>
+                            <button className={this.state.channel === ChannelToDisplay.B ? "blue command selected" : "blue command"} onClick={() => this.setState({ channel: ChannelToDisplay.B })}>B</button>
+                            <button className={this.state.channel === ChannelToDisplay.A ? "alpha command selected" : "alpha command"} onClick={() => this.setState({ channel: ChannelToDisplay.A })}>A</button>
+                            <button className={this.state.channel === ChannelToDisplay.All ? "all command selected" : "all command"} onClick={() => this.setState({ channel: ChannelToDisplay.All })}>ALL</button>
+                        </div>
+                    }
+                    <canvas ref="canvas" className="preview" />
+                </div>
                 {
-                    !this.props.hideChannelSelect && !texture.isCube &&
-                    <div className="control">
-                        <button className={this.state.channel === ChannelToDisplay.R ? "red command selected" : "red command"} onClick={() => this.setState({ channel: ChannelToDisplay.R })}>R</button>
-                        <button className={this.state.channel === ChannelToDisplay.G ? "green command selected" : "green command"} onClick={() => this.setState({ channel: ChannelToDisplay.G })}>G</button>
-                        <button className={this.state.channel === ChannelToDisplay.B ? "blue command selected" : "blue command"} onClick={() => this.setState({ channel: ChannelToDisplay.B })}>B</button>
-                        <button className={this.state.channel === ChannelToDisplay.A ? "alpha command selected" : "alpha command"} onClick={() => this.setState({ channel: ChannelToDisplay.A })}>A</button>
-                        <button className={this.state.channel === ChannelToDisplay.All ? "all command selected" : "all command"} onClick={() => this.setState({ channel: ChannelToDisplay.All })}>ALL</button>
-                    </div>
+                    texture.isRenderTarget &&
+                    <ButtonLineComponent label="Refresh" onClick={() => {
+                        this.updatePreview();
+                    }} />
                 }
-                <canvas ref="canvas" className="preview" />
-            </div>
+            </>
         );
     }
 }

+ 21 - 0
inspector/src/components/actionTabs/tabs/propertyGrids/materials/texturePropertyGridComponent.tsx

@@ -23,6 +23,7 @@ import { GlobalState } from "../../../../../components/globalState";
 import { AdvancedDynamicTextureInstrumentation } from "babylonjs-gui/2D/adtInstrumentation";
 import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
 import { CustomPropertyGridComponent } from '../customPropertyGridComponent';
+import { ButtonLineComponent } from '../../../lines/buttonLineComponent';
 
 interface ITexturePropertyGridComponentProps {
     texture: BaseTexture,
@@ -127,6 +128,26 @@ export class TexturePropertyGridComponent extends React.Component<ITextureProper
                     <TextLineComponent label="Width" value={texture.getSize().width.toString()} />
                     <TextLineComponent label="Height" value={texture.getSize().height.toString()} />
                     {
+                        texture.isRenderTarget &&
+                        <ButtonLineComponent label="Scale up" onClick={() => {
+                            let scene = texture.getScene()!;
+                            texture.scale(2);
+                            setTimeout(() => {
+                                this.props.globalState.onSelectionChangedObservable.notifyObservers(scene.getTextureByUniqueID(texture.uniqueId));
+                            });
+                        }} />
+                    }
+                    {
+                        texture.isRenderTarget &&
+                        <ButtonLineComponent label="Scale down" onClick={() => {                            
+                            let scene = texture.getScene()!;
+                            texture.scale(0.5);
+                            setTimeout(() => {
+                                this.props.globalState.onSelectionChangedObservable.notifyObservers(scene.getTextureByUniqueID(texture.uniqueId));
+                            });
+                        }} />
+                    }
+                    {
                         extension &&
                         <TextLineComponent label="File format" value={extension} />
                     }

+ 6 - 0
src/Lights/Shadows/shadowGenerator.ts

@@ -761,6 +761,7 @@ export class ShadowGenerator implements IShadowGenerator {
     private _currentFaceIndexCache = 0;
     private _textureType: number;
     private _defaultTextureMatrix = Matrix.Identity();
+    private _storedUniqueId: Nullable<number>;
 
     /** @hidden */
     public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {
@@ -834,6 +835,10 @@ export class ShadowGenerator implements IShadowGenerator {
         this._shadowMap.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE);
         this._shadowMap.renderParticles = false;
         this._shadowMap.ignoreCameraViewport = true;
+        if (this._storedUniqueId) {
+            this._shadowMap.uniqueId = this._storedUniqueId;
+        }
+
 
         // Record Face Index before render.
         this._shadowMap.onBeforeRenderObservable.add((faceIndex: number) => {
@@ -877,6 +882,7 @@ export class ShadowGenerator implements IShadowGenerator {
         });
 
         this._shadowMap.onResizeObservable.add((RTT) => {
+            this._storedUniqueId = this._shadowMap!.uniqueId;
             this._mapSize = RTT.getRenderSize();
             this._light._markMeshesAsLightDirty();
             this.recreateShadowMap();

+ 1 - 1
src/Materials/Textures/renderTargetTexture.ts

@@ -538,7 +538,7 @@ export class RenderTargetTexture extends Texture {
      * @param ratio the ratio to apply to the texture size in order to compute the new target size
      */
     public scale(ratio: number): void {
-        var newSize = this.getRenderSize() * ratio;
+        var newSize = Math.max(1, this.getRenderSize() * ratio);
 
         this.resize(newSize);
     }