Code Monkey home page Code Monkey logo

kittycadjs-lite's Introduction

KittyCAD.js Lite

A custom KittyCAD API JS client which is manually maintained and does not follow the OpenAPI updates.

Usage

Either include the index.js in a <script></script> or use <script src="./index.js"></script> to have access to the KittyCADClient class.

You need a video element too:

<video id="stream" src=""/>

Remember to select the element with JS and pass it to KittyCADClient.

const streamEl = document.getElementById("stream");
KittyCADClient("zoo.dev", "API Token", streamEl, ...)

Initializating and usage is easy:

  KittyCADClient("zoo.dev", "API TOKEN", streamEl, () => {
    // You can now use any modeling command here!
    // Check the documentation for what's available:
    // https://zoo.dev/docs/api/modeling/open-a-websocket-which-accepts-modeling-commands?lang=rust#parameters-body-modeling_cmd_req-cmd

    // Example, that doesn't actually work, but what modeling commands
    // look like:
    default_camera_zoom({ magnitude: -25 });
    default_camera_look_at({
      center: { x: 0, y: 0, z: 0 },
      up: { x: 0, y: 0, z: 1 },
      vantage: { x: 0, y: -100, z: 75 },
    });
    const plane_id = make_plane({
      clobber: false,
      hide: true,
      origin: { x: 0, y: 0, z: 0 },
      size:  1,
      x_axis: {x: 1, y: 0, z: 0},
      y_axis: {x: 0, y: 1, z: 0},
    });
    enable_sketch_mode({
      entity_id: plane_id,
      ortho: false,
      animated: false,
      adjust_camera: false,
    });
    const path = start_path();
    move_path_pen({ path, to: { x: 0, y: 0, z: 0 }});
    extend_path({
      path,
      segment: {
        type: "line",
        end: { x, y, z: 0 },
        relative: false,
      }
    });
    close_path({ path_id: path });
    sketch_mode_disable();

    done();
  })

kittycadjs-lite's People

Contributors

lf94 avatar

Watchers

Jonathan Tran avatar Adam Sunderland avatar Adam Chalmers avatar Mike Farrell avatar David Harvey-Macaulay avatar Vonni Williams avatar Pierre Jacquier avatar Ben Crabbe avatar

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.