Skip to content

Commit c774832

Browse files
committed
docs: add demo app
1 parent c79abfe commit c774832

File tree

16 files changed

+298
-1
lines changed

16 files changed

+298
-1
lines changed

apps/demo/.eslintrc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"rules": {
8+
"@angular-eslint/directive-selector": "off",
9+
"@angular-eslint/directive-class-suffix": "off",
10+
"@angular-eslint/component-selector": "off",
11+
"@angular-eslint/component-class-suffix": "off",
12+
"@typescript-eslint/no-empty-function": "off",
13+
"@typescript-eslint/ban-ts-comment": "off",
14+
"@typescript-eslint/no-explicit-any": "off",
15+
"@typescript-eslint/ban-types": "off",
16+
"@typescript-eslint/member-ordering": "off",
17+
"@typescript-eslint/no-non-null-assertion": "off"
18+
},
19+
"extends": ["plugin:@nrwl/nx/angular", "plugin:@angular-eslint/template/process-inline-templates"]
20+
},
21+
{
22+
"files": ["*.html"],
23+
"extends": ["plugin:@nrwl/nx/angular-template"],
24+
"rules": {}
25+
}
26+
]
27+
}

apps/demo/project.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "demo",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"projectType": "application",
5+
"sourceRoot": "apps/demo/src",
6+
"prefix": "demo",
7+
"targets": {
8+
"build": {
9+
"executor": "@angular-devkit/build-angular:browser",
10+
"outputs": ["{options.outputPath}"],
11+
"options": {
12+
"outputPath": "dist/apps/demo",
13+
"index": "apps/demo/src/index.html",
14+
"main": "apps/demo/src/main.ts",
15+
"polyfills": ["zone.js"],
16+
"tsConfig": "apps/demo/tsconfig.app.json",
17+
"assets": ["apps/demo/src/favicon.ico", "apps/demo/src/assets"],
18+
"styles": ["apps/demo/src/styles.css"],
19+
"scripts": []
20+
},
21+
"configurations": {
22+
"production": {
23+
"budgets": [
24+
{
25+
"type": "initial",
26+
"maximumWarning": "500kb",
27+
"maximumError": "1mb"
28+
},
29+
{
30+
"type": "anyComponentStyle",
31+
"maximumWarning": "2kb",
32+
"maximumError": "4kb"
33+
}
34+
],
35+
"outputHashing": "all"
36+
},
37+
"development": {
38+
"buildOptimizer": false,
39+
"optimization": false,
40+
"vendorChunk": true,
41+
"extractLicenses": false,
42+
"sourceMap": true,
43+
"namedChunks": true
44+
}
45+
},
46+
"defaultConfiguration": "production"
47+
},
48+
"serve": {
49+
"executor": "@angular-devkit/build-angular:dev-server",
50+
"configurations": {
51+
"production": {
52+
"browserTarget": "demo:build:production"
53+
},
54+
"development": {
55+
"browserTarget": "demo:build:development"
56+
}
57+
},
58+
"defaultConfiguration": "development"
59+
},
60+
"extract-i18n": {
61+
"executor": "@angular-devkit/build-angular:extract-i18n",
62+
"options": {
63+
"browserTarget": "demo:build"
64+
}
65+
},
66+
"lint": {
67+
"executor": "@nrwl/linter:eslint",
68+
"outputs": ["{options.outputFile}"],
69+
"options": {
70+
"lintFilePatterns": ["apps/demo/**/*.ts", "apps/demo/**/*.html"]
71+
}
72+
}
73+
},
74+
"tags": []
75+
}

apps/demo/src/app/app.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component } from '@angular/core';
2+
import { RouterOutlet } from '@angular/router';
3+
4+
@Component({
5+
standalone: true,
6+
selector: 'demo-root',
7+
template: ` <router-outlet />`,
8+
imports: [RouterOutlet],
9+
})
10+
export class AppComponent { }

apps/demo/src/app/app.routes.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Routes } from '@angular/router';
2+
3+
export const routes: Routes = [
4+
{ path: '', redirectTo: 'test', pathMatch: 'full' },
5+
{ path: 'test', loadComponent: () => import('./test/test.component') },
6+
];
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2+
import { NgtArgs, NgtBeforeRenderEvent } from 'angular-three';
3+
4+
@Component({
5+
selector: 'demo-test-scene',
6+
standalone: true,
7+
template: `
8+
<ngt-mesh (beforeRender)="onBeforeRender($any($event))">
9+
<ngt-box-geometry *args="[2, 2, 2]" />
10+
<ngt-mesh-basic-material color="goldenrod" />
11+
</ngt-mesh>
12+
`,
13+
imports: [NgtArgs],
14+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
15+
})
16+
export class Scene {
17+
onBeforeRender({ object }: NgtBeforeRenderEvent<THREE.Mesh>) {
18+
object.rotation.x += 0.01;
19+
object.rotation.y += 0.01;
20+
}
21+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component } from '@angular/core';
2+
import { NgtCanvas } from 'angular-three';
3+
import { Scene } from './scene.component';
4+
5+
@Component({
6+
selector: 'demo-test',
7+
standalone: true,
8+
template: `<ngt-canvas [scene]="Scene" />`,
9+
imports: [NgtCanvas],
10+
})
11+
export default class DemoTest {
12+
readonly Scene = Scene;
13+
}

