邵佳豪 3 years ago
parent
commit
caaa96097d
  1. 2
      package.json
  2. 2
      src/app/app-routing.module.ts
  3. 35
      src/app/app.component.spec.ts
  4. 2
      src/app/app.module.ts
  5. 12
      src/app/babylon/controller/status/login-status.ts
  6. 4
      src/app/pages/plan/plan.component.html
  7. 21
      src/app/pages/plan/plan.component.scss
  8. 16
      src/app/pages/plan/plan.component.ts
  9. 99
      src/app/three-dimensional/three-dimensional.module.ts
  10. 3
      src/app/three-dimensional/three-home/three-home.component.html
  11. 7
      src/app/three-dimensional/three-home/three-home.component.scss
  12. 23
      src/app/three-dimensional/three-home/three-home.component.ts
  13. 9
      src/app/ui/tabbar/tabbar.component.ts
  14. 7
      yarn.lock

2
package.json

@ -28,6 +28,7 @@
"@babylonjs/loaders": "^4.2.0", "@babylonjs/loaders": "^4.2.0",
"@babylonjs/materials": "^4.2.0", "@babylonjs/materials": "^4.2.0",
"@types/cesium": "^1.59.5", "@types/cesium": "^1.59.5",
"@types/earcut": "^2.1.1",
"@types/react-dom": "^17.0.10", "@types/react-dom": "^17.0.10",
"@types/swiper": "^5.2.1", "@types/swiper": "^5.2.1",
"angular-calendar": "^0.28.2", "angular-calendar": "^0.28.2",
@ -35,6 +36,7 @@
"cesium": "^1.64.0", "cesium": "^1.64.0",
"class-transformer": "^0.4.0", "class-transformer": "^0.4.0",
"e-ngx-cesium": "^6.3.2", "e-ngx-cesium": "^6.3.2",
"earcut": "^2.2.3",
"echarts": "^4.6.0", "echarts": "^4.6.0",
"firebase": "^7.6.2", "firebase": "^7.6.2",
"install": "^0.13.0", "install": "^0.13.0",

2
src/app/app-routing.module.ts

@ -7,7 +7,6 @@ import { NavigationComponent } from './navigation/navigation.component';
//路由守卫 //路由守卫
import { AuthGuard } from './auth.guard' import { AuthGuard } from './auth.guard'
import { HomeComponent } from './pages/home/home.component'; import { HomeComponent } from './pages/home/home.component';
import { ThreeHomeComponent } from './three-dimensional/three-home/three-home.component';
@ -15,7 +14,6 @@ const routes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' }, { path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent }, //登录页 { path: 'login', component: LoginComponent }, //登录页
{ path: 'register', component: RegisterComponent }, //注册页 { path: 'register', component: RegisterComponent }, //注册页
{ path: 'threeDimensional', component: ThreeHomeComponent }, //三维场景
{ {
path: '', component: HomeComponent, children: [ path: '', component: HomeComponent, children: [
{ path: 'home', loadChildren: () => import('./pages/pages.module').then(m => m.PagesModule) } { path: 'home', loadChildren: () => import('./pages/pages.module').then(m => m.PagesModule) }

35
src/app/app.component.spec.ts

@ -1,35 +0,0 @@
import { TestBed, async } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'anxin119'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('anxin119');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('anxin119 app is running!');
});
});

2
src/app/app.module.ts

@ -16,12 +16,10 @@ import { CacheTokenService } from './service/cache-token.service'
import { TreeService } from './service/tree.service' import { TreeService } from './service/tree.service'
import { CookieService } from 'ngx-cookie-service';//cookie插件 import { CookieService } from 'ngx-cookie-service';//cookie插件
import { CountdownModule } from 'ngx-countdown'; //倒计时插件 import { CountdownModule } from 'ngx-countdown'; //倒计时插件
import { ThreeHomeComponent } from './three-dimensional/three-home/three-home.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
ThreeHomeComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

12
src/app/babylon/controller/status/login-status.ts

