angular-three 4.0.0-next.118 → 4.0.0-next.119
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/dom/README.md +135 -2
- package/fesm2022/angular-three.mjs +4 -4
- package/fesm2022/angular-three.mjs.map +1 -1
- package/package.json +1 -1
- package/testing/README.md +151 -2
- package/types/angular-three.d.ts +6 -6
package/dom/README.md
CHANGED
|
@@ -1,3 +1,136 @@
|
|
|
1
|
-
# angular-three/dom
|
|
1
|
+
# `angular-three/dom`
|
|
2
2
|
|
|
3
|
-
Secondary entry point of `angular-three
|
|
3
|
+
Secondary entry point of `angular-three` providing DOM-specific components and utilities for rendering Three.js scenes in the browser.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This entry point is included with `angular-three`:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install angular-three
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
Add the renderer provider to your application config:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// app.config.ts
|
|
19
|
+
import { ApplicationConfig } from '@angular/core';
|
|
20
|
+
import { provideNgtRenderer } from 'angular-three/dom';
|
|
21
|
+
|
|
22
|
+
export const appConfig: ApplicationConfig = {
|
|
23
|
+
providers: [provideNgtRenderer()],
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Components
|
|
28
|
+
|
|
29
|
+
### `NgtCanvas`
|
|
30
|
+
|
|
31
|
+
The main canvas component for rendering Three.js scenes. It creates a WebGL canvas and sets up the Three.js rendering context including:
|
|
32
|
+
|
|
33
|
+
- Canvas sizing and resize handling
|
|
34
|
+
- WebGL renderer initialization
|
|
35
|
+
- Camera and scene setup
|
|
36
|
+
- Event handling
|
|
37
|
+
- Render loop management
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Component } from '@angular/core';
|
|
41
|
+
import { NgtCanvas } from 'angular-three/dom';
|
|
42
|
+
import { extend } from 'angular-three';
|
|
43
|
+
import * as THREE from 'three';
|
|
44
|
+
|
|
45
|
+
// Register Three.js elements
|
|
46
|
+
extend(THREE);
|
|
47
|
+
|
|
48
|
+
@Component({
|
|
49
|
+
selector: 'app-root',
|
|
50
|
+
imports: [NgtCanvas],
|
|
51
|
+
template: `
|
|
52
|
+
<ngt-canvas [shadows]="true" [dpr]="[1, 2]" (created)="onCreated($event)">
|
|
53
|
+
<ng-template canvasContent>
|
|
54
|
+
<ngt-mesh>
|
|
55
|
+
<ngt-box-geometry />
|
|
56
|
+
<ngt-mesh-standard-material />
|
|
57
|
+
</ngt-mesh>
|
|
58
|
+
<ngt-ambient-light [intensity]="0.5" />
|
|
59
|
+
<ngt-directional-light [position]="[5, 5, 5]" />
|
|
60
|
+
</ng-template>
|
|
61
|
+
</ngt-canvas>
|
|
62
|
+
`,
|
|
63
|
+
styles: `
|
|
64
|
+
:host {
|
|
65
|
+
display: block;
|
|
66
|
+
height: 100vh;
|
|
67
|
+
}
|
|
68
|
+
`,
|
|
69
|
+
})
|
|
70
|
+
export class AppComponent {
|
|
71
|
+
onCreated(state: NgtState) {
|
|
72
|
+
console.log('Canvas ready:', state);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### Inputs
|
|
78
|
+
|
|
79
|
+
| Input | Type | Default | Description |
|
|
80
|
+
| -------------- | ------------------------------------- | --------------------- | --------------------------------------------------- |
|
|
81
|
+
| `gl` | `NgtGLOptions` | - | WebGL renderer options |
|
|
82
|
+
| `size` | `NgtSize` | - | Override canvas size |
|
|
83
|
+
| `shadows` | `boolean \| NgtShadows` | `false` | Enable shadow maps |
|
|
84
|
+
| `legacy` | `boolean` | `false` | Enable legacy color mode |
|
|
85
|
+
| `linear` | `boolean` | `false` | Disable automatic sRGB encoding |
|
|
86
|
+
| `flat` | `boolean` | `false` | Disable tone mapping |
|
|
87
|
+
| `orthographic` | `boolean` | `false` | Use orthographic camera |
|
|
88
|
+
| `frameloop` | `NgtFrameloop` | `'always'` | Render loop mode: `'always'`, `'demand'`, `'never'` |
|
|
89
|
+
| `performance` | `Partial<NgtPerformance>` | - | Performance settings |
|
|
90
|
+
| `dpr` | `NgtDpr` | `[1, 2]` | Device pixel ratio range |
|
|
91
|
+
| `raycaster` | `Partial<THREE.Raycaster>` | - | Raycaster configuration |
|
|
92
|
+
| `scene` | `THREE.Scene \| Partial<THREE.Scene>` | - | Scene configuration |
|
|
93
|
+
| `camera` | `NgtCamera \| NgtCameraParameters` | - | Camera configuration |
|
|
94
|
+
| `events` | `Function` | `createPointerEvents` | Event system factory |
|
|
95
|
+
| `eventSource` | `HTMLElement \| ElementRef` | - | Custom event source element |
|
|
96
|
+
| `eventPrefix` | `NgtEventPrefix` | `'offset'` | Event coordinate prefix |
|
|
97
|
+
| `lookAt` | `NgtVector3` | - | Camera look-at target |
|
|
98
|
+
|
|
99
|
+
#### Outputs
|
|
100
|
+
|
|
101
|
+
| Output | Type | Description |
|
|
102
|
+
| --------------- | ---------- | --------------------------------------- |
|
|
103
|
+
| `created` | `NgtState` | Emitted when canvas is initialized |
|
|
104
|
+
| `pointerMissed` | `Event` | Emitted when pointer misses all objects |
|
|
105
|
+
|
|
106
|
+
## Functions
|
|
107
|
+
|
|
108
|
+
### `provideNgtRenderer()`
|
|
109
|
+
|
|
110
|
+
Provider function that sets up Angular Three's custom renderer for Three.js elements.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { provideNgtRenderer } from 'angular-three/dom';
|
|
114
|
+
|
|
115
|
+
export const appConfig: ApplicationConfig = {
|
|
116
|
+
providers: [
|
|
117
|
+
provideNgtRenderer(),
|
|
118
|
+
// With options:
|
|
119
|
+
provideNgtRenderer({ verbose: true }),
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `createPointerEvents()`
|
|
125
|
+
|
|
126
|
+
Creates the default pointer event manager for an Angular Three canvas. This function sets up event listeners and translates DOM pointer events to Three.js raycasting events.
|
|
127
|
+
|
|
128
|
+
Supported events:
|
|
129
|
+
|
|
130
|
+
- `click`, `dblclick`, `contextmenu`
|
|
131
|
+
- `pointerup`, `pointerdown`, `pointermove`
|
|
132
|
+
- `pointerover`, `pointerout`, `pointerenter`, `pointerleave`
|
|
133
|
+
- `pointercancel`, `pointermissed`
|
|
134
|
+
- `wheel`
|
|
135
|
+
|
|
136
|
+
This is the default event system used by `NgtCanvas`. You can provide a custom event factory via the `events` input if needed.
|
|
@@ -2859,7 +2859,7 @@ function resolveRef(ref) {
|
|
|
2859
2859
|
* - A string (name of an object in the scene)
|
|
2860
2860
|
* - A THREE.Object3D reference
|
|
2861
2861
|
* - An ElementRef containing a THREE.Object3D
|
|
2862
|
-
* - A
|
|
2862
|
+
* - A Signal of any of the above
|
|
2863
2863
|
*
|
|
2864
2864
|
* @example
|
|
2865
2865
|
* ```html
|
|
@@ -3246,7 +3246,7 @@ function getLoaderPromises(params, onProgress) {
|
|
|
3246
3246
|
* @typeParam TReturn - The return type after loading
|
|
3247
3247
|
*
|
|
3248
3248
|
* @param loaderConstructorFactory - Factory function that returns the loader constructor
|
|
3249
|
-
* @param input - Signal
|
|
3249
|
+
* @param input - Signal containing the URL(s) to load
|
|
3250
3250
|
* @param options - Optional configuration including extensions, callbacks, and injector
|
|
3251
3251
|
* @returns A ResourceRef containing the loaded data
|
|
3252
3252
|
*
|
|
@@ -4276,7 +4276,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImpor
|
|
|
4276
4276
|
* Sets up element lifecycle event listeners on a Three.js element.
|
|
4277
4277
|
*
|
|
4278
4278
|
* @typeParam TElement - The type of the element
|
|
4279
|
-
* @param target - Signal
|
|
4279
|
+
* @param target - Signal containing the target element
|
|
4280
4280
|
* @param events - Object mapping event names to handler functions
|
|
4281
4281
|
* @param options - Optional injector for dependency injection
|
|
4282
4282
|
* @returns Array of cleanup functions
|
|
@@ -4403,7 +4403,7 @@ const injectObjectEvents = objectEvents;
|
|
|
4403
4403
|
* This function creates reactive event bindings that automatically clean up
|
|
4404
4404
|
* when the target changes or the component is destroyed.
|
|
4405
4405
|
*
|
|
4406
|
-
* @param target - Signal
|
|
4406
|
+
* @param target - Signal containing the target Object3D
|
|
4407
4407
|
* @param events - Object mapping event names to handler functions
|
|
4408
4408
|
* @param options - Optional injector for dependency injection
|
|
4409
4409
|
* @returns Array of cleanup functions
|