Skip to content

Commit 0a38f33

Browse files
committed
fix(core): remove standalone true
1 parent b5e56e7 commit 0a38f33

File tree

7 files changed

+51
-53
lines changed

7 files changed

+51
-53
lines changed

libs/core/README.md

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,38 @@ import { extend } from 'angular-three';
2323
import { Mesh, BoxGeometry } from 'three';
2424

2525
extend({
26-
Mesh, // makes ngt-mesh available
27-
BoxGeometry, // makes ngt-box-geometry available
28-
/* ... */
29-
MyMesh: Mesh, // makes ngt-my-mesh available
26+
Mesh, // makes ngt-mesh available
27+
BoxGeometry, // makes ngt-box-geometry available
28+
/* ... */
29+
MyMesh: Mesh, // makes ngt-my-mesh available
3030
});
3131

3232
// alternatively for demo purposes, you can use the following
3333
// extend(THREE);
3434
// This includes the entire THREE.js namespace
3535

3636
@Component({
37-
// This Component is rendered in the Custom Renderer
38-
standalone: true,
39-
template: `
40-
<ngt-mesh>
41-
<ngt-box-geometry />
42-
</ngt-mesh>
43-
`,
44-
schemas: [CUSTOM_ELEMENTS_SCHEMA], // required
45-
changeDetection: ChangeDetectionStrategy.OnPush,
37+
// This Component is rendered in the Custom Renderer
38+
template: `
39+
<ngt-mesh>
40+
<ngt-box-geometry />
41+
</ngt-mesh>
42+
`,
43+
schemas: [CUSTOM_ELEMENTS_SCHEMA], // required
44+
changeDetection: ChangeDetectionStrategy.OnPush,
4645
})
4746
export class SceneGraph {}
4847

4948
@Component({
50-
// This Component is rendered normally in Angular.
51-
selector: 'app-my-experience',
52-
standalone: true,
53-
template: `
54-
<ngt-canvas [sceneGraph]="SceneGraph" />
55-
`,
56-
imports: [NgtCanvas],
49+
// This Component is rendered normally in Angular.
50+
selector: 'app-my-experience',
51+
template: `
52+
<ngt-canvas [sceneGraph]="SceneGraph" />
53+
`,
54+
imports: [NgtCanvas],
5755
})
5856
export class MyExperience {
59-
SceneGraph = SceneGraph;
57+
SceneGraph = SceneGraph;
6058
}
6159
```
6260

@@ -98,7 +96,7 @@ The consumers can add `web-types` property to the workspace's `package.json` and
9896

9997
```json
10098
{
101-
"web-types": "node_modules/angular-three/web-types.json"
99+
"web-types": "node_modules/angular-three/web-types.json"
102100
}
103101
```
104102

@@ -110,7 +108,7 @@ The consumers can enable it via `html.customData` in their `settings.json` file.
110108

111109
```json
112110
{
113-
"html.customData": ["node_modules/angular-three/metadata.json"]
111+
"html.customData": ["node_modules/angular-three/metadata.json"]
114112
}
115113
```
116114

@@ -122,7 +120,7 @@ Input bindings for `ngt-*` elements work the same way as they do in Angular.
122120
123121
```html
124122
<ngt-mesh [position]="[x, y, z]" [rotation]="[x, y, z]">
125-
<ngt-mesh-basic-material color="hotpink" />
123+
<ngt-mesh-basic-material color="hotpink" />
126124
</ngt-mesh>
127125
```
128126

@@ -179,13 +177,13 @@ The consumers can query for the THREE.js entities like they would do in normal H
179177

180178
```ts
181179
@Component({
182-
template: `
183-
<ngt-mesh #mesh></ngt-mesh>
184-
`,
180+
template: `
181+
<ngt-mesh #mesh></ngt-mesh>
182+
`,
185183
})
186184
export class Box {
187-
mesh = viewChild.required<ElementRef<Mesh>>('mesh');
188-
// notice that it is an ElementRef of THREE.Mesh instead of an HTMLElement
185+
mesh = viewChild.required<ElementRef<Mesh>>('mesh');
186+
// notice that it is an ElementRef of THREE.Mesh instead of an HTMLElement
189187
}
190188
```
191189

@@ -195,18 +193,18 @@ In order to participate in the animation loop, use `injectBeforeRender` inject f
195193

196194
```ts
197195
@Component({
198-
/*...*/
196+
/*...*/
199197
})
200198
export class Box {
201-
mesh = viewChild.required<ElementRef<Mesh>>('mesh');
202-
203-
constructor() {
204-
injectBeforeRender(() => {
205-
// runs every frame
206-
const mesh = this.mesh().nativeElement;
207-
mesh.rotation.x += 0.01;
208-
});
209-
}
199+
mesh = viewChild.required<ElementRef<Mesh>>('mesh');
200+
201+
constructor() {
202+
injectBeforeRender(() => {
203+
// runs every frame
204+
const mesh = this.mesh().nativeElement;
205+
mesh.rotation.x += 0.01;
206+
});
207+
}
210208
}
211209
```
212210

@@ -216,9 +214,9 @@ Angular Three keeps track of its state via an internal store. The consumers can
216214

217215
```ts
218216
export class Box {
219-
store = injectStore();
220-
viewport = this.store.select('viewport'); // Signal<NgtViewport>
221-
camera = this.store.select('camera'); // Signal<NgtCamera> - the default camera
222-
/* many more properties */
217+
store = injectStore();
218+
viewport = this.store.select('viewport'); // Signal<NgtViewport>
219+
camera = this.store.select('camera'); // Signal<NgtCamera> - the default camera
220+
/* many more properties */
223221
}
224222
```

libs/core/src/lib/directives/args.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@angular/core';
1212
import { SPECIAL_INTERNAL_ADD_COMMENT } from '../renderer/constants';
1313

14-
@Directive({ selector: 'ng-template[args]', standalone: true })
14+
@Directive({ selector: 'ng-template[args]' })
1515
export class NgtArgs {
1616
args = input.required<any[] | null>();
1717

libs/core/src/lib/directives/selection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { booleanAttribute, Directive, effect, ElementRef, inject, input, signal,
22
import { Group, Mesh, Object3D } from 'three';
33
import { getLocalState } from '../instance';
44

5-
@Directive({ standalone: true, selector: '[ngtSelection]' })
5+
@Directive({ selector: '[ngtSelection]' })
66
export class NgtSelection {
77
enabled = input(true, { alias: 'ngtSelection', transform: booleanAttribute });
88

@@ -15,7 +15,7 @@ export class NgtSelection {
1515
}
1616
}
1717

18-
@Directive({ standalone: true, selector: 'ngt-group[ngtSelect], ngt-mesh[ngtSelect]' })
18+
@Directive({ selector: 'ngt-group[ngtSelect], ngt-mesh[ngtSelect]' })
1919
export class NgtSelect {
2020
enabled = input(false, { transform: booleanAttribute, alias: 'ngtSelect' });
2121

libs/core/src/lib/pipes/hexify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { inject, Pipe } from '@angular/core';
44
const RGBA_REGEX = /rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*(\d*\.?\d+)?\)/;
55
const DEFAULT_COLOR = 0x000000;
66

7-
@Pipe({ name: 'hexify', pure: true, standalone: true })
7+
@Pipe({ name: 'hexify', pure: true })
88
export class NgtHexify {
99
private document = inject(DOCUMENT, { optional: true });
1010
private ctx?: CanvasRenderingContext2D | null;

libs/core/src/lib/portal.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { updateCamera } from './utils/update';
2929

3030
@Component({
3131
selector: 'ngt-portal-before-render',
32-
standalone: true,
3332
template: `
3433
<!-- Without an element that receives pointer events state.pointer will always be 0/0 -->
3534
<ngt-group (pointerover)="onPointerOver()" attach="none" />
@@ -80,7 +79,7 @@ export class NgtPortalBeforeRender {
8079
}
8180
}
8281

