Skip to content

Commit

Permalink
feat: add ui control:scene view
Browse files Browse the repository at this point in the history
  • Loading branch information
yyc-git committed Nov 10, 2023
1 parent ce8b0f3 commit cf010c9
Show file tree
Hide file tree
Showing 22 changed files with 597 additions and 9 deletions.
19 changes: 19 additions & 0 deletions contributes/meta3d-ui-control-scene-view/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.DS_Store
.merlin
.idea/
.vscode/
jest_0/
reference/
node_modules/
mine/

coverage

dist/

npm-debug

.bsb.lock

yarn.lock

25 changes: 25 additions & 0 deletions contributes/meta3d-ui-control-scene-view/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var gulp = require("gulp");
var path = require("path");
var publish = require("meta3d-tool-publish")

gulp.task("publish_local_env", function (done) {
publish.publishContribute(
"local",
path.join(__dirname, "package.json"),
path.join(__dirname, "dist/static/js", "main.js")
).then(() => {
done()
})
});

gulp.task("publish_production_env", function (done) {
publish.publishContribute(
"production",
path.join(__dirname, "package.json"),
path.join(__dirname, "dist/static/js", "main.js")
).then(() => {
done()
})
});


35 changes: 35 additions & 0 deletions contributes/meta3d-ui-control-scene-view/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "meta3d-ui-control-scene-view",
"version": "0.20.0",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"displayName": "scene view",
"description": "",
"protocol": {
"name": "meta3d-ui-control-scene-view-protocol"
},
"license": "MIT",
"scripts": {
"watch": "tsc -w -noEmit",
"webpack": "webpack --config webpack.config.js",
"meta3d:publish_dev": "cross-env NODE_ENV=development npm run webpack && gulp publish_local_env",
"meta3d:publish_pro": "cross-env NODE_ENV=production npm run webpack && gulp publish_production_env"
},
"keywords": [],
"dependencies": {
"meta3d-type": "^0.20.0",
"meta3d-ui-control-scene-view-protocol": "^0.20.0",
"meta3d-editor-whole-protocol": "^0.20.0"
},
"devDependencies": {
"clean-webpack-plugin": "^4.0.0",
"cross-env": "^7.0.3",
"cz-customizable": "^6.3.0",
"gulp": "^4.0.2",
"meta3d-tool-publish": "^0.20.0",
"source-map-loader": "^3.0.0",
"ts-loader": "^9.2.6",
"typescript": "^4.2.3",
"webpack": "^5.62.1",
"webpack-cli": "^4.9.1"
}
}
84 changes: 84 additions & 0 deletions contributes/meta3d-ui-control-scene-view/src/Main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { getContribute as getContributeMeta3D } from "meta3d-type"
import { uiControlName, textureID, state as uiControlState, inputData, outputData, dragDropType, dragDropData } from "meta3d-ui-control-scene-view-protocol"
import { uiControlContribute } from "meta3d-ui-protocol/src/contribute/UIControlContributeType"
import { changeToStrictlyNull, getFBORect } from "meta3d-ui-control-view-utils/src/Main"
import { service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
import { service as renderService } from "meta3d-editor-sceneview-render-protocol/src/service/ServiceType"
// import { actionName as dropGlbActionName } from "meta3d-action-drop-glb-to-sceneview-protocol"
import { getExn, getWithDefault, isNullable, map } from "meta3d-commonlib-ts/src/NullableUtils"
// import { service as eventService } from "meta3d-event-protocol/src/service/ServiceType"

export let getContribute: getContributeMeta3D<uiControlContribute<inputData, outputData>> = (api) => {
return {
uiControlName: uiControlName,
func: (meta3dState,
{
rect,
label,
}
) => {
let { ui, getPluggablePackageService } = getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-ui-protocol"))
let { beginWindow, endWindow, beginChild, endChild, setNextWindowRect, getFBOTexture, addFBOTexture,
getWindowBarHeight,
// setUIControlState,
handleDragDropTarget
} = ui


meta3dState = setNextWindowRect(meta3dState, rect)

meta3dState = beginWindow(meta3dState, label)

meta3dState = beginChild(meta3dState, "Child_SceneView")

// let fboRect = getFBORect(rect, getWindowBarHeight(meta3dState))
let fboRect = getFBORect(rect, 0)
// fboRect = {
// x: fboRect.x - 5,
// y: fboRect.y - 5,
// width: fboRect.width + 10,
// height: fboRect.height + 10,
// }


meta3dState = addFBOTexture(meta3dState, changeToStrictlyNull(getFBOTexture, meta3dState, textureID), fboRect)


meta3dState = endChild(meta3dState)


// let { handleDragDropTarget } = api.getExtensionService<service>(meta3dState, "meta3d-ui-protocol")

/*!
* refer to https://github.com/ocornut/imgui/issues/1771
*/

let d = handleDragDropTarget<dragDropData>(meta3dState, dragDropType)
meta3dState = d[0]
let data = d[1]


meta3dState = endWindow(meta3dState)



meta3dState = getWithDefault(
map((renderService) => {
return renderService.setViewRect(meta3dState, fboRect)
}, getPluggablePackageService<renderService>(meta3dState, "meta3d-editor-sceneview-render-protocol")),
meta3dState
)



// let { trigger } = api.getExtensionService<eventService>(meta3dState, "meta3d-event-protocol")

// if (!isNullable(data)) {
// return trigger(meta3dState, "meta3d-event-protocol", dropGlbActionName, getExn(data)).then(meta3dState => [meta3dState, null])
// }

return Promise.resolve([meta3dState, null])
},
init: (meta3dState) => Promise.resolve(meta3dState)
}
}
24 changes: 24 additions & 0 deletions contributes/meta3d-ui-control-scene-view/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES6",
"module": "ES6",
"moduleResolution": "node",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"jsx": "react",
// "noEmit": true,
// "noUnusedLocals": true,
// "noUnusedParameters": true,
"noImplicitReturns": true,
"lib": [
"DOM",
"ESNext",
],
"types": [],
"strict": true
},
"include": [
"./src"
]
}
64 changes: 64 additions & 0 deletions contributes/meta3d-ui-control-scene-view/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {
entry: "./src/Main.ts",
mode: process.env.NODE_ENV.trim() == 'production' ? 'production' : 'development',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'static/js/[name].js',
library: {
name: 'Contribute',
type: 'window',
},
},

