@babylonjs/viewer 5.0.0 → 5.0.3
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/configuration/configuration.d.ts +107 -107
- package/configuration/configuration.js +15 -15
- package/configuration/configurationCompatibility.d.ts +8 -8
- package/configuration/configurationCompatibility.js +65 -65
- package/configuration/configurationContainer.d.ts +10 -10
- package/configuration/configurationContainer.js +9 -9
- package/configuration/globals.d.ts +6 -6
- package/configuration/globals.js +17 -17
- package/configuration/index.d.ts +2 -2
- package/configuration/index.js +3 -3
- package/configuration/interfaces/cameraConfiguration.d.ts +31 -31
- package/configuration/interfaces/cameraConfiguration.js +1 -1
- package/configuration/interfaces/colorGradingConfiguration.d.ts +81 -81
- package/configuration/interfaces/colorGradingConfiguration.js +1 -1
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.d.ts +20 -20
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.js +1 -1
- package/configuration/interfaces/environmentMapConfiguration.d.ts +22 -22
- package/configuration/interfaces/environmentMapConfiguration.js +1 -1
- package/configuration/interfaces/groundConfiguration.d.ts +24 -24
- package/configuration/interfaces/groundConfiguration.js +1 -1
- package/configuration/interfaces/imageProcessingConfiguration.d.ts +43 -43
- package/configuration/interfaces/imageProcessingConfiguration.js +1 -1
- package/configuration/interfaces/index.d.ts +15 -15
- package/configuration/interfaces/index.js +15 -15
- package/configuration/interfaces/lightConfiguration.d.ts +60 -60
- package/configuration/interfaces/lightConfiguration.js +1 -1
- package/configuration/interfaces/modelAnimationConfiguration.d.ts +26 -26
- package/configuration/interfaces/modelAnimationConfiguration.js +1 -1
- package/configuration/interfaces/modelConfiguration.d.ts +65 -65
- package/configuration/interfaces/modelConfiguration.js +1 -1
- package/configuration/interfaces/observersConfiguration.d.ts +5 -5
- package/configuration/interfaces/observersConfiguration.js +1 -1
- package/configuration/interfaces/sceneConfiguration.d.ts +48 -48
- package/configuration/interfaces/sceneConfiguration.js +1 -1
- package/configuration/interfaces/sceneOptimizerConfiguration.d.ts +23 -23
- package/configuration/interfaces/sceneOptimizerConfiguration.js +1 -1
- package/configuration/interfaces/skyboxConfiguration.d.ts +21 -21
- package/configuration/interfaces/skyboxConfiguration.js +1 -1
- package/configuration/interfaces/templateConfiguration.d.ts +67 -67
- package/configuration/interfaces/templateConfiguration.js +1 -1
- package/configuration/interfaces/vrConfiguration.d.ts +16 -16
- package/configuration/interfaces/vrConfiguration.js +1 -1
- package/configuration/loader.d.ts +4 -4
- package/configuration/loader.js +16 -16
- package/configuration/mappers.d.ts +42 -42
- package/configuration/mappers.js +190 -190
- package/configuration/renderOnlyLoader.d.ts +33 -33
- package/configuration/renderOnlyLoader.js +161 -161
- package/configuration/types/default.d.ts +6 -6
- package/configuration/types/default.js +120 -120
- package/configuration/types/environmentMap.d.ts +5 -5
- package/configuration/types/environmentMap.js +13 -13
- package/configuration/types/extended.d.ts +6 -6
- package/configuration/types/extended.js +316 -316
- package/configuration/types/index.d.ts +13 -13
- package/configuration/types/index.js +49 -49
- package/configuration/types/minimal.d.ts +6 -6
- package/configuration/types/minimal.js +42 -42
- package/configuration/types/renderOnlyDefault.d.ts +30 -30
- package/configuration/types/renderOnlyDefault.js +30 -30
- package/configuration/types/shadowLight.d.ts +9 -9
- package/configuration/types/shadowLight.js +63 -63
- package/helper/index.d.ts +26 -26
- package/helper/index.js +62 -62
- package/index.d.ts +30 -30
- package/index.js +45 -45
- package/initializer.d.ts +11 -11
- package/initializer.js +34 -34
- package/interfaces.d.ts +5 -5
- package/interfaces.js +1 -1
- package/labs/environmentSerializer.d.ts +126 -126
- package/labs/environmentSerializer.js +190 -190
- package/labs/texture.d.ts +183 -183
- package/labs/texture.js +300 -300
- package/labs/viewerLabs.d.ts +51 -51
- package/labs/viewerLabs.js +133 -133
- package/loader/modelLoader.d.ts +47 -47
- package/loader/modelLoader.js +189 -189
- package/loader/plugins/applyMaterialConfig.d.ts +12 -12
- package/loader/plugins/applyMaterialConfig.js +15 -15
- package/loader/plugins/extendedMaterialLoaderPlugin.d.ts +9 -9
- package/loader/plugins/extendedMaterialLoaderPlugin.js +15 -15
- package/loader/plugins/index.d.ts +18 -18
- package/loader/plugins/index.js +42 -42
- package/loader/plugins/loaderPlugin.d.ts +24 -24
- package/loader/plugins/loaderPlugin.js +1 -1
- package/loader/plugins/msftLodLoaderPlugin.d.ts +12 -12
- package/loader/plugins/msftLodLoaderPlugin.js +20 -20
- package/loader/plugins/telemetryLoaderPlugin.d.ts +12 -12
- package/loader/plugins/telemetryLoaderPlugin.js +35 -35
- package/managers/observablesManager.d.ts +66 -66
- package/managers/observablesManager.js +34 -34
- package/managers/sceneManager.d.ts +243 -243
- package/managers/sceneManager.js +1388 -1388
- package/managers/telemetryManager.d.ts +57 -57
- package/managers/telemetryManager.js +113 -113
- package/model/modelAnimation.d.ts +215 -215
- package/model/modelAnimation.js +232 -232
- package/model/viewerModel.d.ts +228 -228
- package/model/viewerModel.js +669 -669
- package/optimizer/custom/extended.d.ts +11 -11
- package/optimizer/custom/extended.js +98 -98
- package/optimizer/custom/index.d.ts +8 -8
- package/optimizer/custom/index.js +24 -24
- package/package.json +5 -5
- package/renderOnlyIndex.d.ts +11 -11
- package/renderOnlyIndex.js +17 -17
- package/templating/eventManager.d.ts +35 -35
- package/templating/eventManager.js +65 -65
- package/templating/plugins/hdButtonPlugin.d.ts +9 -9
- package/templating/plugins/hdButtonPlugin.js +21 -21
- package/templating/plugins/printButton.d.ts +9 -9
- package/templating/plugins/printButton.js +40 -40
- package/templating/templateManager.d.ts +190 -190
- package/templating/templateManager.js +553 -553
- package/templating/viewerTemplatePlugin.d.ts +21 -21
- package/templating/viewerTemplatePlugin.js +68 -68
- package/viewer/defaultViewer.d.ts +122 -122
- package/viewer/defaultViewer.js +665 -665
- package/viewer/renderOnlyViewer.d.ts +8 -8
- package/viewer/renderOnlyViewer.js +43 -43
- package/viewer/viewer.d.ts +254 -254
- package/viewer/viewer.js +777 -777
- package/viewer/viewerManager.d.ts +55 -55
- package/viewer/viewerManager.js +87 -87
- package/viewer/viewerWithTemplate.d.ts +9 -9
- package/viewer/viewerWithTemplate.js +19 -19
package/loader/modelLoader.js
CHANGED
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
import { GLTFLoaderAnimationStartMode } from "@babylonjs/loaders/glTF/glTFFileLoader.js";
|
|
2
|
-
import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader.js";
|
|
3
|
-
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
4
|
-
import { Tags } from "@babylonjs/core/Misc/tags.js";
|
|
5
|
-
import { ModelState, ViewerModel } from "../model/viewerModel.js";
|
|
6
|
-
import { getLoaderPluginByName } from "./plugins/index.js";
|
|
7
|
-
import "@babylonjs/loaders/glTF/index.js";
|
|
8
|
-
import "@babylonjs/core/Loading/Plugins/babylonFileLoader.js";
|
|
9
|
-
/**
|
|
10
|
-
* An instance of the class is in charge of loading the model correctly.
|
|
11
|
-
* This class will continuously be expended with tasks required from the specific loaders Babylon has.
|
|
12
|
-
*
|
|
13
|
-
* A Model loader is unique per (Abstract)Viewer. It is being generated by the viewer
|
|
14
|
-
*/
|
|
15
|
-
var ModelLoader = /** @class */ (function () {
|
|
16
|
-
/**
|
|
17
|
-
* Create a new Model loader
|
|
18
|
-
* @param _observablesManager
|
|
19
|
-
* @param _configurationContainer
|
|
20
|
-
*/
|
|
21
|
-
function ModelLoader(_observablesManager, _configurationContainer) {
|
|
22
|
-
this._observablesManager = _observablesManager;
|
|
23
|
-
this._configurationContainer = _configurationContainer;
|
|
24
|
-
this._disposed = false;
|
|
25
|
-
this._loaders = [];
|
|
26
|
-
this._loadId = 0;
|
|
27
|
-
this._plugins = [];
|
|
28
|
-
}
|
|
29
|
-
Object.defineProperty(ModelLoader.prototype, "baseUrl", {
|
|
30
|
-
get: function () {
|
|
31
|
-
return this._baseUrl;
|
|
32
|
-
},
|
|
33
|
-
enumerable: false,
|
|
34
|
-
configurable: true
|
|
35
|
-
});
|
|
36
|
-
/**
|
|
37
|
-
* Adds a new plugin to the loader process.
|
|
38
|
-
*
|
|
39
|
-
* @param plugin the plugin name or the plugin itself
|
|
40
|
-
*/
|
|
41
|
-
ModelLoader.prototype.addPlugin = function (plugin) {
|
|
42
|
-
var actualPlugin = {};
|
|
43
|
-
if (typeof plugin === "string") {
|
|
44
|
-
var loadedPlugin = getLoaderPluginByName(plugin);
|
|
45
|
-
if (loadedPlugin) {
|
|
46
|
-
actualPlugin = loadedPlugin;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
actualPlugin = plugin;
|
|
51
|
-
}
|
|
52
|
-
if (actualPlugin && this._plugins.indexOf(actualPlugin) === -1) {
|
|
53
|
-
this._plugins.push(actualPlugin);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Load a model using predefined configuration
|
|
58
|
-
* @param modelConfiguration the modelConfiguration to use to load the model
|
|
59
|
-
*/
|
|
60
|
-
ModelLoader.prototype.load = function (modelConfiguration) {
|
|
61
|
-
var _this = this;
|
|
62
|
-
var model = new ViewerModel(this._observablesManager, modelConfiguration, this._configurationContainer);
|
|
63
|
-
model.loadId = this._loadId++;
|
|
64
|
-
var filename;
|
|
65
|
-
if (modelConfiguration.file) {
|
|
66
|
-
this._baseUrl = "file:";
|
|
67
|
-
filename = modelConfiguration.file;
|
|
68
|
-
}
|
|
69
|
-
else if (modelConfiguration.url) {
|
|
70
|
-
filename = Tools.GetFilename(modelConfiguration.url) || modelConfiguration.url;
|
|
71
|
-
this._baseUrl = modelConfiguration.root || Tools.GetFolderPath(modelConfiguration.url);
|
|
72
|
-
}
|
|
73
|
-
if (!filename || !this._baseUrl) {
|
|
74
|
-
model.state = ModelState.ERROR;
|
|
75
|
-
Tools.Error("No URL provided");
|
|
76
|
-
return model;
|
|
77
|
-
}
|
|
78
|
-
var plugin = modelConfiguration.loader;
|
|
79
|
-
var scene = model.rootMesh.getScene();
|
|
80
|
-
model.loader = SceneLoader.ImportMesh(undefined, this._baseUrl, filename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
|
|
81
|
-
meshes.forEach(function (mesh) {
|
|
82
|
-
Tags.AddTagsTo(mesh, "viewerMesh");
|
|
83
|
-
model.addMesh(mesh);
|
|
84
|
-
});
|
|
85
|
-
model.particleSystems = particleSystems;
|
|
86
|
-
model.skeletons = skeletons;
|
|
87
|
-
for (var _i = 0, animationGroups_1 = animationGroups; _i < animationGroups_1.length; _i++) {
|
|
88
|
-
var animationGroup = animationGroups_1[_i];
|
|
89
|
-
model.addAnimationGroup(animationGroup);
|
|
90
|
-
}
|
|
91
|
-
_this._checkAndRun("onLoaded", model);
|
|
92
|
-
scene.executeWhenReady(function () {
|
|
93
|
-
model.onLoadedObservable.notifyObservers(model);
|
|
94
|
-
});
|
|
95
|
-
}, function (progressEvent) {
|
|
96
|
-
_this._checkAndRun("onProgress", progressEvent);
|
|
97
|
-
model.onLoadProgressObservable.notifyObserversWithPromise(progressEvent);
|
|
98
|
-
}, function (scene, m, exception) {
|
|
99
|
-
model.state = ModelState.ERROR;
|
|
100
|
-
Tools.Error("Load Error: There was an error loading the model. " + m);
|
|
101
|
-
_this._checkAndRun("onError", m, exception);
|
|
102
|
-
model.onLoadErrorObservable.notifyObserversWithPromise({ message: m, exception: exception });
|
|
103
|
-
}, plugin);
|
|
104
|
-
if (model.loader.name === "gltf") {
|
|
105
|
-
var gltfLoader_1 = model.loader;
|
|
106
|
-
gltfLoader_1.animationStartMode = GLTFLoaderAnimationStartMode.NONE;
|
|
107
|
-
gltfLoader_1.compileMaterials = true;
|
|
108
|
-
if (!modelConfiguration.file) {
|
|
109
|
-
gltfLoader_1.rewriteRootURL = function (rootURL, responseURL) {
|
|
110
|
-
return modelConfiguration.root || Tools.GetFolderPath(responseURL || modelConfiguration.url || "");
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
// if ground is set to "mirror":
|
|
114
|
-
if (this._configurationContainer &&
|
|
115
|
-
this._configurationContainer.configuration &&
|
|
116
|
-
this._configurationContainer.configuration.ground &&
|
|
117
|
-
typeof this._configurationContainer.configuration.ground === "object" &&
|
|
118
|
-
this._configurationContainer.configuration.ground.mirror) {
|
|
119
|
-
gltfLoader_1.useClipPlane = true;
|
|
120
|
-
}
|
|
121
|
-
Object.keys(gltfLoader_1)
|
|
122
|
-
.filter(function (name) { return name.indexOf("on") === 0 && name.indexOf("Observable") !== -1; })
|
|
123
|
-
.forEach(function (functionName) {
|
|
124
|
-
gltfLoader_1[functionName].add(function (payload) {
|
|
125
|
-
_this._checkAndRun(functionName.replace("Observable", ""), payload);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
gltfLoader_1.onParsedObservable.add(function (data) {
|
|
129
|
-
if (data && data.json && data.json["asset"]) {
|
|
130
|
-
model.loadInfo = data.json["asset"];
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
gltfLoader_1.onCompleteObservable.add(function () {
|
|
134
|
-
model.loaderDone = true;
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
model.loaderDone = true;
|
|
139
|
-
}
|
|
140
|
-
this._checkAndRun("onInit", model.loader, model);
|
|
141
|
-
this._loaders.push(model.loader);
|
|
142
|
-
return model;
|
|
143
|
-
};
|
|
144
|
-
ModelLoader.prototype.cancelLoad = function (model) {
|
|
145
|
-
var loader = model.loader || this._loaders[model.loadId];
|
|
146
|
-
// ATM only available in the GLTF Loader
|
|
147
|
-
if (loader && loader.name === "gltf") {
|
|
148
|
-
var gltfLoader = loader;
|
|
149
|
-
gltfLoader.dispose();
|
|
150
|
-
model.state = ModelState.CANCELED;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
Tools.Warn("This type of loader cannot cancel the request");
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* dispose the model loader.
|
|
158
|
-
* If loaders are registered and are in the middle of loading, they will be disposed and the request(s) will be cancelled.
|
|
159
|
-
*/
|
|
160
|
-
ModelLoader.prototype.dispose = function () {
|
|
161
|
-
this._loaders.forEach(function (loader) {
|
|
162
|
-
if (loader.name === "gltf") {
|
|
163
|
-
loader.dispose();
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
this._loaders.length = 0;
|
|
167
|
-
this._disposed = true;
|
|
168
|
-
};
|
|
169
|
-
ModelLoader.prototype._checkAndRun = function (functionName) {
|
|
170
|
-
var _this = this;
|
|
171
|
-
var payload = [];
|
|
172
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
173
|
-
payload[_i - 1] = arguments[_i];
|
|
174
|
-
}
|
|
175
|
-
if (this._disposed) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
this._plugins
|
|
179
|
-
.filter(function (p) { return p[functionName]; })
|
|
180
|
-
.forEach(function (plugin) {
|
|
181
|
-
try {
|
|
182
|
-
plugin[functionName].apply(_this, payload);
|
|
183
|
-
}
|
|
184
|
-
catch (e) { }
|
|
185
|
-
});
|
|
186
|
-
};
|
|
187
|
-
return ModelLoader;
|
|
188
|
-
}());
|
|
189
|
-
export { ModelLoader };
|
|
1
|
+
import { GLTFLoaderAnimationStartMode } from "@babylonjs/loaders/glTF/glTFFileLoader.js";
|
|
2
|
+
import { SceneLoader } from "@babylonjs/core/Loading/sceneLoader.js";
|
|
3
|
+
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
4
|
+
import { Tags } from "@babylonjs/core/Misc/tags.js";
|
|
5
|
+
import { ModelState, ViewerModel } from "../model/viewerModel.js";
|
|
6
|
+
import { getLoaderPluginByName } from "./plugins/index.js";
|
|
7
|
+
import "@babylonjs/loaders/glTF/index.js";
|
|
8
|
+
import "@babylonjs/core/Loading/Plugins/babylonFileLoader.js";
|
|
9
|
+
/**
|
|
10
|
+
* An instance of the class is in charge of loading the model correctly.
|
|
11
|
+
* This class will continuously be expended with tasks required from the specific loaders Babylon has.
|
|
12
|
+
*
|
|
13
|
+
* A Model loader is unique per (Abstract)Viewer. It is being generated by the viewer
|
|
14
|
+
*/
|
|
15
|
+
var ModelLoader = /** @class */ (function () {
|
|
16
|
+
/**
|
|
17
|
+
* Create a new Model loader
|
|
18
|
+
* @param _observablesManager
|
|
19
|
+
* @param _configurationContainer
|
|
20
|
+
*/
|
|
21
|
+
function ModelLoader(_observablesManager, _configurationContainer) {
|
|
22
|
+
this._observablesManager = _observablesManager;
|
|
23
|
+
this._configurationContainer = _configurationContainer;
|
|
24
|
+
this._disposed = false;
|
|
25
|
+
this._loaders = [];
|
|
26
|
+
this._loadId = 0;
|
|
27
|
+
this._plugins = [];
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(ModelLoader.prototype, "baseUrl", {
|
|
30
|
+
get: function () {
|
|
31
|
+
return this._baseUrl;
|
|
32
|
+
},
|
|
33
|
+
enumerable: false,
|
|
34
|
+
configurable: true
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Adds a new plugin to the loader process.
|
|
38
|
+
*
|
|
39
|
+
* @param plugin the plugin name or the plugin itself
|
|
40
|
+
*/
|
|
41
|
+
ModelLoader.prototype.addPlugin = function (plugin) {
|
|
42
|
+
var actualPlugin = {};
|
|
43
|
+
if (typeof plugin === "string") {
|
|
44
|
+
var loadedPlugin = getLoaderPluginByName(plugin);
|
|
45
|
+
if (loadedPlugin) {
|
|
46
|
+
actualPlugin = loadedPlugin;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
actualPlugin = plugin;
|
|
51
|
+
}
|
|
52
|
+
if (actualPlugin && this._plugins.indexOf(actualPlugin) === -1) {
|
|
53
|
+
this._plugins.push(actualPlugin);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Load a model using predefined configuration
|
|
58
|
+
* @param modelConfiguration the modelConfiguration to use to load the model
|
|
59
|
+
*/
|
|
60
|
+
ModelLoader.prototype.load = function (modelConfiguration) {
|
|
61
|
+
var _this = this;
|
|
62
|
+
var model = new ViewerModel(this._observablesManager, modelConfiguration, this._configurationContainer);
|
|
63
|
+
model.loadId = this._loadId++;
|
|
64
|
+
var filename;
|
|
65
|
+
if (modelConfiguration.file) {
|
|
66
|
+
this._baseUrl = "file:";
|
|
67
|
+
filename = modelConfiguration.file;
|
|
68
|
+
}
|
|
69
|
+
else if (modelConfiguration.url) {
|
|
70
|
+
filename = Tools.GetFilename(modelConfiguration.url) || modelConfiguration.url;
|
|
71
|
+
this._baseUrl = modelConfiguration.root || Tools.GetFolderPath(modelConfiguration.url);
|
|
72
|
+
}
|
|
73
|
+
if (!filename || !this._baseUrl) {
|
|
74
|
+
model.state = ModelState.ERROR;
|
|
75
|
+
Tools.Error("No URL provided");
|
|
76
|
+
return model;
|
|
77
|
+
}
|
|
78
|
+
var plugin = modelConfiguration.loader;
|
|
79
|
+
var scene = model.rootMesh.getScene();
|
|
80
|
+
model.loader = SceneLoader.ImportMesh(undefined, this._baseUrl, filename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
|
|
81
|
+
meshes.forEach(function (mesh) {
|
|
82
|
+
Tags.AddTagsTo(mesh, "viewerMesh");
|
|
83
|
+
model.addMesh(mesh);
|
|
84
|
+
});
|
|
85
|
+
model.particleSystems = particleSystems;
|
|
86
|
+
model.skeletons = skeletons;
|
|
87
|
+
for (var _i = 0, animationGroups_1 = animationGroups; _i < animationGroups_1.length; _i++) {
|
|
88
|
+
var animationGroup = animationGroups_1[_i];
|
|
89
|
+
model.addAnimationGroup(animationGroup);
|
|
90
|
+
}
|
|
91
|
+
_this._checkAndRun("onLoaded", model);
|
|
92
|
+
scene.executeWhenReady(function () {
|
|
93
|
+
model.onLoadedObservable.notifyObservers(model);
|
|
94
|
+
});
|
|
95
|
+
}, function (progressEvent) {
|
|
96
|
+
_this._checkAndRun("onProgress", progressEvent);
|
|
97
|
+
model.onLoadProgressObservable.notifyObserversWithPromise(progressEvent);
|
|
98
|
+
}, function (scene, m, exception) {
|
|
99
|
+
model.state = ModelState.ERROR;
|
|
100
|
+
Tools.Error("Load Error: There was an error loading the model. " + m);
|
|
101
|
+
_this._checkAndRun("onError", m, exception);
|
|
102
|
+
model.onLoadErrorObservable.notifyObserversWithPromise({ message: m, exception: exception });
|
|
103
|
+
}, plugin);
|
|
104
|
+
if (model.loader.name === "gltf") {
|
|
105
|
+
var gltfLoader_1 = model.loader;
|
|
106
|
+
gltfLoader_1.animationStartMode = GLTFLoaderAnimationStartMode.NONE;
|
|
107
|
+
gltfLoader_1.compileMaterials = true;
|
|
108
|
+
if (!modelConfiguration.file) {
|
|
109
|
+
gltfLoader_1.rewriteRootURL = function (rootURL, responseURL) {
|
|
110
|
+
return modelConfiguration.root || Tools.GetFolderPath(responseURL || modelConfiguration.url || "");
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// if ground is set to "mirror":
|
|
114
|
+
if (this._configurationContainer &&
|
|
115
|
+
this._configurationContainer.configuration &&
|
|
116
|
+
this._configurationContainer.configuration.ground &&
|
|
117
|
+
typeof this._configurationContainer.configuration.ground === "object" &&
|
|
118
|
+
this._configurationContainer.configuration.ground.mirror) {
|
|
119
|
+
gltfLoader_1.useClipPlane = true;
|
|
120
|
+
}
|
|
121
|
+
Object.keys(gltfLoader_1)
|
|
122
|
+
.filter(function (name) { return name.indexOf("on") === 0 && name.indexOf("Observable") !== -1; })
|
|
123
|
+
.forEach(function (functionName) {
|
|
124
|
+
gltfLoader_1[functionName].add(function (payload) {
|
|
125
|
+
_this._checkAndRun(functionName.replace("Observable", ""), payload);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
gltfLoader_1.onParsedObservable.add(function (data) {
|
|
129
|
+
if (data && data.json && data.json["asset"]) {
|
|
130
|
+
model.loadInfo = data.json["asset"];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
gltfLoader_1.onCompleteObservable.add(function () {
|
|
134
|
+
model.loaderDone = true;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
model.loaderDone = true;
|
|
139
|
+
}
|
|
140
|
+
this._checkAndRun("onInit", model.loader, model);
|
|
141
|
+
this._loaders.push(model.loader);
|
|
142
|
+
return model;
|
|
143
|
+
};
|
|
144
|
+
ModelLoader.prototype.cancelLoad = function (model) {
|
|
145
|
+
var loader = model.loader || this._loaders[model.loadId];
|
|
146
|
+
// ATM only available in the GLTF Loader
|
|
147
|
+
if (loader && loader.name === "gltf") {
|
|
148
|
+
var gltfLoader = loader;
|
|
149
|
+
gltfLoader.dispose();
|
|
150
|
+
model.state = ModelState.CANCELED;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
Tools.Warn("This type of loader cannot cancel the request");
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* dispose the model loader.
|
|
158
|
+
* If loaders are registered and are in the middle of loading, they will be disposed and the request(s) will be cancelled.
|
|
159
|
+
*/
|
|
160
|
+
ModelLoader.prototype.dispose = function () {
|
|
161
|
+
this._loaders.forEach(function (loader) {
|
|
162
|
+
if (loader.name === "gltf") {
|
|
163
|
+
loader.dispose();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
this._loaders.length = 0;
|
|
167
|
+
this._disposed = true;
|
|
168
|
+
};
|
|
169
|
+
ModelLoader.prototype._checkAndRun = function (functionName) {
|
|
170
|
+
var _this = this;
|
|
171
|
+
var payload = [];
|
|
172
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
173
|
+
payload[_i - 1] = arguments[_i];
|
|
174
|
+
}
|
|
175
|
+
if (this._disposed) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
this._plugins
|
|
179
|
+
.filter(function (p) { return p[functionName]; })
|
|
180
|
+
.forEach(function (plugin) {
|
|
181
|
+
try {
|
|
182
|
+
plugin[functionName].apply(_this, payload);
|
|
183
|
+
}
|
|
184
|
+
catch (e) { }
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
return ModelLoader;
|
|
188
|
+
}());
|
|
189
|
+
export { ModelLoader };
|
|
190
190
|
//# sourceMappingURL=modelLoader.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ViewerModel } from "../../model/viewerModel";
|
|
2
|
-
import type { ILoaderPlugin } from "./loaderPlugin";
|
|
3
|
-
import type { ISceneLoaderPlugin, ISceneLoaderPluginAsync } from "@babylonjs/core/Loading/sceneLoader.js";
|
|
4
|
-
import type { Material } from "@babylonjs/core/Materials/material.js";
|
|
5
|
-
/**
|
|
6
|
-
* Force-apply material configuration right after a material was loaded.
|
|
7
|
-
*/
|
|
8
|
-
export declare class ApplyMaterialConfigPlugin implements ILoaderPlugin {
|
|
9
|
-
private _model;
|
|
10
|
-
onInit(loader: ISceneLoaderPlugin | ISceneLoaderPluginAsync, model: ViewerModel): void;
|
|
11
|
-
onMaterialLoaded(material: Material): void;
|
|
12
|
-
}
|
|
1
|
+
import type { ViewerModel } from "../../model/viewerModel";
|
|
2
|
+
import type { ILoaderPlugin } from "./loaderPlugin";
|
|
3
|
+
import type { ISceneLoaderPlugin, ISceneLoaderPluginAsync } from "@babylonjs/core/Loading/sceneLoader.js";
|
|
4
|
+
import type { Material } from "@babylonjs/core/Materials/material.js";
|
|
5
|
+
/**
|
|
6
|
+
* Force-apply material configuration right after a material was loaded.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ApplyMaterialConfigPlugin implements ILoaderPlugin {
|
|
9
|
+
private _model;
|
|
10
|
+
onInit(loader: ISceneLoaderPlugin | ISceneLoaderPluginAsync, model: ViewerModel): void;
|
|
11
|
+
onMaterialLoaded(material: Material): void;
|
|
12
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Force-apply material configuration right after a material was loaded.
|
|
3
|
-
*/
|
|
4
|
-
var ApplyMaterialConfigPlugin = /** @class */ (function () {
|
|
5
|
-
function ApplyMaterialConfigPlugin() {
|
|
6
|
-
}
|
|
7
|
-
ApplyMaterialConfigPlugin.prototype.onInit = function (loader, model) {
|
|
8
|
-
this._model = model;
|
|
9
|
-
};
|
|
10
|
-
ApplyMaterialConfigPlugin.prototype.onMaterialLoaded = function (material) {
|
|
11
|
-
this._model && this._model._applyModelMaterialConfiguration(material);
|
|
12
|
-
};
|
|
13
|
-
return ApplyMaterialConfigPlugin;
|
|
14
|
-
}());
|
|
15
|
-
export { ApplyMaterialConfigPlugin };
|
|
1
|
+
/**
|
|
2
|
+
* Force-apply material configuration right after a material was loaded.
|
|
3
|
+
*/
|
|
4
|
+
var ApplyMaterialConfigPlugin = /** @class */ (function () {
|
|
5
|
+
function ApplyMaterialConfigPlugin() {
|
|
6
|
+
}
|
|
7
|
+
ApplyMaterialConfigPlugin.prototype.onInit = function (loader, model) {
|
|
8
|
+
this._model = model;
|
|
9
|
+
};
|
|
10
|
+
ApplyMaterialConfigPlugin.prototype.onMaterialLoaded = function (material) {
|
|
11
|
+
this._model && this._model._applyModelMaterialConfiguration(material);
|
|
12
|
+
};
|
|
13
|
+
return ApplyMaterialConfigPlugin;
|
|
14
|
+
}());
|
|
15
|
+
export { ApplyMaterialConfigPlugin };
|
|
16
16
|
//# sourceMappingURL=applyMaterialConfig.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Material } from "@babylonjs/core/Materials/material.js";
|
|
2
|
-
import type { ILoaderPlugin } from "./loaderPlugin";
|
|
3
|
-
/**
|
|
4
|
-
* A (PBR) material will be extended using this function.
|
|
5
|
-
* This function will hold extra default configuration for the viewer, if not implemented in Babylon itself.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ExtendedMaterialLoaderPlugin implements ILoaderPlugin {
|
|
8
|
-
onMaterialLoaded(baseMaterial: Material): void;
|
|
9
|
-
}
|
|
1
|
+
import type { Material } from "@babylonjs/core/Materials/material.js";
|
|
2
|
+
import type { ILoaderPlugin } from "./loaderPlugin";
|
|
3
|
+
/**
|
|
4
|
+
* A (PBR) material will be extended using this function.
|
|
5
|
+
* This function will hold extra default configuration for the viewer, if not implemented in Babylon itself.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ExtendedMaterialLoaderPlugin implements ILoaderPlugin {
|
|
8
|
+
onMaterialLoaded(baseMaterial: Material): void;
|
|
9
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
|
2
|
-
/**
|
|
3
|
-
* A (PBR) material will be extended using this function.
|
|
4
|
-
* This function will hold extra default configuration for the viewer, if not implemented in Babylon itself.
|
|
5
|
-
*/
|
|
6
|
-
var ExtendedMaterialLoaderPlugin = /** @class */ (function () {
|
|
7
|
-
function ExtendedMaterialLoaderPlugin() {
|
|
8
|
-
}
|
|
9
|
-
ExtendedMaterialLoaderPlugin.prototype.onMaterialLoaded = function (baseMaterial) {
|
|
10
|
-
var material = baseMaterial;
|
|
11
|
-
material.alphaMode = Constants.ALPHA_PREMULTIPLIED_PORTERDUFF;
|
|
12
|
-
};
|
|
13
|
-
return ExtendedMaterialLoaderPlugin;
|
|
14
|
-
}());
|
|
15
|
-
export { ExtendedMaterialLoaderPlugin };
|
|
1
|
+
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
|
2
|
+
/**
|
|
3
|
+
* A (PBR) material will be extended using this function.
|
|
4
|
+
* This function will hold extra default configuration for the viewer, if not implemented in Babylon itself.
|
|
5
|
+
*/
|
|
6
|
+
var ExtendedMaterialLoaderPlugin = /** @class */ (function () {
|
|
7
|
+
function ExtendedMaterialLoaderPlugin() {
|
|
8
|
+
}
|
|
9
|
+
ExtendedMaterialLoaderPlugin.prototype.onMaterialLoaded = function (baseMaterial) {
|
|
10
|
+
var material = baseMaterial;
|
|
11
|
+
material.alphaMode = Constants.ALPHA_PREMULTIPLIED_PORTERDUFF;
|
|
12
|
+
};
|
|
13
|
+
return ExtendedMaterialLoaderPlugin;
|
|
14
|
+
}());
|
|
15
|
+
export { ExtendedMaterialLoaderPlugin };
|
|
16
16
|
//# sourceMappingURL=extendedMaterialLoaderPlugin.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { TelemetryLoaderPlugin } from "./telemetryLoaderPlugin";
|
|
2
|
-
import { ILoaderPlugin } from "./loaderPlugin";
|
|
3
|
-
import { MSFTLodLoaderPlugin } from "./msftLodLoaderPlugin";
|
|
4
|
-
import { ApplyMaterialConfigPlugin } from "./applyMaterialConfig";
|
|
5
|
-
import { ExtendedMaterialLoaderPlugin } from "./extendedMaterialLoaderPlugin";
|
|
6
|
-
export { TelemetryLoaderPlugin, ILoaderPlugin, MSFTLodLoaderPlugin, ApplyMaterialConfigPlugin, ExtendedMaterialLoaderPlugin };
|
|
7
|
-
/**
|
|
8
|
-
* Get a loader plugin according to its name.
|
|
9
|
-
* The plugin will be cached and will be reused if called for again.
|
|
10
|
-
*
|
|
11
|
-
* @param name the name of the plugin
|
|
12
|
-
*/
|
|
13
|
-
export declare function getLoaderPluginByName(name: string): ILoaderPlugin;
|
|
14
|
-
/**
|
|
15
|
-
* @param name
|
|
16
|
-
* @param plugin
|
|
17
|
-
*/
|
|
18
|
-
export declare function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
|
|
1
|
+
import { TelemetryLoaderPlugin } from "./telemetryLoaderPlugin";
|
|
2
|
+
import { ILoaderPlugin } from "./loaderPlugin";
|
|
3
|
+
import { MSFTLodLoaderPlugin } from "./msftLodLoaderPlugin";
|
|
4
|
+
import { ApplyMaterialConfigPlugin } from "./applyMaterialConfig";
|
|
5
|
+
import { ExtendedMaterialLoaderPlugin } from "./extendedMaterialLoaderPlugin";
|
|
6
|
+
export { TelemetryLoaderPlugin, ILoaderPlugin, MSFTLodLoaderPlugin, ApplyMaterialConfigPlugin, ExtendedMaterialLoaderPlugin };
|
|
7
|
+
/**
|
|
8
|
+
* Get a loader plugin according to its name.
|
|
9
|
+
* The plugin will be cached and will be reused if called for again.
|
|
10
|
+
*
|
|
11
|
+
* @param name the name of the plugin
|
|
12
|
+
*/
|
|
13
|
+
export declare function getLoaderPluginByName(name: string): ILoaderPlugin;
|
|
14
|
+
/**
|
|
15
|
+
* @param name
|
|
16
|
+
* @param plugin
|
|
17
|
+
*/
|
|
18
|
+
export declare function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
|
package/loader/plugins/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { TelemetryLoaderPlugin } from "./telemetryLoaderPlugin.js";
|
|
2
|
-
import { MSFTLodLoaderPlugin } from "./msftLodLoaderPlugin.js";
|
|
3
|
-
import { ApplyMaterialConfigPlugin } from "./applyMaterialConfig.js";
|
|
4
|
-
import { ExtendedMaterialLoaderPlugin } from "./extendedMaterialLoaderPlugin.js";
|
|
5
|
-
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
6
|
-
var pluginCache = {};
|
|
7
|
-
export { TelemetryLoaderPlugin, MSFTLodLoaderPlugin, ApplyMaterialConfigPlugin, ExtendedMaterialLoaderPlugin };
|
|
8
|
-
/**
|
|
9
|
-
* Get a loader plugin according to its name.
|
|
10
|
-
* The plugin will be cached and will be reused if called for again.
|
|
11
|
-
*
|
|
12
|
-
* @param name the name of the plugin
|
|
13
|
-
*/
|
|
14
|
-
export function getLoaderPluginByName(name) {
|
|
15
|
-
if (!pluginCache[name]) {
|
|
16
|
-
switch (name) {
|
|
17
|
-
case "telemetry":
|
|
18
|
-
pluginCache[name] = new TelemetryLoaderPlugin();
|
|
19
|
-
break;
|
|
20
|
-
case "msftLod":
|
|
21
|
-
pluginCache[name] = new MSFTLodLoaderPlugin();
|
|
22
|
-
break;
|
|
23
|
-
case "applyMaterialConfig":
|
|
24
|
-
pluginCache[name] = new ApplyMaterialConfigPlugin();
|
|
25
|
-
break;
|
|
26
|
-
case "extendedMaterial":
|
|
27
|
-
pluginCache[name] = new ExtendedMaterialLoaderPlugin();
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return pluginCache[name];
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @param name
|
|
35
|
-
* @param plugin
|
|
36
|
-
*/
|
|
37
|
-
export function addLoaderPlugin(name, plugin) {
|
|
38
|
-
if (pluginCache[name]) {
|
|
39
|
-
Tools.Warn("Overwriting plugin with the same name - " + name);
|
|
40
|
-
}
|
|
41
|
-
pluginCache[name] = plugin;
|
|
42
|
-
}
|
|
1
|
+
import { TelemetryLoaderPlugin } from "./telemetryLoaderPlugin.js";
|
|
2
|
+
import { MSFTLodLoaderPlugin } from "./msftLodLoaderPlugin.js";
|
|
3
|
+
import { ApplyMaterialConfigPlugin } from "./applyMaterialConfig.js";
|
|
4
|
+
import { ExtendedMaterialLoaderPlugin } from "./extendedMaterialLoaderPlugin.js";
|
|
5
|
+
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
|
6
|
+
var pluginCache = {};
|
|
7
|
+
export { TelemetryLoaderPlugin, MSFTLodLoaderPlugin, ApplyMaterialConfigPlugin, ExtendedMaterialLoaderPlugin };
|
|
8
|
+
/**
|
|
9
|
+
* Get a loader plugin according to its name.
|
|
10
|
+
* The plugin will be cached and will be reused if called for again.
|
|
11
|
+
*
|
|
12
|
+
* @param name the name of the plugin
|
|
13
|
+
*/
|
|
14
|
+
export function getLoaderPluginByName(name) {
|
|
15
|
+
if (!pluginCache[name]) {
|
|
16
|
+
switch (name) {
|
|
17
|
+
case "telemetry":
|
|
18
|
+
pluginCache[name] = new TelemetryLoaderPlugin();
|
|
19
|
+
break;
|
|
20
|
+
case "msftLod":
|
|
21
|
+
pluginCache[name] = new MSFTLodLoaderPlugin();
|
|
22
|
+
break;
|
|
23
|
+
case "applyMaterialConfig":
|
|
24
|
+
pluginCache[name] = new ApplyMaterialConfigPlugin();
|
|
25
|
+
break;
|
|
26
|
+
case "extendedMaterial":
|
|
27
|
+
pluginCache[name] = new ExtendedMaterialLoaderPlugin();
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return pluginCache[name];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @param name
|
|
35
|
+
* @param plugin
|
|
36
|
+
*/
|
|
37
|
+
export function addLoaderPlugin(name, plugin) {
|
|
38
|
+
if (pluginCache[name]) {
|
|
39
|
+
Tools.Warn("Overwriting plugin with the same name - " + name);
|
|
40
|
+
}
|
|
41
|
+
pluginCache[name] = plugin;
|
|
42
|
+
}
|
|
43
43
|
//# sourceMappingURL=index.js.map
|