Skip to content

Instantly share code, notes, and snippets.

@Badestrand
Last active April 18, 2022 04:09
Show Gist options
  • Save Badestrand/421217eb786c62a9ae3b68898e3ec3f5 to your computer and use it in GitHub Desktop.
Save Badestrand/421217eb786c62a9ae3b68898e3ec3f5 to your computer and use it in GitHub Desktop.
aviator2-simplegun
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