How to use the babylonjs-editor.Tools.GetConstructorName function in babylonjs-editor

To help you get started, we’ve selected a few babylonjs-editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BabylonJS / Editor / src / tools / graph-behavior / graph-node-tool.ts View on Github external
this.tool.add(node.properties, property.name, property.enums).name(property.name).onChange(r => {
                    if (property.enumsTarget)
                        node.properties[property.name] = property.enumsTarget[r];
                });
                continue;
            }

            // Variable
            if (property.name === 'Variable') {
                const variables = node.graph.variables.map(v => v.name);
                this.tool.add(node.properties, property.name, variables).name(property.name);
                continue;
            }

            // Other
            const ctor = Tools.GetConstructorName(value).toLowerCase();

            switch (ctor) {
                // Primitives
                case 'number':
                case 'string':
                case 'boolean':
                    this.tool.add(node.properties, property.name).name(property.name);
                    break;

                // Vectors
                case 'array':
                    switch (value.length) {
                        case 2:
                        case 3:
                        case 4:
                            const names = ['x', 'y', 'z', 'w'];
github BabylonJS / Editor / src / tools / graph-behavior / graph-node-tool.ts View on Github external
private _setupNodeType (node: GraphTypeNode): void {
        const value = node.properties.value;
        const ctor = Tools.GetConstructorName(value).toLowerCase();

        switch (ctor) {
            // Primitives
            case 'number':
            case 'string':
            case 'boolean':
                this.tool.add(node.properties, 'value').name('Value');
                break;

            // Vectors
            case 'array':
                switch (value.length) {
                    case 2:
                    case 3:
                    case 4:
                        const names = ['x', 'y', 'z', 'w'];
github BabylonJS / Editor / src / tools / behavior / code.ts View on Github external
protected add (): void {
        let ctor = Tools.GetConstructorName(this.node).toLowerCase();
        if (this.node instanceof DirectionalLight)
            ctor = "dirlight";
        else if (this.node instanceof HemisphericLight)
            ctor = "hemlight";

        const data: BehaviorCode = {
            name: 'New Script',
            active: true,
            code: this.template.replace(/{{type}}/g, ctor)
        };
        this.datas.metadatas.push(data);

        this.grid.addRow({
            recid: this.datas.metadatas.length - 1,
            name: data.name
        });
github BabylonJS / Editor / src / tools / graph-behavior / graph-tool.ts View on Github external
private _getType (value: any): string {
        const ctor = Tools.GetConstructorName(value).toLowerCase();
        switch (ctor) {
            case 'string': return 'String';
            case 'number': return 'Number';
            case 'boolean': return 'Boolean';
            case 'array':
                switch (value.length) {
                    case 2: return 'Vector 2D';
                    case 3: return 'Vector 3D';
                    case 4: return 'Vector 4D';
                    default: debugger; return null;
                }
            default: debugger; return null;
        }
    }
}