@volter/blender-engine 0.1.148 → 0.1.150

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 (245) hide show
  1. package/LICENSE +22 -5
  2. package/README.md +4 -11
  3. package/browser/addons/vrm/LICENSE_(OPTION1)_MIT.txt +22 -0
  4. package/browser/addons/vrm/LICENSE_(OPTION2)_GPL-3_0.txt +674 -0
  5. package/browser/addons/vrm/LICENSE_MAIN.txt +1 -0
  6. package/browser/addons/vrm/README.txt +3 -0
  7. package/browser/addons/vrm/__init__.py +41 -0
  8. package/browser/addons/vrm/blender_manifest.toml +16 -0
  9. package/browser/addons/vrm/common/__init__.py +1 -0
  10. package/browser/addons/vrm/common/animation.py +58 -0
  11. package/browser/addons/vrm/common/blender_manifest.py +82 -0
  12. package/browser/addons/vrm/common/char.py +16 -0
  13. package/browser/addons/vrm/common/convert.py +287 -0
  14. package/browser/addons/vrm/common/convert_any.py +48 -0
  15. package/browser/addons/vrm/common/debug.py +40 -0
  16. package/browser/addons/vrm/common/deep.py +162 -0
  17. package/browser/addons/vrm/common/error_dialog.py +274 -0
  18. package/browser/addons/vrm/common/fs.py +71 -0
  19. package/browser/addons/vrm/common/gl.py +20 -0
  20. package/browser/addons/vrm/common/gltf.py +1149 -0
  21. package/browser/addons/vrm/common/human_bone_mapper/__init__.py +1 -0
  22. package/browser/addons/vrm/common/human_bone_mapper/biped_mapping.py +84 -0
  23. package/browser/addons/vrm/common/human_bone_mapper/cats_blender_plugin_fix_model_mapping.py +63 -0
  24. package/browser/addons/vrm/common/human_bone_mapper/human_bone_mapper.py +203 -0
  25. package/browser/addons/vrm/common/human_bone_mapper/microsoft_rocketbox_mapping.py +69 -0
  26. package/browser/addons/vrm/common/human_bone_mapper/mixamo_mapping.py +62 -0
  27. package/browser/addons/vrm/common/human_bone_mapper/mmd_mapping.py +115 -0
  28. package/browser/addons/vrm/common/human_bone_mapper/mpfb_mapping.py +120 -0
  29. package/browser/addons/vrm/common/human_bone_mapper/ready_player_me_mapping.py +65 -0
  30. package/browser/addons/vrm/common/human_bone_mapper/reallusion_mapping.py +94 -0
  31. package/browser/addons/vrm/common/human_bone_mapper/rigify_meta_rig_mapping.py +65 -0
  32. package/browser/addons/vrm/common/human_bone_mapper/structure_based_mapping.py +891 -0
  33. package/browser/addons/vrm/common/human_bone_mapper/unreal_mapping.py +62 -0
  34. package/browser/addons/vrm/common/human_bone_mapper/vrm_addon_mapping.py +112 -0
  35. package/browser/addons/vrm/common/human_bone_mapper/vroid_mapping.py +89 -0
  36. package/browser/addons/vrm/common/legacy_gltf.py +16 -0
  37. package/browser/addons/vrm/common/logger.py +84 -0
  38. package/browser/addons/vrm/common/mtoon0.blend +0 -0
  39. package/browser/addons/vrm/common/mtoon1.blend +0 -0
  40. package/browser/addons/vrm/common/mtoon1_outline.blend +0 -0
  41. package/browser/addons/vrm/common/mtoon_auto_setup.blend +0 -0
  42. package/browser/addons/vrm/common/mtoon_unversioned.py +62 -0
  43. package/browser/addons/vrm/common/ops/__init__.py +10 -0
  44. package/browser/addons/vrm/common/ops/export_scene.py +67 -0
  45. package/browser/addons/vrm/common/ops/icyp.py +53 -0
  46. package/browser/addons/vrm/common/ops/import_scene.py +57 -0
  47. package/browser/addons/vrm/common/ops/vrm.py +2380 -0
  48. package/browser/addons/vrm/common/ops/wm.py +167 -0
  49. package/browser/addons/vrm/common/preferences.py +362 -0
  50. package/browser/addons/vrm/common/progress.py +87 -0
  51. package/browser/addons/vrm/common/rotation.py +89 -0
  52. package/browser/addons/vrm/common/safe_removal.py +46 -0
  53. package/browser/addons/vrm/common/scene_watcher.py +230 -0
  54. package/browser/addons/vrm/common/shader.py +2243 -0
  55. package/browser/addons/vrm/common/shape_key_mapper/__init__.py +1 -0
  56. package/browser/addons/vrm/common/shape_key_mapper/arkit_mapping.py +168 -0
  57. package/browser/addons/vrm/common/shape_key_mapper/mmd_mapping.py +62 -0
  58. package/browser/addons/vrm/common/shape_key_mapper/ready_player_me_mapping.py +52 -0
  59. package/browser/addons/vrm/common/shape_key_mapper/vrchat_mapping.py +17 -0
  60. package/browser/addons/vrm/common/third_party_user_extension.py +214 -0
  61. package/browser/addons/vrm/common/transparent_z_write.blend +0 -0
  62. package/browser/addons/vrm/common/version.py +161 -0
  63. package/browser/addons/vrm/common/vrm0/__init__.py +1 -0
  64. package/browser/addons/vrm/common/vrm0/human_bone.py +662 -0
  65. package/browser/addons/vrm/common/vrm0/material_property.py +346 -0
  66. package/browser/addons/vrm/common/vrm1/__init__.py +1 -0
  67. package/browser/addons/vrm/common/vrm1/expression_preset.py +207 -0
  68. package/browser/addons/vrm/common/vrm1/human_bone.py +822 -0
  69. package/browser/addons/vrm/common/workspace.py +227 -0
  70. package/browser/addons/vrm/common/writable_context.py +77 -0
  71. package/browser/addons/vrm/documentation/en-us/animation/index.md +63 -0
  72. package/browser/addons/vrm/documentation/en-us/create-humanoid-vrm-from-scratch/index.md +131 -0
  73. package/browser/addons/vrm/documentation/en-us/create-simple-vrm-from-scratch/index.md +30 -0
  74. package/browser/addons/vrm/documentation/en-us/development/index.md +136 -0
  75. package/browser/addons/vrm/documentation/en-us/index.md +41 -0
  76. package/browser/addons/vrm/documentation/en-us/installation/index.md +152 -0
  77. package/browser/addons/vrm/documentation/en-us/material-mtoon/index.md +122 -0
  78. package/browser/addons/vrm/documentation/en-us/material-pbr/index.md +94 -0
  79. package/browser/addons/vrm/documentation/en-us/scripting-api/index.md +391 -0
  80. package/browser/addons/vrm/documentation/en-us/ui/export_scene.vrm/index.md +57 -0
  81. package/browser/addons/vrm/documentation/en-us/ui/export_scene.vrma/index.md +17 -0
  82. package/browser/addons/vrm/documentation/en-us/ui/import_scene.vrm/index.md +61 -0
  83. package/browser/addons/vrm/documentation/en-us/ui/import_scene.vrma/index.md +13 -0
  84. package/browser/addons/vrm/documentation/ja-jp/animation/index.md +57 -0
  85. package/browser/addons/vrm/documentation/ja-jp/create-humanoid-vrm-from-scratch/index.md +129 -0
  86. package/browser/addons/vrm/documentation/ja-jp/create-simple-vrm-from-scratch/index.md +29 -0
  87. package/browser/addons/vrm/documentation/ja-jp/development/index.md +137 -0
  88. package/browser/addons/vrm/documentation/ja-jp/index.md +37 -0
  89. package/browser/addons/vrm/documentation/ja-jp/installation/index.md +150 -0
  90. package/browser/addons/vrm/documentation/ja-jp/material-mtoon/index.md +113 -0
  91. package/browser/addons/vrm/documentation/ja-jp/material-pbr/index.md +90 -0
  92. package/browser/addons/vrm/documentation/ja-jp/scripting-api/index.md +389 -0
  93. package/browser/addons/vrm/documentation/ja-jp/ui/export_scene.vrm/index.md +55 -0
  94. package/browser/addons/vrm/documentation/ja-jp/ui/export_scene.vrma/index.md +19 -0
  95. package/browser/addons/vrm/documentation/ja-jp/ui/import_scene.vrm/index.md +56 -0
  96. package/browser/addons/vrm/documentation/ja-jp/ui/import_scene.vrma/index.md +14 -0
  97. package/browser/addons/vrm/editor/__init__.py +1 -0
  98. package/browser/addons/vrm/editor/extension.py +425 -0
  99. package/browser/addons/vrm/editor/extension_accessor.py +75 -0
  100. package/browser/addons/vrm/editor/handler.py +84 -0
  101. package/browser/addons/vrm/editor/khr_character/__init__.py +1 -0
  102. package/browser/addons/vrm/editor/khr_character/panel.py +69 -0
  103. package/browser/addons/vrm/editor/khr_character/property_group.py +27 -0
  104. package/browser/addons/vrm/editor/khr_xmp_json_ld/__init__.py +1 -0
  105. package/browser/addons/vrm/editor/khr_xmp_json_ld/ops.py +464 -0
  106. package/browser/addons/vrm/editor/khr_xmp_json_ld/panel.py +136 -0
  107. package/browser/addons/vrm/editor/khr_xmp_json_ld/property_group.py +83 -0
  108. package/browser/addons/vrm/editor/khr_xmp_json_ld/ui_list.py +198 -0
  109. package/browser/addons/vrm/editor/make_armature.py +709 -0
  110. package/browser/addons/vrm/editor/menu.py +147 -0
  111. package/browser/addons/vrm/editor/migration.py +297 -0
  112. package/browser/addons/vrm/editor/mtoon1/__init__.py +1 -0
  113. package/browser/addons/vrm/editor/mtoon1/handler.py +20 -0
  114. package/browser/addons/vrm/editor/mtoon1/migration.py +536 -0
  115. package/browser/addons/vrm/editor/mtoon1/ops.py +304 -0
  116. package/browser/addons/vrm/editor/mtoon1/panel.py +442 -0
  117. package/browser/addons/vrm/editor/mtoon1/property_group.py +4977 -0
  118. package/browser/addons/vrm/editor/mtoon1/scene_watcher.py +381 -0
  119. package/browser/addons/vrm/editor/node_constraint1/__init__.py +1 -0
  120. package/browser/addons/vrm/editor/node_constraint1/panel.py +317 -0
  121. package/browser/addons/vrm/editor/node_constraint1/property_group.py +25 -0
  122. package/browser/addons/vrm/editor/ops.py +471 -0
  123. package/browser/addons/vrm/editor/panel.py +315 -0
  124. package/browser/addons/vrm/editor/property_group.py +888 -0
  125. package/browser/addons/vrm/editor/search.py +682 -0
  126. package/browser/addons/vrm/editor/spring_bone1/__init__.py +1 -0
  127. package/browser/addons/vrm/editor/spring_bone1/handler.py +994 -0
  128. package/browser/addons/vrm/editor/spring_bone1/menu.py +246 -0
  129. package/browser/addons/vrm/editor/spring_bone1/migration.py +86 -0
  130. package/browser/addons/vrm/editor/spring_bone1/ops.py +1679 -0
  131. package/browser/addons/vrm/editor/spring_bone1/panel.py +605 -0
  132. package/browser/addons/vrm/editor/spring_bone1/property_group.py +1457 -0
  133. package/browser/addons/vrm/editor/spring_bone1/ui_list.py +408 -0
  134. package/browser/addons/vrm/editor/subscription.py +123 -0
  135. package/browser/addons/vrm/editor/t_pose.py +713 -0
  136. package/browser/addons/vrm/editor/validation.py +1271 -0
  137. package/browser/addons/vrm/editor/vrm0/__init__.py +1 -0
  138. package/browser/addons/vrm/editor/vrm0/gizmo_group.py +63 -0
  139. package/browser/addons/vrm/editor/vrm0/handler.py +23 -0
  140. package/browser/addons/vrm/editor/vrm0/menu.py +145 -0
  141. package/browser/addons/vrm/editor/vrm0/migration.py +761 -0
  142. package/browser/addons/vrm/editor/vrm0/ops.py +2145 -0
  143. package/browser/addons/vrm/editor/vrm0/panel.py +1333 -0
  144. package/browser/addons/vrm/editor/vrm0/property_group.py +1818 -0
  145. package/browser/addons/vrm/editor/vrm0/ui_list.py +688 -0
  146. package/browser/addons/vrm/editor/vrm1/__init__.py +1 -0
  147. package/browser/addons/vrm/editor/vrm1/handler.py +28 -0
  148. package/browser/addons/vrm/editor/vrm1/menu.py +76 -0
  149. package/browser/addons/vrm/editor/vrm1/migration.py +321 -0
  150. package/browser/addons/vrm/editor/vrm1/ops.py +2679 -0
  151. package/browser/addons/vrm/editor/vrm1/panel.py +1243 -0
  152. package/browser/addons/vrm/editor/vrm1/property_group.py +2087 -0
  153. package/browser/addons/vrm/editor/vrm1/scene_watcher.py +90 -0
  154. package/browser/addons/vrm/editor/vrm1/ui_list.py +533 -0
  155. package/browser/addons/vrm/exporter/__init__.py +1 -0
  156. package/browser/addons/vrm/exporter/abstract_base_vrm_exporter.py +628 -0
  157. package/browser/addons/vrm/exporter/export_scene.py +930 -0
  158. package/browser/addons/vrm/exporter/gltf2_export_user_extension.py +45 -0
  159. package/browser/addons/vrm/exporter/khr_character_exporter.py +34 -0
  160. package/browser/addons/vrm/exporter/vrm0_exporter.py +4020 -0
  161. package/browser/addons/vrm/exporter/vrm1_exporter.py +3682 -0
  162. package/browser/addons/vrm/exporter/vrm_animation_exporter.py +1035 -0
  163. package/browser/addons/vrm/external/__init__.py +1 -0
  164. package/browser/addons/vrm/external/auto_rig_pro_support.py +3 -0
  165. package/browser/addons/vrm/external/io_scene_gltf2_support.py +418 -0
  166. package/browser/addons/vrm/external/rigify_support.py +1 -0
  167. package/browser/addons/vrm/importer/__init__.py +1 -0
  168. package/browser/addons/vrm/importer/abstract_base_vrm_importer.py +1548 -0
  169. package/browser/addons/vrm/importer/file_handler.py +34 -0
  170. package/browser/addons/vrm/importer/gltf2_import_user_extension.py +268 -0
  171. package/browser/addons/vrm/importer/import_scene.py +646 -0
  172. package/browser/addons/vrm/importer/license_validation.py +198 -0
  173. package/browser/addons/vrm/importer/vrm0_importer.py +1723 -0
  174. package/browser/addons/vrm/importer/vrm1_importer.py +2014 -0
  175. package/browser/addons/vrm/importer/vrm_animation_importer.py +763 -0
  176. package/browser/addons/vrm/importer/vrm_diff.py +316 -0
  177. package/browser/addons/vrm/locale/__init__.py +1 -0
  178. package/browser/addons/vrm/locale/ja_jp.py +826 -0
  179. package/browser/addons/vrm/locale/ruff.toml +8 -0
  180. package/browser/addons/vrm/locale/translation_dictionary.py +10 -0
  181. package/browser/addons/vrm/locale/zh_hans.py +928 -0
  182. package/browser/addons/vrm/registration.py +670 -0
  183. package/browser/addons/vrm.json +18 -0
  184. package/browser/blender-emscripten-engine.mts +66 -129
  185. package/browser/blender-engine.mts +20 -186
  186. package/browser/blender-wali-engine.mts +37 -81
  187. package/browser/describe-thrown.mts +3 -6
  188. package/browser/document-chunks.mts +4 -16
  189. package/browser/gltf_export.py +3161 -0
  190. package/browser/heap-growth.mts +23 -0
  191. package/browser/index.ts +3 -0
  192. package/browser/protocol.ts +130 -43
  193. package/browser/pull-job.mts +2 -10
  194. package/browser/rna.ts +190 -73
  195. package/browser/runtime.ts +271 -106
  196. package/browser/session-addons.mts +33 -0
  197. package/browser/session-frame.mts +5 -24
  198. package/browser/session.py +1389 -1446
  199. package/browser/three/attach-presenter.ts +11 -39
  200. package/browser/three/blender-base64.ts +1 -36
  201. package/browser/three/blender-corner-normals.ts +1 -23
  202. package/browser/three/blender-display-shaders.json +1 -1
  203. package/browser/three/blender-display-shaders.lut +0 -0
  204. package/browser/three/blender-display-transform.ts +2 -1
  205. package/browser/three/blender-frame-columns.ts +5 -13
  206. package/browser/three/blender-graph-material.ts +18 -3
  207. package/browser/three/blender-node-graph.ts +10 -34
  208. package/browser/three/blender-physical-material.ts +2 -31
  209. package/browser/three/blender-runtime-armature.ts +7 -60
  210. package/browser/three/blender-runtime-frame.ts +9 -23
  211. package/browser/three/blender-runtime-geometry.ts +22 -26
  212. package/browser/three/blender-runtime-lighting.ts +48 -178
  213. package/browser/three/blender-runtime-shadows.ts +187 -1
  214. package/browser/three/blender-runtime-skeleton.ts +53 -1
  215. package/browser/three/blender-runtime-view.ts +492 -306
  216. package/browser/three/blender-runtime-weights.ts +9 -72
  217. package/browser/three/blender-sky.ts +13 -33
  218. package/browser/three/blender-triangulate.ts +7 -35
  219. package/browser/three/blender-viewport-sampling.ts +235 -0
  220. package/browser/three/blender-workbench-material.ts +25 -29
  221. package/browser/three/blender-workbench-outline.ts +199 -0
  222. package/browser/three/blender-world-volume.ts +62 -10
  223. package/browser/three/presenter.ts +10 -26
  224. package/browser/three/release.ts +5 -21
  225. package/browser/three/sky-precompute-worker.ts +1 -18
  226. package/browser/three/sky-worker.ts +5 -23
  227. package/browser/three/world-field-sampler.ts +12 -26
  228. package/browser/volter_three.py +9 -105
  229. package/browser/worker.ts +195 -180
  230. package/package.json +5 -2
  231. package/wasm/BUNDLE.json +17 -17
  232. package/wasm/DEPENDENCY-LICENSES.txt +14 -0
  233. package/wasm/blender_browser.data.br +0 -0
  234. package/wasm/blender_browser.js +1 -1
  235. package/wasm/blender_browser.wasm.br +0 -0
  236. package/browser/frame-transfer.mts +0 -19
  237. package/browser/three/agx-base-srgb.lut +0 -0
  238. package/browser/three/agx-look-medium-high-contrast.lut +0 -0
  239. package/browser/three/agx-look-punchy.lut +0 -0
  240. package/browser/three/blender-agx.ts +0 -235
  241. package/browser/three/blender-display-lut.ts +0 -145
  242. package/browser/three/blender-filmic.ts +0 -49
  243. package/browser/three/blender-standard.ts +0 -68
  244. package/browser/three/blender-world-visibility.ts +0 -278
  245. package/browser/three/filmic-srgb.lut +0 -0
