|
| 1 | +import { RouteMeta } from '@analogjs/router'; |
| 2 | +import { NgIf } from '@angular/common'; |
| 3 | +import { Component, CUSTOM_ELEMENTS_SCHEMA, Signal } from '@angular/core'; |
| 4 | +import { NgtArgs, NgtBeforeRenderEvent, NgtCanvas } from 'angular-three'; |
| 5 | +import { NgtpEffectComposer } from 'angular-three-postprocessing'; |
| 6 | +import { NgtpBloom, NgtpDotScreen } from 'angular-three-postprocessing/effects'; |
| 7 | +import { NgtsOrbitControls } from 'angular-three-soba/controls'; |
| 8 | +import { injectNgtsGLTFLoader } from 'angular-three-soba/loaders'; |
| 9 | +import * as THREE from 'three'; |
| 10 | +import { GLTF } from 'three-stdlib'; |
| 11 | + |
| 12 | +export const routeMeta: RouteMeta = { |
| 13 | + title: 'Keen', |
| 14 | +}; |
| 15 | + |
| 16 | +interface KeenGLTF extends GLTF { |
| 17 | + nodes: { mesh_0: THREE.Mesh }; |
| 18 | + materials: { 'Scene_-_Root': THREE.MeshStandardMaterial }; |
| 19 | +} |
| 20 | + |
| 21 | +@Component({ |
| 22 | + standalone: true, |
| 23 | + templateUrl: 'scene.html', |
| 24 | + imports: [NgtpEffectComposer, NgtpBloom, NgtpDotScreen, NgIf, NgtArgs, NgtsOrbitControls], |
| 25 | + schemas: [CUSTOM_ELEMENTS_SCHEMA], |
| 26 | +}) |
| 27 | +class SceneGraph { |
| 28 | + readonly Math = Math; |
| 29 | + readonly keen = injectNgtsGLTFLoader(() => 'keen/scene.gltf') as Signal<KeenGLTF>; |
| 30 | + |
| 31 | + onBeforeRender({ object, state: { clock } }: NgtBeforeRenderEvent<THREE.Group>) { |
| 32 | + object.rotation.z = clock.elapsedTime; |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +@Component({ |
| 37 | + standalone: true, |
| 38 | + templateUrl: 'index.html', |
| 39 | + imports: [NgtCanvas], |
| 40 | +}) |
| 41 | +export default class Keen { |
| 42 | + readonly scene = SceneGraph; |
| 43 | +} |
0 commit comments