mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 23:09:52 +02:00
Merge pull request #13546 from sethalves/fix-display-controller-buttons
keep buttons from drifing away from in-world display of controllers
This commit is contained in:
commit
dfa0b96a93
1 changed files with 16 additions and 18 deletions
|
@ -108,14 +108,13 @@ createControllerDisplay = function(config) {
|
||||||
for (var partName in controller.parts) {
|
for (var partName in controller.parts) {
|
||||||
overlayID = this.overlays[i++];
|
overlayID = this.overlays[i++];
|
||||||
var part = controller.parts[partName];
|
var part = controller.parts[partName];
|
||||||
localPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, part.naturalPosition));
|
localPosition = Vec3.subtract(part.naturalPosition, controller.naturalPosition);
|
||||||
var localRotation;
|
var localRotation;
|
||||||
var value = this.partValues[partName];
|
var value = this.partValues[partName];
|
||||||
var offset, rotation;
|
var offset, rotation;
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
if (part.type === "linear") {
|
if (part.type === "linear") {
|
||||||
var axis = Vec3.multiplyQbyV(controller.rotation, part.axis);
|
offset = Vec3.multiply(part.maxTranslation * value, part.axis);
|
||||||
offset = Vec3.multiply(part.maxTranslation * value, axis);
|
|
||||||
localPosition = Vec3.sum(localPosition, offset);
|
localPosition = Vec3.sum(localPosition, offset);
|
||||||
localRotation = undefined;
|
localRotation = undefined;
|
||||||
} else if (part.type === "joystick") {
|
} else if (part.type === "joystick") {
|
||||||
|
@ -126,8 +125,8 @@ createControllerDisplay = function(config) {
|
||||||
} else {
|
} else {
|
||||||
offset = { x: 0, y: 0, z: 0 };
|
offset = { x: 0, y: 0, z: 0 };
|
||||||
}
|
}
|
||||||
localPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, Vec3.sum(offset, part.naturalPosition)));
|
localPosition = Vec3.sum(offset, localPosition);
|
||||||
localRotation = Quat.multiply(controller.rotation, rotation);
|
localRotation = rotation;
|
||||||
} else if (part.type === "rotational") {
|
} else if (part.type === "rotational") {
|
||||||
value = clamp(value, part.minValue, part.maxValue);
|
value = clamp(value, part.minValue, part.maxValue);
|
||||||
var pct = (value - part.minValue) / part.maxValue;
|
var pct = (value - part.minValue) / part.maxValue;
|
||||||
|
@ -139,8 +138,8 @@ createControllerDisplay = function(config) {
|
||||||
} else {
|
} else {
|
||||||
offset = { x: 0, y: 0, z: 0 };
|
offset = { x: 0, y: 0, z: 0 };
|
||||||
}
|
}
|
||||||
localPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, Vec3.sum(offset, part.naturalPosition)));
|
localPosition = Vec3.sum(offset, localPosition);
|
||||||
localRotation = Quat.multiply(controller.rotation, rotation);
|
localRotation = rotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (localRotation !== undefined) {
|
if (localRotation !== undefined) {
|
||||||
|
@ -169,9 +168,11 @@ createControllerDisplay = function(config) {
|
||||||
|
|
||||||
if (controller.naturalPosition) {
|
if (controller.naturalPosition) {
|
||||||
position = Vec3.sum(Vec3.multiplyQbyV(controller.rotation, controller.naturalPosition), position);
|
position = Vec3.sum(Vec3.multiplyQbyV(controller.rotation, controller.naturalPosition), position);
|
||||||
|
} else {
|
||||||
|
controller.naturalPosition = { x: 0, y: 0, z: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
var overlayID = Overlays.addOverlay("model", {
|
var baseOverlayID = Overlays.addOverlay("model", {
|
||||||
url: controller.modelURL,
|
url: controller.modelURL,
|
||||||
dimensions: Vec3.multiply(sensorScaleFactor, controller.dimensions),
|
dimensions: Vec3.multiply(sensorScaleFactor, controller.dimensions),
|
||||||
localRotation: controller.rotation,
|
localRotation: controller.rotation,
|
||||||
|
@ -181,23 +182,21 @@ createControllerDisplay = function(config) {
|
||||||
ignoreRayIntersection: true
|
ignoreRayIntersection: true
|
||||||
});
|
});
|
||||||
|
|
||||||
controllerDisplay.overlays.push(overlayID);
|
controllerDisplay.overlays.push(baseOverlayID);
|
||||||
overlayID = null;
|
|
||||||
|
|
||||||
if (controller.parts) {
|
if (controller.parts) {
|
||||||
for (var partName in controller.parts) {
|
for (var partName in controller.parts) {
|
||||||
var part = controller.parts[partName];
|
var part = controller.parts[partName];
|
||||||
var partPosition = Vec3.sum(controller.position, Vec3.multiplyQbyV(controller.rotation, part.naturalPosition));
|
var localPosition = Vec3.subtract(part.naturalPosition, controller.naturalPosition);
|
||||||
var innerRotation = controller.rotation;
|
var localRotation = { x: 0, y: 0, z: 0, w: 1 }
|
||||||
|
|
||||||
controllerDisplay.parts[partName] = controller.parts[partName];
|
controllerDisplay.parts[partName] = controller.parts[partName];
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
url: part.modelURL,
|
url: part.modelURL,
|
||||||
localPosition: partPosition,
|
localPosition: localPosition,
|
||||||
localRotation: innerRotation,
|
localRotation: localRotation,
|
||||||
parentID: MyAvatar.SELF_ID,
|
parentID: baseOverlayID,
|
||||||
parentJointIndex: controller.jointIndex,
|
|
||||||
ignoreRayIntersection: true
|
ignoreRayIntersection: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -207,11 +206,10 @@ createControllerDisplay = function(config) {
|
||||||
properties['textures'] = textures;
|
properties['textures'] = textures;
|
||||||
}
|
}
|
||||||
|
|
||||||
overlayID = Overlays.addOverlay("model", properties);
|
var overlayID = Overlays.addOverlay("model", properties);
|
||||||
|
|
||||||
if (part.type === "rotational") {
|
if (part.type === "rotational") {
|
||||||
var input = resolveHardware(part.input);
|
var input = resolveHardware(part.input);
|
||||||
print("Mapping to: ", part.input, input);
|
|
||||||
mapping.from([input]).peek().to(function(partName) {
|
mapping.from([input]).peek().to(function(partName) {
|
||||||
return function(value) {
|
return function(value) {
|
||||||
// insert the most recent controller value into controllerDisplay.partValues.
|
// insert the most recent controller value into controllerDisplay.partValues.
|
||||||
|
|
Loading…
Reference in a new issue