Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
feat(core): ready to start core generators
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Nov 29, 2021
1 parent eaef129 commit 7adf33d
Show file tree
Hide file tree
Showing 97 changed files with 3,033 additions and 182 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// GENERATED
import { NgtGeometry } from '@angular-three/core';
import { NgModule, Directive, Input } from '@angular/core';
import { Directive, Input, NgModule } from '@angular/core';
import * as THREE from 'three';

@Directive({
Expand All @@ -10,12 +10,13 @@ import * as THREE from 'three';
{
provide: NgtGeometry,
useExisting: NgtBoxGeometry,
}
},
],
})
export class NgtBoxGeometry extends NgtGeometry<THREE.BoxGeometry> {

static ngAcceptInputType_args: ConstructorParameters<typeof THREE.BoxGeometry> | undefined;
static ngAcceptInputType_args:
| ConstructorParameters<typeof THREE.BoxGeometry>
| undefined;

@Input() set args(v: ConstructorParameters<typeof THREE.BoxGeometry>) {
this.extraArgs = v;
Expand All @@ -29,4 +30,3 @@ export class NgtBoxGeometry extends NgtGeometry<THREE.BoxGeometry> {
exports: [NgtBoxGeometry],
})
export class NgtBoxGeometryModule {}

9 changes: 7 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@
},
"generators": {
"@nrwl/angular:application": {
"style": "scss",
"linter": "eslint",
"unitTestRunner": "jest"
"unitTestRunner": "jest",
"e2eTestRunner": "none"
},
"@nrwl/angular:library": {
"style": "scss",
"linter": "eslint",
"unitTestRunner": "jest"
},
"@nrwl/angular:component": {}
"@nrwl/angular:component": {
"style": "scss"
}
},
"defaultProject": "core"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"@types/jest": "27.0.3",
"@types/node": "16.11.10",
"@types/three": "0.134.0",
"@typescript-eslint/eslint-plugin": "~5.4.0",
"@typescript-eslint/parser": "~5.4.0",
"@typescript-eslint/eslint-plugin": "~5.5.0",
"@typescript-eslint/parser": "~5.5.0",
"eslint": "8.3.0",
"eslint-config-prettier": "8.3.0",
"jest": "27.3.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/core/audios/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @angular-three/core/audios

Secondary entry point of `@angular-three/core`. It can be used by importing from `@angular-three/core/audios`.
5 changes: 5 additions & 0 deletions packages/core/audios/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "src/index.ts"
}
}
1 change: 1 addition & 0 deletions packages/core/audios/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const greeting = 'Hello World!';
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import {
applyProps,
EnhancedComponentStore,
NgtDestroyedService,
NgtStore,
tapEffect,
} from '@angular-three/core';
import {
Directive,
EventEmitter,
Input,
NgModule,
NgZone,
OnInit,
Output,
} from '@angular/core';
import { withLatestFrom } from 'rxjs';
import * as THREE from 'three';

@Directive({
selector: 'ngt-audio-listener',
exportAs: 'ngtAudioListener',
})
export class NgtAudioListener extends EnhancedComponentStore implements OnInit {
@Input() filter?: AudioNode;
@Input() timeDelta?: number;

@Output() ready = new EventEmitter();

#listener!: THREE.AudioListener;
get listener() {
return this.#listener;
}

constructor(
private store: NgtStore,
private destroyed: NgtDestroyedService,
private ngZone: NgZone
) {
super({});
}

ngOnInit() {
this.ngZone.runOutsideAngular(() => {
this.#listener = new THREE.AudioListener();
const props = {
filter: this.filter,
timeDelta: this.timeDelta,
};
applyProps(this.listener, props);
this.#ready(this.store.selectors.ready$);
});
}

#ready = this.effect<boolean>((ready$) =>
ready$.pipe(
withLatestFrom(this.store.selectors.camera$),
tapEffect(([ready, camera]) => {
this.ngZone.runOutsideAngular(() => {
if (ready && camera) {
camera.add(this.listener);
this.ready.emit();
}
});

return () => {
this.ngZone.runOutsideAngular(() => {
if (ready && camera) {
this.listener.clear();
camera.remove(this.listener);
}
});
};
})
)
);
}

@NgModule({
declarations: [NgtAudioListener],
exports: [NgtAudioListener],
})
export class NgtAudioListenerModule {}
3 changes: 3 additions & 0 deletions packages/core/cameras/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @angular-three/core/cameras

Secondary entry point of `@angular-three/core`. It can be used by importing from `@angular-three/core/cameras`.
5 changes: 5 additions & 0 deletions packages/core/cameras/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "src/index.ts"
}
}
51 changes: 51 additions & 0 deletions packages/core/cameras/src/cube-camera/cube-camera.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {
NGT_OBJECT_CONTROLLER_PROVIDER,
NGT_OBJECT_WATCHED_CONTROLLER,
NgtObject3dController,
} from '@angular-three/core';
import {
Directive,
Inject,
Input,
NgModule,
NgZone,
OnInit,
} from '@angular/core';
import * as THREE from 'three';

