mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 11:46:34 +02:00
more Particles to Entities migration
This commit is contained in:
parent
7ca4c95d4a
commit
c5c44e7cec
1 changed files with 23 additions and 21 deletions
|
@ -129,7 +129,7 @@ function Hand(name, palm, tip, forwardButton, button3, trigger) {
|
|||
this.button3 = button3;
|
||||
this.trigger = trigger;
|
||||
this.holdingFrisbee = false;
|
||||
this.particle = false;
|
||||
this.entity = false;
|
||||
this.palmPosition = function() { return Controller.getSpatialControlPosition(this.palm); }
|
||||
this.grabButtonPressed = function() {
|
||||
return (
|
||||
|
@ -185,28 +185,29 @@ function playSound(sound, position) {
|
|||
|
||||
function cleanupFrisbees() {
|
||||
simulatedFrisbees = [];
|
||||
var particles = Particles.findParticles(MyAvatar.position, 1000);
|
||||
for (particle in particles) {
|
||||
Particles.deleteParticle(particles[particle]);
|
||||
var entities = Entities.findEntities(MyAvatar.position, 1000);
|
||||
for (entity in entities) {
|
||||
Entities.deleteEntity(entities[entity]);
|
||||
}
|
||||
}
|
||||
|
||||
function checkControllerSide(hand) {
|
||||
// If I don't currently have a frisbee in my hand, then try to catch closest one
|
||||
if (!hand.holdingFrisbee && hand.grabButtonPressed()) {
|
||||
var closestParticle = Particles.findClosestParticle(hand.palmPosition(), CATCH_RADIUS);
|
||||
var modelUrl = Particles.getParticleProperties(closestParticle).modelURL;
|
||||
if (closestParticle.isKnownID && validFrisbeeURL(Particles.getParticleProperties(closestParticle).modelURL)) {
|
||||
Particles.editParticle(closestParticle, {modelScale: 1, inHand: true, position: hand.holdPosition(), shouldDie: true});
|
||||
Particles.deleteParticle(closestParticle);
|
||||
var closestEntity = Entities.findClosestEntity(hand.palmPosition(), CATCH_RADIUS);
|
||||
var modelUrl = Entities.getEntityProperties(closestEntity).modelURL;
|
||||
if (closestEntity.isKnownID && validFrisbeeURL(Entities.getEntityProperties(closestEntity).modelURL)) {
|
||||
Entities.editEntity(closestEntity, {modelScale: 1, inHand: true, position: hand.holdPosition(), shouldDie: true});
|
||||
Entities.deleteEntity(closestEntity);
|
||||
debugPrint(hand.message + " HAND- CAUGHT SOMETHING!!");
|
||||
|
||||
var properties = {
|
||||
type: "Model",
|
||||
position: hand.holdPosition(),
|
||||
velocity: { x: 0, y: 0, z: 0},
|
||||
gravity: { x: 0, y: 0, z: 0},
|
||||
inHand: true,
|
||||
radius: FRISBEE_RADIUS,
|
||||
dimensions: { x: FRISBEE_RADIUS, y: FRISBEE_RADIUS / 5, z: FRISBEE_RADIUS },
|
||||
damping: 0.999,
|
||||
modelURL: modelUrl,
|
||||
modelScale: FRISBEE_MODEL_SCALE,
|
||||
|
@ -214,10 +215,10 @@ function checkControllerSide(hand) {
|
|||
lifetime: FRISBEE_LIFETIME
|
||||
};
|
||||
|
||||
newParticle = Particles.addParticle(properties);
|
||||
newEntity = Entities.addEntity(properties);
|
||||
|
||||
hand.holdingFrisbee = true;
|
||||
hand.particle = newParticle;
|
||||
hand.entity = newEntity;
|
||||
|
||||
playSound(catchSound, hand.holdPosition());
|
||||
|
||||
|
@ -228,11 +229,12 @@ function checkControllerSide(hand) {
|
|||
// If '3' is pressed, and not holding a frisbee, make a new one
|
||||
if (hand.grabButtonPressed() && !hand.holdingFrisbee && newfrisbeeEnabled) {
|
||||
var properties = {
|
||||
type: "Model",
|
||||
position: hand.holdPosition(),
|
||||
velocity: { x: 0, y: 0, z: 0},
|
||||
gravity: { x: 0, y: 0, z: 0},
|
||||
inHand: true,
|
||||
radius: FRISBEE_RADIUS,
|
||||
dimensions: { x: FRISBEE_RADIUS, y: FRISBEE_RADIUS / 5, z: FRISBEE_RADIUS },
|
||||
damping: 0.999,
|
||||
modelURL: frisbeeURL(),
|
||||
modelScale: FRISBEE_MODEL_SCALE,
|
||||
|
@ -240,9 +242,9 @@ function checkControllerSide(hand) {
|
|||
lifetime: FRISBEE_LIFETIME
|
||||
};
|
||||
|
||||
newParticle = Particles.addParticle(properties);
|
||||
newEntity = Entities.addEntity(properties);
|
||||
hand.holdingFrisbee = true;
|
||||
hand.particle = newParticle;
|
||||
hand.entity = newEntity;
|
||||
|
||||
// Play a new frisbee sound
|
||||
playSound(newSound, hand.holdPosition());
|
||||
|
@ -258,7 +260,7 @@ function checkControllerSide(hand) {
|
|||
position: hand.holdPosition(),
|
||||
modelRotation: hand.holdRotation()
|
||||
};
|
||||
Particles.editParticle(hand.particle, properties);
|
||||
Entities.editEntity(hand.entity, properties);
|
||||
} else {
|
||||
debugPrint(">>>>> " + hand.name + "-FRISBEE IN HAND, not grabbing, THROW!!!");
|
||||
// If frisbee just released, add velocity to it!
|
||||
|
@ -271,12 +273,12 @@ function checkControllerSide(hand) {
|
|||
modelRotation: hand.holdRotation()
|
||||
};
|
||||
|
||||
Particles.editParticle(hand.particle, properties);
|
||||
Entities.editEntity(hand.entity, properties);
|
||||
|
||||
simulatedFrisbees.push(hand.particle);
|
||||
simulatedFrisbees.push(hand.entity);
|
||||
|
||||
hand.holdingFrisbee = false;
|
||||
hand.particle = false;
|
||||
hand.entity = false;
|
||||
|
||||
playSound(throwSound, hand.holdPosition());
|
||||
}
|
||||
|
@ -323,7 +325,7 @@ function checkController(deltaTime) {
|
|||
function controlFrisbees(deltaTime) {
|
||||
var killSimulations = [];
|
||||
for (frisbee in simulatedFrisbees) {
|
||||
var properties = Particles.getParticleProperties(simulatedFrisbees[frisbee]);
|
||||
var properties = Entities.getEntityProperties(simulatedFrisbees[frisbee]);
|
||||
//get the horizon length from the velocity origin in order to get speed
|
||||
var speed = Vec3.length({x:properties.velocity.x, y:0, z:properties.velocity.z});
|
||||
if (speed < MIN_SIMULATION_SPEED) {
|
||||
|
@ -331,7 +333,7 @@ function controlFrisbees(deltaTime) {
|
|||
killSimulations.push(frisbee);
|
||||
continue;
|
||||
}
|
||||
Particles.editParticle(simulatedFrisbees[frisbee], {modelRotation: Quat.multiply(properties.modelRotation, Quat.fromPitchYawRollDegrees(0, speed * deltaTime * SPIN_MULTIPLIER, 0))});
|
||||
Entities.editEntity(simulatedFrisbees[frisbee], {modelRotation: Quat.multiply(properties.modelRotation, Quat.fromPitchYawRollDegrees(0, speed * deltaTime * SPIN_MULTIPLIER, 0))});
|
||||
|
||||
}
|
||||
for (var i = killSimulations.length - 1; i >= 0; i--) {
|
||||
|
|
Loading…
Reference in a new issue