哪里可以找到 Javascript 树创建器?

发布于 2024-08-31 19:51:55 字数 118 浏览 1 评论 0原文

您知道有哪个 Javascript 树创建器可以让您添加或删除最多 3 层深度的节点吗?

我目前正在使用 jQuery 树视图,但目前正在编写节点项的添加和删除代码,这很困难。

干杯, 标记

Do you know any Javascript Tree Creator that lets you add or remove nodes up to 3 levels deep?

I'm currently using the jQuery treeview but is currently coding the add and remove of node items which is hard.

Cheers,
Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

静谧 2024-09-07 19:51:55

检查我的 jtree,它有一个非常漂亮且简单的 api,带有一些编辑示例

check my one, jtree, it get a pretty nice and easy api, with some editing exemples

冷心人i 2024-09-07 19:51:55

试试这个

http://kazge.com/show/zkjs/src/tree.html< /a>

它支持复选框,以及更多功能

该项目的主页是 https://code.google.com /p/zkjs/

try this one

http://kazge.com/show/zkjs/src/tree.html

it support checkbox, and more feature

the project's home page is https://code.google.com/p/zkjs/

旧时浪漫 2024-09-07 19:51:55

这是一个actionscript版本,它有点像JS,除了线条渲染器/画布与JS不同。它将引导您找到更多脚本,因为该页面在网络上的某个地方充满了此代码的翻译:

此代码实际上是页面中某些代码的端口
http://rosettacode.org/wiki/Fractal_tree

[代码]

/*


  3D Fractal Tree

*/


    public var depth = 9;
    public var  angleSpread = 21.0;
    public var skew = 21.0;
    public var  branchMat : Material;
    public var  averaged = false;
    private var  deg_to_rad = 3.14159265 / 180.0;
    private var  scale = 0.50;
    private var  line : LineRenderer;
    private var  fractalTree : GameObject;
    private var  branch : GameObject;

    function Start () {
        //un-comment the line below to build the tree on start if not using MainController
        buildNewTree();
    }

    function killOldTree(){
        Destroy(fractalTree);   
    }

    function buildNewTree(){
        //Create a new empty gameObject to store our fractal tree
        fractalTree = new GameObject ("Fractal_Tree");
        fractalTree.transform.parent = gameObject.transform;
        if(averaged){angleSpread*=2;}
        drawTree(0.0, 0.0, 0.0, 0.0, 90.0, 90.0, depth);    
    }

    //A recursive function used to draw the fractal tree
    function drawTree( x1 : float,  y1 : float,  z1 : float,  y3 : float,  angle : float,  angle2 : float,  depth : int){
        if (depth != 0){
            //Set the x2 point
             var  x2  : float= x1 + (Mathf.Cos(angle * deg_to_rad) * depth * scale);

            //Set the z2 point
            var   z2  : float= z1 + (Mathf.Cos(angle2 * deg_to_rad) * depth * scale);

            //Set the y2 point
             var  y2  : float= y1 + (Mathf.Sin(angle * deg_to_rad) * depth * scale);

            //Set the y4 point
             var  y4  : float= y3 + (Mathf.Sin(angle2 * deg_to_rad) * depth * scale);

            //Average the y values
             var  n1 : float = (y3+y1)/2;
             var  n2  : float= (y4+y2)/2;

            //Call the drawline function, provide the coordinate data
            drawLine(x1, n1, z1, x2, n2, z2, depth);

            //Iterate the function recursively, change the rotation of the branches
            if(!averaged){
                if(depth % 2 == 0 ){
                    drawTree(x2, y2, z2, y4, angle - angleSpread - skew, angle2 - angleSpread- skew, depth - 1);
                    drawTree(x2, y2, z2, y4, angle + angleSpread - skew, angle2 + angleSpread- skew, depth - 1);
                }
                if(depth % 2 == 1 ){
                    drawTree(x2, y2, z2, y4, angle + angleSpread - skew, angle2-angleSpread- skew, depth - 1);
                    drawTree(x2, y2, z2, y4, angle - angleSpread - skew, angle2+angleSpread- skew, depth - 1);
                }
            }

            //Iterate the function recursively, change the rotation of the branches (rounded version)
            if(averaged){
                if(depth % 2 == 0 ){
                    drawTree(x2, y2, z2, y4, angle - angleSpread - skew, angle2 - skew, depth - 1);
                    drawTree(x2, y2, z2, y4, angle + angleSpread - skew, angle2 - skew, depth - 1);
                }
                if(depth % 2 == 1 ){                    
                    drawTree(x2, y2, z2, y4, angle - skew, angle2 - angleSpread - skew, depth  - 1);
                    drawTree(x2, y2, z2, y4, angle - skew, angle2 + angleSpread - skew, depth - 1);
                }
            }
        }
    }

    //Draws a single branch of the tree
    function drawLine(x1 : float,  y1 : float,  z1 : float,  x2 : float,  y2 : float,  z2 : float,  color : int){

        //Create a gameObject for the branch
        branch = new GameObject ("branch");

        //Make the branch child of the main gameobject
        branch.transform.parent = fractalTree.transform;

        //Add a line renderer to the branch gameobject
        line = branch.AddComponent("LineRenderer") ;//as LineRenderer;

        //Change the material of the LineRenderer
        line.material = branchMat;

        //Thin the branches through each iteration
        line.SetWidth(color*0.04, color*0.02);

        //Draw the line.
        line.SetPosition(0, new Vector3(x1,y1,z1));
        line.SetPosition(1, new Vector3(x2,y2,z2));
    }
