tiledmap+3D相机 报错 版本2.2.0

2.1.2和2.1.3都是正常的, 2.2.0 tiledmap+3D相机 只要旋转一下角度就无法正常显示。


模拟器上面会直接报错
Simulator: E/jswrapper (93): Convert arg1 failed!E/jswrapper (111): [ERROR] Failed to invoke js_renderer_Camera_screenToWorld, location: c:\fb\cxp_220\cocos\scripting\js-bindings\manual\jsb_renderer_manual.cpp:111
Simulator: E/jswrapper (93): jsb: ERROR: File c:\fb\cxp_220\cocos\scripting\js-bindings\manual\jsb_renderer_manual.cpp: Line: 93, Function: js_renderer_Camera_screenToWorld
Simulator: E/jswrapper (111): [ERROR] Failed to invoke js_renderer_Camera_screenToWorld, location: c:\fb\cxp_220\cocos\scripting\js-bindings\manual\jsb_renderer_manual.cpp:111
Simulator: E/jswrapper (93): jsb: ERROR: File c:\fb\cxp_220\cocos\scripting\js-bindings\manual\jsb_renderer_manual.cpp: Line: 93, Function: js_renderer_Camera_screenToWorld
Simulator: E/jswrapper (93): jsb: ERROR: File c:\fb\cxp_220\cocos\scripting\js-bindings\manual\jsb_renderer_manual.cpp: Line: 93, Function: js_renderer_Camera_screenToWorld

这个你需要把世界节点rotateX=90, 然后再把地图rotateX=-90, 你要保证地图的绝对位置 在 XOY 平面才能显示在屏幕上。

关闭裁剪试试 cc.macro.ENABLE_TILEDMAP_CULLING = false;

确实是裁剪的问题,这个问题会修复吗,还是要自己动手了。

我还发现一个问题六边形格子的行列对调了。

const getRayPoint = function (node: cc.Node, ray): cc.Vec2 {
    var results = cc.geomUtils.intersect.raycast(node, ray);
    if (results.length <= 0) return null;
    var distance = results[0].distance;
    var d = cc.vmath.vec3.normalize(cc.v3(), ray.d);
    var p = cc.vmath.vec3.scaleAndAdd(cc.v3(), ray.o, d, distance);
    p = node.convertToNodeSpaceAR(p);
    return p;
}

cc.TiledLayer.prototype._updateCulling = function () {
    if (CC_EDITOR) {
        this.enableCulling(false);
    } else if (this._enableCulling) {
        let camera = cc.Camera.findCamera(this.node);
        if (camera) {
            var pointLD = getRayPoint(this.node, camera.getRay(cc.v2(0, 0)));
            var pointLT = getRayPoint(this.node, camera.getRay(cc.v2(0, cc.winSize.height)));
            var pointRD = getRayPoint(this.node, camera.getRay(cc.v2(cc.winSize.width, 0)));
            var pointRT = getRayPoint(this.node, camera.getRay(cc.v2(cc.winSize.width, cc.winSize.height)));

            var width1 = Math.abs(pointLD.x - pointRD.x);
            var width2 = Math.abs(pointLT.x - pointRT.x);
            var height1 = Math.abs(pointLT.y - pointLD.y);
            var height2 = Math.abs(pointRT.y - pointRD.y);

            var point = cc.v2(pointLD.x < pointLT.x ? pointLD.x : pointLT.x, pointLD.y < pointRD.y ? pointLD.y : pointRD.y);
            var width = width1 > width2 ? width1 : width2;
            var height = height1 > height2 ? height1 : height2;

            this._updateViewPort(point.x, point.y, width, height);
        }
    }
}

已经解决,用射线检测简单写了一下。