nadesiko3 3.2.27

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 (283) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/bin/cnako3 +10 -0
  4. package/bin/cnako3.bat +11 -0
  5. package/bin/nako3server.bat +6 -0
  6. package/demo/ace_editor.html +90 -0
  7. package/demo/ace_editor_tabs.html +162 -0
  8. package/demo/basic.html +71 -0
  9. package/demo/browsers.html +128 -0
  10. package/demo/css/basic.css +3 -0
  11. package/demo/css/common.css +157 -0
  12. package/demo/css/editor.css +8 -0
  13. package/demo/css/flow.css +3 -0
  14. package/demo/css/index.css +3 -0
  15. package/demo/extlib/ace@1.4.12/ace.js +17 -0
  16. package/demo/extlib/ace@1.4.12/ext-code_lens.min.js +1 -0
  17. package/demo/extlib/ace@1.4.12/ext-language_tools.min.js +1 -0
  18. package/demo/extlib/ace@1.4.12/ext-options.min.js +1 -0
  19. package/demo/extlib/ace@1.4.12/ext-settings_menu.js +8 -0
  20. package/demo/extlib/ace@1.4.12/keybinding-vscode.js +8 -0
  21. package/demo/extlib/ace@1.4.12/theme-monokai.js +8 -0
  22. package/demo/extlib/ace@1.4.12/theme-xcode.js +8 -0
  23. package/demo/extlib/chart.js@3.2.1/chart.min.js +13 -0
  24. package/demo/extlib/pure-min.css +11 -0
  25. package/demo/flow.html +97 -0
  26. package/demo/graph.html +53 -0
  27. package/demo/image/nako.png +0 -0
  28. package/demo/image/nakopad-icon256.png +0 -0
  29. package/demo/image/turtle.fla +0 -0
  30. package/demo/image/turtle.png +0 -0
  31. package/demo/index.html +134 -0
  32. package/demo/js/common.js +17 -0
  33. package/demo/js/turtle3d_test.js +44 -0
  34. package/demo/js/turtle_test.js +44 -0
  35. package/demo/runscript.html +47 -0
  36. package/demo/runscript2.html +33 -0
  37. package/demo/turtle.html +58 -0
  38. package/demo/turtle2.html +141 -0
  39. package/demo/turtle3.html +278 -0
  40. package/demo/turtle3d.html +58 -0
  41. package/demo/turtle3d2.html +107 -0
  42. package/demo/version.html +24 -0
  43. package/doc/SETUP.md +172 -0
  44. package/doc/about.md +34 -0
  45. package/doc/browsers.md +60 -0
  46. package/doc/docgen.md +21 -0
  47. package/doc/editor.md +44 -0
  48. package/doc/files.md +37 -0
  49. package/doc/plugins.md +195 -0
  50. package/doc/release.md +78 -0
  51. package/doc/win32.md +57 -0
  52. package/package.json +196 -0
  53. package/release/_hash.txt +65 -0
  54. package/release/_script-tags.txt +13 -0
  55. package/release/command.json +1 -0
  56. package/release/command.json.js +1 -0
  57. package/release/command_cnako3.json +1 -0
  58. package/release/command_list.json +1 -0
  59. package/release/editor.js +2 -0
  60. package/release/editor.js.LICENSE.txt +32 -0
  61. package/release/josi.json +48 -0
  62. package/release/nako_gen_async.js +1 -0
  63. package/release/nako_gen_async.js.LICENSE.txt +595 -0
  64. package/release/plugin_caniuse.js +1 -0
  65. package/release/plugin_caniuse.js.LICENSE.txt +411 -0
  66. package/release/plugin_csv.js +1 -0
  67. package/release/plugin_csv.js.LICENSE.txt +367 -0
  68. package/release/plugin_datetime.js +1 -0
  69. package/release/plugin_datetime.js.LICENSE.txt +471 -0
  70. package/release/plugin_kansuji.js +1 -0
  71. package/release/plugin_kansuji.js.LICENSE.txt +491 -0
  72. package/release/plugin_markup.js +1 -0
  73. package/release/plugin_markup.js.LICENSE.txt +363 -0
  74. package/release/plugin_turtle.js +1 -0
  75. package/release/plugin_turtle.js.LICENSE.txt +435 -0
  76. package/release/plugin_webworker.js +1 -0
  77. package/release/plugin_webworker.js.LICENSE.txt +491 -0
  78. package/release/version.js +2 -0
  79. package/release/version.js.LICENSE.txt +32 -0
  80. package/release/wnako3.js +2 -0
  81. package/release/wnako3.js.LICENSE.txt +1 -0
  82. package/release/wnako3webworker.js +1 -0
  83. package/release/wnako3webworker.js.LICENSE.txt +847 -0
  84. package/release/yoyakugo.json +30 -0
  85. package/src/browsers.md +60 -0
  86. package/src/cnako3.js +466 -0
  87. package/src/commander_ja.js +154 -0
  88. package/src/enako3.js +69 -0
  89. package/src/era.json +22 -0
  90. package/src/index.js +5 -0
  91. package/src/nako3.js +836 -0
  92. package/src/nako3_assert.js +37 -0
  93. package/src/nako3editorfix.sfd +106 -0
  94. package/src/nako3editorfix.woff +0 -0
  95. package/src/nako3server.js +51 -0
  96. package/src/nako_colors.js +86 -0
  97. package/src/nako_errors.js +176 -0
  98. package/src/nako_gen.js +1459 -0
  99. package/src/nako_gen_async.js +1622 -0
  100. package/src/nako_global.js +113 -0
  101. package/src/nako_indent.js +480 -0
  102. package/src/nako_josi_list.js +46 -0
  103. package/src/nako_lex_rules.js +259 -0
  104. package/src/nako_lexer.js +576 -0
  105. package/src/nako_logger.js +138 -0
  106. package/src/nako_parser3.js +1768 -0
  107. package/src/nako_parser_base.js +265 -0
  108. package/src/nako_parser_const.js +37 -0
  109. package/src/nako_prepare.js +293 -0
  110. package/src/nako_reserved_words.js +35 -0
  111. package/src/nako_source_mapping.js +251 -0
  112. package/src/nako_test.js +37 -0
  113. package/src/nako_version.js +8 -0
  114. package/src/plugin_browser.js +191 -0
  115. package/src/plugin_browser_ajax.js +352 -0
  116. package/src/plugin_browser_audio.js +109 -0
  117. package/src/plugin_browser_canvas.js +462 -0
  118. package/src/plugin_browser_chart.js +296 -0
  119. package/src/plugin_browser_color.js +49 -0
  120. package/src/plugin_browser_crypto.js +26 -0
  121. package/src/plugin_browser_dialog.js +53 -0
  122. package/src/plugin_browser_dom_basic.js +322 -0
  123. package/src/plugin_browser_dom_event.js +193 -0
  124. package/src/plugin_browser_dom_parts.js +163 -0
  125. package/src/plugin_browser_geolocation.js +51 -0
  126. package/src/plugin_browser_hotkey.js +25 -0
  127. package/src/plugin_browser_html.js +59 -0
  128. package/src/plugin_browser_in_worker.js +44 -0
  129. package/src/plugin_browser_location.js +21 -0
  130. package/src/plugin_browser_speech.js +111 -0
  131. package/src/plugin_browser_storage.js +121 -0
  132. package/src/plugin_browser_system.js +12 -0
  133. package/src/plugin_browser_websocket.js +73 -0
  134. package/src/plugin_caniuse.js +24 -0
  135. package/src/plugin_csv.js +57 -0
  136. package/src/plugin_datetime.js +414 -0
  137. package/src/plugin_express.js +212 -0
  138. package/src/plugin_kansuji.js +224 -0
  139. package/src/plugin_keigo.js +55 -0
  140. package/src/plugin_markup.js +32 -0
  141. package/src/plugin_math.js +319 -0
  142. package/src/plugin_node.js +1018 -0
  143. package/src/plugin_promise.js +94 -0
  144. package/src/plugin_system.js +2109 -0
  145. package/src/plugin_test.js +38 -0
  146. package/src/plugin_turtle.js +646 -0
  147. package/src/plugin_webworker.js +334 -0
  148. package/src/plugin_weykturtle3d.js +1216 -0
  149. package/src/plugin_worker.js +92 -0
  150. package/src/repl.nako3 +63 -0
  151. package/src/turtle-elephant.png +0 -0
  152. package/src/turtle-panda.png +0 -0
  153. package/src/turtle64.png +0 -0
  154. package/src/wnako3.js +162 -0
  155. package/src/wnako3_editor.css +215 -0
  156. package/src/wnako3_editor.js +1645 -0
  157. package/src/wnako3_editor_marker_red.png +0 -0
  158. package/src/wnako3_editor_marker_red.xcf +0 -0
  159. package/src/wnako3_editor_marker_yellow.png +0 -0
  160. package/src/wnako3_editor_marker_yellow.xcf +0 -0
  161. package/src/wnako3webworker.js +70 -0
  162. package/test/ace_editor/karma.config.js +94 -0
  163. package/test/ace_editor/test/.babelrc.json +3 -0
  164. package/test/ace_editor/test/ace_editor_test.js +178 -0
  165. package/test/ace_editor/test/html/custom_context.html +140 -0
  166. package/test/async/async_basic_test.js +124 -0
  167. package/test/browser/karma.config.js +212 -0
  168. package/test/browser/test/.babelrc.json +3 -0
  169. package/test/browser/test/compare_util.js +50 -0
  170. package/test/browser/test/html/canvas_basic.html +1 -0
  171. package/test/browser/test/html/div_basic.html +2 -0
  172. package/test/browser/test/html/event_dom_form.html +4 -0
  173. package/test/browser/test/html/event_dom_scrolldiv.html +5 -0
  174. package/test/browser/test/image/canvas_test1.png +0 -0
  175. package/test/browser/test/image/canvas_test2.png +0 -0
  176. package/test/browser/test/image/canvas_test3.png +0 -0
  177. package/test/browser/test/image/canvas_test4.png +0 -0
  178. package/test/browser/test/image/canvas_test7.png +0 -0
  179. package/test/browser/test/image/canvas_test8.png +0 -0
  180. package/test/browser/test/image/canvas_test_blank.png +0 -0
  181. package/test/browser/test/image/elephant_kana.png +0 -0
  182. package/test/browser/test/image/panda_kana.png +0 -0
  183. package/test/browser/test/image/turtle_kana.png +0 -0
  184. package/test/browser/test/import_plugin_checker.js +24 -0
  185. package/test/browser/test/plugin_browser_test.js +52 -0
  186. package/test/browser/test/plugin_browser_test_ajax.js +123 -0
  187. package/test/browser/test/plugin_browser_test_color.js +18 -0
  188. package/test/browser/test/plugin_browser_test_dialog.js +72 -0
  189. package/test/browser/test/plugin_browser_test_dom_event.js +598 -0
  190. package/test/browser/test/plugin_browser_test_dom_parts.js +125 -0
  191. package/test/browser/test/plugin_browser_test_system.js +9 -0
  192. package/test/browser/test/plugin_turtle_test.js +817 -0
  193. package/test/browser/test/plugin_webworker_test.js +87 -0
  194. package/test/browser/test/require_test.js +71 -0
  195. package/test/bundled/karma.config.base.js +117 -0
  196. package/test/bundled/karma.config.js +86 -0
  197. package/test/bundled/test/.babelrc.json +3 -0
  198. package/test/bundled/test/bundled_test.js +69 -0
  199. package/test/bundled/test/html/custom_context.html +65 -0
  200. package/test/bundled/test/html/custom_debug.html +66 -0
  201. package/test/bundled/test4b.cmd +52 -0
  202. package/test/bundled/test_base/.babelrc.json +3 -0
  203. package/test/bundled/test_base/_checktool_test.js +25 -0
  204. package/test/bundled/test_base/basic_ajax_test.js +56 -0
  205. package/test/bundled/test_base/basic_async_test.js +18 -0
  206. package/test/bundled/test_base/basic_test.js +153 -0
  207. package/test/bundled/test_base/calc_test.js +132 -0
  208. package/test/bundled/test_base/css/browsers_box.css +114 -0
  209. package/test/bundled/test_base/html/custom_context.html +69 -0
  210. package/test/bundled/test_base/html/custom_debug.html +71 -0
  211. package/test/bundled/test_base/js/browsers_box.js +72 -0
  212. package/test/bundled/test_base/plugin_csv_test.js +37 -0
  213. package/test/bundled/test_base/plugin_datetime_test.js +115 -0
  214. package/test/bundled/test_base/plugin_kansuji_test.js +49 -0
  215. package/test/bundled/test_base/plugin_system_test.js +410 -0
  216. package/test/bundled/test_base/plugin_webworker_test.js +53 -0
  217. package/test/bundled/test_base/resources/ok.txt +1 -0
  218. package/test/bundled/test_base/test_utils.js +191 -0
  219. package/test/common/array_test.js +40 -0
  220. package/test/common/basic_test.js +317 -0
  221. package/test/common/calc_test.js +139 -0
  222. package/test/common/debug_test.js +16 -0
  223. package/test/common/error_test.js +16 -0
  224. package/test/common/flow_test.js +360 -0
  225. package/test/common/func_call.js +136 -0
  226. package/test/common/func_test.js +149 -0
  227. package/test/common/indent_test.js +362 -0
  228. package/test/common/lex_test.js +146 -0
  229. package/test/common/literal_test.js +72 -0
  230. package/test/common/nako_logger_test.js +26 -0
  231. package/test/common/plugin_browser_test.js +24 -0
  232. package/test/common/plugin_browser_ut_audio_test.js +88 -0
  233. package/test/common/plugin_browser_ut_color_test.js +21 -0
  234. package/test/common/plugin_browser_ut_dialog_test.js +100 -0
  235. package/test/common/plugin_browser_ut_html_test.js +13 -0
  236. package/test/common/plugin_browser_ut_system_test.js +10 -0
  237. package/test/common/plugin_csv_test.js +39 -0
  238. package/test/common/plugin_datetime_test.js +120 -0
  239. package/test/common/plugin_kansuji_test.js +59 -0
  240. package/test/common/plugin_promise_test.js +18 -0
  241. package/test/common/plugin_system_test.js +451 -0
  242. package/test/common/prepare_test.js +93 -0
  243. package/test/common/re_test.js +20 -0
  244. package/test/common/variable_scope_test.js +105 -0
  245. package/test/jsconfig.json +19 -0
  246. package/test/karma.config.js +91 -0
  247. package/test/node/add_test.nako3 +1 -0
  248. package/test/node/async_test.js +80 -0
  249. package/test/node/commander_ja_test.js +82 -0
  250. package/test/node/error_message_test.js +244 -0
  251. package/test/node/kai_test.nako3 +6 -0
  252. package/test/node/node_test.js +43 -0
  253. package/test/node/plugin_broken.js.txt +3 -0
  254. package/test/node/plugin_browser_ut_ajax_test.js +355 -0
  255. package/test/node/plugin_browser_ut_location_test.js +32 -0
  256. package/test/node/plugin_markup_test.js +44 -0
  257. package/test/node/plugin_math_test.js +42 -0
  258. package/test/node/plugin_node_test.js +93 -0
  259. package/test/node/plugin_test.js +16 -0
  260. package/test/node/relative_import_test_1.nako3 +1 -0
  261. package/test/node/relative_import_test_2.nako3 +2 -0
  262. package/test/node/require_nako3_test.js +59 -0
  263. package/test/node/requiretest.nako3 +4 -0
  264. package/test/node/requiretest_indirect.nako3 +1 -0
  265. package/test/node/requiretest_name.nako3 +5 -0
  266. package/test/node/runtime_error.nako3 +2 -0
  267. package/test/node/side_effects_test.js +106 -0
  268. package/test/node/sjis.txt +5 -0
  269. package/test/node/syntax_error.nako3 +2 -0
  270. package/test/node/wnako3_editor_test.js +360 -0
  271. package/tools/README.md +7 -0
  272. package/tools/nako3edit/html/edit.html +83 -0
  273. package/tools/nako3edit/html/edit_plugin.js +6 -0
  274. package/tools/nako3edit/html/files.html +49 -0
  275. package/tools/nako3edit/html/nako3edit.css +66 -0
  276. package/tools/nako3edit/index.nako3 +145 -0
  277. package/tools/nako3edit/run.js +12 -0
  278. package/tools/nako3server/html/edit.html +104 -0
  279. package/tools/nako3server/html/edit_plugin.js +6 -0
  280. package/tools/nako3server/html/files.html +53 -0
  281. package/tools/nako3server/html/nako3edit.css +66 -0
  282. package/tools/nako3server/index.nako3 +129 -0
  283. package/tools/nako3server/run.js +12 -0
