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

Creating new assets is difficult #30

Open
cwillisf opened this issue Feb 16, 2018 · 4 comments
Open

Creating new assets is difficult #30

cwillisf opened this issue Feb 16, 2018 · 4 comments

Comments

@cwillisf
Copy link
Contributor

cwillisf commented Feb 16, 2018

Expected Behavior

There should be a straightforward way to create a new empty Asset object, or to create a new Asset with externally-defined contents, without relying on an environment-specific data type.

Actual Behavior

Doing so currently requires creating a Buffer, which is a Node.js-only type. This means there's no good way to create or fill an Asset in environment-neutral code.

Steps to Reproduce

See scratchfoundation/scratch-vm#915

@cwillisf
Copy link
Contributor Author

Once this is fixed we should review all paths in the VM which duplicate sprites, costumes, and sounds. Those duplication paths should be duplicating assets rather than "loading" fresh assets.

@cwillisf cwillisf modified the milestones: February 2018, March 2018 Feb 28, 2018
@thisandagain thisandagain modified the milestones: March 2018, Backlog Apr 4, 2018
@stefania11
Copy link

stefania11 commented Mar 16, 2019

I am also interested in following up on this as we want to create our own library of sprites and currently there is no easy way to do that :(
@cwillisf

@towerofnix
Copy link

@stefania11 I believe this issue isn't related to that (this issue is about dynamically creating asset objects). To add items to libraries of sprites/etc, you'll want to look into modifying the files in src/lib/libraries of scratch-gui (all that's required is that the assets (i.e. their "md5" files) be uploaded onto assets.scratch.mit.edu, which you can do by importing them into any online Scratch project).

@hzhang1902
Copy link

hzhang1902 commented Jul 8, 2021

Check out an npm package called buffer. The APIs are the same as the Node.js ones, and it supports browsers. Currently our project attaches the storage to the vm and we run it on browsers using

new webpack.ProvidePlugin({
      Buffer: ['buffer', 'Buffer'],
    })

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

Successfully merging a pull request may close this issue.

5 participants