archgine 1.0.38 → 1.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,16 @@
1
- import { Application } from './application';
2
- import { IAppOffscreenConfig } from './app-offscreen';
1
+ import { Application, IApplicationConfig } from './application';
3
2
  import { MainScene } from '../scenes/main-scene';
4
- export declare class AppCvs<Config extends IAppOffscreenConfig> extends Application<Config> {
3
+ import { ITree } from '../interfaces';
4
+ import { Adapter } from '../extras/adapter';
5
+ export declare class AppCvs<Config extends IApplicationConfig> extends Application<Config> {
5
6
  params: Config;
7
+ adapter: Adapter;
6
8
  mainScene: MainScene<Config>;
7
9
  constructor(config?: Config);
8
10
  destroy(): void;
9
11
  load(url?: string, layers?: string[]): Promise<void>;
12
+ getLayers(lv?: number): ITree[];
10
13
  trans2MainScene(): void;
14
+ fullScreen(): void;
15
+ updateLayersVisibility(ids: string | string[], visible?: boolean): void;
11
16
  }
@@ -1,19 +1,33 @@
1
1
  import { IApplicationConfig } from './application';
2
2
  import { OpeView } from '../core/ope-view';
3
- export interface IAppOffscreenConfig extends IApplicationConfig {
4
- }
5
- export declare class AppOffscreen<Config extends IAppOffscreenConfig> {
3
+ import { APP_ENUM, ITree } from '../interfaces';
4
+ import { default as EventDispatcher } from '../core/event-dispatcher';
5
+ import { default as Box2 } from '../math/box2';
6
+ export declare class AppOffscreen<Config extends IApplicationConfig> extends EventDispatcher {
6
7
  params: Config;
7
8
  cvs: OffscreenCanvas;
8
9
  worker: Worker;
9
10
  view: OpeView<Config>;
11
+ boundingBox: Box2;
10
12
  readonly workerMessageHandler: (e: MessageEvent) => void;
11
- constructor(config?: Config);
13
+ readonly cameraHandler: (e: MessageEvent) => void;
14
+ readonly runningHandler: (time: DOMHighResTimeStamp) => void;
15
+ constructor(config: Config | undefined, worker: Worker);
12
16
  destroy(): void;
13
17
  bindEvents(): void;
14
18
  unbindEvents(): void;
15
19
  handleWorkerMessage(e: MessageEvent): void;
20
+ handleCameraChanged(e: MessageEvent): void;
21
+ promiseWorkerResponse<T>(task: APP_ENUM, data: any): Promise<T>;
16
22
  resize(): void;
17
- load(url: string, layers?: string[], lv?: number): Promise<void>;
23
+ load(url: string, layers?: string[]): Promise<void>;
24
+ getLayers(lv?: number): Promise<ITree[]>;
25
+ fullscreen(): Promise<void>;
26
+ saveCameraPosition(id?: string): void;
27
+ restoreCameraPosition(id?: string): void;
28
+ clearCameraPosition(id?: string): void;
29
+ updateLayersVisibility(ids: string | string[], visible?: boolean): void;
18
30
  start(): void;
31
+ running(time: DOMHighResTimeStamp): void;
32
+ stop(): void;
19
33
  }
@@ -8,6 +8,20 @@ export interface IApplicationConfig extends IRenderer2Config {
8
8
  frameInterval?: number;
9
9
  syncDelay?: number;
10
10
  animateDuration?: number;
11
+ defaultFill?: string;
12
+ defaultStroke?: string;
13
+ infoFill?: string;
14
+ infoStroke?: string;
15
+ primaryFill?: string;
16
+ primaryStroke?: string;
17
+ successFill?: string;
18
+ successStroke?: string;
19
+ warningFill?: string;
20
+ warningStroke?: string;
21
+ dangerFill?: string;
22
+ dangerStroke?: string;
23
+ activeFill?: string;
24
+ activeStroke?: string;
11
25
  }
12
26
  /**
13
27
  * @author Dio Zhu
@@ -25,8 +39,8 @@ export declare abstract class Application<Config extends IApplicationConfig> ext
25
39
  view: View<any>;
26
40
  readonly runningHandler: (time: DOMHighResTimeStamp) => void;
27
41
  protected constructor(config?: Config);
28
- destroy(): void;
29
42
  get isLoadingScene(): boolean;
43
+ destroy(): void;
30
44
  trans2LoadingScene(): void;
31
45
  hasScene(scene: Scene): boolean;
32
46
  pushScene(scene: Scene): void;
@@ -152,5 +152,6 @@ export declare enum EventsEnum {
152
152
  PINCH_OUT = "pinchout",
153
153
  SWIPE = "swipe",
154
154
  CHANGE_START = "change_start",
155
- CHANGE_END = "change_end"
155
+ CHANGE_END = "change_end",
156
+ CAMERA_CHANGED = "cameraChanged"
156
157
  }
@@ -1,5 +1,5 @@
1
1
  import { default as Vector2 } from '../math/vector2';
2
- import { ICamera2, ICamera2Config, ICamera2Position, IObject2, IVector2 } from '../interfaces';
2
+ import { ICamera2, ICamera2Config, ICamera2Position, IObject2, IPoint2, IVector2 } from '../interfaces';
3
3
  import { default as Matrix3 } from '../math/matrix3';
4
4
  import { Object2 } from './object2';
5
5
  import { default as Box2 } from '../math/box2';
@@ -34,6 +34,7 @@ export default class Camera2<Config extends ICamera2Config> extends Object2 impl
34
34
  get pixelWidth(): number;
35
35
  set(l?: number, r?: number, t?: number, b?: number): void;
36
36
  setByBox(box: Box2): void;
37
+ setTRS(t?: IPoint2, r?: number, s?: number): void;
37
38
  resize(): void;
38
39
  setSize(w: number, h: number): void;
39
40
  getWorldDirection(target: Vector2): Vector2;
@@ -9,6 +9,13 @@ interface IMonitorRecord {
9
9
  }
10
10
  export declare class Monitor {
11
11
  static idCounter: number;
12
+ static children: Monitor[];
13
+ static isRunning: boolean;
14
+ static actived: boolean;
15
+ static duration: number;
16
+ static lastTime: number;
17
+ static messages: IMonitorRecord[];
18
+ static maxLetters: number;
12
19
  id: number;
13
20
  timers: Map<string, number[]>;
14
21
  timersDuration: Map<string, number>;
@@ -16,6 +23,12 @@ export declare class Monitor {
16
23
  countersAmount: Map<string, number>;
17
24
  out: IMonitorRecord[];
18
25
  constructor();
26
+ static active(duration?: number): void;
27
+ static add(o: Monitor): void;
28
+ static remove(o: Monitor): void;
29
+ static handleStart(): void;
30
+ static runLoop(): void;
31
+ static runFrames(): void;
19
32
  destroy(): void;
20
33
  addTimer(key: string, t?: number, duration?: number): void;
21
34
  addTimerDuration(key: string, duration: number): void;
@@ -34,18 +47,5 @@ export declare class Monitor {
34
47
  stdDev(durations: number[], avg: number): number;
35
48
  fd(d: number): string;
36
49
  fx(d: number, l?: number): number;
37
- static children: Monitor[];
38
- static isRunning: boolean;
39
- static actived: boolean;
40
- static duration: number;
41
- static lastTime: number;
42
- static messages: IMonitorRecord[];
43
- static maxLetters: number;
44
- static active(duration?: number): void;
45
- static add(o: Monitor): void;
46
- static remove(o: Monitor): void;
47
- static handleStart(): void;
48
- static runLoop(): void;
49
- static runFrames(): void;
50
50
  }
51
51
  export {};
@@ -1,5 +1,5 @@
1
1
  import { default as EventDispatcher } from './event-dispatcher';
2
- import { IAnimationClip, IBox2, ICamera2, IObject2, IPoint2, IVector2 } from '../interfaces';
2
+ import { IAnimationClip, IBox2, ICamera2, IMatrix3, IObject2, IPoint2, IVector2 } from '../interfaces';
3
3
  import { default as Vector2 } from '../math/vector2';
4
4
  import { default as Matrix3 } from '../math/matrix3';
5
5
  import { default as Box2 } from '../math/box2';
@@ -16,7 +16,6 @@ export declare class Object2 extends EventDispatcher implements IObject2 {
16
16
  name: string;
17
17
  type: string;
18
18
  featureKey: string;
19
- _version: number;
20
19
  parent: IObject2 | undefined;
21
20
  children: IObject2[];
22
21
  up: Vector2;
@@ -49,13 +48,14 @@ export declare class Object2 extends EventDispatcher implements IObject2 {
49
48
  animations: IAnimationClip[];
50
49
  finalSize?: IPoint2;
51
50
  userData: any;
52
- [prop: string]: any;
53
51
  DefaultUp: Vector2;
52
+ [prop: string]: any;
54
53
  private _autoSort;
55
54
  constructor(config?: IObject2Config);
56
- set needsUpdate(v: boolean);
55
+ _version: number;
57
56
  get version(): number;
58
57
  set version(v: number);
58
+ set needsUpdate(v: boolean);
59
59
  destroy(): void;
60
60
  setPosition(v: IVector2): this;
61
61
  translate(x: number, y: number): void;
@@ -67,7 +67,7 @@ export declare class Object2 extends EventDispatcher implements IObject2 {
67
67
  localToWorld(v: Vector2): Vector2;
68
68
  worldToLocal(v: Vector2): Vector2;
69
69
  lookAt(v: Vector2): void;
70
- applyMatrix3(matrix: Matrix3): void;
70
+ applyMatrix3(matrix: IMatrix3): void;
71
71
  updateMatrix(): void;
72
72
  updateMatrixWorld(force?: boolean): void;
73
73
  updateWorldMatrix(updateParents?: boolean, updateChildren?: boolean): void;
@@ -1,9 +1,8 @@
1
- import { IBox2, ICamera2, ICamera2Config, ICanvas, IRenderer2Config, IView } from '../interfaces';
1
+ import { ICamera2, ICamera2Config, ICanvas, IRenderer2Config } from '../interfaces';
2
2
  import { IOrbitControlsConfig } from '../controls/orbit-controls';
3
- import { default as Scene } from '../scenes/scene';
4
3
  import { OrbitController } from '../controls/orbit-controller';
5
- import { default as Box2 } from '../math/box2';
6
4
  import { IAxesHelperConfig } from '../helpers/axes-helper';
5
+ import { View } from './view';
7
6
  export interface IViewConfig extends IRenderer2Config {
8
7
  name?: string;
9
8
  cvs?: ICanvas;
@@ -15,26 +14,11 @@ export interface IViewConfig extends IRenderer2Config {
15
14
  /**
16
15
  * @author Dio Zhu 2024.8.22
17
16
  */
18
- export declare class OpeView<Config extends IViewConfig> implements IView {
17
+ export declare class OpeView<Config extends IViewConfig> extends View<Config> {
19
18
  name: string;
20
- params: Config;
21
- visible: boolean;
22
- cvs: ICanvas | undefined;
23
- scene: Scene | undefined;
24
- scenes: Scene[];
25
- camera: ICamera2 | undefined;
26
- controller?: OrbitController;
19
+ controller: OrbitController;
27
20
  constructor(config?: Config);
28
21
  destroy(): void;
29
- initController(camera?: ICamera2, dom?: HTMLElement): void;
22
+ initController(camera?: ICamera2): void;
30
23
  handleCameraChanged(e: any): void;
31
- reset(): void;
32
- bindScene(scene: Scene): void;
33
- resetCameraByBoundingBox(box: IBox2, animate?: boolean): void;
34
- computeScenesBoundingBox(scenes: Scene[], target?: Box2): Box2;
35
- expandScenesBoundingBox(scenes: Scene[], box?: Box2): void;
36
- /**
37
- * @see Application.running
38
- */
39
- update(time?: DOMHighResTimeStamp): void;
40
24
  }
@@ -1,9 +1,10 @@
1
- import { IBox2, ICamera2, ICamera2Config, ICanvas, IRenderer2Config, IView } from '../interfaces';
1
+ import { IBox2, ICamera2, ICamera2Config, ICamera2Position, ICanvas, IRenderer2Config, IView } from '../interfaces';
2
2
  import { IOrbitControlsConfig } from '../controls/orbit-controls';
3
3
  import { default as Scene } from '../scenes/scene';
4
4
  import { OrbitController } from '../controls/orbit-controller';
5
5
  import { default as Box2 } from '../math/box2';
6
6
  import { IAxesHelperConfig } from '../helpers/axes-helper';
7
+ import { Tween } from '@tweenjs/tween.js';
7
8
  export interface IViewConfig extends IRenderer2Config {
8
9
  name?: string;
9
10
  cvs?: ICanvas;
@@ -11,6 +12,7 @@ export interface IViewConfig extends IRenderer2Config {
11
12
  controls?: IOrbitControlsConfig;
12
13
  axesHelper?: IAxesHelperConfig;
13
14
  alignStageCenter?: boolean;
15
+ animateDuration?: number;
14
16
  }
15
17
  /**
16
18
  * @author Dio Zhu 2024.8.22
@@ -22,19 +24,26 @@ export declare class View<Config extends IViewConfig> implements IView {
22
24
  cvs: ICanvas | undefined;
23
25
  scene: Scene | undefined;
24
26
  scenes: Scene[];
25
- camera: ICamera2 | undefined;
27
+ camera: ICamera2;
26
28
  controller?: OrbitController;
29
+ tween?: Tween;
30
+ animateDuration: number;
27
31
  constructor(config?: Config);
28
32
  destroy(): void;
29
33
  bindScene(scene: Scene): void;
34
+ saveCameraPosition(id?: string): void;
35
+ clearCameraPosition(id?: string): void;
36
+ restoreCameraPosition(id?: string): void;
30
37
  fullscreen(padding?: number, animate?: boolean): void;
31
38
  handleCameraChanged(e: any): void;
32
39
  reset(): void;
33
- resetCameraByBoundingBox(box: IBox2, animate?: boolean): void;
34
- computeScenesBoundingBox(scenes: Scene[], target?: Box2): Box2;
40
+ resetCameraByBoundingBox(box: IBox2, animate?: boolean): Promise<void>;
41
+ animateCamera(from: ICamera2Position, to: ICamera2Position): Promise<void>;
42
+ computeBoundingBox(scenes: Scene[], target?: Box2): Box2;
35
43
  expandScenesBoundingBox(scenes: Scene[], box?: Box2): void;
36
44
  /**
37
45
  * @see Application.running
38
46
  */
39
47
  update(time?: DOMHighResTimeStamp): void;
40
48
  }
49
+ export declare const CAMERA_SESSION_KEY = "camera_position_";
@@ -11,6 +11,8 @@ var Pe = {
11
11
  fps: 60,
12
12
  syncDelay: 800,
13
13
  animateDuration: 600,
14
+ mergeRendering: !1,
15
+ // 合并渲染
14
16
  usedCache: !1,
15
17
  showPoints: !1,
16
18
  wireframe: !1,
@@ -3995,7 +3997,7 @@ Fu.__DOMHandler = Eu;
3995
3997
  Fu.normalizeLineEndings = Le;
3996
3998
  Fu.DOMParser = Ie;
3997
3999
  var gr = Fu.DOMParser;
3998
- const Er = "1.0.38";
4000
+ const Er = "1.0.40";
3999
4001
  function vr() {
4000
4002
  return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
4001
4003
  }
@@ -1,21 +1,60 @@
1
1
  import { default as EventDispatcher } from '../core/event-dispatcher';
2
2
  import { default as Box2 } from '../math/box2';
3
- import { IShape2 } from '../interfaces';
3
+ import { IObject2, ITree } from '../interfaces';
4
+ import { IApplicationConfig } from '../applications/application';
4
5
  export declare class Adapter extends EventDispatcher {
5
6
  name: string;
7
+ params: IApplicationConfig;
6
8
  boundingBox: Box2;
7
- resources: Record<string, IShape2[]>;
9
+ resources: Record<string, IObject2[]>;
10
+ _resourcesMap: Record<string, IObject2>;
11
+ _resourcesTree: ITree[];
8
12
  private _svg?;
9
13
  private _svgRoot?;
10
14
  private _viewBox;
11
15
  private _elementsMap;
12
- constructor();
16
+ constructor(config?: IApplicationConfig);
13
17
  destroy(): void;
14
- load(url: string, layers?: string[], lv?: number): Promise<void>;
18
+ clear(): void;
19
+ load(url: string, layers?: string[]): Promise<void>;
15
20
  init(str?: string): void;
21
+ /**
22
+ * background:
23
+ * ...
24
+ *
25
+ * gros
26
+ * rm
27
+ * ...
28
+ * gros-labels
29
+ * rm-labels
30
+ * ...
31
+ */
16
32
  initResources(): void;
33
+ initResourcesTree(): void;
17
34
  initResource(id: string): void;
18
- getElementById(id: string): Element | undefined;
35
+ getResources(): IObject2[] | undefined;
36
+ getLayers(lv?: number): ITree[];
37
+ getElementById(id?: string): Element | undefined;
38
+ getSymbolElement(el?: Element): Element | undefined;
39
+ trans2Shape(el?: Element, flipY?: boolean): IObject2 | undefined;
40
+ transG(el?: Element, flipY?: boolean): IObject2 | undefined;
41
+ transSymbol(el?: Element, flipY?: boolean): IObject2 | undefined;
42
+ transPath(el?: Element, flipY?: boolean): IObject2 | undefined;
43
+ transUse(el?: Element, flipY?: boolean): IObject2 | undefined;
44
+ transCircle(el?: Element, flipY?: boolean): IObject2 | undefined;
45
+ /**
46
+ * test linked to asset
47
+ * 1、old version: split with ';', use first;
48
+ * 2、new version: use 'aid' attribute;
49
+ * 3、use 'assetId' + SPLITTER + LABEL_TAG save to elementsMap;
50
+ */
51
+ transText(el?: Element, flipY?: boolean): IObject2 | undefined;
52
+ getAssetLabelId(assetId: string): string;
53
+ getResourceById(id?: string): IObject2 | undefined;
54
+ getResourceTreeById(t: ITree | ITree[], id?: string): ITree | undefined;
55
+ updateLayersVisibility(ids: string | string[], visible?: boolean): void;
56
+ _updateAllLayersVisibility(visible?: boolean): void;
57
+ _updateLayersVisibility(t: ITree, visible?: boolean): void;
19
58
  }
20
59
  export declare enum AdapterEnum {
21
60
  INITIALIZATION_START = "INITIALIZATION_START",
@@ -15,20 +15,6 @@ export interface ISvgAppConfig extends IApplicationConfig {
15
15
  selectEnable?: boolean;
16
16
  multiSelectEnable?: boolean;
17
17
  socialDistanceEnable?: boolean;
18
- defaultFill?: string;
19
- defaultStroke?: string;
20
- infoFill?: string;
21
- infoStroke?: string;
22
- primaryFill?: string;
23
- primaryStroke?: string;
24
- successFill?: string;
25
- successStroke?: string;
26
- warningFill?: string;
27
- warningStroke?: string;
28
- dangerFill?: string;
29
- dangerStroke?: string;
30
- activeFill?: string;
31
- activeStroke?: string;
32
18
  }
33
19
  export declare class SvgApp<Config extends ISvgAppConfig> extends EventDispatcher implements IApp {
34
20
  name: string;
@@ -5,7 +5,7 @@ export interface ICircleGeo2 extends IGeo2Config {
5
5
  end?: number;
6
6
  }
7
7
  export declare class CircleGeo2<Config extends ICircleGeo2> extends Geo2<Config> {
8
- readonly name: string;
8
+ readonly isCircle: boolean;
9
9
  radius: number;
10
10
  start: number;
11
11
  end: number;
@@ -4,18 +4,18 @@ import { IBox2, IContext2D, IGeo2, IMatrix3, IPath2Command, IPoint2 } from '../i
4
4
  export interface IGeo2Config {
5
5
  points?: IPoint2[];
6
6
  commands?: string | IPath2Command[];
7
+ flipY?: boolean;
7
8
  }
8
9
  export declare class Geo2<Config extends IGeo2Config> extends SVGPathData implements IGeo2 {
9
- readonly name: string;
10
- _version: number;
10
+ name: string;
11
11
  params: Config;
12
12
  viewMatrix: Matrix3;
13
13
  boundingBox: IBox2;
14
14
  constructor(config?: Config);
15
- set needsUpdate(v: boolean);
15
+ _version: number;
16
16
  get version(): number;
17
17
  set version(v: number);
18
- static getInstanceByPath(o: Element): Geo2<any> | undefined;
18
+ set needsUpdate(v: boolean);
19
19
  static render(ctx: IContext2D, commands: IPath2Command[]): void;
20
20
  setFromPoints(ps?: IPoint2[]): IGeo2;
21
21
  recomputePath(): void;
@@ -1,6 +1,5 @@
1
1
  import { Geo2, IGeo2Config } from './geo2';
2
2
  export declare class PolygonGeo2<Config extends IGeo2Config> extends Geo2<Config> {
3
- readonly name: string;
4
3
  constructor(config?: Config);
5
4
  recomputePath(): this;
6
5
  }
@@ -6,7 +6,6 @@ export interface IPolylineGeo2Options extends IGeo2Config {
6
6
  arrowDeg?: number;
7
7
  }
8
8
  export declare class PolylineGeo2<Config extends IPolylineGeo2Options> extends Geo2<Config> {
9
- readonly name: string;
10
9
  arrowLength: number;
11
10
  arrowDeg: number;
12
11
  stArrow: boolean;
@@ -0,0 +1,12 @@
1
+ import { Geo2 } from '../geometries/geo2';
2
+ import { SVGCommand } from 'svg-pathdata/src/types';
3
+ import { IShape2Config } from '../objects/shape2';
4
+ export declare class GeoHelper {
5
+ params: IShape2Config;
6
+ constructor(config?: IShape2Config);
7
+ destroy(): void;
8
+ static getInstanceByElement(o: Element, flipY?: boolean): Geo2<any> | undefined;
9
+ static getInstanceByPath(o: Element, flipY?: boolean): Geo2<any> | undefined;
10
+ static getInstanceByCircle(o: Element, flipY?: boolean): Geo2<any> | undefined;
11
+ static getInstance(cmd: string | SVGCommand[], flipY?: boolean): Geo2<any> | undefined;
12
+ }
@@ -0,0 +1,10 @@
1
+ import { IMat2 } from '../interfaces';
2
+ import { IShape2Config } from '../objects/shape2';
3
+ export declare class MatHelper {
4
+ params: IShape2Config;
5
+ constructor(config?: IShape2Config);
6
+ destroy(): void;
7
+ static getInstance(config: IShape2Config): IMat2;
8
+ static setCache(config: IShape2Config, mtl: IMat2): void;
9
+ }
10
+ export declare function getMatFeatureKey(o: any): string;
@@ -0,0 +1,7 @@
1
+ import { IShape2 } from '../interfaces';
2
+ import { IShape2Config } from '../objects/shape2';
3
+ import { ITextConfig } from '../shapes2/text';
4
+ export declare class MergeHelper {
5
+ static getShapeByElement(el: Element, config: IShape2Config, flipY?: boolean): IShape2;
6
+ static getText(config: ITextConfig): IShape2;
7
+ }
package/lib/index.d.ts CHANGED
@@ -10,4 +10,5 @@ export { AssetTypeEnum, LayerTypeEnum } from './env/enums';
10
10
  export type { ITree } from './interfaces';
11
11
  export type { IApp, IDummyVo, IDummy } from './extras/interfaces';
12
12
  export { AppEnum, SvgApp } from './extras/svg-app';
13
+ export { AppOffscreen } from './applications/app-offscreen';
13
14
  export { defaultConfig, EnvironmentWorker, RendererWorker, };