mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 17:04:20 +02:00
Improve mouse click logic in scripts.
Also restore behavior of controlPanel.js being hidden on startup.
This commit is contained in:
parent
497713b020
commit
13a63a5a3d
2 changed files with 38 additions and 14 deletions
|
@ -25,7 +25,8 @@ var ADDRESS_BAR_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/tools/address-bar-toggl
|
||||||
var panel = new OverlayPanel({
|
var panel = new OverlayPanel({
|
||||||
positionBinding: { avatar: "MyAvatar" },
|
positionBinding: { avatar: "MyAvatar" },
|
||||||
offsetPosition: { x: 0, y: 0.4, z: 1 },
|
offsetPosition: { x: 0, y: 0.4, z: 1 },
|
||||||
offsetRotation: { w: 0, x: 0, y: 1, z: 0 }
|
offsetRotation: { w: 0, x: 0, y: 1, z: 0 },
|
||||||
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var background = new Image3DOverlay({
|
var background = new Image3DOverlay({
|
||||||
|
@ -36,7 +37,8 @@ var background = new Image3DOverlay({
|
||||||
},
|
},
|
||||||
isFacingAvatar: false,
|
isFacingAvatar: false,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
ignoreRayIntersection: false
|
ignoreRayIntersection: false,
|
||||||
|
visible: false
|
||||||
});
|
});
|
||||||
panel.addChild(background);
|
panel.addChild(background);
|
||||||
|
|
||||||
|
@ -53,7 +55,8 @@ var closeButton = new Image3DOverlay({
|
||||||
x: 0.1,
|
x: 0.1,
|
||||||
y: 0.1,
|
y: 0.1,
|
||||||
z: 0.001
|
z: 0.001
|
||||||
}
|
},
|
||||||
|
visible: false
|
||||||
});
|
});
|
||||||
closeButton.onClick = function(event) {
|
closeButton.onClick = function(event) {
|
||||||
panel.visible = false;
|
panel.visible = false;
|
||||||
|
@ -79,7 +82,8 @@ var micMuteButton = new Image3DOverlay({
|
||||||
x: -0.1,
|
x: -0.1,
|
||||||
y: 0.1,
|
y: 0.1,
|
||||||
z: 0.001
|
z: 0.001
|
||||||
}
|
},
|
||||||
|
visible: false
|
||||||
});
|
});
|
||||||
micMuteButton.onClick = function(event) {
|
micMuteButton.onClick = function(event) {
|
||||||
AudioDevice.toggleMute();
|
AudioDevice.toggleMute();
|
||||||
|
@ -105,7 +109,8 @@ var faceMuteButton = new Image3DOverlay({
|
||||||
x: -0.1,
|
x: -0.1,
|
||||||
y: -0.1,
|
y: -0.1,
|
||||||
z: 0.001
|
z: 0.001
|
||||||
}
|
},
|
||||||
|
visible: false
|
||||||
});
|
});
|
||||||
faceMuteButton.onClick = function(event) {
|
faceMuteButton.onClick = function(event) {
|
||||||
FaceTracker.toggleMute();
|
FaceTracker.toggleMute();
|
||||||
|
@ -131,13 +136,16 @@ var addressBarButton = new Image3DOverlay({
|
||||||
x: 0.1,
|
x: 0.1,
|
||||||
y: -0.1,
|
y: -0.1,
|
||||||
z: 0.001
|
z: 0.001
|
||||||
}
|
},
|
||||||
|
visible: false
|
||||||
});
|
});
|
||||||
addressBarButton.onClick = function(event) {
|
addressBarButton.onClick = function(event) {
|
||||||
DialogsManager.toggleAddressBar();
|
DialogsManager.toggleAddressBar();
|
||||||
};
|
};
|
||||||
panel.addChild(addressBarButton);
|
panel.addChild(addressBarButton);
|
||||||
|
|
||||||
|
panel.setChildrenVisible();
|
||||||
|
|
||||||
|
|
||||||
function onMicMuteToggled() {
|
function onMicMuteToggled() {
|
||||||
var offset;
|
var offset;
|
||||||
|
@ -180,6 +188,16 @@ function onMouseDown(event) {
|
||||||
if (event.isRightButton) {
|
if (event.isRightButton) {
|
||||||
mouseDown.pos = { x: event.x, y: event.y };
|
mouseDown.pos = { x: event.x, y: event.y };
|
||||||
}
|
}
|
||||||
|
mouseDown.maxDistance = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseMove(event) {
|
||||||
|
if (mouseDown.maxDistance !== undefined) {
|
||||||
|
var dist = Vec3.distance(mouseDown.pos, { x: event.x, y: event.y });
|
||||||
|
if (dist > mouseDown.maxDistance) {
|
||||||
|
mouseDown.maxDistance = dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseUp(event) {
|
function onMouseUp(event) {
|
||||||
|
@ -189,7 +207,7 @@ function onMouseUp(event) {
|
||||||
overlay.onClick(event);
|
overlay.onClick(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.isRightButton && Vec3.distance(mouseDown.pos, { x: event.x, y: event.y }) < 10) {
|
if (event.isRightButton && mouseDown.maxDistance < 10) {
|
||||||
panel.setProperties({
|
panel.setProperties({
|
||||||
visible: !panel.visible,
|
visible: !panel.visible,
|
||||||
rotation: Quat.multiply(MyAvatar.orientation, { x: 0, y: 1, z: 0, w: 0 })
|
rotation: Quat.multiply(MyAvatar.orientation, { x: 0, y: 1, z: 0, w: 0 })
|
||||||
|
@ -204,6 +222,7 @@ function onScriptEnd(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(onMouseDown);
|
Controller.mousePressEvent.connect(onMouseDown);
|
||||||
|
Controller.mouseMoveEvent.connect(onMouseMove);
|
||||||
Controller.mouseReleaseEvent.connect(onMouseUp);
|
Controller.mouseReleaseEvent.connect(onMouseUp);
|
||||||
AudioDevice.muteToggled.connect(onMicMuteToggled);
|
AudioDevice.muteToggled.connect(onMicMuteToggled);
|
||||||
FaceTracker.muteToggled.connect(onFaceMuteToggled);
|
FaceTracker.muteToggled.connect(onFaceMuteToggled);
|
||||||
|
|
|
@ -153,8 +153,6 @@ blueSquare3.offsetPosition = {
|
||||||
z: 0
|
z: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
mainPanel.setChildrenVisible();
|
|
||||||
|
|
||||||
var mouseDown = {};
|
var mouseDown = {};
|
||||||
|
|
||||||
function onMouseDown(event) {
|
function onMouseDown(event) {
|
||||||
|
@ -164,6 +162,16 @@ function onMouseDown(event) {
|
||||||
if (event.isRightButton) {
|
if (event.isRightButton) {
|
||||||
mouseDown.pos = { x: event.x, y: event.y };
|
mouseDown.pos = { x: event.x, y: event.y };
|
||||||
}
|
}
|
||||||
|
mouseDown.maxDistance = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseMove(event) {
|
||||||
|
if (mouseDown.maxDistance !== undefined) {
|
||||||
|
var dist = Vec3.distance(mouseDown.pos, { x: event.x, y: event.y });
|
||||||
|
if (dist > mouseDown.maxDistance) {
|
||||||
|
mouseDown.maxDistance = dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseUp(event) {
|
function onMouseUp(event) {
|
||||||
|
@ -177,7 +185,7 @@ function onMouseUp(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.isRightButton && Vec3.distance(mouseDown.pos, { x: event.x, y: event.y }) < 10) {
|
if (event.isRightButton && mouseDown.maxDistance < 10) {
|
||||||
mainPanel.visible = !mainPanel.visible;
|
mainPanel.visible = !mainPanel.visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,10 +194,7 @@ function onScriptEnd() {
|
||||||
mainPanel.destroy();
|
mainPanel.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
print(JSON.stringify(mainPanel.children));
|
|
||||||
print(JSON.stringify(bluePanel.children));
|
|
||||||
print(bluePanel._id);
|
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(onMouseDown);
|
Controller.mousePressEvent.connect(onMouseDown);
|
||||||
|
Controller.mouseMoveEvent.connect(onMouseMove);
|
||||||
Controller.mouseReleaseEvent.connect(onMouseUp);
|
Controller.mouseReleaseEvent.connect(onMouseUp);
|
||||||
Script.scriptEnding.connect(onScriptEnd);
|
Script.scriptEnding.connect(onScriptEnd);
|
||||||
|
|
Loading…
Reference in a new issue