提交 3f20fee0 编写于 作者: M Mr.doob

Merge remote branch 'empaempa/master' into experimental

因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -91,6 +91,7 @@ THREE.QuakeCamera = function ( parameters ) {
this.moveBackward = false;
this.moveLeft = false;
this.moveRight = false;
this.freeze = false;
this.mouseDragOn = false;
......@@ -159,6 +160,8 @@ THREE.QuakeCamera = function ( parameters ) {
case 39: /*right*/
case 68: /*D*/ this.moveRight = true; break;
case 81: this.freeze = !this.freeze; break;
}
......@@ -186,30 +189,48 @@ THREE.QuakeCamera = function ( parameters ) {
this.update = function() {
if ( this.heightSpeed ) {
var y = clamp( this.position.y, this.heightMin, this.heightMax ),
delta = y - this.heightMin;
this.autoSpeedFactor = delta * this.heightCoef;
} else {
this.autoSpeedFactor = 0.0;
}
if ( this.moveForward || this.autoForward ) this.translateZ( - ( this.movementSpeed + this.autoSpeedFactor ) );
if ( this.moveBackward ) this.translateZ( this.movementSpeed );
if ( this.moveLeft ) this.translateX( - this.movementSpeed );
if ( this.moveRight ) this.translateX( this.movementSpeed );
var actualLookSpeed = this.lookSpeed;
if ( !this.activeLook ) {
actualLookSpeed = 0;
if ( !this.freeze ) {
if ( this.heightSpeed ) {
var y = clamp( this.position.y, this.heightMin, this.heightMax ),
delta = y - this.heightMin;
this.autoSpeedFactor = delta * this.heightCoef;
} else {
this.autoSpeedFactor = 0.0;
}
if ( this.moveForward || this.autoForward ) this.translateZ( - ( this.movementSpeed + this.autoSpeedFactor ) );
if ( this.moveBackward ) this.translateZ( this.movementSpeed );
if ( this.moveLeft ) this.translateX( - this.movementSpeed );
if ( this.moveRight ) this.translateX( this.movementSpeed );
var actualLookSpeed = this.lookSpeed;
if ( !this.activeLook ) {
actualLookSpeed = 0;
}
this.lon += this.mouseX * actualLookSpeed;
if( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed;
this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
this.phi = ( 90 - this.lat ) * Math.PI / 180;
this.theta = this.lon * Math.PI / 180;
var targetPosition = this.target.position,
position = this.position;
targetPosition.x = position.x + 100 * Math.sin( this.phi ) * Math.cos( this.theta );
targetPosition.y = position.y + 100 * Math.cos( this.phi );
targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta );
}
this.lon += this.mouseX * actualLookSpeed;
......
......@@ -37,6 +37,7 @@ THREE.MeshShaderMaterial = function ( parameters ) {
this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false;
this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1;
this.fog = parameters.fog !== undefined ? parameters.fog : false; // set to use scene fog
this.lights = parameters.lights !== undefined ? parameters.lights : false; // set to use scene lights
this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : false; // set to use "color" attribute stream
this.skinning = parameters.skinning !== undefined ? parameters.skinning : false; // set to use skinning attribute streams
......
......@@ -17,5 +17,8 @@ THREE.WebGLRenderTarget = function ( width, height, options ) {
this.format = options.format !== undefined ? options.format : THREE.RGBFormat;
this.type = options.type !== undefined ? options.type : THREE.UnsignedByteType;
this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
};
......@@ -105,10 +105,10 @@ THREE.WebGLRenderer = function ( parameters ) {
_stencilShadow.faces = new Uint16Array( 6 );
_stencilShadow.darkness = 0.5;
_stencilShadow.vertices[ 0 * 3 + 0 ] = -2; _stencilShadow.vertices[ 0 * 3 + 1 ] = -1; _stencilShadow.vertices[ 0 * 3 + 2 ] = -1;
_stencilShadow.vertices[ 1 * 3 + 0 ] = 2; _stencilShadow.vertices[ 1 * 3 + 1 ] = -1; _stencilShadow.vertices[ 1 * 3 + 2 ] = -1;
_stencilShadow.vertices[ 2 * 3 + 0 ] = 2; _stencilShadow.vertices[ 2 * 3 + 1 ] = 1; _stencilShadow.vertices[ 2 * 3 + 2 ] = -1;
_stencilShadow.vertices[ 3 * 3 + 0 ] = -2; _stencilShadow.vertices[ 3 * 3 + 1 ] = 1; _stencilShadow.vertices[ 3 * 3 + 2 ] = -1;
_stencilShadow.vertices[ 0 * 3 + 0 ] = -20; _stencilShadow.vertices[ 0 * 3 + 1 ] = -20; _stencilShadow.vertices[ 0 * 3 + 2 ] = -1;
_stencilShadow.vertices[ 1 * 3 + 0 ] = 20; _stencilShadow.vertices[ 1 * 3 + 1 ] = -20; _stencilShadow.vertices[ 1 * 3 + 2 ] = -1;
_stencilShadow.vertices[ 2 * 3 + 0 ] = 20; _stencilShadow.vertices[ 2 * 3 + 1 ] = 20; _stencilShadow.vertices[ 2 * 3 + 2 ] = -1;
_stencilShadow.vertices[ 3 * 3 + 0 ] = -20; _stencilShadow.vertices[ 3 * 3 + 1 ] = 20; _stencilShadow.vertices[ 3 * 3 + 2 ] = -1;
_stencilShadow.faces[ 0 ] = 0; _stencilShadow.faces[ 1 ] = 1; _stencilShadow.faces[ 2 ] = 2;
_stencilShadow.faces[ 3 ] = 0; _stencilShadow.faces[ 4 ] = 2; _stencilShadow.faces[ 5 ] = 3;
......@@ -616,6 +616,7 @@ THREE.WebGLRenderer = function ( parameters ) {
offset_skin = 0,
offset_morphTarget = 0,
offset_custom = 0,
offset_customSrc = 0,
vertexArray = geometryGroup.__vertexArray,
uvArray = geometryGroup.__uvArray,
......@@ -675,6 +676,7 @@ THREE.WebGLRenderer = function ( parameters ) {
for ( a in customAttributes ) {
customAttributes[ a ].offset = 0;
customAttributes[ a ].offsetSrc = 0;
}
......@@ -739,20 +741,61 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( customAttribute.needsUpdate ) {
offset_custom = customAttribute.offset;
offset_customSrc = customAttribute.offsetSrc;
if( customAttribute.size === 1 ) {
customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ face.a ];
customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
if( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ face.a ];
customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
} else if( customAttribute.boundTo === "faces" ) {
customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ offset_customSrc ];
customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ offset_customSrc ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc ];
customAttribute.offsetSrc++;
} else if( customAttribute.boundTo === "faceVertices" ) {
customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ offset_customSrc + 0 ];
customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ offset_customSrc + 1 ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc + 2 ];
customAttribute.offsetSrc += 3;
}
customAttribute.offset += 3;
} else {
v1 = customAttribute.value[ face.a ];
v2 = customAttribute.value[ face.b ];
v3 = customAttribute.value[ face.c ];
if( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
v1 = customAttribute.value[ face.a ];
v2 = customAttribute.value[ face.b ];
v3 = customAttribute.value[ face.c ];
} else if( customAttribute.boundTo === "faces" ) {
v1 = customAttribute.value[ offset_customSrc ];
v2 = customAttribute.value[ offset_customSrc ];
v3 = customAttribute.value[ offset_customSrc ];
customAttribute.offsetSrc++;
} else if( customAttribute.boundTo === "faceVertices" ) {
v1 = customAttribute.value[ offset_customSrc + 0 ];
v2 = customAttribute.value[ offset_customSrc + 1 ];
v3 = customAttribute.value[ offset_customSrc + 2 ];
customAttribute.offsetSrc += 3;
}
if( customAttribute.size === 2 ) {
......@@ -767,15 +810,31 @@ THREE.WebGLRenderer = function ( parameters ) {
} else if( customAttribute.size === 3 ) {
customAttribute.array[ offset_custom + 0 ] = v1.x;
customAttribute.array[ offset_custom + 1 ] = v1.y;
customAttribute.array[ offset_custom + 2 ] = v1.z;
customAttribute.array[ offset_custom + 3 ] = v2.x;
customAttribute.array[ offset_custom + 4 ] = v2.y;
customAttribute.array[ offset_custom + 5 ] = v2.z;
customAttribute.array[ offset_custom + 6 ] = v3.x;
customAttribute.array[ offset_custom + 7 ] = v3.y;
customAttribute.array[ offset_custom + 8 ] = v3.z;
if( customAttribute.type === "c" ) {
customAttribute.array[ offset_custom + 0 ] = v1.r;
customAttribute.array[ offset_custom + 1 ] = v1.g;
customAttribute.array[ offset_custom + 2 ] = v1.b;
customAttribute.array[ offset_custom + 3 ] = v2.r;
customAttribute.array[ offset_custom + 4 ] = v2.g;
customAttribute.array[ offset_custom + 5 ] = v2.b;
customAttribute.array[ offset_custom + 6 ] = v3.r;
customAttribute.array[ offset_custom + 7 ] = v3.g;
customAttribute.array[ offset_custom + 8 ] = v3.b;
} else {
customAttribute.array[ offset_custom + 0 ] = v1.x;
customAttribute.array[ offset_custom + 1 ] = v1.y;
customAttribute.array[ offset_custom + 2 ] = v1.z;
customAttribute.array[ offset_custom + 3 ] = v2.x;
customAttribute.array[ offset_custom + 4 ] = v2.y;
customAttribute.array[ offset_custom + 5 ] = v2.z;
customAttribute.array[ offset_custom + 6 ] = v3.x;
customAttribute.array[ offset_custom + 7 ] = v3.y;
customAttribute.array[ offset_custom + 8 ] = v3.z;
}
customAttribute.offset += 9;
......@@ -1105,22 +1164,66 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( customAttribute.needsUpdate ) {
offset_custom = customAttribute.offset;
offset_customSrc = customAttribute.offsetSrc;
if( customAttribute.size === 1 ) {
customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ face.a ];
customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.d ];
if( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ face.a ];
customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.d ];
} else if( customAttribute.boundTo === "faces" ) {
customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ offset_customSrc ];
customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ offset_customSrc ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc ];
customAttribute.offsetSrc++;
} else if( customAttribute.boundTo === "faceVertices" ) {
customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ offset_customSrc + 0 ];
customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ offset_customSrc + 1 ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc + 2 ];
customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc + 3 ];
customAttribute.offsetSrc += 4;
}
customAttribute.offset += 4;
} else {
v1 = customAttribute.value[ face.a ];
v2 = customAttribute.value[ face.b ];
v3 = customAttribute.value[ face.c ];
v4 = customAttribute.value[ face.d ];
if( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
v1 = customAttribute.value[ face.a ];
v2 = customAttribute.value[ face.b ];
v3 = customAttribute.value[ face.c ];
v4 = customAttribute.value[ face.d ];
} else if( customAttribute.boundTo === "faces" ) {
v1 = customAttribute.value[ offset_customSrc ];
v2 = customAttribute.value[ offset_customSrc ];
v3 = customAttribute.value[ offset_customSrc ];
v4 = customAttribute.value[ offset_customSrc ];
customAttribute.offsetSrc++;
} else if( customAttribute.boundTo === "faceVertices" ) {
v1 = customAttribute.value[ offset_customSrc + 0 ];
v2 = customAttribute.value[ offset_customSrc + 1 ];
v3 = customAttribute.value[ offset_customSrc + 2 ];
v4 = customAttribute.value[ offset_customSrc + 3 ];
customAttribute.offsetSrc += 4;
}
if( customAttribute.size === 2 ) {
......@@ -1137,18 +1240,37 @@ THREE.WebGLRenderer = function ( parameters ) {
} else if( customAttribute.size === 3 ) {
customAttribute.array[ offset_custom + 0 ] = v1.x;
customAttribute.array[ offset_custom + 1 ] = v1.y;
customAttribute.array[ offset_custom + 2 ] = v1.z;
customAttribute.array[ offset_custom + 3 ] = v2.x;
customAttribute.array[ offset_custom + 4 ] = v2.y;
customAttribute.array[ offset_custom + 5 ] = v2.z;
customAttribute.array[ offset_custom + 6 ] = v3.x;
customAttribute.array[ offset_custom + 7 ] = v3.y;
customAttribute.array[ offset_custom + 8 ] = v3.z;
customAttribute.array[ offset_custom + 9 ] = v4.x;
customAttribute.array[ offset_custom + 10 ] = v4.y;
customAttribute.array[ offset_custom + 11 ] = v4.z;
if( customAttribute.type === "c" ) {
customAttribute.array[ offset_custom + 0 ] = v1.r;
customAttribute.array[ offset_custom + 1 ] = v1.g;
customAttribute.array[ offset_custom + 2 ] = v1.b;
customAttribute.array[ offset_custom + 3 ] = v2.r;
customAttribute.array[ offset_custom + 4 ] = v2.g;
customAttribute.array[ offset_custom + 5 ] = v2.b;
customAttribute.array[ offset_custom + 6 ] = v3.r;
customAttribute.array[ offset_custom + 7 ] = v3.g;
customAttribute.array[ offset_custom + 8 ] = v3.b;
customAttribute.array[ offset_custom + 9 ] = v4.r;
customAttribute.array[ offset_custom + 10 ] = v4.g;
customAttribute.array[ offset_custom + 11 ] = v4.b;
} else {
customAttribute.array[ offset_custom + 0 ] = v1.x;
customAttribute.array[ offset_custom + 1 ] = v1.y;
customAttribute.array[ offset_custom + 2 ] = v1.z;
customAttribute.array[ offset_custom + 3 ] = v2.x;
customAttribute.array[ offset_custom + 4 ] = v2.y;
customAttribute.array[ offset_custom + 5 ] = v2.z;
customAttribute.array[ offset_custom + 6 ] = v3.x;
customAttribute.array[ offset_custom + 7 ] = v3.y;
customAttribute.array[ offset_custom + 8 ] = v3.z;
customAttribute.array[ offset_custom + 9 ] = v4.x;
customAttribute.array[ offset_custom + 10 ] = v4.y;
customAttribute.array[ offset_custom + 11 ] = v4.z;
}
customAttribute.offset += 12;
......@@ -2913,6 +3035,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl.enable( _gl.POLYGON_OFFSET_FILL );
_gl.polygonOffset( 0.1, 1.0 );
_gl.enable( _gl.STENCIL_TEST );
_gl.enable( _gl.DEPTH_TEST );
_gl.depthMask( false );
_gl.colorMask( false, false, false, false );
......@@ -4161,14 +4284,13 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( renderTexture && !renderTexture.__webglFramebuffer ) {
if( renderTexture.depthBuffer === undefined ) renderTexture.depthBuffer = true;
if( renderTexture.stencilBuffer === undefined ) renderTexture.stencilBuffer = true;
renderTexture.__webglFramebuffer = _gl.createFramebuffer();
renderTexture.__webglRenderbuffer = _gl.createRenderbuffer();
renderTexture.__webglTexture = _gl.createTexture();
// Setup renderbuffer
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_COMPONENT16, renderTexture.width, renderTexture.height );
// Setup texture
......@@ -4179,11 +4301,35 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, paramThreeToGL( renderTexture.minFilter ) );
_gl.texImage2D( _gl.TEXTURE_2D, 0, paramThreeToGL( renderTexture.format ), renderTexture.width, renderTexture.height, 0, paramThreeToGL( renderTexture.format ), paramThreeToGL( renderTexture.type ), null );
// Setup framebuffer
// Setup render and frame buffer
_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTexture.__webglFramebuffer );
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, renderTexture.__webglTexture, 0 );
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
if( renderTexture.depthBuffer && !renderTexture.stencilBuffer ) {
_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_COMPONENT16, renderTexture.width, renderTexture.height );
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
/* For some reason this is not working. Defaulting to RGBA4.
} else if( !renderTexture.depthBuffer && renderTexture.stencilBuffer ) {
_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.STENCIL_INDEX8, renderTexture.width, renderTexture.height );
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
*/
} else if( renderTexture.depthBuffer && renderTexture.stencilBuffer ) {
_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTexture.width, renderTexture.height );
_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
} else {
_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.RGBA4, renderTexture.width, renderTexture.height );
}
// Release everything
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册