angular-three 2.0.0-beta.264 → 2.0.0-beta.266
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/esm2022/index.mjs +2 -1
- package/esm2022/lib/renderer/index.mjs +8 -5
- package/esm2022/lib/renderer/utils.mjs +2 -2
- package/esm2022/lib/utils/apply-props.mjs +8 -3
- package/esm2022/lib/utils/attach.mjs +9 -6
- package/esm2022/lib/utils/object-events.mjs +29 -0
- package/fesm2022/angular-three.mjs +57 -21
- package/fesm2022/angular-three.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/lib/utils/attach.d.ts +2 -2
- package/lib/utils/object-events.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { untracked, computed, signal, ElementRef, input, inject, ViewContainerRef, NgZone, TemplateRef, afterNextRender, DestroyRef, Directive, effect, InjectionToken, getDebugNode, RendererFactory2, Injectable, makeEnvironmentProviders, EnvironmentInjector, Injector, booleanAttribute, output, viewChild, createEnvironmentInjector, Component, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, contentChild } from '@angular/core';
|
|
2
|
+
import { untracked, computed, signal, ElementRef, input, inject, ViewContainerRef, NgZone, TemplateRef, afterNextRender, DestroyRef, Directive, effect, InjectionToken, getDebugNode, RendererFactory2, Injectable, makeEnvironmentProviders, EnvironmentInjector, Injector, booleanAttribute, output, viewChild, createEnvironmentInjector, Component, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, contentChild, Renderer2 } from '@angular/core';
|
|
3
3
|
import { outputFromObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
4
|
import { injectAutoEffect } from 'ngxtension/auto-effect';
|
|
5
5
|
import { provideResizeOptions, NgxResize } from 'ngxtension/resize';
|
|
6
|
-
import { MathUtils, WebGLRenderer, OrthographicCamera, PerspectiveCamera, Vector3, Layers, Color, ColorManagement, Texture, RGBAFormat, UnsignedByteType, Raycaster, Scene, PCFSoftShadowMap, BasicShadowMap, PCFShadowMap, VSMShadowMap, NoToneMapping, ACESFilmicToneMapping, Vector2, Clock } from 'three';
|
|
6
|
+
import { MathUtils, WebGLRenderer, OrthographicCamera, PerspectiveCamera, Vector3, Layers, Color, BufferAttribute, ColorManagement, Texture, RGBAFormat, UnsignedByteType, Raycaster, Scene, PCFSoftShadowMap, BasicShadowMap, PCFShadowMap, VSMShadowMap, NoToneMapping, ACESFilmicToneMapping, Vector2, Clock } from 'three';
|
|
7
7
|
import { DOCUMENT } from '@angular/common';
|
|
8
8
|
import { Subject, filter } from 'rxjs';
|
|
9
9
|
import { createInjectionToken } from 'ngxtension/create-injection-token';
|
|
@@ -876,7 +876,12 @@ function applyProps(instance, props) {
|
|
|
876
876
|
value &&
|
|
877
877
|
value.constructor &&
|
|
878
878
|
targetProp.constructor.name === value.constructor.name) {
|
|
879
|
-
|
|
879
|
+
if (value instanceof BufferAttribute && !value.array) {
|
|
880
|
+
currentInstance[key] = value;
|
|
881
|
+
}
|
|
882
|
+
else {
|
|
883
|
+
targetProp['copy'](value);
|
|
884
|
+
}
|
|
880
885
|
if (!ColorManagement && !rootState.linear && isColor)
|
|
881
886
|
targetProp['convertSRGBToLinear']();
|
|
882
887
|
} // if nothing else fits, just set the single value, ignore undefined
|
|
@@ -1563,23 +1568,26 @@ function removeChild(node, child) {
|
|
|
1563
1568
|
}
|
|
1564
1569
|
}
|
|
1565
1570
|
|
|
1566
|
-
function attach(object, value, paths = []) {
|
|
1571
|
+
function attach(object, value, paths = [], useApplyProps = false) {
|
|
1567
1572
|
const [base, ...remaining] = paths;
|
|
1568
1573
|
if (!base)
|
|
1569
1574
|
return;
|
|
1570
1575
|
if (remaining.length === 0) {
|
|
1571
|
-
|
|
1576
|
+
if (useApplyProps)
|
|
1577
|
+
applyProps(object, { [base]: value });
|
|
1578
|
+
else
|
|
1579
|
+
object[base] = value;
|
|
1572
1580
|
}
|
|
1573
1581
|
else {
|
|
1574
1582
|
assignEmpty(object, base);
|
|
1575
|
-
attach(object[base], value, remaining);
|
|
1583
|
+
attach(object[base], value, remaining, useApplyProps);
|
|
1576
1584
|
}
|
|
1577
1585
|
}
|
|
1578
|
-
function detach(parent, child, attachProp) {
|
|
1586
|
+
function detach(parent, child, attachProp, useApplyProps = false) {
|
|
1579
1587
|
const childLocalState = getLocalState(child);
|
|
1580
1588
|
if (childLocalState) {
|
|
1581
1589
|
if (Array.isArray(attachProp))
|
|
1582
|
-
attach(parent, childLocalState.previousAttach, attachProp);
|
|
1590
|
+
attach(parent, childLocalState.previousAttach, attachProp, childLocalState.isRaw);
|
|
1583
1591
|
else
|
|
1584
1592
|
childLocalState.previousAttach();
|
|
1585
1593
|
}
|
|
@@ -1663,7 +1671,7 @@ function attachThreeChild(parent, child) {
|
|
|
1663
1671
|
// at this point we don't have rawValue yet, so we bail and wait until the Renderer recalls attach
|
|
1664
1672
|
if (child.__ngt_renderer__[4 /* NgtRendererClassId.rawValue */] === undefined)
|
|
1665
1673
|
return;
|
|
1666
|
-
attach(parent, child.__ngt_renderer__[4 /* NgtRendererClassId.rawValue */], attachProp);
|
|
1674
|
+
attach(parent, child.__ngt_renderer__[4 /* NgtRendererClassId.rawValue */], attachProp, true);
|
|
1667
1675
|
}
|
|
1668
1676
|
else {
|
|
1669
1677
|
attach(parent, child, attachProp);
|
|
@@ -1982,9 +1990,10 @@ class NgtRenderer {
|
|
|
1982
1990
|
}
|
|
1983
1991
|
}
|
|
1984
1992
|
insertBefore(parent, newChild) {
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1993
|
+
// NOTE: not sure why this is here. investigate when we have time
|
|
1994
|
+
// if (parent instanceof HTMLElement && (newChild instanceof HTMLElement || newChild instanceof Text)) {
|
|
1995
|
+
// return this.delegate.appendChild(parent, newChild);
|
|
1996
|
+
// }
|
|
1988
1997
|
if (parent == null || !parent.__ngt_renderer__ || parent === newChild)
|
|
1989
1998
|
return;
|
|
1990
1999
|
this.appendChild(parent, newChild);
|
|
@@ -2066,7 +2075,9 @@ class NgtRenderer {
|
|
|
2066
2075
|
}
|
|
2067
2076
|
rS[4 /* NgtRendererClassId.rawValue */] = maybeCoerced;
|
|
2068
2077
|
}
|
|
2069
|
-
|
|
2078
|
+
else {
|
|
2079
|
+
applyProps(el, { [name]: value });
|
|
2080
|
+
}
|
|
2070
2081
|
return false;
|
|
2071
2082
|
}
|
|
2072
2083
|
return true;
|
|
@@ -2855,6 +2866,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.0", ngImpor
|
|
|
2855
2866
|
}]
|
|
2856
2867
|
}], ctorParameters: () => [{ type: i1.Router }, { type: i0.ChangeDetectorRef }] });
|
|
2857
2868
|
|
|
2869
|
+
function resolveRef(ref) {
|
|
2870
|
+
if (is.ref(ref)) {
|
|
2871
|
+
return ref.nativeElement;
|
|
2872
|
+
}
|
|
2873
|
+
return ref;
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
function injectObjectEvents(target, events, { injector } = {}) {
|
|
2877
|
+
return assertInjector(injectObjectEvents, injector, () => {
|
|
2878
|
+
const autoEffect = injectAutoEffect();
|
|
2879
|
+
const renderer = inject(Renderer2);
|
|
2880
|
+
const cleanUps = [];
|
|
2881
|
+
afterNextRender(() => {
|
|
2882
|
+
autoEffect(() => {
|
|
2883
|
+
const targetRef = resolveRef(target());
|
|
2884
|
+
if (!targetRef)
|
|
2885
|
+
return;
|
|
2886
|
+
Object.entries(events).forEach(([eventName, eventHandler]) => {
|
|
2887
|
+
cleanUps.push(renderer.listen(targetRef, eventName, eventHandler));
|
|
2888
|
+
});
|
|
2889
|
+
return () => {
|
|
2890
|
+
cleanUps.forEach((cleanUp) => cleanUp());
|
|
2891
|
+
};
|
|
2892
|
+
});
|
|
2893
|
+
});
|
|
2894
|
+
inject(DestroyRef).onDestroy(() => {
|
|
2895
|
+
cleanUps.forEach((cleanUp) => cleanUp());
|
|
2896
|
+
});
|
|
2897
|
+
return cleanUps;
|
|
2898
|
+
});
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2858
2901
|
function omit(objFn, keysToOmit) {
|
|
2859
2902
|
return computed(() => {
|
|
2860
2903
|
const obj = objFn();
|
|
@@ -2914,16 +2957,9 @@ function vector3(options, key, keepUndefined = false) {
|
|
|
2914
2957
|
}, { equal: (a, b) => !!a && !!b && a.equals(b) });
|
|
2915
2958
|
}
|
|
2916
2959
|
|
|
2917
|
-
function resolveRef(ref) {
|
|
2918
|
-
if (is.ref(ref)) {
|
|
2919
|
-
return ref.nativeElement;
|
|
2920
|
-
}
|
|
2921
|
-
return ref;
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
2960
|
/**
|
|
2925
2961
|
* Generated bundle index. Do not edit.
|
|
2926
2962
|
*/
|
|
2927
2963
|
|
|
2928
|
-
export { HTML, NGT_STORE, NgtArgs, NgtCanvas, NgtHTML, NgtPortal, NgtPortalContent, NgtRenderer, NgtRendererFactory, NgtRoutedScene, ROUTED_SCENE, addAfterEffect, addEffect, addTail, applyProps, checkNeedsUpdate, checkUpdate, createAttachFunction, extend, getLocalState, injectBeforeRender, injectLoader, injectNextBeforeRender, injectStore, invalidateInstance, is, makeCameraInstance, makeDpr, makeId, makeObjectGraph, makeRendererInstance, merge, omit, pick, prepare, provideHTMLDomElement, provideNgtRenderer, provideStore, resolveRef, signalStore, updateCamera, vector2, vector3 };
|
|
2964
|
+
export { HTML, NGT_STORE, NgtArgs, NgtCanvas, NgtHTML, NgtPortal, NgtPortalContent, NgtRenderer, NgtRendererFactory, NgtRoutedScene, ROUTED_SCENE, addAfterEffect, addEffect, addTail, applyProps, checkNeedsUpdate, checkUpdate, createAttachFunction, extend, getLocalState, injectBeforeRender, injectLoader, injectNextBeforeRender, injectObjectEvents, injectStore, invalidateInstance, is, makeCameraInstance, makeDpr, makeId, makeObjectGraph, makeRendererInstance, merge, omit, pick, prepare, provideHTMLDomElement, provideNgtRenderer, provideStore, resolveRef, signalStore, updateCamera, vector2, vector3 };
|
|
2929
2965
|
//# sourceMappingURL=angular-three.mjs.map
|