x_ite 10.4.1 → 10.5.0

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.
Files changed (51) hide show
  1. package/README.md +4 -4
  2. package/dist/X3DUOM.xml +10 -0
  3. package/dist/assets/components/AnnotationComponent.js +2 -2
  4. package/dist/assets/components/AnnotationComponent.min.js +2 -2
  5. package/dist/assets/components/CADGeometryComponent.js +2 -2
  6. package/dist/assets/components/CADGeometryComponent.min.js +2 -2
  7. package/dist/assets/components/CubeMapTexturingComponent.js +7 -7
  8. package/dist/assets/components/CubeMapTexturingComponent.min.js +2 -2
  9. package/dist/assets/components/DISComponent.js +2 -2
  10. package/dist/assets/components/DISComponent.min.js +2 -2
  11. package/dist/assets/components/EventUtilitiesComponent.js +2 -2
  12. package/dist/assets/components/EventUtilitiesComponent.min.js +2 -2
  13. package/dist/assets/components/Geometry2DComponent.js +19 -23
  14. package/dist/assets/components/Geometry2DComponent.min.js +2 -2
  15. package/dist/assets/components/GeospatialComponent.js +2 -2
  16. package/dist/assets/components/GeospatialComponent.min.js +2 -2
  17. package/dist/assets/components/HAnimComponent.js +2 -2
  18. package/dist/assets/components/HAnimComponent.min.js +2 -2
  19. package/dist/assets/components/KeyDeviceSensorComponent.js +2 -2
  20. package/dist/assets/components/KeyDeviceSensorComponent.min.js +2 -2
  21. package/dist/assets/components/LayoutComponent.js +3 -7
  22. package/dist/assets/components/LayoutComponent.min.js +2 -2
  23. package/dist/assets/components/NURBSComponent.js +859 -812
  24. package/dist/assets/components/NURBSComponent.min.js +2 -2
  25. package/dist/assets/components/ParticleSystemsComponent.js +10 -13
  26. package/dist/assets/components/ParticleSystemsComponent.min.js +2 -2
  27. package/dist/assets/components/PickingComponent.js +2 -2
  28. package/dist/assets/components/PickingComponent.min.js +2 -2
  29. package/dist/assets/components/RigidBodyPhysicsComponent.js +2 -2
  30. package/dist/assets/components/RigidBodyPhysicsComponent.min.js +2 -2
  31. package/dist/assets/components/ScriptingComponent.js +2 -2
  32. package/dist/assets/components/ScriptingComponent.min.js +2 -2
  33. package/dist/assets/components/TextComponent.js +9 -17
  34. package/dist/assets/components/TextComponent.min.js +2 -2
  35. package/dist/assets/components/TextureProjectionComponent.js +14 -8
  36. package/dist/assets/components/TextureProjectionComponent.min.js +2 -2
  37. package/dist/assets/components/Texturing3DComponent.js +16 -16
  38. package/dist/assets/components/Texturing3DComponent.min.js +2 -2
  39. package/dist/assets/components/VolumeRenderingComponent.js +2 -2
  40. package/dist/assets/components/VolumeRenderingComponent.min.js +2 -2
  41. package/dist/assets/components/X_ITEComponent.js +87 -54
  42. package/dist/assets/components/X_ITEComponent.min.js +2 -2
  43. package/dist/example.html +1 -1
  44. package/dist/x_ite.css +1 -1
  45. package/dist/x_ite.d.ts +12 -0
  46. package/dist/x_ite.js +1166 -1125
  47. package/dist/x_ite.min.js +2 -2
  48. package/dist/x_ite.min.mjs +2 -2
  49. package/dist/x_ite.mjs +1166 -1125
  50. package/dist/x_ite.zip +0 -0
  51. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
- /* X_ITE v10.4.1 */
2
- const __X_ITE_X3D__ = window [Symbol .for ("X_ITE.X3D-10.4.1")];
1
+ /* X_ITE v10.5.0 */
2
+ const __X_ITE_X3D__ = window [Symbol .for ("X_ITE.X3D-10.5.0")];
3
3
  /******/ (() => { // webpackBootstrap
4
4
  /******/ "use strict";
5
5
  /******/ // The require scope
@@ -162,33 +162,37 @@ Object .assign (Object .setPrototypeOf (Contour2D .prototype, (external_X_ITE_X3
162
162
  {
163
163
  const childNodes = this .childNodes;
164
164
 
165
+ for (const childNode of childNodes)
166
+ childNode .removeInterest ("addNodeEvent", this);
167
+
165
168
  childNodes .length = 0;
166
169
 
167
170
  for (const node of this ._children)
168
171
  {
169
- const childNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).NurbsCurve2D, node);
172
+ const childNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).NurbsCurve2D, node)
173
+ ?? external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).ContourPolyline2D, node);
170
174
 
171
175
  if (childNode)
172
- {
173
176
  childNodes .push (childNode);
174
- continue;
175
- }
176
- else
177
- {
178
- const childNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).ContourPolyline2D, node);
179
-
180
- if (childNode)
181
- {
182
- childNodes .push (childNode);
183
- continue;
184
- }
185
- }
186
177
  }
178
+
179
+ for (const childNode of childNodes)
180
+ childNode .addInterest ("addNodeEvent", this);
187
181
  },
188
- addTrimmingContour (trimmingContours)
182
+ addTrimmingContour (offset, scale, trimmingContours)
189
183
  {
184
+ const trimmingContour = [ ];
185
+
190
186
  for (const childNode of this .childNodes)
191
- trimmingContours .push (childNode .tessellate (2));
187
+ childNode .tessellate (2, trimmingContour);
188
+
189
+ if (!trimmingContour .length)
190
+ return;
191
+
192
+ for (const point of trimmingContour)
193
+ point .subtract (offset) .divVec (scale);
194
+
195
+ trimmingContours .push (trimmingContour);
192
196
  }
193
197
  });
194
198
 
@@ -349,75 +353,47 @@ function ContourPolyline2D (executionContext)
349
353
 
350
354
  this .addType ((external_X_ITE_X3D_X3DConstants_default()).ContourPolyline2D);
351
355
 
352
- this .controlPoints = [ ];
356
+ this .array = [ ];
353
357
  }
354
358
 
355
359
  Object .assign (Object .setPrototypeOf (ContourPolyline2D .prototype, NURBS_X3DNurbsControlCurveNode .prototype),
356
360
  {
357
- tessellate (type)
361
+ tessellate (type, array = this .array)
358
362
  {
363
+ const
364
+ controlPoints = this ._controlPoint .getValue (),
365
+ numControlPoints = this ._controlPoint .length * 2;
366
+
359
367
  switch (type)
360
368
  {
361
369
  case 0:
362
370
  {
363
- const
364
- controlPointArray = this ._controlPoint .getValue (),
365
- controlPoints = this .controlPoints,
366
- length = this ._controlPoint .length;
367
-
368
- for (let i = 0; i < length; ++ i)
369
- {
370
- const i2 = i * 2;
371
-
372
- controlPoints [i2 + 0] = controlPointArray [i2 + 0];
373
- controlPoints [i2 + 1] = controlPointArray [i2 + 1];
374
- }
371
+ array .length = 0;
375
372
 
376
- controlPoints .length = length * 2;
373
+ for (let i = 0; i < numControlPoints; i += 2)
374
+ array .push (controlPoints [i], controlPoints [i + 1]);
377
375
 
378
- return controlPoints;
376
+ break;
379
377
  }
380
378
  case 1:
381
379
  {
382
- const
383
- controlPointArray = this ._controlPoint .getValue (),
384
- controlPoints = this .controlPoints,
385
- length = this ._controlPoint .length;
386
-
387
- for (let i = 0; i < length; ++ i)
388
- {
389
- const
390
- i2 = i * 2,
391
- i3 = i * 3;
392
-
393
- controlPoints [i3 + 0] = controlPointArray [i2 + 0];
394
- controlPoints [i3 + 1] = 0;
395
- controlPoints [i3 + 2] = controlPointArray [i2 + 1];
396
- }
380
+ array .length = 0;
397
381
 
398
- controlPoints .length = length * 3;
382
+ for (let i = 0; i < numControlPoints; i += 2)
383
+ array .push (controlPoints [i], 0, controlPoints [i + 1]);
399
384
 
400
- return controlPoints;
385
+ break;
401
386
  }
402
- case 3:
387
+ case 2: // Contour2D
403
388
  {
404
- const
405
- controlPointArray = this ._controlPoint .getValue (),
406
- controlPoints = this .controlPoints,
407
- length = this ._controlPoint .length;
408
-
409
- for (let i = 0; i < length; ++ i)
410
- {
411
- const i2 = i * 2;
412
-
413
- controlPoints [i] = new (external_X_ITE_X3D_Vector3_default()) (controlPointArray [i2 + 0], controlPointArray [i2 + 1], 0);
414
- }
389
+ for (let i = 0; i < numControlPoints; i += 2)
390
+ array .push (new (external_X_ITE_X3D_Vector3_default()) (controlPoints [i], controlPoints [i + 1], 0));
415
391
 
416
- controlPoints .length = length;
417
-
418
- return controlPoints;
392
+ break;
419
393
  }
420
394
  }
395
+
396
+ return array;
421
397
  },
422
398
  });
423
399
 
