-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathARindex9.html
60 lines (52 loc) · 1.7 KB
/
ARindex9.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
<!DOCTYPE html>
<html>
<head>
<title>Three.js Room Model</title>
<style>
body {
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script type="module">
import * as THREE from 'https://unpkg.com/[email protected]/build/three.module.js';
import { OBJLoader } from 'https://cdn.jsdelivr.net/npm/three/examples/jsm/loaders/OBJLoader.js';
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setClearColor(0x333333);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
35,
window.innerWidth / window.innerHeight,
0.1,
20000
);
camera.position.set(0, 0, 5);
const scene = new THREE.Scene();
const lightOne = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(lightOne);
const lightTwo = new THREE.PointLight(0xffffff, 0.5);
scene.add(lightTwo);
const objLoader = new OBJLoader();
objLoader.load("Room-1.obj", function (mesh) {
mesh.traverse(function (node) {
if (node.isMesh) {
node.castShadow = true;
node.receiveShadow = true;
}
});
scene.add(mesh);
mesh.position.set(0, 0, 0); // Позиция модели
mesh.rotation.set(0, Math.PI, 0); // Поворот модели
});
function render() {
renderer.render(scene, camera);
requestAnimationFrame(render);
}
render();
</script>
</body>
</html>