LiteGraph.js库的自定义节点项详细做法

function define_filter_document_node_test() {
    //document filter
    //node constructor class
    function MyAddNode() {
        this.properties = { value: "Aa", values: "Aa;Bb;Cc" };
        this._values = this.properties.values.split(";"); 
        var that = this;
        this.widget = this.addWidget("combo", "name",
            this.properties.value, function (v) {
            that.properties.value = v;
            that.triggerSlot(1, v);  },
            { property: "value", values: this._values }
        );

        this.addOutput("res", "string");
        this.properties = { precision: 1 };
    }

    //name to show
    MyAddNode.title = "document_filter";

    var resData =01;
    //function to call when the node is executed
    MyAddNode.prototype.onExecute = function () {
         callbackObj.getElementBy(this.properties.value).then(function (res) {
            resData = res;
        });
        this.setOutputData(0, resData);
    }

    //register in the system
    LiteGraph.registerNodeType("basic/filter_document_node", MyAddNode);

}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值