Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
74fdf547
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,发现更多精彩内容 >>
提交
74fdf547
编写于
7月 12, 2019
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JSM: Added module and TS file for WebVR.
上级
7b5e5a0e
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
299 addition
and
32 deletion
+299
-32
docs/manual/en/introduction/How-to-create-VR-content.html
docs/manual/en/introduction/How-to-create-VR-content.html
+1
-1
docs/manual/zh/introduction/How-to-create-VR-content.html
docs/manual/zh/introduction/How-to-create-VR-content.html
+1
-1
editor/js/Menubar.View.js
editor/js/Menubar.View.js
+1
-9
editor/js/libs/app.js
editor/js/libs/app.js
+1
-1
examples/js/vr/WebVR.js
examples/js/vr/WebVR.js
+26
-8
examples/jsm/vr/WebVR.d.ts
examples/jsm/vr/WebVR.d.ts
+11
-0
examples/jsm/vr/WebVR.js
examples/jsm/vr/WebVR.js
+245
-0
examples/webvr_ballshooter.html
examples/webvr_ballshooter.html
+1
-1
examples/webvr_cubes.html
examples/webvr_cubes.html
+1
-1
examples/webvr_dragging.html
examples/webvr_dragging.html
+1
-1
examples/webvr_lorenzattractor.html
examples/webvr_lorenzattractor.html
+1
-1
examples/webvr_paint.html
examples/webvr_paint.html
+1
-1
examples/webvr_panorama.html
examples/webvr_panorama.html
+1
-1
examples/webvr_rollercoaster.html
examples/webvr_rollercoaster.html
+1
-1
examples/webvr_sandbox.html
examples/webvr_sandbox.html
+1
-1
examples/webvr_sculpt.html
examples/webvr_sculpt.html
+1
-1
examples/webvr_video.html
examples/webvr_video.html
+1
-1
examples/webvr_vive_paint.html
examples/webvr_vive_paint.html
+1
-1
examples/webvr_vive_sculpt.html
examples/webvr_vive_sculpt.html
+1
-1
utils/modularize.js
utils/modularize.js
+1
-0
未找到文件。
docs/manual/en/introduction/How-to-create-VR-content.html
浏览文件 @
74fdf547
...
...
@@ -25,7 +25,7 @@
</p>
<code>
<
script src="/path/to/WebVR.js"
><
/script
>
;
import { WEBVR } from 'three/examples/jsm/vr/WebVR.js'
;
</code>
<p>
...
...
docs/manual/zh/introduction/How-to-create-VR-content.html
浏览文件 @
74fdf547
...
...
@@ -24,7 +24,7 @@
</p>
<code>
<
script src="/path/to/WebVR.js"
><
/script
>
;
import { WEBVR } from 'three/examples/jsm/vr/WebVR.js'
;
</code>
<p>
*WEBVR.createButton()*做了两件重要的事情:首先,它创建了一个按钮,指示了VR的兼容性;
...
...
editor/js/Menubar.View.js
浏览文件 @
74fdf547
...
...
@@ -23,15 +23,7 @@ Menubar.View = function ( editor ) {
option
.
setTextContent
(
'
VR mode
'
);
option
.
onClick
(
function
()
{
if
(
WEBVR
.
isAvailable
()
===
true
)
{
editor
.
signals
.
enterVR
.
dispatch
();
}
else
{
alert
(
'
WebVR not available
'
);
}
editor
.
signals
.
enterVR
.
dispatch
();
}
);
options
.
add
(
option
);
...
...
editor/js/libs/app.js
浏览文件 @
74fdf547
...
...
@@ -112,7 +112,7 @@ var APP = {
if
(
renderer
.
vr
.
enabled
)
{
dom
.
appendChild
(
WEBVR
.
createButton
(
renderer
)
);
dom
.
appendChild
(
THREE
.
WEBVR
.
createButton
(
renderer
)
);
}
...
...
examples/js/vr/WebVR.js
浏览文件 @
74fdf547
...
...
@@ -5,7 +5,7 @@
* Based on @tojiro's vr-samples-utils.js
*/
var
WEBVR
=
{
THREE
.
WEBVR
=
{
createButton
:
function
(
renderer
,
options
)
{
...
...
@@ -25,8 +25,17 @@ var WEBVR = {
button
.
textContent
=
'
ENTER VR
'
;
button
.
onmouseenter
=
function
()
{
button
.
style
.
opacity
=
'
1.0
'
;
};
button
.
onmouseleave
=
function
()
{
button
.
style
.
opacity
=
'
0.5
'
;
};
button
.
onmouseenter
=
function
()
{
button
.
style
.
opacity
=
'
1.0
'
;
};
button
.
onmouseleave
=
function
()
{
button
.
style
.
opacity
=
'
0.5
'
;
};
button
.
onclick
=
function
()
{
...
...
@@ -38,7 +47,7 @@ var WEBVR = {
}
function
showEnterXR
(
device
)
{
function
showEnterXR
(
/*device*/
)
{
var
currentSession
=
null
;
...
...
@@ -53,7 +62,7 @@ var WEBVR = {
}
function
onSessionEnded
(
event
)
{
function
onSessionEnded
(
/*event*/
)
{
currentSession
.
removeEventListener
(
'
end
'
,
onSessionEnded
);
...
...
@@ -74,8 +83,17 @@ var WEBVR = {
button
.
textContent
=
'
ENTER XR
'
;
button
.
onmouseenter
=
function
()
{
button
.
style
.
opacity
=
'
1.0
'
;
};
button
.
onmouseleave
=
function
()
{
button
.
style
.
opacity
=
'
0.5
'
;
};
button
.
onmouseenter
=
function
()
{
button
.
style
.
opacity
=
'
1.0
'
;
};
button
.
onmouseleave
=
function
()
{
button
.
style
.
opacity
=
'
0.5
'
;
};
button
.
onclick
=
function
()
{
...
...
@@ -167,7 +185,7 @@ var WEBVR = {
},
false
);
window
.
addEventListener
(
'
vrdisplaydisconnect
'
,
function
(
event
)
{
window
.
addEventListener
(
'
vrdisplaydisconnect
'
,
function
(
/*event*/
)
{
showVRNotFound
();
...
...
examples/jsm/vr/WebVR.d.ts
0 → 100644
浏览文件 @
74fdf547
import
{
WebGLRenderer
}
from
'
../../../src/Three
'
;
export
interface
WEBVROptions
{
referenceSpaceType
:
string
;
}
export
namespace
WEBVR
{
export
function
createButton
(
renderer
:
WebGLRenderer
,
options
:
WEBVROptions
);
}
examples/jsm/vr/WebVR.js
0 → 100644
浏览文件 @
74fdf547
/**
* @author mrdoob / http://mrdoob.com
* @author Mugen87 / https://github.com/Mugen87
*
* Based on @tojiro's vr-samples-utils.js
*/
var
WEBVR
=
{
createButton
:
function
(
renderer
,
options
)
{
if
(
options
&&
options
.
referenceSpaceType
)
{
renderer
.
vr
.
setReferenceSpaceType
(
options
.
referenceSpaceType
);
}
function
showEnterVR
(
device
)
{
button
.
style
.
display
=
''
;
button
.
style
.
cursor
=
'
pointer
'
;
button
.
style
.
left
=
'
calc(50% - 50px)
'
;
button
.
style
.
width
=
'
100px
'
;
button
.
textContent
=
'
ENTER VR
'
;
button
.
onmouseenter
=
function
()
{
button
.
style
.
opacity
=
'
1.0
'
;
};
button
.
onmouseleave
=
function
()
{
button
.
style
.
opacity
=
'
0.5
'
;
};
button
.
onclick
=
function
()
{
device
.
isPresenting
?
device
.
exitPresent
()
:
device
.
requestPresent
(
[
{
source
:
renderer
.
domElement
}
]
);
};
renderer
.
vr
.
setDevice
(
device
);
}
function
showEnterXR
(
/*device*/
)
{
var
currentSession
=
null
;
function
onSessionStarted
(
session
)
{
session
.
addEventListener
(
'
end
'
,
onSessionEnded
);
renderer
.
vr
.
setSession
(
session
);
button
.
textContent
=
'
EXIT XR
'
;
currentSession
=
session
;
}
function
onSessionEnded
(
/*event*/
)
{
currentSession
.
removeEventListener
(
'
end
'
,
onSessionEnded
);
renderer
.
vr
.
setSession
(
null
);
button
.
textContent
=
'
ENTER XR
'
;
currentSession
=
null
;
}
//
button
.
style
.
display
=
''
;
button
.
style
.
cursor
=
'
pointer
'
;
button
.
style
.
left
=
'
calc(50% - 50px)
'
;
button
.
style
.
width
=
'
100px
'
;
button
.
textContent
=
'
ENTER XR
'
;
button
.
onmouseenter
=
function
()
{
button
.
style
.
opacity
=
'
1.0
'
;
};
button
.
onmouseleave
=
function
()
{
button
.
style
.
opacity
=
'
0.5
'
;
};
button
.
onclick
=
function
()
{
if
(
currentSession
===
null
)
{
navigator
.
xr
.
requestSession
(
'
immersive-vr
'
).
then
(
onSessionStarted
);
}
else
{
currentSession
.
end
();
}
};
}
function
disableButton
()
{
button
.
style
.
display
=
''
;
button
.
style
.
cursor
=
'
auto
'
;
button
.
style
.
left
=
'
calc(50% - 75px)
'
;
button
.
style
.
width
=
'
150px
'
;
button
.
onmouseenter
=
null
;
button
.
onmouseleave
=
null
;
button
.
onclick
=
null
;
}
function
showVRNotFound
()
{
disableButton
();
button
.
textContent
=
'
VR NOT FOUND
'
;
renderer
.
vr
.
setDevice
(
null
);
}
function
showXRNotFound
()
{
disableButton
();
button
.
textContent
=
'
XR NOT FOUND
'
;
}
function
stylizeElement
(
element
)
{
element
.
style
.
position
=
'
absolute
'
;
element
.
style
.
bottom
=
'
20px
'
;
element
.
style
.
padding
=
'
12px 6px
'
;
element
.
style
.
border
=
'
1px solid #fff
'
;
element
.
style
.
borderRadius
=
'
4px
'
;
element
.
style
.
background
=
'
rgba(0,0,0,0.1)
'
;
element
.
style
.
color
=
'
#fff
'
;
element
.
style
.
font
=
'
normal 13px sans-serif
'
;
element
.
style
.
textAlign
=
'
center
'
;
element
.
style
.
opacity
=
'
0.5
'
;
element
.
style
.
outline
=
'
none
'
;
element
.
style
.
zIndex
=
'
999
'
;
}
if
(
'
xr
'
in
navigator
&&
'
supportsSession
'
in
navigator
.
xr
)
{
var
button
=
document
.
createElement
(
'
button
'
);
button
.
style
.
display
=
'
none
'
;
stylizeElement
(
button
);
navigator
.
xr
.
supportsSession
(
'
immersive-vr
'
).
then
(
showEnterXR
).
catch
(
showXRNotFound
);
return
button
;
}
else
if
(
'
getVRDisplays
'
in
navigator
)
{
var
button
=
document
.
createElement
(
'
button
'
);
button
.
style
.
display
=
'
none
'
;
stylizeElement
(
button
);
window
.
addEventListener
(
'
vrdisplayconnect
'
,
function
(
event
)
{
showEnterVR
(
event
.
display
);
},
false
);
window
.
addEventListener
(
'
vrdisplaydisconnect
'
,
function
(
/*event*/
)
{
showVRNotFound
();
},
false
);
window
.
addEventListener
(
'
vrdisplaypresentchange
'
,
function
(
event
)
{
button
.
textContent
=
event
.
display
.
isPresenting
?
'
EXIT VR
'
:
'
ENTER VR
'
;
},
false
);
window
.
addEventListener
(
'
vrdisplayactivate
'
,
function
(
event
)
{
event
.
display
.
requestPresent
(
[
{
source
:
renderer
.
domElement
}
]
);
},
false
);
navigator
.
getVRDisplays
()
.
then
(
function
(
displays
)
{
if
(
displays
.
length
>
0
)
{
showEnterVR
(
displays
[
0
]
);
}
else
{
showVRNotFound
();
}
}
).
catch
(
showVRNotFound
);
return
button
;
}
else
{
var
message
=
document
.
createElement
(
'
a
'
);
message
.
href
=
'
https://webvr.info
'
;
message
.
innerHTML
=
'
WEBVR NOT SUPPORTED
'
;
message
.
style
.
left
=
'
calc(50% - 90px)
'
;
message
.
style
.
width
=
'
180px
'
;
message
.
style
.
textDecoration
=
'
none
'
;
stylizeElement
(
message
);
return
message
;
}
}
};
export
{
WEBVR
};
examples/webvr_ballshooter.html
浏览文件 @
74fdf547
...
...
@@ -13,13 +13,13 @@
</div>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
BoxLineGeometry
}
from
'
./jsm/geometries/BoxLineGeometry.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
camera
,
scene
,
renderer
;
var
controller1
,
controller2
;
...
...
examples/webvr_cubes.html
浏览文件 @
74fdf547
...
...
@@ -13,13 +13,13 @@
</div>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
BoxLineGeometry
}
from
'
./jsm/geometries/BoxLineGeometry.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
clock
=
new
THREE
.
Clock
();
...
...
examples/webvr_dragging.html
浏览文件 @
74fdf547
...
...
@@ -13,11 +13,11 @@
</div>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
container
;
var
camera
,
scene
,
renderer
;
...
...
examples/webvr_lorenzattractor.html
浏览文件 @
74fdf547
...
...
@@ -9,11 +9,11 @@
<body>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
camera
,
scene
,
renderer
;
var
attractor
,
light
;
...
...
examples/webvr_paint.html
浏览文件 @
74fdf547
...
...
@@ -13,11 +13,11 @@
</div>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
container
;
var
camera
,
scene
,
renderer
;
...
...
examples/webvr_panorama.html
浏览文件 @
74fdf547
...
...
@@ -8,11 +8,11 @@
</head>
<body>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
camera
;
var
renderer
;
...
...
examples/webvr_rollercoaster.html
浏览文件 @
74fdf547
...
...
@@ -9,13 +9,13 @@
<body>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
RollerCoasterGeometry
,
RollerCoasterShadowGeometry
,
RollerCoasterLiftersGeometry
,
TreesGeometry
,
SkyGeometry
}
from
'
./jsm/misc/RollerCoaster.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
...
...
examples/webvr_sandbox.html
浏览文件 @
74fdf547
...
...
@@ -9,7 +9,6 @@
<body>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
...
...
@@ -17,6 +16,7 @@
import
{
Lensflare
,
LensflareElement
}
from
'
./jsm/objects/Lensflare.js
'
;
import
{
Reflector
}
from
'
./jsm/objects/Reflector.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
camera
,
scene
,
renderer
;
...
...
examples/webvr_sculpt.html
浏览文件 @
74fdf547
...
...
@@ -13,13 +13,13 @@
</div>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
MarchingCubes
}
from
'
./jsm/objects/MarchingCubes.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
container
;
var
camera
,
scene
,
renderer
;
...
...
examples/webvr_video.html
浏览文件 @
74fdf547
...
...
@@ -15,7 +15,6 @@
</div>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<video
id=
"video"
loop
muted
crossOrigin=
"anonymous"
webkit-playsinline
style=
"display:none"
>
<source
src=
"textures/MaryOculus.webm"
>
...
...
@@ -25,6 +24,7 @@
<script
type=
"module"
>
import
*
as
THREE
from
'
../build/three.module.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
camera
,
scene
,
renderer
;
...
...
examples/webvr_vive_paint.html
浏览文件 @
74fdf547
...
...
@@ -13,7 +13,6 @@
</div>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
...
...
@@ -21,6 +20,7 @@
import
{
OBJLoader
}
from
'
./jsm/loaders/OBJLoader.js
'
;
import
{
PaintViveController
}
from
'
./jsm/vr/PaintViveController.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
container
;
var
camera
,
scene
,
renderer
;
...
...
examples/webvr_vive_sculpt.html
浏览文件 @
74fdf547
...
...
@@ -13,7 +13,6 @@
</div>
<script
src=
"js/vr/HelioWebXRPolyfill.js"
></script>
<script
src=
"js/vr/WebVR.js"
></script>
<script
type=
"module"
>
...
...
@@ -22,6 +21,7 @@
import
{
OBJLoader
}
from
'
./jsm/loaders/OBJLoader.js
'
;
import
{
MarchingCubes
}
from
'
./jsm/objects/MarchingCubes.js
'
;
import
{
ViveController
}
from
'
./jsm/vr/ViveController.js
'
;
import
{
WEBVR
}
from
'
./jsm/vr/WebVR.js
'
;
var
container
;
var
camera
,
scene
,
renderer
;
...
...
utils/modularize.js
浏览文件 @
74fdf547
...
...
@@ -254,6 +254,7 @@ var files = [
{
path
:
'
vr/deprecated/GearVRController.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
vr/PaintViveController.js
'
,
dependencies
:
[
{
name
:
'
ViveController
'
,
path
:
'
vr/ViveController.js
'
}
],
ignoreList
:
[]
},
{
path
:
'
vr/ViveController.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
vr/WebVR.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
WebGL.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录