You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import { Component, ElementRef, OnInit } from '@angular/core';
|
|
|
|
import { Game } from 'src/app/babylon/game';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-plan',
|
|
|
|
templateUrl: './plan.component.html',
|
|
|
|
styleUrls: ['./plan.component.scss']
|
|
|
|
})
|
|
|
|
export class PlanComponent implements OnInit {
|
|
|
|
|
|
|
|
constructor(private element: ElementRef,) { }
|
|
|
|
|
|
|
|
static instance: PlanComponent;
|
|
|
|
public game: Game = new Game();
|
|
|
|
public canvas: HTMLCanvasElement; //canvas 实例
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
PlanComponent.instance = this;
|
|
|
|
this.canvas = this.element.nativeElement.querySelector('#center') as HTMLCanvasElement;
|
|
|
|
this.game.init(this.canvas);
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy(): void { //组件销毁前 销毁canvas
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|