@@ -499,16 +475,17 @@ var external_X_ITE_X3D_Vector4_default = /*#__PURE__*/__webpack_require__.n(exte
499
475
 
500
476
 
501
477
 
502
- const NURBS = {
478
+ const NURBS =
479
+ {
503
480
  getTessellation (tessellation, dimension)
504
481
  {
505
482
  if (tessellation > 0)
506
- return tessellation + 1;
483
+ return tessellation;
507
484
 
508
485
  if (tessellation < 0)
509
- return -tessellation * dimension + 1;
486
+ return -tessellation * dimension;
510
487
 
511
- return 2 * dimension + 1;
488
+ return 2 * dimension;
512
489
  },
513
490
  getClosed2D (order, knot, weight, controlPoint)
514
491
  {
@@ -526,12 +503,7 @@ const NURBS = {
526
503
 
527
504
  // Check if first and last point are coincident.
528
505
 
529
- if (! controlPoint [0] .equals (controlPoint [dimension - 1]))
530
- return false;
531
-
532
- // Check if knots are periodic.
533
-
534
- if (! this .isPeriodic (order, dimension, knot))
506
+ if (!controlPoint [0] .equals (controlPoint [dimension - 1]))
535
507
  return false;
536
508
 
537
509
  return true;
@@ -558,12 +530,7 @@ const NURBS = {
558
530
 
559
531
  // Check if first and last point are coincident.
560
532
 
561
- if (! controlPointNode .get1Point (0, firstPoint) .equals (controlPointNode .get1Point (dimension - 1, lastPoint)))
562
- return false;
563
-
564
- // Check if knots are periodic.
565
-
566
- if (! this .isPeriodic (order, dimension, knot))
533
+ if (!controlPointNode .get1Point (0, firstPoint) .equals (controlPointNode .get1Point (dimension - 1, lastPoint)))
567
534
  return false;
568
535
 
569
536
  return true;
@@ -579,7 +546,7 @@ const NURBS = {
579
546
  {
580
547
  const haveWeights = weight .length === controlPointNode .getSize ();
581
548
 
582
- for (let v = 0, length = vDimension; v < length; ++ v)
549
+ for (let v = 0; v < vDimension; ++ v)
583
550
  {
584
551
  const
585
552
  first = v * uDimension,
@@ -595,15 +562,10 @@ const NURBS = {
595
562
 
596
563
  // Check if first and last point are coincident.
597
564
 
598
- if (! controlPointNode .get1Point (first, firstPoint) .equals (controlPointNode .get1Point (last, lastPoint)))
565
+ if (!controlPointNode .get1Point (first, firstPoint) .equals (controlPointNode .get1Point (last, lastPoint)))
599
566
  return false;
600
567
  }
601
568
 
602
- // Check if knots are periodic.
603
-
604
- if (! this .isPeriodic (uOrder, uDimension, uKnot))
605
- return false;
606
-
607
569
  return true;
608
570
  };
609
571
  })(),
@@ -617,7 +579,7 @@ const NURBS = {
617
579
  {
618
580
  const haveWeights = weight .length === controlPointNode .getSize ();
619
581
 
620
- for (let u = 0, size = uDimension; u < size; ++ u)
582
+ for (let u = 0; u < uDimension; ++ u)
621
583
  {
622
584
  const
623
585
  first = u,
@@ -633,56 +595,20 @@ const NURBS = {
633
595
 
634
596
  // Check if first and last point are coincident.
635
597
 
636
- if (! controlPointNode .get1Point (first, firstPoint) .equals (controlPointNode .get1Point (last, lastPoint)))
598
+ if (!controlPointNode .get1Point (first, firstPoint) .equals (controlPointNode .get1Point (last, lastPoint)))
637
599
  return false;
638
600
  }
639
601
 
640
- // Check if knots are periodic.
641
-
642
- if (! this .isPeriodic (vOrder, vDimension, vKnot))
643
- return false;
644
-
645
602
  return true;
646
603
  };
647
604
  })(),
648
- isPeriodic (order, dimension, knot)
649
- {
650
- // Check if knots are periodic.
651
-
652
- if (knot .length === dimension + order)
653
- {
654
- {
655
- let count = 1;
656
-
657
- for (let i = 1, size = order; i < size; ++ i)
658
- {
659
- count += knot [i] === knot [0];
660
- }
661
-
662
- if (count === order)
663
- return false;
664
- }
665
-
666
- {
667
- let count = 1;
668
-
669
- for (let i = knot .length - order, size = knot .length - 1; i < size; ++ i)
670
- {
671
- count += knot [i] === knot [size];
672
- }
673
-
674
- if (count === order)
675
- return false;
676
- }
677
- }
678
-
679
- return true;
680
- },
681
605
  getKnots (result, closed, order, dimension, knot)
682
606
  {
683
- const knots = result || [ ];
607
+ const
608
+ length = dimension + order,
609
+ knots = result ?? [ ];
684
610
 
685
- for (let i = 0, length = knot .length; i < length; ++ i)
611
+ for (let i = 0, l = knot .length; i < l; ++ i)
686
612
  knots [i] = knot [i];
687
613
 
688
614
  knots .length = knot .length;
@@ -692,15 +618,15 @@ const NURBS = {
692
618
 
693
619
  let generateUniform = true;
694
620
 
695
- if (knots .length === dimension + order)
621
+ if (knots .length === length)
696
622
  {
697
623
  generateUniform = false;
698
624
 
699
625
  let consecutiveKnots = 0;
700
626
 
701
- for (let i = 1, length = knots .length; i < length; ++ i)
627
+ for (let i = 1; i < length; ++ i)
702
628
  {
703
- if (knots [i] == knots [i - 1])
629
+ if (knots [i] === knots [i - 1])
704
630
  ++ consecutiveKnots;
705
631
  else
706
632
  consecutiveKnots = 0;
@@ -715,13 +641,48 @@ const NURBS = {
715
641
 
716
642
  if (generateUniform)
717
643
  {
718
- for (let i = 0, length = dimension + order; i < length; ++ i)
719
- knots [i] = i / (length - 1);
644
+ if (closed)
645
+ {
646
+ // Generate periodic uniform knots.
647
+
648
+ for (let i = 0; i < length; ++ i)
649
+ knots [i] = i;
650
+ }
651
+ else
652
+ {
653
+ // Generate pinned uniform knots.
654
+
655
+ let
656
+ i = 0,
657
+ k = 1;
658
+
659
+ for (; i < order; ++ i)
660
+ knots [i] = 0;
661
+
662
+ for (const l = length - order; i < l; ++ i, ++ k)
663
+ knots [i] = k;
664
+
665
+ for (; i < length; ++ i)
666
+ knots [i] = k;
667
+ }
668
+
669
+ knots .length = length;
670
+
671
+ // Scale knots.
672
+
673
+ const max = knots .at (-1);
674
+
675
+ for (let i = 0; i < length; ++ i)
676
+ knots [i] /= max;
720
677
  }
721
678
 
722
679
  if (closed)
723
680
  {
724
- for (let i = 1, length = order - 1; i < length; ++ i)
681
+ // Make knots periodic.
682
+
683
+ const l = order - 1;
684
+
685
+ for (let i = 1; i < l; ++ i)
725
686
  knots .push (knots .at (-1) + (knots [i] - knots [i - 1]));
726
687
  }
727
688
 
@@ -732,7 +693,7 @@ const NURBS = {
732
693
  if (weight .length !== dimension)
733
694
  return undefined;
734
695
 
735
- const weights = result || [ ];
696
+ const weights = result ?? [ ];
736
697
 
737
698
  for (let i = 0; i < dimension; ++ i)
738
699
  {
@@ -750,7 +711,7 @@ const NURBS = {
750
711
  if (weight .length !== dimension)
751
712
  return undefined;
752
713
 
753
- const weights = result || [ ];
714
+ const weights = result ?? [ ];
754
715
 
755
716
  for (let u = 0, i = 0; u < uDimension; ++ u)
756
717
  {
@@ -767,7 +728,7 @@ const NURBS = {
767
728
  getControlPoints2D (result, closed, order, weights, controlPoint)
768
729
  {
769
730
  const
770
- controlPoints = result || [ ],
731
+ controlPoints = result ?? [ ],
771
732
  controlPointArray = controlPoint .getValue (),
772
733
  dimension = controlPoint .length,
773
734
  haveWeights = !! weights,
@@ -783,16 +744,18 @@ const NURBS = {
783
744
  {
784
745
  const
785
746
  i2 = i * 2,
786
- p = controlPoints [i] || new Vector (0, 0, 0);
747
+ cp = controlPoints [i] ??= new Vector (0, 0, 0);
787
748
 
788
- controlPoints [i] = p .set (controlPointArray [i2 + 0], controlPointArray [i2 + 1], haveWeights ? weights [i] : 0);
749
+ cp .set (controlPointArray [i2 + 0], controlPointArray [i2 + 1], haveWeights ? weights [i] : 0);
789
750
  }
790
751
 
791
752
  controlPoints .length = dimension;
792
753
 
793
754
  if (closed)
794
755
  {
795
- for (let i = 1, size = order - 1; i < size; ++ i)
756
+ const length = order - 1;
757
+
758
+ for (let i = 1; i < length; ++ i)
796
759
  controlPoints .push (controlPoints [i]);
797
760
  }
798
761
 
@@ -801,7 +764,7 @@ const NURBS = {
801
764
  getControlPoints (result, closed, order, weights, controlPointNode)
802
765
  {
803
766
  const
804
- controlPoints = result || [ ],
767
+ controlPoints = result ?? [ ],
805
768
  dimension = controlPointNode .getSize (),
806
769
  haveWeights = !! weights,
807
770
  Vector = haveWeights ? (external_X_ITE_X3D_Vector4_default()) : (external_X_ITE_X3D_Vector3_default());
@@ -814,7 +777,7 @@ const NURBS = {
814
777
 
815
778
  for (let i = 0; i < dimension; ++ i)
816
779
  {
817
- const cp = controlPoints [i] = controlPointNode .get1Point (i, controlPoints [i] || new Vector (0, 0, 0, 0));
780
+ const cp = controlPointNode .get1Point (i, controlPoints [i] ??= new Vector (0, 0, 0, 0));
818
781
 
819
782
  if (haveWeights)
820
783
  cp .w = weights [i];
@@ -824,7 +787,9 @@ const NURBS = {
824
787
 
825
788
  if (closed)
826
789
  {
827
- for (let i = 1, size = order - 1; i < size; ++ i)
790
+ const length = order - 1;
791
+
792
+ for (let i = 1; i < length; ++ i)
828
793
  controlPoints .push (controlPoints [i]);
829
794
  }
830
795
 
@@ -833,7 +798,7 @@ const NURBS = {
833
798
  getUVControlPoints (result, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, weights, controlPointNode)
834
799
  {
835
800
  const
836
- controlPoints = result || [ ],
801
+ controlPoints = result ?? [ ],
837
802
  haveWeights = !! weights,
838
803
  Vector = haveWeights ? (external_X_ITE_X3D_Vector4_default()) : (external_X_ITE_X3D_Vector3_default());
839
804
 
@@ -845,16 +810,13 @@ const NURBS = {
845
810
 
846
811
  for (let u = 0; u < uDimension; ++ u)
847
812
  {
848
- let cp = controlPoints [u];
849
-
850
- if (! cp)
851
- cp = controlPoints [u] = [ ];
813
+ const cp = controlPoints [u] ??= [ ];
852
814
 
853
815
  for (let v = 0; v < vDimension; ++ v)
854
816
  {
855
817
  const index = v * uDimension + u;
856
818
 
857
- cp [v] = controlPointNode .get1Point (index, cp [v] || new Vector (0, 0, 0, 0));
819
+ controlPointNode .get1Point (index, cp [v] ??= new Vector (0, 0, 0, 0));
858
820
 
859
821
  if (haveWeights)
860
822
  cp [v] .w = weights [index];
@@ -864,7 +826,9 @@ const NURBS = {
864
826
 
865
827
  if (vClosed)
866
828
  {
867
- for (let i = 1, length = vOrder - 1; i < length; ++ i)
829
+ const length = vOrder - 1;
830
+
831
+ for (let i = 1; i < length; ++ i)
868
832
  cp .push (cp [i]);
869
833
  }
870
834
  }
@@ -873,7 +837,9 @@ const NURBS = {
873
837
 
874
838
  if (uClosed)
875
839
  {
876
- for (let i = 1, length = uOrder - 1; i < length; ++ i)
840
+ const length = uOrder - 1;
841
+
842
+ for (let i = 1; i < length; ++ i)
877
843
  controlPoints .push (controlPoints [i]);
878
844
  }
879
845
 
@@ -881,27 +847,26 @@ const NURBS = {
881
847
  },
882
848
  getTexControlPoints (result, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, controlPointNode)
883
849
  {
884
- const controlPoints = result || [ ];
850
+ const controlPoints = result ?? [ ];
885
851
 
886
852
  for (let u = 0; u < uDimension; ++ u)
887
853
  {
888
- let cp = controlPoints [u];
889
-
890
- if (! cp)
891
- cp = controlPoints [u] = [ ];
854
+ const cp = controlPoints [u] ??= [ ];
892
855
 
893
856
  for (let v = 0; v < vDimension; ++ v)
894
857
  {
895
858
  const index = v * uDimension + u;
896
859
 
897
- cp [v] = controlPointNode .get1Point (index, cp [v] || new (external_X_ITE_X3D_Vector4_default()) ());
860
+ controlPointNode .get1Point (index, cp [v] ??= new (external_X_ITE_X3D_Vector4_default()) ());
898
861
  }
899
862
 
900
863
  cp .length = vDimension;
901
864
 
902
865
  if (vClosed)
903
866
  {
904
- for (let i = 1, length = vOrder - 1; i < length; ++ i)
867
+ const length = vOrder - 1;
868
+
869
+ for (let i = 1; i < length; ++ i)
905
870
  cp .push (cp [i]);
906
871
  }
907
872
  }
@@ -910,7 +875,9 @@ const NURBS = {
910
875
 
911
876
  if (uClosed)
912
877
  {
913
- for (let i = 1, length = uOrder - 1; i < length; ++ i)
878
+ const length = uOrder - 1;
879
+
880
+ for (let i = 1; i < length; ++ i)
914
881
  controlPoints .push (controlPoints [i]);
915
882
  }
916
883
 
@@ -2035,47 +2002,32 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
2035
2002
 
2036
2003
  /* harmony default export */ const support = (external_X_ITE_X3D_Namespace_default().add ("support", support_default_));
2037
2004
  ;// CONCATENATED MODULE: ./src/lib/nurbs/extras/sample.js
2038
- var tmp1 = [ ];
2005
+ const tmp1 = [ ] ;
2039
2006
 
2040
- const sample_default_ = function (mesh, surface, opts)
2007
+ function sample (mesh, surface, opts)
2041
2008
  {
2042
- mesh = mesh || { };
2043
- opts = opts || { };
2044
-
2045
- var
2046
- points = mesh .points = mesh .points || [ ],
2047
- faces = mesh .faces = mesh .faces || [ ],
2048
- haveWeights = opts .haveWeights;
2049
-
2050
- var dimension = surface .dimension - haveWeights;
2051
-
2052
- if (Array .isArray (opts .resolution))
2053
- {
2054
- var resolution = opts .resolution;
2055
- }
2056
- else
2057
- {
2058
- var
2059
- res = opts .resolution === undefined ? 31 : opts .resolution,
2060
- resolution = new Array (surface .splineDimension) .fill (res);
2061
- }
2009
+ const
2010
+ points = mesh .points ??= [ ],
2011
+ faces = mesh .faces ??= [ ],
2012
+ haveWeights = opts .haveWeights,
2013
+ dimension = surface .dimension - haveWeights,
2014
+ resolution = opts .resolution;
2062
2015
 
2063
2016
  switch (surface .splineDimension)
2064
2017
  {
2065
2018
  case 1:
2066
2019
  {
2067
- var
2020
+ const
2068
2021
  nu = resolution [0],
2069
- uClosed = surface .boundary [0] === "closed",
2070
- nuBound = nu + ! uClosed,
2022
+ nuBound = nu + 1,
2071
2023
  nbVertices = nuBound * dimension,
2072
- domain = opts .domain || surface .domain,
2024
+ domain = surface .domain,
2073
2025
  uDomain = domain [0],
2074
2026
  uDistance = uDomain [1] - uDomain [0];
2075
2027
 
2076
- for (var i = 0; i < nuBound; ++ i)
2028
+ for (let i = 0; i < nuBound; ++ i)
2077
2029
  {
2078
- var
2030
+ const
2079
2031
  u = uDomain [0] + uDistance * i / nu,
2080
2032
  ptr = i * dimension;
2081
2033
 
@@ -2083,14 +2035,14 @@ const sample_default_ = function (mesh, surface, opts)
2083
2035
 
2084
2036
  if (haveWeights)
2085
2037
  {
2086
- var w = tmp1 [dimension];
2038
+ const w = tmp1 [dimension];
2087
2039
 
2088
- for (var d = 0; d < dimension; ++ d)
2040
+ for (let d = 0; d < dimension; ++ d)
2089
2041
  points [ptr + d] = tmp1 [d] / w;
2090
2042
  }
2091
2043
  else
2092
2044
  {
2093
- for (var d = 0; d < dimension; ++ d)
2045
+ for (let d = 0; d < dimension; ++ d)
2094
2046
  points [ptr + d] = tmp1 [d];
2095
2047
  }
2096
2048
  }
@@ -2100,29 +2052,29 @@ const sample_default_ = function (mesh, surface, opts)
2100
2052
  }
2101
2053
  case 2:
2102
2054
  {
2103
- var
2055
+ const
2104
2056
  nu = resolution [0],
2105
2057
  nv = resolution [1],
2106
- uClosed = surface .boundary [0] === "closed",
2107
- vClosed = surface .boundary [1] === "closed",
2108
- nuBound = nu + ! uClosed,
2109
- nvBound = nv + ! vClosed,
2058
+ nuBound = nu + 1,
2059
+ nvBound = nv + 1,
2110
2060
  nbVertices = nuBound * nvBound * dimension,
2111
- domain = opts .domain || surface .domain,
2061
+ domain = surface .domain,
2112
2062
  uDomain = domain [0],
2113
2063
  vDomain = domain [1],
2114
2064
  uDistance = uDomain [1] - uDomain [0],
2115
- vDistance = vDomain [1] - vDomain [0];
2065
+ vDistance = vDomain [1] - vDomain [0],
2066
+ uClosed = opts .closed [0],
2067
+ vClosed = opts .closed [1];
2116
2068
 
2117
2069
  // Generate points.
2118
2070
 
2119
- for (var i = 0; i < nuBound; ++ i)
2071
+ for (let i = 0; i < nuBound; ++ i)
2120
2072
  {
2121
- var u = uDomain [0] + uDistance * i / nu;
2073
+ const u = uDomain [0] + uDistance * i / nu;
2122
2074
 
2123
- for (var j = 0; j < nvBound; ++ j)
2075
+ for (let j = 0; j < nvBound; ++ j)
2124
2076
  {
2125
- var
2077
+ const
2126
2078
  v = vDomain [0] + vDistance * j / nv,
2127
2079
  ptr = (i + nuBound * j) * dimension;
2128
2080
 
@@ -2130,14 +2082,14 @@ const sample_default_ = function (mesh, surface, opts)
2130
2082
 
2131
2083
  if (haveWeights)
2132
2084
  {
2133
- var w = tmp1 [dimension];
2085
+ const w = tmp1 [dimension];
2134
2086
 
2135
- for (var d = 0; d < dimension; ++ d)
2087
+ for (let d = 0; d < dimension; ++ d)
2136
2088
  points [ptr + d] = tmp1 [d] / w;
2137
2089
  }
2138
2090
  else
2139
2091
  {
2140
- for (var d = 0; d < dimension; ++ d)
2092
+ for (let d = 0; d < dimension; ++ d)
2141
2093
  points [ptr + d] = tmp1 [d];
2142
2094
  }
2143
2095
  }
@@ -2147,25 +2099,20 @@ const sample_default_ = function (mesh, surface, opts)
2147
2099
 
2148
2100
  // Generate faces.
2149
2101
 
2150
- var
2151
- uClosed = opts .closed [0],
2152
- vClosed = opts .closed [1];
2102
+ let c = 0;
2153
2103
 
2154
- var c = 0;
2155
-
2156
- for (var i = 0; i < nu; ++ i)
2104
+ for (let i = 0; i < nu; ++ i)
2157
2105
  {
2158
- var
2159
- i0 = i,
2160
- i1 = i + 1;
2106
+ const i0 = i;
2107
+ let i1 = i + 1;
2161
2108
 
2162
2109
  if (uClosed)
2163
2110
  i1 = i1 % nu;
2164
2111
 
2165
- for (var j = 0; j < nv; ++ j)
2112
+ for (let j = 0; j < nv; ++ j)
2166
2113
  {
2167
- var j0 = j;
2168
- var j1 = j + 1;
2114
+ const j0 = j;
2115
+ let j1 = j + 1;
2169
2116
 
2170
2117
  if (vClosed)
2171
2118
  j1 = j1 % nv;
@@ -2186,87 +2133,19 @@ const sample_default_ = function (mesh, surface, opts)
2186
2133
 
2187
2134
  faces .length = c;
2188
2135
 
2189
- /*
2190
- // Trimming Contours
2191
-
2192
- if (opts .trimmingContours)
2193
- {
2194
- var holes = [ ];
2195
-
2196
- var trimmingContours = opts .trimmingContours;
2197
-
2198
- for (var t = 0, iLength = trimmingContours .length; t < iLength; ++ t)
2199
- {
2200
- var
2201
- trimmingContour = trimmingContours [t],
2202
- hole = [ ];
2203
-
2204
- for (var p = 0, pLength = trimmingContour .length; p < pLength; ++ p)
2205
- {
2206
- var point = trimmingContour [p];
2207
-
2208
- surface .evaluate (tmp1, point .x, point .y);
2209
-
2210
- for (var d = 0; d < dimension; ++ d)
2211
- points .push (tmp1 [d]);
2212
-
2213
- var vertex = new Vector3 (tmp1 [0], tmp1 [1], tmp1 [2]);
2214
-
2215
- vertex .index = c ++;
2216
-
2217
- hole .push (vertex);
2218
- }
2219
-
2220
- holes .push (hole);
2221
- }
2222
-
2223
- var
2224
- contours = [ ],
2225
- triangles = [ ],
2226
- trimmed = [ ];
2227
-
2228
- for (var v = 0, fLength = faces .length; v < fLength; v += 3)
2229
- {
2230
- contours .length = 0;
2231
- triangles .length = 0;
2232
-
2233
- var
2234
- index1 = faces [v] * 3,
2235
- index2 = faces [v + 1] * 3,
2236
- index3 = faces [v + 2] * 3;
2237
-
2238
- var
2239
- vertex1 = new Vector3 (points [index1], points [index1 + 1], points [index1 + 2]),
2240
- vertex2 = new Vector3 (points [index2], points [index2 + 1], points [index2 + 2]),
2241
- vertex3 = new Vector3 (points [index3], points [index3 + 1], points [index3 + 2]);
2242
-
2243
- vertex1 .index = v;
2244
- vertex2 .index = v + 1;
2245
- vertex3 .index = v + 2;
2246
-
2247
- contours .push ([ vertex1, vertex2, vertex3 ], ... holes);
2248
-
2249
- Triangle3 .triangulatePolygon (contours, triangles);
2250
-
2251
- for (var t = 0, tLength = triangles .length; t < tLength; ++ t)
2252
- trimmed .push (triangles [t] .index);
2253
- }
2254
-
2255
- mesh .faces = trimmed;
2256
- }
2257
- */
2258
-
2259
2136
  break;
2260
2137
  }
2261
2138
  default:
2262
- throw new Error("Can only sample contours and surfaces");
2139
+ throw new Error ("Can only sample contours and surfaces.");
2263
2140
  }
2264
2141
 
2265
2142
  return mesh;
2266
- };
2143
+ }
2144
+
2145
+ const sample_default_ = sample;
2267
2146
  ;
2268
2147
 
2269
- /* harmony default export */ const sample = (external_X_ITE_X3D_Namespace_default().add ("sample", sample_default_));
2148
+ /* harmony default export */ const extras_sample = (external_X_ITE_X3D_Namespace_default().add ("sample", sample_default_));
2270
2149
  ;// CONCATENATED MODULE: ./src/lib/nurbs/nurbs.js
2271
2150
 
2272
2151
 
@@ -2590,7 +2469,7 @@ function nurbs (points, degree, knots, weights, boundary, opts)
2590
2469
  return ctor;
2591
2470
  }
2592
2471
 
2593
- nurbs .sample = sample;
2472
+ nurbs .sample = extras_sample;
2594
2473
 
2595
2474
  const nurbs_default_ = nurbs;
2596
2475
  ;
@@ -2690,13 +2569,13 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2690
2569
  if (this .controlPointNode)
2691
2570
  this .controlPointNode .addInterest ("requestRebuild", this);
2692
2571
  },
2693
- getTessellation (numKnots)
2572
+ getTessellation (dimension)
2694
2573
  {
2695
- return NURBS_NURBS .getTessellation (this ._tessellation .getValue (), numKnots - this ._order .getValue ());
2574
+ return NURBS_NURBS .getTessellation (this ._tessellation .getValue (), dimension);
2696
2575
  },
2697
2576
  getClosed (order, knot, weight, controlPointNode)
2698
2577
  {
2699
- if (! this ._closed .getValue ())
2578
+ if (!this ._closed .getValue ())
2700
2579
  return false;
2701
2580
 
2702
2581
  return NURBS_NURBS .getClosed (order, knot, weight, controlPointNode);
@@ -2709,12 +2588,16 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2709
2588
  {
2710
2589
  return NURBS_NURBS .getControlPoints (result, closed, order, weights, controlPointNode);
2711
2590
  },
2591
+ getSurface ()
2592
+ {
2593
+ return this .surface;
2594
+ },
2712
2595
  tessellate ()
2713
2596
  {
2714
2597
  if (this ._order .getValue () < 2)
2715
2598
  return [ ];
2716
2599
 
2717
- if (! this .controlPointNode)
2600
+ if (!this .controlPointNode)
2718
2601
  return [ ];
2719
2602
 
2720
2603
  if (this .controlPointNode .getSize () < this ._order .getValue ())
@@ -2722,16 +2605,15 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2722
2605
 
2723
2606
  const
2724
2607
  vertexArray = this .getVertices (),
2608
+ numVertices = vertexArray .length,
2725
2609
  array = [ ];
2726
2610
 
2727
- if (vertexArray .length)
2611
+ if (numVertices)
2728
2612
  {
2729
- const length = vertexArray .length;
2730
-
2731
- for (let i = 0; i < length; i += 8)
2613
+ for (let i = 0; i < numVertices; i += 8)
2732
2614
  array .push (vertexArray [i], vertexArray [i + 1], vertexArray [i + 2]);
2733
2615
 
2734
- array .push (vertexArray [length - 4], vertexArray [length - 3], vertexArray [length - 2]);
2616
+ array .push (vertexArray [numVertices - 4], vertexArray [numVertices - 3], vertexArray [numVertices - 2]);
2735
2617
  }
2736
2618
 
2737
2619
  return array;
@@ -2741,7 +2623,7 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2741
2623
  if (this ._order .getValue () < 2)
2742
2624
  return;
2743
2625
 
2744
- if (! this .controlPointNode)
2626
+ if (!this .controlPointNode)
2745
2627
  return;
2746
2628
 
2747
2629
  if (this .controlPointNode .getSize () < this ._order .getValue ())
@@ -2764,7 +2646,7 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2764
2646
 
2765
2647
  const degree = this ._order .getValue () - 1;
2766
2648
 
2767
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
2649
+ this .surface = (this .surface ?? nurbs_nurbs) ({
2768
2650
  boundary: ["open"],
2769
2651
  degree: [degree],
2770
2652
  knots: [knots],
@@ -2772,20 +2654,20 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2772
2654
  debug: false,
2773
2655
  });
2774
2656
 
2775
- this .sampleOptions .resolution [0] = this .getTessellation (knots .length);
2657
+ this .sampleOptions .resolution [0] = this .getTessellation (controlPoints .length);
2658
+ this .sampleOptions .closed = closed;
2776
2659
  this .sampleOptions .haveWeights = !! weights;
2777
2660
 
2778
2661
  const
2779
- mesh = nurbs_nurbs .sample (this .mesh, surface, this .sampleOptions),
2662
+ mesh = nurbs_nurbs .sample (this .mesh, this .surface, this .sampleOptions),
2780
2663
  points = mesh .points,
2664
+ numPoints = points .length - 3,
2781
2665
  vertexArray = this .getVertices ();
2782
2666
 
2783
- for (let i2 = 3, length = points .length; i2 < length; i2 += 3)
2667
+ for (let i = 0; i < numPoints; i += 3)
2784
2668
  {
2785
- const i1 = i2 - 3;
2786
-
2787
- vertexArray .push (points [i1], points [i1 + 1], points [i1 + 2], 1);
2788
- vertexArray .push (points [i2], points [i2 + 1], points [i2 + 2], 1);
2669
+ vertexArray .push (points [i + 0], points [i + 1], points [i + 2], 1,
2670
+ points [i + 3], points [i + 4], points [i + 5], 1);
2789
2671
  }
2790
2672
  },
2791
2673
  dispose ()
@@ -2890,13 +2772,13 @@ function NurbsCurve2D (executionContext)
2890
2772
 
2891
2773
  Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsControlCurveNode .prototype),
2892
2774
  {
2893
- getTessellation (numKnots)
2775
+ getTessellation (dimension)
2894
2776
  {
2895
- return NURBS_NURBS .getTessellation (this ._tessellation .getValue (), numKnots - this ._order .getValue ());
2777
+ return NURBS_NURBS .getTessellation (this ._tessellation .getValue (), dimension);
2896
2778
  },
2897
2779
  getClosed (order, knot, weight, controlPoint)
2898
2780
  {
2899
- if (! this ._closed .getValue ())
2781
+ if (!this ._closed .getValue ())
2900
2782
  return false;
2901
2783
 
2902
2784
  return NURBS_NURBS .getClosed2D (order, knot, weight, controlPoint);
@@ -2913,12 +2795,8 @@ Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsC
2913
2795
  {
2914
2796
  return NURBS_NURBS .getControlPoints2D (result, closed, order, weights, controlPoint);
2915
2797
  },
2916
- tessellate (type)
2798
+ tessellate (type, array = this .array)
2917
2799
  {
2918
- const array = this .array;
2919
-
2920
- array .length = 0;
2921
-
2922
2800
  if (this ._order .getValue () < 2)
2923
2801
  return array;
2924
2802
 
@@ -2942,7 +2820,7 @@ Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsC
2942
2820
 
2943
2821
  const degree = this ._order .getValue () - 1;
2944
2822
 
2945
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
2823
+ this .surface = (this .surface ?? nurbs_nurbs) ({
2946
2824
  boundary: ["open"],
2947
2825
  degree: [degree],
2948
2826
  knots: [knots],
@@ -2950,39 +2828,39 @@ Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsC
2950
2828
  debug: false,
2951
2829
  });
2952
2830
 
2953
- this .sampleOptions .resolution [0] = this .getTessellation (knots .length);
2831
+ this .sampleOptions .resolution [0] = this .getTessellation (controlPoints .length);
2832
+ this .sampleOptions .closed = closed;
2954
2833
  this .sampleOptions .haveWeights = !! weights;
2955
2834
 
2956
2835
  const
2957
- mesh = nurbs_nurbs .sample (this .mesh, surface, this .sampleOptions),
2958
- points = mesh .points;
2836
+ mesh = nurbs_nurbs .sample (this .mesh, this .surface, this .sampleOptions),
2837
+ points = mesh .points,
2838
+ numPoints = points .length;
2959
2839
 
2960
2840
  switch (type)
2961
2841
  {
2962
2842
  case 0:
2963
2843
  {
2964
- for (let i = 0, length = points .length; i < length; i += 2)
2965
- {
2844
+ array .length = 0;
2845
+
2846
+ for (let i = 0; i < numPoints; i += 2)
2966
2847
  array .push (points [i], points [i + 1]);
2967
- }
2968
2848
 
2969
2849
  break;
2970
2850
  }
2971
2851
  case 1:
2972
2852
  {
2973
- for (let i = 0, length = points .length; i < length; i += 2)
2974
- {
2853
+ array .length = 0;
2854
+
2855
+ for (let i = 0; i < numPoints; i += 2)
2975
2856
  array .push (points [i], 0, points [i + 1]);
2976
- }
2977
2857
 
2978
2858
  break;
2979
2859
  }
2980
- case 2:
2860
+ case 2: // Contour2D
2981
2861
  {
2982
- for (let i = 0, length = points .length; i < length; i += 2)
2983
- {
2862
+ for (let i = 0; i < numPoints; i += 2)
2984
2863
  array .push (new (external_X_ITE_X3D_Vector3_default()) (points [i], points [i + 1], 0));
2985
- }
2986
2864
 
2987
2865
  break;
2988
2866
  }
@@ -3017,12 +2895,12 @@ const NurbsCurve2D_default_ = NurbsCurve2D;
3017
2895
  ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .X3DChildNode"
3018
2896
  const external_X_ITE_X3D_X3DChildNode_namespaceObject = __X_ITE_X3D__ .X3DChildNode;
3019
2897
  var external_X_ITE_X3D_X3DChildNode_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_X3DChildNode_namespaceObject);
3020
- ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .OrientationInterpolator"
3021
- const external_X_ITE_X3D_OrientationInterpolator_namespaceObject = __X_ITE_X3D__ .OrientationInterpolator;
3022
- var external_X_ITE_X3D_OrientationInterpolator_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_OrientationInterpolator_namespaceObject);
3023
2898
  ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Rotation4"
3024
2899
  const external_X_ITE_X3D_Rotation4_namespaceObject = __X_ITE_X3D__ .Rotation4;
3025
2900
  var external_X_ITE_X3D_Rotation4_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Rotation4_namespaceObject);
2901
+ ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Algorithm"
2902
+ const external_X_ITE_X3D_Algorithm_namespaceObject = __X_ITE_X3D__ .Algorithm;
2903
+ var external_X_ITE_X3D_Algorithm_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Algorithm_namespaceObject);
3026
2904
  ;// CONCATENATED MODULE: ./src/x_ite/Components/NURBS/NurbsOrientationInterpolator.js
3027
2905
  /*******************************************************************************
3028
2906
  *
@@ -3083,7 +2961,6 @@ var external_X_ITE_X3D_Rotation4_default = /*#__PURE__*/__webpack_require__.n(ex
3083
2961
 
3084
2962
 
3085
2963
 
3086
-
3087
2964
  function NurbsOrientationInterpolator (executionContext)
3088
2965
  {
3089
2966
  external_X_ITE_X3D_X3DChildNode_default().call (this, executionContext);
@@ -3092,12 +2969,7 @@ function NurbsOrientationInterpolator (executionContext)
3092
2969
 
3093
2970
  this .addChildObjects ((external_X_ITE_X3D_X3DConstants_default()).inputOutput, "rebuild", new (external_X_ITE_X3D_Fields_default()).SFTime ());
3094
2971
 
3095
- this .interpolator = new (external_X_ITE_X3D_OrientationInterpolator_default()) (executionContext);
3096
- this .knots = [ ];
3097
- this .weights = [ ];
3098
- this .controlPoints = [ ];
3099
- this .mesh = { };
3100
- this .sampleOptions = { resolution: [ 128 ] };
2972
+ this .geometry = new NURBS_NurbsCurve (executionContext);
3101
2973
  }
3102
2974
 
3103
2975
  Object .assign (Object .setPrototypeOf (NurbsOrientationInterpolator .prototype, (external_X_ITE_X3D_X3DChildNode_default()).prototype),
@@ -3106,114 +2978,49 @@ Object .assign (Object .setPrototypeOf (NurbsOrientationInterpolator .prototype,
3106
2978
  {
3107
2979
  external_X_ITE_X3D_X3DChildNode_default().prototype .initialize .call (this);
3108
2980
 
3109
- this ._order .addInterest ("requestRebuild", this);
3110
- this ._knot .addInterest ("requestRebuild", this);
3111
- this ._weight .addInterest ("requestRebuild", this);
3112
- this ._controlPoint .addInterest ("set_controlPoint__", this);
2981
+ this ._set_fraction .addInterest ("set_fraction__", this);
3113
2982
 
3114
- this ._rebuild .addInterest ("build", this);
2983
+ this ._order .addFieldInterest (this .geometry ._order);
2984
+ this ._knot .addFieldInterest (this .geometry ._knot);
2985
+ this ._weight .addFieldInterest (this .geometry ._weight);
2986
+ this ._controlPoint .addFieldInterest (this .geometry ._controlPoint);
3115
2987
 
3116
- this ._set_fraction .addFieldInterest (this .interpolator ._set_fraction);
3117
- this .interpolator ._value_changed .addFieldInterest (this ._value_changed);
2988
+ this .geometry ._tessellation = 1;
2989
+ this .geometry ._order = this ._order;
2990
+ this .geometry ._knot = this ._knot;
2991
+ this .geometry ._weight = this ._weight;
2992
+ this .geometry ._controlPoint = this ._controlPoint;
3118
2993
 
3119
- this .interpolator .setup ();
2994
+ this .geometry ._rebuild .addInterest ("set_geometry__", this);
2995
+ this .geometry .setup ();
3120
2996
 
3121
- this .set_controlPoint__ ();
2997
+ this .set_geometry__ ();
3122
2998
  },
3123
- set_controlPoint__ ()
2999
+ set_geometry__ ()
3124
3000
  {
3125
- if (this .controlPointNode)
3126
- this .controlPointNode .removeInterest ("requestRebuild", this);
3127
-
3128
- this .controlPointNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DCoordinateNode, this ._controlPoint);
3129
-
3130
- if (this .controlPointNode)
3131
- this .controlPointNode .addInterest ("requestRebuild", this);
3001
+ const surface = this .geometry .getSurface ();
3132
3002
 
3133
- this .requestRebuild ();
3134
- },
3135
- getClosed (order, knot, weight, controlPointNode)
3136
- {
3137
- return false && 0;
3138
- },
3139
- getKnots (result, closed, order, dimension, knot)
3140
- {
3141
- return NURBS_NURBS .getKnots (result, closed, order, dimension, knot);
3142
- },
3143
- getWeights (result, dimension, weight)
3144
- {
3145
- return NURBS_NURBS .getWeights (result, dimension, weight);
3146
- },
3147
- getControlPoints (result, closed, order, weights, controlPointNode)
3148
- {
3149
- return NURBS_NURBS .getControlPoints (result, closed, order, weights, controlPointNode);
3150
- },
3151
- requestRebuild ()
3152
- {
3153
- this ._rebuild .addEvent ();
3003
+ this .derivative = surface .evaluator (1);
3154
3004
  },
3155
- build ()
3005
+ set_fraction__: (() =>
3156
3006
  {
3157
- if (this ._order .getValue () < 2)
3158
- return;
3159
-
3160
- if (! this .controlPointNode)
3161
- return;
3162
-
3163
- if (this .controlPointNode .getSize () < this ._order .getValue ())
3164
- return;
3165
-
3166
- // Order and dimension are now positive numbers.
3167
-
3168
- const
3169
- closed = this .getClosed (this ._order .getValue (), this ._knot, this ._weight, this .controlPointNode),
3170
- weights = this .getWeights (this .weights, this .controlPointNode .getSize (), this ._weight),
3171
- controlPoints = this .getControlPoints (this .controlPoints, closed, this ._order .getValue (), weights, this .controlPointNode);
3172
-
3173
- // Knots
3174
-
3175
- const
3176
- knots = this .getKnots (this .knots, closed, this ._order .getValue (), this .controlPointNode .getSize (), this ._knot),
3177
- scale = knots .at (-1) - knots [0];
3178
-
3179
- // Initialize NURBS tessellator
3180
-
3181
- const degree = this ._order .getValue () - 1;
3182
-
3183
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
3184
- boundary: ["open"],
3185
- degree: [degree],
3186
- knots: [knots],
3187
- points: controlPoints,
3188
- debug: false,
3189
- });
3190
-
3191
- this .sampleOptions .haveWeights = !! weights;
3192
-
3193
3007
  const
3194
- mesh = nurbs_nurbs .sample (this .mesh, surface, this .sampleOptions),
3195
- points = mesh .points,
3196
- interpolator = this .interpolator;
3197
-
3198
- interpolator ._key .length = 0;
3199
- interpolator ._keyValue .length = 0;
3008
+ direction = new (external_X_ITE_X3D_Vector3_default()) (),
3009
+ rotation = new (external_X_ITE_X3D_Rotation4_default()) ();
3200
3010
 
3201
- for (let i = 0, length = points .length - 3; i < length; i += 3)
3011
+ return function ()
3202
3012
  {
3203
- const direction = new (external_X_ITE_X3D_Vector3_default()) (points [i + 3] - points [i + 0],
3204
- points [i + 4] - points [i + 1],
3205
- points [i + 5] - points [i + 2]);
3013
+ const
3014
+ fraction = external_X_ITE_X3D_Algorithm_default().clamp (this ._set_fraction .getValue (), 0, 1),
3015
+ surface = this .geometry .getSurface (),
3016
+ uDomain = surface .domain [0],
3017
+ u = external_X_ITE_X3D_Algorithm_default().project (fraction, 0, 1, ... uDomain);
3206
3018
 
3207
- interpolator ._key .push (knots [0] + i / (length - 3 + (3 * closed)) * scale);
3208
- interpolator ._keyValue. push (new (external_X_ITE_X3D_Rotation4_default()) ((external_X_ITE_X3D_Vector3_default()).zAxis, direction));
3209
- }
3019
+ this .derivative (direction, u);
3210
3020
 
3211
- if (closed)
3212
- {
3213
- interpolator ._key .push (knots [0] + scale);
3214
- interpolator ._keyValue. push (interpolator ._keyValue [0]);
3215
- }
3216
- },
3021
+ this ._value_changed = rotation .setFromToVec ((external_X_ITE_X3D_Vector3_default()).zAxis, direction);
3022
+ };
3023
+ })(),
3217
3024
  });
3218
3025
 
3219
3026
  Object .defineProperties (NurbsOrientationInterpolator,
@@ -3238,9 +3045,6 @@ const NurbsOrientationInterpolator_default_ = NurbsOrientationInterpolator;
3238
3045
  ;
3239
3046
 
3240
3047
  /* harmony default export */ const NURBS_NurbsOrientationInterpolator = (external_X_ITE_X3D_Namespace_default().add ("NurbsOrientationInterpolator", NurbsOrientationInterpolator_default_));
3241
- ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Algorithm"
3242
- const external_X_ITE_X3D_Algorithm_namespaceObject = __X_ITE_X3D__ .Algorithm;
3243
- var external_X_ITE_X3D_Algorithm_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Algorithm_namespaceObject);
3244
3048
  ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Triangle3"
3245
3049
  const external_X_ITE_X3D_Triangle3_namespaceObject = __X_ITE_X3D__ .Triangle3;
3246
3050
  var external_X_ITE_X3D_Triangle3_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Triangle3_namespaceObject);
@@ -3347,13 +3151,11 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3347
3151
  },
3348
3152
  set_controlPoint__ ()
3349
3153
  {
3350
- if (this .controlPointNode)
3351
- this .controlPointNode .removeInterest ("requestRebuild", this);
3154
+ this .controlPointNode ?.removeInterest ("requestRebuild", this);
3352
3155
 
3353
3156
  this .controlPointNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DCoordinateNode, this ._controlPoint);
3354
3157
 
3355
- if (this .controlPointNode)
3356
- this .controlPointNode .addInterest ("requestRebuild", this);
3158
+ this .controlPointNode ?.addInterest ("requestRebuild", this);
3357
3159
  },
3358
3160
  setTessellationScale (value)
3359
3161
  {
@@ -3361,13 +3163,13 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3361
3163
 
3362
3164
  this .requestRebuild ();
3363
3165
  },
3364
- getUTessellation (numKnots)
3166
+ getUTessellation ()
3365
3167
  {
3366
- return Math .floor (NURBS_NURBS .getTessellation (this ._uTessellation .getValue (), numKnots - this ._uOrder .getValue ()) * this .tessellationScale);
3168
+ return Math .floor (NURBS_NURBS .getTessellation (this ._uTessellation .getValue (), this ._uDimension .getValue ()) * this .tessellationScale);
3367
3169
  },
3368
- getVTessellation (numKnots)
3170
+ getVTessellation (numWeights)
3369
3171
  {
3370
- return Math .floor (NURBS_NURBS .getTessellation (this ._vTessellation .getValue (), numKnots - this ._vOrder .getValue ()) * this .tessellationScale);
3172
+ return Math .floor (NURBS_NURBS .getTessellation (this ._vTessellation .getValue (), this ._vDimension .getValue ()) * this .tessellationScale);
3371
3173
  },
3372
3174
  getUClosed (uOrder, uDimension, vDimension, uKnot, weight, controlPointNode)
3373
3175
  {
@@ -3395,10 +3197,12 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3395
3197
  {
3396
3198
  return NURBS_NURBS .getUVControlPoints (result, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, weights, controlPointNode);
3397
3199
  },
3398
- getTrimmingContours ()
3200
+ getSurface ()
3399
3201
  {
3400
- return undefined;
3202
+ return this .surface;
3401
3203
  },
3204
+ trimSurface ()
3205
+ { },
3402
3206
  build ()
3403
3207
  {
3404
3208
  if (this ._uOrder .getValue () < 2)
@@ -3416,7 +3220,7 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3416
3220
  if (!this .controlPointNode)
3417
3221
  return;
3418
3222
 
3419
- if (this .controlPointNode .getSize () !== this ._uDimension .getValue () * this ._vDimension .getValue ())
3223
+ if (this .controlPointNode .getSize () < this ._uDimension .getValue () * this ._vDimension .getValue ())
3420
3224
  return;
3421
3225
 
3422
3226
  // Order and dimension are now positive numbers.
@@ -3443,7 +3247,7 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3443
3247
  uDegree = this ._uOrder .getValue () - 1,
3444
3248
  vDegree = this ._vOrder .getValue () - 1;
3445
3249
 
3446
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
3250
+ this .surface = (this .surface ?? nurbs_nurbs) ({
3447
3251
  boundary: ["open", "open"],
3448
3252
  degree: [uDegree, vDegree],
3449
3253
  knots: [uKnots, vKnots],
@@ -3453,126 +3257,135 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3453
3257
 
3454
3258
  const sampleOptions = this .sampleOptions;
3455
3259
 
3456
- sampleOptions .resolution [0] = this .getUTessellation (uKnots .length);
3457
- sampleOptions .resolution [1] = this .getVTessellation (vKnots .length);
3458
- sampleOptions .closed [0] = uClosed;
3459
- sampleOptions .closed [1] = vClosed;
3460
- sampleOptions .domain = undefined;
3461
- sampleOptions .haveWeights = !! weights;
3462
- sampleOptions .trimmingContours = this .getTrimmingContours ();
3260
+ sampleOptions .resolution [0] = this .getUTessellation ();
3261
+ sampleOptions .resolution [1] = this .getVTessellation ();
3262
+ sampleOptions .closed [0] = uClosed;
3263
+ sampleOptions .closed [1] = vClosed;
3264
+ sampleOptions .haveWeights = !! weights;
3463
3265
 
3464
3266
  const
3465
- mesh = nurbs_nurbs .sample (this .mesh, surface, sampleOptions),
3267
+ mesh = nurbs_nurbs .sample (this .mesh, this .surface, sampleOptions),
3466
3268
  faces = mesh .faces,
3467
3269
  points = mesh .points,
3468
3270
  vertexArray = this .getVertices ();
3469
3271
 
3470
- for (let i = 0, length = faces .length; i < length; ++ i)
3272
+ for (const face of faces)
3471
3273
  {
3472
- const index = faces [i] * 3;
3274
+ const index = face * 3;
3473
3275
 
3474
3276
  vertexArray .push (points [index], points [index + 1], points [index + 2], 1);
3475
3277
  }
3476
3278
 
3477
- this .buildNurbsTexCoords (uClosed, vClosed, this ._uOrder .getValue (), this ._vOrder .getValue (), uKnots, vKnots, this ._uDimension .getValue (), this ._vDimension .getValue (), surface .domain);
3279
+ this .buildNurbsTexCoords (uClosed, vClosed, this ._uOrder .getValue (), this ._vOrder .getValue (), uKnots, vKnots, this ._uDimension .getValue (), this ._vDimension .getValue ());
3280
+
3478
3281
  this .generateNormals (faces, points);
3282
+ this .trimSurface (uKnots, vKnots);
3479
3283
  this .setSolid (this ._solid .getValue ());
3480
3284
  this .setCCW (true);
3481
3285
  },
3482
- buildNurbsTexCoords: (() =>
3286
+ buildNurbsTexCoords (uClosed, vClosed, uOrder, vOrder, uKnots, vKnots, uDimension, vDimension)
3483
3287
  {
3484
- const
3485
- defaultTexUKnots = [ ],
3486
- defaultTexVKnots = [ ],
3487
- defaultTexControlPoints = [[[0, 0, 0, 1], [0, 1, 0, 1]], [[1, 0, 0, 1], [1, 1, 0, 1]]];
3288
+ const texCoordArray = this .getTexCoords ();
3488
3289
 
3489
- function getDefaultTexKnots (result, knots)
3290
+ this .getMultiTexCoords () .push (texCoordArray);
3291
+
3292
+ if (this .texCoordNode && this .texCoordNode .getSize () <= uDimension * vDimension)
3490
3293
  {
3491
- result [0] = result [1] = knots [0];
3492
- result [2] = result [3] = knots .at (-1);
3493
- return result;
3294
+ const
3295
+ texUDegree = uOrder - 1,
3296
+ texVDegree = vOrder - 1,
3297
+ texUKnots = uKnots,
3298
+ texVKnots = vKnots,
3299
+ texControlPoints = this .getTexControlPoints (this .texControlPoints, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, this .texCoordNode);
3300
+
3301
+ this .createNurbsTexCoords (texUDegree, texVDegree, texUKnots, texVKnots, texControlPoints, texCoordArray);
3302
+ }
3303
+ else if (this .nurbsTexCoordNode ?.isValid ())
3304
+ {
3305
+ const
3306
+ node = this .nurbsTexCoordNode,
3307
+ texUDegree = node ._uOrder .getValue () - 1,
3308
+ texVDegree = node ._vOrder .getValue () - 1,
3309
+ texUKnots = this .getKnots (this .texUKnots, false, node ._uOrder .getValue (), node ._uDimension .getValue (), node ._uKnot),
3310
+ texVKnots = this .getKnots (this .texVKnots, false, node ._vOrder .getValue (), node ._vDimension .getValue (), node ._vKnot),
3311
+ texWeights = this .getUVWeights (this .texWeights, node ._uDimension .getValue (), node ._vDimension .getValue (), node ._weight),
3312
+ texControlPoints = node .getControlPoints (texWeights);
3313
+
3314
+ this .createNurbsTexCoords (texUDegree, texVDegree, texUKnots, texVKnots, texControlPoints, texCoordArray);
3494
3315
  }
3316
+ else
3317
+ {
3318
+ this .createDefaultNurbsTexCoords (texCoordArray);
3319
+ }
3320
+ },
3321
+ createDefaultNurbsTexCoords: (() =>
3322
+ {
3323
+ const
3324
+ defaultTexKnots = [0, 0, 5, 5],
3325
+ defaultTexControlPoints = [[[0, 0, 0, 1], [0, 1, 0, 1]], [[1, 0, 0, 1], [1, 1, 0, 1]]];
3495
3326
 
3496
- return function (uClosed, vClosed, uOrder, vOrder, uKnots, vKnots, uDimension, vDimension, domain)
3327
+ return function (texCoordArray)
3497
3328
  {
3498
- const sampleOptions = this .sampleOptions;
3329
+ // Create texture coordinates in the unit square.
3499
3330
 
3500
- if (this .texCoordNode && this .texCoordNode .getSize () === uDimension * vDimension)
3501
- {
3502
- var
3503
- texUDegree = uOrder - 1,
3504
- texVDegree = vOrder - 1,
3505
- texUKnots = uKnots,
3506
- texVKnots = vKnots,
3507
- texControlPoints = this .getTexControlPoints (this .texControlPoints, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, this .texCoordNode);
3508
- }
3509
- else if (this .nurbsTexCoordNode && this .nurbsTexCoordNode .isValid ())
3510
- {
3511
- var
3512
- node = this .nurbsTexCoordNode,
3513
- texUDegree = node ._uOrder .getValue () - 1,
3514
- texVDegree = node ._vOrder .getValue () - 1,
3515
- texUKnots = this .getKnots (this .texUKnots, false, node ._uOrder .getValue (), node ._uDimension .getValue (), node ._uKnot),
3516
- texVKnots = this .getKnots (this .texVKnots, false, node ._vOrder .getValue (), node ._vDimension .getValue (), node ._vKnot),
3517
- texWeights = this .getUVWeights (this .texWeights, node ._uDimension .getValue (), node ._vDimension .getValue (), node ._weight);
3518
- texControlPoints = node .getControlPoints (texWeights);
3519
- }
3520
- else
3521
- {
3522
- var
3523
- texUDegree = 1,
3524
- texVDegree = 1,
3525
- texUKnots = getDefaultTexKnots (defaultTexUKnots, uKnots),
3526
- texVKnots = getDefaultTexKnots (defaultTexVKnots, vKnots),
3527
- texControlPoints = defaultTexControlPoints;
3528
-
3529
- sampleOptions .domain = domain;
3530
- }
3331
+ const
3332
+ texUDegree = 1,
3333
+ texVDegree = 1,
3334
+ texUKnots = defaultTexKnots,
3335
+ texVKnots = defaultTexKnots,
3336
+ texControlPoints = defaultTexControlPoints;
3531
3337
 
3532
- const texSurface = this .texSurface = (this .texSurface || nurbs_nurbs) ({
3533
- boundary: ["open", "open"],
3534
- degree: [texUDegree, texVDegree],
3535
- knots: [texUKnots, texVKnots],
3536
- points: texControlPoints,
3537
- });
3338
+ return this .createNurbsTexCoords (texUDegree, texVDegree, texUKnots, texVKnots, texControlPoints, texCoordArray);
3339
+ };
3340
+ })(),
3341
+ createNurbsTexCoords (texUDegree, texVDegree, texUKnots, texVKnots, texControlPoints, texCoordArray)
3342
+ {
3343
+ this .texSurface = (this .texSurface ?? nurbs_nurbs) ({
3344
+ boundary: ["open", "open"],
3345
+ degree: [texUDegree, texVDegree],
3346
+ knots: [texUKnots, texVKnots],
3347
+ points: texControlPoints,
3348
+ });
3538
3349
 
3539
- sampleOptions .closed [0] = false;
3540
- sampleOptions .closed [1] = false;
3541
- sampleOptions .haveWeights = false;
3350
+ const sampleOptions = this .sampleOptions;
3542
3351
 
3543
- const
3544
- texMesh = nurbs_nurbs .sample (this .texMesh, texSurface, sampleOptions),
3545
- faces = texMesh .faces,
3546
- points = texMesh .points,
3547
- texCoordArray = this .getTexCoords ();
3352
+ sampleOptions .closed [0] = false;
3353
+ sampleOptions .closed [1] = false;
3354
+ sampleOptions .haveWeights = false;
3548
3355
 
3549
- for (let i = 0, length = faces .length; i < length; ++ i)
3550
- {
3551
- const index = faces [i] * 4;
3356
+ const
3357
+ texMesh = nurbs_nurbs .sample (this .texMesh, this .texSurface, sampleOptions),
3358
+ faces = texMesh .faces,
3359
+ points = texMesh .points;
3552
3360
 
3553
- texCoordArray .push (points [index], points [index + 1], points [index + 2], points [index + 3]);
3554
- }
3361
+ for (const face of faces)
3362
+ {
3363
+ const i = face * 4;
3555
3364
 
3556
- this .getMultiTexCoords () .push (this .getTexCoords ());
3557
- };
3558
- })(),
3365
+ texCoordArray .push (points [i], points [i + 1], points [i + 2], points [i + 3]);
3366
+ }
3367
+
3368
+ return texCoordArray;
3369
+ },
3559
3370
  generateNormals (faces, points)
3560
3371
  {
3561
3372
  const
3562
3373
  normals = this .createNormals (faces, points),
3563
3374
  normalArray = this .getNormals ();
3564
3375
 
3565
- for (const normal of normals)
3566
- normalArray .push (normal .x, normal .y, normal .z);
3376
+ for (const { x, y, z } of normals)
3377
+ normalArray .push (x, y, z);
3567
3378
  },
3568
3379
  createNormals (faces, points)
3569
3380
  {
3381
+ // TODO: handle uClosed, vClosed.
3382
+
3570
3383
  const
3571
3384
  normalIndex = new Map (),
3572
3385
  normals = this .createFaceNormals (faces, points),
3573
- length = faces .length;
3386
+ numFaces = faces .length;
3574
3387
 
3575
- for (let i = 0; i < length; ++ i)
3388
+ for (let i = 0; i < numFaces; ++ i)
3576
3389
  {
3577
3390
  const index = faces [i];
3578
3391
 
@@ -3596,10 +3409,10 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3596
3409
  return function (faces, points)
3597
3410
  {
3598
3411
  const
3599
- normals = this .faceNormals || [ ],
3600
- length = faces .length;
3412
+ normals = this .faceNormals ?? [ ],
3413
+ numFaces = faces .length;
3601
3414
 
3602
- for (let i = 0; i < length; i += 3)
3415
+ for (let i = 0; i < numFaces; i += 3)
3603
3416
  {
3604
3417
  const
3605
3418
  index1 = faces [i] * 3,
@@ -3610,14 +3423,14 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3610
3423
  v2 .set (points [index2], points [index2 + 1], points [index2 + 2]);
3611
3424
  v3 .set (points [index3], points [index3 + 1], points [index3 + 2]);
3612
3425
 
3613
- const normal = external_X_ITE_X3D_Triangle3_default().normal (v1, v2 ,v3, normals [i] || new (external_X_ITE_X3D_Vector3_default()) ());
3426
+ const normal = external_X_ITE_X3D_Triangle3_default().normal (v1, v2 ,v3, normals [i] ?? new (external_X_ITE_X3D_Vector3_default()) ());
3614
3427
 
3615
3428
  normals [i] = normal;
3616
3429
  normals [i + 1] = normal;
3617
3430
  normals [i + 2] = normal;
3618
3431
  }
3619
3432
 
3620
- normals .length = length;
3433
+ normals .length = numFaces;
3621
3434
 
3622
3435
  return normals;
3623
3436
  };
@@ -3724,9 +3537,6 @@ const NurbsPatchSurface_default_ = NurbsPatchSurface;
3724
3537
  ;
3725
3538
 
3726
3539
  /* harmony default export */ const NURBS_NurbsPatchSurface = (external_X_ITE_X3D_Namespace_default().add ("NurbsPatchSurface", NurbsPatchSurface_default_));
3727
- ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .PositionInterpolator"
3728
- const external_X_ITE_X3D_PositionInterpolator_namespaceObject = __X_ITE_X3D__ .PositionInterpolator;
3729
- var external_X_ITE_X3D_PositionInterpolator_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_PositionInterpolator_namespaceObject);
3730
3540
  ;// CONCATENATED MODULE: ./src/x_ite/Components/NURBS/NurbsPositionInterpolator.js
3731
3541
  /*******************************************************************************
3732
3542
  *
@@ -3792,14 +3602,7 @@ function NurbsPositionInterpolator (executionContext)
3792
3602
 
3793
3603
  this .addType ((external_X_ITE_X3D_X3DConstants_default()).NurbsPositionInterpolator);
3794
3604
 
3795
- this .addChildObjects ((external_X_ITE_X3D_X3DConstants_default()).inputOutput, "rebuild", new (external_X_ITE_X3D_Fields_default()).SFTime ());
3796
-
3797
- this .interpolator = new (external_X_ITE_X3D_PositionInterpolator_default()) (executionContext);
3798
- this .knots = [ ];
3799
- this .weights = [ ];
3800
- this .controlPoints = [ ];
3801
- this .mesh = { };
3802
- this .sampleOptions = { resolution: [ 128 ] };
3605
+ this .geometry = new NURBS_NurbsCurve (executionContext);
3803
3606
  }
3804
3607
 
3805
3608
  Object .assign (Object .setPrototypeOf (NurbsPositionInterpolator .prototype, (external_X_ITE_X3D_X3DChildNode_default()).prototype),
@@ -3808,104 +3611,38 @@ Object .assign (Object .setPrototypeOf (NurbsPositionInterpolator .prototype, (e
3808
3611
  {
3809
3612
  external_X_ITE_X3D_X3DChildNode_default().prototype .initialize .call (this);
3810
3613
 
3811
- this ._order .addInterest ("requestRebuild", this);
3812
- this ._knot .addInterest ("requestRebuild", this);
3813
- this ._weight .addInterest ("requestRebuild", this);
3814
- this ._controlPoint .addInterest ("set_controlPoint__", this);
3815
-
3816
- this ._rebuild .addInterest ("build", this);
3817
-
3818
- this ._set_fraction .addFieldInterest (this .interpolator ._set_fraction);
3819
- this .interpolator ._value_changed .addFieldInterest (this ._value_changed);
3820
-
3821
- this .interpolator .setup ();
3822
-
3823
- this .set_controlPoint__ ();
3824
- },
3825
- set_controlPoint__ ()
3826
- {
3827
- if (this .controlPointNode)
3828
- this .controlPointNode .removeInterest ("requestRebuild", this);
3614
+ this ._set_fraction .addInterest ("set_fraction__", this);
3829
3615
 
3830
- this .controlPointNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DCoordinateNode, this ._controlPoint);
3616
+ this ._order .addFieldInterest (this .geometry ._order);
3617
+ this ._knot .addFieldInterest (this .geometry ._knot);
3618
+ this ._weight .addFieldInterest (this .geometry ._weight);
3619
+ this ._controlPoint .addFieldInterest (this .geometry ._controlPoint);
3831
3620
 
3832
- if (this .controlPointNode)
3833
- this .controlPointNode .addInterest ("requestRebuild", this);
3621
+ this .geometry ._tessellation = 1;
3622
+ this .geometry ._order = this ._order;
3623
+ this .geometry ._knot = this ._knot;
3624
+ this .geometry ._weight = this ._weight;
3625
+ this .geometry ._controlPoint = this ._controlPoint;
3834
3626
 
3835
- this .requestRebuild ();
3836
- },
3837
- getClosed (order, knot, weight, controlPointNode)
3838
- {
3839
- return false && 0;
3840
- },
3841
- getKnots (result, closed, order, dimension, knot)
3842
- {
3843
- return NURBS_NURBS .getKnots (result, closed, order, dimension, knot);
3844
- },
3845
- getWeights (result, dimension, weight)
3846
- {
3847
- return NURBS_NURBS .getWeights (result, dimension, weight);
3848
- },
3849
- getControlPoints (result, closed, order, weights, controlPointNode)
3850
- {
3851
- return NURBS_NURBS .getControlPoints (result, closed, order, weights, controlPointNode);
3852
- },
3853
- requestRebuild ()
3854
- {
3855
- this ._rebuild .addEvent ();
3627
+ this .geometry .setup ();
3856
3628
  },
3857
- build ()
3629
+ set_fraction__: (() =>
3858
3630
  {
3859
- if (this ._order .getValue () < 2)
3860
- return;
3861
-
3862
- if (! this .controlPointNode)
3863
- return;
3864
-
3865
- if (this .controlPointNode .getSize () < this ._order .getValue ())
3866
- return;
3867
-
3868
- // Order and dimension are now positive numbers.
3869
-
3870
- const
3871
- closed = this .getClosed (this ._order .getValue (), this ._knot, this ._weight, this .controlPointNode),
3872
- weights = this .getWeights (this .weights, this .controlPointNode .getSize (), this ._weight),
3873
- controlPoints = this .getControlPoints (this .controlPoints, closed, this ._order .getValue (), weights, this .controlPointNode);
3874
-
3875
- // Knots
3876
-
3877
- const
3878
- knots = this .getKnots (this .knots, closed, this ._order .getValue (), this .controlPointNode .getSize (), this ._knot),
3879
- scale = knots .at (-1) - knots [0];
3880
-
3881
- // Initialize NURBS tessellator
3631
+ const value = new (external_X_ITE_X3D_Vector3_default()) ();
3882
3632
 
3883
- const degree = this ._order .getValue () - 1;
3884
-
3885
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
3886
- boundary: ["open"],
3887
- degree: [degree],
3888
- knots: [knots],
3889
- points: controlPoints,
3890
- debug: false,
3891
- });
3892
-
3893
- this .sampleOptions .haveWeights = !! weights;
3894
-
3895
- const
3896
- mesh = nurbs_nurbs .sample (this .mesh, surface, this .sampleOptions),
3897
- points = mesh .points,
3898
- interpolator = this .interpolator;
3633
+ return function ()
3634
+ {
3635
+ const
3636
+ fraction = external_X_ITE_X3D_Algorithm_default().clamp (this ._set_fraction .getValue (), 0, 1),
3637
+ surface = this .geometry .getSurface (),
3638
+ uDomain = surface .domain [0],
3639
+ u = external_X_ITE_X3D_Algorithm_default().project (fraction, 0, 1, ... uDomain);
3899
3640
 
3900
- interpolator ._key .length = 0;
3901
- interpolator ._keyValue .length = 0;
3641
+ surface .evaluate (value, u);
3902
3642
 
3903
- for (let i = 0, length = points .length; i < length; i += 3)
3904
- {
3905
- interpolator ._key .push (knots [0] + i / (length - 3) * scale);
3906
- interpolator ._keyValue. push (new (external_X_ITE_X3D_Fields_default()).SFVec3f (points [i], points [i + 1], points [i + 2]));
3907
- }
3908
- },
3643
+ this ._value_changed = value;
3644
+ };
3645
+ })(),
3909
3646
  });
3910
3647
 
3911
3648
  Object .defineProperties (NurbsPositionInterpolator,
@@ -4105,91 +3842,6 @@ const NurbsSet_default_ = NurbsSet;
4105
3842
  ;
4106
3843
 
4107
3844
  /* harmony default export */ const NURBS_NurbsSet = (external_X_ITE_X3D_Namespace_default().add ("NurbsSet", NurbsSet_default_));
4108
- ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Line3"
4109
- const external_X_ITE_X3D_Line3_namespaceObject = __X_ITE_X3D__ .Line3;
4110
- var external_X_ITE_X3D_Line3_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Line3_namespaceObject);
4111
- ;// CONCATENATED MODULE: ./src/standard/Math/Geometry/Triangle2.js
4112
- /*******************************************************************************
4113
- *
4114
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4115
- *
4116
- * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
4117
- *
4118
- * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
4119
- *
4120
- * The copyright notice above does not evidence any actual of intended
4121
- * publication of such source code, and is an unpublished work by create3000.
4122
- * This material contains CONFIDENTIAL INFORMATION that is the property of
4123
- * create3000.
4124
- *
4125
- * No permission is granted to copy, distribute, or create derivative works from
4126
- * the contents of this software, in whole or in part, without the prior written
4127
- * permission of create3000.
4128
- *
4129
- * NON-MILITARY USE ONLY
4130
- *
4131
- * All create3000 software are effectively free software with a non-military use
4132
- * restriction. It is free. Well commented source is provided. You may reuse the
4133
- * source in any way you please with the exception anything that uses it must be
4134
- * marked to indicate is contains 'non-military use only' components.
4135
- *
4136
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4137
- *
4138
- * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
4139
- *
4140
- * This file is part of the X_ITE Project.
4141
- *
4142
- * X_ITE is free software: you can redistribute it and/or modify it under the
4143
- * terms of the GNU General Public License version 3 only, as published by the
4144
- * Free Software Foundation.
4145
- *
4146
- * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
4147
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
4148
- * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
4149
- * details (a copy is included in the LICENSE file that accompanied this code).
4150
- *
4151
- * You should have received a copy of the GNU General Public License version 3
4152
- * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
4153
- * copy of the GPLv3 License.
4154
- *
4155
- * For Silvio, Joy and Adi.
4156
- *
4157
- ******************************************************************************/
4158
-
4159
- const Triangle2 =
4160
- {
4161
- isPointInTriangle (a, b, c, point)
4162
- {
4163
- // https://en.wikipedia.org/wiki/Barycentric_coordinate_system
4164
-
4165
- const det = (b.y - c.y) * (a.x - c.x) + (c.x - b.x) * (a.y - c.y);
4166
-
4167
- if (det == 0)
4168
- return false;
4169
-
4170
- const u = ((b.y - c.y) * (point .x - c.x) + (c.x - b.x) * (point .y - c.y)) / det;
4171
-
4172
- if (u < 0 || u > 1)
4173
- return false;
4174
-
4175
- const v = ((c.y - a.y) * (point .x - c.x) + (a.x - c.x) * (point .y - c.y)) / det;
4176
-
4177
- if (v < 0 || v > 1)
4178
- return false;
4179
-
4180
- const t = 1 - u - v;
4181
-
4182
- if (t < 0 || t > 1)
4183
- return false;
4184
-
4185
- return true;
4186
- },
4187
- };
4188
-
4189
- const Triangle2_default_ = Triangle2;
4190
- ;
4191
-
4192
- /* harmony default export */ const Geometry_Triangle2 = (external_X_ITE_X3D_Namespace_default().add ("Triangle2", Triangle2_default_));
4193
3845
  ;// CONCATENATED MODULE: ./src/x_ite/Components/NURBS/NurbsSurfaceInterpolator.js
4194
3846
  /*******************************************************************************
4195
3847
  *
@@ -4262,6 +3914,8 @@ Object .assign (Object .setPrototypeOf (NurbsSurfaceInterpolator .prototype, (ex
4262
3914
  {
4263
3915
  initialize ()
4264
3916
  {
3917
+ external_X_ITE_X3D_X3DChildNode_default().prototype .initialize .call (this);
3918
+
4265
3919
  this ._set_fraction .addInterest ("set_fraction__", this);
4266
3920
 
4267
3921
  this ._uOrder .addFieldInterest (this .geometry ._uOrder);
@@ -4273,8 +3927,8 @@ Object .assign (Object .setPrototypeOf (NurbsSurfaceInterpolator .prototype, (ex
4273
3927
  this ._weight .addFieldInterest (this .geometry ._weight);
4274
3928
  this ._controlPoint .addFieldInterest (this .geometry ._controlPoint);
4275
3929
 
4276
- this .geometry ._uTessellation = 128;
4277
- this .geometry ._vTessellation = 128;
3930
+ this .geometry ._uTessellation = 1;
3931
+ this .geometry ._vTessellation = 1;
4278
3932
  this .geometry ._uOrder = this ._uOrder;
4279
3933
  this .geometry ._vOrder = this ._vOrder;
4280
3934
  this .geometry ._uDimension = this ._uDimension;
@@ -4284,56 +3938,43 @@ Object .assign (Object .setPrototypeOf (NurbsSurfaceInterpolator .prototype, (ex
4284
3938
  this .geometry ._weight = this ._weight;
4285
3939
  this .geometry ._controlPoint = this ._controlPoint;
4286
3940
 
3941
+ this .geometry ._rebuild .addInterest ("set_geometry__", this);
4287
3942
  this .geometry .setup ();
3943
+
3944
+ this .set_geometry__ ();
3945
+ },
3946
+ set_geometry__ ()
3947
+ {
3948
+ const surface = this .geometry .getSurface ();
3949
+
3950
+ this .uDerivative = surface .evaluator ([1, 0]);
3951
+ this .vDerivative = surface .evaluator ([0, 1]);
4288
3952
  },
4289
3953
  set_fraction__: (() =>
4290
3954
  {
4291
3955
  const
4292
- a = new (external_X_ITE_X3D_Vector3_default()) (),
4293
- b = new (external_X_ITE_X3D_Vector3_default()) (),
4294
- c = new (external_X_ITE_X3D_Vector3_default()) (),
4295
- point = new (external_X_ITE_X3D_Vector3_default()) (),
4296
- line = new (external_X_ITE_X3D_Line3_default()) ((external_X_ITE_X3D_Vector3_default()).Zero, (external_X_ITE_X3D_Vector3_default()).zAxis),
4297
- uvt = { };
3956
+ uVector = new (external_X_ITE_X3D_Vector3_default()) (),
3957
+ vVector = new (external_X_ITE_X3D_Vector3_default()) (),
3958
+ position = new (external_X_ITE_X3D_Vector3_default()) ();
4298
3959
 
4299
3960
  return function ()
4300
3961
  {
4301
3962
  const
4302
- fraction = this ._set_fraction .getValue (),
4303
- texCoordsArray = this .geometry .getTexCoords (),
4304
- normalArray = this .geometry .getNormals (),
4305
- verticesArray = this .geometry .getVertices ();
4306
-
4307
- for (let i4 = 0, i3 = 0, length = texCoordsArray .length; i4 < length; i4 += 12, i3 += 9)
4308
- {
4309
- a .set (texCoordsArray [i4 + 0], texCoordsArray [i4 + 1], 0);
4310
- b .set (texCoordsArray [i4 + 4], texCoordsArray [i4 + 5], 0);
4311
- c .set (texCoordsArray [i4 + 7], texCoordsArray [i4 + 9], 0);
4312
-
4313
- if (Geometry_Triangle2 .isPointInTriangle (a, b, c, fraction))
4314
- {
4315
- line .set (point .set (fraction .x, fraction .y, 0), (external_X_ITE_X3D_Vector3_default()).zAxis);
4316
-
4317
- if (line .intersectsTriangle (a, b, c, uvt))
4318
- {
4319
- const
4320
- u = uvt .u,
4321
- v = uvt .v,
4322
- t = uvt .t;
4323
-
4324
- const normal = new (external_X_ITE_X3D_Vector3_default()) (t * normalArray [i3 + 0] + u * normalArray [i3 + 3] + v * normalArray [i3 + 6],
4325
- t * normalArray [i3 + 1] + u * normalArray [i3 + 4] + v * normalArray [i3 + 7],
4326
- t * normalArray [i3 + 2] + u * normalArray [i3 + 5] + v * normalArray [i3 + 8]);
4327
-
4328
- const position = new (external_X_ITE_X3D_Vector3_default()) (t * verticesArray [i4 + 0] + u * verticesArray [i4 + 4] + v * verticesArray [i4 + 8],
4329
- t * verticesArray [i4 + 1] + u * verticesArray [i4 + 5] + v * verticesArray [i4 + 9],
4330
- t * verticesArray [i4 + 2] + u * verticesArray [i4 + 6] + v * verticesArray [i4 + 10]);
4331
-
4332
- this ._normal_changed = normal;
4333
- this ._position_changed = position;
4334
- }
4335
- }
4336
- }
3963
+ fraction = this ._set_fraction .getValue (),
3964
+ uFraction = external_X_ITE_X3D_Algorithm_default().clamp (fraction .x, 0, 1),
3965
+ vFraction = external_X_ITE_X3D_Algorithm_default().clamp (fraction .y, 0, 1),
3966
+ surface = this .geometry .getSurface (),
3967
+ uDomain = surface .domain [0],
3968
+ vDomain = surface .domain [1],
3969
+ u = external_X_ITE_X3D_Algorithm_default().project (uFraction, 0, 1, ... uDomain),
3970
+ v = external_X_ITE_X3D_Algorithm_default().project (vFraction, 0, 1, ... vDomain);
3971
+
3972
+ this .uDerivative (uVector, u, v);
3973
+ this .vDerivative (vVector, u, v);
3974
+ surface .evaluate (position, u, v);
3975
+
3976
+ this ._normal_changed = uVector .cross (vVector);
3977
+ this ._position_changed = position;
4337
3978
  };
4338
3979
  })(),
4339
3980
  });
@@ -4462,13 +4103,11 @@ Object .assign (Object .setPrototypeOf (NurbsSweptSurface .prototype, NURBS_X3DP
4462
4103
  },
4463
4104
  set_crossSectionCurve__ ()
4464
4105
  {
4465
- if (this .crossSectionCurveNode)
4466
- this .crossSectionCurveNode .removeInterest ("requestRebuild", this);
4106
+ this .crossSectionCurveNode ?.removeInterest ("requestRebuild", this);
4467
4107
 
4468
4108
  this .crossSectionCurveNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DNurbsControlCurveNode, this ._crossSectionCurve);
4469
4109
 
4470
- if (this .crossSectionCurveNode)
4471
- this .crossSectionCurveNode .addInterest ("requestRebuild", this);
4110
+ this .crossSectionCurveNode ?.addInterest ("requestRebuild", this);
4472
4111
  },
4473
4112
  set_trajectoryCurve__ ()
4474
4113
  {
@@ -4480,10 +4119,10 @@ Object .assign (Object .setPrototypeOf (NurbsSweptSurface .prototype, NURBS_X3DP
4480
4119
  },
4481
4120
  build ()
4482
4121
  {
4483
- if (! this .crossSectionCurveNode)
4122
+ if (!this .crossSectionCurveNode)
4484
4123
  return;
4485
4124
 
4486
- if (! this .trajectoryCurveNode)
4125
+ if (!this .trajectoryCurveNode)
4487
4126
  return;
4488
4127
 
4489
4128
  const extrusion = this .extrusion;
@@ -4495,17 +4134,20 @@ Object .assign (Object .setPrototypeOf (NurbsSweptSurface .prototype, NURBS_X3DP
4495
4134
 
4496
4135
  this .getColors () .assign (extrusion .getColors ());
4497
4136
  this .getTexCoords () .assign (extrusion .getTexCoords ());
4137
+ this .getTangents () .assign (extrusion .getTangents ());
4498
4138
  this .getNormals () .assign (extrusion .getNormals ());
4499
4139
  this .getVertices () .assign (extrusion .getVertices ());
4500
4140
 
4501
4141
  this .getMultiTexCoords () .push (this .getTexCoords ());
4502
4142
 
4503
- if (! this ._ccw .getValue ())
4143
+ if (!this ._ccw .getValue ())
4504
4144
  {
4505
- const normals = this .getNormals ();
4145
+ const
4146
+ normalsArray = this .getNormals (),
4147
+ numNormals = normalsArray .length;
4506
4148
 
4507
- for (let i = 0, length = normals .length; i < length; ++ i)
4508
- normals [i] = -normals [i];
4149
+ for (let i = 0; i < numNormals; ++ i)
4150
+ normalsArray [i] *= -1;
4509
4151
  }
4510
4152
 
4511
4153
  this .setSolid (this ._solid .getValue ());
@@ -4627,30 +4269,26 @@ Object .assign (Object .setPrototypeOf (NurbsSwungSurface .prototype, NURBS_X3DP
4627
4269
  },
4628
4270
  set_profileCurve__ ()
4629
4271
  {
4630
- if (this .profileCurveNode)
4631
- this .profileCurveNode .removeInterest ("requestRebuild", this);
4272
+ this .profileCurveNode ?.removeInterest ("requestRebuild", this);
4632
4273
 
4633
4274
  this .profileCurveNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DNurbsControlCurveNode, this ._profileCurve);
4634
4275
 
4635
- if (this .profileCurveNode)
4636
- this .profileCurveNode .addInterest ("requestRebuild", this);
4276
+ this .profileCurveNode ?.addInterest ("requestRebuild", this);
4637
4277
  },
4638
4278
  set_trajectoryCurve__ ()
4639
4279
  {
4640
- if (this .trajectoryCurveNode)
4641
- this .trajectoryCurveNode .removeInterest ("requestRebuild", this);
4280
+ this .trajectoryCurveNode ?.removeInterest ("requestRebuild", this);
4642
4281
 
4643
4282
  this .trajectoryCurveNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DNurbsControlCurveNode, this ._trajectoryCurve);
4644
4283
 
4645
- if (this .trajectoryCurveNode)
4646
- this .trajectoryCurveNode .addInterest ("requestRebuild", this);
4284
+ this .trajectoryCurveNode ?.addInterest ("requestRebuild", this);
4647
4285
  },
4648
4286
  build ()
4649
4287
  {
4650
- if (! this .profileCurveNode)
4288
+ if (!this .profileCurveNode)
4651
4289
  return;
4652
4290
 
4653
- if (! this .trajectoryCurveNode)
4291
+ if (!this .trajectoryCurveNode)
4654
4292
  return;
4655
4293
 
4656
4294
  const extrusion = this .extrusion;
@@ -4662,17 +4300,20 @@ Object .assign (Object .setPrototypeOf (NurbsSwungSurface .prototype, NURBS_X3DP
4662
4300
 
4663
4301
  this .getColors () .assign (extrusion .getColors ());
4664
4302
  this .getTexCoords () .assign (extrusion .getTexCoords ());
4303
+ this .getTangents () .assign (extrusion .getTangents ());
4665
4304
  this .getNormals () .assign (extrusion .getNormals ());
4666
4305
  this .getVertices () .assign (extrusion .getVertices ());
4667
4306
 
4668
4307
  this .getMultiTexCoords () .push (this .getTexCoords ());
4669
4308
 
4670
- if (! this ._ccw .getValue ())
4309
+ if (!this ._ccw .getValue ())
4671
4310
  {
4672
- const normals = this .getNormals ();
4311
+ const
4312
+ normalsArray = this .getNormals (),
4313
+ numNormals = normalsArray .length;
4673
4314
 
4674
- for (let i = 0, length = normals .length; i < length; ++ i)
4675
- normals [i] = -normals [i];
4315
+ for (let i = 0; i < numNormals; ++ i)
4316
+ normalsArray [i] *= -1;
4676
4317
  }
4677
4318
 
4678
4319
  this .setSolid (this ._solid .getValue ());
@@ -4761,40 +4402,39 @@ function NurbsTextureCoordinate (executionContext)
4761
4402
 
4762
4403
  this .addType ((external_X_ITE_X3D_X3DConstants_default()).NurbsTextureCoordinate);
4763
4404
 
4764
- this .controlPoints = [ ];
4405
+ this .array = [ ];
4765
4406
  }
4766
4407
 
4767
4408
  Object .assign (Object .setPrototypeOf (NurbsTextureCoordinate .prototype, (external_X_ITE_X3D_X3DNode_default()).prototype),
4768
4409
  {
4769
- initialize ()
4770
- {
4771
- external_X_ITE_X3D_X3DNode_default().prototype .initialize .call (this);
4772
- },
4773
4410
  getControlPoints (texWeights)
4774
4411
  {
4775
4412
  const
4776
- controlPointArray = this ._controlPoint .getValue (),
4777
- controlPoints = this .controlPoints;
4413
+ uDimension = this ._uDimension .getValue (),
4414
+ vDimension = this ._vDimension .getValue (),
4415
+ controlPoints = this ._controlPoint .getValue (),
4416
+ array = this .array;
4778
4417
 
4779
- for (let u = 0, uDimension = this ._uDimension .getValue (); u < uDimension; ++ u)
4418
+ for (let u = 0; u < uDimension; ++ u)
4780
4419
  {
4781
- let cp = controlPoints [u];
4782
-
4783
- if (! cp)
4784
- cp = controlPoints [u] = [ ];
4420
+ const cp = array [u] ??= [ ];
4785
4421
 
4786
- for (let v = 0, vDimension = this ._vDimension .getValue (); v < vDimension; ++ v)
4422
+ for (let v = 0; v < vDimension; ++ v)
4787
4423
  {
4788
4424
  const
4789
4425
  index = v * uDimension + u,
4790
- p = cp [v] || new (external_X_ITE_X3D_Vector4_default()) (),
4426
+ p = cp [v] ?? new (external_X_ITE_X3D_Vector4_default()) (),
4791
4427
  i = index * 2;
4792
4428
 
4793
- cp [v] = p .set (controlPointArray [i], controlPointArray [i + 1], 0, texWeights ? texWeights [index] : 1);
4429
+ cp [v] = p .set (controlPoints [i], controlPoints [i + 1], 0, texWeights ? texWeights [index] : 1);
4794
4430
  }
4431
+
4432
+ cp .length = vDimension;
4795
4433
  }
4796
4434
 
4797
- return controlPoints;
4435
+ array .length = uDimension;
4436
+
4437
+ return array;
4798
4438
  },
4799
4439
  isValid ()
4800
4440
  {
@@ -4810,7 +4450,7 @@ Object .assign (Object .setPrototypeOf (NurbsTextureCoordinate .prototype, (exte
4810
4450
  if (this ._vDimension .getValue () < this ._vOrder .getValue ())
4811
4451
  return false;
4812
4452
 
4813
- if (this ._controlPoint .length !== this ._uDimension .getValue () * this ._vDimension .getValue ())
4453
+ if (this ._controlPoint .length < this ._uDimension .getValue () * this ._vDimension .getValue ())
4814
4454
  return false;
4815
4455
 
4816
4456
  return true;
@@ -4841,6 +4481,148 @@ const NurbsTextureCoordinate_default_ = NurbsTextureCoordinate;
4841
4481
  ;
4842
4482
 
4843
4483
  /* harmony default export */ const NURBS_NurbsTextureCoordinate = (external_X_ITE_X3D_Namespace_default().add ("NurbsTextureCoordinate", NurbsTextureCoordinate_default_));
4484
+ ;// CONCATENATED MODULE: ./src/standard/Math/Geometry/Triangle2.js
4485
+ /*******************************************************************************
4486
+ *
4487
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4488
+ *
4489
+ * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
4490
+ *
4491
+ * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
4492
+ *
4493
+ * The copyright notice above does not evidence any actual of intended
4494
+ * publication of such source code, and is an unpublished work by create3000.
4495
+ * This material contains CONFIDENTIAL INFORMATION that is the property of
4496
+ * create3000.
4497
+ *
4498
+ * No permission is granted to copy, distribute, or create derivative works from
4499
+ * the contents of this software, in whole or in part, without the prior written
4500
+ * permission of create3000.
4501
+ *
4502
+ * NON-MILITARY USE ONLY
4503
+ *
4504
+ * All create3000 software are effectively free software with a non-military use
4505
+ * restriction. It is free. Well commented source is provided. You may reuse the
4506
+ * source in any way you please with the exception anything that uses it must be
4507
+ * marked to indicate is contains 'non-military use only' components.
4508
+ *
4509
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4510
+ *
4511
+ * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
4512
+ *
4513
+ * This file is part of the X_ITE Project.
4514
+ *
4515
+ * X_ITE is free software: you can redistribute it and/or modify it under the
4516
+ * terms of the GNU General Public License version 3 only, as published by the
4517
+ * Free Software Foundation.
4518
+ *
4519
+ * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
4520
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
4521
+ * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
4522
+ * details (a copy is included in the LICENSE file that accompanied this code).
4523
+ *
4524
+ * You should have received a copy of the GNU General Public License version 3
4525
+ * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
4526
+ * copy of the GPLv3 License.
4527
+ *
4528
+ * For Silvio, Joy and Adi.
4529
+ *
4530
+ ******************************************************************************/
4531
+
4532
+
4533
+
4534
+ const Triangle2 =
4535
+ {
4536
+ /**
4537
+ *
4538
+ * @param {Vector2} a first point of triangle
4539
+ * @param {Vector2} b second point of triangle
4540
+ * @param {Vector2} c third point of triangle
4541
+ * @returns
4542
+ */
4543
+ area ({ x: ax, y: ay }, { x: bx, y: by }, { x: cx, y: cy })
4544
+ {
4545
+ return Math .abs (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by)) / 2;
4546
+ },
4547
+ /**
4548
+ *
4549
+ * @param {Vector2} p point to test
4550
+ * @param {Vector2} a first point of triangle
4551
+ * @param {Vector2} b second point of triagle
4552
+ * @param {Vector2} c third point of triangle
4553
+ * @returns
4554
+ */
4555
+ isPointInTriangle ({ x: px, y: py }, { x: ax, y: ay }, { x: bx, y: by }, { x: cx, y: cy })
4556
+ {
4557
+ // https://en.wikipedia.org/wiki/Barycentric_coordinate_system
4558
+
4559
+ const det = (by - cy) * (ax - cx) + (cx - bx) * (ay - cy);
4560
+
4561
+ if (det === 0)
4562
+ return false;
4563
+
4564
+ const u = ((by - cy) * (px - cx) + (cx - bx) * (py - cy)) / det;
4565
+
4566
+ if (u < 0 || u > 1)
4567
+ return false;
4568
+
4569
+ const v = ((cy - ay) * (px - cx) + (ax - cx) * (py - cy)) / det;
4570
+
4571
+ if (v < 0 || v > 1)
4572
+ return false;
4573
+
4574
+ const t = 1 - u - v;
4575
+
4576
+ if (t < 0 || t > 1)
4577
+ return false;
4578
+
4579
+ return true;
4580
+ },
4581
+ /**
4582
+ *
4583
+ * @param {Vector2} p point to convert
4584
+ * @param {Vector2} a first point of triangle
4585
+ * @param {Vector2} b second point of triangle
4586
+ * @param {Vector2} c third point of triangle
4587
+ * @returns
4588
+ */
4589
+ toBarycentric: (function ()
4590
+ {
4591
+ const
4592
+ v0 = new (external_X_ITE_X3D_Vector2_default()) (),
4593
+ v1 = new (external_X_ITE_X3D_Vector2_default()) (),
4594
+ v2 = new (external_X_ITE_X3D_Vector2_default()) ();
4595
+
4596
+ return function (point, a, b, c, result)
4597
+ {
4598
+ v0 .assign (b) .subtract (a);
4599
+ v1 .assign (c) .subtract (a);
4600
+ v2 .assign (point) .subtract (a);
4601
+
4602
+ const
4603
+ d00 = v0 .dot (v0),
4604
+ d01 = v0 .dot (v1),
4605
+ d11 = v1 .dot (v1),
4606
+ d20 = v2 .dot (v0),
4607
+ d21 = v2 .dot (v1),
4608
+ denom = d00 * d11 - d01 * d01;
4609
+
4610
+ result .v = (d11 * d20 - d01 * d21) / denom;
4611
+ result .t = (d00 * d21 - d01 * d20) / denom;
4612
+ result .u = 1 - result .v - result .t;
4613
+
4614
+ return result;
4615
+ };
4616
+ })(),
4617
+ };
4618
+
4619
+ const Triangle2_default_ = Triangle2;
4620
+ ;
4621
+
4622
+ /* harmony default export */ const Geometry_Triangle2 = (external_X_ITE_X3D_Namespace_default().add ("Triangle2", Triangle2_default_));
4623
+ ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .libtess"
4624
+ const external_X_ITE_X3D_libtess_namespaceObject = __X_ITE_X3D__ .libtess;
4625
+ var external_X_ITE_X3D_libtess_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_libtess_namespaceObject);
4844
4626
  ;// CONCATENATED MODULE: ./src/x_ite/Components/NURBS/NurbsTrimmedSurface.js
4845
4627
  /*******************************************************************************
4846
4628
  *
@@ -4897,6 +4679,10 @@ const NurbsTextureCoordinate_default_ = NurbsTextureCoordinate;
4897
4679
 
4898
4680
 
4899
4681
 
4682
+
4683
+
4684
+
4685
+
4900
4686
  function NurbsTrimmedSurface (executionContext)
4901
4687
  {
4902
4688
  NURBS_X3DNurbsSurfaceGeometryNode .call (this, executionContext);
@@ -4904,6 +4690,7 @@ function NurbsTrimmedSurface (executionContext)
4904
4690
  this .addType ((external_X_ITE_X3D_X3DConstants_default()).NurbsTrimmedSurface);
4905
4691
 
4906
4692
  this .trimmingContourNodes = [ ];
4693
+ this .trimmingContours = [ ];
4907
4694
  }
4908
4695
 
4909
4696
  Object .assign (Object .setPrototypeOf (NurbsTrimmedSurface .prototype, NURBS_X3DNurbsSurfaceGeometryNode .prototype),
@@ -4941,6 +4728,9 @@ Object .assign (Object .setPrototypeOf (NurbsTrimmedSurface .prototype, NURBS_X3
4941
4728
  {
4942
4729
  const trimmingContourNodes = this .trimmingContourNodes;
4943
4730
 
4731
+ for (const trimmingContourNode of trimmingContourNodes)
4732
+ trimmingContourNode .removeInterest ("requestRebuild", this);
4733
+
4944
4734
  trimmingContourNodes .length = 0;
4945
4735
 
4946
4736
  for (const node of this ._trimmingContour)
@@ -4950,18 +4740,275 @@ Object .assign (Object .setPrototypeOf (NurbsTrimmedSurface .prototype, NURBS_X3
4950
4740
  if (trimmingContourNode)
4951
4741
  trimmingContourNodes .push (trimmingContourNode);
4952
4742
  }
4743
+
4744
+ for (const trimmingContourNode of trimmingContourNodes)
4745
+ trimmingContourNode .addInterest ("requestRebuild", this);
4953
4746
  },
4954
- getTrimmingContours ()
4747
+ getTrimmingContours (offset, scale, trimmingContours)
4748
+ {
4749
+ for (const trimmingContourNode of this .trimmingContourNodes)
4750
+ trimmingContourNode .addTrimmingContour (offset, scale, trimmingContours);
4751
+
4752
+ return trimmingContours;
4753
+ },
4754
+ trimSurface: (function ()
4755
+ {
4756
+ const unitSquare = [
4757
+ new (external_X_ITE_X3D_Vector3_default()) (0, 0, 0),
4758
+ new (external_X_ITE_X3D_Vector3_default()) (1, 0, 0),
4759
+ new (external_X_ITE_X3D_Vector3_default()) (1, 1, 0),
4760
+ new (external_X_ITE_X3D_Vector3_default()) (0, 1, 0),
4761
+ ];
4762
+
4763
+ return function (uKnots, vKnots)
4764
+ {
4765
+ // console .time (this .getTypeName ());
4766
+
4767
+ const
4768
+ uMin = uKnots .at (0),
4769
+ vMin = vKnots .at (0),
4770
+ uMax = uKnots .at (-1),
4771
+ vMax = vKnots .at (-1),
4772
+ uScale = uMax - uMin,
4773
+ vScale = vMax - vMin,
4774
+ offset = new (external_X_ITE_X3D_Vector3_default()) (uMin, vMin, 0),
4775
+ scale = new (external_X_ITE_X3D_Vector3_default()) (uScale, vScale, 1)
4776
+
4777
+ // Triangulate holes on unit square.
4778
+
4779
+ const
4780
+ defaultTriangles = this .createDefaultNurbsTriangles ([ ]),
4781
+ numDefaultTriangles = defaultTriangles .length,
4782
+ trimmingContours = this .getTrimmingContours (offset, scale, [unitSquare]),
4783
+ trimmingTriangles = this .triangulatePolygon (trimmingContours, [ ], false),
4784
+ numTrimmingTriangles = trimmingTriangles .length,
4785
+ contours = [ ];
4786
+
4787
+ // Do nothing if there are no trimming contours.
4788
+ if (trimmingContours .length === 1)
4789
+ return;
4790
+
4791
+ for (let i = 0; i < numDefaultTriangles; ++ i)
4792
+ defaultTriangles [i] .index = i;
4793
+
4794
+ for (let i = 0; i < numDefaultTriangles; i += 3)
4795
+ contours .push (defaultTriangles .slice (i, i + 3));
4796
+
4797
+ for (let i = 0; i < numTrimmingTriangles; i += 3)
4798
+ contours .push (trimmingTriangles .slice (i, i + 3));
4799
+
4800
+ const
4801
+ multiTexCoordArray = this .getMultiTexCoords (),
4802
+ normalArray = this .getNormals (),
4803
+ vertexArray = this .getVertices (),
4804
+ trimmedTriangles = this .triangulatePolygon (contours, [ ], true),
4805
+ numTrimmedTriangles = trimmedTriangles .length,
4806
+ numTexCoordChannels = multiTexCoordArray .length,
4807
+ trimmedMultiTexCoords = multiTexCoordArray .map (() => [ ]),
4808
+ trimmedNormals = [ ],
4809
+ trimmedVertices = [ ],
4810
+ uvt = { };
4811
+
4812
+ // console .log (trimmedTriangles .toString ());
4813
+
4814
+ // Filter triangles with very small area.
4815
+
4816
+ const MIN_AREA = 1e-6;
4817
+
4818
+ let f = 0;
4819
+
4820
+ for (let t = 0; t < numTrimmedTriangles; t += 3)
4821
+ {
4822
+ const { [t]: a, [t + 1]: b, [t + 2]: c } = trimmedTriangles;
4823
+
4824
+ if (Geometry_Triangle2 .area (a, b, c) < MIN_AREA)
4825
+ continue;
4826
+
4827
+ trimmedTriangles [f ++] = a,
4828
+ trimmedTriangles [f ++] = b,
4829
+ trimmedTriangles [f ++] = c;
4830
+ }
4831
+
4832
+ trimmedTriangles .length = f;
4833
+
4834
+ // Find points in defaultTriangles and interpolate new points.
4835
+
4836
+ const MIN_BARYCENTRIC_DISTANCE = 1e-5;
4837
+
4838
+ FIND_POINTS: for (let t = 0; t < f; ++ t)
4839
+ {
4840
+ const p = trimmedTriangles [t];
4841
+
4842
+ if (p .hasOwnProperty ("index"))
4843
+ {
4844
+ const
4845
+ d = p .index,
4846
+ d3 = d * 3,
4847
+ d4 = d * 4;
4848
+
4849
+ // Copy point on surface.
4850
+
4851
+ for (let tc = 0; tc < numTexCoordChannels; ++ tc)
4852
+ {
4853
+ const
4854
+ texCoordArray = multiTexCoordArray [tc],
4855
+ trimmedTexCoords = trimmedMultiTexCoords [tc];
4856
+
4857
+ const { [d4]: t1, [d4 + 1]: t2, [d4 + 2]: t3, [d4 + 3]: t4 } = texCoordArray;
4858
+
4859
+ trimmedTexCoords .push (t1, t2, t3, t4);
4860
+ }
4861
+
4862
+ const
4863
+ { [d3]: n1, [d3 + 1]: n2, [d3 + 2]: n3 } = normalArray,
4864
+ { [d4]: v1, [d4 + 1]: v2, [d4 + 2]: v3 } = vertexArray;
4865
+
4866
+ trimmedNormals .push (n1, n2, n3);
4867
+ trimmedVertices .push (v1, v2, v3, 1);
4868
+
4869
+ continue FIND_POINTS;
4870
+ }
4871
+
4872
+ for (let d = 0; d < numDefaultTriangles; d += 3)
4873
+ {
4874
+ // At least one triangle should match.
4875
+
4876
+ const { [d]: a, [d + 1]: b, [d + 2]: c } = defaultTriangles;
4877
+
4878
+ const { u, v, t } = Geometry_Triangle2 .toBarycentric (p, a, b, c, uvt);
4879
+
4880
+ // Check if p lies in triangle.
4881
+
4882
+ if (Math .abs (u - 0.5) > 0.5 + MIN_BARYCENTRIC_DISTANCE)
4883
+ continue;
4884
+
4885
+ if (Math .abs (v - 0.5) > 0.5 + MIN_BARYCENTRIC_DISTANCE)
4886
+ continue;
4887
+
4888
+ if (Math .abs (t - 0.5) > 0.5 + MIN_BARYCENTRIC_DISTANCE)
4889
+ continue;
4890
+
4891
+ // Interpolate point on surface.
4892
+
4893
+ const
4894
+ d3 = d * 3,
4895
+ d4 = d * 4;
4896
+
4897
+ for (let tc = 0; tc < numTexCoordChannels; ++ tc)
4898
+ {
4899
+ const
4900
+ texCoordArray = multiTexCoordArray [tc],
4901
+ trimmedTexCoords = trimmedMultiTexCoords [tc];
4902
+
4903
+ trimmedTexCoords .push (
4904
+ u * texCoordArray [d4 + 0] + v * texCoordArray [d4 + 4] + t * texCoordArray [d4 + 8],
4905
+ u * texCoordArray [d4 + 1] + v * texCoordArray [d4 + 5] + t * texCoordArray [d4 + 9],
4906
+ u * texCoordArray [d4 + 2] + v * texCoordArray [d4 + 6] + t * texCoordArray [d4 + 10],
4907
+ u * texCoordArray [d4 + 3] + v * texCoordArray [d4 + 7] + t * texCoordArray [d4 + 11],
4908
+ );
4909
+ }
4910
+
4911
+ trimmedNormals .push (
4912
+ u * normalArray [d3 + 0] + v * normalArray [d3 + 3] + t * normalArray [d3 + 6],
4913
+ u * normalArray [d3 + 1] + v * normalArray [d3 + 4] + t * normalArray [d3 + 7],
4914
+ u * normalArray [d3 + 2] + v * normalArray [d3 + 5] + t * normalArray [d3 + 8],
4915
+ );
4916
+
4917
+ trimmedVertices .push (
4918
+ u * vertexArray [d4 + 0] + v * vertexArray [d4 + 4] + t * vertexArray [d4 + 8],
4919
+ u * vertexArray [d4 + 1] + v * vertexArray [d4 + 5] + t * vertexArray [d4 + 9],
4920
+ u * vertexArray [d4 + 2] + v * vertexArray [d4 + 6] + t * vertexArray [d4 + 10],
4921
+ 1,
4922
+ );
4923
+
4924
+ continue FIND_POINTS;
4925
+ }
4926
+
4927
+ // Point not found, discard triangle.
4928
+
4929
+ const n = t % 3;
4930
+
4931
+ for (const trimmedTexCoords of trimmedMultiTexCoords)
4932
+ trimmedTexCoords .length -= n * 4;
4933
+
4934
+ trimmedNormals .length -= n * 3;
4935
+ trimmedVertices .length -= n * 4;
4936
+
4937
+ t += 2 - n;
4938
+ }
4939
+
4940
+ for (let tc = 0; tc < numTexCoordChannels; ++ tc)
4941
+ multiTexCoordArray [tc] .assign (trimmedMultiTexCoords [tc]);
4942
+
4943
+ normalArray .assign (trimmedNormals);
4944
+ vertexArray .assign (trimmedVertices);
4945
+
4946
+ // console .timeEnd (this .getTypeName ());
4947
+ };
4948
+ })(),
4949
+ createDefaultNurbsTriangles (triangles)
4955
4950
  {
4951
+ // Create triangles in the unit square.
4952
+
4956
4953
  const
4957
- trimmingContourNodes = this .trimmingContourNodes,
4958
- trimmingContours = [ ];
4954
+ texCoordArray = this .createDefaultNurbsTexCoords ([ ]),
4955
+ numTexCoords = texCoordArray .length;
4959
4956
 
4960
- for (const trimmingContourNode of trimmingContourNodes)
4961
- trimmingContourNode .addTrimmingContour (trimmingContours);
4957
+ for (let i = 0; i < numTexCoords; i += 4)
4958
+ triangles .push (new (external_X_ITE_X3D_Vector3_default()) (texCoordArray [i], texCoordArray [i + 1], 0));
4962
4959
 
4963
- return trimmingContours;
4960
+ return triangles;
4964
4961
  },
4962
+ triangulatePolygon: (() =>
4963
+ {
4964
+ // Function called for each vertex of tessellator output.
4965
+
4966
+ function vertexCallback (point, triangles)
4967
+ {
4968
+ triangles .push (point);
4969
+ }
4970
+
4971
+ function combineCallback (coords, data, weight)
4972
+ {
4973
+ return new (external_X_ITE_X3D_Vector3_default()) (... coords);
4974
+ }
4975
+
4976
+ function combineCallbackIndex (coords, [a, b, c, d], weight)
4977
+ {
4978
+ if (!c && a .x === b .x && a .y === b .y)
4979
+ return a;
4980
+
4981
+ return new (external_X_ITE_X3D_Vector3_default()) (... coords);
4982
+ }
4983
+
4984
+ const tessy = new (external_X_ITE_X3D_libtess_default()).GluTesselator ();
4985
+
4986
+ tessy .gluTessCallback ((external_X_ITE_X3D_libtess_default()).gluEnum .GLU_TESS_VERTEX_DATA, vertexCallback);
4987
+ tessy .gluTessCallback ((external_X_ITE_X3D_libtess_default()).gluEnum .GLU_TESS_COMBINE, combineCallback);
4988
+ tessy .gluTessProperty ((external_X_ITE_X3D_libtess_default()).gluEnum .GLU_TESS_WINDING_RULE, (external_X_ITE_X3D_libtess_default()).windingRule .GLU_TESS_WINDING_ODD);
4989
+ tessy .gluTessNormal (0, 0, 1);
4990
+
4991
+ return function (contours, triangles, index)
4992
+ {
4993
+ tessy .gluTessCallback ((external_X_ITE_X3D_libtess_default()).gluEnum .GLU_TESS_COMBINE, index ? combineCallbackIndex : combineCallback);
4994
+
4995
+ tessy .gluTessBeginPolygon (triangles);
4996
+
4997
+ for (const points of contours)
4998
+ {
4999
+ tessy .gluTessBeginContour ();
5000
+
5001
+ for (const point of points)
5002
+ tessy .gluTessVertex (point, point);
5003
+
5004
+ tessy .gluTessEndContour ();
5005
+ }
5006
+
5007
+ tessy .gluTessEndPolygon ();
5008
+
5009
+ return triangles;
5010
+ };
5011
+ })(),
4965
5012
  });
4966
5013
 
4967
5014
  function NurbsTrimmedSurface_filter (array, remove)