[关闭]
@yangyc 2019-03-10T10:03:24.000000Z 字数 3304 阅读 503

在此处输入标题

未分类


Wonder.js

Wonder.js is a Functional, High performance 3D WebGL Engine.

Showcases

showcase1

Design

Feature

Usage

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>cube</title>
  6. </head>
  7. <body>
  8. <script src="https://github.com/Wonder-Technology/Wonder.js/tree/master/examples/wd.js"></script>
  9. <script>
  10. window.onload = function () {
  11. return wd.loadConfig(["https://github.com/Wonder-Technology/Wonder.js/tree/master/examples/config/setting.json", "https://github.com/Wonder-Technology/Wonder.js/tree/master/examples/config/"]).forEach(function (state) {
  12. }).then(function () {
  13. return initSample(wd.unsafeGetState());
  14. })
  15. function _createBox(state) {
  16. var [state, material] = wd.createLightMaterial(state);
  17. var state = wd.setLightMaterialDiffuseColor(material, [0.0, 0.5, 0.2], state);
  18. var state = wd.setLightMaterialSpecularColor(material, [0.3, 0.1, 0.6], state);
  19. var [state, meshRenderer] = wd.createMeshRenderer(state);
  20. var [state, gameObject] = wd.createGameObject(state);
  21. var state = wd.addGameObjectLightMaterialComponent(gameObject, material, state);
  22. var state = wd.addGameObjectMeshRendererComponent(gameObject, meshRenderer, state);
  23. var [state, geometry] = wd.createBoxGeometry(state);
  24. var state = wd.addGameObjectGeometryComponent(gameObject, geometry, state);
  25. return [state, gameObject];
  26. };
  27. function _createCamera(state) {
  28. var [state, basicCameraView] = wd.createBasicCameraView(state);
  29. var state =
  30. wd.activeBasicCameraView(
  31. basicCameraView, state
  32. );
  33. var [state, perspectiveCameraProjection] = wd.createPerspectiveCameraProjection(state);
  34. var state = wd.setPerspectiveCameraProjectionNear(perspectiveCameraProjection, 0.1, state);
  35. var state = wd.setPerspectiveCameraProjectionFar(perspectiveCameraProjection, 2000, state);
  36. var state = wd.setPerspectiveCameraProjectionFovy(perspectiveCameraProjection, 60, state);
  37. var [state, gameObject] = wd.createGameObject(state);
  38. var state = wd.addGameObjectBasicCameraViewComponent(gameObject, basicCameraView, state);
  39. var state = wd.addGameObjectPerspectiveCameraProjectionComponent(gameObject, perspectiveCameraProjection, state);
  40. var transform = wd.unsafeGetGameObjectTransformComponent(gameObject, state);
  41. var state = wd.setTransformLocalPosition(transform, [0, 10, 50], state);
  42. return [state, gameObject];
  43. };
  44. function _createDirectionLight(state) {
  45. var [state, light] = wd.createDirectionLight(state);
  46. var state = wd.setDirectionLightColor(light, [1.0, 0.0, 0.0], state);
  47. var [state, gameObject] = wd.createGameObject(state);
  48. var transform = wd.unsafeGetGameObjectTransformComponent(gameObject, state);
  49. var state = wd.setTransformLocalEulerAngles(transform, [0, 180, 0], state);
  50. var state = wd.addGameObjectDirectionLightComponent(gameObject, light, state);
  51. return [state, gameObject];
  52. };
  53. function initSample(state) {
  54. var [state, box] = _createBox(state);
  55. var state = wd.setAmbientLightColor([0.2, 0.2, 0.2], state);
  56. var [state, directionLightGameObject] = _createDirectionLight(state);
  57. var [state, cameraGameObject] = _createCamera(state);
  58. wd.startDirector(state);
  59. }
  60. };
  61. </script>
  62. </body>
  63. </html>

How to build

Useful links

What's this?

Art

Design is Art

Code is Art

Everything is Art

Extend Everything

High Performance

Support All Web Platform

PC

Chrome

Firefox

Document

Contributing

Join us, We can create the amazing 3D world together!

Feature

Tool

Usage

How to build

How to test

License

MIT Licence

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注