import * as React from "react"; import { Texture, BaseTexture, CubeTexture, Observable } from "babylonjs"; import { PropertyChangedEvent } from "../../../../propertyChangedEvent"; import { LineContainerComponent } from "../../../lineContainerComponent"; import { SliderLineComponent } from "../../../lines/sliderLineComponent"; import { TextLineComponent } from "../../../lines/textLineComponent"; import { CheckBoxLineComponent } from "../../../lines/checkBoxLineComponent"; import { TextureLineComponent } from "../../../lines/textureLineComponent"; import { FloatLineComponent } from "../../../lines/floatLineComponent"; import { OptionsLineComponent } from "../../../lines/optionsLineComponent"; import { FileButtonLineComponent } from "../../../lines/fileButtonLineComponent"; import { LockObject } from "../lockObject"; interface ITexturePropertyGridComponentProps { texture: BaseTexture, lockObject: LockObject, onPropertyChangedObservable?: Observable } export class TexturePropertyGridComponent extends React.Component { constructor(props: ITexturePropertyGridComponentProps) { super(props); } updateTexture(file: File) { const texture = this.props.texture; BABYLON.Tools.ReadFile(file, (data) => { var blob = new Blob([data], { type: "octet/stream" }); var url = URL.createObjectURL(blob); if (texture.isCube) { let extension: string | undefined = undefined; if (file.name.toLowerCase().indexOf(".dds") > 0) { extension = ".dds"; } else if (file.name.toLowerCase().indexOf(".env") > 0) { extension = ".env"; } (texture as CubeTexture).updateURL(url, extension, () => this.forceUpdate()); } else { (texture as Texture).updateURL(url, null, () => this.forceUpdate()); } }, undefined, true); } render() { const texture = this.props.texture; var samplingMode = [ { label: "Nearest", value: BABYLON.Texture.NEAREST_NEAREST }, { label: "Nearest & linear mip", value: BABYLON.Texture.NEAREST_LINEAR }, { label: "Linear", value: BABYLON.Texture.LINEAR_LINEAR_MIPLINEAR }, ]; return (
this.updateTexture(file)} accept=".jpg, .png, .tga, .dds, .env" /> { texture.updateSamplingMode && texture.updateSamplingMode(value)} /> } { (texture as any).rootContainer && } { !texture.isCube &&
texture.wrapU === BABYLON.Texture.CLAMP_ADDRESSMODE} onSelect={(value) => texture.wrapU = value ? BABYLON.Texture.CLAMP_ADDRESSMODE : BABYLON.Texture.WRAP_ADDRESSMODE} /> texture.wrapV === BABYLON.Texture.CLAMP_ADDRESSMODE} onSelect={(value) => texture.wrapV = value ? BABYLON.Texture.CLAMP_ADDRESSMODE : BABYLON.Texture.WRAP_ADDRESSMODE} />
} { texture.isCube &&
}
); } }