增加抗锯齿选项

pull/348/MERGE
ChenX 5 years ago
parent 8fcf3776d7
commit bfc56d2578

@ -1,5 +1,5 @@
import { Command } from "../Editor/CommandMachine"; import { Command } from "../Editor/CommandMachine";
import { OptionModalStore, OptionModal } from "../UI/Components/Modal/OptionModal/OptionModal"; import { ConfigStore, ConfigDialog } from "../UI/Components/Modal/OptionModal/ConfigDialog";
import { app } from "../ApplicationServices/Application"; import { app } from "../ApplicationServices/Application";
import { ModalPosition } from "../UI/Components/Modal/ModalsManage"; import { ModalPosition } from "../UI/Components/Modal/ModalsManage";
@ -7,7 +7,7 @@ export class Command_Options implements Command
{ {
async exec() async exec()
{ {
let OptionStore = OptionModalStore.GetInstance() as OptionModalStore; let OptionStore = ConfigStore.GetInstance() as ConfigStore;
app.Editor.ModalManage.RenderModal(OptionModal, ModalPosition.Center, { store: OptionStore }); app.Editor.ModalManage.RenderModal(ConfigDialog, ModalPosition.Center, { store: OptionStore });
} }
} }

@ -0,0 +1,5 @@
export function IsDev()
{
return window.location.hostname === "localhost";
}

@ -26,7 +26,7 @@ require("three-SMAAPass");
require("three-OutlinePass"); require("three-OutlinePass");
enum AAType export enum AAType
{ {
FXAA = 0,//快速近似抗锯齿(性能更好) FXAA = 0,//快速近似抗锯齿(性能更好)
SMAA = 1,//多重采样抗锯齿(质量更好) SMAA = 1,//多重采样抗锯齿(质量更好)
@ -120,17 +120,28 @@ export class Viewer
if (this._AAType === AAType.FXAA) if (this._AAType === AAType.FXAA)
{ {
arrayRemoveOnce(this.Composer.passes, this._EffectFXAAPass); arrayRemoveOnce(this.Composer.passes, this._EffectFXAAPass);
this.Composer.passes.push(this._SMAAPass);
if (!this._SMAAPass)
{
this._SMAAPass = new SMAAPass(this.Width, this.Height);
this._SMAAPass.renderToScreen = true;
}
this.Composer.addPass(this._SMAAPass);
} }
else else
{ {
arrayRemoveOnce(this.Composer.passes, this._SMAAPass); arrayRemoveOnce(this.Composer.passes, this._SMAAPass);
this.Composer.passes.push(this._EffectFXAAPass); this.Composer.addPass(this._EffectFXAAPass);
} }
this._AAType = type; this._AAType = type;
this.UpdateRender(); this.UpdateRender();
} }
} }
get AAType()
{
return this._AAType;
}
//初始化render //初始化render
InitRender(canvasContainer: HTMLElement) InitRender(canvasContainer: HTMLElement)
@ -174,8 +185,6 @@ export class Viewer
this.Composer.addPass(this.OutlinePass); this.Composer.addPass(this.OutlinePass);
this._SMAAPass = new SMAAPass(this.Width, this.Height);
this._SMAAPass.renderToScreen = true;
this._EffectFXAAPass = new FXAAPass(); this._EffectFXAAPass = new FXAAPass();
this.Composer.addPass(this._EffectFXAAPass); this.Composer.addPass(this._EffectFXAAPass);

