Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
31925d23
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,发现更多精彩内容 >>
提交
31925d23
编写于
11月 13, 2019
作者:
O
Or Fleisher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Init 360 6DOF example
🚀
上级
4ab3edd6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
162 addition
and
0 deletion
+162
-0
examples/textures/kandao3.jpg
examples/textures/kandao3.jpg
+0
-0
examples/textures/kandao3_depthmap.jpg
examples/textures/kandao3_depthmap.jpg
+0
-0
examples/webvr_6dof_panorama.html
examples/webvr_6dof_panorama.html
+162
-0
未找到文件。
examples/textures/kandao3.jpg
0 → 100644
浏览文件 @
31925d23
1.2 MB
examples/textures/kandao3_depthmap.jpg
0 → 100644
浏览文件 @
31925d23
20.6 KB
examples/webvr_6dof_panorama.html
0 → 100644
浏览文件 @
31925d23
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webvr - 360 6DOF panorama
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, user-scalable=no"
>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"main.css"
>
<!-- WebXR Device API (For Chrome M76+), expires 12/04/2019 -->
<meta
http-equiv=
"origin-trial"
content=
"Aq9LklhCLNUveuCr7QTpGpqwCPG817cYHdVyQuJPOZYk47iRB390lUKa5edVmgS1pZSl8HPspElEC/91Fz55dwIAAABTeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJYUkRldmljZU03NiIsImV4cGlyeSI6MTU3NTQxNzU5OX0="
>
</head>
<body>
<div
id=
"container"
></div>
<div
id=
"info"
>
<a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
webvr - 360 6DOF panorama
<br
/>
Written by
<a
href=
"https://orfleisher.com"
target=
"_blank"
rel=
"noopener"
>
@juniorxsound
</a>
. Panorama from
<a
href=
"http://www.meryproject.com/"
target=
"_blank"
rel=
"noopener"
>
reference panoramas
</a>
.
</div>
<script
type=
"x-shader/x-vertex"
id=
"vertexshader"
>
varying
vec2
vUv
;
uniform
sampler2D
depth_map
;
uniform
float
displacement
;
void
main
()
{
vUv
=
uv
;
float
depth
=
texture2D
(
depth_map
,
uv
).
r
;
float
disp
=
displacement
*
depth
;
vec3
offset
=
position
+
(
-
normal
)
*
disp
;
gl_Position
=
projectionMatrix
*
modelViewMatrix
*
vec4
(
offset
,
1.0
);
}
</script>
<script
type=
"x-shader/x-fragment"
id=
"fragmentshader"
>
varying
vec2
vUv
;
uniform
sampler2D
texture
;
void
main
()
{
gl_FragColor
=
texture2D
(
texture
,
vUv
);
}
</script>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
camera
,
scene
,
renderer
,
sphere
,
clock
;
init
();
animate
();
function
init
()
{
var
container
=
document
.
getElementById
(
'
container
'
);
clock
=
new
THREE
.
Clock
();
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x101010
);
camera
=
new
THREE
.
PerspectiveCamera
(
75
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
2000
);
var
cameraRig
=
new
THREE
.
Object3D
();
cameraRig
.
position
.
y
=
-
1.6
;
cameraRig
.
add
(
camera
);
scene
.
add
(
cameraRig
);
// Create the panoramic sphere with the custom shader material
var
panoSphereGeo
=
new
THREE
.
SphereBufferGeometry
(
6
,
256
,
256
);
var
panoSphereMat
=
new
THREE
.
ShaderMaterial
({
uniforms
:
{
texture
:
{
value
:
null
},
depth_map
:
{
value
:
null
},
displacement
:
{
value
:
4
}
},
vertexShader
:
document
.
getElementById
(
'
vertexshader
'
).
textContent
,
fragmentShader
:
document
.
getElementById
(
'
fragmentshader
'
).
textContent
,
side
:
THREE
.
BackSide
});
sphere
=
new
THREE
.
Mesh
(
panoSphereGeo
,
panoSphereMat
);
scene
.
add
(
sphere
);
// Load and assign the texture and depth map
var
loader
=
new
THREE
.
TextureLoader
();
loader
.
load
(
'
./textures/kandao3.jpg
'
,
function
(
texture
)
{
texture
.
minFilter
=
THREE
.
NearestFilter
texture
.
magFilter
=
THREE
.
LinearFilter
texture
.
format
=
THREE
.
RGBFormat
texture
.
generateMipmaps
=
false
sphere
.
material
.
uniforms
.
texture
.
value
=
texture
;
});
loader
.
load
(
'
./textures/kandao3_depthmap.jpg
'
,
function
(
depth
)
{
depth
.
minFilter
=
THREE
.
NearestFilter
depth
.
magFilter
=
THREE
.
LinearFilter
depth
.
format
=
THREE
.
RGBFormat
depth
.
generateMipmaps
=
false
sphere
.
material
.
uniforms
.
depth_map
.
value
=
depth
;
});
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
vr
.
enabled
=
true
;
container
.
appendChild
(
renderer
.
domElement
);
document
.
body
.
appendChild
(
WEBVR
.
createButton
(
renderer
)
);
//
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
}
function
onWindowResize
()
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
function
animate
()
{
renderer
.
setAnimationLoop
(
render
);
}
function
render
()
{
// If we are not presenting move the camera a little so the effect is visible
if
(
!
renderer
.
vr
.
isPresenting
())
{
var
time
=
clock
.
getElapsedTime
();
sphere
.
rotation
.
y
+=
0.001
;
sphere
.
position
.
x
=
Math
.
sin
(
time
)
*
0.2
;
sphere
.
position
.
z
=
Math
.
cos
(
time
)
*
0.2
;
}
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录