Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webgl25
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Villard PierreFrederic
webgl25
Commits
2052c026
Commit
2052c026
authored
4 months ago
by
DESERT Romain
Browse files
Options
Downloads
Patches
Plain Diff
ajout FPS/IPS
parent
a4eb5abe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ALVARIZA-BILLAR_DESERT_KANY/projet.js
+20
-4
20 additions, 4 deletions
ALVARIZA-BILLAR_DESERT_KANY/projet.js
with
20 additions
and
4 deletions
ALVARIZA-BILLAR_DESERT_KANY/projet.js
+
20
−
4
View file @
2052c026
...
...
@@ -9,6 +9,9 @@ import {OBJLoader} from 'three/addons/loaders/OBJLoader.js';
import
{
OrbitControls
}
from
'
three/addons/controls/OrbitControls.js
'
;
import
*
as
dat
from
'
https://cdn.jsdelivr.net/npm/dat.gui@0.7.9/build/dat.gui.module.js
'
;
import
{
MTLLoader
}
from
'
three/addons/loaders/MTLLoader.js
'
;
import
Stats
from
'
https://cdn.jsdelivr.net/npm/three@0.130.1/examples/jsm/libs/stats.module.js
'
;
window
.
scene
=
new
THREE
.
Scene
();
...
...
@@ -18,6 +21,10 @@ var cameraControls;
var
clock
=
new
THREE
.
Clock
();
var
beton
;
var
car
;
var
stats
=
new
Stats
();
stats
.
showPanel
(
0
);
// 0: afficher le panneau des FPS
document
.
body
.
appendChild
(
stats
.
dom
);
window
.
carSpeed
=
50
;
window
.
carMoving
=
true
;
...
...
@@ -73,7 +80,7 @@ function fillScene() {
scene
.
add
(
road
);
// DALLE DE BÉTON
// DALLE DE BÉTON
(sous la maisonnette)
var
betonTexture
=
texture
.
load
(
'
textures/beton.jpg
'
);
betonTexture
.
wrapS
=
THREE
.
RepeatWrapping
;
betonTexture
.
wrapT
=
THREE
.
RepeatWrapping
;
...
...
@@ -90,6 +97,9 @@ function fillScene() {
scene
.
add
(
beton
);
// CAPSULE EN BÉTON (sous les pompes à essence)
var
capsuleLength
=
5700
;
// Longueur de la capsule
var
capsuleHeight
=
800
;
// Largeur de la capsule
...
...
@@ -122,13 +132,13 @@ function fillScene() {
const
grayMaterial
=
new
THREE
.
MeshStandardMaterial
({
color
:
0x888888
});
// Gris
// Bas du poteau (rouge)
const
bottomPoleGeometry
=
new
THREE
.
CylinderGeometry
(
30
,
30
,
1
5
00
,
32
);
const
bottomPoleGeometry
=
new
THREE
.
CylinderGeometry
(
30
,
30
,
1
0
00
,
32
);
const
bottomPole
=
new
THREE
.
Mesh
(
bottomPoleGeometry
,
redMaterial
);
bottomPole
.
position
.
set
(
-
5000
,
750
,
6000
);
scene
.
add
(
bottomPole
);
// Haut du poteau (gris)
const
topPoleGeometry
=
new
THREE
.
CylinderGeometry
(
3
0
,
30
,
15
00
,
32
);
const
topPoleGeometry
=
new
THREE
.
CylinderGeometry
(
2
0
,
30
,
20
00
,
32
);
const
topPole
=
new
THREE
.
Mesh
(
topPoleGeometry
,
grayMaterial
);
topPole
.
position
.
set
(
-
5000
,
2250
,
6000
);
scene
.
add
(
topPole
);
...
...
@@ -191,7 +201,9 @@ function fillScene() {
loadCar
();
}
// Charger la voiture
/**
* Charge la voiture
*/
function
loadCar
()
{
new
OBJLoader
().
load
(
'
car.obj
'
,
function
(
object
)
{
car
=
object
;
...
...
@@ -240,6 +252,8 @@ function init() {
function
animate
()
{
window
.
requestAnimationFrame
(
animate
);
stats
.
begin
();
if
(
car
&&
window
.
carMoving
)
{
car
.
position
.
z
+=
window
.
carSpeed
;
// Avance sur l'axe Z
...
...
@@ -250,6 +264,8 @@ function animate() {
}
render
();
stats
.
end
();
}
function
render
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment