| @@ -23,7 +23,7 @@ | |||
| // or | |||
| // import {ThreeViewer, LoadingScreenPlugin} from 'threepipe' // if using import maps | |||
| // import {ThreeViewer, LoadingScreenPlugin} from './../../dist/index.mjs' | |||
| // import {ThreeViewer, LoadingScreenPlugin} from 'https://threepipe.org/dist/index.mjs' | |||
| // import {ThreeViewer, LoadingScreenPlugin} from 'https://unpkg.com/threepipe@latest/dist/index.mjs' | |||
| const viewer = new ThreeViewer({canvas: document.getElementById('three-canvas')}) | |||
| @@ -17,7 +17,7 @@ | |||
| <body> | |||
| <div id="root"></div> | |||
| <script id="example-script" type="module" data-scripts="./index.html"> | |||
| // import {ThreeViewer, LoadingScreenPlugin} from 'https://threepipe.org/dist/index.mjs' | |||
| // import {ThreeViewer, LoadingScreenPlugin} from 'https://unpkg.com/threepipe@latest/dist/index.mjs' | |||
| import {ThreeViewer, LoadingScreenPlugin} from './../../dist/index.mjs' | |||
| import React from 'https://esm.sh/react@18' | |||
| import ReactDOM from 'https://esm.sh/react-dom@18' | |||
| @@ -19,7 +19,7 @@ | |||
| <body> | |||
| <div id="root"></div> | |||
| <script id="example-script" type="text/babel" data-scripts="./index.html" data-type="module"> | |||
| // import {ThreeViewer, LoadingScreenPlugin} from 'https://threepipe.org/dist/index.mjs' | |||
| // import {ThreeViewer, LoadingScreenPlugin} from 'https://unpkg.com/threepipe@latest/dist/index.mjs' | |||
| import {ThreeViewer, LoadingScreenPlugin} from './../../dist/index.mjs' | |||
| import React from 'https://esm.sh/react@18' | |||
| import ReactDOM from 'https://esm.sh/react-dom@18' | |||
| @@ -19,7 +19,7 @@ | |||
| <canvas id="three-canvas" style="width: 800px; height: 600px" ref="canvasRef"></canvas> | |||
| </div> | |||
| <script id="example-script" type="module" data-scripts="./index.html"> | |||
| // import { ThreeViewer, LoadingScreenPlugin } from 'https://threepipe.org/dist/index.mjs' | |||
| // import { ThreeViewer, LoadingScreenPlugin } from 'https://unpkg.com/threepipe@latest/dist/index.mjs' | |||
| import { ThreeViewer, LoadingScreenPlugin } from './../../dist/index.mjs' | |||
| import { createApp, ref, onMounted, onBeforeUnmount } from "https://unpkg.com/vue@3/dist/vue.esm-browser.prod.js"; | |||
| @@ -6,6 +6,7 @@ import { | |||
| Color, | |||
| Group, | |||
| ILoader, | |||
| ImportAddOptions, | |||
| Importer, | |||
| Mesh, | |||
| Object3D, | |||
| @@ -149,7 +150,7 @@ export class MDDLoadPlugin extends BaseImporterPlugin { | |||
| export class PCDLoadPlugin extends BaseImporterPlugin { | |||
| public static readonly PluginType = 'PCDLoadPlugin' | |||
| protected _importer = new Importer(class extends PCDLoader implements ILoader { | |||
| transform(points: Points, options: AnyOptions): any { | |||
| transform(points: Points, options: ImportAddOptions): any { | |||
| if (options.autoCenter) points.geometry.center() | |||
| points.geometry.rotateX(Math.PI) | |||
| return points | |||
| @@ -215,7 +216,7 @@ export class VTKLoadPlugin extends BaseImporterPlugin { | |||
| export class XYZLoadPlugin extends BaseImporterPlugin { | |||
| public static readonly PluginType = 'XYZLoadPlugin' | |||
| protected _importer = new Importer(class extends XYZLoader implements ILoader { | |||
| transform(res: BufferGeometry, options: AnyOptions): Points|undefined { | |||
| transform(res: BufferGeometry, options: ImportAddOptions): Points|undefined { | |||
| if (!res.attributes?.normal) res.computeVertexNormals() | |||
| if (options.autoCenter) res.center() | |||
| return res ? new Points(res, new PointsMaterial({ | |||
| @@ -302,7 +302,7 @@ export class AssetImporter extends EventDispatcher<IAssetImporterEventMap> imple | |||
| // baseUrl: LoaderUtils.extractUrlBase(url), | |||
| } | |||
| loader.loadFileOptions = options | |||
| loader.importOptions = options | |||
| res = await loader.loadAsync(path + (options.queryString ? (path.includes('?') ? '&' : '?') + options.queryString : ''), (e)=>{ | |||
| if (onDownloadProgress) onDownloadProgress(e) | |||
| const total = e.lengthComputable ? e.total : undefined | |||
| @@ -315,7 +315,7 @@ export class AssetImporter extends EventDispatcher<IAssetImporterEventMap> imple | |||
| }) | |||
| }) | |||
| if (loader.transform) res = await loader.transform(res, options) | |||
| delete loader.loadFileOptions | |||
| delete loader.importOptions | |||
| this._rootContext = undefined | |||
| @@ -84,8 +84,8 @@ export interface AddAssetOptions extends AddObjectOptions{ | |||
| */ | |||
| autoSetBackground?: boolean | |||
| } | |||
| export type ImportAddOptions = ImportAssetOptions & AddAssetOptions | |||
| export type AddRawOptions = ProcessRawOptions & AddAssetOptions | |||
| export interface ImportAddOptions extends ImportAssetOptions, AddAssetOptions{} | |||
| export interface AddRawOptions extends ProcessRawOptions, AddAssetOptions{} | |||
| export interface AssetManagerEventMap{ | |||
| loadAsset: {data: ImportResult} | |||
| @@ -1,16 +1,17 @@ | |||
| import {Loader} from 'three' | |||
| import {IAssetImporter, LoadFileOptions} from './IAssetImporter' | |||
| import {IAssetImporter} from './IAssetImporter' | |||
| import {IDisposable} from 'ts-browser-helpers' | |||
| import {ImportAddOptions} from './AssetManager' | |||
| export interface ILoader<T = any, T2 = T> extends Loader, Partial<IDisposable> { | |||
| loadFileOptions?: LoadFileOptions | |||
| importOptions?: ImportAddOptions | |||
| loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<any>; | |||
| /** | |||
| * Transform after load, like convert geometry to mesh, etc. for reference see {@link DRACOLoader2} or {@link PLYLoadPlugin} | |||
| * @param res - result of load | |||
| * @param options | |||
| */ | |||
| transform?(res: T, options: LoadFileOptions): T2|Promise<T2> | |||
| transform?(res: T, options: ImportAddOptions): T2|Promise<T2> | |||
| } | |||
| export interface IImporter { | |||
| ext: string[]; | |||
| @@ -42,11 +42,11 @@ export class OrbitControls3 extends OrbitControls implements IUiConfigContainer, | |||
| @uiInput() @serialize() minPolarAngle = 0 | |||
| @uiInput() @serialize() maxPolarAngle = Math.PI | |||
| @uiInput() @serialize() minAzimuthAngle = -10000 // should be -Infinity but this breaks the UI | |||
| @uiInput() @serialize() maxAzimuthAngle = 10000 // should be Infinity but this breaks the UI | |||
| @uiInput() @serialize() minAzimuthAngle = -1e6 // should be -Infinity but this breaks the UI | |||
| @uiInput() @serialize() maxAzimuthAngle = 1e6 // should be Infinity but this breaks the UI | |||
| @uiVector() @serialize() clampMin = new Vector3(-10000, -10000, -10000) // should be -Infinity but this breaks the UI | |||
| @uiVector() @serialize() clampMax = new Vector3(10000, 10000, 10000) // should be Infinity but this breaks the UI | |||
| @uiVector() @serialize() clampMin = new Vector3(-1e6, -1e6, -1e6) // should be -Infinity but this breaks the UI | |||
| @uiVector() @serialize() clampMax = new Vector3(1e6, 1e6, 1e6) // should be Infinity but this breaks the UI | |||
| // @uiToggle() | |||
| @serialize() screenSpacePanning = true | |||