Skip to content

Commit 895c943

Browse files
committed
Updated Ray with the material.side change.
1 parent d79db8c commit 895c943

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/Ray.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,24 @@ THREE.Ray = function ( origin, direction, near, far ) {
138138
rangeSq = this.range * this.range,
139139
geometry = object.geometry,
140140
vertices = geometry.vertices,
141-
objMatrix;
141+
objMatrix, geometryMaterials,
142+
isFaceMaterial, material, side;
143+
144+
geometryMaterials = object.geometry.materials;
145+
isFaceMaterial = object.material instanceof THREE.MeshFaceMaterial;
146+
side = object.material.side;
142147

143148
object.matrixRotationWorld.extractRotation( object.matrixWorld );
144149

145150
for ( f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
146151

147152
face = geometry.faces[ f ];
148153

154+
material = isFaceMaterial === true ? geometryMaterials[ face.materialIndex ] : object.material;
155+
if ( material === undefined ) continue;
156+
157+
side = material.side;
158+
149159
originCopy.copy( this.origin );
150160
directionCopy.copy( this.direction );
151161

@@ -170,7 +180,7 @@ THREE.Ray = function ( origin, direction, near, far ) {
170180

171181
if ( scalar < 0 ) continue;
172182

173-
if ( object.doubleSided || ( object.flipSided ? dot > 0 : dot < 0 ) ) {
183+
if ( side === THREE.DoubleSide || ( side === THREE.FrontSide ? dot < 0 : dot > 0 ) ) {
174184

175185
intersectPoint.add( originCopy, directionCopy.multiplyScalar( scalar ) );
176186

0 commit comments

Comments
 (0)