Morphing error for "same script" Needle vs Vanilla

Hello,

I’m working on Morphing right now and I have a problem (See on the script).
My gameObject with the script has the exact same geometry than in right (CubeGeometry, same scale, same subdivision)

But, when I generate a total new geometry from scratch, the morphing works perfectly, no error.
If I take the geometry of my GameObject, and I do exactly the same thing, I got an error.
On the left the “Needle way” script, on the right the original script.

Do someone has an idea ?

Original Post on Discord

by user 224464722878005248

by user 224464722878005248

Is “this.gameObject” of type “mesh” ? e.g. what does “this.gameObject.type” print?

image.png

by user 224464722878005248

Yes

by user 224464722878005248

For debugging I’d recommend you enable “pause on exceptions” and have a look at what exactly is missing / undefined

You can also jump to the position in the threejs source (by clicking the links on the right of your logs)

If the code is one big line click this button at the bottom

And then you can add breakpoints
image.png
image.png

It sends me the same error
In three.module.js

by user 224464722878005248

by user 224464722878005248

by user 224464722878005248

Looks like you have an object there that only has x,y,z but is not a Vector3

Yes for sure it wont change that - but then you can use the browsers debugging tools to see what is undefined / what the values are of your code at that point in time and try figure out what is wrong and why

Will help you a lot in the long run if you learn to use those tools :slightly_smiling_face:

You can do the same for your code - and you can add this command in your code in any line debugger to force the javascript debugger to break at runtime

What do you mean ?

I will try to understand the error

But it’s weird because it’s the exact geometry of the example and I checked the generation of “Morph targets” are valid :confused:

by user 224464722878005248

Ok, found a lead

by user 224464722878005248

by user 224464722878005248

I don’t really know why
But when I generate my Morph Target with the original script, the mesh.morphTargetInfluences is correctly “changed” (without any line of code)
But in the Needle way script it doesn’t

by user 224464722878005248

What do you mean by Needle way script :slightly_smiling_face:

The left function
With this.gameObject.geometry

by user 224464722878005248