@combeenation/3d-viewer 18.5.1 → 19.0.0
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/dist/lib-cjs/buildinfo.json +1 -1
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/dist/lib-cjs/index.d.ts +4 -3
- package/dist/lib-cjs/index.js +4 -3
- package/dist/lib-cjs/index.js.map +1 -1
- package/dist/lib-cjs/internal/cbn-custom-babylon-loader-plugin.js +1 -1
- package/dist/lib-cjs/internal/cbn-custom-babylon-loader-plugin.js.map +1 -1
- package/dist/lib-cjs/internal/export-helper.js +1 -77
- package/dist/lib-cjs/internal/export-helper.js.map +1 -1
- package/dist/lib-cjs/manager/export-manager.d.ts +82 -0
- package/dist/lib-cjs/manager/export-manager.js +224 -0
- package/dist/lib-cjs/manager/export-manager.js.map +1 -0
- package/dist/lib-cjs/{helper/decals-helper.d.ts → utils/decal-utils.d.ts} +5 -1
- package/dist/lib-cjs/{helper/decals-helper.js → utils/decal-utils.js} +6 -3
- package/dist/lib-cjs/utils/decal-utils.js.map +1 -0
- package/dist/lib-cjs/utils/node-utils.d.ts +17 -0
- package/dist/lib-cjs/utils/node-utils.js +92 -0
- package/dist/lib-cjs/utils/node-utils.js.map +1 -0
- package/dist/lib-cjs/viewer.d.ts +3 -5
- package/dist/lib-cjs/viewer.js +3 -7
- package/dist/lib-cjs/viewer.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -3
- package/src/internal/cbn-custom-babylon-loader-plugin.ts +2 -2
- package/src/internal/export-helper.ts +2 -100
- package/src/manager/export-manager.ts +273 -0
- package/src/{helper/decals-helper.ts → utils/decal-utils.ts} +6 -1
- package/src/utils/node-utils.ts +112 -0
- package/src/viewer.ts +5 -11
- package/dist/lib-cjs/helper/decals-helper.js.map +0 -1
- package/dist/lib-cjs/manager/dxf-export-manager.d.ts +0 -39
- package/dist/lib-cjs/manager/dxf-export-manager.js +0 -116
- package/dist/lib-cjs/manager/dxf-export-manager.js.map +0 -1
- package/dist/lib-cjs/manager/gltf-export-manager.d.ts +0 -54
- package/dist/lib-cjs/manager/gltf-export-manager.js +0 -124
- package/dist/lib-cjs/manager/gltf-export-manager.js.map +0 -1
- package/src/manager/dxf-export-manager.ts +0 -123
- package/src/manager/gltf-export-manager.ts +0 -139
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { Animation, GLTF2Export, IExportOptions, Node, NodeDescription, Viewer } from '../index';
|
|
2
|
-
import {
|
|
3
|
-
exportPostProcess,
|
|
4
|
-
exportPreProcess,
|
|
5
|
-
isExportableTransformNode,
|
|
6
|
-
normalizeFileName,
|
|
7
|
-
} from '../internal/export-helper';
|
|
8
|
-
import { getInternalMetadataValue } from '../internal/metadata-helper';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Interface TODOS
|
|
12
|
-
* ===============
|
|
13
|
-
* - create settings object instead of individual input parameters (optimizeForAR, excludeNodes, fileName)
|
|
14
|
-
* - see `DxfExportManager`
|
|
15
|
-
* - much more flexible when adding new parameters
|
|
16
|
-
* - rename functions to create/download, instead of suffixing "ToFile"
|
|
17
|
-
* - also see `DxfExportManager`
|
|
18
|
-
*
|
|
19
|
-
* Viewer control is directly accessing these functions, so introducing breaking changes here is really annoying, as we
|
|
20
|
-
* have to add another version switch in the source code of the viewer control.
|
|
21
|
-
* Maybe there is a chance to update the interface when re-creating the viewer control in the new cfgr editor.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Manager for gltf export and augmented reality features
|
|
26
|
-
*/
|
|
27
|
-
export class GltfExportManager {
|
|
28
|
-
protected _maxTextureSize: number;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Defines options for the export.
|
|
32
|
-
* We don't allow the user to overwrite certain settings, since we rely on properties like `removeNoopRootNodes` to
|
|
33
|
-
* stay `true` in order to make the AR export work.
|
|
34
|
-
* We could theoretically allow it if AR optimization is not desired, but this may confuse the user.
|
|
35
|
-
*/
|
|
36
|
-
protected static _gltfExportOptions(optimizeForAR: boolean, excludeNodes?: NodeDescription[]): IExportOptions {
|
|
37
|
-
return {
|
|
38
|
-
shouldExportNode: function (node: Node): boolean {
|
|
39
|
-
if (optimizeForAR) {
|
|
40
|
-
// we explicitely marked nodes, that should be exported in AR mode
|
|
41
|
-
return !!getInternalMetadataValue(node, 'exportNode');
|
|
42
|
-
} else {
|
|
43
|
-
// use the default export node check (enabled state, exclusion list, etc...)
|
|
44
|
-
return isExportableTransformNode(node, excludeNodes);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
shouldExportAnimation: (animation: Animation) => !optimizeForAR,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** @internal */
|
|
53
|
-
public constructor(protected viewer: Viewer) {
|
|
54
|
-
// store initial max texture size, so that we can restore it in the post processing
|
|
55
|
-
this._maxTextureSize = viewer.engine.getCaps().maxTextureSize;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Exports selected nodes to a file.
|
|
60
|
-
* @param fileName Optional name of the exported .GLB file.
|
|
61
|
-
* @param optimizeForAR Adjusts the exported GLB so that known issues get automatically fixed, this
|
|
62
|
-
* is mostly targeting Apples .usdz format.
|
|
63
|
-
* @param excludeNodes Optional list of nodes to be excluded from the export.
|
|
64
|
-
*/
|
|
65
|
-
public async exportGlb(
|
|
66
|
-
fileName?: string,
|
|
67
|
-
optimizeForAR: boolean = false,
|
|
68
|
-
excludeNodes?: NodeDescription[]
|
|
69
|
-
): Promise<File | undefined> {
|
|
70
|
-
if (optimizeForAR) await exportPreProcess(this.viewer, { excludeNodes, scaleDownTextures: true });
|
|
71
|
-
|
|
72
|
-
const glbData = await GLTF2Export.GLBAsync(
|
|
73
|
-
this.viewer.scene,
|
|
74
|
-
'dummy',
|
|
75
|
-
GltfExportManager._gltfExportOptions(optimizeForAR, excludeNodes)
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
if (optimizeForAR) await exportPostProcess(this.viewer);
|
|
79
|
-
|
|
80
|
-
const resBlob = glbData.glTFFiles['dummy.glb'];
|
|
81
|
-
// check if result is valid, according to the typings this could also be a string
|
|
82
|
-
if (resBlob instanceof Blob) {
|
|
83
|
-
const normalizedFileName = normalizeFileName(fileName, 'glb', 'glb-export');
|
|
84
|
-
return new File([resBlob], normalizedFileName);
|
|
85
|
-
} else {
|
|
86
|
-
// result was not a valid blob
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Exports selected nodes to GLTF. This may result in more than one file, since textures are exported seperately.
|
|
93
|
-
* @param filename Name of the main (text-based) .GLTF file referring to separate texture files.
|
|
94
|
-
* @param optimizeForAR Adjusts the exported GLB so that known issues get automatically fixed, this
|
|
95
|
-
* is mostly targeting Apples .usdz format.
|
|
96
|
-
* @param excludeNodes Optional list of nodes to be excluded from the export.
|
|
97
|
-
*/
|
|
98
|
-
public async exportGltfToFile(
|
|
99
|
-
fileName: string,
|
|
100
|
-
optimizeForAR: boolean = false,
|
|
101
|
-
excludeNodes?: NodeDescription[]
|
|
102
|
-
): Promise<void> {
|
|
103
|
-
if (optimizeForAR) await exportPreProcess(this.viewer, { excludeNodes, scaleDownTextures: true });
|
|
104
|
-
|
|
105
|
-
const gltf = await GLTF2Export.GLTFAsync(
|
|
106
|
-
this.viewer.scene,
|
|
107
|
-
// no need to add .glb, as Babylon.js does that internally
|
|
108
|
-
fileName,
|
|
109
|
-
GltfExportManager._gltfExportOptions(optimizeForAR, excludeNodes)
|
|
110
|
-
);
|
|
111
|
-
gltf.downloadFiles();
|
|
112
|
-
|
|
113
|
-
if (optimizeForAR) await exportPostProcess(this.viewer);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Exports selected nodes to GLB. This results in one binary file.
|
|
118
|
-
* @param fileName Name of the main (text-based) .GLTF file referring to seperate texture files.
|
|
119
|
-
* @param optimizeForAR Adjusts the exported GLB so that known issues get automatically fixed, this
|
|
120
|
-
* is mostly targeting Apples .usdz format.
|
|
121
|
-
* @param excludeNodes Optional list of nodes to be excluded from the export.
|
|
122
|
-
*/
|
|
123
|
-
public async exportGlbToFile(
|
|
124
|
-
fileName: string,
|
|
125
|
-
optimizeForAR: boolean = false,
|
|
126
|
-
excludeNodes?: NodeDescription[]
|
|
127
|
-
): Promise<void> {
|
|
128
|
-
if (optimizeForAR) await exportPreProcess(this.viewer, { excludeNodes, scaleDownTextures: true });
|
|
129
|
-
|
|
130
|
-
const glb = await GLTF2Export.GLBAsync(
|
|
131
|
-
this.viewer.scene,
|
|
132
|
-
fileName,
|
|
133
|
-
GltfExportManager._gltfExportOptions(optimizeForAR, excludeNodes)
|
|
134
|
-
);
|
|
135
|
-
glb.downloadFiles();
|
|
136
|
-
|
|
137
|
-
if (optimizeForAR) await exportPostProcess(this.viewer);
|
|
138
|
-
}
|
|
139
|
-
}
|