@shopware-ag/dive 1.16.10 → 1.16.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/dive",
3
- "version": "1.16.10",
3
+ "version": "1.16.12",
4
4
  "description": "Shopware Spatial Framework",
5
5
  "type": "module",
6
6
  "main": "./build/dive.cjs",
@@ -444,6 +444,13 @@ export class DIVECommunication {
444
444
 
445
445
  this.registered.delete(payload.id);
446
446
 
447
+ // detach from parent
448
+ Array.from(this.registered.values()).forEach((object) => {
449
+ if (!object.parentId) return;
450
+ if (object.parentId !== payload.id) return;
451
+ object.parentId = null;
452
+ });
453
+
447
454
  this.scene.DeleteSceneObject(deletedObject);
448
455
 
449
456
  return true;
@@ -12,7 +12,11 @@ import { type DIVESceneObject } from '../types';
12
12
  export class DIVEGroup extends DIVENode {
13
13
  readonly isDIVEGroup: true = true;
14
14
 
15
- private _members: Object3D[]; // lines to children
15
+ private _members: Object3D[]; // children objects
16
+
17
+ public get members(): Object3D[] {
18
+ return this._members;
19
+ }
16
20
 
17
21
  private _lines: Line[]; // lines to children
18
22
 
@@ -329,7 +329,7 @@ export class DIVERoot extends Object3D {
329
329
 
330
330
  this.detachTransformControls(sceneObject);
331
331
 
332
- this.remove(sceneObject);
332
+ sceneObject.parent!.remove(sceneObject);
333
333
  }
334
334
 
335
335
  private deleteModel(model: Partial<COMModel> & { id: string }): void {
@@ -343,7 +343,7 @@ export class DIVERoot extends Object3D {
343
343
 
344
344
  this.detachTransformControls(sceneObject);
345
345
 
346
- this.remove(sceneObject);
346
+ sceneObject.parent!.remove(sceneObject);
347
347
  }
348
348
 
349
349
  private deletePrimitive(
@@ -359,11 +359,11 @@ export class DIVERoot extends Object3D {
359
359
 
360
360
  this.detachTransformControls(sceneObject);
361
361
 
362
- this.remove(sceneObject);
362
+ sceneObject.parent!.remove(sceneObject);
363
363
  }
364
364
 
365
365
  private deleteGroup(group: Partial<COMGroup> & { id: string }): void {
366
- const sceneObject = this.GetSceneObject(group);
366
+ const sceneObject = this.GetSceneObject<DIVEGroup>(group);
367
367
  if (!sceneObject) {
368
368
  console.warn(
369
369
  `DIVERoot.deleteGroup: Group with id ${group.id} not found`,
@@ -373,8 +373,8 @@ export class DIVERoot extends Object3D {
373
373
 
374
374
  this.detachTransformControls(sceneObject);
375
375
 
376
- for (let i = sceneObject.children.length - 1; i >= 0; i--) {
377
- this.attach(sceneObject.children[i]);
376
+ for (let i = sceneObject.members.length - 1; i >= 0; i--) {
377
+ this.attach(sceneObject.members[i]);
378
378
  }
379
379
 
380
380
  sceneObject.parent!.remove(sceneObject);
@@ -870,6 +870,13 @@ describe('DIVE/scene/root/DIVERoot', () => {
870
870
  expect(spyConsoleWarn).toHaveBeenCalled();
871
871
 
872
872
  spyConsoleWarn.mockClear();
873
+ root['detachTransformControls'] = jest.fn();
874
+ jest.spyOn(root, 'GetSceneObject').mockReturnValueOnce({
875
+ members: [new Object3D()],
876
+ parent: {
877
+ remove: jest.fn(),
878
+ },
879
+ } as unknown as DIVESceneObject);
873
880
  expect(() =>
874
881
  root.DeleteSceneObject({
875
882
  id: 'id',
@@ -883,6 +890,7 @@ describe('DIVE/scene/root/DIVERoot', () => {
883
890
  const firstFind = root.GetSceneObject({ id: 'id' });
884
891
  jest.spyOn(root, 'GetSceneObject').mockReturnValueOnce({
885
892
  ...firstFind,
893
+ members: [new Object3D()],
886
894
  parent: sceneParent,
887
895
  children: [
888
896
  {