main.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import * as THREE from 'https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js';
  2. import {GUI} from 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/libs/dat.gui.module.js';
  3. import {controls} from './controls.js';
  4. import {game} from './game.js';
  5. import {terrain} from './terrain.js';
  6. let _APP = null;
  7. class ProceduralTerrain_Demo extends game.Game {
  8. constructor() {
  9. super();
  10. }
  11. _OnInitialize() {
  12. this._CreateGUI();
  13. this._userCamera = new THREE.Object3D();
  14. this._userCamera.position.set(4100, 0, 0);
  15. this._graphics.Camera.position.set(3853, -609, -1509);
  16. this._graphics.Camera.quaternion.set(0.403, 0.59, -0.549, 0.432);
  17. this._graphics.Camera.position.set(1412, -1674, -3848);
  18. this._graphics.Camera.quaternion.set(0.1004, 0.7757, -0.6097, 0.1278);
  19. this._entities['_terrain'] = new terrain.TerrainChunkManager({
  20. camera: this._graphics.Camera,
  21. scene: this._graphics.Scene,
  22. gui: this._gui,
  23. guiParams: this._guiParams,
  24. game: this
  25. });
  26. this._entities['_controls'] = new controls.FPSControls({
  27. camera: this._graphics.Camera,
  28. scene: this._graphics.Scene,
  29. domElement: this._graphics._threejs.domElement,
  30. gui: this._gui,
  31. guiParams: this._guiParams,
  32. });
  33. this._totalTime = 0;
  34. this._LoadBackground();
  35. }
  36. _CreateGUI() {
  37. this._guiParams = {
  38. general: {
  39. },
  40. };
  41. this._gui = new GUI();
  42. const generalRollup = this._gui.addFolder('General');
  43. this._gui.close();
  44. }
  45. _LoadBackground() {
  46. this._graphics.Scene.background = new THREE.Color(0x000000);
  47. const loader = new THREE.CubeTextureLoader();
  48. const texture = loader.load([
  49. './resources/space-posx.jpg',
  50. './resources/space-negx.jpg',
  51. './resources/space-posy.jpg',
  52. './resources/space-negy.jpg',
  53. './resources/space-posz.jpg',
  54. './resources/space-negz.jpg',
  55. ]);
  56. this._graphics._scene.background = texture;
  57. }
  58. _OnStep(timeInSeconds) {
  59. }
  60. }
  61. function _Main() {
  62. _APP = new ProceduralTerrain_Demo();
  63. }
  64. _Main();