x_ite 10.4.2 → 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 (49) hide show
  1. package/README.md +4 -4
  2. package/dist/assets/components/AnnotationComponent.js +2 -2
  3. package/dist/assets/components/AnnotationComponent.min.js +2 -2
  4. package/dist/assets/components/CADGeometryComponent.js +2 -2
  5. package/dist/assets/components/CADGeometryComponent.min.js +2 -2
  6. package/dist/assets/components/CubeMapTexturingComponent.js +2 -2
  7. package/dist/assets/components/CubeMapTexturingComponent.min.js +2 -2
  8. package/dist/assets/components/DISComponent.js +2 -2
  9. package/dist/assets/components/DISComponent.min.js +2 -2
  10. package/dist/assets/components/EventUtilitiesComponent.js +2 -2
  11. package/dist/assets/components/EventUtilitiesComponent.min.js +2 -2
  12. package/dist/assets/components/Geometry2DComponent.js +19 -23
  13. package/dist/assets/components/Geometry2DComponent.min.js +2 -2
  14. package/dist/assets/components/GeospatialComponent.js +2 -2
  15. package/dist/assets/components/GeospatialComponent.min.js +2 -2
  16. package/dist/assets/components/HAnimComponent.js +2 -2
  17. package/dist/assets/components/HAnimComponent.min.js +2 -2
  18. package/dist/assets/components/KeyDeviceSensorComponent.js +2 -2
  19. package/dist/assets/components/KeyDeviceSensorComponent.min.js +2 -2
  20. package/dist/assets/components/LayoutComponent.js +2 -6
  21. package/dist/assets/components/LayoutComponent.min.js +2 -2
  22. package/dist/assets/components/NURBSComponent.js +805 -770
  23. package/dist/assets/components/NURBSComponent.min.js +2 -2
  24. package/dist/assets/components/ParticleSystemsComponent.js +10 -13
  25. package/dist/assets/components/ParticleSystemsComponent.min.js +2 -2
  26. package/dist/assets/components/PickingComponent.js +2 -2
  27. package/dist/assets/components/PickingComponent.min.js +2 -2
  28. package/dist/assets/components/RigidBodyPhysicsComponent.js +2 -2
  29. package/dist/assets/components/RigidBodyPhysicsComponent.min.js +2 -2
  30. package/dist/assets/components/ScriptingComponent.js +2 -2
  31. package/dist/assets/components/ScriptingComponent.min.js +2 -2
  32. package/dist/assets/components/TextComponent.js +7 -13
  33. package/dist/assets/components/TextComponent.min.js +2 -2
  34. package/dist/assets/components/TextureProjectionComponent.js +2 -2
  35. package/dist/assets/components/TextureProjectionComponent.min.js +2 -2
  36. package/dist/assets/components/Texturing3DComponent.js +10 -10
  37. package/dist/assets/components/Texturing3DComponent.min.js +2 -2
  38. package/dist/assets/components/VolumeRenderingComponent.js +2 -2
  39. package/dist/assets/components/VolumeRenderingComponent.min.js +2 -2
  40. package/dist/assets/components/X_ITEComponent.js +2 -2
  41. package/dist/assets/components/X_ITEComponent.min.js +2 -2
  42. package/dist/example.html +1 -1
  43. package/dist/x_ite.css +1 -1
  44. package/dist/x_ite.js +483 -308
  45. package/dist/x_ite.min.js +2 -2
  46. package/dist/x_ite.min.mjs +2 -2
  47. package/dist/x_ite.mjs +483 -308
  48. package/dist/x_ite.zip +0 -0
  49. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
- /* X_ITE v10.4.2 */
2
- const __X_ITE_X3D__ = window [Symbol .for ("X_ITE.X3D-10.4.2")];
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
 
@@ -530,11 +506,6 @@ const NURBS =
530
506
  if (!controlPoint [0] .equals (controlPoint [dimension - 1]))
531
507
  return false;
532
508
 
533
- // Check if knots are periodic.
534
-
535
- if (!this .isPeriodic (order, dimension, knot))
536
- return false;
537
-
538
509
  return true;
539
510
  },
540
511
  getClosed: (() =>
@@ -562,11 +533,6 @@ const NURBS =
562
533
  if (!controlPointNode .get1Point (0, firstPoint) .equals (controlPointNode .get1Point (dimension - 1, lastPoint)))
563
534
  return false;
564
535
 
565
- // Check if knots are periodic.
566
-
567
- if (!this .isPeriodic (order, dimension, knot))
568
- return false;
569
-
570
536
  return true;
571
537
  };
572
538
  })(),
@@ -580,7 +546,7 @@ const NURBS =
580
546
  {
581
547
  const haveWeights = weight .length === controlPointNode .getSize ();
582
548
 
583
- for (let v = 0, length = vDimension; v < length; ++ v)
549
+ for (let v = 0; v < vDimension; ++ v)
584
550
  {
585
551
  const
586
552
  first = v * uDimension,
@@ -600,11 +566,6 @@ const NURBS =
600
566
  return false;
601
567
  }
602
568
 
603
- // Check if knots are periodic.
604
-
605
- if (!this .isPeriodic (uOrder, uDimension, uKnot))
606
- return false;
607
-
608
569
  return true;
609
570
  };
610
571
  })(),
@@ -618,7 +579,7 @@ const NURBS =
618
579
  {
619
580
  const haveWeights = weight .length === controlPointNode .getSize ();
620
581
 
621
- for (let u = 0, size = uDimension; u < size; ++ u)
582
+ for (let u = 0; u < uDimension; ++ u)
622
583
  {
623
584
  const
624
585
  first = u,
@@ -638,52 +599,14 @@ const NURBS =
638
599
  return false;
639
600
  }
640
601
 
641
- // Check if knots are periodic.
642
-
643
- if (!this .isPeriodic (vOrder, vDimension, vKnot))
644
- return false;
645
-
646
602
  return true;
647
603
  };
648
604
  })(),
649
- isPeriodic (order, dimension, knot)
650
- {
651
- // Check if knots are periodic.
652
-
653
- if (knot .length === dimension + order)
654
- {
655
- {
656
- let count = 1;
657
-
658
- for (let i = 1, size = order; i < size; ++ i)
659
- {
660
- count += knot [i] === knot [0];
661
- }
662
-
663
- if (count === order)
664
- return false;
665
- }
666
-
667
- {
668
- let count = 1;
669
-
670
- for (let i = knot .length - order, size = knot .length - 1; i < size; ++ i)
671
- {
672
- count += knot [i] === knot [size];
673
- }
674
-
675
- if (count === order)
676
- return false;
677
- }
678
- }
679
-
680
- return true;
681
- },
682
605
  getKnots (result, closed, order, dimension, knot)
683
606
  {
684
607
  const
685
608
  length = dimension + order,
686
- knots = result || [ ];
609
+ knots = result ?? [ ];
687
610
 
688
611
  for (let i = 0, l = knot .length; i < l; ++ i)
689
612
  knots [i] = knot [i];
@@ -744,13 +667,22 @@ const NURBS =
744
667
  }
745
668
 
746
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;
747
677
  }
748
678
 
749
679
  if (closed)
750
680
  {
751
681
  // Make knots periodic.
752
682
 
753
- for (let i = 1, l = order - 1; i < l; ++ i)
683
+ const l = order - 1;
684
+
685
+ for (let i = 1; i < l; ++ i)
754
686
  knots .push (knots .at (-1) + (knots [i] - knots [i - 1]));
755
687
  }
756
688
 
@@ -761,7 +693,7 @@ const NURBS =
761
693
  if (weight .length !== dimension)
762
694
  return undefined;
763
695
 
764
- const weights = result || [ ];
696
+ const weights = result ?? [ ];
765
697
 
766
698
  for (let i = 0; i < dimension; ++ i)
