three.js 如何用webgl搭建一个3D库房,3D仓库3D码头,3D集装箱,车辆定位,叉车定位可视化孪生系统——第十五课( 七 )

/*创建车*/function createCarModel(_name, _position, _rotation, _scale, carType) {var model = ...model;// 1.集卡(带集装箱的) 2.集卡(空车) 3.散卡(带箱的小货车) 4.正面吊 5.小铲车 6 板车if (carType) {switch (carType) {case 1: {model.filePath = "../js/models/jika/";model.mtlFileName = "jika.mtl";model.objFileName = "jika.obj";model.scale = {x: 4.200,y: 4.200,z: 4.200}}break;case 2: {model.filePath = "../js/models/jika_nocube/";model.mtlFileName = "jika_nocube.mtl";model.objFileName = "jika_nocube.obj";model.scale = {x: 4.200,y: 4.200,z: 4.200}}break;case 3: {model.filePath = "../js/models/sanka/";model.mtlFileName = "sanka.mtl";model.objFileName = "sanka.obj";model.scale = {x: 0.080,y: 0.080,z: 0.080}model.rotation[1].degree -= Math.PI / 2;}break;case 4: {model.filePath = "../js/models/diaoche/";model.mtlFileName = "dc.mtl";model.objFileName = "dc.obj";model.scale = {x: 1.150,y: 1.150,z: 1.150}}break;case 5: {model.filePath = "../js/models/canche/";model.mtlFileName = "canche.mtl";model.objFileName = "canche.obj";model.scale = {x: 0.1,y: 0.1,z: 0.1}}break;case 6: {model.filePath = "../js/models/banche/";model.mtlFileName = "banche.mtl";model.objFileName = "banche.obj";model.scale = {x: 4.200,y: 4.200,z: 4.200}}break;}}//model.scale.x *= 0.8;//model.scale.y *= 0.8;//model.scale.z *= 0.8;return model;}2.3、自动生成货物模型
 生成模型注意对于批量模型消耗浏览器性能,掉帧问题 。这里后面我会用专门的篇幅讲解,如何优化加载大量货物且不掉帧的解决方案 。
//获取区域库位划分数据webapi.GetAllArea(1, function (result) {var models = [];if (result && result.length > 0) {$("#room_shelfNub").html(result.length);$.each(result, function (_index, _obj) {var _color = _obj.color;if (_color == "") {_color = Math.random() * 16777215 + "";} else {_color = _color.replace("#", "0x")}_color = parseInt(_color)//生成区域画线var model = createAreaModels(_obj.code, _obj.name, _color, _obj.AreaPoints);models = models.concat(model);})}console.log(models);WT3DObj.commonFunc.loadModelsByJsons(models, { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }, true, function () {});})2.4、主要逻辑
具体实现逻辑主要分为五个步骤
1、创建模型
2、校准坐标系,将模型的坐标系与数据坐标系校准对应 。
3、根据配置载入配置模型,如摄像头等
4、生成库位、货物 。根据动态数据,生成库位、车辆、货物等模型
5、业务逻辑 。实现滑动,双击,搜索等常规业务 。
由于篇幅原因,本节先讲解到这 。
技术交流 1203193731@qq.com
交流微信:

three.js 如何用webgl搭建一个3D库房,3D仓库3D码头,3D集装箱,车辆定位,叉车定位可视化孪生系统——第十五课

文章插图
如果你有什么要交流的心得 可邮件我
其它

经验总结扩展阅读