ModelMesh.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import defineProperties from '../Core/defineProperties.js';
  2. /**
  3. * A model's mesh and its materials.
  4. * <p>
  5. * Use {@link Model#getMesh} to create an instance.
  6. * </p>
  7. *
  8. * @alias ModelMesh
  9. * @internalConstructor
  10. * @class
  11. *
  12. * @see Model#getMesh
  13. */
  14. function ModelMesh(mesh, runtimeMaterialsById, id) {
  15. var materials = [];
  16. var primitives = mesh.primitives;
  17. var length = primitives.length;
  18. for (var i = 0; i < length; ++i) {
  19. var p = primitives[i];
  20. materials[i] = runtimeMaterialsById[p.material];
  21. }
  22. this._name = mesh.name;
  23. this._materials = materials;
  24. this._id = id;
  25. }
  26. defineProperties(ModelMesh.prototype, {
  27. /**
  28. * The value of the <code>name</code> property of this mesh.
  29. *
  30. * @memberof ModelMesh.prototype
  31. *
  32. * @type {String}
  33. * @readonly
  34. */
  35. name : {
  36. get : function() {
  37. return this._name;
  38. }
  39. },
  40. /**
  41. * The index of the mesh.
  42. *
  43. * @memberof ModelMesh.prototype
  44. *
  45. * @type {String}
  46. * @readonly
  47. */
  48. id : {
  49. get : function() {
  50. return this._id;
  51. }
  52. },
  53. /**
  54. * An array of {@link ModelMaterial} instances indexed by the mesh's
  55. * primitive indices.
  56. *
  57. * @memberof ModelMesh.prototype
  58. *
  59. * @type {ModelMaterial[]}
  60. * @readonly
  61. */
  62. materials : {
  63. get : function() {
  64. return this._materials;
  65. }
  66. }
  67. });
  68. export default ModelMesh;