forked from github/game-off-2013
-
Notifications
You must be signed in to change notification settings - Fork 1
/
spitball.js
36 lines (32 loc) · 1.07 KB
/
spitball.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use strict";
define(['settings', 'tween.min'], function(settings) {
function Spitball(source, target) {
var ballGeometry = new THREE.SphereGeometry( settings.ballRadius );
var ballMaterial = new THREE.MeshBasicMaterial( {
color:0x00FF00,
transparent:true,
opacity:0.45
});
var ballMesh = new THREE.Mesh( ballGeometry, ballMaterial );
ballMesh.position = source;
function launch() {
var tween = new TWEEN.Tween( { x:source.x, y:source.y, z:source.z } )
.to( {x:target.x, y:target.y, z:target.z}, 250 )
.easing( TWEEN.Easing.Linear.None)
.onUpdate( function () {
ballMesh.position.x = this.x;
ballMesh.position.y = this.y;
ballMesh.position.z = this.z;
});
tween.start();
}
return {
model: ballMesh,
pickables: [],
launch: launch,
};
}
return {
Spitball:Spitball,
};
});