mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 22:37:11 +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/gridTool.js",
|
||||||
"libraries/entityList.js",
|
"libraries/entityList.js",
|
||||||
"particle_explorer/particleExplorerTool.js",
|
"particle_explorer/particleExplorerTool.js",
|
||||||
"libraries/lightOverlayManager.js"
|
"libraries/entityIconOverlayManager.js"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var selectionDisplay = SelectionDisplay;
|
var selectionDisplay = SelectionDisplay;
|
||||||
var selectionManager = SelectionManager;
|
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();
|
var cameraManager = new CameraManager();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
var POINT_LIGHT_URL = "http://s3.amazonaws.com/hifi-public/images/tools/point-light.svg";
|
EntityIconOverlayManager = function(entityTypes, getOverlayPropertiesFunc) {
|
||||||
var SPOT_LIGHT_URL = "http://s3.amazonaws.com/hifi-public/images/tools/spot-light.svg";
|
|
||||||
|
|
||||||
LightOverlayManager = function() {
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var visible = false;
|
var visible = false;
|
||||||
|
@ -79,24 +76,33 @@ LightOverlayManager = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEntity(entityID) {
|
function addEntity(entityID) {
|
||||||
var properties = Entities.getEntityProperties(entityID);
|
var properties = Entities.getEntityProperties(entityID, ['position', 'type']);
|
||||||
if (properties.type == "Light" && !(entityID in entityOverlays)) {
|
if (entityTypes.indexOf(properties.type) > -1 && !(entityID in entityOverlays)) {
|
||||||
var overlay = getOverlay();
|
var overlay = getOverlay();
|
||||||
entityOverlays[entityID] = overlay;
|
entityOverlays[entityID] = overlay;
|
||||||
entityIDs[entityID] = entityID;
|
entityIDs[entityID] = entityID;
|
||||||
Overlays.editOverlay(overlay, {
|
var overlayProperties = {
|
||||||
position: properties.position,
|
position: properties.position,
|
||||||
url: properties.isSpotlight ? SPOT_LIGHT_URL : POINT_LIGHT_URL,
|
|
||||||
rotation: Quat.fromPitchYawRollDegrees(0, 0, 270),
|
rotation: Quat.fromPitchYawRollDegrees(0, 0, 270),
|
||||||
visible: visible,
|
visible: visible,
|
||||||
alpha: 0.9,
|
alpha: 0.9,
|
||||||
scale: 0.5,
|
scale: 0.5,
|
||||||
|
drawInFront: true,
|
||||||
|
isFacingAvatar: true,
|
||||||
color: {
|
color: {
|
||||||
red: 255,
|
red: 255,
|
||||||
green: 255,
|
green: 255,
|
||||||
blue: 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]);
|
Overlays.deleteOverlay(allOverlays[i]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
Loading…
Reference in a new issue