[/code]

here is an actionscript version, it's abit like JS, except that the line renderer/canvas is different in JS. it will lead you to more scripts, as tehre is a page full of translations of this code somewhere on the net:

this code is actually a port of some code from a page
http://rosettacode.org/wiki/Fractal_tree

[code]

/*


  3D Fractal Tree

*/


    public var depth = 9;
    public var  angleSpread = 21.0;
    public var skew = 21.0;
    public var  branchMat : Material;
    public var  averaged = false;
    private var  deg_to_rad = 3.14159265 / 180.0;
    private var  scale = 0.50;
    private var  line : LineRenderer;
    private var  fractalTree : GameObject;
    private var  branch : GameObject;

    function Start () {
        //un-comment the line below to build the tree on start if not using MainController
        buildNewTree();
    }

    function killOldTree(){
        Destroy(fractalTree);   
    }

    function buildNewTree(){
        //Create a new empty gameObject to store our fractal tree
        fractalTree = new GameObject ("Fractal_Tree");
        fractalTree.transform.parent = gameObject.transform;
        if(averaged){angleSpread*=2;}
        drawTree(0.0, 0.0, 0.0, 0.0, 90.0, 90.0, depth);    
    }

    //A recursive function used to draw the fractal tree
    function drawTree( x1 : float,  y1 : float,  z1 : float,  y3 : float,  angle : float,  angle2 : float,  depth : int){
        if (depth != 0){
            //Set the x2 point
             var  x2  : float= x1 + (Mathf.Cos(angle * deg_to_rad) * depth * scale);

            //Set the z2 point
            var   z2  : float= z1 + (Mathf.Cos(angle2 * deg_to_rad) * depth * scale);

            //Set the y2 point
             var  y2  : float= y1 + (Mathf.Sin(angle * deg_to_rad) * depth * scale);

            //Set the y4 point
             var  y4  : float= y3 + (Mathf.Sin(angle2 * deg_to_rad) * depth * scale);

            //Average the y values
             var  n1 : float = (y3+y1)/2;
             var  n2  : float= (y4+y2)/2;

            //Call the drawline function, provide the coordinate data
            drawLine(x1, n1, z1, x2, n2, z2, depth);

            //Iterate the function recursively, change the rotation of the branches
            if(!averaged){
                if(depth % 2 == 0 ){
                    drawTree(x2, y2, z2, y4, angle - angleSpread - skew, angle2 - angleSpread- skew, depth - 1);
                    drawTree(x2, y2, z2, y4, angle + angleSpread - skew, angle2 + angleSpread- skew, depth - 1);
                }
                if(depth % 2 == 1 ){
                    drawTree(x2, y2, z2, y4, angle + angleSpread - skew, angle2-angleSpread- skew, depth - 1);
                    drawTree(x2, y2, z2, y4, angle - angleSpread - skew, angle2+angleSpread- skew, depth - 1);
                }
            }

            //Iterate the function recursively, change the rotation of the branches (rounded version)
            if(averaged){
                if(depth % 2 == 0 ){
                    drawTree(x2, y2, z2, y4, angle - angleSpread - skew, angle2 - skew, depth - 1);
                    drawTree(x2, y2, z2, y4, angle + angleSpread - skew, angle2 - skew, depth - 1);
                }
                if(depth % 2 == 1 ){                    
                    drawTree(x2, y2, z2, y4, angle - skew, angle2 - angleSpread - skew, depth  - 1);
                    drawTree(x2, y2, z2, y4, angle - skew, angle2 + angleSpread - skew, depth - 1);
                }
            }
        }
    }

    //Draws a single branch of the tree
    function drawLine(x1 : float,  y1 : float,  z1 : float,  x2 : float,  y2 : float,  z2 : float,  color : int){

        //Create a gameObject for the branch
        branch = new GameObject ("branch");

        //Make the branch child of the main gameobject
        branch.transform.parent = fractalTree.transform;

        //Add a line renderer to the branch gameobject
        line = branch.AddComponent("LineRenderer") ;//as LineRenderer;

        //Change the material of the LineRenderer
        line.material = branchMat;

        //Thin the branches through each iteration
        line.SetWidth(color*0.04, color*0.02);

        //Draw the line.
        line.SetPosition(0, new Vector3(x1,y1,z1));
        line.SetPosition(1, new Vector3(x2,y2,z2));
    }
[/code]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文