@@ -0,0 +1,1216 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * PluginWeykTurtle3D
4
+ */
5
+ let THREE = window.THREE
6
+
7
+ const PluginWeykTurtle3D = {
8
+ '初期化': {
9
+ type: 'func',
10
+ josi: [],
11
+ pure: true,
12
+ fn: function (sys) {
13
+ if (sys._weykturtle3d) { return }
14
+ if (typeof window.THREE === 'undefined') {
15
+ throw new Error('three.jsが読み込まれていません')
16
+ }
17
+ THREE = window.THREE // set three.js instance
18
+ sys._weykturtle3d = {
19
+ containerid: '',
20
+ camera: -1,
21
+ target: -1,
22
+ _renderer: null,
23
+ _scene: null,
24
+ _lines: new THREE.Group(),
25
+ _camera: null,
26
+ _controls: null,
27
+ _camerahelper: null,
28
+ _axishelper: null,
29
+ list: [],
30
+ clearAll: function () {
31
+ console.log('[TURTLE] clearAll')
32
+ this.disposeAllTurtle()
33
+ this.disposeAllLine()
34
+ const scene = this._scene
35
+ if (scene !== null) {
36
+ scene.remove(this._lines)
37
+ scene.add(this._lines)
38
+ if (this._camerahelper !== null) {
39
+ this._camerahelper.visible = false
40
+ scene.remove(this._camerahelper)
41
+ scene.add(this._camerahelper)
42
+ }
43
+ if (this._axishelper !== null) {
44
+ this._axishelper.visible = false
45
+ scene.remove(this._axishelper)
46
+ scene.add(this._axishelper)
47
+ }
48
+ this.initTurtle()
49
+ }
50
+ },
51
+ disposeAllTurtle: function () {
52
+ // カメをクリア
53
+ for (let i = 0; i < this.list.length; i++) {
54
+ const tt = this.list[i]
55
+ tt.mlist = [] // ジョブをクリア
56
+ // かめのモデルをカメから削除
57
+ this.disposeChildObject(tt.obj)
58
+ }
59
+ this.list = []
60
+ this.target = -1
61
+ this.camera = -1
62
+ this.flagSetTimer = false
63
+ },
64
+ disposeAllLine: function () {
65
+ // 引いた線を線用のバッファからクリア
66
+ if (this._lines !== null) {
67
+ this.disposeChildObject(this._lines)
68
+ }
69
+ },
70
+ createDefaultTurtle: function () {
71
+ const obj = new THREE.Group()
72
+
73
+ const material = new THREE.LineBasicMaterial({ vertexColors: true })
74
+
75
+ const vertices = new Float32Array([
76
+ 0.0, 1.0, 0.0,
77
+ -0.6, -1.0, 0.0,
78
+ 0.0, -0.5, 0.0,
79
+ 0.6, -1.0, 0.0,
80
+
81
+ 0.0, 0.0, 0.5,
82
+ 0.0, 1.0, 0.0,
83
+ -0.6, -1.0, 0.0,
84
+ 0.0, -0.5, 0.0,
85
+ 0.6, -1.0, 0.0,
86
+
87
+ 0.0, 0.0, -0.5,
88
+ 0.0, 1.0, 0.0,
89
+ -0.6, -1.0, 0.0,
90
+ 0.0, -0.5, 0.0,
91
+ 0.6, -1.0, 0.0
92
+ ])
93
+
94
+ const colors = new Float32Array([
95
+ 0.0, 1.0, 0.0,
96
+ 0.0, 1.0, 0.0,
97
+ 0.0, 1.0, 0.0,
98
+ 0.0, 1.0, 0.0,
99
+
100
+ 1.0, 0.0, 0.0,
101
+ 1.0, 0.0, 0.0,
102
+ 1.0, 0.0, 0.0,
103
+ 1.0, 0.0, 0.0,
104
+ 1.0, 0.0, 0.0,
105
+
106
+ 0.0, 0.0, 1.0,
107
+ 0.0, 0.0, 1.0,
108
+ 0.0, 0.0, 1.0,
109
+ 0.0, 0.0, 1.0,
110
+ 0.0, 0.0, 1.0
111
+ ])
112
+
113
+ const indices = [
114
+ 0, 1, 1, 2, 2, 3, 3, 0,
115
+ 4, 5, 4, 6, 4, 7, 4, 8,
116
+ 9, 10, 9, 11, 9, 12, 9, 13
117
+ ]
118
+
119
+ const geometry = new THREE.BufferGeometry()
120
+ geometry.setIndex(indices)
121
+ geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
122
+ geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3))
123
+ geometry.computeBoundingSphere()
124
+
125
+ const lineSegments = new THREE.LineSegments(geometry, material)
126
+ lineSegments.scale.set(30.0, 30.0, 30.0)
127
+
128
+ obj.add(lineSegments)
129
+ return obj
130
+ },
131
+ createTurtle: function (modelUrl) {
132
+ // カメの情報を sys._turtle リストに追加
133
+ const id = this.list.length
134
+ const tt = {
135
+ id: id,
136
+ obj: new THREE.Group(),
137
+ home: {
138
+ position: new THREE.Vector3(0, 0, 0),
139
+ quaternion: new THREE.Quaternion()
140
+ },
141
+ color: new THREE.Color(0xffffff),
142
+ lineWidth: 4,
143
+ flagDown: true,
144
+ flagLoaded: false,
145
+ f_visible: true,
146
+ mlist: []
147
+ }
148
+ this.list.push(tt)
149
+ this.target = id
150
+ tt.home.position.copy(tt.obj.position)
151
+ tt.home.quaternion.copy(tt.obj.quaternion)
152
+ this.loadTurtle(tt, modelUrl)
153
+ const scene = this.getScene()
154
+ scene.add(tt.obj)
155
+ return id
156
+ },
157
+ loadTurtle: function (tt, url) {
158
+ const loader = new THREE.ObjectLoader()
159
+ const me = this
160
+ if (url instanceof THREE.Object3D) {
161
+ console.log('turtle.object')
162
+ me.disposeChildObject(tt.obj)
163
+ const obj = url
164
+ tt.obj.add(obj)
165
+ tt.flagLoaded = true
166
+ me.doDraw()
167
+ return
168
+ }
169
+ if (url.length === 0) {
170
+ console.log('turtle.default')
171
+ me.disposeChildObject(tt.obj)
172
+ const obj = me.createDefaultTurtle()
173
+ tt.obj.add(obj)
174
+ tt.flagLoaded = true
175
+ me.doDraw()
176
+ return
177
+ }
178
+ loader.load(url, function (obj) {
179
+ console.log('turtle.onload')
180
+ me.disposeChildObject(tt.obj)
181
+ tt.obj.add(obj)
182
+ tt.flagLoaded = true
183
+ me.doDraw()
184
+ }, function (xhr) {
185
+ // nothing
186
+ }, function (xhr) {
187
+ console.log('turtle.onerror')
188
+ tt.flagLoaded = true
189
+ tt.f_visible = false
190
+ tt.obj.visible = false
191
+ me.disposeChildObject(tt.obj)
192
+ me.doDraw()
193
+ })
194
+ },
195
+ initTurtle: function () {
196
+ if (this.list.length === 0) {
197
+ const index = this.createTurtle('')
198
+ const tt = this.list[index]
199
+ tt.obj.position.set(0, 0, 1000)
200
+ const axis = new THREE.Vector3(0, 0, -1).normalize()
201
+ const angle = 0
202
+ tt.obj.quaternion.setFromAxisAngle(axis, angle)
203
+ tt.home.position.copy(tt.obj.position)
204
+ tt.home.quaternion.copy(tt.obj.quaternion)
205
+ tt.f_visible = false
206
+ tt.obj.visible = false
207
+ this.camera = index
208
+ this.target = -1
209
+ }
210
+ },
211
+ getCur: function () {
212
+ if (this.list.length === 0) {
213
+ throw Error('最初に『T3Dカメ作成』命令を呼び出してください。')
214
+ }
215
+ if (this.target < 0 || this.target >= this.list.length) {
216
+ throw Error('指定された番号のカメはいません。')
217
+ }
218
+ return this.list[this.target]
219
+ },
220
+ doDraw: function () {
221
+ if (this.camera === -1) { return }
222
+ this.getRenderer()
223
+ const camera = this.list[this.camera]
224
+ if (this._controls !== null) { //
225
+ } else {
226
+ this._camera.position.copy(camera.obj.position)
227
+ this._camera.quaternion.copy(camera.obj.quaternion)
228
+ }
229
+ if (this._camerahelper !== null) {
230
+ this._camerahelper.update()
231
+ }
232
+ this._renderer.clear()
233
+ if (this._controls !== null) {
234
+ this._controls.update()
235
+ camera.obj.position.copy(this._camera.position)
236
+ camera.obj.quaternion.copy(this._camera.quaternion)
237
+ }
238
+ this._renderer.render(this._scene, this._camera)
239
+ },
240
+ setCameraHelper: function (flag) {
241
+ if (flag) {
242
+ if (this._camerahelper === null) {
243
+ if (typeof THREE.CameraHelper === 'undefined') {
244
+ throw Error('カメラヘルパの機能が見当たりません。')
245
+ }
246
+ const cameraHelper = new THREE.CameraHelper(this._camera)
247
+ this._camerahelper = cameraHelper
248
+ this._scene.add(cameraHelper)
249
+ }
250
+ this._camerahelper.visible = true
251
+ } else {
252
+ if (this._camerahelper !== null) {
253
+ this._camerahelper.visible = false
254
+ }
255
+ }
256
+ },
257
+ setAxisHelper: function (flag) {
258
+ if (flag) {
259
+ if (this._axishelper === null) {
260
+ if (typeof THREE.AxisHelper === 'undefined') {
261
+ throw Error('AXISヘルパの機能が見当たりません。')
262
+ }
263
+ const axisHelper = new THREE.AxisHelper(1000)
264
+ this._axishelper = axisHelper
265
+ this._scene.add(axisHelper)
266
+ }
267
+ this._axishelper.visible = true
268
+ } else {
269
+ if (this._axishelper !== null) {
270
+ this._axishelper.visible = false
271
+ }
272
+ }
273
+ },
274
+ getScene: function () {
275
+ if (this._scene === null) {
276
+ const scene = new THREE.Scene()
277
+ if (scene === null) {
278
+ throw new Error('シーンを作成できません')
279
+ }
280
+ this._scene = scene
281
+ }
282
+ return this._scene
283
+ },
284
+ getCamera: function () {
285
+ if (this._camera === null) {
286
+ const camera = new THREE.PerspectiveCamera(60, 1.0, 1, 65000)
287
+ if (camera === null) {
288
+ throw new Error('カメラを作成できません')
289
+ }
290
+ this.resetCamera(camera)
291
+ this._camera = camera
292
+ }
293
+ return this._camera
294
+ },
295
+ resetCamera: function (camera) {
296
+ camera.position.set(0, 0, 1000)
297
+ if (this._renderer !== null) {
298
+ const rect = new THREE.Vector2()
299
+ this._renderer.getSize(rect)
300
+ camera.aspect = rect.width / rect.height
301
+ }
302
+ camera.up = new THREE.Vector3(0, 1, 0)
303
+ camera.lookAt(new THREE.Vector3(0, 0, 0))
304
+ },
305
+ initTrutle3dEnv: function (renderer) {
306
+ renderer.setClearColor(0x000000, 1.0)
307
+ renderer.autoClear = false
308
+
309
+ const scene = this.getScene()
310
+ // eslint-disable-next-line no-unused-vars
311
+ const camera = this.getCamera()
312
+
313
+ scene.add(sys._weykturtle3d._lines)
314
+ if (this.list.length === 0) {
315
+ this.initTurtle()
316
+ }
317
+ },
318
+ initRenderer: function () {
319
+ // 描画先をセットする
320
+ let to = sys.__v0['T3Dカメ描画先']
321
+ if (typeof to === 'string') { to = document.querySelector(to) || document.getElementById(to) }
322
+ if (!to) {
323
+ throw new Error('[ERROR] T3Dカメ描画先が見当たりません。')
324
+ }
325
+ this.setRenderer(to)
326
+ },
327
+ setRenderer: function (to) {
328
+ if (to instanceof THREE.WebGLRenderer) {
329
+ this._renderer = to
330
+ } else {
331
+ const renderer = new THREE.WebGLRenderer({ antialias: false, alpha: true })
332
+ if (renderer === null) {
333
+ throw new Error('レンダラを作成できません')
334
+ }
335
+ renderer.setPixelRatio(window.devicePixelRatio)
336
+ renderer.setSize(to.clientWidth, to.clientHeight)
337
+ to.appendChild(renderer.domElement)
338
+ this._renderer = renderer
339
+ }
340
+ return this._renderer
341
+ },
342
+ setupRenderer: function () {
343
+ this.initTrutle3dEnv(this._renderer)
344
+ },
345
+ getRenderer: function () {
346
+ if (this._renderer === null) {
347
+ this.initRenderer()
348
+ this.setupRenderer()
349
+ }
350
+ return this._renderer
351
+ },
352
+ setupControl: function (controlConstrucor) {
353
+ if (typeof controlConstrucor === 'undefined') {
354
+ throw new Error('指定されたコンコントロールが見当たりません。')
355
+ }
356
+ if (this._controls !== null) {
357
+ if (this._controls instanceof controlConstrucor) {
358
+ return this._controls
359
+ } else {
360
+ throw new Error('既にコントロールを適用しています。コントロールの変更はできません。')
361
+ }
362
+ }
363
+ const renderer = this.getRenderer()
364
+ const camera = this.getCamera(renderer)
365
+ // eslint-disable-next-line new-cap
366
+ const controls = new controlConstrucor(camera, renderer.domElement)
367
+ controls.enabled = true
368
+ this._controls = controls
369
+ return this._controls
370
+ },
371
+ line: function (tt, v1, v2) {
372
+ if (tt) {
373
+ if (!tt.flagDown) { return }
374
+ }
375
+ const geometry = new THREE.BufferGeometry()
376
+ const vertices = new THREE.Float32BufferAttribute(6, 3)
377
+ vertices.copyVector3sArray([v1, v2])
378
+ const material = new THREE.LineBasicMaterial({ color: tt.color, linewidth: tt.lineWidth })
379
+ geometry.setAttribute('position', vertices)
380
+ const line = new THREE.Line(geometry, material)
381
+ this._lines.add(line)
382
+ },
383
+ doMacro: function (tt, wait) {
384
+ const me = this
385
+ if (!tt.flagLoaded && wait > 0) {
386
+ console.log('[TURTLE] waiting ...')
387
+ return true
388
+ }
389
+ const m = tt.mlist.shift()
390
+ const cmd = (m !== undefined) ? m[0] : ''
391
+ switch (cmd) {
392
+ case 'xyz':
393
+ // 起点を移動する
394
+ tt.obj.position.copy(m[1])
395
+ break
396
+ case 'mv': {
397
+ const v1 = tt.obj.position.clone()
398
+ const v2 = m[1]
399
+ // 線を引く
400
+ this.line(tt, v1, v2)
401
+ // カメの角度を変更
402
+ tt.obj.lookAt(v2)
403
+ const headup90 = new THREE.Quaternion()
404
+ const axisX = new THREE.Vector3(1, 0, 0)
405
+ headup90.setFromAxisAngle(axisX, Math.PI / 2)
406
+ tt.obj.quaternion.multiply(headup90)
407
+ // カメを移動
408
+ tt.obj.position.copy(v2)
409
+ break
410
+ }
411
+ case 'fd': {
412
+ const v1 = tt.obj.position.clone()
413
+ const v2 = new THREE.Vector3(0, m[1] * m[2], 0)
414
+ v2.applyQuaternion(tt.obj.quaternion)
415
+ v2.add(v1)
416
+ this.line(tt, v1, v2)
417
+ tt.obj.position.copy(v2)
418
+ break
419
+ }
420
+ case 'su': {
421
+ const v1 = tt.obj.position.clone()
422
+ const v2 = new THREE.Vector3(0, m[1], 0)
423
+ const modifier = new THREE.Quaternion()
424
+ const axis = new THREE.Vector3(1, 0, 0)
425
+ modifier.setFromAxisAngle(axis, (-90) * Math.PI / 180)
426
+ const target = tt.obj.quaternion.clone()
427
+ target.multiply(modifier)
428
+ v2.applyQuaternion(target)
429
+ v2.add(v1)
430
+ this.line(tt, v1, v2)
431
+ tt.obj.position.copy(v2)
432
+ break
433
+ }
434
+ case 'sd': {
435
+ const v1 = tt.obj.position.clone()
436
+ const v2 = new THREE.Vector3(0, m[1], 0)
437
+ const modifier = new THREE.Quaternion()
438
+ const axis = new THREE.Vector3(1, 0, 0)
439
+ modifier.setFromAxisAngle(axis, 90 * Math.PI / 180)
440
+ const target = tt.obj.quaternion.clone()
441
+ target.multiply(modifier)
442
+ v2.applyQuaternion(target)
443
+ v2.add(v1)
444
+ this.line(tt, v1, v2)
445
+ tt.obj.position.copy(v2)
446
+ break
447
+ }
448
+ case 'sl': {
449
+ const v1 = tt.obj.position.clone()
450
+ const v2 = new THREE.Vector3(0, m[1], 0)
451
+ const modifier = new THREE.Quaternion()
452
+ const axis = new THREE.Vector3(0, 0, 1)
453
+ modifier.setFromAxisAngle(axis, 90 * Math.PI / 180)
454
+ const target = tt.obj.quaternion.clone()
455
+ target.multiply(modifier)
456
+ v2.applyQuaternion(target)
457
+ v2.add(v1)
458
+ this.line(tt, v1, v2)
459
+ tt.obj.position.copy(v2)
460
+ break
461
+ }
462
+ case 'sr': {
463
+ const v1 = tt.obj.position.clone()
464
+ const v2 = new THREE.Vector3(0, m[1], 0)
465
+ const modifier = new THREE.Quaternion()
466
+ const axis = new THREE.Vector3(0, 0, 1)
467
+ modifier.setFromAxisAngle(axis, (-90) * Math.PI / 180)
468
+ const target = tt.obj.quaternion.clone()
469
+ target.multiply(modifier)
470
+ v2.applyQuaternion(target)
471
+ v2.add(v1)
472
+ this.line(tt, v1, v2)
473
+ tt.obj.position.copy(v2)
474
+ break
475
+ }
476
+ case 'angle': {
477
+ const euler = new THREE.Euler()
478
+ euler.fromArray(m[1])
479
+ // eslint-disable-next-line no-unused-vars
480
+ const dir = new THREE.Quaternion()
481
+ tt.obj.quaternion.setFromEuler(euler)
482
+ break
483
+ }
484
+ case 'rotr': {
485
+ const rv = m[1]
486
+ const target = new THREE.Quaternion()
487
+ const axis = new THREE.Vector3(0, 0, 1)
488
+ target.setFromAxisAngle(axis, (-rv % 360) * Math.PI / 180)
489
+ tt.obj.quaternion.multiply(target)
490
+ break
491
+ }
492
+ case 'rotl': {
493
+ const rv = m[1]
494
+ const target = new THREE.Quaternion()
495
+ const axis = new THREE.Vector3(0, 0, 1)
496
+ target.setFromAxisAngle(axis, (rv % 360) * Math.PI / 180)
497
+ tt.obj.quaternion.multiply(target)
498
+ break
499
+ }
500
+ case 'rotu': {
501
+ const rv = m[1]
502
+ const target = new THREE.Quaternion()
503
+ const axis = new THREE.Vector3(1, 0, 0)
504
+ target.setFromAxisAngle(axis, (-rv % 360) * Math.PI / 180)
505
+ tt.obj.quaternion.multiply(target)
506
+ break
507
+ }
508
+ case 'rotd': {
509
+ const rv = m[1]
510
+ const target = new THREE.Quaternion()
511
+ const axis = new THREE.Vector3(1, 0, 0)
512
+ target.setFromAxisAngle(axis, (rv % 360) * Math.PI / 180)
513
+ tt.obj.quaternion.multiply(target)
514
+ break
515
+ }
516
+ case 'rolr': {
517
+ const rv = m[1]
518
+ const target = new THREE.Quaternion()
519
+ const axis = new THREE.Vector3(0, 1, 0)
520
+ target.setFromAxisAngle(axis, (rv % 360) * Math.PI / 180)
521
+ tt.obj.quaternion.multiply(target)
522
+ break
523
+ }
524
+ case 'roll': {
525
+ const rv = m[1]
526
+ const target = new THREE.Quaternion()
527
+ const axis = new THREE.Vector3(0, 1, 0)
528
+ target.setFromAxisAngle(axis, (-rv % 360) * Math.PI / 180)
529
+ tt.obj.quaternion.multiply(target)
530
+ break
531
+ }
532
+ case 'color':
533
+ tt.color = new m[1]()
534
+ break
535
+ case 'size':
536
+ tt.lineWidth = m[1]
537
+ break
538
+ case 'penOn':
539
+ tt.flagDown = m[1]
540
+ break
541
+ case 'visible':
542
+ tt.f_visible = m[1]
543
+ if (tt.f_visible) {
544
+ tt.obj.visible = true
545
+ } else {
546
+ tt.obj.visible = false
547
+ }
548
+ break
549
+ case 'changeModel':
550
+ tt.flagLoaded = false
551
+ me.loadTurtle(tt, m[1])
552
+ break
553
+ case 'changeCamera':
554
+ me.camera = m[1]
555
+ break
556
+ case 'sethome':
557
+ tt.home.position.copy(tt.obj.position)
558
+ tt.home.quaternion.copy(tt.obj.quaternion)
559
+ break
560
+ case 'gohome':
561
+ tt.obj.position.copy(tt.home.position)
562
+ tt.obj.quaternion.copy(tt.home.quaternion)
563
+ break
564
+ }
565
+ return (tt.mlist.length > 0)
566
+ },
567
+ doMacroAll: function (wait) {
568
+ let hasNext = false
569
+ for (let i = 0; i < this.list.length; i++) {
570
+ const tt = this.list[i]
571
+ if (this.doMacro(tt, wait)) { hasNext = true }
572
+ }
573
+ return hasNext
574
+ },
575
+ flagSetTimer: false,
576
+ animationStart: function () {
577
+ const wait = this.getWait()
578
+ if (wait === 0) {
579
+ this.animation()
580
+ return
581
+ }
582
+ if (this.flagSetTimer) { return }
583
+ this.flagSetTimer = true
584
+ this.animationFrame(this.animation)
585
+ },
586
+ getWait: function () {
587
+ return sys.__v0['T3Dカメ速度']
588
+ },
589
+ disposeChildObject: function (obj) {
590
+ while (obj.children.length > 0) {
591
+ this.disposeChildObject(obj.children[0])
592
+ obj.remove(obj.children[0])
593
+ }
594
+ if (obj.geometry) { obj.geometry.dispose() }
595
+
596
+ if (obj.material) {
597
+ Object.keys(obj.material).forEach(prop => {
598
+ if (!obj.material[prop]) { return }
599
+ if (typeof obj.material[prop].dispose === 'function') { obj.material[prop].dispose() }
600
+ })
601
+ obj.material.dispose()
602
+ }
603
+ },
604
+ animation: function () {
605
+ const me = sys._weykturtle3d
606
+ const now = Date.now()
607
+ const elapsedMs = now - me._prevUpdatedTime
608
+ const wait = me.getWait()
609
+ if (wait > 0 && elapsedMs < wait) {
610
+ me.doDraw()
611
+ me.animationFrame(me.animation)
612
+ return
613
+ }
614
+ let hasNext = me.doMacroAll(wait)
615
+ if (wait <= 0) {
616
+ while (hasNext) {
617
+ hasNext = me.doMacroAll(wait)
618
+ }
619
+ } else if (hasNext || me._controls !== null) {
620
+ me.doDraw()
621
+ me._prevUpdatedTime = now
622
+ me.animationFrame(me.animation)
623
+ return
624
+ }
625
+ me.doDraw()
626
+ me.flagSetTimer = false
627
+ }
628
+ }
629
+ sys._weykturtle3d.animationFrame = (function () {
630
+ return function (callback, element) {
631
+ window.setTimeout(callback, 1000 / 60)
632
+ }
633
+ /* window.requestAnimationFrame ||
634
+ window.webkitRequestAnimationFrame ||
635
+ window.mozRequestAnimationFrame ||
636
+ window.oRequestAnimationFrame ||
637
+ window.msRequestAnimationFrame || */
638
+ })()
639
+ }
640
+ },
641
+ // @3Dタートルグラフィックス/カメ操作
642
+ 'T3Dカメ作成': { // @タートルグラフィックスを開始してカメのIDを返す // @T3Dかめさくせい
643
+ type: 'func',
644
+ josi: [],
645
+ pure: true,
646
+ fn: function (sys) {
647
+ if (!sys._weykturtle3d) { return null }
648
+ sys._weykturtle3d.initTurtle()
649
+ const modelUrl = sys.__v0['T3DカメモデルURL']
650
+ const id = sys._weykturtle3d.createTurtle(modelUrl)
651
+ return id
652
+ },
653
+ return_none: false
654
+ },
655
+ 'T3Dカメ操作対象設定': { // @IDを指定して操作対象となるカメを変更する // @T3Dかめそうさたいしょうせってい
656
+ type: 'func',
657
+ josi: [['に', 'へ', 'の']],
658
+ pure: true,
659
+ fn: function (id, sys) {
660
+ if (!sys._weykturtle3d) { return null }
661
+ sys._weykturtle3d.target = id
662
+ },
663
+ return_none: true
664
+ },
665
+ 'T3Dカメ描画先': { type: 'var', value: 'turtle3d_div' }, // @T3Dかめびょうがさき
666
+ 'T3DカメモデルURL': { type: 'var', value: '' }, // @T3DかめもでるURL
667
+ 'T3Dカメモデル変更': { // @カメのモデルをURLに変更する // @T3Dかめもでるへんこう
668
+ type: 'func',
669
+ josi: [['に', 'へ']],
670
+ pure: true,
671
+ fn: function (url, sys) {
672
+ if (!sys._weykturtle3d) { return null }
673
+ const tt = sys._weykturtle3d.getCur()
674
+ tt.mlist.push(['changeModel', url])
675
+ sys._weykturtle3d.animationStart()
676
+ },
677
+ return_none: true
678
+ },
679
+ 'T3Dカメ速度': { type: 'const', value: 100 }, // @T3Dかめそくど
680
+ 'T3Dカメ速度設定': { // @カメの動作速度vに設定(大きいほど遅い) // @T3Dかめそくどせってい
681
+ type: 'func',
682
+ josi: [['に', 'へ']],
683
+ pure: true,
684
+ fn: function (v, sys) {
685
+ sys.__varslist[0]['T3Dカメ速度'] = v
686
+ },
687
+ return_none: true
688
+ },
689
+ 'T3Dカメ移動': { // @カメの位置を[x,y,z]へ移動する // @T3Dかめいどう
690
+ type: 'func',
691
+ josi: [['に', 'へ']],
692
+ pure: true,
693
+ fn: function (xyz, sys) {
694
+ if (!sys._weykturtle3d) { return null }
695
+ const tt = sys._weykturtle3d.getCur()
696
+ tt.mlist.push(['mv', new THREE.Vector3(xyz[0], xyz[1], xyz[2])])
697
+ sys._weykturtle3d.animationStart()
698
+ },
699
+ return_none: true
700
+ },
701
+ 'T3Dカメ原点設定': { // @カメの原点を現在の位置・向きに設定する // @T3Dかめげんてんせってい
702
+ type: 'func',
703
+ josi: [],
704
+ pure: true,
705
+ fn: function (sys) {
706
+ if (!sys._weykturtle3d) { return null }
707
+ const tt = sys._weykturtle3d.getCur()
708
+ tt.mlist.push(['sethome'])
709
+ sys._weykturtle3d.animationStart()
710
+ },
711
+ return_none: true
712
+ },
713
+ 'T3Dカメ原点移動': { // @カメを原点の位置・向きに移動する(描画はしない) // @T3Dかめげんてんいどう
714
+ type: 'func',
715
+ josi: [],
716
+ pure: true,
717
+ fn: function (sys) {
718
+ if (!sys._weykturtle3d) { return null }
719
+ const tt = sys._weykturtle3d.getCur()
720
+ tt.mlist.push(['gohome'])
721
+ sys._weykturtle3d.animationStart()
722
+ },
723
+ return_none: true
724
+ },
725
+ 'T3Dカメ起点移動': { // @カメの描画起点位置を[x,y,z]へ移動する // @T3Dかめきてんいどう
726
+ type: 'func',
727
+ josi: [['に', 'へ']],
728
+ pure: true,
729
+ fn: function (xyz, sys) {
730
+ if (!sys._weykturtle3d) { return null }
731
+ const tt = sys._weykturtle3d.getCur()
732
+ tt.mlist.push(['xyz', new THREE.Vector3(xyz[0], xyz[1], xyz[2])])
733
+ sys._weykturtle3d.animationStart()
734
+ },
735
+ return_none: true
736
+ },
737
+ 'T3Dカメ進': { // @カメの位置をVだけ進める // @T3Dかめすすむ
738
+ type: 'func',
739
+ josi: [['だけ']],
740
+ pure: true,
741
+ fn: function (v, sys) {
742
+ if (!sys._weykturtle3d) { return null }
743
+ const tt = sys._weykturtle3d.getCur()
744
+ tt.mlist.push(['fd', v, 1])
745
+ sys._weykturtle3d.animationStart()
746
+ },
747
+ return_none: true
748
+ },
749
+ 'T3Dカメ戻': { // @カメの位置をVだけ戻す // @T3Dかめもどる
750
+ type: 'func',
751
+ josi: [['だけ']],
752
+ pure: true,
753
+ fn: function (v, sys) {
754
+ if (!sys._weykturtle3d) { return null }
755
+ const tt = sys._weykturtle3d.getCur()
756
+ tt.mlist.push(['fd', v, -1])
757
+ sys._weykturtle3d.animationStart()
758
+ },
759
+ return_none: true
760
+ },
761
+ 'T3Dカメ上平行移動': { // @カメの位置を上にVだけ進める // @T3Dかめうえへいこういどう
762
+ type: 'func',
763
+ josi: [['だけ']],
764
+ pure: true,
765
+ fn: function (v, sys) {
766
+ if (!sys._weykturtle3d) { return null }
767
+ const tt = sys._weykturtle3d.getCur()
768
+ tt.mlist.push(['su', v])
769
+ sys._weykturtle3d.animationStart()
770
+ },
771
+ return_none: true
772
+ },
773
+ 'T3Dカメ下平行移動': { // @カメの位置を下にVだけ進める // @T3Dかめしたへいこういどう
774
+ type: 'func',
775
+ josi: [['だけ']],
776
+ pure: true,
777
+ fn: function (v, sys) {
778
+ if (!sys._weykturtle3d) { return null }
779
+ const tt = sys._weykturtle3d.getCur()
780
+ tt.mlist.push(['sd', v])
781
+ sys._weykturtle3d.animationStart()
782
+ },
783
+ return_none: true
784
+ },
785
+ 'T3Dカメ左平行移動': { // @カメの位置を左にVだけ進める // @T3Dかめひだりへいこういどう
786
+ type: 'func',
787
+ josi: [['だけ']],
788
+ pure: true,
789
+ fn: function (v, sys) {
790
+ if (!sys._weykturtle3d) { return null }
791
+ const tt = sys._weykturtle3d.getCur()
792
+ tt.mlist.push(['sl', v])
793
+ sys._weykturtle3d.animationStart()
794
+ },
795
+ return_none: true
796
+ },
797
+ 'T3Dカメ右平行移動': { // @カメの位置を右にVだけ進める // @T3Dかめみぎへいこういどう
798
+ type: 'func',
799
+ josi: [['だけ']],
800
+ pure: true,
801
+ fn: function (v, sys) {
802
+ if (!sys._weykturtle3d) { return null }
803
+ const tt = sys._weykturtle3d.getCur()
804
+ tt.mlist.push(['sr', v])
805
+ sys._weykturtle3d.animationStart()
806
+ },
807
+ return_none: true
808
+ },
809
+ 'T3Dカメ動': { // @カメの位置をDIRにVだけ進める // @T3Dかめうごく
810
+ type: 'func',
811
+ josi: [['へ', 'に'], ['だけ']],
812
+ pure: true,
813
+ fn: function (dir, v, sys) {
814
+ if (!sys._weykturtle3d) { return null }
815
+ const tt = sys._weykturtle3d.getCur()
816
+ let cmd = ''
817
+ if (dir === '前' || dir === '後') {
818
+ if (dir === '前') {
819
+ tt.mlist.push(['fd', v, 1])
820
+ } else {
821
+ tt.mlist.push(['fd', v, -1])
822
+ }
823
+ } else {
824
+ if (dir === '上' || dir === 'UP' || dir === 'うえ') {
825
+ cmd = 'su'
826
+ } else
827
+ if (dir === '下' || dir === 'DOWN' || dir === 'した') {
828
+ cmd = 'sd'
829
+ } else
830
+ if (dir === '右' || dir === 'RIGHT' || dir === 'みぎ') {
831
+ cmd = 'sr'
832
+ } else
833
+ if (dir === '左' || dir === 'LEFT' || dir === 'ひだり') {
834
+ cmd = 'sl'
835
+ } else {
836
+ throw Error('方向の指定が正しくありません。前後上下左右のいずれかで指定してください。')
837
+ }
838
+ tt.mlist.push([cmd, v])
839
+ }
840
+ sys._weykturtle3d.animationStart()
841
+ },
842
+ return_none: true
843
+ },
844
+ 'T3Dカメ角度設定': { // @カメの向きをオイラー(XYZ)にて設定する // @T3Dかめかくどせってい
845
+ type: 'func',
846
+ josi: [['に', 'へ', 'の']],
847
+ pure: true,
848
+ fn: function (v, sys) {
849
+ if (!sys._weykturtle3d) { return null }
850
+ const tt = sys._weykturtle3d.getCur()
851
+ tt.mlist.push(['angle', parseFloat(v)])
852
+ sys._weykturtle3d.animationStart()
853
+ },
854
+ return_none: true
855
+ },
856
+ 'T3Dカメ右回転': { // @カメの向きをDEGだけ右に向ける // @T3Dかめみぎかいてん
857
+ type: 'func',
858
+ josi: [['だけ']],
859
+ pure: true,
860
+ fn: function (v, sys) {
861
+ if (!sys._weykturtle3d) { return null }
862
+ const tt = sys._weykturtle3d.getCur()
863
+ tt.mlist.push(['rotr', v])
864
+ sys._weykturtle3d.animationStart()
865
+ },
866
+ return_none: true
867
+ },
868
+ 'T3Dカメ左回転': { // @カメの向きをDEGだけ左に向ける // @T3Dかめひだりかいてん
869
+ type: 'func',
870
+ josi: [['だけ']],
871
+ pure: true,
872
+ fn: function (v, sys) {
873
+ if (!sys._weykturtle3d) { return null }
874
+ const tt = sys._weykturtle3d.getCur()
875
+ tt.mlist.push(['rotl', v])
876
+ sys._weykturtle3d.animationStart()
877
+ },
878
+ return_none: true
879
+ },
880
+ 'T3Dカメ上回転': { // @カメの向きをDEGだけ上に向ける // @T3Dかめうえかいてん
881
+ type: 'func',
882
+ josi: [['だけ']],
883
+ pure: true,
884
+ fn: function (v, sys) {
885
+ if (!sys._weykturtle3d) { return null }
886
+ const tt = sys._weykturtle3d.getCur()
887
+ tt.mlist.push(['rotu', v])
888
+ sys._weykturtle3d.animationStart()
889
+ },
890
+ return_none: true
891
+ },
892
+ 'T3Dカメ下回転': { // @カメの向きをDEGだけ下に向ける // @T3Dかめしたかいてん
893
+ type: 'func',
894
+ josi: [['だけ']],
895
+ pure: true,
896
+ fn: function (v, sys) {
897
+ if (!sys._weykturtle3d) { return null }
898
+ const tt = sys._weykturtle3d.getCur()
899
+ tt.mlist.push(['rotd', v])
900
+ sys._weykturtle3d.animationStart()
901
+ },
902
+ return_none: true
903
+ },
904
+ 'T3Dカメ回転': { // @カメの向きをDEGだけDIRに向ける // @T3Dかめかいてん
905
+ type: 'func',
906
+ josi: [['へ', 'に'], ['だけ']],
907
+ pure: true,
908
+ fn: function (dir, v, sys) {
909
+ if (!sys._weykturtle3d) { return null }
910
+ const tt = sys._weykturtle3d.getCur()
911
+ let cmd = ''
912
+ if (dir === '上' || dir === 'UP' || dir === 'うえ') {
913
+ cmd = 'rotu'
914
+ } else
915
+ if (dir === '下' || dir === 'DOWN' || dir === 'した') {
916
+ cmd = 'rotd'
917
+ } else
918
+ if (dir === '右' || dir === 'RIGHT' || dir === 'みぎ') {
919
+ cmd = 'rotr'
920
+ } else
921
+ if (dir === '左' || dir === 'LEFT' || dir === 'ひだり') {
922
+ cmd = 'rotl'
923
+ } else {
924
+ throw Error('方向の指定が正しくありません。上下左右のいずれかで指定してください。')
925
+ }
926
+ tt.mlist.push([cmd, v])
927
+ sys._weykturtle3d.animationStart()
928
+ },
929
+ return_none: true
930
+ },
931
+ 'T3Dカメ右ロール': { // @カメをDEGだけ右に傾ける // @T3Dかめみぎろーる
932
+ type: 'func',
933
+ josi: [['だけ']],
934
+ pure: true,
935
+ fn: function (v, sys) {
936
+ if (!sys._weykturtle3d) { return null }
937
+ const tt = sys._weykturtle3d.getCur()
938
+ tt.mlist.push(['rolr', v])
939
+ sys._weykturtle3d.animationStart()
940
+ },
941
+ return_none: true
942
+ },
943
+ 'T3Dカメ左ロール': { // @カメのDEGだけ左に傾ける // @T3Dかめひだりろーる
944
+ type: 'func',
945
+ josi: [['だけ']],
946
+ pure: true,
947
+ fn: function (v, sys) {
948
+ if (!sys._weykturtle3d) { return null }
949
+ const tt = sys._weykturtle3d.getCur()
950
+ tt.mlist.push(['roll', v])
951
+ sys._weykturtle3d.animationStart()
952
+ },
953
+ return_none: true
954
+ },
955
+ 'T3Dカメ傾': { // @カメをDEGだけDIRに傾ける // @T3Dかめかたむける
956
+ type: 'func',
957
+ josi: [['に', 'へ'], ['だけ']],
958
+ pure: true,
959
+ fn: function (dir, v, sys) {
960
+ if (!sys._weykturtle3d) { return null }
961
+ const tt = sys._weykturtle3d.getCur()
962
+ let cmd = ''
963
+ if (dir === '右' || dir === 'RIGHT' || dir === 'みぎ') {
964
+ cmd = 'rolr'
965
+ } else
966
+ if (dir === '左' || dir === 'LEFT' || dir === 'ひだり') {
967
+ cmd = 'roll'
968
+ } else {
969
+ throw Error('向きの指定が正しくありません。左右のどちらかで指定してください。')
970
+ }
971
+ tt.mlist.push([cmd, v])
972
+ sys._weykturtle3d.animationStart()
973
+ },
974
+ return_none: true
975
+ },
976
+ 'T3Dカメペン色設定': { // @カメのペン描画色をCに設定する // @T3Dかめぺんいろせってい
977
+ type: 'func',
978
+ josi: [['に', 'へ']],
979
+ pure: true,
980
+ fn: function (c, sys) {
981
+ if (!sys._weykturtle3d) { return null }
982
+ const tt = sys._weykturtle3d.getCur()
983
+ tt.mlist.push(['color', c])
984
+ sys._weykturtle3d.animationStart()
985
+ },
986
+ return_none: true
987
+ },
988
+ 'T3Dカメペンサイズ設定': { // @カメペンのサイズをWに設定する // @T3Dかめぺんさいずせってい
989
+ type: 'func',
990
+ josi: [['に', 'へ']],
991
+ pure: true,
992
+ fn: function (w, sys) {
993
+ if (!sys._weykturtle3d) { return null }
994
+ const tt = sys._weykturtle3d.getCur()
995
+ tt.mlist.push(['size', w])
996
+ sys._weykturtle3d.animationStart()
997
+ },
998
+ return_none: true
999
+ },
1000
+ 'T3Dカメペン設定': { // @カメペンを使うかどうかをV(オン/オフ)に設定する // @T3Dかめぺんせってい
1001
+ type: 'func',
1002
+ josi: [['に', 'へ']],
1003
+ pure: true,
1004
+ fn: function (w, sys) {
1005
+ if (!sys._weykturtle3d) { return null }
1006
+ const tt = sys._weykturtle3d.getCur()
1007
+ tt.mlist.push(['penOn', w])
1008
+ sys._weykturtle3d.animationStart()
1009
+ },
1010
+ return_none: true
1011
+ },
1012
+ 'T3Dカメ全消去': { // @表示しているカメと描画内容を全部消去する // @T3Dかめぜんしょうきょ
1013
+ type: 'func',
1014
+ josi: [],
1015
+ pure: true,
1016
+ fn: function (sys) {
1017
+ if (!sys._weykturtle3d) { return null }
1018
+ sys._weykturtle3d.clearAll()
1019
+ },
1020
+ return_none: true
1021
+ },
1022
+ 'T3Dカメ非表示': { // @カメのモデルを非表示にする。描画に影響しない。 // @T3Dかめひひょうじ
1023
+ type: 'func',
1024
+ josi: [],
1025
+ pure: true,
1026
+ fn: function (sys) {
1027
+ if (!sys._weykturtle3d) { return null }
1028
+ const tt = sys._weykturtle3d.getCur()
1029
+ tt.mlist.push(['visible', false])
1030
+ sys._weykturtle3d.animationStart()
1031
+ },
1032
+ return_none: true
1033
+ },
1034
+ 'T3Dカメ表示': { // @非表示にしたカメのモデルを表示する。 // @T3Dかめひょうじ
1035
+ type: 'func',
1036
+ josi: [],
1037
+ pure: true,
1038
+ fn: function (sys) {
1039
+ if (!sys._weykturtle3d) { return null }
1040
+ const tt = sys._weykturtle3d.getCur()
1041
+ tt.mlist.push(['visible', true])
1042
+ sys._weykturtle3d.animationStart()
1043
+ },
1044
+ return_none: true
1045
+ },
1046
+ 'T3D視点カメ設定': { // @指定したカメを視点として使用する // @T3Dしてんかめせってい
1047
+ type: 'func',
1048
+ josi: [['に', 'へ']],
1049
+ pure: true,
1050
+ fn: function (w, sys) {
1051
+ if (!sys._weykturtle3d) { return null }
1052
+ if (w < 0 || w >= sys._weykturtle3d.list.length) {
1053
+ throw Error('指定された番号のカメはいません。')
1054
+ }
1055
+ const tt = sys._weykturtle3d.getCur()
1056
+ tt.mlist.push(['changeCamera', w])
1057
+ sys._weykturtle3d.animationStart()
1058
+ },
1059
+ return_none: true
1060
+ },
1061
+ // @3Dタートルグラフィックス/基本機能
1062
+ 'T3D描画準備': { // @指定したDOMのIDに対する描画を準備し、描画オブジェクトを返す // @T3Dびょうがじゅんび
1063
+ type: 'func',
1064
+ josi: [['に', 'へ']],
1065
+ pure: true,
1066
+ fn: function (to, sys) {
1067
+ if (!sys._weykturtle3d) { return null }
1068
+ if (typeof THREE === 'undefined') {
1069
+ throw new Error('three.jsが読み込まれていません')
1070
+ }
1071
+
1072
+ if (typeof to === 'string') { to = document.querySelector(to) || document.getElementById(to) }
1073
+ if (!to) { throw new Error('TJS描画準備に指定した描画先に誤りがあります') }
1074
+
1075
+ sys._weykturtle3d.setRenderer(to)
1076
+ sys._weykturtle3d.setupRenderer()
1077
+ return sys._weykturtle3d._renderer
1078
+ },
1079
+ return_none: false
1080
+ },
1081
+ 'T3D描画': { // @現在の状態を描画する // @T3Dびょうが
1082
+ type: 'func',
1083
+ josi: [],
1084
+ pure: true,
1085
+ fn: function (sys) {
1086
+ if (!sys._weykturtle3d) { return null }
1087
+ sys._weykturtle3d.doDraw()
1088
+ },
1089
+ return_none: true
1090
+ },
1091
+ 'T3D背景色設定': { // @canvasをクリアする際の背景色を設定する // @T3Dはいけいしょくせってい
1092
+ type: 'func',
1093
+ josi: [['に', 'へ']],
1094
+ pure: true,
1095
+ fn: function (c, sys) {
1096
+ if (!sys._weykturtle3d) { return null }
1097
+ if (sys._weykturtle3d._renderer === null) {
1098
+ sys._weykturtle3d.setRenderTarget()
1099
+ }
1100
+ sys._weykturtle3d._renderer.setClearColor(c)
1101
+ sys._weykturtle3d.animationStart()
1102
+ },
1103
+ return_none: true
1104
+ },
1105
+ 'T3D背景透過設定': { // @canvasをクリアする際の背景のアルファ値を設定する // @T3Dはいけいとうかせってい
1106
+ type: 'func',
1107
+ josi: [['に', 'へ']],
1108
+ pure: true,
1109
+ fn: function (c, sys) {
1110
+ if (!sys._weykturtle3d) { return null }
1111
+ if (sys._weykturtle3d._renderer === null) {
1112
+ sys._weykturtle3d.setRenderTarget()
1113
+ }
1114
+ sys._weykturtle3d._renderer.setClearAlpha(c)
1115
+ sys._weykturtle3d.animationStart()
1116
+ },
1117
+ return_none: true
1118
+ },
1119
+ 'T3DJSON取得': { // @描画した線のJSON形式で取得する // @T3DJSONしゅとく
1120
+ type: 'func',
1121
+ josi: [],
1122
+ pure: true,
1123
+ fn: function (sys) {
1124
+ if (!sys._weykturtle3d) { return null }
1125
+ return JSON.stringify(sys._weykturtle3d._lines.toJSON())
1126
+ },
1127
+ return_none: false
1128
+ },
1129
+ // @3Dタートルグラフィックス/ヘルパ機能
1130
+ 'T3Dオービットコントロール設定': { // オービットコントロールを組み込む // @T3Dおーびっとこんとろーるせってい
1131
+ type: 'func',
1132
+ josi: [],
1133
+ pure: true,
1134
+ fn: function (sys) {
1135
+ if (!sys._weykturtle3d) { return null }
1136
+ if (typeof THREE.OrbitControls !== 'undefined') {
1137
+ return sys._weykturtle3d.setupControl(THREE.OrbitControls)
1138
+ }
1139
+ return null
1140
+ },
1141
+ return_none: false
1142
+ },
1143
+ 'T3Dコントロール有効': { // @組み込んだコントロールを有効にする // @T3Dこんとろーるゆうこう
1144
+ type: 'func',
1145
+ josi: [],
1146
+ pure: true,
1147
+ fn: function (sys) {
1148
+ if (!sys._weykturtle3d) { return null }
1149
+ if (sys._weykturtle3d._controls) {
1150
+ sys._weykturtle3d._controls.enabled = true
1151
+ }
1152
+ },
1153
+ return_none: true
1154
+ },
1155
+ 'T3Dコントロール無効': { // @組み込んだコントロールを無効にする // @T3Dこんとろーるむこう
1156
+ type: 'func',
1157
+ josi: [],
1158
+ pure: true,
1159
+ fn: function (sys) {
1160
+ if (!sys._weykturtle3d) { return null }
1161
+ if (sys._weykturtle3d._controls) {
1162
+ sys._weykturtle3d._controls.enabled = false
1163
+ }
1164
+ },
1165
+ return_none: true
1166
+ },
1167
+ 'T3Dカメラヘルパ表示': { // @カメラヘルパーを表示する // @T3Dかめらへるぱひょうじ
1168
+ type: 'func',
1169
+ josi: [],
1170
+ pure: true,
1171
+ fn: function (sys) {
1172
+ if (!sys._weykturtle3d) { return null }
1173
+ sys._weykturtle3d.setCameraHelper(true)
1174
+ },
1175
+ return_none: true
1176
+ },
1177
+ 'T3Dカメラヘルパ非表示': { // @カメラヘルパーを非表示にする // @T3Dかめらへるぱひひょうじ
1178
+ type: 'func',
1179
+ josi: [],
1180
+ pure: true,
1181
+ fn: function (sys) {
1182
+ if (!sys._weykturtle3d) { return null }
1183
+ sys._weykturtle3d.setCameraHelper(false)
1184
+ },
1185
+ return_none: true
1186
+ },
1187
+ 'T3D軸線ヘルパ表示': { // @座標軸ヘルパーを表示する // @T3Dじくせんへるぱひょうじ
1188
+ type: 'func',
1189
+ josi: [],
1190
+ pure: true,
1191
+ fn: function (sys) {
1192
+ if (!sys._weykturtle3d) { return null }
1193
+ sys._weykturtle3d.setAxisHelper(true)
1194
+ },
1195
+ return_none: true
1196
+ },
1197
+ 'T3D軸線ヘルパ非表示': { // @座標軸ヘルパーを非表示にする // @T3Dじくせんへるぱひひょうじ
1198
+ type: 'func',
1199
+ josi: [],
1200
+ pure: true,
1201
+ fn: function (sys) {
1202
+ if (!sys._weykturtle3d) { return null }
1203
+ sys._weykturtle3d.setAxisHelper(false)
1204
+ },
1205
+ return_none: true
1206
+ }
1207
+ }
1208
+
1209
+ if (typeof (global) === 'object' && typeof (global.process) === 'object') {
1210
+ module.exports = PluginWeykTurtle3D
1211
+ }
1212
+
1213
+ // ブラウザからscriptタグで取り込んだ時、自動で登録する
1214
+ if (typeof (navigator) === 'object') {
1215
+ navigator.nako3.addPluginObject('PluginWeykTurtle3D', PluginWeykTurtle3D)
1216
+ }