-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
99 lines (66 loc) · 2.21 KB
/
index.html
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
<script src="https://threejs.org/build/three.js"></script>
<script src="https://threejs.org/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<body>
</body>
<script type="text/javascript">
let camera, scene, renderer, clock, rightArm, leftLeg, test;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.01, 10 );
camera.position.set( 2, 2, - 2 );
clock = new THREE.Clock();
scene = new THREE.Scene();
scene.background = new THREE.Color( 0xffffff );
const light = new THREE.HemisphereLight( 0xbbbbff, 0x444422 );
light.position.set( 0, 1, 0 );
scene.add( light );
// model
const loader = new THREE.GLTFLoader();
loader.load( 'https://threejs.org/examples/models/gltf/Soldier.glb', function ( gltf ) {
const model = gltf.scene;
rightArm = model.getObjectByName( 'mixamorigRightArm' );
leftLeg = model.getObjectByName('mixamorigLeftLeg');
scene.add( model );
console.log( model );
} );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.gammaOutput = true;
renderer.gammaFactor = 2.2;
document.body.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
const controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.target.set( 0, 1, 0 );
controls.update();
test = 0;
setTimeout(moveLeg, 1000)
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
function animate() {
requestAnimationFrame( animate );
const t = clock.getElapsedTime();
if ( rightArm ) {
// rightArm.rotation.z += Math.sin( t ) * 0.005;
rightArm.rotation.z = 1347 / 900 ;
}
if (leftLeg) {
//leftLeg.rotation.x = 1517 /900;
}
renderer.render( scene, camera );
}
function moveLeg(){
console.log("move leg")
leftLeg.rotation.x = test / 900;
test += 100;
setTimeout(moveLeg, 1000)
}
</script>
mixamorigLeftLeg
children 0 children 1 skeleton bones