mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
[Bug] add fix alpha transparency artifact options and fix bug (#10419)
* add fix alpha transparency artifact options and fix bug add fix alpha transparency artifact options fix bug - Fixed an issue where events were registered more than once * Non-transparent channels or RGBE channels are not allowed * Update image.js * revert set hidden to set style
This commit is contained in:
@@ -81,6 +81,8 @@ module.exports = {
|
||||
bakeOfflineMipmapsTip: 'Bake Offline Mipmaps',
|
||||
flipVertical: 'Flip Vertical',
|
||||
flipVerticalTip: 'Flip Vertical',
|
||||
fixAlphaTransparencyArtifacts: 'Fix Alpha Transparency Artifacts',
|
||||
fixAlphaTransparencyArtifactsTip: 'Fill transparent pixels with color of neareast solid pixel. These filled pixels would fix the dark halos at transparent borders of textures. Please turn on this option when you use the Alpha transparency channel in textures.',
|
||||
isRGBE: 'Is RGBE',
|
||||
isRGBETip: 'Is RGBE',
|
||||
},
|
||||
|
||||
@@ -81,6 +81,8 @@ module.exports = {
|
||||
bakeOfflineMipmapsTip: 'Bake Offline Mipmaps',
|
||||
flipVertical: 'Flip Vertical',
|
||||
flipVerticalTip: 'Flip Vertical',
|
||||
fixAlphaTransparencyArtifacts: 'Fix Alpha Transparency Artifacts',
|
||||
fixAlphaTransparencyArtifactsTip: '为全透明像素填充相邻像素的颜色,防止纹理过滤引起的黑边问题。当使用 Alpha 透明通道时,请启用此功能。',
|
||||
isRGBE: 'Is RGBE',
|
||||
isRGBETip: 'Is RGBE',
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const { appendFileSync } = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
exports.template = `
|
||||
@@ -17,6 +16,10 @@ exports.template = `
|
||||
<ui-label slot="label" value="i18n:ENGINE.assets.image.bakeOfflineMipmaps" tooltip="i18n:ENGINE.assets.image.bakeOfflineMipmapsTip"></ui-label>
|
||||
<ui-checkbox slot="content" class="bakeOfflineMipmaps-checkbox"></ui-checkbox>
|
||||
</ui-prop>
|
||||
<ui-prop class="fixATAProp">
|
||||
<ui-label slot="label" value="i18n:ENGINE.assets.image.fixAlphaTransparencyArtifacts" tooltip="i18n:ENGINE.assets.image.fixAlphaTransparencyArtifactsTip"></ui-label>
|
||||
<ui-checkbox slot="content" class="fixAlphaTransparencyArtifacts-checkbox"></ui-checkbox>
|
||||
</ui-prop>
|
||||
<ui-prop class="isRGBE-prop">
|
||||
<ui-label slot="label" value="i18n:ENGINE.assets.image.isRGBE" tooltip="i18n:ENGINE.assets.image.isRGBETip"></ui-label>
|
||||
<ui-checkbox slot="content" class="isRGBE-checkbox"></ui-checkbox>
|
||||
@@ -49,6 +52,8 @@ exports.$ = {
|
||||
container: '.asset-image',
|
||||
typeSelect: '.type-select',
|
||||
flipVerticalCheckbox: '.flipVertical-checkbox',
|
||||
fixAlphaTransparencyArtifactsCheckbox: '.fixAlphaTransparencyArtifacts-checkbox',
|
||||
fixATAProp: '.fixATAProp',
|
||||
isRGBEProp: '.isRGBE-prop',
|
||||
isRGBECheckbox: '.isRGBE-checkbox',
|
||||
|
||||
@@ -70,7 +75,8 @@ const Elements = {
|
||||
panel.dispatch('change');
|
||||
|
||||
// There are other properties whose updates depend on its changes attribute corresponds to the edit element
|
||||
Elements.isRGBE.update.bind(panel)();
|
||||
Elements.isRGBE.update.call(panel);
|
||||
Elements.fixAlphaTransparencyArtifacts.update.call(panel);
|
||||
});
|
||||
},
|
||||
update() {
|
||||
@@ -126,6 +132,38 @@ const Elements = {
|
||||
panel.$.bakeOfflineMipmapsCheckbox.value = panel.meta.userData.bakeOfflineMipmaps;
|
||||
},
|
||||
},
|
||||
|
||||
fixAlphaTransparencyArtifacts: {
|
||||
ready() {
|
||||
const panel = this;
|
||||
panel.$.fixAlphaTransparencyArtifactsCheckbox.addEventListener('change', (event) => {
|
||||
panel.metaList.forEach((meta) => {
|
||||
meta.userData.fixAlphaTransparencyArtifacts = event.target.value;
|
||||
|
||||
});
|
||||
panel.dispatch('change');
|
||||
});
|
||||
},
|
||||
update() {
|
||||
const panel = this;
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
const fixAlphaTransparencyArtifactsCheckbox = panel.$.fixAlphaTransparencyArtifactsCheckbox;
|
||||
/** @type {HTMLElement} */
|
||||
const fixATAProp = panel.$.fixATAProp;
|
||||
fixAlphaTransparencyArtifactsCheckbox.value = panel.meta.userData.fixAlphaTransparencyArtifacts;
|
||||
const bannedTypes = ['normal map'];
|
||||
const isCapableToFixAlphaTransparencyArtifacts = !bannedTypes.includes(panel.meta.userData.type);
|
||||
if (isCapableToFixAlphaTransparencyArtifacts) {
|
||||
fixATAProp.style.display = 'block';
|
||||
panel.updateInvalid(panel.$.fixAlphaTransparencyArtifactsCheckbox, 'fixAlphaTransparencyArtifacts');
|
||||
panel.updateReadonly(panel.$.fixAlphaTransparencyArtifactsCheckbox);
|
||||
} else {
|
||||
fixATAProp.style.display = 'none';
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
isRGBE: {
|
||||
ready() {
|
||||
const panel = this;
|
||||
@@ -185,6 +223,9 @@ exports.ready = function() {
|
||||
element.ready.call(this);
|
||||
}
|
||||
}
|
||||
this.$.panel.addEventListener('change', () => {
|
||||
this.dispatch('change');
|
||||
});
|
||||
};
|
||||
|
||||
exports.methods = {
|
||||
@@ -271,8 +312,5 @@ exports.methods = {
|
||||
this.$.panelName.setAttribute('value', this.meta.userData.type);
|
||||
this.$.panel.setAttribute('src', path.join(__dirname, `./${asset.importer}.js`));
|
||||
this.$.panel.update(assetList, metaList);
|
||||
this.$.panel.addEventListener('change', () => {
|
||||
this.dispatch('change');
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user