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
07bfc3da
Commit
07bfc3da
authored
4 months ago
by
Eykime
Browse files
Options
Downloads
Patches
Plain Diff
Fonctions principal pour Three
parent
2037d6c2
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
COGNET/main.js
+86
-0
86 additions, 0 deletions
COGNET/main.js
with
86 additions
and
0 deletions
COGNET/main.js
+
86
−
0
View file @
07bfc3da
"
use strict
"
;
import
*
as
THREE
from
'
three
'
;
import
{
OBJLoader
}
from
'
three/addons/loaders/OBJLoader.js
'
;
import
{
OrbitControls
}
from
'
three/addons/controls/OrbitControls.js
'
;
import
{
dat
}
from
'
/lib/dat.gui.min.js
'
;
import
{
Coordinates
}
from
'
./lib/Coordinates.js
'
;
import
renderer
from
"
three/src/renderers/common/Renderer
"
;
let
camera
,
renderer
;
let
cameraControls
;
let
clock
=
new
THREE
.
Clock
();
let
scene
=
new
THREE
.
Scene
();
/**
*
*/
function
fillScene
()
{
}
/**
*
*/
function
addToDOM
()
{
let
container
=
document
.
getElementById
(
'
webGL
'
);
let
canvas
=
container
.
getElementsByTagName
(
'
canvas
'
);
if
(
canvas
.
length
>
0
)
{
container
.
removeChild
(
canvas
[
0
]);
}
container
.
appendChild
(
renderer
.
domElement
);
}
/**
*
*/
function
init
()
{
let
canvasWidth
=
window
.
innerWidth
;
let
canvasHeight
=
window
.
innerHeight
;
let
canvasRatio
=
canvasWidth
/
canvasHeight
;
// RENDERER
renderer
=
new
THREE
.
WebGLRenderer
(
{
antialias
:
true
}
);
renderer
.
setSize
(
canvasWidth
,
canvasHeight
);
renderer
.
setClearColor
(
0xFFFFFF
,
1.0
);
// Camera: Y up, X right, Z up
camera
=
new
THREE
.
PerspectiveCamera
(
1
,
canvasRatio
,
50
,
150
);
camera
.
position
.
set
(
0.5
,
0.5
,
100
);
// CONTROLS
cameraControls
=
new
OrbitControls
(
camera
,
renderer
.
domElement
);
cameraControls
.
target
.
set
(
0.5
,
0.5
,
0
);
}
/**
*
*/
function
animate
()
{
window
.
requestAnimationFrame
(
animate
);
render
();
}
/**
*
*/
function
render
()
{
let
delta
=
clock
.
getDelta
();
cameraControls
.
update
(
delta
);
renderer
.
render
(
scene
,
camera
);
}
try
{
init
();
fillScene
();
addToDOM
();
animate
();
}
catch
(
e
)
{
const
errorReport
=
"
Your program encountered an unrecoverable error, can not 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