{"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","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;QAEAd,KAAAG,gBAAAY,KAAAC,GAAA,SAAA,SAAAC;UACI,IAAAC,UAAApB,MAAAQ,KAAA,KAAAR,MAAAQ,KAAA,MAAAW,OAAAE;UACArB,MAAAS,MAAAT,MAAAQ,KAAA,KAAAc,KAAAC,KAAAH;UACApB,MAAAwB;;QAGJtB,KAAAI,gBAAAY,GAAA,U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,QAAAjC,KAAAc,MAAAd,KAAAa,WAAAjC,KAAAK,QAAAiD;QACA/D,GAAAgE,MAAAxC,MAAAyC,GAAA,GAAA;UAAAC,OAAA;WAAAC,gBAAAC;;MAlFJC,WAAA,EADClE,SAAAH,GAAAiD,UAC+B7C,KAAAe,WAAA,uBAAA;MAGhCkD,WAAA,EADClE,SAAAH,GAAAsE,WACiClE,KAAAe,WAAA,wBAAA;MAGlCkD,WAAA,EADClE,SAAAH,GAAAuE,SAC+BnE,KAAAe,WAAA,wBAAA;MAGhCkD,WAAA,EADClE,SAAAH,GAAAuE,SACuBnE,KAAAe,WAAA,gBAAA;MAZPf,OAAAiE,WAAA,EADpBnE,WACoBE;MAwFrB,OAAAA;KAxFA,CAAAJ,GAAAwE;IAAqBC,QAAAC,UAAAtE","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 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.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(1, { angle: 360 }).repeatForever().start();\n }\n\n}\n"],"file":"index.js"}