Drawing a circular spline in JS
Does someone have a simple script to help me?
I’m getting nowhere.
Does someone have a simple script to help me?
I’m getting nowhere.
Here is one for an ellipse spline from Herb: http://www.cheetah3d.com/forum/showthread.php?t=6607
Maybe you can use parts of it.
// Circle.js
//
// Based off of SineCircle (c) 2005 Martin Wengenmayer
//
// This script is in the public domain. Feel free to modify it or use
// it as a starting point for your own creations.
//
// Purpose:
// Demonstrates how to create a custom spline object.
// Goes in the /Scripts/Splineobj/ folder.
function buildUI(obj){
obj.setParameter("name","Circle");
obj.addParameterFloat("Diameter", 0.5, 0.001, 1000.0, true, true);
}
function buildObject(obj) {
var diameter = obj.getParameter("Diameter");
var spline=obj.core();
var pos = new Vec3D(0, 0, 1);
spline.move(pos);
for(var i=1; i<=360; i++) {
var ii=Math.PI*2*i/360;
pos = new Vec3D(Math.sin(ii) * diameter, 0, Math.cos(ii) * diameter);
spline.line(pos);
}
}
var circle = doc.document().addObject(SCRIPTSPLINE);
circle.setParameter("scriptName", "Scripts/Splineobj/Circle.js");
circle.setParameter("name", "Circle Script");
circle.setCreatorObj(true);
circle.update();