Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
程序员秋风
360-sneakers-viewer
提交
9344d0ec
3
360-sneakers-viewer
项目概览
程序员秋风
/
360-sneakers-viewer
通知
2689
Star
92
Fork
43
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
3
360-sneakers-viewer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9344d0ec
编写于
3年前
作者:
H
huayifeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init: repo
上级
master
无相关合并请求
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
100 addition
and
0 deletion
+100
-0
index-draco.html
index-draco.html
+100
-0
未找到文件。
index-draco.html
0 → 100644
浏览文件 @
9344d0ec
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - glTF 2.0 - variants
</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=
"https://cdn.jsdelivr.net/gh/mrdoob/three.js@r130/examples/main.css"
>
</head>
<body>
<script
type=
"module"
>
import
*
as
THREE
from
'
https://cdn.jsdelivr.net/npm/three@0.129.0/build/three.module.js
'
;
import
{
OrbitControls
}
from
'
https://cdn.jsdelivr.net/gh/mrdoob/three.js@r130/examples/jsm/controls/OrbitControls.js
'
;
import
{
GLTFLoader
}
from
'
https://cdn.jsdelivr.net/gh/mrdoob/three.js@r130/examples/jsm/loaders/GLTFLoader.js
'
;
import
{
DRACOLoader
}
from
'
https://cdn.jsdelivr.net/gh/mrdoob/three.js@r130/examples/jsm/loaders/DRACOLoader.js
'
let
camera
,
scene
,
renderer
;
init
();
render
();
function
init
()
{
const
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
// 设置一个透视摄像机
camera
=
new
THREE
.
PerspectiveCamera
(
45
,
window
.
innerWidth
/
window
.
innerHeight
,
0.25
,
1000
);
// 设置相机的位置
camera
.
position
.
set
(
0
,
1.5
,
-
30.0
);
scene
=
new
THREE
.
Scene
();
setTimeout
(()
=>
{
// 设置灯光
const
directionalLight
=
new
THREE
.
AmbientLight
(
0xffffff
,
4
);
scene
.
add
(
directionalLight
);
directionalLight
.
position
.
set
(
2
,
5
,
5
);
},
3000
);
// 加载模型
const
gltfloader
=
new
GLTFLoader
();
const
draco
=
new
DRACOLoader
();
draco
.
setDecoderPath
(
'
https://www.gstatic.com/draco/v1/decoders/
'
);
gltfloader
.
setDRACOLoader
(
draco
);
gltfloader
.
setPath
(
'
assets/obj4/
'
);
gltfloader
.
load
(
'
er4-1.glb
'
,
function
(
gltf
)
{
gltf
.
scene
.
scale
.
set
(
0.2
,
0.2
,
0.2
);
//设置缩放
gltf
.
scene
.
rotation
.
set
(
-
Math
.
PI
/
2
,
0
,
0
)
// 设置角度
const
Orbit
=
new
THREE
.
Object3D
();
Orbit
.
add
(
gltf
.
scene
);
Orbit
.
rotation
.
set
(
0
,
Math
.
PI
/
2
,
0
);
scene
.
add
(
Orbit
);
render
();
});
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
const
controls
=
new
OrbitControls
(
camera
,
renderer
.
domElement
);
controls
.
addEventListener
(
'
change
'
,
render
);
controls
.
minDistance
=
2
;
// 限制距离
controls
.
maxDistance
=
10
;
controls
.
target
.
set
(
0
,
0
,
0
);
// 旋转中心点
controls
.
minPolarAngle
=
0.3
// 设置最小旋转角度
controls
.
maxPolarAngle
=
Math
.
PI
/
2
-
Math
.
PI
/
10
controls
.
update
();
window
.
addEventListener
(
'
resize
'
,
onWindowResize
);
}
function
onWindowResize
()
{
// 重新渲染
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
render
();
}
function
render
()
{
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
反馈
建议
客服
返回
顶部