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
ca19c989
Commit
ca19c989
authored
3 months ago
by
HERRY Matteo
Browse files
Options
Downloads
Patches
Plain Diff
table taille + nappe taille + bougeoir position + boussole possition + carré de scène
parent
6656ed9e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
HERRY-M--HERRY-E/TABLO.js
+36
-21
36 additions, 21 deletions
HERRY-M--HERRY-E/TABLO.js
with
36 additions
and
21 deletions
HERRY-M--HERRY-E/TABLO.js
+
36
−
21
View file @
ca19c989
...
...
@@ -56,7 +56,7 @@ function CreationTable() {
var
material
=
new
THREE
.
MeshStandardMaterial
({
color
:
0x8B4513
});
// Tabletop
var
tabletopGeometry
=
new
THREE
.
BoxGeometry
(
6
,
0.2
,
3
);
var
tabletopGeometry
=
new
THREE
.
BoxGeometry
(
7
,
0.2
,
3
);
var
tabletop
=
new
THREE
.
Mesh
(
tabletopGeometry
,
material
);
tabletop
.
position
.
set
(
0
,
2.6
,
0
);
tableGroup
.
add
(
tabletop
);
...
...
@@ -79,6 +79,30 @@ function CreationTable() {
tableGroup
.
position
.
set
(
5
,
0
,
0
);
// Positionner la table à droite
scene
.
add
(
tableGroup
);
}
function
CreationCarré
()
{
// Charger la texture
const
textureLoader
=
new
THREE
.
TextureLoader
();
const
texture
=
textureLoader
.
load
(
'
textures/fond.png
'
);
// Remplace par le chemin de ta texture .png
// Matériau avec la texture
var
material
=
new
THREE
.
MeshStandardMaterial
({
map
:
texture
,
// Appliquer la texture
side
:
THREE
.
DoubleSide
// Voir les faces intérieures aussi
});
// Définir la taille de la boîte
var
boxGeometry
=
new
THREE
.
BoxGeometry
(
40
,
40.01
,
40
);
// Créer la boîte avec la texture
var
box
=
new
THREE
.
Mesh
(
boxGeometry
,
material
);
// Positionner la boîte
box
.
position
.
set
(
5
,
20
,
0
);
// Ajouter la boîte à la scène
scene
.
add
(
box
);
}
function
CreationNappe
()
{
var
clothMaterial
=
new
THREE
.
MeshStandardMaterial
({
...
...
@@ -88,7 +112,7 @@ function CreationNappe() {
});
// Création d'un plan subdivisé pour permettre des déformations
var
clothGeometry
=
new
THREE
.
PlaneGeometry
(
6
.2
,
3.2
,
20
,
20
);
// Légèrement plus grand que la table
var
clothGeometry
=
new
THREE
.
PlaneGeometry
(
7
.2
,
3.2
,
20
,
20
);
// Légèrement plus grand que la table
// Déformation légère pour un effet plus naturel
var
vertices
=
clothGeometry
.
attributes
.
position
;
...
...
@@ -103,22 +127,13 @@ function CreationNappe() {
scene
.
add
(
cloth
);
}
function
ImageDeFond
()
{
const
loader
=
new
THREE
.
TextureLoader
();
loader
.
load
(
'
textures/fond.png
'
,
function
(
texture
)
{
scene
.
background
=
texture
;
},
undefined
,
function
(
err
)
{
console
.
error
(
'
Erreur lors du chargement de la texture :
'
,
err
);
});
}
function
fillScene
()
{
scene
=
new
THREE
.
Scene
();
// LIGHT
var
light
=
new
THREE
.
DirectionalLight
(
0xFFFFFF
,
3
);
var
light
=
new
THREE
.
DirectionalLight
(
0xFFFFFF
,
7
);
light
.
position
.
set
(
1
,
1
,
1
);
scene
.
add
(
light
);
var
light2
=
new
THREE
.
AmbientLight
(
0xFFFFFF
,
1
);
...
...
@@ -211,7 +226,7 @@ var mtlLoader1 = new MTLLoader();
objLoader1
.
load
(
'
boussole.obj
'
,
function
(
object
)
{
normalizeAndPosition
(
object
,
0.5
,
new
THREE
.
Vector3
(
2
.35
,
2.77
,
0.9
));
normalizeAndPosition
(
object
,
0.5
,
new
THREE
.
Vector3
(
2
,
2.77
,
0.9
));
object
.
rotation
.
y
=
5
;
scene
.
add
(
object
);
},
...
...
@@ -255,7 +270,7 @@ var mtlLoader1 = new MTLLoader();
loader6
.
load
(
'
bougeoir.obj
'
,
function
(
object
)
{
normalizeAndPosition
(
object
,
1
,
new
THREE
.
Vector3
(
3.
6
,
2.71
,
-
14
));
normalizeAndPosition
(
object
,
1
,
new
THREE
.
Vector3
(
3.
1
,
2.71
,
-
14
));
var
material
=
new
THREE
.
MeshStandardMaterial
({
color
:
new
THREE
.
Color
(
42
/
255
,
23
/
255
,
13
/
255
),
// Conversion des valeurs RGB (de 0 à 1)
...
...
@@ -283,9 +298,9 @@ var mtlLoader1 = new MTLLoader();
'
verre.obj
'
,
function
(
object
)
{
normalizeAndPosition
(
object
,
0.8
,
new
THREE
.
Vector3
(
2.6
,
3.3
,
-
0.1
));
object
.
rotation
.
x
=
4
;
object
.
rotation
.
y
=
-
0.
2
;
object
.
rotation
.
z
=
1.0
;
object
.
rotation
.
x
=
-
3.3
;
object
.
rotation
.
y
=
-
0.
4
;
object
.
rotation
.
z
=
1.0
2
;
var
material
=
new
THREE
.
MeshPhysicalMaterial
({
color
:
new
THREE
.
Color
(
107
/
255
,
109
/
255
,
115
/
255
),
...
...
@@ -301,7 +316,7 @@ var mtlLoader1 = new MTLLoader();
envMapIntensity
:
2.5
,
// J'ai monté encore plus fort
});
//Création de la caméra pour gérer les reflets
//
Création de la caméra pour gérer les reflets
const
cubeRenderTarget
=
new
THREE
.
WebGLCubeRenderTarget
(
128
);
const
camera
=
new
THREE
.
CubeCamera
(
1
,
1000
,
cubeRenderTarget
);
scene
.
add
(
camera
);
...
...
@@ -316,7 +331,7 @@ var mtlLoader1 = new MTLLoader();
scene
.
add
(
object
);
//Stocker la caméra pour la mettre à jour à chaque frame
//
Stocker la caméra pour la mettre à jour à chaque frame
object
.
userData
.
cubeCamera
=
camera
;
},
function
(
xhr
)
{
...
...
@@ -327,10 +342,10 @@ var mtlLoader1 = new MTLLoader();
}
);
CreationCarré
();
CreationTable
();
CreationNappe
();
ImageDeFond
()
}
function
animate
()
{
...
...
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