@j-kyoda/vue-three-vrm 0.6.4 → 0.8.0
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.
- package/README.md +127 -17
- package/dist/index.css +1 -1
- package/dist/vue-three-vrm.es.js +693 -701
- package/dist/vue-three-vrm.umd.js +2 -2
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -7,33 +7,143 @@ A Vue 3 component designed to render and display VRM models on your web pages.
|
|
|
7
7
|
Package is available on NPM: https://www.npmjs.com/package/@j-kyoda/vue-three-vrm
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm
|
|
10
|
+
npm install @j-kyoda/vue-three-vrm three @pixiv/three-vrm
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
---
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## Usage
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
```vue
|
|
18
|
+
<script setup>
|
|
19
|
+
import { ref } from 'vue'
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
npm install
|
|
21
|
-
```
|
|
21
|
+
import { VroidControl, ThreeFrame } from '@j-kyoda/vue-three-vrm'
|
|
22
22
|
|
|
23
|
-
### Compile and Hot-Reload for Development
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const context_ready = ref(false)
|
|
25
|
+
const render_context = ref(null)
|
|
26
|
+
const animation = ref(false)
|
|
28
27
|
|
|
29
|
-
|
|
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'
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
|
|
36
|
+
const context_initialized = async (context) => {
|
|
37
|
+
render_context.value = context // save context
|
|
38
|
+
context_ready.value = true // Begin model loading.
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const model_loaded = (name, vrm_model) => {
|
|
42
|
+
const context = render_context.value
|
|
43
|
+
|
|
44
|
+
// add model to scene
|
|
45
|
+
const model = vrm_model.scene
|
|
46
|
+
model.name = name
|
|
47
|
+
vrm_model.setPosition({ x: 0, y: 0, z: 0 })
|
|
48
|
+
context.scene.add(model)
|
|
49
|
+
|
|
50
|
+
animation.value = true // Starting animation.
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<div class="frame">
|
|
56
|
+
<ThreeFrame
|
|
57
|
+
:animation="animation"
|
|
58
|
+
:useOrbitControls="true"
|
|
59
|
+
:useGridHelper="true"
|
|
60
|
+
:useAxesHelper="false"
|
|
61
|
+
:useDefaultLight="true"
|
|
62
|
+
v-on:initialized="context_initialized"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
<div v-if="context_ready">
|
|
66
|
+
<VroidControl
|
|
67
|
+
:model_name="model_name"
|
|
68
|
+
:pose_url="pose_url"
|
|
69
|
+
:vrm_url="vrm_url"
|
|
70
|
+
v-on:loaded="model_loaded"
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
</template>
|
|
74
|
+
|
|
75
|
+
<style scoped>
|
|
76
|
+
.frame {
|
|
77
|
+
display: block;
|
|
78
|
+
width: 400px;
|
|
79
|
+
height: 400px;
|
|
80
|
+
margin: 0 auto;
|
|
81
|
+
padding: 0;
|
|
82
|
+
}
|
|
83
|
+
</style>
|
|
33
84
|
```
|
|
34
85
|
|
|
35
|
-
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## ThreeFrame
|
|
89
|
+
|
|
90
|
+
### Props
|
|
91
|
+
|
|
92
|
+
| ID | Type | Default | Description |
|
|
93
|
+
| :--------------- | :------- | :------ | :---------------------------------- |
|
|
94
|
+
| animation | Boolean | false | Controls animation loop execution. |
|
|
95
|
+
| useOrbitControls | Boolean | false | Enables/disables `OrbitControls`. |
|
|
96
|
+
| useGridHelper | Boolean | false | Shows/hides the grid. |
|
|
97
|
+
| useAxesHelper | Boolean | false | Shows/hides the 3D axis arrows. |
|
|
98
|
+
| useDefaultLight | Boolean | false | Sets up default lighting. |
|
|
99
|
+
|
|
100
|
+
### Events (Emits)
|
|
101
|
+
|
|
102
|
+
| Event | Description | Payload |
|
|
103
|
+
| :----------- | :----------------------------------------------------- | :------------- |
|
|
104
|
+
| initialized | Occurs when the renderer setup is complete. | ContextObject |
|
|
105
|
+
| animate | Occurs before the rendering process in animation loop. | ContextObject |
|
|
106
|
+
|
|
107
|
+
## ContextObject
|
|
36
108
|
|
|
37
|
-
```sh
|
|
38
|
-
npm run lint
|
|
39
109
|
```
|
|
110
|
+
{
|
|
111
|
+
GLTFLoader,
|
|
112
|
+
THREE,
|
|
113
|
+
VRMExpressionPresetName,
|
|
114
|
+
VRMHumanBoneName,
|
|
115
|
+
camera, // Instance of THREE.PerspectiveCamera
|
|
116
|
+
controls, // Instance of OrbitControls
|
|
117
|
+
renderer, // Instance of THREE.WebGLRenderer
|
|
118
|
+
scene // Instance of THREE.Scene
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## VroidControl
|
|
123
|
+
|
|
124
|
+
### Props
|
|
125
|
+
|
|
126
|
+
| ID | Type | default | Description |
|
|
127
|
+
| :-------------- | :----- | :----------- | :------------------------------------------------------ |
|
|
128
|
+
| model_name | String | '' | The name of the VRoid model to display. ** Required **. |
|
|
129
|
+
| expression_name | String | 'expression' | The name of the expression model. |
|
|
130
|
+
| expression_url | String | '' | The URL of the expression model. |
|
|
131
|
+
| expression_data | Object | null | The object for the expression model. |
|
|
132
|
+
| pose_name | String | 'pose' | The name of the pose model. |
|
|
133
|
+
| pose_url | String | '' | The URL of the pose model. |
|
|
134
|
+
| pose_data | Object | null | The object for the pose model. |
|
|
135
|
+
| vrm_name | String | 'vrm' | The name of the VRM model. |
|
|
136
|
+
| vrm_url | String | '' | The URL of the VRM model. |
|
|
137
|
+
| vrm_data | Object | null | The object for the VRM model. |
|
|
138
|
+
|
|
139
|
+
### Events (Emits)
|
|
140
|
+
|
|
141
|
+
| Event | Description | Payload |
|
|
142
|
+
| :--------- | :------------------------------------------------ | :----------------------------------- |
|
|
143
|
+
| loading | Occurs while the VRoid model is loading. | VRoid model name |
|
|
144
|
+
| loaded | Occurs when the VRoid model has finished loading. | VRoid model name, VRMModel instance |
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
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/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.box[data-v-
|
|
1
|
+
.box[data-v-8fb60132]{display:block;width:100%;height:100%}
|