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
RIFI Zaynab
webgl25
Commits
db7ce626
Commit
db7ce626
authored
2 months ago
by
DeRycke Leanne
Browse files
Options
Downloads
Patches
Plain Diff
Add new file
parent
5e51962c
No related branches found
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
DUFOUR/chambre.js
+106
-0
106 additions, 0 deletions
DUFOUR/chambre.js
with
106 additions
and
0 deletions
DUFOUR/chambre.js
0 → 100644
+
106
−
0
View file @
db7ce626
"
use strict
"
;
import
*
as
THREE
from
'
three
'
;
import
{
OrbitControls
}
from
'
three/addons/controls/OrbitControls.js
'
;
import
{
Coordinates
}
from
'
./lib/Coordinates.js
'
;
var
camera
,
renderer
;
var
windowScale
;
window
.
scene
=
new
THREE
.
Scene
();
var
cameraControls
;
var
clock
=
new
THREE
.
Clock
();
var
transparentCube
;
// Objet autour duquel la caméra tournera
function
fillScene
()
{
scene
=
new
THREE
.
Scene
();
scene
.
fog
=
new
THREE
.
Fog
(
0x808080
,
2000
,
4000
);
// LIGHTS
scene
.
add
(
new
THREE
.
AmbientLight
(
0x222222
));
var
light
=
new
THREE
.
DirectionalLight
(
0xFFFFFF
,
0.7
);
light
.
position
.
set
(
200
,
500
,
500
);
scene
.
add
(
light
);
light
=
new
THREE
.
DirectionalLight
(
0xFFFFFF
,
0.9
);
light
.
position
.
set
(
-
200
,
-
100
,
-
400
);
scene
.
add
(
light
);
Coordinates
.
drawGround
({
size
:
1000
});
// Cube Transparent au Centre
var
transparentMaterial
=
new
THREE
.
MeshBasicMaterial
({
transparent
:
true
,
opacity
:
0
});
var
cubeGeometry
=
new
THREE
.
BoxGeometry
(
100
,
100
,
100
);
transparentCube
=
new
THREE
.
Mesh
(
cubeGeometry
,
transparentMaterial
);
transparentCube
.
position
.
set
(
0
,
50
,
0
);
// Position du cube
scene
.
add
(
transparentCube
);
// Ajout du lit
var
bed
=
new
THREE
.
TextureLoader
().
load
(
'
lit.png
'
);
var
bedMaterial
=
new
THREE
.
MeshBasicMaterial
({
map
:
bed
});
var
bedSizeLength
=
400
,
bedSizeHeight
=
200
,
bedSizeWidth
=
200
;
var
bedGeometry
=
new
THREE
.
BoxGeometry
(
bedSizeLength
,
bedSizeHeight
,
bedSizeWidth
);
bed
=
new
THREE
.
Mesh
(
bedGeometry
,
bedMaterial
);
//bed = new THREE.Mesh(bedGeometry);
bed
.
position
.
set
(
200
,
100
,
425
);
window
.
scene
.
add
(
bed
);
}
function
init
()
{
var
canvasWidth
=
846
;
var
canvasHeight
=
494
;
var
canvasRatio
=
canvasWidth
/
canvasHeight
;
// RENDERER
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
renderer
.
gammaInput
=
true
;
renderer
.
gammaOutput
=
true
;
renderer
.
setSize
(
canvasWidth
,
canvasHeight
);
renderer
.
setClearColor
(
0xAAAAAA
,
1.0
);
// CAMERA
camera
=
new
THREE
.
PerspectiveCamera
(
45
,
canvasRatio
,
1
,
4000
);
camera
.
position
.
set
(
-
500
,
125
,
-
100
);
camera
.
lookAt
(
new
THREE
.
Vector3
(
0
,
0
,
0
));
// CONTROLS (L'utilisateur peut tourner la caméra)
cameraControls
=
new
OrbitControls
(
camera
,
renderer
.
domElement
);
cameraControls
.
enableDamping
=
true
;
// Ajoute un effet d'inertie
cameraControls
.
dampingFactor
=
0.05
;
cameraControls
.
rotateSpeed
=
1.0
;
}
function
addToDOM
()
{
var
container
=
document
.
getElementById
(
'
webGL
'
);
var
canvas
=
container
.
getElementsByTagName
(
'
canvas
'
);
if
(
canvas
.
length
>
0
)
{
container
.
removeChild
(
canvas
[
0
]);
}
container
.
appendChild
(
renderer
.
domElement
);
}
function
animate
()
{
requestAnimationFrame
(
animate
);
render
();
}
function
render
()
{
var
delta
=
clock
.
getDelta
();
cameraControls
.
update
();
// Mise à jour des contrôles de la caméra
renderer
.
render
(
window
.
scene
,
camera
);
}
// Lancement du programme
try
{
init
();
fillScene
();
animate
();
addToDOM
();
}
catch
(
e
)
{
var
errorReport
=
"
Your program encountered an unrecoverable error, cannot draw on canvas. Error was:<br/><br/>
"
;
$
(
'
#webGL
'
).
append
(
errorReport
+
e
);
}
\ No newline at end of file
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