mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:29:47 +02:00
Fixes for scaling tablet
This commit is contained in:
parent
6e6687c3a6
commit
9c6b8a6826
3 changed files with 76 additions and 26 deletions
|
@ -3029,6 +3029,12 @@ function MyController(hand) {
|
||||||
|
|
||||||
if (this.grabbedIsOverlay) {
|
if (this.grabbedIsOverlay) {
|
||||||
Overlays.editOverlay(this.grabbedThingID, reparentProps);
|
Overlays.editOverlay(this.grabbedThingID, reparentProps);
|
||||||
|
// AJT: resize tablet to allow it to counter scale.
|
||||||
|
if (this.grabbedThingID === HMD.tabletID) {
|
||||||
|
var DEFAULT_TABLET_WIDTH = 0.4375;
|
||||||
|
var tabletScalePercentage = getTabletScalePercentageFromSettings();
|
||||||
|
resizeTablet(DEFAULT_TABLET_WIDTH * (tabletScalePercentage / 100));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (grabbedProperties.userData.length > 0) {
|
if (grabbedProperties.userData.length > 0) {
|
||||||
try{
|
try{
|
||||||
|
@ -3805,6 +3811,12 @@ function MyController(hand) {
|
||||||
parentID: this.previousParentID[this.grabbedThingID],
|
parentID: this.previousParentID[this.grabbedThingID],
|
||||||
parentJointIndex: this.previousParentJointIndex[this.grabbedThingID],
|
parentJointIndex: this.previousParentJointIndex[this.grabbedThingID],
|
||||||
});
|
});
|
||||||
|
// AJT: resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
|
||||||
|
if (this.grabbedThingID === HMD.tabletID) {
|
||||||
|
var DEFAULT_TABLET_WIDTH = 0.4375;
|
||||||
|
var tabletScalePercentage = getTabletScalePercentageFromSettings();
|
||||||
|
resizeTablet(DEFAULT_TABLET_WIDTH * (tabletScalePercentage / 100));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// we're putting this back as a child of some other parent, so zero its velocity
|
// we're putting this back as a child of some other parent, so zero its velocity
|
||||||
Entities.editEntity(this.grabbedThingID, {
|
Entities.editEntity(this.grabbedThingID, {
|
||||||
|
|
|
@ -303,32 +303,8 @@ WebTablet.prototype.getOverlayObject = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
WebTablet.prototype.setWidth = function (width) {
|
WebTablet.prototype.setWidth = function (width) {
|
||||||
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
// imported from libraries/utils.js
|
||||||
|
resizeTablet(width);
|
||||||
// scale factor of natural tablet dimensions.
|
|
||||||
this.width = (width || DEFAULT_WIDTH) * sensorScaleFactor;
|
|
||||||
var tabletScaleFactor = this.width / TABLET_NATURAL_DIMENSIONS.x;
|
|
||||||
this.height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
|
||||||
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
|
||||||
this.dpi = DEFAULT_DPI * (DEFAULT_WIDTH / this.width);
|
|
||||||
|
|
||||||
// update tablet model dimensions
|
|
||||||
Overlays.editOverlay(this.tabletEntityID, { dimensions: this.getDimensions() });
|
|
||||||
|
|
||||||
// update webOverlay
|
|
||||||
var WEB_ENTITY_Z_OFFSET = (this.depth / 2) * (1 / sensorScaleFactor);
|
|
||||||
var WEB_ENTITY_Y_OFFSET = 0.004 * (1 / sensorScaleFactor);
|
|
||||||
Overlays.editOverlay(this.webOverlayID, {
|
|
||||||
localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
|
|
||||||
dpi: this.dpi
|
|
||||||
});
|
|
||||||
|
|
||||||
// update homeButton
|
|
||||||
var HOME_BUTTON_Y_OFFSET = ((this.height / 2) - (this.height / 20)) * (1 / sensorScaleFactor);
|
|
||||||
Overlays.editOverlay(this.homeButtonID, {
|
|
||||||
localPosition: {x: -0.001, y: -HOME_BUTTON_Y_OFFSET, z: 0.0},
|
|
||||||
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WebTablet.prototype.destroy = function () {
|
WebTablet.prototype.destroy = function () {
|
||||||
|
|
|
@ -351,3 +351,65 @@ clamp = function(val, min, max){
|
||||||
flatten = function(array) {
|
flatten = function(array) {
|
||||||
return [].concat.apply([], array);
|
return [].concat.apply([], array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTabletScalePercentageFromSettings = function () {
|
||||||
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
|
var toolbarMode = tablet.toolbarMode;
|
||||||
|
var DEFAULT_TABLET_SCALE = 100;
|
||||||
|
var tabletScalePercentage = DEFAULT_TABLET_SCALE;
|
||||||
|
if (!toolbarMode) {
|
||||||
|
if (HMD.active) {
|
||||||
|
tabletScalePercentage = Settings.getValue("hmdTabletScale") || DEFAULT_TABLET_SCALE;
|
||||||
|
} else {
|
||||||
|
tabletScalePercentage = Settings.getValue("desktopTabletScale") || DEFAULT_TABLET_SCALE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tabletScalePercentage;
|
||||||
|
};
|
||||||
|
|
||||||
|
resizeTablet = function (width, newParentJointID) {
|
||||||
|
|
||||||
|
if (!HMD.tabletID || !HMD.tabletScreenID || !HMD.homeButtonID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||||
|
var sensorScaleOffsetOverride = 1;
|
||||||
|
var SENSOR_TO_ROOM_MATRIX = 65534;
|
||||||
|
var parentJointIndex = Overlays.getProperty(HMD.tabletID, "parentJointIndex");
|
||||||
|
if (parentJointIndex === SENSOR_TO_ROOM_MATRIX) {
|
||||||
|
sensorScaleOffsetOverride = 1 / sensorScaleFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// will need to be recaclulated if dimensions of fbx model change.
|
||||||
|
var TABLET_NATURAL_DIMENSIONS = {x: 33.797, y: 50.129, z: 2.269};
|
||||||
|
var DEFAULT_DPI = 34;
|
||||||
|
var DEFAULT_WIDTH = 0.4375;
|
||||||
|
|
||||||
|
// scale factor of natural tablet dimensions.
|
||||||
|
var tabletWidth = (width || DEFAULT_WIDTH) * sensorScaleFactor;
|
||||||
|
var tabletScaleFactor = tabletWidth / TABLET_NATURAL_DIMENSIONS.x;
|
||||||
|
var tabletHeight = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
||||||
|
var tabletDepth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
||||||
|
var tabletDpi = DEFAULT_DPI * (DEFAULT_WIDTH / tabletWidth);
|
||||||
|
|
||||||
|
// update tablet model dimensions
|
||||||
|
Overlays.editOverlay(HMD.tabletID, {
|
||||||
|
dimensions: { x: tabletWidth, y: tabletHeight, z: tabletDepth }
|
||||||
|
});
|
||||||
|
|
||||||
|
// update webOverlay
|
||||||
|
var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2) * sensorScaleOffsetOverride;
|
||||||
|
var WEB_ENTITY_Y_OFFSET = 0.004 * sensorScaleOffsetOverride;
|
||||||
|
Overlays.editOverlay(HMD.tabletScreenID, {
|
||||||
|
localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
|
||||||
|
dpi: tabletDpi
|
||||||
|
});
|
||||||
|
|
||||||
|
// update homeButton
|
||||||
|
var HOME_BUTTON_Y_OFFSET = ((tabletHeight / 2) - (tabletHeight / 20)) * sensorScaleOffsetOverride;
|
||||||
|
Overlays.editOverlay(HMD.homeButtonID, {
|
||||||
|
localPosition: {x: -0.001, y: -HOME_BUTTON_Y_OFFSET, z: 0.0},
|
||||||
|
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue