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
0227c412
Commit
0227c412
authored
5 months ago
by
MEHIAOUI Mohamed
Browse files
Options
Downloads
Patches
Plain Diff
designer des pommes
parent
65280907
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
MEHIAOUI/index.html
+1
-1
1 addition, 1 deletion
MEHIAOUI/index.html
MEHIAOUI/projet.js
+38
-7
38 additions, 7 deletions
MEHIAOUI/projet.js
with
39 additions
and
8 deletions
MEHIAOUI/index.html
+
1
−
1
View file @
0227c412
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<!-- JQuery pour afficher les erreurs -->
<!-- JQuery pour afficher les erreurs -->
<script
type=
"text/javascript"
src=
"https://code.jquery.com/jquery-3.5.1.min.js"
></script>
<script
type=
"text/javascript"
src=
"https://code.jquery.com/jquery-3.5.1.min.js"
></script>
<!-- Un titre centre -->
<!-- Un titre centre -->
<div
id=
"webGL"
class=
"centre"
></div>
<div
id=
"webGL"
class=
"centre"
>
Juste un bol, des fruits, et des fleurs
</div>
<!-- Mon script avec un chemin relatif -->
<!-- Mon script avec un chemin relatif -->
<script
type=
"module"
src=
"projet.js"
></script>
<script
type=
"module"
src=
"projet.js"
></script>
</body>
</body>
...
...
This diff is collapsed.
Click to expand it.
MEHIAOUI/projet.js
+
38
−
7
View file @
0227c412
...
@@ -80,16 +80,47 @@ function fillScene() {
...
@@ -80,16 +80,47 @@ function fillScene() {
bol
.
position
.
set
(
-
5
,
5
,
5
);
bol
.
position
.
set
(
-
5
,
5
,
5
);
bol
.
rotation
.
x
=
Math
.
PI
;
bol
.
rotation
.
x
=
Math
.
PI
;
//fonction pour creer une pomme
function
createApple
(
x
,
y
,
z
,
color
)
{
function
createApple
(
x
,
y
,
z
,
color
)
{
var
apple
=
new
THREE
.
Mesh
(
new
THREE
.
SphereGeometry
(
1.5
,
22
,
22
),
new
THREE
.
MeshPhongMaterial
({
color
:
color
}));
var
applePoints
=
[];
apple
.
position
.
set
(
x
,
y
,
z
);
applePoints
.
push
(
new
THREE
.
Vector2
(
0
,
0
));
// Base
// tige de la pomme
applePoints
.
push
(
new
THREE
.
Vector2
(
1.2
,
0.4
));
var
tige
=
new
THREE
.
Mesh
(
new
THREE
.
CylinderGeometry
(
0.1
,
0.1
,
1
,
32
),
new
THREE
.
MeshPhongMaterial
({
color
:
0x8B4513
}));
applePoints
.
push
(
new
THREE
.
Vector2
(
1.8
,
1.0
));
tige
.
position
.
set
(
x
,
y
+
1
,
z
);
applePoints
.
push
(
new
THREE
.
Vector2
(
2.1
,
1.8
));
// Plus large vers le centre
window
.
scene
.
add
(
tige
);
applePoints
.
push
(
new
THREE
.
Vector2
(
2.0
,
2.6
));
applePoints
.
push
(
new
THREE
.
Vector2
(
1.7
,
3.1
));
applePoints
.
push
(
new
THREE
.
Vector2
(
1.4
,
3.4
));
// Arrondi progressif
applePoints
.
push
(
new
THREE
.
Vector2
(
1.0
,
3.6
));
applePoints
.
push
(
new
THREE
.
Vector2
(
0.7
,
3.7
));
applePoints
.
push
(
new
THREE
.
Vector2
(
0.5
,
3.65
));
// Début de l'indentation
applePoints
.
push
(
new
THREE
.
Vector2
(
0.3
,
3.5
));
// Légère dépression
applePoints
.
push
(
new
THREE
.
Vector2
(
0.1
,
3.3
));
// Dépression plus marquée
applePoints
.
push
(
new
THREE
.
Vector2
(
0
,
3.2
));
// Haut légèrement incurvé
var
appleGeometry
=
new
THREE
.
LatheGeometry
(
applePoints
,
64
);
// Plus de segments pour plus de douceur
var
appleMaterial
=
new
THREE
.
MeshPhongMaterial
({
color
:
color
,
shininess
:
50
});
var
apple
=
new
THREE
.
Mesh
(
appleGeometry
,
appleMaterial
);
apple
.
position
.
set
(
x
,
y
,
z
);
// Créer la tige avec une légère courbure
var
stemGeometry
=
new
THREE
.
CylinderGeometry
(
0.1
,
0.15
,
0.5
,
16
);
var
stemMaterial
=
new
THREE
.
MeshPhongMaterial
({
color
:
0x8B4513
});
var
stem
=
new
THREE
.
Mesh
(
stemGeometry
,
stemMaterial
);
stem
.
position
.
set
(
x
,
y
+
3.4
,
z
);
stem
.
rotation
.
z
=
Math
.
PI
/
10
;
// Inclinaison réaliste
// Ajouter une petite feuille pour plus de réalisme
var
leafGeometry
=
new
THREE
.
SphereGeometry
(
0.2
,
16
,
8
);
var
leafMaterial
=
new
THREE
.
MeshPhongMaterial
({
color
:
0x228B22
});
var
leaf
=
new
THREE
.
Mesh
(
leafGeometry
,
leafMaterial
);
leaf
.
position
.
set
(
x
+
0.2
,
y
+
3.6
,
z
);
leaf
.
scale
.
set
(
1
,
0.5
,
1
);
// Rendre la feuille plus plate
window
.
scene
.
add
(
apple
);
window
.
scene
.
add
(
apple
);
window
.
scene
.
add
(
stem
);
window
.
scene
.
add
(
leaf
);
}
}
//Remplir le bol de pommes à des positions différentes
//Remplir le bol de pommes à des positions différentes
createApple
(
-
5
,
2
,
5
,
0xFF0000
);
createApple
(
-
5
,
2
,
5
,
0xFF0000
);
createApple
(
-
4
,
4
,
7
,
0x00FF00
);
createApple
(
-
4
,
4
,
7
,
0x00FF00
);
...
...
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