make requested changes

This commit is contained in:
Dante Ruiz 2018-04-11 13:30:21 -07:00
parent 54c3f48e65
commit ba9d5d18bc
6 changed files with 93 additions and 10 deletions

View file

@ -489,7 +489,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
entityID: this.targetEntityID
};
Messages.sendMessage('Hifi-unhighlight-entity', JSON.stringify(message));
Messages.sendLocalMessage('Hifi-unhighlight-entity', JSON.stringify(message));
var grabbedProperties = Entities.getEntityProperties(this.targetEntityID);
// if an object is "equipped" and has a predefined offset, use it.

View file

@ -1,7 +1,9 @@
"use strict";
//
// highlightNearbyEntities.js
//
// Created by Dante Ruiz 2018-4-10
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -12,6 +14,8 @@
DEFAULT_SEARCH_SPHERE_DISTANCE, getGrabbableData, makeLaserParams, entityIsCloneable, Messages, print
*/
"use strict";
(function () {
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Script.include("/~/system/libraries/controllers.js");
@ -40,15 +44,16 @@
this.isGrabable = function(controllerData, props) {
var entityIsGrabable = false;
if (dispatcherUtils.entityIsGrabbable(props) || entityIsCloneable(props)) {
// if we've attempted to grab a child, roll up to the root of the tree
var groupRootProps = dispatcherUtils.findGroupParent(controllerData, props);
if (dispatcherUtils.entityIsGrabbable(groupRootProps)) {
return true;
entityIsGrabable = true;
if (!dispatcherUtils.entityIsGrabbable(groupRootProps)) {
entityIsGrabable = false;
}
return true;
}
return false;
return entityIsGrabable;
};
this.hasHyperLink = function(props) {

View file

@ -0,0 +1,77 @@
//
// mouseHighlightEntities.js
//
// scripts/system/controllers/controllerModules/
//
// Created by Dante Ruiz 2018-4-11
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
/* jslint bitwise: true */
/* global Script, print, Entities, Picks, HMD */
(function() {
var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
function MouseHighlightEntities() {
this.highlightedEntity = null;
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
5,
["mouse"],
[],
100);
this.isReady = function(controllerData) {
if (HMD.active) {
print("????");
if (this.highlightedEntity) {
// unhighlight entity
}
} else {
var pickResult = controllerData.mouseRayPick;
if (pickResult.type === Picks.INTERSECTED_ENTITY) {
var targetEntityID = pickResult.objectID;
if (this.highlightedEntity !== targetEntityID) {
var targetProps = Entities.getEntityProperties(targetEntityID, [
"dynamic", "shapeType", "position",
"rotation", "dimensions", "density",
"userData", "locked", "type", "href"
]);
if (this.highlightedEntity) {
dispatcherUtils.unhighlightTargetEntity(this.highlightedEntity);
this.highlightedEntity = null;
}
if (dispatcherUtils.entityIsGrabbable(targetProps)) {
// highlight entity
dispatcherUtils.highlightTargetEntity(targetEntityID);
this.highlightedEntity = targetEntityID;
}
}
}
}
return dispatcherUtils.makeRunningValues(false, [], []);
};
this.run = function(controllerData) {
return this.isReady(controllerData);
};
}
var mouseHighlightEntities = new MouseHighlightEntities();
dispatcherUtils.enableDispatcherModule("MouseHighlightEntities", mouseHighlightEntities);
function cleanup() {
dispatcherUtils.disableDispatcherModule("MouseHighlightEntities");
}
Script.scriptEnding.connect(cleanup);
})();

View file

@ -120,7 +120,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
entityID: this.targetEntityID
};
Messages.sendMessage('Hifi-unhighlight-entity', JSON.stringify(message));
Messages.sendLocalMessage('Hifi-unhighlight-entity', JSON.stringify(message));
};
// this is for when the action is going to time-out

View file

@ -95,7 +95,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
entityID: this.targetEntityID
};
Messages.sendMessage('Hifi-unhighlight-entity', JSON.stringify(message));
Messages.sendLocalMessage('Hifi-unhighlight-entity', JSON.stringify(message));
var handJointIndex;
// if (this.ignoreIK) {
// handJointIndex = this.controllerJointIndex;

View file

@ -33,7 +33,8 @@ var CONTOLLER_SCRIPTS = [
"controllerModules/mouseHMD.js",
"controllerModules/scaleEntity.js",
"controllerModules/highlightNearbyEntities.js",
"controllerModules/nearGrabHyperLinkEntity.js"
"controllerModules/nearGrabHyperLinkEntity.js",
"controllerModules/mouseHighlightEntities.js"
];
var DEBUG_MENU_ITEM = "Debug defaultScripts.js";