angular-three 1.4.2 → 1.4.4
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/esm2020/lib/renderer/renderer.mjs +23 -8
- package/esm2020/lib/renderer/utils.mjs +6 -4
- package/esm2020/lib/stores/rx-store.mjs +11 -2
- package/fesm2015/angular-three.mjs +37 -10
- package/fesm2015/angular-three.mjs.map +1 -1
- package/fesm2020/angular-three.mjs +36 -10
- package/fesm2020/angular-three.mjs.map +1 -1
- package/lib/renderer/utils.d.ts +2 -2
- package/lib/stores/rx-store.d.ts +2 -0
- package/package.json +1 -1
- package/plugin/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { ElementRef, Injectable, inject, InjectionToken, ViewContainerRef, TemplateRef, Directive, Input, EventEmitter, getDebugNode, RendererFactory2, ChangeDetectorRef, makeEnvironmentProviders, EnvironmentInjector, createEnvironmentInjector, Component, HostBinding, Output, ViewChild, Pipe, SkipSelf, ContentChild } from '@angular/core';
|
|
3
3
|
import { provideNgxResizeOptions, NgxResize } from 'ngx-resize';
|
|
4
|
-
import { isObservable, of, map, from, tap, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, BehaviorSubject, startWith, filter, distinctUntilChanged, takeUntil, merge } from 'rxjs';
|
|
4
|
+
import { isObservable, of, map, from, tap, retry, catchError, share, ReplaySubject, switchMap, forkJoin, take, BehaviorSubject, startWith, combineLatest, filter, distinctUntilChanged, takeUntil, merge } from 'rxjs';
|
|
5
5
|
import * as THREE from 'three';
|
|
6
6
|
import { DOCUMENT, NgForOf, NgIf } from '@angular/common';
|
|
7
7
|
import { RxState, selectSlice } from '@rx-angular/state';
|
|
@@ -546,6 +546,15 @@ class NgtRxStore extends RxState {
|
|
|
546
546
|
effect(obs, sideEffectFn) {
|
|
547
547
|
return this.hold(obs.pipe(tapEffect(sideEffectFn)));
|
|
548
548
|
}
|
|
549
|
+
triggerChangeDetection(cdr, keys = []) {
|
|
550
|
+
let $ = this.$;
|
|
551
|
+
if (keys.length) {
|
|
552
|
+
$ = combineLatest(keys.map((key) => this.select(key).pipe(startWith(this.get(key) ?? undefined))));
|
|
553
|
+
}
|
|
554
|
+
this.hold($, () => {
|
|
555
|
+
requestAnimationFrame(() => void cdr.detectChanges());
|
|
556
|
+
});
|
|
557
|
+
}
|
|
549
558
|
}
|
|
550
559
|
NgtRxStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRxStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
551
560
|
NgtRxStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtRxStore });
|
|
@@ -1451,7 +1460,7 @@ function removeThreeRecursive(array, parent, dispose) {
|
|
|
1451
1460
|
if (array)
|
|
1452
1461
|
[...array].forEach((child) => removeThreeChild(parent, child, dispose));
|
|
1453
1462
|
}
|
|
1454
|
-
function processThreeEvent(instance, priority, eventName, callback, cdr) {
|
|
1463
|
+
function processThreeEvent(instance, priority, eventName, callback, cdr, targetCdr) {
|
|
1455
1464
|
const lS = getLocalState(instance);
|
|
1456
1465
|
if (eventName === SPECIAL_EVENTS.BEFORE_RENDER) {
|
|
1457
1466
|
return lS.store
|
|
@@ -1478,7 +1487,7 @@ function processThreeEvent(instance, priority, eventName, callback, cdr) {
|
|
|
1478
1487
|
};
|
|
1479
1488
|
lS.handlers = {
|
|
1480
1489
|
...lS.handlers,
|
|
1481
|
-
[eventName]: eventToHandler(updatedCallback, cdr),
|
|
1490
|
+
[eventName]: eventToHandler(updatedCallback, cdr, targetCdr),
|
|
1482
1491
|
};
|
|
1483
1492
|
// increment the count everytime
|
|
1484
1493
|
lS.eventCount += 1;
|
|
@@ -1495,9 +1504,11 @@ function processThreeEvent(instance, priority, eventName, callback, cdr) {
|
|
|
1495
1504
|
}
|
|
1496
1505
|
};
|
|
1497
1506
|
}
|
|
1498
|
-
function eventToHandler(callback, cdr) {
|
|
1507
|
+
function eventToHandler(callback, cdr, targetCdr) {
|
|
1499
1508
|
return (event) => {
|
|
1500
1509
|
callback(event);
|
|
1510
|
+
if (targetCdr)
|
|
1511
|
+
targetCdr.detectChanges();
|
|
1501
1512
|
cdr.detectChanges();
|
|
1502
1513
|
};
|
|
1503
1514
|
}
|
|
@@ -1947,11 +1958,16 @@ class NgtRenderer {
|
|
|
1947
1958
|
// on first pass, we return the Root Scene as the root node
|
|
1948
1959
|
if (this.root && !this.first) {
|
|
1949
1960
|
this.first = true;
|
|
1950
|
-
|
|
1961
|
+
const node = this.store.createNode('three', this.store.rootScene);
|
|
1962
|
+
node.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
1963
|
+
return node;
|
|
1951
1964
|
}
|
|
1952
1965
|
// handle compound
|
|
1953
|
-
if (this.store.isCompound(name))
|
|
1954
|
-
|
|
1966
|
+
if (this.store.isCompound(name)) {
|
|
1967
|
+
const compound = this.store.createNode('compound', element);
|
|
1968
|
+
compound.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
1969
|
+
return compound;
|
|
1970
|
+
}
|
|
1955
1971
|
// handle portal
|
|
1956
1972
|
if (name === SPECIAL_DOM_TAG.NGT_PORTAL) {
|
|
1957
1973
|
return this.store.createNode('portal', element);
|
|
@@ -1991,7 +2007,9 @@ class NgtRenderer {
|
|
|
1991
2007
|
}
|
|
1992
2008
|
return node;
|
|
1993
2009
|
}
|
|
1994
|
-
|
|
2010
|
+
const domNode = this.store.createNode('dom', element);
|
|
2011
|
+
domNode.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */] = () => getDebugNode(element).injector;
|
|
2012
|
+
return domNode;
|
|
1995
2013
|
}
|
|
1996
2014
|
createComment(value) {
|
|
1997
2015
|
const comment = this.delegate.createComment(value);
|
|
@@ -2157,16 +2175,24 @@ class NgtRenderer {
|
|
|
2157
2175
|
}
|
|
2158
2176
|
}
|
|
2159
2177
|
listen(target, eventName, callback) {
|
|
2178
|
+
const targetCdr = target.__ngt_renderer__[13 /* NgtRendererClassId.injectorFactory */]?.().get(ChangeDetectorRef, null);
|
|
2160
2179
|
// if target is DOM node, then we pass that to delegate Renderer
|
|
2161
2180
|
if (this.store.isDOM(target)) {
|
|
2162
|
-
|
|
2181
|
+
const callbackWithCdr = (event) => {
|
|
2182
|
+
const value = callback(event);
|
|
2183
|
+
if (targetCdr)
|
|
2184
|
+
targetCdr.detectChanges();
|
|
2185
|
+
this.store.rootCdr.detectChanges();
|
|
2186
|
+
return value;
|
|
2187
|
+
};
|
|
2188
|
+
return this.delegate.listen(target, eventName, callbackWithCdr);
|
|
2163
2189
|
}
|
|
2164
2190
|
if (target.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'three' ||
|
|
2165
2191
|
(target.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
|
|
2166
2192
|
target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */])) {
|
|
2167
2193
|
const instance = target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */] || target;
|
|
2168
2194
|
const priority = getLocalState(target).priority;
|
|
2169
|
-
return processThreeEvent(instance, priority || 0, eventName, callback, this.store.rootCdr);
|
|
2195
|
+
return processThreeEvent(instance, priority || 0, eventName, callback, this.store.rootCdr, targetCdr);
|
|
2170
2196
|
}
|
|
2171
2197
|
if (target.__ngt_renderer__[0 /* NgtRendererClassId.type */] === 'compound' &&
|
|
2172
2198
|
!target.__ngt_renderer__[6 /* NgtRendererClassId.compounded */]) {
|