redhotmagma-visualization 1.43.4 → 1.44.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.
@@ -13,6 +13,7 @@ var _RGBELoader = require("three/examples/jsm/loaders/RGBELoader");
13
13
  var _get = _interopRequireDefault(require("lodash/get"));
14
14
  var _size = _interopRequireDefault(require("lodash/size"));
15
15
  var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
16
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
16
17
  var _glTFExporter = require("./Exporters/glTFExporter");
17
18
  var _findIndex = _interopRequireDefault(require("lodash/findIndex"));
18
19
  var _merge = _interopRequireDefault(require("lodash/merge"));
@@ -528,119 +529,32 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
528
529
  });
529
530
  }
530
531
  }, {
531
- key: "applyCustomizations",
532
+ key: "applyMaterialParams",
532
533
  value: function () {
533
- var _applyCustomizations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(model, item, imageLoader) {
534
+ var _applyMaterialParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(model, materialOptions, imageLoader) {
534
535
  var _this4 = this;
535
- var options,
536
- _options$saveAndResto,
537
- saveAndRestore,
538
- params,
539
- material,
540
- _params,
541
- _args3 = arguments;
536
+ var params;
542
537
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
543
538
  while (1) switch (_context3.prev = _context3.next) {
544
539
  case 0:
545
- options = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : {};
546
- _options$saveAndResto = options.saveAndRestore, saveAndRestore = _options$saveAndResto === void 0 ? true : _options$saveAndResto;
547
- params = item.params;
548
- if (params) {
549
- Object.keys(params).forEach(function (p) {
550
- // skip not allowed props
551
- if (allowedObjectProps.indexOf(p) === -1) {
552
- return;
553
- }
554
- // restore original value first
555
- if (params[p] === UNSET) {
556
- if (model.originalValues && model.originalValues[p]) {
557
- model[p].copy(model.originalValues[p]);
558
- }
559
- return;
560
- }
561
- // store original value for later restoration
562
- if (!model.originalValues) {
563
- model.originalValues = {};
564
- }
565
- if (!model.originalValues[p]) {
566
- model.originalValues[p] = model[p] ? model[p].clone() : model[p];
567
- }
568
- // apply the param values
569
- switch (p) {
570
- case "scale":
571
- {
572
- var _params$p = params[p],
573
- _params$p$x = _params$p.x,
574
- x = _params$p$x === void 0 ? 1 : _params$p$x,
575
- _params$p$y = _params$p.y,
576
- y = _params$p$y === void 0 ? 1 : _params$p$y,
577
- _params$p$z = _params$p.z,
578
- z = _params$p$z === void 0 ? 1 : _params$p$z;
579
- model[p].set(x, y, z);
580
- break;
581
- }
582
- case "rotation":
583
- case "position":
584
- {
585
- var _params$p2 = params[p],
586
- _params$p2$x = _params$p2.x,
587
- _x4 = _params$p2$x === void 0 ? 0 : _params$p2$x,
588
- _params$p2$y = _params$p2.y,
589
- _y = _params$p2$y === void 0 ? 0 : _params$p2$y,
590
- _params$p2$z = _params$p2.z,
591
- _z = _params$p2$z === void 0 ? 0 : _params$p2$z;
592
- model[p].set(_x4, _y, _z);
593
- break;
594
- }
595
- }
596
- });
597
- }
598
-
599
- // store & restore original material and textures before applying new param values
600
- saveAndRestore && Object.values(getMaterials(model)).map(function (mat) {
601
- if (!mat.original) {
602
- mat.original = mat.clone();
603
- Object.values(mat).filter(function (value) {
604
- return value && value.isTexture;
605
- }).forEach(function (texture) {
606
- if (!texture.original) {
607
- texture.original = texture.clone();
608
- }
609
- });
610
- } else {
611
- mat.copy(mat.original);
612
- Object.keys(mat).forEach(function (key) {
613
- var value = mat[key];
614
- if (value && value.original) {
615
- value.copy(value.original);
616
- }
617
- });
618
- mat.needsUpdate = true;
619
- }
620
- });
621
-
622
- // set new material params if provided
623
- // the material object should be located under item.params.material
624
- // item.material is only for backward compatibility
625
- material = params && params.material || item.material;
626
- if (!material) {
627
- _context3.next = 12;
540
+ if (!materialOptions) {
541
+ _context3.next = 6;
628
542
  break;
629
543
  }
630
- _params = material.params;
631
- _context3.t0 = _params;
544
+ params = materialOptions.params;
545
+ _context3.t0 = params;
632
546
  if (!_context3.t0) {
633
- _context3.next = 12;
547
+ _context3.next = 6;
634
548
  break;
635
549
  }
636
- _context3.next = 12;
550
+ _context3.next = 6;
637
551
  return Promise.all(getAllMaterials(model).map( /*#__PURE__*/function () {
638
552
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(material) {
639
553
  var materialName, materialNames;
640
554
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
641
555
  while (1) switch (_context2.prev = _context2.next) {
642
556
  case 0:
643
- materialName = _params.materialName, materialNames = _params.materialNames; // check materialNames list if provided
557
+ materialName = params.materialName, materialNames = params.materialNames; // check materialNames list if provided
644
558
  if (!(materialNames instanceof Array && materialNames.indexOf(material.name) === -1)) {
645
559
  _context2.next = 3;
646
560
  break;
@@ -654,13 +568,13 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
654
568
  return _context2.abrupt("return");
655
569
  case 5:
656
570
  _context2.next = 7;
657
- return Promise.all(Object.keys(_params).map( /*#__PURE__*/function () {
571
+ return Promise.all(Object.keys(params).map( /*#__PURE__*/function () {
658
572
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(p) {
659
573
  var texture, value;
660
574
  return _regeneratorRuntime().wrap(function _callee$(_context) {
661
575
  while (1) switch (_context.prev = _context.next) {
662
576
  case 0:
663
- if (!(_params[p] === UNSET)) {
577
+ if (!(params[p] === UNSET)) {
664
578
  _context.next = 2;
665
579
  break;
666
580
  }
@@ -671,14 +585,14 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
671
585
  break;
672
586
  case 5:
673
587
  texture = material[p] || material.map && material.map.clone() || new _three.Texture();
674
- _context.t1 = findImageBySrc(_this4.sceneContainer, "".concat(_this4._modelBasePath).concat(_params[p]));
588
+ _context.t1 = findImageBySrc(_this4.sceneContainer, "".concat(_this4._modelBasePath).concat(params[p]));
675
589
  if (_context.t1) {
676
590
  _context.next = 11;
677
591
  break;
678
592
  }
679
593
  _context.next = 10;
680
594
  return new Promise(function (resolve, reject) {
681
- return imageLoader.load(_params[p], resolve, undefined, reject);
595
+ return imageLoader.load(params[p], resolve, undefined, reject);
682
596
  });
683
597
  case 10:
684
598
  _context.t1 = _context.sent;
@@ -688,13 +602,13 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
688
602
  material[p] = texture;
689
603
  return _context.abrupt("break", 20);
690
604
  case 15:
691
- value = parseFloat(_params[p]);
605
+ value = parseFloat(params[p]);
692
606
  if (!isNaN(value)) {
693
607
  material[p] = value;
694
608
  }
695
609
  return _context.abrupt("break", 20);
696
610
  case 18:
697
- material[p] = new _three.Color(_params[p]);
611
+ material[p] = new _three.Color(params[p]);
698
612
  return _context.abrupt("break", 20);
699
613
  case 20:
700
614
  case "end":
@@ -702,7 +616,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
702
616
  }
703
617
  }, _callee);
704
618
  }));
705
- return function (_x6) {
619
+ return function (_x5) {
706
620
  return _ref7.apply(this, arguments);
707
621
  };
708
622
  }()));
@@ -715,17 +629,138 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
715
629
  }
716
630
  }, _callee2);
717
631
  }));
718
- return function (_x5) {
632
+ return function (_x4) {
719
633
  return _ref6.apply(this, arguments);
720
634
  };
721
635
  }()));
722
- case 12:
636
+ case 6:
723
637
  case "end":
724
638
  return _context3.stop();
725
639
  }
726
640
  }, _callee3);
727
641
  }));
728
- function applyCustomizations(_x, _x2, _x3) {
642
+ function applyMaterialParams(_x, _x2, _x3) {
643
+ return _applyMaterialParams.apply(this, arguments);
644
+ }
645
+ return applyMaterialParams;
646
+ }()
647
+ }, {
648
+ key: "applyCustomizations",
649
+ value: function () {
650
+ var _applyCustomizations = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(model, item, imageLoader) {
651
+ var _this5 = this;
652
+ var options,
653
+ _options$saveAndResto,
654
+ saveAndRestore,
655
+ params,
656
+ materials,
657
+ material,
658
+ allMaterials,
659
+ _args4 = arguments;
660
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
661
+ while (1) switch (_context4.prev = _context4.next) {
662
+ case 0:
663
+ options = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : {};
664
+ _options$saveAndResto = options.saveAndRestore, saveAndRestore = _options$saveAndResto === void 0 ? true : _options$saveAndResto;
665
+ params = item.params;
666
+ if (params) {
667
+ Object.keys(params).forEach(function (p) {
668
+ // skip not allowed props
669
+ if (allowedObjectProps.indexOf(p) === -1) {
670
+ return;
671
+ }
672
+ // restore original value first
673
+ if (params[p] === UNSET) {
674
+ if (model.originalValues && model.originalValues[p]) {
675
+ model[p].copy(model.originalValues[p]);
676
+ }
677
+ return;
678
+ }
679
+ // store original value for later restoration
680
+ if (!model.originalValues) {
681
+ model.originalValues = {};
682
+ }
683
+ if (!model.originalValues[p]) {
684
+ model.originalValues[p] = model[p] ? model[p].clone() : model[p];
685
+ }
686
+ // apply the param values
687
+ switch (p) {
688
+ case "scale":
689
+ {
690
+ var _params$p = params[p],
691
+ _params$p$x = _params$p.x,
692
+ x = _params$p$x === void 0 ? 1 : _params$p$x,
693
+ _params$p$y = _params$p.y,
694
+ y = _params$p$y === void 0 ? 1 : _params$p$y,
695
+ _params$p$z = _params$p.z,
696
+ z = _params$p$z === void 0 ? 1 : _params$p$z;
697
+ model[p].set(x, y, z);
698
+ break;
699
+ }
700
+ case "rotation":
701
+ case "position":
702
+ {
703
+ var _params$p2 = params[p],
704
+ _params$p2$x = _params$p2.x,
705
+ _x9 = _params$p2$x === void 0 ? 0 : _params$p2$x,
706
+ _params$p2$y = _params$p2.y,
707
+ _y = _params$p2$y === void 0 ? 0 : _params$p2$y,
708
+ _params$p2$z = _params$p2.z,
709
+ _z = _params$p2$z === void 0 ? 0 : _params$p2$z;
710
+ model[p].set(_x9, _y, _z);
711
+ break;
712
+ }
713
+ }
714
+ });
715
+ }
716
+
717
+ // store & restore original material and textures before applying new param values
718
+ saveAndRestore && Object.values(getMaterials(model)).map(function (mat) {
719
+ if (!mat.original) {
720
+ mat.original = mat.clone();
721
+ Object.values(mat).filter(function (value) {
722
+ return value && value.isTexture;
723
+ }).forEach(function (texture) {
724
+ if (!texture.original) {
725
+ texture.original = texture.clone();
726
+ }
727
+ });
728
+ } else {
729
+ mat.copy(mat.original);
730
+ Object.keys(mat).forEach(function (key) {
731
+ var value = mat[key];
732
+ if (value && value.original) {
733
+ value.copy(value.original);
734
+ }
735
+ });
736
+ mat.needsUpdate = true;
737
+ }
738
+ });
739
+
740
+ // set new material params if provided
741
+ // the material object should be located under item.params.material
742
+ // item.material is only for backward compatibility
743
+ materials = (params === null || params === void 0 ? void 0 : params.materials) || [];
744
+ material = (params === null || params === void 0 ? void 0 : params.material) || item.material;
745
+ allMaterials = [].concat(_toConsumableArray(materials), [material]).filter(function (v) {
746
+ return v;
747
+ });
748
+ _context4.t0 = allMaterials.length;
749
+ if (!_context4.t0) {
750
+ _context4.next = 12;
751
+ break;
752
+ }
753
+ _context4.next = 12;
754
+ return Promise.all(allMaterials.map(function (material) {
755
+ return _this5.applyMaterialParams(model, material, imageLoader);
756
+ }));
757
+ case 12:
758
+ case "end":
759
+ return _context4.stop();
760
+ }
761
+ }, _callee4);
762
+ }));
763
+ function applyCustomizations(_x6, _x7, _x8) {
729
764
  return _applyCustomizations.apply(this, arguments);
730
765
  }
