PHP 7.4.33
Preview: ConvertNode.js Size: 1.92 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/three/src/nodes/utils/ConvertNode.js
import Node from '../core/Node.js';

/**
 * This module is part of the TSL core and usually not used in app level code.
 * It represents a convert operation during the shader generation process
 * meaning it converts the data type of a node to a target data type.
 *
 * @augments Node
 */
class ConvertNode extends Node {

	static get type() {

		return 'ConvertNode';

	}

	/**
	 * Constructs a new convert node.
	 *
	 * @param {Node} node - The node which type should be converted.
	 * @param {string} convertTo - The target node type. Multiple types can be defined by separating them with a `|` sign.
	 */
	constructor( node, convertTo ) {

		super();

		/**
		 * The node which type should be converted.
		 *
		 * @type {Node}
		 */
		this.node = node;

		/**
		 * The target node type. Multiple types can be defined by separating them with a `|` sign.
		 *
		 * @type {string}
		 */
		this.convertTo = convertTo;

	}

	/**
	 * This method is overwritten since the implementation tries to infer the best
	 * matching type from the {@link ConvertNode#convertTo} property.
	 *
	 * @param {NodeBuilder} builder - The current node builder.
	 * @return {string} The node type.
	 */
	getNodeType( builder ) {

		const requestType = this.node.getNodeType( builder );

		let convertTo = null;

		for ( const overloadingType of this.convertTo.split( '|' ) ) {

			if ( convertTo === null || builder.getTypeLength( requestType ) === builder.getTypeLength( overloadingType ) ) {

				convertTo = overloadingType;

			}

		}

		return convertTo;

	}

	serialize( data ) {

		super.serialize( data );

		data.convertTo = this.convertTo;

	}

	deserialize( data ) {

		super.deserialize( data );

		this.convertTo = data.convertTo;

	}

	generate( builder, output ) {

		const node = this.node;
		const type = this.getNodeType( builder );

		const snippet = node.build( builder, type );

		return builder.format( snippet, type, output );

	}

}

export default ConvertNode;

Directory Contents

Dirs: 0 × Files: 28
Name Size Perms Modified Actions
1.37 KB lrw-r--r-- 2025-03-28 11:04:37
Edit Download
1.92 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
5.23 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
814 B lrw-r--r-- 2025-03-28 11:04:38
Edit Download
1.47 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
2.32 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
2.91 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
1.92 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
6.33 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
1.08 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
1.95 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
999 B lrw-r--r-- 2025-03-28 11:04:38
Edit Download
1.15 KB lrw-r--r-- 2025-03-28 11:04:38
Edit Download
560 B lrw-r--r-- 2025-03-28 11:04:38
Edit Download
4.31 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
13.47 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
3.23 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
2.91 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
6.16 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
2.31 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
3.25 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
2.14 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.81 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
2.62 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.78 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
4.46 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1.14 KB lrw-r--r-- 2025-03-28 11:04:39
Edit Download
1008 B lrw-r--r-- 2025-03-28 11:04:39
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).