projects/atft/src/lib/actor/ux/loader/loader-actor.component.ts
AfterViewInit
OnChanges
OnDestroy
providers |
provideParent(LoaderActorComponent)
|
selector | atft-loader-actor |
Properties |
Methods |
|
Inputs |
Outputs |
constructor(rendererService: RendererService, parent: AbstractObject3D<any>, animationService: AnimationService)
|
||||||||||||
Parameters :
|
animate | |
Type : boolean
|
|
Default value : true
|
|
materialColor | |
Type : string | number
|
|
Default value : '#5DADE2'
|
|
layer | |
Type : number
|
|
Default value : 0
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:42
|
name | |
Type : string
|
|
Default value : uuidv4()
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:40
|
rotateX | |
Type : number
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:24
|
|
Rotation in Euler angles (radians) with order X, Y, Z. |
rotateY | |
Type : number
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:25
|
rotateZ | |
Type : number
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:26
|
scaleX | |
Type : number
|
|
Default value : 1
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:36
|
scaleY | |
Type : number
|
|
Default value : 1
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:37
|
scaleZ | |
Type : number
|
|
Default value : 1
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:38
|
translateX | |
Type : number
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:31
|
|
Translate the geometry. This is typically done as a one time operation, and not during a loop. |
translateY | |
Type : number
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:32
|
translateZ | |
Type : number
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:33
|
changed | |
Type : EventEmitter
|
|
Inherited from
AbstractObject3D
|
|
Defined in
AbstractObject3D:44
|
Protected getMaterial |
getMaterial()
|
Returns :
THREE.Material
|
Protected init |
init()
|
Returns :
void
|
Public ngAfterViewInit |
ngAfterViewInit()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:39
|
Returns :
void
|
Public ngOnDestroy |
ngOnDestroy()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:81
|
Returns :
void
|
Protected start |
start()
|
Returns :
void
|
Public stop |
stop()
|
Returns :
void
|
Protected updateAnimation |
updateAnimation()
|
Returns :
void
|
Protected newObject3DInstance |
newObject3DInstance()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:21
|
Returns :
THREE.Object3D
|
Public addChild | ||||||
addChild(object: AbstractObject3D<any>)
|
||||||
Inherited from
AbstractObject3D
|
||||||
Defined in
AbstractObject3D:143
|
||||||
Parameters :
Returns :
void
|
Protected afterInit |
afterInit()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:156
|
Returns :
void
|
Public applyRotation |
applyRotation()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:118
|
Returns :
void
|
Public applyScale |
applyScale()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:135
|
Returns :
void
|
Public applyTranslation |
applyTranslation()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:127
|
Returns :
void
|
Public findByName | ||||||
findByName(name: string)
|
||||||
Inherited from
AbstractObject3D
|
||||||
Defined in
AbstractObject3D:185
|
||||||
Parameters :
Returns :
any
|
Public getChildren |
getChildren()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:202
|
Returns :
Array<AbstractObject3D<any>>
|
Public getObject |
getObject()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:175
|
Returns :
T
|
Public ngOnChanges | ||||||
ngOnChanges(changes: SimpleChanges)
|
||||||
Inherited from
AbstractObject3D
|
||||||
Defined in
AbstractObject3D:57
|
||||||
Parameters :
Returns :
void
|
Public ngOnInit |
ngOnInit()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:97
|
Returns :
void
|
Protected recursionByName | |||||||||
recursionByName(currentNode: AbstractObject3D<any>, name: string)
|
|||||||||
Inherited from
AbstractObject3D
|
|||||||||
Defined in
AbstractObject3D:192
|
|||||||||
Parameters :
Returns :
any
|
Public removeChild | ||||||
removeChild(object: AbstractObject3D<any>)
|
||||||
Inherited from
AbstractObject3D
|
||||||
Defined in
AbstractObject3D:160
|
||||||
Parameters :
Returns :
void
|
Public removeChildByName | ||||||
removeChildByName(name: string)
|
||||||
Inherited from
AbstractObject3D
|
||||||
Defined in
AbstractObject3D:206
|
||||||
Parameters :
Returns :
void
|
Public updateParent |
updateParent()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:111
|
Returns :
void
|
Protected animation |
Type : Subscription
|
Private i |
Type : number
|
Default value : 0
|
Private ring1 |
Type : THREE.Mesh
|
Private ring2 |
Type : THREE.Mesh
|
Private ring3 |
Type : THREE.Mesh
|
Private subscribed |
Default value : false
|
Protected childlren |
Type : Array<AbstractObject3D<any>>
|
Default value : []
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:46
|
Protected object |
Type : T
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:48
|
import { AfterViewInit, Component, Input, OnChanges, OnDestroy, Optional, SkipSelf } from '@angular/core';
import { appliedMaterial, provideParent } from '../../../util';
import { EmptyComponent } from '../../../object/helper';
import { AnimationService } from '../../../animation';
import { RendererService } from '../../../renderer';
import { AbstractObject3D } from '../../../object';
import * as THREE from 'three';
import { Subscription } from 'rxjs';
@Component({
selector: 'atft-loader-actor',
providers: [provideParent(LoaderActorComponent)],
template: ``
})
export class LoaderActorComponent extends EmptyComponent implements AfterViewInit, OnChanges, OnDestroy {
@Input()
animate = true;
@Input()
materialColor: string | number = '#5DADE2';
private ring1!: THREE.Mesh;
private ring2!: THREE.Mesh;
private ring3!: THREE.Mesh;
private subscribed = false;
private i = 0;
protected animation!: Subscription;
constructor(
protected override rendererService: RendererService,
@SkipSelf() @Optional() protected override parent: AbstractObject3D<any>,
protected animationService: AnimationService
) {
super(rendererService, parent);
}
public override ngAfterViewInit() {
super.ngAfterViewInit();
// console.log('LoaderActorComponent.ngAfterViewInit');
this.init();
this.start();
}
protected getMaterial(): THREE.Material {
return appliedMaterial(this.materialColor, 'basic');
}
protected init() {
// console.log('LoaderActorComponent.init');
const geometry = new THREE.RingGeometry(0.85, 1, 64, 1, 0, Math.PI * 1.8);
const material = this.getMaterial();
this.ring1 = new THREE.Mesh(geometry, material);
this.ring1.scale.set(70, 70, 1);
this.object.add(this.ring1);
this.ring2 = new THREE.Mesh(geometry, material);
this.ring2.scale.set(60, 60, 1);
this.object.add(this.ring2);
this.ring3 = new THREE.Mesh(geometry, material);
this.ring3.scale.set(50, 50, 1);
this.object.add(this.ring3);
}
protected start() {
// console.log('LoaderActorComponent.updateText');
if (this.animate) {
// console.log('LoaderActorComponent.animate init');
this.updateAnimation = this.updateAnimation.bind(this);
this.animation = this.animationService.animate.subscribe(this.updateAnimation);
this.subscribed = true;
this.animationService.start();
}
}
public override ngOnDestroy() {
// console.log('LoaderActorComponent.ngOnDestroy');
super.ngOnDestroy();
this.stop();
}
protected updateAnimation() {
if (this.subscribed) {
// console.log('LoaderActorComponent.updateAnimation');
this.i++;
this.ring1.scale.set(70 + (Math.sin(this.i / 20) * 10) + 12, 70 + (Math.sin(this.i / 20) * 10) + 12, 1);
this.ring1.rotateZ(Math.sin(this.i / 100) / 5);
this.ring2.rotateZ(Math.cos(this.i / 70) / 10);
this.ring3.rotateZ(Math.sin(this.i / 50) / 20);
}
}
public stop() {
if (this.subscribed) {
// console.log('LoaderActorComponent.done');
this.subscribed = false;
this.i = 0;
this.animation?.unsubscribe();
}
}
}