123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- /*global define*/
- define([
- '../Core/defaultValue',
- '../Core/PrimitiveType'
- ], function(
- defaultValue,
- PrimitiveType) {
- "use strict";
- /**
- * Represents a command to the renderer for drawing.
- *
- * @private
- */
- var DrawCommand = function(options) {
- options = defaultValue(options, defaultValue.EMPTY_OBJECT);
- /**
- * The bounding volume of the geometry in world space. This is used for culling and frustum selection.
- * <p>
- * For best rendering performance, use the tightest possible bounding volume. Although
- * <code>undefined</code> is allowed, always try to provide a bounding volume to
- * allow the tightest possible near and far planes to be computed for the scene, and
- * minimize the number of frustums needed.
- * </p>
- *
- * @type {Object}
- * @default undefined
- *
- * @see DrawCommand#debugShowBoundingVolume
- */
- this.boundingVolume = options.boundingVolume;
- /**
- * When <code>true</code>, the renderer frustum and horizon culls the command based on its {@link DrawCommand#boundingVolume}.
- * If the command was already culled, set this to <code>false</code> for a performance improvement.
- *
- * @type {Boolean}
- * @default true
- */
- this.cull = defaultValue(options.cull, true);
- /**
- * The transformation from the geometry in model space to world space.
- * <p>
- * When <code>undefined</code>, the geometry is assumed to be defined in world space.
- * </p>
- *
- * @type {Matrix4}
- * @default undefined
- */
- this.modelMatrix = options.modelMatrix;
- /**
- * The type of geometry in the vertex array.
- *
- * @type {PrimitiveType}
- * @default PrimitiveType.TRIANGLES
- */
- this.primitiveType = defaultValue(options.primitiveType, PrimitiveType.TRIANGLES);
- /**
- * The vertex array.
- *
- * @type {VertexArray}
- * @default undefined
- */
- this.vertexArray = options.vertexArray;
- /**
- * The number of vertices to draw in the vertex array.
- *
- * @type {Number}
- * @default undefined
- */
- this.count = options.count;
- /**
- * The offset to start drawing in the vertex array.
- *
- * @type {Number}
- * @default 0
- */
- this.offset = defaultValue(options.offset, 0);
- /**
- * The shader program to apply.
- *
- * @type {ShaderProgram}
- * @default undefined
- */
- this.shaderProgram = options.shaderProgram;
- /**
- * An object with functions whose names match the uniforms in the shader program
- * and return values to set those uniforms.
- *
- * @type {Object}
- * @default undefined
- */
- this.uniformMap = options.uniformMap;
- /**
- * The render state.
- *
- * @type {RenderState}
- * @default undefined
- *
- * @see Context#createRenderState
- */
- this.renderState = options.renderState;
- /**
- * The framebuffer to draw to.
- *
- * @type {Framebuffer}
- * @default undefined
- */
- this.framebuffer = options.framebuffer;
- /**
- * The pass when to render.
- *
- * @type {Pass}
- * @default undefined
- */
- this.pass = options.pass;
- /**
- * Specifies if this command is only to be executed in the frustum closest
- * to the eye containing the bounding volume. Defaults to <code>false</code>.
- *
- * @type {Boolean}
- * @default false
- */
- this.executeInClosestFrustum = defaultValue(options.executeInClosestFrustum, false);
- /**
- * The object who created this command. This is useful for debugging command
- * execution; it allows us to see who created a command when we only have a
- * reference to the command, and can be used to selectively execute commands
- * with {@link Scene#debugCommandFilter}.
- *
- * @type {Object}
- * @default undefined
- *
- * @see Scene#debugCommandFilter
- */
- this.owner = options.owner;
- /**
- * This property is for debugging only; it is not for production use nor is it optimized.
- * <p>
- * Draws the {@link DrawCommand#boundingVolume} for this command, assuming it is a sphere, when the command executes.
- * </p>
- *
- * @type {Boolean}
- * @default false
- *
- * @see DrawCommand#boundingVolume
- */
- this.debugShowBoundingVolume = defaultValue(options.debugShowBoundingVolume, false);
- /**
- * Used to implement Scene.debugShowFrustums.
- * @private
- */
- this.debugOverlappingFrustums = 0;
- /**
- * @private
- */
- this.oit = undefined;
- };
- /**
- * Executes the draw command.
- *
- * @param {Context} context The renderer context in which to draw.
- * @param {PassState} [passState] The state for the current render pass.
- * @param {RenderState} [renderState] The render state that will override the render state of the command.
- * @param {ShaderProgram} [shaderProgram] The shader program that will override the shader program of the command.
- */
- DrawCommand.prototype.execute = function(context, passState, renderState, shaderProgram) {
- context.draw(this, passState, renderState, shaderProgram);
- };
- return DrawCommand;
- });
|