美文网首页工作生活
Cesium模型跟随鼠标旋转

Cesium模型跟随鼠标旋转

作者: Codifier | 来源:发表于2019-07-03 16:00 被阅读0次
viewer.scene.camera.changed.addEventListener(function(){
        var cameraHeading = viewer.scene.camera.heading;
        var diff = preCameraHeading - cameraHeading;
        if(model){
            model.modelMatrix = Cesium.Matrix4.multiply(model.modelMatrix, rotateAroundZ(diff), new Cesium.Matrix4());
            preModelMatrixes[0] = model.modelMatrix;
        }
        preCameraHeading = cameraHeading;
}, this);

function rotateAroundZ(rads){
        var cosTheta = Math.cos(rads);
        var sinTheta = Math.sin(rads);
        var v = [cosTheta, sinTheta, 0.0, 0.0, -sinTheta, cosTheta, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0];
        return Cesium.Matrix4.fromArray(v);
}

相关文章

网友评论

    本文标题:Cesium模型跟随鼠标旋转

    本文链接:https://www.haomeiwen.com/subject/euqchctx.html