Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (scene: Scene) {
super(scene);
// Extension
this.alwaysApply = true;
// Spector
this.spector = new Spector();
}
cameraControls.rotateSpeed = 0.3;
cameraControls.zoomSpeed = 1.0;
cameraControls.panSpeed = 2.0;
function setSize(width, height) {
canvas.width = width;
canvas.height = height;
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
setSize(canvas.clientWidth, canvas.clientHeight);
window.addEventListener('resize', () => setSize(canvas.clientWidth, canvas.clientHeight));
if (DEBUG) {
const spector = new Spector();
spector.displayUI();
}
// Creates a render loop that is wrapped with camera update and stats logging
export function makeRenderLoop(render) {
return function tick() {
cameraControls.update();
stats.begin();
render();
stats.end();
if (!ABORTED) {
requestAnimationFrame(tick)
}
}
}
async function raytraceApp({
scene,
camera,
shaderSampleCount,
maxSampleCount,
realTime,
debug
}) {
let store = getStore();
if(debug) {
let spectorGlDebug = new spector.Spector();
spectorGlDebug.displayUI();
}
const materialData = scene.materials.getMaterialData();
const sceneTextures = scene.textures.getTextures();
const {bvhData, geometryData} = buildSceneBvh(scene);
// https://webglfundamentals.org/webgl/lessons/webgl-data-textures.html
const alignment = 1;
gl.pixelStorei(gl.UNPACK_ALIGNMENT, alignment);
// raytrace framebuffer
let traceFboColorTarget = glApp.createTexture2D(glApp.width, glApp.height, {
type: gl.FLOAT,
internalFormat: gl.RGBA32F,
format: gl.RGBA