ModelRenderResources.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import Check from "../../Core/Check.js";
  2. import ModelAlphaOptions from "./ModelAlphaOptions.js";
  3. import RenderState from "../../Renderer/RenderState.js";
  4. import ShaderBuilder from "../../Renderer/ShaderBuilder.js";
  5. import DepthFunction from "../DepthFunction.js";
  6. /**
  7. * Model render resources are for setting details that are consistent across
  8. * the entire model.
  9. *
  10. * @constructor
  11. * @param {Model} model The model that will be rendered
  12. *
  13. * @private
  14. */
  15. function ModelRenderResources(model) {
  16. //>>includeStart('debug', pragmas.debug);
  17. Check.typeOf.object("model", model);
  18. //>>includeEnd('debug');
  19. /**
  20. * An object used to build a shader incrementally. Each pipeline stage
  21. * may add lines of shader code to this object.
  22. *
  23. * @type {ShaderBuilder}
  24. * @readonly
  25. *
  26. * @private
  27. */
  28. this.shaderBuilder = new ShaderBuilder();
  29. /**
  30. * A reference to the model.
  31. *
  32. * @type {Model}
  33. * @readonly
  34. *
  35. * @private
  36. */
  37. this.model = model;
  38. /**
  39. * A dictionary mapping uniform name to functions that return the uniform
  40. * values.
  41. *
  42. * @type {Object<string, Function>}
  43. * @readonly
  44. *
  45. * @private
  46. */
  47. this.uniformMap = {};
  48. /**
  49. * Options for configuring the alpha stage such as pass and alpha cutoff.
  50. *
  51. * @type {ModelAlphaOptions}
  52. * @readonly
  53. *
  54. * @private
  55. */
  56. this.alphaOptions = new ModelAlphaOptions();
  57. /**
  58. * An object storing options for creating a {@link RenderState}.
  59. * The pipeline stages simply set the options, the render state is created
  60. * when the {@link DrawCommand} is constructed.
  61. *
  62. * @type {object}
  63. * @readonly
  64. *
  65. * @private
  66. */
  67. this.renderStateOptions = RenderState.getState(
  68. RenderState.fromCache({
  69. depthTest: {
  70. enabled: true,
  71. func: DepthFunction.LESS_OR_EQUAL,
  72. },
  73. })
  74. );
  75. /**
  76. * Whether the model has a silhouette. This value indicates what draw commands
  77. * are needed and is set by ModelSilhouettePipelineStage.
  78. *
  79. * @type {boolean}
  80. * @default false
  81. *
  82. * @private
  83. */
  84. this.hasSilhouette = false;
  85. /**
  86. * Whether the model is part of a tileset that uses the skipLevelOfDetail
  87. * optimization. This value indicates what draw commands are needed and
  88. * is set by TilesetPipelineStage.
  89. *
  90. * @type {boolean}
  91. * @default false
  92. *
  93. * @private
  94. */
  95. this.hasSkipLevelOfDetail = false;
  96. }
  97. export default ModelRenderResources;