|
@@ -13,10 +13,12 @@ import { Texture } from 'babylonjs/Materials/Textures/texture';
|
|
import { SliderLineComponent } from '../../../sharedComponents/sliderLineComponent';
|
|
import { SliderLineComponent } from '../../../sharedComponents/sliderLineComponent';
|
|
import { FloatLineComponent } from '../../../sharedComponents/floatLineComponent';
|
|
import { FloatLineComponent } from '../../../sharedComponents/floatLineComponent';
|
|
import { ButtonLineComponent } from '../../../sharedComponents/buttonLineComponent';
|
|
import { ButtonLineComponent } from '../../../sharedComponents/buttonLineComponent';
|
|
|
|
+import { ReflectionTextureNodeModel } from '../reflectionTexture/reflectionTextureNodeModel';
|
|
|
|
+import { CubeTexture } from 'babylonjs/Materials/Textures/cubeTexture';
|
|
|
|
|
|
interface ITexturePropertyTabComponentProps {
|
|
interface ITexturePropertyTabComponentProps {
|
|
globalState: GlobalState;
|
|
globalState: GlobalState;
|
|
- node: TextureNodeModel;
|
|
|
|
|
|
+ node: TextureNodeModel | ReflectionTextureNodeModel;
|
|
}
|
|
}
|
|
|
|
|
|
export class TexturePropertyTabComponent extends React.Component<ITexturePropertyTabComponentProps, {isEmbedded: boolean}> {
|
|
export class TexturePropertyTabComponent extends React.Component<ITexturePropertyTabComponentProps, {isEmbedded: boolean}> {
|
|
@@ -30,9 +32,11 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
}
|
|
}
|
|
|
|
|
|
UNSAFE_componentWillUpdate(nextProps: ITexturePropertyTabComponentProps, nextState: {isEmbedded: boolean}) {
|
|
UNSAFE_componentWillUpdate(nextProps: ITexturePropertyTabComponentProps, nextState: {isEmbedded: boolean}) {
|
|
- let texture = nextProps.node.texture as BaseTexture;
|
|
|
|
|
|
+ if (nextProps.node !== this.props.node) {
|
|
|
|
+ let texture = nextProps.node.texture as BaseTexture;
|
|
|
|
|
|
- nextState.isEmbedded = !texture || texture.name.substring(0, 4) !== "http";
|
|
|
|
|
|
+ nextState.isEmbedded = !texture || texture.name.substring(0, 4) !== "http";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private _generateRandomForCache() {
|
|
private _generateRandomForCache() {
|
|
@@ -43,7 +47,7 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- updateAftertextureLoad() {
|
|
|
|
|
|
+ updateAfterTextureLoad() {
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onRebuildRequiredObservable.notifyObservers();
|
|
this.props.globalState.onRebuildRequiredObservable.notifyObservers();
|
|
}
|
|
}
|
|
@@ -59,8 +63,15 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
|
|
|
|
let texture = this.props.node.texture as BaseTexture;
|
|
let texture = this.props.node.texture as BaseTexture;
|
|
if (!texture) {
|
|
if (!texture) {
|
|
- this.props.node.texture = new Texture(null, this.props.globalState.nodeMaterial.getScene(), false, false);
|
|
|
|
- texture = this.props.node.texture;
|
|
|
|
|
|
+
|
|
|
|
+ if (this.props.node instanceof TextureNodeModel) {
|
|
|
|
+ this.props.node.texture = new Texture(null, this.props.globalState.nodeMaterial.getScene(), false, false);
|
|
|
|
+ texture = this.props.node.texture;
|
|
|
|
+ } else {
|
|
|
|
+ this.props.node.texture = new CubeTexture("", this.props.globalState.nodeMaterial.getScene());
|
|
|
|
+ texture = this.props.node.texture;
|
|
|
|
+ texture.coordinatesMode = Texture.CUBIC_MODE;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
Tools.ReadFile(file, (data) => {
|
|
Tools.ReadFile(file, (data) => {
|
|
@@ -71,7 +82,7 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
reader.onloadend = () => {
|
|
reader.onloadend = () => {
|
|
let base64data = reader.result as string;
|
|
let base64data = reader.result as string;
|
|
|
|
|
|
- if (texture.isCube) {
|
|
|
|
|
|
+ if (texture.isCube || this.props.node instanceof ReflectionTextureNodeModel) {
|
|
let extension: string | undefined = undefined;
|
|
let extension: string | undefined = undefined;
|
|
if (file.name.toLowerCase().indexOf(".dds") > 0) {
|
|
if (file.name.toLowerCase().indexOf(".dds") > 0) {
|
|
extension = ".dds";
|
|
extension = ".dds";
|
|
@@ -79,9 +90,9 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
extension = ".env";
|
|
extension = ".env";
|
|
}
|
|
}
|
|
|
|
|
|
- (texture as Texture).updateURL(base64data, extension, () => this.updateAftertextureLoad());
|
|
|
|
|
|
+ (texture as Texture).updateURL(base64data, extension, () => this.updateAfterTextureLoad());
|
|
} else {
|
|
} else {
|
|
- (texture as Texture).updateURL(base64data, null, () => this.updateAftertextureLoad());
|
|
|
|
|
|
+ (texture as Texture).updateURL(base64data, null, () => this.updateAfterTextureLoad());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, undefined, true);
|
|
}, undefined, true);
|
|
@@ -91,12 +102,23 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
let texture = this.props.node.texture as BaseTexture;
|
|
let texture = this.props.node.texture as BaseTexture;
|
|
if (!texture) {
|
|
if (!texture) {
|
|
this.props.node.texture = new Texture(url, this.props.globalState.nodeMaterial.getScene(), false, false, undefined, () => {
|
|
this.props.node.texture = new Texture(url, this.props.globalState.nodeMaterial.getScene(), false, false, undefined, () => {
|
|
- this.updateAftertextureLoad();
|
|
|
|
|
|
+ this.updateAfterTextureLoad();
|
|
});
|
|
});
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- (texture as Texture).updateURL(url, null, () => this.updateAftertextureLoad());
|
|
|
|
|
|
+ if (texture.isCube || this.props.node instanceof ReflectionTextureNodeModel) {
|
|
|
|
+ let extension: string | undefined = undefined;
|
|
|
|
+ if (url.toLowerCase().indexOf(".dds") > 0) {
|
|
|
|
+ extension = ".dds";
|
|
|
|
+ } else if (url.toLowerCase().indexOf(".env") > 0) {
|
|
|
|
+ extension = ".env";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ (texture as Texture).updateURL(url, extension, () => this.updateAfterTextureLoad());
|
|
|
|
+ } else {
|
|
|
|
+ (texture as Texture).updateURL(url, null, () => this.updateAfterTextureLoad());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
render() {
|
|
render() {
|
|
@@ -108,6 +130,8 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
}
|
|
}
|
|
|
|
|
|
url = url.replace(/\?nocache=\d+/, "");
|
|
url = url.replace(/\?nocache=\d+/, "");
|
|
|
|
+
|
|
|
|
+ let isInReflectionMode = this.props.node instanceof ReflectionTextureNodeModel;
|
|
|
|
|
|
return (
|
|
return (
|
|
<div>
|
|
<div>
|
|
@@ -116,23 +140,30 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
<TextInputLineComponent globalState={this.props.globalState} label="Name" propertyName="name" target={this.props.node.block!} onChange={() => this.props.globalState.onUpdateRequiredObservable.notifyObservers()} />
|
|
<TextInputLineComponent globalState={this.props.globalState} label="Name" propertyName="name" target={this.props.node.block!} onChange={() => this.props.globalState.onUpdateRequiredObservable.notifyObservers()} />
|
|
</LineContainerComponent>
|
|
</LineContainerComponent>
|
|
<LineContainerComponent title="PROPERTIES">
|
|
<LineContainerComponent title="PROPERTIES">
|
|
- <CheckBoxLineComponent label="Auto select UV" propertyName="autoSelectUV" target={this.props.node.block!} />
|
|
|
|
|
|
+ <CheckBoxLineComponent label="Auto select UV" propertyName="autoSelectUV" target={this.props.node.block!} onValueChanged={() => {
|
|
|
|
+ this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
|
|
+ }}/> {
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
|
|
+ <CheckBoxLineComponent label="Gamma space" propertyName="gammaSpace" target={texture} onValueChanged={() => {
|
|
|
|
+ this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
|
|
+ }}/>
|
|
|
|
+ }
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
<CheckBoxLineComponent label="Clamp U" isSelected={() => texture.wrapU === Texture.CLAMP_ADDRESSMODE} onSelect={(value) => {
|
|
<CheckBoxLineComponent label="Clamp U" isSelected={() => texture.wrapU === Texture.CLAMP_ADDRESSMODE} onSelect={(value) => {
|
|
texture.wrapU = value ? Texture.CLAMP_ADDRESSMODE : Texture.WRAP_ADDRESSMODE;
|
|
texture.wrapU = value ? Texture.CLAMP_ADDRESSMODE : Texture.WRAP_ADDRESSMODE;
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
}} />
|
|
}} />
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
<CheckBoxLineComponent label="Clamp V" isSelected={() => texture.wrapV === Texture.CLAMP_ADDRESSMODE} onSelect={(value) => {
|
|
<CheckBoxLineComponent label="Clamp V" isSelected={() => texture.wrapV === Texture.CLAMP_ADDRESSMODE} onSelect={(value) => {
|
|
texture.wrapV = value ? Texture.CLAMP_ADDRESSMODE : Texture.WRAP_ADDRESSMODE;
|
|
texture.wrapV = value ? Texture.CLAMP_ADDRESSMODE : Texture.WRAP_ADDRESSMODE;
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
}} />
|
|
}} />
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
<FloatLineComponent label="Offset U" target={texture} propertyName="uOffset"
|
|
<FloatLineComponent label="Offset U" target={texture} propertyName="uOffset"
|
|
onChange={() => {
|
|
onChange={() => {
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
@@ -140,29 +171,29 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
/>
|
|
/>
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
- <FloatLineComponent label="Offset U" target={texture} propertyName="vOffset"
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
|
|
+ <FloatLineComponent label="Offset V" target={texture} propertyName="vOffset"
|
|
onChange={() => {
|
|
onChange={() => {
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
<FloatLineComponent label="Scale U" target={texture} propertyName="uScale"
|
|
<FloatLineComponent label="Scale U" target={texture} propertyName="uScale"
|
|
onChange={() => {
|
|
onChange={() => {
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
}} />
|
|
}} />
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
<FloatLineComponent label="Scale V" target={texture} propertyName="vScale"
|
|
<FloatLineComponent label="Scale V" target={texture} propertyName="vScale"
|
|
onChange={() => {
|
|
onChange={() => {
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
}} />
|
|
}} />
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
<SliderLineComponent label="Rotation U" target={texture} propertyName="uAng" minimum={0} maximum={Math.PI * 2} useEuler={true} step={0.1}
|
|
<SliderLineComponent label="Rotation U" target={texture} propertyName="uAng" minimum={0} maximum={Math.PI * 2} useEuler={true} step={0.1}
|
|
onChange={() => {
|
|
onChange={() => {
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
@@ -170,7 +201,7 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
/>
|
|
/>
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
<SliderLineComponent label="Rotation V" target={texture} propertyName="vAng" minimum={0} maximum={Math.PI * 2} useEuler={true} step={0.1}
|
|
<SliderLineComponent label="Rotation V" target={texture} propertyName="vAng" minimum={0} maximum={Math.PI * 2} useEuler={true} step={0.1}
|
|
onChange={() => {
|
|
onChange={() => {
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
@@ -178,7 +209,7 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
/>
|
|
/>
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- texture &&
|
|
|
|
|
|
+ texture && !isInReflectionMode &&
|
|
<SliderLineComponent label="Rotation W" target={texture} propertyName="wAng" minimum={0} maximum={Math.PI * 2} useEuler={true} step={0.1}
|
|
<SliderLineComponent label="Rotation W" target={texture} propertyName="wAng" minimum={0} maximum={Math.PI * 2} useEuler={true} step={0.1}
|
|
onChange={() => {
|
|
onChange={() => {
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
this.props.globalState.onUpdateRequiredObservable.notifyObservers();
|
|
@@ -190,7 +221,7 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
|
|
<CheckBoxLineComponent label="Embed texture" isSelected={() => this.state.isEmbedded} onSelect={value => {
|
|
<CheckBoxLineComponent label="Embed texture" isSelected={() => this.state.isEmbedded} onSelect={value => {
|
|
this.setState({isEmbedded: value});
|
|
this.setState({isEmbedded: value});
|
|
this.props.node.texture = null;
|
|
this.props.node.texture = null;
|
|
- this.updateAftertextureLoad();
|
|
|
|
|
|
+ this.updateAfterTextureLoad();
|
|
}}/>
|
|
}}/>
|
|
{
|
|
{
|
|
this.state.isEmbedded &&
|
|
this.state.isEmbedded &&
|