PHP 7.4.33
Preview: StorageArrayElementNode.js Size: 2.62 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/three/src/nodes/utils/StorageArrayElementNode.js
import { nodeProxy } from '../tsl/TSLBase.js';
import ArrayElementNode from './ArrayElementNode.js';

/**
 * This class enables element access on instances of {@link StorageBufferNode}.
 * In most cases, it is indirectly used when accessing elements with the
 * {@link StorageBufferNode#element} method.
 *
 * ```js
 * const position = positionStorage.element( instanceIndex );
 * ```
 *
 * @augments ArrayElementNode
 */
class StorageArrayElementNode extends ArrayElementNode {

	static get type() {

		return 'StorageArrayElementNode';

	}

	/**
	 * Constructs storage buffer element node.
	 *
	 * @param {StorageBufferNode} storageBufferNode - The storage buffer node.
	 * @param {Node} indexNode - The index node that defines the element access.
	 */
	constructor( storageBufferNode, indexNode ) {

		super( storageBufferNode, indexNode );

		/**
		 * This flag can be used for type testing.
		 *
		 * @type {boolean}
		 * @readonly
		 * @default true
		 */
		this.isStorageArrayElementNode = true;

	}

	/**
	 * The storage buffer node.
	 *
	 * @param {Node} value
	 * @type {StorageBufferNode}
	 */
	set storageBufferNode( value ) {

		this.node = value;

	}

	get storageBufferNode() {

		return this.node;

	}

	getMemberType( builder, name ) {

		const structTypeNode = this.storageBufferNode.structTypeNode;

		if ( structTypeNode ) {

			return structTypeNode.getMemberType( builder, name );

		}

		return 'void';

	}

	setup( builder ) {

		if ( builder.isAvailable( 'storageBuffer' ) === false ) {

			if ( this.node.isPBO === true ) {

				builder.setupPBO( this.node );

			}

		}

		return super.setup( builder );

	}

	generate( builder, output ) {

		let snippet;

		const isAssignContext = builder.context.assign;

		//

		if ( builder.isAvailable( 'storageBuffer' ) === false ) {

			if ( this.node.isPBO === true && isAssignContext !== true && ( this.node.value.isInstancedBufferAttribute || builder.shaderStage !== 'compute' ) ) {

				snippet = builder.generatePBO( this );

			} else {

				snippet = this.node.build( builder );

			}

		} else {

			snippet = super.generate( builder );

		}

		if ( isAssignContext !== true ) {

			const type = this.getNodeType( builder );

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

		}

		return snippet;

	}

}

export default StorageArrayElementNode;

/**
 * TSL function for creating a storage element node.
 *
 * @tsl
 * @function
 * @param {StorageBufferNode} storageBufferNode - The storage buffer node.
 * @param {Node} indexNode - The index node that defines the element access.
 * @returns {StorageArrayElementNode}
 */
export const storageElement = /*@__PURE__*/ nodeProxy( StorageArrayElementNode );

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).