Uncaught TypeError: babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0 __. Observable не является конструктором - PullRequest
1 голос
/ 09 марта 2020

По какой-то причине это ошибка, которую я получаю при попытке присоединить 3D-модель к Babylon. Я перепробовал все. введите описание изображения здесь . Я прикрепил полученную ошибку. Есть ли более простой способ прикрепить 3D модель (GLTF)? или как я могу это исправить? Все остальные объекты есть, и камера работает нормально. Что еще я могу добавить?

   <!DOCTYPE html>
<html>
  <head>
    <title>Babylon - Tutorials from www.FilmsByKris.com</title>
    <script src="js/babylon.js"></script>
    <script src="js/babylon.glTFFileLoader.js"></script>
    <link rel="stylesheet" href="main.css" />
  </head>
  <body>
    <canvas id="renderCanvas"></canvas>
    <model-3d
      background-color="#ffffff"
      src="LegoRobot/ComplexRobot.gltf"
    ></model-3d>
    <script>
      var canvas = document.getElementById("renderCanvas");
      var engine = new BABYLON.Engine(canvas, true);
      var Scene = new BABYLON.Scene(engine);

      //cameras
      var Camera = new BABYLON.ArcRotateCamera(
        "Camera",
        1,
        1,
        20,
        new BABYLON.Vector3(0, 0, 0),
        Scene
      );

      //lights
      var light0 = new BABYLON.PointLight(
        "Omni",
        new BABYLON.Vector3(0, 0, 10),
        Scene
      );
      //BABYLON.SceneLoader.Append("LegoRobot/ComplexRobot.glb", scene);
      // Create a default arc rotate camera and light.
      //     scene.createDefaultCameraOrLight(true, true, true);

      //     // The default camera looks at the back of the asset.
      //     // Rotate the camera by 180 degrees to the front of the asset.
      //     scene.activeCamera.alpha += Math.PI;
      //   });
      //meshes
      //sphere parameters are: name, number of segments (highly detailed or not), size, scene to attach the mesh.
      var ball = BABYLON.Mesh.CreateSphere("Ball", 10, 1.0, Scene);
      ball.position.x = -5; //position mesh

      //box parameters are: name, size of the box, the scene to attach the mesh.
      var box = BABYLON.Mesh.CreateBox("Box", 1, Scene);
      box.position.x = -10; //position mesh

      //plane parameters are: name, size, and scene to attach the mesh.
      var plane = BABYLON.Mesh.CreatePlane("Plane", 10.0, Scene);
      plane.position.x = 5; //position mesh
      plane.rotation.y = Math.PI; //rotate 180

      //cylinder parameters are:
      //name, height, diameterTop, diameterBottom, tessellation (highly detailed or not), scene, updatable.
      var cylinder = BABYLON.Mesh.CreateCylinder(
        "cylinder",
        3,
        3,
        3,
        20,
        Scene,
        false
      );
      cylinder.position.x = 15; //position mesh

      Scene.activeCamera.attachControl(canvas);

      engine.runRenderLoop(function() {
        Scene.render();
      });

      window.addEventListener("resize", function() {
        engine.resize();
      });
    </script>
  </body>
</html>
...