Skip to content
Snippets Groups Projects
Commit 27065b9e authored by jonschi's avatar jonschi
Browse files

add some comments to threejs script

parent 6d067307
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -24,12 +24,14 @@ const carFlatGeometry = new THREE.BoxGeometry(6,0.5,3) ...@@ -24,12 +24,14 @@ const carFlatGeometry = new THREE.BoxGeometry(6,0.5,3)
// Materials // Materials
// Create a material for the tire that is black and uses a tire texture
const tireMaterial = new THREE.MeshStandardMaterial() const tireMaterial = new THREE.MeshStandardMaterial()
tireMaterial.metalness = 0.5 tireMaterial.metalness = 0.5
tireMaterial.roughness = 0.4 tireMaterial.roughness = 0.4
tireMaterial.normalMap = tireTexture tireMaterial.normalMap = tireTexture
tireMaterial.color = new THREE.Color(0x888888) tireMaterial.color = new THREE.Color(0x888888)
// Create a material for the Car that is green, metallic and uses a metal texture
const carMaterial = new THREE.MeshStandardMaterial() const carMaterial = new THREE.MeshStandardMaterial()
carMaterial.metalness = 0.5 carMaterial.metalness = 0.5
carMaterial.roughness = 0.2 carMaterial.roughness = 0.2
...@@ -43,25 +45,30 @@ const carHeightMesh = new THREE.Mesh(carHeightGeometry, carMaterial) ...@@ -43,25 +45,30 @@ const carHeightMesh = new THREE.Mesh(carHeightGeometry, carMaterial)
carHeightMesh.name = "Car High Mesh" carHeightMesh.name = "Car High Mesh"
scene.add(carHeightMesh) scene.add(carHeightMesh)
// Add the flat part of the car as a child to the root mesh
const carFlatMesh = new THREE.Mesh(carFlatGeometry, carMaterial) const carFlatMesh = new THREE.Mesh(carFlatGeometry, carMaterial)
carFlatMesh.name = 'Car Flat Mesh' carFlatMesh.name = 'Car Flat Mesh'
carHeightMesh.add(carFlatMesh) carHeightMesh.add(carFlatMesh)
// Add the first tire to the root mesh
const tireMesh1 = new THREE.Mesh(tireGeometry, tireMaterial) const tireMesh1 = new THREE.Mesh(tireGeometry, tireMaterial)
tireMesh1.name = 'Tire 1 Mesh' tireMesh1.name = 'Tire 1 Mesh'
tireMesh1.position.set(-2,-1.2,1) tireMesh1.position.set(-2,-1.2,1)
carHeightMesh.add(tireMesh1) carHeightMesh.add(tireMesh1)
// Add the second tire to the root mesh
const tireMesh2 = new THREE.Mesh(tireGeometry, tireMaterial) const tireMesh2 = new THREE.Mesh(tireGeometry, tireMaterial)
tireMesh2.name = 'Tire 2 Mesh' tireMesh2.name = 'Tire 2 Mesh'
tireMesh2.position.set(-2,-1.2,-1) tireMesh2.position.set(-2,-1.2,-1)
carHeightMesh.add(tireMesh2) carHeightMesh.add(tireMesh2)
// Add the third tire to the root mesh
const tireMesh3 = new THREE.Mesh(tireGeometry, tireMaterial) const tireMesh3 = new THREE.Mesh(tireGeometry, tireMaterial)
tireMesh3.name = 'Tire 3 Mesh' tireMesh3.name = 'Tire 3 Mesh'
tireMesh3.position.set(2,-1.2,-1) tireMesh3.position.set(2,-1.2,-1)
carHeightMesh.add(tireMesh3) carHeightMesh.add(tireMesh3)
// Add the fourth tire to the root mesh
const tireMesh4 = new THREE.Mesh(tireGeometry, tireMaterial) const tireMesh4 = new THREE.Mesh(tireGeometry, tireMaterial)
tireMesh4.name = 'Tire 4 Mesh' tireMesh4.name = 'Tire 4 Mesh'
tireMesh4.position.set(2,-1.2,1) tireMesh4.position.set(2,-1.2,1)
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment