mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 12:54:30 +02:00
keep parent of lights that already have parents
This commit is contained in:
parent
890f98b38b
commit
eb03dcd821
1 changed files with 22 additions and 14 deletions
|
@ -47,10 +47,6 @@ if (SHOW_OVERLAYS === true) {
|
||||||
lightOverlayManager.setVisible(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 DEFAULT_PARENT_ID = '{00000000-0000-0000-0000-000000000000}'
|
||||||
|
|
||||||
var AXIS_SCALE = 1;
|
var AXIS_SCALE = 1;
|
||||||
|
@ -408,7 +404,7 @@ function makeSliders(light) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function createLightModel(position,rotation) {
|
function createLightModel(position, rotation) {
|
||||||
var blockProperties = {
|
var blockProperties = {
|
||||||
name: 'Hifi-Spotlight-Model',
|
name: 'Hifi-Spotlight-Model',
|
||||||
type: 'Model',
|
type: 'Model',
|
||||||
|
@ -417,7 +413,7 @@ function createLightModel(position,rotation) {
|
||||||
dimensions: LIGHT_MODEL_DIMENSIONS,
|
dimensions: LIGHT_MODEL_DIMENSIONS,
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
position: position,
|
position: position,
|
||||||
rotation:rotation,
|
rotation: rotation,
|
||||||
script: PARENT_SCRIPT_URL,
|
script: PARENT_SCRIPT_URL,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
handControllerKey: {
|
handControllerKey: {
|
||||||
|
@ -529,6 +525,7 @@ function handleValueMessages(channel, message, sender) {
|
||||||
|
|
||||||
var currentLight;
|
var currentLight;
|
||||||
var block;
|
var block;
|
||||||
|
var hasParent = false;
|
||||||
|
|
||||||
function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
if (channel !== 'Hifi-Light-Overlay-Ray-Check') {
|
if (channel !== 'Hifi-Light-Overlay-Ray-Check') {
|
||||||
|
@ -553,7 +550,16 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
|
|
||||||
currentLight = lightID;
|
currentLight = lightID;
|
||||||
var lightProperties = Entities.getEntityProperties(lightID);
|
var lightProperties = Entities.getEntityProperties(lightID);
|
||||||
block = createLightModel(lightProperties.position,lightProperties.rotation);
|
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 = {
|
var light = {
|
||||||
id: lightID,
|
id: lightID,
|
||||||
|
@ -604,18 +610,20 @@ function cleanup(fromMessage) {
|
||||||
parentID: null,
|
parentID: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
if(fromMessage!==true){
|
if (fromMessage !== true) {
|
||||||
Messages.messageReceived.disconnect(handleLightModMessages);
|
Messages.messageReceived.disconnect(handleLightModMessages);
|
||||||
Messages.messageReceived.disconnect(handleValueMessages);
|
Messages.messageReceived.disconnect(handleValueMessages);
|
||||||
Messages.messageReceived.disconnect(handleLightOverlayRayCheckMessages);
|
Messages.messageReceived.disconnect(handleLightOverlayRayCheckMessages);
|
||||||
lightOverlayManager.setVisible(false);
|
lightOverlayManager.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
selectionManager.clearSelections();
|
selectionManager.clearSelections();
|
||||||
Script.update.disconnect(rotateCloseButtons);
|
Script.update.disconnect(rotateCloseButtons);
|
||||||
|
if (hasParent === false) {
|
||||||
Entities.deleteEntity(block);
|
Entities.deleteEntity(block);
|
||||||
|
}
|
||||||
|
hasParent = false;
|
||||||
currentLight = null;
|
currentLight = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue