[880] | 1 | /** |
---|
| 2 | * @file Arrow Object |
---|
| 3 | * @author Patryk Gliszczynski |
---|
| 4 | * @version 1.0 |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | class Arrow { |
---|
| 8 | /** |
---|
| 9 | * Class reposnsible for the visualization of the cylindrical pointer. |
---|
| 10 | */ |
---|
| 11 | |
---|
| 12 | constructor(y_pos) { |
---|
| 13 | var geometry = new THREE.ConeGeometry(Config.Arrow.WIDTH, |
---|
| 14 | Config.Arrow.LENGTH, |
---|
| 15 | Config.Arrow.FACES); |
---|
| 16 | |
---|
| 17 | let texture = new THREE.TextureLoader().load(Config.Arrow.TEXTURE); |
---|
| 18 | texture.wrapS = texture.wrapT = THREE.RepeatWrapping; |
---|
| 19 | texture.repeat.set(Config.Arrow.REPEAT, Config.Arrow.REPEAT); |
---|
| 20 | texture.anisotropy = Config.Arrow.ANISOTROPY; |
---|
| 21 | |
---|
| 22 | let material = new THREE.MeshLambertMaterial({map: texture}); |
---|
| 23 | material.opacity = 0; |
---|
| 24 | material.blending = THREE.NoBlending; |
---|
| 25 | |
---|
| 26 | this.mesh = new THREE.Mesh(geometry, material); |
---|
| 27 | this.mesh.castShadow = Config.Arrow.CAST_SHADOW; |
---|
| 28 | this.mesh.receiveShadow = Config.Arrow.RECEIVE_SHADOW; |
---|
| 29 | this.mesh.position.set(Config.Arrow.X_POS, y_pos, Config.Arrow.Z_POS) |
---|
| 30 | this.mesh.rotation.z += Config.Arrow.Z_ROT; |
---|
| 31 | this.mesh.scale.set(0.01, 0.01, 0.01); |
---|
| 32 | this.enlarge(); |
---|
| 33 | this.goRight(); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | enlarge() { |
---|
| 37 | let scale = Config.Arrow.Tween.Scale.Up.SIZE; |
---|
| 38 | let speed = Config.Arrow.Tween.Scale.Up.SPEED; |
---|
| 39 | let tween = new TWEEN.Tween(this.mesh.scale).to({x: scale, y: scale, z: scale}, speed); |
---|
| 40 | tween.easing(Config.Arrow.Tween.Scale.Up.EASING); |
---|
| 41 | tween.start(); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | goRight() { |
---|
| 45 | let tween = new TWEEN.Tween(this.mesh.position).to({x: Config.Arrow.Tween.Move.Right.X_POS}, |
---|
| 46 | Config.Arrow.Tween.Move.Right.SPEED); |
---|
| 47 | tween.easing(Config.Arrow.Tween.Move.Right.EASING); |
---|
| 48 | tween.onComplete(this.goLeft.bind(this)); |
---|
| 49 | tween.start(); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | goLeft() { |
---|
| 53 | let tween = new TWEEN.Tween(this.mesh.position).to({x: Config.Arrow.Tween.Move.Left.X_POS}, |
---|
| 54 | Config.Arrow.Tween.Move.Left.SPEED); |
---|
| 55 | tween.easing(Config.Arrow.Tween.Move.Left.EASING); |
---|
| 56 | tween.onComplete(this.goRight.bind(this)); |
---|
| 57 | tween.start(); |
---|
| 58 | } |
---|
| 59 | } |
---|