767
699
  {
@@ -779,7 +711,7 @@ const NURBS =
779
711
  if (weight .length !== dimension)
780
712
  return undefined;
781
713
 
782
- const weights = result || [ ];
714
+ const weights = result ?? [ ];
783
715
 
784
716
  for (let u = 0, i = 0; u < uDimension; ++ u)
785
717
  {
@@ -796,7 +728,7 @@ const NURBS =
796
728
  getControlPoints2D (result, closed, order, weights, controlPoint)
797
729
  {
798
730
  const
799
- controlPoints = result || [ ],
731
+ controlPoints = result ?? [ ],
800
732
  controlPointArray = controlPoint .getValue (),
801
733
  dimension = controlPoint .length,
802
734
  haveWeights = !! weights,
@@ -812,16 +744,18 @@ const NURBS =
812
744
  {
813
745
  const
814
746
  i2 = i * 2,
815
- p = controlPoints [i] || new Vector (0, 0, 0);
747
+ cp = controlPoints [i] ??= new Vector (0, 0, 0);
816
748
 
817
- 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);
818
750
  }
819
751
 
820
752
  controlPoints .length = dimension;
821
753
 
822
754
  if (closed)
823
755
  {
824
- for (let i = 1, size = order - 1; i < size; ++ i)
756
+ const length = order - 1;
757
+
758
+ for (let i = 1; i < length; ++ i)
825
759
  controlPoints .push (controlPoints [i]);
826
760
  }
827
761
 
@@ -830,7 +764,7 @@ const NURBS =
830
764
  getControlPoints (result, closed, order, weights, controlPointNode)
831
765
  {
832
766
  const
833
- controlPoints = result || [ ],
767
+ controlPoints = result ?? [ ],
834
768
  dimension = controlPointNode .getSize (),
835
769
  haveWeights = !! weights,
836
770
  Vector = haveWeights ? (external_X_ITE_X3D_Vector4_default()) : (external_X_ITE_X3D_Vector3_default());
@@ -843,7 +777,7 @@ const NURBS =
843
777
 
844
778
  for (let i = 0; i < dimension; ++ i)
845
779
  {
846
- 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));
847
781
 
848
782
  if (haveWeights)
849
783
  cp .w = weights [i];
@@ -853,7 +787,9 @@ const NURBS =
853
787
 
854
788
  if (closed)
855
789
  {
856
- for (let i = 1, size = order - 1; i < size; ++ i)
790
+ const length = order - 1;
791
+
792
+ for (let i = 1; i < length; ++ i)
857
793
  controlPoints .push (controlPoints [i]);
858
794
  }
859
795
 
@@ -862,7 +798,7 @@ const NURBS =
862
798
  getUVControlPoints (result, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, weights, controlPointNode)
863
799
  {
864
800
  const
865
- controlPoints = result || [ ],
801
+ controlPoints = result ?? [ ],
866
802
  haveWeights = !! weights,
867
803
  Vector = haveWeights ? (external_X_ITE_X3D_Vector4_default()) : (external_X_ITE_X3D_Vector3_default());
868
804
 
@@ -874,16 +810,13 @@ const NURBS =
874
810
 
875
811
  for (let u = 0; u < uDimension; ++ u)
876
812
  {
877
- let cp = controlPoints [u];
878
-
879
- if (!cp)
880
- cp = controlPoints [u] = [ ];
813
+ const cp = controlPoints [u] ??= [ ];
881
814
 
882
815
  for (let v = 0; v < vDimension; ++ v)
883
816
  {
884
817
  const index = v * uDimension + u;
885
818
 
886
- 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));
887
820
 
888
821
  if (haveWeights)
889
822
  cp [v] .w = weights [index];
@@ -893,7 +826,9 @@ const NURBS =
893
826
 
894
827
  if (vClosed)
895
828
  {
896
- for (let i = 1, length = vOrder - 1; i < length; ++ i)
829
+ const length = vOrder - 1;
830
+
831
+ for (let i = 1; i < length; ++ i)
897
832
  cp .push (cp [i]);
898
833
  }
899
834
  }
@@ -902,7 +837,9 @@ const NURBS =
902
837
 
903
838
  if (uClosed)
904
839
  {
905
- for (let i = 1, length = uOrder - 1; i < length; ++ i)
840
+ const length = uOrder - 1;
841
+
842
+ for (let i = 1; i < length; ++ i)
906
843
  controlPoints .push (controlPoints [i]);
907
844
  }
908
845
 
@@ -910,27 +847,26 @@ const NURBS =
910
847
  },
911
848
  getTexControlPoints (result, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, controlPointNode)
912
849
  {
913
- const controlPoints = result || [ ];
850
+ const controlPoints = result ?? [ ];
914
851
 
915
852
  for (let u = 0; u < uDimension; ++ u)
916
853
  {
917
- let cp = controlPoints [u];
918
-
919
- if (!cp)
920
- cp = controlPoints [u] = [ ];
854
+ const cp = controlPoints [u] ??= [ ];
921
855
 
922
856
  for (let v = 0; v < vDimension; ++ v)
923
857
  {
924
858
  const index = v * uDimension + u;
925
859
 
926
- 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()) ());
927
861
  }
928
862
 
929
863
  cp .length = vDimension;
930
864
 
931
865
  if (vClosed)
932
866
  {
933
- for (let i = 1, length = vOrder - 1; i < length; ++ i)
867
+ const length = vOrder - 1;
868
+
869
+ for (let i = 1; i < length; ++ i)
934
870
  cp .push (cp [i]);
935
871
  }
936
872
  }
@@ -939,7 +875,9 @@ const NURBS =
939
875
 
940
876
  if (uClosed)
941
877
  {
942
- for (let i = 1, length = uOrder - 1; i < length; ++ i)
878
+ const length = uOrder - 1;
879
+
880
+ for (let i = 1; i < length; ++ i)
943
881
  controlPoints .push (controlPoints [i]);
944
882
  }
945
883
 
