-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #354 from makimenko/re-style2
ModelActorComponent + upgrade three 0.126.1
- Loading branch information
Showing
20 changed files
with
3,402 additions
and
3,939 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
projects/atft/src/lib/actor/data-center/server/model-actor.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {Component, Input, Optional, SkipSelf} from '@angular/core'; | ||
import {provideParent} from '../../../util'; | ||
import {AbstractServerActor} from './abstract-server-actor'; | ||
import {AbstractObject3D, IconService, ModelService} from '../../../object'; | ||
import {RendererService} from '../../../renderer'; | ||
|
||
@Component({ | ||
selector: 'atft-model-actor', | ||
providers: [provideParent(ModelActorComponent)], | ||
template: ` | ||
<atft-empty> | ||
<atft-empty atft-raycaster-group (mouseEnter)="onSelected()" (mouseExit)="onDeselected()" (click)="onClick()"> | ||
<atft-obj-loader *ngIf="modelPath" [model]="modelPath"> | ||
</atft-obj-loader> | ||
</atft-empty> | ||
<atft-text-mesh [text]="label" [size]="2" [bevelEnabled]="false" height="0" [centered]="true" | ||
material="basic" materialColor="0xDADADA" [translateY]="-11" [translateZ]="0.2"> | ||
</atft-text-mesh> | ||
<atft-frame-mesh *ngIf="showFrame" [thickness]="1" [sizeX]="15" [sizeY]="15" [translateZ]="0.1" material="basic" | ||
[materialColor]="color"> | ||
</atft-frame-mesh> | ||
</atft-empty> | ||
` | ||
}) | ||
export class ModelActorComponent extends AbstractServerActor { | ||
|
||
@Input() | ||
set model(model: string) { | ||
const iconProvider = this.modelService.getSource(model); | ||
this.modelPath = iconProvider.url; | ||
} | ||
|
||
get model(): string { | ||
return this.model; | ||
} | ||
|
||
public modelPath: string; | ||
|
||
constructor( | ||
protected rendererService: RendererService, | ||
@SkipSelf() @Optional() protected parent: AbstractObject3D<any>, | ||
protected modelService: ModelService | ||
) { | ||
super(rendererService, parent); | ||
} | ||
|
||
|
||
} |
30 changes: 0 additions & 30 deletions
30
projects/atft/src/lib/actor/data-center/server/user-actor.component.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
projects/atft/src/lib/object/loader/services/abstract-asset.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import {Injectable} from '@angular/core'; | ||
|
||
const SEPARATOR = ':'; | ||
const REPLACE_SYMBOL = '?'; | ||
|
||
export interface BaseAssetSource { | ||
url: string; | ||
} | ||
|
||
@Injectable() | ||
export abstract class AbstractAssetService<T extends BaseAssetSource> { | ||
|
||
protected providers: Map<string, T> = new Map(); | ||
abstract defaultProvider; | ||
|
||
constructor() { | ||
this.init(); | ||
} | ||
|
||
protected abstract init(); | ||
|
||
public registerProvider(key: string, source: T) { | ||
this.providers.set(key, source); | ||
} | ||
|
||
public setDefaultProvider(key: string) { | ||
this.defaultProvider = key; | ||
} | ||
|
||
public getSource(icon: string): T { | ||
if (icon) { | ||
if (icon.indexOf(SEPARATOR) > 0) { | ||
const args = icon.split(SEPARATOR); | ||
return this.getSourceByNamespace(args[0], args[1]); | ||
} else { | ||
return this.getSourceByNamespace(this.defaultProvider, icon); | ||
} | ||
} else { | ||
return this.defaultIfNotFound(icon); | ||
} | ||
} | ||
|
||
public getSourceByNamespace(namespace: string, icon: string): T { | ||
// console.log('AbstractAssetService.getUrlByNamespace', namespace + ', ' + icon); | ||
const provider = this.providers.get(namespace); | ||
if (!provider) { | ||
console.warn('Icon provider not found', provider); | ||
return this.defaultIfNotFound(icon); | ||
} | ||
const finalUrl = provider.url.replace(REPLACE_SYMBOL, icon); | ||
// console.log('AbstractAssetService.getUrlByNamespace url', svgUrl); | ||
return this.getFinalResult(finalUrl, provider); | ||
} | ||
|
||
public abstract getFinalResult(finalUrl: string, provider: T): T; | ||
|
||
public abstract defaultIfNotFound(icon: string): T; | ||
|
||
} |
Oops, something went wrong.