Browse Source

注册组件

dev
陈鹏飞 4 years ago
parent
commit
22bad743b7
  1. 4
      src/app/app.module.ts
  2. 9
      src/app/three-dimensional/three-home/three-home.component.ts

4
src/app/app.module.ts

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

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

@ -1,4 +1,5 @@
import { Component, ElementRef, OnInit } from '@angular/core';
import { Game } from 'src/app/babylon/game';
@Component({
selector: 'app-three-home',
@ -10,13 +11,13 @@ export class ThreeHomeComponent implements OnInit {
constructor(private element: ElementRef,) { }
static instance: ThreeHomeComponent;
//public game: Game = new Game();
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);
// ThreeHomeComponent.instance = this;
// this.canvas = this.element.nativeElement.querySelector('#center') as HTMLCanvasElement;
// this.game.init(this.canvas);
}
}

Loading…
Cancel
Save