sunrize 1.0.11

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 (200) hide show
  1. package/.vscode/launch.json +17 -0
  2. package/.vscode/settings.json +21 -0
  3. package/.vscode/tasks.json +25 -0
  4. package/LICENSE.md +627 -0
  5. package/Makefile +4 -0
  6. package/README.md +15 -0
  7. package/bin/sunrise.js +13 -0
  8. package/package.json +103 -0
  9. package/src/audio/Tink.mp3 +0 -0
  10. package/src/html/application.html +62 -0
  11. package/src/html/application.js +6 -0
  12. package/src/html/document.html +36 -0
  13. package/src/html/document.js +6 -0
  14. package/src/images/OutlineEditor/AccessTypes/AccessTypes.xcf +0 -0
  15. package/src/images/OutlineEditor/AccessTypes/initializeOnly.png +0 -0
  16. package/src/images/OutlineEditor/AccessTypes/inputOnly.0.png +0 -0
  17. package/src/images/OutlineEditor/AccessTypes/inputOnly.1.png +0 -0
  18. package/src/images/OutlineEditor/AccessTypes/inputOnly.2.png +0 -0
  19. package/src/images/OutlineEditor/AccessTypes/inputOnly.active.png +0 -0
  20. package/src/images/OutlineEditor/AccessTypes/inputOnly.png +0 -0
  21. package/src/images/OutlineEditor/AccessTypes/inputOutput.0.0.png +0 -0
  22. package/src/images/OutlineEditor/AccessTypes/inputOutput.0.1.png +0 -0
  23. package/src/images/OutlineEditor/AccessTypes/inputOutput.0.2.png +0 -0
  24. package/src/images/OutlineEditor/AccessTypes/inputOutput.1.0.png +0 -0
  25. package/src/images/OutlineEditor/AccessTypes/inputOutput.1.1.png +0 -0
  26. package/src/images/OutlineEditor/AccessTypes/inputOutput.1.2.png +0 -0
  27. package/src/images/OutlineEditor/AccessTypes/inputOutput.2.0.png +0 -0
  28. package/src/images/OutlineEditor/AccessTypes/inputOutput.2.1.png +0 -0
  29. package/src/images/OutlineEditor/AccessTypes/inputOutput.2.2.png +0 -0
  30. package/src/images/OutlineEditor/AccessTypes/inputOutput.png +0 -0
  31. package/src/images/OutlineEditor/AccessTypes/outputOnly.0.png +0 -0
  32. package/src/images/OutlineEditor/AccessTypes/outputOnly.1.png +0 -0
  33. package/src/images/OutlineEditor/AccessTypes/outputOnly.2.png +0 -0
  34. package/src/images/OutlineEditor/AccessTypes/outputOnly.active.png +0 -0
  35. package/src/images/OutlineEditor/AccessTypes/outputOnly.png +0 -0
  36. package/src/images/OutlineEditor/Fields/MFBool.svg +177 -0
  37. package/src/images/OutlineEditor/Fields/MFColor.svg +150 -0
  38. package/src/images/OutlineEditor/Fields/MFColorRGBA.svg +220 -0
  39. package/src/images/OutlineEditor/Fields/MFDouble.svg +162 -0
  40. package/src/images/OutlineEditor/Fields/MFFloat.svg +173 -0
  41. package/src/images/OutlineEditor/Fields/MFImage.svg +234 -0
  42. package/src/images/OutlineEditor/Fields/MFInt32.svg +168 -0
  43. package/src/images/OutlineEditor/Fields/MFMatrix3d.svg +219 -0
  44. package/src/images/OutlineEditor/Fields/MFMatrix3f.svg +212 -0
  45. package/src/images/OutlineEditor/Fields/MFMatrix4d.svg +212 -0
  46. package/src/images/OutlineEditor/Fields/MFMatrix4f.svg +205 -0
  47. package/src/images/OutlineEditor/Fields/MFNode.svg +180 -0
  48. package/src/images/OutlineEditor/Fields/MFRotation.svg +175 -0
  49. package/src/images/OutlineEditor/Fields/MFString.svg +152 -0
  50. package/src/images/OutlineEditor/Fields/MFTime.svg +164 -0
  51. package/src/images/OutlineEditor/Fields/MFVec2d.svg +172 -0
  52. package/src/images/OutlineEditor/Fields/MFVec2f.svg +165 -0
  53. package/src/images/OutlineEditor/Fields/MFVec3d.svg +179 -0
  54. package/src/images/OutlineEditor/Fields/MFVec3f.svg +173 -0
  55. package/src/images/OutlineEditor/Fields/MFVec4d.svg +166 -0
  56. package/src/images/OutlineEditor/Fields/MFVec4f.svg +159 -0
  57. package/src/images/OutlineEditor/Fields/SFBool.svg +137 -0
  58. package/src/images/OutlineEditor/Fields/SFColor.svg +143 -0
  59. package/src/images/OutlineEditor/Fields/SFColorRGBA.svg +213 -0
  60. package/src/images/OutlineEditor/Fields/SFDouble.svg +155 -0
  61. package/src/images/OutlineEditor/Fields/SFFloat.svg +166 -0
  62. package/src/images/OutlineEditor/Fields/SFImage.svg +234 -0
  63. package/src/images/OutlineEditor/Fields/SFInt32.svg +163 -0
  64. package/src/images/OutlineEditor/Fields/SFMatrix3d.svg +219 -0
  65. package/src/images/OutlineEditor/Fields/SFMatrix3f.svg +206 -0
  66. package/src/images/OutlineEditor/Fields/SFMatrix4d.svg +212 -0
  67. package/src/images/OutlineEditor/Fields/SFMatrix4f.svg +199 -0
  68. package/src/images/OutlineEditor/Fields/SFNode.svg +174 -0
  69. package/src/images/OutlineEditor/Fields/SFRotation.svg +169 -0
  70. package/src/images/OutlineEditor/Fields/SFString.svg +147 -0
  71. package/src/images/OutlineEditor/Fields/SFTime.svg +158 -0
  72. package/src/images/OutlineEditor/Fields/SFVec2d.svg +166 -0
  73. package/src/images/OutlineEditor/Fields/SFVec2f.svg +159 -0
  74. package/src/images/OutlineEditor/Fields/SFVec3d.svg +173 -0
  75. package/src/images/OutlineEditor/Fields/SFVec3f.svg +167 -0
  76. package/src/images/OutlineEditor/Fields/SFVec4d.svg +166 -0
  77. package/src/images/OutlineEditor/Fields/SFVec4f.svg +153 -0
  78. package/src/images/OutlineEditor/Fields/Unkown.svg +137 -0
  79. package/src/images/OutlineEditor/Fields/none.png +0 -0
  80. package/src/images/OutlineEditor/Node/ExportedNode.svg +212 -0
  81. package/src/images/OutlineEditor/Node/ExternProto.svg +237 -0
  82. package/src/images/OutlineEditor/Node/ImportedNode.svg +230 -0
  83. package/src/images/OutlineEditor/Node/NULL.svg +160 -0
  84. package/src/images/OutlineEditor/Node/Prototype.svg +263 -0
  85. package/src/images/OutlineEditor/Node/Route.svg +207 -0
  86. package/src/images/OutlineEditor/Node/SharedNode.svg +245 -0
  87. package/src/images/OutlineEditor/Node/X3DBaseNode.svg +167 -0
  88. package/src/images/OutlineEditor/Node/X3DExecutionContext.svg +207 -0
  89. package/src/images/OutlineEditor/Values/Bell.svg +79 -0
  90. package/src/images/OutlineEditor/Values/FALSE.svg +76 -0
  91. package/src/images/OutlineEditor/Values/TRUE.svg +76 -0
  92. package/src/images/icon.icns +0 -0
  93. package/src/images/icon.ico +0 -0
  94. package/src/images/icon.png +0 -0
  95. package/src/images/icons/arrow.svg +113 -0
  96. package/src/images/icons/hand.svg +129 -0
  97. package/src/main.js +9 -0
  98. package/src/sunrize/Application/ActionKeys.js +80 -0
  99. package/src/sunrize/Application/Application.js +660 -0
  100. package/src/sunrize/Application/DataStorage.js +179 -0
  101. package/src/sunrize/Application/Document.js +453 -0
  102. package/src/sunrize/Application/Footer.js +46 -0
  103. package/src/sunrize/Application/GetText.js +10 -0
  104. package/src/sunrize/Application/Interface.js +148 -0
  105. package/src/sunrize/Application/SecondaryToolbar.js +156 -0
  106. package/src/sunrize/Application/Selection.js +49 -0
  107. package/src/sunrize/Application/Sidebar.js +51 -0
  108. package/src/sunrize/Application/Tabs.js +329 -0
  109. package/src/sunrize/Application/Traverse.js +341 -0
  110. package/src/sunrize/Bits/Algorithm.js +5 -0
  111. package/src/sunrize/Bits/Beep.js +13 -0
  112. package/src/sunrize/Bits/Highlight.js +16 -0
  113. package/src/sunrize/Bits/Validate.js +59 -0
  114. package/src/sunrize/Controls/AddPrototypePopover.js +111 -0
  115. package/src/sunrize/Controls/Dialog.js +74 -0
  116. package/src/sunrize/Controls/EditUserDefinedFieldPopover.js +223 -0
  117. package/src/sunrize/Controls/Popover.js +32 -0
  118. package/src/sunrize/Controls/RenameNodeInput.js +94 -0
  119. package/src/sunrize/Controls/RenameNodePopover.js +40 -0
  120. package/src/sunrize/Controls/Splitter.js +102 -0
  121. package/src/sunrize/Controls/Tabs.js +96 -0
  122. package/src/sunrize/Editors/AnimationEditor.js +18 -0
  123. package/src/sunrize/Editors/BrowserSize.js +101 -0
  124. package/src/sunrize/Editors/Console.js +239 -0
  125. package/src/sunrize/Editors/FileManager.js +18 -0
  126. package/src/sunrize/Editors/Library.js +268 -0
  127. package/src/sunrize/Editors/NodeInspector.js +18 -0
  128. package/src/sunrize/Editors/NodeList.js +122 -0
  129. package/src/sunrize/Editors/OutlineEditor.js +2007 -0
  130. package/src/sunrize/Editors/OutlineRouteGraph.js +557 -0
  131. package/src/sunrize/Editors/OutlineView.js +3017 -0
  132. package/src/sunrize/Editors/Primitives.js +452 -0
  133. package/src/sunrize/Editors/SceneProperties.js +477 -0
  134. package/src/sunrize/Editors/ScriptEditor.js +594 -0
  135. package/src/sunrize/Editors/Units.js +146 -0
  136. package/src/sunrize/Fields/MFStringTextArea.js +32 -0
  137. package/src/sunrize/Fields/SFStringInput.js +32 -0
  138. package/src/sunrize/Fields.js +2 -0
  139. package/src/sunrize/Tools/CADGeometry/CADAssemblyTool.js +20 -0
  140. package/src/sunrize/Tools/CADGeometry/CADFaceTool.js +20 -0
  141. package/src/sunrize/Tools/CADGeometry/CADLayerTool.js +20 -0
  142. package/src/sunrize/Tools/CADGeometry/CADPartTool.js +20 -0
  143. package/src/sunrize/Tools/CADGeometry.js +6 -0
  144. package/src/sunrize/Tools/Core/ToolColors.js +33 -0
  145. package/src/sunrize/Tools/Core/X3DNodeTool.js +132 -0
  146. package/src/sunrize/Tools/Core/X3DPrototypeInstanceTool.js +31 -0
  147. package/src/sunrize/Tools/Core.js +3 -0
  148. package/src/sunrize/Tools/Geospatial/GeoLODTool.js +40 -0
  149. package/src/sunrize/Tools/Geospatial/GeoLocationTool.js +20 -0
  150. package/src/sunrize/Tools/Geospatial/GeoTransformTool.js +20 -0
  151. package/src/sunrize/Tools/Geospatial.js +5 -0
  152. package/src/sunrize/Tools/Grouping/GroupTool.js +20 -0
  153. package/src/sunrize/Tools/Grouping/StaticGroupTool.js +20 -0
  154. package/src/sunrize/Tools/Grouping/SwitchTool.js +20 -0
  155. package/src/sunrize/Tools/Grouping/TransformTool.js +20 -0
  156. package/src/sunrize/Tools/Grouping/TransformTool.x3d +37 -0
  157. package/src/sunrize/Tools/Grouping/Vector.x3d +98 -0
  158. package/src/sunrize/Tools/Grouping/X3DBoundedObjectTool.js +44 -0
  159. package/src/sunrize/Tools/Grouping/X3DBoundedObjectTool.x3d +330 -0
  160. package/src/sunrize/Tools/Grouping/X3DTransformNodeTool.js +44 -0
  161. package/src/sunrize/Tools/Grouping.js +6 -0
  162. package/src/sunrize/Tools/HAnim/HAnimHumanoidTool.js +20 -0
  163. package/src/sunrize/Tools/HAnim/HAnimJointTool.js +20 -0
  164. package/src/sunrize/Tools/HAnim/HAnimSegmentTool.js +20 -0
  165. package/src/sunrize/Tools/HAnim/HAnimSiteTool.js +20 -0
  166. package/src/sunrize/Tools/HAnim.js +6 -0
  167. package/src/sunrize/Tools/Layering/LayerTool.js +16 -0
  168. package/src/sunrize/Tools/Layering/X3DLayerNodeTool.js +22 -0
  169. package/src/sunrize/Tools/Layering.js +3 -0
  170. package/src/sunrize/Tools/Layout/LayoutGroupTool.js +78 -0
  171. package/src/sunrize/Tools/Layout/LayoutLayerTool.js +16 -0
  172. package/src/sunrize/Tools/Layout/ScreenGroupTool.js +20 -0
  173. package/src/sunrize/Tools/Layout.js +5 -0
  174. package/src/sunrize/Tools/Navigation/BillboardTool.js +37 -0
  175. package/src/sunrize/Tools/Navigation/CollisionTool.js +37 -0
  176. package/src/sunrize/Tools/Navigation/LODTool.js +37 -0
  177. package/src/sunrize/Tools/Navigation.js +5 -0
  178. package/src/sunrize/Tools/Networking/AnchorTool.js +20 -0
  179. package/src/sunrize/Tools/Networking/InlineTool.js +20 -0
  180. package/src/sunrize/Tools/Networking.js +4 -0
  181. package/src/sunrize/Tools/ParticleSystems/ParticleSystemTool.js +20 -0
  182. package/src/sunrize/Tools/ParticleSystems.js +3 -0
  183. package/src/sunrize/Tools/Picking/PickableGroupTool.js +20 -0
  184. package/src/sunrize/Tools/Picking.js +3 -0
  185. package/src/sunrize/Tools/RigidBodyPhysics/CollidableOffsetTool.js +37 -0
  186. package/src/sunrize/Tools/RigidBodyPhysics/CollidableShapeTool.js +37 -0
  187. package/src/sunrize/Tools/RigidBodyPhysics.js +4 -0
  188. package/src/sunrize/Tools/Shaders/ToolShader.x3d +86 -0
  189. package/src/sunrize/Tools/Shape/ShapeTool.js +20 -0
  190. package/src/sunrize/Tools/Shape.js +3 -0
  191. package/src/sunrize/Tools/VolumeRendering/IsoSurfaceVolumeDataTool.js +16 -0
  192. package/src/sunrize/Tools/VolumeRendering/SegmentedVolumeDataTool.js +16 -0
  193. package/src/sunrize/Tools/VolumeRendering/VolumeDataTool.js +16 -0
  194. package/src/sunrize/Tools/VolumeRendering/X3DVolumeDataNodeTool.js +12 -0
  195. package/src/sunrize/Tools/VolumeRendering.js +5 -0
  196. package/src/sunrize/Tools.js +15 -0
  197. package/src/sunrize/Undo/Editor.js +2146 -0
  198. package/src/sunrize/Undo/UndoManager.js +204 -0
  199. package/src/sunrize/X3D.js +8 -0
  200. package/src/themes/dark.css +1291 -0
