Skip to content

Commit

Permalink
feat: signals are ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Chau Tran authored and Chau Tran committed May 9, 2023
1 parent 580393b commit ec8f498
Show file tree
Hide file tree
Showing 54 changed files with 4,870 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"releaseName": "Release ${version}"
},
"hooks": {
"before:bump": "npx nx package angular-three",
"before:bump": "pnpm exec nx package angular-three",
"after:bump": ["git checkout -- package.json"]
}
}
33 changes: 33 additions & 0 deletions apps/demo/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "angularThree",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "angular-three",
"style": "kebab-case"
}
]
},
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"]
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
75 changes: 75 additions & 0 deletions apps/demo/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "demo",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"prefix": "angular-three",
"sourceRoot": "apps/demo/src",
"tags": [],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/demo",
"index": "apps/demo/src/index.html",
"main": "apps/demo/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/demo/tsconfig.app.json",
"assets": ["apps/demo/src/favicon.ico", "apps/demo/src/assets"],
"styles": ["apps/demo/src/styles.css"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "demo:build:production"
},
"development": {
"browserTarget": "demo:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "demo:build"
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/demo/**/*.ts", "apps/demo/**/*.html"]
}
}
}
}
57 changes: 57 additions & 0 deletions apps/demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { NgTemplateOutlet } from '@angular/common';
import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { NgtCanvas, extend } from 'angular-three';
import * as THREE from 'three';

extend(THREE);

@Component({
selector: 'app-cube',
standalone: true,
template: `
<ngt-mesh
(beforeRender)="onBeforeRender($any($event).object)"
(pointerover)="hover.set(true)"
(pointerout)="hover.set(false)"
(click)="active.set(!active())"
[scale]="active() ? 1.5 : 1"
>
<ngt-box-geometry />
<ngt-mesh-standard-material [color]="hover() ? 'hotpink' : 'orange'" />
</ngt-mesh>
`,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Cube {
hover = signal(false);
active = signal(false);

onBeforeRender(mesh: THREE.Mesh) {
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.01;
}
}

@Component({
standalone: true,
template: `
<ngt-spot-light [position]="5" />
<ngt-point-light [position]="-5" />
<app-cube />
`,
imports: [Cube, NgTemplateOutlet],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Scene {}

@Component({
standalone: true,
imports: [NgtCanvas],
selector: 'angular-three-root',
template: ` <ngt-canvas [sceneGraph]="scene" />`,
})
export class AppComponent {
readonly scene = Scene;
}
5 changes: 5 additions & 0 deletions apps/demo/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ApplicationConfig } from '@angular/core';

export const appConfig: ApplicationConfig = {
providers: [],
};
Empty file added apps/demo/src/assets/.gitkeep
Empty file.
Binary file added apps/demo/src/favicon.ico
Binary file not shown.
13 changes: 13 additions & 0 deletions apps/demo/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>demo</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<angular-three-root />
</body>
</html>
5 changes: 5 additions & 0 deletions apps/demo/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { appConfig } from './app/app.config';

bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
73 changes: 73 additions & 0 deletions apps/demo/src/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* You can add global styles to this file, and also import other style files */
/*
1. Use a more-intuitive box-sizing model.
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
/*
2. Remove default margin
*/
* {
margin: 0;
}
/*
3. Allow percentage-based heights in the application
*/
html,
body {
height: 100%;
width: 100%;
}
/*
Typographic tweaks!
4. Add accessible line-height
5. Improve text rendering
*/
body {
line-height: 1.5;
-webkit-font-smoothing: antialiased;
font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji,
Segoe UI Emoji;
}
/*
6. Improve media defaults
*/
img,
picture,
video,
canvas,
svg {
display: block;
max-width: 100%;
}
/*
7. Remove built-in form typography styles
*/
input,
button,
textarea,
select {
font: inherit;
}
/*
8. Avoid text overflows
*/
p,
h1,
h2,
h3,
h4,
h5,
h6 {
overflow-wrap: break-word;
}
/*
9. Create a root stacking context
*/
#root,
#__next {
isolation: isolate;
}
10 changes: 10 additions & 0 deletions apps/demo/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": []
},
"files": ["src/main.ts"],
"include": ["src/**/*.d.ts"],
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
}
7 changes: 7 additions & 0 deletions apps/demo/tsconfig.editor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*.ts"],
"compilerOptions": {
"types": []
}
}
29 changes: 29 additions & 0 deletions apps/demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "es2022",
"useDefineForClassFields": false,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.editor.json"
}
],
"extends": "../../tsconfig.base.json",
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
1 change: 1 addition & 0 deletions libs/angular-three/metadata.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion libs/angular-three/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"dest": "../../dist/libs/angular-three",
"lib": {
"entryFile": "src/index.ts"
}
},
"allowedNonPeerDependencies": ["ngx-resize", "@nx/devkit", "nx"],
"assets": ["metadata.json", "web-types.json"]
}
34 changes: 30 additions & 4 deletions libs/angular-three/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
{
"name": "angular-three",
"version": "0.0.1",
"version": "0.0.0-replace",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/angular-threejs/angular-three/tree/main/libs/angular-three"
},
"author": {
"name": "Chau Tran",
"email": "nartc7789@gmail.com",
"url": "https://nartc.me"
},
"description": "Angular Renderer for THREE.js",
"keywords": [
"angular",
"threejs",
"renderer"
],
"license": "MIT",
"peerDependencies": {
"@angular/common": "^16.0.0",
"@angular/core": "^16.0.0"
"@angular/core": "^16.0.0",
"three": "^0.148.0 || ^0.149.0 || ^0.150.0 || ^0.151.0 || ^0.152.0"
},
"dependencies": {
"tslib": "^2.3.0"
"ngx-resize": "^2.0.0",
"tslib": "^2.3.0",
"@nx/devkit": "^16.0.0",
"nx": "^16.0.0"
},
"sideEffects": false
"sideEffects": false,
"generators": "./plugin/generators.json",
"schematics": "./plugin/generators.json",
"web-types": "./web-types.json"
}
15 changes: 15 additions & 0 deletions libs/angular-three/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
},
"defaultConfiguration": "production"
},
"package": {
"executor": "nx:run-commands",
"options": {
"commands": [
"node ./tools/scripts/generate-json.mjs",
"pnpm exec nx build angular-three",
"pnpm exec nx build angular-three-plugin"
],
"parallel": false
}
},
"publish": {
"command": "npm publish",
"cwd": "dist/libs/angular-three"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
Expand Down

0 comments on commit ec8f498

Please sign in to comment.