ModelInstance.js 770 B

12345678910111213141516171819202122232425262728293031323334
  1. import Matrix4 from "../Core/Matrix4.js";
  2. /**
  3. * @private
  4. */
  5. function ModelInstance(collection, modelMatrix, instanceId) {
  6. this.primitive = collection;
  7. this._modelMatrix = Matrix4.clone(modelMatrix);
  8. this._instanceId = instanceId;
  9. }
  10. Object.defineProperties(ModelInstance.prototype, {
  11. instanceId: {
  12. get: function () {
  13. return this._instanceId;
  14. },
  15. },
  16. model: {
  17. get: function () {
  18. return this.primitive._model;
  19. },
  20. },
  21. modelMatrix: {
  22. get: function () {
  23. return Matrix4.clone(this._modelMatrix);
  24. },
  25. set: function (value) {
  26. Matrix4.clone(value, this._modelMatrix);
  27. this.primitive.expandBoundingSphere(this._modelMatrix);
  28. this.primitive._dirty = true;
  29. },
  30. },
  31. });
  32. export default ModelInstance;