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,102 @@
1
+ "use strict"
2
+
3
+ const
4
+ $ = require ("jquery"),
5
+ Interface = require ("../Application/Interface"),
6
+ Algorithm = require ("../Bits/Algorithm")
7
+
8
+ module .exports = class Splitter extends Interface
9
+ {
10
+ constructor (element, orientation)
11
+ {
12
+ super (`Sunrize.Splitter.${element .attr ("id")}.`)
13
+
14
+ this .splitter = element
15
+ this .orientation = orientation
16
+
17
+ switch (this .orientation)
18
+ {
19
+ case "horizontal":
20
+ {
21
+ const top = this .splitter .find ("> .horizontal-splitter-top")
22
+
23
+ top .resizable ({
24
+ minHeight: 0,
25
+ handles: "s",
26
+ resize: () =>
27
+ {
28
+ this .position = top .outerHeight () / this .splitter .innerHeight ()
29
+ },
30
+ })
31
+
32
+ top .find ("> .ui-resizable-s") .append ($("<div></div>"))
33
+
34
+ break
35
+ }
36
+ case "vertical":
37
+ {
38
+ const left = this .splitter .find ("> .vertical-splitter-left")
39
+
40
+ left .resizable ({
41
+ minWidth: 0,
42
+ handles: "e",
43
+ resize: () =>
44
+ {
45
+ this .position = left .outerWidth () / this .splitter .innerWidth ()
46
+ },
47
+ })
48
+
49
+ left .find ("> .ui-resizable-e") .append ($("<div></div>"))
50
+
51
+ break
52
+ }
53
+ }
54
+
55
+ this .setup ()
56
+ }
57
+
58
+ configure ()
59
+ {
60
+ if (this .config .file .position !== undefined)
61
+ this .position = this .config .file .position
62
+ }
63
+
64
+ get position ()
65
+ {
66
+ this .config .file .position
67
+ }
68
+
69
+ /**
70
+ * @param {number} position
71
+ */
72
+ set position (position)
73
+ {
74
+ position = Algorithm .clamp (position, 0, 1)
75
+
76
+ this .config .file .position = position;
77
+
78
+ switch (this .orientation)
79
+ {
80
+ case "horizontal":
81
+ {
82
+ const
83
+ top = this .splitter .find ("> .horizontal-splitter-top"),
84
+ bottom = this .splitter .find ("> .horizontal-splitter-bottom")
85
+
86
+ top .css ("height", (100 * position) + "%")
87
+ bottom .css ("height", (100 * (1 - position)) + "%")
88
+ break
89
+ }
90
+ case "vertical":
91
+ {
92
+ const
93
+ left = this .splitter .find ("> .vertical-splitter-left"),
94
+ right = this .splitter .find ("> .vertical-splitter-right")
95
+
96
+ left .css ("width", (100 * position) + "%")
97
+ right .css ("width", (100 * (1 - position)) + "%")
98
+ break
99
+ }
100
+ }
101
+ }
102
+ }
@@ -0,0 +1,96 @@
1
+ "use strict"
2
+
3
+ const
4
+ $ = require ("jquery"),
5
+ Interface = require ("../Application/Interface")
6
+
7
+ module .exports = class Tabs extends Interface
8
+ {
9
+ constructor (element, orientation)
10
+ {
11
+ super (`Sunrize.Tabs.${element .attr ("id")}.`)
12
+
13
+ this .element = element
14
+ this .orientation = orientation
15
+ this .tabs = $("<ul></ul>") .appendTo (this .element)
16
+ }
17
+
18
+ initialize ()
19
+ {
20
+ this .addTabs ()
21
+
22
+ this .element .tabs ()
23
+ this .element .tabs ("option", "classes.ui-tabs", this .orientation);
24
+ this .element .on ("tabsactivate", () => this .tabActivated ());
25
+ }
26
+
27
+ addTabs () { }
28
+
29
+ configure (defaults = { })
30
+ {
31
+ this .config .file .addDefaultValues (Object .assign ({ active: 0 }, defaults))
32
+
33
+ if (this .element .tabs ("option", "active") === this .config .file .active)
34
+ this .tabActivated ()
35
+ else
36
+ this .element .tabs ("option", "active", this .config .file .active)
37
+ }
38
+
39
+ tabActivated ()
40
+ {
41
+ const
42
+ active = this .element .tabs ("option", "active"),
43
+ panel = $(this .element .find (`.tabs-panel`) .get (active))
44
+
45
+ this .config .file .active = active
46
+
47
+ if (panel .data ("Tabs.initialized"))
48
+ return
49
+
50
+ panel .data ("Tabs.initialized", true)
51
+ this .initTab (panel)
52
+ }
53
+
54
+ addTextTab (id, title)
55
+ {
56
+ const tab = $("<li></li>")
57
+ .append ($("<a></a>")
58
+ .attr ("href", `#${id}-tab`)
59
+ .attr ("title", title)
60
+ .text (title))
61
+ .appendTo (this .tabs)
62
+
63
+ this .addPanel (id)
64
+ }
65
+
66
+ addIconTab (id, icon, title)
67
+ {
68
+ $("<li></li>")
69
+ .append ($("<a></a>")
70
+ .attr ("href", `#${id}-tab`)
71
+ .attr ("title", title)
72
+ .append ($("<span></span>")
73
+ .addClass ("material-icons")
74
+ .text (icon)))
75
+ .appendTo (this .tabs)
76
+
77
+ this .addPanel (id)
78
+ }
79
+
80
+ addPanel (id)
81
+ {
82
+ $("<div></div>")
83
+ .attr ("id", `${id}-tab`)
84
+ .append ($("<div></div>")
85
+ .attr ("id", id)
86
+ .addClass (["tabs-panel", id]))
87
+ .appendTo (this .element)
88
+ }
89
+
90
+ getPanel (id)
91
+ {
92
+ return this .element .find (`.tabs-panel.${id}`)
93
+ }
94
+
95
+ initTab (panel) { }
96
+ }
@@ -0,0 +1,18 @@
1
+ "use strict"
2
+
3
+ const
4
+ Interface = require ("../Application/Interface")
5
+
6
+ module .exports = class AnimationEditor extends Interface
7
+ {
8
+ constructor (element)
9
+ {
10
+ super (`Sunrize.AnimationEditor.${element .attr ("id")}.`)
11
+
12
+ this .animationEditor = element
13
+
14
+ this .animationEditor .text ("Animation Editor")
15
+
16
+ this .setup ()
17
+ }
18
+ }
@@ -0,0 +1,101 @@
1
+ "use strict"
2
+
3
+ const
4
+ $ = require ("jquery"),
5
+ X3D = require ("../X3D"),
6
+ Dialog = require ("../Controls/Dialog"),
7
+ _ = require ("../Application/GetText")
8
+
9
+ module .exports = new class BrowserSize extends Dialog
10
+ {
11
+ constructor ()
12
+ {
13
+ super ("Sunrize.BrowserSize.")
14
+
15
+ this .setup ()
16
+ }
17
+
18
+ initialize ()
19
+ {
20
+ super .initialize ()
21
+
22
+ // Add class.
23
+
24
+ this .element .addClass ("browser-size")
25
+
26
+ this .table = $("<table></table>") .appendTo (this .element)
27
+ this .table .header = $("<thead></thead>") .appendTo (this .table)
28
+ this .table .body = $("<tbody></tbody>") .appendTo (this .table)
29
+
30
+ $("<tr></tr>")
31
+ .append ($("<th></th>")
32
+ .attr ("colspan", "2")
33
+ .text (_ ("Browser Size")))
34
+ .appendTo (this .table .header)
35
+
36
+ this .enabled = $("<input></input>")
37
+ .attr ("id", "browser-size-enabled")
38
+ .attr ("type", "checkbox")
39
+ .on ("change", () => this .onchange ())
40
+
41
+ $("<tr></tr>")
42
+ .append ($("<th></th>"))
43
+ .append ($("<td></td>")
44
+ .append (this .enabled)
45
+ .append ($("<label></label>")
46
+ .attr ("for", "browser-size-enabled")
47
+ .text (_ ("Enabled"))))
48
+ .appendTo (this .table .body)
49
+
50
+ this .numerator = $("<input></input>")
51
+ .attr ("type", "number")
52
+ .attr ("step", "1")
53
+ .css ("width", "calc((100% - 20px) / 2)")
54
+ .on ("change", () => this .onchange ())
55
+
56
+ const slash = $("<span></span>")
57
+ .css ({ "display": "inline-block", "width": "20px", "text-align": "center" })
58
+ .text ("/")
59
+
60
+ this .denominator = $("<input></input>")
61
+ .attr ("type", "number")
62
+ .attr ("step", "1")
63
+ .css ("width", "calc((100% - 20px) / 2)")
64
+ .on ("change", () => this .onchange ())
65
+
66
+ $("<tr></tr>")
67
+ .append ($("<th></th>")
68
+ .text (_ ("Aspect Ratio")))
69
+ .append ($("<td></td>")
70
+ .append (this .numerator)
71
+ .append (slash)
72
+ .append (this .denominator))
73
+ .appendTo (this .table .body)
74
+ }
75
+
76
+ configure ()
77
+ {
78
+ super .configure ({ size: [400, 100] })
79
+
80
+ // Set default config values.
81
+
82
+ this .config .file .addDefaultValues ({
83
+ enabled: false,
84
+ numerator: 1,
85
+ denominator: 1,
86
+ })
87
+
88
+ this .enabled .prop ("checked", this .config .file .enabled)
89
+ this .numerator .val (this .config .file .numerator)
90
+ this .denominator .val (this .config .file .denominator)
91
+ }
92
+
93
+ onchange ()
94
+ {
95
+ this .config .file .enabled = this .enabled .prop ("checked")
96
+ this .config .file .numerator = parseFloat (this .numerator .val ())
97
+ this .config .file .denominator = parseFloat (this .denominator .val ())
98
+
99
+ require ("../Application/Document") .onresize ()
100
+ }
101
+ }
@@ -0,0 +1,239 @@
1
+
2
+ "use strict"
3
+
4
+ const
5
+ $ = require ("jquery"),
6
+ electron = require ("electron"),
7
+ X3D = require ("../X3D"),
8
+ Interface = require ("../Application/Interface"),
9
+ _ = require ("../Application/GetText")
10
+
11
+ module .exports = class Console extends Interface
12
+ {
13
+ HISTORY_MAX = 100
14
+
15
+ logLevels = [
16
+ "debug",
17
+ "log",
18
+ "warn",
19
+ "error",
20
+ ]
21
+
22
+ constructor (element)
23
+ {
24
+ super (`Sunrize.Console.${element .attr ("id")}.`)
25
+
26
+ this .suspendConsole = false;
27
+ this .messageTime = 0
28
+ this .historyIndex = 0
29
+ this .history = [ ]
30
+ this .addMessageCallback = this .addMessage .bind (this)
31
+
32
+ this .console = element
33
+ this .left = $("<div></div>") .addClass ("console-left") .appendTo (this .console)
34
+ this .toolbar = $("<div></div>") .addClass (["toolbar", "vertical-toolbar", "console-toolbar"]) .appendTo (this .console)
35
+ this .output = $("<div></div>") .addClass (["console-output", "output"]) .attr ("tabindex", 0) .appendTo (this .left)
36
+ this .input = $("<div></div>") .addClass ("console-input") .appendTo (this .left)
37
+
38
+ this .suspendButton = $("<span></span>")
39
+ .addClass ("material-icons")
40
+ .attr ("title", _ ("Suspend console output."))
41
+ .text ("cancel")
42
+ .appendTo (this .toolbar)
43
+ .on ("click", () => this .setSuspendConsole (!this .suspendConsole))
44
+
45
+ this .clearButton = $("<span></span>")
46
+ .addClass ("material-icons")
47
+ .attr ("title", _ ("Clear console."))
48
+ .text ("delete_forever")
49
+ .appendTo (this .toolbar)
50
+ .on ("click", () => this .clearConsole ())
51
+
52
+ $("<span></span>") .addClass ("separator") .appendTo (this .toolbar)
53
+
54
+ this .textarea = $("<textarea></textarea>")
55
+ .attr ("placeholder", _ ("Evaluate JavaScript code here."))
56
+ .attr ("tabindex", 0)
57
+ .appendTo (this .input)
58
+ .on ("keydown", (event) => this .onKeyDown (event))
59
+ .on ("keyup", (event) => this .onKeyUp (event))
60
+
61
+ if (this .console .attr ("id") !== "console")
62
+ {
63
+ this .output .html ($("#console .console-output") .html ())
64
+ this .output .scrollTop (this .output .prop ("scrollHeight"))
65
+ }
66
+
67
+ electron .ipcRenderer .on ("console-message", this .addMessageCallback)
68
+
69
+ this .setup ()
70
+ }
71
+
72
+ configure ()
73
+ {
74
+ super .configure ()
75
+
76
+ this .config .file .addDefaultValues ({ history: [ ] })
77
+
78
+ this .history = this .config .file .history .slice (-this .HISTORY_MAX)
79
+ this .historyIndex = this .history .length
80
+ }
81
+
82
+ async setBrowserEvent (event)
83
+ {
84
+ try
85
+ {
86
+ super .setBrowserEvent (event)
87
+
88
+ if (event !== X3D .X3DConstants .INITIALIZED_EVENT)
89
+ return
90
+
91
+ this .scriptNode = this .browser .currentScene .createNode ("Script")
92
+ this .scriptNode .url = new X3D .MFString ("ecmascript:");
93
+ }
94
+ catch (error)
95
+ { }
96
+ }
97
+
98
+ excludes = new Set ([
99
+ "The vm module of Node.js is deprecated in the renderer process and will be removed.",
100
+ ])
101
+
102
+ addMessage (event, level, sourceId, line, message)
103
+ {
104
+ if (this .excludes .has (message))
105
+ return
106
+
107
+ const
108
+ classes = this .logLevels [level] || "log",
109
+ text = $("<p></p>") .addClass (classes) .attr ("title", `${sourceId}:${line}`) .text (message)
110
+
111
+ if (this .messageTime && performance .now () - this .messageTime > 1000)
112
+ text .addClass ("splitter")
113
+
114
+ this .messageTime = performance .now ()
115
+
116
+ this .output .append (text)
117
+ this .output .scrollTop (this .output .prop ("scrollHeight"))
118
+ }
119
+
120
+ setSuspendConsole (value)
121
+ {
122
+ this .suspendConsole = value
123
+
124
+ if (value)
125
+ {
126
+ electron .ipcRenderer .off ("console-message", this .addMessageCallback)
127
+ this .addMessage (null, "info", __filename, 0, `Console output suspended at ${new Date () .toLocaleTimeString ()}.`)
128
+ this .suspendButton .addClass ("active")
129
+ }
130
+ else
131
+ {
132
+ electron .ipcRenderer .on ("console-message", this .addMessageCallback)
133
+ this .addMessage (null, "info", __filename, 0, `Console output enabled at ${new Date () .toLocaleTimeString ()}.`)
134
+ this .suspendButton .removeClass ("active")
135
+ }
136
+ }
137
+
138
+ clearConsole ()
139
+ {
140
+ this .messageTime = 0
141
+
142
+ this .output .empty ()
143
+ this .addMessage (null, "info", __filename, 0, `Console cleared at ${new Date () .toLocaleTimeString ()}.`)
144
+ }
145
+
146
+ onKeyDown (event)
147
+ {
148
+ switch (event .key)
149
+ {
150
+ case "Enter":
151
+ {
152
+ this .evaluateSourceCode (event)
153
+ return
154
+ }
155
+ case "ArrowUp":
156
+ {
157
+ if (this .historyIndex === this .history .length)
158
+ {
159
+ const text = this .textarea .val () .trim ()
160
+
161
+ if (text && text !== this .history .at (-1))
162
+ this .history .push (text)
163
+ }
164
+
165
+ this .config .file .history = this .history
166
+
167
+ this .historyIndex = Math .max (this .historyIndex - 1, 0)
168
+
169
+ if (this .historyIndex < this .history .length)
170
+ this .textarea .val (this .history [this .historyIndex])
171
+
172
+ this .adjustTextAreaHeight ()
173
+ return
174
+ }
175
+ case "ArrowDown":
176
+ {
177
+ this .historyIndex = Math .min (this .historyIndex + 1, this .history .length - 1)
178
+
179
+ if (this .historyIndex < this .history .length)
180
+ this .textarea .val (this .history [this .historyIndex])
181
+
182
+ this .adjustTextAreaHeight ()
183
+ return
184
+ }
185
+ }
186
+ }
187
+
188
+ onKeyUp (event)
189
+ {
190
+ this .adjustTextAreaHeight ()
191
+ }
192
+
193
+ adjustTextAreaHeight ()
194
+ {
195
+ const div = $("<div></div>")
196
+ .css ({
197
+ "width": `${this .textarea .width ()}px`,
198
+ "white-space": "pre-wrap",
199
+ "word-wrap": "break-word",
200
+ })
201
+ .text (this .textarea .val ())
202
+ .appendTo ($("body"))
203
+
204
+ this .input .css ("height", `${div .height () + 5}px`)
205
+ this .output .css ("height", `calc(100% - ${this .input .height ()}px)`)
206
+
207
+ div .remove ()
208
+ }
209
+
210
+ evaluateSourceCode (event)
211
+ {
212
+ event .preventDefault ()
213
+
214
+ const text = this .textarea .val () .trim ()
215
+
216
+ if (!text)
217
+ return
218
+
219
+ if (text !== this .history .at (-1))
220
+ this .history .push (text)
221
+
222
+ this .config .file .history = this .history
223
+
224
+ this .historyIndex = this .history .length
225
+
226
+ console .info (text)
227
+
228
+ try
229
+ {
230
+ console .debug ("" + this .scriptNode .getValue () .evaluate (text))
231
+ }
232
+ catch (error)
233
+ {
234
+ console .error (`${error .name}: ${error .message}`)
235
+ }
236
+
237
+ this .textarea .val ("")
238
+ }
239
+ }
@@ -0,0 +1,18 @@
1
+ "use strict"
2
+
3
+ const
4
+ Interface = require ("../Application/Interface")
5
+
6
+ module .exports = class FileManager extends Interface
7
+ {
8
+ constructor (element)
9
+ {
10
+ super (`Sunrize.FileManager.${element .attr ("id")}.`)
11
+
12
+ this .fileManager = element
13
+
14
+ this .fileManager .text ("File Manager")
15
+
16
+ this .setup ()
17
+ }
18
+ }