littlejsengine 1.18.28 → 1.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,9 +81,14 @@ class ThreeJSPlugin
81
81
  if (!this.renderer) return; // headless mode
82
82
 
83
83
  // keep renderer size and css in sync with the LittleJS canvas
84
+ // mainCanvasSize is css pixels, three scales it by the pixel ratio
84
85
  const threeCanvas = this.renderer.domElement;
85
- if (threeCanvas.width != mainCanvasSize.x || threeCanvas.height != mainCanvasSize.y)
86
+ const dpr = getCanvasPixelRatio();
87
+ const bufferSizeX = mainCanvasSize.x * dpr | 0;
88
+ const bufferSizeY = mainCanvasSize.y * dpr | 0;
89
+ if (threeCanvas.width != bufferSizeX || threeCanvas.height != bufferSizeY)
86
90
  {
91
+ this.renderer.setPixelRatio(dpr);
87
92
  this.renderer.setSize(mainCanvasSize.x, mainCanvasSize.y, false);
88
93
  this.camera.aspect = mainCanvasSize.x / mainCanvasSize.y;
89
94
  this.camera.updateProjectionMatrix();