Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/mapviewer/webgl/WebGLMapViewerRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {

loadObjs: boolean = true;
loadNpcs: boolean = true;
loadLocs: boolean = true;

// State
lastClientTick: number = 0;
Expand Down Expand Up @@ -618,6 +619,12 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
this.setLoadNpcs(v);
},
},
Locs: {
value: this.loadLocs,
onChange: (v: boolean) => {
this.setLoadLocs(v);
},
},
},
{ collapsed: true },
),
Expand All @@ -635,6 +642,7 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
maxLevel: this.maxLevel,
loadObjs: this.loadObjs,
loadNpcs: this.loadNpcs,
loadLocs: this.loadLocs,
smoothTerrain: this.smoothTerrain,
minimizeDrawCalls: !this.hasMultiDraw,
loadedTextureIds: this.loadedTextureIds,
Expand Down Expand Up @@ -699,6 +707,7 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
mapData.maxLevel === this.maxLevel &&
mapData.loadObjs === this.loadObjs &&
mapData.loadNpcs === this.loadNpcs &&
mapData.loadLocs === this.loadLocs &&
mapData.smoothTerrain === this.smoothTerrain
);
}
Expand Down Expand Up @@ -758,6 +767,14 @@ export class WebGLMapViewerRenderer extends MapViewerRenderer<WebGLMapSquare> {
}
}

setLoadLocs(enabled: boolean): void {
const updated = this.loadLocs !== enabled;
this.loadLocs = enabled;
if (updated) {
this.clearMaps();
}
}

override onResize(width: number, height: number): void {
this.app.resize(width, height);
}
Expand Down
1 change: 1 addition & 0 deletions src/mapviewer/webgl/loader/SdMapData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type SdMapData = {
maxLevel: number;
loadObjs: boolean;
loadNpcs: boolean;
loadLocs: boolean;

smoothTerrain: boolean;

Expand Down
14 changes: 10 additions & 4 deletions src/mapviewer/webgl/loader/SdMapDataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { createNpcDatas } from "../npc/NpcData";
import { NpcSpawnGroup } from "../npc/NpcSpawnGroup";
import { SdMapData } from "./SdMapData";
import { SdMapLoaderInput } from "./SdMapLoaderInput";
import { LocAnimatedData } from "../loc/LocAnimatedData";

function loadHeightMapTextureData(scene: Scene): Int16Array {
const heightMapTextureData = new Int16Array(Scene.MAX_LEVELS * scene.sizeX * scene.sizeY);
Expand Down Expand Up @@ -557,6 +558,7 @@ export class SdMapDataLoader implements RenderDataLoader<SdMapLoaderInput, SdMap
maxLevel,
loadObjs,
loadNpcs,
loadLocs,
smoothTerrain,
minimizeDrawCalls,
loadedTextureIds,
Expand Down Expand Up @@ -614,11 +616,14 @@ export class SdMapDataLoader implements RenderDataLoader<SdMapLoaderInput, SdMap
createObjSceneModels(objModelLoader, sceneModels, scene, borderSize, objSpawns);
}

addSceneModels(this.modelHashBuf!, textureLoader, sceneBuf, sceneModels, minimizeDrawCalls);
let locsAnimated: LocAnimatedData[] = [];
if (loadLocs) {
addSceneModels(this.modelHashBuf!, textureLoader, sceneBuf, sceneModels, minimizeDrawCalls);

// Animated locs
const locsAnimated = sceneBuf.addLocAnimatedGroups(locAnimatedGroups);
console.log(`animated locs: ${locsAnimated.length}`);
// Animated locs
locsAnimated = sceneBuf.addLocAnimatedGroups(locAnimatedGroups);
console.log(`animated locs: ${locsAnimated.length}`);
}

// Npcs

Expand Down Expand Up @@ -784,6 +789,7 @@ export class SdMapDataLoader implements RenderDataLoader<SdMapLoaderInput, SdMap
maxLevel,
loadObjs,
loadNpcs,
loadLocs,

smoothTerrain,

Expand Down
1 change: 1 addition & 0 deletions src/mapviewer/webgl/loader/SdMapLoaderInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type SdMapLoaderInput = {
maxLevel: number;
loadObjs: boolean;
loadNpcs: boolean;
loadLocs: boolean;

smoothTerrain: boolean;

Expand Down