This commit is contained in:
James B. Pollack 2015-12-10 13:44:53 -08:00
parent 1000b60280
commit c3e9cde7fb

View file

@ -424,21 +424,24 @@ function MyController(hand) {
var handToObject = Vec3.subtract(objectPosition, handPosition);
var finalRotation = Quat.rotationBetween(Vec3.multiply(-1,Vec3.UP), handToObject);
var finalRotation = Quat.rotationBetween(Vec3.multiply(-1, Vec3.UP), handToObject);
var distance = Vec3.distance(handPosition, objectPosition);
var speed = distance * 1;
var lifepsan = distance / speed;
var lifespan = 1;
if (this.particleBeam === null) {
print('create beam')
this.createParticleBeam(objectPosition, finalRotation, color)
this.createParticleBeam(objectPosition, finalRotation, color, speed)
} else {
print('update beam')
this.updateParticleBeam(objectPosition, finalRotation, color)
this.updateParticleBeam(objectPosition, finalRotation, color, speed, lifepsan)
}
}
this.createParticleBeam = function(position, orientation, color) {
this.createParticleBeam = function(position, orientation, color, speed, lifepsan) {
var particleBeamProperties = {
type: "ParticleEffect",
isEmitting: true,
@ -448,9 +451,9 @@ function MyController(hand) {
"name": "Particle Beam",
"color": color,
"maxParticles": 2000,
"lifespan": 3,
"lifespan": 1,
"emitRate": 50,
"emitSpeed": 20,
"emitSpeed": 1,
"speedSpread": 0,
"emitOrientation": {
"x": -1,
@ -500,7 +503,7 @@ function MyController(hand) {
this.particleBeam = Entities.addEntity(particleBeamProperties);
}
this.updateParticleBeam = function(position, orientation, color) {
this.updateParticleBeam = function(position, orientation, color, speed, lifepsan) {
print('O IN UPDATE:::' + JSON.stringify(orientation))
// var beamProps = Entities.getEntityProperties(this.particleBeam);
@ -509,7 +512,9 @@ function MyController(hand) {
rotation: orientation,
position: position,
visible: true,
color: color
color: color,
emitSpeed: speed,
lifepsan: lifepsan
})
@ -953,7 +958,7 @@ function MyController(hand) {
this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, change);
}
this.handleDistantParticleBeam(handPosition, grabbedProperties.position,this.currentObjectRotation, INTERSECT_COLOR)
this.handleDistantParticleBeam(handPosition, grabbedProperties.position, this.currentObjectRotation, INTERSECT_COLOR)
Entities.updateAction(this.grabbedEntity, this.actionID, {
targetPosition: this.currentObjectPosition,