mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-25 11:18:30 +00:00
[extension] 增加对自定义多线程扩展的支持,并更新 meta 文件
This commit is contained in:
parent
b97579d9c0
commit
3f71c91904
@ -1,4 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
'COCOS_CREATE_EXTENSION': 'Create a new extension...',
|
||||||
'primary_menu': 'Enhance Kit Manage...',
|
'primary_menu': 'Enhance Kit Manage...',
|
||||||
'settings_menu': 'Enhance Kit Settings...',
|
'settings_menu': 'Enhance Kit Settings...',
|
||||||
'install_menu': 'Install...',
|
'install_menu': 'Install...',
|
||||||
@ -53,6 +54,8 @@ module.exports = {
|
|||||||
'thread_desc2': 'Please note that the following settings are global settings, and any changes will affect all projects. All settings will be lost after reinstalling, upgrading, or uninstalling the Enhance Kit.',
|
'thread_desc2': 'Please note that the following settings are global settings, and any changes will affect all projects. All settings will be lost after reinstalling, upgrading, or uninstalling the Enhance Kit.',
|
||||||
'thread_debug': 'Debug Mode',
|
'thread_debug': 'Debug Mode',
|
||||||
'thread_debug_desc': 'When enabled, detailed logs will be output for debugging, which may significantly reduce performance.',
|
'thread_debug_desc': 'When enabled, detailed logs will be output for debugging, which may significantly reduce performance.',
|
||||||
|
'thread_custom': 'Project multithreading extension',
|
||||||
|
'thread_custom_desc': 'This will activate the multithreading extension in the project\'s worker directory.',
|
||||||
'thread_asset_pipeline': 'Multi-threaded Asset Pipeline',
|
'thread_asset_pipeline': 'Multi-threaded Asset Pipeline',
|
||||||
'thread_asset_pipeline_desc': 'When enabled, the asset pipeline will be executed in a separate thread, reducing stuttering caused by resource downloading, caching, and loading.',
|
'thread_asset_pipeline_desc': 'When enabled, the asset pipeline will be executed in a separate thread, reducing stuttering caused by resource downloading, caching, and loading.',
|
||||||
'thread_audio_system': 'Multi-threaded Audio System',
|
'thread_audio_system': 'Multi-threaded Audio System',
|
||||||
@ -61,4 +64,12 @@ module.exports = {
|
|||||||
'thread_audio_sync_desc': 'How often the properties of audio instances (playback progress, total duration, etc.) are synchronized from the worker thread to the main thread. Too frequent updates may impact performance.',
|
'thread_audio_sync_desc': 'How often the properties of audio instances (playback progress, total duration, etc.) are synchronized from the worker thread to the main thread. Too frequent updates may impact performance.',
|
||||||
'thread_scheduler': 'Thread Communication Scheduler',
|
'thread_scheduler': 'Thread Communication Scheduler',
|
||||||
'thread_scheduler_desc': 'When enabled, multiple data communications will be bundled and sent together, which may reduce performance overhead caused by frequent communications.',
|
'thread_scheduler_desc': 'When enabled, multiple data communications will be bundled and sent together, which may reduce performance overhead caused by frequent communications.',
|
||||||
|
'thread_compile_custom_thread_menu': 'Recompile the multithreading extension',
|
||||||
|
'thread_create_custom_thread_menu': 'Project multithreading extension',
|
||||||
|
'thread_custom_not_exists_1': 'You have the Enhance Kit project multithreading extension enabled, but there is no worker directory in the project, you can create one by clicking on the menu items ',
|
||||||
|
'thread_custom_not_exists_2': ' .',
|
||||||
|
'create_thread_custom_success': 'The project multithreading extension has been created in the worker directory.',
|
||||||
|
'refresh_thread_custom_success': 'The multithreading extension has been recompiled.',
|
||||||
|
'create_thread_custom_already_exists': 'The project already exists in the worker directory, just update creator-worker.d.ts to the latest version.',
|
||||||
|
'thread_custom_need_delete': 'There is a multithreading extension in the project, you can manually delete the worker directory in the project if it is no longer needed.',
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
|
'COCOS_CREATE_EXTENSION': '创建新扩展插件...',
|
||||||
'primary_menu': '社区版管理...',
|
'primary_menu': '社区版管理...',
|
||||||
'settings_menu': '社区版设置...',
|
'settings_menu': '社区版设置...',
|
||||||
'install_menu': '安装...',
|
'install_menu': '安装...',
|
||||||
@ -53,6 +54,8 @@ module.exports = {
|
|||||||
'thread_desc2': '请注意,以下为全局设置,改动会影响到所有项目,并且在重新安装、升级或卸载社区版后丢失所有设置。',
|
'thread_desc2': '请注意,以下为全局设置,改动会影响到所有项目,并且在重新安装、升级或卸载社区版后丢失所有设置。',
|
||||||
'thread_debug': '调试模式',
|
'thread_debug': '调试模式',
|
||||||
'thread_debug_desc': '启用后将会输出详细日志以便进行调试,这可能会大幅降低性能。',
|
'thread_debug_desc': '启用后将会输出详细日志以便进行调试,这可能会大幅降低性能。',
|
||||||
|
'thread_custom': '项目多线程扩展',
|
||||||
|
'thread_custom_desc': '启用后将会激活项目 worker 目录下的自定义扩展。',
|
||||||
'thread_asset_pipeline': '多线程驱动资源管线',
|
'thread_asset_pipeline': '多线程驱动资源管线',
|
||||||
'thread_asset_pipeline_desc': '启用后将资源管线移至线程中执行,减少由资源下载、缓存与加载导致的卡顿。',
|
'thread_asset_pipeline_desc': '启用后将资源管线移至线程中执行,减少由资源下载、缓存与加载导致的卡顿。',
|
||||||
'thread_audio_system': '多线程驱动音频系统',
|
'thread_audio_system': '多线程驱动音频系统',
|
||||||
@ -61,4 +64,12 @@ module.exports = {
|
|||||||
'thread_audio_sync_desc': '间隔多久从 Worker 线程将音频实例的属性(播放进度、总时长等)同步到主线程,太频繁可能会影响性能。',
|
'thread_audio_sync_desc': '间隔多久从 Worker 线程将音频实例的属性(播放进度、总时长等)同步到主线程,太频繁可能会影响性能。',
|
||||||
'thread_scheduler': '线程通信调度器',
|
'thread_scheduler': '线程通信调度器',
|
||||||
'thread_scheduler_desc': '启用后将多次数据通信打包发送,这可能会减少因通信次数带来的性能消耗。',
|
'thread_scheduler_desc': '启用后将多次数据通信打包发送,这可能会减少因通信次数带来的性能消耗。',
|
||||||
|
'thread_compile_custom_thread_menu': '重新编译多线程扩展',
|
||||||
|
'thread_create_custom_thread_menu': '项目多线程扩展',
|
||||||
|
'thread_custom_not_exists_1': '你启用了社区版的项目多线程扩展,但项目中不存在 worker 目录,可以通过依次点击菜单项 ',
|
||||||
|
'thread_custom_not_exists_2': ' 来创建扩展。',
|
||||||
|
'create_thread_custom_success': '已在 worker 目录创建项目多线程扩展。',
|
||||||
|
'refresh_thread_custom_success': '已重新编译多线程扩展。',
|
||||||
|
'create_thread_custom_already_exists': '项目已存在 worker 目录,仅更新 creator-worker.d.ts 至最新版本。',
|
||||||
|
'thread_custom_need_delete': '项目中存在多线程扩展,若不再需要可手动删除项目中的 worker 目录。',
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ const path = require('path');
|
|||||||
* 环境信息
|
* 环境信息
|
||||||
*/
|
*/
|
||||||
let engineEditorPath = path.dirname(path.dirname(Editor.frameworkPath));
|
let engineEditorPath = path.dirname(path.dirname(Editor.frameworkPath));
|
||||||
|
let engineVersion = null;
|
||||||
|
|
||||||
const engineMinigameAdapterPath = path.join(engineEditorPath, "builtin", "adapters");
|
const engineMinigameAdapterPath = path.join(engineEditorPath, "builtin", "adapters");
|
||||||
const engineWechatMinigameWorkerMainMacroPath = path.join(engineEditorPath, "builtin", "adapters", "platforms/wechat/worker/macro.js");
|
const engineWechatMinigameWorkerMainMacroPath = path.join(engineEditorPath, "builtin", "adapters", "platforms/wechat/worker/macro.js");
|
||||||
@ -13,6 +14,7 @@ const engineWechatMinigameWorkerSubMacroPath = path.join(engineEditorPath, "buil
|
|||||||
|
|
||||||
const WECHAT_MINIGAME_WORKER_SUB_PATH = "platforms/wechat/res/workers";
|
const WECHAT_MINIGAME_WORKER_SUB_PATH = "platforms/wechat/res/workers";
|
||||||
const WECHAT_MINIGAME_CONFIG_PATH = "platforms/wechat/res/game.json";
|
const WECHAT_MINIGAME_CONFIG_PATH = "platforms/wechat/res/game.json";
|
||||||
|
const WECHAT_MINIGAME_WORKER_CUSTOM_PATH = "platforms/wechat/res/workers/custom";
|
||||||
|
|
||||||
function t(str) {
|
function t(str) {
|
||||||
return Editor.T('enhance-kit.' + str);
|
return Editor.T('enhance-kit.' + str);
|
||||||
@ -27,6 +29,68 @@ function getMinigameAdapterVersion() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getProjectWorkerDtsPath() {
|
||||||
|
return path.join(getProjectCustomWorkerPath(), "creator-worker.d.ts");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProjectCustomWorkerPath() {
|
||||||
|
return path.join(path.dirname(Editor.url("db://assets/")), "worker");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getProjectCustomWorkerSrcPath() {
|
||||||
|
return path.join(getProjectCustomWorkerPath(), "src");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTemplatePath(version, name) {
|
||||||
|
return path.join(Editor.url("packages://enhance-kit"), "templates", String(engineVersion), version, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyFolder(src, dest) {
|
||||||
|
function createDir(path) {
|
||||||
|
fs.mkdirSync(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs.existsSync(src)) {
|
||||||
|
createDir(dest)
|
||||||
|
/**
|
||||||
|
* @des 方式一:利用子进程操作命令行方式
|
||||||
|
*/
|
||||||
|
// child_process.spawn('cp', ['-r', copiedPath, resultPath])
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @des 方式二:
|
||||||
|
*/
|
||||||
|
const files = fs.readdirSync(src, { withFileTypes: true });
|
||||||
|
for (let i = 0; i < files.length; i++) {
|
||||||
|
const cf = files[i]
|
||||||
|
const ccp = path.join(src, cf.name)
|
||||||
|
const crp = path.join(dest, cf.name)
|
||||||
|
if (cf.isFile()) {
|
||||||
|
fs.copyFileSync(ccp, crp)
|
||||||
|
} else if (cf.isDirectory()) {
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* @des 判断读(R_OK | W_OK)写权限
|
||||||
|
*/
|
||||||
|
fs.accessSync(path.join(crp, '..'), fs.constants.W_OK)
|
||||||
|
copyFolder(ccp, crp, true);
|
||||||
|
} catch (error) {
|
||||||
|
Editor.error('folder write error:', error);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (cf.isSymbolicLink()) {
|
||||||
|
fs.symlinkSync(fs.readlinkSync(ccp), crp)
|
||||||
|
} else if (cf.isBlockDevice() || cf.isCharacterDevice()) {
|
||||||
|
fs.copyFileSync(ccp, crp)
|
||||||
|
} else {
|
||||||
|
Editor.error('not file or directory: ', ccp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Editor.error('do not exist path: ', src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getSettings() {
|
function getSettings() {
|
||||||
const minigameVersion = getMinigameAdapterVersion();
|
const minigameVersion = getMinigameAdapterVersion();
|
||||||
const isUninstalled = minigameVersion === "";
|
const isUninstalled = minigameVersion === "";
|
||||||
@ -45,6 +109,7 @@ function getSettings() {
|
|||||||
CC_WORKER_AUDIO_SYSTEM: getMacroBooleanValue(content, "CC_WORKER_AUDIO_SYSTEM"),
|
CC_WORKER_AUDIO_SYSTEM: getMacroBooleanValue(content, "CC_WORKER_AUDIO_SYSTEM"),
|
||||||
CC_WORKER_SCHEDULER: getMacroBooleanValue(content, "CC_WORKER_SCHEDULER"),
|
CC_WORKER_SCHEDULER: getMacroBooleanValue(content, "CC_WORKER_SCHEDULER"),
|
||||||
CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL: getMacroIntegerValue(content, "CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL"),
|
CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL: getMacroIntegerValue(content, "CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL"),
|
||||||
|
CC_CUSTOM_WORKER: getMacroBooleanValue(content, "CC_CUSTOM_WORKER"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,6 +136,7 @@ function setSettings(macro, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkAndModifyWorkerFiles();
|
checkAndModifyWorkerFiles();
|
||||||
|
refreshCustomThreadCode();
|
||||||
syncSettingsToSubWorker();
|
syncSettingsToSubWorker();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +174,7 @@ function checkAndModifyWorkerFiles() {
|
|||||||
const gameJson = JSON.parse(fs.readFileSync(gameJsonPath, { encoding: "utf-8" }));
|
const gameJson = JSON.parse(fs.readFileSync(gameJsonPath, { encoding: "utf-8" }));
|
||||||
|
|
||||||
// 是否启用 Worker
|
// 是否启用 Worker
|
||||||
if (result.CC_WORKER_ASSET_PIPELINE || result.CC_WORKER_AUDIO_SYSTEM) {
|
if (result.CC_WORKER_ASSET_PIPELINE || result.CC_WORKER_AUDIO_SYSTEM || result.CC_CUSTOM_WORKER) {
|
||||||
// 没有 Worker 目录与配置的话提醒用户重新安装
|
// 没有 Worker 目录与配置的话提醒用户重新安装
|
||||||
if (!(gameJson.workers && fs.existsSync(workerDir))) {
|
if (!(gameJson.workers && fs.existsSync(workerDir))) {
|
||||||
Editor.error(t('thread_not_right_workers_dir'));
|
Editor.error(t('thread_not_right_workers_dir'));
|
||||||
@ -119,6 +185,45 @@ function checkAndModifyWorkerFiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshCustomThreadCode() {
|
||||||
|
const result = getSettings();
|
||||||
|
if (result.code === 0) {
|
||||||
|
const customDir = path.join(engineMinigameAdapterPath, WECHAT_MINIGAME_WORKER_CUSTOM_PATH);
|
||||||
|
const src = getProjectCustomWorkerSrcPath();
|
||||||
|
// 是否启用 Worker
|
||||||
|
if (result.CC_CUSTOM_WORKER) {
|
||||||
|
if (fs.existsSync(src)) {
|
||||||
|
fs.rmSync(customDir, { force: true, recursive: true });
|
||||||
|
copyFolder(src, customDir);
|
||||||
|
fs.writeFileSync(path.join(customDir, "ipc-worker.js"), "module.exports = require('../ipc-worker.js');");
|
||||||
|
Editor.success(t('refresh_thread_custom_success'));
|
||||||
|
} else {
|
||||||
|
fs.rmSync(customDir, { force: true, recursive: true });
|
||||||
|
Editor.error(t('thread_custom_not_exists_1') + Editor.T('i18n:MAIN_MENU.package.title') + "-" + t('COCOS_CREATE_EXTENSION') + "-" + t('thread_create_custom_thread_menu') + t('thread_custom_not_exists_2'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fs.rmSync(customDir, { force: true, recursive: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createThreadTemplate() {
|
||||||
|
const version = getMinigameAdapterVersion();
|
||||||
|
const src = getTemplatePath(version, "worker");
|
||||||
|
const dest = getProjectCustomWorkerPath();
|
||||||
|
if (fs.existsSync(dest)) {
|
||||||
|
// 写入 creator-worker.d.ts
|
||||||
|
const workerDtsPath = path.join(getTemplatePath(version, "worker"), "creator-worker.d.ts");
|
||||||
|
const projectWorkerDtsPath = getProjectWorkerDtsPath();
|
||||||
|
if (exist(workerDtsPath) && exist(projectWorkerDtsPath)) {
|
||||||
|
fs.writeFileSync(projectWorkerDtsPath, fs.readFileSync(workerDtsPath));
|
||||||
|
}
|
||||||
|
Editor.success(t('create_thread_custom_already_exists'));
|
||||||
|
} else {
|
||||||
|
copyFolder(src, dest);
|
||||||
|
Editor.success(t('create_thread_custom_success'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
@ -142,10 +247,24 @@ module.exports = {
|
|||||||
event.reply(null);
|
event.reply(null);
|
||||||
},
|
},
|
||||||
|
|
||||||
"scene:ready"(event) {
|
createThreadTemplate() {
|
||||||
checkAndModifyWorkerFiles();
|
createThreadTemplate();
|
||||||
|
refreshCustomThreadCode();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
refreshCustomThreadCode() {
|
||||||
|
refreshCustomThreadCode();
|
||||||
|
},
|
||||||
|
|
||||||
|
"scene:ready"(event) {
|
||||||
|
Editor.Scene.callSceneScript('enhance-kit', 'scene-get-engine-version', function (err, version) {
|
||||||
|
if (version) {
|
||||||
|
engineVersion = version;
|
||||||
|
checkAndModifyWorkerFiles();
|
||||||
|
refreshCustomThreadCode();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"description": "This extension provides support for cocos enhance kit.",
|
"description": "This extension provides support for cocos enhance kit.",
|
||||||
"author": "SmallMain",
|
"author": "SmallMain",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
|
"scene-script": "scene.js",
|
||||||
"panel": {
|
"panel": {
|
||||||
"main": "panel/index.js",
|
"main": "panel/index.js",
|
||||||
"type": "dockable",
|
"type": "dockable",
|
||||||
@ -16,6 +17,12 @@
|
|||||||
"main-menu": {
|
"main-menu": {
|
||||||
"i18n:MAIN_MENU.project.title/i18n:enhance-kit.settings_menu": {
|
"i18n:MAIN_MENU.project.title/i18n:enhance-kit.settings_menu": {
|
||||||
"message": "enhance-kit:openSettings"
|
"message": "enhance-kit:openSettings"
|
||||||
|
},
|
||||||
|
"i18n:MAIN_MENU.package.title/i18n:enhance-kit.COCOS_CREATE_EXTENSION/i18n:enhance-kit.thread_create_custom_thread_menu": {
|
||||||
|
"message": "enhance-kit:createThreadTemplate"
|
||||||
|
},
|
||||||
|
"i18n:MAIN_MENU.project.title/i18n:enhance-kit.thread_compile_custom_thread_menu": {
|
||||||
|
"message": "enhance-kit:refreshCustomThreadCode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"runtime-resource": {
|
"runtime-resource": {
|
||||||
@ -27,4 +34,4 @@
|
|||||||
"resources/**/*"
|
"resources/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,12 @@ Editor.Panel.extend({
|
|||||||
<ui-prop id="td" tabindex="-1" name="${t('thread_debug')}" tooltip="${t('thread_debug_desc')}">
|
<ui-prop id="td" tabindex="-1" name="${t('thread_debug')}" tooltip="${t('thread_debug_desc')}">
|
||||||
<ui-checkbox id="tdc" tabindex="-1"></ui-checkbox>
|
<ui-checkbox id="tdc" tabindex="-1"></ui-checkbox>
|
||||||
</ui-prop>
|
</ui-prop>
|
||||||
<ui-prop id="tap" tabindex="-1" name="${t('thread_asset_pipeline')}" tooltip="${t('thread_asset_pipeline_desc')}">
|
<ui-prop id="tap" tabindex="-1" name="${t('thread_asset_pipeline')}" tooltip="${t('thread_asset_pipeline_desc')}">
|
||||||
<ui-checkbox id="tapc" tabindex="-1"></ui-checkbox>
|
<ui-checkbox id="tapc" tabindex="-1"></ui-checkbox>
|
||||||
</ui-prop>
|
</ui-prop>
|
||||||
|
<ui-prop id="tc" tabindex="-1" name="${t('thread_custom')}" tooltip="${t('thread_custom_desc')}">
|
||||||
|
<ui-checkbox id="tcc" tabindex="-1"></ui-checkbox>
|
||||||
|
</ui-prop>
|
||||||
<ui-prop id="fs" tabindex="-1" name="${t('thread_audio_system')}" tooltip="${t('thread_audio_system_desc')}" foldable>
|
<ui-prop id="fs" tabindex="-1" name="${t('thread_audio_system')}" tooltip="${t('thread_audio_system_desc')}" foldable>
|
||||||
<ui-checkbox id="fsc" tabindex="-1"></ui-checkbox>
|
<ui-checkbox id="fsc" tabindex="-1"></ui-checkbox>
|
||||||
<div slot="child">
|
<div slot="child">
|
||||||
@ -51,6 +54,8 @@ Editor.Panel.extend({
|
|||||||
thread_debug_checkbox: '#tdc',
|
thread_debug_checkbox: '#tdc',
|
||||||
thread_asset_pipeline: '#tap',
|
thread_asset_pipeline: '#tap',
|
||||||
thread_asset_pipeline_checkbox: '#tapc',
|
thread_asset_pipeline_checkbox: '#tapc',
|
||||||
|
thread_custom: '#tc',
|
||||||
|
thread_custom_checkbox: '#tcc',
|
||||||
thread_audio_system: '#fs',
|
thread_audio_system: '#fs',
|
||||||
thread_audio_system_checkbox: '#fsc',
|
thread_audio_system_checkbox: '#fsc',
|
||||||
thread_audio_system_interval: '#fsi',
|
thread_audio_system_interval: '#fsi',
|
||||||
@ -72,6 +77,7 @@ Editor.Panel.extend({
|
|||||||
this.$ready_area.classList.remove('hidden');
|
this.$ready_area.classList.remove('hidden');
|
||||||
|
|
||||||
this.$thread_debug_checkbox.checked = data.CC_WORKER_DEBUG;
|
this.$thread_debug_checkbox.checked = data.CC_WORKER_DEBUG;
|
||||||
|
this.$thread_custom_checkbox.checked = data.CC_CUSTOM_WORKER;
|
||||||
this.$thread_asset_pipeline_checkbox.checked = data.CC_WORKER_ASSET_PIPELINE;
|
this.$thread_asset_pipeline_checkbox.checked = data.CC_WORKER_ASSET_PIPELINE;
|
||||||
this.$thread_audio_system_checkbox.checked = data.CC_WORKER_AUDIO_SYSTEM;
|
this.$thread_audio_system_checkbox.checked = data.CC_WORKER_AUDIO_SYSTEM;
|
||||||
this.$thread_audio_system_interval_input.value = data.CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL;
|
this.$thread_audio_system_interval_input.value = data.CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL;
|
||||||
@ -85,6 +91,10 @@ Editor.Panel.extend({
|
|||||||
this.setSettings("CC_WORKER_ASSET_PIPELINE", this.$thread_asset_pipeline_checkbox.checked);
|
this.setSettings("CC_WORKER_ASSET_PIPELINE", this.$thread_asset_pipeline_checkbox.checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$thread_custom_checkbox.addEventListener('change', () => {
|
||||||
|
this.setSettings("CC_CUSTOM_WORKER", this.$thread_custom_checkbox.checked);
|
||||||
|
});
|
||||||
|
|
||||||
const onAudioSystemEnableChange = (enabled) => {
|
const onAudioSystemEnableChange = (enabled) => {
|
||||||
this.$thread_audio_system_interval_input.disabled = !enabled;
|
this.$thread_audio_system_interval_input.disabled = !enabled;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ver": "1.1.2",
|
"ver": "1.1.3",
|
||||||
"uuid": "74663d94-6782-4dee-9db9-26127ee8b265",
|
"uuid": "74663d94-6782-4dee-9db9-26127ee8b265",
|
||||||
|
"importer": "folder",
|
||||||
"isBundle": true,
|
"isBundle": true,
|
||||||
"bundleName": "",
|
"bundleName": "",
|
||||||
"priority": 1,
|
"priority": 1,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ver": "1.1.2",
|
"ver": "1.1.3",
|
||||||
"uuid": "8ee63b7e-0ac8-4cb5-95f0-85278bfd748a",
|
"uuid": "8ee63b7e-0ac8-4cb5-95f0-85278bfd748a",
|
||||||
|
"importer": "folder",
|
||||||
"isBundle": false,
|
"isBundle": false,
|
||||||
"bundleName": "",
|
"bundleName": "",
|
||||||
"priority": 1,
|
"priority": 1,
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"ver": "1.0.25",
|
"ver": "1.0.27",
|
||||||
"uuid": "5dcffc18-b913-460e-a0d9-5d74f4cda12b",
|
"uuid": "5dcffc18-b913-460e-a0d9-5d74f4cda12b",
|
||||||
|
"importer": "effect",
|
||||||
"compiledShaders": [
|
"compiledShaders": [
|
||||||
{
|
{
|
||||||
"glsl1": {
|
"glsl1": {
|
||||||
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\nattribute float a_texId;\nvarying float v_texId;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n v_texId = a_texId;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
|
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TINT\nattribute vec4 a_color0;\nvarying vec4 v_color0;\n#endif\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#if USE_MULTI_TEXTURE\nattribute float a_texId;\nvarying float v_texId;\n#endif\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #if USE_MULTI_TEXTURE\n v_texId = a_texId;\n #endif\n #endif\n v_color = a_color;\n #if USE_TINT\n v_color0 = a_color0;\n #endif\n gl_Position = pos;\n}",
|
||||||
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nvarying float v_texId;\nuniform sampler2D texture;\nuniform sampler2D texture2;\nuniform sampler2D texture3;\nuniform sampler2D texture4;\nuniform sampler2D texture5;\nuniform sampler2D texture6;\nuniform sampler2D texture7;\nuniform sampler2D texture8;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n if(v_texId < 1.0){\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n } else if(v_texId < 2.0){\n vec4 texture2_tmp = texture2D(texture2, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture2\n texture2_tmp.a *= texture2D(texture2, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture2_tmp.rgb * texture2_tmp.rgb);\n o.a *= texture2_tmp.a;\n #else\n o *= texture2_tmp;\n #endif\n } else if(v_texId < 3.0){\n vec4 texture3_tmp = texture2D(texture3, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture3\n texture3_tmp.a *= texture2D(texture3, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture3_tmp.rgb * texture3_tmp.rgb);\n o.a *= texture3_tmp.a;\n #else\n o *= texture3_tmp;\n #endif\n } else if(v_texId < 4.0){\n vec4 texture4_tmp = texture2D(texture4, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture4\n texture4_tmp.a *= texture2D(texture4, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture4_tmp.rgb * texture4_tmp.rgb);\n o.a *= texture4_tmp.a;\n #else\n o *= texture4_tmp;\n #endif\n } else if(v_texId < 5.0){\n vec4 texture5_tmp = texture2D(texture5, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture5\n texture5_tmp.a *= texture2D(texture5, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture5_tmp.rgb * texture5_tmp.rgb);\n o.a *= texture5_tmp.a;\n #else\n o *= texture5_tmp;\n #endif\n } else if(v_texId < 6.0){\n vec4 texture6_tmp = texture2D(texture6, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture6\n texture6_tmp.a *= texture2D(texture6, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture6_tmp.rgb * texture6_tmp.rgb);\n o.a *= texture6_tmp.a;\n #else\n o *= texture6_tmp;\n #endif\n } else if(v_texId < 7.0){\n vec4 texture7_tmp = texture2D(texture7, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture7\n texture7_tmp.a *= texture2D(texture7, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture7_tmp.rgb * texture7_tmp.rgb);\n o.a *= texture7_tmp.a;\n #else\n o *= texture7_tmp;\n #endif\n } else {\n vec4 texture8_tmp = texture2D(texture8, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture8\n texture8_tmp.a *= texture2D(texture8, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture8_tmp.rgb * texture8_tmp.rgb);\n o.a *= texture8_tmp.a;\n #else\n o *= texture8_tmp;\n #endif\n }\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"
|
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TINT\nvarying vec4 v_color0;\n#endif\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#if USE_MULTI_TEXTURE\nvarying float v_texId;\nuniform sampler2D texture2;\nuniform sampler2D texture3;\nuniform sampler2D texture4;\nuniform sampler2D texture5;\nuniform sampler2D texture6;\nuniform sampler2D texture7;\nuniform sampler2D texture8;\n#endif\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_MULTI_TEXTURE\n if(v_texId < 1.0){\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n } else if(v_texId < 2.0){\n vec4 texture2_tmp = texture2D(texture2, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture2\n texture2_tmp.a *= texture2D(texture2, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture2_tmp.rgb * texture2_tmp.rgb);\n o.a *= texture2_tmp.a;\n #else\n o *= texture2_tmp;\n #endif\n } else if(v_texId < 3.0){\n vec4 texture3_tmp = texture2D(texture3, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture3\n texture3_tmp.a *= texture2D(texture3, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture3_tmp.rgb * texture3_tmp.rgb);\n o.a *= texture3_tmp.a;\n #else\n o *= texture3_tmp;\n #endif\n } else if(v_texId < 4.0){\n vec4 texture4_tmp = texture2D(texture4, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture4\n texture4_tmp.a *= texture2D(texture4, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture4_tmp.rgb * texture4_tmp.rgb);\n o.a *= texture4_tmp.a;\n #else\n o *= texture4_tmp;\n #endif\n } else if(v_texId < 5.0){\n vec4 texture5_tmp = texture2D(texture5, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture5\n texture5_tmp.a *= texture2D(texture5, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture5_tmp.rgb * texture5_tmp.rgb);\n o.a *= texture5_tmp.a;\n #else\n o *= texture5_tmp;\n #endif\n } else if(v_texId < 6.0){\n vec4 texture6_tmp = texture2D(texture6, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture6\n texture6_tmp.a *= texture2D(texture6, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture6_tmp.rgb * texture6_tmp.rgb);\n o.a *= texture6_tmp.a;\n #else\n o *= texture6_tmp;\n #endif\n } else if(v_texId < 7.0){\n vec4 texture7_tmp = texture2D(texture7, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture7\n texture7_tmp.a *= texture2D(texture7, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture7_tmp.rgb * texture7_tmp.rgb);\n o.a *= texture7_tmp.a;\n #else\n o *= texture7_tmp;\n #endif\n } else {\n vec4 texture8_tmp = texture2D(texture8, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture8\n texture8_tmp.a *= texture2D(texture8, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture8_tmp.rgb * texture8_tmp.rgb);\n o.a *= texture8_tmp.a;\n #else\n o *= texture8_tmp;\n #endif\n }\n #else\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n #endif\n #if USE_TINT\n vec4 finalColor;\n finalColor.a = v_color.a * o.a;\n finalColor.rgb = ((o.a - 1.0) * v_color0.a + 1.0 - o.rgb) * v_color0.rgb + o.rgb * v_color.rgb;\n ALPHA_TEST(finalColor);\n gl_FragColor = finalColor;\n #else\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n #endif\n}"
|
||||||
},
|
},
|
||||||
"glsl3": {
|
"glsl3": {
|
||||||
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\nin float a_texId;\nout float v_texId;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n v_texId = a_texId;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
|
"vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TINT\nin vec4 a_color0;\nout vec4 v_color0;\n#endif\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#if USE_MULTI_TEXTURE\nin float a_texId;\nout float v_texId;\n#endif\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #if USE_MULTI_TEXTURE\n v_texId = a_texId;\n #endif\n #endif\n v_color = a_color;\n #if USE_TINT\n v_color0 = a_color0;\n #endif\n gl_Position = pos;\n}",
|
||||||
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nin float v_texId;\nuniform sampler2D texture;\nuniform sampler2D texture2;\nuniform sampler2D texture3;\nuniform sampler2D texture4;\nuniform sampler2D texture5;\nuniform sampler2D texture6;\nuniform sampler2D texture7;\nuniform sampler2D texture8;\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n if(v_texId < 1.0){\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n } else if(v_texId < 2.0){\n vec4 texture2_tmp = texture(texture2, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture2\n texture2_tmp.a *= texture(texture2, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture2_tmp.rgb * texture2_tmp.rgb);\n o.a *= texture2_tmp.a;\n #else\n o *= texture2_tmp;\n #endif\n } else if(v_texId < 3.0){\n vec4 texture3_tmp = texture(texture3, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture3\n texture3_tmp.a *= texture(texture3, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture3_tmp.rgb * texture3_tmp.rgb);\n o.a *= texture3_tmp.a;\n #else\n o *= texture3_tmp;\n #endif\n } else if(v_texId < 4.0){\n vec4 texture4_tmp = texture(texture4, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture4\n texture4_tmp.a *= texture(texture4, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture4_tmp.rgb * texture4_tmp.rgb);\n o.a *= texture4_tmp.a;\n #else\n o *= texture4_tmp;\n #endif\n } else if(v_texId < 5.0){\n vec4 texture5_tmp = texture(texture5, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture5\n texture5_tmp.a *= texture(texture5, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture5_tmp.rgb * texture5_tmp.rgb);\n o.a *= texture5_tmp.a;\n #else\n o *= texture5_tmp;\n #endif\n } else if(v_texId < 6.0){\n vec4 texture6_tmp = texture(texture6, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture6\n texture6_tmp.a *= texture(texture6, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture6_tmp.rgb * texture6_tmp.rgb);\n o.a *= texture6_tmp.a;\n #else\n o *= texture6_tmp;\n #endif\n } else if(v_texId < 7.0){\n vec4 texture7_tmp = texture(texture7, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture7\n texture7_tmp.a *= texture(texture7, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture7_tmp.rgb * texture7_tmp.rgb);\n o.a *= texture7_tmp.a;\n #else\n o *= texture7_tmp;\n #endif\n } else {\n vec4 texture8_tmp = texture(texture8, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture8\n texture8_tmp.a *= texture(texture8, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture8_tmp.rgb * texture8_tmp.rgb);\n o.a *= texture8_tmp.a;\n #else\n o *= texture8_tmp;\n #endif\n }\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}"
|
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TINT\nin vec4 v_color0;\n#endif\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#if USE_MULTI_TEXTURE\nin float v_texId;\nuniform sampler2D texture2;\nuniform sampler2D texture3;\nuniform sampler2D texture4;\nuniform sampler2D texture5;\nuniform sampler2D texture6;\nuniform sampler2D texture7;\nuniform sampler2D texture8;\n#endif\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n #if USE_MULTI_TEXTURE\n if(v_texId < 1.0){\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n } else if(v_texId < 2.0){\n vec4 texture2_tmp = texture(texture2, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture2\n texture2_tmp.a *= texture(texture2, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture2_tmp.rgb * texture2_tmp.rgb);\n o.a *= texture2_tmp.a;\n #else\n o *= texture2_tmp;\n #endif\n } else if(v_texId < 3.0){\n vec4 texture3_tmp = texture(texture3, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture3\n texture3_tmp.a *= texture(texture3, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture3_tmp.rgb * texture3_tmp.rgb);\n o.a *= texture3_tmp.a;\n #else\n o *= texture3_tmp;\n #endif\n } else if(v_texId < 4.0){\n vec4 texture4_tmp = texture(texture4, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture4\n texture4_tmp.a *= texture(texture4, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture4_tmp.rgb * texture4_tmp.rgb);\n o.a *= texture4_tmp.a;\n #else\n o *= texture4_tmp;\n #endif\n } else if(v_texId < 5.0){\n vec4 texture5_tmp = texture(texture5, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture5\n texture5_tmp.a *= texture(texture5, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture5_tmp.rgb * texture5_tmp.rgb);\n o.a *= texture5_tmp.a;\n #else\n o *= texture5_tmp;\n #endif\n } else if(v_texId < 6.0){\n vec4 texture6_tmp = texture(texture6, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture6\n texture6_tmp.a *= texture(texture6, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture6_tmp.rgb * texture6_tmp.rgb);\n o.a *= texture6_tmp.a;\n #else\n o *= texture6_tmp;\n #endif\n } else if(v_texId < 7.0){\n vec4 texture7_tmp = texture(texture7, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture7\n texture7_tmp.a *= texture(texture7, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture7_tmp.rgb * texture7_tmp.rgb);\n o.a *= texture7_tmp.a;\n #else\n o *= texture7_tmp;\n #endif\n } else {\n vec4 texture8_tmp = texture(texture8, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture8\n texture8_tmp.a *= texture(texture8, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture8_tmp.rgb * texture8_tmp.rgb);\n o.a *= texture8_tmp.a;\n #else\n o *= texture8_tmp;\n #endif\n }\n #else\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n #endif\n #if USE_TINT\n vec4 finalColor;\n finalColor.a = v_color.a * o.a;\n finalColor.rgb = ((o.a - 1.0) * v_color0.a + 1.0 - o.rgb) * v_color0.rgb + o.rgb * v_color.rgb;\n ALPHA_TEST(finalColor);\n gl_FragColor = finalColor;\n #else\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n #endif\n}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
9
extension/scene.js
Normal file
9
extension/scene.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
|
||||||
|
'scene-get-engine-version': function (event) {
|
||||||
|
if (event.reply) {
|
||||||
|
event.reply(null, cc.ENGINE_VERSION);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
72
extension/templates/2.4.13/2.1.0/worker/creator-worker.d.ts
vendored
Normal file
72
extension/templates/2.4.13/2.1.0/worker/creator-worker.d.ts
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
declare namespace worker {
|
||||||
|
export const createInnerAudioContext: any;
|
||||||
|
export const connectSocket: any;
|
||||||
|
export function createSharedArrayBuffer(size: number): WXSharedArrayBuffer;
|
||||||
|
export const downloadFile: any;
|
||||||
|
export const env: { USER_DATA_PATH: string };
|
||||||
|
export const getFileSystemManager: any;
|
||||||
|
export const onMessage: any;
|
||||||
|
export const postMessage: any;
|
||||||
|
export const request: any;
|
||||||
|
export const uploadFile: any;
|
||||||
|
export interface WXSharedArrayBuffer {
|
||||||
|
buffer: SharedArrayBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "ipc-worker.js" {
|
||||||
|
/**
|
||||||
|
* 是否初始化完成
|
||||||
|
*
|
||||||
|
* - 初始化完成后,宏才被设为有效值
|
||||||
|
*/
|
||||||
|
export const inited: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问主线程的入口
|
||||||
|
*/
|
||||||
|
export const main: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册主线程可以访问的入口
|
||||||
|
*
|
||||||
|
* 请务必在脚本执行时调用才有效。
|
||||||
|
*/
|
||||||
|
export function registerHandler(name: string, handler: object): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用自定义 Worker
|
||||||
|
*/
|
||||||
|
declare var CC_CUSTOM_WORKER: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用 Worker 调度模式,这会减少通信次数
|
||||||
|
*/
|
||||||
|
declare var CC_WORKER_SCHEDULER: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用 Worker 调试模式
|
||||||
|
*/
|
||||||
|
declare var CC_WORKER_DEBUG: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用 Worker 使用同步版本的文件系统 API
|
||||||
|
*/
|
||||||
|
declare var CC_WORKER_FS_SYNC: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用 Worker 驱动资源管线
|
||||||
|
*/
|
||||||
|
declare var CC_WORKER_ASSET_PIPELINE: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用 Worker 驱动音频系统
|
||||||
|
*/
|
||||||
|
declare var CC_WORKER_AUDIO_SYSTEM: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Worker 音频系统同步音频属性的间隔时间(单位:毫秒)
|
||||||
|
*/
|
||||||
|
declare var CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL: number;
|
||||||
|
|
13
extension/templates/2.4.13/2.1.0/worker/jsconfig.json
Normal file
13
extension/templates/2.4.13/2.1.0/worker/jsconfig.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "ES5",
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src",
|
||||||
|
"creator-worker.d.ts"
|
||||||
|
],
|
||||||
|
}
|
3
extension/templates/2.4.13/2.1.0/worker/src/index.js
Normal file
3
extension/templates/2.4.13/2.1.0/worker/src/index.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// 该文件会在 Worker 初始化时执行,可在这里初始化或者引用其它脚本
|
||||||
|
// This file will be executed when the Worker is initialized, either initialize it here or require another script.
|
||||||
|
require("math.js");
|
9
extension/templates/2.4.13/2.1.0/worker/src/math.js
Normal file
9
extension/templates/2.4.13/2.1.0/worker/src/math.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
const { registerHandler } = require("ipc-worker.js");
|
||||||
|
|
||||||
|
export function add(x, y, callback) {
|
||||||
|
callback(x + y);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerHandler("math", {
|
||||||
|
add,
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user