File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ export default {
6767 sakura .position .y = 2 ;
6868 scene .add (sakura);
6969 animate ();
70- console .log (sakura);
70+ // console.log(sakura);
7171 },
7272 function (xhr ) {
7373 if (xhr .loaded < xhr .total ) {
@@ -84,10 +84,11 @@ export default {
8484 var axesHelper = new THREE.AxesHelper (100 );
8585 scene .add (axesHelper);
8686
87+ let model, mixer
8788 loader .load (
8889 " /models/calibur/scene.gltf" ,
8990 (gltf ) => {
90- let model = gltf .scene ;
91+ model = gltf .scene ;
9192 model .traverse ((o ) => {
9293 // 将图片作为纹理加载
9394 let explosionTexture = new THREE.TextureLoader ().load (
@@ -104,13 +105,22 @@ export default {
104105 });
105106 scene .add (model);
106107 model .position .set (2 , - 2 , - 1 );
107- console .log (model);
108+ // console.log(gltf);
109+
110+
111+ // add animations
112+ mixer = new THREE.AnimationMixer (model);
113+ let clip = THREE .AnimationClip .findByName (gltf .animations , " Walk" )
114+ const action = mixer .clipAction (clip);
115+ action .play ();
108116 },
109117 undefined ,
110118 function (error ) {
111119 console .error (error);
112120 }
113121 );
122+ const clock = new THREE.Clock ();
123+
114124 // render LOOP
115125 function animate () {
116126 // internal func: callback in a regular basis
@@ -119,6 +129,7 @@ export default {
119129 // rotate
120130 oct .rotation .y += 0.01 ;
121131 sakura .rotation .y += 0.01 ;
132+ if (clock) mixer .update (clock .getDelta ())
122133 // model.rotation.y += 0.01;
123134
124135 renderer .render (scene, camera);
Original file line number Diff line number Diff line change 1919 :size =" 3"
2020 :rotation =" { y: Math.PI / 4, z: Math.PI / 4 }"
2121 >
22- <!-- < MatcapMaterial name="2E763A_78A0B7_B3D1CF_14F209" /> -- >
23- <PhongMaterial >
22+ <MatcapMaterial name =" 2E763A_78A0B7_B3D1CF_14F209" />
23+ <!-- < PhongMaterial>
2424 <Texture src="/img/copy.jpg" />
25- </PhongMaterial >
25+ </PhongMaterial> -->
2626 </Box >
2727 </Scene >
2828 </Renderer >
You can’t perform that action at this time.
0 commit comments