@combeenation/3d-viewer 8.0.0 → 8.1.0-alpha1
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/classes/parameter.d.ts +27 -0
- package/dist/lib-cjs/api/classes/parameter.js +27 -0
- package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
- package/dist/lib-cjs/api/classes/variant.d.ts +8 -0
- package/dist/lib-cjs/api/classes/variant.js +12 -0
- package/dist/lib-cjs/api/classes/variant.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewer.d.ts +2 -2
- package/dist/lib-cjs/api/classes/viewer.js +9 -8
- package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
- package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +1 -0
- package/dist/lib-cjs/api/manager/gltfExportManager.js +7 -2
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/tagManager.d.ts +25 -23
- package/dist/lib-cjs/api/manager/tagManager.js +153 -89
- package/dist/lib-cjs/api/manager/tagManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +1 -1
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +5 -7
- package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +1 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +16 -4
- package/dist/lib-cjs/api/util/structureHelper.d.ts +6 -6
- package/dist/lib-cjs/api/util/structureHelper.js +31 -28
- package/dist/lib-cjs/api/util/structureHelper.js.map +1 -1
- package/dist/lib-cjs/buildinfo.json +1 -1
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/api/classes/parameter.ts +30 -0
- package/src/api/classes/variant.ts +14 -0
- package/src/api/classes/viewer.ts +12 -14
- package/src/api/manager/gltfExportManager.ts +8 -3
- package/src/api/manager/tagManager.ts +178 -119
- package/src/api/manager/variantInstanceManager.ts +5 -8
- package/src/api/util/globalTypes.ts +20 -4
- package/src/api/util/structureHelper.ts +29 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combeenation/3d-viewer",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0-alpha1",
|
|
4
4
|
"description": "Combeenation 3D Viewer",
|
|
5
5
|
"homepage": "https://github.com/Combeenation/3d-viewer#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dist-full": "npm run clean-dist && npm run lint && cross-env NODE_ENV='production' webpack --config build/webpack.conf.js --progress && npm run replace-version",
|
|
33
33
|
"docs-local": "typedoc --tsconfig tsconfig.json --media doc/assets --out docs-local",
|
|
34
34
|
"docs-publish": "typedoc --tsconfig tsconfig.json --media doc/assets --out docs",
|
|
35
|
-
"format": "prettier --write
|
|
35
|
+
"format": "prettier --write ./src",
|
|
36
36
|
"generate-profile": "cross-env NODE_ENV='dev' webpack --config build/webpack.conf.js --profile --json > dist/webpack-stats.json",
|
|
37
37
|
"lint": "eslint src/**",
|
|
38
38
|
"pack": "npm run dist-cjs && npm pack",
|
|
@@ -139,6 +139,36 @@ export class Parameter {
|
|
|
139
139
|
*/
|
|
140
140
|
public static readonly ROTATION = 'rotation';
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Mutates the color.
|
|
144
|
+
*
|
|
145
|
+
* Scopes:
|
|
146
|
+
* * {@link Material} via {@link TagManager}
|
|
147
|
+
*
|
|
148
|
+
* @parser {@link parseColor}
|
|
149
|
+
*/
|
|
150
|
+
public static readonly COLOR = 'color';
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Mutates the metallness.
|
|
154
|
+
*
|
|
155
|
+
* Scopes:
|
|
156
|
+
* * {@link Material} via {@link TagManager}
|
|
157
|
+
*
|
|
158
|
+
* @parser {@link parseNumber}
|
|
159
|
+
*/
|
|
160
|
+
public static readonly METALLNESS = 'metallness';
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Mutates the roughness.
|
|
164
|
+
*
|
|
165
|
+
* Scopes:
|
|
166
|
+
* * {@link Material} via {@link TagManager}
|
|
167
|
+
*
|
|
168
|
+
* @parser {@link parseNumber}
|
|
169
|
+
*/
|
|
170
|
+
public static readonly ROUGHNESS = 'roughness';
|
|
171
|
+
|
|
142
172
|
/**
|
|
143
173
|
* Mutates whether a shadow should be casted or not.
|
|
144
174
|
*
|
|
@@ -244,6 +244,20 @@ export class Variant extends Parameterizable {
|
|
|
244
244
|
return this.elements.reduce((a, c) => [...a, ...c.nodesFlat], [] as TransformNode[]);
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
/**
|
|
248
|
+
* The cloned Meshes of all {@link Element}s created for this {@link Variant} flattened.
|
|
249
|
+
*/
|
|
250
|
+
get elementMeshesFlat(): Mesh[] {
|
|
251
|
+
return this.elements.reduce((a, c) => [...a, ...c.meshesFlat], [] as Mesh[]);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* The cloned Meshes of all {@link Element}s created for this {@link Variant} flattened.
|
|
256
|
+
*/
|
|
257
|
+
get elementAbstractMeshesFlat(): AbstractMesh[] {
|
|
258
|
+
return this.elements.reduce((a, c) => [...a, ...c.abstractMeshesFlat], [] as AbstractMesh[]);
|
|
259
|
+
}
|
|
260
|
+
|
|
247
261
|
/**
|
|
248
262
|
* All {@link Element}s from this {@link Variant}'s parents.
|
|
249
263
|
*/
|
|
@@ -10,7 +10,7 @@ import { backgroundDomeName, envHelperMetadataName } from '../util/babylonHelper
|
|
|
10
10
|
import { debounce, loadJavascript, loadJson } from '../util/resourceHelper';
|
|
11
11
|
import { getCustomCbnBabylonLoaderPlugin } from '../util/sceneLoaderHelper';
|
|
12
12
|
import { replaceDots } from '../util/stringHelper';
|
|
13
|
-
import {
|
|
13
|
+
import { isNodeIncludedInExclusionList } from '../util/structureHelper';
|
|
14
14
|
import * as Index from './../../index';
|
|
15
15
|
import { AnimationInterface } from './animationInterface';
|
|
16
16
|
import { Event } from './event';
|
|
@@ -35,7 +35,7 @@ import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
|
35
35
|
import { ScreenshotTools } from '@babylonjs/core/Misc/screenshotTools';
|
|
36
36
|
import { WebXRSessionManager } from '@babylonjs/core/XR/webXRSessionManager';
|
|
37
37
|
import { Scene } from '@babylonjs/core/scene';
|
|
38
|
-
import {
|
|
38
|
+
import { isString } from 'lodash-es';
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* The main exposed object. This is the entry point into the application
|
|
@@ -308,6 +308,10 @@ export class Viewer extends EventBroadcaster {
|
|
|
308
308
|
indexJson.scene = sceneJson;
|
|
309
309
|
}
|
|
310
310
|
this._scene = await this.initScene();
|
|
311
|
+
// set initial tag manager parameter values
|
|
312
|
+
if (tagManagerParameterValues) {
|
|
313
|
+
await this.tagManager.setParameterValues(tagManagerParameterValues);
|
|
314
|
+
}
|
|
311
315
|
// create instance manager
|
|
312
316
|
this._variantInstances = await VariantInstanceManager.create(this);
|
|
313
317
|
// create optional default instances
|
|
@@ -317,7 +321,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
317
321
|
indexJson.setup = setupJson;
|
|
318
322
|
}
|
|
319
323
|
this.printInstanceDefinitions(indexJson.setup);
|
|
320
|
-
await this.createVariantInstances(
|
|
324
|
+
await this.createVariantInstances();
|
|
321
325
|
}
|
|
322
326
|
this.broadcastEvent(Event.VARIANT_INSTANCES_READY, this);
|
|
323
327
|
// create gltf export manager
|
|
@@ -486,7 +490,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
486
490
|
// ignore meshes with infinite distance, typically these are sky boxes
|
|
487
491
|
const hasInfiniteDistance = mesh.infiniteDistance;
|
|
488
492
|
// ignore excluded meshes
|
|
489
|
-
const isExcluded = excludeGeometry ?
|
|
493
|
+
const isExcluded = excludeGeometry ? isNodeIncludedInExclusionList(mesh, excludeGeometry) : false;
|
|
490
494
|
return isEnabled && isNotBBoxMesh && hasValidBBoxInfo && !hasInfiniteDistance && !isExcluded;
|
|
491
495
|
})
|
|
492
496
|
.reduce(
|
|
@@ -579,7 +583,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
579
583
|
* Resets everything by calling {@link destroy} to clear all references and {@link bootstrap} to setup a clean
|
|
580
584
|
* environment
|
|
581
585
|
*/
|
|
582
|
-
public async reset(tagManagerParameterValues
|
|
586
|
+
public async reset(tagManagerParameterValues?: TagManagerParameterValue[]): Promise<Viewer> {
|
|
583
587
|
await this.destroy();
|
|
584
588
|
return this.bootstrap(tagManagerParameterValues);
|
|
585
589
|
}
|
|
@@ -723,7 +727,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
723
727
|
this._cloneMaterialsOnMutation = sceneJson.cloneMaterialsOnMutation;
|
|
724
728
|
}
|
|
725
729
|
// register observers for tag manager
|
|
726
|
-
this.tagManager.
|
|
730
|
+
this.tagManager.registerNewObjectObservers(scene);
|
|
727
731
|
this.broadcastEvent(Event.SCENE_PROCESSING_END, scene);
|
|
728
732
|
return scene;
|
|
729
733
|
}
|
|
@@ -743,15 +747,10 @@ export class Viewer extends EventBroadcaster {
|
|
|
743
747
|
/**
|
|
744
748
|
* Batch creation of multiple {@link VariantInstance} objects with a {@link SetupJson} object passed
|
|
745
749
|
*/
|
|
746
|
-
protected async createVariantInstances(
|
|
747
|
-
tagManagerParameterValues?: TagManagerParameterValue[]
|
|
748
|
-
): Promise<VariantInstance[]> {
|
|
750
|
+
protected async createVariantInstances(): Promise<VariantInstance[]> {
|
|
749
751
|
const setupJson = SpecStorage.get<SetupJson>('setup');
|
|
750
752
|
const instances: VariantInstance[] = [];
|
|
751
753
|
for (const instanceDefinition of setupJson.instances) {
|
|
752
|
-
if (isArray(tagManagerParameterValues)) {
|
|
753
|
-
instanceDefinition.tagManagerParameterValues = tagManagerParameterValues;
|
|
754
|
-
}
|
|
755
754
|
// don't create the instance right away if `lazy` is set, register it for later creation (on first usage) instead
|
|
756
755
|
// however if the variant should be `visible` by default, `lazy` loading doesn't make sense and should therefore
|
|
757
756
|
// be overruled by the `visible` flag
|
|
@@ -762,8 +761,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
762
761
|
const instance = await this.variantInstances.create(
|
|
763
762
|
instanceDefinition.variant,
|
|
764
763
|
instanceDefinition.name,
|
|
765
|
-
instanceDefinition.parameters
|
|
766
|
-
instanceDefinition.tagManagerParameterValues
|
|
764
|
+
instanceDefinition.parameters
|
|
767
765
|
);
|
|
768
766
|
instances.push(instance);
|
|
769
767
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Viewer } from '../classes/viewer';
|
|
2
|
-
import {
|
|
2
|
+
import { injectNodeMetadata } from '../util/babylonHelper';
|
|
3
|
+
import { isNodeIncludedInExclusionList } from '../util/structureHelper';
|
|
3
4
|
import { Engine } from '@babylonjs/core/Engines/engine';
|
|
4
5
|
import { SceneLoader } from '@babylonjs/core/Loading/sceneLoader';
|
|
5
6
|
import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
|
|
@@ -15,6 +16,7 @@ import { has, merge } from 'lodash-es';
|
|
|
15
16
|
type MetadataMap = { [key: string]: any };
|
|
16
17
|
export class GltfExportManager {
|
|
17
18
|
protected static readonly _CLONED_FROM_MAT_METADATA_PROPERTY = 'clonedFrom';
|
|
19
|
+
public static readonly NAME_BEFORE_EXPORT_METADATA_PROPERTY = 'nameBeforeExport';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Constructor.
|
|
@@ -111,7 +113,7 @@ export class GltfExportManager {
|
|
|
111
113
|
if ((node.name as string).startsWith(Viewer.BOUNDING_BOX_NAME)) {
|
|
112
114
|
return false;
|
|
113
115
|
}
|
|
114
|
-
if (excluded && node instanceof
|
|
116
|
+
if (excluded && node instanceof TransformNode && isNodeIncludedInExclusionList(node, excluded)) {
|
|
115
117
|
return false;
|
|
116
118
|
}
|
|
117
119
|
return true;
|
|
@@ -268,7 +270,10 @@ export class GltfExportManager {
|
|
|
268
270
|
*/
|
|
269
271
|
protected setUniqueMeshNames(scene: Scene): void {
|
|
270
272
|
const allNodes = scene.getNodes().filter(node => node instanceof TransformNode) as TransformNode[];
|
|
271
|
-
allNodes.forEach(currMesh =>
|
|
273
|
+
allNodes.forEach(currMesh => {
|
|
274
|
+
injectNodeMetadata(currMesh, { [GltfExportManager.NAME_BEFORE_EXPORT_METADATA_PROPERTY]: currMesh.name }, false);
|
|
275
|
+
currMesh.name = `${currMesh.name}_${currMesh.uniqueId}`;
|
|
276
|
+
});
|
|
272
277
|
}
|
|
273
278
|
|
|
274
279
|
/**
|