From a31cfdc3a1e679fe7be9a5be8e90f46e8fcefcbb Mon Sep 17 00:00:00 2001 From: yyc-git <395976266@qq.com> Date: Wed, 25 Oct 2023 15:06:51 +0800 Subject: [PATCH] feat: pass run test:redo/undo when run fix clone with parent->redo; fix add glb->redo; --- .../meta3d-action-add-cube/package.json | 2 +- .../meta3d-action-add-cube/src/Main.ts | 6 ++--- .../package.json | 2 +- .../src/Main.ts | 6 ++--- .../package.json | 2 +- .../src/Main.ts | 8 +++--- .../package.json | 2 +- .../package.json | 2 +- doc/0.19.0.org | 20 +++++++++++++- .../src/DisposeGameObjectUtils.ts | 26 +++---------------- .../meta3d-structure-utils/src/ArrayUtils.ts | 6 +++++ 11 files changed, 44 insertions(+), 38 deletions(-) diff --git a/contributes/meta3d-action-add-cube/package.json b/contributes/meta3d-action-add-cube/package.json index 5789b940c..f1d72c658 100755 --- a/contributes/meta3d-action-add-cube/package.json +++ b/contributes/meta3d-action-add-cube/package.json @@ -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", diff --git a/contributes/meta3d-action-add-cube/src/Main.ts b/contributes/meta3d-action-add-cube/src/Main.ts index 59cd65819..e90b48a5c 100755 --- a/contributes/meta3d-action-add-cube/src/Main.ts +++ b/contributes/meta3d-action-add-cube/src/Main.ts @@ -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> = (api) => { @@ -86,8 +86,8 @@ export let getContribute: getContributeMeta3D(meta3dState, "meta3d-engine-whole-sceneview-protocol") let engineWholeGameViewService = api.getExtensionService(meta3dState, "meta3d-engine-whole-gameview-protocol") - meta3dState = disposeGameObjectAndChildren(meta3dState, engineWholeService, disposedGameObjectForSceneView) - meta3dState = disposeGameObjectAndChildren(meta3dState, engineWholeGameViewService, disposedGameObjectForGameView) + meta3dState = disposeGameObjectAndAllChildren(meta3dState, engineWholeService, disposedGameObjectForSceneView) + meta3dState = disposeGameObjectAndAllChildren(meta3dState, engineWholeGameViewService, disposedGameObjectForGameView) return Promise.resolve(meta3dState) })) diff --git a/contributes/meta3d-action-add-glb-to-scene/package.json b/contributes/meta3d-action-add-glb-to-scene/package.json index be23f4820..901c9573b 100755 --- a/contributes/meta3d-action-add-glb-to-scene/package.json +++ b/contributes/meta3d-action-add-glb-to-scene/package.json @@ -1,6 +1,6 @@ { "name": "meta3d-action-add-glb-to-scene", - "version": "0.18.2", + "version": "0.18.3", "publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307", "repoLink": "", "protocol": { diff --git a/contributes/meta3d-action-add-glb-to-scene/src/Main.ts b/contributes/meta3d-action-add-glb-to-scene/src/Main.ts index 21b14d4b3..29638077c 100755 --- a/contributes/meta3d-action-add-glb-to-scene/src/Main.ts +++ b/contributes/meta3d-action-add-glb-to-scene/src/Main.ts @@ -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" @@ -104,8 +104,8 @@ export let getContribute: getContributeMeta3D(meta3dState, "meta3d-engine-whole-sceneview-protocol") let engineWholeGameViewService = api.getExtensionService(meta3dState, "meta3d-engine-whole-gameview-protocol") - meta3dState = disposeGameObjectAndChildren(meta3dState, engineWholeService, disposedGameObjectForSceneView) - meta3dState = disposeGameObjectAndChildren(meta3dState, engineWholeGameViewService, disposedGameObjectForGameView) + meta3dState = disposeGameObjectAndAllChildren(meta3dState, engineWholeService, disposedGameObjectForSceneView) + meta3dState = disposeGameObjectAndAllChildren(meta3dState, engineWholeGameViewService, disposedGameObjectForGameView) return Promise.resolve(meta3dState) })) diff --git a/contributes/meta3d-action-clone-gameobject/package.json b/contributes/meta3d-action-clone-gameobject/package.json index 38ba520cc..a2768f1c9 100755 --- a/contributes/meta3d-action-clone-gameobject/package.json +++ b/contributes/meta3d-action-clone-gameobject/package.json @@ -1,6 +1,6 @@ { "name": "meta3d-action-clone-gameobject", - "version": "0.18.1", + "version": "0.18.2", "publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307", "repoLink": "", "protocol": { diff --git a/contributes/meta3d-action-clone-gameobject/src/Main.ts b/contributes/meta3d-action-clone-gameobject/src/Main.ts index b7def6333..3b1baf06f 100755 --- a/contributes/meta3d-action-clone-gameobject/src/Main.ts +++ b/contributes/meta3d-action-clone-gameobject/src/Main.ts @@ -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, clonedGameObjectsForGameView: Array) => { @@ -33,15 +33,17 @@ export let getContribute: getContributeMeta3D> = 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([ diff --git a/contributes/meta3d-pipeline-dispose-gameview/package.json b/contributes/meta3d-pipeline-dispose-gameview/package.json index 9bed4e744..7b1ff421d 100755 --- a/contributes/meta3d-pipeline-dispose-gameview/package.json +++ b/contributes/meta3d-pipeline-dispose-gameview/package.json @@ -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" diff --git a/contributes/meta3d-pipeline-dispose-sceneview/package.json b/contributes/meta3d-pipeline-dispose-sceneview/package.json index cc830339c..280862780 100755 --- a/contributes/meta3d-pipeline-dispose-sceneview/package.json +++ b/contributes/meta3d-pipeline-dispose-sceneview/package.json @@ -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" diff --git a/doc/0.19.0.org b/doc/0.19.0.org index 55e5add78..df67a3bad 100755 --- a/doc/0.19.0.org +++ b/doc/0.19.0.org @@ -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 diff --git a/utils/meta3d-dispose-utils/src/DisposeGameObjectUtils.ts b/utils/meta3d-dispose-utils/src/DisposeGameObjectUtils.ts index 602fc0f83..d8daeaad2 100755 --- a/utils/meta3d-dispose-utils/src/DisposeGameObjectUtils.ts +++ b/utils/meta3d-dispose-utils/src/DisposeGameObjectUtils.ts @@ -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 = (meta3dState: meta3dState, +export let disposeGameObjectAndAllChildren = (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, meta3dState: meta3dState, gameObject: gameObject): Array => { - 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)) } \ No newline at end of file diff --git a/utils/meta3d-structure-utils/src/ArrayUtils.ts b/utils/meta3d-structure-utils/src/ArrayUtils.ts index 55ea8316c..789c4ca3e 100755 --- a/utils/meta3d-structure-utils/src/ArrayUtils.ts +++ b/utils/meta3d-structure-utils/src/ArrayUtils.ts @@ -58,4 +58,10 @@ export let push = (arr: Array, value: T) => { arr.push(value) return arr +} + +export let flatten = (arr: Array>): Array => { + return arr.reduce((result, valueArr) => { + return result.concat(valueArr) + }, []) } \ No newline at end of file