@ -1,4 +1,7 @@
import { HttpErrorResponse } from "@angular/common/http"; import { HttpErrorResponse } from "@angular/common/http";
import { Vector3 } from "@babylonjs/core";
import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
import { PolygonMeshBuilder } from "@babylonjs/core/Meshes/polygonMesh";
import { plainToClass } from "class-transformer"; import { plainToClass } from "class-transformer";
import { InstitutionData, NormalData } from "../../model/data/institution/institution-data"; import { InstitutionData, NormalData } from "../../model/data/institution/institution-data";
import { InsitutionDataSimple } from "../../model/data/institution/institution-data-simple"; import { InsitutionDataSimple } from "../../model/data/institution/institution-data-simple";
@ -123,10 +126,19 @@ export class LoginSatus extends StatusBase {
console.log("加载完成", meshes); console.log("加载完成", meshes);
}); });
let l_xy = 100;
let result = [new Vector3(l_xy, l_xy), new Vector3(l_xy, -l_xy), new Vector3(-l_xy, -l_xy), new Vector3(-l_xy, l_xy)];
let poly_tri = new PolygonMeshBuilder("polytri", result, SceneManager.Instance.scene);
let mesh = poly_tri.build(true, 0);
mesh.position.y = -10;
console.log(poly_tri);
//UIManager.open<TopbarWindow>(TopbarWindow); //UIManager.open<TopbarWindow>(TopbarWindow);
// this.openSelectWindow();//可以开启选择、新建单位 // this.openSelectWindow();//可以开启选择、新建单位
} }
//退出状态 //退出状态
onExit() { onExit() {

4
src/app/pages/plan/plan.component.html

@ -1 +1,3 @@
<p>三级预案!</p> <div class="content">
<canvas id="center"></canvas>
</div>

21
src/app/pages/plan/plan.component.scss

@ -1,16 +1,7 @@
nz-select { .content{
margin: 0 8px 10px 0; width: 100%;
width: 120px; height: 100%;
// background-color: red; overflow: hidden;
} position: relative;
canvas{ width: 100%; height: 100%; border: none; outline: none; }
.logo-self {
font-size: 50px;
text-shadow: 0px 0px 6px #8df;
color: white;
font-weight: 600;
}
.font{
font-size: 20px;
// font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
} }

16
src/app/pages/plan/plan.component.ts

@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, ElementRef, OnInit } from '@angular/core';
import { Game } from 'src/app/babylon/game';
@Component({ @Component({
selector: 'app-plan', selector: 'app-plan',
@ -7,9 +8,20 @@ import { Component, OnInit } from '@angular/core';
}) })
export class PlanComponent implements OnInit { export class PlanComponent implements OnInit {
constructor() { } constructor(private element: ElementRef,) { }
static instance: PlanComponent;
public game: Game = new Game();
public canvas: HTMLCanvasElement; //canvas 实例
ngOnInit(): void { ngOnInit(): void {
PlanComponent.instance = this;
this.canvas = this.element.nativeElement.querySelector('#center') as HTMLCanvasElement;
this.game.init(this.canvas);
}
ngOnDestroy(): void { //组件销毁前 销毁canvas
} }
} }

99
src/app/three-dimensional/three-dimensional.module.ts

@ -1,99 +0,0 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { A11yModule } from '@angular/cdk/a11y';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { PortalModule } from '@angular/cdk/portal';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { CdkStepperModule } from '@angular/cdk/stepper';
import { CdkTableModule } from '@angular/cdk/table';
import { CdkTreeModule } from '@angular/cdk/tree';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatBadgeModule } from '@angular/material/badge';
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatStepperModule } from '@angular/material/stepper';
import { MatChipsModule } from '@angular/material/chips';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatDialogModule } from '@angular/material/dialog';
import { MatDividerModule } from '@angular/material/divider';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatListModule } from '@angular/material/list';
import { MatMenuModule } from '@angular/material/menu';
import { MatNativeDateModule, MatRippleModule } from '@angular/material/core';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatRadioModule } from '@angular/material/radio';
import { MatSelectModule } from '@angular/material/select';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatSliderModule } from '@angular/material/slider';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatTreeModule } from '@angular/material/tree';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ThreeHomeComponent } from './three-home/three-home.component';
@NgModule({
declarations: [ThreeHomeComponent],
imports: [
CommonModule,
A11yModule,
DragDropModule,
PortalModule,
ScrollingModule,
CdkStepperModule,
CdkTableModule,
CdkTreeModule,
MatAutocompleteModule,
MatBadgeModule,
MatBottomSheetModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
MatStepperModule,
MatDatepickerModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatNativeDateModule,
MatRippleModule,
MatPaginatorModule,
MatProgressBarModule,
MatProgressSpinnerModule,
MatRadioModule,
MatSelectModule,
MatSidenavModule,
MatSliderModule,
MatSlideToggleModule,
MatSnackBarModule,
MatSortModule,
MatTableModule,
MatTabsModule,
MatToolbarModule,
MatTooltipModule,
MatTreeModule,
FormsModule,
ReactiveFormsModule,
]
})
export class ThreeDimensionalModule { }