@@ -0,0 +1,391 @@
1
+ ---
2
+ title: "Automation samples with Python scripts"
3
+ description: "A sample of automating VRM-related processes using a Python script."
4
+ ---
5
+
6
+ A sample of automating VRM-related processes using a Python script.
7
+
8
+ ![](/assets/images/scripting_api.gif)
9
+
10
+ ## Importing VRM files
11
+
12
+ ```python
13
+ import bpy
14
+
15
+ result = bpy.ops.import_scene.vrm(filepath="path_to_your_vrm_model.vrm")
16
+ if result != {"FINISHED"}:
17
+ raise Exception(f"Failed to import vrm: {result}")
18
+ ```
19
+
20
+ ## Exporting VRM files
21
+
22
+ ```python
23
+ import bpy
24
+ from pathlib import Path
25
+
26
+ output_filepath = str(Path.home() / "path_to_your_new_vrm_model.vrm")
27
+ result = bpy.ops.export_scene.vrm(filepath=output_filepath)
28
+ if result != {"FINISHED"}:
29
+ raise Exception(f"Failed to export vrm: {result}")
30
+
31
+ print(f"{output_filepath=}")
32
+ ```
33
+
34
+ ## VRM Metadata Settings
35
+
36
+ For VRM 1.0
37
+
38
+ ```python
39
+ import bpy
40
+
41
+ context = bpy.context
42
+
43
+ bpy.ops.object.add(type="ARMATURE", location=(0, 0, 0))
44
+
45
+ armature = context.object
46
+ armature.data.vrm_addon_extension.spec_version = "1.0"
47
+
48
+ meta = armature.data.vrm_addon_extension.vrm1.meta
49
+ meta.vrm_name = "Your Model Name"
50
+ meta.version = "1.0.0"
51
+ meta.authors.add().value = "Author 1"
52
+ meta.copyright_information = "Copyright Information"
53
+ meta.contact_information = "Contact Information"
54
+ meta.references.add().value = "https://example.com"
55
+ meta.third_party_licenses = "Third Party Licenses"
56
+ thumbnail_image = context.blend_data.images.new(name="New Image", width=32, height=32)
57
+ meta.thumbnail_image = thumbnail_image
58
+ meta.avatar_permission = "onlyAuthor" # or "onlySeparatelyLicensedPerson", "everyone"
59
+ meta.allow_excessively_violent_usage = False
60
+ meta.allow_excessively_sexual_usage = False
61
+ meta.commercial_usage = "personalNonProfit" # or "personalProfit", "corporation"
62
+ meta.allow_political_or_religious_usage = False
63
+ meta.allow_antisocial_or_hate_usage = False
64
+ meta.credit_notation = "required" # or "unnecessary"
65
+ meta.allow_redistribution = False
66
+ meta.modification = (
67
+ "prohibited" # or "allowModification", "allowModificationRedistribution"
68
+ )
69
+ meta.other_license_url = ""
70
+ ```
71
+
72
+ ## VRM Human Bone Settings
73
+
74
+ For VRM 1.0
75
+
76
+ ```python
77
+ import bpy
78
+
79
+ context = bpy.context
80
+
81
+ bpy.ops.object.add(type="ARMATURE", location=(0, 0, 0))
82
+ armature = context.object
83
+ armature.data.vrm_addon_extension.spec_version = "1.0"
84
+
85
+ bpy.ops.object.mode_set(mode="EDIT")
86
+
87
+ hips_bone = armature.data.edit_bones.new("hips")
88
+ hips_bone.head = (0, 0, 0.5)
89
+ hips_bone.tail = (0, 0, 0.75)
90
+
91
+ spine_bone = armature.data.edit_bones.new("spine")
92
+ spine_bone.parent = hips_bone
93
+ spine_bone.head = (0, 0, 0.75)
94
+ spine_bone.tail = (0, 0, 1)
95
+
96
+ bpy.ops.object.mode_set(mode="OBJECT")
97
+
98
+ armature.data.vrm_addon_extension.vrm1.humanoid.human_bones.hips.node.bone_name = "hips"
99
+ armature.data.vrm_addon_extension.vrm1.humanoid.human_bones.spine.node.bone_name = (
100
+ "spine"
101
+ )
102
+ ```
103
+
104
+ ## VRM MToon Material Settings
105
+
106
+ ```python
107
+ import bpy
108
+
109
+ context = bpy.context
110
+
111
+ image = context.blend_data.images.new(name="New Image", width=32, height=32)
112
+
113
+ material = context.blend_data.materials.new("New MToon Material")
114
+ material.vrm_addon_extension.mtoon1.enabled = True
115
+
116
+ gltf = material.vrm_addon_extension.mtoon1
117
+ gltf.pbr_metallic_roughness.base_color_factor = (0, 1, 0, 1)
118
+ gltf.pbr_metallic_roughness.base_color_texture.index.source = image
119
+
120
+ # Similar settings can be made for textures other than "base_color_texture"
121
+ gltf.pbr_metallic_roughness.base_color_texture.index.sampler.mag_filter = (
122
+ "NEAREST" # or "LINEAR"
123
+ )
124
+ gltf.pbr_metallic_roughness.base_color_texture.index.sampler.min_filter = "NEAREST" # or "LINEAR", "NEAREST_MIPMAP_NEAREST", "LINEAR_MIPMAP_NEAREST", "NEAREST_MIPMAP_LINEAR", "LINEAR_MIPMAP_LINEAR"
125
+ gltf.pbr_metallic_roughness.base_color_texture.index.sampler.wrap_s = (
126
+ "REPEAT" # or "CLAMP_TO_EDGE", "MIRRORED_REPEAT"
127
+ )
128
+ gltf.pbr_metallic_roughness.base_color_texture.index.sampler.wrap_t = (
129
+ "REPEAT" # or "CLAMP_TO_EDGE", "MIRRORED_REPEAT"
130
+ )
131
+ gltf.pbr_metallic_roughness.base_color_texture.extensions.khr_texture_transform.offset = (
132
+ 0,
133
+ 0,
134
+ )
135
+ gltf.pbr_metallic_roughness.base_color_texture.extensions.khr_texture_transform.scale = (
136
+ 1,
137
+ 1,
138
+ )
139
+
140
+ gltf.alpha_mode = "OPAQUE" # or "MASK", "BLEND"
141
+ gltf.double_sided = False
142
+ gltf.alpha_cutoff = 0.5
143
+ gltf.normal_texture.index.source = image
144
+ gltf.normal_texture.scale = 1
145
+ gltf.emissive_texture.index.source = image
146
+ gltf.emissive_factor = (0, 0, 0)
147
+ gltf.extensions.khr_materials_emissive_strength.emissive_strength = 1.0
148
+
149
+ mtoon = gltf.extensions.vrmc_materials_mtoon
150
+ mtoon.transparent_with_z_write = False
151
+ mtoon.render_queue_offset_number = 0
152
+ mtoon.shade_multiply_texture.index.source = image
153
+ mtoon.shade_color_factor = (0, 0, 1)
154
+ mtoon.shading_shift_texture.index.source = image
155
+ mtoon.shading_shift_texture.scale = 1
156
+ mtoon.shading_shift_factor = 0
157
+ mtoon.shading_toony_factor = 0
158
+ mtoon.gi_equalization_factor = 0
159
+ mtoon.matcap_factor = (1, 1, 1)
160
+ mtoon.matcap_texture.index.source = image
161
+ mtoon.parametric_rim_color_factor = (0, 0, 0)
162
+ mtoon.rim_multiply_texture.index.source = image
163
+ mtoon.rim_lighting_mix_factor = 0
164
+ mtoon.parametric_rim_fresnel_power_factor = 1.0
165
+ mtoon.parametric_rim_lift_factor = 1.0
166
+ mtoon.outline_width_mode = "worldCoordinates" # or "none", "screenCoordinates"
167
+ mtoon.outline_width_factor = 0.01
168
+ mtoon.outline_width_multiply_texture.index.source = image
169
+ mtoon.outline_color_factor = (0, 0, 0)
170
+ mtoon.outline_lighting_mix_factor = 0
171
+ mtoon.uv_animation_mask_texture.index.source = image
172
+ mtoon.uv_animation_scroll_x_speed_factor = 0
173
+ mtoon.uv_animation_scroll_y_speed_factor = 0
174
+ mtoon.uv_animation_rotation_speed_factor = 0
175
+ ```
176
+
177
+ ## Dynamically generate VRM characters and export to file
178
+
179
+ ![](/assets/images/humanoid.gif)
180
+
181
+ The script automates the steps in
182
+ [Create Humanoid VRM](../create-humanoid-vrm-from-scratch/) and exports it as a
183
+ VRM.
184
+
185
+ ```python
186
+ from pathlib import Path
187
+
188
+ import bpy
189
+
190
+ # Initialize
191
+
192
+ if bpy.app.module:
193
+ bpy.ops.preferences.addon_enable(module="io_scene_vrm")
194
+
195
+ # Create an armature
196
+
197
+ armature_data = bpy.data.armatures.new("Armature")
198
+ armature_object = bpy.data.objects.new("Armature", armature_data)
199
+ bpy.context.scene.collection.objects.link(armature_object)
200
+ bpy.context.view_layer.objects.active = armature_object
201
+
202
+ bpy.ops.object.mode_set(mode="EDIT")
203
+
204
+ hips_bone = armature_data.edit_bones.new("hips")
205
+ hips_bone.head = (0, 0, 0.5)
206
+ hips_bone.tail = (0, 1, 0.5)
207
+ hips_bone_name = hips_bone.name
208
+
209
+ right_upper_leg_bone = armature_data.edit_bones.new("upper_leg.R")
210
+ right_upper_leg_bone.head = (-0.125, 0, 0.5)
211
+ right_upper_leg_bone.tail = (-0.125, 1, 0.5)
212
+ right_upper_leg_bone.parent = hips_bone
213
+ right_upper_leg_bone_name = right_upper_leg_bone.name
214
+
215
+ right_lower_leg_bone = armature_data.edit_bones.new("lower_leg.R")
216
+ right_lower_leg_bone.head = (-0.125, 0, 0.25)
217
+ right_lower_leg_bone.tail = (-0.125, 1, 0.25)
218
+ right_lower_leg_bone.parent = right_upper_leg_bone
219
+ right_lower_leg_bone_name = right_lower_leg_bone.name
220
+
221
+ right_foot_bone = armature_data.edit_bones.new("foot.R")
222
+ right_foot_bone.head = (-0.125, 0, 0)
223
+ right_foot_bone.tail = (-0.125, 1, 0)
224
+ right_foot_bone.parent = right_lower_leg_bone
225
+ right_foot_bone_name = right_foot_bone.name
226
+
227
+ left_upper_leg_bone = armature_data.edit_bones.new("upper_leg.L")
228
+ left_upper_leg_bone.head = (0.125, 0, 0.5)
229
+ left_upper_leg_bone.tail = (0.125, 1, 0.5)
230
+ left_upper_leg_bone.parent = hips_bone
231
+ left_upper_leg_bone_name = left_upper_leg_bone.name
232
+
233
+ left_lower_leg_bone = armature_data.edit_bones.new("lower_leg.L")
234
+ left_lower_leg_bone.head = (0.125, 0, 0.25)
235
+ left_lower_leg_bone.tail = (0.125, 1, 0.25)
236
+ left_lower_leg_bone.parent = left_upper_leg_bone
237
+ left_lower_leg_bone_name = left_lower_leg_bone.name
238
+
239
+ left_foot_bone = armature_data.edit_bones.new("foot.L")
240
+ left_foot_bone.head = (0.125, 0, 0)
241
+ left_foot_bone.tail = (0.125, 1, 0)
242
+ left_foot_bone.parent = left_lower_leg_bone
243
+ left_foot_bone_name = left_foot_bone.name
244
+
245
+ spine_bone = armature_data.edit_bones.new("spine")
246
+ spine_bone.head = (0, 0, 0.625)
247
+ spine_bone.tail = (0, 1, 0.625)
248
+ spine_bone.parent = hips_bone
249
+ spine_bone_name = spine_bone.name
250
+
251
+ right_upper_arm_bone = armature_data.edit_bones.new("upper_arm.R")
252
+ right_upper_arm_bone.head = (-0.125, 0, 0.75)
253
+ right_upper_arm_bone.tail = (-0.125, 1, 0.75)
254
+ right_upper_arm_bone.parent = spine_bone
255
+ right_upper_arm_bone_name = right_upper_arm_bone.name
256
+
257
+ right_lower_arm_bone = armature_data.edit_bones.new("lower_arm.R")
258
+ right_lower_arm_bone.head = (-0.25, 0, 0.75)
259
+ right_lower_arm_bone.tail = (-0.25, 1, 0.75)
260
+ right_lower_arm_bone.parent = right_upper_arm_bone
261
+ right_lower_arm_bone_name = right_lower_arm_bone.name
262
+
263
+ right_hand_bone = armature_data.edit_bones.new("hand.R")
264
+ right_hand_bone.head = (-0.375, 0, 0.75)
265
+ right_hand_bone.tail = (-0.375, 1, 0.75)
266
+ right_hand_bone.parent = right_lower_arm_bone
267
+ right_hand_bone_name = right_hand_bone.name
268
+
269
+ left_upper_arm_bone = armature_data.edit_bones.new("upper_arm.L")
270
+ left_upper_arm_bone.head = (0.125, 0, 0.75)
271
+ left_upper_arm_bone.tail = (0.125, 1, 0.75)
272
+ left_upper_arm_bone.parent = spine_bone
273
+ left_upper_arm_bone_name = left_upper_arm_bone.name
274
+
275
+ left_lower_arm_bone = armature_data.edit_bones.new("lower_arm.L")
276
+ left_lower_arm_bone.head = (0.25, 0, 0.75)
277
+ left_lower_arm_bone.tail = (0.25, 1, 0.75)
278
+ left_lower_arm_bone.parent = left_upper_arm_bone
279
+ left_lower_arm_bone_name = left_lower_arm_bone.name
280
+
281
+ left_hand_bone = armature_data.edit_bones.new("hand.L")
282
+ left_hand_bone.head = (0.375, 0, 0.75)
283
+ left_hand_bone.tail = (0.375, 1, 0.75)
284
+ left_hand_bone.parent = left_lower_arm_bone
285
+ left_hand_bone_name = left_hand_bone.name
286
+
287
+ head_bone = armature_data.edit_bones.new("head")
288
+ head_bone.head = (0, 0, 0.75)
289
+ head_bone.tail = (0, 1, 0.75)
290
+ head_bone.parent = spine_bone
291
+ head_bone_name = head_bone.name
292
+
293
+ bpy.ops.object.mode_set(mode="OBJECT")
294
+
295
+ # Assign VRM human bones
296
+
297
+ humanoid = armature_data.vrm_addon_extension.vrm1.humanoid
298
+ humanoid.human_bones.head.node.bone_name = head_bone_name
299
+ humanoid.human_bones.spine.node.bone_name = spine_bone_name
300
+ humanoid.human_bones.hips.node.bone_name = hips_bone_name
301
+ humanoid.human_bones.right_upper_arm.node.bone_name = right_upper_arm_bone_name
302
+ humanoid.human_bones.right_lower_arm.node.bone_name = right_lower_arm_bone_name
303
+ humanoid.human_bones.right_hand.node.bone_name = right_hand_bone_name
304
+ humanoid.human_bones.left_upper_arm.node.bone_name = left_upper_arm_bone_name
305
+ humanoid.human_bones.left_lower_arm.node.bone_name = left_lower_arm_bone_name
306
+ humanoid.human_bones.left_hand.node.bone_name = left_hand_bone_name
307
+ humanoid.human_bones.right_upper_leg.node.bone_name = right_upper_leg_bone_name
308
+ humanoid.human_bones.right_lower_leg.node.bone_name = right_lower_leg_bone_name
309
+ humanoid.human_bones.right_foot.node.bone_name = right_foot_bone_name
310
+ humanoid.human_bones.left_upper_leg.node.bone_name = left_upper_leg_bone_name
311
+ humanoid.human_bones.left_lower_leg.node.bone_name = left_lower_leg_bone_name
312
+ humanoid.human_bones.left_foot.node.bone_name = left_foot_bone_name
313
+
314
+ # Add meshes
315
+
316
+ bpy.ops.mesh.primitive_uv_sphere_add(radius=0.25)
317
+ head = bpy.context.active_object
318
+ head.parent = armature_object
319
+ head.parent_bone = humanoid.human_bones.head.node.bone_name
320
+ head.parent_type = "BONE"
321
+
322
+ bpy.ops.mesh.primitive_cube_add(size=0.4)
323
+ spine = bpy.context.active_object
324
+ spine.parent = armature_object
325
+ spine.parent_bone = humanoid.human_bones.spine.node.bone_name
326
+ spine.parent_type = "BONE"
327
+
328
+ bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1)
329
+ left_upper_arm = bpy.context.active_object
330
+ left_upper_arm.parent = armature_object
331
+ left_upper_arm.parent_bone = humanoid.human_bones.left_upper_arm.node.bone_name
332
+ left_upper_arm.parent_type = "BONE"
333
+
334
+ bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1)
335
+ left_hand = bpy.context.active_object
336
+ left_hand.parent = armature_object
337
+ left_hand.parent_bone = humanoid.human_bones.left_hand.node.bone_name
338
+ left_hand.parent_type = "BONE"
339
+
340
+ bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1)
341
+ right_upper_arm = bpy.context.active_object
342
+ right_upper_arm.parent = armature_object
343
+ right_upper_arm.parent_bone = humanoid.human_bones.right_upper_arm.node.bone_name
344
+ right_upper_arm.parent_type = "BONE"
345
+
346
+ bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1)
347
+ right_hand = bpy.context.active_object
348
+ right_hand.parent = armature_object
349
+ right_hand.parent_bone = humanoid.human_bones.right_hand.node.bone_name
350
+ right_hand.parent_type = "BONE"
351
+
352
+ bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1)
353
+ left_upper_leg = bpy.context.active_object
354
+ left_upper_leg.parent = armature_object
355
+ left_upper_leg.parent_bone = humanoid.human_bones.left_upper_leg.node.bone_name
356
+ left_upper_leg.parent_type = "BONE"
357
+
358
+ bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1)
359
+ right_upper_leg = bpy.context.active_object
360
+ right_upper_leg.parent = armature_object
361
+ right_upper_leg.parent_bone = humanoid.human_bones.right_upper_leg.node.bone_name
362
+ right_upper_leg.parent_type = "BONE"
363
+
364
+ bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1)
365
+ left_lower_leg = bpy.context.active_object
366
+ left_lower_leg.parent = armature_object
367
+ left_lower_leg.parent_bone = humanoid.human_bones.left_lower_leg.node.bone_name
368
+ left_lower_leg.parent_type = "BONE"
369
+
370
+ bpy.ops.mesh.primitive_ico_sphere_add(radius=0.1)
371
+ right_lower_leg = bpy.context.active_object
372
+ right_lower_leg.parent = armature_object
373
+ right_lower_leg.parent_bone = humanoid.human_bones.right_lower_leg.node.bone_name
374
+ right_lower_leg.parent_type = "BONE"
375
+
376
+ # Set metadata
377
+
378
+ meta = armature_data.vrm_addon_extension.vrm1.meta
379
+ meta.vrm_name = "Your Model Name"
380
+ meta.version = "1.0.0"
381
+
382
+ # Save to a file
383
+
384
+ output_filepath = str(Path(__file__).parent / "path_to_your_vrm_model.vrm")
385
+ result = bpy.ops.export_scene.vrm(filepath=output_filepath)
386
+ if result != {"FINISHED"}:
387
+ message = f"Failed to export vrm: {result}"
388
+ raise RuntimeError(message)
389
+
390
+ print(f'Saved the VRM file to "{output_filepath}"')
391
+ ```
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: "Export VRM (.vrm)"
3
+ description: "Export VRM (.vrm) files from Blender and review the available export options."
4
+ ---
5
+
6
+ Select `File` → `Export` → `VRM (.vrm)` from the menu to display the VRM export
7
+ dialog. Press the `Save` button to export the currently edited armature as a VRM
8
+ file.
9
+
10
+ ![](1.png)
11
+
12
+ ## Options
13
+
14
+ ### ✅ Export Invisible Objects
15
+
16
+ Include invisible objects during export. As an exception, the target armature
17
+ for export will be exported even if it is invisible.
18
+
19
+ ### ✅ Export Only Selections
20
+
21
+ Export only the selected objects.
22
+
23
+ ### ✅ Enable Advanced Options
24
+
25
+ Enable the [Advanced Options] items. Please note that changing these items may
26
+ result in a loss of compatibility of the VRM file between applications.
27
+
28
+ ### ✅ [Advanced Options] [VRM 1.0 only] Use Sparse Accessors
29
+
30
+ Use sparse accessors when exporting shape keys. This may reduce file size for
31
+ models using shape keys, but VRM files will become unreadable in older
32
+ applications using
33
+ [UniVRM 0.115.0 or earlier](https://github.com/saturday06/VRM-Addon-for-Blender/issues/381#issuecomment-1838365762).
34
+
35
+ ### ✅ [Advanced Options] [VRM 1.0 only] Export All Bone Influences
36
+
37
+ Export all bone weights. By default, the number of exported weights is limited
38
+ to 4 for display compatibility. According to the VRM specification, up to 255
39
+ bone weights can be assigned to a single vertex. However, most applications that
40
+ handle VRM only interpret up to 4 weights per vertex. This removes that
41
+ limitation and exports all bone weights. Please use this feature with caution,
42
+ setting weights carefully, or only when the export results will be used in
43
+ specific applications, as meshes may become significantly distorted in some
44
+ applications.
45
+
46
+ ### ✅ [Advanced Options] [VRM 1.0 only] Export Lights
47
+
48
+ Include light objects in the export. There is currently no consensus on how
49
+ lights should be handled in VRM, so the results are unpredictable. Please use
50
+ this feature only when using applications that can handle lights.
51
+
52
+ ### ✅ [Advanced Options] [VRM 1.0 only] Export glTF Animations
53
+
54
+ Export glTF animations. By default, glTF animations are not exported. Since VRM
55
+ files are designed with the assumption that motion retargeting will be applied,
56
+ glTF animations often cannot be directly applied as-is. Please consider using
57
+ [VRM Animation](https://vrm-addon-for-blender.info/en-us/animation/) instead.
@@ -0,0 +1,17 @@
1
+ ---
2
+ title: "Export VRM Animation (.vrma)"
3
+ description: "Export VRM Animation (.vrma) from Blender and see what data is included."
4
+ ---
5
+
6
+ By selecting `File` → `Export` → `VRM Animation (.vrma)` from the menu, the
7
+ [VRM Animation](../../animation/) export dialog will be displayed.
8
+
9
+ ![](1.png)
10
+
11
+ When you press the `Save` button, animations assigned to VRM 1.0 placed in the
12
+ scene that meet the following conditions will be exported as a VRMA file:
13
+
14
+ - Rotation values of bones assigned to VRM Humanoid bones
15
+ - Translation values of bones assigned to the Hips bone among VRM Humanoid bones
16
+ - Preview values of VRM Expressions
17
+ - Translation values of objects specified in the Preview Target of VRM Look At
@@ -0,0 +1,61 @@
1
+ ---
2
+ title: "Import VRM (.vrm)"
3
+ description: "Import VRM (.vrm) files into Blender and configure the import options."
4
+ ---
5
+
6
+ Select `File` → `Import` → `VRM (.vrm)` from the menu to display the VRM import
7
+ dialog. Select a VRM file and click the `Open` button to load the VRM file into
8
+ the scene.
9
+
10
+ ![](1.png)
11
+
12
+ ## Options
13
+
14
+ ### ✅ Extract texture images into the folder
15
+
16
+ Creates a folder in the same location as the VRM file and extracts the textures
17
+ contained within the VRM file. If unchecked, textures will be embedded in the
18
+ currently edited `.blend` file.
19
+
20
+ ### ✅ Don't overwrite existing texture image folder
21
+
22
+ When creating a folder for texture images, if a folder already exists, a
23
+ sequential number will be appended to prevent overwriting the folder.
24
+
25
+ ### ✅ Set shading type to "Material"
26
+
27
+ After loading the VRM file, sets the 3D viewport shading to Material Preview.
28
+ While this setting may not be particularly meaningful for users familiar with
29
+ Blender, it's intended to help newcomers get excited by seeing a display that
30
+ closely matches how it appears on other platforms immediately after import.
31
+
32
+ ### ✅ Set view transform to "Standard"
33
+
34
+ After loading the VRM file, sets the color management view transform to
35
+ "Standard". VRM files are not compatible with Blender's default view transform
36
+ settings and often appear slightly dull. Setting the view transform to
37
+ "Standard" solves this issue.
38
+
39
+ ### ✅ Set an imported armature display to "Wire"
40
+
41
+ After loading the VRM file, sets the armature viewport display to "Wire".
42
+
43
+ ### ✅ Set an imported armature display to show "In-Front"
44
+
45
+ After loading the VRM file, displays the armature in front of other objects.
46
+
47
+ ### ✅ Set an imported bone shape to default
48
+
49
+ The official importer for the glTF format, which is the parent specification of
50
+ VRM, sometimes automatically changes the bone shape display to ICO spheres or
51
+ similar. However, as the addon author, I find this behavior unnatural for VRM
52
+ files that primarily contain humanoid armatures. This option suppresses that
53
+ behavior and sets bones to the default octahedral shape.
54
+
55
+ ### ✅ Enable MToon Outline Preview
56
+
57
+ "MToon", the toon shader included in VRM, includes an anime-style outline
58
+ rendering feature. Since this is implemented using the inverted hull method,
59
+ enabling it may increase the vertex count displayed in the statistics overlay
60
+ and increase viewport performance load. Disabling this option resolves these
61
+ issues.
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: "Import VRM Animation (.vrma)"
3
+ description: "Import VRM Animation (.vrma) into a VRM 1.0 model in Blender."
4
+ ---
5
+
6
+ By selecting `File` → `Import` → `VRM Animation (.vrma)` from the menu, the
7
+ [VRM Animation](../../animation/) import dialog will be displayed.
8
+
9
+ ![](1.png)
10
+
11
+ When you select a VRMA file and press the `Open` button, the animation will be
12
+ applied to the VRM 1.0 model in the current scene. If there is no VRM 1.0 model
13
+ in the current scene, a minimal model will be automatically generated.
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: "VRMアニメーション"
3
+ description: "VRM Animationのインポートとエクスポート手順を解説します。"
4
+ ---
5
+
6
+ VRM Animationのインポートとエクスポートの解説です。
7
+
8
+ ![](/assets/images/animation.gif)
9
+
10
+ ## VRM Animationファイルのエクスポート
11
+
12
+ VRM Animationのエクスポートには、VRM
13
+ 1.0のアーマチュアが必要です。エクスポートされるアニメーションは次の通りです
14
+
15
+ - Humanoidボーンの回転値
16
+ - Humanoid Hipsボーンの移動値
17
+ - Expressionのプレビュー値 (Look At値のエクスポートは現在未対応)
18
+
19
+ 最低限のアニメーションをエクスポートしてみます。
20
+
21
+ ![](1.png)
22
+
23
+ ![](2.png)
24
+
25
+ ![](3.png)
26
+
27
+ ![](4.png)
28
+
29
+ ![](5.png)
30
+
31
+ ![](6.png)
32
+
33
+ ![](7.png)
34
+
35
+ ![](8.png)
36
+
37
+ ![](9.png)
38
+
39
+ ![](10.png)
40
+
41
+ ![](11.png)
42
+
43
+ ![](12.png)
44
+
45
+ ![](13.png)
46
+
47
+ ![](14.png)
48
+
49
+ ![](15.png)
50
+
51
+ ## VRM Animationファイルのインポート
52
+
53
+ ![](16.png)
54
+
55
+ ![](17.png)
56
+
57
+ ![](18.png)