map finit

This commit is contained in:
Baptiste Rebillard 2022-03-10 00:34:02 +01:00
parent 8821cc0313
commit ba8029e8b8
7 changed files with 58 additions and 125 deletions

View file

@ -64,9 +64,9 @@ $desc = [
//c'est peu compréhensible mais l'ancien systeme (avant Baptiste Rébillard <- moi) utilisait inutilement une base de donnée
if (isset($_GET['function'])) {
if ($_GET['function'] == "get_map_info")
if (htmlspecialchars($_GET['function']) == "get_map_info")
get_map_info();
elseif ($_GET['function'] == "get_map_selectors")
elseif (htmlspecialchars($_GET['function']) == "get_map_selectors")
get_map_selectors();
}
@ -87,7 +87,7 @@ function get_map_selectors() {
function get_map_info() {
if (isset($_GET['selector'])) {
$select = $_GET['selector'];
$select = htmlspecialchars($_GET['selector']);
header('Content-Type: application/json');

View file

Before

Width:  |  Height:  |  Size: 565 KiB

After

Width:  |  Height:  |  Size: 565 KiB

View file

@ -2,6 +2,8 @@
let hoverColor = "#e9b82f";
let normalColor = "#efbd95";
var rep2 = "assets/map/";
function get_name(id){
return id.replace("map-", "");
}
@ -16,7 +18,7 @@ function clicked(elem){
'selector': get_name(elem.id),
};
return $.ajax({
url: 'ajax.php',
url: rep2+'ajax.php',
data: object,
method: 'get'
}).done(function (data) {

View file

@ -3,6 +3,7 @@
* Code : Ronan Bonnet
*
*/
var rep = "assets/map/";
import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.119.1/build/three.module.js';
@ -84,7 +85,7 @@ function init() {
//
var loader = new GLTFLoader(loadingManager);
loader.load('map3D.glb', function(gltf) {
loader.load(rep+'map3D.glb', function(gltf) {
var object = gltf.scene;
gltf.scene.scale.set( 2, 2, 2 );
gltf.scene.position.x = 0; //Position (x = right+ left-)
@ -162,7 +163,7 @@ function getSelectors() {
'info': info,
}
return $.ajax({
url: 'ajax.php',
url: rep+'ajax.php',
data: object,
method: 'get',
success: function(data){
@ -204,7 +205,7 @@ function handleClickOnBuilding(x,y) {
'selector': selector,
};
return $.ajax({
url: 'ajax.php',
url: rep+'ajax.php',
data: object,
method: 'get'
}).done(function (data) {

110
map.php
View file

@ -1,74 +1,59 @@
<?php
ob_start(); // Start reading html
require_once 'map/ajax.php';
require_once 'assets/map/ajax.php';
?>
<main>
<h1>Le Plan</h1>
<p>
Voici le plan de ton nouveau campus, que tu vas connaître par cœur en quelques jours !
</p>
<p>
<strong>Clique sur un bâtiment pour voir les infos.</strong>
</p>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
<style>
.hidden {
display: none;
}
</style>
<div id="maps_button">
<button onclick="enable3DMap()" class="main-button">Map 3D</button>
<button onclick="enable2DMap()" class="main-button">Map 2D</button>
</div>
<section id="loading-screen">
<div class="loader"></div>
</section>
<div id="maps" class="">
<script src="map/script_map3d.js" type="module"></script>
<div id="map" class="hidden">
<?php echo file_get_contents("map/map2d.svg"); ?>
<canvas id="canvasID"></canvas>
</div>
</div>
<script>
function enable3DMap() {
var map3d = document.querySelector('#maps #map3d');
var map = document.querySelector('#maps #map');
map3d.classList.add("hidden");
map.classList.add("hidden");
map3d.classList.remove("hidden");
}
function enable2DMap() {
var map3d = document.querySelector('#maps #map3d');
var map = document.querySelector('#maps #map');
map.classList.add("hidden");
map3d.classList.add("hidden");
map.classList.remove("hidden");
}
</script>
<script type="text/javascript" src="map/script_map2d.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
<style>
.hidden {
display: none;
}
</style>
<div id="maps_button">
<button onclick="enable3DMap()" class="main-button">Map 3D</button>
<button onclick="enable2DMap()" class="main-button">Map 2D</button>
</div>
<section id="loading-screen">
<div class="loader"></div>
</section>
<div id="maps" class="">
<script src="assets/map/script_map3d.js" type="module"></script>
<div id="map" class="hidden">
<?php echo file_get_contents("assets/map/map2d.svg"); ?>
<canvas id="canvasID"></canvas>
</div>
</div>
<script>
function enable3DMap() {
var map3d = document.querySelector('#maps #map3d');
var map = document.querySelector('#maps #map');
map3d.classList.add("hidden");
map.classList.add("hidden");
map3d.classList.remove("hidden");
}
function enable2DMap() {
var map3d = document.querySelector('#maps #map3d');
var map = document.querySelector('#maps #map');
map.classList.add("hidden");
map3d.classList.add("hidden");
map.classList.remove("hidden");
}
</script>
<script type="text/javascript" src="assets/map/script_map2d.js"></script>
<p>
Une petite note sur le numéro des salles : sur ton emploi du temps, le bâtiment est marqué en premier, et
@ -83,6 +68,7 @@ function enable2DMap() {
Map</a>.
</p>
</main>
<?php
$infopage = ["", "Plan", ob_get_clean(), "", "map"]; //relativepath, pagetitle, pagecontent, pagescript, pagename | cf structure/template.php ligne 2 à 6
include("structure/template.php");

View file

@ -1,56 +0,0 @@
<?php
require_once 'ajax.php';
?>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
<style>
.hidden {
display: none;
}
</style>
<div id="maps_button">
<button onclick="enable3DMap()" class="main-button">Map 3D</button>
<button onclick="enable2DMap()" class="main-button">Map 2D</button>
</div>
<section id="loading-screen">
<div class="loader"></div>
</section>
<div id="maps" class="">
<script src="script_map3d.js" type="module"></script>
<div id="map" class="hidden">
<?php echo file_get_contents("map2d.svg"); ?>
<canvas id="canvasID"></canvas>
</div>
</div>
<script>
function enable3DMap() {
var map3d = document.querySelector('#maps #map3d');
var map = document.querySelector('#maps #map');
map3d.classList.add("hidden");
map.classList.add("hidden");
map3d.classList.remove("hidden");
}
function enable2DMap() {
var map3d = document.querySelector('#maps #map3d');
var map = document.querySelector('#maps #map');
map.classList.add("hidden");
map3d.classList.add("hidden");
map.classList.remove("hidden");
}
</script>
<script type="text/javascript" src="script_map2d.js"></script>