731
766
  return applyCustomizations;
@@ -733,7 +768,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
733
768
  }, {
734
769
  key: "loadSceneContainer",
735
770
  value: function loadSceneContainer(item) {
736
- var _this5 = this;
771
+ var _this6 = this;
737
772
  var path;
738
773
  var itemType = _typeof(item);
739
774
  if ("string" === itemType) {
@@ -752,32 +787,32 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
752
787
  var imageLoader = this.createImageLoader(loaderOptions);
753
788
  return new Promise(function (resolve, reject) {
754
789
  modelLoader.load(modelFileName, /*#__PURE__*/function () {
755
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(gltf) {
790
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gltf) {
756
791
  var model;
757
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
758
- while (1) switch (_context4.prev = _context4.next) {
792
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
793
+ while (1) switch (_context5.prev = _context5.next) {
759
794
  case 0:
760
795
  model = gltf.scene;
761
796
  model.userData.path = path;
762
797
  if (undefined !== item.index) {
763
798
  model.userData.index = item.index;
764
799
  }
765
- _this5.fixImportedScene(model);
800
+ _this6.fixImportedScene(model);
766
801
  if (!("object" === itemType)) {
767
- _context4.next = 7;
802
+ _context5.next = 7;
768
803
  break;
769
804
  }
770
- _context4.next = 7;
771
- return _this5.applyCustomizations(model, item, imageLoader);
805
+ _context5.next = 7;
806
+ return _this6.applyCustomizations(model, item, imageLoader);
772
807
  case 7:
773
808
  resolve(gltf);
774
809
  case 8:
775
810
  case "end":
776
- return _context4.stop();
811
+ return _context5.stop();
777
812
  }
778
- }, _callee4);
813
+ }, _callee5);
779
814
  }));
780
- return function (_x7) {
815
+ return function (_x10) {
781
816
  return _ref8.apply(this, arguments);
782
817
  };
783
818
  }(), undefined, reject);
@@ -813,10 +848,10 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
813
848
  }, {
814
849
  key: "initCustomizableMaterialsIfNeeded",
815
850
  value: function () {
816
- var _initCustomizableMaterialsIfNeeded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
851
+ var _initCustomizableMaterialsIfNeeded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
817
852
  var materials;
818
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
819
- while (1) switch (_context5.prev = _context5.next) {
853
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
854
+ while (1) switch (_context6.prev = _context6.next) {
820
855
  case 0:
821
856
  // reset customizable materials to always find the right one in the loaded scene
822
857
  this._customizableMaterialKeys.length = 0;
@@ -826,13 +861,13 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
826
861
  this.guessCustomizableMaterialNameIfNotSet(materials);
827
862
  this.findCustomizableMaterials(materials);
828
863
  }
829
- _context5.next = 6;
864
+ _context6.next = 6;
830
865
  return this.dispatchMaterialUpdateEvent();
831
866
  case 6:
832
867
  case "end":
833
- return _context5.stop();
868
+ return _context6.stop();
834
869
  }
835
- }, _callee5, this);
870
+ }, _callee6, this);
836
871
  }));
