jj-spielfigur-3d
Version:
Comic-Figures and Archetypes in 3D for Games / E-Learning drawn by Jens Janetzki.
78 lines (67 loc) • 2.14 kB
JavaScript
const THREE = require('three');
import mat from '../../../material/index.js'
export default function (settings){
const material = new mat( { color: settings.color } );
this.getHair = function () {
const geometry = new THREE.SphereGeometry( .45 )
const circle = new THREE.Mesh( geometry, material );
circle.position.setY(1.15)
circle.position.setX(-.07)
circle.position.setZ(-.05)
return circle
}
this.getHair2 = function () {
const hair = this.getHair()
hair.position.setX(.07)
hair.scale.y = -1
return hair
}
this.getHair3 = function () {
const geometry = new THREE.SphereGeometry( .52 )
const circle = new THREE.Mesh( geometry, material );
circle.position.setY(1.1)
circle.position.setX(0)
circle.position.setZ(-.1)
return circle
}
this.getHair4 = function () {
let geometry = new THREE.CylinderGeometry( .05, .2, .9, 8 )
if (settings.variant && settings.variant == 'short') {
geometry = new THREE.CylinderGeometry( .05, .15, .4, 8 )
}
const circle = new THREE.Mesh( geometry, material );
circle.rotateX(.4)
circle.position.setY(.8)
circle.position.setZ(-.8)
if (settings.variant && settings.variant == 'short') {
circle.position.setY(1)
circle.position.setZ(-0.75)
circle.rotateZ(0.1)
}
return circle
}
this.getHair5 = function () {
const geometry = new THREE.SphereGeometry( .18 )
const circle = new THREE.Mesh( geometry, material );
circle.position.setY(1.2)
circle.position.setZ(-0.5)
return circle
}
this.getHair6 = function () {
const geometry = new THREE.CylinderGeometry( .15, .15, .1, 8 )
const circle = new THREE.Mesh( geometry, new mat( { color: settings.accent || 0xff0000 } ) );
circle.rotateX(.4)
circle.position.setY(1.2)
circle.position.setZ(-0.6)
return circle
}
const group = new THREE.Group();
group.name="hair";
group.add(this.getHair())
group.add(this.getHair2())
group.add(this.getHair3())
group.add(this.getHair4())
group.add(this.getHair5())
group.add(this.getHair6())
return group
}