Explorar el Código

HTMLMesh: Render image at the correct position (#25916)

Vincent Fretin hace 2 años
padre
commit
888ced843e
Se han modificado 1 ficheros con 8 adiciones y 1 borrados
  1. 8 1
      examples/jsm/interactive/HTMLMesh.js

+ 8 - 1
examples/jsm/interactive/HTMLMesh.js

@@ -277,7 +277,14 @@ function html2canvas( element ) {
 
 			if ( element.style.display === 'none' ) return;
 
-			context.drawImage( element, 0, 0, element.width, element.height );
+			const rect = element.getBoundingClientRect();
+
+			x = rect.left - offset.left - 0.5;
+			y = rect.top - offset.top - 0.5;
+			width = rect.width + 0.5;
+			height = rect.height + 0.5;
+
+			context.drawImage( element, x, y, width, height );
 
 		} else {