@colijnit/homedecorator 257.1.12 → 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;
@@ -1749,9 +1749,10 @@
1749
1749
  };
1750
1750
  RelativePositionUtils.GetClientTouchPosition = function (event, canvas) {
1751
1751
  var touch = event.touches[0];
1752
- var x = touch.clientX;
1753
- var y = touch.clientY;
1754
- return new THREE__namespace.Vector2(x, y);
1752
+ var rect = canvas.getBoundingClientRect();
1753
+ var xOffset = touch.clientX - rect.left;
1754
+ var yOffset = touch.clientY - rect.top;
1755
+ return new THREE__namespace.Vector2(xOffset, yOffset);
1755
1756
  };
1756
1757
  RelativePositionUtils.GetElementRect = function (element, handleAppOffset) {
1757
1758
  var rect;
@@ -5753,6 +5754,7 @@
5753
5754
  _this.canMove = true;
5754
5755
  _this.locked = false;
5755
5756
  _this.obstructFloorMoves = true; // Does this object affect other floor items
5757
+ _this.positionValid = true;
5756
5758
  _this.allowRotate = true; // Show rotate option in context menu
5757
5759
  _this.fixed = false;
5758
5760
  _this.canChangeCustomMeshColor = false;
@@ -6396,6 +6398,7 @@
6396
6398
  _this.locked = false;
6397
6399
  _this.obstructFloorMoves = true;
6398
6400
  _this.boundaryBox = new THREE.Box3();
6401
+ _this.positionValid = true;
6399
6402
  _this._items = [];
6400
6403
  _this._halfSize = new THREE.Vector3();
6401
6404
  _this._boundaryBoxCenter = new THREE.Vector3();
@@ -19354,6 +19357,13 @@
19354
19357
  function ErrorGlowService(_sceneService) {
19355
19358
  this._sceneService = _sceneService;
19356
19359
  }
19360
+ Object.defineProperty(ErrorGlowService.prototype, "errorGlow", {
19361
+ get: function () {
19362
+ return this._errorGlow;
19363
+ },
19364
+ enumerable: false,
19365
+ configurable: true
19366
+ });
19357
19367
  ErrorGlowService._createErrorGlow = function (item, color, opacity, ignoreDepth) {
19358
19368
  if (color === void 0) { color = defaultColor$2; }
19359
19369
  if (opacity === void 0) { opacity = defaultOpacity; }
@@ -19382,8 +19392,13 @@
19382
19392
  var newItem = this._cloneObject3D(source);
19383
19393
  if (meshMaterial) {
19384
19394
  newItem.traverse(function (child) {
19385
- if (child instanceof THREE.Mesh) {
19386
- 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
+ }
19387
19402
  }
19388
19403
  });
19389
19404
  }
@@ -19393,8 +19408,13 @@
19393
19408
  var newGroup = this._cloneObject3D(source);
19394
19409
  if (meshMaterial) {
19395
19410
  newGroup.traverse(function (child) {
19396
- if (child instanceof THREE.Mesh) {
19397
- 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
+ }
19398
19418
  }
19399
19419
  });
19400
19420
  }
@@ -19422,6 +19442,10 @@
19422
19442
  var clone = _this._cloneObject3D(child);
19423
19443
  clone.position.copy(child.position);
19424
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);
19425
19449
  newObject.add(clone);
19426
19450
  }
19427
19451
  });
@@ -19430,6 +19454,7 @@
19430
19454
  ErrorGlowService.prototype.showError = function (item, position, rotation, parent) {
19431
19455
  var pos = position || item.position;
19432
19456
  var rot = rotation || item.rotation;
19457
+ item.positionValid = false;
19433
19458
  if (this._errorGlow && this._errorGlow.userData.cloneID !== item.uuid) {
19434
19459
  this._removeErrorGlowObject();
19435
19460
  }
@@ -19550,6 +19575,20 @@
19550
19575
  this._subs.forEach(function (s) { return s.unsubscribe(); });
19551
19576
  this._removeListeners();
19552
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
+ };
19553
19592
  RotationService.prototype.rotate = function (item, from, to, ccw) {
19554
19593
  if (ccw === void 0) { ccw = true; }
19555
19594
  if (!from || !to) {
@@ -19576,10 +19615,12 @@
19576
19615
  if (!collisionInfo.valid) {
19577
19616
  this._outlineService.showErrorOutline(item);
19578
19617
  if (collisionInfo.intersectsWall) {
19579
- return from;
19618
+ this._errorGlowService.showError(item);
19619
+ // return from;
19580
19620
  }
19581
19621
  }
19582
19622
  else {
19623
+ this._errorGlowService.hideError();
19583
19624
  this._outlineService.showOutline(item);
19584
19625
  }
19585
19626
  originalRotation.y = angle;
@@ -22034,7 +22075,8 @@
22034
22075
  this._placedPosition = position;
22035
22076
  this._placedIntersection = intersection;
22036
22077
  if (this.draggedData.type === ItemType.FloorDecoration && this._placedIntersection && this._placedIntersection.object) {
22037
- 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));
22038
22080
  this._replacePinWithFurniture(this._placedPosition);
22039
22081
  }