@@ -2064,47 +2002,32 @@ const support_default_ = function (cacheKey, nurbs, accessors, debug, checkBound
2064
2002
 
2065
2003
  /* harmony default export */ const support = (external_X_ITE_X3D_Namespace_default().add ("support", support_default_));
2066
2004
  ;// CONCATENATED MODULE: ./src/lib/nurbs/extras/sample.js
2067
- var tmp1 = [ ];
2005
+ const tmp1 = [ ] ;
2068
2006
 
2069
- const sample_default_ = function (mesh, surface, opts)
2007
+ function sample (mesh, surface, opts)
2070
2008
  {
2071
- mesh = mesh || { };
2072
- opts = opts || { };
2073
-
2074
- var
2075
- points = mesh .points = mesh .points || [ ],
2076
- faces = mesh .faces = mesh .faces || [ ],
2077
- haveWeights = opts .haveWeights;
2078
-
2079
- var dimension = surface .dimension - haveWeights;
2080
-
2081
- if (Array .isArray (opts .resolution))
2082
- {
2083
- var resolution = opts .resolution;
2084
- }
2085
- else
2086
- {
2087
- var
2088
- res = opts .resolution === undefined ? 31 : opts .resolution,
2089
- resolution = new Array (surface .splineDimension) .fill (res);
2090
- }
2009
+ const
2010
+ points = mesh .points ??= [ ],
2011
+ faces = mesh .faces ??= [ ],
2012
+ haveWeights = opts .haveWeights,
2013
+ dimension = surface .dimension - haveWeights,
2014
+ resolution = opts .resolution;
2091
2015
 
2092
2016
  switch (surface .splineDimension)
2093
2017
  {
2094
2018
  case 1:
2095
2019
  {
2096
- var
2020
+ const
2097
2021
  nu = resolution [0],
2098
- uClosed = surface .boundary [0] === "closed",
2099
- nuBound = nu + ! uClosed,
2022
+ nuBound = nu + 1,
2100
2023
  nbVertices = nuBound * dimension,
2101
- domain = opts .domain || surface .domain,
2024
+ domain = surface .domain,
2102
2025
  uDomain = domain [0],
2103
2026
  uDistance = uDomain [1] - uDomain [0];
2104
2027
 
2105
- for (var i = 0; i < nuBound; ++ i)
2028
+ for (let i = 0; i < nuBound; ++ i)
2106
2029
  {
2107
- var
2030
+ const
2108
2031
  u = uDomain [0] + uDistance * i / nu,
2109
2032
  ptr = i * dimension;
2110
2033
 
@@ -2112,14 +2035,14 @@ const sample_default_ = function (mesh, surface, opts)
2112
2035
 
2113
2036
  if (haveWeights)
2114
2037
  {
2115
- var w = tmp1 [dimension];
2038
+ const w = tmp1 [dimension];
2116
2039
 
2117
- for (var d = 0; d < dimension; ++ d)
2040
+ for (let d = 0; d < dimension; ++ d)
2118
2041
  points [ptr + d] = tmp1 [d] / w;
2119
2042
  }
2120
2043
  else
2121
2044
  {
2122
- for (var d = 0; d < dimension; ++ d)
2045
+ for (let d = 0; d < dimension; ++ d)
2123
2046
  points [ptr + d] = tmp1 [d];
2124
2047
  }
2125
2048
  }
@@ -2129,29 +2052,29 @@ const sample_default_ = function (mesh, surface, opts)
2129
2052
  }
2130
2053
  case 2:
2131
2054
  {
2132
- var
2055
+ const
2133
2056
  nu = resolution [0],
2134
2057
  nv = resolution [1],
2135
- uClosed = surface .boundary [0] === "closed",
2136
- vClosed = surface .boundary [1] === "closed",
2137
- nuBound = nu + ! uClosed,
2138
- nvBound = nv + ! vClosed,
2058
+ nuBound = nu + 1,
2059
+ nvBound = nv + 1,
2139
2060
  nbVertices = nuBound * nvBound * dimension,
2140
- domain = opts .domain || surface .domain,
2061
+ domain = surface .domain,
2141
2062
  uDomain = domain [0],
2142
2063
  vDomain = domain [1],
2143
2064
  uDistance = uDomain [1] - uDomain [0],
2144
- vDistance = vDomain [1] - vDomain [0];
2065
+ vDistance = vDomain [1] - vDomain [0],
2066
+ uClosed = opts .closed [0],
2067
+ vClosed = opts .closed [1];
2145
2068
 
2146
2069
  // Generate points.
2147
2070
 
2148
- for (var i = 0; i < nuBound; ++ i)
2071
+ for (let i = 0; i < nuBound; ++ i)
2149
2072
  {
2150
- var u = uDomain [0] + uDistance * i / nu;
2073
+ const u = uDomain [0] + uDistance * i / nu;
2151
2074
 
2152
- for (var j = 0; j < nvBound; ++ j)
2075
+ for (let j = 0; j < nvBound; ++ j)
2153
2076
  {
2154
- var
2077
+ const
2155
2078
  v = vDomain [0] + vDistance * j / nv,
2156
2079
  ptr = (i + nuBound * j) * dimension;
2157
2080
 
@@ -2159,14 +2082,14 @@ const sample_default_ = function (mesh, surface, opts)
2159
2082
 
2160
2083
  if (haveWeights)
2161
2084
  {
2162
- var w = tmp1 [dimension];
2085
+ const w = tmp1 [dimension];
2163
2086
 
2164
- for (var d = 0; d < dimension; ++ d)
2087
+ for (let d = 0; d < dimension; ++ d)
2165
2088
  points [ptr + d] = tmp1 [d] / w;
2166
2089
  }
2167
2090
  else
2168
2091
  {
2169
- for (var d = 0; d < dimension; ++ d)
2092
+ for (let d = 0; d < dimension; ++ d)
2170
2093
  points [ptr + d] = tmp1 [d];
2171
2094
  }
2172
2095
  }
@@ -2176,25 +2099,20 @@ const sample_default_ = function (mesh, surface, opts)
2176
2099
 
2177
2100
  // Generate faces.
2178
2101
 
2179
- var
2180
- uClosed = opts .closed [0],
2181
- vClosed = opts .closed [1];
2182
-
2183
- var c = 0;
2102
+ let c = 0;
2184
2103
 
2185
- for (var i = 0; i < nu; ++ i)
2104
+ for (let i = 0; i < nu; ++ i)
2186
2105
  {
2187
- var
2188
- i0 = i,
2189
- i1 = i + 1;
2106
+ const i0 = i;
2107
+ let i1 = i + 1;
2190
2108
 
2191
2109
  if (uClosed)
2192
2110
  i1 = i1 % nu;
2193
2111
 
2194
- for (var j = 0; j < nv; ++ j)
2112
+ for (let j = 0; j < nv; ++ j)
2195
2113
  {
2196
- var j0 = j;
2197
- var j1 = j + 1;
2114
+ const j0 = j;
2115
+ let j1 = j + 1;
2198
2116
 
2199
2117
  if (vClosed)
2200
2118
  j1 = j1 % nv;
@@ -2215,87 +2133,19 @@ const sample_default_ = function (mesh, surface, opts)
2215
2133
 
2216
2134
  faces .length = c;
2217
2135
 
2218
- /*
2219
- // Trimming Contours
2220
-
2221
- if (opts .trimmingContours)
2222
- {
2223
- var holes = [ ];
2224
-
2225
- var trimmingContours = opts .trimmingContours;
2226
-
2227
- for (var t = 0, iLength = trimmingContours .length; t < iLength; ++ t)
2228
- {
2229
- var
2230
- trimmingContour = trimmingContours [t],
2231
- hole = [ ];
2232
-
2233
- for (var p = 0, pLength = trimmingContour .length; p < pLength; ++ p)
2234
- {
2235
- var point = trimmingContour [p];
2236
-
2237
- surface .evaluate (tmp1, point .x, point .y);
2238
-
2239
- for (var d = 0; d < dimension; ++ d)
2240
- points .push (tmp1 [d]);
2241
-
2242
- var vertex = new Vector3 (tmp1 [0], tmp1 [1], tmp1 [2]);
2243
-
2244
- vertex .index = c ++;
2245
-
2246
- hole .push (vertex);
2247
- }
2248
-
2249
- holes .push (hole);
2250
- }
2251
-
2252
- var
2253
- contours = [ ],
2254
- triangles = [ ],
2255
- trimmed = [ ];
2256
-
2257
- for (var v = 0, fLength = faces .length; v < fLength; v += 3)
2258
- {
2259
- contours .length = 0;
2260
- triangles .length = 0;
2261
-
2262
- var
2263
- index1 = faces [v] * 3,
2264
- index2 = faces [v + 1] * 3,
2265
- index3 = faces [v + 2] * 3;
2266
-
2267
- var
2268
- vertex1 = new Vector3 (points [index1], points [index1 + 1], points [index1 + 2]),
2269
- vertex2 = new Vector3 (points [index2], points [index2 + 1], points [index2 + 2]),
2270
- vertex3 = new Vector3 (points [index3], points [index3 + 1], points [index3 + 2]);
2271
-
2272
- vertex1 .index = v;
2273
- vertex2 .index = v + 1;
2274
- vertex3 .index = v + 2;
2275
-
2276
- contours .push ([ vertex1, vertex2, vertex3 ], ... holes);
2277
-
2278
- Triangle3 .triangulatePolygon (contours, triangles);
2279
-
2280
- for (var t = 0, tLength = triangles .length; t < tLength; ++ t)
2281
- trimmed .push (triangles [t] .index);
2282
- }
2283
-
2284
- mesh .faces = trimmed;
2285
- }
2286
- */
2287
-
2288
2136
  break;
2289
2137
  }
2290
2138
  default:
2291
- throw new Error("Can only sample contours and surfaces");
2139
+ throw new Error ("Can only sample contours and surfaces.");
2292
2140
  }
2293
2141
 
2294
2142
  return mesh;
2295
- };
2143
+ }
2144
+
2145
+ const sample_default_ = sample;
2296
2146
  ;
2297
2147
 
2298
- /* 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_));
2299
2149
  ;// CONCATENATED MODULE: ./src/lib/nurbs/nurbs.js
2300
2150
 
2301
2151
 
@@ -2619,7 +2469,7 @@ function nurbs (points, degree, knots, weights, boundary, opts)
2619
2469
  return ctor;
2620
2470
  }
2621
2471
 
2622
- nurbs .sample = sample;
2472
+ nurbs .sample = extras_sample;
2623
2473
 
2624
2474
  const nurbs_default_ = nurbs;
2625
2475
  ;
@@ -2719,9 +2569,9 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2719
2569
  if (this .controlPointNode)
2720
2570
  this .controlPointNode .addInterest ("requestRebuild", this);
2721
2571
  },
2722
- getTessellation (numKnots)
2572
+ getTessellation (dimension)
2723
2573
  {
2724
- return NURBS_NURBS .getTessellation (this ._tessellation .getValue (), numKnots - this ._order .getValue ());
2574
+ return NURBS_NURBS .getTessellation (this ._tessellation .getValue (), dimension);
2725
2575
  },
2726
2576
  getClosed (order, knot, weight, controlPointNode)
2727
2577
  {
@@ -2738,6 +2588,10 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2738
2588
  {
2739
2589
  return NURBS_NURBS .getControlPoints (result, closed, order, weights, controlPointNode);
2740
2590
  },
2591
+ getSurface ()
2592
+ {
2593
+ return this .surface;
2594
+ },
2741
2595
  tessellate ()
2742
2596
  {
2743
2597
  if (this ._order .getValue () < 2)
@@ -2751,16 +2605,15 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2751
2605
 
2752
2606
  const
2753
2607
  vertexArray = this .getVertices (),
2608
+ numVertices = vertexArray .length,
2754
2609
  array = [ ];
2755
2610
 
2756
- if (vertexArray .length)
2611
+ if (numVertices)
2757
2612
  {
2758
- const length = vertexArray .length;
2759
-
2760
- for (let i = 0; i < length; i += 8)
2613
+ for (let i = 0; i < numVertices; i += 8)
2761
2614
  array .push (vertexArray [i], vertexArray [i + 1], vertexArray [i + 2]);
2762
2615
 
2763
- array .push (vertexArray [length - 4], vertexArray [length - 3], vertexArray [length - 2]);
2616
+ array .push (vertexArray [numVertices - 4], vertexArray [numVertices - 3], vertexArray [numVertices - 2]);
2764
2617
  }
2765
2618
 
2766
2619
  return array;
@@ -2793,7 +2646,7 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2793
2646
 
2794
2647
  const degree = this ._order .getValue () - 1;
2795
2648
 
2796
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
2649
+ this .surface = (this .surface ?? nurbs_nurbs) ({
2797
2650
  boundary: ["open"],
2798
2651
  degree: [degree],
2799
2652
  knots: [knots],
@@ -2801,20 +2654,20 @@ Object .assign (Object .setPrototypeOf (NurbsCurve .prototype, NURBS_X3DParametr
2801
2654
  debug: false,
2802
2655
  });
2803
2656
 
2804
- this .sampleOptions .resolution [0] = this .getTessellation (knots .length);
2657
+ this .sampleOptions .resolution [0] = this .getTessellation (controlPoints .length);
2658
+ this .sampleOptions .closed = closed;
2805
2659
  this .sampleOptions .haveWeights = !! weights;
2806
2660
 
2807
2661
  const
2808
- mesh = nurbs_nurbs .sample (this .mesh, surface, this .sampleOptions),
2662
+ mesh = nurbs_nurbs .sample (this .mesh, this .surface, this .sampleOptions),
2809
2663
  points = mesh .points,
2664
+ numPoints = points .length - 3,
2810
2665
  vertexArray = this .getVertices ();
2811
2666
 
2812
- for (let i2 = 3, length = points .length; i2 < length; i2 += 3)
2667
+ for (let i = 0; i < numPoints; i += 3)
2813
2668
  {
2814
- const i1 = i2 - 3;
2815
-
2816
- vertexArray .push (points [i1], points [i1 + 1], points [i1 + 2], 1);
2817
- 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);
2818
2671
  }
2819
2672
  },
2820
2673
  dispose ()
@@ -2919,9 +2772,9 @@ function NurbsCurve2D (executionContext)
2919
2772
 
2920
2773
  Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsControlCurveNode .prototype),
2921
2774
  {
2922
- getTessellation (numKnots)
2775
+ getTessellation (dimension)
2923
2776
  {
2924
- return NURBS_NURBS .getTessellation (this ._tessellation .getValue (), numKnots - this ._order .getValue ());
2777
+ return NURBS_NURBS .getTessellation (this ._tessellation .getValue (), dimension);
2925
2778
  },
2926
2779
  getClosed (order, knot, weight, controlPoint)
2927
2780
  {
@@ -2942,12 +2795,8 @@ Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsC
2942
2795
  {
2943
2796
  return NURBS_NURBS .getControlPoints2D (result, closed, order, weights, controlPoint);
2944
2797
  },
2945
- tessellate (type)
2798
+ tessellate (type, array = this .array)
2946
2799
  {
2947
- const array = this .array;
2948
-
2949
- array .length = 0;
2950
-
2951
2800
  if (this ._order .getValue () < 2)
2952
2801
  return array;
2953
2802
 
@@ -2971,7 +2820,7 @@ Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsC
2971
2820
 
2972
2821
  const degree = this ._order .getValue () - 1;
2973
2822
 
2974
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
2823
+ this .surface = (this .surface ?? nurbs_nurbs) ({
2975
2824
  boundary: ["open"],
2976
2825
  degree: [degree],
2977
2826
  knots: [knots],
@@ -2979,39 +2828,39 @@ Object .assign (Object .setPrototypeOf (NurbsCurve2D .prototype, NURBS_X3DNurbsC
2979
2828
  debug: false,
2980
2829
  });
2981
2830
 
2982
- this .sampleOptions .resolution [0] = this .getTessellation (knots .length);
2831
+ this .sampleOptions .resolution [0] = this .getTessellation (controlPoints .length);
2832
+ this .sampleOptions .closed = closed;
2983
2833
  this .sampleOptions .haveWeights = !! weights;
2984
2834
 
2985
2835
  const
2986
- mesh = nurbs_nurbs .sample (this .mesh, surface, this .sampleOptions),
2987
- points = mesh .points;
2836
+ mesh = nurbs_nurbs .sample (this .mesh, this .surface, this .sampleOptions),
2837
+ points = mesh .points,
2838
+ numPoints = points .length;
2988
2839
 
2989
2840
  switch (type)
2990
2841
  {
2991
2842
  case 0:
2992
2843
  {
2993
- for (let i = 0, length = points .length; i < length; i += 2)
2994
- {
2844
+ array .length = 0;
2845
+
2846
+ for (let i = 0; i < numPoints; i += 2)
2995
2847
  array .push (points [i], points [i + 1]);
2996
- }
2997
2848
 
2998
2849
  break;
2999
2850
  }
3000
2851
  case 1:
3001
2852
  {
3002
- for (let i = 0, length = points .length; i < length; i += 2)
3003
- {
2853
+ array .length = 0;
2854
+
2855
+ for (let i = 0; i < numPoints; i += 2)
3004
2856
  array .push (points [i], 0, points [i + 1]);
3005
- }
3006
2857
 
3007
2858
  break;
3008
2859
  }
3009
- case 2:
2860
+ case 2: // Contour2D
3010
2861
  {
3011
- for (let i = 0, length = points .length; i < length; i += 2)
3012
- {
2862
+ for (let i = 0; i < numPoints; i += 2)
3013
2863
  array .push (new (external_X_ITE_X3D_Vector3_default()) (points [i], points [i + 1], 0));
3014
- }
3015
2864
 
3016
2865
  break;
3017
2866
  }
@@ -3046,12 +2895,12 @@ const NurbsCurve2D_default_ = NurbsCurve2D;
3046
2895
  ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .X3DChildNode"
3047
2896
  const external_X_ITE_X3D_X3DChildNode_namespaceObject = __X_ITE_X3D__ .X3DChildNode;
3048
2897
  var external_X_ITE_X3D_X3DChildNode_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_X3DChildNode_namespaceObject);
3049
- ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .OrientationInterpolator"
3050
- const external_X_ITE_X3D_OrientationInterpolator_namespaceObject = __X_ITE_X3D__ .OrientationInterpolator;
3051
- var external_X_ITE_X3D_OrientationInterpolator_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_OrientationInterpolator_namespaceObject);
3052
2898
  ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Rotation4"
3053
2899
  const external_X_ITE_X3D_Rotation4_namespaceObject = __X_ITE_X3D__ .Rotation4;
3054
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);
3055
2904
  ;// CONCATENATED MODULE: ./src/x_ite/Components/NURBS/NurbsOrientationInterpolator.js
3056
2905
  /*******************************************************************************
3057
2906
  *
@@ -3112,7 +2961,6 @@ var external_X_ITE_X3D_Rotation4_default = /*#__PURE__*/__webpack_require__.n(ex
3112
2961
 
3113
2962
 
3114
2963
 
3115
-
3116
2964
  function NurbsOrientationInterpolator (executionContext)
3117
2965
  {
3118
2966
  external_X_ITE_X3D_X3DChildNode_default().call (this, executionContext);
@@ -3121,12 +2969,7 @@ function NurbsOrientationInterpolator (executionContext)
3121
2969
 
3122
2970
  this .addChildObjects ((external_X_ITE_X3D_X3DConstants_default()).inputOutput, "rebuild", new (external_X_ITE_X3D_Fields_default()).SFTime ());
3123
2971
 
3124
- this .interpolator = new (external_X_ITE_X3D_OrientationInterpolator_default()) (executionContext);
3125
- this .knots = [ ];
3126
- this .weights = [ ];
3127
- this .controlPoints = [ ];
3128
- this .mesh = { };
3129
- this .sampleOptions = { resolution: [ 128 ] };
2972
+ this .geometry = new NURBS_NurbsCurve (executionContext);
3130
2973
  }
3131
2974
 
3132
2975
  Object .assign (Object .setPrototypeOf (NurbsOrientationInterpolator .prototype, (external_X_ITE_X3D_X3DChildNode_default()).prototype),
@@ -3135,112 +2978,49 @@ Object .assign (Object .setPrototypeOf (NurbsOrientationInterpolator .prototype,
3135
2978
  {
3136
2979
  external_X_ITE_X3D_X3DChildNode_default().prototype .initialize .call (this);
3137
2980
 
3138
- this ._order .addInterest ("requestRebuild", this);
3139
- this ._knot .addInterest ("requestRebuild", this);
3140
- this ._weight .addInterest ("requestRebuild", this);
3141
- this ._controlPoint .addInterest ("set_controlPoint__", this);
2981
+ this ._set_fraction .addInterest ("set_fraction__", this);
3142
2982
 
3143
- 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);
3144
2987
 
3145
- this ._set_fraction .addFieldInterest (this .interpolator ._set_fraction);
3146
- 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;
3147
2993
 
3148
- this .interpolator .setup ();
2994
+ this .geometry ._rebuild .addInterest ("set_geometry__", this);
2995
+ this .geometry .setup ();
3149
2996
 
3150
- this .set_controlPoint__ ();
2997
+ this .set_geometry__ ();
3151
2998
  },
3152
- set_controlPoint__ ()
2999
+ set_geometry__ ()
3153
3000
  {
3154
- if (this .controlPointNode)
3155
- this .controlPointNode .removeInterest ("requestRebuild", this);
3156
-
3157
- this .controlPointNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DCoordinateNode, this ._controlPoint);
3158
-
3159
- if (this .controlPointNode)
3160
- this .controlPointNode .addInterest ("requestRebuild", this);
3001
+ const surface = this .geometry .getSurface ();
3161
3002
 
3162
- this .requestRebuild ();
3163
- },
3164
- getClosed (order, knot, weight, controlPointNode)
3165
- {
3166
- return NURBS_NURBS .getClosed (order, knot, weight, controlPointNode);
3167
- },
3168
- getKnots (result, closed, order, dimension, knot)
3169
- {
3170
- return NURBS_NURBS .getKnots (result, closed, order, dimension, knot);
3171
- },
3172
- getWeights (result, dimension, weight)
3173
- {
3174
- return NURBS_NURBS .getWeights (result, dimension, weight);
3175
- },
3176
- getControlPoints (result, closed, order, weights, controlPointNode)
3177
- {
3178
- return NURBS_NURBS .getControlPoints (result, closed, order, weights, controlPointNode);
3179
- },
3180
- requestRebuild ()
3181
- {
3182
- this ._rebuild .addEvent ();
3003
+ this .derivative = surface .evaluator (1);
3183
3004
  },
3184
- build ()
3005
+ set_fraction__: (() =>
3185
3006
  {
3186
- if (this ._order .getValue () < 2)
3187
- return;
3188
-
3189
- if (!this .controlPointNode)
3190
- return;
3191
-
3192
- if (this .controlPointNode .getSize () < this ._order .getValue ())
3193
- return;
3194
-
3195
- // Order and dimension are now positive numbers.
3196
-
3197
- const
3198
- closed = this .getClosed (this ._order .getValue (), this ._knot, this ._weight, this .controlPointNode),
3199
- weights = this .getWeights (this .weights, this .controlPointNode .getSize (), this ._weight),
3200
- controlPoints = this .getControlPoints (this .controlPoints, closed, this ._order .getValue (), weights, this .controlPointNode);
3201
-
3202
- // Knots
3203
-
3204
- const
3205
- knots = this .getKnots (this .knots, closed, this ._order .getValue (), this .controlPointNode .getSize (), this ._knot),
3206
- scale = knots .at (-1) - knots [0];
3207
-
3208
- // Initialize NURBS tessellator
3209
-
3210
- const degree = this ._order .getValue () - 1;
3211
-
3212
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
3213
- boundary: ["open"],
3214
- degree: [degree],
3215
- knots: [knots],
3216
- points: controlPoints,
3217
- debug: false,
3218
- });
3219
-
3220
- this .sampleOptions .haveWeights = !! weights;
3221
-
3222
- const
3223
- mesh = nurbs_nurbs .sample (this .mesh, surface, this .sampleOptions),
3224
- points = mesh .points,
3225
- interpolator = this .interpolator;
3226
-
3227
- interpolator ._key .length = 0;
3228
- interpolator ._keyValue .length = 0;
3229
-
3230
3007
  const
3231
3008
  direction = new (external_X_ITE_X3D_Vector3_default()) (),
3232
3009
  rotation = new (external_X_ITE_X3D_Rotation4_default()) ();
3233
3010
 
3234
- for (let i = 0, length = points .length - 3; i < length; i += 3)
3011
+ return function ()
3235
3012
  {
3236
- direction .set (points [i + 3] - points [i + 0],
3237
- points [i + 4] - points [i + 1],
3238
- 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);
3239
3018
 
3240
- interpolator ._key .push (i / (length - 3));
3241
- interpolator ._keyValue. push (rotation .setFromToVec ((external_X_ITE_X3D_Vector3_default()).zAxis, direction));
3242
- }
3243
- },
3019
+ this .derivative (direction, u);
3020
+
3021
+ this ._value_changed = rotation .setFromToVec ((external_X_ITE_X3D_Vector3_default()).zAxis, direction);
3022
+ };
3023
+ })(),
3244
3024
  });
