{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671508811507,"data":{"id":71713232,"title":"2.6.2 模型3D","slug":"oygc67","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"

本章节主要介绍3D模型,图层中如3D车标会使用到3D模型。 3D模型的管理与纹理管理类型,只是接口不同。

另图层的3D模型图元添加可以参考3D模型图元章节。

场景图

时序图

核心接口

   boolean com.autonavi.gbl.map.MapView.addLayer3DModel(Layer3DModel modelParam)

boolean com.autonavi.gbl.map.MapView.updateLayer3DModel(Layer3DModel modelParam)

boolean com.autonavi.gbl.map.MapView.destroyLayer3DModel(int resId)

说明:函数详情,请复制函数名称到在线API搜索

调用示例

 public final static int MODEL_ID_CAR_AUTO = 2000;\n\n public class FileUtils {\n\n    public static byte[] File2byte(String filePath) {\n        if (TextUtils.isEmpty(filePath)) {\n            return null;\n        }\n        return File2byte(new File(filePath));\n    }\n\n    @Nullable\n    public static byte[] File2byte(File file) {\n        if (!file.exists()) {\n            return null;\n        }\n\n        byte[] buffer = null;\n        FileInputStream fis = null;\n        ByteArrayOutputStream bos = null;\n        try {\n            fis = new FileInputStream(file);\n            bos = new ByteArrayOutputStream();\n            byte[] b = new byte[1024];\n            int n;\n            while ((n = fis.read(b)) != -1) {\n                bos.write(b, 0, n);\n            }\n            buffer = bos.toByteArray();\n        } catch (IOException e) {\n            e.printStackTrace();\n        } finally {\n            safetyClose(fis);\n            safetyClose(bos);\n        }\n        LoggerUtil.d(TAG, "File2byte: path = " + file);\n        return buffer;\n    }\n    public static void safetyClose(Closeable closeable) {\n        if (closeable != null) {\n            try {\n                closeable.close();\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n        }\n    }\n }\n  \nstatic void addLayer3DModel(MapView mapView, int markerId, byte[] file) {\n        Layer3DModel layer3DModel = new Layer3DModel();\n        layer3DModel.resourceID = markerId;\n        layer3DModel.dataBuff = new BinaryStream(file);\n        mapView.addLayer3DModel(layer3DModel);\n    }\n\naddLayer3DModel(mapView, MODEL_ID_CAR_AUTO, FileUtils.File2byte(new File(".\\res\\autocar.dat")));\n



","body_lake":null,"pub_level":null,"status":"0","updated_at":"2022-04-06 07:01:52","deleted_at":null,"nameSpace":"mnlcaa/v610","browseCount":86,"collectCount":0,"estimateDate":5,"docStatus":0,"permissions":true,"overView":false}}