mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
fixing magic numbers
changing to local entity making var names more friendly
This commit is contained in:
parent
91db29e92f
commit
fb869034f2
1 changed files with 20 additions and 20 deletions
|
@ -7,11 +7,12 @@
|
||||||
APP_ICON = 'https://binaryrelay.com/files/public-docs/hifi/laser/laser.svg',
|
APP_ICON = 'https://binaryrelay.com/files/public-docs/hifi/laser/laser.svg',
|
||||||
APP_ICON_ACTIVE = 'https://binaryrelay.com/files/public-docs/hifi/laser/laser-a.svg';
|
APP_ICON_ACTIVE = 'https://binaryrelay.com/files/public-docs/hifi/laser/laser-a.svg';
|
||||||
|
|
||||||
|
|
||||||
var POINT_INDEX_CHANNEL = "Hifi-Point-Index",
|
var POINT_INDEX_CHANNEL = "Hifi-Point-Index",
|
||||||
GRAB_DISABLE_CHANNEL = "Hifi-Grab-Disable",
|
GRAB_DISABLE_CHANNEL = "Hifi-Grab-Disable",
|
||||||
POINTER_DISABLE_CHANNEL = "Hifi-Pointer-Disable";
|
POINTER_DISABLE_CHANNEL = "Hifi-Pointer-Disable";
|
||||||
|
|
||||||
|
var TRIGGER_PRESSURE = 0.95;
|
||||||
|
|
||||||
var tablet = Tablet.getTablet('com.highfidelity.interface.tablet.system');
|
var tablet = Tablet.getTablet('com.highfidelity.interface.tablet.system');
|
||||||
|
|
||||||
var button = tablet.addButton({
|
var button = tablet.addButton({
|
||||||
|
@ -29,8 +30,8 @@
|
||||||
beam: null,
|
beam: null,
|
||||||
sphere: null
|
sphere: null
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var rayExclusionList = [];
|
var rayExclusionList = [];
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,14 +41,14 @@
|
||||||
|
|
||||||
var isNewEntityNeeded = (laserEntities[hand].beam === null);
|
var isNewEntityNeeded = (laserEntities[hand].beam === null);
|
||||||
|
|
||||||
var _hand = hand === 'right' ? Controller.Standard.RightHand : Controller.Standard.LeftHand;
|
var currentHand = hand === 'right' ? Controller.Standard.RightHand : Controller.Standard.LeftHand;
|
||||||
var _joint = hand === 'right' ? 'RightHand' : 'LeftHand'; //'RightHandIndex4' : 'LeftHandIndex4'
|
var jointName = hand === 'right' ? 'RightHand' : 'LeftHand'; //'RightHandIndex4' : 'LeftHandIndex4'
|
||||||
var controllerLocation = getControllerWorldLocation(_hand, true);
|
var controllerLocation = getControllerWorldLocation(currentHand, true);
|
||||||
|
|
||||||
var worldHandRotation = controllerLocation.orientation;
|
var worldHandRotation = controllerLocation.orientation;
|
||||||
|
|
||||||
var pickRay = {
|
var pickRay = {
|
||||||
origin: MyAvatar.getJointPosition(_joint),
|
origin: MyAvatar.getJointPosition(jointName),
|
||||||
direction: Quat.getUp(worldHandRotation),
|
direction: Quat.getUp(worldHandRotation),
|
||||||
length: PICK_MAX_DISTANCE
|
length: PICK_MAX_DISTANCE
|
||||||
};
|
};
|
||||||
|
@ -83,8 +84,7 @@
|
||||||
|
|
||||||
var sphere = {
|
var sphere = {
|
||||||
lifetime: 360,
|
lifetime: 360,
|
||||||
type: 'Shape',
|
type: 'Sphere',
|
||||||
shape: 'circle3d',
|
|
||||||
dimensions: {x: sphereSize, y: sphereSize, z: sphereSize},
|
dimensions: {x: sphereSize, y: sphereSize, z: sphereSize},
|
||||||
color: {red: 0, green: 255, blue: 0},
|
color: {red: 0, green: 255, blue: 0},
|
||||||
position: intersection,
|
position: intersection,
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
drawInFront: true,
|
drawInFront: true,
|
||||||
color: {red: 0, green: 255, blue: 0},
|
color: {red: 0, green: 255, blue: 0},
|
||||||
parentID: MyAvatar.sessionUUID,
|
parentID: MyAvatar.sessionUUID,
|
||||||
parentJointIndex: MyAvatar.getJointIndex(_joint),
|
parentJointIndex: MyAvatar.getJointIndex(jointName),
|
||||||
localPosition: {x: 0, y: .2, z: 0},
|
localPosition: {x: 0, y: .2, z: 0},
|
||||||
localRotation: Quat.normalize({}),
|
localRotation: Quat.normalize({}),
|
||||||
dimensions: Vec3.multiply(PICK_MAX_DISTANCE * 2, Vec3.ONE),
|
dimensions: Vec3.multiply(PICK_MAX_DISTANCE * 2, Vec3.ONE),
|
||||||
|
@ -110,11 +110,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
laserEntities[hand].beam = Entities.addEntity(beam);
|
laserEntities[hand].beam = Entities.addEntity(beam,true);
|
||||||
rayExclusionList.push(laserEntities[hand].beam);
|
rayExclusionList.push(laserEntities[hand].beam);
|
||||||
|
|
||||||
if (ray.intersects || avatarRay.intersects) {
|
if (ray.intersects || avatarRay.intersects) {
|
||||||
laserEntities[hand].sphere = Entities.addEntity(sphere);
|
laserEntities[hand].sphere = Entities.addEntity(sphere,true);
|
||||||
rayExclusionList.push(laserEntities[hand].sphere);
|
rayExclusionList.push(laserEntities[hand].sphere);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
|
|
||||||
Entities.editEntity(laserEntities[hand].beam, {
|
Entities.editEntity(laserEntities[hand].beam, {
|
||||||
parentID: MyAvatar.sessionUUID,
|
parentID: MyAvatar.sessionUUID,
|
||||||
parentJointIndex: MyAvatar.getJointIndex(_joint),
|
parentJointIndex: MyAvatar.getJointIndex(jointName),
|
||||||
localPosition: {x: 0, y: .2, z: 0},
|
localPosition: {x: 0, y: .2, z: 0},
|
||||||
localRotation: Quat.normalize({}),
|
localRotation: Quat.normalize({}),
|
||||||
dimensions: Vec3.multiply(PICK_MAX_DISTANCE * 2, Vec3.ONE),
|
dimensions: Vec3.multiply(PICK_MAX_DISTANCE * 2, Vec3.ONE),
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
} else {
|
} else {
|
||||||
Entities.editEntity(laserEntities[hand].beam, {
|
Entities.editEntity(laserEntities[hand].beam, {
|
||||||
parentID: MyAvatar.sessionUUID,
|
parentID: MyAvatar.sessionUUID,
|
||||||
parentJointIndex: MyAvatar.getJointIndex(_joint),
|
parentJointIndex: MyAvatar.getJointIndex(jointName),
|
||||||
localPosition: {x: 0, y: .2, z: 0},
|
localPosition: {x: 0, y: .2, z: 0},
|
||||||
localRotation: Quat.normalize({}),
|
localRotation: Quat.normalize({}),
|
||||||
dimensions: Vec3.multiply(PICK_MAX_DISTANCE * 2, Vec3.ONE),
|
dimensions: Vec3.multiply(PICK_MAX_DISTANCE * 2, Vec3.ONE),
|
||||||
|
@ -155,14 +155,14 @@
|
||||||
var deleteBeamLeft = true,
|
var deleteBeamLeft = true,
|
||||||
deleteBeamRight = true;
|
deleteBeamRight = true;
|
||||||
|
|
||||||
if (Controller.getValue(Controller.Standard.LT) > .95) {
|
if (Controller.getValue(Controller.Standard.LT) > TRIGGER_PRESSURE) {
|
||||||
deleteBeamLeft = false;
|
deleteBeamLeft = false;
|
||||||
laser('left', deltaTime);
|
laser('left');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Controller.getValue(Controller.Standard.RT) > .95) {
|
if (Controller.getValue(Controller.Standard.RT) > TRIGGER_PRESSURE) {
|
||||||
deleteBeamRight = false;
|
deleteBeamRight = false;
|
||||||
laser('right', deltaTime);
|
laser('right');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleteBeamLeft && laserEntities.left.beam !== null) {
|
if (deleteBeamLeft && laserEntities.left.beam !== null) {
|
||||||
|
@ -181,7 +181,7 @@
|
||||||
laserEntities.right.sphere = null;
|
laserEntities.right.sphere = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (deleteBeamRight && laserEntities.right.beam !== null && deleteBeamLeft && laserEntities.left.beam !== null) {
|
if (deleteBeamRight && deleteBeamLeft) {
|
||||||
rayExclusionList = [];
|
rayExclusionList = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
|
|
||||||
var _switch = true;
|
var _switch = true;
|
||||||
|
|
||||||
function bSwitch() {
|
function buttonSwitch() {
|
||||||
if (_switch) {
|
if (_switch) {
|
||||||
Script.update.connect(triggerWatcher);
|
Script.update.connect(triggerWatcher);
|
||||||
Messages.subscribe(POINT_INDEX_CHANNEL);
|
Messages.subscribe(POINT_INDEX_CHANNEL);
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
_switch = !_switch;
|
_switch = !_switch;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.clicked.connect(bSwitch);
|
button.clicked.connect(buttonSwitch);
|
||||||
|
|
||||||
function clean() {
|
function clean() {
|
||||||
tablet.removeButton(button);
|
tablet.removeButton(button);
|
||||||
|
|
Loading…
Reference in a new issue