fixed setOrthographicProjection

This commit is contained in:
mige 2025-08-12 15:11:56 +04:00
parent 0212461717
commit a6452745a3
3 changed files with 13 additions and 12 deletions

View File

@ -792,3 +792,5 @@ class MyScene extends RenderNode {
}
renderer.addNodes([new scene.Axes(), new MyScene()]);
window.renderer = renderer;

View File

@ -1250,9 +1250,8 @@ class Renderer {
}
}
protected _readDepthBuffer() {
this.depthFramebuffer!.readPixelBuffersAsync();
//console.log("read depth");
protected _readDepthBuffer(callback?: () => void) {
this.depthFramebuffer!.readPixelBuffersAsync(callback);
}
protected _readPickingBuffer_webgl1() {
@ -1390,12 +1389,14 @@ class Renderer {
public setOrthographicProjection(isOrtho: boolean) {
if (isOrtho !== this.activeCamera.isOrthographic) {
let dist = this.getDepthMinDistance();
if (dist && isOrtho) {
this.activeCamera.focusDistance = dist;
}
this.activeCamera.isOrthographic = isOrtho;
this.events.dispatch(this.events.projchanged, this.activeCamera);
this._readDepthBuffer(() => {
let dist = this.getDepthMinDistance();
if (dist && isOrtho) {
this.activeCamera.focusDistance = dist;
}
this.activeCamera.isOrthographic = isOrtho;
this.events.dispatch(this.events.projchanged, this.activeCamera);
});
}
}

View File

@ -264,17 +264,15 @@ export class Framebuffer extends BaseFramebuffer {
clientWaitAsync(gl, sync, 0).then(() => {
this._skipFrame = false;
gl.deleteSync(sync);
for (let i = 0; i < pb.length; i++) {
let pbi = pb[i];
if (pbi.data) {
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, pbi.buffer);
gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, pbi.data!);
callback && callback(this);
}
}
gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null);
callback && callback(this);
});
}