| | |
| | | let pixiStaMap = new Map(); |
| | | let pixiCrnMap = new Map(); |
| | | let pixiShelfMap = new Map(); |
| | | let pixiTrackMap = new Map(); |
| | | let objectsContainer; |
| | | let objectsContainer2; |
| | | let graphicsShelf; |
| | |
| | | pixiStaMap = new Map();//重置 |
| | | objectsContainer.removeChildren() |
| | | |
| | | let bayWidthList = this.initWidth(map) |
| | | map.forEach((item, index) => { |
| | | for(let idx = 0;idx < item.length;idx++){ |
| | | let val = item[idx]; |
| | | if(val.cellWidth == undefined || val.cellWidth === ''){ |
| | | val.cellWidth = bayWidthList[idx]; |
| | | } |
| | | } |
| | | }) |
| | | |
| | | let bayHeightList = this.initHeight(map); |
| | | let bayWidthList = this.initWidth(map) |
| | | map.forEach((item, index) => { |
| | | for(let idx = 0;idx < item.length;idx++){ |
| | | let val = item[idx]; |
| | | if(val.cellHeight == undefined || val.cellHeight === ''){ |
| | | val.cellHeight = bayHeightList[index]; |
| | | } |
| | | if(val.cellWidth == undefined || val.cellWidth === ''){ |
| | | val.cellWidth = bayWidthList[idx]; |
| | | } |
| | | } |
| | | }) |
| | | |
| | | map.forEach((item, index) => { |
| | | for(let idx = 0;idx < item.length;idx++){ |
| | | let val = item[idx]; |
| | | // 计算合并单元格的实际宽高 |
| | | const rowHeightScaled = bayHeightList.map(h => (h != null && h !== -1) ? (h / 8) : (height)); |
| | | let yOffsets = []; |
| | | let yCursor = 0; |
| | | for (let r = 0; r < map.length; r++) { |
| | | yOffsets[r] = yCursor; |
| | | yCursor += (rowHeightScaled[r] || 0); |
| | | } |
| | | |
| | | map.forEach((row, rowIndex) => { |
| | | let xCursor = 0; |
| | | for (let colIndex = 0; colIndex < row.length; colIndex++) { |
| | | let val = row[colIndex]; |
| | | let cellWidth = val.cellWidth / 40; |
| | | let cellHeight = val.cellHeight / 8; |
| | | |
| | | val.width = cellWidth; |
| | | val.height = cellHeight; |
| | | |
| | | val.posX = idx * cellWidth; |
| | | val.posY = index * cellHeight; |
| | | val.posX = xCursor; |
| | | val.posY = yOffsets[rowIndex]; |
| | | |
| | | xCursor += cellWidth; |
| | | } |
| | | }) |
| | | |
| | |
| | | return new PIXI.Sprite(texture); |
| | | } |
| | | |
| | | function createTrackSprite(width, height) { |
| | | let idx = width + "-" + height; |
| | | let texture = pixiTrackMap.get(idx); |
| | | if (texture == undefined) { |
| | | texture = createTrackTexture(width, height); |
| | | pixiTrackMap.set(idx, texture); |
| | | } |
| | | return new PIXI.Sprite(texture); |
| | | } |
| | | |
| | | function getContainer(type, width, height) { |
| | | let graphics = new PIXI.Graphics(); |
| | | let drawBorder = true; |
| | |
| | | } |
| | | } else if (item.type == 'crn') { |
| | | if (getDeviceNo(value) == -1) { |
| | | sprite = new PIXI.Sprite(graphicsCrnTrack); |
| | | sprite = createTrackSprite(item.width, item.height); |
| | | sprite.zIndex = 0; |
| | | } else { |
| | | sprite = new PIXI.Sprite(graphicsCrn); |