-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5载入船型.html
193 lines (169 loc) · 4.75 KB
/
5载入船型.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<<<<<<< HEAD
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
</style>
</head>
<body></body>
<script
async
src="https://unpkg.com/[email protected]/dist/es-module-shims.js"
></script>
<!-- 映射器,恶心 -->
<script type="importmap">
{
"imports": {
"three": "/webGpu/3D/node_modules/three/build/three.module.js",
"three/addons/": "/webGpu/3D/node_modules/three/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from "three";
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
// console.log("GLTFLoader", GLTFLoader);
// 渲染器
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x808080);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.gammaOuput = true;
document.body.appendChild(renderer.domElement);
// 摄像机
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
100
);
camera.position.set(0, 0, 1);
// 创建场景
const scene = new THREE.Scene();
// 我们还需要光照,
const directionalLight = new THREE.DirectionalLight(0xffffff, 2);
directionalLight.position.set(0, 0, 100);
scene.add(directionalLight);
const loader = new GLTFLoader();
let root;
loader.load(
"/webGpu/3D/assets/small_cargo_ship/scene.gltf",
function (glb) {
root = glb.scene;
root.position.set(0,0,0)
root.scale.set(.7, .7, .7)
root.rotation.set(.30, 0, 0)
scene.add(root);
// console.log(glb);
},
(xhr) => {
console.log(xhr);
},
function (error) {
console.error(error);
}
);
// 如果不调用动画,则不会显示模型。。。
function animate(params) {
requestAnimationFrame(animate);
root.rotation.y +=.01
renderer.render(scene, camera);
}
animate()
</script>
</html>
=======
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
</style>
</head>
<body></body>
<script
async
src="https://unpkg.com/[email protected]/dist/es-module-shims.js"
></script>
<!-- 映射器,恶心 -->
<script type="importmap">
{
"imports": {
"three": "/webGpu/3D/node_modules/three/build/three.module.js",
"three/addons/": "/webGpu/3D/node_modules/three/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from "three";
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
// console.log("GLTFLoader", GLTFLoader);
// 渲染器
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x808080);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.gammaOuput = true;
document.body.appendChild(renderer.domElement);
// 摄像机
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
100
);
camera.position.set(0, 0, 1);
// 创建场景
const scene = new THREE.Scene();
// 我们还需要光照,
const directionalLight = new THREE.DirectionalLight(0xffffff, 2);
directionalLight.position.set(0, 0, 100);
scene.add(directionalLight);
const loader = new GLTFLoader();
let root;
loader.load(
"/webGpu/3D/assets/small_cargo_ship/scene.gltf",
function (glb) {
root = glb.scene;
root.position.set(0,0,0)
root.scale.set(.7, .7, .7)
root.rotation.set(.30, 0, 0)
scene.add(root);
// console.log(glb);
},
(xhr) => {
console.log(xhr);
},
function (error) {
console.error(error);
}
);
// 如果不调用动画,则不会显示模型。。。
function animate(params) {
requestAnimationFrame(animate);
root.rotation.y +=.01
renderer.render(scene, camera);
}
animate()
</script>
</html>
>>>>>>> 22ba171124f2bc4c6d85100406aca3bb0b7013dc