Skip to content

Commit

Permalink
feat(uicontrol): add Asset
Browse files Browse the repository at this point in the history
separate header, body: header = multiple Image Buttons
add Image Button ui control
add new Input
update export,import action
update drag to Scene View

action protocol remove type elementState
action->createState get meta3dState
  • Loading branch information
yyc-git committed Nov 26, 2023
1 parent 8d9119d commit 7bb76c8
Show file tree
Hide file tree
Showing 238 changed files with 3,825 additions and 1,672 deletions.
19 changes: 19 additions & 0 deletions contributes/meta3d-action-add-glb-to-scene/.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-glb-to-scene/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-action-add-glb-to-scene/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "meta3d-action-add-glb-to-scene",
"version": "0.20.1",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"repoLink": "",
"protocol": {
"name": "meta3d-action-drop-glb-to-sceneview-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-drop-glb-to-sceneview-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"
}
}
114 changes: 114 additions & 0 deletions contributes/meta3d-action-add-glb-to-scene/src/Main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
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 } from "meta3d-action-drop-glb-to-sceneview-protocol"
import { eventName, inputData } from "meta3d-action-drop-glb-to-sceneview-protocol/src/EventType"
// import { service as eventSourcingService } from "meta3d-event-sourcing-protocol/src/service/ServiceType"
// import { service as converterSceneViewService } from "meta3d-scenegraph-converter-three-sceneview-protocol/src/service/ServiceType"
// import { service as converterGameViewService } from "meta3d-scenegraph-converter-three-gameview-protocol/src/service/ServiceType"
// import { service as runEngineGameViewService } from "meta3d-editor-run-engine-gameview-protocol/src/service/ServiceType"
// import { service as assetService } from "meta3d-asset-protocol/src/service/ServiceType"
// 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 { 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"
import { uiControlName as assetUIControlName } from "meta3d-ui-control-asset-protocol"
import { dropAssetFileUIData } from "meta3d-ui-control-scene-view-protocol"
// // import { GLTF } from "meta3d-load-scene-utils/src/three/GLTFLoader"
import { service as gameViewRenderService } from "meta3d-editor-gameview-render-protocol/src/service/ServiceType"

export let getContribute: getContributeMeta3D<actionContribute<dropAssetFileUIData, 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, { fromUIControlName, data }) => {
if (fromUIControlName !== assetUIControlName) {
return Promise.resolve(meta3dState)
}

let glbId = data

let editorWholeService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol"))
let { getAllGLBAssets, loadGlb } = editorWholeService.asset(meta3dState)

let allGLBAssets = getAllGLBAssets(meta3dState)

if (allGLBAssets.length == 0) {
return Promise.resolve(meta3dState)
}

let [_glbId, _glbName, glb] = api.nullable.getExn(allGLBAssets.find((asset) => {
return asset[0] == glbId
}))

return loadGlb(meta3dState, glb)
.then((gltf) => {
let data = editorWholeService.addScene(meta3dState, gltf.scene)
meta3dState = data[0]
let importedGameObject = data[1]

let state = api.nullable.getExn(api.action.getActionState<state>(meta3dState, actionName))
meta3dState = api.action.setActionState(meta3dState, actionName, {
...state,
importedGameObjects:
state.importedGameObjects.push(importedGameObject)
})

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

if (api.nullable.isNullable(importedGameObjects.last())) {
return Promise.resolve(meta3dState)
}

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

let state = api.nullable.getExn(api.action.getActionState<state>(meta3dState, actionName))
meta3dState = api.action.setActionState(meta3dState, actionName, {
...state,
importedGameObjects: state.importedGameObjects.pop()
})

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

meta3dState = disposeGameObjectAndAllChildren(meta3dState, editorWholeService, 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: [uiData]
}))
})
},
createState: (meta3dState) => {
return {
importedGameObjects: api.immutable.createList(meta3dState),
}
}
}
}
24 changes: 24 additions & 0 deletions contributes/meta3d-action-add-glb-to-scene/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-glb-to-scene/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-load-glb/.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-load-glb/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-action-load-glb/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "meta3d-action-load-glb",
"version": "0.20.2",
"publisher": "0xf63e1991A343814EdE505D7cfC368615EAe75307",
"repoLink": "",
"protocol": {
"name": "meta3d-action-load-glb-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-load-glb-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 7bb76c8

Please sign in to comment.