// Plutus Three.js Environment 14: polytrack_3d style (track on water, Sky, Water shader).

import * as THREE from 'three';
import { createScene, setupSkyEnvironment } from './createScene.js';
import { createLighting } from './createLighting.js';
import { createWater, createTrack } from './map.js';
import { loadTexture } from './loadAssets.js';

export { loadTexture, loadGlb } from './loadAssets.js';
export { createScene, setupSkyEnvironment } from './createScene.js';
export { createLighting } from './createLighting.js';
export { createWater, createTrack } from './map.js';

export async function createEnvironment(baseUrl = '/') {
  const base = baseUrl.replace(/\/$/, '') + '/';
  const { scene, sky, sun } = createScene();
  createLighting(scene);

  const waterNormals = await loadTexture(base + 'textures/waternormals.jpg');
  const water = createWater(scene, sun, waterNormals);

  await createTrack(scene, base);

  return { scene, sky, sun, water };
}
