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
bb109d55
Commit
bb109d55
authored
3 months ago
by
DESERT Romain
Browse files
Options
Downloads
Patches
Plain Diff
j'ai corrigé ma betise, désolé encore
parent
58364c19
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ALGUL/checklistProjet.md
+1
-1
1 addition, 1 deletion
ALGUL/checklistProjet.md
ALGUL/index.js
+149
-171
149 additions, 171 deletions
ALGUL/index.js
with
150 additions
and
172 deletions
ALGUL/checklistProjet.md
+
1
−
1
View file @
bb109d55
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
-
[ ] Géométrie
-
[ ] Géométrie
-
[X] Couleur
-
[X] Couleur
-
[ ] Transparence
-
[ ] Transparence
-
[
X
] Eclairage
-
[
] Eclairage
-
[X] Ombres portées
-
[X] Ombres portées
-
[] Position de la caméra
-
[] Position de la caméra
-
[X] Brouillard
-
[X] Brouillard
...
...
This diff is collapsed.
Click to expand it.
ALGUL/index.js
+
149
−
171
View file @
bb109d55
...
@@ -16,7 +16,7 @@ camera.position.set(380, 200, 30);
...
@@ -16,7 +16,7 @@ camera.position.set(380, 200, 30);
// RENDERER
// RENDERER
const
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
const
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
renderer
.
shadowMap
.
enabled
=
true
;
renderer
.
shadowMap
.
enabled
=
true
;
renderer
.
shadowMap
.
type
=
THREE
.
PCFSoftShadowMap
;
renderer
.
shadowMap
.
type
=
THREE
.
PCFSoftShadowMap
;
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
...
@@ -30,142 +30,148 @@ controls.maxDistance = 2000;
...
@@ -30,142 +30,148 @@ controls.maxDistance = 2000;
controls
.
minDistance
=
50
;
controls
.
minDistance
=
50
;
controls
.
target
.
set
(
0
,
0
,
0
);
controls
.
target
.
set
(
0
,
0
,
0
);
// Directional Light (Soleil)
// LUMIÈRES
const
light
=
new
THREE
.
DirectionalLight
(
0xffffff
,
1
);
light
.
position
.
set
(
10
,
50
,
50
);
scene
.
add
(
light
);
const
ambientLight
=
new
THREE
.
AmbientLight
(
0x404040
,
2
);
scene
.
add
(
ambientLight
);
const
hemisphereLight
=
new
THREE
.
HemisphereLight
(
0x87CEEB
,
0x222222
,
1
);
scene
.
add
(
hemisphereLight
);
// SOLEIL
const
sunGeometry
=
new
THREE
.
SphereGeometry
(
50
,
32
,
32
);
const
sunMaterial
=
new
THREE
.
MeshBasicMaterial
({
color
:
0xffcc00
});
const
sun
=
new
THREE
.
Mesh
(
sunGeometry
,
sunMaterial
);
sun
.
position
.
set
(
-
700
,
800
,
-
1000
);
scene
.
add
(
sun
);
const
sunLight
=
new
THREE
.
DirectionalLight
(
0xffddaa
,
3
);
const
sunLight
=
new
THREE
.
DirectionalLight
(
0xffddaa
,
3
);
sunLight
.
position
.
set
(
500
,
5
00
,
-
5
00
);
sunLight
.
position
.
set
(
500
,
10
00
,
-
10
00
);
sunLight
.
castShadow
=
true
;
sunLight
.
castShadow
=
true
;
sunLight
.
shadow
.
mapSize
.
width
=
4096
;
sunLight
.
shadow
.
mapSize
.
width
=
2048
;
sunLight
.
shadow
.
mapSize
.
height
=
4096
;
sunLight
.
shadow
.
mapSize
.
height
=
2048
;
sunLight
.
shadow
.
camera
.
near
=
0.5
;
sunLight
.
shadow
.
camera
.
near
=
1
;
sunLight
.
shadow
.
camera
.
far
=
5
000
;
sunLight
.
shadow
.
camera
.
far
=
3
000
;
sunLight
.
shadow
.
camera
.
left
=
-
1000
;
sunLight
.
shadow
.
camera
.
left
=
-
1000
;
sunLight
.
shadow
.
camera
.
right
=
1000
;
sunLight
.
shadow
.
camera
.
right
=
1000
;
sunLight
.
shadow
.
camera
.
top
=
1000
;
sunLight
.
shadow
.
camera
.
top
=
1000
;
sunLight
.
shadow
.
camera
.
bottom
=
-
1000
;
sunLight
.
shadow
.
camera
.
bottom
=
-
1000
;
scene
.
add
(
sunLight
);
scene
.
add
(
sunLight
);
// Lumière ambiante (éclaire toute la scène)
const
ambientLight
=
new
THREE
.
AmbientLight
(
0x404040
,
2
);
scene
.
add
(
ambientLight
);
// Spotlight
const
spotLight
=
new
THREE
.
SpotLight
(
0xffffff
,
5
,
500
,
Math
.
PI
/
6
,
0.5
,
2
);
spotLight
.
position
.
set
(
250
,
200
,
-
50
);
spotLight
.
castShadow
=
true
;
scene
.
add
(
spotLight
);
const
loader
=
new
GLTFLoader
();
const
loader
=
new
GLTFLoader
();
loader
.
load
(
'
modeles/old_bridge.glb
'
,
function
(
gltf
)
{
loader
.
load
(
'
modeles/old_bridge.glb
'
,
function
(
gltf
)
{
const
bridge
=
gltf
.
scene
;
const
bridge
=
gltf
.
scene
;
bridge
.
traverse
((
node
)
=>
{
bridge
.
traverse
((
node
)
=>
{
if
(
node
.
isMesh
)
{
if
(
node
.
isMesh
)
{
node
.
castShadow
=
true
;
node
.
castShadow
=
true
;
node
.
receiveShadow
=
true
;
node
.
receiveShadow
=
true
;
}
}
});
});
scene
.
add
(
bridge
);
scene
.
add
(
bridge
);
bridge
.
position
.
set
(
0
,
100
,
0
);
bridge
.
position
.
set
(
0
,
100
,
0
);
bridge
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
bridge
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
bridge
.
rotation
.
y
=
Math
.
PI
/
2
;
bridge
.
rotation
.
y
=
Math
.
PI
/
2
;
controls
.
target
.
copy
(
bridge
.
position
);
controls
.
target
.
copy
(
bridge
.
position
);
controls
.
update
();
controls
.
update
();
},
undefined
,
function
(
error
)
{
},
undefined
,
function
(
error
)
{
console
.
error
(
"
Erreur de chargement du pont :
"
,
error
);
console
.
error
(
"
Erreur de chargement du pont :
"
,
error
);
});
});
loader
.
load
(
'
modeles/old_bridge.glb
'
,
function
(
gltf
)
{
loader
.
load
(
'
modeles/old_bridge.glb
'
,
function
(
gltf
)
{
const
bridge2
=
gltf
.
scene
;
const
bridge2
=
gltf
.
scene
;
bridge2
.
traverse
((
node
)
=>
{
bridge2
.
traverse
((
node
)
=>
{
if
(
node
.
isMesh
)
{
if
(
node
.
isMesh
)
{
node
.
castShadow
=
true
;
node
.
castShadow
=
true
;
node
.
receiveShadow
=
true
;
node
.
receiveShadow
=
true
;
}
}
});
});
scene
.
add
(
bridge2
);
scene
.
add
(
bridge2
);
bridge2
.
position
.
set
(
-
950
,
100
,
0
);
bridge2
.
position
.
set
(
-
950
,
100
,
0
);
bridge2
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
bridge2
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
bridge2
.
rotation
.
y
=
Math
.
PI
/
2
;
bridge2
.
rotation
.
y
=
Math
.
PI
/
2
;
controls
.
target
.
copy
(
bridge2
.
position
);
controls
.
target
.
copy
(
bridge2
.
position
);
controls
.
update
();
controls
.
update
();
},
undefined
,
function
(
error
)
{
},
undefined
,
function
(
error
)
{
console
.
error
(
"
Erreur de chargement du pont :
"
,
error
);
console
.
error
(
"
Erreur de chargement du pont :
"
,
error
);
});
});
loader
.
load
(
'
modeles/old_bridge.glb
'
,
function
(
gltf
)
{
loader
.
load
(
'
modeles/old_bridge.glb
'
,
function
(
gltf
)
{
const
bridge3
=
gltf
.
scene
;
const
bridge3
=
gltf
.
scene
;
bridge3
.
traverse
((
node
)
=>
{
bridge3
.
traverse
((
node
)
=>
{
if
(
node
.
isMesh
)
{
if
(
node
.
isMesh
)
{
node
.
castShadow
=
true
;
node
.
castShadow
=
true
;
node
.
receiveShadow
=
true
;
node
.
receiveShadow
=
true
;
}
}
});
});
scene
.
add
(
bridge3
);
scene
.
add
(
bridge3
);
bridge3
.
position
.
set
(
100
,
100
,
126
);
bridge3
.
position
.
set
(
100
,
100
,
126
);
bridge3
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
bridge3
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
bridge3
.
rotation
.
y
=
Math
.
PI
/
-
2
;
bridge3
.
rotation
.
y
=
Math
.
PI
/
-
2
;
controls
.
target
.
copy
(
bridge3
.
position
);
controls
.
target
.
copy
(
bridge3
.
position
);
controls
.
update
();
controls
.
update
();
},
undefined
,
function
(
error
)
{
},
undefined
,
function
(
error
)
{
console
.
error
(
"
Erreur de chargement du pont :
"
,
error
);
console
.
error
(
"
Erreur de chargement du pont :
"
,
error
);
});
});
loader
.
load
(
'
modeles/old_bridge.glb
'
,
function
(
gltf
)
{
loader
.
load
(
'
modeles/old_bridge.glb
'
,
function
(
gltf
)
{
const
bridge4
=
gltf
.
scene
;
const
bridge4
=
gltf
.
scene
;
bridge4
.
traverse
((
node
)
=>
{
bridge4
.
traverse
((
node
)
=>
{
if
(
node
.
isMesh
)
{
if
(
node
.
isMesh
)
{
node
.
castShadow
=
true
;
node
.
castShadow
=
true
;
node
.
receiveShadow
=
true
;
node
.
receiveShadow
=
true
;
}
}
});
});
scene
.
add
(
bridge4
);
scene
.
add
(
bridge4
);
bridge4
.
position
.
set
(
-
850
,
100
,
126
);
bridge4
.
position
.
set
(
-
850
,
100
,
126
);
bridge4
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
bridge4
.
scale
.
set
(
0.5
,
0.5
,
0.5
);
bridge4
.
rotation
.
y
=
Math
.
PI
/
-
2
;
bridge4
.
rotation
.
y
=
Math
.
PI
/
-
2
;
controls
.
target
.
copy
(
bridge4
.
position
);
controls
.
target
.
copy
(
bridge4
.
position
);
controls
.
update
();
controls
.
update
();
},
undefined
,
function
(
error
)
{
},
undefined
,
function
(
error
)
{
console
.
error
(
"
Erreur de chargement du pont :
"
,
error
);
console
.
error
(
"
Erreur de chargement du pont :
"
,
error
);
});
});
loader
.
load
(
'
modeles/bateau.glb
'
,
function
(
gltf
)
{
loader
.
load
(
'
modeles/bateau.glb
'
,
function
(
gltf
)
{
const
boat1
=
gltf
.
scene
.
clone
();
const
boat1
=
gltf
.
scene
.
clone
();
boat1
.
traverse
((
node
)
=>
{
boat1
.
traverse
((
node
)
=>
{
if
(
node
.
isMesh
)
{
if
(
node
.
isMesh
)
{
node
.
castShadow
=
true
;
node
.
castShadow
=
true
;
node
.
receiveShadow
=
true
;
node
.
receiveShadow
=
true
;
}
}
});
});
const
boat2
=
gltf
.
scene
.
clone
();
const
boat2
=
gltf
.
scene
.
clone
();
boat2
.
traverse
((
node
)
=>
{
boat2
.
traverse
((
node
)
=>
{
if
(
node
.
isMesh
)
{
if
(
node
.
isMesh
)
{
node
.
castShadow
=
true
;
node
.
castShadow
=
true
;
node
.
receiveShadow
=
true
;
node
.
receiveShadow
=
true
;
}
}
});
});
boat1
.
position
.
set
(
-
300
,
1
,
-
500
);
boat1
.
position
.
set
(
-
300
,
1
,
-
500
);
boat1
.
scale
.
set
(
0.3
,
0.3
,
0.3
);
boat1
.
scale
.
set
(
0.3
,
0.3
,
0.3
);
boat2
.
position
.
set
(
-
200
,
1
,
-
600
);
boat2
.
position
.
set
(
-
200
,
1
,
-
600
);
boat2
.
scale
.
set
(
0.3
,
0.3
,
0.3
);
boat2
.
scale
.
set
(
0.3
,
0.3
,
0.3
);
boat2
.
rotation
.
y
=
Math
.
PI
/
4
;
boat2
.
rotation
.
y
=
Math
.
PI
/
4
;
scene
.
add
(
boat1
);
scene
.
add
(
boat1
);
scene
.
add
(
boat2
);
scene
.
add
(
boat2
);
},
undefined
,
function
(
error
)
{
},
undefined
,
function
(
error
)
{
console
.
error
(
"
Erreur de chargement des bateaux :
"
,
error
);
console
.
error
(
"
Erreur de chargement des bateaux :
"
,
error
);
});
});
const
textureLoader
=
new
THREE
.
TextureLoader
();
const
textureLoader
=
new
THREE
.
TextureLoader
();
...
@@ -176,8 +182,8 @@ groundTexture.offset.set(0, 0);
...
@@ -176,8 +182,8 @@ groundTexture.offset.set(0, 0);
const
groundMaterial
=
new
THREE
.
MeshLambertMaterial
({
map
:
groundTexture
});
const
groundMaterial
=
new
THREE
.
MeshLambertMaterial
({
map
:
groundTexture
});
const
solidGround
=
new
THREE
.
Mesh
(
const
solidGround
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneGeometry
(
10000
,
10000
,
100
,
100
),
new
THREE
.
PlaneGeometry
(
10000
,
10000
,
100
,
100
),
groundMaterial
groundMaterial
);
);
solidGround
.
rotation
.
x
=
-
Math
.
PI
/
2
;
solidGround
.
rotation
.
x
=
-
Math
.
PI
/
2
;
solidGround
.
position
.
y
=
-
2
;
solidGround
.
position
.
y
=
-
2
;
...
@@ -187,35 +193,34 @@ scene.add(solidGround);
...
@@ -187,35 +193,34 @@ scene.add(solidGround);
const
objLoader
=
new
OBJLoader
();
const
objLoader
=
new
OBJLoader
();
objLoader
.
load
(
'
modeles/scream/Scream 3D-bl.obj
'
,
function
(
obj
)
{
objLoader
.
load
(
'
modeles/scream/Scream 3D-bl.obj
'
,
function
(
obj
)
{
const
screamTexture
=
textureLoader
.
load
(
'
modeles/scream/Scream Texture.png
'
);
const
screamTexture
=
textureLoader
.
load
(
'
modeles/scream/Scream Texture.png
'
);
obj
.
traverse
((
child
)
=>
{
obj
.
traverse
((
child
)
=>
{
if
(
child
.
isMesh
)
{
if
(
child
.
isMesh
)
{
child
.
material
=
new
THREE
.
MeshBasicMaterial
({
map
:
screamTexture
});
child
.
material
=
new
THREE
.
MeshBasicMaterial
({
map
:
screamTexture
});
child
.
castShadow
=
true
;
child
.
castShadow
=
true
;
child
.
receiveShadow
=
true
;
child
.
receiveShadow
=
true
;
}
}
});
});
obj
.
position
.
set
(
250
,
-
60
,
-
30
);
obj
.
position
.
set
(
250
,
-
60
,
-
30
);
obj
.
scale
.
set
(
20
,
20
,
20
);
obj
.
scale
.
set
(
20
,
20
,
20
);
obj
.
rotation
.
z
=
Math
.
PI
/
2.5
;
obj
.
rotation
.
z
=
Math
.
PI
/
2.5
;
obj
.
rotation
.
y
=
Math
.
PI
/
-
5
;
obj
.
rotation
.
y
=
Math
.
PI
/
-
5
;
spotLight
.
target
=
obj
;
scene
.
add
(
obj
);
scene
.
add
(
obj
);
},
undefined
,
function
(
error
)
{
},
undefined
,
function
(
error
)
{
console
.
error
(
"
Erreur de chargement du modèle Scream :
"
,
error
);
console
.
error
(
"
Erreur de chargement du modèle Scream :
"
,
error
);
});
});
const
skyTexture
=
textureLoader
.
load
(
'
textures/skybox2.png
'
);
const
skyTexture
=
textureLoader
.
load
(
'
textures/skybox2.png
'
);
const
skyMaterial
=
new
THREE
.
MeshBasicMaterial
({
const
skyMaterial
=
new
THREE
.
MeshBasicMaterial
({
map
:
skyTexture
,
map
:
skyTexture
,
side
:
THREE
.
BackSide
side
:
THREE
.
BackSide
});
});
const
skySphere
=
new
THREE
.
Mesh
(
const
skySphere
=
new
THREE
.
Mesh
(
new
THREE
.
SphereGeometry
(
3000
,
32
,
32
),
new
THREE
.
SphereGeometry
(
3000
,
32
,
32
),
skyMaterial
skyMaterial
);
);
skySphere
.
rotation
.
x
=
Math
.
PI
/
2
;
skySphere
.
rotation
.
x
=
Math
.
PI
/
2
;
skySphere
.
rotation
.
z
=
Math
.
PI
/
-
1
;
skySphere
.
rotation
.
z
=
Math
.
PI
/
-
1
;
...
@@ -236,48 +241,21 @@ sprite2.scale.set(50, 100, 50);
...
@@ -236,48 +241,21 @@ sprite2.scale.set(50, 100, 50);
scene
.
add
(
sprite2
);
scene
.
add
(
sprite2
);
const
gui
=
new
dat
.
GUI
();
const
gui
=
new
dat
.
GUI
();
const
cameraFolder
=
gui
.
addFolder
(
"
Zoom & Brouillard
"
);
gui
.
add
(
camera
,
'
fov
'
,
10
,
100
).
name
(
'
Zoom
'
).
onChange
(()
=>
{
cameraFolder
.
add
(
camera
,
"
fov
"
,
10
,
100
).
name
(
"
Zoom
"
).
onChange
(()
=>
{
camera
.
updateProjectionMatrix
();
camera
.
updateProjectionMatrix
();
});
cameraFolder
.
add
(
scene
.
fog
,
"
density
"
,
0
,
0.0015
).
name
(
"
Brouillard
"
);
const
sunFolder
=
gui
.
addFolder
(
"
Soleil
"
);
const
sunColor
=
{
color
:
sunLight
.
color
.
getHex
()
};
sunFolder
.
add
(
sunLight
,
"
intensity
"
,
0
,
10
).
name
(
"
Intensité Soleil
"
);
sunFolder
.
addColor
(
sunColor
,
"
color
"
).
name
(
"
Couleur Soleil
"
).
onChange
((
value
)
=>
{
sunLight
.
color
.
set
(
value
);
});
sunFolder
.
add
(
sunLight
.
position
,
"
x
"
,
-
2000
,
2000
).
name
(
"
Position X
"
);
sunFolder
.
add
(
sunLight
.
position
,
"
y
"
,
-
2000
,
2000
).
name
(
"
Position Y
"
);
sunFolder
.
add
(
sunLight
.
position
,
"
z
"
,
-
2000
,
2000
).
name
(
"
Position Z
"
);
const
ambientFolder
=
gui
.
addFolder
(
"
Lumière Ambiante
"
);
const
ambientColor
=
{
color
:
ambientLight
.
color
.
getHex
()
};
ambientFolder
.
add
(
ambientLight
,
"
intensity
"
,
0
,
5
).
name
(
"
Intensité Ambiante
"
);
ambientFolder
.
addColor
(
ambientColor
,
"
color
"
).
name
(
"
Couleur Ambiante
"
).
onChange
((
value
)
=>
{
ambientLight
.
color
.
set
(
value
);
});
const
spotFolder
=
gui
.
addFolder
(
"
Spotlight sur Le Cri
"
);
const
spotColor
=
{
color
:
spotLight
.
color
.
getHex
()
};
spotFolder
.
add
(
spotLight
,
"
intensity
"
,
0
,
10
).
name
(
"
Intensité Spotlight
"
);
spotFolder
.
addColor
(
spotColor
,
"
color
"
).
name
(
"
Couleur Spotlight
"
).
onChange
((
value
)
=>
{
spotLight
.
color
.
set
(
value
);
});
});
spotFolder
.
add
(
spotLight
.
position
,
"
x
"
,
-
500
,
500
).
name
(
"
Position X
"
);
gui
.
add
(
sunLight
,
'
intensity
'
,
0
,
10
).
name
(
'
Soleil Intensité
'
);
spotFolder
.
add
(
spotLight
.
position
,
"
y
"
,
50
,
500
).
name
(
"
Position Y
"
);
gui
.
add
(
scene
.
fog
,
'
density
'
,
0
,
0.0015
).
name
(
'
Brouillard
'
);
spotFolder
.
add
(
spotLight
.
position
,
"
z
"
,
-
500
,
500
).
name
(
"
Position Z
"
);
function
animate
()
{
function
animate
()
{
requestAnimationFrame
(
animate
);
requestAnimationFrame
(
animate
);
controls
.
update
();
controls
.
update
();
renderer
.
render
(
scene
,
camera
);
renderer
.
render
(
scene
,
camera
);
}
}
animate
();
animate
();
window
.
addEventListener
(
'
resize
'
,
()
=>
{
window
.
addEventListener
(
'
resize
'
,
()
=>
{
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
camera
.
updateProjectionMatrix
();
});
});
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