@giro3d/giro3d
Version:
A JS/WebGL framework for 3D geospatial data visualization
56 lines (54 loc) • 2.03 kB
JavaScript
/*
* Copyright (c) 2015-2018, IGN France.
* Copyright (c) 2018-2026, Giro3D team.
* SPDX-License-Identifier: MIT
*/
import Panel from './Panel';
class WebGLRendererInspector extends Panel {
/**
* @param gui - The GUI.
* @param instance - The Giro3D instance.
*/
constructor(gui, instance) {
super(gui, instance, 'WebGLRenderer');
this.renderer = this.instance.renderer;
this.addController(this.renderer, 'localClippingEnabled').onChange(() => this.notify());
this._addCapabilities(this.renderer, this.gui.addFolder('Capabilities'));
const loseContextExt = this.renderer.getContext().getExtension('WEBGL_lose_context');
if (loseContextExt) {
this.addController(loseContextExt, 'loseContext').name('Lose context');
this.addController(loseContextExt, 'restoreContext').name('Restore context');
}
}
/**
* @param renderer - The renderer
* @param rendererPanel - The GUI
*/
_addCapabilities(renderer, rendererPanel) {
const cap = renderer.capabilities;
const debug = renderer.debug;
const ctrls = this._controllers;
function add(ctrl, prop, name) {
ctrls.push(rendererPanel.add(ctrl, prop).name(name));
}
add(cap, 'isWebGL2', 'WebGL 2');
add(cap, 'maxTextures', 'Max texture units');
add(cap, 'maxTextureSize', 'Max texture size');
add(cap, 'precision', 'Precision');
add(cap, 'maxFragmentUniforms', 'Max fragment shader uniforms');
add(cap, 'logarithmicDepthBuffer', 'Logarithmic depth buffer');
add(cap, 'maxAttributes', 'Max shader attributes');
add(debug, 'checkShaderErrors', 'Check shader errors');
const extensionPanel = rendererPanel.addFolder('Extensions');
extensionPanel.close();
const supported = renderer.getContext().getSupportedExtensions();
if (supported) {
const suppObj = {};
for (const supp of supported) {
suppObj[supp] = true;
ctrls.push(extensionPanel.add(suppObj, supp).name(supp));
}
}
}
}
export default WebGLRendererInspector;