Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
fc612d0a
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fc612d0a
编写于
3月 04, 2019
作者:
S
Sneha Belkhale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
removing unused lines and fixing formatting to tabs only
上级
bedee743
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
32 deletion
+30
-32
examples/webgl_box_projected_cubemap_environment_mapping.html
...ples/webgl_box_projected_cubemap_environment_mapping.html
+30
-32
未找到文件。
examples/webgl_box_projected_cubemap_environment_mapping.html
浏览文件 @
fc612d0a
...
...
@@ -72,26 +72,26 @@
#ifdef BOX_PROJECTED_ENV_MAP
uniform vec3 cubeMapSize;
uniform vec3 cubeMapPos;
varying vec3 vWorldPosition;
uniform vec3 cubeMapSize;
uniform vec3 cubeMapPos;
varying vec3 vWorldPosition;
vec3 parallaxCorrectNormal( vec3 v, vec3 cubeSize, vec3 cubePos ) {
vec3 parallaxCorrectNormal( vec3 v, vec3 cubeSize, vec3 cubePos ) {
vec3 nDir = normalize( v );
vec3 rbmax = ( .5 * ( cubeSize - cubePos ) - vWorldPosition ) / nDir;
vec3 rbmin = ( - .5 * ( cubeSize - cubePos ) - vWorldPosition ) / nDir;
vec3 nDir = normalize( v );
vec3 rbmax = ( .5 * ( cubeSize - cubePos ) - vWorldPosition ) / nDir;
vec3 rbmin = ( - .5 * ( cubeSize - cubePos ) - vWorldPosition ) / nDir;
vec3 rbminmax;
rbminmax.x = ( nDir.x > 0. ) ? rbmax.x : rbmin.x;
rbminmax.y = ( nDir.y > 0. ) ? rbmax.y : rbmin.y;
rbminmax.z = ( nDir.z > 0. ) ? rbmax.z : rbmin.z;
vec3 rbminmax;
rbminmax.x = ( nDir.x > 0. ) ? rbmax.x : rbmin.x;
rbminmax.y = ( nDir.y > 0. ) ? rbmax.y : rbmin.y;
rbminmax.z = ( nDir.z > 0. ) ? rbmax.z : rbmin.z;
float correction = min( min( rbminmax.x, rbminmax.y ), rbminmax.z );
vec3 boxIntersection = vWorldPosition + nDir * correction;
float correction = min( min( rbminmax.x, rbminmax.y ), rbminmax.z );
vec3 boxIntersection = vWorldPosition + nDir * correction;
return boxIntersection - cubePos;
}
return boxIntersection - cubePos;
}
#endif
...
...
@@ -134,11 +134,11 @@
vec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );
#ifdef ENVMAP_TYPE_CUBE
vec3 worldNormalFinal = worldNormal;
vec3 worldNormalFinal = worldNormal;
#ifdef BOX_PROJECTED_ENV_MAP
#ifdef BOX_PROJECTED_ENV_MAP
worldNormalFinal = parallaxCorrectNormal( worldNormal, cubeMapSize, cubeMapPos );
worldNormalFinal = parallaxCorrectNormal( worldNormal, cubeMapSize, cubeMapPos );
#endif
...
...
@@ -193,13 +193,13 @@
#ifdef ENVMAP_TYPE_CUBE
vec3 reflectVecFinal = reflectVec;
vec3 reflectVecFinal = reflectVec;
#ifdef BOX_PROJECTED_ENV_MAP
#ifdef BOX_PROJECTED_ENV_MAP
reflectVecFinal = parallaxCorrectNormal( reflectVec, cubeMapSize, cubeMapPos );
reflectVecFinal = parallaxCorrectNormal( reflectVec, cubeMapSize, cubeMapPos );
#endif
#endif
vec3 queryReflectVec = vec3( flipEnvMap * reflectVecFinal.x, reflectVecFinal.yz );
...
...
@@ -257,8 +257,8 @@
return envMapColor.rgb * envMapIntensity;
}
#endif
`
;
#endif
`
;
// scene size
var
WIDTH
=
window
.
innerWidth
;
...
...
@@ -325,7 +325,6 @@
cubeCamera
=
new
THREE
.
CubeCamera
(
1
,
1000
,
512
);
cubeCamera
.
renderTarget
.
texture
.
generateMipmaps
=
true
;
cubeCamera
.
renderTarget
.
texture
.
minFilter
=
THREE
.
LinearMipMapLinearFilter
;
cubeCamera
.
renderTarget
.
texture
.
magFilter
=
THREE
.
LinearFilter
;
cubeCamera
.
renderTarget
.
texture
.
mapping
=
THREE
.
CubeReflectionMapping
;
cubeCamera
.
position
.
set
(
0
,
-
100
,
0
);
...
...
@@ -346,18 +345,18 @@
var
boxProjectedMat
=
new
THREE
.
MeshPhysicalMaterial
({
color
:
new
THREE
.
Color
(
'
#ffffff
'
),
roughness
:
1
,
envMap
:
cubeCamera
.
renderTarget
.
texture
,
roughness
:
1
,
envMap
:
cubeCamera
.
renderTarget
.
texture
,
roughnessMap
:
rMap
,
});
});
boxProjectedMat
.
onBeforeCompile
=
function
(
shader
)
{
shader
.
uniforms
.
cubeMapSize
=
{
value
:
new
THREE
.
Vector3
(
200
,
100
,
100
)
};
shader
.
uniforms
.
cubeMapPos
=
{
value
:
new
THREE
.
Vector3
(
0
,
-
50
,
0
)
};
shader
.
uniforms
.
cubeMapPos
=
{
value
:
new
THREE
.
Vector3
(
0
,
-
50
,
0
)
};
shader
.
uniforms
.
flipEnvMap
.
value
=
true
;
//replace shader chunks with box projection chunks
//replace shader chunks with box projection chunks
shader
.
vertexShader
=
'
varying vec3 vWorldPosition;
\n
'
+
shader
.
vertexShader
;
shader
.
vertexShader
=
shader
.
vertexShader
.
replace
(
...
...
@@ -379,10 +378,9 @@
};
groundPlane
=
new
THREE
.
Mesh
(
new
THREE
.
Plane
Geometry
(
200
,
100
,
100
),
boxProjectedMat
);
groundPlane
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneBuffer
Geometry
(
200
,
100
,
100
),
boxProjectedMat
);
groundPlane
.
rotateX
(
-
Math
.
PI
/
2
);
groundPlane
.
position
.
set
(
0
,
-
49
,
0
);
groundPlane
.
geometry
.
computeVertexNormals
();
scene
.
add
(
groundPlane
);
// walls
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录