mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-10 22:27:22 +02:00
beamz
This commit is contained in:
parent
1000b60280
commit
c3e9cde7fb
1 changed files with 18 additions and 13 deletions
|
@ -426,19 +426,22 @@ function MyController(hand) {
|
||||||
var handToObject = Vec3.subtract(objectPosition, handPosition);
|
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) {
|
if (this.particleBeam === null) {
|
||||||
print('create beam')
|
print('create beam')
|
||||||
this.createParticleBeam(objectPosition, finalRotation, color)
|
this.createParticleBeam(objectPosition, finalRotation, color, speed)
|
||||||
} else {
|
} else {
|
||||||
print('update beam')
|
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 = {
|
var particleBeamProperties = {
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
isEmitting: true,
|
isEmitting: true,
|
||||||
|
@ -448,9 +451,9 @@ function MyController(hand) {
|
||||||
"name": "Particle Beam",
|
"name": "Particle Beam",
|
||||||
"color": color,
|
"color": color,
|
||||||
"maxParticles": 2000,
|
"maxParticles": 2000,
|
||||||
"lifespan": 3,
|
"lifespan": 1,
|
||||||
"emitRate": 50,
|
"emitRate": 50,
|
||||||
"emitSpeed": 20,
|
"emitSpeed": 1,
|
||||||
"speedSpread": 0,
|
"speedSpread": 0,
|
||||||
"emitOrientation": {
|
"emitOrientation": {
|
||||||
"x": -1,
|
"x": -1,
|
||||||
|
@ -500,7 +503,7 @@ function MyController(hand) {
|
||||||
this.particleBeam = Entities.addEntity(particleBeamProperties);
|
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))
|
print('O IN UPDATE:::' + JSON.stringify(orientation))
|
||||||
|
|
||||||
// var beamProps = Entities.getEntityProperties(this.particleBeam);
|
// var beamProps = Entities.getEntityProperties(this.particleBeam);
|
||||||
|
@ -509,7 +512,9 @@ function MyController(hand) {
|
||||||
rotation: orientation,
|
rotation: orientation,
|
||||||
position: position,
|
position: position,
|
||||||
visible: true,
|
visible: true,
|
||||||
color: color
|
color: color,
|
||||||
|
emitSpeed: speed,
|
||||||
|
lifepsan: lifepsan
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue