Skip to content

Commit 054a010

Browse files
committed
docs: setup new docs (3)
1 parent 4bdfcde commit 054a010

File tree

15 files changed

+489
-200
lines changed

15 files changed

+489
-200
lines changed

apps/docs/astro.config.mjs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import starlight from '@astrojs/starlight';
33
import tailwind from '@astrojs/tailwind';
44
import { defineConfig } from 'astro/config';
55
import { readFileSync } from 'node:fs';
6-
import starlightBlog from 'starlight-blog';
76

87
function includeContentPlugin() {
98
const map = new Map();
@@ -47,11 +46,11 @@ export default defineConfig({
4746
ssr: {
4847
noExternal: [
4948
'angular-three',
50-
'angular-three/**',
5149
'angular-three-soba/**',
5250
'angular-three-cannon',
5351
'angular-three-cannon/**',
5452
'angular-three-rapier',
53+
'angular-three-rapier/**',
5554
'angular-three-postprocessing',
5655
'angular-three-postprocessing/**',
5756
'@angular/common',
@@ -73,21 +72,28 @@ export default defineConfig({
7372
starlight({
7473
title: 'Angular Three',
7574
plugins: [
76-
starlightBlog({
77-
authors: {
78-
chau: {
79-
name: 'Chau Tran',
80-
url: 'https://nartc.me',
81-
picture: 'https://avatars.githubusercontent.com/u/25516557?v=4',
82-
},
83-
},
84-
}),
75+
// starlightBlog({
76+
// authors: {
77+
// chau: {
78+
// name: 'Chau Tran',
79+
// url: 'https://nartc.me',
80+
// picture: 'https://avatars.githubusercontent.com/u/25516557?v=4',
81+
// },
82+
// },
83+
// }),
8584
],
8685
favicon: './src/assets/angular-three-dark.svg',
87-
tableOfContents: { minHeadingLevel: 2, maxHeadingLevel: 4 },
88-
logo: { light: './src/assets/angular-three.svg', dark: './src/assets/angular-three-dark.svg' },
89-
social: { github: 'https://github.com/angular-threejs/angular-three' },
90-
credits: true,
86+
tableOfContents: {
87+
minHeadingLevel: 2,
88+
maxHeadingLevel: 4,
89+
},
90+
logo: {
91+
light: './src/assets/angular-three.svg',
92+
dark: './src/assets/angular-three-dark.svg',
93+
},
94+
social: {
95+
github: 'https://github.com/angular-threejs/angular-three',
96+
},
9197
customCss: ['./src/tailwind.css'],
9298
sidebar: [
9399
{

apps/docs/ec.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { pluginLineNumbers } from '@expressive-code/plugin-line-numbers';
22

33
export default {
4-
themes: ['dark-plus', 'light-plus'],
54
plugins: [pluginLineNumbers()],
65
};

apps/docs/package.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,28 @@
1212
"dependencies": {
1313
"@astrojs/starlight": "^0.31.1",
1414
"@astrojs/starlight-tailwind": "^3.0.0",
15-
"@astrojs/tailwind": "^5.1.5",
16-
"astro": "^5.1.8",
17-
"starlight-blog": "^0.16.1",
15+
"@astrojs/tailwind": "^5.1.4",
16+
"angular-three": "file:../../dist/libs/core",
17+
"astro": "^5.1.5",
1818
"sharp": "^0.33.5",
19-
"tailwindcss": "^3.4.17"
19+
"starlight-blog": "^0.16.1",
20+
"tailwindcss": "^3.4.4"
2021
},
2122
"devDependencies": {
2223
"@expressive-code/plugin-line-numbers": "^0.40.1"
24+
},
25+
"nx": {
26+
"targets": {
27+
"dev": {
28+
"dependsOn": [
29+
{
30+
"projects": [
31+
"core"
32+
],
33+
"target": "build"
34+
}
35+
]
36+
}
37+
}
2338
}
2439
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {
2+
ChangeDetectionStrategy,
3+
Component,
4+
CUSTOM_ELEMENTS_SCHEMA,
5+
ElementRef,
6+
signal,
7+
viewChild,
8+
} from '@angular/core';
9+
import { extend, injectBeforeRender } from 'angular-three';
10+
import { BoxGeometry, Mesh, MeshNormalMaterial } from 'three';
11+
12+
@Component({
13+
selector: 'app-scene-graph',
14+
template: `
15+
<ngt-mesh #mesh [scale]="scale()" (pointerover)="scale.set(1.5)" (pointerout)="scale.set(1)">
16+
<ngt-box-geometry />
17+
<ngt-mesh-normal-material />
18+
</ngt-mesh>
19+
`,
20+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
21+
changeDetection: ChangeDetectionStrategy.OnPush,
22+
})
23+
export class SceneGraph {
24+
private meshRef = viewChild.required<ElementRef<Mesh>>('mesh');
25+
26+
protected scale = signal(1);
27+
28+
constructor() {
29+
extend({ Mesh, MeshNormalMaterial, BoxGeometry });
30+
31+
injectBeforeRender(() => {
32+
const mesh = this.meshRef().nativeElement;
33+
mesh.rotation.x += 0.01;
34+
mesh.rotation.y += 0.01;
35+
});
36+
}
37+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component } from '@angular/core';
2+
import { NgtCanvasDeclarations, provideNgtRenderer } from 'angular-three/dom';
3+
import { SceneGraph } from './scene-graph';
4+
5+
@Component({
6+
template: `
7+
<ngt-canvas [camera]="{ position: [0, 0, 2] }">
8+
<app-scene-graph *canvasContent />
9+
</ngt-canvas>
10+
`,
11+
imports: [NgtCanvasDeclarations, SceneGraph],
12+
})
13+
export default class SimpleScene {
14+
static clientProviders = [provideNgtRenderer()];
15+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
import { Tabs, TabItem } from '@astrojs/starlight/components';
3+
import { getEntry, render } from 'astro:content';
4+
5+
interface Props {
6+
class?: string;
7+
snippets: {
8+
name: string;
9+
title?: string;
10+
}[]
11+
}
12+
13+
const { snippets, class: className = '' } = Astro.props;
14+
15+
const settledResults = await Promise.allSettled(
16+
snippets.map(async (snippet) => {
17+
const entryPromise = getEntry('snippets', snippet.name);
18+
if (!entryPromise) {
19+
return Promise.reject(new Error(`Snippet ${snippet.name} not found`));
20+
}
21+
22+
const entry = await entryPromise;
23+
return ({ entry, tabTitle: snippet.title });
24+
})
25+
);
26+
27+
const results = [];
28+
29+
for (const settledResult of settledResults) {
30+
if (settledResult.status === 'rejected') {
31+
throw settledResult.reason;
32+
}
33+
34+
results.push(settledResult.value);
35+
}
36+
37+
38+
39+
const rendered = await Promise.all(
40+
results.map(async resultEntry => {
41+
const {Content} = await render(resultEntry.entry);
42+
return {Content, tabTitle: resultEntry.tabTitle}
43+
})
44+
);
45+
---
46+
47+
<div class:list={["p-4 rounded border border-dashed border-accent-600 dark:border-accent-200 shadow-2xl h-fit", className]}>
48+
<Tabs>
49+
{rendered.map(({Content, tabTitle}) => (
50+
<TabItem label={tabTitle || ''}>
51+
<Content />
52+
</TabItem>
53+
))}
54+
</Tabs>
55+
</div>

apps/docs/src/content.config.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
import { defineCollection } from 'astro:content';
2-
31
import { docsLoader } from '@astrojs/starlight/loaders';
42
import { docsSchema } from '@astrojs/starlight/schema';
3+
import { glob } from 'astro/loaders';
4+
import { defineCollection, z } from 'astro:content';
55
import { blogSchema } from 'starlight-blog/schema';
66

77
export const collections = {
8-
// @ts-expect-error - not sure why this is an error
9-
docs: defineCollection({ loader: docsLoader(), schema: docsSchema({ extend: (context) => blogSchema(context) }) }),
8+
docs: defineCollection({
9+
loader: docsLoader(),
10+
schema: docsSchema({
11+
// @ts-expect-error
12+
extend: (context) => blogSchema(context),
13+
}),
14+
}),
15+
snippets: defineCollection({
16+
loader: glob({ pattern: '**/*.md', base: './src/content/snippets' }),
17+
schema: z.object({}),
18+
}),
1019
};

apps/docs/src/content/docs/index.mdx

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,52 @@
11
---
2-
title: Welcome to Starlight
3-
description: Get started building your docs site with Starlight.
2+
title: Welcome to Angular Three
3+
description: Get started building your 3D scene graphs with Angular Three
44
template: splash
55
hero:
66
title: |
7-
Welcome to Starlight with
8-
<span
9-
class="font-black text-transparent
10-
bg-clip-text bg-gradient-to-b
11-
from-accent-700 to-accent-400
12-
dark:from-accent-500 dark:to-accent-200"
13-
>
14-
Tailwind
15-
</span>
16-
tagline: Congrats on setting up a new Starlight project!
7+
Declarative 3D experiences with
8+
<code class="text-accent-600 dark:text-accent-200">Angular</code>
179
image:
18-
file: ../../assets/houston.webp
10+
dark: ../../assets/angular-three-dark.svg
11+
light: ../../assets/angular-three.svg
1912
actions:
20-
- text: Example Guide
13+
- text: Getting started
2114
link: /guides/example/
2215
icon: right-arrow
23-
- text: Read the Starlight docs
24-
link: https://starlight.astro.build
16+
- text: Check out the demo
17+
link: https://demo.angularthree.org
2518
icon: external
2619
variant: minimal
2720
---
2821

29-
import { Card, CardGrid } from '@astrojs/starlight/components';
22+
import FloatingCodeBlock from '../../components/ui/floating-code-block.astro';
23+
import SimpleScene from '../../components/scenes/simple-scene/simple-scene';
3024

31-
## Next steps
25+
<section class="min-h-screen w-full flex justify-center items-center">
26+
<div class="relative h-full w-full grid grid-cols-8 gap-4">
27+
<div class="col-span-3">
28+
<h1>
29+
Declarative <span class="text-accent-600 dark:text-accent-200">scene graphs</span>
30+
</h1>
3231

33-
<CardGrid stagger>
34-
<Card title="Update content" icon="pencil">
35-
Edit `src/content/docs/index.mdx` to see this page change.
36-
</Card>
37-
<Card title="Add new content" icon="add-document">
38-
Add Markdown or MDX files to `src/content/docs` to create new pages.
39-
</Card>
40-
<Card title="Configure your site" icon="setting">
41-
Edit your `sidebar` and other config in `astro.config.mjs`.
42-
</Card>
43-
<Card title="Read the docs" icon="open-book">
44-
Learn more in [the Starlight Docs](https://starlight.astro.build/).
45-
</Card>
46-
</CardGrid>
32+
<p>
33+
Angular Three allows the users to declaratively build a scene graph using the familiar Angular template syntax. This
34+
approach enables Angular developers to leverage familiar skills and tools of Angular template to build 3D scenes.
35+
</p>
36+
37+
<div class="h-[200px] w-full">
38+
<SimpleScene client:only />
39+
</div>
40+
41+
</div>
42+
<FloatingCodeBlock
43+
class="col-span-5"
44+
snippets={[
45+
{ title: 'scene-graph.ts', name: 'simple-scene' },
46+
{ title: 'canvas.ts', name: 'simple-scene-canvas' },
47+
]}
48+
/>
49+
50+
</div>
51+
52+
</section>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
```angular-ts
2+
import { NgtCanvasDeclarations } from 'angular-three/dom';
3+
import { SceneGraph } from './scene-graph';
4+
5+
@Component({
6+
template: `
7+
<ngt-canvas>
8+
<app-scene-graph *canvasContent />
9+
</ngt-canvas>
10+
`,
11+
imports: [NgtCanvasDeclarations, SceneGraph]
12+
})
13+
export class SimpleScene {}
14+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
```angular-ts
2+
import { extend, injectBeforeRender } from 'angular-three';
3+
import { Mesh, BoxGeometry, MeshNormalMaterial } from 'three';
4+
5+
@Component({
6+
selector: 'app-scene-graph',
7+
template: `
8+
<ngt-mesh #mesh
9+
[scale]="scale()"
10+
(pointerover)="scale.set(1.5)"
11+
(pointerout)="scale.set(1)"
12+
>
13+
<ngt-box-geometry />
14+
<ngt-mesh-normal-material />
15+
</ngt-mesh>
16+
`,
17+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
18+
})
19+
export class SceneGraph {
20+
private meshRef = viewChild.required<ElementRef<Mesh>>('mesh');
21+
22+
protected scale = signal(1);
23+
24+
constructor() {
25+
extend({ Mesh, BoxGeometry, MeshNormalMaterial });
26+
27+
injectBeforeRender(() => {
28+
const mesh = this.meshRef().nativeElement;
29+
mesh.rotation.x += 0.01;
30+
mesh.rotation.y += 0.01;
31+
});
32+
}
33+
}
34+
```

apps/docs/src/env.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)