3245
3025
 
3246
3026
  Object .defineProperties (NurbsOrientationInterpolator,
@@ -3265,9 +3045,6 @@ const NurbsOrientationInterpolator_default_ = NurbsOrientationInterpolator;
3265
3045
  ;
3266
3046
 
3267
3047
  /* harmony default export */ const NURBS_NurbsOrientationInterpolator = (external_X_ITE_X3D_Namespace_default().add ("NurbsOrientationInterpolator", NurbsOrientationInterpolator_default_));
3268
- ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Algorithm"
3269
- const external_X_ITE_X3D_Algorithm_namespaceObject = __X_ITE_X3D__ .Algorithm;
3270
- var external_X_ITE_X3D_Algorithm_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Algorithm_namespaceObject);
3271
3048
  ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Triangle3"
3272
3049
  const external_X_ITE_X3D_Triangle3_namespaceObject = __X_ITE_X3D__ .Triangle3;
3273
3050
  var external_X_ITE_X3D_Triangle3_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Triangle3_namespaceObject);
@@ -3374,13 +3151,11 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3374
3151
  },
3375
3152
  set_controlPoint__ ()
3376
3153
  {
3377
- if (this .controlPointNode)
3378
- this .controlPointNode .removeInterest ("requestRebuild", this);
3154
+ this .controlPointNode ?.removeInterest ("requestRebuild", this);
3379
3155
 
3380
3156
  this .controlPointNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DCoordinateNode, this ._controlPoint);
