This commit is contained in:
Kurt Hutten
2024-03-26 21:49:05 +11:00
committed by GitHub
parent 39566174e7
commit f52128c41a

View File

@ -1289,40 +1289,14 @@ export class EngineCommandManager {
this.callbacksEngineStateConnection.push(callback) this.callbacksEngineStateConnection.push(callback)
} }
endSession() { endSession() {
// TODO: instead of sending a single command with `object_ids: Object.keys(this.artifactMap)` const deleteCmd: EngineCommand = {
// we need to loop over them each individually because if the engine doesn't recognise a single type: 'modeling_cmd_req',
// id the whole command fails. cmd_id: uuidv4(),
const artifactsToDelete: any = {} cmd: {
Object.entries(this.artifactMap).forEach(([id, artifact]) => { type: 'scene_clear_all',
const artifactTypesToDelete: ArtifactMap[string]['commandType'][] = [ },
// 'start_path' creates a new scene object for the path, which is why it needs to be deleted, }
// however all of the segments in the path are its children so there don't need to be deleted. this.engineConnection?.send(deleteCmd)
// this fact is very opaque in the api and docs (as to what should can be deleted).
// Using an array is the list is likely to grow.
'start_path',
'entity_linear_pattern',
'entity_circular_pattern',
]
if (artifactTypesToDelete.includes(artifact.commandType)) {
artifactsToDelete[id] = artifact
}
if (artifact.commandType === 'import_files') {
// TODO why is this handled differently from other artifacts, i.e. why does it not use the id from the
// modeling command? We're having to do special clean up for this one special object.
artifactsToDelete[(artifact as any)?.data?.data?.object_id] = artifact
}
})
Object.keys(artifactsToDelete).forEach((id) => {
const deleteCmd: EngineCommand = {
type: 'modeling_cmd_req',
cmd_id: uuidv4(),
cmd: {
type: 'remove_scene_objects',
object_ids: [id],
},
}
this.engineConnection?.send(deleteCmd)
})
} }
addCommandLog(message: CommandLog) { addCommandLog(message: CommandLog) {
if (this._commandLogs.length > 500) { if (this._commandLogs.length > 500) {