Browse Source

Merge pull request #14892 from 06wj/patch0

Fix CanvasRenderer sprite.raycast bug
Mr.doob 7 years ago
parent
commit
e848b24a3c

+ 5 - 1
docs/examples/SpriteCanvasMaterial.html

@@ -23,6 +23,7 @@
 		parameters is an object that can be used to set up the default properties
 		parameters is an object that can be used to set up the default properties
 		</p>
 		</p>
 		<p>
 		<p>
+		rotation - the rotation of the sprite<br/>
 		color - the color of the sprite<br/>
 		color - the color of the sprite<br/>
 		program - the program used to draw the sprite
 		program - the program used to draw the sprite
 		</p>
 		</p>
@@ -30,7 +31,10 @@
 
 
 		<h2>Properties</h2>
 		<h2>Properties</h2>
 
 
-
+		<h3>[property:Radians rotation]</h3>
+		<p>
+		The rotation of the sprite in radians. Default is 0.
+		</p>
 
 
 		<h3>[property:Color color]</h3>
 		<h3>[property:Color color]</h3>
 		<p>
 		<p>

+ 1 - 1
examples/js/renderers/CanvasRenderer.js

@@ -7,7 +7,7 @@ THREE.SpriteCanvasMaterial = function ( parameters ) {
 	THREE.Material.call( this );
 	THREE.Material.call( this );
 
 
 	this.type = 'SpriteCanvasMaterial';
 	this.type = 'SpriteCanvasMaterial';
-
+	this.rotation = 0;
 	this.color = new THREE.Color( 0xffffff );
 	this.color = new THREE.Color( 0xffffff );
 	this.program = function () {};
 	this.program = function () {};
 
 

+ 1 - 0
examples/js/renderers/Projector.js

@@ -878,6 +878,7 @@ THREE.Projector = function () {
 
 
 			} else if ( object instanceof THREE.Sprite ) {
 			} else if ( object instanceof THREE.Sprite ) {
 
 
+				object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
 				_vector4.set( _modelMatrix.elements[ 12 ], _modelMatrix.elements[ 13 ], _modelMatrix.elements[ 14 ], 1 );
 				_vector4.set( _modelMatrix.elements[ 12 ], _modelMatrix.elements[ 13 ], _modelMatrix.elements[ 14 ], 1 );
 				_vector4.applyMatrix4( _viewProjectionMatrix );
 				_vector4.applyMatrix4( _viewProjectionMatrix );