@colijnit/configurator 12.0.14 → 12.0.16
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/app/builder.d.ts +6 -0
- package/bundles/colijnit-configurator.umd.js +76 -24
- package/bundles/colijnit-configurator.umd.js.map +1 -1
- package/colijnit-configurator.metadata.json +1 -1
- package/esm2015/app/builder.js +72 -23
- package/esm2015/utils/threed.utils.js +6 -2
- package/fesm2015/colijnit-configurator.js +75 -23
- package/fesm2015/colijnit-configurator.js.map +1 -1
- package/package.json +1 -1
package/app/builder.d.ts
CHANGED
|
@@ -49,6 +49,12 @@ export declare class Builder {
|
|
|
49
49
|
private _downloadAsset;
|
|
50
50
|
private _build;
|
|
51
51
|
private _prepareTheSelections;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the materialId of the parent up the tree until presentionlevel 1 is reached
|
|
54
|
+
* @param id
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
private _getMaterialIdFromParent;
|
|
52
58
|
private _createAdjustable;
|
|
53
59
|
private _createAddable;
|
|
54
60
|
private _placeAddables;
|
|
@@ -532,7 +532,7 @@
|
|
|
532
532
|
};
|
|
533
533
|
ThreedUtils.prototype.loadGlbSource = function (file) {
|
|
534
534
|
return __awaiter(this, void 0, void 0, function () {
|
|
535
|
-
var obj, children;
|
|
535
|
+
var obj, children, name, parent;
|
|
536
536
|
return __generator(this, function (_a) {
|
|
537
537
|
switch (_a.label) {
|
|
538
538
|
case 0: return [4 /*yield*/, this.loadGlbModel(file, false)];
|
|
@@ -549,8 +549,12 @@
|
|
|
549
549
|
});
|
|
550
550
|
if (obj.children.length === 1 && obj.children[0] instanceof THREE__namespace.Group) { // flatten children
|
|
551
551
|
children = obj.children[0].children.slice();
|
|
552
|
+
name = obj.children[0].name;
|
|
552
553
|
obj.children.length = 0;
|
|
553
|
-
|
|
554
|
+
parent = new THREE__namespace.Object3D();
|
|
555
|
+
parent.name = name;
|
|
556
|
+
parent.children = children;
|
|
557
|
+
obj.add(parent);
|
|
554
558
|
}
|
|
555
559
|
}
|
|
556
560
|
return [2 /*return*/, obj];
|
|
@@ -2593,37 +2597,66 @@
|
|
|
2593
2597
|
.filter(function (s) { return s.generic && s.decoNode.variation && !s.decoNode.type; })
|
|
2594
2598
|
.map(function (value, index, array) {
|
|
2595
2599
|
// find selection of variation
|
|
2596
|
-
var sel = _this._selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.
|
|
2600
|
+
var sel = _this._selections.find(function (s) { return s.artNodeIdDeco === value.decoNode.variation.parentId; });
|
|
2597
2601
|
if (sel) {
|
|
2598
2602
|
value.decoNode.variation.supplierArticleNr = sel.supplierArticleNr;
|
|
2599
2603
|
}
|
|
2600
|
-
value.decoNode.variation.materialId = value.
|
|
2604
|
+
value.decoNode.variation.materialId = _this._getMaterialIdFromParent(value.node);
|
|
2601
2605
|
return value.decoNode.variation;
|
|
2602
2606
|
});
|
|
2603
|
-
|
|
2607
|
+
var selections = this._selections.slice();
|
|
2608
|
+
// commented out for the moment
|
|
2609
|
+
// globalVariations.forEach(g => {
|
|
2610
|
+
// const parentIdx = selections.findIndex(s => s.decoNode && s.decoNode.id === g.parentId);
|
|
2611
|
+
// if (parentIdx) { // remove parent selection
|
|
2612
|
+
// selections.splice(parentIdx, 1);
|
|
2613
|
+
// }
|
|
2614
|
+
// const idx = selections.findIndex(s => s.decoNode && s.decoNode.id === g.id);
|
|
2615
|
+
// if (idx) { // move generic variations to top
|
|
2616
|
+
// const selection = selections[idx];
|
|
2617
|
+
// selections.splice(idx, 1);
|
|
2618
|
+
// selections.unshift(selection);
|
|
2619
|
+
// }
|
|
2620
|
+
// });
|
|
2604
2621
|
var globalVariationsRewrite = true;
|
|
2605
|
-
var len =
|
|
2622
|
+
var len = selections.length;
|
|
2606
2623
|
var lastAdded;
|
|
2607
2624
|
var lastAdjustable;
|
|
2608
2625
|
var newPart = false;
|
|
2609
2626
|
var previousPresLevel = -1;
|
|
2610
2627
|
var positioning;
|
|
2628
|
+
var optionText;
|
|
2629
|
+
var selectionOfArticle = selections.find(function (s) { return s.nodeType === nodeType_enum.NodeType.Article; });
|
|
2630
|
+
var adjustableSelections = selections.filter(function (s) { return s.addAdjust === '2'; });
|
|
2631
|
+
var isArticleWithMaterial = adjustableSelections.length === 0 &&
|
|
2632
|
+
selectionOfArticle.gameObject &&
|
|
2633
|
+
selectionOfArticle.gameObject.length > 0;
|
|
2611
2634
|
for (var i = 0; i < len; i++) {
|
|
2612
|
-
var selection =
|
|
2635
|
+
var selection = selections[i];
|
|
2613
2636
|
if (selection.presentationLevel === 1) {
|
|
2614
2637
|
positioning = selection.hdecoPositioning;
|
|
2638
|
+
optionText = selection.question;
|
|
2615
2639
|
}
|
|
2616
2640
|
if (selection.presentationLevel > previousPresLevel) {
|
|
2617
2641
|
selection.hdecoPositioning = selection.hdecoPositioning || positioning;
|
|
2618
2642
|
}
|
|
2619
2643
|
if (selection.decoNode) {
|
|
2620
2644
|
if (selection.decoNode.type === decoNodeType_enum.DecoNodeType.Variation) {
|
|
2645
|
+
var decoNode = selection.decoNode;
|
|
2646
|
+
decoNode.optionText = optionText;
|
|
2647
|
+
// find selection of variation and set materialId in case of multimaterial
|
|
2648
|
+
decoNode.materialId = this._getMaterialIdFromParent(decoNode.nodeId);
|
|
2621
2649
|
if (lastAdded) {
|
|
2622
2650
|
if (newPart) {
|
|
2623
|
-
|
|
2651
|
+
if (decoNode.materialId) {
|
|
2652
|
+
lastAdded.variations.push(decoNode);
|
|
2653
|
+
}
|
|
2654
|
+
else {
|
|
2655
|
+
lastAdded.variations = [decoNode];
|
|
2656
|
+
}
|
|
2624
2657
|
}
|
|
2625
2658
|
else {
|
|
2626
|
-
lastAdded.variations.push(
|
|
2659
|
+
lastAdded.variations.push(decoNode);
|
|
2627
2660
|
}
|
|
2628
2661
|
newPart = false;
|
|
2629
2662
|
}
|
|
@@ -2632,7 +2665,7 @@
|
|
|
2632
2665
|
globalVariations.length = 0;
|
|
2633
2666
|
globalVariationsRewrite = false;
|
|
2634
2667
|
}
|
|
2635
|
-
globalVariations.push(
|
|
2668
|
+
globalVariations.push(decoNode);
|
|
2636
2669
|
}
|
|
2637
2670
|
// const variation: FurniturePartVariation = new FurniturePartVariation();
|
|
2638
2671
|
// variation.BrandId = selection.decoNode.brandId;
|
|
@@ -2640,19 +2673,14 @@
|
|
|
2640
2673
|
// variation.MaterialId = (selection.decoNode as any).materialId;
|
|
2641
2674
|
// variation.SupplierArticleNr = (selection.decoNode as any).supplierArticleNr;
|
|
2642
2675
|
// usedVariations.push(variation);
|
|
2643
|
-
// this._upsertFurniture(this.activeInstance, {
|
|
2644
|
-
// Variation: selection.decoNode.brandId,
|
|
2645
|
-
// VariationDescription: selection.decoNode.gameObjectName,
|
|
2646
|
-
// SupplierArticleNr: (selection.decoNode as any).supplierArticleNr
|
|
2647
|
-
// });
|
|
2648
2676
|
}
|
|
2649
|
-
else if (selection.decoNode.type === decoNodeType_enum.DecoNodeType.Part &&
|
|
2677
|
+
else if ((selection.decoNode.type === decoNodeType_enum.DecoNodeType.Part &&
|
|
2650
2678
|
typeof selection.decoNode.gameObjectName === 'string' &&
|
|
2651
|
-
selection.decoNode.gameObjectName.length) {
|
|
2652
|
-
if (selection.decoNode.kind === decoNodeKind_enum.DecoNodeKind.Adjustable) {
|
|
2679
|
+
selection.decoNode.gameObjectName.length) || (isArticleWithMaterial)) {
|
|
2680
|
+
if (selection.decoNode.kind === decoNodeKind_enum.DecoNodeKind.Adjustable || (isArticleWithMaterial)) {
|
|
2653
2681
|
selection.variations = globalVariations;
|
|
2654
2682
|
this._adjustables.push(selection);
|
|
2655
|
-
if (!lastAdded || lastAdded.nodeId !== selection.nodeId) {
|
|
2683
|
+
if (!lastAdded || (lastAdded.nodeId !== selection.nodeId || lastAdded.node !== selection.node)) {
|
|
2656
2684
|
newPart = true;
|
|
2657
2685
|
}
|
|
2658
2686
|
lastAdded = selection;
|
|
@@ -2664,7 +2692,7 @@
|
|
|
2664
2692
|
lastAdjustable.addables.push(selection);
|
|
2665
2693
|
}
|
|
2666
2694
|
this._addables.push(selection);
|
|
2667
|
-
if (!lastAdded || lastAdded.nodeId !== selection.nodeId) {
|
|
2695
|
+
if (!lastAdded || (lastAdded.nodeId !== selection.nodeId || lastAdded.node !== selection.node)) {
|
|
2668
2696
|
newPart = true;
|
|
2669
2697
|
}
|
|
2670
2698
|
lastAdded = selection;
|
|
@@ -2676,14 +2704,36 @@
|
|
|
2676
2704
|
// this._upsertFurniture(this.activeInstance,
|
|
2677
2705
|
// {Variations: usedVariations});
|
|
2678
2706
|
};
|
|
2707
|
+
/**
|
|
2708
|
+
* Returns the materialId of the parent up the tree until presentionlevel 1 is reached
|
|
2709
|
+
* @param id
|
|
2710
|
+
* @private
|
|
2711
|
+
*/
|
|
2712
|
+
Builder.prototype._getMaterialIdFromParent = function (id) {
|
|
2713
|
+
var idx = this._selections.findIndex(function (s) { return s.node === id; });
|
|
2714
|
+
var currentLevel = 999;
|
|
2715
|
+
if (idx > -1) {
|
|
2716
|
+
for (var i = idx; i > 0; i--) {
|
|
2717
|
+
var selection = this._selections[i];
|
|
2718
|
+
if (selection.presentationLevel >= currentLevel) {
|
|
2719
|
+
break;
|
|
2720
|
+
}
|
|
2721
|
+
currentLevel = selection.presentationLevel;
|
|
2722
|
+
if (selection.hdecoGameObject) {
|
|
2723
|
+
return selection.hdecoGameObject;
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
return undefined;
|
|
2728
|
+
};
|
|
2679
2729
|
Builder.prototype._createAdjustable = function (parent, adj) {
|
|
2680
|
-
var obj = this._source ? this._source.getObjectByName(adj.decoNode.gameObjectName) : null;
|
|
2730
|
+
var obj = this._source ? this._source.getObjectByName(adj.decoNode.gameObjectName || adj.gameObject) : null;
|
|
2681
2731
|
if (!obj) {
|
|
2682
2732
|
// in case of glb files, the importer removes dots from names
|
|
2683
2733
|
var name = adj.decoNode.gameObjectName.replace(/[.]/g, '');
|
|
2684
2734
|
obj = this._source ? this._source.getObjectByName(name) : null;
|
|
2685
2735
|
if (!obj) {
|
|
2686
|
-
|
|
2736
|
+
console.warn("No object with name " + adj.decoNode.gameObjectName + " found!");
|
|
2687
2737
|
return null;
|
|
2688
2738
|
}
|
|
2689
2739
|
}
|
|
@@ -2691,11 +2741,13 @@
|
|
|
2691
2741
|
adjustable.name = this._createUniqueName(parent, obj);
|
|
2692
2742
|
adjustable.userData.selection = adj;
|
|
2693
2743
|
adjustable.position.set(0, 0, 0);
|
|
2694
|
-
adjustable.
|
|
2744
|
+
adjustable.traverse(function (c) {
|
|
2745
|
+
c.visible = !c.name.toLowerCase().startsWith('c_');
|
|
2746
|
+
});
|
|
2695
2747
|
parent.add(adjustable);
|
|
2696
2748
|
// the object being added to the customFloorGroup is being recreated so we loose the reference
|
|
2697
2749
|
// therefor we need to retrieve the created object again
|
|
2698
|
-
|
|
2750
|
+
adjustable = parent.getObjectByName(adjustable.name);
|
|
2699
2751
|
this._placedAdjustables.push(adjustable);
|
|
2700
2752
|
return adjustable;
|
|
2701
2753
|
};
|