<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<title>3D 特效</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<style>
|
body {
|
margin: 0;
|
overflow: hidden;
|
}
|
|
#label {
|
position: absolute;
|
padding: 10px;
|
background: rgba(255, 255, 255, 0.6);
|
line-height: 1;
|
border-radius: 5px;
|
}
|
|
#video {
|
position: absolute;
|
width: 0;
|
height: 0;
|
}
|
</style>
|
<script src="~/Content/js/ThreeJs/js/three.js"></script>
|
<script src="~/Content/js/ThreeJs/js/stats.min.js"></script>
|
<script src="~/Content/js/ThreeJs/js/OrbitControls.js"></script>
|
<script src="~/Content/js/ThreeJs/js/dat.gui.min.js"></script>
|
<script src="~/Content/js/ThreeJs/js/EffectComposer.js"></script>
|
<script src="~/Content/js/ThreeJs/js/RenderPass.js"></script>
|
<script src="~/Content/js/ThreeJs/js/OutlinePass.js"></script>
|
<script src="~/Content/js/ThreeJs/js/FXAAShader.js"></script>
|
<script src="~/Content/js/ThreeJs/js/CopyShader.js"></script>
|
<script src="~/Content/js/ThreeJs/js/ShaderPass.js"></script>
|
<script src="~/Content/js/ThreeJs/js/ThreeBSP.js"></script>
|
|
<script src="~/Content/js/ThreeJs/ThreeJs_Composer.js"></script>
|
<script src="~/Content/js/jquery/jquery-1.8.1.min.js" type="text/javascript"></script>
|
<script src="~/js/core/common.js"></script>
|
@*<script src="~/Content/js/ThreeJs/Modules.js" charset="UTF-8"></script>*@
|
</head>
|
<body>
|
<div id="label"></div>
|
<div id="container"></div>
|
<video id="video" autoplay loop muted>
|
@*<source src="./video/videoPlane.mp4">*@
|
</video>
|
<script>
|
var para = initPara();
|
para.url = {
|
GetAreas: "@Url.Action("GetAreas")",
|
GetRows: "@Url.Action("GetRows")",
|
GetLocations: "@Url.Action("GetLocations")",
|
};
|
|
function getAreas() {
|
ajaxManage({
|
url: para.url.GetAreas,
|
success: function (result) {
|
//console.log(result);
|
para.base.areas = result.Data;
|
}
|
});
|
}
|
|
function getRows(areaCode) {
|
ajaxManage({
|
url: para.url.GetRows + "?areaCode=" + areaCode,
|
success: function (result) {
|
console.log(result);
|
para.base.rows = result.Data;
|
}
|
});
|
}
|
|
function getLocations(areaCode) {
|
ajaxManage({
|
url: para.url.GetLocations + "?areaCode=" + areaCode,
|
success: function (result) {
|
console.log(result);
|
para.base.locations = result.Data;
|
}
|
});
|
}
|
|
//初始化参数
|
function initPara() {
|
return {
|
//three参数
|
base: {
|
scene: {},
|
camera: {},
|
renderer: {},
|
light: {},
|
composer: {},
|
options: {},
|
stats: {},
|
objects: [],
|
areas: [],
|
rows: [],
|
locations: []
|
},
|
|
//模型材质信息
|
mat: {
|
planeMat: {},
|
RackMat: {},
|
RackMat2: {},
|
CargoMat: {},
|
LineMat: {},
|
RollTexture: {},
|
RollMat: {}
|
},
|
//库区信息
|
storage: {
|
storageZoneSize: 0,
|
storageZoneList: []
|
},
|
//货架信息
|
shelf: {
|
shelfSize: 0,
|
shelfList: []
|
},
|
//货位信息
|
storageUnit: {
|
storageUnitSize: 0,
|
storageUnitList: []
|
},
|
//货物信息
|
cargo: {
|
cargoSize: 0,
|
cargoList: [],
|
CargosExist: {}
|
},
|
//尺寸
|
size: {
|
PLANE_LENGTH: 24,
|
PLANE_WIDTH: 200,
|
PLANE_HEIGHT: 2,
|
HOLDER_LENGTH: 2,
|
HOLDER_WIDTH: 2,
|
HOLDER_HEIGHT: 25,
|
LAYER_NUM: 3, //层级
|
COLUMN_NUM: 2 //列
|
},
|
//位置
|
position: {
|
area1: {
|
x: -1200,
|
z: -100,
|
w: 800,
|
h: 1000,
|
font_size: 30,
|
textColor: "000000",
|
textposition: "左对齐"
|
},
|
area2: {
|
x: -1200,
|
z: -100,
|
w: 800,
|
h: 1000,
|
font_size: 30,
|
textColor: "000000",
|
textposition: "左对齐"
|
},
|
}
|
}
|
};
|
|
// 初始化
|
function init() {
|
initMat();
|
initScene();
|
initCamera();
|
initRenderer();
|
initContent();
|
initLight();
|
initControls();
|
initGui();
|
//addArea(-500, 0, 1000, 500, para.base.scene, "ID1$库区1号", "000000", 20, "左对齐");
|
getAreas();
|
//添加库区 原料A区:YLRS01 原理-B区: YLRS02 原料-C区: YLRS03 原料满区 YLREND
|
$.each(para.base.areas, function (index, value) {
|
if (value.CN_S_AREA_CODE == "YLREND") {
|
para.position.area1.name = "ID1$" + value.CN_S_AREA_NAME;
|
addArea(para.position.area1);
|
getRows("YLREND");
|
addShelfTest(para.base.scene, para.base.objects, para.position.area1, -100, -300);
|
getLocations("YLREND");
|
$.each(para.base.locations, function (index, value) {
|
if (value.VIEW_STATE == "满") {
|
addOneUnitCargosTest(value.CN_S_ROW, value.CN_S_FLOOR, (parseInt(value.CN_S_COL) - 1) + "", para.base.scene);
|
}
|
});
|
}
|
if (value.CN_S_AREA_CODE == "YLRS02") {
|
//addArea(500, 0, 1000, 500, para.base.scene, "ID2$" + value.CN_S_AREA_NAME, "000000", 20, "左对齐");
|
}
|
if (value.CN_S_AREA_CODE == "YLRS03") {
|
//addArea(00, 0, 1000, 500, para.base.scene, "ID1$" + value.CN_S_AREA_NAME, "000000", 20, "左对齐");
|
}
|
});
|
|
// addShelfTest(scene, objects);
|
|
|
//添加货物
|
// for(var i = 1; i <= 3; i++){
|
// for(var j = 1; j <= 2; j++){
|
// for(var k = 1; k <= 3; k++) {
|
// addOneUnitCargosTest("A" + k, i, j, scene);
|
// }
|
// }
|
// }
|
|
//货位 3排4列5层的货物
|
//addOneUnitCargosTest("A2", 5, 7, para.base.scene);
|
//addOneUnitCargosTest("A2", 2, 1, para.base.scene);
|
|
//添加选中时的蒙版
|
para.base.composer = new THREE.ThreeJs_Composer(para.base.renderer, para.base.scene, para.base.camera, para.base.options);
|
|
document.addEventListener('resize', onWindowResize, false);
|
|
}
|
|
/** 初始化材质信息 */
|
function initMat() {
|
para.mat.planeMat = new THREE.MeshLambertMaterial();
|
para.mat.RackMat = new THREE.MeshLambertMaterial();
|
para.mat.RackMat2 = new THREE.MeshPhongMaterial({ color: 0x1C86EE });
|
para.mat.CargoMat = new THREE.MeshLambertMaterial();
|
para.mat.LineMat = new THREE.MeshLambertMaterial();
|
para.mat.RollMat = new THREE.MeshLambertMaterial();
|
|
new THREE.TextureLoader().load('/Content/js/ThreeJs/images/plane.png', function (map) {
|
para.mat.planeMat.map = map;
|
para.mat.planeMat.transparent = true;
|
para.mat.planeMat.opacity = 0.8;
|
para.mat.planeMat.needsUpdate = true;
|
});
|
new THREE.TextureLoader().load("/Content/js/ThreeJs/images/rack.png", function (map) {
|
para.mat.RackMat.map = map;
|
para.mat.RackMat.needsUpdate = true;
|
});
|
new THREE.TextureLoader().load("/Content/js/ThreeJs/images/box.png", function (map) {
|
para.mat.CargoMat.map = map;
|
para.mat.CargoMat.needsUpdate = true;
|
});
|
new THREE.TextureLoader().load("/Content/js/ThreeJs/images/line.png", function (map) {
|
para.mat.LineMat.map = map;
|
para.mat.LineMat.needsUpdate = true;
|
});
|
para.mat.RollTexture = new THREE.TextureLoader().load("/Content/js/ThreeJs/images/biaoyu.png", function (map) {
|
para.mat.RollMat.map = map;
|
para.mat.RollMat.needsUpdate = true;
|
para.mat.RollMat.transparent = true;
|
para.mat.RollMat.side = THREE.DoubleSide;
|
});
|
para.mat.RollTexture.wrapS = THREE.RepeatWrapping;
|
para.mat.RollTexture.wrapT = THREE.RepeatWrapping;
|
}
|
|
// 初始化场景
|
function initScene() {
|
para.base.scene = new THREE.Scene();
|
para.base.stats = initStats();
|
}
|
|
// 初始化相机
|
function initCamera() {
|
para.base.camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 10000);
|
para.base.camera.position.set(0, 800, 1500);
|
para.base.camera.lookAt(new THREE.Vector3(0, 0, 0));
|
}
|
|
/** 放置虚线框区域和库区名称 */
|
function addArea(area) {
|
addPlane(area.x, area.z, area.w, area.h, para.base.scene);
|
|
new THREE.FontLoader().load('/Content/js/ThreeJs/FZYaoTi_Regular.json', function (font) {
|
////加入立体文字
|
var text = new THREE.TextGeometry(area.name.split("$")[1], {
|
// 设定文字字体
|
font: font,
|
//尺寸
|
size: area.font_size,
|
//厚度
|
height: 0.01
|
});
|
text.computeBoundingBox();
|
//3D文字材质
|
var m = new THREE.MeshStandardMaterial({ color: "#" + area.textColor });
|
var mesh = new THREE.Mesh(text, m)
|
if (area.textposition == "左对齐") {
|
mesh.position.x = area.x - area.w / 2 + 10;
|
} else if (area.textposition == "居中") {
|
mesh.position.x = area.x - 15;
|
} else if (area.textposition == "右对齐") {
|
mesh.position.x = area.x + area.w / 2 - 60;
|
}
|
mesh.position.y = 1.3;
|
mesh.position.z = area.z + area.h / 2 - 20;
|
mesh.rotation.x = -Math.PI / 2.0;
|
para.base.scene.add(mesh);
|
});
|
}
|
|
/** 矩形区域 */
|
function addPlane(x, z, width, length, scene) {
|
var lineWidth = 8
|
var geometry = new THREE.PlaneGeometry(lineWidth, length);
|
var obj = new THREE.Mesh(geometry, para.mat.LineMat);
|
obj.position.set(x, 1.5, z);
|
obj.rotation.x = -Math.PI / 2.0;
|
var obj2 = obj.clone();
|
obj2.translateX(width);
|
|
var geometry2 = new THREE.PlaneGeometry(lineWidth, width);
|
var obj3 = new THREE.Mesh(geometry2, para.mat.LineMat);
|
obj3.position.set(x + width / 2, 1.5, z - length / 2 + lineWidth / 2);
|
obj3.rotation.x = -Math.PI / 2.0;
|
obj3.rotation.z = -Math.PI / 2.0;
|
var obj4 = obj3.clone();
|
obj4.translateX(length - lineWidth);
|
|
var group = new THREE.Group();
|
group.add(obj);
|
group.add(obj2);
|
group.add(obj3);
|
group.add(obj4);
|
group.translateX(-width / 2);
|
para.base.scene.add(group);
|
}
|
|
// 初始化灯光
|
function initLight() {
|
var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.3 );//模拟远处类似太阳的光源
|
directionalLight.color.setHSL( 0.1, 1, 0.95 );
|
directionalLight.position.set( 0, 200, 0).normalize();
|
para.base.scene.add(directionalLight);
|
|
var ambient = new THREE.AmbientLight( 0xffffff, 1 ); //AmbientLight,影响整个场景的光源
|
ambient.position.set(0,0,0);
|
para.base.scene.add( ambient );
|
}
|
|
// 初始化性能插件
|
function initStats() {
|
var stats = new Stats();
|
|
stats.domElement.style.position = 'absolute';
|
stats.domElement.style.left = '0px';
|
stats.domElement.style.top = '0px';
|
|
document.body.appendChild(stats.domElement);
|
return stats;
|
}
|
|
// 初始化GUI
|
function initGui() {
|
para.base.options = new function () {
|
this.batchNo = ''; this.qty = 0; this.qtyUom = ''; this.qty2 = 0;
|
this.实时全景监控 = function () {
|
window.open("3DVideo.html");
|
};
|
};
|
var gui = new dat.GUI();
|
gui.domElement.style = 'position:absolute;top:10px;right:0px;height:600px';
|
gui.add(para.base.options, 'batchNo').name("物料批号:").listen();
|
gui.add(para.base.options, 'qty').name("数量:").listen();
|
gui.add(para.base.options, 'qtyUom').name("单位:").listen();
|
gui.add(para.base.options, 'qty2').name("件数:").listen();
|
gui.add(para.base.options, '实时全景监控');
|
}
|
|
// 初始化渲染器
|
function initRenderer() {
|
para.base.renderer = new THREE.WebGLRenderer({antialias: true});
|
para.base.renderer.setSize(window.innerWidth, window.innerHeight);
|
para.base.renderer.setClearColor(0x4682B4, 1.0);
|
document.body.appendChild(para.base.renderer.domElement);
|
}
|
|
//创建地板
|
function createFloor(){
|
var loader = new THREE.TextureLoader();
|
loader.load("/Content/js/ThreeJs/images/floor2.jpg",function(texture){
|
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
texture.repeat.set( 10, 10 );
|
var floorGeometry = new THREE.BoxGeometry(3600, 2000, 1);
|
var floorMaterial = new THREE.MeshBasicMaterial( { map: texture, side: THREE.DoubleSide } );
|
var floor = new THREE.Mesh(floorGeometry, floorMaterial);
|
floor.position.y = -0.5;
|
floor.rotation.x = Math.PI / 2;
|
floor.name = "地面";
|
para.base.scene.add(floor);
|
para.base.objects.push( floor );
|
});
|
}
|
|
//创建墙
|
function createCubeWall(width, height, depth, angle, material, x, y, z, name){
|
var cubeGeometry = new THREE.BoxGeometry(width, height, depth );
|
var cube = new THREE.Mesh( cubeGeometry, material );
|
cube.position.x = x;
|
cube.position.y = y;
|
cube.position.z = z;
|
cube.rotation.y += angle*Math.PI; //-逆时针旋转,+顺时针
|
cube.name = name;
|
para.base.scene.add(cube);
|
}
|
|
// 初始化模型
|
function initContent() {
|
createFloor();
|
//创建墙
|
createCubeWall(10, 200, 2000, 0, new THREE.MeshPhongMaterial({color: 0xafc0ca}), -1800, 100, 0, "墙面");
|
//创建墙
|
createCubeWall(10, 200, 3600, 0.5, new THREE.MeshPhongMaterial({color: 0xafc0ca}), 0, 100, 1000, "墙面");
|
//创建墙
|
createCubeWall(10, 200, 2000, 1, new THREE.MeshPhongMaterial({color: 0xafc0ca}), 1800, 100, 0, "墙面");
|
//创建墙
|
createCubeWall(10, 200, 3600, 1.5, new THREE.MeshPhongMaterial({color: 0xafc0ca}), 0, 100, -1000, "墙面");
|
}
|
|
// 初始化轨迹球控件
|
function initControls() {
|
controls = new THREE.OrbitControls(para.base.camera, para.base.renderer.domElement);
|
controls.enableDamping = true;
|
controls.dampingFactor = 0.5;
|
// 视角最小距离
|
controls.minDistance = 100;
|
// 视角最远距离
|
controls.maxDistance = 5000;
|
// 最大角度
|
controls.maxPolarAngle = Math.PI/2.2;
|
}
|
|
// 更新控件
|
function update() {
|
para.base.stats.update();
|
controls.update();
|
}
|
|
/** 放置一叠货架 */
|
/** stack_num 货架的叠数 */
|
function addStackOfRack(x, y, z, plane_x, plane_y, plane_z, holder_x, holder_y, holder_z, scene, name, num, stack_num, objects) {
|
for (var i = 0; i < stack_num; i++) {
|
addRack(x, y * (i + 1), z, plane_x, plane_y, plane_z, holder_x, holder_y, holder_z, scene, name + "$" + (i + 1), num, objects);
|
}
|
}
|
|
/** 放置单层货架 */
|
/** x,y,z 整个模型在场景中的位置 */
|
/** plane_x,plane_y,plane_z 货架板面的长高宽 */
|
/** holder_x,holder_y,holder_z 货架支架的长高宽 */
|
/** scene,name,num 要添加的场景,货架的名字,单层货架的库位数量 */
|
function addRack(x, y, z, plane_x, plane_y, plane_z, holder_x, holder_y, holder_z, scene, name, num, objects) {
|
var plane = new THREE.BoxGeometry(plane_x, plane_y, plane_z / num);
|
var gz = [];
|
for (var i = 0; i < num; i++) {
|
gz.push(z + plane_z / num / 2 + (plane_z / num) * i);
|
var obj = new THREE.Mesh(plane, para.mat.RackMat);
|
obj.position.set(x, y, gz[i]);
|
|
var msg = name + "$" + (i);
|
var storageUnitId = msg.split("$")[1] + "$" + msg.split("$")[3] + "$" + msg.split("$")[4];
|
|
//添加货位
|
var storageUnit_obj = new storageUnit(msg.split("$")[0],
|
msg.split("$")[1],
|
msg.split("$")[2],
|
msg.split("$")[3],
|
msg.split("$")[4],
|
x, y, gz[i], storageUnitId);
|
para.storageUnit.storageUnitList.push(storageUnit_obj);
|
para.storageUnit.storageUnitSize++;
|
|
var Unit = getStorageUnitById(msg.split("$")[1], msg.split("$")[3], msg.split("$")[4]);
|
obj.name = "货位" + "$" + Unit.storageUnitId;
|
scene.add(obj);
|
objects.push(obj);
|
}
|
|
var holder = new THREE.BoxGeometry(holder_x, holder_y, holder_z);
|
var obj2 = new THREE.Mesh(holder, para.mat.RackMat2);
|
var obj3 = new THREE.Mesh(holder, para.mat.RackMat2);
|
var obj4 = new THREE.Mesh(holder, para.mat.RackMat2);
|
var obj5 = new THREE.Mesh(holder, para.mat.RackMat2);
|
|
obj2.position.set(x - plane_x / 2 + holder_x / 2, y - holder_y / 2 - plane_y / 2, z + holder_z / 2);
|
obj3.position.set(x + plane_x / 2 - holder_x / 2, y - holder_y / 2 - plane_y / 2, z + holder_z / 2);
|
obj4.position.set(x - plane_x / 2 + holder_x / 2, y - holder_y / 2 - plane_y / 2, z + plane_z - holder_z / 2);
|
obj5.position.set(x + plane_x / 2 - holder_x / 2, y - holder_y / 2 - plane_y / 2, z + plane_z - holder_z / 2);
|
scene.add(obj2); scene.add(obj3); scene.add(obj4); scene.add(obj5);
|
}
|
|
// 窗口变动触发的方法
|
function onWindowResize() {
|
para.base.camera.aspect = window.innerWidth / window.innerHeight;
|
para.base.camera.updateProjectionMatrix();
|
para.base.renderer.setSize(window.innerWidth, window.innerHeight);
|
}
|
|
function animate() {
|
requestAnimationFrame(animate);
|
para.base.renderer.render(para.base.scene, para.base.camera);
|
para.base.composer.render();
|
update();
|
}
|
|
//创建货位对象
|
function storageUnit(storageZoneId, shelfId, shelfName,
|
inLayerNum, inColumnNum,
|
positionX, positionY, positionZ, storageUnitId) {
|
this.storageZoneId = storageZoneId;
|
this.shelfId = shelfId;
|
this.shelfName = shelfName;
|
this.inLayerNum = inLayerNum;
|
this.inColumnNum = inColumnNum;
|
this.positionX = positionX;
|
this.positionY = positionY;
|
this.positionZ = positionZ;
|
this.storageUnitId = storageUnitId;
|
}
|
|
//根据货架ID、层数、列数获取货位对象
|
function getStorageUnitById(shelfId, inLayerNum, inColumnNum) {
|
|
for (var i = 0; i < para.storageUnit.storageUnitSize; i++) {
|
if (para.storageUnit.storageUnitList[i].shelfId == shelfId && para.storageUnit.storageUnitList[i].inLayerNum == inLayerNum && para.storageUnit.storageUnitList[i].inColumnNum == inColumnNum) {
|
//console.log(para.storageUnit.storageUnitList[i]);
|
return para.storageUnit.storageUnitList[i];
|
}
|
}
|
}
|
|
/** 根据3D库图货架配置表添加货架 */
|
function addShelfTest(scene, objects, area, shiftX, shiftZ) {
|
|
var shelf_list = new Array();
|
|
var pianyiNum = 0;
|
$.each(para.base.rows, function (index, value) {
|
shelf_list.push({ StorageZoneId: 'Z1', shelfId: value.CN_S_ROW, shelfName: '货架A' + i, x: area.x + pianyiNum + shiftX, y: 27, z: area.z + shiftZ, LAYER_NUM: value.CN_N_FLOOR, COLUMN_NUM: value.CN_N_COL });
|
pianyiNum += 100;
|
});
|
|
para.shelf.shelfSize = shelf_list.length;
|
for (var i = 0; i < para.shelf.shelfSize; i++) {
|
para.size.PLANE_WIDTH = shelf_list[i].COLUMN_NUM * 30;
|
|
var shelf_obj = new shelf(shelf_list[i].StorageZoneId,
|
shelf_list[i].shelfId,
|
shelf_list[i].shelfName,
|
para.size.PLANE_LENGTH, para.size.PLANE_WIDTH, para.size.PLANE_HEIGHT,
|
para.size.HOLDER_LENGTH,
|
para.size.HOLDER_WIDTH,
|
para.size.HOLDER_HEIGHT,
|
shelf_list[i].x,
|
shelf_list[i].y,
|
shelf_list[i].z,
|
shelf_list[i].LAYER_NUM,
|
shelf_list[i].COLUMN_NUM);
|
para.shelf.shelfList.push(shelf_obj);
|
}
|
|
for (var i = 0; i < para.shelf.shelfSize; i++) {
|
addStackOfRack(para.shelf.shelfList[i].positionX, para.shelf.shelfList[i].positionY, para.shelf.shelfList[i].positionZ, para.shelf.shelfList[i].planeLength, para.shelf.shelfList[i].planeHeight, para.shelf.shelfList[i].planeWidth, para.shelf.shelfList[i].holderLength, para.shelf.shelfList[i].holderHeight, para.shelf.shelfList[i].holderWidth, scene, para.shelf.shelfList[i].storageZoneId + "$" + para.shelf.shelfList[i].shelfId + "$" + para.shelf.shelfList[i].shelfName, para.shelf.shelfList[i].columnNum, para.shelf.shelfList[i].layerNum, objects);
|
}
|
}
|
|
//创建货架对象
|
function shelf(storageZoneId, shelfId, shelfName,
|
planeLength, planeWidth, planeHeight,
|
holderLength, holderWidth, holderHeight,
|
positionX, positionY, positionZ,
|
layerNum, columnNum) {
|
this.storageZoneId = storageZoneId;
|
this.shelfId = shelfId;
|
this.shelfName = shelfName;
|
this.planeLength = planeLength;
|
this.planeWidth = planeWidth;
|
this.planeHeight = planeHeight;
|
this.holderLength = holderLength;
|
this.holderWidth = holderWidth;
|
this.holderHeight = holderHeight;
|
this.positionX = positionX;
|
this.positionY = positionY;
|
this.positionZ = positionZ;
|
this.layerNum = layerNum;
|
this.columnNum = columnNum;
|
}
|
|
/** 添加单个货位上的货物 */
|
function addOneUnitCargosTest(shelfId, inLayerNum, inColumnNum, scene) {
|
var storageUnit = getStorageUnitById(shelfId, inLayerNum, inColumnNum);
|
if (storageUnit == undefined) {
|
return;
|
}
|
var shelf = getShelfById(storageUnit.shelfId);
|
var storageUnitid = storageUnit.storageUnitId;
|
var x = storageUnit.positionX;
|
var y = storageUnit.positionY + 8 + shelf.planeHeight/2;
|
var z = storageUnit.positionZ;
|
addCargo(x,y,z,16,16,16,scene,"货物"+"$"+storageUnitid)
|
}
|
|
//根据货架编码获取货架对象
|
function getShelfById(shelfId) {
|
for (var i = 0; i < para.shelf.shelfSize; i++) {
|
if (para.shelf.shelfList[i].shelfId == shelfId) {
|
return para.shelf.shelfList[i];
|
}
|
}
|
}
|
|
/** 放置单个货物 */
|
function addCargo(x, y, z, box_x, box_y, box_z, scene, name) {
|
var geometry = new THREE.BoxGeometry(box_x, box_y, box_z);
|
var obj = new THREE.Mesh(geometry, para.mat.CargoMat);
|
obj.position.set(x, y, z);
|
obj.name = name;
|
scene.add(obj);
|
}
|
|
init();
|
animate();
|
|
</script>
|
</body>
|
</html>
|