@combeenation/3d-viewer 12.2.1 → 12.3.0-beta2
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/util/babylonHelper.js +0 -1
- package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +2 -0
- package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +2 -2
- package/dist/lib-cjs/api/util/sceneLoaderHelper.js +31 -16
- package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +1 -1
- package/dist/lib-cjs/buildinfo.json +1 -1
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/dist/lib-cjs/index.d.ts +14 -5
- package/dist/lib-cjs/index.js +20 -9
- package/dist/lib-cjs/index.js.map +1 -1
- package/package.json +1 -2
- package/src/api/util/babylonHelper.ts +1 -2
- package/src/api/util/globalTypes.ts +2 -0
- package/src/api/util/sceneLoaderHelper.ts +55 -20
- package/src/index.ts +17 -4
package/dist/lib-cjs/index.d.ts
CHANGED
|
@@ -26,10 +26,19 @@ import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
|
|
|
26
26
|
import { Engine } from '@babylonjs/core/Engines/engine';
|
|
27
27
|
import { DirectionalLight } from '@babylonjs/core/Lights/directionalLight';
|
|
28
28
|
import { HemisphericLight } from '@babylonjs/core/Lights/hemisphericLight';
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
import { BackgroundMaterial } from '@babylonjs/core/Materials/Background/backgroundMaterial';
|
|
30
|
+
import { NodeMaterial } from '@babylonjs/core/Materials/Node';
|
|
31
|
+
/**
|
|
32
|
+
* Importing from .../PBR covers all PBR material types, also the deprecated ones like `PBRMetallicRoughnessMaterial`.
|
|
33
|
+
* In this way we can also load models which contain these PBR materials.
|
|
34
|
+
* Still we only actively use `PBRMaterial` in the viewer code base and we also only want to expose this one to the
|
|
35
|
+
* consumer.
|
|
36
|
+
*/
|
|
37
|
+
import { PBRMaterial } from '@babylonjs/core/Materials/PBR';
|
|
38
|
+
/**
|
|
39
|
+
* Same story as for PBR materials, we want to support also textures but only want to expose a few of them
|
|
40
|
+
*/
|
|
41
|
+
import { CubeTexture, DynamicTexture, Texture } from '@babylonjs/core/Materials/Textures';
|
|
33
42
|
import { Material } from '@babylonjs/core/Materials/material';
|
|
34
43
|
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial';
|
|
35
44
|
import { Color3, Color4 } from '@babylonjs/core/Maths/math.color';
|
|
@@ -51,4 +60,4 @@ import { EventEmitter } from 'eventemitter3';
|
|
|
51
60
|
/**
|
|
52
61
|
* Expose some frequently used babylon modules by our consumers.
|
|
53
62
|
*/
|
|
54
|
-
export { AnimationManager, AnimationInterface, Variant, VariantInstanceManager, Viewer, ParameterObservable, Parameterizable, VariantParameterizable, ViewerLight, emitter as Emitter, EventEmitter, Event, Parameter, VariantInstance, Color3, Color4, Vector3, AbstractMesh, InstancedMesh, Mesh, TransformNode, Node, Material, PBRMaterial, StandardMaterial, Scene, Engine, ArcRotateCamera, DynamicTexture, CubeTexture, MeshBuilder, Texture, BabylonAnimation, HemisphericLight, DirectionalLight, Element, EventBroadcaster, SceneManager, PlacementAnimation, BabylonHelper, GltfExportManager, SpecStorage, TagManager, ViewerError, ViewerErrorIds, };
|
|
63
|
+
export { AnimationManager, AnimationInterface, Variant, VariantInstanceManager, Viewer, ParameterObservable, Parameterizable, VariantParameterizable, ViewerLight, emitter as Emitter, EventEmitter, Event, Parameter, VariantInstance, Color3, Color4, Vector3, AbstractMesh, InstancedMesh, Mesh, TransformNode, Node, Material, PBRMaterial, StandardMaterial, NodeMaterial, BackgroundMaterial, Scene, Engine, ArcRotateCamera, DynamicTexture, CubeTexture, MeshBuilder, Texture, BabylonAnimation, HemisphericLight, DirectionalLight, Element, EventBroadcaster, SceneManager, PlacementAnimation, BabylonHelper, GltfExportManager, SpecStorage, TagManager, ViewerError, ViewerErrorIds, };
|
package/dist/lib-cjs/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ViewerErrorIds = exports.ViewerError = exports.TagManager = exports.SpecStorage = exports.GltfExportManager = exports.BabylonHelper = exports.PlacementAnimation = exports.SceneManager = exports.EventBroadcaster = exports.Element = exports.DirectionalLight = exports.HemisphericLight = exports.BabylonAnimation = exports.Texture = exports.MeshBuilder = exports.CubeTexture = exports.DynamicTexture = exports.ArcRotateCamera = exports.Engine = exports.Scene = exports.StandardMaterial = exports.PBRMaterial = exports.Material = exports.Node = exports.TransformNode = exports.Mesh = exports.InstancedMesh = exports.AbstractMesh = exports.Vector3 = exports.Color4 = exports.Color3 = exports.VariantInstance = exports.Parameter = exports.Event = exports.EventEmitter = exports.Emitter = exports.ViewerLight = exports.VariantParameterizable = exports.Parameterizable = exports.ParameterObservable = exports.Viewer = exports.VariantInstanceManager = exports.Variant = exports.AnimationManager = void 0;
|
|
26
|
+
exports.ViewerErrorIds = exports.ViewerError = exports.TagManager = exports.SpecStorage = exports.GltfExportManager = exports.BabylonHelper = exports.PlacementAnimation = exports.SceneManager = exports.EventBroadcaster = exports.Element = exports.DirectionalLight = exports.HemisphericLight = exports.BabylonAnimation = exports.Texture = exports.MeshBuilder = exports.CubeTexture = exports.DynamicTexture = exports.ArcRotateCamera = exports.Engine = exports.Scene = exports.BackgroundMaterial = exports.NodeMaterial = exports.StandardMaterial = exports.PBRMaterial = exports.Material = exports.Node = exports.TransformNode = exports.Mesh = exports.InstancedMesh = exports.AbstractMesh = exports.Vector3 = exports.Color4 = exports.Color3 = exports.VariantInstance = exports.Parameter = exports.Event = exports.EventEmitter = exports.Emitter = exports.ViewerLight = exports.VariantParameterizable = exports.Parameterizable = exports.ParameterObservable = exports.Viewer = exports.VariantInstanceManager = exports.Variant = exports.AnimationManager = void 0;
|
|
27
27
|
const element_1 = require("./api/classes/element");
|
|
28
28
|
Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return element_1.Element; } });
|
|
29
29
|
const event_1 = require("./api/classes/event");
|
|
@@ -76,14 +76,25 @@ const directionalLight_1 = require("@babylonjs/core/Lights/directionalLight");
|
|
|
76
76
|
Object.defineProperty(exports, "DirectionalLight", { enumerable: true, get: function () { return directionalLight_1.DirectionalLight; } });
|
|
77
77
|
const hemisphericLight_1 = require("@babylonjs/core/Lights/hemisphericLight");
|
|
78
78
|
Object.defineProperty(exports, "HemisphericLight", { enumerable: true, get: function () { return hemisphericLight_1.HemisphericLight; } });
|
|
79
|
-
const
|
|
80
|
-
Object.defineProperty(exports, "
|
|
81
|
-
const
|
|
82
|
-
Object.defineProperty(exports, "
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
const backgroundMaterial_1 = require("@babylonjs/core/Materials/Background/backgroundMaterial");
|
|
80
|
+
Object.defineProperty(exports, "BackgroundMaterial", { enumerable: true, get: function () { return backgroundMaterial_1.BackgroundMaterial; } });
|
|
81
|
+
const Node_1 = require("@babylonjs/core/Materials/Node");
|
|
82
|
+
Object.defineProperty(exports, "NodeMaterial", { enumerable: true, get: function () { return Node_1.NodeMaterial; } });
|
|
83
|
+
/**
|
|
84
|
+
* Importing from .../PBR covers all PBR material types, also the deprecated ones like `PBRMetallicRoughnessMaterial`.
|
|
85
|
+
* In this way we can also load models which contain these PBR materials.
|
|
86
|
+
* Still we only actively use `PBRMaterial` in the viewer code base and we also only want to expose this one to the
|
|
87
|
+
* consumer.
|
|
88
|
+
*/
|
|
89
|
+
const PBR_1 = require("@babylonjs/core/Materials/PBR");
|
|
90
|
+
Object.defineProperty(exports, "PBRMaterial", { enumerable: true, get: function () { return PBR_1.PBRMaterial; } });
|
|
91
|
+
/**
|
|
92
|
+
* Same story as for PBR materials, we want to support also textures but only want to expose a few of them
|
|
93
|
+
*/
|
|
94
|
+
const Textures_1 = require("@babylonjs/core/Materials/Textures");
|
|
95
|
+
Object.defineProperty(exports, "CubeTexture", { enumerable: true, get: function () { return Textures_1.CubeTexture; } });
|
|
96
|
+
Object.defineProperty(exports, "DynamicTexture", { enumerable: true, get: function () { return Textures_1.DynamicTexture; } });
|
|
97
|
+
Object.defineProperty(exports, "Texture", { enumerable: true, get: function () { return Textures_1.Texture; } });
|
|
87
98
|
const material_1 = require("@babylonjs/core/Materials/material");
|
|
88
99
|
Object.defineProperty(exports, "Material", { enumerable: true, get: function () { return material_1.Material; } });
|
|
89
100
|
const standardMaterial_1 = require("@babylonjs/core/Materials/standardMaterial");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mDAAgD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mDAAgD;AAqG9C,wFArGO,iBAAO,OAqGP;AApGT,+CAAqD;AA0EnD,sFA1EO,aAAK,OA0EP;AAFM,wFAxEG,eAAO,OAwEH;AAvEpB,qEAAkE;AAoGhE,iGApGO,mCAAgB,OAoGP;AAnGlB,uDAAoD;AAyElD,0FAzEO,qBAAS,OAyEP;AAxEX,2EAAwE;AAiEtE,oGAjEO,yCAAmB,OAiEP;AAhErB,mEAAgE;AAiE9D,gGAjEO,iCAAe,OAiEP;AAhEjB,yEAAsE;AAkGpE,mGAlGO,uCAAkB,OAkGP;AAjGpB,mDAAgD;AA2D9C,wFA3DO,iBAAO,OA2DP;AA1DT,mEAAgE;AAqE9D,gGArEO,iCAAe,OAqEP;AApEjB,iFAA8E;AA8D5E,uGA9DO,+CAAsB,OA8DP;AA7DxB,iDAA8C;AA0D5C,uFA1DO,eAAM,OA0DP;AAzDR,2DAAwE;AAkGtE,4FAlGO,yBAAW,OAkGP;AACX,+FAnGoB,4BAAc,OAmGpB;AAlGhB,2DAAwD;AA4DtD,4FA5DO,yBAAW,OA4DP;AA3Db,qEAAkE;AAmDhE,iGAnDO,mCAAgB,OAmDP;AAlDlB,uEAAoE;AA4FlE,kGA5FO,qCAAiB,OA4FP;AA3FnB,6DAA0D;AAwFxD,6FAxFO,2BAAY,OAwFP;AAvFd,yDAAsD;AA4FpD,2FA5FO,uBAAU,OA4FP;AA3FZ,iFAA8E;AAkD5E,uGAlDO,+CAAsB,OAkDP;AAjDxB,yDAAsD;AAyFpD,4FAzFO,yBAAW,OAyFP;AAxFb,wEAA0D;AAsFxD,sCAAa;AArFf,oEAAqF;AA8EnF,iGA9EoB,qBAAgB,OA8EpB;AA7ElB,6EAA0E;AAwExE,gGAxEO,iCAAe,OAwEP;AAvEjB,2DAAwD;AAsEtD,uFAtEO,eAAM,OAsEP;AArER,8EAA2E;AA6EzE,iGA7EO,mCAAgB,OA6EP;AA5ElB,8EAA2E;AA2EzE,iGA3EO,mCAAgB,OA2EP;AA1ElB,gGAA6F;AAiE3F,mGAjEO,uCAAkB,OAiEP;AAhEpB,yDAA8D;AA+D5D,6FA/DO,mBAAY,OA+DP;AA7Dd;;;;;GAKG;AACH,uDAA4D;AAqD1D,4FArDO,iBAAW,OAqDP;AAnDb;;GAEG;AACH,iEAA0F;AAwDxF,4FAxDO,sBAAW,OAwDP;AADX,+FAvDoB,yBAAc,OAuDpB;AAGd,wFA1DoC,kBAAO,OA0DpC;AAzDT,iEAA8D;AA8C5D,yFA9CO,mBAAQ,OA8CP;AA7CV,iFAA8E;AA+C5E,iGA/CO,mCAAgB,OA+CP;AA9ClB,iEAAkE;AAoChE,uFApCO,mBAAM,OAoCP;AACN,uFArCe,mBAAM,OAqCf;AApCR,mEAA4D;AAqC1D,wFArCO,qBAAO,OAqCP;AApCT,sEAAmE;AAqCjE,6FArCO,2BAAY,OAqCP;AApCd,wEAAqE;AAqCnE,8FArCO,6BAAa,OAqCP;AApCf,sDAAmD;AAqCjD,qFArCO,WAAI,OAqCP;AApCN,oEAAiE;AAiD/D,4FAjDO,yBAAW,OAiDP;AAhDb,wEAAqE;AAoCnE,8FApCO,6BAAa,OAoCP;AAlCf;;;;GAIG;AACH,yDAAuD;AACvD,+CAA4C;AA6B1C,qFA7BO,WAAI,OA6BP;AA5BN,iDAA8C;AAkC5C,sFAlCO,aAAK,OAkCP;AAjCP,iDAA6C;AAgB3C,6FAhBO,4BAAY,OAgBP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combeenation/3d-viewer",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.0-beta2",
|
|
4
4
|
"description": "Combeenation 3D Viewer",
|
|
5
5
|
"homepage": "https://github.com/Combeenation/3d-viewer#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babylonjs/core": "6.27.1",
|
|
50
50
|
"@babylonjs/loaders": "6.27.1",
|
|
51
|
-
"@babylonjs/materials": "6.27.1",
|
|
52
51
|
"@babylonjs/serializers": "6.27.1",
|
|
53
52
|
"eventemitter3": "4.0.7",
|
|
54
53
|
"gsap": "3.11.2",
|
|
@@ -31,7 +31,7 @@ import { Tools } from '@babylonjs/core/Misc/tools';
|
|
|
31
31
|
import { Node } from '@babylonjs/core/node';
|
|
32
32
|
import { Scene } from '@babylonjs/core/scene';
|
|
33
33
|
import { Nullable } from '@babylonjs/core/types';
|
|
34
|
-
import {
|
|
34
|
+
import { get, has, merge, uniq } from 'lodash-es';
|
|
35
35
|
|
|
36
36
|
const backgroundDomeName = 'BackgroundDome_ViewerGenerated';
|
|
37
37
|
const envHelperMetadataName = 'viewerEnvHelper';
|
|
@@ -108,7 +108,6 @@ const cloneTransformNode = function (
|
|
|
108
108
|
const clone = node.clone(newName, node.parent, true);
|
|
109
109
|
if (clone) {
|
|
110
110
|
clone.id = newName;
|
|
111
|
-
clone.metadata = cloneDeep(node.metadata);
|
|
112
111
|
injectMetadata(clone, { cloneSource: node }, false);
|
|
113
112
|
injectMetadata(node, { cloneTarget: clone }, false);
|
|
114
113
|
// if the cloned node is of type InstancedMesh, due to a bug(?),
|
|
@@ -22,6 +22,8 @@ type Color4 = import('@babylonjs/core/Maths/math.color').Color4;
|
|
|
22
22
|
type Material = import('@babylonjs/core/Materials/material').Material;
|
|
23
23
|
type PBRMaterial = import('@babylonjs/core/Materials/PBR/pbrMaterial').PBRMaterial;
|
|
24
24
|
type StandardMaterial = import('@babylonjs/core/Materials/standardMaterial').StandardMaterial;
|
|
25
|
+
type BackgroundMaterial = import('@babylonjs/core/Materials/Background/backgroundMaterial').BackgroundMaterial;
|
|
26
|
+
type NodeMaterial = import('@babylonjs/core/Materials/Node').NodeMaterial;
|
|
25
27
|
type DynamicTexture = import('@babylonjs/core/Materials/Textures/dynamicTexture').DynamicTexture;
|
|
26
28
|
type Mesh = import('@babylonjs/core/Meshes/mesh').Mesh;
|
|
27
29
|
type AbstractMesh = import('@babylonjs/core/Meshes/abstractMesh').AbstractMesh;
|
|
@@ -11,6 +11,7 @@ import { AssetContainer } from '@babylonjs/core/assetContainer';
|
|
|
11
11
|
import { Node as BjsNode } from '@babylonjs/core/node';
|
|
12
12
|
import { Scene } from '@babylonjs/core/scene';
|
|
13
13
|
import { Nullable } from '@babylonjs/core/types';
|
|
14
|
+
import { isArray, isString } from 'lodash-es';
|
|
14
15
|
import has from 'lodash-es/has';
|
|
15
16
|
|
|
16
17
|
// map for keeping track of active "node enable" observers
|
|
@@ -88,26 +89,59 @@ export const getMaterialPostLoadObserver = function (concerningMesh: Mesh) {
|
|
|
88
89
|
};
|
|
89
90
|
};
|
|
90
91
|
|
|
92
|
+
type InstanceData = {
|
|
93
|
+
name: string;
|
|
94
|
+
tags?: string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function _isMeshInstanceData(data: any): data is InstanceData {
|
|
98
|
+
const hasName = isString(data.name);
|
|
99
|
+
const hasValidTags = !data.tags || isString(data.tags);
|
|
100
|
+
return hasName && hasValidTags;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type MeshData = {
|
|
104
|
+
name: string;
|
|
105
|
+
materialId?: string;
|
|
106
|
+
instances?: unknown[];
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
function _isMeshData(data: any): data is MeshData {
|
|
110
|
+
const hasName = isString(data.name);
|
|
111
|
+
const hasValidMaterialId = !data.materialId || isString(data.materialId);
|
|
112
|
+
|
|
113
|
+
return hasName && hasValidMaterialId;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
type DataWithMeshes = { meshes: unknown[] };
|
|
117
|
+
|
|
118
|
+
function _isDataWithMeshes(data: any): data is DataWithMeshes {
|
|
119
|
+
return data && isArray(data.meshes);
|
|
120
|
+
}
|
|
121
|
+
|
|
91
122
|
/**
|
|
92
123
|
* Internal function that compares the original meshes on a .babylon file with what was loaded,
|
|
93
124
|
* and tags missing materials with respective metadata on respective meshes.
|
|
94
125
|
* @param dataParsed original data
|
|
95
126
|
* @param container loaded data
|
|
96
127
|
*/
|
|
97
|
-
export const addMissingMaterialMetadata = function (dataParsed:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
128
|
+
export const addMissingMaterialMetadata = function (dataParsed: unknown, container: AssetContainer) {
|
|
129
|
+
if (!_isDataWithMeshes(dataParsed)) return;
|
|
130
|
+
|
|
131
|
+
const validatedMeshes = dataParsed.meshes.filter(_isMeshData);
|
|
132
|
+
|
|
133
|
+
container.meshes.forEach(importedMesh => {
|
|
134
|
+
const parsedMesh = validatedMeshes.find(mesh => mesh.name === importedMesh.name);
|
|
135
|
+
|
|
136
|
+
// save original material id of the imported babylon or GLB file
|
|
137
|
+
injectMetadata(importedMesh, { [parsedMaterialIdMetadataName]: parsedMesh?.materialId }, false);
|
|
138
|
+
|
|
139
|
+
const materialOnImportedMesh = importedMesh.material?.id;
|
|
140
|
+
const materialOnOriginalMesh = parsedMesh?.materialId;
|
|
141
|
+
|
|
142
|
+
if (materialOnOriginalMesh && materialOnImportedMesh !== materialOnOriginalMesh) {
|
|
108
143
|
window.Cbn?.Assets.assertMaterialExists(materialOnOriginalMesh);
|
|
109
|
-
injectMetadata(
|
|
110
|
-
break;
|
|
144
|
+
injectMetadata(importedMesh, { [missingMaterialMetadataName]: materialOnOriginalMesh }, false);
|
|
111
145
|
}
|
|
112
146
|
});
|
|
113
147
|
};
|
|
@@ -124,7 +158,11 @@ export const addMissingMaterialMetadata = function (dataParsed: any, container:
|
|
|
124
158
|
* @param dataParsed original data
|
|
125
159
|
* @param container loaded data
|
|
126
160
|
*/
|
|
127
|
-
export const reconstructTagsForInstancedMeshes = function (dataParsed:
|
|
161
|
+
export const reconstructTagsForInstancedMeshes = function (dataParsed: unknown, container: AssetContainer) {
|
|
162
|
+
if (!_isDataWithMeshes(dataParsed)) return;
|
|
163
|
+
|
|
164
|
+
const validatedMeshes = dataParsed.meshes.filter(_isMeshData);
|
|
165
|
+
|
|
128
166
|
container.meshes.forEach(importedMesh => {
|
|
129
167
|
if (importedMesh instanceof InstancedMesh) {
|
|
130
168
|
// remove all tags from the imported mesh if there are some, since these tags are probably coming from the
|
|
@@ -134,12 +172,9 @@ export const reconstructTagsForInstancedMeshes = function (dataParsed: any, cont
|
|
|
134
172
|
Tags.RemoveTagsFrom(importedMesh, importedTags);
|
|
135
173
|
|
|
136
174
|
// get tags of parsed instanced mesh and set them on the imported instanced mesh
|
|
137
|
-
const parsedSourceMesh =
|
|
138
|
-
|
|
139
|
-
);
|
|
140
|
-
const parsedInstancedMesh = parsedSourceMesh?.instances.find(
|
|
141
|
-
(parsedMesh: any) => parsedMesh.name === importedMesh.name
|
|
142
|
-
);
|
|
175
|
+
const parsedSourceMesh = validatedMeshes.find(mesh => mesh.name === importedMesh.sourceMesh.name);
|
|
176
|
+
const validatedSourceMeshInstances = parsedSourceMesh?.instances?.filter(_isMeshInstanceData);
|
|
177
|
+
const parsedInstancedMesh = validatedSourceMeshInstances?.find(mesh => mesh.name === importedMesh.name);
|
|
143
178
|
const parsedTags = parsedInstancedMesh?.tags;
|
|
144
179
|
if (parsedTags) {
|
|
145
180
|
Tags.AddTagsTo(importedMesh, parsedTags);
|
package/src/index.ts
CHANGED
|
@@ -27,10 +27,21 @@ import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
|
|
|
27
27
|
import { Engine } from '@babylonjs/core/Engines/engine';
|
|
28
28
|
import { DirectionalLight } from '@babylonjs/core/Lights/directionalLight';
|
|
29
29
|
import { HemisphericLight } from '@babylonjs/core/Lights/hemisphericLight';
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
import { BackgroundMaterial } from '@babylonjs/core/Materials/Background/backgroundMaterial';
|
|
31
|
+
import { NodeMaterial } from '@babylonjs/core/Materials/Node';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Importing from .../PBR covers all PBR material types, also the deprecated ones like `PBRMetallicRoughnessMaterial`.
|
|
35
|
+
* In this way we can also load models which contain these PBR materials.
|
|
36
|
+
* Still we only actively use `PBRMaterial` in the viewer code base and we also only want to expose this one to the
|
|
37
|
+
* consumer.
|
|
38
|
+
*/
|
|
39
|
+
import { PBRMaterial } from '@babylonjs/core/Materials/PBR';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Same story as for PBR materials, we want to support also textures but only want to expose a few of them
|
|
43
|
+
*/
|
|
44
|
+
import { CubeTexture, DynamicTexture, Texture } from '@babylonjs/core/Materials/Textures';
|
|
34
45
|
import { Material } from '@babylonjs/core/Materials/material';
|
|
35
46
|
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial';
|
|
36
47
|
import { Color3, Color4 } from '@babylonjs/core/Maths/math.color';
|
|
@@ -80,6 +91,8 @@ export {
|
|
|
80
91
|
Material,
|
|
81
92
|
PBRMaterial,
|
|
82
93
|
StandardMaterial,
|
|
94
|
+
NodeMaterial,
|
|
95
|
+
BackgroundMaterial,
|
|
83
96
|
Scene,
|
|
84
97
|
Engine,
|
|
85
98
|
ArcRotateCamera,
|