Last active
April 18, 2022 04:09
-
-
Save Badestrand/421217eb786c62a9ae3b68898e3ec3f5 to your computer and use it in GitHub Desktop.
aviator2-simplegun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const metalMaterial = new THREE.MeshStandardMaterial({ | |
color: 0x222222, | |
flatShading: true, | |
roughness: 0.5, | |
metalness: 1.0 | |
}) | |
class SimpleGun { | |
static createMesh() { | |
const BODY_RADIUS = 3 | |
const BODY_LENGTH = 20 | |
const full = new THREE.Group() | |
const body = new THREE.Mesh( | |
new THREE.CylinderGeometry(BODY_RADIUS, BODY_RADIUS, BODY_LENGTH), | |
metalMaterial, | |
) | |
body.rotation.z = Math.PI/2 | |
full.add(body) | |
const barrel = new THREE.Mesh( | |
new THREE.CylinderGeometry(BODY_RADIUS/2, BODY_RADIUS/2, BODY_LENGTH), | |
metalMaterial, | |
) | |
barrel.rotation.z = Math.PI/2 | |
barrel.position.x = BODY_LENGTH | |
full.add(barrel) | |
return full | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment