Add wireframe mode
This commit is contained in:
15
src/main.ts
15
src/main.ts
@@ -155,6 +155,8 @@ var curRotY = Config.CAMERA_DEFAULT_ROT_Y;
|
||||
var cameraMode: 'orbital' | 'fps' = 'fps';
|
||||
var moveSpeed = 0.15;
|
||||
var fastMoveSpeed = 0.4;
|
||||
/** Rendering modes */
|
||||
var wireframeMode = false;
|
||||
function drawScene() {
|
||||
fps++;
|
||||
let now = new Date();
|
||||
@@ -280,7 +282,12 @@ function drawScene() {
|
||||
//gl.uniform1f(uTime_loc, timeSpent);
|
||||
let displacementMap_loc = gl.getUniformLocation(<WebGLProgram>defaultProgram, "displace_map");
|
||||
gl.uniform1i(displacementMap_loc, 0); //Get texture from slot 0
|
||||
oceanGrid.draw(gl);
|
||||
|
||||
// Draw ocean grid with wireframe mode if enabled
|
||||
if (wireframeMode) {
|
||||
gl.lineWidth(1.0);
|
||||
}
|
||||
oceanGrid.draw(gl, wireframeMode);
|
||||
}
|
||||
requestAnimationFrame(drawScene);
|
||||
}
|
||||
@@ -429,6 +436,12 @@ function main() {
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
||||
// Wireframe toggle with F key
|
||||
if (evt.key === 'f' || evt.key === 'F') {
|
||||
wireframeMode = !wireframeMode;
|
||||
console.log(`Wireframe mode: ${wireframeMode ? 'ON' : 'OFF'}`);
|
||||
}
|
||||
|
||||
// Handle orbital camera keyboard input
|
||||
if (cameraMode === 'orbital') {
|
||||
handleKeyboardInput();
|
||||
|
||||
Reference in New Issue
Block a user