build-dxf 0.0.19-6 → 0.0.19-8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-dxf",
3
- "version": "0.0.19-6",
3
+ "version": "0.0.19-8",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.d.ts CHANGED
@@ -7,6 +7,26 @@ export * from './utils/DxfSystem/plugin/ModelDataPlugin';
7
7
  * @param camera
8
8
  * @returns
9
9
  */
10
- export declare function createEditor(dom: HTMLDivElement, camera?: THREE.OrthographicCamera): Promise<{
10
+ export declare function createEditor(dom: HTMLDivElement, camera?: THREE.Camera, orbitControls?: boolean): Promise<{
11
11
  dxfSystem: DxfSystem;
12
+ getFileAll: () => {
13
+ dxf: File;
14
+ obj: File;
15
+ glb: File;
16
+ gltf: File;
17
+ };
12
18
  }>;
19
+ /**
20
+ * 获取所有文件数据
21
+ * @param dxfSystem
22
+ */
23
+ export declare function getFileAll(dxfSystem?: DxfSystem): {
24
+ dxf: File;
25
+ obj: File;
26
+ glb: File;
27
+ gltf: File;
28
+ };
29
+ /** 获取全局DxfSystem
30
+ * @returns
31
+ */
32
+ export declare function getGlobalDxfSystem(): DxfSystem | null;
package/src/build.js CHANGED
@@ -120,7 +120,7 @@ class ComponentManager extends EventDispatcher {
120
120
  * @param callBack
121
121
  */
122
122
  findComponents(predicate) {
123
- return this.components.find(predicate);
123
+ return this.components.filter(predicate);
124
124
  }
125
125
  /**
126
126
  *
@@ -3076,26 +3076,45 @@ function loadRenderPlugin() {
3076
3076
  function loadEditorPlugin() {
3077
3077
  return import("./index3.js");
3078
3078
  }
3079
- async function createEditor(dom, camera) {
3079
+ let gloabalDxfSystem = null;
3080
+ async function createEditor(dom, camera, orbitControls = false) {
3080
3081
  const mp = await Promise.resolve().then(() => index);
3081
3082
  const rp = await loadRenderPlugin();
3082
3083
  const editor = await loadEditorPlugin();
3083
3084
  const dxfSystem = new DxfSystem().usePlugin(mp.ModelDataPlugin.create({
3084
3085
  detailsPoint: false,
3085
- whiteModel: false
3086
+ whiteModel: true
3086
3087
  })).usePlugin(rp.RenderPlugin.create({
3087
3088
  originalLine: false,
3088
3089
  modelData: false,
3089
3090
  detailsPoint: false,
3090
- orbitControls: false,
3091
+ orbitControls,
3091
3092
  camera
3092
3093
  })).usePlugin(editor.Editor);
3093
3094
  const domContainer = dxfSystem.findComponentByType(rp.components.DomContainer);
3094
3095
  domContainer && dom.appendChild(domContainer.domElement);
3096
+ gloabalDxfSystem = dxfSystem;
3095
3097
  return {
3096
- dxfSystem
3098
+ dxfSystem,
3099
+ getFileAll: () => getFileAll(dxfSystem)
3097
3100
  };
3098
3101
  }
3102
+ function getFileAll(dxfSystem = gloabalDxfSystem) {
3103
+ const whiteModel = dxfSystem.findComponentByName("WhiteModel");
3104
+ const dxf = new File([dxfSystem.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" });
3105
+ const obj = new File([whiteModel.toOBJBlob()], "model.obj", { type: "application/octet-stream" });
3106
+ const glb = new File([whiteModel.toGltfBlob(true)], "model.glb", { type: "application/octet-stream" });
3107
+ const gltf = new File([whiteModel.toGltfBlob(false)], "model.gltf", { type: "application/json" });
3108
+ return {
3109
+ dxf,
3110
+ obj,
3111
+ glb,
3112
+ gltf
3113
+ };
3114
+ }
3115
+ function getGlobalDxfSystem() {
3116
+ return gloabalDxfSystem;
3117
+ }
3099
3118
  export {
3100
3119
  Box2 as B,
3101
3120
  Component as C,
@@ -3110,5 +3129,7 @@ export {
3110
3129
  DetailsPoint as a,
3111
3130
  PointVirtualGrid as b,
3112
3131
  createEditor as c,
3132
+ getGlobalDxfSystem as d,
3133
+ getFileAll as g,
3113
3134
  index$1 as i
3114
3135
  };