嵌套的情况:获取slot所在龙骨的节点树
js 复制代码 let parent= this.armature; while (!!parent) { console.log(parent.name); parent= parent.parent; }
- yu /yu1 /yu_11 /root
- yu/yu_1/ root
获取slot所在龙骨的节点树
js 复制代码 let parent= this; while (!!parent) { console.log(parent.name); parent= parent.parent; }
- yu1/ bone2/ bone1/ bone/ root
查顶点数据的xy
这个问题主要是查uv,检索到的顶点数据如下
diff 复制代码 -24.829999923706055, 14.130000114440918, 0.25266502084435194, 0.5545648966428529, -14.710000038146973, 17.8799991607666, 0.2753669662466309, 0.5507230580316307, -0.6800000071525574, 17.8799991607666, 0.30681630250081016, 0.5507230580316307, 14.949999809265137, 8.800000190734863, 0.34185151668838026, 0.560020725189713, 17.950000762939453, 1.5299999713897705, 0.34857875850877873, 0.567474092226572, 25.950000762939453, 0.46000000834465027, 0.36651805425896256, 0.5685757779241226, 25.950000762939453, -17.1200008392334, 0.36651805425896256, 0.5865826441525178, 15.819999694824219, -17.1200008392334, 0.34381412764003766, 0.5865826441525178, 11.920000076293945, -13.039999961853027, 0.33506871800478333, 0.5824071249195949, 2.1500000953674316, -13.569999694824219, 0.3131506187906525, 0.5829457277769869, -13.479999542236328, -7.71999979019165, 0.27811342338643646, 0.5769522043398625, -25.049999237060547, 4.880000114440918, 0.2521589885425939, 0.5640420980867327
对应12个点
我编写了一个uv工具,观察到引擎计算的顶点的确是有问题的,错误的设置mesh,渲染效果也是符合预期
再看顶点计算的规则
js 复制代码 localVertices[vfOffset++] = (region.x + floatArray[uvOffset + i] * region.width) / textureAtlasWidth; localVertices[vfOffset++] = (region.y + floatArray[uvOffset + i + 1] * region.height) / textureAtlasHeight;
概括说就是计算出再合图纹理中的uv
ini 复制代码 uv= (region.x + uv*region.width)/textureWidth
floatArray指向的就是单图里面的uv
切换资源的关键帧数据在哪
gotoAndPlay
也怀疑过是bones缩放引起的
也怀疑过是精度的问题
如上图,顶点-24.83
,在js中变成了-24.829999
,不过这个精度差异非常小,不像是这个问题导致
最终问题定位
最终排查到是龙骨工程mesh设置的有问题
这里解释下uvs的含义,龙骨会导出3个文件,ske.json、tex.png、tex.json
uvs的顶点是0-1
,对应的是散图纹理的0-1
,不是龙骨导出tex.png的0-1