Bläddra i källkod

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

Vincent Fretin 2 år sedan
förälder
incheckning
888ced843e
1 ändrade filer med 8 tillägg och 1 borttagningar
  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 {