-
-
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 #381 from makimenko/stl-loader
#375: STL Loader
- Loading branch information
Showing
6 changed files
with
72 additions
and
469 deletions.
There are no files selected for viewing
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
48 changes: 48 additions & 0 deletions
48
projects/atft/src/lib/object/loader/stl-loader.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,48 @@ | ||
import {Component, Input, Optional, SkipSelf} from '@angular/core'; | ||
|
||
import * as THREE from 'three'; | ||
import {RendererService} from '../../renderer/renderer.service'; | ||
import {appliedMaterial, provideParent} from '../../util'; | ||
import {AbstractObject3D} from '../abstract-object-3d'; | ||
import {AbstractModelLoader} from './abstract-model-loader'; | ||
import {STLLoader} from 'three/examples/jsm/loaders/STLLoader'; | ||
|
||
@Component({ | ||
selector: 'atft-stl-loader', | ||
providers: [provideParent(StlLoaderComponent)], | ||
template: '<ng-content></ng-content>' | ||
}) | ||
export class StlLoaderComponent extends AbstractModelLoader { | ||
private loader = new STLLoader(); | ||
|
||
@Input() | ||
material: string; | ||
|
||
@Input() | ||
materialColor: string | number = '#FFFFFF'; | ||
|
||
@Input() | ||
depthWrite = true; | ||
|
||
constructor( | ||
protected rendererService: RendererService, | ||
@SkipSelf() @Optional() protected parent: AbstractObject3D<any> | ||
) { | ||
super(rendererService, parent); | ||
} | ||
|
||
protected async loadLazyObject() { | ||
// console.log('StlLoaderComponent.loadLazyObject'); | ||
return new Promise<THREE.Object3D>((resolve, reject) => { | ||
this.loader.load(this.model, geometry => { | ||
const material = appliedMaterial(this.materialColor, this.material, this.depthWrite); | ||
const mesh = new THREE.Mesh(geometry, material); | ||
resolve(mesh); | ||
}, | ||
undefined, | ||
reject | ||
); | ||
}); | ||
} | ||
|
||
} |
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