new File()
Provides tools and methods for reading and saving a range of model file formats.
Classes
Members
-
:boolean
fsAPISupported <static>
-
Stores whether or not the File System Access API is supported.
Type
- boolean
Methods
-
exportGeometry(object, exporter) <static>
-
Exports a
THREE.Object3Dand its children to a local file.This method exports the geometry of a given object/group to a file in the specified format using the THREE exporters. Many of these exporters will include empty objects in the output and do not respect the
drawRangeproperty of geometries. As the geometry model used in the framework is highly dynamic, it will often contain empty objects (such as the transparent mesh on a roof level with no skylights) and makes full use of draw ranges.To accommodate this, a temporary model hierarchy is created that mirrors the given object/group hierarchy, but includes only meshes and object that have renderable content and converts any dynamic
PD.PolyMeshinstances to staticTHREE.Meshinstances. These temporary objects are never added to the scene and thus do not use any resources on the GPU, so will be garbage collected at some point after the export is complete.Parameters:
Name Type Description objectTHREE.Object3D The object/group to export.
exporterPD.File.ExportOptions The export settings configuration object.
Returns:
Returns true if the export was successful.
- Type
- boolean
-
fileOpen( [config]) <async, static>
-
Attempts to open a file from disk.
This method first checks if the File System Access API is supported and uses it if available. If not supported, or a security error occurs, it falls back to a legacy
<input type="file">method.Parameters:
Name Type Argument Description configObject <optional>
An optional configuration object for opening the file(s).
Properties of
config:Name Type Argument Description idstring <optional>
The unique identifier for the file picker that the system can use to remember selected folders.
descriptionstring <optional>
The description to display alongside the file-type selector.
extensionsArray.<string> <optional>
The file extension(s) to display in the file-type selector.
mimeTypeArray.<string> <optional>
The MIME type of the file(s) to open, defaults to ["/"].
startInstring <optional>
The well known directory to start in ('desktop'|'documents'|'downloads'|'music'|'pictures'|'videos'), defaults to an empty string.
options.multipleboolean <optional>
Whether or not to allow multiple file selection, defaults to false.
Returns:
Returns a promise that resolves to the selected file or file(s), or
nullif the user cancels.- Type
- Promise.<(File|Array.<File>|null)>
-
fileSave(blobOrPromiseBlobOrResponse [, config] [, existingHandle] [, throwIfExistingHandleNotGood] [, filePickerShown]) <async, static>
-
Attempts to save a file to disk.
This method first checks if the File System Access API is supported and uses it if available. If not supported, or a security error occurs, it falls back to a legacy
<input type="file">method.Parameters:
Name Type Argument Description blobOrPromiseBlobOrResponseBlob | Promise.<Blob> | Response The
Blob,Promiseresolving to aBlob, orResponseto save.configObject | Array.<Object> <optional>
An optional configuration object.
Properties of
config:Name Type Argument Description idstring <optional>
The unique identifier for the file picker that the system can use to remember selected folders.
descriptionstring <optional>
The description to display alongside the file-type selector.
extensionsArray.<string> <optional>
The file extension(s) to display in the file-type selector.
mimeTypeArray.<string> <optional>
The MIME type of the file(s) to open, defaults to ["/"].
startInstring <optional>
The well known directory to start in ('desktop'|'documents'|'downloads'|'music'|'pictures'|'videos'), defaults to an empty string.
fileNamestring <optional>
The default name of the file to save/download, defaults to 'Untitled'.
existingHandleFileHandle <optional>
An existing file handle to save the data to, defaults to
null.throwIfExistingHandleNotGoodboolean <optional>
Whether or not to throw an error if the existing file handle is not valid, defaults to false.
filePickerShownfunction <optional>
A callback function to call when the file picker is shown, defaults to
null.Returns:
Returns a promise that resolves to a file handle or
nullif the user cancels.- Type
- Promise.<(FileHandle|null)>
-
loadFile(file, manager [, filesMap]) <static>
-
Imports a single geometry file and add its contents to the model.
Parameters:
Name Type Argument Description fileFile A file object to load.
managerTHREE.LoadingManager The loading manager to use for loading the file.
filesMapMap <optional>
A map of file names to File objects.
Returns:
Returns an object or group containing the loaded geometry.
- Type
- THREE.Object3D
-
loadFiles(files [, filesMap]) <async, static>
-
Load one or more model geometry files.
Parameters:
Name Type Argument Description filesArray.<File> An array of File objects to load.
filesMapMap <optional>
A map of file names to File objects. This is used by a file manager to load assets that are referenced by model files and included in the given array of files, and to avoid loading the same file multiple times. If not provided, a new map will be created from the files array. A map should contain file names as keys and File objects as values. This allows the loading manager to resolve file URLs correctly.
Returns:
Returns true if files were loaded, false if the files array is empty.
- Type
- boolean
-
parseCityJSON(json, element [, options]) <static>
-
Imports a CityJSON file into the given element shell.
Parameters:
Name Type Argument Description jsonobject The JSON data object.
elementBIM.Element The element to add the geometry to.
optionsobject <optional>
Optional configuration callbacks and mesh options.
Properties of
options:Name Type Argument Description progressIncrementnumber <optional>
An optional fractional progress rate for callbacks.
callbackProgressfunction <optional>
An optional function to call after each progress increment.
callbackCompletefunction <optional>
An optional function to call when parsing is complete.
debugboolean <optional>
An optional flag to show parsing time in the console.
Throws:
-
Occurs if the file is empty or invalid.
- Type
- TypeError
Returns:
Returns true recognizable geometry was added to the shell.
- Type
- boolean
-
-
parseGBXML(gbxml [, options]) <static>
-
Creates a new project from an imported gbXML file.
Parameters:
Name Type Argument Description gbxmlobject A JSON object representation of the XML data.
optionsobject <optional>
Optional configuration callbacks and mesh options.
Properties of
options:Name Type Argument Description progressIncrementnumber <optional>
An optional fractional progress rate for callbacks.
callbackProgressfunction <optional>
An optional function to call after each progress increment.
callbackCompletefunction <optional>
An optional function to call when parsing is complete.
debugboolean <optional>
An optional flag to show parsing time in the console.
Throws:
-
Occurs if the file is empty or invalid.
- Type
- TypeError
Returns:
Returns a new BIM.Project, or null if the gbXML is invalid.
- Type
- BIM.Project
-
-
parseJSON(json [, manager]) <async, static>
-
Handles loading JSON data containing multiple objects and meshes.
Parameters:
Name Type Argument Description jsonObject A hierarchical JSON object.
managerTHREE.LoadingManager <optional>
A loading manager to use for loading asset files.
Returns:
A promise that resolves when the JSON file has been processed.
- Type
- Promise.<void>
-
parseMOD(reader [, options]) <static>
-
Imports an Ecotect .MOD file as a
BIM.Element.Compositeelement.Parameters:
Name Type Argument Description readerobject A container to avoid large string copies.
Properties of
reader:Name Type Description resultobject The textual contents of the Ecotect .MOD file.
optionsobject <optional>
Optional configuration callbacks and mesh options.
Properties of
options:Name Type Argument Description groupByfunction <optional>
A store for materials loaded from associated
mtllibfiles.progressIncrementnumber <optional>
An optional fractional progress rate for callbacks.
callbackProgressfunction <optional>
An optional function to call after each progress increment.
callbackCompletefunction <optional>
An optional function to call when parsing is complete.
fileInfoobject <optional>
The file information associated with the selected .MOD file.
debugboolean <optional>
An optional flag to show parsing time in the console.
Throws:
-
Occurs if the file is empty or invalid.
- Type
- TypeError
Returns:
Returns composite element containing all elements in the file.
-
-
parseOBJ(reader [, options]) <static>
-
Imports a WaveFront .OBJ file as one or more BRep shapes.
Parameters:
Name Type Argument Description readerobject A container to avoid large string copies.
Properties of
reader:Name Type Description resultobject The textual contents of the Wavefront OBJ file.
optionsobject <optional>
Optional configuration callbacks and mesh options.
Properties of
options:Name Type Argument Description materialsfunction <optional>
A store for materials loaded from associated
mtllibfiles.progressIncrementnumber <optional>
An optional fractional progress rate for callbacks.
callbackProgressfunction <optional>
An optional function to call after each progress increment.
callbackCompletefunction <optional>
An optional function to call when parsing is complete.
swapYZboolean <optional>
An optional flag to swap the Y and Z axis in the model, defaults to false.
flipYboolean <optional>
An optional flag to reverse the Y axis in the model, defaults to false.
debugboolean <optional>
An optional flag to show parsing time in the console.
Throws:
-
Occurs if the file is empty or invalid.
- Type
- TypeError
Returns:
Returns a Map with object names and breps parsed from the file.
- Type
- Map
-
-
parseZIP(container) <async, static>
-
Handles loading a ZIP file containing multiple 3D model files.
Parameters:
Name Type Description containerObject A container object holding the ZIP file data.
Properties of
container:Name Type Description resultArrayBuffer The contents of the ZIP file as an ArrayBuffer.
Returns:
A promise that resolves when the ZIP file has been processed.
- Type
- Promise.<void>
-
saveAs3DM(object, filename) <async, static>
-
Saves a 3D object as a Rhino 3DM file.
When the object has been converted to a 3DM object URL, this function calls the
PD.GlobalActions.saveObjectURLToClientmethod to save the data to the local file system. The file will be saved with the given filename suffixed with the current date/time and the.3dmfile extension.Parameters:
Name Type Description objectTHREE.Object3D The root 3D object to save.
filenamestring The name of the file to save.
-
saveAs3MF(object, filename) <async, static>
-
Saves a 3D object as a 3MF file.
When the object has been converted to a 3MF object URL, this function calls the
PD.GlobalActions.saveObjectURLToClientmethod to save the data to the local file system. The file will be saved with the given filename suffixed with the current date/time and the.3mffile extension.Parameters:
Name Type Description objectTHREE.Object3D The root 3D object to save.
filenamestring The name of the file to save.
-
saveAsGLTF(object, filename [, binary]) <async, static>
-
Saves a THREE 3D object as a GLB/GLTF file.
When the object has been converted to a GLB/GLTF object URL, this function calls the
PD.GlobalActions.saveObjectURLToClientmethod to save the data to the local file system. The file will be saved with the given filename suffixed with the current date/time and either the.glbor.gltffile extension, depending on the value of thebinaryargument.Parameters:
Name Type Argument Description objectTHREE.Object3D The root 3D object to save.
filenamestring The name of the file to save.
binaryboolean <optional>
Whether to save as binary GLB instead of ASCII GLTF, defaults to true.
-
saveAsOBJ(object, filename) <async, static>
-
Saves a 3D object as a Wavefront Object file.
When the object has been converted to an OBJ object URL, this function calls the
PD.GlobalActions.saveObjectURLToClientmethod to save the data to the local file system. The file will be saved with the given filename suffixed with the current date/time and the.objfile extension.Parameters:
Name Type Description objectTHREE.Object3D The root 3D object to save.
filenamestring The name of the file to save.
-
saveAsPLY(object, filename) <async, static>
-
Saves a 3D object as a Stanford Triangle Format file.
When the object has been converted to a PLY object URL, this function calls the
PD.GlobalActions.saveObjectURLToClientmethod to save the data to the local file system. The file will be saved with the given filename suffixed with the current date/time and the.plyfile extension.Parameters:
Name Type Description objectTHREE.Object3D The root 3D object to save.
filenamestring The name of the file to save.
-
saveAsSTL(object, filename) <async, static>
-
Saves a 3D object as a Stereolithography file.
When the object has been converted to a STL object URL, this function calls the
PD.GlobalActions.saveObjectURLToClientmethod to save the data to the local file system. The file will be saved with the given filename suffixed with the current date/time and the.stlfile extension.Parameters:
Name Type Description objectTHREE.Object3D The root 3D object to save.
filenamestring The name of the file to save.
-
saveAsUSDZ(object, filename) <async, static>
-
Saves a 3D object as a USDZ file.
When the object has been converted to a USDZ object URL, this function calls the
PD.GlobalActions.saveObjectURLToClientmethod to save the data to the local file system. The file will be saved with the given filename suffixed with the current date/time and the.usdzfile extension.Parameters:
Name Type Description objectTHREE.Object3D The root 3D object to save.
filenamestring The name of the file to save.