22040
22082
  else {
@@ -22057,7 +22099,7 @@
22057
22099
  this._placedPosition = null;
22058
22100
  this._placedIntersection = null;
22059
22101
  this.draggedStatus.clean();
22060
- this._errorGlowService.hideError();
22102
+ // this._errorGlowService.hideError();
22061
22103
  this._snappingCollisionService.handleEndOfDragging();
22062
22104
  this._outlineService.hideOutline();
22063
22105
  };
@@ -22083,7 +22125,7 @@
22083
22125
  }
22084
22126
  };
22085
22127
  DragAndDropService.prototype.clickReleased = function () {
22086
- this._errorGlowService.hideError();
22128
+ // this._errorGlowService.hideError();
22087
22129
  this._snappingCollisionService.handleEndOfDragging();
22088
22130
  };
22089
22131
  DragAndDropService.prototype._createPin = function (point, floorIntersect) {
@@ -22184,8 +22226,14 @@
22184
22226
  if (!item.elevationFixed) {
22185
22227
  item.elevation = 0;
22186
22228
  }
22187
- if (!collisionInfo.valid) {
22188
- 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
+ }
22189
22237
  if (collisionInfo.intersectsWall /* && !(item instanceof CustomWallFloorItem)*/) {
22190
22238
  positionMoveTo = this._slideAtFloor(item, positionMoveTo, item.rotation);
22191
22239
  this._outlineService.showOutline(item);
@@ -22202,7 +22250,7 @@
22202
22250
  item.elevation =
22203
22251
  collisionInfo.obstructingObjects[0].halfSize.y * 2 + (collisionInfo.obstructingObjects[0].elevation);
22204
22252
  }
22205
- else if (this._settingsService.settings.options.usePlacementSnapping
22253
+ else if (this._settingsService.settings.options.usePlacementSnapping && item.positionValid
22206
22254
  // && (item instanceof Item && (item.canSnapToWall || item.canSnapToObject))
22207
22255
  ) {
22208
22256
  this._snappingCollisionService.handleSnapping(item, positionMoveTo);
@@ -22211,6 +22259,9 @@
22211
22259
  positionMoveTo.y = item.getFloorY();
22212
22260
  }
22213
22261
  this._outlineService.showOutline(item);
22262
+ if (!item.positionValid) {
22263
+ this._errorGlowService.showError(item);
22264
+ }
22214
22265
  if (!this._snappingCollisionService.itemHasSnapped()) {
22215
22266
  item.position.copy(positionMoveTo);
22216
22267
  }
@@ -22810,6 +22861,7 @@
22810
22861
  case SceneEventState.ROTATING:
22811
22862
  this._clickDragged();
22812
22863
  this._markSceneToUpdate();
22864
+ this._eventService.objectMovingOrRotating.next();
22813
22865
  break;
22814
22866
  }
22815
22867
  }
@@ -22887,11 +22939,8 @@
22887
22939
  return this._intersectionService.getIntersections(mouseVector, objects, options);
22888
22940
  };
22889
22941
  SceneEventService.prototype._setMousePositionFromTouchEvent = function (event) {
22890
- var touch = event.touches[0];
22891
- if (touch) {
22892
- var canvas = event.target;
22893
- this._mousePosition.set(touch.pageX - (canvas ? canvas.offsetLeft : 0), touch.pageY - (canvas ? canvas.offsetTop : 0));
22894
- }
22942
+ var canvas = this._element;
22943
+ this._mousePosition = RelativePositionUtils.GetClientTouchPosition(event, canvas);
22895
22944
  };
22896
22945
  SceneEventService.prototype._touchStartEvent = function (event) {
22897
22946
  var _this = this;
@@ -23050,6 +23099,7 @@
23050
23099
  this._dragAndDropService.clickDragged(intersection);
23051
23100
  this._messageBusService.emit(MessageType.ClickDragged);
23052
23101
  this._debouncedSaveState.next('item dragged');
23102
+ this._rotationService.clearRotationError(this._selectedObject, this._rotationStartPoint, intersection.point, !this.rotateNoDrag);
23053
23103
  }
23054
23104
  this._hudService.update();
23055
23105
  }