@ioai/robot_viewer 0.0.0-stage → 1.1.2

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 (159) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +217 -2
  3. package/bin/cli.js +83 -0
  4. package/dist/assets/css/PlotPanel-3e7d7555.css +1 -0
  5. package/dist/assets/js/ColladaLoader-2a0c4638.js +1 -0
  6. package/dist/assets/js/GLTFLoader-7a7f40d7.js +1 -0
  7. package/dist/assets/js/MTLLoader-b6ce88b7.js +1 -0
  8. package/dist/assets/js/OBJLoader-7667aa01.js +1 -0
  9. package/dist/assets/js/PlotPanel-09f986c7.js +1 -0
  10. package/dist/assets/js/STLLoader-de0915d4.js +1 -0
  11. package/dist/assets/js/URDFLoader-a34b6917.js +1 -0
  12. package/dist/assets/js/USDZLoader-64197f74.js +7 -0
  13. package/dist/assets/js/__vite-browser-external-afb87ea8.js +1 -0
  14. package/dist/assets/js/codemirror-c3cec7b3.js +1 -0
  15. package/dist/assets/js/codemirror-themes-e6995a6a.js +1 -0
  16. package/dist/assets/js/d3-2e308866.js +1 -0
  17. package/dist/assets/js/index-56e94ce5.js +6 -0
  18. package/dist/assets/js/mujoco_wasm-345a2576.js +1 -0
  19. package/dist/assets/js/three-9c891de0.js +6 -0
  20. package/dist/camera-publish-worker.js +1 -0
  21. package/dist/favicon.svg +2 -0
  22. package/dist/heartbeat-worker.js +1 -0
  23. package/dist/index.html +4373 -0
  24. package/dist/models/mocap/blender_human.urdf +2319 -0
  25. package/dist/models/mocap/blender_human_skeleton_v4.urdf +1432 -0
  26. package/dist/models/mocap/blender_human_skeleton_v5.urdf +2717 -0
  27. package/dist/models/mocap/meshes/v4/L_base_link.STL +0 -0
  28. package/dist/models/mocap/meshes/v4/L_figer1_1.STL +0 -0
  29. package/dist/models/mocap/meshes/v4/L_figer1_2.STL +0 -0
  30. package/dist/models/mocap/meshes/v4/L_figer1_3.STL +0 -0
  31. package/dist/models/mocap/meshes/v4/L_figer1_4.STL +0 -0
  32. package/dist/models/mocap/meshes/v4/L_figer1_5.STL +0 -0
  33. package/dist/models/mocap/meshes/v4/L_figer1base.STL +0 -0
  34. package/dist/models/mocap/meshes/v4/L_figer2_1.STL +0 -0
  35. package/dist/models/mocap/meshes/v4/L_figer2_2.STL +0 -0
  36. package/dist/models/mocap/meshes/v4/L_figer2_3.STL +0 -0
  37. package/dist/models/mocap/meshes/v4/L_figer2_4.STL +0 -0
  38. package/dist/models/mocap/meshes/v4/L_figer2_5.STL +0 -0
  39. package/dist/models/mocap/meshes/v4/L_figer3_1.STL +0 -0
  40. package/dist/models/mocap/meshes/v4/L_figer3_2.STL +0 -0
  41. package/dist/models/mocap/meshes/v4/L_figer3_3.STL +0 -0
  42. package/dist/models/mocap/meshes/v4/L_figer3_4.STL +0 -0
  43. package/dist/models/mocap/meshes/v4/L_figer3_5.STL +0 -0
  44. package/dist/models/mocap/meshes/v4/L_figer4_1.STL +0 -0
  45. package/dist/models/mocap/meshes/v4/L_figer4_2.STL +0 -0
  46. package/dist/models/mocap/meshes/v4/L_figer4_3.STL +0 -0
  47. package/dist/models/mocap/meshes/v4/L_figer4_4.STL +0 -0
  48. package/dist/models/mocap/meshes/v4/L_figer4_5.STL +0 -0
  49. package/dist/models/mocap/meshes/v4/L_figer5_1.STL +0 -0
  50. package/dist/models/mocap/meshes/v4/L_figer5_2.STL +0 -0
  51. package/dist/models/mocap/meshes/v4/L_figer5_3.STL +0 -0
  52. package/dist/models/mocap/meshes/v4/L_figer5_4.STL +0 -0
  53. package/dist/models/mocap/meshes/v4/L_figer5_5.STL +0 -0
  54. package/dist/models/mocap/meshes/v4/L_handle.STL +0 -0
  55. package/dist/models/mocap/meshes/v4/L_handleseat.STL +0 -0
  56. package/dist/models/mocap/meshes/v4/L_mark.STL +0 -0
  57. package/dist/models/mocap/meshes/v4/L_markseat.STL +0 -0
  58. package/dist/models/mocap/meshes/v4/Lgamepadbase.STL +0 -0
  59. package/dist/models/mocap/meshes/v4/Link1.STL +0 -0
  60. package/dist/models/mocap/meshes/v4/Link2.STL +0 -0
  61. package/dist/models/mocap/meshes/v4/R_base_link.STL +0 -0
  62. package/dist/models/mocap/meshes/v4/R_figer1_1.STL +0 -0
  63. package/dist/models/mocap/meshes/v4/R_figer1_2.STL +0 -0
  64. package/dist/models/mocap/meshes/v4/R_figer1_3.STL +0 -0
  65. package/dist/models/mocap/meshes/v4/R_figer1_4.STL +0 -0
  66. package/dist/models/mocap/meshes/v4/R_figer1_5.STL +0 -0
  67. package/dist/models/mocap/meshes/v4/R_figer1base.STL +0 -0
  68. package/dist/models/mocap/meshes/v4/R_figer2_1.STL +0 -0
  69. package/dist/models/mocap/meshes/v4/R_figer2_2.STL +0 -0
  70. package/dist/models/mocap/meshes/v4/R_figer2_3.STL +0 -0
  71. package/dist/models/mocap/meshes/v4/R_figer2_4.STL +0 -0
  72. package/dist/models/mocap/meshes/v4/R_figer2_5.STL +0 -0
  73. package/dist/models/mocap/meshes/v4/R_figer3_1.STL +0 -0
  74. package/dist/models/mocap/meshes/v4/R_figer3_2.STL +0 -0
  75. package/dist/models/mocap/meshes/v4/R_figer3_3.STL +0 -0
  76. package/dist/models/mocap/meshes/v4/R_figer3_4.STL +0 -0
  77. package/dist/models/mocap/meshes/v4/R_figer3_5.STL +0 -0
  78. package/dist/models/mocap/meshes/v4/R_figer4_1.STL +0 -0
  79. package/dist/models/mocap/meshes/v4/R_figer4_2.STL +0 -0
  80. package/dist/models/mocap/meshes/v4/R_figer4_3.STL +0 -0
  81. package/dist/models/mocap/meshes/v4/R_figer4_4.STL +0 -0
  82. package/dist/models/mocap/meshes/v4/R_figer4_5.STL +0 -0
  83. package/dist/models/mocap/meshes/v4/R_figer5_1.STL +0 -0
  84. package/dist/models/mocap/meshes/v4/R_figer5_2.STL +0 -0
  85. package/dist/models/mocap/meshes/v4/R_figer5_3.STL +0 -0
  86. package/dist/models/mocap/meshes/v4/R_figer5_4.STL +0 -0
  87. package/dist/models/mocap/meshes/v4/R_figer5_5.STL +0 -0
  88. package/dist/models/mocap/meshes/v4/R_handle.STL +0 -0
  89. package/dist/models/mocap/meshes/v4/R_handleseat.STL +0 -0
  90. package/dist/models/mocap/meshes/v4/R_mark.STL +0 -0
  91. package/dist/models/mocap/meshes/v4/R_markseat.STL +0 -0
  92. package/dist/models/mocap/meshes/v4/Rgamepadbase.STL +0 -0
  93. package/dist/models/mocap/meshes/v4/base_link.STL +0 -0
  94. package/dist/models/mocap/meshes/v4/r_figer1_1.STL +0 -0
  95. package/dist/models/mocap/meshes/v5/L_handleseat.STL +0 -0
  96. package/dist/models/mocap/meshes/v5/R_handleseat.STL +0 -0
  97. package/dist/models/mocap/meshes/v5/link_LeftSkeletonBase.STL +0 -0
  98. package/dist/models/mocap/meshes/v5/link_LeftSkeletonIndex1.STL +0 -0
  99. package/dist/models/mocap/meshes/v5/link_LeftSkeletonIndex2.STL +0 -0
  100. package/dist/models/mocap/meshes/v5/link_LeftSkeletonIndex3.STL +0 -0
  101. package/dist/models/mocap/meshes/v5/link_LeftSkeletonIndex4.STL +0 -0
  102. package/dist/models/mocap/meshes/v5/link_LeftSkeletonMiddle1.STL +0 -0
  103. package/dist/models/mocap/meshes/v5/link_LeftSkeletonMiddle2.STL +0 -0
  104. package/dist/models/mocap/meshes/v5/link_LeftSkeletonMiddle3.STL +0 -0
  105. package/dist/models/mocap/meshes/v5/link_LeftSkeletonMiddle4.STL +0 -0
  106. package/dist/models/mocap/meshes/v5/link_LeftSkeletonPinky1.STL +0 -0
  107. package/dist/models/mocap/meshes/v5/link_LeftSkeletonPinky2.STL +0 -0
  108. package/dist/models/mocap/meshes/v5/link_LeftSkeletonPinky3.STL +0 -0
  109. package/dist/models/mocap/meshes/v5/link_LeftSkeletonPinky4.STL +0 -0
  110. package/dist/models/mocap/meshes/v5/link_LeftSkeletonRing1.STL +0 -0
  111. package/dist/models/mocap/meshes/v5/link_LeftSkeletonRing2.STL +0 -0
  112. package/dist/models/mocap/meshes/v5/link_LeftSkeletonRing3.STL +0 -0
  113. package/dist/models/mocap/meshes/v5/link_LeftSkeletonRing4.STL +0 -0
  114. package/dist/models/mocap/meshes/v5/link_LeftSkeletonThumb1.STL +0 -0
  115. package/dist/models/mocap/meshes/v5/link_LeftSkeletonThumb2.STL +0 -0
  116. package/dist/models/mocap/meshes/v5/link_LeftSkeletonThumb3.STL +0 -0
  117. package/dist/models/mocap/meshes/v5/link_LeftSkeletonThumb4.STL +0 -0
  118. package/dist/models/mocap/meshes/v5/link_LeftSkeletonThumbBase.STL +0 -0
  119. package/dist/models/mocap/meshes/v5/link_RightSkeletonBase.STL +0 -0
  120. package/dist/models/mocap/meshes/v5/link_RightSkeletonIndex1.STL +0 -0
  121. package/dist/models/mocap/meshes/v5/link_RightSkeletonIndex2.STL +0 -0
  122. package/dist/models/mocap/meshes/v5/link_RightSkeletonIndex3.STL +0 -0
  123. package/dist/models/mocap/meshes/v5/link_RightSkeletonIndex4.STL +0 -0
  124. package/dist/models/mocap/meshes/v5/link_RightSkeletonMiddle1.STL +0 -0
  125. package/dist/models/mocap/meshes/v5/link_RightSkeletonMiddle2.STL +0 -0
  126. package/dist/models/mocap/meshes/v5/link_RightSkeletonMiddle3.STL +0 -0
  127. package/dist/models/mocap/meshes/v5/link_RightSkeletonMiddle4.STL +0 -0
  128. package/dist/models/mocap/meshes/v5/link_RightSkeletonPinky1.STL +0 -0
  129. package/dist/models/mocap/meshes/v5/link_RightSkeletonPinky2.STL +0 -0
  130. package/dist/models/mocap/meshes/v5/link_RightSkeletonPinky3.STL +0 -0
  131. package/dist/models/mocap/meshes/v5/link_RightSkeletonPinky4.STL +0 -0
  132. package/dist/models/mocap/meshes/v5/link_RightSkeletonRing1.STL +0 -0
  133. package/dist/models/mocap/meshes/v5/link_RightSkeletonRing2.STL +0 -0
  134. package/dist/models/mocap/meshes/v5/link_RightSkeletonRing3.STL +0 -0
  135. package/dist/models/mocap/meshes/v5/link_RightSkeletonRing4.STL +0 -0
  136. package/dist/models/mocap/meshes/v5/link_RightSkeletonThumb1.STL +0 -0
  137. package/dist/models/mocap/meshes/v5/link_RightSkeletonThumb2.STL +0 -0
  138. package/dist/models/mocap/meshes/v5/link_RightSkeletonThumb3.STL +0 -0
  139. package/dist/models/mocap/meshes/v5/link_RightSkeletonThumb4.STL +0 -0
  140. package/dist/models/mocap/meshes/v5/link_RightSkeletonThumbBase.STL +0 -0
  141. package/dist/scripts/start-rosbridge.sh +77 -0
  142. package/dist/usd-iframe.html +41 -0
  143. package/dist/usd-viewer/bindings/.gitattributes +2 -0
  144. package/dist/usd-viewer/bindings/emHdBindings.data +19331 -0
  145. package/dist/usd-viewer/bindings/emHdBindings.js +12281 -0
  146. package/dist/usd-viewer/bindings/emHdBindings.wasm +0 -0
  147. package/dist/usd-viewer/bindings/emHdBindings.worker.js +124 -0
  148. package/dist/usd-viewer/environments/neutral.hdr +0 -0
  149. package/dist/usd-viewer/error-handler.js +57 -0
  150. package/dist/usd-viewer/hydra/HydraPrimitives.js +740 -0
  151. package/dist/usd-viewer/hydra/TextureRegistry.js +130 -0
  152. package/dist/usd-viewer/hydra/ThreeJsRenderDelegate.js +65 -0
  153. package/dist/usd-viewer/index.d.ts +1 -0
  154. package/dist/usd-viewer/main.js +1018 -0
  155. package/dist/usd-viewer/usd.html +36 -0
  156. package/dist/usd-viewer/usdUtils.js +67 -0
  157. package/package.json +70 -4
  158. package/server/package.json +14 -0
  159. package/server/static-server.js +106 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Ziqi Fan
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,218 @@
1
- # Temporary Holding Version
1
+ ![screenshot](./docs/screenshot.png)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ---
4
+
5
+ # IO Robot Viewer
6
+
7
+ **IO Robot Viewer** 是一个基于 [Three.js](https://threejs.org/) 的浏览器端机器人遥操作适配&调试工具,提供直观的界面用于可视化、编辑和仿真机器人模型。支持查看和分析机器人结构、关节和物理属性。
8
+
9
+ **在线演示**:http://192.168.2.46:3000
10
+
11
+ ## 通过 npm 本地启动
12
+
13
+ 首次联网下载并启动最新版:
14
+
15
+ ```bash
16
+ npx -y --prefer-offline @ioai/robot_viewer
17
+ ```
18
+
19
+ 启动后按终端提示访问:
20
+
21
+ ```text
22
+ http://127.0.0.1:3000
23
+ http://localhost:3000
24
+ ```
25
+
26
+ `--prefer-offline` 表示优先复用 npm 缓存,缓存缺失时仍会联网。确认指定版本已经缓存后,可以在无网络环境下运行:
27
+
28
+ ```bash
29
+ npx -y --offline @ioai/robot_viewer@1.1.2
30
+ ```
31
+
32
+ 如果需要长期离线使用和最简启动命令,推荐首次联网时全局安装:
33
+
34
+ ```bash
35
+ npm install -g @ioai/robot_viewer@1.1.2
36
+ robot-viewer
37
+ ```
38
+
39
+ 默认仅监听本机地址。需要允许局域网其他设备访问时:
40
+
41
+ ```bash
42
+ npx -y --prefer-offline @ioai/robot_viewer --host 0.0.0.0
43
+ ```
44
+
45
+ ## 主要功能
46
+
47
+ - **格式支持**:
48
+ - **URDF**:统一机器人描述格式
49
+ - **Xacro**:ROS Xacro 格式,支持宏展开和条件逻辑
50
+ - **MJCF**:MuJoCo XML 格式
51
+ - **USD**:通用场景描述格式(部分支持)
52
+ - **机器人类型**:串联机器人结构(暂不支持并联机器人)
53
+ - **ROS 集成**:通过 ROS topic 实时控制关节(WebSocket 桥接)
54
+ - **可视化工具**:视觉/碰撞几何体、惯性张量、质心、坐标系、关节轴、阴影、坐标系方向,支持在坐标轴控制面板中按名称筛选、显示名称、调整显示尺寸,并在长列表下滚动查看全部名称
55
+ - **交互控制**:实时拖拽关节、调整模型姿态
56
+ - **测量工具**:测量关节和连杆之间的距离并进行 3D 可视化,显示 X/Y/Z 轴投影和总距离,支持离地高度测量
57
+ - **代码编辑器**:内置 CodeMirror 编辑器,支持语法高亮和实时预览
58
+ - **物理仿真**:集成 MuJoCo 引擎进行动力学仿真(MJCF 模型)
59
+ - **实时监控**:`?plot=1` 参数打开关节曲线监控面板,实时对比 cmd/state 数据(Chrome 后台标签页不受节流)
60
+ - **场景管理**:文件树和场景图可视化,支持层级结构
61
+
62
+ ## 快速开始
63
+
64
+ 本项目使用 **pnpm**,也支持 **npm** 或 **yarn**。
65
+
66
+ 克隆仓库并安装依赖:
67
+
68
+ ```bash
69
+ pnpm install
70
+ ```
71
+
72
+ 启动开发服务器:
73
+
74
+ ```bash
75
+ pnpm run dev
76
+ ```
77
+
78
+ 生产构建:
79
+
80
+ ```bash
81
+ pnpm run build
82
+ ```
83
+
84
+ 构建产物输出到 `dist/` 目录。
85
+
86
+ ## 生产部署
87
+
88
+ 生产环境用 `deploy_on_server.sh`(`pnpm run build` + 静态服务托管 `dist/`),**不要**用 `deploy.sh`——它会注入 Vite HMR 客户端,后台标签页被强制刷新后模型丢失。
89
+
90
+ ```bash
91
+ ./deploy_on_server.sh # 构建 + 启动前端(:3000)
92
+ ./deploy_on_server.sh --daemon # 后台常驻(日志在 logs/,用 --stop 停止)
93
+ ./deploy_on_server.sh --skip-build # 复用已有 dist/
94
+ ./deploy_on_server.sh --port 8080 # 自定义前端端口
95
+ ./deploy_on_server.sh --stop # 停止 daemon 服务
96
+ ```
97
+
98
+
99
+ 在生产服务器上配置开机自动启动:
100
+
101
+ ```bash
102
+ # 复制 service 文件到 systemd 目录
103
+ sudo cp io_robot_viewer/io_robot_viewer.service /etc/systemd/system/
104
+
105
+ # 重新加载 systemd 配置
106
+ sudo systemctl daemon-reload
107
+
108
+ # 启用开机自启
109
+ sudo systemctl enable io_robot_viewer
110
+
111
+ # 立即启动服务
112
+ sudo systemctl start io_robot_viewer
113
+
114
+ # 查看服务状态
115
+ sudo systemctl status io_robot_viewer
116
+ ```
117
+
118
+ **常用管理命令**:
119
+ ```bash
120
+ sudo systemctl start io_robot_viewer # 启动服务
121
+ sudo systemctl stop io_robot_viewer # 停止服务
122
+ sudo systemctl restart io_robot_viewer # 重启服务
123
+ sudo journalctl -u io_robot_viewer -f # 查看实时日志
124
+ ```
125
+
126
+ 服务配置文件位于 `io_robot_viewer.service`,开机时会自动构建并启动 Web 服务器。
127
+
128
+
129
+ ## ROS 集成(可选功能)
130
+
131
+ Robot Viewer 支持通过 ROS 2 实时控制机器人关节和应用 TF 变换数据。
132
+
133
+ ### 前置要求
134
+
135
+ - ROS 2 环境(Humble/Iron/Jazzy)
136
+ - rosbridge_suite 包
137
+
138
+ ### 快速启动
139
+
140
+ **方式 1:一键启动(推荐)**
141
+ ```bash
142
+ ./scripts/start-rosbridge.sh --domain_id=xxx
143
+ ```
144
+
145
+ **方式 2:手动启动**
146
+ ```bash
147
+ # 如果未安装 rosbridge_suite
148
+ sudo apt install ros-$ROS_DISTRO-rosbridge-suite
149
+
150
+ # 启动 rosbridge_server
151
+ ros2 run rosbridge_server rosbridge_websocket
152
+ ```
153
+
154
+ ### 连接使用
155
+
156
+ 1. 在 Web 页面打开 ROS 连接面板
157
+ 2. 输入 `ws://localhost:9090`
158
+ 3. 点击连接
159
+
160
+ 额外:在 URL 后追加 `?plot=1` 可打开实时关节曲线监控面板。
161
+
162
+ ### 功能支持
163
+
164
+ **关节控制**:
165
+ ```bash
166
+ # 发布关节控制消息
167
+ ros2 topic pub /io_teleop/joint_cmd sensor_msgs/msg/JointState \
168
+ "{name: ['joint1'], position: [1.0]}"
169
+ ```
170
+
171
+ **TF 数据应用**(适用于动捕/外骨骼场景):
172
+ - 订阅 `/tf` topic 自动将 TF 变换应用到对应 link
173
+ - 自动处理坐标系转换(ROS Z-up → Three.js Y-up)
174
+ - 首帧校准保证连接前后位置稳定
175
+ - 支持手臂间距缩放和朝向调整(见 `src/controllers/TFController.js`)
176
+
177
+ ### 架构说明
178
+
179
+ ```
180
+ 用户浏览器 ←─ HTTP ─← Web 服务器(静态文件)
181
+ ↓
182
+ WebSocket (ws://localhost:9090)
183
+ ↓
184
+ ros2 run rosbridge_server rosbridge_websocket
185
+ ↓
186
+ 本地 ROS 2 节点
187
+ ```
188
+
189
+ - Web 服务器仅提供静态文件
190
+ - ROS 消息在本地完成,不经过服务器中转
191
+ - 延迟极低(< 10ms)
192
+
193
+ ## 贡献
194
+
195
+ 欢迎社区贡献!无论是修复 Bug、添加功能还是改进文档,我们都非常感谢您的参与。
196
+
197
+ - **Bug 报告**:提交 [Issue](https://github.com/fan-ziqi/robot_viewer/issues) 并附上详细信息
198
+ - **功能建议**:在 [Discussions](https://github.com/fan-ziqi/robot_viewer/discussions) 中讨论想法
199
+ - **Pull Request**:提交 PR 时请附上清晰的描述和测试
200
+
201
+ ## 许可证
202
+
203
+ 本项目基于 [Apache License 2.0](LICENSE) 开源。
204
+
205
+ ## 致谢
206
+
207
+ Robot Viewer 基于开源机器人社区的优秀成果构建,集成了以下开源项目:
208
+
209
+ - **[urdf-loader](https://github.com/gkjohnson/urdf-loaders)** - Three.js 的 URDF 加载器
210
+ - **[xacro-parser](https://github.com/gkjohnson/xacro-parser)** - JavaScript 的 ROS Xacro 文件格式解析器
211
+ - **[mujoco_wasm](https://github.com/zalo/mujoco_wasm)** - 编译为 WebAssembly 的 MuJoCo 物理引擎
212
+ - **[usd-viewer](https://github.com/needle-tools/usd-viewer)** - 支持丰富 USDStage 的 OpenUSD 查看器
213
+ - **[roslibjs](https://github.com/RobotWebTools/roslibjs)** - ROS WebSocket 通信的 JavaScript 库
214
+ - **[mechaverse](https://github.com/jurmy24/mechaverse)** - 通用 3D 机器人模型查看器,提供了宝贵的设计灵感
215
+
216
+ 感谢以上项目的维护者和贡献者的基础性工作。
217
+
218
+ 本项目部分开发借助了 [Cursor](https://cursor.sh)。
package/bin/cli.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const { spawn } = require('child_process');
6
+
7
+ const packageJson = JSON.parse(
8
+ fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')
9
+ );
10
+
11
+ function usage() {
12
+ console.log(`
13
+ IO Robot Viewer Mini v${packageJson.version}
14
+
15
+ 用法: robot-viewer [选项]
16
+
17
+ 选项:
18
+ -p, --port <port> 服务端口(默认 3000)
19
+ --host <host> 监听地址(默认 127.0.0.1)
20
+ -v, --version 显示版本
21
+ -h, --help 显示帮助
22
+ `);
23
+ }
24
+
25
+ function parseArgs(argv) {
26
+ const options = { port: 3000, host: '127.0.0.1' };
27
+ for (let i = 0; i < argv.length; i += 1) {
28
+ const arg = argv[i];
29
+ if (arg === '-p' || arg === '--port') {
30
+ options.port = Number(argv[++i]);
31
+ } else if (arg === '--host') {
32
+ options.host = argv[++i];
33
+ } else if (arg === '-v' || arg === '--version') {
34
+ console.log(packageJson.version);
35
+ process.exit(0);
36
+ } else if (arg === '-h' || arg === '--help') {
37
+ usage();
38
+ process.exit(0);
39
+ } else {
40
+ console.error(`未知参数: ${arg}`);
41
+ usage();
42
+ process.exit(1);
43
+ }
44
+ }
45
+
46
+ if (!Number.isInteger(options.port) || options.port < 1 || options.port > 65535) {
47
+ console.error('端口必须是 1-65535 之间的整数');
48
+ process.exit(1);
49
+ }
50
+ return options;
51
+ }
52
+
53
+ const root = path.join(__dirname, '..');
54
+ const distIndex = path.join(root, 'dist', 'index.html');
55
+ const serverEntry = path.join(root, 'server', 'static-server.js');
56
+
57
+ if (!fs.existsSync(distIndex) || !fs.existsSync(serverEntry)) {
58
+ console.error('npm 包缺少构建产物,无法启动 Robot Viewer。');
59
+ process.exit(1);
60
+ }
61
+
62
+ const options = parseArgs(process.argv.slice(2));
63
+ const child = spawn(process.execPath, [serverEntry], {
64
+ cwd: root,
65
+ env: {
66
+ ...process.env,
67
+ PORT: String(options.port),
68
+ HOST: options.host,
69
+ DIST_DIR: path.join(root, 'dist')
70
+ },
71
+ stdio: 'inherit'
72
+ });
73
+
74
+ child.on('error', error => {
75
+ console.error(`启动失败: ${error.message}`);
76
+ process.exit(1);
77
+ });
78
+
79
+ child.on('exit', code => process.exit(code ?? 1));
80
+
81
+ for (const signal of ['SIGINT', 'SIGTERM']) {
82
+ process.on(signal, () => child.kill(signal));
83
+ }
@@ -0,0 +1 @@
1
+ .uplot,.uplot *,.uplot *:before,.uplot *:after{box-sizing:border-box}.uplot{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";line-height:1.5;width:min-content}.u-title{text-align:center;font-size:18px;font-weight:700}.u-wrap{position:relative;-webkit-user-select:none;user-select:none}.u-over,.u-under{position:absolute}.u-under{overflow:hidden}.uplot canvas{display:block;position:relative;width:100%;height:100%}.u-axis{position:absolute}.u-legend{font-size:14px;margin:auto;text-align:center}.u-inline{display:block}.u-inline *{display:inline-block}.u-inline tr{margin-right:16px}.u-legend th{font-weight:600}.u-legend th>*{vertical-align:middle;display:inline-block}.u-legend .u-marker{width:1em;height:1em;margin-right:4px;background-clip:padding-box!important}.u-inline.u-live th:after{content:":";vertical-align:middle}.u-inline:not(.u-live) .u-value{display:none}.u-series>*{padding:4px}.u-series th{cursor:pointer}.u-legend .u-off>*{opacity:.3}.u-select{background:rgba(0,0,0,.07);position:absolute;pointer-events:none}.u-cursor-x,.u-cursor-y{position:absolute;left:0;top:0;pointer-events:none;will-change:transform}.u-hz .u-cursor-x,.u-vt .u-cursor-y{height:100%;border-right:1px dashed #607D8B}.u-hz .u-cursor-y,.u-vt .u-cursor-x{width:100%;border-bottom:1px dashed #607D8B}.u-cursor-pt{position:absolute;top:0;left:0;border-radius:50%;border:0 solid;pointer-events:none;will-change:transform;background-clip:padding-box!important}.u-axis.u-off,.u-select.u-off,.u-cursor-x.u-off,.u-cursor-y.u-off,.u-cursor-pt.u-off{display:none}
@@ -0,0 +1 @@
1
+ import{DataTextureLoader as e,LinearMipmapLinearFilter as t,Loader as n,LoaderUtils as s,FileLoader as i,Vector3 as o,Matrix4 as r,MeshBasicMaterial as a,Scene as c,TextureLoader as l,Color as d,MathUtils as u,AnimationClip as f,VectorKeyframeTrack as h,QuaternionKeyframeTrack as m,MeshLambertMaterial as p,MeshPhongMaterial as g,Vector2 as b,DoubleSide as y,FrontSide as N,PerspectiveCamera as w,OrthographicCamera as x,AmbientLight as A,SpotLight as k,PointLight as v,DirectionalLight as T,BufferGeometry as _,Float32BufferAttribute as C,Group as E,Quaternion as O,SRGBColorSpace as j,Bone as I,LineBasicMaterial as R,SkinnedMesh as q,Mesh as M,Line as S,LineSegments as z,RepeatWrapping as L,ClampToEdgeWrapping as U,Skeleton as G}from"./three-9c891de0.js";class B extends e{constructor(e){super(e)}parse(e){const n=0,s=1,i=2,o=3,r=9,a=10,c=11,l=48,d=4,u=0,f=1,h=2,m=3;if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let p=0;const g=new Uint8Array(e),b={id_length:g[p++],colormap_type:g[p++],image_type:g[p++],colormap_index:g[p++]|g[p++]<<8,colormap_length:g[p++]|g[p++]<<8,colormap_size:g[p++],origin:[g[p++]|g[p++]<<8,g[p++]|g[p++]<<8],width:g[p++]|g[p++]<<8,height:g[p++]|g[p++]<<8,pixel_size:g[p++],flags:g[p++]};if(function(e){switch(e.image_type){case s:case r:if(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case i:case o:case a:case c:if(e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case n:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+e.image_type)}if(e.width<=0||e.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size)throw new Error("THREE.TGALoader: Invalid pixel size "+e.pixel_size)}(b),b.id_length+p>e.length)throw new Error("THREE.TGALoader: No data.");p+=b.id_length;let y=!1,N=!1,w=!1;switch(b.image_type){case r:y=!0,N=!0;break;case s:N=!0;break;case a:y=!0;break;case i:break;case c:y=!0,w=!0;break;case o:w=!0}const x=new Uint8Array(b.width*b.height*4),A=function(e,t,n,s,i){let o,r;const a=n.pixel_size>>3,c=n.width*n.height*a;if(t&&(r=i.subarray(s,s+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;o=new Uint8Array(c);let r=0;const l=new Uint8Array(a);for(;r<c;)if(e=i[s++],t=1+(127&e),128&e){for(n=0;n<a;++n)l[n]=i[s++];for(n=0;n<t;++n)o.set(l,r+n*a);r+=a*t}else{for(t*=a,n=0;n<t;++n)o[r+n]=i[s++];r+=t}}else o=i.subarray(s,s+=t?n.width*n.height:c);return{pixel_data:o,palettes:r}}(y,N,b,p,g);return function(e,t,n,s,i){let o,r,a,c,p,g;switch((b.flags&l)>>d){default:case h:o=0,a=1,p=t,r=0,c=1,g=n;break;case u:o=0,a=1,p=t,r=n-1,c=-1,g=-1;break;case m:o=t-1,a=-1,p=-1,r=0,c=1,g=n;break;case f:o=t-1,a=-1,p=-1,r=n-1,c=-1,g=-1}if(w)switch(b.pixel_size){case 8:!function(e,t,n,s,i,o,r,a){let c,l,d,u=0;const f=b.width;for(d=t;d!==s;d+=n)for(l=i;l!==r;l+=o,u++)c=a[u],e[4*(l+f*d)+0]=c,e[4*(l+f*d)+1]=c,e[4*(l+f*d)+2]=c,e[4*(l+f*d)+3]=255}(e,r,c,g,o,a,p,s);break;case 16:!function(e,t,n,s,i,o,r,a){let c,l,d=0;const u=b.width;for(l=t;l!==s;l+=n)for(c=i;c!==r;c+=o,d+=2)e[4*(c+u*l)+0]=a[d+0],e[4*(c+u*l)+1]=a[d+0],e[4*(c+u*l)+2]=a[d+0],e[4*(c+u*l)+3]=a[d+1]}(e,r,c,g,o,a,p,s);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(b.pixel_size){case 8:!function(e,t,n,s,i,o,r,a,c){const l=c;let d,u,f,h=0;const m=b.width;for(f=t;f!==s;f+=n)for(u=i;u!==r;u+=o,h++)d=a[h],e[4*(u+m*f)+3]=255,e[4*(u+m*f)+2]=l[3*d+0],e[4*(u+m*f)+1]=l[3*d+1],e[4*(u+m*f)+0]=l[3*d+2]}(e,r,c,g,o,a,p,s,i);break;case 16:!function(e,t,n,s,i,o,r,a){let c,l,d,u=0;const f=b.width;for(d=t;d!==s;d+=n)for(l=i;l!==r;l+=o,u+=2)c=a[u+0]+(a[u+1]<<8),e[4*(l+f*d)+0]=(31744&c)>>7,e[4*(l+f*d)+1]=(992&c)>>2,e[4*(l+f*d)+2]=(31&c)<<3,e[4*(l+f*d)+3]=32768&c?0:255}(e,r,c,g,o,a,p,s);break;case 24:!function(e,t,n,s,i,o,r,a){let c,l,d=0;const u=b.width;for(l=t;l!==s;l+=n)for(c=i;c!==r;c+=o,d+=3)e[4*(c+u*l)+3]=255,e[4*(c+u*l)+2]=a[d+0],e[4*(c+u*l)+1]=a[d+1],e[4*(c+u*l)+0]=a[d+2]}(e,r,c,g,o,a,p,s);break;case 32:!function(e,t,n,s,i,o,r,a){let c,l,d=0;const u=b.width;for(l=t;l!==s;l+=n)for(c=i;c!==r;c+=o,d+=4)e[4*(c+u*l)+2]=a[d+0],e[4*(c+u*l)+1]=a[d+1],e[4*(c+u*l)+0]=a[d+2],e[4*(c+u*l)+3]=a[d+3]}(e,r,c,g,o,a,p,s);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(x,b.width,b.height,A.pixel_data,A.palettes),{data:x,width:b.width,height:b.height,flipY:!0,generateMipmaps:!0,minFilter:t}}}class F extends n{load(e,t,n,o){const r=this,a=""===r.path?s.extractUrlBase(e):r.path,c=new i(r.manager);c.setPath(r.path),c.setRequestHeader(r.requestHeader),c.setWithCredentials(r.withCredentials),c.load(e,function(n){try{t(r.parse(n,a))}catch(s){o&&o(s),r.manager.itemError(e)}},n,o)}parse(e,t){function s(e,t){const n=[],s=e.childNodes;for(let i=0,o=s.length;i<o;i++){const e=s[i];e.nodeName===t&&n.push(e)}return n}function i(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=t[s];return n}function F(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=parseFloat(t[s]);return n}function P(e){if(0===e.length)return[];const t=e.trim().split(/\s+/),n=new Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=parseInt(t[s]);return n}function H(e){return e.substring(1)}function V(){return"three_default_"+St++}function D(e){return 0===Object.keys(e).length}function J(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}function W(e){return void 0!==e?e.textContent:"Y_UP"}function X(e,t,n,i){const o=s(e,t)[0];if(void 0!==o){const e=s(o,n);for(let t=0;t<e.length;t++)i(e[t])}}function Z(e,t){for(const n in e){e[n].build=t(e[n])}}function K(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function Y(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"input"===s.nodeName){const e=H(s.getAttribute("source")),n=s.getAttribute("semantic");t.inputs[n]=e}}return t}function Q(e){const t={};let n=e.getAttribute("target").split("/");const s=n.shift();let i=n.shift();const o=-1!==i.indexOf("("),r=-1!==i.indexOf(".");if(r)n=i.split("."),i=n.shift(),t.member=n.shift();else if(o){const e=i.split("(");i=e.shift();for(let t=0;t<e.length;t++)e[t]=parseInt(e[t].replace(/\)/,""));t.indices=e}return t.id=s,t.sid=i,t.arraySyntax=o,t.memberSyntax=r,t.sampler=H(e.getAttribute("source")),t}function $(e){const t=[],n=e.channels,s=e.samplers,i=e.sources;for(const o in n)if(n.hasOwnProperty(o)){const e=n[o],r=s[e.sampler],a=r.inputs.INPUT,c=r.inputs.OUTPUT;oe(te(e,i[a],i[c]),t)}return t}function ee(e){return K(zt.animations[e],$)}function te(e,t,n){const s=zt.nodes[e.id],i=xt(s.id),o=s.transforms[e.sid],r=s.matrix.clone().transpose();let a,c,l,d,u,f;const h={};if("matrix"===o)for(l=0,d=t.array.length;l<d;l++)if(a=t.array[l],c=l*n.stride,void 0===h[a]&&(h[a]={}),!0===e.arraySyntax){const t=n.array[c],s=e.indices[0]+4*e.indices[1];h[a][s]=t}else for(u=0,f=n.stride;u<f;u++)h[a][u]=n.array[c+u];const m=function(e,t){const n=[];for(const i in e)n.push({time:parseFloat(i),value:e[i]});n.sort(s);for(let i=0;i<16;i++)re(n,i,t.elements[i]);return n;function s(e,t){return e.time-t.time}}(h,r);return{name:i.uuid,keyframes:m}}const ne=new o,se=new o,ie=new O;function oe(e,t){const n=e.keyframes,s=e.name,i=[],o=[],r=[],a=[];for(let c=0,l=n.length;c<l;c++){const e=n[c],t=e.time,s=e.value;dt.fromArray(s).transpose(),dt.decompose(ne,ie,se),i.push(t),o.push(ne.x,ne.y,ne.z),r.push(ie.x,ie.y,ie.z,ie.w),a.push(se.x,se.y,se.z)}return o.length>0&&t.push(new h(s+".position",i,o)),r.length>0&&t.push(new m(s+".quaternion",i,r)),a.length>0&&t.push(new h(s+".scale",i,a)),t}function re(e,t,n){let s,i,o,r=!0;for(i=0,o=e.length;i<o;i++)s=e[i],void 0===s.value[t]?s.value[t]=null:r=!1;if(!0===r)for(i=0,o=e.length;i<o;i++)s=e[i],s.value[t]=n;else!function(e,t){let n,s;for(let i=0,o=e.length;i<o;i++){const o=e[i];if(null===o.value[t]){if(n=ae(e,i,t),s=ce(e,i,t),null===n){o.value[t]=s.value[t];continue}if(null===s){o.value[t]=n.value[t];continue}le(o,n,s,t)}}}(e,t)}function ae(e,t,n){for(;t>=0;){const s=e[t];if(null!==s.value[n])return s;t--}return null}function ce(e,t,n){for(;t<e.length;){const s=e[t];if(null!==s.value[n])return s;t++}return null}function le(e,t,n,s){n.time-t.time!==0?e.value[s]=(e.time-t.time)*(n.value[s]-t.value[s])/(n.time-t.time)+t.value[s]:e.value[s]=t.value[s]}function de(e){const t=[],n=e.name,s=e.end-e.start||-1,i=e.animations;for(let o=0,r=i.length;o<r;o++){const e=ee(i[o]);for(let n=0,s=e.length;n<s;n++)t.push(e[n])}return new f(n,s,t)}function ue(e){return K(zt.clips[e],de)}function fe(e){const t={sources:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=F(s.textContent);break;case"source":const e=s.getAttribute("id");t.sources[e]=Ve(s);break;case"joints":t.joints=he(s);break;case"vertex_weights":t.vertexWeights=me(s)}}return t}function he(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"input"===s.nodeName){const e=s.getAttribute("semantic"),n=H(s.getAttribute("source"));t.inputs[e]=n}}return t}function me(e){const t={inputs:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=s.getAttribute("semantic"),n=H(s.getAttribute("source")),i=parseInt(s.getAttribute("offset"));t.inputs[e]={id:n,offset:i};break;case"vcount":t.vcount=P(s.textContent);break;case"v":t.v=P(s.textContent)}}return t}function pe(e){const t={id:e.id},n=zt.geometries[t.id];return void 0!==e.skin&&(t.skin=function(e){const t=4,n={joints:[],indices:{array:[],stride:t},weights:{array:[],stride:t}},s=e.sources,i=e.vertexWeights,o=i.vcount,a=i.v,c=i.inputs.JOINT.offset,l=i.inputs.WEIGHT.offset,d=e.sources[e.joints.inputs.JOINT],u=e.sources[e.joints.inputs.INV_BIND_MATRIX],f=s[i.inputs.WEIGHT.id].array;let h,m,p,g=0;for(h=0,p=o.length;h<p;h++){const e=o[h],s=[];for(m=0;m<e;m++){const e=a[g+c],t=f[a[g+l]];s.push({index:e,weight:t}),g+=2}for(s.sort(b),m=0;m<t;m++){const e=s[m];void 0!==e?(n.indices.array.push(e.index),n.weights.array.push(e.weight)):(n.indices.array.push(0),n.weights.array.push(0))}}e.bindShapeMatrix?n.bindMatrix=(new r).fromArray(e.bindShapeMatrix).transpose():n.bindMatrix=(new r).identity();for(h=0,p=d.array.length;h<p;h++){const e=d.array[h],t=(new r).fromArray(u.array,h*u.stride).transpose();n.joints.push({name:e,boneInverse:t})}return n;function b(e,t){return t.weight-e.weight}}(e.skin),n.sources.skinIndices=t.skin.indices,n.sources.skinWeights=t.skin.weights),t}function ge(e){return K(zt.controllers[e],pe)}function be(e){return void 0!==e.build?e.build:e.init_from}function ye(e){const t=zt.images[e];return void 0!==t?K(t,be):null}function Ne(e){const t={surfaces:{},samplers:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"newparam":we(s,t);break;case"technique":t.technique=ke(s);break;case"extra":t.extra=Oe(s)}}return t}function we(e,t){const n=e.getAttribute("sid");for(let s=0,i=e.childNodes.length;s<i;s++){const i=e.childNodes[s];if(1===i.nodeType)switch(i.nodeName){case"surface":t.surfaces[n]=xe(i);break;case"sampler2D":t.samplers[n]=Ae(i)}}}function xe(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"init_from"===s.nodeName)t.init_from=s.textContent}return t}function Ae(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"source"===s.nodeName)t.source=s.textContent}return t}function ke(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=s.nodeName,t.parameters=ve(s);break;case"extra":t.extra=Oe(s)}}return t}function ve(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[s.nodeName]=Te(s);break;case"transparent":t[s.nodeName]={opaque:s.hasAttribute("opaque")?s.getAttribute("opaque"):"A_ONE",data:Te(s)}}}return t}function Te(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"color":t[s.nodeName]=F(s.textContent);break;case"float":t[s.nodeName]=parseFloat(s.textContent);break;case"texture":t[s.nodeName]={id:s.getAttribute("texture"),extra:_e(s)}}}return t}function _e(e){const t={technique:{}};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"extra"===s.nodeName)Ce(s,t)}return t}function Ce(e,t){for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"technique"===s.nodeName)Ee(s,t)}}function Ee(e,t){for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[s.nodeName]=parseFloat(s.textContent);break;case"wrapU":case"wrapV":"TRUE"===s.textContent.toUpperCase()?t.technique[s.nodeName]=1:"FALSE"===s.textContent.toUpperCase()?t.technique[s.nodeName]=0:t.technique[s.nodeName]=parseInt(s.textContent);break;case"bump":t[s.nodeName]=Ie(s)}}}function Oe(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"technique"===s.nodeName)t.technique=je(s)}return t}function je(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"double_sided":t[s.nodeName]=parseInt(s.textContent);break;case"bump":t[s.nodeName]=Ie(s)}}return t}function Ie(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"texture"===s.nodeName)t[s.nodeName]={id:s.getAttribute("texture"),texcoord:s.getAttribute("texcoord"),extra:_e(s)}}return t}function Re(e){return e}function qe(e){const t=(n=e.url,K(zt.effects[n],Re));var n;const s=t.profile.technique;let i;switch(s.type){case"phong":case"blinn":i=new g;break;case"lambert":i=new p;break;default:i=new a}function o(e,n=null){const s=t.profile.samplers[e.id];let i=null;if(void 0!==s){i=ye(t.profile.surfaces[s.source].init_from)}else i=ye(e.id);if(null!==i){const t=function(e){let t,n=e.slice((e.lastIndexOf(".")-1>>>0)+2);n=n.toLowerCase(),t="tga"===n?It:jt;return t}(i);if(void 0!==t){const s=t.load(i),o=e.extra;if(void 0!==o&&void 0!==o.technique&&!1===D(o.technique)){const e=o.technique;s.wrapS=e.wrapU?L:U,s.wrapT=e.wrapV?L:U,s.offset.set(e.offsetU||0,e.offsetV||0),s.repeat.set(e.repeatU||1,e.repeatV||1)}else s.wrapS=L,s.wrapT=L;return null!==n&&(s.colorSpace=n),s}return null}return null}i.name=e.name||"";const r=s.parameters;for(const a in r){const e=r[a];switch(a){case"diffuse":e.color&&i.color.fromArray(e.color),e.texture&&(i.map=o(e.texture,j));break;case"specular":e.color&&i.specular&&i.specular.fromArray(e.color),e.texture&&(i.specularMap=o(e.texture));break;case"bump":e.texture&&(i.normalMap=o(e.texture));break;case"ambient":e.texture&&(i.lightMap=o(e.texture,j));break;case"shininess":e.float&&i.shininess&&(i.shininess=e.float);break;case"emission":e.color&&i.emissive&&i.emissive.fromArray(e.color),e.texture&&(i.emissiveMap=o(e.texture,j))}}i.color.convertSRGBToLinear(),i.specular&&i.specular.convertSRGBToLinear(),i.emissive&&i.emissive.convertSRGBToLinear();let c=r.transparent,l=r.transparency;if(void 0===l&&c&&(l={float:1}),void 0===c&&l&&(c={opaque:"A_ONE",data:{color:[1,1,1,1]}}),c&&l)if(c.data.texture)i.transparent=!0;else{const e=c.data.color;switch(c.opaque){case"A_ONE":i.opacity=e[3]*l.float;break;case"RGB_ZERO":i.opacity=1-e[0]*l.float;break;case"A_ZERO":i.opacity=1-e[3]*l.float;break;case"RGB_ONE":i.opacity=e[0]*l.float}i.opacity<1&&(i.transparent=!0)}if(void 0!==s.extra&&void 0!==s.extra.technique){const e=s.extra.technique;for(const t in e){const n=e[t];switch(t){case"double_sided":i.side=1===n?y:N;break;case"bump":i.normalMap=o(n.texture),i.normalScale=new b(1,1)}}}return i}function Me(e){return K(zt.materials[e],qe)}function Se(e){for(let t=0;t<e.childNodes.length;t++){const n=e.childNodes[t];if("technique_common"===n.nodeName)return ze(n)}return{}}function ze(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"perspective":case"orthographic":t.technique=s.nodeName,t.parameters=Le(s)}}return t}function Le(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[s.nodeName]=parseFloat(s.textContent)}}return t}function Ue(e){let t;switch(e.optics.technique){case"perspective":t=new w(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":let n=e.optics.parameters.ymag,s=e.optics.parameters.xmag;const i=e.optics.parameters.aspect_ratio;s=void 0===s?n*i:s,n=void 0===n?s/i:n,s*=.5,n*=.5,t=new x(-s,s,n,-n,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new w}return t.name=e.name||"",t}function Ge(e){const t=zt.cameras[e];return void 0!==t?K(t,Ue):null}function Be(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=s.nodeName,t.parameters=Fe(s)}}return t}function Fe(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"color":const e=F(s.textContent);t.color=(new d).fromArray(e).convertSRGBToLinear();break;case"falloff_angle":t.falloffAngle=parseFloat(s.textContent);break;case"quadratic_attenuation":const n=parseFloat(s.textContent);t.distance=n?Math.sqrt(1/n):0}}return t}function Pe(e){let t;switch(e.technique){case"directional":t=new T;break;case"point":t=new v;break;case"spot":t=new k;break;case"ambient":t=new A}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function He(e){const t=zt.lights[e];return void 0!==t?K(t,Pe):null}function Ve(e){const t={array:[],stride:3};for(let n=0;n<e.childNodes.length;n++){const o=e.childNodes[n];if(1===o.nodeType)switch(o.nodeName){case"float_array":t.array=F(o.textContent);break;case"Name_array":t.array=i(o.textContent);break;case"technique_common":const e=s(o,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function De(e){const t={};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];1===s.nodeType&&(t[s.getAttribute("semantic")]=H(s.getAttribute("source")))}return t}function Je(e){const t={type:e.nodeName,material:e.getAttribute("material"),count:parseInt(e.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"input":const e=H(s.getAttribute("source")),n=s.getAttribute("semantic"),i=parseInt(s.getAttribute("offset")),o=parseInt(s.getAttribute("set")),r=o>0?n+o:n;t.inputs[r]={id:e,offset:i},t.stride=Math.max(t.stride,i+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=P(s.textContent);break;case"p":t.p=P(s.textContent)}}return t}function We(e){let t=0;for(let n=0,s=e.length;n<s;n++){!0===e[n].hasUV&&t++}t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function Xe(e){const t={},n=e.sources,s=e.vertices,i=e.primitives;if(0===i.length)return{};const o=function(e){const t={};for(let n=0;n<e.length;n++){const s=e[n];void 0===t[s.type]&&(t[s.type]=[]),t[s.type].push(s)}return t}(i);for(const r in o){const e=o[r];We(e),t[r]=Ze(e,n,s)}return t}function Ze(e,t,n){const s={},i={array:[],stride:0},o={array:[],stride:0},r={array:[],stride:0},a={array:[],stride:0},c={array:[],stride:0},l=[],d=4,u=[],f=4,h=new _,m=[];let p=0;for(let g=0;g<e.length;g++){const s=e[g],d=s.inputs;let f=0;switch(s.type){case"lines":case"linestrips":f=2*s.count;break;case"triangles":f=3*s.count;break;case"polylist":for(let e=0;e<s.count;e++){const t=s.vcount[e];switch(t){case 3:f+=3;break;case 4:f+=6;break;default:f+=3*(t-2)}}}h.addGroup(p,f,g),p+=f,s.material&&m.push(s.material);for(const h in d){const f=d[h];switch(h){case"VERTEX":for(const d in n){const h=n[d];switch(d){case"POSITION":const n=i.array.length;if(Ke(s,t[h],f.offset,i.array),i.stride=t[h].stride,t.skinWeights&&t.skinIndices&&(Ke(s,t.skinIndices,f.offset,l),Ke(s,t.skinWeights,f.offset,u)),!1===s.hasUV&&!0===e.uvsNeedsFix){const e=(i.array.length-n)/i.stride;for(let t=0;t<e;t++)r.array.push(0,0)}break;case"NORMAL":Ke(s,t[h],f.offset,o.array),o.stride=t[h].stride;break;case"COLOR":Ke(s,t[h],f.offset,c.array),c.stride=t[h].stride;break;case"TEXCOORD":Ke(s,t[h],f.offset,r.array),r.stride=t[h].stride;break;case"TEXCOORD1":Ke(s,t[h],f.offset,a.array),r.stride=t[h].stride}}break;case"NORMAL":Ke(s,t[f.id],f.offset,o.array),o.stride=t[f.id].stride;break;case"COLOR":Ke(s,t[f.id],f.offset,c.array,!0),c.stride=t[f.id].stride;break;case"TEXCOORD":Ke(s,t[f.id],f.offset,r.array),r.stride=t[f.id].stride;break;case"TEXCOORD1":Ke(s,t[f.id],f.offset,a.array),a.stride=t[f.id].stride}}}return i.array.length>0&&h.setAttribute("position",new C(i.array,i.stride)),o.array.length>0&&h.setAttribute("normal",new C(o.array,o.stride)),c.array.length>0&&h.setAttribute("color",new C(c.array,c.stride)),r.array.length>0&&h.setAttribute("uv",new C(r.array,r.stride)),a.array.length>0&&h.setAttribute("uv1",new C(a.array,a.stride)),l.length>0&&h.setAttribute("skinIndex",new C(l,d)),u.length>0&&h.setAttribute("skinWeight",new C(u,f)),s.data=h,s.type=e[0].type,s.materialKeys=m,s}function Ke(e,t,n,s,i=!1){const o=e.p,r=e.stride,a=e.vcount;function c(e){let t=o[e+n]*d;const r=t+d;for(;t<r;t++)s.push(l[t]);if(i){const e=s.length-d-1;Rt.setRGB(s[e+0],s[e+1],s[e+2]).convertSRGBToLinear(),s[e+0]=Rt.r,s[e+1]=Rt.g,s[e+2]=Rt.b}}const l=t.array,d=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,n=a.length;t<n;t++){const n=a[t];if(4===n){const t=e+1*r,n=e+2*r,s=e+3*r;c(e+0*r),c(t),c(s),c(t),c(n),c(s)}else if(3===n){const t=e+1*r,n=e+2*r;c(e+0*r),c(t),c(n)}else if(n>4)for(let t=1,s=n-2;t<=s;t++){const n=e+r*t,s=e+r*(t+1);c(e+0*r),c(n),c(s)}e+=r*n}}else for(let u=0,f=o.length;u<f;u+=r)c(u)}function Ye(e){return K(zt.geometries[e],Xe)}function Qe(e){return void 0!==e.build?e.build:e}function $e(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"joint":t.joints[s.getAttribute("sid")]=et(s);break;case"link":t.links.push(nt(s))}}}function et(e){let t;for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"prismatic":case"revolute":t=tt(s)}}return t}function tt(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new o,limits:{min:0,max:0},type:e.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"axis":const e=F(s.textContent);t.axis.fromArray(e);break;case"limits":const n=s.getElementsByTagName("max")[0],i=s.getElementsByTagName("min")[0];t.limits.max=parseFloat(n.textContent),t.limits.min=parseFloat(i.textContent)}}return t.limits.min>=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function nt(e){const t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"attachment_full":t.attachments.push(st(s));break;case"matrix":case"translate":case"rotate":t.transforms.push(it(s))}}return t}function st(e){const t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"link":t.links.push(nt(s));break;case"matrix":case"translate":case"rotate":t.transforms.push(it(s))}}return t}function it(e){const t={type:e.nodeName},n=F(e.textContent);switch(t.type){case"matrix":t.obj=new r,t.obj.fromArray(n).transpose();break;case"translate":t.obj=new o,t.obj.fromArray(n);break;case"rotate":t.obj=new o,t.obj.fromArray(n),t.angle=u.degToRad(n[3])}return t}function ot(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType&&"technique_common"===s.nodeName)rt(s,t)}}function rt(e,t){for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"inertia":t.inertia=F(s.textContent);break;case"mass":t.mass=F(s.textContent)[0]}}}function at(e){const t={target:e.getAttribute("target").split("/").pop()};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType&&"axis"===s.nodeName){const e=s.getElementsByTagName("param")[0];t.axis=e.textContent;const n=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=n.substring(0,n.length-1)}}return t}function ct(e){return void 0!==e.build?e.build:e}function lt(e){const t=[],n=_t.querySelector('[id="'+e.id+'"]');for(let s=0;s<n.childNodes.length;s++){const e=n.childNodes[s];if(1!==e.nodeType)continue;let i,a;switch(e.nodeName){case"matrix":i=F(e.textContent);const n=(new r).fromArray(i).transpose();t.push({sid:e.getAttribute("sid"),type:e.nodeName,obj:n});break;case"translate":case"scale":i=F(e.textContent),a=(new o).fromArray(i),t.push({sid:e.getAttribute("sid"),type:e.nodeName,obj:a});break;case"rotate":i=F(e.textContent),a=(new o).fromArray(i);const s=u.degToRad(i[3]);t.push({sid:e.getAttribute("sid"),type:e.nodeName,obj:a,angle:s})}}return t}const dt=new r,ut=new o;function ft(e){const t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new r,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1!==s.nodeType)continue;let i;switch(s.nodeName){case"node":t.nodes.push(s.getAttribute("id")),ft(s);break;case"instance_camera":t.instanceCameras.push(H(s.getAttribute("url")));break;case"instance_controller":t.instanceControllers.push(ht(s));break;case"instance_light":t.instanceLights.push(H(s.getAttribute("url")));break;case"instance_geometry":t.instanceGeometries.push(ht(s));break;case"instance_node":t.instanceNodes.push(H(s.getAttribute("url")));break;case"matrix":i=F(s.textContent),t.matrix.multiply(dt.fromArray(i).transpose()),t.transforms[s.getAttribute("sid")]=s.nodeName;break;case"translate":i=F(s.textContent),ut.fromArray(i),t.matrix.multiply(dt.makeTranslation(ut.x,ut.y,ut.z)),t.transforms[s.getAttribute("sid")]=s.nodeName;break;case"rotate":i=F(s.textContent);const e=u.degToRad(i[3]);t.matrix.multiply(dt.makeRotationAxis(ut.fromArray(i),e)),t.transforms[s.getAttribute("sid")]=s.nodeName;break;case"scale":i=F(s.textContent),t.matrix.scale(ut.fromArray(i)),t.transforms[s.getAttribute("sid")]=s.nodeName}}return wt(t.id)||(zt.nodes[t.id]=t),t}function ht(e){const t={id:H(e.getAttribute("url")),materials:{},skeletons:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];switch(s.nodeName){case"bind_material":const e=s.getElementsByTagName("instance_material");for(let n=0;n<e.length;n++){const s=e[n],i=s.getAttribute("symbol"),o=s.getAttribute("target");t.materials[i]=H(o)}break;case"skeleton":t.skeletons.push(H(s.textContent))}}return t}function mt(e,t){const n=[],s=[];let i,o,r;for(i=0;i<e.length;i++){const s=e[i];let o;if(wt(s))o=xt(s),pt(o,t,n);else if(kt(s)){const e=zt.visualScenes[s].children;for(let s=0;s<e.length;s++){const i=e[s];if("JOINT"===i.type){pt(xt(i.id),t,n)}}}}for(i=0;i<t.length;i++)for(o=0;o<n.length;o++)if(r=n[o],r.bone.name===t[i].name){s[i]=r,r.processed=!0;break}for(i=0;i<n.length;i++)r=n[i],!1===r.processed&&(s.push(r),r.processed=!0);const a=[],c=[];for(i=0;i<s.length;i++)r=s[i],a.push(r.bone),c.push(r.boneInverse);return new G(a,c)}function pt(e,t,n){e.traverse(function(e){if(!0===e.isBone){let s;for(let n=0;n<t.length;n++){const i=t[n];if(i.name===e.name){s=i.boneInverse;break}}void 0===s&&(s=new r),n.push({bone:e,boneInverse:s,processed:!1})}})}function gt(e){const t=[],n=e.matrix,s=e.nodes,i=e.type,o=e.instanceCameras,r=e.instanceControllers,a=e.instanceLights,c=e.instanceGeometries,l=e.instanceNodes;for(let u=0,f=s.length;u<f;u++)t.push(xt(s[u]));for(let u=0,f=o.length;u<f;u++){const e=Ge(o[u]);null!==e&&t.push(e.clone())}for(let u=0,f=r.length;u<f;u++){const e=r[u],n=ge(e.id),s=Nt(Ye(n.id),e.materials),i=mt(e.skeletons,n.skin.joints);for(let o=0,r=s.length;o<r;o++){const e=s[o];e.isSkinnedMesh&&(e.bind(i,n.skin.bindMatrix),e.normalizeSkinWeights()),t.push(e)}}for(let u=0,f=a.length;u<f;u++){const e=He(a[u]);null!==e&&t.push(e.clone())}for(let u=0,f=c.length;u<f;u++){const e=c[u],n=Nt(Ye(e.id),e.materials);for(let s=0,i=n.length;s<i;s++)t.push(n[s])}for(let u=0,f=l.length;u<f;u++)t.push(xt(l[u]).clone());let d;if(0===s.length&&1===t.length)d=t[0];else{d="JOINT"===i?new I:new E;for(let e=0;e<t.length;e++)d.add(t[e])}return d.name="JOINT"===i?e.sid:e.name,d.matrix.copy(n),d.matrix.decompose(d.position,d.quaternion,d.scale),d}const bt=new a({name:n.DEFAULT_MATERIAL_NAME,color:16711935});function yt(e,t){const n=[];for(let s=0,i=e.length;s<i;s++){const i=t[e[s]];void 0===i?n.push(bt):n.push(Me(i))}return n}function Nt(e,t){const n=[];for(const s in e){const i=e[s],o=yt(i.materialKeys,t);if(0===o.length&&("lines"===s||"linestrips"===s?o.push(new R):o.push(new g)),"lines"===s||"linestrips"===s)for(let e=0,t=o.length;e<t;e++){const t=o[e];if(!0===t.isMeshPhongMaterial||!0===t.isMeshLambertMaterial){const n=new R;n.color.copy(t.color),n.opacity=t.opacity,n.transparent=t.transparent,o[e]=n}}const r=void 0!==i.data.attributes.skinIndex,a=1===o.length?o[0]:o;let c;switch(s){case"lines":c=new z(i.data,a);break;case"linestrips":c=new S(i.data,a);break;case"triangles":case"polylist":c=r?new q(i.data,a):new M(i.data,a)}n.push(c)}return n}function wt(e){return void 0!==zt.nodes[e]}function xt(e){return K(zt.nodes[e],gt)}function At(e){const t=new E;t.name=e.name;const n=e.children;for(let s=0;s<n.length;s++){const e=n[s];t.add(xt(e.id))}return t}function kt(e){return void 0!==zt.visualScenes[e]}function vt(e){return K(zt.visualScenes[e],At)}if(0===e.length)return{scene:new c};const Tt=(new DOMParser).parseFromString(e,"application/xml"),_t=s(Tt,"COLLADA")[0],Ct=Tt.getElementsByTagName("parsererror")[0];if(void 0!==Ct){const e=s(Ct,"div")[0];let t;return t=e?e.textContent:function(e){let t="";const n=[e];for(;n.length;){const e=n.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",n.push.apply(n,e.childNodes))}return t.trim()}(Ct),null}_t.getAttribute("version");const Et=(Ot=s(_t,"asset")[0],{unit:J(s(Ot,"unit")[0]),upAxis:W(s(Ot,"up_axis")[0])});var Ot;const jt=new l(this.manager);let It;jt.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),B&&(It=new B(this.manager),It.setPath(this.resourcePath||t));const Rt=new d,qt=[];let Mt={},St=0;const zt={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};X(_t,"library_animations","animation",function e(t){const n={sources:{},samplers:{},channels:{}};let s=!1;for(let i=0,o=t.childNodes.length;i<o;i++){const o=t.childNodes[i];if(1!==o.nodeType)continue;let r;switch(o.nodeName){case"source":r=o.getAttribute("id"),n.sources[r]=Ve(o);break;case"sampler":r=o.getAttribute("id"),n.samplers[r]=Y(o);break;case"channel":r=o.getAttribute("target"),n.channels[r]=Q(o);break;case"animation":e(o),s=!0}}!1===s&&(zt.animations[t.getAttribute("id")||u.generateUUID()]=n)}),X(_t,"library_animation_clips","animation_clip",function(e){const t={name:e.getAttribute("id")||"default",start:parseFloat(e.getAttribute("start")||0),end:parseFloat(e.getAttribute("end")||0),animations:[]};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"instance_animation"===s.nodeName)t.animations.push(H(s.getAttribute("url")))}zt.clips[e.getAttribute("id")]=t}),X(_t,"library_controllers","controller",function(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"skin":t.id=H(s.getAttribute("source")),t.skin=fe(s);break;case"morph":t.id=H(s.getAttribute("source"))}}zt.controllers[e.getAttribute("id")]=t}),X(_t,"library_images","image",function(e){const t={init_from:s(e,"init_from")[0].textContent};zt.images[e.getAttribute("id")]=t}),X(_t,"library_effects","effect",function(e){const t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"profile_COMMON"===s.nodeName)t.profile=Ne(s)}zt.effects[e.getAttribute("id")]=t}),X(_t,"library_materials","material",function(e){const t={name:e.getAttribute("name")};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"instance_effect"===s.nodeName)t.url=H(s.getAttribute("url"))}zt.materials[e.getAttribute("id")]=t}),X(_t,"library_cameras","camera",function(e){const t={name:e.getAttribute("name")};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"optics"===s.nodeName)t.optics=Se(s)}zt.cameras[e.getAttribute("id")]=t}),X(_t,"library_lights","light",function(e){let t={};for(let n=0,s=e.childNodes.length;n<s;n++){const s=e.childNodes[n];if(1===s.nodeType&&"technique_common"===s.nodeName)t=Be(s)}zt.lights[e.getAttribute("id")]=t}),X(_t,"library_geometries","geometry",function(e){const t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},n=s(e,"mesh")[0];if(void 0!==n){for(let e=0;e<n.childNodes.length;e++){const s=n.childNodes[e];if(1!==s.nodeType)continue;const i=s.getAttribute("id");switch(s.nodeName){case"source":t.sources[i]=Ve(s);break;case"vertices":t.vertices=De(s);break;case"polygons":break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(Je(s))}}zt.geometries[e.getAttribute("id")]=t}}),X(_t,"library_nodes","node",ft),X(_t,"library_visual_scenes","visual_scene",function(e){const t={name:e.getAttribute("name"),children:[]};!function(e){const t=e.getElementsByTagName("node");for(let n=0;n<t.length;n++){const e=t[n];!1===e.hasAttribute("id")&&e.setAttribute("id",V())}}(e);const n=s(e,"node");for(let s=0;s<n.length;s++)t.children.push(ft(n[s]));zt.visualScenes[e.getAttribute("id")]=t}),X(_t,"library_kinematics_models","kinematics_model",function(e){const t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType&&"technique_common"===s.nodeName)$e(s,t)}zt.kinematicsModels[e.getAttribute("id")]=t}),X(_t,"library_physics_models","physics_model",function(e){const t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType&&"rigid_body"===s.nodeName)t.rigidBodies[s.getAttribute("name")]={},ot(s,t.rigidBodies[s.getAttribute("name")])}zt.physicsModels[e.getAttribute("id")]=t}),X(_t,"scene","instance_kinematics_scene",function(e){const t={bindJointAxis:[]};for(let n=0;n<e.childNodes.length;n++){const s=e.childNodes[n];if(1===s.nodeType&&"bind_joint_axis"===s.nodeName)t.bindJointAxis.push(at(s))}zt.kinematicsScenes[H(e.getAttribute("url"))]=t}),Z(zt.animations,$),Z(zt.clips,de),Z(zt.controllers,pe),Z(zt.images,be),Z(zt.effects,Re),Z(zt.materials,qe),Z(zt.cameras,Ue),Z(zt.lights,Pe),Z(zt.geometries,Xe),Z(zt.visualScenes,At),function(){const e=zt.clips;if(!0===D(e)){if(!1===D(zt.animations)){const e=[];for(const t in zt.animations){const n=ee(t);for(let t=0,s=n.length;t<s;t++)e.push(n[t])}qt.push(new f("default",-1,e))}}else for(const t in e)qt.push(ue(t))}(),function(){const e=Object.keys(zt.kinematicsModels)[0],t=Object.keys(zt.kinematicsScenes)[0],n=Object.keys(zt.visualScenes)[0];if(void 0===e||void 0===t)return;const s=(i=e,K(zt.kinematicsModels[i],Qe));var i;const o=function(e){return K(zt.kinematicsScenes[e],ct)}(t),a=vt(n),c=o.bindJointAxis,l={};for(let r=0,u=c.length;r<u;r++){const e=c[r],t=_t.querySelector('[sid="'+e.target+'"]');if(t){const n=t.parentElement;d(e.jointIndex,n)}}function d(e,t){const n=t.getAttribute("name"),i=s.joints[e];a.traverse(function(s){s.name===n&&(l[e]={object:s,transforms:lt(t),joint:i,position:i.zeroPosition})})}const f=new r;Mt={joints:s&&s.joints,getJointValue:function(e){const t=l[e];if(t)return t.position},setJointValue:function(e,t){const n=l[e];if(n){const s=n.joint;if(t>s.limits.max||t<s.limits.min);else if(s.static);else{const i=n.object,o=s.axis,r=n.transforms;dt.identity();for(let n=0;n<r.length;n++){const i=r[n];if(i.sid&&-1!==i.sid.indexOf(e))switch(s.type){case"revolute":dt.multiply(f.makeRotationAxis(o,u.degToRad(t)));break;case"prismatic":dt.multiply(f.makeTranslation(o.x*t,o.y*t,o.z*t))}else switch(i.type){case"matrix":dt.multiply(i.obj);break;case"translate":dt.multiply(f.makeTranslation(i.obj.x,i.obj.y,i.obj.z));break;case"scale":dt.scale(i.obj);break;case"rotate":dt.multiply(f.makeRotationAxis(i.obj,i.angle))}}i.matrix.copy(dt),i.matrix.decompose(i.position,i.quaternion,i.scale),l[e].position=t}}}}}();const Lt=function(e){return vt(H(s(e,"instance_visual_scene")[0].getAttribute("url")))}(s(_t,"scene")[0]);return Lt.animations=qt,"Z_UP"===Et.upAxis&&Lt.rotation.set(-Math.PI/2,0,0),Lt.scale.multiplyScalar(Et.unit),{get animations(){return qt},kinematics:Mt,library:zt,scene:Lt}}}export{F as ColladaLoader};