|
|
|
@ -108,7 +108,7 @@ export default abstract class BaseRenderer { |
|
|
|
} |
|
|
|
|
|
|
|
createPointForEntity(item: ItemJson, option?: RendererCudOption): Object3DLike { |
|
|
|
const point = this.createPoint(item, option) |
|
|
|
let point = this.createPoint(item, option) |
|
|
|
point.visible = ((typeof item.v !== 'undefined') ? item.v : true) |
|
|
|
|
|
|
|
if (item.dt.storeAt?.item) { |
|
|
|
@ -118,7 +118,24 @@ export default abstract class BaseRenderer { |
|
|
|
setUserDataForItem(item, point) |
|
|
|
this.afterCreateOrUpdatePoint(item, option, point) |
|
|
|
this.tempViewport.entityManager.appendObject(item.id, point) |
|
|
|
this.appendToScene(point) |
|
|
|
if (typeof option.getParentObject3D === 'function') { |
|
|
|
// 要求添加到指定 父对象
|
|
|
|
const parent: THREE.Object3D = option.getParentObject3D(this.tempViewport, item) |
|
|
|
if (point instanceof MeshWrap) { |
|
|
|
const wrap = point as MeshWrap |
|
|
|
const mesh = wrap.manager.wrapToObject3D(wrap) |
|
|
|
this.tempViewport.entityManager.replaceObject(item.id, mesh) |
|
|
|
parent.add(mesh) |
|
|
|
point = mesh |
|
|
|
|
|
|
|
} else { |
|
|
|
parent.add(point) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
// 默认添加到场景中
|
|
|
|
this.appendToScene(point) |
|
|
|
} |
|
|
|
return point |
|
|
|
} |
|
|
|
|
|
|
|
@ -155,13 +172,14 @@ export default abstract class BaseRenderer { |
|
|
|
if (!rackRenderer) { |
|
|
|
console.error(`Cannot find renderer for rack type ${rack.t}`) |
|
|
|
} |
|
|
|
const { position, rotation } = rackRenderer.getStorePlacement(rack, item.dt.storeAt.bay, item.dt.storeAt.level, item.dt.storeAt.cell) |
|
|
|
const { position, rotation, getParentObject3D } = rackRenderer.getStorePlacement(rack, item.dt.storeAt.bay, item.dt.storeAt.level, item.dt.storeAt.cell) |
|
|
|
if (!position || !rotation) { |
|
|
|
console.error(`无法获取物品 ${item.id} 的存储位置`) |
|
|
|
} |
|
|
|
|
|
|
|
option.position = position |
|
|
|
option.rotation = rotation |
|
|
|
option.getParentObject3D = getParentObject3D |
|
|
|
} |
|
|
|
|
|
|
|
if (_.isArray(option?.position) && _.isArray(option?.rotation)) { |
|
|
|
@ -312,7 +330,10 @@ export default abstract class BaseRenderer { |
|
|
|
* 获取物品存储到地堆货位中,返回可存放的位置和角度一个 Position 和 Rotation |
|
|
|
*/ |
|
|
|
getStorePlacement(storeItem: ItemJson, bay = 0, level = 0, cell = 0) |
|
|
|
: { position: [number, number, number], rotation: [number, number, number] } { |
|
|
|
: { |
|
|
|
position: [number, number, number], rotation: [number, number, number], |
|
|
|
getParentObject3D?: (viewport: Viewport, parent: ItemJson) => THREE.Object3D |
|
|
|
} { |
|
|
|
throw new Error(' 不支持库存物品的添加. t=' + this.itemTypeName) |
|
|
|
} |
|
|
|
|
|
|
|
|