guansss / pixi-live2d-display

A PixiJS plugin to display Live2D models of any kind.
https://guansss.github.io/pixi-live2d-display/
MIT License
823 stars 125 forks source link

如何设置模型的Bounds #93

Closed loclink closed 1 year ago

loclink commented 1 year ago

作者您好,请问如何在加载完模型之后更改模型的边界呢?

guansss commented 1 year ago

抱歉回复晚了

你说的是模型的边界还是 hit area 的边界?如果是模型边界的话,可以继承 Live2DModel 并重载 Live2DModel.prototype._calculateBounds(),如果是 hit area 的话,这个是通过顶点位置动态计算的,需要修改 InternalModel.prototype.getDrawableBounds()

fishpigbird commented 5 months ago

希望实现类似于ex studio中更改边界的效果,以修复鼠标追踪偏移。

image

我将代码更改后,鼠标追踪似乎仍然和以前一样有偏移,不清楚是否应该在这里更改,以自定义模型边界?

        _calculateBounds() {
            this._bounds.addFrame(this.transform, 0, -9000, this.internalModel.width, this.internalModel.height);
        }
       _calculateBounds() {
            this._bounds.addFrame(this.transform, 0, -this.internalModel.height/2, this.internalModel.width, this.internalModel.height);
        }

image