| import {EXRExporter2, SimpleJSONExporter, SimpleTextExporter} from './export' | import {EXRExporter2, SimpleJSONExporter, SimpleTextExporter} from './export' | ||||
| import {IRenderTarget} from '../rendering' | import {IRenderTarget} from '../rendering' | ||||
| /** | |||||
| * Asset Exporter | |||||
| * | |||||
| * Utility class to export objects, materials, textures, render targets, etc. | |||||
| * Used in {@link AssetManager} to export assets. | |||||
| * @category Asset Manager | |||||
| */ | |||||
| export class AssetExporter extends EventDispatcher<BaseEvent, 'exporterCreate' | 'exportFile'> implements IAssetExporter { | export class AssetExporter extends EventDispatcher<BaseEvent, 'exporterCreate' | 'exportFile'> implements IAssetExporter { | ||||
| readonly exporters: IExporter[] = [ | readonly exporters: IExporter[] = [ | ||||
| {ctor: ()=>new SimpleJSONExporter(), ext: ['json']}, | {ctor: ()=>new SimpleJSONExporter(), ext: ['json']}, |
| url?: string, loaded?: number, total?: number | url?: string, loaded?: number, total?: number | ||||
| loader?: ILoader, | loader?: ILoader, | ||||
| } | } | ||||
| /** | |||||
| * Asset Importer | |||||
| * | |||||
| * Utility class to import assets from local files, blobs, urls, etc. | |||||
| * Used in {@link AssetManager} to import assets. | |||||
| * Acts as a wrapper over three.js LoadingManager and adds support for dynamically loading loaders, caching assets, better event dispatching and file tracking. | |||||
| * @category Asset Manager | |||||
| */ | |||||
| export class AssetImporter extends EventDispatcher<IAssetImporterEvent, IAssetImporterEventTypes> implements IAssetImporter { | export class AssetImporter extends EventDispatcher<IAssetImporterEvent, IAssetImporterEventTypes> implements IAssetImporter { | ||||
| private _loadingManager: LoadingManager | private _loadingManager: LoadingManager | ||||
| this._loadingManager = new LoadingManager(this._onLoad, this._onProgress, this._onError) | this._loadingManager = new LoadingManager(this._onLoad, this._onProgress, this._onError) | ||||
| this._loadingManager.onStart = this._onStart | this._loadingManager.onStart = this._onStart | ||||
| this._loadingManager.setURLModifier(this._urlModifier) | this._loadingManager.setURLModifier(this._urlModifier) | ||||
| // addDracoLoader() | |||||
| } | } | ||||
| get loadingManager(): LoadingManager { | get loadingManager(): LoadingManager { |
| export type AddRawOptions = ProcessRawOptions & AddAssetOptions | export type AddRawOptions = ProcessRawOptions & AddAssetOptions | ||||
| /** | |||||
| * Asset Manager | |||||
| * | |||||
| * Utility class to manage import, export, and material management. | |||||
| * @category Asset Manager | |||||
| */ | |||||
| export class AssetManager extends EventDispatcher<BaseEvent&{data: ImportResult}, 'loadAsset'> { | export class AssetManager extends EventDispatcher<BaseEvent&{data: ImportResult}, 'loadAsset'> { | ||||
| static readonly PluginType = 'AssetManager' | static readonly PluginType = 'AssetManager' | ||||
| readonly viewer: ThreeViewer | readonly viewer: ThreeViewer |
| /** | /** | ||||
| * Export and bundle the viewer config (scene settings). | * Export and bundle the viewer config (scene settings). | ||||
| * only works for rootSceneModelRoot and supported only in GLTFExporter2 {@link GLTFExporter2Options.viewerConfig} | * only works for rootSceneModelRoot and supported only in GLTFExporter2 {@link GLTFExporter2Options.viewerConfig} | ||||
| * {@default true} | |||||
| * @default true | |||||
| */ | */ | ||||
| viewerConfig?: boolean, | viewerConfig?: boolean, | ||||
| import {MaterialExtension} from '../materials' | import {MaterialExtension} from '../materials' | ||||
| import {generateUUID, isInScene} from '../three' | import {generateUUID, isInScene} from '../three' | ||||
| /** | |||||
| * Material Manager | |||||
| * Utility class to manage materials. | |||||
| * Maintains a library of materials and material templates that can be used to manage or create new materials. | |||||
| * Used in {@link AssetManager} to manage materials. | |||||
| * @category Asset Manager | |||||
| */ | |||||
| export class MaterialManager<T = ''> extends EventDispatcher<BaseEvent, T> { | export class MaterialManager<T = ''> extends EventDispatcher<BaseEvent, T> { | ||||
| readonly templates: IMaterialTemplate[] = [ | readonly templates: IMaterialTemplate[] = [ | ||||
| PhysicalMaterial.MaterialTemplate, | PhysicalMaterial.MaterialTemplate, |
| import {IViewerPluginSync, ThreeViewer} from '../../viewer' | import {IViewerPluginSync, ThreeViewer} from '../../viewer' | ||||
| import {Importer, Rhino3dmLoader2} from '../../assetmanager' | import {Importer, Rhino3dmLoader2} from '../../assetmanager' | ||||
| /** | |||||
| * Adds support for loading Rhino `.3dm` files. | |||||
| * @category Plugins | |||||
| */ | |||||
| export class Rhino3dmLoadPlugin implements IViewerPluginSync { | export class Rhino3dmLoadPlugin implements IViewerPluginSync { | ||||
| declare ['constructor']: typeof Rhino3dmLoadPlugin | declare ['constructor']: typeof Rhino3dmLoadPlugin | ||||
| importOptions?: ImportFilesOptions | importOptions?: ImportFilesOptions | ||||
| addOptions?: AddAssetOptions | addOptions?: AddAssetOptions | ||||
| } | } | ||||
| /** | |||||
| * Dropzone Plugin | |||||
| * | |||||
| * Adds a dropzone to the viewer for importing assets. | |||||
| * | |||||
| * Automatically imports and adds assets to the scene, the behavior can be configured. | |||||
| * @category Plugins | |||||
| */ | |||||
| @uiFolderContainer('Dropzone') | @uiFolderContainer('Dropzone') | ||||
| export class DropzonePlugin extends AViewerPluginSync<'drop'> { | export class DropzonePlugin extends AViewerPluginSync<'drop'> { | ||||
| static readonly PluginType = 'Dropzone' | static readonly PluginType = 'Dropzone' |
| import {AViewerPluginSync} from '../../viewer' | import {AViewerPluginSync} from '../../viewer' | ||||
| /** | /** | ||||
| * A simple plugin that provides functions to enter, exit, toggle full screen mode and check if the viewer is in full screen mode. | |||||
| * Full Screen Plugin | |||||
| * | |||||
| * A simple plugin that provides functions to {@link enter}, {@link exit}, {@link toggle} full screen mode and check if the viewer is in full screen mode with {@link isFullScreen}. | |||||
| * | |||||
| * Implementation from: | * Implementation from: | ||||
| * https://stackoverflow.com/questions/50568474/how-to-enter-fullscreen-in-three-js | * https://stackoverflow.com/questions/50568474/how-to-enter-fullscreen-in-three-js | ||||
| * | |||||
| * @todo: try out some lib like https://github.com/sindresorhus/screenfull for proper cross browser support | * @todo: try out some lib like https://github.com/sindresorhus/screenfull for proper cross browser support | ||||
| * @category Plugins | |||||
| */ | */ | ||||
| @uiFolderContainer('Full Screen') | @uiFolderContainer('Full Screen') | ||||
| export class FullScreenPlugin extends AViewerPluginSync<'enter'|'exit'> { | export class FullScreenPlugin extends AViewerPluginSync<'enter'|'exit'> { |
| export type DepthBufferPluginTarget = WebGLRenderTarget | export type DepthBufferPluginTarget = WebGLRenderTarget | ||||
| export type DepthBufferPluginPass = GBufferRenderPass<'depth', DepthBufferPluginTarget> | export type DepthBufferPluginPass = GBufferRenderPass<'depth', DepthBufferPluginTarget> | ||||
| /** | |||||
| * Depth Buffer Plugin | |||||
| * | |||||
| * Adds a pre-render pass to render the depth buffer to a render target that can be used as gbuffer or for postprocessing. | |||||
| * @category Plugins | |||||
| */ | |||||
| @uiFolderContainer('Depth Buffer Plugin') | @uiFolderContainer('Depth Buffer Plugin') | ||||
| export class DepthBufferPlugin | export class DepthBufferPlugin | ||||
| extends PipelinePassPlugin<DepthBufferPluginPass, 'depth', DepthBufferPluginEventTypes> { | extends PipelinePassPlugin<DepthBufferPluginPass, 'depth', DepthBufferPluginEventTypes> { |
| // type NormalBufferPluginTarget = WebGLMultipleRenderTargets | WebGLRenderTarget | // type NormalBufferPluginTarget = WebGLMultipleRenderTargets | WebGLRenderTarget | ||||
| export type NormalBufferPluginTarget = WebGLRenderTarget | export type NormalBufferPluginTarget = WebGLRenderTarget | ||||
| export type NormalBufferPluginPass = GBufferRenderPass<'normal', NormalBufferPluginTarget> | export type NormalBufferPluginPass = GBufferRenderPass<'normal', NormalBufferPluginTarget> | ||||
| /** | |||||
| * Normal Buffer Plugin | |||||
| * | |||||
| * Adds a pre-render pass to render the normal buffer to a render target that can be used for postprocessing. | |||||
| * @category Plugins | |||||
| */ | |||||
| @uiFolderContainer('Normal Buffer Plugin') | @uiFolderContainer('Normal Buffer Plugin') | ||||
| export class NormalBufferPlugin | export class NormalBufferPlugin | ||||
| extends PipelinePassPlugin<NormalBufferPluginPass, 'normal', NormalBufferPluginEventTypes> { | extends PipelinePassPlugin<NormalBufferPluginPass, 'normal', NormalBufferPluginEventTypes> { |
| "*": "https://repalash.com/uiconfig-tweakpane" | "*": "https://repalash.com/uiconfig-tweakpane" | ||||
| } | } | ||||
| }, | }, | ||||
| "entryPoints": ["src/index.ts"], | |||||
| "entryPoints": [ | |||||
| "src/index.ts" | |||||
| ], | |||||
| "name": "ThreePipe", | "name": "ThreePipe", | ||||
| "excludeExternals": true, | "excludeExternals": true, | ||||
| "readme": "none", | "readme": "none", | ||||
| "categorizeByGroup": false, | "categorizeByGroup": false, | ||||
| "categoryOrder": [ | "categoryOrder": [ | ||||
| "Viewer", "*", "Others" | |||||
| "Viewer", "Plugins", "Asset Manager", "*", "Others" | |||||
| ], | ], | ||||
| "externalPattern": [ | "externalPattern": [ | ||||
| "**/node_modules/**", | "**/node_modules/**", |