Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
entrega-coches-igev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jonschi
entrega-coches-igev
Commits
c0fed678
Commit
c0fed678
authored
Mar 13, 2022
by
jonschi
Browse files
Options
Downloads
Patches
Plain Diff
add tireNormalMap and call render every tick
parent
2cbe2a4d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/script.js
+21
-4
21 additions, 4 deletions
src/script.js
static/textures/tireNormalMap.jpg
+0
-0
0 additions, 0 deletions
static/textures/tireNormalMap.jpg
with
21 additions
and
4 deletions
src/script.js
+
21
−
4
View file @
c0fed678
...
...
@@ -6,7 +6,7 @@ import { Material, RGBA_ASTC_10x10_Format } from 'three'
// Loading
const
textureLoader
=
new
THREE
.
TextureLoader
()
// TODO: load some texture
const
tireTexture
=
textureLoader
.
load
(
'
/textures/tireNormalMap.jpg
'
)
// Debug
const
gui
=
new
dat
.
GUI
()
...
...
@@ -26,17 +26,20 @@ const tireGeometry = new THREE.TorusGeometry(.7, .2, 16, 100)
const
tireMaterial
=
new
THREE
.
MeshStandardMaterial
()
tireMaterial
.
metalness
=
0.7
tireMaterial
.
roughness
=
0.2
tireMaterial
.
color
=
new
THREE
.
Color
(
0x888888
)
tireMaterial
.
normalMap
=
tireTexture
tireMaterial
.
color
=
new
THREE
.
Color
(
0xffffff
)
// Mesh
const
tireMesh
=
new
THREE
.
Mesh
(
tireGeometry
,
tireMaterial
)
scene
.
add
(
tireMesh
)
// Lights
const
pointLight
=
new
THREE
.
PointLight
(
0xffffff
,
0.1
)
pointLight
.
position
.
set
(
2
,
3
,
4
);
pointLight
.
position
.
set
(
2
,
3
,
4
)
pointLight
.
intensity
=
0.3
scene
.
add
(
pointLight
)
/**
...
...
@@ -87,5 +90,19 @@ renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2))
/**
* Render
*/
const
clock
=
new
THREE
.
Clock
()
const
tick
=
()
=>
{
const
elapsedTime
=
clock
.
getElapsedTime
()
// Update objects
tireMesh
.
rotation
.
y
=
.
5
*
elapsedTime
// Render
renderer
.
render
(
scene
,
camera
)
// Call tick again on the next frame
window
.
requestAnimationFrame
(
tick
)
}
tick
()
This diff is collapsed.
Click to expand it.
static/textures/tireNormalMap.jpg
0 → 100644
+
0
−
0
View file @
c0fed678
146 KiB
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
sign in
to comment