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

Animation Tracks: Convert to es6 classes #20013

Merged
merged 7 commits into from
Feb 17, 2021

Conversation

ianpurvis
Copy link
Contributor

Supports #19986

return new QuaternionLinearInterpolant( this.times, this.values, this.getValueSize(), result );

},

InterpolantFactoryMethodSmooth: undefined // not yet implemented
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this pattern where prototype methods are undefined to drive fallback logic in base KeyframeTrack. It feels kind of wrong to mutate the KeyframeTrack interface, although I guess if these can be considered internal it doesn't matter. No need to change now, just pointing it out as another candidate for some cleanup down the road.

Comment on lines +458 to 466
Object.assign( KeyframeTrack.prototype, {

TimeBufferType: Float32Array,

ValueBufferType: Float32Array,

DefaultInterpolation: InterpolateLinear,

} );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated whether or not to preserve these prototype properties. They should reduce memory footprint with a large number of animation tracks, though I don't know if that matters in real world usage. They seem better suited as static props than instance props? Anyways, let me know what direction is good and I can tweak this PR as needed.

Honestly, all of the inheritance doesn't seem that useful. In the long run maybe the track system could just be refactored with a more data-driven approach.

@DefinitelyMaybe DefinitelyMaybe mentioned this pull request Aug 5, 2020
43 tasks
@mrdoob mrdoob added this to the r121 milestone Aug 23, 2020
@mrdoob mrdoob modified the milestones: r121, r122 Sep 29, 2020
@mrdoob mrdoob modified the milestones: r122, r123 Oct 28, 2020
@mrdoob mrdoob modified the milestones: r123, r124 Nov 25, 2020
@mrdoob mrdoob modified the milestones: r124, r125 Dec 24, 2020
@mrdoob mrdoob modified the milestones: r125, r126 Jan 27, 2021
@mrdoob mrdoob merged commit 582df68 into mrdoob:dev Feb 17, 2021
@mrdoob
Copy link
Owner

mrdoob commented Feb 17, 2021

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Feb 17, 2021

Btw, seems like Object.assign() breaks tree-shaking in Rollup. I'll change them to individual *.prototype.* =.

@mrdoob
Copy link
Owner

mrdoob commented Feb 17, 2021

6100437

@ianpurvis ianpurvis deleted the animation-tracks-es6-classes branch February 17, 2021 22:12
@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 23, 2021

It seems this PR has broken KeyframeTrack serialization. This can easily be tested by drag'n'drop an animated asset into the editor and wait for the save.

https://raw.githack.com/mrdoob/three.js/dev/editor/index.html
https://github.com/mrdoob/three.js/blob/dev/examples/models/gltf/Flamingo.glb

The following runtime error occurs:

three.module.js:32997 Uncaught RangeError: Maximum call stack size exceeded

At this place:

const trackType = track.constructor;

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 23, 2021

Fiddle demonstrating the bug:

https://jsfiddle.net/th1m48a9/

@mrdoob Since the release is tomorrow, this is in some sense a blocker. If not fixed in time, it's better to revert this PR.

@ianpurvis
Copy link
Contributor Author

@Mugen87 Thanks for the bug report... I think this should be fixed in #21342.

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

Successfully merging this pull request may close these issues.

3 participants