mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 10:24:01 +02:00
fix avatar/shape material targets, refresh material target when parent changes
This commit is contained in:
parent
78256fb5bb
commit
b8b9035f9d
2 changed files with 40 additions and 14 deletions
|
@ -2523,18 +2523,23 @@ 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 parentModelData;
|
||||||
var parentModel = properties.parentID !== Uuid.NULL &&
|
var properties = Entities.getEntityProperties(data.entityID, ["type", "parentID"]);
|
||||||
Entities.getEntityProperties(properties.parentID, ["type"]).type === "Model";
|
if (properties.type === "Material" && properties.parentID !== Uuid.NULL) {
|
||||||
var parentModelData;
|
var parentType = Entities.getEntityProperties(properties.parentID, ["type"]).type;
|
||||||
if (properties.type === "Material" && parentModel) {
|
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") {
|
||||||
emitScriptEvent({
|
parentModelData = {};
|
||||||
type: 'materialTargetReply',
|
parentModelData.numMeshes = 1;
|
||||||
materialTargetData: parentModelData,
|
parentModelData.materialNames = [];
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
emitScriptEvent({
|
||||||
|
type: 'materialTargetReply',
|
||||||
|
materialTargetData: parentModelData,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
HMD.displayModeChanged.connect(function() {
|
HMD.displayModeChanged.connect(function() {
|
||||||
|
|
|
@ -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",
|
||||||
|
@ -2007,6 +2008,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);
|
||||||
|
|
||||||
|
@ -2622,6 +2626,17 @@ function createProperty(propertyData, propertyElementID, propertyName, propertyI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PROPERTY-SPECIFIC CALLBACKS
|
||||||
|
*/
|
||||||
|
|
||||||
|
function parentIDChanged() {
|
||||||
|
if (selectedEntityProperties.type === "Material") {
|
||||||
|
requestMaterialTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BUTTON CALLBACKS
|
* BUTTON CALLBACKS
|
||||||
*/
|
*/
|
||||||
|
@ -3156,6 +3171,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);
|
||||||
|
@ -3256,7 +3275,9 @@ function sendMaterialTargetProperty() {
|
||||||
|
|
||||||
if (materialTargetList !== "") {
|
if (materialTargetList !== "") {
|
||||||
materialTargetList = materialTargetList.substring(0, materialTargetList.length - 1);
|
materialTargetList = materialTargetList.substring(0, materialTargetList.length - 1);
|
||||||
materialTargetList = "[" + materialTargetList + "]";
|
if (materialTargetList.length > 1) {
|
||||||
|
materialTargetList = "[" + materialTargetList + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProperty("parentMaterialName", materialTargetList, false);
|
updateProperty("parentMaterialName", materialTargetList, false);
|
||||||
|
@ -3780,7 +3801,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;
|
||||||
|
|
Loading…
Reference in a new issue