19 changed files with 232 additions and 101 deletions
|
After Width: | Height: | Size: 438 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 234 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
@ -0,0 +1,5 @@ |
|||||
|
import BaseEntity from '@/core/base/BaseItemEntity.ts' |
||||
|
|
||||
|
export default class PalletEntity extends BaseEntity { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
import BaseInteraction from '@/core/base/BaseInteraction.ts' |
||||
|
import * as THREE from 'three' |
||||
|
|
||||
|
export default class PalletInteraction extends BaseInteraction { |
||||
|
|
||||
|
get isSinglePointMode(): boolean { |
||||
|
return true |
||||
|
} |
||||
|
|
||||
|
constructor(itemTypeName: string) { |
||||
|
super(itemTypeName) |
||||
|
} |
||||
|
|
||||
|
createPointOfItem(item: ItemJson, point: THREE.Vector3): ItemJson { |
||||
|
item = super.createPointOfItem(item, point) |
||||
|
|
||||
|
// 创建一个地堆货架
|
||||
|
item.dt.palletWidth = 1 // 宽度
|
||||
|
item.dt.palletDepth = 1.2 // 深度
|
||||
|
return item |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
import type { PropertySetter } from "@/core/base/PropertyTypes.ts"; |
||||
|
import { basicFieldsSetter } from "@/editor/widgets/property/PropertyPanelConstant.ts"; |
||||
|
|
||||
|
const propertySetter: PropertySetter = { |
||||
|
flatten: { |
||||
|
fields: [ |
||||
|
...basicFieldsSetter, |
||||
|
{ |
||||
|
dataPath: 'dt.palletWidth', label: '托盘宽度', input: 'InputNumber', |
||||
|
inputProps: {}, |
||||
|
}, |
||||
|
{ |
||||
|
dataPath: 'dt.palletDepth', label: '托盘深度', input: 'InputNumber', |
||||
|
inputProps: {}, |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
export default propertySetter; |
||||
@ -0,0 +1,75 @@ |
|||||
|
import * as THREE from 'three' |
||||
|
import BaseRenderer from '@/core/base/BaseRenderer.ts' |
||||
|
import Constract from '@/core/Constract.ts' |
||||
|
import InstancePointManager from '@/core/manager/InstancePointManager.ts' |
||||
|
import type { Object3DLike } from '@/types/ModelTypes.ts' |
||||
|
import MODULE_3DS_File from '@/assets/Models/Tote.3ds?url' |
||||
|
import MODULE_3DS_TEX from '@/assets/Models/ToteTex.png?url' |
||||
|
import { load3DModule, loadByUrl, loadTexture } from '@/core/ModelUtils.ts' |
||||
|
|
||||
|
/** |
||||
|
* 货架货位渲染器 |
||||
|
*/ |
||||
|
export default class PalletRenderer extends BaseRenderer { |
||||
|
static POINT_NAME = 'pallet_point' |
||||
|
|
||||
|
/** |
||||
|
* 默认点的高度, 防止和地面重合 |
||||
|
*/ |
||||
|
readonly defulePositionY: number = Constract.HEIGHT_WAY |
||||
|
readonly defaultScale: THREE.Vector3 = new THREE.Vector3(1, 1, 1) |
||||
|
readonly defaultRotation: THREE.Vector3 = new THREE.Vector3(0, 0, 0) |
||||
|
readonly defaultUserData = { |
||||
|
color: 0x4559A0 |
||||
|
} |
||||
|
|
||||
|
toteGeometry: THREE.BufferGeometry |
||||
|
toteMaterial: THREE.Material |
||||
|
|
||||
|
init() { |
||||
|
return Promise.all([ |
||||
|
super.init(), |
||||
|
loadByUrl(MODULE_3DS_File), |
||||
|
loadTexture(MODULE_3DS_TEX) |
||||
|
|
||||
|
]).then(([_, { data: queue3dsFile }, queueTexture]) => { |
||||
|
const mesh = load3DModule(queue3dsFile, '.3ds').children[0] as THREE.Mesh |
||||
|
this.toteGeometry = mesh.geometry.rotateX(-Math.PI / 2) |
||||
|
this.toteGeometry.scale(1, 1, 1) |
||||
|
this.toteGeometry.center() |
||||
|
this.toteMaterial = mesh.material as THREE.Material |
||||
|
this.toteMaterial.map = queueTexture |
||||
|
this.toteMaterial.color.set(this.defaultUserData.color) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
createPointBasic(item: ItemJson, option?: RendererCudOption): Object3DLike { |
||||
|
return this.pointManager.createPoint(item) |
||||
|
} |
||||
|
|
||||
|
get pointManager(): InstancePointManager { |
||||
|
if (!this.tempViewport) { |
||||
|
throw new Error('tempViewport is not set.') |
||||
|
} |
||||
|
return this.tempViewport.getOrCreatePointManager(this.itemTypeName, () => |
||||
|
// 构建 InstanceMesh 代理对象
|
||||
|
InstancePointManager.create(this.itemTypeName, |
||||
|
this.tempViewport, |
||||
|
this.toteGeometry, |
||||
|
this.toteMaterial, |
||||
|
Constract.MAX_PALLET_INSTANCES) |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
dispose() { |
||||
|
super.dispose() |
||||
|
if (this.toteGeometry) { |
||||
|
this.toteGeometry.dispose() |
||||
|
this.toteGeometry = undefined |
||||
|
} |
||||
|
if (this.toteMaterial) { |
||||
|
this.toteMaterial.dispose() |
||||
|
this.toteMaterial = undefined |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
import { defineModule } from '@/core/manager/ModuleManager.ts' |
||||
|
import ToteRenderer from './ToteRenderer.ts' |
||||
|
import ToteEntity from './ToteEntity.ts' |
||||
|
import ToteInteraction from './ToteInteraction.ts' |
||||
|
import propertySetter from './TotePropertySetter.ts' |
||||
|
|
||||
|
export const ITEM_TYPE_NAME = 'tote' |
||||
|
|
||||
|
export default defineModule({ |
||||
|
name: ITEM_TYPE_NAME, |
||||
|
renderer: new ToteRenderer(ITEM_TYPE_NAME), |
||||
|
interaction: new ToteInteraction(ITEM_TYPE_NAME), |
||||
|
setter: propertySetter, |
||||
|
entity: ToteEntity |
||||
|
}) |
||||
Loading…
Reference in new issue