Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelActorComponent + upgrade three 0.126.1 #354

Merged
merged 3 commits into from
Mar 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,024 changes: 3,207 additions & 3,817 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -17,42 +17,42 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^11.1.2",
"@angular/common": "^11.1.2",
"@angular/compiler": "^11.1.2",
"@angular/core": "^11.1.2",
"@angular/forms": "^11.1.2",
"@angular/platform-browser": "^11.1.2",
"@angular/platform-browser-dynamic": "^11.1.2",
"@angular/router": "^11.1.2",
"@angular/animations": "^11.2.6",
"@angular/common": "^11.2.6",
"@angular/compiler": "^11.2.6",
"@angular/core": "^11.2.6",
"@angular/forms": "^11.2.6",
"@angular/platform-browser": "^11.2.6",
"@angular/platform-browser-dynamic": "^11.2.6",
"@angular/router": "^11.2.6",
"core-js": "^3.8.3",
"dagre": "^0.8.5",
"rxjs": "^6.6.6",
"snyk": "^1.463.0",
"three": "^0.125.2",
"snyk": "^1.500.0",
"three": "^0.126.1",
"uuid": "^8.3.2",
"yaml": "^1.10.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1100.7",
"@angular-devkit/core": "^11.1.3",
"@angular/cli": "^11.1.3",
"@angular/compiler-cli": "^11.1.2",
"@angular/language-service": "^11.1.2",
"@angular-devkit/build-angular": "^0.1102.5",
"@angular-devkit/core": "^11.2.5",
"@angular/cli": "^11.2.5",
"@angular/compiler-cli": "^11.2.6",
"@angular/language-service": "^11.2.6",
"@babel/core": "^7.12.13",
"@compodoc/compodoc": "^1.1.11",
"@storybook/addon-actions": "^6.1.17",
"@storybook/addon-docs": "^6.1.17",
"@storybook/addon-essentials": "^6.1.17",
"@storybook/addon-links": "^6.1.17",
"@storybook/addons": "^6.1.17",
"@storybook/addon-links": "^6.1.21",
"@storybook/addons": "^6.1.21",
"@storybook/angular": "^6.1.17",
"@types/dagre": "^0.7.44",
"@types/jasmine": "^3.6.3",
"@types/jasminewd2": "^2.0.8",
"@types/node": "^13.13.41",
"@types/webgl2": "0.0.5",
"@types/webgl2": "0.0.6",
"babel-loader": "^8.2.2",
"codecov": "^3.8.1",
"codelyzer": "^6.0.0",
2 changes: 1 addition & 1 deletion projects/atft/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "atft",
"version": "1.4.13",
"version": "1.4.14",
"description": "Ready-to-use Angular components for Three.js, see https://makimenko.github.io/angular-template-for-threejs/.",
"keywords": [
"threejs",
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import {WorkstationActorComponent} from './server/workstation-actor.component';
import {GridActorComponent} from './layer/grid-actor.component';
import {DagreCompositionComponent, DagreEdgeComponent, DagreLayoutComponent, DagreNodeComponent, DagreYamlParserComponent} from './layout';
import {ActorRepositoryService} from './service';
import {UserActorComponent} from './server';
import {ModelActorComponent} from './server';

@NgModule({
imports: [
@@ -30,7 +30,7 @@ import {UserActorComponent} from './server';
DagreCompositionComponent,
DagreNodeComponent,
DagreYamlParserComponent,
UserActorComponent
ModelActorComponent
],
exports: [
LayerActorComponent,
@@ -45,15 +45,15 @@ import {UserActorComponent} from './server';
DagreCompositionComponent,
DagreNodeComponent,
DagreYamlParserComponent,
UserActorComponent
ModelActorComponent
],
entryComponents: [
ServerStandActorComponent,
ServerBarrelActorComponent,
ServerCompactActorComponent,
ServerIconActorComponent,
WorkstationActorComponent,
UserActorComponent,
ModelActorComponent,
DagreNodeComponent,
DagreEdgeComponent,
DagreCompositionComponent
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ export interface BaseInfo {
export interface Node extends BaseInfo {
type?: string;
icon?: string;
model?: string;
}

export interface Composition extends BaseInfo {
Original file line number Diff line number Diff line change
@@ -103,12 +103,12 @@ export class DagreYamlParserComponent extends AbstractEmptyDirective implements
nodeRef.instance.composition = node.composition;
this.instances.push(nodeRef);

const serverFactory = this.getNodeComponent(node.type);
const serverFactory = this.getNodeComponent((node.model ? 'model' : node.type));
const serverRef = nodeRef.instance.container.createComponent(serverFactory);
serverRef.instance.name = node.name;
serverRef.instance.label = (node.label ? node.label : node.name);
serverRef.instance.icon = node.icon;
serverRef.instance.svgNoHoles = true;
serverRef.instance.model = node.model;

this.instances.push(serverRef);
}
2 changes: 1 addition & 1 deletion projects/atft/src/lib/actor/data-center/server/index.ts
Original file line number Diff line number Diff line change
@@ -4,4 +4,4 @@ export * from './server-stand-actor.component';
export * from './server-compact-actor.component';
export * from './server-icon-actor.component';
export * from './workstation-actor.component';
export * from './user-actor.component';
export * from './model-actor.component';
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);
}


}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {
ServerBarrelActorComponent,
ServerCompactActorComponent,
ServerIconActorComponent,
ServerStandActorComponent, UserActorComponent,
ServerStandActorComponent, ModelActorComponent,
WorkstationActorComponent
} from '../server';

@@ -22,7 +22,7 @@ export class ActorRepositoryService {
this.register('barrel', ServerBarrelActorComponent);
this.register('icon', ServerIconActorComponent);
this.register('workstation', WorkstationActorComponent);
this.register('user', UserActorComponent);
this.register('model', ModelActorComponent);
}

public register(id: string, component: Type<any>): void {
5 changes: 3 additions & 2 deletions projects/atft/src/lib/object/atft-object.module.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {AtftTextModule} from './text/atft-text.module';
import {CommonModule} from '@angular/common';
import {SceneComponent} from './scene.component';
import {ContentProjectionComponent} from './content-projection.component';
import {FontService, IconService, ObjLoaderService, SvgLoaderService} from './loader';
import {FontService, IconService, ModelService, ObjLoaderService, SvgLoaderService} from './loader';


@NgModule({
@@ -37,7 +37,8 @@ import {FontService, IconService, ObjLoaderService, SvgLoaderService} from './lo
FontService,
SvgLoaderService,
IconService,
ObjLoaderService
ObjLoaderService,
ModelService
]
})
export class AtftObjectModule {
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import {provideParent} from '../../util';
import {AbstractObject3D} from '../abstract-object-3d';
import {AbstractModelLoader} from './abstract-model-loader';
import {ObjLoaderService} from './services/obj-loader.service';
import {IconService} from './services';

/**
* Component for employing THREE.OBJLoader to load [Wavefront *.obj files][1].
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;

}
Loading