zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
<!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>