Issue: The THREE.GLTFLoader cannot process this asset. Only glTF versions below 2.0 are compatible

Upon utilizing three.js, I encountered an error while parsing data from the GLTF JSON file. This file was exported from the three.js 3D viewer and editor, indicating a version of 4.5 in the JSON content.

Highlighted below is the JSX code snippet:

import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";

// Spaceships
import Praetor from "../Assets/GameObjects/Spaceships/Praetor.json";

const SpaceshipLoader = new GLTFLoader();

class Spaceship {
  constructor() {
    this.health = 100;
    this.speed = 10;
    this.positionX = 0;
    this.positionY = 0;
  }
  create(Scene) {
    // Loading the spaceship into the scene
    SpaceshipLoader.parse(
      Praetor,
      function (SpaceshipObject) {
        Scene.add(SpaceshipObject);
      },
      function (xhr) {
        console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
      },
      function (error) {
        console.log("An error occurred");
        console.log(error);
      }
    );
  }
  move() {}
  shoot() {}
}

export { Spaceship };

Below is an excerpt from the JSON file data, excluding the Array buffers:

{
  "metadata": {
    "version": "4.5",
    "type": "Object",
    "generator": "Object3D.toJSON"
  },
  "geometries": [
    {
      "uuid": "d6edee71-c106-4e47-b6eb-4fed31adf432",
      "type": "BufferGeometry",
      "data": {
        "attributes": {
          …
        },
        "index": {
          "type": "Uint16Array",
          "array": [
            0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 9, 10, 6, 11, 12, 13, 14, 15, 16, 17,
            18, 19, 20, 21, 19, 22, 23, 24, 25, 26, 27, 28, 29, 27, 30, 31, 32,
            33, 34, 35, 36, 37, 35, 38, 39, 40, 41, 42, 40, 43, 44, 45, 46, 47
          ]
        },
        "interleavedBuffers": {
          "b443ef6f-e5e3-4350-9ef6-c45065b45033": {
            "uuid": "b443ef6f-e5e3-4350-9ef6-c45065b45033",
            "buffer": "53392d6c-081d-44a5-ace0-badffbc81707",
            "type": "Float32Array",
            "stride": 8
          }
        },

It's worth mentioning that the object loaded flawlessly in the three.js editor.

Answer №1

Failure to export a glTF asset from the three.js editor has occurred. This pertains to the three.js JSON format that necessitates loading via THREE.ObjectLoader.

Ensure to utilize the options File > Export GLB or File > Export GLTF within the editor to generate a glTF asset.

It should be noted that the object loaded flawlessly in the three.js editor.

The editor possesses the capability to identify the appropriate loader for said JSON.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

AngularJS: How to detect the browser's refresh event

Can AngularJS detect when the user clicks the Refresh button on the browser? Is there a built-in method in the framework for developers to access? Thank you ...

Ways to access JSON data in JavaScript

I'm experiencing difficulty accessing the JSON data provided below. My approach involves utilizing the JavaScript AJAX success function, and when attempting alerts with the following code, $.ajax({ type:'GET', url:myURL, success : function ...

Use Javascript or Jquery to dynamically change the background color of cells in HTML tables based on their numerical

I am working with a collection of HTML tables that contain numbers presented in a specific style: <table border="1"> <tr> <th>Day</th> <th>Time</th> <th>A</th> <th>B</th> &l ...

Display a date that is asynchronously rendered for each item in the v-for loop

I am currently working on a project that involves an array of servers being displayed in a template using v-for. To receive dynamic data for each server, I have implemented the vue-nats library to subscribe them individually. methods: { subscribe(uuid) ...

A guide on updating an item in a basic JavaScript file with Node.js

This query pertains to Workbox and Webpack, but no prior knowledge of these libraries is necessary. Background Information (Optional) Currently using the InjectManifest plugin from Workbox 4.3.1 (workbox-webpack-plugin). While this version provides the o ...

Having trouble choosing a dropdown value with ng-model; the first item keeps showing up as blank when selected

When I attempt to select a dropdown value inside an AngularJS function by setting the value to the ng-model, the dropdown initially shows a blank value selected. Below is my HTML code: <select class="pulldown" ng-model="test" ng-options="obj as obj.des ...

What effect does setting AutoPostBack to "true" in an ASP dropdownlist have on the fireEvent() function?

I am currently working on an aspx page. This page includes three dropdown lists and a button, all of which are populated dynamically based on the code written in the code-behind file (.cs file). To achieve this, I need to utilize two event handler methods ...

Changing the data type of a column in an Excel file from XLSX to

I am currently working with the XLSX npm package and attempting to download a sample Excel file, add some data to it, and then upload it back. The fields in the file include MOBILE NUMBER, DATE, TIME, and NAME. When I upload the file, the values for the DA ...

Creating a standard login.js file for seamless integration with nightwatch.js testing

When creating tests for my web application, I need to first simulate a login before proceeding with the rest of the tests to access inner pages. Currently, I am in the process of refactoring the code so that I can create an 'include' for common f ...

Use JavaScript to dynamically add CSS styles to elements before and after a button wrapper

My code seems simple, but for some reason it's not working. I'm trying to add CSS styles to a button when there is a div with the class .wp-block-group both before and after the button. $(".btn-superimposed-wrapper").each(function () ...

Error encountered: 'applePaySession.completeMerchantValidation' is not a valid object reference when attempting to process a successful apple pay payment

So, I'm having an issue with the user's payment going through but encountering undefined value when checking compatibility. I've been trying to debug this problem in my code snippet below: setCanDisplayApplePay() { var client = n ...

Can we move the "user" object to the forefront and retrieve it from a location other than the "on.AuthSateChanged(user => .... }" function?

Is there a way to define a ref in vuefire to firebase path that relies on the current User object? Can I bring the "user" object to the top level so it can be accessed outside the "on.AuthSateChanged(user => .... }" block? firebase-config.js import * ...

Booting up the node.js environment with the help of a C++ application

Is it possible to start Node.js from a C++ application? The reason I ask is because I have a C++ console application that launches a JavaScript application which uses require('os'). However, it is failing with the error "Uncaught ReferenceError: ...

Projector.js is now located in /examples/js/renderers/Projector.js within THREE.Projector

Currently, I've been encountering a problem with my three.js program specifically when rendering on Google Chrome. Despite successfully creating the scene, all objects appear black in color. Interestingly, the program functions flawlessly on Firefox; ...

Specify the dependencies in the package.json file to ensure that the React package designed for React v17 is compatible with React v18 as well

Recently, I developed an npm package using React v17.0.2. The structure of the package.json file is as follows: { "name": "shoe-store", "version": "0.1.0", "private": true, "dependencies": ...

How come these functions continue to be executed asynchronously even when the Async module is being utilized?

My decision to utilize the Async module aimed at populating a mongodb collection according to a specific order proved to be quite challenging. Despite the fact that the code worked without Async, it failed to insert documents in the desired sequence: func ...

Set a maximum limit for the number of checkboxes that can be selected

If there are 10 checkboxes on a page, I am searching for a specific behavior: Use a variable called maxSelections to control the maximum number of selectable checkboxes Once maxSelections is reached, disable the other checkboxes on the page Even after re ...

Issue with javascript code not functioning post axios request

When working on my project, I utilize axios for handling Ajax requests. I crafted a script that attaches a listener to all links and then leverages Axios to make the Ajax request. Following the Ajax request, I aim to execute some post-processing steps. Aft ...

Determine if a SQL column exists following a SELECT statement

I have a query that I need help with: let selectQuery = "select * from mainTable where username = '"+ username + "'"; In my code, I am trying to make sure that childtable2id exists in the table. Here is what I have so far: for (let i = 0; i & ...

Sending data through forms

I'm having trouble storing values input through a dropdown menu in variables event1 and event2, despite trying global declarations. How can I successfully store a value to both variables and pass it to the JavaScript code? Thank you. <!DOCTYPE HT ...