GithubHelp home page GithubHelp logo

polygonjs / polygonjs Goto Github PK

View Code? Open in Web Editor NEW
545.0 17.0 41.0 144.49 MB

node-based WebGL design tool

Home Page: https://polygonjs.com

License: MIT License

JavaScript 35.76% TypeScript 57.81% HTML 0.03% GLSL 6.38% CSS 0.01%
webgl 3d node-based animation procedural threejs javascript geometry-processing nocode glsl

polygonjs's Introduction

Polygonjs

NPM package Twitter Discord Forum

Polygonjs is a node-based 3D WebGL design tool.

--- Home Page --- Documentation --- Try Demo ---

Polygonjs helps creating 3D interactives experiences for the web, without having to code.

A 3D scene is built by creating and connecting nodes. This gives you a non-destructive worflow, where you can try different ideas quickly, without fearing of breaking anything.

Polygonjs is also designed to be extended. This means that if it does not have a feature you need, you can add it, either by using its API, or by reading in this repository how the existing nodes are implemented and using that as a starting point.

The editor can be used both from the web or locally. The web version is convenient to discover the editor, but the local version is recommended for production, since it has the following advantages:

  • quick access to models and textures on your computer
  • tree shaked exports: It exports only the nodes you use.
  • git integration: Every files is saved as text, either json or javascript.
  • version tracking: It is an npm module, and has its version in package.json just like other dependencies
  • integration to any web project (such as threejs, vuejs, react, vanilla)

Inside Polygonjs node-based Editor

Start a project:

The easiest way to start a project is by using the cli tool:

npm create polygonjs@latest

or

yarn create polygonjs

You'll then be able to choose one of the templates for vanilla js, threejs, vuejs, react or react-three-fiber.

Add to an existing project:

If you already have an npm project, you can easily add it with:

npm add polygonjs-editor

or

yarn add polygonjs-editor

And you can then start the editor with:

npm run polygonjs-editor

or

yarn polygonjs-editor

Node-based

The nodes are grouped in contexts, each for a specific type of task:

  • ANIM nodes create animations.
  • AUDIO nodes generate and modify audio.
  • COP nodes import and update textures.
  • EVENT nodes trigger or react to scene events.
  • GL nodes create GLSL shaders.
  • JS nodes add state & events to scene objects.
  • MAT nodes create materials.
  • OBJ nodes add objects to your scene.
  • POST nodes set up post processing.
  • ROP nodes set up the renderers.
  • SOP nodes handle procedural modelling.

Plugins

Polygonjs is designed to be extensible. You can create your own plugins to add custom nodes. There are currently 4 official plugins:

  • Mapbox to add 3D objects to Mapbox maps.
  • Occlusion to calculate occlusion on a geometry and get more pleasant lighting.
  • Mediapipe Facemesh to track a face from a webcam feed
  • Physics to create and simulate rigid bodies.

Based on Threejs

Polygonjs is based on the powerful webgl library Threejs. While Polygonjs offers many nodes for many different types of 3D scenes, there are times where you may want to dig deeper and update the scenes in specific ways.

For this, you can directly access the threejs objects. There are 2 ways to do so:

  • From the scene
const scene = new PolyScene(); // this is the polygonjs scene
const threejsScene = scene.threejsScene(); // and it contains the threejs scene
  • From any node
const scene = new PolyScene();
const rootNode = scene.root();
const geo = rootNode.createNode('geo');
const plane = geo.createNode('plane');

// now let's get the content of the plane node
const container = await plane.compute();
// the container is an envelope that contains a coreGroup
const coreGroup = container.coreContent();
// and we can now get an array of THREE.Object3D:
const objects = coreGroup.threejsObjects();
// and we can use threejs API:
const object = objects[0];
object.position.set(0, 1, 0);
object.updateMatrix();

polygonjs's People

Contributors

dependabot[bot] avatar frading avatar polygonjs avatar snyk-bot 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  avatar  avatar  avatar  avatar  avatar  avatar

polygonjs's Issues

Draco lib can't be installed

I have a local installation of polygonjs.
Windows > Libraries > Install Draco ends up with threejs is not installed error message.

"File > Save" does not work

Hello again,

I just followed the instructions found in "https://polygonjs.com/docs/install/new", opened the editor and tried to save the scene using "File > Save".

The first attempt led to a "warning" and wanted me to npm install again. Thus, I stopped npm run polygon and ran npm install instead. This gave me the typical set of warnings

npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/@polygonjs/polygonjs/node_modules/three
npm WARN   three@"0.152.2" from @polygonjs/[email protected]
npm WARN   node_modules/@polygonjs/polygonjs
npm WARN     @polygonjs/polygonjs@"1.5.26" from [email protected]
npm WARN     node_modules/polygonjs-editor
npm WARN   2 more (three-mesh-bvh, three-mesh-bvh)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer three@"^0.149.0" from [email protected]
npm WARN node_modules/@polygonjs/polygonjs/node_modules/web-ifc-three
npm WARN   web-ifc-three@"0.0.125" from @polygonjs/[email protected]
npm WARN   node_modules/@polygonjs/polygonjs
npm WARN 
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/three
npm WARN   peer three@"^0.149.0" from [email protected]
npm WARN   node_modules/@polygonjs/polygonjs/node_modules/web-ifc-three
npm WARN     web-ifc-three@"0.0.125" from @polygonjs/[email protected]
npm WARN     node_modules/@polygonjs/polygonjs

up to date, audited 381 packages in 604ms

45 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

So, I ran npm run polygon, reloaded "http://localhost:8091/scenes/scene_01/edit" and tried to "File > Save" again - which led me to the same warning as before...

Therefore, it seems as if "File > Save" would not work

Amendment: "File > Save As..." does not work either...

Rigid and Soft body simulation

integrate a library like Ammo or Cannon.

Simulated objects setup could be done with a few nodes, such as RBDPrepare and RBDSolver. Optional nodes could create low res hulls if needed.

How to import a scene into a plain HTML document?

Hello,

I may be blind but I could not find instructions for exporting a scene such that I can easily import it into a plain web page, e.g. similar to

  ...
  <div id="xxx" style="..."></div>
  <link rel="stylesheet" href="xxx.css"/>
  <script src="xxx.js"></script>
  ...

The script would not need editor functionality, a simple "player" would suffice

light baking

Try and integrate with blender and its renderer. A dedicated node 'LightBaker' (or maybe a renderer) could behave as such:

  • convert the objects mentioned in an object mask to a format that blender can import (ensure before that there are uvs)
  • convert lights as well
  • convert the environment map
  • run blender's renderer, having set it up to that it writes textures
  • import back the textures and add them as lightmaps to the used material nodes

wrong "Local Export" path

I just created a new PolygonJS project and started the editor.

Then I tried to export the shown scene (the shiny sphere on a checkerboard). The first attempt failed (complaining about a missing npm install, which I did)

The second attempt reported that the export would be up-to-date, showed the export path and offered the local export to be opened - which failed

Possible reason: the reported path is ./public/polygonjs/build/scene_01, but actually, the files can be found in ./public/polygonjs/scenes/scene_01

THREE's renderer and scene could be represented as nodes

Currently the camera creates its own renderer, and every node is added to the same scene. Having dedicated nodes for each would allow to:

  • more easily change the parameters of a renderers
  • choose which scene an object is added to, which could help doing post processing after having rendered multiple scenes

animation/event system

A system where action/triggers to start animations based on user events could be created with just nodes could be interesting.
Houdini's CHOPs or Babylonjs's actions can be a good source of inspiration.

COP Node "Text" doesn't update on changes

I'm still really new to polygonjs… Still wrapping my head around it, so maybe I overlooked something.
polygonjs is so awsome btw! <3

I was working with the COP Node Text that produces a canvas that can be used as a texture. Some of the settings do not update the canvas, or they update the canvas, but polygonjs does not show the change in the texture.

Digging around, I found the COP Canvas Node that has a button to manually update the texture.
Maybe the same button would make sense for the text node?

update = ParamConfig.BUTTON(null, {
cook: false,
callback: (node: BaseNodeType) => {
CanvasCopNode.PARAM_CALLBACK_update(node as CanvasCopNode);
},

AR integration

AR could be added, by simply adding a new type of camera, on top of the currently existing PerspectiveCamera and OrthographicCamera.

https://github.com/jeromeetienne/AR.js seems like a great library to integrate.

The camera parameters could be as easy as adding what type of markers it would accept.

Three.js dependency version mismatch

I just downloaded the repo and tried to build.

However, npm install failed with

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @polygonjs/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/three
npm ERR!   three@"0.152.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer three@"^0.141.0" from [email protected]
npm ERR! node_modules/three-bvh-csg
npm ERR!   three-bvh-csg@"0.0.5" from the root project

What is your recommendation for a fix?

Clone methods do not respect proper OOP

What you have right now all over the place is:

class Node {
  constructor(asd) {
    this.asd = asd;
  }
  clone() {
    return new Node(this.asd);
  }
}
node1 = new Node(123);
node2 = node1.clone();

However, you can show very easily how wrong it is if you actually try to use OOP:

class SpecialNode extends Node {
  broom = 'broooom';
}
specialNode1 = new SpecialNode(456);
specialNode2 = specialNode1.clone();

specialNode1 instanceof SpecialNode is of course true, but specialNode2 regresses into a Node... the proper way to clone in JavaScript is: new this.constructor(this.asd)

orbit controls ...

... don't work for me, in both examples start.html and start2.html.

Great idea and implementation, nevertheless!
Thanks, Dirk

js builder

Similar to the current glsl builder used for materials, particles and textures, add a javascript builder system to easily manipulate geometry attributes, or objects parameters.

Run polygon.js as a webhook in response and return a message and an attachment

I recently woke up from a nap with an idea to use PolygonJS as a Discord webhook watcher. The goal is to output a "Hello World" message along with a GLTF cube. Alternatively, I would like it to send an OpenAI LLM message and an AI-generated image as an attachment via Replicate.com.

I have already set up the API endpoints for the cloud APIs. However, I am seeking insights on setting up the Discord webhook that ticks every half second, and advice on cloud hosting.

"THREE.EXRLoader: provided file doesn't appear to be in OpenEXR format."

Yet another problem: given the outcome of my previous issue, I tried to "online export" the demo scene to "Vanilla JS" from my locally installed PolygonJS project.

The codesandbox.io window opened (with the expected set of files) but failed to show the scene - instead I got the following error message:

THREE.EXRLoader: provided file doesn't appear to be in OpenEXR format.

▼ 4 stack frames were expanded.
parseHeader
https://lnwx6t.csb.app/node_modules/three/examples/jsm/loaders/EXRLoader.js:1142:15
EXRLoader.parse
https://lnwx6t.csb.app/node_modules/three/examples/jsm/loaders/EXRLoader.js:1286:23
Object.eval [as onLoad]
https://lnwx6t.csb.app/node_modules/three/build/three.cjs:41908:26
eval
https://lnwx6t.csb.app/node_modules/three/build/three.cjs:41502:38
▲ 4 stack frames were expanded.

This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error.
This error overlay is powered by `react-error-overlay` used in `create-react-app`.

Easily switch nodes to use workers

Polish the current worker setup. A subnetwork whose nodes are sent to a worker should be able to only copy/shader an attribute buffer (as opposed to transfer a whole geometry, which can be very slow)

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.