import * as React from "react"; import { GlobalState } from '../../globalState'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCircle, faRing, faCube, faHockeyPuck, faSquareFull, faPlus, faDotCircle } from '@fortawesome/free-solid-svg-icons'; import { PreviewMeshType } from './previewMeshType'; import { DataStorage } from '../../dataStorage'; interface IPreviewMeshControlComponent { globalState: GlobalState; } export class PreviewMeshControlComponent extends React.Component { changeMeshType(newOne: PreviewMeshType) { if (this.props.globalState.previewMeshType === newOne) { return; } this.props.globalState.previewMeshType = newOne; this.props.globalState.onPreviewCommandActivated.notifyObservers(); DataStorage.StoreNumber("PreviewMeshType", newOne); this.forceUpdate(); } useCustomMesh(evt: any) { var files: File[] = evt.target.files; if (files && files.length) { let file = files[0]; this.props.globalState.previewMeshFile = file; this.props.globalState.previewMeshType = PreviewMeshType.Custom; this.props.globalState.onPreviewCommandActivated.notifyObservers(); this.forceUpdate(); } (document.getElementById("file-picker")! as HTMLInputElement).value = ""; } render() { return (
this.changeMeshType(PreviewMeshType.Box)} className={"button" + (this.props.globalState.previewMeshType === PreviewMeshType.Box ? " selected" : "")}>
this.changeMeshType(PreviewMeshType.Sphere)} className={"button" + (this.props.globalState.previewMeshType === PreviewMeshType.Sphere ? " selected" : "")}>
this.changeMeshType(PreviewMeshType.Torus)} className={"button" + (this.props.globalState.previewMeshType === PreviewMeshType.Torus ? " selected" : "")}>
this.changeMeshType(PreviewMeshType.Cylinder)} className={"button" + (this.props.globalState.previewMeshType === PreviewMeshType.Cylinder ? " selected" : "")}>
this.changeMeshType(PreviewMeshType.Plane)} className={"button" + (this.props.globalState.previewMeshType === PreviewMeshType.Plane ? " selected" : "")}>
this.changeMeshType(PreviewMeshType.ShaderBall)} className={"button" + (this.props.globalState.previewMeshType === PreviewMeshType.ShaderBall ? " selected" : "")}>
this.useCustomMesh(evt)} accept=".gltf, .glb, .babylon, .obj"/>
); } }