diff --git a/src/DatabaseServices/Lights/DirectionalLight.ts b/src/DatabaseServices/Lights/DirectionalLight.ts index ad6536304..53b7d1197 100644 --- a/src/DatabaseServices/Lights/DirectionalLight.ts +++ b/src/DatabaseServices/Lights/DirectionalLight.ts @@ -18,7 +18,7 @@ import { Light } from "./Light"; export class DirectionalLight extends Light { private m_Target = new Vector3(); - protected m_ShowHelper = true; + protected m_ShowHelper = false; get Target() { @@ -42,7 +42,10 @@ export class DirectionalLight extends Light } GetGripPoints(): Array { - return [this.Position, this.m_Target]; + if (this.ShowHelper) + return [this.Position, this.m_Target]; + else + return []; } MoveGripPoints(indexList: number[], vec: Vector3) { diff --git a/src/UI/Components/Modal/LightModal.tsx b/src/UI/Components/Modal/LightModal.tsx index 9dc217984..75c2b1f52 100644 --- a/src/UI/Components/Modal/LightModal.tsx +++ b/src/UI/Components/Modal/LightModal.tsx @@ -56,6 +56,7 @@ interface ILightComponentProps pars: [string, string][]; isShowPos: boolean; isSelectTarget: boolean; + hideColor?: boolean; } @observer @@ -142,17 +143,20 @@ export class LightDataCom extends React.Component { /> : null }
-
- 颜色 - - { - light.Color = new Color(color); - app.m_Editor.UpdateScreen(); - }} - /> -
+ { + !this.props.hideColor && +
+ 颜色 + + { + light.Color = new Color(color); + app.m_Editor.UpdateScreen(); + }} + /> +
+ } { this.props.light instanceof HemisphereLight ?
底色 diff --git a/src/UI/Components/RightPanel/RightPanel.less b/src/UI/Components/RightPanel/RightPanel.less index a2996df38..a7c56bfc7 100644 --- a/src/UI/Components/RightPanel/RightPanel.less +++ b/src/UI/Components/RightPanel/RightPanel.less @@ -1,4 +1,4 @@ -@height:20px; +@height:27px; #RightPanel .lg-target .bp3-input-group{ cursor: pointer; width: 10rem; @@ -23,6 +23,7 @@ display: flex; flex-wrap: wrap; justify-content: space-between; + align-items: center; &>div{ margin-top: 0; margin-bottom: 15px; diff --git a/src/UI/Components/RightPanel/ScenePanel.tsx b/src/UI/Components/RightPanel/ScenePanel.tsx index 4e9d976c6..68a376be8 100644 --- a/src/UI/Components/RightPanel/ScenePanel.tsx +++ b/src/UI/Components/RightPanel/ScenePanel.tsx @@ -1,20 +1,95 @@ -import { Alignment, Button, Intent, ITreeNode, Switch, Divider } from '@blueprintjs/core'; +import { Alignment, Button, Intent, Switch, Divider, HTMLSelect, Label, Classes, NumericInput } from '@blueprintjs/core'; import { observable } from 'mobx'; import { inject, observer } from 'mobx-react'; import * as React from 'react'; -import { FixedNotZero } from '../../../Common/Utils'; import { RightPanelStore } from '../../Store/RightPanelStore'; import { LightDataCom, LightModal } from '../Modal/LightModal'; +import { hot } from 'react-hot-loader/root'; +import { Vector3, Matrix4, Math as TMath } from 'three'; +import { app } from '../../../ApplicationServices/Application'; +import { FixedNotZero } from '../../../Common/Utils'; +import { angle, equalv3 } from '../../../Geometry/GeUtils'; -export interface ITreeExampleState +enum ETime { - nodes: ITreeNode[]; + Morning = "上午", + Noon = "中午", + Afternoon = "下午", + Evening = "傍晚", } +const DefaultDist = 2000; + +@hot @inject("store") @observer -export class ScenePanel extends React.Component<{ store?: RightPanelStore }, ITreeExampleState> +export class ScenePanel extends React.Component<{ store?: RightPanelStore }, {}> { + @observable sunState = { + time: ETime.Morning, + angle: "60", + rotation: "0" + } + private SetSunPostion(angle: number, rotation: number) + { + let pos = new Vector3(DefaultDist * Math.cos(angle), 0, DefaultDist * Math.sin(angle)); + pos.applyMatrix4(new Matrix4().makeRotationZ(rotation)); + this.props.store.lightStore.m_DirectionalLight.Position = pos; + app.m_Editor.UpdateScreen(); + } + private handleSuntime = () => + { + let dirLight = this.props.store.lightStore.m_DirectionalLight; + + switch (this.sunState.time) + { + case ETime.Morning: + dirLight.Intensity = 2; + this.sunState.angle = "60"; + this.sunState.rotation = "0"; + this.SetSunPostion(Math.PI / 3, 0); + break; + case ETime.Noon: + dirLight.Intensity = 6; + this.sunState.angle = "90"; + this.sunState.rotation = "0"; + this.SetSunPostion(Math.PI / 2, 0); + break; + case ETime.Afternoon: + dirLight.Intensity = 4; + this.sunState.angle = "60"; + this.sunState.rotation = "180"; + this.SetSunPostion(Math.PI / 3, Math.PI); + break; + case ETime.Evening: + dirLight.Intensity = 2; + this.sunState.angle = "30"; + this.sunState.rotation = "180"; + this.SetSunPostion(Math.PI / 6, Math.PI); + break; + default: + break; + } + app.m_Editor.UpdateScreen(); + } + private handleChangeSunAngle = (num: number) => + { + this.sunState.angle = num.toString(); + this.SetSunPostion(TMath.degToRad(num), TMath.degToRad(parseFloat(this.sunState.rotation))); + } + private handleChangeSunRotation = (num: number) => + { + this.sunState.rotation = num.toString(); + this.SetSunPostion(TMath.degToRad(parseFloat(this.sunState.angle)), TMath.degToRad(num)); + } + componentWillMount() + { + const sun = this.props.store.lightStore.m_DirectionalLight; + let vec = sun.Position.setZ(0); + + this.sunState.angle = equalv3(vec, new Vector3()) ? "90" : FixedNotZero(TMath.radToDeg(vec.angleTo(sun.Position)), 0); + this.sunState.rotation = FixedNotZero(TMath.radToDeg(angle(vec)), 0); + } render() { const lightStore = this.props.store.lightStore; @@ -92,18 +167,50 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore }, ITr alignIndicator={Alignment.RIGHT} />
+ + { + this.sunState.time = e.currentTarget.value as ETime; + this.handleSuntime(); + }} + /> +
+ + +
{