123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 |
- import defaultValue from "../Core/defaultValue.js";
- import defined from "../Core/defined.js";
- import PrimitiveType from "../Core/PrimitiveType.js";
- function DrawCommand(options) {
- options = defaultValue(options, defaultValue.EMPTY_OBJECT);
- this._boundingVolume = options.boundingVolume;
- this._orientedBoundingBox = options.orientedBoundingBox;
- this._cull = defaultValue(options.cull, true);
- this._occlude = defaultValue(options.occlude, true);
- this._modelMatrix = options.modelMatrix;
- this._primitiveType = defaultValue(
- options.primitiveType,
- PrimitiveType.TRIANGLES
- );
- this._vertexArray = options.vertexArray;
- this._count = options.count;
- this._offset = defaultValue(options.offset, 0);
- this._instanceCount = defaultValue(options.instanceCount, 0);
- this._shaderProgram = options.shaderProgram;
- this._uniformMap = options.uniformMap;
- this._renderState = options.renderState;
- this._framebuffer = options.framebuffer;
- this._pass = options.pass;
- this._executeInClosestFrustum = defaultValue(
- options.executeInClosestFrustum,
- false
- );
- this._owner = options.owner;
- this._debugShowBoundingVolume = defaultValue(
- options.debugShowBoundingVolume,
- false
- );
- this._debugOverlappingFrustums = 0;
- this._castShadows = defaultValue(options.castShadows, false);
- this._receiveShadows = defaultValue(options.receiveShadows, false);
- this._pickId = options.pickId;
- this._pickOnly = defaultValue(options.pickOnly, false);
- this.dirty = true;
- this.lastDirtyTime = 0;
-
- this.derivedCommands = {};
- }
- Object.defineProperties(DrawCommand.prototype, {
-
- boundingVolume: {
- get: function () {
- return this._boundingVolume;
- },
- set: function (value) {
- if (this._boundingVolume !== value) {
- this._boundingVolume = value;
- this.dirty = true;
- }
- },
- },
-
- orientedBoundingBox: {
- get: function () {
- return this._orientedBoundingBox;
- },
- set: function (value) {
- if (this._orientedBoundingBox !== value) {
- this._orientedBoundingBox = value;
- this.dirty = true;
- }
- },
- },
-
- cull: {
- get: function () {
- return this._cull;
- },
- set: function (value) {
- if (this._cull !== value) {
- this._cull = value;
- this.dirty = true;
- }
- },
- },
-
- occlude: {
- get: function () {
- return this._occlude;
- },
- set: function (value) {
- if (this._occlude !== value) {
- this._occlude = value;
- this.dirty = true;
- }
- },
- },
-
- modelMatrix: {
- get: function () {
- return this._modelMatrix;
- },
- set: function (value) {
- if (this._modelMatrix !== value) {
- this._modelMatrix = value;
- this.dirty = true;
- }
- },
- },
-
- primitiveType: {
- get: function () {
- return this._primitiveType;
- },
- set: function (value) {
- if (this._primitiveType !== value) {
- this._primitiveType = value;
- this.dirty = true;
- }
- },
- },
-
- vertexArray: {
- get: function () {
- return this._vertexArray;
- },
- set: function (value) {
- if (this._vertexArray !== value) {
- this._vertexArray = value;
- this.dirty = true;
- }
- },
- },
-
- count: {
- get: function () {
- return this._count;
- },
- set: function (value) {
- if (this._count !== value) {
- this._count = value;
- this.dirty = true;
- }
- },
- },
-
- offset: {
- get: function () {
- return this._offset;
- },
- set: function (value) {
- if (this._offset !== value) {
- this._offset = value;
- this.dirty = true;
- }
- },
- },
-
- instanceCount: {
- get: function () {
- return this._instanceCount;
- },
- set: function (value) {
- if (this._instanceCount !== value) {
- this._instanceCount = value;
- this.dirty = true;
- }
- },
- },
-
- shaderProgram: {
- get: function () {
- return this._shaderProgram;
- },
- set: function (value) {
- if (this._shaderProgram !== value) {
- this._shaderProgram = value;
- this.dirty = true;
- }
- },
- },
-
- castShadows: {
- get: function () {
- return this._castShadows;
- },
- set: function (value) {
- if (this._castShadows !== value) {
- this._castShadows = value;
- this.dirty = true;
- }
- },
- },
-
- receiveShadows: {
- get: function () {
- return this._receiveShadows;
- },
- set: function (value) {
- if (this._receiveShadows !== value) {
- this._receiveShadows = value;
- this.dirty = true;
- }
- },
- },
-
- uniformMap: {
- get: function () {
- return this._uniformMap;
- },
- set: function (value) {
- if (this._uniformMap !== value) {
- this._uniformMap = value;
- this.dirty = true;
- }
- },
- },
-
- renderState: {
- get: function () {
- return this._renderState;
- },
- set: function (value) {
- if (this._renderState !== value) {
- this._renderState = value;
- this.dirty = true;
- }
- },
- },
-
- framebuffer: {
- get: function () {
- return this._framebuffer;
- },
- set: function (value) {
- if (this._framebuffer !== value) {
- this._framebuffer = value;
- this.dirty = true;
- }
- },
- },
-
- pass: {
- get: function () {
- return this._pass;
- },
- set: function (value) {
- if (this._pass !== value) {
- this._pass = value;
- this.dirty = true;
- }
- },
- },
-
- executeInClosestFrustum: {
- get: function () {
- return this._executeInClosestFrustum;
- },
- set: function (value) {
- if (this._executeInClosestFrustum !== value) {
- this._executeInClosestFrustum = value;
- this.dirty = true;
- }
- },
- },
-
- owner: {
- get: function () {
- return this._owner;
- },
- set: function (value) {
- if (this._owner !== value) {
- this._owner = value;
- this.dirty = true;
- }
- },
- },
-
- debugShowBoundingVolume: {
- get: function () {
- return this._debugShowBoundingVolume;
- },
- set: function (value) {
- if (this._debugShowBoundingVolume !== value) {
- this._debugShowBoundingVolume = value;
- this.dirty = true;
- }
- },
- },
-
- debugOverlappingFrustums: {
- get: function () {
- return this._debugOverlappingFrustums;
- },
- set: function (value) {
- if (this._debugOverlappingFrustums !== value) {
- this._debugOverlappingFrustums = value;
- this.dirty = true;
- }
- },
- },
-
- pickId: {
- get: function () {
- return this._pickId;
- },
- set: function (value) {
- if (this._pickId !== value) {
- this._pickId = value;
- this.dirty = true;
- }
- },
- },
-
- pickOnly: {
- get: function () {
- return this._pickOnly;
- },
- set: function (value) {
- if (this._pickOnly !== value) {
- this._pickOnly = value;
- this.dirty = true;
- }
- },
- },
- });
- DrawCommand.shallowClone = function (command, result) {
- if (!defined(command)) {
- return undefined;
- }
- if (!defined(result)) {
- result = new DrawCommand();
- }
- result._boundingVolume = command._boundingVolume;
- result._orientedBoundingBox = command._orientedBoundingBox;
- result._cull = command._cull;
- result._occlude = command._occlude;
- result._modelMatrix = command._modelMatrix;
- result._primitiveType = command._primitiveType;
- result._vertexArray = command._vertexArray;
- result._count = command._count;
- result._offset = command._offset;
- result._instanceCount = command._instanceCount;
- result._shaderProgram = command._shaderProgram;
- result._uniformMap = command._uniformMap;
- result._renderState = command._renderState;
- result._framebuffer = command._framebuffer;
- result._pass = command._pass;
- result._executeInClosestFrustum = command._executeInClosestFrustum;
- result._owner = command._owner;
- result._debugShowBoundingVolume = command._debugShowBoundingVolume;
- result._debugOverlappingFrustums = command._debugOverlappingFrustums;
- result._castShadows = command._castShadows;
- result._receiveShadows = command._receiveShadows;
- result._pickId = command._pickId;
- result._pickOnly = command._pickOnly;
- result.dirty = true;
- result.lastDirtyTime = 0;
- return result;
- };
- DrawCommand.prototype.execute = function (context, passState) {
- context.draw(this, passState);
- };
- export default DrawCommand;
|