|
|
@ -15,12 +15,23 @@ export default abstract class BaseRenderer { |
|
|
*/ |
|
|
*/ |
|
|
tempViewport?: Viewport = undefined |
|
|
tempViewport?: Viewport = undefined |
|
|
|
|
|
|
|
|
|
|
|
isUpdating: boolean = false |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 开始更新 |
|
|
* 开始更新 |
|
|
* @param viewport 当前视口 |
|
|
* @param viewport 当前视口 |
|
|
*/ |
|
|
*/ |
|
|
beginRendererUpdate(viewport: Viewport): void { |
|
|
beginRendererUpdate(viewport: Viewport): void { |
|
|
this.tempViewport = viewport |
|
|
this.tempViewport = viewport |
|
|
|
|
|
this.isUpdating = true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 结束更新 |
|
|
|
|
|
*/ |
|
|
|
|
|
endRendererUpdate(): void { |
|
|
|
|
|
this.tempViewport = undefined |
|
|
|
|
|
this.isUpdating = false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -33,6 +44,18 @@ export default abstract class BaseRenderer { |
|
|
*/ |
|
|
*/ |
|
|
abstract createLineBasic(start: ItemJson, end: ItemJson, type: LinkType): THREE.Object3D[] |
|
|
abstract createLineBasic(start: ItemJson, end: ItemJson, type: LinkType): THREE.Object3D[] |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 创建或更新线之后的回调 |
|
|
|
|
|
*/ |
|
|
|
|
|
afterCreateOrUpdateLine(start: ItemJson, end: ItemJson, type: LinkType, option: RendererCudOption, objects: THREE.Object3D[]) { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 删除线之后的回调 |
|
|
|
|
|
*/ |
|
|
|
|
|
afterDeleteLine(start: ItemJson, end: ItemJson, type: LinkType, option: RendererCudOption, objects: THREE.Object3D[]) { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
fillObjectUserDataFromItem(item: ItemJson, ...objects: THREE.Object3D[]) { |
|
|
fillObjectUserDataFromItem(item: ItemJson, ...objects: THREE.Object3D[]) { |
|
|
_.forEach(objects, (object) => { |
|
|
_.forEach(objects, (object) => { |
|
|
if (!object.name && item.name) { |
|
|
if (!object.name && item.name) { |
|
|
@ -168,6 +191,8 @@ export default abstract class BaseRenderer { |
|
|
|
|
|
|
|
|
this.tempViewport.entityManager.appendLineObject(id, lines) |
|
|
this.tempViewport.entityManager.appendLineObject(id, lines) |
|
|
this.appendToScene(...lines) |
|
|
this.appendToScene(...lines) |
|
|
|
|
|
|
|
|
|
|
|
this.afterCreateOrUpdateLine(start, end, type, option, lines) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -190,6 +215,8 @@ export default abstract class BaseRenderer { |
|
|
geom.setFromPoints([startPoint.position, endPoint.position]) |
|
|
geom.setFromPoints([startPoint.position, endPoint.position]) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
this.afterCreateOrUpdateLine(start, end, type, option, lines) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -198,21 +225,16 @@ export default abstract class BaseRenderer { |
|
|
* @param end 终点 |
|
|
* @param end 终点 |
|
|
* @param option 渲染选项 |
|
|
* @param option 渲染选项 |
|
|
*/ |
|
|
*/ |
|
|
deleteLine(start: ItemJson, end: ItemJson, option?: RendererCudOption) { |
|
|
deleteLine(start: ItemJson, end: ItemJson, type: LinkType, option?: RendererCudOption) { |
|
|
const id = getLineId(start.id, end.id, 'center') |
|
|
const id = getLineId(start.id, end.id, type) |
|
|
const lines = this.tempViewport.entityManager.findLineObjectsById(id) |
|
|
const lines = this.tempViewport.entityManager.findLineObjectsById(id) |
|
|
if (lines) { |
|
|
if (lines) { |
|
|
this.tempViewport.scene.remove(...lines) |
|
|
this.tempViewport.scene.remove(...lines) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.tempViewport.entityManager.deleteLineObjectOnly(id) |
|
|
this.tempViewport.entityManager.deleteLineObjectOnly(id) |
|
|
|
|
|
this.afterDeleteLine(start, end, type, option, lines) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 结束更新 |
|
|
|
|
|
*/ |
|
|
|
|
|
endRendererUpdate(): void { |
|
|
|
|
|
this.tempViewport = undefined |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|