mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 13:47:23 +02:00
Create entities at hand position rather than in front of avatar
This commit is contained in:
parent
59dc5ec3b8
commit
ca7c747c96
2 changed files with 11 additions and 5 deletions
|
@ -110,6 +110,7 @@ CreatePalette = function (side, leftInputs, rightInputs) {
|
|||
}
|
||||
|
||||
function update(intersectionOverlayID) {
|
||||
var CREATE_OFFSET = { x: 0, y: 0.05, z: -0.02 };
|
||||
// Highlight cube.
|
||||
if (intersectionOverlayID === cubeOverlay !== isHighlightingCube) {
|
||||
isHighlightingCube = !isHighlightingCube;
|
||||
|
@ -119,14 +120,14 @@ CreatePalette = function (side, leftInputs, rightInputs) {
|
|||
// Cube click.
|
||||
if (isHighlightingCube && controlHand.triggerClicked() !== isCubePressed) {
|
||||
isCubePressed = controlHand.triggerClicked();
|
||||
|
||||
if (isCubePressed) {
|
||||
Overlays.editOverlay(cubeOverlay, {
|
||||
localPosition: Vec3.sum(CUBE_PROPERTIES.localPosition, { x: 0, y: 0, z: 0.01 })
|
||||
});
|
||||
CUBE_ENTITY_PROPERTIES.position =
|
||||
Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0.2, z: -1.0 }));
|
||||
CUBE_ENTITY_PROPERTIES.rotation = MyAvatar.orientation;
|
||||
CUBE_ENTITY_PROPERTIES.position = Vec3.sum(controlHand.palmPosition(),
|
||||
Vec3.multiplyQbyV(controlHand.orientation(),
|
||||
Vec3.sum({ x: 0, y: CUBE_ENTITY_PROPERTIES.dimensions.z / 2, z: 0 }, CREATE_OFFSET)));
|
||||
CUBE_ENTITY_PROPERTIES.rotation = controlHand.orientation();
|
||||
Entities.addEntity(CUBE_ENTITY_PROPERTIES);
|
||||
} else {
|
||||
Overlays.editOverlay(cubeOverlay, {
|
||||
|
|
|
@ -39,6 +39,7 @@ Hand = function (side) {
|
|||
handPose,
|
||||
handPosition,
|
||||
handOrientation,
|
||||
palmPosition,
|
||||
|
||||
intersection = {};
|
||||
|
||||
|
@ -70,6 +71,10 @@ Hand = function (side) {
|
|||
return handOrientation;
|
||||
}
|
||||
|
||||
function getPalmPosition() {
|
||||
return palmPosition;
|
||||
}
|
||||
|
||||
function triggerPressed() {
|
||||
return isTriggerPressed;
|
||||
}
|
||||
|
@ -88,7 +93,6 @@ Hand = function (side) {
|
|||
|
||||
function update() {
|
||||
var gripValue,
|
||||
palmPosition,
|
||||
overlayID,
|
||||
overlayIDs,
|
||||
overlayDistance,
|
||||
|
@ -191,6 +195,7 @@ Hand = function (side) {
|
|||
valid: valid,
|
||||
position: position,
|
||||
orientation: orientation,
|
||||
palmPosition: getPalmPosition,
|
||||
triggerPressed: triggerPressed,
|
||||
triggerClicked: triggerClicked,
|
||||
gripClicked: gripClicked,
|
||||
|
|
Loading…
Reference in a new issue