Skip to content

Commit

Permalink
fix(editor): fix camera's aspect for scene view, game view and publis…
Browse files Browse the repository at this point in the history
…hed canvas
  • Loading branch information
yyc-git committed Oct 31, 2023
1 parent c5ce495 commit 667d1a1
Show file tree
Hide file tree
Showing 47 changed files with 206 additions and 501 deletions.
3 changes: 1 addition & 2 deletions contributes/meta3d-pipeline-camera-sceneview/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-camera-sceneview",
"version": "0.19.1",
"version": "0.19.3",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"protocol": {
"name": "meta3d-pipeline-camera-sceneview-protocol"
Expand All @@ -17,7 +17,6 @@
"meta3d-bs-most-protocol": "^0.19.0",
"meta3d-engine-core-sceneview-protocol": "^0.19.0",
"meta3d-pipeline-camera-sceneview-protocol": "^0.19.0",
"meta3d-pipeline-viewrect-sceneview-protocol": "^0.19.0",
"meta3d-type": "^0.19.1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ import { getState } from "../Utils"
import { states } from "meta3d-pipeline-camera-sceneview-protocol/src/StateType"
import { updateCamera } from "meta3d-pipeline-camera-utils/src/UpdateCameraJobUtils"
import { getExn } from "meta3d-commonlib-ts/src/NullableUtils"
import { pipelineName as viewRectPipelineName } from "meta3d-pipeline-viewrect-sceneview-protocol/src/StateType"
import { state as engineCoreState } from "meta3d-engine-core-sceneview-protocol/src/state/StateType"
import { service as engineCoreService } from "meta3d-engine-core-sceneview-protocol/src/service/ServiceType"
import { service as uiService } from "meta3d-ui-protocol/src/service/ServiceType"
import { state as uiState } from "meta3d-ui-protocol/src/state/StateType"
import { getViewRect } from "meta3d-view-utils/src/SceneViewRect";

export let execFunc: execFuncType = (meta3dState, { api, getStatesFunc, setStatesFunc, meta3dEngineCoreExtensionProtocolName }) => {
let states = getStatesFunc<states>(meta3dState)
let { mostService, engineCoreService, isDebug } = getState(states)

return mostService.callFunc(() => {
//console.log("update camera job")
let uiService = api.getExtensionService<uiService>(meta3dState, "meta3d-ui-protocol")
let uiState = api.getExtensionState<uiState>(meta3dState, "meta3d-ui-protocol")

// let { width, height } = getExn(states[viewRectPipelineName].viewRect)
let { width, height } = getExn(getViewRect(
uiService,
uiState
))

let { width, height } = getExn(states[viewRectPipelineName].viewRect)

return api.setExtensionState(meta3dState, meta3dEngineCoreExtensionProtocolName, updateCamera<engineCoreState, engineCoreService>(api.getExtensionState(meta3dState, meta3dEngineCoreExtensionProtocolName), engineCoreService, isDebug, [width, height]))
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "meta3d-pipeline-viewrect-sceneview",
"version": "0.19.1",
"name": "meta3d-pipeline-editor-viewrect-gameview",
"version": "0.19.0",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"protocol": {
"name": "meta3d-pipeline-viewrect-sceneview-protocol"
"name": "meta3d-pipeline-viewrect-gameview-protocol"
},
"license": "MIT",
"scripts": {
Expand All @@ -15,7 +15,8 @@
"keywords": [],
"dependencies": {
"meta3d-bs-most-protocol": "^0.19.0",
"meta3d-pipeline-viewrect-sceneview-protocol": "^0.19.0",
"meta3d-pipeline-viewrect-gameview-protocol": "^0.19.0",
"meta3d-ui-protocol": "^0.19.0",
"meta3d-type": "^0.19.1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { pipelineContribute } from "meta3d-engine-core-sceneview-protocol/src/contribute/work/PipelineContributeType";
import { pipelineContribute } from "meta3d-engine-core-gameview-protocol/src/contribute/work/PipelineContributeType";
import { execFunc as execGetViewRectForInitJob } from "./jobs/init/GetViewRectJob"
import { execFunc as execGetViewRectForUpdateJob } from "./jobs/update/GetViewRectJob"
import { config } from "meta3d-pipeline-viewrect-sceneview-protocol/src/ConfigType";
import { state, states, pipelineName, allPipelineData, job } from "meta3d-pipeline-viewrect-sceneview-protocol/src/StateType";
import { config } from "meta3d-pipeline-viewrect-gameview-protocol/src/ConfigType";
import { state, states, pipelineName, allPipelineData, job } from "meta3d-pipeline-viewrect-gameview-protocol/src/StateType";
import { getContribute as getContributeMeta3D } from "meta3d-type"
import { service as mostService } from "meta3d-bs-most-protocol/src/service/ServiceType"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { state, states, pipelineName } from "meta3d-pipeline-viewrect-sceneview-protocol/src/StateType"
import { state, states, pipelineName } from "meta3d-pipeline-viewrect-gameview-protocol/src/StateType"

export let getState = (states: states): state => {
return states[pipelineName]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { execFunc as execFuncType } from "meta3d-engine-core-gameview-protocol/src/contribute/work/PipelineContributeType"
import { getState, setState } from "../Utils";
import { states } from "meta3d-pipeline-viewrect-gameview-protocol/src/StateType"

export let execFunc: execFuncType = (meta3dState, { api, getStatesFunc, setStatesFunc }) => {
let states = getStatesFunc<states>(meta3dState)
let { mostService } = getState(states)

return mostService.just(meta3dState)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { execFunc as execFuncType } from "meta3d-engine-core-gameview-protocol/src/contribute/work/PipelineContributeType"
import { getState, setState } from "../Utils";
import { states } from "meta3d-pipeline-viewrect-gameview-protocol/src/StateType"
import { getViewRect } from "meta3d-view-utils/src/GameViewRect";
import { getExn } from "meta3d-commonlib-ts/src/NullableUtils";
import { service as uiService } from "meta3d-ui-protocol/src/service/ServiceType"
import { state as uiState } from "meta3d-ui-protocol/src/state/StateType"

export let execFunc: execFuncType = (meta3dState, { api, getStatesFunc, setStatesFunc }) => {
let states = getStatesFunc<states>(meta3dState)
let { mostService } = getState(states)

return mostService.callFunc(() => {
//console.log("get view rect job");

let uiService = api.getExtensionService<uiService>(meta3dState, "meta3d-ui-protocol")
let uiState = api.getExtensionState<uiState>(meta3dState, "meta3d-ui-protocol")

return setStatesFunc<states>(
meta3dState,
setState(states, {
...getState(states),
viewRect: getExn(getViewRect(
uiService,
uiState
))
})
)
})
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-editor-webgl1-game-view1",
"version": "0.19.1",
"version": "0.19.2",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"protocol": {
"name": "meta3d-pipeline-editor-webgl1-game-view1-protocol"
Expand Down
33 changes: 18 additions & 15 deletions contributes/meta3d-pipeline-editor-webgl1-game-view1/src/Main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { pipelineContribute } from "meta3d-engine-core-gameview-protocol/src/contribute/work/PipelineContributeType";
import { execFunc as execInitArcballCameraControllerJob } from "./jobs/init/InitArcballCameraControllerJob";
import { execFunc as execCreateDefaultSceneJob } from "./jobs/init/CreateDefaultSceneJob";
import { execFunc as execPrepareFBO } from "./jobs/update/PrepareFBOJob";
import { execFunc as execUpdateArcballCameraControllerJob } from "./jobs/update/UpdateArcballCameraControllerJob";
import { execFunc as execPrepareStatus } from "./jobs/render/PrepareStatusJob";
import { execFunc as execUseFBO } from "./jobs/render/UseFBOJob";
import { config } from "meta3d-pipeline-editor-webgl1-game-view1-protocol/src/ConfigType";
import { state, states, pipelineName, allPipelineData, job } from "meta3d-pipeline-editor-webgl1-game-view1-protocol/src/StateType";
import { pipelineContribute } from "meta3d-engine-core-gameview-protocol/src/contribute/work/PipelineContributeType"
import { execFunc as execInitArcballCameraControllerJob } from "./jobs/init/InitArcballCameraControllerJob"
import { execFunc as execCreateDefaultSceneJob } from "./jobs/init/CreateDefaultSceneJob"
import { execFunc as execPrepareFBO } from "./jobs/update/PrepareFBOJob"
import { execFunc as execUpdateCameraAspectJob } from "./jobs/update/UpdateCameraAspectJob"
import { execFunc as execUpdateArcballCameraControllerJob } from "./jobs/update/UpdateArcballCameraControllerJob"
import { execFunc as execPrepareStatus } from "./jobs/render/PrepareStatusJob"
import { execFunc as execUseFBO } from "./jobs/render/UseFBOJob"
import { config } from "meta3d-pipeline-editor-webgl1-game-view1-protocol/src/ConfigType"
import { state, states, pipelineName, allPipelineData, job } from "meta3d-pipeline-editor-webgl1-game-view1-protocol/src/StateType"
import { getContribute as getContributeMeta3D } from "meta3d-type"
import { service as mostService } from "meta3d-bs-most-protocol/src/service/ServiceType"
import { service as webgl1Service } from "meta3d-webgl1-protocol/src/service/ServiceType"
Expand All @@ -16,17 +17,19 @@ import { service as engineWholeService } from "meta3d-engine-whole-gameview-prot
let _getExecFunc = (_pipelineName: string, jobName: string) => {
switch (jobName) {
case job.InitArcballCameraController:
return execInitArcballCameraControllerJob;
return execInitArcballCameraControllerJob
case job.CreateDefaultScene:
return execCreateDefaultSceneJob;
return execCreateDefaultSceneJob
case job.UpdateCameraAspectJob:
return execUpdateCameraAspectJob
case job.UpdateArcballCameraController:
return execUpdateArcballCameraControllerJob;
return execUpdateArcballCameraControllerJob
case job.PrepareFBO:
return execPrepareFBO;
return execPrepareFBO
case job.PrepareStatus:
return execPrepareStatus;
return execPrepareStatus
case job.UseFBO:
return execUseFBO;
return execUseFBO
default:
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ import { state as meta3dState } from "meta3d-type"
import { addDefaultGameObjects, createUnUseGameObjectsForGameViewForUnifyGameObject } from "meta3d-pipeline-editor-webgl1-view1-utils/src/CreateDefaultSceneJobUtils"
import { activeFirstBasicCameraView } from "meta3d-load-scene-utils/src/Main"

type canvasSize = [number, number]

let _addDefaultGameObjects = (meta3dState: meta3dState, engineWholeService: engineWholeService,
// eventService: eventService,
// eventExtensionProtocolName: string,
canvasSize: canvasSize
): meta3dState => {
// TODO not use arcball
let data = addDefaultGameObjects<engineWholeService>(meta3dState, engineWholeService, canvasSize)
let data = addDefaultGameObjects<engineWholeService>(meta3dState, engineWholeService)
meta3dState = data[0]

meta3dState = createUnUseGameObjectsForGameViewForUnifyGameObject(meta3dState, engineWholeService)
Expand All @@ -29,18 +23,12 @@ export let execFunc: execFuncType = (meta3dState, { api, getStatesFunc, setState
let {
mostService,
engineWholeService,
// eventService,
canvas
} = getState(states)

return mostService.callFunc(() => {
//console.log("update job");


meta3dState = _addDefaultGameObjects(meta3dState, engineWholeService,
// eventService,
// "meta3d-event-protocol",
[canvas.width, canvas.height]
)

return meta3dState
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { execFunc as execFuncType } from "meta3d-engine-core-sceneview-protocol/src/contribute/work/PipelineContributeType"
import { getState, setState } from "../Utils";
import { states } from "meta3d-pipeline-editor-webgl1-game-view1-protocol/src/StateType";
import { getExn } from "meta3d-commonlib-ts/src/NullableUtils";
import { getViewRect } from "meta3d-view-utils/src/GameViewRect";
import { service as uiService } from "meta3d-ui-protocol/src/service/ServiceType"
import { state as uiState } from "meta3d-ui-protocol/src/state/StateType"
import { updateAllCameraAspect } from "meta3d-pipeline-editor-webgl1-view1-utils/src/CreateDefaultSceneJobUtils";

export let execFunc: execFuncType = (meta3dState, { api, getStatesFunc, setStatesFunc }) => {
let states = getStatesFunc<states>(meta3dState)
let {
mostService,
engineWholeService
} = getState(states)

return mostService.callFunc(() => {
let uiService = api.getExtensionService<uiService>(meta3dState, "meta3d-ui-protocol")
let uiState = api.getExtensionState<uiState>(meta3dState, "meta3d-ui-protocol")

let { width, height } = getExn(getViewRect(
uiService,
uiState
))

return updateAllCameraAspect(meta3dState, engineWholeService, width, height)
})
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-editor-webgl1-scene-view1",
"version": "0.19.1",
"version": "0.19.2",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"protocol": {
"name": "meta3d-pipeline-editor-webgl1-scene-view1-protocol"
Expand Down
17 changes: 10 additions & 7 deletions contributes/meta3d-pipeline-editor-webgl1-scene-view1/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { pipelineContribute } from "meta3d-engine-core-sceneview-protocol/src/co
import { execFunc as execInitArcballCameraControllerJob } from "./jobs/init/InitArcballCameraControllerJob";
import { execFunc as execCreateDefaultSceneJob } from "./jobs/init/CreateDefaultSceneJob";
import { execFunc as execPrepareFBO } from "./jobs/update/PrepareFBOJob";
import { execFunc as execUpdateCameraAspectJob } from "./jobs/update/UpdateCameraAspectJob"
import { execFunc as execUpdateArcballCameraControllerJob } from "./jobs/update/UpdateArcballCameraControllerJob";
import { execFunc as execPrepareStatus } from "./jobs/render/PrepareStatusJob";
import { execFunc as execUseFBO } from "./jobs/render/UseFBOJob";
Expand All @@ -17,17 +18,19 @@ import { service as eventService } from "meta3d-event-protocol/src/service/Servi
let _getExecFunc = (_pipelineName: string, jobName: string) => {
switch (jobName) {
case job.InitArcballCameraController:
return execInitArcballCameraControllerJob;
return execInitArcballCameraControllerJob
case job.CreateDefaultScene:
return execCreateDefaultSceneJob;
case job.PrepareFBO:
return execPrepareFBO;
return execCreateDefaultSceneJob
case job.UpdateCameraAspectJob:
return execUpdateCameraAspectJob
case job.UpdateArcballCameraController:
return execUpdateArcballCameraControllerJob;
return execUpdateArcballCameraControllerJob
case job.PrepareFBO:
return execPrepareFBO
case job.PrepareStatus:
return execPrepareStatus;
return execPrepareStatus
case job.UseFBO:
return execUseFBO;
return execUseFBO
default:
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { state as meta3dState } from "meta3d-type"
// import { service as eventService } from "meta3d-event-protocol/src/service/ServiceType"
import { activeCameraForSceneView, addDefaultGameObjects, addGameObjectsForSceneView } from "meta3d-pipeline-editor-webgl1-view1-utils/src/CreateDefaultSceneJobUtils"

type canvasSize = [number, number]
// type canvasSize = [number, number]

let _addDefaultGameObjects = (meta3dState: meta3dState, engineWholeService: engineWholeService,
// eventService: eventService,
// eventExtensionProtocolName: string,
canvasSize: canvasSize
// canvasSize: canvasSize
): meta3dState => {
let data = addDefaultGameObjects<engineWholeService>(meta3dState, engineWholeService, canvasSize)
let data = addDefaultGameObjects<engineWholeService>(meta3dState, engineWholeService)
meta3dState = data[0]

data = addGameObjectsForSceneView(meta3dState, engineWholeService,
// eventService, eventExtensionProtocolName,
canvasSize)
)
meta3dState = data[0]
let cameraController = data[1]
let cameraGameObject = data[2]
Expand All @@ -45,7 +45,7 @@ export let execFunc: execFuncType = (meta3dState, { api, getStatesFunc, setState
meta3dState = _addDefaultGameObjects(meta3dState, engineWholeService,
// eventService,
// "meta3d-event-protocol",
[canvas.width, canvas.height]
// [canvas.width, canvas.height]
)

return meta3dState
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { execFunc as execFuncType } from "meta3d-engine-core-sceneview-protocol/src/contribute/work/PipelineContributeType"
import { getState, setState } from "../Utils";
import { states } from "meta3d-pipeline-editor-webgl1-scene-view1-protocol/src/StateType";
import { getExn } from "meta3d-commonlib-ts/src/NullableUtils";
import { getViewRect } from "meta3d-view-utils/src/SceneViewRect";
import { service as uiService } from "meta3d-ui-protocol/src/service/ServiceType"
import { state as uiState } from "meta3d-ui-protocol/src/state/StateType"
import { updateAllCameraAspect } from "meta3d-pipeline-editor-webgl1-view1-utils/src/CreateDefaultSceneJobUtils";

export let execFunc: execFuncType = (meta3dState, { api, getStatesFunc, setStatesFunc }) => {
let states = getStatesFunc<states>(meta3dState)
let {
mostService,
engineWholeService
} = getState(states)

return mostService.callFunc(() => {
let uiService = api.getExtensionService<uiService>(meta3dState, "meta3d-ui-protocol")
let uiState = api.getExtensionState<uiState>(meta3dState, "meta3d-ui-protocol")

let { width, height } = getExn(getViewRect(
uiService,
uiState
))

return updateAllCameraAspect(meta3dState, engineWholeService, width, height)
})
}
2 changes: 1 addition & 1 deletion contributes/meta3d-pipeline-viewrect-gameview/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meta3d-pipeline-viewrect-gameview",
"version": "0.19.1",
"version": "0.19.2",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"protocol": {
"name": "meta3d-pipeline-viewrect-gameview-protocol"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,7 @@ import { states } from "meta3d-pipeline-viewrect-gameview-protocol/src/StateType

export let execFunc: execFuncType = (meta3dState, { api, getStatesFunc, setStatesFunc }) => {
let states = getStatesFunc<states>(meta3dState)
let { mostService, canvas } = getState(states)
let { mostService } = getState(states)

return mostService.callFunc(() => {
//console.log("get view rect job");

return setStatesFunc<states>(
meta3dState,
setState(states, {
...getState(states),
viewRect: {
x: 0,
y: 0,
width: canvas.width,
height: canvas.height
}
})
)
})
return mostService.just(meta3dState)
}
Loading

0 comments on commit 667d1a1

Please sign in to comment.