@combeenation/3d-viewer 12.0.0-alpha3 → 12.0.0-alpha4
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/api/manager/gltfExportManager.d.ts +2 -1
- package/dist/lib-cjs/api/manager/gltfExportManager.js +15 -6
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
- package/dist/lib-cjs/buildinfo.json +1 -1
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/api/manager/gltfExportManager.ts +18 -12
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node as BjsNode, Color3, InstancedMesh, PBRMaterial } from '../../index';
|
|
1
|
+
import { Node as BjsNode, Color3, InstancedMesh, PBRMaterial, Vector3 } from '../../index';
|
|
2
2
|
import { Viewer } from '../classes/viewer';
|
|
3
3
|
import { injectMetadata } from '../util/babylonHelper';
|
|
4
4
|
import { bakeGeometryOfMesh, createMeshFromInstancedMesh, resetTransformation } from '../util/geometryHelper';
|
|
@@ -13,6 +13,7 @@ export class GltfExportManager {
|
|
|
13
13
|
deleteAfterExport: 'deleteAfterExport',
|
|
14
14
|
exchangeMaterialWith: 'exchangeMaterialWith',
|
|
15
15
|
};
|
|
16
|
+
protected static readonly _EXPORT_ROOT_NAME = '__export_root__';
|
|
16
17
|
|
|
17
18
|
protected constructor(protected viewer: Viewer) {}
|
|
18
19
|
|
|
@@ -66,8 +67,17 @@ export class GltfExportManager {
|
|
|
66
67
|
.filter(material => this._shouldReplaceMaterial(material))
|
|
67
68
|
.forEach(material => this._createRefractionMaterialReplacement(material as PBRMaterial));
|
|
68
69
|
|
|
70
|
+
const exportRootNode = new TransformNode(GltfExportManager._EXPORT_ROOT_NAME, this.viewer.scene);
|
|
71
|
+
exportRootNode.scaling = new Vector3(-1, 1, 1);
|
|
72
|
+
injectMetadata(exportRootNode!, {
|
|
73
|
+
[GltfExportManager._METADATA_PROPS.exportNode]: true,
|
|
74
|
+
[GltfExportManager._METADATA_PROPS.deleteAfterExport]: true,
|
|
75
|
+
});
|
|
76
|
+
|
|
69
77
|
// handle nodes
|
|
70
|
-
this.viewer.scene.rootNodes
|
|
78
|
+
this.viewer.scene.rootNodes
|
|
79
|
+
.filter(rootNode => rootNode.name !== GltfExportManager._EXPORT_ROOT_NAME)
|
|
80
|
+
.forEach(rootNode => this._prepareNodeForExport(rootNode, exportRootNode, excluded));
|
|
71
81
|
|
|
72
82
|
// bake transformation of all meshes, so that no negative scalings are left
|
|
73
83
|
// it's important that this is done AFTER instanced meshes have been converted (_prepareNodeForExport)
|
|
@@ -78,7 +88,11 @@ export class GltfExportManager {
|
|
|
78
88
|
// reset transformation of all "TransformNodes", which couldn't be handled by the geometry baking algorithm
|
|
79
89
|
// it's important that this is done AFTER all geometries have been baked
|
|
80
90
|
[...this.viewer.scene.transformNodes, ...this.viewer.scene.meshes]
|
|
81
|
-
.filter(
|
|
91
|
+
.filter(
|
|
92
|
+
node =>
|
|
93
|
+
!!node.metadata?.[GltfExportManager._METADATA_PROPS.exportNode] &&
|
|
94
|
+
node.name !== GltfExportManager._EXPORT_ROOT_NAME
|
|
95
|
+
)
|
|
82
96
|
.forEach(node => resetTransformation(node as TransformNode));
|
|
83
97
|
}
|
|
84
98
|
|
|
@@ -100,18 +114,10 @@ export class GltfExportManager {
|
|
|
100
114
|
shouldExportNode: function (node: BjsNode) {
|
|
101
115
|
return !!node.metadata?.[GltfExportManager._METADATA_PROPS.exportNode];
|
|
102
116
|
},
|
|
103
|
-
// keep root node(s)
|
|
104
|
-
// this seems to be important due to the geometry baking and transformation resetting stuff
|
|
105
|
-
// => root node would have no transformation anymore, which seems to be problematic for the import
|
|
106
|
-
removeNoopRootNodes: false,
|
|
107
117
|
};
|
|
108
118
|
}
|
|
109
119
|
|
|
110
|
-
protected _prepareNodeForExport(
|
|
111
|
-
node: BjsNode,
|
|
112
|
-
clonedParent: Nullable<TransformNode>,
|
|
113
|
-
excluded?: ExcludedGeometryList
|
|
114
|
-
) {
|
|
120
|
+
protected _prepareNodeForExport(node: BjsNode, clonedParent: TransformNode, excluded?: ExcludedGeometryList) {
|
|
115
121
|
if (!this._shouldExportNode(node, excluded)) {
|
|
116
122
|
return;
|
|
117
123
|
}
|