Comments (4)
Image resources are currently loaded with 'new Image()' object and setting the 'src'. This has multiple nice consequences
- Images can be loaded from any web resource asynchronously with URLs. Have to check out cross-origin policies on this, im guessing you can load files from anywhere, the same way we can embed
img
tags from any location. - We can use base64 encoded data. instead of a url we can just provide the raw data directly in the css "mimetpye+base64" format. This means the image binary can be included in the preset json itself. This i think allows the preset-internal resources that you mention
As for global resources im including a Resources object (https://github.com/azeem/webvs/blob/1.1dev/src/Resources.js) that contains common resources. If the present json mentions a key in the Resources object instead of a URL or Base64 data then its loaded from the Resources object (check texer example https://github.com/azeem/webvs/blob/1.1dev/examples/PilloFight.html).
As for packs, i agree with you, it makes limited sense. But if anyone wants to package Webvs the library with preset packs then registering pack level resources is as simple as adding more data into Webvs.Resources
object. This can even be done at runtime without touching the library code.
from webvs.
How about a media
object in the root of the preset.
Taking the form of "media": {"fileName":"data/url"}
It would contain any embedded media and urls pointing to either standalone media or packs of media.
I think media packs would compliment WebVS packs (if we get to such a thing), its sympathetic to AVS installers.
They (media packs) would probably better suited to having base64 encoded entries only, to reduce http requests.
localstorage could be optionally used to cache fetched media.
The media could then be added to Webvs.Resources
as azeem wrote about above.
The only downside of allowing external stuff is
- This is the internet, things go down and disappear
- Cross domain security policies (Not a problem with CORS)
So when converting presets, I guess it would be best to convert them a pack at a time, and generate a media pack for the pack (ignoring Tug's texer resource files)
Also I converted all (85) of Tug's texer resources to base64/pngs: https://github.com/QOAL/qios-webvseditor/blob/master/avsres.js
from webvs.
I like the "media": {"fileName":"data/url"}
idea. if a file is being used multiple times (like texer image for example) then this can avoid repetition.
I agree with you on external files. Its not much of an advantage when you can just robustly embed the image as base64 data itself. Its just a nice addon that comes for free since loading of images work the same in either case. Going further, if there are other non-image types of binary resources that we might want to use then embedding seems to be the cleaner way to go.
from webvs.
I have added a ResourceManager system (https://github.com/azeem/webvs/blob/1.2dev/src/ResourceManager.js) that (hopefully) addresses some of the issues discussed in this thread and here: #13
So here is how it works right now.
- ResourceManager maintains a map between filenames and URI (could be URL or data URI)
- In the JSON, for individual effects, the resources will be specified only by filenames
- When a resource is required by an effect, it asks the ResourceManager, which then looks up the URI and loads the resource.
Now, there are different ways to setup this filename to URI map in the resource manager
-
From the preset JSON. a
resources
field in the root eg:"resources": { "uris": { "abc.png": "http://example.com/abc.png", "def.bmp": "data:image/png;base64;..." } }
-
Programatically. by calling
registerUri
onResourceManager
. UIs can use this. When preset JSON's are generated later with agetPreset
call, theresources
field is automatically added -
Builtin resource packs. This is just a bunch of default files that the Webvs library user is expected to put at a fixed location.
-
And may be later from External resource packs.
from webvs.
Related Issues (20)
- Convolution filter is rotated compared to AVS HOT 9
- Support arbitrary linewidth
- component property names ('s capitalization) HOT 6
- Make enumeration property values case-insensitive
- Pillofight example not working properly
- Not running anywhere anymore. (libs.js error?) HOT 4
- Examples do not play audio in Chrome HOT 1
- Examples do not react to audio in Firefox
- Indexes in webvs JSON? HOT 2
- Handle unsupported effects gracefully HOT 1
- None of the examples work, because the music has been removed from Soundcloud. HOT 4
- Showcase live webvs examples on the web HOT 2
- Write more Unit Tests
- Uncaught TypeError: Cannot read property 'updateDimVars' of undefined
- Component support HOT 6
- New TexerII feature: Add variable for rotation
- SSC missing code variables
- Missing blendmodes
- func-tests don't run (on linux?) HOT 1
- Help with Preset HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webvs.