837
872
  function initCustomizableMaterialsIfNeeded() {
838
873
  return _initCustomizableMaterialsIfNeeded.apply(this, arguments);
@@ -856,56 +891,56 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
856
891
  }, {
857
892
  key: "loadSceneSync",
858
893
  value: function () {
859
- var _loadSceneSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(resourceList) {
894
+ var _loadSceneSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(resourceList) {
860
895
  var result;
861
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
862
- while (1) switch (_context6.prev = _context6.next) {
896
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
897
+ while (1) switch (_context7.prev = _context7.next) {
863
898
  case 0:
864
- _context6.prev = 0;
865
- _context6.next = 3;
899
+ _context7.prev = 0;
900
+ _context7.next = 3;
866
901
  return this._loadScenePromise;
867
902
  case 3:
868
- _context6.next = 7;
903
+ _context7.next = 7;
869
904
  break;
870
905
  case 5:
871
- _context6.prev = 5;
872
- _context6.t0 = _context6["catch"](0);
906
+ _context7.prev = 5;
907
+ _context7.t0 = _context7["catch"](0);
873
908
  case 7:
874
- _context6.prev = 7;
909
+ _context7.prev = 7;
875
910
  this._loadScenePromise = this.loadScene(resourceList);
876
- _context6.next = 11;
911
+ _context7.next = 11;
877
912
  return this._loadScenePromise;
878
913
  case 11:
879
- result = _context6.sent;
880
- _context6.next = 17;
914
+ result = _context7.sent;
915
+ _context7.next = 17;
881
916
  break;
882
917
  case 14:
883
- _context6.prev = 14;
884
- _context6.t1 = _context6["catch"](7);
918
+ _context7.prev = 14;
919
+ _context7.t1 = _context7["catch"](7);
885
920
  // remove promise if it is failed
886
921
  delete this._loadScenePromise;
887
922
  case 17:
888
- _context6.prev = 17;
889
- _context6.next = 20;
923
+ _context7.prev = 17;
924
+ _context7.next = 20;
890
925
  return this.envMapPromise;
891
926
  case 20:
892
- _context6.next = 24;
927
+ _context7.next = 24;
893
928
  break;
894
929
  case 22:
895
- _context6.prev = 22;
896
- _context6.t2 = _context6["catch"](17);
930
+ _context7.prev = 22;
931
+ _context7.t2 = _context7["catch"](17);
897
932
  case 24:
898
933
  if (!this.isAnimating()) {
899
934
  this.render();
900
935
  }
901
- return _context6.abrupt("return", result);
936
+ return _context7.abrupt("return", result);
902
937
  case 26:
903
938
  case "end":
904
- return _context6.stop();
939
+ return _context7.stop();
905
940
  }
906
- }, _callee6, this, [[0, 5], [7, 14], [17, 22]]);
941
+ }, _callee7, this, [[0, 5], [7, 14], [17, 22]]);
907
942
  }));