@Directive({
selector: 'ngt-cube-camera',
exportAs: 'ngtCubeCamera',
providers: [NGT_OBJECT_CONTROLLER_PROVIDER],
})
export class NgtCubeCamera implements OnInit {
static ngAcceptInputType_args: ConstructorParameters<typeof THREE.CubeCamera>;

#cubeCamera?: THREE.CubeCamera;
get cubeCamera() {
return this.#cubeCamera;
}

@Input() args!: ConstructorParameters<typeof THREE.CubeCamera>;

constructor(
@Inject(NGT_OBJECT_WATCHED_CONTROLLER)
private objectController: NgtObject3dController,
private ngZone: NgZone
) {}

ngOnInit() {
this.objectController.initFn = () => {
return this.ngZone.runOutsideAngular(() => {
this.#cubeCamera = new THREE.CubeCamera(...this.args);
return this.#cubeCamera;
});
};
}
}

@NgModule({
declarations: [NgtCubeCamera],
exports: [NgtCubeCamera],
})
export class NgtCubeCameraModule {}
1 change: 1 addition & 0 deletions packages/core/cameras/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const greeting = 'Hello World!';
3 changes: 3 additions & 0 deletions packages/core/geometries/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @angular-three/core/geometries

Secondary entry point of `@angular-three/core`. It can be used by importing from `@angular-three/core/geometries`.
5 changes: 5 additions & 0 deletions packages/core/geometries/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "src/index.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// GENERATED
import { NgtGeometry } from '@angular-three/core';
import { Directive, Input, NgModule } from '@angular/core';
import * as THREE from 'three';

@Directive({
selector: 'ngt-box-geometry',
exportAs: 'ngtBoxGeometry',
providers: [
{
provide: NgtGeometry,
useExisting: NgtBoxGeometry,
},
],
})
export class NgtBoxGeometry extends NgtGeometry<THREE.BoxGeometry> {
static ngAcceptInputType_args:
| ConstructorParameters<typeof THREE.BoxGeometry>
| undefined;

@Input() set args(v: ConstructorParameters<typeof THREE.BoxGeometry>) {
this.geometryArgs = v;
}

geometryType = THREE.BoxGeometry;
}

@NgModule({
declarations: [NgtBoxGeometry],
exports: [NgtBoxGeometry],
})
export class NgtBoxGeometryModule {}
1 change: 1 addition & 0 deletions packages/core/geometries/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './box-geometry/box-geometry.directive';
3 changes: 3 additions & 0 deletions packages/core/group/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @angular-three/core/group

Secondary entry point of `@angular-three/core`. It can be used by importing from `@angular-three/core/group`.
5 changes: 5 additions & 0 deletions packages/core/group/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "src/index.ts"
}
}
1 change: 1 addition & 0 deletions packages/core/group/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/group.directive';
40 changes: 40 additions & 0 deletions packages/core/group/src/lib/group.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
NGT_OBJECT_CONTROLLER_PROVIDER,
NGT_OBJECT_WATCHED_CONTROLLER,
NgtObject3dController,
} from '@angular-three/core';
import { Directive, Inject, NgModule, NgZone, OnInit } from '@angular/core';
import * as THREE from 'three';

@Directive({
selector: 'ngt-group',
exportAs: 'ngtGroup',
providers: [NGT_OBJECT_CONTROLLER_PROVIDER],
})
export class NgtGroup implements OnInit {
#group?: THREE.Group;
get group() {
return this.#group;
}

constructor(
@Inject(NGT_OBJECT_WATCHED_CONTROLLER)
private objectController: NgtObject3dController,
private ngZone: NgZone
) {}

ngOnInit() {
this.objectController.initFn = () => {
return this.ngZone.runOutsideAngular(() => {
this.#group = new THREE.Group();
return this.#group;
});
};
}
}

@NgModule({
declarations: [NgtGroup],
exports: [NgtGroup],
})
export class NgtGroupModule {}
3 changes: 3 additions & 0 deletions packages/core/materials/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @angular-three/core/materials

Secondary entry point of `@angular-three/core`. It can be used by importing from `@angular-three/core/materials`.
5 changes: 5 additions & 0 deletions packages/core/materials/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "src/index.ts"
}
}
1 change: 1 addition & 0 deletions packages/core/materials/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './mesh-basic-material/mesh-basic-material.directive';
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// GENERATED
import { NgtMaterial } from '@angular-three/core';
import { Directive, NgModule } from '@angular/core';
import * as THREE from 'three';

@Directive({
selector: 'ngt-mesh-basic-material',
exportAs: 'ngtMeshBasicMaterial',
providers: [
{
provide: NgtMaterial,
useExisting: NgtMeshBasicMaterial,
},
],
})
export class NgtMeshBasicMaterial extends NgtMaterial<
THREE.MeshBasicMaterialParameters,
THREE.MeshBasicMaterial
> {
static ngAcceptInputType_parameters:
| THREE.MeshBasicMaterialParameters
| undefined;

materialType = THREE.MeshBasicMaterial;
}

@NgModule({
declarations: [NgtMeshBasicMaterial],
exports: [NgtMeshBasicMaterial],
})
export class NgtMeshBasicMaterialModule {}
3 changes: 3 additions & 0 deletions packages/core/meshes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @angular-three/core/meshes

Secondary entry point of `@angular-three/core`. It can be used by importing from `@angular-three/core/meshes`.
5 changes: 5 additions & 0 deletions packages/core/meshes/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "src/index.ts"
}
}
3 changes: 3 additions & 0 deletions packages/core/meshes/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './mesh/mesh.directive';
export * from './instanced-mesh/instanced-mesh.directive';
export * from './skinned-mesh/skinned-mesh.directive';
Loading

0 comments on commit 7adf33d

Please sign in to comment.