Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
c3a6cf03
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,体验更适合开发者的 AI 搜索 >>
提交
c3a6cf03
编写于
3月 04, 2020
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Examples: Remove webgl_lightshafts and respective glTF asset.
上级
9c7b4f49
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
0 addition
and
230 deletion
+0
-230
examples/files.js
examples/files.js
+0
-1
examples/models/gltf/Tree/README.md
examples/models/gltf/Tree/README.md
+0
-5
examples/models/gltf/Tree/tree.glb
examples/models/gltf/Tree/tree.glb
+0
-0
examples/textures/lightShaft.png
examples/textures/lightShaft.png
+0
-0
examples/webgl_lightshafts.html
examples/webgl_lightshafts.html
+0
-224
未找到文件。
examples/files.js
浏览文件 @
c3a6cf03
...
@@ -300,7 +300,6 @@ var files = {
...
@@ -300,7 +300,6 @@ var files = {
"
webgl_gpgpu_protoplanet
"
,
"
webgl_gpgpu_protoplanet
"
,
"
webgl_instancing_modified
"
,
"
webgl_instancing_modified
"
,
"
webgl_lightningstrike
"
,
"
webgl_lightningstrike
"
,
"
webgl_lightshafts
"
,
"
webgl_materials_modified
"
,
"
webgl_materials_modified
"
,
"
webgl_raymarching_reflect
"
,
"
webgl_raymarching_reflect
"
,
"
webgl_shadowmap_csm
"
,
"
webgl_shadowmap_csm
"
,
...
...
examples/models/gltf/Tree/README.md
已删除
100644 → 0
浏览文件 @
9c7b4f49
# Low Poly Foliage Test
Model by
[
Splodeman
](
https://sketchfab.com/3d-models/low-poly-foliage-test-c1ce9830c6af4b5289ee9ecb3c30512f
)
.
The model is license under Creative Commons Attribution.
examples/models/gltf/Tree/tree.glb
已删除
100644 → 0
浏览文件 @
9c7b4f49
文件已删除
examples/textures/lightShaft.png
已删除
100644 → 0
浏览文件 @
9c7b4f49
47.6 KB
examples/webgl_lightshafts.html
已删除
100644 → 0
浏览文件 @
9c7b4f49
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - Light Shafts
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"main.css"
>
</head>
<body>
<div
id=
"info"
>
<a
href=
"https://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
- Light Shafts
<br/>
Model by
<a
href=
"https://skfb.ly/6ICER"
target=
"_blank"
rel=
"noopener"
>
Splodeman
</a><br
/>
</div>
<script
type=
"x-shader/x-vertex"
id=
"vertexShader"
>
#
include
<
common
>
uniform
float
speed
;
uniform
float
time
;
uniform
float
timeOffset
;
varying
vec2
vUv
;
varying
float
vAlpha
;
void
main
()
{
vec3
pos
=
position
;
float
l
=
(
time
*
speed
*
0.01
)
+
timeOffset
;
float
f
=
fract
(
l
);
// linear time factor [0,1)
float
a
=
f
*
f
;
// quadratic time factor [0,1)
// slightly animate the vertices of light shaft if necessary
// pos.x += cos( l * 20.0 ) * sin( l * 10.0 );
vAlpha
=
saturate
(
0.7
+
min
(
1.0
,
a
*
10.0
)
*
(
sin
(
a
*
40.0
)
*
0.25
)
);
vUv
=
uv
;
gl_Position
=
projectionMatrix
*
modelViewMatrix
*
vec4
(
pos
,
1.0
);
}
</script>
<script
type=
"x-shader/x-fragment"
id=
"fragmentShader"
>
uniform
float
attenuation
;
uniform
vec3
color
;
uniform
sampler2D
colorTexture
;
varying
vec2
vUv
;
varying
float
vAlpha
;
void
main
()
{
vec4
textureColor
=
texture2D
(
colorTexture
,
vUv
);
gl_FragColor
=
vec4
(
textureColor
.
rgb
*
color
.
rgb
,
textureColor
.
a
*
vAlpha
);
gl_FragColor
.
a
*=
pow
(
gl_FragCoord
.
z
,
attenuation
);
}
</script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
OrbitControls
}
from
'
./jsm/controls/OrbitControls.js
'
;
import
{
GLTFLoader
}
from
'
./jsm/loaders/GLTFLoader.js
'
;
var
container
,
controls
,
clock
;
var
camera
,
scene
,
renderer
,
uniforms
;
init
();
animate
();
function
init
()
{
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
45
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
100
);
camera
.
position
.
set
(
3.2
,
3
,
3.7
);
clock
=
new
THREE
.
Clock
();
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0xcf8b74
);
var
light
=
new
THREE
.
HemisphereLight
(
0xffffff
,
0x444444
);
light
.
position
.
set
(
0
,
20
,
0
);
scene
.
add
(
light
);
light
=
new
THREE
.
DirectionalLight
(
0xffffff
);
light
.
position
.
set
(
0
,
20
,
10
);
scene
.
add
(
light
);
// light shafts definition
var
textureLoader
=
new
THREE
.
TextureLoader
();
var
texture
=
textureLoader
.
load
(
'
textures/lightShaft.png
'
);
uniforms
=
{
// controls how fast the ray attenuates when the camera comes closer
attenuation
:
{
value
:
10
},
// controls the speed of the animation
speed
:
{
value
:
2
},
// the color of the ray
color
:
{
value
:
new
THREE
.
Color
(
0xdadc9f
)
},
// the visual representation of the ray highly depends on the used texture
colorTexture
:
{
value
:
texture
},
// global time value for animation
time
:
{
value
:
0
},
// individual time offset so rays are animated differently if necessary
timeOffset
:
{
value
:
0
}
};
var
lightShaftMaterial
=
new
THREE
.
ShaderMaterial
(
{
uniforms
:
uniforms
,
vertexShader
:
document
.
getElementById
(
'
vertexShader
'
).
textContent
,
fragmentShader
:
document
.
getElementById
(
'
fragmentShader
'
).
textContent
,
blending
:
THREE
.
AdditiveBlending
,
depthWrite
:
false
,
transparent
:
true
,
side
:
THREE
.
DoubleSide
}
);
var
lightShaftGeometry
=
new
THREE
.
PlaneBufferGeometry
(
0.5
,
5
);
// model
var
loader
=
new
GLTFLoader
().
setPath
(
'
models/gltf/Tree/
'
);
loader
.
load
(
'
tree.glb
'
,
function
(
gltf
)
{
gltf
.
scene
.
traverse
(
function
(
child
)
{
if
(
child
.
isMesh
)
{
child
.
material
.
transparent
=
false
;
child
.
material
.
alphaTest
=
0.5
;
child
.
material
.
depthWrite
=
true
;
}
}
);
scene
.
add
(
gltf
.
scene
);
// when the model is loaded, add light shafts
for
(
var
i
=
0
;
i
<
5
;
i
++
)
{
var
lightShaft
=
new
THREE
.
Mesh
(
lightShaftGeometry
,
lightShaftMaterial
);
lightShaft
.
position
.
x
=
-
1
+
1.5
*
Math
.
sign
(
(
i
%
2
)
);
lightShaft
.
position
.
y
=
2
;
lightShaft
.
position
.
z
=
-
1.5
+
(
i
*
0.5
);
lightShaft
.
rotation
.
y
=
Math
.
PI
*
0.2
;
lightShaft
.
rotation
.
z
=
Math
.
PI
*
-
(
0.15
+
0.1
*
Math
.
random
()
);
scene
.
add
(
lightShaft
);
}
}
);
//
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
outputEncoding
=
THREE
.
sRGBEncoding
;
container
.
appendChild
(
renderer
.
domElement
);
controls
=
new
OrbitControls
(
camera
,
renderer
.
domElement
);
controls
.
target
.
set
(
0.5
,
1.5
,
0
);
controls
.
minDistance
=
2
;
controls
.
maxDistance
=
20
;
controls
.
update
();
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
}
function
onWindowResize
()
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
//
function
animate
()
{
requestAnimationFrame
(
animate
);
const
delta
=
clock
.
getDelta
();
uniforms
.
time
.
value
+=
delta
;
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录