projects/atft/src/lib/object/mesh/abstract-mesh-3d.ts
OnChanges
Properties |
Methods |
|
Inputs |
Outputs |
castShadow | |
Type : boolean
|
|
Default value : true
|
|
depthWrite | |
Type : boolean
|
|
Default value : true
|
|
material | |
Type : string
|
|
materialColor | |
Type : string | number
|
|
Default value : '#5DADE2'
|
|
receiveShadow | |
Type : boolean
|
|
Default value : true
|
|
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
|
Public applyMaterial |
applyMaterial()
|
Returns :
void
|
Protected applyShadowProps | ||||||
applyShadowProps(mesh: THREE.Mesh)
|
||||||
Parameters :
Returns :
void
|
Protected getMaterial |
getMaterial()
|
Returns :
THREE.Material
|
Public ngOnChanges | ||||||
ngOnChanges(changes: SimpleChanges)
|
||||||
Inherited from
AbstractObject3D
|
||||||
Defined in
AbstractObject3D:33
|
||||||
Parameters :
Returns :
void
|
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
|
Protected Abstract newObject3DInstance |
newObject3DInstance()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:179
|
Returns :
T
|
Public ngAfterViewInit |
ngAfterViewInit()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:181
|
Returns :
void
|
Public ngOnDestroy |
ngOnDestroy()
|
Inherited from
AbstractObject3D
|
Defined in
AbstractObject3D:86
|
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 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 { Input, OnChanges, SimpleChanges, Directive } from '@angular/core';
import * as THREE from 'three';
import {AbstractObject3D} from '../abstract-object-3d';
import {appliedMaterial} from '../../util';
@Directive()
export abstract class AbstractMesh extends AbstractObject3D<THREE.Mesh> implements OnChanges {
@Input()
material!: string;
@Input()
materialColor: string | number = '#5DADE2';
@Input()
castShadow = true;
@Input()
receiveShadow = true;
@Input()
depthWrite = true;
protected getMaterial(): THREE.Material {
return appliedMaterial(this.materialColor, this.material, this.depthWrite);
}
protected applyShadowProps(mesh: THREE.Mesh) {
mesh.castShadow = this.castShadow;
mesh.receiveShadow = this.receiveShadow;
}
public override ngOnChanges(changes: SimpleChanges) {
super.ngOnChanges(changes);
if (!this.getObject()) {
return;
}
let mustRerender = false;
if (['material', 'materialColor', 'depthWrite'].some(propName => propName in changes)) {
this.applyMaterial();
mustRerender = true;
}
if (mustRerender) {
this.rendererService.render();
}
}
public applyMaterial() {
this.getObject().material = this.getMaterial();
}
}