-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvrm.html
More file actions
160 lines (123 loc) · 4.27 KB
/
vrm.html
File metadata and controls
160 lines (123 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html>
<head>
<title>A-Frame Examples</title>
<meta name="description" content="Testing VRM Avatars">
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">
<script src="js/aframe-v1.7.1.js"></script>
<script src="js/aframe-environment-component.js"></script>
<script src="js/controller-listener.js"></script>
<script src="js/player-move.js"></script>
<script src="js/raycaster-extras.js"></script>
<!-- Official three-vrm libraries (compatible with A-Frame's Three.js r137) -->
<script src="js/three-vrm.js"></script>
<script src="js/three-vrm-animation.js"></script>
<!-- Custom A-Frame VRM component bundle using official libraries -->
<script src="js/aframe-vrm-bundle.js"></script>
</head>
<body>
<style>
#debug-console {
position: fixed;
top: 10px;
left: 10px;
width: 400px;
max-height: 300px;
overflow-y: auto;
background: rgba(0,0,0,0.8);
color: #0f0;
font-family: monospace;
font-size: 10px;
padding: 10px;
z-index: 1000;
border: 1px solid #0f0;
}
</style>
<div id="debug-console"></div>
<script>
// Intercept console.log
const debugDiv = document.getElementById('debug-console');
const originalLog = console.log;
console.log = function(...args) {
originalLog.apply(console, args);
const msg = args.map(a => typeof a === 'object' ? JSON.stringify(a) : a).join(' ');
debugDiv.innerHTML += msg + '<br>';
debugDiv.scrollTop = debugDiv.scrollHeight;
};
// if raycaster is pointing at this object, press trigger to change color
AFRAME.registerComponent("vrm-test", {
init: function ()
{
// replace GLTF MeshBasicMaterial with Material that supports shading
this.el.addEventListener("model-loaded", function(eventData) {
console.log("model-loaded!");
let model = eventData.detail.model;
model.traverse((obj) => {
if (obj.isMesh)
{
let newMaterial = new THREE.MeshLambertMaterial(
{alphaTest: 0.5, alphaWrite: false, emissive: "#111111"});
newMaterial.map = obj.material.map;
obj.material = newMaterial;
}
});
});
// Material replacement complete
// look-at object (check: string used by querySelector?)
// Use A-Frame's setAttribute with property name to update just the lookAt property
this.el.setAttribute("vrm", "lookAt", document.querySelector("a-camera"));
this.clock = new THREE.Clock();
},
tick: function()
{
}
});
</script>
<a-scene>
<a-assets>
<img id="gradient" src="images/gradient-fade.png" />
</a-assets>
<a-sky
color = "#000337">
</a-sky>
<a-entity vrm="src: models/Asian/Asian_F_1_Busi.vrm;"
vrm-anim="src: cmu_mocap_bvh/cmu_bvh_01-09/01/01_01.vrma"
position="0 0 -1"
rotation="0 180 0"
vrm-test
shadow="cast: true; receive: false;"
>
</a-entity>
<a-entity vrm="src: https://raw.githack.com/vrm-c/UniVRM/master/Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm;"
vrm-anim="src: VRMA/Clapping.vrma"
position="1 0 -1"
rotation="0 180 0"
shadow="cast: true; receive: false;"
>
</a-entity>
<a-entity
id="player"
position="0 0 1"
player-move="controllerListenerId: #controller-data;
navigationMeshClass: environmentGround;">
<a-camera></a-camera>
<a-entity
id="controller-data"
controller-listener="leftControllerId: #left-controller;
rightControllerId: #right-controller;">
</a-entity>
<a-entity
id="left-controller"
oculus-touch-controls="hand: left">
</a-entity>
<a-entity
id="right-controller"
oculus-touch-controls="hand: right"
raycaster="objects: .raycaster-target, .environmentGround;"
raycaster-extras="controllerListenerId: #controller-data;
beamImageSrc: #gradient; beamLength: 0.5;">
</a-entity>
</a-entity>
</a-scene>
</body>
</html>