// Enable sourcemaps for debugging webpack's output.
// devtool: "source-map",

resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.scss'],
modules: ['node_modules']
},

module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: "ts-loader"
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: 'pre',
test: /\.js$/,
loader: "source-map-loader"
},
]
},
plugins: [
/**
* All files inside webpack's output.path directory will be removed once, but the
* directory itself will not be. If using webpack 4+'s default configuration,
* everything under <PROJECT_DIR>/dist/ will be removed.
* Use cleanOnceBeforeBuildPatterns to override this behavior.
*
* During rebuilds, all webpack assets that are not used anymore
* will be removed automatically.
*
* See `Options and Defaults` for information
*/
new CleanWebpackPlugin(),
// new HtmlWebpackPlugin({
// template: './user.html',
// filename: 'user.html',
// }),
],
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
externals: {
}
};
12 changes: 8 additions & 4 deletions doc/0.21.0.org
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ TODO add scene view render
TODO add ui control


TODO update meta3d-view-utils->getViewRect





TODO core, event add entry implement, protocol
Expand All @@ -275,6 +271,14 @@ e.g. scenegraph utils-> api.getExtensionService<editorWholeService>(meta3dState,

TODO fix scene->create gameObject: not consider un used

TODO update UpdateCameraJob
TODO update meta3d-view-utils->getViewRect







TODO update editor-whole

Expand Down
2 changes: 0 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"packages": [
"protocols/extension_protocols/*",
"protocols/contribute_protocols/*",
"extensions/*",
"contributes/*",
"packages/editor-whole/protocols/extension_protocols/*",
"packages/editor-whole/protocols/contribute_protocols/*",
"packages/editor-whole/extensions/*",
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
"workspaces": [
"protocols/extension_protocols/*",
"protocols/contribute_protocols/*",
"extensions/*",
"contributes/*",
"packages/editor-whole/protocols/extension_protocols/*",
"packages/editor-whole/protocols/contribute_protocols/*",
"packages/editor-whole/extensions/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { state as meta3dState, packageProtocolName, canvasData } from "meta3d-ty
// import { ecsConfig, scene } from "meta3d-engine-scene-protocol/src/service/ServiceType"
import { webgl1Context } from "meta3d-webgl1-protocol/src/service/ServiceType"
import { nullable } from "meta3d-commonlib-ts/src/nullable";
import { service as uiService } from "meta3d-ui-protocol/src/service/ServiceType"
import { service as uiService, texture } from "meta3d-ui-protocol/src/service/ServiceType"

type addToFuncs = (meta3dState: meta3dState, func: (meta3dState: meta3dState) => Promise<meta3dState>) => Promise<meta3dState>

Expand All @@ -12,6 +12,8 @@ type event = any

type ecsConfig = any

export type uiTexture = texture

export type configData = [canvasData, { isDebug: boolean, clearColor: [number, number, number, number], skinName: nullable<string> }]


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.DS_Store
.merlin
.idea/
.vscode/
jest_0/
reference/
node_modules/
mine/

coverage

dist/

npm-debug

.bsb.lock

yarn.lock

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var gulp = require("gulp");
var path = require("path");
var publish = require("meta3d-tool-publish-protocol")

gulp.task("publish_local_env", function (done) {
publish.publishContributeProtocol(
"local",
path.join(__dirname, "package.json"),
path.join(__dirname, "icon.png")
).then(() => {
done()
})
});

gulp.task("publish_production_env", function (done) {
publish.publishContributeProtocol(
"production",
path.join(__dirname, "package.json"),
path.join(__dirname, "icon.png")
).then(() => {
done()
})
});

gulp.task("publishConfig_local_env", function (done) {
publish.publishContributeProtocolConfig(
"local",
path.join(__dirname, "package.json"),
path.join(__dirname, "dist/static/js", "main.js")
).then(() => {
done()
})
});

gulp.task("publishConfig_production_env", function (done) {
publish.publishContributeProtocolConfig(
"production",
path.join(__dirname, "package.json"),
path.join(__dirname, "dist/static/js", "main.js")
).then(() => {
done()
})
});


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cf010c9

Please sign in to comment.