Skip to content

Commit

Permalink
feat(mainEditorMaterial): split MainEditorBasic/lightMaterial to Main…
Browse files Browse the repository at this point in the history
…EditorBasic/LightMaterialForGam
  • Loading branch information
AmyOrz committed Apr 6, 2019
1 parent 8e13f43 commit 6577143
Show file tree
Hide file tree
Showing 30 changed files with 597 additions and 509 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
open Color;

open ColorType;

module Method = {
let changeColor = (materialComponent, value) => {
let colorArray =
value |> convertColorObjToColorPickType |> getEngineColorRgbArr;

StateEngineService.unsafeGetState()
|> BasicMaterialEngineService.setColor(colorArray, materialComponent)
|> StateLogicService.refreshEngineState;

StateInspectorEngineService.unsafeGetState()
|> InspectorEngineMaterialChangeValueUtils.changeMaterialValue(
colorArray,
(
GameObjectComponentEngineService.getBasicMaterialComponent,
BasicMaterialEngineService.setColor,
),
);
};
};

let component =
ReasonReact.statelessComponent("MainEditorBasicMaterialForAsset");

let render = (reduxTuple, materialComponent, _self) =>
InspectorMaterialComponentUtils.buildBasicMaterialComponent(
reduxTuple,
materialComponent,
Method.changeColor,
);

let make =
(
~uiState: AppStore.appState,
~dispatchFunc,
~materialComponent,
_children,
) => {
...component,
render: self => render((uiState, dispatchFunc), materialComponent, self),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
open Color;

open ColorType;

module Method = {
let changeColor = (materialComponent, value) => {
let colorArray =
value |> convertColorObjToColorPickType |> getEngineColorRgbArr;

StateEngineService.unsafeGetState()
|> LightMaterialEngineService.setLightMaterialDiffuseColor(
colorArray,
materialComponent,
)
|> StateLogicService.refreshEngineState;

StateInspectorEngineService.unsafeGetState()
|> InspectorEngineMaterialChangeValueUtils.changeMaterialValue(
colorArray,
(
GameObjectComponentEngineService.getLightMaterialComponent,
LightMaterialEngineService.setLightMaterialDiffuseColor,
),
);
};

let changeShininess = (materialComponent, value) => {
StateEngineService.unsafeGetState()
|> LightMaterialEngineService.setLightMaterialShininess(
value,
materialComponent,
)
|> StateLogicService.refreshEngineState;

StateInspectorEngineService.unsafeGetState()
|> InspectorEngineMaterialChangeValueUtils.changeMaterialValue(
value,
(
GameObjectComponentEngineService.getLightMaterialComponent,
LightMaterialEngineService.setLightMaterialShininess,
),
);
};
};

let component =
ReasonReact.statelessComponent("MainEditorLightMaterialForAsset");

let render = ((uiState, dispatchFunc), materialComponent, _self) =>
InspectorMaterialComponentUtils.buildLightMaterialComponent(
(uiState, dispatchFunc),
materialComponent,
(Method.changeColor, Method.changeShininess),
);

let make =
(
~uiState: AppStore.appState,
~dispatchFunc,
~materialComponent,
_children,
) => {
...component,
render: self => render((uiState, dispatchFunc), materialComponent, self),
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ module Method = {
StateEditorService.getState(),
StateInspectorEngineService.unsafeGetState(),
)
|> InspectorEngineGameObjectLogicService.disposeInspectorEngineContainerGameObjectAllChildren;
|> InspectorEngineGameObjectLogicService.disposeInspectorEngineContainerGameObjectAllChildren
|> JobEngineService.execDisposeJob
|> StateInspectorEngineService.setState
|> ignore;
};
};

Expand Down Expand Up @@ -101,19 +104,17 @@ let render =
{
switch (state.materialType) {
| BasicMaterial =>
<MainEditorBasicMaterial
<MainEditorBasicMaterialForAsset
uiState
dispatchFunc
materialComponent
isShowInspectorCanvas=true
/>

| LightMaterial =>
<MainEditorLightMaterial
<MainEditorLightMaterialForAsset
uiState
dispatchFunc
materialComponent
isShowInspectorCanvas=true
/>
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
open Color;

open ColorType;

let component =
ReasonReact.statelessComponent("MainEditorBasicMaterialForGameObject");

module Method = {
let changeColor = (materialComponent, value) => {
let colorArray =
value |> convertColorObjToColorPickType |> getEngineColorRgbArr;

StateEngineService.unsafeGetState()
|> BasicMaterialEngineService.setColor(colorArray, materialComponent)
|> StateLogicService.refreshEngineState;
};
};

let render = (reduxTuple, materialComponent, _self) =>
InspectorMaterialComponentUtils.buildBasicMaterialComponent(
reduxTuple,
materialComponent,
Method.changeColor,
);

let make =
(
~uiState: AppStore.appState,
~dispatchFunc,
~materialComponent,
_children,
) => {
...component,
render: self => render((uiState, dispatchFunc), materialComponent, self),
};
Loading

0 comments on commit 6577143

Please sign in to comment.