提交 d8c23537 编写于 作者: A alteredq

Merge remote-tracking branch 'remotes/mrdoob/dev' into dev

因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
此差异已折叠。
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -62,7 +62,7 @@
var mesh;
var textureCube;
var cameraCube, sceneCube, cubeTarget;
var cameraCube, sceneCube;
var loader;
......@@ -95,7 +95,6 @@
// SKYBOX
cubeTarget = new THREE.Vector3( 0, 0, 0 );
sceneCube = new THREE.Scene();
cameraCube = new THREE.PerspectiveCamera( 25, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 );
sceneCube.add( cameraCube );
......@@ -348,11 +347,7 @@
controls.update();
cubeTarget.x = - camera.position.x;
cubeTarget.y = - camera.position.y;
cubeTarget.z = - camera.position.z;
cameraCube.lookAt( cubeTarget );
cameraCube.rotation.copy( camera.rotation );
renderer.clear();
renderer.render( sceneCube, cameraCube );
......
......@@ -103,30 +103,35 @@ THREE.Ray = function ( origin, direction ) {
objMatrix = object.matrixWorld;
// check if face.centroid is behind the origin
// determine if ray intersects the plane of the face
// note: this works regardless of the direction of the face normal
vector = objMatrix.multiplyVector3( vector.copy( face.centroid ) ).subSelf( originCopy );
dot = vector.dot( directionCopy );
normal = object.matrixRotationWorld.multiplyVector3( normal.copy( face.normal ) );
dot = directionCopy.dot( normal );
if ( dot <= 0 ) continue;
// bail if ray and plane are parallel
//
if ( Math.abs( dot ) < 0.0001 ) continue;
a = objMatrix.multiplyVector3( a.copy( vertices[ face.a ].position ) );
b = objMatrix.multiplyVector3( b.copy( vertices[ face.b ].position ) );
c = objMatrix.multiplyVector3( c.copy( vertices[ face.c ].position ) );
if ( face instanceof THREE.Face4 ) d = objMatrix.multiplyVector3( d.copy( vertices[ face.d ].position ) );
// calc distance to plane
normal = object.matrixRotationWorld.multiplyVector3( normal.copy( face.normal ) );
dot = directionCopy.dot( normal );
scalar = normal.dot( vector ) / dot;
if ( object.doubleSided || ( object.flipSided ? dot > 0 : dot < 0 ) ) { // Math.abs( dot ) > 0.0001
// if negative distance, then plane is behind ray
if ( scalar < 0 ) continue;
if ( object.doubleSided || ( object.flipSided ? dot > 0 : dot < 0 ) ) {
scalar = normal.dot( vector.sub( a, originCopy ) ) / dot;
intersectPoint.add( originCopy, directionCopy.multiplyScalar( scalar ) );
if ( face instanceof THREE.Face3 ) {
a = objMatrix.multiplyVector3( a.copy( vertices[ face.a ].position ) );
b = objMatrix.multiplyVector3( b.copy( vertices[ face.b ].position ) );
c = objMatrix.multiplyVector3( c.copy( vertices[ face.c ].position ) );
if ( pointInFace3( intersectPoint, a, b, c ) ) {
intersect = {
......@@ -144,6 +149,11 @@ THREE.Ray = function ( origin, direction ) {
} else if ( face instanceof THREE.Face4 ) {
a = objMatrix.multiplyVector3( a.copy( vertices[ face.a ].position ) );
b = objMatrix.multiplyVector3( b.copy( vertices[ face.b ].position ) );
c = objMatrix.multiplyVector3( c.copy( vertices[ face.c ].position ) );
d = objMatrix.multiplyVector3( d.copy( vertices[ face.d ].position ) );
if ( pointInFace3( intersectPoint, a, b, d ) || pointInFace3( intersectPoint, b, c, d ) ) {
intersect = {
......
......@@ -3244,7 +3244,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this.setBlending( scene.overrideMaterial.blending );
this.setDepthTest( scene.overrideMaterial.depthTest );
setDepthWrite( scene.overrideMaterial.depthWrite );
this.setDepthWrite( scene.overrideMaterial.depthWrite );
setPolygonOffset( scene.overrideMaterial.polygonOffset, scene.overrideMaterial.polygonOffsetFactor, scene.overrideMaterial.polygonOffsetUnits );
renderObjects( scene.__webglObjects, false, "", camera, lights, fog, true, scene.overrideMaterial );
......@@ -3279,7 +3279,12 @@ THREE.WebGLRenderer = function ( parameters ) {
}
//_gl.finish();
// Ensure depth buffer writing is enabled so it can be cleared on next render
this.setDepthTest( true );
this.setDepthWrite( true );
// _gl.finish();
};
......@@ -3348,7 +3353,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( useBlending ) _this.setBlending( material.blending );
_this.setDepthTest( material.depthTest );
setDepthWrite( material.depthWrite );
_this.setDepthWrite( material.depthWrite );
setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
}
......@@ -3395,7 +3400,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( useBlending ) _this.setBlending( material.blending );
_this.setDepthTest( material.depthTest );
setDepthWrite( material.depthWrite );
_this.setDepthWrite( material.depthWrite );
setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
}
......@@ -4889,7 +4894,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( _oldDepthTest !== depthTest ) {
if( depthTest ) {
if ( depthTest ) {
_gl.enable( _gl.DEPTH_TEST );
......@@ -4905,24 +4910,24 @@ THREE.WebGLRenderer = function ( parameters ) {
};
function setLineWidth ( width ) {
if ( width !== _oldLineWidth ) {
this.setDepthWrite = function ( depthWrite ) {
_gl.lineWidth( width );
if ( _oldDepthWrite !== depthWrite ) {
_oldLineWidth = width;
_gl.depthMask( depthWrite );
_oldDepthWrite = depthWrite;
}
};
function setDepthWrite ( depthWrite ) {
function setLineWidth ( width ) {
if ( _oldDepthWrite !== depthWrite ) {
if ( width !== _oldLineWidth ) {
_gl.depthMask( depthWrite );
_oldDepthWrite = depthWrite;
_gl.lineWidth( width );
_oldLineWidth = width;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册