3381
3157
 
3382
- if (this .controlPointNode)
3383
- this .controlPointNode .addInterest ("requestRebuild", this);
3158
+ this .controlPointNode ?.addInterest ("requestRebuild", this);
3384
3159
  },
3385
3160
  setTessellationScale (value)
3386
3161
  {
@@ -3388,13 +3163,13 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3388
3163
 
3389
3164
  this .requestRebuild ();
3390
3165
  },
3391
- getUTessellation (numKnots)
3166
+ getUTessellation ()
3392
3167
  {
3393
- 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);
3394
3169
  },
3395
- getVTessellation (numKnots)
3170
+ getVTessellation (numWeights)
3396
3171
  {
3397
- 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);
3398
3173
  },
3399
3174
  getUClosed (uOrder, uDimension, vDimension, uKnot, weight, controlPointNode)
3400
3175
  {
@@ -3422,10 +3197,12 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3422
3197
  {
3423
3198
  return NURBS_NURBS .getUVControlPoints (result, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, weights, controlPointNode);
3424
3199
  },
3425
- getTrimmingContours ()
3200
+ getSurface ()
3426
3201
  {
3427
- return undefined;
3202
+ return this .surface;
3428
3203
  },
3204
+ trimSurface ()
3205
+ { },
3429
3206
  build ()
3430
3207
  {
3431
3208
  if (this ._uOrder .getValue () < 2)
@@ -3470,7 +3247,7 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3470
3247
  uDegree = this ._uOrder .getValue () - 1,
3471
3248
  vDegree = this ._vOrder .getValue () - 1;
3472
3249
 
3473
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
3250
+ this .surface = (this .surface ?? nurbs_nurbs) ({
3474
3251
  boundary: ["open", "open"],
3475
3252
  degree: [uDegree, vDegree],
3476
3253
  knots: [uKnots, vKnots],
@@ -3480,115 +3257,135 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3480
3257
 
3481
3258
  const sampleOptions = this .sampleOptions;
3482
3259
 
3483
- sampleOptions .resolution [0] = this .getUTessellation (uKnots .length);
3484
- sampleOptions .resolution [1] = this .getVTessellation (vKnots .length);
3485
- sampleOptions .closed [0] = uClosed;
3486
- sampleOptions .closed [1] = vClosed;
3487
- sampleOptions .haveWeights = !! weights;
3488
- 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;
3489
3265
 
3490
3266
  const
3491
- mesh = nurbs_nurbs .sample (this .mesh, surface, sampleOptions),
3267
+ mesh = nurbs_nurbs .sample (this .mesh, this .surface, sampleOptions),
3492
3268
  faces = mesh .faces,
3493
3269
  points = mesh .points,
3494
3270
  vertexArray = this .getVertices ();
3495
3271
 
3496
- for (let i = 0, length = faces .length; i < length; ++ i)
3272
+ for (const face of faces)
3497
3273
  {
3498
- const index = faces [i] * 3;
3274
+ const index = face * 3;
3499
3275
 
3500
3276
  vertexArray .push (points [index], points [index + 1], points [index + 2], 1);
3501
3277
  }
3502
3278
 
3503
3279
  this .buildNurbsTexCoords (uClosed, vClosed, this ._uOrder .getValue (), this ._vOrder .getValue (), uKnots, vKnots, this ._uDimension .getValue (), this ._vDimension .getValue ());
3280
+
3504
3281
  this .generateNormals (faces, points);
3282
+ this .trimSurface (uKnots, vKnots);
3505
3283
  this .setSolid (this ._solid .getValue ());
3506
3284
  this .setCCW (true);
3507
3285
  },
3508
- buildNurbsTexCoords: (() =>
3286
+ buildNurbsTexCoords (uClosed, vClosed, uOrder, vOrder, uKnots, vKnots, uDimension, vDimension)
3509
3287
  {
3510
- const
3511
- defaultTexKnots = [0, 0, 5, 5],
3512
- defaultTexControlPoints = [[[0, 0, 0, 1], [0, 1, 0, 1]], [[1, 0, 0, 1], [1, 1, 0, 1]]];
3288
+ const texCoordArray = this .getTexCoords ();
3513
3289
 
3514
- return function (uClosed, vClosed, uOrder, vOrder, uKnots, vKnots, uDimension, vDimension)
3290
+ this .getMultiTexCoords () .push (texCoordArray);
3291
+
3292
+ if (this .texCoordNode && this .texCoordNode .getSize () <= uDimension * vDimension)
3515
3293
  {
3516
- const sampleOptions = this .sampleOptions;
3517
-
3518
- if (this .texCoordNode && this .texCoordNode .getSize () === uDimension * vDimension)
3519
- {
3520
- var
3521
- texUDegree = uOrder - 1,
3522
- texVDegree = vOrder - 1,
3523
- texUKnots = uKnots,
3524
- texVKnots = vKnots,
3525
- texControlPoints = this .getTexControlPoints (this .texControlPoints, uClosed, vClosed, uOrder, vOrder, uDimension, vDimension, this .texCoordNode);
3526
- }
3527
- else if (this .nurbsTexCoordNode && this .nurbsTexCoordNode .isValid ())
3528
- {
3529
- var
3530
- node = this .nurbsTexCoordNode,
3531
- texUDegree = node ._uOrder .getValue () - 1,
3532
- texVDegree = node ._vOrder .getValue () - 1,
3533
- texUKnots = this .getKnots (this .texUKnots, false, node ._uOrder .getValue (), node ._uDimension .getValue (), node ._uKnot),
3534
- texVKnots = this .getKnots (this .texVKnots, false, node ._vOrder .getValue (), node ._vDimension .getValue (), node ._vKnot),
3535
- texWeights = this .getUVWeights (this .texWeights, node ._uDimension .getValue (), node ._vDimension .getValue (), node ._weight);
3536
- texControlPoints = node .getControlPoints (texWeights);
3537
- }
3538
- else
3539
- {
3540
- var
3541
- texUDegree = 1,
3542
- texVDegree = 1,
3543
- texUKnots = defaultTexKnots,
3544
- texVKnots = defaultTexKnots,
3545
- texControlPoints = defaultTexControlPoints;
3546
- }
3547
-
3548
- const texSurface = this .texSurface = (this .texSurface || nurbs_nurbs) ({
3549
- boundary: ["open", "open"],
3550
- degree: [texUDegree, texVDegree],
3551
- knots: [texUKnots, texVKnots],
3552
- points: texControlPoints,
3553
- });
3554
-
3555
- sampleOptions .closed [0] = false;
3556
- sampleOptions .closed [1] = false;
3557
- sampleOptions .haveWeights = false;
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);
3558
3300
 
3301
+ this .createNurbsTexCoords (texUDegree, texVDegree, texUKnots, texVKnots, texControlPoints, texCoordArray);
3302
+ }
3303
+ else if (this .nurbsTexCoordNode ?.isValid ())
3304
+ {
3559
3305
  const
3560
- texMesh = nurbs_nurbs .sample (this .texMesh, texSurface, sampleOptions),
3561
- faces = texMesh .faces,
3562
- points = texMesh .points,
3563
- texCoordArray = this .getTexCoords ();
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);
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]]];
3564
3326
 
3565
- this .getMultiTexCoords () .push (texCoordArray);
3327
+ return function (texCoordArray)
3328
+ {
3329
+ // Create texture coordinates in the unit square.
3566
3330
 
3567
- for (let i = 0, length = faces .length; i < length; ++ i)
3568
- {
3569
- const index = faces [i] * 4;
3331
+ const
3332
+ texUDegree = 1,
3333
+ texVDegree = 1,
3334
+ texUKnots = defaultTexKnots,
3335
+ texVKnots = defaultTexKnots,
3336
+ texControlPoints = defaultTexControlPoints;
3570
3337
 
3571
- texCoordArray .push (points [index], points [index + 1], points [index + 2], points [index + 3]);
3572
- }
3338
+ return this .createNurbsTexCoords (texUDegree, texVDegree, texUKnots, texVKnots, texControlPoints, texCoordArray);
3573
3339
  };
3574
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
+ });
3349
+
3350
+ const sampleOptions = this .sampleOptions;
3351
+
3352
+ sampleOptions .closed [0] = false;
3353
+ sampleOptions .closed [1] = false;
3354
+ sampleOptions .haveWeights = false;
3355
+
3356
+ const
3357
+ texMesh = nurbs_nurbs .sample (this .texMesh, this .texSurface, sampleOptions),
3358
+ faces = texMesh .faces,
3359
+ points = texMesh .points;
3360
+
3361
+ for (const face of faces)
3362
+ {
3363
+ const i = face * 4;
3364
+
3365
+ texCoordArray .push (points [i], points [i + 1], points [i + 2], points [i + 3]);
3366
+ }
3367
+
3368
+ return texCoordArray;
3369
+ },
3575
3370
  generateNormals (faces, points)
