@fps-games/editor 0.2.0-beta.3 → 0.2.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-bridge/capabilities/editor-state.d.ts.map +1 -1
- package/dist/agent-bridge/capabilities/editor-state.js +26 -17
- package/dist/agent-bridge/capabilities/editor-state.js.map +1 -1
- package/dist/agent-bridge/capabilities/prefabs.d.ts.map +1 -1
- package/dist/agent-bridge/capabilities/prefabs.js +61 -13
- package/dist/agent-bridge/capabilities/prefabs.js.map +1 -1
- package/dist/agent-bridge/capabilities/scene-objects.d.ts +1 -1
- package/dist/agent-bridge/capabilities/scene-objects.d.ts.map +1 -1
- package/dist/agent-bridge/capabilities/scene-objects.js +110 -25
- package/dist/agent-bridge/capabilities/scene-objects.js.map +1 -1
- package/dist/agent-bridge/capabilities/selection.d.ts.map +1 -1
- package/dist/agent-bridge/capabilities/selection.js +8 -5
- package/dist/agent-bridge/capabilities/selection.js.map +1 -1
- package/dist/agent-bridge/capabilities/shadows.d.ts.map +1 -1
- package/dist/agent-bridge/capabilities/shadows.js +11 -2
- package/dist/agent-bridge/capabilities/shadows.js.map +1 -1
- package/dist/agent-bridge/capabilities/transform.d.ts.map +1 -1
- package/dist/agent-bridge/capabilities/transform.js +6 -4
- package/dist/agent-bridge/capabilities/transform.js.map +1 -1
- package/dist/agent-bridge/capabilities/viewport.d.ts.map +1 -1
- package/dist/agent-bridge/capabilities/viewport.js +79 -47
- package/dist/agent-bridge/capabilities/viewport.js.map +1 -1
- package/dist/agent-bridge/shared.d.ts +8 -3
- package/dist/agent-bridge/shared.d.ts.map +1 -1
- package/dist/agent-bridge/shared.js +32 -0
- package/dist/agent-bridge/shared.js.map +1 -1
- package/dist/build-info.json +34 -34
- package/dist/local-editor-agent-actions.d.ts.map +1 -1
- package/dist/local-editor-agent-actions.js +9 -5
- package/dist/local-editor-agent-actions.js.map +1 -1
- package/dist/local-editor-harness.d.ts.map +1 -1
- package/dist/local-editor-harness.js +264 -41
- package/dist/local-editor-harness.js.map +1 -1
- package/node_modules/@fps-games/babylon-renderer/package.json +7 -7
- package/node_modules/@fps-games/editor-babylon/package.json +5 -5
- package/node_modules/@fps-games/editor-browser/dist/index.d.ts +3 -1
- package/node_modules/@fps-games/editor-browser/dist/index.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/index.js +2 -0
- package/node_modules/@fps-games/editor-browser/dist/index.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts +2 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js +260 -94
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-controller.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-projection.d.ts +7 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-projection.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-projection.js +186 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-projection.js.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-scope.d.ts +2 -2
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-scope.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-scope.js +14 -8
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-scope.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.js +23 -7
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-hierarchy-tree.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.d.ts +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.js +6 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-icons.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-input-router.d.ts +3 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-input-router.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-input-router.js +60 -13
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-input-router.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-status-diagnostics.d.ts +24 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-status-diagnostics.d.ts.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-status-diagnostics.js +69 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-status-diagnostics.js.map +1 -0
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts +58 -14
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui-types.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js +196 -11
- package/node_modules/@fps-games/editor-browser/dist/local-editor-ui.js.map +1 -1
- package/node_modules/@fps-games/editor-browser/package.json +4 -4
- package/node_modules/@fps-games/editor-core/dist/editor-session.d.ts +3 -0
- package/node_modules/@fps-games/editor-core/dist/editor-session.d.ts.map +1 -1
- package/node_modules/@fps-games/editor-core/dist/editor-session.js +9 -0
- package/node_modules/@fps-games/editor-core/dist/editor-session.js.map +1 -1
- package/node_modules/@fps-games/editor-core/package.json +6 -6
- package/node_modules/@fps-games/editor-forge-play/package.json +2 -2
- package/node_modules/@fps-games/editor-playable-sdk/package.json +6 -6
- package/node_modules/@fps-games/editor-protocol/package.json +2 -2
- package/node_modules/@fps-games/editor-tooling/package.json +3 -3
- package/node_modules/@fps-games/playable-assets/package.json +1 -1
- package/node_modules/@fps-games/playable-contracts/package.json +1 -1
- package/node_modules/@fps-games/playable-rendering/package.json +2 -2
- package/node_modules/@fps-games/playable-runtime/package.json +12 -12
- package/node_modules/@fps-games/playable-runtime-data/package.json +4 -4
- package/node_modules/@fps-games/playable-scene/package.json +2 -2
- package/node_modules/@fps-games/plugin-api/package.json +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-assets/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-assets/package.json +5 -5
- package/node_modules/@fps-games/plugin-host/package.json +2 -2
- package/node_modules/@fps-games/plugin-markers/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-markers/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-markers/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-markers/package.json +5 -5
- package/node_modules/@fps-games/plugin-materials/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-materials/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-materials/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-materials/package.json +5 -5
- package/node_modules/@fps-games/plugin-rendering/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-rendering/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-rendering/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-rendering/package.json +5 -5
- package/node_modules/@fps-games/plugin-scene/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-scene/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-scene/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-scene/package.json +5 -5
- package/node_modules/@fps-games/plugin-shadows/dist/version.d.ts +1 -1
- package/node_modules/@fps-games/plugin-shadows/dist/version.js +1 -1
- package/node_modules/@fps-games/plugin-shadows/dist/version.js.map +1 -1
- package/node_modules/@fps-games/plugin-shadows/package.json +7 -7
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/agent-bridge/capabilities/transform.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/agent-bridge/capabilities/transform.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAKL,KAAK,gDAAgD,EACrD,KAAK,kCAAkC,EACxC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE/E,wBAAgB,2CAA2C,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EACnF,KAAK,EAAE,kCAAkC,CAAC,SAAS,EAAE,MAAM,CAAC,EAC5D,OAAO,EAAE,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAC7D,QAAQ,EAAE,MAAM,IAAI,EACpB,UAAU,EAAE,gDAAgD,CAAC,SAAS,CAAC,GACtE,qCAAqC,CASvC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isEditorTransformTrsSnapshot, } from '@fps-games/editor-core';
|
|
2
2
|
import { EDITOR_AGENT_BRIDGE_CAPABILITY_ID, } from '@fps-games/editor-protocol';
|
|
3
3
|
import { cloneVec3, createLocalEditorAgentBridgeFailure, editorTransformSnapshotToAgentTransform, isLocalEditorAgentBridgeVec3, } from '../diagnostics.js';
|
|
4
|
-
import { cloneAgentBridgeSelection, isAgentBridgeDocumentNodeSelectable, } from '../shared.js';
|
|
4
|
+
import { cloneAgentBridgeSelection, getAgentBridgeSafeSceneSelection, isAgentBridgeDocumentNodeSelectable, isAgentBridgeSafeSceneObjectId, } from '../shared.js';
|
|
5
5
|
export function createLocalEditorAgentBridgeTransformSource(state, options, renderUi, operations) {
|
|
6
6
|
return {
|
|
7
7
|
move(input) {
|
|
@@ -31,7 +31,8 @@ function moveAgentBridgeObject(state, options, input, renderUi, operations) {
|
|
|
31
31
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE, 'Editor is not in edit mode.', { code: 'editor.notReady', objectId });
|
|
32
32
|
}
|
|
33
33
|
const document = state.session.getState({ cloneDocuments: false }).workingDocument;
|
|
34
|
-
if (!
|
|
34
|
+
if (!isAgentBridgeSafeSceneObjectId(operations, objectId)
|
|
35
|
+
|| !isAgentBridgeDocumentNodeSelectable(options, document, objectId)) {
|
|
35
36
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE, `Object is not movable: ${objectId}`, { code: 'transform.notSelectable', objectId });
|
|
36
37
|
}
|
|
37
38
|
const before = state.projection?.readNodeTransform(objectId) ?? null;
|
|
@@ -75,7 +76,8 @@ function setAgentBridgeObjectTransform(state, options, input, renderUi, operatio
|
|
|
75
76
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET, 'Editor is not in edit mode.', { code: 'editor.notReady', objectId });
|
|
76
77
|
}
|
|
77
78
|
const document = state.session.getState({ cloneDocuments: false }).workingDocument;
|
|
78
|
-
if (!
|
|
79
|
+
if (!isAgentBridgeSafeSceneObjectId(operations, objectId)
|
|
80
|
+
|| !isAgentBridgeDocumentNodeSelectable(options, document, objectId)) {
|
|
79
81
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET, `Object is not transformable: ${objectId}`, { code: 'transform.notSelectable', objectId });
|
|
80
82
|
}
|
|
81
83
|
const before = state.projection?.readNodeTransform(objectId) ?? null;
|
|
@@ -149,7 +151,7 @@ function dispatchAgentBridgeTransformPatch(state, options, input, renderUi, oper
|
|
|
149
151
|
objectId,
|
|
150
152
|
before: editorTransformSnapshotToAgentTransform(before) ?? {},
|
|
151
153
|
after: editorTransformSnapshotToAgentTransform(updated) ?? {},
|
|
152
|
-
selection: cloneAgentBridgeSelection(
|
|
154
|
+
selection: cloneAgentBridgeSelection(getAgentBridgeSafeSceneSelection(operations)),
|
|
153
155
|
};
|
|
154
156
|
}
|
|
155
157
|
function addAgentBridgeVec3(left, right) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/agent-bridge/capabilities/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iCAAiC,GAGlC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,SAAS,EACT,mCAAmC,EACnC,uCAAuC,EACvC,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,yBAAyB,EACzB,mCAAmC,GAGpC,MAAM,cAAc,CAAC;AAGtB,MAAM,UAAU,2CAA2C,CACzD,KAA4D,EAC5D,OAA6D,EAC7D,QAAoB,EACpB,UAAuE;IAEvE,OAAO;QACL,IAAI,CAAC,KAAK;YACR,OAAO,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC5E,CAAC;QACD,GAAG,CAAC,KAAK;YACP,OAAO,6BAA6B,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QACpF,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAC5B,KAA4D,EAC5D,OAA6D,EAC7D,KAAkE,EA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nF,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QACnB,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QACnB,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import {\n type EditorTransformSnapshot,\n type EditorTransformTool,\n isEditorTransformTrsSnapshot,\n} from '@fps-games/editor-core';\nimport {\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID,\n type EditorAgentBridgeTransformMoveOutput,\n type EditorAgentBridgeVec3,\n} from '@fps-games/editor-protocol';\nimport {\n cloneVec3,\n createLocalEditorAgentBridgeFailure,\n editorTransformSnapshotToAgentTransform,\n isLocalEditorAgentBridgeVec3,\n} from '../diagnostics.js';\nimport type { LocalEditorAgentBridgeTransformSource } from '../source-types.js';\nimport {\n cloneAgentBridgeSelection,\n isAgentBridgeDocumentNodeSelectable,\n type LocalEditorAgentBridgeCapabilitySourceOperations,\n type LocalEditorAgentBridgeHarnessState,\n} from '../shared.js';\nimport type { LocalEditorHarnessOptions } from '../../local-editor-harness.js';\n\nexport function createLocalEditorAgentBridgeTransformSource<TDocument, TPatch, TAsset>(\n state: LocalEditorAgentBridgeHarnessState<TDocument, TPatch>,\n options: LocalEditorHarnessOptions<TDocument, TPatch, TAsset>,\n renderUi: () => void,\n operations: LocalEditorAgentBridgeCapabilitySourceOperations<TDocument>,\n): LocalEditorAgentBridgeTransformSource {\n return {\n move(input) {\n return moveAgentBridgeObject(state, options, input, renderUi, operations);\n },\n set(input) {\n return setAgentBridgeObjectTransform(state, options, input, renderUi, operations);\n },\n };\n}\n\nfunction moveAgentBridgeObject<TDocument, TPatch, TAsset>(\n state: LocalEditorAgentBridgeHarnessState<TDocument, TPatch>,\n options: LocalEditorHarnessOptions<TDocument, TPatch, TAsset>,\n input: { objectId?: string; position?: unknown; offset?: unknown },\n renderUi: () => void,\n operations: LocalEditorAgentBridgeCapabilitySourceOperations<TDocument>,\n): ReturnType<LocalEditorAgentBridgeTransformSource['move']> {\n const objectId = typeof input?.objectId === 'string' ? input.objectId.trim() : '';\n if (!objectId) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n 'transform.move requires objectId.',\n { code: 'transform.invalidInput' },\n );\n }\n const hasPosition = input.position !== undefined;\n const hasOffset = input.offset !== undefined;\n if (hasPosition === hasOffset) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n 'transform.move requires exactly one of position or offset.',\n { code: 'transform.invalidInput', objectId },\n );\n }\n const movePosition = hasPosition && isLocalEditorAgentBridgeVec3(input.position) ? input.position : null;\n const moveOffset = hasOffset && isLocalEditorAgentBridgeVec3(input.offset) ? input.offset : null;\n if ((hasPosition && !movePosition) || (hasOffset && !moveOffset)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n 'transform.move position or offset must be a finite Vec3.',\n { code: 'transform.invalidVec3', objectId },\n );\n }\n if (state.mode !== 'editor' || !state.session) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n 'Editor is not in edit mode.',\n { code: 'editor.notReady', objectId },\n );\n }\n const document = state.session.getState({ cloneDocuments: false }).workingDocument;\n if (!isAgentBridgeDocumentNodeSelectable(options, document, objectId)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n `Object is not movable: ${objectId}`,\n { code: 'transform.notSelectable', objectId },\n );\n }\n const before = state.projection?.readNodeTransform(objectId) ?? null;\n if (!before || !isEditorTransformTrsSnapshot(before)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n `Object does not have an editable TRS transform: ${objectId}`,\n { code: 'transform.unsupported', objectId },\n );\n }\n const after = operations.cloneTransformSnapshot(before);\n if (!isEditorTransformTrsSnapshot(after)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n `Object does not have an editable TRS transform: ${objectId}`,\n { code: 'transform.unsupported', objectId },\n );\n }\n after.position = movePosition\n ? cloneVec3(movePosition)\n : addAgentBridgeVec3(after.position, moveOffset!);\n return dispatchAgentBridgeTransformPatch(\n state,\n options,\n {\n capabilityId: EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n objectId,\n before,\n after,\n tool: 'move',\n label: `Agent move ${objectId}`,\n },\n renderUi,\n operations,\n );\n}\n\nfunction setAgentBridgeObjectTransform<TDocument, TPatch, TAsset>(\n state: LocalEditorAgentBridgeHarnessState<TDocument, TPatch>,\n options: LocalEditorHarnessOptions<TDocument, TPatch, TAsset>,\n input: { objectId?: string; position?: unknown; rotation?: unknown; scale?: unknown },\n renderUi: () => void,\n operations: LocalEditorAgentBridgeCapabilitySourceOperations<TDocument>,\n): ReturnType<LocalEditorAgentBridgeTransformSource['set']> {\n const objectId = typeof input?.objectId === 'string' ? input.objectId.trim() : '';\n if (!objectId) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n 'transform.set requires objectId.',\n { code: 'transform.invalidInput' },\n );\n }\n const hasPosition = input.position !== undefined;\n const hasRotation = input.rotation !== undefined;\n const hasScale = input.scale !== undefined;\n if (!hasPosition && !hasRotation && !hasScale) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n 'transform.set requires at least one of position, rotation, or scale.',\n { code: 'transform.invalidInput', objectId },\n );\n }\n const position = hasPosition && isLocalEditorAgentBridgeVec3(input.position) ? input.position : null;\n const rotation = hasRotation && isLocalEditorAgentBridgeVec3(input.rotation) ? input.rotation : null;\n const scale = hasScale && isLocalEditorAgentBridgeVec3(input.scale) ? input.scale : null;\n if ((hasPosition && !position) || (hasRotation && !rotation) || (hasScale && !scale)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n 'transform.set position, rotation, and scale must be finite Vec3 values when provided.',\n { code: 'transform.invalidVec3', objectId },\n );\n }\n if (state.mode !== 'editor' || !state.session) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n 'Editor is not in edit mode.',\n { code: 'editor.notReady', objectId },\n );\n }\n const document = state.session.getState({ cloneDocuments: false }).workingDocument;\n if (!isAgentBridgeDocumentNodeSelectable(options, document, objectId)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n `Object is not transformable: ${objectId}`,\n { code: 'transform.notSelectable', objectId },\n );\n }\n const before = state.projection?.readNodeTransform(objectId) ?? null;\n if (!before || !isEditorTransformTrsSnapshot(before)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n `Object does not have an editable TRS transform: ${objectId}`,\n { code: 'transform.unsupported', objectId },\n );\n }\n const after = operations.cloneTransformSnapshot(before);\n if (!isEditorTransformTrsSnapshot(after)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n `Object does not have an editable TRS transform: ${objectId}`,\n { code: 'transform.unsupported', objectId },\n );\n }\n if (position) after.position = cloneVec3(position);\n if (rotation) after.rotation = cloneVec3(rotation);\n if (scale) after.scale = cloneVec3(scale);\n return dispatchAgentBridgeTransformPatch(\n state,\n options,\n {\n capabilityId: EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n objectId,\n before,\n after,\n tool: position ? 'move' : rotation ? 'rotate' : 'scale',\n label: `Agent set transform ${objectId}`,\n },\n renderUi,\n operations,\n );\n}\n\nfunction dispatchAgentBridgeTransformPatch<TDocument, TPatch, TAsset>(\n state: LocalEditorAgentBridgeHarnessState<TDocument, TPatch>,\n options: LocalEditorHarnessOptions<TDocument, TPatch, TAsset>,\n input: {\n capabilityId: string;\n objectId: string;\n before: EditorTransformSnapshot;\n after: EditorTransformSnapshot;\n tool: Exclude<EditorTransformTool, 'select'>;\n label: string;\n },\n renderUi: () => void,\n operations: LocalEditorAgentBridgeCapabilitySourceOperations<TDocument>,\n): EditorAgentBridgeTransformMoveOutput | ReturnType<typeof createLocalEditorAgentBridgeFailure> {\n const { capabilityId, objectId, before, after, tool, label } = input;\n if (state.mode !== 'editor' || !state.session) {\n return createLocalEditorAgentBridgeFailure(\n capabilityId,\n 'Editor is not in edit mode.',\n { code: 'editor.notReady', objectId },\n );\n }\n const document = state.session.getState({ cloneDocuments: false }).workingDocument;\n const patch = options.documentAdapter.createTransformPatch?.({\n document,\n targetId: objectId,\n tool,\n space: 'world',\n constraint: 'free',\n before,\n after,\n });\n if (!patch) {\n return createLocalEditorAgentBridgeFailure(\n capabilityId,\n `Transform patch was not created for object: ${objectId}`,\n { code: 'transform.patchUnavailable', objectId },\n );\n }\n const result = state.session.dispatch({\n type: 'document.patch',\n label: patch.label ?? `Agent move ${objectId}`,\n patch: patch.patch,\n targetId: objectId,\n ...operations.withProjectionImpact(operations.resolveProjectionImpact(\n patch,\n patch.reprojectIds?.length\n ? operations.createReprojectProjectionImpact(patch.reprojectIds)\n : operations.createTransformProjectionImpact([patch.changedId ?? objectId]),\n )),\n });\n if (!result.documentChanged) {\n return createLocalEditorAgentBridgeFailure(\n capabilityId,\n `Transform was unchanged for object: ${objectId}`,\n { code: 'transform.unchanged', objectId },\n );\n }\n if (patch.reprojectIds?.length) operations.reprojectProjectionForChangedIds(result.workingDocument, patch.reprojectIds);\n else operations.syncProjectionForChangedIds(result.workingDocument, [patch.changedId ?? objectId]);\n state.summary = operations.summarizeDocument(result.workingDocument, state.session.getSource());\n state.status = patch.label ?? label;\n operations.dispatchSelectionCommand({\n type: 'selection.replace',\n selectedIds: [objectId],\n activeId: objectId,\n label,\n });\n renderUi();\n const updated = state.projection?.readNodeTransform(objectId) ?? after;\n return {\n objectId,\n before: editorTransformSnapshotToAgentTransform(before) ?? {},\n after: editorTransformSnapshotToAgentTransform(updated) ?? {},\n selection: cloneAgentBridgeSelection(state.session.getState({ cloneDocuments: false }).selection),\n } satisfies EditorAgentBridgeTransformMoveOutput;\n}\n\nfunction addAgentBridgeVec3(left: EditorAgentBridgeVec3, right: EditorAgentBridgeVec3): EditorAgentBridgeVec3 {\n return {\n x: left.x + right.x,\n y: left.y + right.y,\n z: left.z + right.z,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/agent-bridge/capabilities/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iCAAiC,GAGlC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,SAAS,EACT,mCAAmC,EACnC,uCAAuC,EACvC,4BAA4B,GAC7B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,mCAAmC,EACnC,8BAA8B,GAG/B,MAAM,cAAc,CAAC;AAGtB,MAAM,UAAU,2CAA2C,CACzD,KAA4D,EAC5D,OAA6D,EAC7D,QAAoB,EACpB,UAAuE;IAEvE,OAAO;QACL,IAAI,CAAC,KAAK;YACR,OAAO,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC5E,CAAC;QACD,GAAG,CAAC,KAAK;YACP,OAAO,6BAA6B,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UA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AO,CAAC,IAAI,EAAE;QAC7D,SAAS,EAAE,yBAAyB,CAAC,gCAAgC,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC;AACnD,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA2B,EAAE,KAA4B;IACnF,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QACnB,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QACnB,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import {\n type EditorTransformSnapshot,\n type EditorTransformTool,\n isEditorTransformTrsSnapshot,\n} from '@fps-games/editor-core';\nimport {\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID,\n type EditorAgentBridgeTransformMoveOutput,\n type EditorAgentBridgeVec3,\n} from '@fps-games/editor-protocol';\nimport {\n cloneVec3,\n createLocalEditorAgentBridgeFailure,\n editorTransformSnapshotToAgentTransform,\n isLocalEditorAgentBridgeVec3,\n} from '../diagnostics.js';\nimport type { LocalEditorAgentBridgeTransformSource } from '../source-types.js';\nimport {\n cloneAgentBridgeSelection,\n getAgentBridgeSafeSceneSelection,\n isAgentBridgeDocumentNodeSelectable,\n isAgentBridgeSafeSceneObjectId,\n type LocalEditorAgentBridgeCapabilitySourceOperations,\n type LocalEditorAgentBridgeHarnessState,\n} from '../shared.js';\nimport type { LocalEditorHarnessOptions } from '../../local-editor-harness.js';\n\nexport function createLocalEditorAgentBridgeTransformSource<TDocument, TPatch, TAsset>(\n state: LocalEditorAgentBridgeHarnessState<TDocument, TPatch>,\n options: LocalEditorHarnessOptions<TDocument, TPatch, TAsset>,\n renderUi: () => void,\n operations: LocalEditorAgentBridgeCapabilitySourceOperations<TDocument>,\n): LocalEditorAgentBridgeTransformSource {\n return {\n move(input) {\n return moveAgentBridgeObject(state, options, input, renderUi, operations);\n },\n set(input) {\n return setAgentBridgeObjectTransform(state, options, input, renderUi, operations);\n },\n };\n}\n\nfunction moveAgentBridgeObject<TDocument, TPatch, TAsset>(\n state: LocalEditorAgentBridgeHarnessState<TDocument, TPatch>,\n options: LocalEditorHarnessOptions<TDocument, TPatch, TAsset>,\n input: { objectId?: string; position?: unknown; offset?: unknown },\n renderUi: () => void,\n operations: LocalEditorAgentBridgeCapabilitySourceOperations<TDocument>,\n): ReturnType<LocalEditorAgentBridgeTransformSource['move']> {\n const objectId = typeof input?.objectId === 'string' ? input.objectId.trim() : '';\n if (!objectId) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n 'transform.move requires objectId.',\n { code: 'transform.invalidInput' },\n );\n }\n const hasPosition = input.position !== undefined;\n const hasOffset = input.offset !== undefined;\n if (hasPosition === hasOffset) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n 'transform.move requires exactly one of position or offset.',\n { code: 'transform.invalidInput', objectId },\n );\n }\n const movePosition = hasPosition && isLocalEditorAgentBridgeVec3(input.position) ? input.position : null;\n const moveOffset = hasOffset && isLocalEditorAgentBridgeVec3(input.offset) ? input.offset : null;\n if ((hasPosition && !movePosition) || (hasOffset && !moveOffset)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n 'transform.move position or offset must be a finite Vec3.',\n { code: 'transform.invalidVec3', objectId },\n );\n }\n if (state.mode !== 'editor' || !state.session) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n 'Editor is not in edit mode.',\n { code: 'editor.notReady', objectId },\n );\n }\n const document = state.session.getState({ cloneDocuments: false }).workingDocument;\n if (!isAgentBridgeSafeSceneObjectId(operations, objectId)\n || !isAgentBridgeDocumentNodeSelectable(options, document, objectId)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n `Object is not movable: ${objectId}`,\n { code: 'transform.notSelectable', objectId },\n );\n }\n const before = state.projection?.readNodeTransform(objectId) ?? null;\n if (!before || !isEditorTransformTrsSnapshot(before)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n `Object does not have an editable TRS transform: ${objectId}`,\n { code: 'transform.unsupported', objectId },\n );\n }\n const after = operations.cloneTransformSnapshot(before);\n if (!isEditorTransformTrsSnapshot(after)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n `Object does not have an editable TRS transform: ${objectId}`,\n { code: 'transform.unsupported', objectId },\n );\n }\n after.position = movePosition\n ? cloneVec3(movePosition)\n : addAgentBridgeVec3(after.position, moveOffset!);\n return dispatchAgentBridgeTransformPatch(\n state,\n options,\n {\n capabilityId: EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_MOVE,\n objectId,\n before,\n after,\n tool: 'move',\n label: `Agent move ${objectId}`,\n },\n renderUi,\n operations,\n );\n}\n\nfunction setAgentBridgeObjectTransform<TDocument, TPatch, TAsset>(\n state: LocalEditorAgentBridgeHarnessState<TDocument, TPatch>,\n options: LocalEditorHarnessOptions<TDocument, TPatch, TAsset>,\n input: { objectId?: string; position?: unknown; rotation?: unknown; scale?: unknown },\n renderUi: () => void,\n operations: LocalEditorAgentBridgeCapabilitySourceOperations<TDocument>,\n): ReturnType<LocalEditorAgentBridgeTransformSource['set']> {\n const objectId = typeof input?.objectId === 'string' ? input.objectId.trim() : '';\n if (!objectId) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n 'transform.set requires objectId.',\n { code: 'transform.invalidInput' },\n );\n }\n const hasPosition = input.position !== undefined;\n const hasRotation = input.rotation !== undefined;\n const hasScale = input.scale !== undefined;\n if (!hasPosition && !hasRotation && !hasScale) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n 'transform.set requires at least one of position, rotation, or scale.',\n { code: 'transform.invalidInput', objectId },\n );\n }\n const position = hasPosition && isLocalEditorAgentBridgeVec3(input.position) ? input.position : null;\n const rotation = hasRotation && isLocalEditorAgentBridgeVec3(input.rotation) ? input.rotation : null;\n const scale = hasScale && isLocalEditorAgentBridgeVec3(input.scale) ? input.scale : null;\n if ((hasPosition && !position) || (hasRotation && !rotation) || (hasScale && !scale)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n 'transform.set position, rotation, and scale must be finite Vec3 values when provided.',\n { code: 'transform.invalidVec3', objectId },\n );\n }\n if (state.mode !== 'editor' || !state.session) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n 'Editor is not in edit mode.',\n { code: 'editor.notReady', objectId },\n );\n }\n const document = state.session.getState({ cloneDocuments: false }).workingDocument;\n if (!isAgentBridgeSafeSceneObjectId(operations, objectId)\n || !isAgentBridgeDocumentNodeSelectable(options, document, objectId)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n `Object is not transformable: ${objectId}`,\n { code: 'transform.notSelectable', objectId },\n );\n }\n const before = state.projection?.readNodeTransform(objectId) ?? null;\n if (!before || !isEditorTransformTrsSnapshot(before)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n `Object does not have an editable TRS transform: ${objectId}`,\n { code: 'transform.unsupported', objectId },\n );\n }\n const after = operations.cloneTransformSnapshot(before);\n if (!isEditorTransformTrsSnapshot(after)) {\n return createLocalEditorAgentBridgeFailure(\n EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n `Object does not have an editable TRS transform: ${objectId}`,\n { code: 'transform.unsupported', objectId },\n );\n }\n if (position) after.position = cloneVec3(position);\n if (rotation) after.rotation = cloneVec3(rotation);\n if (scale) after.scale = cloneVec3(scale);\n return dispatchAgentBridgeTransformPatch(\n state,\n options,\n {\n capabilityId: EDITOR_AGENT_BRIDGE_CAPABILITY_ID.TRANSFORM_SET,\n objectId,\n before,\n after,\n tool: position ? 'move' : rotation ? 'rotate' : 'scale',\n label: `Agent set transform ${objectId}`,\n },\n renderUi,\n operations,\n );\n}\n\nfunction dispatchAgentBridgeTransformPatch<TDocument, TPatch, TAsset>(\n state: LocalEditorAgentBridgeHarnessState<TDocument, TPatch>,\n options: LocalEditorHarnessOptions<TDocument, TPatch, TAsset>,\n input: {\n capabilityId: string;\n objectId: string;\n before: EditorTransformSnapshot;\n after: EditorTransformSnapshot;\n tool: Exclude<EditorTransformTool, 'select'>;\n label: string;\n },\n renderUi: () => void,\n operations: LocalEditorAgentBridgeCapabilitySourceOperations<TDocument>,\n): EditorAgentBridgeTransformMoveOutput | ReturnType<typeof createLocalEditorAgentBridgeFailure> {\n const { capabilityId, objectId, before, after, tool, label } = input;\n if (state.mode !== 'editor' || !state.session) {\n return createLocalEditorAgentBridgeFailure(\n capabilityId,\n 'Editor is not in edit mode.',\n { code: 'editor.notReady', objectId },\n );\n }\n const document = state.session.getState({ cloneDocuments: false }).workingDocument;\n const patch = options.documentAdapter.createTransformPatch?.({\n document,\n targetId: objectId,\n tool,\n space: 'world',\n constraint: 'free',\n before,\n after,\n });\n if (!patch) {\n return createLocalEditorAgentBridgeFailure(\n capabilityId,\n `Transform patch was not created for object: ${objectId}`,\n { code: 'transform.patchUnavailable', objectId },\n );\n }\n const result = state.session.dispatch({\n type: 'document.patch',\n label: patch.label ?? `Agent move ${objectId}`,\n patch: patch.patch,\n targetId: objectId,\n ...operations.withProjectionImpact(operations.resolveProjectionImpact(\n patch,\n patch.reprojectIds?.length\n ? operations.createReprojectProjectionImpact(patch.reprojectIds)\n : operations.createTransformProjectionImpact([patch.changedId ?? objectId]),\n )),\n });\n if (!result.documentChanged) {\n return createLocalEditorAgentBridgeFailure(\n capabilityId,\n `Transform was unchanged for object: ${objectId}`,\n { code: 'transform.unchanged', objectId },\n );\n }\n if (patch.reprojectIds?.length) operations.reprojectProjectionForChangedIds(result.workingDocument, patch.reprojectIds);\n else operations.syncProjectionForChangedIds(result.workingDocument, [patch.changedId ?? objectId]);\n state.summary = operations.summarizeDocument(result.workingDocument, state.session.getSource());\n state.status = patch.label ?? label;\n operations.dispatchSelectionCommand({\n type: 'selection.replace',\n selectedIds: [objectId],\n activeId: objectId,\n label,\n });\n renderUi();\n const updated = state.projection?.readNodeTransform(objectId) ?? after;\n return {\n objectId,\n before: editorTransformSnapshotToAgentTransform(before) ?? {},\n after: editorTransformSnapshotToAgentTransform(updated) ?? {},\n selection: cloneAgentBridgeSelection(getAgentBridgeSafeSceneSelection(operations)),\n } satisfies EditorAgentBridgeTransformMoveOutput;\n}\n\nfunction addAgentBridgeVec3(left: EditorAgentBridgeVec3, right: EditorAgentBridgeVec3): EditorAgentBridgeVec3 {\n return {\n x: left.x + right.x,\n y: left.y + right.y,\n z: left.z + right.z,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/agent-bridge/capabilities/viewport.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/agent-bridge/capabilities/viewport.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EASL,KAAK,gDAAgD,EACrD,KAAK,kCAAkC,EACxC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE/E,wBAAgB,0CAA0C,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAClF,KAAK,EAAE,kCAAkC,CAAC,SAAS,EAAE,MAAM,CAAC,EAC5D,OAAO,EAAE,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAC7D,QAAQ,EAAE,MAAM,IAAI,EACpB,UAAU,EAAE,gDAAgD,CAAC,SAAS,CAAC,GACtE,oCAAoC,CAqFtC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EDITOR_AGENT_BRIDGE_CAPABILITY_ID, } from '@fps-games/editor-protocol';
|
|
2
2
|
import { cloneVec3, createLocalEditorAgentBridgeFailure, isLocalEditorAgentBridgeVec3, } from '../diagnostics.js';
|
|
3
|
-
import { cloneAgentBridgeSelection,
|
|
3
|
+
import { cloneAgentBridgeSelection, getAgentBridgeSafeSceneHierarchy, getAgentBridgeSafeSceneSelection, hasAgentBridgeSafeSceneScope, isAgentBridgeHierarchyObjectSelectable, normalizeAgentBridgeIdList, normalizeAgentBridgeString, } from '../shared.js';
|
|
4
4
|
export function createLocalEditorAgentBridgeViewportSource(state, options, renderUi, operations) {
|
|
5
5
|
return {
|
|
6
6
|
focusObject(input) {
|
|
@@ -8,20 +8,28 @@ export function createLocalEditorAgentBridgeViewportSource(state, options, rende
|
|
|
8
8
|
if (!objectId) {
|
|
9
9
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_FOCUS_OBJECT, 'viewport.focusObject requires objectId.', { code: 'viewport.invalidInput' });
|
|
10
10
|
}
|
|
11
|
+
const document = state.session?.getState({ cloneDocuments: false }).workingDocument ?? null;
|
|
12
|
+
const hierarchy = document ? getAgentBridgeSafeSceneHierarchy(operations) : [];
|
|
13
|
+
if (!document || !isAgentBridgeHierarchyObjectSelectable(options, document, objectId, hierarchy)) {
|
|
14
|
+
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_FOCUS_OBJECT, `Viewport object was not found: ${objectId}`, { code: 'viewport.targetNotFound', objectId });
|
|
15
|
+
}
|
|
11
16
|
const focused = operations.focusProjectionNode(objectId);
|
|
12
17
|
renderUi();
|
|
13
18
|
return { objectId, focused };
|
|
14
19
|
},
|
|
15
20
|
frameSelection() {
|
|
16
|
-
const
|
|
21
|
+
const selection = getAgentBridgeSafeSceneSelection(operations);
|
|
22
|
+
const focused = hasAgentBridgeSafeSceneScope(operations) && selection.activeId
|
|
23
|
+
? operations.focusProjectionNode(selection.activeId)
|
|
24
|
+
: false;
|
|
17
25
|
renderUi();
|
|
18
26
|
return {
|
|
19
27
|
focused,
|
|
20
|
-
selection: cloneAgentBridgeSelection(
|
|
28
|
+
selection: cloneAgentBridgeSelection(selection),
|
|
21
29
|
};
|
|
22
30
|
},
|
|
23
31
|
getCamera() {
|
|
24
|
-
return createAgentBridgeViewportCameraState(state);
|
|
32
|
+
return createAgentBridgeViewportCameraState(state, operations);
|
|
25
33
|
},
|
|
26
34
|
setCameraPreset(input) {
|
|
27
35
|
return setAgentBridgeViewportCameraPreset(state, options, input, renderUi, operations);
|
|
@@ -30,10 +38,10 @@ export function createLocalEditorAgentBridgeViewportSource(state, options, rende
|
|
|
30
38
|
return orbitAgentBridgeViewportCamera(state, options, input, renderUi, operations);
|
|
31
39
|
},
|
|
32
40
|
getVisibilitySnapshot() {
|
|
33
|
-
return createAgentBridgeViewportVisibilitySnapshot(state);
|
|
41
|
+
return createAgentBridgeViewportVisibilitySnapshot(state, operations);
|
|
34
42
|
},
|
|
35
43
|
setVisibility(input) {
|
|
36
|
-
const result = setAgentBridgeViewportVisibility(state, input);
|
|
44
|
+
const result = setAgentBridgeViewportVisibility(state, options, input, operations);
|
|
37
45
|
if ('ok' in result && result.ok === false)
|
|
38
46
|
return result;
|
|
39
47
|
operations.requestSceneFrame('agent-viewport-visibility-set');
|
|
@@ -41,6 +49,9 @@ export function createLocalEditorAgentBridgeViewportSource(state, options, rende
|
|
|
41
49
|
return result;
|
|
42
50
|
},
|
|
43
51
|
clearVisibility() {
|
|
52
|
+
if (!hasAgentBridgeSafeSceneScope(operations)) {
|
|
53
|
+
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_VISIBILITY_CLEAR, 'Scene viewport visibility is unavailable outside the Scene Hierarchy scope.', { code: 'viewport.sceneScopeRequired' });
|
|
54
|
+
}
|
|
44
55
|
const previousCount = Object.keys(state.previewVisibility.overrides).length;
|
|
45
56
|
const wasIsolated = state.previewVisibility.isolatedObjectIds.length > 0;
|
|
46
57
|
state.previewVisibility.overrides = {};
|
|
@@ -53,11 +64,11 @@ export function createLocalEditorAgentBridgeViewportSource(state, options, rende
|
|
|
53
64
|
renderUi();
|
|
54
65
|
return {
|
|
55
66
|
changed: previousCount > 0 || wasIsolated,
|
|
56
|
-
snapshot: createAgentBridgeViewportVisibilitySnapshot(state),
|
|
67
|
+
snapshot: createAgentBridgeViewportVisibilitySnapshot(state, operations),
|
|
57
68
|
};
|
|
58
69
|
},
|
|
59
70
|
enterIsolation(input) {
|
|
60
|
-
const result = enterAgentBridgeViewportIsolation(state, input);
|
|
71
|
+
const result = enterAgentBridgeViewportIsolation(state, options, input, operations);
|
|
61
72
|
if ('ok' in result && result.ok === false)
|
|
62
73
|
return result;
|
|
63
74
|
operations.requestSceneFrame('agent-viewport-isolation-enter');
|
|
@@ -66,7 +77,7 @@ export function createLocalEditorAgentBridgeViewportSource(state, options, rende
|
|
|
66
77
|
},
|
|
67
78
|
};
|
|
68
79
|
}
|
|
69
|
-
function setAgentBridgeViewportVisibility(state, input) {
|
|
80
|
+
function setAgentBridgeViewportVisibility(state, options, input, operations) {
|
|
70
81
|
const ids = normalizeAgentBridgeIdList(Array.isArray(input.objectIds) ? input.objectIds : []);
|
|
71
82
|
if (ids.length === 0) {
|
|
72
83
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_VISIBILITY_SET, 'viewport.visibility.set requires at least one objectId.', { code: 'viewport.visibility.invalidInput' });
|
|
@@ -74,8 +85,15 @@ function setAgentBridgeViewportVisibility(state, input) {
|
|
|
74
85
|
if (typeof input.visible !== 'boolean') {
|
|
75
86
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_VISIBILITY_SET, 'viewport.visibility.set requires visible to be boolean.', { code: 'viewport.visibility.invalidInput' });
|
|
76
87
|
}
|
|
88
|
+
const document = state.session?.getState({ cloneDocuments: false }).workingDocument ?? null;
|
|
89
|
+
const hierarchy = document ? getAgentBridgeSafeSceneHierarchy(operations) : [];
|
|
90
|
+
const invalidId = ids.find(id => !document || !isAgentBridgeHierarchyObjectSelectable(options, document, id, hierarchy));
|
|
91
|
+
if (invalidId) {
|
|
92
|
+
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_VISIBILITY_SET, `Viewport object was not found: ${invalidId}`, { code: 'viewport.targetNotFound', objectId: invalidId });
|
|
93
|
+
}
|
|
77
94
|
const previous = JSON.stringify(state.previewVisibility.overrides);
|
|
78
|
-
const
|
|
95
|
+
const safeIds = new Set(hierarchy.map(item => item.id));
|
|
96
|
+
const nextOverrides = Object.fromEntries(Object.entries(state.previewVisibility.overrides).filter(([id]) => safeIds.has(id)));
|
|
79
97
|
const protectedIds = new Set([
|
|
80
98
|
...(state.previewVisibility.protectedObjectIds ?? []),
|
|
81
99
|
...(state.previewVisibility.protectedReceiverIds ?? []),
|
|
@@ -93,9 +111,12 @@ function setAgentBridgeViewportVisibility(state, input) {
|
|
|
93
111
|
if (blockedIds.length === 0) {
|
|
94
112
|
state.previewVisibility.isolatedObjectIds = [];
|
|
95
113
|
}
|
|
114
|
+
else {
|
|
115
|
+
state.previewVisibility.isolatedObjectIds = state.previewVisibility.isolatedObjectIds.filter(id => safeIds.has(id));
|
|
116
|
+
}
|
|
96
117
|
state.previewVisibility.reason = normalizeAgentBridgeString(input.reason) || undefined;
|
|
97
|
-
|
|
98
|
-
const entries = state.projection?.setPreviewVisibilityOverrides?.(
|
|
118
|
+
state.projection?.clearPreviewVisibilityOverrides?.();
|
|
119
|
+
const entries = state.projection?.setPreviewVisibilityOverrides?.(nextOverrides) ?? [];
|
|
99
120
|
const diagnostics = blockedIds.length > 0
|
|
100
121
|
? [{
|
|
101
122
|
code: 'shadow.receiverProtectedInDebugContext',
|
|
@@ -107,23 +128,30 @@ function setAgentBridgeViewportVisibility(state, input) {
|
|
|
107
128
|
: undefined;
|
|
108
129
|
return {
|
|
109
130
|
changed: previous !== JSON.stringify(state.previewVisibility.overrides),
|
|
110
|
-
snapshot: createAgentBridgeViewportVisibilitySnapshot(state, entries, diagnostics),
|
|
131
|
+
snapshot: createAgentBridgeViewportVisibilitySnapshot(state, operations, entries, diagnostics),
|
|
111
132
|
...(diagnostics ? { diagnostics } : {}),
|
|
112
133
|
};
|
|
113
134
|
}
|
|
114
|
-
function enterAgentBridgeViewportIsolation(state, input) {
|
|
135
|
+
function enterAgentBridgeViewportIsolation(state, options, input, operations) {
|
|
115
136
|
const targetIds = normalizeAgentBridgeIdList(Array.isArray(input.objectIds) ? input.objectIds : []);
|
|
116
137
|
if (targetIds.length === 0) {
|
|
117
138
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_ISOLATION_ENTER, 'viewport.isolation.enter requires at least one objectId.', { code: 'viewport.isolation.invalidInput' });
|
|
118
139
|
}
|
|
119
|
-
const
|
|
140
|
+
const document = state.session?.getState({ cloneDocuments: false }).workingDocument ?? null;
|
|
141
|
+
const hierarchy = document ? getAgentBridgeSafeSceneHierarchy(operations) : [];
|
|
142
|
+
const invalidId = targetIds.find(id => !document || !isAgentBridgeHierarchyObjectSelectable(options, document, id, hierarchy));
|
|
143
|
+
if (invalidId) {
|
|
144
|
+
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_ISOLATION_ENTER, `Viewport object was not found: ${invalidId}`, { code: 'viewport.targetNotFound', objectId: invalidId });
|
|
145
|
+
}
|
|
146
|
+
const objectIds = createAgentBridgeViewportObjectIds(state, operations);
|
|
120
147
|
if (objectIds.length === 0) {
|
|
121
148
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_ISOLATION_ENTER, 'Viewport projection is unavailable or has no visible objects to isolate.', { code: 'viewport.projectionUnavailable' });
|
|
122
149
|
}
|
|
123
150
|
const keep = new Set(targetIds);
|
|
124
151
|
for (const targetId of targetIds) {
|
|
125
152
|
for (const parentId of state.projection?.getProjectionParentIds?.(targetId) ?? []) {
|
|
126
|
-
|
|
153
|
+
if (hierarchy.some(item => item.id === parentId))
|
|
154
|
+
keep.add(parentId);
|
|
127
155
|
}
|
|
128
156
|
}
|
|
129
157
|
const nextOverrides = {};
|
|
@@ -147,19 +175,21 @@ function enterAgentBridgeViewportIsolation(state, input) {
|
|
|
147
175
|
: undefined;
|
|
148
176
|
return {
|
|
149
177
|
changed: previous !== JSON.stringify(state.previewVisibility),
|
|
150
|
-
snapshot: createAgentBridgeViewportVisibilitySnapshot(state, entries, diagnostics),
|
|
178
|
+
snapshot: createAgentBridgeViewportVisibilitySnapshot(state, operations, entries, diagnostics),
|
|
151
179
|
...(diagnostics ? { diagnostics } : {}),
|
|
152
180
|
};
|
|
153
181
|
}
|
|
154
|
-
function createAgentBridgeViewportVisibilitySnapshot(state, entries, diagnostics) {
|
|
182
|
+
function createAgentBridgeViewportVisibilitySnapshot(state, operations, entries, diagnostics) {
|
|
155
183
|
const projectionEntries = entries ?? state.projection?.getPreviewVisibilityOverrides?.() ?? [];
|
|
156
|
-
const
|
|
184
|
+
const safeIds = new Set(getAgentBridgeSafeSceneHierarchy(operations).map(item => item.id));
|
|
185
|
+
const safeProjectionEntries = projectionEntries.filter(entry => safeIds.has(entry.nodeId));
|
|
186
|
+
const entryById = new Map(safeProjectionEntries.map(entry => [entry.nodeId, entry]));
|
|
157
187
|
const objectIds = new Set([
|
|
158
|
-
...Object.keys(state.previewVisibility.overrides),
|
|
159
|
-
...
|
|
160
|
-
...state.previewVisibility.isolatedObjectIds,
|
|
188
|
+
...Object.keys(state.previewVisibility.overrides).filter(id => safeIds.has(id)),
|
|
189
|
+
...safeProjectionEntries.map(entry => entry.nodeId),
|
|
190
|
+
...state.previewVisibility.isolatedObjectIds.filter(id => safeIds.has(id)),
|
|
161
191
|
]);
|
|
162
|
-
const isolatedIds = new Set(state.previewVisibility.isolatedObjectIds);
|
|
192
|
+
const isolatedIds = new Set(state.previewVisibility.isolatedObjectIds.filter(id => safeIds.has(id)));
|
|
163
193
|
const normalizedEntries = [...objectIds].sort().map((objectId) => {
|
|
164
194
|
const projectionEntry = entryById.get(objectId);
|
|
165
195
|
const overrideVisible = state.previewVisibility.overrides[objectId];
|
|
@@ -180,19 +210,20 @@ function createAgentBridgeViewportVisibilitySnapshot(state, entries, diagnostics
|
|
|
180
210
|
...(diagnostics?.length ? { diagnostics } : {}),
|
|
181
211
|
};
|
|
182
212
|
}
|
|
183
|
-
function createAgentBridgeViewportObjectIds(state) {
|
|
213
|
+
function createAgentBridgeViewportObjectIds(state, operations) {
|
|
184
214
|
const fromOverrides = Object.keys(state.previewVisibility.overrides);
|
|
185
215
|
const fromProjectedNodes = state.projection?.getProjectedNodeIds?.() ?? [];
|
|
186
216
|
const fromProjection = state.projection?.getPreviewVisibilityOverrides?.().map(entry => entry.nodeId) ?? [];
|
|
187
|
-
const sessionIds =
|
|
217
|
+
const sessionIds = getAgentBridgeSafeSceneSelection(operations).selectedIds;
|
|
188
218
|
const ids = new Set([...fromProjectedNodes, ...fromOverrides, ...fromProjection, ...sessionIds]);
|
|
219
|
+
const safeIds = new Set(getAgentBridgeSafeSceneHierarchy(operations).map(item => item.id));
|
|
189
220
|
if (ids.size > 0)
|
|
190
|
-
return [...ids];
|
|
221
|
+
return [...ids].filter(id => safeIds.has(id));
|
|
191
222
|
return [];
|
|
192
223
|
}
|
|
193
|
-
function createAgentBridgeViewportCameraState(state) {
|
|
224
|
+
function createAgentBridgeViewportCameraState(state, operations) {
|
|
194
225
|
const cameraState = state.sceneViewCamera?.getState();
|
|
195
|
-
const selection =
|
|
226
|
+
const selection = getAgentBridgeSafeSceneSelection(operations);
|
|
196
227
|
const alpha = cameraState?.alpha;
|
|
197
228
|
const beta = cameraState?.beta;
|
|
198
229
|
const radius = cameraState?.radius;
|
|
@@ -217,7 +248,7 @@ function setAgentBridgeViewportCameraPreset(state, options, input, renderUi, ope
|
|
|
217
248
|
if (!state.sceneViewCamera) {
|
|
218
249
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_CAMERA_SET_PRESET, 'Viewport camera is unavailable.', { code: 'viewport.camera.unavailable' });
|
|
219
250
|
}
|
|
220
|
-
const target = resolveAgentBridgeViewportCameraTarget(state, options, input.target, EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_CAMERA_SET_PRESET);
|
|
251
|
+
const target = resolveAgentBridgeViewportCameraTarget(state, options, input.target, EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_CAMERA_SET_PRESET, operations);
|
|
221
252
|
if (!target.ok)
|
|
222
253
|
return target.result;
|
|
223
254
|
const preset = normalizeAgentBridgeViewportCameraPreset(input.preset);
|
|
@@ -226,7 +257,7 @@ function setAgentBridgeViewportCameraPreset(state, options, input, renderUi, ope
|
|
|
226
257
|
}
|
|
227
258
|
const radius = normalizeAgentBridgePositiveNumber(input.radius, null);
|
|
228
259
|
const distanceScale = normalizeAgentBridgePositiveNumber(input.distanceScale, 1);
|
|
229
|
-
const baseRadius = target.radius ?? createAgentBridgeViewportCameraState(state).radius ?? undefined;
|
|
260
|
+
const baseRadius = target.radius ?? createAgentBridgeViewportCameraState(state, operations).radius ?? undefined;
|
|
230
261
|
const scaledRadius = baseRadius && distanceScale ? baseRadius * distanceScale : baseRadius;
|
|
231
262
|
const changed = state.sceneViewCamera.setViewPreset(preset, {
|
|
232
263
|
target: target.target,
|
|
@@ -240,7 +271,7 @@ function setAgentBridgeViewportCameraPreset(state, options, input, renderUi, ope
|
|
|
240
271
|
if (changed)
|
|
241
272
|
operations.requestSceneFrame('agent-viewport-camera-set-preset');
|
|
242
273
|
renderUi();
|
|
243
|
-
return createAgentBridgeViewportCameraMutationOutput(state, changed);
|
|
274
|
+
return createAgentBridgeViewportCameraMutationOutput(state, changed, operations);
|
|
244
275
|
}
|
|
245
276
|
function orbitAgentBridgeViewportCamera(state, options, input, renderUi, operations) {
|
|
246
277
|
if (state.mode !== 'editor' || !state.session) {
|
|
@@ -252,7 +283,7 @@ function orbitAgentBridgeViewportCamera(state, options, input, renderUi, operati
|
|
|
252
283
|
if (!state.sceneViewCamera) {
|
|
253
284
|
return createLocalEditorAgentBridgeFailure(EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_CAMERA_ORBIT, 'Viewport camera is unavailable.', { code: 'viewport.camera.unavailable' });
|
|
254
285
|
}
|
|
255
|
-
const target = resolveAgentBridgeViewportCameraTarget(state, options, input.target, EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_CAMERA_ORBIT);
|
|
286
|
+
const target = resolveAgentBridgeViewportCameraTarget(state, options, input.target, EDITOR_AGENT_BRIDGE_CAPABILITY_ID.VIEWPORT_CAMERA_ORBIT, operations);
|
|
256
287
|
if (!target.ok)
|
|
257
288
|
return target.result;
|
|
258
289
|
const changed = state.sceneViewCamera.orbit({
|
|
@@ -269,10 +300,10 @@ function orbitAgentBridgeViewportCamera(state, options, input, renderUi, operati
|
|
|
269
300
|
if (changed)
|
|
270
301
|
operations.requestSceneFrame('agent-viewport-camera-orbit');
|
|
271
302
|
renderUi();
|
|
272
|
-
return createAgentBridgeViewportCameraMutationOutput(state, changed);
|
|
303
|
+
return createAgentBridgeViewportCameraMutationOutput(state, changed, operations);
|
|
273
304
|
}
|
|
274
|
-
function createAgentBridgeViewportCameraMutationOutput(state, changed) {
|
|
275
|
-
const cameraState = createAgentBridgeViewportCameraState(state);
|
|
305
|
+
function createAgentBridgeViewportCameraMutationOutput(state, changed, operations) {
|
|
306
|
+
const cameraState = createAgentBridgeViewportCameraState(state, operations);
|
|
276
307
|
return {
|
|
277
308
|
changed,
|
|
278
309
|
viewPreset: cameraState.viewPreset,
|
|
@@ -282,8 +313,8 @@ function createAgentBridgeViewportCameraMutationOutput(state, changed) {
|
|
|
282
313
|
selection: cameraState.selection,
|
|
283
314
|
};
|
|
284
315
|
}
|
|
285
|
-
function resolveAgentBridgeViewportCameraTarget(state, options, input, capabilityId) {
|
|
286
|
-
const target = input ?? createDefaultAgentBridgeViewportCameraTarget(
|
|
316
|
+
function resolveAgentBridgeViewportCameraTarget(state, options, input, capabilityId, operations) {
|
|
317
|
+
const target = input ?? createDefaultAgentBridgeViewportCameraTarget(operations);
|
|
287
318
|
if (target.kind === 'point') {
|
|
288
319
|
if (!isLocalEditorAgentBridgeVec3(target.point)) {
|
|
289
320
|
return {
|
|
@@ -294,9 +325,9 @@ function resolveAgentBridgeViewportCameraTarget(state, options, input, capabilit
|
|
|
294
325
|
return { ok: true, target: cloneVec3(target.point) };
|
|
295
326
|
}
|
|
296
327
|
if (target.kind === 'scene')
|
|
297
|
-
return resolveAgentBridgeSceneCameraTarget(state, options);
|
|
328
|
+
return resolveAgentBridgeSceneCameraTarget(state, options, operations);
|
|
298
329
|
if (target.kind === 'selection')
|
|
299
|
-
return resolveAgentBridgeSelectionCameraTarget(state, capabilityId);
|
|
330
|
+
return resolveAgentBridgeSelectionCameraTarget(state, capabilityId, operations);
|
|
300
331
|
if (target.kind === 'object') {
|
|
301
332
|
const objectId = normalizeAgentBridgeString(target.objectId);
|
|
302
333
|
if (!objectId) {
|
|
@@ -306,7 +337,8 @@ function resolveAgentBridgeViewportCameraTarget(state, options, input, capabilit
|
|
|
306
337
|
};
|
|
307
338
|
}
|
|
308
339
|
const document = state.session?.getState({ cloneDocuments: false }).workingDocument ?? null;
|
|
309
|
-
|
|
340
|
+
const hierarchy = document ? getAgentBridgeSafeSceneHierarchy(operations) : [];
|
|
341
|
+
if (!document || !isAgentBridgeHierarchyObjectSelectable(options, document, objectId, hierarchy)) {
|
|
310
342
|
return {
|
|
311
343
|
ok: false,
|
|
312
344
|
result: createLocalEditorAgentBridgeFailure(capabilityId, `Camera target object was not found: ${objectId}`, { code: 'viewport.camera.targetNotFound', objectId }),
|
|
@@ -319,12 +351,12 @@ function resolveAgentBridgeViewportCameraTarget(state, options, input, capabilit
|
|
|
319
351
|
result: createLocalEditorAgentBridgeFailure(capabilityId, 'Unsupported camera target.', { code: 'viewport.camera.invalidTarget' }),
|
|
320
352
|
};
|
|
321
353
|
}
|
|
322
|
-
function createDefaultAgentBridgeViewportCameraTarget(
|
|
323
|
-
const selection =
|
|
354
|
+
function createDefaultAgentBridgeViewportCameraTarget(operations) {
|
|
355
|
+
const selection = getAgentBridgeSafeSceneSelection(operations);
|
|
324
356
|
return selection.activeId ? { kind: 'selection' } : { kind: 'scene' };
|
|
325
357
|
}
|
|
326
|
-
function resolveAgentBridgeSelectionCameraTarget(state, capabilityId) {
|
|
327
|
-
const selection =
|
|
358
|
+
function resolveAgentBridgeSelectionCameraTarget(state, capabilityId, operations) {
|
|
359
|
+
const selection = getAgentBridgeSafeSceneSelection(operations);
|
|
328
360
|
const selectedIds = selection.selectedIds.length > 0
|
|
329
361
|
? selection.selectedIds
|
|
330
362
|
: selection.activeId ? [selection.activeId] : [];
|
|
@@ -347,14 +379,14 @@ function resolveAgentBridgeSelectionCameraTarget(state, capabilityId) {
|
|
|
347
379
|
radius: createAgentBridgeCameraRadiusFromBounds(bounds),
|
|
348
380
|
};
|
|
349
381
|
}
|
|
350
|
-
function resolveAgentBridgeSceneCameraTarget(state, options) {
|
|
382
|
+
function resolveAgentBridgeSceneCameraTarget(state, options, operations) {
|
|
351
383
|
const document = state.session?.getState({ cloneDocuments: false }).workingDocument ?? null;
|
|
352
384
|
if (!document)
|
|
353
385
|
return { ok: true, target: null };
|
|
354
|
-
const hierarchy =
|
|
386
|
+
const hierarchy = getAgentBridgeSafeSceneHierarchy(operations);
|
|
355
387
|
const objectIds = hierarchy
|
|
356
388
|
.map(item => item.id)
|
|
357
|
-
.filter(objectId =>
|
|
389
|
+
.filter(objectId => isAgentBridgeHierarchyObjectSelectable(options, document, objectId, hierarchy));
|
|
358
390
|
if (objectIds.length === 0)
|
|
359
391
|
return { ok: true, target: null };
|
|
360
392
|
const bounds = state.projection?.getSelectionBounds(objectIds) ?? null;
|