Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
.DS_Store
dist
dist-ssr
!libs/**/*
coverage
*.local

Expand Down
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
2 changes: 2 additions & 0 deletions libs/x-viewer/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# core
This is the core package of reusable crucial pieces of code for x-viewer.
11,773 changes: 11,773 additions & 0 deletions libs/x-viewer/core/dist/index.esm.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions libs/x-viewer/core/dist/types/Locale.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export declare const en: {
ProgressBar: {
Loading: string;
LoadingFailed: string;
Comparing: string;
};
Tooltip: {
boxSelect: string;
pickMarkup: string;
};
};
export declare const cn: {
ProgressBar: {
Loading: string;
LoadingFailed: string;
Comparing: string;
};
Tooltip: {
boxSelect: string;
pickMarkup: string;
};
};
export declare const i18n: import("i18next").i18n;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Viewer2d } from "../../core/viewers";
export declare class DxfLayoutBar {
protected readonly viewer: Viewer2d;
private element?;
private content?;
private itemList;
constructor(viewer: Viewer2d);
init(): void;
private handleMouseWheel;
private createItem;
destroy(): void;
show(): void;
hide(): void;
}
export declare class ModelLayoutSwitchItem {
protected readonly viewer: Viewer2d;
private eventBus;
element: HTMLElement;
resetActivate?: () => void;
active: boolean;
constructor(viewer: Viewer2d, name: string);
private createItem;
setActive(active: boolean): void;
resetActive(): void;
destroy(): void;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./DxfLayoutBar";
20 changes: 20 additions & 0 deletions libs/x-viewer/core/dist/types/components/tool-tip/Tooltip.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
interface TooltipConfig {
showOnCreate?: boolean;
followPointer?: boolean;
parentNode?: HTMLElement;
target?: HTMLElement;
}
export declare class Tooltip {
private node;
private parentNode;
private target;
private childNode;
constructor(id: string, content?: string | HTMLElement | null, cfg?: TooltipConfig);
setContent(content: string | HTMLElement): void;
updateChildContent(content: string | HTMLElement): void;
follow: (event: MouseEvent) => void;
show: () => false | void;
hide: () => false | void;
destroy: () => void;
}
export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Tooltip";
288 changes: 288 additions & 0 deletions libs/x-viewer/core/dist/types/core/Configs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
import * as THREE from "three";
/**
* Camera projection type.
*/
export declare enum CameraProjection {
Perspective = "Perspective",
Orthographic = "Orthographic"
}
/**
* Camera info
*/
export interface CameraInfo {
/**
* Camera projection type
*/
projection: CameraProjection;
/**
* The camera position
*/
position: THREE.Vector3;
/**
* The target that the camera looks to
*/
target: THREE.Vector3;
/**
* @internal
*/
up?: THREE.Vector3;
/**
* The camera zoom
*/
zoom?: number;
/**
* The camera's near clip plane
*/
near?: number;
/**
* The camera's far clip plane
*/
far?: number;
/**
* Used by perspective camera
*/
fov?: number;
/**
* Used by perspective camera
*/
aspect?: number;
/**
* Used by orthographic camera
*/
left?: number;
/**
* Used by orthographic camera
*/
right?: number;
/**
* Used by orthographic camera
*/
bottom?: number;
/**
* Used by orthographic camera
*/
top?: number;
}
/**
* Model config
*/
export interface ModelConfig {
/**
* Unique id of the model
*/
modelId?: string;
/**
* Model name
*/
name?: string;
/**
* Source url of the model
*/
src: string;
/**
* Used to distinguish format, because it may be hard to know the format by src!
* @internal
*/
fileFormat?: string;
/**
* File encoding, can be used by dxf. Common encoding include "UTF-8", "gb2312", etc.
* @internal
*/
encoding?: string;
/**
* A float array of length 16, definds model's position, rotation and scale
*/
matrix?: number[];
/**
* If we want to merge meshes/lines/points with the same material
* @internal
* @default false
*/
merge?: boolean;
/**
* If we want to generate and show edges/outlines to the modle.
* It is useful for Viewer3d.
* @internal
*/
edges?: boolean;
/**
* If this model is visible by default.
* @internal
*/
visible?: boolean;
/**
* This is only useful for obj model, mtl is material file.
* @internal
*/
mtlUrls?: string[];
}
/**
* 2d model config
*/
export interface Model2dConfig extends ModelConfig {
/**
* If to ignore anything of paper space.
* There are some scenarios to ignore paper space by default, includes:
* - Dxf overlay, aka, loading more than one dxf files into a viewer. We'll only load model space for the first file.
* - Dxf compare. Since we'll only compare model space, it won't load paper space at all.
*
* This option is useful when user want to explicitly ignore paper space.
* @default false
*/
ignorePaperSpace?: boolean;
/**
* Applies this color to everything in this model.
* This allows user to show a drawing with a pure color (black, white, etc.).
* Color value is between 0 and 1, e.g., [1, 0, 0] means 'red'.
*/
overrideColor?: number[];
}
/**
* Common viewer config
*/
export interface BaseViewerConfig {
/**
* @description canvas id to contain the viewer.
*/
containerId: string;
/**
* Language of the viewer.
* @description Default is `en`.
*/
language?: "cn" | "en";
/**
* @internal
*/
logLevel?: "debug" | "info" | "warn" | "error" | "silent";
/**
* @internal
*/
enableSpinner?: boolean;
/**
* @internal
*/
enableProgressBar?: boolean;
/**
* @description just for react native
* @internal
*/
context?: WebGLRenderingContext | WebGL2RenderingContext;
/**
* @description just for react native
* @internal
*/
context2d?: CanvasRenderingContext2D;
}
/**
* This wrappers most config for Viewer3d
*/
export interface Viewer3dConfig extends BaseViewerConfig {
/**
* Default is `meters`
* @internal
*/
units?: string;
}
/**
* This wrappers most config for Viewer2d
*/
export interface Viewer2dConfig extends BaseViewerConfig {
/**
* Enables layout bar so we can switch to other layouts.
* The default layout bar is an example UI of the viewer, since plenty of APIs are exposed,
* you are recommended to create your own layout bar with customized style, location, etc.
*/
enableLayoutBar?: boolean;
/**
* If to cache model into indexeddb (or maybe local storage in future).
* If enabled, it will get model data from cache the next time model is loaded.
* @internal
* @default true
*/
enableLocalCache?: boolean;
}
/**
* Dxf compare config.
*/
export interface DxfCompareConfig {
/**
* Enables to compare properties (color, linetype, line width, etc.)
*/
enableDetailComparision: boolean;
}
/**
* A default Viewer3dConfig as a template, which enables most plugins.
* @internal
*/
export declare const DefaultViewer3dConfig: Viewer3dConfig;
/**
* @internal
*/
export interface IsolateObjectsParam {
id: string;
modelId: string;
}
/**
* @internal
*/
export interface IsolateObjectsParams {
familyInstanceIds: IsolateObjectsParam[];
}
/**
* @internal
*/
export interface ScreenshotConfig {
type: string;
quality: number;
includeOverlay: boolean;
}
/**
* Viewpoint definition.
*/
export interface Viewpoint {
/**
* The camera location
*/
eye: THREE.Vector3;
/**
* The location that the camera looks to
*/
look: THREE.Vector3;
/**
* @internal
*/
up?: THREE.Vector3;
/**
* The camera zoom, used by Orthographic camera.
*/
zoom?: number;
}
/**
* View direction.
*/
export declare enum ViewDirection {
Top = "Top",
Bottom = "Bottom",
Front = "Front",
Back = "Back",
Left = "Left",
Right = "Right"
}
/**
* Icon class.
* Used by toolbar and bottom bar icons, etc.
*/
export interface IconClass {
/**
* The default icon.
*/
default: string;
/**
* The icon when item is actived.
*/
active?: string;
/**
* The icon font class name.
*/
iconFont?: string;
}
Loading