@ -2,7 +2,8 @@ import { Button, Classes, H2, H3, H5, Icon, Intent } from '@blueprintjs/core';
import { observable } from 'mobx'; import { observable } from 'mobx';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { ResourcesCDN_HOST, CURRENT_HOST } from '../../../Common/HostUrl'; import { IsDev } from '../../../Common/Deving';
import { CURRENT_HOST, ResourcesCDN_HOST } from '../../../Common/HostUrl';
import { FileServer } from '../../../DatabaseServices/FileServer'; import { FileServer } from '../../../DatabaseServices/FileServer';
import { TopPanelStore } from '../../Store/TopPanelStore'; import { TopPanelStore } from '../../Store/TopPanelStore';
import { Carousel } from '../Carousel'; import { Carousel } from '../Carousel';
@ -12,7 +13,7 @@ import './MainContent.less';
@observer @observer
export class ContentComponent extends React.Component<{ store?: TopPanelStore }> export class ContentComponent extends React.Component<{ store?: TopPanelStore }>
{ {
@observable private editoring = false @observable private editoring = false;
//添加新文件 //添加新文件
handleAddNewFile = async () => handleAddNewFile = async () =>
{ {
@ -28,6 +29,8 @@ export class ContentComponent extends React.Component<{ store?: TopPanelStore }>
} }
async componentDidMount() async componentDidMount()
{ {
if (IsDev())
this.handleAddNewFile();
await this.props.store.UpdateFileList2(); await this.props.store.UpdateFileList2();
} }

@ -17,7 +17,7 @@
position: fixed; position: fixed;
outline: none; outline: none;
font-size: 8px; font-size: 8px;
overflow: hidden; overflow: hidden; //影响到DisplayConfigPanel 的ColorPick
select{ select{
font-size: 8px; font-size: 8px;
} }

@ -241,7 +241,6 @@ export class ModalManage
app.Editor.MaskManage.Clear(); app.Editor.MaskManage.Clear();
this.events.forEach(f => f()); this.events.forEach(f => f());
this.events.length = 0; this.events.length = 0;
JigUtils.Destroy();
} }
EndCmd() EndCmd()
{ {

@ -1,19 +1,17 @@
import React = require("react"); import React = require("react");
import { Classes, Icon, H4, Button, Intent, Tabs, Tab, TabId, Card } from "@blueprintjs/core"; import { Button, Card, Classes, H4, Icon, Intent, Tab, Tabs } from "@blueprintjs/core";
import { app } from "../../../../ApplicationServices/Application";
import { observer, inject } from "mobx-react";
import { observable } from "mobx"; import { observable } from "mobx";
import { FileServer } from "../../../../DatabaseServices/FileServer"; import { observer } from "mobx-react";
import { Color } from "three";
import { begin } from "xaop"; import { begin } from "xaop";
import { app } from "../../../../ApplicationServices/Application";
import { KeyBoard } from "../../../../Common/KeyEnum"; import { KeyBoard } from "../../../../Common/KeyEnum";
import { DisplayPanel } from "./DisplayPanel";
import { Singleton } from "../../../../Common/Singleton"; import { Singleton } from "../../../../Common/Singleton";
import { ConfigCom } from "../../IConfig"; import { FileServer } from "../../../../DatabaseServices/FileServer";
import { userConfig } from "../../../../Editor/UserConfig"; import { userConfig } from "../../../../Editor/UserConfig";
interface Optioins import { DisplayConfigPanel } from "./DisplayConfigPanel";
{ import { DrawConfigPanel } from "./DrawConfigPanel";
bgcolor: string;
}
export enum EOptionTabId export enum EOptionTabId
{ {
File = "file", File = "file",
@ -22,43 +20,42 @@ export enum EOptionTabId
Draw = "ht", Draw = "ht",
} }
export class OptionModalStore extends Singleton export class ConfigStore extends Singleton
{ {
private oldBgcolor = "#000000"; private oldBgcolor = "#000000";
@observable m_Option: Optioins = { @observable bgColor = "#000000";
bgcolor: "#000000",
};
OnCanel = () => OnCanel = () =>
{ {
//背景色恢复上一次确定/应用时的 //背景色恢复上一次确定/应用时的
app.Viewer.Renderer.setClearColor(this.oldBgcolor); app.Viewer.Renderer.setClearColor(this.oldBgcolor);
this.m_Option.bgcolor = this.oldBgcolor; this.bgColor = this.oldBgcolor;
app.Editor.ModalManage.Clear(); app.Editor.ModalManage.Clear();
app.Viewer.Renderer.setClearColor(new Color(this.bgColor), 1);
app.Viewer.UpdateRender();
} }
OnOK = () => OnOK = () =>
{ {
this.oldBgcolor = this.m_Option.bgcolor; this.oldBgcolor = this.bgColor;
app.Editor.ModalManage.Clear(); app.Editor.ModalManage.Clear();
} }
Apply = () => Apply = () =>
{ {
this.oldBgcolor = this.m_Option.bgcolor; this.oldBgcolor = this.bgColor;
} }
} }
@inject("store")
/**
* (O)
*/
@observer @observer
export class OptionModal extends React.Component<{ store: OptionModalStore }, {}> export class ConfigDialog extends React.Component
{ {
@observable private selectedTabId: EOptionTabId = EOptionTabId.Draw; @observable private selectedTabId: EOptionTabId = EOptionTabId.Show;
@observable private curFileTitle = "图纸"; @observable private curFileTitle = "图纸";
optionModal: HTMLElement; optionModal: HTMLElement;
constructor(props)
{
super(props);
}
RegisterHandleKeyBoardEvent() RegisterHandleKeyBoardEvent()
{ {
const store = this.props.store; const store = ConfigStore.GetInstance() as ConfigStore;
app.Editor.ModalManage.events.push(begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) => app.Editor.ModalManage.events.push(begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) =>
{ {
if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space) if (e.keyCode === KeyBoard.Enter || e.keyCode === KeyBoard.Space)
@ -92,7 +89,7 @@ export class OptionModal extends React.Component<{ store: OptionModalStore }, {}
} }
render() render()
{ {
const store = this.props.store const store = ConfigStore.GetInstance() as ConfigStore;
return ( return (
<div <div
className={Classes.DIALOG_CONTAINER} className={Classes.DIALOG_CONTAINER}
@ -119,9 +116,9 @@ export class OptionModal extends React.Component<{ store: OptionModalStore }, {}
</Card> </Card>
<Tabs id="TabsOption" selectedTabId={this.selectedTabId} onChange={e => this.selectedTabId = e as EOptionTabId}> <Tabs id="TabsOption" selectedTabId={this.selectedTabId} onChange={e => this.selectedTabId = e as EOptionTabId}>
<Tab id={EOptionTabId.File} title="文件" /> <Tab id={EOptionTabId.File} title="文件" />
<Tab id={EOptionTabId.Show} title="显示" panel={<DisplayPanel OptionStore={store as OptionModalStore} />} /> <Tab id={EOptionTabId.Show} title="显示" panel={<DisplayConfigPanel store={store} />} />
<Tab id={EOptionTabId.Sys} title="系统" /> <Tab id={EOptionTabId.Sys} title="系统" />
<Tab id={EOptionTabId.Draw} title="绘图" panel={<ConfigCom store={userConfig} />} /> <Tab id={EOptionTabId.Draw} title="绘图" panel={<DrawConfigPanel store={userConfig} />} />
</Tabs> </Tabs>
</div> </div>

@ -0,0 +1,83 @@
import React = require("react");
import { Card, HTMLSelect, Label, Classes } from "@blueprintjs/core";
import { observable } from "mobx";
import { observer } from "mobx-react";
import { ColorResult, SketchPicker } from "react-color";
import { Color } from "three";
import { app } from "../../../../ApplicationServices/Application";
import { ConfigStore } from "./ConfigDialog";
import { AAType } from "../../../../GraphicsSystem/Viewer";
@observer
export class DisplayConfigPanel extends React.Component<{ store: ConfigStore }>
{
@observable private _OpenColorPick = false;
@observable _AAType = "性能";
componentWillMount()
{
this._AAType = app.Viewer.AAType === AAType.FXAA ? "性能" : "质量";
}
handleChangeColor = (color: ColorResult) =>
{
this.props.store.bgColor = color.hex;
app.Viewer.Renderer.setClearColor(new Color(color.hex), 1);
app.Editor.UpdateScreen();
}
render()
{
const popover: React.CSSProperties = {
position: 'absolute',
}
const cover: React.CSSProperties = {
position: 'fixed',
top: '0px',
right: '0px',
bottom: '0px',
left: '0px',
}
let color = this.props.store.bgColor;
return (
<Card>
<div>
<div style={{ display: "inline-flex" }}>
<p>:</p>
<div style={{ zIndex: 100 }}>
<div
style={{
background: color,
width: 20,
height: 20
}}
onClick={this.handleClick}
/>
{this._OpenColorPick &&
<div style={popover}>
<div style={cover} onClick={this.handleClick} />
<SketchPicker
color={this.props.store.bgColor}
onChange={this.handleChangeColor}
/>
</div>
}
</div>
</div>
<Label className={Classes.INLINE}>
齿:
<HTMLSelect options={["性能", "质量"]}
value={this._AAType}
onChange={e =>
{
app.Viewer.AAType = e.target.value === "性能" ? AAType.FXAA : AAType.SMAA;
this._AAType = e.target.value;
}} />
</Label>
</div>
</Card>
)
}
handleClick = () =>
{
this._OpenColorPick = !this._OpenColorPick;
};
}

@ -1,69 +0,0 @@
import React = require("react");
import { Card, H5, Popover, Classes, Button } from "@blueprintjs/core";
import { app } from "../../../../ApplicationServices/Application";
import { Color } from "three";
import { SketchPicker } from "react-color";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import { OptionModalStore } from "./OptionModal";
enum DisplayPanelShow
{
BgColorPicker = 1,
}
@inject("OptionStore")
@observer
export class DisplayPanel extends React.Component<{ OptionStore: OptionModalStore }, {}>
{
m_InputEl = HTMLInputElement;
@observable private m_isShow: DisplayPanelShow = -1;
handleChangeColor = (color) =>
{
console.log(color.hex)
this.props.OptionStore.m_Option.bgcolor = color.hex;
app.Viewer.Renderer.setClearColor(new Color(color.hex), 1);
app.Editor.UpdateScreen();
}
RenderBgColorPicker = () =>
{
return (
<div>
<SketchPicker
color={"#334048"}
onChange={this.handleChangeColor}
/>
</div>
)
}
render()
{
return (
<Card>
<H5></H5>
<input
style={{ width: "8rem" }}
type="text"
className={Classes.INPUT}
value={this.props.OptionStore.m_Option.bgcolor}
/>
<Popover
isOpen={this.m_isShow === DisplayPanelShow.BgColorPicker}
content={this.RenderBgColorPicker()}
>
<Button
icon="style"
minimal={true}
title={`背景色`}
onClick={() =>
{
if (this.m_isShow !== DisplayPanelShow.BgColorPicker)
this.m_isShow = DisplayPanelShow.BgColorPicker;
else
this.m_isShow = -1;
}}
/>
</Popover >
</Card>
)
}
}

@ -1,8 +1,8 @@
import { Card, Checkbox, Classes, H5, Label } from '@blueprintjs/core'; import { Card, Checkbox, Classes, H5, Label } from '@blueprintjs/core';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { app } from '../../ApplicationServices/Application'; import { app } from '../../../../ApplicationServices/Application';
import { UserConfig } from '../../Editor/UserConfig'; import { UserConfig } from '../../../../Editor/UserConfig';
interface IConfigProps interface IConfigProps
{ {
@ -10,7 +10,7 @@ interface IConfigProps
} }
@observer @observer
export class ConfigCom extends React.Component<IConfigProps, {}> { export class DrawConfigPanel extends React.Component<IConfigProps, {}> {
private toggleDrillingReactor = () => private toggleDrillingReactor = () =>
{ {
const userConfig = this.props.store; const userConfig = this.props.store;
Loading…
Cancel
Save