diff --git a/src/lib/map/light/MapLight.ts b/src/lib/map/light/MapLight.ts index 537ea1e..6707767 100644 --- a/src/lib/map/light/MapLight.ts +++ b/src/lib/map/light/MapLight.ts @@ -5,14 +5,9 @@ import { LightParamsRecord, LightRecord, } from '@wowserhq/format'; -import { - getDayNightTime, - interpolateColorTable, - interpolateNumericTable, - selectLightsForPosition, -} from './util.js'; +import { getDayNightTime, interpolateNumericTable, selectLightsForPosition } from './util.js'; import { SUN_PHI_TABLE, SUN_THETA_TABLE } from './table.js'; -import { LIGHT_FLOAT_BAND, LIGHT_INT_BAND, LIGHT_PARAM } from './const.js'; +import { LIGHT_PARAM } from './const.js'; import { getAreaLightsFromDb } from './db.js'; import { AreaLight, WeightedAreaLight } from './types.js'; import SceneLight from '../../light/SceneLight.js'; diff --git a/src/lib/map/light/util.ts b/src/lib/map/light/util.ts index f463f8c..d1f18c9 100644 --- a/src/lib/map/light/util.ts +++ b/src/lib/map/light/util.ts @@ -1,6 +1,6 @@ import * as THREE from 'three'; -import { AreaLight, WeightedAreaLight } from './types.js'; import { MAP_CORNER_X, MAP_CORNER_Y } from '@wowserhq/format'; +import { AreaLight, WeightedAreaLight } from './types.js'; const clamp = (value: number, min: number, max: number) => { return Math.min(Math.max(value, min), max); diff --git a/src/lib/map/loader/util.ts b/src/lib/map/loader/util.ts index 92d750a..3f4d848 100644 --- a/src/lib/map/loader/util.ts +++ b/src/lib/map/loader/util.ts @@ -1,12 +1,4 @@ -import { - MAP_CHUNK_FACE_COUNT_X, - MAP_CHUNK_FACE_COUNT_Y, - MAP_CHUNK_HEIGHT, - MAP_CHUNK_VERTEX_COUNT, - MAP_CHUNK_VERTEX_STEP_X, - MAP_CHUNK_VERTEX_STEP_Y, - MAP_CHUNK_WIDTH, -} from '@wowserhq/format'; +import { MAP_CHUNK_FACE_COUNT_X, MAP_CHUNK_FACE_COUNT_Y } from '@wowserhq/format'; import { DEFAULT_TERRAIN_VERTEX_BUFFER } from './const.js'; const isTerrainHole = (holes: number, x: number, y: number) => { @@ -17,55 +9,6 @@ const isTerrainHole = (holes: number, x: number, y: number) => { return (hole & holes) !== 0; }; -const createDefaultTerrainVertexBuffer = () => { - // Vertex coordinates for x-axis (forward axis) - const vxe = new Float32Array(MAP_CHUNK_FACE_COUNT_X + 1); - const vxo = new Float32Array(MAP_CHUNK_FACE_COUNT_X); - for (let i = 0; i < MAP_CHUNK_FACE_COUNT_X; i++) { - const vx = -(i * MAP_CHUNK_VERTEX_STEP_X); - vxe[i] = vx; - vxo[i] = vx - MAP_CHUNK_VERTEX_STEP_X / 2.0; - } - vxe[MAP_CHUNK_FACE_COUNT_X] = -MAP_CHUNK_HEIGHT; - - // Vertex coordinates for y-axis (right axis) - const vye = new Float32Array(MAP_CHUNK_FACE_COUNT_Y + 1); - const vyo = new Float32Array(MAP_CHUNK_FACE_COUNT_Y); - for (let i = 0; i < MAP_CHUNK_FACE_COUNT_Y; i++) { - const vy = -(i * MAP_CHUNK_VERTEX_STEP_Y); - vye[i] = vy; - vyo[i] = vy - MAP_CHUNK_VERTEX_STEP_Y / 2.0; - } - vye[MAP_CHUNK_FACE_COUNT_Y] = -MAP_CHUNK_WIDTH; - - const vertexBuffer = new ArrayBuffer(MAP_CHUNK_VERTEX_COUNT * 16); - const vertexBufferView = new DataView(vertexBuffer); - - let i = 0; - - for (let x = 0; x < MAP_CHUNK_FACE_COUNT_X + 1; x++) { - // Evens - for (let y = 0; y < MAP_CHUNK_FACE_COUNT_Y + 1; y++) { - vertexBufferView.setFloat32(i * 16 + 0, vxe[x], true); - vertexBufferView.setFloat32(i * 16 + 4, vye[y], true); - - i++; - } - - // Odds - if (x < MAP_CHUNK_FACE_COUNT_X) { - for (let y = 0; y < MAP_CHUNK_FACE_COUNT_Y; y++) { - vertexBufferView.setFloat32(i * 16 + 0, vxo[x], true); - vertexBufferView.setFloat32(i * 16 + 4, vyo[y], true); - - i++; - } - } - } - - return vertexBuffer; -}; - const createTerrainVertexBuffer = (vertexHeights: Float32Array, vertexNormals: Int8Array) => { // Copy the default vertex buffer (contains x and y coordinates) const data = DEFAULT_TERRAIN_VERTEX_BUFFER.slice(0); @@ -137,9 +80,4 @@ const mergeTerrainLayerSplats = (layerSplats: Uint8Array[], width: number, heigh return data; }; -export { - createDefaultTerrainVertexBuffer, - createTerrainIndexBuffer, - createTerrainVertexBuffer, - mergeTerrainLayerSplats, -}; +export { createTerrainIndexBuffer, createTerrainVertexBuffer, mergeTerrainLayerSplats };