908
- function loadSceneSync(_x8) {
943
+ function loadSceneSync(_x11) {
909
944
  return _loadSceneSync.apply(this, arguments);
910
945
  }
911
946
  return loadSceneSync;
@@ -913,11 +948,11 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
913
948
  }, {
914
949
  key: "loadScene",
915
950
  value: function () {
916
- var _loadScene = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(resourceList) {
917
- var _this6 = this;
951
+ var _loadScene = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(resourceList) {
952
+ var _this7 = this;
918
953
  var sceneContainer, _diffResourceLists, toBeRemoved, toBeAdded, toBeUpdated, toBeApplied, shouldResetScene, toBeDisposed, triggerLoadEvent, sceneParts, imageLoader, mixer, animations;
919
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
920
- while (1) switch (_context7.prev = _context7.next) {
954
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
955
+ while (1) switch (_context8.prev = _context8.next) {
921
956
  case 0:
922
957
  sceneContainer = this.sceneContainer;
923
958
  this.stopAnimation();
@@ -942,12 +977,12 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
942
977
  });
943
978
  triggerLoadEvent = !!(toBeAdded.length || toBeUpdated.length || toBeApplied.length);
944
979
  triggerLoadEvent && this.onLoadStart();
945
- _context7.next = 13;
980
+ _context8.next = 13;
946
981
  return Promise.all(toBeAdded.map(function (item) {
947
- return _this6.loadSceneContainer(item);
982
+ return _this7.loadSceneContainer(item);
948
983
  }));
949
984
  case 13:
950
- sceneParts = _context7.sent;
985
+ sceneParts = _context8.sent;
951
986
  sceneParts.forEach(function (_ref10) {
952
987
  var scene = _ref10.scene,
953
988
  animations = _ref10.animations;
@@ -955,10 +990,10 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
955
990
 
956
991
  // collect animations
957
992
  if (animations.length) {
958
- var _this6$animations;
959
- (_this6$animations = _this6.animations).push.apply(_this6$animations, _toConsumableArray(animations.filter(function (_ref11) {
993
+ var _this7$animations;
994
+ (_this7$animations = _this7.animations).push.apply(_this7$animations, _toConsumableArray(animations.filter(function (_ref11) {
960
995
  var name = _ref11.name;
961
- return !_this6.animations.find(function (_ref12) {
996
+ return !_this7.animations.find(function (_ref12) {
962
997
  var existingName = _ref12.name;
963
998
  return name !== existingName;
964
999
  });
@@ -966,7 +1001,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
966
1001
  }
967
1002
  });
968
1003
  sceneContainer.updateWorldMatrix(true, true);
969
- _context7.next = 18;
1004
+ _context8.next = 18;
970
1005
  return Promise.all(toBeUpdated.map(function (item) {
971
1006
  var itemSrc = getSrc(item);
972
1007
  var object = findObjectWith(sceneContainer, function (_ref13) {
@@ -974,28 +1009,30 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
974
1009
  return userData.path === itemSrc && userData.index === item.index;
975
1010
  });
976
1011
  var path = getSrc(item);
977
- var _this6$parseModelPath = _this6.parseModelPath(path),
978
- resourcePath = _this6$parseModelPath.resourcePath;
1012
+ var _this7$parseModelPath = _this7.parseModelPath(path),
1013
+ resourcePath = _this7$parseModelPath.resourcePath;
979
1014
  var loaderOptions = {
980
- basePath: _this6._modelBasePath,
1015
+ basePath: _this7._modelBasePath,
981
1016
  resourcePath: resourcePath
982
1017
  };
983
- var imageLoader = _this6.createImageLoader(loaderOptions);
984
- return object && _this6.applyCustomizations(object, item, imageLoader);
1018
+ var imageLoader = _this7.createImageLoader(loaderOptions);
1019
+ return object && _this7.applyCustomizations(object, item, imageLoader);
985
1020
  }));
986
1021
  case 18:
987
1022
  // apply global or targeted param values
988
1023
  imageLoader = this.createImageLoader({
989
1024
  basePath: this._modelBasePath
990
1025
  });
991
- _context7.next = 21;
1026
+ _context8.next = 21;
992
1027
  return Promise.all(toBeApplied.map(function (_ref14) {
993
1028
  var optionParams = _ref14.params,
994
1029
  files = _ref14.files;
995
1030
  // find model based on objectName
996
1031
  var objectName = optionParams.objectName,
997
1032
  _optionParams$materia = optionParams.material,
998
- material = _optionParams$materia === void 0 ? {} : _optionParams$materia;
1033
+ material = _optionParams$materia === void 0 ? {} : _optionParams$materia,
1034
+ _optionParams$materia2 = optionParams.materials,
1035
+ materials = _optionParams$materia2 === void 0 ? [] : _optionParams$materia2;
999
1036
  var objects = objectName ? findAllObjectsWith(sceneContainer, function (_ref15) {
1000
1037
  var name = _ref15.name;
1001
1038
  return name === objectName;
@@ -1005,17 +1042,22 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1005
1042
  params: _objectSpread(_objectSpread({}, optionParams), {}, {
1006
1043
  material: _objectSpread(_objectSpread({}, material), {}, {
1007
1044
  params: params && mapObjectValues(params, files)
1045
+ }),
1046
+ materials: materials.map(function (material) {
1047
+ return _objectSpread(_objectSpread({}, material), {}, {
1048
+ params: material.params && mapObjectValues(material.params, files)
1049
+ });
1008
1050
  })
1009
1051
  })
1010
1052
  };
1011
1053
  return Promise.all(objects.map(function (object) {
1012
- return _this6.applyCustomizations(object, item, imageLoader, {
1054
+ return _this7.applyCustomizations(object, item, imageLoader, {
1013
1055
  saveAndRestore: false
1014
1056
  });
1015
1057
  }));
1016
1058
  }));
1017
1059
  case 21:
1018
- _context7.next = 23;
1060
+ _context8.next = 23;
1019
1061
  return this.initCustomizableMaterialsIfNeeded();
1020
1062
  case 23:
1021
1063
  this.setupGround();
@@ -1034,11 +1076,11 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1034
1076
  }
1035
1077
  case 29:
1036
1078
  case "end":
1037
- return _context7.stop();
1079
+ return _context8.stop();
1038
1080
  }
1039
- }, _callee7, this);
1081
+ }, _callee8, this);
1040
1082
  }));
1041
- function loadScene(_x9) {
1083
+ function loadScene(_x12) {
1042
1084
  return _loadScene.apply(this, arguments);
1043
1085
  }
1044
1086
  return loadScene;
@@ -1070,7 +1112,7 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1070
1112
  var lookat = dir.multiplyScalar(distance).add(position);
1071
1113
  var rotation = new _three.Quaternion();
1072
1114
  camera.getWorldQuaternion(rotation);
1073
- var orientation = _three.Object3D.DefaultUp.clone().applyQuaternion(rotation);
1115
+ var orientation = _three.Object3D.DefaultUp.clone();
1074
1116
  var fov = camera.fov || 45;
1075
1117
  var cameraView = {
1076
1118
  position: position,
@@ -1146,11 +1188,6 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1146
1188
  };
1147
1189
  }
1148
1190
  this.screenshotViews = this.calculateRelativeViews(this.relativeScreenshotViews, center, (this.controls.minDistance + this.controls.maxDistance) * 0.5);
1149
- if (!this._firstCameraInitDone) {
1150
- this._firstCameraInitDone = true;
1151
- this.currentCameraView = null;
1152
- this.jumpToView("default", false);
1153
- }
1154
1191
  }
1155
1192
  }, {
1156
1193
  key: "initCameraViews",
@@ -1164,8 +1201,18 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1164
1201
  }
1165
1202
  var box = this.getSceneContainerBox();
1166
1203
  var center = box.getCenter(new _three.Vector3());
1204
+ var currentCameraName = this.currentCameraView;
1205
+ var previousCameraView = this.cameraViews[currentCameraName];
1167
1206
  this.setupRelativeCameras(center);
1168
1207
  this.setupSceneCameras(cameras, center);
1208
+ if (!this._firstCameraInitDone) {
1209
+ this._firstCameraInitDone = true;
1210
+ this.currentCameraView = null;
1211
+ this.jumpToView("default", false);
1212
+ } else if (previousCameraView && this.cameraViews[currentCameraName] && !(0, _isEqual["default"])(previousCameraView, this.cameraViews[currentCameraName])) {
1213
+ this.currentCameraView = null;
1214
+ this.jumpToView(currentCameraName, true);
1215
+ }
1169
1216
  }
1170
1217
  }, {
1171
1218
  key: "jumpToView",
@@ -1360,27 +1407,27 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1360
1407
  }, {
1361
1408
  key: "update",
1362
1409
  value: function () {
1363
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(configuration) {
1410
+ var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(configuration) {
1364
1411
  var sceneData;
1365
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1366
- while (1) switch (_context8.prev = _context8.next) {
1412
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1413
+ while (1) switch (_context9.prev = _context9.next) {
1367
1414
  case 0:
1368
1415
  this._configuration = configuration;
1369
1416
  sceneData = (0, _get["default"])(configuration, "visualizationData.sceneData", false) || (0, _get["default"])(configuration, "visualizationData.designViews[0].models.".concat(this._materialVariantPath), false);
1370
- _context8.t0 = sceneData;
1371
- if (!_context8.t0) {
1372
- _context8.next = 6;
1417
+ _context9.t0 = sceneData;
1418
+ if (!_context9.t0) {
1419
+ _context9.next = 6;
1373
1420
  break;
1374
1421
  }
1375
- _context8.next = 6;
1422
+ _context9.next = 6;
1376
1423
  return this.loadSceneSync(sceneData);
1377
1424
  case 6:
1378
1425
  case "end":
1379
- return _context8.stop();
1426
+ return _context9.stop();
1380
1427
  }
1381
- }, _callee8, this);
1428
+ }, _callee9, this);
1382
1429
  }));
1383
- function update(_x10) {
1430
+ function update(_x13) {
1384
1431
  return _update.apply(this, arguments);
1385
1432
  }
1386
1433
  return update;
@@ -1388,24 +1435,24 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1388
1435
  }, {
1389
1436
  key: "updateMaterial",
1390
1437
  value: function () {
1391
- var _updateMaterial = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1438
+ var _updateMaterial = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1392
1439
  var sceneData;
1393
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1394
- while (1) switch (_context9.prev = _context9.next) {
1440
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1441
+ while (1) switch (_context10.prev = _context10.next) {
1395
1442
  case 0:
1396
1443
  sceneData = (0, _get["default"])(this._designAreaList, "[0].designView.models.".concat(this._materialVariantPath)) || (0, _get["default"])(this._configuration, "visualizationData.designViews[0].models.".concat(this._materialVariantPath)) || false;
1397
- _context9.t0 = sceneData;
1398
- if (!_context9.t0) {
1399
- _context9.next = 5;
1444
+ _context10.t0 = sceneData;
1445
+ if (!_context10.t0) {
1446
+ _context10.next = 5;
1400
1447
  break;
1401
1448
  }
1402
- _context9.next = 5;
1449
+ _context10.next = 5;
1403
1450
  return this.loadSceneSync(sceneData);
1404
1451
  case 5:
1405
1452
  case "end":
1406
- return _context9.stop();
1453
+ return _context10.stop();
1407
1454
  }
1408
- }, _callee9, this);
1455
+ }, _callee10, this);
1409
1456
  }));
