@colijnit/homedecorator 257.1.13 → 257.1.14

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.
@@ -13,6 +13,7 @@ export declare abstract class BaseItem extends Object3D {
13
13
  locked: boolean;
14
14
  itemGroup: any;
15
15
  obstructFloorMoves: boolean;
16
+ positionValid: boolean;
16
17
  allowRotate: boolean;
17
18
  fixed: boolean;
18
19
  skin: Skin;
@@ -13,6 +13,7 @@ export declare class ItemGroup extends Group {
13
13
  wantsRotation: Euler;
14
14
  metadata: Metadata;
15
15
  boundaryBox: Box3;
16
+ positionValid: boolean;
16
17
  private _items;
17
18
  private _halfSize;
18
19
  private _boundaryBoxCenter;
@@ -1,8 +1,11 @@
1
- import { Euler, Object3D, Vector3 } from 'three';
1
+ import { Euler, Group, Object3D, Vector3 } from 'three';
2
2
  import { SceneService } from './scene.service';
3
+ import { Furniture } from '../items/furniture';
4
+ import { Item } from '../items/item';
3
5
  import * as i0 from "@angular/core";
4
6
  export declare class ErrorGlowService {
5
7
  private _sceneService;
8
+ get errorGlow(): Object3D | Group;
6
9
  private _errorGlow;
7
10
  private _parent;
8
11
  constructor(_sceneService: SceneService);
@@ -10,7 +13,7 @@ export declare class ErrorGlowService {
10
13
  private static _cloneItem;
11
14
  private static _cloneGroup;
12
15
  private static _cloneObject3D;
13
- showError(item: Object3D, position?: Vector3, rotation?: Euler, parent?: Object3D): void;
16
+ showError(item: Item | Furniture, position?: Vector3, rotation?: Euler, parent?: Object3D): void;
14
17
  hideError(): void;
15
18
  private _removeErrorGlowObject;
16
19
  static ɵfac: i0.ɵɵFactoryDeclaration<ErrorGlowService, never>;
@@ -35,6 +35,7 @@ export declare class RotationService implements OnDestroy {
35
35
  private _moveFactor;
36
36
  constructor(_outlineService: OutlineService, _collisionManagerService: CollisionManagerService, _itemService: ItemService, _configService: ConfigurationService, _appService: HomedecoratorAppService, _sceneService: SceneService, _errorGlowService: ErrorGlowService, _settingsService: HomedecoratorSettingsService);
37
37
  ngOnDestroy(): void;
38
+ clearRotationError(item: FloorItem, from: Vector3, to: Vector3, ccw?: boolean): void;
38
39
  rotate(item: FloorItem, from: Vector3, to: Vector3, ccw?: boolean): Vector3;
39
40
  enableRotationFor(item: Item): void;
40
41
  private _handleMouseDown;
@@ -5754,6 +5754,7 @@
5754
5754
  _this.canMove = true;
5755
5755
  _this.locked = false;
5756
5756
  _this.obstructFloorMoves = true; // Does this object affect other floor items
5757
+ _this.positionValid = true;
5757
5758
  _this.allowRotate = true; // Show rotate option in context menu
5758
5759
  _this.fixed = false;
5759
5760
  _this.canChangeCustomMeshColor = false;
@@ -6397,6 +6398,7 @@
6397
6398
  _this.locked = false;
6398
6399
  _this.obstructFloorMoves = true;
6399
6400
  _this.boundaryBox = new THREE.Box3();
6401
+ _this.positionValid = true;
6400
6402
  _this._items = [];
6401
6403
  _this._halfSize = new THREE.Vector3();
6402
6404
  _this._boundaryBoxCenter = new THREE.Vector3();
@@ -19355,6 +19357,13 @@
19355
19357
  function ErrorGlowService(_sceneService) {
19356
19358
  this._sceneService = _sceneService;
19357
19359
  }
19360
+ Object.defineProperty(ErrorGlowService.prototype, "errorGlow", {
19361
+ get: function () {
19362
+ return this._errorGlow;
19363
+ },
19364
+ enumerable: false,
19365
+ configurable: true
19366
+ });
19358
19367
  ErrorGlowService._createErrorGlow = function (item, color, opacity, ignoreDepth) {
19359
19368
  if (color === void 0) { color = defaultColor$2; }
19360
19369
  if (opacity === void 0) { opacity = defaultOpacity; }
@@ -19383,8 +19392,13 @@
19383
19392
  var newItem = this._cloneObject3D(source);
19384
19393
  if (meshMaterial) {
19385
19394
  newItem.traverse(function (child) {
19386
- if (child instanceof THREE.Mesh) {
19387
- child.material = meshMaterial;
19395
+ if (child.isMesh) {
19396
+ if (Array.isArray(child.material)) {
19397
+ child.material = child.material.map(function () { return meshMaterial; });
19398
+ }
19399
+ else {
19400
+ child.material = meshMaterial;
19401
+ }
19388
19402
  }
19389
19403
  });
19390
19404
  }
@@ -19394,8 +19408,13 @@
19394
19408
  var newGroup = this._cloneObject3D(source);
19395
19409
  if (meshMaterial) {
19396
19410
  newGroup.traverse(function (child) {
19397
- if (child instanceof THREE.Mesh) {
19398
- child.material = meshMaterial;
19411
+ if (child.isMesh) {
19412
+ if (Array.isArray(child.material)) {
19413
+ child.material = child.material.map(function () { return meshMaterial; });
19414
+ }
19415
+ else {
19416
+ child.material = meshMaterial;
19417
+ }
19399
19418
  }
19400
19419
  });
19401
19420
  }
@@ -19423,6 +19442,10 @@
19423
19442
  var clone = _this._cloneObject3D(child);
19424
19443
  clone.position.copy(child.position);
19425
19444
  clone.rotation.copy(child.rotation);
19445
+ clone.scale.copy(child.scale);
19446
+ clone.name = child.name;
19447
+ clone.visible = child.visible;
19448
+ clone.userData = Object.assign({}, child.userData);
19426
19449
  newObject.add(clone);
19427
19450
  }
19428
19451
  });
@@ -19431,6 +19454,7 @@
19431
19454
  ErrorGlowService.prototype.showError = function (item, position, rotation, parent) {
19432
19455
  var pos = position || item.position;
19433
19456
  var rot = rotation || item.rotation;
19457
+ item.positionValid = false;
19434
19458
  if (this._errorGlow && this._errorGlow.userData.cloneID !== item.uuid) {
19435
19459
  this._removeErrorGlowObject();
19436
19460
  }
@@ -19551,6 +19575,20 @@
19551
19575
  this._subs.forEach(function (s) { return s.unsubscribe(); });
19552
19576
  this._removeListeners();
19553
19577
  };
19578
+ RotationService.prototype.clearRotationError = function (item, from, to, ccw) {
19579
+ if (ccw === void 0) { ccw = true; }
19580
+ if (this._errorGlowService.errorGlow) {
19581
+ var originalPosition = item.position;
19582
+ var originalRotation = item.rotation;
19583
+ var angle = Utils$1.angle(from.x - originalPosition.x, ccw ? from.z - originalPosition.z : Math.abs(from.z - originalPosition.z), to.x - originalPosition.x, ccw ? to.z - originalPosition.z : Math.abs(to.z - originalPosition.z)) + originalRotation.y;
19584
+ var rotation = new THREE.Euler(originalRotation.x, angle, originalRotation.z);
19585
+ var collisionInfo = this._collisionManagerService.validatePosition(null, rotation, item, this._itemService.getFurniture());
19586
+ if (collisionInfo.valid) {
19587
+ this._errorGlowService.hideError();
19588
+ item.positionValid = true;
19589
+ }
19590
+ }
19591
+ };
19554
19592
  RotationService.prototype.rotate = function (item, from, to, ccw) {
19555
19593
  if (ccw === void 0) { ccw = true; }
19556
19594
  if (!from || !to) {
@@ -19577,10 +19615,12 @@
19577
19615
  if (!collisionInfo.valid) {
19578
19616
  this._outlineService.showErrorOutline(item);
19579
19617
  if (collisionInfo.intersectsWall) {
19580
- return from;
19618
+ this._errorGlowService.showError(item);
19619
+ // return from;
19581
19620
  }
19582
19621
  }
19583
19622
  else {
19623
+ this._errorGlowService.hideError();
19584
19624
  this._outlineService.showOutline(item);
19585
19625
  }
19586
19626
  originalRotation.y = angle;
@@ -22035,7 +22075,8 @@
22035
22075
  this._placedPosition = position;
22036
22076
  this._placedIntersection = intersection;
22037
22077
  if (this.draggedData.type === ItemType.FloorDecoration && this._placedIntersection && this._placedIntersection.object) {
22038
- this._floorService.configureFloor((this._placedIntersection.object instanceof FloorPlaneItem ? this._placedIntersection.object : this._placedIntersection.object.parent));
22078
+ this._floorService.configureFloor((this._placedIntersection.object instanceof FloorPlaneItem ?
22079
+ this._placedIntersection.object : this._placedIntersection.object.parent));
22039
22080
  this._replacePinWithFurniture(this._placedPosition);
22040
22081
  }
22041
22082
  else {
@@ -22058,7 +22099,7 @@
22058
22099
  this._placedPosition = null;
22059
22100
  this._placedIntersection = null;
22060
22101
  this.draggedStatus.clean();
22061
- this._errorGlowService.hideError();
22102
+ // this._errorGlowService.hideError();
22062
22103
  this._snappingCollisionService.handleEndOfDragging();
22063
22104
  this._outlineService.hideOutline();
22064
22105
  };
@@ -22084,7 +22125,7 @@
22084
22125
  }
22085
22126
  };
22086
22127
  DragAndDropService.prototype.clickReleased = function () {
22087
- this._errorGlowService.hideError();
22128
+ // this._errorGlowService.hideError();
22088
22129
  this._snappingCollisionService.handleEndOfDragging();
22089
22130
  };
22090
22131
  DragAndDropService.prototype._createPin = function (point, floorIntersect) {
@@ -22185,8 +22226,14 @@
22185
22226
  if (!item.elevationFixed) {
22186
22227
  item.elevation = 0;
22187
22228
  }
22188
- if (!collisionInfo.valid) {
22189
- positionMoveTo.y = item.getFloorY();
22229
+ if (item.positionValid && !collisionInfo.valid) {
22230
+ if (item.canElevate && !item.elevationFixed && collisionInfo.obstructingObjects && collisionInfo.obstructingObjects.length > 0) {
22231
+ positionMoveTo.y =
22232
+ collisionInfo.obstructingObjects[0].halfSize.y * 2 + (collisionInfo.obstructingObjects[0].elevation);
22233
+ }
22234
+ else {
22235
+ positionMoveTo.y = item.getFloorY();
22236
+ }
22190
22237
  if (collisionInfo.intersectsWall /* && !(item instanceof CustomWallFloorItem)*/) {
22191
22238
  positionMoveTo = this._slideAtFloor(item, positionMoveTo, item.rotation);
22192
22239
  this._outlineService.showOutline(item);
@@ -22203,7 +22250,7 @@
22203
22250
  item.elevation =
22204
22251
  collisionInfo.obstructingObjects[0].halfSize.y * 2 + (collisionInfo.obstructingObjects[0].elevation);
22205
22252
  }
22206
- else if (this._settingsService.settings.options.usePlacementSnapping
22253
+ else if (this._settingsService.settings.options.usePlacementSnapping && item.positionValid
22207
22254
  // && (item instanceof Item && (item.canSnapToWall || item.canSnapToObject))
22208
22255
  ) {
22209
22256
  this._snappingCollisionService.handleSnapping(item, positionMoveTo);
@@ -22212,6 +22259,9 @@
22212
22259
  positionMoveTo.y = item.getFloorY();
22213
22260
  }
22214
22261
  this._outlineService.showOutline(item);
22262
+ if (!item.positionValid) {
22263
+ this._errorGlowService.showError(item);
22264
+ }
22215
22265
  if (!this._snappingCollisionService.itemHasSnapped()) {
22216
22266
  item.position.copy(positionMoveTo);
22217
22267
  }
@@ -23049,6 +23099,7 @@
23049
23099
  this._dragAndDropService.clickDragged(intersection);
23050
23100
  this._messageBusService.emit(MessageType.ClickDragged);
23051
23101
  this._debouncedSaveState.next('item dragged');
23102
+ this._rotationService.clearRotationError(this._selectedObject, this._rotationStartPoint, intersection.point, !this.rotateNoDrag);
23052
23103
  }
23053
23104
  this._hudService.update();
23054
23105
  }