This repository has been archived by the owner on Jul 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
89 lines (68 loc) · 2.39 KB
/
index.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
<html>
<head>
<title>Transept de la cathédrale d'Amiens</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body style="margin: 0">
<!--<div id="code" style="visibility: hidden">
Entrez le code
</div>-->
<script type="importmap">
{
"imports": {"three": "./Libs/three.module.js"}
}
</script>
<script type="module">
import * as THREE from 'three';
import GameLoop from "./Programmes/GameLoop.js";
import Player from "./Programmes/Player/Player.js";
import PlayerInput from "./Programmes/Player/PlayerInput.js";
import { CharacterController } from "./Programmes/Packages/PMG/PMG.js";
import Collision from "./Programmes/Collision.js";
import Scene from "./Programmes/Scene.js";
/**@type {HTMLDivElement}*/
let container;
/**@type {THREE.PerspectiveCamera}*/
let camera;
/**@type {THREE.Scene}*/
let scene;
/**@type {THREE.WebGLRenderer}*/
let rendu;
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function Init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.01, 100);
// Scene
scene = new THREE.Scene();
Scene.load(scene);
// Player
let playerObject = Scene.getPlayerModel(scene, camera);
playerObject.position.set(0, 1.5, 0);
let playerInput = new PlayerInput(0);
let player = new Player(playerObject, playerInput);
let characterController = new CharacterController(player);
// Collision
Collision.setPlaygroundZone(5, 20, 11);
// WebGL
rendu = new THREE.WebGLRenderer();
rendu.setSize(window.innerWidth, window.innerHeight);
container.appendChild(rendu.domElement);
window.addEventListener('resize', onWindowResize, false);
container.addEventListener('click', () => container.requestPointerLock(), false);
GameLoop.add(Afficher);
GameLoop.update();
}
function Afficher() {
rendu.render(scene, camera);
}
Init();
//Animer();
</script>
</body>
</html>