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

SpriteAnimator/useSpriteLoader types #2171

Merged
merged 71 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
6b3af00
feat: added optional Sprite or Plane geometry for SpriteAnimator
netgfx Sep 6, 2023
2c3b3d5
Merge remote-tracking branch 'origin/master'
netgfx Sep 13, 2023
66a09ec
Merge branch 'pmndrs:master' into master
netgfx Sep 19, 2023
f2422a0
Merge branch 'pmndrs:master' into master
netgfx Sep 29, 2023
4ea2d8c
Merge branch 'pmndrs:master' into master
netgfx Oct 7, 2023
67689d4
Merge branch 'pmndrs:master' into master
netgfx Oct 9, 2023
3de0966
Merge branch 'pmndrs:master' into master
netgfx Oct 19, 2023
723b3a1
Merge branch 'pmndrs:master' into master
netgfx Oct 26, 2023
b73ccde
Merge branch 'pmndrs:master' into master
netgfx Nov 15, 2023
583564f
Merge branch 'pmndrs:master' into master
netgfx Dec 18, 2023
29bb924
Merge branch 'pmndrs:master' into master
netgfx Jan 5, 2024
edb486a
Merge branch 'pmndrs:master' into master
netgfx Jan 21, 2024
6163ed9
Merge branch 'pmndrs:master' into master
netgfx Jan 31, 2024
197c444
Merge branch 'pmndrs:master' into master
netgfx Feb 3, 2024
1d97ca9
Merge branch 'pmndrs:master' into master
netgfx Feb 5, 2024
bfd6851
Merge branch 'pmndrs:master' into master
netgfx Feb 10, 2024
a1a3e18
Merge branch 'pmndrs:master' into master
netgfx Feb 11, 2024
f236ea3
Merge branch 'pmndrs:master' into master
netgfx Feb 24, 2024
7e25331
Merge branch 'pmndrs:master' into master
netgfx Mar 5, 2024
cf80ba3
Merge branch 'pmndrs:master' into master
netgfx Mar 16, 2024
4ab5687
Merge branch 'pmndrs:master' into master
netgfx Apr 12, 2024
dee87b1
Merge branch 'pmndrs:master' into master
netgfx May 31, 2024
abde9ab
Merge branch 'pmndrs:master' into master
netgfx Jun 10, 2024
e6758ca
Merge branch 'pmndrs:master' into master
netgfx Jun 11, 2024
b966985
Merge branch 'pmndrs:master' into master
netgfx Jun 20, 2024
136961e
Merge branch 'pmndrs:master' into master
netgfx Oct 22, 2024
5cda03d
Merge branch 'pmndrs:master' into master
netgfx Oct 29, 2024
d0eec1d
Merge branch 'pmndrs:master' into master
netgfx Oct 30, 2024
01eb03b
fix: added more strict types to spriteanimator
netgfx Oct 30, 2024
5e37309
improved documentation
netgfx Oct 30, 2024
116f112
replaced interface with type, added prop comments
netgfx Oct 31, 2024
b737319
removed unused types, preferred type inferring when possible
netgfx Oct 31, 2024
7154c26
fixes for types and more accurate type handling
netgfx Nov 1, 2024
b673613
prettier fixes
netgfx Nov 1, 2024
2f047b0
improved dependencies, fixed eslint errors
netgfx Nov 1, 2024
cd9ac2b
no more any
abernier Nov 1, 2024
0f492f7
removing more type-assertions
abernier Nov 1, 2024
ab72df5
Merge branch 'pmndrs:master' into master
netgfx Nov 2, 2024
479cd9e
cleaned up some comments on documentation
netgfx Nov 2, 2024
b4f04ed
more types enhancements
abernier Nov 2, 2024
1391a2f
removing more type-assertions
abernier Nov 2, 2024
941e8a3
CommonProps
abernier Nov 2, 2024
8d6d44e
Merge branch 'pmndrs:master' into master
netgfx Nov 2, 2024
35db2d4
fix for useSpriteLoader types
abernier Nov 2, 2024
671989d
common props
netgfx Nov 3, 2024
b09d6a8
Merge branch 'master' into fix/spriteanimator-types
netgfx Nov 3, 2024
0667aa4
Merge remote-tracking branch 'origin/fix/spriteanimator-types' into f…
netgfx Nov 3, 2024
3968b43
added default values
netgfx Nov 5, 2024
46f2a81
removed unused functions
netgfx Nov 5, 2024
138d9cb
Spriteanimator is now pulling types from useSpriteLoader
netgfx Nov 5, 2024
50dce65
renamed function
netgfx Nov 5, 2024
b956cb7
removed extra dependencies, removed duplicate variables
netgfx Nov 8, 2024
3bacfe1
simplified promise to callback
netgfx Nov 8, 2024
85071b9
Merge branch 'master' of https://github.com/pmndrs/drei into pr/2171
abernier Nov 10, 2024
fbb87ab
Merge branch 'pmndrs:master' into master
netgfx Nov 10, 2024
d822dfe
Merge branch 'master' into fix/spriteanimator-types
netgfx Nov 10, 2024
3ba5fc4
added eslint fixes
netgfx Nov 10, 2024
9845805
Merge branch 'fix/spriteanimator-types' of https://github.com/netgfx/…
abernier Nov 11, 2024
a7110a7
added proper types on some internal variables
netgfx Nov 12, 2024
bf0526a
streamlined types for onLoad
netgfx Nov 12, 2024
a151832
sharing getFirstFrame
abernier Nov 12, 2024
c097c0d
killing deps
abernier Nov 12, 2024
9deb57f
simplifying useSpriteLoader
abernier Nov 12, 2024
3111c1b
added spriteAnimator interactive story
netgfx Nov 12, 2024
f313986
Merge remote-tracking branch 'origin/fix/spriteanimator-types' into f…
netgfx Nov 12, 2024
192cfe4
reverted story, added a new story with json data
netgfx Nov 12, 2024
e8916cd
removed unused assets
netgfx Nov 12, 2024
bc95cc5
Revert "simplifying useSpriteLoader"
abernier Nov 14, 2024
140fe43
Revert "killing deps"
abernier Nov 14, 2024
d219708
fix for unnecessary re-render
netgfx Nov 15, 2024
07a56ec
prettier formatting
netgfx Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
300 changes: 300 additions & 0 deletions .storybook/public/cyclops.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
{"frames": {

"Attacking_000":
{
"frame": {"x":1,"y":1,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_001":
{
"frame": {"x":643,"y":1,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_002":
{
"frame": {"x":1285,"y":1,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_003":
{
"frame": {"x":1927,"y":1,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_004":
{
"frame": {"x":2569,"y":1,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_005":
{
"frame": {"x":3211,"y":1,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_006":
{
"frame": {"x":1,"y":483,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_007":
{
"frame": {"x":643,"y":483,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_008":
{
"frame": {"x":1285,"y":483,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_009":
{
"frame": {"x":1927,"y":483,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_010":
{
"frame": {"x":2569,"y":483,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Attacking_011":
{
"frame": {"x":3211,"y":483,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_000":
{
"frame": {"x":1,"y":965,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_001":
{
"frame": {"x":643,"y":965,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_002":
{
"frame": {"x":1285,"y":965,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_003":
{
"frame": {"x":1927,"y":965,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_004":
{
"frame": {"x":2569,"y":965,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_005":
{
"frame": {"x":3211,"y":965,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_006":
{
"frame": {"x":1,"y":1447,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_007":
{
"frame": {"x":643,"y":1447,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_008":
{
"frame": {"x":1285,"y":1447,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_009":
{
"frame": {"x":1927,"y":1447,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_010":
{
"frame": {"x":2569,"y":1447,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Hurt_011":
{
"frame": {"x":3211,"y":1447,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_000":
{
"frame": {"x":1,"y":1929,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_001":
{
"frame": {"x":643,"y":1929,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_002":
{
"frame": {"x":1285,"y":1929,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_003":
{
"frame": {"x":1927,"y":1929,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_004":
{
"frame": {"x":2569,"y":1929,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_005":
{
"frame": {"x":3211,"y":1929,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_006":
{
"frame": {"x":1,"y":2411,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_007":
{
"frame": {"x":643,"y":2411,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_008":
{
"frame": {"x":1285,"y":2411,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_009":
{
"frame": {"x":1927,"y":2411,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_010":
{
"frame": {"x":2569,"y":2411,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
},
"Idle_011":
{
"frame": {"x":3211,"y":2411,"w":640,"h":480},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":640,"h":480},
"sourceSize": {"w":640,"h":480}
}},
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "1.0",
"image": "cyclops.png",
"format": "RGBA8888",
"size": {"w":3852,"h":2892},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:0e87593e152aa1b96dcc023abeafd158:bb7257f44207a87046359dab31983daf:cf3b5afa5774b99a9ed80f2056562301$"
}
}
Binary file added .storybook/public/cyclops.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions .storybook/stories/SpriteAnimator.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { SpriteAnimator, useSpriteLoader } from '../../src'

const SPRITE_IMAGE = 'story.png'
const SPRITE_DATA = 'story.json'
const CYCLOPS_IMAGE = 'cyclops.png'
const CYCLOPS_JSON = 'cyclops.json'

export default {
title: 'Misc/SpriteAnimator',
Expand Down Expand Up @@ -82,3 +84,23 @@ export const SpriteAnimatorSt3 = {
render: (args) => <SpriteAnimatorScene3 {...args} />,
name: 'Multiple',
} satisfies Story

function SpriteAnimatorScene4(props: React.ComponentProps<typeof SpriteAnimator>) {
const commonProps = {
textureImageURL: CYCLOPS_IMAGE,
textureDataURL: CYCLOPS_JSON,
animationNames: ['idle', 'attacking', 'hurt'],
}

return (
<>
<SpriteAnimator {...props} position={[-2, 0, 0.01]} {...commonProps} fps={18} scale={2.5} frameName={'idle'} />
</>
)
}

export const SpriteAnimatorSt4 = {
args: {},
render: (args) => <SpriteAnimatorScene4 {...args} />,
name: 'Image & JSON',
} satisfies Story
Loading