sunrize 1.7.44 → 1.7.46

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 (32) hide show
  1. package/package.json +12 -12
  2. package/src/Application/Document.js +1 -9
  3. package/src/Components/Geometry2D/Arc2D.js +16 -0
  4. package/src/Components/Geometry2D/ArcClose2D.js +14 -0
  5. package/src/Components/Geometry2D/Circle2D.js +23 -0
  6. package/src/Components/Geometry2D/Disk2D.js +53 -0
  7. package/src/Components/Geometry2D/Polyline2D.js +16 -0
  8. package/src/Components/Geometry2D/Polypoint2D.js +20 -0
  9. package/src/Components/Geometry2D/Rectangle2D.js +27 -0
  10. package/src/Components/Geometry2D/TriangleSet2D.js +33 -0
  11. package/src/Components/Geometry3D/Box.js +27 -0
  12. package/src/Components/Geometry3D/Cone.js +79 -0
  13. package/src/Components/Geometry3D/Cylinder.js +81 -0
  14. package/src/Components/Geometry3D/ElevationGrid.js +23 -0
  15. package/src/Components/Geometry3D/Extrusion.js +194 -0
  16. package/src/Components/Geometry3D/IndexedFaceSet.js +158 -0
  17. package/src/Components/Geometry3D/Sphere.js +27 -0
  18. package/src/Components/NURBS/NurbsCurve.js +17 -0
  19. package/src/Components/NURBS/NurbsSweptSurface.js +24 -0
  20. package/src/Components/NURBS/NurbsSwungSurface.js +24 -0
  21. package/src/Components/NURBS/X3DNurbsSurfaceGeometryNode.js +19 -0
  22. package/src/Components/Rendering/IndexedLineSet.js +24 -0
  23. package/src/Components/Rendering/LineSet.js +34 -0
  24. package/src/Components/Rendering/X3DComposedGeometryNode.js +44 -0
  25. package/src/Components/Rendering/X3DGeometryNode.js +195 -0
  26. package/src/Components/Text/Text.js +17 -0
  27. package/src/Components.js +33 -0
  28. package/src/Editors/OutlineEditor.js +183 -18
  29. package/src/Editors/OutlineView.js +3 -3
  30. package/src/Editors/ScriptEditor.js +79 -17
  31. package/src/Tools/Geometry2D/Disk2DTool.js +16 -18
  32. package/src/Undo/Editor.js +198 -144
@@ -607,150 +607,6 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
607
607
  return executionContext === parentContext
608
608
  }
609
609
 
