Fixed grabbing in VR

This commit is contained in:
ksuprynowicz 2023-04-22 19:53:52 +02:00
parent 6f92cf0330
commit 85262dfe28
6 changed files with 22 additions and 10 deletions

View file

@ -39,8 +39,9 @@ Rectangle {
} }
Component.onCompleted: { Component.onCompleted: {
AudioScriptingInterface.noiseGateOpened.connect(function() { micBar.gated = false; }); //TODO: this was causing type errors
AudioScriptingInterface.noiseGateClosed.connect(function() { micBar.gated = true; }); //AudioScriptingInterface.noiseGateOpened.connect(function() { micBar.gated = false; });
//AudioScriptingInterface.noiseGateClosed.connect(function() { micBar.gated = true; });
HMD.displayModeChanged.connect(function() { HMD.displayModeChanged.connect(function() {
muted = AudioScriptingInterface.muted; muted = AudioScriptingInterface.muted;
pushToTalk = AudioScriptingInterface.pushToTalk; pushToTalk = AudioScriptingInterface.pushToTalk;

View file

@ -102,7 +102,9 @@ Script.include("/~/system/libraries/controllers.js");
for (var i = 0; i < nearbyEntityProperties.length; i++) { for (var i = 0; i < nearbyEntityProperties.length; i++) {
var props = nearbyEntityProperties[i]; var props = nearbyEntityProperties[i];
var grabPosition = controllerData.controllerLocations[this.hand].position; // Is offset from hand position. var grabPosition = controllerData.controllerLocations[this.hand].position; // Is offset from hand position.
var dist = distanceBetweenPointAndEntityBoundingBox(grabPosition, props); // TODO: this function gives incorrect result now and needs to be fixed later
//var dist = distanceBetweenPointAndEntityBoundingBox(grabPosition, props);
var dist = 0;
var distance = Vec3.distance(grabPosition, props.position); var distance = Vec3.distance(grabPosition, props.position);
if ((dist > nearGrabDistance) || if ((dist > nearGrabDistance) ||
(distance > nearGrabRadius)) { // Only smallish entities can be near grabbed. (distance > nearGrabRadius)) { // Only smallish entities can be near grabbed.

View file

@ -73,23 +73,24 @@ Script.include("/~/system/libraries/controllers.js");
width: 0.025, width: 0.025,
drawInFront: true drawInFront: true
}; };
//V8TODO: check render states
var teleportEnd = { var teleportEnd = {
type: "model", type: "Model",
url: TARGET_MODEL_URL, url: TARGET_MODEL_URL,
dimensions: TARGET_MODEL_DIMENSIONS, dimensions: TARGET_MODEL_DIMENSIONS,
ignorePickIntersection: true ignorePickIntersection: true
}; };
var seatEnd = { var seatEnd = {
type: "model", type: "Model",
url: SEAT_MODEL_URL, url: SEAT_MODEL_URL,
dimensions: TARGET_MODEL_DIMENSIONS, dimensions: TARGET_MODEL_DIMENSIONS,
ignorePickIntersection: true ignorePickIntersection: true
}; };
var collisionEnd = { var collisionEnd = {
type: "shape", type: "Shape",
shape: "box", shape: "box",
dimensions: { x: 1.0, y: 0.001, z: 1.0 }, dimensions: { x: 1.0, y: 0.001, z: 1.0 },
alpha: 0.0, alpha: 0.0,
@ -409,6 +410,7 @@ Script.include("/~/system/libraries/controllers.js");
}); });
//V8TODO: this won't work anymore
_this.playAreaOverlay = Overlays.addOverlay("model", { _this.playAreaOverlay = Overlays.addOverlay("model", {
url: _this.PLAY_AREA_OVERLAY_MODEL, url: _this.PLAY_AREA_OVERLAY_MODEL,
drawInFront: false, drawInFront: false,
@ -434,6 +436,7 @@ Script.include("/~/system/libraries/controllers.js");
for (var i = 0; i < _this.playAreaSensorPositions.length; i++) { for (var i = 0; i < _this.playAreaSensorPositions.length; i++) {
if (i > _this.playAreaSensorPositionOverlays.length - 1) { if (i > _this.playAreaSensorPositionOverlays.length - 1) {
//V8TODO: replace with local entity
var overlay = Overlays.addOverlay("model", { var overlay = Overlays.addOverlay("model", {
url: _this.PLAY_AREA_SENSOR_OVERLAY_MODEL, url: _this.PLAY_AREA_SENSOR_OVERLAY_MODEL,
dimensions: _this.PLAY_AREA_SENSOR_OVERLAY_DIMENSIONS, dimensions: _this.PLAY_AREA_SENSOR_OVERLAY_DIMENSIONS,

View file

@ -11,13 +11,15 @@
/* global Script, Menu */ /* global Script, Menu */
Script.include("controllerDispatcher.js");
var CONTOLLER_SCRIPTS = [ var CONTOLLER_SCRIPTS = [
"squeezeHands.js", "squeezeHands.js",
"controllerDisplayManager.js", "controllerDisplayManager.js",
"grab.js", "grab.js",
//"toggleAdvancedMovementForHandControllers.js", //"toggleAdvancedMovementForHandControllers.js",
"handTouch.js", "handTouch.js",
"controllerDispatcher.js", //"controllerDispatcher.js",
"controllerModules/nearParentGrabOverlay.js", "controllerModules/nearParentGrabOverlay.js",
"controllerModules/stylusInput.js", "controllerModules/stylusInput.js",
"controllerModules/equipEntity.js", "controllerModules/equipEntity.js",
@ -44,6 +46,7 @@ var DEBUG_MENU_ITEM = "Debug defaultScripts.js";
function runDefaultsTogether() { function runDefaultsTogether() {
for (var j in CONTOLLER_SCRIPTS) { for (var j in CONTOLLER_SCRIPTS) {
if (CONTOLLER_SCRIPTS.hasOwnProperty(j)) { if (CONTOLLER_SCRIPTS.hasOwnProperty(j)) {
print("including " + CONTOLLER_SCRIPTS[j]);
Script.include(CONTOLLER_SCRIPTS[j]); Script.include(CONTOLLER_SCRIPTS[j]);
} }
} }
@ -52,6 +55,7 @@ function runDefaultsTogether() {
function runDefaultsSeparately() { function runDefaultsSeparately() {
for (var i in CONTOLLER_SCRIPTS) { for (var i in CONTOLLER_SCRIPTS) {
if (CONTOLLER_SCRIPTS.hasOwnProperty(i)) { if (CONTOLLER_SCRIPTS.hasOwnProperty(i)) {
print("loading " + CONTOLLER_SCRIPTS[j]);
Script.load(CONTOLLER_SCRIPTS[i]); Script.load(CONTOLLER_SCRIPTS[i]);
} }
} }

View file

@ -101,7 +101,6 @@ SelectionManager = (function() {
return; return;
} }
print("handleEntitySelectionToolUpdates JSON.parse(message): " + messageParsed.method);
if (messageParsed.method === "selectEntity") { if (messageParsed.method === "selectEntity") {
if (!that.editEnabled) { if (!that.editEnabled) {
return; return;
@ -1302,7 +1301,7 @@ SelectionDisplay = (function() {
var debugPickPlaneEnabled = false; var debugPickPlaneEnabled = false;
var debugPickPlane = Entities.addEntity({ var debugPickPlane = Entities.addEntity({
type: "shape", type: "Shape",
shape: "Quad", shape: "Quad",
alpha: 0.25, alpha: 0.25,
color: COLOR_DEBUG_PICK_PLANE, color: COLOR_DEBUG_PICK_PLANE,

View file

@ -565,6 +565,9 @@ var distanceBetweenPointAndEntityBoundingBox = function(point, entityProps) {
var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions); var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions);
var localMin = Vec3.subtract(entityXform.pos, minOffset); var localMin = Vec3.subtract(entityXform.pos, minOffset);
var localMax = Vec3.sum(entityXform.pos, maxOffset); var localMax = Vec3.sum(entityXform.pos, maxOffset);
// TODO: was originally this, but this causes an error on V8 branch and probably never worked on QtScript either
//var localMin = Vec3.subtract(entityXform.trans, minOffset);
//var localMax = Vec3.sum(entityXform.trans, maxOffset);
var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z}; var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z};
v.x = Math.max(v.x, localMin.x); v.x = Math.max(v.x, localMin.x);