angular-three 1.7.1 → 1.7.2

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.
@@ -894,6 +894,27 @@ class NgtStore extends NgtRxStore {
894
894
  this.set({ ready: true });
895
895
  this.invalidate();
896
896
  }
897
+ destroy(canvas) {
898
+ this.set((state) => ({
899
+ internal: { ...state.internal, active: false },
900
+ }));
901
+ setTimeout(() => {
902
+ const { gl, xr, events } = this.get();
903
+ if (gl) {
904
+ if (events.disconnect) {
905
+ events.disconnect();
906
+ }
907
+ gl.renderLists.dispose();
908
+ gl.forceContextLoss();
909
+ if (gl.xr && gl.xr.enabled) {
910
+ gl.xr.setAnimationLoop(null);
911
+ xr.disconnect();
912
+ }
913
+ dispose(this.get());
914
+ rootStateMap.delete(canvas);
915
+ }
916
+ }, 500);
917
+ }
897
918
  resize() {
898
919
  const state = this.get();
899
920
  let oldSize = state.size;
@@ -937,6 +958,15 @@ function computeInitialSize(canvas, defaultSize) {
937
958
  }
938
959
  return { width: 0, height: 0, top: 0, left: 0 };
939
960
  }
961
+ // Disposes an object and all its properties
962
+ function dispose(obj) {
963
+ if (obj.dispose && !is.scene(obj))
964
+ obj.dispose();
965
+ for (const p in obj) {
966
+ p.dispose?.();
967
+ delete obj[p];
968
+ }
969
+ }
940
970
 
941
971
  const NGT_COMPOUND_PREFIXES = new InjectionToken('NgtCompoundPrefixes');
942
972
 
@@ -2477,6 +2507,7 @@ class NgtCanvas extends NgtRxStore {
2477
2507
  if (this.glEnvInjector)
2478
2508
  this.glEnvInjector.destroy();
2479
2509
  injectNgtLoader.destroy();
2510
+ this.store.destroy(this.glCanvas.nativeElement);
2480
2511
  super.ngOnDestroy();
2481
2512
  }
2482
2513
  overrideDetectChanges() {