redhotmagma-visualization 1.44.10 → 1.45.1
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/Constants.js +1 -0
- package/DevApp.js +14 -0
- package/Three/Three2D.js +25 -4
- package/Three/Three3D.js +121 -83
- package/Three/Three3DScene.js +132 -58
- package/Utils/createBakedShadow.js +1 -2
- package/Utils/initTextureCanvas.js +3 -1
- package/Utils/optimizeTextureImage.js +1 -1
- package/Utils/rememberCameraViewOffset.js +12 -7
- package/Utils/restrictCameraMovement.js +2 -2
- package/VisualizationContainer.js +34 -10
- package/package.json +3 -3
- package/public/libs/draco/README.md +2 -2
- package/public/libs/draco/draco_decoder.js +17 -35
- package/public/libs/draco/draco_decoder.wasm +0 -0
- package/public/libs/draco/draco_wasm_wrapper.js +117 -104
- package/public/libs/draco/gltf/draco_decoder.js +16 -31
- package/public/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/public/libs/draco/gltf/draco_wasm_wrapper.js +116 -104
- package/src/Constants.js +1 -0
- package/src/DevApp.js +12 -0
- package/src/Three/Three2D.js +4 -3
- package/src/Three/Three3D.js +15 -8
- package/src/Three/Three3DScene.js +85 -29
- package/src/Three/__tests__/Three3D.test.js +0 -33
- package/src/Utils/createBakedShadow.js +2 -4
- package/src/Utils/initTextureCanvas.js +2 -1
- package/src/Utils/optimizeTextureImage.js +1 -1
- package/src/Utils/rememberCameraViewOffset.js +5 -3
- package/src/Utils/restrictCameraMovement.js +1 -1
- package/src/VisualizationContainer.js +19 -0
- package/Three/Controls/OrbitControls.js +0 -724
- package/Three/Loaders/ColladaLoader.js +0 -2568
- package/Three/Loaders/MTLLoader.js +0 -418
- package/Three/Loaders/OBJLoader.js +0 -516
- package/src/Three/Controls/OrbitControls.js +0 -934
- package/src/Three/Loaders/ColladaLoader.js +0 -3245
- package/src/Three/Loaders/MTLLoader.js +0 -512
- package/src/Three/Loaders/OBJLoader.js +0 -640
package/Three/Three3DScene.js
CHANGED
|
@@ -8,9 +8,9 @@ var _three = require("three");
|
|
|
8
8
|
var _Three3D2 = require("./Three3D");
|
|
9
9
|
var _isMobileDevice = require("../Utils/isMobileDevice");
|
|
10
10
|
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
11
|
-
var
|
|
11
|
+
var _DRACOLoader2 = require("three/examples/jsm/loaders/DRACOLoader");
|
|
12
12
|
var _RGBELoader = require("three/examples/jsm/loaders/RGBELoader");
|
|
13
|
-
var
|
|
13
|
+
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
14
14
|
var _size = _interopRequireDefault(require("lodash/size"));
|
|
15
15
|
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
16
16
|
var _glTFExporter = require("./Exporters/glTFExporter");
|
|
@@ -18,10 +18,15 @@ var _findIndex = _interopRequireDefault(require("lodash/findIndex"));
|
|
|
18
18
|
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
19
19
|
var _createBakedShadow = _interopRequireDefault(require("../Utils/createBakedShadow"));
|
|
20
20
|
var _setLightShadow2 = _interopRequireDefault(require("../Utils/setLightShadow"));
|
|
21
|
+
var _Constants = require("../Constants");
|
|
22
|
+
var _createImageRepository = require("../Utils/createImageRepository");
|
|
23
|
+
var _createCache = require("../Utils/createCache");
|
|
21
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
22
25
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
23
26
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
24
27
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
28
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
29
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
25
30
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
26
31
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
27
32
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -130,9 +135,11 @@ function findImageBySrc(tree, src) {
|
|
|
130
135
|
var material = _ref5.material;
|
|
131
136
|
if (!result && material) {
|
|
132
137
|
for (var _i2 = 0, _Object$values = Object.values(material); _i2 < _Object$values.length; _i2++) {
|
|
138
|
+
var _value$image, _value$userData;
|
|
133
139
|
var value = _Object$values[_i2];
|
|
134
|
-
if (value && value.isTexture && value.image
|
|
135
|
-
result = value.
|
|
140
|
+
if (value && value.isTexture && (((_value$image = value.image) === null || _value$image === void 0 ? void 0 : _value$image.src) === src || ((_value$userData = value.userData) === null || _value$userData === void 0 ? void 0 : _value$userData.src) === src)) {
|
|
141
|
+
result = value.source;
|
|
142
|
+
return result;
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
}
|
|
@@ -282,7 +289,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
282
289
|
_defineProperty(_assertThisInitialized(_this), "defaultCamera", null);
|
|
283
290
|
_defineProperty(_assertThisInitialized(_this), "dirLightPosition", new _three.Vector3(1, 1, 1).normalize());
|
|
284
291
|
_defineProperty(_assertThisInitialized(_this), "defaultCameraPosition", new _three.Vector3(0, 1, 2).normalize());
|
|
285
|
-
_defineProperty(_assertThisInitialized(_this), "defaultScreenshotPosition", new _three.Vector3(0,
|
|
292
|
+
_defineProperty(_assertThisInitialized(_this), "defaultScreenshotPosition", new _three.Vector3(0, 1, 2).normalize());
|
|
286
293
|
_defineProperty(_assertThisInitialized(_this), "relativeCameraViews", {});
|
|
287
294
|
_defineProperty(_assertThisInitialized(_this), "relativeScreenshotViews", {});
|
|
288
295
|
_defineProperty(_assertThisInitialized(_this), "groundObjectNames", [/ground/i]);
|
|
@@ -303,7 +310,13 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
303
310
|
shadowTextureScaling: 0.96,
|
|
304
311
|
blurRadius: 6,
|
|
305
312
|
shadowOpacity: 0.8
|
|
306
|
-
}
|
|
313
|
+
},
|
|
314
|
+
textureImageCacheSize: 20
|
|
315
|
+
});
|
|
316
|
+
_defineProperty(_assertThisInitialized(_this), "onLoadError", function (url) {
|
|
317
|
+
var errorMessage = "Could not load file: ".concat(url);
|
|
318
|
+
// eslint-disable-next-line no-console
|
|
319
|
+
console.error(errorMessage);
|
|
307
320
|
});
|
|
308
321
|
_defineProperty(_assertThisInitialized(_this), "animate", function () {
|
|
309
322
|
var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
@@ -377,12 +390,53 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
377
390
|
value: function createLoader() {
|
|
378
391
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
379
392
|
var loadingManager = this.createLoadingManager(options);
|
|
380
|
-
|
|
381
|
-
|
|
393
|
+
if (!this.dracoLoader) {
|
|
394
|
+
var dracoLoader = new ( /*#__PURE__*/function (_DRACOLoader) {
|
|
395
|
+
_inherits(PatchedDRACOLoader, _DRACOLoader);
|
|
396
|
+
var _super2 = _createSuper(PatchedDRACOLoader);
|
|
397
|
+
function PatchedDRACOLoader() {
|
|
398
|
+
_classCallCheck(this, PatchedDRACOLoader);
|
|
399
|
+
return _super2.apply(this, arguments);
|
|
400
|
+
}
|
|
401
|
+
_createClass(PatchedDRACOLoader, [{
|
|
402
|
+
key: "decodeGeometry",
|
|
403
|
+
value: function decodeGeometry(buffer, taskConfig) {
|
|
404
|
+
return _get(_getPrototypeOf(PatchedDRACOLoader.prototype), "decodeGeometry", this).call(this, buffer, taskConfig)["catch"](function (e) {
|
|
405
|
+
// eslint-disable-next-line no-console
|
|
406
|
+
console.error(e.message || e.error);
|
|
407
|
+
// make sure an empty geometry is returned to not break the app
|
|
408
|
+
return {
|
|
409
|
+
attributes: {}
|
|
410
|
+
};
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}]);
|
|
414
|
+
return PatchedDRACOLoader;
|
|
415
|
+
}(_DRACOLoader2.DRACOLoader))();
|
|
416
|
+
dracoLoader.setDecoderPath("libs/draco/gltf/");
|
|
417
|
+
this.dracoLoader = dracoLoader;
|
|
418
|
+
}
|
|
382
419
|
var loader = new _GLTFLoader.GLTFLoader(loadingManager);
|
|
383
|
-
loader.setDRACOLoader(dracoLoader);
|
|
420
|
+
loader.setDRACOLoader(this.dracoLoader);
|
|
384
421
|
return loader;
|
|
385
422
|
}
|
|
423
|
+
}, {
|
|
424
|
+
key: "getImageCache",
|
|
425
|
+
value: function getImageCache() {
|
|
426
|
+
if (!this._imageCache) {
|
|
427
|
+
this._imageCache = (0, _createCache.createCache)(this.config.textureImageCacheSize);
|
|
428
|
+
}
|
|
429
|
+
return this._imageCache;
|
|
430
|
+
}
|
|
431
|
+
}, {
|
|
432
|
+
key: "useImageRepository",
|
|
433
|
+
value: function useImageRepository(imageLoader) {
|
|
434
|
+
return (0, _createImageRepository.createImageRepository)(this.getImageCache(), function (src) {
|
|
435
|
+
return new Promise(function (resolve, reject) {
|
|
436
|
+
return imageLoader.load(src, resolve, undefined, reject);
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
}
|
|
386
440
|
}, {
|
|
387
441
|
key: "createImageLoader",
|
|
388
442
|
value: function createImageLoader() {
|
|
@@ -398,7 +452,6 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
398
452
|
alpha: true,
|
|
399
453
|
antialias: true
|
|
400
454
|
});
|
|
401
|
-
renderer.outputEncoding = _three.sRGBEncoding;
|
|
402
455
|
renderer.shadowMap.enabled = true;
|
|
403
456
|
renderer.shadowMap.type = _three.PCFSoftShadowMap;
|
|
404
457
|
renderer.toneMapping = _three.ACESFilmicToneMapping;
|
|
@@ -426,7 +479,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
426
479
|
var pmremGenerator = new _three.PMREMGenerator(renderer);
|
|
427
480
|
pmremGenerator.compileEquirectangularShader();
|
|
428
481
|
this.envMapPromise = new Promise(function (resolve, reject) {
|
|
429
|
-
new _RGBELoader.RGBELoader().
|
|
482
|
+
new _RGBELoader.RGBELoader().load(envMapURL, function (texture) {
|
|
430
483
|
_this2.envMap = pmremGenerator.fromEquirectangular(texture).texture;
|
|
431
484
|
_this2.scene.environment = _this2.envMap;
|
|
432
485
|
texture.dispose();
|
|
@@ -477,7 +530,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
477
530
|
color: 0x202020
|
|
478
531
|
});
|
|
479
532
|
}
|
|
480
|
-
var mesh = new _three.Mesh(new _three.
|
|
533
|
+
var mesh = new _three.Mesh(new _three.PlaneGeometry(1, 1), shadowMaterial);
|
|
481
534
|
mesh.name = "ground";
|
|
482
535
|
mesh.rotation.x = -Math.PI / 2;
|
|
483
536
|
mesh.receiveShadow = true;
|
|
@@ -537,21 +590,22 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
537
590
|
value: function () {
|
|
538
591
|
var _applyMaterialParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(model, materialOptions, imageLoader) {
|
|
539
592
|
var _this4 = this;
|
|
540
|
-
var params;
|
|
593
|
+
var imageRepository, params;
|
|
541
594
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
542
595
|
while (1) switch (_context3.prev = _context3.next) {
|
|
543
596
|
case 0:
|
|
597
|
+
imageRepository = this.useImageRepository(imageLoader);
|
|
544
598
|
if (!materialOptions) {
|
|
545
|
-
_context3.next =
|
|
599
|
+
_context3.next = 7;
|
|
546
600
|
break;
|
|
547
601
|
}
|
|
548
602
|
params = materialOptions.params;
|
|
549
603
|
_context3.t0 = params;
|
|
550
604
|
if (!_context3.t0) {
|
|
551
|
-
_context3.next =
|
|
605
|
+
_context3.next = 7;
|
|
552
606
|
break;
|
|
553
607
|
}
|
|
554
|
-
_context3.next =
|
|
608
|
+
_context3.next = 7;
|
|
555
609
|
return Promise.all(getAllMaterials(model).map( /*#__PURE__*/function () {
|
|
556
610
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(material) {
|
|
557
611
|
var materialName, materialNames;
|
|
@@ -574,7 +628,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
574
628
|
_context2.next = 7;
|
|
575
629
|
return Promise.all(Object.keys(params).map( /*#__PURE__*/function () {
|
|
576
630
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(p) {
|
|
577
|
-
var texture, value;
|
|
631
|
+
var _material$p, _material$map, texture, src, textureSource, value;
|
|
578
632
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
579
633
|
while (1) switch (_context.prev = _context.next) {
|
|
580
634
|
case 0:
|
|
@@ -585,36 +639,40 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
585
639
|
return _context.abrupt("return");
|
|
586
640
|
case 2:
|
|
587
641
|
_context.t0 = p;
|
|
588
|
-
_context.next = _context.t0 === "alphaMap" ? 5 : _context.t0 === "aoMap" ? 5 : _context.t0 === "emissiveMap" ? 5 : _context.t0 === "lightMap" ? 5 : _context.t0 === "map" ? 5 : _context.t0 === "metalnessMap" ? 5 : _context.t0 === "normalMap" ? 5 : _context.t0 === "roughnessMap" ? 5 : _context.t0 === "clearcoatMap" ? 5 : _context.t0 === "clearcoatNormalMap" ? 5 : _context.t0 === "clearcoatRoughnessMap" ? 5 : _context.t0 === "sheenRoughnessMap" ? 5 : _context.t0 === "sheenColorMap" ? 5 : _context.t0 === "specularIntensityMap" ? 5 : _context.t0 === "specularColorMap" ? 5 : _context.t0 === "thicknessMap" ? 5 : _context.t0 === "transmissionMap" ? 5 : _context.t0 === "aoMapIntensity" ?
|
|
642
|
+
_context.next = _context.t0 === "alphaMap" ? 5 : _context.t0 === "aoMap" ? 5 : _context.t0 === "emissiveMap" ? 5 : _context.t0 === "lightMap" ? 5 : _context.t0 === "map" ? 5 : _context.t0 === "metalnessMap" ? 5 : _context.t0 === "normalMap" ? 5 : _context.t0 === "roughnessMap" ? 5 : _context.t0 === "clearcoatMap" ? 5 : _context.t0 === "clearcoatNormalMap" ? 5 : _context.t0 === "clearcoatRoughnessMap" ? 5 : _context.t0 === "sheenRoughnessMap" ? 5 : _context.t0 === "sheenColorMap" ? 5 : _context.t0 === "specularIntensityMap" ? 5 : _context.t0 === "specularColorMap" ? 5 : _context.t0 === "thicknessMap" ? 5 : _context.t0 === "transmissionMap" ? 5 : _context.t0 === "aoMapIntensity" ? 20 : _context.t0 === "emissiveIntensity" ? 20 : _context.t0 === "envMapIntensity" ? 20 : _context.t0 === "lightMapIntensity" ? 20 : _context.t0 === "metalness" ? 20 : _context.t0 === "opacity" ? 20 : _context.t0 === "refractionRatio" ? 20 : _context.t0 === "roughness" ? 20 : _context.t0 === "attenuationDistance" ? 20 : _context.t0 === "clearcoat" ? 20 : _context.t0 === "clearcoatRoughness" ? 20 : _context.t0 === "ior" ? 20 : _context.t0 === "reflectivity" ? 20 : _context.t0 === "sheen" ? 20 : _context.t0 === "sheenRoughness" ? 20 : _context.t0 === "specularIntensity" ? 20 : _context.t0 === "thickness" ? 20 : _context.t0 === "transmission" ? 20 : _context.t0 === "color" ? 23 : _context.t0 === "emissive" ? 23 : _context.t0 === "attenuationColor" ? 23 : _context.t0 === "sheenColor" ? 23 : _context.t0 === "specularColor" ? 23 : 25;
|
|
589
643
|
break;
|
|
590
644
|
case 5:
|
|
591
|
-
texture = material[p] ||
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
645
|
+
texture = ((_material$p = material[p]) === null || _material$p === void 0 ? void 0 : _material$p.clone()) || new _three.Texture();
|
|
646
|
+
texture.flipY = ((_material$map = material.map) === null || _material$map === void 0 ? void 0 : _material$map.flipY) || false;
|
|
647
|
+
src = imageLoader.manager.resolveURL(params[p]);
|
|
648
|
+
textureSource = findImageBySrc(_this4.sceneContainer, src);
|
|
649
|
+
if (!textureSource) {
|
|
650
|
+
_context.next = 13;
|
|
595
651
|
break;
|
|
596
652
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
case
|
|
604
|
-
texture.image = _context.
|
|
653
|
+
texture.source = textureSource;
|
|
654
|
+
_context.next = 16;
|
|
655
|
+
break;
|
|
656
|
+
case 13:
|
|
657
|
+
_context.next = 15;
|
|
658
|
+
return imageRepository.loadImage(params[p]);
|
|
659
|
+
case 15:
|
|
660
|
+
texture.image = _context.sent;
|
|
661
|
+
case 16:
|
|
662
|
+
texture.userData.src = src;
|
|
605
663
|
texture.needsUpdate = true;
|
|
606
664
|
material[p] = texture;
|
|
607
|
-
return _context.abrupt("break",
|
|
608
|
-
case
|
|
665
|
+
return _context.abrupt("break", 25);
|
|
666
|
+
case 20:
|
|
609
667
|
value = parseFloat(params[p]);
|
|
610
668
|
if (!isNaN(value)) {
|
|
611
669
|
material[p] = value;
|
|
612
670
|
}
|
|
613
|
-
return _context.abrupt("break",
|
|
614
|
-
case
|
|
671
|
+
return _context.abrupt("break", 25);
|
|
672
|
+
case 23:
|
|
615
673
|
material[p] = new _three.Color(params[p]);
|
|
616
|
-
return _context.abrupt("break",
|
|
617
|
-
case
|
|
674
|
+
return _context.abrupt("break", 25);
|
|
675
|
+
case 25:
|
|
618
676
|
case "end":
|
|
619
677
|
return _context.stop();
|
|
620
678
|
}
|
|
@@ -625,7 +683,10 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
625
683
|
};
|
|
626
684
|
}()));
|
|
627
685
|
case 7:
|
|
628
|
-
|
|
686
|
+
if (material.alphaMap) {
|
|
687
|
+
material.transparent = true;
|
|
688
|
+
material.side = _three.DoubleSide;
|
|
689
|
+
}
|
|
629
690
|
material.needsUpdate = true;
|
|
630
691
|
case 9:
|
|
631
692
|
case "end":
|
|
@@ -637,11 +698,11 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
637
698
|
return _ref6.apply(this, arguments);
|
|
638
699
|
};
|
|
639
700
|
}()));
|
|
640
|
-
case
|
|
701
|
+
case 7:
|
|
641
702
|
case "end":
|
|
642
703
|
return _context3.stop();
|
|
643
704
|
}
|
|
644
|
-
}, _callee3);
|
|
705
|
+
}, _callee3, this);
|
|
645
706
|
}));
|
|
646
707
|
function applyMaterialParams(_x, _x2, _x3) {
|
|
647
708
|
return _applyMaterialParams.apply(this, arguments);
|
|
@@ -723,7 +784,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
723
784
|
if (!mat.original) {
|
|
724
785
|
mat.original = mat.clone();
|
|
725
786
|
Object.values(mat).filter(function (value) {
|
|
726
|
-
return value && value.
|
|
787
|
+
return value && value.clone;
|
|
727
788
|
}).forEach(function (texture) {
|
|
728
789
|
if (!texture.original) {
|
|
729
790
|
texture.original = texture.clone();
|
|
@@ -733,7 +794,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
733
794
|
mat.copy(mat.original);
|
|
734
795
|
Object.keys(mat).forEach(function (key) {
|
|
735
796
|
var value = mat[key];
|
|
736
|
-
if (value && value.original) {
|
|
797
|
+
if (_typeof(value) === "object" && value !== null && value !== void 0 && value.copy && value.original) {
|
|
737
798
|
value.copy(value.original);
|
|
738
799
|
}
|
|
739
800
|
});
|
|
@@ -892,6 +953,13 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
892
953
|
modelFileName: modelFileName
|
|
893
954
|
};
|
|
894
955
|
}
|
|
956
|
+
}, {
|
|
957
|
+
key: "checkEmptyScene",
|
|
958
|
+
value: function checkEmptyScene() {
|
|
959
|
+
if (!this.sceneContainer.children.length) {
|
|
960
|
+
this.observable.dispatch(_Constants.EventTypes.EmptySceneError);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
895
963
|
}, {
|
|
896
964
|
key: "loadSceneSync",
|
|
897
965
|
value: function () {
|
|
@@ -982,14 +1050,21 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
982
1050
|
triggerLoadEvent = !!(toBeAdded.length || toBeUpdated.length || toBeApplied.length);
|
|
983
1051
|
triggerLoadEvent && this.onLoadStart();
|
|
984
1052
|
_context8.next = 13;
|
|
985
|
-
return Promise.
|
|
1053
|
+
return Promise.allSettled(toBeAdded.map(function (item) {
|
|
986
1054
|
return _this7.loadSceneContainer(item);
|
|
987
1055
|
}));
|
|
988
1056
|
case 13:
|
|
989
1057
|
sceneParts = _context8.sent;
|
|
990
|
-
sceneParts.forEach(function (_ref10) {
|
|
991
|
-
var
|
|
992
|
-
|
|
1058
|
+
sceneParts.forEach(function (_ref10, index) {
|
|
1059
|
+
var value = _ref10.value,
|
|
1060
|
+
reason = _ref10.reason;
|
|
1061
|
+
if (reason) {
|
|
1062
|
+
// eslint-disable-next-line no-console
|
|
1063
|
+
console.error("Failed to load 3D model: ".concat(toBeAdded[index].model));
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
var scene = value.scene,
|
|
1067
|
+
animations = value.animations;
|
|
993
1068
|
sceneContainer.add(scene);
|
|
994
1069
|
|
|
995
1070
|
// collect animations
|
|
@@ -1004,8 +1079,9 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
1004
1079
|
})));
|
|
1005
1080
|
}
|
|
1006
1081
|
});
|
|
1082
|
+
this.checkEmptyScene();
|
|
1007
1083
|
sceneContainer.updateWorldMatrix(true, true);
|
|
1008
|
-
_context8.next =
|
|
1084
|
+
_context8.next = 19;
|
|
1009
1085
|
return Promise.all(toBeUpdated.map(function (item) {
|
|
1010
1086
|
var itemSrc = getSrc(item);
|
|
1011
1087
|
var object = findObjectWith(sceneContainer, function (_ref13) {
|
|
@@ -1022,12 +1098,12 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
1022
1098
|
var imageLoader = _this7.createImageLoader(loaderOptions);
|
|
1023
1099
|
return object && _this7.applyCustomizations(object, item, imageLoader);
|
|
1024
1100
|
}));
|
|
1025
|
-
case
|
|
1101
|
+
case 19:
|
|
1026
1102
|
// apply global or targeted param values
|
|
1027
1103
|
imageLoader = this.createImageLoader({
|
|
1028
1104
|
basePath: this._modelBasePath
|
|
1029
1105
|
});
|
|
1030
|
-
_context8.next =
|
|
1106
|
+
_context8.next = 22;
|
|
1031
1107
|
return Promise.all(toBeApplied.map(function (_ref14) {
|
|
1032
1108
|
var optionParams = _ref14.params,
|
|
1033
1109
|
files = _ref14.files;
|
|
@@ -1060,10 +1136,10 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
1060
1136
|
});
|
|
1061
1137
|
}));
|
|
1062
1138
|
}));
|
|
1063
|
-
case
|
|
1064
|
-
_context8.next =
|
|
1139
|
+
case 22:
|
|
1140
|
+
_context8.next = 24;
|
|
1065
1141
|
return this.initCustomizableMaterialsIfNeeded();
|
|
1066
|
-
case
|
|
1142
|
+
case 24:
|
|
1067
1143
|
this.setupGround();
|
|
1068
1144
|
this.addLightsIfNeeded(sceneContainer);
|
|
1069
1145
|
this.fitSceneToCamera();
|
|
@@ -1078,7 +1154,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
1078
1154
|
mixer.clipAction(animations[0]).play();
|
|
1079
1155
|
this.startAnimation("builtin");
|
|
1080
1156
|
}
|
|
1081
|
-
case
|
|
1157
|
+
case 30:
|
|
1082
1158
|
case "end":
|
|
1083
1159
|
return _context8.stop();
|
|
1084
1160
|
}
|
|
@@ -1114,9 +1190,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
1114
1190
|
var dir = camera.getWorldDirection(new _three.Vector3());
|
|
1115
1191
|
var distance = position.distanceTo(center);
|
|
1116
1192
|
var lookat = dir.multiplyScalar(distance).add(position);
|
|
1117
|
-
var
|
|
1118
|
-
camera.getWorldQuaternion(rotation);
|
|
1119
|
-
var orientation = _three.Object3D.DefaultUp.clone();
|
|
1193
|
+
var orientation = _three.Object3D.DEFAULT_UP;
|
|
1120
1194
|
var fov = camera.fov || 45;
|
|
1121
1195
|
var cameraView = {
|
|
1122
1196
|
position: position,
|
|
@@ -1432,7 +1506,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
1432
1506
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1433
1507
|
case 0:
|
|
1434
1508
|
this._configuration = configuration;
|
|
1435
|
-
sceneData = (0,
|
|
1509
|
+
sceneData = (0, _get2["default"])(configuration, "visualizationData.sceneData", false) || (0, _get2["default"])(configuration, "visualizationData.designViews[0].models.".concat(this._materialVariantPath), false);
|
|
1436
1510
|
_context9.t0 = sceneData;
|
|
1437
1511
|
if (!_context9.t0) {
|
|
1438
1512
|
_context9.next = 6;
|
|
@@ -1459,7 +1533,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
1459
1533
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1460
1534
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1461
1535
|
case 0:
|
|
1462
|
-
sceneData = (0,
|
|
1536
|
+
sceneData = (0, _get2["default"])(this._designAreaList, "[0].designView.models.".concat(this._materialVariantPath)) || (0, _get2["default"])(this._configuration, "visualizationData.designViews[0].models.".concat(this._materialVariantPath)) || false;
|
|
1463
1537
|
_context10.t0 = sceneData;
|
|
1464
1538
|
if (!_context10.t0) {
|
|
1465
1539
|
_context10.next = 5;
|
|
@@ -1487,7 +1561,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
|
|
|
1487
1561
|
while (1) switch (_context11.prev = _context11.next) {
|
|
1488
1562
|
case 0:
|
|
1489
1563
|
this._designAreaList = designAreaList;
|
|
1490
|
-
sceneData = (0,
|
|
1564
|
+
sceneData = (0, _get2["default"])(designAreaList, "[0].designView.models.".concat(this._materialVariantPath));
|
|
1491
1565
|
_context11.t0 = sceneData;
|
|
1492
1566
|
if (!_context11.t0) {
|
|
1493
1567
|
_context11.next = 6;
|
|
@@ -51,7 +51,7 @@ function createBakedShadow(scene, options) {
|
|
|
51
51
|
var box = new _three.Box3().expandByObject(scene);
|
|
52
52
|
var sphere = box.getBoundingSphere(new _three.Sphere());
|
|
53
53
|
var radius = sphere.radius;
|
|
54
|
-
var shadowGeometry = new _three.
|
|
54
|
+
var shadowGeometry = new _three.PlaneGeometry(1, 1);
|
|
55
55
|
shadowGeometry.rotateX(-Math.PI * 0.5);
|
|
56
56
|
shadowGeometry.rotateY(Math.PI);
|
|
57
57
|
var shadowGround = new _three.Mesh(shadowGeometry, new _three.ShadowMaterial({
|
|
@@ -84,7 +84,6 @@ function createBakedShadow(scene, options) {
|
|
|
84
84
|
alpha: true,
|
|
85
85
|
antialias: true
|
|
86
86
|
});
|
|
87
|
-
renderer.outputEncoding = _three.sRGBEncoding;
|
|
88
87
|
renderer.shadowMap.enabled = true;
|
|
89
88
|
renderer.shadowMap.type = _three.PCFSoftShadowMap;
|
|
90
89
|
renderer.setRenderTarget(renderTarget);
|
|
@@ -25,9 +25,11 @@ function initTextureCanvas(texture) {
|
|
|
25
25
|
console.warn("There is no image for the given texture.", texture);
|
|
26
26
|
}
|
|
27
27
|
if (!texture.originalImage || texture.image.nodeName !== "CANVAS") {
|
|
28
|
+
var _texture$image, _texture$userData;
|
|
28
29
|
var originalImage = (0, _optimizeTextureImage.optimizeTextureImage)(texture.image);
|
|
29
30
|
// eslint-disable-next-line no-console
|
|
30
|
-
|
|
31
|
+
texture.userData.src = ((_texture$image = texture.image) === null || _texture$image === void 0 ? void 0 : _texture$image.src) || ((_texture$userData = texture.userData) === null || _texture$userData === void 0 ? void 0 : _texture$userData.src);
|
|
32
|
+
console.log("Creating canvas from texture: ".concat(texture.userData.src));
|
|
31
33
|
texture.image = createCanvasFromImage(originalImage);
|
|
32
34
|
texture.originalImage = originalImage;
|
|
33
35
|
} else {
|
|
@@ -21,7 +21,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
21
21
|
* @return {HTMLImageElement|HTMLCanvasElement}
|
|
22
22
|
*/
|
|
23
23
|
var optimizeTextureImage = exports.optimizeTextureImage = function optimizeTextureImage(image) {
|
|
24
|
-
var maxTextureSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
24
|
+
var maxTextureSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4096;
|
|
25
25
|
var minTextureSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2048;
|
|
26
26
|
var textureSize = Math.max(image.width, image.height);
|
|
27
27
|
if (textureSize <= maxTextureSize && textureSize >= minTextureSize) {
|
|
@@ -5,13 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.rememberCameraViewOffset = void 0;
|
|
7
7
|
var rememberCameraViewOffset = exports.rememberCameraViewOffset = function rememberCameraViewOffset(camera) {
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
var view = camera.view;
|
|
9
|
+
if (!view) {
|
|
10
|
+
return function () {
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
var fullWidth = view.fullWidth,
|
|
15
|
+
fullHeight = view.fullHeight,
|
|
16
|
+
offsetX = view.offsetX,
|
|
17
|
+
offsetY = view.offsetY,
|
|
18
|
+
width = view.width,
|
|
19
|
+
height = view.height;
|
|
15
20
|
return function () {
|
|
16
21
|
return camera.setViewOffset(fullWidth, fullHeight, offsetX, offsetY, width, height);
|
|
17
22
|
};
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.restrictOrbitControls = void 0;
|
|
7
7
|
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
8
|
-
var _OrbitControls =
|
|
8
|
+
var _OrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
10
|
var stateMemo = function stateMemo(obj, props) {
|
|
11
11
|
var state = (0, _pick["default"])(obj, props);
|
|
@@ -14,7 +14,7 @@ var stateMemo = function stateMemo(obj, props) {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
var restrictOrbitControls = exports.restrictOrbitControls = function restrictOrbitControls(orbitControls) {
|
|
17
|
-
if (!(orbitControls instanceof _OrbitControls
|
|
17
|
+
if (!(orbitControls instanceof _OrbitControls.OrbitControls)) {
|
|
18
18
|
throw new Error("restrictOrbitControls can handle only the OrbitControls object type");
|
|
19
19
|
}
|
|
20
20
|
var restoreInitialState = stateMemo(orbitControls, ["minPolarAngle", "maxPolarAngle", "minAzimuthAngle", "maxAzimuthAngle"]);
|
|
@@ -112,12 +112,35 @@ var VisualizationContainer = exports.VisualizationContainer = /*#__PURE__*/funct
|
|
|
112
112
|
this.resizeSensor = new _cssElementQueries.ResizeSensor(container, this.onSizeChange);
|
|
113
113
|
}
|
|
114
114
|
}, {
|
|
115
|
-
key: "
|
|
116
|
-
value: function
|
|
117
|
-
|
|
115
|
+
key: "initMutationObserver",
|
|
116
|
+
value: function initMutationObserver() {
|
|
117
|
+
if (this.mutationObserver) {
|
|
118
|
+
this.mutationObserver.disconnect();
|
|
119
|
+
}
|
|
118
120
|
var _this$props2 = this.props,
|
|
119
121
|
visualization = _this$props2.visualization,
|
|
120
122
|
alignTargetElement = _this$props2.alignTargetElement;
|
|
123
|
+
if (!alignTargetElement) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
this.mutationObserver = new MutationObserver(function () {
|
|
127
|
+
(0, _updateFitSizeToElement.updateFitSizeToElement)(visualization, alignTargetElement).updateCameraPosition({
|
|
128
|
+
animate: true
|
|
129
|
+
});
|
|
130
|
+
visualization.render();
|
|
131
|
+
});
|
|
132
|
+
// do the update only when attributes have changed (e.g. style)
|
|
133
|
+
this.mutationObserver.observe(alignTargetElement, {
|
|
134
|
+
attributes: true
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "updateVisualization",
|
|
139
|
+
value: function updateVisualization() {
|
|
140
|
+
var prevProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
141
|
+
var _this$props3 = this.props,
|
|
142
|
+
visualization = _this$props3.visualization,
|
|
143
|
+
alignTargetElement = _this$props3.alignTargetElement;
|
|
121
144
|
var container = this.containerRef.current;
|
|
122
145
|
if (visualization !== prevProps.visualization) {
|
|
123
146
|
if (prevProps.visualization) {
|
|
@@ -139,13 +162,14 @@ var VisualizationContainer = exports.VisualizationContainer = /*#__PURE__*/funct
|
|
|
139
162
|
});
|
|
140
163
|
visualization.render();
|
|
141
164
|
}
|
|
165
|
+
this.initMutationObserver();
|
|
142
166
|
}
|
|
143
167
|
}, {
|
|
144
168
|
key: "componentWillUnmount",
|
|
145
169
|
value: function componentWillUnmount() {
|
|
146
|
-
var _this$
|
|
147
|
-
autoDispose = _this$
|
|
148
|
-
visualization = _this$
|
|
170
|
+
var _this$props4 = this.props,
|
|
171
|
+
autoDispose = _this$props4.autoDispose,
|
|
172
|
+
visualization = _this$props4.visualization;
|
|
149
173
|
autoDispose && visualization.dispose();
|
|
150
174
|
this.resizeSensor && this.resizeSensor.detach();
|
|
151
175
|
this.offObservers && this.offObservers();
|
|
@@ -177,10 +201,10 @@ var VisualizationContainer = exports.VisualizationContainer = /*#__PURE__*/funct
|
|
|
177
201
|
}, {
|
|
178
202
|
key: "render",
|
|
179
203
|
value: function render() {
|
|
180
|
-
var _this$
|
|
181
|
-
className = _this$
|
|
182
|
-
ProgressComponent = _this$
|
|
183
|
-
BrokenComponent = _this$
|
|
204
|
+
var _this$props5 = this.props,
|
|
205
|
+
className = _this$props5.className,
|
|
206
|
+
ProgressComponent = _this$props5.ProgressComponent,
|
|
207
|
+
BrokenComponent = _this$props5.BrokenComponent;
|
|
184
208
|
var broken = this.state.broken;
|
|
185
209
|
var style = _objectSpread(_objectSpread({}, className ? {} : defaultContainerStyle), broken && BrokenComponent && {
|
|
186
210
|
display: "none"
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redhotmagma-visualization",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/polyfill": "^7.12.1",
|
|
9
|
-
"@configuratorware/scripts": "1.
|
|
9
|
+
"@configuratorware/scripts": "1.45.1",
|
|
10
10
|
"@tweenjs/tween.js": "^17.6.0",
|
|
11
11
|
"console-polyfill": "^0.3.0",
|
|
12
12
|
"css-element-queries": "^1.2.3",
|
|
13
13
|
"lodash": "^4.17.21",
|
|
14
14
|
"prop-types": "^15.7.2",
|
|
15
|
-
"three": "^0.
|
|
15
|
+
"three": "^0.164.1",
|
|
16
16
|
"uuid": "^3.4.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
@@ -17,10 +17,10 @@ Each file is provided in two variations:
|
|
|
17
17
|
* **Default:** Latest stable builds, tracking the project's [master branch](https://github.com/google/draco).
|
|
18
18
|
* **glTF:** Builds targeted by the [glTF mesh compression extension](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression), tracking the [corresponding Draco branch](https://github.com/google/draco/tree/gltf_2.0_draco_extension).
|
|
19
19
|
|
|
20
|
-
Either variation may be used with `
|
|
20
|
+
Either variation may be used with `DRACOLoader`:
|
|
21
21
|
|
|
22
22
|
```js
|
|
23
|
-
var dracoLoader = new
|
|
23
|
+
var dracoLoader = new DRACOLoader();
|
|
24
24
|
dracoLoader.setDecoderPath('path/to/decoders/');
|
|
25
25
|
dracoLoader.setDecoderConfig({type: 'js'}); // (Optional) Override detection of WASM support.
|
|
26
26
|
```
|