keep parent of lights that already have parents

This commit is contained in:
James B. Pollack 2015-12-19 12:47:44 -08:00
parent 890f98b38b
commit eb03dcd821

View file

@ -47,10 +47,6 @@ if (SHOW_OVERLAYS === true) {
lightOverlayManager.setVisible(true);
}
// var entityResult = Entities.findRayIntersection(pickRay, true); // want precision picking
// var pickRay = Camera.computePickRay(event.x, event.y);
// var lightResult = lightOverlayManager.findRayIntersection(pickRay)
var DEFAULT_PARENT_ID = '{00000000-0000-0000-0000-000000000000}'
var AXIS_SCALE = 1;
@ -529,6 +525,7 @@ function handleValueMessages(channel, message, sender) {
var currentLight;
var block;
var hasParent = false;
function handleLightOverlayRayCheckMessages(channel, message, sender) {
if (channel !== 'Hifi-Light-Overlay-Ray-Check') {
@ -553,7 +550,16 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
currentLight = lightID;
var lightProperties = Entities.getEntityProperties(lightID);
if (lightProperties.parentID !== DEFAULT_PARENT_ID) {
//this light has a parent already. so lets call our block the parent and then make sure not to delete it at the end;
hasParent = true;
block = lightProperties.parentID;
if (lightProperties.parentJointIndex !== -1) {
//should make sure to retain the parent too. but i don't actually know what the
}
} else {
block = createLightModel(lightProperties.position, lightProperties.rotation);
}
var light = {
id: lightID,
@ -614,8 +620,10 @@ function cleanup(fromMessage) {
selectionManager.clearSelections();
Script.update.disconnect(rotateCloseButtons);
if (hasParent === false) {
Entities.deleteEntity(block);
}
hasParent = false;
currentLight = null;