Skip to content
Permalink
Browse files

feat(wdb): add imageDataIndex in wdbData

  • Loading branch information...
AmyOrz
AmyOrz committed Apr 16, 2019
1 parent 458762a commit bacfd2abc2fc1f51802ef10773fb8ea37c95f823
@@ -229,17 +229,24 @@ module Method = {
/>
|> Result.SameDataResult.success,
~wdbNodeFunc=
(nodeId, nodeData) => {
(nodeId, {imageDataIndex} as nodeData) => {
let fileName = WDBNodeAssetService.getNodeName(nodeData);

/* TODO get wdb img base64 from map */
let imgSrc =
ImageDataMapUtils.getImgSrc(
imageDataIndex,
editorState
|> MaterialDataAssetEditorService.unsafeGetDefaultMaterialSnapshotPath,
editorState,
);

<FileBox
key
uiState
dispatchFunc
effectAllowd="copyMove"
dragImg
imgSrc="./public/img/wdb.png"
imgSrc
nodeId
fileName
widget
@@ -1,11 +1,6 @@
module Method = {
let didMount = () => {
Js.log("wdb did mount");
let state = StateInspectorEngineService.unsafeGetState();

let game = state |> SceneEngineService.getSceneGameObject;

state |> HierarchyGameObjectEngineService.getAllChildren(game) |> Js.log;

AssetTreeInspectorUtils.showInspectorCanvas();
};
@@ -2,8 +2,8 @@ open TreeAssetType;

open NodeAssetType;

let buildNode = (~nodeId, ~name, ~wdbGameObject) =>
WDBNode(nodeId, {name, wdbGameObject});
let buildNode = (~nodeId, ~name, ~wdbGameObject, ~imageDataIndex) =>
WDBNode(nodeId, {name, wdbGameObject, imageDataIndex});

let buildNodeByNodeData = (~nodeId, ~nodeData) => WDBNode(nodeId, nodeData);

@@ -27,7 +27,7 @@ let isWDBNode = node =>
| _ => false
};

let rename = (~name, ~nodeData) : wdbNodeData => {...nodeData, name};
let rename = (~name, ~nodeData): wdbNodeData => {...nodeData, name};

let getNodeName = ({name}: wdbNodeData) => name;

@@ -19,7 +19,7 @@ type nodeId = int;
type wdbNodeData = {
name: string,
wdbGameObject: int,
/* imageDataIndex: int, */
imageDataIndex: int,
};

type textureNodeData = {
@@ -23,7 +23,15 @@ let importAssetWDB =
|> WonderBsMost.Most.tap(
((engineState, (imageUint8ArrayDataMap, _), gameObject)) => {
let allGameObjects =
HierarchyGameObjectEngineService.getAllGameObjects(gameObject, engineState);
HierarchyGameObjectEngineService.getAllGameObjects(
gameObject,
engineState,
);

let (editorState, newImageDataIndex) =
editorState |> IndexAssetEditorService.generateImageDataMapIndex;

/* TODO need create wdb snapshot */

editorState
/* |> WDBNodeMapAssetEditorService.setResult(
@@ -45,6 +53,17 @@ let importAssetWDB =
~nodeId=wdbNodeId,
~name,
~wdbGameObject=gameObject,
~imageDataIndex=newImageDataIndex,
),
)
|> ImageDataMapAssetEditorService.setData(
newImageDataIndex,
ImageDataMapAssetService.buildData(
~base64=None,
~uint8Array=None,
~name="wdb",
~mimeType=ImageUtils.getDefaultMimeType(),
(),
),
)
|> StateEditorService.setState
@@ -62,6 +62,7 @@ let insertWDBNode =
parentFolderNodeId,
gameObject,
name,
imageDataIndex,
(editorState, engineState),
) => (
editorState
@@ -71,6 +72,17 @@ let insertWDBNode =
~nodeId=wdbNodeId,
~wdbGameObject=gameObject,
~name,
~imageDataIndex,
),
)
|> ImageDataMapAssetEditorService.setData(
imageDataIndex,
ImageDataMapAssetService.buildData(
~base64=None,
~uint8Array=None,
~name="material",
~mimeType=ImageUtils.getDefaultMimeType(),
(),
),
),
engineState,
@@ -197,13 +197,16 @@ module BuildAssetTree = {
let (engineState, gameObject) =
GameObjectEngineService.create(engineState);
let name = "gameObject1";
let (editorState, newImageDataIndex) =
IndexAssetEditorService.generateImageDataMapIndex(editorState);

(editorState, engineState)
|> MainEditorAssetTreeNodeTool.insertWDBNode(
id1,
rootId,
gameObject,
name,
newImageDataIndex,
)
|> StateLogicService.setState;

@@ -14,11 +14,17 @@ let addWDBNodeToRoot =
~editorState,
~name="",
~arrayBuffer=Js.Typed_array.ArrayBuffer.make(0),
~imageDataIndex,
(),
) =>
WDBNodeAssetEditorService.addWDBNodeToAssetTree(
RootTreeAssetEditorService.getRootNode(editorState),
WDBNodeAssetService.buildNode(~nodeId, ~name, ~wdbGameObject=gameObject),
WDBNodeAssetService.buildNode(
~nodeId,
~name,
~wdbGameObject=gameObject,
~imageDataIndex,
),
editorState,
);

@@ -71,6 +71,10 @@ let _ =
let _addNoTexCoordGeometryWDBGameObject = () => {
let editorState = StateEditorService.getState();
let engineState = StateEngineService.unsafeGetState();
let (editorState, newImageDataIndex) =
IndexAssetEditorService.generateImageDataMapIndex(
editorState,
);

let (engineState, gameObject, _, _, name) =
GeometryToolEngine.createGameObjectAndSetPointData(
@@ -87,6 +91,7 @@ let _ =
~nodeId=id1,
~name,
~gameObject,
~imageDataIndex=newImageDataIndex,
(),
);

0 comments on commit bacfd2a

Please sign in to comment.
You can’t perform that action at this time.