Skip to content

Commit 00d276e

Browse files
Chau TranChau Tran
Chau Tran
authored and
Chau Tran
committed
docs: migrate keen
1 parent 343fd8f commit 00d276e

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ngt-canvas [sceneGraph]="scene" [camera]="{ position: [0, 0, 15], near: 5, far: 20 }" />
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<ngt-color *args="['black']" attach="background" />
2+
3+
<ngt-ambient-light />
4+
<ngt-directional-light [position]="[0, 1, 2]" />
5+
6+
<ngt-group [position]="[0, -7, 0]" [rotation]="[-Math.PI / 2, 0, 0]" (beforeRender)="onBeforeRender($event)">
7+
<ngt-mesh
8+
*ngIf="keen() as keen"
9+
[material]="keen.materials['Scene_-_Root']"
10+
[geometry]="keen.nodes['mesh_0'].geometry"
11+
/>
12+
</ngt-group>
13+
14+
<ngtp-effect-composer>
15+
<ngtp-bloom [intensity]="5" />
16+
<ngtp-dot-screen [scale]="3" />
17+
</ngtp-effect-composer>
18+
19+
<ngts-orbit-controls />

0 commit comments

Comments
 (0)