Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error encountered when cloning a BatchedMesh: Uncaught TypeError: this._matricesTexture.image.slice is not a function #28803

Closed
lanvada opened this issue Jul 4, 2024 · 2 comments · Fixed by #28805
Labels

Comments

@lanvada
Copy link
Contributor

lanvada commented Jul 4, 2024

Description

While attempting to clone a BatchedMesh, I encountered the following error: Uncaught TypeError: this._matricesTexture.image.slice is not a function.

I noticed that the BatchedMesh source code contains the following lines:

...
// Line 930
this._matricesTexture.image.data = this._matricesTexture.image.slice();
...
// Line 935
this._colorsTexture.image.data = this._colorsTexture.image.slice();
...

During debugging, I observed that the data property of image is a TypedArray, but image itself does not have a slice() method. I am wondering if image.slice() should be modified to image.data.slice()?

Reproduction steps

Clone a BatchedMesh

Code

none

Live example

none

Screenshots

No response

Version

r166

Device

Desktop

Browser

Chrome

OS

Windows

@lanvada
Copy link
Contributor Author

lanvada commented Jul 4, 2024

Since I didn't find the Image class in the Threejs documentation, I don't quite understand what the data structure of Image is, and whether only the Image in the DataTexture created in BatchedMesh does not have a slice() method

@Shakhriddin
Copy link

It’s good that you noticed, there really should be an image.data.slice() here to clone texture data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants