Skip to content
Permalink
Browse files

feat(script): add draft; pass script example run test;

  • Loading branch information...
yyc-git committed Mar 24, 2019
1 parent ecc4bcd commit 52c76db71ce1f1a1278ba715b8ae4a6829ead6f6
Showing with 1,382 additions and 200 deletions.
  1. +1 −2 .cz-config.js
  2. +3 −0 config/no_worker/job/init_jobs.json
  3. +3 −0 config/no_worker/job/loop_jobs.json
  4. +3 −0 config/no_worker/pipeline/init_pipelines.json
  5. +3 −0 config/no_worker/pipeline/loop_pipelines.json
  6. +3 −0 examples/config/no_worker/job/init_jobs.json
  7. +3 −0 examples/config/no_worker/job/loop_jobs.json
  8. +3 −0 examples/config/no_worker/pipeline/init_pipelines.json
  9. +3 −0 examples/config/no_worker/pipeline/loop_pipelines.json
  10. 0 examples/cube/index.html
  11. 0 examples/load_model/index.html
  12. +232 −0 examples/script/index.html
  13. +287 −83 examples/wd.js
  14. +36 −8 src/Index.re
  15. +64 −0 src/api/GameObjectAPI.re
  16. +40 −0 src/api/script/ScriptAPI.re
  17. +48 −0 src/api/script/ScriptAttributeAPI.re
  18. +13 −0 src/api/script/ScriptEventFunctionAPI.re
  19. 0 src/asset/converter/utils/ConvertMeshUtils.re
  20. 0 src/asset/generate/node/AddNodeDataSystem.re
  21. +2 −0 src/job/no_worker/NoWorkerJobHandleSystem.re
  22. +9 −0 src/job/no_worker/init/InitScriptJob.re
  23. +1 −1 src/job/no_worker/loop/RenderIMGUIJob.re
  24. +9 −0 src/job/no_worker/loop/UpdateScriptJob.re
  25. +1 −1 src/job/worker/render/draw/RenderIMGUIRenderWorkerJob.re
  26. +1 −0 src/service/atom/ImmutableHashMapService.re
  27. +15 −9 src/service/record/main/camera_controller/arcball/AddArcballCameraControllerService.re
  28. +4 −2 src/service/record/main/camera_controller/arcball/GameObjectArcballCameraControllerService.re
  29. +3 −0 src/service/record/main/data/GameObjectType.re
  30. +29 −0 src/service/record/main/data/script/ScriptAttributeType.re
  31. +1 −0 src/service/record/main/data/script/ScriptEventFunctionType.re
  32. +1 −0 src/service/record/main/data/script/ScriptType.re
  33. +6 −0 src/service/record/main/gameObject/GetComponentGameObjectService.re
  34. +4 −0 src/service/record/main/gameObject/RecordGameObjectService.re
  35. +0 −2 src/service/record/main/material/basic/AddBasicMaterialService.re
  36. +0 −2 src/service/record/main/material/light/AddLightMaterialService.re
  37. +2 −47 src/service/state/main/api/RecordAPIMainService.re
  38. +55 −0 src/service/state/main/api/RecordIMGUIAPIMainService.re
  39. +17 −0 src/service/state/main/api/RecordScriptAPIMainService.re
  40. +1 −1 src/service/state/main/camera_controller/arcball/DisposeArcballCameraControllerMainService.re
  41. +1 −1 src/service/state/main/camera_controller/arcball/UpdateArcballCameraControllerMainService.re
  42. +49 −3 src/service/state/main/data/StateDataMainType.re
  43. +15 −0 src/service/state/main/gameObject/AddComponentGameObjectMainService.re
  44. +11 −0 src/service/state/main/gameObject/InitGameObjectMainService.re
  45. +0 −2 src/service/state/main/geometry/CreateGeometryMainService.re
  46. +14 −0 src/service/state/main/script/AddScriptMainService.re
  47. +17 −0 src/service/state/main/script/CreateScriptMainService.re
  48. +9 −0 src/service/state/main/script/GameObjectScriptMainService.re
  49. +80 −0 src/service/state/main/script/OperateScriptAttributeDataMainService.re
  50. +140 −0 src/service/state/main/script/OperateScriptDataMainService.re
  51. +70 −0 src/service/state/main/script/OperateScriptEventFunctionDataMainService.re
  52. +30 −0 src/service/state/main/script/RecordScriptMainService.re
  53. +1 −0 src/service/state/main/state/CreateStateMainService.re
  54. +3 −3 src/service/state/render_worker/api/RecordAPIRenderWorkerService.re
  55. +1 −1 src/service/state/render_worker/data/StateDataRenderWorkerType.re
  56. +5 −5 test/integration/no_worker/asset/assemble/assembleWDBFromGLB_test.re
  57. +4 −4 test/integration/no_worker/asset/generate/generateSceneGraphByGameObject_test.re
  58. +4 −2 test/integration/no_worker/job/loop/disposeJob_test.re
  59. +12 −12 test/integration/no_worker/job/loop/renderIMGUIJob_test.re
  60. +7 −7 test/integration/worker/job/render_worker/imgui/renderIMGUIRenderWorkerJob_test.re
  61. 0 test/tool/service/atom/FloatTool.re
  62. +1 −1 test/tool/service/imgui/IMGUITool.re
  63. +2 −1 test/unit/ecs/gameObject/GameObject_test.re
  64. 0 test/unit/service/atom/ArrayService_test.re
@@ -15,8 +15,7 @@ module.exports = {
],

scopes: [
// { name: "exampleScope" },
// { name: "changeMe" }
{ name: "script" },
{ name: "state" },
{ name: "api" },
{ name: "data-json" },
@@ -43,5 +43,8 @@
},
{
"name": "init_imgui"
},
{
"name": "init_script"
}
]
@@ -8,6 +8,9 @@
{
"name": "update_camera"
},
{
"name": "update_script"
},
{
"name": "get_camera_data"
},
@@ -46,6 +46,9 @@
},
{
"name": "init_imgui"
},
{
"name": "init_script"
}
]
}
@@ -17,6 +17,9 @@
{
"name": "update_camera"
},
{
"name": "update_script"
},
{
"name": "get_camera_data"
},
@@ -43,5 +43,8 @@
},
{
"name": "init_imgui"
},
{
"name": "init_script"
}
]
@@ -8,6 +8,9 @@
{
"name": "update_camera"
},
{
"name": "update_script"
},
{
"name": "get_camera_data"
},
@@ -46,6 +46,9 @@
},
{
"name": "init_imgui"
},
{
"name": "init_script"
}
]
}
@@ -17,6 +17,9 @@
{
"name": "update_camera"
},
{
"name": "update_script"
},
{
"name": "get_camera_data"
},
0 examples/cube/index.html 100644 → 100755
No changes.
0 examples/load_model/index.html 100644 → 100755
No changes.
@@ -0,0 +1,232 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>cube</title>
</head>

<body>
<script src="../../test/e2e/js/AssetTool.js"></script>
<script src="../../test/e2e/js/LightBoxesTool.js"></script>
<script src="../../test/e2e/js/PositionTool.js"></script>
<script src="../../test/e2e/js/LightTool.js"></script>
<script src="../../test/e2e/js/CameraTool.js"></script>
<script src="../../test/e2e/js/LightMaterialTool.js"></script>
<script src="../wd.js"></script>

<script>
window.onload = function () {
return AssetTool.loadConfig(["../config/setting.json", "../config/"], null, function () {
return initSample(wd.unsafeGetState());
});
function _init1(script, api, state) {
var scriptAttribute2 =
api.unsafeGetScriptAttribute(
script,
"scriptAttribute2",
state
);
var a = api.unsafeGetScriptAttributeFieldValue(
"a",
scriptAttribute2
);
console.log("init->a: ", a)
return state
};
function _update1(script, api, state) {
var scriptAttribute1 =
api.unsafeGetScriptAttribute(
script,
"scriptAttribute1",
state
);
var a = api.unsafeGetScriptAttributeFieldValue(
"a",
scriptAttribute1
);
console.log("a: ", a)
var state =
api.setScriptAttributeFieldValue(
script,
"scriptAttribute1",
"a",
a + 1,
state
);
return state
};
function _addScript(box, state) {
var [state, scriptComponent] = wd.createScript(state);
// var [state, scriptEventFunctionData1] =
var scriptEventFunctionData1 =
wd.createScriptEventFunctionData(
// "scriptEventFunctionData1"
{
"init": (script, api, state) => {
return _init1(script, api, state);
},
"update": (script, api, state) => {
return _update1(script, api, state);
}
}
);
// var scriptEventFunctionData1 =
// wd.addScriptEventFunctionData(
// "update",
// (script, api, state) => {
// return _update1(script, api, state);
// },
// scriptEventFunctionData1
// );
// var [state, scriptAttribute1] =
var scriptAttribute1 =
wd.createScriptAttribute(
);
var scriptAttribute1 =
wd.addScriptAttributeField(
"a", {
"type": "int",
"defaultValue": 0
},
scriptAttribute1
);
var scriptAttribute1 =
wd.addScriptAttributeField(
"b", {
"type": "float",
"defaultValue": 0.1
},
scriptAttribute1
);
var scriptAttribute2 =
wd.createScriptAttribute(
);
var scriptAttribute2 =
wd.addScriptAttributeField(
"a", {
"type": "float",
"defaultValue": 10.5
},
scriptAttribute2
);
var state =
wd.addScriptEventFunction(
scriptComponent,
"scriptEventFunctionData1",
scriptEventFunctionData1,
state
);
var state =
wd.addScriptAttribute(
scriptComponent,
"scriptAttribute1",
scriptAttribute1,
state
);
var state =
wd.addScriptAttribute(
scriptComponent,
"scriptAttribute2",
scriptAttribute2,
state
);
var state =
wd.addGameObjectScriptComponent(
box, scriptComponent, state
);
return state;
};
function initSample(state) {
var [state, box] = LightBoxesTool.createBox(state);
var state = wd.setAmbientLightColor([0.2, 0.2, 0.2], state);
var [state, directionLightGameObject] = LightTool.createDirectionLight(state);
var transform = wd.unsafeGetGameObjectTransformComponent(directionLightGameObject, state);
var state = wd.setTransformLocalEulerAngles(transform, [0, 180, 0], state);
var [state, cameraGameObject] = LightBoxesTool.createCamera(state);
var [state, cameraController] = wd.createArcballCameraController(state);
var state =
wd.setArcballCameraControllerDistance(cameraController, 50, state);
var state =
wd.setArcballCameraControllerWheelSpeed(cameraController, 1, state);
var state = wd.addGameObjectArcballCameraControllerComponent(cameraGameObject, cameraController, state);
var state =
wd.bindArcballCameraControllerEvent(
cameraController, state
);
var state = _addScript(box, state);
wd.startDirector(state);
}
};
</script>
</body>

</html>

0 comments on commit 52c76db

Please sign in to comment.
You can’t perform that action at this time.