Error Encountered: Attempting to access the 'play' property of an undefined object caused a TypeError

I recently tried my hand at creating avatars and animations using readyplay.me and mixamo. For those interested, you can check out the tutorial I followed here: https://dev.to/nourdinedev/how-to-use-threejs-and-react-to-render-a-3d-model-of-your-self-4kkf

Sharing my App.js code below – while I successfully managed to create an avatar that works in JavaScript, I encountered an error when trying to replace model.glb with model_animation.glb. Any insights on what might be causing this error would be greatly appreciated!

/*
Auto-generated by: https://github.com/pmndrs/gltfjsx
*/

import React, { useRef, useEffect } from "react";
import { useGLTF, useAnimations } from "@react-three/drei";

export default function Model({ ...props }) {
  const group = useRef();
  const { nodes, materials, animations } = useGLTF(
    "/model_animation.glb"
  );
  const { actions } = useAnimations(animations, group);
  useEffect(() => {
    actions["Armature|mixamo.com|Layer0"].play();
  });
  return (
    <group ref={group} {...props} dispose={null}>
    <group name="Armature001"></group>
      <primitive object={nodes.Hips} />
      <skinnedMesh name="Wolf3D_Avatar001" geometry={nodes.Wolf3D_Avatar001.geometry} material={materials['Wolf3D_Avatar.001']} skeleton={nodes.Wolf3D_Avatar001.skeleton} morphTargetDictionary={nodes.Wolf3D_Avatar001.morphTargetDictionary} morphTargetInfluences={nodes.Wolf3D_Avatar001.morphTargetInfluences} />
    </group>
  )
}

useGLTF.preload('/model_animation.glb')

Answer №1

Make sure to update the file name of your model to align with the import statement in your code.

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

What is the best way to showcase a value in JavaScript using CSS styling?

I'm looking to customize the background, font style, and outline for both open and closed elements in the code snippet below: a.innerHTML = "We are Open now now."; a.innerHTML = "We are Closed, arm."; Additionally, I want to appl ...

Is anyone else experiencing issues with the Express middleware that checks for IDs? Looking for suggestions on how to fix

Currently working on a project with Node js utilizing Express and MongoDb for the backend. In this project, USERS have the ability to post COMMENTS, so I have created a middleware to access the DELETE route and check if the USER ID matches the ID of the in ...

What is the best way to deliver flash messages using Express 4.0?

Currently, my web application requires authentication, and I am encountering an issue with the signup page. If a user tries to sign up with an email that is already in the database, I want to display an error message. Here is the code snippet I am using on ...

Having trouble retrieving the value from the input text in a dynamically generated table

How can I retrieve values from a dynamically generated table after clicking a button? Below is the code I have implemented to create a table with input fields: function createTable(rows, cols){ var body = document.body, table = document.createEl ...

What is the best way to clean HTML in a React application?

I am trying to showcase HTML content on the React front end. Here is the input I have: <p>Hello/<p> Aadafsf <h1>H1 in hello</h1> This content was written using CKEditor from the Admin side. This is how it appears on the React fro ...

Is it possible to exclude certain static files from being served in express.static?

const express = require('express'); const app = express(); app.use('/app', express.static(path.resolve(__dirname, './app'), { maxage: '600s' })) app.listen(9292, function(err){ if (err) console.log(err); ...

Create a custom npm package that is compatible with frontend environments like create-react-app. Ensure you have a suitable loader in place to handle the specific file type of the module

After developing a node module and releasing it as a node package, I encountered an issue when trying to use it in frontend applications (specifically with a 'create-react-app'). The error message that appeared stated: Module parse failed: Unexp ...

console displaying indentation problems with laravel and vue

I am currently utilizing Vue within Laravel and encountering a multitude of indentation errors in the console. https://i.sstatic.net/sfRec.png Here is an excerpt from my package.json file: "private": true, "scripts": { "clean": "rimraf public/buil ...

Error encountered in Three.js when using multiple canvases and loading JSON geometry

I have been working on creating multiple views and came across an example code here which worked flawlessly when I tried it. However, when I replaced the geometries with ones I created in Blender, I encountered an error: Cannot read property 'length ...

Can halting an ajax function mid-process prevent it from finishing?

My objective is to convert a video using ffmpeg, which tends to take a considerable amount of time to complete. I'm considering sending an ajax request to the server for this task, but I don't want the user to have to wait until the video convers ...

Tips for downloading a file using a Django function triggered by JavaScript instead of redirecting to the URL

Managing a page with multiple buttons that trigger various functions, such as sending an SMS (via API), emailing a file, or downloading a PDF. The button actions are powered by Ajax requests through JavaScript instead of using forms. I initially used Java ...

Changing values in object using Mongoose in MongoDB

Currently, I have a basic collection stored in MongoDB using Mongoose. My users model consists of a single field of type object, and I am looking to dynamically modify this object. However, despite my attempts using findByIdAndUpdate(), findById, findOne( ...

The function insertAdjacentHTML does not seem to be functioning properly when used with a

I am working with a parent element that contains some child elements. I create a DocumentFragment and clone certain nodes, adding them to the fragment. Then, I attempt to insert the fragment into the DOM using the insertAdjacentHTML method. Here is an ex ...

Trigger the ASP .NET OnCheckedChange server event using JavaScript

One issue I encountered is related to a checkbox with an OnCheckedChanged event. Occasionally, I modify the checked status of the checkbox using javascript. However, when this occurs, the OnCheckedChanged event does not trigger. Is there any method to ens ...

Is jQuery failing to correctly validate the RadioButtonList?

Using jQuery, I am attempting to validate a RadioButtonList to make sure that the user has selected one of the values. If none of the radio buttons are checked, an alert message should appear. However, even after selecting a radio button, the alert continu ...

Which entity is responsible for supplying the next() function within Express middleware?

I'm trying to understand the workings of next() in Node.js and Express middleware. While there have been previous inquiries regarding middleware operations, such as this one, I am seeking a fresh perspective. The primary query troubling me is: who s ...

Managing JSON responses from a server using Javascript

I have encountered various similar issues, but none of them have provided a solution for my specific question. On my server, I generate a JSON string and place it in the response: List<String> list = getSomeList(); JSONArray jsArray = new JSONArray( ...

What is the method for acquiring a dynamic segment in the router of a Next.js 13 application?

Currently in my project, I am using the new App Router in Next.js 13 and MongoDB as the DBMS to fetch data via API. When trying to retrieve all data from a collection, it is successful. However, fetching only one data results in failure. The error message ...

The Jquery Ajax .load() function is not working properly

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Tabs - Expanding content</title> <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> < ...

`The ultimate guide to fixing the node.js ENOENT error`

Currently, I am utilizing express.js to execute this code snippet: var repl = require("repl"); var express = require('express'); var app = express(); var server = require('http').createServer(app); var io = require('socket.io&apos ...