BABYLON JS在y轴上对导入的网格旋转进行动画处理

时间:2018-08-04 17:20:20

标签: javascript babylonjs

先谢谢您。我试图弄清楚如何修改代码以将旋转动画添加到导入的网格对象中。

我想出了如何将其定位在其轴上,但无法弄清楚如何使y轴上的旋转动画。

我已经提交了html源代码和app.js代码。

///////    this is the app.js code

/// <reference path="babylon.d.ts" />

var BjsApp = BjsApp || {};

BjsApp.init = function() {
  // create var and put the canvas in it
  var canvas = document.getElementById('renderCanvas');



  // create a babylonjs engine object, and pput the canvas in it and make it true for antialias
  var engine = new BABYLON.Engine(canvas, true);

  // get rid of manifest error alert
  engine.enableOfflineSupport = false;


  // creae scene 
  var createScene = function(){
    
    // put engine in the scene
    var scene = new BABYLON.Scene(engine);

    // add color to the frame background
    scene.clearColor = new BABYLON.Color3.Black();

    
    // add camera
    var camera = new BABYLON.ArcRotateCamera('arcCam', BABYLON.Tools.ToRadians(-90),BABYLON.Tools.ToRadians(90),10,BABYLON.Vector3.Zero(),scene);

    // attach camera to canvas /scene
    camera.attachControl(canvas, true);

    // add light
    var light = new BABYLON.PointLight('PointLight', new BABYLON.Vector3(0,0,0),scene);

    light.parent = camera;
    light.intensity=1.5;

  
    

  BABYLON.SceneLoader.ImportMesh("","","../assets/Logo.babylon",
  scene,function(newMeshes) { 
    //  newMeshes.forEach(function(mesh){
    //       mesh.rotation = new BABYLON.Vector3(BABYLON.Tools.ToRadians(
    //      0),0,0);
    //   }              );  
  
   
  });
  

  return scene;
}


  var scene = createScene();
  engine.runRenderLoop(function(){
    scene.render();
  });
}

---------

Here is the HTML source code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Babylon Template</title>
  <script src="https://cdn.babylonjs.com/babylon.js"></script>
  <script src="https://preview.babylonjs.com/loaders/babylonjs.loaders.min.js"></script>
  <script type="text/javascript" src="https://unpkg.com/default-passive-events"></script>
  <script src="https://code.jquery.com/pep/0.4.1/pep.js"></script>
  <link rel="stylesheet" href="css/style.css">




</head>

<body>

  <!-- create the canvas and give it an id-->
  <canvas id="renderCanvas"></canvas>

  <!-- call the js file -->
  <script src="js/app.js"></script>

  <!-- initialize the function "BjsApp.init();" in the js file-->
  <script>
    window.addEventListener('DOMContentLoaded', function () {
      BjsApp.init();
    });</script>
</body>

</html>

0 个答案:

没有答案