1410
1457
  function updateMaterial() {
1411
1458
  return _updateMaterial.apply(this, arguments);
@@ -1415,27 +1462,27 @@ var Three3DScene = exports.Three3DScene = /*#__PURE__*/function (_Three3D) {
1415
1462
  }, {
1416
1463
  key: "updateDesignAreaList",
1417
1464
  value: function () {
1418
- var _updateDesignAreaList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(designAreaList) {
1465
+ var _updateDesignAreaList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(designAreaList) {
1419
1466
  var sceneData;
1420
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1421
- while (1) switch (_context10.prev = _context10.next) {
1467
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1468
+ while (1) switch (_context11.prev = _context11.next) {
1422
1469
  case 0:
1423
1470
  this._designAreaList = designAreaList;
1424
1471
  sceneData = (0, _get["default"])(designAreaList, "[0].designView.models.".concat(this._materialVariantPath));
1425
- _context10.t0 = sceneData;
1426
- if (!_context10.t0) {
1427
- _context10.next = 6;
1472
+ _context11.t0 = sceneData;
1473
+ if (!_context11.t0) {
1474
+ _context11.next = 6;
1428
1475
  break;
1429
1476
  }
1430
- _context10.next = 6;
1477
+ _context11.next = 6;
1431
1478
  return this.loadSceneSync(sceneData);
1432
1479
  case 6:
1433
1480
  case "end":
1434
- return _context10.stop();
1481
+ return _context11.stop();
1435
1482
  }
1436
- }, _callee10, this);
1483
+ }, _callee11, this);
1437
1484
  }));
1438
- function updateDesignAreaList(_x11) {
1485
+ function updateDesignAreaList(_x14) {
1439
1486
  return _updateDesignAreaList.apply(this, arguments);
1440
1487
  }
1441
1488
  return updateDesignAreaList;