mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-09 04:56:01 +10:00
Added normal to returned collider for mesh collider tests
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
.DS_Store
|
||||
*.swp
|
||||
.project
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @author drojdjou / http://everyday3d.com/
|
||||
* @author bartek drozdz / http://everyday3d.com/
|
||||
*/
|
||||
|
||||
THREE.CollisionUtils = {};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @author drojdjou / http://everyday3d.com/
|
||||
* @author bartek drozdz / http://everyday3d.com/
|
||||
*/
|
||||
|
||||
THREE.PlaneCollider = function( point, normal ) {
|
||||
@@ -38,6 +38,7 @@ THREE.MeshCollider = function( vertices, faces, normals, box ) {
|
||||
|
||||
THREE.CollisionSystem = function() {
|
||||
|
||||
this.collisionNormal;
|
||||
this.colliders = [];
|
||||
this.hits = [];
|
||||
|
||||
@@ -139,8 +140,12 @@ THREE.CollisionSystem.prototype.rayMesh = function( r, me ) {
|
||||
var p2 = me.vertices[ me.faces[ t + 2 ] ];
|
||||
var n = me.normals[ me.faces[ i ] ];
|
||||
|
||||
d = Math.min(d, this.rayTriangle( rt, p0, p1, p2, n, d ) );
|
||||
var nd = this.rayTriangle( rt, p0, p1, p2, n, d );
|
||||
|
||||
if(nd < d) {
|
||||
d = nd;
|
||||
me.normal = this.collisionNormal;
|
||||
}
|
||||
}
|
||||
|
||||
return d;
|
||||
@@ -246,6 +251,8 @@ THREE.CollisionSystem.prototype.rayTriangle = function( ray, p0, p1, p2, n, mind
|
||||
if( !(gamma >= 0) ) return Number.MAX_VALUE;
|
||||
//console.log("gamma: " + gamma);
|
||||
|
||||
this.collisionNormal = n;
|
||||
|
||||
return t;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user