MeshGrid.re.ts 530 B

12345678910111213141516171819202122232425262728
  1. import * as RE from "rogue-engine";
  2. import { Object3D } from "three";
  3. export default class MeshGrid extends RE.Component {
  4. @RE.props.list.prefab() allModels: RE.Prefab[] = [];
  5. awake() {
  6. let x = 0;
  7. let z = 0;
  8. if (this.allModels.length > 0) {
  9. this.allModels.forEach(prefab => {
  10. let model = prefab.instantiate(RE.App.currentScene);
  11. model.position.set(x + 0.5 * x, 0, z + 0.5 * z);
  12. x++;
  13. if (x == 6) {
  14. x = 0;
  15. z++;
  16. }
  17. });
  18. }
  19. }
  20. start() {}
  21. update() {}
  22. }
  23. RE.registerComponent(MeshGrid);