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

Commit

Permalink
feat(soba): standalone api
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Jul 21, 2022
1 parent 6c26dcd commit 5707f85
Show file tree
Hide file tree
Showing 42 changed files with 406 additions and 430 deletions.
10 changes: 1 addition & 9 deletions apps/sandbox/src/app/kinematic-cube/kinematic-cube.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { NgtPhysicBody, NgtPhysicsModule } from '@angular-three/cannon';
import {
NgtCanvasModule,
NgtEuler,
NgtRenderState,
NgtTriple,
NgtVector3,
NgtVectorPipeModule,
} from '@angular-three/core';
import { NgtCanvasModule, NgtEuler, NgtRenderState, NgtTriple, NgtVector3 } from '@angular-three/core';
import { NgtInstancedBufferAttributeModule, NgtVector2AttributeModule } from '@angular-three/core/attributes';
import { NgtBoxGeometryModule, NgtPlaneGeometryModule, NgtSphereGeometryModule } from '@angular-three/core/geometries';
import { NgtHemisphereLightModule, NgtPointLightModule, NgtSpotLightModule } from '@angular-three/core/lights';
Expand Down Expand Up @@ -167,7 +160,6 @@ export class InstancedSpheres implements OnInit {
NgtStatsModule,
NgtHemisphereLightModule,
NgtSpotLightModule,
NgtVectorPipeModule,
NgtPointLightModule,
NgtPlaneGeometryModule,
NgtMeshPhongMaterialModule,
Expand Down
10 changes: 6 additions & 4 deletions libs/soba/abstractions/src/lib/billboard/billboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import {
BooleanInput,
coerceBooleanProperty,
NgtObjectInputs,
NgtObjectPassThroughModule,
NgtObjectPassThrough,
NgtRenderState,
provideObjectHostRef,
Ref,
} from '@angular-three/core';
import { NgtGroupModule } from '@angular-three/core/group';
import { CommonModule } from '@angular/common';
import { NgIf, NgTemplateOutlet } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Expand All @@ -24,6 +24,7 @@ import * as THREE from 'three/src/Three';

@Directive({
selector: 'ng-template[ngt-soba-billboard-content]',
standalone: true,
})
export class NgtSobaBillboardContent {
constructor(public templateRef: TemplateRef<{ billboard: Ref<THREE.Group> }>) {}
Expand All @@ -35,6 +36,7 @@ export class NgtSobaBillboardContent {

@Component({
selector: 'ngt-soba-billboard',
standalone: true,
template: `
<ngt-group
(beforeRender)="onBeforeRender($event); beforeRender.emit($event)"
Expand All @@ -48,6 +50,7 @@ export class NgtSobaBillboardContent {
></ng-container>
</ngt-group>
`,
imports: [NgtGroupModule, NgtObjectPassThrough, NgIf, NgTemplateOutlet],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [provideObjectHostRef(NgtSobaBillboard)],
})
Expand Down Expand Up @@ -105,8 +108,7 @@ export class NgtSobaBillboard extends NgtObjectInputs<THREE.Group> {
}

@NgModule({
declarations: [NgtSobaBillboard, NgtSobaBillboardContent],
imports: [NgtSobaBillboard, NgtSobaBillboardContent],
exports: [NgtSobaBillboard, NgtSobaBillboardContent],
imports: [NgtGroupModule, CommonModule, NgtObjectPassThroughModule],
})
export class NgtSobaBillboardModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import {
coerceNumberProperty,
is,
makeVector3,
NgtObjectPassThroughModule,
NgtObjectPassThrough,
NgtTriple,
NumberInput,
provideObjectHostRef,
} from '@angular-three/core';
import { CommonModule } from '@angular/common';
import { AsyncPipe, NgIf, NgTemplateOutlet } from '@angular/common';
import { ChangeDetectionStrategy, Component, Input, NgModule } from '@angular/core';
import * as THREE from 'three/src/Three';
import { NgtSobaLine, NgtSobaLineModule } from '../line/line';
import { NgtSobaLine, NgtSobaLineContent } from '../line/line';

@Component({
selector: 'ngt-soba-cubic-bezier-line[start][end][midA][midB]',
standalone: true,
template: `
<ngt-soba-line
*ngIf="cubicLineViewModel$ | async as cubicLineViewModel"
Expand All @@ -34,6 +35,7 @@ import { NgtSobaLine, NgtSobaLineModule } from '../line/line';
</ng-container>
</ngt-soba-line>
`,
imports: [NgtSobaLine, NgtObjectPassThrough, NgtSobaLineContent, NgTemplateOutlet, NgIf, AsyncPipe],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [provideObjectHostRef(NgtSobaCubicBezierLine)],
})
Expand Down Expand Up @@ -104,8 +106,7 @@ export class NgtSobaCubicBezierLine extends NgtSobaLine {
}

@NgModule({
declarations: [NgtSobaCubicBezierLine],
imports: [NgtSobaCubicBezierLine],
exports: [NgtSobaCubicBezierLine],
imports: [NgtSobaLineModule, NgtObjectPassThroughModule, CommonModule],
})
export class NgtSobaCubicBezierLineModule {}
26 changes: 19 additions & 7 deletions libs/soba/abstractions/src/lib/gizmo-helper/gizmo-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import {
makeVector3,
NgtObjectInputs,
NgtObjectInputsState,
NgtObjectPassThroughModule,
NgtPortalModule,
NgtObjectPassThrough,
NgtPortal,
NgtPortalContent,
NgtRenderState,
prepare,
provideObjectHostRef,
Ref,
tapEffect,
} from '@angular-three/core';
import { NgtGroupModule } from '@angular-three/core/group';
import { NgtSobaOrthographicCameraModule } from '@angular-three/soba/cameras';
import { CommonModule } from '@angular/common';
import { NgtGroup } from '@angular-three/core/group';
import { NgtSobaOrthographicCamera } from '@angular-three/soba/cameras';
import { AsyncPipe, NgIf, NgTemplateOutlet } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Expand Down Expand Up @@ -43,6 +44,7 @@ export interface NgtSobaGizmoHelperState extends NgtObjectInputsState<THREE.Grou

@Directive({
selector: 'ng-template[ngt-soba-gizmo-helper-content]',
standalone: true,
})
export class NgtSobaGizmoHelperContent {
constructor(public templateRef: TemplateRef<{ gizmo: THREE.Group }>) {}
Expand All @@ -63,6 +65,7 @@ const targetPosition = makeVector3();

@Component({
selector: 'ngt-soba-gizmo-helper',
standalone: true,
template: `
<ngt-portal *ngIf="ready$ | async" [ref]="virtualScene">
<ng-template ngt-portal-content>
Expand All @@ -83,6 +86,16 @@ const targetPosition = makeVector3();
</ng-template>
</ngt-portal>
`,
imports: [
NgtPortal,
NgtPortalContent,
NgtGroup,
NgtObjectPassThrough,
NgtSobaOrthographicCamera,
NgIf,
NgTemplateOutlet,
AsyncPipe,
],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [provideObjectHostRef(NgtSobaGizmoHelper)],
})
Expand Down Expand Up @@ -276,8 +289,7 @@ export class NgtSobaGizmoHelper extends NgtObjectInputs<THREE.Group, NgtSobaGizm
}

@NgModule({
declarations: [NgtSobaGizmoHelper, NgtSobaGizmoHelperContent],
imports: [NgtSobaGizmoHelper, NgtSobaGizmoHelperContent],
exports: [NgtSobaGizmoHelper, NgtSobaGizmoHelperContent],
imports: [NgtPortalModule, NgtGroupModule, NgtObjectPassThroughModule, CommonModule, NgtSobaOrthographicCameraModule],
})
export class NgtSobaGizmoHelperModule {}
50 changes: 25 additions & 25 deletions libs/soba/abstractions/src/lib/gizmo-helper/gizmo-viewcube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import {
NgtEvent,
NgtInstance,
NgtInstanceState,
NgtRepeatModule,
NgtRepeat,
NgtStore,
NgtTriple,
NgtVector3,
NumberInput,
Ref,
startWithUndefined,
} from '@angular-three/core';
import { NgtBoxGeometryModule } from '@angular-three/core/geometries';
import { NgtGroupModule } from '@angular-three/core/group';
import { NgtAmbientLightModule, NgtPointLightModule } from '@angular-three/core/lights';
import { NgtMeshBasicMaterialModule, NgtMeshLambertMaterialModule } from '@angular-three/core/materials';
import { NgtMeshModule } from '@angular-three/core/meshes';
import { CommonModule } from '@angular/common';
import { NgtBoxGeometry } from '@angular-three/core/geometries';
import { NgtGroup } from '@angular-three/core/group';
import { NgtAmbientLight, NgtPointLight } from '@angular-three/core/lights';
import { NgtMeshBasicMaterial, NgtMeshLambertMaterial } from '@angular-three/core/materials';
import { NgtMesh } from '@angular-three/core/meshes';
import { AsyncPipe, NgForOf } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Expand Down Expand Up @@ -183,6 +183,7 @@ export abstract class NgtSobaGizmoViewCubeGeneric<TPart extends object> extends

@Directive({
selector: '[ngtSobaGizmoViewCubeGenericPassThrough]',
standalone: true,
})
export class NgtSobaGizmoViewCubePassThrough {
@Input() set ngtSobaGizmoViewCubeGenericPassThrough(wrapper: unknown) {
Expand Down Expand Up @@ -227,6 +228,7 @@ export class NgtSobaGizmoViewCubePassThrough {

@Component({
selector: 'ngt-soba-gizmo-face-material[hover][index]',
standalone: true,
template: `
<ngt-mesh-lambert-material
[ref]="instance"
Expand All @@ -237,6 +239,7 @@ export class NgtSobaGizmoViewCubePassThrough {
[opacity]="opacity"
></ngt-mesh-lambert-material>
`,
imports: [NgtMeshLambertMaterial, AsyncPipe],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
Expand Down Expand Up @@ -294,6 +297,7 @@ export class NgtSobaGizmoFaceMaterial extends NgtSobaGizmoViewCubeGeneric<THREE.

@Component({
selector: 'ngt-soba-gizmo-face-cube',
standalone: true,
template: `
<ngt-mesh
[raycast]="raycast"
Expand All @@ -310,6 +314,7 @@ export class NgtSobaGizmoFaceMaterial extends NgtSobaGizmoViewCubeGeneric<THREE.
></ngt-soba-gizmo-face-material>
</ngt-mesh>
`,
imports: [NgtMesh, NgtBoxGeometry, NgtSobaGizmoFaceMaterial, NgtSobaGizmoViewCubePassThrough, NgtRepeat, NgForOf],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
Expand Down Expand Up @@ -343,6 +348,7 @@ export class NgtSobaGizmoFaceCube extends NgtSobaGizmoViewCubeGeneric<THREE.Mesh

@Component({
selector: 'ngt-soba-gizmo-edge-cube[dimensions][position]',
standalone: true,
template: `
<ngt-mesh
[scale]="1.01"
Expand All @@ -361,6 +367,7 @@ export class NgtSobaGizmoFaceCube extends NgtSobaGizmoViewCubeGeneric<THREE.Mesh
></ngt-mesh-basic-material>
</ngt-mesh>
`,
imports: [NgtMesh, NgtBoxGeometry, NgtMeshBasicMaterial],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
Expand Down Expand Up @@ -408,6 +415,7 @@ export class NgtSobaGizmoEdgeCube extends NgtSobaGizmoViewCubeGeneric<THREE.Mesh

@Component({
selector: 'ngt-soba-gizmo-viewcube',
standalone: true,
template: `
<ngt-group [scale]="60">
<ngt-soba-gizmo-face-cube [ngtSobaGizmoViewCubeGenericPassThrough]="this"></ngt-soba-gizmo-face-cube>
Expand All @@ -430,6 +438,15 @@ export class NgtSobaGizmoEdgeCube extends NgtSobaGizmoViewCubeGeneric<THREE.Mesh
<ngt-point-light [position]="10" intensity="0.5"></ngt-point-light>
</ngt-group>
`,
imports: [
NgtGroup,
NgtSobaGizmoFaceCube,
NgtSobaGizmoEdgeCube,
NgtAmbientLight,
NgtPointLight,
NgtSobaGizmoViewCubePassThrough,
NgForOf,
],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
Expand All @@ -447,24 +464,7 @@ export class NgtSobaGizmoViewcube extends NgtSobaGizmoViewCubeGeneric<THREE.Grou
}

@NgModule({
declarations: [
NgtSobaGizmoViewcube,
NgtSobaGizmoViewCubePassThrough,
NgtSobaGizmoFaceMaterial,
NgtSobaGizmoFaceCube,
NgtSobaGizmoEdgeCube,
],
imports: [NgtSobaGizmoViewcube],
exports: [NgtSobaGizmoViewcube],
imports: [
CommonModule,
NgtMeshLambertMaterialModule,
NgtMeshBasicMaterialModule,
NgtMeshModule,
NgtBoxGeometryModule,
NgtGroupModule,
NgtAmbientLightModule,
NgtPointLightModule,
NgtRepeatModule,
],
})
export class NgtSobaGizmoViewcubeModule {}
Loading

0 comments on commit 5707f85

Please sign in to comment.