apps/demo/src/assets/.gitkeep

Whitespace-only changes.

apps/demo/src/favicon.ico

14.7 KB
Binary file not shown.

apps/demo/src/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Demo</title>
6+
<base href="/" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<link rel="icon" type="image/x-icon" href="favicon.ico" />
9+
</head>
10+
<body>
11+
<demo-root></demo-root>
12+
</body>
13+
</html>

apps/demo/src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { bootstrapApplication } from '@angular/platform-browser';
2+
import { provideRouter } from '@angular/router';
3+
import { extend } from 'angular-three';
4+
import * as THREE from 'three';
5+
import { AppComponent } from './app/app.component';
6+
import { routes } from './app/app.routes';
7+
8+
extend(THREE);
9+
10+
bootstrapApplication(AppComponent, { providers: [provideRouter(routes)] }).catch((err) => console.error(err));

apps/demo/src/styles.css

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
1. Use a more-intuitive box-sizing model.
3+
*/
4+
*,
5+
*::before,
6+
*::after {
7+
box-sizing: border-box;
8+
}
9+
/*
10+
2. Remove default margin
11+
*/
12+
* {
13+
margin: 0;
14+
}
15+
/*
16+
3. Allow percentage-based heights in the application
17+
*/
18+
html,
19+
body {
20+
height: 100%;
21+
width: 100%;
22+
}
23+
/*
24+
Typographic tweaks!
25+
4. Add accessible line-height
26+
5. Improve text rendering
27+
*/
28+
body {
29+
line-height: 1.5;
30+
-webkit-font-smoothing: antialiased;
31+
font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji,
32+
Segoe UI Emoji;
33+
}
34+
/*
35+
6. Improve media defaults
36+
*/
37+
img,
38+
picture,
39+
video,
40+
canvas,
41+
svg {
42+
display: block;
43+
max-width: 100%;
44+
}
45+
/*
46+
7. Remove built-in form typography styles
47+
*/
48+
input,
49+
button,
50+
textarea,
51+
select {
52+
font: inherit;
53+
}
54+
/*
55+
8. Avoid text overflows
56+
*/
57+
p,
58+
h1,
59+
h2,
60+
h3,
61+
h4,
62+
h5,
63+
h6 {
64+
overflow-wrap: break-word;
65+
}
66+
/*
67+
9. Create a root stacking context
68+
*/
69+
#root,
70+
#__next {
71+
isolation: isolate;
72+
}

apps/demo/tsconfig.app.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"types": []
6+
},
7+
"files": ["src/main.ts"],
8+
"include": ["src/**/*.d.ts"],
9+
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
10+
}

apps/demo/tsconfig.editor.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["src/**/*.ts"],
4+
"compilerOptions": {
5+
"types": []
6+
}
7+
}

apps/demo/tsconfig.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022",
4+
"useDefineForClassFields": false,
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitOverride": true,
8+
"noPropertyAccessFromIndexSignature": true,
9+
"noImplicitReturns": true,
10+
"noFallthroughCasesInSwitch": true
11+
},
12+
"files": [],
13+
"include": [],
14+
"references": [
15+
{
16+
"path": "./tsconfig.app.json"
17+
},
18+
{
19+
"path": "./tsconfig.editor.json"
20+
}
21+
],
22+
"extends": "../../tsconfig.base.json",
23+
"angularCompilerOptions": {
24+
"enableI18nLegacyMessageIdFormat": false,
25+
"strictInjectionParameters": true,
26+
"strictInputAccessModifiers": true,
27+
"strictTemplates": true
28+
}
29+
}

libs/angular-three/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
export * from './lib/canvas';
2+
export * from './lib/types';
3+
export * from './lib/di/catalogue';
4+
export * from './lib/directives/args';
5+
export * from './lib/directives/repeat';

libs/angular-three/src/lib/renderer/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { applyProps } from '../utils/apply-props';
66
import { getLocalState } from '../utils/instance';
77
import { is } from '../utils/is';
88
import { NgtCompoundClassId, NgtQueueOpClassId, NgtRendererClassId } from './enums';
9-
import { attachThreeChild, SPECIAL_PROPERTIES } from './utils';
9+
import { attachThreeChild, removeThreeChild, SPECIAL_PROPERTIES } from './utils';
1010

1111
export type NgtRendererRootState = {
1212
store: NgtStore;

0 commit comments

Comments
 (0)