mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 11:35:20 +02:00
Merge pull request #11560 from druiz17/far-grab-nondynamic
Far grab non-dynamic entities
This commit is contained in:
commit
4a3b59ea61
2 changed files with 37 additions and 6 deletions
|
@ -119,6 +119,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
this.reticleMaxX;
|
this.reticleMaxX;
|
||||||
this.reticleMinY = MARGIN;
|
this.reticleMinY = MARGIN;
|
||||||
this.reticleMaxY;
|
this.reticleMaxY;
|
||||||
|
this.madeDynamic = false;
|
||||||
|
|
||||||
var ACTION_TTL = 15; // seconds
|
var ACTION_TTL = 15; // seconds
|
||||||
|
|
||||||
|
@ -344,6 +345,13 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||||
Entities.callEntityMethod(this.grabbedThingID, "releaseGrab", args);
|
Entities.callEntityMethod(this.grabbedThingID, "releaseGrab", args);
|
||||||
|
|
||||||
|
if (this.madeDynamic) {
|
||||||
|
var props = {};
|
||||||
|
props.dynamic = false;
|
||||||
|
props.localVelocity = {x: 0, y: 0, z: 0};
|
||||||
|
Entities.editEntity(this.grabbedThingID, props);
|
||||||
|
this.madeDynamic = false;
|
||||||
|
}
|
||||||
this.actionID = null;
|
this.actionID = null;
|
||||||
this.grabbedThingID = null;
|
this.grabbedThingID = null;
|
||||||
};
|
};
|
||||||
|
@ -503,7 +511,13 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
this.destroyContextOverlay();
|
this.destroyContextOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entityIsDistanceGrabbable(targetProps)) {
|
if (entityIsGrabbable(targetProps)) {
|
||||||
|
if (!entityIsDistanceGrabbable(targetProps)) {
|
||||||
|
targetProps.dynamic = true;
|
||||||
|
Entities.editEntity(entityID, targetProps);
|
||||||
|
this.madeDynamic = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.distanceRotating) {
|
if (!this.distanceRotating) {
|
||||||
this.grabbedThingID = entityID;
|
this.grabbedThingID = entityID;
|
||||||
this.grabbedDistance = rayPickInfo.distance;
|
this.grabbedDistance = rayPickInfo.distance;
|
||||||
|
|
|
@ -15,12 +15,13 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
/* global MyAvatar, Entities, Script, Camera, Vec3, Reticle, Overlays, getEntityCustomData, Messages, Quat, Controller,
|
/* global MyAvatar, Entities, Script, Camera, Vec3, Reticle, Overlays, getEntityCustomData, Messages, Quat, Controller,
|
||||||
isInEditMode, HMD */
|
isInEditMode, HMD entityIsGrabbable*/
|
||||||
|
|
||||||
|
|
||||||
(function() { // BEGIN LOCAL_SCOPE
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
Script.include("/~/system/libraries/utils.js");
|
Script.include("/~/system/libraries/utils.js");
|
||||||
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
var MAX_SOLID_ANGLE = 0.01; // objects that appear smaller than this can't be grabbed
|
var MAX_SOLID_ANGLE = 0.01; // objects that appear smaller than this can't be grabbed
|
||||||
|
|
||||||
var DELAY_FOR_30HZ = 33; // milliseconds
|
var DELAY_FOR_30HZ = 33; // milliseconds
|
||||||
|
@ -330,9 +331,11 @@ Grabber.prototype.pressEvent = function(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isDynamic = Entities.getEntityProperties(pickResults.objectID, "dynamic").dynamic;
|
var props = Entities.getEntityProperties(pickResults.objectID, ["dynamic", "userData", "locked", "type"]);
|
||||||
if (!isDynamic) {
|
var isDynamic = props.dynamic;
|
||||||
// only grab dynamic objects
|
var isGrabbable = props.grabbable;
|
||||||
|
if (!entityIsGrabbable(props)) {
|
||||||
|
// only grab grabbable objects
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,6 +353,7 @@ Grabber.prototype.pressEvent = function(event) {
|
||||||
var entityProperties = Entities.getEntityProperties(clickedEntity);
|
var entityProperties = Entities.getEntityProperties(clickedEntity);
|
||||||
this.startPosition = entityProperties.position;
|
this.startPosition = entityProperties.position;
|
||||||
this.lastRotation = entityProperties.rotation;
|
this.lastRotation = entityProperties.rotation;
|
||||||
|
this.madeDynamic = false;
|
||||||
var cameraPosition = Camera.getPosition();
|
var cameraPosition = Camera.getPosition();
|
||||||
|
|
||||||
var objectBoundingDiameter = Vec3.length(entityProperties.dimensions);
|
var objectBoundingDiameter = Vec3.length(entityProperties.dimensions);
|
||||||
|
@ -361,6 +365,11 @@ Grabber.prototype.pressEvent = function(event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entityIsGrabbable(props) && !isDynamic) {
|
||||||
|
entityProperties.dynamic = true;
|
||||||
|
Entities.editEntity(clickedEntity, entityProperties);
|
||||||
|
this.madeDynamic = true;
|
||||||
|
}
|
||||||
// this.activateEntity(clickedEntity, entityProperties);
|
// this.activateEntity(clickedEntity, entityProperties);
|
||||||
this.isGrabbing = true;
|
this.isGrabbing = true;
|
||||||
|
|
||||||
|
@ -416,6 +425,14 @@ Grabber.prototype.releaseEvent = function(event) {
|
||||||
if (this.actionID) {
|
if (this.actionID) {
|
||||||
Entities.deleteAction(this.entityID, this.actionID);
|
Entities.deleteAction(this.entityID, this.actionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.madeDynamic) {
|
||||||
|
var entityProps = {};
|
||||||
|
entityProps.dynamic = false;
|
||||||
|
entityProps.localVelocity = {x: 0, y: 0, z: 0};
|
||||||
|
Entities.editEntity(this.entityID, entityProps);
|
||||||
|
}
|
||||||
|
|
||||||
this.actionID = null;
|
this.actionID = null;
|
||||||
|
|
||||||
LaserPointers.setRenderState(this.mouseRayEntities, "");
|
LaserPointers.setRenderState(this.mouseRayEntities, "");
|
||||||
|
|
Loading…
Reference in a new issue