|
| 1 | +import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, inject } from '@angular/core'; |
| 2 | +import { NgtArgs } from 'angular-three'; |
| 3 | +import { NgtrCuboidCollider, NgtrPhysics } from 'angular-three-rapier'; |
| 4 | +import { NgtsCameraControls } from 'angular-three-soba/controls'; |
| 5 | +import { NgtsPreload } from 'angular-three-soba/misc'; |
| 6 | +import { NgtsContactShadows, NgtsEnvironment, NgtsLightformer } from 'angular-three-soba/staging'; |
| 7 | +import { Experience as BasicExperience } from '../basic/experience'; |
| 8 | +import { Experience as BrunoExperience } from '../bruno-simons-20k/experience'; |
| 9 | +import { Experience as InstancedVertexColorsExperience } from '../instanced-vertex-colors/experience'; |
| 10 | +import { Experience as LodExperience } from '../lod/experience'; |
| 11 | +import { Experience as LowpolyEarthExperience } from '../lowpoly-earth/experience'; |
| 12 | +import { Experience as ShakyExperience } from '../shaky/experience'; |
| 13 | +import { Experience as StarsExperience } from '../stars/experience'; |
| 14 | +import { Letter } from './letter'; |
| 15 | + |
| 16 | +/* credit: https://pmndrs.github.io/examples/demos/portal-shapes */ |
| 17 | + |
| 18 | +@Component({ |
| 19 | + standalone: true, |
| 20 | + template: ` |
| 21 | + <ngt-color *args="['#4899c9']" attach="background" /> |
| 22 | +
|
| 23 | + <ngtr-physics [options]="{ gravity: [0, -60, 0] }"> |
| 24 | + <ng-template> |
| 25 | + <!-- ANGULAR --> |
| 26 | + <app-letter char="A" [position]="[1, 50, -1]"> |
| 27 | + <ng-template> |
| 28 | + <app-basic-experience [withEffect]="false" /> |
| 29 | + </ng-template> |
| 30 | + </app-letter> |
| 31 | +
|
| 32 | + <app-letter char="N" [position]="[2, 60, -2]" [rotation]="[4, 5, 6]"> |
| 33 | + <ng-template> |
| 34 | + <app-bruno-experience [withEffect]="false" /> |
| 35 | + </ng-template> |
| 36 | + </app-letter> |
| 37 | +
|
| 38 | + <app-letter char="G" [position]="[3, 70, 2]" [rotation]="[7, 8, 9]"> |
| 39 | + <ng-template> |
| 40 | + <app-instanced-vertex-colors-experience [withEffect]="false" /> |
| 41 | + </ng-template> |
| 42 | + </app-letter> |
| 43 | +
|
| 44 | + <app-letter char="U" [position]="[-1, 80, 3]" [rotation]="[10, 11, 12]"> |
| 45 | + <ng-template> |
| 46 | + <app-lod-experience /> |
| 47 | + </ng-template> |
| 48 | + </app-letter> |
| 49 | +
|
| 50 | + <app-letter char="L" [position]="[-2, 90, 2]" [rotation]="[13, 14, 15]"> |
| 51 | + <ng-template> |
| 52 | + <ngt-group [scale]="15"> |
| 53 | + <app-lowpoly-earth-experience /> |
| 54 | + </ngt-group> |
| 55 | + </ng-template> |
| 56 | + </app-letter> |
| 57 | +
|
| 58 | + <app-letter char="A" [position]="[-3, 100, -3]" [rotation]="[16, 17, 18]"> |
| 59 | + <ng-template> |
| 60 | + <app-shaky-experience [withEffect]="false" /> |
| 61 | + </ng-template> |
| 62 | + </app-letter> |
| 63 | +
|
| 64 | + <app-letter char="R" [position]="[-4, 110, 1]" [rotation]="[19, 20, 21]" [stencilBuffer]="true"> |
| 65 | + <ng-template> |
| 66 | + <app-stars-experience /> |
| 67 | + </ng-template> |
| 68 | + </app-letter> |
| 69 | +
|
| 70 | + <!-- invisible walls --> |
| 71 | + <ngt-object3D ngtrCuboidCollider [args]="[100, 1, 100]" [position]="[0, -6, 0]" /> |
| 72 | + <ngt-object3D ngtrCuboidCollider [args]="[30, 100, 1]" [position]="[0, 0, -30]" /> |
| 73 | + <ngt-object3D ngtrCuboidCollider [args]="[30, 100, 1]" [position]="[0, 0, 10]" /> |
| 74 | + <ngt-object3D ngtrCuboidCollider [args]="[1, 100, 30]" [position]="[-30, 0, 0]" /> |
| 75 | + <ngt-object3D ngtrCuboidCollider [args]="[1, 100, 30]" [position]="[30, 0, 0]" /> |
| 76 | + </ng-template> |
| 77 | + </ngtr-physics> |
| 78 | +
|
| 79 | + <!-- environment --> |
| 80 | + <ngts-environment |
| 81 | + [options]="{ |
| 82 | + files: 'https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/1k/dancing_hall_1k.hdr', |
| 83 | + resolution: 1024, |
| 84 | + }" |
| 85 | + > |
| 86 | + <ng-template> |
| 87 | + <!-- On top of the HDRI we add some rectangular and circular shapes for nicer reflections --> |
| 88 | + <ngt-group [rotation]="[-Math.PI / 3, 0, 0]"> |
| 89 | + <ngts-lightformer |
| 90 | + [options]="{ |
| 91 | + intensity: 4 * Math.PI, |
| 92 | + rotation: [Math.PI / 2, 0, 0], |
| 93 | + position: [0, 5, -9], |
| 94 | + scale: [10, 10, 1], |
| 95 | + }" |
| 96 | + /> |
| 97 | + @for (x of [2, 0, 2, 0, 2, 0, 2, 0]; track $index) { |
| 98 | + <ngts-lightformer |
| 99 | + [options]="{ |
| 100 | + form: 'circle', |
| 101 | + intensity: 4 * Math.PI, |
| 102 | + rotation: [Math.PI / 2, 0, 0], |
| 103 | + position: [x, 4, $index * 4], |
| 104 | + scale: [4, 1, 1], |
| 105 | + }" |
| 106 | + /> |
| 107 | + } |
| 108 | + <ngts-lightformer |
| 109 | + [options]="{ |
| 110 | + intensity: 2 * Math.PI, |
| 111 | + rotation: [0, Math.PI / 2, 0], |
| 112 | + position: [-5, 1, -1], |
| 113 | + scale: [50, 2, 1], |
| 114 | + }" |
| 115 | + /> |
| 116 | + <ngts-lightformer |
| 117 | + [options]="{ |
| 118 | + intensity: 2 * Math.PI, |
| 119 | + rotation: [0, -Math.PI / 2, 0], |
| 120 | + position: [10, 1, 0], |
| 121 | + scale: [50, 2, 1], |
| 122 | + }" |
| 123 | + /> |
| 124 | + </ngt-group> |
| 125 | + </ng-template> |
| 126 | + </ngts-environment> |
| 127 | +
|
| 128 | + <!-- contact shadows for naive soft shadows --> |
| 129 | + <ngts-contact-shadows |
| 130 | + [options]="{ smooth: false, scale: 100, position: [0, -5.05, 0], blur: 0.5, opacity: 0.75 }" |
| 131 | + /> |
| 132 | +
|
| 133 | + <!-- yomotsu/camera-controls, a better replacement for OrbitControls --> |
| 134 | + <ngts-camera-controls |
| 135 | + [options]="{ makeDefault: true, dollyToCursor: true, minPolarAngle: 0, maxPolarAngle: Math.PI / 2 }" |
| 136 | + /> |
| 137 | + `, |
| 138 | + schemas: [CUSTOM_ELEMENTS_SCHEMA], |
| 139 | + changeDetection: ChangeDetectionStrategy.OnPush, |
| 140 | + imports: [ |
| 141 | + NgtrPhysics, |
| 142 | + NgtrCuboidCollider, |
| 143 | + NgtsEnvironment, |
| 144 | + NgtsLightformer, |
| 145 | + NgtsContactShadows, |
| 146 | + NgtsCameraControls, |
| 147 | + Letter, |
| 148 | + BasicExperience, |
| 149 | + NgtArgs, |
| 150 | + BrunoExperience, |
| 151 | + InstancedVertexColorsExperience, |
| 152 | + LodExperience, |
| 153 | + LowpolyEarthExperience, |
| 154 | + ShakyExperience, |
| 155 | + StarsExperience, |
| 156 | + ], |
| 157 | + hostDirectives: [NgtsPreload], |
| 158 | +}) |
| 159 | +export class Experience { |
| 160 | + protected readonly Math = Math; |
| 161 | + |
| 162 | + private preload = inject(NgtsPreload, { host: true }); |
| 163 | + |
| 164 | + constructor() { |
| 165 | + this.preload.all.set(true); |
| 166 | + } |
| 167 | +} |
0 commit comments