GithubHelp home page GithubHelp logo

raphaelameaume / fragment Goto Github PK

View Code? Open in Web Editor NEW
778.0 778.0 18.0 11.92 MB

[alpha] A web development environment for creative coding

Home Page: https://fragment.tools

License: MIT License

CSS 0.55% HTML 0.15% JavaScript 60.41% GLSL 0.15% Svelte 38.74%
creative-coding generative-art javascript web

fragment's People

Contributors

raphaelameaume avatar spenserblack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fragment's Issues

live export error

Hi,
thank you for the great project.

My issue is that I cannot run the live export website.

To reproduce,

  1. create an empty project
fragment ./sketch.js --new
  1. create a build
fragment ./sketch.js -b 
  1. the build succeeds with terminal log:
[fragment] ℹ Building files for:
- sketch.js
vite v3.2.5 building for production...
✓ 195 modules transformed.
12:15:59 AM [vite-plugin-svelte] dom compile done.
package       	files	 time	  avg
fragment-tools	   68	0.65s	9.6ms
../../../../../../../../../Desktop/fragment-bug/sketch/assets/mp4.2ae3801e.wasm        41.00 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/index.html                      0.62 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/assets/MidiPanel.a1686b2e.js    2.63 KiB / gzip: 1.33 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/assets/Exports.bcb82c63.js      4.57 KiB / gzip: 1.60 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/assets/sketch.412731aa.js       0.22 KiB / gzip: 0.16 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/assets/2DRenderer.8ac322c0.js   0.08 KiB / gzip: 0.09 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/assets/Console.bb8de45e.css     6.37 KiB / gzip: 1.75 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/assets/index.a53bd8f9.css       23.83 KiB / gzip: 4.21 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/assets/Console.cff4120d.js      52.21 KiB / gzip: 12.27 KiB
../../../../../../../../../Desktop/fragment-bug/sketch/assets/index.ed224408.js        198.13 KiB / gzip: 64.08 KiB
[fragment] ✔ Built files for:
- sketch.js
  1. run the live version (in my case, using VS Code live server), then get an error in the browser console:
Uncaught TypeError: Cannot read properties of undefined (reading 'buildConfig')
    at n.$$.update (index.f22b538f.js:98:80358)
    at se (index.f22b538f.js:1:8784)
    at new io (index.f22b538f.js:98:80779)
    at Array.Ph (index.f22b538f.js:98:88622)
    at Array.Uh (index.f22b538f.js:98:90443)
    at Pe (index.f22b538f.js:1:1646)
    at Array.Ih (index.f22b538f.js:98:87522)
    at Pe (index.f22b538f.js:1:1646)
    at Array.wh (index.f22b538f.js:98:81230)
    at Ah (index.f22b538f.js:98:84286)
  1. in the browser window, it's stuck with the on-screen message:
[fragment]
loading dependencies...

thank you for any help!

Faster GIF encoding

I notice the GIF encoder is pretty slow and hangs, and also seems to be a two-pass approach. You might like to look into gifenc which should be faster. Just to note, it uses a different quantization algorithm, so it may produce different results.

You can see an example in action below, rendering 150 frames at 1024x768px renders in ~1.5 seconds, compared to your tool which is something like 30+ seconds. 😄

https://looom-tools.netlify.app/ (click the circle/record button)

It requires a little more setup but can give you some additional flexibility in terms of quantization, worker structure, and dithering.

Two example implementations:

There is also room for a two-pass approach with gifenc, such as generating a single palette from all frames in the first pass, and in the second pass doing the encoding with that fixed palette. This can produce better consistency across frames but is slower (although, to be honest, probably still faster than your current encoder).

Also pinging @jesi-rgb who is doing similar work with p5js, it would be nice to consolidate some of these ideas around fast GIF encoding for creative coding tools. See here and here.

VectorInput is broken

VectorInput, in addition with not dispatching "change" events for Vec3Input, has a broken behaviour.

Currently, the inference for VectorInput is based on the number of keys when value is an object or length if an array. The advantage of these "light" checks is that Fragment can build a VectorInput by forcing prop type to be a vec3 if you have a color-like kind of object like { r: 0, g: 244, b: 200 }.

Inputs should whenever possible (so not primitives like number or string) modify the source value so changes can be reflected on the object without any addition to the sketch code e.g:

export let props = {
  direction: {
    value: { x: 0, y: 0, z: 0 },
  }
};

export let update = () => {
     console.log(props.direction.x); // should reflect changes from the UI
};

When an input dispatches a change, the value sent by the event should be the same type as the value received, or in case of an object, just send back the reference to the value and not a shallow/deep copy of the object.

This should be valid for vectors as arrays (like [0, 0, 0]), and for upper-level abstractions of vectors broadly used like THREE.Vector3();

This would also be a good time to add support for Vec4 inputs.

Bug with threejs dependencies

Im having issue while trying three template Fragment on windows :

step 1 : try the command fragment ./sketch.js --new --template=three/orthographic

getting error message ( you should install threejs )

step 2 : npm install three

install correctly

step 3 : fragment ./sketch.js

Could not resolve "./E:/github/sketchs/node_modules/three/build/three.module.js"

The error is obviously the ./ at the start of the url.

Usage with lygia

Hello! I'm having using shader functions from lygia... It doesn't seem possible with glsify (as it's currently setup) to load shader parts with the #include method.

This vite GLSL loader looks promising and I tried to swap out your hot-shader-reload.js with the vite plugin, but I got an error when hot-reloading:

node:internal/errors:466
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at utimes (node:fs:2000:10)
    at file:///Users/ben/Documents/personal-repos/fragment/node_modules/vite-plugin-glsl/src/watchShader.js:60:7

So it's clearly not as straightforward as a one-to-one replacement.

Do you think there's a way of getting #include to work in a shader (or any other means of loading in lygia files)?

OrbitControls not working in three.js template

Hey! Thanks for amazing library! Love the API and everything about it.
While creating a three.js demo, i tried to add OrbitControls to move scene around. But didnt quite worked for me =(.
This was my code:

import * as THREE from "three";
_import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";_



let camera,controls;

export let init = ({ scene,renderer, width, height }) => {
    camera = new THREE.PerspectiveCamera(45, 1, 0.1, 100);
    camera.position.z = 10;
    camera.lookAt(new THREE.Vector3());
    _controls = new OrbitControls(camera, renderer.domElement);_
    scene.add(new THREE.Mesh(
        new THREE.BoxGeometry(1,1,1),new THREE.MeshNormalMaterial()
    ))

};

export let update = ({ renderer, scene, time, deltaTime }) => {
    controls.update()
    renderer.render(scene, camera);
    
};

export let resize = ({ width, height }) => {
    camera.aspect = width / height;
    camera.updateProjectionMatrix();
};

export let rendering = "three";

Change canvas orientation

Hey! What a great tool you are making! I wanted to add a PR for supporting landscape/portrait canvas orientation which would be useful for example when exporting a sketch to a SVG, to be then drawn using a pen plotter.

I wonder if it's better to include Landscape/Portrait suffixes to each paper size entry (which would double the number of presets), or maybe to have additional setting that modifies the placement of canvas width and height values for each preset. Wdyt? 🙂

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.