3576
3371
  {
3577
3372
  const
3578
3373
  normals = this .createNormals (faces, points),
3579
3374
  normalArray = this .getNormals ();
3580
3375
 
3581
- for (const normal of normals)
3582
- normalArray .push (normal .x, normal .y, normal .z);
3376
+ for (const { x, y, z } of normals)
3377
+ normalArray .push (x, y, z);
3583
3378
  },
3584
3379
  createNormals (faces, points)
3585
3380
  {
3381
+ // TODO: handle uClosed, vClosed.
3382
+
3586
3383
  const
3587
3384
  normalIndex = new Map (),
3588
3385
  normals = this .createFaceNormals (faces, points),
3589
- length = faces .length;
3386
+ numFaces = faces .length;
3590
3387
 
3591
- for (let i = 0; i < length; ++ i)
3388
+ for (let i = 0; i < numFaces; ++ i)
3592
3389
  {
3593
3390
  const index = faces [i];
3594
3391
 
@@ -3612,10 +3409,10 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3612
3409
  return function (faces, points)
3613
3410
  {
3614
3411
  const
3615
- normals = this .faceNormals || [ ],
3616
- length = faces .length;
3412
+ normals = this .faceNormals ?? [ ],
3413
+ numFaces = faces .length;
3617
3414
 
3618
- for (let i = 0; i < length; i += 3)
3415
+ for (let i = 0; i < numFaces; i += 3)
3619
3416
  {
3620
3417
  const
3621
3418
  index1 = faces [i] * 3,
@@ -3626,14 +3423,14 @@ Object .assign (Object .setPrototypeOf (X3DNurbsSurfaceGeometryNode .prototype,
3626
3423
  v2 .set (points [index2], points [index2 + 1], points [index2 + 2]);
3627
3424
  v3 .set (points [index3], points [index3 + 1], points [index3 + 2]);
3628
3425
 
3629
- 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()) ());
3630
3427
 
3631
3428
  normals [i] = normal;
3632
3429
  normals [i + 1] = normal;
3633
3430
  normals [i + 2] = normal;
3634
3431
  }
3635
3432
 
3636
- normals .length = length;
3433
+ normals .length = numFaces;
3637
3434
 
3638
3435
  return normals;
3639
3436
  };
@@ -3740,9 +3537,6 @@ const NurbsPatchSurface_default_ = NurbsPatchSurface;
3740
3537
  ;
3741
3538
 
3742
3539
  /* harmony default export */ const NURBS_NurbsPatchSurface = (external_X_ITE_X3D_Namespace_default().add ("NurbsPatchSurface", NurbsPatchSurface_default_));
3743
- ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .PositionInterpolator"
3744
- const external_X_ITE_X3D_PositionInterpolator_namespaceObject = __X_ITE_X3D__ .PositionInterpolator;
3745
- var external_X_ITE_X3D_PositionInterpolator_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_PositionInterpolator_namespaceObject);
3746
3540
  ;// CONCATENATED MODULE: ./src/x_ite/Components/NURBS/NurbsPositionInterpolator.js
3747
3541
  /*******************************************************************************
3748
3542
  *
@@ -3808,14 +3602,7 @@ function NurbsPositionInterpolator (executionContext)
3808
3602
 
3809
3603
  this .addType ((external_X_ITE_X3D_X3DConstants_default()).NurbsPositionInterpolator);
3810
3604
 
3811
- this .addChildObjects ((external_X_ITE_X3D_X3DConstants_default()).inputOutput, "rebuild", new (external_X_ITE_X3D_Fields_default()).SFTime ());
3812
-
3813
- this .interpolator = new (external_X_ITE_X3D_PositionInterpolator_default()) (executionContext);
3814
- this .knots = [ ];
3815
- this .weights = [ ];
3816
- this .controlPoints = [ ];
3817
- this .mesh = { };
3818
- this .sampleOptions = { resolution: [ 128 ] };
3605
+ this .geometry = new NURBS_NurbsCurve (executionContext);
3819
3606
  }
3820
3607
 
3821
3608
  Object .assign (Object .setPrototypeOf (NurbsPositionInterpolator .prototype, (external_X_ITE_X3D_X3DChildNode_default()).prototype),
@@ -3824,104 +3611,38 @@ Object .assign (Object .setPrototypeOf (NurbsPositionInterpolator .prototype, (e
3824
3611
  {
3825
3612
  external_X_ITE_X3D_X3DChildNode_default().prototype .initialize .call (this);
3826
3613
 
3827
- this ._order .addInterest ("requestRebuild", this);
3828
- this ._knot .addInterest ("requestRebuild", this);
3829
- this ._weight .addInterest ("requestRebuild", this);
3830
- this ._controlPoint .addInterest ("set_controlPoint__", this);
3831
-
3832
- this ._rebuild .addInterest ("build", this);
3833
-
3834
- this ._set_fraction .addFieldInterest (this .interpolator ._set_fraction);
3835
- this .interpolator ._value_changed .addFieldInterest (this ._value_changed);
3836
-
3837
- this .interpolator .setup ();
3838
-
3839
- this .set_controlPoint__ ();
3840
- },
3841
- set_controlPoint__ ()
3842
- {
3843
- if (this .controlPointNode)
3844
- this .controlPointNode .removeInterest ("requestRebuild", this);
3614
+ this ._set_fraction .addInterest ("set_fraction__", this);
3845
3615
 
3846
- 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);
3847
3620
 
3848
- if (this .controlPointNode)
3849
- 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;
3850
3626
 
3851
- this .requestRebuild ();
3852
- },
3853
- getClosed (order, knot, weight, controlPointNode)
3854
- {
3855
- return NURBS_NURBS .getClosed (order, knot, weight, controlPointNode);
3856
- },
3857
- getKnots (result, closed, order, dimension, knot)
3858
- {
3859
- return NURBS_NURBS .getKnots (result, closed, order, dimension, knot);
3860
- },
3861
- getWeights (result, dimension, weight)
3862
- {
3863
- return NURBS_NURBS .getWeights (result, dimension, weight);
3864
- },
3865
- getControlPoints (result, closed, order, weights, controlPointNode)
3866
- {
3867
- return NURBS_NURBS .getControlPoints (result, closed, order, weights, controlPointNode);
3868
- },
3869
- requestRebuild ()
3870
- {
3871
- this ._rebuild .addEvent ();
3627
+ this .geometry .setup ();
3872
3628
  },
3873
- build ()
3629
+ set_fraction__: (() =>
3874
3630
  {
3875
- if (this ._order .getValue () < 2)
3876
- return;
3877
-
3878
- if (!this .controlPointNode)
3879
- return;
3880
-
3881
- if (this .controlPointNode .getSize () < this ._order .getValue ())
3882
- return;
3883
-
3884
- // Order and dimension are now positive numbers.
3885
-
3886
- const
3887
- closed = this .getClosed (this ._order .getValue (), this ._knot, this ._weight, this .controlPointNode),
3888
- weights = this .getWeights (this .weights, this .controlPointNode .getSize (), this ._weight),
3889
- controlPoints = this .getControlPoints (this .controlPoints, closed, this ._order .getValue (), weights, this .controlPointNode);
3890
-
3891
- // Knots
3892
-
3893
- const
3894
- knots = this .getKnots (this .knots, closed, this ._order .getValue (), this .controlPointNode .getSize (), this ._knot),
3895
- scale = knots .at (-1) - knots [0];
3896
-
3897
- // Initialize NURBS tessellator
3898
-
3899
- const degree = this ._order .getValue () - 1;
3631
+ const value = new (external_X_ITE_X3D_Vector3_default()) ();
3900
3632
 
3901
- const surface = this .surface = (this .surface || nurbs_nurbs) ({
3902
- boundary: ["open"],
3903
- degree: [degree],
3904
- knots: [knots],
3905
- points: controlPoints,
3906
- debug: false,
3907
- });
3908
-
3909
- this .sampleOptions .haveWeights = !! weights;
3910
-
3911
- const
3912
- mesh = nurbs_nurbs .sample (this .mesh, surface, this .sampleOptions),
3913
- points = mesh .points,
3914
- 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);
3915
3640
 
3916
- interpolator ._key .length = 0;
3917
- interpolator ._keyValue .length = 0;
3641
+ surface .evaluate (value, u);
3918
3642
 
3919
- for (let i = 0, length = points .length; i < length; i += 3)
3920
- {
3921
- interpolator ._key .push (i / (length - 3));
3922
- interpolator ._keyValue .push (new (external_X_ITE_X3D_Fields_default()).SFVec3f (points [i], points [i + 1], points [i + 2]));
3923
- }
3924
- },
3643
+ this ._value_changed = value;
3644
+ };
3645
+ })(),
3925
3646
  });
3926
3647
 
3927
3648
  Object .defineProperties (NurbsPositionInterpolator,
@@ -4121,91 +3842,6 @@ const NurbsSet_default_ = NurbsSet;
4121
3842
  ;
4122
3843
 
4123
3844
  /* harmony default export */ const NURBS_NurbsSet = (external_X_ITE_X3D_Namespace_default().add ("NurbsSet", NurbsSet_default_));
4124
- ;// CONCATENATED MODULE: external "__X_ITE_X3D__ .Line3"
4125
- const external_X_ITE_X3D_Line3_namespaceObject = __X_ITE_X3D__ .Line3;
4126
- var external_X_ITE_X3D_Line3_default = /*#__PURE__*/__webpack_require__.n(external_X_ITE_X3D_Line3_namespaceObject);
4127
- ;// CONCATENATED MODULE: ./src/standard/Math/Geometry/Triangle2.js
4128
- /*******************************************************************************
4129
- *
4130
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4131
- *
4132
- * Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011 - 2022.
4133
- *
4134
- * All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
4135
- *
4136
- * The copyright notice above does not evidence any actual of intended
4137
- * publication of such source code, and is an unpublished work by create3000.
4138
- * This material contains CONFIDENTIAL INFORMATION that is the property of
4139
- * create3000.
4140
- *
4141
- * No permission is granted to copy, distribute, or create derivative works from
4142
- * the contents of this software, in whole or in part, without the prior written
4143
- * permission of create3000.
4144
- *
4145
- * NON-MILITARY USE ONLY
4146
- *
4147
- * All create3000 software are effectively free software with a non-military use
4148
- * restriction. It is free. Well commented source is provided. You may reuse the
4149
- * source in any way you please with the exception anything that uses it must be
4150
- * marked to indicate is contains 'non-military use only' components.
4151
- *
4152
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4153
- *
4154
- * Copyright 2011 - 2022, Holger Seelig <holger.seelig@yahoo.de>.
4155
- *
4156
- * This file is part of the X_ITE Project.
4157
- *
4158
- * X_ITE is free software: you can redistribute it and/or modify it under the
4159
- * terms of the GNU General Public License version 3 only, as published by the
4160
- * Free Software Foundation.
4161
- *
4162
- * X_ITE is distributed in the hope that it will be useful, but WITHOUT ANY
4163
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
4164
- * A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
4165
- * details (a copy is included in the LICENSE file that accompanied this code).
4166
- *
4167
- * You should have received a copy of the GNU General Public License version 3
4168
- * along with X_ITE. If not, see <https://www.gnu.org/licenses/gpl.html> for a
4169
- * copy of the GPLv3 License.
4170
- *
4171
- * For Silvio, Joy and Adi.
4172
- *
4173
- ******************************************************************************/
4174
-
4175
- const Triangle2 =
4176
- {
4177
- isPointInTriangle (a, b, c, point)
4178
- {
4179
- // https://en.wikipedia.org/wiki/Barycentric_coordinate_system
4180
-
4181
- const det = (b.y - c.y) * (a.x - c.x) + (c.x - b.x) * (a.y - c.y);
4182
-
4183
- if (det == 0)
4184
- return false;
4185
-
4186
- const u = ((b.y - c.y) * (point .x - c.x) + (c.x - b.x) * (point .y - c.y)) / det;
4187
-
4188
- if (u < 0 || u > 1)
4189
- return false;
4190
-
4191
- const v = ((c.y - a.y) * (point .x - c.x) + (a.x - c.x) * (point .y - c.y)) / det;
4192
-
4193
- if (v < 0 || v > 1)
4194
- return false;
4195
-
4196
- const t = 1 - u - v;
4197
-
4198
- if (t < 0 || t > 1)
4199
- return false;
4200
-
4201
- return true;
4202
- },
4203
- };
4204
-
4205
- const Triangle2_default_ = Triangle2;
4206
- ;
4207
-
4208
- /* harmony default export */ const Geometry_Triangle2 = (external_X_ITE_X3D_Namespace_default().add ("Triangle2", Triangle2_default_));
4209
3845
  ;// CONCATENATED MODULE: ./src/x_ite/Components/NURBS/NurbsSurfaceInterpolator.js
4210
3846
  /*******************************************************************************
4211
3847
  *
@@ -4278,6 +3914,8 @@ Object .assign (Object .setPrototypeOf (NurbsSurfaceInterpolator .prototype, (ex
4278
3914
  {
4279
3915
  initialize ()
4280
3916
  {
3917
+ external_X_ITE_X3D_X3DChildNode_default().prototype .initialize .call (this);
3918
+
4281
3919
  this ._set_fraction .addInterest ("set_fraction__", this);
4282
3920
 
4283
3921
  this ._uOrder .addFieldInterest (this .geometry ._uOrder);
@@ -4289,8 +3927,8 @@ Object .assign (Object .setPrototypeOf (NurbsSurfaceInterpolator .prototype, (ex
4289
3927
  this ._weight .addFieldInterest (this .geometry ._weight);
4290
3928
  this ._controlPoint .addFieldInterest (this .geometry ._controlPoint);
4291
3929
 
4292
- this .geometry ._uTessellation = 128;
4293
- this .geometry ._vTessellation = 128;
3930
+ this .geometry ._uTessellation = 1;
3931
+ this .geometry ._vTessellation = 1;
4294
3932
  this .geometry ._uOrder = this ._uOrder;
4295
3933
  this .geometry ._vOrder = this ._vOrder;
4296
3934
  this .geometry ._uDimension = this ._uDimension;
@@ -4300,56 +3938,43 @@ Object .assign (Object .setPrototypeOf (NurbsSurfaceInterpolator .prototype, (ex
4300
3938
  this .geometry ._weight = this ._weight;
4301
3939
  this .geometry ._controlPoint = this ._controlPoint;
4302
3940
 
3941
+ this .geometry ._rebuild .addInterest ("set_geometry__", this);
4303
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]);
4304
3952
  },
4305
3953
  set_fraction__: (() =>
4306
3954
  {
4307
3955
  const
4308
- a = new (external_X_ITE_X3D_Vector3_default()) (),
4309
- b = new (external_X_ITE_X3D_Vector3_default()) (),
4310
- c = new (external_X_ITE_X3D_Vector3_default()) (),
4311
- point = new (external_X_ITE_X3D_Vector3_default()) (),
4312
- line = new (external_X_ITE_X3D_Line3_default()) ((external_X_ITE_X3D_Vector3_default()).Zero, (external_X_ITE_X3D_Vector3_default()).zAxis),
4313
- 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()) ();
4314
3959
 
4315
3960
  return function ()
4316
3961
  {
4317
3962
  const
4318
- fraction = this ._set_fraction .getValue (),
4319
- texCoordsArray = this .geometry .getTexCoords (),
4320
- normalArray = this .geometry .getNormals (),
4321
- verticesArray = this .geometry .getVertices ();
4322
-
4323
- for (let i4 = 0, i3 = 0, length = texCoordsArray .length; i4 < length; i4 += 12, i3 += 9)
4324
- {
4325
- a .set (texCoordsArray [i4 + 0], texCoordsArray [i4 + 1], 0);
4326
- b .set (texCoordsArray [i4 + 4], texCoordsArray [i4 + 5], 0);
4327
- c .set (texCoordsArray [i4 + 7], texCoordsArray [i4 + 9], 0);
4328
-
4329
- if (Geometry_Triangle2 .isPointInTriangle (a, b, c, fraction))
4330
- {
4331
- line .set (point .set (fraction .x, fraction .y, 0), (external_X_ITE_X3D_Vector3_default()).zAxis);
4332
-
4333
- if (line .intersectsTriangle (a, b, c, uvt))
4334
- {
4335
- const
4336
- u = uvt .u,
4337
- v = uvt .v,
4338
- t = uvt .t;
4339
-
4340
- const normal = new (external_X_ITE_X3D_Vector3_default()) (t * normalArray [i3 + 0] + u * normalArray [i3 + 3] + v * normalArray [i3 + 6],
4341
- t * normalArray [i3 + 1] + u * normalArray [i3 + 4] + v * normalArray [i3 + 7],
4342
- t * normalArray [i3 + 2] + u * normalArray [i3 + 5] + v * normalArray [i3 + 8]);
4343
-
4344
- const position = new (external_X_ITE_X3D_Vector3_default()) (t * verticesArray [i4 + 0] + u * verticesArray [i4 + 4] + v * verticesArray [i4 + 8],
4345
- t * verticesArray [i4 + 1] + u * verticesArray [i4 + 5] + v * verticesArray [i4 + 9],
4346
- t * verticesArray [i4 + 2] + u * verticesArray [i4 + 6] + v * verticesArray [i4 + 10]);
4347
-
4348
- this ._normal_changed = normal;
4349
- this ._position_changed = position;
4350
- }
4351
- }
4352
- }
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;
4353
3978
  };
4354
3979
  })(),
4355
3980
  });
@@ -4478,13 +4103,11 @@ Object .assign (Object .setPrototypeOf (NurbsSweptSurface .prototype, NURBS_X3DP
4478
4103
  },
4479
4104
  set_crossSectionCurve__ ()
4480
4105
  {
4481
- if (this .crossSectionCurveNode)
4482
- this .crossSectionCurveNode .removeInterest ("requestRebuild", this);
4106
+ this .crossSectionCurveNode ?.removeInterest ("requestRebuild", this);
4483
4107
 
4484
4108
  this .crossSectionCurveNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DNurbsControlCurveNode, this ._crossSectionCurve);
4485
4109
 
4486
- if (this .crossSectionCurveNode)
4487
- this .crossSectionCurveNode .addInterest ("requestRebuild", this);
4110
+ this .crossSectionCurveNode ?.addInterest ("requestRebuild", this);
4488
4111
  },
4489
4112
  set_trajectoryCurve__ ()
4490
4113
  {
@@ -4511,6 +4134,7 @@ Object .assign (Object .setPrototypeOf (NurbsSweptSurface .prototype, NURBS_X3DP
4511
4134
 
4512
4135
  this .getColors () .assign (extrusion .getColors ());
4513
4136
  this .getTexCoords () .assign (extrusion .getTexCoords ());
4137
+ this .getTangents () .assign (extrusion .getTangents ());
4514
4138
  this .getNormals () .assign (extrusion .getNormals ());
4515
4139
  this .getVertices () .assign (extrusion .getVertices ());
4516
4140
 
@@ -4518,10 +4142,12 @@ Object .assign (Object .setPrototypeOf (NurbsSweptSurface .prototype, NURBS_X3DP
4518
4142
 
4519
4143
  if (!this ._ccw .getValue ())
4520
4144
  {
4521
- const normals = this .getNormals ();
4145
+ const
4146
+ normalsArray = this .getNormals (),
4147
+ numNormals = normalsArray .length;
4522
4148
 
4523
- for (let i = 0, length = normals .length; i < length; ++ i)
4524
- normals [i] = -normals [i];
4149
+ for (let i = 0; i < numNormals; ++ i)
4150
+ normalsArray [i] *= -1;
4525
4151
  }
4526
4152
 
4527
4153
  this .setSolid (this ._solid .getValue ());
@@ -4643,23 +4269,19 @@ Object .assign (Object .setPrototypeOf (NurbsSwungSurface .prototype, NURBS_X3DP
4643
4269
  },
4644
4270
  set_profileCurve__ ()
4645
4271
  {
4646
- if (this .profileCurveNode)
4647
- this .profileCurveNode .removeInterest ("requestRebuild", this);
4272
+ this .profileCurveNode ?.removeInterest ("requestRebuild", this);
4648
4273
 
4649
4274
  this .profileCurveNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DNurbsControlCurveNode, this ._profileCurve);
4650
4275
 
4651
- if (this .profileCurveNode)
4652
- this .profileCurveNode .addInterest ("requestRebuild", this);
4276
+ this .profileCurveNode ?.addInterest ("requestRebuild", this);
4653
4277
  },
4654
4278
  set_trajectoryCurve__ ()
4655
4279
  {
4656
- if (this .trajectoryCurveNode)
4657
- this .trajectoryCurveNode .removeInterest ("requestRebuild", this);
4280
+ this .trajectoryCurveNode ?.removeInterest ("requestRebuild", this);
4658
4281
 
4659
4282
  this .trajectoryCurveNode = external_X_ITE_X3D_X3DCast_default() ((external_X_ITE_X3D_X3DConstants_default()).X3DNurbsControlCurveNode, this ._trajectoryCurve);
4660
4283
 
4661
- if (this .trajectoryCurveNode)
4662
- this .trajectoryCurveNode .addInterest ("requestRebuild", this);
4284
+ this .trajectoryCurveNode ?.addInterest ("requestRebuild", this);
4663
4285
  },
4664
4286
  build ()
4665
4287
  {
@@ -4678,6 +4300,7 @@ Object .assign (Object .setPrototypeOf (NurbsSwungSurface .prototype, NURBS_X3DP
4678
4300
 
4679
4301
  this .getColors () .assign (extrusion .getColors ());
4680
4302
  this .getTexCoords () .assign (extrusion .getTexCoords ());
4303
+ this .getTangents () .assign (extrusion .getTangents ());
4681
4304
  this .getNormals () .assign (extrusion .getNormals ());
4682
4305
  this .getVertices () .assign (extrusion .getVertices ());
4683
4306
 
@@ -4685,10 +4308,12 @@ Object .assign (Object .setPrototypeOf (NurbsSwungSurface .prototype, NURBS_X3DP
4685
4308
 
4686
4309
  if (!this ._ccw .getValue ())
4687
4310
  {
4688
- const normals = this .getNormals ();
4311
+ const
4312
+ normalsArray = this .getNormals (),
4313
+ numNormals = normalsArray .length;
4689
4314
 
4690
- for (let i = 0, length = normals .length; i < length; ++ i)
4691
- normals [i] = -normals [i];
4315
+ for (let i = 0; i < numNormals; ++ i)
4316
+ normalsArray [i] *= -1;
4692
4317
  }
4693
4318
 
4694
4319
  this .setSolid (this ._solid .getValue ());
@@ -4777,7 +4402,7 @@ function NurbsTextureCoordinate (executionContext)
4777
4402
 
4778
4403
  this .addType ((external_X_ITE_X3D_X3DConstants_default()).NurbsTextureCoordinate);
4779
4404
 
4780
- this .controlPoints = [ ];
4405
+ this .array = [ ];
4781
4406
  }
4782
4407
 
4783
4408
  Object .assign (Object .setPrototypeOf (NurbsTextureCoordinate .prototype, (external_X_ITE_X3D_X3DNode_default()).prototype),
@@ -4785,28 +4410,31 @@ Object .assign (Object .setPrototypeOf (NurbsTextureCoordinate .prototype, (exte
4785
4410
  getControlPoints (texWeights)
4786
4411
  {
4787
4412
  const
4788
- controlPointArray = this ._controlPoint .getValue (),
4789
- controlPoints = this .controlPoints;
4413
+ uDimension = this ._uDimension .getValue (),
4414
+ vDimension = this ._vDimension .getValue (),
4415
+ controlPoints = this ._controlPoint .getValue (),
4416
+ array = this .array;
4790
4417
 
4791
- for (let u = 0, uDimension = this ._uDimension .getValue (); u < uDimension; ++ u)
4418
+ for (let u = 0; u < uDimension; ++ u)
4792
4419
  {
4793
- let cp = controlPoints [u];
4794
-
4795
- if (!cp)
4796
- cp = controlPoints [u] = [ ];
4420
+ const cp = array [u] ??= [ ];
4797
4421
 
4798
- for (let v = 0, vDimension = this ._vDimension .getValue (); v < vDimension; ++ v)
4422
+ for (let v = 0; v < vDimension; ++ v)
4799
4423
  {
4800
4424
  const
4801
4425
  index = v * uDimension + u,
4802
- p = cp [v] || new (external_X_ITE_X3D_Vector4_default()) (),
4426
+ p = cp [v] ?? new (external_X_ITE_X3D_Vector4_default()) (),
4803
4427
  i = index * 2;
4804
4428
 
4805
- 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);
4806
4430
  }
4431
+
4432
+ cp .length = vDimension;
4807
4433
  }
4808
4434
 
4809
- return controlPoints;
4435
+ array .length = uDimension;
4436
+
4437
+ return array;
4810
4438
  },
4811
4439
  isValid ()
4812
4440
  {
@@ -4853,6 +4481,148 @@ const NurbsTextureCoordinate_default_ = NurbsTextureCoordinate;
4853
4481
  ;
4854
4482
 
4855
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);
4856
4626
  ;// CONCATENATED MODULE: ./src/x_ite/Components/NURBS/NurbsTrimmedSurface.js
4857
4627
  /*******************************************************************************
4858
4628
  *
@@ -4909,6 +4679,10 @@ const NurbsTextureCoordinate_default_ = NurbsTextureCoordinate;
4909
4679
 
4910
4680
 
4911
4681
 
4682
+
4683
+
4684
+
4685
+
4912
4686
  function NurbsTrimmedSurface (executionContext)
4913
4687
  {
4914
4688
  NURBS_X3DNurbsSurfaceGeometryNode .call (this, executionContext);
@@ -4916,6 +4690,7 @@ function NurbsTrimmedSurface (executionContext)
4916
4690
  this .addType ((external_X_ITE_X3D_X3DConstants_default()).NurbsTrimmedSurface);
4917
4691
 
4918
4692
  this .trimmingContourNodes = [ ];
4693
+ this .trimmingContours = [ ];
4919
4694
  }
4920
4695
 
4921
4696
  Object .assign (Object .setPrototypeOf (NurbsTrimmedSurface .prototype, NURBS_X3DNurbsSurfaceGeometryNode .prototype),
@@ -4953,6 +4728,9 @@ Object .assign (Object .setPrototypeOf (NurbsTrimmedSurface .prototype, NURBS_X3
4953
4728
  {
4954
4729
  const trimmingContourNodes = this .trimmingContourNodes;
4955
4730
 
4731
+ for (const trimmingContourNode of trimmingContourNodes)
4732
+ trimmingContourNode .removeInterest ("requestRebuild", this);
4733
+
4956
4734
  trimmingContourNodes .length = 0;
4957
4735
 
4958
4736
  for (const node of this ._trimmingContour)
@@ -4962,18 +4740,275 @@ Object .assign (Object .setPrototypeOf (NurbsTrimmedSurface .prototype, NURBS_X3
4962
4740
  if (trimmingContourNode)
4963
4741
  trimmingContourNodes .push (trimmingContourNode);
4964
4742
  }
4743
+
4744
+ for (const trimmingContourNode of trimmingContourNodes)
4745
+ trimmingContourNode .addInterest ("requestRebuild", this);
4746
+ },
4747
+ getTrimmingContours (offset, scale, trimmingContours)
4748
+ {
4749
+ for (const trimmingContourNode of this .trimmingContourNodes)
4750
+ trimmingContourNode .addTrimmingContour (offset, scale, trimmingContours);
4751
+
4752
+ return trimmingContours;
4965
4753
  },
4966
- getTrimmingContours ()
4754
+ trimSurface: (function ()
4967
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)
4950
+ {
4951
+ // Create triangles in the unit square.
4952
+
4968
4953
  const
4969
- trimmingContourNodes = this .trimmingContourNodes,
4970
- trimmingContours = [ ];
4954
+ texCoordArray = this .createDefaultNurbsTexCoords ([ ]),
4955
+ numTexCoords = texCoordArray .length;
4971
4956
 
4972
- for (const trimmingContourNode of trimmingContourNodes)
4973
- 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));
4974
4959
 
4975
- return trimmingContours;
4960
+ return triangles;
4976
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
+ })(),
4977
5012
  });
4978
5013
 
4979
5014
  function NurbsTrimmedSurface_filter (array, remove)