STLLoader class
Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
Supports both binary and ASCII encoded files, with automatic detection of type.
The loader returns a non-indexed buffer geometry.
Limitations: Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL). There is perhaps some question as to how valid it is to always assume little-endian-ness. ASCII decoding assumes file is UTF-8.
Usage: const loader = new STLLoader(); loader.load( './models/stl/slotted_disk.stl', function ( geometry ) { scene.add( new THREE.Mesh( geometry ) ); });
For binary STLs geometry might contain colors for vertices. To use it: // use the same code to load STL as above if (geometry.hasColors) { material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: true }); } else { .... } const mesh = new THREE.Mesh( geometry, material );
For ASCII STLs containing multiple solids, each solid is assigned to a different group. Groups can be used to assign a different color by defining an array of materials with the same length of geometry.groups and passing it to the Mesh constructor:
const mesh = new THREE.Mesh( geometry, material );
For example:
const materials = []; const nGeometryGroups = geometry.groups.length;
const colorMap = ...; // Some logic to index colors.
for (let i = 0; i < nGeometryGroups; i++) {
const material = new THREE.MeshPhongMaterial({
color: colorMap[i],
wireframe: false
});
}
materials.push(material); const mesh = new THREE.Mesh(geometry, materials);
Constructors
- STLLoader([dynamic manager])
Properties
- crossOrigin ↔ String
-
getter/setter pairinherited
- flipY ↔ bool
-
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- manager ↔ LoadingManager
-
getter/setter pairinherited
- mimeType ↔ String
-
getter/setter pairinherited
- path ↔ String
-
getter/setter pairinherited
-
requestHeader
↔ Map<
String, dynamic> -
getter/setter pairinherited
- resourcePath ↔ String?
-
getter/setter pairinherited
- responseType ↔ String
-
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- withCredentials ↔ bool
-
getter/setter pairinherited
Methods
-
load(
dynamic url, Function onLoad, [Function? onProgress, Function? onError]) → void -
override
-
loadAsync(
dynamic url) → Future -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
dynamic data, [String? path, Function? onLoad, Function? onError]) → BufferGeometry -
override
-
parseASCII(
String data) → BufferGeometry -
parseBinary(
Uint8List data) → BufferGeometry -
setCrossOrigin(
String crossOrigin) → Loader -
inherited
-
setPath(
String path) → Loader -
inherited
-
setRequestHeader(
Map< String, dynamic> requestHeader) → Loader -
inherited
-
setResourcePath(
String? resourcePath) → Loader -
inherited
-
setWithCredentials(
bool value) → Loader -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited