{"version":3,"sources":["assets/home/home.ts"],"names":["_a","cc","_decorator","ccclass","property","Home","_super","__extends","_this","apply","this","arguments","objectNumLabel","objectNumSlider","enbaleMultiNode","objects","nums","num","enableMultiRender","prefabs","prototype","onLoad","children","concat","removeAllChildren","CC_JSB","node","on","slider","offset","progress","Math","ceil","numUpdate","toggle","isChecked","multiRenderUpdate","string","length","i","createObject","destroy","reCreateObjects","destroyAllChildren","random","floor","instantiate","comp","_c","_b","getComponent","Label","Sprite","RichText","sp","Skeleton","autoSwitchMaterial","RenderComponent","EnableType","ENABLE","allowDynamicAtlas","addChild","position","v3","width","height","tween","by","angle","repeatForever","start","__decorate","Slider","Node","Component","exports","default"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAM,IAAAA,KAAAC,GAAAC,YAAAC,UAAAH,GAAAG,SAAAC,WAAAJ,GAAAI;IAGN,IAAAC,OAAA,SAAAC;MAAkCC,UAAAF,MAAAC;MAAlC,SAAAD;QAAA,IAAAG,QAAA,SAAAF,UAAAA,OAAAG,MAAAC,MAAAC,cAAAD;QAGIF,MAAAI,iBAAA;QAGAJ,MAAAK,kBAAA;QAGAL,MAAAM,kBAAA;QAGAN,MAAAO,UAAA;QAEAP,MAAAQ,OAAA,EAAA,IAAA;QACAR,MAAAS,MAAAT,MAAAQ,KAAA;QAEAR,MAAAU,oBAAA;QAEAV,MAAAW,UAAA;;;MAEUd,KAAAe,UAAAC,SAAA;QAAV,IAAAb,QAAAE;QACIA,KAAAS,UAAAT,KAAAK,QAAAO,SAAAC;QACAb,KAAAK,QAAAS,kBAAA;QAGAC;QAIAf,KAAAG,gBAAAa,KAAAC,GAAA,SAAA,SAAAC;UACI,IAAAC,UAAArB,MAAAQ,KAAA,KAAAR,MAAAQ,KAAA,MAAAY,OAAAE;UACAtB,MAAAS,MAAAT,MAAAQ,KAAA,KAAAe,KAAAC,KAAAH;UACArB,MAAAyB;;QAGJvB,KAAAI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D,gBAAAC,WAAAC;UACAZ,KAAAa,oBAAA3D,GAAAwD,gBAAAC,WAAAC;;QAGJjD,KAAAK,QAAA8C,SAAAnC;QAEAA,KAAAoC,WAAA7D,GAAA8D,GAAAhC,KAAAc,MAAAd,KAAAa,WAAAlC,KAAAK,QAAAiD,QAAAjC,KAAAc,MAAAd,KAAAa,WAAAlC,KAAAK,QAAAkD;QACAhE,GAAAiE,MAAAxC,MAAAyC,GAAA,GAAA;UAAAC,OAAA;WAAAC,gBAAAC;;MA1FJC,WAAA,EADCnE,SAAAH,GAAAkD,UAC+B9C,KAAAe,WAAA,uBAAA;MAGhCmD,WAAA,EADCnE,SAAAH,GAAAuE,WACiCnE,KAAAe,WAAA,wBAAA;MAGlCmD,WAAA,EADCnE,SAAAH,GAAAwE,SAC+BpE,KAAAe,WAAA,wBAAA;MAGhCmD,WAAA,EADCnE,SAAAH,GAAAwE,SACuBpE,KAAAe,WAAA,gBAAA;MAZPf,OAAAkE,WAAA,EADpBpE,WACoBE;MAgGrB,OAAAA;KAhGA,CAAAJ,GAAAyE;IAAqBC,QAAAC,UAAAvE","sourcesContent":["const { ccclass, property } = cc._decorator;\n\n@ccclass\nexport default class Home extends cc.Component {\n\n @property(cc.Label)\n objectNumLabel: cc.Label = null;\n\n @property(cc.Slider)\n objectNumSlider: cc.Slider = null;\n\n @property(cc.Node)\n enbaleMultiNode: cc.Node = null;\n\n @property(cc.Node)\n objects: cc.Node = null;\n\n nums = [10, 10000];\n num = this.nums[0];\n\n enableMultiRender = true;\n\n prefabs: cc.Node[] = [];\n\n protected onLoad(): void {\n this.prefabs = this.objects.children.concat();\n this.objects.removeAllChildren(false);\n\n // Native 暂不支持 Spine 组件与其它组件合批\n if (CC_JSB) {\n this.prefabs = this.prefabs.filter(v => !v.getComponent(sp.Skeleton));\n }\n\n this.objectNumSlider.node.on('slide', (slider: cc.Slider) => {\n const offset = (this.nums[1] - this.nums[0]) * slider.progress;\n this.num = this.nums[0] + Math.ceil(offset);\n this.numUpdate();\n });\n\n this.enbaleMultiNode.on('toggle', (toggle: cc.Toggle) => {\n this.enableMultiRender = toggle.isChecked;\n this.multiRenderUpdate();\n });\n\n this.objectNumSlider.progress = 0.02;\n const offset = (this.nums[1] - this.nums[0]) * this.objectNumSlider.progress;\n this.num = this.nums[0] + Math.ceil(offset);\n this.numUpdate();\n this.multiRenderUpdate();\n }\n\n\n numUpdate() {\n this.objectNumLabel.string = `对象数量:${this.num}`;\n\n let offset = this.num - this.objects.children.length;\n\n if (offset > 0) {\n for (let i = 0; i < offset; i++) {\n this.createObject();\n }\n } else {\n offset = -offset;\n for (let i = 0; i < offset; i++) {\n this.objects.children[i].destroy();\n }\n }\n }\n\n\n multiRenderUpdate() {\n this.reCreateObjects();\n }\n\n\n reCreateObjects() {\n this.objects.destroyAllChildren();\n for (let i = 0; i < this.num; i++) {\n this.createObject();\n }\n }\n\n\n createObject() {\n const random = Math.floor(Math.random() * this.prefabs.length);\n const node = cc.instantiate(this.prefabs[random]);\n\n if (this.enableMultiRender) {\n const comp = node.getComponent(cc.Label) ?? node.getComponent(cc.Sprite) ?? node.getComponent(cc.RichText) ?? node.getComponent(sp.Skeleton);\n comp.autoSwitchMaterial = cc.RenderComponent.EnableType.ENABLE;\n comp.allowDynamicAtlas = cc.RenderComponent.EnableType.ENABLE;\n }\n\n this.objects.addChild(node);\n\n node.position = cc.v3(Math.floor(Math.random() * this.objects.width), Math.floor(Math.random() * this.objects.height));\n cc.tween(node).by(3, { angle: 360 }).repeatForever().start();\n }\n\n}\n"],"file":"index.js"}