@2112-lab/central-plant 0.3.48 → 0.3.50

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.
@@ -3,6 +3,7 @@ import * as THREE from 'three';
3
3
  import { loadTextureSet } from '../environment/textureConfig.js';
4
4
  import { ModelManager } from './modelManager.js';
5
5
  import { SceneClearingUtility } from '../../utils/sceneClearingUtility.js';
6
+ import { DEFAULT_HOME_VIEW_DIRECTION } from '../controls/cameraControlsManager.js';
6
7
 
7
8
  var _excluded = ["direction"],
8
9
  _excluded2 = ["direction"];
@@ -866,6 +867,19 @@ var SceneOperationsManager = /*#__PURE__*/function () {
866
867
  if (!(data !== null && data !== void 0 && (_data$scene2 = data.scene) !== null && _data$scene2 !== void 0 && _data$scene2.children) || !componentDictionary) {
867
868
  return;
868
869
  }
870
+
871
+ // Collect every connector uuid referenced by the scene's connections so we
872
+ // can inject connectors under the SAME uuid scheme the scene actually uses.
873
+ // Two schemes exist in the wild:
874
+ // - Preferred (runtime add path + minimal export): `${componentUuid}_${dictConnectorUuid}`
875
+ // - Legacy (older hand-authored scenes): `${componentUuid}-CONNECTOR-${index+1}`
876
+ var connectionEndpoints = new Set();
877
+ if (Array.isArray(data.connections)) {
878
+ data.connections.forEach(function (conn) {
879
+ if (conn !== null && conn !== void 0 && conn.from) connectionEndpoints.add(conn.from);
880
+ if (conn !== null && conn !== void 0 && conn.to) connectionEndpoints.add(conn.to);
881
+ });
882
+ }
869
883
  var componentsProcessed = 0;
870
884
  var connectorsInjected = 0;
871
885
  data.scene.children.forEach(function (child) {
@@ -888,9 +902,18 @@ var SceneOperationsManager = /*#__PURE__*/function () {
888
902
 
889
903
  // Deep clone the connector children from the dictionary
890
904
  child.children = dictEntry.children.map(function (connector, index) {
891
- // Generate unique UUID for this connector instance
892
- // Format: COMPONENT-UUID-CONNECTOR-INDEX
893
- var connectorUuid = "".concat(child.uuid, "-CONNECTOR-").concat(index + 1);
905
+ // Choose the connector uuid that matches the scheme the scene's
906
+ // connections reference. Prefer `${componentUuid}_${dictConnectorUuid}`
907
+ // (sandbox add path + minimal export); fall back to the legacy
908
+ // index-based scheme `${componentUuid}-CONNECTOR-${index+1}` when the
909
+ // connections reference that form. If neither is referenced (e.g. an
910
+ // unconnected connector), default to the preferred scheme.
911
+ var legacyUuid = "".concat(child.uuid, "-CONNECTOR-").concat(index + 1);
912
+ var preferredUuid = connector.uuid ? "".concat(child.uuid, "_").concat(connector.uuid) : legacyUuid;
913
+ var connectorUuid = preferredUuid;
914
+ if (!connectionEndpoints.has(preferredUuid) && connectionEndpoints.has(legacyUuid)) {
915
+ connectorUuid = legacyUuid;
916
+ }
894
917
 
895
918
  // Clone connector with deep copy of userData
896
919
  var clonedConnector = _objectSpread2(_objectSpread2({}, connector), {}, {
@@ -1096,6 +1119,7 @@ var SceneOperationsManager = /*#__PURE__*/function () {
1096
1119
  }, {
1097
1120
  key: "_finalizeScene",
1098
1121
  value: function _finalizeScene(data, crosscubeTextureSet, isImported) {
1122
+ var _component$cameraCont;
1099
1123
  var component = this.sceneViewer;
1100
1124
  component.currentSceneData = data;
1101
1125
  component.crosscubeTextureSet = crosscubeTextureSet;
@@ -1107,6 +1131,14 @@ var SceneOperationsManager = /*#__PURE__*/function () {
1107
1131
  }
1108
1132
  this._setTransformControlsState(true, false); // Enable but keep hidden initially
1109
1133
  }
1134
+
1135
+ // Frame the camera so all components fit perfectly in view (low, ground-level angle)
1136
+ if ((_component$cameraCont = component.cameraControlsManager) !== null && _component$cameraCont !== void 0 && _component$cameraCont.fitCameraToScene) {
1137
+ component.cameraControlsManager.fitCameraToScene({
1138
+ direction: DEFAULT_HOME_VIEW_DIRECTION,
1139
+ groundLevel: true
1140
+ });
1141
+ }
1110
1142
  }
1111
1143
 
1112
1144
  /**
@@ -1,4 +1,4 @@
1
- import { createForOfIteratorHelper as _createForOfIteratorHelper, objectSpread2 as _objectSpread2, construct as _construct, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import { objectSpread2 as _objectSpread2, createForOfIteratorHelper as _createForOfIteratorHelper, construct as _construct, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import * as THREE from 'three';
3
3
 
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2112-lab/central-plant",
3
- "version": "0.3.48",
3
+ "version": "0.3.50",
4
4
  "description": "Utility modules for the Central Plant Application",
5
5
  "main": "dist/bundle/index.js",
6
6
  "module": "dist/esm/src/index.js",