Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

donmccurdy/three-shadenodeloader

Repository files navigation

THREE.ShadeNodeLoader

Status License

three.js loader for shaders created with Shade app for iOS.

const loader = new ShadeNodeLoader();

const sceneTime = new TimerNode();

// Some node types (time, microphone input, props, etc.) need to be
// provided by the application. Use the `.setFactory()` method to configure
// a callback for creating these nodes.
loader.setFactory( ( nodeDef ) => {

  switch ( nodeDef.class ) {

    case 'TimeNode':
      return sceneTime;

    default:
      throw new Error(`Unknown type: ${nodeDef.class}.`);

  }

} );

// The load callback returns a THREE.NodeMaterial instance, ready to be
// used in a mesh. Additional properties created by the loader may be
// visible in `material.userData`, such as:
// - needsDerivatives: Derivatives must be enabled on the material.
// - needsBarycentric: Barycentric coordinates must be added to the geometry.
// - instanceCount: Requires a THREE.InstanceBufferGeometry with the given count.
loader.load(

  'shaders/Dissolve/Graph.json',

  ( material ) => scene.add( new THREE.Mesh( new THREE.TorusKnotBufferGeometry(), material ) ),

  ( event ) => console.info( event ),

  ( error ) => console.error( error )

);

About

[EXPERIMENTAL] three.js loader for shaders created with Shade app for iOS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published