项目作者: karimbeyrouti

项目描述 :
Structure ThreeJS with Ember using templates
高级语言: JavaScript
项目地址: git://github.com/karimbeyrouti/ember-three-ui.git
创建时间: 2019-12-26T14:45:37Z
项目社区:https://github.com/karimbeyrouti/ember-three-ui

开源协议:MIT License

下载


ember-three-ui

This addon enables three.js scene hierarchy to be composed in templates.
It currently support a small subset of the functionality provided by three.js, there
is lots to add and improve. However, hopefully this is a solid foundation for
future development.

This is the handlebars template for a simple scene:

  1. <main>
  2. <EmberThree
  3. @id='cube-demo'
  4. @rendererParams={{this.rendererParams}}
  5. as |emberThree|
  6. >
  7. <EmberThree::Cameras::PerspectiveCamera
  8. @position={{this.cameraPosition}}
  9. ></EmberThree::Cameras::PerspectiveCamera>
  10. <EmberThree::Objects::Mesh
  11. @rotation={{this.rotation}}
  12. @parent={{emberThree.scene}}
  13. @material={{this.material}}
  14. @geometry={{this.geometry}}
  15. ></EmberThree::Objects::Mesh>
  16. </EmberThree>
  17. </main>

and the corresponding JavaScript:

  1. import THREE from 'three';
  2. import { inject as service } from '@ember/service';
  3. import Component from '@glimmer/component';
  4. import { tracked } from '@glimmer/tracking';
  5. export default class DemoComponent extends Component {
  6. @service('ember-three/scene-manager') sceneManager;
  7. @tracked rotation = new THREE.Vector3();
  8. cameraPosition = new THREE.Vector3(0, 0, 5);
  9. geometry = new THREE.BoxGeometry(1, 1, 1);
  10. material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
  11. constructor() {
  12. super(...arguments);
  13. let emberThree = this.sceneManager.get(this.sceneId);
  14. emberThree.addRafCallback(this.render, this);
  15. }
  16. render() {
  17. this.rotation.x += 0.01;
  18. this.rotation.y += 0.01;
  19. this.rotation = this.rotation;
  20. }
  21. }

this is what you should see.

Compatibility

  • Ember.js v2.18 or above
  • Ember CLI v2.13 or above
  • Node.js v8 or above

Installation

  1. ember install ember-three-ui

Demo

https://karimbeyrouti.github.io/ember-three-ui/

Usage

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.