83-
@Directive({ selector: 'ng-template[portalContent]', standalone: true })
82+
@Directive({ selector: 'ng-template[portalContent]' })
8483
export class NgtPortalContent {
8584
constructor() {
8685
const { element: comment } = inject(ViewContainerRef);
@@ -140,7 +139,7 @@ export type NgtPortalInjectableState = Partial<
140139
imports: [NgtPortalBeforeRender],
141140
schemas: [CUSTOM_ELEMENTS_SCHEMA],
142141
changeDetection: ChangeDetectionStrategy.OnPush,
143-
providers: [provideStore(() => signalStore({}))],
142+
providers: [provideStore(() => signalStore<NgtState>({}))],
144143
})
145144
export class NgtPortal {
146145
container = input.required<Object3D>();

libs/core/src/lib/utils/object-events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Object3D } from 'three';
44
import { NgtEventHandlers, NgtThreeEvent } from '../types';
55
import { resolveRef } from './resolve-ref';
66

7-
@Directive({ standalone: true, selector: '[ngtObjectEvents]' })
7+
@Directive({ selector: '[ngtObjectEvents]' })
88
/**
99
* As host directive:
1010
* - outputs: [

libs/plugin/src/generators/init/generator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ export async function initGenerator(
125125
return warnExperienceWasNotGenerated(tree, `AppComponent was not found`);
126126
}
127127

128-
// TODO (chau): revisit if standalone:true becomes the default
129-
const isStandalone = appComponentContent.includes(`standalone: true`);
128+
// standalone is true or not exist
129+
const isStandalone =
130+
appComponentContent.includes(`standalone: true`) || !appComponentContent.includes('standalone');
130131
if (!isStandalone) {
131132
return warnExperienceWasNotGenerated(tree, `AppComponent is not a Standalone Component`);
132133
}

0 commit comments

Comments
 (0)