Skip to content

Commit

Permalink
release more params of fbx mesh optimizer (cocos#14123)
Browse files Browse the repository at this point in the history
  • Loading branch information
arsen2010 authored Feb 8, 2023
1 parent 2c5ac16 commit f143e7e
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 4 deletions.
16 changes: 16 additions & 0 deletions editor/i18n/en/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,22 @@ module.exports = {
name: 'Ratio',
title: 'Target Ratio',
},
preserveSurfaceCurvature: {
name: 'Surface Curvature',
title: 'Preserve Surface Curvature',
},
preserveBorderEdges: {
name: 'Border Edges',
title: 'Preserve Border Edges',
},
preserveUVSeamEdges: {
name: 'UV Seam Edges',
title: 'Preserve UV Seam Edges',
},
preserveUVFoldoverEdges: {
name: 'UV Foldover Edges',
title: 'Preserve UV Foldover Edges',
},
enableSmartLink: {
name: 'Smart Link',
title: 'Enable Smart Link',
Expand Down
18 changes: 17 additions & 1 deletion editor/i18n/zh/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ module.exports = {
'若不勾选,网格数据被提交到 GPU 后会被自动释放。<br>',
},
meshOptimizer: {
name: 'Mesh Optimizer',
name: 'Mesh 优化',
title: 'Mesh Optimizer',
simplification: {
name: 'Simplification',
Expand Down Expand Up @@ -339,6 +339,22 @@ module.exports = {
name: 'LOD 压缩比例',
title: 'Target Ratio',
},
preserveSurfaceCurvature: {
name: '保留表面曲率',
title: 'Preserve Surface Curvature',
},
preserveBorderEdges: {
name: '保留边界边',
title: 'Preserve Border Edges',
},
preserveUVSeamEdges: {
name: '保留 UV 缝合边',
title: 'Preserve UV Seam Edges',
},
preserveUVFoldoverEdges: {
name: '保留 UV 折叠边',
title: 'Preserve UV Foldover Edges',
},
enableSmartLink: {
name: '防止破面',
title: 'Smart Link',
Expand Down
92 changes: 90 additions & 2 deletions editor/inspector/assets/fbx/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ exports.template = /* html */`
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.targetRatio.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.targetRatio.title"></ui-label>
<ui-slider slot="content" class="meshOptimizer-targetRatio-slider" min="0" max="1" step="0.01"></ui-slider>
</ui-prop>
<ui-prop>
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.preserveSurfaceCurvature.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.preserveSurfaceCurvature.title"></ui-label>
<ui-checkbox slot="content" class="meshOptimizer-preserveSurfaceCurvature-checkbox"></ui-checkbox>
</ui-prop>
<ui-prop>
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.preserveBorderEdges.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.preserveBorderEdges.title"></ui-label>
<ui-checkbox slot="content" class="meshOptimizer-preserveBorderEdges-checkbox"></ui-checkbox>
</ui-prop>
<ui-prop>
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.preserveUVSeamEdges.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.preserveUVSeamEdges.title"></ui-label>
<ui-checkbox slot="content" class="meshOptimizer-preserveUVSeamEdges-checkbox"></ui-checkbox>
</ui-prop>
<ui-prop>
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.preserveUVFoldoverEdges.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.preserveUVFoldoverEdges.title"></ui-label>
<ui-checkbox slot="content" class="meshOptimizer-preserveUVFoldoverEdges-checkbox"></ui-checkbox>
</ui-prop>
<ui-prop>
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.enableSmartLink.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.simplify.enableSmartLink.title"></ui-label>
<ui-checkbox slot="content" class="meshOptimizer-enableSmartLink-checkbox"></ui-checkbox>
Expand Down Expand Up @@ -165,6 +181,10 @@ exports.$ = {
// simplifyOptions
meshOptimizerSimplifyOptions: '.simplify-options',
meshOptimizerTargetRatioSlider: '.meshOptimizer-targetRatio-slider',
meshOptimizerPreserveSurfaceCurvatureCheckbox: '.meshOptimizer-preserveSurfaceCurvature-checkbox',
meshOptimizerPreserveBorderEdgesCheckbox: '.meshOptimizer-preserveBorderEdges-checkbox',
meshOptimizerPreserveUVSeamEdgesCheckbox: '.meshOptimizer-preserveUVSeamEdges-checkbox',
meshOptimizerPreserveUVFoldoverEdgesCheckbox: '.meshOptimizer-preserveUVFoldoverEdges-checkbox',
meshOptimizerEnableSmartLinkCheckbox: '.meshOptimizer-enableSmartLink-checkbox',
meshOptimizerAgressivenessSlider: '.meshOptimizer-agressiveness-slider',
meshOptimizerMaxIterationCountSlider: '.meshOptimizer-maxIterationCount-slider',
Expand Down Expand Up @@ -555,6 +575,74 @@ const Elements = {
updateElementReadonly.call(panel, panel.$.meshOptimizerEnableSmartLinkCheckbox);
},
},
preserveSurfaceCurvature: {
ready() {
const panel = this;
panel.$.meshOptimizerPreserveSurfaceCurvatureCheckbox.addEventListener('change', panel.setProp.bind(panel, 'meshOptimizer.simplifyOptions.preserveSurfaceCurvature', 'boolean'));
panel.$.meshOptimizerPreserveSurfaceCurvatureCheckbox.addEventListener('confirm', () => {
panel.dispatch('snapshot');
});
},
update() {
const panel = this;

panel.$.meshOptimizerPreserveSurfaceCurvatureCheckbox.value = getPropValue.call(panel, panel.meta.userData, false, 'meshOptimizer.simplifyOptions.preserveSurfaceCurvature');

updateElementInvalid.call(panel, panel.$.meshOptimizerPreserveSurfaceCurvatureCheckbox, 'meshOptimizer.simplifyOptions.preserveSurfaceCurvature');
updateElementReadonly.call(panel, panel.$.meshOptimizerPreserveSurfaceCurvatureCheckbox);
},
},
preserveBorderEdges: {
ready() {
const panel = this;
panel.$.meshOptimizerPreserveBorderEdgesCheckbox.addEventListener('change', panel.setProp.bind(panel, 'meshOptimizer.simplifyOptions.preserveBorderEdges', 'boolean'));
panel.$.meshOptimizerPreserveBorderEdgesCheckbox.addEventListener('confirm', () => {
panel.dispatch('snapshot');
});
},
update() {
const panel = this;

panel.$.meshOptimizerPreserveBorderEdgesCheckbox.value = getPropValue.call(panel, panel.meta.userData, false, 'meshOptimizer.simplifyOptions.preserveBorderEdges');

updateElementInvalid.call(panel, panel.$.meshOptimizerPreserveBorderEdgesCheckbox, 'meshOptimizer.simplifyOptions.preserveBorderEdges');
updateElementReadonly.call(panel, panel.$.meshOptimizerPreserveBorderEdgesCheckbox);
},
},
preserveUVSeamEdges: {
ready() {
const panel = this;
panel.$.meshOptimizerPreserveUVSeamEdgesCheckbox.addEventListener('change', panel.setProp.bind(panel, 'meshOptimizer.simplifyOptions.preserveUVSeamEdges', 'boolean'));
panel.$.meshOptimizerPreserveUVSeamEdgesCheckbox.addEventListener('confirm', () => {
panel.dispatch('snapshot');
});
},
update() {
const panel = this;

panel.$.meshOptimizerPreserveUVSeamEdgesCheckbox.value = getPropValue.call(panel, panel.meta.userData, false, 'meshOptimizer.simplifyOptions.preserveUVSeamEdges');

updateElementInvalid.call(panel, panel.$.meshOptimizerPreserveUVSeamEdgesCheckbox, 'meshOptimizer.simplifyOptions.preserveUVSeamEdges');
updateElementReadonly.call(panel, panel.$.meshOptimizerPreserveUVSeamEdgesCheckbox);
},
},
preserveUVFoldoverEdges: {
ready() {
const panel = this;
panel.$.meshOptimizerPreserveUVFoldoverEdgesCheckbox.addEventListener('change', panel.setProp.bind(panel, 'meshOptimizer.simplifyOptions.preserveUVFoldoverEdges', 'boolean'));
panel.$.meshOptimizerPreserveUVFoldoverEdgesCheckbox.addEventListener('confirm', () => {
panel.dispatch('snapshot');
});
},
update() {
const panel = this;

panel.$.meshOptimizerPreserveUVFoldoverEdgesCheckbox.value = getPropValue.call(panel, panel.meta.userData, false, 'meshOptimizer.simplifyOptions.preserveUVFoldoverEdges');

updateElementInvalid.call(panel, panel.$.meshOptimizerPreserveUVFoldoverEdgesCheckbox, 'meshOptimizer.simplifyOptions.preserveUVFoldoverEdges');
updateElementReadonly.call(panel, panel.$.meshOptimizerPreserveUVFoldoverEdgesCheckbox);
},
},
agressiveness: {
ready() {
const panel = this;
Expand All @@ -566,7 +654,7 @@ const Elements = {
update() {
const panel = this;

panel.$.meshOptimizerAgressivenessSlider.value = getPropValue.call(panel, panel.meta.userData, 1, 'meshOptimizer.simplifyOptions.agressiveness');
panel.$.meshOptimizerAgressivenessSlider.value = getPropValue.call(panel, panel.meta.userData, 7, 'meshOptimizer.simplifyOptions.agressiveness');

updateElementInvalid.call(panel, panel.$.meshOptimizerAgressivenessSlider, 'meshOptimizer.simplifyOptions.agressiveness');
updateElementReadonly.call(panel, panel.$.meshOptimizerAgressivenessSlider);
Expand All @@ -583,7 +671,7 @@ const Elements = {
update() {
const panel = this;

panel.$.meshOptimizerMaxIterationCountSlider.value = getPropValue.call(panel, panel.meta.userData, 1, 'meshOptimizer.simplifyOptions.maxIterationCount');
panel.$.meshOptimizerMaxIterationCountSlider.value = getPropValue.call(panel, panel.meta.userData, 100, 'meshOptimizer.simplifyOptions.maxIterationCount');

updateElementInvalid.call(panel, panel.$.meshOptimizerMaxIterationCountSlider, 'meshOptimizer.simplifyOptions.maxIterationCount');
updateElementReadonly.call(panel, panel.$.meshOptimizerMaxIterationCountSlider);
Expand Down
2 changes: 1 addition & 1 deletion editor/inspector/utils/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ exports.setPropValue = function(prop, type, event) {
if (propNames.length > 1) {
for (let i = 0; i < lastIndex; i++) {
const propName = propNames[i];
if (!target[propName]) {
if (!target[propName] || typeof target[propName] !== 'object') {
target[propName] = {};
}
target = target[propName];
Expand Down

0 comments on commit f143e7e

Please sign in to comment.