提交 1e4ae4fc 编写于 作者: M Mr.doob

WebGLBackground: Simplified skybox code.

上级 32785a1d
......@@ -4,8 +4,6 @@ uniform float opacity;
varying vec3 vWorldPosition;
#include <common>
void main() {
gl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );
......
......@@ -5,8 +5,6 @@ varying vec3 vWorldPosition;
void main() {
vWorldPosition = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position = projectionMatrix * vec4( normalMatrix * position, 1.0 );
}
......@@ -19,7 +19,7 @@ function WebGLBackground( renderer, state, geometries, premultipliedAlpha ) {
var clearAlpha = 0;
var planeCamera, planeMesh;
var boxCamera, boxMesh;
var boxMesh;
function render( scene, camera, forceClear ) {
......@@ -44,9 +44,7 @@ function WebGLBackground( renderer, state, geometries, premultipliedAlpha ) {
if ( background && background.isCubeTexture ) {
if ( boxCamera === undefined ) {
boxCamera = new PerspectiveCamera();
if ( boxMesh === undefined ) {
boxMesh = new Mesh(
new BoxBufferGeometry( 5, 5, 5 ),
......@@ -63,17 +61,13 @@ function WebGLBackground( renderer, state, geometries, premultipliedAlpha ) {
}
boxCamera.projectionMatrix.copy( camera.projectionMatrix );
boxCamera.matrixWorld.extractRotation( camera.matrixWorld );
boxCamera.matrixWorldInverse.getInverse( boxCamera.matrixWorld );
boxMesh.material.uniforms[ "tCube" ].value = background;
boxMesh.modelViewMatrix.multiplyMatrices( boxCamera.matrixWorldInverse, boxMesh.matrixWorld );
boxMesh.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, boxMesh.matrixWorld );
boxMesh.normalMatrix.getNormalMatrix( boxMesh.modelViewMatrix );
geometries.update( boxMesh.geometry );
renderer.renderBufferDirect( boxCamera, null, boxMesh.geometry, boxMesh.material, boxMesh, null );
renderer.renderBufferDirect( camera, null, boxMesh.geometry, boxMesh.material, boxMesh, null );
} else if ( background && background.isTexture ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册