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

Commit

Permalink
feat(soba): make soba buildable for now
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Apr 17, 2022
1 parent 8ff5a30 commit b42f235
Show file tree
Hide file tree
Showing 25 changed files with 4,757 additions and 4,383 deletions.
2 changes: 1 addition & 1 deletion libs/core/src/lib/abstracts/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export abstract class NgtInstance<

protected readonly instanceArgs$ = this.select((s) => s.instanceArgs);

protected set instanceArgs(v: unknown | unknown[]) {
set instanceArgs(v: unknown | unknown[]) {
this.set({
instanceArgs: Array.isArray(v) ? v : [v],
} as Partial<TInstanceState>);
Expand Down
10 changes: 5 additions & 5 deletions libs/soba/abstractions/src/lib/image/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ export interface NgtSobaImageState extends NgtObjectInputsState<THREE.Mesh> {
<ngt-soba-image-shader-material
#ngtMaterial
[color]="color"
[color]="color!"
[map]="imageViewModel.texture"
[zoom]="imageViewModel.zoom"
[grayscale]="imageViewModel.grayscale"
[zoom]="imageViewModel.zoom!"
[grayscale]="imageViewModel.grayscale!"
[scale]="imageViewModel.planeBounds"
[imageBounds]="imageViewModel.imageBounds"
[toneMapped]="imageViewModel.toneMapped"
[toneMapped]="imageViewModel.toneMapped!"
></ngt-soba-image-shader-material>
<ngt-mesh
Expand All @@ -98,7 +98,7 @@ export interface NgtSobaImageState extends NgtObjectInputsState<THREE.Mesh> {
[rotation]="rotation"
[quaternion]="quaternion"
[scale]="scale"
[color]="color"
[color]="color!"
[userData]="userData"
[castShadow]="castShadow"
[receiveShadow]="receiveShadow"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class NgtSobaOrthographicCameraContent {
selector: 'ngt-soba-orthographic-camera',
template: `
<ngt-orthographic-camera
[args]="instanceArgs"
[args]="$any(instanceArgs)"
[left]="size.width / -2"
[right]="size.width / 2"
[top]="size.height / 2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,83 +1,13 @@
import {
NgtAnimationFrameStore,
NgtCanvasState,
NgtCanvasStore,
NgtStore,
tapEffect,
} from '@angular-three/core';
import { Directive, NgModule, NgZone, OnInit, Output } from '@angular/core';
import { tap } from 'rxjs';
import { FirstPersonControls } from 'three-stdlib';
import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';

interface NgtSobaFirstPersonControlsState {
controls: FirstPersonControls;
}

@Directive({
@Component({
selector: 'ngt-soba-first-person-controls',
exportAs: 'ngtSobaFirstPersonControls',
template: ``,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NgtSobaFirstPersonControls
extends NgtStore<NgtSobaFirstPersonControlsState>
implements OnInit
{
@Output() ready = this.select((s) => s.controls);

constructor(
private zone: NgZone,
private canvasStore: NgtCanvasStore,
private animationFrameStore: NgtAnimationFrameStore
) {
super();
}

ngOnInit() {
this.zone.runOutsideAngular(() => {
this.onCanvasReady(this.canvasStore.ready$, () => {
this.init(
this.select(
this.canvasStore.camera$,
this.canvasStore.renderer$,
(camera, renderer) => ({ camera, renderer })
)
);

this.registerAnimation(this.select((s) => s.controls));
});
});
}

private readonly init = this.effect<
Pick<NgtCanvasState, 'camera' | 'renderer'>
>(
tap(({ camera, renderer }) => {
if (camera && renderer) {
this.set({
controls: new FirstPersonControls(
camera,
renderer.domElement
),
});
}
})
);

private readonly registerAnimation = this.effect<FirstPersonControls>(
tapEffect((controls) => {
const animationUuid = this.animationFrameStore.register({
callback: ({ delta }) => {
controls.update(delta);
},
});

return () => {
this.animationFrameStore.unregister(animationUuid);
};
})
);

get controls() {
return this.get((s) => s.controls) as FirstPersonControls;
export class NgtSobaFirstPersonControls {
constructor() {
console.warn(`<ngt-soba-first-person-controls> is being reworked`);
}
}

Expand All @@ -86,3 +16,92 @@ export class NgtSobaFirstPersonControls
exports: [NgtSobaFirstPersonControls],
})
export class NgtSobaFirstPersonControlsModule {}

// import {
// NgtAnimationFrameStore,
// NgtCanvasState,
// NgtCanvasStore,
// NgtStore,
// tapEffect,
// } from '@angular-three/core';
// import { Directive, NgModule, NgZone, OnInit, Output } from '@angular/core';
// import { tap } from 'rxjs';
// import { FirstPersonControls } from 'three-stdlib';
//
// interface NgtSobaFirstPersonControlsState {
// controls: FirstPersonControls;
// }
//
// @Directive({
// selector: 'ngt-soba-first-person-controls',
// exportAs: 'ngtSobaFirstPersonControls',
// })
// export class NgtSobaFirstPersonControls
// extends NgtStore<NgtSobaFirstPersonControlsState>
// implements OnInit
// {
// @Output() ready = this.select((s) => s.controls);
//
// constructor(
// private zone: NgZone,
// private canvasStore: NgtCanvasStore,
// private animationFrameStore: NgtAnimationFrameStore
// ) {
// super();
// }
//
// ngOnInit() {
// this.zone.runOutsideAngular(() => {
// this.onCanvasReady(this.canvasStore.ready$, () => {
// this.init(
// this.select(
// this.canvasStore.camera$,
// this.canvasStore.renderer$,
// (camera, renderer) => ({ camera, renderer })
// )
// );
//
// this.registerAnimation(this.select((s) => s.controls));
// });
// });
// }
//
// private readonly init = this.effect<
// Pick<NgtCanvasState, 'camera' | 'renderer'>
// >(
// tap(({ camera, renderer }) => {
// if (camera && renderer) {
// this.set({
// controls: new FirstPersonControls(
// camera,
// renderer.domElement
// ),
// });
// }
// })
// );
//
// private readonly registerAnimation = this.effect<FirstPersonControls>(
// tapEffect((controls) => {
// const animationUuid = this.animationFrameStore.register({
// callback: ({ delta }) => {
// controls.update(delta);
// },
// });
//
// return () => {
// this.animationFrameStore.unregister(animationUuid);
// };
// })
// );
//
// get controls() {
// return this.get((s) => s.controls) as FirstPersonControls;
// }
// }
//
// @NgModule({
// declarations: [NgtSobaFirstPersonControls],
// exports: [NgtSobaFirstPersonControls],
// })
// export class NgtSobaFirstPersonControlsModule {}
Loading

0 comments on commit b42f235

Please sign in to comment.