mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 10:04:49 +02:00
Update LightOverlayManager to work with particles
This commit is contained in:
parent
49efd8ad42
commit
ce5ee42961
2 changed files with 32 additions and 12 deletions
|
@ -33,13 +33,27 @@ Script.include([
|
|||
"libraries/gridTool.js",
|
||||
"libraries/entityList.js",
|
||||
"particle_explorer/particleExplorerTool.js",
|
||||
"libraries/lightOverlayManager.js"
|
||||
"libraries/entityIconOverlayManager.js"
|
||||
]);
|
||||
|
||||
var selectionDisplay = SelectionDisplay;
|
||||
var selectionManager = SelectionManager;
|
||||
|
||||
var lightOverlayManager = new LightOverlayManager();
|
||||
const PARTICLE_SYSTEM_URL = Script.resolvePath("assets/images/icon-particles.svg");
|
||||
const POINT_LIGHT_URL = Script.resolvePath("assets/images/icon-point-light.svg");
|
||||
const SPOT_LIGHT_URL = Script.resolvePath("assets/images/icon-spot-light.svg");
|
||||
var lightOverlayManager = new EntityIconOverlayManager(['Light', 'ParticleEffect'], function(entityID) {
|
||||
var properties = Entities.getEntityProperties(entityID, ['type', 'isSpotlight']);
|
||||
if (properties.type === 'Light') {
|
||||
return {
|
||||
url: properties.isSpotlight ? SPOT_LIGHT_URL : POINT_LIGHT_URL,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
url: PARTICLE_SYSTEM_URL,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var cameraManager = new CameraManager();
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
var POINT_LIGHT_URL = "http://s3.amazonaws.com/hifi-public/images/tools/point-light.svg";
|
||||
var SPOT_LIGHT_URL = "http://s3.amazonaws.com/hifi-public/images/tools/spot-light.svg";
|
||||
|
||||
LightOverlayManager = function() {
|
||||
EntityIconOverlayManager = function(entityTypes, getOverlayPropertiesFunc) {
|
||||
var self = this;
|
||||
|
||||
var visible = false;
|
||||
|
@ -79,24 +76,33 @@ LightOverlayManager = function() {
|
|||
}
|
||||
|
||||
function addEntity(entityID) {
|
||||
var properties = Entities.getEntityProperties(entityID);
|
||||
if (properties.type == "Light" && !(entityID in entityOverlays)) {
|
||||
var properties = Entities.getEntityProperties(entityID, ['position', 'type']);
|
||||
if (entityTypes.indexOf(properties.type) > -1 && !(entityID in entityOverlays)) {
|
||||
var overlay = getOverlay();
|
||||
entityOverlays[entityID] = overlay;
|
||||
entityIDs[entityID] = entityID;
|
||||
Overlays.editOverlay(overlay, {
|
||||
var overlayProperties = {
|
||||
position: properties.position,
|
||||
url: properties.isSpotlight ? SPOT_LIGHT_URL : POINT_LIGHT_URL,
|
||||
rotation: Quat.fromPitchYawRollDegrees(0, 0, 270),
|
||||
visible: visible,
|
||||
alpha: 0.9,
|
||||
scale: 0.5,
|
||||
drawInFront: true,
|
||||
isFacingAvatar: true,
|
||||
color: {
|
||||
red: 255,
|
||||
green: 255,
|
||||
blue: 255
|
||||
}
|
||||
});
|
||||
};
|
||||
if (getOverlayPropertiesFunc) {
|
||||
var customProperties = getOverlayPropertiesFunc(entityID, properties);
|
||||
for (var key in customProperties) {
|
||||
overlayProperties[key] = customProperties[key];
|
||||
}
|
||||
}
|
||||
print("overlay:", properties.type, JSON.stringify(overlayProperties));
|
||||
Overlays.editOverlay(overlay, overlayProperties);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,4 +136,4 @@ LightOverlayManager = function() {
|
|||
Overlays.deleteOverlay(allOverlays[i]);
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
Loading…
Reference in a new issue