610
- static nodesToRemove = new Map ()
611
-
612
- /**
613
- *
614
- * @param {X3DExecutionContext} executionContext
615
- * @param {Array<X3DNode|SFNode>|MFNode} nodes
616
- * @param {UndoManager} undoManager
617
- */
618
- static removeNodesFromExecutionContextIfNecessary (executionContext, nodes, undoManager = UndoManager .shared)
619
- {
620
- if (!nodes .length)
621
- return;
622
-
623
- if (!this .nodesToRemove .has (executionContext))
624
- this .nodesToRemove .set (executionContext, [ ]);
625
-
626
- const nodesToRemove = this .nodesToRemove .get (executionContext);
627
-
628
- for (const node of nodes)
629
- nodesToRemove .push (node);
630
-
631
- if (undoManager .defer ("removeNodesFromExecutionContextIfNecessary"))
632
- return;
633
-
634
- undoManager .defer ("removeNodesFromExecutionContextIfNecessary", () =>
635
- {
636
- for (const [executionContext, nodesToRemove] of this .nodesToRemove)
637
- {
638
- // Add nodes and child nodes.
639
-
640
- const children = new Set ();
641
-
642
- Array .from (Traverse .traverse (nodesToRemove, Traverse .ROOT_NODES | Traverse .PROTO_DECLARATIONS | Traverse .PROTO_DECLARATION_BODY))
643
- .filter (object => object instanceof X3D .SFNode)
644
- .forEach (node => children .add (node .getValue () .valueOf ()));
645
-
646
- // Remove nodes still in scene graph.
647
-
648
- Array .from (Traverse .traverse (executionContext, Traverse .ROOT_NODES | Traverse .PROTO_DECLARATIONS | Traverse .PROTO_DECLARATION_BODY))
649
- .filter (object => object instanceof X3D .SFNode)
650
- .forEach (node => children .delete (node .getValue () .valueOf ()));
651
-
652
- if (children .size === 0)
653
- continue;
654
-
655
- undoManager .beginUndo (_("Remove %s Nodes from Execution Context"), children .size);
656
-
657
- for (const node of children)
658
- {
659
- // Rebind X3DBindableNode nodes.
660
-
661
- if (node .getType () .includes (X3D .X3DConstants .X3DBindableNode))
662
- {
663
- if (node ._isBound .getValue ())
664
- {
665
- undoManager .registerUndo (() =>
666
- {
667
- this .setFieldValue (executionContext, node, node ._set_bind, true, undoManager);
668
- });
669
- }
670
- }
671
-
672
- // Remove named nodes.
673
-
674
- if (node .getName ())
675
- this .removeNamedNode (executionContext, node, undoManager);
676
-
677
- // Remove routes.
678
-
679
- this .deleteRoutes (executionContext, node, undoManager);
680
-
681
- // Remove imported nodes if node is an Inline node.
682
-
683
- for (const importedNode of Array .from (executionContext .getImportedNodes ()))
684
- {
685
- if (importedNode .getInlineNode () .valueOf () === node)
686
- this .removeImportedNode (executionContext, importedNode .getImportedName (), undoManager);
687
- }
688
-
689
- // Remove exported nodes.
690
-
691
- if (executionContext instanceof X3D .X3DScene)
692
- {
693
- for (const exportedNode of Array .from (executionContext .getExportedNodes ()))
694
- {
695
- if (exportedNode .getLocalNode () .valueOf () === node)
696
- this .removeExportedNode (executionContext, exportedNode .getExportedName (), undoManager);
697
- }
698
- }
699
-
700
- // Clear fields, to get right clone count.
701
-
702
- for (const field of node .getFields ())
703
- {
704
- switch (field .getType ())
705
- {
706
- case X3D .X3DConstants .SFNode:
707
- {
708
- this .setFieldValue (executionContext, node, field, null, undoManager);
709
- break;
710
- }
711
- case X3D .X3DConstants .MFNode:
712
- {
713
- this .setFieldValue (executionContext, node, field, new X3D .MFNode (), undoManager);
714
- break;
715
- }
716
- }
717
- }
718
-
719
- this .#setLive (node, false, undoManager);
720
- }
721
-
722
- this .requestUpdateInstances (executionContext, undoManager);
723
-
724
- undoManager .endUndo ();
725
- }
726
-
727
- this .nodesToRemove .clear ();
728
- });
729
- }
730
-
731
- /**
732
- *
733
- * @param {X3DBaseNode} node
734
- * @param {boolean} value
735
- */
736
- static #setLive (node, value, undoManager = UndoManager .shared)
737
- {
738
- node = node .valueOf ();
739
-
740
- const oldValue = node .isLive ();
741
-
742
- undoManager .beginUndo (_("Set live state to »%s«"), value);
743
-
744
- node .setLive (value);
745
-
746
- undoManager .registerUndo (() =>
747
- {
748
- this .#setLive (node, oldValue, undoManager);
749
- });
750
-
751
- undoManager .endUndo ();
752
- }
753
-
754
610
  /**
755
611
  *
756
612
  * @param {X3DScene} scene
@@ -3542,6 +3398,204 @@ ${scene .toXMLString ({ html: true, indent: " " .repeat (6) }) .trimEnd () }
3542
3398
  });
3543
3399
  }
3544
3400
 
3401
+ static #nodesToRemove = new Map ();
3402
+
3403
+ /**
3404
+ *
3405
+ * @param {X3DExecutionContext} executionContext
3406
+ * @param {Array<X3DNode|SFNode>|MFNode} nodes
3407
+ * @param {UndoManager} undoManager
3408
+ */
3409
+ static removeNodesFromExecutionContextIfNecessary (executionContext, nodes, undoManager = UndoManager .shared)
3410
+ {
3411
+ if (!nodes .length)
3412
+ return;
3413
+
3414
+ if (!this .#nodesToRemove .has (executionContext))
3415
+ this .#nodesToRemove .set (executionContext, [ ]);
3416
+
3417
+ const nodesToRemove = this .#nodesToRemove .get (executionContext);
3418
+
3419
+ for (const node of nodes)
3420
+ nodesToRemove .push (node .valueOf ());
3421
+
3422
+ if (undoManager .defer ("removeNodesFromExecutionContextIfNecessary"))
3423
+ return;
3424
+
3425
+ undoManager .defer ("removeNodesFromExecutionContextIfNecessary", () =>
3426
+ {
3427
+ for (const [executionContext, nodesToRemove] of this .#nodesToRemove)
3428
+ {
3429
+ // Add nodes and child nodes.
3430
+
3431
+ const children = new Set ();
3432
+
3433
+ Array .from (Traverse .traverse (nodesToRemove, Traverse .ROOT_NODES | Traverse .PROTO_DECLARATIONS | Traverse .PROTO_DECLARATION_BODY))
3434
+ .filter (object => object instanceof X3D .SFNode)
3435
+ .forEach (node => children .add (node .getValue () .valueOf ()));
3436
+
3437
+ // Remove nodes still in scene graph.
3438
+
3439
+ Array .from (Traverse .traverse (executionContext, Traverse .ROOT_NODES | Traverse .PROTO_DECLARATIONS | Traverse .PROTO_DECLARATION_BODY))
3440
+ .filter (object => object instanceof X3D .SFNode)
3441
+ .forEach (node => children .delete (node .getValue () .valueOf ()));
3442
+
3443
+ if (children .size === 0)
3444
+ continue;
3445
+
3446
+ undoManager .beginUndo (_("Remove %s Nodes from Execution Context"), children .size);
3447
+
3448
+ for (const node of children)
3449
+ {
3450
+ // Rebind X3DBindableNode nodes.
3451
+
3452
+ if (node .getType () .includes (X3D .X3DConstants .X3DBindableNode))
3453
+ {
3454
+ if (node ._isBound .getValue ())
3455
+ {
3456
+ undoManager .registerUndo (() =>
3457
+ {
3458
+ this .setFieldValue (executionContext, node, node ._set_bind, true, undoManager);
3459
+ });
3460
+ }
3461
+ }
3462
+
3463
+ // Remove named nodes.
3464
+
3465
+ if (node .getName ())
3466
+ this .removeNamedNode (executionContext, node, undoManager);
3467
+
3468
+ // Remove routes.
3469
+
3470
+ this .deleteRoutes (executionContext, node, undoManager);
3471
+
3472
+ // Remove imported nodes if node is an Inline node.
3473
+
3474
+ for (const importedNode of Array .from (executionContext .getImportedNodes ()))
3475
+ {
3476
+ if (importedNode .getInlineNode () .valueOf () === node)
3477
+ this .removeImportedNode (executionContext, importedNode .getImportedName (), undoManager);
3478
+ }
3479
+
3480
+ // Remove exported nodes.
3481
+
3482
+ if (executionContext instanceof X3D .X3DScene)
3483
+ {
3484
+ for (const exportedNode of Array .from (executionContext .getExportedNodes ()))
3485
+ {
3486
+ if (exportedNode .getLocalNode () .valueOf () === node)
3487
+ this .removeExportedNode (executionContext, exportedNode .getExportedName (), undoManager);
3488
+ }
3489
+ }
3490
+
3491
+ // Clear fields, to get right clone count.
3492
+
3493
+ for (const field of node .getFields ())
3494
+ {
3495
+ switch (field .getType ())
3496
+ {
3497
+ case X3D .X3DConstants .SFNode:
3498
+ {
3499
+ this .setFieldValue (executionContext, node, field, null, undoManager);
3500
+ break;
3501
+ }
3502
+ case X3D .X3DConstants .MFNode:
3503
+ {
3504
+ this .setFieldValue (executionContext, node, field, new X3D .MFNode (), undoManager);
3505
+ break;
3506
+ }
3507
+ }
3508
+ }
3509
+
3510
+ this .#setLive (node, false, undoManager);
3511
+ this .#removeSelection (node, undoManager);
3512
+ }
3513
+
3514
+ this .requestUpdateInstances (executionContext, undoManager);
3515
+
3516
+ undoManager .endUndo ();
3517
+ }
3518
+
3519
+ this .#nodesToRemove .clear ();
3520
+ });
3521
+ }
3522
+
3523
+ /**
3524
+ *
3525
+ * @param {X3DBaseNode} node
3526
+ * @param {boolean} value
3527
+ * @param {UndoManager} undoManager
3528
+ */
3529
+ static #setLive (node, value, undoManager = UndoManager .shared)
3530
+ {
3531
+ node = node .valueOf ();
3532
+
3533
+ const oldValue = node .isLive ();
3534
+
3535
+ undoManager .beginUndo (_("Set live state to »%s«"), value);
3536
+
3537
+ node .setLive (value);
3538
+
3539
+ undoManager .registerUndo (() =>
3540
+ {
3541
+ this .#setLive (node, oldValue, undoManager);
3542
+ });
3543
+
3544
+ undoManager .endUndo ();
3545
+ }
3546
+
3547
+ /**
3548
+ *
3549
+ * @param {X3DBaseNode} node
3550
+ * @param {UndoManager} undoManager
3551
+ */
3552
+ static #addSelection (node, undoManager = UndoManager .shared)
3553
+ {
3554
+ node = node .valueOf ();
3555
+
3556
+ const selection = require ("../Application/Selection");
3557
+
3558
+ if (selection .has (node))
3559
+ return;
3560
+
3561
+ undoManager .beginUndo (_("Select node"));
3562
+
3563
+ selection .add (node);
3564
+
3565
+ undoManager .registerUndo (() =>
3566
+ {
3567
+ this .#removeSelection (node, undoManager);
3568
+ });
3569
+
3570
+ undoManager .endUndo ();
3571
+ }
3572
+
3573
+ /**
3574
+ *
3575
+ * @param {X3DBaseNode} node
3576
+ * @param {UndoManager} undoManager
3577
+ */
3578
+ static #removeSelection (node, undoManager = UndoManager .shared)
3579
+ {
3580
+ node = node .valueOf ();
3581
+
3582
+ const selection = require ("../Application/Selection");
3583
+
3584
+ if (!selection .has (node))
3585
+ return;
3586
+
3587
+ undoManager .beginUndo (_("Deselect node"));
3588
+
3589
+ selection .remove (node);
3590
+
3591
+ undoManager .registerUndo (() =>
3592
+ {
3593
+ this .#addSelection (node, undoManager);
3594
+ });
3595
+
3596
+ undoManager .endUndo ();
3597
+ }
3598
+
3545
3599
  /**
3546
3600
  *
3547
3601
  * @param {function} callback