Skip to content

Commit

Permalink
feat(uicontrol): add Scene Tree
Browse files Browse the repository at this point in the history
separate header, body: header = multiple Image Buttons;
rename to Tree;
add new Input;
  • Loading branch information
yyc-git committed Nov 27, 2023
1 parent 7bb76c8 commit af85382
Show file tree
Hide file tree
Showing 132 changed files with 4,025 additions and 159 deletions.
19 changes: 19 additions & 0 deletions contributes/meta3d-action-add-cube/.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-action-add-cube/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()
})
});


37 changes: 37 additions & 0 deletions contributes/meta3d-action-add-cube/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "meta3d-action-add-cube",
"version": "0.20.1",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"displayName": "add-cube",
"repoLink": "https://github.com/Meta3D-Technology/Meta3D/tree/master/contributes/meta3d-action-add-cube",
"description": "add cube action",
"protocol": {
"name": "meta3d-action-add-cube-protocol"
},
"license": "MIT",
"scripts": {
"watch": "tsc -w -noEmit",
"webpack": "webpack --config webpack.config.js",
"meta3d:publish_dev_auto": "yarn version --patch --no-git-tag-version && yarn meta3d:publish_dev",
"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-action-add-cube-protocol": "^0.20.0",
"meta3d-editor-whole-protocol": "^0.20.0",
"meta3d-type": "^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"
}
}
87 changes: 87 additions & 0 deletions contributes/meta3d-action-add-cube/src/Main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { state as meta3dState, getContribute as getContributeMeta3D, api } from "meta3d-type"
import { actionContribute, service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
import { actionName, state, uiData } from "meta3d-action-add-cube-protocol"
import { eventName, inputData } from "meta3d-action-add-cube-protocol/src/EventType"
import { disposeGameObjectAndAllChildren } from "meta3d-dispose-utils/src/DisposeGameObjectUtils"
import { createCubeGameObject } from "meta3d-primitive-utils/src/CubeUtils"
import { service as gameViewRenderService } from "meta3d-editor-gameview-render-protocol/src/service/ServiceType"

let _createCube = (meta3dState: meta3dState, api: api) => {
let engineSceneService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).scene(meta3dState)

let diffuseColor: [number, number, number] = [Math.random(), Math.random(), Math.random()]
let localPosition: [number, number, number] = [Math.random() * 10 - 5, Math.random() * 10 - 5, 0]

return createCubeGameObject(meta3dState, engineSceneService, [localPosition, diffuseColor])
}

export let getContribute: getContributeMeta3D<actionContribute<uiData, state>> = (api) => {
return {
actionName: actionName,
init: (meta3dState) => {
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)

return new Promise((resolve, reject) => {
resolve(eventSourcingService.on<inputData>(meta3dState, eventName, 0, (meta3dState) => {
let data = _createCube(meta3dState, api)
meta3dState = data[0]
let addedGameObject = data[1]

let state = api.nullable.getExn(
api.action.getActionState<state>(meta3dState, actionName)
)

meta3dState = api.action.setActionState(meta3dState, actionName, {
...state,
addedGameObjects:
state.addedGameObjects.push(addedGameObject)
})

let editorWholeService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol"))
return Promise.resolve(api.nullable.getWithDefault(
api.nullable.map(
({ runOnlyOnce }) => {
return runOnlyOnce(meta3dState)
},
editorWholeService.getPluggablePackageService<gameViewRenderService>(meta3dState, "meta3d-editor-gameview-render-protocol")
),
meta3dState
))
}, (meta3dState) => {
let {
addedGameObjects,
} = api.nullable.getExn(api.action.getActionState<state>(meta3dState, actionName))

let disposedGameObject = api.nullable.getExn(addedGameObjects.last())

let state = api.nullable.getExn(api.action.getActionState<state>(meta3dState, actionName))

meta3dState = api.action.setActionState(meta3dState, actionName, {
...state,
addedGameObjects:
state.addedGameObjects.pop()
})

meta3dState = disposeGameObjectAndAllChildren(meta3dState, api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")), disposedGameObject)

return Promise.resolve(meta3dState)
}))
})
},
handler: (meta3dState, uiData) => {
return new Promise<meta3dState>((resolve, reject) => {
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)

resolve(eventSourcingService.addEvent<inputData>(meta3dState, {
name: eventName,
inputData: []
}))
})
},
createState: (meta3dState) => {
return {
addedGameObjects: api.immutable.createList(meta3dState),
}
}
}
}
24 changes: 24 additions & 0 deletions contributes/meta3d-action-add-cube/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-action-add-cube/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: {
}
};
19 changes: 19 additions & 0 deletions contributes/meta3d-action-clone-gameobject/.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-action-clone-gameobject/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()
})
});


36 changes: 36 additions & 0 deletions contributes/meta3d-action-clone-gameobject/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "meta3d-action-clone-gameobject",
"version": "0.20.1",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"repoLink": "",
"protocol": {
"name": "meta3d-action-clone-gameobject-protocol"
},
"license": "MIT",
"scripts": {
"watch": "tsc -w -noEmit",
"webpack": "webpack --config webpack.config.js",
"meta3d:publish_dev_auto": "yarn version --patch --no-git-tag-version && yarn meta3d:publish_dev",
"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-action-clone-gameobject-protocol": "^0.20.0",
"meta3d-action-select-scenetree-node-protocol": "^0.20.0",
"meta3d-editor-whole-protocol": "^0.20.0",
"meta3d-type": "^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"
}
}
Loading

0 comments on commit af85382

Please sign in to comment.