3
src/app/three-dimensional/three-home/three-home.component.html

@ -1,3 +0,0 @@
<div class="content">
<canvas id="center"></canvas>
</div>

7
src/app/three-dimensional/three-home/three-home.component.scss

@ -1,7 +0,0 @@
.content{
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
canvas{ width: 100%; height: 100%; border: none; outline: none; }
}

23
src/app/three-dimensional/three-home/three-home.component.ts

@ -1,23 +0,0 @@
import { Component, ElementRef, OnInit } from '@angular/core';
import { Game } from 'src/app/babylon/game';
@Component({
selector: 'app-three-home',
templateUrl: './three-home.component.html',
styleUrls: ['./three-home.component.scss']
})
export class ThreeHomeComponent implements OnInit {
constructor(private element: ElementRef,) { }
static instance: ThreeHomeComponent;
public game: Game = new Game();
public canvas: HTMLCanvasElement; //canvas 实例
ngOnInit(): void {
ThreeHomeComponent.instance = this;
this.canvas = this.element.nativeElement.querySelector('#center') as HTMLCanvasElement;
this.game.init(this.canvas);
}
}

9
src/app/ui/tabbar/tabbar.component.ts

@ -25,11 +25,6 @@ export class TabbarComponent implements OnInit {
},1000); },1000);
} }
//进入 三维场景
initThreeDimensional() {
this.router.navigate(['/threeDimensional'])
}
//获得时间 //获得时间
time:string time:string
getTime() { getTime() {
@ -71,9 +66,7 @@ export class TabbarComponent implements OnInit {
//修改密码 //修改密码
changpsw() { changpsw() {
let dialogRef = this.dialog.open(ChangepasswordComponent, let dialogRef = this.dialog.open(ChangepasswordComponent,{ width: '348px' });
{ width: '348px' });
dialogRef.afterClosed().subscribe(); dialogRef.afterClosed().subscribe();
} }

7
yarn.lock

@ -2683,6 +2683,11 @@
dependencies: dependencies:
cesium "*" cesium "*"
"@types/earcut@^2.1.1":
version "2.1.1"
resolved "https://registry.nlark.com/@types/earcut/download/@types/earcut-2.1.1.tgz#573a0af609f17005c751f6f4ffec49cfe358ea51"
integrity sha1-VzoK9gnxcAXHUfb0/+xJz+NY6lE=
"@types/estree@*": "@types/estree@*":
version "0.0.50" version "0.0.50"
resolved "https://registry.nlark.com/@types/estree/download/@types/estree-0.0.50.tgz#1e0caa9364d3fccd2931c3ed96fdbeaa5d4cca83" resolved "https://registry.nlark.com/@types/estree/download/@types/estree-0.0.50.tgz#1e0caa9364d3fccd2931c3ed96fdbeaa5d4cca83"
@ -4958,7 +4963,7 @@ e-ngx-cesium@^6.3.2:
font-awesome "^4.7.0" font-awesome "^4.7.0"
lodash "^4.17.4" lodash "^4.17.4"
earcut@^2.0.0: earcut@^2.0.0, earcut@^2.2.3:
version "2.2.3" version "2.2.3"
resolved "https://registry.nlark.com/earcut/download/earcut-2.2.3.tgz#d44ced2ff5a18859568e327dd9c7d46b16f55cf4" resolved "https://registry.nlark.com/earcut/download/earcut-2.2.3.tgz#d44ced2ff5a18859568e327dd9c7d46b16f55cf4"
integrity sha1-1EztL/WhiFlWjjJ92cfUaxb1XPQ= integrity sha1-1EztL/WhiFlWjjJ92cfUaxb1XPQ=

Loading…
Cancel
Save