@@ -0,0 +1,59 @@
1
+ "use strict"
2
+
3
+ const $ = require ("jquery")
4
+
5
+ /**
6
+ *
7
+ * @param {RegExp} regex
8
+ * @param {Function} error
9
+ * @returns {JQuery<HTMLElement>}
10
+ */
11
+ $.fn.validate = function (regex, error)
12
+ {
13
+ this
14
+ .off ("keydown.validate")
15
+ .off ("keyup.validate")
16
+ .off ("change.validate")
17
+
18
+ let lastValue = this .val ()
19
+
20
+ this .on ("keydown.validate", (event) =>
21
+ {
22
+ if (event .key .length > 1)
23
+ return
24
+
25
+ const
26
+ start = this .prop ("selectionStart"),
27
+ end = this .prop ("selectionEnd"),
28
+ value = this .val () .substr (0, start) + event .key + this .val () .substr (end)
29
+
30
+ if (value .match (regex))
31
+ return
32
+
33
+ event .preventDefault ()
34
+
35
+ if (typeof error === "function")
36
+ error .call (this, event)
37
+ })
38
+ .on ("keyup.validate", (event) =>
39
+ {
40
+ // https://stackoverflow.com/questions/44962941/html-text-input-element-disable-mac-double-space-to-insert-period
41
+
42
+ if (this .val () .match (regex))
43
+ return
44
+
45
+ const
46
+ start = this .prop ("selectionStart"),
47
+ end = this .prop ("selectionEnd")
48
+
49
+ this .val (lastValue)
50
+ this .prop ("selectionStart", start)
51
+ this .prop ("selectionEnd", end)
52
+ })
53
+ .on ("change.validate", (event) =>
54
+ {
55
+ lastValue = this .val ()
56
+ })
57
+
58
+ return this
59
+ }
@@ -0,0 +1,111 @@
1
+ "use strict"
2
+
3
+ const
4
+ $ = require ("jquery"),
5
+ DataStorage = require ("../Application/DataStorage"),
6
+ Editor = require ("../Undo/Editor"),
7
+ UndoManager = require ("../Undo/UndoManager"),
8
+ _ = require ("../Application/GetText")
9
+
10
+ require ("./Popover")
11
+ require ("../Bits/Validate")
12
+
13
+ const types = {
14
+ externproto: 0,
15
+ proto: 1,
16
+ }
17
+
18
+ $.fn.addPrototypePopover = function (executionContext, type)
19
+ {
20
+ // Create config.
21
+
22
+ const config = new DataStorage (localStorage, "Sunrize.")
23
+
24
+ config .addDefaultValues ({ selectedIndex: 1 })
25
+
26
+ // Create content.
27
+
28
+ const content = $("<div></div>")
29
+
30
+ const protoMenu = $("<select></select>")
31
+ .append ($("<option></option>") .text ("EXTERNPROTO"))
32
+ .append ($("<option></option>") .text ("PROTO"))
33
+ .prop ("selectedIndex", config .selectedIndex = type ? types [type] : config .selectedIndex)
34
+ .on ("change", () => config .selectedIndex = protoMenu .prop ("selectedIndex"))
35
+ .appendTo (content)
36
+
37
+ const nameInput = $("<input></input>")
38
+ .attr ("placeholder", _ ("Enter name"))
39
+ .appendTo (content)
40
+
41
+ // Create tooltip.
42
+
43
+ const tooltip = this .popover ({
44
+ content: content,
45
+ events: {
46
+ show: (event, api) =>
47
+ {
48
+ nameInput .validate (Editor .Id, () =>
49
+ {
50
+ $ .beep ()
51
+ nameInput .highlight ()
52
+ })
53
+ .on ("keydown.addPrototypePopover", (event) =>
54
+ {
55
+ if (event .key !== "Enter")
56
+ return
57
+
58
+ api .toggle (false)
59
+ event .preventDefault ()
60
+
61
+ if (!nameInput .val () .length)
62
+ return
63
+
64
+ switch (protoMenu .prop ("selectedIndex"))
65
+ {
66
+ case 0:
67
+ {
68
+ const name = executionContext .getUniqueExternProtoName (nameInput .val ())
69
+
70
+ UndoManager .shared .beginUndo (_ ("Add Extern Proto Declaration »%s«"), name)
71
+
72
+ const externproto = Editor .addExternProtoDeclaration (executionContext, name)
73
+
74
+ if (!executionContext .protos .get (name))
75
+ {
76
+ const available = Editor .getNextAvailableProtoNode (executionContext, externproto)
77
+
78
+ if (available)
79
+ Editor .replaceProtoNodes (executionContext, available, externproto)
80
+ }
81
+
82
+ UndoManager .shared .endUndo ()
83
+ break
84
+ }
85
+ case 1:
86
+ {
87
+ const name = executionContext .getUniqueProtoName (nameInput .val ())
88
+
89
+ UndoManager .shared .beginUndo (_ ("Add Proto Declaration »%s«"), name)
90
+
91
+ const
92
+ proto = Editor .addProtoDeclaration (executionContext, name),
93
+ available = Editor .getNextAvailableProtoNode (executionContext, proto)
94
+
95
+ if (available)
96
+ Editor .replaceProtoNodes (executionContext, available, proto)
97
+
98
+ UndoManager .shared .endUndo ()
99
+ break
100
+ }
101
+ }
102
+ })
103
+
104
+ setTimeout (() => nameInput .trigger ("select"), 1)
105
+ },
106
+ },
107
+ })
108
+
109
+ return this
110
+ }
111
+
@@ -0,0 +1,74 @@
1
+ "use strict"
2
+
3
+ const
4
+ $ = require ("jquery"),
5
+ Interface = require ("../Application/Interface")
6
+
7
+ module .exports = class Dialog extends Interface
8
+ {
9
+ initialize ()
10
+ {
11
+ // Create window and handle resize and move.
12
+
13
+ this .element = $("<div></div>") .dialog ({
14
+ classes: {
15
+ "ui-dialog": "dialog",
16
+ },
17
+ modal: true,
18
+ autoOpen: false,
19
+ show: true,
20
+ draggable: false,
21
+ minHeight : 100,
22
+ open: () =>
23
+ {
24
+ this .element .dialog ("widget")
25
+ .nextAll (".ui-widget-overlay")
26
+ .on ("click", () => this .close ())
27
+
28
+ this .onopen ()
29
+ },
30
+ close: () =>
31
+ {
32
+ this .onclose ()
33
+ },
34
+ })
35
+
36
+ this .element .dialog ("widget")
37
+ .draggable ({
38
+ drag: (event, ui) => this .config .file .position = { my: `left+${ui .position .left} top+${ui .position .top}`, at: "left top" },
39
+ })
40
+ .resizable({
41
+ resize: (event, ui) => this .config .file .size = [ui .size .width, ui .size .height],
42
+ })
43
+ .find (".ui-dialog-titlebar") .remove ()
44
+ }
45
+
46
+ configure (defaults = { })
47
+ {
48
+ // Set default config values.
49
+
50
+ this .config .file .addDefaultValues (Object .assign ({
51
+ position: undefined,
52
+ size: [400, 250],
53
+ },
54
+ defaults))
55
+ }
56
+
57
+ open ()
58
+ {
59
+ this .element .dialog ({
60
+ position: { ...this .config .file .position, of: $("body") },
61
+ width: this .config .file .size [0],
62
+ height: this .config .file .size [1],
63
+ })
64
+ .dialog ("open")
65
+ }
66
+
67
+ close ()
68
+ {
69
+ this .element .dialog ("close")
70
+ }
71
+
72
+ onopen () { }
73
+ onclose () { }
74
+ }
@@ -0,0 +1,223 @@
1
+ "use strict"
2
+
3
+ const
4
+ $ = require ("jquery"),
5
+ X3D = require ("../X3D"),
6
+ Editor = require ("../Undo/Editor"),
7
+ UndoManager = require ("../Undo/UndoManager"),
8
+ _ = require ("../Application/GetText")
9
+
10
+ require ("./Popover")
11
+ require ("../Bits/Validate")
12
+
13
+ const accessTypes = new Map ([
14
+ [X3D .X3DConstants .initializeOnly, "initializeOnly"],
15
+ [X3D .X3DConstants .inputOnly, "inputOnly"],
16
+ [X3D .X3DConstants .outputOnly, "outputOnly"],
17
+ [X3D .X3DConstants .inputOutput, "inputOutput"],
18
+ ])
19
+
20
+ $.fn.editUserDefinedFieldPopover = function (executionContext, node, field)
21
+ {
22
+ const Fields = X3D .require ("x_ite/Fields")
23
+
24
+ // Create content.
25
+
26
+ const content = $("<div></div>")
27
+
28
+ const typeNameMenu = $("<select></select>")
29
+ .appendTo (content)
30
+
31
+ const singleFields = $("<optgroup></optgroup>")
32
+ .attr ("label", "Single Fields")
33
+ .append ($("<option></option>") .text ("SFBool"))
34
+ .append ($("<option></option>") .text ("SFColor"))
35
+ .append ($("<option></option>") .text ("SFColorRGBA"))
36
+ .append ($("<option></option>") .text ("SFDouble"))
37
+ .append ($("<option></option>") .text ("SFFloat"))
38
+ .append ($("<option></option>") .text ("SFImage"))
39
+ .append ($("<option></option>") .text ("SFInt32"))
40
+ .append ($("<option></option>") .text ("SFMatrix3d"))
41
+ .append ($("<option></option>") .text ("SFMatrix3f"))
42
+ .append ($("<option></option>") .text ("SFMatrix4d"))
43
+ .append ($("<option></option>") .text ("SFMatrix4f"))
44
+ .append ($("<option></option>") .text ("SFNode"))
45
+ .append ($("<option></option>") .text ("SFRotation"))
46
+ .append ($("<option></option>") .text ("SFString"))
47
+ .append ($("<option></option>") .text ("SFTime"))
48
+ .append ($("<option></option>") .text ("SFVec2d"))
49
+ .append ($("<option></option>") .text ("SFVec2f"))
50
+ .append ($("<option></option>") .text ("SFVec3d"))
51
+ .append ($("<option></option>") .text ("SFVec3f"))
52
+ .append ($("<option></option>") .text ("SFVec4d"))
53
+ .append ($("<option></option>") .text ("SFVec4f"))
54
+ .appendTo (typeNameMenu)
55
+
56
+ const multiFields = $("<optgroup></optgroup>")
57
+ .attr ("label", "Multi Fields")
58
+ .append ($("<option></option>") .text ("MFBool"))
59
+ .append ($("<option></option>") .text ("MFColor"))
60
+ .append ($("<option></option>") .text ("MFColorRGBA"))
61
+ .append ($("<option></option>") .text ("MFDouble"))
62
+ .append ($("<option></option>") .text ("MFFloat"))
63
+ .append ($("<option></option>") .text ("MFImage"))
64
+ .append ($("<option></option>") .text ("MFInt32"))
65
+ .append ($("<option></option>") .text ("MFMatrix3d"))
66
+ .append ($("<option></option>") .text ("MFMatrix3f"))
67
+ .append ($("<option></option>") .text ("MFMatrix4d"))
68
+ .append ($("<option></option>") .text ("MFMatrix4f"))
69
+ .append ($("<option></option>") .text ("MFNode"))
70
+ .append ($("<option></option>") .text ("MFRotation"))
71
+ .append ($("<option></option>") .text ("MFString"))
72
+ .append ($("<option></option>") .text ("MFTime"))
73
+ .append ($("<option></option>") .text ("MFVec2d"))
74
+ .append ($("<option></option>") .text ("MFVec2f"))
75
+ .append ($("<option></option>") .text ("MFVec3d"))
76
+ .append ($("<option></option>") .text ("MFVec3f"))
77
+ .append ($("<option></option>") .text ("MFVec4d"))
78
+ .append ($("<option></option>") .text ("MFVec4f"))
79
+ .appendTo (typeNameMenu)
80
+
81
+ const accessTypeMenu = $("<select></select>")
82
+ .append ($("<option></option>") .text ("initializeOnly"))
83
+ .append ($("<option></option>") .text ("inputOnly"))
84
+ .append ($("<option></option>") .text ("outputOnly"))
85
+ .append ($("<option></option>") .text ("inputOutput"))
86
+ .appendTo (content)
87
+
88
+ const nameInput = $("<input></input>")
89
+ .attr ("placeholder", _ ("Enter name"))
90
+ .appendTo (content)
91
+
92
+ const okButton = $("<button></button>")
93
+ .text (_ ("Apply"))
94
+ .on ("click", confirm)
95
+ .appendTo (content)
96
+
97
+ if (field)
98
+ {
99
+ typeNameMenu
100
+ .find ("option")
101
+ .filter ((i, e) => $(e) .text () === field .getTypeName ())
102
+ .prop ("selected", true);
103
+
104
+ accessTypeMenu
105
+ .find ("option")
106
+ .filter ((i, e) => $(e) .text () === accessTypes .get (field .getAccessType ()))
107
+ .prop ("selected", true);
108
+
109
+ nameInput .val (field .getName ())
110
+ }
111
+
112
+ // Create tooltip.
113
+
114
+ const tooltip = this .popover ({
115
+ content: content,
116
+ events: {
117
+ show: (event, api) =>
118
+ {
119
+ nameInput .validate (Editor .Id, () =>
120
+ {
121
+ $ .beep ()
122
+ nameInput .highlight ()
123
+ })
124
+ .on ("keydown", (event) =>
125
+ {
126
+ if (event .key !== "Enter")
127
+ return
128
+
129
+ confirm (event)
130
+ })
131
+
132
+ setTimeout (() => nameInput .trigger ("select"), 1)
133
+ },
134
+ },
135
+ })
136
+
137
+ function confirm (event)
138
+ {
139
+ const
140
+ typeName = typeNameMenu .find ("option:selected") .text (),
141
+ type = X3D .X3DConstants [typeName],
142
+ accessType = X3D .X3DConstants [accessTypeMenu .find ("option:selected") .text ()],
143
+ name = nameInput .val ()
144
+
145
+ if (field)
146
+ {
147
+ if (node .getFields () .has (name) && node .getFields () .get (name) !== field)
148
+ {
149
+ // Error: field name exists.
150
+ $ .beep ()
151
+ nameInput .highlight ()
152
+ event .preventDefault ()
153
+ }
154
+ else
155
+ {
156
+ tooltip .qtip ("api") .toggle (false)
157
+ event .preventDefault ()
158
+
159
+ if (!name .length)
160
+ return
161
+
162
+ if (type === field .getType () && accessType == field .getAccessType () && name === field .getName ())
163
+ return
164
+
165
+ // Change field.
166
+
167
+ const fields = Array .from (node .getUserDefinedFields ())
168
+
169
+ if (type === field .getType ())
170
+ {
171
+ UndoManager .shared .beginUndo (_ ("Edit Field »%s«"), field .getName ())
172
+ Editor .updateUserDefinedField (executionContext, node, field, accessType, name)
173
+ UndoManager .shared .endUndo ()
174
+ }
175
+ else
176
+ {
177
+ const
178
+ index = fields .indexOf (field),
179
+ newField = new Fields [typeName] ()
180
+
181
+ UndoManager .shared .beginUndo (_ ("Change Type of Field »%s«"), field .getName ())
182
+
183
+ newField .setAccessType (accessType)
184
+ newField .setName (name)
185
+ fields .splice (index, 1, newField)
186
+
187
+ Editor .setUserDefinedFields (executionContext, node, fields)
188
+ UndoManager .shared .endUndo ()
189
+ }
190
+ }
191
+ }
192
+ else
193
+ {
194
+ if (node .getFields () .has (name))
195
+ {
196
+ // Error: field name exists.
197
+ $ .beep ()
198
+ nameInput .highlight ()
199
+ event .preventDefault ()
200
+ }
201
+ else
202
+ {
203
+ tooltip .qtip ("api") .toggle (false)
204
+ event .preventDefault ()
205
+
206
+ if (!name .length)
207
+ return
208
+
209
+ // Add field.
210
+
211
+ const field = new Fields [typeName] ()
212
+
213
+ field .setAccessType (accessType)
214
+ field .setName (name)
215
+
216
+ Editor .addUserDefinedField (executionContext, node, field)
217
+ }
218
+ }
219
+ }
220
+
221
+ return this
222
+ }
223
+
@@ -0,0 +1,32 @@
1
+ "use strict"
2
+
3
+ const $ = require ("jquery")
4
+
5
+ require ("qtip2")
6
+
7
+ $.fn.popover = function (options)
8
+ {
9
+ return this .qtip ($.extend (true,
10
+ {
11
+ position: {
12
+ my: "top right",
13
+ at: "bottom left",
14
+ },
15
+ style: {
16
+ classes: "qtip-tipsy",
17
+ },
18
+ show: {
19
+ ready: true,
20
+ modal: true,
21
+ solo: true,
22
+ delay: 200,
23
+ },
24
+ events: {
25
+ hide: function (event, api)
26
+ {
27
+ api .destroy (true)
28
+ },
29
+ },
30
+ },
31
+ options))
32
+ }
@@ -0,0 +1,94 @@
1
+ "use strict"
2
+
3
+ const
4
+ $ = require ("jquery"),
5
+ X3D = require ("../X3D"),
6
+ Editor = require ("../Undo/Editor"),
7
+ UndoManager = require ("../Undo/UndoManager"),
8
+ _ = require ("../Application/GetText")
9
+
10
+ require ("../Bits/Validate")
11
+
12
+ $.fn.renameNodeInput = function (node)
13
+ {
14
+ this .off ("keydown.renameNodeInput")
15
+
16
+ this .val (node ? node .getName () : "")
17
+
18
+ this .validate (Editor .Id, () =>
19
+ {
20
+ $ .beep ()
21
+ this .highlight ()
22
+ })
23
+ .on ("keydown.renameNodeInput", (event) =>
24
+ {
25
+ if (!node)
26
+ return
27
+
28
+ if (event .key !== "Enter")
29
+ return
30
+
31
+ event .preventDefault ()
32
+
33
+ let name = this .val ()
34
+
35
+ if (name === node .getName ())
36
+ return
37
+
38
+ const executionContext = node .getExecutionContext ();
39
+
40
+ if (node instanceof X3D .X3DProtoDeclarationNode)
41
+ {
42
+ if (!name)
43
+ return
44
+
45
+ if (node .isExternProto)
46
+ {
47
+ name = executionContext .getUniqueExternProtoName (name)
48
+
49
+ const externproto = node
50
+
51
+ UndoManager .shared .beginUndo (_ ("Update Extern Proto Declaration »%s«"), name)
52
+
53
+ Editor .updateExternProtoDeclaration (executionContext, name, externproto)
54
+
55
+ if (!executionContext .protos .get (name))
56
+ {
57
+ const available = Editor .getNextAvailableProtoNode (executionContext, externproto)
58
+
59
+ if (available)
60
+ Editor .replaceProtoNodes (executionContext, available, externproto)
61
+ }
62
+
63
+ UndoManager .shared .endUndo ()
64
+ }
65
+ else
66
+ {
67
+ name = executionContext .getUniqueProtoName (name)
68
+
69
+ const proto = node
70
+
71
+ UndoManager .shared .beginUndo (_ ("Update Proto Declaration »%s«"), name)
72
+
73
+ Editor .updateProtoDeclaration (executionContext, name, proto)
74
+
75
+ const available = Editor .getNextAvailableProtoNode (executionContext, proto)
76
+
77
+ if (available)
78
+ Editor .replaceProtoNodes (executionContext, available, proto)
79
+
80
+ UndoManager .shared .endUndo ()
81
+ }
82
+ }
83
+ else
84
+ {
85
+ if (name)
86
+ Editor .updateNamedNode (executionContext, executionContext .getUniqueName (name), node)
87
+ else
88
+ Editor .removeNamedNode (executionContext, node)
89
+ }
90
+ })
91
+
92
+ return this
93
+ }
94
+
@@ -0,0 +1,40 @@
1
+ "use strict"
2
+
3
+ const
4
+ $ = require ("jquery"),
5
+ _ = require ("../Application/GetText")
6
+
7
+ require ("./Popover")
8
+ require ("./RenameNodeInput")
9
+
10
+ $.fn.renameNodePopover = function (node)
11
+ {
12
+ // Create content.
13
+
14
+ const nameInput = $("<input></input>")
15
+ .attr ("placeholder", _ ("Enter name"))
16
+ .renameNodeInput (node)
17
+
18
+ // Create tooltip.
19
+
20
+ const tooltip = this .popover ({
21
+ content: nameInput,
22
+ events: {
23
+ show: (event, api) =>
24
+ {
25
+ nameInput .on ("keydown.renameNodePopover", (event) =>
26
+ {
27
+ if (event .key !== "Enter")
28
+ return
29
+
30
+ api .toggle (false)
31
+ })
32
+
33
+ setTimeout (() => nameInput .trigger ("select"), 1)
34
+ },
35
+ },
36
+ })
37
+
38
+ return this
39
+ }
40
+