main.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.OrbitControls({
  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._entities['_controls'] = new controls.ShipControls({
  34. // camera: this._graphics.Camera,
  35. // scene: this._graphics.Scene,
  36. // domElement: this._graphics._threejs.domElement,
  37. // gui: this._gui,
  38. // guiParams: this._guiParams,
  39. // });
  40. this._entities['_controls'] = new controls.FPSControls({
  41. camera: this._graphics.Camera,
  42. scene: this._graphics.Scene,
  43. domElement: this._graphics._threejs.domElement,
  44. gui: this._gui,
  45. guiParams: this._guiParams,
  46. });
  47. // this._focusMesh = new THREE.Mesh(
  48. // new THREE.SphereGeometry(25, 32, 32),
  49. // new THREE.MeshBasicMaterial({
  50. // color: 0xFFFFFF
  51. // }));
  52. // this._focusMesh.castShadow = true;
  53. // this._focusMesh.receiveShadow = true;
  54. //this._graphics.Scene.add(this._focusMesh);
  55. this._totalTime = 0;
  56. this._LoadBackground();
  57. }
  58. _CreateGUI() {
  59. this._guiParams = {
  60. general: {
  61. },
  62. };
  63. this._gui = new GUI();
  64. const generalRollup = this._gui.addFolder('General');
  65. this._gui.close();
  66. }
  67. _LoadBackground() {
  68. this._graphics.Scene.background = new THREE.Color(0x000000);
  69. const loader = new THREE.CubeTextureLoader();
  70. const texture = loader.load([
  71. './resources/space-posx.jpg',
  72. './resources/space-negx.jpg',
  73. './resources/space-posy.jpg',
  74. './resources/space-negy.jpg',
  75. './resources/space-posz.jpg',
  76. './resources/space-negz.jpg',
  77. ]);
  78. this._graphics._scene.background = texture;
  79. }
  80. _OnStep(timeInSeconds) {
  81. }
  82. }
  83. function _Main() {
  84. _APP = new ProceduralTerrain_Demo();
  85. }
  86. _Main();