@j-kyoda/vue-three-vrm 0.10.0 → 0.10.1

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 (3) hide show
  1. package/README.md +15 -0
  2. package/README.md.orig +158 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -34,6 +34,9 @@ const vrm_url = 'models/chico_hoodie.vrm'
34
34
  // toDo: Please enter your VRMA file URL here.(OPTION)
35
35
  const vrma_url = 'models/sample.vrma'
36
36
 
37
+ let _vrm_model = null
38
+
39
+
37
40
  const context_initialized = async (context) => {
38
41
  render_context.value = context // save context
39
42
  context_ready.value = true // Begin model loading.
@@ -42,6 +45,9 @@ const context_initialized = async (context) => {
42
45
  const model_loaded = (name, vrm_model) => {
43
46
  const context = render_context.value
44
47
 
48
+ // save
49
+ _vrm_model = vrm_model
50
+
45
51
  // add model to scene
46
52
  const model = vrm_model.scene
47
53
  model.name = name
@@ -50,6 +56,14 @@ const model_loaded = (name, vrm_model) => {
50
56
 
51
57
  animation.value = true // Starting animation.
52
58
  }
59
+
60
+ const cb_animate = (context) => {
61
+ const { deltaTime } = context
62
+ if (_vrm_model != null) {
63
+ // animate
64
+ _vrm_model.updateAnimation(deltaTime)
65
+ }
66
+ }
53
67
  </script>
54
68
 
55
69
  <template>
@@ -61,6 +75,7 @@ const model_loaded = (name, vrm_model) => {
61
75
  :useAxesHelper="false"
62
76
  :useDefaultLight="true"
63
77
  v-on:initialized="context_initialized"
78
+ v-on:animate="cb_animate"
64
79
  />
65
80
  </div>
66
81
  <div v-if="context_ready">
package/README.md.orig ADDED
@@ -0,0 +1,158 @@
1
+ # @j-kyoda/vue-three-vrm
2
+
3
+ A Vue 3 component designed to render and display VRM models on your web pages.
4
+
5
+ ## Installation
6
+
7
+ Package is available on NPM: https://www.npmjs.com/package/@j-kyoda/vue-three-vrm
8
+
9
+ ```sh
10
+ npm install @j-kyoda/vue-three-vrm three @pixiv/three-vrm @pixiv/three-vrm-animation
11
+ ```
12
+
13
+ ---
14
+
15
+ ## Usage
16
+
17
+ ```vue
18
+ <script setup>
19
+ import { ref } from 'vue'
20
+
21
+ import { VroidControl, ThreeFrame } from '@j-kyoda/vue-three-vrm'
22
+
23
+
24
+ const context_ready = ref(false)
25
+ const render_context = ref(null)
26
+ const animation = ref(false)
27
+
28
+ // toDo: Please enter your model name here.
29
+ const model_name = 'chico_hoodie'
30
+ // toDo: Please enter your pose URL here.
31
+ const pose_url = 'poses/chico_pose_goodjob_202506.json'
32
+ // toDo: Please enter your VRM model URL here.
33
+ const vrm_url = 'models/chico_hoodie.vrm'
34
+ // toDo: Please enter your VRMA file URL here.(OPTION)
35
+ const vrma_url = 'models/sample.vrma'
36
+
37
+ const context_initialized = async (context) => {
38
+ render_context.value = context // save context
39
+ context_ready.value = true // Begin model loading.
40
+ }
41
+
42
+ const model_loaded = (name, vrm_model) => {
43
+ const context = render_context.value
44
+
45
+ // add model to scene
46
+ const model = vrm_model.scene
47
+ model.name = name
48
+ vrm_model.setPosition({ x: 0, y: 0, z: 0 })
49
+ context.scene.add(model)
50
+
51
+ animation.value = true // Starting animation.
52
+ }
53
+ </script>
54
+
55
+ <template>
56
+ <div class="frame">
57
+ <ThreeFrame
58
+ :animation="animation"
59
+ :useOrbitControls="true"
60
+ :useGridHelper="true"
61
+ :useAxesHelper="false"
62
+ :useDefaultLight="true"
63
+ v-on:initialized="context_initialized"
64
+ />
65
+ </div>
66
+ <div v-if="context_ready">
67
+ <VroidControl
68
+ :model_name="model_name"
69
+ :pose_url="pose_url"
70
+ :vrm_url="vrm_url"
71
+ :vrma_url="vrma_url"
72
+ v-on:loaded="model_loaded"
73
+ />
74
+ </div>
75
+ </template>
76
+
77
+ <style scoped>
78
+ .frame {
79
+ display: block;
80
+ width: 400px;
81
+ height: 400px;
82
+ margin: 0 auto;
83
+ padding: 0;
84
+ }
85
+ </style>
86
+ ```
87
+
88
+ ---
89
+
90
+ ## ThreeFrame
91
+
92
+ ### Props
93
+
94
+ | ID | Type | Default | Description |
95
+ | :--------------- | :------- | :------ | :------------------------------------- |
96
+ | animation | Boolean | false | Controls animation loop execution. |
97
+ | clearAlpha | Number | 1.0 | Clear Alpha value. Ranges from 0 to 1. |
98
+ | clearColor | String | #7fbfff | Clear color value. |
99
+ | useOrbitControls | Boolean | false | Enables/disables `OrbitControls`. |
100
+ | useGridHelper | Boolean | false | Shows/hides the grid. |
101
+ | useAxesHelper | Boolean | false | Shows/hides the 3D axis arrows. |
102
+ | useDefaultLight | Boolean | false | Sets up default lighting. |
103
+
104
+ ### Events (Emits)
105
+
106
+ | Event | Description | Payload |
107
+ | :----------- | :----------------------------------------------------- | :------------- |
108
+ | initialized | Occurs when the renderer setup is complete. | ContextObject |
109
+ | animate | Occurs before the rendering process in animation loop. | ContextObject |
110
+
111
+ ## ContextObject
112
+
113
+ ```
114
+ {
115
+ GLTFLoader,
116
+ THREE,
117
+ VRMExpressionPresetName,
118
+ VRMHumanBoneName,
119
+ VRMUtils,
120
+ camera, // Instance of THREE.PerspectiveCamera
121
+ controls, // Instance of OrbitControls
122
+ deltaTime, //
123
+ renderer, // Instance of THREE.WebGLRenderer
124
+ scene // Instance of THREE.Scene
125
+ }
126
+ ```
127
+
128
+ ## VroidControl
129
+
130
+ ### Props
131
+
132
+ | ID | Type | default | Description |
133
+ | :-------------- | :----- | :----------- | :------------------------------------------------------ |
134
+ | model_name | String | '' | The name of the VRoid model to display. **Required**. |
135
+ | expression_name | String | 'expression' | The name of the expression model. |
136
+ | expression_url | String | '' | The URL of the expression model. |
137
+ | expression_data | Object | null | The object for the expression model. |
138
+ | pose_name | String | 'pose' | The name of the pose model. |
139
+ | pose_url | String | '' | The URL of the pose model. |
140
+ | pose_data | Object | null | The object for the pose model. |
141
+ | vrm_name | String | 'vrm' | The name of the VRM model. |
142
+ | vrm_url | String | '' | The URL of the VRM model. |
143
+ | vrm_data | Object | null | The object for the VRM model. |
144
+ | vrma_name | String | '' | The name of the VRMA model. |
145
+ | vrma_url | String | null | The URL of the VRMA model. |
146
+ | vrma_data | Object | null | The object for the VRMA model. |
147
+
148
+ ### Events (Emits)
149
+
150
+ | Event | Description | Payload |
151
+ | :--------- | :------------------------------------------------ | :----------------------------------- |
152
+ | loading | Occurs while the VRoid model is loading. | VRoid model name |
153
+ | loaded | Occurs when the VRoid model has finished loading. | VRoid model name, VRMModel instance |
154
+
155
+
156
+ ## License
157
+
158
+ This project is licensed under the MIT License. For more details, please refer to the LICENSE file located at the root of the project.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j-kyoda/vue-three-vrm",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "A Vue 3 component designed to render and display VRM models on your web pages.",
5
5
  "type": "module",
6
6
  "private": false,