Skip to content

Commit

Permalink
fix crash, do async
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Feb 27, 2024
1 parent ac07b5c commit f48728d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions prismarine-viewer/viewer/lib/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ export class Viewer {
this.renderPass.camera = this.camera
this.composer.render()
} else {
this.renderer.render(this.scene, this.camera)
this.renderer.renderAsync(this.scene, this.camera)
}
this.entities.render()
// this.entities.render()
}

async waitForChunksToRender () {
Expand Down
6 changes: 5 additions & 1 deletion prismarine-viewer/viewer/lib/worldrenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ export class WorldRenderer {
}
this.sectionObjects[data.key] = object
this.updatePosDataChunk(data.key)
object.occlusionTest = true
// mesh.occlusionTest = true
this.scene.add(object)
// mesh.onBeforeRender = (renderer, scene, camera, geometry) => {
// //@ts-ignore
// object.occluded = renderer.isOccluded(mesh)
// }
} else if (data.type === 'sectionFinished') {
this.sectionsOutstanding.delete(data.key)
this.renderUpdateEmitter.emit('update')
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const renderer = new WebGpuRenderer({
initWithRenderer(renderer.domElement)
window.renderer = renderer
let pixelRatio = window.devicePixelRatio || 1 // todo this value is too high on ios, need to check, probably we should use avg, also need to make it configurable
if (!renderer.capabilities.isWebGL2) pixelRatio = 1 // webgl1 has issues with high pixel ratio (sometimes screen is clipped)
// if (!renderer.capabilities.isWebGL2) pixelRatio = 1 // webgl1 has issues with high pixel ratio (sometimes screen is clipped)
renderer.setPixelRatio(pixelRatio)
renderer.setSize(window.innerWidth, window.innerHeight)
renderer.domElement.id = 'viewer-canvas'
Expand Down

0 comments on commit f48728d

Please sign in to comment.