Merge pull request #15351 from dback2/materialTargetRC82Fix

Case 22092: Fix avatar/shape material targets, refresh material target when parent changes (RC82)
This commit is contained in:
Shannon Romano 2019-04-11 17:51:19 -07:00 committed by GitHub
commit a368658da2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 14 deletions

View file

@ -2523,12 +2523,17 @@ var PropertiesTool = function (opts) {
propertyRanges: propertyRanges, propertyRanges: propertyRanges,
}); });
} else if (data.type === "materialTargetRequest") { } else if (data.type === "materialTargetRequest") {
var properties = Entities.getEntityProperties(data.entityID, ["type", "parentID"]);
var parentModel = properties.parentID !== Uuid.NULL &&
Entities.getEntityProperties(properties.parentID, ["type"]).type === "Model";
var parentModelData; var parentModelData;
if (properties.type === "Material" && parentModel) { var properties = Entities.getEntityProperties(data.entityID, ["type", "parentID"]);
if (properties.type === "Material" && properties.parentID !== Uuid.NULL) {
var parentType = Entities.getEntityProperties(properties.parentID, ["type"]).type;
if (parentType === "Model" || Entities.getNestableType(properties.parentID) === "avatar") {
parentModelData = Graphics.getModel(properties.parentID); parentModelData = Graphics.getModel(properties.parentID);
} else if (parentType === "Shape" || parentType === "Box" || parentType === "Sphere") {
parentModelData = {};
parentModelData.numMeshes = 1;
parentModelData.materialNames = [];
}
} }
emitScriptEvent({ emitScriptEvent({
type: 'materialTargetReply', type: 'materialTargetReply',

View file

@ -55,6 +55,7 @@ const GROUPS = [
label: "Parent", label: "Parent",
type: "string", type: "string",
propertyID: "parentID", propertyID: "parentID",
onChange: parentIDChanged,
}, },
{ {
label: "Parent Joint Index", label: "Parent Joint Index",
@ -2009,6 +2010,9 @@ function createStringProperty(property, elProperty) {
elInput.addEventListener('change', createEmitTextPropertyUpdateFunction(property)); elInput.addEventListener('change', createEmitTextPropertyUpdateFunction(property));
if (propertyData.onChange !== undefined) {
elInput.addEventListener('change', propertyData.onChange);
}
elProperty.appendChild(elInput); elProperty.appendChild(elInput);
@ -2624,6 +2628,17 @@ function createProperty(propertyData, propertyElementID, propertyName, propertyI
} }
/**
* PROPERTY-SPECIFIC CALLBACKS
*/
function parentIDChanged() {
if (selectedEntityProperties.type === "Material") {
requestMaterialTarget();
}
}
/** /**
* BUTTON CALLBACKS * BUTTON CALLBACKS
*/ */
@ -3158,6 +3173,10 @@ function setTextareaScrolling(element) {
* MATERIAL TARGET FUNCTIONS * MATERIAL TARGET FUNCTIONS
*/ */
function requestMaterialTarget() {
EventBridge.emitWebEvent(JSON.stringify({ type: 'materialTargetRequest', entityID: selectedEntityProperties.id }));
}
function setMaterialTargetData(materialTargetData) { function setMaterialTargetData(materialTargetData) {
let elDivOptions = getPropertyInputElement("parentMaterialName"); let elDivOptions = getPropertyInputElement("parentMaterialName");
resetDynamicMultiselectProperty(elDivOptions); resetDynamicMultiselectProperty(elDivOptions);
@ -3258,8 +3277,10 @@ function sendMaterialTargetProperty() {
if (materialTargetList !== "") { if (materialTargetList !== "") {
materialTargetList = materialTargetList.substring(0, materialTargetList.length - 1); materialTargetList = materialTargetList.substring(0, materialTargetList.length - 1);
if (materialTargetList.length > 1) {
materialTargetList = "[" + materialTargetList + "]"; materialTargetList = "[" + materialTargetList + "]";
} }
}
updateProperty("parentMaterialName", materialTargetList, false); updateProperty("parentMaterialName", materialTargetList, false);
} }
@ -3782,7 +3803,7 @@ function loaded() {
} }
if (hasSelectedEntityChanged && selectedEntityProperties.type === "Material") { if (hasSelectedEntityChanged && selectedEntityProperties.type === "Material") {
EventBridge.emitWebEvent(JSON.stringify({ type: 'materialTargetRequest', entityID: selectedEntityProperties.id })); requestMaterialTarget();
} }
let activeElement = document.activeElement; let activeElement = document.activeElement;