angular-three 4.0.0-next.99 → 4.0.0
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/README.md +8 -4
- package/dom/README.md +135 -2
- package/fesm2022/angular-three-dom.mjs +138 -37
- package/fesm2022/angular-three-dom.mjs.map +1 -1
- package/fesm2022/angular-three-testing.mjs +45 -8
- package/fesm2022/angular-three-testing.mjs.map +1 -1
- package/fesm2022/angular-three.mjs +3411 -2278
- package/fesm2022/angular-three.mjs.map +1 -1
- package/metadata.json +15960 -22461
- package/package.json +8 -8
- package/testing/README.md +151 -2
- package/types/angular-three-dom.d.ts +154 -0
- package/types/angular-three-testing.d.ts +101 -0
- package/types/angular-three.d.ts +2267 -0
- package/web-types.json +28256 -36522
- package/dom/index.d.ts +0 -2
- package/dom/lib/canvas.d.ts +0 -51
- package/dom/lib/events.d.ts +0 -3
- package/dom/lib/renderer.d.ts +0 -2
- package/index.d.ts +0 -30
- package/lib/directives/args.d.ts +0 -11
- package/lib/directives/common.d.ts +0 -20
- package/lib/directives/parent.d.ts +0 -17
- package/lib/directives/selection.d.ts +0 -18
- package/lib/events.d.ts +0 -7
- package/lib/html.d.ts +0 -15
- package/lib/instance.d.ts +0 -8
- package/lib/loader-resource.d.ts +0 -14
- package/lib/loader.d.ts +0 -42
- package/lib/loop.d.ts +0 -31
- package/lib/pipes/hexify.d.ts +0 -21
- package/lib/portal.d.ts +0 -48
- package/lib/renderer/catalogue.d.ts +0 -6
- package/lib/renderer/constants.d.ts +0 -12
- package/lib/renderer/renderer.d.ts +0 -59
- package/lib/renderer/state.d.ts +0 -65
- package/lib/renderer/utils.d.ts +0 -15
- package/lib/roots.d.ts +0 -9
- package/lib/routed-scene.d.ts +0 -8
- package/lib/store.d.ts +0 -10
- package/lib/three-types.d.ts +0 -224
- package/lib/types.d.ts +0 -316
- package/lib/utils/apply-props.d.ts +0 -10
- package/lib/utils/attach.d.ts +0 -9
- package/lib/utils/before-render.d.ts +0 -29
- package/lib/utils/is.d.ts +0 -24
- package/lib/utils/make.d.ts +0 -13
- package/lib/utils/object-events.d.ts +0 -32
- package/lib/utils/output-ref.d.ts +0 -3
- package/lib/utils/parameters.d.ts +0 -20
- package/lib/utils/resolve-ref.d.ts +0 -2
- package/lib/utils/signal-state.d.ts +0 -27
- package/lib/utils/update.d.ts +0 -4
- package/testing/index.d.ts +0 -2
- package/testing/lib/test-bed.d.ts +0 -41
- package/testing/lib/test-canvas.d.ts +0 -14
- package/testing/lib/utils/mock-canvas.d.ts +0 -5
- package/testing/lib/utils/web-gl-rendering-context.d.ts +0 -16
|
@@ -0,0 +1,2267 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Injector, Signal, WritableSignal, ElementRef, Provider, ProviderToken, Type, AbstractType, InjectionToken, ResourceRef, RendererFactory2, RendererType2, Renderer2, ChangeDetectorRef, InjectOptions, OutputEmitterRef, ValueEqualityFn } from '@angular/core';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
import { Object3D } from 'three';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
6
|
+
import { Router } from '@angular/router';
|
|
7
|
+
import * as angular_three from 'angular-three';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Abstract base class for Angular Three structural directives.
|
|
11
|
+
*
|
|
12
|
+
* This class provides common functionality for structural directives like `NgtArgs` and `NgtParent`,
|
|
13
|
+
* including view management, value injection, and change detection.
|
|
14
|
+
*
|
|
15
|
+
* Subclasses must implement:
|
|
16
|
+
* - `validate()`: Returns true if the directive has a valid value to inject
|
|
17
|
+
* - `linkedValue`: A signal containing the current value
|
|
18
|
+
* - `shouldSkipRender`: A signal indicating whether rendering should be skipped
|
|
19
|
+
*
|
|
20
|
+
* @typeParam TValue - The type of value this directive manages
|
|
21
|
+
*/
|
|
22
|
+
declare abstract class NgtCommonDirective<TValue> {
|
|
23
|
+
private vcr;
|
|
24
|
+
private template;
|
|
25
|
+
protected injector: Injector;
|
|
26
|
+
protected injected: boolean;
|
|
27
|
+
protected injectedValue: TValue | null;
|
|
28
|
+
private view?;
|
|
29
|
+
protected get commentNode(): any;
|
|
30
|
+
abstract validate(): boolean;
|
|
31
|
+
protected abstract linkedValue: Signal<TValue | null>;
|
|
32
|
+
protected abstract shouldSkipRender: Signal<boolean>;
|
|
33
|
+
protected constructor();
|
|
34
|
+
get value(): TValue | null;
|
|
35
|
+
protected beforeCreateView(): void;
|
|
36
|
+
private createView;
|
|
37
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtCommonDirective<any>, never>;
|
|
38
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtCommonDirective<any>, never, never, {}, {}, never, never, true, never>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Structural directive for passing constructor arguments to Three.js elements.
|
|
43
|
+
*
|
|
44
|
+
* The `NgtArgs` directive allows you to pass constructor arguments to Three.js objects
|
|
45
|
+
* when they are created. This is essential for objects that require constructor arguments
|
|
46
|
+
* like geometries, materials, and custom objects.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```html
|
|
50
|
+
* <!-- Pass arguments to BoxGeometry constructor -->
|
|
51
|
+
* <ngt-mesh>
|
|
52
|
+
* <ngt-box-geometry *args="[1, 2, 3]" />
|
|
53
|
+
* </ngt-mesh>
|
|
54
|
+
*
|
|
55
|
+
* <!-- Use with primitive for external objects -->
|
|
56
|
+
* <ngt-primitive *args="[myObject]" />
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare class NgtArgs extends NgtCommonDirective<any[]> {
|
|
60
|
+
args: _angular_core.InputSignal<any[] | null>;
|
|
61
|
+
protected linkedValue: _angular_core.WritableSignal<any[] | null>;
|
|
62
|
+
protected shouldSkipRender: _angular_core.Signal<boolean>;
|
|
63
|
+
constructor();
|
|
64
|
+
validate(): boolean;
|
|
65
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtArgs, never>;
|
|
66
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtArgs, "ng-template[args]", never, { "args": { "alias": "args"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type NgtNonFunctionKeys<T> = {
|
|
70
|
+
[K in keyof T]-?: T[K] extends Function ? never : K;
|
|
71
|
+
}[keyof T];
|
|
72
|
+
type NgtOverwrite<T, O> = Omit<T, NgtNonFunctionKeys<O>> & O;
|
|
73
|
+
type NgtProperties<T> = Pick<T, NgtNonFunctionKeys<T>>;
|
|
74
|
+
type NgtMutable<P> = {
|
|
75
|
+
[K in keyof P]: P[K] extends Array<any> ? P[K] : P[K] | Readonly<P[K]>;
|
|
76
|
+
};
|
|
77
|
+
interface NgtMathRepresentation {
|
|
78
|
+
set(...args: number[]): any;
|
|
79
|
+
}
|
|
80
|
+
interface NgtVectorRepresentation extends NgtMathRepresentation {
|
|
81
|
+
setScalar(value: number): any;
|
|
82
|
+
}
|
|
83
|
+
type NgtMathTypes = NgtMathRepresentation | THREE.Euler | THREE.Color;
|
|
84
|
+
type NgtMathType<T extends NgtMathTypes> = T extends THREE.Color ? NgtArguments<typeof THREE.Color> | THREE.ColorRepresentation : T extends NgtVectorRepresentation | THREE.Layers | THREE.Euler ? T | Parameters<T['set']> | number : T | Parameters<T['set']>;
|
|
85
|
+
type NgtMathProperties<P> = {
|
|
86
|
+
[K in keyof P as P[K] extends NgtMathTypes ? K : never]: P[K] extends NgtMathTypes ? NgtMathType<P[K]> : never;
|
|
87
|
+
};
|
|
88
|
+
type NgtIsProperties<P> = {
|
|
89
|
+
[K in keyof P as P[K] extends true ? K : never]: true;
|
|
90
|
+
};
|
|
91
|
+
type NgtNonMutableProperties = 'id' | 'uuid' | 'name' | 'type' | 'parent' | 'children';
|
|
92
|
+
type NgtNonPartialProperties<P> = {
|
|
93
|
+
[K in keyof P as K extends NgtNonMutableProperties ? K : never]: P[K];
|
|
94
|
+
};
|
|
95
|
+
type NgtNullableRaycast<P> = {
|
|
96
|
+
[K in keyof P as K extends 'raycast' ? K : never]: K extends 'raycast' ? P[K] | null : never;
|
|
97
|
+
};
|
|
98
|
+
type NgtVector2 = NgtMathType<THREE.Vector2>;
|
|
99
|
+
type NgtVector3 = NgtMathType<THREE.Vector3>;
|
|
100
|
+
type NgtVector4 = NgtMathType<THREE.Vector4>;
|
|
101
|
+
type NgtColor = NgtMathType<THREE.Color>;
|
|
102
|
+
type NgtLayers = NgtMathType<THREE.Layers>;
|
|
103
|
+
type NgtQuaternion = NgtMathType<THREE.Quaternion>;
|
|
104
|
+
type NgtEuler = NgtMathType<THREE.Euler>;
|
|
105
|
+
type NgtMatrix3 = NgtMathType<THREE.Matrix3>;
|
|
106
|
+
type NgtMatrix4 = NgtMathType<THREE.Matrix4>;
|
|
107
|
+
interface NgtRaycastableRepresentation {
|
|
108
|
+
raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
|
|
109
|
+
}
|
|
110
|
+
type ThreeDisposeEvent = {
|
|
111
|
+
type: 'dispose';
|
|
112
|
+
target: any;
|
|
113
|
+
};
|
|
114
|
+
type ThreeChangeEvent = {
|
|
115
|
+
type: 'change';
|
|
116
|
+
target: any;
|
|
117
|
+
};
|
|
118
|
+
type ThreeAddedEvent = {
|
|
119
|
+
type: 'added';
|
|
120
|
+
target: any;
|
|
121
|
+
};
|
|
122
|
+
type ThreeRemovedEvent = {
|
|
123
|
+
type: 'removed';
|
|
124
|
+
target: any;
|
|
125
|
+
};
|
|
126
|
+
type ThreeChildAddedEvent = {
|
|
127
|
+
type: 'childadded';
|
|
128
|
+
target: any;
|
|
129
|
+
child: any;
|
|
130
|
+
};
|
|
131
|
+
type ThreeChildRemovedEvent = {
|
|
132
|
+
type: 'childremoved';
|
|
133
|
+
target: any;
|
|
134
|
+
child: any;
|
|
135
|
+
};
|
|
136
|
+
interface NgtNodeEventMap<TInstance = NgtAnyRecord> {
|
|
137
|
+
attached: NgtAfterAttach<TInstance, any>;
|
|
138
|
+
updated: TInstance;
|
|
139
|
+
created: TInstance;
|
|
140
|
+
disposed: ThreeDisposeEvent;
|
|
141
|
+
}
|
|
142
|
+
type NgtObject3DEventsMap = {
|
|
143
|
+
[TEvent in keyof NgtEventHandlers]-?: Parameters<NonNullable<NgtEventHandlers[TEvent]>>[0];
|
|
144
|
+
} & {
|
|
145
|
+
added: ThreeAddedEvent;
|
|
146
|
+
removed: ThreeRemovedEvent;
|
|
147
|
+
childadded: ThreeChildAddedEvent;
|
|
148
|
+
childremoved: ThreeChildRemovedEvent;
|
|
149
|
+
change: ThreeChangeEvent;
|
|
150
|
+
};
|
|
151
|
+
type NgtAllObject3DEventsMap<TInstance> = NgtObject3DEventsMap & NgtNodeEventMap<TInstance>;
|
|
152
|
+
interface NgtNodeElement<TConstructor extends NgtConstructorRepresentation, TInstance = InstanceType<TConstructor>> {
|
|
153
|
+
attach: string | string[] | NgtAttachFunction;
|
|
154
|
+
dispose?: (() => void) | null;
|
|
155
|
+
parameters: Partial<TInstance>;
|
|
156
|
+
__ngt_args__?: NgtArguments<TConstructor>;
|
|
157
|
+
}
|
|
158
|
+
interface NgtNodeEventListener<TConstructor extends NgtConstructorRepresentation, TInstance = InstanceType<TConstructor>, TEventMap extends NgtNodeEventMap<TInstance> = TInstance extends NgtRaycastableRepresentation ? NgtAllObject3DEventsMap<TInstance> : NgtNodeEventMap<TInstance>> {
|
|
159
|
+
addEventListener<TEventKey extends keyof TEventMap>(type: TEventKey, listener: (this: NgtNodeElement<TConstructor, TInstance>, ev: TEventMap[TEventKey]) => any): void;
|
|
160
|
+
removeEventListener<TEventKey extends keyof TEventMap>(type: TEventKey, listener: (this: NgtNodeElement<TConstructor, TInstance>, ev: TEventMap[TEventKey]) => any): void;
|
|
161
|
+
}
|
|
162
|
+
type NgtElementProperties<TConstructor extends NgtConstructorRepresentation, TInstance = InstanceType<TConstructor>> = Partial<NgtOverwrite<TInstance, NgtMathProperties<TInstance> & NgtNullableRaycast<TInstance>>> & NgtIsProperties<TInstance> & NgtNonPartialProperties<TInstance> & NgtNodeElement<TConstructor, TInstance>;
|
|
163
|
+
type NgtThreeElement<TConstructor extends NgtConstructorRepresentation> = NgtMutable<NgtElementProperties<TConstructor>> & NgtNodeEventListener<TConstructor>;
|
|
164
|
+
type ThreeExports = typeof THREE;
|
|
165
|
+
type NgtThreeElementsImpl = {
|
|
166
|
+
[K in keyof ThreeExports]: ThreeExports[K] extends NgtConstructorRepresentation ? NgtThreeElement<ThreeExports[K]> : never;
|
|
167
|
+
};
|
|
168
|
+
interface NgtThreeElements {
|
|
169
|
+
'ngt-scene': NgtThreeElementsImpl['Scene'];
|
|
170
|
+
'ngt-object3D': NgtThreeElementsImpl['Object3D'];
|
|
171
|
+
'ngt-lOD': NgtThreeElementsImpl['LOD'];
|
|
172
|
+
'ngt-mesh': NgtThreeElementsImpl['Mesh'];
|
|
173
|
+
'ngt-instanced-mesh': NgtThreeElementsImpl['InstancedMesh'];
|
|
174
|
+
'ngt-skinned-mesh': NgtThreeElementsImpl['SkinnedMesh'];
|
|
175
|
+
'ngt-bone': NgtThreeElementsImpl['Bone'];
|
|
176
|
+
'ngt-material': NgtThreeElementsImpl['Material'];
|
|
177
|
+
'ngt-mesh-basic-material': NgtThreeElementsImpl['MeshBasicMaterial'];
|
|
178
|
+
'ngt-mesh-physical-material': NgtThreeElementsImpl['MeshPhysicalMaterial'];
|
|
179
|
+
'ngt-mesh-standard-material': NgtThreeElementsImpl['MeshStandardMaterial'];
|
|
180
|
+
'ngt-mesh-toon-material': NgtThreeElementsImpl['MeshToonMaterial'];
|
|
181
|
+
'ngt-mesh-normal-material': NgtThreeElementsImpl['MeshNormalMaterial'];
|
|
182
|
+
'ngt-mesh-depth-material': NgtThreeElementsImpl['MeshDepthMaterial'];
|
|
183
|
+
'ngt-mesh-distance-material': NgtThreeElementsImpl['MeshDistanceMaterial'];
|
|
184
|
+
'ngt-mesh-matcap-material': NgtThreeElementsImpl['MeshMatcapMaterial'];
|
|
185
|
+
'ngt-mesh-phong-material': NgtThreeElementsImpl['MeshPhongMaterial'];
|
|
186
|
+
'ngt-line-basic-material': NgtThreeElementsImpl['LineBasicMaterial'];
|
|
187
|
+
'ngt-line-dashed-material': NgtThreeElementsImpl['LineDashedMaterial'];
|
|
188
|
+
'ngt-mesh-lambert-material': NgtThreeElementsImpl['MeshLambertMaterial'];
|
|
189
|
+
'ngt-points-material': NgtThreeElementsImpl['PointsMaterial'];
|
|
190
|
+
'ngt-raw-shader-material': NgtThreeElementsImpl['RawShaderMaterial'];
|
|
191
|
+
'ngt-shader-material': NgtThreeElementsImpl['ShaderMaterial'];
|
|
192
|
+
'ngt-shadow-material': NgtThreeElementsImpl['ShadowMaterial'];
|
|
193
|
+
'ngt-sprite-material': NgtThreeElementsImpl['SpriteMaterial'];
|
|
194
|
+
'ngt-instanced-buffer-geometry': NgtThreeElementsImpl['InstancedBufferGeometry'];
|
|
195
|
+
'ngt-buffer-geometry': NgtThreeElementsImpl['BufferGeometry'];
|
|
196
|
+
'ngt-wireframe-geometry': NgtThreeElementsImpl['WireframeGeometry'];
|
|
197
|
+
'ngt-box-geometry': NgtThreeElementsImpl['BoxGeometry'];
|
|
198
|
+
'ngt-extrude-geometry': NgtThreeElementsImpl['ExtrudeGeometry'];
|
|
199
|
+
'ngt-shape-geometry': NgtThreeElementsImpl['ShapeGeometry'];
|
|
200
|
+
'ngt-circle-geometry': NgtThreeElementsImpl['CircleGeometry'];
|
|
201
|
+
'ngt-cylinder-geometry': NgtThreeElementsImpl['CylinderGeometry'];
|
|
202
|
+
'ngt-capsule-geometry': NgtThreeElementsImpl['CapsuleGeometry'];
|
|
203
|
+
'ngt-cone-geometry': NgtThreeElementsImpl['ConeGeometry'];
|
|
204
|
+
'ngt-edges-geometry': NgtThreeElementsImpl['EdgesGeometry'];
|
|
205
|
+
'ngt-tetrahedron-geometry': NgtThreeElementsImpl['TetrahedronGeometry'];
|
|
206
|
+
'ngt-octahedron-geometry': NgtThreeElementsImpl['OctahedronGeometry'];
|
|
207
|
+
'ngt-icosahedron-geometry': NgtThreeElementsImpl['IcosahedronGeometry'];
|
|
208
|
+
'ngt-polyhedron-geometry': NgtThreeElementsImpl['PolyhedronGeometry'];
|
|
209
|
+
'ngt-dodecahedron-geometry': NgtThreeElementsImpl['DodecahedronGeometry'];
|
|
210
|
+
'ngt-tube-geometry': NgtThreeElementsImpl['TubeGeometry'];
|
|
211
|
+
'ngt-torus-knot-geometry': NgtThreeElementsImpl['TorusKnotGeometry'];
|
|
212
|
+
'ngt-torus-geometry': NgtThreeElementsImpl['TorusGeometry'];
|
|
213
|
+
'ngt-sphere-geometry': NgtThreeElementsImpl['SphereGeometry'];
|
|
214
|
+
'ngt-ring-geometry': NgtThreeElementsImpl['RingGeometry'];
|
|
215
|
+
'ngt-plane-geometry': NgtThreeElementsImpl['PlaneGeometry'];
|
|
216
|
+
'ngt-lathe-geometry': NgtThreeElementsImpl['LatheGeometry'];
|
|
217
|
+
'ngt-line': NgtThreeElementsImpl['Line'];
|
|
218
|
+
'ngt-line-segments': NgtThreeElementsImpl['LineSegments'];
|
|
219
|
+
'ngt-line-loop': NgtThreeElementsImpl['LineLoop'];
|
|
220
|
+
'ngt-points': NgtThreeElementsImpl['Points'];
|
|
221
|
+
'ngt-group': NgtThreeElementsImpl['Group'];
|
|
222
|
+
'ngt-camera': NgtThreeElementsImpl['Camera'];
|
|
223
|
+
'ngt-perspective-camera': NgtThreeElementsImpl['PerspectiveCamera'];
|
|
224
|
+
'ngt-orthographic-camera': NgtThreeElementsImpl['OrthographicCamera'];
|
|
225
|
+
'ngt-cube-camera': NgtThreeElementsImpl['CubeCamera'];
|
|
226
|
+
'ngt-array-camera': NgtThreeElementsImpl['ArrayCamera'];
|
|
227
|
+
'ngt-spot-light': NgtThreeElementsImpl['SpotLight'];
|
|
228
|
+
'ngt-point-light': NgtThreeElementsImpl['PointLight'];
|
|
229
|
+
'ngt-rect-area-light': NgtThreeElementsImpl['RectAreaLight'];
|
|
230
|
+
'ngt-hemisphere-light': NgtThreeElementsImpl['HemisphereLight'];
|
|
231
|
+
'ngt-directional-light': NgtThreeElementsImpl['DirectionalLight'];
|
|
232
|
+
'ngt-ambient-light': NgtThreeElementsImpl['AmbientLight'];
|
|
233
|
+
'ngt-light-probe': NgtThreeElementsImpl['LightProbe'];
|
|
234
|
+
'ngt-spot-light-helper': NgtThreeElementsImpl['SpotLightHelper'];
|
|
235
|
+
'ngt-skeleton-helper': NgtThreeElementsImpl['SkeletonHelper'];
|
|
236
|
+
'ngt-point-light-helper': NgtThreeElementsImpl['PointLightHelper'];
|
|
237
|
+
'ngt-hemisphere-light-helper': NgtThreeElementsImpl['HemisphereLightHelper'];
|
|
238
|
+
'ngt-grid-helper': NgtThreeElementsImpl['GridHelper'];
|
|
239
|
+
'ngt-polar-grid-helper': NgtThreeElementsImpl['PolarGridHelper'];
|
|
240
|
+
'ngt-directional-light-helper': NgtThreeElementsImpl['DirectionalLightHelper'];
|
|
241
|
+
'ngt-camera-helper': NgtThreeElementsImpl['CameraHelper'];
|
|
242
|
+
'ngt-box-helper': NgtThreeElementsImpl['BoxHelper'];
|
|
243
|
+
'ngt-box3-helper': NgtThreeElementsImpl['Box3Helper'];
|
|
244
|
+
'ngt-plane-helper': NgtThreeElementsImpl['PlaneHelper'];
|
|
245
|
+
'ngt-arrow-helper': NgtThreeElementsImpl['ArrowHelper'];
|
|
246
|
+
'ngt-axes-helper': NgtThreeElementsImpl['AxesHelper'];
|
|
247
|
+
'ngt-audio': NgtThreeElementsImpl['Audio'];
|
|
248
|
+
'ngt-positional-audio': NgtThreeElementsImpl['PositionalAudio'];
|
|
249
|
+
'ngt-audio-listener': NgtThreeElementsImpl['AudioListener'];
|
|
250
|
+
'ngt-texture': NgtThreeElementsImpl['Texture'];
|
|
251
|
+
'ngt-compressed-texture': NgtThreeElementsImpl['CompressedTexture'];
|
|
252
|
+
'ngt-video-texture': NgtThreeElementsImpl['VideoTexture'];
|
|
253
|
+
'ngt-data-texture': NgtThreeElementsImpl['DataTexture'];
|
|
254
|
+
'ngt-data3D-texture': NgtThreeElementsImpl['Data3DTexture'];
|
|
255
|
+
'ngt-cube-texture': NgtThreeElementsImpl['CubeTexture'];
|
|
256
|
+
'ngt-canvas-texture': NgtThreeElementsImpl['CanvasTexture'];
|
|
257
|
+
'ngt-depth-texture': NgtThreeElementsImpl['DepthTexture'];
|
|
258
|
+
'ngt-raycaster': NgtThreeElementsImpl['Raycaster'];
|
|
259
|
+
'ngt-sprite': NgtThreeElementsImpl['Sprite'];
|
|
260
|
+
'ngt-vector2': NgtThreeElementsImpl['Vector2'];
|
|
261
|
+
'ngt-vector3': NgtThreeElementsImpl['Vector3'];
|
|
262
|
+
'ngt-vector4': NgtThreeElementsImpl['Vector4'];
|
|
263
|
+
'ngt-euler': NgtThreeElementsImpl['Euler'];
|
|
264
|
+
'ngt-matrix3': NgtThreeElementsImpl['Matrix3'];
|
|
265
|
+
'ngt-matrix4': NgtThreeElementsImpl['Matrix4'];
|
|
266
|
+
'ngt-quaternion': NgtThreeElementsImpl['Quaternion'];
|
|
267
|
+
'ngt-buffer-attribute': NgtThreeElementsImpl['BufferAttribute'];
|
|
268
|
+
'ngt-float16-buffer-attribute': NgtThreeElementsImpl['Float16BufferAttribute'];
|
|
269
|
+
'ngt-float32-buffer-attribute': NgtThreeElementsImpl['Float32BufferAttribute'];
|
|
270
|
+
'ngt-int8-buffer-attribute': NgtThreeElementsImpl['Int8BufferAttribute'];
|
|
271
|
+
'ngt-int16-buffer-attribute': NgtThreeElementsImpl['Int16BufferAttribute'];
|
|
272
|
+
'ngt-int32-buffer-attribute': NgtThreeElementsImpl['Int32BufferAttribute'];
|
|
273
|
+
'ngt-uint8-buffer-attribute': NgtThreeElementsImpl['Uint8BufferAttribute'];
|
|
274
|
+
'ngt-uint16-buffer-attribute': NgtThreeElementsImpl['Uint16BufferAttribute'];
|
|
275
|
+
'ngt-uint32-buffer-attribute': NgtThreeElementsImpl['Uint32BufferAttribute'];
|
|
276
|
+
'ngt-instanced-buffer-attribute': NgtThreeElementsImpl['InstancedBufferAttribute'];
|
|
277
|
+
'ngt-color': NgtThreeElementsImpl['Color'];
|
|
278
|
+
'ngt-fog': NgtThreeElementsImpl['Fog'];
|
|
279
|
+
'ngt-fog-exp2': NgtThreeElementsImpl['FogExp2'];
|
|
280
|
+
'ngt-shape': NgtThreeElementsImpl['Shape'];
|
|
281
|
+
'ngt-primitive': NgtThreeElement<any>;
|
|
282
|
+
'ngt-value': NgtThreeElement<any> & {
|
|
283
|
+
rawValue: any;
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
declare global {
|
|
287
|
+
interface HTMLElementTagNameMap extends NgtThreeElements {
|
|
288
|
+
}
|
|
289
|
+
interface HTMLElementEventMap extends NgtAllObject3DEventsMap<any> {
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @fileoverview Signal-based state management ported from ngrx/signals.
|
|
295
|
+
*
|
|
296
|
+
* This module provides a reactive state management solution using Angular signals.
|
|
297
|
+
* It supports deep signal access for nested state properties and efficient state updates.
|
|
298
|
+
*
|
|
299
|
+
* Ported from ngrx/signals. Last synced: 08/16/2025
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
type NonRecord = Iterable<any> | WeakSet<any> | WeakMap<any, any> | Promise<any> | Date | Error | RegExp | ArrayBuffer | DataView | Function;
|
|
303
|
+
type Prettify<T> = {
|
|
304
|
+
[K in keyof T]: T[K];
|
|
305
|
+
} & {};
|
|
306
|
+
type IsRecord<T> = T extends object ? (T extends NonRecord ? false : true) : false;
|
|
307
|
+
type IsUnknownRecord<T> = string extends keyof T ? true : number extends keyof T ? true : false;
|
|
308
|
+
type IsKnownRecord<T> = IsRecord<T> extends true ? (IsUnknownRecord<T> extends true ? false : true) : false;
|
|
309
|
+
declare const STATE_SOURCE: unique symbol;
|
|
310
|
+
/**
|
|
311
|
+
* Type representing a writable state source with signals for each property.
|
|
312
|
+
*/
|
|
313
|
+
type WritableStateSource<State extends object> = {
|
|
314
|
+
[STATE_SOURCE]: {
|
|
315
|
+
[K in keyof State]: WritableSignal<State[K]>;
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Type representing a readonly state source with signals for each property.
|
|
320
|
+
*/
|
|
321
|
+
type StateSource<State extends object> = {
|
|
322
|
+
[STATE_SOURCE]: {
|
|
323
|
+
[K in keyof State]: Signal<State[K]>;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Function type for partial state updates.
|
|
328
|
+
*/
|
|
329
|
+
type PartialStateUpdater<State extends object> = (state: State) => Partial<State>;
|
|
330
|
+
/**
|
|
331
|
+
* A signal that provides deep access to nested properties as signals.
|
|
332
|
+
*
|
|
333
|
+
* Allows accessing nested properties directly on the signal, e.g., `state.user.name()`
|
|
334
|
+
* instead of `state().user.name`.
|
|
335
|
+
*/
|
|
336
|
+
type DeepSignal<T> = Signal<T> & (IsKnownRecord<T> extends true ? Readonly<{
|
|
337
|
+
[K in keyof T]: IsKnownRecord<T[K]> extends true ? DeepSignal<T[K]> : Signal<T[K]>;
|
|
338
|
+
}> : unknown);
|
|
339
|
+
/**
|
|
340
|
+
* Converts a regular signal to a deep signal that allows nested property access.
|
|
341
|
+
*
|
|
342
|
+
* @typeParam T - The type of the signal's value
|
|
343
|
+
* @param signal - The signal to convert
|
|
344
|
+
* @returns A DeepSignal with nested property access
|
|
345
|
+
*/
|
|
346
|
+
declare function toDeepSignal<T>(signal: Signal<T>): DeepSignal<T>;
|
|
347
|
+
/**
|
|
348
|
+
* A reactive state container built on Angular signals.
|
|
349
|
+
*
|
|
350
|
+
* Provides deep signal access to nested properties, an update method for
|
|
351
|
+
* modifying state, and a snapshot getter for non-reactive access.
|
|
352
|
+
*/
|
|
353
|
+
type SignalState<State extends object> = DeepSignal<State> & WritableStateSource<State> & {
|
|
354
|
+
/** Updates the state with partial updates or updater functions */
|
|
355
|
+
update: (...updaters: Array<Partial<Prettify<State>> | PartialStateUpdater<Prettify<State>>>) => void;
|
|
356
|
+
/** Gets the current state value without triggering reactivity */
|
|
357
|
+
get snapshot(): State;
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* Creates a reactive state container from an initial state object.
|
|
361
|
+
*
|
|
362
|
+
* The returned SignalState provides:
|
|
363
|
+
* - Deep signal access to nested properties (e.g., `state.camera()`)
|
|
364
|
+
* - An `update` method for modifying state
|
|
365
|
+
* - A `snapshot` getter for non-reactive access
|
|
366
|
+
*
|
|
367
|
+
* @typeParam State - The shape of the state object
|
|
368
|
+
* @param initialState - The initial state values
|
|
369
|
+
* @returns A SignalState instance
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* const store = signalState({
|
|
374
|
+
* camera: null,
|
|
375
|
+
* scene: null,
|
|
376
|
+
* size: { width: 0, height: 0 }
|
|
377
|
+
* });
|
|
378
|
+
*
|
|
379
|
+
* // Access reactively
|
|
380
|
+
* const width = store.size.width();
|
|
381
|
+
*
|
|
382
|
+
* // Update state
|
|
383
|
+
* store.update({ camera: new THREE.PerspectiveCamera() });
|
|
384
|
+
*
|
|
385
|
+
* // Access snapshot
|
|
386
|
+
* const { scene } = store.snapshot;
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
declare function signalState<State extends object>(initialState: State): SignalState<State>;
|
|
390
|
+
|
|
391
|
+
type NgtArguments<T> = T extends NgtConstructorRepresentation ? T extends typeof THREE.Color ? [r: number, g: number, b: number] | [color: THREE.ColorRepresentation] : ConstructorParameters<T> : any[];
|
|
392
|
+
type NgtConstructorRepresentation<T = any> = new (...args: any[]) => T;
|
|
393
|
+
type NgtAnyRecord = Record<string, any>;
|
|
394
|
+
type NgtNullish<T> = T | null | undefined;
|
|
395
|
+
interface NgtDisposable {
|
|
396
|
+
type?: string;
|
|
397
|
+
dispose?: () => void;
|
|
398
|
+
}
|
|
399
|
+
interface NgtEquConfig {
|
|
400
|
+
/** Compare arrays by reference equality a === b (default), or by shallow equality */
|
|
401
|
+
arrays?: 'reference' | 'shallow';
|
|
402
|
+
/** Compare objects by reference equality a === b (default), or by shallow equality */
|
|
403
|
+
objects?: 'reference' | 'shallow';
|
|
404
|
+
/** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
|
|
405
|
+
strict?: boolean;
|
|
406
|
+
}
|
|
407
|
+
type NgtCameraLike = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
408
|
+
type NgtCamera = NgtCameraLike & {
|
|
409
|
+
manual?: boolean;
|
|
410
|
+
};
|
|
411
|
+
type NgtCameraParameters = Partial<NgtThreeElement<typeof THREE.Camera> & NgtThreeElement<typeof THREE.PerspectiveCamera> & NgtThreeElement<typeof THREE.OrthographicCamera>> & {
|
|
412
|
+
manual?: boolean;
|
|
413
|
+
};
|
|
414
|
+
interface NgtRendererLike {
|
|
415
|
+
render: (scene: THREE.Scene, camera: THREE.Camera) => any;
|
|
416
|
+
dispose?: () => void;
|
|
417
|
+
}
|
|
418
|
+
type NgtCanvasElement = HTMLCanvasElement | OffscreenCanvas;
|
|
419
|
+
type NgtGlobalRenderCallback = (timeStamp: number) => void;
|
|
420
|
+
type NgtGLDefaultOptions = Omit<THREE.WebGLRendererParameters, 'canvas'> & {
|
|
421
|
+
canvas: NgtCanvasElement;
|
|
422
|
+
};
|
|
423
|
+
type NgtGLOptions = NgtRendererLike | ((defaultGLOptions: NgtGLDefaultOptions) => NgtRendererLike) | Partial<NgtProperties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> | undefined;
|
|
424
|
+
type NgtDpr = number | [min: number, max: number];
|
|
425
|
+
interface NgtSize {
|
|
426
|
+
width: number;
|
|
427
|
+
height: number;
|
|
428
|
+
top: number;
|
|
429
|
+
left: number;
|
|
430
|
+
}
|
|
431
|
+
interface NgtViewport extends NgtSize {
|
|
432
|
+
/** The initial pixel ratio */
|
|
433
|
+
initialDpr: number;
|
|
434
|
+
/** Current pixel ratio */
|
|
435
|
+
dpr: number;
|
|
436
|
+
/** size.width / viewport.width */
|
|
437
|
+
factor: number;
|
|
438
|
+
/** Camera distance */
|
|
439
|
+
distance: number;
|
|
440
|
+
/** Camera aspect ratio: width / height */
|
|
441
|
+
aspect: number;
|
|
442
|
+
}
|
|
443
|
+
type NgtShadows = boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>;
|
|
444
|
+
type NgtFrameloop = 'always' | 'demand' | 'never';
|
|
445
|
+
interface NgtPerformance {
|
|
446
|
+
/** Current performance normal, between min and max */
|
|
447
|
+
current: number;
|
|
448
|
+
/** How low the performance can go, between 0 and max */
|
|
449
|
+
min: number;
|
|
450
|
+
/** How high the performance can go, between min and max */
|
|
451
|
+
max: number;
|
|
452
|
+
/** Time until current returns to max in ms */
|
|
453
|
+
debounce: number;
|
|
454
|
+
/** Sets current to min, puts the system in regression */
|
|
455
|
+
regress: () => void;
|
|
456
|
+
}
|
|
457
|
+
type NgtEventPrefix = 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
458
|
+
interface NgtIntersection extends THREE.Intersection {
|
|
459
|
+
/** The event source (the object which registered the handler) */
|
|
460
|
+
eventObject: THREE.Object3D;
|
|
461
|
+
}
|
|
462
|
+
interface NgtIntersectionEvent<TSourceEvent> extends NgtIntersection {
|
|
463
|
+
/** The event source (the object which registered the handler) */
|
|
464
|
+
eventObject: THREE.Object3D;
|
|
465
|
+
/** An array of intersections */
|
|
466
|
+
intersections: NgtIntersection[];
|
|
467
|
+
/** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
|
|
468
|
+
unprojectedPoint: THREE.Vector3;
|
|
469
|
+
/** Normalized event coordinates */
|
|
470
|
+
pointer: THREE.Vector2;
|
|
471
|
+
/** Delta between first click and this event */
|
|
472
|
+
delta: number;
|
|
473
|
+
/** The ray that pierced it */
|
|
474
|
+
ray: THREE.Ray;
|
|
475
|
+
/** The camera that was used by the raycaster */
|
|
476
|
+
camera: NgtCamera;
|
|
477
|
+
/** stopPropagation will stop underlying handlers from firing */
|
|
478
|
+
stopPropagation: () => void;
|
|
479
|
+
/** The original host event */
|
|
480
|
+
nativeEvent: TSourceEvent;
|
|
481
|
+
/** If the event was stopped by calling stopPropagation */
|
|
482
|
+
stopped: boolean;
|
|
483
|
+
}
|
|
484
|
+
type NgtThreeEvent<TEvent> = NgtIntersectionEvent<TEvent> & NgtProperties<TEvent>;
|
|
485
|
+
type NgtDomEvent = PointerEvent | MouseEvent | WheelEvent;
|
|
486
|
+
interface NgtEventHandlers {
|
|
487
|
+
click?: (event: NgtThreeEvent<MouseEvent>) => void;
|
|
488
|
+
contextmenu?: (event: NgtThreeEvent<MouseEvent>) => void;
|
|
489
|
+
dblclick?: (event: NgtThreeEvent<MouseEvent>) => void;
|
|
490
|
+
pointerup?: (event: NgtThreeEvent<PointerEvent>) => void;
|
|
491
|
+
pointerdown?: (event: NgtThreeEvent<PointerEvent>) => void;
|
|
492
|
+
pointerover?: (event: NgtThreeEvent<PointerEvent>) => void;
|
|
493
|
+
pointerout?: (event: NgtThreeEvent<PointerEvent>) => void;
|
|
494
|
+
pointerenter?: (event: NgtThreeEvent<PointerEvent>) => void;
|
|
495
|
+
pointerleave?: (event: NgtThreeEvent<PointerEvent>) => void;
|
|
496
|
+
pointermove?: (event: NgtThreeEvent<PointerEvent>) => void;
|
|
497
|
+
pointermissed?: (event: MouseEvent) => void;
|
|
498
|
+
pointercancel?: (event: NgtThreeEvent<PointerEvent>) => void;
|
|
499
|
+
wheel?: (event: NgtThreeEvent<WheelEvent>) => void;
|
|
500
|
+
}
|
|
501
|
+
type NgtEvents = {
|
|
502
|
+
[TEvent in keyof NgtEventHandlers]-?: EventListener;
|
|
503
|
+
};
|
|
504
|
+
type NgtFilterFunction = (items: THREE.Intersection[], store: SignalState<NgtState>) => THREE.Intersection[];
|
|
505
|
+
type NgtComputeFunction = (event: NgtDomEvent, root: SignalState<NgtState>, previous: SignalState<NgtState> | null) => void;
|
|
506
|
+
interface NgtEventManager<TTarget> {
|
|
507
|
+
/** Determines if the event layer is active */
|
|
508
|
+
enabled: boolean;
|
|
509
|
+
/** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
|
|
510
|
+
priority: number;
|
|
511
|
+
/** The compute function needs to set up the raycaster and an xy- pointer */
|
|
512
|
+
compute?: NgtComputeFunction;
|
|
513
|
+
/** The filter can re-order or re-structure the intersections */
|
|
514
|
+
filter?: NgtFilterFunction;
|
|
515
|
+
/** The target node the event layer is tied to */
|
|
516
|
+
connected?: TTarget;
|
|
517
|
+
/** All the pointer event handlers through which the host forwards native events */
|
|
518
|
+
handlers?: NgtEvents;
|
|
519
|
+
/** Allows re-connecting to another target */
|
|
520
|
+
connect?: (target: TTarget) => void;
|
|
521
|
+
/** Removes all existing events handlers from the target */
|
|
522
|
+
disconnect?: () => void;
|
|
523
|
+
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
524
|
+
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
525
|
+
*/
|
|
526
|
+
update?: () => void;
|
|
527
|
+
}
|
|
528
|
+
interface NgtPointerCaptureTarget {
|
|
529
|
+
intersection: NgtIntersection;
|
|
530
|
+
target: Element;
|
|
531
|
+
}
|
|
532
|
+
interface NgtInstanceHierarchyState {
|
|
533
|
+
objects: NgtInstanceNode[];
|
|
534
|
+
nonObjects: NgtInstanceNode[];
|
|
535
|
+
parent: NgtInstanceNode | null;
|
|
536
|
+
geometryStamp: number;
|
|
537
|
+
}
|
|
538
|
+
interface NgtInstanceState<TObject extends NgtAnyRecord = NgtAnyRecord> {
|
|
539
|
+
/**
|
|
540
|
+
* The store that the intsance is being rendered with
|
|
541
|
+
*/
|
|
542
|
+
store: SignalState<NgtState> | null;
|
|
543
|
+
/**
|
|
544
|
+
* hierachy store for the instance
|
|
545
|
+
*/
|
|
546
|
+
hierarchyStore: SignalState<NgtInstanceHierarchyState>;
|
|
547
|
+
parent: Signal<NgtInstanceHierarchyState['parent']>;
|
|
548
|
+
objects: Signal<NgtInstanceHierarchyState['objects']>;
|
|
549
|
+
nonObjects: Signal<NgtInstanceHierarchyState['nonObjects']>;
|
|
550
|
+
/**
|
|
551
|
+
* reference back to the object
|
|
552
|
+
*/
|
|
553
|
+
object: TObject & {
|
|
554
|
+
__ngt__?: NgtInstanceState<TObject>;
|
|
555
|
+
};
|
|
556
|
+
add: (instance: NgtInstanceNode, type: 'objects' | 'nonObjects') => void;
|
|
557
|
+
remove: (instance: NgtInstanceNode, type: 'objects' | 'nonObjects') => void;
|
|
558
|
+
setParent: (parent: NgtInstanceNode | null) => void;
|
|
559
|
+
updateGeometryStamp: () => void;
|
|
560
|
+
/**
|
|
561
|
+
* event count for the instance
|
|
562
|
+
*/
|
|
563
|
+
eventCount: number;
|
|
564
|
+
/**
|
|
565
|
+
* handlers for the instance
|
|
566
|
+
*/
|
|
567
|
+
handlers: Partial<NgtEventHandlers>;
|
|
568
|
+
/**
|
|
569
|
+
* attach information so that we can detach as well as reset
|
|
570
|
+
*/
|
|
571
|
+
attach?: string[] | NgtAttachFunction;
|
|
572
|
+
/**
|
|
573
|
+
* previously attach information so we can reset as well as clean up
|
|
574
|
+
*/
|
|
575
|
+
previousAttach?: unknown | (() => void);
|
|
576
|
+
/**
|
|
577
|
+
* the element tag used to create this instance
|
|
578
|
+
*/
|
|
579
|
+
type: string;
|
|
580
|
+
onUpdate?: (node: NgtInstanceNode) => void;
|
|
581
|
+
onAttach?: (afterAttach: NgtAfterAttach) => void;
|
|
582
|
+
setPointerEvent?: <TEvent extends keyof NgtEventHandlers>(eventName: TEvent, callback: NgtEventHandlers[TEvent]) => () => void;
|
|
583
|
+
addInteraction?: (store?: SignalState<NgtState> | null) => void;
|
|
584
|
+
removeInteraction?: (store?: SignalState<NgtState> | null) => void;
|
|
585
|
+
}
|
|
586
|
+
type NgtInstanceNode<TObject extends NgtAnyRecord = NgtAnyRecord> = TObject & {
|
|
587
|
+
__ngt_id__: string;
|
|
588
|
+
__ngt__: NgtInstanceState<TObject>;
|
|
589
|
+
};
|
|
590
|
+
type NgtAttachFunction<TChild = any, TParent = any> = (parent: TParent, child: TChild, store: SignalState<NgtState>) => void | (() => void);
|
|
591
|
+
type NgtAttachable<TChild = any, TParent = any> = NgtAttachFunction<TChild, TParent> | string | (string | number)[];
|
|
592
|
+
interface NgtAfterAttach<TChild = NgtInstanceNode, TParent = NgtInstanceNode> {
|
|
593
|
+
parent: TParent;
|
|
594
|
+
node: TChild;
|
|
595
|
+
}
|
|
596
|
+
interface NgtRenderState extends NgtState {
|
|
597
|
+
delta: number;
|
|
598
|
+
frame?: XRFrame;
|
|
599
|
+
}
|
|
600
|
+
interface NgtBeforeRenderEvent<TObject = NgtInstanceNode> {
|
|
601
|
+
state: NgtRenderState;
|
|
602
|
+
object: TObject;
|
|
603
|
+
}
|
|
604
|
+
interface NgtBeforeRenderRecord {
|
|
605
|
+
callback: (state: NgtRenderState) => void;
|
|
606
|
+
store: SignalState<NgtState>;
|
|
607
|
+
priority?: number;
|
|
608
|
+
}
|
|
609
|
+
interface NgtXRManager {
|
|
610
|
+
connect: () => void;
|
|
611
|
+
disconnect: () => void;
|
|
612
|
+
}
|
|
613
|
+
interface NgtInternalState {
|
|
614
|
+
active: boolean;
|
|
615
|
+
priority: number;
|
|
616
|
+
frames: number;
|
|
617
|
+
lastEvent: ElementRef<NgtDomEvent | null>;
|
|
618
|
+
interaction: THREE.Object3D[];
|
|
619
|
+
hovered: Map<string, NgtThreeEvent<NgtDomEvent>>;
|
|
620
|
+
capturedMap: Map<number, Map<THREE.Object3D, NgtPointerCaptureTarget>>;
|
|
621
|
+
initialClick: [x: number, y: number];
|
|
622
|
+
initialHits: THREE.Object3D[];
|
|
623
|
+
subscribers: NgtBeforeRenderRecord[];
|
|
624
|
+
subscribe: (callback: NgtBeforeRenderRecord['callback'], priority?: number, store?: SignalState<NgtState>) => () => void;
|
|
625
|
+
}
|
|
626
|
+
interface NgtState {
|
|
627
|
+
/** id **/
|
|
628
|
+
id: string;
|
|
629
|
+
/** The instance of the renderer */
|
|
630
|
+
gl: THREE.WebGLRenderer;
|
|
631
|
+
/** Default camera */
|
|
632
|
+
camera: NgtCamera;
|
|
633
|
+
/** Default scene */
|
|
634
|
+
scene: THREE.Scene;
|
|
635
|
+
/** Default raycaster */
|
|
636
|
+
raycaster: THREE.Raycaster;
|
|
637
|
+
/** Default clock */
|
|
638
|
+
clock: THREE.Clock;
|
|
639
|
+
/** Event layer interface, contains the event handler and the node they're connected to */
|
|
640
|
+
events: NgtEventManager<any>;
|
|
641
|
+
/** XR interface */
|
|
642
|
+
xr: NgtXRManager;
|
|
643
|
+
/** Currently used controls */
|
|
644
|
+
controls: THREE.EventDispatcher | null;
|
|
645
|
+
/** Normalized event coordinates */
|
|
646
|
+
pointer: THREE.Vector2;
|
|
647
|
+
legacy: boolean;
|
|
648
|
+
/** Shortcut to gl.outputColorSpace = LinearSRGBColorSpace */
|
|
649
|
+
linear: boolean;
|
|
650
|
+
/** Shortcut to gl.toneMapping = NoTonemapping */
|
|
651
|
+
flat: boolean;
|
|
652
|
+
/** Render loop flags */
|
|
653
|
+
frameloop: NgtFrameloop;
|
|
654
|
+
/** Adaptive performance interface */
|
|
655
|
+
performance: NgtPerformance;
|
|
656
|
+
/** Reactive pixel-size of the canvas */
|
|
657
|
+
size: NgtSize;
|
|
658
|
+
/** Reactive size of the viewport in threejs units */
|
|
659
|
+
viewport: NgtViewport & {
|
|
660
|
+
getCurrentViewport: (camera: NgtCamera, target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>, size?: NgtSize) => Omit<NgtViewport, 'dpr' | 'initialDpr'>;
|
|
661
|
+
};
|
|
662
|
+
/** Flags the canvas for render, but doesn't render in itself */
|
|
663
|
+
invalidate: (frames?: number) => void;
|
|
664
|
+
/** Advance (render) one step */
|
|
665
|
+
advance: (timestamp: number, runGlobalEffects?: boolean) => void;
|
|
666
|
+
/** Shortcut to setting the event layer */
|
|
667
|
+
setEvents: (events: Partial<NgtEventManager<any>>) => void;
|
|
668
|
+
/**
|
|
669
|
+
* Shortcut to manual sizing
|
|
670
|
+
*/
|
|
671
|
+
setSize: (width: number, height: number, top?: number, left?: number) => void;
|
|
672
|
+
/** Shortcut to manual setting the pixel ratio */
|
|
673
|
+
setDpr: (dpr: NgtDpr) => void;
|
|
674
|
+
/** Shortcut to frameloop flags */
|
|
675
|
+
setFrameloop: (frameloop?: NgtFrameloop) => void;
|
|
676
|
+
/** When the canvas was clicked but nothing was hit */
|
|
677
|
+
/** PointerMissed Observable */
|
|
678
|
+
pointerMissed$: Observable<MouseEvent>;
|
|
679
|
+
/** If this state model is layered (via createPortal) then this contains the previous layer */
|
|
680
|
+
previousRoot: SignalState<NgtState> | null;
|
|
681
|
+
/** Internals */
|
|
682
|
+
internal: NgtInternalState;
|
|
683
|
+
/** maxSkipCount from renderer options */
|
|
684
|
+
maxNotificationSkipCount?: number;
|
|
685
|
+
}
|
|
686
|
+
interface NgtCanvasOptions {
|
|
687
|
+
gl?: NgtGLOptions;
|
|
688
|
+
size?: NgtSize;
|
|
689
|
+
shadows?: NgtShadows;
|
|
690
|
+
legacy?: boolean;
|
|
691
|
+
linear?: boolean;
|
|
692
|
+
flat?: boolean;
|
|
693
|
+
orthographic?: boolean;
|
|
694
|
+
frameloop?: NgtFrameloop;
|
|
695
|
+
performance?: Partial<Omit<NgtPerformance, 'regress'>>;
|
|
696
|
+
dpr?: NgtDpr;
|
|
697
|
+
raycaster?: Partial<THREE.Raycaster>;
|
|
698
|
+
scene?: THREE.Scene | Partial<THREE.Scene>;
|
|
699
|
+
camera?: NgtCamera | NgtCameraParameters;
|
|
700
|
+
events?: (store: SignalState<NgtState>) => NgtEventManager<HTMLElement>;
|
|
701
|
+
eventSource?: HTMLElement | ElementRef<HTMLElement>;
|
|
702
|
+
eventPrefix?: NgtEventPrefix;
|
|
703
|
+
lookAt?: NgtVector3;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Structural directive for specifying a custom parent for Three.js objects.
|
|
708
|
+
*
|
|
709
|
+
* By default, Three.js objects are parented to the nearest Object3D ancestor in the template.
|
|
710
|
+
* The `NgtParent` directive allows you to override this behavior and specify a different parent.
|
|
711
|
+
*
|
|
712
|
+
* The parent can be specified as:
|
|
713
|
+
* - A string (name of an object in the scene)
|
|
714
|
+
* - A THREE.Object3D reference
|
|
715
|
+
* - An ElementRef containing a THREE.Object3D
|
|
716
|
+
* - A Signal of any of the above
|
|
717
|
+
*
|
|
718
|
+
* @example
|
|
719
|
+
* ```html
|
|
720
|
+
* <!-- Parent to a named object in the scene -->
|
|
721
|
+
* <ngt-mesh *parent="'myGroup'">
|
|
722
|
+
* <ngt-box-geometry />
|
|
723
|
+
* </ngt-mesh>
|
|
724
|
+
*
|
|
725
|
+
* <!-- Parent to a reference -->
|
|
726
|
+
* <ngt-mesh *parent="myGroupRef">
|
|
727
|
+
* <ngt-box-geometry />
|
|
728
|
+
* </ngt-mesh>
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
declare class NgtParent extends NgtCommonDirective<THREE.Object3D | null | undefined> {
|
|
732
|
+
parent: _angular_core.InputSignal<string | THREE.Object3D<THREE.Object3DEventMap> | ElementRef<THREE.Object3D<THREE.Object3DEventMap>> | (() => NgtNullish<ElementRef<THREE.Object3D> | THREE.Object3D | string>)>;
|
|
733
|
+
private store;
|
|
734
|
+
private _parent;
|
|
735
|
+
protected linkedValue: _angular_core.WritableSignal<THREE.Object3D<THREE.Object3DEventMap> | null | undefined>;
|
|
736
|
+
protected shouldSkipRender: _angular_core.Signal<boolean>;
|
|
737
|
+
constructor();
|
|
738
|
+
validate(): boolean;
|
|
739
|
+
protected beforeCreateView(): void;
|
|
740
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtParent, never>;
|
|
741
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtParent, "ng-template[parent]", never, { "parent": { "alias": "parent"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Directive for managing selection state of Three.js objects.
|
|
746
|
+
*
|
|
747
|
+
* This directive creates a selection context that child `NgtSelect` directives can use
|
|
748
|
+
* to register themselves as selectable. The selection state is exposed as a readonly signal.
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* ```html
|
|
752
|
+
* <ngt-group [selection]="true">
|
|
753
|
+
* <ngt-mesh [select]="isSelected()">
|
|
754
|
+
* <ngt-box-geometry />
|
|
755
|
+
* </ngt-mesh>
|
|
756
|
+
* </ngt-group>
|
|
757
|
+
* ```
|
|
758
|
+
*/
|
|
759
|
+
declare class NgtSelectionApi {
|
|
760
|
+
enabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
761
|
+
private source;
|
|
762
|
+
selected: _angular_core.Signal<(Object3D<THREE.Object3DEventMap> | ElementRef<Object3D<THREE.Object3DEventMap>>)[]>;
|
|
763
|
+
update(...args: Parameters<typeof this$1.source.update>): void;
|
|
764
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtSelectionApi, never>;
|
|
765
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtSelectionApi, "[selection]", never, { "enabled": { "alias": "selection"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Directive for marking Three.js objects as selectable.
|
|
769
|
+
*
|
|
770
|
+
* When applied to a mesh or group, this directive registers the object with the parent
|
|
771
|
+
* `NgtSelectionApi` when enabled. For groups, all child meshes are automatically registered.
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* ```html
|
|
775
|
+
* <ngt-mesh [select]="true">
|
|
776
|
+
* <ngt-box-geometry />
|
|
777
|
+
* </ngt-mesh>
|
|
778
|
+
* ```
|
|
779
|
+
*/
|
|
780
|
+
declare class NgtSelect {
|
|
781
|
+
enabled: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
782
|
+
constructor();
|
|
783
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtSelect, never>;
|
|
784
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtSelect, "ngt-group[select], ngt-mesh[select]", never, { "enabled": { "alias": "select"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Array containing NgtSelectionApi and NgtSelect directives for convenient importing.
|
|
788
|
+
*
|
|
789
|
+
* @example
|
|
790
|
+
* ```typescript
|
|
791
|
+
* @Component({
|
|
792
|
+
* imports: [NgtSelection],
|
|
793
|
+
* })
|
|
794
|
+
* export class MyComponent {}
|
|
795
|
+
* ```
|
|
796
|
+
*/
|
|
797
|
+
declare const NgtSelection: readonly [typeof NgtSelectionApi, typeof NgtSelect];
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Removes all traces of an object from the event handling system.
|
|
801
|
+
*
|
|
802
|
+
* This function cleans up:
|
|
803
|
+
* - Interaction array
|
|
804
|
+
* - Initial hits
|
|
805
|
+
* - Hovered elements map
|
|
806
|
+
* - Pointer captures
|
|
807
|
+
*
|
|
808
|
+
* @param store - The Angular Three store
|
|
809
|
+
* @param object - The object to remove from interactivity
|
|
810
|
+
*/
|
|
811
|
+
declare function removeInteractivity(store: SignalState<NgtState>, object: THREE.Object3D): void;
|
|
812
|
+
/**
|
|
813
|
+
* Creates the event handling system for a store.
|
|
814
|
+
*
|
|
815
|
+
* Returns an object with a `handlePointer` function that creates event handlers
|
|
816
|
+
* for different pointer event types. These handlers perform raycasting,
|
|
817
|
+
* event propagation, and callback invocation.
|
|
818
|
+
*
|
|
819
|
+
* @param store - The Angular Three store to create events for
|
|
820
|
+
* @returns An object containing the handlePointer factory function
|
|
821
|
+
*/
|
|
822
|
+
declare function createEvents(store: SignalState<NgtState>): {
|
|
823
|
+
handlePointer: (name: string) => (event: NgtDomEvent) => void;
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* @fileoverview Internal constants used by the Angular Three renderer.
|
|
828
|
+
*
|
|
829
|
+
* These flags are used to mark DOM nodes and track renderer state.
|
|
830
|
+
* @internal
|
|
831
|
+
*/
|
|
832
|
+
/** Flag indicating a node is managed by the Angular Three renderer */
|
|
833
|
+
declare const NGT_RENDERER_NODE_FLAG = "__ngt_renderer__";
|
|
834
|
+
/** Flag for canvas content template comments */
|
|
835
|
+
declare const NGT_CANVAS_CONTENT_FLAG = "__ngt_renderer_canvas_content__";
|
|
836
|
+
/** Flag for portal content template comments */
|
|
837
|
+
declare const NGT_PORTAL_CONTENT_FLAG = "__ngt_renderer_portal_content__";
|
|
838
|
+
/** Flag for args directive comments */
|
|
839
|
+
declare const NGT_ARGS_FLAG = "__ngt_renderer_args__";
|
|
840
|
+
/** Flag for parent directive comments */
|
|
841
|
+
declare const NGT_PARENT_FLAG = "__ngt_renderer_parent__";
|
|
842
|
+
/** Internal flag for adding comment nodes */
|
|
843
|
+
declare const NGT_INTERNAL_ADD_COMMENT_FLAG = "__ngt_renderer_add_comment__";
|
|
844
|
+
/** Internal flag for setting parent on comment nodes */
|
|
845
|
+
declare const NGT_INTERNAL_SET_PARENT_COMMENT_FLAG = "__ngt_renderer_set_parent_comment__";
|
|
846
|
+
/** Flag for getting node attributes */
|
|
847
|
+
declare const NGT_GET_NODE_ATTRIBUTE_FLAG = "__ngt_get_node_attribute__";
|
|
848
|
+
/** Flag for DOM parent element reference */
|
|
849
|
+
declare const NGT_DOM_PARENT_FLAG = "__ngt_dom_parent__";
|
|
850
|
+
/** Flag indicating the delegate renderer's destroyNode has been patched */
|
|
851
|
+
declare const NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG = "__ngt_delegate_renderer_destroy_node_patched__";
|
|
852
|
+
/** Flag for HTML directive classes */
|
|
853
|
+
declare const NGT_HTML_FLAG = "__ngt_html__";
|
|
854
|
+
/** Native Three.js EventDispatcher events */
|
|
855
|
+
declare const THREE_NATIVE_EVENTS: string[];
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Provider function for configuring the DOM element for HTML components in Angular Three.
|
|
859
|
+
*
|
|
860
|
+
* This function creates a provider that specifies where HTML content should be rendered
|
|
861
|
+
* relative to the Three.js canvas. By default, HTML content is appended to the canvas's parent element.
|
|
862
|
+
*
|
|
863
|
+
* @returns A provider for the HTML DOM element configuration
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* ```typescript
|
|
867
|
+
* // Default: append to canvas parent
|
|
868
|
+
* @Component({
|
|
869
|
+
* providers: [provideHTMLDomElement()],
|
|
870
|
+
* })
|
|
871
|
+
*
|
|
872
|
+
* // Custom element
|
|
873
|
+
* @Component({
|
|
874
|
+
* providers: [provideHTMLDomElement(() => document.getElementById('my-container')!)],
|
|
875
|
+
* })
|
|
876
|
+
* ```
|
|
877
|
+
*/
|
|
878
|
+
declare function provideHTMLDomElement(): Provider;
|
|
879
|
+
declare function provideHTMLDomElement(factory: () => HTMLElement): Provider;
|
|
880
|
+
declare function provideHTMLDomElement<TDeps extends Array<ProviderToken<any>>, TValues extends {
|
|
881
|
+
[K in keyof TDeps]: TDeps[K] extends Type<infer T> | AbstractType<infer T> | InjectionToken<infer T> ? T : never;
|
|
882
|
+
}>(deps: TDeps, factory: (...args: TValues) => HTMLElement): Provider;
|
|
883
|
+
/**
|
|
884
|
+
* Abstract base directive for creating HTML components that render alongside the Three.js canvas.
|
|
885
|
+
*
|
|
886
|
+
* Extend this class to create components that render DOM elements positioned relative to the
|
|
887
|
+
* Three.js scene. The DOM element will be appended to either the canvas's parent element
|
|
888
|
+
* or a custom element specified via `provideHTMLDomElement`.
|
|
889
|
+
*
|
|
890
|
+
* @example
|
|
891
|
+
* ```typescript
|
|
892
|
+
* @Directive({ selector: '[myHtml]', providers: [provideHTMLDomElement()] })
|
|
893
|
+
* export class MyHtmlDirective extends NgtHTML {
|
|
894
|
+
* // Implementation
|
|
895
|
+
* }
|
|
896
|
+
* ```
|
|
897
|
+
*/
|
|
898
|
+
declare abstract class NgtHTML {
|
|
899
|
+
static [NGT_HTML_FLAG]: boolean;
|
|
900
|
+
protected domElement: HTMLElement | "gl" | null;
|
|
901
|
+
constructor();
|
|
902
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtHTML, never>;
|
|
903
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtHTML, never, never, {}, {}, never, never, true, never>;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* @deprecated Use `getInstanceState` instead. Will be removed in 5.0.0
|
|
908
|
+
* @param obj - The object to get local state from
|
|
909
|
+
* @returns The instance state if the object has been prepared, undefined otherwise
|
|
910
|
+
*/
|
|
911
|
+
declare function getLocalState<TInstance extends object>(obj: TInstance | undefined): NgtInstanceState | undefined;
|
|
912
|
+
/**
|
|
913
|
+
* Retrieves the Angular Three instance state from a Three.js object.
|
|
914
|
+
*
|
|
915
|
+
* Every Three.js object managed by Angular Three has an associated instance state
|
|
916
|
+
* that contains metadata such as the store reference, parent/child relationships,
|
|
917
|
+
* event handlers, and attach information.
|
|
918
|
+
*
|
|
919
|
+
* @typeParam TInstance - The type of the Three.js object
|
|
920
|
+
* @param obj - The Three.js object to get instance state from
|
|
921
|
+
* @returns The instance state if the object has been prepared, undefined otherwise
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```typescript
|
|
925
|
+
* const mesh = new THREE.Mesh();
|
|
926
|
+
* prepare(mesh, 'ngt-mesh');
|
|
927
|
+
* const state = getInstanceState(mesh);
|
|
928
|
+
* console.log(state?.type); // 'ngt-mesh'
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
declare function getInstanceState<TInstance extends NgtAnyRecord>(obj: TInstance | undefined): NgtInstanceState<TInstance> | undefined;
|
|
932
|
+
/**
|
|
933
|
+
* Invalidates an instance, triggering a re-render of the scene.
|
|
934
|
+
*
|
|
935
|
+
* This function marks the instance as needing an update and triggers the render loop
|
|
936
|
+
* to re-render the scene. It traverses up to the root store to ensure proper invalidation
|
|
937
|
+
* even for objects in portals.
|
|
938
|
+
*
|
|
939
|
+
* @typeParam TInstance - The type of the Three.js object
|
|
940
|
+
* @param instance - The instance node to invalidate
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```typescript
|
|
944
|
+
* // After modifying a mesh's properties
|
|
945
|
+
* mesh.position.x = 10;
|
|
946
|
+
* invalidateInstance(mesh);
|
|
947
|
+
* ```
|
|
948
|
+
*/
|
|
949
|
+
declare function invalidateInstance<TInstance extends NgtAnyRecord>(instance: NgtInstanceNode<TInstance>): void;
|
|
950
|
+
/**
|
|
951
|
+
* Prepares a Three.js object for use with Angular Three.
|
|
952
|
+
*
|
|
953
|
+
* This function attaches the Angular Three instance state to a Three.js object,
|
|
954
|
+
* enabling it to be managed by the Angular Three renderer. The instance state
|
|
955
|
+
* includes parent/child relationships, event handlers, and store references.
|
|
956
|
+
*
|
|
957
|
+
* @typeParam TInstance - The type of the Three.js object
|
|
958
|
+
* @param object - The Three.js object to prepare
|
|
959
|
+
* @param type - The element type name (e.g., 'ngt-mesh', 'ngt-primitive')
|
|
960
|
+
* @param instanceState - Optional partial instance state to merge with defaults
|
|
961
|
+
* @returns The prepared instance node
|
|
962
|
+
*
|
|
963
|
+
* @example
|
|
964
|
+
* ```typescript
|
|
965
|
+
* // Prepare a mesh for Angular Three
|
|
966
|
+
* const mesh = new THREE.Mesh(geometry, material);
|
|
967
|
+
* const prepared = prepare(mesh, 'ngt-mesh', { store });
|
|
968
|
+
* ```
|
|
969
|
+
*/
|
|
970
|
+
declare function prepare<TInstance extends NgtAnyRecord = NgtAnyRecord>(object: TInstance, type: string, instanceState?: Partial<NgtInstanceState>): NgtInstanceNode<TInstance>;
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Generates a unique identifier.
|
|
974
|
+
*
|
|
975
|
+
* When called with an intersection event, creates a deterministic ID based on
|
|
976
|
+
* the object UUID, index, and instance ID. Otherwise, generates a new UUID.
|
|
977
|
+
*
|
|
978
|
+
* @param event - Optional intersection event to generate ID from
|
|
979
|
+
* @returns A unique string identifier
|
|
980
|
+
*/
|
|
981
|
+
declare function makeId(event?: NgtIntersection): string;
|
|
982
|
+
/**
|
|
983
|
+
* Resolves the device pixel ratio within specified bounds.
|
|
984
|
+
*
|
|
985
|
+
* When given a range [min, max], clamps the device's actual DPR to this range.
|
|
986
|
+
* Falls back to 2x DPR in environments where it cannot be detected (e.g., workers).
|
|
987
|
+
*
|
|
988
|
+
* @param dpr - A single DPR value or [min, max] range
|
|
989
|
+
* @param window - Optional window object to get devicePixelRatio from
|
|
990
|
+
* @returns The resolved DPR value
|
|
991
|
+
*/
|
|
992
|
+
declare function makeDpr(dpr: NgtDpr, window?: Window): number;
|
|
993
|
+
/**
|
|
994
|
+
* Creates a WebGL renderer instance with sensible defaults.
|
|
995
|
+
*
|
|
996
|
+
* If a custom renderer is provided via glOptions, it will be used directly.
|
|
997
|
+
* Otherwise, creates a new WebGLRenderer with high-performance defaults.
|
|
998
|
+
*
|
|
999
|
+
* @typeParam TCanvas - The type of canvas element
|
|
1000
|
+
* @param glOptions - Renderer configuration or custom renderer
|
|
1001
|
+
* @param canvas - The canvas element to render to
|
|
1002
|
+
* @returns A WebGLRenderer instance
|
|
1003
|
+
*/
|
|
1004
|
+
declare function makeRendererInstance<TCanvas extends NgtCanvasElement>(glOptions: NgtGLOptions, canvas: TCanvas): THREE.WebGLRenderer;
|
|
1005
|
+
/**
|
|
1006
|
+
* Creates a camera instance based on the projection type.
|
|
1007
|
+
*
|
|
1008
|
+
* @param isOrthographic - Whether to create an orthographic camera
|
|
1009
|
+
* @param size - The viewport size for calculating aspect ratio
|
|
1010
|
+
* @returns Either an OrthographicCamera or PerspectiveCamera
|
|
1011
|
+
*/
|
|
1012
|
+
declare function makeCameraInstance(isOrthographic: boolean, size: NgtSize): THREE.PerspectiveCamera | THREE.OrthographicCamera;
|
|
1013
|
+
/**
|
|
1014
|
+
* Type representing a parsed object graph from a loaded 3D model.
|
|
1015
|
+
*
|
|
1016
|
+
* Contains maps of named nodes, materials, and meshes for easy access.
|
|
1017
|
+
*/
|
|
1018
|
+
type NgtObjectMap = {
|
|
1019
|
+
/** Map of named Object3D nodes */
|
|
1020
|
+
nodes: Record<string, THREE.Object3D<any>>;
|
|
1021
|
+
/** Map of named materials */
|
|
1022
|
+
materials: Record<string, THREE.Material>;
|
|
1023
|
+
/** Map of named meshes */
|
|
1024
|
+
meshes: Record<string, THREE.Mesh>;
|
|
1025
|
+
[key: string]: any;
|
|
1026
|
+
};
|
|
1027
|
+
/**
|
|
1028
|
+
* Creates an object graph from a Three.js scene hierarchy.
|
|
1029
|
+
*
|
|
1030
|
+
* Traverses the object and extracts named nodes, materials, and meshes
|
|
1031
|
+
* into lookup tables for convenient access.
|
|
1032
|
+
*
|
|
1033
|
+
* @param object - The root Object3D to traverse
|
|
1034
|
+
* @returns An object containing nodes, materials, and meshes maps
|
|
1035
|
+
*
|
|
1036
|
+
* @example
|
|
1037
|
+
* ```typescript
|
|
1038
|
+
* const gltf = await loader.loadAsync('model.gltf');
|
|
1039
|
+
* const { nodes, materials } = makeObjectGraph(gltf.scene);
|
|
1040
|
+
* // Access named objects: nodes['MyMesh'], materials['MyMaterial']
|
|
1041
|
+
* ```
|
|
1042
|
+
*/
|
|
1043
|
+
declare function makeObjectGraph(object: THREE.Object3D): NgtObjectMap;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Type representing a GLTF-like object with a scene property.
|
|
1047
|
+
*/
|
|
1048
|
+
type NgtGLTFLike = {
|
|
1049
|
+
scene: THREE.Object3D;
|
|
1050
|
+
};
|
|
1051
|
+
/**
|
|
1052
|
+
* Interface for Three.js loaders that support async loading.
|
|
1053
|
+
*
|
|
1054
|
+
* @typeParam T - The type of data the loader returns
|
|
1055
|
+
*/
|
|
1056
|
+
interface NgtLoader<T> extends THREE.Loader {
|
|
1057
|
+
load(url: string, onLoad?: (result: T) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: unknown) => void): unknown;
|
|
1058
|
+
loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<T>;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Type representing a loader constructor.
|
|
1062
|
+
*/
|
|
1063
|
+
type NgtLoaderProto<T> = new (...args: any) => NgtLoader<T extends unknown ? any : T>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Utility type to extract the return type of a loader.
|
|
1066
|
+
*/
|
|
1067
|
+
type NgtLoaderReturnType<T, L extends NgtLoaderProto<T>> = T extends unknown ? Awaited<ReturnType<InstanceType<L>['loadAsync']>> : T;
|
|
1068
|
+
/**
|
|
1069
|
+
* Type for loader extension functions that configure the loader before use.
|
|
1070
|
+
*/
|
|
1071
|
+
type NgtLoaderExtensions<T extends {
|
|
1072
|
+
prototype: NgtLoaderProto<any>;
|
|
1073
|
+
}> = (loader: T['prototype']) => void;
|
|
1074
|
+
/**
|
|
1075
|
+
* Conditional type utility.
|
|
1076
|
+
*/
|
|
1077
|
+
type NgtConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
|
|
1078
|
+
/**
|
|
1079
|
+
* Branching return type utility.
|
|
1080
|
+
*/
|
|
1081
|
+
type NgtBranchingReturn<T, Parent, Coerced> = NgtConditionalType<T, Parent, Coerced, T>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Type representing the result of loading based on input type.
|
|
1084
|
+
* - String input returns a single result
|
|
1085
|
+
* - Array input returns an array of results
|
|
1086
|
+
* - Object input returns an object with the same keys and loaded values
|
|
1087
|
+
*/
|
|
1088
|
+
type NgtLoaderResults<TInput extends string | string[] | Record<string, string>, TReturn> = TInput extends string[] ? TReturn[] : TInput extends object ? {
|
|
1089
|
+
[key in keyof TInput]: TReturn;
|
|
1090
|
+
} : TReturn;
|
|
1091
|
+
/**
|
|
1092
|
+
* @deprecated Use loaderResource instead. Will be removed in v5.0.0
|
|
1093
|
+
* @since v4.0.0~
|
|
1094
|
+
*/
|
|
1095
|
+
declare function _injectLoader<TData, TUrl extends string | string[] | Record<string, string>, TLoaderConstructor extends NgtLoaderProto<TData>, TReturn = NgtLoaderReturnType<TData, TLoaderConstructor>>(loaderConstructorFactory: (inputs: string[]) => TLoaderConstructor, inputs: () => TUrl, { extensions, onProgress, onLoad, injector, }?: {
|
|
1096
|
+
extensions?: NgtLoaderExtensions<TLoaderConstructor>;
|
|
1097
|
+
onProgress?: (event: ProgressEvent) => void;
|
|
1098
|
+
onLoad?: (data: NoInfer<TReturn>) => void;
|
|
1099
|
+
injector?: Injector;
|
|
1100
|
+
}): Signal<NgtLoaderResults<TUrl, NgtBranchingReturn<TReturn, NgtGLTFLike, NgtGLTFLike & NgtObjectMap>> | null>;
|
|
1101
|
+
declare namespace _injectLoader {
|
|
1102
|
+
var preload: <TData, TUrl extends string | string[] | Record<string, string>, TLoaderConstructor extends NgtLoaderProto<TData>>(loaderConstructorFactory: (inputs: string[]) => TLoaderConstructor, inputs: () => TUrl, extensions?: NgtLoaderExtensions<TLoaderConstructor>, onLoad?: (data: NoInfer<TData>) => void) => void;
|
|
1103
|
+
var destroy: () => void;
|
|
1104
|
+
var clear: (urls: string | string[]) => void;
|
|
1105
|
+
}
|
|
1106
|
+
type NgtInjectedLoader = typeof _injectLoader;
|
|
1107
|
+
/**
|
|
1108
|
+
* @deprecated Use loaderResource instead. Will be removed in v5.0.0
|
|
1109
|
+
* @since v4.0.0~
|
|
1110
|
+
*/
|
|
1111
|
+
declare const injectLoader: NgtInjectedLoader;
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Loads Three.js assets using Angular's resource API.
|
|
1115
|
+
*
|
|
1116
|
+
* This function provides a signal-based approach to loading Three.js assets like
|
|
1117
|
+
* GLTF models, textures, and other files. It leverages Angular's resource API
|
|
1118
|
+
* for better integration with Angular's reactivity system.
|
|
1119
|
+
*
|
|
1120
|
+
* Features:
|
|
1121
|
+
* - Automatic caching of loaded assets
|
|
1122
|
+
* - Support for single URLs, arrays, or object maps
|
|
1123
|
+
* - GLTF scene graph extraction
|
|
1124
|
+
* - Progress and completion callbacks
|
|
1125
|
+
*
|
|
1126
|
+
* @typeParam TData - The type of data returned by the loader
|
|
1127
|
+
* @typeParam TUrl - The type of URL input (string, string[], or Record<string, string>)
|
|
1128
|
+
* @typeParam TLoaderConstructor - The loader constructor type
|
|
1129
|
+
* @typeParam TReturn - The return type after loading
|
|
1130
|
+
*
|
|
1131
|
+
* @param loaderConstructorFactory - Factory function that returns the loader constructor
|
|
1132
|
+
* @param input - Signal containing the URL(s) to load
|
|
1133
|
+
* @param options - Optional configuration including extensions, callbacks, and injector
|
|
1134
|
+
* @returns A ResourceRef containing the loaded data
|
|
1135
|
+
*
|
|
1136
|
+
* @example
|
|
1137
|
+
* ```typescript
|
|
1138
|
+
* // Load a single GLTF model
|
|
1139
|
+
* const model = loaderResource(
|
|
1140
|
+
* () => GLTFLoader,
|
|
1141
|
+
* () => '/assets/model.gltf'
|
|
1142
|
+
* );
|
|
1143
|
+
*
|
|
1144
|
+
* // Access in template
|
|
1145
|
+
* @if (model.value(); as gltf) {
|
|
1146
|
+
* <ngt-primitive *args="[gltf.scene]" />
|
|
1147
|
+
* }
|
|
1148
|
+
* ```
|
|
1149
|
+
*/
|
|
1150
|
+
declare function loaderResource<TData, TUrl extends string | string[] | Record<string, string>, TLoaderConstructor extends NgtLoaderProto<TData>, TReturn = NgtLoaderReturnType<TData, TLoaderConstructor>>(loaderConstructorFactory: (url: TUrl) => TLoaderConstructor, input: () => TUrl, { extensions, onLoad, onProgress, injector, }?: {
|
|
1151
|
+
extensions?: NgtLoaderExtensions<TLoaderConstructor>;
|
|
1152
|
+
onLoad?: (data: NoInfer<NgtLoaderResults<TUrl, NgtBranchingReturn<TReturn, NgtGLTFLike, NgtGLTFLike & NgtObjectMap>>>) => void;
|
|
1153
|
+
onProgress?: (event: ProgressEvent) => void;
|
|
1154
|
+
injector?: Injector;
|
|
1155
|
+
}): ResourceRef<NgtLoaderResults<TUrl, NgtBranchingReturn<TReturn, NgtGLTFLike, NgtGLTFLike & NgtObjectMap>> | undefined>;
|
|
1156
|
+
declare namespace loaderResource {
|
|
1157
|
+
var preload: <TData, TUrl extends string | string[] | Record<string, string>, TLoaderConstructor extends NgtLoaderProto<TData>>(loaderConstructor: TLoaderConstructor, inputs: TUrl, extensions?: NgtLoaderExtensions<TLoaderConstructor>) => void;
|
|
1158
|
+
var destroy: () => void;
|
|
1159
|
+
var clear: (urls: string | string[]) => void;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* Global map of canvas elements to their associated stores.
|
|
1164
|
+
*
|
|
1165
|
+
* This map maintains references to all active Angular Three canvas roots,
|
|
1166
|
+
* allowing the render loop to iterate over and render all active scenes.
|
|
1167
|
+
*/
|
|
1168
|
+
declare const roots: Map<NgtCanvasElement, SignalState<NgtState>>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Adds a global render callback which is called each frame.
|
|
1171
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
|
|
1172
|
+
*/
|
|
1173
|
+
declare const addEffect: (callback: NgtGlobalRenderCallback) => () => void;
|
|
1174
|
+
/**
|
|
1175
|
+
* Adds a global after-render callback which is called each frame.
|
|
1176
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
|
|
1177
|
+
*/
|
|
1178
|
+
declare const addAfterEffect: (callback: NgtGlobalRenderCallback) => () => void;
|
|
1179
|
+
/**
|
|
1180
|
+
* Adds a global callback which is called when rendering stops.
|
|
1181
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
|
|
1182
|
+
*/
|
|
1183
|
+
declare const addTail: (callback: NgtGlobalRenderCallback) => () => void;
|
|
1184
|
+
/**
|
|
1185
|
+
* Type of global effect in the render loop.
|
|
1186
|
+
* - 'before': Runs before the main render
|
|
1187
|
+
* - 'after': Runs after the main render
|
|
1188
|
+
* - 'tail': Runs when rendering stops
|
|
1189
|
+
*/
|
|
1190
|
+
type NgtGlobalEffectType = 'before' | 'after' | 'tail';
|
|
1191
|
+
/**
|
|
1192
|
+
* Executes all global effects of the specified type.
|
|
1193
|
+
*
|
|
1194
|
+
* @param type - The type of global effects to flush ('before', 'after', or 'tail')
|
|
1195
|
+
* @param timestamp - The current timestamp from requestAnimationFrame
|
|
1196
|
+
*/
|
|
1197
|
+
declare function flushGlobalEffects(type: NgtGlobalEffectType, timestamp: number): void;
|
|
1198
|
+
/**
|
|
1199
|
+
* Injection token for the Angular Three render loop.
|
|
1200
|
+
*
|
|
1201
|
+
* Provides access to the render loop controls including invalidate and advance functions.
|
|
1202
|
+
*/
|
|
1203
|
+
declare const NGT_LOOP: InjectionToken<{
|
|
1204
|
+
loop: (timestamp: number) => void;
|
|
1205
|
+
invalidate: (store?: SignalState<NgtState>, frames?: number) => void;
|
|
1206
|
+
advance: (timestamp: number, runGlobalEffects?: boolean, store?: SignalState<NgtState>, frame?: XRFrame) => void;
|
|
1207
|
+
}>;
|
|
1208
|
+
/**
|
|
1209
|
+
* Injects the Angular Three render loop controller.
|
|
1210
|
+
*
|
|
1211
|
+
* The loop controller provides methods to control the render loop:
|
|
1212
|
+
* - `invalidate`: Marks the scene as needing a re-render
|
|
1213
|
+
* - `advance`: Manually advances the render loop by one frame
|
|
1214
|
+
* - `loop`: The main animation loop function
|
|
1215
|
+
*
|
|
1216
|
+
* @returns The render loop controller
|
|
1217
|
+
*
|
|
1218
|
+
* @example
|
|
1219
|
+
* ```typescript
|
|
1220
|
+
* const loop = injectLoop();
|
|
1221
|
+
* // Trigger a re-render
|
|
1222
|
+
* loop.invalidate();
|
|
1223
|
+
* // Manually advance one frame
|
|
1224
|
+
* loop.advance(performance.now());
|
|
1225
|
+
* ```
|
|
1226
|
+
*/
|
|
1227
|
+
declare function injectLoop(): {
|
|
1228
|
+
loop: (timestamp: number) => void;
|
|
1229
|
+
invalidate: (store?: SignalState<NgtState>, frames?: number) => void;
|
|
1230
|
+
advance: (timestamp: number, runGlobalEffects?: boolean, store?: SignalState<NgtState>, frame?: XRFrame) => void;
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Pipe for converting CSS color strings to hexadecimal numbers.
|
|
1235
|
+
*
|
|
1236
|
+
* Supports various color formats:
|
|
1237
|
+
* - Hex strings: '#ff0000' -> 0xff0000
|
|
1238
|
+
* - RGB: 'rgb(255, 0, 0)' -> 0xff0000
|
|
1239
|
+
* - RGBA: 'rgba(255, 0, 0, 0.5)' -> hex with alpha
|
|
1240
|
+
* - CSS color names: 'red' -> 0xff0000
|
|
1241
|
+
*
|
|
1242
|
+
* Returns 0x000000 (black) for invalid or null values.
|
|
1243
|
+
*
|
|
1244
|
+
* @example
|
|
1245
|
+
* ```html
|
|
1246
|
+
* <ngt-mesh-basic-material [color]="'red' | hexify" />
|
|
1247
|
+
* <ngt-mesh-basic-material [color]="'#ff0000' | hexify" />
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
declare class NgtHexify {
|
|
1251
|
+
private document;
|
|
1252
|
+
private ctx?;
|
|
1253
|
+
private cache;
|
|
1254
|
+
/**
|
|
1255
|
+
* transforms a:
|
|
1256
|
+
* - hex string to a hex number
|
|
1257
|
+
* - rgb string to a hex number
|
|
1258
|
+
* - rgba string to a hex number
|
|
1259
|
+
* - css color string to a hex number
|
|
1260
|
+
*
|
|
1261
|
+
* always default to black if failed
|
|
1262
|
+
* @param value
|
|
1263
|
+
*/
|
|
1264
|
+
transform(value: string): number;
|
|
1265
|
+
private hexStringToNumber;
|
|
1266
|
+
private componentToHex;
|
|
1267
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtHexify, never>;
|
|
1268
|
+
static ɵpipe: _angular_core.ɵɵPipeDeclaration<NgtHexify, "hexify", true>;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Directive to enable automatic rendering for portal content.
|
|
1273
|
+
*
|
|
1274
|
+
* When applied to an `ngt-portal`, this directive sets up automatic rendering
|
|
1275
|
+
* of the portal's scene on each frame. The render priority can be configured
|
|
1276
|
+
* to control the order of rendering relative to other subscriptions.
|
|
1277
|
+
*
|
|
1278
|
+
* @example
|
|
1279
|
+
* ```html
|
|
1280
|
+
* <ngt-portal [container]="container" [autoRender]="2">
|
|
1281
|
+
* <ng-template portalContent>
|
|
1282
|
+
* <ngt-mesh />
|
|
1283
|
+
* </ng-template>
|
|
1284
|
+
* </ngt-portal>
|
|
1285
|
+
* ```
|
|
1286
|
+
*/
|
|
1287
|
+
declare class NgtPortalAutoRender {
|
|
1288
|
+
private portalStore;
|
|
1289
|
+
private parentStore;
|
|
1290
|
+
private portal;
|
|
1291
|
+
renderPriority: _angular_core.InputSignalWithTransform<number, unknown>;
|
|
1292
|
+
constructor();
|
|
1293
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtPortalAutoRender, never>;
|
|
1294
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtPortalAutoRender, "ngt-portal[autoRender]", never, { "renderPriority": { "alias": "autoRender"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Structural directive for defining portal content.
|
|
1298
|
+
*
|
|
1299
|
+
* This directive marks the template content that will be rendered inside the portal.
|
|
1300
|
+
* It must be used inside an `ngt-portal` component.
|
|
1301
|
+
*
|
|
1302
|
+
* @example
|
|
1303
|
+
* ```html
|
|
1304
|
+
* <ngt-portal [container]="myGroup">
|
|
1305
|
+
* <ng-template portalContent let-injector="injector">
|
|
1306
|
+
* <ngt-mesh />
|
|
1307
|
+
* </ng-template>
|
|
1308
|
+
* </ngt-portal>
|
|
1309
|
+
* ```
|
|
1310
|
+
*/
|
|
1311
|
+
declare class NgtPortalContent {
|
|
1312
|
+
static ngTemplateContextGuard(_: NgtPortalContent, ctx: unknown): ctx is {
|
|
1313
|
+
injector: Injector;
|
|
1314
|
+
};
|
|
1315
|
+
constructor();
|
|
1316
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtPortalContent, never>;
|
|
1317
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtPortalContent, "ng-template[portalContent]", never, {}, {}, never, never, true, never>;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* State interface for portal configuration.
|
|
1321
|
+
*
|
|
1322
|
+
* Extends the base NgtState with customizable event handling configuration.
|
|
1323
|
+
*/
|
|
1324
|
+
interface NgtPortalState extends Omit<NgtState, 'events'> {
|
|
1325
|
+
/** Portal-specific event configuration */
|
|
1326
|
+
events: {
|
|
1327
|
+
/** Whether events are enabled for this portal */
|
|
1328
|
+
enabled?: boolean;
|
|
1329
|
+
/** Event handling priority */
|
|
1330
|
+
priority?: number;
|
|
1331
|
+
/** Custom compute function for raycasting */
|
|
1332
|
+
compute?: NgtComputeFunction;
|
|
1333
|
+
/** Connected event target */
|
|
1334
|
+
connected?: any;
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Component for creating a portal to render Three.js content into a different container.
|
|
1339
|
+
*
|
|
1340
|
+
* Portals allow you to render content into a separate Three.js object while maintaining
|
|
1341
|
+
* the React-like declarative structure. Each portal has its own store with separate
|
|
1342
|
+
* raycaster and pointer state.
|
|
1343
|
+
*
|
|
1344
|
+
* @example
|
|
1345
|
+
* ```html
|
|
1346
|
+
* <ngt-group #portalContainer />
|
|
1347
|
+
*
|
|
1348
|
+
* <ngt-portal [container]="portalContainer">
|
|
1349
|
+
* <ng-template portalContent>
|
|
1350
|
+
* <ngt-mesh>
|
|
1351
|
+
* <ngt-box-geometry />
|
|
1352
|
+
* </ngt-mesh>
|
|
1353
|
+
* </ng-template>
|
|
1354
|
+
* </ngt-portal>
|
|
1355
|
+
* ```
|
|
1356
|
+
*/
|
|
1357
|
+
declare class NgtPortalImpl {
|
|
1358
|
+
container: _angular_core.InputSignal<THREE.Object3D<THREE.Object3DEventMap>>;
|
|
1359
|
+
state: _angular_core.InputSignal<Partial<NgtPortalState>>;
|
|
1360
|
+
private contentRef;
|
|
1361
|
+
private anchorRef;
|
|
1362
|
+
private previousStore;
|
|
1363
|
+
private portalStore;
|
|
1364
|
+
private injector;
|
|
1365
|
+
private size;
|
|
1366
|
+
private events;
|
|
1367
|
+
private restState;
|
|
1368
|
+
private portalContentRendered;
|
|
1369
|
+
portalRendered: _angular_core.Signal<boolean>;
|
|
1370
|
+
private portalViewRef?;
|
|
1371
|
+
constructor();
|
|
1372
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtPortalImpl, never>;
|
|
1373
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgtPortalImpl, "ngt-portal", never, { "container": { "alias": "container"; "required": true; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; }, {}, ["contentRef", "anchorRef"], never, true, never>;
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Array containing NgtPortalImpl and NgtPortalContent for convenient importing.
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```typescript
|
|
1380
|
+
* @Component({
|
|
1381
|
+
* imports: [NgtPortal],
|
|
1382
|
+
* })
|
|
1383
|
+
* export class MyComponent {}
|
|
1384
|
+
* ```
|
|
1385
|
+
*/
|
|
1386
|
+
declare const NgtPortal: readonly [typeof NgtPortalImpl, typeof NgtPortalContent];
|
|
1387
|
+
|
|
1388
|
+
/**
|
|
1389
|
+
* Registers Three.js constructors for use in templates.
|
|
1390
|
+
*
|
|
1391
|
+
* Call this function to make Three.js classes available for use as custom elements.
|
|
1392
|
+
* The function returns a cleanup function that removes the registered entries.
|
|
1393
|
+
*
|
|
1394
|
+
* @param objects - An object mapping names to Three.js constructors
|
|
1395
|
+
* @returns A cleanup function to remove the registered entries
|
|
1396
|
+
*
|
|
1397
|
+
* @example
|
|
1398
|
+
* ```typescript
|
|
1399
|
+
* import { extend } from 'angular-three';
|
|
1400
|
+
* import { Mesh, BoxGeometry, MeshStandardMaterial } from 'three';
|
|
1401
|
+
*
|
|
1402
|
+
* // Register at component level
|
|
1403
|
+
* extend({ Mesh, BoxGeometry, MeshStandardMaterial });
|
|
1404
|
+
*
|
|
1405
|
+
* // Now you can use in templates:
|
|
1406
|
+
* // <ngt-mesh>
|
|
1407
|
+
* // <ngt-box-geometry />
|
|
1408
|
+
* // <ngt-mesh-standard-material />
|
|
1409
|
+
* // </ngt-mesh>
|
|
1410
|
+
* ```
|
|
1411
|
+
*/
|
|
1412
|
+
declare function extend(objects: object): () => void;
|
|
1413
|
+
/**
|
|
1414
|
+
* Removes entries from the catalogue by key.
|
|
1415
|
+
*
|
|
1416
|
+
* @param keys - The keys to remove from the catalogue
|
|
1417
|
+
*/
|
|
1418
|
+
declare function remove(...keys: string[]): void;
|
|
1419
|
+
/**
|
|
1420
|
+
* Injection token for the Three.js constructor catalogue.
|
|
1421
|
+
*/
|
|
1422
|
+
declare const NGT_CATALOGUE: InjectionToken<Record<string, NgtConstructorRepresentation>>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Injects the Three.js constructor catalogue.
|
|
1425
|
+
*
|
|
1426
|
+
* @returns The catalogue mapping names to constructors
|
|
1427
|
+
*/
|
|
1428
|
+
declare function injectCatalogue(): Record<string, NgtConstructorRepresentation>;
|
|
1429
|
+
|
|
1430
|
+
type ThreeRendererState = [
|
|
1431
|
+
type: 'three',
|
|
1432
|
+
destroyed: boolean,
|
|
1433
|
+
rawValue: any | undefined,
|
|
1434
|
+
portalContainer: never | undefined,
|
|
1435
|
+
injector: never | undefined,
|
|
1436
|
+
parent: NgtRendererNode<'platform' | 'portal' | 'three'> | undefined,
|
|
1437
|
+
children: Array<NgtRendererNode<'platform' | 'portal' | 'comment'>>
|
|
1438
|
+
];
|
|
1439
|
+
type PortalRendererState = [
|
|
1440
|
+
type: 'portal',
|
|
1441
|
+
destroyed: boolean,
|
|
1442
|
+
rawValue: never | undefined,
|
|
1443
|
+
portalContainer: NgtRendererNode<'three'> | undefined,
|
|
1444
|
+
injector: Injector | undefined,
|
|
1445
|
+
parent: any | undefined,
|
|
1446
|
+
children: any[]
|
|
1447
|
+
];
|
|
1448
|
+
type PlatformRendererState = [
|
|
1449
|
+
type: 'platform',
|
|
1450
|
+
destroyed: boolean,
|
|
1451
|
+
rawValue: never | undefined,
|
|
1452
|
+
portalContainer: never | undefined,
|
|
1453
|
+
injector: never | undefined,
|
|
1454
|
+
parent: NgtRendererNode<'three' | 'portal'> | undefined,
|
|
1455
|
+
children: Array<NgtRendererNode<'three' | 'portal' | 'comment'>>
|
|
1456
|
+
];
|
|
1457
|
+
type CommentRendererState = [
|
|
1458
|
+
type: 'comment',
|
|
1459
|
+
destroyed: boolean,
|
|
1460
|
+
rawValue: never | undefined,
|
|
1461
|
+
portalContainer: never | undefined,
|
|
1462
|
+
injector: Injector | undefined,
|
|
1463
|
+
parent: NgtRendererNode | undefined,
|
|
1464
|
+
children: NgtRendererNode[]
|
|
1465
|
+
];
|
|
1466
|
+
type TextRendererState = [
|
|
1467
|
+
type: 'text',
|
|
1468
|
+
destroyed: boolean,
|
|
1469
|
+
rawValue: never | undefined,
|
|
1470
|
+
portalContainer: never | undefined,
|
|
1471
|
+
injector: never | undefined,
|
|
1472
|
+
parent: NgtRendererNode | undefined,
|
|
1473
|
+
children: NgtRendererNode[]
|
|
1474
|
+
];
|
|
1475
|
+
type NgtRendererStateMap = {
|
|
1476
|
+
three: ThreeRendererState;
|
|
1477
|
+
portal: PortalRendererState;
|
|
1478
|
+
platform: PlatformRendererState;
|
|
1479
|
+
comment: CommentRendererState;
|
|
1480
|
+
text: TextRendererState;
|
|
1481
|
+
};
|
|
1482
|
+
interface NgtRendererNode<TType extends keyof NgtRendererStateMap = keyof NgtRendererStateMap> extends NgtAnyRecord {
|
|
1483
|
+
[NGT_RENDERER_NODE_FLAG]: NgtRendererStateMap[TType];
|
|
1484
|
+
[NGT_DOM_PARENT_FLAG]?: HTMLElement;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Configuration options for the Angular Three renderer factory.
|
|
1489
|
+
*/
|
|
1490
|
+
interface NgtRendererFactory2Options {
|
|
1491
|
+
/**
|
|
1492
|
+
* Enable verbose logging for debugging renderer operations.
|
|
1493
|
+
* @default false
|
|
1494
|
+
*/
|
|
1495
|
+
verbose?: boolean;
|
|
1496
|
+
/**
|
|
1497
|
+
* When a change happens to an object's direct children, Angular Three will notify the object's ancestors
|
|
1498
|
+
* of this change so the ancestors are aware of the updated matrices of the object. In order to reduce the
|
|
1499
|
+
* number of notifications, Angular Three caches and skips notifications when possible.
|
|
1500
|
+
*
|
|
1501
|
+
* However, this can cause missed notifications in some cases. Control the number of skips with this option.
|
|
1502
|
+
*
|
|
1503
|
+
* @default 5
|
|
1504
|
+
*/
|
|
1505
|
+
maxNotificationSkipCount?: number;
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Injection token for renderer factory options.
|
|
1509
|
+
*/
|
|
1510
|
+
declare const NGT_RENDERER_OPTIONS: InjectionToken<NgtRendererFactory2Options>;
|
|
1511
|
+
/**
|
|
1512
|
+
* Angular renderer factory for Three.js elements.
|
|
1513
|
+
*
|
|
1514
|
+
* This factory creates NgtRenderer2 instances for components that use Angular Three.
|
|
1515
|
+
* It intercepts Angular's rendering operations and translates them to Three.js object
|
|
1516
|
+
* creation and manipulation.
|
|
1517
|
+
*
|
|
1518
|
+
* The factory is typically provided via `provideNgtRenderer()` in your application config.
|
|
1519
|
+
*
|
|
1520
|
+
* @example
|
|
1521
|
+
* ```typescript
|
|
1522
|
+
* // In app.config.ts
|
|
1523
|
+
* import { provideNgtRenderer } from 'angular-three/dom';
|
|
1524
|
+
*
|
|
1525
|
+
* export const appConfig: ApplicationConfig = {
|
|
1526
|
+
* providers: [provideNgtRenderer()]
|
|
1527
|
+
* };
|
|
1528
|
+
* ```
|
|
1529
|
+
*/
|
|
1530
|
+
declare class NgtRendererFactory2 implements RendererFactory2 {
|
|
1531
|
+
private delegateRendererFactory;
|
|
1532
|
+
private catalogue;
|
|
1533
|
+
private document;
|
|
1534
|
+
private options;
|
|
1535
|
+
private rendererMap;
|
|
1536
|
+
/**
|
|
1537
|
+
* NOTE: We use `useFactory` to instantiate `NgtRendererFactory2`
|
|
1538
|
+
*/
|
|
1539
|
+
constructor(delegateRendererFactory: RendererFactory2);
|
|
1540
|
+
createRenderer(hostElement: any, type: RendererType2 | null): Renderer2;
|
|
1541
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtRendererFactory2, never>;
|
|
1542
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<NgtRendererFactory2>;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Custom Angular renderer for Three.js elements.
|
|
1546
|
+
*
|
|
1547
|
+
* This renderer intercepts Angular's DOM operations and translates them to Three.js
|
|
1548
|
+
* object manipulations. It handles:
|
|
1549
|
+
* - Element creation (converting ngt-* elements to Three.js objects)
|
|
1550
|
+
* - Property/attribute setting (applying props to Three.js objects)
|
|
1551
|
+
* - Event listening (setting up Three.js event handlers)
|
|
1552
|
+
* - Parent-child relationships (managing the Three.js scene graph)
|
|
1553
|
+
*
|
|
1554
|
+
* @internal
|
|
1555
|
+
*/
|
|
1556
|
+
declare class NgtRenderer2 implements Renderer2 {
|
|
1557
|
+
delegateRenderer: Renderer2;
|
|
1558
|
+
private catalogue;
|
|
1559
|
+
private document;
|
|
1560
|
+
private options;
|
|
1561
|
+
count: number;
|
|
1562
|
+
private argsInjectors;
|
|
1563
|
+
private parentInjectors;
|
|
1564
|
+
constructor(delegateRenderer: Renderer2, catalogue: Record<string, NgtConstructorRepresentation>, document: Document, options: NgtRendererFactory2Options, count?: number);
|
|
1565
|
+
get data(): {
|
|
1566
|
+
[key: string]: any;
|
|
1567
|
+
};
|
|
1568
|
+
destroy(): void;
|
|
1569
|
+
createElement(name: string, namespace?: string | null): NgtRendererNode<"three"> | NgtRendererNode<"platform"> | NgtRendererNode<"portal">;
|
|
1570
|
+
createComment(value: string): NgtRendererNode<"comment">;
|
|
1571
|
+
createText(value: string): NgtRendererNode<"text">;
|
|
1572
|
+
destroyNode: (node: NgtRendererNode) => void;
|
|
1573
|
+
appendChild(parent: NgtRendererNode, newChild: NgtRendererNode, refChild?: NgtRendererNode, isMove?: boolean): void;
|
|
1574
|
+
insertBefore(parent: NgtRendererNode, newChild: NgtRendererNode, refChild: NgtRendererNode, isMove?: boolean): void;
|
|
1575
|
+
removeChild(parent: NgtRendererNode, oldChild: NgtRendererNode, isHostElement?: boolean): void;
|
|
1576
|
+
parentNode(node: NgtRendererNode): any;
|
|
1577
|
+
removeAttribute(el: NgtRendererNode, name: string, namespace?: string | null): void;
|
|
1578
|
+
setAttribute(el: NgtRendererNode, name: string, value: string, namespace?: string | null): void;
|
|
1579
|
+
setProperty(el: NgtRendererNode, name: string, value: any): void;
|
|
1580
|
+
listen(target: 'window' | 'document' | 'body' | NgtRendererNode, eventName: string, callback: (event: any) => boolean | void): () => void;
|
|
1581
|
+
private appendThreeRendererNodes;
|
|
1582
|
+
private setNodeRelationship;
|
|
1583
|
+
private getNgtDirective;
|
|
1584
|
+
private normalizeAttach;
|
|
1585
|
+
addClass: (el: any, name: string) => void;
|
|
1586
|
+
removeClass: (el: any, name: string) => void;
|
|
1587
|
+
setStyle: (el: any, style: string, value: any, flags?: _angular_core.RendererStyleFlags2) => void;
|
|
1588
|
+
removeStyle: (el: any, style: string, flags?: _angular_core.RendererStyleFlags2) => void;
|
|
1589
|
+
selectRootElement: (selectorOrNode: string | any, preserveContent?: boolean) => any;
|
|
1590
|
+
nextSibling: (node: any) => any;
|
|
1591
|
+
setValue: (node: any, value: string) => void;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Creates a canvas root initializer function.
|
|
1596
|
+
*
|
|
1597
|
+
* This function sets up the Three.js rendering context including the WebGL renderer,
|
|
1598
|
+
* camera, scene, and all related state. It returns a configurator object that can
|
|
1599
|
+
* be used to update canvas options and destroy the root.
|
|
1600
|
+
*
|
|
1601
|
+
* @param injector - Optional injector for dependency injection
|
|
1602
|
+
* @returns A function that takes a canvas element and returns a configurator
|
|
1603
|
+
*
|
|
1604
|
+
* @example
|
|
1605
|
+
* ```typescript
|
|
1606
|
+
* const initRoot = canvasRootInitializer();
|
|
1607
|
+
* const configurator = initRoot(canvasElement);
|
|
1608
|
+
* configurator.configure({ shadows: true, dpr: [1, 2] });
|
|
1609
|
+
* ```
|
|
1610
|
+
*/
|
|
1611
|
+
declare function canvasRootInitializer(injector?: Injector): (canvas: NgtCanvasElement) => {
|
|
1612
|
+
isConfigured: boolean;
|
|
1613
|
+
destroy: (timeout?: number) => void;
|
|
1614
|
+
configure: (inputs: NgtCanvasOptions) => void;
|
|
1615
|
+
};
|
|
1616
|
+
/**
|
|
1617
|
+
* Type representing the canvas configurator returned by canvasRootInitializer.
|
|
1618
|
+
*/
|
|
1619
|
+
type NgtCanvasConfigurator = ReturnType<ReturnType<typeof canvasRootInitializer>>;
|
|
1620
|
+
/**
|
|
1621
|
+
* Disposes an object and all its disposable properties.
|
|
1622
|
+
*
|
|
1623
|
+
* Recursively calls dispose() on the object and all its properties that have
|
|
1624
|
+
* a dispose method, except for Scene objects which are handled separately.
|
|
1625
|
+
*
|
|
1626
|
+
* @typeParam T - The type of the object to dispose
|
|
1627
|
+
* @param obj - The object to dispose
|
|
1628
|
+
*/
|
|
1629
|
+
declare function dispose<T extends NgtDisposable>(obj: T): void;
|
|
1630
|
+
|
|
1631
|
+
/**
|
|
1632
|
+
* Component for rendering Three.js scenes based on Angular Router routes.
|
|
1633
|
+
*
|
|
1634
|
+
* This component wraps a router-outlet and ensures proper change detection
|
|
1635
|
+
* when routes change. Use this when you want to have different Three.js scenes
|
|
1636
|
+
* for different routes in your application.
|
|
1637
|
+
*
|
|
1638
|
+
* @example
|
|
1639
|
+
* ```typescript
|
|
1640
|
+
* // In your routes configuration
|
|
1641
|
+
* const routes: Routes = [
|
|
1642
|
+
* { path: 'scene1', component: Scene1Component },
|
|
1643
|
+
* { path: 'scene2', component: Scene2Component },
|
|
1644
|
+
* ];
|
|
1645
|
+
*
|
|
1646
|
+
* // In your template
|
|
1647
|
+
* <ngt-canvas>
|
|
1648
|
+
* <ngt-routed-scene *canvasContent />
|
|
1649
|
+
* </ngt-canvas>
|
|
1650
|
+
* ```
|
|
1651
|
+
*/
|
|
1652
|
+
declare class NgtRoutedScene {
|
|
1653
|
+
constructor(router: Router, cdr: ChangeDetectorRef);
|
|
1654
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtRoutedScene, never>;
|
|
1655
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NgtRoutedScene, "ngt-routed-scene", never, {}, {}, never, never, true, never>;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
/**
|
|
1659
|
+
* Factory function to create the Angular Three store.
|
|
1660
|
+
*
|
|
1661
|
+
* Creates and initializes the central state management store for the Angular Three application.
|
|
1662
|
+
* This store contains all the state needed for rendering including the WebGL renderer, camera, scene,
|
|
1663
|
+
* raycaster, and internal state for managing the render loop and event handling.
|
|
1664
|
+
*
|
|
1665
|
+
* @returns A SignalState containing the NgtState object with reactive signals for all state properties
|
|
1666
|
+
*
|
|
1667
|
+
* @example
|
|
1668
|
+
* ```typescript
|
|
1669
|
+
* // Usually provided automatically by NgtCanvas
|
|
1670
|
+
* providers: [{ provide: NGT_STORE, useFactory: storeFactory }]
|
|
1671
|
+
* ```
|
|
1672
|
+
*/
|
|
1673
|
+
declare function storeFactory(): SignalState<NgtState>;
|
|
1674
|
+
/**
|
|
1675
|
+
* Injection token for the Angular Three store.
|
|
1676
|
+
*
|
|
1677
|
+
* Use this token to access the store directly via Angular's dependency injection system.
|
|
1678
|
+
* The store contains the complete state of the Three.js scene including renderer, camera, scene, and more.
|
|
1679
|
+
*
|
|
1680
|
+
* @example
|
|
1681
|
+
* ```typescript
|
|
1682
|
+
* const store = inject(NGT_STORE);
|
|
1683
|
+
* const camera = store.camera();
|
|
1684
|
+
* ```
|
|
1685
|
+
*/
|
|
1686
|
+
declare const NGT_STORE: InjectionToken<SignalState<NgtState>>;
|
|
1687
|
+
/**
|
|
1688
|
+
* Injects the Angular Three store into the current injection context.
|
|
1689
|
+
*
|
|
1690
|
+
* This is the primary way to access the store in components, directives, and services.
|
|
1691
|
+
* The store provides reactive signals for all Three.js state including the renderer,
|
|
1692
|
+
* camera, scene, raycaster, and more.
|
|
1693
|
+
*
|
|
1694
|
+
* @param options - Optional injection options (e.g., { optional: true, skipSelf: true })
|
|
1695
|
+
* @returns The Angular Three store as a SignalState, or null if optional and not found
|
|
1696
|
+
*
|
|
1697
|
+
* @example
|
|
1698
|
+
* ```typescript
|
|
1699
|
+
* // In a component or directive
|
|
1700
|
+
* const store = injectStore();
|
|
1701
|
+
*
|
|
1702
|
+
* // Access reactive state
|
|
1703
|
+
* const camera = store.camera();
|
|
1704
|
+
* const scene = store.scene();
|
|
1705
|
+
*
|
|
1706
|
+
* // Access snapshot (non-reactive)
|
|
1707
|
+
* const { gl, size } = store.snapshot;
|
|
1708
|
+
* ```
|
|
1709
|
+
*/
|
|
1710
|
+
declare function injectStore(options: InjectOptions & {
|
|
1711
|
+
optional?: false;
|
|
1712
|
+
}): SignalState<NgtState>;
|
|
1713
|
+
declare function injectStore(options: InjectOptions): SignalState<NgtState> | null;
|
|
1714
|
+
declare function injectStore(): SignalState<NgtState>;
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* Internal symbol used to temporarily store the parent's store on an instance.
|
|
1718
|
+
* This is a workaround to give the instance access to the store from its parent
|
|
1719
|
+
* during property application. The property is cleared after applyProps completes.
|
|
1720
|
+
* @internal
|
|
1721
|
+
*/
|
|
1722
|
+
declare const NGT_APPLY_PROPS = "__ngt_apply_props__";
|
|
1723
|
+
/**
|
|
1724
|
+
* Resolves a property key that may contain dot notation (pierced props).
|
|
1725
|
+
*
|
|
1726
|
+
* This function handles nested property access like 'position.x' by traversing
|
|
1727
|
+
* the object hierarchy and returning the final target object and key.
|
|
1728
|
+
*
|
|
1729
|
+
* @param instance - The root instance to start from
|
|
1730
|
+
* @param key - The property key, potentially with dot notation
|
|
1731
|
+
* @returns An object containing the root object, target key, and target property value
|
|
1732
|
+
*
|
|
1733
|
+
* @example
|
|
1734
|
+
* ```typescript
|
|
1735
|
+
* const mesh = new THREE.Mesh();
|
|
1736
|
+
* const result = resolveInstanceKey(mesh, 'position.x');
|
|
1737
|
+
* // result.root = mesh.position
|
|
1738
|
+
* // result.targetKey = 'x'
|
|
1739
|
+
* // result.targetProp = mesh.position.x
|
|
1740
|
+
* ```
|
|
1741
|
+
*/
|
|
1742
|
+
declare function resolveInstanceKey(instance: any, key: string): {
|
|
1743
|
+
root: any;
|
|
1744
|
+
targetKey: string;
|
|
1745
|
+
targetProp: any;
|
|
1746
|
+
};
|
|
1747
|
+
/**
|
|
1748
|
+
* Applies a set of properties to a Three.js instance.
|
|
1749
|
+
*
|
|
1750
|
+
* This is the core function for updating Three.js objects with new property values.
|
|
1751
|
+
* It handles various property types including:
|
|
1752
|
+
* - Math types (Vector3, Color, Euler, etc.) with automatic conversion
|
|
1753
|
+
* - Pierced props (dot notation like 'position.x')
|
|
1754
|
+
* - Arrays (converted to set/fromArray calls)
|
|
1755
|
+
* - Layers (mask copying)
|
|
1756
|
+
* - Textures (automatic color space management)
|
|
1757
|
+
*
|
|
1758
|
+
* After applying props, the function triggers necessary updates like
|
|
1759
|
+
* camera projection matrix updates and texture needsUpdate flags.
|
|
1760
|
+
*
|
|
1761
|
+
* @typeParam T - The type of the Three.js instance
|
|
1762
|
+
* @param instance - The Three.js instance to update
|
|
1763
|
+
* @param props - An object containing the properties to apply
|
|
1764
|
+
* @returns The updated instance
|
|
1765
|
+
*
|
|
1766
|
+
* @example
|
|
1767
|
+
* ```typescript
|
|
1768
|
+
* const mesh = new THREE.Mesh();
|
|
1769
|
+
* applyProps(mesh, {
|
|
1770
|
+
* position: [1, 2, 3],
|
|
1771
|
+
* 'rotation.x': Math.PI / 2,
|
|
1772
|
+
* visible: true
|
|
1773
|
+
* });
|
|
1774
|
+
* ```
|
|
1775
|
+
*/
|
|
1776
|
+
declare function applyProps<T extends NgtAnyRecord>(instance: NgtInstanceState<T>['object'], props: NgtAnyRecord): T & {
|
|
1777
|
+
__ngt__?: NgtInstanceState<T> | undefined;
|
|
1778
|
+
};
|
|
1779
|
+
|
|
1780
|
+
/**
|
|
1781
|
+
* Attaches a value to an object at the specified path.
|
|
1782
|
+
*
|
|
1783
|
+
* This function recursively traverses the path and sets the value at the final key.
|
|
1784
|
+
* It's used internally to implement the `attach` property on Three.js elements.
|
|
1785
|
+
*
|
|
1786
|
+
* @param object - The target object to attach to
|
|
1787
|
+
* @param value - The value to attach
|
|
1788
|
+
* @param paths - An array of path segments (e.g., ['material', 'map'])
|
|
1789
|
+
* @param useApplyProps - Whether to use applyProps for setting the value
|
|
1790
|
+
*
|
|
1791
|
+
* @example
|
|
1792
|
+
* ```typescript
|
|
1793
|
+
* const mesh = new THREE.Mesh();
|
|
1794
|
+
* attach(mesh, texture, ['material', 'map']);
|
|
1795
|
+
* // mesh.material.map = texture
|
|
1796
|
+
* ```
|
|
1797
|
+
*/
|
|
1798
|
+
declare function attach(object: NgtInstanceNode, value: unknown, paths?: string[], useApplyProps?: boolean): void;
|
|
1799
|
+
/**
|
|
1800
|
+
* Detaches a child from its parent, restoring the previous value.
|
|
1801
|
+
*
|
|
1802
|
+
* This function reverses the attach operation by restoring the previous value
|
|
1803
|
+
* that was stored when the child was attached.
|
|
1804
|
+
*
|
|
1805
|
+
* @param parent - The parent object
|
|
1806
|
+
* @param child - The child object to detach
|
|
1807
|
+
* @param attachProp - The attach path or function that was used
|
|
1808
|
+
*/
|
|
1809
|
+
declare function detach(parent: NgtInstanceNode, child: NgtInstanceNode, attachProp: string[] | NgtAttachFunction): void;
|
|
1810
|
+
/**
|
|
1811
|
+
* Creates a custom attach function for advanced attachment scenarios.
|
|
1812
|
+
*
|
|
1813
|
+
* Use this when you need custom logic for attaching a child to a parent,
|
|
1814
|
+
* such as when the relationship isn't a simple property assignment.
|
|
1815
|
+
*
|
|
1816
|
+
* @typeParam TChild - The type of the child object
|
|
1817
|
+
* @typeParam TParent - The type of the parent object
|
|
1818
|
+
* @param cb - Callback that performs the attachment and optionally returns a cleanup function
|
|
1819
|
+
* @returns An attach function compatible with the `attach` property
|
|
1820
|
+
*
|
|
1821
|
+
* @example
|
|
1822
|
+
* ```typescript
|
|
1823
|
+
* const customAttach = createAttachFunction<THREE.Mesh, THREE.Group>(
|
|
1824
|
+
* ({ parent, child, store }) => {
|
|
1825
|
+
* parent.add(child);
|
|
1826
|
+
* return () => parent.remove(child);
|
|
1827
|
+
* }
|
|
1828
|
+
* );
|
|
1829
|
+
* ```
|
|
1830
|
+
*/
|
|
1831
|
+
declare function createAttachFunction<TChild = any, TParent = any>(cb: (params: {
|
|
1832
|
+
parent: TParent;
|
|
1833
|
+
child: TChild;
|
|
1834
|
+
store: SignalState<NgtState>;
|
|
1835
|
+
}) => (() => void) | void): NgtAttachFunction<TChild, TParent>;
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* `beforeRender` invokes its callback on every frame. Hence, the notion of tracking
|
|
1839
|
+
* changes (i.e: signals) does not really matter since we're getting latest values of the things we need on every frame anyway.
|
|
1840
|
+
*
|
|
1841
|
+
* If `priority` is a Signal, `beforeRender` will set up an Effect internally and returns the `EffectRef#destroy` instead.
|
|
1842
|
+
*
|
|
1843
|
+
* @example
|
|
1844
|
+
* ```ts
|
|
1845
|
+
* const destroy = beforeRender(
|
|
1846
|
+
* ({ gl, camera }) => {
|
|
1847
|
+
* // before render logic
|
|
1848
|
+
* },
|
|
1849
|
+
* {
|
|
1850
|
+
* priority: this.priority, // this.priority is a Signal<number>
|
|
1851
|
+
* }
|
|
1852
|
+
* )
|
|
1853
|
+
* ```
|
|
1854
|
+
*/
|
|
1855
|
+
declare function beforeRender(cb: NgtBeforeRenderRecord['callback'], { priority, injector }?: {
|
|
1856
|
+
priority?: number | (() => number);
|
|
1857
|
+
injector?: Injector;
|
|
1858
|
+
}): () => void;
|
|
1859
|
+
/**
|
|
1860
|
+
* @deprecated Use `beforeRender` instead. Will be removed in v5.0.0
|
|
1861
|
+
* @since v4.0.0
|
|
1862
|
+
*/
|
|
1863
|
+
declare const injectBeforeRender: typeof beforeRender;
|
|
1864
|
+
|
|
1865
|
+
/**
|
|
1866
|
+
* Directive for binding Three.js element lifecycle events to outputs.
|
|
1867
|
+
*
|
|
1868
|
+
* This directive provides outputs for Angular Three element events and native
|
|
1869
|
+
* Three.js events like added, removed, and disposed. It's designed to be used
|
|
1870
|
+
* as a host directive.
|
|
1871
|
+
*
|
|
1872
|
+
* Outputs:
|
|
1873
|
+
* - Angular Three: created, attached, updated
|
|
1874
|
+
* - Three.js: added, removed, childadded, childremoved, change, disposed
|
|
1875
|
+
*
|
|
1876
|
+
* Input: `elementEvents` - The element to listen for events on
|
|
1877
|
+
*
|
|
1878
|
+
* @example
|
|
1879
|
+
* ```typescript
|
|
1880
|
+
* @Component({
|
|
1881
|
+
* hostDirectives: [{
|
|
1882
|
+
* directive: NgtElementEvents,
|
|
1883
|
+
* inputs: ['elementEvents: events'],
|
|
1884
|
+
* outputs: ['attached', 'updated']
|
|
1885
|
+
* }]
|
|
1886
|
+
* })
|
|
1887
|
+
* export class MyMesh {
|
|
1888
|
+
* elementEvents = inject(NgtElementEvents, { host: true });
|
|
1889
|
+
*
|
|
1890
|
+
* constructor() {
|
|
1891
|
+
* this.elementEvents.events.set(this.meshRef);
|
|
1892
|
+
* }
|
|
1893
|
+
* }
|
|
1894
|
+
* ```
|
|
1895
|
+
*/
|
|
1896
|
+
declare class NgtElementEvents<TElement extends object> {
|
|
1897
|
+
created: _angular_core.OutputEmitterRef<TElement>;
|
|
1898
|
+
attached: _angular_core.OutputEmitterRef<NgtAfterAttach<TElement, angular_three.NgtInstanceNode<angular_three.NgtAnyRecord>>>;
|
|
1899
|
+
updated: _angular_core.OutputEmitterRef<TElement>;
|
|
1900
|
+
added: _angular_core.OutputEmitterRef<any>;
|
|
1901
|
+
removed: _angular_core.OutputEmitterRef<any>;
|
|
1902
|
+
childadded: _angular_core.OutputEmitterRef<any>;
|
|
1903
|
+
childremoved: _angular_core.OutputEmitterRef<any>;
|
|
1904
|
+
change: _angular_core.OutputEmitterRef<any>;
|
|
1905
|
+
disposed: _angular_core.OutputEmitterRef<any>;
|
|
1906
|
+
events: _angular_core.ModelSignal<TElement | ElementRef<TElement> | (() => ElementRef<TElement> | TElement | null | undefined) | null | undefined>;
|
|
1907
|
+
constructor();
|
|
1908
|
+
private emitEvent;
|
|
1909
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtElementEvents<any>, never>;
|
|
1910
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtElementEvents<any>, "[elementEvents]", never, { "events": { "alias": "elementEvents"; "required": false; "isSignal": true; }; }, { "created": "created"; "attached": "attached"; "updated": "updated"; "added": "added"; "removed": "removed"; "childadded": "childadded"; "childremoved": "childremoved"; "change": "change"; "disposed": "disposed"; "events": "elementEventsChange"; }, never, never, true, never>;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Sets up element lifecycle event listeners on a Three.js element.
|
|
1914
|
+
*
|
|
1915
|
+
* @typeParam TElement - The type of the element
|
|
1916
|
+
* @param target - Signal containing the target element
|
|
1917
|
+
* @param events - Object mapping event names to handler functions
|
|
1918
|
+
* @param options - Optional injector for dependency injection
|
|
1919
|
+
* @returns Array of cleanup functions
|
|
1920
|
+
*
|
|
1921
|
+
* @example
|
|
1922
|
+
* ```typescript
|
|
1923
|
+
* elementEvents(
|
|
1924
|
+
* () => this.meshRef.nativeElement,
|
|
1925
|
+
* {
|
|
1926
|
+
* created: (mesh) => console.log('Mesh created'),
|
|
1927
|
+
* attached: ({ parent, node }) => console.log('Attached to', parent),
|
|
1928
|
+
* }
|
|
1929
|
+
* );
|
|
1930
|
+
* ```
|
|
1931
|
+
*/
|
|
1932
|
+
declare function elementEvents<TElement extends object>(target: () => ElementRef<TElement> | TElement | null | undefined, events: {
|
|
1933
|
+
created?: (element: TElement) => void;
|
|
1934
|
+
updated?: (element: TElement) => void;
|
|
1935
|
+
attached?: (element: NgtAfterAttach<TElement>) => void;
|
|
1936
|
+
added?: (event: any) => void;
|
|
1937
|
+
removed?: (event: any) => void;
|
|
1938
|
+
childadded?: (event: any) => void;
|
|
1939
|
+
childremoved?: (event: any) => void;
|
|
1940
|
+
change?: (event: any) => void;
|
|
1941
|
+
disposed?: (event: any) => void;
|
|
1942
|
+
}, { injector }?: {
|
|
1943
|
+
injector?: Injector;
|
|
1944
|
+
}): (() => void)[];
|
|
1945
|
+
|
|
1946
|
+
/**
|
|
1947
|
+
* Collection of type checking and comparison utilities for Angular Three.
|
|
1948
|
+
*
|
|
1949
|
+
* These utilities help with runtime type checking of Three.js objects,
|
|
1950
|
+
* Angular references, and general equality comparisons.
|
|
1951
|
+
*
|
|
1952
|
+
* @example
|
|
1953
|
+
* ```typescript
|
|
1954
|
+
* // Check if something is a Three.js mesh
|
|
1955
|
+
* if (is.three<THREE.Mesh>(obj, 'isMesh')) {
|
|
1956
|
+
* // obj is typed as THREE.Mesh
|
|
1957
|
+
* }
|
|
1958
|
+
*
|
|
1959
|
+
* // Check if two values are equal
|
|
1960
|
+
* if (is.equ(a, b, { objects: 'shallow' })) {
|
|
1961
|
+
* // values are considered equal
|
|
1962
|
+
* }
|
|
1963
|
+
* ```
|
|
1964
|
+
*/
|
|
1965
|
+
declare const is: {
|
|
1966
|
+
/** Checks if value is a plain object (not array or function) */
|
|
1967
|
+
obj: (a: unknown) => a is object;
|
|
1968
|
+
/** Checks if value is a Three.js Material */
|
|
1969
|
+
material: (a: unknown) => a is THREE.Material;
|
|
1970
|
+
/** Checks if value is a Three.js BufferGeometry */
|
|
1971
|
+
geometry: (a: unknown) => a is THREE.BufferGeometry;
|
|
1972
|
+
/** Checks if value is a Three.js OrthographicCamera */
|
|
1973
|
+
orthographicCamera: (a: unknown) => a is THREE.OrthographicCamera;
|
|
1974
|
+
/** Checks if value is a Three.js PerspectiveCamera */
|
|
1975
|
+
perspectiveCamera: (a: unknown) => a is THREE.PerspectiveCamera;
|
|
1976
|
+
/** Checks if value is a Three.js Camera */
|
|
1977
|
+
camera: (a: unknown) => a is THREE.Camera;
|
|
1978
|
+
/** Checks if value is a renderer-like object with a render method */
|
|
1979
|
+
renderer: (a: unknown) => boolean;
|
|
1980
|
+
/** Checks if value is a Three.js Scene */
|
|
1981
|
+
scene: (a: unknown) => a is THREE.Scene;
|
|
1982
|
+
/** Checks if value is an Angular ElementRef */
|
|
1983
|
+
ref: (a: unknown) => a is ElementRef;
|
|
1984
|
+
/** Checks if value is an Angular Three instance node (prepared object) */
|
|
1985
|
+
instance: (a: unknown) => a is NgtInstanceNode;
|
|
1986
|
+
/** Checks if value is a Three.js Object3D */
|
|
1987
|
+
object3D: (a: unknown) => a is THREE.Object3D;
|
|
1988
|
+
/**
|
|
1989
|
+
* Generic Three.js type check using the is* pattern.
|
|
1990
|
+
* @example is.three<THREE.Mesh>(obj, 'isMesh')
|
|
1991
|
+
*/
|
|
1992
|
+
three: <TThreeEntity extends object, TKey extends keyof TThreeEntity = keyof TThreeEntity>(a: unknown, isKey: TKey extends `is${infer K}` ? TKey : never) => a is TThreeEntity;
|
|
1993
|
+
/** Checks if value is a valid Three.js ColorRepresentation */
|
|
1994
|
+
colorRepresentation: (a: unknown) => a is THREE.ColorRepresentation;
|
|
1995
|
+
/** Checks if object has colorSpace or outputColorSpace property */
|
|
1996
|
+
colorSpaceExist: <T extends NgtRendererLike | THREE.Texture | object, P = T extends NgtRendererLike ? {
|
|
1997
|
+
outputColorSpace: string;
|
|
1998
|
+
} : {
|
|
1999
|
+
colorSpace: string;
|
|
2000
|
+
}>(object: T) => object is T & P;
|
|
2001
|
+
/**
|
|
2002
|
+
* Deep equality comparison with configurable behavior for arrays and objects.
|
|
2003
|
+
* @param a - First value to compare
|
|
2004
|
+
* @param b - Second value to compare
|
|
2005
|
+
* @param config - Comparison configuration
|
|
2006
|
+
*/
|
|
2007
|
+
equ(a: any, b: any, { arrays, objects, strict }?: NgtEquConfig): boolean;
|
|
2008
|
+
};
|
|
2009
|
+
|
|
2010
|
+
/**
|
|
2011
|
+
* Directive for binding Three.js pointer events to outputs.
|
|
2012
|
+
*
|
|
2013
|
+
* This directive provides outputs for all Three.js pointer events that can be used
|
|
2014
|
+
* with standard Angular event binding syntax. It's designed to be used as a host directive.
|
|
2015
|
+
*
|
|
2016
|
+
* Outputs: click, dblclick, contextmenu, pointerup, pointerdown, pointerover,
|
|
2017
|
+
* pointerout, pointerenter, pointerleave, pointermove, pointermissed, pointercancel, wheel
|
|
2018
|
+
*
|
|
2019
|
+
* Input: `objectEvents` - The Three.js object to listen for events on
|
|
2020
|
+
*
|
|
2021
|
+
* @example
|
|
2022
|
+
* ```typescript
|
|
2023
|
+
* @Component({
|
|
2024
|
+
* hostDirectives: [{
|
|
2025
|
+
* directive: NgtObjectEvents,
|
|
2026
|
+
* inputs: ['objectEvents: events'],
|
|
2027
|
+
* outputs: ['click', 'pointerover', 'pointerout']
|
|
2028
|
+
* }]
|
|
2029
|
+
* })
|
|
2030
|
+
* export class MyMesh {
|
|
2031
|
+
* objectEvents = inject(NgtObjectEvents, { host: true });
|
|
2032
|
+
*
|
|
2033
|
+
* constructor() {
|
|
2034
|
+
* this.objectEvents.events.set(this.meshRef);
|
|
2035
|
+
* }
|
|
2036
|
+
* }
|
|
2037
|
+
* ```
|
|
2038
|
+
*/
|
|
2039
|
+
declare class NgtObjectEvents {
|
|
2040
|
+
click: _angular_core.OutputEmitterRef<NgtThreeEvent<MouseEvent>>;
|
|
2041
|
+
dblclick: _angular_core.OutputEmitterRef<NgtThreeEvent<MouseEvent>>;
|
|
2042
|
+
contextmenu: _angular_core.OutputEmitterRef<NgtThreeEvent<MouseEvent>>;
|
|
2043
|
+
pointerup: _angular_core.OutputEmitterRef<NgtThreeEvent<PointerEvent>>;
|
|
2044
|
+
pointerdown: _angular_core.OutputEmitterRef<NgtThreeEvent<PointerEvent>>;
|
|
2045
|
+
pointerover: _angular_core.OutputEmitterRef<NgtThreeEvent<PointerEvent>>;
|
|
2046
|
+
pointerout: _angular_core.OutputEmitterRef<NgtThreeEvent<PointerEvent>>;
|
|
2047
|
+
pointerenter: _angular_core.OutputEmitterRef<NgtThreeEvent<PointerEvent>>;
|
|
2048
|
+
pointerleave: _angular_core.OutputEmitterRef<NgtThreeEvent<PointerEvent>>;
|
|
2049
|
+
pointermove: _angular_core.OutputEmitterRef<NgtThreeEvent<PointerEvent>>;
|
|
2050
|
+
pointermissed: _angular_core.OutputEmitterRef<NgtThreeEvent<MouseEvent>>;
|
|
2051
|
+
pointercancel: _angular_core.OutputEmitterRef<NgtThreeEvent<PointerEvent>>;
|
|
2052
|
+
wheel: _angular_core.OutputEmitterRef<NgtThreeEvent<WheelEvent>>;
|
|
2053
|
+
events: _angular_core.ModelSignal<THREE.Object3D<THREE.Object3DEventMap> | ElementRef<THREE.Object3D<THREE.Object3DEventMap>> | (() => ElementRef<THREE.Object3D> | THREE.Object3D | null | undefined) | null | undefined>;
|
|
2054
|
+
constructor();
|
|
2055
|
+
private emitEvent;
|
|
2056
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgtObjectEvents, never>;
|
|
2057
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<NgtObjectEvents, "[objectEvents]", never, { "events": { "alias": "objectEvents"; "required": false; "isSignal": true; }; }, { "click": "click"; "dblclick": "dblclick"; "contextmenu": "contextmenu"; "pointerup": "pointerup"; "pointerdown": "pointerdown"; "pointerover": "pointerover"; "pointerout": "pointerout"; "pointerenter": "pointerenter"; "pointerleave": "pointerleave"; "pointermove": "pointermove"; "pointermissed": "pointermissed"; "pointercancel": "pointercancel"; "wheel": "wheel"; "events": "objectEventsChange"; }, never, never, true, never>;
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* @deprecated Use objectEvents instead. Will be removed in v5.0.0
|
|
2061
|
+
* @since v4.0.0
|
|
2062
|
+
*/
|
|
2063
|
+
declare const injectObjectEvents: typeof objectEvents;
|
|
2064
|
+
/**
|
|
2065
|
+
* Sets up event listeners on a Three.js object.
|
|
2066
|
+
*
|
|
2067
|
+
* This function creates reactive event bindings that automatically clean up
|
|
2068
|
+
* when the target changes or the component is destroyed.
|
|
2069
|
+
*
|
|
2070
|
+
* @param target - Signal containing the target Object3D
|
|
2071
|
+
* @param events - Object mapping event names to handler functions
|
|
2072
|
+
* @param options - Optional injector for dependency injection
|
|
2073
|
+
* @returns Array of cleanup functions
|
|
2074
|
+
*
|
|
2075
|
+
* @example
|
|
2076
|
+
* ```typescript
|
|
2077
|
+
* objectEvents(
|
|
2078
|
+
* () => this.meshRef.nativeElement,
|
|
2079
|
+
* {
|
|
2080
|
+
* click: (event) => console.log('Clicked!', event),
|
|
2081
|
+
* pointerover: (event) => console.log('Hover start'),
|
|
2082
|
+
* }
|
|
2083
|
+
* );
|
|
2084
|
+
* ```
|
|
2085
|
+
*/
|
|
2086
|
+
declare function objectEvents(target: () => ElementRef<THREE.Object3D> | THREE.Object3D | null | undefined, events: NgtEventHandlers, { injector }?: {
|
|
2087
|
+
injector?: Injector;
|
|
2088
|
+
}): (() => void)[];
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Gets the emit function from an OutputEmitterRef if it has active listeners.
|
|
2092
|
+
*
|
|
2093
|
+
* @typeParam T - The type of value the emitter emits
|
|
2094
|
+
* @param emitterRef - The output emitter reference
|
|
2095
|
+
* @returns The bound emit function, or undefined if no listeners
|
|
2096
|
+
*/
|
|
2097
|
+
declare function getEmitter<T>(emitterRef: OutputEmitterRef<T> | undefined): ((value: T) => void) | undefined;
|
|
2098
|
+
/**
|
|
2099
|
+
* Checks if any of the provided emitter refs have active listeners.
|
|
2100
|
+
*
|
|
2101
|
+
* @param emitterRefs - The output emitter references to check
|
|
2102
|
+
* @returns true if any emitter has listeners
|
|
2103
|
+
*/
|
|
2104
|
+
declare function hasListener(...emitterRefs: (OutputEmitterRef<unknown> | undefined)[]): boolean;
|
|
2105
|
+
|
|
2106
|
+
/**
|
|
2107
|
+
* @fileoverview Signal utilities for transforming and accessing object properties.
|
|
2108
|
+
*
|
|
2109
|
+
* This module provides computed signal utilities for working with object properties,
|
|
2110
|
+
* including `omit`, `pick`, `merge`, and vector conversion functions.
|
|
2111
|
+
*/
|
|
2112
|
+
type KeysOfType<TObject extends object, TType> = Exclude<{
|
|
2113
|
+
[K in keyof TObject]: TObject[K] extends TType | undefined | null ? K : never;
|
|
2114
|
+
}[keyof TObject], undefined>;
|
|
2115
|
+
/**
|
|
2116
|
+
* Creates a computed signal that omits specified keys from an object.
|
|
2117
|
+
*
|
|
2118
|
+
* @typeParam TObject - The type of the source object
|
|
2119
|
+
* @typeParam TKeys - The keys to omit
|
|
2120
|
+
* @param objFn - Function returning the source object
|
|
2121
|
+
* @param keysToOmit - Array of keys to omit
|
|
2122
|
+
* @param equal - Optional equality function for change detection
|
|
2123
|
+
* @returns A signal containing the object without the omitted keys
|
|
2124
|
+
*
|
|
2125
|
+
* @example
|
|
2126
|
+
* ```typescript
|
|
2127
|
+
* const state = signal({ a: 1, b: 2, c: 3 });
|
|
2128
|
+
* const withoutB = omit(() => state(), ['b']);
|
|
2129
|
+
* // withoutB() => { a: 1, c: 3 }
|
|
2130
|
+
* ```
|
|
2131
|
+
*/
|
|
2132
|
+
declare function omit<TObject extends object, TKeys extends (keyof TObject)[]>(objFn: () => TObject, keysToOmit: TKeys, equal?: ValueEqualityFn<NoInfer<Omit<TObject, TKeys[number]>>>): Signal<Omit<TObject, TKeys[number]>>;
|
|
2133
|
+
/**
|
|
2134
|
+
* Creates a computed signal that picks specified keys from an object.
|
|
2135
|
+
*
|
|
2136
|
+
* Can pick a single key (returning the value) or multiple keys (returning a partial object).
|
|
2137
|
+
*
|
|
2138
|
+
* @example
|
|
2139
|
+
* ```typescript
|
|
2140
|
+
* const state = signal({ a: 1, b: 2, c: 3 });
|
|
2141
|
+
*
|
|
2142
|
+
* // Pick single key
|
|
2143
|
+
* const a = pick(() => state(), 'a');
|
|
2144
|
+
* // a() => 1
|
|
2145
|
+
*
|
|
2146
|
+
* // Pick multiple keys
|
|
2147
|
+
* const ab = pick(() => state(), ['a', 'b']);
|
|
2148
|
+
* // ab() => { a: 1, b: 2 }
|
|
2149
|
+
* ```
|
|
2150
|
+
*/
|
|
2151
|
+
declare function pick<TObject extends object, TKey extends keyof TObject>(objFn: () => TObject, key: TKey, equal?: ValueEqualityFn<NoInfer<TObject[TKey]>>): Signal<TObject[TKey]>;
|
|
2152
|
+
declare function pick<TObject extends object, TKeys extends (keyof TObject)[]>(objFn: () => TObject, keys: TKeys, equal?: ValueEqualityFn<NoInfer<Pick<TObject, TKeys[number]>>>): Signal<Pick<TObject, TKeys[number]>>;
|
|
2153
|
+
/**
|
|
2154
|
+
* Creates a computed signal that merges an object with static values.
|
|
2155
|
+
*
|
|
2156
|
+
* @param objFn - Function returning the source object
|
|
2157
|
+
* @param toMerge - Static values to merge
|
|
2158
|
+
* @param mode - 'override' (default) puts toMerge values on top, 'backfill' puts them underneath
|
|
2159
|
+
* @param equal - Optional equality function
|
|
2160
|
+
* @returns A signal containing the merged object
|
|
2161
|
+
*
|
|
2162
|
+
* @example
|
|
2163
|
+
* ```typescript
|
|
2164
|
+
* const options = signal({ size: 10 });
|
|
2165
|
+
* const withDefaults = merge(() => options(), { color: 'red' }, 'backfill');
|
|
2166
|
+
* // withDefaults() => { color: 'red', size: 10 }
|
|
2167
|
+
* ```
|
|
2168
|
+
*/
|
|
2169
|
+
declare function merge<TObject extends object>(objFn: () => TObject, toMerge: Partial<TObject>, mode?: 'override' | 'backfill', equal?: ValueEqualityFn<NoInfer<TObject>>): Signal<TObject & Partial<TObject>>;
|
|
2170
|
+
type NgtVectorComputed<TVector extends THREE.Vector2 | THREE.Vector3 | THREE.Vector4, TNgtVector = TVector extends THREE.Vector2 ? NgtVector2 : TVector extends THREE.Vector3 ? NgtVector3 : NgtVector4> = {
|
|
2171
|
+
(input: Signal<TNgtVector>): Signal<TVector>;
|
|
2172
|
+
(input: Signal<TNgtVector>, keepUndefined: true): Signal<TVector | undefined>;
|
|
2173
|
+
<TObject extends object>(options: Signal<TObject>, key: KeysOfType<TObject, TNgtVector>): Signal<TVector>;
|
|
2174
|
+
<TObject extends object>(options: Signal<TObject>, key: KeysOfType<TObject, TNgtVector>, keepUndefined: true): Signal<TVector | undefined>;
|
|
2175
|
+
};
|
|
2176
|
+
/**
|
|
2177
|
+
* Creates a computed Vector2 signal from various input formats.
|
|
2178
|
+
*
|
|
2179
|
+
* Accepts: number (scalar), [x, y] array, or Vector2 instance.
|
|
2180
|
+
*
|
|
2181
|
+
* @example
|
|
2182
|
+
* ```typescript
|
|
2183
|
+
* const pos = vector2(input);
|
|
2184
|
+
* // or from options object
|
|
2185
|
+
* const pos = vector2(options, 'position');
|
|
2186
|
+
* ```
|
|
2187
|
+
*/
|
|
2188
|
+
declare const vector2: NgtVectorComputed<THREE.Vector2, number | THREE.Vector2 | [x: number, y: number]>;
|
|
2189
|
+
/**
|
|
2190
|
+
* Creates a computed Vector3 signal from various input formats.
|
|
2191
|
+
*
|
|
2192
|
+
* Accepts: number (scalar), [x, y, z] array, or Vector3 instance.
|
|
2193
|
+
*
|
|
2194
|
+
* @example
|
|
2195
|
+
* ```typescript
|
|
2196
|
+
* const pos = vector3(input);
|
|
2197
|
+
* // or from options object
|
|
2198
|
+
* const pos = vector3(options, 'position');
|
|
2199
|
+
* ```
|
|
2200
|
+
*/
|
|
2201
|
+
declare const vector3: NgtVectorComputed<THREE.Vector3, number | THREE.Vector3 | [x: number, y: number, z: number]>;
|
|
2202
|
+
/**
|
|
2203
|
+
* Creates a computed Vector4 signal from various input formats.
|
|
2204
|
+
*
|
|
2205
|
+
* Accepts: number (scalar), [x, y, z, w] array, or Vector4 instance.
|
|
2206
|
+
*
|
|
2207
|
+
* @example
|
|
2208
|
+
* ```typescript
|
|
2209
|
+
* const pos = vector4(input);
|
|
2210
|
+
* // or from options object
|
|
2211
|
+
* const pos = vector4(options, 'position');
|
|
2212
|
+
* ```
|
|
2213
|
+
*/
|
|
2214
|
+
declare const vector4: NgtVectorComputed<THREE.Vector4, number | THREE.Vector4 | [x: number, y: number, z: number, w: number]>;
|
|
2215
|
+
|
|
2216
|
+
/**
|
|
2217
|
+
* Resolves a value that may be wrapped in an Angular ElementRef.
|
|
2218
|
+
*
|
|
2219
|
+
* If the value is an ElementRef, returns its nativeElement.
|
|
2220
|
+
* Otherwise, returns the value directly.
|
|
2221
|
+
*
|
|
2222
|
+
* @typeParam TObject - The type of the object
|
|
2223
|
+
* @param ref - An ElementRef or direct value
|
|
2224
|
+
* @returns The unwrapped value
|
|
2225
|
+
*
|
|
2226
|
+
* @example
|
|
2227
|
+
* ```typescript
|
|
2228
|
+
* // With ElementRef
|
|
2229
|
+
* const mesh = resolveRef(meshRef); // returns meshRef.nativeElement
|
|
2230
|
+
*
|
|
2231
|
+
* // With direct value
|
|
2232
|
+
* const mesh = resolveRef(myMesh); // returns myMesh
|
|
2233
|
+
* ```
|
|
2234
|
+
*/
|
|
2235
|
+
declare function resolveRef<TObject>(ref: ElementRef<TObject | undefined> | TObject | undefined): TObject | undefined;
|
|
2236
|
+
|
|
2237
|
+
/**
|
|
2238
|
+
* Sets the needsUpdate flag on an object if it has one.
|
|
2239
|
+
*
|
|
2240
|
+
* Also sets uniformsNeedUpdate for shader materials.
|
|
2241
|
+
*
|
|
2242
|
+
* @param value - The object to update
|
|
2243
|
+
*/
|
|
2244
|
+
declare function checkNeedsUpdate(value: unknown): void;
|
|
2245
|
+
/**
|
|
2246
|
+
* Performs necessary updates on a Three.js object after property changes.
|
|
2247
|
+
*
|
|
2248
|
+
* For cameras, updates projection matrix and world matrix.
|
|
2249
|
+
* For other objects, sets the needsUpdate flag.
|
|
2250
|
+
*
|
|
2251
|
+
* @param value - The object to update
|
|
2252
|
+
*/
|
|
2253
|
+
declare function checkUpdate(value: unknown): void;
|
|
2254
|
+
/**
|
|
2255
|
+
* Updates a camera's projection based on the viewport size.
|
|
2256
|
+
*
|
|
2257
|
+
* For orthographic cameras, updates the frustum bounds.
|
|
2258
|
+
* For perspective cameras, updates the aspect ratio.
|
|
2259
|
+
* Skips update if the camera is marked as manual.
|
|
2260
|
+
*
|
|
2261
|
+
* @param camera - The camera to update
|
|
2262
|
+
* @param size - The current viewport size
|
|
2263
|
+
*/
|
|
2264
|
+
declare function updateCamera(camera: NgtCamera, size: NgtSize): void;
|
|
2265
|
+
|
|
2266
|
+
export { NGT_APPLY_PROPS, NGT_ARGS_FLAG, NGT_CANVAS_CONTENT_FLAG, NGT_CATALOGUE, NGT_DELEGATE_RENDERER_DESTROY_NODE_PATCHED_FLAG, NGT_DOM_PARENT_FLAG, NGT_GET_NODE_ATTRIBUTE_FLAG, NGT_HTML_FLAG, NGT_INTERNAL_ADD_COMMENT_FLAG, NGT_INTERNAL_SET_PARENT_COMMENT_FLAG, NGT_LOOP, NGT_PARENT_FLAG, NGT_PORTAL_CONTENT_FLAG, NGT_RENDERER_NODE_FLAG, NGT_RENDERER_OPTIONS, NGT_STORE, NgtArgs, NgtElementEvents, NgtHTML, NgtHexify, NgtObjectEvents, NgtParent, NgtPortal, NgtPortalAutoRender, NgtPortalContent, NgtPortalImpl, NgtRenderer2, NgtRendererFactory2, NgtRoutedScene, NgtSelect, NgtSelection, NgtSelectionApi, THREE_NATIVE_EVENTS, addAfterEffect, addEffect, addTail, applyProps, attach, beforeRender, canvasRootInitializer, checkNeedsUpdate, checkUpdate, createAttachFunction, createEvents, detach, dispose, elementEvents, extend, flushGlobalEffects, getEmitter, getInstanceState, getLocalState, hasListener, injectBeforeRender, injectCatalogue, injectLoader, injectLoop, injectObjectEvents, injectStore, invalidateInstance, is, loaderResource, makeCameraInstance, makeDpr, makeId, makeObjectGraph, makeRendererInstance, merge, objectEvents, omit, pick, prepare, provideHTMLDomElement, remove, removeInteractivity, resolveInstanceKey, resolveRef, roots, signalState, storeFactory, toDeepSignal, updateCamera, vector2, vector3, vector4 };
|
|
2267
|
+
export type { DeepSignal, NgtAfterAttach, NgtAllObject3DEventsMap, NgtAnyRecord, NgtArguments, NgtAttachFunction, NgtAttachable, NgtBeforeRenderEvent, NgtBeforeRenderRecord, NgtBranchingReturn, NgtCamera, NgtCameraLike, NgtCameraParameters, NgtCanvasConfigurator, NgtCanvasElement, NgtCanvasOptions, NgtColor, NgtComputeFunction, NgtConditionalType, NgtConstructorRepresentation, NgtDisposable, NgtDomEvent, NgtDpr, NgtElementProperties, NgtEquConfig, NgtEuler, NgtEventHandlers, NgtEventManager, NgtEventPrefix, NgtEvents, NgtFilterFunction, NgtFrameloop, NgtGLDefaultOptions, NgtGLOptions, NgtGLTFLike, NgtGlobalEffectType, NgtGlobalRenderCallback, NgtInjectedLoader, NgtInstanceHierarchyState, NgtInstanceNode, NgtInstanceState, NgtInternalState, NgtIntersection, NgtIntersectionEvent, NgtIsProperties, NgtLayers, NgtLoader, NgtLoaderExtensions, NgtLoaderProto, NgtLoaderResults, NgtLoaderReturnType, NgtMathProperties, NgtMathRepresentation, NgtMathType, NgtMathTypes, NgtMatrix3, NgtMatrix4, NgtMutable, NgtNodeElement, NgtNodeEventListener, NgtNodeEventMap, NgtNonFunctionKeys, NgtNonMutableProperties, NgtNonPartialProperties, NgtNullableRaycast, NgtNullish, NgtObject3DEventsMap, NgtObjectMap, NgtOverwrite, NgtPerformance, NgtPointerCaptureTarget, NgtPortalState, NgtProperties, NgtQuaternion, NgtRaycastableRepresentation, NgtRenderState, NgtRendererFactory2Options, NgtRendererLike, NgtShadows, NgtSize, NgtState, NgtThreeElement, NgtThreeElements, NgtThreeEvent, NgtVector2, NgtVector3, NgtVector4, NgtVectorRepresentation, NgtViewport, NgtXRManager, PartialStateUpdater, SignalState, StateSource, ThreeAddedEvent, ThreeChangeEvent, ThreeChildAddedEvent, ThreeChildRemovedEvent, ThreeDisposeEvent, ThreeRemovedEvent, WritableStateSource };
|