b3ff355a89ef5979c929d7f95b62ab9520647b59.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. System.register(["cc"], function (_export, _context) {
  2. "use strict";
  3. var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, _decorator, Camera, Component, gfx, MeshRenderer, RenderTexture, view, _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _crd, ccclass, property, RtToModel;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. return {
  8. setters: [function (_cc) {
  9. _cclegacy = _cc.cclegacy;
  10. __checkObsolete__ = _cc.__checkObsolete__;
  11. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  12. _decorator = _cc._decorator;
  13. Camera = _cc.Camera;
  14. Component = _cc.Component;
  15. gfx = _cc.gfx;
  16. MeshRenderer = _cc.MeshRenderer;
  17. RenderTexture = _cc.RenderTexture;
  18. view = _cc.view;
  19. }],
  20. execute: function () {
  21. _crd = true;
  22. _cclegacy._RF.push({}, "dbd7dMQYutDs7I7uj+3zIiU", "RtToModel", undefined);
  23. __checkObsolete__(['_decorator', 'Camera', 'Component', 'gfx', 'MeshRenderer', 'RenderTexture', 'view']);
  24. ({
  25. ccclass,
  26. property
  27. } = _decorator);
  28. /** 三维摄像机内容显示到模型上 */
  29. _export("RtToModel", RtToModel = (_dec = ccclass('RtToModel'), _dec2 = property(Camera), _dec3 = property(MeshRenderer), _dec(_class = (_class2 = class RtToModel extends Component {
  30. constructor(...args) {
  31. super(...args);
  32. _initializerDefineProperty(this, "camara", _descriptor, this);
  33. _initializerDefineProperty(this, "model", _descriptor2, this);
  34. this.rt = new RenderTexture();
  35. }
  36. start() {
  37. const size = view.getVisibleSize();
  38. const colorAttachment = new gfx.ColorAttachment();
  39. const depthStencilAttachment = new gfx.DepthStencilAttachment();
  40. const pi = new gfx.RenderPassInfo([colorAttachment], depthStencilAttachment);
  41. this.rt.reset({
  42. width: size.width,
  43. height: size.height,
  44. passInfo: pi
  45. });
  46. this.camara.targetTexture = this.rt;
  47. const mat = this.model.material;
  48. mat.setProperty('mainTexture', this.rt);
  49. }
  50. onDestroy() {
  51. this.rt.destroy();
  52. }
  53. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "camara", [_dec2], {
  54. configurable: true,
  55. enumerable: true,
  56. writable: true,
  57. initializer: function () {
  58. return null;
  59. }
  60. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "model", [_dec3], {
  61. configurable: true,
  62. enumerable: true,
  63. writable: true,
  64. initializer: function () {
  65. return null;
  66. }
  67. })), _class2)) || _class));
  68. _cclegacy._RF.pop();
  69. _crd = false;
  70. }
  71. };
  72. });
  73. //# sourceMappingURL=b3ff355a89ef5979c929d7f95b62ab9520647b59.js.map