displaying offset values

This commit is contained in:
Wayne Chen 2019-03-21 08:38:31 -07:00
parent 554a144b0e
commit 1f71a291a5
2 changed files with 17 additions and 16 deletions

View file

@ -28,8 +28,6 @@ Rectangle {
signal sendToScript(var message); signal sendToScript(var message);
function emitSendToScript(message) { function emitSendToScript(message) {
console.log("sending to script");
console.log(JSON.stringify(message));
sendToScript(message); sendToScript(message);
} }
@ -57,7 +55,7 @@ Rectangle {
left: parent.left left: parent.left
leftMargin: 20 leftMargin: 20
} }
label: "X OFFSET" label: "X OFFSET: " + value.toFixed(2);
maximumValue: 1.0 maximumValue: 1.0
minimumValue: -1.0 minimumValue: -1.0
stepSize: 0.05 stepSize: 0.05
@ -79,7 +77,7 @@ Rectangle {
left: parent.left left: parent.left
leftMargin: 20 leftMargin: 20
} }
label: "Y OFFSET" label: "Y OFFSET: " + value.toFixed(2);
maximumValue: 1.0 maximumValue: 1.0
minimumValue: -1.0 minimumValue: -1.0
stepSize: 0.05 stepSize: 0.05
@ -101,7 +99,7 @@ Rectangle {
left: parent.left left: parent.left
leftMargin: 20 leftMargin: 20
} }
label: "Z OFFSET" label: "Z OFFSET: " + value.toFixed(2);
maximumValue: 0.0 maximumValue: 0.0
minimumValue: -1.0 minimumValue: -1.0
stepSize: 0.05 stepSize: 0.05

View file

@ -6,13 +6,17 @@
var ui; var ui;
var onCreateAvatarInputsBarEntity = false; var onCreateAvatarInputsBarEntity = false;
var micBarEntity, bubbleIconEntity; var micBarEntity = null;
var bubbleIconEntity = null;
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml"; var AVATAR_INPUTS_EDIT_QML_SOURCE = "hifi/EditAvatarInputsBar.qml";
// QML NATURAL DIMENSIONS // QML NATURAL DIMENSIONS
var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3}; var MIC_BAR_DIMENSIONS = {x: 0.036, y: 0.048, z: 0.3};
var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3}; var BUBBLE_ICON_DIMENSIONS = {x: 0.036, y: 0.036, z: 0.3};
// ENTITY NAMES
var MIC_BAR_NAME = "AvatarInputsMicBarEntity";
var BUBBLE_ICON_NAME = "AvatarInputsBubbleIconEntity";
// CONSTANTS // CONSTANTS
var LOCAL_POSITION_X_OFFSET = -0.2; var LOCAL_POSITION_X_OFFSET = -0.2;
var LOCAL_POSITION_Y_OFFSET = -0.125; var LOCAL_POSITION_Y_OFFSET = -0.125;
@ -56,20 +60,19 @@
var bubbleIconLocalPosition = Entities.getEntityProperties(bubbleIconEntity).localPosition; var bubbleIconLocalPosition = Entities.getEntityProperties(bubbleIconEntity).localPosition;
console.log("mic bar local position is at " + JSON.stringify(micBarLocalPosition)); console.log("mic bar local position is at " + JSON.stringify(micBarLocalPosition));
console.log("bubble icon local position is at " + JSON.stringify(bubbleIconLocalPosition)); console.log("bubble icon local position is at " + JSON.stringify(bubbleIconLocalPosition));
} else if (message.method === "destroy") {
console.log("destroying");
Entities.deleteEntity(micBarEntity);
Entities.deleteEntity(bubbleIconEntity);
} }
}; };
function createEntities(){ function createEntities() {
if (micBarEntity != null && bubbleIconEntity != null) {
return;
}
// POSITIONS // POSITIONS
var micBarLocalPosition = {x: (-(MIC_BAR_DIMENSIONS.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET}; var micBarLocalPosition = {x: (-(MIC_BAR_DIMENSIONS.x / 2)) + LOCAL_POSITION_X_OFFSET, y: LOCAL_POSITION_Y_OFFSET, z: LOCAL_POSITION_Z_OFFSET};
var bubbleIconLocalPosition = {x: (MIC_BAR_DIMENSIONS.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET}; var bubbleIconLocalPosition = {x: (MIC_BAR_DIMENSIONS.x * 1.2 / 2) + LOCAL_POSITION_X_OFFSET, y: ((MIC_BAR_DIMENSIONS.y - BUBBLE_ICON_DIMENSIONS.y) / 2 + LOCAL_POSITION_Y_OFFSET), z: LOCAL_POSITION_Z_OFFSET};
var props = { var props = {
type: "Web", type: "Web",
name: "AvatarInputsMicBarEntity", name: MIC_BAR_NAME,
parentID: MyAvatar.SELF_ID, parentID: MyAvatar.SELF_ID,
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"),
localPosition: micBarLocalPosition, localPosition: micBarLocalPosition,
@ -86,7 +89,7 @@
micBarEntity = Entities.addEntity(props, "local"); micBarEntity = Entities.addEntity(props, "local");
var props = { var props = {
type: "Web", type: "Web",
name: "AvatarInputsBubbleIconEntity", name: BUBBLE_ICON_NAME,
parentID: MyAvatar.SELF_ID, parentID: MyAvatar.SELF_ID,
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"),
localPosition: bubbleIconLocalPosition, localPosition: bubbleIconLocalPosition,
@ -118,9 +121,9 @@
home: Script.resourcesPath() + "qml/hifi/EditAvatarInputsBar.qml", home: Script.resourcesPath() + "qml/hifi/EditAvatarInputsBar.qml",
onMessage: fromQml, onMessage: fromQml,
onOpened: createEntities, onOpened: createEntities,
onClosed: cleanup, // onClosed: cleanup,
// normalButton: "icons/tablet-icons/avatar-i.svg", normalButton: "icons/tablet-icons/edit-i.svg",
// activeButton: "icons/tablet-icons/avatar-a.svg", activeButton: "icons/tablet-icons/edit-a.svg",
}); });
}; };