Giter VIP home page Giter VIP logo

triceratops's Introduction

Triceratops

Triceratops logo

Triceratops is a Grasshopper plugin that exports geometry from Grasshopper to a JSON file in the Three.js object scene format.

Goals

Triceratops is a Grasshopper exporter made for web developers that use Three.js. Therefore, the intention is to create a Grasshopper plugin that exposes the Three.js object classes and their attributes while using terminology the mirrors that of Three.js. Many components represent specific Three.js object classes in both name and attributes. For instance, the component MeshStandardMaterial allows the user to create an object of this class and associate it a mesh object.

Acknowledgement

This project was built with support from Kohn Pedersen Fox Associates PC.

Install

Watch the tutorial video here or follow the steps below:

  • Go to Triceratops page at Food4Rhino and download the project .zip folder.

  • Extract the files from the .zip folder.

  • Place the .gha file in your grasshopper components folder. This can be found from Grasshopper at: File > Special Folders > Components Folder

    or often at the following location on your C drive: C:\Users[your username]\AppData\Roaming\Grasshopper\Libraries

  • Restart, or start a new instance of Rhino/Grasshopper

Output

The plugin produces as a JSON with using the Three.js object scene format. The resulting JSON objects can be loaded into a Three.js canvas using THREE.ObjectLoader().

Supported Geometry

Meshes, lines, and points are supported. The exporter uses the bufferGeometry format for defining geometry. All meshes use face indexing.

Tools

Triceratops menu

Geometry

  • Mesh Mesh builds a Three.js mesh object with associated bufferGeometry. If no material is defined Three.js will automatically assign MeshBasicMaterial.
  • MeshVertexColors MeshVertexColors builds a Three.js mesh object with vertex colors.
  • MeshColorFaces Color Mesh Faces unwelds all mesh edges and colors vertices based on mesh faces.
  • Line Line builds a Three.js line object and associated bufferGeometry. If no material is defined Three.js will automatically assign LineBasicMaterial.
  • LineVertexColors LineVertexColor creates a Three.js line object that uses vertex colors.
  • Points Points creates a Three.js points object with associated bufferGeometry. If no material is specified, Three.js will assign PointsMaterial on load.
  • Points PointsVertexColors creates a Three.js points object where each point can be given a custom color. If no material is specified, Three.js will assign PointsMaterial on load.
  • UserData UserData creates an object consisting of custom key, value pairs that can be attached to geometry using threejs' userData property.

Materials

  • MeshNormalMaterial MeshNormalMaterial creates a Three.js material object of the MeshNormalMaterial type. This material colors mesh faces based on their normal.
  • MeshBasicMaterial MeshBasicMaterial creates a Three.js material object of the MeshBasicMaterial type. This material gives a mesh a solid color that does not react to scene lighting or shadows.
  • MeshStandardMaterial MeshStandardMaterial creates a Three.js material object of the MeshStandardMaterial class. This material uses physically based rendering to make a material that reacts to light in a realistic way.
  • Wireframe WireframeSettings can be added to other materials and so that only the wireframe of the object is visible.
  • ShadowMaterial ShadowMaterial creates a material that receives shadow, but is otherwise not visible.
  • LineBasicMaterial LineBasicMaterial creates a Three.js material object of the LineBasicMaterial class. This material can define a solid color for the line.
  • LineDashedMaterial LineDashedMaterial creates a Three.js material object of the LineDashedMaterial class. This material can define a dot-dash pattern for the line.
  • PointsMaterial PointsMaterial creates a PointsMaterial Three.js object. This material can be applied to Points geometry.

Textures

  • Texture Texture creates a Three.js Texture object.
  • CubeTexture CubeTexture creates a Three.js CubeTexture object. This can be used to define a scenes background.
  • ImageSettings Image Settings allows you to change the saturation, contrast, and lightness of an image (only works on Windows).
  • TextureSettings Texture Settings creates a Three.js
  • MeshStandardMaterialMaps MeshStandardMaterial Maps allows a user to define texture maps for MeshStandardMaterial.

Lighting

  • AmbientLight AmbientLight creates a Three.js AmbientLight object.
  • HemisphereLight HemisphereLight creates a Three.js HemisphereLight object.
  • DirectionalLight DirectionalLight creates a Three.js DirectionalLight object. Because of limitations with the Three.js ObjectLoader, the directional light's target is always set to the origin.
  • SpotLight SpotLight creates a Three.js SpotLight object. Because of limitations with the Three.js ObjectLoader, the spotlight's target is always set to the origin.
  • PointLight PointLight creates a Three.js PointLight object.
  • RectAreaLight RectAreaLight creates a Three.js RectAreaLight object.

Scene

  • Scene Scene creates a Scene object from one or more mesh geometries.
  • Scene Fog creates a Fog object.

File Management

  • WriteTextFile WriteTextFile writes a text file to a specific location.
  • ExportJSON ExportJSON creates a JSON string from any Three.js Object3d.
  • RelativePath RelativePath generates the file path to the location where the grasshopper is saved.
  • HTTPServer HTTPServer launches an HTTP server for testing your website (only works on Windows).

Example Scene

The example scene demonstrates how to export meshes with various materials and settings.

example scene

Chair

This example demonstrates some basic texture mapping.

example scene

House

This example shows how various geometry types and lighting can work together to create an architectural scene.

example scene

Development Environment

The plugin was developed in Visual Studio using the Grasshopper plugin template. The Visual Studio project folder is included in this repository.

Next steps

  • Automatically produce entire viewer website as index.html
  • Sprites
  • Geometry primitives (box, sphere, cone, etc.)
  • 2 sided materials
  • optional face indexing for meshes
  • meshLines
  • fat Lines
  • animate objects using GH slider to control the frames
  • clipping plane
  • depth texture
  • shaders

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.