个人原创文档,转载请注明出处!模型导入:https://doc.babylonjs.com/api...代码片段:BABYLON.SceneLoader.ImportMesh('','gltf/','Waterpump_3.glb',scene,function(newMeshes,particleSystems,skeletons){scene.createDefaultCameraOrLight(true,true,true);//console.log(newMeshes);mesh=newMeshes[0];mesh.setPivotMatrix(BABYLON.Matrix.Translation(0.5,0.5,0.5),false);animGroups=scene.animationGroups;scene.activeCamera.setPosition(newBABYLON.Vector3(-1,1,1));})1.动画分为三种:骨骼动画,模型动画,制作动画a。骨骼动画:https://www.babylonjs-playgro...https://blog.csdn.net/qq_3010...取值取自通过模型b引入的成功回调参数。模型动画是将模型放到场景中,模型导入成功的回调方法写在animGroups=scene.animationGroups;//播放和停止动画anime.start();//从头开始??播放anime.stop();//停止anime.restart();//Reset//暂停并继续播放组合动画.pause();//暂停anime.play();//播放模型中的动画多为动画组,多个动画组合起来达到效果。scene.animationGroups[89].start(false,1,0,10)或者同一个动画同时应用多个模型元素,那么就可以varani3=scene.beginAnimation('shang_1090xiaoshi',0,10,false,1、function(){console.log(1)},scene.animationGroups[89]);ani3.start(false,1,0,10)动画组方法c。动画制作官网链接//创建动画对象varanimationBox=newBABYLON.动画("myAnimation","scaling.x",30,BABYLON.Animation.ANIMATIONTYPE\_FLOAT,BABYLON.Animation.ANIMATIONLOOPMODE\_CYCLE);参数名称含义参数1动画的名称参数2可以是任意网格属性,取决于你想改变什么参数3每秒请求的帧数参数4修改值的类型:float(比如平移),矢量(例如方向)或四元数参数5动画在其上限时将采取的行为类型varanimation=newBABYLON.Animation("camTar","target",30,BABYLON.Animation.ANIMATIONTYPE_VECTOR3,BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);//包含所有动画键的数组varkeys=[];keys.push({frame:0,value:1});keys.push({frame:20,value:0.2});animation.setKeys(keys2);camera.animations.push(animation);scene.beginAnimation(scene.activeCamera,0,time,false,1,function(){打回来();});参考例1参考例2scene.beginAnimation的参数:nametypedescriptiontargetanytargetfromnumberfpsstartframetonumberfpsendframeloopboolean如果为true,动画会循环(取决于BABYLON.Animation.ANIMATIONLOOPMODEspeedRationumberdefault:1speedratioforthisanimationonAnimationEnd()=>void即使动画已经被手动停止,这个函数也在动画结束时触发(也取决于ANIMATIONLOOPMODE)animatableAnimatable可选的特定动画stopCurrent布尔值如果有的话,我们应该停止现有的动画吗?默认是这个函数返回一个BABYLON.Animatable对象,您可以使用它来访问单个动画(对于例如,使用getAnimationByTargetProperty函数。BABYLON.Animatable对象还支持以下函数:pause()restart()stop()reset()varnewAnimation=scene.beginAnimation(box1,0,100,true);newAnimation.pause();Easingfunctions您可以使用easing函数为动画添加一些行为。如果您想了解更多关于easing函数的信息,请参阅以下有用链接MSDNEasingfunctionsdocumentationEasyfunctioncheatsheet可以使用的预定义缓动函数:BABYLON.CircleEase()BABYLON.BackEase(振幅)BABYLON.BounceEase(弹跳,弹性)BABYLON.CubicEase()BABYLON.ElasticEase(振动,弹性)BABYLON.ExponentialEase(指数)BABYLON.PowerEase(功率)BABYLON.QuadraticEase()BABYLON.QuarticEase()BABYLON.QuinticEase()BABYLON.SineEase()BABYLON.BezierCurveEase()
