Skip to content

能否扩展现有方法实现鼠标移到live2d模型上后模型半透明 #15

@alicesola

Description

@alicesola

我注意到您的src\renderer\display\Application.js中有
detectClickThrough() { const detect = (event) => { this.context.readPixels( event.clientX * this.resolution, this.canvas.height - event.clientY * this.resolution, //2d坐标系和3d坐标系的转换,坐标原点由左上角变为屏幕左下角 1, 1, this.context.RGBA, this.context.UNSIGNED_BYTE, this.rgba ); if (this.rgba[3] != 0 && this.ignoreFlag == true) { // console.log("[Hime Display] Click through detected", false); this.nodeAPI.ipc.setIgnoreMouseEvents(false); //通知模型变半透明 this.modelManagers.now?.handleMessage({ channel: "control:set-model-alpha", data:{ lowAlpha: true } }) this.ignoreFlag = false; } else if (this.rgba[3] == 0 && this.ignoreFlag == false) { // console.log("[Hime Display] Click through detected", true); this.nodeAPI.ipc.setIgnoreMouseEvents(true, { forward: true }); //通知模型变不透明 this.modelManagers.now?.handleMessage({ channel: "control:set-model-alpha", data:{ lowAlpha: false } }); this.ignoreFlag = true; } }; // 对比之下,pointermove事件返回的坐标带有小数 this.canvas.addEventListener("mousemove", detect); }
这个方法,可以利用这个方法传信息给渲染层使模型半透明吗,我只前改了一下这个方法,所有中间有了临时的实现方法,如果这个不透明度还能通过控制面板设置并存到当前模型配置中就更好了

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions