mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
lightsaber immediately turns off on release
This commit is contained in:
parent
4110630d1f
commit
cabc47e7a9
2 changed files with 76 additions and 56 deletions
|
@ -27,7 +27,16 @@
|
|||
|
||||
ArcBall.prototype = {
|
||||
isGrabbed: false,
|
||||
startNearGrab: function() {
|
||||
startDistanceGrab: function() {
|
||||
this.searchForNearbyArcBalls();
|
||||
|
||||
},
|
||||
|
||||
startFarGrab: function() {
|
||||
this.searchForNearbyArcBalls();
|
||||
},
|
||||
|
||||
searchForNearbyArcBalls: function() {
|
||||
//Search for nearby balls and create an arc to it if one is found
|
||||
var position = Entities.getEntityProperties(this.entityID, "position").position
|
||||
var entities = Entities.findEntities(position, 10);
|
||||
|
@ -36,12 +45,13 @@
|
|||
if (props.name === "Arc Ball" && JSON.stringify(_this.entityID) !== JSON.stringify(entity)) {
|
||||
_this.target = entity;
|
||||
_this.createBeam(position, props.position);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
createBeam: function(startPosition, endPosition) {
|
||||
|
||||
// Creates particle arc from start position to end position
|
||||
var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation;
|
||||
var sourceToTargetVec = Vec3.subtract(endPosition, startPosition);
|
||||
|
@ -102,9 +112,13 @@
|
|||
this.particleArc = Entities.addEntity(props);
|
||||
},
|
||||
|
||||
updateBeam: function(startPosition) {
|
||||
updateBeam: function() {
|
||||
if(!this.target) {
|
||||
return;
|
||||
}
|
||||
var startPosition = Entities.getEntityProperties(this.entityID, "position").position;
|
||||
|
||||
var targetPosition = Entities.getEntityProperties(this.target, "position").position;
|
||||
print("TARGET position " + JSON.stringify(this.target));
|
||||
var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation;
|
||||
var sourceToTargetVec = Vec3.subtract(targetPosition, startPosition);
|
||||
var emitOrientation = Quat.rotationBetween(Vec3.UNIT_Z, sourceToTargetVec);
|
||||
|
@ -115,14 +129,18 @@
|
|||
},
|
||||
|
||||
continueNearGrab: function() {
|
||||
var startPosition = Entities.getEntityProperties(this.entityID, "position").position;
|
||||
this.updateBeam(startPosition);
|
||||
this.updateBeam();
|
||||
},
|
||||
|
||||
continueDistanceGrab: function() {
|
||||
this.updateBeam();
|
||||
},
|
||||
|
||||
releaseGrab: function() {
|
||||
Entities.editEntity(this.particleArc, {
|
||||
isEmitting: false
|
||||
});
|
||||
this.target = null;
|
||||
},
|
||||
|
||||
unload: function() {
|
||||
|
|
|
@ -31,12 +31,14 @@
|
|||
|
||||
startNearGrab: function() {
|
||||
Entities.editEntity(this.beam, {
|
||||
isEmitting: true
|
||||
isEmitting: true,
|
||||
visible: true
|
||||
});
|
||||
},
|
||||
|
||||
releaseGrab: function() {
|
||||
Entities.editEntity(this.beam, {
|
||||
visible: false,
|
||||
isEmitting: false
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue