Skip to content

Commit

Permalink
feat: pass run test:redo/undo when run
Browse files Browse the repository at this point in the history
fix clone with parent->redo;
fix add glb->redo;
  • Loading branch information
yyc-git committed Oct 25, 2023
1 parent 3a7df15 commit a31cfdc
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 38 deletions.
2 changes: 1 addition & 1 deletion contributes/meta3d-action-add-cube/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-action-add-cube",
"version": "0.18.1",
"version": "0.18.2",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"displayName": "add-cube",
"repoLink": "https://github.com/Meta3D-Technology/Meta3D/tree/master/contributes/meta3d-action-add-cube",
Expand Down
6 changes: 3 additions & 3 deletions contributes/meta3d-action-add-cube/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getState, setState } from "./Utils"
import { getExn } from "meta3d-commonlib-ts/src/NullableUtils"
import { List } from "immutable"
import { gameObject } from "meta3d-gameobject-protocol"
import { disposeGameObjectAndChildren } from "meta3d-dispose-utils/src/DisposeGameObjectUtils"
import { disposeGameObjectAndAllChildren } from "meta3d-dispose-utils/src/DisposeGameObjectUtils"
import { createCubeGameObject } from "meta3d-primitive-utils/src/CubeUtils"

export let getContribute: getContributeMeta3D<actionContribute<clickUIData, state>> = (api) => {
Expand Down Expand Up @@ -86,8 +86,8 @@ export let getContribute: getContributeMeta3D<actionContribute<clickUIData, stat
let engineWholeService = api.getExtensionService<engineWholeService>(meta3dState, "meta3d-engine-whole-sceneview-protocol")
let engineWholeGameViewService = api.getExtensionService<engineWholeGameViewService>(meta3dState, "meta3d-engine-whole-gameview-protocol")

meta3dState = disposeGameObjectAndChildren<engineWholeService>(meta3dState, engineWholeService, disposedGameObjectForSceneView)
meta3dState = disposeGameObjectAndChildren<engineWholeGameViewService>(meta3dState, engineWholeGameViewService, disposedGameObjectForGameView)
meta3dState = disposeGameObjectAndAllChildren<engineWholeService>(meta3dState, engineWholeService, disposedGameObjectForSceneView)
meta3dState = disposeGameObjectAndAllChildren<engineWholeGameViewService>(meta3dState, engineWholeGameViewService, disposedGameObjectForGameView)

return Promise.resolve(meta3dState)
}))
Expand Down
2 changes: 1 addition & 1 deletion contributes/meta3d-action-add-glb-to-scene/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-action-add-glb-to-scene",
"version": "0.18.2",
"version": "0.18.3",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"repoLink": "",
"protocol": {
Expand Down
6 changes: 3 additions & 3 deletions contributes/meta3d-action-add-glb-to-scene/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getExn, isNullable } from "meta3d-commonlib-ts/src/NullableUtils"
import { getActionState, setElementStateField } from "meta3d-ui-utils/src/ElementStateUtils"
import { getState, setState } from "./Utils"
import { List } from "immutable"
import { disposeGameObjectAndChildren } from "meta3d-dispose-utils/src/DisposeGameObjectUtils"
import { disposeGameObjectAndAllChildren } from "meta3d-dispose-utils/src/DisposeGameObjectUtils"
import { service as engineWholeService } from "meta3d-engine-whole-sceneview-protocol/src/service/ServiceType"
import { service as engineWholeGameViewService } from "meta3d-engine-whole-gameview-protocol/src/service/ServiceType"
import { service as loadGLBService } from "meta3d-load-glb-protocol/src/service/ServiceType"
Expand Down Expand Up @@ -104,8 +104,8 @@ export let getContribute: getContributeMeta3D<actionContribute<dropGlbUIData, st
let engineWholeService = api.getExtensionService<engineWholeService>(meta3dState, "meta3d-engine-whole-sceneview-protocol")
let engineWholeGameViewService = api.getExtensionService<engineWholeGameViewService>(meta3dState, "meta3d-engine-whole-gameview-protocol")

meta3dState = disposeGameObjectAndChildren<engineWholeService>(meta3dState, engineWholeService, disposedGameObjectForSceneView)
meta3dState = disposeGameObjectAndChildren<engineWholeGameViewService>(meta3dState, engineWholeGameViewService, disposedGameObjectForGameView)
meta3dState = disposeGameObjectAndAllChildren<engineWholeService>(meta3dState, engineWholeService, disposedGameObjectForSceneView)
meta3dState = disposeGameObjectAndAllChildren<engineWholeGameViewService>(meta3dState, engineWholeGameViewService, disposedGameObjectForGameView)

return Promise.resolve(meta3dState)
}))
Expand Down
2 changes: 1 addition & 1 deletion contributes/meta3d-action-clone-gameobject/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-action-clone-gameobject",
"version": "0.18.1",
"version": "0.18.2",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"repoLink": "",
"protocol": {
Expand Down
8 changes: 5 additions & 3 deletions contributes/meta3d-action-clone-gameobject/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getState, setState } from "./Utils"
import { List } from "immutable"
import { actionName as selectSceneTreeNodeActionName, state as selectSceneTreeNodeState } from "meta3d-action-select-scenetree-node-protocol"
import { gameObject } from "meta3d-gameobject-protocol"
import { isArraysEqual } from "meta3d-structure-utils/src/ArrayUtils"
import { flatten, isArraysEqual } from "meta3d-structure-utils/src/ArrayUtils"
import { service as runEngineGameViewService } from "meta3d-editor-run-engine-gameview-protocol/src/service/ServiceType"

let _checkClonedGameObjectShouldEqualForBothView = (clonedGameObjectsForSceneView: Array<gameObject>, clonedGameObjectsForGameView: Array<gameObject>) => {
Expand All @@ -33,15 +33,17 @@ export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> =

let data = engineWholeSceneViewService.scene.gameObject.cloneGameObject(meta3dState, 1, { isShareMaterial: true, }, selectedGameObject)
meta3dState = data[0]
let clonedGameObjectsForSceneView = data[1][0]
let clonedGameObjectsForSceneView = flatten(data[1])

data = engineWholeGameViewService.scene.gameObject.cloneGameObject(meta3dState, 1, { isShareMaterial: true, }, selectedGameObject)
meta3dState = data[0]
let clonedGameObjectsForGameView = data[1][0]
let clonedGameObjectsForGameView = flatten(data[1])



_checkClonedGameObjectShouldEqualForBothView(clonedGameObjectsForSceneView, clonedGameObjectsForGameView)


let clonedGameObjects = clonedGameObjectsForSceneView

meta3dState = setElementStateField([
Expand Down
2 changes: 1 addition & 1 deletion contributes/meta3d-pipeline-dispose-gameview/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-dispose-gameview",
"version": "0.18.0",
"version": "0.18.1",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"protocol": {
"name": "meta3d-pipeline-dispose-gameview-protocol"
Expand Down
2 changes: 1 addition & 1 deletion contributes/meta3d-pipeline-dispose-sceneview/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-dispose-sceneview",
"version": "0.18.0",
"version": "0.18.1",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"protocol": {
"name": "meta3d-pipeline-dispose-sceneview-protocol"
Expand Down
20 changes: 19 additions & 1 deletion doc/0.19.0.org
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,25 @@ TODO need publish:



** TODO pass run test:redo/undo when run
** DONE pass run test:redo/undo when run

TODO need publish
# clone
# add cube
# add glb




TODO fix:
clone with parent->redo

TODO fix test glb:
add glb->redo


** TODO fix: stop error not in event


** TODO SceneTree, Asset header not scroll

Expand Down
26 changes: 3 additions & 23 deletions utils/meta3d-dispose-utils/src/DisposeGameObjectUtils.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import { state as meta3dState } from "meta3d-type"
import { gameObject } from "meta3d-gameobject-protocol"
import { service as engineWholeService } from "meta3d-engine-whole-sceneview-protocol/src/service/ServiceType"
import { getExn, isNullable } from "meta3d-commonlib-ts/src/NullableUtils"

export let disposeGameObjectAndChildren =<engineWholeService_ extends engineWholeService> (meta3dState: meta3dState,
export let disposeGameObjectAndAllChildren = <engineWholeService_ extends engineWholeService>(meta3dState: meta3dState,
engineWholeService: engineWholeService_,
gameObject: gameObject): meta3dState => {
let { getChildren, getGameObjects } = engineWholeService.scene.transform
let { getTransform, disposeGameObjects } = engineWholeService.scene.gameObject
let { disposeGameObjects, getGameObjectAndAllChildren } = engineWholeService.scene.gameObject

let _getGameObjects = (result: Array<gameObject>, meta3dState: meta3dState, gameObject: gameObject): Array<gameObject> => {
let children = getChildren(meta3dState, getTransform(meta3dState, gameObject))

if (isNullable(children) || getExn(children).length == 0) {
return result
}

return getExn(children).reduce((result, child) => {
let gameObject = getGameObjects(meta3dState, child)[0]

result.push(
gameObject
)

return _getGameObjects(result, meta3dState, gameObject)
}, result)
}

return disposeGameObjects(meta3dState, _getGameObjects([gameObject], meta3dState, gameObject))
return disposeGameObjects(meta3dState, getGameObjectAndAllChildren(meta3dState, gameObject))
}
6 changes: 6 additions & 0 deletions utils/meta3d-structure-utils/src/ArrayUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ export let push = <T>(arr: Array<T>, value: T) => {
arr.push(value)

return arr
}

export let flatten = <T>(arr: Array<Array<T>>): Array<T> => {
return arr.reduce((result, valueArr) => {
return result.concat(valueArr)
}, [])
}

0 comments on commit a31cfdc

Please sign in to comment.